DNF_DLL/test/hook.cpp

757 lines
20 KiB
C++
Raw Normal View History

2022-03-08 12:57:35 +08:00
#include "pch.h"
#include "hook.h"
2022-09-06 00:08:26 +08:00
//ע<><D7A2>nut
uint32_t __cdecl hook::H_Register_Nut(uint32_t v, void* f, int freeVarsCnt)
2022-03-08 12:57:35 +08:00
{
2022-09-06 00:08:26 +08:00
/*
wchar_t* funcName = nullptr;
SQGetString(v, -1 - freeVarsCnt, &funcName);
//std::wcout << funcName << std::endl;
wprintf(L"Function:%s Num:%d Address: 0x%p\n", funcName, freeVarsCnt,f);
*/
2022-03-08 12:57:35 +08:00
static int build = 0;
if (build == 0 && f == (void*)0x005C5980)
{
squirrel::R_Register_Nut();
2022-11-06 23:12:18 +08:00
//squirrel::InitGameScript();//<2F><><EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
build = 1;
2022-03-08 12:57:35 +08:00
}
2022-11-06 23:12:18 +08:00
#if defined DOFILE_HOOK
if (f == (void*)0x013563C0)
{
return MLnewclosure(v, squirrel::LDofile, freeVarsCnt);
}
#endif
2022-03-08 12:57:35 +08:00
return MLnewclosure(v, f, freeVarsCnt);
}
2022-09-06 00:08:26 +08:00
//ע<><D7A2><EFBFBD>հ<EFBFBD>
2022-03-08 12:57:35 +08:00
void hook::H_Register_Pack(void* Ecx)
{
Lpfn_Init(Ecx);
sock::R_Register_Pack();
}
2022-09-06 00:08:26 +08:00
//HOOK<4F><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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-09-06 00:08:26 +08:00
2022-11-06 23:12:18 +08:00
wchar_t* strbuffer = (wchar_t*)a6;
2022-09-06 00:08:26 +08:00
2022-11-06 23:12:18 +08:00
wchar_t* clone = new wchar_t[wcslen(strbuffer) + 1];
wcscpy(clone, strbuffer);
std::string GameStr;
DNFTOOL::Wchar_tToString(GameStr, clone);
delete[]clone;
//Hook<6F><6B>Ϸ<EFBFBD><CFB7><EFBFBD>ô<EFBFBD><C3B4><EFBFBD>CallBack ui/optionwindow
#ifdef SETTINGWINDOWS
if (GameStr.find("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") != std::string::npos)
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_SettingWindowCallBack", -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<6F><6B>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><DABB>չ<EFBFBD><D5B9><EFBFBD>CallBack ui/inventory/inventory_bottom.ui
#ifdef RecoverySystem
if (GameStr.find("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") != std::string::npos)
{
if (GameStr.find("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><EFBFBD><EFBFBD>") != 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("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD>") != std::string::npos)Type = 1;
else if (GameStr.find("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ") != std::string::npos)Type = 2;
else if (GameStr.find("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ղ<EFBFBD><EFBFBD><EFBFBD>") != std::string::npos)Type = 3;
else if (GameStr.find("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>ְҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>") != std::string::npos)Type = 5;
else if (GameStr.find("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") != std::string::npos)Type = 4;
else if (GameStr.find("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱװ") != std::string::npos)Type = 6;
else if (GameStr.find("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD>") != std::string::npos)Type = 7;
else if (GameStr.find("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") != std::string::npos)Type = 8;
else if (GameStr.find("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD>") != std::string::npos)Type = 9;
else if (GameStr.find("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ") != 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);
}
}
#endif
#ifndef SELL
2022-11-10 04:27:41 +08:00
/*
2022-11-06 23:12:18 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (a3 == 15 && a4 == 503)
2022-09-06 00:08:26 +08:00
{
2022-11-06 23:12:18 +08:00
for (DrawCodestruct iter : DrawCodeT3_STL)
{
wchar_t* str = DNFTOOL::char2wchar(iter.str.c_str());
DrawCodeF(thisc, Seat, iter.Xpos, iter.Ypos, iter.Color, (int)str);
delete[]str;
}
DrawCodeT3_STL.clear();
return;
2022-09-06 00:08:26 +08:00
}
2022-11-10 04:27:41 +08:00
*/
2022-09-06 00:08:26 +08:00
2022-11-06 23:12:18 +08:00
//Ver.1180.2.1r
if (GameStr.find("Ver. 1.180.2.1r") != std::string::npos)
{
return;
}
if (GameStr.find("ch11.<2E><><EFBFBD><EFBFBD>֮ɭ") != std::string::npos)
{
a3 += 32;
a4 -= 58;
}
if (DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+") == 6 && (GameStr.find("˳<EFBFBD><EFBFBD>") != std::string::npos || GameStr.find("ӵ<EFBFBD><EFBFBD>") != std::string::npos || GameStr.find("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>") != std::string::npos))
{
a3 += 32;
a4 -= 58;
}
2022-09-06 00:08:26 +08:00
// ui/hud/hud.ui <20><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>
2022-04-24 02:31:42 +08:00
if (a3 == 9999 && a4 == 9999)
{
2022-09-06 00:08:26 +08:00
squirrel::SqrCallBackFunc();
//imguiC::Init();
2022-11-06 23:12:18 +08:00
return;
2022-04-24 02:31:42 +08:00
}
2022-11-06 23:12:18 +08:00
#endif // !SELL
2022-09-06 00:08:26 +08:00
// ui/hud/hud.ui <20><><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);
2022-09-06 00:08:26 +08:00
SQPushString(v, L"Sq_DrawMainMaxLayerCustomUI", -1);
2022-05-07 14:31:17 +08:00
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushString(v, L"Lenheart", -1);
2022-11-06 23:12:18 +08:00
SQ_Call(v, 2, 0, 1);
2022-05-07 14:31:17 +08:00
SQPop(v, 2);
2022-06-20 03:10:33 +08:00
2022-09-06 00:08:26 +08:00
for (DrawCodestruct iter : DrawCodeT1_STL)
2022-04-24 02:31:42 +08:00
{
2022-09-06 00:08:26 +08:00
wchar_t* str = DNFTOOL::char2wchar(iter.str.c_str());
DrawCodeF(thisc, Seat, iter.Xpos, iter.Ypos, iter.Color, (int)str);
delete[]str;
2022-04-24 02:31:42 +08:00
}
2022-09-06 00:08:26 +08:00
DrawCodeT1_STL.clear();
2022-11-06 23:12:18 +08:00
return;
2022-04-24 02:31:42 +08:00
}
2022-09-06 00:08:26 +08:00
// ui/selectcharacter/selectcharacterover.ui ѡ<><D1A1>ɫ
2022-05-23 21:37:38 +08:00
if (a3 == 9999 && a4 == 9489)
{
2022-06-20 03:10:33 +08:00
static bool Init = false;
if (!Init)
{
2022-09-06 00:08:26 +08:00
squirrel::InitGameScript();//<2F><><EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-06-20 03:10:33 +08:00
Init = true;
}
2022-05-23 21:37:38 +08:00
uint32_t v = GetSqVm();
SQPushRootTable(v);
2022-09-06 00:08:26 +08:00
SQPushString(v, L"Sq_SelectCharacter", -1);
2022-05-23 21:37:38 +08:00
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushString(v, L"Lenheart", -1);
2022-11-06 23:12:18 +08:00
SQ_Call(v, 2, 0, 1);
2022-05-23 21:37:38 +08:00
SQPop(v, 2);
2022-11-06 23:12:18 +08:00
return;
2022-05-23 21:37:38 +08:00
}
2022-04-24 02:31:42 +08:00
2022-09-06 00:08:26 +08:00
// ui/event/creatednftwevent/creatednftwevent.ui <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (a3 == 8888 && a4 == 8884)
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_DrawMainTopLayerCustomUI", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushString(v, L"Lenheart", -1);
2022-11-06 23:12:18 +08:00
SQ_Call(v, 2, 0, 1);
2022-09-06 00:08:26 +08:00
SQPop(v, 2);
for (DrawCodestruct iter : DrawCodeT2_STL)
{
wchar_t* str = DNFTOOL::char2wchar(iter.str.c_str());
DrawCodeF(thisc, Seat, iter.Xpos, iter.Ypos, iter.Color, (int)str);
delete[]str;
}
DrawCodeT2_STL.clear();
2022-11-06 23:12:18 +08:00
return;
2022-09-06 00:08:26 +08:00
}
2022-06-20 03:10:33 +08:00
#if defined MONSTER_BLOOD_UI
2022-11-06 23:12:18 +08:00
////<2F><><EFBFBD>߹<EFBFBD><DFB9><EFBFBD>Ѫ<EFBFBD><D1AA><EFBFBD><EFBFBD>һЩ<D2BB><D0A9><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
//if (a4 == 100 || a4 == 107 || a4 == 99)
//{
// //if (a3 == 37 || a3 == 100 || a3 == 74 || a3 == 70)
// //{
// a3 = 5000;
// a4 = 5000;
// //}
//}
2022-06-20 03:10:33 +08:00
#endif
2022-11-06 23:12:18 +08:00
return DrawCodeF(thisc, Seat, a3, a4, a5, (int)strbuffer);
2022-04-11 19:44:03 +08:00
}
2022-03-08 12:57:35 +08:00
2022-11-06 23:12:18 +08:00
#ifdef GET_EXE_STR
//Exe<78><65><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Hook
typedef int(_cdecl _sub1220590)(int a1);
static _sub1220590* sub1220590 = (_sub1220590*)0x1220590;
int _cdecl Newsub1220590(int a1)
{
static bool OpenSw = false;
if (!OpenSw)
{
if (DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+") == 1)
{
OpenSw = true;
}
return sub1220590(a1);
}
else
{
int StrIndex;
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_GetExeStr_Event", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, a1);
SQ_Call(v, 2, 1, 1);
SQGetInt(v, -1, &StrIndex);
SQPop(v, 3);
return sub1220590(StrIndex);
}
}
#endif
2022-04-24 02:31:42 +08:00
2022-09-06 00:08:26 +08:00
//HOOK<4F><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
#ifdef CREAT_CHR_UI
typedef DWORD(_fastcall _OldCreatChr)(DWORD thisc, DWORD Seat, DWORD a3);
static _OldCreatChr* OldCreatChr;
DWORD _fastcall CreatChr(DWORD thisc, DWORD Seat, DWORD a2)
{
//std::cout << "a2:" << a2 << std::endl;
if (*(int*)0x1A5FE1C == 1)
{
if (*(int*)a2 == 25481068)
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_CreatChr", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushString(v, L"Lenheart", -1);
2022-11-06 23:12:18 +08:00
SQ_Call(v, 2, 0, 1);
2022-09-06 00:08:26 +08:00
SQPop(v, 2);
}
}
return OldCreatChr(thisc, 0, a2);
}
#endif // CREAT_CHR_UI
//HOOK Item<65><6D>ɫ
#ifdef ITEMRARITY
extern std::map< int,int>ItemColorMap;
typedef DWORD(_cdecl _OldHookEquNameColor)(int rarity);
static _OldHookEquNameColor* OldHookEquNameColor;
DWORD _cdecl HookEquNameColor(int rarity)
{
DWORD OldColor = OldHookEquNameColor(rarity);
switch (rarity)
{
case 6:
return 0xFF0055FF;
case 7:
return 0xFF9314FF;
case 8:
return 0xFF1CBC0C;
case 9:
return 0xFFACFF08;
}
return OldColor;
}
typedef DWORD(_fastcall _OldHookItemColor)(DWORD thisc, DWORD Seat);
static _OldHookItemColor* OldHookItemColor;
DWORD _fastcall HookItemColor(DWORD thisc, DWORD Seat)
{
int ItemCode = *(int*)(thisc + 0x1C);
if (ItemColorMap.count(ItemCode) == 1)
{
return ItemColorMap[ItemCode];
}
//<2F><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>ɫmap<61><70><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>ԭ<EFBFBD><D4AD>ɫ<EFBFBD><C9AB>ȡ
int Rarity = *(int*)(thisc + 0xF4);
int color = HookEquNameColor(Rarity);
return color;
}
#endif
//HOOK <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#ifdef SENDPACKHOOK
static SendPacksType _OldSendPackType;
int __fastcall NewSendPacksType(DWORD thisc, int Seat, int Parm)
{
2022-11-06 23:12:18 +08:00
static bool OpenSw = false;
if (!OpenSw)
{
if (DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+") == 1)
{
OpenSw = true;
}
return _OldSendPackType(thisc, 0, Parm);
}
else
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_SendPackType_Event", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, Parm);
SQ_Call(v, 2, 0, 1);
SQPop(v, 2);
return _OldSendPackType(thisc, 0, Parm);
}
2022-09-06 00:08:26 +08:00
}
#endif
/*
//HOOK <20><>ȡITEM <20><><EFBFBD><EFBFBD>
typedef int(_fastcall __GetItemPos)(DWORD thisc, DWORD Seat);
static __GetItemPos* GetItemPos;
int __fastcall NewGetItemPos(DWORD thisc, int Seat)
{
int PosX = *(int*)(thisc + 0x14);
int PosY = *(int*)(thisc + 0x18);
return PosX;
}
*/
/*
//Img <20><><EFBFBD>ƺ<EFBFBD><C6BA><EFBFBD>
typedef int(_fastcall __sub_11A97E0)(DWORD a1, DWORD Seat, int a2, int a3,DWORD a4, int a5,int a6,int a7 ,int a8,float a9, float a10);
static __sub_11A97E0* sub_11A97E0;
int _fastcall Newsub_11A97E0(DWORD a1, DWORD Seat, int a2, int a3, DWORD a4, int a5, int a6, int a7, int a8, float a9, float a10)
{
//std::cout << "a1: " << a1 << std::endl;
//std::cout << "a2: " << a2 << std::endl;
//std::cout << "a3: " << a3 << std::endl;
//std::cout << "a4: " << a4 << std::endl;
//std::cout << "a5: " << a5 << std::endl;
//std::cout << "a6: " << a6 << std::endl;
//std::cout << "a7: " << a7 << std::endl;
//std::cout << "a8: " << a8 << std::endl;
//std::cout << "a9: " << a9 << std::endl;
//std::cout << "a10: " << a10 << std::endl;
static DWORD st = a4;
return sub_11A97E0(a1, 0, a2, a3, st, a5, a6, a7, a8, a9, a10);
}
*/
//HOOK <20><><EFBFBD><EFBFBD>stackable
typedef int(_cdecl _sub7AA800)(int a1, int a2, int a3 , int a4, int a5 , int a6,char a7);
static _sub7AA800* sub7AA800;
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);
}
2022-11-06 23:12:18 +08:00
#ifdef DRAWITEM
2022-09-06 00:08:26 +08:00
//HOOK <20><><EFBFBD><EFBFBD>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)
{
static bool OpenSw = false;
if (!OpenSw)
{
//std::cout << DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+") << std::endl;
if (DNFTOOL::GetHook(0x1A5FB4C, "0x14+0x28+") == 1)
{
OpenSw = true;
}
return sub11A8F60(a1, 0, a2, a3, a4);
}
else
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_DrawItemBack", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, a2);
SQPushInt(v, a3);
SQPushInt(v, a4);
2022-11-06 23:12:18 +08:00
SQ_Call(v, 4, 0, 1);
2022-09-06 00:08:26 +08:00
SQPop(v, 2);
int ret = sub11A8F60(a1, 0, a2, a3, a4);
SQPushRootTable(v);
SQPushString(v, L"Sq_DrawItemFront", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, a2);
SQPushInt(v, a3);
SQPushInt(v, a4);
2022-11-06 23:12:18 +08:00
SQ_Call(v, 4, 0, 1);
2022-09-06 00:08:26 +08:00
SQPop(v, 2);
return ret;
}
}
2022-11-06 23:12:18 +08:00
#endif
2022-09-06 00:08:26 +08:00
/*
//ģ<><C4A3>SQRCAll
typedef int(__sub_5AADF0)(void(__cdecl* a1)(int, int, int, int), int a2, int a3);
static __sub_5AADF0* sub_5AADF0;
int Newsub_5AADF0(void(__cdecl* a1)(int, int, int, int), int a2, int a3)
{
std::cout << "drawani: " << a1 << std::endl;
//std::cout << "TestDrawSkill" << std::endl;
//std::cout << "DrawSkillAddr:" << a1 << std::endl;
return sub_5AADF0(a1, a2, a3);
}
*/
/*
//<2F>󲿷<EFBFBD>IMG<4D><47><EFBFBD>ֵĵ<D6B5><C4B5>ú<EFBFBD><C3BA><EFBFBD>
typedef int(_fastcall __sub_11B2390)(DWORD a1, DWORD Seat, int a2, int a3, int a4, int a5, DWORD* a6);
static __sub_11B2390* sub_11B2390;
int _fastcall Newsub_11B2390(DWORD a1, DWORD Seat, int a2, int a3, int a4, int a5, DWORD* a6)
{
//std::cout << "a2: " << a2 << std::endl;
//std::cout << "a3: " << a3 << std::endl;
//std::cout << "a4: " << a4 << std::endl;
//std::cout << "a5: " << a5 << std::endl;
a2 = 100;
a3 = 100;
return sub_11B2390(a1, 0, a2, a3, a4, a5, a6);
}
*/
/*
//push string
std::map< std::wstring, int>BQS;
static SqPushStringFunc* OldSQPushString;
int NewSqPushStringFunc(uint32_t v, const wchar_t* s, int len)
{
std::wstring a = s;
if (BQS.count(a) != 1)
{
wprintf(L"Name:%s Len:%d\n", s, len);
BQS[a] = 1;
}
//std::wcout << funcName << std::endl;
return OldSQPushString(v, s, len);
}
*/
2022-11-06 23:12:18 +08:00
/*
typedef int(SQ_CompilebufferFunc)(uint32_t v, const wchar_t* s,int size, wchar_t* filename, BOOL printerror);
static SQ_CompilebufferFunc* SQ_Compilebuffer = (SQ_CompilebufferFunc*)0x135B2C0;
*/
/*
// HOOK exe <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
static SQ_CompilebufferFunc* OldSQ_Compilebuffer;
int NewSQ_Compilebuffer(uint32_t v, const wchar_t* s, int size, wchar_t* filename, BOOL printerror)
{
wprintf(L"File--%s: \n str--\n%s \n \n", filename, s);
return OldSQ_Compilebuffer(v, s, size, filename, printerror);
}
*/
#if defined MONSTER_BLOOD_UI
typedef int(_fastcall _Blood)(DWORD thisc, DWORD Seat, DWORD a1, DWORD a2);
typedef int(_fastcall _DrawMonFace)(DWORD thisc, DWORD Seat, DWORD a1, DWORD a2);
static _Blood* OldBlood;
static _Blood* OldBlood1;
static _Blood* OldBlood2;
static _DrawMonFace* DrawMonFace = (_DrawMonFace*)0x43a1b0;
int _fastcall NewBlood(DWORD thisc, DWORD Seat, DWORD a1, DWORD a2)
{
BOOL DrawSw;
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_GetDrawMonBloodSw", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQ_Call(v, 1, 1, 1);
SQGetBool(v, -1, &DrawSw);
SQPop(v, 3);
if (DrawSw == TRUE)
{
return 0;
}
else
{
int ret = OldBlood(thisc, 0, a1, a2);
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_DrawMonsterBlood", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, *(DWORD*)(thisc + 8));
SQPushInt(v, a1);
SQPushInt(v, a2);
SQ_Call(v, 4, 0, 1);
SQPop(v, 2);
return ret;
}
}
int _fastcall NewBlood1(DWORD thisc, DWORD Seat, DWORD a1, DWORD a2)
{
BOOL DrawSw;
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_GetDrawMonBloodSw", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQ_Call(v, 1, 1, 1);
SQGetBool(v, -1, &DrawSw);
SQPop(v, 3);
if (DrawSw == TRUE)
{
return 0;
}
else
{
int ret = OldBlood1(thisc, 0, a1, a2);
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_DrawMonsterBlood", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, *(DWORD*)(thisc + 8));
SQPushInt(v, a1);
SQPushInt(v, a2);
SQ_Call(v, 4, 0, 1);
SQPop(v, 2);
return ret;
}
}
int _fastcall NewBlood2(DWORD thisc, DWORD Seat, DWORD a1, DWORD a2)
{
int ret = OldBlood2(thisc, 0, a1, a2);
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_DrawMonsterBlood", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, *(DWORD*)(thisc + 8));
SQPushInt(v, a1);
SQPushInt(v, a2);
SQ_Call(v, 4, 0, 1);
SQPop(v, 2);
return ret;
}
#endif
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>HOOK<4F><4B><EFBFBD><EFBFBD><><CEAA><EFBFBD>õ<EFBFBD>this<69><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ)
#ifdef Inventory_M_Pos
typedef int(_fastcall _inventory_M_Pos)(DWORD thisc, DWORD Seat);
static _inventory_M_Pos* Old_inventory_M_Pos;
int _fastcall New_inventory_M_Pos(DWORD thisc, DWORD Seat)
{
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"Sq_Set_Inventory_M_Pos", -1);
SQ_Get(v, -2);
SQPushRootTable(v);
SQPushInt(v, thisc);
SQ_Call(v, 2, 0, 1);
SQPop(v, 2);
return Old_inventory_M_Pos(thisc, Seat);
}
#endif
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-11-06 23:12:18 +08:00
//HOOK<4F><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
#ifdef Inventory_M_Pos
MH_CreateHook((void*)0x11D24F0, &New_inventory_M_Pos, reinterpret_cast<void**>(&Old_inventory_M_Pos));
MH_EnableHook((void*)0x11D24F0);
#endif
//HOOK<4F><4B><EFBFBD><EFBFBD>Ѫ<EFBFBD><D1AA>
#if defined MONSTER_BLOOD_UI
MH_CreateHook((void*)0x43d770, &NewBlood, reinterpret_cast<void**>(&OldBlood));
MH_EnableHook((void*)0x43d770);
MH_CreateHook((void*)0x43d620, &NewBlood1, reinterpret_cast<void**>(&OldBlood1));
MH_EnableHook((void*)0x43d620);
MH_CreateHook((void*)0x43d4d0, &NewBlood2, reinterpret_cast<void**>(&OldBlood2));
MH_EnableHook((void*)0x43d4d0);
#endif
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-09-06 00:08:26 +08:00
MH_EnableHook((void*)INIT_PACK_ADDRESS);
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-09-06 00:08:26 +08:00
MH_EnableHook((void*)INIT_NUT_ADDRESS);
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-09-06 00:08:26 +08:00
MH_EnableHook((void*)INIT_NUT_DRAWCODE);
2022-03-08 12:57:35 +08:00
2022-09-06 00:08:26 +08:00
#ifdef CREAT_CHR_UI
MH_CreateHook((void*)0x10f3050, &CreatChr, reinterpret_cast<void**>(&OldCreatChr));
MH_EnableHook((void*)0x10f3050);
#endif // CREAT_CHR_UI
2022-04-11 19:44:03 +08:00
2022-09-06 00:08:26 +08:00
#ifdef ITEMRARITY
//HOOK<4F><4B>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
MH_CreateHook((void*)0x7AB080, &HookItemColor, reinterpret_cast<void**>(&OldHookItemColor));
MH_EnableHook((void*)0x7AB080);
2022-05-23 21:37:38 +08:00
2022-09-06 00:08:26 +08:00
//HOOK<4F><4B><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ɫ
MH_CreateHook((void*)0x7AAD00, &HookEquNameColor, reinterpret_cast<void**>(&OldHookEquNameColor));
MH_EnableHook((void*)0x7AAD00);
#endif
2022-03-16 10:03:39 +08:00
2022-09-06 00:08:26 +08:00
#ifdef SENDPACKHOOK
//HOOK<4F><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MH_CreateHook((void*)0x1127D60, &NewSendPacksType, reinterpret_cast<void**>(&_OldSendPackType));
MH_EnableHook((void*)0x1127D60);
2022-05-07 14:31:17 +08:00
#endif
2022-09-06 00:08:26 +08:00
2022-11-06 23:12:18 +08:00
#ifdef DRAWITEM
2022-09-06 00:08:26 +08:00
//HOOK Item<65><6D><EFBFBD><EFBFBD>
MH_CreateHook((void*)0x7AA800, &newsub7AA800, reinterpret_cast<void**>(&sub7AA800));
MH_EnableHook((void*)0x7AA800);
2022-11-06 23:12:18 +08:00
#endif
2022-09-06 00:08:26 +08:00
2022-11-06 23:12:18 +08:00
#ifdef GET_EXE_STR
//exe<78>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MH_CreateHook((void*)0x1220590, &Newsub1220590, reinterpret_cast<void**>(&sub1220590));
MH_EnableHook((void*)0x1220590);
#endif
2022-09-06 00:08:26 +08:00
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
//MH_CreateHook((void*)0x48c690, &NewGetItemPos, reinterpret_cast<void**>(&GetItemPos));
//MH_EnableHook((void*)0x48c690);
//nut<75><74><EFBFBD>û<EFBFBD><C3BB>Ƽ<EFBFBD><C6BC>ܵĺ<DCB5><C4BA><EFBFBD>
//MH_CreateHook((void*)0x5DCDA0, &Newsub_5DCDA0, reinterpret_cast<void**>(&sub_5DCDA0));
//MH_EnableHook((void*)0x5DCDA0);
//<2F><><EFBFBD>Ƽ<EFBFBD><C6BC><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
//MH_CreateHook((void*)0x5A4BE0, &Newsub_5A4BE0, reinterpret_cast<void**>(&sub_5A4BE0));
//MH_EnableHook((void*)0x5A4BE0);
//img<6D><67><EFBFBD>Ƶĺ<C6B5><C4BA><EFBFBD>
//MH_CreateHook((void*)0x11A97E0, &Newsub_11A97E0, reinterpret_cast<void**>(&sub_11A97E0));
//MH_EnableHook((void*)0x11A97E0);
//<2F>󲿷<EFBFBD>IMG<4D><47><EFBFBD>ֵĵ<D6B5><C4B5>ú<EFBFBD><C3BA><EFBFBD>
//MH_CreateHook((void*)0x11B2390, &Newsub_11B2390, reinterpret_cast<void**>(&sub_11B2390));
//MH_EnableHook((void*)0x11B2390);
//ģ<><C4A3>Sqrcall
//MH_CreateHook((void*)0x5AACB0, &Newsub_5AADF0, reinterpret_cast<void**>(&sub_5AADF0));
//MH_EnableHook((void*)0x5AACB0);
//MH_CreateHook((void*)0x5A4BE0, &Newsub_5A4BE0, reinterpret_cast<void**>(&sub_5A4BE0));
//MH_EnableHook((void*)0x5A4BE0);
//MH_CreateHook((void*)0x1358A60, &NewSqPushStringFunc, reinterpret_cast<void**>(&OldSQPushString));
//MH_EnableHook((void*)0x1358A60);
2022-11-06 23:12:18 +08:00
//MH_CreateHook((void*)0x11A8F60, &newsub11A8F60, reinterpret_cast<void**>(&sub11A8F60));
//MH_EnableHook((void*)0x11A8F60);
2022-09-06 00:08:26 +08:00
2022-11-06 23:12:18 +08:00
// HOOK exe <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//MH_CreateHook((void*)0x135B2C0, &NewSQ_Compilebuffer, reinterpret_cast<void**>(&OldSQ_Compilebuffer));
//MH_EnableHook((void*)0x135B2C0);
2022-03-16 10:03:39 +08:00
return 0;
}