Check if the process is already bootstrapped, the boostrapper performs its own detouring of calls \return true if bootstrapped
| 47 | /// Check if the process is already bootstrapped, the boostrapper performs its own detouring of calls |
| 48 | /// \return true if bootstrapped |
| 49 | static bool IsBootstrapped() { |
| 50 | // Try the hooked GPA first |
| 51 | auto* gpaBootstrapperInfo = reinterpret_cast<PFN_D3D12_GET_GPUOPEN_BOOTSTRAPPER_INFO>(GetProcAddress((HINSTANCE)&__ImageBase, "D3D12GetGPUOpenBootstrapperInfo")); |
| 52 | |
| 53 | // Otherwise, check the known bootstrapper handle |
| 54 | // SysWow64 will not get in here, so just check the 64 bit module |
| 55 | if (HMODULE bootstrapperHandle; GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "GRS.Backends.DX12.BootstrapperX64.dll", &bootstrapperHandle) && bootstrapperHandle) { |
| 56 | gpaBootstrapperInfo = reinterpret_cast<PFN_D3D12_GET_GPUOPEN_BOOTSTRAPPER_INFO>(GetProcAddress(bootstrapperHandle, "D3D12GetGPUOpenBootstrapperInfo")); |
| 57 | } |
| 58 | |
| 59 | // None found? |
| 60 | if (!gpaBootstrapperInfo) { |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | // Get info |
| 65 | D3D12GPUOpenBootstrapperInfo info{}; |
| 66 | gpaBootstrapperInfo(&info); |
| 67 | |
| 68 | // Version check |
| 69 | return info.version >= 1; |
| 70 | } |
| 71 | |
| 72 | /// DLL entrypoint |
| 73 | BOOL WINAPI DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID reserved) { |