From 378f4ba664f7c6d8464806e429b87ed2b84f779c Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Mon, 28 Feb 2022 00:14:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=83=E6=80=81=E7=88=86=E7=82=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/dllmain.cpp | 75 +---------------- test/pch.h | 12 ++- test/函数块.cpp | 208 +++++++++++++++++++++++++---------------------- 3 files changed, 126 insertions(+), 169 deletions(-) diff --git a/test/dllmain.cpp b/test/dllmain.cpp index d86685f..2dd91c8 100644 --- a/test/dllmain.cpp +++ b/test/dllmain.cpp @@ -38,24 +38,9 @@ uint32_t NewPushString(uint32_t v, wchar_t* f, int freeVarsCnt) return MLSqPushString(v, f, freeVarsCnt); } -/* -static NoticeCall _Noticecall = NULL; -void tihuancall(DWORD a1, DWORD a2, DWORD a3, DWORD a4, DWORD a5, DWORD a6, DWORD a7, DWORD a8, DWORD a9, DWORD a10, DWORD a11, DWORD a12, DWORD a13) -{ - std::cout << "true" << std::endl; - - std::cout << a1 << std::endl; - std::cout << a2 << std::endl; - std::cout << a3 << std::endl; - std::cout << a4 << std::endl; - //std::cout << a5 << std::endl; - - //return _Noticecall(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); -} -*/ int HOOK() { std::cout << u8"开始hook" << std::endl; @@ -63,7 +48,7 @@ int HOOK() /* if (MH_CreateHook((void*)0x9536C0, &tihuancall, - reinterpret_cast(&_Noticecall)) != MH_OK) + reinterpret_cast(&BCBB)) != MH_OK) { return 2; } @@ -98,62 +83,6 @@ int HOOK() void testcall() { - //SQdofile(GetSqVm(), L"1.cpp", false, false); - //SQloadfile(GetSqVm(), L"1.cpp", false); - - //SQDofile(GetSqVm(),L"1.cpp",0,0); - //std::cout << gm(0x186FB828) << std::endl; - - - //_SendpacksType(*_SendClass, 0, 0x2D); - //_SendPacks(); - - /* - _SendpacksType(*_SendClass, 0, 75); - _SendPacksByte(*_SendClass, 0, 2); - _SendPacksByte(*_SendClass, 0, 2); - _SendPacks(); - - _SendpacksType(*_SendClass, 0, 75); - _SendPacksByte(*_SendClass, 0, 1); - _SendPacksByte(*_SendClass, 0, 2); - _SendPacks(); - - - _SendpacksType(*_SendClass, 0, 37); - _SendPacksWord(*_SendClass, 0, 636); - _SendPacksWord(*_SendClass, 0, 268); - _SendPacksByte(*_SendClass, 0, 5); - _SendPacksWord(*_SendClass, 0, 200); - _SendPacks(); - */ - - /* - _SendpacksType(*_SendClass, 0, 38); - _SendPacksByte(*_SendClass, 0, 1); - _SendPacksByte(*_SendClass, 0, 0); - _SendPacksWord(*_SendClass, 0, 1109); - _SendPacksWord(*_SendClass, 0, 268); - _SendPacksByte(*_SendClass, 0, 5); - _SendPacksWord(*_SendClass, 0, 0); - _SendPacksWord(*_SendClass, 0, 0); - _SendPacks(); - */ - - - /* - _SendpacksType(*_SendClass, 0, 17); - _SendPacksByte(*_SendClass, 3, 1); - _SendPacksWord(*_SendClass, 56, 1); - _SendPacksDWord(*_SendClass, 0, 1); - _SendPacksDWord(*_SendClass, 6, 1); - _SendPacks(); - */ - /* - _SendpacksType(*_SendClass, 0, 0x3); - _SendPacks(); - */ - } @@ -209,7 +138,7 @@ BOOL APIENTRY DllMain( HMODULE hModule, switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: - //HOOK(); + Lenheart(); break; case DLL_THREAD_ATTACH: diff --git a/test/pch.h b/test/pch.h index 7ec3b5b..9873f3c 100644 --- a/test/pch.h +++ b/test/pch.h @@ -263,7 +263,17 @@ static SendPacksWORD _SendPacksWord = (SendPacksWORD)0x1128580; typedef int(__fastcall* SendPacksDWORD)(DWORD thisc, int Seat, int Parm); static SendPacksDWORD _SendPacksDWord = (SendPacksDWORD)0x11285B0; + +//公告Class this地址 +typedef DWORD NoticeClass; +static NoticeClass* _NoticeClass = (NoticeClass*)0x1A5FB20; //公告CALL -typedef void( *NoticeCall)(int a1, int a2, int a3, int a4, int a5, int a6, int a7); +typedef void(__fastcall* NoticeCall)(DWORD thisc, int Seat , char* a1, DWORD a2, DWORD a3, DWORD a4, DWORD a5, DWORD a6, DWORD a7); static NoticeCall _Noticecall = (NoticeCall)0x9536C0; + +//公告CALL +typedef void(__fastcall* NoticeTCall)(DWORD thisc, DWORD Seat, DWORD a1, char* a2, DWORD a3); +static NoticeTCall _NoticeTcall = (NoticeTCall)0xE6E070; + + #endif //PCH_H diff --git a/test/函数块.cpp b/test/函数块.cpp index d7062c3..b67fcf1 100644 --- a/test/函数块.cpp +++ b/test/函数块.cpp @@ -237,86 +237,90 @@ int GetEquAddr(int addr) } return -1; } +char* UnicodeToAnsi(const wchar_t* szStr, char* pResult, int maxLen) +{ + if (NULL == pResult) + return NULL; + int nLen = WideCharToMultiByte(CP_ACP, 0, szStr, -1, NULL, 0, NULL, NULL); + if (0 == nLen) + { + return NULL; + } + if (nLen >= maxLen) + nLen = maxLen; + WideCharToMultiByte(CP_ACP, 0, szStr, -1, pResult, nLen, NULL, NULL); + return pResult; +} +wchar_t* AnsiToUnicode(const char* szStr, wchar_t* pResult, int maxLen) +{ + if (NULL == pResult) + return NULL; + int nLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szStr, -1, NULL, 0); + if (0 == nLen) + { + return NULL; + } + if (nLen >= maxLen) + nLen = maxLen; + + nLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szStr, -1, pResult, nLen); + if (0 == nLen) + { + return NULL; + } + return pResult; +} + // static int SQloadfile(uint32_t v, const wchar_t* filename, bool printerror) { - SQFILE* file = SQfopen(filename, L"rb+"); - //FILE* file; - //file = fopen(filename, "rb"); - int ret; - unsigned short us; - unsigned char uc; + //wchar_t* ת char* + int size = wcslen(filename); + char* fname = (char*)new char[size]; + UnicodeToAnsi(filename, fname, size); + + FILE* file; + file = fopen(fname, "rb+"); LSQLEXREADFUNC func = SQ_io_file_lexfeed_ASCII; if (file) { - ret = SQfread(&us, 1, 2, file); - if (ret != 2) + //ļĴС + fseek(file, 0, SEEK_END); + int size = ftell(file); + rewind(file); + + //һװļĿռ + char* ar = (char*)malloc(sizeof(char) * size); + //ļÿζһsize + fread(ar, 1, size, file); + + int skey[] = { 5,2,3,5,0 };// + + Cutecode(ar, skey);// + + FILE* outfile; + outfile = fopen("ImagePacks2/sprite_interface_teart_zero.npk", "wb+"); + int da = strlen(ar); + fwrite(ar, 1, da, outfile); + + fclose(outfile);//رļ + free(ar);//ͷڴ + + SQFILE* newfile = SQfopen(L"ImagePacks2/sprite_interface_teart_zero.npk", L"rb+");//µļ + + SQfseek(newfile, 0, 2);//λͷ + if (SQ_Compile(v, func, newfile, filename, printerror) >= 0) { - us = 0; + fclose(file);//رļ + SQ__Fclose(newfile);//رļ + remove("ImagePacks2/sprite_interface_teart_zero.npk");//ɾļ + return 0; } - if (us == 0xFAFA) - { - SQfseek(file, 0, 2); - if (SQ_Readclosure(v, SQ_File_read, file) > 0) - { - SQ__Fclose(file); - return SQ_OK; - } - } - else - { - switch (us) - { - case 0xFFFE: func = SQ_io_file_lexfeed_UCS2_BE; break;//UTF-16 little endian; - case 0xFEFF: func = SQ_io_file_lexfeed_UCS2_LE; break;//UTF-16 big endian; - case 0xBBEF: - if (SQfread(&uc, 1, sizeof(uc), file) == 0) - { - SQ__Fclose(file); - return 1; - } - if (uc != 0xBF) - { - SQ__Fclose(file); - return 1; - } - func = SQ_io_file_lexfeed_UTF8; - break;//UTF-8 ; - default: SQfseek(file, 0, 2); break; // ascii - } - SQfseek(file, 0, 1);//λβ - int length = SQftell(file);//õļ - SQfseek(file, 0, 2);//λͷ - - - char* temp = new char[length+4];//newһµַ - - SQfread(temp, sizeof(temp), length, file);//ļַ - temp[length] = '\0';//βӽ - - int key[] = { 5,2,3,5,0 };// - Cutecode(temp, key);// - - SQFILE* newfile = SQfopen(L"ImagePacks2/sprite_interface_teart_zero.npk", L"wb+");//µļ - SQwrite(temp, sizeof(temp), strlen(temp), newfile);//д - - - SQfseek(file, 0, 2);//λͷ - SQfseek(newfile, 0, 2);//λͷ - - if (SQ_Compile(v, func, newfile, filename, printerror) >= 0) - { - SQ__Fclose(file);//رļ - SQ__Fclose(newfile);//رļ - remove("ImagePacks2/sprite_interface_teart_zero.npk");//ɾļ - return SQ_OK; - } - } - SQ__Fclose(file); + fclose(file);//رļ return -1; } - return 1; + return -1; } static int SQdofile(uint32_t v, const wchar_t* filename, bool retval, bool printerror) @@ -339,26 +343,21 @@ static int SQdofile(uint32_t v, const wchar_t* filename, bool retval, bool print - - - -void ggc(char* str,int type,int color) +/* +void gonggao(char* str,int ctype,int ccolor) { - int shangdian; - int laba; - int ggtype; - int ggcolor; - int ggstr; + int shop, gonggao, type, color; + char*addr; + if (ctype == NULL) + ctype = 16; + if (ccolor == NULL) + ccolor = 0x65535; + shop = 0x1A5FB20; + gonggao = 0x9536c0; + type = ctype; + color = ccolor; + addr = str; - //ggtype = 16; - //ggcolor = 65535; - shangdian = 0x1A5FB20; - laba = 0x9536c0; - ggtype = 16; - ggcolor = 65535; - ggstr = (int)str; - //std::cout << ggstr << std::endl; - _asm { pushad @@ -375,13 +374,17 @@ void ggc(char* str,int type,int color) call dword ptr[ebp - 0x08] popad } - } +*/ - - - +//ڹ +void WindowsNotice(char* str ,int type = 0x10d ,int b = 0x0) +{ + DWORD thisc = 0x1A5FB20; + thisc = *(DWORD*)thisc; + _NoticeTcall(thisc, 0, type, str, b); +} @@ -406,14 +409,29 @@ void RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t v) //Test static int sq_Test(uint32_t v) { - //sq_pushinteger(v, n1); + + /* + DWORD thisc = 0x1A5FB20; - *(char**)0x400F00 = (char*)u"test"; + + thisc = *(DWORD*)thisc; + thisc = *(DWORD*)(thisc + 0x40); - _Noticecall(0x400F00, 65535, 14, 0, 0, 0, 0); + char *str = (char*)u"test"; - return 0; + + _Noticecall(thisc, NULL, str, 0x66535, 14, 0, 0, 0, 0); + */ + + //char* str = (char*)u"test"; + //gonggao(str, 14,NULL); + + WindowsNotice((char*)u"ҵ"); + + SQPopTop(v); + SQPushInt(v, 1); + return 1; } // װ static int GetCharacterAttribute(uint32_t v)