| 11 | }; |
| 12 | |
| 13 | static FARPROC GetFunction(Module index, const char *name) |
| 14 | { |
| 15 | static HMODULE modules[MODULE_MAX]{}; |
| 16 | static LPCWSTR module_dlls[MODULE_MAX] |
| 17 | { |
| 18 | L"d3d9.dll", |
| 19 | L"dwrite.dll", |
| 20 | L"version.dll", |
| 21 | }; |
| 22 | |
| 23 | if (modules[index] == nullptr) |
| 24 | { |
| 25 | BOOL wow64 = FALSE; |
| 26 | WCHAR path[MAX_PATH]; |
| 27 | |
| 28 | if (IsWow64Process(GetCurrentProcess(), &wow64) && wow64) |
| 29 | GetSystemWow64DirectoryW(path, MAX_PATH); |
| 30 | else |
| 31 | GetSystemDirectoryW(path, MAX_PATH); |
| 32 | |
| 33 | lstrcatW(path, L"\\"); |
| 34 | lstrcatW(path, module_dlls[index]); |
| 35 | modules[index] = LoadLibraryW(path); |
| 36 | } |
| 37 | |
| 38 | return GetProcAddress(modules[index], name); |
| 39 | } |
| 40 | |
| 41 | template<typename T> |
| 42 | static T _Forward(Module index, const char* funcName, T) |