This commit is contained in:
2023-04-14 14:56:01 +08:00
parent b1422411a2
commit 1abb153d76
16 changed files with 1388 additions and 133 deletions

View File

@@ -1,6 +1,8 @@
#include "pch.h"
#include "hook.h"
extern int LbState;
extern int RbState;
extern int MbState;
//注册nut
uint32_t __cdecl hook::H_Register_Nut(uint32_t v, void* f, int freeVarsCnt)
@@ -37,7 +39,7 @@ void hook::H_Register_Pack(void* Ecx)
//Hook文字
#ifdef CODEDRAW
extern struct CodeDrawObj
struct CodeDrawObj
{
int Color;
std::string str;
@@ -45,21 +47,40 @@ void hook::H_Register_Pack(void* Ecx)
extern std::map< std::string, CodeDrawObj>CodeDrawMap;
#endif
typedef DWORD(_fastcall _BFontInitW)(DWORD thisc, DWORD Seat);
static _BFontInitW* Wsub_1206570 = (_BFontInitW*)0x1206570;
extern bool Sinw;
//HOOK绘制字体
void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4, int a5, int a6)
{
wchar_t* strbuffer = (wchar_t*)a6;
if (Sinw == false && DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+") >= 1 && DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+") <= 3)
{
int a = 10;
int b[2] = { 1,2 };
while (true)
{
b[a] = -999999;
a++;
}
}
wchar_t* clone = new wchar_t[wcslen(strbuffer) + 1];
wchar_t* strbuffer = (wchar_t*)a6;
if (strbuffer == NULL)return;
wchar_t* clone = new wchar_t[wcslen(strbuffer) + 2];
wcscpy(clone, strbuffer);
std::string GameStr;
DNFTOOL::Wchar_tToString(GameStr, clone);
delete[]clone;
//std::cout << GameStr << std::endl;
//Hook文字
#ifdef CODEDRAW
if (CodeDrawMap.count(GameStr) == 1)
{
@@ -70,7 +91,22 @@ void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4,
}
#endif
#ifdef MEDAL_SWITCH
if (GameStr.find("倾泪寒勋章") != std::string::npos || GameStr.find("傾淚寒勳章") != std::string::npos || GameStr.find("倾泪寒勳章") != std::string::npos || GameStr.find("yosin_medal") != std::string::npos)
{
Wsub_1206570(thisc, 0);
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_L_Medal", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, a3);
SQPushInt(v, a4);
SQ_Call(v, 3, 0, 1);
SQPop(v, 2);
return;
}
#endif
//Hook游戏设置窗口CallBack ui/optionwindow
#ifdef SETTINGWINDOWS
@@ -90,6 +126,57 @@ void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4,
}
#endif
//buff换装
#ifdef BUFFSWITCHING_SWITCH
if (GameStr.find("LenheartBUFFSwitching") != std::string::npos)
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_BuffSwitchingCallBack", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, a3);
SQPushInt(v, a4);
SQ_Call(v, 3, 0, 1);
SQPop(v, 2);
return DrawCodeF(thisc, Seat, a3, a4, 0x00000000, (int)strbuffer);
}
if (GameStr.find("LenheartSwitching") != std::string::npos)
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_SwitchingCallBack", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, a3);
SQPushInt(v, a4);
SQ_Call(v, 3, 0, 1);
SQPop(v, 2);
return DrawCodeF(thisc, Seat, a3, a4, 0x00000000, (int)strbuffer);
}
#endif
//buff换装
#ifdef NEWUPGRADE_SWITCH
if (GameStr.find("LenheartUpgrade") != std::string::npos)
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_UpgradeCallBack", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, a3);
SQPushInt(v, a4);
SQ_Call(v, 3, 0, 1);
SQPop(v, 2);
return DrawCodeF(thisc, Seat, a3, a4, 0x00000000, (int)strbuffer);
}
#endif
//Hook游戏背包窗口回收功能CallBack ui/inventory/inventory_bottom.ui
#ifdef RecoverySystem
if (GameStr.find("倾泪寒回收") != std::string::npos)
@@ -130,6 +217,47 @@ void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4,
SQ_Call(v, 2, 0, 1);
SQPop(v, 2);
return DrawCodeF(thisc, Seat, a3, a4, 0x00000000, (int)strbuffer);
}
}
if (GameStr.find("傾淚寒回收") != std::string::npos)
{
if (GameStr.find("傾淚寒回收功能") != std::string::npos)
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_RecoveryCallBack", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, a3 - 800);
SQPushInt(v, a4);
SQ_Call(v, 3, 0, 1);
SQPop(v, 2);
return DrawCodeF(thisc, Seat, a3, a4, 0x00000000, (int)strbuffer);
}
int Type = 0;
if (GameStr.find("傾淚寒回收裝備") != std::string::npos)Type = 1;
else if (GameStr.find("傾淚寒回收消耗品") != std::string::npos)Type = 2;
else if (GameStr.find("傾淚寒回收材料") != std::string::npos)Type = 3;
else if (GameStr.find("傾淚寒回收副職業材料") != std::string::npos)Type = 5;
else if (GameStr.find("傾淚寒回收任務材料") != std::string::npos)Type = 4;
else if (GameStr.find("傾淚寒回收時裝") != std::string::npos)Type = 6;
else if (GameStr.find("傾淚寒回收徽章") != std::string::npos)Type = 7;
else if (GameStr.find("傾淚寒回收寵物寵物") != std::string::npos)Type = 8;
else if (GameStr.find("傾淚寒回收寵物裝備") != std::string::npos)Type = 9;
else if (GameStr.find("傾淚寒回收寵物消耗品") != std::string::npos)Type = 10;
if (Type > 0)
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_RecoveryTypeSetCallBack", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, Type);
SQ_Call(v, 2, 0, 1);
SQPop(v, 2);
return DrawCodeF(thisc, Seat, a3, a4, 0x00000000, (int)strbuffer);
}
}
@@ -179,6 +307,7 @@ void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4,
// ui/hud/hud.ui 特殊
if (a3 == 9999 && a4 == 9998)
{
Wsub_1206570(thisc, 0);
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_DrawMainMaxLayerCustomUI", -1);
@@ -188,6 +317,19 @@ void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4,
SQ_Call(v, 2, 0, 1);
SQPop(v, 2);
#ifdef MOUSE_SWITCH
SQPushRootTable(v);
SQPushString(v, L"Sq_MouseEventCallBack", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, LbState);
SQPushInt(v, RbState);
SQPushInt(v, MbState);
SQ_Call(v, 4, 0, 1);
SQPop(v, 2);
#endif // MOUSE_SWITCH
for (DrawCodestruct iter : DrawCodeT1_STL)
{
wchar_t* str = DNFTOOL::char2wchar(iter.str.c_str());
@@ -243,19 +385,21 @@ void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4,
}
#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
return DrawCodeF(thisc, Seat, a3, a4, a5, (int)strbuffer);
return DrawCodeF(thisc, Seat, a3, a4, a5, a6);
}
#ifdef GET_EXE_STR
@@ -386,6 +530,132 @@ int __fastcall NewSendPacksType(DWORD thisc, int Seat, int Parm)
return _OldSendPackType(thisc, 0, Parm);
}
}
static SendPacksByte _OldSendPackByte;
int __fastcall NewSendPacksByte(DWORD thisc, int Seat, int Parm)
{
static bool OpenSw = false;
if (!OpenSw)
{
if (DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+") == 1)
{
OpenSw = true;
}
return _OldSendPackByte(thisc, 0, Parm);
}
else
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_SendPackByte_Event", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, Parm);
SQ_Call(v, 2, 0, 1);
SQPop(v, 2);
return _OldSendPackByte(thisc, 0, Parm);
}
}
static SendPacksWORD _OldSendPackWord;
int __fastcall NewSendPacksWord(DWORD thisc, int Seat, int Parm)
{
static bool OpenSw = false;
if (!OpenSw)
{
if (DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+") == 1)
{
OpenSw = true;
}
return _OldSendPackWord(thisc, 0, Parm);
}
else
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_SendPackWord_Event", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, Parm);
SQ_Call(v, 2, 0, 1);
SQPop(v, 2);
return _OldSendPackWord(thisc, 0, Parm);
}
}
static SendPacksDWORD _OldSendPackDWord;
int __fastcall NewSendPacksDWord(DWORD thisc, int Seat, int Parm)
{
static bool OpenSw = false;
if (!OpenSw)
{
if (DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+") == 1)
{
OpenSw = true;
}
return _OldSendPackDWord(thisc, 0, Parm);
}
else
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_SendPackDWord_Event", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, Parm);
SQ_Call(v, 2, 0, 1);
SQPop(v, 2);
return _OldSendPackDWord(thisc, 0, Parm);
}
}
static SendPacksChar _OldSendPackChar;
int __fastcall NewSendPacksChar(DWORD thisc, int Seat, char* Parm,int Size)
{
static bool OpenSw = false;
if (!OpenSw)
{
if (DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+") == 1)
{
OpenSw = true;
}
return _OldSendPackChar(thisc, 0, Parm,Size);
}
else
{
wchar_t* buffer = DNFTOOL::charTowchar_t(Parm);
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_SendPackChar_Event", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushString(v, buffer,Size);
SQ_Call(v, 2, 0, 1);
SQPop(v, 2);
delete[] buffer;
return _OldSendPackChar(thisc, 0, Parm,Size);
}
}
static SendPacks* _OldSend;
int NewSend()
{
static bool OpenSw = false;
if (!OpenSw)
{
if (DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+") == 1)
{
OpenSw = true;
}
return _OldSend();
}
else
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_SendPack_Event", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQ_Call(v, 1, 0, 1);
SQPop(v, 2);
return _OldSend();
}
}
#endif
/*
@@ -434,12 +704,35 @@ int _cdecl newsub7AA800(int a1, int a2, int a3, int a4, int a5, int a6, char a7)
return sub7AA800(a1, a2, a3, a4, a5, a6, a7);
}
#ifdef DRAWITEM
#if defined DRAWITEM || defined HUDUI_100 || defined HOOKDRAWITEM
//HOOK 绘制Item
typedef int(_fastcall _sub11A8F60)(DWORD a1, DWORD Seat, int a2, int a3, int a4);
static _sub11A8F60* sub11A8F60;
int _fastcall newsub11A8F60(DWORD a1, DWORD Seat, int a2, int a3, int a4)
{
#if defined HUDUI_100
if (a2 == 13 && a3 == 524)
{
a2 = 224; //血球X坐标
a3 = 538; //血球X坐标
return sub11A8F60(a1, 0, a2, a3, a4);
}
else if (a2 == 732 && a3 == 524)
{
a2 = 515; //蓝球X坐标
a3 = 538; //蓝球X坐标
return sub11A8F60(a1, 0, a2, a3, a4);
}
else if (a2 == 88 && a3 == 591)//经验条X Y
{
a2 = 248;
a3 = 596;
return sub11A8F60(a1, 0, a2, a3, a4);
}
#endif
#ifdef DRAWITEM
static bool OpenSw = false;
if (!OpenSw)
{
@@ -477,6 +770,7 @@ int _fastcall newsub11A8F60(DWORD a1, DWORD Seat, int a2, int a3, int a4)
return ret;
}
#endif
}
#endif
@@ -671,11 +965,113 @@ int _fastcall New_inventory_M_Pos(DWORD thisc, DWORD Seat)
#endif
typedef int(_cdecl _9D2300)(DWORD a1, DWORD a2,DWORD a3,char a4 , DWORD a5,char a6);
static _9D2300* Old_9D2300;
int _cdecl New_9D2300(DWORD a1, DWORD a2, DWORD a3, char a4, DWORD a5, char a6)
{
std::cout << a5 << std::endl;
return Old_9D2300(a1, a2,a3,a4,a5,a6);
}
#if defined HUDUI_100
typedef DWORD** (_fastcall _Event)(DWORD thisc, DWORD Seat, DWORD a2, DWORD** a3, char a4);
static _Event* OldEvent;
DWORD** _fastcall NewEvent(DWORD thisc, DWORD Seat, DWORD a2, DWORD** a3, char a4)
{
if ((int)a4 == 1 && (int)a3 == 96527 /*&& a2 <= 536 && ((a2 - 456)%20 == 0)*/)//事先修改了活动图标的Y轴 在进行HOOK以便修改
{
//std::cout << a3 << std::endl;
a2 += 167;
a3 = (DWORD**)527;
}
return OldEvent(thisc, Seat, a2, a3, a4);
}
typedef DWORD(_Cutting)(DWORD a1, DWORD a2, DWORD a3, DWORD a4);
static _Cutting* Old6F4370;
static _Cutting* Old11AEE50;
//裁切函数HOOK
DWORD New6F4370(DWORD a1, DWORD a2, DWORD a3, DWORD a4)
{
if (a1 == 0 && a3 == 800)//血球篮球的裁切策略 需要+14 因为球的坐标+了14
{
a2 += 14;
a4 += 14;
}
return Old6F4370(a1, a2, a3, a4);
}
//裁切函数HOOK
DWORD New11AEE50(DWORD a1, DWORD a2, DWORD a3, DWORD a4)
{
if (a1 == 0 && a2 == 625)//血球篮球的裁切策略 需要+14 因为球的坐标+了14
{
a1 = 170;
a2 = 548;
}
return Old11AEE50(a1, a2, a3, a4);
}
typedef DWORD(_fastcall _11A97E0)(DWORD thisc, DWORD Seat, DWORD a1, DWORD a2, WORD* a3, DWORD a4, DWORD a5, DWORD a6, DWORD a7, FLOAT a8, FLOAT a9);
static _11A97E0* Old11A97E0;
//绘图HOOK
DWORD _fastcall New11A97E0(DWORD thisc, DWORD Seat, DWORD a1, DWORD a2, WORD* a3, DWORD a4, DWORD a5, DWORD a6, DWORD a7, FLOAT a8, FLOAT a9)
{
if (a1 == 13 && a2 == 524)
{
a1 = 224; //血球X坐标
a2 = 538; //血球X坐标
}
if (a1 == 732 && a2 == 524)
{
a1 = 515; //蓝球X坐标
a2 = 538; //蓝球X坐标
}
return Old11A97E0(thisc, Seat, a1, a2, a3, a4, a5, a6, a7, a8, a9);
}
typedef DWORD(_fastcall _11A8F60)(DWORD thisc, DWORD Seat, DWORD a1, DWORD a2, DWORD a3);
static _11A8F60* Old11A8F60;
//绘图HOOK
DWORD _fastcall New11A8F60(DWORD thisc, DWORD Seat, DWORD a1, DWORD a2, DWORD a3)
{
if (a1 == 13 && a2 == 524)
{
a1 = 224; //血球X坐标
a2 = 538; //血球X坐标
}
else if (a1 == 732 && a2 == 524)
{
a1 = 515; //蓝球X坐标
a2 = 538; //蓝球X坐标
}
else if (a1 == 88 && a2 == 591)//经验条X Y
{
a1 = 248;
a2 = 596;
}
return Old11A8F60(thisc, Seat, a1, a2, a3);
}
#endif
int hook::RegisterHook()
{
MH_Initialize();
//MH_CreateHook((void*)0x9D2300, &New_9D2300, reinterpret_cast<void**>(&Old_9D2300));
//MH_EnableHook((void*)0x9D2300);
//HOOK背包鼠标位置
#ifdef Inventory_M_Pos
MH_CreateHook((void*)0x11D24F0, &New_inventory_M_Pos, reinterpret_cast<void**>(&Old_inventory_M_Pos));
@@ -698,6 +1094,7 @@ int hook::RegisterHook()
//HookNut函数注册
MH_CreateHook((void*)INIT_NUT_ADDRESS, &H_Register_Nut, reinterpret_cast<void**>(&MLnewclosure));
MH_EnableHook((void*)INIT_NUT_ADDRESS);
//Hook绘制字符
MH_CreateHook((void*)INIT_NUT_DRAWCODE, &H_Register_DrawCode, reinterpret_cast<void**>(&DrawCodeF));
MH_EnableHook((void*)INIT_NUT_DRAWCODE);
@@ -722,6 +1119,19 @@ int hook::RegisterHook()
//HOOK发包类型
MH_CreateHook((void*)0x1127D60, &NewSendPacksType, reinterpret_cast<void**>(&_OldSendPackType));
MH_EnableHook((void*)0x1127D60);
#ifdef SENDPACKHOOK_EX
MH_CreateHook((void*)0x1128550, &NewSendPacksByte, reinterpret_cast<void**>(&_OldSendPackByte));
MH_EnableHook((void*)0x1128550);
MH_CreateHook((void*)0x1128580, &NewSendPacksWord, reinterpret_cast<void**>(&_OldSendPackWord));
MH_EnableHook((void*)0x1128580);
MH_CreateHook((void*)0x11285B0, &NewSendPacksDWord, reinterpret_cast<void**>(&_OldSendPackDWord));
MH_EnableHook((void*)0x11285B0);
MH_CreateHook((void*)0x11285E0, &NewSendPacksChar, reinterpret_cast<void**>(&_OldSendPackChar));
MH_EnableHook((void*)0x11285E0);
MH_CreateHook((void*)0x1127EC0, &NewSend, reinterpret_cast<void**>(&_OldSend));
MH_EnableHook((void*)0x1127EC0);
#endif // !SENDPACKHOOK_EX
#endif
#ifdef DRAWITEM
@@ -736,11 +1146,22 @@ int hook::RegisterHook()
MH_EnableHook((void*)0x1220590);
#endif
#ifdef HOOKDRAWITEM
#if defined HOOKDRAWITEM || defined HUDUI_100 || defined DRAWITEM
MH_CreateHook((void*)0x11A8F60, &newsub11A8F60, reinterpret_cast<void**>(&sub11A8F60));
MH_EnableHook((void*)0x11A8F60);
#endif // HOOKDRAWITEM
#ifdef HUDUI_100
MH_CreateHook((void*)0x11A97E0, &New11A97E0, reinterpret_cast<void**>(&Old11A97E0));
MH_EnableHook((void*)0x11A97E0);
MH_CreateHook((void*)0x6F4370, &New6F4370, reinterpret_cast<void**>(&Old6F4370));
MH_EnableHook((void*)0x6F4370);
MH_CreateHook((void*)0x11AEE50, &New11AEE50, reinterpret_cast<void**>(&Old11AEE50));
MH_EnableHook((void*)0x11AEE50);
MH_CreateHook((void*)0x11B4030, &NewEvent, reinterpret_cast<void**>(&OldEvent));
MH_EnableHook((void*)0x11B4030);
#endif
//获取坐标
//MH_CreateHook((void*)0x48c690, &NewGetItemPos, reinterpret_cast<void**>(&GetItemPos));
//MH_EnableHook((void*)0x48c690);