ReactOS  0.4.14-dev-114-gc8cbd56
mmfuncs.h File Reference

Go to the source code of this file.

Macros

#define ALIGN_DOWN_BY(size, align)   ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1))
 
#define ALIGN_UP_BY(size, align)   (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align))
 
#define ALIGN_DOWN_POINTER_BY(ptr, align)   ((PVOID)ALIGN_DOWN_BY(ptr, align))
 
#define ALIGN_UP_POINTER_BY(ptr, align)   ((PVOID)ALIGN_UP_BY(ptr, align))
 
#define ALIGN_DOWN(size, type)   ALIGN_DOWN_BY(size, sizeof(type))
 
#define ALIGN_UP(size, type)   ALIGN_UP_BY(size, sizeof(type))
 
#define ALIGN_DOWN_POINTER(ptr, type)   ALIGN_DOWN_POINTER_BY(ptr, sizeof(type))
 
#define ALIGN_UP_POINTER(ptr, type)   ALIGN_UP_POINTER_BY(ptr, sizeof(type))
 
#define FIELD_OFFSET(type, field)   ((ULONG)&(((type *)0)->field))
 
#define FIELD_SIZE(type, field)   (sizeof(((type *)0)->field))
 
#define POOL_TAGGING   1
 
#define IF_DEBUG   if (FALSE)
 
#define BYTE_OFFSET(Va)   ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
 
#define BYTES_TO_PAGES(Size)   (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0))
 
#define PAGE_ALIGN(Va)   ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
 
#define ROUND_TO_PAGES(Size)   (((ULONG_PTR) (Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
 
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)
 
#define COMPUTE_PAGES_SPANNED(Va, Size)   ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size)
 
#define MmGetMdlByteCount(_Mdl)   ((_Mdl)->ByteCount)
 
#define MmGetMdlByteOffset(_Mdl)   ((_Mdl)->ByteOffset)
 
#define MmGetMdlBaseVa(Mdl)   ((Mdl)->StartVa)
 
#define MmGetMdlPfnArray(_Mdl)   ((PPFN_NUMBER) ((_Mdl) + 1))
 
#define MmGetMdlVirtualAddress(_Mdl)   ((PVOID) ((PCHAR) ((_Mdl)->StartVa) + (_Mdl)->ByteOffset))
 
#define MmGetProcedureAddress(Address)   (Address)
 
#define MmLockPagableCodeSection(Address)   MmLockPagableDataSection(Address)
 
#define MmGetSystemAddressForMdl(Mdl)
 
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
 
#define MmInitializeMdl(_MemoryDescriptorList, _BaseVa, _Length)
 
#define MmPrepareMdlForReuse(_Mdl)
 

Functions

 $if (_WDMDDK_) $endif(_WDMDDK_) $if(_NTIFS_) FORCEINLINE ULONG HEAP_MAKE_TAG_FLAGS(_In_ ULONG TagBase
 
 $endif (_NTIFS_) $if(_WDMDDK_) _Must_inspect_result_ _IRQL_requires_max_(DISPATCH_LEVEL) _When_(return !
 
 _Post_writable_byte_size_ (NumberOfBytes)) NTKERNELAPI PVOID NTAPI MmAllocateContiguousMemory(_In_ SIZE_T NumberOfBytes
 
_Must_inspect_result_ _IRQL_requires_max_ (DISPATCH_LEVEL) _When_(return !
 
NTKERNELAPI PMDL NTAPI MmCreateMdl (_Out_writes_bytes_opt_(sizeof(MDL)+(sizeof(PFN_NUMBER) *ADDRESS_AND_SIZE_TO_SPAN_PAGES(Base, Length))) PMDL MemoryDescriptorList, _In_reads_bytes_opt_(Length) PVOID Base, _In_ SIZE_T Length)
 
 _IRQL_requires_max_ (PASSIVE_LEVEL) NTKERNELAPI PVOID NTAPI MmGetSystemRoutineAddress(_In_ PUNICODE_STRING SystemRoutineName)
 
NTKERNELAPI LOGICAL NTAPI MmIsDriverVerifying (_In_ struct _DRIVER_OBJECT *DriverObject)
 
_Must_inspect_result_ _IRQL_requires_max_ (APC_LEVEL) NTKERNELAPI PVOID NTAPI MmLockPagableDataSection(_In_ PVOID AddressWithinSection)
 
_Must_inspect_result_ _When_ (AccessMode==KernelMode, _IRQL_requires_max_(DISPATCH_LEVEL)) _When_(AccessMode
 
_Must_inspect_result_ _Maybe_raises_SEH_exception_ _In_ __drv_strictType (KPROCESSOR_MODE/enum _MODE, __drv_typeConst) KPROCESSOR_MODE AccessMode)
 
 _Post_writable_byte_size_ (MemoryDescriptorList->ByteCount) _When_(AccessMode
 
NTKERNELAPI MM_SYSTEMSIZE NTAPI MmQuerySystemSize (VOID)
 
NTKERNELAPI SIZE_T NTAPI MmSizeOfMdl (_In_reads_bytes_opt_(Length) PVOID Base, _In_ SIZE_T Length)
 
 $endif (_WDMDDK_) $if(_NTDDK_) _IRQL_requires_max_(PASSIVE_LEVEL) NTKERNELAPI PPHYSICAL_MEMORY_RANGE NTAPI MmGetPhysicalMemoryRanges(VOID)
 
NTKERNELAPI PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress (_In_ PVOID BaseAddress)
 
NTKERNELAPI BOOLEAN NTAPI MmIsNonPagedSystemAddressValid (_In_ PVOID VirtualAddress)
 
NTKERNELAPI PVOID NTAPI MmGetVirtualForPhysical (_In_ PHYSICAL_ADDRESS PhysicalAddress)
 
NTKERNELAPI BOOLEAN NTAPI MmIsThisAnNtAsSystem (VOID)
 
_Must_inspect_result_ _In_ __in_data_source (USER_MODE) SIZE_T Size
 
 $endif (_NTDDK_) $if(_NTIFS_) NTKERNELAPI BOOLEAN NTAPI MmIsRecursiveIoFault(VOID)
 
_Must_inspect_result_ _Out_writes_bytes_opt_ (NumberOfBytes)) NTKERNELAPI PVOID NTAPI MmAllocateMappingAddress(_In_ SIZE_T NumberOfBytes
 
 _In_reads_ (NumberOfLists) PREAD_LIST *ReadLists)
 
_Must_inspect_result_ _At_BaseAddress (Mem)) __kernel_entryNTSYSCALLAPINTSTATUSNTAPINtAllocateVirtualMemory(_In_ HANDLE ProcessHandle, _Inout_ _Outptr_result_buffer_(*RegionSize) PVOID *BaseAddress, _In_ ULONG_PTR ZeroBits, _Inout_ PSIZE_T RegionSize, _In_ ULONG AllocationType, _In_ ULONG Protect
 
__kernel_entry _Inout_ __drv_freesMem (Mem) PVOID *BaseAddress
 

Variables

_In_ ULONG Tag
 
_In_ PHYSICAL_ADDRESS HighestAcceptableAddress
 
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS LowestAcceptableAddress
 
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_opt_ PHYSICAL_ADDRESS BoundaryAddressMultiple
 
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_opt_ PHYSICAL_ADDRESS _In_ MEMORY_CACHING_TYPE CacheType
 
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS HighAddress
 
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS SkipBytes
 
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_ SIZE_T TotalBytes
 
_In_ SIZE_T NumberOfBytes
 
_In_ PEPROCESS Process
 
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
 
_In_ PEPROCESS _In_ KPROCESSOR_MODE _In_ LOCK_OPERATION Operation
 
_Inout_ PMDL MemoryDescriptorList
 
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_opt_ PHYSICAL_ADDRESS _In_ MEMORY_CACHING_TYPE _In_ NODE_REQUIREMENT PreferredNode
 
_Must_inspect_result_ _In_ SIZE_T _In_ PVOID PageAddress
 
_Must_inspect_result_ _Outptr_result_bytebuffer_ ViewSize PVOIDMappedBase
 
_Must_inspect_result_ _Outptr_result_bytebuffer_ ViewSize PVOID _Inout_ PSIZE_T ViewSize
 
_Must_inspect_result_ _In_ _In_ ULONG ProbeMode
 
_In_ BOOLEAN DelayClose
 
_In_ MMFLUSH_TYPE FlushType
 
_In_opt_ PLARGE_INTEGER NewFileSize
 
_In_ SIZE_T Length
 
_Must_inspect_result_ _In_ ULONG PoolTag
 
_Must_inspect_result_ _In_ ULONG NewProtect
 
_In_ ULONG ThunkBufferSize
 
_In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_ SIZE_T _In_ MEMORY_CACHING_TYPE _In_ ULONG Flags
 
_Inout_ PSIZE_T _In_opt_ PMDLX NewMdl
 
_Inout_ PSIZE_T _In_opt_ PMDLX _In_ MM_ROTATE_DIRECTION Direction
 
_Inout_ PSIZE_T _In_opt_ PMDLX _In_ MM_ROTATE_DIRECTION _In_ PMM_ROTATE_COPY_CALLBACK_FUNCTION CopyFunction
 
_Inout_ PSIZE_T _In_opt_ PMDLX _In_ MM_ROTATE_DIRECTION _In_ PMM_ROTATE_COPY_CALLBACK_FUNCTION _In_opt_ PVOID Context
 
__kernel_entry _Inout_ _Inout_ PSIZE_T RegionSize
 
__kernel_entry _Inout_ _Inout_ PSIZE_T _In_ ULONG FreeType
 

Macro Definition Documentation

◆ ADDRESS_AND_SIZE_TO_SPAN_PAGES

#define ADDRESS_AND_SIZE_TO_SPAN_PAGES (   _Va,
  _Size 
)
Value:
((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \
+ (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT))
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define PAGE_SIZE
Definition: env_spec_w32.h:49
_Check_return_ _Ret_maybenull_ _In_ size_t _In_ size_t _Size
Definition: malloc.h:112
unsigned int ULONG
Definition: retypes.h:1

◆ ALIGN_DOWN

#define ALIGN_DOWN (   size,
  type 
)    ALIGN_DOWN_BY(size, sizeof(type))

◆ ALIGN_DOWN_BY

#define ALIGN_DOWN_BY (   size,
  align 
)    ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1))

◆ ALIGN_DOWN_POINTER

#define ALIGN_DOWN_POINTER (   ptr,
  type 
)    ALIGN_DOWN_POINTER_BY(ptr, sizeof(type))

◆ ALIGN_DOWN_POINTER_BY

#define ALIGN_DOWN_POINTER_BY (   ptr,
  align 
)    ((PVOID)ALIGN_DOWN_BY(ptr, align))

◆ ALIGN_UP

#define ALIGN_UP (   size,
  type 
)    ALIGN_UP_BY(size, sizeof(type))

◆ ALIGN_UP_BY

#define ALIGN_UP_BY (   size,
  align 
)    (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align))

◆ ALIGN_UP_POINTER

#define ALIGN_UP_POINTER (   ptr,
  type 
)    ALIGN_UP_POINTER_BY(ptr, sizeof(type))

◆ ALIGN_UP_POINTER_BY

#define ALIGN_UP_POINTER_BY (   ptr,
  align 
)    ((PVOID)ALIGN_UP_BY(ptr, align))

◆ BYTE_OFFSET

#define BYTE_OFFSET (   Va)    ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))

◆ BYTES_TO_PAGES

#define BYTES_TO_PAGES (   Size)    (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0))

◆ COMPUTE_PAGES_SPANNED

#define COMPUTE_PAGES_SPANNED (   Va,
  Size 
)    ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size)

◆ FIELD_OFFSET

#define FIELD_OFFSET (   type,
  field 
)    ((ULONG)&(((type *)0)->field))

◆ FIELD_SIZE

#define FIELD_SIZE (   type,
  field 
)    (sizeof(((type *)0)->field))

◆ IF_DEBUG

#define IF_DEBUG   if (FALSE)

◆ MmGetMdlBaseVa

#define MmGetMdlBaseVa (   Mdl)    ((Mdl)->StartVa)

◆ MmGetMdlByteCount

#define MmGetMdlByteCount (   _Mdl)    ((_Mdl)->ByteCount)

◆ MmGetMdlByteOffset

#define MmGetMdlByteOffset (   _Mdl)    ((_Mdl)->ByteOffset)

◆ MmGetMdlPfnArray

#define MmGetMdlPfnArray (   _Mdl)    ((PPFN_NUMBER) ((_Mdl) + 1))

◆ MmGetMdlVirtualAddress

#define MmGetMdlVirtualAddress (   _Mdl)    ((PVOID) ((PCHAR) ((_Mdl)->StartVa) + (_Mdl)->ByteOffset))

◆ MmGetProcedureAddress

#define MmGetProcedureAddress (   Address)    (Address)

◆ MmGetSystemAddressForMdl

#define MmGetSystemAddressForMdl (   Mdl)
Value:
(((Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \
((Mdl)->MappedSystemVa) : \
#define MDL_MAPPED_TO_SYSTEM_VA
Definition: mmtypes.h:18
PVOID NTAPI MmMapLockedPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode)
Definition: mdlsup.c:822
#define MDL_SOURCE_IS_NONPAGED_POOL
Definition: mmtypes.h:20

◆ MmGetSystemAddressForMdlSafe

#define MmGetSystemAddressForMdlSafe (   _Mdl,
  _Priority 
)
Value:
(((_Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA \
(_Mdl)->MappedSystemVa : \
KernelMode, MmCached, NULL, FALSE, (_Priority)))
#define MDL_MAPPED_TO_SYSTEM_VA
Definition: mmtypes.h:18
smooth NULL
Definition: ftsmooth.c:416
#define MDL_SOURCE_IS_NONPAGED_POOL
Definition: mmtypes.h:20
void * PVOID
Definition: retypes.h:9
PVOID NTAPI MmMapLockedPagesSpecifyCache(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN MEMORY_CACHING_TYPE CacheType, IN PVOID BaseAddress, IN ULONG BugCheckOnFailure, IN MM_PAGE_PRIORITY Priority)
Definition: mdlsup.c:664

◆ MmInitializeMdl

#define MmInitializeMdl (   _MemoryDescriptorList,
  _BaseVa,
  _Length 
)
Value:
{ \
(_MemoryDescriptorList)->Next = (PMDL) NULL; \
(_MemoryDescriptorList)->Size = (CSHORT) (sizeof(MDL) + \
(sizeof(PFN_NUMBER) * ADDRESS_AND_SIZE_TO_SPAN_PAGES(_BaseVa, _Length))); \
(_MemoryDescriptorList)->MdlFlags = 0; \
(_MemoryDescriptorList)->StartVa = (PVOID) PAGE_ALIGN(_BaseVa); \
(_MemoryDescriptorList)->ByteOffset = BYTE_OFFSET(_BaseVa); \
(_MemoryDescriptorList)->ByteCount = (ULONG) _Length; \
}
ULONG PFN_NUMBER
Definition: ke.h:8
smooth NULL
Definition: ftsmooth.c:416
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)
#define PAGE_ALIGN(Va)
MDL
Definition: mmtypes.h:117
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _In_ LARGE_INTEGER ByteCount
Definition: iotypes.h:1061
unsigned int ULONG
Definition: retypes.h:1
short CSHORT
Definition: umtypes.h:127
#define BYTE_OFFSET(Va)
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:716

◆ MmLockPagableCodeSection

#define MmLockPagableCodeSection (   Address)    MmLockPagableDataSection(Address)

◆ MmPrepareMdlForReuse

#define MmPrepareMdlForReuse (   _Mdl)
Value:
{ \
if (((_Mdl)->MdlFlags & MDL_PARTIAL_HAS_BEEN_MAPPED) != 0) { \
ASSERT(((_Mdl)->MdlFlags & MDL_PARTIAL) != 0); \
MmUnmapLockedPages((_Mdl)->MappedSystemVa, (_Mdl)); \
} else if (((_Mdl)->MdlFlags & MDL_PARTIAL) == 0) { \
ASSERT(((_Mdl)->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) == 0); \
} \
}
#define MDL_MAPPED_TO_SYSTEM_VA
Definition: mmtypes.h:18
#define MDL_PARTIAL_HAS_BEEN_MAPPED
Definition: mmtypes.h:23
#define MDL_PARTIAL
Definition: mmtypes.h:22

◆ PAGE_ALIGN

#define PAGE_ALIGN (   Va)    ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))

◆ POOL_TAGGING

#define POOL_TAGGING   1

◆ ROUND_TO_PAGES

#define ROUND_TO_PAGES (   Size)    (((ULONG_PTR) (Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))

Function Documentation

◆ $endif() [1/3]

$endif ( _NTIFS_  )

Definition at line 2594 of file iofuncs.h.

2620 {
2621  ASSERT(Irp->CurrentLocation <= Irp->StackCount);
2622  Irp->CurrentLocation++;
2623 #ifdef NONAMELESSUNION
2624  Irp->Tail.Overlay.s.u.CurrentStackLocation++;
2625 #else
2626  Irp->Tail.Overlay.CurrentStackLocation++;
2627 #endif
2628 }
_In_ PIRP Irp
Definition: csq.h:116
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

◆ $endif() [2/3]

$endif ( _WDMDDK_  )

Definition at line 202 of file ke.h.

226 {
227  ULONGLONG Low;
228  LONGLONG High;
229 } NEON128, *PNEON128;
Definition: strmini.h:380
int64_t LONGLONG
Definition: typedefs.h:66
uint64_t ULONGLONG
Definition: typedefs.h:65
Definition: strmini.h:378
NEON128
Definition: ke.h:229
* PNEON128
Definition: ke.h:229

◆ $endif() [3/3]

$endif ( _NTDDK_  )

Definition at line 2487 of file iofuncs.h.

2495 {
2496  PriorityInfo->Size = sizeof(IO_PRIORITY_INFO);
2497  PriorityInfo->ThreadPriority = 0xffff;
2498  PriorityInfo->IoPriority = IoPriorityNormal;
2499  PriorityInfo->PagePriority = 0;
2500 }
struct _IO_PRIORITY_INFO IO_PRIORITY_INFO
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD _Inout_ PIO_PRIORITY_INFO PriorityInfo
Definition: fltkernel.h:2653

◆ $if()

$if ( _WDMDDK_  )

Kernel definitions for AMD64

Kernel definitions for ARM

Definition at line 1 of file ke.h.

31 {
32  ULONG Dummy;
struct _KFLOATING_SAVE KFLOATING_SAVE
struct _KFLOATING_SAVE * PKFLOATING_SAVE
unsigned int ULONG
Definition: retypes.h:1

◆ __drv_freesMem()

__kernel_entry _Inout_ __drv_freesMem ( Mem  )

Definition at line 1315 of file exfuncs.h.

1316 {
1317  Lookaside->L.TotalFrees++;
1318 #ifdef NONAMELESSUNION
1319  if (ExQueryDepthSList(&Lookaside->L.u.ListHead) >= Lookaside->L.Depth) {
1320  Lookaside->L.u3.FreeMisses++;
1321  (Lookaside->L.u5.Free)(Entry);
1322  } else {
1323 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1324  ExInterlockedPushEntrySList(&Lookaside->L.u.ListHead,
1326  &Lookaside->Lock__ObsoleteButDoNotDelete);
1327 #else
1329 #endif
1330  }
1331 #else /* NONAMELESSUNION */
1332  if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
1333  Lookaside->L.FreeMisses++;
1334  (Lookaside->L.Free)(Entry);
1335  } else {
1336 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1339  &Lookaside->Lock__ObsoleteButDoNotDelete);
1340 #else
1342 #endif
1343  }
1344 #endif /* NONAMELESSUNION */
1345 }
#define ExInterlockedPushEntrySList(SListHead, SListEntry, Lock)
Definition: exfuncs.h:163
_Inout_ PVOID Lookaside
Definition: fltkernel.h:2532
#define PSLIST_ENTRY
Definition: rtltypes.h:130
FORCEINLINE USHORT ExQueryDepthSList(_In_ PSLIST_HEADER SListHead)
Definition: exfuncs.h:153
NTKERNELAPI PSLIST_ENTRY FASTCALL InterlockedPushEntrySList(IN PSLIST_HEADER ListHead, IN PSLIST_ENTRY ListEntry)
Definition: interlocked.c:82
base of all file and directory entries
Definition: entries.h:82

◆ __drv_strictType()

_Must_inspect_result_ _Maybe_raises_SEH_exception_ _In_ __drv_strictType ( KPROCESSOR_MODE/enum  _MODE,
__drv_typeConst   
)

◆ __in_data_source()

_Must_inspect_result_ _In_ __in_data_source ( USER_MODE  )

◆ _In_reads_()

_In_reads_ ( NumberOfLists  )

◆ _IRQL_requires_max_() [1/3]

_Must_inspect_result_ _IRQL_requires_max_ ( DISPATCH_LEVEL  )

Definition at line 30 of file rmap.c.

36 {
38 }
#define TAG_RMAP
Definition: tag.h:133
#define P(row, col)
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

◆ _IRQL_requires_max_() [2/3]

_IRQL_requires_max_ ( PASSIVE_LEVEL  )

Definition at line 64 of file Messaging.c.

75 {
76  PFLT_SERVER_PORT_OBJECT PortObject;
78 
79  /* The caller must allow at least one connection */
80  if (MaxConnections == 0)
81  {
83  }
84 
85  /* The request must be for a kernel handle */
86  if (!(ObjectAttributes->Attributes & OBJ_KERNEL_HANDLE))
87  {
89  }
90 
91  /*
92  * Get rundown protection on the target to stop the owner
93  * from unloading whilst this port object is open. It gets
94  * removed in the FltpServerPortClose callback
95  */
97  if (!NT_SUCCESS(Status))
98  {
99  return Status;
100  }
101 
102  /* Create the server port object for this filter */
106  KernelMode,
107  NULL,
108  sizeof(FLT_SERVER_PORT_OBJECT),
109  0,
110  0,
111  (PVOID *)&PortObject);
112  if (NT_SUCCESS(Status))
113  {
114  /* Zero out the struct */
115  RtlZeroMemory(PortObject, sizeof(FLT_SERVER_PORT_OBJECT));
116 
117  /* Increment the ref count on the target filter */
119 
120  /* Setup the filter port object */
121  PortObject->Filter = Filter;
122  PortObject->ConnectNotify = ConnectNotifyCallback;
124  PortObject->MessageNotify = MessageNotifyCallback;
125  PortObject->Cookie = ServerPortCookie;
126  PortObject->MaxConnections = MaxConnections;
127 
128  /* Insert the object */
129  Status = ObInsertObject(PortObject,
130  NULL,
132  0,
133  NULL,
135  if (NT_SUCCESS(Status))
136  {
137  /* Lock the connection list */
139 
140  /* Add the new port object to the connection list and increment the count */
143 
144  /* Unlock the connection list*/
146  }
147  }
148 
149  if (!NT_SUCCESS(Status))
150  {
151  /* Allow the filter to be cleaned up */
153  }
154 
155  return Status;
156 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _Outptr_ PFLT_PORT * ServerPort
Definition: fltkernel.h:1873
PFLT_CONNECT_NOTIFY ConnectNotify
Definition: fltmgrint.h:191
VOID FLTAPI FltObjectDereference(_Inout_ PVOID Object)
Definition: Object.c:53
LONG NTSTATUS
Definition: precomp.h:26
#define InsertTailList(ListHead, Entry)
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
ULONG FltpObjectPointerReference(_In_ PFLT_OBJECT Object)
Definition: Object.c:322
LIST_ENTRY mList
Definition: fltmgrint.h:56
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
#define FILE_READ_DATA
Definition: nt_native.h:628
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:952
POBJECT_TYPE ServerPortObjectType
Definition: Messaging.c:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback
Definition: fltkernel.h:1873
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback
Definition: fltkernel.h:1873
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI ObInsertObject(IN PVOID Object, IN PACCESS_STATE AccessState OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG ObjectPointerBias, OUT PVOID *NewObject OPTIONAL, OUT PHANDLE Handle)
Definition: obhandle.c:2932
#define STANDARD_RIGHTS_ALL
Definition: nt_native.h:69
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
NTSTATUS FLTAPI FltObjectReference(_Inout_ PVOID Object)
Definition: Object.c:41
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID ServerPortCookie
Definition: fltkernel.h:1873
FAST_MUTEX mLock
Definition: fltmgrint.h:55
PFLT_MESSAGE_NOTIFY MessageNotify
Definition: fltmgrint.h:193
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY _In_opt_ PFLT_MESSAGE_NOTIFY _In_ LONG MaxConnections
Definition: fltkernel.h:1873
PFLT_DISCONNECT_NOTIFY DisconnectNotify
Definition: fltmgrint.h:192
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY _In_opt_ PFLT_MESSAGE_NOTIFY MessageNotifyCallback
Definition: fltkernel.h:1873
FLT_MUTEX_LIST_HEAD ConnectionList
Definition: fltmgrint.h:121

◆ _IRQL_requires_max_() [3/3]

_Must_inspect_result_ _IRQL_requires_max_ ( APC_LEVEL  )

◆ _Out_writes_bytes_opt_()

_Must_inspect_result_ _Out_writes_bytes_opt_ ( NumberOfBytes  )

◆ _Post_writable_byte_size_() [1/2]

_Must_inspect_result_ _Post_writable_byte_size_ ( NumberOfBytes  )

◆ _Post_writable_byte_size_() [2/2]

_Post_writable_byte_size_ ( MemoryDescriptorList->  ByteCount)

◆ _When_()

◆ BaseAddress()

_Must_inspect_result_ _At_* BaseAddress ( Mem  )

◆ MmCreateMdl()

◆ MmGetPhysicalAddress()

NTKERNELAPI PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress ( _In_ PVOID  BaseAddress)

◆ MmGetVirtualForPhysical()

NTKERNELAPI PVOID NTAPI MmGetVirtualForPhysical ( _In_ PHYSICAL_ADDRESS  PhysicalAddress)

◆ MmIsDriverVerifying()

NTKERNELAPI LOGICAL NTAPI MmIsDriverVerifying ( _In_ struct _DRIVER_OBJECT DriverObject)

◆ MmIsNonPagedSystemAddressValid()

NTKERNELAPI BOOLEAN NTAPI MmIsNonPagedSystemAddressValid ( _In_ PVOID  VirtualAddress)

◆ MmIsThisAnNtAsSystem()

NTKERNELAPI BOOLEAN NTAPI MmIsThisAnNtAsSystem ( VOID  )

Definition at line 246 of file mmsup.c.

247 {
248  /* Return if this is a server system */
249  return MmProductType & 0xFF;
250 }
ULONG MmProductType
Definition: mminit.c:325

Referenced by FsRtlInitializeTunnels(), PsChangeQuantumTable(), and UDFInitializeZones().

◆ MmQuerySystemSize()

NTKERNELAPI MM_SYSTEMSIZE NTAPI MmQuerySystemSize ( VOID  )

Definition at line 257 of file mmsup.c.

258 {
259  /* Return the low, medium or high memory system type */
260  return MmSystemSize;
261 }
MM_SYSTEMSIZE MmSystemSize
Definition: mminit.c:326

Referenced by CcInitializeCacheManager(), CdInitializeGlobalData(), DriverEntry(), PspInitPhase0(), RxInitializeWorkQueueDispatcher(), and UDFInitializeZones().

◆ MmSizeOfMdl()

NTKERNELAPI SIZE_T NTAPI MmSizeOfMdl ( _In_reads_bytes_opt_(Length) PVOID  Base,
_In_ SIZE_T  Length 
)

Variable Documentation

◆ AccessMode

Definition at line 396 of file mmfuncs.h.

Referenced by BuildExplicitAccessWithNameA(), BuildExplicitAccessWithNameW(), BuildImpersonateExplicitAccessWithNameA(), BuildImpersonateExplicitAccessWithNameW(), CmpConvertHandleToKernelHandle(), CmpCreateLinkNode(), CmpDoCreate(), CmpDoCreateChild(), CmpDoOpen(), CmpParseKey(), DosCreateFileEx(), DosOpenFile(), ExLockUserBuffer(), ExpDesktopOkToClose(), ExpWindowStationOkToClose(), ExpWinStaObjectParse(), IntCreateDesktop(), IntCreateWindowStation(), IntValidateDesktopHandle(), IntValidateWindowStationHandle(), IopCreateFile(), IopParseDevice(), IopParseFile(), IopQueryAttributesFile(), MmMapLockedPages(), MmMapLockedPagesSpecifyCache(), MmProbeAndLockPages(), MockMmProbeAndLockPages(), MockObReferenceObjectByHandle(), NtDeleteFile(), ObCheckCreateObjectAccess(), ObCheckObjectAccess(), ObCloseHandle(), ObCreateObject(), ObOpenObjectByName(), ObOpenObjectByPointer(), ObpCaptureObjectCreateInformation(), ObpCaptureObjectName(), ObpCheckObjectReference(), ObpCheckTraverseAccess(), ObpCloseHandle(), ObpCloseHandleTableEntry(), ObpCreateHandle(), ObpCreateUnnamedHandle(), ObpIncrementHandleCount(), ObpLookupObjectName(), ObpParseSymbolicLink(), ObpReferenceProcessObjectByHandle(), ObReferenceFileObjectForWrite(), ObReferenceObjectByHandle(), ObReferenceObjectByName(), ObReferenceObjectByPointer(), OkayToCloseProc(), ProbeAndCaptureObjectAttributes(), QueryNameProc(), ReleaseCapturedObjectAttributes(), SeAccessCheck(), SeFastTraverseCheck(), SeOpenObjectAuditAlarm(), SepCaptureAcl(), SepCaptureSecurityQualityOfService(), SepCaptureSid(), SepReleaseAcl(), SepReleaseSecurityQualityOfService(), SepReleaseSid(), SeReleaseSidAndAttributesArray(), WmipCaptureGuidObjectAttributes(), WmipOpenGuidObject(), and WmipOpenGuidObjectByName().

◆ BoundaryAddressMultiple

◆ CacheType

◆ Context

◆ CopyFunction

◆ DelayClose

_In_ BOOLEAN DelayClose

Definition at line 593 of file mmfuncs.h.

◆ Direction

◆ Flags

◆ FlushType

_In_ MMFLUSH_TYPE FlushType

Definition at line 601 of file mmfuncs.h.

◆ FreeType

Definition at line 810 of file mmfuncs.h.

◆ HighAddress

◆ HighestAcceptableAddress

Definition at line 204 of file mmfuncs.h.

◆ Length

Definition at line 617 of file mmfuncs.h.

◆ LowestAcceptableAddress

◆ MappedBase

◆ MemoryDescriptorList

_In_ ULONG _Inout_ PMDL MemoryDescriptorList

Definition at line 406 of file mmfuncs.h.

Referenced by CcMdlReadComplete2(), DECLARE_INTERFACE_(), and FsRtlMdlReadCompleteDev().

◆ NewFileSize

_In_opt_ PLARGE_INTEGER NewFileSize

Definition at line 609 of file mmfuncs.h.

Referenced by MmCanFileBeTruncated(), NtfsSetEndOfFile(), and UDFCommonCleanup().

◆ NewMdl

Definition at line 773 of file mmfuncs.h.

◆ NewProtect

◆ NumberOfBytes

_Inout_ PSIZE_T NumberOfBytes

Definition at line 260 of file mmfuncs.h.

◆ Operation

Definition at line 396 of file mmfuncs.h.

◆ PageAddress

Definition at line 472 of file mmfuncs.h.

Referenced by _MiFlushMappedSection(), and MmAreMemoryPagesAvailable().

◆ PoolTag

_In_ ULONG PoolTag

Definition at line 643 of file mmfuncs.h.

◆ PreferredNode

◆ ProbeMode

◆ Process

_In_ PEPROCESS Process

Definition at line 396 of file mmfuncs.h.

◆ RegionSize

Definition at line 810 of file mmfuncs.h.

◆ SkipBytes

◆ Tag

Initial value:
{
return ((ULONG)((TagBase) + ((Tag) << HEAP_TAG_SHIFT)))
#define HEAP_TAG_SHIFT
Definition: nt_native.h:1724
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
unsigned int ULONG
Definition: retypes.h:1

Definition at line 188 of file mmfuncs.h.

◆ ThunkBufferSize

_In_ ULONG ThunkBufferSize

Definition at line 700 of file mmfuncs.h.

Referenced by MmAddVerifierThunks().

◆ TotalBytes

◆ ViewSize

Definition at line 493 of file mmfuncs.h.