diff options
Diffstat (limited to 'win32/lazyload.h')
-rw-r--r-- | win32/lazyload.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/win32/lazyload.h b/win32/lazyload.h new file mode 100644 index 000000000..034bc7e45 --- /dev/null +++ b/win32/lazyload.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #ifndef LAZYLOAD_H | ||
2 | #define LAZYLOAD_H | ||
3 | |||
4 | /* simplify loading of DLL functions */ | ||
5 | |||
6 | struct proc_addr { | ||
7 | FARPROC pfunction; | ||
8 | unsigned initialized; | ||
9 | }; | ||
10 | |||
11 | /* Declares a function to be loaded dynamically from a DLL. */ | ||
12 | #define DECLARE_PROC_ADDR(rettype, function, ...) \ | ||
13 | static struct proc_addr proc_addr_##function = { NULL, 0 }; \ | ||
14 | rettype (WINAPI *function)(__VA_ARGS__) | ||
15 | |||
16 | /* | ||
17 | * Loads a function from a DLL (once-only). | ||
18 | * Returns non-NULL function pointer on success. | ||
19 | * Returns NULL and sets errno == ENOSYS on failure. | ||
20 | */ | ||
21 | #define INIT_PROC_ADDR(dll, function) \ | ||
22 | (function = get_proc_addr(#dll, #function, &proc_addr_##function)) | ||
23 | |||
24 | void *get_proc_addr(const char *dll, const char *function, | ||
25 | struct proc_addr *proc); | ||
26 | |||
27 | #endif | ||