Cygwin: (mostly) drop NT4 and Samba < 3.0 support
[newlib-cygwin.git] / winsup / cygwin / autoload.cc
blobcc9dafe1b62173c9d00117d84491633b2b10d63a
1 /* autoload.cc: all dynamic load stuff.
3 This file is part of Cygwin.
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. */
9 #include "winsup.h"
10 #include "miscfuncs.h"
11 #include <fenv.h>
12 #define USE_SYS_TYPES_FD_SET
13 #include <winsock2.h>
15 bool NO_COPY wsock_started;
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.
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.
30 * So, immediately following the the call to one of the above routines
31 * we have:
32 * DLL info (4/8 bytes) Pointer to a block of information concerning
33 * the DLL (see below).
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.
40 * func addr (8 bytes) Address of the actual Win32 function. For the
41 * reason why this is necessary, see the below
42 * description of the load_state.
43 * func name (n bytes) asciz string containing the name of the function
44 * to be loaded.
46 * The DLL info block consists of the following
47 * load_state (4/8 bytes) Pointer to a word containing the routine used
48 * to eventually invoke the function. Initially
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.
53 * On x86_64, the jmp is not tweaked directly. Rather,
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.
61 * DLL locker (4 bytes) Word to use to avoid multi-thread access during
62 * initialization.
63 * extra init (4/8 bytes) Extra initialization function.
64 * DLL name (n bytes) asciz string containing the name of the DLL.
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. */
70 #ifdef __x86_64__
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 ");
86 #else
87 #error unimplemented for this target
88 #endif
90 /* Standard DLL load macro. May invoke a fatal error if the function isn't
91 found. */
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)
99 /* Main DLL setup stuff. */
100 #ifdef __x86_64__
101 #define LoadDLLfuncEx3(name, dllname, notimp, err, no_resolve_on_fork) \
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\
120 .hword " #notimp " \n\
121 .hword ((" #err ") & 0xffff) \n\
122 3:.quad 1b \n\
123 .asciz \"" #name "\" \n\
124 .text \n\
126 #else
127 #error unimplemented for this target
128 #endif
130 /* DLL loader helper functions used during initialization. */
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");
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");
142 extern "C" {
144 #ifdef __x86_64__
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\
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\
158 sarl $16,%eax # swap to low order word \n\
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\
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\
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\
191 pop %r10 # Pointer to 'return address' \n\
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\
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\
206 #else
207 #error unimplemented for this target
208 #endif
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
215 UINT_PTR load_state;
216 HANDLE handle;
217 LONG here;
218 void (*init) ();
219 WCHAR name[];
222 struct func_info
224 struct dll_info *dll;
225 LONG decoration;
226 UINT_PTR func_addr;
227 char name[];
230 /* Mechanism for setting up info for passing to dll_chain routines. */
231 typedef __uint128_t two_addr_t;
232 union retchain
234 struct {uintptr_t high; uintptr_t low;};
235 two_addr_t ll;
238 /* This function handles the problem described here:
240 http://www.microsoft.com/technet/security/advisory/2269637.mspx
241 https://msdn.microsoft.com/library/ff919712 */
242 static __inline bool
243 dll_load (HANDLE& handle, PWCHAR name)
245 HANDLE h = NULL;
246 WCHAR dll_path[MAX_PATH];
248 /* Try loading with full path, which sometimes fails for no good reason. */
249 wcpcpy (wcpcpy (dll_path, windows_system_directory), name);
250 h = LoadLibraryW (dll_path);
251 /* If it failed, try loading just by name. */
252 if (!h)
253 h = LoadLibraryW (name);
254 if (!h)
255 return false;
256 handle = h;
257 return true;
260 #define RETRY_COUNT 10
262 /* The standard DLL initialization routine. */
263 #ifdef __x86_64__
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. */
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\
301 INIT_WRAPPER (std_dll_init)
303 #else
304 #error unimplemented for this target
305 #endif
307 __attribute__ ((used, noinline)) static two_addr_t
308 std_dll_init (struct func_info *func)
310 struct dll_info *dll = func->dll;
311 retchain ret;
313 if (InterlockedIncrement (&dll->here))
316 InterlockedDecrement (&dll->here);
317 yield ();
319 while (InterlockedIncrement (&dll->here));
320 else if ((uintptr_t) dll->handle <= 1)
322 fenv_t fpuenv;
323 fegetenv (&fpuenv);
324 DWORD err = ERROR_SUCCESS;
325 int i;
326 /* MSDN seems to imply that LoadLibrary can fail mysteriously, so,
327 since there have been reports of this in the mailing list, retry
328 several times before giving up. */
329 for (i = 1; i <= RETRY_COUNT; i++)
331 /* If loading the library succeeds, just leave the loop. */
332 if (dll_load (dll->handle, dll->name))
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 ();
343 if ((uintptr_t) dll->handle <= 1)
345 if ((func->decoration & 1))
346 dll->handle = INVALID_HANDLE_VALUE;
347 else
348 api_fatal ("unable to load %W, %E", dll->name);
350 fesetenv (&fpuenv);
353 /* Set "arguments" for dll_chain. */
354 ret.low = (uintptr_t) dll->init;
355 ret.high = (uintptr_t) func;
357 InterlockedDecrement (&dll->here);
358 return ret.ll;
361 /* Initialization function for winsock stuff. */
363 #ifdef __x86_64__
364 /* See above comment preceeding std_dll_init. */
365 INIT_WRAPPER (wsock_init)
366 #else
367 #error unimplemented for this target
368 #endif
370 __attribute__ ((used, noinline)) static two_addr_t
371 wsock_init (struct func_info *func)
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;
377 static LONG NO_COPY here = -1L;
378 struct dll_info *dll = func->dll;
380 while (InterlockedIncrement (&here))
382 InterlockedDecrement (&here);
383 yield ();
386 if (!wsock_started)
388 int (*wsastartup) (int, WSADATA *);
390 /* Don't use autoload to load WSAStartup to eliminate recursion. */
391 wsastartup = (int (*)(int, WSADATA *))
392 GetProcAddress ((HMODULE) (dll->handle), "WSAStartup");
393 if (wsastartup)
395 int res = wsastartup (MAKEWORD (2, 2), &wsadata);
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);
405 wsock_started = 1;
408 InterlockedDecrement (&here);
409 volatile retchain ret;
410 /* Set "arguments for dll_chain. */
411 ret.low = (uintptr_t) dll_func_load;
412 ret.high = (uintptr_t) func;
413 return ret.ll;
416 LoadDLLprime (ws2_32, _wsock_init, 0)
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" */
448 LoadDLLfunc (AuthzAccessCheck, authz)
449 LoadDLLfunc (AuthzFreeContext, authz)
450 LoadDLLfunc (AuthzInitializeContextFromSid, authz)
451 LoadDLLfunc (AuthzInitializeContextFromToken, authz)
452 LoadDLLfunc (AuthzInitializeResourceManager, authz)
454 LoadDLLfunc (DnsQuery_A, dnsapi)
455 LoadDLLfunc (DnsFree, dnsapi)
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)
466 LoadDLLfuncEx2 (DiscardVirtualMemory, kernel32, 1, 127)
467 LoadDLLfuncEx (ClosePseudoConsole, kernel32, 1)
468 LoadDLLfuncEx (CreatePseudoConsole, kernel32, 1)
469 LoadDLLfuncEx (IsWow64Process2, kernel32, 1)
470 LoadDLLfuncEx (ResizePseudoConsole, kernel32, 1)
472 /* MSDN claims these are exported by kernel32.dll, but only
473 QueryUnbiasedInterruptTime actually is. The others are only
474 available via KernelBase.dll. */
475 LoadDLLfunc (QueryInterruptTime, KernelBase)
476 LoadDLLfunc (QueryInterruptTimePrecise, KernelBase)
477 LoadDLLfunc (QueryUnbiasedInterruptTimePrecise, KernelBase)
478 LoadDLLfuncEx (SetThreadDescription, KernelBase, 1)
479 LoadDLLfunc (VirtualAlloc2, KernelBase)
481 LoadDLLfunc (NtMapViewOfSectionEx, ntdll)
482 LoadDLLfuncEx (RtlSetProcessPlaceholderCompatibilityMode, ntdll, 1)
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)
505 LoadDLLfunc (WNetCloseEnum, mpr)
506 LoadDLLfunc (WNetEnumResourceW, mpr)
507 LoadDLLfunc (WNetGetLastErrorW, mpr)
508 LoadDLLfunc (WNetGetProviderNameW, mpr)
509 LoadDLLfunc (WNetGetResourceInformationW, mpr)
510 LoadDLLfunc (WNetOpenEnumW, mpr)
512 LoadDLLfunc (DsEnumerateDomainTrustsW, netapi32)
513 LoadDLLfunc (DsGetDcNameW, netapi32)
514 LoadDLLfunc (NetApiBufferFree, netapi32)
515 LoadDLLfunc (NetGroupEnum, netapi32)
516 LoadDLLfunc (NetLocalGroupEnum, netapi32)
517 LoadDLLfunc (NetLocalGroupGetInfo, netapi32)
518 LoadDLLfunc (NetUseGetInfo, netapi32)
519 LoadDLLfunc (NetUserEnum, netapi32)
520 LoadDLLfunc (NetUserGetGroups, netapi32)
521 LoadDLLfunc (NetUserGetInfo, netapi32)
522 LoadDLLfunc (NetUserGetLocalGroups, netapi32)
524 LoadDLLfunc (CoTaskMemFree, ole32)
526 LoadDLLfunc (LsaConnectUntrusted, secur32)
527 LoadDLLfunc (LsaDeregisterLogonProcess, secur32)
528 LoadDLLfunc (LsaFreeReturnBuffer, secur32)
529 LoadDLLfunc (LsaLogonUser, secur32)
530 LoadDLLfunc (LsaLookupAuthenticationPackage, secur32)
531 LoadDLLfunc (LsaRegisterLogonProcess, secur32)
532 LoadDLLfunc (TranslateNameW, secur32)
534 LoadDLLfunc (SHGetDesktopFolder, shell32)
536 LoadDLLfunc (CreateFontW, gdi32)
537 LoadDLLfunc (DeleteObject, gdi32)
538 LoadDLLfunc (EnumFontFamiliesExW, gdi32)
539 LoadDLLfunc (GetGlyphIndicesW, gdi32)
540 LoadDLLfunc (SelectObject, gdi32)
542 LoadDLLfunc (CloseClipboard, user32)
543 LoadDLLfunc (CloseDesktop, user32)
544 LoadDLLfunc (CloseWindowStation, user32)
545 LoadDLLfunc (CreateDesktopW, user32)
546 LoadDLLfunc (CreateWindowExW, user32)
547 LoadDLLfunc (CreateWindowStationW, user32)
548 LoadDLLfunc (DefWindowProcW, user32)
549 LoadDLLfunc (DestroyWindow, user32)
550 LoadDLLfunc (DispatchMessageW, user32)
551 LoadDLLfunc (EmptyClipboard, user32)
552 LoadDLLfunc (EnumChildWindows, user32)
553 LoadDLLfunc (EnumWindows, user32)
554 LoadDLLfunc (GetClassNameA, user32)
555 LoadDLLfunc (GetClipboardData, user32)
556 LoadDLLfunc (GetDC, user32)
557 LoadDLLfunc (GetForegroundWindow, user32)
558 LoadDLLfunc (GetKeyboardLayout, user32)
559 LoadDLLfunc (GetMessageW, user32)
560 LoadDLLfunc (GetPriorityClipboardFormat, user32)
561 LoadDLLfunc (GetProcessWindowStation, user32)
562 LoadDLLfunc (GetThreadDesktop, user32)
563 LoadDLLfunc (GetUserObjectInformationW, user32)
564 LoadDLLfunc (GetWindowThreadProcessId, user32)
565 LoadDLLfunc (MessageBeep, user32)
566 LoadDLLfunc (MessageBoxW, user32)
567 LoadDLLfunc (MsgWaitForMultipleObjectsEx, user32)
568 LoadDLLfunc (OpenClipboard, user32)
569 LoadDLLfunc (PeekMessageW, user32)
570 LoadDLLfunc (PostMessageW, user32)
571 LoadDLLfunc (PostQuitMessage, user32)
572 LoadDLLfunc (RegisterClassW, user32)
573 LoadDLLfunc (RegisterClipboardFormatW, user32)
574 LoadDLLfunc (SendNotifyMessageW, user32)
575 LoadDLLfunc (SetClipboardData, user32)
576 LoadDLLfunc (SetParent, user32)
577 LoadDLLfunc (SetProcessWindowStation, user32)
578 LoadDLLfunc (SetThreadDesktop, user32)
579 LoadDLLfunc (UnregisterClassW, user32)
581 LoadDLLfuncEx (CreateEnvironmentBlock, userenv, 1)
582 LoadDLLfuncEx2 (CreateProfile, userenv, 1, 1)
583 LoadDLLfunc (DestroyEnvironmentBlock, userenv)
584 LoadDLLfunc (LoadUserProfileW, userenv)
586 LoadDLLfuncEx3 (waveInAddBuffer, winmm, 1, 0, 1)
587 LoadDLLfuncEx3 (waveInClose, winmm, 1, 0, 1)
588 LoadDLLfuncEx3 (waveInGetNumDevs, winmm, 1, 0, 1)
589 LoadDLLfuncEx3 (waveInOpen, winmm, 1, 0, 1)
590 LoadDLLfuncEx3 (waveInPrepareHeader, winmm, 1, 0, 1)
591 LoadDLLfuncEx3 (waveInReset, winmm, 1, 0, 1)
592 LoadDLLfuncEx3 (waveInStart, winmm, 1, 0, 1)
593 LoadDLLfuncEx3 (waveInUnprepareHeader, winmm, 1, 0, 1)
594 LoadDLLfuncEx3 (waveOutClose, winmm, 1, 0, 1)
595 LoadDLLfuncEx3 (waveOutGetNumDevs, winmm, 1, 0, 1)
596 LoadDLLfuncEx3 (waveOutGetVolume, winmm, 1, 0, 1)
597 LoadDLLfuncEx3 (waveOutOpen, winmm, 1, 0, 1)
598 LoadDLLfuncEx3 (waveOutPrepareHeader, winmm, 1, 0, 1)
599 LoadDLLfuncEx3 (waveOutReset, winmm, 1, 0, 1)
600 LoadDLLfuncEx3 (waveOutSetVolume, winmm, 1, 0, 1)
601 LoadDLLfuncEx3 (waveOutUnprepareHeader, winmm, 1, 0, 1)
602 LoadDLLfuncEx3 (waveOutWrite, winmm, 1, 0, 1)
604 LoadDLLfunc (accept, ws2_32)
605 LoadDLLfunc (bind, ws2_32)
606 LoadDLLfunc (closesocket, ws2_32)
607 LoadDLLfunc (connect, ws2_32)
608 LoadDLLfunc (FreeAddrInfoW, ws2_32)
609 LoadDLLfunc (GetAddrInfoW, ws2_32)
610 LoadDLLfunc (GetNameInfoW, ws2_32)
611 LoadDLLfunc (gethostbyaddr, ws2_32)
612 LoadDLLfunc (gethostbyname, ws2_32)
613 LoadDLLfunc (gethostname, ws2_32)
614 LoadDLLfunc (getpeername, ws2_32)
615 LoadDLLfunc (getprotobyname, ws2_32)
616 LoadDLLfunc (getprotobynumber, ws2_32)
617 LoadDLLfunc (getservbyname, ws2_32)
618 LoadDLLfunc (getservbyport, ws2_32)
619 LoadDLLfunc (getsockname, ws2_32)
620 LoadDLLfunc (getsockopt, ws2_32)
621 LoadDLLfunc (ioctlsocket, ws2_32)
622 LoadDLLfunc (listen, ws2_32)
623 LoadDLLfunc (setsockopt, ws2_32)
624 LoadDLLfunc (shutdown, ws2_32)
625 LoadDLLfunc (socket, ws2_32)
626 LoadDLLfunc (WSAAsyncSelect, ws2_32)
627 LoadDLLfunc (WSADuplicateSocketW, ws2_32)
628 LoadDLLfunc (WSAEnumNetworkEvents, ws2_32)
629 LoadDLLfunc (WSAEventSelect, ws2_32)
630 LoadDLLfunc (WSAGetLastError, ws2_32)
631 LoadDLLfunc (WSAIoctl, ws2_32)
632 LoadDLLfunc (WSARecv, ws2_32)
633 LoadDLLfunc (WSARecvFrom, ws2_32)
634 LoadDLLfunc (WSASendMsg, ws2_32)
635 LoadDLLfunc (WSASendTo, ws2_32)
636 LoadDLLfunc (WSASetLastError, ws2_32)
637 LoadDLLfunc (WSASocketW, ws2_32)
638 // LoadDLLfunc (WSAStartup, ws2_32)
639 LoadDLLfunc (WSAWaitForMultipleEvents, ws2_32)
641 LoadDLLfunc (PdhAddEnglishCounterW, pdh)
642 LoadDLLfunc (PdhCollectQueryData, pdh)
643 LoadDLLfunc (PdhGetFormattedCounterValue, pdh)
644 LoadDLLfunc (PdhOpenQueryW, pdh)