DNF_DLL/test/sock.cpp

74 lines
1.6 KiB
C++
Raw Normal View History

2022-03-08 12:57:35 +08:00
#include "pch.h"
#include "sock.h"
2022-05-07 14:31:17 +08:00
extern std::map<std::string, std::string>Json_STL;
2022-03-11 07:10:23 +08:00
2022-05-07 14:31:17 +08:00
void sock::Pack_Control(int idx, int code, void* p3, void* p4)
2022-03-08 12:57:35 +08:00
{
2022-03-10 20:33:31 +08:00
DWORD Size;
Net_Get_Dword(Size);
2022-03-11 21:52:14 +08:00
char* Buffer = new char[Size + 1];
2022-03-10 20:33:31 +08:00
Net_Get_Buffer(Buffer, Size);
Buffer[Size] = '\0';
2022-05-07 14:31:17 +08:00
rapidjson::Document Dom;
Dom.Parse(Buffer);//<2F><><EFBFBD><EFBFBD> <20>ַ<EFBFBD><D6B7><EFBFBD>
int Op = Dom["op"].GetInt();//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
2022-03-11 07:10:23 +08:00
2022-05-07 14:31:17 +08:00
//<2F><><EFBFBD><EFBFBD>
#if defined DRAGONBOX_SWITCH
if (Op >= 0 && Op < 10)Json_STL["DragonBox"] = Buffer;
#endif
//<2F><><EFBFBD><EFBFBD>Boss
#if defined WORLDBOSS_SWITCH
if (Op >= 10 && Op < 20)Json_STL["WorldBoss"] = Buffer;
2022-04-21 12:48:20 +08:00
#endif
2022-03-08 12:57:35 +08:00
2022-05-07 14:31:17 +08:00
#if defined LOCALHOSTS_SWITCH
std::cout << "130<EFBFBD><EFBFBD><EFBFBD>հ<EFBFBD><EFBFBD>ɹ<EFBFBD>" << std::endl;
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << Buffer << std::endl;
#endif
}
2022-03-08 12:57:35 +08:00
void sock::R_Register_Pack()
{
auto Registerfunc = reinterpret_cast<register_pack_handler_t>(0x7186D0);
2022-05-07 14:31:17 +08:00
Registerfunc(130, Pack_Control, 0);
2022-03-08 12:57:35 +08:00
}
2022-03-10 20:33:31 +08:00
bool sock::Net_Get_Byte(BYTE& v)
2022-03-08 12:57:35 +08:00
{
2022-03-10 20:33:31 +08:00
typedef bool(__cdecl* func_t)(BYTE*);
2022-03-08 12:57:35 +08:00
return reinterpret_cast<func_t>(0x011AEA00)(&v);
}
2022-03-10 20:33:31 +08:00
bool sock::Net_Get_Short(short int& v)
2022-03-08 12:57:35 +08:00
{
2022-03-10 20:33:31 +08:00
typedef bool(__cdecl* func_t)(short int*);
2022-03-08 12:57:35 +08:00
return reinterpret_cast<func_t>(0x011AEA30)(&v);
}
2022-03-10 20:33:31 +08:00
bool sock::Net_Get_Dword(DWORD& v)
2022-03-08 12:57:35 +08:00
{
2022-03-10 20:33:31 +08:00
typedef bool(__cdecl* func_t)(DWORD*);
2022-03-08 12:57:35 +08:00
return reinterpret_cast<func_t>(0x011AEA60)(&v);
}
2022-03-10 20:33:31 +08:00
bool sock::Net_Get_Buffer(char* v, int sz)
2022-03-08 12:57:35 +08:00
{
typedef bool(__cdecl* func_t)(char*, int);
return reinterpret_cast<func_t>(0x011AEA90)(v, sz);
}
/*
bool sock::HookRegistPackHandler(int idx, pack_handler_t handler)
{
return handleTable.emplace(idx, handler).second;
}
*/