diff options
-rw-r--r-- | test cases/common/122 shared module/module.c | 16 | ||||
-rw-r--r-- | test cases/common/122 shared module/prog.c | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/test cases/common/122 shared module/module.c b/test cases/common/122 shared module/module.c index 181b760..9c8774d 100644 --- a/test cases/common/122 shared module/module.c +++ b/test cases/common/122 shared module/module.c @@ -27,6 +27,19 @@ fptr find_any_f (const char *name) { #include <windows.h> #include <tlhelp32.h> +static wchar_t* +win32_get_last_error (void) +{ + wchar_t *msg = NULL; + + FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER + | FORMAT_MESSAGE_IGNORE_INSERTS + | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, GetLastError (), 0, + (LPWSTR) &msg, 0, NULL); + return msg; +} + /* Unlike Linux and OS X, when a library is loaded, all the symbols aren't * loaded into a single namespace. You must fetch the symbol by iterating over * all loaded modules. Code for finding the function from any of the loaded @@ -38,7 +51,8 @@ fptr find_any_f (const char *name) { snapshot = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE, 0); if (snapshot == (HANDLE) -1) { - printf("Could not get snapshot\n"); + wchar_t *msg = win32_get_last_error (); + printf("Could not get snapshot: %S\n", msg); return 0; } diff --git a/test cases/common/122 shared module/prog.c b/test cases/common/122 shared module/prog.c index 2b63840..8b56d93 100644 --- a/test cases/common/122 shared module/prog.c +++ b/test cases/common/122 shared module/prog.c @@ -8,7 +8,7 @@ typedef int (*fptr) (void); #include <windows.h> -wchar_t* +static wchar_t* win32_get_last_error (void) { wchar_t *msg = NULL; |