ReactOS 0.4.15-dev-7958-gcd0bb1a
module.c
Go to the documentation of this file.
1/*
2 * Unit tests for module/DLL/library API
3 *
4 * Copyright (c) 2004 Eric Pouech
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include "wine/test.h"
22#include <windows.h>
23#include <stdio.h>
24#include <psapi.h>
25
26static DWORD (WINAPI *pGetDllDirectoryA)(DWORD,LPSTR);
27static DWORD (WINAPI *pGetDllDirectoryW)(DWORD,LPWSTR);
28static BOOL (WINAPI *pSetDllDirectoryA)(LPCSTR);
29static DLL_DIRECTORY_COOKIE (WINAPI *pAddDllDirectory)(const WCHAR*);
30static BOOL (WINAPI *pRemoveDllDirectory)(DLL_DIRECTORY_COOKIE);
31static BOOL (WINAPI *pSetDefaultDllDirectories)(DWORD);
32static BOOL (WINAPI *pK32GetModuleInformation)(HANDLE process, HMODULE module,
34
36
37static BOOL cmpStrAW(const char* a, const WCHAR* b, DWORD lenA, DWORD lenB)
38{
39 WCHAR aw[1024];
40
42 a, lenA, aw, sizeof(aw) / sizeof(aw[0]) );
43 if (len != lenB) return FALSE;
44 return memcmp(aw, b, len * sizeof(WCHAR)) == 0;
45}
46
47static const struct
48{
52} dll_image =
53{
54 { IMAGE_DOS_SIGNATURE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 }, 0, 0, { 0 },
55 sizeof(IMAGE_DOS_HEADER) },
56 {
57 IMAGE_NT_SIGNATURE, /* Signature */
58 {
59#if defined __i386__
60 IMAGE_FILE_MACHINE_I386, /* Machine */
61#elif defined __x86_64__
62 IMAGE_FILE_MACHINE_AMD64, /* Machine */
63#elif defined __powerpc__
64 IMAGE_FILE_MACHINE_POWERPC, /* Machine */
65#elif defined __arm__
66 IMAGE_FILE_MACHINE_ARMNT, /* Machine */
67#elif defined __aarch64__
68 IMAGE_FILE_MACHINE_ARM64, /* Machine */
69#else
70# error You must specify the machine type
71#endif
72 1, /* NumberOfSections */
73 0, /* TimeDateStamp */
74 0, /* PointerToSymbolTable */
75 0, /* NumberOfSymbols */
76 sizeof(IMAGE_OPTIONAL_HEADER), /* SizeOfOptionalHeader */
77 IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_DLL /* Characteristics */
78 },
79 { IMAGE_NT_OPTIONAL_HDR_MAGIC, /* Magic */
80 1, /* MajorLinkerVersion */
81 0, /* MinorLinkerVersion */
82 0, /* SizeOfCode */
83 0, /* SizeOfInitializedData */
84 0, /* SizeOfUninitializedData */
85 0, /* AddressOfEntryPoint */
86 0x1000, /* BaseOfCode */
87#ifndef _WIN64
88 0, /* BaseOfData */
89#endif
90 0x10000000, /* ImageBase */
91 0x1000, /* SectionAlignment */
92 0x1000, /* FileAlignment */
93 4, /* MajorOperatingSystemVersion */
94 0, /* MinorOperatingSystemVersion */
95 1, /* MajorImageVersion */
96 0, /* MinorImageVersion */
97 4, /* MajorSubsystemVersion */
98 0, /* MinorSubsystemVersion */
99 0, /* Win32VersionValue */
100 0x2000, /* SizeOfImage */
101 sizeof(IMAGE_DOS_HEADER) + sizeof(IMAGE_NT_HEADERS), /* SizeOfHeaders */
102 0, /* CheckSum */
103 IMAGE_SUBSYSTEM_WINDOWS_CUI, /* Subsystem */
104 0, /* DllCharacteristics */
105 0, /* SizeOfStackReserve */
106 0, /* SizeOfStackCommit */
107 0, /* SizeOfHeapReserve */
108 0, /* SizeOfHeapCommit */
109 0, /* LoaderFlags */
110 0, /* NumberOfRvaAndSizes */
111 { { 0 } } /* DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] */
112 }
113 },
114 { ".rodata", { 0 }, 0x1000, 0x1000, 0, 0, 0, 0, 0,
117
118static void create_test_dll( const char *name )
119{
120 DWORD dummy;
122
123 ok( handle != INVALID_HANDLE_VALUE, "failed to create file err %u\n", GetLastError() );
124 WriteFile( handle, &dll_image, sizeof(dll_image), &dummy, NULL );
125 SetFilePointer( handle, dll_image.nt.OptionalHeader.SizeOfImage, NULL, FILE_BEGIN );
128}
129
130static void testGetModuleFileName(const char* name)
131{
132 HMODULE hMod;
133 char bufA[MAX_PATH];
134 WCHAR bufW[MAX_PATH];
135 DWORD len1A, len1W = 0, len2A, len2W = 0;
136
137 hMod = (name) ? GetModuleHandleA(name) : NULL;
138
139 /* first test, with enough space in buffer */
140 memset(bufA, '-', sizeof(bufA));
141 SetLastError(0xdeadbeef);
142 len1A = GetModuleFileNameA(hMod, bufA, sizeof(bufA));
144 broken(GetLastError() == 0xdeadbeef), /* <= XP SP3 */
145 "LastError was not reset: %u\n", GetLastError());
146 ok(len1A > 0, "Getting module filename for handle %p\n", hMod);
147
149 {
150 memset(bufW, '-', sizeof(bufW));
151 SetLastError(0xdeadbeef);
152 len1W = GetModuleFileNameW(hMod, bufW, sizeof(bufW) / sizeof(WCHAR));
154 broken(GetLastError() == 0xdeadbeef), /* <= XP SP3 */
155 "LastError was not reset: %u\n", GetLastError());
156 ok(len1W > 0, "Getting module filename for handle %p\n", hMod);
157 }
158
159 ok(len1A == strlen(bufA), "Unexpected length of GetModuleFilenameA (%d/%d)\n", len1A, lstrlenA(bufA));
160
162 {
163 ok(len1W == lstrlenW(bufW), "Unexpected length of GetModuleFilenameW (%d/%d)\n", len1W, lstrlenW(bufW));
164 ok(cmpStrAW(bufA, bufW, len1A, len1W), "Comparing GetModuleFilenameAW results\n");
165 }
166
167 /* second test with a buffer too small */
168 memset(bufA, '-', sizeof(bufA));
169 len2A = GetModuleFileNameA(hMod, bufA, len1A / 2);
170 ok(len2A > 0, "Getting module filename for handle %p\n", hMod);
171
173 {
174 memset(bufW, '-', sizeof(bufW));
175 len2W = GetModuleFileNameW(hMod, bufW, len1W / 2);
176 ok(len2W > 0, "Getting module filename for handle %p\n", hMod);
177 ok(cmpStrAW(bufA, bufW, len2A, len2W), "Comparing GetModuleFilenameAW results with buffer too small\n" );
178 ok(len1W / 2 == len2W, "Correct length in GetModuleFilenameW with buffer too small (%d/%d)\n", len1W / 2, len2W);
179 }
180
181 ok(len1A / 2 == len2A,
182 "Correct length in GetModuleFilenameA with buffer too small (%d/%d)\n", len1A / 2, len2A);
183}
184
186{
187 char bufA[MAX_PATH];
188 WCHAR bufW[MAX_PATH];
189
190 /* test wrong handle */
192 {
193 bufW[0] = '*';
194 ok(GetModuleFileNameW((void*)0xffffffff, bufW, sizeof(bufW) / sizeof(WCHAR)) == 0, "Unexpected success in module handle\n");
195 ok(bufW[0] == '*', "When failing, buffer shouldn't be written to\n");
196 }
197
198 bufA[0] = '*';
199 ok(GetModuleFileNameA((void*)0xffffffff, bufA, sizeof(bufA)) == 0, "Unexpected success in module handle\n");
200 ok(bufA[0] == '*', "When failing, buffer shouldn't be written to\n");
201}
202
203static void testLoadLibraryA(void)
204{
205 HMODULE hModule, hModule1;
206 FARPROC fp;
207
208 SetLastError(0xdeadbeef);
209 hModule = LoadLibraryA("kernel32.dll");
210 ok( hModule != NULL, "kernel32.dll should be loadable\n");
211 ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %d\n", GetLastError());
212
213 fp = GetProcAddress(hModule, "CreateFileA");
214 ok( fp != NULL, "CreateFileA should be there\n");
215 ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %d\n", GetLastError());
216
217 SetLastError(0xdeadbeef);
218 hModule1 = LoadLibraryA("kernel32 ");
219 ok( hModule1 != NULL, "\"kernel32 \" should be loadable\n" );
220 ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %d\n", GetLastError() );
221 ok( hModule == hModule1, "Loaded wrong module\n" );
222 FreeLibrary(hModule1);
224}
225
226static void testNestedLoadLibraryA(void)
227{
228 static const char dllname[] = "shell32.dll";
230 HMODULE hModule1, hModule2, hModule3;
231
232 /* This is not really a Windows conformance test, but more a Wine
233 * regression test. Wine's builtin dlls can be loaded from multiple paths,
234 * and this test tries to make sure that Wine does not get confused and
235 * really unloads the Unix .so file at the right time. Failure to do so
236 * will result in the dll being unloadable.
237 * This test must be done with a dll that can be unloaded, which means:
238 * - it must not already be loaded
239 * - it must not have a 16-bit counterpart
240 */
242 strcat(path1, "\\system\\");
243 strcat(path1, dllname);
244 hModule1 = LoadLibraryA(path1);
245 if (!hModule1)
246 {
247 /* We must be on Windows, so we cannot test */
248 return;
249 }
250
252 strcat(path2, "\\system32\\");
253 strcat(path2, dllname);
254 hModule2 = LoadLibraryA(path2);
255 ok(hModule2 != NULL, "LoadLibrary(%s) failed\n", path2);
256
257 /* The first LoadLibrary() call may have registered the dll under the
258 * system32 path. So load it, again, under the '...\system\...' path so
259 * Wine does not immediately notice that it is already loaded.
260 */
261 hModule3 = LoadLibraryA(path1);
262 ok(hModule3 != NULL, "LoadLibrary(%s) failed\n", path1);
263
264 /* Now fully unload the dll */
265 ok(FreeLibrary(hModule3), "FreeLibrary() failed\n");
266 ok(FreeLibrary(hModule2), "FreeLibrary() failed\n");
267 ok(FreeLibrary(hModule1), "FreeLibrary() failed\n");
268 ok(GetModuleHandleA(dllname) == NULL, "%s was not fully unloaded\n", dllname);
269
270 /* Try to load the dll again, if refcounting is ok, this should work */
271 hModule1 = LoadLibraryA(path1);
272 ok(hModule1 != NULL, "LoadLibrary(%s) failed\n", path1);
273 if (hModule1 != NULL)
274 ok(FreeLibrary(hModule1), "FreeLibrary() failed\n");
275}
276
277static void testLoadLibraryA_Wrong(void)
278{
280
281 /* Try to load a nonexistent dll */
282 SetLastError(0xdeadbeef);
283 hModule = LoadLibraryA("non_ex_pv.dll");
284 ok( !hModule, "non_ex_pv.dll should be not loadable\n");
285 ok( GetLastError() == ERROR_MOD_NOT_FOUND, "Expected ERROR_MOD_NOT_FOUND, got %d\n", GetLastError() );
286
287 /* Just in case */
289}
290
292{
293 FARPROC fp;
294
295 SetLastError(0xdeadbeef);
296 fp = GetProcAddress(NULL, "non_ex_call");
297 ok( !fp, "non_ex_call should not be found\n");
298 ok( GetLastError() == ERROR_PROC_NOT_FOUND, "Expected ERROR_PROC_NOT_FOUND, got %d\n", GetLastError() );
299
300 SetLastError(0xdeadbeef);
301 fp = GetProcAddress((HMODULE)0xdeadbeef, "non_ex_call");
302 ok( !fp, "non_ex_call should not be found\n");
303 ok( GetLastError() == ERROR_MOD_NOT_FOUND, "Expected ERROR_MOD_NOT_FOUND, got %d\n", GetLastError() );
304}
305
306static void testLoadLibraryEx(void)
307{
310 HANDLE hfile;
311 BOOL ret;
312
313 hfile = CreateFileA("testfile.dll", GENERIC_READ | GENERIC_WRITE,
316 ok(hfile != INVALID_HANDLE_VALUE, "Expected a valid file handle\n");
317
318 /* NULL lpFileName */
319 SetLastError(0xdeadbeef);
321 ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
324 "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
325
326 /* empty lpFileName */
327 SetLastError(0xdeadbeef);
328 hmodule = LoadLibraryExA("", NULL, 0);
329 ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
332 "Expected ERROR_MOD_NOT_FOUND or ERROR_DLL_NOT_FOUND, got %d\n", GetLastError());
333
334 /* hFile is non-NULL */
335 SetLastError(0xdeadbeef);
336 hmodule = LoadLibraryExA("testfile.dll", hfile, 0);
337 ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
339 {
341 GetLastError() == ERROR_INVALID_PARAMETER, /* win2k3 */
342 "Unexpected last error, got %d\n", GetLastError());
343 }
344
345 SetLastError(0xdeadbeef);
346 hmodule = LoadLibraryExA("testfile.dll", (HANDLE)0xdeadbeef, 0);
347 ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
349 {
351 GetLastError() == ERROR_INVALID_PARAMETER, /* win2k3 */
352 "Unexpected last error, got %d\n", GetLastError());
353 }
354
355 /* try to open a file that is locked */
356 SetLastError(0xdeadbeef);
357 hmodule = LoadLibraryExA("testfile.dll", NULL, 0);
358 ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
360 {
362 "Expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
363 }
364
365 /* lpFileName does not matter */
367 {
368 SetLastError(0xdeadbeef);
369 hmodule = LoadLibraryExA(NULL, hfile, 0);
370 ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
372 GetLastError() == ERROR_INVALID_PARAMETER, /* win2k3 */
373 "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
374 }
375
376 CloseHandle(hfile);
377
378 /* load empty file */
379 SetLastError(0xdeadbeef);
381 ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
383 {
385 "Expected ERROR_FILE_INVALID, got %d\n", GetLastError());
386 }
387
388 DeleteFileA("testfile.dll");
389
391 if (path[lstrlenA(path) - 1] != '\\')
392 lstrcatA(path, "\\");
393 lstrcatA(path, "kernel32.dll");
394
395 /* load kernel32.dll with an absolute path */
396 SetLastError(0xdeadbeef);
398 ok(hmodule != 0, "Expected valid module handle\n");
399 ok(GetLastError() == 0xdeadbeef ||
401 "Expected 0xdeadbeef or ERROR_SUCCESS, got %d\n", GetLastError());
402
403 /* try invalid file handle */
404 SetLastError(0xdeadbeef);
405 hmodule = LoadLibraryExA(path, (HANDLE)0xdeadbeef, 0);
406 if (!hmodule) /* succeeds on xp and older */
407 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
408
410
411 /* load kernel32.dll with no path */
412 SetLastError(0xdeadbeef);
414 ok(hmodule != 0, "Expected valid module handle\n");
415 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
416
418
420 if (path[lstrlenA(path) - 1] != '\\')
421 lstrcatA(path, "\\");
422 lstrcatA(path, "kernel32.dll");
423
424 /* load kernel32.dll with an absolute path that does not exist */
425 SetLastError(0xdeadbeef);
428 {
429 ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
430 }
432 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
433
434 /* Free the loaded dll when it's the first time this dll is loaded
435 in process - First time should pass, second fail */
436 SetLastError(0xdeadbeef);
438 ok(hmodule != 0, "Expected valid module handle\n");
439
440 SetLastError(0xdeadbeef);
442 ok(ret, "Expected to be able to free the module, failed with %d\n", GetLastError());
443 SetLastError(0xdeadbeef);
445 ok(!ret, "Unexpected ability to free the module, failed with %d\n", GetLastError());
446
447 /* load with full path, name without extension */
449 if (path[lstrlenA(path) - 1] != '\\')
450 lstrcatA(path, "\\");
451 lstrcatA(path, "kernel32");
453 ok(hmodule != NULL, "got %p\n", hmodule);
455
456 /* same with alterate search path */
458 ok(hmodule != NULL, "got %p\n", hmodule);
460}
461
463{
464 static const struct
465 {
466 int add_dirs[4];
467 int dll_dir;
468 int expect;
469 } tests[] =
470 {
471 { { 1, 2, 3 }, 4, 3 }, /* 0 */
472 { { 1, 3, 2 }, 4, 2 },
473 { { 3, 1 }, 4, 1 },
474 { { 5, 6 }, 4, 4 },
475 { { 5, 2 }, 4, 2 },
476 { { 0 }, 4, 4 }, /* 5 */
477 { { 0 }, 0, 0 },
478 { { 6, 5 }, 5, 0 },
479 { { 1, 1, 2 }, 0, 2 },
480 };
481 char *p, path[MAX_PATH], buf[MAX_PATH];
482 WCHAR bufW[MAX_PATH];
484 unsigned int i, j, k;
485 BOOL ret;
486 HMODULE mod;
487
488 if (!pAddDllDirectory || !pSetDllDirectoryA) return;
489
490 GetTempPathA( sizeof(path), path );
491 GetTempFileNameA( path, "tmp", 0, buf );
492 DeleteFileA( buf );
494 ok( ret, "CreateDirectory failed err %u\n", GetLastError() );
495 p = buf + strlen( buf );
496 for (i = 1; i <= 6; i++)
497 {
498 sprintf( p, "\\%u", i );
500 ok( ret, "CreateDirectory failed err %u\n", GetLastError() );
501 if (i >= 5) continue; /* dirs 5 and 6 are left empty */
502 sprintf( p, "\\%u\\winetestdll.dll", i );
504 }
505 SetLastError( 0xdeadbeef );
506 mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
507 ok( !mod, "LoadLibrary succeeded\n" );
508 ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
509
510 SetLastError( 0xdeadbeef );
511 mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_USER_DIRS );
512 ok( !mod, "LoadLibrary succeeded\n" );
514 "wrong error %u\n", GetLastError() );
515
516 SetLastError( 0xdeadbeef );
517 mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
518 ok( !mod, "LoadLibrary succeeded\n" );
519 ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
520
521 SetLastError( 0xdeadbeef );
522 mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
523 ok( !mod, "LoadLibrary succeeded\n" );
524 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
525
526 SetLastError( 0xdeadbeef );
528 ok( !mod, "LoadLibrary succeeded\n" );
529 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
530
531 SetLastError( 0xdeadbeef );
532 mod = LoadLibraryExA( "foo\\winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
533 ok( !mod, "LoadLibrary succeeded\n" );
534 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
535
536 SetLastError( 0xdeadbeef );
537 mod = LoadLibraryExA( "\\windows\\winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
538 ok( !mod, "LoadLibrary succeeded\n" );
539 ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
540
541 for (j = 0; j < sizeof(tests) / sizeof(tests[0]); j++)
542 {
543 for (k = 0; tests[j].add_dirs[k]; k++)
544 {
545 sprintf( p, "\\%u", tests[j].add_dirs[k] );
546 MultiByteToWideChar( CP_ACP, 0, buf, -1, bufW, MAX_PATH );
547 cookies[k] = pAddDllDirectory( bufW );
548 ok( cookies[k] != NULL, "failed to add %s\n", buf );
549 }
550 if (tests[j].dll_dir)
551 {
552 sprintf( p, "\\%u", tests[j].dll_dir );
553 pSetDllDirectoryA( buf );
554 }
555 else pSetDllDirectoryA( NULL );
556
557 SetLastError( 0xdeadbeef );
558 mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_USER_DIRS );
559 if (tests[j].expect)
560 {
561 ok( mod != NULL, "%u: LoadLibrary failed err %u\n", j, GetLastError() );
563 sprintf( p, "\\%u\\winetestdll.dll", tests[j].expect );
564 ok( !lstrcmpiA( path, buf ), "%u: wrong module %s expected %s\n", j, path, buf );
565 }
566 else
567 {
568 ok( !mod, "%u: LoadLibrary succeeded\n", j );
570 "%u: wrong error %u\n", j, GetLastError() );
571 }
572 FreeLibrary( mod );
573
574 for (k = 0; tests[j].add_dirs[k]; k++) pRemoveDllDirectory( cookies[k] );
575 }
576
577 for (i = 1; i <= 6; i++)
578 {
579 sprintf( p, "\\%u\\winetestdll.dll", i );
580 DeleteFileA( buf );
581 sprintf( p, "\\%u", i );
583 }
584 *p = 0;
586}
587
588static void testGetDllDirectory(void)
589{
590 CHAR bufferA[MAX_PATH];
591 WCHAR bufferW[MAX_PATH];
593 int i;
594 static const char *dll_directories[] =
595 {
596 "",
597 "C:\\Some\\Path",
598 "C:\\Some\\Path\\",
599 "Q:\\A\\Long\\Path with spaces that\\probably\\doesn't exist!",
600 };
601 const int test_count = sizeof(dll_directories) / sizeof(dll_directories[0]);
602
603 if (!pGetDllDirectoryA || !pGetDllDirectoryW)
604 {
605 win_skip("GetDllDirectory not available\n");
606 return;
607 }
608 if (!pSetDllDirectoryA)
609 {
610 win_skip("SetDllDirectoryA not available\n");
611 return;
612 }
613
614 for (i = 0; i < test_count; i++)
615 {
616 length = strlen(dll_directories[i]);
617 if (!pSetDllDirectoryA(dll_directories[i]))
618 {
619 skip("i=%d, SetDllDirectoryA failed\n", i);
620 continue;
621 }
622
623 /* no buffer, determine length */
624 ret = pGetDllDirectoryA(0, NULL);
625 ok(ret == length + 1, "Expected %u, got %u\n", length + 1, ret);
626
627 ret = pGetDllDirectoryW(0, NULL);
628 ok(ret == length + 1, "Expected %u, got %u\n", length + 1, ret);
629
630 /* buffer of exactly the right size */
631 bufferA[length] = 'A';
632 bufferA[length + 1] = 'A';
633 ret = pGetDllDirectoryA(length + 1, bufferA);
634 ok(ret == length || broken(ret + 1 == length) /* win8 */,
635 "i=%d, Expected %u(+1), got %u\n", i, length, ret);
636 ok(bufferA[length + 1] == 'A', "i=%d, Buffer overflow\n", i);
637 ok(strcmp(bufferA, dll_directories[i]) == 0, "i=%d, Wrong path returned: '%s'\n", i, bufferA);
638
639 bufferW[length] = 'A';
640 bufferW[length + 1] = 'A';
641 ret = pGetDllDirectoryW(length + 1, bufferW);
642 ok(ret == length, "i=%d, Expected %u, got %u\n", i, length, ret);
643 ok(bufferW[length + 1] == 'A', "i=%d, Buffer overflow\n", i);
644 ok(cmpStrAW(dll_directories[i], bufferW, length, length),
645 "i=%d, Wrong path returned: %s\n", i, wine_dbgstr_w(bufferW));
646
647 /* Zero size buffer. The buffer may or may not be terminated depending
648 * on the Windows version and whether the A or W API is called. */
649 bufferA[0] = 'A';
650 ret = pGetDllDirectoryA(0, bufferA);
651 ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
652
653 bufferW[0] = 'A';
654 ret = pGetDllDirectoryW(0, bufferW);
655 ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
656 ok(bufferW[0] == 0 || /* XP, 2003 */
657 broken(bufferW[0] == 'A'), "i=%d, Buffer overflow\n", i);
658
659 /* buffer just one too short */
660 bufferA[0] = 'A';
661 ret = pGetDllDirectoryA(length, bufferA);
662 ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
663 if (length != 0)
664 ok(bufferA[0] == 0, "i=%d, Buffer not null terminated\n", i);
665
666 bufferW[0] = 'A';
667 ret = pGetDllDirectoryW(length, bufferW);
668 ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
669 ok(bufferW[0] == 0 || /* XP, 2003 */
670 broken(bufferW[0] == 'A'), "i=%d, Buffer overflow\n", i);
671
672 if (0)
673 {
674 /* crashes on win8 */
675 /* no buffer, but too short length */
676 ret = pGetDllDirectoryA(length, NULL);
677 ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
678
679 ret = pGetDllDirectoryW(length, NULL);
680 ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
681 }
682 }
683
684 /* unset whatever we did so following tests won't be affected */
685 pSetDllDirectoryA(NULL);
686}
687
688static void init_pointers(void)
689{
690 HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
691
692#define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hKernel32, #f))
699 MAKEFUNC(K32GetModuleInformation);
700#undef MAKEFUNC
701
702 /* before Windows 7 this was not exported in kernel32 */
703 if (!pK32GetModuleInformation)
704 {
705 HMODULE hPsapi = LoadLibraryA("psapi.dll");
706 pK32GetModuleInformation = (void *)GetProcAddress(hPsapi, "GetModuleInformation");
707 }
708}
709
710static void testGetModuleHandleEx(void)
711{
712 static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2',0};
713 static const WCHAR nosuchmodW[] = {'n','o','s','u','c','h','m','o','d',0};
714 BOOL ret;
715 DWORD error;
716 HMODULE mod, mod_kernel32;
717
718 SetLastError( 0xdeadbeef );
721 ok( !ret, "unexpected success\n" );
722 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
723
724 SetLastError( 0xdeadbeef );
725 ret = GetModuleHandleExA( 0, "kernel32", NULL );
727 ok( !ret, "unexpected success\n" );
728 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
729
730 SetLastError( 0xdeadbeef );
731 mod = (HMODULE)0xdeadbeef;
732 ret = GetModuleHandleExA( 0, "kernel32", &mod );
733 ok( ret, "unexpected failure %u\n", GetLastError() );
734 ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod );
735 FreeLibrary( mod );
736
737 SetLastError( 0xdeadbeef );
738 mod = (HMODULE)0xdeadbeef;
739 ret = GetModuleHandleExA( 0, "nosuchmod", &mod );
741 ok( !ret, "unexpected success\n" );
742 ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
743 ok( mod == NULL, "got %p\n", mod );
744
745 SetLastError( 0xdeadbeef );
748 ok( !ret, "unexpected success\n" );
749 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
750
751 SetLastError( 0xdeadbeef );
752 ret = GetModuleHandleExW( 0, kernel32W, NULL );
754 ok( !ret, "unexpected success\n" );
755 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
756
757 SetLastError( 0xdeadbeef );
758 mod = (HMODULE)0xdeadbeef;
759 ret = GetModuleHandleExW( 0, kernel32W, &mod );
760 ok( ret, "unexpected failure %u\n", GetLastError() );
761 ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod );
762 FreeLibrary( mod );
763
764 SetLastError( 0xdeadbeef );
765 mod = (HMODULE)0xdeadbeef;
766 ret = GetModuleHandleExW( 0, nosuchmodW, &mod );
768 ok( !ret, "unexpected success\n" );
769 ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
770 ok( mod == NULL, "got %p\n", mod );
771
772 SetLastError( 0xdeadbeef );
773 ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL );
775 ok( !ret, "unexpected success\n" );
776 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
777
778 SetLastError( 0xdeadbeef );
779 ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "kernel32", NULL );
781 ok( !ret, "unexpected success\n" );
782 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
783
784 SetLastError( 0xdeadbeef );
785 mod = (HMODULE)0xdeadbeef;
786 ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "kernel32", &mod );
787 ok( ret, "unexpected failure %u\n", GetLastError() );
788 ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod );
789
790 SetLastError( 0xdeadbeef );
791 mod = (HMODULE)0xdeadbeef;
792 ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "nosuchmod", &mod );
794 ok( !ret, "unexpected success\n" );
795 ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
796 ok( mod == NULL, "got %p\n", mod );
797
798 SetLastError( 0xdeadbeef );
799 ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL );
801 ok( !ret, "unexpected success\n" );
802 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
803
804 SetLastError( 0xdeadbeef );
805 ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, kernel32W, NULL );
807 ok( !ret, "unexpected success\n" );
808 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
809
810 SetLastError( 0xdeadbeef );
811 mod = (HMODULE)0xdeadbeef;
812 ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, kernel32W, &mod );
813 ok( ret, "unexpected failure %u\n", GetLastError() );
814 ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod );
815
816 SetLastError( 0xdeadbeef );
817 mod = (HMODULE)0xdeadbeef;
818 ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, nosuchmodW, &mod );
820 ok( !ret, "unexpected success\n" );
821 ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
822 ok( mod == NULL, "got %p\n", mod );
823
824 mod_kernel32 = LoadLibraryA( "kernel32" );
825
826 SetLastError( 0xdeadbeef );
827 ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, NULL, NULL );
829 ok( !ret, "unexpected success\n" );
830 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
831
832 SetLastError( 0xdeadbeef );
833 ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)mod_kernel32, NULL );
835 ok( !ret, "unexpected success\n" );
836 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
837
838 SetLastError( 0xdeadbeef );
839 mod = (HMODULE)0xdeadbeef;
840 ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)mod_kernel32, &mod );
841 ok( ret, "unexpected failure %u\n", GetLastError() );
842 ok( mod == mod_kernel32, "got %p\n", mod );
843 FreeLibrary( mod );
844
845 SetLastError( 0xdeadbeef );
846 mod = (HMODULE)0xdeadbeef;
847 ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)0xbeefdead, &mod );
849 ok( !ret, "unexpected success\n" );
850 ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
851 ok( mod == NULL, "got %p\n", mod );
852
853 SetLastError( 0xdeadbeef );
854 ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, NULL, NULL );
856 ok( !ret, "unexpected success\n" );
857 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
858
859 SetLastError( 0xdeadbeef );
860 ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)mod_kernel32, NULL );
862 ok( !ret, "unexpected success\n" );
863 ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
864
865 SetLastError( 0xdeadbeef );
866 mod = (HMODULE)0xdeadbeef;
867 ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)mod_kernel32, &mod );
868 ok( ret, "unexpected failure %u\n", GetLastError() );
869 ok( mod == mod_kernel32, "got %p\n", mod );
870 FreeLibrary( mod );
871
872 SetLastError( 0xdeadbeef );
873 mod = (HMODULE)0xdeadbeef;
874 ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)0xbeefdead, &mod );
876 ok( !ret, "unexpected success\n" );
877 ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
878 ok( mod == NULL, "got %p\n", mod );
879
880 FreeLibrary( mod_kernel32 );
881}
882
884{
886 HMODULE mod;
887 BOOL ret;
888
890 memset(&info, 0xAA, sizeof(info));
891 ret = pK32GetModuleInformation(GetCurrentProcess(), mod, &info, sizeof(info));
892 ok(ret, "K32GetModuleInformation failed for main module\n");
893 ok(info.lpBaseOfDll == mod, "Wrong info.lpBaseOfDll = %p, expected %p\n", info.lpBaseOfDll, mod);
894 ok(info.EntryPoint != NULL, "Expected nonzero entrypoint\n");
895
896 mod = GetModuleHandleA("kernel32.dll");
897 memset(&info, 0xAA, sizeof(info));
898 ret = pK32GetModuleInformation(GetCurrentProcess(), mod, &info, sizeof(info));
899 ok(ret, "K32GetModuleInformation failed for kernel32 module\n");
900 ok(info.lpBaseOfDll == mod, "Wrong info.lpBaseOfDll = %p, expected %p\n", info.lpBaseOfDll, mod);
901 ok(info.EntryPoint != NULL, "Expected nonzero entrypoint\n");
902}
903
904static void test_AddDllDirectory(void)
905{
906 static const WCHAR tmpW[] = {'t','m','p',0};
907 static const WCHAR dotW[] = {'.','\\','.',0};
908 static const WCHAR rootW[] = {'\\',0};
911 BOOL ret;
912
913 if (!pAddDllDirectory || !pRemoveDllDirectory)
914 {
915 win_skip( "AddDllDirectory not available\n" );
916 return;
917 }
918
919 buf[0] = '\0';
920 GetTempPathW( sizeof(path)/sizeof(path[0]), path );
921 ret = GetTempFileNameW( path, tmpW, 0, buf );
922 ok( ret, "GetTempFileName failed err %u\n", GetLastError() );
923 SetLastError( 0xdeadbeef );
924 cookie = pAddDllDirectory( buf );
925 ok( cookie != NULL, "AddDllDirectory failed err %u\n", GetLastError() );
926 SetLastError( 0xdeadbeef );
927 ret = pRemoveDllDirectory( cookie );
928 ok( ret, "RemoveDllDirectory failed err %u\n", GetLastError() );
929
930 DeleteFileW( buf );
931 SetLastError( 0xdeadbeef );
932 cookie = pAddDllDirectory( buf );
933 ok( !cookie, "AddDllDirectory succeeded\n" );
934 ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError() );
935 cookie = pAddDllDirectory( dotW );
936 ok( !cookie, "AddDllDirectory succeeded\n" );
937 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
938 cookie = pAddDllDirectory( rootW );
939 ok( cookie != NULL, "AddDllDirectory failed err %u\n", GetLastError() );
940 SetLastError( 0xdeadbeef );
941 ret = pRemoveDllDirectory( cookie );
942 ok( ret, "RemoveDllDirectory failed err %u\n", GetLastError() );
944 lstrcpyW( buf + 2, tmpW );
945 cookie = pAddDllDirectory( buf );
946 ok( !cookie, "AddDllDirectory succeeded\n" );
947 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
948}
949
951{
952 HMODULE mod;
953 BOOL ret;
954
955 if (!pSetDefaultDllDirectories)
956 {
957 win_skip( "SetDefaultDllDirectories not available\n" );
958 return;
959 }
960
961 mod = LoadLibraryA( "authz.dll" );
962 ok( mod != NULL, "loading authz failed\n" );
963 FreeLibrary( mod );
964 ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_USER_DIRS );
965 ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
966 mod = LoadLibraryA( "authz.dll" );
967 todo_wine ok( !mod, "loading authz succeeded\n" );
968 FreeLibrary( mod );
969 ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_SYSTEM32 );
970 ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
971 mod = LoadLibraryA( "authz.dll" );
972 ok( mod != NULL, "loading authz failed\n" );
973 FreeLibrary( mod );
975 todo_wine ok( !mod, "loading authz succeeded\n" );
976 FreeLibrary( mod );
977 ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
978 ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
979 mod = LoadLibraryA( "authz.dll" );
980 todo_wine ok( !mod, "loading authz succeeded\n" );
981 FreeLibrary( mod );
982 ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DEFAULT_DIRS );
983 ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
984 mod = LoadLibraryA( "authz.dll" );
985 ok( mod != NULL, "loading authz failed\n" );
986 FreeLibrary( mod );
987
988 SetLastError( 0xdeadbeef );
989 ret = pSetDefaultDllDirectories( 0 );
990 ok( !ret, "SetDefaultDllDirectories succeeded\n" );
991 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
992
993 SetLastError( 0xdeadbeef );
994 ret = pSetDefaultDllDirectories( 3 );
995 ok( !ret, "SetDefaultDllDirectories succeeded\n" );
996 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
997
998 SetLastError( 0xdeadbeef );
999 ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_APPLICATION_DIR | 0x8000 );
1000 ok( !ret, "SetDefaultDllDirectories succeeded\n" );
1001 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
1002
1003 SetLastError( 0xdeadbeef );
1004 ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
1005 ok( !ret || broken(ret) /* win7 */, "SetDefaultDllDirectories succeeded\n" );
1006 if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
1007
1008 SetLastError( 0xdeadbeef );
1010 ok( !ret || broken(ret) /* win7 */, "SetDefaultDllDirectories succeeded\n" );
1011 if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
1012
1013 /* restore some sane defaults */
1014 pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DEFAULT_DIRS );
1015}
1016
1018{
1020
1021 /* Test if we can use GetModuleFileNameW */
1022
1023 SetLastError(0xdeadbeef);
1026 {
1027 win_skip("GetModuleFileNameW not existing on this platform, skipping W-calls\n");
1029 }
1030
1031 init_pointers();
1032
1034 testGetModuleFileName("kernel32.dll");
1036
1038
1049}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
#define broken(x)
Definition: _sntprintf.h:21
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HMODULE hModule
Definition: animate.c:44
static const WCHAR rootW[]
Definition: chain.c:69
#define CloseHandle
Definition: compat.h:739
#define IMAGE_FILE_MACHINE_ARMNT
Definition: compat.h:127
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define FILE_BEGIN
Definition: compat.h:761
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
int(* FARPROC)()
Definition: compat.h:36
#define CP_ACP
Definition: compat.h:109
#define IMAGE_FILE_MACHINE_POWERPC
Definition: compat.h:128
#define SetFilePointer
Definition: compat.h:743
#define SetLastError(x)
Definition: compat.h:752
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define FreeLibrary(x)
Definition: compat.h:748
#define GetCurrentProcess()
Definition: compat.h:759
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define IMAGE_FILE_MACHINE_ARM64
Definition: compat.h:129
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define lstrcpyW
Definition: compat.h:749
#define MultiByteToWideChar
Definition: compat.h:110
#define FILE_SHARE_READ
Definition: compat.h:136
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1004
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:159
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
BOOL WINAPI GetModuleHandleExW(IN DWORD dwFlags, IN LPCWSTR lpwModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:866
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
BOOL WINAPI GetModuleHandleExA(IN DWORD dwFlags, IN LPCSTR lpModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:896
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:539
DWORD WINAPI GetDllDirectoryW(IN DWORD nBufferLength, OUT LPWSTR lpBuffer)
Definition: path.c:887
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2146
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2080
BOOL WINAPI SetDllDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:838
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2337
DWORD WINAPI GetDllDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:915
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2283
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _IMAGE_DOS_HEADER IMAGE_DOS_HEADER
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static int mod
Definition: i386-dis.c:1288
#define wine_dbgstr_w
Definition: kernel32.h:34
void * DLL_DIRECTORY_COOKIE
Definition: libloaderapi.h:26
WINBASEAPI BOOL WINAPI RemoveDllDirectory(DLL_DIRECTORY_COOKIE)
WINBASEAPI DLL_DIRECTORY_COOKIE WINAPI AddDllDirectory(const WCHAR *)
WINBASEAPI BOOL WINAPI SetDefaultDllDirectories(DWORD)
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define error(str)
Definition: mkdosfs.c:1605
#define CREATE_ALWAYS
Definition: disk.h:72
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static struct test_info tests[]
HANDLE hKernel32
Definition: locale.c:13
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static const WCHAR filenameW[]
Definition: amstream.c:41
UINT test_count
Definition: shader.c:5671
static HMODULE hPsapi
Definition: integrity.c:31
IMAGE_SECTION_HEADER section
Definition: module.c:51
static BOOL cmpStrAW(const char *a, const WCHAR *b, DWORD lenA, DWORD lenB)
Definition: module.c:37
static LPSTR
Definition: module.c:26
static void testGetModuleHandleEx(void)
Definition: module.c:710
static void testLoadLibraryA(void)
Definition: module.c:203
static const struct @1667 dll_image
static void create_test_dll(const char *name)
Definition: module.c:118
static void test_LoadLibraryEx_search_flags(void)
Definition: module.c:462
static void testGetDllDirectory(void)
Definition: module.c:588
#define MAKEFUNC(f)
static void testGetModuleFileName_Wrong(void)
Definition: module.c:185
static void testGetProcAddress_Wrong(void)
Definition: module.c:291
static LPWSTR
Definition: module.c:27
static void test_AddDllDirectory(void)
Definition: module.c:904
static void testGetModuleFileName(const char *name)
Definition: module.c:130
static BOOL is_unicode_enabled
Definition: module.c:35
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
IMAGE_NT_HEADERS nt
Definition: module.c:50
IMAGE_DOS_HEADER dos
Definition: module.c:49
static void init_pointers(void)
Definition: module.c:688
static void testLoadLibraryA_Wrong(void)
Definition: module.c:277
static void testLoadLibraryEx(void)
Definition: module.c:306
static void test_SetDefaultDllDirectories(void)
Definition: module.c:950
static void testNestedLoadLibraryA(void)
Definition: module.c:226
static void testK32GetModuleInformation(void)
Definition: module.c:883
static HMODULE MODULEINFO * modinfo
Definition: module.c:33
#define todo_wine
Definition: custom.c:79
static const WCHAR dotW[]
Definition: directory.c:80
static HMODULE hmodule
Definition: rasapi.c:29
static const WCHAR path1[]
Definition: path.c:28
static const WCHAR path2[]
Definition: path.c:29
int k
Definition: mpi.c:3369
static CookieInternal * cookies
Definition: msctf.c:65
#define BOOL
Definition: nt_native.h:43
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define DWORD
Definition: nt_native.h:44
#define GENERIC_WRITE
Definition: nt_native.h:90
#define IMAGE_SUBSYSTEM_WINDOWS_CUI
Definition: ntimage.h:438
#define IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: ntimage.h:231
#define IMAGE_FILE_MACHINE_AMD64
Definition: ntimage.h:17
#define IMAGE_SCN_MEM_READ
Definition: ntimage.h:240
#define IMAGE_NT_OPTIONAL_HDR_MAGIC
Definition: ntimage.h:387
#define IMAGE_FILE_EXECUTABLE_IMAGE
Definition: pedump.c:160
#define IMAGE_FILE_MACHINE_I386
Definition: pedump.c:174
struct _IMAGE_OPTIONAL_HEADER IMAGE_OPTIONAL_HEADER
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
#define IMAGE_FILE_DLL
Definition: pedump.c:169
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
#define win_skip
Definition: test.h:160
#define memset(x, y, z)
Definition: compat.h:39
Definition: cookie.c:34
Definition: name.c:39
HANDLE HMODULE
Definition: typedefs.h:77
int ret
#define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
Definition: winbase.h:350
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
Definition: winbase.h:354
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:342
#define LOAD_LIBRARY_SEARCH_SYSTEM32
Definition: winbase.h:353
BOOL WINAPI AreFileApisANSI(void)
Definition: utils.c:866
#define LOAD_WITH_ALTERED_SEARCH_PATH
Definition: winbase.h:344
#define LOAD_LIBRARY_SEARCH_USER_DIRS
Definition: winbase.h:352
#define LOAD_LIBRARY_SEARCH_APPLICATION_DIR
Definition: winbase.h:351
#define WINAPI
Definition: msvc.h:6
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define ERROR_FILE_INVALID
Definition: winerror.h:585
#define ERROR_PROC_NOT_FOUND
Definition: winerror.h:199
#define CP_OEMCP
Definition: winnls.h:231
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
char CHAR
Definition: xmlstorage.h:175