1 /* 2 * PROJECT: ReactOS kernel-mode tests - Filter Manager 3 * LICENSE: GPLv2+ - See COPYING in the top level directory 4 * PURPOSE: Tests for checking the create operations 5 * PROGRAMMER: Ged Murphy <gedmurphy@reactos.org> 6 */ 7 8 #include <kmt_test.h> 9 #include <fltkernel.h> 10 11 //#define NDEBUG 12 #include <debug.h> 13 14 /* prototypes */ 15 static 16 FLT_PREOP_CALLBACK_STATUS 17 FLTAPI 18 TestFilterPreOperation( 19 _Inout_ PFLT_CALLBACK_DATA Data, 20 _In_ PCFLT_RELATED_OBJECTS FltObjects, 21 _Outptr_result_maybenull_ PVOID *CompletionContext 22 ); 23 24 static 25 FLT_POSTOP_CALLBACK_STATUS 26 FLTAPI 27 TestFilterPostOperation( 28 _Inout_ PFLT_CALLBACK_DATA Data, 29 _In_ PCFLT_RELATED_OBJECTS FltObjects, 30 _In_opt_ PVOID CompletionContext, 31 _In_ FLT_POST_OPERATION_FLAGS Flags 32 ); 33 34 35 /* Globals */ 36 static PDRIVER_OBJECT TestDriverObject; 37 38 39 CONST FLT_OPERATION_REGISTRATION Callbacks[] = 40 { 41 { IRP_MJ_CREATE, 42 0, 43 TestFilterPreOperation, 44 TestFilterPostOperation }, 45 46 { IRP_MJ_OPERATION_END } 47 }; 48 49 50 NTSTATUS 51 TestEntry( 52 IN PDRIVER_OBJECT DriverObject, 53 IN PCUNICODE_STRING RegistryPath, 54 OUT PCWSTR *DeviceName, 55 IN OUT INT *Flags) 56 { 57 NTSTATUS Status = STATUS_SUCCESS; 58 59 PAGED_CODE(); 60 61 UNREFERENCED_PARAMETER(RegistryPath); 62 UNREFERENCED_PARAMETER(Flags); 63 64 DPRINT("Entry!\n"); 65 66 ok_irql(PASSIVE_LEVEL); 67 TestDriverObject = DriverObject; 68 69 *DeviceName = L"fltmgr_create"; 70 71 trace("Hi, this is the filter manager create test driver\n"); 72 73 (VOID)KmtFilterRegisterCallbacks(Callbacks); 74 75 return Status; 76 } 77 78 VOID 79 TestFilterUnload( 80 IN ULONG Flags) 81 { 82 PAGED_CODE(); 83 84 DPRINT("Unload!\n"); 85 86 ok_irql(PASSIVE_LEVEL); 87 88 trace("Unloading filter manager test driver\n"); 89 } 90 91 VOID 92 TestQueryTeardown( 93 _In_ PCFLT_RELATED_OBJECTS FltObjects, 94 _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags) 95 { 96 UNREFERENCED_PARAMETER(FltObjects); 97 UNREFERENCED_PARAMETER(Flags); 98 } 99 100 NTSTATUS 101 TestInstanceSetup( 102 _In_ PCFLT_RELATED_OBJECTS FltObjects, 103 _In_ FLT_INSTANCE_SETUP_FLAGS Flags, 104 _In_ DEVICE_TYPE VolumeDeviceType, 105 _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType, 106 _In_ PUNICODE_STRING VolumeName, 107 _In_ ULONG SectorSize, 108 _In_ ULONG ReportedSectorSize 109 ) 110 { 111 trace("Received an attach request for VolumeType 0x%X, FileSystemType %d\n", 112 VolumeDeviceType, 113 VolumeFilesystemType); 114 115 return STATUS_FLT_DO_NOT_ATTACH; 116 } 117 118 static 119 FLT_PREOP_CALLBACK_STATUS 120 FLTAPI 121 TestFilterPreOperation( 122 _Inout_ PFLT_CALLBACK_DATA Data, 123 _In_ PCFLT_RELATED_OBJECTS FltObjects, 124 _Outptr_result_maybenull_ PVOID *CompletionContext) 125 { 126 PFLT_IO_PARAMETER_BLOCK Iopb = Data->Iopb; 127 128 ok_eq_hex(Iopb->MajorFunction, IRP_MJ_CREATE); 129 130 return FLT_PREOP_SUCCESS_NO_CALLBACK; 131 } 132 133 static 134 FLT_POSTOP_CALLBACK_STATUS 135 FLTAPI 136 TestFilterPostOperation( 137 _Inout_ PFLT_CALLBACK_DATA Data, 138 _In_ PCFLT_RELATED_OBJECTS FltObjects, 139 _In_opt_ PVOID CompletionContext, 140 _In_ FLT_POST_OPERATION_FLAGS Flags) 141 { 142 PFLT_IO_PARAMETER_BLOCK Iopb = Data->Iopb; 143 144 ok_eq_hex(Iopb->MajorFunction, IRP_MJ_CREATE); 145 146 return FLT_POSTOP_FINISHED_PROCESSING; 147 }