Only hook IBaseFileSystem::FileExists if we're also hooking INetChannel::SendFile or INetChannel::ProcessPacket.
This works around a TF Replay SourceHook crash that Johns was seeing when using 1.8. SourceHook is not thread-safe at the time of this writing.
This commit is contained in:
parent
5815e49d93
commit
8924a9744e
@ -79,8 +79,6 @@ void CHookManager::Initialize()
|
|||||||
PRCH_enabled = false;
|
PRCH_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SH_ADD_HOOK(IBaseFileSystem, FileExists, basefilesystem, SH_MEMBER(this, &CHookManager::FileExists), false);
|
|
||||||
|
|
||||||
basefilesystemPatch = SH_GET_CALLCLASS(basefilesystem);
|
basefilesystemPatch = SH_GET_CALLCLASS(basefilesystem);
|
||||||
|
|
||||||
m_netFileSendFwd = forwards->CreateForward("OnFileSend", ET_Event, 2, NULL, Param_Cell, Param_String);
|
m_netFileSendFwd = forwards->CreateForward("OnFileSend", ET_Event, 2, NULL, Param_Cell, Param_String);
|
||||||
@ -236,12 +234,22 @@ void CHookManager::NetChannelHook(int client)
|
|||||||
|
|
||||||
/* Normal NetChannel Hooks. */
|
/* Normal NetChannel Hooks. */
|
||||||
{
|
{
|
||||||
CVTableHook hook(pNetChannel);
|
CVTableHook nethook(pNetChannel);
|
||||||
size_t iter;
|
size_t iter;
|
||||||
|
|
||||||
|
/* Initial Hook */
|
||||||
|
if (!m_netChannelHooks.length())
|
||||||
|
{
|
||||||
|
CVTableHook filehook(basefilesystem);
|
||||||
|
|
||||||
|
int hookid = SH_ADD_VPHOOK(IBaseFileSystem, FileExists, basefilesystem, SH_MEMBER(this, &CHookManager::FileExists), false);
|
||||||
|
filehook.SetHookID(hookid);
|
||||||
|
m_netChannelHooks.append(new CVTableHook(filehook));
|
||||||
|
}
|
||||||
|
|
||||||
for (iter = 0; iter < m_netChannelHooks.length(); ++iter)
|
for (iter = 0; iter < m_netChannelHooks.length(); ++iter)
|
||||||
{
|
{
|
||||||
/* We can technically skip 2; even technical-ier, this could be a bool; but Valve. */
|
if (nethook == m_netChannelHooks[iter])
|
||||||
if (hook == m_netChannelHooks[iter])
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -250,16 +258,16 @@ void CHookManager::NetChannelHook(int client)
|
|||||||
if (iter == m_netChannelHooks.length())
|
if (iter == m_netChannelHooks.length())
|
||||||
{
|
{
|
||||||
int hookid = SH_ADD_VPHOOK(INetChannel, SendFile, pNetChannel, SH_MEMBER(this, &CHookManager::SendFile), false);
|
int hookid = SH_ADD_VPHOOK(INetChannel, SendFile, pNetChannel, SH_MEMBER(this, &CHookManager::SendFile), false);
|
||||||
hook.SetHookID(hookid);
|
nethook.SetHookID(hookid);
|
||||||
m_netChannelHooks.append(new CVTableHook(hook));
|
m_netChannelHooks.append(new CVTableHook(nethook));
|
||||||
|
|
||||||
hookid = SH_ADD_VPHOOK(INetChannel, ProcessPacket, pNetChannel, SH_MEMBER(this, &CHookManager::ProcessPacket), false);
|
hookid = SH_ADD_VPHOOK(INetChannel, ProcessPacket, pNetChannel, SH_MEMBER(this, &CHookManager::ProcessPacket), false);
|
||||||
hook.SetHookID(hookid);
|
nethook.SetHookID(hookid);
|
||||||
m_netChannelHooks.append(new CVTableHook(hook));
|
m_netChannelHooks.append(new CVTableHook(nethook));
|
||||||
|
|
||||||
hookid = SH_ADD_VPHOOK(INetChannel, ProcessPacket, pNetChannel, SH_MEMBER(this, &CHookManager::ProcessPacket_Post), true);
|
hookid = SH_ADD_VPHOOK(INetChannel, ProcessPacket, pNetChannel, SH_MEMBER(this, &CHookManager::ProcessPacket_Post), true);
|
||||||
hook.SetHookID(hookid);
|
nethook.SetHookID(hookid);
|
||||||
m_netChannelHooks.append(new CVTableHook(hook));
|
m_netChannelHooks.append(new CVTableHook(nethook));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user