ReactOS  0.4.15-dev-1623-g66cf1d2
load.c File Reference
#include <apitest.h>
#include <ndk/pstypes.h>
#include <ndk/rtlfuncs.h>
Include dependency graph for load.c:

Go to the source code of this file.

Functions

 START_TEST (load)
 

Function Documentation

◆ START_TEST()

START_TEST ( load  )

Definition at line 12 of file load.c.

13 {
14  HMODULE hUser32;
15  HMODULE hUser32_2;
16  BOOL Ret;
17  DWORD Error;
18  PPEB Peb = NtCurrentPeb();
19 
20  /* Before init */
21  hUser32 = GetModuleHandleW(L"user32");
22  ok(hUser32 == NULL, "hUser32 = %p\n", hUser32);
23  ok(Peb->KernelCallbackTable == NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
24  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
25 
26  SetLastError(12345);
27  hUser32 = LoadLibraryW(L"user32");
28  Error = GetLastError();
29  ok(hUser32 != NULL, "LoadLibrary failed\n");
30  ok(Error != 12345, "Error = %lu\n", Error);
31 
32  /* Initialized */
33  hUser32_2 = GetModuleHandleW(L"user32");
34  ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
35  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
36  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
37 
38  SetLastError(12345);
39  hUser32_2 = LoadLibraryW(L"user32");
40  Error = GetLastError();
41  ok(hUser32_2 == hUser32, "LoadLibrary failed\n");
42  ok(Error == 12345, "Error = %lu\n", Error);
43 
44  /* Still initialized */
45  hUser32_2 = GetModuleHandleW(L"user32");
46  ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
47  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
48  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
49 
50  SetLastError(12345);
51  Ret = FreeLibrary(hUser32);
52  Error = GetLastError();
53  ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
54  ok(Error == 12345, "Error = %lu\n", Error);
55 
56  /* Still initialized */
57  hUser32_2 = GetModuleHandleW(L"user32");
58  ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
59  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
60  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
61 
62  SetLastError(12345);
63  Ret = FreeLibrary(hUser32);
64  Error = GetLastError();
65  ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
66  ok(Error == 12345, "Error = %lu\n", Error);
67 
68  /* Somebody kept an extra reference! */
69  hUser32_2 = GetModuleHandleW(L"user32");
70  ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
71  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
72  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
73 
74  SetLastError(12345);
75  Ret = FreeLibrary(hUser32);
76  Error = GetLastError();
77  ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
78  ok(Error == 12345, "Error = %lu\n", Error);
79 
80  /* Uninitialized */
81  hUser32 = GetModuleHandleW(L"user32");
82  ok(hUser32 == NULL, "hUser32 = %p\n", hUser32);
83  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
84  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
85 
86  SetLastError(12345);
87  hUser32 = LoadLibraryW(L"user32");
88  Error = GetLastError();
89  ok(hUser32 != NULL, "LoadLibrary failed\n");
90  ok(Error != 12345, "Error = %lu\n", Error);
91 
92  /* Initialized again */
93  hUser32_2 = GetModuleHandleW(L"user32");
94  ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
95  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
96  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
97 
98  SetLastError(12345);
99  Ret = FreeLibrary(hUser32);
100  Error = GetLastError();
101  ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
102  ok(Error == 12345, "Error = %lu\n", Error);
103 
104  /* Extra reference again */
105  hUser32_2 = GetModuleHandleW(L"user32");
106  ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
107  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
108  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
109 
110  SetLastError(12345);
111  Ret = FreeLibrary(hUser32);
112  Error = GetLastError();
113  ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
114  ok(Error == 12345, "Error = %lu\n", Error);
115 
116  /* Uninitialized again */
117  hUser32 = GetModuleHandleW(L"user32");
118  ok(hUser32 == NULL, "hUser32 = %p\n", hUser32);
119  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
120  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
121 }
PPEB Peb
Definition: dllmain.c:27
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LoadLibraryW(x)
Definition: compat.h:606
PVOID KernelCallbackTable
Definition: ntddk_ex.h:254
#define FreeLibrary(x)
Definition: compat.h:607
PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine
Definition: btrfs_drv.h:1962
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL Error
Definition: chkdsk.c:66
#define SetLastError(x)
Definition: compat.h:611
static const WCHAR L[]
Definition: oid.c:1250
#define NtCurrentPeb()
Definition: FLS.c:20
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838