1 | /*
|
---|
2 | * Copyright 2010 Vicente J. Botet Escriba
|
---|
3 | * Copyright 2014 Renato Tegon Forti, Antony Polukhin
|
---|
4 | * Copyright 2015 Andrey Semashev
|
---|
5 | * Copyright 2015 Antony Polukhin
|
---|
6 | *
|
---|
7 | * Distributed under the Boost Software License, Version 1.0.
|
---|
8 | * See http://www.boost.org/LICENSE_1_0.txt
|
---|
9 | */
|
---|
10 |
|
---|
11 | #ifndef BOOST_WINAPI_DLL_HPP_INCLUDED_
|
---|
12 | #define BOOST_WINAPI_DLL_HPP_INCLUDED_
|
---|
13 |
|
---|
14 | #include <boost/winapi/basic_types.hpp>
|
---|
15 |
|
---|
16 | #ifdef BOOST_HAS_PRAGMA_ONCE
|
---|
17 | #pragma once
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #if BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
|
---|
21 |
|
---|
22 | #if !defined( BOOST_USE_WINDOWS_H )
|
---|
23 | extern "C" {
|
---|
24 | namespace boost { namespace winapi {
|
---|
25 | #ifdef _WIN64
|
---|
26 | typedef INT_PTR_ (WINAPI *FARPROC_)();
|
---|
27 | typedef INT_PTR_ (WINAPI *NEARPROC_)();
|
---|
28 | typedef INT_PTR_ (WINAPI *PROC_)();
|
---|
29 | #else
|
---|
30 | typedef int (WINAPI *FARPROC_)();
|
---|
31 | typedef int (WINAPI *NEARPROC_)();
|
---|
32 | typedef int (WINAPI *PROC_)();
|
---|
33 | #endif // _WIN64
|
---|
34 | }} // namespace boost::winapi
|
---|
35 |
|
---|
36 | #if !defined( BOOST_NO_ANSI_APIS )
|
---|
37 | BOOST_SYMBOL_IMPORT _Ret_maybenull_ boost::winapi::HMODULE_ WINAPI LoadLibraryA(_In_ boost::winapi::LPCSTR_ lpFileName);///@@@Boostilonchenkorrekturen.Michael Soliman.2018-04-10.
|
---|
38 | BOOST_SYMBOL_IMPORT _Ret_maybenull_ boost::winapi::HMODULE_ WINAPI
|
---|
39 |
|
---|
40 |
|
---|
41 | LoadLibraryExA(
|
---|
42 | _In_ boost::winapi::LPCSTR_ lpFileName,
|
---|
43 | _Reserved_ boost::winapi::HANDLE_ hFile,
|
---|
44 | _In_ boost::winapi::DWORD_ dwFlags
|
---|
45 | );
|
---|
46 |
|
---|
47 | BOOST_SYMBOL_IMPORT _When_(lpModuleName==NULL,_Ret_notnull_)///@@@Boostilonchenkorrekturen.Michael Soliman.2018-04-10.
|
---|
48 | _When_(lpModuleName!=NULL,_Ret_maybenull_)
|
---|
49 | boost::winapi::HMODULE_ WINAPI
|
---|
50 | GetModuleHandleA(_In_opt_ boost::winapi::LPCSTR_ lpModuleName);
|
---|
51 |
|
---|
52 | BOOST_SYMBOL_IMPORT _Success_(return!=0)
|
---|
53 | _Ret_range_(1,nSize)
|
---|
54 | boost::winapi::DWORD_ WINAPI
|
---|
55 | GetModuleFileNameA(
|
---|
56 | _In_opt_ boost::winapi::HMODULE_ hModule,
|
---|
57 | _Out_writes_to_(nSize, ((return < nSize) ? (return + 1) : nSize)) boost::winapi::LPSTR_ lpFilename,
|
---|
58 | _In_ boost::winapi::DWORD_ nSize
|
---|
59 | );
|
---|
60 | #endif
|
---|
61 | BOOST_SYMBOL_IMPORT _Ret_maybenull_ boost::winapi::HMODULE_ WINAPI LoadLibraryW(_In_ boost::winapi::LPCWSTR_ lpFileName);
|
---|
62 | BOOST_SYMBOL_IMPORT _Ret_maybenull_ boost::winapi::HMODULE_ WINAPI
|
---|
63 | LoadLibraryExW(
|
---|
64 | _In_ boost::winapi::LPCWSTR_ lpFileName,
|
---|
65 | _Reserved_ boost::winapi::HANDLE_ hFile,
|
---|
66 | _In_ boost::winapi::DWORD_ dwFlags
|
---|
67 | );
|
---|
68 |
|
---|
69 | BOOST_SYMBOL_IMPORT _When_(lpModuleName==NULL,_Ret_notnull_)///@@@Boostilonchenkorrekturen.Michael Soliman.2018-04-10.
|
---|
70 | _When_(lpModuleName!=NULL,_Ret_maybenull_)
|
---|
71 | boost::winapi::HMODULE_ WINAPI GetModuleHandleW(_In_opt_ boost::winapi::LPCWSTR_ lpModuleName);
|
---|
72 | BOOST_SYMBOL_IMPORT _Success_(return != 0)
|
---|
73 | _Ret_range_(1, nSize)
|
---|
74 | boost::winapi::DWORD_ WINAPI
|
---|
75 | GetModuleFileNameW(
|
---|
76 | _In_opt_ boost::winapi::HMODULE_ hModule,
|
---|
77 | _Out_writes_to_(nSize, ((return < nSize) ? (return + 1) : nSize)) boost::winapi::LPWSTR_ lpFilename,
|
---|
78 | _In_ boost::winapi::DWORD_ nSize
|
---|
79 | );
|
---|
80 |
|
---|
81 | #if !defined( UNDER_CE )
|
---|
82 | BOOST_SYMBOL_IMPORT boost::winapi::FARPROC_ WINAPI GetProcAddress(_In_ boost::winapi::HMODULE_ hModule,_In_ boost::winapi::LPCSTR_ lpProcName); ///@@@Boostilonchenkorrekturen.Michael Soliman.2018-04-10.
|
---|
83 | #else
|
---|
84 | // On Windows CE there are two functions: GetProcAddressA (since Windows CE 3.0) and GetProcAddressW.
|
---|
85 | // GetProcAddress is a macro that is _always_ defined to GetProcAddressW.
|
---|
86 | BOOST_SYMBOL_IMPORT boost::winapi::FARPROC_ WINAPI
|
---|
87 | GetProcAddressA(boost::winapi::HMODULE_ hModule, boost::winapi::LPCSTR_ lpProcName);
|
---|
88 | BOOST_SYMBOL_IMPORT boost::winapi::FARPROC_ WINAPI
|
---|
89 | GetProcAddressW(boost::winapi::HMODULE_ hModule, boost::winapi::LPCWSTR_ lpProcName);
|
---|
90 | #endif
|
---|
91 |
|
---|
92 | struct _MEMORY_BASIC_INFORMATION;
|
---|
93 |
|
---|
94 | #if !defined( BOOST_WINAPI_IS_MINGW )
|
---|
95 | BOOST_SYMBOL_IMPORT boost::winapi::SIZE_T_ WINAPI
|
---|
96 | VirtualQuery(
|
---|
97 | _In_opt_ boost::winapi::LPCVOID_ lpAddress,///@@@Boostilonchenkorrekturen.Michael Soliman.2018-04-10.
|
---|
98 | _Out_writes_bytes_to_(dwLength, return) ::_MEMORY_BASIC_INFORMATION* lpBuffer,
|
---|
99 | _In_ boost::winapi::ULONG_PTR_ dwLength
|
---|
100 | );
|
---|
101 | #else // !defined( BOOST_WINAPI_IS_MINGW )
|
---|
102 | BOOST_SYMBOL_IMPORT boost::winapi::DWORD_ WINAPI
|
---|
103 | VirtualQuery(
|
---|
104 | _In_opt_ boost::winapi::LPCVOID_ lpAddress,///@@@Boostilonchenkorrekturen.Michael Soliman.2018-04-10.
|
---|
105 | _Out_writes_bytes_to_(dwLength, return) ::_MEMORY_BASIC_INFORMATION* lpBuffer,
|
---|
106 | _In_ boost::winapi::DWORD_ dwLength
|
---|
107 | );
|
---|
108 | #endif // !defined( BOOST_WINAPI_IS_MINGW )
|
---|
109 | } // extern "C"
|
---|
110 | #endif // #if !defined( BOOST_USE_WINDOWS_H )
|
---|
111 |
|
---|
112 | namespace boost {
|
---|
113 | namespace winapi {
|
---|
114 |
|
---|
115 | typedef struct BOOST_MAY_ALIAS MEMORY_BASIC_INFORMATION_ {
|
---|
116 | PVOID_ BaseAddress;
|
---|
117 | PVOID_ AllocationBase;
|
---|
118 | DWORD_ AllocationProtect;
|
---|
119 | SIZE_T_ RegionSize;
|
---|
120 | DWORD_ State;
|
---|
121 | DWORD_ Protect;
|
---|
122 | DWORD_ Type;
|
---|
123 | } *PMEMORY_BASIC_INFORMATION_;
|
---|
124 |
|
---|
125 | #if defined( BOOST_USE_WINDOWS_H )
|
---|
126 | typedef ::FARPROC FARPROC_;
|
---|
127 | typedef ::NEARPROC NEARPROC_;
|
---|
128 | typedef ::PROC PROC_;
|
---|
129 |
|
---|
130 | const DWORD_ DONT_RESOLVE_DLL_REFERENCES_ = DONT_RESOLVE_DLL_REFERENCES;
|
---|
131 | const DWORD_ LOAD_WITH_ALTERED_SEARCH_PATH_ = LOAD_WITH_ALTERED_SEARCH_PATH;
|
---|
132 | #else // defined( BOOST_USE_WINDOWS_H )
|
---|
133 | const DWORD_ DONT_RESOLVE_DLL_REFERENCES_ = 0x00000001;
|
---|
134 | const DWORD_ LOAD_WITH_ALTERED_SEARCH_PATH_ = 0x00000008;
|
---|
135 | #endif // defined( BOOST_USE_WINDOWS_H )
|
---|
136 |
|
---|
137 | // This one is not defined by MinGW
|
---|
138 | const DWORD_ LOAD_IGNORE_CODE_AUTHZ_LEVEL_ = 0x00000010;
|
---|
139 |
|
---|
140 | #if !defined( BOOST_NO_ANSI_APIS )
|
---|
141 | using ::LoadLibraryA;
|
---|
142 | using ::LoadLibraryExA;
|
---|
143 | using ::GetModuleHandleA;
|
---|
144 | using ::GetModuleFileNameA;
|
---|
145 | #endif // !defined( BOOST_NO_ANSI_APIS )
|
---|
146 | using ::LoadLibraryW;
|
---|
147 | using ::LoadLibraryExW;
|
---|
148 | using ::GetModuleHandleW;
|
---|
149 | using ::GetModuleFileNameW;
|
---|
150 |
|
---|
151 | #if !defined( UNDER_CE )
|
---|
152 | // For backward compatibility, don't use directly. Use get_proc_address instead.
|
---|
153 | using ::GetProcAddress;
|
---|
154 | #else
|
---|
155 | using ::GetProcAddressA;
|
---|
156 | using ::GetProcAddressW;
|
---|
157 | #endif
|
---|
158 |
|
---|
159 | BOOST_FORCEINLINE FARPROC_ get_proc_address(HMODULE_ hModule, LPCSTR_ lpProcName)
|
---|
160 | {
|
---|
161 | #if !defined( UNDER_CE )
|
---|
162 | return ::GetProcAddress(hModule, lpProcName);
|
---|
163 | #else
|
---|
164 | return ::GetProcAddressA(hModule, lpProcName);
|
---|
165 | #endif
|
---|
166 | }
|
---|
167 |
|
---|
168 | BOOST_FORCEINLINE SIZE_T_ VirtualQuery(LPCVOID_ lpAddress, MEMORY_BASIC_INFORMATION_* lpBuffer, ULONG_PTR_ dwLength)
|
---|
169 | {
|
---|
170 | return ::VirtualQuery(lpAddress, reinterpret_cast< ::_MEMORY_BASIC_INFORMATION* >(lpBuffer), dwLength);
|
---|
171 | }
|
---|
172 |
|
---|
173 | #if !defined( BOOST_NO_ANSI_APIS )
|
---|
174 | BOOST_FORCEINLINE HMODULE_ load_library(LPCSTR_ lpFileName)
|
---|
175 | {
|
---|
176 | return ::LoadLibraryA(lpFileName);
|
---|
177 | }
|
---|
178 |
|
---|
179 | BOOST_FORCEINLINE HMODULE_ load_library_ex(LPCSTR_ lpFileName, HANDLE_ hFile, DWORD_ dwFlags)
|
---|
180 | {
|
---|
181 | return ::LoadLibraryExA(lpFileName, hFile, dwFlags);
|
---|
182 | }
|
---|
183 |
|
---|
184 | BOOST_FORCEINLINE HMODULE_ get_module_handle(LPCSTR_ lpFileName)
|
---|
185 | {
|
---|
186 | return ::GetModuleHandleA(lpFileName);
|
---|
187 | }
|
---|
188 |
|
---|
189 | BOOST_FORCEINLINE DWORD_ get_module_file_name(HMODULE_ hModule, LPSTR_ lpFilename, DWORD_ nSize)
|
---|
190 | {
|
---|
191 | return ::GetModuleFileNameA(hModule, lpFilename, nSize);
|
---|
192 | }
|
---|
193 | #endif // #if !defined( BOOST_NO_ANSI_APIS )
|
---|
194 |
|
---|
195 | BOOST_FORCEINLINE HMODULE_ load_library(LPCWSTR_ lpFileName)
|
---|
196 | {
|
---|
197 | return ::LoadLibraryW(lpFileName);
|
---|
198 | }
|
---|
199 |
|
---|
200 | BOOST_FORCEINLINE HMODULE_ load_library_ex(LPCWSTR_ lpFileName, HANDLE_ hFile, DWORD_ dwFlags)
|
---|
201 | {
|
---|
202 | return ::LoadLibraryExW(lpFileName, hFile, dwFlags);
|
---|
203 | }
|
---|
204 |
|
---|
205 | BOOST_FORCEINLINE HMODULE_ get_module_handle(LPCWSTR_ lpFileName)
|
---|
206 | {
|
---|
207 | return ::GetModuleHandleW(lpFileName);
|
---|
208 | }
|
---|
209 |
|
---|
210 | BOOST_FORCEINLINE DWORD_ get_module_file_name(HMODULE_ hModule, LPWSTR_ lpFilename, DWORD_ nSize)
|
---|
211 | {
|
---|
212 | return ::GetModuleFileNameW(hModule, lpFilename, nSize);
|
---|
213 | }
|
---|
214 |
|
---|
215 | } // namespace winapi
|
---|
216 | } // namespace boost
|
---|
217 |
|
---|
218 | #endif // BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
|
---|
219 |
|
---|
220 | //
|
---|
221 | // FreeLibrary is in a different partition set (slightly)
|
---|
222 | //
|
---|
223 |
|
---|
224 | #if BOOST_WINAPI_PARTITION_APP || BOOST_WINAPI_PARTITION_SYSTEM
|
---|
225 |
|
---|
226 | #if !defined(BOOST_USE_WINDOWS_H)
|
---|
227 | extern "C" {
|
---|
228 | BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ WINAPI
|
---|
229 | FreeLibrary(boost::winapi::HMODULE_ hModule);
|
---|
230 | }
|
---|
231 | #endif
|
---|
232 |
|
---|
233 | namespace boost {
|
---|
234 | namespace winapi {
|
---|
235 | using ::FreeLibrary;
|
---|
236 | }
|
---|
237 | }
|
---|
238 |
|
---|
239 | #endif // BOOST_WINAPI_PARTITION_APP || BOOST_WINAPI_PARTITION_SYSTEM
|
---|
240 | #endif // BOOST_WINAPI_DLL_HPP_INCLUDED_
|
---|