[test][ASan][Win] Print more info when LoadLibrary fails

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D118206
This commit is contained in:
Arthur Eubanks 2022-01-25 17:46:29 -08:00
parent cbc623c767
commit 092f6ae292
1 changed files with 14 additions and 2 deletions

View File

@ -59,8 +59,20 @@ int main(int argc, char **argv) {
HMODULE h = LoadLibrary(dll_name);
if (!h) {
printf("Could not load DLL: %s (code: %lu)!\n",
dll_name, GetLastError());
DWORD err = GetLastError();
printf("Could not load DLL: %s (code: %lu)!\n", dll_name, err);
LPSTR buf;
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 0,
NULL);
printf("Error: %s\n", buf);
LocalFree(buf);
return 102;
}