Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/pnp.c | 81 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 3 deletions(-)
diff --git a/dlls/ntoskrnl.exe/pnp.c b/dlls/ntoskrnl.exe/pnp.c index 56b1cac3cc..1fda026310 100644 --- a/dlls/ntoskrnl.exe/pnp.c +++ b/dlls/ntoskrnl.exe/pnp.c @@ -480,7 +480,12 @@ void WINAPI IoInvalidateDeviceRelations( DEVICE_OBJECT *device_object, DEVICE_RE NTSTATUS WINAPI IoGetDeviceProperty( DEVICE_OBJECT *device, DEVICE_REGISTRY_PROPERTY property, ULONG length, void *buffer, ULONG *needed ) { - NTSTATUS status = STATUS_NOT_IMPLEMENTED; + SP_DEVINFO_DATA sp_device = {sizeof(sp_device)}; + WCHAR device_instance_id[MAX_DEVICE_ID_LEN]; + DWORD sp_property = -1; + NTSTATUS status; + HDEVINFO set; + TRACE("device %p, property %u, length %u, buffer %p, needed %p.\n", device, property, length, buffer, needed);
@@ -508,7 +513,7 @@ NTSTATUS WINAPI IoGetDeviceProperty( DEVICE_OBJECT *device, DEVICE_REGISTRY_PROP status = STATUS_BUFFER_TOO_SMALL;
ExFreePool( id ); - break; + return status; } case DevicePropertyPhysicalDeviceObjectName: { @@ -543,11 +548,81 @@ NTSTATUS WINAPI IoGetDeviceProperty( DEVICE_OBJECT *device, DEVICE_REGISTRY_PROP *needed = 0; } HeapFree(GetProcessHeap(), 0, name); - break; + return status; } + case DevicePropertyDeviceDescription: + sp_property = SPDRP_DEVICEDESC; + break; + case DevicePropertyHardwareID: + sp_property = SPDRP_HARDWAREID; + break; + case DevicePropertyCompatibleIDs: + sp_property = SPDRP_COMPATIBLEIDS; + break; + case DevicePropertyClassName: + sp_property = SPDRP_CLASS; + break; + case DevicePropertyClassGuid: + sp_property = SPDRP_CLASSGUID; + break; + case DevicePropertyManufacturer: + sp_property = SPDRP_MFG; + break; + case DevicePropertyFriendlyName: + sp_property = SPDRP_FRIENDLYNAME; + break; + case DevicePropertyLocationInformation: + sp_property = SPDRP_LOCATION_INFORMATION; + break; + case DevicePropertyBusTypeGuid: + sp_property = SPDRP_BUSTYPEGUID; + break; + case DevicePropertyLegacyBusType: + sp_property = SPDRP_LEGACYBUSTYPE; + break; + case DevicePropertyBusNumber: + sp_property = SPDRP_BUSNUMBER; + break; + case DevicePropertyAddress: + sp_property = SPDRP_ADDRESS; + break; + case DevicePropertyUINumber: + sp_property = SPDRP_UI_NUMBER; + break; + case DevicePropertyInstallState: + sp_property = SPDRP_INSTALL_STATE; + break; + case DevicePropertyRemovalPolicy: + sp_property = SPDRP_REMOVAL_POLICY; + break; default: FIXME("Unhandled property %u.\n", property); + return STATUS_NOT_IMPLEMENTED; + } + + if ((status = get_device_instance_id( device, device_instance_id ))) + return status; + + if ((set = SetupDiCreateDeviceInfoList( &GUID_NULL, NULL )) == INVALID_HANDLE_VALUE) + { + ERR("Failed to create device list, error %#x.\n", GetLastError()); + return GetLastError(); } + + if (!SetupDiOpenDeviceInfoW( set, device_instance_id, NULL, 0, &sp_device)) + { + ERR("Failed to open device, error %#x.\n", GetLastError()); + SetupDiDestroyDeviceInfoList( set ); + return GetLastError(); + } + + if (SetupDiGetDeviceRegistryPropertyW( set, &sp_device, sp_property, NULL, buffer, length, needed )) + status = STATUS_SUCCESS; + else + status = GetLastError(); + + SetupDiDestroyDeviceInfoList( set ); + return status; }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/pnp.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/dlls/ntoskrnl.exe/pnp.c b/dlls/ntoskrnl.exe/pnp.c index 1fda026310..fd9dfe5ed6 100644 --- a/dlls/ntoskrnl.exe/pnp.c +++ b/dlls/ntoskrnl.exe/pnp.c @@ -934,6 +934,9 @@ static NTSTATUS WINAPI pnp_manager_device_pnp( DEVICE_OBJECT *device, IRP *irp ) /* Nothing to do. */ irp->IoStatus.u.Status = STATUS_SUCCESS; break; + case IRP_MN_QUERY_CAPABILITIES: + irp->IoStatus.u.Status = STATUS_SUCCESS; + break; case IRP_MN_QUERY_ID: { BUS_QUERY_ID_TYPE type = stack->Parameters.QueryId.IdType;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/pnp.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/dlls/ntoskrnl.exe/pnp.c b/dlls/ntoskrnl.exe/pnp.c index fd9dfe5ed6..0e0471a446 100644 --- a/dlls/ntoskrnl.exe/pnp.c +++ b/dlls/ntoskrnl.exe/pnp.c @@ -928,6 +928,9 @@ static NTSTATUS WINAPI pnp_manager_device_pnp( DEVICE_OBJECT *device, IRP *irp )
switch (stack->MinorFunction) { + case IRP_MN_QUERY_DEVICE_RELATIONS: + /* The FDO above already handled this, so return the same status. */ + break; case IRP_MN_START_DEVICE: case IRP_MN_SURPRISE_REMOVAL: case IRP_MN_REMOVE_DEVICE:
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/pnp.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/ntoskrnl.exe/pnp.c b/dlls/ntoskrnl.exe/pnp.c index 0e0471a446..221e1dee45 100644 --- a/dlls/ntoskrnl.exe/pnp.c +++ b/dlls/ntoskrnl.exe/pnp.c @@ -226,10 +226,12 @@ static void load_function_driver( DEVICE_OBJECT *device, HDEVINFO set, SP_DEVINF return; }
+ TRACE("Calling AddDevice routine %p.\n", driver_obj->DriverExtension->AddDevice); if (driver_obj->DriverExtension->AddDevice) status = driver_obj->DriverExtension->AddDevice( driver_obj, device ); else status = STATUS_NOT_IMPLEMENTED; + TRACE("AddDevice routine %p returned %#x.\n", driver_obj->DriverExtension->AddDevice, status);
ObDereferenceObject( driver_obj );