I was reading about file system stack and found a source code and i am trying to understand what it is actually doing
it is finding the device object of \device\harddisk0\partition0 and then it sends a IRP_MJ_PNP request to it and builds the IRP using IoBuildSynchronousFsdRequest, sets the minorfunc to IRP_MN_QUERY_DEVICE_RELATIONS and QueryDeviceRelations.Type to TargetDeviceRelation
now can someone explain what does this actually do? whats the purpose of IRP_MN_QUERY_DEVICE_RELATIONS regarding the partition0 device object and whats the deal with this TargetDeviceRelation? where can i read more about this?
KeInitializeEvent( &event, NotificationEvent, FALSE );
irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP,
DeviceObject,
NULL,
0,
NULL,
&event,
&ioStatusBlock );
if (irp == NULL) {
status = STATUS_INSUFFICIENT_RESOURCES;
goto End;
}
irpStack = IoGetNextIrpStackLocation( irp );
irpStack->MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS;
irpStack->Parameters.QueryDeviceRelations.Type = TargetDeviceRelation;
irp->IoStatus.Status = STATUS_NOT_SUPPORTED ;
status = IoCallDriver( DeviceObject, irp );
if (status == STATUS_PENDING) {
KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL );
status = ioStatusBlock.Status;}