DNF_DLL/test/dllmain.cpp

152 lines
2.9 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*)0x9536C0, &tihuancall,
reinterpret_cast<void**>(&BCBB)) != MH_OK)
{
return 2;
}
// Enable the hook for MessageBoxW.
if (MH_EnableHook((void*)0x9536C0) != 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()
{
}
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:
Lenheart();
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}