| 36 | } |
| 37 | |
| 38 | void SWCADetour::Install() noexcept |
| 39 | { |
| 40 | if (!s_User32) |
| 41 | { |
| 42 | s_User32.reset(LoadLibraryEx(L"user32.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32)); |
| 43 | FAIL_FAST_LAST_ERROR_IF_NULL(s_User32); |
| 44 | } |
| 45 | |
| 46 | if (!SetWindowCompositionAttribute) |
| 47 | { |
| 48 | SetWindowCompositionAttribute = reinterpret_cast<PFN_SET_WINDOW_COMPOSITION_ATTRIBUTE>(GetProcAddress(s_User32.get(), UTIL_STRINGIFY_UTF8(SetWindowCompositionAttribute))); |
| 49 | FAIL_FAST_LAST_ERROR_IF(!SetWindowCompositionAttribute); |
| 50 | } |
| 51 | |
| 52 | if (!s_RequestAttribute) |
| 53 | { |
| 54 | s_RequestAttribute = RegisterWindowMessage(WM_TTBHOOKREQUESTREFRESH.c_str()); |
| 55 | FAIL_FAST_LAST_ERROR_IF(!s_RequestAttribute); |
| 56 | } |
| 57 | |
| 58 | if (!s_DetourInstalled) |
| 59 | { |
| 60 | DetourTransaction transaction; |
| 61 | transaction.update_all_threads(); |
| 62 | transaction.attach(SetWindowCompositionAttribute, FunctionDetour); |
| 63 | transaction.commit(); |
| 64 | |
| 65 | s_DetourInstalled = true; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | void SWCADetour::Uninstall() noexcept |
| 70 | { |
nothing calls this directly
no test coverage detected