2022-03-08 12:57:35 +08:00
|
|
|
|
#include "pch.h"
|
|
|
|
|
|
#include "hook.h"
|
|
|
|
|
|
|
2022-04-24 02:31:42 +08:00
|
|
|
|
extern std::vector<DrawCodestruct>DrawCodeT1_STL;
|
|
|
|
|
|
extern std::vector<DrawCodestruct>DrawCodeT2_STL;
|
2022-03-08 12:57:35 +08:00
|
|
|
|
|
|
|
|
|
|
uint32_t hook::H_Register_Nut(uint32_t v, void* f, int freeVarsCnt)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
static int build = 0;
|
|
|
|
|
|
if (build == 0 && f == (void*)0x005C5980)
|
|
|
|
|
|
{
|
|
|
|
|
|
squirrel::R_Register_Nut();
|
|
|
|
|
|
}
|
|
|
|
|
|
return MLnewclosure(v, f, freeVarsCnt);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void hook::H_Register_Pack(void* Ecx)
|
|
|
|
|
|
{
|
|
|
|
|
|
Lpfn_Init(Ecx);
|
|
|
|
|
|
sock::R_Register_Pack();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-24 02:31:42 +08:00
|
|
|
|
void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4, int a5, int a6)
|
2022-04-11 19:44:03 +08:00
|
|
|
|
{
|
2022-05-23 21:37:38 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>
|
2022-04-24 02:31:42 +08:00
|
|
|
|
if (a3 == 9999 && a4 == 9999)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (DrawCodestruct iter : DrawCodeT1_STL)
|
|
|
|
|
|
{
|
2022-04-24 18:02:17 +08:00
|
|
|
|
//wchar_t* str = DNFTOOL::charTowchar_t((char*)iter.str.c_str());
|
|
|
|
|
|
DrawCodeF(thisc, Seat, iter.Xpos, iter.Ypos, iter.Color, (int)iter.str);
|
2022-04-24 02:31:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
DrawCodeT1_STL.clear();
|
|
|
|
|
|
}
|
2022-05-23 21:37:38 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
2022-04-24 02:31:42 +08:00
|
|
|
|
if (a3 == 9999 && a4 == 9998)
|
|
|
|
|
|
{
|
2022-05-07 14:31:17 +08:00
|
|
|
|
uint32_t v = GetSqVm();
|
|
|
|
|
|
SQPushRootTable(v);
|
|
|
|
|
|
SQPushString(v, L"DrawMainMaxLayerCustomUI", -1);
|
|
|
|
|
|
SQ_Get(v, -2);
|
|
|
|
|
|
SQPushRootTable(v);
|
|
|
|
|
|
SQPushString(v, L"Lenheart", -1);
|
2022-06-20 03:10:33 +08:00
|
|
|
|
SQ_Call(v, 2, 0, 0);
|
2022-05-07 14:31:17 +08:00
|
|
|
|
SQPop(v, 2);
|
2022-06-20 03:10:33 +08:00
|
|
|
|
|
|
|
|
|
|
//int num = SQGetTop(v);
|
|
|
|
|
|
//std::cout << num << std::endl;
|
|
|
|
|
|
|
2022-04-24 02:31:42 +08:00
|
|
|
|
for (DrawCodestruct iter : DrawCodeT2_STL)
|
|
|
|
|
|
{
|
2022-04-24 18:02:17 +08:00
|
|
|
|
//wchar_t* str = DNFTOOL::charTowchar_t((char*)iter.str.c_str());
|
|
|
|
|
|
DrawCodeF(thisc, Seat, iter.Xpos, iter.Ypos, iter.Color, (int)iter.str);
|
2022-04-24 02:31:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
DrawCodeT2_STL.clear();
|
|
|
|
|
|
}
|
2022-05-23 21:37:38 +08:00
|
|
|
|
//ѡ<><D1A1>ɫ
|
|
|
|
|
|
if (a3 == 9999 && a4 == 9489)
|
|
|
|
|
|
{
|
2022-06-20 03:10:33 +08:00
|
|
|
|
static bool Init = false;
|
|
|
|
|
|
if (!Init)
|
|
|
|
|
|
{
|
|
|
|
|
|
InitGameScript();//<2F><><EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
Init = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-23 21:37:38 +08:00
|
|
|
|
uint32_t v = GetSqVm();
|
|
|
|
|
|
SQPushRootTable(v);
|
|
|
|
|
|
SQPushString(v, L"InitLenheartClass", -1);
|
|
|
|
|
|
SQ_Get(v, -2);
|
|
|
|
|
|
SQPushRootTable(v);
|
|
|
|
|
|
SQPushString(v, L"Lenheart", -1);
|
2022-06-20 03:10:33 +08:00
|
|
|
|
SQ_Call(v, 2, 0, 0);
|
2022-05-23 21:37:38 +08:00
|
|
|
|
SQPop(v, 2);
|
|
|
|
|
|
}
|
2022-04-24 02:31:42 +08:00
|
|
|
|
|
2022-06-20 03:10:33 +08:00
|
|
|
|
#if defined MONSTER_BLOOD_UI
|
|
|
|
|
|
if (a4 == 100 || a4 == 107 || a4 == 99)
|
|
|
|
|
|
{
|
|
|
|
|
|
//if (a3 == 37 || a3 == 100 || a3 == 74 || a3 == 70)
|
|
|
|
|
|
//{
|
|
|
|
|
|
a3 = 5000;
|
|
|
|
|
|
a4 = 5000;
|
|
|
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
//std::cout << "xPos:" << a3 << "yPos:" << a4 <<std::endl;
|
|
|
|
|
|
//thisc = 0;
|
2022-04-24 02:31:42 +08:00
|
|
|
|
return DrawCodeF(thisc, Seat, a3, a4, a5, a6);
|
2022-04-11 19:44:03 +08:00
|
|
|
|
}
|
2022-03-08 12:57:35 +08:00
|
|
|
|
|
2022-04-24 02:31:42 +08:00
|
|
|
|
|
2022-03-08 12:57:35 +08:00
|
|
|
|
int hook::RegisterHook()
|
|
|
|
|
|
{
|
2022-05-23 21:37:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-08 12:57:35 +08:00
|
|
|
|
MH_Initialize();
|
2022-04-24 02:31:42 +08:00
|
|
|
|
//Hook<6F>հ<EFBFBD>
|
2022-03-08 12:57:35 +08:00
|
|
|
|
MH_CreateHook((void*)INIT_PACK_ADDRESS, &H_Register_Pack, reinterpret_cast<void**>(&Lpfn_Init));
|
2022-04-24 02:31:42 +08:00
|
|
|
|
//HookNut<75><74><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
2022-03-08 12:57:35 +08:00
|
|
|
|
MH_CreateHook((void*)INIT_NUT_ADDRESS, &H_Register_Nut, reinterpret_cast<void**>(&MLnewclosure));
|
2022-04-24 02:31:42 +08:00
|
|
|
|
//Hook<6F><6B><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
|
|
|
|
|
|
MH_CreateHook((void*)INIT_NUT_DRAWCODE, &H_Register_DrawCode, reinterpret_cast<void**>(&DrawCodeF));
|
2022-03-08 12:57:35 +08:00
|
|
|
|
|
2022-04-11 19:44:03 +08:00
|
|
|
|
|
2022-03-08 12:57:35 +08:00
|
|
|
|
MH_EnableHook((void*)INIT_PACK_ADDRESS);
|
|
|
|
|
|
MH_EnableHook((void*)INIT_NUT_ADDRESS);
|
2022-04-24 02:31:42 +08:00
|
|
|
|
MH_EnableHook((void*)INIT_NUT_DRAWCODE);
|
2022-05-23 21:37:38 +08:00
|
|
|
|
|
2022-03-08 12:57:35 +08:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
2022-03-16 10:03:39 +08:00
|
|
|
|
|
|
|
|
|
|
int hook::InitGameScript()
|
|
|
|
|
|
{
|
2022-05-07 14:31:17 +08:00
|
|
|
|
#if defined LOCALHOSTS_SWITCH
|
2022-03-16 10:03:39 +08:00
|
|
|
|
uint32_t v = GetSqVm();
|
|
|
|
|
|
SQPushRootTable(v);
|
|
|
|
|
|
SQPushString(v, L"SetHudUI", -1);
|
|
|
|
|
|
SQ_Get(v, -2);
|
|
|
|
|
|
SQPushRootTable(v);
|
2022-04-11 19:44:03 +08:00
|
|
|
|
SQPushString(v, L"1.cpp", -1);
|
2022-03-16 10:03:39 +08:00
|
|
|
|
SQ_Call(v, 2, 1, 0);
|
|
|
|
|
|
SQPop(v, 2);
|
2022-05-07 14:31:17 +08:00
|
|
|
|
#else
|
|
|
|
|
|
uint32_t v = GetSqVm();
|
|
|
|
|
|
SQPushRootTable(v);
|
|
|
|
|
|
SQPushString(v, L"L_sq_Dofile", -1);
|
|
|
|
|
|
SQ_Get(v, -2);
|
|
|
|
|
|
SQPushRootTable(v);
|
|
|
|
|
|
SQPushString(v, L"licbylist.dll", -1);
|
2022-06-20 03:10:33 +08:00
|
|
|
|
SQ_Call(v, 2, 0, 0);
|
2022-05-07 14:31:17 +08:00
|
|
|
|
SQPop(v, 2);
|
|
|
|
|
|
#endif
|
2022-03-16 10:03:39 +08:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|