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 dedicatedmaterialsystem.cpp #800

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
25 changes: 16 additions & 9 deletions primedev/dedicated/dedicatedmaterialsystem.cpp
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading