ReactOS  0.4.14-dev-1252-g782ff23
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  PTEB Teb = NtCurrentTeb();
20 
21  /* Before init */
22  hUser32 = GetModuleHandleW(L"user32");
23  ok(hUser32 == NULL, "hUser32 = %p\n", hUser32);
24  ok(Peb->KernelCallbackTable == NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
25  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
26  ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
27 
28  SetLastError(12345);
29  hUser32 = LoadLibraryW(L"user32");
30  Error = GetLastError();
31  ok(hUser32 != NULL, "LoadLibrary failed\n");
32  ok(Error != 12345, "Error = %lu\n", Error);
33 
34  /* Initialized */
35  hUser32_2 = GetModuleHandleW(L"user32");
36  ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
37  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
38  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
39  ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
40 
41  SetLastError(12345);
42  hUser32_2 = LoadLibraryW(L"user32");
43  Error = GetLastError();
44  ok(hUser32_2 == hUser32, "LoadLibrary failed\n");
45  ok(Error == 12345, "Error = %lu\n", Error);
46 
47  /* Still initialized */
48  hUser32_2 = GetModuleHandleW(L"user32");
49  ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
50  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
51  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
52  ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
53 
54  SetLastError(12345);
55  Ret = FreeLibrary(hUser32);
56  Error = GetLastError();
57  ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
58  ok(Error == 12345, "Error = %lu\n", Error);
59 
60  /* Still initialized */
61  hUser32_2 = GetModuleHandleW(L"user32");
62  ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
63  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
64  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
65  ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
66 
67  SetLastError(12345);
68  Ret = FreeLibrary(hUser32);
69  Error = GetLastError();
70  ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
71  ok(Error == 12345, "Error = %lu\n", Error);
72 
73  /* Somebody kept an extra reference! */
74  hUser32_2 = GetModuleHandleW(L"user32");
75  ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
76  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
77  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
78  ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
79 
80  SetLastError(12345);
81  Ret = FreeLibrary(hUser32);
82  Error = GetLastError();
83  ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
84  ok(Error == 12345, "Error = %lu\n", Error);
85 
86  /* Uninitialized */
87  hUser32 = GetModuleHandleW(L"user32");
88  ok(hUser32 == NULL, "hUser32 = %p\n", hUser32);
89  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
90  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
91  ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
92 
93  SetLastError(12345);
94  hUser32 = LoadLibraryW(L"user32");
95  Error = GetLastError();
96  ok(hUser32 != NULL, "LoadLibrary failed\n");
97  ok(Error != 12345, "Error = %lu\n", Error);
98 
99  /* Initialized again */
100  hUser32_2 = GetModuleHandleW(L"user32");
101  ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
102  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
103  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
104  ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
105 
106  SetLastError(12345);
107  Ret = FreeLibrary(hUser32);
108  Error = GetLastError();
109  ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
110  ok(Error == 12345, "Error = %lu\n", Error);
111 
112  /* Extra reference again */
113  hUser32_2 = GetModuleHandleW(L"user32");
114  ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
115  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
116  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
117  ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
118 
119  SetLastError(12345);
120  Ret = FreeLibrary(hUser32);
121  Error = GetLastError();
122  ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
123  ok(Error == 12345, "Error = %lu\n", Error);
124 
125  /* Uninitialized again */
126  hUser32 = GetModuleHandleW(L"user32");
127  ok(hUser32 == NULL, "hUser32 = %p\n", hUser32);
128  ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
129  ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
130  ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
131 }
ULONG Win32ClientInfo[31]
Definition: compat.h:504
#define TRUE
Definition: types.h:120
PPEB Peb
Definition: dllmain.c:27
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LoadLibraryW(x)
Definition: compat.h:412
smooth NULL
Definition: ftsmooth.c:416
PVOID KernelCallbackTable
Definition: ntddk_ex.h:254
#define FreeLibrary(x)
Definition: compat.h:413
PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine
Definition: btrfs_drv.h:1893
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL Error
Definition: chkdsk.c:66
#define SetLastError(x)
Definition: compat.h:417
static const WCHAR L[]
Definition: oid.c:1250
Definition: compat.h:492
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define NtCurrentPeb()
Definition: FLS.c:20
#define ok(value,...)
Definition: atltest.h:57
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:847