ReactOS 0.4.15-dev-7788-g1ad9096
Object.c File Reference
#include "fltmgr.h"
#include "fltmgrint.h"
#include <debug.h>
Include dependency graph for Object.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define ExpChangePushlock(x, y, z)   InterlockedCompareExchangePointer((PVOID*)x, (PVOID)y, (PVOID)z)
 
#define EX_PUSH_LOCK_LOCK_V   ((ULONG_PTR)0x0)
 
#define EX_PUSH_LOCK_LOCK   ((ULONG_PTR)0x1)
 
#define EX_PUSH_LOCK_WAITING   ((ULONG_PTR)0x2)
 
#define EX_PUSH_LOCK_WAKING   ((ULONG_PTR)0x4)
 
#define EX_PUSH_LOCK_MULTIPLE_SHARED   ((ULONG_PTR)0x8)
 
#define EX_PUSH_LOCK_SHARE_INC   ((ULONG_PTR)0x10)
 
#define EX_PUSH_LOCK_PTR_BITS   ((ULONG_PTR)0xf)
 

Functions

NTSTATUS FLTAPI FltObjectReference (_Inout_ PVOID Object)
 
VOID FLTAPI FltObjectDereference (_Inout_ PVOID Object)
 
 _Acquires_lock_ (_Global_critical_region_)
 
 _Releases_lock_ (_Global_critical_region_)
 
 _IRQL_requires_max_ (PASSIVE_LEVEL)
 
VOID FltpExInitializeRundownProtection (_Out_ PEX_RUNDOWN_REF RundownRef)
 
BOOLEAN FltpExAcquireRundownProtection (_Inout_ PEX_RUNDOWN_REF RundownRef)
 
BOOLEAN FltpExReleaseRundownProtection (_Inout_ PEX_RUNDOWN_REF RundownRef)
 
BOOLEAN FltpExRundownCompleted (_Inout_ PEX_RUNDOWN_REF RundownRef)
 
NTSTATUS NTAPI FltpObjectRundownWait (_Inout_ PEX_RUNDOWN_REF RundownRef)
 
NTSTATUS FltpGetBaseDeviceObjectName (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PUNICODE_STRING ObjectName)
 
NTSTATUS FltpGetObjectName (_In_ PVOID Object, _Inout_ PUNICODE_STRING ObjectName)
 
ULONG FltpObjectPointerReference (_In_ PFLT_OBJECT Object)
 
VOID FltpObjectPointerDereference (_In_ PFLT_OBJECT Object)
 

Macro Definition Documentation

◆ EX_PUSH_LOCK_LOCK

#define EX_PUSH_LOCK_LOCK   ((ULONG_PTR)0x1)

Definition at line 29 of file Object.c.

◆ EX_PUSH_LOCK_LOCK_V

#define EX_PUSH_LOCK_LOCK_V   ((ULONG_PTR)0x0)

Definition at line 28 of file Object.c.

◆ EX_PUSH_LOCK_MULTIPLE_SHARED

#define EX_PUSH_LOCK_MULTIPLE_SHARED   ((ULONG_PTR)0x8)

Definition at line 32 of file Object.c.

◆ EX_PUSH_LOCK_PTR_BITS

#define EX_PUSH_LOCK_PTR_BITS   ((ULONG_PTR)0xf)

Definition at line 34 of file Object.c.

◆ EX_PUSH_LOCK_SHARE_INC

#define EX_PUSH_LOCK_SHARE_INC   ((ULONG_PTR)0x10)

Definition at line 33 of file Object.c.

◆ EX_PUSH_LOCK_WAITING

#define EX_PUSH_LOCK_WAITING   ((ULONG_PTR)0x2)

Definition at line 30 of file Object.c.

◆ EX_PUSH_LOCK_WAKING

#define EX_PUSH_LOCK_WAKING   ((ULONG_PTR)0x4)

Definition at line 31 of file Object.c.

◆ ExpChangePushlock

#define ExpChangePushlock (   x,
  y,
  z 
)    InterlockedCompareExchangePointer((PVOID*)x, (PVOID)y, (PVOID)z)

Definition at line 23 of file Object.c.

◆ NDEBUG

#define NDEBUG

Definition at line 17 of file Object.c.

Function Documentation

◆ _Acquires_lock_()

_Acquires_lock_ ( _Global_critical_region_  )

Definition at line 59 of file Object.c.

64{
66
67 /* Try acquiring the lock */
69 {
70 /* Someone changed it, use the slow path */
72 }
73
74 /* Sanity check */
75 FLT_ASSERT(PushLock->Locked);
76}
#define EX_PUSH_LOCK_LOCK_V
Definition: Object.c:28
#define FLT_ASSERT(_e)
Definition: fltkernel.h:49
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
VOID FASTCALL ExfAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:471
int32_t * PLONG
Definition: typedefs.h:58

◆ _IRQL_requires_max_()

_IRQL_requires_max_ ( PASSIVE_LEVEL  )

Definition at line 137 of file Object.c.

141{
142 PAGED_CODE();
143
144 return ZwClose(FileHandle);
145}
#define PAGED_CODE()
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)

◆ _Releases_lock_()

_Releases_lock_ ( _Global_critical_region_  )

Definition at line 101 of file Object.c.

106{
107 EX_PUSH_LOCK OldValue = *PushLock;
108 EX_PUSH_LOCK NewValue;
109
110 /* Sanity checks */
111 FLT_ASSERT(OldValue.Locked);
112
113 /* Check if the pushlock is shared */
114 if (OldValue.Shared > 1)
115 {
116 /* Decrease the share count */
117 NewValue.Value = OldValue.Value - EX_PUSH_LOCK_SHARE_INC;
118 }
119 else
120 {
121 /* Clear the pushlock entirely */
122 NewValue.Value = 0;
123 }
124
125 /* Check if nobody is waiting on us and try clearing the lock here */
126 if ((OldValue.Waiting) ||
127 (ExpChangePushlock(PushLock, NewValue.Ptr, OldValue.Ptr) !=
128 OldValue.Ptr))
129 {
130 /* We have waiters, use the long path */
131 ExfReleasePushLock(PushLock);
132 }
133
135}
#define EX_PUSH_LOCK_SHARE_INC
Definition: Object.c:33
#define ExpChangePushlock(x, y, z)
Definition: Object.c:23
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
VOID FASTCALL ExfReleasePushLock(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:810
ULONG_PTR Value
Definition: extypes.h:465
PVOID Ptr
Definition: extypes.h:466
ULONG_PTR Waiting
Definition: extypes.h:460
ULONG_PTR Shared
Definition: extypes.h:463
ULONG_PTR Locked
Definition: extypes.h:459

◆ FltObjectDereference()

VOID FLTAPI FltObjectDereference ( _Inout_ PVOID  Object)

Definition at line 53 of file Object.c.

54{
56}
BOOLEAN FltpExReleaseRundownProtection(_Inout_ PEX_RUNDOWN_REF RundownRef)
Definition: Object.c:224
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object

Referenced by _IRQL_requires_max_(), CreateClientPort(), FltEnumerateVolumes(), FltpServerPortClose(), FltStartFiltering(), and FltUnregisterFilter().

◆ FltObjectReference()

NTSTATUS FLTAPI FltObjectReference ( _Inout_ PVOID  Object)

Definition at line 41 of file Object.c.

42{
44 {
46 }
47
48 return STATUS_SUCCESS;
49}
BOOLEAN FltpExAcquireRundownProtection(_Inout_ PEX_RUNDOWN_REF RundownRef)
Definition: Object.c:218
#define STATUS_FLT_DELETING_OBJECT
Definition: ntstatus.h:1432
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by _IRQL_requires_max_(), CreateClientPort(), FltEnumerateVolumes(), FltRegisterFilter(), and FltStartFiltering().

◆ FltpExAcquireRundownProtection()

BOOLEAN FltpExAcquireRundownProtection ( _Inout_ PEX_RUNDOWN_REF  RundownRef)

Definition at line 218 of file Object.c.

219{
220 return ExAcquireRundownProtection(RundownRef);
221}
#define ExAcquireRundownProtection
Definition: ex.h:135

Referenced by FltObjectReference().

◆ FltpExInitializeRundownProtection()

VOID FltpExInitializeRundownProtection ( _Out_ PEX_RUNDOWN_REF  RundownRef)

Definition at line 212 of file Object.c.

213{
215}
#define ExInitializeRundownProtection
Definition: ex.h:137

Referenced by FltRegisterFilter().

◆ FltpExReleaseRundownProtection()

BOOLEAN FltpExReleaseRundownProtection ( _Inout_ PEX_RUNDOWN_REF  RundownRef)

Definition at line 224 of file Object.c.

225{
226 ExReleaseRundownProtection(RundownRef);
227 return TRUE;
228}
#define TRUE
Definition: types.h:120
#define ExReleaseRundownProtection
Definition: ex.h:136

Referenced by FltObjectDereference().

◆ FltpExRundownCompleted()

BOOLEAN FltpExRundownCompleted ( _Inout_ PEX_RUNDOWN_REF  RundownRef)

Definition at line 231 of file Object.c.

232{
233 return _InterlockedExchange((PLONG)RundownRef, 1);
234}
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)

Referenced by FltUnregisterFilter().

◆ FltpGetBaseDeviceObjectName()

NTSTATUS FltpGetBaseDeviceObjectName ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PUNICODE_STRING  ObjectName 
)

Definition at line 245 of file Object.c.

247{
248 PDEVICE_OBJECT BaseDeviceObject;
250
251 /*
252 * Get the lowest device object on the stack, which may be the
253 * object we were passed, and lookup the name for that object
254 */
255 BaseDeviceObject = IoGetDeviceAttachmentBaseRef(DeviceObject);
256 Status = FltpGetObjectName(BaseDeviceObject, ObjectName);
257 ObDereferenceObject(BaseDeviceObject);
258
259 return Status;
260}
NTSTATUS FltpGetObjectName(_In_ PVOID Object, _Inout_ PUNICODE_STRING ObjectName)
Definition: Object.c:263
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
PDEVICE_OBJECT NTAPI IoGetDeviceAttachmentBaseRef(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1419
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:64
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by FltpEnumerateFileSystemVolumes(), and FltpFsNotification().

◆ FltpGetObjectName()

NTSTATUS FltpGetObjectName ( _In_ PVOID  Object,
_Inout_ PUNICODE_STRING  ObjectName 
)

Definition at line 263 of file Object.c.

265{
266 OBJECT_NAME_INFORMATION LocalNameInfo;
267 POBJECT_NAME_INFORMATION ObjectNameInfo = &LocalNameInfo;
270
271 if (ObjectName == NULL)
273
274 /* Get the size of the buffer required to hold the nameinfo */
276 &LocalNameInfo,
277 sizeof(LocalNameInfo),
278 &ReturnLength);
280 {
281 ObjectNameInfo = ExAllocatePoolWithTag(PagedPool,
284 if (ObjectNameInfo == NULL) return STATUS_INSUFFICIENT_RESOURCES;
285
286 /* Get the actual name info now we have the buffer to hold it */
288 ObjectNameInfo,
290 &ReturnLength);
291 }
292
293
294 if (NT_SUCCESS(Status))
295 {
296 /* Make sure the buffer we were passed is large enough to hold the string */
297 if (ObjectName->MaximumLength < ObjectNameInfo->Name.Length)
298 {
299 /* It wasn't, let's enlarge the buffer */
301 ObjectNameInfo->Name.Length,
302 FALSE);
303
304 }
305
306 if (NT_SUCCESS(Status))
307 {
308 /* Copy the object name into the callers buffer */
309 RtlCopyUnicodeString(ObjectName, &ObjectNameInfo->Name);
310 }
311 }
312
313 if (ObjectNameInfo != &LocalNameInfo)
314 {
316 }
317
318 return Status;
319}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
NTSTATUS FltpReallocateUnicodeString(_In_ PUNICODE_STRING String, _In_ SIZE_T NewLength, _In_ BOOLEAN CopyExisting)
Definition: Lib.c:39
#define FM_TAG_UNICODE_STRING
Definition: fltmgr.h:20
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSTATUS NTAPI ObQueryNameString(IN PVOID Object, OUT POBJECT_NAME_INFORMATION ObjectNameInfo, IN ULONG Length, OUT PULONG ReturnLength)
Definition: obname.c:1207
UNICODE_STRING Name
Definition: nt_native.h:1270
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by FltpAttachToFileSystemDevice(), FltpEnumerateFileSystemVolumes(), and FltpGetBaseDeviceObjectName().

◆ FltpObjectPointerDereference()

VOID FltpObjectPointerDereference ( _In_ PFLT_OBJECT  Object)

Definition at line 335 of file Object.c.

336{
337 if (InterlockedDecrementSizeT(&Object->PointerCount) == 0)
338 {
339 // Cleanup
341 }
342}
#define InterlockedDecrementSizeT(a)
Definition: interlocked.h:153

Referenced by FltpServerPortDelete().

◆ FltpObjectPointerReference()

ULONG FltpObjectPointerReference ( _In_ PFLT_OBJECT  Object)

Definition at line 322 of file Object.c.

323{
325
326 /* Store the old count and increment */
327 Result = &Object->PointerCount;
328 InterlockedIncrementSizeT(&Object->PointerCount);
329
330 /* Return the initial value */
331 return *Result;
332}
#define InterlockedIncrementSizeT(a)
Definition: interlocked.h:220
uint32_t * PULONG
Definition: typedefs.h:59
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by _IRQL_requires_max_().

◆ FltpObjectRundownWait()

NTSTATUS NTAPI FltpObjectRundownWait ( _Inout_ PEX_RUNDOWN_REF  RundownRef)

Definition at line 238 of file Object.c.

239{
240 //return FltpExWaitForRundownProtectionRelease(RundownRef);
241 return 0;
242}

Referenced by FltUnregisterFilter().