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).
-- v4: ntoskrnl: Implement IoGetDevicePropertyData().
From: Vibhav Pant vibhavp@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..73641ad3a0f 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 WINAPI 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 LOCALE_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*);
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 tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147925
Your paranoid android.
=== debian11b (64 bit WoW report) ===
ddraw: ddraw2.c:3735: Test failed: Expected screen size 1024x768, got 0x0.