中国星际RPG联盟

 找回密码
 注册

QQ登录

只需一步,快速开始

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

17号播放Midi插件

[复制链接]
跳转到指定楼层
楼主
发表于 2013-8-22 23:51:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #pragma comment(lib,"ole32.lib")
  4. #pragma comment(lib,"dxguid.lib")
  5. #include "dmusici.h"
  6. #include "windows.h"
  7. #define DMUS_SEG_REPEAT_INFINITE 0xFFFFFFFF

  8. #define PINT int *
  9. #define FASTCALL __fastcall
  10. #pragma pack(1)

  11. typedef struct
  12. {
  13.     DWORD Unused0;
  14.     DWORD Text;//1
  15.     DWORD Code;//2
  16.     DWORD Unused2;//
  17.     DWORD Address;
  18.     DWORD Value;
  19.     USHORT Operator;
  20. } *ActionParams;

  21. typedef void *HANDLE;

  22. const FARPROC (WINAPI**sc_GetProcAddress) ( HMODULE hModule, LPCSTR lpProcName ) = (const FARPROC(WINAPI**)(HMODULE,LPCSTR))0x4ED160;
  23. const FARPROC (WINAPI**sc_GetProcAddress1) (void) = (const FARPROC(WINAPI**)(void))0x4ED160;
  24. char* (FASTCALL*GetResString)(USHORT index) = (char*(FASTCALL*)(USHORT))0x448880;
  25. DWORD (WINAPI**sc_LoadLibrary)(LPCSTR) = (DWORD(WINAPI**)(LPCSTR))(0x4ED15C);
  26. void (WINAPI**sc_FreeLibrary)(DWORD) = (void(WINAPI**)(DWORD))(0x4ED138);
  27. BOOL (WINAPI**sc_VirtualProtect)(DWORD, DWORD, DWORD, DWORD *) = (BOOL(WINAPI**)(DWORD, DWORD, DWORD, DWORD *))0x5D171358;
  28. void * (WINAPI**sc_VirtualAlloc)(void *, SIZE_T, DWORD, DWORD) = (void *(WINAPI**)(void *, SIZE_T, DWORD, DWORD))0x004ED127;

  29. FILE *(*sc_fopen)(LPCSTR,LPCSTR)=(FILE *(*)(LPCSTR,LPCSTR))(0x77C0F010/*0x7C02AE09*/);
  30. int(*sc_fwrite)(void*,DWORD,DWORD,FILE*)=(int(*)(void*,DWORD,DWORD,FILE*))(0x77C1173B/*0x7C02CF72*/);
  31. int(*sc_fclose)(FILE*)=(int(*)(FILE*))(0x77C10AB1/*0x7C01441F*/);
  32. void *(*sc_malloc)(DWORD)=(void *(*)(DWORD))(0x77BFC407);
  33. void (*sc_free)(void *)=(void (*)(void *))(0x77BFC21B);

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

  41. //int(WINAPI*sc_CoInitialize)(LPVOID pvReserved) = (int(WINAPI*)(LPVOID pvReserved))0x769B2A53;
  42. //int(WINAPI*sc_CoCreateInstance)(REFCLSID rclsid, LPUNKNOWN pUnkOuter,DWORD dwClsContext, REFIID riid, LPVOID FAR* ppv) = (int(WINAPI*)(REFCLSID rclsid, LPUNKNOWN pUnkOuter,DWORD dwClsContext, REFIID riid, LPVOID FAR* ppv))0x769B057E;


  43. BOOL FASTCALL Comment(ActionParams params)
  44. {

  45.     int(WINAPI*sc_CoInitialize)(LPVOID pvReserved);
  46.     int(WINAPI*sc_CoCreateInstance)(REFCLSID rclsid, LPUNKNOWN pUnkOuter,DWORD dwClsContext, REFIID riid, LPVOID FAR* ppv);
  47.     _asm{
  48.         call $+5+13;
  49.             _EMIT 'C';
  50.             _EMIT 'o'
  51.             _EMIT 'I'
  52.             _EMIT 'n'
  53.             _EMIT 'i'
  54.             _EMIT 't'
  55.             _EMIT 'i'
  56.             _EMIT 'a'
  57.             _EMIT 'l'
  58.             _EMIT 'i'
  59.             _EMIT 'z'
  60.             _EMIT 'e'
  61.             _EMIT '\0';
  62.         lodsd;
  63.         push 76990000h;
  64.     }
  65.     (*sc_GetProcAddress1)();
  66.     _asm{
  67.         mov sc_CoInitialize,eax;
  68.         call $+5+17;
  69.             _EMIT 'C';
  70.             _EMIT 'o'
  71.             _EMIT 'C'
  72.             _EMIT 'r'
  73.             _EMIT 'e'
  74.             _EMIT 'a'
  75.             _EMIT 't'
  76.             _EMIT 'e'
  77.             _EMIT 'I'
  78.             _EMIT 'n'
  79.             _EMIT 's'
  80.             _EMIT 't'
  81.             _EMIT 'a';
  82.             _EMIT 'n'
  83.             _EMIT 'c'
  84.             _EMIT 'e'
  85.             _EMIT '\0'
  86.         lodsd;
  87.         push 76990000h;
  88.     }
  89.    
  90.     (*sc_GetProcAddress1)();
  91.     _asm{//    call DS:sc_GetProcAddress;
  92.         mov sc_CoCreateInstance,eax;
  93.     }
  94.    
  95.     HANDLE mpq,file;
  96.     DWORD siz;
  97.     IDirectMusicPerformance* performance = 0;
  98.     IDirectMusicSegment* segment = 0;
  99.     IDirectMusicLoader* loader = 0;
  100.     unsigned char* data = 0;
  101.     unsigned char *dest;
  102.     DMUS_OBJECTDESC desc;

  103.     if(!(*sc_SFileOpenArchive)((char*)0x509364, 0, 0, &mpq)) return false;
  104.     if(!(*sc_SFileOpenFileEx)(mpq, (*GetResString)(params->Text), 0, &file)) return false;
  105.     siz=(*sc_SFileGetFileSize)(file, 0);
  106.     dest=(unsigned char *)(*sc_malloc)(siz);
  107.     if(dest==0)
  108.         return true;
  109.     (*sc_SFileReadFile)(file, dest, siz, &siz, 0);
  110.     (*sc_SFileCloseFile)(file);
  111.     (*sc_SFileCloseArchive)(mpq);

  112.     //if(data) (*sc_free)(data);//释放上一个资源
  113.     data = dest;
  114. /*
  115.     if(segment)
  116.     {
  117.         if(performance)
  118.         {
  119.             performance->Stop(segment,0,0,0);
  120.             segment->SetParam(GUID_Unload,-1,0,0,(void**)performance);
  121.         }
  122.         segment->Release();
  123.         segment=0;
  124.     }
  125.     if(loader)
  126.     {
  127.         loader->Release();
  128.         loader=0;
  129.     }
  130.     if(performance)
  131.     {
  132.         performance->CloseDown();
  133.         performance->Release();
  134.         performance=0;
  135.     }
  136.     CoUninitialize();
  137.     */

  138.     desc.dwSize = 848;
  139.     desc.pbMemData  = data;
  140.     desc.llMemLength = siz;
  141.     desc.dwValidData = 1026;
  142.     desc.guidClass.Data1=0xd2ac2882;
  143.     desc.guidClass.Data2=0xb39b;
  144.     desc.guidClass.Data3=0x11d1;
  145.     desc.guidClass.Data4[0]=0x87;
  146.     desc.guidClass.Data4[1]=0x04;
  147.     desc.guidClass.Data4[2]=0x00;
  148.     desc.guidClass.Data4[3]=0x60;
  149.     desc.guidClass.Data4[4]=0x08;
  150.     desc.guidClass.Data4[5]=0x93;
  151.     desc.guidClass.Data4[6]=0xb1;
  152.     desc.guidClass.Data4[7]=0xbd;

  153.     GUID CLSIDDirectMusicPerformance = {0xd2ac2881,0xb39b,0x11d1,{0x87,0x04,0x00,0x60,0x08,0x93,0xb1,0xbd}};
  154.     GUID IIDIDirectMusicPerformance = {0x07d43d03,0x6523,0x11d2,{0x87,0x1d,0x00,0x60,0x08,0x93,0xb1,0xbd}};
  155.     GUID CLSIDDirectMusicLoader = {0xd2ac2892,0xb39b,0x11d1,{0x87,0x04,0x00,0x60,0x08,0x93,0xb1,0xbd}};
  156.     GUID IIDIDirectMusicLoader = {0x2ffaaca2,0x5dca,0x11d2,{0xaf,0xa6,0x00,0xaa,0x00,0x24,0xd8,0xb6}};
  157.     GUID GUIDStandardMIDIFile = {0x06621075,0xe92e,0x11d1,{0xa8,0xc5,0x00,0xc0,0x4f,0xa3,0x72,0x6e}};
  158.     GUID GUIDDownload = {0xd2ac28a7,0xb39b,0x11d1,{0x87,0x04,0x00,0x60,0x08,0x93,0xb1,0xbd}};
  159.     GUID IIDIDirectMusicSegment = {0xf96029a2,0x4282,0x11d2,{0x87,0x17,0x00,0x60,0x08,0x93,0xb1,0xbd}};

  160.     if((*sc_CoInitialize)(0) < 0) return true;
  161.     if((*sc_CoCreateInstance)(CLSIDDirectMusicPerformance,0,CLSCTX_INPROC,IIDIDirectMusicPerformance,(void**)&performance) < 0) return true;
  162.     if((*sc_CoCreateInstance)(CLSIDDirectMusicLoader,0,CLSCTX_INPROC,IIDIDirectMusicLoader,(void**)&loader) < 0) return true;
  163.     loader->GetObject(&desc,IIDIDirectMusicSegment,(void**)&segment);
  164.     performance->Init(0,0,0);
  165.     performance->AddPort(0);
  166.     segment->SetParam(GUIDStandardMIDIFile,-1,0,0,performance);
  167.     segment->SetParam(GUIDDownload,-1,0,0,performance);
  168.     segment->SetRepeats(params->Code==0?1:params->Code);
  169.     performance->PlaySegment(segment,0,0,0);
  170.     return true;

  171. }


  172. void AfterFunction(){}
  173. LPCSTR Base64Enc(int size = 0)
  174. {
  175.     if (size <= 0)
  176.         size = PtrToLong((PBYTE)AfterFunction - (PBYTE)Comment);
  177.     PBYTE text = (PBYTE)Comment;
  178.     PBYTE out = new BYTE[(size - 1) * 4 / 3 + 1],buf = out;
  179.     int buflen = 0;

  180.     while(size>0)
  181.     {
  182.         *buf++ = ((text[0] >> 2 ) & 0x3f) + 0x30;
  183.         *buf++ = (((text[0] & 3) << 4) | (text[1] >> 4)) + 0x30;
  184.         *buf++ = (((text[1] & 0xF) << 2) | (text[2] >> 6)) + 0x30;
  185.         *buf++ = (text[2] & 0x3F) + 0x30;

  186.         text +=3;
  187.         size -=3;
  188.         buflen +=4;
  189.     }

  190.     *buf = 0;
  191.     return (LPCSTR)out;
  192. }


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

使用道具 举报

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

Re:17号播放Midi插件

Comment("EH_\PNcP0`00DeIGRoWX3@0004=_BFiYM6UQK6UjI@2]J000VGKo5F3ACP29AN3X4@0004=_@g9UHGAUBFicM65^HfD0[FP009UfoaEPdDh0RDGT<m^=ANa@De=XI9=@08UMo8UMn8UMj?lE_=9>08G0M@Lc`>T[0`00IX]?18e5l51C^828A03od53oMNco5FSCCP25`7CKDomel?lEF==>08U5m52h1lBoMoo@Ro1I>o<?Q>X2001CSDGdD?mem5KoMO3o5ECCCP3oMO3o5F3CCP3oMNco5L3BCP2;AOBiVk<008V5H?oooh_1IXV5??cookSA4@00Rm1VRIDno?ooRm5VREFdRm1VREFf^R=U0029]FSooomVREFDSE01Ro9VRGFFRo5VRGGDRo1VRGGF_\YM001VRKEdooooRo;7QB3loom@0`00RIeTooooahDTo?oo0P@00<N5>?cooh8X[=;6QD3loon7aXE1o?oo18RM@_coolJ5@ocoof36QDClool8aXE5o?ooTlJ5A_cook76QDOloonmadF`PBR\d\I5^8O6AKT4R5fjaTFkH<I5_0S6AKfCaTFn\LI5_kg7AI03?M@7aTFHQlI5VAf8GI[6AI]PaTFL2<I5WI?6AIjaaTFO_LM5d98X[=;6AMR7aTGI18QMf\I5ff36AM`8aTGMTlI5g[76AMnmahE`ooooXZcj;fJ9]GKoooo6QGSooon_aXEiooooYXRMN_ooolJ5NoooojZn;^T006J9MJB;l6J9AHJhPT8005>8WGcoooo6QGgooolTaXEnoooof<J5OooookK7AJ1e4686IXUeY\I5Z:S6AJW5R5fZaTF[`<I5[4o6AJfSaTF^L\I5[fk7AH2W::cBIXU=Q<I5R8O6AHT4R5f:aTF;H<I5S0S6AHfCaTF>\LI5Skg7AL2R:F3iIXU5a6J9ELK6ALR7aTG95hQMb\I5bf36AL`8aTG=TlI5c[76ALnmoeGPQL0?S:d0002=AOa@SDF@D6X3Dhe5\53oENB5`0n<T`0008e5j52=QG3ooom@JP=CSDG@D?mEi8G0O7Z;ANR;28eEn5:=EL1BSIDPo?ooDU3oD@b;AOb;25=CDe3oD@b;AOb;25=@oe5PogGlRdGhR`QCDf[oSEFPDU3oDDcoMOb;AOR;25=CJ_n=EH1BD?mAC8]723_3M@<c`42;COR;4E1Aoe8HRdGlR`QCDe=CogGhD?mA43?0@5mNFlW3", 0, 0, 17, 0, 1);
Comment("2.mid", 0, 0, 0, 0, 17);
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-29 16:26 , Processed in 1.220625 second(s), 19 queries .

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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