DNF_DLL/test/dllmain.cpp

152 lines
2.9 KiB
C++
Raw Normal View History

2022-02-03 19:20:05 +08:00
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"
2022-02-03 22:25:03 +08:00
2022-02-06 11:33:52 +08:00
2022-02-10 14:14:08 +08:00
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);
}
2022-02-13 19:54:59 +08:00
static SqPushStringFunc* MLSqPushString = NULL;
2022-02-10 14:14:08 +08:00
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);
}
2022-02-26 19:07:14 +08:00
2022-02-10 14:14:08 +08:00
int HOOK()
{
std::cout << u8"开始hook" << std::endl;
2022-02-26 19:07:14 +08:00
2022-02-10 14:14:08 +08:00
/*
2022-02-26 19:07:14 +08:00
if (MH_CreateHook((void*)0x9536C0, &tihuancall,
2022-02-28 00:14:53 +08:00
reinterpret_cast<void**>(&BCBB)) != MH_OK)
2022-02-10 14:14:08 +08:00
{
return 2;
}
// Enable the hook for MessageBoxW.
2022-02-26 19:07:14 +08:00
if (MH_EnableHook((void*)0x9536C0) != MH_OK)
2022-02-10 14:14:08 +08:00
{
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;
}
2022-02-14 23:35:11 +08:00
2022-02-06 11:33:52 +08:00
void testcall()
{
2022-02-26 19:07:14 +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-28 00:14:53 +08:00
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;
}