From d2fb2a75d24198048bda53dee030cce1f4831a32 Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Thu, 21 Apr 2022 12:48:20 +0800 Subject: [PATCH] 1111 --- test/DNFTOOL.cpp | 33 +++++++++++++++++++++++++++++++ test/DNFTOOL.h | 6 ++++++ test/STL.cpp | 6 ++++++ test/STL.h | 48 ++++++++++++++++++++++++--------------------- test/framework.h | 28 +++++++++++++++++++++++++- test/sock.cpp | 8 ++++++-- test/squirrel.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++---- 7 files changed, 150 insertions(+), 29 deletions(-) diff --git a/test/DNFTOOL.cpp b/test/DNFTOOL.cpp index 12cccc8..38ff2df 100644 --- a/test/DNFTOOL.cpp +++ b/test/DNFTOOL.cpp @@ -284,3 +284,36 @@ void DNFTOOL::GMNotice(char* str, int type, int color) thisc = *(DWORD*)(thisc + 0x40); _Noticecall(thisc, 0, str, color, type, 0, 0, 0); } + +std::string DNFTOOL::GetIP() +{ + httplib::SSLClient Tencword("docs.qq.com"); + + std::string body; + auto res = Tencword.Get("/doc/DQ1dGbVpzTkZDVlhY", + [&](const char* data, size_t data_length) { + body.append(data, data_length); + return true; + }); + int strat_index = body.find("Yosin_Ip:"); + int end_index = body.find("Yosin_IP"); + + if (strat_index != -1 && end_index != -1) + { + std::string rqip = body.substr(strat_index + 9, end_index - (strat_index + 9)); + return rqip; + } + else + return GetIP(); +} + +void DNFTOOL::Wchar_tToString(std::string& szDst, wchar_t* wchar) +{ + wchar_t* wText = wchar; + DWORD dwNum = WideCharToMultiByte(CP_OEMCP, NULL, wText, -1, NULL, 0, NULL, FALSE);// WideCharToMultiByte的运用 + char* psText; // psText为char*的临时数组,作为赋值给std::string的中间变量 + psText = new char[dwNum]; + WideCharToMultiByte(CP_OEMCP, NULL, wText, -1, psText, dwNum, NULL, FALSE);// WideCharToMultiByte的再次运用 + szDst = psText;// std::string赋值 + delete[]psText;// psText的清除 +} diff --git a/test/DNFTOOL.h b/test/DNFTOOL.h index 4cb72c7..56160e7 100644 --- a/test/DNFTOOL.h +++ b/test/DNFTOOL.h @@ -72,12 +72,18 @@ public: //获取装备偏移地址 static int GetEquAddr(int addr); + //wchar_t* 转 char* static char* UnicodeToAnsi(const wchar_t* szStr, char* pResult, int maxLen); + //wchar_t* 转 string* + static void Wchar_tToString(std::string& szDst, wchar_t* wchar); + //char* 转 wchar_t* static wchar_t* AnsiToUnicode(const char* szStr, wchar_t* pResult, int maxLen); //窗口公告 0x10d static void WindowsNotice(char* str, int type = 0x10d, int b = 0x0); //GM公告 static void GMNotice(char* str, int type, int color); + //获取IP + static std::string GetIP(); }; diff --git a/test/STL.cpp b/test/STL.cpp index d9fb9a3..6346a1d 100644 --- a/test/STL.cpp +++ b/test/STL.cpp @@ -1,6 +1,8 @@ #include "pch.h" #include "STL.h" +//龙盒 +#if defined DRAGONBOX_SWITCH void STL::SyncDargonBox_STL() { DargonState_STL["dargonmap"].sync = 0; @@ -98,7 +100,10 @@ int STL::SelectDargonModel_STL(int Type) } return 0; } +#endif +//普通 STL +#if defined NORMAL_STL int STL::Check_STL(std::string name,int Type,int idx) { switch (Type) @@ -199,3 +204,4 @@ bool STL::GetBoolArr_STL(std::string name, int idx) { return BoolArr_STL[name][idx]; } +#endif \ No newline at end of file diff --git a/test/STL.h b/test/STL.h index 76382a7..16c6098 100644 --- a/test/STL.h +++ b/test/STL.h @@ -1,7 +1,7 @@ #pragma once - - +//普通 STL +#if defined NORMAL_STL //构造int类型容器 static std::mapInt_STL; //构造float类型容器 @@ -11,17 +11,6 @@ static std::mapString_STL; //构造bool类型容器 static std::mapBool_STL; -struct TimeSTLStruct -{ - wchar_t* Name; - int Max_Time; - int Now_Time; - long long Static_Time; - HANDLE Thand; -}; -//构造Time类型容器 -static std::mapTime_STL; - //构造intarr类型容器 static std::map>IntArr_STL; //构造floatarr类型容器 @@ -31,16 +20,28 @@ static std::map>StringArr_STL; //构造boolarr类型容器 static std::map>BoolArr_STL; - - - static std::mapaod; static std::mapbod; static std::mapcod; static std::mapdod; +#endif +//时间 STL +#if defined TIME_STL +struct TimeSTLStruct +{ + wchar_t* Name; + int Max_Time; + int Now_Time; + long long Static_Time; + HANDLE Thand; +}; +//构造Time类型容器 +static std::mapTime_STL; +#endif -ifdenf DRAGONBOX_SWITCH +//龙盒 +#if defined DRAGONBOX_SWITCH //抽奖 类型结构体 struct Dargonresult { @@ -60,7 +61,7 @@ struct DargonMap static std::mapDargonState_STL; //龙盒模式Map static std::mapDargonModel_STL; -ifndef +#endif class STL { @@ -68,8 +69,8 @@ private: public: - - + //普通 STL + #if defined NORMAL_STL //查询指定容器是否存在 static int Check_STL(std::string name,int Type,int idx = 0); //static int Check_STL_Idx(std::string name,int idx); @@ -92,14 +93,17 @@ public: static float GetFloatArr_STL(std::string name, int idx); static std::string GetStringArr_STL(std::string name, int idx); static bool GetBoolArr_STL(std::string name, int idx); - + #endif + + //龙盒 + #if defined DRAGONBOX_SWITCH static void SyncDargonBox_STL();//同调龙盒包 static void DrawDargonBox_STL(char* Buffer);//设置龙盒包 static int SelectDargonBox_STL(int Type,int Index = 0);//获取龙盒包 static void DrawDargonModel_STL(int Value);//设置龙盒模式 static int SelectDargonModel_STL(int Type);//获取龙盒模式 - + #endif }; diff --git a/test/framework.h b/test/framework.h index 41be2e2..e6a6cf3 100644 --- a/test/framework.h +++ b/test/framework.h @@ -19,4 +19,30 @@ #include "rapidjson/stringbuffer.h" #include "rapidjson/filereadstream.h" #include "rapidjson/filewritestream.h" -#include "rapidjson/istreamwrapper.h" \ No newline at end of file +#include "rapidjson/istreamwrapper.h" + + + + + + + + + + + + +#define CHRATRBT_SWITCH "浜虹墿鎴栬澶囧睘鎬 鏌ョ湅 淇敼 寮鍚" +#define TOWN_SWITCH "鍩庨晣绫绘帴鍙 寮鍚" +#define CHRINFO_SWITCH "瑙掕壊鐤插姵缁忛獙鑾峰彇 寮鍚" +#define SEND_PACK_SWITCH "鍙戝寘绫 寮鍚" +#define SEND_API_SWITCH "鍙戝寘鍔熻兘API 寮鍚" +#define DOFILE_API_SWITCH "L璋冪敤 寮鍚" +#define LCOUT_API_SWITCH "L杈撳嚭鍏憡 寮鍚" +#define NEW_WINDOW_API_SWITCH "L鏂板缓绐楀彛 寮鍚" +#define SET_SLOT_API_SWITCH "L璁剧疆UI妲 寮鍚" + + +#define DRAGONBOX_SWITCH "榫欑洅寮鍚" +#define NORMAL_STL "鏅歋TL寮鍚" +#define TIME_STL "鏃堕棿STL寮鍚" \ No newline at end of file diff --git a/test/sock.cpp b/test/sock.cpp index be0ce79..6d3aa3f 100644 --- a/test/sock.cpp +++ b/test/sock.cpp @@ -5,8 +5,8 @@ #include "DNFTOOL.h" - - +//龙盒 +#if defined DRAGONBOX_SWITCH void sock::Pack_抽奖(int idx, int code, void* p3, void* p4) { DWORD Size; @@ -25,12 +25,16 @@ void sock::Pack_ std::cout << u8"130号收包成功" << std::endl; } +#endif void sock::R_Register_Pack() { auto Registerfunc = reinterpret_cast(0x7186D0); + //龙盒 + #if defined DRAGONBOX_SWITCH Registerfunc(130, Pack_抽奖, 0); + #endif } bool sock::Net_Get_Byte(BYTE& v) diff --git a/test/squirrel.cpp b/test/squirrel.cpp index 857f928..3393bb3 100644 --- a/test/squirrel.cpp +++ b/test/squirrel.cpp @@ -655,7 +655,8 @@ int squirrel::SetSlot(uint32_t v) return 1; } - +//普通 STL +#if defined NORMAL_STL //查询 类型容器 int squirrel::Get_STL(uint32_t v) { @@ -839,8 +840,10 @@ int squirrel::New_STL(uint32_t v) } return 1; } +#endif - +//时间 STL +#if defined TIME_STL //时间容器线程 void TimeSTL(LPVOID lpParam) { @@ -934,7 +937,10 @@ int squirrel::Timer_STL(uint32_t v) } return 1; } +#endif +//龙盒 +#if defined DRAGONBOX_SWITCH //同步 龙盒数据包 int squirrel::Sync_Dragon_Pack(uint32_t v) { @@ -1050,13 +1056,15 @@ int squirrel::Set_DragonModel(uint32_t v) } return 1; } +#endif + //获取Squirrel v 基址 inline uint32_t GetSqVm() { return *(uint32_t*)0x1AF3544; } - +//注册 Nut API void squirrel::RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t v = NULL) { if (v == NULL) @@ -1071,41 +1079,75 @@ void squirrel::RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t void squirrel::R_Register_Nut() { RegisterNutApi(L"L_sq_Test", squirrel::sq_Test); + + //人物或装备属性 查看 修改 开启 +#if defined CHRATRBT_SWITCH RegisterNutApi(L"L_sq_GetCharacterAttribute", squirrel::GetCharacterAttribute);//获取人物或装备属性 RegisterNutApi(L"L_sq_SetCharacterAttribute", squirrel::SetCharacterAttribute);//设置人物或装备属性 +#endif + +#if defined TOWN_SWITCH RegisterNutApi(L"L_sq_GetTownIndex", squirrel::GetTownIndex);//获取城镇编号 RegisterNutApi(L"L_sq_GetRegionIndex", squirrel::GetRegionIndex);//获取区域编号 RegisterNutApi(L"L_sq_GetTownXpos", squirrel::GetTownXpos);//获取城镇X坐标 RegisterNutApi(L"L_sq_GetTownYpos", squirrel::GetTownYpos);//获取城镇Y坐标 +#endif + +#if defined CHRINFO_SWITCH RegisterNutApi(L"L_sq_GetFatigue", squirrel::GetFatigue);//获取疲劳值 RegisterNutApi(L"L_sq_GetExp", squirrel::GetExp);//获取经验值 +#endif +#if defined SEND_PACK_SWITCH RegisterNutApi(L"L_sq_SendPackType", squirrel::SendPackType);//发包类型 RegisterNutApi(L"L_sq_SendPackByte", squirrel::SendPackByte);//包数据Byte RegisterNutApi(L"L_sq_SendPackWord", squirrel::SendPackWord);//包数据Word RegisterNutApi(L"L_sq_SendPackDWord", squirrel::SendPackDWord);//包数据DWord RegisterNutApi(L"L_sq_SendPackWChar", squirrel::SendPackWChar);//包数据DWord RegisterNutApi(L"L_sq_SendPack", squirrel::SendPack);//发包 +#if defined SEND_API_SWITCH RegisterNutApi(L"L_sq_GivePlayerItem", squirrel::GivePlayerItem);//给用户物品 RegisterNutApi(L"L_sq_GivePlayerEqu", squirrel::GivePlayerEqu);//给用户装备 RegisterNutApi(L"L_sq_GoDungeon", squirrel::GoDungeon);//去副本 RegisterNutApi(L"L_sq_GoTown", squirrel::GoTown);//去城镇 RegisterNutApi(L"L_sq_MoveTown", squirrel::MoveTown);//去城镇 +#endif +#endif + +#if defined DOFILE_API_SWITCH RegisterNutApi(L"L_sq_Dofile", squirrel::LDofile);//加密读取 +#endif + +#if defined LCOUT_API_SWITCH RegisterNutApi(L"L_cout", squirrel::Lcout);//输出公告 +#endif + +#if defined NEW_WINDOW_API_SWITCH RegisterNutApi(L"L_NewWindows", squirrel::NewWindows);//创建窗口 +#endif + +#if defined SET_SLOT_API_SWITCH RegisterNutApi(L"L_SetSlot", squirrel::SetSlot);//设置槽坐标 +#endif - + //普通 STL +#if defined NORMAL_STL RegisterNutApi(L"L_New_STL", squirrel::New_STL);//新建容器 RegisterNutApi(L"L_Set_STL", squirrel::Set_STL);//设置容器 RegisterNutApi(L"L_Get_STL", squirrel::Get_STL);//获取容器 +#endif +//时间 STL +#if defined TIME_STL RegisterNutApi(L"L_Timer_STL", squirrel::Timer_STL);//时间容器 +#endif +//龙盒 +#if defined DRAGONBOX_SWITCH RegisterNutApi(L"L_Get_DragonModel", squirrel::Get_DragonModel);//获取龙盒模式 RegisterNutApi(L"L_Set_DragonModel", squirrel::Set_DragonModel);//设置龙盒模式 RegisterNutApi(L"L_Redom_Dragon", squirrel::Redom_Dragon);//抽奖 RegisterNutApi(L"L_Get_Dragon_Pack", squirrel::Get_Dragon_Pack);//查询龙盒包 RegisterNutApi(L"L_Sync_Dragon_Pack", squirrel::Sync_Dragon_Pack);//同步龙盒包 +#endif }