Skip to content

Commit

Permalink
dedicated: Remove uses of Autohook from dedicated.cpp (#799)
Browse files Browse the repository at this point in the history
Removes use of AUTOHOOK macro from dedicated.cpp
  • Loading branch information
ASpoonPlaysGames authored Sep 16, 2024
1 parent f9a9798 commit 1f4765d
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions primedev/dedicated/dedicated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include "masterserver/masterserver.h"
#include "util/printcommands.h"

AUTOHOOK_INIT()

bool IsDedicatedServer()
{
static bool result = strstr(GetCommandLineA(), "-dedicated");
Expand Down Expand Up @@ -114,10 +112,8 @@ DWORD WINAPI ConsoleInputThread(PVOID pThreadParameter)
return 0;
}

// clang-format off
AUTOHOOK(IsGameActiveWindow, engine.dll + 0x1CDC80,
bool,, ())
// clang-format on
static bool (*o_pIsGameActiveWindow)() = nullptr;
static bool h_IsGameActiveWindow()
{
return true;
}
Expand All @@ -126,7 +122,8 @@ ON_DLL_LOAD_DEDI_RELIESON("engine.dll", DedicatedServer, ServerPresence, (CModul
{
spdlog::info("InitialiseDedicated");

AUTOHOOK_DISPATCH_MODULE(engine.dll)
o_pIsGameActiveWindow = module.Offset(0x1CDC80).RCast<decltype(o_pIsGameActiveWindow)>();
HookAttach(&(PVOID&)o_pIsGameActiveWindow, (PVOID)h_IsGameActiveWindow);

// Host_Init
// prevent a particle init that relies on client dll
Expand Down Expand Up @@ -270,12 +267,10 @@ ON_DLL_LOAD_DEDI("tier0.dll", DedicatedServerOrigin, (CModule module))
module.GetExportedFunction("Tier0_InitOrigin").Patch("C3");
}

// clang-format off
AUTOHOOK(PrintSquirrelError, server.dll + 0x794D0,
void, __fastcall, (void* sqvm))
// clang-format on
static void(__fastcall* o_pPrintSquirrelError)(void* sqvm) = nullptr;
static void __fastcall h_PrintSquirrelError(void* sqvm)
{
PrintSquirrelError(sqvm);
o_pPrintSquirrelError(sqvm);

// close dedicated server if a fatal error is hit
// atm, this will crash if not aborted, so this just closes more gracefully
Expand All @@ -289,7 +284,8 @@ void, __fastcall, (void* sqvm))

ON_DLL_LOAD_DEDI("server.dll", DedicatedServerGameDLL, (CModule module))
{
AUTOHOOK_DISPATCH_MODULE(server.dll)
o_pPrintSquirrelError = module.Offset(0x794D0).RCast<decltype(o_pPrintSquirrelError)>();
HookAttach(&(PVOID&)o_pPrintSquirrelError, (PVOID)h_PrintSquirrelError);

if (CommandLine()->CheckParm("-nopakdedi"))
{
Expand Down

0 comments on commit 1f4765d

Please sign in to comment.