00049 :
00050
00051 This function performs
the mount and driver reload
functions for this mini-
00052
file system recognizer driver.
00053
00054 Arguments:
00055
00056 DeviceObject - Pointer to
this driver's device object.
00057
00058
Irp - Pointer to
the I/O
Request Packet (
IRP) representing the function to
00059 be performed.
00060
00061 Return Value:
00062
00063 The function value is the final status of the operation.
00064
00065
00066 --*/
00067
00068 {
00069
NTSTATUS status;
00070
PIO_STACK_LOCATION irpSp;
00071
PDEVICE_EXTENSION deviceExtension;
00072
PDEVICE_OBJECT targetDevice;
00073
PPACKED_BOOT_SECTOR buffer;
00074 LARGE_INTEGER byteOffset;
00075 LARGE_INTEGER secondByteOffset;
00076 LARGE_INTEGER lastByteOffset;
00077 UNICODE_STRING driverName;
00078 ULONG bytesPerSector;
00079 LARGE_INTEGER numberOfSectors;
00080
00081
PAGED_CODE();
00082
00083
00084
00085
00086
00087 deviceExtension = (
PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
00088 irpSp =
IoGetCurrentIrpStackLocation( Irp );
00089
00090
switch ( irpSp->
MinorFunction ) {
00091
00092
case IRP_MN_MOUNT_VOLUME:
00093
00094
00095
00096
00097
00098
00099
00100
00101 status = STATUS_UNRECOGNIZED_VOLUME;
00102
00103
00104
00105
00106
00107
00108 targetDevice = irpSp->
Parameters.MountVolume.DeviceObject;
00109
00110
if (
FsRecGetDeviceSectorSize( targetDevice,
00111 &bytesPerSector ) &&
00112
FsRecGetDeviceSectors( targetDevice,
00113 bytesPerSector,
00114 &numberOfSectors )) {
00115
00116 byteOffset.QuadPart = 0;
00117 buffer =
NULL;
00118 secondByteOffset.QuadPart = numberOfSectors.QuadPart >> 1;
00119 secondByteOffset.QuadPart *= (LONG) bytesPerSector;
00120 lastByteOffset.QuadPart = (numberOfSectors.QuadPart - 1) * (LONG) bytesPerSector;
00121
00122
if (
FsRecReadBlock( targetDevice,
00123 &byteOffset,
00124
sizeof(
PACKED_BOOT_SECTOR ),
00125 bytesPerSector,
00126 (PVOID *)&buffer,
00127 NULL ) &&
00128
IsNtfsVolume( buffer, bytesPerSector, &numberOfSectors )) {
00129
00130 status = STATUS_FS_DRIVER_REQUIRED;
00131
00132 }
else {
00133
00134
if (
FsRecReadBlock( targetDevice,
00135 &secondByteOffset,
00136
sizeof( PACKED_BOOT_SECTOR ),
00137 bytesPerSector,
00138 (PVOID *)&buffer,
00139 NULL ) &&
00140
IsNtfsVolume( buffer, bytesPerSector, &numberOfSectors )) {
00141
00142 status = STATUS_FS_DRIVER_REQUIRED;
00143
00144 }
else {
00145
00146
if (
FsRecReadBlock( targetDevice,
00147 &lastByteOffset,
00148
sizeof( PACKED_BOOT_SECTOR ),
00149 bytesPerSector,
00150 (PVOID *)&buffer,
00151 NULL ) &&
00152
IsNtfsVolume( buffer, bytesPerSector, &numberOfSectors )) {
00153
00154 status = STATUS_FS_DRIVER_REQUIRED;
00155 }
00156 }
00157 }
00158
00159
if (buffer !=
NULL) {
00160
ExFreePool( buffer );
00161 }
00162 }
00163
00164
break;
00165
00166
case IRP_MN_LOAD_FILE_SYSTEM:
00167
00168 status =
FsRecLoadFileSystem( DeviceObject,
00169 L
"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Ntfs" );
00170
break;
00171
00172
default:
00173 status = STATUS_INVALID_DEVICE_REQUEST;
00174
00175 }
00176
00177
00178
00179
00180
00181
00182
Irp->
IoStatus.Status = status;
00183
IoCompleteRequest( Irp, IO_NO_INCREMENT );
00184
00185
return status;
00186 }