Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/ntoskrnl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 5942556e12..c989b3a684 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -373,7 +373,7 @@ NTSTATUS WINAPI ObOpenObjectByPointer( void *obj, ULONG attr, ACCESS_STATE *acce return STATUS_NOT_IMPLEMENTED; }
- if (attr & ~OBJ_KERNEL_HANDLE) FIXME( "access %x not supported\n", access ); + if (attr & ~OBJ_KERNEL_HANDLE) FIXME( "attr %#x not supported\n", attr ); if (access_state) FIXME( "access_state not implemented\n" );
if (type && ObGetObjectType( obj ) != type) return STATUS_OBJECT_TYPE_MISMATCH;
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47623 Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/ntoskrnl.c | 15 +++++-- dlls/ntoskrnl.exe/tests/driver.c | 77 ++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 3 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index c989b3a684..80dee34b75 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -3260,10 +3260,19 @@ VOID WINAPI IoStartNextPacket(PDEVICE_OBJECT deviceobject, BOOLEAN cancelable) /***************************************************** * ObQueryNameString (NTOSKRNL.EXE.@) */ -NTSTATUS WINAPI ObQueryNameString(PVOID object, POBJECT_NAME_INFORMATION name, ULONG maxlength, PULONG returnlength) +NTSTATUS WINAPI ObQueryNameString( void *object, OBJECT_NAME_INFORMATION *name, ULONG size, ULONG *ret_size ) { - FIXME("(%p %p %u %p) stub\n", object, name, maxlength, returnlength); - return STATUS_NOT_IMPLEMENTED; + HANDLE handle; + NTSTATUS ret; + + TRACE("object %p, name %p, size %u, ret_size %p.\n", object, name, size, ret_size); + + if ((ret = ObOpenObjectByPointer( object, 0, NULL, 0, NULL, KernelMode, &handle ))) + return ret; + ret = NtQueryObject( handle, ObjectNameInformation, name, size, ret_size ); + + NtClose( handle ); + return ret; }
/***************************************************** diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index 94b62b05fe..3333b3939d 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -1524,6 +1524,82 @@ static void test_IoAttachDeviceToDeviceStack(void) IoDeleteDevice(dev3); }
+static void test_object_name(void) +{ + static const WCHAR event_nameW[] = L"\wine_test_event"; + static const WCHAR device_nameW[] = L"\Device\WineTestDriver"; + char buffer[1024]; + OBJECT_NAME_INFORMATION *name = (OBJECT_NAME_INFORMATION *)buffer; + OBJECT_ATTRIBUTES attr; + UNICODE_STRING string; + ULONG ret_size; + HANDLE handle; + KEVENT *event; + NTSTATUS ret; + + ret_size = 0; + ret = ObQueryNameString(lower_device, name, 0, &ret_size); + ok(ret == STATUS_INFO_LENGTH_MISMATCH, "got status %#x\n", ret); + ok(ret_size == sizeof(*name) + sizeof(device_nameW), "got size %u\n", ret_size); + + ret_size = 0; + ret = ObQueryNameString(lower_device, name, sizeof(buffer), &ret_size); + ok(!ret, "got status %#x\n", ret); + ok(!wcscmp(name->Name.Buffer, device_nameW), "got name %ls\n", name->Name.Buffer); + ok(ret_size == sizeof(*name) + sizeof(device_nameW), "got size %u\n", ret_size); + ok(name->Name.Length == wcslen(device_nameW) * sizeof(WCHAR), "got length %u\n", name->Name.Length); + ok(name->Name.MaximumLength == sizeof(device_nameW), "got maximum length %u\n", name->Name.MaximumLength); + + event = IoCreateSynchronizationEvent(NULL, &handle); + ok(!!event, "failed to create event\n"); + + ret_size = 0; + ret = ObQueryNameString(event, name, sizeof(buffer), &ret_size); + ok(!ret, "got status %#x\n", ret); + ok(!name->Name.Buffer, "got name %ls\n", name->Name.Buffer); + ok(ret_size == sizeof(*name), "got size %u\n", ret_size); + ok(!name->Name.Length, "got length %u\n", name->Name.Length); + ok(!name->Name.MaximumLength, "got maximum length %u\n", name->Name.MaximumLength); + + ret = ZwClose(handle); + ok(!ret, "got status %#x\n", ret); + + RtlInitUnicodeString(&string, event_nameW); + InitializeObjectAttributes(&attr, &string, OBJ_KERNEL_HANDLE, NULL, NULL); + ret = ZwCreateEvent(&handle, 0, &attr, NotificationEvent, TRUE); + ok(!ret, "got status %#x\n", ret); + ret = ObReferenceObjectByHandle(handle, 0, *pExEventObjectType, KernelMode, (void **)&event, NULL); + ok(!ret, "got status %#x\n", ret); + + ret_size = 0; + ret = ObQueryNameString(event, name, sizeof(buffer), &ret_size); + ok(!ret, "got status %#x\n", ret); + ok(!wcscmp(name->Name.Buffer, event_nameW), "got name %ls\n", name->Name.Buffer); + ok(ret_size == sizeof(*name) + sizeof(event_nameW), "got size %u\n", ret_size); + ok(name->Name.Length == wcslen(event_nameW) * sizeof(WCHAR), "got length %u\n", name->Name.Length); + ok(name->Name.MaximumLength == sizeof(event_nameW), "got maximum length %u\n", name->Name.MaximumLength); + + ObDereferenceObject(event); + ret = ZwClose(handle); + ok(!ret, "got status %#x\n", ret); + + ret_size = 0; + ret = ObQueryNameString(KeGetCurrentThread(), name, sizeof(buffer), &ret_size); + ok(!ret, "got status %#x\n", ret); + ok(!name->Name.Buffer, "got name %ls\n", name->Name.Buffer); + ok(ret_size == sizeof(*name), "got size %u\n", ret_size); + ok(!name->Name.Length, "got length %u\n", name->Name.Length); + ok(!name->Name.MaximumLength, "got maximum length %u\n", name->Name.MaximumLength); + + ret_size = 0; + ret = ObQueryNameString(IoGetCurrentProcess(), name, sizeof(buffer), &ret_size); + ok(!ret, "got status %#x\n", ret); + ok(!name->Name.Buffer, "got name %ls\n", name->Name.Buffer); + ok(ret_size == sizeof(*name), "got size %u\n", ret_size); + ok(!name->Name.Length, "got length %u\n", name->Name.Length); + ok(!name->Name.MaximumLength, "got maximum length %u\n", name->Name.MaximumLength); +} + static PIO_WORKITEM main_test_work_item;
static void WINAPI main_test_task(DEVICE_OBJECT *device, void *context) @@ -1633,6 +1709,7 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st test_resource(); test_lookup_thread(); test_IoAttachDeviceToDeviceStack(); + test_object_name(); #if defined(__i386__) || defined(__x86_64__) test_executable_pool(); #endif
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=55578
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/ntoskrnl.exe/tests/driver.c:1633 Task: Patch failed to apply
=== debian10 (build log) ===
error: patch failed: dlls/ntoskrnl.exe/tests/driver.c:1633 Task: Patch failed to apply
=== debian10 (build log) ===
error: patch failed: dlls/ntoskrnl.exe/tests/driver.c:1633 Task: Patch failed to apply
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47623 Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/ntoskrnl.c | 11 ++++++----- dlls/ntoskrnl.exe/tests/driver.c | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 80dee34b75..b873c9b770 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -1539,10 +1539,15 @@ NTSTATUS WINAPI IoCreateDriver( UNICODE_STRING *name, PDRIVER_INITIALIZE init ) for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) driver->driver_obj.MajorFunction[i] = unhandled_irp;
+ EnterCriticalSection( &drivers_cs ); + if (wine_rb_put( &wine_drivers, &driver->driver_obj.DriverName, &driver->entry )) + ERR( "failed to insert driver %s in tree\n", debugstr_us(name) ); + LeaveCriticalSection( &drivers_cs ); + status = driver->driver_obj.DriverInit( &driver->driver_obj, &driver->driver_extension.ServiceKeyName ); if (status) { - ObDereferenceObject( driver ); + IoDeleteDriver( &driver->driver_obj ); return status; }
@@ -1552,10 +1557,6 @@ NTSTATUS WINAPI IoCreateDriver( UNICODE_STRING *name, PDRIVER_INITIALIZE init ) driver->driver_obj.MajorFunction[i] = unhandled_irp; }
- EnterCriticalSection( &drivers_cs ); - if (wine_rb_put( &wine_drivers, &driver->driver_obj.DriverName, &driver->entry )) - ERR( "failed to insert driver %s in tree\n", debugstr_us(name) ); - LeaveCriticalSection( &drivers_cs ); return STATUS_SUCCESS; }
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index 3333b3939d..0f333dd25b 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -56,7 +56,7 @@ static int running_under_wine; static int winetest_debug; static int winetest_report_success;
-static POBJECT_TYPE *pExEventObjectType, *pIoFileObjectType, *pPsThreadType; +static POBJECT_TYPE *pExEventObjectType, *pIoFileObjectType, *pPsThreadType, *pIoDriverObjectType; static PEPROCESS *pPsInitialSystemProcess; static void *create_caller_thread;
@@ -1921,8 +1921,12 @@ static VOID WINAPI driver_Unload(DRIVER_OBJECT *driver)
NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry) { + static const WCHAR IoDriverObjectTypeW[] = {'I','o','D','r','i','v','e','r','O','b','j','e','c','t','T','y','p','e',0}; + static const WCHAR driver_nameW[] = {'\','D','r','i','v','e','r', + '\','W','i','n','e','T','e','s','t','D','r','i','v','e','r',0}; UNICODE_STRING nameW, linkW; NTSTATUS status; + void *obj;
DbgPrint("loading driver\n");
@@ -1937,6 +1941,19 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry) driver->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = driver_FlushBuffers; driver->MajorFunction[IRP_MJ_CLOSE] = driver_Close;
+ RtlInitUnicodeString(&nameW, IoDriverObjectTypeW); + pIoDriverObjectType = MmGetSystemRoutineAddress(&nameW); + + RtlInitUnicodeString(&nameW, driver_nameW); + if ((status = ObReferenceObjectByName(&nameW, 0, NULL, 0, *pIoDriverObjectType, KernelMode, NULL, &obj))) + return status; + if (obj != driver) + { + ObDereferenceObject(obj); + return STATUS_UNSUCCESSFUL; + } + ObDereferenceObject(obj); + RtlInitUnicodeString(&nameW, device_name); RtlInitUnicodeString(&linkW, driver_link);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=55579
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/ntoskrnl.exe/tests/driver.c:1633 Task: Patch failed to apply
=== debian10 (build log) ===
error: patch failed: dlls/ntoskrnl.exe/tests/driver.c:1633 Task: Patch failed to apply
=== debian10 (build log) ===
error: patch failed: dlls/ntoskrnl.exe/tests/driver.c:1633 Task: Patch failed to apply
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47623 Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/advapi32/tests/service.c | 90 +++++++++++++++++++++++++++++++++++ programs/services/services.c | 2 +- 2 files changed, 91 insertions(+), 1 deletion(-)
diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c index e4ff7d79ba..9dad710490 100644 --- a/dlls/advapi32/tests/service.c +++ b/dlls/advapi32/tests/service.c @@ -35,6 +35,8 @@ static const CHAR spooler[] = "Spooler"; /* Should be available on all platforms */ static CHAR selfname[MAX_PATH];
+static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); + static BOOL (WINAPI *pChangeServiceConfig2A)(SC_HANDLE,DWORD,LPVOID); static BOOL (WINAPI *pChangeServiceConfig2W)(SC_HANDLE,DWORD,LPVOID); static BOOL (WINAPI *pEnumServicesStatusExA)(SC_HANDLE, SC_ENUM_TYPE, DWORD, @@ -67,6 +69,8 @@ static void init_function_pointers(void) pQueryServiceStatusEx= (void*)GetProcAddress(hadvapi32, "QueryServiceStatusEx"); pQueryServiceObjectSecurity = (void*)GetProcAddress(hadvapi32, "QueryServiceObjectSecurity"); pNotifyServiceStatusChangeW = (void*)GetProcAddress(hadvapi32, "NotifyServiceStatusChangeW"); + + pIsWow64Process = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsWow64Process"); }
static void test_open_scm(void) @@ -1767,6 +1771,91 @@ static void test_close(void) ok(ret, "Expected success got error %u\n", GetLastError()); }
+static void test_wow64(void) +{ + SC_HANDLE manager, service; + BOOL wow64, ret; + HANDLE file; + + if (!pIsWow64Process || !pIsWow64Process(GetCurrentProcess(), &wow64) || !wow64) + { + skip("Not running under WoW64.\n"); + return; + } + + if (!(manager = OpenSCManagerA(NULL, NULL, SC_MANAGER_CREATE_SERVICE))) + { + skip("Not enough permissions to create a service.\n"); + return; + } + + file = CreateFileA("C:\windows\syswow64\winetestsvc.exe", GENERIC_WRITE, + 0, NULL, CREATE_ALWAYS, 0, NULL); + CloseHandle(file); + + service = CreateServiceA(manager, "winetestsvc", "winetestsvc", + SERVICE_START | SERVICE_STOP | SERVICE_QUERY_STATUS | DELETE, + SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, + "C:\windows\system32\winetestsvc.exe service serve", NULL, NULL, NULL, NULL, NULL); + ok(!!service, "Failed to create service, error %u.\n", GetLastError()); + ret = StartServiceA(service, 0, NULL); + ok(!ret, "Expected failure.\n"); + todo_wine ok(GetLastError() == ERROR_BAD_EXE_FORMAT, "Got error %u.\n", GetLastError()); + + ret = DeleteService(service); + ok(ret, "Failed to delete service, error %u.\n", GetLastError()); + CloseServiceHandle(service); + + service = CreateServiceA(manager, "winetestsvc", "winetestsvc", SERVICE_START | DELETE, + SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, + "C:\windows\system32\winetestsvc.exe", NULL, NULL, NULL, NULL, NULL); + ok(!!service, "Failed to create service, error %u.\n", GetLastError()); + ret = StartServiceA(service, 0, NULL); + ok(!ret, "Expected failure.\n"); + todo_wine ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Got error %u.\n", GetLastError()); + + ret = DeleteService(service); + ok(ret, "Failed to delete service, error %u.\n", GetLastError()); + CloseServiceHandle(service); + + ret = DeleteFileA("C:\windows\syswow64\winetestsvc.exe"); + ok(ret, "Failed to delete file, error %u.\n", GetLastError()); + + file = CreateFileA("C:\windows\sysnative\winetestsvc.exe", GENERIC_WRITE, + 0, NULL, CREATE_ALWAYS, 0, NULL); + CloseHandle(file); + + service = CreateServiceA(manager, "winetestsvc", "winetestsvc", SERVICE_START | DELETE, + SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, + "C:\windows\system32\winetestsvc.exe service serve", NULL, NULL, NULL, NULL, NULL); + ok(!!service, "Failed to create service, error %u.\n", GetLastError()); + ret = StartServiceA(service, 0, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Got error %u.\n", GetLastError()); + + ret = DeleteService(service); + ok(ret, "Failed to delete service, error %u.\n", GetLastError()); + CloseServiceHandle(service); + + service = CreateServiceA(manager, "winetestsvc", "winetestsvc", SERVICE_START | DELETE, + SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, + "C:\windows\system32\winetestsvc.exe", NULL, NULL, NULL, NULL, NULL); + ok(!!service, "Failed to create service, error %u.\n", GetLastError()); + ret = StartServiceA(service, 0, NULL); + ok(!ret, "Expected failure.\n"); + todo_wine ok(GetLastError() == ERROR_BAD_EXE_FORMAT, "Got error %u.\n", GetLastError()); + + ret = DeleteService(service); + ok(ret, "Failed to delete service, error %u.\n", GetLastError()); + CloseServiceHandle(service); + + ret = DeleteFileA("C:\windows\sysnative\winetestsvc.exe"); + ok(ret, "Failed to delete file, error %u.\n", GetLastError()); + + CloseServiceHandle(service); + CloseServiceHandle(manager); +} + static void test_sequence(void) { SC_HANDLE scm_handle, svc_handle; @@ -2689,6 +2778,7 @@ START_TEST(service) test_query_svc(); test_enum_svc(); test_close(); + test_wow64(); /* Test the creation, querying and deletion of a service */ test_sequence(); test_queryconfig2(); diff --git a/programs/services/services.c b/programs/services/services.c index f4351d5866..75d8c17b0b 100644 --- a/programs/services/services.c +++ b/programs/services/services.c @@ -826,7 +826,7 @@ static DWORD get_service_binary_path(const struct service_entry *service_entry, ExpandEnvironmentStringsW(service_entry->config.lpBinaryPathName, *path, size);
/* if service image is configured to systemdir, redirect it to wow64 systemdir */ - if (service_entry->is_wow64) + if (service_entry->is_wow64 && !(service_entry->config.dwServiceType & (SERVICE_FILE_SYSTEM_DRIVER | SERVICE_KERNEL_DRIVER))) { WCHAR system_dir[MAX_PATH], *redirected; DWORD len;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=55580
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/ntoskrnl.exe/tests/driver.c:1633 Task: Patch failed to apply
=== debian10 (build log) ===
error: patch failed: dlls/ntoskrnl.exe/tests/driver.c:1633 Task: Patch failed to apply
=== debian10 (build log) ===
error: patch failed: dlls/ntoskrnl.exe/tests/driver.c:1633 Task: Patch failed to apply
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47623 Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec index 0b2a267d38..841fb6dfcd 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -33,6 +33,7 @@ @ stdcall -arch=win64 ExpInterlockedPopEntrySList(ptr) RtlInterlockedPopEntrySList @ stdcall -arch=win64 ExpInterlockedPushEntrySList(ptr ptr) RtlInterlockedPushEntrySList @ stub HalExamineMBR +@ stdcall -arch=arm,arm64,x86_64 InitializeSListHead(ptr) RtlInitializeSListHead @ stdcall -fastcall InterlockedCompareExchange(ptr long long) NTOSKRNL_InterlockedCompareExchange @ stdcall -fastcall InterlockedDecrement(ptr) NTOSKRNL_InterlockedDecrement @ stdcall -fastcall InterlockedExchange(ptr long) NTOSKRNL_InterlockedExchange
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=55581
Your paranoid android.
=== debian10 (build log) ===
error: patch failed: dlls/ntoskrnl.exe/tests/driver.c:1633 Task: Patch failed to apply
=== debian10 (build log) ===
error: patch failed: dlls/ntoskrnl.exe/tests/driver.c:1633 Task: Patch failed to apply
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=55577
Your paranoid android.
=== debian10 (32 bit report) ===
Report errors: ntoskrnl.exe:ntoskrnl contains a misplaced todo message for driver
=== debian10 (32 bit Chinese:China report) ===
Report errors: ntoskrnl.exe:ntoskrnl contains a misplaced todo message for driver
=== debian10 (32 bit WoW report) ===
Report errors: ntoskrnl.exe:ntoskrnl contains a misplaced todo message for driver
=== debian10 (64 bit WoW report) ===
Report errors: ntoskrnl.exe:ntoskrnl contains a misplaced todo message for driver