205 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			C++
		
	
	
	
			
		
		
	
	
			205 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			C++
		
	
	
	
| // dllmain.cpp : 定义 DLL 应用程序的入口点。
 | |
| #include "pch.h"
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 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 SqPushStringFunc* 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_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;
 | |
| }
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 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();
 | |
|     */
 | |
| }
 | |
| 
 | |
| void LenheartThread(void)
 | |
| {
 | |
|     //  下方写全局变量
 | |
|     static int Nut头地址;
 | |
|     static int 属性头地址;
 | |
|     static int 可开始执行判断;
 | |
| 
 | |
| 
 | |
|     while (true)
 | |
|     {
 | |
|         Sleep(10);
 | |
| 
 | |
|         if (GetHook(0x1A5FB4C, "0x14+0x28+") == 6)可开始执行判断 = 1;
 | |
|         if (可开始执行判断 == 1)
 | |
|         {
 | |
|             RegisterNut();
 | |
| 
 | |
|             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;;
 | |
|                     testcall();
 | |
|                     SetExeNutWrtNum(0, 0);
 | |
|                     SetNutArrNum(Nut头地址 , 20, 0);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| 
 | |
| __declspec(dllexport) void Lenheart()
 | |
| {
 | |
|     DWORD threadID;
 | |
|     CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)LenheartThread, NULL, 0, &threadID);
 | |
| }
 | |
| 
 | |
| 
 | |
| BOOL APIENTRY DllMain( HMODULE hModule,
 | |
|                        DWORD  ul_reason_for_call,
 | |
|                        LPVOID lpReserved
 | |
|                      )
 | |
| {
 | |
| 
 | |
|     switch (ul_reason_for_call)
 | |
|     {
 | |
|     case DLL_PROCESS_ATTACH:
 | |
|         //HOOK();
 | |
|         Lenheart();
 | |
|         break;
 | |
|     case DLL_THREAD_ATTACH:
 | |
|     case DLL_THREAD_DETACH:
 | |
|     case DLL_PROCESS_DETACH:
 | |
|         break;
 | |
|     }
 | |
|     return TRUE;
 | |
| }
 | |
| 
 |