| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  | #include "dispatch.h"
 | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  | #include "Assembler.h"
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | #include "l_squirrel.h"
 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define MAIN_OFFSET(offset) ((void *)((0x8048000) + (offset)))
 | 
					
						
							|  |  |  | #define SUBHOOK_INIT(func, addr)    \
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	fn##func func = (fn##func)addr; \ | 
					
						
							|  |  |  | 	FuncHook h##func | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define SUBHOOK_SETUP(func) h##func.Hook((void **)&func, (void *)_##func)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | #define INIT_HOOK(func, addr)                      \
 | 
					
						
							|  |  |  | 	using Type_##func = decltype(hook_##func);     \ | 
					
						
							|  |  |  | 	Type_##func *old_##func = (Type_##func *)addr; \ | 
					
						
							| 
									
										
										
										
											2022-09-12 18:11:08 +08:00
										 |  |  | 	FuncHook mhook_##func | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define HOOK_SETUP(func) mhook_##func.Hook((void **)&old_##func, (void *)hook_##func)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  | class Controller | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	SINGLETON_DEFINE_S(Controller); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	Controller(); | 
					
						
							| 
									
										
										
										
											2022-09-03 17:30:34 +08:00
										 |  |  | 	~Controller(); | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  | public: | 
					
						
							|  |  |  | 	void init(); | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	void Jinit(); | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2022-09-02 01:27:05 +08:00
										 |  |  | 	static int hook_IPacketDispatcher_ParamBase_dispatch_template(int a1, int a2, int a3); | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  | 	/**
 | 
					
						
							|  |  |  | 	 * @brief hook修复镶嵌徽章 | 
					
						
							|  |  |  | 	 * @param pDispatcher_UseJewel | 
					
						
							|  |  |  | 	 * @param pUser | 
					
						
							|  |  |  | 	 * @param pBuf | 
					
						
							|  |  |  | 	 * @return | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	static int hook_UseJewel_dispatch_sig(void *pDispatcher_UseJewel, CUser *pUser, PacketBuf *pBuf); | 
					
						
							| 
									
										
										
										
											2022-09-03 17:30:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	// 使用蜜蜡
 | 
					
						
							|  |  |  | 	static int hook_Dispatcher_ModItemAttr_dispatch_sig(Dispatcher_ModItemAttr *dis_mod, CUser *user, PacketBuf *pBuf); | 
					
						
							| 
									
										
										
										
											2022-09-03 17:30:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  | 	/**
 | 
					
						
							|  |  |  | 	 * @brief hook收包处理 | 
					
						
							|  |  |  | 	 * @param a1 | 
					
						
							|  |  |  | 	 * @param a2 | 
					
						
							|  |  |  | 	 * @param a3 | 
					
						
							|  |  |  | 	 * @param a4 | 
					
						
							|  |  |  | 	 * @param src | 
					
						
							|  |  |  | 	 * @param a6 | 
					
						
							|  |  |  | 	 * @param a7 | 
					
						
							|  |  |  | 	 * @param a8 | 
					
						
							|  |  |  | 	 * @return | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	static int hook_PacketDispatcher_doDispatch(PacketDispatcher *a1, CUser *a2, int a3, int packet_id, char *packet_src, int pecakt_len, int a7, int a8); | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	static int hook_LenDispatcher_New_Gmdebug_Command(void *a1, void *pUser, void *pBuf); | 
					
						
							| 
									
										
										
										
											2022-09-03 17:30:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	static int hook_DisPatcher_MoveMap_dispatch_sig(void *a1, CUser *pUser, PacketBuf *pBuf); | 
					
						
							| 
									
										
										
										
											2022-09-03 17:30:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	static int hook_Inter_LoadEtc_dispatch_sig(void *a1, CUser *pUser, char *a3); | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	static int hook_DisPatcher_ReturnToSelectCharacter_dispatch_sig(void *a1, CUser *pUser, char *a3); | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	static void hook_importCashShopItemList(const std::string *str); | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	static void hook_ProcessIPG_ResultOutput(CUser *user, int Goods_No, int item_id, int Cera_Type, InterfacePacketBuf *pbuf); | 
					
						
							| 
									
										
										
										
											2022-09-21 16:28:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	static int hook_Dispatcher_BuyCeraShopItem_dispatch_sig(void *a1, CUser *pUser, PacketBuf *pBuf); | 
					
						
							| 
									
										
										
										
											2022-09-21 16:28:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	static bool hook_Init(int a1, char **a2); | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2022-09-12 18:11:08 +08:00
										 |  |  | 	INIT_HOOK(IPacketDispatcher_ParamBase_dispatch_template, base::IPacketDispatcher::ParamBase::dispatch_template); | 
					
						
							|  |  |  | 	INIT_HOOK(PacketDispatcher_doDispatch, base::PacketDispatcher::doDispatch); | 
					
						
							|  |  |  | 	INIT_HOOK(Dispatcher_ModItemAttr_dispatch_sig, base::Dispatcher_ModItemAttr::dispatch_sig); | 
					
						
							|  |  |  | 	INIT_HOOK(UseJewel_dispatch_sig, base::Dispatcher_UseJewel::dispatch_sig); | 
					
						
							|  |  |  | 	INIT_HOOK(DisPatcher_MoveMap_dispatch_sig, base::DisPatcher_MoveMap::dispatch_sig); | 
					
						
							|  |  |  | 	INIT_HOOK(Inter_LoadEtc_dispatch_sig, base::Inter_LoadEtc::dispatch_sig); | 
					
						
							|  |  |  | 	INIT_HOOK(DisPatcher_ReturnToSelectCharacter_dispatch_sig, base::DisPatcher_ReturnToSelectCharacter::dispatch_sig); | 
					
						
							| 
									
										
										
										
											2022-09-21 16:28:11 +08:00
										 |  |  | 	INIT_HOOK(Init, base::Init); | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	INIT_HOOK(LenDispatcher_New_Gmdebug_Command, 0x820BBDE); | 
					
						
							| 
									
										
										
										
											2022-09-13 22:47:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	CAssembler assembler; | 
					
						
							| 
									
										
										
										
											2024-04-24 10:25:44 +08:00
										 |  |  | 	Assembler *Asm; | 
					
						
							| 
									
										
										
										
											2022-09-01 16:56:37 +08:00
										 |  |  | }; |