ReactOS 0.4.15-dev-7934-g1dc8d80
filter.cpp
Go to the documentation of this file.
1
2// Copyright (C) Alexander Telyatnikov, Ivan Keliukh, Yegor Anchishkin, SKIF Software, 1999-2013. Kiev, Ukraine
3// All rights reserved
4// This file was released under the GPLv2 on June 2015.
6/*
7
8 Module Name: Filter.cpp
9
10 Abstract:
11
12 Contains code to handle register file system notification and attach to
13 CDFS if required.
14
15 Environment:
16
17 Kernel mode only
18
19*/
20
21#include "udffs.h"
22
23// define the file specific bug-check id
24#define UDF_BUG_CHECK_ID UDF_FILE_FILTER
25
26VOID
28 PFILTER_DEV_EXTENSION FilterDevExt;
29 PDEVICE_OBJECT filterDeviceObject;
30 NTSTATUS RC;
31
32// BrutePoint();
33
34 // Acquire GlobalDataResource
35 UDFAcquireResourceExclusive(&(UDFGlobalData.GlobalDataResource), TRUE);
36
37 if (!NT_SUCCESS(RC = IoCreateDevice(
38 UDFGlobalData.DriverObject, // our driver object
39 sizeof(FILTER_DEV_EXTENSION), // don't need an extension
40 // for this object
41 NULL, // name - can be used to
42 // "open" the driver
43 // see the R.Nagar's book
44 // for alternate choices
46 0, // no special characteristics
47 // do not want this as an
48 // exclusive device, though
49 // we might
50 FALSE,
51 &filterDeviceObject))) {
52 // failed to create a filter device object, leave ...
53 // Release the global resource.
54 UDFReleaseResource( &(UDFGlobalData.GlobalDataResource) );
55 return;
56 }
57 FilterDevExt = (PFILTER_DEV_EXTENSION)filterDeviceObject->DeviceExtension;
58 // Zero it out (typically this has already been done by the I/O
59 // Manager but it does not hurt to do it again)!
60 RtlZeroMemory(FilterDevExt, sizeof(FILTER_DEV_EXTENSION));
61
62 // Initialize the signature fields
64 FilterDevExt->NodeIdentifier.NodeSize = sizeof(FILTER_DEV_EXTENSION);
65
66 UDFPrint(("UDFCheckOtherFS: Attaching filter devobj %x to FS devobj %x \n",filterDeviceObject,deviceObject));
68 UDFPrint(("UDFCheckOtherFS: top devobj is %x \n",deviceObject));
69 FilterDevExt->lowerFSDeviceObject = deviceObject;
70
71 RC = IoAttachDeviceByPointer( filterDeviceObject, deviceObject );
72 if (!NT_SUCCESS(RC)) {
73 IoDeleteDevice( filterDeviceObject );
74 } else {
75 filterDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
76 }
77 // Release the global resource.
78 UDFReleaseResource( &(UDFGlobalData.GlobalDataResource) );
79}
80
81VOID
82UDFCheckOtherFSByName(PCWSTR DeviceObjectName) {
83 PFILE_OBJECT fileObject;
85 UNICODE_STRING nameString;
86 NTSTATUS RC;
87
88 UDFPrint(("UDFCheckOtherFSByName: trying %s \n",DeviceObjectName));
89
90 RtlInitUnicodeString( &nameString, DeviceObjectName );
92 &nameString,
94 &fileObject,
96 );
97
98 if (!NT_SUCCESS(RC)) {
99 UDFPrint(("UDFCheckOtherFSByName: error %x while calling IoGetDeviceObjectPointer \n",RC));
100 return;
101 }
102
104
105 ObDereferenceObject( fileObject );
106}
107
108#if 0
109VOID
110NTAPI
114 )
115
116/*
117
118Routine Description:
119
120 This routine is invoked whenever a file system has either registered or
121 unregistered itself as an active file system.
122
123 For the former case, this routine creates a device object and attaches it
124 to the specified file system's device object. This allows this driver
125 to filter all requests to that file system.
126
127 For the latter case, this file system's device object is located,
128 detached, and deleted. This removes this file system as a filter for
129 the specified file system.
130
131Arguments:
132
133 DeviceObject - Pointer to the file system's device object.
134
135 FsActive - bolean indicating whether the file system has registered
136 (TRUE) or unregistered (FALSE) itself as an active file system.
137
138Return Value:
139
140 None.
141
142*/
143
144{
145 // Begin by determine whether or not the file system is a cdrom-based file
146 // system. If not, then this driver is not concerned with it.
147 if (DeviceObject->DeviceType != FILE_DEVICE_CD_ROM_FILE_SYSTEM) {
148 return;
149 }
150
151 // Begin by determining whether this file system is registering or
152 // unregistering as an active file system.
153 if (FsActive) {
154 UDFPrint(("UDFFSNotification \n"));
156 }
157}
158#endif
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define UDFReleaseResource(Resource)
Definition: env_spec_w32.h:661
#define UDFAcquireResourceExclusive(Resource, CanWait)
Definition: env_spec_w32.h:656
VOID UDFCheckOtherFS(PDEVICE_OBJECT deviceObject)
Definition: filter.cpp:27
VOID UDFCheckOtherFSByName(PCWSTR DeviceObjectName)
Definition: filter.cpp:82
MxDeviceObject deviceObject
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
PDEVICE_OBJECT NTAPI IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1385
NTSTATUS NTAPI IoAttachDeviceByPointer(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:947
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1435
VOID NTAPI UDFFsNotification(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN FsActive)
Definition: udfinit.cpp:779
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM
Definition: winioctl.h:109
#define UDF_NODE_TYPE_FILTER_DEVOBJ
Definition: struct.h:64
struct _FILTER_DEV_EXTENSION * PFILTER_DEV_EXTENSION
struct _FILTER_DEV_EXTENSION FILTER_DEV_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
PDEVICE_OBJECT lowerFSDeviceObject
Definition: struct.h:350
UDFIdentifier NodeIdentifier
Definition: struct.h:348
uint32 NodeType
Definition: struct.h:75
uint32 NodeSize
Definition: struct.h:76
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define NTAPI
Definition: typedefs.h:36
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
UDFData UDFGlobalData
Definition: udfinit.cpp:25
#define UDFPrint(Args)
Definition: udffs.h:223
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ BOOLEAN FsActive
Definition: iotypes.h:7360
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ObDereferenceObject
Definition: obfuncs.h:203