Valhalla Legends Forums Archive | Battle.net Bot Development | Extracting Data From Mpq

AuthorMessageTime
TheNewOne
is there any documents on how someone would go about doing this? All links and support are appreciated.

Edit: Extracting Data From Mpq is what i ment for documents on it.
May 13, 2004, 2:35 PM
LoRd
This can be done by using Storm.dll's API calls.

[quote][code]Storm_252 - int SFileCloseArchive(HANDLE hArchive);
Storm_253 - int SFileCloseFile(HANDLE hFile);
Storm_262 - int SFileDestroy();
Storm_265 - int SFileGetFileSize(HANDLE hFile, int * fileSizeHigh);
Storm_266 - int SFileOpenArchive(char * name, int flags, int, HANDLE * hArchive);
Storm_268 - int SFileOpenFileEx(HANDLE hArchive, char * fileName, int, HANDLE * hFile);
Storm_269 - int SFileReadFile(HANDLE hFile, void * buffer, int toRead, int * read, int);
Storm_271 - int SFileSetFilePointer(HANDLE hFile, int filePos, int * filePosHigh, int method);

Storm_465 - int setLastError(DWORD dwErrCode)

Storm_491 - int memcpy(void *src, void *dst, int count)
Storm_494 - int ZeroMemory(void *buf, int count)

Storm_501 - int memcpy(char *dst, char *src, int count)
Storm_506 - int strlen(char *string)
Storm_510 - int _strupr(char *)
Storm_579 - int _strlwr(char *)[/code][/quote]
May 13, 2004, 3:25 PM
Eibro
[quote author=LoRd[nK] link=board=17;threadid=6785;start=0#msg59983 date=1084461937]
This can be done by using Storm.dll's API calls.

[quote][code]Storm_252 - int SFileCloseArchive(HANDLE hArchive);
Storm_253 - int SFileCloseFile(HANDLE hFile);
Storm_262 - int SFileDestroy();
Storm_265 - int SFileGetFileSize(HANDLE hFile, int * fileSizeHigh);
Storm_266 - int SFileOpenArchive(char * name, int flags, int, HANDLE * hArchive);
Storm_268 - int SFileOpenFileEx(HANDLE hArchive, char * fileName, int, HANDLE * hFile);
Storm_269 - int SFileReadFile(HANDLE hFile, void * buffer, int toRead, int * read, int);
Storm_271 - int SFileSetFilePointer(HANDLE hFile, int filePos, int * filePosHigh, int method);

Storm_465 - int setLastError(DWORD dwErrCode)

Storm_491 - int memcpy(void *src, void *dst, int count)
Storm_494 - int ZeroMemory(void *buf, int count)

Storm_501 - int memcpy(char *dst, char *src, int count)
Storm_506 - int strlen(char *string)
Storm_510 - int _strupr(char *)
Storm_579 - int _strlwr(char *)[/code][/quote]
[/quote]AFAIK, the calling convention of those functions should be __stdcall. Also, the return value of SFile* functions would be better represented as a BOOL.
Edit: In addition, SSetLastError doesn't return anything.
May 13, 2004, 9:37 PM
Skywing
Remember that you need to be careful about dynamic linking storm, because it tries to overwrite some of the tables used for mpq decoding if it discovers you using LoadLibrary on it.
May 14, 2004, 2:32 AM
iago
Yeah, what Skywing said.

Also, many of those are named wrong.

[code]465   SErrSetLastError(DWORD dwErrCode)
491   int SMemCpy(void *src, void *dst, int count)
494   int SMemZero(void *buf, int count)
501   int SStrCpy(char *dst, char *src, int count)
506   int SStrLen(char *str)
510   int SStrUpr(char *str)
579   SStrLwr(char *str)
[/code]

It's possible I got return values wrong, I didn't double check those. And I'm not 100% sure about the names of the last two (SStrUpr, SStrLwr), somebody sent me those ones and I didn't doublecheck.
May 14, 2004, 6:26 PM
UserLoser.
[quote author=Skywing link=board=17;threadid=6785;start=0#msg60054 date=1084501953]
Remember that you need to be careful about dynamic linking storm, because it tries to overwrite some of the tables used for mpq decoding if it discovers you using LoadLibrary on it.
[/quote]

I load Storm.dll via LoadLibrary on my VB client, and I can extract only some files which seem to be extracted ok, such as prepatch.lst, patch.txt, BNUpdate.exe, ect.. But as far as files such as Starcraft.exe, Storm.dll, and Battle.snp, those don't come out correctly? (or someone said blizzard bytecode or something like that?)
May 14, 2004, 8:59 PM
phvckmeh
how would u do this in vb6? like to extract a cdkey
May 15, 2004, 11:33 PM
TheNewOne
Use the info they gave us and convert. If it doesnt work try use other info on the net. Try google.
May 16, 2004, 1:07 AM
UserLoser.
[quote author=phvckmeh link=board=17;threadid=6785;start=0#msg60308 date=1084664031]
how would u do this in vb6? like to extract a cdkey
[/quote]

You wouldn't use any of the functions posted from Storm to extract a CDKey
May 16, 2004, 1:11 AM
Skywing
[quote author=UserLoser. link=board=17;threadid=6785;start=0#msg60131 date=1084568358]
[quote author=Skywing link=board=17;threadid=6785;start=0#msg60054 date=1084501953]
Remember that you need to be careful about dynamic linking storm, because it tries to overwrite some of the tables used for mpq decoding if it discovers you using LoadLibrary on it.
[/quote]

I load Storm.dll via LoadLibrary on my VB client, and I can extract only some files which seem to be extracted ok, such as prepatch.lst, patch.txt, BNUpdate.exe, ect.. But as far as files such as Starcraft.exe, Storm.dll, and Battle.snp, those don't come out correctly? (or someone said blizzard bytecode or something like that?)
[/quote]
It's possible that Blizzard removed their protection. For a long time, Storm.dll would destroy the datatables used for MPQ processing if you tried to LoadLibrary it. I suppose they don't much care about people reading MPQs anymore though.
May 18, 2004, 12:12 AM
Maddox
I wouldn't think it would be that hard to dump those tables and reinitialize them afterwards.
May 20, 2004, 1:20 AM
Skywing
[quote author=Maddox link=board=17;threadid=6785;start=0#msg60895 date=1085016028]
I wouldn't think it would be that hard to dump those tables and reinitialize them afterwards.
[/quote]
You could probably do that. There are easier ways though, that don't require any particular Storm.dll version, such as calling DllMain yourself for DLL_PROCESS_ATTACH again, but with the optional PCONTEXT set appropriately for a static link attach.
May 24, 2004, 3:11 AM
Maddox
That assumes all initialized data is on the stack (which is probably true).
May 24, 2004, 10:01 PM
Skywing
[quote author=Maddox link=board=17;threadid=6785;start=0#msg61621 date=1085436076]
That assumes all initialized data is on the stack (which is probably true).
[/quote]
No, it doesn't. It's in Storm's data section, and Storm's DllMain initializes all of the relevant data on DLL_PROCESS_ATTACH.
May 27, 2004, 1:25 AM

Search