https://git.reactos.org/?p=reactos.git;a=commitdiff;h=47842d784718a2e877a1e1...
commit 47842d784718a2e877a1e13a2ecc4c87cb9b5957 Author: Timo Kreuzer timo.kreuzer@reactos.org AuthorDate: Sat Oct 3 18:46:31 2020 +0200 Commit: Timo Kreuzer timo.kreuzer@reactos.org CommitDate: Sat Jun 25 22:57:18 2022 +0200
[NTDLL_APITEST] Check whether changing the product type in the registry has an effect on RtlGetNtProductType --- .../rostests/apitests/ntdll/RtlGetNtProductType.c | 72 +++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-)
diff --git a/modules/rostests/apitests/ntdll/RtlGetNtProductType.c b/modules/rostests/apitests/ntdll/RtlGetNtProductType.c index 31549152839..c7cc6b0eb9f 100644 --- a/modules/rostests/apitests/ntdll/RtlGetNtProductType.c +++ b/modules/rostests/apitests/ntdll/RtlGetNtProductType.c @@ -68,11 +68,66 @@ ReturnNtProduct(PDWORD ProductNtType) return FALSE; }
+static +BOOLEAN +ChangeNtProductType(DWORD NtProductType) +{ + PWSTR ProductTypeString; + LONG Result; + HKEY Key; + DWORD dwSize; + + if (NtProductType == NtProductWinNt) + { + ProductTypeString = L"WinNT"; + } + else if (NtProductType == NtProductLanManNt) + { + ProductTypeString = L"LanmanNT"; + } + else if (NtProductType == NtProductServer) + { + ProductTypeString = L"ServerNT"; + } + else + { + ok(FALSE, "Passed invalid product type to CHangeNtProduct: %lu", NtProductType); + } + + Result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SYSTEM\CurrentControlSet\Control\ProductOptions", + 0, + KEY_QUERY_VALUE, + &Key); + if (Result != ERROR_SUCCESS) + { + ok(FALSE, "RegOpenKeyExW failed with 0x%lx\n", Result); + return FALSE; + } + + dwSize = ((DWORD)wcslen(ProductTypeString) + 1) * sizeof(WCHAR); + Result = RegSetValueExW(Key, + L"ProductType", + 0, + REG_SZ, + (PBYTE)ProductTypeString, + dwSize); + if (Result != ERROR_SUCCESS) + { + ok(FALSE, "RegSetValueExW failed with 0x%lx\n", Result); + RegCloseKey(Key); + return FALSE; + } + + RegCloseKey(Key); + return FALSE; +} + START_TEST(RtlGetNtProductType) { BOOLEAN Ret; DWORD ProductNtType; - NT_PRODUCT_TYPE ProductType = NtProductWinNt; + NT_PRODUCT_TYPE ProductType = NtProductWinNt, ProductType2;
/* * Wrap the call in SEH. This ensures the testcase won't crash but also @@ -94,4 +149,19 @@ START_TEST(RtlGetNtProductType) 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); + + /* Change product type in the registry */ + ok_char(ChangeNtProductType(NtProductWinNt), TRUE); + ok_char(RtlGetNtProductType(&ProductType2), TRUE); + ok_long(ProductType2, NtProductWinNt); + + ok_char(ChangeNtProductType(NtProductLanManNt), TRUE); + ok_char(RtlGetNtProductType(&ProductType2), TRUE); + ok_long(ProductType2, NtProductLanManNt); + + ok_char(ChangeNtProductType(NtProductServer), TRUE); + ok_char(RtlGetNtProductType(&ProductType2), TRUE); + ok_long(ProductType2, NtProductServer); + + ok_char(ChangeNtProductType(ProductType), TRUE); }