mirror of
https://github.com/reactos/reactos.git
synced 2024-06-30 01:42:30 +00:00
Changes to support new VFAT functions and the loader
svn path=/trunk/; revision=140
This commit is contained in:
parent
6ce4528a80
commit
3244132cc7
|
@ -1946,12 +1946,14 @@ IDEIoTimer(PDEVICE_OBJECT DeviceObject,
|
||||||
PIDE_CONTROLLER_EXTENSION ControllerExtension;
|
PIDE_CONTROLLER_EXTENSION ControllerExtension;
|
||||||
|
|
||||||
// Setup Extension pointer
|
// Setup Extension pointer
|
||||||
|
CHECKPOINT;
|
||||||
ControllerExtension = (PIDE_CONTROLLER_EXTENSION) Context;
|
ControllerExtension = (PIDE_CONTROLLER_EXTENSION) Context;
|
||||||
|
|
||||||
// Handle state change if necessary
|
// Handle state change if necessary
|
||||||
switch (ControllerExtension->TimerState)
|
switch (ControllerExtension->TimerState)
|
||||||
{
|
{
|
||||||
case IDETimerResetWaitForBusyNegate:
|
case IDETimerResetWaitForBusyNegate:
|
||||||
|
CHECKPOINT;
|
||||||
if (!(IDEReadStatus(ControllerExtension->CommandPortBase) &
|
if (!(IDEReadStatus(ControllerExtension->CommandPortBase) &
|
||||||
IDE_SR_BUSY))
|
IDE_SR_BUSY))
|
||||||
{
|
{
|
||||||
|
@ -1962,6 +1964,7 @@ IDEIoTimer(PDEVICE_OBJECT DeviceObject,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDETimerResetWaitForDrdyAssert:
|
case IDETimerResetWaitForDrdyAssert:
|
||||||
|
CHECKPOINT;
|
||||||
if (IDEReadStatus(ControllerExtension->CommandPortBase) &
|
if (IDEReadStatus(ControllerExtension->CommandPortBase) &
|
||||||
IDE_SR_DRQ)
|
IDE_SR_DRQ)
|
||||||
{
|
{
|
||||||
|
@ -1988,12 +1991,14 @@ IDEIoTimer(PDEVICE_OBJECT DeviceObject,
|
||||||
// If we're counting down, then count.
|
// If we're counting down, then count.
|
||||||
if (ControllerExtension->TimerCount > 0)
|
if (ControllerExtension->TimerCount > 0)
|
||||||
{
|
{
|
||||||
|
CHECKPOINT;
|
||||||
ControllerExtension->TimerCount--;
|
ControllerExtension->TimerCount--;
|
||||||
|
|
||||||
// Else we'll check the state and process if necessary
|
// Else we'll check the state and process if necessary
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
CHECKPOINT;
|
||||||
switch (ControllerExtension->TimerState)
|
switch (ControllerExtension->TimerState)
|
||||||
{
|
{
|
||||||
case IDETimerIdle:
|
case IDETimerIdle:
|
||||||
|
@ -2001,6 +2006,7 @@ IDEIoTimer(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
case IDETimerCmdWait:
|
case IDETimerCmdWait:
|
||||||
// Command timed out, reset drive and try again or fail
|
// Command timed out, reset drive and try again or fail
|
||||||
|
CHECKPOINT;
|
||||||
if (++ControllerExtension->Retries > IDE_MAX_CMD_RETRIES)
|
if (++ControllerExtension->Retries > IDE_MAX_CMD_RETRIES)
|
||||||
{
|
{
|
||||||
ControllerExtension->CurrentIrp->IoStatus.Status = STATUS_IO_TIMEOUT;
|
ControllerExtension->CurrentIrp->IoStatus.Status = STATUS_IO_TIMEOUT;
|
||||||
|
@ -2015,6 +2021,7 @@ IDEIoTimer(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
case IDETimerResetWaitForBusyNegate:
|
case IDETimerResetWaitForBusyNegate:
|
||||||
case IDETimerResetWaitForDrdyAssert:
|
case IDETimerResetWaitForDrdyAssert:
|
||||||
|
CHECKPOINT;
|
||||||
ControllerExtension->CurrentIrp->IoStatus.Status = STATUS_IO_TIMEOUT;
|
ControllerExtension->CurrentIrp->IoStatus.Status = STATUS_IO_TIMEOUT;
|
||||||
ControllerExtension->CurrentIrp->IoStatus.Information = 0;
|
ControllerExtension->CurrentIrp->IoStatus.Information = 0;
|
||||||
IDEFinishOperation(ControllerExtension);
|
IDEFinishOperation(ControllerExtension);
|
||||||
|
|
|
@ -36,10 +36,8 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||||
DPRINT("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
DPRINT("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
||||||
pDeviceObject,DiskSector,Buffer);
|
pDeviceObject,DiskSector,Buffer);
|
||||||
|
|
||||||
// sectorNumber.HighPart = 0;
|
SET_LARGE_INTEGER_LOW_PART(sectorNumber, DiskSector << 9);
|
||||||
// sectorNumber.LowPart = DiskSector * BLOCKSIZE;
|
SET_LARGE_INTEGER_HIGH_PART(sectorNumber, DiskSector >> 23);
|
||||||
sectorNumber.LowPart=DiskSector<<9;
|
|
||||||
sectorNumber.HighPart=DiskSector>>23;
|
|
||||||
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
||||||
|
|
||||||
sectorSize = BLOCKSIZE*SectorCount;
|
sectorSize = BLOCKSIZE*SectorCount;
|
||||||
|
@ -84,7 +82,11 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||||
if (!NT_SUCCESS(status)) {
|
if (!NT_SUCCESS(status)) {
|
||||||
DbgPrint("IO failed!!! VFATREadSectors : Error code: %x\n", status);
|
DbgPrint("IO failed!!! VFATREadSectors : Error code: %x\n", status);
|
||||||
DbgPrint("(pDeviceObject %x, DiskSector %x, Buffer %x, offset 0x%x%x)\n",
|
DbgPrint("(pDeviceObject %x, DiskSector %x, Buffer %x, offset 0x%x%x)\n",
|
||||||
pDeviceObject,DiskSector,Buffer,sectorNumber.HighPart,sectorNumber.LowPart);
|
pDeviceObject,
|
||||||
|
DiskSector,
|
||||||
|
Buffer,
|
||||||
|
GET_LARGE_INTEGER_HIGH_PART(sectorNumber),
|
||||||
|
GET_LARGE_INTEGER_LOW_PART(sectorNumber));
|
||||||
ExFreePool(mbr);
|
ExFreePool(mbr);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -113,8 +115,8 @@ BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||||
DPRINT("VFATWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
DPRINT("VFATWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
||||||
pDeviceObject,DiskSector,Buffer);
|
pDeviceObject,DiskSector,Buffer);
|
||||||
|
|
||||||
sectorNumber.HighPart = 0;
|
SET_LARGE_INTEGER_LOW_PART(sectorNumber, DiskSector << 9);
|
||||||
sectorNumber.LowPart = DiskSector * BLOCKSIZE;
|
SET_LARGE_INTEGER_HIGH_PART(sectorNumber, DiskSector >> 23);
|
||||||
|
|
||||||
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -105,9 +105,9 @@ NTSTATUS FsdGetFileDirectoryInformation(PFCB pFcb,
|
||||||
AllocSize = ((pFcb->entry.FileSize + DeviceExt->BytesPerCluster - 1) /
|
AllocSize = ((pFcb->entry.FileSize + DeviceExt->BytesPerCluster - 1) /
|
||||||
DeviceExt->BytesPerCluster) *
|
DeviceExt->BytesPerCluster) *
|
||||||
DeviceExt->BytesPerCluster;
|
DeviceExt->BytesPerCluster;
|
||||||
pInfo->AllocationSize.LowPart= AllocSize;
|
LARGE_INTEGER_QUAD_PART(pInfo->AllocationSize) = AllocSize;
|
||||||
pInfo->AllocationSize.HighPart= AllocSize >>32;
|
|
||||||
pInfo->FileAttributes=pFcb->entry.Attrib;
|
pInfo->FileAttributes=pFcb->entry.Attrib;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,8 +138,7 @@ NTSTATUS FsdGetFileFullDirectoryInformation(PFCB pFcb,
|
||||||
AllocSize = ((pFcb->entry.FileSize + DeviceExt->BytesPerCluster - 1) /
|
AllocSize = ((pFcb->entry.FileSize + DeviceExt->BytesPerCluster - 1) /
|
||||||
DeviceExt->BytesPerCluster) *
|
DeviceExt->BytesPerCluster) *
|
||||||
DeviceExt->BytesPerCluster;
|
DeviceExt->BytesPerCluster;
|
||||||
pInfo->AllocationSize.LowPart= AllocSize;
|
LARGE_INTEGER_QUAD_PART(pInfo->AllocationSize) = AllocSize;
|
||||||
pInfo->AllocationSize.HighPart= (AllocSize >>32);
|
|
||||||
pInfo->FileAttributes=pFcb->entry.Attrib;
|
pInfo->FileAttributes=pFcb->entry.Attrib;
|
||||||
// pInfo->EaSize=;
|
// pInfo->EaSize=;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
@ -176,8 +175,7 @@ DPRINT("sizeof %d,Length %d, BufLength %d, Next %d\n"
|
||||||
AllocSize = ((pFcb->entry.FileSize + DeviceExt->BytesPerCluster - 1) /
|
AllocSize = ((pFcb->entry.FileSize + DeviceExt->BytesPerCluster - 1) /
|
||||||
DeviceExt->BytesPerCluster) *
|
DeviceExt->BytesPerCluster) *
|
||||||
DeviceExt->BytesPerCluster;
|
DeviceExt->BytesPerCluster;
|
||||||
pInfo->AllocationSize.LowPart= AllocSize;
|
LARGE_INTEGER_QUAD_PART(pInfo->AllocationSize) = AllocSize;
|
||||||
pInfo->AllocationSize.HighPart= AllocSize >>32;
|
|
||||||
pInfo->FileAttributes=pFcb->entry.Attrib;
|
pInfo->FileAttributes=pFcb->entry.Attrib;
|
||||||
// pInfo->EaSize=;
|
// pInfo->EaSize=;
|
||||||
for (i=0;i<8 && (pFcb->entry.Filename[i]!=' ') ;i++)
|
for (i=0;i<8 && (pFcb->entry.Filename[i]!=' ') ;i++)
|
||||||
|
|
|
@ -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"
|
||||||
|
@ -657,15 +657,29 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
{
|
{
|
||||||
PWSTR current;
|
PWSTR current;
|
||||||
PWSTR next;
|
PWSTR next;
|
||||||
PWSTR string = FileName;
|
PWSTR string;
|
||||||
PFCB ParentFcb = NULL;
|
PFCB ParentFcb;
|
||||||
PFCB Fcb = ExAllocatePool(NonPagedPool,sizeof(FCB));
|
PFCB Fcb;
|
||||||
PFCB Temp;
|
PFCB Temp;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("FsdOpenFile(%08lx, %08lx, %08lx)\n",
|
||||||
|
DeviceExt,
|
||||||
|
FileObject,
|
||||||
|
FileName);
|
||||||
|
|
||||||
|
CHECKPOINT;
|
||||||
|
string = FileName;
|
||||||
|
CHECKPOINT;
|
||||||
|
ParentFcb = NULL;
|
||||||
|
CHECKPOINT;
|
||||||
|
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);
|
||||||
|
@ -678,9 +692,11 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
*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)
|
||||||
{
|
{
|
||||||
|
/* FIXME: should the FCB be freed here? */
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
Temp = Fcb;
|
Temp = Fcb;
|
||||||
|
@ -693,6 +709,7 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
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);
|
||||||
|
@ -1014,21 +1031,33 @@ NTSTATUS FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
* FUNCTION: Create or open a file
|
* FUNCTION: Create or open a file
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
PIO_STACK_LOCATION Stack;
|
||||||
PFILE_OBJECT FileObject = Stack->FileObject;
|
PFILE_OBJECT FileObject;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PDEVICE_EXTENSION DeviceExt;
|
PDEVICE_EXTENSION DeviceExt;
|
||||||
|
|
||||||
DPRINT("VFAT FsdCreate...\n");
|
DPRINT("FsdCreate(DeviceObject %08lx, Irp %08lx)\n",
|
||||||
|
DeviceObject,
|
||||||
|
Irp);
|
||||||
|
|
||||||
|
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
CHECKPOINT;
|
||||||
|
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);
|
||||||
return(Status);
|
CHECKPOINT;
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1049,7 +1078,7 @@ NTSTATUS FsdWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
|
|
||||||
Length = Stack->Parameters.Write.Length;
|
Length = Stack->Parameters.Write.Length;
|
||||||
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
|
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
|
||||||
Offset = Stack->Parameters.Write.ByteOffset.LowPart;
|
Offset = GET_LARGE_INTEGER_LOW_PART(Stack->Parameters.Write.ByteOffset);
|
||||||
|
|
||||||
Status = FsdWriteFile(DeviceExt,FileObject,Buffer,Length,Offset);
|
Status = FsdWriteFile(DeviceExt,FileObject,Buffer,Length,Offset);
|
||||||
|
|
||||||
|
@ -1078,7 +1107,7 @@ NTSTATUS FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
|
|
||||||
Length = Stack->Parameters.Read.Length;
|
Length = Stack->Parameters.Read.Length;
|
||||||
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
|
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
|
||||||
Offset = Stack->Parameters.Read.ByteOffset.LowPart;
|
Offset = GET_LARGE_INTEGER_LOW_PART(Stack->Parameters.Read.ByteOffset);
|
||||||
|
|
||||||
Status = FsdReadFile(DeviceExt,FileObject,Buffer,Length,Offset,
|
Status = FsdReadFile(DeviceExt,FileObject,Buffer,Length,Offset,
|
||||||
&LengthRead);
|
&LengthRead);
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
OBJECTS= blockdev.o iface.o dir.o
|
OBJECTS= blockdev.o iface.o dir.o
|
||||||
|
|
||||||
all: $(OBJECTS)
|
all: vfatfsd.o
|
||||||
|
|
||||||
|
vfatfsd.o: $(OBJECTS)
|
||||||
$(LD) $(OBJECTS) -r -o vfatfsd.o
|
$(LD) $(OBJECTS) -r -o vfatfsd.o
|
||||||
$(NM) --numeric-sort vfatfsd.o > vfatfsd.sym
|
$(NM) --numeric-sort vfatfsd.o > vfatfsd.sym
|
||||||
|
|
||||||
|
|
|
@ -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 *************************************************************/
|
||||||
|
@ -165,13 +165,13 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
|
||||||
}
|
}
|
||||||
DeviceObject = IoGetAttachedDevice(DeviceObject);
|
DeviceObject = IoGetAttachedDevice(DeviceObject);
|
||||||
}
|
}
|
||||||
// DPRINT("Remainder %x\n",Remainder);
|
DPRINT("Remainder %x\n",Remainder);
|
||||||
// DPRINT("Remainder %w\n",Remainder);
|
DPRINT("Remainder %w\n",Remainder);
|
||||||
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
|
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
|
||||||
wstrlen(Remainder));
|
wstrlen(Remainder));
|
||||||
RtlInitUnicodeString(&(FileObject->FileName),Remainder);
|
RtlInitUnicodeString(&(FileObject->FileName),Remainder);
|
||||||
// DPRINT("FileObject->FileName.Buffer %x %w\n",
|
DPRINT("FileObject->FileName.Buffer %x %w\n",
|
||||||
// FileObject->FileName.Buffer,FileObject->FileName.Buffer);
|
FileObject->FileName.Buffer,FileObject->FileName.Buffer);
|
||||||
}
|
}
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
|
||||||
|
@ -190,6 +190,7 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
|
||||||
|
|
||||||
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||||
|
|
||||||
|
DPRINT("DevObj StackSize %d\n", DeviceObject->StackSize);
|
||||||
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
|
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
|
||||||
if (Irp==NULL)
|
if (Irp==NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#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 ****************************************************************/
|
||||||
|
@ -125,7 +125,12 @@ PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
|
||||||
* RETURNS: A pointer to the stack location
|
* RETURNS: A pointer to the stack location
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
return(&Irp->Stack[Irp->CurrentLocation]);
|
DPRINT("IoGetCurrentIrpStackLocation: Irp %08lx CurLoc %d StkCnt %d\n",
|
||||||
|
Irp,
|
||||||
|
Irp->CurrentLocation,
|
||||||
|
Irp->StackCount);
|
||||||
|
|
||||||
|
return &Irp->Stack[Irp->CurrentLocation];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,6 +149,11 @@ PIO_STACK_LOCATION IoGetNextIrpStackLocation(PIRP Irp)
|
||||||
* RETURNS: A pointer to the stack location
|
* RETURNS: A pointer to the stack location
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
DPRINT("IoGetNextIrpStackLocation: Irp %08lx CurLoc %d StkCnt %d\n",
|
||||||
|
Irp,
|
||||||
|
Irp->CurrentLocation,
|
||||||
|
Irp->StackCount);
|
||||||
|
|
||||||
assert(Irp!=NULL);
|
assert(Irp!=NULL);
|
||||||
DPRINT("Irp %x Irp->StackPtr %x\n",Irp,Irp->CurrentLocation);
|
DPRINT("Irp %x Irp->StackPtr %x\n",Irp,Irp->CurrentLocation);
|
||||||
return(&Irp->Stack[Irp->CurrentLocation-1]);
|
return(&Irp->Stack[Irp->CurrentLocation-1]);
|
||||||
|
@ -154,17 +164,22 @@ 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;
|
PDRIVER_OBJECT drv = DevObject->DriverObject;
|
||||||
IO_STACK_LOCATION* param = IoGetNextIrpStackLocation(irp);
|
IO_STACK_LOCATION* param = IoGetNextIrpStackLocation(irp);
|
||||||
|
|
||||||
DPRINT("Deviceobject %x\n",DevObject);
|
DPRINT("Deviceobject %x\n",DevObject);
|
||||||
DPRINT("Irp %x\n",irp);
|
DPRINT("Irp %x\n",irp);
|
||||||
|
|
||||||
irp->Tail.Overlay.CurrentStackLocation--;
|
irp->Tail.Overlay.CurrentStackLocation--;
|
||||||
irp->CurrentLocation--;
|
irp->CurrentLocation--;
|
||||||
|
|
||||||
DPRINT("Io stack address %x\n",param);
|
DPRINT("Io stack address %x\n",param);
|
||||||
DPRINT("Function %d Routine %x\n",param->MajorFunction,
|
DPRINT("Function %d Routine %x\n",param->MajorFunction,
|
||||||
drv->MajorFunction[param->MajorFunction]);
|
drv->MajorFunction[param->MajorFunction]);
|
||||||
|
|
||||||
return(drv->MajorFunction[param->MajorFunction](DevObject,irp));
|
Status = drv->MajorFunction[param->MajorFunction](DevObject,irp);
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
PIRP IoAllocateIrp(CCHAR StackSize, BOOLEAN ChargeQuota)
|
PIRP IoAllocateIrp(CCHAR StackSize, BOOLEAN ChargeQuota)
|
||||||
|
|
|
@ -91,7 +91,6 @@ VOID LdrInitModuleManagment(VOID)
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
LdrLoadDriver(PUNICODE_STRING Filename)
|
LdrLoadDriver(PUNICODE_STRING Filename)
|
||||||
{
|
{
|
||||||
char BlockBuffer[512];
|
|
||||||
PVOID ModuleLoadBase;
|
PVOID ModuleLoadBase;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
HANDLE FileHandle;
|
HANDLE FileHandle;
|
||||||
|
@ -107,25 +106,18 @@ LdrLoadDriver(PUNICODE_STRING Filename)
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
CHECKPOINT;
|
||||||
Status = ZwOpenFile(&FileHandle,
|
Status = ZwOpenFile(&FileHandle,
|
||||||
FILE_ALL_ACCESS,
|
FILE_ALL_ACCESS,
|
||||||
&FileObjectAttributes,
|
&FileObjectAttributes,
|
||||||
NULL, 0, 0);
|
NULL, 0, 0);
|
||||||
|
CHECKPOINT;
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
|
||||||
/* Read first block of image to determine type */
|
|
||||||
Status = ZwReadFile(FileHandle, 0, 0, 0, 0, BlockBuffer, 512, 0, 0);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
ZwClose(FileHandle);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
CHECKPOINT;
|
|
||||||
|
|
||||||
/* Get the size of the file */
|
/* Get the size of the file */
|
||||||
Status = ZwQueryInformationFile(FileHandle,
|
Status = ZwQueryInformationFile(FileHandle,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if CHECKED
|
||||||
#define VALIDATE_POOL validate_kernel_pool()
|
#define VALIDATE_POOL validate_kernel_pool()
|
||||||
#else
|
#else
|
||||||
#define VALIDATE_POOL
|
#define VALIDATE_POOL
|
||||||
|
@ -528,11 +528,13 @@ asmlinkage VOID ExFreePool(PVOID block)
|
||||||
* block = block to free
|
* block = block to free
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
block_hdr* blk=address_to_block(block);
|
block_hdr *blk = address_to_block(block);
|
||||||
OLD_DPRINT("(%s:%d) freeing block %x\n",__FILE__,__LINE__,blk);
|
|
||||||
|
OLD_DPRINT("ExFreePool(block %x), size %d, caller %x\n",
|
||||||
// DbgPrint("ExFreePool(block %x), size %d, caller %x\n",block,blk->size,
|
block,
|
||||||
// ((PULONG)&block)[-1]);
|
blk->size,
|
||||||
|
((PULONG)&block)[-1]);
|
||||||
|
OLD_DPRINT("freeing block %x\n",blk);
|
||||||
|
|
||||||
VALIDATE_POOL;
|
VALIDATE_POOL;
|
||||||
|
|
||||||
|
@ -560,9 +562,9 @@ PVOID ExAllocateNonPagedPoolWithTag(ULONG type, ULONG size, ULONG Tag)
|
||||||
block_hdr* current=NULL;
|
block_hdr* current=NULL;
|
||||||
void* block;
|
void* block;
|
||||||
|
|
||||||
// DbgPrint("Blocks on free list %d\n",nr_free_blocks);
|
OLD_DPRINT("Blocks on free list %d\n",nr_free_blocks);
|
||||||
// DbgPrint("Blocks on used list %d\n",nr_used_blocks);
|
OLD_DPRINT("Blocks on used list %d\n",nr_used_blocks);
|
||||||
// OLD_DPRINT("ExAllocateNonPagedPool(type %d, size %d)\n",type,size);
|
OLD_DPRINT("ExAllocateNonPagedPool(type %d, size %d)\n",type,size);
|
||||||
VALIDATE_POOL;
|
VALIDATE_POOL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -602,5 +604,6 @@ PVOID ExAllocateNonPagedPoolWithTag(ULONG type, ULONG size, ULONG Tag)
|
||||||
*/
|
*/
|
||||||
block=block_to_address(grow_kernel_pool(size));
|
block=block_to_address(grow_kernel_pool(size));
|
||||||
memset(block,0,size);
|
memset(block,0,size);
|
||||||
return(block);
|
|
||||||
|
return block;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,11 +45,16 @@ PVOID ExAllocatePool(POOL_TYPE PoolType, ULONG NumberOfBytes)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PVOID Block;
|
PVOID Block;
|
||||||
// DbgPrint("ExAllocatePool(NumberOfBytes %d) caller %x\n",
|
|
||||||
// NumberOfBytes,((PULONG)&PoolType)[-1]);
|
OLD_DPRINT("ExAllocatePool(NumberOfBytes %d) caller %x\n",
|
||||||
|
NumberOfBytes,
|
||||||
|
((PULONG)&PoolType)[-1]);
|
||||||
|
|
||||||
Block = ExAllocatePoolWithTag(PoolType,NumberOfBytes,TAG_NONE);
|
Block = ExAllocatePoolWithTag(PoolType,NumberOfBytes,TAG_NONE);
|
||||||
// DbgPrint("ExAllocatePool() = %x\n",Block);
|
|
||||||
return(Block);
|
OLD_DPRINT("ExAllocatePool() = %x\n",Block);
|
||||||
|
|
||||||
|
return Block;
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID ExAllocatePoolWithTag(ULONG type, ULONG size, ULONG Tag)
|
PVOID ExAllocatePoolWithTag(ULONG type, ULONG size, ULONG Tag)
|
||||||
|
|
Loading…
Reference in a new issue