mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-12-06 18:08:31 +00:00
Fix const-ness issue, and stabilise virtual function api
This commit is contained in:
parent
c31229be95
commit
5957edb9df
@ -9,7 +9,7 @@ for sdk_target in MMS.sdk_targets:
|
|||||||
binary = MMS.HL2Library(builder, cxx, name, sdk)
|
binary = MMS.HL2Library(builder, cxx, name, sdk)
|
||||||
binary.compiler.cxxincludes += [os.path.join(builder.sourcePath, 'third_party', 'khook', 'include')]
|
binary.compiler.cxxincludes += [os.path.join(builder.sourcePath, 'third_party', 'khook', 'include')]
|
||||||
|
|
||||||
binary.compiler.defines += ['KHOOK_STANDALONE']
|
binary.compiler.defines += ['KHOOK_STANDALONE', 'KHOOK_EXPORT']
|
||||||
for task in MMS.libkhook:
|
for task in MMS.libkhook:
|
||||||
if task.target.arch == binary.compiler.target.arch:
|
if task.target.arch == binary.compiler.target.arch:
|
||||||
binary.compiler.linkflags += [task.binary]
|
binary.compiler.linkflags += [task.binary]
|
||||||
|
|||||||
@ -64,9 +64,9 @@ public:
|
|||||||
virtual void DLLInit_Post(int *isgdUnload)
|
virtual void DLLInit_Post(int *isgdUnload)
|
||||||
{
|
{
|
||||||
#ifdef META_IS_SOURCE2
|
#ifdef META_IS_SOURCE2
|
||||||
auto mfi = KHook::__GetMFPVtableIndex__(&ISource2ServerConfig::Disconnect);
|
auto mfi = KHook::GetVtableIndex(&ISource2ServerConfig::Disconnect);
|
||||||
#else
|
#else
|
||||||
auto mfi = KHook::__GetMFPVtableIndex__(&IServerGameDLL::DLLShutdown);
|
auto mfi = KHook::GetVtableIndex(&IServerGameDLL::DLLShutdown);
|
||||||
#endif
|
#endif
|
||||||
assert(mfi != -1);
|
assert(mfi != -1);
|
||||||
*isgdUnload = mfi;
|
*isgdUnload = mfi;
|
||||||
|
|||||||
@ -82,7 +82,7 @@ void SourceProvider::SourceConVarAccessor::RemoveMetamodCommands()
|
|||||||
*/
|
*/
|
||||||
bool SourceProvider::SourceConVarAccessor::InitConCommandBaseList()
|
bool SourceProvider::SourceConVarAccessor::InitConCommandBaseList()
|
||||||
{
|
{
|
||||||
char *vfunc = (char *)KHook::GetVirtualFunction(&ICvar::GetCommands, icvar);
|
char *vfunc = (char *)KHook::ExtractMFP(KHook::GetVtableFunction(icvar, &ICvar::GetCommands));
|
||||||
|
|
||||||
if (*vfunc == '\xE9')
|
if (*vfunc == '\xE9')
|
||||||
{
|
{
|
||||||
|
|||||||
@ -143,7 +143,7 @@ void Source2Provider::Notify_DLLInit_Pre(CreateInterfaceFn engineFactory,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SHOULD_OVERRIDE_ALLOWDEDICATED_SERVER
|
#ifdef SHOULD_OVERRIDE_ALLOWDEDICATED_SERVER
|
||||||
m_AllowDedicatedServers.Configure(KHook::GetVirtualFunction(&ISource2ServerConfig::AllowDedicatedServers, serverconfig));
|
m_AllowDedicatedServers.Configure((void*)KHook::ExtractMFP(KHook::GetVtableFunction(serverconfig, &ISource2ServerConfig::AllowDedicatedServers)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_RegisterLoopMode.Add(enginesvcmgr);
|
m_RegisterLoopMode.Add(enginesvcmgr);
|
||||||
@ -247,7 +247,7 @@ const char* Source2Provider::GetGameDescription()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SHOULD_OVERRIDE_ALLOWDEDICATED_SERVER
|
#ifdef SHOULD_OVERRIDE_ALLOWDEDICATED_SERVER
|
||||||
KHook::Return<bool> Source2Provider::Hook_AllowDedicatedServers(ISource2ServerConfig*, EUniverse universe) const
|
KHook::Return<bool> Source2Provider::Hook_AllowDedicatedServers(const ISource2ServerConfig*, EUniverse universe)
|
||||||
{
|
{
|
||||||
return { KHook::Action::Supercede, true };
|
return { KHook::Action::Supercede, true };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
#ifdef SHOULD_OVERRIDE_ALLOWDEDICATED_SERVER
|
#ifdef SHOULD_OVERRIDE_ALLOWDEDICATED_SERVER
|
||||||
KHook::Member<ISource2ServerConfig, bool, EUniverse> m_AllowDedicatedServers;
|
KHook::Member<ISource2ServerConfig, bool, EUniverse> m_AllowDedicatedServers;
|
||||||
bool Hook_AllowDedicatedServers(ISource2ServerConfig*, EUniverse universe) const;
|
KHook::Return<bool> Hook_AllowDedicatedServers(const ISource2ServerConfig*, EUniverse universe);
|
||||||
#endif
|
#endif
|
||||||
KHook::Virtual<IEngineServiceMgr, void, const char*, ILoopModeFactory*, void **> m_RegisterLoopMode;
|
KHook::Virtual<IEngineServiceMgr, void, const char*, ILoopModeFactory*, void **> m_RegisterLoopMode;
|
||||||
KHook::Return<void> Hook_RegisterLoopMode(IEngineServiceMgr*, const char* pszLoopModeName, ILoopModeFactory *pLoopModeFactory, void **ppGlobalPointer);
|
KHook::Return<void> Hook_RegisterLoopMode(IEngineServiceMgr*, const char* pszLoopModeName, ILoopModeFactory *pLoopModeFactory, void **ppGlobalPointer);
|
||||||
|
|||||||
@ -614,11 +614,11 @@ mm_PatchDllInit(bool patch)
|
|||||||
|
|
||||||
if (g_is_source2)
|
if (g_is_source2)
|
||||||
{
|
{
|
||||||
mfp = KHook::__GetMFPVtableIndex__(&ISource2Server::Init);
|
mfp = KHook::GetVtableIndex(&ISource2Server::Init);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mfp = KHook::__GetMFPVtableIndex__(&IServerGameDLL::DLLInit);
|
mfp = KHook::GetVtableIndex(&IServerGameDLL::DLLInit);
|
||||||
}
|
}
|
||||||
assert(mfp != -1);
|
assert(mfp != -1);
|
||||||
|
|
||||||
@ -659,11 +659,11 @@ mm_PatchDllShutdown()
|
|||||||
|
|
||||||
if (g_is_source2)
|
if (g_is_source2)
|
||||||
{
|
{
|
||||||
mfp = KHook::__GetMFPVtableIndex__(&ISource2ServerConfig::Disconnect);
|
mfp = KHook::GetVtableIndex(&ISource2ServerConfig::Disconnect);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mfp = KHook::__GetMFPVtableIndex__(&IServerGameDLL::DLLShutdown);
|
mfp = KHook::GetVtableIndex(&IServerGameDLL::DLLShutdown);
|
||||||
}
|
}
|
||||||
assert(mfp != -1);
|
assert(mfp != -1);
|
||||||
|
|
||||||
@ -689,7 +689,7 @@ mm_PatchAllowDedicated(bool patch)
|
|||||||
void **vtable_src;
|
void **vtable_src;
|
||||||
void **vtable_dest;
|
void **vtable_dest;
|
||||||
|
|
||||||
std::int32_t mfp = KHook::__GetMFPVtableIndex__(&ISource2ServerConfig::AllowDedicatedServers);
|
std::int32_t mfp = KHook::GetVtableIndex(&ISource2ServerConfig::AllowDedicatedServers);
|
||||||
|
|
||||||
assert(mfp != -1);
|
assert(mfp != -1);
|
||||||
|
|
||||||
@ -721,7 +721,7 @@ mm_PatchConnect(bool patch)
|
|||||||
void **vtable_src;
|
void **vtable_src;
|
||||||
void **vtable_dest;
|
void **vtable_dest;
|
||||||
|
|
||||||
std::int32_t mfp = KHook::__GetMFPVtableIndex__(&ISource2ServerConfig::Connect);
|
std::int32_t mfp = KHook::GetVtableIndex(&ISource2ServerConfig::Connect);
|
||||||
|
|
||||||
vtable_src = (void **) *(void **) &is2sc_thunk;
|
vtable_src = (void **) *(void **) &is2sc_thunk;
|
||||||
vtable_dest = (void **) *(void **) config_iface;
|
vtable_dest = (void **) *(void **) config_iface;
|
||||||
|
|||||||
@ -112,8 +112,8 @@ public:
|
|||||||
void **vtable_src;
|
void **vtable_src;
|
||||||
IRandomThings sample;
|
IRandomThings sample;
|
||||||
|
|
||||||
auto mfp_dest = KHook::__GetMFPVtableIndex__(&ServerPlugin::ClientCommand);
|
auto mfp_dest = KHook::GetVtableIndex(&ServerPlugin::ClientCommand);
|
||||||
auto mfp_src = KHook::__GetMFPVtableIndex__(&IRandomThings::ClientCommand);
|
auto mfp_src = KHook::GetVtableIndex(&IRandomThings::ClientCommand);
|
||||||
|
|
||||||
assert(mfp_dest != -1);
|
assert(mfp_dest != -1);
|
||||||
assert(mfp_src != -1);
|
assert(mfp_src != -1);
|
||||||
@ -134,7 +134,7 @@ public:
|
|||||||
&& mm_backend != MMBackend_CSGO
|
&& mm_backend != MMBackend_CSGO
|
||||||
&& mm_backend != MMBackend_MCV)
|
&& mm_backend != MMBackend_MCV)
|
||||||
{
|
{
|
||||||
auto mfp_fconnect = KHook::__GetMFPVtableIndex__(&ServerPlugin::ClientFullyConnect);
|
auto mfp_fconnect = KHook::GetVtableIndex(&ServerPlugin::ClientFullyConnect);
|
||||||
|
|
||||||
assert(mfp_fconnect != -1);
|
assert(mfp_fconnect != -1);
|
||||||
|
|
||||||
|
|||||||
2
third_party/khook
vendored
2
third_party/khook
vendored
@ -1 +1 @@
|
|||||||
Subproject commit d95c617b67bbffb519b0c788c47d2924ba39cd73
|
Subproject commit b95ce7df00cf3bbcbaf4d65a60c1d55d2a3b9c8f
|
||||||
Loading…
Reference in New Issue
Block a user