#include "master.h"
-F_STRING *get_error_message(void)
-{
- DWORD id = GetLastError();
- F_CHAR *msg = error_message(id);
- F_STRING *string = from_u16_string(msg);
- LocalFree(msg);
- return string;
-}
-
-/* You must LocalFree() the return value! */
-F_CHAR *error_message(DWORD id)
-{
- F_CHAR *buffer;
- int index;
-
- DWORD ret = FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- id,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR)(void *) &buffer,
- 0, NULL);
- if(ret == 0)
- return error_message(GetLastError());
-
- /* strip whitespace from end */
- index = wcslen(buffer) - 1;
- while(index >= 0 && isspace(buffer[index]))
- buffer[index--] = 0;
-
- return buffer;
-}
-
HMODULE hFactorDll;
void init_ffi(void)
/* Difference between Jan 1 00:00:00 1601 and Jan 1 00:00:00 1970 */
#define EPOCH_OFFSET 0x019db1ded53e8000LL
-F_STRING *get_error_message(void);
-DLLEXPORT F_CHAR *error_message(DWORD id);
-void windows_error(void);
-
void init_ffi(void);
void ffi_dlopen(F_DLL *dll);
void *ffi_dlsym(F_DLL *dll, F_SYMBOL *symbol);