These tests have to live in ntoskrnl, since only kernel drivers and processes running as LOCAL SYSTEM can create permanent objects.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 6 ++-- dlls/ntoskrnl.exe/tests/driver.c | 49 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec index 6acdec5dc5a..0f65490b487 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -1378,7 +1378,7 @@ @ stdcall ZwClose(long) NtClose @ stub ZwCloseObjectAuditAlarm @ stdcall -private ZwConnectPort(ptr ptr ptr ptr ptr ptr ptr ptr) NtConnectPort -@ stdcall -private ZwCreateDirectoryObject(ptr long ptr) NtCreateDirectoryObject +@ stdcall ZwCreateDirectoryObject(ptr long ptr) NtCreateDirectoryObject @ stdcall ZwCreateEvent(ptr long ptr long long) NtCreateEvent @ stdcall ZwCreateFile(ptr long ptr ptr ptr long long long long ptr long) NtCreateFile @ stdcall -private ZwCreateIoCompletion(ptr long ptr long) NtCreateIoCompletion @@ -1412,11 +1412,11 @@ @ stdcall -private ZwLoadKey(ptr ptr) NtLoadKey @ stdcall -private ZwLockFile(long long ptr ptr ptr ptr ptr ptr long long) NtLockFile @ stdcall -private ZwLockVirtualMemory(long ptr ptr long) NtLockVirtualMemory -@ stdcall -private ZwMakeTemporaryObject(long) NtMakeTemporaryObject +@ stdcall ZwMakeTemporaryObject(long) NtMakeTemporaryObject @ stdcall -private ZwMapViewOfSection(long long ptr long long ptr ptr long long long) NtMapViewOfSection @ stdcall -private ZwNotifyChangeDirectoryFile(long long ptr ptr ptr ptr long long long) NtNotifyChangeDirectoryFile @ stdcall -private ZwNotifyChangeKey(long long ptr ptr ptr long long ptr long long) NtNotifyChangeKey -@ stdcall -private ZwOpenDirectoryObject(ptr long ptr) NtOpenDirectoryObject +@ stdcall ZwOpenDirectoryObject(ptr long ptr) NtOpenDirectoryObject @ stdcall -private ZwOpenEvent(ptr long ptr) NtOpenEvent @ stdcall ZwOpenFile(ptr long ptr ptr long long) NtOpenFile @ stdcall -private ZwOpenJobObject(ptr long ptr) NtOpenJobObject diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index bb5bbeb4fa5..0ae63ffafb3 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -2024,6 +2024,54 @@ static void test_process_memory(const struct test_input *test_input) ObDereferenceObject(process); }
+static void test_permanence(void) +{ + OBJECT_ATTRIBUTES attr; + HANDLE handle, handle2; + UNICODE_STRING str; + NTSTATUS status; + + RtlInitUnicodeString(&str, L"\BaseNamedObjects\wine_test_dir"); + InitializeObjectAttributes(&attr, &str, 0, 0, NULL); + status = ZwCreateDirectoryObject( &handle, GENERIC_ALL, &attr ); + ok(!status, "got %#x\n", status); + status = ZwClose( handle ); + ok(!status, "got %#x\n", status); + status = ZwOpenDirectoryObject( &handle, 0, &attr ); + ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#x\n", status); + + attr.Attributes = OBJ_PERMANENT; + status = ZwCreateDirectoryObject( &handle, GENERIC_ALL, &attr ); + ok(!status, "got %#x\n", status); + status = ZwClose( handle ); + ok(!status, "got %#x\n", status); + + attr.Attributes = 0; + status = ZwOpenDirectoryObject( &handle, 0, &attr ); + todo_wine ok(!status, "got %#x\n", status); + status = ZwMakeTemporaryObject( handle ); + ok(!status, "got %#x\n", status); + status = ZwMakeTemporaryObject( handle ); + ok(!status, "got %#x\n", status); + status = ZwClose( handle ); + todo_wine ok(!status, "got %#x\n", status); + status = ZwOpenDirectoryObject( &handle, 0, &attr ); + ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#x\n", status); + + status = ZwCreateDirectoryObject( &handle, GENERIC_ALL, &attr ); + ok(!status, "got %#x\n", status); + attr.Attributes = OBJ_PERMANENT; + status = ZwOpenDirectoryObject( &handle2, 0, &attr ); + ok(status == STATUS_SUCCESS, "got %#x\n", status); + status = ZwClose( handle2 ); + ok(!status, "got %#x\n", status); + status = ZwClose( handle ); + ok(!status, "got %#x\n", status); + attr.Attributes = 0; + status = ZwOpenDirectoryObject( &handle, 0, &attr ); + ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#x\n", status); +} + static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *stack) { ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength; @@ -2080,6 +2128,7 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st test_affinity(); test_dpc(); test_process_memory(test_input); + test_permanence();
if (main_test_work_item) return STATUS_UNEXPECTED_IO_ERROR;