Use device::irp_mj.dev_ctl(), instead.
[Project]\r
FileName=WinVBlock.dev\r
Name=WinVBlock\r
-UnitCount=69\r
+UnitCount=67\r
PchHead=-1\r
PchSource=-1\r
Ver=3\r
OverrideBuildCmd=0\r
BuildCmd=\r
\r
-[Unit29]\r
-FileName=src\include\bus_dev_ctl.h\r
-CompileCpp=1\r
-Folder=Include\r
-Compile=1\r
-Link=1\r
-Priority=1000\r
-OverrideBuildCmd=0\r
-BuildCmd=\r
-\r
[Unit30]\r
-FileName=src\include\bus_pnp.h\r
-CompileCpp=1\r
-Folder=Include\r
-Compile=1\r
-Link=1\r
-Priority=1000\r
-OverrideBuildCmd=0\r
-BuildCmd=\r
-\r
-[Unit31]\r
FileName=src\include\debug.h\r
CompileCpp=1\r
Folder=Include\r
OverrideBuildCmd=0\r
BuildCmd=\r
\r
-[Unit32]\r
+[Unit31]\r
FileName=src\include\disk.h\r
CompileCpp=1\r
Folder=Include\r
BuildCmd=\r
\r
[Unit33]\r
-FileName=src\include\disk_dev_ctl.h\r
+FileName=src\include\disk_scsi.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit34]\r
-FileName=src\include\disk_pnp.h\r
+FileName=src\include\driver.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit35]\r
-FileName=src\include\disk_scsi.h\r
+FileName=src\include\filedisk.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit36]\r
-FileName=src\include\driver.h\r
+FileName=src\include\grub4dos.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit37]\r
-FileName=src\include\filedisk.h\r
+FileName=src\include\httpdisk.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit38]\r
-FileName=src\include\grub4dos.h\r
+FileName=src\include\irp.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit39]\r
-FileName=src\include\httpdisk.h\r
+FileName=src\include\mdi.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit40]\r
-FileName=src\include\irp.h\r
+FileName=src\include\memdisk.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit41]\r
-FileName=src\include\mdi.h\r
+FileName=src\include\mount.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit42]\r
-FileName=src\include\memdisk.h\r
+FileName=src\include\portable.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit43]\r
-FileName=src\include\mount.h\r
+FileName=src\include\probe.h\r
Folder=Include\r
Compile=1\r
Link=1\r
CompileCpp=1\r
\r
[Unit44]\r
-FileName=src\include\portable.h\r
+FileName=src\include\protocol.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit45]\r
-FileName=src\include\probe.h\r
+FileName=src\include\ramdisk.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit46]\r
-FileName=src\include\protocol.h\r
+FileName=src\include\registry.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit47]\r
-FileName=src\include\ramdisk.h\r
+FileName=src\include\resource.h\r
Folder=Include\r
Compile=1\r
Link=1\r
CompileCpp=1\r
\r
[Unit48]\r
-FileName=src\include\registry.h\r
+FileName=src\include\winvblock.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit49]\r
-FileName=src\include\resource.h\r
+FileName=src\util\mount.c\r
CompileCpp=1\r
-Folder=Include\r
+Folder=Util\r
Compile=1\r
Link=1\r
Priority=1000\r
BuildCmd=\r
\r
[Unit50]\r
-FileName=src\include\winvblock.h\r
+FileName=src\aoe\aoe.rc\r
CompileCpp=1\r
-Folder=Include\r
+Folder=AoE\r
Compile=1\r
-Link=1\r
+Link=0\r
Priority=1000\r
OverrideBuildCmd=0\r
BuildCmd=\r
\r
[Unit51]\r
-FileName=src\util\mount.c\r
-Folder=Util\r
+FileName=src\include\device.h\r
+Folder=Include\r
Compile=1\r
Link=1\r
Priority=1000\r
CompileCpp=1\r
\r
[Unit52]\r
-FileName=src\aoe\aoe.rc\r
+FileName=src\winvblock\device.c\r
CompileCpp=1\r
-Folder=AoE\r
+Folder=WinVBlock\r
Compile=1\r
-Link=0\r
+Link=1\r
Priority=1000\r
OverrideBuildCmd=0\r
BuildCmd=\r
BuildCmd=\r
\r
[Unit53]\r
-FileName=src\include\device.h\r
-Folder=Include\r
+FileName=src\winvblock\filedisk\filedisk.c\r
+Folder=WinVBlock/FileDisk\r
Compile=1\r
Link=1\r
Priority=1000\r
CompileCpp=1\r
\r
[Unit54]\r
-FileName=src\winvblock\device.c\r
+FileName=src\winvblock\filedisk\grub4dos.c\r
CompileCpp=1\r
-Folder=WinVBlock\r
+Folder=WinVBlock/FileDisk\r
Compile=1\r
Link=1\r
Priority=1000\r
BuildCmd=\r
\r
[Unit55]\r
-FileName=src\winvblock\filedisk\filedisk.c\r
+FileName=src\include\byte.h\r
CompileCpp=1\r
-Folder=WinVBlock/FileDisk\r
+Folder=Include\r
Compile=1\r
Link=1\r
Priority=1000\r
BuildCmd=\r
\r
[Unit56]\r
-FileName=src\winvblock\filedisk\grub4dos.c\r
+FileName=src\include\msvhd.h\r
CompileCpp=1\r
-Folder=WinVBlock/FileDisk\r
+Folder=Include\r
Compile=1\r
Link=1\r
Priority=1000\r
BuildCmd=\r
\r
[Unit57]\r
-FileName=src\include\byte.h\r
+FileName=src\util\winvblock.rc\r
CompileCpp=1\r
-Folder=Include\r
+Folder=Util\r
Compile=1\r
-Link=1\r
+Link=0\r
Priority=1000\r
OverrideBuildCmd=0\r
BuildCmd=\r
\r
[Unit58]\r
-FileName=src\include\msvhd.h\r
+FileName=src\include\wv_stdlib.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit59]\r
-FileName=src\util\winvblock.rc\r
-Folder=Util\r
+FileName=src\winvblock\wv_stdlib.c\r
+Folder=WinVBlock\r
Compile=1\r
-Link=0\r
+Link=1\r
Priority=1000\r
OverrideBuildCmd=0\r
BuildCmd=\r
+CompileCpp=1\r
\r
[Unit61]\r
-FileName=src\winvblock\wv_stdlib.c\r
+FileName=src\aoe\wv_stdlib.c\r
CompileCpp=1\r
-Folder=WinVBlock\r
+Folder=AoE\r
Compile=1\r
Link=1\r
Priority=1000\r
BuildCmd=\r
\r
[Unit60]\r
-FileName=src\include\wv_stdlib.h\r
+FileName=src\include\wv_stddef.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit62]\r
-FileName=src\include\wv_stddef.h\r
+FileName=src\include\wv_string.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit63]\r
-FileName=src\aoe\wv_stdlib.c\r
+FileName=src\winvblock\wv_string.c\r
CompileCpp=1\r
-Folder=AoE\r
+Folder=WinVBlock\r
Compile=1\r
Link=1\r
Priority=1000\r
BuildCmd=\r
\r
[Unit64]\r
-FileName=src\include\wv_string.h\r
+FileName=src\include\wv_stdbool.h\r
CompileCpp=1\r
Folder=Include\r
Compile=1\r
BuildCmd=\r
\r
[Unit65]\r
-FileName=src\winvblock\wv_string.c\r
+FileName=src\aoe\wv_string.c\r
CompileCpp=1\r
-Folder=WinVBlock\r
+Folder=AoE\r
Compile=1\r
Link=1\r
Priority=1000\r
BuildCmd=\r
\r
[Unit66]\r
-FileName=src\include\wv_stdbool.h\r
+FileName=src\aoe\bus.c\r
CompileCpp=1\r
-Folder=Include\r
+Folder=AoE\r
Compile=1\r
Link=1\r
Priority=1000\r
BuildCmd=\r
\r
[Unit67]\r
-FileName=src\aoe\wv_string.c\r
+FileName=src\include\aoe_bus.h\r
CompileCpp=1\r
-Folder=AoE\r
+Folder=Include\r
Compile=1\r
Link=1\r
Priority=1000\r
OverrideBuildCmd=0\r
BuildCmd=\r
\r
+[Unit29]\r
+FileName=src\include\bus_pnp.h\r
+CompileCpp=1\r
+Folder=Include\r
+Compile=1\r
+Link=1\r
+Priority=1000\r
+OverrideBuildCmd=0\r
+BuildCmd=\r
+\r
+[Unit32]\r
+FileName=src\include\disk_pnp.h\r
+CompileCpp=1\r
+Folder=Include\r
+Compile=1\r
+Link=1\r
+Priority=1000\r
+OverrideBuildCmd=0\r
+BuildCmd=\r
+\r
+++ /dev/null
-/**
- * Copyright (C) 2009-2010, Shao Miller <shao.miller@yrdsb.edu.on.ca>.
- * Copyright 2006-2008, V.
- * For WinAoE contact information, see http://winaoe.org/
- *
- * This file is part of WinVBlock, derived from WinAoE.
- *
- * WinVBlock is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * WinVBlock is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef _BUS_DEV_CTL_H
-# define _BUS_DEV_CTL_H
-
-/**
- * @file
- *
- * Bus Device Control IRP handling.
- */
-
-extern irp__handler bus_dev_ctl__dispatch;
-
-#endif /* _BUS_DEV_CTL_H */
IN PIRP
);
+/**
+ * The prototype for a device IRP_MJ_DEVICE_CONTROL dispatch.
+ *
+ * @v dev Points to the device.
+ * @v irp Points to the IRP.
+ * @v code The I/O control code.
+ * @ret NTSTATUS The status of processing the IRP for the device.
+ */
+typedef NTSTATUS STDCALL device__dev_ctl_func(
+ IN struct device__type *,
+ IN PIRP,
+ IN ULONG POINTER_ALIGNMENT
+ );
+
+
/* IRP major function handler table. */
struct device__irp_mj {
device__dispatch_func * power;
device__dispatch_func * sys_ctl;
+ device__dev_ctl_func * dev_ctl;
};
/* Details common to all devices this driver works with */
+++ /dev/null
-/**
- * Copyright (C) 2009-2010, Shao Miller <shao.miller@yrdsb.edu.on.ca>.
- * Copyright 2006-2008, V.
- * For WinAoE contact information, see http://winaoe.org/
- *
- * This file is part of WinVBlock, derived from WinAoE.
- *
- * WinVBlock is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * WinVBlock is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef _DISK_DEV_CTL_H
-# define _DISK_DEV_CTL_H
-
-/**
- * @file
- *
- * Disk Device Control IRP handling.
- */
-
-extern irp__handler disk_dev_ctl__dispatch;
-
-#endif /* _DISK_DEV_CTL_H */
UNICODE_STRING filepath_unicode;
};
-extern irp__handler filedisk__attach;
+extern device__dispatch_func filedisk__attach;
/**
* Initialize the global, file-backed disk-common environment
#include "device.h"
#include "bus.h"
#include "bus_pnp.h"
-#include "bus_dev_ctl.h"
#include "debug.h"
+/* IRP_MJ_DEVICE_CONTROL dispatcher from bus/dev_ctl.c */
+extern device__dev_ctl_func bus_dev_ctl__dispatch;
+
/* Forward declarations. */
static device__free_func bus__free_;
static device__create_pdo_func bus__create_pdo_;
struct device__irp_mj bus__irp_mj_ = {
bus__power_,
bus__sys_ctl_,
+ bus_dev_ctl__dispatch,
};
/**
* Why? It sets completion to true, so others won't be called.
*/
{ 0, 0, TRUE, TRUE, driver__not_supported },
- { IRP_MJ_DEVICE_CONTROL, 0, FALSE, TRUE, bus_dev_ctl__dispatch },
{ IRP_MJ_PNP, 0, FALSE, TRUE, bus_pnp__simple },
{ IRP_MJ_PNP,
IRP_MN_START_DEVICE, FALSE, FALSE, bus_pnp__start_dev },
#include "debug.h"
#include "filedisk.h"
-static NTSTATUS STDCALL disk_detach(
- IN PDEVICE_OBJECT dev_obj,
- IN PIRP irp,
- IN PIO_STACK_LOCATION io_stack_loc,
+/* Forward declarations. */
+static device__dispatch_func bus_dev_ctl__disk_detach_;
+
+static NTSTATUS STDCALL bus_dev_ctl__disk_detach_(
IN struct device__type * dev,
- OUT winvblock__bool_ptr completion
+ IN PIRP irp
) {
winvblock__uint8_ptr buffer = irp->AssociatedIrp.SystemBuffer;
winvblock__uint32 disk_num = *(winvblock__uint32_ptr) buffer;
if (disk_walker->BootDrive) {
DBG("Cannot unmount a boot drive.\n");
irp->IoStatus.Information = 0;
- *completion = TRUE;
return STATUS_INVALID_DEVICE_REQUEST;
}
DBG("Deleting disk %d\n", dev_walker->dev_num);
}
bus->Children--;
irp->IoStatus.Information = 0;
- *completion = TRUE;
return STATUS_SUCCESS;
}
NTSTATUS STDCALL bus_dev_ctl__dispatch(
- IN PDEVICE_OBJECT dev_obj,
- IN PIRP irp,
- IN PIO_STACK_LOCATION io_stack_loc,
IN struct device__type * dev,
- OUT winvblock__bool_ptr completion
+ IN PIRP irp,
+ IN ULONG POINTER_ALIGNMENT code
) {
NTSTATUS status;
- switch (io_stack_loc->Parameters.DeviceIoControl.IoControlCode) {
+
+ switch (code) {
case IOCTL_FILE_ATTACH:
- status = filedisk__attach(
- dev_obj,
- irp,
- io_stack_loc,
- dev,
- completion
- );
+ status = filedisk__attach(dev, irp);
break;
case IOCTL_FILE_DETACH:
- status = disk_detach(
- dev_obj,
- irp,
- io_stack_loc,
- dev,
- completion
- );
+ status = bus_dev_ctl__disk_detach_(dev, irp);
break;
default:
irp->IoStatus.Status = status;
IoCompleteRequest(irp, IO_NO_INCREMENT);
- *completion = TRUE;
return status;
}
#include "disk.h"
#include "debug.h"
-static NTSTATUS STDCALL storage_query_prop(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PIO_STACK_LOCATION Stack,
- IN struct device__type * dev_ptr,
- OUT winvblock__bool_ptr completion_ptr
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- PSTORAGE_PROPERTY_QUERY storage_prop_query = Irp->AssociatedIrp.SystemBuffer;
- winvblock__uint32 copy_size;
- disk__type_ptr disk_ptr;
- STORAGE_ADAPTER_DESCRIPTOR storage_adapter_desc;
- STORAGE_DEVICE_DESCRIPTOR storage_dev_desc;
-
- disk_ptr = disk__get_ptr ( dev_ptr );
- if ( storage_prop_query->PropertyId == StorageAdapterProperty
- && storage_prop_query->QueryType == PropertyStandardQuery )
- {
- copy_size =
- ( Stack->Parameters.DeviceIoControl.OutputBufferLength <
- sizeof ( STORAGE_ADAPTER_DESCRIPTOR ) ? Stack->
- Parameters.DeviceIoControl.
- OutputBufferLength : sizeof ( STORAGE_ADAPTER_DESCRIPTOR ) );
- storage_adapter_desc.Version = sizeof ( STORAGE_ADAPTER_DESCRIPTOR );
- storage_adapter_desc.Size = sizeof ( STORAGE_ADAPTER_DESCRIPTOR );
- storage_adapter_desc.MaximumTransferLength =
- disk__max_xfer_len ( disk_ptr );
-#if 0
- storage_adapter_desc.MaximumTransferLength = SECTORSIZE * POOLSIZE;
-#endif
- storage_adapter_desc.MaximumPhysicalPages = ( winvblock__uint32 ) - 1;
- storage_adapter_desc.AlignmentMask = 0;
- storage_adapter_desc.AdapterUsesPio = TRUE;
- storage_adapter_desc.AdapterScansDown = FALSE;
- storage_adapter_desc.CommandQueueing = FALSE;
- storage_adapter_desc.AcceleratedTransfer = FALSE;
- storage_adapter_desc.BusType = BusTypeScsi;
- RtlCopyMemory ( Irp->AssociatedIrp.SystemBuffer, &storage_adapter_desc,
- copy_size );
- Irp->IoStatus.Information = ( ULONG_PTR ) copy_size;
- status = STATUS_SUCCESS;
- }
-
- if ( storage_prop_query->PropertyId == StorageDeviceProperty
- && storage_prop_query->QueryType == PropertyStandardQuery )
- {
- copy_size =
- ( Stack->Parameters.DeviceIoControl.OutputBufferLength <
- sizeof ( STORAGE_DEVICE_DESCRIPTOR ) ? Stack->
- Parameters.DeviceIoControl.
- OutputBufferLength : sizeof ( STORAGE_DEVICE_DESCRIPTOR ) );
- storage_dev_desc.Version = sizeof ( STORAGE_DEVICE_DESCRIPTOR );
- storage_dev_desc.Size = sizeof ( STORAGE_DEVICE_DESCRIPTOR );
- storage_dev_desc.DeviceType = DIRECT_ACCESS_DEVICE;
- storage_dev_desc.DeviceTypeModifier = 0;
- storage_dev_desc.RemovableMedia = disk__removable[disk_ptr->media];
- storage_dev_desc.CommandQueueing = FALSE;
- storage_dev_desc.VendorIdOffset = 0;
- storage_dev_desc.ProductIdOffset = 0;
- storage_dev_desc.ProductRevisionOffset = 0;
- storage_dev_desc.SerialNumberOffset = 0;
- storage_dev_desc.BusType = BusTypeScsi;
- storage_dev_desc.RawPropertiesLength = 0;
- RtlCopyMemory ( Irp->AssociatedIrp.SystemBuffer, &storage_dev_desc,
- copy_size );
- Irp->IoStatus.Information = ( ULONG_PTR ) copy_size;
- status = STATUS_SUCCESS;
- }
-
- if ( status == STATUS_INVALID_PARAMETER )
- {
- DBG ( "!!Invalid IOCTL_STORAGE_QUERY_PROPERTY "
- "(PropertyId: %08x / QueryType: %08x)!!\n",
- storage_prop_query->PropertyId, storage_prop_query->QueryType );
- }
- return status;
-}
-
-static NTSTATUS STDCALL disk_get_drive_geom(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PIO_STACK_LOCATION Stack,
- IN struct device__type * dev_ptr,
- OUT winvblock__bool_ptr completion_ptr
- )
-{
- winvblock__uint32 copy_size;
- DISK_GEOMETRY disk_geom;
- disk__type_ptr disk_ptr;
-
- copy_size =
- ( Stack->Parameters.DeviceIoControl.OutputBufferLength <
- sizeof ( DISK_GEOMETRY ) ? Stack->Parameters.DeviceIoControl.
- OutputBufferLength : sizeof ( DISK_GEOMETRY ) );
- disk_geom.MediaType = FixedMedia;
- disk_ptr = disk__get_ptr ( dev_ptr );
- disk_geom.Cylinders.QuadPart = disk_ptr->Cylinders;
- disk_geom.TracksPerCylinder = disk_ptr->Heads;
- disk_geom.SectorsPerTrack = disk_ptr->Sectors;
- disk_geom.BytesPerSector = disk_ptr->SectorSize;
- RtlCopyMemory ( Irp->AssociatedIrp.SystemBuffer, &disk_geom, copy_size );
- Irp->IoStatus.Information = ( ULONG_PTR ) copy_size;
- return STATUS_SUCCESS;
-}
-
-static NTSTATUS STDCALL scsi_get_address(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PIO_STACK_LOCATION Stack,
- IN struct device__type * dev_ptr,
- OUT winvblock__bool_ptr completion_ptr
- )
-{
- winvblock__uint32 copy_size;
- SCSI_ADDRESS scsi_address;
-
- copy_size =
- ( Stack->Parameters.DeviceIoControl.OutputBufferLength <
- sizeof ( SCSI_ADDRESS ) ? Stack->Parameters.DeviceIoControl.
- OutputBufferLength : sizeof ( SCSI_ADDRESS ) );
- scsi_address.Length = sizeof ( SCSI_ADDRESS );
- scsi_address.PortNumber = 0;
- scsi_address.PathId = 0;
- scsi_address.TargetId = (winvblock__uint8) dev_ptr->dev_num;
- scsi_address.Lun = 0;
- RtlCopyMemory ( Irp->AssociatedIrp.SystemBuffer, &scsi_address, copy_size );
- Irp->IoStatus.Information = ( ULONG_PTR ) copy_size;
- return STATUS_SUCCESS;
-}
+/* Forward declarations. */
+static device__dispatch_func disk_dev_ctl__storage_query_prop_;
+static device__dispatch_func disk_dev_ctl__get_geom_;
+static device__dispatch_func disk_dev_ctl__scsi_get_address_;
+
+static NTSTATUS STDCALL disk_dev_ctl__storage_query_prop_(
+ IN struct device__type * dev,
+ IN PIRP irp
+ ) {
+ disk__type_ptr disk;
+ PIO_STACK_LOCATION io_stack_loc = IoGetCurrentIrpStackLocation(irp);
+ NTSTATUS status = STATUS_INVALID_PARAMETER;
+ PSTORAGE_PROPERTY_QUERY storage_prop_query = irp->AssociatedIrp.SystemBuffer;
+ winvblock__uint32 copy_size;
+ STORAGE_ADAPTER_DESCRIPTOR storage_adapter_desc;
+ STORAGE_DEVICE_DESCRIPTOR storage_dev_desc;
+
+ disk = disk__get_ptr(dev);
+ if (
+ storage_prop_query->PropertyId == StorageAdapterProperty &&
+ storage_prop_query->QueryType == PropertyStandardQuery
+ ) {
+ copy_size = (
+ io_stack_loc->Parameters.DeviceIoControl.OutputBufferLength <
+ sizeof (STORAGE_ADAPTER_DESCRIPTOR) ?
+ io_stack_loc->Parameters.DeviceIoControl.OutputBufferLength :
+ sizeof (STORAGE_ADAPTER_DESCRIPTOR)
+ );
+ storage_adapter_desc.Version = sizeof (STORAGE_ADAPTER_DESCRIPTOR);
+ storage_adapter_desc.Size = sizeof (STORAGE_ADAPTER_DESCRIPTOR);
+ storage_adapter_desc.MaximumTransferLength =
+ disk__max_xfer_len(disk);
+ #if 0
+ storage_adapter_desc.MaximumTransferLength = SECTORSIZE * POOLSIZE;
+ #endif
+ storage_adapter_desc.MaximumPhysicalPages = (winvblock__uint32) -1;
+ storage_adapter_desc.AlignmentMask = 0;
+ storage_adapter_desc.AdapterUsesPio = TRUE;
+ storage_adapter_desc.AdapterScansDown = FALSE;
+ storage_adapter_desc.CommandQueueing = FALSE;
+ storage_adapter_desc.AcceleratedTransfer = FALSE;
+ storage_adapter_desc.BusType = BusTypeScsi;
+ RtlCopyMemory(
+ irp->AssociatedIrp.SystemBuffer,
+ &storage_adapter_desc,
+ copy_size
+ );
+ irp->IoStatus.Information = (ULONG_PTR) copy_size;
+ status = STATUS_SUCCESS;
+ }
+
+ if (
+ storage_prop_query->PropertyId == StorageDeviceProperty &&
+ storage_prop_query->QueryType == PropertyStandardQuery
+ ) {
+ copy_size = (
+ io_stack_loc->Parameters.DeviceIoControl.OutputBufferLength <
+ sizeof (STORAGE_DEVICE_DESCRIPTOR) ?
+ io_stack_loc->Parameters.DeviceIoControl.OutputBufferLength :
+ sizeof (STORAGE_DEVICE_DESCRIPTOR)
+ );
+ storage_dev_desc.Version = sizeof (STORAGE_DEVICE_DESCRIPTOR);
+ storage_dev_desc.Size = sizeof (STORAGE_DEVICE_DESCRIPTOR);
+ storage_dev_desc.DeviceType = DIRECT_ACCESS_DEVICE;
+ storage_dev_desc.DeviceTypeModifier = 0;
+ storage_dev_desc.RemovableMedia = disk__removable[disk->media];
+ storage_dev_desc.CommandQueueing = FALSE;
+ storage_dev_desc.VendorIdOffset = 0;
+ storage_dev_desc.ProductIdOffset = 0;
+ storage_dev_desc.ProductRevisionOffset = 0;
+ storage_dev_desc.SerialNumberOffset = 0;
+ storage_dev_desc.BusType = BusTypeScsi;
+ storage_dev_desc.RawPropertiesLength = 0;
+ RtlCopyMemory(
+ irp->AssociatedIrp.SystemBuffer,
+ &storage_dev_desc,
+ copy_size
+ );
+ irp->IoStatus.Information = (ULONG_PTR) copy_size;
+ status = STATUS_SUCCESS;
+ }
+
+ if (status == STATUS_INVALID_PARAMETER) {
+ DBG(
+ "!!Invalid IOCTL_STORAGE_QUERY_PROPERTY "
+ "(PropertyId: %08x / QueryType: %08x)!!\n",
+ storage_prop_query->PropertyId,
+ storage_prop_query->QueryType
+ );
+ }
+ return status;
+ }
+
+static NTSTATUS STDCALL disk_dev_ctl__get_geom_(
+ IN struct device__type * dev,
+ IN PIRP irp
+ ) {
+ PIO_STACK_LOCATION io_stack_loc = IoGetCurrentIrpStackLocation(irp);
+ winvblock__uint32 copy_size;
+ DISK_GEOMETRY disk_geom;
+ disk__type_ptr disk;
+
+ copy_size = (
+ io_stack_loc->Parameters.DeviceIoControl.OutputBufferLength <
+ sizeof (DISK_GEOMETRY) ?
+ io_stack_loc->Parameters.DeviceIoControl.OutputBufferLength :
+ sizeof (DISK_GEOMETRY)
+ );
+ disk_geom.MediaType = FixedMedia;
+ disk = disk__get_ptr(dev);
+ disk_geom.Cylinders.QuadPart = disk->Cylinders;
+ disk_geom.TracksPerCylinder = disk->Heads;
+ disk_geom.SectorsPerTrack = disk->Sectors;
+ disk_geom.BytesPerSector = disk->SectorSize;
+ RtlCopyMemory(
+ irp->AssociatedIrp.SystemBuffer,
+ &disk_geom,
+ copy_size
+ );
+ irp->IoStatus.Information = (ULONG_PTR) copy_size;
+ return STATUS_SUCCESS;
+ }
+
+static NTSTATUS STDCALL disk_dev_ctl__scsi_get_address_(
+ IN struct device__type * dev,
+ IN PIRP irp
+ ) {
+ PIO_STACK_LOCATION io_stack_loc= IoGetCurrentIrpStackLocation(irp);
+ winvblock__uint32 copy_size;
+ SCSI_ADDRESS scsi_address;
+
+ copy_size = (
+ io_stack_loc->Parameters.DeviceIoControl.OutputBufferLength <
+ sizeof (SCSI_ADDRESS) ?
+ io_stack_loc->Parameters.DeviceIoControl.OutputBufferLength :
+ sizeof (SCSI_ADDRESS)
+ );
+ scsi_address.Length = sizeof (SCSI_ADDRESS);
+ scsi_address.PortNumber = 0;
+ scsi_address.PathId = 0;
+ scsi_address.TargetId = (winvblock__uint8) dev->dev_num;
+ scsi_address.Lun = 0;
+ RtlCopyMemory(
+ irp->AssociatedIrp.SystemBuffer,
+ &scsi_address,
+ copy_size
+ );
+ irp->IoStatus.Information = (ULONG_PTR) copy_size;
+ return STATUS_SUCCESS;
+ }
NTSTATUS STDCALL disk_dev_ctl__dispatch(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PIO_STACK_LOCATION Stack,
- IN struct device__type * dev_ptr,
- OUT winvblock__bool_ptr completion_ptr
- )
-{
- NTSTATUS status;
-
- switch ( Stack->Parameters.DeviceIoControl.IoControlCode )
- {
- case IOCTL_STORAGE_QUERY_PROPERTY:
- status =
- storage_query_prop ( DeviceObject, Irp, Stack, dev_ptr,
- completion_ptr );
- break;
- case IOCTL_DISK_GET_DRIVE_GEOMETRY:
- status =
- disk_get_drive_geom ( DeviceObject, Irp, Stack, dev_ptr,
- completion_ptr );
- break;
- case IOCTL_SCSI_GET_ADDRESS:
- status =
- scsi_get_address ( DeviceObject, Irp, Stack, dev_ptr,
- completion_ptr );
- break;
- /*
- * Some cases that pop up on Windows Server 2003
- */
-#if 0
- case IOCTL_MOUNTDEV_UNIQUE_ID_CHANGE_NOTIFY:
- case IOCTL_MOUNTDEV_LINK_CREATED:
- case IOCTL_MOUNTDEV_QUERY_STABLE_GUID:
- case IOCTL_VOLUME_ONLINE:
- Irp->IoStatus.Information = 0;
- status = STATUS_SUCCESS;
- break;
-#endif
- default:
- Irp->IoStatus.Information = 0;
- status = STATUS_INVALID_PARAMETER;
- }
-
- Irp->IoStatus.Status = status;
- IoCompleteRequest ( Irp, IO_NO_INCREMENT );
- *completion_ptr = TRUE;
- return status;
-}
+ IN struct device__type * dev,
+ IN PIRP irp,
+ IN ULONG POINTER_ALIGNMENT code
+ ) {
+ NTSTATUS status;
+
+ switch (code) {
+ case IOCTL_STORAGE_QUERY_PROPERTY:
+ status = disk_dev_ctl__storage_query_prop_(dev, irp);
+ break;
+
+ case IOCTL_DISK_GET_DRIVE_GEOMETRY:
+ status = disk_dev_ctl__get_geom_(dev, irp);
+ break;
+
+ case IOCTL_SCSI_GET_ADDRESS:
+ status = disk_dev_ctl__scsi_get_address_(dev, irp);
+ break;
+
+ /* Some cases that pop up on Windows Server 2003. */
+ #if 0
+ case IOCTL_MOUNTDEV_UNIQUE_ID_CHANGE_NOTIFY:
+ case IOCTL_MOUNTDEV_LINK_CREATED:
+ case IOCTL_MOUNTDEV_QUERY_STABLE_GUID:
+ case IOCTL_VOLUME_ONLINE:
+ irp->IoStatus.Information = 0;
+ status = STATUS_SUCCESS;
+ break;
+ #endif
+
+ default:
+ irp->IoStatus.Information = 0;
+ status = STATUS_INVALID_PARAMETER;
+ }
+
+ irp->IoStatus.Status = status;
+ IoCompleteRequest(irp, IO_NO_INCREMENT);
+ return status;
+ }
#include "device.h"
#include "disk.h"
#include "disk_pnp.h"
-#include "disk_dev_ctl.h"
#include "disk_scsi.h"
#include "debug.h"
}
#endif
+/* IRP_MJ_DEVICE_CONTROL dispatcher from disk/dev_ctl.c */
+extern device__dev_ctl_func disk_dev_ctl__dispatch;
+
/* Forward declarations. */
static device__free_func free_disk;
static device__dispatch_func disk__power_;
struct device__irp_mj disk__irp_mj_ = {
disk__power_,
disk__sys_ctl_,
+ disk_dev_ctl__dispatch,
};
static
* Why? It sets completion to true, so others won't be called.
*/
{ 0, 0, TRUE, TRUE, driver__not_supported },
- { IRP_MJ_DEVICE_CONTROL, 0, FALSE, TRUE, disk_dev_ctl__dispatch },
{ IRP_MJ_SCSI, 0, FALSE, TRUE, disk_scsi__dispatch },
{ IRP_MJ_PNP, 0, FALSE, TRUE, disk_pnp__simple },
{ IRP_MJ_PNP,
static driver__dispatch_func driver__dispatch_power_;
static driver__dispatch_func driver__dispatch_create_close_;
static driver__dispatch_func driver__dispatch_sys_ctl_;
+static driver__dispatch_func driver__dispatch_dev_ctl_;
static driver__dispatch_func driver__dispatch_;
static void STDCALL driver__unload_(IN PDRIVER_OBJECT);
DriverObject->MajorFunction[IRP_MJ_CLOSE] = driver__dispatch_create_close_;
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] =
driver__dispatch_sys_ctl_;
- DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = driver__dispatch_;
+ DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
+ driver__dispatch_dev_ctl_;
DriverObject->MajorFunction[IRP_MJ_SCSI] = driver__dispatch_;
/* Set the driver Unload callback. */
DriverObject->DriverUnload = driver__unload_;
return driver__complete_irp(irp, 0, STATUS_NOT_SUPPORTED);
}
+/* Handle an IRP_MJ_DEVICE_CONTROL IRP. */
+static NTSTATUS driver__dispatch_dev_ctl_(
+ IN PDEVICE_OBJECT dev_obj,
+ IN PIRP irp
+ ) {
+ /* device__get() checks for a NULL dev_obj */
+ struct device__type * dev = device__get(dev_obj);
+ PIO_STACK_LOCATION io_stack_loc = IoGetCurrentIrpStackLocation(irp);
+
+ #ifdef DEBUGIRPS
+ Debug_IrpStart(dev_obj, irp);
+ #endif
+ /* Check that the device exists. */
+ if (!dev || dev->state == device__state_deleted)
+ return driver__complete_irp(irp, 0, STATUS_NO_SUCH_DEVICE);
+ /* Call the particular device's power handler. */
+ if (dev->irp_mj && dev->irp_mj->dev_ctl) {
+ return dev->irp_mj->dev_ctl(
+ dev,
+ irp,
+ io_stack_loc->Parameters.DeviceIoControl.IoControlCode
+ );
+ }
+ /* Otherwise, we don't support the IRP. */
+ return driver__complete_irp(irp, 0, STATUS_NOT_SUPPORTED);
+ }
+
static NTSTATUS STDCALL driver__dispatch_(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
}
NTSTATUS STDCALL filedisk__attach(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PIO_STACK_LOCATION Stack,
- IN struct device__type * dev_ptr,
- OUT winvblock__bool_ptr completion_ptr
- )
-{
+ IN struct device__type * dev,
+ IN PIRP irp
+ ) {
ANSI_STRING file_path1;
- winvblock__uint8_ptr buf = Irp->AssociatedIrp.SystemBuffer;
+ winvblock__uint8_ptr buf = irp->AssociatedIrp.SystemBuffer;
mount__filedisk_ptr params = ( mount__filedisk_ptr ) buf;
UNICODE_STRING file_path2;
OBJECT_ATTRIBUTES obj_attrs;