From b9b5b6762d062ed7ea76b761a4f18371ea7f5160 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Thu, 18 Aug 2011 07:08:59 +0000 Subject: [PATCH] [KMTESTS] - Make IRP major function name table public - IoHelper: catch all IRPs and add debug messages svn path=/branches/GSoC_2011/KMTestSuite/; revision=53293 --- kmtests/include/kmt_platform.h | 4 +++ kmtests/include/kmt_test.h | 36 +++++++++++++++++++++++++- kmtests/kmtest_drv/kmtest_standalone.c | 34 +----------------------- kmtests/ntos_io/IoHelper_drv.c | 16 +++++++----- 4 files changed, 50 insertions(+), 40 deletions(-) diff --git a/kmtests/include/kmt_platform.h b/kmtests/include/kmt_platform.h index b730512d1e8..e407da91c00 100644 --- a/kmtests/include/kmt_platform.h +++ b/kmtests/include/kmt_platform.h @@ -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 #include diff --git a/kmtests/include/kmt_test.h b/kmtests/include/kmt_test.h index 7b8f8376c11..86f86641e76 100644 --- a/kmtests/include/kmt_test.h +++ b/kmtests/include/kmt_test.h @@ -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) { diff --git a/kmtests/kmtest_drv/kmtest_standalone.c b/kmtests/kmtest_drv/kmtest_standalone.c index 42dc16119f7..29ded93dff8 100644 --- a/kmtests/kmtest_drv/kmtest_standalone.c +++ b/kmtests/kmtest_drv/kmtest_standalone.c @@ -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) diff --git a/kmtests/ntos_io/IoHelper_drv.c b/kmtests/ntos_io/IoHelper_drv.c index 79fba760f06..fc7b1168c5f 100644 --- a/kmtests/ntos_io/IoHelper_drv.c +++ b/kmtests/ntos_io/IoHelper_drv.c @@ -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; -- 2.17.1