From 32348af364f0f20aab60f4c821fe024f30879e60 Mon Sep 17 00:00:00 2001 From: tmp64 Date: Sat, 19 Aug 2023 20:15:43 +0700 Subject: [PATCH] Add GetDispatch hook --- rehlds/engine/sys_dll.cpp | 5 +++++ rehlds/engine/sys_dll.h | 1 + rehlds/public/rehlds/rehlds_api.h | 5 +++++ rehlds/rehlds/rehlds_api_impl.cpp | 4 ++++ rehlds/rehlds/rehlds_api_impl.h | 6 ++++++ 5 files changed, 21 insertions(+) diff --git a/rehlds/engine/sys_dll.cpp b/rehlds/engine/sys_dll.cpp index 293119d..c7434d0 100644 --- a/rehlds/engine/sys_dll.cpp +++ b/rehlds/engine/sys_dll.cpp @@ -677,6 +677,11 @@ qboolean EXT_FUNC Voice_SetClientListening(int iReceiver, int iSender, qboolean } DISPATCHFUNCTION GetDispatch(char *pname) +{ + return g_RehldsHookchains.m_GetDispatch.callChain(GetDispatch_Internal, pname); +} + +DISPATCHFUNCTION GetDispatch_Internal(char* pname) { int i; DISPATCHFUNCTION pDispatch; diff --git a/rehlds/engine/sys_dll.h b/rehlds/engine/sys_dll.h index adab155..66ea83c 100644 --- a/rehlds/engine/sys_dll.h +++ b/rehlds/engine/sys_dll.h @@ -115,6 +115,7 @@ NOBODY void GameSetBackground(qboolean bNewSetting); qboolean Voice_GetClientListening(int iReceiver, int iSender); qboolean Voice_SetClientListening(int iReceiver, int iSender, qboolean bListen); DISPATCHFUNCTION GetDispatch(char *pname); +DISPATCHFUNCTION GetDispatch_Internal(char* pname); const char *FindAddressInTable(extensiondll_t *pDll, uint32 function); uint32 FindNameInTable(extensiondll_t *pDll, const char *pName); NOBODY const char *ConvertNameToLocalPlatform(const char *pchInName); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index bc83581..9c6962f 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -259,6 +259,10 @@ typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ClientPrintf typedef IHookChain IRehldsHook_SV_AllowPhysent; typedef IHookChainRegistry IRehldsHookRegistry_SV_AllowPhysent; +//GetDispatch hook +typedef IHookChain IRehldsHook_GetDispatch; +typedef IHookChainRegistry IRehldsHookRegistry_GetDispatch; + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -318,6 +322,7 @@ public: virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0; virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0; virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent() = 0; + virtual IRehldsHookRegistry_GetDispatch* GetDispatch() = 0; }; struct RehldsFuncs_t { diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index d186220..94af421 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -883,6 +883,10 @@ IRehldsHookRegistry_SV_AllowPhysent* CRehldsHookchains::SV_AllowPhysent() { return &m_SV_AllowPhysent; } +EXT_FUNC IRehldsHookRegistry_GetDispatch* CRehldsHookchains::GetDispatch() { + return &m_GetDispatch; +} + int EXT_FUNC CRehldsApi::GetMajorVersion() { return REHLDS_API_VERSION_MAJOR; diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 699bd16..b5829f1 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -254,6 +254,10 @@ typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_ClientPri typedef IHookChainImpl CRehldsHook_SV_AllowPhysent; typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_AllowPhysent; +//GetDispatch hook +typedef IHookChainImpl CRehldsHook_GetDispatch; +typedef IHookChainRegistryImpl CRehldsHookRegistry_GetDispatch; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -311,6 +315,7 @@ public: CRehldsHookRegistry_SV_AddResource m_SV_AddResource; CRehldsHookRegistry_SV_ClientPrintf m_SV_ClientPrintf; CRehldsHookRegistry_SV_AllowPhysent m_SV_AllowPhysent; + CRehldsHookRegistry_GetDispatch m_GetDispatch; public: EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -368,6 +373,7 @@ public: EXT_FUNC virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource(); EXT_FUNC virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf(); EXT_FUNC virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent(); + EXT_FUNC virtual IRehldsHookRegistry_GetDispatch* GetDispatch(); }; extern CRehldsHookchains g_RehldsHookchains;