ReactOS 0.4.15-dev-7704-gc07eb9f
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;
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");
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");
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);
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);
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);
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");
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);
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);
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}
#define NtCurrentPeb()
Definition: FLS.c:22
#define ok(value,...)
Definition: atltest.h:57
BOOL Error
Definition: chkdsk.c:66
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define SetLastError(x)
Definition: compat.h:752
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
PPEB Peb
Definition: dllmain.c:27
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define L(x)
Definition: ntvdm.h:50
PVOID KernelCallbackTable
Definition: ntddk_ex.h:254
PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine
Definition: btrfs_drv.h:1916
DWORD WINAPI GetLastError(void)
Definition: except.c:1042