aboutsummaryrefslogtreecommitdiff
path: root/primedev/dedicated
diff options
context:
space:
mode:
Diffstat (limited to 'primedev/dedicated')
-rw-r--r--primedev/dedicated/dedicated.cpp22
-rw-r--r--primedev/dedicated/dedicatedmaterialsystem.cpp25
2 files changed, 25 insertions, 22 deletions
diff --git a/primedev/dedicated/dedicated.cpp b/primedev/dedicated/dedicated.cpp
index eca9b9f1..8b0604fc 100644
--- a/primedev/dedicated/dedicated.cpp
+++ b/primedev/dedicated/dedicated.cpp
@@ -8,8 +8,6 @@
#include "masterserver/masterserver.h"
#include "util/printcommands.h"
-AUTOHOOK_INIT()
-
bool IsDedicatedServer()
{
static bool result = strstr(GetCommandLineA(), "-dedicated");
@@ -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;
}
@@ -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
@@ -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
@@ -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"))
{
diff --git a/primedev/dedicated/dedicatedmaterialsystem.cpp b/primedev/dedicated/dedicatedmaterialsystem.cpp
index 01078086..f74cbfe3 100644
--- a/primedev/dedicated/dedicatedmaterialsystem.cpp
+++ b/primedev/dedicated/dedicatedmaterialsystem.cpp
@@ -1,11 +1,18 @@
#include "dedicated.h"
#include "core/tier0.h"
-AUTOHOOK_INIT()
-
-// clang-format off
-AUTOHOOK(D3D11CreateDevice, materialsystem_dx11.dll + 0xD9A0E,
-HRESULT, __stdcall, (
+static HRESULT(__stdcall* o_pD3D11CreateDevice)(
+ void* pAdapter,
+ int DriverType,
+ HMODULE Software,
+ UINT Flags,
+ int* pFeatureLevels,
+ UINT FeatureLevels,
+ UINT SDKVersion,
+ void** ppDevice,
+ int* pFeatureLevel,
+ void** ppImmediateContext) = nullptr;
+static HRESULT __stdcall h_D3D11CreateDevice(
void* pAdapter,
int DriverType,
HMODULE Software,
@@ -15,8 +22,7 @@ HRESULT, __stdcall, (
UINT SDKVersion,
void** ppDevice,
int* pFeatureLevel,
- void** ppImmediateContext))
-// clang-format on
+ void** ppImmediateContext)
{
// note: this is super duper temp pretty much just messing around with it
// does run surprisingly well on dedi for a software driver tho if you ignore the +1gb ram usage at times, seems like dedi doesn't
@@ -26,13 +32,14 @@ HRESULT, __stdcall, (
if (CommandLine()->CheckParm("-softwared3d11"))
DriverType = 5; // D3D_DRIVER_TYPE_WARP
- return D3D11CreateDevice(
+ return o_pD3D11CreateDevice(
pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion, ppDevice, pFeatureLevel, ppImmediateContext);
}
ON_DLL_LOAD_DEDI("materialsystem_dx11.dll", DedicatedServerMaterialSystem, (CModule module))
{
- AUTOHOOK_DISPATCH()
+ o_pD3D11CreateDevice = module.Offset(0xD9A0E).RCast<decltype(o_pD3D11CreateDevice)>();
+ HookAttach(&(PVOID&)o_pD3D11CreateDevice, (PVOID)h_D3D11CreateDevice);
// CMaterialSystem::FindMaterial
// make the game always use the error material