中国星际RPG联盟
标题:
18号导入单位模型 5.16版本跨系统
[打印本页]
作者:
castelu
时间:
2013-8-22 23:51
标题:
18号导入单位模型 5.16版本跨系统
#include <stdio.h>
#include <windows.h>
#include "mmsystem.h"
#define PINT int *
#define FASTCALL __fastcall
#pragma pack(1)
typedef struct
{
DWORD Unused0;
DWORD Text;//1
DWORD Code;//2
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))0x004ED12C;
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 int *buffer;
unsigned int *dest;
DWORD siz;
void * (WINAPI*sc_VirtualAlloc)(void *, SIZE_T, DWORD, DWORD);
if(!(*sc_SFileOpenArchive)((char*)0x509364, 0, 0, &mpq)) return false;
if(!(*sc_SFileOpenFileEx)(mpq, (*GetResString)(params->Text), 0, &file)) return false;
siz=(*sc_SFileGetFileSize)(file, 0);
_asm
{
push 40h
push 1000h
push eax
push 0
_EMIT 0xFF
_EMIT 0x15
_EMIT 0x2C
_EMIT 0xD1
_EMIT 0x4E
_EMIT 0x00//VirtuaAlloc
mov dest,eax
}
(*sc_SFileReadFile)(file, dest, siz, &siz, 0);
(*sc_SFileCloseFile)(file);
(*sc_SFileCloseArchive)(mpq);
siz = *(unsigned __int16 *)dest;//取帧数
buffer = (unsigned int *)(((int)dest) + 10);//取第一帧的offset地址
while(siz)
{
*buffer += (unsigned int)dest;
buffer += 2;//+8就是下一帧,因为是int*
siz--;
}
*(unsigned int *)params->Code = (unsigned int)dest;//修改指针 you le?...1级的改法
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\\comment18.txt","wb");
fprintf(f1,"Comment(\"%s\", 0, 0, 18, 0, 1);\n",Base64Enc());
fclose(f1);
int i;
}
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);
复制代码
欢迎光临 中国星际RPG联盟 (http://www.scrpg.net/)
Powered by Discuz! X3.1