| 831 | } |
| 832 | |
| 833 | bool 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 | |
| 858 | void GlobalDeviceDetour::Uninstall() { |
| 859 | // Detach from detour |
no outgoing calls
no test coverage detected