20 #ifndef WINPR_LIBRARY_H
21 #define WINPR_LIBRARY_H
23 #include <winpr/winpr.h>
24 #include <winpr/wtypes.h>
26 #if !defined(_WIN32) || defined(_UWP)
28 typedef HANDLE DLL_DIRECTORY_COOKIE;
30 #define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200
31 #define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x00001000
32 #define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
33 #define LOAD_LIBRARY_SEARCH_USER_DIRS 0x00000400
35 #define DONT_RESOLVE_DLL_REFERENCES 0x00000001
36 #define LOAD_LIBRARY_AS_DATAFILE 0x00000002
37 #define LOAD_WITH_ALTERED_SEARCH_PATH 0x00000008
38 #define LOAD_IGNORE_CODE_AUTHZ_LEVEL 0x00000010
39 #define LOAD_LIBRARY_AS_IMAGE_RESOURCE 0x00000020
40 #define LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE 0x00000040
41 #define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR 0x00000100
42 #define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200
43 #define LOAD_LIBRARY_SEARCH_USER_DIRS 0x00000400
44 #define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
45 #define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x00001000
52 WINPR_API DLL_DIRECTORY_COOKIE AddDllDirectory(PCWSTR NewDirectory);
53 WINPR_API BOOL RemoveDllDirectory(DLL_DIRECTORY_COOKIE Cookie);
54 WINPR_API BOOL SetDefaultDllDirectories(DWORD DirectoryFlags);
56 WINPR_API HMODULE LoadLibraryA(LPCSTR lpLibFileName);
57 WINPR_API HMODULE LoadLibraryW(LPCWSTR lpLibFileName);
59 WINPR_API HMODULE LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
60 WINPR_API HMODULE LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
67 #define LoadLibrary LoadLibraryW
68 #define LoadLibraryEx LoadLibraryExW
70 #define LoadLibrary LoadLibraryA
71 #define LoadLibraryEx LoadLibraryExA
81 WINPR_API HMODULE LoadLibraryX(LPCSTR lpLibFileName);
82 WINPR_API HMODULE LoadLibraryExX(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
96 #define GetProcAddressAs(module, name, type) WINPR_FUNC_PTR_CAST(GetProcAddress(module, name), type)
98 #if !defined(_WIN32) && !defined(__CYGWIN__)
105 WINPR_API HMODULE GetModuleHandleA(LPCSTR lpModuleName);
106 WINPR_API HMODULE GetModuleHandleW(LPCWSTR lpModuleName);
108 WINPR_API DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize);
109 WINPR_API DWORD GetModuleFileNameW(HMODULE hModule, LPWSTR lpFilename, DWORD nSize);
111 WINPR_API FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName);
113 WINPR_API BOOL FreeLibrary(HMODULE hLibModule);
120 #define GetModuleHandle GetModuleHandleW
121 #define GetModuleFileName GetModuleFileNameW
123 #define GetModuleHandle GetModuleHandleA
124 #define GetModuleFileName GetModuleFileNameA