ReactOS 0.4.17-dev-218-g5635d24
mmfuncs.h File Reference
#include <umtypes.h>
#include <mmtypes.h>
Include dependency graph for mmfuncs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

NTSTATUS NTAPI MmCreateSection (_Out_ PVOID *SectionObject, _In_ ACCESS_MASK DesiredAccess, _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, _In_ PLARGE_INTEGER MaximumSize, _In_ ULONG SectionPageProtection, _In_ ULONG AllocationAttributes, _In_opt_ HANDLE FileHandle, _In_opt_ PFILE_OBJECT File)
 
NTSTATUS NTAPI MmMapViewOfSection (_In_ PVOID SectionObject, _In_ PEPROCESS Process, _Outptr_result_bytebuffer_(*ViewSize) _Pre_opt_valid_ PVOID *BaseAddress, _In_ ULONG_PTR ZeroBits, _In_ SIZE_T CommitSize, _Inout_opt_ PLARGE_INTEGER SectionOffset, _Inout_ PSIZE_T ViewSize, _In_range_(ViewShare, ViewUnmap) SECTION_INHERIT InheritDisposition, _In_ ULONG AllocationType, _In_ ULONG Protect)
 
NTSTATUS NTAPI MmUnmapViewOfSection (_In_ struct _EPROCESS *Process, _In_ PVOID BaseAddress)
 
NTSYSCALLAPI NTSTATUS NTAPI NtAreMappedFilesTheSame (_In_ PVOID File1MappedAsAnImage, _In_ PVOID File2MappedAsFile)
 
NTSTATUS NTAPI NtAllocateUserPhysicalPages (_In_ HANDLE ProcessHandle, _Inout_ PULONG_PTR NumberOfPages, _Inout_ PULONG_PTR UserPfnArray)
 
_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
 
NTSYSCALLAPI NTSTATUS NTAPI NtCreatePagingFile (_In_ PUNICODE_STRING FileName, _In_ PLARGE_INTEGER MinimumSize, _In_ PLARGE_INTEGER MaximumSize, _In_ ULONG Reserved)
 
_Must_inspect_result_ __kernel_entry NTSYSCALLAPI NTSTATUS NTAPI NtCreateSection (_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, _In_opt_ PLARGE_INTEGER MaximumSize, _In_ ULONG SectionPageProtection, _In_ ULONG AllocationAttributes, _In_opt_ HANDLE FileHandle)
 
NTSYSCALLAPI NTSTATUS NTAPI NtExtendSection (_In_ HANDLE SectionHandle, _In_ PLARGE_INTEGER NewMaximumSize)
 
NTSYSCALLAPI NTSTATUS NTAPI NtFlushInstructionCache (_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _In_ SIZE_T NumberOfBytesToFlush)
 
NTSYSCALLAPI NTSTATUS NTAPI NtFlushVirtualMemory (_In_ HANDLE ProcessHandle, _Inout_ PVOID *BaseAddress, _Inout_ PSIZE_T RegionSize, _Out_ PIO_STATUS_BLOCK IoStatus)
 
NTSTATUS NTAPI NtFreeUserPhysicalPages (_In_ HANDLE ProcessHandle, _Inout_ PULONG_PTR NumberOfPages, _Inout_ PULONG_PTR UserPfnArray)
 
__kernel_entry _IRQL_requires_max_ (PASSIVE_LEVEL) NTSYSCALLAPI NTSTATUS NTAPI NtFreeVirtualMemory(_In_ HANDLE ProcessHandle
 Queries information details about a security descriptor.
 
__kernel_entry _Inout_ __drv_freesMem (Mem) PVOID *BaseAddress
 
NTSTATUS NTAPI NtGetWriteWatch (_In_ HANDLE ProcessHandle, _In_ ULONG Flags, _In_ PVOID BaseAddress, _In_ SIZE_T RegionSize, _In_ PVOID *UserAddressArray, _Out_ PULONG_PTR EntriesInUserAddressArray, _Out_ PULONG Granularity)
 
NTSYSCALLAPI NTSTATUS NTAPI NtLockVirtualMemory (_In_ HANDLE ProcessHandle, _Inout_ PVOID *BaseAddress, _Inout_ PSIZE_T NumberOfBytesToLock, _In_ ULONG MapType)
 
NTSTATUS NTAPI NtMapUserPhysicalPages (_In_ PVOID VirtualAddresses, _In_ ULONG_PTR NumberOfPages, _Inout_ PULONG_PTR UserPfnArray)
 
NTSTATUS NTAPI NtMapUserPhysicalPagesScatter (_In_ PVOID *VirtualAddresses, _In_ ULONG_PTR NumberOfPages, _Inout_ PULONG_PTR UserPfnArray)
 
NTSYSCALLAPI NTSTATUS NTAPI NtMapViewOfSection (_In_ HANDLE SectionHandle, _In_ HANDLE ProcessHandle, _Outptr_result_bytebuffer_(*ViewSize) _Pre_valid_ PVOID *BaseAddress, _In_ ULONG_PTR ZeroBits, _In_ SIZE_T CommitSize, _Inout_opt_ PLARGE_INTEGER SectionOffset, _Inout_ PSIZE_T ViewSize, _In_range_(ViewShare, ViewUnmap) SECTION_INHERIT InheritDisposition, _In_ ULONG AllocationType, _In_ ULONG Win32Protect)
 
NTSYSCALLAPI NTSTATUS NTAPI NtOpenSection (_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
 
NTSYSCALLAPI NTSTATUS NTAPI NtProtectVirtualMemory (_In_ HANDLE ProcessHandle, _In_ PVOID *BaseAddress, _In_ SIZE_T *NumberOfBytesToProtect, _In_ ULONG NewAccessProtection, _Out_ PULONG OldAccessProtection)
 
NTSYSCALLAPI NTSTATUS NTAPI NtQuerySection (_In_ HANDLE SectionHandle, _In_ SECTION_INFORMATION_CLASS SectionInformationClass, _Out_ PVOID SectionInformation, _In_ SIZE_T Length, _Out_ PSIZE_T ResultLength)
 
NTSYSCALLAPI NTSTATUS NTAPI NtQueryVirtualMemory (_In_ HANDLE ProcessHandle, _In_ PVOID Address, _In_ MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass, _Out_ PVOID VirtualMemoryInformation, _In_ SIZE_T Length, _Out_opt_ PSIZE_T ResultLength)
 
NTSYSCALLAPI NTSTATUS NTAPI NtReadVirtualMemory (_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _Out_ PVOID Buffer, _In_ SIZE_T NumberOfBytesToRead, _Out_opt_ PSIZE_T NumberOfBytesRead)
 
NTSTATUS NTAPI NtResetWriteWatch (_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _In_ SIZE_T RegionSize)
 
NTSYSCALLAPI NTSTATUS NTAPI NtUnlockVirtualMemory (_In_ HANDLE ProcessHandle, _Inout_ PVOID *BaseAddress, _Inout_ PSIZE_T NumberOfBytesToUnlock, _In_ ULONG MapType)
 
NTSYSCALLAPI NTSTATUS NTAPI NtUnmapViewOfSection (_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress)
 
NTSYSCALLAPI NTSTATUS NTAPI NtWriteVirtualMemory (_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _In_ PVOID Buffer, _In_ SIZE_T NumberOfBytesToWrite, _Out_opt_ PSIZE_T NumberOfBytesWritten)
 
NTSYSAPI NTSTATUS NTAPI ZwAreMappedFilesTheSame (_In_ PVOID File1MappedAsAnImage, _In_ PVOID File2MappedAsFile)
 
NTSYSAPI NTSTATUS NTAPI ZwCreatePagingFile (_In_ PUNICODE_STRING FileName, _In_ PLARGE_INTEGER MinimumSize, _In_ PLARGE_INTEGER MaximumSize, _In_ ULONG Reserved)
 
 _IRQL_requires_max_ (APC_LEVEL) NTSYSAPI NTSTATUS NTAPI ZwCreateSection(_Out_ PHANDLE SectionHandle
 Probes and locks virtual pages in memory for the specified process.
 
NTSYSAPI NTSTATUS NTAPI ZwExtendSection (_In_ HANDLE SectionHandle, _In_ PLARGE_INTEGER NewMaximumSize)
 
NTSYSAPI NTSTATUS NTAPI ZwLockVirtualMemory (_In_ HANDLE ProcessHandle, _Inout_ PVOID *BaseAddress, _Inout_ PSIZE_T NumberOfBytesToLock, _In_ ULONG MapType)
 
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_range_ (ViewShare, ViewUnmap) SECTION_INHERIT InheritDisposition
 
NTSYSAPI NTSTATUS NTAPI ZwOpenSection (_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
 
NTSYSAPI NTSTATUS NTAPI ZwProtectVirtualMemory (_In_ HANDLE ProcessHandle, _In_ PVOID *BaseAddress, _In_ SIZE_T *NumberOfBytesToProtect, _In_ ULONG NewAccessProtection, _Out_ PULONG OldAccessProtection)
 
NTSYSAPI NTSTATUS NTAPI ZwQuerySection (_In_ HANDLE SectionHandle, _In_ SECTION_INFORMATION_CLASS SectionInformationClass, _Out_ PVOID SectionInformation, _In_ SIZE_T Length, _Out_opt_ PSIZE_T ResultLength)
 
NTSYSAPI NTSTATUS NTAPI ZwQueryVirtualMemory (_In_ HANDLE ProcessHandle, _In_ PVOID Address, _In_ MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass, _Out_ PVOID VirtualMemoryInformation, _In_ SIZE_T Length, _Out_opt_ PSIZE_T ResultLength)
 
NTSYSAPI NTSTATUS NTAPI ZwReadVirtualMemory (_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _Out_ PVOID Buffer, _In_ SIZE_T NumberOfBytesToRead, _Out_opt_ PSIZE_T NumberOfBytesRead)
 
NTSYSAPI NTSTATUS NTAPI ZwUnlockVirtualMemory (_In_ HANDLE ProcessHandle, _Inout_ PVOID *BaseAddress, _Inout_ PSIZE_T NumberOfBytesToUnlock, _In_ ULONG MapType)
 
NTSYSAPI NTSTATUS NTAPI ZwWriteVirtualMemory (_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _In_ PVOID Buffer, _In_ SIZE_T NumberOfBytesToWrite, _Out_opt_ PSIZE_T NumberOfBytesWritten)
 

Variables

__kernel_entry _Inout_ _Inout_ PSIZE_T RegionSize
 
__kernel_entry _Inout_ _Inout_ PSIZE_T _In_ ULONG FreeType
 
_In_ ACCESS_MASK DesiredAccess
 
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes
 
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER MaximumSize
 
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG SectionPageProtection
 
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG AllocationAttributes
 
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG _In_opt_ HANDLE FileHandle
 
_In_ HANDLE ProcessHandle
 
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOIDBaseAddress
 
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR ZeroBits
 
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T CommitSize
 
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
 
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
 
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ ULONG AllocationType
 
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ ULONG _In_ ULONG Win32Protect
 

Function Documentation

◆ __drv_freesMem()

_IRQL_requires_same_ _In_ __drv_freesMem ( Mem  )

◆ _In_range_()

◆ _IRQL_requires_max_() [1/2]

_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
Definition: actypes.h:127
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 NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#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:24
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
#define STATUS_CANT_WAIT
Definition: ntstatus.h:546
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:204
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:203
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
#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:2061
_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:4423
#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/2]

__kernel_entry _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 NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#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
static LONG MaxConnections
#define KernelMode
Definition: asm.h:38
#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
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
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

◆ BaseAddress()

_Must_inspect_result_ _At_ * BaseAddress ( Mem  )

◆ MmCreateSection()

NTSTATUS NTAPI MmCreateSection ( _Out_ PVOID SectionObject,
_In_ ACCESS_MASK  DesiredAccess,
_In_opt_ POBJECT_ATTRIBUTES  ObjectAttributes,
_In_ PLARGE_INTEGER  MaximumSize,
_In_ ULONG  SectionPageProtection,
_In_ ULONG  AllocationAttributes,
_In_opt_ HANDLE  FileHandle,
_In_opt_ PFILE_OBJECT  File 
)

◆ MmMapViewOfSection()

NTSTATUS NTAPI MmMapViewOfSection ( _In_ PVOID  SectionObject,
_In_ PEPROCESS  Process,
_Outptr_result_bytebuffer_ *ViewSize _Pre_opt_valid_ PVOID BaseAddress,
_In_ ULONG_PTR  ZeroBits,
_In_ SIZE_T  CommitSize,
_Inout_opt_ PLARGE_INTEGER  SectionOffset,
_Inout_ PSIZE_T  ViewSize,
_In_range_(ViewShare, ViewUnmap) SECTION_INHERIT  InheritDisposition,
_In_ ULONG  AllocationType,
_In_ ULONG  Protect 
)

Definition at line 4031 of file section.c.

4042{
4043 PSECTION Section;
4046 BOOLEAN NotAtBase = FALSE;
4047 BOOLEAN IsAttached = FALSE;
4049
4051 {
4052 DPRINT("Mapping ARM3 section into %s\n", Process->ImageFileName);
4055 Process,
4057 ZeroBits,
4058 CommitSize,
4060 ViewSize,
4061 InheritDisposition,
4063 Protect);
4064 }
4065
4066 ASSERT(Process);
4067
4069 {
4071 }
4072
4074 {
4076 IsAttached = TRUE;
4077 }
4078
4079 Section = SectionObject;
4080 AddressSpace = &Process->Vm;
4081
4082 if (Section->u.Flags.NoChange)
4084
4086
4087 if (Section->u.Flags.Image)
4088 {
4089 ULONG i;
4090 ULONG NrSegments;
4091 ULONG_PTR ImageBase;
4092 SIZE_T ImageSize;
4093 PMM_IMAGE_SECTION_OBJECT ImageSectionObject;
4094 PMM_SECTION_SEGMENT SectionSegments;
4095
4096 ImageSectionObject = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment);
4097 SectionSegments = ImageSectionObject->Segments;
4098 NrSegments = ImageSectionObject->NrSegments;
4099
4100 ASSERT(ImageSectionObject->RefCount > 0);
4101
4102 ImageBase = (ULONG_PTR)*BaseAddress;
4103 if (ImageBase == 0)
4104 {
4105 ImageBase = (ULONG_PTR)ImageSectionObject->BasedAddress;
4106 }
4107
4108 ImageSize = 0;
4109 for (i = 0; i < NrSegments; i++)
4110 {
4111 ULONG_PTR MaxExtent;
4112 MaxExtent = (ULONG_PTR)(SectionSegments[i].Image.VirtualAddress +
4113 SectionSegments[i].Length.QuadPart);
4114 ImageSize = max(ImageSize, MaxExtent);
4115 }
4116
4117 ImageSectionObject->ImageInformation.ImageFileSize = (ULONG)ImageSize;
4118
4119 /* Check for an illegal base address */
4120 if (((ImageBase + ImageSize) > (ULONG_PTR)MM_HIGHEST_VAD_ADDRESS) ||
4121 ((ImageBase + ImageSize) < ImageSize))
4122 {
4123 ASSERT(*BaseAddress == NULL);
4124 ImageBase = ALIGN_DOWN_BY((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS - ImageSize,
4126 NotAtBase = TRUE;
4127 }
4128 else if (ImageBase != ALIGN_DOWN_BY(ImageBase, MM_VIRTMEM_GRANULARITY))
4129 {
4130 ASSERT(*BaseAddress == NULL);
4131 ImageBase = ALIGN_DOWN_BY(ImageBase, MM_VIRTMEM_GRANULARITY);
4132 NotAtBase = TRUE;
4133 }
4134
4135 /* Check there is enough space to map the section at that point. */
4136 if (!MmIsAddressRangeFree(AddressSpace, (PVOID)ImageBase, PAGE_ROUND_UP(ImageSize)))
4137 {
4138 /* Fail if the user requested a fixed base address. */
4139 if ((*BaseAddress) != NULL)
4140 {
4142 goto Exit;
4143 }
4144 /* Otherwise find a gap to map the image. */
4146 if (ImageBase == 0)
4147 {
4149 goto Exit;
4150 }
4151 /* Remember that we loaded image at a different base address */
4152 NotAtBase = TRUE;
4153 }
4154
4155 for (i = 0; i < NrSegments; i++)
4156 {
4157 PVOID SBaseAddress = (PVOID)
4158 ((char*)ImageBase + (ULONG_PTR)SectionSegments[i].Image.VirtualAddress);
4159 MmLockSectionSegment(&SectionSegments[i]);
4161 TRUE,
4162 &SectionSegments[i],
4163 &SBaseAddress,
4164 SectionSegments[i].Length.QuadPart,
4165 SectionSegments[i].Protection,
4166 0,
4167 0);
4168 MmUnlockSectionSegment(&SectionSegments[i]);
4169 if (!NT_SUCCESS(Status))
4170 {
4171 /* roll-back */
4172 while (i--)
4173 {
4174 SBaseAddress = ((char*)ImageBase + (ULONG_PTR)SectionSegments[i].Image.VirtualAddress);
4175 MmLockSectionSegment(&SectionSegments[i]);
4176 MmUnmapViewOfSegment(AddressSpace, SBaseAddress);
4177 MmUnlockSectionSegment(&SectionSegments[i]);
4178 }
4179
4180 goto Exit;
4181 }
4182 }
4183
4184 *BaseAddress = (PVOID)ImageBase;
4185 *ViewSize = ImageSize;
4186
4187 DPRINT("Mapped %p for section pointer %p\n", ImageSectionObject, ImageSectionObject->FileObject->SectionObjectPointer);
4188
4189 /* One more map */
4190 InterlockedIncrement(&ImageSectionObject->MapCount);
4191 }
4192 else
4193 {
4195 LONGLONG ViewOffset;
4196
4197 ASSERT(Segment->RefCount > 0);
4198
4199 /* check for write access */
4202 {
4204 goto Exit;
4205 }
4206 /* check for read access */
4209 {
4211 goto Exit;
4212 }
4213 /* check for execute access */
4216 {
4218 goto Exit;
4219 }
4220
4221 if (SectionOffset == NULL)
4222 {
4223 ViewOffset = 0;
4224 }
4225 else
4226 {
4227 SectionOffset->QuadPart &= ~(PAGE_SIZE - 1);
4228 ViewOffset = SectionOffset->QuadPart;
4229 }
4230
4231 /* Check if the offset and size would cause an overflow */
4232 if (((ULONG64)ViewOffset + *ViewSize) < (ULONG64)ViewOffset)
4233 {
4234 DPRINT1("Section offset overflows\n");
4236 goto Exit;
4237 }
4238
4239 /* Check if the offset and size are bigger than the section itself */
4240 if (((ULONG64)ViewOffset + *ViewSize) > (ULONG64)Section->SizeOfSection.QuadPart)
4241 {
4242 /* This is allowed for physical memory sections and kernel mode callers */
4243 if (!Section->u.Flags.PhysicalMemory || (ExGetPreviousMode() == UserMode))
4244 {
4245 DPRINT1("Section offset and size are larger than section\n");
4247 goto Exit;
4248 }
4249 }
4250
4251 if ((*ViewSize) == 0)
4252 {
4253 /* Calculate a view size and make sure it doesn't overflow a SIZE_T */
4254 ULONG64 CalculatedSize = Section->SizeOfSection.QuadPart - ViewOffset;
4255 if (CalculatedSize > SIZE_T_MAX)
4256 {
4257 DPRINT1("ViewSize is larger than SIZE_T_MAX\n");
4259 goto Exit;
4260 }
4261
4262 *ViewSize = (SIZE_T)CalculatedSize;
4263 }
4264 else if ((ExGetPreviousMode() == UserMode) &&
4265 (((*ViewSize)+ViewOffset) > Section->SizeOfSection.QuadPart) &&
4266 (!Section->u.Flags.Reserve))
4267 {
4268 /* Dubious */
4269 (*ViewSize) = MIN(Section->SizeOfSection.QuadPart - ViewOffset, SIZE_T_MAX - PAGE_SIZE);
4270 }
4271
4273
4276 FALSE,
4277 Segment,
4279 *ViewSize,
4280 Protect,
4281 ViewOffset,
4284 if (!NT_SUCCESS(Status))
4285 {
4286 goto Exit;
4287 }
4288 }
4289
4290 if (NotAtBase)
4292 else
4294
4295Exit:
4296
4298
4299 if (IsAttached)
4300 {
4302 }
4303
4304 return Status;
4305}
#define ALIGN_DOWN_BY(size, align)
#define InterlockedIncrement
Definition: armddk.h:53
#define MIN(x, y)
Definition: rdesktop.h:171
#define DPRINT1
Definition: precomp.h:8
#define SIZE_T_MAX
Definition: dhcpd.h:91
#define PAGE_READONLY
Definition: compat.h:138
#define ULONG_PTR
Definition: config.h:101
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define ExGetPreviousMode
Definition: ex.h:143
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
_Must_inspect_result_ _Outptr_ PVOID * SectionObject
Definition: fsrtlfuncs.h:860
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FORCEINLINE BOOLEAN MiIsRosSectionObject(IN PSECTION Section)
Definition: miarm.h:1105
#define ASSERT(a)
Definition: mode.c:44
unsigned __int64 ULONG64
Definition: imports.h:198
#define UserMode
Definition: asm.h:39
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
Definition: mmfuncs.h:407
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR ZeroBits
Definition: mmfuncs.h:405
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ ULONG AllocationType
Definition: mmfuncs.h:410
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID * BaseAddress
Definition: mmfuncs.h:404
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:408
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T CommitSize
Definition: mmfuncs.h:406
#define PAGE_ROUND_UP(x)
Definition: mmtypes.h:38
#define SEC_NO_CHANGE
Definition: mmtypes.h:95
#define MEM_TOP_DOWN
Definition: nt_native.h:1324
#define PAGE_WRITECOPY
Definition: nt_native.h:1308
#define PAGE_READWRITE
Definition: nt_native.h:1307
#define PAGE_EXECUTE_READ
Definition: nt_native.h:1310
#define PAGE_EXECUTE
Definition: nt_native.h:1309
#define PAGE_EXECUTE_WRITECOPY
Definition: nt_native.h:1312
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1311
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define MM_HIGHEST_VAD_ADDRESS
Definition: mm.h:46
FORCEINLINE VOID MmLockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1695
#define MmLockSectionSegment(x)
Definition: mm.h:1396
#define MM_VIRTMEM_GRANULARITY
Definition: mm.h:102
#define MmUnlockSectionSegment(x)
Definition: mm.h:1404
struct _MM_IMAGE_SECTION_OBJECT * PMM_IMAGE_SECTION_OBJECT
FORCEINLINE VOID MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1708
#define PAGE_FLAGS_VALID_FOR_SECTION
Definition: mm.h:139
BOOLEAN NTAPI MmIsAddressRangeFree(_In_ PMMSUPPORT AddressSpace, _In_ PVOID Address, _In_ ULONG_PTR Length)
Definition: marea.c:111
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1769
struct _MM_SECTION_SEGMENT * PMM_SECTION_SEGMENT
PVOID NTAPI MmFindGap(PMMSUPPORT AddressSpace, SIZE_T Length, ULONG_PTR Granularity, BOOLEAN TopDown)
#define STATUS_INVALID_VIEW_SIZE
Definition: ntstatus.h:361
#define STATUS_SECTION_PROTECTION
Definition: ntstatus.h:408
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:354
#define STATUS_INVALID_PAGE_PROTECTION
Definition: ntstatus.h:399
#define STATUS_IMAGE_NOT_AT_BASE
Definition: ntstatus.h:192
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:704
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756
NTSTATUS Status
Definition: section.c:5207
static NTSTATUS MmUnmapViewOfSegment(PMMSUPPORT AddressSpace, PVOID BaseAddress)
Definition: section.c:3566
NTSTATUS NTAPI MmMapViewOfArm3Section(_In_ PVOID SectionObject, _In_ PEPROCESS Process, _Outptr_result_bytebuffer_(*ViewSize) _When_(*ViewSize !=0, _Pre_opt_valid_) _When_(*ViewSize==0, _Pre_valid_) PVOID *BaseAddress, _In_ ULONG_PTR ZeroBits, _In_ SIZE_T CommitSize, _Inout_ PLARGE_INTEGER SectionOffset, _Inout_ PSIZE_T ViewSize, _In_range_(ViewShare, ViewUnmap) SECTION_INHERIT InheritDisposition, _In_ ULONG AllocationType, _In_ ULONG Protect)
Definition: section.c:2534
return FALSE
Definition: section.c:5371
static NTSTATUS MmMapViewOfSegment(PMMSUPPORT AddressSpace, BOOLEAN AsImage, PMM_SECTION_SEGMENT Segment, PVOID *BaseAddress, SIZE_T ViewSize, ULONG Protect, LONGLONG ViewOffset, ULONG AllocationType)
Definition: section.c:3403
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
static void Exit(void)
Definition: sock.c:1330
ULONG PhysicalMemory
Definition: mmtypes.h:473
ULONG NoChange
Definition: mmtypes.h:486
PMM_SECTION_SEGMENT Segments
Definition: mm.h:240
PFILE_OBJECT FileObject
Definition: mm.h:232
SECTION_IMAGE_INFORMATION ImageInformation
Definition: mm.h:237
struct _MM_SECTION_SEGMENT::@1950 Image
MMSECTION_FLAGS Flags
Definition: mmtypes.h:817
union _SECTION::@2867 u
PSEGMENT Segment
Definition: mmtypes.h:812
ULONG InitialPageProtection
Definition: mmtypes.h:819
LARGE_INTEGER SizeOfSection
Definition: mmtypes.h:813
#define max(a, b)
Definition: svc.c:63
int64_t LONGLONG
Definition: typedefs.h:68
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
static int Protect(const char **args)
Definition: vfdcmd.c:2132
_Inout_ PVOID Segment
Definition: exfuncs.h:1101
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2274
KAPC_STATE
Definition: ketypes.h:1711
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by _Function_class_(), _Success_(), ExpInitNls(), GDI_MapHandleTable(), IntMapDesktopView(), IntUserHeapCreate(), MapGlobalUserHeap(), MiLoadImageSection(), MmCreatePeb(), MmInitializeProcessAddressSpace(), NtMapViewOfSection(), NtSecureConnectPort(), and PspMapSystemDll().

◆ MmUnmapViewOfSection()

NTSTATUS NTAPI MmUnmapViewOfSection ( _In_ struct _EPROCESS Process,
_In_ PVOID  BaseAddress 
)

◆ NtAllocateUserPhysicalPages()

NTSTATUS NTAPI NtAllocateUserPhysicalPages ( _In_ HANDLE  ProcessHandle,
_Inout_ PULONG_PTR  NumberOfPages,
_Inout_ PULONG_PTR  UserPfnArray 
)

◆ NtAreMappedFilesTheSame()

NTSYSCALLAPI NTSTATUS NTAPI NtAreMappedFilesTheSame ( _In_ PVOID  File1MappedAsAnImage,
_In_ PVOID  File2MappedAsFile 
)

◆ NtCreatePagingFile()

NTSYSCALLAPI NTSTATUS NTAPI NtCreatePagingFile ( _In_ PUNICODE_STRING  FileName,
_In_ PLARGE_INTEGER  MinimumSize,
_In_ PLARGE_INTEGER  MaximumSize,
_In_ ULONG  Reserved 
)

Definition at line 366 of file pagefile.c.

371{
377 PMMPAGING_FILE PagingFile;
378 SIZE_T AllocMapSize;
379 ULONG Count;
381 UNICODE_STRING PageFileName;
382 LARGE_INTEGER SafeMinimumSize, SafeMaximumSize, AllocationSize;
383 FILE_FS_DEVICE_INFORMATION FsDeviceInfo;
385 PACL Dacl;
388
389 PAGED_CODE();
390
391 DPRINT("NtCreatePagingFile(FileName: '%wZ', MinimumSize: %I64d, MaximumSize: %I64d)\n",
392 FileName, MinimumSize->QuadPart, MaximumSize->QuadPart);
393
395 {
397 }
398
400
402 {
404 {
406 }
407
409 {
410 SafeMinimumSize = ProbeForReadLargeInteger(MinimumSize);
411 SafeMaximumSize = ProbeForReadLargeInteger(MaximumSize);
412 PageFileName = ProbeForReadUnicodeString(FileName);
413 }
415 {
416 /* Return the exception code */
418 }
419 _SEH2_END;
420 }
421 else
422 {
423 SafeMinimumSize = *MinimumSize;
424 SafeMaximumSize = *MaximumSize;
425 PageFileName = *FileName;
426 }
427
428 /*
429 * Pagefiles cannot be larger than the platform-specific memory addressable
430 * limits, and of course the minimum should be smaller than the maximum.
431 */
432 if (SafeMinimumSize.QuadPart < MINIMUM_PAGEFILE_SIZE ||
433 SafeMinimumSize.QuadPart > MAXIMUM_PAGEFILE_SIZE)
434 {
436 }
437 if (SafeMaximumSize.QuadPart < SafeMinimumSize.QuadPart ||
438 SafeMaximumSize.QuadPart > MAXIMUM_PAGEFILE_SIZE)
439 {
441 }
442
443 /* Validate the name length */
444 if ((PageFileName.Length == 0) ||
445 (PageFileName.Length > MAXIMUM_FILENAME_LENGTH))
446 {
448 }
449
450 /* Allocate a buffer to keep the name copy. Note that it is kept only
451 * for information purposes, so it gets allocated in the paged pool,
452 * even if it will be stored in the PagingFile structure, that is
453 * allocated from non-paged pool (see below). */
454 PageFileName.MaximumLength = PageFileName.Length;
456 if (Buffer == NULL)
457 {
459 }
460
461 /* Copy the name */
463 {
465 {
466 ProbeForRead(PageFileName.Buffer, PageFileName.Length, sizeof(WCHAR));
467 RtlCopyMemory(Buffer, PageFileName.Buffer, PageFileName.Length);
468 }
470 {
472
473 /* Return the exception code */
475 }
476 _SEH2_END;
477 }
478 else
479 {
480 RtlCopyMemory(Buffer, PageFileName.Buffer, PageFileName.Length);
481 }
482
483 /* Replace caller's buffer with ours */
484 PageFileName.Buffer = Buffer;
485
486 /* Create the security descriptor for the page file */
488 if (!NT_SUCCESS(Status))
489 {
491 return Status;
492 }
493
494 /* Create the DACL: we will only allow two SIDs */
495 Count = sizeof(ACL) + (sizeof(ACE) + RtlLengthSid(SeLocalSystemSid)) +
496 (sizeof(ACE) + RtlLengthSid(SeAliasAdminsSid));
498 if (Dacl == NULL)
499 {
502 }
503
504 /* Initialize the DACL */
506 if (!NT_SUCCESS(Status))
507 goto EarlyQuit;
508
509 /* Grant full access to admins */
511 if (!NT_SUCCESS(Status))
512 goto EarlyQuit;
513
514 /* Grant full access to SYSTEM */
516 if (!NT_SUCCESS(Status))
517 goto EarlyQuit;
518
519 /* Attach the DACL to the security descriptor */
521 if (!NT_SUCCESS(Status))
522 goto EarlyQuit;
523
525 &PageFileName,
527 NULL,
529
530 /* Make sure we can at least store a complete page:
531 * If we have 2048 BytesPerAllocationUnit (FAT16 < 128MB) there is
532 * a problem if the paging file is fragmented. Suppose the first cluster
533 * of the paging file is cluster 3042 but cluster 3043 is NOT part of the
534 * paging file but of another file. We can't write a complete page (4096
535 * bytes) to the physical location of cluster 3042 then. */
536 AllocationSize.QuadPart = SafeMinimumSize.QuadPart + PAGE_SIZE;
537
538 /* First, attempt to replace the page file, if existing */
542 &IoStatus,
548 NULL,
549 0,
551 NULL,
553 /* If we failed, relax a bit constraints, someone may be already holding the
554 * the file, so share write, don't attempt to replace and don't delete on close
555 * (basically, don't do anything conflicting).
556 * This can happen if the caller attempts to extend a page file.
557 */
558 if (!NT_SUCCESS(Status))
559 {
560 ULONG i;
561
565 &IoStatus,
569 FILE_OPEN,
571 NULL,
572 0,
574 NULL,
576 if (!NT_SUCCESS(Status))
577 goto EarlyQuit;
578
579 /* We opened it! Check we are that "someone" ;-)
580 * First, get the opened file object.
581 */
586 (PVOID*)&FileObject,
587 NULL);
588 if (!NT_SUCCESS(Status))
589 {
591 goto EarlyQuit;
592 }
593
594 /* Find if it matches a previous page file */
595 PagingFile = NULL;
596
598
599 for (i = 0; i < MmNumberOfPagingFiles; ++i)
600 {
601 if (MmPagingFile[i]->FileObject->SectionObjectPointer == FileObject->SectionObjectPointer)
602 {
603 /* Same object pointer: this is the matching page file */
604 PagingFile = MmPagingFile[i];
605 break;
606 }
607 }
608
609 /* If we didn't find the page file, fail */
610 if (PagingFile == NULL)
611 {
616 goto EarlyQuit;
617 }
618
619 /* Don't allow page file shrinking */
620 if (PagingFile->MinimumSize > (SafeMinimumSize.QuadPart >> PAGE_SHIFT))
621 {
626 goto EarlyQuit;
627 }
628
629 if ((SafeMaximumSize.QuadPart >> PAGE_SHIFT) < PagingFile->MaximumSize)
630 {
635 goto EarlyQuit;
636 }
637
638 /* FIXME: implement parameters checking and page file extension */
640
645 goto EarlyQuit;
646 }
647
648 if (!NT_SUCCESS(Status))
649 {
650EarlyQuit:
651 DPRINT1("Failed creating page file: %lx\n", Status);
654 return Status;
655 }
656
657 /* Set the security descriptor */
658 if (NT_SUCCESS(IoStatus.Status))
659 {
661 if (!NT_SUCCESS(Status))
662 {
666 return Status;
667 }
668 }
669
670 /* DACL is no longer needed, free it */
672
673 /* FIXME: To enable once page file management is moved to ARM3 */
674#if 0
675 /* Check we won't overflow commit limit with the page file */
677 {
681 }
682#endif
683
684 /* Set its end of file to minimal size */
685 Status = ZwSetInformationFile(FileHandle,
686 &IoStatus,
687 &SafeMinimumSize,
688 sizeof(LARGE_INTEGER),
690 if (!NT_SUCCESS(Status) || !NT_SUCCESS(IoStatus.Status))
691 {
694 return Status;
695 }
696
701 (PVOID*)&FileObject,
702 NULL);
703 if (!NT_SUCCESS(Status))
704 {
707 return Status;
708 }
709
710 /* Only allow page file on a few device types */
716 {
720 return Status;
721 }
722
723 /* Deny page file creation on a floppy disk */
724 FsDeviceInfo.Characteristics = 0;
726 sizeof(FsDeviceInfo), &FsDeviceInfo, &Count);
728 {
733 }
734
735 /*
736 * Missing validation steps TODO:
737 * (see https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/mm/modwrite/create.htm )
738 *
739 * - Verify that no file system driver or any filter driver has done file
740 * I/O while opening the file.
741 * Verify that nothing of the paging file is yet in memory. Specifically,
742 * the file object must either have no SectionObjectPointer or the latter
743 * must have neither a DataSectionObject nor an ImageSectionObject.
744 * Otherwise, we should fail, returning STATUS_INCOMPATIBLE_FILE_MAP.
745 *
746 * - Inform all the applicable drivers to prepare for the possibility of
747 * paging I/O. Much of the point to paging I/O is to resolve page faults.
748 * Especially important is that drivers that handle paging I/O do not
749 * cause more page faults. All the code and data that each driver might
750 * ever use for access to the paging file must be locked into physical
751 * memory. This can’t be left until paging I/O actually occurs.
752 * It must be done in advance.
753 */
754
755 PagingFile = ExAllocatePoolZero(NonPagedPool, sizeof(*PagingFile), TAG_MM);
756 if (PagingFile == NULL)
757 {
762 }
763
764 PagingFile->FileHandle = FileHandle;
765 PagingFile->FileObject = FileObject;
766 PagingFile->Size = (SafeMinimumSize.QuadPart >> PAGE_SHIFT);
767 PagingFile->MinimumSize = PagingFile->Size;
768 PagingFile->MaximumSize = (SafeMaximumSize.QuadPart >> PAGE_SHIFT);
769 /* First page is never used: it's the header
770 * TODO: write it
771 */
772 PagingFile->FreeSpace = PagingFile->Size - 1;
773 PagingFile->CurrentUsage = 0;
774 PagingFile->PageFileName = PageFileName;
775 ASSERT(PagingFile->Size == PagingFile->FreeSpace + PagingFile->CurrentUsage + 1);
776
777 AllocMapSize = sizeof(RTL_BITMAP) + (((PagingFile->MaximumSize + 31) / 32) * sizeof(ULONG));
779 AllocMapSize,
780 TAG_MM);
781 if (PagingFile->Bitmap == NULL)
782 {
783 ExFreePoolWithTag(PagingFile, TAG_MM);
788 }
789
790 RtlInitializeBitMap(PagingFile->Bitmap,
791 (PULONG)(PagingFile->Bitmap + 1),
792 (ULONG)(PagingFile->MaximumSize));
793 RtlClearAllBits(PagingFile->Bitmap);
794
795 /* Insert the new paging file information into the list */
797 /* Ensure the corresponding slot is empty yet */
803
805
807 {
809 }
810
811 return STATUS_SUCCESS;
812}
SIZE_T MmTotalCommitLimitMaximum
Definition: mminit.c:361
#define PAGED_CODE()
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
_In_ PVOID _In_ ULONG _Out_ PVOID _In_ ULONG _Inout_ PULONG _In_ KPROCESSOR_MODE PreviousMode
#define FILE_DELETE_ON_CLOSE
Definition: constants.h:494
#define MAXIMUM_PAGEFILE_SIZE
Definition: pagefile.c:76
#define MAX_PAGING_FILES
Definition: pagefile.c:23
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
Definition: bufpool.h:45
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define RtlInitializeBitMap
Definition: dbgbitmap.h:326
#define RtlClearAllBits
Definition: dbgbitmap.h:329
#define RTL_BITMAP
Definition: dbgbitmap.h:323
#define DEVICE_TYPE
Definition: guid.c:10
#define FILE_SHARE_READ
Definition: compat.h:136
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define MAXIMUM_FILENAME_LENGTH
Definition: env_spec_w32.h:41
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define DO_SYSTEM_BOOT_PARTITION
Definition: env_spec_w32.h:400
#define NonPagedPool
Definition: env_spec_w32.h:307
#define PagedPool
Definition: env_spec_w32.h:308
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:323
struct _FileName FileName
Definition: fatprocs.h:897
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
@ FileEndOfFileInformation
Definition: from_kernel.h:81
#define FILE_NO_COMPRESSION
Definition: from_kernel.h:43
#define FILE_OPEN
Definition: from_kernel.h:54
@ FileFsDeviceInformation
Definition: from_kernel.h:222
#define FILE_NO_INTERMEDIATE_BUFFERING
Definition: from_kernel.h:28
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
NTSTATUS NTAPI IoQueryVolumeInformation(IN PFILE_OBJECT FileObject, IN FS_INFORMATION_CLASS FsInformationClass, IN ULONG Length, OUT PVOID FsInformation, OUT PULONG ReturnedLength)
Definition: iofunc.c:1294
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
DeviceType
Definition: mmdrv.h:42
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
static PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
struct _ACL ACL
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER MaximumSize
Definition: mmfuncs.h:362
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1625
NTSYSAPI NTSTATUS NTAPI RtlCreateAcl(PACL Acl, ULONG AclSize, ULONG AclRevision)
NTSYSAPI ULONG NTAPI RtlLengthSid(IN PSID Sid)
Definition: sid.c:150
NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor(_Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ ULONG Revision)
int Count
Definition: noreturn.cpp:7
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define WRITE_DAC
Definition: nt_native.h:59
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
BOOLEAN NTAPI IoInitializeCrashDump(IN HANDLE PageFileHandle)
Definition: iomgr.c:650
PSID SeLocalSystemSid
Definition: sid.c:38
PSID SeAliasAdminsSid
Definition: sid.c:41
const LUID SeCreatePagefilePrivilege
Definition: priv.c:34
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1549
NTSTATUS NTAPI IoCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG Disposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength, IN CREATE_FILE_TYPE CreateFileType, IN PVOID ExtraCreateParameters OPTIONAL, IN ULONG Options)
Definition: file.c:3008
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:57
KGUARDED_MUTEX MmPageFileCreationLock
Definition: pagefile.c:60
static BOOLEAN MmSwapSpaceMessage
Definition: pagefile.c:103
PFN_COUNT MiFreeSwapPages
Definition: pagefile.c:66
static BOOLEAN MmSystemPageFileLocated
Definition: pagefile.c:105
#define MINIMUM_PAGEFILE_SIZE
Definition: pagefile.c:18
ULONG MmNumberOfPagingFiles
Definition: pagefile.c:63
BOOLEAN NTAPI SeSinglePrivilegeCheck(_In_ LUID PrivilegeValue, _In_ KPROCESSOR_MODE PreviousMode)
Checks if a single privilege is present in the context of the calling thread.
Definition: priv.c:744
#define STATUS_FLOPPY_VOLUME
Definition: ntstatus.h:686
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:570
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:571
#define STATUS_TOO_MANY_PAGING_FILES
Definition: ntstatus.h:481
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
short WCHAR
Definition: pedump.c:58
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:53
#define FILE_DEVICE_NETWORK_FILE_SYSTEM
Definition: winioctl.h:65
#define FILE_DEVICE_DFS_FILE_SYSTEM
Definition: winioctl.h:98
#define FILE_DEVICE_DFS_VOLUME
Definition: winioctl.h:99
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:207
#define ProbeForReadUnicodeString(Ptr)
Definition: probe.h:77
#define ProbeForReadLargeInteger(Ptr)
Definition: probe.h:75
#define STATUS_NOT_FOUND
Definition: shellext.h:72
Definition: rtltypes.h:987
PFN_NUMBER MinimumSize
Definition: mm.h:522
UNICODE_STRING PageFileName
Definition: mm.h:526
PFN_NUMBER Size
Definition: mm.h:520
PRTL_BITMAP Bitmap
Definition: mm.h:527
PFN_NUMBER CurrentUsage
Definition: mm.h:524
PFN_NUMBER FreeSpace
Definition: mm.h:523
PFILE_OBJECT FileObject
Definition: mm.h:525
PFN_NUMBER MaximumSize
Definition: mm.h:521
HANDLE FileHandle
Definition: mm.h:528
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define TAG_DACL
Definition: tag.h:168
#define TAG_MM
Definition: tag.h:113
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSYSAPI NTSTATUS WINAPI RtlAddAccessAllowedAce(PACL, DWORD, DWORD, PSID)
NTSYSAPI NTSTATUS WINAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR, BOOLEAN, PACL, BOOLEAN)
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:191
#define IO_NO_PARAMETER_CHECKING
Definition: iotypes.h:541
* PFILE_OBJECT
Definition: iotypes.h:1998
@ CreateFileTypeNone
Definition: iotypes.h:535
#define IO_OPEN_PAGING_FILE
Definition: iotypes.h:7354
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
#define ObDereferenceObject
Definition: obfuncs.h:203
#define DACL_SECURITY_INFORMATION
Definition: setypes.h:125
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
#define ACL_REVISION
Definition: setypes.h:39

Referenced by SmpCreatePagingFile().

◆ NtCreateSection()

_Must_inspect_result_ __kernel_entry NTSYSCALLAPI NTSTATUS NTAPI NtCreateSection ( _Out_ PHANDLE  SectionHandle,
_In_ ACCESS_MASK  DesiredAccess,
_In_opt_ POBJECT_ATTRIBUTES  ObjectAttributes,
_In_opt_ PLARGE_INTEGER  MaximumSize,
_In_ ULONG  SectionPageProtection,
_In_ ULONG  AllocationAttributes,
_In_opt_ HANDLE  FileHandle 
)

◆ NtExtendSection()

NTSYSCALLAPI NTSTATUS NTAPI NtExtendSection ( _In_ HANDLE  SectionHandle,
_In_ PLARGE_INTEGER  NewMaximumSize 
)

◆ NtFlushInstructionCache()

NTSYSCALLAPI NTSTATUS NTAPI NtFlushInstructionCache ( _In_ HANDLE  ProcessHandle,
_In_ PVOID  BaseAddress,
_In_ SIZE_T  NumberOfBytesToFlush 
)

◆ NtFlushVirtualMemory()

NTSYSCALLAPI NTSTATUS NTAPI NtFlushVirtualMemory ( _In_ HANDLE  ProcessHandle,
_Inout_ PVOID BaseAddress,
_Inout_ PSIZE_T  RegionSize,
_Out_ PIO_STATUS_BLOCK  IoStatus 
)

◆ NtFreeUserPhysicalPages()

NTSTATUS NTAPI NtFreeUserPhysicalPages ( _In_ HANDLE  ProcessHandle,
_Inout_ PULONG_PTR  NumberOfPages,
_Inout_ PULONG_PTR  UserPfnArray 
)

◆ NtGetWriteWatch()

NTSTATUS NTAPI NtGetWriteWatch ( _In_ HANDLE  ProcessHandle,
_In_ ULONG  Flags,
_In_ PVOID  BaseAddress,
_In_ SIZE_T  RegionSize,
_In_ PVOID UserAddressArray,
_Out_ PULONG_PTR  EntriesInUserAddressArray,
_Out_ PULONG  Granularity 
)

◆ NtLockVirtualMemory()

NTSYSCALLAPI NTSTATUS NTAPI NtLockVirtualMemory ( _In_ HANDLE  ProcessHandle,
_Inout_ PVOID BaseAddress,
_Inout_ PSIZE_T  NumberOfBytesToLock,
_In_ ULONG  MapType 
)

◆ NtMapUserPhysicalPages()

NTSTATUS NTAPI NtMapUserPhysicalPages ( _In_ PVOID  VirtualAddresses,
_In_ ULONG_PTR  NumberOfPages,
_Inout_ PULONG_PTR  UserPfnArray 
)

◆ NtMapUserPhysicalPagesScatter()

NTSTATUS NTAPI NtMapUserPhysicalPagesScatter ( _In_ PVOID VirtualAddresses,
_In_ ULONG_PTR  NumberOfPages,
_Inout_ PULONG_PTR  UserPfnArray 
)

◆ NtMapViewOfSection()

NTSYSCALLAPI NTSTATUS NTAPI NtMapViewOfSection ( _In_ HANDLE  SectionHandle,
_In_ HANDLE  ProcessHandle,
_Outptr_result_bytebuffer_ *ViewSize _Pre_valid_ PVOID BaseAddress,
_In_ ULONG_PTR  ZeroBits,
_In_ SIZE_T  CommitSize,
_Inout_opt_ PLARGE_INTEGER  SectionOffset,
_Inout_ PSIZE_T  ViewSize,
_In_range_(ViewShare, ViewUnmap) SECTION_INHERIT  InheritDisposition,
_In_ ULONG  AllocationType,
_In_ ULONG  Win32Protect 
)

Definition at line 3264 of file section.c.

3275{
3276 PVOID SafeBaseAddress;
3277 LARGE_INTEGER SafeSectionOffset;
3278 SIZE_T SafeViewSize;
3279 PSECTION Section;
3283 ULONG ProtectionMask;
3285#if defined(_M_IX86) || defined(_M_AMD64)
3286 static const ULONG ValidAllocationType = (MEM_TOP_DOWN | MEM_LARGE_PAGES |
3288#else
3289 static const ULONG ValidAllocationType = (MEM_TOP_DOWN | MEM_LARGE_PAGES |
3291#endif
3292
3293 /* Check for invalid inherit disposition */
3294 if ((InheritDisposition > ViewUnmap) || (InheritDisposition < ViewShare))
3295 {
3296 DPRINT1("Invalid inherit disposition\n");
3298 }
3299
3300 /* Allow only valid allocation types */
3301 if (AllocationType & ~ValidAllocationType)
3302 {
3303 DPRINT1("Invalid allocation type\n");
3305 }
3306
3307 /* Convert the protection mask, and validate it */
3308 ProtectionMask = MiMakeProtectionMask(Win32Protect);
3309 if (ProtectionMask == MM_INVALID_PROTECTION)
3310 {
3311 DPRINT1("Invalid page protection\n");
3313 }
3314
3315 /* Now convert the protection mask into desired section access mask */
3316 DesiredAccess = MmMakeSectionAccess[ProtectionMask & 0x7];
3317
3318 /* Assume no section offset */
3319 SafeSectionOffset.QuadPart = 0;
3320
3321 /* Enter SEH */
3322 _SEH2_TRY
3323 {
3324 /* Check for unsafe parameters */
3325 if (PreviousMode != KernelMode)
3326 {
3327 /* Probe the parameters */
3330 }
3331
3332 /* Check if a section offset was given */
3333 if (SectionOffset)
3334 {
3335 /* Check for unsafe parameters and capture section offset */
3337 SafeSectionOffset = *SectionOffset;
3338 }
3339
3340 /* Capture the other parameters */
3341 SafeBaseAddress = *BaseAddress;
3342 SafeViewSize = *ViewSize;
3343 }
3345 {
3346 /* Return the exception code */
3348 }
3349 _SEH2_END;
3350
3351 /* Check for kernel-mode address */
3352 if (SafeBaseAddress > MM_HIGHEST_VAD_ADDRESS)
3353 {
3354 DPRINT1("Kernel base not allowed\n");
3356 }
3357
3358 /* Check for range entering kernel-mode */
3359 if (((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS - (ULONG_PTR)SafeBaseAddress) < SafeViewSize)
3360 {
3361 DPRINT1("Overflowing into kernel base not allowed\n");
3363 }
3364
3365 /* Check for invalid zero bits */
3366 if (ZeroBits)
3367 {
3369 {
3370 DPRINT1("Invalid zero bits\n");
3372 }
3373
3374 if ((((ULONG_PTR)SafeBaseAddress << ZeroBits) >> ZeroBits) != (ULONG_PTR)SafeBaseAddress)
3375 {
3376 DPRINT1("Invalid zero bits\n");
3378 }
3379
3380 if (((((ULONG_PTR)SafeBaseAddress + SafeViewSize) << ZeroBits) >> ZeroBits) != ((ULONG_PTR)SafeBaseAddress + SafeViewSize))
3381 {
3382 DPRINT1("Invalid zero bits\n");
3384 }
3385 }
3386
3387 /* Reference the process */
3392 (PVOID*)&Process,
3393 NULL);
3394 if (!NT_SUCCESS(Status)) return Status;
3395
3396 /* Reference the section */
3397 Status = ObReferenceObjectByHandle(SectionHandle,
3401 (PVOID*)&Section,
3402 NULL);
3403 if (!NT_SUCCESS(Status))
3404 {
3406 return Status;
3407 }
3408
3409 if (Section->u.Flags.PhysicalMemory)
3410 {
3411 if (PreviousMode == UserMode &&
3412 SafeSectionOffset.QuadPart + SafeViewSize > MmHighestPhysicalPage << PAGE_SHIFT)
3413 {
3414 DPRINT1("Denying map past highest physical page.\n");
3415 ObDereferenceObject(Section);
3418 }
3419 }
3420 else if (!(AllocationType & MEM_DOS_LIM))
3421 {
3422 /* Check for non-allocation-granularity-aligned BaseAddress */
3423 if (SafeBaseAddress != ALIGN_DOWN_POINTER_BY(SafeBaseAddress, MM_VIRTMEM_GRANULARITY))
3424 {
3425 DPRINT("BaseAddress is not at 64-kilobyte address boundary.\n");
3426 ObDereferenceObject(Section);
3429 }
3430
3431 /* Do the same for the section offset */
3432 if (SafeSectionOffset.LowPart != ALIGN_DOWN_BY(SafeSectionOffset.LowPart, MM_VIRTMEM_GRANULARITY))
3433 {
3434 DPRINT("SectionOffset is not at 64-kilobyte address boundary.\n");
3435 ObDereferenceObject(Section);
3438 }
3439 }
3440
3441 /* Now do the actual mapping */
3442 Status = MmMapViewOfSection(Section,
3443 Process,
3444 &SafeBaseAddress,
3445 ZeroBits,
3446 CommitSize,
3447 &SafeSectionOffset,
3448 &SafeViewSize,
3449 InheritDisposition,
3451 Win32Protect);
3452
3453 /* Return data only on success */
3454 if (NT_SUCCESS(Status))
3455 {
3456 /* Check if this is an image for the current process */
3457 if ((Section->u.Flags.Image) &&
3460 {
3461 /* Notify the debugger */
3462 DbgkMapViewOfSection(Section,
3463 SafeBaseAddress,
3464 SafeSectionOffset.LowPart,
3465 SafeViewSize);
3466 }
3467
3468 /* Enter SEH */
3469 _SEH2_TRY
3470 {
3471 /* Return parameters to user */
3472 *BaseAddress = SafeBaseAddress;
3473 *ViewSize = SafeViewSize;
3474 if (SectionOffset) *SectionOffset = SafeSectionOffset;
3475 }
3477 {
3478 /* Nothing to do */
3479 }
3480 _SEH2_END;
3481 }
3482
3483 /* Dereference all objects and return status */
3484 ObDereferenceObject(Section);
3486 return Status;
3487}
ACCESS_MASK MmMakeSectionAccess[8]
Definition: section.c:20
ULONG NTAPI MiMakeProtectionMask(IN ULONG Protect)
Definition: section.c:140
VOID NTAPI DbgkMapViewOfSection(IN PVOID Section, IN PVOID BaseAddress, IN ULONG SectionOffset, IN ULONG_PTR ViewSize)
Definition: dbgkutil.c:380
#define PROCESS_VM_OPERATION
Definition: pstypes.h:156
PFN_NUMBER MmHighestPhysicalPage
Definition: meminit.c:31
#define MM_INVALID_PROTECTION
Definition: miarm.h:67
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ ULONG _In_ ULONG Win32Protect
Definition: mmfuncs.h:412
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
#define MEM_DOS_LIM
Definition: mmtypes.h:90
ULONG ACCESS_MASK
Definition: nt_native.h:40
@ ViewUnmap
Definition: nt_native.h:1282
@ ViewShare
Definition: nt_native.h:1281
#define MEM_RESERVE
Definition: nt_native.h:1317
#define MEM_LARGE_PAGES
Definition: nt_native.h:1325
#define MI_MAX_ZERO_BITS
Definition: mm.h:83
POBJECT_TYPE PsProcessType
Definition: process.c:20
#define STATUS_MAPPED_ALIGNMENT
Definition: ntstatus.h:798
#define STATUS_INVALID_PARAMETER_9
Definition: ntstatus.h:577
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:572
#define STATUS_INVALID_PARAMETER_6
Definition: ntstatus.h:574
#define STATUS_INVALID_PARAMETER_8
Definition: ntstatus.h:576
#define ProbeForWriteLargeInteger(Ptr)
Definition: probe.h:46
#define ProbeForWritePointer(Ptr)
Definition: probe.h:42
#define ProbeForWriteSize_t(Ptr)
Definition: probe.h:45
POBJECT_TYPE MmSectionObjectType
Definition: section.c:196
NTSTATUS NTAPI MmMapViewOfSection(_In_ PVOID SectionObject, _In_ PEPROCESS Process, _Outptr_result_bytebuffer_(*ViewSize) _Pre_opt_valid_ PVOID *BaseAddress, _In_ ULONG_PTR ZeroBits, _In_ SIZE_T CommitSize, _Inout_opt_ PLARGE_INTEGER SectionOffset, _Inout_ PSIZE_T ViewSize, _In_range_(ViewShare, ViewUnmap) SECTION_INHERIT InheritDisposition, _In_ ULONG AllocationType, _In_ ULONG Protect)
Definition: section.c:4031
#define ALIGN_DOWN_POINTER_BY(ptr, align)
Definition: umtypes.h:82
ULONG LowPart
Definition: typedefs.h:106
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2664

Referenced by BasepLoadLibraryAsDatafile(), CabinetExtractFile(), CabinetOpen(), CON_API(), CsrSrvAttachSharedSection(), CsrSrvCreateSharedSection(), get_manifest_in_manifest_file(), get_manifest_in_pe_file(), GRAPHICS_BUFFER_Initialize(), GuiApplyUserSettings(), GuiConsoleShowConsoleProperties(), Heap32ListFirst(), Heap32ListNext(), InitFunctionPtrs(), LdrpMapDll(), LdrVerifyImageMatchesChecksum(), MapFile(), MapViewOfFileEx(), Module32FirstW(), Module32NextW(), Process32FirstW(), Process32NextW(), SdbpOpenMemMappedFile(), SetupCopyFile(), START_TEST(), Test_BasedSection(), test_cross_process_notifications(), Test_ImageSection(), Test_ImageSection2(), test_notifications(), test_NtMapViewOfSection(), Test_PageFileSection(), test_query_image_information(), test_query_region_information(), Test_RawSize(), Test_SectionContents(), Test_Truncate(), TestPhysicalMemorySection(), TH32CreateSnapshotSectionInitialize(), Thread32First(), and Thread32Next().

◆ NtOpenSection()

NTSYSCALLAPI NTSTATUS NTAPI NtOpenSection ( _Out_ PHANDLE  SectionHandle,
_In_ ACCESS_MASK  DesiredAccess,
_In_ POBJECT_ATTRIBUTES  ObjectAttributes 
)

◆ NtProtectVirtualMemory()

NTSYSCALLAPI NTSTATUS NTAPI NtProtectVirtualMemory ( _In_ HANDLE  ProcessHandle,
_In_ PVOID BaseAddress,
_In_ SIZE_T NumberOfBytesToProtect,
_In_ ULONG  NewAccessProtection,
_Out_ PULONG  OldAccessProtection 
)

◆ NtQuerySection()

NTSYSCALLAPI NTSTATUS NTAPI NtQuerySection ( _In_ HANDLE  SectionHandle,
_In_ SECTION_INFORMATION_CLASS  SectionInformationClass,
_Out_ PVOID  SectionInformation,
_In_ SIZE_T  Length,
_Out_ PSIZE_T  ResultLength 
)

◆ NtQueryVirtualMemory()

NTSYSCALLAPI NTSTATUS NTAPI NtQueryVirtualMemory ( _In_ HANDLE  ProcessHandle,
_In_ PVOID  Address,
_In_ MEMORY_INFORMATION_CLASS  VirtualMemoryInformationClass,
_Out_ PVOID  VirtualMemoryInformation,
_In_ SIZE_T  Length,
_Out_opt_ PSIZE_T  ResultLength 
)

◆ NtReadVirtualMemory()

NTSYSCALLAPI NTSTATUS NTAPI NtReadVirtualMemory ( _In_ HANDLE  ProcessHandle,
_In_ PVOID  BaseAddress,
_Out_ PVOID  Buffer,
_In_ SIZE_T  NumberOfBytesToRead,
_Out_opt_ PSIZE_T  NumberOfBytesRead 
)

◆ NtResetWriteWatch()

NTSTATUS NTAPI NtResetWriteWatch ( _In_ HANDLE  ProcessHandle,
_In_ PVOID  BaseAddress,
_In_ SIZE_T  RegionSize 
)

◆ NtUnlockVirtualMemory()

NTSYSCALLAPI NTSTATUS NTAPI NtUnlockVirtualMemory ( _In_ HANDLE  ProcessHandle,
_Inout_ PVOID BaseAddress,
_Inout_ PSIZE_T  NumberOfBytesToUnlock,
_In_ ULONG  MapType 
)

◆ NtUnmapViewOfSection()

NTSYSCALLAPI NTSTATUS NTAPI NtUnmapViewOfSection ( _In_ HANDLE  ProcessHandle,
_In_ PVOID  BaseAddress 
)

◆ NtWriteVirtualMemory()

NTSYSCALLAPI NTSTATUS NTAPI NtWriteVirtualMemory ( _In_ HANDLE  ProcessHandle,
_In_ PVOID  BaseAddress,
_In_ PVOID  Buffer,
_In_ SIZE_T  NumberOfBytesToWrite,
_Out_opt_ PSIZE_T  NumberOfBytesWritten 
)

◆ ZwAreMappedFilesTheSame()

NTSYSAPI NTSTATUS NTAPI ZwAreMappedFilesTheSame ( _In_ PVOID  File1MappedAsAnImage,
_In_ PVOID  File2MappedAsFile 
)

Referenced by LdrpCheckForLoadedDll().

◆ ZwCreatePagingFile()

NTSYSAPI NTSTATUS NTAPI ZwCreatePagingFile ( _In_ PUNICODE_STRING  FileName,
_In_ PLARGE_INTEGER  MinimumSize,
_In_ PLARGE_INTEGER  MaximumSize,
_In_ ULONG  Reserved 
)

◆ ZwExtendSection()

NTSYSAPI NTSTATUS NTAPI ZwExtendSection ( _In_ HANDLE  SectionHandle,
_In_ PLARGE_INTEGER  NewMaximumSize 
)

◆ ZwLockVirtualMemory()

NTSYSAPI NTSTATUS NTAPI ZwLockVirtualMemory ( _In_ HANDLE  ProcessHandle,
_Inout_ PVOID BaseAddress,
_Inout_ PSIZE_T  NumberOfBytesToLock,
_In_ ULONG  MapType 
)

◆ ZwOpenSection()

◆ ZwProtectVirtualMemory()

NTSYSAPI NTSTATUS NTAPI ZwProtectVirtualMemory ( _In_ HANDLE  ProcessHandle,
_In_ PVOID BaseAddress,
_In_ SIZE_T NumberOfBytesToProtect,
_In_ ULONG  NewAccessProtection,
_Out_ PULONG  OldAccessProtection 
)

◆ ZwQuerySection()

NTSYSAPI NTSTATUS NTAPI ZwQuerySection ( _In_ HANDLE  SectionHandle,
_In_ SECTION_INFORMATION_CLASS  SectionInformationClass,
_Out_ PVOID  SectionInformation,
_In_ SIZE_T  Length,
_Out_opt_ PSIZE_T  ResultLength 
)

◆ ZwQueryVirtualMemory()

NTSYSAPI NTSTATUS NTAPI ZwQueryVirtualMemory ( _In_ HANDLE  ProcessHandle,
_In_ PVOID  Address,
_In_ MEMORY_INFORMATION_CLASS  VirtualMemoryInformationClass,
_Out_ PVOID  VirtualMemoryInformation,
_In_ SIZE_T  Length,
_Out_opt_ PSIZE_T  ResultLength 
)

◆ ZwReadVirtualMemory()

NTSYSAPI NTSTATUS NTAPI ZwReadVirtualMemory ( _In_ HANDLE  ProcessHandle,
_In_ PVOID  BaseAddress,
_Out_ PVOID  Buffer,
_In_ SIZE_T  NumberOfBytesToRead,
_Out_opt_ PSIZE_T  NumberOfBytesRead 
)

◆ ZwUnlockVirtualMemory()

NTSYSAPI NTSTATUS NTAPI ZwUnlockVirtualMemory ( _In_ HANDLE  ProcessHandle,
_Inout_ PVOID BaseAddress,
_Inout_ PSIZE_T  NumberOfBytesToUnlock,
_In_ ULONG  MapType 
)

◆ ZwWriteVirtualMemory()

NTSYSAPI NTSTATUS NTAPI ZwWriteVirtualMemory ( _In_ HANDLE  ProcessHandle,
_In_ PVOID  BaseAddress,
_In_ PVOID  Buffer,
_In_ SIZE_T  NumberOfBytesToWrite,
_Out_opt_ PSIZE_T  NumberOfBytesWritten 
)

Variable Documentation

◆ AllocationAttributes

◆ AllocationType

◆ BaseAddress

_Inout_ PVOID * BaseAddress

Definition at line 404 of file mmfuncs.h.

Referenced by $endif(), __RtlImageDirectoryEntryToData(), __RtlImageRvaToVa(), _IRQL_requires_max_(), AdvancedErrorChecks(), AtaReqCopySatlBuffer(), AtaReqMapBuffer(), AtaReqSendRequest(), AVrfpIsVerifierProviderDll(), AVrfpLdrGetProcedureAddress(), BehaviorChecks(), BiosDiskService(), BiosMiscService(), BiosMouseEnable(), CalcCheckSum(), CcPreparePinWrite(), CcpUnpinData(), CheckAdjacentVADs(), CheckAlignment(), CheckSize(), CheckSomeDefaultAddresses(), CheckSumMappedFile(), ClasspGetMaxUsableBufferLengthFromOffset(), CmpInitializeMachineDependentConfiguration(), CpuExceptionFilter(), CreateProcessInternalW(), DbgkMapViewOfSection(), DbgkUnMapViewOfSection(), DECLARE_INTERFACE_(), DiskBios32Post(), DosBIOSInitialize(), DosClonePsp(), DosCreatePsp(), DosInt21h(), DosLoadExecutableInternal(), DosMouseCleanup(), DosMouseDisable(), DosMouseEnable(), DosMouseInitialize(), DosTerminateProcess(), ExLockUserBuffer(), ExpComputePartialHashForAddress(), FAT12CountAvailableClusters(), FAT12FindAndMarkAvailableCluster(), FAT12GetNextCluster(), FAT12WriteCluster(), FAT16CountAvailableClusters(), FAT16FindAndMarkAvailableCluster(), FAT16GetNextCluster(), FAT16WriteCluster(), FAT32CountAvailableClusters(), FAT32FindAndMarkAvailableCluster(), FAT32GetNextCluster(), FAT32WriteCluster(), FileSectionViewPermissionCheck(), find_entry(), FlushViewOfFile(), GetEbdaLocation(), GetProcessVersion(), HalpMapPhysicalMemory64Vista(), IMAGEHLP_RecalculateChecksum(), InitializeBiosInt32(), InitializeModeTable(), IntAgpCommitVirtual(), IntAgpFreeVirtual(), IntVideoPortImageDirectoryEntryToData(), IopLoadDriver(), is_data_file_module(), KdpSysReadControlSpace(), KdpSysWriteControlSpace(), Ke386SetGdtEntryBase(), KeSweepICache(), LdrAccessResource(), LdrAddRefDll(), LdrDisableThreadCalloutsForDll(), LdrFindResource_U(), LdrFindResourceDirectory_U(), LdrGetProcedureAddress(), LdrInitShimEngineDynamic(), LdrLoadDll(), LdrpAccessResource(), LdrpAllocateDataTableEntry(), LdrpCallInitRoutine(), LdrpFetchAddressOfSecurityCookie(), LdrpGetProcedureAddress(), LdrpLoadDll(), LdrRelocateImage(), LdrRelocateImageWithBias(), LdrUnloadDll(), LdrVerifyMappedImageMatchesChecksum(), LlbAllocateMemoryEntry(), LoadModule(), LoadOle32Export(), main(), MapFile(), MapFileAndCheckSumA(), MapFileAndCheckSumW(), MemCleanup(), MemInitialize(), MiAddHalIoMappings(), MiAllocateContiguousMemory(), MiBuildPfnDatabaseFromPages(), MiCacheImageSymbols(), MiCheckForContiguousMemory(), MiCheckVadsForLockOperation(), MiCreateArm3StaticMemoryArea(), MiCreatePebOrTeb(), MiFindContiguousMemory(), MiFreeContiguousMemory(), MiInsertVadEx(), MiLockVirtualMemory(), MiMapLockedPagesInUserSpace(), MiMapViewOfDataSection(), MiProtectVirtualMemory(), MiQueryMemoryBasicInformation(), MiQueryMemorySectionName(), MiRemoveMappedPtes(), MiRosCleanupMemoryArea(), MiRosUnmapViewOfSection(), MiUnlockVirtualMemory(), MiUnmapLockedPagesInUserSpace(), MiUnmapViewOfSection(), MmAllocateNonCachedMemory(), MmAlterRegion(), MmAlterViewAttributes(), MmCreateKernelStack(), MmCreateMemoryArea(), MmFindRegion(), MmFreeContiguousMemory(), MmFreeContiguousMemorySpecifyCache(), MmFreeNonCachedMemory(), MmMapIoSpace(), MmMapLockedPagesSpecifyCache(), MmMapViewOfArm3Section(), MmMapViewOfSection(), MmMapViewOfSegment(), MmProtectSectionView(), MmUnloadSystemImage(), MmUnmapIoSpace(), MmUnmapLockedPages(), MmUnmapReservedMapping(), MmUnmapVideoDisplay(), MmUnmapViewOfSection(), MmUnmapViewOfSegment(), NtFlushInstructionCache(), NtFlushVirtualMemory(), NtGetVersionResource(), NtGetWriteWatch(), NtLockVirtualMemory(), NtMapViewOfSection(), NtProtectVirtualMemory(), NtQueryVirtualMemory(), NtReadVirtualMemory(), NtResetWriteWatch(), NtUnlockVirtualMemory(), NtUnmapViewOfSection(), NtWriteVirtualMemory(), OpenAndMapFile(), PageFileBehaviorChecks(), PcMemGetBiosMemoryMap(), PeLdrpFetchAddressOfSecurityCookie(), PropertyLengthAsVariant(), RamdiskCreateDiskDevice(), RamdiskGetPartitionInfo(), RamdiskReadWriteReal(), RamdiskSetPartitionInfo(), RamdiskUnmapPages(), ReserveMemory(), RtlAddFunctionTable(), RtlConvertPropertyToVariant(), RtlConvertVariantToProperty(), RtlDebugGetUserInfoHeap(), RtlDebugSetUserFlagsHeap(), RtlDebugSetUserValueHeap(), RtlDestroyHeap(), RtlFindMessage(), RtlGetExpWinVer(), RtlGetUserInfoHeap(), RtlImageDirectoryEntryToData(), RtlImageRvaToVa(), RtlInstallFunctionTableCallback(), RtlpDebugPageHeapValidate(), RtlpDestroyHeapSegment(), RtlpDphNormalHeapValidate(), RtlpInitEnvironment(), RtlpPageHeapGetUserInfo(), RtlpPageHeapSetUserFlags(), RtlpPageHeapSetUserValue(), RtlpPageHeapSize(), RtlSetUserFlagsHeap(), RtlSetUserValueHeap(), ScrResetScreen(), ScrSetFont(), SE_IsShimDll(), SeiCheckComPlusImage(), SeiCreateShimModuleInfo(), SeiFindHookModuleInfo(), SeiGetShimModuleInfo(), SeiInit(), SerialDetectUartType(), SetMemory(), SimpleErrorChecks(), START_TEST(), supports_pdb(), supports_rsym(), SystemProcessWorker(), Test_ImageSection2(), test_pack_MEMORY_BASIC_INFORMATION(), Test_PageFileSection(), Test_RawSize(), Test_SectionContents(), test_SymEnumSymbols(), test_SymFromAddr(), test_SymFromName(), test_SymRegCallback(), Test_Truncate(), TestMap(), UefiInitializeAppleGraphics(), UefiSetMemory(), UnMapFile(), VbeGetVideoMemoryBaseAddress(), VbeSetMode(), VdmpInitialize(), VidBiosDrawGlyph(), VidBiosPost(), VidBiosSetVideoMode(), VidBiosVideoService(), VideoPortLockBuffer(), VidFbInitializeVideo(), VidInitialize(), VirtualLock(), VirtualUnlock(), and Write().

◆ CommitSize

◆ DesiredAccess

Definition at line 360 of file mmfuncs.h.

◆ FileHandle

◆ FreeType

◆ MaximumSize

◆ ObjectAttributes

Definition at line 361 of file mmfuncs.h.

◆ ProcessHandle

_In_ HANDLE ProcessHandle

Definition at line 403 of file mmfuncs.h.

Referenced by BaseCheckForVDM(), BasepReplaceProcessThreadTokens(), BasePushProcessParameters(), CON_API(), ConDrvCreateScreenBuffer(), CreateProcessInternalW(), CSR_API(), GetProcessVersion(), GRAPHICS_BUFFER_Initialize(), InsertProcessSecurityCommon(), InsertTokenToProcessCommon(), IntAgpReserveVirtual(), IntVideoPortMapMemory(), IsProcessInJob(), LsapCheckLogonProcess(), LsapEnumLogonSessions(), LsapGetLogonSessionData(), LsapIsTrustedClient(), MiQueryMemoryBasicInformation(), MiQueryMemorySectionName(), NtAllocateVirtualMemory(), NtAssignProcessToJobObject(), NtCreateProcess(), NtCreateProcessEx(), NtCreateThread(), NtDebugActiveProcess(), NtFlushInstructionCache(), NtFlushVirtualMemory(), NtFreeVirtualMemory(), NtGetWriteWatch(), NtIsProcessInJob(), NtLockVirtualMemory(), NtMapViewOfSection(), NtOpenProcess(), NtOpenProcessToken(), NtOpenProcessTokenEx(), NtProtectVirtualMemory(), NtQueryInformationProcess(), NtQueryVirtualMemory(), NtReadVirtualMemory(), NtRemoveProcessDebug(), NtResetWriteWatch(), NtResumeProcess(), NtSetInformationProcess(), NtSuspendProcess(), NtTerminateProcess(), NtUnlockVirtualMemory(), NtUnmapViewOfSection(), NtUserProcessConnect(), NtUserResolveDesktop(), NtWriteVirtualMemory(), OpenProcess(), OpenProcessToken(), ProcessIdToSessionId(), PsaEnumerateProcessModules(), PsCreateSystemProcess(), PsCreateSystemThread(), PsOpenTokenOfProcess(), PspCreateProcess(), PspCreateThread(), RtlCreateUserThread(), RtlFreeUserThreadStack(), RtlInitializeContext(), RtlpCreateUserStack(), RtlpFreeUserStack(), RtlpInitEnvironment(), RtlpQueryRemoteProcessModules(), SmpExecPgm(), SmpGetProcessMuSessionId(), SmpHandleConnectionRequest(), SmpInit(), SmpSetProcessMuSessionId(), StuffStdHandle(), TEXTMODE_BUFFER_Initialize(), WahOpenCurrentThread(), and wait_process_handle().

◆ RegionSize

◆ SectionOffset

◆ SectionPageProtection

◆ ViewSize

Definition at line 408 of file mmfuncs.h.

Referenced by _Function_class_(), AdvancedErrorChecks(), BasepLoadLibraryAsDatafile(), BehaviorChecks(), CcpMapData(), CcRosCreateVacb(), CmpInitializeMachineDependentConfiguration(), CON_API(), ConDrvGetConsoleScreenBufferInfo(), CsrSrvAttachSharedSection(), CsrSrvCreateSharedSection(), ExpInitNls(), FileSectionViewPermissionCheck(), GRAPHICS_BUFFER_Initialize(), GuiApplyUserSettings(), GuiConsoleShowConsoleProperties(), Heap32ListFirst(), Heap32ListNext(), IntGdiAddFontResourceSingle(), IntMapDesktopView(), IntUserHeapCreate(), LdrpCheckForLoadedDll(), LdrpMapDll(), LdrVerifyImageMatchesChecksum(), MapFile(), MapGlobalUserHeap(), MapViewOfFileEx(), MiInsertVadEx(), MiLoadImageSection(), MiMapViewInSystemSpace(), MiMapViewOfDataSection(), MiRosUnmapViewOfSection(), MmCheckSystemImage(), MmCommitSessionMappedView(), MmCreatePeb(), MmInitializeProcessAddressSpace(), MmMapViewInSessionSpace(), MmMapViewInSystemSpace(), MmMapViewInSystemSpaceEx(), MmMapViewOfArm3Section(), MmMapViewOfSection(), MmMapViewOfSegment(), Module32FirstW(), Module32NextW(), NtMapViewOfSection(), PageFileBehaviorChecks(), Process32FirstW(), Process32NextW(), PspMapSystemDll(), RtlDestroyQueryDebugBuffer(), SimpleErrorChecks(), SystemProcessWorker(), Test_BasedSection(), Test_ImageSection(), Test_ImageSection2(), Test_PageFileSection(), Test_RawSize(), Test_SectionContents(), Test_Truncate(), TestPhysicalMemorySection(), TH32CreateSnapshotSectionInitialize(), Thread32First(), Thread32Next(), and VdmpInitialize().

◆ Win32Protect

◆ ZeroBits