From 6583312298d32dd1a959b02577425c6a6c3d3f37 Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Sun, 24 Apr 2022 02:31:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=98=E5=88=B6=E5=AD=97=E7=AC=A6=EF=BC=88?= =?UTF-8?q?=E4=B8=8D=E5=A4=AA=E6=BB=A1=E6=84=8F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/DNFTOOL.h | 5 +++ test/Dargon.h | 2 - test/STL.cpp | 3 ++ test/STL.h | 11 ++++++ test/framework.h | 20 ++++++---- test/hook.cpp | 80 +++++++++++++++++---------------------- test/hook.h | 4 ++ test/sock.cpp | 3 -- test/squirrel.cpp | 80 +++++++++++++++++++++++++++++++++++---- test/squirrel.h | 7 ++++ test/test.vcxproj | 1 - test/test.vcxproj.filters | 3 -- 12 files changed, 150 insertions(+), 69 deletions(-) delete mode 100644 test/Dargon.h diff --git a/test/DNFTOOL.h b/test/DNFTOOL.h index 7b2d115..602d7b7 100644 --- a/test/DNFTOOL.h +++ b/test/DNFTOOL.h @@ -46,7 +46,12 @@ static NoticeTCall _NoticeTcall = (NoticeTCall)0xE6E070; typedef int(DrawTe)(DWORD thisc, int a2, int a3, int a4, int a5, int a6, __int64 a7, float a8, float a9, float a10, int a11, int a12); //static NoticeTCall _NoticeTcall = (NoticeTCall)0xE6E070; +//绘制字符 +typedef void(__fastcall* DrawCode)(DWORD thisc, int Seat, int a3, int a4, int a5, int a6); +static DrawCode DrawCodeF; +#define INIT_NUT_DRAWCODE 0x1206BD0 +//0x1b45b94 class DNFTOOL { private: diff --git a/test/Dargon.h b/test/Dargon.h deleted file mode 100644 index c9c7883..0000000 --- a/test/Dargon.h +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once -#include "framework.h" diff --git a/test/STL.cpp b/test/STL.cpp index 6eadc11..1c88d90 100644 --- a/test/STL.cpp +++ b/test/STL.cpp @@ -1,6 +1,9 @@ #include "pch.h" #include "STL.h" +std::vectorDrawCodeT1_STL; +std::vectorDrawCodeT2_STL; + //龙盒 #if defined DRAGONBOX_SWITCH void STL::SyncDargonBox_STL() diff --git a/test/STL.h b/test/STL.h index 93a62b5..8c23e2d 100644 --- a/test/STL.h +++ b/test/STL.h @@ -64,6 +64,17 @@ static std::mapDargonModel_STL; #endif +//绘制汉字结构体 +struct DrawCodestruct +{ + std::string str; + int Xpos; + int Ypos; + int Color; +}; + + + class STL { diff --git a/test/framework.h b/test/framework.h index 51f2c51..9334545 100644 --- a/test/framework.h +++ b/test/framework.h @@ -10,9 +10,6 @@ #include #include -//#include "squirrel.h" -#include "hook.h" -#include "DNFTOOL.h" #include "rapidjson/document.h" @@ -29,8 +26,6 @@ - - #define LOCALHOSTS_SWITCH "鏈湴鍏嶉獙璇 寮鍚" @@ -50,7 +45,7 @@ #define NORMAL_STL "鏅歋TL寮鍚" #define TIME_STL "鏃堕棿STL寮鍚" #define JSON_STL "Json_STL 寮鍚" - +#define CODE_STL "瀛楃_STL 寮鍚" @@ -95,4 +90,15 @@ "QgNT3E6lrOopRk9U48JMV7qRdHF7icGtABGmlcBAqOOQzJWLOUXrukp8BHlAwyt0\n"\ "viEw5OFWhMMr3AUcynsAYVi47iqfSVMrrwWBFfadHNRbcZchmHbwp9fJhzV53ecK\n"\ "LAhMaD06LDHNnEJ1cGt1jiw=\n"\ -"-----END PRIVATE KEY-----" \ No newline at end of file +"-----END PRIVATE KEY-----" + + + + +//#include "squirrel.h" +#include "STL.h" +#include "DNFTOOL.h" +#include "sock.h" +#include "hook.h" +#include "squirrel.h" + diff --git a/test/hook.cpp b/test/hook.cpp index 16ab628..a066078 100644 --- a/test/hook.cpp +++ b/test/hook.cpp @@ -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::vectorDrawCodeT1_STL; +extern std::vectorDrawCodeT2_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 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 <(&Lpfn_Init)); - + //HookNut函数注册 MH_CreateHook((void*)INIT_NUT_ADDRESS, &H_Register_Nut, reinterpret_cast(&MLnewclosure)); + //Hook绘制字符 + MH_CreateHook((void*)INIT_NUT_DRAWCODE, &H_Register_DrawCode, reinterpret_cast(&DrawCodeF)); - MH_CreateHook((void*)0x1358C50, &ThFunc, reinterpret_cast(&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; } diff --git a/test/hook.h b/test/hook.h index b5e78e7..196788c 100644 --- a/test/hook.h +++ b/test/hook.h @@ -1,4 +1,6 @@ #pragma once +#include "MinHook.h" +#pragma comment(lib, "libMinHook.x86.lib") class hook { @@ -11,6 +13,8 @@ public: static uint32_t H_Register_Nut(uint32_t v, void* f, int freeVarsCnt); //HOOK_收包的替换函数 static void H_Register_Pack(void* Ecx); + //HOOK_绘制字符的替换函数 + static void _fastcall H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4, int a5, int a6); //总HOOK static int RegisterHook(); diff --git a/test/sock.cpp b/test/sock.cpp index 6d3aa3f..5e2e13a 100644 --- a/test/sock.cpp +++ b/test/sock.cpp @@ -1,9 +1,6 @@ #include "pch.h" #include "sock.h" -#include "STL.h" -#include "DNFTOOL.h" - //龙盒 #if defined DRAGONBOX_SWITCH diff --git a/test/squirrel.cpp b/test/squirrel.cpp index 4051651..59fbdb5 100644 --- a/test/squirrel.cpp +++ b/test/squirrel.cpp @@ -1,8 +1,6 @@ #include "pch.h" #include "squirrel.h" -#include "DNFTOOL.h" -#include "RSAC.h" -#include "STL.h" + int squirrel::SQloadfile(uint32_t v, const wchar_t* filename, BOOL printerror) { @@ -71,11 +69,17 @@ int squirrel::SQdofile(uint32_t v, const wchar_t* filename, BOOL retval, BOOL pr //Test int squirrel::sq_Test(uint32_t v) { + int a; + SQGetInt(v, 2, &a); + //GMNotice((char*)u"我的天"); //WindowsNotice((char*)u"我的天"); //SQPopTop(v); //SQPushInt(v, 1); + //char* str = (char*)"test"; + + std::cout << a << std::endl; return 0; } //读人物 或 装备属性 @@ -1052,7 +1056,7 @@ int squirrel::Set_DragonModel(uint32_t v) #endif - +//Json STL #if defined JSON_STL //构造Json类型容器 static std::mapJson_STL; @@ -1122,7 +1126,6 @@ int squirrel::Jsoner_STL(uint32_t v) SQGetString(v, 3, &GKey); char* key = DNFTOOL::wchar_tTochar(GKey); rapidjson::Document Dom; - std::cout << Json_STL["Lenheart"].c_str() << std::endl; Dom.Parse(Json_STL[Name].c_str());//加载 字符串 std::vector Data; @@ -1256,6 +1259,64 @@ int squirrel::Jsoner_STL(uint32_t v) } #endif + + +//字符 STL +#if defined CODE_STL +extern std::vectorDrawCodeT1_STL; +extern std::vectorDrawCodeT2_STL; +int squirrel::Coder_STL(uint32_t v) +{ + wchar_t* Str; + int XPos; + int YPos; + int Color; + int Type; + int ParameterNum = SQGetTop(v); + if (ParameterNum == 6) + { + //获取字符串内容 + SQGetString(v, 2, &Str); + //获取X坐标 + SQGetInt(v, 3, &XPos); + //获取X坐标 + SQGetInt(v, 4, &YPos); + //获取颜色 + SQGetInt(v, 5, &Color); + //获取类型 + SQGetInt(v, 6, &Type); + + DrawCodestruct Buffer; + char* str = DNFTOOL::wchar_tTochar(Str); + Buffer.str = str; + Buffer.Xpos = XPos; + Buffer.Ypos = YPos; + Buffer.Color = Color; + switch (Type) + { + case 0: + { + DrawCodeT1_STL.push_back(Buffer); + } + break; + case 1: + { + DrawCodeT2_STL.push_back(Buffer); + } + break; + } + SQPushBool(v, true); + } + else + { + SQPushBool(v, false); + } + return 1; +} +#endif + + + //获取Squirrel v 基址 inline uint32_t GetSqVm() { @@ -1334,7 +1395,7 @@ void squirrel::R_Register_Nut() RegisterNutApi(L"L_Get_STL", squirrel::Get_STL);//获取容器 #endif -//时间 STL + //时间 STL #if defined TIME_STL RegisterNutApi(L"L_Timer_STL", squirrel::Timer_STL);//时间容器 #endif @@ -1344,7 +1405,12 @@ void squirrel::R_Register_Nut() RegisterNutApi(L"L_Json_STL", squirrel::Jsoner_STL);//时间容器 #endif -//龙盒 + //字符 STL +#if defined CODE_STL + RegisterNutApi(L"L_Code_STL", squirrel::Coder_STL);//字符容器 +#endif + + //龙盒 #if defined DRAGONBOX_SWITCH RegisterNutApi(L"L_Get_DragonModel", squirrel::Get_DragonModel);//获取龙盒模式 RegisterNutApi(L"L_Set_DragonModel", squirrel::Set_DragonModel);//设置龙盒模式 diff --git a/test/squirrel.h b/test/squirrel.h index 1db8bdc..2b45aa5 100644 --- a/test/squirrel.h +++ b/test/squirrel.h @@ -1,4 +1,6 @@ #pragma once +#include "DNFTOOL.h" +#include "RSAC.h" //-------------------------------------------------------------------------------------------Squirrel @@ -186,6 +188,9 @@ static SQ_ThrowerrorFunc* SQ_Throwerror = (SQ_ThrowerrorFunc*)0x13591A0; inline uint32_t GetSqVm(); + + + class squirrel { private: @@ -231,6 +236,8 @@ public:// static int Timer_STL(uint32_t v);//时间容器 static int Jsoner_STL(uint32_t v);//时间容器 + static int Coder_STL(uint32_t v);//时间容器 + public://龙盒 static int Sync_Dragon_Pack(uint32_t v);//同步 龙盒数据包 static int Get_Dragon_Pack(uint32_t v);//获取 龙盒数据包 diff --git a/test/test.vcxproj b/test/test.vcxproj index 4a2fa51..9371a2a 100644 --- a/test/test.vcxproj +++ b/test/test.vcxproj @@ -174,7 +174,6 @@ - diff --git a/test/test.vcxproj.filters b/test/test.vcxproj.filters index 868a34b..23a6728 100644 --- a/test/test.vcxproj.filters +++ b/test/test.vcxproj.filters @@ -42,9 +42,6 @@ 澶存枃浠 - - 澶存枃浠 - 澶存枃浠