diff options
author | glx22 <glx@openttd.org> | 2021-05-20 18:28:14 +0200 |
---|---|---|
committer | Loïc Guilloux <glx22@users.noreply.github.com> | 2021-06-10 23:17:29 +0200 |
commit | 5d05c4919bd5b5cb9cf1e0123f0c65769e67bd2d (patch) | |
tree | 066ea036fe12b963f9ce7fcd04d5e1898c0a29c0 /src/os/windows/crashlog_win.cpp | |
parent | f4c7d5577ed83d426371f86d780aed01c5370953 (diff) | |
download | openttd-5d05c4919bd5b5cb9cf1e0123f0c65769e67bd2d.tar.xz |
Codechange: [WIN32] Reduce manual dynamic loading as WinXP is the minimum version
Diffstat (limited to 'src/os/windows/crashlog_win.cpp')
-rw-r--r-- | src/os/windows/crashlog_win.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp index a7ff8e411..0e1d2f8cc 100644 --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -22,6 +22,7 @@ #include <windows.h> #include <mmsystem.h> #include <signal.h> +#include <psapi.h> #include "../../safeguards.h" @@ -206,25 +207,19 @@ static char *PrintModuleInfo(char *output, const char *last, HMODULE mod) /* virtual */ char *CrashLogWindows::LogModules(char *output, const char *last) const { MakeCRCTable(AllocaM(uint32, 256)); - BOOL (WINAPI *EnumProcessModules)(HANDLE, HMODULE*, DWORD, LPDWORD); - output += seprintf(output, last, "Module information:\n"); - if (LoadLibraryList((Function*)&EnumProcessModules, "psapi.dll\0EnumProcessModules\0\0")) { + HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId()); + if (proc != nullptr) { HMODULE modules[100]; DWORD needed; - BOOL res; - - HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId()); - if (proc != nullptr) { - res = EnumProcessModules(proc, modules, sizeof(modules), &needed); - CloseHandle(proc); - if (res) { - size_t count = std::min<DWORD>(needed / sizeof(HMODULE), lengthof(modules)); + BOOL res = EnumProcessModules(proc, modules, sizeof(modules), &needed); + CloseHandle(proc); + if (res) { + size_t count = std::min<DWORD>(needed / sizeof(HMODULE), lengthof(modules)); - for (size_t i = 0; i != count; i++) output = PrintModuleInfo(output, last, modules[i]); - return output + seprintf(output, last, "\n"); - } + for (size_t i = 0; i != count; i++) output = PrintModuleInfo(output, last, modules[i]); + return output + seprintf(output, last, "\n"); } } output = PrintModuleInfo(output, last, nullptr); |