mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 14:43:02 +00:00
[APITEST][NTDLL] Implement RtlGetNtProductType testcase (#2489)
This commit is contained in:
parent
975d417b34
commit
d778d04a16
3 changed files with 100 additions and 0 deletions
|
@ -56,6 +56,7 @@ list(APPEND SOURCE
|
||||||
RtlGetFullPathName_UstrEx.c
|
RtlGetFullPathName_UstrEx.c
|
||||||
RtlGetLengthWithoutTrailingPathSeperators.c
|
RtlGetLengthWithoutTrailingPathSeperators.c
|
||||||
RtlGetLongestNtPathLength.c
|
RtlGetLongestNtPathLength.c
|
||||||
|
RtlGetNtProductType.c
|
||||||
RtlHandle.c
|
RtlHandle.c
|
||||||
RtlImageRvaToVa.c
|
RtlImageRvaToVa.c
|
||||||
RtlIsNameLegalDOS8Dot3.c
|
RtlIsNameLegalDOS8Dot3.c
|
||||||
|
|
97
modules/rostests/apitests/ntdll/RtlGetNtProductType.c
Normal file
97
modules/rostests/apitests/ntdll/RtlGetNtProductType.c
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS API tests
|
||||||
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
|
* PURPOSE: Tests for the RtlGetNtProductType API
|
||||||
|
* COPYRIGHT: Copyright 2020 Bișoc George <fraizeraust99 at gmail dot com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "precomp.h"
|
||||||
|
#include <winbase.h>
|
||||||
|
#include <winreg.h>
|
||||||
|
|
||||||
|
static
|
||||||
|
BOOLEAN
|
||||||
|
ReturnNtProduct(PDWORD ProductNtType)
|
||||||
|
{
|
||||||
|
LONG Result;
|
||||||
|
HKEY Key;
|
||||||
|
WCHAR Data[20];
|
||||||
|
DWORD Size = sizeof(Data);
|
||||||
|
|
||||||
|
Result = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
|
L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
|
||||||
|
0,
|
||||||
|
KEY_QUERY_VALUE,
|
||||||
|
&Key);
|
||||||
|
if (Result != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
*ProductNtType = 0;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result = RegQueryValueExW(Key,
|
||||||
|
L"ProductType",
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
(PBYTE)&Data,
|
||||||
|
&Size);
|
||||||
|
if (Result != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
RegCloseKey(Key);
|
||||||
|
*ProductNtType = 0;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wcscmp(Data, L"WinNT") == 0)
|
||||||
|
{
|
||||||
|
*ProductNtType = NtProductWinNt;
|
||||||
|
RegCloseKey(Key);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wcscmp(Data, L"LanmanNT") == 0)
|
||||||
|
{
|
||||||
|
*ProductNtType = NtProductLanManNt;
|
||||||
|
RegCloseKey(Key);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wcscmp(Data, L"ServerNT") == 0)
|
||||||
|
{
|
||||||
|
*ProductNtType = NtProductServer;
|
||||||
|
RegCloseKey(Key);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ProductNtType = 0;
|
||||||
|
RegCloseKey(Key);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(RtlGetNtProductType)
|
||||||
|
{
|
||||||
|
BOOLEAN Ret;
|
||||||
|
DWORD ProductNtType;
|
||||||
|
NT_PRODUCT_TYPE ProductType = NtProductWinNt;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wrap the call in SEH. This ensures the testcase won't crash but also
|
||||||
|
* it proves to us that RtlGetNtProductType() throws an exception if a NULL
|
||||||
|
* argument is being passed to caller as output.
|
||||||
|
*/
|
||||||
|
StartSeh()
|
||||||
|
RtlGetNtProductType(NULL);
|
||||||
|
EndSeh(STATUS_ACCESS_VIOLATION);
|
||||||
|
|
||||||
|
/* Query the product type normally from the Registry */
|
||||||
|
Ret = ReturnNtProduct(&ProductNtType);
|
||||||
|
if (!Ret)
|
||||||
|
{
|
||||||
|
ok(Ret, "Failed to query the product type value!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now, get the product type from the NTDLL system call */
|
||||||
|
Ret = RtlGetNtProductType(&ProductType);
|
||||||
|
ok(Ret == TRUE, "Expected a valid product type value (and TRUE as returned success code) but got %u as status.\n", Ret);
|
||||||
|
ok(ProductNtType == ProductType, "Expected the product type value to be the same but got %lu (original value pointed by RtlGetNtProductType() is %d).\n", ProductNtType, ProductType);
|
||||||
|
}
|
|
@ -55,6 +55,7 @@ extern void func_RtlGetFullPathName_Ustr(void);
|
||||||
extern void func_RtlGetFullPathName_UstrEx(void);
|
extern void func_RtlGetFullPathName_UstrEx(void);
|
||||||
extern void func_RtlGetLengthWithoutTrailingPathSeperators(void);
|
extern void func_RtlGetLengthWithoutTrailingPathSeperators(void);
|
||||||
extern void func_RtlGetLongestNtPathLength(void);
|
extern void func_RtlGetLongestNtPathLength(void);
|
||||||
|
extern void func_RtlGetNtProductType(void);
|
||||||
extern void func_RtlHandle(void);
|
extern void func_RtlHandle(void);
|
||||||
extern void func_RtlImageRvaToVa(void);
|
extern void func_RtlImageRvaToVa(void);
|
||||||
extern void func_RtlIsNameLegalDOS8Dot3(void);
|
extern void func_RtlIsNameLegalDOS8Dot3(void);
|
||||||
|
@ -123,6 +124,7 @@ const struct test winetest_testlist[] =
|
||||||
{ "RtlGetFullPathName_UstrEx", func_RtlGetFullPathName_UstrEx },
|
{ "RtlGetFullPathName_UstrEx", func_RtlGetFullPathName_UstrEx },
|
||||||
{ "RtlGetLengthWithoutTrailingPathSeperators", func_RtlGetLengthWithoutTrailingPathSeperators },
|
{ "RtlGetLengthWithoutTrailingPathSeperators", func_RtlGetLengthWithoutTrailingPathSeperators },
|
||||||
{ "RtlGetLongestNtPathLength", func_RtlGetLongestNtPathLength },
|
{ "RtlGetLongestNtPathLength", func_RtlGetLongestNtPathLength },
|
||||||
|
{ "RtlGetNtProductType", func_RtlGetNtProductType },
|
||||||
{ "RtlHandle", func_RtlHandle },
|
{ "RtlHandle", func_RtlHandle },
|
||||||
{ "RtlImageRvaToVa", func_RtlImageRvaToVa },
|
{ "RtlImageRvaToVa", func_RtlImageRvaToVa },
|
||||||
{ "RtlIsNameLegalDOS8Dot3", func_RtlIsNameLegalDOS8Dot3 },
|
{ "RtlIsNameLegalDOS8Dot3", func_RtlIsNameLegalDOS8Dot3 },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue