8 static void GetErrorStr(char **error
, BOOL condition
)
12 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|FORMAT_MESSAGE_FROM_SYSTEM
, NULL
, GetLastError(),
13 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
), error
, 0, NULL
);
19 void Host_HostLib_FreeErrorStr(char *error
)
24 void *Host_HostLib_Open(const char *filename
, char **error
)
28 D(printf("[hostlib] Open: filename=%s\n", filename
));
29 handle
= LoadLibrary(filename
);
30 GetErrorStr(error
, !handle
);
35 int Host_HostLib_Close(void *handle
, char **error
)
39 D(printf("[hostlib] Close: handle=0x%08x\n", handle
));
40 err
= !FreeLibrary(handle
);
41 GetErrorStr(error
, err
);
46 void *Host_HostLib_GetPointer(void *handle
, const char *symbol
, char **error
)
50 D(printf("[hostlib] GetPointer: handle=0x%08x, symbol=%s\n", handle
, symbol
));
51 ptr
= GetProcAddress(handle
, symbol
);
52 GetErrorStr(error
, !ptr
);
56 unsigned long Host_HostLib_GetInterface(void *handle
, char **names
, void **funcs
)
58 unsigned long unresolved
= 0;
60 for (; *names
; names
++) {
61 *funcs
= GetProcAddress(handle
, *names
);
62 D(printf("[hostlib] GetInterface: handle=0x%08x, symbol=%s, value=0x%08x\n", handle
, *names
, *funcs
));