[PATCH v2 0/1] MR6338: ntoskrnl: Implement IoGetDevicePropertyData().
IoGetDevicePropertyData is used to implement the `IOCTL_BTH_GET_DEVICE_INFO` Bluetooth IOCTL to fetch cached information for remote devices, without having to access the device extension pointer (which is arguably racy and more fragile). -- v2: ntoskrnl: Implement IoGetDevicePropertyData(). https://gitlab.winehq.org/wine/wine/-/merge_requests/6338
From: Vibhav Pant <vibhavp(a)gmail.com> --- dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 1 + dlls/ntoskrnl.exe/pnp.c | 47 +++++++++++++++++++++++++++++ include/ddk/wdm.h | 1 + 3 files changed, 49 insertions(+) diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec index 1bf8ce22fd0..e9ad2aa7e74 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -406,6 +406,7 @@ @ stdcall IoGetDeviceInterfaces(ptr ptr long ptr) @ stdcall IoGetDeviceObjectPointer(ptr long ptr ptr) @ stdcall IoGetDeviceProperty(ptr long long ptr ptr) +@ stdcall IoGetDevicePropertyData(ptr ptr long long long ptr ptr ptr) @ stub IoGetDeviceToVerify @ stub IoGetDiskDeviceObject @ stub IoGetDmaAdapter diff --git a/dlls/ntoskrnl.exe/pnp.c b/dlls/ntoskrnl.exe/pnp.c index 7444b81823c..78adbc32b8e 100644 --- a/dlls/ntoskrnl.exe/pnp.c +++ b/dlls/ntoskrnl.exe/pnp.c @@ -503,6 +503,53 @@ void WINAPI IoInvalidateDeviceRelations( DEVICE_OBJECT *device_object, DEVICE_RE } } +/*********************************************************************** + * IoGetDevicePropertyData (NTOSKRNL.EXE.@) + */ +NTSTATUS IoGetDevicePropertyData( DEVICE_OBJECT *device, const DEVPROPKEY *property_key, LCID lcid, + ULONG flags, ULONG size, void *data, ULONG *required_size, + DEVPROPTYPE *property_type ) +{ + SP_DEVINFO_DATA sp_device = {sizeof(sp_device)}; + WCHAR device_instance_id[MAX_DEVICE_ID_LEN]; + HDEVINFO set; + NTSTATUS status; + + TRACE( "device %p, property_key %s, lcid %#lx, flags %#lx, size %lu, data %p, required_size %p, property_type %p", + device, debugstr_propkey( property_key ), lcid, flags, size, data, required_size, + property_type ); + + if (lcid == LOCALE_SYSTEM_DEFAULT || lcid == LOCALE_USER_DEFAULT) return STATUS_INVALID_PARAMETER; + if (lcid != LOCALE_NEUTRAL) FIXME( "Only LOCAL_NEUTRAL is supported\n" ); + + status = get_device_instance_id( device, device_instance_id ); + if (status != STATUS_SUCCESS) return status; + + set = SetupDiCreateDeviceInfoList( &GUID_NULL, NULL ); + if (set == INVALID_HANDLE_VALUE) + { + ERR( "Failed to create device list, error %#lx.\n", GetLastError() ); + return GetLastError(); + } + + if (!SetupDiOpenDeviceInfoW( set, device_instance_id, NULL, 0, &sp_device )) + { + ERR( "Failed to open device, error %#lx.\n", GetLastError() ); + SetupDiDestroyDeviceInfoList( set ); + return GetLastError(); + } + + if (!SetupDiGetDevicePropertyW( set, &sp_device, property_key, property_type, data, size, required_size, flags )) + { + ERR( "Failed to get device property, error %#lx.\n", GetLastError()); + SetupDiDestroyDeviceInfoList( set ); + return GetLastError(); + } + + SetupDiDestroyDeviceInfoList( set ); + return STATUS_SUCCESS; +} + /*********************************************************************** * IoGetDeviceProperty (NTOSKRNL.EXE.@) */ diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h index 78d14a95b6a..e0c21d0ccfd 100644 --- a/include/ddk/wdm.h +++ b/include/ddk/wdm.h @@ -1765,6 +1765,7 @@ PEPROCESS WINAPI IoGetCurrentProcess(void); NTSTATUS WINAPI IoGetDeviceInterfaces(const GUID*,PDEVICE_OBJECT,ULONG,PWSTR*); NTSTATUS WINAPI IoGetDeviceObjectPointer(UNICODE_STRING*,ACCESS_MASK,PFILE_OBJECT*,PDEVICE_OBJECT*); NTSTATUS WINAPI IoGetDeviceProperty(PDEVICE_OBJECT,DEVICE_REGISTRY_PROPERTY,ULONG,PVOID,PULONG); +NTSTATUS WINAPI IoGetDevicePropertyData(PDEVICE_OBJECT,const DEVPROPKEY*,LCID,ULONG,ULONG,void*,ULONG*,DEVPROPTYPE*); PVOID WINAPI IoGetDriverObjectExtension(PDRIVER_OBJECT,PVOID); PDEVICE_OBJECT WINAPI IoGetRelatedDeviceObject(PFILE_OBJECT); void WINAPI IoGetStackLimits(ULONG_PTR*,ULONG_PTR*); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6338
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147923 Your paranoid android. === debian11 (build log) === ../wine/dlls/ntoskrnl.exe/pnp.c:509:10: error: conflicting types for ‘IoGetDevicePropertyData’ Task: The win32 Wine build failed === debian11b (build log) === ../wine/dlls/ntoskrnl.exe/pnp.c:509:10: error: conflicting types for ‘IoGetDevicePropertyData’ Task: The wow32 Wine build failed
participants (3)
-
Marvin -
Vibhav Pant -
Vibhav Pant (@vibhavp)