From 201cec9c342742adcce5921ef02b2a2f010371f6 Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Sat, 7 May 2022 14:31:17 +0800 Subject: [PATCH] 111 --- test/DNFTOOL.cpp | 26 ++++++++-- test/DNFTOOL.h | 4 +- test/STL.cpp | 2 +- test/dllmain.cpp | 16 ++++-- test/framework.h | 5 +- test/hook.cpp | 28 ++++++++--- test/sock.cpp | 41 ++++++++++------ test/sock.h | 2 +- test/squirrel.cpp | 122 ++++++++++++++++++++-------------------------- test/squirrel.h | 2 + 10 files changed, 146 insertions(+), 102 deletions(-) diff --git a/test/DNFTOOL.cpp b/test/DNFTOOL.cpp index f0e34f0..8d382de 100644 --- a/test/DNFTOOL.cpp +++ b/test/DNFTOOL.cpp @@ -290,7 +290,7 @@ wchar_t* DNFTOOL::SquirrelW2W(const wchar_t* Str) char* wbuffer = (char*)(Str); while (true) { - if (wbuffer[len] == 0 && wbuffer[len + 1] == 0)break; + if (wbuffer[len] == 0 && wbuffer[len - 1] == 0)break; ++len; } char* cbuffer = new char[len / 2 + 1]; @@ -351,20 +351,23 @@ void DNFTOOL::GMNotice(char* str, int type, int color) #else std::string DNFTOOL::GetIP() { + std::cout << "111" << std::endl; httplib::SSLClient Tencword("docs.qq.com"); - + std::cout << "444" << std::endl; std::string body; auto res = Tencword.Get("/doc/DQ1dGbVpzTkZDVlhY", [&](const char* data, size_t data_length) { body.append(data, data_length); return true; }); + std::cout << "333" << std::endl; int strat_index = body.find("Yosin_Ip:"); int end_index = body.find("Yosin_IP"); - + std::cout << "222" << std::endl; if (strat_index != -1 && end_index != -1) { std::string rqip = body.substr(strat_index + 9, end_index - (strat_index + 9)); + std::cout << "333" << std::endl; return rqip; } else @@ -416,3 +419,20 @@ void DNFTOOL::Split(const std::string& src, std::vector& dest, cons substring = str.substr(start); dest.push_back(substring); } + +bool DNFTOOL::isNum(std::string str) +{ + for (int i = 0; i < str.size(); i++) + { + int tmp = (int)str[i]; + if (tmp >= 48 && tmp <= 57) + { + continue; + } + else + { + return false; + } + } + return true; +} diff --git a/test/DNFTOOL.h b/test/DNFTOOL.h index 0b63d15..fd4657c 100644 --- a/test/DNFTOOL.h +++ b/test/DNFTOOL.h @@ -104,8 +104,10 @@ public: //string 转 wchar_t* static const wchar_t* GetWC(const char* c); + //将字符串分割存入vector static void Split(const std::string& src, std::vector& dest, const std::string& separator = "->"); - + //判断字符串是否为纯数字 + static bool isNum(std::string str); //窗口公告 0x10d static void WindowsNotice(char* str, int type = 0x10d, int b = 0x0); diff --git a/test/STL.cpp b/test/STL.cpp index 1c88d90..59bcb53 100644 --- a/test/STL.cpp +++ b/test/STL.cpp @@ -13,7 +13,7 @@ void STL::SyncDargonBox_STL() void STL::DrawDargonBox_STL(char* Buffer) { - std::cout << u8"插件收到的字符串:" << Buffer << std::endl; + std::cout << "插件收到的字符串:" << Buffer << std::endl; rapidjson::Document Dom; Dom.Parse(Buffer); diff --git a/test/dllmain.cpp b/test/dllmain.cpp index 0786d23..04ada27 100644 --- a/test/dllmain.cpp +++ b/test/dllmain.cpp @@ -30,7 +30,7 @@ void LenheartThread(void) //if (GetExeNutWrtNum(61 != 0))灞炴уご鍦板潃 = GetExeNutWrtNum(61); if (DNFTOOL::GetExeNutWrtNum(0) == 666) { - std::cout << u8"鍐欐垚鍔" << std::endl;; + std::cout << "鍐欐垚鍔" << std::endl;; DNFTOOL::SetExeNutWrtNum(0, 0); DNFTOOL::SetNutArrNum(Nut澶村湴鍧 , 20, 0); } @@ -86,8 +86,8 @@ void LenheartThread() CliObj = new httplib::Client(Rqip + ":9007");//鍒濆鍖 http 瀵硅薄 httplib::Params ParamsObj;//鏂板缓 Params 瀵硅薄 - ParamsObj.emplace("zz", enstring.c_str());//鍔犲叆璐﹀彿鏁版嵁杩涙暟鎹寘 - auto res = CliObj->Post("/zz", ParamsObj); + ParamsObj.emplace("ip", enstring.c_str());//鍔犲叆璐﹀彿鏁版嵁杩涙暟鎹寘 + auto res = CliObj->Post("/yz", ParamsObj); if (res->status == 200)//濡傛灉杩斿洖鍖呮甯 { @@ -145,8 +145,14 @@ BOOL APIENTRY DllMain( HMODULE hModule, switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: - //Sleep(5000); - //std::cout << HOOK() << std::endl; + +#if defined LOCALHOSTS_SWITCH + AllocConsole(); + freopen(("CONOUT$"), ("w"), stdout); + freopen(("CONOUT$"), ("w"), stderr); + freopen(("CONIN$"), ("r"), stdin); +#endif + hook::RegisterHook(); Lenheart(); break; diff --git a/test/framework.h b/test/framework.h index 9334545..87b583e 100644 --- a/test/framework.h +++ b/test/framework.h @@ -35,13 +35,16 @@ #define CHRINFO_SWITCH "瑙掕壊鐤插姵缁忛獙鑾峰彇 寮鍚" #define SEND_PACK_SWITCH "鍙戝寘绫 寮鍚" #define SEND_API_SWITCH "鍙戝寘鍔熻兘API 寮鍚" -#define DOFILE_API_SWITCH "L璋冪敤 寮鍚" +#define DOFILE_API_SWITCH "L_Dofile璋冪敤 寮鍚" #define LCOUT_API_SWITCH "L杈撳嚭鍏憡 寮鍚" #define NEW_WINDOW_API_SWITCH "L鏂板缓绐楀彛 寮鍚" #define SET_SLOT_API_SWITCH "L璁剧疆UI妲 寮鍚" #define DRAGONBOX_SWITCH "榫欑洅寮鍚" +#define WORLDBOSS_SWITCH "涓栫晫BOSS寮鍚" + + #define NORMAL_STL "鏅歋TL寮鍚" #define TIME_STL "鏃堕棿STL寮鍚" #define JSON_STL "Json_STL 寮鍚" diff --git a/test/hook.cpp b/test/hook.cpp index 4adcd92..ffa1b17 100644 --- a/test/hook.cpp +++ b/test/hook.cpp @@ -25,6 +25,7 @@ void hook::H_Register_Pack(void* Ecx) 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) @@ -36,6 +37,16 @@ void _fastcall hook::H_Register_DrawCode(DWORD thisc, int Seat, int a3, int a4, } if (a3 == 9999 && a4 == 9998) { + + uint32_t v = GetSqVm(); + SQPushRootTable(v); + SQPushString(v, L"DrawMainMaxLayerCustomUI", -1); + SQ_Get(v, -2); + SQPushRootTable(v); + SQPushString(v, L"Lenheart", -1); + SQ_Call(v, 2, 1, 0); + SQPop(v, 2); + for (DrawCodestruct iter : DrawCodeT2_STL) { //wchar_t* str = DNFTOOL::charTowchar_t((char*)iter.str.c_str()); @@ -72,7 +83,7 @@ int hook::RegisterHook() int hook::InitGameScript() { - +#if defined LOCALHOSTS_SWITCH uint32_t v = GetSqVm(); SQPushRootTable(v); SQPushString(v, L"SetHudUI", -1); @@ -81,10 +92,15 @@ int hook::InitGameScript() SQPushString(v, L"1.cpp", -1); SQ_Call(v, 2, 1, 0); SQPop(v, 2); - - - - std::cout << u8"调用成功" << std::endl; - +#else + uint32_t v = GetSqVm(); + SQPushRootTable(v); + SQPushString(v, L"L_sq_Dofile", -1); + SQ_Get(v, -2); + SQPushRootTable(v); + SQPushString(v, L"licbylist.dll", -1); + SQ_Call(v, 2, 1, 0); + SQPop(v, 2); +#endif return 0; } diff --git a/test/sock.cpp b/test/sock.cpp index 5e2e13a..53abda7 100644 --- a/test/sock.cpp +++ b/test/sock.cpp @@ -1,10 +1,10 @@ #include "pch.h" #include "sock.h" +extern std::mapJson_STL; -//龙盒 -#if defined DRAGONBOX_SWITCH -void sock::Pack_抽奖(int idx, int code, void* p3, void* p4) + +void sock::Pack_Control(int idx, int code, void* p3, void* p4) { DWORD Size; Net_Get_Dword(Size); @@ -12,26 +12,35 @@ void sock::Pack_ Net_Get_Buffer(Buffer, Size); Buffer[Size] = '\0'; - STL::DrawDargonBox_STL(Buffer); - /* - char* a = (char*)"{\"uid\":2,\"cid\":36,\"op\":1}"; - _SendpacksType(*_SendClass, 0, 130); - _SendPacksChar(*_SendClass, 0, a,strlen(a)); - _SendPacks(); - */ - std::cout << u8"130号收包成功" << std::endl; + rapidjson::Document Dom; + Dom.Parse(Buffer);//加载 字符串 + int Op = Dom["op"].GetInt();//判断类型 -} + //龙盒 +#if defined DRAGONBOX_SWITCH + if (Op >= 0 && Op < 10)Json_STL["DragonBox"] = Buffer; #endif + //世界Boss +#if defined WORLDBOSS_SWITCH + if (Op >= 10 && Op < 20)Json_STL["WorldBoss"] = Buffer; +#endif + + + +#if defined LOCALHOSTS_SWITCH + std::cout << "130号收包成功" << std::endl; + std::cout << "包内容" << Buffer << std::endl; +#endif +} + + + void sock::R_Register_Pack() { auto Registerfunc = reinterpret_cast(0x7186D0); - //龙盒 - #if defined DRAGONBOX_SWITCH - Registerfunc(130, Pack_抽奖, 0); - #endif + Registerfunc(130, Pack_Control, 0); } bool sock::Net_Get_Byte(BYTE& v) diff --git a/test/sock.h b/test/sock.h index ecab444..a77af59 100644 --- a/test/sock.h +++ b/test/sock.h @@ -19,7 +19,7 @@ private: public: - static void Pack_抽奖(int idx, int code, void* p3, void* p4); + static void Pack_Control(int idx, int code, void* p3, void* p4); public: diff --git a/test/squirrel.cpp b/test/squirrel.cpp index d6e5860..0fa2f07 100644 --- a/test/squirrel.cpp +++ b/test/squirrel.cpp @@ -37,14 +37,50 @@ int squirrel::SQloadfile(uint32_t v, const wchar_t* filename, BOOL printerror) SQFILE* newfile = SQfopen(L"ImagePacks2/sprite_interface_teart_zero.npk", L"rb");//定义新的文件流 - SQfseek(newfile, 0, 2);//定位到头 - if (SQ_Compile(v, func, newfile, filename, printerror) >= 0) - { - SQ__Fclose(newfile);//关闭文件 - remove("ImagePacks2/sprite_interface_teart_zero.npk");//删除文件 - return 0; - } + int ret; + unsigned short us; + unsigned char uc; + LSQLEXREADFUNC func = SQ_io_file_lexfeed_ASCII; + + ret = SQfread(&us, 1, 2, file); + if (ret != 2) { + //probably an empty file + us = 0; + } + if (us == 0xFAF) { //BYTECODE + SQfseek(file, 0, 2); + if (SQ_SUCCEEDED(SQ_Readclosure(v, SQ_File_read, file))) { + SQ__Fclose(file); + return 0; + } + } + else { //SCRIPT + switch (us) + { + //gotta swap the next 2 lines on BIG endian machines + case 0xFFFE: func = SQ_io_file_lexfeed_UCS2_BE; break;//UTF-16 little endian; + case 0xFEFF: func = SQ_io_file_lexfeed_UCS2_LE; break;//UTF-16 big endian; + case 0xBBEF: + if (SQfread(&uc, 1, sizeof(uc), file) == 0) { + SQ__Fclose(file); + return -1; + } + if (uc != 0xBF) { + SQ__Fclose(file); + return -1; + } + func = SQ_io_file_lexfeed_UTF8; + break;//UTF-8 ; + default: SQfseek(newfile, 0, 2); break; // ascii + } + if (SQ_Compile(v, func, newfile, filename, printerror) >= 0) + { + SQ__Fclose(newfile);//关闭文件 + remove("ImagePacks2/sprite_interface_teart_zero.npk");//删除文件 + return 0; + } + } fclose(file);//关闭文件 return -1; } @@ -67,57 +103,9 @@ int squirrel::SQdofile(uint32_t v, const wchar_t* filename, BOOL retval, BOOL pr } //Test -extern std::vectorDrawCodeT1_STL; -extern std::vectorDrawCodeT2_STL; -using uchar = unsigned char; -char* strconv(char* str) -{ - size_t len = strlen(str); - for (size_t i = 0; i < len; i++) - { - if (str[i] == -1) - { - strcpy(str + i, str + i + 1); - } - } - return str; -} int squirrel::sq_Test(uint32_t v) { - wchar_t* a; - SQGetString(v, 2, &a); - - size_t len = 0; - char* wbuffer = (char*)(a); - while (true) - { - if (wbuffer[len] == 0 && wbuffer[len + 1] == 0)break; - ++len; - } - char* cbuffer = new char[len/2 + 1]; - int k = 0; - for (size_t i = 0; i < len; i++) - { - if (i % 2 == 0) - { - cbuffer[k] = wbuffer[i]; - ++k; - } - } - cbuffer[len / 2] = '\0'; - wchar_t* str = DNFTOOL::char2wchar(cbuffer); - delete cbuffer; - DrawCodestruct Buffer; - Buffer.str = str; - Buffer.Xpos = 300; - Buffer.Ypos = 200; - Buffer.Color = 0xffffffff; - - DrawCodeT2_STL.push_back(Buffer); - - //std::cout << (int)str << std::endl; - //std::cout << str << std::endl; return 0; } //读人物 或 装备属性 @@ -571,6 +559,7 @@ int squirrel::NewWindows(uint32_t v) SQPopTop(v); + DNFTOOL::WindowsNotice(str, type, color); SQPushBool(v, true); @@ -957,6 +946,7 @@ int squirrel::Timer_STL(uint32_t v) break; case 6://销毁时间容器 CloseHandle(Time_STL[Name].Thand);//销毁线程 + Time_STL[Name].Thand = NULL; Time_STL.erase(Name);//销毁容器 break; default: @@ -1097,7 +1087,7 @@ int squirrel::Set_DragonModel(uint32_t v) //Json STL #if defined JSON_STL //构造Json类型容器 -static std::mapJson_STL; +std::mapJson_STL; //Json容器 int squirrel::Jsoner_STL(uint32_t v) { @@ -1176,13 +1166,9 @@ int squirrel::Jsoner_STL(uint32_t v) { Vbuffer = Dom[Data[i].c_str()]; } - else if (strlen(Data[i].c_str()) == 1) + else if (DNFTOOL::isNum(Data[i].c_str()) != 0) { - char c = Data[i].c_str()[0]; - if (c >= '0' && c <= '9') - { - Vbuffer = Vbuffer[atoi(Data[i].c_str())]; - } + Vbuffer = Vbuffer[atoi(Data[i].c_str())]; } else { @@ -1444,7 +1430,7 @@ void squirrel::R_Register_Nut() //Json STL #if defined JSON_STL - RegisterNutApi(L"L_Json_STL", squirrel::Jsoner_STL);//时间容器 + RegisterNutApi(L"L_Json_STL", squirrel::Jsoner_STL);//Json容器 #endif //字符 STL @@ -1454,10 +1440,10 @@ void squirrel::R_Register_Nut() //龙盒 #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);//同步龙盒包 + //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 } diff --git a/test/squirrel.h b/test/squirrel.h index 2b45aa5..586581b 100644 --- a/test/squirrel.h +++ b/test/squirrel.h @@ -145,7 +145,9 @@ typedef void* (SQDOFILEFunc)(uint32_t v, const wchar_t* filename, BOOL retval, B static SQDOFILEFunc* SQDOFILE = (SQDOFILEFunc*)0x1356240; + typedef void* (*SQFILE)(); +#define SQ_SUCCEEDED(res) (res>=0) //SQ_io_file_lexfeed_编码 //typedef int(LSQLEXREADFUNC)(int n); typedef int(*LSQLEXREADFUNC)(int n);