diff --git a/test/dllmain.cpp b/test/dllmain.cpp index 2dd91c8..ec1d493 100644 --- a/test/dllmain.cpp +++ b/test/dllmain.cpp @@ -38,6 +38,24 @@ uint32_t NewPushString(uint32_t v, wchar_t* f, int freeVarsCnt) return MLSqPushString(v, f, freeVarsCnt); } +static DrawTe* Cbuffer = NULL; + +int Tihuan(DWORD thisc,int a2, int a3, int a4, int a5, int a6, __int64 a7, float a8, float a9, float a10, int a11, int a12) +{ + std::cout << a2 << std::endl; + std::cout << a3 << std::endl; + std::cout << a4 << std::endl; + std::cout << a5 << std::endl; + std::cout << a6 << std::endl; + std::cout << a7 << std::endl; + std::cout << a8 << std::endl; + std::cout << a9 << std::endl; + std::cout << a10 << std::endl; + std::cout << a11 << std::endl; + std::cout << a12 << std::endl; + + return Cbuffer(thisc,a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); +} @@ -45,20 +63,23 @@ int HOOK() { std::cout << u8"开始hook" << std::endl; + if (MH_Initialize() != MH_OK)//初始化Hook + { + return 1; + } - /* - if (MH_CreateHook((void*)0x9536C0, &tihuancall, - reinterpret_cast(&BCBB)) != MH_OK) + if (MH_CreateHook((void*)0x11D07D0, &Tihuan, + reinterpret_cast(&Cbuffer)) != MH_OK) { return 2; } // Enable the hook for MessageBoxW. - if (MH_EnableHook((void*)0x9536C0) != MH_OK) + if (MH_EnableHook((void*)0x11D07D0) != MH_OK) { return 3; } - */ + /* if (MH_CreateHook((void*)0x1358A60, &NewClosure, @@ -138,7 +159,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/framework.h b/test/framework.h index b298854..c165ae5 100644 --- a/test/framework.h +++ b/test/framework.h @@ -11,4 +11,4 @@ #include "squirrel.h" #include "MinHook.h" - +#pragma comment(lib, "libMinHook.x86.lib") diff --git a/test/pch.h b/test/pch.h index 9873f3c..54465a0 100644 --- a/test/pch.h +++ b/test/pch.h @@ -73,6 +73,8 @@ static SqGetBoolFunc* SQGetBool = (SqGetBoolFunc*)0x1358E30; //GetString typedef int(SqGetStringFunc)(uint32_t v, uint32_t stackIndex, wchar_t** sstring); static SqGetStringFunc* SQGetString = (SqGetStringFunc*)0x1358E70; +typedef int(SqGetStringCFunc)(uint32_t v, uint32_t stackIndex, char** sstring); +static SqGetStringCFunc* SQGetStringc = (SqGetStringCFunc*)0x1358E70; //GetUserdata typedef int(SqGetUserdataFunc)(uint32_t v, uint32_t stackIndex, DWORD* up, DWORD* up1); static SqGetUserdataFunc* SQGetUserdata = (SqGetUserdataFunc*)0x1358EC0; @@ -268,12 +270,15 @@ static SendPacksDWORD _SendPacksDWord = (SendPacksDWORD)0x11285B0; typedef DWORD NoticeClass; static NoticeClass* _NoticeClass = (NoticeClass*)0x1A5FB20; //公告CALL -typedef void(__fastcall* NoticeCall)(DWORD thisc, int Seat , char* a1, DWORD a2, DWORD a3, DWORD a4, DWORD a5, DWORD a6, DWORD a7); +typedef void(__fastcall* NoticeCall)(DWORD thisc, int Seat , char* a1, DWORD a2, DWORD a3, DWORD a4, DWORD a5, DWORD a6); static NoticeCall _Noticecall = (NoticeCall)0x9536C0; -//公告CALL +//窗口CALL typedef void(__fastcall* NoticeTCall)(DWORD thisc, DWORD Seat, DWORD a1, char* a2, DWORD a3); static NoticeTCall _NoticeTcall = (NoticeTCall)0xE6E070; +//绘制?//TODO +typedef int( DrawTe)(DWORD thisc, int a2, int a3, int a4, int a5, int a6, __int64 a7, float a8, float a9, float a10, int a11, int a12); +//static NoticeTCall _NoticeTcall = (NoticeTCall)0xE6E070; #endif //PCH_H diff --git a/test/test.vcxproj b/test/test.vcxproj index e7abbf2..8a4b3d0 100644 --- a/test/test.vcxproj +++ b/test/test.vcxproj @@ -104,6 +104,9 @@ Console true false + + + D:\hookDNF\DOF_DllHook\test;%(AdditionalLibraryDirectories) @@ -126,7 +129,8 @@ true true false - squirrel.lib;libMinHook.x86.lib;%(AdditionalDependencies) + libMinHook.x86.lib;%(AdditionalDependencies) + D:\hookDNF\DOF_DllHook\test;%(AdditionalLibraryDirectories) diff --git a/test/函数块.cpp b/test/函数块.cpp index b67fcf1..b2efe08 100644 --- a/test/函数块.cpp +++ b/test/函数块.cpp @@ -343,49 +343,24 @@ static int SQdofile(uint32_t v, const wchar_t* filename, bool retval, bool print -/* -void gonggao(char* str,int ctype,int ccolor) -{ - 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; - _asm - { - pushad - mov ecx, dword ptr[ebp - 0x04] - mov ecx, dword ptr[ecx] - mov ecx, dword ptr[ecx + 0x40] - push 0x00000000 - push 0x00000000 - push 0x00000000 - push 0x00000000 - push dword ptr[ebp - 0x0c] - push dword ptr[ebp - 0x10] - push dword ptr[ebp - 0x14] - call dword ptr[ebp - 0x08] - popad - } -} -*/ - - -//ڹ +//ڹ 0x10d void WindowsNotice(char* str ,int type = 0x10d ,int b = 0x0) { DWORD thisc = 0x1A5FB20; thisc = *(DWORD*)thisc; _NoticeTcall(thisc, 0, type, str, b); } - +//GM +void GMNotice(char* str, int type,int color) +{ + if (type == NULL)type = 14; + if (color == NULL)color = 0x65535; + DWORD thisc = 0x1A5FB20; + thisc = *(DWORD*)thisc; + thisc = *(DWORD*)(thisc + 0x40); + _Noticecall(thisc, 0, str, color, type, 0, 0, 0); +} @@ -410,24 +385,8 @@ void RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t v) static int sq_Test(uint32_t v) { - /* - DWORD thisc = 0x1A5FB20; - - - - thisc = *(DWORD*)thisc; - thisc = *(DWORD*)(thisc + 0x40); - - char *str = (char*)u"test"; - - - _Noticecall(thisc, NULL, str, 0x66535, 14, 0, 0, 0, 0); - */ - - //char* str = (char*)u"test"; - //gonggao(str, 14,NULL); - - WindowsNotice((char*)u"ҵ"); + //GMNotice((char*)u"ҵ"); + //WindowsNotice((char*)u"ҵ"); SQPopTop(v); SQPushInt(v, 1); @@ -706,6 +665,194 @@ static int LDofile(uint32_t v) return 1; } +//Lcout +static int Lcout(uint32_t v) +{ + char* str = NULL; + int type = NULL; + int color = NULL; + int num = SQGetTop(v); + + if (num == 2 || num == 3 || num == 4) + { + switch (num) + { + case 2: + SQGetStringc(v, 2, &str); + break; + case 3: + SQGetStringc(v, 2, &str); + SQGetInt(v, 3, &type); + break; + case 4: + SQGetStringc(v, 2, &str); + SQGetInt(v, 3, &type); + SQGetInt(v, 4, &color); + break; + } + + SQPopTop(v); + + GMNotice(str, type, color); + + SQPushBool(v, true); + } + else + { + SQPushBool(v, false); + } + + return 1; +} + +//Lcout +static int NewWindows(uint32_t v) +{ + char* str = NULL; + int type = NULL; + int color = NULL; + int num = SQGetTop(v); + + if (num == 2 || num == 3 || num == 4) + { + switch (num) + { + case 2: + SQGetStringc(v, 2, &str); + break; + case 3: + SQGetStringc(v, 2, &str); + SQGetInt(v, 3, &type); + break; + case 4: + SQGetStringc(v, 2, &str); + SQGetInt(v, 3, &type); + SQGetInt(v, 4, &color); + break; + } + + SQPopTop(v); + + WindowsNotice(str, type, color); + + SQPushBool(v, true); + } + else + { + SQPushBool(v, false); + } + + return 1; +} + +//Lcout +static int SetSlot(uint32_t v) +{ + int Type = NULL; + int Index = NULL; + int Xpos = NULL; + int Ypos = NULL; + + + int OneAddr = NULL; + int* xpos = NULL; + int* ypos = NULL; + + int ParameterNum = SQGetTop(v); + + if (ParameterNum == 5) + { + SQGetInt(v, 2, &Type); + SQGetInt(v, 3, &Index); + SQGetInt(v, 4, &Xpos); + SQGetInt(v, 5, &Ypos); + + SQPopTop(v); + + switch (Type) + { + case 0://չ + OneAddr = *(int*)0x1ADE0CC; + OneAddr = *(int*)(OneAddr + (0x60 + (4 * Index))); + xpos = (int*)(OneAddr + (0x14)); + ypos = (int*)(OneAddr + (0x18)); + *xpos = Xpos; + *ypos = Ypos; + break; + case 1:// + OneAddr = *(int*)0x1ADE0CC; + OneAddr = *(int*)(OneAddr + (0x30 + (4 * Index))); + xpos = (int*)(OneAddr + (0x14)); + ypos = (int*)(OneAddr + (0x18)); + *xpos = Xpos; + *ypos = Ypos; + break; + case 2://л + OneAddr = *(int*)0x1ADE0CC; + OneAddr = *(int*)(OneAddr + (0x124 + (4 * Index))); + xpos = (int*)(OneAddr + (0x14)); + ypos = (int*)(OneAddr + (0x18)); + *xpos = Xpos; + *ypos = Ypos; + break; + case 3://Ʒ + OneAddr = *(int*)0x1ADE0CC; + OneAddr = *(int*)(OneAddr + (0x18 + (4 * Index))); + xpos = (int*)(OneAddr + (0x14)); + ypos = (int*)(OneAddr + (0x18)); + *xpos = Xpos; + *ypos = Ypos; + break; + case 4://Լչ + OneAddr = *(int*)0x1ADE0CC; + OneAddr = *(int*)(OneAddr + 0xC); + OneAddr = *(int*)(OneAddr + 0x4); + OneAddr = *(int*)(OneAddr + 0x0); + OneAddr = *(int*)(OneAddr + 0x34); + OneAddr = *(int*)(OneAddr + 0x4); + OneAddr = *(int*)(OneAddr + 0x28); + OneAddr = *(int*)(OneAddr + 0x4); + + xpos = (int*)(OneAddr + (0x394)); + ypos = (int*)(OneAddr + (0x398)); + *xpos = Xpos; + *ypos = Ypos; + break; + case 5://Լܼ + OneAddr = *(int*)(0x16E95AC + 0x400000); + OneAddr = *(int*)(OneAddr + 0x68); + OneAddr = *(int*)(OneAddr + 0x0); + OneAddr = *(int*)(OneAddr + 0x8); + OneAddr = *(int*)(OneAddr + 0x64); + OneAddr = *(int*)(OneAddr + 0x0); + OneAddr = *(int*)(OneAddr + 0x1C); + OneAddr = *(int*)(OneAddr + 0x0); + + xpos = (int*)(OneAddr + (0x1794)); + ypos = (int*)(OneAddr + (0x1798)); + *xpos = Xpos; + *ypos = Ypos; + break; + case 6://˵ + OneAddr = *(int*)0x1ADE0CC; + OneAddr = *(int*)(OneAddr + (0x84 + (4 * Index))); + xpos = (int*)(OneAddr + (0x14)); + ypos = (int*)(OneAddr + (0x18)); + *xpos = Xpos; + *ypos = Ypos; + break; + } + + SQPushBool(v, true); + } + else + { + SQPushBool(v, false); + } + + return 1; +} + void RegisterNut() { RegisterNutApi(L"L_sq_Test", sq_Test); @@ -724,6 +871,9 @@ void RegisterNut() RegisterNutApi(L"L_sq_GivePlayerEqu", GivePlayerEqu); RegisterNutApi(L"L_sq_GoDungeon", GoDungeon); RegisterNutApi(L"L_sq_Dofile", LDofile); + RegisterNutApi(L"L_cout", Lcout); + RegisterNutApi(L"L_NewWindows", NewWindows); + RegisterNutApi(L"L_SetSlot", SetSlot); }