mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-04 02:55:50 +03:00
commit
05ecee33b2
@ -998,7 +998,7 @@ void Cmd_ExecuteString(char *text, cmd_source_t src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
IGameClient* cl = (src == src_client) ? GetRehldsApiClient(host_client) : NULL;
|
IGameClient* cl = (src == src_client) ? GetRehldsApiClient(host_client) : NULL;
|
||||||
if (!g_RehldsHookchains.m_ValidateCommand.callChain(ValidateCmd_API, false, cmd_argv[0], src, cl))
|
if (!g_RehldsHookchains.m_ValidateCommand.callChain(ValidateCmd_API, cmd_argv[0], src, cl))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_RehldsHookchains.m_ExecuteServerStringCmd.callChain(Cmd_ExecuteString_internal, cmd_argv[0], src, cl);
|
g_RehldsHookchains.m_ExecuteServerStringCmd.callChain(Cmd_ExecuteString_internal, cmd_argv[0], src, cl);
|
||||||
|
@ -1307,7 +1307,7 @@ bool EXT_FUNC NET_GetPacketPreprocessor(uint8* data, unsigned int len, const net
|
|||||||
qboolean NET_GetPacket(netsrc_t sock) {
|
qboolean NET_GetPacket(netsrc_t sock) {
|
||||||
qboolean getRes = NET_GetPacket_internal(sock);
|
qboolean getRes = NET_GetPacket_internal(sock);
|
||||||
while (getRes) {
|
while (getRes) {
|
||||||
bool pass = g_RehldsHookchains.m_PreprocessPacket.callChain(NET_GetPacketPreprocessor, FALSE, net_message.data, net_message.cursize, net_from);
|
bool pass = g_RehldsHookchains.m_PreprocessPacket.callChain(NET_GetPacketPreprocessor, net_message.data, net_message.cursize, net_from);
|
||||||
if (pass) {
|
if (pass) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1781,7 +1781,7 @@ qboolean EXT_FUNC SV_FilterUser(USERID_t *userid)
|
|||||||
|
|
||||||
int SV_CheckProtocol(netadr_t *adr, int nProtocol)
|
int SV_CheckProtocol(netadr_t *adr, int nProtocol)
|
||||||
{
|
{
|
||||||
return g_RehldsHookchains.m_SV_CheckProtocol.callChain(SV_CheckProtocol_internal, 0, adr, nProtocol);
|
return g_RehldsHookchains.m_SV_CheckProtocol.callChain(SV_CheckProtocol_internal, adr, nProtocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* <a7396> ../engine/sv_main.c:2302 */
|
/* <a7396> ../engine/sv_main.c:2302 */
|
||||||
@ -1868,7 +1868,7 @@ int SV_CheckChallenge(netadr_t *adr, int nChallengeValue)
|
|||||||
|
|
||||||
int SV_CheckIPRestrictions(netadr_t *adr, int nAuthProtocol)
|
int SV_CheckIPRestrictions(netadr_t *adr, int nAuthProtocol)
|
||||||
{
|
{
|
||||||
return g_RehldsHookchains.m_SV_CheckIPRestrictions.callChain(SV_CheckIPRestrictions_internal, 0, adr, nAuthProtocol);
|
return g_RehldsHookchains.m_SV_CheckIPRestrictions.callChain(SV_CheckIPRestrictions_internal, adr, nAuthProtocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* <a743d> ../engine/sv_main.c:2393 */
|
/* <a743d> ../engine/sv_main.c:2393 */
|
||||||
@ -1909,7 +1909,7 @@ int SV_CheckIPConnectionReuse(netadr_t *adr)
|
|||||||
|
|
||||||
int SV_FinishCertificateCheck(netadr_t *adr, int nAuthProtocol, char *szRawCertificate, char *userinfo)
|
int SV_FinishCertificateCheck(netadr_t *adr, int nAuthProtocol, char *szRawCertificate, char *userinfo)
|
||||||
{
|
{
|
||||||
return g_RehldsHookchains.m_SV_FinishCertificateCheck.callChain(SV_FinishCertificateCheck_internal, 0, adr, nAuthProtocol, szRawCertificate, userinfo);
|
return g_RehldsHookchains.m_SV_FinishCertificateCheck.callChain(SV_FinishCertificateCheck_internal, adr, nAuthProtocol, szRawCertificate, userinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* <a74f4> ../engine/sv_main.c:2461 */
|
/* <a74f4> ../engine/sv_main.c:2461 */
|
||||||
@ -1950,7 +1950,7 @@ int EXT_FUNC SV_FinishCertificateCheck_internal(netadr_t *adr, int nAuthProtocol
|
|||||||
|
|
||||||
int SV_CheckKeyInfo(netadr_t *adr, char *protinfo, short unsigned int *port, int *pAuthProtocol, char *pszRaw, char *cdkey)
|
int SV_CheckKeyInfo(netadr_t *adr, char *protinfo, short unsigned int *port, int *pAuthProtocol, char *pszRaw, char *cdkey)
|
||||||
{
|
{
|
||||||
return g_RehldsHookchains.m_SV_CheckKeyInfo.callChain(SV_CheckKeyInfo_internal, 0, adr, protinfo, port, pAuthProtocol, pszRaw, cdkey);
|
return g_RehldsHookchains.m_SV_CheckKeyInfo.callChain(SV_CheckKeyInfo_internal, adr, protinfo, port, pAuthProtocol, pszRaw, cdkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* <a7584> ../engine/sv_main.c:2527 */
|
/* <a7584> ../engine/sv_main.c:2527 */
|
||||||
@ -7124,7 +7124,7 @@ void SV_Shutdown(void)
|
|||||||
|
|
||||||
qboolean SV_CompareUserID(USERID_t *id1, USERID_t *id2)
|
qboolean SV_CompareUserID(USERID_t *id1, USERID_t *id2)
|
||||||
{
|
{
|
||||||
return g_RehldsHookchains.m_SV_CompareUserID.callChain(SV_CompareUserID_internal, 0, id1, id2);
|
return g_RehldsHookchains.m_SV_CompareUserID.callChain(SV_CompareUserID_internal, id1, id2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* <a5ef9> ../engine/sv_main.c:9585 */
|
/* <a5ef9> ../engine/sv_main.c:9585 */
|
||||||
@ -7153,7 +7153,7 @@ qboolean EXT_FUNC SV_CompareUserID_internal(USERID_t *id1, USERID_t *id2)
|
|||||||
|
|
||||||
char* SV_GetIDString(USERID_t *id)
|
char* SV_GetIDString(USERID_t *id)
|
||||||
{
|
{
|
||||||
return g_RehldsHookchains.m_SV_GetIDString.callChain(SV_GetIDString_internal, 0, id);
|
return g_RehldsHookchains.m_SV_GetIDString.callChain(SV_GetIDString_internal, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* <aad82> ../engine/sv_main.c:9625 */
|
/* <aad82> ../engine/sv_main.c:9625 */
|
||||||
|
@ -687,7 +687,7 @@ qboolean EXT_FUNC Steam_NotifyClientConnect_api(IGameClient *cl, const void *pvS
|
|||||||
qboolean Steam_NotifyClientConnect(client_t *cl, const void *pvSteam2Key, unsigned int ucbSteam2Key)
|
qboolean Steam_NotifyClientConnect(client_t *cl, const void *pvSteam2Key, unsigned int ucbSteam2Key)
|
||||||
{
|
{
|
||||||
return g_RehldsHookchains.m_Steam_NotifyClientConnect
|
return g_RehldsHookchains.m_Steam_NotifyClientConnect
|
||||||
.callChain(Steam_NotifyClientConnect_api, FALSE, GetRehldsApiClient(cl), pvSteam2Key, ucbSteam2Key);
|
.callChain(Steam_NotifyClientConnect_api, GetRehldsApiClient(cl), pvSteam2Key, ucbSteam2Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* <f1884> ../engine/sv_steam3.cpp:914 */
|
/* <f1884> ../engine/sv_steam3.cpp:914 */
|
||||||
@ -707,7 +707,7 @@ qboolean EXT_FUNC Steam_NotifyBotConnect_api(IGameClient* cl)
|
|||||||
|
|
||||||
qboolean Steam_NotifyBotConnect(client_t *cl)
|
qboolean Steam_NotifyBotConnect(client_t *cl)
|
||||||
{
|
{
|
||||||
return g_RehldsHookchains.m_Steam_NotifyBotConnect.callChain(Steam_NotifyBotConnect_api, FALSE, GetRehldsApiClient(cl));
|
return g_RehldsHookchains.m_Steam_NotifyBotConnect.callChain(Steam_NotifyBotConnect_api, GetRehldsApiClient(cl));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* <f18cf> ../engine/sv_steam3.cpp:924 */
|
/* <f18cf> ../engine/sv_steam3.cpp:924 */
|
||||||
|
@ -142,7 +142,10 @@ void SV_ParseConsistencyResponse(client_t *pSenderClient)
|
|||||||
Q_memcpy(resbuffer, r->rguc_reserved, sizeof(resbuffer));
|
Q_memcpy(resbuffer, r->rguc_reserved, sizeof(resbuffer));
|
||||||
if (!Q_memcmp(resbuffer, nullbuffer, sizeof(resbuffer)))
|
if (!Q_memcmp(resbuffer, nullbuffer, sizeof(resbuffer)))
|
||||||
{
|
{
|
||||||
if (MSG_ReadBits(32) != *(uint32 *)&r->rgucMD5_hash[0])
|
uint32 hash = MSG_ReadBits(32);
|
||||||
|
g_RehldsHookchains.m_GenericFileConsistencyResponce.callChain(NULL, GetRehldsApiClient(pSenderClient), r, hash);
|
||||||
|
|
||||||
|
if (hash != *(uint32 *)&r->rgucMD5_hash[0])
|
||||||
c = idx + 1;
|
c = idx + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -30,12 +30,22 @@
|
|||||||
template<typename t_ret, typename ...t_args>
|
template<typename t_ret, typename ...t_args>
|
||||||
class IHookChain {
|
class IHookChain {
|
||||||
protected:
|
protected:
|
||||||
virtual ~IHookChain() { }
|
virtual ~IHookChain() {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual t_ret callNext(t_args... args) = 0;
|
virtual t_ret callNext(t_args... args) = 0;
|
||||||
virtual t_ret getOriginalReturnResult() = 0;
|
virtual t_ret callOriginal(t_args... args) = 0;
|
||||||
virtual bool isOriginalCalled() = 0;
|
};
|
||||||
|
|
||||||
|
template<typename ...t_args>
|
||||||
|
class IVoidHookChain
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
virtual ~IVoidHookChain() {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void callNext(t_args... args) = 0;
|
||||||
|
virtual void callOriginal(t_args... args) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Hook chain registry(for hooks [un]registration)
|
// Hook chain registry(for hooks [un]registration)
|
||||||
@ -48,16 +58,6 @@ public:
|
|||||||
virtual void unregisterHook(hookfunc_t hook) = 0;
|
virtual void unregisterHook(hookfunc_t hook) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<typename ...t_args>
|
|
||||||
class IVoidHookChain {
|
|
||||||
public:
|
|
||||||
virtual void callNext(t_args... args) = 0;
|
|
||||||
virtual bool isOriginalCalled() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Hook chain registry(for hooks [un]registration)
|
// Hook chain registry(for hooks [un]registration)
|
||||||
template<typename ...t_args>
|
template<typename ...t_args>
|
||||||
class IVoidHookChainRegistry {
|
class IVoidHookChainRegistry {
|
||||||
|
@ -34,8 +34,8 @@
|
|||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
|
|
||||||
#define REHLDS_API_VERSION_MAJOR 1
|
#define REHLDS_API_VERSION_MAJOR 2
|
||||||
#define REHLDS_API_VERSION_MINOR 3
|
#define REHLDS_API_VERSION_MINOR 0
|
||||||
|
|
||||||
//Steam_NotifyClientConnect hook
|
//Steam_NotifyClientConnect hook
|
||||||
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
|
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
|
||||||
@ -141,6 +141,10 @@ typedef IVoidHookChainRegistry<edict_t *, int, const char *, float, float, int,
|
|||||||
typedef IVoidHookChain<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHook_SV_WriteFullClientUpdate;
|
typedef IVoidHookChain<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHook_SV_WriteFullClientUpdate;
|
||||||
typedef IVoidHookChainRegistry<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHookRegistry_SV_WriteFullClientUpdate;
|
typedef IVoidHookChainRegistry<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHookRegistry_SV_WriteFullClientUpdate;
|
||||||
|
|
||||||
|
//SV_GenericFileConsistencyResponce hook
|
||||||
|
typedef IVoidHookChain<IGameClient *, resource_t *, uint32> IRehldsHook_GenericFileConsistencyResponce;
|
||||||
|
typedef IVoidHookChainRegistry<IGameClient *, resource_t *, uint32> IRehldsHookRegistry_GenericFileConsistencyResponce;
|
||||||
|
|
||||||
class IRehldsHookchains {
|
class IRehldsHookchains {
|
||||||
public:
|
public:
|
||||||
virtual ~IRehldsHookchains() { }
|
virtual ~IRehldsHookchains() { }
|
||||||
@ -171,6 +175,7 @@ public:
|
|||||||
virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I() = 0;
|
virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I() = 0;
|
||||||
virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I() = 0;
|
virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I() = 0;
|
||||||
virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate() = 0;
|
virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate() = 0;
|
||||||
|
virtual IRehldsHookRegistry_GenericFileConsistencyResponce* GenericFileConsistencyResponce() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RehldsFuncs_t {
|
struct RehldsFuncs_t {
|
||||||
|
@ -77,6 +77,7 @@ public:
|
|||||||
class INetChan {
|
class INetChan {
|
||||||
public:
|
public:
|
||||||
virtual const netadr_t* GetRemoteAdr() = 0;
|
virtual const netadr_t* GetRemoteAdr() = 0;
|
||||||
|
virtual sizebuf_t* GetMessageBuf() = 0;
|
||||||
|
|
||||||
|
|
||||||
// this must be the last virtual function in class
|
// this must be the last virtual function in class
|
||||||
@ -108,6 +109,8 @@ public:
|
|||||||
virtual const char* GetName() = 0;
|
virtual const char* GetName() = 0;
|
||||||
virtual uint32 GetWorldmapCrc() = 0;
|
virtual uint32 GetWorldmapCrc() = 0;
|
||||||
virtual uint8* GetClientDllMd5() = 0;
|
virtual uint8* GetClientDllMd5() = 0;
|
||||||
|
virtual sizebuf_t* GetDatagram() = 0;
|
||||||
|
virtual sizebuf_t* GetReliableDatagram() = 0;
|
||||||
|
|
||||||
virtual void SetModelName(const char* modelname) = 0;
|
virtual void SetModelName(const char* modelname) = 0;
|
||||||
};
|
};
|
||||||
|
@ -17,26 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
|
#include "hookchains_impl.h"
|
||||||
AbstractHookChain::AbstractHookChain() {
|
|
||||||
memset(m_Hooks, 0, sizeof(m_Hooks));
|
|
||||||
m_NumHooks = 0;
|
|
||||||
m_CurHook = 0;
|
|
||||||
m_bOriginalCalled = false;
|
|
||||||
m_OriginalFunc = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* AbstractHookChain::nextHook() {
|
|
||||||
return (m_CurHook < m_NumHooks) ? m_Hooks[m_CurHook++] : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AbstractHookChain::init(void* origFunc, void* hooks, int numHooks) {
|
|
||||||
m_OriginalFunc = origFunc;
|
|
||||||
m_NumHooks = numHooks;
|
|
||||||
m_CurHook = 0;
|
|
||||||
m_bOriginalCalled = false;
|
|
||||||
memcpy(m_Hooks, hooks, numHooks * sizeof(size_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractHookChainRegistry::AbstractHookChainRegistry()
|
AbstractHookChainRegistry::AbstractHookChainRegistry()
|
||||||
{
|
{
|
||||||
|
@ -28,96 +28,82 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "hookchains.h"
|
#include "hookchains.h"
|
||||||
|
|
||||||
#define MAX_HOOKS_IN_CHAIN 64
|
#define MAX_HOOKS_IN_CHAIN 63
|
||||||
|
|
||||||
class AbstractHookChain {
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void* m_Hooks[MAX_HOOKS_IN_CHAIN];
|
|
||||||
void* m_OriginalFunc;
|
|
||||||
int m_CurHook;
|
|
||||||
int m_NumHooks;
|
|
||||||
|
|
||||||
bool m_bOriginalCalled;
|
|
||||||
|
|
||||||
AbstractHookChain();
|
|
||||||
|
|
||||||
void* nextHook();
|
|
||||||
|
|
||||||
public:
|
|
||||||
void init(void* origFunc, void* hooks, int numHooks);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
// Implementation for chains in modules
|
||||||
template<typename t_ret, typename ...t_args>
|
template<typename t_ret, typename ...t_args>
|
||||||
class IHookChainImpl : public IHookChain<t_ret, t_args...>, public AbstractHookChain {
|
class IHookChainImpl : public IHookChain<t_ret, t_args...> {
|
||||||
public:
|
public:
|
||||||
typedef t_ret(*hookfunc_t)(IHookChain<t_ret, t_args...>*, t_args...);
|
typedef t_ret(*hookfunc_t)(IHookChain<t_ret, t_args...>*, t_args...);
|
||||||
typedef t_ret(*origfunc_t)(t_args...);
|
typedef t_ret(*origfunc_t)(t_args...);
|
||||||
|
|
||||||
private:
|
IHookChainImpl(void** hooks, origfunc_t orig) : m_Hooks(hooks), m_OriginalFunc(orig)
|
||||||
t_ret m_OriginalReturnResult;
|
{
|
||||||
|
if (orig == NULL)
|
||||||
public:
|
rehlds_syserror("Non-void HookChain without original function.");
|
||||||
virtual ~IHookChainImpl() { }
|
|
||||||
|
|
||||||
IHookChainImpl(t_ret defaultResult) {
|
|
||||||
m_OriginalReturnResult = defaultResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ~IHookChainImpl() {}
|
||||||
|
|
||||||
virtual t_ret callNext(t_args... args) {
|
virtual t_ret callNext(t_args... args) {
|
||||||
void* nextvhook = nextHook();
|
hookfunc_t nexthook = (hookfunc_t)m_Hooks[0];
|
||||||
if (nextvhook) {
|
|
||||||
hookfunc_t nexthook = (hookfunc_t)nextvhook;
|
if (nexthook)
|
||||||
return nexthook(this, args...);
|
{
|
||||||
|
IHookChainImpl nextChain(m_Hooks + 1, m_OriginalFunc);
|
||||||
|
return nexthook(&nextChain, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
origfunc_t origfunc = (origfunc_t)m_OriginalFunc;
|
return m_OriginalFunc(args...);
|
||||||
m_OriginalReturnResult = origfunc(args...);
|
|
||||||
m_bOriginalCalled = true;
|
|
||||||
return m_OriginalReturnResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual t_ret getOriginalReturnResult() {
|
virtual t_ret callOriginal(t_args... args) {
|
||||||
return m_OriginalReturnResult;
|
return m_OriginalFunc(args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isOriginalCalled() {
|
private:
|
||||||
return m_bOriginalCalled;
|
void** m_Hooks;
|
||||||
}
|
origfunc_t m_OriginalFunc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Implementation for void chains in modules
|
||||||
template<typename ...t_args>
|
template<typename ...t_args>
|
||||||
class IVoidHookChainImpl : public IVoidHookChain<t_args...>, public AbstractHookChain {
|
class IVoidHookChainImpl : public IVoidHookChain<t_args...> {
|
||||||
public:
|
public:
|
||||||
typedef void(*hookfunc_t)(IVoidHookChain<t_args...>*, t_args...);
|
typedef void(*hookfunc_t)(IVoidHookChain<t_args...>*, t_args...);
|
||||||
typedef void(*origfunc_t)(t_args...);
|
typedef void(*origfunc_t)(t_args...);
|
||||||
|
|
||||||
virtual ~IVoidHookChainImpl() { }
|
IVoidHookChainImpl(void** hooks, origfunc_t orig) : m_Hooks(hooks), m_OriginalFunc(orig) {}
|
||||||
|
virtual ~IVoidHookChainImpl() {}
|
||||||
|
|
||||||
virtual void callNext(t_args... args) {
|
virtual void callNext(t_args... args) {
|
||||||
void* nextvhook = nextHook();
|
hookfunc_t nexthook = (hookfunc_t)m_Hooks[0];
|
||||||
if (nextvhook) {
|
|
||||||
hookfunc_t nexthook = (hookfunc_t)nextvhook;
|
|
||||||
nexthook(this, args...);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (nexthook)
|
||||||
|
{
|
||||||
|
IVoidHookChainImpl nextChain(m_Hooks + 1, m_OriginalFunc);
|
||||||
|
nexthook(&nextChain, args...);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (m_OriginalFunc)
|
||||||
|
m_OriginalFunc(args...);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void callOriginal(t_args... args) {
|
||||||
origfunc_t origfunc = (origfunc_t)m_OriginalFunc;
|
origfunc_t origfunc = (origfunc_t)m_OriginalFunc;
|
||||||
if (origfunc) {
|
origfunc(args...);
|
||||||
origfunc(args...);
|
|
||||||
}
|
|
||||||
m_bOriginalCalled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isOriginalCalled() {
|
private:
|
||||||
return m_bOriginalCalled;
|
void** m_Hooks;
|
||||||
}
|
origfunc_t m_OriginalFunc;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AbstractHookChainRegistry {
|
class AbstractHookChainRegistry {
|
||||||
protected:
|
protected:
|
||||||
void* m_Hooks[MAX_HOOKS_IN_CHAIN];
|
void* m_Hooks[MAX_HOOKS_IN_CHAIN + 1]; // +1 for null
|
||||||
int m_NumHooks;
|
int m_NumHooks;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -136,9 +122,8 @@ public:
|
|||||||
|
|
||||||
virtual ~IHookChainRegistryImpl() { }
|
virtual ~IHookChainRegistryImpl() { }
|
||||||
|
|
||||||
t_ret callChain(origfunc_t origFunc, t_ret defaultResult, t_args... args) {
|
t_ret callChain(origfunc_t origFunc, t_args... args) {
|
||||||
IHookChainImpl<t_ret, t_args...> chain(defaultResult);
|
IHookChainImpl<t_ret, t_args...> chain(m_Hooks, origFunc);
|
||||||
chain.init((void*)origFunc, m_Hooks, m_NumHooks);
|
|
||||||
return chain.callNext(args...);
|
return chain.callNext(args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,14 +144,14 @@ public:
|
|||||||
virtual ~IVoidHookChainRegistryImpl() { }
|
virtual ~IVoidHookChainRegistryImpl() { }
|
||||||
|
|
||||||
void callChain(origfunc_t origFunc, t_args... args) {
|
void callChain(origfunc_t origFunc, t_args... args) {
|
||||||
IVoidHookChainImpl<t_args...> chain;
|
IVoidHookChainImpl<t_args...> chain(m_Hooks, origFunc);
|
||||||
chain.init((void*)origFunc, m_Hooks, m_NumHooks);
|
|
||||||
chain.callNext(args...);
|
chain.callNext(args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void registerHook(hookfunc_t hook) {
|
virtual void registerHook(hookfunc_t hook) {
|
||||||
addHook((void*)hook);
|
addHook((void*)hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void unregisterHook(hookfunc_t hook) {
|
virtual void unregisterHook(hookfunc_t hook) {
|
||||||
removeHook((void*)hook);
|
removeHook((void*)hook);
|
||||||
}
|
}
|
||||||
|
@ -253,6 +253,10 @@ IRehldsHookRegistry_SV_WriteFullClientUpdate* CRehldsHookchains::SV_WriteFullCli
|
|||||||
return &m_SV_WriteFullClientUpdate;
|
return &m_SV_WriteFullClientUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IRehldsHookRegistry_GenericFileConsistencyResponce* CRehldsHookchains::GenericFileConsistencyResponce() {
|
||||||
|
return &m_GenericFileConsistencyResponce;
|
||||||
|
}
|
||||||
|
|
||||||
int EXT_FUNC CRehldsApi::GetMajorVersion()
|
int EXT_FUNC CRehldsApi::GetMajorVersion()
|
||||||
{
|
{
|
||||||
return REHLDS_API_VERSION_MAJOR;
|
return REHLDS_API_VERSION_MAJOR;
|
||||||
|
@ -135,6 +135,10 @@ typedef IVoidHookChainRegistryImpl<edict_t *, int, const char *, float, float, i
|
|||||||
typedef IVoidHookChainImpl<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> CRehldsHook_SV_WriteFullClientUpdate;
|
typedef IVoidHookChainImpl<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> CRehldsHook_SV_WriteFullClientUpdate;
|
||||||
typedef IVoidHookChainRegistryImpl<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> CRehldsHookRegistry_SV_WriteFullClientUpdate;
|
typedef IVoidHookChainRegistryImpl<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> CRehldsHookRegistry_SV_WriteFullClientUpdate;
|
||||||
|
|
||||||
|
//SV_WriteFullClientUpdate hook
|
||||||
|
typedef IVoidHookChainImpl<IGameClient *, resource_t *, uint32> CRehldsHook_GenericFileConsistencyResponce;
|
||||||
|
typedef IVoidHookChainRegistryImpl<IGameClient *, resource_t *, uint32> CRehldsHookRegistry_GenericFileConsistencyResponce;
|
||||||
|
|
||||||
class CRehldsHookchains : public IRehldsHookchains {
|
class CRehldsHookchains : public IRehldsHookchains {
|
||||||
public:
|
public:
|
||||||
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
|
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
|
||||||
@ -163,6 +167,7 @@ public:
|
|||||||
CRehldsHookRegistry_PF_Remove_I m_PF_Remove_I;
|
CRehldsHookRegistry_PF_Remove_I m_PF_Remove_I;
|
||||||
CRehldsHookRegistry_PF_BuildSoundMsg_I m_PF_BuildSoundMsg_I;
|
CRehldsHookRegistry_PF_BuildSoundMsg_I m_PF_BuildSoundMsg_I;
|
||||||
CRehldsHookRegistry_SV_WriteFullClientUpdate m_SV_WriteFullClientUpdate;
|
CRehldsHookRegistry_SV_WriteFullClientUpdate m_SV_WriteFullClientUpdate;
|
||||||
|
CRehldsHookRegistry_GenericFileConsistencyResponce m_GenericFileConsistencyResponce;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
|
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
|
||||||
@ -191,6 +196,7 @@ public:
|
|||||||
virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I();
|
virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I();
|
||||||
virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I();
|
virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I();
|
||||||
virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate();
|
virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate();
|
||||||
|
virtual IRehldsHookRegistry_GenericFileConsistencyResponce* GenericFileConsistencyResponce();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CRehldsHookchains g_RehldsHookchains;
|
extern CRehldsHookchains g_RehldsHookchains;
|
||||||
|
@ -111,6 +111,11 @@ const netadr_t* EXT_FUNC CNetChan::GetRemoteAdr()
|
|||||||
return &m_pNetChan->remote_address;
|
return &m_pNetChan->remote_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sizebuf_t* EXT_FUNC CNetChan::GetMessageBuf()
|
||||||
|
{
|
||||||
|
return &m_pNetChan->message;
|
||||||
|
}
|
||||||
|
|
||||||
netchan_t* EXT_FUNC CNetChan::GetChan()
|
netchan_t* EXT_FUNC CNetChan::GetChan()
|
||||||
{
|
{
|
||||||
return m_pNetChan;
|
return m_pNetChan;
|
||||||
@ -178,6 +183,14 @@ uint8* EXT_FUNC CRehldsServerData::GetClientDllMd5() {
|
|||||||
return g_psv.clientdllmd5;
|
return g_psv.clientdllmd5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sizebuf_t* EXT_FUNC CRehldsServerData::GetDatagram() {
|
||||||
|
return &g_psv.datagram;
|
||||||
|
}
|
||||||
|
|
||||||
|
sizebuf_t* EXT_FUNC CRehldsServerData::GetReliableDatagram() {
|
||||||
|
return &g_psv.reliable_datagram;
|
||||||
|
}
|
||||||
|
|
||||||
void Rehlds_Interfaces_FreeClients()
|
void Rehlds_Interfaces_FreeClients()
|
||||||
{
|
{
|
||||||
if (g_GameClients == NULL)
|
if (g_GameClients == NULL)
|
||||||
|
@ -39,8 +39,7 @@ public:
|
|||||||
CNetChan(netchan_t* chan);
|
CNetChan(netchan_t* chan);
|
||||||
|
|
||||||
virtual const netadr_t* GetRemoteAdr();
|
virtual const netadr_t* GetRemoteAdr();
|
||||||
|
virtual sizebuf_t* GetMessageBuf();
|
||||||
|
|
||||||
|
|
||||||
virtual netchan_t* GetChan();
|
virtual netchan_t* GetChan();
|
||||||
};
|
};
|
||||||
@ -96,6 +95,8 @@ public:
|
|||||||
virtual const char* GetName();
|
virtual const char* GetName();
|
||||||
virtual uint32 GetWorldmapCrc();
|
virtual uint32 GetWorldmapCrc();
|
||||||
virtual uint8* GetClientDllMd5();
|
virtual uint8* GetClientDllMd5();
|
||||||
|
virtual sizebuf_t* GetDatagram();
|
||||||
|
virtual sizebuf_t* GetReliableDatagram();
|
||||||
|
|
||||||
virtual void SetModelName(const char* modelname);
|
virtual void SetModelName(const char* modelname);
|
||||||
};
|
};
|
||||||
|
@ -1,11 +1,20 @@
|
|||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
#include "rehlds_tests_shared.h"
|
#include "rehlds_tests_shared.h"
|
||||||
#include "cppunitlite/TestHarness.h"
|
#include "cppunitlite/TestHarness.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
TEST(CRC32C_Hash, CRC32C, 1000) {
|
TEST(CRC32C_Hash, CRC32C, 1000) {
|
||||||
|
|
||||||
Sys_CheckCpuInstructionsSupport();
|
Sys_CheckCpuInstructionsSupport();
|
||||||
CHECK("SSE4.2 Support", cpuinfo.sse4_2);
|
//CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
||||||
|
if (!cpuinfo.sse4_2)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Test '" __FUNCTION__ "' not runned: sse 4.2 doesn't supported";
|
||||||
|
std::cout << ss.str() << std::endl;
|
||||||
|
std::cout.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct testdata_t {
|
struct testdata_t {
|
||||||
const char* src;
|
const char* src;
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
#include "rehlds_tests_shared.h"
|
#include "rehlds_tests_shared.h"
|
||||||
#include "cppunitlite/TestHarness.h"
|
#include "cppunitlite/TestHarness.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
TEST(AngleVectorsTest, MathLib, 1000) {
|
TEST(AngleVectorsTest, MathLib, 1000) {
|
||||||
Sys_CheckCpuInstructionsSupport();
|
Sys_CheckCpuInstructionsSupport();
|
||||||
CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
//CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
||||||
|
if (!cpuinfo.sse4_1)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Test '" __FUNCTION__ "' not runned: sse 4.1 doesn't supported";
|
||||||
|
std::cout << ss.str() << std::endl;
|
||||||
|
std::cout.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct testdata_t {
|
struct testdata_t {
|
||||||
vec3_t angles;
|
vec3_t angles;
|
||||||
@ -41,7 +50,15 @@ TEST(AngleVectorsTest, MathLib, 1000) {
|
|||||||
|
|
||||||
TEST(AngleVectorsTransposeTest, MathLib, 1000) {
|
TEST(AngleVectorsTransposeTest, MathLib, 1000) {
|
||||||
Sys_CheckCpuInstructionsSupport();
|
Sys_CheckCpuInstructionsSupport();
|
||||||
CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
//CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
||||||
|
if (!cpuinfo.sse4_1)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Test '" __FUNCTION__ "' not runned: sse 4.1 doesn't supported";
|
||||||
|
std::cout << ss.str() << std::endl;
|
||||||
|
std::cout.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct testdata_t {
|
struct testdata_t {
|
||||||
vec3_t angles;
|
vec3_t angles;
|
||||||
@ -78,7 +95,15 @@ TEST(AngleVectorsTransposeTest, MathLib, 1000) {
|
|||||||
|
|
||||||
TEST(AngleMatrixTest, MathLib, 1000) {
|
TEST(AngleMatrixTest, MathLib, 1000) {
|
||||||
Sys_CheckCpuInstructionsSupport();
|
Sys_CheckCpuInstructionsSupport();
|
||||||
CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
//CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
||||||
|
if (!cpuinfo.sse4_1)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Test '" __FUNCTION__ "' not runned: sse 4.1 doesn't supported";
|
||||||
|
std::cout << ss.str() << std::endl;
|
||||||
|
std::cout.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct testdata_t {
|
struct testdata_t {
|
||||||
vec3_t angles;
|
vec3_t angles;
|
||||||
@ -120,7 +145,15 @@ TEST(AngleMatrixTest, MathLib, 1000) {
|
|||||||
|
|
||||||
TEST(DotProductTest, MathLib, 1000) {
|
TEST(DotProductTest, MathLib, 1000) {
|
||||||
Sys_CheckCpuInstructionsSupport();
|
Sys_CheckCpuInstructionsSupport();
|
||||||
CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
//CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
||||||
|
if (!cpuinfo.sse4_1)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Test '" __FUNCTION__ "' not runned: sse 4.1 doesn't supported";
|
||||||
|
std::cout << ss.str() << std::endl;
|
||||||
|
std::cout.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct testdata_t {
|
struct testdata_t {
|
||||||
vec3_t v1;
|
vec3_t v1;
|
||||||
@ -146,7 +179,15 @@ TEST(DotProductTest, MathLib, 1000) {
|
|||||||
|
|
||||||
TEST(CrossProductTest, MathLib, 1000) {
|
TEST(CrossProductTest, MathLib, 1000) {
|
||||||
Sys_CheckCpuInstructionsSupport();
|
Sys_CheckCpuInstructionsSupport();
|
||||||
CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
//CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
||||||
|
if (!cpuinfo.sse4_1)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Test '" __FUNCTION__ "' not runned: sse 4.1 doesn't supported";
|
||||||
|
std::cout << ss.str() << std::endl;
|
||||||
|
std::cout.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct testdata_t {
|
struct testdata_t {
|
||||||
vec3_t v1;
|
vec3_t v1;
|
||||||
@ -176,7 +217,15 @@ TEST(CrossProductTest, MathLib, 1000) {
|
|||||||
|
|
||||||
TEST(LengthTest, MathLib, 1000) {
|
TEST(LengthTest, MathLib, 1000) {
|
||||||
Sys_CheckCpuInstructionsSupport();
|
Sys_CheckCpuInstructionsSupport();
|
||||||
CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
//CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
||||||
|
if (!cpuinfo.sse4_1)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Test '" __FUNCTION__ "' not runned: sse 4.1 doesn't supported";
|
||||||
|
std::cout << ss.str() << std::endl;
|
||||||
|
std::cout.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct testdata_t {
|
struct testdata_t {
|
||||||
vec3_t v;
|
vec3_t v;
|
||||||
@ -201,7 +250,15 @@ TEST(LengthTest, MathLib, 1000) {
|
|||||||
|
|
||||||
TEST(Length2DTest, MathLib, 1000) {
|
TEST(Length2DTest, MathLib, 1000) {
|
||||||
Sys_CheckCpuInstructionsSupport();
|
Sys_CheckCpuInstructionsSupport();
|
||||||
CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
//CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
||||||
|
if (!cpuinfo.sse4_1)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Test '" __FUNCTION__ "' not runned: sse 4.1 doesn't supported";
|
||||||
|
std::cout << ss.str() << std::endl;
|
||||||
|
std::cout.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct testdata_t {
|
struct testdata_t {
|
||||||
vec3_t v;
|
vec3_t v;
|
||||||
@ -226,7 +283,15 @@ TEST(Length2DTest, MathLib, 1000) {
|
|||||||
|
|
||||||
TEST(VectorNormalizeTest, MathLib, 1000) {
|
TEST(VectorNormalizeTest, MathLib, 1000) {
|
||||||
Sys_CheckCpuInstructionsSupport();
|
Sys_CheckCpuInstructionsSupport();
|
||||||
CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
//CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
||||||
|
if (!cpuinfo.sse4_1)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Test '" __FUNCTION__ "' not runned: sse 4.1 doesn't supported";
|
||||||
|
std::cout << ss.str() << std::endl;
|
||||||
|
std::cout.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct testdata_t {
|
struct testdata_t {
|
||||||
vec3_t vecIn;
|
vec3_t vecIn;
|
||||||
@ -257,7 +322,15 @@ TEST(VectorNormalizeTest, MathLib, 1000) {
|
|||||||
|
|
||||||
TEST(VectorAnglesTest, MathLib, 1000) {
|
TEST(VectorAnglesTest, MathLib, 1000) {
|
||||||
Sys_CheckCpuInstructionsSupport();
|
Sys_CheckCpuInstructionsSupport();
|
||||||
CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
//CHECK("SSE4.1 Support", cpuinfo.sse4_1);
|
||||||
|
if (!cpuinfo.sse4_1)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Test '" __FUNCTION__ "' not runned: sse 4.1 doesn't supported";
|
||||||
|
std::cout << ss.str() << std::endl;
|
||||||
|
std::cout.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct testdata_t {
|
struct testdata_t {
|
||||||
vec3_t forward;
|
vec3_t forward;
|
||||||
|
Loading…
Reference in New Issue
Block a user