| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | //************************************
 | 
					
						
							|  |  |  |  | // FileName:  D:\VisualStudioSource\dnf_project\src\controller.cpp
 | 
					
						
							|  |  |  |  | // FullName:  D:\VisualStudioSource\dnf_project\src
 | 
					
						
							|  |  |  |  | // Date:      2022/09/01
 | 
					
						
							|  |  |  |  | // By:        Vance
 | 
					
						
							|  |  |  |  | // Copyright (c) 2022.  Vance All rights reserved
 | 
					
						
							|  |  |  |  | //************************************
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | #include "controller.h"
 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  |  | Controller::Controller() : | 
					
						
							|  |  |  |  | 	assembler(Arch::kX86), | 
					
						
							|  |  |  |  | 	Asm(NULL) | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  |  | 	Asm = assembler.GetAssembler(); | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | Controller::~Controller() | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void Controller::init() | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  |  | 	CMem::WriteUChar((void*)(base::GlobalData::Init_fix_1 - 0x1), 0); | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 	//.text:085BDE9D 83 F8 0A                                                        cmp     eax, 10
 | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  |  | 	CMem::WriteUChar((void*)(base::CParty::addDungeonClear_fix_1 + 2), 0x7E); //<2F><>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 	//.text:085BDF30 83 F8 1E                                                        cmp     eax, 30
 | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  |  | 	CMem::WriteUChar((void*)(base::CParty::addDungeonClear_fix_2 + 2), 0x7E); //Զ<>ű<EFBFBD><C5B1><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 	//.text:085BDFC3 83 F8 32                                                        cmp     eax, 50
 | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  |  | 	CMem::WriteUChar((void*)(base::CParty::addDungeonClear_fix_3 + 2), 0x7E); //<2F><><EFBFBD>类<EFBFBD><E7B1BB>
 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-09 12:24:02 +08:00
										 |  |  |  | 	/*	<09><><EFBFBD><EFBFBD>ʹ<EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD>
 | 
					
						
							|  |  |  |  | 		<EFBFBD><EFBFBD>ַ	<EFBFBD><EFBFBD><EFBFBD><EFBFBD>	ԭʼ<EFBFBD>ֽ<EFBFBD>	<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD> | 
					
						
							|  |  |  |  | 		08179043	0x1	97 	B8 | 
					
						
							|  |  |  |  | 		0817904E	0x1	8C 	AD | 
					
						
							|  |  |  |  | 	*/ | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  |  | 	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 <20>̳ǹ<CCB3><C7B9><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>                                                */ | 
					
						
							|  |  |  |  | 	/************************************************************************/ | 
					
						
							|  |  |  |  | 	//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); | 
					
						
							| 
									
										
										
										
											2022-09-09 12:24:02 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  |  | 	Asm->mov(eax, dword_ptr(ebp, 0xC)); | 
					
						
							|  |  |  |  | 	Asm->mov(dword_ptr(esp), eax); | 
					
						
							| 
									
										
										
										
											2022-09-09 12:24:02 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  |  | 	Asm->mov(eax, int(&hook_ProcessIPG_ResultOutput)); | 
					
						
							|  |  |  |  | 	Asm->call(eax); | 
					
						
							| 
									
										
										
										
											2022-09-09 12:24:02 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  |  | 	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); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-12 18:11:08 +08:00
										 |  |  |  | 	//HOOK_SETUP(IPacketDispatcher_ParamBase_dispatch_template);
 | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-12 18:11:08 +08:00
										 |  |  |  | 	HOOK_SETUP(UseJewel_dispatch_sig); | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-12 18:11:08 +08:00
										 |  |  |  | 	HOOK_SETUP(Dispatcher_ModItemAttr_dispatch_sig); | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-12 18:11:08 +08:00
										 |  |  |  | 	HOOK_SETUP(PacketDispatcher_doDispatch); | 
					
						
							| 
									
										
										
										
											2022-09-03 17:30:34 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-12 18:11:08 +08:00
										 |  |  |  | 	HOOK_SETUP(DisPatcher_MoveMap_dispatch_sig); | 
					
						
							| 
									
										
										
										
											2022-09-03 17:30:34 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-12 18:11:08 +08:00
										 |  |  |  | 	HOOK_SETUP(Inter_LoadEtc_dispatch_sig); | 
					
						
							| 
									
										
										
										
											2022-09-03 17:30:34 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 	LOG("Controller::init()"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | int Controller::hook_IPacketDispatcher_ParamBase_dispatch_template(int a1, int a2, int a3) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	//[root@nimzgryilkxubzo game] # [DNF_PROJECT] Recv() class :1 id : 84 len : 21 callback : 0x81258b6	(nil)0x81258b6	0x8125a06	(nil)(nil)
 | 
					
						
							|  |  |  |  | 	//	[DNF_PROJECT] + 12	0x8bd8d54 :	Dispatcher_ModItemAttr::dispatch_sig(CUser *,PacketBuf &)
 | 
					
						
							|  |  |  |  | 	//	[DNF_PROJECT] + 16	0x8bd8d58 :	IPacketDispatcher<MSG_BASE,ParamBase,(ch_state)0>::check_state(CUser *,PacketBuf &)
 | 
					
						
							|  |  |  |  | 	//	[DNF_PROJECT] + 20	0x8bd8d5c :	Dispatcher_ModItemAttr::read(PacketBuf &,MSG_BASE &)
 | 
					
						
							|  |  |  |  | 	//	[DNF_PROJECT] + 24	0x8bd8d60 :	Dispatcher_ModItemAttr::process(CUser *,MSG_BASE &,ParamBase &)
 | 
					
						
							|  |  |  |  | 	//	[DNF_PROJECT] + 28	0x8bd8d64 :	IPacketDispatcher<MSG_BASE,ParamBase,(ch_state)0>::send(CUser *,ParamBase&)
 | 
					
						
							|  |  |  |  | 	// 
 | 
					
						
							|  |  |  |  | 	// 
 | 
					
						
							|  |  |  |  | 	//	[DNF_PROJECT] + 12	0x8bd7dd4 :	Dispatcher_Antibot::dispatch_sig
 | 
					
						
							|  |  |  |  | 	//	[DNF_PROJECT] + 16	0x8bd7dd8 :	IPacketDispatcher<MSG_BASE,ParamBase,(ch_state)0>::check_state(CUser *,PacketBuf &)
 | 
					
						
							|  |  |  |  | 	//	[DNF_PROJECT] + 20	0x8bd7ddc :	Dispatcher_Antibot::read(PacketBuf &,MSG_BASE &)
 | 
					
						
							|  |  |  |  | 	//	[DNF_PROJECT] + 24	0x8bd7de0 :	Dispatcher_Antibot::process(CUser *,MSG_BASE &,ParamBase &)
 | 
					
						
							|  |  |  |  | 	//	[DNF_PROJECT] + 28	0x8bd7de4 :	IPacketDispatcher<MSG_BASE,ParamBase,(ch_state)0>::send(CUser *,ParamBase&)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	//LOG("ParamBase_dispatch_template[ +12	:%p	+16	:%p	+20	:%p	+24	:%p	+28	:%p ]"
 | 
					
						
							|  |  |  |  | 	//	, *(int*)a1 + 12
 | 
					
						
							|  |  |  |  | 	//	, *(int*)a1 + 16
 | 
					
						
							|  |  |  |  | 	//	, *(int*)a1 + 20
 | 
					
						
							|  |  |  |  | 	//	, *(int*)a1 + 24
 | 
					
						
							|  |  |  |  | 	//	, *(int*)a1 + 28
 | 
					
						
							|  |  |  |  | 	//);
 | 
					
						
							|  |  |  |  | 	Controller::Get()->old_IPacketDispatcher_ParamBase_dispatch_template(a1, a2, a3); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-02 23:34:06 +08:00
										 |  |  |  | int Controller::hook_UseJewel_dispatch_sig(void* pDispatcher_UseJewel, CUser* user, PacketBuf* pBuf) | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-09-12 13:35:16 +08:00
										 |  |  |  | 	ENUM_PACK_RET_TYPE ret = CDispatch::Get()->UseJewel_dispatch_sig(pDispatcher_UseJewel, user, pBuf); | 
					
						
							|  |  |  |  | 	int result = (ret == PAK_ERROR) ? 1 : 0; | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 	// 08217C06  <20>ֽ<EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2022-09-12 13:35:16 +08:00
										 |  |  |  | 	return result; | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-03 17:30:34 +08:00
										 |  |  |  | int Controller::hook_Dispatcher_ModItemAttr_dispatch_sig(Dispatcher_ModItemAttr* dis_mod, CUser* user, PacketBuf* pBuf) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	PacketBuf new_buf; | 
					
						
							|  |  |  |  | 	memcpy(&new_buf, pBuf, sizeof(PacketBuf)); | 
					
						
							| 
									
										
										
										
											2022-09-12 13:35:16 +08:00
										 |  |  |  | 	short equipment_pos = 0; | 
					
						
							| 
									
										
										
										
											2022-09-12 18:11:08 +08:00
										 |  |  |  | 	int equipment_id = 0; | 
					
						
							|  |  |  |  | 	short item_pos = 0; | 
					
						
							| 
									
										
										
										
											2022-09-12 13:35:16 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if ((unsigned __int8)new_buf.get_short(&equipment_pos) != 1 | 
					
						
							|  |  |  |  | 		|| (unsigned __int8)new_buf.get_int(&equipment_id) != 1 | 
					
						
							|  |  |  |  | 		|| (unsigned __int8)new_buf.get_short(&item_pos) != 1) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		user->SendCmdErrorPacket(84, -1); | 
					
						
							|  |  |  |  | 		return 0; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-03 17:30:34 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	CInventory* CurCharacInvenW = user->getCurCharacInvenR(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	auto item_inven = CurCharacInvenW->GetInvenRef(CInventory::INVENTORY_TYPE_ITEM, item_pos); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (!item_inven->isEmpty() && item_inven->getKey() == ITEM_ID_YIJIRUHUN) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		ENUM_PACK_RET_TYPE ret = CDispatch::Get()->Dispatcher_ModItemAttr_dispatch_sig(dis_mod, user, pBuf); | 
					
						
							|  |  |  |  | 		int result = (ret == PAK_ERROR) ? 1 : 0; | 
					
						
							|  |  |  |  | 		return result; | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-09-12 18:11:08 +08:00
										 |  |  |  | 	return Get()->old_Dispatcher_ModItemAttr_dispatch_sig(dis_mod, user, pBuf); | 
					
						
							| 
									
										
										
										
											2022-09-03 17:30:34 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | int Controller::hook_PacketDispatcher_doDispatch(PacketDispatcher* a1, CUser* user, int packet_class, int packet_id, char* packet_src, int packet_len, int a7, int a8) | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | 	int(***dispatcher)(int, CUser*, char*) = (int(***)(int, CUser*, char*))a1->get_dispatcher(packet_id); | 
					
						
							|  |  |  |  | 	if (dispatcher) | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | 		//v32 = (**dispatcher)(dispatcher, user, v25);
 | 
					
						
							|  |  |  |  | 		LOG("Recv()	class:%d	id:%d	len:%d	%p	[ +00 :%p +12 :%p +16 :%p +20 :%p +24 :%p +28 :%p ]" | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 			, packet_class | 
					
						
							|  |  |  |  | 			, packet_id | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | 			, packet_len | 
					
						
							|  |  |  |  | 			, (**dispatcher) | 
					
						
							|  |  |  |  | 			, *(int*)dispatcher | 
					
						
							|  |  |  |  | 			, *(int*)dispatcher + 12 | 
					
						
							|  |  |  |  | 			, *(int*)dispatcher + 16 | 
					
						
							|  |  |  |  | 			, *(int*)dispatcher + 20 | 
					
						
							|  |  |  |  | 			, *(int*)dispatcher + 24 | 
					
						
							|  |  |  |  | 			, *(int*)dispatcher + 28 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-03 17:30:34 +08:00
										 |  |  |  | 	if (packet_id == PACKET_ID_ITEM_USE_EQUIPMENT_MOVEITEM) | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2022-09-02 23:34:06 +08:00
										 |  |  |  | 		int result = 0; | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | 		PacketBuf* v25 = PacketBuf::NewPacketBuf(); | 
					
						
							|  |  |  |  | 		user->setLastPacketID(packet_id); | 
					
						
							|  |  |  |  | 		v25->bind_packet(packet_src, packet_len); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		LOG("Recv()	class:%d	id:%d	len:%d packet_data :%s " | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 			, packet_class | 
					
						
							|  |  |  |  | 			, packet_id | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | 			, packet_len | 
					
						
							| 
									
										
										
										
											2022-09-12 13:35:16 +08:00
										 |  |  |  | 			, Utils::ToHexString((const unsigned char*)packet_src, packet_len).c_str() | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-02 23:34:06 +08:00
										 |  |  |  | 		if (v25) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			ENUM_PACK_RET_TYPE ret = CDispatch::Get()->UseEquipmentMoveItem(user, v25); | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-02 23:34:06 +08:00
										 |  |  |  | 			result = (ret == PAK_ERROR) ? 1 : 0; | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-02 23:34:06 +08:00
										 |  |  |  | 			PacketBuf::DelPacketBuf(v25); | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  |  | 		return result; | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-09-12 18:11:08 +08:00
										 |  |  |  | 	return Get()->old_PacketDispatcher_doDispatch(a1, user, packet_class, packet_id, packet_src, packet_len, a7, a8); | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-12 18:11:08 +08:00
										 |  |  |  | int Controller::hook_DisPatcher_MoveMap_dispatch_sig(void* a1, CUser* pUser, PacketBuf* pBuf) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	ENUM_PACK_RET_TYPE ret = CDispatch::Get()->MoveMap_dispatch_sig(a1, pUser, pBuf); | 
					
						
							|  |  |  |  | 	int result = (ret == PAK_ERROR) ? 1 : 0; | 
					
						
							|  |  |  |  | 	return result; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | int Controller::hook_Inter_LoadEtc_dispatch_sig(void* a1, CUser* pUser, char* a3) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	CDispatch::Get()->Inter_LoadEtc_dispatch_sig(a1, pUser, a3); | 
					
						
							|  |  |  |  | 	return Get()->old_Inter_LoadEtc_dispatch_sig(a1, pUser, a3); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | int Controller::hook_DisPatcher_ReturnToSelectCharacter_dispatch_sig(void* a1, CUser* pUser, char* a3) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	CDispatch::Get()->DisPatcher_ReturnToSelectCharacter_dispatch_sig(a1, pUser, a3); | 
					
						
							|  |  |  |  | 	return Get()->old_DisPatcher_ReturnToSelectCharacter_dispatch_sig(a1, pUser, a3); | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  |  | 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<>ǵ<EFBFBD>ȯ 1<>Ǵ<EFBFBD><C7B4><EFBFBD>
 | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		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; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 |