|
- #include <stdio.h>
- #include <windows.h>
- #include "mmsystem.h"
- #define PINT int *
- #define FASTCALL __fastcall
- #pragma pack(1)
- typedef struct
- {
- DWORD Unused0;
- DWORD stringID;
- DWORD code;
- DWORD Unused2;
- DWORD Address;
- DWORD Value;
- USHORT Operator;
- } *ActionParams;
- typedef void *HANDLE;
- const FARPROC (WINAPI**sc_GetProcAddress) ( HMODULE hModule, LPCSTR lpProcName ) = (const FARPROC(WINAPI**)(HMODULE,LPCSTR))0x4ED160;
- char* (FASTCALL*GetResString)(USHORT index) = (char*(FASTCALL*)(USHORT))0x448880;
- DWORD (WINAPI**sc_LoadLibrary)(LPCSTR) = (DWORD(WINAPI**)(LPCSTR))(0x4ED15C);
- void (WINAPI**sc_FreeLibrary)(DWORD) = (void(WINAPI**)(DWORD))(0x4ED138);
- BOOL (WINAPI**sc_VirtualProtect)(DWORD, DWORD, DWORD, DWORD *) = (BOOL(WINAPI**)(DWORD, DWORD, DWORD, DWORD *))0x5D171358;
- void * (WINAPI**sc_VirtualAlloc)(void *, SIZE_T, DWORD, DWORD) = (void *(WINAPI**)(void *, SIZE_T, DWORD, DWORD))0x004ED127;
- FILE *(*sc_fopen)(LPCSTR,LPCSTR)=(FILE *(*)(LPCSTR,LPCSTR))(0x77C0F010/*0x7C02AE09*/);
- int(*sc_fwrite)(void*,DWORD,DWORD,FILE*)=(int(*)(void*,DWORD,DWORD,FILE*))(0x77C1173B/*0x7C02CF72*/);
- int(*sc_fclose)(FILE*)=(int(*)(FILE*))(0x77C10AB1/*0x7C01441F*/);
- void *(*sc_malloc)(DWORD)=(void *(*)(DWORD))(0x77BFC407);
- void (*sc_free)(void *)=(void (*)(void *))(0x77BFC21B);
- BOOL(WINAPI**sc_SFileOpenArchive)(char *archivename, DWORD dwPriority, DWORD dwFlags, HANDLE *handle)=(BOOL(WINAPI**)(char *archivename, DWORD dwPriority, DWORD dwFlags, HANDLE *handle))0x4ED2BC;
- BOOL(WINAPI**sc_SFileOpenFile)(char *filename, HANDLE *handle) = (BOOL(WINAPI**)(char *filename, HANDLE *handle))0x4ED364;
- BOOL(WINAPI**sc_SFileCloseFile)(HANDLE hFile) = (BOOL(WINAPI**)(HANDLE hFile))0x4ED360;
- BOOL(WINAPI**sc_SFileCloseArchive)(HANDLE hArchive) = (BOOL(WINAPI**)(HANDLE hArchive))0x4ED2C0;
- long(WINAPI**sc_SFileGetFileSize)(HANDLE hFile, LPDWORD lpFileSizeHigh) = (long(WINAPI**)(HANDLE hFile, LPDWORD lpFileSizeHigh))0x4ED358;
- BOOL(WINAPI**sc_SFileOpenFileEx)(HANDLE handle, char *filename, char mode, HANDLE *result) =(BOOL(WINAPI**)(HANDLE handle, char *filename, char mode, HANDLE *result))0x4ED368;
- BOOL(WINAPI**sc_SFileReadFile)(HANDLE hFile, void *buffer, DWORD nNumberOfBytesToRead, DWORD*, DWORD) = (BOOL(WINAPI**)(HANDLE hFile, void *buffer, DWORD nNumberOfBytesToRead, DWORD*, DWORD))0x4ED354;
- MMRESULT(WINAPI*sc_midiStreamOpen)(LPHMIDISTRM phms, LPUINT puDeviceID, DWORD cMidi, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen) = (MMRESULT(WINAPI*)(LPHMIDISTRM phms, LPUINT puDeviceID, DWORD cMidi, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen))0x76B29F78;
- MMRESULT(WINAPI*sc_midiStreamClose)(HMIDISTRM hms)=(MMRESULT(WINAPI*)(HMIDISTRM hms))0x76B2A2AB;
- MMRESULT(WINAPI*sc_midiOutPrepareHeader)(HMIDIOUT hmo, LPMIDIHDR pmh, UINT cbmh)=(MMRESULT(WINAPI*)(HMIDIOUT hmo, LPMIDIHDR pmh, UINT cbmh))0x76B28DC5;
- MMRESULT(WINAPI*sc_midiStreamOut)(HMIDISTRM hms, LPMIDIHDR pmh, UINT cbmh)=(MMRESULT(WINAPI*)(HMIDISTRM hms, LPMIDIHDR pmh, UINT cbmh))0x76B2A4EE;
- MMRESULT(WINAPI*sc_midiOutOpen)(LPHMIDIOUT phmo,UINT uDeviceID,DWORD_PTR dwCallback,DWORD_PTR dwInstance, DWORD fdwOpen)=(MMRESULT(WINAPI*)(LPHMIDIOUT phmo,UINT uDeviceID,DWORD_PTR dwCallback,DWORD_PTR dwInstance, DWORD fdwOpen))0x76B28B74;
- MMRESULT(WINAPI*sc_midiOutGetID)(HMIDIOUT hmo, LPUINT puDeviceID)=(MMRESULT(WINAPI*)(HMIDIOUT hmo, LPUINT puDeviceID))0x76B29CBB;
- /*
- HANDLE mpq,file;
- FILE *f1;
- unsigned char *buffer;
- DWORD size;
- DWORD method=0x6277;
- char *path=(*GetResString)(params->stringID);
- f1=(*sc_fopen)(path,(LPCSTR)&method);
- if(f1)
- {
- (*sc_SFileOpenArchive)((char*)0x509364,0,0,&mpq);
- (*sc_SFileOpenFileEx)(mpq,(char*)&method,0,&file);
- size=(*sc_SFileGetFileSize)(file,0);
- buffer=(unsigned char*)(*sc_malloc)(size);
- (*sc_SFileReadFile)(file,buffer,size,&size,0);
- method=0;
- for(DWORD i=0;i<size;i+=19)
- method += i * buffer;
- if(method==0x4DF1269C)
- {
- (*sc_fwrite)(buffer,size,1,f1);
- (*sc_fclose)(f1);
- (*sc_LoadLibrary)(path);
- }
- (*sc_SFileCloseFile)(file);
- (*sc_SFileCloseArchive)(mpq);
- (*sc_free)(buffer);
- }
- return true;
- */
- BOOL FASTCALL Comment(ActionParams params)
- {
- HANDLE mpq,file;
- unsigned char *buffer;
- unsigned int *dest=(unsigned int *)params->code;
- DWORD siz = params->Address;
- while(siz > 1)
- {
- siz--;
- dest = (unsigned int *)*dest;
- }
- dest += params->Value;
- if(!(*sc_SFileOpenArchive)((char*)0x509364, 0, 0, &mpq))return false;
- if(!(*sc_SFileOpenFileEx)(mpq, (*GetResString)(params->stringID), 0, &file))return false;
- siz=(*sc_SFileGetFileSize)(file, 0);
- (*sc_SFileReadFile)(file, dest, siz, &siz, 0);
- (*sc_SFileCloseFile)(file);
- (*sc_SFileCloseArchive)(mpq);
- return true;
- }
- void AfterFunction(){}
- LPCSTR Base64Enc(int size = 0)
- {
- if (size <= 0)
- size = PtrToLong((PBYTE)AfterFunction - (PBYTE)Comment);
- PBYTE text = (PBYTE)Comment;
- PBYTE out = new BYTE[(size - 1) * 4 / 3 + 1],buf = out;
- int buflen = 0;
- while(size>0)
- {
- *buf++ = ((text[0] >> 2 ) & 0x3f) + 0x30;
- *buf++ = (((text[0] & 3) << 4) | (text[1] >> 4)) + 0x30;
- *buf++ = (((text[1] & 0xF) << 2) | (text[2] >> 6)) + 0x30;
- *buf++ = (text[2] & 0x3F) + 0x30;
- text +=3;
- size -=3;
- buflen +=4;
- }
- *buf = 0;
- return (LPCSTR)out;
- }
- int main(int argc, CHAR* argv[])
- {
- malloc(1);
- FILE *f1=fopen("d:\\desktop\\comment.txt","wb");
- fprintf(f1,"Comment(\"%s\", 0, 0, 19, 0, 1);\n",Base64Enc());
- fclose(f1);
- int i;
- }
复制代码 |
|