mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 19:55:41 +00:00
[KMTESTS]
- Fix IRP handling, and some 64 bit warnings svn path=/trunk/; revision=55031
This commit is contained in:
parent
7e9887db23
commit
74a51ae888
2 changed files with 48 additions and 8 deletions
|
@ -22,8 +22,13 @@
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
DRIVER_INITIALIZE DriverEntry;
|
DRIVER_INITIALIZE DriverEntry;
|
||||||
static DRIVER_UNLOAD DriverUnload;
|
static DRIVER_UNLOAD DriverUnload;
|
||||||
|
__drv_dispatchType(IRP_MJ_CREATE)
|
||||||
static DRIVER_DISPATCH DriverCreate;
|
static DRIVER_DISPATCH DriverCreate;
|
||||||
|
__drv_dispatchType(IRP_MJ_CLEANUP)
|
||||||
|
static DRIVER_DISPATCH DriverCleanup;
|
||||||
|
__drv_dispatchType(IRP_MJ_CLOSE)
|
||||||
static DRIVER_DISPATCH DriverClose;
|
static DRIVER_DISPATCH DriverClose;
|
||||||
|
__drv_dispatchType(IRP_MJ_DEVICE_CONTROL)
|
||||||
static DRIVER_DISPATCH DriverIoControl;
|
static DRIVER_DISPATCH DriverIoControl;
|
||||||
|
|
||||||
/* Globals */
|
/* Globals */
|
||||||
|
@ -83,6 +88,7 @@ DriverEntry(
|
||||||
|
|
||||||
DriverObject->DriverUnload = DriverUnload;
|
DriverObject->DriverUnload = DriverUnload;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = DriverCreate;
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = DriverCreate;
|
||||||
|
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = DriverCleanup;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = DriverClose;
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = DriverClose;
|
||||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DriverIoControl;
|
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DriverIoControl;
|
||||||
|
|
||||||
|
@ -130,7 +136,7 @@ DriverUnload(
|
||||||
/**
|
/**
|
||||||
* @name DriverCreate
|
* @name DriverCreate
|
||||||
*
|
*
|
||||||
* Driver Dispatch function for CreateFile
|
* Driver Dispatch function for IRP_MJ_CREATE
|
||||||
*
|
*
|
||||||
* @param DeviceObject
|
* @param DeviceObject
|
||||||
* Device Object
|
* Device Object
|
||||||
|
@ -166,9 +172,9 @@ DriverCreate(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name DriverClose
|
* @name DriverCleanup
|
||||||
*
|
*
|
||||||
* Driver Dispatch function for CloseHandle.
|
* Driver Dispatch function for IRP_MJ_CLEANUP
|
||||||
*
|
*
|
||||||
* @param DeviceObject
|
* @param DeviceObject
|
||||||
* Device Object
|
* Device Object
|
||||||
|
@ -180,7 +186,7 @@ DriverCreate(
|
||||||
static
|
static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
DriverClose(
|
DriverCleanup(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +198,7 @@ DriverClose(
|
||||||
|
|
||||||
IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
|
IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
DPRINT("DriverClose. DeviceObject=%p, RequestorMode=%d, FileObject=%p, FsContext=%p, FsContext2=%p\n",
|
DPRINT("DriverCleanup. DeviceObject=%p, RequestorMode=%d, FileObject=%p, FsContext=%p, FsContext2=%p\n",
|
||||||
DeviceObject, Irp->RequestorMode, IoStackLocation->FileObject,
|
DeviceObject, Irp->RequestorMode, IoStackLocation->FileObject,
|
||||||
IoStackLocation->FileObject->FsContext, IoStackLocation->FileObject->FsContext2);
|
IoStackLocation->FileObject->FsContext, IoStackLocation->FileObject->FsContext2);
|
||||||
|
|
||||||
|
@ -218,10 +224,44 @@ DriverClose(
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name DriverClose
|
||||||
|
*
|
||||||
|
* Driver Dispatch function for IRP_MJ_CLOSE
|
||||||
|
*
|
||||||
|
* @param DeviceObject
|
||||||
|
* Device Object
|
||||||
|
* @param Irp
|
||||||
|
* I/O request packet
|
||||||
|
*
|
||||||
|
* @return Status
|
||||||
|
*/
|
||||||
|
static
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DriverClose(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PIRP Irp)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
PAGED_CODE();
|
||||||
|
|
||||||
|
DPRINT("DriverClose. DeviceObject=%p, RequestorMode=%d\n",
|
||||||
|
DeviceObject, Irp->RequestorMode);
|
||||||
|
|
||||||
|
Irp->IoStatus.Status = Status;
|
||||||
|
Irp->IoStatus.Information = 0;
|
||||||
|
|
||||||
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name DriverIoControl
|
* @name DriverIoControl
|
||||||
*
|
*
|
||||||
* Driver Dispatch function for DeviceIoControl.
|
* Driver Dispatch function for IRP_MJ_DEVICE_CONTROL
|
||||||
*
|
*
|
||||||
* @param DeviceObject
|
* @param DeviceObject
|
||||||
* Device Object
|
* Device Object
|
||||||
|
|
|
@ -320,7 +320,7 @@ DriverDispatch(
|
||||||
IrpHandlers[i].IrpHandler != NULL)
|
IrpHandlers[i].IrpHandler != NULL)
|
||||||
return IrpHandlers[i].IrpHandler(DeviceObject, Irp, IoStackLocation);
|
return IrpHandlers[i].IrpHandler(DeviceObject, Irp, IoStackLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* default handler for DeviceControl */
|
/* default handler for DeviceControl */
|
||||||
if (IoStackLocation->MajorFunction == IRP_MJ_DEVICE_CONTROL ||
|
if (IoStackLocation->MajorFunction == IRP_MJ_DEVICE_CONTROL ||
|
||||||
IoStackLocation->MajorFunction == IRP_MJ_INTERNAL_DEVICE_CONTROL)
|
IoStackLocation->MajorFunction == IRP_MJ_INTERNAL_DEVICE_CONTROL)
|
||||||
|
@ -462,7 +462,7 @@ DeviceControlHandler(
|
||||||
{
|
{
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
ULONG ControlCode = (IoStackLocation->Parameters.DeviceIoControl.IoControlCode & 0x00000FFC) >> 2;
|
ULONG ControlCode = (IoStackLocation->Parameters.DeviceIoControl.IoControlCode & 0x00000FFC) >> 2;
|
||||||
ULONG OutLength = IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength;
|
SIZE_T OutLength = IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < sizeof MessageHandlers / sizeof MessageHandlers[0]; ++i)
|
for (i = 0; i < sizeof MessageHandlers / sizeof MessageHandlers[0]; ++i)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue