From 7242f38fd7d3da310bbf42a9aacda9be1eea05cf Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 6 Oct 2005 22:10:27 +0000 Subject: [PATCH] get_error_message() is for native calls in native/win32/ffi.c error_message() is called via alien-invoke from factor code bugfix: the last "fix" caused the factor runtime to get a char* instead of F_STRING --- native/misc.c | 11 ++++++++--- native/misc.h | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/native/misc.c b/native/misc.c index b553224e77..4234f2a3e3 100644 --- a/native/misc.c +++ b/native/misc.c @@ -68,17 +68,22 @@ char *buffer_to_c_string(char *buffer) return (char*)c_str; } -char *last_error() +F_STRING *get_error_message() +{ + DWORD id = GetLastError(); + return from_c_string(error_message(id)); +} + +char *error_message(DWORD id) { char *buffer; int index; - DWORD dw = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, - dw, + id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &buffer, 0, NULL); diff --git a/native/misc.h b/native/misc.h index 05aab9f434..c7fd2f8e41 100644 --- a/native/misc.h +++ b/native/misc.h @@ -6,6 +6,7 @@ void primitive_millis(void); void primitive_random_int(void); #ifdef WIN32 char *buffer_to_c_string(char *buffer); -DLLEXPORT char *last_error(); +F_STRING *get_error_message(); +DLLEXPORT char *error_message(DWORD id); #endif