]>
Commit | Line | Data |
---|---|---|
a5cc215f CV |
1 | /* autoload.cc: all dynamic load stuff. |
2 | ||
a5cc215f CV |
3 | This file is part of Cygwin. |
4 | ||
5 | This software is a copyrighted work licensed under the terms of the | |
6 | Cygwin license. Please consult the file "CYGWIN_LICENSE" for | |
7 | details. */ | |
8 | ||
9 | #include "winsup.h" | |
ade47a34 | 10 | #include "miscfuncs.h" |
81137c50 | 11 | #include <fenv.h> |
d61b1993 CF |
12 | #define USE_SYS_TYPES_FD_SET |
13 | #include <winsock2.h> | |
14 | ||
ade47a34 CF |
15 | bool NO_COPY wsock_started; |
16 | ||
d61b1993 CF |
17 | /* Macro for defining "auto-load" functions. |
18 | * Note that this is self-modifying code *gasp*. | |
19 | * The first invocation of a routine will trigger the loading of | |
20 | * the DLL. This will then be followed by the discovery of | |
21 | * the procedure's entry point, which is placed into the location | |
22 | * pointed to by the stack pointer. This code then changes | |
23 | * the "call" operand which invoked it to a "jmp" which will | |
24 | * transfer directly to the DLL function on the next invocation. | |
25 | * | |
26 | * Subsequent calls to routines whose transfer address has not been | |
27 | * determined will skip the "load the dll" step, starting at the | |
28 | * "discovery of the entry point" step. | |
29 | * | |
30 | * So, immediately following the the call to one of the above routines | |
31 | * we have: | |
61522196 | 32 | * DLL info (4/8 bytes) Pointer to a block of information concerning |
d61b1993 | 33 | * the DLL (see below). |
77680cac CV |
34 | * DLL notimp (2 bytes) Bool value flagging that non-existence of this |
35 | * function is not a fatal error. | |
36 | * DLL error (2 bytes) Error value returned if function load fails. | |
37 | * Depends on the return type of the function. | |
38 | * Default is 0 == BOOL FALSE or == HANDLE NULL or | |
39 | * == Pointer NULL. | |
1f962581 | 40 | * func addr (8 bytes) Address of the actual Win32 function. For the |
61522196 CV |
41 | * reason why this is necessary, see the below |
42 | * description of the load_state. | |
d61b1993 CF |
43 | * func name (n bytes) asciz string containing the name of the function |
44 | * to be loaded. | |
45 | * | |
46 | * The DLL info block consists of the following | |
61522196 | 47 | * load_state (4/8 bytes) Pointer to a word containing the routine used |
d61b1993 | 48 | * to eventually invoke the function. Initially |
61522196 CV |
49 | * points to an init function which loads the DLL, |
50 | * gets the process's load address, changes the contents | |
51 | * here to point to the function address, and changes | |
52 | * the address argument of the initial jmp call. | |
1f962581 | 53 | * On x86_64, the jmp is not tweaked directly. Rather, |
61522196 CV |
54 | * the address of the Win32 function is stored in the |
55 | * aforementioned Win32 function address slot and fetched | |
56 | * there for a jmp *%rax call. This indirection is | |
57 | * necessary to workaround the lack of a jmp opcode with | |
58 | * offset values > 32 bit. If the initialization has | |
59 | * been done, only the load part is done. | |
60 | * DLL handle (4/8 bytes) The handle to use when loading the DLL. | |
d61b1993 CF |
61 | * DLL locker (4 bytes) Word to use to avoid multi-thread access during |
62 | * initialization. | |
61522196 | 63 | * extra init (4/8 bytes) Extra initialization function. |
d61b1993 CF |
64 | * DLL name (n bytes) asciz string containing the name of the DLL. |
65 | */ | |
66 | ||
67 | /* LoadDLLprime is used to prime the DLL info information, providing an | |
68 | additional initialization routine to call prior to calling the first | |
69 | function. */ | |
bbfe79fb | 70 | #ifdef __x86_64__ |
61522196 CV |
71 | #define LoadDLLprime(dllname, init_also, no_resolve_on_fork) __asm__ (" \n\ |
72 | .ifndef " #dllname "_primed \n\ | |
73 | .section .data_cygwin_nocopy,\"w\" \n\ | |
74 | .align 8 \n\ | |
75 | ."#dllname "_info: \n\ | |
76 | .quad _std_dll_init \n\ | |
77 | .quad " #no_resolve_on_fork " \n\ | |
78 | .long -1 \n\ | |
79 | .align 8 \n\ | |
80 | .quad " #init_also " \n\ | |
81 | .string16 \"" #dllname ".dll\" \n\ | |
82 | .text \n\ | |
83 | .set " #dllname "_primed, 1 \n\ | |
84 | .endif \n\ | |
85 | "); | |
bbfe79fb KB |
86 | #else |
87 | #error unimplemented for this target | |
88 | #endif | |
d61b1993 | 89 | |
ebd2f65c | 90 | /* Standard DLL load macro. May invoke a fatal error if the function isn't |
d61b1993 | 91 | found. */ |
77680cac CV |
92 | #define LoadDLLfunc(name, dllname) \ |
93 | LoadDLLfuncEx (name, dllname, 0) | |
94 | #define LoadDLLfuncEx(name, dllname, notimp) \ | |
95 | LoadDLLfuncEx2(name, dllname, notimp, 0) | |
96 | #define LoadDLLfuncEx2(name, dllname, notimp, err) \ | |
97 | LoadDLLfuncEx3(name, dllname, notimp, err, 0) | |
d61b1993 CF |
98 | |
99 | /* Main DLL setup stuff. */ | |
bbfe79fb | 100 | #ifdef __x86_64__ |
77680cac | 101 | #define LoadDLLfuncEx3(name, dllname, notimp, err, no_resolve_on_fork) \ |
61522196 CV |
102 | LoadDLLprime (dllname, dll_func_load, no_resolve_on_fork) \ |
103 | __asm__ (" \n\ | |
104 | .section ." #dllname "_autoload_text,\"wx\" \n\ | |
105 | .global " #name " \n\ | |
106 | .global _win32_" #name " \n\ | |
107 | .align 16 \n\ | |
108 | " #name ": \n\ | |
109 | _win32_" #name ": \n\ | |
110 | movq 3f(%rip),%rax \n\ | |
111 | jmp *%rax \n\ | |
112 | 1:movq 2f(%rip),%rax \n\ | |
113 | push %rbp # Keep 16 byte aligned \n\ | |
114 | push %r9 \n\ | |
115 | push %r8 \n\ | |
116 | push %rdx \n\ | |
117 | push %rcx \n\ | |
118 | call *(%rax) \n\ | |
119 | 2:.quad ." #dllname "_info \n\ | |
77680cac CV |
120 | .hword " #notimp " \n\ |
121 | .hword ((" #err ") & 0xffff) \n\ | |
61522196 CV |
122 | 3:.quad 1b \n\ |
123 | .asciz \"" #name "\" \n\ | |
124 | .text \n\ | |
125 | "); | |
bbfe79fb KB |
126 | #else |
127 | #error unimplemented for this target | |
128 | #endif | |
d61b1993 CF |
129 | |
130 | /* DLL loader helper functions used during initialization. */ | |
131 | ||
132 | /* The function which finds the address, given the name and overwrites | |
133 | the call so that future invocations go straight to the function in | |
134 | the DLL. */ | |
135 | extern "C" void dll_func_load () __asm__ ("dll_func_load"); | |
136 | ||
137 | /* Called by the primary initialization function "init_std_dll" to | |
138 | setup the stack and eliminate future calls to init_std_dll for other | |
139 | functions from this DLL. */ | |
140 | extern "C" void dll_chain () __asm__ ("dll_chain"); | |
141 | ||
a5cc215f CV |
142 | extern "C" { |
143 | ||
bbfe79fb | 144 | #ifdef __x86_64__ |
61522196 CV |
145 | __asm__ (" \n\ |
146 | .section .rdata,\"r\" \n\ | |
147 | msg1: \n\ | |
148 | .ascii \"couldn't dynamically determine load address for '%s' (handle %p), %E\\0\"\n\ | |
149 | \n\ | |
150 | .text \n\ | |
151 | .p2align 4,,15 \n\ | |
152 | noload: \n\ | |
153 | movq 40(%rsp),%rdx # Get the address of the information block\n\ | |
154 | movl 8(%rdx),%eax # Should we 'ignore' the lack \n\ | |
155 | test $1,%eax # of this function? \n\ | |
156 | jz 1f # Nope. \n\ | |
157 | andl $0xffff0000,%eax# upper word (== desired return value) \n\ | |
77680cac | 158 | sarl $16,%eax # swap to low order word \n\ |
61522196 CV |
159 | movl %eax,32(%rsp) # Save for later (in shadow space) \n\ |
160 | movl $127,%ecx # ERROR_PROC_NOT_FOUND \n\ | |
161 | call SetLastError # Set it \n\ | |
162 | movl 32(%rsp),%eax # Get back return value \n\ | |
61522196 CV |
163 | addq $40,%rsp # Revert stack \n\ |
164 | pop %r10 # Drop pointer to 'return address' \n\ | |
165 | pop %rcx # Restore arg registers \n\ | |
166 | pop %rdx \n\ | |
167 | pop %r8 \n\ | |
168 | pop %r9 \n\ | |
169 | pop %rbp # ...and restore frame pointer \n\ | |
170 | ret # Return \n\ | |
171 | 1: \n\ | |
172 | movq (%rdx),%rax # Handle value \n\ | |
173 | movq 8(%rax),%r8 \n\ | |
174 | lea 20(%rdx),%rdx # Location of name of function \n\ | |
175 | lea msg1(%rip),%rcx # The message \n\ | |
176 | call api_fatal # Print message. Never returns \n\ | |
177 | \n\ | |
178 | .globl dll_func_load \n\ | |
179 | dll_func_load: \n\ | |
180 | movq (%rsp),%rdx # 'Return address' contains load info \n\ | |
181 | movq (%rdx),%rcx # Where handle lives \n\ | |
182 | movq 8(%rcx),%rcx # Address of Handle to DLL \n\ | |
183 | addq $20,%rdx # Address of name of function to load \n\ | |
184 | subq $40,%rsp # Shadow space + 8 byte for alignment \n\ | |
185 | call GetProcAddress # Load it \n\ | |
186 | test %rax,%rax # Success? \n\ | |
187 | jne gotit # Yes \n\ | |
188 | jmp noload # Issue an error or return \n\ | |
189 | gotit: \n\ | |
190 | addq $40,%rsp # Revert stack \n\ | |
d2ef2331 | 191 | pop %r10 # Pointer to 'return address' \n\ |
61522196 CV |
192 | movq %rax,12(%r10) # Move absolute address to address slot \n\ |
193 | subq $25,%r10 # Point to jmp \n\ | |
194 | pop %rcx # Restore arg registers \n\ | |
195 | pop %rdx \n\ | |
196 | pop %r8 \n\ | |
197 | pop %r9 \n\ | |
198 | pop %rbp # ...and restore frame pointer \n\ | |
199 | jmp *%r10 # Jump to actual function \n\ | |
200 | \n\ | |
201 | .global dll_chain \n\ | |
202 | dll_chain: \n\ | |
203 | push %rax # Restore 'return address' \n\ | |
204 | jmp *%rdx # Jump to next init function \n\ | |
205 | "); | |
bbfe79fb KB |
206 | #else |
207 | #error unimplemented for this target | |
208 | #endif | |
d61b1993 CF |
209 | |
210 | /* C representations of the two info blocks described above. | |
211 | FIXME: These structures confuse gdb for some reason. GDB can print | |
212 | the whole structure but has problems with the name field? */ | |
213 | struct dll_info | |
a5cc215f | 214 | { |
61522196 | 215 | UINT_PTR load_state; |
d61b1993 CF |
216 | HANDLE handle; |
217 | LONG here; | |
218 | void (*init) (); | |
893a8b78 | 219 | WCHAR name[]; |
a5cc215f CV |
220 | }; |
221 | ||
d61b1993 CF |
222 | struct func_info |
223 | { | |
224 | struct dll_info *dll; | |
225 | LONG decoration; | |
61522196 | 226 | UINT_PTR func_addr; |
d61b1993 CF |
227 | char name[]; |
228 | }; | |
a5cc215f | 229 | |
d61b1993 | 230 | /* Mechanism for setting up info for passing to dll_chain routines. */ |
61522196 | 231 | typedef __uint128_t two_addr_t; |
d61b1993 CF |
232 | union retchain |
233 | { | |
61522196 CV |
234 | struct {uintptr_t high; uintptr_t low;}; |
235 | two_addr_t ll; | |
d61b1993 CF |
236 | }; |
237 | ||
15d6f564 CV |
238 | /* This function handles the problem described here: |
239 | ||
240 | http://www.microsoft.com/technet/security/advisory/2269637.mspx | |
105f79b4 | 241 | https://msdn.microsoft.com/library/ff919712 */ |
8ceb4854 | 242 | static __inline bool |
15d6f564 | 243 | dll_load (HANDLE& handle, PWCHAR name) |
a16b0549 | 244 | { |
fc449e1c | 245 | HANDLE h = NULL; |
fcda8810 | 246 | WCHAR dll_path[MAX_PATH]; |
15d6f564 | 247 | |
105f79b4 | 248 | /* Try loading with full path, which sometimes fails for no good reason. */ |
fcda8810 CV |
249 | wcpcpy (wcpcpy (dll_path, windows_system_directory), name); |
250 | h = LoadLibraryW (dll_path); | |
105f79b4 | 251 | /* If it failed, try loading just by name. */ |
15d6f564 | 252 | if (!h) |
fcda8810 | 253 | h = LoadLibraryW (name); |
8ceb4854 CF |
254 | if (!h) |
255 | return false; | |
256 | handle = h; | |
257 | return true; | |
a16b0549 CF |
258 | } |
259 | ||
0dcfb061 CV |
260 | #define RETRY_COUNT 10 |
261 | ||
d61b1993 | 262 | /* The standard DLL initialization routine. */ |
bbfe79fb | 263 | #ifdef __x86_64__ |
61522196 CV |
264 | |
265 | /* On x86_64, we need assembler wrappers for std_dll_init and wsock_init. | |
266 | In the x86_64 ABI it's no safe bet that frame[1] (aka 8(%rbp)) contains | |
267 | the return address. Consequentially, if we try to overwrite frame[1] | |
268 | with the address of dll_chain, we end up with a scrambled stack, the | |
269 | result depending on the optimization settings and the current frame of | |
270 | mind of the compiler. So for x86_64, we disable overwriting the return | |
271 | address in the real std_dll_init/wsock_init function, but rather do this | |
272 | in the wrapper, after return from the function, when we exactly know | |
273 | where the original return address is stored on the stack. */ | |
274 | ||
275 | #define INIT_WRAPPER(func) \ | |
276 | __asm__ (" \n\ | |
277 | .text \n\ | |
278 | .p2align 4,,15 \n\ | |
279 | .seh_proc _" #func " \n\ | |
280 | _" #func ": \n\ | |
281 | pushq %rbp \n\ | |
282 | .seh_pushreg %rbp \n\ | |
283 | movq %rsp,%rbp \n\ | |
284 | .seh_setframe %rbp,0 \n\ | |
285 | subq $0x20,%rsp \n\ | |
286 | .seh_stackalloc 32 \n\ | |
287 | .seh_endprologue \n\ | |
288 | movq 0x28(%rsp),%rcx # return address as parameter \n\ | |
289 | call " #func " \n\ | |
290 | movdqa %xmm0,0x10(%rsp) # 128 bit return value in xmm0 \n\ | |
291 | movq 0x10(%rsp),%rax # copy over to %rax and %rdx \n\ | |
292 | movq 0x18(%rsp),%rdx \n\ | |
293 | leaq dll_chain(%rip),%rcx # load address of dll_chain \n\ | |
294 | movq %rcx,0x28(%rsp) # and overwrite return address \n\ | |
295 | addq $0x20,%rsp \n\ | |
296 | popq %rbp \n\ | |
297 | ret \n\ | |
298 | .seh_endproc \n\ | |
299 | "); | |
300 | ||
301 | INIT_WRAPPER (std_dll_init) | |
302 | ||
bbfe79fb KB |
303 | #else |
304 | #error unimplemented for this target | |
305 | #endif | |
306 | ||
61522196 CV |
307 | __attribute__ ((used, noinline)) static two_addr_t |
308 | std_dll_init (struct func_info *func) | |
a5cc215f | 309 | { |
d61b1993 CF |
310 | struct dll_info *dll = func->dll; |
311 | retchain ret; | |
312 | ||
313 | if (InterlockedIncrement (&dll->here)) | |
314 | do | |
315 | { | |
316 | InterlockedDecrement (&dll->here); | |
084ea510 | 317 | yield (); |
d61b1993 CF |
318 | } |
319 | while (InterlockedIncrement (&dll->here)); | |
a16b0549 | 320 | else if ((uintptr_t) dll->handle <= 1) |
d61b1993 | 321 | { |
0f81b5d4 DK |
322 | fenv_t fpuenv; |
323 | fegetenv (&fpuenv); | |
0dcfb061 | 324 | DWORD err = ERROR_SUCCESS; |
a16b0549 | 325 | int i; |
b66f2546 CF |
326 | /* MSDN seems to imply that LoadLibrary can fail mysteriously, so, |
327 | since there have been reports of this in the mailing list, retry | |
0dcfb061 | 328 | several times before giving up. */ |
a16b0549 | 329 | for (i = 1; i <= RETRY_COUNT; i++) |
0dcfb061 CV |
330 | { |
331 | /* If loading the library succeeds, just leave the loop. */ | |
15d6f564 | 332 | if (dll_load (dll->handle, dll->name)) |
0dcfb061 CV |
333 | break; |
334 | /* Otherwise check error code returned by LoadLibrary. If the | |
335 | error code is neither NOACCESS nor DLL_INIT_FAILED, break out | |
336 | of the loop. */ | |
337 | err = GetLastError (); | |
338 | if (err != ERROR_NOACCESS && err != ERROR_DLL_INIT_FAILED) | |
339 | break; | |
340 | if (i < RETRY_COUNT) | |
341 | yield (); | |
342 | } | |
a16b0549 | 343 | if ((uintptr_t) dll->handle <= 1) |
0dcfb061 | 344 | { |
15d6f564 | 345 | if ((func->decoration & 1)) |
0dcfb061 CV |
346 | dll->handle = INVALID_HANDLE_VALUE; |
347 | else | |
15d6f564 | 348 | api_fatal ("unable to load %W, %E", dll->name); |
0dcfb061 | 349 | } |
92626feb | 350 | fesetenv (&fpuenv); |
d61b1993 CF |
351 | } |
352 | ||
b66f2546 | 353 | /* Set "arguments" for dll_chain. */ |
61522196 CV |
354 | ret.low = (uintptr_t) dll->init; |
355 | ret.high = (uintptr_t) func; | |
8d07b1aa | 356 | |
d61b1993 | 357 | InterlockedDecrement (&dll->here); |
d61b1993 CF |
358 | return ret.ll; |
359 | } | |
360 | ||
361 | /* Initialization function for winsock stuff. */ | |
61522196 | 362 | |
bbfe79fb | 363 | #ifdef __x86_64__ |
61522196 CV |
364 | /* See above comment preceeding std_dll_init. */ |
365 | INIT_WRAPPER (wsock_init) | |
bbfe79fb KB |
366 | #else |
367 | #error unimplemented for this target | |
368 | #endif | |
61522196 CV |
369 | |
370 | __attribute__ ((used, noinline)) static two_addr_t | |
371 | wsock_init (struct func_info *func) | |
d61b1993 | 372 | { |
264b5e13 CV |
373 | /* CV 2016-03-09: Moved wsadata into wsock_init to workaround a problem |
374 | with the NO_COPY definition of wsadata and here starting with gcc-5.3.0. | |
375 | See the git log for a description. */ | |
376 | static WSADATA NO_COPY wsadata; | |
d61b1993 | 377 | static LONG NO_COPY here = -1L; |
d61b1993 | 378 | struct dll_info *dll = func->dll; |
d61b1993 | 379 | |
63b61cd1 | 380 | while (InterlockedIncrement (&here)) |
a5cc215f | 381 | { |
63b61cd1 | 382 | InterlockedDecrement (&here); |
084ea510 | 383 | yield (); |
a5cc215f CV |
384 | } |
385 | ||
ee0afa42 | 386 | if (!wsock_started) |
d61b1993 | 387 | { |
7073ef4e | 388 | int (*wsastartup) (int, WSADATA *); |
a5cc215f | 389 | |
7c8d92d7 | 390 | /* Don't use autoload to load WSAStartup to eliminate recursion. */ |
7073ef4e | 391 | wsastartup = (int (*)(int, WSADATA *)) |
1ff9f4b9 | 392 | GetProcAddress ((HMODULE) (dll->handle), "WSAStartup"); |
d61b1993 | 393 | if (wsastartup) |
1ff9f4b9 | 394 | { |
8cd1ff7a | 395 | int res = wsastartup (MAKEWORD (2, 2), &wsadata); |
a5cc215f | 396 | |
d61b1993 CF |
397 | debug_printf ("res %d", res); |
398 | debug_printf ("wVersion %d", wsadata.wVersion); | |
399 | debug_printf ("wHighVersion %d", wsadata.wHighVersion); | |
400 | debug_printf ("szDescription %s", wsadata.szDescription); | |
401 | debug_printf ("szSystemStatus %s", wsadata.szSystemStatus); | |
402 | debug_printf ("iMaxSockets %d", wsadata.iMaxSockets); | |
403 | debug_printf ("iMaxUdpDg %d", wsadata.iMaxUdpDg); | |
c4458148 | 404 | |
d61b1993 | 405 | wsock_started = 1; |
1ff9f4b9 | 406 | } |
d61b1993 | 407 | } |
c0508da2 | 408 | InterlockedDecrement (&here); |
bc6ed549 | 409 | volatile retchain ret; |
ee0afa42 | 410 | /* Set "arguments for dll_chain. */ |
61522196 CV |
411 | ret.low = (uintptr_t) dll_func_load; |
412 | ret.high = (uintptr_t) func; | |
d61b1993 | 413 | return ret.ll; |
b0a50cf3 CF |
414 | } |
415 | ||
a16b0549 | 416 | LoadDLLprime (ws2_32, _wsock_init, 0) |
d61b1993 | 417 | |
77680cac CV |
418 | LoadDLLfunc (CheckTokenMembership, advapi32) |
419 | LoadDLLfunc (CreateProcessAsUserW, advapi32) | |
420 | LoadDLLfunc (DeregisterEventSource, advapi32) | |
421 | LoadDLLfunc (DecryptFileW, advapi32) | |
422 | LoadDLLfunc (EncryptFileW, advapi32) | |
423 | LoadDLLfunc (LogonUserW, advapi32) | |
424 | LoadDLLfunc (LookupAccountNameW, advapi32) | |
425 | LoadDLLfunc (LookupAccountSidW, advapi32) | |
426 | LoadDLLfunc (LsaClose, advapi32) | |
427 | LoadDLLfunc (LsaEnumerateAccountRights, advapi32) | |
428 | LoadDLLfunc (LsaFreeMemory, advapi32) | |
429 | LoadDLLfunc (LsaLookupSids, advapi32) | |
430 | LoadDLLfunc (LsaOpenPolicy, advapi32) | |
431 | LoadDLLfunc (LsaQueryInformationPolicy, advapi32) | |
432 | LoadDLLfunc (LsaRetrievePrivateData, advapi32) | |
433 | LoadDLLfunc (LsaStorePrivateData, advapi32) | |
434 | LoadDLLfunc (RegOpenUserClassesRoot, advapi32) | |
435 | LoadDLLfunc (RegOpenCurrentUser, advapi32) | |
436 | LoadDLLfunc (RegCloseKey, advapi32) | |
437 | LoadDLLfunc (RegCreateKeyExW, advapi32) | |
438 | LoadDLLfunc (RegEnumKeyExW, advapi32) | |
439 | LoadDLLfunc (RegEnumValueW, advapi32) | |
440 | LoadDLLfunc (RegGetKeySecurity, advapi32) | |
441 | LoadDLLfunc (RegOpenKeyExW, advapi32) | |
442 | LoadDLLfunc (RegQueryInfoKeyW, advapi32) | |
443 | LoadDLLfunc (RegQueryValueExW, advapi32) | |
444 | LoadDLLfunc (RegisterEventSourceW, advapi32) | |
445 | LoadDLLfunc (ReportEventW, advapi32) | |
446 | LoadDLLfunc (SystemFunction036, advapi32) /* Aka "RtlGenRandom" */ | |
447 | ||
448 | LoadDLLfunc (AuthzAccessCheck, authz) | |
449 | LoadDLLfunc (AuthzFreeContext, authz) | |
450 | LoadDLLfunc (AuthzInitializeContextFromSid, authz) | |
451 | LoadDLLfunc (AuthzInitializeContextFromToken, authz) | |
452 | LoadDLLfunc (AuthzInitializeResourceManager, authz) | |
453 | ||
454 | LoadDLLfunc (DnsQuery_A, dnsapi) | |
455 | LoadDLLfunc (DnsFree, dnsapi) | |
456 | ||
457 | LoadDLLfunc (GetAdaptersAddresses, iphlpapi) | |
458 | LoadDLLfunc (GetIfEntry, iphlpapi) | |
459 | LoadDLLfunc (GetIpAddrTable, iphlpapi) | |
460 | LoadDLLfunc (GetIpForwardTable, iphlpapi) | |
461 | LoadDLLfunc (GetNetworkParams, iphlpapi) | |
462 | LoadDLLfunc (GetTcpTable, iphlpapi) | |
463 | LoadDLLfunc (GetTcp6Table, iphlpapi) | |
464 | LoadDLLfunc (GetUdpTable, iphlpapi) | |
77680cac | 465 | |
013de6b0 | 466 | LoadDLLfuncEx2 (DiscardVirtualMemory, kernel32, 1, 127) |
77680cac CV |
467 | LoadDLLfuncEx (ClosePseudoConsole, kernel32, 1) |
468 | LoadDLLfuncEx (CreatePseudoConsole, kernel32, 1) | |
469 | LoadDLLfuncEx (IsWow64Process2, kernel32, 1) | |
470 | LoadDLLfuncEx (ResizePseudoConsole, kernel32, 1) | |
92626feb | 471 | |
c05df027 CV |
472 | /* MSDN claims these are exported by kernel32.dll, but only |
473 | QueryUnbiasedInterruptTime actually is. The others are only | |
474 | available via KernelBase.dll. */ | |
77680cac CV |
475 | LoadDLLfunc (QueryInterruptTime, KernelBase) |
476 | LoadDLLfunc (QueryInterruptTimePrecise, KernelBase) | |
477 | LoadDLLfunc (QueryUnbiasedInterruptTimePrecise, KernelBase) | |
478 | LoadDLLfuncEx (SetThreadDescription, KernelBase, 1) | |
479 | LoadDLLfunc (VirtualAlloc2, KernelBase) | |
480 | ||
481 | LoadDLLfunc (NtMapViewOfSectionEx, ntdll) | |
f6b56abe | 482 | LoadDLLfuncEx (RtlSetProcessPlaceholderCompatibilityMode, ntdll, 1) |
77680cac CV |
483 | |
484 | LoadDLLfunc (ldap_bind_s, wldap32) | |
485 | LoadDLLfunc (ldap_count_entries, wldap32) | |
486 | LoadDLLfunc (ldap_count_valuesW, wldap32) | |
487 | LoadDLLfunc (ldap_first_entry, wldap32) | |
488 | LoadDLLfunc (ldap_get_next_page_s, wldap32) | |
489 | LoadDLLfunc (ldap_get_valuesW, wldap32) | |
490 | LoadDLLfunc (ldap_get_values_lenW, wldap32) | |
491 | LoadDLLfunc (ldap_initW, wldap32) | |
492 | LoadDLLfunc (ldap_msgfree, wldap32) | |
493 | LoadDLLfunc (ldap_next_entry, wldap32) | |
494 | LoadDLLfunc (ldap_search_abandon_page, wldap32) | |
495 | LoadDLLfunc (ldap_search_init_pageW, wldap32) | |
496 | LoadDLLfunc (ldap_search_sW, wldap32) | |
497 | LoadDLLfunc (ldap_set_option, wldap32) | |
498 | LoadDLLfunc (ldap_sslinitW, wldap32) | |
499 | LoadDLLfunc (ldap_unbind, wldap32) | |
500 | LoadDLLfunc (ldap_value_freeW, wldap32) | |
501 | LoadDLLfunc (ldap_value_free_len, wldap32) | |
502 | LoadDLLfunc (LdapGetLastError, wldap32) | |
503 | LoadDLLfunc (LdapMapErrorToWin32, wldap32) | |
504 | ||
7db1c6fc CV |
505 | LoadDLLfunc (WNetCloseEnum, mpr) |
506 | LoadDLLfunc (WNetEnumResourceW, mpr) | |
507 | LoadDLLfunc (WNetGetProviderNameW, mpr) | |
508 | LoadDLLfunc (WNetGetResourceInformationW, mpr) | |
509 | LoadDLLfunc (WNetOpenEnumW, mpr) | |
510 | ||
77680cac CV |
511 | LoadDLLfunc (DsEnumerateDomainTrustsW, netapi32) |
512 | LoadDLLfunc (DsGetDcNameW, netapi32) | |
513 | LoadDLLfunc (NetApiBufferFree, netapi32) | |
514 | LoadDLLfunc (NetGroupEnum, netapi32) | |
515 | LoadDLLfunc (NetLocalGroupEnum, netapi32) | |
516 | LoadDLLfunc (NetLocalGroupGetInfo, netapi32) | |
517 | LoadDLLfunc (NetUseGetInfo, netapi32) | |
518 | LoadDLLfunc (NetUserEnum, netapi32) | |
519 | LoadDLLfunc (NetUserGetGroups, netapi32) | |
520 | LoadDLLfunc (NetUserGetInfo, netapi32) | |
521 | LoadDLLfunc (NetUserGetLocalGroups, netapi32) | |
522 | ||
205190a8 CV |
523 | LoadDLLfunc (CoInitialize, ole32) |
524 | LoadDLLfunc (CoUninitialize, ole32) | |
77680cac CV |
525 | LoadDLLfunc (CoTaskMemFree, ole32) |
526 | ||
527 | LoadDLLfunc (LsaConnectUntrusted, secur32) | |
528 | LoadDLLfunc (LsaDeregisterLogonProcess, secur32) | |
529 | LoadDLLfunc (LsaFreeReturnBuffer, secur32) | |
530 | LoadDLLfunc (LsaLogonUser, secur32) | |
531 | LoadDLLfunc (LsaLookupAuthenticationPackage, secur32) | |
532 | LoadDLLfunc (LsaRegisterLogonProcess, secur32) | |
533 | LoadDLLfunc (TranslateNameW, secur32) | |
534 | ||
205190a8 | 535 | LoadDLLfunc (SHCreateItemFromParsingName, shell32) |
77680cac | 536 | LoadDLLfunc (SHGetDesktopFolder, shell32) |
205190a8 | 537 | LoadDLLfunc (SHGetKnownFolderItem, shell32) |
77680cac CV |
538 | |
539 | LoadDLLfunc (CreateFontW, gdi32) | |
540 | LoadDLLfunc (DeleteObject, gdi32) | |
541 | LoadDLLfunc (EnumFontFamiliesExW, gdi32) | |
542 | LoadDLLfunc (GetGlyphIndicesW, gdi32) | |
543 | LoadDLLfunc (SelectObject, gdi32) | |
544 | ||
545 | LoadDLLfunc (CloseClipboard, user32) | |
546 | LoadDLLfunc (CloseDesktop, user32) | |
547 | LoadDLLfunc (CloseWindowStation, user32) | |
548 | LoadDLLfunc (CreateDesktopW, user32) | |
549 | LoadDLLfunc (CreateWindowExW, user32) | |
550 | LoadDLLfunc (CreateWindowStationW, user32) | |
551 | LoadDLLfunc (DefWindowProcW, user32) | |
552 | LoadDLLfunc (DestroyWindow, user32) | |
553 | LoadDLLfunc (DispatchMessageW, user32) | |
554 | LoadDLLfunc (EmptyClipboard, user32) | |
8aad3a7e | 555 | LoadDLLfunc (EnumChildWindows, user32) |
77680cac | 556 | LoadDLLfunc (EnumWindows, user32) |
8aad3a7e | 557 | LoadDLLfunc (GetClassNameA, user32) |
77680cac CV |
558 | LoadDLLfunc (GetClipboardData, user32) |
559 | LoadDLLfunc (GetDC, user32) | |
560 | LoadDLLfunc (GetForegroundWindow, user32) | |
561 | LoadDLLfunc (GetKeyboardLayout, user32) | |
562 | LoadDLLfunc (GetMessageW, user32) | |
563 | LoadDLLfunc (GetPriorityClipboardFormat, user32) | |
564 | LoadDLLfunc (GetProcessWindowStation, user32) | |
565 | LoadDLLfunc (GetThreadDesktop, user32) | |
566 | LoadDLLfunc (GetUserObjectInformationW, user32) | |
567 | LoadDLLfunc (GetWindowThreadProcessId, user32) | |
568 | LoadDLLfunc (MessageBeep, user32) | |
569 | LoadDLLfunc (MessageBoxW, user32) | |
570 | LoadDLLfunc (MsgWaitForMultipleObjectsEx, user32) | |
571 | LoadDLLfunc (OpenClipboard, user32) | |
572 | LoadDLLfunc (PeekMessageW, user32) | |
573 | LoadDLLfunc (PostMessageW, user32) | |
574 | LoadDLLfunc (PostQuitMessage, user32) | |
575 | LoadDLLfunc (RegisterClassW, user32) | |
576 | LoadDLLfunc (RegisterClipboardFormatW, user32) | |
577 | LoadDLLfunc (SendNotifyMessageW, user32) | |
578 | LoadDLLfunc (SetClipboardData, user32) | |
579 | LoadDLLfunc (SetParent, user32) | |
580 | LoadDLLfunc (SetProcessWindowStation, user32) | |
581 | LoadDLLfunc (SetThreadDesktop, user32) | |
582 | LoadDLLfunc (UnregisterClassW, user32) | |
583 | ||
584 | LoadDLLfuncEx (CreateEnvironmentBlock, userenv, 1) | |
585 | LoadDLLfuncEx2 (CreateProfile, userenv, 1, 1) | |
586 | LoadDLLfunc (DestroyEnvironmentBlock, userenv) | |
587 | LoadDLLfunc (LoadUserProfileW, userenv) | |
588 | ||
589 | LoadDLLfuncEx3 (waveInAddBuffer, winmm, 1, 0, 1) | |
590 | LoadDLLfuncEx3 (waveInClose, winmm, 1, 0, 1) | |
591 | LoadDLLfuncEx3 (waveInGetNumDevs, winmm, 1, 0, 1) | |
592 | LoadDLLfuncEx3 (waveInOpen, winmm, 1, 0, 1) | |
593 | LoadDLLfuncEx3 (waveInPrepareHeader, winmm, 1, 0, 1) | |
594 | LoadDLLfuncEx3 (waveInReset, winmm, 1, 0, 1) | |
595 | LoadDLLfuncEx3 (waveInStart, winmm, 1, 0, 1) | |
596 | LoadDLLfuncEx3 (waveInUnprepareHeader, winmm, 1, 0, 1) | |
597 | LoadDLLfuncEx3 (waveOutClose, winmm, 1, 0, 1) | |
598 | LoadDLLfuncEx3 (waveOutGetNumDevs, winmm, 1, 0, 1) | |
599 | LoadDLLfuncEx3 (waveOutGetVolume, winmm, 1, 0, 1) | |
600 | LoadDLLfuncEx3 (waveOutOpen, winmm, 1, 0, 1) | |
601 | LoadDLLfuncEx3 (waveOutPrepareHeader, winmm, 1, 0, 1) | |
602 | LoadDLLfuncEx3 (waveOutReset, winmm, 1, 0, 1) | |
603 | LoadDLLfuncEx3 (waveOutSetVolume, winmm, 1, 0, 1) | |
604 | LoadDLLfuncEx3 (waveOutUnprepareHeader, winmm, 1, 0, 1) | |
605 | LoadDLLfuncEx3 (waveOutWrite, winmm, 1, 0, 1) | |
abfa508e TY |
606 | LoadDLLfuncEx3 (waveOutMessage, winmm, 1, 0, 1) |
607 | LoadDLLfuncEx3 (waveOutGetDevCapsA, winmm, 1, 0, 1) | |
77680cac CV |
608 | |
609 | LoadDLLfunc (accept, ws2_32) | |
610 | LoadDLLfunc (bind, ws2_32) | |
611 | LoadDLLfunc (closesocket, ws2_32) | |
612 | LoadDLLfunc (connect, ws2_32) | |
613 | LoadDLLfunc (FreeAddrInfoW, ws2_32) | |
614 | LoadDLLfunc (GetAddrInfoW, ws2_32) | |
615 | LoadDLLfunc (GetNameInfoW, ws2_32) | |
616 | LoadDLLfunc (gethostbyaddr, ws2_32) | |
617 | LoadDLLfunc (gethostbyname, ws2_32) | |
618 | LoadDLLfunc (gethostname, ws2_32) | |
619 | LoadDLLfunc (getpeername, ws2_32) | |
620 | LoadDLLfunc (getprotobyname, ws2_32) | |
621 | LoadDLLfunc (getprotobynumber, ws2_32) | |
622 | LoadDLLfunc (getservbyname, ws2_32) | |
623 | LoadDLLfunc (getservbyport, ws2_32) | |
624 | LoadDLLfunc (getsockname, ws2_32) | |
625 | LoadDLLfunc (getsockopt, ws2_32) | |
626 | LoadDLLfunc (ioctlsocket, ws2_32) | |
627 | LoadDLLfunc (listen, ws2_32) | |
628 | LoadDLLfunc (setsockopt, ws2_32) | |
629 | LoadDLLfunc (shutdown, ws2_32) | |
630 | LoadDLLfunc (socket, ws2_32) | |
631 | LoadDLLfunc (WSAAsyncSelect, ws2_32) | |
632 | LoadDLLfunc (WSADuplicateSocketW, ws2_32) | |
633 | LoadDLLfunc (WSAEnumNetworkEvents, ws2_32) | |
634 | LoadDLLfunc (WSAEventSelect, ws2_32) | |
635 | LoadDLLfunc (WSAGetLastError, ws2_32) | |
636 | LoadDLLfunc (WSAIoctl, ws2_32) | |
7db1c6fc | 637 | LoadDLLfunc (WSAPoll, ws2_32) |
77680cac CV |
638 | LoadDLLfunc (WSARecv, ws2_32) |
639 | LoadDLLfunc (WSARecvFrom, ws2_32) | |
640 | LoadDLLfunc (WSASendMsg, ws2_32) | |
641 | LoadDLLfunc (WSASendTo, ws2_32) | |
642 | LoadDLLfunc (WSASetLastError, ws2_32) | |
643 | LoadDLLfunc (WSASocketW, ws2_32) | |
644 | // LoadDLLfunc (WSAStartup, ws2_32) | |
645 | LoadDLLfunc (WSAWaitForMultipleEvents, ws2_32) | |
646 | ||
647 | LoadDLLfunc (PdhAddEnglishCounterW, pdh) | |
648 | LoadDLLfunc (PdhCollectQueryData, pdh) | |
649 | LoadDLLfunc (PdhGetFormattedCounterValue, pdh) | |
650 | LoadDLLfunc (PdhOpenQueryW, pdh) | |
a5cc215f | 651 | } |