数据库类sdk制作完毕

This commit is contained in:
小疯 2022-09-17 14:53:51 +08:00
parent 1dc395f164
commit 34af6a1936
8 changed files with 564 additions and 143 deletions

View File

@ -291,146 +291,7 @@ void Controller::hook_importCashShopItemList(const std::string* str)
void Controller::hook_ProcessIPG_ResultOutput(CUser* user, int Goods_No, int item_id, int Cera_Type, InterfacePacketBuf* pbuf)
{
LOG("hook_ProcessIPG_ResultOutput");
LOG("%s %d %d %d %p", user->getCurCharacName().c_str(), Goods_No, item_id, Cera_Type, pbuf);
if (Cera_Type == 0) //0Êǵãȯ 1ÊÇ´ú±Ò
{
if (Goods_No >= CGameDataManager::Get()->get_cera_award_begin_id() && Goods_No <= CGameDataManager::Get()->get_cera_award_end_id())
{
int cur_purchase_count = 1;
AWARD_ITEM BonusItem;
LOG("Size:%d", CGameDataManager::Get()->get_cera_award_item_map()->Size());
if (CGameDataManager::Get()->get_cera_award_item_map()->Find(cur_purchase_count, &BonusItem))
{
if (user->getCurCharacR())
{
if (BonusItem.item_id == 1)
{
WongWork::CCeraShop::G_CCeraShop()->_processCoin(user, BonusItem.item_num, 0);
}
else
{
auto item = CDataManager::G_CDataManager()->find_item(BonusItem.item_id);
if (item)
{
//if (item->is_stackable()
// && ((*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 16 // GetItemType
// || (*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 34)) // GetItemType
{
int inserted = -1;
Inven_Item v60 = {};
*(_DWORD*)((char*)&v60 + 2) = BonusItem.item_id;
*(_DWORD*)((char*)&v60 + 7) = BonusItem.item_num;
(*(void(**)(CItem*, Inven_Item*))(*(_DWORD*)item + 8))(item, &v60);
auto CurCharacInvenW = user->getCurCharacInvenW();
inserted = CurCharacInvenW->insertItemIntoInventory(v60, 15, 1, 0);
if (inserted == -1)
{
auto CurCharacNo = user->getCurCharacNo();
((WongWork::CMailBoxHelper*)(user))->ReqDBSendNewMailCashShop(&v60, 0, CurCharacNo, 1, 0, 0);
}
else
{
user->SendUpdateItemList(1, 0, inserted);
}
}
}
}
}
pbuf->put_int(BonusItem.item_id);
pbuf->put_int(BonusItem.item_num);
std::vector <unsigned char> code;
for (int i = 0; i < 0x30; i++)
{
code.push_back(0x90);
}
//0817964F 0817967F
CMem::WriteBytes((void*)0x0817964F, code.data(), code.size());
return;
}
}
else if (Goods_No >= CGameDataManager::Get()->get_cera_award_package_begin_id() && Goods_No <= CGameDataManager::Get()->get_cera_award_package_end_id())
{
int cur_purchase_count = 1;
AWARD_ITEM BonusItem;
LOG("Size:%d", CGameDataManager::Get()->get_cera_award_package_item_map()->Size());
if (CGameDataManager::Get()->get_cera_award_package_item_map()->Find(cur_purchase_count, &BonusItem))
{
if (user->getCurCharacR())
{
if (BonusItem.item_id == 1)
{
WongWork::CCeraShop::G_CCeraShop()->_processCoin(user, BonusItem.item_num, 0);
}
else
{
auto item = CDataManager::G_CDataManager()->find_item(BonusItem.item_id);
if (item)
{
//if (item->is_stackable()
// && ((*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 16 // GetItemType
// || (*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 34)) // GetItemType
{
int inserted = -1;
Inven_Item v60 = {};
*(_DWORD*)((char*)&v60 + 2) = BonusItem.item_id;
*(_DWORD*)((char*)&v60 + 7) = BonusItem.item_num;
(*(void(**)(CItem*, Inven_Item*))(*(_DWORD*)item + 8))(item, &v60);
auto CurCharacInvenW = user->getCurCharacInvenW();
inserted = CurCharacInvenW->insertItemIntoInventory(v60, 15, 1, 0);
if (inserted == -1)
{
auto CurCharacNo = user->getCurCharacNo();
((WongWork::CMailBoxHelper*)(user))->ReqDBSendNewMailCashShop(&v60, 0, CurCharacNo, 1, 0, 0);
}
else
{
user->SendUpdateItemList(1, 0, inserted);
}
}
}
}
}
pbuf->put_int(BonusItem.item_id);
pbuf->put_int(BonusItem.item_num);
std::vector <unsigned char> code;
for (int i = 0; i < 0x30; i++)
{
code.push_back(0x90);
}
//0817964F 0817967F
CMem::WriteBytes((void*)0x0817964F, code.data(), code.size());
return;
}
}
}
std::vector <unsigned char> code = {
0x8B, 0x85, 0x04, 0xFF, 0xFF, 0xFF, 0x89, 0x44, 0x24, 0x04, 0x8D, 0x85, 0x14, 0xFF, 0xFF, 0xFF,
0x89, 0x04, 0x24, 0xE8, 0xD5, 0x22, 0xF5, 0xFF, 0x8B, 0x85, 0x00, 0xFF, 0xFF, 0xFF, 0x89, 0x44,
0x24, 0x04, 0x8D, 0x85, 0x14, 0xFF, 0xFF, 0xFF, 0x89, 0x04, 0x24, 0xE8, 0xBD, 0x22, 0xF5, 0xFF
};
CMem::WriteBytes((void*)0x0817964F, code.data(), code.size());
CDispatch::Get()->ProcessIPG_ResultOutput(user, Goods_No, item_id, Cera_Type, pbuf);
}
int Controller::hook_Dispatcher_BuyCeraShopItem_dispatch_sig(void* a1, CUser* pUser, PacketBuf* pBuf)

View File

@ -1,6 +1,5 @@
#include "dispatch.h"
#include "Assembler.h"
#include "GameDataManager.h"
#define MAIN_OFFSET(offset) ((void *)((0x8048000) + (offset)))

View File

@ -556,6 +556,147 @@ ENUM_PACK_RET_TYPE CDispatch::DisPatcher_ReturnToSelectCharacter_dispatch_sig(vo
return PAK_OK;
}
ENUM_PACK_RET_TYPE CDispatch::ProcessIPG_ResultOutput(CUser* user, int Goods_No, int item_id, int Cera_Type, InterfacePacketBuf* pbuf)
{
if (Cera_Type == 0) //0Êǵãȯ 1ÊÇ´ú±Ò
{
if (Goods_No >= CGameDataManager::Get()->get_cera_award_begin_id() && Goods_No <= CGameDataManager::Get()->get_cera_award_end_id())
{
int cur_purchase_count = 1;
AWARD_ITEM BonusItem;
LOG("Size:%d", CGameDataManager::Get()->get_cera_award_item_map()->Size());
if (CGameDataManager::Get()->get_cera_award_item_map()->Find(cur_purchase_count, &BonusItem))
{
if (user->getCurCharacR())
{
if (BonusItem.item_id == 1)
{
WongWork::CCeraShop::G_CCeraShop()->_processCoin(user, BonusItem.item_num, 0);
}
else
{
auto item = CDataManager::G_CDataManager()->find_item(BonusItem.item_id);
if (item)
{
//if (item->is_stackable()
// && ((*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 16 // GetItemType
// || (*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 34)) // GetItemType
{
int inserted = -1;
Inven_Item v60 = {};
*(_DWORD*)((char*)&v60 + 2) = BonusItem.item_id;
*(_DWORD*)((char*)&v60 + 7) = BonusItem.item_num;
(*(void(**)(CItem*, Inven_Item*))(*(_DWORD*)item + 8))(item, &v60);
auto CurCharacInvenW = user->getCurCharacInvenW();
inserted = CurCharacInvenW->insertItemIntoInventory(v60, 15, 1, 0);
if (inserted == -1)
{
auto CurCharacNo = user->getCurCharacNo();
((WongWork::CMailBoxHelper*)(user))->ReqDBSendNewMailCashShop(&v60, 0, CurCharacNo, 1, 0, 0);
}
else
{
user->SendUpdateItemList(1, 0, inserted);
}
}
}
}
}
pbuf->put_int(BonusItem.item_id);
pbuf->put_int(BonusItem.item_num);
std::vector <unsigned char> code;
for (int i = 0; i < 0x30; i++)
{
code.push_back(0x90);
}
//0817964F 0817967F
CMem::WriteBytes((void*)0x0817964F, code.data(), code.size());
return;
}
}
else if (Goods_No >= CGameDataManager::Get()->get_cera_award_package_begin_id() && Goods_No <= CGameDataManager::Get()->get_cera_award_package_end_id())
{
int cur_purchase_count = 1;
AWARD_ITEM BonusItem;
LOG("Size:%d", CGameDataManager::Get()->get_cera_award_package_item_map()->Size());
if (CGameDataManager::Get()->get_cera_award_package_item_map()->Find(cur_purchase_count, &BonusItem))
{
if (user->getCurCharacR())
{
if (BonusItem.item_id == 1)
{
WongWork::CCeraShop::G_CCeraShop()->_processCoin(user, BonusItem.item_num, 0);
}
else
{
auto item = CDataManager::G_CDataManager()->find_item(BonusItem.item_id);
if (item)
{
//if (item->is_stackable()
// && ((*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 16 // GetItemType
// || (*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 34)) // GetItemType
{
int inserted = -1;
Inven_Item v60 = {};
*(_DWORD*)((char*)&v60 + 2) = BonusItem.item_id;
*(_DWORD*)((char*)&v60 + 7) = BonusItem.item_num;
(*(void(**)(CItem*, Inven_Item*))(*(_DWORD*)item + 8))(item, &v60);
auto CurCharacInvenW = user->getCurCharacInvenW();
inserted = CurCharacInvenW->insertItemIntoInventory(v60, 15, 1, 0);
if (inserted == -1)
{
auto CurCharacNo = user->getCurCharacNo();
((WongWork::CMailBoxHelper*)(user))->ReqDBSendNewMailCashShop(&v60, 0, CurCharacNo, 1, 0, 0);
}
else
{
user->SendUpdateItemList(1, 0, inserted);
}
}
}
}
}
pbuf->put_int(BonusItem.item_id);
pbuf->put_int(BonusItem.item_num);
std::vector <unsigned char> code;
for (int i = 0; i < 0x30; i++)
{
code.push_back(0x90);
}
//0817964F 0817967F
CMem::WriteBytes((void*)0x0817964F, code.data(), code.size());
return;
}
}
}
std::vector <unsigned char> code = {
0x8B, 0x85, 0x04, 0xFF, 0xFF, 0xFF, 0x89, 0x44, 0x24, 0x04, 0x8D, 0x85, 0x14, 0xFF, 0xFF, 0xFF,
0x89, 0x04, 0x24, 0xE8, 0xD5, 0x22, 0xF5, 0xFF, 0x8B, 0x85, 0x00, 0xFF, 0xFF, 0xFF, 0x89, 0x44,
0x24, 0x04, 0x8D, 0x85, 0x14, 0xFF, 0xFF, 0xFF, 0x89, 0x04, 0x24, 0xE8, 0xBD, 0x22, 0xF5, 0xFF
};
CMem::WriteBytes((void*)0x0817964F, code.data(), code.size());
return PAK_OK;
}
void CDispatch::SendMsg(CUser* user, int pack_id, int status, const std::string& str)
{
char out_str[0xff] = {};

View File

@ -6,6 +6,7 @@
#include "Singleton.h"
#include "./sdk/sdk_class.h"
#include "utils.h"
#include "GameDataManager.h"
enum NOTI_PACKETMESSAGE_TYPE : int
{
@ -38,6 +39,7 @@ public:
ENUM_PACK_RET_TYPE DisPatcher_ReturnToSelectCharacter_dispatch_sig(void* a1, CUser* user, char* a3);
ENUM_PACK_RET_TYPE ProcessIPG_ResultOutput(CUser* user, int Goods_No, int item_id, int Cera_Type, InterfacePacketBuf* pbuf);
void SendMsg(CUser* user, int pack_id, int status, const std::string& str);

View File

@ -12,7 +12,7 @@ public:
static DBMgr* G_CDBMgr()
{
return *(DBMgr**)base::GlobalData::s_db_mgr;
return (DBMgr*)base::GlobalData::s_db_mgr;
}
int setUserIdx(int a2)

View File

@ -4,10 +4,358 @@
#define __MYSQL_H__
class CQueryCounter
{
public:
unsigned char UnknownData_NULL[0x3C];
public:
int CQueryCounter_make()
{
return CallT<int>(base::CQueryCounter::CQueryCounter_make, this);
}
int GetQueryCountTable()
{
return CallT<int>(base::CQueryCounter::GetQueryCountTable, this);
}
int IncreaseQueryCount(std::string const& a2)
{
return CallT<int>(base::CQueryCounter::IncreaseQueryCount, this, a2);
}
int LoadQueryTable()
{
return CallT<int>(base::CQueryCounter::LoadQueryTable, this);
}
int RegisterQuery(char const* a2, int a3, int a4)
{
return CallT<int>(base::CQueryCounter::RegisterQuery, this, a2, a3, a4);
}
int Reset()
{
return CallT<int>(base::CQueryCounter::Reset, this);
}
int SaveQuery(char const* a2, int& a3)
{
return CallT<int>(base::CQueryCounter::SaveQuery, this, a2, a3);
}
int SetResponseTime(double a2)
{
return CallT<int>(base::CQueryCounter::SetResponseTime, this, a2);
}
int UpdateQueryCounter()
{
return CallT<int>(base::CQueryCounter::UpdateQueryCounter, this);
}
int setLogDB(bool a2)
{
return CallT<int>(base::CQueryCounter::setLogDB, this, a2);
}
int CQueryCounter_destroy()
{
return CallT<int>(base::CQueryCounter::CQueryCounter_destroy, this);
}
};
class MySQL
{
public:
unsigned char UnknownData_NULL[0x4208C];
public:
int GetQueryCounter()
{
return CallT<int>(base::MySQL::GetQueryCounter, this);
}
int GetQueryString()
{
return CallT<int>(base::MySQL::GetQueryString, this);
}
MySQL()
{
CallT<int>(base::MySQL::MySQL_make, this);
}
int SetQueryCounter(CQueryCounter* a2)
{
return CallT<int>(base::MySQL::SetQueryCounter, this, a2);
}
int blob_to_str(int a2, void* a3, int a4)
{
return CallT<int>(base::MySQL::blob_to_str, this, a2, a3, a4);
}
int clear_result_set()
{
return CallT<int>(base::MySQL::clear_result_set, this);
}
int close()
{
return CallT<int>(base::MySQL::close, this);
}
int escape_string(char* a2, char const* a3)
{
return CallT<int>(base::MySQL::escape_string, this, a2, a3);
}
int exec(bool a2)
{
return CallT<int>(base::MySQL::exec, this, a2);
}
int exec_query()
{
return CallT<int>(base::MySQL::exec_query, this);
}
int fetch()
{
return CallT<int>(base::MySQL::fetch, this);
}
int getAffectedRowCount()
{
return CallT<int>(base::MySQL::getAffectedRowCount, this);
}
int getClientVersion()
{
return CallT<int>(base::MySQL::getClientVersion, this);
}
int getDBError()
{
return CallT<int>(base::MySQL::getDBError, this);
}
int getServerVersion()
{
return CallT<int>(base::MySQL::getServerVersion, this);
}
int get_binary(int a2, void* a3, int a4)
{
return CallT<int>(base::MySQL::get_binary, this, a2, a3, a4);
}
int get_binary_length(int a2)
{
return CallT<int>(base::MySQL::get_binary_length, this, a2);
}
int get_byte(int a2, char& a3)
{
return CallT<int>(base::MySQL::get_byte, this, a2, a3);
}
int get_byte2(int a2, int& a3)
{
return CallT<int>(base::MySQL::get_byte2, this, a2, a3);
}
int get_char(int a2, char& a3)
{
return CallT<int>(base::MySQL::get_char, this, a2, a3);
}
int get_float(int a2, float& a3)
{
return CallT<int>(base::MySQL::get_float, this, a2, a3);
}
int get_int(int a2, int& a3)
{
return CallT<int>(base::MySQL::get_int, this, a2, a3);
}
int get_int2(int a2, uint& a3)
{
return CallT<int>(base::MySQL::get_int2, this, a2, a3);
}
int get_longlong(int a2, long long& a3)
{
return CallT<int>(base::MySQL::get_longlong, this, a2, a3);
}
int get_n_rows()
{
return CallT<int>(base::MySQL::get_n_rows, this);
}
int get_short(int a2, int& a3)
{
return CallT<int>(base::MySQL::get_short, this, a2, a3);
}
int get_short2(int a2, short& a3)
{
return CallT<int>(base::MySQL::get_short2, this, a2, a3);
}
int get_str(int a2, char* a3, int a4)
{
return CallT<int>(base::MySQL::get_str, this, a2, a3, a4);
}
int get_ubyte(int a2, uchar& a3)
{
return CallT<int>(base::MySQL::get_ubyte, this, a2, a3);
}
int get_uint(int a2, uint& a3)
{
return CallT<int>(base::MySQL::get_uint, this, a2, a3);
}
int get_ulong(int a2, ulong& a3)
{
return CallT<int>(base::MySQL::get_ulong, this, a2, a3);
}
int get_ulonglong(int a2, unsigned long long& a3)
{
return CallT<int>(base::MySQL::get_ulonglong, this, a2, a3);
}
int get_ushort(int a2, ushort& a3)
{
return CallT<int>(base::MySQL::get_ushort, this, a2, a3);
}
int init()
{
return CallT<int>(base::MySQL::init, this);
}
int init_db_handle()
{
return CallT<int>(base::MySQL::init_db_handle, this);
}
int insert(char const* a2, ...)
{
int nSize = 0;
char buff[1024];
memset(buff, 0, sizeof(buff));
va_list args;
va_start(args, a2);
nSize = vsnprintf(buff, sizeof(buff), a2, args);
va_end(args);
return CallT<int>(base::MySQL::insert, this, buff);
}
int is_valid_col(int a2)
{
return CallT<int>(base::MySQL::is_valid_col, this, a2);
}
int is_valid_data(int a2)
{
return CallT<int>(base::MySQL::is_valid_data, this, a2);
}
int open(char* a2, char* a3, char* a4, char* a5)
{
return CallT<int>(base::MySQL::open, this, a2, a3, a4, a5);
}
int open(char* a2, uint a3, char* a4, char* a5, char* a6)
{
return CallT<int>(base::MySQL::open, this, a2, a3, a4, a5, a6);
}
int ping()
{
return CallT<int>(base::MySQL::ping, this);
}
int select(char const* a2, ...)
{
int nSize = 0;
char buff[1024];
memset(buff, 0, sizeof(buff));
va_list args;
va_start(args, a2);
nSize = vsnprintf(buff, sizeof(buff), a2, args);
va_end(args);
return CallT<int>(base::MySQL::select, this, buff);
}
int select2()
{
return CallT<int>(base::MySQL::select2, this);
}
int set_charset_name_option()
{
return CallT<int>(base::MySQL::set_charset_name_option, this);
}
int set_compress_option()
{
return CallT<int>(base::MySQL::set_compress_option, this);
}
int set_query(char const* a2, ...)
{
int nSize = 0;
char buff[1024];
memset(buff, 0, sizeof(buff));
va_list args;
va_start(args, a2);
nSize = vsnprintf(buff, sizeof(buff), a2, args);
va_end(args);
return CallT<int>(base::MySQL::set_query, this, buff);
}
int set_query2()
{
return CallT<int>(base::MySQL::set_query2, this);
}
int set_read_default_grp_option()
{
return CallT<int>(base::MySQL::set_read_default_grp_option, this);
}
int set_reconnect_option()
{
return CallT<int>(base::MySQL::set_reconnect_option, this);
}
int update(char const* a2, ...)
{
int nSize = 0;
char buff[1024];
memset(buff, 0, sizeof(buff));
va_list args;
va_start(args, a2);
nSize = vsnprintf(buff, sizeof(buff), a2, args);
va_end(args);
return CallT<int>(base::MySQL::update, this, buff);
}
~MySQL()
{
CallT<int>(base::MySQL::MySQL_destroy, this);
}
};

View File

@ -6,6 +6,8 @@ namespace base
const int ScanInt = 0x088BC37B;
const int ScanStr = 0x088BC7A2;
const int Init = 0x082A08F4;
const int importCashShopItemList = 0x088FDCB5;
const int importCashShopItemList_hook_begin = 0x088FDD59;
@ -392,8 +394,75 @@ namespace base
}
namespace CQueryCounter
{
const int CQueryCounter_make = 0x085ECAEC;
const int GetQueryCountTable = 0x0844D652;
const int IncreaseQueryCount = 0x085ECC5E;
const int LoadQueryTable = 0x085ED18A;
const int RegisterQuery = 0x085ED5AE;
const int Reset = 0x085ECBD6;
const int SaveQuery = 0x085ED3A2;
const int SetResponseTime = 0x085ED108;
const int UpdateQueryCounter = 0x085ECEE6;
const int setLogDB = 0x0844D63A;
const int CQueryCounter_destroy = 0x085ECB8A;
}
namespace MySQL
{
const int GetQueryCounter = 0x082A4202;
const int GetQueryString = 0x0844D65E;
const int MySQL_make = 0x083F3AC8;
const int SetQueryCounter = 0x083F531C;
const int blob_to_str = 0x083F452A;
const int clear_result_set = 0x083F5630;
const int close = 0x083F3E74;
const int escape_string = 0x083F48AA;
const int exec = 0x083F4326;
const int exec_query = 0x083F5348;
const int fetch = 0x083F44BC;
const int getAffectedRowCount = 0x083F4310;
const int getClientVersion = 0x083F4622;
const int getDBError = 0x0811B97A;
const int getServerVersion = 0x083F460C;
const int get_binary = 0x0812531A;
const int get_binary_length = 0x081253DE;
const int get_byte = 0x080FDE54;
const int get_byte2 = 0x0844D73A;
const int get_char = 0x0815E6A6;
const int get_float = 0x0844D6D0;
const int get_int = 0x0811692C;
const int get_int2 = 0x080E22AE;
const int get_longlong = 0x085F4214;
const int get_n_rows = 0x080E236C;
const int get_short = 0x0814201C;
const int get_short2 = 0x080FDDEC;
const int get_str = 0x080ECDEA;
const int get_ubyte = 0x080FDEBA;
const int get_uint = 0x080E22F2;
const int get_ulong = 0x0844D66A;
const int get_ulonglong = 0x081754C8;
const int get_ushort = 0x08116990;
const int init = 0x083F3CE4;
const int init_db_handle = 0x083F3C16;
const int insert = 0x083F46AE;
const int is_valid_col = 0x080E22D0;
const int is_valid_data = 0x085F41B2;
const int open = 0x083F3E9E;
const int open = 0x083F4024;
const int ping = 0x083F4514;
const int select = 0x083F4678;
const int select2 = 0x083F4630;
const int set_charset_name_option = 0x083F3C02;
const int set_compress_option = 0x083F3AFE;
const int set_query = 0x083F41C0;
const int set_query2 = 0x083F4782;
const int set_read_default_grp_option = 0x083F3B80;
const int set_reconnect_option = 0x083F3C0C;
const int update = 0x083F4718;
const int MySQL_destroy = 0x083F3AEA;
}

View File

@ -4,6 +4,7 @@
#include "enum.h"
#include "ida_sdk.h"
#include <string>
#include <vector>
template<typename R, typename A, typename ... ARG> R CallT(A call_addr, const ARG ... arguments)