ntdll: Fix return codes for NtCreateKey (with tests).
This commit is contained in:
parent
ad064915c9
commit
8a42a8c11a
|
@ -58,8 +58,9 @@ NTSTATUS WINAPI NtCreateKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_AT
|
||||||
TRACE( "(%p,%s,%s,%lx,%lx,%p)\n", attr->RootDirectory, debugstr_us(attr->ObjectName),
|
TRACE( "(%p,%s,%s,%lx,%lx,%p)\n", attr->RootDirectory, debugstr_us(attr->ObjectName),
|
||||||
debugstr_us(class), options, access, retkey );
|
debugstr_us(class), options, access, retkey );
|
||||||
|
|
||||||
|
if (!retkey || !attr) return STATUS_ACCESS_VIOLATION;
|
||||||
|
if (attr->Length > sizeof(OBJECT_ATTRIBUTES)) return STATUS_INVALID_PARAMETER;
|
||||||
if (attr->ObjectName->Length > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW;
|
if (attr->ObjectName->Length > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW;
|
||||||
if (!retkey) return STATUS_INVALID_PARAMETER;
|
|
||||||
|
|
||||||
SERVER_START_REQ( create_key )
|
SERVER_START_REQ( create_key )
|
||||||
{
|
{
|
||||||
|
|
|
@ -298,10 +298,38 @@ static void test_NtCreateKey(void)
|
||||||
ACCESS_MASK am = GENERIC_ALL;
|
ACCESS_MASK am = GENERIC_ALL;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
|
/* All NULL */
|
||||||
|
status = pNtCreateKey(NULL, 0, NULL, 0, 0, 0, 0);
|
||||||
|
ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got: 0x%08lx\n", status);
|
||||||
|
|
||||||
|
/* Only the key */
|
||||||
|
status = pNtCreateKey(&key, 0, NULL, 0, 0, 0, 0);
|
||||||
|
ok(status == STATUS_ACCESS_VIOLATION /* W2K3/XP/W2K */ || status == STATUS_INVALID_PARAMETER /* NT4 */,
|
||||||
|
"Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_PARAMETER(NT4), got: 0x%08lx\n", status);
|
||||||
|
|
||||||
|
/* Only accessmask */
|
||||||
|
status = pNtCreateKey(NULL, am, NULL, 0, 0, 0, 0);
|
||||||
|
ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got: 0x%08lx\n", status);
|
||||||
|
|
||||||
|
/* Key and accessmask */
|
||||||
|
status = pNtCreateKey(&key, am, NULL, 0, 0, 0, 0);
|
||||||
|
ok(status == STATUS_ACCESS_VIOLATION /* W2K3/XP/W2K */ || status == STATUS_INVALID_PARAMETER /* NT4 */,
|
||||||
|
"Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_PARAMETER(NT4), got: 0x%08lx\n", status);
|
||||||
|
|
||||||
InitializeObjectAttributes(&attr, &winetestpath, 0, 0, 0);
|
InitializeObjectAttributes(&attr, &winetestpath, 0, 0, 0);
|
||||||
|
|
||||||
|
/* Only attributes */
|
||||||
|
status = pNtCreateKey(NULL, 0, &attr, 0, 0, 0, 0);
|
||||||
|
ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got: 0x%08lx\n", status);
|
||||||
|
|
||||||
status = pNtCreateKey(&key, am, &attr, 0, 0, 0, 0);
|
status = pNtCreateKey(&key, am, &attr, 0, 0, 0, 0);
|
||||||
ok(status == STATUS_SUCCESS, "NtCreateKey Failed: 0x%08lx\n", status);
|
ok(status == STATUS_SUCCESS, "NtCreateKey Failed: 0x%08lx\n", status);
|
||||||
|
|
||||||
|
/* Length > sizeof(OBJECT_ATTRIBUTES) */
|
||||||
|
attr.Length *= 2;
|
||||||
|
status = pNtCreateKey(&key, am, &attr, 0, 0, 0, 0);
|
||||||
|
ok(status == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got: 0x%08lx\n", status);
|
||||||
|
|
||||||
pNtClose(&key);
|
pNtClose(&key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue