From 94848bc8364582fdf080ccf66d25b63d2ab498da Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Mon, 29 Jun 2020 01:33:50 +1000 Subject: [PATCH] loader: better error messages for plugin loading --- source-code/source/PD-Loader/dllmain.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source-code/source/PD-Loader/dllmain.cpp b/source-code/source/PD-Loader/dllmain.cpp index 7473261..17637c1 100644 --- a/source-code/source/PD-Loader/dllmain.cpp +++ b/source-code/source/PD-Loader/dllmain.cpp @@ -159,6 +159,16 @@ void LoadDVA(std::wstring &path, LPCWSTR dir, LPCWSTR fileName) if (e != ERROR_DLL_INIT_FAILED) // in case dllmain returns false { std::wstring msg = L"Unable to load " + std::wstring(fileName) + L". Error: " + std::to_wstring(e); + + LPVOID err_msg; + if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, e, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (LPWSTR)&err_msg, 1, NULL) + != 0) + { + msg += L"\n"; + msg += (LPWSTR)err_msg; + } + switch (e) { case 126: