MCPcopy Create free account
hub / github.com/GPUOpen-Tools/GPU-Reshape / Install

Method Install

Source/Backends/DX12/Layer/Source/Device.cpp:833–856  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

831}
832
833bool GlobalDeviceDetour::Install() {
834 ASSERT(!D3D12GPUOpenFunctionTableNext.next_D3D12CreateDeviceOriginal, "Global device detour re-entry");
835
836 // Attempt to find module
837 HMODULE handle = nullptr;
838 if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_PIN, L"d3d12.dll", &handle)) {
839 return false;
840 }
841
842 // Attach against original address
843 D3D12GPUOpenFunctionTableNext.next_D3D12GetInterfaceOriginal = reinterpret_cast<PFN_D3D12_GET_INTERFACE>(GetProcAddress(handle, "D3D12GetInterface"));
844 DetourAttach(&reinterpret_cast<void*&>(D3D12GPUOpenFunctionTableNext.next_D3D12GetInterfaceOriginal), reinterpret_cast<void*>(HookD3D12GetInterface));
845
846 // Attach against original address
847 D3D12GPUOpenFunctionTableNext.next_D3D12CreateDeviceOriginal = reinterpret_cast<PFN_D3D12_CREATE_DEVICE>(GetProcAddress(handle, "D3D12CreateDevice"));
848 DetourAttach(&reinterpret_cast<void*&>(D3D12GPUOpenFunctionTableNext.next_D3D12CreateDeviceOriginal), reinterpret_cast<void*>(HookID3D12CreateDevice));
849
850 // Attach against original address
851 D3D12GPUOpenFunctionTableNext.next_EnableExperimentalFeatures = reinterpret_cast<PFN_ENABLE_EXPERIMENTAL_FEATURES>(GetProcAddress(handle, "D3D12EnableExperimentalFeatures"));
852 DetourAttach(&reinterpret_cast<void*&>(D3D12GPUOpenFunctionTableNext.next_EnableExperimentalFeatures), reinterpret_cast<void*>(HookD3D12EnableExperimentalFeatures));
853
854 // OK
855 return true;
856}
857
858void GlobalDeviceDetour::Uninstall() {
859 // Detach from detour

Callers 5

DllMainFunction · 0.45
CreateCommandQueueStateFunction · 0.45
PoolAndInstallFeaturesFunction · 0.45
D3D12CreateDeviceGPUOpenFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected