中国星际RPG联盟

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4354|回复: 0
打印 上一主题 下一主题

18号导入单位模型 5.16版本跨系统

[复制链接]
跳转到指定楼层
楼主
发表于 2013-8-22 23:51:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  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))0x004ED12C;

  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.     void * (WINAPI*sc_VirtualAlloc)(void *, SIZE_T, DWORD, DWORD);

  79.     if(!(*sc_SFileOpenArchive)((char*)0x509364, 0, 0, &mpq)) return false;
  80.     if(!(*sc_SFileOpenFileEx)(mpq, (*GetResString)(params->Text), 0, &file)) return false;
  81.     siz=(*sc_SFileGetFileSize)(file, 0);
  82.     _asm
  83.     {
  84.         push 40h
  85.         push 1000h
  86.         push eax
  87.         push 0
  88.         _EMIT 0xFF
  89.         _EMIT 0x15
  90.         _EMIT 0x2C
  91.         _EMIT 0xD1
  92.         _EMIT 0x4E
  93.         _EMIT 0x00//VirtuaAlloc
  94.         mov dest,eax
  95.     }
  96.     (*sc_SFileReadFile)(file, dest, siz, &siz, 0);
  97.     (*sc_SFileCloseFile)(file);
  98.     (*sc_SFileCloseArchive)(mpq);

  99.     siz = *(unsigned __int16 *)dest;//取帧数
  100.     buffer = (unsigned int *)(((int)dest) + 10);//取第一帧的offset地址
  101.     while(siz)
  102.     {
  103.         *buffer += (unsigned int)dest;
  104.         buffer += 2;//+8就是下一帧,因为是int*
  105.         siz--;
  106.     }
  107.     *(unsigned int *)params->Code = (unsigned int)dest;//修改指针 you le?...1级的改法
  108.     return true;

  109. }



  110. void AfterFunction(){}
  111. LPCSTR Base64Enc(int size = 0)
  112. {
  113.     if (size <= 0)
  114.         size = PtrToLong((PBYTE)AfterFunction - (PBYTE)Comment);
  115.     PBYTE text = (PBYTE)Comment;
  116.     PBYTE out = new BYTE[(size - 1) * 4 / 3 + 1],buf = out;
  117.     int buflen = 0;

  118.     while(size>0)
  119.     {
  120.         *buf++ = ((text[0] >> 2 ) & 0x3f) + 0x30;
  121.         *buf++ = (((text[0] & 3) << 4) | (text[1] >> 4)) + 0x30;
  122.         *buf++ = (((text[1] & 0xF) << 2) | (text[2] >> 6)) + 0x30;
  123.         *buf++ = (text[2] & 0x3F) + 0x30;

  124.         text +=3;
  125.         size -=3;
  126.         buflen +=4;
  127.     }

  128.     *buf = 0;
  129.     return (LPCSTR)out;
  130. }


  131. int main(int argc, CHAR* argv[])
  132. {
  133.      malloc(1);   
  134.     FILE *f1=fopen("d:\\desktop\\comment18.txt","wb");
  135.     fprintf(f1,"Comment(\"%s\", 0, 0, 18, 0, 1);\n",Base64Enc());
  136.     fclose(f1);
  137.     int i;
  138. }



  139. Comment("EH_\Pn`@EUN=AO1@<oIFEVQTTe00RoWo5KcBCP25`7D7<l3YR@0006J;C`B=AOQ@E[R0R4@0om1@ogG`oaEXddh0QL1dfeKoMOSo5ESCCP29AOaZ@6P04000D6X0oaD\dDh0RDGdEXe5o53oMOcoMOCoMOSo5ECCCP3oMOSo5F3CCP3oMO3o5L3BCP2;AO@?]a29EOb=B0XkeW@=0@6;AOB3`@SoCOaelh]?28T1<l10Gek9`l=A", 0, 0, 18, 0, 1);
复制代码
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 顶 踩
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-29 18:43 , Processed in 1.156243 second(s), 19 queries .

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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