中国星际RPG联盟

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4430|回复: 1
打印 上一主题 下一主题

18号替换单位外形插件源代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-8-22 23:51:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  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 Text;//1
  11.     DWORD Code;//2
  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 int *buffer;
  76.     unsigned int *dest;
  77.     DWORD siz;

  78.     if(!(*sc_SFileOpenArchive)((char*)0x509364, 0, 0, &mpq)) return false;
  79.     if(!(*sc_SFileOpenFileEx)(mpq, (*GetResString)(params->Text), 0, &file)) return false;
  80.     siz=(*sc_SFileGetFileSize)(file, 0);
  81.     dest=(unsigned int *)(*sc_malloc)(siz);
  82.     (*sc_SFileReadFile)(file, dest, siz, &siz, 0);
  83.     (*sc_SFileCloseFile)(file);
  84.     (*sc_SFileCloseArchive)(mpq);

  85.     siz = *(unsigned __int16 *)dest;//取帧数
  86.     buffer = (unsigned int *)(((int)dest) + 10);//取第一帧的offset地址
  87.     while(siz)
  88.     {
  89.         *buffer += (unsigned int)dest;
  90.         buffer += 2;//+8就是下一帧,因为是int*
  91.         siz--;
  92.     }
  93.     *(unsigned int *)params->Code = (unsigned int)dest;//修改指针 you le?...1级的改法
  94.     return true;

  95. }



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

  104.     while(size>0)
  105.     {
  106.         *buf++ = ((text[0] >> 2 ) & 0x3f) + 0x30;
  107.         *buf++ = (((text[0] & 3) << 4) | (text[1] >> 4)) + 0x30;
  108.         *buf++ = (((text[1] & 0xF) << 2) | (text[2] >> 6)) + 0x30;
  109.         *buf++ = (text[2] & 0x3F) + 0x30;

  110.         text +=3;
  111.         size -=3;
  112.         buflen +=4;
  113.     }

  114.     *buf = 0;
  115.     return (LPCSTR)out;
  116. }


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

使用道具 举报

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

Re:18号替换单位外形插件源代码

Comment("EH_\Pn`<DeN=AOA@<omGEfQTTe00RmWo5KcBCP25`7D4<l3[NfJ;B`B=AOQ@EkR0R4@0om1@ogGdoaEXddh0QL1dgUIGogGhoaEHddh0RDGlD;P7a;mgom1IEh_`SDGlD?meo5KoMOSo5ECCCP3oMOSo5F3CCP3oMOCo5L3BCP0?]`j9COb=APXkcg@:0C23`0SoCOaemX]328T`<l10GUmKbL?3", 0, 0, 18, 0, 1);

参数1 资源文件名
参数2 指针
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-14 14:43 , Processed in 1.140610 second(s), 19 queries .

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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