2010-02-26 11:43:19 +00:00
|
|
|
#pragma once
|
1998-08-25 04:27:41 +00:00
|
|
|
|
2001-03-16 18:11:24 +00:00
|
|
|
#include <internal/arch/mm.h>
|
1998-08-25 04:27:41 +00:00
|
|
|
|
2021-03-26 08:32:34 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
1998-09-05 17:34:23 +00:00
|
|
|
/* TYPES *********************************************************************/
|
|
|
|
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS;
|
2006-05-10 17:47:44 +00:00
|
|
|
|
2011-07-25 00:01:29 +00:00
|
|
|
extern PMMSUPPORT MmKernelAddressSpace;
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
extern PFN_COUNT MiFreeSwapPages;
|
|
|
|
extern PFN_COUNT MiUsedSwapPages;
|
|
|
|
extern PFN_COUNT MmNumberOfPhysicalPages;
|
2009-10-19 23:04:50 +00:00
|
|
|
extern UCHAR MmDisablePagingExecutive;
|
2010-07-16 00:34:26 +00:00
|
|
|
extern PFN_NUMBER MmLowestPhysicalPage;
|
|
|
|
extern PFN_NUMBER MmHighestPhysicalPage;
|
|
|
|
extern PFN_NUMBER MmAvailablePages;
|
2010-07-15 01:10:18 +00:00
|
|
|
extern PFN_NUMBER MmResidentAvailablePages;
|
2018-02-09 13:21:14 +00:00
|
|
|
extern ULONG MmThrottleTop;
|
|
|
|
extern ULONG MmThrottleBottom;
|
2005-09-14 01:05:50 +00:00
|
|
|
|
2009-10-31 01:02:35 +00:00
|
|
|
extern LIST_ENTRY MmLoadedUserImageList;
|
|
|
|
|
2009-11-12 19:41:39 +00:00
|
|
|
extern KMUTANT MmSystemLoadLock;
|
|
|
|
|
2009-10-31 01:02:35 +00:00
|
|
|
extern ULONG MmNumberOfPagingFiles;
|
|
|
|
|
2021-12-30 19:57:14 +00:00
|
|
|
extern SIZE_T MmTotalNonPagedPoolQuota;
|
|
|
|
extern SIZE_T MmTotalPagedPoolQuota;
|
|
|
|
|
2009-10-31 01:02:35 +00:00
|
|
|
extern PVOID MmUnloadedDrivers;
|
|
|
|
extern PVOID MmLastUnloadedDrivers;
|
|
|
|
extern PVOID MmTriageActionTaken;
|
|
|
|
extern PVOID KernelVerifier;
|
|
|
|
extern MM_DRIVER_VERIFIER_DATA MmVerifierData;
|
|
|
|
|
|
|
|
extern SIZE_T MmTotalCommitLimit;
|
|
|
|
extern SIZE_T MmTotalCommittedPages;
|
|
|
|
extern SIZE_T MmSharedCommit;
|
|
|
|
extern SIZE_T MmDriverCommit;
|
|
|
|
extern SIZE_T MmProcessCommit;
|
|
|
|
extern SIZE_T MmPagedPoolCommit;
|
|
|
|
extern SIZE_T MmPeakCommitment;
|
|
|
|
extern SIZE_T MmtotalCommitLimitMaximum;
|
|
|
|
|
2014-03-11 22:51:22 +00:00
|
|
|
extern PVOID MiDebugMapping; // internal
|
|
|
|
extern PMMPTE MmDebugPte; // internal
|
2009-11-04 22:40:18 +00:00
|
|
|
|
2021-07-23 15:14:47 +00:00
|
|
|
extern KSPIN_LOCK MmPfnLock;
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
struct _KTRAP_FRAME;
|
2000-07-04 08:52:47 +00:00
|
|
|
struct _EPROCESS;
|
2001-12-31 01:53:46 +00:00
|
|
|
struct _MM_RMAP_ENTRY;
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
typedef ULONG_PTR SWAPENTRY;
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2021-12-30 19:57:14 +00:00
|
|
|
//
|
|
|
|
// Pool Quota values
|
|
|
|
//
|
|
|
|
#define MI_QUOTA_NON_PAGED_NEEDED_PAGES 64
|
|
|
|
#define MI_NON_PAGED_QUOTA_MIN_RESIDENT_PAGES 200
|
|
|
|
#define MI_CHARGE_PAGED_POOL_QUOTA 0x80000
|
|
|
|
#define MI_CHARGE_NON_PAGED_POOL_QUOTA 0x10000
|
|
|
|
|
2021-06-07 17:31:24 +00:00
|
|
|
//
|
|
|
|
// Special IRQL value (found in assertions)
|
|
|
|
//
|
|
|
|
#define MM_NOIRQL ((KIRQL)0xFFFFFFFF)
|
|
|
|
|
2009-10-13 19:45:40 +00:00
|
|
|
//
|
2009-10-31 01:02:35 +00:00
|
|
|
// MmDbgCopyMemory Flags
|
2009-10-13 19:45:40 +00:00
|
|
|
//
|
|
|
|
#define MMDBG_COPY_WRITE 0x00000001
|
|
|
|
#define MMDBG_COPY_PHYSICAL 0x00000002
|
|
|
|
#define MMDBG_COPY_UNSAFE 0x00000004
|
|
|
|
#define MMDBG_COPY_CACHED 0x00000008
|
|
|
|
#define MMDBG_COPY_UNCACHED 0x00000010
|
|
|
|
#define MMDBG_COPY_WRITE_COMBINED 0x00000020
|
|
|
|
|
|
|
|
//
|
|
|
|
// Maximum chunk size per copy
|
|
|
|
//
|
|
|
|
#define MMDBG_COPY_MAX_SIZE 0x8
|
|
|
|
|
2014-03-11 22:51:22 +00:00
|
|
|
#if defined(_X86_) // intenal for marea.c
|
2009-11-04 22:40:18 +00:00
|
|
|
#define MI_STATIC_MEMORY_AREAS (14)
|
|
|
|
#else
|
|
|
|
#define MI_STATIC_MEMORY_AREAS (13)
|
|
|
|
#endif
|
2009-06-21 05:46:50 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
#define MEMORY_AREA_SECTION_VIEW (1)
|
2020-10-23 14:16:51 +00:00
|
|
|
#ifdef NEWCC
|
2012-03-03 22:34:35 +00:00
|
|
|
#define MEMORY_AREA_CACHE (2)
|
2020-10-23 14:16:51 +00:00
|
|
|
#endif
|
- Fix a bug in memory area creation: Static memory areas had the static flag embedded in their type, so code that was switch()ing on the type would fail to recognize the actual type, because MEMORY_AREA_STATIC was ORed in.
- Add a new memory area type: MEMORY_AREA_OWNED_BY_ARM3. This will allow us to instruct the ReactOS Memory MAnager to "Back. The Fuck. Off." during page faults and such, so we can handle page faults inside ARM3-owned PTEs ourselves.
- Right now, all ARM3 PTEs and data is nonpaged, so no page faults should happen, but this may change in the future.
- Also will allow us to manage our own PDEs so we can do on-demand inpage instead of syncing with the ReactOS Mm hack cache.
- Create all memory areas in one shot in MmCreateSystemMemoryAreas (get rid of MiInitPageDirectoryMap and MiInitPagedPool memory area creation).
- Mark all of ours as owned by ARM3.
- Make them all static.
- The only non-ARM3 one right now is paged pool, we own all the other static areas.
- Move this code into mm, instead of mm/ARM3, since memory areas are not an ARM3 concept.
- Also create memory areas for session space, session view, and other ARM3 memory ranges, so nobody touches those ranges.
- Dump the kernel address space after all this is done, in a MmDbg function in mm.
- This cleans up ARM3 of some ROS-specific code, and also collapses Phase 1 and 2 into a single phase.
svn path=/trunk/; revision=43486
2009-10-15 18:54:35 +00:00
|
|
|
#define MEMORY_AREA_OWNED_BY_ARM3 (15)
|
2009-06-21 05:46:50 +00:00
|
|
|
#define MEMORY_AREA_STATIC (0x80000000)
|
2005-09-14 01:05:50 +00:00
|
|
|
|
2005-06-25 17:01:17 +00:00
|
|
|
/* Although Microsoft says this isn't hardcoded anymore,
|
|
|
|
they won't be able to change it. Stuff depends on it */
|
2007-10-19 23:21:45 +00:00
|
|
|
#define MM_VIRTMEM_GRANULARITY (64 * 1024)
|
2004-09-28 19:49:21 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
#define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
|
2000-12-28 03:38:08 +00:00
|
|
|
|
2001-01-08 02:14:06 +00:00
|
|
|
/*
|
|
|
|
* Additional flags for protection attributes
|
|
|
|
*/
|
2005-09-14 01:05:50 +00:00
|
|
|
#define PAGE_WRITETHROUGH (1024)
|
|
|
|
#define PAGE_SYSTEM (2048)
|
|
|
|
|
|
|
|
#define SEC_PHYSICALMEMORY (0x80000000)
|
|
|
|
|
2020-11-06 08:39:31 +00:00
|
|
|
#define MC_USER (0)
|
|
|
|
#define MC_SYSTEM (1)
|
|
|
|
#define MC_MAXIMUM (2)
|
2005-09-14 01:05:50 +00:00
|
|
|
|
|
|
|
#define PAGED_POOL_MASK 1
|
|
|
|
#define MUST_SUCCEED_POOL_MASK 2
|
|
|
|
#define CACHE_ALIGNED_POOL_MASK 4
|
|
|
|
#define QUOTA_POOL_MASK 8
|
|
|
|
#define SESSION_POOL_MASK 32
|
|
|
|
#define VERIFIER_POOL_MASK 64
|
|
|
|
|
2018-08-13 05:52:05 +00:00
|
|
|
#define MAX_PAGING_FILES (16)
|
|
|
|
|
2014-03-11 22:51:22 +00:00
|
|
|
// FIXME: use ALIGN_UP_BY
|
2005-09-14 01:05:50 +00:00
|
|
|
#define MM_ROUND_UP(x,s) \
|
|
|
|
((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
|
|
|
|
|
|
|
|
#define MM_ROUND_DOWN(x,s) \
|
|
|
|
((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
|
|
|
|
|
2009-01-24 00:54:02 +00:00
|
|
|
#define PAGE_FLAGS_VALID_FOR_SECTION \
|
|
|
|
(PAGE_READONLY | \
|
|
|
|
PAGE_READWRITE | \
|
|
|
|
PAGE_WRITECOPY | \
|
|
|
|
PAGE_EXECUTE | \
|
|
|
|
PAGE_EXECUTE_READ | \
|
|
|
|
PAGE_EXECUTE_READWRITE | \
|
|
|
|
PAGE_EXECUTE_WRITECOPY | \
|
2015-08-07 15:52:04 +00:00
|
|
|
PAGE_NOACCESS | \
|
|
|
|
PAGE_NOCACHE)
|
2009-01-24 00:54:02 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
#define PAGE_IS_READABLE \
|
|
|
|
(PAGE_READONLY | \
|
|
|
|
PAGE_READWRITE | \
|
|
|
|
PAGE_WRITECOPY | \
|
|
|
|
PAGE_EXECUTE_READ | \
|
|
|
|
PAGE_EXECUTE_READWRITE | \
|
|
|
|
PAGE_EXECUTE_WRITECOPY)
|
|
|
|
|
|
|
|
#define PAGE_IS_WRITABLE \
|
|
|
|
(PAGE_READWRITE | \
|
|
|
|
PAGE_WRITECOPY | \
|
|
|
|
PAGE_EXECUTE_READWRITE | \
|
|
|
|
PAGE_EXECUTE_WRITECOPY)
|
|
|
|
|
|
|
|
#define PAGE_IS_EXECUTABLE \
|
|
|
|
(PAGE_EXECUTE | \
|
|
|
|
PAGE_EXECUTE_READ | \
|
|
|
|
PAGE_EXECUTE_READWRITE | \
|
|
|
|
PAGE_EXECUTE_WRITECOPY)
|
|
|
|
|
|
|
|
#define PAGE_IS_WRITECOPY \
|
|
|
|
(PAGE_WRITECOPY | \
|
|
|
|
PAGE_EXECUTE_WRITECOPY)
|
2004-12-30 08:05:12 +00:00
|
|
|
|
2012-06-01 09:01:41 +00:00
|
|
|
//
|
|
|
|
// Wait entry for marking pages that are being serviced
|
|
|
|
//
|
2019-07-28 12:27:51 +00:00
|
|
|
#ifdef _M_IX86
|
2012-06-01 09:01:41 +00:00
|
|
|
#define MM_WAIT_ENTRY 0x7ffffc00
|
2019-07-28 12:27:51 +00:00
|
|
|
#elif defined(_M_AMD64)
|
|
|
|
#define MM_WAIT_ENTRY 0x7FFFFFFFFFFFFC00ULL
|
|
|
|
#else
|
|
|
|
#error Unsupported architecture!
|
|
|
|
#endif
|
2008-08-16 01:58:59 +00:00
|
|
|
|
2021-06-13 09:12:57 +00:00
|
|
|
#ifdef _M_AMD64
|
|
|
|
#define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
|
|
|
|
InterlockedCompareExchange64((PLONG64)(PointerPte), Exchange, Comperand)
|
|
|
|
|
|
|
|
#define InterlockedExchangePte(PointerPte, Value) \
|
|
|
|
InterlockedExchange64((PLONG64)(PointerPte), Value)
|
|
|
|
#else
|
2008-08-16 01:58:59 +00:00
|
|
|
#define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
|
2008-12-03 18:04:26 +00:00
|
|
|
InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
|
2008-08-16 01:58:59 +00:00
|
|
|
|
|
|
|
#define InterlockedExchangePte(PointerPte, Value) \
|
2008-12-03 18:04:26 +00:00
|
|
|
InterlockedExchange((PLONG)(PointerPte), Value)
|
2021-06-13 09:12:57 +00:00
|
|
|
#endif
|
2008-08-16 01:58:59 +00:00
|
|
|
|
2001-02-10 22:51:11 +00:00
|
|
|
typedef struct _MM_SECTION_SEGMENT
|
2001-01-12 21:00:08 +00:00
|
|
|
{
|
2021-06-07 17:31:24 +00:00
|
|
|
LONG64 RefCount;
|
2020-10-26 08:04:49 +00:00
|
|
|
PFILE_OBJECT FileObject;
|
|
|
|
|
2006-07-09 19:37:39 +00:00
|
|
|
FAST_MUTEX Lock; /* lock which protects the page directory */
|
[NEWCC]
A reintegration checkpoint for the NewCC branch, brought to you by Team NewCC.
Differences with current ReactOS trunk:
* A new memory area type, MEMORY_AREA_CACHE, is added, which represents a mapped region of a file. In NEWCC mode, user sections are MEMORY_AREA_CACHE type as well, and obey new semantics. In non-NEWCC mode, they aren't used.
* A way of claiming a page entry for a specific thread's work is added. Placing the special SWAPENTRY value MM_WAIT_ENTRY in a page table, or in a section page table should indicate that memory management code is intended to wait for another thread to make some status change before checking the state of the page entry again. In code that uses this convention, a return value of STATUS_SUCCESS + 1 is used to indicate that the caller should use the MiWaitForPageEvent macro to wait until somebody has change the state of a wait entry before checking again. This is a lighter weight mechanism than PAGEOPs.
* A way of asking the caller to perform some blocking operation without locks held is provided. This replaces some spaghettified code in which locks are repeatedly taken and broken by code that performs various blocking operations. Using this mechanism, it is possible to do a small amount of non-blocking work, fill in a request, then return STATUS_MORE_PROCESSING_REQUIRED to request that locks be dropped and the blocking operation be carried out. A MM_REQUIRED_RESOURCES structure is provided to consumers of this contract to use to accumulate state across many blocking operations. Several functions wrapping blocking operations are provided in ntoskrnl/cache/reqtools.c.
* Image section pages are no longer direct mapped. This is done to simplify consolidation of ownership of pages under the data section system. At a later time, it may be possible to make data pages directly available to image sections for the same file. This is likely the only direct performance impact this code makes on non-NEWCC mode.
RMAPs:
* A new type of RMAP entry is introduced, distinguished by RMAP_IS_SEGMENT(Address) of the rmap entry. This kind of entry contains a pointer to a section page table node in the Process pointer, which in turn links back to the MM_SECTION_SEGMENT it belongs to. Therefore, a page belonging only to a segment (that is, a segment page that isn't mapped) can exist and be evicted using the normal page eviction mechanism in balance.c. Each of the rmap function has been modified to deal with segment rmaps.
* The low 8 bits of the Address field in a segment rmap denote the entry number in the generic table node pointed to by Process that points to the page the rmap belongs to. By combining them, you can determine the file offset the page belongs to.
* In NEWCC mode, MmSharePageEntry/UnsharePageEntry are not used, and instead the page reference count is used to keep track of the number of mappings of a page, allowing the last reference expiring to allow the page to be recycled without much intervention. These are still used in non-NEWCC mode. One change has been made, the count fields have been narrowed by 1 bit to make room for a dirty bit in SSE entries, needed when a page is present but unmapped.
Section page tables:
* The section page tables are now implemented using RtlGenericTables. This enables a fairly compact representation of section page tables without having the existence of a section object imply 4k of fake PDEs. In addition, each node in the generic table has a wide file offset that is a multiple of 256 pages, or 1 megabyte total. Besides needing wide file offsets, the only other visible change caused by the switch to generic tables for section page tables is the need to lock the section segment before interacting with the section page table.
Eviction:
* Page eviction in cache sections is accomplished by MmpPageOutPhysicalAddress. In the case of a shared page, it tries to remove all mappings of the indicated page. If this process fails at any point, the page will simply be drawn back into the target address spaces. After succeeding at this, if TRUE has been accumulated into the page's dirty bit in the section page table, it is written back, and then permanently removed.
NewCC mode:
* NEWCC mode is introduced, which rewrites the file cache to a set of cache stripes actively mapped, along with unmapped section data.
* NewCC is more authentic in its interpretation of the external interface to the windows cache than the current cache manager, implementing each of the cache manager functions according to the documented interface with no preconceived ideas about how anything should be implemented internally. Cache stripes are implemented on top of section objects, using the same memory manager paths, and therefore economizing code and complexity. This replaces a rather complicated system in which pages can be owned by the cache manager and the memory manager simultaneously and they must cooperate in a fairly sophisticated way to manage them. Since they're quite interdependent in the current code, modifying either is very difficult. In NEWCC, they have a clear division of labor and thus can be worked on independently.
* Several third party filesystems that use the kernel Cc interface work properly using NEWCC, including matt wu's ext3 driver.
* In contrast with code that tries to make CcInitializeCacheMap and CcUninitializeCacheMap into a pair that supports reference counting, NEWCC lazily initializes the shared and private cache maps as needed and uses the presence of a PrivateCacheMap on at least one file pointing to the SharedCacheMap as an indication that the FILE_OBJECT reference in the SharedCacheMap should still be held. When the last PrivateCacheMap is discarded, that's the appropriate time to tear down caching for a specific file, as the SharedCacheMap data is allowed to be saved and reused. We honor this by making the SharedCacheMap into a depot for keeping track of the PrivateCacheMap objects associated with views of a file.
svn path=/trunk/; revision=55833
2012-02-23 12:03:06 +00:00
|
|
|
LARGE_INTEGER RawLength; /* length of the segment which is part of the mapped file */
|
|
|
|
LARGE_INTEGER Length; /* absolute length of the segment */
|
2021-01-27 15:20:08 +00:00
|
|
|
PLONG64 ReferenceCount;
|
2020-11-06 08:39:31 +00:00
|
|
|
ULONG SectionCount;
|
[NEWCC]
A reintegration checkpoint for the NewCC branch, brought to you by Team NewCC.
Differences with current ReactOS trunk:
* A new memory area type, MEMORY_AREA_CACHE, is added, which represents a mapped region of a file. In NEWCC mode, user sections are MEMORY_AREA_CACHE type as well, and obey new semantics. In non-NEWCC mode, they aren't used.
* A way of claiming a page entry for a specific thread's work is added. Placing the special SWAPENTRY value MM_WAIT_ENTRY in a page table, or in a section page table should indicate that memory management code is intended to wait for another thread to make some status change before checking the state of the page entry again. In code that uses this convention, a return value of STATUS_SUCCESS + 1 is used to indicate that the caller should use the MiWaitForPageEvent macro to wait until somebody has change the state of a wait entry before checking again. This is a lighter weight mechanism than PAGEOPs.
* A way of asking the caller to perform some blocking operation without locks held is provided. This replaces some spaghettified code in which locks are repeatedly taken and broken by code that performs various blocking operations. Using this mechanism, it is possible to do a small amount of non-blocking work, fill in a request, then return STATUS_MORE_PROCESSING_REQUIRED to request that locks be dropped and the blocking operation be carried out. A MM_REQUIRED_RESOURCES structure is provided to consumers of this contract to use to accumulate state across many blocking operations. Several functions wrapping blocking operations are provided in ntoskrnl/cache/reqtools.c.
* Image section pages are no longer direct mapped. This is done to simplify consolidation of ownership of pages under the data section system. At a later time, it may be possible to make data pages directly available to image sections for the same file. This is likely the only direct performance impact this code makes on non-NEWCC mode.
RMAPs:
* A new type of RMAP entry is introduced, distinguished by RMAP_IS_SEGMENT(Address) of the rmap entry. This kind of entry contains a pointer to a section page table node in the Process pointer, which in turn links back to the MM_SECTION_SEGMENT it belongs to. Therefore, a page belonging only to a segment (that is, a segment page that isn't mapped) can exist and be evicted using the normal page eviction mechanism in balance.c. Each of the rmap function has been modified to deal with segment rmaps.
* The low 8 bits of the Address field in a segment rmap denote the entry number in the generic table node pointed to by Process that points to the page the rmap belongs to. By combining them, you can determine the file offset the page belongs to.
* In NEWCC mode, MmSharePageEntry/UnsharePageEntry are not used, and instead the page reference count is used to keep track of the number of mappings of a page, allowing the last reference expiring to allow the page to be recycled without much intervention. These are still used in non-NEWCC mode. One change has been made, the count fields have been narrowed by 1 bit to make room for a dirty bit in SSE entries, needed when a page is present but unmapped.
Section page tables:
* The section page tables are now implemented using RtlGenericTables. This enables a fairly compact representation of section page tables without having the existence of a section object imply 4k of fake PDEs. In addition, each node in the generic table has a wide file offset that is a multiple of 256 pages, or 1 megabyte total. Besides needing wide file offsets, the only other visible change caused by the switch to generic tables for section page tables is the need to lock the section segment before interacting with the section page table.
Eviction:
* Page eviction in cache sections is accomplished by MmpPageOutPhysicalAddress. In the case of a shared page, it tries to remove all mappings of the indicated page. If this process fails at any point, the page will simply be drawn back into the target address spaces. After succeeding at this, if TRUE has been accumulated into the page's dirty bit in the section page table, it is written back, and then permanently removed.
NewCC mode:
* NEWCC mode is introduced, which rewrites the file cache to a set of cache stripes actively mapped, along with unmapped section data.
* NewCC is more authentic in its interpretation of the external interface to the windows cache than the current cache manager, implementing each of the cache manager functions according to the documented interface with no preconceived ideas about how anything should be implemented internally. Cache stripes are implemented on top of section objects, using the same memory manager paths, and therefore economizing code and complexity. This replaces a rather complicated system in which pages can be owned by the cache manager and the memory manager simultaneously and they must cooperate in a fairly sophisticated way to manage them. Since they're quite interdependent in the current code, modifying either is very difficult. In NEWCC, they have a clear division of labor and thus can be worked on independently.
* Several third party filesystems that use the kernel Cc interface work properly using NEWCC, including matt wu's ext3 driver.
* In contrast with code that tries to make CcInitializeCacheMap and CcUninitializeCacheMap into a pair that supports reference counting, NEWCC lazily initializes the shared and private cache maps as needed and uses the presence of a PrivateCacheMap on at least one file pointing to the SharedCacheMap as an indication that the FILE_OBJECT reference in the SharedCacheMap should still be held. When the last PrivateCacheMap is discarded, that's the appropriate time to tear down caching for a specific file, as the SharedCacheMap data is allowed to be saved and reused. We honor this by making the SharedCacheMap into a depot for keeping track of the PrivateCacheMap objects associated with views of a file.
svn path=/trunk/; revision=55833
2012-02-23 12:03:06 +00:00
|
|
|
ULONG Protection;
|
2020-11-06 08:39:31 +00:00
|
|
|
PULONG Flags;
|
2005-09-14 01:05:50 +00:00
|
|
|
BOOLEAN WriteCopy;
|
[NEWCC]
A reintegration checkpoint for the NewCC branch, brought to you by Team NewCC.
Differences with current ReactOS trunk:
* A new memory area type, MEMORY_AREA_CACHE, is added, which represents a mapped region of a file. In NEWCC mode, user sections are MEMORY_AREA_CACHE type as well, and obey new semantics. In non-NEWCC mode, they aren't used.
* A way of claiming a page entry for a specific thread's work is added. Placing the special SWAPENTRY value MM_WAIT_ENTRY in a page table, or in a section page table should indicate that memory management code is intended to wait for another thread to make some status change before checking the state of the page entry again. In code that uses this convention, a return value of STATUS_SUCCESS + 1 is used to indicate that the caller should use the MiWaitForPageEvent macro to wait until somebody has change the state of a wait entry before checking again. This is a lighter weight mechanism than PAGEOPs.
* A way of asking the caller to perform some blocking operation without locks held is provided. This replaces some spaghettified code in which locks are repeatedly taken and broken by code that performs various blocking operations. Using this mechanism, it is possible to do a small amount of non-blocking work, fill in a request, then return STATUS_MORE_PROCESSING_REQUIRED to request that locks be dropped and the blocking operation be carried out. A MM_REQUIRED_RESOURCES structure is provided to consumers of this contract to use to accumulate state across many blocking operations. Several functions wrapping blocking operations are provided in ntoskrnl/cache/reqtools.c.
* Image section pages are no longer direct mapped. This is done to simplify consolidation of ownership of pages under the data section system. At a later time, it may be possible to make data pages directly available to image sections for the same file. This is likely the only direct performance impact this code makes on non-NEWCC mode.
RMAPs:
* A new type of RMAP entry is introduced, distinguished by RMAP_IS_SEGMENT(Address) of the rmap entry. This kind of entry contains a pointer to a section page table node in the Process pointer, which in turn links back to the MM_SECTION_SEGMENT it belongs to. Therefore, a page belonging only to a segment (that is, a segment page that isn't mapped) can exist and be evicted using the normal page eviction mechanism in balance.c. Each of the rmap function has been modified to deal with segment rmaps.
* The low 8 bits of the Address field in a segment rmap denote the entry number in the generic table node pointed to by Process that points to the page the rmap belongs to. By combining them, you can determine the file offset the page belongs to.
* In NEWCC mode, MmSharePageEntry/UnsharePageEntry are not used, and instead the page reference count is used to keep track of the number of mappings of a page, allowing the last reference expiring to allow the page to be recycled without much intervention. These are still used in non-NEWCC mode. One change has been made, the count fields have been narrowed by 1 bit to make room for a dirty bit in SSE entries, needed when a page is present but unmapped.
Section page tables:
* The section page tables are now implemented using RtlGenericTables. This enables a fairly compact representation of section page tables without having the existence of a section object imply 4k of fake PDEs. In addition, each node in the generic table has a wide file offset that is a multiple of 256 pages, or 1 megabyte total. Besides needing wide file offsets, the only other visible change caused by the switch to generic tables for section page tables is the need to lock the section segment before interacting with the section page table.
Eviction:
* Page eviction in cache sections is accomplished by MmpPageOutPhysicalAddress. In the case of a shared page, it tries to remove all mappings of the indicated page. If this process fails at any point, the page will simply be drawn back into the target address spaces. After succeeding at this, if TRUE has been accumulated into the page's dirty bit in the section page table, it is written back, and then permanently removed.
NewCC mode:
* NEWCC mode is introduced, which rewrites the file cache to a set of cache stripes actively mapped, along with unmapped section data.
* NewCC is more authentic in its interpretation of the external interface to the windows cache than the current cache manager, implementing each of the cache manager functions according to the documented interface with no preconceived ideas about how anything should be implemented internally. Cache stripes are implemented on top of section objects, using the same memory manager paths, and therefore economizing code and complexity. This replaces a rather complicated system in which pages can be owned by the cache manager and the memory manager simultaneously and they must cooperate in a fairly sophisticated way to manage them. Since they're quite interdependent in the current code, modifying either is very difficult. In NEWCC, they have a clear division of labor and thus can be worked on independently.
* Several third party filesystems that use the kernel Cc interface work properly using NEWCC, including matt wu's ext3 driver.
* In contrast with code that tries to make CcInitializeCacheMap and CcUninitializeCacheMap into a pair that supports reference counting, NEWCC lazily initializes the shared and private cache maps as needed and uses the presence of a PrivateCacheMap on at least one file pointing to the SharedCacheMap as an indication that the FILE_OBJECT reference in the SharedCacheMap should still be held. When the last PrivateCacheMap is discarded, that's the appropriate time to tear down caching for a specific file, as the SharedCacheMap data is allowed to be saved and reused. We honor this by making the SharedCacheMap into a depot for keeping track of the PrivateCacheMap objects associated with views of a file.
svn path=/trunk/; revision=55833
2012-02-23 12:03:06 +00:00
|
|
|
BOOLEAN Locked;
|
|
|
|
|
2012-03-28 19:41:40 +00:00
|
|
|
struct
|
[NEWCC]
A reintegration checkpoint for the NewCC branch, brought to you by Team NewCC.
Differences with current ReactOS trunk:
* A new memory area type, MEMORY_AREA_CACHE, is added, which represents a mapped region of a file. In NEWCC mode, user sections are MEMORY_AREA_CACHE type as well, and obey new semantics. In non-NEWCC mode, they aren't used.
* A way of claiming a page entry for a specific thread's work is added. Placing the special SWAPENTRY value MM_WAIT_ENTRY in a page table, or in a section page table should indicate that memory management code is intended to wait for another thread to make some status change before checking the state of the page entry again. In code that uses this convention, a return value of STATUS_SUCCESS + 1 is used to indicate that the caller should use the MiWaitForPageEvent macro to wait until somebody has change the state of a wait entry before checking again. This is a lighter weight mechanism than PAGEOPs.
* A way of asking the caller to perform some blocking operation without locks held is provided. This replaces some spaghettified code in which locks are repeatedly taken and broken by code that performs various blocking operations. Using this mechanism, it is possible to do a small amount of non-blocking work, fill in a request, then return STATUS_MORE_PROCESSING_REQUIRED to request that locks be dropped and the blocking operation be carried out. A MM_REQUIRED_RESOURCES structure is provided to consumers of this contract to use to accumulate state across many blocking operations. Several functions wrapping blocking operations are provided in ntoskrnl/cache/reqtools.c.
* Image section pages are no longer direct mapped. This is done to simplify consolidation of ownership of pages under the data section system. At a later time, it may be possible to make data pages directly available to image sections for the same file. This is likely the only direct performance impact this code makes on non-NEWCC mode.
RMAPs:
* A new type of RMAP entry is introduced, distinguished by RMAP_IS_SEGMENT(Address) of the rmap entry. This kind of entry contains a pointer to a section page table node in the Process pointer, which in turn links back to the MM_SECTION_SEGMENT it belongs to. Therefore, a page belonging only to a segment (that is, a segment page that isn't mapped) can exist and be evicted using the normal page eviction mechanism in balance.c. Each of the rmap function has been modified to deal with segment rmaps.
* The low 8 bits of the Address field in a segment rmap denote the entry number in the generic table node pointed to by Process that points to the page the rmap belongs to. By combining them, you can determine the file offset the page belongs to.
* In NEWCC mode, MmSharePageEntry/UnsharePageEntry are not used, and instead the page reference count is used to keep track of the number of mappings of a page, allowing the last reference expiring to allow the page to be recycled without much intervention. These are still used in non-NEWCC mode. One change has been made, the count fields have been narrowed by 1 bit to make room for a dirty bit in SSE entries, needed when a page is present but unmapped.
Section page tables:
* The section page tables are now implemented using RtlGenericTables. This enables a fairly compact representation of section page tables without having the existence of a section object imply 4k of fake PDEs. In addition, each node in the generic table has a wide file offset that is a multiple of 256 pages, or 1 megabyte total. Besides needing wide file offsets, the only other visible change caused by the switch to generic tables for section page tables is the need to lock the section segment before interacting with the section page table.
Eviction:
* Page eviction in cache sections is accomplished by MmpPageOutPhysicalAddress. In the case of a shared page, it tries to remove all mappings of the indicated page. If this process fails at any point, the page will simply be drawn back into the target address spaces. After succeeding at this, if TRUE has been accumulated into the page's dirty bit in the section page table, it is written back, and then permanently removed.
NewCC mode:
* NEWCC mode is introduced, which rewrites the file cache to a set of cache stripes actively mapped, along with unmapped section data.
* NewCC is more authentic in its interpretation of the external interface to the windows cache than the current cache manager, implementing each of the cache manager functions according to the documented interface with no preconceived ideas about how anything should be implemented internally. Cache stripes are implemented on top of section objects, using the same memory manager paths, and therefore economizing code and complexity. This replaces a rather complicated system in which pages can be owned by the cache manager and the memory manager simultaneously and they must cooperate in a fairly sophisticated way to manage them. Since they're quite interdependent in the current code, modifying either is very difficult. In NEWCC, they have a clear division of labor and thus can be worked on independently.
* Several third party filesystems that use the kernel Cc interface work properly using NEWCC, including matt wu's ext3 driver.
* In contrast with code that tries to make CcInitializeCacheMap and CcUninitializeCacheMap into a pair that supports reference counting, NEWCC lazily initializes the shared and private cache maps as needed and uses the presence of a PrivateCacheMap on at least one file pointing to the SharedCacheMap as an indication that the FILE_OBJECT reference in the SharedCacheMap should still be held. When the last PrivateCacheMap is discarded, that's the appropriate time to tear down caching for a specific file, as the SharedCacheMap data is allowed to be saved and reused. We honor this by making the SharedCacheMap into a depot for keeping track of the PrivateCacheMap objects associated with views of a file.
svn path=/trunk/; revision=55833
2012-02-23 12:03:06 +00:00
|
|
|
{
|
2012-03-28 19:41:40 +00:00
|
|
|
ULONGLONG FileOffset; /* start offset into the file for image sections */
|
|
|
|
ULONG_PTR VirtualAddress; /* start offset into the address range for image sections */
|
[NEWCC]
A reintegration checkpoint for the NewCC branch, brought to you by Team NewCC.
Differences with current ReactOS trunk:
* A new memory area type, MEMORY_AREA_CACHE, is added, which represents a mapped region of a file. In NEWCC mode, user sections are MEMORY_AREA_CACHE type as well, and obey new semantics. In non-NEWCC mode, they aren't used.
* A way of claiming a page entry for a specific thread's work is added. Placing the special SWAPENTRY value MM_WAIT_ENTRY in a page table, or in a section page table should indicate that memory management code is intended to wait for another thread to make some status change before checking the state of the page entry again. In code that uses this convention, a return value of STATUS_SUCCESS + 1 is used to indicate that the caller should use the MiWaitForPageEvent macro to wait until somebody has change the state of a wait entry before checking again. This is a lighter weight mechanism than PAGEOPs.
* A way of asking the caller to perform some blocking operation without locks held is provided. This replaces some spaghettified code in which locks are repeatedly taken and broken by code that performs various blocking operations. Using this mechanism, it is possible to do a small amount of non-blocking work, fill in a request, then return STATUS_MORE_PROCESSING_REQUIRED to request that locks be dropped and the blocking operation be carried out. A MM_REQUIRED_RESOURCES structure is provided to consumers of this contract to use to accumulate state across many blocking operations. Several functions wrapping blocking operations are provided in ntoskrnl/cache/reqtools.c.
* Image section pages are no longer direct mapped. This is done to simplify consolidation of ownership of pages under the data section system. At a later time, it may be possible to make data pages directly available to image sections for the same file. This is likely the only direct performance impact this code makes on non-NEWCC mode.
RMAPs:
* A new type of RMAP entry is introduced, distinguished by RMAP_IS_SEGMENT(Address) of the rmap entry. This kind of entry contains a pointer to a section page table node in the Process pointer, which in turn links back to the MM_SECTION_SEGMENT it belongs to. Therefore, a page belonging only to a segment (that is, a segment page that isn't mapped) can exist and be evicted using the normal page eviction mechanism in balance.c. Each of the rmap function has been modified to deal with segment rmaps.
* The low 8 bits of the Address field in a segment rmap denote the entry number in the generic table node pointed to by Process that points to the page the rmap belongs to. By combining them, you can determine the file offset the page belongs to.
* In NEWCC mode, MmSharePageEntry/UnsharePageEntry are not used, and instead the page reference count is used to keep track of the number of mappings of a page, allowing the last reference expiring to allow the page to be recycled without much intervention. These are still used in non-NEWCC mode. One change has been made, the count fields have been narrowed by 1 bit to make room for a dirty bit in SSE entries, needed when a page is present but unmapped.
Section page tables:
* The section page tables are now implemented using RtlGenericTables. This enables a fairly compact representation of section page tables without having the existence of a section object imply 4k of fake PDEs. In addition, each node in the generic table has a wide file offset that is a multiple of 256 pages, or 1 megabyte total. Besides needing wide file offsets, the only other visible change caused by the switch to generic tables for section page tables is the need to lock the section segment before interacting with the section page table.
Eviction:
* Page eviction in cache sections is accomplished by MmpPageOutPhysicalAddress. In the case of a shared page, it tries to remove all mappings of the indicated page. If this process fails at any point, the page will simply be drawn back into the target address spaces. After succeeding at this, if TRUE has been accumulated into the page's dirty bit in the section page table, it is written back, and then permanently removed.
NewCC mode:
* NEWCC mode is introduced, which rewrites the file cache to a set of cache stripes actively mapped, along with unmapped section data.
* NewCC is more authentic in its interpretation of the external interface to the windows cache than the current cache manager, implementing each of the cache manager functions according to the documented interface with no preconceived ideas about how anything should be implemented internally. Cache stripes are implemented on top of section objects, using the same memory manager paths, and therefore economizing code and complexity. This replaces a rather complicated system in which pages can be owned by the cache manager and the memory manager simultaneously and they must cooperate in a fairly sophisticated way to manage them. Since they're quite interdependent in the current code, modifying either is very difficult. In NEWCC, they have a clear division of labor and thus can be worked on independently.
* Several third party filesystems that use the kernel Cc interface work properly using NEWCC, including matt wu's ext3 driver.
* In contrast with code that tries to make CcInitializeCacheMap and CcUninitializeCacheMap into a pair that supports reference counting, NEWCC lazily initializes the shared and private cache maps as needed and uses the presence of a PrivateCacheMap on at least one file pointing to the SharedCacheMap as an indication that the FILE_OBJECT reference in the SharedCacheMap should still be held. When the last PrivateCacheMap is discarded, that's the appropriate time to tear down caching for a specific file, as the SharedCacheMap data is allowed to be saved and reused. We honor this by making the SharedCacheMap into a depot for keeping track of the PrivateCacheMap objects associated with views of a file.
svn path=/trunk/; revision=55833
2012-02-23 12:03:06 +00:00
|
|
|
ULONG Characteristics;
|
|
|
|
} Image;
|
|
|
|
|
2020-11-06 08:39:31 +00:00
|
|
|
ULONG SegFlags;
|
|
|
|
|
2021-01-27 15:20:08 +00:00
|
|
|
ULONGLONG LastPage;
|
|
|
|
|
[NEWCC]
A reintegration checkpoint for the NewCC branch, brought to you by Team NewCC.
Differences with current ReactOS trunk:
* A new memory area type, MEMORY_AREA_CACHE, is added, which represents a mapped region of a file. In NEWCC mode, user sections are MEMORY_AREA_CACHE type as well, and obey new semantics. In non-NEWCC mode, they aren't used.
* A way of claiming a page entry for a specific thread's work is added. Placing the special SWAPENTRY value MM_WAIT_ENTRY in a page table, or in a section page table should indicate that memory management code is intended to wait for another thread to make some status change before checking the state of the page entry again. In code that uses this convention, a return value of STATUS_SUCCESS + 1 is used to indicate that the caller should use the MiWaitForPageEvent macro to wait until somebody has change the state of a wait entry before checking again. This is a lighter weight mechanism than PAGEOPs.
* A way of asking the caller to perform some blocking operation without locks held is provided. This replaces some spaghettified code in which locks are repeatedly taken and broken by code that performs various blocking operations. Using this mechanism, it is possible to do a small amount of non-blocking work, fill in a request, then return STATUS_MORE_PROCESSING_REQUIRED to request that locks be dropped and the blocking operation be carried out. A MM_REQUIRED_RESOURCES structure is provided to consumers of this contract to use to accumulate state across many blocking operations. Several functions wrapping blocking operations are provided in ntoskrnl/cache/reqtools.c.
* Image section pages are no longer direct mapped. This is done to simplify consolidation of ownership of pages under the data section system. At a later time, it may be possible to make data pages directly available to image sections for the same file. This is likely the only direct performance impact this code makes on non-NEWCC mode.
RMAPs:
* A new type of RMAP entry is introduced, distinguished by RMAP_IS_SEGMENT(Address) of the rmap entry. This kind of entry contains a pointer to a section page table node in the Process pointer, which in turn links back to the MM_SECTION_SEGMENT it belongs to. Therefore, a page belonging only to a segment (that is, a segment page that isn't mapped) can exist and be evicted using the normal page eviction mechanism in balance.c. Each of the rmap function has been modified to deal with segment rmaps.
* The low 8 bits of the Address field in a segment rmap denote the entry number in the generic table node pointed to by Process that points to the page the rmap belongs to. By combining them, you can determine the file offset the page belongs to.
* In NEWCC mode, MmSharePageEntry/UnsharePageEntry are not used, and instead the page reference count is used to keep track of the number of mappings of a page, allowing the last reference expiring to allow the page to be recycled without much intervention. These are still used in non-NEWCC mode. One change has been made, the count fields have been narrowed by 1 bit to make room for a dirty bit in SSE entries, needed when a page is present but unmapped.
Section page tables:
* The section page tables are now implemented using RtlGenericTables. This enables a fairly compact representation of section page tables without having the existence of a section object imply 4k of fake PDEs. In addition, each node in the generic table has a wide file offset that is a multiple of 256 pages, or 1 megabyte total. Besides needing wide file offsets, the only other visible change caused by the switch to generic tables for section page tables is the need to lock the section segment before interacting with the section page table.
Eviction:
* Page eviction in cache sections is accomplished by MmpPageOutPhysicalAddress. In the case of a shared page, it tries to remove all mappings of the indicated page. If this process fails at any point, the page will simply be drawn back into the target address spaces. After succeeding at this, if TRUE has been accumulated into the page's dirty bit in the section page table, it is written back, and then permanently removed.
NewCC mode:
* NEWCC mode is introduced, which rewrites the file cache to a set of cache stripes actively mapped, along with unmapped section data.
* NewCC is more authentic in its interpretation of the external interface to the windows cache than the current cache manager, implementing each of the cache manager functions according to the documented interface with no preconceived ideas about how anything should be implemented internally. Cache stripes are implemented on top of section objects, using the same memory manager paths, and therefore economizing code and complexity. This replaces a rather complicated system in which pages can be owned by the cache manager and the memory manager simultaneously and they must cooperate in a fairly sophisticated way to manage them. Since they're quite interdependent in the current code, modifying either is very difficult. In NEWCC, they have a clear division of labor and thus can be worked on independently.
* Several third party filesystems that use the kernel Cc interface work properly using NEWCC, including matt wu's ext3 driver.
* In contrast with code that tries to make CcInitializeCacheMap and CcUninitializeCacheMap into a pair that supports reference counting, NEWCC lazily initializes the shared and private cache maps as needed and uses the presence of a PrivateCacheMap on at least one file pointing to the SharedCacheMap as an indication that the FILE_OBJECT reference in the SharedCacheMap should still be held. When the last PrivateCacheMap is discarded, that's the appropriate time to tear down caching for a specific file, as the SharedCacheMap data is allowed to be saved and reused. We honor this by making the SharedCacheMap into a depot for keeping track of the PrivateCacheMap objects associated with views of a file.
svn path=/trunk/; revision=55833
2012-02-23 12:03:06 +00:00
|
|
|
RTL_GENERIC_TABLE PageTable;
|
2001-02-10 22:51:11 +00:00
|
|
|
} MM_SECTION_SEGMENT, *PMM_SECTION_SEGMENT;
|
2001-01-12 21:00:08 +00:00
|
|
|
|
2003-06-27 21:28:30 +00:00
|
|
|
typedef struct _MM_IMAGE_SECTION_OBJECT
|
1998-08-25 04:27:41 +00:00
|
|
|
{
|
2021-01-27 15:20:08 +00:00
|
|
|
LONG64 RefCount;
|
2021-06-07 17:31:24 +00:00
|
|
|
PFILE_OBJECT FileObject;
|
|
|
|
ULONG SectionCount;
|
|
|
|
LONG MapCount;
|
2020-11-06 08:39:31 +00:00
|
|
|
ULONG SegFlags;
|
|
|
|
|
2013-08-28 21:09:16 +00:00
|
|
|
SECTION_IMAGE_INFORMATION ImageInformation;
|
|
|
|
PVOID BasedAddress;
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG NrSegments;
|
|
|
|
PMM_SECTION_SEGMENT Segments;
|
2003-06-27 21:28:30 +00:00
|
|
|
} MM_IMAGE_SECTION_OBJECT, *PMM_IMAGE_SECTION_OBJECT;
|
|
|
|
|
2020-12-14 14:55:08 +00:00
|
|
|
#define MM_PHYSICALMEMORY_SEGMENT (0x1)
|
2020-11-06 08:39:31 +00:00
|
|
|
#define MM_DATAFILE_SEGMENT (0x2)
|
|
|
|
#define MM_SEGMENT_INDELETE (0x4)
|
|
|
|
#define MM_SEGMENT_INCREATE (0x8)
|
2021-06-07 17:31:24 +00:00
|
|
|
#define MM_IMAGE_SECTION_FLUSH_DELETE (0x10)
|
2020-11-06 08:39:31 +00:00
|
|
|
|
|
|
|
|
2017-10-08 12:13:47 +00:00
|
|
|
#define MA_GetStartingAddress(_MemoryArea) ((_MemoryArea)->VadNode.StartingVpn << PAGE_SHIFT)
|
|
|
|
#define MA_GetEndingAddress(_MemoryArea) (((_MemoryArea)->VadNode.EndingVpn + 1) << PAGE_SHIFT)
|
2015-05-16 20:10:03 +00:00
|
|
|
|
2005-01-02 17:55:06 +00:00
|
|
|
typedef struct _MEMORY_AREA
|
1998-09-05 17:34:23 +00:00
|
|
|
{
|
2015-05-16 20:10:41 +00:00
|
|
|
MMVAD VadNode;
|
2017-08-18 07:13:34 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG Type;
|
2005-11-13 17:28:24 +00:00
|
|
|
ULONG Flags;
|
2005-09-14 01:05:50 +00:00
|
|
|
BOOLEAN DeleteInProgress;
|
2013-03-13 18:13:55 +00:00
|
|
|
ULONG Magic;
|
2010-10-05 05:07:13 +00:00
|
|
|
PVOID Vad;
|
2020-10-23 14:44:24 +00:00
|
|
|
|
|
|
|
struct
|
2002-06-11 22:09:03 +00:00
|
|
|
{
|
2021-02-02 09:06:00 +00:00
|
|
|
LONGLONG ViewOffset;
|
2020-10-23 14:44:24 +00:00
|
|
|
PMM_SECTION_SEGMENT Segment;
|
|
|
|
LIST_ENTRY RegionListHead;
|
|
|
|
} SectionData;
|
1998-10-05 04:01:30 +00:00
|
|
|
} MEMORY_AREA, *PMEMORY_AREA;
|
1998-09-05 17:34:23 +00:00
|
|
|
|
[NTOS]: Implement MiDecrementReferenceCount and rewrite large parts of the ProbeAndLock/Unlock MDL API to fully use ARM3 APIs, dropping MmReference/DereferencePage behind.
[NTOS]: Fix many MDL API bugs: correctly check for I/O pages, use LIST_HEAD instead of -1, track system-wide locked pages, use the process working set lock instead of the address space lock, add check for cross-ring MDL mappings, and make some small optimizations.
[NTOS]: Make some more fixes in MmAllocatePagesForMdl, MmFreeMdlPages to make the PFN entries more "correct".
[NTOS]: Had a little breakthrough: instead of complicating our lives and hiding certain ReactOS-Mm fields inside legitimate ARM3/MMPFN fields, differentiate between "legacy" (RosMm) and ARM3 pages. The legacy allocator (MmAllocPage/MmRequestPageMemoryConsumer) will use the non-paged pool to allocate a MMROSPFN add-on (8 bytes), in which the RMAP list head and SWAPENTRY are stored. When a legacy "free" is done, this data is deleted. Additionally, we can now tell apart between ARM3 and RosMm pages, so appropriate ASSERTs have been added to make sure the two never cross paths (which should safely let us use all the PFN fields now and implement working sets, etc...). I don't know why I didn't think of this sooner.
svn path=/trunk/; revision=49201
2010-10-19 04:30:48 +00:00
|
|
|
typedef struct _MM_RMAP_ENTRY
|
|
|
|
{
|
|
|
|
struct _MM_RMAP_ENTRY* Next;
|
|
|
|
PEPROCESS Process;
|
|
|
|
PVOID Address;
|
|
|
|
#if DBG
|
|
|
|
PVOID Caller;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
MM_RMAP_ENTRY, *PMM_RMAP_ENTRY;
|
|
|
|
|
2010-11-02 15:05:37 +00:00
|
|
|
#if MI_TRACE_PFNS
|
|
|
|
extern ULONG MI_PFN_CURRENT_USAGE;
|
|
|
|
extern CHAR MI_PFN_CURRENT_PROCESS_NAME[16];
|
|
|
|
#define MI_SET_USAGE(x) MI_PFN_CURRENT_USAGE = x
|
2021-03-30 14:20:25 +00:00
|
|
|
#define MI_SET_PROCESS2(x) memcpy(MI_PFN_CURRENT_PROCESS_NAME, x, min(sizeof(x), sizeof(MI_PFN_CURRENT_PROCESS_NAME)))
|
|
|
|
FORCEINLINE
|
|
|
|
void
|
|
|
|
MI_SET_PROCESS(PEPROCESS Process)
|
|
|
|
{
|
|
|
|
if (!Process)
|
|
|
|
MI_SET_PROCESS2("Kernel");
|
|
|
|
else if (Process == (PEPROCESS)1)
|
|
|
|
MI_SET_PROCESS2("Hydra");
|
|
|
|
else
|
|
|
|
MI_SET_PROCESS2(Process->ImageFileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
void
|
|
|
|
MI_SET_PROCESS_USTR(PUNICODE_STRING ustr)
|
|
|
|
{
|
|
|
|
PWSTR pos, strEnd;
|
2021-06-24 14:35:00 +00:00
|
|
|
ULONG i;
|
2021-03-30 14:20:25 +00:00
|
|
|
|
|
|
|
if (!ustr->Buffer || ustr->Length == 0)
|
|
|
|
{
|
|
|
|
MI_PFN_CURRENT_PROCESS_NAME[0] = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = strEnd = &ustr->Buffer[ustr->Length / sizeof(WCHAR)];
|
|
|
|
while ((*pos != L'\\') && (pos > ustr->Buffer))
|
|
|
|
pos--;
|
|
|
|
|
|
|
|
if (*pos == L'\\')
|
|
|
|
pos++;
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(MI_PFN_CURRENT_PROCESS_NAME) && pos <= strEnd; i++, pos++)
|
|
|
|
MI_PFN_CURRENT_PROCESS_NAME[i] = (CHAR)*pos;
|
|
|
|
}
|
2010-11-02 15:05:37 +00:00
|
|
|
#else
|
|
|
|
#define MI_SET_USAGE(x)
|
2021-03-30 14:20:25 +00:00
|
|
|
#define MI_SET_PROCESS(x)
|
2010-11-02 15:05:37 +00:00
|
|
|
#define MI_SET_PROCESS2(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef enum _MI_PFN_USAGES
|
|
|
|
{
|
|
|
|
MI_USAGE_NOT_SET = 0,
|
|
|
|
MI_USAGE_PAGED_POOL,
|
|
|
|
MI_USAGE_NONPAGED_POOL,
|
|
|
|
MI_USAGE_NONPAGED_POOL_EXPANSION,
|
|
|
|
MI_USAGE_KERNEL_STACK,
|
|
|
|
MI_USAGE_KERNEL_STACK_EXPANSION,
|
|
|
|
MI_USAGE_SYSTEM_PTE,
|
|
|
|
MI_USAGE_VAD,
|
|
|
|
MI_USAGE_PEB_TEB,
|
|
|
|
MI_USAGE_SECTION,
|
|
|
|
MI_USAGE_PAGE_TABLE,
|
|
|
|
MI_USAGE_PAGE_DIRECTORY,
|
|
|
|
MI_USAGE_LEGACY_PAGE_DIRECTORY,
|
|
|
|
MI_USAGE_DRIVER_PAGE,
|
|
|
|
MI_USAGE_CONTINOUS_ALLOCATION,
|
|
|
|
MI_USAGE_MDL,
|
|
|
|
MI_USAGE_DEMAND_ZERO,
|
|
|
|
MI_USAGE_ZERO_LOOP,
|
|
|
|
MI_USAGE_CACHE,
|
|
|
|
MI_USAGE_PFN_DATABASE,
|
|
|
|
MI_USAGE_BOOT_DRIVER,
|
|
|
|
MI_USAGE_INIT_MEMORY,
|
2021-03-30 14:20:25 +00:00
|
|
|
MI_USAGE_PAGE_FILE,
|
|
|
|
MI_USAGE_COW,
|
|
|
|
MI_USAGE_WSLE,
|
2010-11-02 15:05:37 +00:00
|
|
|
MI_USAGE_FREE_PAGE
|
|
|
|
} MI_PFN_USAGES;
|
|
|
|
|
2009-06-27 09:54:56 +00:00
|
|
|
//
|
|
|
|
// These two mappings are actually used by Windows itself, based on the ASSERTS
|
|
|
|
//
|
|
|
|
#define StartOfAllocation ReadInProgress
|
|
|
|
#define EndOfAllocation WriteInProgress
|
|
|
|
|
2009-06-21 03:57:42 +00:00
|
|
|
typedef struct _MMPFNENTRY
|
2008-02-14 23:39:31 +00:00
|
|
|
{
|
2009-06-21 03:57:42 +00:00
|
|
|
USHORT Modified:1;
|
|
|
|
USHORT ReadInProgress:1; // StartOfAllocation
|
|
|
|
USHORT WriteInProgress:1; // EndOfAllocation
|
2010-09-28 22:41:46 +00:00
|
|
|
USHORT PrototypePte:1;
|
|
|
|
USHORT PageColor:4;
|
|
|
|
USHORT PageLocation:3;
|
2009-06-21 03:57:42 +00:00
|
|
|
USHORT RemovalRequested:1;
|
2010-09-28 22:41:46 +00:00
|
|
|
USHORT CacheAttribute:2;
|
2009-06-21 03:57:42 +00:00
|
|
|
USHORT Rom:1;
|
2014-03-11 22:51:22 +00:00
|
|
|
USHORT ParityError:1;
|
2009-06-21 03:57:42 +00:00
|
|
|
} MMPFNENTRY;
|
|
|
|
|
2014-03-11 22:51:22 +00:00
|
|
|
// Mm internal
|
2009-06-21 03:57:42 +00:00
|
|
|
typedef struct _MMPFN
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
2010-09-28 22:41:46 +00:00
|
|
|
PFN_NUMBER Flink;
|
2014-02-08 15:54:38 +00:00
|
|
|
ULONG WsIndex;
|
2009-06-21 03:57:42 +00:00
|
|
|
PKEVENT Event;
|
|
|
|
NTSTATUS ReadStatus;
|
|
|
|
SINGLE_LIST_ENTRY NextStackPfn;
|
2014-02-08 15:54:38 +00:00
|
|
|
|
|
|
|
// HACK for ROSPFN
|
|
|
|
SWAPENTRY SwapEntry;
|
2009-06-21 03:57:42 +00:00
|
|
|
} u1;
|
2010-09-28 22:41:46 +00:00
|
|
|
PMMPTE PteAddress;
|
2008-02-14 23:39:31 +00:00
|
|
|
union
|
|
|
|
{
|
2009-06-21 03:57:42 +00:00
|
|
|
PFN_NUMBER Blink;
|
2010-09-28 22:41:46 +00:00
|
|
|
ULONG_PTR ShareCount;
|
2009-06-21 03:57:42 +00:00
|
|
|
} u2;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2014-02-08 15:54:38 +00:00
|
|
|
USHORT ReferenceCount;
|
2009-06-21 03:57:42 +00:00
|
|
|
MMPFNENTRY e1;
|
|
|
|
};
|
2008-02-14 23:39:31 +00:00
|
|
|
struct
|
|
|
|
{
|
2009-06-21 03:57:42 +00:00
|
|
|
USHORT ReferenceCount;
|
|
|
|
USHORT ShortFlags;
|
|
|
|
} e2;
|
|
|
|
} u3;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
MMPTE OriginalPte;
|
2014-02-08 15:54:38 +00:00
|
|
|
LONG AweReferenceCount;
|
|
|
|
|
|
|
|
// HACK for ROSPFN
|
|
|
|
PMM_RMAP_ENTRY RmapListHead;
|
2008-02-14 23:39:31 +00:00
|
|
|
};
|
2009-06-21 03:57:42 +00:00
|
|
|
union
|
|
|
|
{
|
2010-09-28 22:41:46 +00:00
|
|
|
ULONG_PTR EntireFrame;
|
2009-06-21 03:57:42 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
ULONG_PTR PteFrame:25;
|
|
|
|
ULONG_PTR InPageError:1;
|
|
|
|
ULONG_PTR VerifierAllocation:1;
|
|
|
|
ULONG_PTR AweAllocation:1;
|
|
|
|
ULONG_PTR Priority:3;
|
|
|
|
ULONG_PTR MustBeCached:1;
|
|
|
|
};
|
|
|
|
} u4;
|
2010-11-02 15:05:37 +00:00
|
|
|
#if MI_TRACE_PFNS
|
|
|
|
MI_PFN_USAGES PfnUsage;
|
|
|
|
CHAR ProcessName[16];
|
2021-03-30 14:20:25 +00:00
|
|
|
#define MI_SET_PFN_PROCESS_NAME(pfn, x) memcpy(pfn->ProcessName, x, min(sizeof(x), sizeof(pfn->ProcessName)))
|
2021-06-24 14:35:00 +00:00
|
|
|
PVOID CallSite;
|
2010-11-02 15:05:37 +00:00
|
|
|
#endif
|
2014-02-08 17:45:19 +00:00
|
|
|
|
|
|
|
// HACK until WS lists are supported
|
|
|
|
MMWSLE Wsle;
|
2021-01-27 09:29:07 +00:00
|
|
|
struct _MMPFN* NextLRU;
|
|
|
|
struct _MMPFN* PreviousLRU;
|
2009-06-21 03:57:42 +00:00
|
|
|
} MMPFN, *PMMPFN;
|
2008-02-14 23:39:31 +00:00
|
|
|
|
2010-06-06 15:59:42 +00:00
|
|
|
extern PMMPFN MmPfnDatabase;
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2009-10-31 01:02:35 +00:00
|
|
|
typedef struct _MMPFNLIST
|
|
|
|
{
|
|
|
|
PFN_NUMBER Total;
|
|
|
|
MMLISTS ListName;
|
|
|
|
PFN_NUMBER Flink;
|
|
|
|
PFN_NUMBER Blink;
|
|
|
|
} MMPFNLIST, *PMMPFNLIST;
|
|
|
|
|
|
|
|
extern MMPFNLIST MmZeroedPageListHead;
|
|
|
|
extern MMPFNLIST MmFreePageListHead;
|
|
|
|
extern MMPFNLIST MmStandbyPageListHead;
|
|
|
|
extern MMPFNLIST MmModifiedPageListHead;
|
|
|
|
extern MMPFNLIST MmModifiedNoWritePageListHead;
|
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
typedef struct _MM_MEMORY_CONSUMER
|
|
|
|
{
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG PagesUsed;
|
|
|
|
ULONG PagesTarget;
|
|
|
|
NTSTATUS (*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed);
|
|
|
|
} MM_MEMORY_CONSUMER, *PMM_MEMORY_CONSUMER;
|
2004-08-01 07:24:59 +00:00
|
|
|
|
|
|
|
typedef struct _MM_REGION
|
|
|
|
{
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG Type;
|
|
|
|
ULONG Protect;
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
SIZE_T Length;
|
2005-09-14 01:05:50 +00:00
|
|
|
LIST_ENTRY RegionListEntry;
|
2004-08-01 07:24:59 +00:00
|
|
|
} MM_REGION, *PMM_REGION;
|
2003-05-17 19:16:39 +00:00
|
|
|
|
2014-03-11 22:51:22 +00:00
|
|
|
// Mm internal
|
2008-03-09 21:15:12 +00:00
|
|
|
/* Entry describing free pool memory */
|
|
|
|
typedef struct _MMFREE_POOL_ENTRY
|
|
|
|
{
|
|
|
|
LIST_ENTRY List;
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
PFN_COUNT Size;
|
2008-03-09 21:15:12 +00:00
|
|
|
ULONG Signature;
|
|
|
|
struct _MMFREE_POOL_ENTRY *Owner;
|
|
|
|
} MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY;
|
|
|
|
|
2010-08-29 19:27:58 +00:00
|
|
|
/* Signature of a freed block */
|
|
|
|
#define MM_FREE_POOL_SIGNATURE 'ARM3'
|
|
|
|
|
2008-03-09 21:15:12 +00:00
|
|
|
/* Paged pool information */
|
|
|
|
typedef struct _MM_PAGED_POOL_INFO
|
2008-11-30 19:28:11 +00:00
|
|
|
{
|
2008-03-09 21:15:12 +00:00
|
|
|
PRTL_BITMAP PagedPoolAllocationMap;
|
|
|
|
PRTL_BITMAP EndOfPagedPoolBitmap;
|
|
|
|
PMMPTE FirstPteForPagedPool;
|
|
|
|
PMMPTE LastPteForPagedPool;
|
2010-11-24 15:21:45 +00:00
|
|
|
PMMPDE NextPdeForPagedPoolExpansion;
|
2008-03-09 21:15:12 +00:00
|
|
|
ULONG PagedPoolHint;
|
|
|
|
SIZE_T PagedPoolCommit;
|
|
|
|
SIZE_T AllocatedPagedPool;
|
|
|
|
} MM_PAGED_POOL_INFO, *PMM_PAGED_POOL_INFO;
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
extern MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM];
|
2005-06-25 17:01:17 +00:00
|
|
|
|
2018-08-13 05:52:05 +00:00
|
|
|
/* Page file information */
|
|
|
|
typedef struct _MMPAGING_FILE
|
|
|
|
{
|
2018-08-16 12:04:27 +00:00
|
|
|
PFN_NUMBER Size;
|
2018-08-16 11:50:16 +00:00
|
|
|
PFN_NUMBER MaximumSize;
|
|
|
|
PFN_NUMBER MinimumSize;
|
2018-08-16 12:04:27 +00:00
|
|
|
PFN_NUMBER FreeSpace;
|
|
|
|
PFN_NUMBER CurrentUsage;
|
2018-08-16 11:41:16 +00:00
|
|
|
PFILE_OBJECT FileObject;
|
2018-08-13 06:24:39 +00:00
|
|
|
UNICODE_STRING PageFileName;
|
2018-08-16 12:04:27 +00:00
|
|
|
PRTL_BITMAP Bitmap;
|
2018-08-16 11:41:16 +00:00
|
|
|
HANDLE FileHandle;
|
2018-08-13 05:52:05 +00:00
|
|
|
}
|
|
|
|
MMPAGING_FILE, *PMMPAGING_FILE;
|
|
|
|
|
|
|
|
extern PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES];
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
typedef VOID
|
|
|
|
(*PMM_ALTER_REGION_FUNC)(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID BaseAddress,
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
SIZE_T Length,
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG OldType,
|
|
|
|
ULONG OldProtect,
|
|
|
|
ULONG NewType,
|
|
|
|
ULONG NewProtect
|
|
|
|
);
|
|
|
|
|
|
|
|
typedef VOID
|
|
|
|
(*PMM_FREE_PAGE_FUNC)(
|
|
|
|
PVOID Context,
|
|
|
|
PMEMORY_AREA MemoryArea,
|
|
|
|
PVOID Address,
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER Page,
|
2005-09-14 01:05:50 +00:00
|
|
|
SWAPENTRY SwapEntry,
|
|
|
|
BOOLEAN Dirty
|
|
|
|
);
|
2005-06-25 17:01:17 +00:00
|
|
|
|
2009-10-13 19:45:40 +00:00
|
|
|
//
|
|
|
|
// Mm copy support for Kd
|
|
|
|
//
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmDbgCopyMemory(
|
|
|
|
IN ULONG64 Address,
|
|
|
|
IN PVOID Buffer,
|
|
|
|
IN ULONG Size,
|
|
|
|
IN ULONG Flags
|
|
|
|
);
|
|
|
|
|
2009-11-08 01:13:49 +00:00
|
|
|
//
|
|
|
|
// Determines if a given address is a session address
|
|
|
|
//
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmIsSessionAddress(
|
|
|
|
IN PVOID Address
|
|
|
|
);
|
|
|
|
|
2012-08-01 07:54:37 +00:00
|
|
|
ULONG
|
|
|
|
NTAPI
|
|
|
|
MmGetSessionId(
|
|
|
|
IN PEPROCESS Process
|
|
|
|
);
|
|
|
|
|
2013-09-22 18:47:36 +00:00
|
|
|
ULONG
|
|
|
|
NTAPI
|
|
|
|
MmGetSessionIdEx(
|
|
|
|
IN PEPROCESS Process
|
|
|
|
);
|
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
/* marea.c *******************************************************************/
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-01-02 17:55:06 +00:00
|
|
|
MmCreateMemoryArea(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG Type,
|
|
|
|
PVOID *BaseAddress,
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
SIZE_T Length,
|
2005-11-13 17:28:24 +00:00
|
|
|
ULONG Protection,
|
2005-09-14 01:05:50 +00:00
|
|
|
PMEMORY_AREA *Result,
|
2005-11-13 17:28:24 +00:00
|
|
|
ULONG AllocationFlags,
|
2013-11-26 21:38:02 +00:00
|
|
|
ULONG AllocationGranularity
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
PMEMORY_AREA
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-01-02 19:14:52 +00:00
|
|
|
MmLocateMemoryAreaByAddress(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address
|
|
|
|
);
|
2005-01-02 17:55:06 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-01-02 17:55:06 +00:00
|
|
|
MmFreeMemoryArea(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
PMEMORY_AREA MemoryArea,
|
|
|
|
PMM_FREE_PAGE_FUNC FreePage,
|
|
|
|
PVOID FreePageContext
|
|
|
|
);
|
2005-01-02 17:55:06 +00:00
|
|
|
|
2015-05-17 00:34:59 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiRosCleanupMemoryArea(
|
|
|
|
PEPROCESS Process,
|
|
|
|
PMMVAD Vad);
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
PMEMORY_AREA
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-01-02 19:14:52 +00:00
|
|
|
MmLocateMemoryAreaByRegion(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address,
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
SIZE_T Length
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2005-01-02 17:55:06 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-01-02 17:55:06 +00:00
|
|
|
MmFindGap(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
SIZE_T Length,
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG_PTR Granularity,
|
|
|
|
BOOLEAN TopDown
|
|
|
|
);
|
2005-01-02 17:55:06 +00:00
|
|
|
|
2013-03-13 18:13:55 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiRosCheckMemoryAreas(
|
|
|
|
PMMSUPPORT AddressSpace);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiCheckAllProcessMemoryAreas(VOID);
|
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
/* npool.c *******************************************************************/
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiInitializeNonPagedPool(VOID);
|
1999-12-02 20:53:55 +00:00
|
|
|
|
2008-03-09 21:15:12 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
|
|
|
MiAllocatePoolPages(
|
|
|
|
IN POOL_TYPE PoolType,
|
|
|
|
IN SIZE_T SizeInBytes
|
|
|
|
);
|
|
|
|
|
|
|
|
POOL_TYPE
|
|
|
|
NTAPI
|
|
|
|
MmDeterminePoolType(
|
|
|
|
IN PVOID VirtualAddress
|
|
|
|
);
|
|
|
|
|
|
|
|
ULONG
|
|
|
|
NTAPI
|
|
|
|
MiFreePoolPages(
|
|
|
|
IN PVOID StartingAddress
|
|
|
|
);
|
|
|
|
|
2004-08-08 20:33:17 +00:00
|
|
|
/* pool.c *******************************************************************/
|
|
|
|
|
2021-12-30 19:57:14 +00:00
|
|
|
_Requires_lock_held_(PspQuotaLock)
|
2004-08-08 20:33:17 +00:00
|
|
|
BOOLEAN
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2021-12-30 19:57:14 +00:00
|
|
|
MmRaisePoolQuota(
|
|
|
|
_In_ POOL_TYPE PoolType,
|
|
|
|
_In_ SIZE_T CurrentMaxQuota,
|
|
|
|
_Out_ PSIZE_T NewMaxQuota
|
|
|
|
);
|
|
|
|
|
|
|
|
_Requires_lock_held_(PspQuotaLock)
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmReturnPoolQuota(
|
|
|
|
_In_ POOL_TYPE PoolType,
|
|
|
|
_In_ SIZE_T QuotaToReturn
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-08 20:33:17 +00:00
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
/* mdl.c *********************************************************************/
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmBuildMdlFromPages(
|
|
|
|
PMDL Mdl,
|
2010-07-15 22:50:12 +00:00
|
|
|
PPFN_NUMBER Pages
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
|
|
|
/* mminit.c ******************************************************************/
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmInit1(
|
2008-02-15 01:19:46 +00:00
|
|
|
VOID
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2007-01-25 17:51:45 +00:00
|
|
|
BOOLEAN
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
2007-01-25 17:51:45 +00:00
|
|
|
MmInitSystem(IN ULONG Phase,
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* pagefile.c ****************************************************************/
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
SWAPENTRY
|
|
|
|
NTAPI
|
|
|
|
MmAllocSwapPage(VOID);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmFreeSwapPage(SWAPENTRY Entry);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmInitPagingFile(VOID);
|
1999-11-25 10:47:58 +00:00
|
|
|
|
2010-11-22 22:18:02 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject);
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmReadFromSwapPage(
|
|
|
|
SWAPENTRY SwapEntry,
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER Page
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmWriteToSwapPage(
|
|
|
|
SWAPENTRY SwapEntry,
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER Page
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmShowOutOfSpaceMessagePagingFile(VOID);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2014-08-06 21:53:09 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MiReadPageFile(
|
|
|
|
_In_ PFN_NUMBER Page,
|
|
|
|
_In_ ULONG PageFileIndex,
|
|
|
|
_In_ ULONG_PTR PageFileOffset);
|
|
|
|
|
2005-04-18 00:42:31 +00:00
|
|
|
/* process.c ****************************************************************/
|
|
|
|
|
|
|
|
NTSTATUS
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
- PS_UNKNOWN_VALUE determines if the process should be created with large pages: rename to PS_LARGE_PAGES
- Do Address Space initialization as per "Windows Internals II" slides, either for the Boot, System, Cloned User or New User Process cases.
- Rename MmCreateProcessAddressSpace to MmInitializeProcessAddressSpace, and MmCopyMmInfo to MmCreateProcessAddressSpace. What ReactOS did is correct as per "Windows Internals II", but the names were inverted.
- Clone the Object Table if we are the boot process, and only initialize part of the address space (since we don't need things like guard page, TEB, etc), however, do initialize and map the shared user data section.
- Make the initial system process and idle process share the same page directory instead of creating a new one.
- Use the same priority class as the parent process, if the process was in the idle or below-normal priority class.
- Only duplicate handles if the caller requested it, instead of always duplicating the process's handles!
- Generate a null image file name for system processes.
- Rename ObpCreateHandleTable to ObInitProcess and better handle race and out-of-memory conditions. Detect if auditing required, but don't do anything about it.
- Initialize the Idle/System process address space much earlier in the boot process, in MmInitSystem.
Thanks to Alex for providing various information, and answering all my questions.
svn path=/trunk/; revision=29223
2007-09-26 20:55:26 +00:00
|
|
|
MmInitializeProcessAddressSpace(
|
2006-07-09 18:54:13 +00:00
|
|
|
IN PEPROCESS Process,
|
2007-09-27 18:07:44 +00:00
|
|
|
IN PEPROCESS Clone OPTIONAL,
|
- PS_UNKNOWN_VALUE determines if the process should be created with large pages: rename to PS_LARGE_PAGES
- Do Address Space initialization as per "Windows Internals II" slides, either for the Boot, System, Cloned User or New User Process cases.
- Rename MmCreateProcessAddressSpace to MmInitializeProcessAddressSpace, and MmCopyMmInfo to MmCreateProcessAddressSpace. What ReactOS did is correct as per "Windows Internals II", but the names were inverted.
- Clone the Object Table if we are the boot process, and only initialize part of the address space (since we don't need things like guard page, TEB, etc), however, do initialize and map the shared user data section.
- Make the initial system process and idle process share the same page directory instead of creating a new one.
- Use the same priority class as the parent process, if the process was in the idle or below-normal priority class.
- Only duplicate handles if the caller requested it, instead of always duplicating the process's handles!
- Generate a null image file name for system processes.
- Rename ObpCreateHandleTable to ObInitProcess and better handle race and out-of-memory conditions. Detect if auditing required, but don't do anything about it.
- Initialize the Idle/System process address space much earlier in the boot process, in MmInitSystem.
Thanks to Alex for providing various information, and answering all my questions.
svn path=/trunk/; revision=29223
2007-09-26 20:55:26 +00:00
|
|
|
IN PVOID Section OPTIONAL,
|
2007-09-27 18:07:44 +00:00
|
|
|
IN OUT PULONG Flags,
|
2006-07-27 00:22:36 +00:00
|
|
|
IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-04-18 00:42:31 +00:00
|
|
|
NTSTATUS
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2009-10-15 05:56:41 +00:00
|
|
|
MmCreatePeb(
|
|
|
|
IN PEPROCESS Process,
|
|
|
|
IN PINITIAL_PEB InitialPeb,
|
|
|
|
OUT PPEB *BasePeb
|
|
|
|
);
|
2005-04-18 00:42:31 +00:00
|
|
|
|
2009-10-15 05:56:41 +00:00
|
|
|
NTSTATUS
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-09-14 01:05:50 +00:00
|
|
|
MmCreateTeb(
|
2009-10-15 05:56:41 +00:00
|
|
|
IN PEPROCESS Process,
|
|
|
|
IN PCLIENT_ID ClientId,
|
|
|
|
IN PINITIAL_TEB InitialTeb,
|
|
|
|
OUT PTEB* BaseTeb
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-04-22 12:52:25 +00:00
|
|
|
VOID
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-09-14 01:05:50 +00:00
|
|
|
MmDeleteTeb(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2006-07-09 18:54:13 +00:00
|
|
|
PTEB Teb
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2005-04-22 12:52:25 +00:00
|
|
|
|
2006-07-09 18:54:13 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmCleanProcessAddressSpace(IN PEPROCESS Process);
|
|
|
|
|
2021-04-26 16:18:23 +00:00
|
|
|
VOID
|
2006-07-09 18:54:13 +00:00
|
|
|
NTAPI
|
|
|
|
MmDeleteProcessAddressSpace(IN PEPROCESS Process);
|
|
|
|
|
|
|
|
ULONG
|
|
|
|
NTAPI
|
|
|
|
MmGetSessionLocaleId(VOID);
|
|
|
|
|
2006-07-21 19:28:38 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmSetMemoryPriorityProcess(
|
|
|
|
IN PEPROCESS Process,
|
|
|
|
IN UCHAR MemoryPriority
|
|
|
|
);
|
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
/* i386/pfault.c *************************************************************/
|
2000-04-02 13:32:43 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmPageFault(
|
|
|
|
ULONG Cs,
|
|
|
|
PULONG Eip,
|
|
|
|
PULONG Eax,
|
|
|
|
ULONG Cr2,
|
|
|
|
ULONG ErrorCode
|
|
|
|
);
|
2011-09-26 21:57:40 +00:00
|
|
|
|
|
|
|
/* special.c *****************************************************************/
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
2014-10-22 13:04:57 +00:00
|
|
|
MiInitializeSpecialPool(VOID);
|
2011-09-26 21:57:40 +00:00
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmUseSpecialPool(
|
|
|
|
IN SIZE_T NumberOfBytes,
|
|
|
|
IN ULONG Tag);
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmIsSpecialPoolAddress(
|
|
|
|
IN PVOID P);
|
|
|
|
|
2014-10-22 13:13:31 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmIsSpecialPoolAddressFree(
|
|
|
|
IN PVOID P);
|
|
|
|
|
2011-09-26 21:57:40 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
|
|
|
MmAllocateSpecialPool(
|
|
|
|
IN SIZE_T NumberOfBytes,
|
|
|
|
IN ULONG Tag,
|
|
|
|
IN POOL_TYPE PoolType,
|
|
|
|
IN ULONG SpecialType);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmFreeSpecialPool(
|
|
|
|
IN PVOID P);
|
2000-04-07 02:24:03 +00:00
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
/* mm.c **********************************************************************/
|
2000-04-07 02:24:03 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmAccessFault(
|
2018-01-01 14:25:45 +00:00
|
|
|
IN ULONG FaultCode,
|
- Fix critical bugs in exception handling: Unwinding was completely broken, using the wrong SEH protector to detect collided unwinding. The correct protector itself also had a broken check.
- Fix architectural bug in the entire TrapFrame<->Context conversion system and Ring Privilege Transitions (Inter-ring and intra-ring) which was lacking proper sanitation and validation of segments, flags and debug registers. Among other things, IOPL is now respected, CS is not KGDT_R0_CODE | RPL_MASK anymore, and the GPF code is now properly being called. This completely fixes exception handling being totally broken and crashing firefox installer, mirc, and other applications.
- Rewrite the page fault handler base code in assembly instead of relying on a broken C routine. Detect VDM, V8086, detecting expected/normal fault in ExpInterlockedPopEntrySList and faults in the system handler code. Rewrite MmAccessFault to be the main function that calls out to other sub-fault functions, and use the same prototype as NT.
- Fix the KGDT boot table to have proper granularity and big flags, and extend it to 256 entries.
- Create proper thread context in RtlInitializeContext and cleanup Rtl Thread routines.
- Remove all int3 and breakpoints from trap handlers, and replace them with a much better "UNHANDLED_PATH" macro which freezes the system, beeps, and displays a message with the line of code that's unhandled. This is to clearly tell the user that something is unhandled, instead of nesting infinite exceptions due to the int3.
- Fix a bug in INT_PROLOG.
- Sanitize EFLAGS and Code Segments in KeContextToTrapFrame and KeTrapFrameToContext.
- Implement KiUpdateDr7 and KiRecordDr7 as well as DR_MASK and other DR-validation macros and functions to protect against DR-vulnerabilites as well as to properly account for each active hardware breakpoint in a per-thread fashion by using the dispatcher header.
- Allow CR0_EM when running in a VDM.
- Fix FPU/NPX Register handling in KeContextToTrapFrame and KeTrapFrameToContext, and also speed it up by manual copying instead of a memory move.
- Properly give IOPL 3 to user-mode threads if they requested it.
- Detect GPF during GPF.
- Detect pagefault with a trap-frame spread over two or more pages and nested.
- Properly sanitize and set correct trap frame in KiInitailizeUserApc.
- Return STATUS_ACCESS_VIOLATION during page faults instead of STATUS_UNSUCESSFUL.
- Fix assert in VdmSwapContext, as well as Code Selector check which was broken.
- Fix delayed object deletion (ObDeferDeleteObject) and the Ob Repear Routine and list.
- Update Kernel Fun.
- BUGBUG: Temporaily hack VMWare to detection to always detect VMWare.
svn path=/trunk/; revision=25238
2006-12-29 18:49:00 +00:00
|
|
|
IN PVOID Address,
|
|
|
|
IN KPROCESSOR_MODE Mode,
|
|
|
|
IN PVOID TrapInformation
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2000-07-04 08:52:47 +00:00
|
|
|
|
2005-04-18 00:42:31 +00:00
|
|
|
/* process.c *****************************************************************/
|
|
|
|
|
|
|
|
PVOID
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2007-09-24 14:01:54 +00:00
|
|
|
MmCreateKernelStack(BOOLEAN GuiStack, UCHAR Node);
|
2005-04-18 00:42:31 +00:00
|
|
|
|
|
|
|
VOID
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-05-09 01:38:29 +00:00
|
|
|
MmDeleteKernelStack(PVOID Stack,
|
2005-04-18 00:42:31 +00:00
|
|
|
BOOLEAN GuiStack);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2022-09-12 12:22:52 +00:00
|
|
|
/* balance.c / pagefile.c******************************************************/
|
|
|
|
|
2023-07-22 21:48:58 +00:00
|
|
|
FORCEINLINE VOID UpdateTotalCommittedPages(LONG Delta)
|
2022-09-12 12:22:52 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Add up all the used "Committed" memory + pagefile.
|
|
|
|
* Not sure this is right. 8^\
|
|
|
|
* MmTotalCommittedPages should be adjusted consistently with
|
|
|
|
* other counters at different places.
|
|
|
|
*
|
|
|
|
MmTotalCommittedPages = MiMemoryConsumers[MC_SYSTEM].PagesUsed +
|
|
|
|
MiMemoryConsumers[MC_USER].PagesUsed +
|
|
|
|
MiUsedSwapPages;
|
|
|
|
*/
|
2023-07-22 21:48:58 +00:00
|
|
|
|
2022-09-12 12:22:52 +00:00
|
|
|
/* Update Commitment */
|
|
|
|
SIZE_T TotalCommittedPages = InterlockedExchangeAddSizeT(&MmTotalCommittedPages, Delta) + Delta;
|
|
|
|
|
|
|
|
/* Update Peak = max(Peak, Total) in a lockless way */
|
|
|
|
SIZE_T PeakCommitment = MmPeakCommitment;
|
|
|
|
while (TotalCommittedPages > PeakCommitment &&
|
|
|
|
InterlockedCompareExchangeSizeT(&MmPeakCommitment, TotalCommittedPages, PeakCommitment) != PeakCommitment)
|
|
|
|
{
|
|
|
|
PeakCommitment = MmPeakCommitment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-25 18:45:23 +00:00
|
|
|
/* balance.c *****************************************************************/
|
2003-06-27 21:28:30 +00:00
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmInitializeMemoryConsumer(
|
|
|
|
ULONG Consumer,
|
|
|
|
NTSTATUS (*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed)
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2007-10-19 23:21:45 +00:00
|
|
|
VOID
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
|
|
|
MmInitializeBalancer(
|
|
|
|
ULONG NrAvailablePages,
|
|
|
|
ULONG NrSystemPages
|
|
|
|
);
|
2001-03-13 16:25:55 +00:00
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
NTSTATUS
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
|
|
|
MmReleasePageMemoryConsumer(
|
|
|
|
ULONG Consumer,
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER Page
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmRequestPageMemoryConsumer(
|
|
|
|
ULONG Consumer,
|
|
|
|
BOOLEAN MyWait,
|
2010-07-15 22:50:12 +00:00
|
|
|
PPFN_NUMBER AllocatedPage
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiInitBalancerThread(VOID);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmRebalanceMemoryConsumers(VOID);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
|
|
|
/* rmap.c **************************************************************/
|
2021-01-28 14:42:12 +00:00
|
|
|
#define RMAP_SEGMENT_MASK ~((ULONG_PTR)0xff)
|
|
|
|
#define RMAP_IS_SEGMENT(x) (((ULONG_PTR)(x) & RMAP_SEGMENT_MASK) == RMAP_SEGMENT_MASK)
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmSetRmapListHeadPage(
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER Page,
|
2005-09-14 01:05:50 +00:00
|
|
|
struct _MM_RMAP_ENTRY* ListHead
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
struct _MM_RMAP_ENTRY*
|
|
|
|
NTAPI
|
2010-07-15 22:50:12 +00:00
|
|
|
MmGetRmapListHeadPage(PFN_NUMBER Page);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmInsertRmap(
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER Page,
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmDeleteAllRmaps(
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER Page,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Context,
|
2006-05-18 20:32:17 +00:00
|
|
|
VOID (*DeleteMapping)(PVOID Context, struct _EPROCESS *Process, PVOID Address)
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmDeleteRmap(
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER Page,
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmInitializeRmapList(VOID);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2010-07-15 22:50:12 +00:00
|
|
|
MmPageOutPhysicalAddress(PFN_NUMBER Page);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2021-01-27 09:29:07 +00:00
|
|
|
PMM_SECTION_SEGMENT
|
|
|
|
NTAPI
|
|
|
|
MmGetSectionAssociation(PFN_NUMBER Page,
|
|
|
|
PLARGE_INTEGER Offset);
|
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
/* freelist.c **********************************************************/
|
2021-07-23 15:14:47 +00:00
|
|
|
_IRQL_raises_(DISPATCH_LEVEL)
|
|
|
|
_IRQL_requires_max_(DISPATCH_LEVEL)
|
|
|
|
_Requires_lock_not_held_(MmPfnLock)
|
|
|
|
_Acquires_lock_(MmPfnLock)
|
|
|
|
_IRQL_saves_
|
2017-11-21 22:33:42 +00:00
|
|
|
FORCEINLINE
|
|
|
|
KIRQL
|
|
|
|
MiAcquirePfnLock(VOID)
|
|
|
|
{
|
|
|
|
return KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
|
|
|
}
|
|
|
|
|
2021-07-23 15:14:47 +00:00
|
|
|
_Requires_lock_held_(MmPfnLock)
|
|
|
|
_Releases_lock_(MmPfnLock)
|
|
|
|
_IRQL_requires_(DISPATCH_LEVEL)
|
2017-11-21 22:33:42 +00:00
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
|
|
|
MiReleasePfnLock(
|
2021-07-23 15:14:47 +00:00
|
|
|
_In_ _IRQL_restores_ KIRQL OldIrql)
|
2017-11-21 22:33:42 +00:00
|
|
|
{
|
|
|
|
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
|
|
|
|
}
|
|
|
|
|
2021-07-23 15:14:47 +00:00
|
|
|
_IRQL_requires_min_(DISPATCH_LEVEL)
|
|
|
|
_Requires_lock_not_held_(MmPfnLock)
|
|
|
|
_Acquires_lock_(MmPfnLock)
|
2017-11-21 22:36:34 +00:00
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
|
|
|
MiAcquirePfnLockAtDpcLevel(VOID)
|
|
|
|
{
|
|
|
|
PKSPIN_LOCK_QUEUE LockQueue;
|
|
|
|
|
|
|
|
ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);
|
|
|
|
LockQueue = &KeGetCurrentPrcb()->LockQueue[LockQueuePfnLock];
|
|
|
|
KeAcquireQueuedSpinLockAtDpcLevel(LockQueue);
|
|
|
|
}
|
|
|
|
|
2021-07-23 15:14:47 +00:00
|
|
|
_Requires_lock_held_(MmPfnLock)
|
|
|
|
_Releases_lock_(MmPfnLock)
|
|
|
|
_IRQL_requires_min_(DISPATCH_LEVEL)
|
2017-11-21 22:36:34 +00:00
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
|
|
|
MiReleasePfnLockFromDpcLevel(VOID)
|
|
|
|
{
|
|
|
|
PKSPIN_LOCK_QUEUE LockQueue;
|
|
|
|
|
|
|
|
LockQueue = &KeGetCurrentPrcb()->LockQueue[LockQueuePfnLock];
|
|
|
|
KeReleaseQueuedSpinLockFromDpcLevel(LockQueue);
|
|
|
|
ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);
|
|
|
|
}
|
|
|
|
|
2021-07-23 15:14:47 +00:00
|
|
|
#define MI_ASSERT_PFN_LOCK_HELD() NT_ASSERT((KeGetCurrentIrql() >= DISPATCH_LEVEL) && (MmPfnLock != 0))
|
2017-11-21 22:33:42 +00:00
|
|
|
|
2008-03-09 21:15:12 +00:00
|
|
|
FORCEINLINE
|
2009-06-21 03:57:42 +00:00
|
|
|
PMMPFN
|
2010-07-15 22:50:12 +00:00
|
|
|
MiGetPfnEntry(IN PFN_NUMBER Pfn)
|
2008-03-09 21:15:12 +00:00
|
|
|
{
|
2009-06-21 03:57:42 +00:00
|
|
|
PMMPFN Page;
|
- This is a HIGH RISK patch. It has been tested on multiple emulators and configurations but requires broader input.
- Implement several changes to PFN database management:
- The PTEs for the PFN Database are now created by ARM3. Unlike the old code which create PTE for every page on the machine, ARM3 only creates PTEs to account for pages that should be in the PFN database.
- A second related change is what "pages should be in the PFN database". Previously, reserved or otherwise non-existing (ie: holes) memory regions would get a PFN entry created and marked as "BIOS". This is wasteful and not compatible with Windows: there should not be PFN entries created at all.
- So we removed BIOS PFN entries, and now only create PTEs for valid pages as listed in the physical memory ranges.
- This allows machines with "holes" in their physical address space not to waste dozens of MBs of nonpaged pool
- Also saves memory on regular machines too, since 1-4MB worth of memory will now not be in the DB anymore
- To keep track of pages that are invalid/unknown/ignored, there is now a "PFN Bitmap". This bitmap has one bit set for each valid PFN in the database.
- And so, MiGetPfnEntry now also validates that, if there is a PFN Bitmap, the requested PFN is actually present in the database.
- This introduces a major functional change: device pages, reserved pages, and other BIOS pages cannot be referenced, shared, or managed in any meaningful way.
- We have attempted to fix parts of the OS that depended on this, but there may still be bugs.
- A known issue may be an assertion during reboot and/or shutdown in the hyperspace mapping function. It is currently safe to simply "cont" in the debugger a couple of times.
- We are working on a fix.
svn path=/trunk/; revision=42220
2009-07-25 21:35:31 +00:00
|
|
|
extern RTL_BITMAP MiPfnBitMap;
|
2008-05-12 20:48:48 +00:00
|
|
|
|
2008-03-09 21:15:12 +00:00
|
|
|
/* Make sure the PFN number is valid */
|
2009-06-21 04:14:49 +00:00
|
|
|
if (Pfn > MmHighestPhysicalPage) return NULL;
|
2011-07-25 00:01:29 +00:00
|
|
|
|
- This is a HIGH RISK patch. It has been tested on multiple emulators and configurations but requires broader input.
- Implement several changes to PFN database management:
- The PTEs for the PFN Database are now created by ARM3. Unlike the old code which create PTE for every page on the machine, ARM3 only creates PTEs to account for pages that should be in the PFN database.
- A second related change is what "pages should be in the PFN database". Previously, reserved or otherwise non-existing (ie: holes) memory regions would get a PFN entry created and marked as "BIOS". This is wasteful and not compatible with Windows: there should not be PFN entries created at all.
- So we removed BIOS PFN entries, and now only create PTEs for valid pages as listed in the physical memory ranges.
- This allows machines with "holes" in their physical address space not to waste dozens of MBs of nonpaged pool
- Also saves memory on regular machines too, since 1-4MB worth of memory will now not be in the DB anymore
- To keep track of pages that are invalid/unknown/ignored, there is now a "PFN Bitmap". This bitmap has one bit set for each valid PFN in the database.
- And so, MiGetPfnEntry now also validates that, if there is a PFN Bitmap, the requested PFN is actually present in the database.
- This introduces a major functional change: device pages, reserved pages, and other BIOS pages cannot be referenced, shared, or managed in any meaningful way.
- We have attempted to fix parts of the OS that depended on this, but there may still be bugs.
- A known issue may be an assertion during reboot and/or shutdown in the hyperspace mapping function. It is currently safe to simply "cont" in the debugger a couple of times.
- We are working on a fix.
svn path=/trunk/; revision=42220
2009-07-25 21:35:31 +00:00
|
|
|
/* Make sure this page actually has a PFN entry */
|
2011-06-06 19:08:39 +00:00
|
|
|
if ((MiPfnBitMap.Buffer) && !(RtlTestBit(&MiPfnBitMap, (ULONG)Pfn))) return NULL;
|
2008-03-09 21:15:12 +00:00
|
|
|
|
|
|
|
/* Get the entry */
|
2010-06-06 15:59:42 +00:00
|
|
|
Page = &MmPfnDatabase[Pfn];
|
2008-03-09 21:15:12 +00:00
|
|
|
|
|
|
|
/* Return it */
|
|
|
|
return Page;
|
|
|
|
};
|
|
|
|
|
2009-06-21 04:28:31 +00:00
|
|
|
FORCEINLINE
|
|
|
|
PFN_NUMBER
|
|
|
|
MiGetPfnEntryIndex(IN PMMPFN Pfn1)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// This will return the Page Frame Number (PFN) from the MMPFN
|
|
|
|
//
|
2010-06-06 15:59:42 +00:00
|
|
|
return Pfn1 - MmPfnDatabase;
|
2009-06-21 04:28:31 +00:00
|
|
|
}
|
|
|
|
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
2021-01-27 09:29:07 +00:00
|
|
|
MmGetLRUNextUserPage(PFN_NUMBER PreviousPage, BOOLEAN MoveToLast);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
|
|
|
MmGetLRUFirstUserPage(VOID);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2009-06-27 09:54:56 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2010-11-02 14:58:39 +00:00
|
|
|
MmDumpArmPfnDatabase(
|
|
|
|
IN BOOLEAN StatusOnly
|
2009-06-27 09:54:56 +00:00
|
|
|
);
|
|
|
|
|
2010-09-28 16:47:25 +00:00
|
|
|
VOID
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
2010-09-28 16:47:25 +00:00
|
|
|
MmZeroPageThread(
|
|
|
|
VOID
|
2006-10-05 16:14:28 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2009-03-10 00:31:14 +00:00
|
|
|
/* hypermap.c *****************************************************************/
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
2021-04-07 21:26:44 +00:00
|
|
|
MiMapPageInHyperSpace(IN PEPROCESS Process,
|
|
|
|
IN PFN_NUMBER Page,
|
|
|
|
IN PKIRQL OldIrql);
|
2001-04-04 22:21:32 +00:00
|
|
|
|
2009-03-10 00:31:14 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2021-04-07 21:26:44 +00:00
|
|
|
MiUnmapPageInHyperSpace(IN PEPROCESS Process,
|
|
|
|
IN PVOID Address,
|
|
|
|
IN KIRQL OldIrql);
|
2009-03-10 00:31:14 +00:00
|
|
|
|
|
|
|
PVOID
|
|
|
|
NTAPI
|
2011-12-19 18:44:47 +00:00
|
|
|
MiMapPagesInZeroSpace(IN PMMPFN Pfn1,
|
|
|
|
IN PFN_NUMBER NumberOfPages);
|
2009-06-23 09:34:45 +00:00
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress,
|
|
|
|
IN PFN_NUMBER NumberOfPages);
|
2009-03-10 00:31:14 +00:00
|
|
|
|
|
|
|
/* i386/page.c *********************************************************/
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmCreateVirtualMapping(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS* Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address,
|
|
|
|
ULONG flProtect,
|
2021-03-22 08:52:11 +00:00
|
|
|
PFN_NUMBER Page
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmCreateVirtualMappingUnsafe(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS* Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address,
|
|
|
|
ULONG flProtect,
|
2021-03-22 08:52:11 +00:00
|
|
|
PFN_NUMBER Page
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
|
|
|
|
2023-04-10 18:14:06 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmCreatePhysicalMapping(
|
|
|
|
_Inout_opt_ PEPROCESS Process,
|
|
|
|
_In_ PVOID Address,
|
|
|
|
_In_ ULONG flProtect,
|
|
|
|
_In_ PFN_NUMBER Page);
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG
|
|
|
|
NTAPI
|
|
|
|
MmGetPageProtect(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS* Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address);
|
2001-04-17 04:11:01 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmSetPageProtect(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS* Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address,
|
|
|
|
ULONG flProtect
|
|
|
|
);
|
2003-05-17 13:45:04 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmIsPagePresent(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS* Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address
|
|
|
|
);
|
2001-12-29 14:32:22 +00:00
|
|
|
|
2012-06-01 09:01:41 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmIsDisabledPage(
|
|
|
|
struct _EPROCESS* Process,
|
|
|
|
PVOID Address
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmInitGlobalKernelPageDirectory(VOID);
|
2004-04-22 01:57:49 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmDeletePageFileMapping(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address,
|
|
|
|
SWAPENTRY* SwapEntry
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmCreatePageFileMapping(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address,
|
|
|
|
SWAPENTRY SwapEntry
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2021-03-22 08:52:11 +00:00
|
|
|
VOID
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
2021-03-22 08:52:11 +00:00
|
|
|
MmGetPageFileMapping(
|
|
|
|
PEPROCESS Process,
|
|
|
|
PVOID Address,
|
|
|
|
SWAPENTRY *SwapEntry);
|
2001-12-31 01:53:46 +00:00
|
|
|
|
2021-03-22 08:52:11 +00:00
|
|
|
BOOLEAN
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
2021-03-22 08:52:11 +00:00
|
|
|
MmIsPageSwapEntry(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address
|
|
|
|
);
|
|
|
|
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
|
|
|
MmAllocPage(
|
2010-02-20 14:47:23 +00:00
|
|
|
ULONG Consumer
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
2010-07-15 22:50:12 +00:00
|
|
|
MmDereferencePage(PFN_NUMBER Page);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2010-07-15 22:50:12 +00:00
|
|
|
MmReferencePage(PFN_NUMBER Page);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG
|
|
|
|
NTAPI
|
2010-07-15 22:50:12 +00:00
|
|
|
MmGetReferenceCountPage(PFN_NUMBER Page);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
2010-07-15 22:50:12 +00:00
|
|
|
MmIsPageInUse(PFN_NUMBER Page);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmSetSavedSwapEntryPage(
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER Page,
|
2005-09-14 01:05:50 +00:00
|
|
|
SWAPENTRY SavedSwapEntry);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
SWAPENTRY
|
|
|
|
NTAPI
|
2010-07-15 22:50:12 +00:00
|
|
|
MmGetSavedSwapEntryPage(PFN_NUMBER Page);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmSetCleanPage(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2021-03-22 08:52:11 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmSetDirtyBit(PEPROCESS Process, PVOID Address, BOOLEAN Bit);
|
|
|
|
#define MmSetCleanPage(__P, __A) MmSetDirtyBit(__P, __A, FALSE)
|
|
|
|
#define MmSetDirtyPage(__P, __A) MmSetDirtyBit(__P, __A, TRUE)
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmDeletePageTable(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address
|
|
|
|
);
|
|
|
|
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
|
|
|
MmGetPfnForProcess(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
- PS_UNKNOWN_VALUE determines if the process should be created with large pages: rename to PS_LARGE_PAGES
- Do Address Space initialization as per "Windows Internals II" slides, either for the Boot, System, Cloned User or New User Process cases.
- Rename MmCreateProcessAddressSpace to MmInitializeProcessAddressSpace, and MmCopyMmInfo to MmCreateProcessAddressSpace. What ReactOS did is correct as per "Windows Internals II", but the names were inverted.
- Clone the Object Table if we are the boot process, and only initialize part of the address space (since we don't need things like guard page, TEB, etc), however, do initialize and map the shared user data section.
- Make the initial system process and idle process share the same page directory instead of creating a new one.
- Use the same priority class as the parent process, if the process was in the idle or below-normal priority class.
- Only duplicate handles if the caller requested it, instead of always duplicating the process's handles!
- Generate a null image file name for system processes.
- Rename ObpCreateHandleTable to ObInitProcess and better handle race and out-of-memory conditions. Detect if auditing required, but don't do anything about it.
- Initialize the Idle/System process address space much earlier in the boot process, in MmInitSystem.
Thanks to Alex for providing various information, and answering all my questions.
svn path=/trunk/; revision=29223
2007-09-26 20:55:26 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmCreateProcessAddressSpace(
|
|
|
|
IN ULONG MinWs,
|
|
|
|
IN PEPROCESS Dest,
|
2010-07-23 23:30:00 +00:00
|
|
|
IN PULONG_PTR DirectoryTableBase
|
- PS_UNKNOWN_VALUE determines if the process should be created with large pages: rename to PS_LARGE_PAGES
- Do Address Space initialization as per "Windows Internals II" slides, either for the Boot, System, Cloned User or New User Process cases.
- Rename MmCreateProcessAddressSpace to MmInitializeProcessAddressSpace, and MmCopyMmInfo to MmCreateProcessAddressSpace. What ReactOS did is correct as per "Windows Internals II", but the names were inverted.
- Clone the Object Table if we are the boot process, and only initialize part of the address space (since we don't need things like guard page, TEB, etc), however, do initialize and map the shared user data section.
- Make the initial system process and idle process share the same page directory instead of creating a new one.
- Use the same priority class as the parent process, if the process was in the idle or below-normal priority class.
- Only duplicate handles if the caller requested it, instead of always duplicating the process's handles!
- Generate a null image file name for system processes.
- Rename ObpCreateHandleTable to ObInitProcess and better handle race and out-of-memory conditions. Detect if auditing required, but don't do anything about it.
- Initialize the Idle/System process address space much earlier in the boot process, in MmInitSystem.
Thanks to Alex for providing various information, and answering all my questions.
svn path=/trunk/; revision=29223
2007-09-26 20:55:26 +00:00
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
- PS_UNKNOWN_VALUE determines if the process should be created with large pages: rename to PS_LARGE_PAGES
- Do Address Space initialization as per "Windows Internals II" slides, either for the Boot, System, Cloned User or New User Process cases.
- Rename MmCreateProcessAddressSpace to MmInitializeProcessAddressSpace, and MmCopyMmInfo to MmCreateProcessAddressSpace. What ReactOS did is correct as per "Windows Internals II", but the names were inverted.
- Clone the Object Table if we are the boot process, and only initialize part of the address space (since we don't need things like guard page, TEB, etc), however, do initialize and map the shared user data section.
- Make the initial system process and idle process share the same page directory instead of creating a new one.
- Use the same priority class as the parent process, if the process was in the idle or below-normal priority class.
- Only duplicate handles if the caller requested it, instead of always duplicating the process's handles!
- Generate a null image file name for system processes.
- Rename ObpCreateHandleTable to ObInitProcess and better handle race and out-of-memory conditions. Detect if auditing required, but don't do anything about it.
- Initialize the Idle/System process address space much earlier in the boot process, in MmInitSystem.
Thanks to Alex for providing various information, and answering all my questions.
svn path=/trunk/; revision=29223
2007-09-26 20:55:26 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmInitializeHandBuiltProcess(
|
|
|
|
IN PEPROCESS Process,
|
2010-07-23 23:30:00 +00:00
|
|
|
IN PULONG_PTR DirectoryTableBase
|
- PS_UNKNOWN_VALUE determines if the process should be created with large pages: rename to PS_LARGE_PAGES
- Do Address Space initialization as per "Windows Internals II" slides, either for the Boot, System, Cloned User or New User Process cases.
- Rename MmCreateProcessAddressSpace to MmInitializeProcessAddressSpace, and MmCopyMmInfo to MmCreateProcessAddressSpace. What ReactOS did is correct as per "Windows Internals II", but the names were inverted.
- Clone the Object Table if we are the boot process, and only initialize part of the address space (since we don't need things like guard page, TEB, etc), however, do initialize and map the shared user data section.
- Make the initial system process and idle process share the same page directory instead of creating a new one.
- Use the same priority class as the parent process, if the process was in the idle or below-normal priority class.
- Only duplicate handles if the caller requested it, instead of always duplicating the process's handles!
- Generate a null image file name for system processes.
- Rename ObpCreateHandleTable to ObInitProcess and better handle race and out-of-memory conditions. Detect if auditing required, but don't do anything about it.
- Initialize the Idle/System process address space much earlier in the boot process, in MmInitSystem.
Thanks to Alex for providing various information, and answering all my questions.
svn path=/trunk/; revision=29223
2007-09-26 20:55:26 +00:00
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2005-05-09 01:38:29 +00:00
|
|
|
NTSTATUS
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
- PS_UNKNOWN_VALUE determines if the process should be created with large pages: rename to PS_LARGE_PAGES
- Do Address Space initialization as per "Windows Internals II" slides, either for the Boot, System, Cloned User or New User Process cases.
- Rename MmCreateProcessAddressSpace to MmInitializeProcessAddressSpace, and MmCopyMmInfo to MmCreateProcessAddressSpace. What ReactOS did is correct as per "Windows Internals II", but the names were inverted.
- Clone the Object Table if we are the boot process, and only initialize part of the address space (since we don't need things like guard page, TEB, etc), however, do initialize and map the shared user data section.
- Make the initial system process and idle process share the same page directory instead of creating a new one.
- Use the same priority class as the parent process, if the process was in the idle or below-normal priority class.
- Only duplicate handles if the caller requested it, instead of always duplicating the process's handles!
- Generate a null image file name for system processes.
- Rename ObpCreateHandleTable to ObInitProcess and better handle race and out-of-memory conditions. Detect if auditing required, but don't do anything about it.
- Initialize the Idle/System process address space much earlier in the boot process, in MmInitSystem.
Thanks to Alex for providing various information, and answering all my questions.
svn path=/trunk/; revision=29223
2007-09-26 20:55:26 +00:00
|
|
|
MmInitializeHandBuiltProcess2(
|
|
|
|
IN PEPROCESS Process
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2012-02-18 23:59:31 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmSetExecuteOptions(IN ULONG ExecuteOptions);
|
|
|
|
|
2012-02-20 06:42:02 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmGetExecuteOptions(IN PULONG ExecuteOptions);
|
|
|
|
|
2022-09-09 17:17:14 +00:00
|
|
|
_Success_(return)
|
|
|
|
BOOLEAN
|
2005-09-14 01:05:50 +00:00
|
|
|
MmDeleteVirtualMapping(
|
2023-04-10 18:14:06 +00:00
|
|
|
_Inout_opt_ PEPROCESS Process,
|
2022-09-09 17:17:14 +00:00
|
|
|
_In_ PVOID Address,
|
|
|
|
_Out_opt_ BOOLEAN* WasDirty,
|
|
|
|
_Out_opt_ PPFN_NUMBER Page
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2023-04-10 18:14:06 +00:00
|
|
|
_Success_(return)
|
|
|
|
BOOLEAN
|
|
|
|
MmDeletePhysicalMapping(
|
|
|
|
_Inout_opt_ PEPROCESS Process,
|
|
|
|
_In_ PVOID Address,
|
|
|
|
_Out_opt_ BOOLEAN * WasDirty,
|
|
|
|
_Out_opt_ PPFN_NUMBER Page
|
|
|
|
);
|
|
|
|
|
2021-04-01 13:54:19 +00:00
|
|
|
/* arch/procsup.c ************************************************************/
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
MiArchCreateProcessAddressSpace(
|
|
|
|
_In_ PEPROCESS Process,
|
|
|
|
_In_ PULONG_PTR DirectoryTableBase);
|
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
/* wset.c ********************************************************************/
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
MmTrimUserMemory(
|
|
|
|
ULONG Target,
|
|
|
|
ULONG Priority,
|
|
|
|
PULONG NrFreedPages
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
/* region.c ************************************************************/
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmAlterRegion(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID BaseAddress,
|
|
|
|
PLIST_ENTRY RegionListHead,
|
|
|
|
PVOID StartAddress,
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
SIZE_T Length,
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG NewType,
|
|
|
|
ULONG NewProtect,
|
|
|
|
PMM_ALTER_REGION_FUNC AlterFunc
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2005-11-28 23:43:40 +00:00
|
|
|
MmInitializeRegion(
|
2005-09-14 01:05:50 +00:00
|
|
|
PLIST_ENTRY RegionListHead,
|
2005-11-28 23:43:40 +00:00
|
|
|
SIZE_T Length,
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG Type,
|
|
|
|
ULONG Protect
|
|
|
|
);
|
|
|
|
|
|
|
|
PMM_REGION
|
|
|
|
NTAPI
|
|
|
|
MmFindRegion(
|
|
|
|
PVOID BaseAddress,
|
|
|
|
PLIST_ENTRY RegionListHead,
|
|
|
|
PVOID Address,
|
|
|
|
PVOID* RegionBaseAddress
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
|
|
|
/* section.c *****************************************************************/
|
|
|
|
|
2021-01-27 09:29:07 +00:00
|
|
|
#define PFN_FROM_SSE(E) ((PFN_NUMBER)((E) >> PAGE_SHIFT))
|
|
|
|
#define IS_SWAP_FROM_SSE(E) ((E) & 0x00000001)
|
|
|
|
#define MM_IS_WAIT_PTE(E) \
|
|
|
|
(IS_SWAP_FROM_SSE(E) && SWAPENTRY_FROM_SSE(E) == MM_WAIT_ENTRY)
|
|
|
|
#define MAKE_PFN_SSE(P) ((ULONG_PTR)((P) << PAGE_SHIFT))
|
|
|
|
#define SWAPENTRY_FROM_SSE(E) ((E) >> 1)
|
|
|
|
#define MAKE_SWAP_SSE(S) (((ULONG_PTR)(S) << 1) | 0x1)
|
|
|
|
#define DIRTY_SSE(E) ((E) | 2)
|
|
|
|
#define CLEAN_SSE(E) ((E) & ~2)
|
|
|
|
#define IS_DIRTY_SSE(E) ((E) & 2)
|
2021-01-27 12:03:06 +00:00
|
|
|
#define WRITE_SSE(E) ((E) | 4)
|
|
|
|
#define IS_WRITE_SSE(E) ((E) & 4)
|
2021-06-13 09:12:57 +00:00
|
|
|
#ifdef _WIN64
|
|
|
|
#define PAGE_FROM_SSE(E) ((E) & 0xFFFFFFF000ULL)
|
|
|
|
#else
|
2021-01-27 09:29:07 +00:00
|
|
|
#define PAGE_FROM_SSE(E) ((E) & 0xFFFFF000)
|
2021-06-13 09:12:57 +00:00
|
|
|
#endif
|
2021-01-27 12:03:06 +00:00
|
|
|
#define SHARE_COUNT_FROM_SSE(E) (((E) & 0x00000FFC) >> 3)
|
|
|
|
#define MAX_SHARE_COUNT 0x1FF
|
|
|
|
#define MAKE_SSE(P, C) ((ULONG_PTR)((P) | ((C) << 3)))
|
|
|
|
#define BUMPREF_SSE(E) (PAGE_FROM_SSE(E) | ((SHARE_COUNT_FROM_SSE(E) + 1) << 3) | ((E) & 0x7))
|
|
|
|
#define DECREF_SSE(E) (PAGE_FROM_SSE(E) | ((SHARE_COUNT_FROM_SSE(E) - 1) << 3) | ((E) & 0x7))
|
2021-01-27 09:29:07 +00:00
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
_MmLockSectionSegment(PMM_SECTION_SEGMENT Segment,
|
|
|
|
const char *file,
|
|
|
|
int line);
|
|
|
|
|
|
|
|
#define MmLockSectionSegment(x) _MmLockSectionSegment(x,__FILE__,__LINE__)
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
_MmUnlockSectionSegment(PMM_SECTION_SEGMENT Segment,
|
|
|
|
const char *file,
|
|
|
|
int line);
|
|
|
|
|
|
|
|
#define MmUnlockSectionSegment(x) _MmUnlockSectionSegment(x,__FILE__,__LINE__)
|
|
|
|
|
2013-08-28 21:09:16 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmGetImageInformation(
|
|
|
|
OUT PSECTION_IMAGE_INFORMATION ImageInformation
|
|
|
|
);
|
|
|
|
|
2006-07-27 00:22:36 +00:00
|
|
|
PFILE_OBJECT
|
|
|
|
NTAPI
|
|
|
|
MmGetFileObjectForSection(
|
2010-10-05 15:55:52 +00:00
|
|
|
IN PVOID Section
|
2006-07-27 00:22:36 +00:00
|
|
|
);
|
2006-10-22 19:53:10 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmGetFileNameForAddress(
|
|
|
|
IN PVOID Address,
|
|
|
|
OUT PUNICODE_STRING ModuleName
|
|
|
|
);
|
2006-07-27 00:22:36 +00:00
|
|
|
|
2006-10-22 20:56:24 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmGetFileNameForSection(
|
2010-10-05 15:55:52 +00:00
|
|
|
IN PVOID Section,
|
2006-11-30 05:22:20 +00:00
|
|
|
OUT POBJECT_NAME_INFORMATION *ModuleName
|
2006-10-22 20:56:24 +00:00
|
|
|
);
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-09-14 01:05:50 +00:00
|
|
|
MmQuerySectionView(
|
|
|
|
PMEMORY_AREA MemoryArea,
|
|
|
|
PVOID Address,
|
|
|
|
PMEMORY_BASIC_INFORMATION Info,
|
2010-07-16 00:34:26 +00:00
|
|
|
PSIZE_T ResultLength
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-05-09 01:38:29 +00:00
|
|
|
NTSTATUS
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
|
|
|
MmProtectSectionView(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
PMEMORY_AREA MemoryArea,
|
|
|
|
PVOID BaseAddress,
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
SIZE_T Length,
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG Protect,
|
|
|
|
PULONG OldProtect
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmInitSectionImplementation(VOID);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-05-09 01:38:29 +00:00
|
|
|
NTSTATUS
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
|
|
|
MmNotPresentFaultSectionView(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
MEMORY_AREA* MemoryArea,
|
[NEWCC]
A reintegration checkpoint for the NewCC branch, brought to you by Team NewCC.
Differences with current ReactOS trunk:
* A new memory area type, MEMORY_AREA_CACHE, is added, which represents a mapped region of a file. In NEWCC mode, user sections are MEMORY_AREA_CACHE type as well, and obey new semantics. In non-NEWCC mode, they aren't used.
* A way of claiming a page entry for a specific thread's work is added. Placing the special SWAPENTRY value MM_WAIT_ENTRY in a page table, or in a section page table should indicate that memory management code is intended to wait for another thread to make some status change before checking the state of the page entry again. In code that uses this convention, a return value of STATUS_SUCCESS + 1 is used to indicate that the caller should use the MiWaitForPageEvent macro to wait until somebody has change the state of a wait entry before checking again. This is a lighter weight mechanism than PAGEOPs.
* A way of asking the caller to perform some blocking operation without locks held is provided. This replaces some spaghettified code in which locks are repeatedly taken and broken by code that performs various blocking operations. Using this mechanism, it is possible to do a small amount of non-blocking work, fill in a request, then return STATUS_MORE_PROCESSING_REQUIRED to request that locks be dropped and the blocking operation be carried out. A MM_REQUIRED_RESOURCES structure is provided to consumers of this contract to use to accumulate state across many blocking operations. Several functions wrapping blocking operations are provided in ntoskrnl/cache/reqtools.c.
* Image section pages are no longer direct mapped. This is done to simplify consolidation of ownership of pages under the data section system. At a later time, it may be possible to make data pages directly available to image sections for the same file. This is likely the only direct performance impact this code makes on non-NEWCC mode.
RMAPs:
* A new type of RMAP entry is introduced, distinguished by RMAP_IS_SEGMENT(Address) of the rmap entry. This kind of entry contains a pointer to a section page table node in the Process pointer, which in turn links back to the MM_SECTION_SEGMENT it belongs to. Therefore, a page belonging only to a segment (that is, a segment page that isn't mapped) can exist and be evicted using the normal page eviction mechanism in balance.c. Each of the rmap function has been modified to deal with segment rmaps.
* The low 8 bits of the Address field in a segment rmap denote the entry number in the generic table node pointed to by Process that points to the page the rmap belongs to. By combining them, you can determine the file offset the page belongs to.
* In NEWCC mode, MmSharePageEntry/UnsharePageEntry are not used, and instead the page reference count is used to keep track of the number of mappings of a page, allowing the last reference expiring to allow the page to be recycled without much intervention. These are still used in non-NEWCC mode. One change has been made, the count fields have been narrowed by 1 bit to make room for a dirty bit in SSE entries, needed when a page is present but unmapped.
Section page tables:
* The section page tables are now implemented using RtlGenericTables. This enables a fairly compact representation of section page tables without having the existence of a section object imply 4k of fake PDEs. In addition, each node in the generic table has a wide file offset that is a multiple of 256 pages, or 1 megabyte total. Besides needing wide file offsets, the only other visible change caused by the switch to generic tables for section page tables is the need to lock the section segment before interacting with the section page table.
Eviction:
* Page eviction in cache sections is accomplished by MmpPageOutPhysicalAddress. In the case of a shared page, it tries to remove all mappings of the indicated page. If this process fails at any point, the page will simply be drawn back into the target address spaces. After succeeding at this, if TRUE has been accumulated into the page's dirty bit in the section page table, it is written back, and then permanently removed.
NewCC mode:
* NEWCC mode is introduced, which rewrites the file cache to a set of cache stripes actively mapped, along with unmapped section data.
* NewCC is more authentic in its interpretation of the external interface to the windows cache than the current cache manager, implementing each of the cache manager functions according to the documented interface with no preconceived ideas about how anything should be implemented internally. Cache stripes are implemented on top of section objects, using the same memory manager paths, and therefore economizing code and complexity. This replaces a rather complicated system in which pages can be owned by the cache manager and the memory manager simultaneously and they must cooperate in a fairly sophisticated way to manage them. Since they're quite interdependent in the current code, modifying either is very difficult. In NEWCC, they have a clear division of labor and thus can be worked on independently.
* Several third party filesystems that use the kernel Cc interface work properly using NEWCC, including matt wu's ext3 driver.
* In contrast with code that tries to make CcInitializeCacheMap and CcUninitializeCacheMap into a pair that supports reference counting, NEWCC lazily initializes the shared and private cache maps as needed and uses the presence of a PrivateCacheMap on at least one file pointing to the SharedCacheMap as an indication that the FILE_OBJECT reference in the SharedCacheMap should still be held. When the last PrivateCacheMap is discarded, that's the appropriate time to tear down caching for a specific file, as the SharedCacheMap data is allowed to be saved and reused. We honor this by making the SharedCacheMap into a depot for keeping track of the PrivateCacheMap objects associated with views of a file.
svn path=/trunk/; revision=55833
2012-02-23 12:03:06 +00:00
|
|
|
PVOID Address,
|
|
|
|
BOOLEAN Locked
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmPageOutSectionView(
|
|
|
|
PMMSUPPORT AddressSpace,
|
|
|
|
PMEMORY_AREA MemoryArea,
|
|
|
|
PVOID Address,
|
|
|
|
ULONG_PTR Entry
|
|
|
|
);
|
|
|
|
|
|
|
|
CODE_SEG("INIT")
|
2005-05-09 01:38:29 +00:00
|
|
|
NTSTATUS
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
2004-08-01 07:24:59 +00:00
|
|
|
MmCreatePhysicalMemorySection(VOID);
|
|
|
|
|
2005-05-09 01:38:29 +00:00
|
|
|
NTSTATUS
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
|
|
|
MmAccessFaultSectionView(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
MEMORY_AREA* MemoryArea,
|
2021-02-05 14:04:07 +00:00
|
|
|
PVOID Address,
|
|
|
|
BOOLEAN Locked
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2002-08-14 20:58:39 +00:00
|
|
|
VOID
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
2004-08-01 07:24:59 +00:00
|
|
|
MmFreeSectionSegments(PFILE_OBJECT FileObject);
|
|
|
|
|
2022-11-28 23:49:33 +00:00
|
|
|
/* Exported from NT 6.2 onward. We keep it internal. */
|
2020-10-27 16:36:18 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2022-11-28 23:49:33 +00:00
|
|
|
MmMapViewInSystemSpaceEx(
|
2020-10-27 16:36:18 +00:00
|
|
|
_In_ PVOID Section,
|
|
|
|
_Outptr_result_bytebuffer_ (*ViewSize) PVOID *MappedBase,
|
|
|
|
_Inout_ PSIZE_T ViewSize,
|
2021-02-02 09:06:00 +00:00
|
|
|
_Inout_ PLARGE_INTEGER SectionOffset,
|
2022-11-28 23:49:33 +00:00
|
|
|
_In_ ULONG_PTR Flags);
|
2020-10-27 16:36:18 +00:00
|
|
|
|
2020-10-27 16:37:38 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmArePagesResident(
|
|
|
|
_In_ PEPROCESS Process,
|
|
|
|
_In_ PVOID BaseAddress,
|
|
|
|
_In_ ULONG Length);
|
|
|
|
|
2020-11-06 08:39:31 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmMakePagesDirty(
|
|
|
|
_In_ PEPROCESS Process,
|
|
|
|
_In_ PVOID Address,
|
|
|
|
_In_ ULONG Length);
|
|
|
|
|
2021-01-27 12:03:06 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmFlushSegment(
|
|
|
|
_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer,
|
|
|
|
_In_opt_ PLARGE_INTEGER Offset,
|
|
|
|
_In_ ULONG Length,
|
2021-05-24 06:56:17 +00:00
|
|
|
_Out_opt_ PIO_STATUS_BLOCK Iosb);
|
2021-01-27 12:03:06 +00:00
|
|
|
|
2021-01-29 17:48:32 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmMakeDataSectionResident(
|
|
|
|
_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer,
|
|
|
|
_In_ LONGLONG Offset,
|
|
|
|
_In_ ULONG Length,
|
|
|
|
_In_ PLARGE_INTEGER ValidDataLength);
|
|
|
|
|
2021-01-27 12:03:06 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmPurgeSegment(
|
|
|
|
_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer,
|
|
|
|
_In_opt_ PLARGE_INTEGER Offset,
|
|
|
|
_In_ ULONG Length);
|
|
|
|
|
2020-11-06 08:39:31 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmCheckDirtySegment(
|
|
|
|
PMM_SECTION_SEGMENT Segment,
|
|
|
|
PLARGE_INTEGER Offset,
|
|
|
|
BOOLEAN ForceDirty,
|
|
|
|
BOOLEAN PageOut);
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmUnsharePageEntrySectionSegment(PMEMORY_AREA MemoryArea,
|
|
|
|
PMM_SECTION_SEGMENT Segment,
|
|
|
|
PLARGE_INTEGER Offset,
|
|
|
|
BOOLEAN Dirty,
|
|
|
|
BOOLEAN PageOut,
|
|
|
|
ULONG_PTR *InEntry);
|
|
|
|
|
2021-07-23 15:14:47 +00:00
|
|
|
_When_(OldIrql == MM_NOIRQL, _IRQL_requires_max_(DISPATCH_LEVEL))
|
|
|
|
_When_(OldIrql == MM_NOIRQL, _Requires_lock_not_held_(MmPfnLock))
|
|
|
|
_When_(OldIrql != MM_NOIRQL, _Requires_lock_held_(MmPfnLock))
|
|
|
|
_When_(OldIrql != MM_NOIRQL, _Releases_lock_(MmPfnLock))
|
|
|
|
_When_(OldIrql != MM_NOIRQL, _IRQL_requires_(DISPATCH_LEVEL))
|
2020-11-06 08:39:31 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2021-10-31 21:02:38 +00:00
|
|
|
MmDereferenceSegmentWithLock(
|
|
|
|
_In_ PMM_SECTION_SEGMENT Segment,
|
|
|
|
_In_ _When_(OldIrql != MM_NOIRQL, _IRQL_restores_) KIRQL OldIrql);
|
2021-06-07 17:31:24 +00:00
|
|
|
|
2021-07-23 15:14:47 +00:00
|
|
|
_IRQL_requires_max_(DISPATCH_LEVEL)
|
|
|
|
_Requires_lock_not_held_(MmPfnLock)
|
2021-06-07 17:31:24 +00:00
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
|
|
|
MmDereferenceSegment(PMM_SECTION_SEGMENT Segment)
|
|
|
|
{
|
|
|
|
MmDereferenceSegmentWithLock(Segment, MM_NOIRQL);
|
|
|
|
}
|
2020-11-06 08:39:31 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmExtendSection(
|
|
|
|
_In_ PVOID Section,
|
|
|
|
_Inout_ PLARGE_INTEGER NewSize);
|
|
|
|
|
2021-01-27 09:29:07 +00:00
|
|
|
/* sptab.c *******************************************************************/
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
_MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
|
|
|
|
PLARGE_INTEGER Offset,
|
|
|
|
ULONG_PTR Entry,
|
|
|
|
const char *file,
|
|
|
|
int line);
|
|
|
|
|
|
|
|
ULONG_PTR
|
|
|
|
NTAPI
|
|
|
|
_MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
|
|
|
|
PLARGE_INTEGER Offset,
|
|
|
|
const char *file,
|
|
|
|
int line);
|
|
|
|
|
|
|
|
#define MmSetPageEntrySectionSegment(S,O,E) _MmSetPageEntrySectionSegment(S,O,E,__FILE__,__LINE__)
|
|
|
|
|
|
|
|
#define MmGetPageEntrySectionSegment(S,O) _MmGetPageEntrySectionSegment(S,O,__FILE__,__LINE__)
|
|
|
|
|
2007-02-23 07:13:19 +00:00
|
|
|
/* sysldr.c ******************************************************************/
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2007-02-22 18:02:53 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiReloadBootLoadedDrivers(
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2007-02-22 18:02:53 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MiInitializeLoadedModuleList(
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock
|
|
|
|
);
|
|
|
|
|
2019-07-13 22:04:19 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmChangeKernelResourceSectionProtection(IN ULONG_PTR ProtectionMask);
|
|
|
|
|
2019-06-25 18:45:23 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmMakeKernelResourceSectionWritable(VOID);
|
|
|
|
|
2007-02-23 07:13:19 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmLoadSystemImage(
|
|
|
|
IN PUNICODE_STRING FileName,
|
|
|
|
IN PUNICODE_STRING NamePrefix OPTIONAL,
|
|
|
|
IN PUNICODE_STRING LoadedName OPTIONAL,
|
|
|
|
IN ULONG Flags,
|
|
|
|
OUT PVOID *ModuleObject,
|
|
|
|
OUT PVOID *ImageBaseAddress
|
|
|
|
);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmUnloadSystemImage(
|
|
|
|
IN PVOID ImageHandle
|
|
|
|
);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmCheckSystemImage(
|
|
|
|
IN HANDLE ImageHandle,
|
|
|
|
IN BOOLEAN PurgeSection
|
|
|
|
);
|
2007-02-22 18:02:53 +00:00
|
|
|
|
2008-08-21 11:04:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmCallDllInitialize(
|
2023-08-19 17:39:56 +00:00
|
|
|
_In_ PLDR_DATA_TABLE_ENTRY LdrEntry,
|
|
|
|
_In_ PLIST_ENTRY ModuleListHead);
|
2008-08-21 11:04:50 +00:00
|
|
|
|
2020-11-20 14:18:43 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmFreeDriverInitialization(
|
|
|
|
IN PLDR_DATA_TABLE_ENTRY LdrEntry);
|
2011-07-25 00:01:29 +00:00
|
|
|
|
2022-11-28 23:49:33 +00:00
|
|
|
/* ReactOS-only, used by psmgr.c PspLookupSystemDllEntryPoint() as well */
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
RtlpFindExportedRoutineByName(
|
|
|
|
_In_ PVOID ImageBase,
|
|
|
|
_In_ PCSTR ExportName,
|
|
|
|
_Out_ PVOID* Function,
|
|
|
|
_Out_opt_ PBOOLEAN IsForwarder,
|
|
|
|
_In_ NTSTATUS NotFoundStatus);
|
|
|
|
|
|
|
|
/* Exported from NT 10.0 onward. We keep it internal. */
|
|
|
|
PVOID
|
|
|
|
NTAPI
|
|
|
|
RtlFindExportedRoutineByName(
|
|
|
|
_In_ PVOID ImageBase,
|
|
|
|
_In_ PCSTR ExportName);
|
|
|
|
|
2011-07-25 00:01:29 +00:00
|
|
|
/* procsup.c *****************************************************************/
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmGrowKernelStack(
|
|
|
|
IN PVOID StackPointer
|
|
|
|
);
|
|
|
|
|
2008-04-21 21:42:00 +00:00
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
2009-04-27 10:12:57 +00:00
|
|
|
MmLockAddressSpace(PMMSUPPORT AddressSpace)
|
2008-04-21 21:42:00 +00:00
|
|
|
{
|
2009-04-27 10:12:57 +00:00
|
|
|
KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, Vm)->AddressCreationLock);
|
2008-04-21 21:42:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
2009-04-27 10:12:57 +00:00
|
|
|
MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
|
2008-04-21 21:42:00 +00:00
|
|
|
{
|
2009-04-27 10:12:57 +00:00
|
|
|
KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, Vm)->AddressCreationLock);
|
2008-04-21 21:42:00 +00:00
|
|
|
}
|
|
|
|
|
The puzzle of the design decisions behind the React address space structure continues to be troubling (perhaps there was no design?). Every time a process address space is initialized,
the owner process is stored (which we now use to figure out the lowest address). Recall that NULL means kernel, anything else means per-process. This is great, except that after some
painfull header groking, one understands that the PMADDRESS_SPACE structure is actually *not* a separate structure, but embedded within PEPROCESS itself. It is a React-specific structure
(hence the attempts to get rid of it), that seems to have been "overloaded" on top of the VadRoot structure that Windows uses for user-mode memory allocations. To clarify, this structure
is actually embedded inside the process that owns it, except for the kernel address space, which is a global variable. So there's absolutely *no* point in saving a reference to the owner
process, since we'll always be embedded inside it (except for kernel address space).
This patch creates the MmGetAddressSpaceOwner macro which either returns NULL for kernel address space, or uses the CONTAINING_RECORD macro to return the owner (embedded) process.
svn path=/trunk/; revision=34873
2008-07-27 23:53:04 +00:00
|
|
|
FORCEINLINE
|
|
|
|
PEPROCESS
|
2009-04-27 10:12:57 +00:00
|
|
|
MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace)
|
The puzzle of the design decisions behind the React address space structure continues to be troubling (perhaps there was no design?). Every time a process address space is initialized,
the owner process is stored (which we now use to figure out the lowest address). Recall that NULL means kernel, anything else means per-process. This is great, except that after some
painfull header groking, one understands that the PMADDRESS_SPACE structure is actually *not* a separate structure, but embedded within PEPROCESS itself. It is a React-specific structure
(hence the attempts to get rid of it), that seems to have been "overloaded" on top of the VadRoot structure that Windows uses for user-mode memory allocations. To clarify, this structure
is actually embedded inside the process that owns it, except for the kernel address space, which is a global variable. So there's absolutely *no* point in saving a reference to the owner
process, since we'll always be embedded inside it (except for kernel address space).
This patch creates the MmGetAddressSpaceOwner macro which either returns NULL for kernel address space, or uses the CONTAINING_RECORD macro to return the owner (embedded) process.
svn path=/trunk/; revision=34873
2008-07-27 23:53:04 +00:00
|
|
|
{
|
Looks like this address space nonsense made even less sense than originally understood. The kernel address space was something created very early-on, and associated with a global variable
that actually contained the address space itself (so it wasn't part of any process). Its locks however, were associated to the "current process", which, when this function is called, is the
idle process (which later is cloned into the initial system process). Shortly thereafter, the address space of the "current process" (still, at this point, the idle process) was initialized
with the function reserved for real processes (MmInitializeProcessAddressSpace), which among other things, performed a couple of user-mode mappings (which are irrelevant and should not be
part of the system process address space). This created a weird schism: the kernel address space was actually a global variable associated with no process at all, while the kernel process
had its own address space as well (which was not the kernel address space). It's a miracle this didn't screw anything up especially since whether or not the address space has an owner
determined the lowest address (which means that if the kernel process allocated a memory with its *own* address space, the code would think it was a user-mode process).
This patch gets rid of the kernel address space as a static structure, and instead makes it a pointer into the idle/system process' address space. It also gets rid of MmInitializeKernelAddresSpace
and instead makes use of the existing MmInitializeHandBuiltProcess, cleaning up the user-mode allocations previously made. Even though all address spaces now have an owner and are part of a
process, MmGetAddressSpaceOwner will still return NULL for now, to remain backwards compatible with legacy code.
svn path=/trunk/; revision=34876
2008-07-28 00:43:57 +00:00
|
|
|
if (AddressSpace == MmKernelAddressSpace) return NULL;
|
2009-04-27 10:12:57 +00:00
|
|
|
return CONTAINING_RECORD(AddressSpace, EPROCESS, Vm);
|
The puzzle of the design decisions behind the React address space structure continues to be troubling (perhaps there was no design?). Every time a process address space is initialized,
the owner process is stored (which we now use to figure out the lowest address). Recall that NULL means kernel, anything else means per-process. This is great, except that after some
painfull header groking, one understands that the PMADDRESS_SPACE structure is actually *not* a separate structure, but embedded within PEPROCESS itself. It is a React-specific structure
(hence the attempts to get rid of it), that seems to have been "overloaded" on top of the VadRoot structure that Windows uses for user-mode memory allocations. To clarify, this structure
is actually embedded inside the process that owns it, except for the kernel address space, which is a global variable. So there's absolutely *no* point in saving a reference to the owner
process, since we'll always be embedded inside it (except for kernel address space).
This patch creates the MmGetAddressSpaceOwner macro which either returns NULL for kernel address space, or uses the CONTAINING_RECORD macro to return the owner (embedded) process.
svn path=/trunk/; revision=34873
2008-07-27 23:53:04 +00:00
|
|
|
}
|
|
|
|
|
2008-04-21 21:42:00 +00:00
|
|
|
FORCEINLINE
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT
|
2008-04-21 21:42:00 +00:00
|
|
|
MmGetCurrentAddressSpace(VOID)
|
|
|
|
{
|
2009-04-27 10:12:57 +00:00
|
|
|
return &((PEPROCESS)KeGetCurrentThread()->ApcState.Process)->Vm;
|
2008-04-21 21:42:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT
|
2008-04-21 21:42:00 +00:00
|
|
|
MmGetKernelAddressSpace(VOID)
|
|
|
|
{
|
Looks like this address space nonsense made even less sense than originally understood. The kernel address space was something created very early-on, and associated with a global variable
that actually contained the address space itself (so it wasn't part of any process). Its locks however, were associated to the "current process", which, when this function is called, is the
idle process (which later is cloned into the initial system process). Shortly thereafter, the address space of the "current process" (still, at this point, the idle process) was initialized
with the function reserved for real processes (MmInitializeProcessAddressSpace), which among other things, performed a couple of user-mode mappings (which are irrelevant and should not be
part of the system process address space). This created a weird schism: the kernel address space was actually a global variable associated with no process at all, while the kernel process
had its own address space as well (which was not the kernel address space). It's a miracle this didn't screw anything up especially since whether or not the address space has an owner
determined the lowest address (which means that if the kernel process allocated a memory with its *own* address space, the code would think it was a user-mode process).
This patch gets rid of the kernel address space as a static structure, and instead makes it a pointer into the idle/system process' address space. It also gets rid of MmInitializeKernelAddresSpace
and instead makes use of the existing MmInitializeHandBuiltProcess, cleaning up the user-mode allocations previously made. Even though all address spaces now have an owner and are part of a
process, MmGetAddressSpaceOwner will still return NULL for now, to remain backwards compatible with legacy code.
svn path=/trunk/; revision=34876
2008-07-28 00:43:57 +00:00
|
|
|
return MmKernelAddressSpace;
|
2008-04-21 21:42:00 +00:00
|
|
|
}
|
2013-03-13 18:13:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* expool.c ******************************************************************/
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
ExpCheckPoolAllocation(
|
|
|
|
PVOID P,
|
|
|
|
POOL_TYPE PoolType,
|
|
|
|
ULONG Tag);
|
2013-11-19 23:09:13 +00:00
|
|
|
|
2016-09-14 12:45:45 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
ExReturnPoolQuota(
|
|
|
|
IN PVOID P);
|
|
|
|
|
2013-11-19 23:09:13 +00:00
|
|
|
|
2014-02-18 18:12:30 +00:00
|
|
|
/* mmsup.c *****************************************************************/
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmAdjustWorkingSetSize(
|
|
|
|
IN SIZE_T WorkingSetMinimumInBytes,
|
|
|
|
IN SIZE_T WorkingSetMaximumInBytes,
|
|
|
|
IN ULONG SystemCache,
|
|
|
|
IN BOOLEAN IncreaseOkay);
|
|
|
|
|
|
|
|
|
2013-11-19 23:09:13 +00:00
|
|
|
/* session.c *****************************************************************/
|
|
|
|
|
|
|
|
_IRQL_requires_max_(APC_LEVEL)
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmAttachSession(
|
|
|
|
_Inout_ PVOID SessionEntry,
|
|
|
|
_Out_ PKAPC_STATE ApcState);
|
|
|
|
|
|
|
|
_IRQL_requires_max_(APC_LEVEL)
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmDetachSession(
|
|
|
|
_Inout_ PVOID SessionEntry,
|
|
|
|
_Out_ PKAPC_STATE ApcState);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmQuitNextSession(
|
|
|
|
_Inout_ PVOID SessionEntry);
|
|
|
|
|
|
|
|
PVOID
|
|
|
|
NTAPI
|
|
|
|
MmGetSessionById(
|
|
|
|
_In_ ULONG SessionId);
|
|
|
|
|
2013-11-22 12:14:47 +00:00
|
|
|
_IRQL_requires_max_(APC_LEVEL)
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmSetSessionLocaleId(
|
|
|
|
_In_ LCID LocaleId);
|
2014-02-16 09:54:05 +00:00
|
|
|
|
2018-08-13 05:42:57 +00:00
|
|
|
/* shutdown.c *****************************************************************/
|
|
|
|
|
|
|
|
VOID
|
|
|
|
MmShutdownSystem(IN ULONG Phase);
|
2014-02-16 09:54:05 +00:00
|
|
|
|
|
|
|
/* virtual.c *****************************************************************/
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmCopyVirtualMemory(IN PEPROCESS SourceProcess,
|
|
|
|
IN PVOID SourceAddress,
|
|
|
|
IN PEPROCESS TargetProcess,
|
|
|
|
OUT PVOID TargetAddress,
|
|
|
|
IN SIZE_T BufferSize,
|
|
|
|
IN KPROCESSOR_MODE PreviousMode,
|
|
|
|
OUT PSIZE_T ReturnSize);
|
|
|
|
|
2021-04-12 09:36:19 +00:00
|
|
|
/* wslist.cpp ****************************************************************/
|
|
|
|
_Requires_exclusive_lock_held_(WorkingSet->WorkingSetMutex)
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiInitializeWorkingSetList(_Inout_ PMMSUPPORT WorkingSet);
|
|
|
|
|
2021-03-26 08:32:34 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
2021-05-11 14:14:03 +00:00
|
|
|
|
|
|
|
namespace ntoskrnl
|
|
|
|
{
|
|
|
|
using MiPfnLockGuard = const KiQueuedSpinLockGuard<LockQueuePfnLock>;
|
|
|
|
} // namespace ntoskrnl
|
|
|
|
|
2021-03-26 08:32:34 +00:00
|
|
|
#endif
|