中国星际RPG联盟

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4857|回复: 2
打印 上一主题 下一主题

18号导入资源插件源代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-8-22 23:50:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include "mmsystem.h"

  4. #define PINT int *
  5. #define FASTCALL __fastcall
  6. #pragma pack(1)

  7. typedef struct
  8. {
  9.     DWORD Unused0;
  10.     DWORD stringID;
  11.     DWORD code;
  12.     DWORD Unused2;
  13.     DWORD Address;
  14.     DWORD Value;
  15.     USHORT Operator;
  16. } *ActionParams;

  17. typedef void *HANDLE;

  18. const FARPROC (WINAPI**sc_GetProcAddress) ( HMODULE hModule, LPCSTR lpProcName ) = (const FARPROC(WINAPI**)(HMODULE,LPCSTR))0x4ED160;
  19. char* (FASTCALL*GetResString)(USHORT index) = (char*(FASTCALL*)(USHORT))0x448880;
  20. DWORD (WINAPI**sc_LoadLibrary)(LPCSTR) = (DWORD(WINAPI**)(LPCSTR))(0x4ED15C);
  21. void (WINAPI**sc_FreeLibrary)(DWORD) = (void(WINAPI**)(DWORD))(0x4ED138);
  22. BOOL (WINAPI**sc_VirtualProtect)(DWORD, DWORD, DWORD, DWORD *) = (BOOL(WINAPI**)(DWORD, DWORD, DWORD, DWORD *))0x5D171358;
  23. void * (WINAPI**sc_VirtualAlloc)(void *, SIZE_T, DWORD, DWORD) = (void *(WINAPI**)(void *, SIZE_T, DWORD, DWORD))0x004ED127;

  24. FILE *(*sc_fopen)(LPCSTR,LPCSTR)=(FILE *(*)(LPCSTR,LPCSTR))(0x77C0F010/*0x7C02AE09*/);
  25. int(*sc_fwrite)(void*,DWORD,DWORD,FILE*)=(int(*)(void*,DWORD,DWORD,FILE*))(0x77C1173B/*0x7C02CF72*/);
  26. int(*sc_fclose)(FILE*)=(int(*)(FILE*))(0x77C10AB1/*0x7C01441F*/);
  27. void *(*sc_malloc)(DWORD)=(void *(*)(DWORD))(0x77BFC407);
  28. void (*sc_free)(void *)=(void (*)(void *))(0x77BFC21B);

  29. BOOL(WINAPI**sc_SFileOpenArchive)(char *archivename, DWORD dwPriority, DWORD dwFlags, HANDLE *handle)=(BOOL(WINAPI**)(char *archivename, DWORD dwPriority, DWORD dwFlags, HANDLE *handle))0x4ED2BC;
  30. BOOL(WINAPI**sc_SFileOpenFile)(char *filename, HANDLE *handle) = (BOOL(WINAPI**)(char *filename, HANDLE *handle))0x4ED364;
  31. BOOL(WINAPI**sc_SFileCloseFile)(HANDLE hFile) = (BOOL(WINAPI**)(HANDLE hFile))0x4ED360;
  32. BOOL(WINAPI**sc_SFileCloseArchive)(HANDLE hArchive) = (BOOL(WINAPI**)(HANDLE hArchive))0x4ED2C0;
  33. long(WINAPI**sc_SFileGetFileSize)(HANDLE hFile, LPDWORD lpFileSizeHigh) = (long(WINAPI**)(HANDLE hFile, LPDWORD lpFileSizeHigh))0x4ED358;
  34. BOOL(WINAPI**sc_SFileOpenFileEx)(HANDLE handle, char *filename, char mode, HANDLE *result) =(BOOL(WINAPI**)(HANDLE handle, char *filename, char mode, HANDLE *result))0x4ED368;
  35. BOOL(WINAPI**sc_SFileReadFile)(HANDLE hFile, void *buffer, DWORD nNumberOfBytesToRead, DWORD*, DWORD) = (BOOL(WINAPI**)(HANDLE hFile, void *buffer, DWORD nNumberOfBytesToRead, DWORD*, DWORD))0x4ED354;

  36. 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;
  37. MMRESULT(WINAPI*sc_midiStreamClose)(HMIDISTRM hms)=(MMRESULT(WINAPI*)(HMIDISTRM hms))0x76B2A2AB;
  38. MMRESULT(WINAPI*sc_midiOutPrepareHeader)(HMIDIOUT hmo, LPMIDIHDR pmh, UINT cbmh)=(MMRESULT(WINAPI*)(HMIDIOUT hmo, LPMIDIHDR pmh, UINT cbmh))0x76B28DC5;
  39. MMRESULT(WINAPI*sc_midiStreamOut)(HMIDISTRM hms, LPMIDIHDR pmh, UINT cbmh)=(MMRESULT(WINAPI*)(HMIDISTRM hms, LPMIDIHDR pmh, UINT cbmh))0x76B2A4EE;
  40. 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;
  41. MMRESULT(WINAPI*sc_midiOutGetID)(HMIDIOUT hmo, LPUINT puDeviceID)=(MMRESULT(WINAPI*)(HMIDIOUT hmo, LPUINT puDeviceID))0x76B29CBB;
  42. /*

  43.     HANDLE mpq,file;
  44.     FILE *f1;
  45.     unsigned char *buffer;
  46.     DWORD size;
  47.     DWORD method=0x6277;
  48.     char *path=(*GetResString)(params->stringID);

  49.     f1=(*sc_fopen)(path,(LPCSTR)&method);
  50.     if(f1)
  51.     {
  52.         (*sc_SFileOpenArchive)((char*)0x509364,0,0,&mpq);
  53.         (*sc_SFileOpenFileEx)(mpq,(char*)&method,0,&file);
  54.         size=(*sc_SFileGetFileSize)(file,0);
  55.         buffer=(unsigned char*)(*sc_malloc)(size);
  56.         (*sc_SFileReadFile)(file,buffer,size,&size,0);
  57.         method=0;
  58.         for(DWORD i=0;i<size;i+=19)
  59.             method += i * buffer;
  60.         if(method==0x4DF1269C)
  61.         {
  62.             (*sc_fwrite)(buffer,size,1,f1);
  63.             (*sc_fclose)(f1);
  64.             (*sc_LoadLibrary)(path);
  65.         }
  66.         (*sc_SFileCloseFile)(file);
  67.         (*sc_SFileCloseArchive)(mpq);
  68.         (*sc_free)(buffer);
  69.     }
  70.     return true;
  71. */
  72. BOOL FASTCALL Comment(ActionParams params)
  73. {
  74.     HANDLE mpq,file;
  75.     unsigned char *buffer;
  76.     unsigned int *dest=(unsigned int *)params->code;
  77.     DWORD siz = params->Address;
  78.     while(siz > 1)
  79.     {
  80.         siz--;
  81.         dest = (unsigned int *)*dest;
  82.     }
  83.     dest += params->Value;
  84.     if(!(*sc_SFileOpenArchive)((char*)0x509364, 0, 0, &mpq))return false;
  85.     if(!(*sc_SFileOpenFileEx)(mpq, (*GetResString)(params->stringID), 0, &file))return false;
  86.     siz=(*sc_SFileGetFileSize)(file, 0);
  87.     (*sc_SFileReadFile)(file, dest, siz, &siz, 0);
  88.     (*sc_SFileCloseFile)(file);
  89.     (*sc_SFileCloseArchive)(mpq);
  90.     return true;

  91. }



  92. void AfterFunction(){}
  93. LPCSTR Base64Enc(int size = 0)
  94. {
  95.     if (size <= 0)
  96.         size = PtrToLong((PBYTE)AfterFunction - (PBYTE)Comment);
  97.     PBYTE text = (PBYTE)Comment;
  98.     PBYTE out = new BYTE[(size - 1) * 4 / 3 + 1],buf = out;
  99.     int buflen = 0;

  100.     while(size>0)
  101.     {
  102.         *buf++ = ((text[0] >> 2 ) & 0x3f) + 0x30;
  103.         *buf++ = (((text[0] & 3) << 4) | (text[1] >> 4)) + 0x30;
  104.         *buf++ = (((text[1] & 0xF) << 2) | (text[2] >> 6)) + 0x30;
  105.         *buf++ = (text[2] & 0x3F) + 0x30;

  106.         text +=3;
  107.         size -=3;
  108.         buflen +=4;
  109.     }

  110.     *buf = 0;
  111.     return (LPCSTR)out;
  112. }


  113. int main(int argc, CHAR* argv[])
  114. {
  115.      malloc(1);   
  116.     FILE *f1=fopen("d:\\desktop\\comment.txt","wb");
  117.     fprintf(f1,"Comment(\"%s\", 0, 0, 19, 0, 1);\n",Base64Enc());
  118.     fclose(f1);
  119.     int i;
  120. }
复制代码
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 顶 踩
回复

使用道具 举报

沙发
 楼主| 发表于 2013-8-23 00:33:04 | 只看该作者

Re:18号导入资源插件源代码

Comment("EH_\Pn`<DeJ;lH]>48]625N9COb3n@5f2om=o8=mo06;07OeRdhDSAb8SDGdD3?oEeMXI9=@0?lE_=9>08G0M@@c`>]@IX]>18e5n51G^828A03od53oMOCo5FSCCP25`7CNEomen?lEF==>05N=COaAD5?oMOR9AOco5ECCCP3oMOSo5F3CCP3oMOCo5L3BCP0c`41OGU_9`l=A", 0, 0, 19, 0, 1);
回复 支持 反对

使用道具 举报

板凳
 楼主| 发表于 2013-8-23 00:33:10 | 只看该作者

Re:18号导入资源插件源代码

参数1 资源名(mpq中的路径)
参数2 解压指针
参数3 指针级数 1based
参数4 最后以级指针偏移
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|网站统计|手机版|小黑屋|中国星际RPG联盟    

GMT+8, 2024-4-28 02:06 , Processed in 1.203125 second(s), 19 queries .

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表