• Welcome to Valhalla Legends Archive.
 

Extracting Data From Mpq

Started by TheNewOne, May 13, 2004, 09:35 AM

Previous topic - Next topic

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.

Eric

#1
This can be done by using Storm.dll's API calls.

QuoteStorm_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 *)

Eibro

#2
Quote from: LoRd[nK] on May 13, 2004, 10:25 AM
This can be done by using Storm.dll's API calls.

QuoteStorm_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 *)
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.
Eibro of Yeti Lovers.

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.

iago

Yeah, what Skywing said.

Also, many of those are named wrong.

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)


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.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


UserLoser.

Quote from: Skywing on May 13, 2004, 09:32 PM
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.

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?)

phvckmeh

how would u do this in vb6? like to extract a cdkey

TheNewOne

Use the info they gave us and convert. If it doesnt work try use other info on the net. Try google.

UserLoser.

Quote from: phvckmeh on May 15, 2004, 06:33 PM
how would u do this in vb6? like to extract a cdkey

You wouldn't use any of the functions posted from Storm to extract a CDKey

Skywing

Quote from: UserLoser. on May 14, 2004, 03:59 PM
Quote from: Skywing on May 13, 2004, 09:32 PM
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.

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?)
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.

Maddox

I wouldn't think it would be that hard to dump those tables and reinitialize them afterwards.
asdf.

Skywing

Quote from: Maddox on May 19, 2004, 08:20 PM
I wouldn't think it would be that hard to dump those tables and reinitialize them afterwards.
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.

Maddox

#12
That assumes all initialized data is on the stack (which is probably true).
asdf.

Skywing

Quote from: Maddox on May 24, 2004, 05:01 PM
That assumes all initialized data is on the stack (which is probably true).
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.