11 static bool self =
false;
13 void* dlopen(
const char* path,
int mode) {
20 void* handle = LoadLibrary(path);
22 char *
buf = malloc(strlen(path) + 20);
23 sprintf(buf,
"%s.dll", path);
24 handle = LoadLibrary(buf);
31 void* dlsym(
void* handle,
const char* symbol) {
32 return GetProcAddress(handle, symbol);
35 int dlclose(
void* handle) {
38 return FreeLibrary(handle) != 0;
41 static char dlerror_buf[200];
43 const char *dlerror(
void) {
45 return "not supported";
48 DWORD err = GetLastError();
50 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
51 FORMAT_MESSAGE_FROM_SYSTEM |
52 FORMAT_MESSAGE_IGNORE_INSERTS,
53 NULL, err, 0, (LPTSTR)&error_msg, 0, NULL) != 0) {
54 strncpy(dlerror_buf, error_msg,
sizeof(dlerror_buf));
55 dlerror_buf[
sizeof(dlerror_buf) - 1] =
'\0';
58 return "Failed to get error message";