2015-11-17 13:45:59 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS API tests
|
|
|
|
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
|
|
|
|
* PURPOSE: Test for loading/unloading user32.dll
|
|
|
|
* PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <apitest.h>
|
2015-11-20 17:27:27 +00:00
|
|
|
#include <ndk/pstypes.h>
|
|
|
|
#include <ndk/rtlfuncs.h>
|
2015-11-17 13:45:59 +00:00
|
|
|
|
|
|
|
START_TEST(load)
|
|
|
|
{
|
|
|
|
HMODULE hUser32;
|
|
|
|
HMODULE hUser32_2;
|
|
|
|
BOOL Ret;
|
|
|
|
DWORD Error;
|
2015-11-20 17:27:27 +00:00
|
|
|
PPEB Peb = NtCurrentPeb();
|
|
|
|
PTEB Teb = NtCurrentTeb();
|
|
|
|
|
|
|
|
/* Before init */
|
|
|
|
hUser32 = GetModuleHandleW(L"user32");
|
|
|
|
ok(hUser32 == NULL, "hUser32 = %p\n", hUser32);
|
|
|
|
ok(Peb->KernelCallbackTable == NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
|
|
|
|
ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
|
|
|
|
ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
|
2015-11-17 13:45:59 +00:00
|
|
|
|
|
|
|
SetLastError(12345);
|
|
|
|
hUser32 = LoadLibraryW(L"user32");
|
|
|
|
Error = GetLastError();
|
|
|
|
ok(hUser32 != NULL, "LoadLibrary failed\n");
|
|
|
|
ok(Error != 12345, "Error = %lu\n", Error);
|
|
|
|
|
2015-11-20 17:27:27 +00:00
|
|
|
/* Initialized */
|
|
|
|
hUser32_2 = GetModuleHandleW(L"user32");
|
|
|
|
ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
|
|
|
|
ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
|
|
|
|
ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
|
|
|
|
ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
|
|
|
|
|
2015-11-17 13:45:59 +00:00
|
|
|
SetLastError(12345);
|
|
|
|
hUser32_2 = LoadLibraryW(L"user32");
|
|
|
|
Error = GetLastError();
|
|
|
|
ok(hUser32_2 == hUser32, "LoadLibrary failed\n");
|
|
|
|
ok(Error == 12345, "Error = %lu\n", Error);
|
|
|
|
|
2015-11-20 17:27:27 +00:00
|
|
|
/* Still initialized */
|
|
|
|
hUser32_2 = GetModuleHandleW(L"user32");
|
|
|
|
ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
|
|
|
|
ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
|
|
|
|
ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
|
|
|
|
ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
|
|
|
|
|
|
|
|
SetLastError(12345);
|
|
|
|
Ret = FreeLibrary(hUser32);
|
|
|
|
Error = GetLastError();
|
|
|
|
ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
|
|
|
|
ok(Error == 12345, "Error = %lu\n", Error);
|
|
|
|
|
|
|
|
/* Still initialized */
|
|
|
|
hUser32_2 = GetModuleHandleW(L"user32");
|
|
|
|
ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
|
|
|
|
ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
|
|
|
|
ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
|
|
|
|
ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
|
|
|
|
|
|
|
|
SetLastError(12345);
|
2015-11-17 13:45:59 +00:00
|
|
|
Ret = FreeLibrary(hUser32);
|
|
|
|
Error = GetLastError();
|
|
|
|
ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
|
|
|
|
ok(Error == 12345, "Error = %lu\n", Error);
|
|
|
|
|
2015-11-20 17:27:27 +00:00
|
|
|
/* Somebody kept an extra reference! */
|
|
|
|
hUser32_2 = GetModuleHandleW(L"user32");
|
|
|
|
ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
|
|
|
|
ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
|
|
|
|
ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
|
|
|
|
ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
|
|
|
|
|
|
|
|
SetLastError(12345);
|
2015-11-17 13:45:59 +00:00
|
|
|
Ret = FreeLibrary(hUser32);
|
|
|
|
Error = GetLastError();
|
|
|
|
ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
|
|
|
|
ok(Error == 12345, "Error = %lu\n", Error);
|
|
|
|
|
2015-11-20 17:27:27 +00:00
|
|
|
/* Uninitialized */
|
|
|
|
hUser32 = GetModuleHandleW(L"user32");
|
|
|
|
ok(hUser32 == NULL, "hUser32 = %p\n", hUser32);
|
|
|
|
ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
|
|
|
|
ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
|
|
|
|
ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
|
|
|
|
|
2015-11-17 13:45:59 +00:00
|
|
|
SetLastError(12345);
|
|
|
|
hUser32 = LoadLibraryW(L"user32");
|
|
|
|
Error = GetLastError();
|
|
|
|
ok(hUser32 != NULL, "LoadLibrary failed\n");
|
2015-11-20 17:27:27 +00:00
|
|
|
ok(Error != 12345, "Error = %lu\n", Error);
|
|
|
|
|
|
|
|
/* Initialized again */
|
|
|
|
hUser32_2 = GetModuleHandleW(L"user32");
|
|
|
|
ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
|
|
|
|
ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
|
|
|
|
ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
|
|
|
|
ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
|
|
|
|
|
|
|
|
SetLastError(12345);
|
|
|
|
Ret = FreeLibrary(hUser32);
|
|
|
|
Error = GetLastError();
|
|
|
|
ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
|
2015-11-17 13:45:59 +00:00
|
|
|
ok(Error == 12345, "Error = %lu\n", Error);
|
|
|
|
|
2015-11-20 17:27:27 +00:00
|
|
|
/* Extra reference again */
|
|
|
|
hUser32_2 = GetModuleHandleW(L"user32");
|
|
|
|
ok(hUser32_2 == hUser32, "hUser32 = %p\n", hUser32);
|
|
|
|
ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
|
|
|
|
ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
|
|
|
|
ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
|
|
|
|
|
|
|
|
SetLastError(12345);
|
2015-11-17 13:45:59 +00:00
|
|
|
Ret = FreeLibrary(hUser32);
|
|
|
|
Error = GetLastError();
|
|
|
|
ok(Ret == TRUE, "FreeLibrary returned %d\n", Ret);
|
|
|
|
ok(Error == 12345, "Error = %lu\n", Error);
|
2015-11-20 17:27:27 +00:00
|
|
|
|
|
|
|
/* Uninitialized again */
|
|
|
|
hUser32 = GetModuleHandleW(L"user32");
|
|
|
|
ok(hUser32 == NULL, "hUser32 = %p\n", hUser32);
|
|
|
|
ok(Peb->KernelCallbackTable != NULL, "KernelCallbackTable = %p\n", Peb->KernelCallbackTable);
|
|
|
|
ok(Peb->PostProcessInitRoutine == NULL, "PostProcessInitRoutine = %p\n", Peb->PostProcessInitRoutine);
|
|
|
|
ok(Teb->Win32ClientInfo != NULL, "Win32ClientInfo = %p\n", Teb->Win32ClientInfo);
|
2015-11-17 13:45:59 +00:00
|
|
|
}
|