[KMTESTS]

- Make IRP major function name table public
- IoHelper: catch all IRPs and add debug messages

svn path=/branches/GSoC_2011/KMTestSuite/; revision=53293
This commit is contained in:
Thomas Faber 2011-08-18 07:08:59 +00:00
parent ee28aa087c
commit b9b5b6762d
4 changed files with 50 additions and 40 deletions

View file

@ -8,6 +8,10 @@
#ifndef _KMTEST_PLATFORM_H_
#define _KMTEST_PLATFORM_H_
#if !defined _KMTEST_TEST_H_
#error include kmt_test.h instead of including kmt_platform.h!
#endif /* !defined _KMTEST_TEST_H_ */
#if defined KMT_KERNEL_MODE || defined KMT_STANDALONE_DRIVER
#include <ntddk.h>
#include <ntifs.h>

View file

@ -82,6 +82,7 @@ typedef struct
extern BOOLEAN KmtIsCheckedBuild;
extern BOOLEAN KmtIsMultiProcessorBuild;
extern PCSTR KmtMajorFunctionNames[];
VOID KmtSetIrql(IN KIRQL NewIrql);
BOOLEAN KmtAreInterruptsEnabled(VOID);
@ -96,7 +97,9 @@ VOID KmtCloseDriver(VOID);
DWORD KmtSendToDriver(IN DWORD ControlCode);
DWORD KmtSendStringToDriver(IN DWORD ControlCode, IN PCSTR String);
DWORD KmtSendBufferToDriver(IN DWORD ControlCode, IN OUT PVOID Buffer OPTIONAL, IN DWORD InLength, IN OUT PDWORD OutLength);
#endif /* defined KMT_USER_MODE */
#else /* if !defined KMT_KERNEL_MODE && !defined KMT_USER_MODE */
#error either KMT_KERNEL_MODE or KMT_USER_MODE must be defined
#endif /* !defined KMT_KERNEL_MODE && !defined KMT_USER_MODE */
extern PKMT_RESULTBUFFER ResultBuffer;
@ -169,6 +172,37 @@ BOOLEAN KmtSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, ...)
#if defined KMT_KERNEL_MODE
BOOLEAN KmtIsCheckedBuild;
BOOLEAN KmtIsMultiProcessorBuild;
PCSTR KmtMajorFunctionNames[] =
{
"Create",
"CreateNamedPipe",
"Close",
"Read",
"Write",
"QueryInformation",
"SetInformation",
"QueryEa",
"SetEa",
"FlushBuffers",
"QueryVolumeInformation",
"SetVolumeInformation",
"DirectoryControl",
"FileSystemControl",
"DeviceControl",
"InternalDeviceControl/Scsi",
"Shutdown",
"LockControl",
"Cleanup",
"CreateMailslot",
"QuerySecurity",
"SetSecurity",
"Power",
"SystemControl",
"DeviceChange",
"QueryQuota",
"SetQuota",
"Pnp/PnpPower"
};
VOID KmtSetIrql(IN KIRQL NewIrql)
{

View file

@ -47,38 +47,6 @@ static KMT_IRP_HANDLER_ENTRY IrpHandlers[KMT_MAX_IRP_HANDLERS] = { { 0 } };
#define KMT_MAX_MESSAGE_HANDLERS 256
static KMT_MESSAGE_HANDLER_ENTRY MessageHandlers[KMT_MAX_MESSAGE_HANDLERS] = { { 0 } };
static const char *IrpMajorFunctionNames[] =
{
"Create",
"CreateNamedPipe",
"Close",
"Read",
"Write",
"QueryInformation",
"SetInformation",
"QueryEa",
"SetEa",
"FlushBuffers",
"QueryVolumeInformation",
"SetVolumeInformation",
"DirectoryControl",
"FileSystemControl",
"DeviceControl",
"InternalDeviceControl/Scsi",
"Shutdown",
"LockControl",
"Cleanup",
"CreateMailslot",
"QuerySecurity",
"SetSecurity",
"Power",
"SystemControl",
"DeviceChange",
"QueryQuota",
"SetQuota",
"Pnp/PnpPower"
};
/**
* @name DriverEntry
*
@ -342,7 +310,7 @@ DriverDispatch(
IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
DPRINT("DriverDispatch: Function=%s, Device=%p\n",
IrpMajorFunctionNames[IoStackLocation->MajorFunction],
KmtMajorFunctionNames[IoStackLocation->MajorFunction],
DeviceObject);
for (i = 0; i < sizeof IrpHandlers / sizeof IrpHandlers[0]; ++i)

View file

@ -20,6 +20,7 @@ TestEntry(
IN OUT INT *Flags)
{
NTSTATUS Status = STATUS_SUCCESS;
INT i;
PAGED_CODE();
@ -27,10 +28,12 @@ TestEntry(
UNREFERENCED_PARAMETER(RegistryPath);
UNREFERENCED_PARAMETER(Flags);
DPRINT("TestEntry. DriverObject=%p, RegistryPath=%wZ\n", DriverObject, RegistryPath);
*DeviceName = L"IoHelper";
KmtRegisterIrpHandler(IRP_MJ_CREATE, NULL, TestIrpHandler);
KmtRegisterIrpHandler(IRP_MJ_CLOSE, NULL, TestIrpHandler);
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; ++i)
KmtRegisterIrpHandler(i, NULL, TestIrpHandler);
return Status;
}
@ -42,6 +45,8 @@ TestUnload(
PAGED_CODE();
UNREFERENCED_PARAMETER(DriverObject);
DPRINT("TestUnload. DriverObject=%p\n", DriverObject);
}
static
@ -53,10 +58,9 @@ TestIrpHandler(
{
NTSTATUS Status = STATUS_SUCCESS;
if (IoStackLocation->MajorFunction == IRP_MJ_CREATE)
DPRINT("Helper Driver: Create Device %p", DeviceObject);
else if (IoStackLocation->MajorFunction == IRP_MJ_CLOSE)
DPRINT("Helper Driver: Close Device %p", DeviceObject);
DPRINT("TestIrpHandler. Function=%s, DeviceObject=%p\n",
KmtMajorFunctionNames[IoStackLocation->MajorFunction],
DeviceObject);
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;