ReactOS 0.4.16-dev-424-ge4748fe
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)
 Queries information details about a security descriptor.
 
NTKERNELAPI LOGICAL NTAPI MmIsDriverVerifying (_In_ struct _DRIVER_OBJECT *DriverObject)
 
_Must_inspect_result_ _IRQL_requires_max_ (APC_LEVEL) NTKERNELAPI PVOID NTAPI MmLockPagableDataSection(_In_ PVOID AddressWithinSection)
 Probes and locks virtual pages in memory for the specified process.
 
_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)
 
 _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_SIZE
Definition: env_spec_w32.h:49
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
_Check_return_ _Ret_maybenull_ _In_ size_t _In_ size_t _Size
Definition: malloc.h:109
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59

◆ 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) : \
PVOID NTAPI MmMapLockedPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode)
Definition: mdlsup.c:818
#define KernelMode
Definition: asm.h:38
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
#define MDL_SOURCE_IS_NONPAGED_POOL
Definition: mmtypes.h:20
#define MDL_MAPPED_TO_SYSTEM_VA
Definition: mmtypes.h:18

◆ MmGetSystemAddressForMdlSafe

#define MmGetSystemAddressForMdlSafe (   _Mdl,
  _Priority 
)
Value:
(((_Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA \
(_Mdl)->MappedSystemVa : \
KernelMode, MmCached, NULL, FALSE, (_Priority)))
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
PVOID NTAPI MmMapLockedPagesSpecifyCache(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN MEMORY_CACHING_TYPE CacheType, IN PVOID BaseAddress, IN ULONG BugCheckOnFailure, IN ULONG Priority)
Definition: mdlsup.c:660
void * PVOID
Definition: typedefs.h:50
@ MmCached
Definition: mmtypes.h:130

◆ 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; \
}
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:732
ULONG PFN_NUMBER
Definition: ke.h:9
short CSHORT
Definition: umtypes.h:127
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _In_ LARGE_INTEGER ByteCount
Definition: iotypes.h:1099
#define BYTE_OFFSET(Va)
#define PAGE_ALIGN(Va)
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)
MDL
Definition: mmtypes.h:117

◆ 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_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 ( _NTDDK_  )

Definition at line 559 of file iofuncs.h.

2502{
2503 PriorityInfo->Size = sizeof(IO_PRIORITY_INFO);
2504 PriorityInfo->ThreadPriority = 0xffff;
2505 PriorityInfo->IoPriority = IoPriorityNormal;
2506 PriorityInfo->PagePriority = 0;
2507}
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD _Inout_ PIO_PRIORITY_INFO PriorityInfo
Definition: fltkernel.h:2654
struct _IO_PRIORITY_INFO IO_PRIORITY_INFO
@ IoPriorityNormal
Definition: iotypes.h:1233

◆ $endif() [2/3]

$endif ( _NTIFS_  )

Definition at line 396 of file rtlfuncs.h.

2856{
2858 ret.QuadPart = SignedInteger;
2859 return ret;
2860}
return ret
Definition: rtlfuncs.h:3107

◆ $endif() [3/3]

$endif ( _WDMDDK_  )

Definition at line 85 of file ke.h.

226{
229} NEON128, *PNEON128;
NEON128
Definition: ke.h:229
* PNEON128
Definition: ke.h:229
@ High
Definition: strmini.h:378
@ Low
Definition: strmini.h:380
int64_t LONGLONG
Definition: typedefs.h:68
uint64_t ULONGLONG
Definition: typedefs.h:67

◆ $if()

$if ( _WDMDDK_  )

Kernel definitions for ARM64

Kernel definitions for AMD64

Kernel definitions for ARM

Definition at line 1 of file ke.h.

31{
32 ULONG Dummy;
KFLOATING_SAVE
Definition: ke.h:33
* PKFLOATING_SAVE
Definition: ke.h:33

◆ __drv_freesMem()

__kernel_entry _Inout_ __drv_freesMem ( Mem  )

Definition at line 913 of file exfuncs.h.

1524{
1525 Lookaside->L.TotalFrees++;
1526#ifdef NONAMELESSUNION
1527 if (ExQueryDepthSList(&Lookaside->L.u.ListHead) >= Lookaside->L.Depth) {
1528 Lookaside->L.u3.FreeMisses++;
1529 (Lookaside->L.u5.Free)(Entry);
1530 } else {
1531#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1534 &Lookaside->Lock__ObsoleteButDoNotDelete);
1535#else
1537#endif
1538 }
1539#else /* NONAMELESSUNION */
1540 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
1541 Lookaside->L.FreeMisses++;
1542 (Lookaside->L.Free)(Entry);
1543 } else {
1544#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1547 &Lookaside->Lock__ObsoleteButDoNotDelete);
1548#else
1550#endif
1551 }
1552#endif /* NONAMELESSUNION */
1553}
base of all file and directory entries
Definition: entries.h:83
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_opt_ ULONG _Out_ WDFLOOKASIDE * Lookaside
Definition: wdfmemory.h:414
#define ExInterlockedPushEntrySList(SListHead, SListEntry, Lock)
Definition: exfuncs.h:163
FORCEINLINE USHORT ExQueryDepthSList(_In_ PSLIST_HEADER SListHead)
Definition: exfuncs.h:153
#define InterlockedPushEntrySList(SListHead, SListEntry)
Definition: rtlfuncs.h:3406
#define PSLIST_ENTRY
Definition: rtltypes.h:134

◆ __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_ ( APC_LEVEL  )

Probes and locks virtual pages in memory for the specified process.

Parameters
[in,out]MemoryDescriptorListMemory Descriptor List (MDL) containing the buffer to be probed and locked.
[in]ProcessThe process for which the buffer should be probed and locked.
[in]AccessModeAccess mode for probing the pages. Can be KernelMode or UserMode.
[in]LockOperationThe type of the probing and locking operation. Can be IoReadAccess, IoWriteAccess or IoModifyAccess.
Returns
Nothing.
See also
MmProbeAndLockPages
Remarks
Must be called at IRQL <= APC_LEVEL

Probes and locks virtual pages in memory for the specified process.

Frees previously reserved amount of memory in system virtual address space.

Parameters
[in]NumberOfBytesSize, in bytes, of memory to reserve.
[in]PoolTagPool Tag identifying the buffer. Usually consists from 4 characters in reversed order.
Returns
A pointer to the 1st memory block of the reserved buffer in case of success, NULL otherwise.
Remarks
Must be called at IRQL <= APC_LEVEL
Parameters
[in]BaseAddressA pointer to the 1st memory block of the reserved buffer.
[in]PoolTagPool Tag identifying the buffer. Usually consists from 4 characters in reversed order.
Returns
Nothing.
See also
MmAllocateMappingAddress
Remarks
Must be called at IRQL <= APC_LEVEL

Definition at line 37 of file cddata.c.

254{
255 THREAD_CONTEXT ThreadContext = {0};
256 PIRP_CONTEXT IrpContext = NULL;
258
259#ifdef CD_SANITY
260 PVOID PreviousTopLevel;
261#endif
262
264
265#if DBG
266
267 KIRQL SaveIrql = KeGetCurrentIrql();
268
269#endif
270
272
274
276
277#ifdef CD_SANITY
278 PreviousTopLevel = IoGetTopLevelIrp();
279#endif
280
281 //
282 // Loop until this request has been completed or posted.
283 //
284
285 do {
286
287 //
288 // Use a try-except to handle the exception cases.
289 //
290
291 _SEH2_TRY {
292
293 //
294 // If the IrpContext is NULL then this is the first pass through
295 // this loop.
296 //
297
298 if (IrpContext == NULL) {
299
300 //
301 // Decide if this request is waitable an allocate the IrpContext.
302 // If the file object in the stack location is NULL then this
303 // is a mount which is always waitable. Otherwise we look at
304 // the file object flags.
305 //
306
308
309 Wait = TRUE;
310
311 } else {
312
313 Wait = CanFsdWait( Irp );
314 }
315
316 IrpContext = CdCreateIrpContext( Irp, Wait );
317
318 //
319 // Update the thread context information.
320 //
321
322 CdSetThreadContext( IrpContext, &ThreadContext );
323
324#ifdef CD_SANITY
325 NT_ASSERT( !CdTestTopLevel ||
326 SafeNodeType( IrpContext->TopLevel ) == CDFS_NTC_IRP_CONTEXT );
327#endif
328
329 //
330 // Otherwise cleanup the IrpContext for the retry.
331 //
332
333 } else {
334
335 //
336 // Set the MORE_PROCESSING flag to make sure the IrpContext
337 // isn't inadvertently deleted here. Then cleanup the
338 // IrpContext to perform the retry.
339 //
340
341 SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_MORE_PROCESSING );
342 CdCleanupIrpContext( IrpContext, FALSE );
343 }
344
345 //
346 // Case on the major irp code.
347 //
348
349 switch (IrpContext->MajorFunction) {
350
351 case IRP_MJ_CREATE :
352
353 Status = CdCommonCreate( IrpContext, Irp );
354 break;
355
356 case IRP_MJ_CLOSE :
357
358 Status = CdCommonClose( IrpContext, Irp );
359 break;
360
361 case IRP_MJ_READ :
362
363 //
364 // If this is an Mdl complete request, don't go through
365 // common read.
366 //
367
368 if (FlagOn( IrpContext->MinorFunction, IRP_MN_COMPLETE )) {
369
370 Status = CdCompleteMdl( IrpContext, Irp );
371
372 } else {
373
374 Status = CdCommonRead( IrpContext, Irp );
375 }
376
377 break;
378
379 case IRP_MJ_WRITE :
380
381 Status = CdCommonWrite( IrpContext, Irp );
382 break;
383
385
386 Status = CdCommonQueryInfo( IrpContext, Irp );
387 break;
388
390
391 Status = CdCommonSetInfo( IrpContext, Irp );
392 break;
393
395
396 Status = CdCommonQueryVolInfo( IrpContext, Irp );
397 break;
398
400
401 Status = CdCommonDirControl( IrpContext, Irp );
402 break;
403
405
406 Status = CdCommonFsControl( IrpContext, Irp );
407 break;
408
410
411 Status = CdCommonDevControl( IrpContext, Irp );
412 break;
413
415
416 Status = CdCommonLockControl( IrpContext, Irp );
417 break;
418
419 case IRP_MJ_CLEANUP :
420
421 Status = CdCommonCleanup( IrpContext, Irp );
422 break;
423
424 case IRP_MJ_PNP :
425
426 Status = CdCommonPnp( IrpContext, Irp );
427 break;
428
429 case IRP_MJ_SHUTDOWN :
430
431 Status = CdCommonShutdown( IrpContext, Irp );
432 break;
433
434 default :
435
437 CdCompleteRequest( IrpContext, Irp, Status );
438 }
439
441
442 Status = CdProcessException( IrpContext, Irp, _SEH2_GetExceptionCode() );
443 } _SEH2_END;
444
445 } while (Status == STATUS_CANT_WAIT);
446
447#ifdef CD_SANITY
448 NT_ASSERT( !CdTestTopLevel ||
449 (PreviousTopLevel == IoGetTopLevelIrp()) );
450#endif
451
453
454 NT_ASSERT( SaveIrql == KeGetCurrentIrql( ));
455
456 return Status;
457}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
LONG CdExceptionFilter(_Inout_ PIRP_CONTEXT IrpContext, _In_ PEXCEPTION_POINTERS ExceptionPointer)
Definition: cddata.c:525
VOID CdSetThreadContext(_Inout_ PIRP_CONTEXT IrpContext, _In_ PTHREAD_CONTEXT ThreadContext)
Definition: cddata.c:981
#define ASSERT_OPTIONAL_IRP(I)
Definition: cddata.h:251
NTSTATUS CdCompleteMdl(_In_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: cachesup.c:411
VOID CdCleanupIrpContext(_In_ PIRP_CONTEXT IrpContext, _In_ BOOLEAN Post)
Definition: strucsup.c:1733
#define CanFsdWait(I)
Definition: cdprocs.h:2001
NTSTATUS CdCommonLockControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: lockctrl.c:35
NTSTATUS CdCommonDevControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: devctrl.c:46
_Ret_valid_ PIRP_CONTEXT CdCreateIrpContext(_In_ PIRP Irp, _In_ BOOLEAN Wait)
Definition: strucsup.c:1573
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define IRP_CONTEXT_FLAG_MORE_PROCESSING
Definition: cdstruc.h:1214
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define CDFS_NTC_IRP_CONTEXT
Definition: nodetype.h:34
#define SafeNodeType(Ptr)
Definition: nodetype.h:54
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
Status
Definition: gdiplustypes.h:25
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
#define STATUS_CANT_WAIT
Definition: ntstatus.h:452
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:164
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
#define IRP_MN_COMPLETE
Definition: iotypes.h:4420
#define IRP_MJ_FILE_SYSTEM_CONTROL
#define IRP_MJ_SHUTDOWN
#define IRP_MJ_CLEANUP
#define NT_ASSERT
Definition: rtlfuncs.h:3327

◆ _IRQL_requires_max_() [2/3]

_Must_inspect_result_ _IRQL_requires_max_ ( DISPATCH_LEVEL  )

Definition at line 347 of file common.c.

3587{
3589 BOOLEAN requestSent = FALSE;
3590
3591 BOOLEAN shouldRetry = TRUE;
3592 PCDB cdb = (PCDB)DeviceExtension->PowerContext.Srb.Cdb;
3593 ULONG timeoutValue = DeviceExtension->TimeOutValue;
3594 ULONG retryCount = 1;
3595
3596 // reset some fields.
3597 DeviceExtension->PowerContext.RetryIntervalIn100ns = 0;
3598 status = PowerContextReuseRequest(DeviceExtension);
3599 RequestClearSendTime(DeviceExtension->PowerContext.PowerRequest);
3600
3601 if (!NT_SUCCESS(status))
3602 {
3603 return status;
3604 }
3605
3606 // set proper timeout value and max retry count.
3607 switch(DeviceExtension->PowerContext.PowerChangeState.PowerDown)
3608 {
3612 break;
3613
3615 // Case of issuing SYNC CACHE command. Do not use power irp timeout remaining time in this case
3616 // as we want to give best try on SYNC CACHE command.
3617 retryCount = MAXIMUM_RETRIES;
3618 timeoutValue = DeviceExtension->TimeOutValue;
3619 break;
3620
3622 {
3623 // Case of issuing STOP UNIT command
3624 // As "Imme" bit is set to '1', this command should be completed in short time.
3625 // This command is at low importance, failure of this command has very small impact.
3626 ULONG secondsRemaining = 0;
3627
3628#if (WINVER >= 0x0601)
3629 // this API is introduced in Windows7
3630 PoQueryWatchdogTime(DeviceExtension->LowerPdo, &secondsRemaining);
3631#endif
3632
3633 if (secondsRemaining == 0)
3634 {
3635 // not able to retrieve remaining time from PoQueryWatchdogTime API, use default values.
3636 retryCount = MAXIMUM_RETRIES;
3637 timeoutValue = SCSI_CDROM_TIMEOUT;
3638 }
3639 else
3640 {
3641 // plan to leave about 30 seconds to lower level drivers if possible.
3642 if (secondsRemaining >= 32)
3643 {
3644 retryCount = (secondsRemaining - 30)/SCSI_CDROM_TIMEOUT + 1;
3645 timeoutValue = SCSI_CDROM_TIMEOUT;
3646
3647 if (retryCount > MAXIMUM_RETRIES)
3648 {
3649 retryCount = MAXIMUM_RETRIES;
3650 }
3651
3652 if (retryCount == 1)
3653 {
3654 timeoutValue = secondsRemaining - 30;
3655 }
3656 }
3657 else
3658 {
3659 // issue the command with minimal timeout value and do not retry on it.
3660 retryCount = 1;
3661 timeoutValue = 2;
3662 }
3663 }
3664 }
3665 break;
3666 default:
3667 NT_ASSERT( FALSE );
3669 return status;
3670 }
3671
3672 DeviceExtension->PowerContext.RetryCount = retryCount;
3673
3674 // issue command.
3675 while (shouldRetry)
3676 {
3677
3678 // set SRB fields.
3679 DeviceExtension->PowerContext.Srb.SrbFlags = SRB_FLAGS_NO_DATA_TRANSFER |
3684
3685 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
3686 DeviceExtension->PowerContext.Srb.TimeOutValue = timeoutValue;
3687
3688 if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceInitial)
3689 {
3690 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_LOCK_QUEUE;
3691 }
3692 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceLocked)
3693 {
3694 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_QUIESCE_DEVICE;
3695 }
3696 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced)
3697 {
3698 // Case of issuing SYNC CACHE command.
3699 DeviceExtension->PowerContext.Srb.CdbLength = 10;
3700 cdb->SYNCHRONIZE_CACHE10.OperationCode = SCSIOP_SYNCHRONIZE_CACHE;
3701 }
3702 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceFlushed)
3703 {
3704 // Case of issuing STOP UNIT command.
3705 DeviceExtension->PowerContext.Srb.CdbLength = 6;
3706 cdb->START_STOP.OperationCode = SCSIOP_START_STOP_UNIT;
3707 cdb->START_STOP.Start = 0;
3708 cdb->START_STOP.Immediate = 1;
3709 }
3710 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceStopped)
3711 {
3712 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_UNLOCK_QUEUE;
3713 }
3714
3715 // Set up completion routine and context if requested
3717 {
3718 WdfRequestSetCompletionRoutine(DeviceExtension->PowerContext.PowerRequest,
3720 Context);
3721 }
3722
3723 status = RequestSend(DeviceExtension,
3724 DeviceExtension->PowerContext.PowerRequest,
3725 DeviceExtension->IoTarget,
3727 &requestSent);
3728
3729 if (requestSent)
3730 {
3731 if ((CompletionRoutine == NULL) &&
3732 (SRB_STATUS(DeviceExtension->PowerContext.Srb.SrbStatus) != SRB_STATUS_SUCCESS))
3733 {
3734 TracePrint((TRACE_LEVEL_ERROR,
3735 TRACE_FLAG_POWER,
3736 "%p\tError occured when issuing %s command to device. Srb %p, Status %x\n",
3737 DeviceExtension->PowerContext.PowerRequest,
3738 (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced) ? "SYNC CACHE" : "STOP UNIT",
3739 &DeviceExtension->PowerContext.Srb,
3740 DeviceExtension->PowerContext.Srb.SrbStatus));
3741
3742 NT_ASSERT(!(TEST_FLAG(DeviceExtension->PowerContext.Srb.SrbStatus, SRB_STATUS_QUEUE_FROZEN)));
3743
3744 shouldRetry = RequestSenseInfoInterpret(DeviceExtension,
3745 DeviceExtension->PowerContext.PowerRequest,
3746 &(DeviceExtension->PowerContext.Srb),
3747 retryCount - DeviceExtension->PowerContext.RetryCount,
3748 &status,
3749 &(DeviceExtension->PowerContext.RetryIntervalIn100ns));
3750
3751 if (shouldRetry && (DeviceExtension->PowerContext.RetryCount-- == 0))
3752 {
3753 shouldRetry = FALSE;
3754 }
3755 }
3756 else
3757 {
3758 // succeeded, do not need to retry.
3759 shouldRetry = FALSE;
3760 }
3761
3762 }
3763 else
3764 {
3765 // request failed to be sent
3766 shouldRetry = FALSE;
3767 }
3768
3769 if (shouldRetry)
3770 {
3772 t.QuadPart = -DeviceExtension->PowerContext.RetryIntervalIn100ns;
3774
3775 status = PowerContextReuseRequest(DeviceExtension);
3776 if (!NT_SUCCESS(status))
3777 {
3778 shouldRetry = FALSE;
3779 }
3780 }
3781 }
3782
3783 if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced)
3784 {
3785 // record SYNC CACHE command completion time stamp.
3786 KeQueryTickCount(&DeviceExtension->PowerContext.Step1CompleteTime);
3787 }
3788
3789 return status;
3790}
#define MAXIMUM_RETRIES
Definition: cdrom.h:124
#define SCSI_CDROM_TIMEOUT
Definition: cdrom.h:680
BOOLEAN RequestSenseInfoInterpret(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ PSCSI_REQUEST_BLOCK Srb, _In_ ULONG RetriedCount, _Out_ NTSTATUS *Status, _Out_opt_ _Deref_out_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG *RetryIntervalIn100ns)
Definition: sense.c:2467
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
@ PowerDownDeviceStopped
Definition: cdrom.h:412
@ PowerDownDeviceQuiesced
Definition: cdrom.h:410
@ PowerDownDeviceInitial
Definition: cdrom.h:408
@ PowerDownDeviceLocked
Definition: cdrom.h:409
@ PowerDownDeviceFlushed
Definition: cdrom.h:411
union _CDB * PCDB
#define SCSIOP_START_STOP_UNIT
Definition: cdrw_hw.h:897
#define SCSIOP_SYNCHRONIZE_CACHE
Definition: cdrw_hw.h:918
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSTATUS RequestSend(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDFIOTARGET IoTarget, _In_ ULONG Flags, _Out_opt_ PBOOLEAN RequestSent)
Definition: common.c:3793
VOID RequestClearSendTime(_In_ WDFREQUEST Request)
Definition: common.c:111
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:315
#define SRB_FLAGS_NO_DATA_TRANSFER
Definition: srb.h:402
#define SRB_FUNCTION_LOCK_QUEUE
Definition: srb.h:332
#define SRB_FUNCTION_UNLOCK_QUEUE
Definition: srb.h:333
#define SRB_FLAGS_BYPASS_LOCKED_QUEUE
Definition: srb.h:410
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
Definition: srb.h:397
#define SRB_STATUS(Status)
Definition: srb.h:389
#define SRB_STATUS_QUEUE_FROZEN
Definition: srb.h:386
#define SRB_FLAGS_NO_QUEUE_FREEZE
Definition: srb.h:404
#define SRB_STATUS_SUCCESS
Definition: srb.h:341
#define KeDelayExecutionThread(mode, foo, t)
Definition: env_spec_w32.h:484
GLdouble GLdouble t
Definition: gl.h:2047
#define SRB_FLAGS_D3_PROCESSING
Definition: srb.h:165
#define SRB_FUNCTION_QUIESCE_DEVICE
Definition: srb.h:99
#define KeQueryTickCount(CurrentCount)
Definition: ke.h:43
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
Definition: cdrw_hw.h:28
struct _CDB::_START_STOP START_STOP
struct _CDB::_SYNCHRONIZE_CACHE10 SYNCHRONIZE_CACHE10
@ WDF_REQUEST_SEND_OPTION_SYNCHRONOUS
Definition: wdfrequest.h:109
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
Definition: wdfrequest.h:895

◆ _IRQL_requires_max_() [3/3]

_IRQL_requires_max_ ( PASSIVE_LEVEL  )

Queries information details about a security descriptor.

Computes the quota size of a security descriptor.

Assigns a security descriptor for a new object.

An extended function that assigns a security descriptor for a new object.

Frees a security descriptor.

An extended function that sets new information data to a security descriptor.

Modifies some information data about a security descriptor.

Parameters
[in]SecurityInformationSecurity information details to be queried from a security descriptor.
[out]SecurityDescriptorThe returned security descriptor with security information data.
[in,out]LengthThe returned length of a security descriptor.
[in,out]ObjectsSecurityDescriptorThe returned object security descriptor.
Returns
Returns STATUS_SUCCESS if the operations have been completed successfully and that the specific information about the security descriptor has been queried. STATUS_BUFFER_TOO_SMALL is returned if the buffer size is too small to contain the queried info about the security descriptor.
Parameters
[in]ObjectIf specified, the function will use this arbitrary object that points to an object security descriptor.
[in]SecurityInformationSecurity information details to be set.
[in]SecurityDescriptorA security descriptor where its info is to be changed.
[in,out]ObjectsSecurityDescriptorThe returned pointer to security descriptor objects.
[in]PoolTypePool type for the new security descriptor to allocate.
[in]GenericMappingThe generic mapping of access rights masks.
Returns
See SeSetSecurityDescriptorInfoEx.
Parameters
[in]ObjectIf specified, the function will use this arbitrary object that points to an object security descriptor.
[in]SecurityInformationSecurity information details to be set.
[in]SecurityDescriptorA security descriptor where its info is to be changed.
[in,out]ObjectsSecurityDescriptorThe returned pointer to security descriptor objects.
[in]AutoInheritFlagsFlags bitmask inheritation, influencing how the security descriptor can be inherited and if it can be in the first place.
[in]PoolTypePool type for the new security descriptor to allocate.
[in]GenericMappingThe generic mapping of access rights masks.
Returns
Returns STATUS_SUCCESS if the operations have been completed without problems and that new info has been set to the security descriptor. STATUS_NO_SECURITY_ON_OBJECT is returned if the object does not have a security descriptor. STATUS_INSUFFICIENT_RESOURCES is returned if memory pool allocation for the new security descriptor with new info set has failed.
Parameters
[in]SecurityDescriptorA security descriptor to be freed from memory.
Returns
Returns STATUS_SUCCESS.
Parameters
[in]_ParentDescriptorA security descriptor of the parent object that is being created.
[in]_ExplicitDescriptorAn explicit security descriptor that is applied to a new object.
[out]NewDescriptorThe new allocated security descriptor.
[in]ObjectTypeThe type of the new object.
[in]IsDirectoryObjectSet this to TRUE if the newly created object is a directory object, otherwise set this to FALSE.
[in]AutoInheritFlagsAutomatic inheritance flags that influence how access control entries within ACLs from security descriptors are inherited.
[in]SubjectContextSecurity subject context of the new object.
[in]GenericMappingGeneric mapping of access mask rights.
[in]PoolTypeThis parameter is unused.
Returns
Returns STATUS_SUCCESS if the operations have been completed successfully and that the security descriptor has been assigned to the new object. STATUS_NO_TOKEN is returned if the caller hasn't supplied a valid argument to a security subject context. STATUS_INVALID_OWNER is returned if the caller hasn't supplied a parent descriptor that belongs to the main user (owner). STATUS_INVALID_PRIMARY_GROUP is returned by the same reason as with the previous NTSTATUS code. The two NTSTATUS codes are returned if the calling thread stated that the owner and/or group is defaulted to the parent descriptor (SEF_DEFAULT_OWNER_FROM_PARENT and/or SEF_DEFAULT_GROUP_FROM_PARENT respectively). STATUS_INSUFFICIENT_RESOURCES is returned if memory pool allocation for the descriptor buffer has failed. A failure NTSTATUS is returned otherwise.
Parameters
[in]ParentDescriptorA security descriptor of the parent object that is being created.
[in]ExplicitDescriptorAn explicit security descriptor that is applied to a new object.
[out]NewDescriptorThe new allocated security descriptor.
[in]IsDirectoryObjectSet this to TRUE if the newly created object is a directory object, otherwise set this to FALSE.
[in]SubjectContextSecurity subject context of the new object.
[in]GenericMappingGeneric mapping of access mask rights.
[in]PoolTypeThis parameter is unused.
Returns
See SeAssignSecurityEx.
Parameters
[in]SecurityDescriptorA security descriptor.
[out]QuotaInfoSizeThe returned quota size of the given security descriptor to the caller. The function may return 0 to this parameter if the descriptor doesn't have a group or a discretionary access control list (DACL) even.
Returns
Returns STATUS_SUCCESS if the quota size of a security descriptor has been computed successfully. STATUS_UNKNOWN_REVISION is returned if the security descriptor has an invalid revision.

Definition at line 923 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 */
107 NULL,
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;
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}
static const INTERNET_PORT ServerPort
Definition: CWebService.cpp:11
POBJECT_TYPE ServerPortObjectType
Definition: Messaging.c:24
VOID FLTAPI FltObjectDereference(_Inout_ PVOID Object)
Definition: Object.c:53
NTSTATUS FLTAPI FltObjectReference(_Inout_ PVOID Object)
Definition: Object.c:41
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
_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:1877
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback
Definition: fltkernel.h:1875
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID ServerPortCookie
Definition: fltkernel.h:1874
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback
Definition: fltkernel.h:1876
ULONG FltpObjectPointerReference(_In_ PFLT_OBJECT Object)
Definition: Object.c:322
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
static LONG MaxConnections
#define FILE_READ_DATA
Definition: nt_native.h:628
#define STANDARD_RIGHTS_ALL
Definition: nt_native.h:69
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
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:2935
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:1039
FLT_MUTEX_LIST_HEAD ConnectionList
Definition: fltmgrint.h:121
LIST_ENTRY mList
Definition: fltmgrint.h:56
FAST_MUTEX mLock
Definition: fltmgrint.h:55
PFLT_DISCONNECT_NOTIFY DisconnectNotify
Definition: fltmgrint.h:192
PFLT_MESSAGE_NOTIFY MessageNotify
Definition: fltmgrint.h:193
PFLT_CONNECT_NOTIFY ConnectNotify
Definition: fltmgrint.h:191
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

◆ _Post_writable_byte_size_() [1/2]

_Post_writable_byte_size_ ( MemoryDescriptorList->  ByteCount)

◆ _Post_writable_byte_size_() [2/2]

_Must_inspect_result_ _Post_writable_byte_size_ ( NumberOfBytes  )

◆ _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 _IRQL_requires_max_(), BuildExplicitAccessWithNameA(), BuildExplicitAccessWithNameW(), BuildImpersonateExplicitAccessWithNameA(), BuildImpersonateExplicitAccessWithNameW(), CmpConvertHandleToKernelHandle(), CmpCreateLinkNode(), CmpDoCreate(), CmpDoCreateChild(), CmpDoOpen(), CmpParseKey(), DosCreateFileEx(), DosOpenFile(), ExLockUserBuffer(), ExpDesktopOkToClose(), ExpWindowStationOkToClose(), ExpWinStaObjectParse(), FxProbeAndLockForRead(), FxProbeAndLockForWrite(), FxProbeAndLockWithAccess(), IntCreateDesktop(), IntCreateWindowStation(), IntValidateDesktopHandle(), IntValidateWindowStationHandle(), IopCreateFile(), IopParseDevice(), IopParseFile(), IopQueryAttributesFile(), MmMapLockedPages(), MmMapLockedPagesSpecifyCache(), MmProbeAndLockPages(), MockMmProbeAndLockPages(), MockObReferenceObjectByHandle(), Mx::MxReferenceObjectByHandle(), 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(), SepAccessCheckWorker(), SepCaptureAcl(), SepCaptureSecurityQualityOfService(), SepCaptureSid(), SepReleaseAcl(), SepReleaseSecurityQualityOfService(), SepReleaseSid(), SeReleaseSidAndAttributesArray(), WmipCaptureGuidObjectAttributes(), WmipOpenGuidObject(), and WmipOpenGuidObjectByName().

◆ BoundaryAddressMultiple

◆ CacheType

◆ Context

◆ CopyFunction

◆ DelayClose

_In_ BOOLEAN DelayClose

Definition at line 592 of file mmfuncs.h.

◆ Direction

Definition at line 774 of file mmfuncs.h.

◆ Flags

◆ FlushType

_In_ MMFLUSH_TYPE FlushType

Definition at line 600 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 616 of file mmfuncs.h.

◆ LowestAcceptableAddress

◆ MappedBase

◆ MemoryDescriptorList

◆ NewFileSize

_In_opt_ PLARGE_INTEGER NewFileSize

Definition at line 608 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 397 of file mmfuncs.h.

◆ PageAddress

Definition at line 472 of file mmfuncs.h.

Referenced by MmAreMemoryPagesAvailable().

◆ PoolTag

Definition at line 642 of file mmfuncs.h.

◆ PreferredNode

◆ ProbeMode

◆ Process

_In_ PEPROCESS Process

Definition at line 395 of file mmfuncs.h.

◆ RegionSize

Definition at line 809 of file mmfuncs.h.

◆ SkipBytes

◆ Tag

Initial value:
{
return ((ULONG)((TagBase) + ((Tag) << HEAP_TAG_SHIFT)))
#define HEAP_TAG_SHIFT
Definition: nt_native.h:1724
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065

Definition at line 187 of file mmfuncs.h.

◆ ThunkBufferSize

_In_ ULONG ThunkBufferSize

Definition at line 699 of file mmfuncs.h.

Referenced by MmAddVerifierThunks().

◆ TotalBytes

◆ ViewSize

Definition at line 493 of file mmfuncs.h.