mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Changes to support the COFF driver loader
svn path=/trunk/; revision=144
This commit is contained in:
parent
02e3d7b08e
commit
2d14c3e110
10 changed files with 511 additions and 454 deletions
|
@ -1,66 +1,67 @@
|
||||||
//
|
/*
|
||||||
// IDE.C - IDE Disk driver
|
* IDE.C - IDE Disk driver
|
||||||
// written by Rex Jolliff
|
* written by Rex Jolliff
|
||||||
// with help from various documentation sources and a few peeks at
|
* with help from various documentation sources and a few peeks at
|
||||||
// linux and freebsd sources.
|
* linux and freebsd sources.
|
||||||
//
|
*
|
||||||
// This driver supports up to 4 controllers with up to 2 drives each.
|
* This driver supports up to 4 controllers with up to 2 drives each.
|
||||||
// The device names are assigned as follows:
|
* The device names are assigned as follows:
|
||||||
// \Devices\HarddiskX\Partition0
|
* \Devices\HarddiskX\Partition0
|
||||||
// for the raw device, and
|
* for the raw device, and
|
||||||
// \Devices\HarddiskX\PartitionY
|
* \Devices\HarddiskX\PartitionY
|
||||||
// for partitions
|
* for partitions
|
||||||
// where:
|
* where:
|
||||||
// X is computed by counting the available drives from the following
|
* X is computed by counting the available drives from the following
|
||||||
// sequence: the controller number (0=0x1f0, 1=0x170, 2=0x1e8,
|
* sequence: the controller number (0=0x1f0, 1=0x170, 2=0x1e8,
|
||||||
// 3=0x168) * 2 plus the drive number (0,1)
|
* 3=0x168) * 2 plus the drive number (0,1)
|
||||||
// Y is the partition number
|
* Y is the partition number
|
||||||
//
|
*
|
||||||
// The driver exports the following function:
|
* The driver exports the following function:
|
||||||
//
|
*
|
||||||
// DriverEntry() - NT device driver initialization routine
|
* DriverEntry() - NT device driver initialization routine
|
||||||
//
|
*
|
||||||
// And the following functions are exported implicitly:
|
* And the following functions are exported implicitly:
|
||||||
//
|
*
|
||||||
// IDEStartIo() - called to start an I/O request packet
|
* IDEStartIo() - called to start an I/O request packet
|
||||||
// IDEDispatchOpenClose() - Called to open/close the device. a NOOP
|
* IDEDispatchOpenClose() - Called to open/close the device. a NOOP
|
||||||
// IDEDispatchReadWrite() - Called to read/write the device.
|
* IDEDispatchReadWrite() - Called to read/write the device.
|
||||||
// IDEDispatchQueryInformation() - Called to get device information
|
* IDEDispatchQueryInformation() - Called to get device information
|
||||||
// IDEDispatchSetInformation() - Called to set device information
|
* IDEDispatchSetInformation() - Called to set device information
|
||||||
// IDEDispatchDeviceControl() - Called to execute device control requests
|
* IDEDispatchDeviceControl() - Called to execute device control requests
|
||||||
//
|
*
|
||||||
// Modification History:
|
* Modification History:
|
||||||
// 05/25/98 RJJ Created.
|
* 05/25/98 RJJ Created.
|
||||||
// 05/30/98 RJJ Removed IRQ handler and inserted busy waits
|
* 05/30/98 RJJ Removed IRQ handler and inserted busy waits
|
||||||
// just to get something working...
|
* just to get something working...
|
||||||
// 07/18/98 RJJ Made drastic changes so that the driver
|
* 07/18/98 RJJ Made drastic changes so that the driver
|
||||||
// resembles a WinNT driver.
|
* resembles a WinNT driver.
|
||||||
// 08/05/98 RJJ Changed to .C extension
|
* 08/05/98 RJJ Changed to .C extension
|
||||||
// 09/19/98 RJJ First release (run for cover!)
|
* 09/19/98 RJJ First release (run for cover!)
|
||||||
//
|
*
|
||||||
// Test List:
|
* Test List:
|
||||||
// 09/17/98 RJJ Pri/MST: 14.12X19 WDC AC31000H Test Passed
|
* 09/17/98 RJJ Pri/MST: 14.12X19 WDC AC31000H Test Passed
|
||||||
// Pri/SLV: None.
|
* Pri/SLV: None.
|
||||||
//
|
*
|
||||||
//
|
*
|
||||||
// To Do:
|
* To Do:
|
||||||
// FIXME: a timer should be used to watch for device timeouts and errors
|
* FIXME: a timer should be used to watch for device timeouts and errors
|
||||||
// FIXME: errors should be retried
|
* FIXME: errors should be retried
|
||||||
// FIXME: a drive reset/recalibrate should be attempted if errors occur
|
* FIXME: a drive reset/recalibrate should be attempted if errors occur
|
||||||
// FIXME: Use DMA for transfers if drives support it
|
* FIXME: Use DMA for transfers if drives support it
|
||||||
// FIXME: should we support unloading of this driver???
|
* FIXME: should we support unloading of this driver???
|
||||||
// FIXME: the device information should come from AUTODETECT (via registry)
|
* FIXME: the device information should come from AUTODETECT (via registry)
|
||||||
// FIXME: really big devices need to be handled correctly
|
* FIXME: really big devices need to be handled correctly
|
||||||
// FIXME: should get device info from the registry
|
* FIXME: should get device info from the registry
|
||||||
// FIXME: should report hardware usage to iomgr
|
* FIXME: should report hardware usage to iomgr
|
||||||
// FIXME: finish implementation of QueryInformation
|
* FIXME: finish implementation of QueryInformation
|
||||||
// FIXME: finish implementation of SetInformation
|
* FIXME: finish implementation of SetInformation
|
||||||
// FIXME: finish implementation of DeviceControl
|
* FIXME: finish implementation of DeviceControl
|
||||||
// FIXME: bring up to ATA-3 spec
|
* FIXME: bring up to ATA-3 spec
|
||||||
// FIXME: add general support for ATAPI devices
|
* FIXME: add general support for ATAPI devices
|
||||||
// FIXME: add support for ATAPI CDROMs
|
* FIXME: add support for ATAPI CDROMs
|
||||||
// FIXME: add support for ATAPI ZIP drives/RHDs
|
* FIXME: add support for ATAPI ZIP drives/RHDs
|
||||||
// FIXME: add support for ATAPI tape drives
|
* FIXME: add support for ATAPI tape drives
|
||||||
|
*/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||||
IN ULONG DiskSector,
|
IN ULONG DiskSector,
|
||||||
IN ULONG SectorCount,
|
IN ULONG SectorCount,
|
||||||
IN UCHAR* Buffer)
|
IN UCHAR* Buffer)
|
||||||
{
|
{
|
||||||
|
@ -33,22 +33,28 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||||
ULONG sectorSize;
|
ULONG sectorSize;
|
||||||
PULONG mbr;
|
PULONG mbr;
|
||||||
|
|
||||||
DPRINT("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
|
||||||
pDeviceObject,DiskSector,Buffer);
|
|
||||||
|
|
||||||
SET_LARGE_INTEGER_LOW_PART(sectorNumber, DiskSector << 9);
|
SET_LARGE_INTEGER_LOW_PART(sectorNumber, DiskSector << 9);
|
||||||
SET_LARGE_INTEGER_HIGH_PART(sectorNumber, DiskSector >> 23);
|
SET_LARGE_INTEGER_HIGH_PART(sectorNumber, DiskSector >> 23);
|
||||||
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
||||||
|
sectorSize = BLOCKSIZE * SectorCount;
|
||||||
|
|
||||||
sectorSize = BLOCKSIZE*SectorCount;
|
/* FIXME: this routine does not need to alloc mem and copy */
|
||||||
|
|
||||||
mbr = ExAllocatePool(NonPagedPool, sectorSize);
|
mbr = ExAllocatePool(NonPagedPool, sectorSize);
|
||||||
|
|
||||||
|
DPRINT("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
||||||
|
pDeviceObject,
|
||||||
|
DiskSector,
|
||||||
|
Buffer);
|
||||||
|
DPRINT("sectorNumber %08lx:%08lx sectorSize %ld\n",
|
||||||
|
(unsigned long int)GET_LARGE_INTEGER_HIGH_PART(sectorNumber),
|
||||||
|
(unsigned long int)GET_LARGE_INTEGER_LOW_PART(sectorNumber),
|
||||||
|
sectorSize);
|
||||||
|
|
||||||
if (!mbr) {
|
if (!mbr) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DPRINT("Building synchronous FSD Request...\n");
|
DPRINT("Building synchronous FSD Request...\n");
|
||||||
irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
|
irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
|
||||||
pDeviceObject,
|
pDeviceObject,
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <wstring.h>
|
#include <wstring.h>
|
||||||
#include <ddk/cctypes.h>
|
#include <ddk/cctypes.h>
|
||||||
|
|
||||||
//#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
#include "vfat.h"
|
#include "vfat.h"
|
||||||
|
@ -668,18 +668,12 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
FileObject,
|
FileObject,
|
||||||
FileName);
|
FileName);
|
||||||
|
|
||||||
CHECKPOINT;
|
|
||||||
string = FileName;
|
string = FileName;
|
||||||
CHECKPOINT;
|
|
||||||
ParentFcb = NULL;
|
ParentFcb = NULL;
|
||||||
CHECKPOINT;
|
|
||||||
Fcb = ExAllocatePool(NonPagedPool, sizeof(FCB));
|
Fcb = ExAllocatePool(NonPagedPool, sizeof(FCB));
|
||||||
CHECKPOINT;
|
|
||||||
next = &string[0];
|
next = &string[0];
|
||||||
CHECKPOINT;
|
|
||||||
current = next+1;
|
current = next+1;
|
||||||
|
|
||||||
CHECKPOINT;
|
|
||||||
while (next!=NULL)
|
while (next!=NULL)
|
||||||
{
|
{
|
||||||
DPRINT("current %w next %x\n",current,next);
|
DPRINT("current %w next %x\n",current,next);
|
||||||
|
@ -692,7 +686,6 @@ CHECKPOINT;
|
||||||
*next=0;
|
*next=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECKPOINT;
|
|
||||||
Status = FindFile(DeviceExt,Fcb,ParentFcb,current,NULL,NULL);
|
Status = FindFile(DeviceExt,Fcb,ParentFcb,current,NULL,NULL);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -709,7 +702,6 @@ CHECKPOINT;
|
||||||
Fcb = ParentFcb;
|
Fcb = ParentFcb;
|
||||||
}
|
}
|
||||||
ParentFcb = Temp;
|
ParentFcb = Temp;
|
||||||
CHECKPOINT;
|
|
||||||
}
|
}
|
||||||
FileObject->FsContext = ParentFcb;
|
FileObject->FsContext = ParentFcb;
|
||||||
DPRINT("file opn, fcb=%x\n",ParentFcb);
|
DPRINT("file opn, fcb=%x\n",ParentFcb);
|
||||||
|
@ -724,7 +716,7 @@ BOOLEAN FsdHasFileSystem(PDEVICE_OBJECT DeviceToMount)
|
||||||
* by this fsd
|
* by this fsd
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
BootSector* Boot;
|
BootSector *Boot;
|
||||||
|
|
||||||
Boot = ExAllocatePool(NonPagedPool,512);
|
Boot = ExAllocatePool(NonPagedPool,512);
|
||||||
|
|
||||||
|
@ -738,7 +730,8 @@ BOOLEAN FsdHasFileSystem(PDEVICE_OBJECT DeviceToMount)
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
ExFreePool(Boot);
|
ExFreePool(Boot);
|
||||||
return(FALSE);
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS FsdMountDevice(PDEVICE_EXTENSION DeviceExt,
|
NTSTATUS FsdMountDevice(PDEVICE_EXTENSION DeviceExt,
|
||||||
|
@ -844,19 +837,37 @@ NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
PVOID Temp;
|
PVOID Temp;
|
||||||
ULONG TempLength;
|
ULONG TempLength;
|
||||||
|
|
||||||
|
/* PRECONDITION */
|
||||||
|
assert(DeviceExt != NULL);
|
||||||
|
assert(DeviceExt->BytesPerCluster != 0);
|
||||||
|
assert(FileObject != NULL);
|
||||||
|
assert(FileObject->FsContext != NULL);
|
||||||
|
|
||||||
DPRINT("FsdReadFile(DeviceExt %x, FileObject %x, Buffer %x, "
|
DPRINT("FsdReadFile(DeviceExt %x, FileObject %x, Buffer %x, "
|
||||||
"Length %d, ReadOffset %d)\n",DeviceExt,FileObject,Buffer,
|
"Length %d, ReadOffset %d)\n",
|
||||||
Length,ReadOffset);
|
DeviceExt,
|
||||||
|
FileObject,
|
||||||
|
Buffer,
|
||||||
|
Length,
|
||||||
|
ReadOffset);
|
||||||
|
DPRINT("DeviceExt->BytesPerCluster %d\n", DeviceExt->BytesPerCluster);
|
||||||
|
|
||||||
FirstCluster = ReadOffset / DeviceExt->BytesPerCluster;
|
FirstCluster = ReadOffset / DeviceExt->BytesPerCluster;
|
||||||
Fcb = FileObject->FsContext;
|
Fcb = FileObject->FsContext;
|
||||||
if (DeviceExt->FatType == FAT32)
|
if (DeviceExt->FatType == FAT32)
|
||||||
CurrentCluster = Fcb->entry.FirstCluster+Fcb->entry.FirstClusterHigh*65536;
|
{
|
||||||
|
CurrentCluster = Fcb->entry.FirstCluster +
|
||||||
|
Fcb->entry.FirstClusterHigh * 65536;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
CurrentCluster = Fcb->entry.FirstCluster;
|
{
|
||||||
if (CurrentCluster<2)
|
CurrentCluster = Fcb->entry.FirstCluster;
|
||||||
return STATUS_UNSUCCESSFUL;// FIXME : root of FAT16 ?
|
}
|
||||||
DPRINT("DeviceExt->BytesPerCluster %x\n",DeviceExt->BytesPerCluster);
|
if (CurrentCluster < 2)
|
||||||
|
{
|
||||||
|
/* FIXME : root of FAT16 ? */
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
if (ReadOffset >= Fcb->entry.FileSize)
|
if (ReadOffset >= Fcb->entry.FileSize)
|
||||||
{
|
{
|
||||||
|
@ -868,11 +879,11 @@ NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
}
|
}
|
||||||
*LengthRead = 0;
|
*LengthRead = 0;
|
||||||
Temp = ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster);
|
Temp = ExAllocatePool(NonPagedPool,DeviceExt->BytesPerCluster);
|
||||||
|
/* FIXME: optimize by remembering the last cluster read and using if possible */
|
||||||
for (FileOffset=0; FileOffset < FirstCluster; FileOffset++)
|
for (FileOffset=0; FileOffset < FirstCluster; FileOffset++)
|
||||||
{
|
{
|
||||||
CurrentCluster = GetNextCluster(DeviceExt,CurrentCluster);
|
CurrentCluster = GetNextCluster(DeviceExt,CurrentCluster);
|
||||||
}
|
}
|
||||||
CHECKPOINT;
|
|
||||||
if ((ReadOffset % DeviceExt->BytesPerCluster)!=0)
|
if ((ReadOffset % DeviceExt->BytesPerCluster)!=0)
|
||||||
{
|
{
|
||||||
VFATLoadCluster(DeviceExt,Temp,CurrentCluster);
|
VFATLoadCluster(DeviceExt,Temp,CurrentCluster);
|
||||||
|
@ -888,7 +899,6 @@ NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
Length = Length - TempLength;
|
Length = Length - TempLength;
|
||||||
Buffer = Buffer + TempLength;
|
Buffer = Buffer + TempLength;
|
||||||
}
|
}
|
||||||
CHECKPOINT;
|
|
||||||
while (Length > DeviceExt->BytesPerCluster)
|
while (Length > DeviceExt->BytesPerCluster)
|
||||||
{
|
{
|
||||||
VFATLoadCluster(DeviceExt, Buffer, CurrentCluster);
|
VFATLoadCluster(DeviceExt, Buffer, CurrentCluster);
|
||||||
|
@ -904,7 +914,6 @@ NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
Buffer = Buffer + DeviceExt->BytesPerCluster;
|
Buffer = Buffer + DeviceExt->BytesPerCluster;
|
||||||
Length = Length - DeviceExt->BytesPerCluster;
|
Length = Length - DeviceExt->BytesPerCluster;
|
||||||
}
|
}
|
||||||
CHECKPOINT;
|
|
||||||
if (Length > 0)
|
if (Length > 0)
|
||||||
{
|
{
|
||||||
(*LengthRead) = (*LengthRead) + Length;
|
(*LengthRead) = (*LengthRead) + Length;
|
||||||
|
@ -1041,21 +1050,14 @@ NTSTATUS FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
Irp);
|
Irp);
|
||||||
|
|
||||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
CHECKPOINT;
|
|
||||||
FileObject = Stack->FileObject;
|
FileObject = Stack->FileObject;
|
||||||
CHECKPOINT;
|
|
||||||
DeviceExt = DeviceObject->DeviceExtension;
|
DeviceExt = DeviceObject->DeviceExtension;
|
||||||
CHECKPOINT;
|
|
||||||
Status = FsdOpenFile(DeviceExt,FileObject,FileObject->FileName.Buffer);
|
Status = FsdOpenFile(DeviceExt,FileObject,FileObject->FileName.Buffer);
|
||||||
CHECKPOINT;
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
CHECKPOINT;
|
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
CHECKPOINT;
|
|
||||||
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
CHECKPOINT;
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -1097,14 +1099,23 @@ NTSTATUS FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
ULONG Length;
|
ULONG Length;
|
||||||
PVOID Buffer;
|
PVOID Buffer;
|
||||||
ULONG Offset;
|
ULONG Offset;
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
PIO_STACK_LOCATION Stack;
|
||||||
PFILE_OBJECT FileObject = Stack->FileObject;
|
PFILE_OBJECT FileObject;
|
||||||
PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
|
PDEVICE_EXTENSION DeviceExt;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG LengthRead;
|
ULONG LengthRead;
|
||||||
|
|
||||||
DPRINT("FsdRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
DPRINT("FsdRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
||||||
|
|
||||||
|
/* Precondition / Initialization */
|
||||||
|
assert(Irp != NULL);
|
||||||
|
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
assert(Stack != NULL);
|
||||||
|
FileObject = Stack->FileObject;
|
||||||
|
assert(FileObject != NULL);
|
||||||
|
DeviceExt = DeviceObject->DeviceExtension;
|
||||||
|
assert(DeviceExt != NULL);
|
||||||
|
|
||||||
Length = Stack->Parameters.Read.Length;
|
Length = Stack->Parameters.Read.Length;
|
||||||
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
|
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
|
||||||
Offset = GET_LARGE_INTEGER_LOW_PART(Stack->Parameters.Read.ByteOffset);
|
Offset = GET_LARGE_INTEGER_LOW_PART(Stack->Parameters.Read.ByteOffset);
|
||||||
|
@ -1143,7 +1154,8 @@ NTSTATUS FsdMount(PDEVICE_OBJECT DeviceToMount)
|
||||||
DeviceObject->Vpb->Flags |= VPB_MOUNTED;
|
DeviceObject->Vpb->Flags |= VPB_MOUNTED;
|
||||||
DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject,
|
DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject,
|
||||||
DeviceToMount);
|
DeviceToMount);
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS FsdFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
NTSTATUS FsdFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
|
@ -1156,7 +1168,9 @@ NTSTATUS FsdFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
PDEVICE_OBJECT DeviceToMount = Stack->Parameters.Mount.DeviceObject;
|
PDEVICE_OBJECT DeviceToMount = Stack->Parameters.Mount.DeviceObject;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("VFAT FSC\n");
|
DPRINT("FsdFileSystemControl(DevObj %08lx, Irp %08lx)\n", DeviceObject, Irp);
|
||||||
|
|
||||||
|
/* FIXME: should make sure that this is actually a mount request! */
|
||||||
|
|
||||||
if (FsdHasFileSystem(DeviceToMount))
|
if (FsdHasFileSystem(DeviceToMount))
|
||||||
{
|
{
|
||||||
|
@ -1182,9 +1196,17 @@ NTSTATUS FsdGetStandardInformation(PFCB FCB, PDEVICE_OBJECT DeviceObject,
|
||||||
* FUNCTION: Retrieve the standard file information
|
* FUNCTION: Retrieve the standard file information
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
|
PDEVICE_EXTENSION DeviceExtension;
|
||||||
unsigned long AllocSize;
|
unsigned long AllocSize;
|
||||||
|
|
||||||
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
|
/* PRECONDITION */
|
||||||
|
assert(DeviceExtension != NULL);
|
||||||
|
assert(DeviceExtension->BytesPerCluster != 0);
|
||||||
|
assert(StandardInfo != NULL);
|
||||||
|
assert(FCB != NULL);
|
||||||
|
|
||||||
RtlZeroMemory(StandardInfo, sizeof(FILE_STANDARD_INFORMATION));
|
RtlZeroMemory(StandardInfo, sizeof(FILE_STANDARD_INFORMATION));
|
||||||
|
|
||||||
/* Make allocsize a rounded up multiple of BytesPerCluster */
|
/* Make allocsize a rounded up multiple of BytesPerCluster */
|
||||||
|
@ -1210,27 +1232,42 @@ NTSTATUS FsdQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
* FUNCTION: Retrieve the specified file information
|
* FUNCTION: Retrieve the specified file information
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
NTSTATUS RC;
|
||||||
FILE_INFORMATION_CLASS FileInformationClass =
|
PIO_STACK_LOCATION Stack;
|
||||||
Stack->Parameters.QueryFile.FileInformationClass;
|
FILE_INFORMATION_CLASS FileInformationClass;
|
||||||
PFILE_OBJECT FileObject = NULL;
|
PFILE_OBJECT FileObject;
|
||||||
PFCB FCB = NULL;
|
PFCB FCB;
|
||||||
// PCCB CCB = NULL;
|
// PCCB CCB;
|
||||||
|
|
||||||
NTSTATUS RC = STATUS_SUCCESS;
|
|
||||||
void *SystemBuffer;
|
void *SystemBuffer;
|
||||||
|
|
||||||
|
/* PRECONDITION */
|
||||||
|
assert(DeviceObject != NULL);
|
||||||
|
assert(Irp != NULL);
|
||||||
|
|
||||||
|
/* INITIALIZATION */
|
||||||
|
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
FileInformationClass = Stack->Parameters.QueryFile.FileInformationClass;
|
||||||
|
FileObject = NULL;
|
||||||
|
FCB = NULL;
|
||||||
|
// PCCB CCB = NULL;
|
||||||
|
RC = STATUS_SUCCESS;
|
||||||
FileObject = Stack->FileObject;
|
FileObject = Stack->FileObject;
|
||||||
// CCB = (PCCB)(FileObject->FsContext2);
|
// CCB = (PCCB)(FileObject->FsContext2);
|
||||||
// FCB = CCB->Buffer; // Should be CCB->FCB???
|
// FCB = CCB->Buffer; // Should be CCB->FCB???
|
||||||
FCB=(PFCB)(FileObject->FsContext);
|
FCB = (PFCB)(FileObject->FsContext);
|
||||||
|
SystemBuffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
|
||||||
|
// SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||||
|
|
||||||
SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
|
DPRINT("FsdQueryInformation(DevObj %08lx, Irp %08lx)\n", DeviceObject, Irp);
|
||||||
|
|
||||||
switch(FileInformationClass) {
|
switch(FileInformationClass) {
|
||||||
case FileStandardInformation:
|
case FileStandardInformation:
|
||||||
RC = FsdGetStandardInformation(FCB, DeviceObject, SystemBuffer);
|
RC = FsdGetStandardInformation(FCB, DeviceObject, SystemBuffer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
RC = STATUS_INVALID_PARAMETER;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RC;
|
return RC;
|
||||||
|
@ -1264,7 +1301,7 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceObject->Flags=0;
|
DeviceObject->Flags = DO_DIRECT_IO;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = FsdClose;
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = FsdClose;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = FsdCreate;
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = FsdCreate;
|
||||||
DriverObject->MajorFunction[IRP_MJ_READ] = FsdRead;
|
DriverObject->MajorFunction[IRP_MJ_READ] = FsdRead;
|
||||||
|
|
|
@ -67,7 +67,7 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
PIO_STACK_LOCATION StackPtr;
|
PIO_STACK_LOCATION StackPtr;
|
||||||
|
|
||||||
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
|
Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE);
|
||||||
if (Irp==NULL)
|
if (Irp==NULL)
|
||||||
{
|
{
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
@ -83,6 +83,7 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
|
||||||
StackPtr->Control = 0;
|
StackPtr->Control = 0;
|
||||||
StackPtr->DeviceObject = DeviceObject;
|
StackPtr->DeviceObject = DeviceObject;
|
||||||
StackPtr->FileObject = NULL;
|
StackPtr->FileObject = NULL;
|
||||||
|
StackPtr->CompletionRoutine = NULL;
|
||||||
|
|
||||||
switch(MinorFunction)
|
switch(MinorFunction)
|
||||||
{
|
{
|
||||||
|
@ -144,6 +145,7 @@ PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
|
||||||
StackPtr->Control = 0;
|
StackPtr->Control = 0;
|
||||||
StackPtr->DeviceObject = DeviceObject;
|
StackPtr->DeviceObject = DeviceObject;
|
||||||
StackPtr->FileObject = NULL;
|
StackPtr->FileObject = NULL;
|
||||||
|
StackPtr->CompletionRoutine = NULL;
|
||||||
StackPtr->Parameters.Write.Length = Length;
|
StackPtr->Parameters.Write.Length = Length;
|
||||||
|
|
||||||
if (MajorFunction == IRP_MJ_READ || MajorFunction == IRP_MJ_WRITE)
|
if (MajorFunction == IRP_MJ_READ || MajorFunction == IRP_MJ_WRITE)
|
||||||
|
@ -237,7 +239,7 @@ PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
|
||||||
Irp->UserBuffer = (LPVOID)Buffer;
|
Irp->UserBuffer = (LPVOID)Buffer;
|
||||||
Irp->UserEvent = Event;
|
Irp->UserEvent = Event;
|
||||||
Irp->UserIosb = IoStatusBlock;
|
Irp->UserIosb = IoStatusBlock;
|
||||||
if (DeviceObject->Flags&DO_BUFFERED_IO)
|
if (DeviceObject->Flags & DO_BUFFERED_IO)
|
||||||
{
|
{
|
||||||
DPRINT("Doing buffer i/o\n");
|
DPRINT("Doing buffer i/o\n");
|
||||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||||
|
@ -247,12 +249,13 @@ PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
|
||||||
IoFreeIrp(Irp);
|
IoFreeIrp(Irp);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
/* FIXME: should copy buffer in on other ops */
|
||||||
if (MajorFunction == IRP_MJ_WRITE)
|
if (MajorFunction == IRP_MJ_WRITE)
|
||||||
{
|
{
|
||||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, Buffer, Length);
|
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, Buffer, Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DeviceObject->Flags&DO_DIRECT_IO)
|
if (DeviceObject->Flags & DO_DIRECT_IO)
|
||||||
{
|
{
|
||||||
DPRINT("Doing direct i/o\n");
|
DPRINT("Doing direct i/o\n");
|
||||||
|
|
||||||
|
@ -276,6 +279,7 @@ PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
|
||||||
StackPtr->Control = 0;
|
StackPtr->Control = 0;
|
||||||
StackPtr->DeviceObject = DeviceObject;
|
StackPtr->DeviceObject = DeviceObject;
|
||||||
StackPtr->FileObject = NULL;
|
StackPtr->FileObject = NULL;
|
||||||
|
StackPtr->CompletionRoutine = NULL;
|
||||||
StackPtr->Parameters.Write.Length = Length;
|
StackPtr->Parameters.Write.Length = Length;
|
||||||
if (MajorFunction == IRP_MJ_READ)
|
if (MajorFunction == IRP_MJ_READ)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
#include <wstring.h>
|
#include <wstring.h>
|
||||||
|
|
||||||
//#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* FUNCTIONS *************************************************************/
|
/* FUNCTIONS *************************************************************/
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
|
@ -155,7 +155,9 @@ NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject)
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CHECKPOINT;
|
||||||
KeReleaseSpinLock(&FileSystemListLock,oldlvl);
|
KeReleaseSpinLock(&FileSystemListLock,oldlvl);
|
||||||
|
CHECKPOINT;
|
||||||
return(STATUS_UNRECOGNIZED_VOLUME);
|
return(STATUS_UNRECOGNIZED_VOLUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,309 +1,313 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/io/irp.c
|
* FILE: ntoskrnl/io/irp.c
|
||||||
* PURPOSE: Handle IRPs
|
* PURPOSE: Handle IRPs
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* 24/05/98: Created
|
* 24/05/98: Created
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* NOTES *******************************************************************
|
/* NOTES *******************************************************************
|
||||||
*
|
*
|
||||||
* Layout of an IRP
|
* Layout of an IRP
|
||||||
*
|
*
|
||||||
* ################
|
* ################
|
||||||
* # Headers #
|
* # Headers #
|
||||||
* ################
|
* ################
|
||||||
* # #
|
* # #
|
||||||
* # Variable #
|
* # Variable #
|
||||||
* # length list #
|
* # length list #
|
||||||
* # of io stack #
|
* # of io stack #
|
||||||
* # locations #
|
* # locations #
|
||||||
* # #
|
* # #
|
||||||
* ################
|
* ################
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ****************************************************************/
|
/* INCLUDES ****************************************************************/
|
||||||
|
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
#include <internal/io.h>
|
#include <internal/io.h>
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
//#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
PDEVICE_OBJECT IoGetDeviceToVerify(PETHREAD Thread)
|
PDEVICE_OBJECT IoGetDeviceToVerify(PETHREAD Thread)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Returns a pointer to the device, representing a removable-media
|
* FUNCTION: Returns a pointer to the device, representing a removable-media
|
||||||
* device, that is the target of the given thread's I/O request
|
* device, that is the target of the given thread's I/O request
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID IoFreeIrp(PIRP Irp)
|
VOID IoFreeIrp(PIRP Irp)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Releases a caller allocated irp
|
* FUNCTION: Releases a caller allocated irp
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* Irp = Irp to free
|
* Irp = Irp to free
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
ExFreePool(Irp);
|
ExFreePool(Irp);
|
||||||
}
|
}
|
||||||
|
|
||||||
PIRP IoMakeAssociatedIrp(PIRP Irp, CCHAR StackSize)
|
PIRP IoMakeAssociatedIrp(PIRP Irp, CCHAR StackSize)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Allocates and initializes an irp to associated with a master irp
|
* FUNCTION: Allocates and initializes an irp to associated with a master irp
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* Irp = Master irp
|
* Irp = Master irp
|
||||||
* StackSize = Number of stack locations to be allocated in the irp
|
* StackSize = Number of stack locations to be allocated in the irp
|
||||||
* RETURNS: The irp allocated
|
* RETURNS: The irp allocated
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PIRP AssocIrp;
|
PIRP AssocIrp;
|
||||||
|
|
||||||
AssocIrp = IoAllocateIrp(StackSize,FALSE);
|
AssocIrp = IoAllocateIrp(StackSize,FALSE);
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID IoMarkIrpPending(PIRP Irp)
|
VOID IoMarkIrpPending(PIRP Irp)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Marks the specified irp, indicating further processing will
|
* FUNCTION: Marks the specified irp, indicating further processing will
|
||||||
* be required by other driver routines
|
* be required by other driver routines
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* Irp = Irp to mark
|
* Irp = Irp to mark
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DPRINT("IoGetCurrentIrpStackLocation(Irp) %x\n",
|
DPRINT("IoGetCurrentIrpStackLocation(Irp) %x\n",
|
||||||
IoGetCurrentIrpStackLocation(Irp));
|
IoGetCurrentIrpStackLocation(Irp));
|
||||||
IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED;
|
IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED;
|
||||||
Irp->Tail.Overlay.Thread = KeGetCurrentThread();
|
Irp->Tail.Overlay.Thread = KeGetCurrentThread();
|
||||||
DPRINT("IoGetCurrentIrpStackLocation(Irp)->Control %x\n",
|
DPRINT("IoGetCurrentIrpStackLocation(Irp)->Control %x\n",
|
||||||
IoGetCurrentIrpStackLocation(Irp)->Control);
|
IoGetCurrentIrpStackLocation(Irp)->Control);
|
||||||
DPRINT("SL_PENDING_RETURNED %x\n",SL_PENDING_RETURNED);
|
DPRINT("SL_PENDING_RETURNED %x\n",SL_PENDING_RETURNED);
|
||||||
}
|
}
|
||||||
|
|
||||||
USHORT IoSizeOfIrp(CCHAR StackSize)
|
USHORT IoSizeOfIrp(CCHAR StackSize)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Determines the size of an IRP
|
* FUNCTION: Determines the size of an IRP
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* StackSize = number of stack locations in the IRP
|
* StackSize = number of stack locations in the IRP
|
||||||
* RETURNS: The size of the IRP in bytes
|
* RETURNS: The size of the IRP in bytes
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
return(sizeof(IRP)+((StackSize-1)*sizeof(IO_STACK_LOCATION)));
|
return(sizeof(IRP)+((StackSize-1)*sizeof(IO_STACK_LOCATION)));
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID IoInitializeIrp(PIRP Irp, USHORT PacketSize, CCHAR StackSize)
|
VOID IoInitializeIrp(PIRP Irp, USHORT PacketSize, CCHAR StackSize)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Initalizes an irp allocated by the caller
|
* FUNCTION: Initalizes an irp allocated by the caller
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* Irp = IRP to initalize
|
* Irp = IRP to initalize
|
||||||
* PacketSize = Size in bytes of the IRP
|
* PacketSize = Size in bytes of the IRP
|
||||||
* StackSize = Number of stack locations in the IRP
|
* StackSize = Number of stack locations in the IRP
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
assert(Irp!=NULL);
|
assert(Irp != NULL);
|
||||||
memset(Irp,0,PacketSize);
|
|
||||||
Irp->StackCount=StackSize;
|
memset(Irp,0,PacketSize);
|
||||||
Irp->CurrentLocation=StackSize;
|
Irp->StackCount=StackSize;
|
||||||
Irp->Tail.Overlay.CurrentStackLocation=IoGetCurrentIrpStackLocation(Irp);
|
Irp->CurrentLocation=StackSize;
|
||||||
}
|
Irp->Tail.Overlay.CurrentStackLocation=IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
}
|
||||||
PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
|
|
||||||
/*
|
PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
|
||||||
* FUNCTION: Gets a pointer to the callers location in the I/O stack in
|
/*
|
||||||
* the given IRP
|
* FUNCTION: Gets a pointer to the callers location in the I/O stack in
|
||||||
* ARGUMENTS:
|
* the given IRP
|
||||||
* Irp = Points to the IRP
|
* ARGUMENTS:
|
||||||
* RETURNS: A pointer to the stack location
|
* Irp = Points to the IRP
|
||||||
*/
|
* RETURNS: A pointer to the stack location
|
||||||
{
|
*/
|
||||||
DPRINT("IoGetCurrentIrpStackLocation: Irp %08lx CurLoc %d StkCnt %d\n",
|
{
|
||||||
Irp,
|
DPRINT("IoGetCurrentIrpStackLocation: Irp %08lx CurLoc %d StkCnt %d\n",
|
||||||
Irp->CurrentLocation,
|
Irp,
|
||||||
Irp->StackCount);
|
Irp->CurrentLocation,
|
||||||
|
Irp->StackCount);
|
||||||
return &Irp->Stack[Irp->CurrentLocation];
|
|
||||||
}
|
return &Irp->Stack[Irp->CurrentLocation];
|
||||||
|
}
|
||||||
|
|
||||||
VOID IoSetNextIrpStackLocation(PIRP Irp)
|
|
||||||
{
|
VOID IoSetNextIrpStackLocation(PIRP Irp)
|
||||||
Irp->CurrentLocation--;
|
{
|
||||||
Irp->Tail.Overlay.CurrentStackLocation--;
|
Irp->CurrentLocation--;
|
||||||
}
|
Irp->Tail.Overlay.CurrentStackLocation--;
|
||||||
|
}
|
||||||
PIO_STACK_LOCATION IoGetNextIrpStackLocation(PIRP Irp)
|
|
||||||
/*
|
PIO_STACK_LOCATION IoGetNextIrpStackLocation(PIRP Irp)
|
||||||
* FUNCTION: Gives a higher level driver access to the next lower driver's
|
/*
|
||||||
* I/O stack location
|
* FUNCTION: Gives a higher level driver access to the next lower driver's
|
||||||
* ARGUMENTS:
|
* I/O stack location
|
||||||
* Irp = points to the irp
|
* ARGUMENTS:
|
||||||
* RETURNS: A pointer to the stack location
|
* Irp = points to the irp
|
||||||
*/
|
* RETURNS: A pointer to the stack location
|
||||||
{
|
*/
|
||||||
DPRINT("IoGetNextIrpStackLocation: Irp %08lx CurLoc %d StkCnt %d\n",
|
{
|
||||||
Irp,
|
DPRINT("IoGetNextIrpStackLocation: Irp %08lx CurLoc %d StkCnt %d\n",
|
||||||
Irp->CurrentLocation,
|
Irp,
|
||||||
Irp->StackCount);
|
Irp->CurrentLocation,
|
||||||
|
Irp->StackCount);
|
||||||
assert(Irp!=NULL);
|
|
||||||
DPRINT("Irp %x Irp->StackPtr %x\n",Irp,Irp->CurrentLocation);
|
assert(Irp!=NULL);
|
||||||
return(&Irp->Stack[Irp->CurrentLocation-1]);
|
DPRINT("Irp %x Irp->StackPtr %x\n",Irp,Irp->CurrentLocation);
|
||||||
}
|
return(&Irp->Stack[Irp->CurrentLocation-1]);
|
||||||
|
}
|
||||||
NTSTATUS IoCallDriver(PDEVICE_OBJECT DevObject, PIRP irp)
|
|
||||||
/*
|
NTSTATUS IoCallDriver(PDEVICE_OBJECT DevObject, PIRP irp)
|
||||||
* FUNCTION: Sends an IRP to the next lower driver
|
/*
|
||||||
*/
|
* FUNCTION: Sends an IRP to the next lower driver
|
||||||
{
|
*/
|
||||||
NTSTATUS Status;
|
{
|
||||||
PDRIVER_OBJECT drv = DevObject->DriverObject;
|
NTSTATUS Status;
|
||||||
IO_STACK_LOCATION* param = IoGetNextIrpStackLocation(irp);
|
PDRIVER_OBJECT drv = DevObject->DriverObject;
|
||||||
|
IO_STACK_LOCATION* param = IoGetNextIrpStackLocation(irp);
|
||||||
DPRINT("Deviceobject %x\n",DevObject);
|
|
||||||
DPRINT("Irp %x\n",irp);
|
DPRINT("Deviceobject %x\n",DevObject);
|
||||||
|
DPRINT("Irp %x\n",irp);
|
||||||
irp->Tail.Overlay.CurrentStackLocation--;
|
|
||||||
irp->CurrentLocation--;
|
irp->Tail.Overlay.CurrentStackLocation--;
|
||||||
|
irp->CurrentLocation--;
|
||||||
DPRINT("Io stack address %x\n",param);
|
|
||||||
DPRINT("Function %d Routine %x\n",param->MajorFunction,
|
DPRINT("Io stack address %x\n",param);
|
||||||
drv->MajorFunction[param->MajorFunction]);
|
DPRINT("Function %d Routine %x\n",param->MajorFunction,
|
||||||
|
drv->MajorFunction[param->MajorFunction]);
|
||||||
Status = drv->MajorFunction[param->MajorFunction](DevObject,irp);
|
|
||||||
return Status;
|
Status = drv->MajorFunction[param->MajorFunction](DevObject,irp);
|
||||||
}
|
return Status;
|
||||||
|
}
|
||||||
PIRP IoAllocateIrp(CCHAR StackSize, BOOLEAN ChargeQuota)
|
|
||||||
/*
|
PIRP IoAllocateIrp(CCHAR StackSize, BOOLEAN ChargeQuota)
|
||||||
* FUNCTION: Allocates an IRP
|
/*
|
||||||
* ARGUMENTS:
|
* FUNCTION: Allocates an IRP
|
||||||
* StackSize = the size of the stack required for the irp
|
* ARGUMENTS:
|
||||||
* ChargeQuota = Charge allocation to current threads quota
|
* StackSize = the size of the stack required for the irp
|
||||||
* RETURNS: Irp allocated
|
* ChargeQuota = Charge allocation to current threads quota
|
||||||
*/
|
* RETURNS: Irp allocated
|
||||||
{
|
*/
|
||||||
PIRP Irp;
|
{
|
||||||
|
PIRP Irp;
|
||||||
DPRINT("IoAllocateIrp(StackSize %d ChargeQuota %d)\n",StackSize,
|
|
||||||
ChargeQuota);
|
DPRINT("IoAllocateIrp(StackSize %d ChargeQuota %d)\n",
|
||||||
if (ChargeQuota)
|
StackSize,
|
||||||
{
|
ChargeQuota);
|
||||||
Irp = ExAllocatePoolWithQuota(NonPagedPool,IoSizeOfIrp(StackSize));
|
if (ChargeQuota)
|
||||||
}
|
{
|
||||||
else
|
Irp = ExAllocatePoolWithQuota(NonPagedPool,IoSizeOfIrp(StackSize));
|
||||||
{
|
}
|
||||||
Irp = ExAllocatePool(NonPagedPool,IoSizeOfIrp(StackSize));
|
else
|
||||||
}
|
{
|
||||||
|
Irp = ExAllocatePool(NonPagedPool,IoSizeOfIrp(StackSize));
|
||||||
if (Irp==NULL)
|
}
|
||||||
{
|
|
||||||
return(NULL);
|
if (Irp==NULL)
|
||||||
}
|
{
|
||||||
|
return(NULL);
|
||||||
Irp->StackCount=StackSize;
|
}
|
||||||
Irp->CurrentLocation=StackSize;
|
|
||||||
|
IoInitializeIrp(Irp, IoSizeOfIrp(StackSize), StackSize);
|
||||||
DPRINT("Irp %x Irp->StackPtr %d\n",Irp,Irp->CurrentLocation);
|
|
||||||
return(Irp);
|
DPRINT("Irp %x Irp->StackPtr %d\n", Irp, Irp->CurrentLocation);
|
||||||
}
|
|
||||||
|
return Irp;
|
||||||
VOID IoSetCompletionRoutine(PIRP Irp,
|
}
|
||||||
PIO_COMPLETION_ROUTINE CompletionRoutine,
|
|
||||||
PVOID Context,
|
VOID IoSetCompletionRoutine(PIRP Irp,
|
||||||
BOOLEAN InvokeOnSuccess,
|
PIO_COMPLETION_ROUTINE CompletionRoutine,
|
||||||
BOOLEAN InvokeOnError,
|
PVOID Context,
|
||||||
BOOLEAN InvokeOnCancel)
|
BOOLEAN InvokeOnSuccess,
|
||||||
{
|
BOOLEAN InvokeOnError,
|
||||||
IO_STACK_LOCATION* param = IoGetNextIrpStackLocation(Irp);
|
BOOLEAN InvokeOnCancel)
|
||||||
|
{
|
||||||
param->CompletionRoutine=CompletionRoutine;
|
IO_STACK_LOCATION* param = IoGetNextIrpStackLocation(Irp);
|
||||||
param->CompletionContext=Context;
|
|
||||||
if (InvokeOnSuccess)
|
param->CompletionRoutine=CompletionRoutine;
|
||||||
{
|
param->CompletionContext=Context;
|
||||||
param->Control = param->Control | SL_INVOKE_ON_SUCCESS;
|
if (InvokeOnSuccess)
|
||||||
}
|
{
|
||||||
if (InvokeOnError)
|
param->Control = param->Control | SL_INVOKE_ON_SUCCESS;
|
||||||
{
|
}
|
||||||
param->Control = param->Control | SL_INVOKE_ON_ERROR;
|
if (InvokeOnError)
|
||||||
}
|
{
|
||||||
if (InvokeOnCancel)
|
param->Control = param->Control | SL_INVOKE_ON_ERROR;
|
||||||
{
|
}
|
||||||
param->Control = param->Control | SL_INVOKE_ON_CANCEL;
|
if (InvokeOnCancel)
|
||||||
}
|
{
|
||||||
}
|
param->Control = param->Control | SL_INVOKE_ON_CANCEL;
|
||||||
|
}
|
||||||
VOID IopCompleteRequest(struct _KAPC* Apc,
|
}
|
||||||
PKNORMAL_ROUTINE* NormalRoutine,
|
|
||||||
PVOID* NormalContext,
|
VOID IopCompleteRequest(struct _KAPC* Apc,
|
||||||
PVOID* SystemArgument1,
|
PKNORMAL_ROUTINE* NormalRoutine,
|
||||||
PVOID* SystemArgument2)
|
PVOID* NormalContext,
|
||||||
{
|
PVOID* SystemArgument1,
|
||||||
IoSecondStageCompletion((PIRP)(*NormalContext),
|
PVOID* SystemArgument2)
|
||||||
IO_NO_INCREMENT);
|
{
|
||||||
}
|
IoSecondStageCompletion((PIRP)(*NormalContext),
|
||||||
|
IO_NO_INCREMENT);
|
||||||
VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost)
|
}
|
||||||
/*
|
|
||||||
* FUNCTION: Indicates the caller has finished all processing for a given
|
VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost)
|
||||||
* I/O request and is returning the given IRP to the I/O manager
|
/*
|
||||||
* ARGUMENTS:
|
* FUNCTION: Indicates the caller has finished all processing for a given
|
||||||
* Irp = Irp to be cancelled
|
* I/O request and is returning the given IRP to the I/O manager
|
||||||
* PriorityBoost = Increment by which to boost the priority of the
|
* ARGUMENTS:
|
||||||
* thread making the request
|
* Irp = Irp to be cancelled
|
||||||
*/
|
* PriorityBoost = Increment by which to boost the priority of the
|
||||||
{
|
* thread making the request
|
||||||
unsigned int i;
|
*/
|
||||||
NTSTATUS Status;
|
{
|
||||||
|
unsigned int i;
|
||||||
DPRINT("IoCompleteRequest(Irp %x, PriorityBoost %d)\n",
|
NTSTATUS Status;
|
||||||
Irp,PriorityBoost);
|
|
||||||
|
DPRINT("IoCompleteRequest(Irp %x, PriorityBoost %d)\n",
|
||||||
for (i=0;i<Irp->StackCount;i++)
|
Irp,PriorityBoost);
|
||||||
{
|
|
||||||
DPRINT("&Irp->Stack[i] %x\n",&Irp->Stack[i]);
|
for (i=0;i<Irp->StackCount;i++)
|
||||||
if (Irp->Stack[i].CompletionRoutine!=NULL)
|
{
|
||||||
{
|
DPRINT("&Irp->Stack[%d].CompletionRoutine %08lx\n",
|
||||||
Status = Irp->Stack[i].CompletionRoutine(
|
i,
|
||||||
Irp->Stack[i].DeviceObject,
|
Irp->Stack[i].CompletionRoutine);
|
||||||
Irp,
|
if (Irp->Stack[i].CompletionRoutine != NULL)
|
||||||
Irp->Stack[i].CompletionContext);
|
{
|
||||||
if (Status == STATUS_MORE_PROCESSING_REQUIRED)
|
Status = Irp->Stack[i].CompletionRoutine(
|
||||||
{
|
Irp->Stack[i].DeviceObject,
|
||||||
return;
|
Irp,
|
||||||
}
|
Irp->Stack[i].CompletionContext);
|
||||||
}
|
if (Status == STATUS_MORE_PROCESSING_REQUIRED)
|
||||||
DPRINT("Irp->Stack[i].Control %x\n",Irp->Stack[i].Control);
|
{
|
||||||
if (Irp->Stack[i].Control & SL_PENDING_RETURNED)
|
return;
|
||||||
{
|
}
|
||||||
DPRINT("Setting PendingReturned flag\n");
|
}
|
||||||
Irp->PendingReturned = TRUE;
|
DPRINT("Irp->Stack[%d].Control %08lx\n", i, Irp->Stack[i].Control);
|
||||||
}
|
if (Irp->Stack[i].Control & SL_PENDING_RETURNED)
|
||||||
}
|
{
|
||||||
|
DPRINT("Setting PendingReturned flag\n");
|
||||||
if (Irp->PendingReturned)
|
Irp->PendingReturned = TRUE;
|
||||||
{
|
}
|
||||||
KeInitializeApc(&Irp->Tail.Apc,
|
}
|
||||||
&Irp->Tail.Overlay.Thread->Tcb,
|
|
||||||
0,
|
if (Irp->PendingReturned)
|
||||||
IopCompleteRequest,
|
{
|
||||||
NULL,
|
KeInitializeApc(&Irp->Tail.Apc,
|
||||||
NULL,
|
&Irp->Tail.Overlay.Thread->Tcb,
|
||||||
0,
|
0,
|
||||||
Irp);
|
IopCompleteRequest,
|
||||||
KeInsertQueueApc(&Irp->Tail.Apc,NULL,NULL,0);
|
NULL,
|
||||||
}
|
NULL,
|
||||||
else
|
0,
|
||||||
{
|
Irp);
|
||||||
IoSecondStageCompletion(Irp,PriorityBoost);
|
KeInsertQueueApc(&Irp->Tail.Apc,NULL,NULL,0);
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
>>>>>>> 1.7
|
{
|
||||||
|
IoSecondStageCompletion(Irp,PriorityBoost);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
assert(FileObject != NULL);
|
||||||
|
|
||||||
if (ByteOffset==NULL)
|
if (ByteOffset==NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
//#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* MACROS ********************************************************************/
|
/* MACROS ********************************************************************/
|
||||||
|
@ -196,7 +196,7 @@ LdrPEProcessDriver(PVOID ModuleLoadBase)
|
||||||
PIMAGE_FILE_HEADER PEFileHeader;
|
PIMAGE_FILE_HEADER PEFileHeader;
|
||||||
PIMAGE_OPTIONAL_HEADER PEOptionalHeader;
|
PIMAGE_OPTIONAL_HEADER PEOptionalHeader;
|
||||||
|
|
||||||
DbgPrint("Processing PE Driver at module base:%08lx\n", ModuleLoadBase);
|
DPRINT("Processing PE Driver at module base:%08lx\n", ModuleLoadBase);
|
||||||
|
|
||||||
/* Get header pointers */
|
/* Get header pointers */
|
||||||
PEDosHeader = (PIMAGE_DOS_HEADER) ModuleLoadBase;
|
PEDosHeader = (PIMAGE_DOS_HEADER) ModuleLoadBase;
|
||||||
|
@ -223,18 +223,18 @@ LdrPEProcessDriver(PVOID ModuleLoadBase)
|
||||||
|
|
||||||
/* FIXME: check/verify OS version number */
|
/* FIXME: check/verify OS version number */
|
||||||
|
|
||||||
DbgPrint("OptionalHdrMagic:%04x LinkVersion:%d.%d\n",
|
DPRINT("OptionalHdrMagic:%04x LinkVersion:%d.%d\n",
|
||||||
PEOptionalHeader->Magic,
|
PEOptionalHeader->Magic,
|
||||||
PEOptionalHeader->MajorLinkerVersion,
|
PEOptionalHeader->MajorLinkerVersion,
|
||||||
PEOptionalHeader->MinorLinkerVersion);
|
PEOptionalHeader->MinorLinkerVersion);
|
||||||
DbgPrint("Size: CODE:%08lx(%d) DATA:%08lx(%d) BSS:%08lx(%d)\n",
|
DPRINT("Size: CODE:%08lx(%d) DATA:%08lx(%d) BSS:%08lx(%d)\n",
|
||||||
PEOptionalHeader->SizeOfCode,
|
PEOptionalHeader->SizeOfCode,
|
||||||
PEOptionalHeader->SizeOfCode,
|
PEOptionalHeader->SizeOfCode,
|
||||||
PEOptionalHeader->SizeOfInitializedData,
|
PEOptionalHeader->SizeOfInitializedData,
|
||||||
PEOptionalHeader->SizeOfInitializedData,
|
PEOptionalHeader->SizeOfInitializedData,
|
||||||
PEOptionalHeader->SizeOfUninitializedData,
|
PEOptionalHeader->SizeOfUninitializedData,
|
||||||
PEOptionalHeader->SizeOfUninitializedData);
|
PEOptionalHeader->SizeOfUninitializedData);
|
||||||
DbgPrint("Entry Point:%08lx\n", PEOptionalHeader->AddressOfEntryPoint);
|
DPRINT("Entry Point:%08lx\n", PEOptionalHeader->AddressOfEntryPoint);
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
|
||||||
/* Determine the size of the module */
|
/* Determine the size of the module */
|
||||||
|
@ -450,8 +450,9 @@ LdrCOFFDoRelocations(module *Module, unsigned int SectionIndex)
|
||||||
|
|
||||||
for (j = 0; j < Section->s_nreloc; j++)
|
for (j = 0; j < Section->s_nreloc; j++)
|
||||||
{
|
{
|
||||||
DbgPrint("vaddr %x ", Relocation->r_vaddr);
|
DPRINT("vaddr %x symndex %x",
|
||||||
DbgPrint("symndex %x ", Relocation->r_symndx);
|
Relocation->r_vaddr,
|
||||||
|
Relocation->r_symndx);
|
||||||
|
|
||||||
switch (Relocation->r_type)
|
switch (Relocation->r_type)
|
||||||
{
|
{
|
||||||
|
@ -470,10 +471,10 @@ LdrCOFFDoRelocations(module *Module, unsigned int SectionIndex)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DbgPrint("%.8s: Unknown relocation type %x at %d in module\n",
|
DPRINT("%.8s: Unknown relocation type %x at %d in module\n",
|
||||||
Module->scn_list[SectionIndex].s_name,
|
Module->scn_list[SectionIndex].s_name,
|
||||||
Relocation->r_type,
|
Relocation->r_type,
|
||||||
j);
|
j);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
Relocation++;
|
Relocation++;
|
||||||
|
@ -502,7 +503,7 @@ LdrCOFFDoAddr32Reloc(module *Module, SCNHDR *Section, RELOC *Relocation)
|
||||||
|
|
||||||
Value = LdrCOFFGetSymbolValue(Module, Relocation->r_symndx);
|
Value = LdrCOFFGetSymbolValue(Module, Relocation->r_symndx);
|
||||||
Location = (unsigned int *)(Module->base + Relocation->r_vaddr);
|
Location = (unsigned int *)(Module->base + Relocation->r_vaddr);
|
||||||
DbgPrint("ADDR32 loc %x value %x *loc %x ", Location, Value, *Location);
|
DPRINT("ADDR32 loc %x value %x *loc %x\n", Location, Value, *Location);
|
||||||
*Location = (*Location) + Module->base;
|
*Location = (*Location) + Module->base;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -596,7 +597,7 @@ LdrCOFFGetSymbolValue(module *Module, unsigned int Idx)
|
||||||
char Name[255];
|
char Name[255];
|
||||||
|
|
||||||
LdrCOFFGetSymbolName(Module, Idx, Name);
|
LdrCOFFGetSymbolName(Module, Idx, Name);
|
||||||
DbgPrint("name %s ", Name);
|
DPRINT("name %s ", Name);
|
||||||
|
|
||||||
/* Check if the symbol is a section we have relocated */
|
/* Check if the symbol is a section we have relocated */
|
||||||
if (strcmp(Name, ".text") == 0)
|
if (strcmp(Name, ".text") == 0)
|
||||||
|
@ -714,7 +715,7 @@ NTSTATUS LdrLoadLibrary(HANDLE ProcessHandle,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DbgPrint("Library already loaded\n");
|
DPRINT("Library already loaded\n");
|
||||||
*Module = Library
|
*Module = Library
|
||||||
}
|
}
|
||||||
RtlFreeUnicodeString(&umodName);
|
RtlFreeUnicodeString(&umodName);
|
||||||
|
|
Loading…
Reference in a new issue