Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove uses of Autohook from rejectconnectionfixes.cpp #793

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions primedev/client/rejectconnectionfixes.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#include "engine/r2engine.h"

AUTOHOOK_INIT()

// this is called from when our connection is rejected, this is the only case we're hooking this for
// clang-format off
AUTOHOOK(COM_ExplainDisconnection, engine.dll + 0x1342F0,
void,, (bool a1, const char* fmt, ...))
// clang-format on
static void (*o_pCOM_ExplainDisconnection)(bool a1, const char* fmt, ...) = nullptr;
static void h_COM_ExplainDisconnection(bool a1, const char* fmt, ...)
{
va_list va;
va_start(va, fmt);
Expand All @@ -25,10 +21,11 @@ void,, (bool a1, const char* fmt, ...))
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "disconnect", cmd_source_t::kCommandSrcCode);
}

return COM_ExplainDisconnection(a1, "%s", buf);
return o_pCOM_ExplainDisconnection(a1, "%s", buf);
}

ON_DLL_LOAD_CLIENT("engine.dll", RejectConnectionFixes, (CModule module))
{
AUTOHOOK_DISPATCH()
o_pCOM_ExplainDisconnection = module.Offset(0x1342F0).RCast<decltype(o_pCOM_ExplainDisconnection)>();
HookAttach(&(PVOID&)o_pCOM_ExplainDisconnection, (PVOID)h_COM_ExplainDisconnection);
}
Loading