修复 商城购买赠送物品
This commit is contained in:
@@ -8,9 +8,11 @@
|
||||
|
||||
#include "controller.h"
|
||||
|
||||
Controller::Controller()
|
||||
Controller::Controller() :
|
||||
assembler(Arch::kX86),
|
||||
Asm(NULL)
|
||||
{
|
||||
|
||||
Asm = assembler.GetAssembler();
|
||||
}
|
||||
|
||||
Controller::~Controller()
|
||||
@@ -18,16 +20,15 @@ Controller::~Controller()
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Controller::init()
|
||||
{
|
||||
Mem::WriteUChar((void*)(base::GlobalData::Init_fix_1 - 0x1), 0);
|
||||
CMem::WriteUChar((void*)(base::GlobalData::Init_fix_1 - 0x1), 0);
|
||||
//.text:085BDE9D 83 F8 0A cmp eax, 10
|
||||
Mem::WriteUChar((void*)(base::CParty::addDungeonClear_fix_1 + 2), 0x7E); //普通被击
|
||||
CMem::WriteUChar((void*)(base::CParty::addDungeonClear_fix_1 + 2), 0x7E); //普通被击
|
||||
//.text:085BDF30 83 F8 1E cmp eax, 30
|
||||
Mem::WriteUChar((void*)(base::CParty::addDungeonClear_fix_2 + 2), 0x7E); //远古被击
|
||||
CMem::WriteUChar((void*)(base::CParty::addDungeonClear_fix_2 + 2), 0x7E); //远古被击
|
||||
//.text:085BDFC3 83 F8 32 cmp eax, 50
|
||||
Mem::WriteUChar((void*)(base::CParty::addDungeonClear_fix_3 + 2), 0x7E); //异界被击
|
||||
CMem::WriteUChar((void*)(base::CParty::addDungeonClear_fix_3 + 2), 0x7E); //异界被击
|
||||
|
||||
|
||||
/* 修正使用代币增加积分
|
||||
@@ -35,11 +36,61 @@ void Controller::init()
|
||||
08179043 0x1 97 B8
|
||||
0817904E 0x1 8C AD
|
||||
*/
|
||||
Mem::WriteUChar((void*)(0x08179043), 0xB8);
|
||||
Mem::WriteUChar((void*)(0x0817904E), 0xAD);
|
||||
CMem::WriteUChar((void*)(0x08179043), 0xB8);
|
||||
CMem::WriteUChar((void*)(0x0817904E), 0xAD);
|
||||
|
||||
|
||||
//mov dword ptr [esp+4], 8E0F448h
|
||||
Asm->lea(eax, dword_ptr(ebp, -0x84));
|
||||
Asm->mov(dword_ptr(esp), eax);
|
||||
Asm->mov(eax, int(&hook_importCashShopItemList));
|
||||
Asm->call(eax);
|
||||
Asm->mov(dword_ptr(esp, 4), 0x8E0F448);
|
||||
Asm->mov(eax, base::importCashShopItemList_hook_end);
|
||||
Asm->jmp(eax);
|
||||
auto code_importCashShopItemList = assembler.GetBytes(true);
|
||||
void* new_importCashShopItemList_addr = Utils::alloc(code_importCashShopItemList.size());
|
||||
CMem::WriteBytes(new_importCashShopItemList_addr, code_importCashShopItemList.data(), code_importCashShopItemList.size());
|
||||
LOG("code :%s", Utils::ToHexString((const unsigned char*)code_importCashShopItemList.data(), code_importCashShopItemList.size()).c_str());
|
||||
LOG("code_addr :%p", new_importCashShopItemList_addr);
|
||||
|
||||
CMem::HookJmp(base::importCashShopItemList_hook_begin, (int)new_importCashShopItemList_addr);
|
||||
|
||||
/************************************************************************/
|
||||
/* HOOK 商城购买物品成功处理 */
|
||||
/************************************************************************/
|
||||
//mov dword ptr [ebp-0FCh], 0FFFFFFFFh
|
||||
|
||||
Asm->lea(eax, dword_ptr(ebp, -0xEC));
|
||||
Asm->mov(dword_ptr(esp, 0x10), eax);
|
||||
|
||||
Asm->mov(eax, dword_ptr(ebp, -0x3A));
|
||||
Asm->mov(dword_ptr(esp, 0xc), eax);
|
||||
|
||||
Asm->mov(eax, dword_ptr(ebp, -0x5C));
|
||||
Asm->mov(dword_ptr(esp, 8), eax);
|
||||
|
||||
Asm->mov(eax, dword_ptr(ebp, -0x60));
|
||||
Asm->mov(dword_ptr(esp, 4), eax);
|
||||
|
||||
Asm->mov(eax, dword_ptr(ebp, 0xC));
|
||||
Asm->mov(dword_ptr(esp), eax);
|
||||
|
||||
Asm->mov(eax, int(&hook_ProcessIPG_ResultOutput));
|
||||
Asm->call(eax);
|
||||
|
||||
|
||||
Asm->mov(dword_ptr(ebp, -0xfc), 0x0FFFFFFFF);
|
||||
Asm->mov(eax, base::ItemVendingMachine::ProcessIPG_ResultOutput_hook_end);
|
||||
Asm->jmp(eax);
|
||||
auto code_ProcessIPG_ResultOutput = assembler.GetBytes(true);
|
||||
void* new_ProcessIPG_ResultOutput_addr = Utils::alloc(code_ProcessIPG_ResultOutput.size());
|
||||
CMem::WriteBytes(new_ProcessIPG_ResultOutput_addr, code_ProcessIPG_ResultOutput.data(), code_ProcessIPG_ResultOutput.size());
|
||||
LOG("code_2 :%s", Utils::ToHexString((const unsigned char*)code_ProcessIPG_ResultOutput.data(), code_ProcessIPG_ResultOutput.size()).c_str());
|
||||
LOG("code_addr_2 :%p", new_ProcessIPG_ResultOutput_addr);
|
||||
|
||||
|
||||
CMem::HookJmp(base::ItemVendingMachine::ProcessIPG_ResultOutput_hook_begin, (int)new_ProcessIPG_ResultOutput_addr);
|
||||
|
||||
//HOOK_SETUP(IPacketDispatcher_ParamBase_dispatch_template);
|
||||
|
||||
@@ -192,3 +243,121 @@ int Controller::hook_DisPatcher_ReturnToSelectCharacter_dispatch_sig(void* a1, C
|
||||
return Get()->old_DisPatcher_ReturnToSelectCharacter_dispatch_sig(a1, pUser, a3);
|
||||
}
|
||||
|
||||
void Controller::hook_importCashShopItemList(const std::string* str)
|
||||
{
|
||||
LOG("hook_importCashShopItemList :%s", str->c_str());
|
||||
if (str == NULL) return;
|
||||
if (*str == "[start end id]")
|
||||
{
|
||||
int item_id_begin_ = ScanInt();
|
||||
int item_id_end_ = ScanInt();
|
||||
|
||||
CGameDataManager::Get()->set_cera_award_begin_id(item_id_begin_);
|
||||
CGameDataManager::Get()->set_cera_award_end_id(item_id_end_);
|
||||
LOG("hook_importCashShopItemList item_id_begin_ :%d item_id_end_ :%d", item_id_begin_, item_id_end_);
|
||||
}
|
||||
else if (*str == "[reward item]")
|
||||
{
|
||||
int _total = ScanInt();
|
||||
LOG("hook_importCashShopItemList _total :%d", _total);
|
||||
for (int i = 0; i < _total; i++)
|
||||
{
|
||||
int count_ = ScanInt();
|
||||
int item_id = ScanInt();
|
||||
int item_num = ScanInt();
|
||||
CGameDataManager::Get()->add_cera_awarw_item(count_, item_id, item_num);
|
||||
LOG("hook_importCashShopItemList count_ :%d item_id :%d item_num :%d", count_, item_id, item_num);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
int Controller::hook_Dispatcher_BuyCeraShopItem_dispatch_sig(void* a1, CUser* pUser, PacketBuf* pBuf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user