绘制字符(不太满意)

This commit is contained in:
2022-04-24 02:31:42 +08:00
parent 3bdafc7e35
commit 6583312298
12 changed files with 150 additions and 69 deletions

View File

@@ -1,14 +1,8 @@
#include "pch.h"
#include "hook.h"
#include "sock.h"
#include "MinHook.h"
#include "squirrel.h"
#pragma comment(lib, "libMinHook.x86.lib")
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)
{
@@ -29,62 +23,56 @@ void hook::H_Register_Pack(void* Ecx)
}
std::map<wchar_t*, int> bufferm;
static SqPushRootFunc* yuancall;
uint32_t ThFunc(uint32_t v)
void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4, int a5, int a6)
{
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)str);
}
DrawCodeT1_STL.clear();
}
if (a3 == 9999 && a4 == 9998)
{
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)str);
}
DrawCodeT2_STL.clear();
}
int a = yuancall(v);
//std::cout << u8"参数个数" << params << std::endl;
//SQ_Get(v, -2);
//std::cout <<u8"参数个数为" << ParameterNum - 1 << std::endl;
for (int i = -3; i < 3; ++i)
{
if (SQ_GetType(v, i) == 134217744)
{
wchar_t* Name;
SQGetString(v, i, &Name);
if (bufferm.count(Name) == 0)
{
bufferm[Name] = 1;
std::wcout << u8"参数为" << Name << std::endl;
}
}
}
//SQPrintFunc(v);
return a;
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_CreateHook((void*)0x1358C50, &ThFunc, reinterpret_cast<void**>(&yuancall));
MH_EnableHook((void*)INIT_PACK_ADDRESS);
MH_EnableHook((void*)INIT_NUT_ADDRESS);
//MH_EnableHook((void*)0x1358C50);
MH_EnableHook((void*)INIT_NUT_DRAWCODE);
return 0;
}
int hook::InitGameScript()
{
MH_EnableHook((void*)0x1359280);
/*
uint32_t v = GetSqVm();
SQPushRootTable(v);
SQPushString(v, L"SetHudUI", -1);
@@ -97,6 +85,6 @@ int hook::InitGameScript()
std::cout << u8"调用成功" << std::endl;
*/
return 0;
}