mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[NTDLL_APITEST] Show that registry strings can be longer than MAXUSHORT.
This commit is contained in:
parent
faac9169e6
commit
c83d7ba185
1 changed files with 43 additions and 9 deletions
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS API tests
|
* PROJECT: ReactOS API Tests
|
||||||
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
|
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
||||||
* PURPOSE: Test for NtSetValueKey
|
* PURPOSE: Test for NtSetValueKey
|
||||||
* PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
|
* COPYRIGHT: Copyright 2016-2019 Thomas Faber (thomas.faber@reactos.org)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
@ -24,6 +24,9 @@ START_TEST(NtSetValueKey)
|
||||||
PKEY_VALUE_PARTIAL_INFORMATION PartialInfo;
|
PKEY_VALUE_PARTIAL_INFORMATION PartialInfo;
|
||||||
ULONG PartialInfoLength;
|
ULONG PartialInfoLength;
|
||||||
ULONG ResultLength;
|
ULONG ResultLength;
|
||||||
|
ULONG DataLength;
|
||||||
|
PWCHAR LargeBuffer;
|
||||||
|
ULONG LargeBufferLength;
|
||||||
const struct
|
const struct
|
||||||
{
|
{
|
||||||
ULONG Type;
|
ULONG Type;
|
||||||
|
@ -89,14 +92,20 @@ START_TEST(NtSetValueKey)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartialInfoLength = FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[128]);
|
LargeBufferLength = 0x20000;
|
||||||
PartialInfo = HeapAlloc(GetProcessHeap(), 0, PartialInfoLength);
|
LargeBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, LargeBufferLength);
|
||||||
if (PartialInfo == NULL)
|
|
||||||
|
PartialInfoLength = FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[LargeBufferLength]);
|
||||||
|
PartialInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, PartialInfoLength);
|
||||||
|
|
||||||
|
if (LargeBuffer == NULL || PartialInfo == NULL)
|
||||||
{
|
{
|
||||||
|
RtlFreeHeap(GetProcessHeap(), 0, LargeBuffer);
|
||||||
|
RtlFreeHeap(GetProcessHeap(), 0, PartialInfo);
|
||||||
NtDeleteKey(KeyHandle);
|
NtDeleteKey(KeyHandle);
|
||||||
NtClose(KeyHandle);
|
NtClose(KeyHandle);
|
||||||
NtClose(ParentKeyHandle);
|
NtClose(ParentKeyHandle);
|
||||||
skip("No key handle\n");
|
skip("Could not allocate buffers\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +203,32 @@ START_TEST(NtSetValueKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, PartialInfo);
|
/* String value larger than MAXUSHORT */
|
||||||
|
{
|
||||||
|
const ULONG DataLengths[] = { 0x10000, 0x10002, 0x20000 };
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&ValueName, L"ExistingValue");
|
||||||
|
for (i = 0; i < RTL_NUMBER_OF(DataLengths); i++)
|
||||||
|
{
|
||||||
|
DataLength = DataLengths[i];
|
||||||
|
RtlFillMemoryUlong(LargeBuffer, DataLength, '\0B\0A');
|
||||||
|
LargeBuffer[DataLength / sizeof(WCHAR) - 2] = L'C';
|
||||||
|
LargeBuffer[DataLength / sizeof(WCHAR) - 1] = UNICODE_NULL;
|
||||||
|
Status = NtSetValueKey(KeyHandle, &ValueName, 0, REG_SZ, LargeBuffer, DataLength);
|
||||||
|
ok(Status == STATUS_SUCCESS, "[0x%lx] NtSetValueKey failed with %lx", DataLength, Status);
|
||||||
|
|
||||||
|
RtlZeroMemory(PartialInfo, PartialInfoLength);
|
||||||
|
Status = NtQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation, PartialInfo, PartialInfoLength, &ResultLength);
|
||||||
|
ok(Status == STATUS_SUCCESS, "[0x%lx] NtQueryValueKey failed with %lx\n", DataLength, Status);
|
||||||
|
ok(PartialInfo->TitleIndex == 0, "[0x%lx] TitleIndex = %lu\n", DataLength, PartialInfo->TitleIndex);
|
||||||
|
ok(PartialInfo->Type == REG_SZ, "[0x%lx] Type = %lu\n", DataLength, PartialInfo->Type);
|
||||||
|
ok(PartialInfo->DataLength == DataLength, "[0x%lx] DataLength = %lu\n", DataLength, PartialInfo->DataLength);
|
||||||
|
ok(!memcmp(PartialInfo->Data, LargeBuffer, DataLength), "[0x%lx] Data does not match set value\n", DataLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlFreeHeap(GetProcessHeap(), 0, LargeBuffer);
|
||||||
|
RtlFreeHeap(GetProcessHeap(), 0, PartialInfo);
|
||||||
Status = NtDeleteKey(KeyHandle);
|
Status = NtDeleteKey(KeyHandle);
|
||||||
ok(Status == STATUS_SUCCESS, "NtDeleteKey returned %lx\n", Status);
|
ok(Status == STATUS_SUCCESS, "NtDeleteKey returned %lx\n", Status);
|
||||||
Status = NtClose(KeyHandle);
|
Status = NtClose(KeyHandle);
|
||||||
|
|
Loading…
Reference in a new issue