| 
									
										
										
										
											2022-02-03 19:20:05 +08:00
										 |  |  |  | // dllmain.cpp : 定义 DLL 应用程序的入口点。
 | 
					
						
							|  |  |  |  | #include "pch.h"
 | 
					
						
							| 
									
										
										
										
											2022-02-07 03:31:00 +08:00
										 |  |  |  | //#include "函数块.h"
 | 
					
						
							| 
									
										
										
										
											2022-02-03 19:20:05 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-03 22:25:03 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-06 11:33:52 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-10 14:14:08 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | typedef int(SqGetStringFunc)(uint32_t v, uint32_t stackIndex, wchar_t** ppString); | 
					
						
							|  |  |  |  | static SqGetStringFunc* SQGetString = (SqGetStringFunc*)0x1358E70; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | static realSqNewClosure* MLnewclosure = NULL; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | uint32_t NewClosure(uint32_t v, void* f, int freeVarsCnt) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     std::cout << std::endl; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     wchar_t* funcName; | 
					
						
							|  |  |  |  |     SQGetString(v, -1 - freeVarsCnt, &funcName); | 
					
						
							|  |  |  |  |     //if (funcName == L"sq_CreateAICharacter")
 | 
					
						
							|  |  |  |  |     //{
 | 
					
						
							|  |  |  |  |         //wprintf(L"Funaddr:%s\t", f);
 | 
					
						
							|  |  |  |  |         //std::cout << f << std::endl;
 | 
					
						
							|  |  |  |  |     //}
 | 
					
						
							|  |  |  |  |     wprintf(L"Funname:%s\tAbli:%d\tFunAddr:0x%p", funcName, freeVarsCnt, f); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     return MLnewclosure(v, f, freeVarsCnt); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | static realSqPushString* MLSqPushString = NULL; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | uint32_t NewPushString(uint32_t v, wchar_t* f, int freeVarsCnt) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     std::cout << std::endl; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     wprintf(L"Funname:%s\tAbli:%d\tFunAddr:0x%p", f, freeVarsCnt, f); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     return MLSqPushString(v, f, freeVarsCnt); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | int HOOK() | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     std::cout << u8"开始hook" << std::endl; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     if (MH_Initialize() != MH_OK) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return 1; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /*
 | 
					
						
							|  |  |  |  |     if (MH_CreateHook((void*)0x135B850, &NewClosure, | 
					
						
							|  |  |  |  |         reinterpret_cast<void**>(&MLnewclosure)) != MH_OK) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return 2; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // Enable the hook for MessageBoxW.
 | 
					
						
							|  |  |  |  |     if (MH_EnableHook((void*)0x135B850) != MH_OK) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return 3; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /*
 | 
					
						
							|  |  |  |  |     if (MH_CreateHook((void*)0x1358A60, &NewClosure, | 
					
						
							|  |  |  |  |         reinterpret_cast<void**>(&MLnewclosure)) != MH_OK) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return 2; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // Enable the hook for MessageBoxW.
 | 
					
						
							|  |  |  |  |     if (MH_EnableHook((void*)0x1358A60) != MH_OK) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return 3; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     return 0; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | typedef int(isgm)(int C); | 
					
						
							|  |  |  |  | static isgm* gm = (isgm*)0x176F380; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-06 11:33:52 +08:00
										 |  |  |  | void testcall() | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-02-10 14:14:08 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     //std::cout << gm(0x186FB828) << std::endl;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-07 03:31:00 +08:00
										 |  |  |  |     //_SendpacksType(*_SendClass, 0, 0x2D);
 | 
					
						
							|  |  |  |  |     //_SendPacks();
 | 
					
						
							| 
									
										
										
										
											2022-02-10 14:14:08 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     /*
 | 
					
						
							|  |  |  |  |     _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(); | 
					
						
							|  |  |  |  |     */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-07 03:31:00 +08:00
										 |  |  |  |     /*
 | 
					
						
							|  |  |  |  |     _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(); | 
					
						
							|  |  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2022-02-10 14:14:08 +08:00
										 |  |  |  |     /*
 | 
					
						
							| 
									
										
										
										
											2022-02-07 03:31:00 +08:00
										 |  |  |  |     _SendpacksType(*_SendClass, 0, 0x3); | 
					
						
							|  |  |  |  |     _SendPacks(); | 
					
						
							| 
									
										
										
										
											2022-02-10 14:14:08 +08:00
										 |  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2022-02-06 11:33:52 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-10 14:14:08 +08:00
										 |  |  |  | void LenheartThread(void) | 
					
						
							| 
									
										
										
										
											2022-02-03 22:25:03 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-02-07 03:31:00 +08:00
										 |  |  |  |     //  下方写全局变量
 | 
					
						
							|  |  |  |  |     static int Nut头地址; | 
					
						
							|  |  |  |  |     static int 属性头地址; | 
					
						
							|  |  |  |  |     static int 可开始执行判断; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-10 14:14:08 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-03 19:20:05 +08:00
										 |  |  |  |     while (true) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-02-10 14:14:08 +08:00
										 |  |  |  |         Sleep(10); | 
					
						
							| 
									
										
										
										
											2022-02-03 22:25:03 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (GetHook(0x1A5FB4C, "0x14+0x28+") == 6)可开始执行判断 = 1; | 
					
						
							|  |  |  |  |         if (可开始执行判断 == 1) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-02-10 14:14:08 +08:00
										 |  |  |  |             RegisterNut(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-03 22:25:03 +08:00
										 |  |  |  |             while (true) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Sleep(10); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (GetExeNutWrtNum(61) != 0 && Nut头地址 == 0)Nut头地址 = GetExeNutWrtNum(61); | 
					
						
							|  |  |  |  |                 //if (GetExeNutWrtNum(61 != 0))属性头地址 = GetExeNutWrtNum(61);
 | 
					
						
							|  |  |  |  |                 if (GetExeNutWrtNum(0) == 666) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     std::cout << u8"写成功" << std::endl;; | 
					
						
							| 
									
										
										
										
											2022-02-06 11:33:52 +08:00
										 |  |  |  |                     testcall(); | 
					
						
							| 
									
										
										
										
											2022-02-03 22:25:03 +08:00
										 |  |  |  |                     SetExeNutWrtNum(0, 0); | 
					
						
							| 
									
										
										
										
											2022-02-07 03:31:00 +08:00
										 |  |  |  |                     SetNutArrNum(Nut头地址 , 20, 0); | 
					
						
							| 
									
										
										
										
											2022-02-03 22:25:03 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-02-03 19:20:05 +08:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | __declspec(dllexport) void Lenheart() | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     DWORD threadID; | 
					
						
							| 
									
										
										
										
											2022-02-10 14:14:08 +08:00
										 |  |  |  |     CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)LenheartThread, NULL, 0, &threadID); | 
					
						
							| 
									
										
										
										
											2022-02-03 19:20:05 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | BOOL APIENTRY DllMain( HMODULE hModule, | 
					
						
							|  |  |  |  |                        DWORD  ul_reason_for_call, | 
					
						
							|  |  |  |  |                        LPVOID lpReserved | 
					
						
							|  |  |  |  |                      ) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     switch (ul_reason_for_call) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |     case DLL_PROCESS_ATTACH: | 
					
						
							| 
									
										
										
										
											2022-02-10 14:14:08 +08:00
										 |  |  |  |         //HOOK();
 | 
					
						
							| 
									
										
										
										
											2022-02-03 19:20:05 +08:00
										 |  |  |  |         Lenheart(); | 
					
						
							| 
									
										
										
										
											2022-02-10 14:14:08 +08:00
										 |  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2022-02-03 19:20:05 +08:00
										 |  |  |  |     case DLL_THREAD_ATTACH: | 
					
						
							|  |  |  |  |     case DLL_THREAD_DETACH: | 
					
						
							|  |  |  |  |     case DLL_PROCESS_DETACH: | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     return TRUE; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 |