120 lines
2.9 KiB
C++
120 lines
2.9 KiB
C++
#include "pch.h"
|
||
#include "hook.h"
|
||
|
||
extern std::vector<DrawCodestruct>DrawCodeT1_STL;
|
||
extern std::vector<DrawCodestruct>DrawCodeT2_STL;
|
||
|
||
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();
|
||
}
|
||
|
||
|
||
void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4, int a5, int a6)
|
||
{
|
||
//헝蕎<ED979D>뇜
|
||
if (a3 == 9999 && a4 == 9999)
|
||
{
|
||
for (DrawCodestruct iter : DrawCodeT1_STL)
|
||
{
|
||
//wchar_t* str = DNFTOOL::charTowchar_t((char*)iter.str.c_str());
|
||
DrawCodeF(thisc, Seat, iter.Xpos, iter.Ypos, iter.Color, (int)iter.str);
|
||
}
|
||
DrawCodeT1_STL.clear();
|
||
}
|
||
//景喝
|
||
if (a3 == 9999 && a4 == 9998)
|
||
{
|
||
|
||
uint32_t v = GetSqVm();
|
||
SQPushRootTable(v);
|
||
SQPushString(v, L"DrawMainMaxLayerCustomUI", -1);
|
||
SQ_Get(v, -2);
|
||
SQPushRootTable(v);
|
||
SQPushString(v, L"Lenheart", -1);
|
||
SQ_Call(v, 2, 1, 0);
|
||
SQPop(v, 2);
|
||
|
||
for (DrawCodestruct iter : DrawCodeT2_STL)
|
||
{
|
||
//wchar_t* str = DNFTOOL::charTowchar_t((char*)iter.str.c_str());
|
||
DrawCodeF(thisc, Seat, iter.Xpos, iter.Ypos, iter.Color, (int)iter.str);
|
||
}
|
||
DrawCodeT2_STL.clear();
|
||
}
|
||
//朞실<E69C9E>
|
||
if (a3 == 9999 && a4 == 9489)
|
||
{
|
||
uint32_t v = GetSqVm();
|
||
SQPushRootTable(v);
|
||
SQPushString(v, L"InitLenheartClass", -1);
|
||
SQ_Get(v, -2);
|
||
SQPushRootTable(v);
|
||
SQPushString(v, L"Lenheart", -1);
|
||
SQ_Call(v, 2, 1, 0);
|
||
SQPop(v, 2);
|
||
}
|
||
|
||
return DrawCodeF(thisc, Seat, a3, a4, a5, a6);
|
||
}
|
||
|
||
|
||
int hook::RegisterHook()
|
||
{
|
||
|
||
|
||
|
||
MH_Initialize();
|
||
//Hook澗관
|
||
MH_CreateHook((void*)INIT_PACK_ADDRESS, &H_Register_Pack, reinterpret_cast<void**>(&Lpfn_Init));
|
||
//HookNut변鑒鬧꿍
|
||
MH_CreateHook((void*)INIT_NUT_ADDRESS, &H_Register_Nut, reinterpret_cast<void**>(&MLnewclosure));
|
||
//Hook삥齡俚륜
|
||
MH_CreateHook((void*)INIT_NUT_DRAWCODE, &H_Register_DrawCode, reinterpret_cast<void**>(&DrawCodeF));
|
||
|
||
|
||
MH_EnableHook((void*)INIT_PACK_ADDRESS);
|
||
MH_EnableHook((void*)INIT_NUT_ADDRESS);
|
||
MH_EnableHook((void*)INIT_NUT_DRAWCODE);
|
||
|
||
return 0;
|
||
}
|
||
|
||
int hook::InitGameScript()
|
||
{
|
||
|
||
#if defined LOCALHOSTS_SWITCH
|
||
uint32_t v = GetSqVm();
|
||
SQPushRootTable(v);
|
||
SQPushString(v, L"SetHudUI", -1);
|
||
SQ_Get(v, -2);
|
||
SQPushRootTable(v);
|
||
SQPushString(v, L"1.cpp", -1);
|
||
SQ_Call(v, 2, 1, 0);
|
||
SQPop(v, 2);
|
||
#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);
|
||
SQ_Call(v, 2, 1, 0);
|
||
SQPop(v, 2);
|
||
#endif
|
||
return 0;
|
||
}
|