| 27 | using namespace std::chrono_literals; |
| 28 | |
| 29 | bool LoadRenderDoc() |
| 30 | { |
| 31 | LONG error = ERROR_SUCCESS; |
| 32 | |
| 33 | // Open the libraries key |
| 34 | char keyPath[MAX_PATH] = { "RenderDoc.RDCCapture.1\\DefaultIcon" }; |
| 35 | HKEY iconKey; |
| 36 | error = RegOpenKeyExA(HKEY_CLASSES_ROOT, keyPath, 0, KEY_READ, &iconKey); |
| 37 | if (error != ERROR_SUCCESS) |
| 38 | return false; |
| 39 | |
| 40 | // Get the default library |
| 41 | char path[MAX_PATH]; |
| 42 | DWORD length = MAX_PATH; |
| 43 | error = RegQueryValueExA(iconKey, "", NULL, NULL, (PBYTE)path, &length); |
| 44 | RegCloseKey(iconKey); |
| 45 | if (error != ERROR_SUCCESS) |
| 46 | return false; |
| 47 | |
| 48 | if (path[0] == '\0') |
| 49 | return false; |
| 50 | |
| 51 | strcpy(strrchr(path, '\\') + 1, "renderdoc.dll"); |
| 52 | return LoadLibraryA(path) != NULL; |
| 53 | } |
| 54 | |
| 55 | void AttachDetours(); |
| 56 | void DetachDetours(); |