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
|
|
|
|
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
|
|
|
|
2010-07-16 00:34:26 +00:00
|
|
|
extern PFN_NUMBER MiFreeSwapPages;
|
|
|
|
extern PFN_NUMBER MiUsedSwapPages;
|
|
|
|
extern SIZE_T MmTotalPagedPoolQuota;
|
|
|
|
extern SIZE_T MmTotalNonPagedPoolQuota;
|
2005-09-14 01:05:50 +00:00
|
|
|
extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
|
2010-07-16 00:34:26 +00:00
|
|
|
extern PFN_NUMBER 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;
|
2005-09-14 01:05:50 +00:00
|
|
|
|
2008-02-14 23:39:31 +00:00
|
|
|
extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
|
2008-02-24 10:43:56 +00:00
|
|
|
extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
|
2008-02-14 23:39:31 +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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2010-07-16 13:23:43 +00:00
|
|
|
extern PVOID MiDebugMapping;
|
|
|
|
extern PMMPTE MmDebugPte;
|
2009-11-04 22:40:18 +00:00
|
|
|
|
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;
|
2005-09-14 01:05:50 +00:00
|
|
|
struct _MM_PAGEOP;
|
2002-05-14 21:19:21 +00:00
|
|
|
typedef ULONG SWAPENTRY;
|
2004-08-01 07:24:59 +00:00
|
|
|
|
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
|
|
|
|
|
2009-11-04 22:40:18 +00:00
|
|
|
#if defined(_X86_)
|
|
|
|
#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)
|
|
|
|
#define MEMORY_AREA_VIRTUAL_MEMORY (8)
|
- 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
|
|
|
|
|
|
|
#define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
|
|
|
|
|
|
|
|
#define MM_CORE_DUMP_TYPE_NONE (0x0)
|
|
|
|
#define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
|
|
|
|
#define MM_CORE_DUMP_TYPE_FULL (0x2)
|
|
|
|
|
|
|
|
#define MM_PAGEOP_PAGEIN (1)
|
|
|
|
#define MM_PAGEOP_PAGEOUT (2)
|
|
|
|
#define MM_PAGEOP_PAGESYNCH (3)
|
|
|
|
#define MM_PAGEOP_ACCESSFAULT (4)
|
1998-09-05 17:34:23 +00:00
|
|
|
|
2008-03-09 21:15:12 +00:00
|
|
|
/* Number of list heads to use */
|
|
|
|
#define MI_FREE_POOL_LISTS 4
|
|
|
|
|
2009-03-10 00:31:14 +00:00
|
|
|
|
2008-03-09 21:15:12 +00:00
|
|
|
/* Signature of free pool blocks */
|
2009-08-24 18:19:53 +00:00
|
|
|
#define MM_FREE_POOL_TAG 'lprF'
|
2008-03-09 21:15:12 +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)
|
|
|
|
|
|
|
|
#define MM_PAGEFILE_SEGMENT (0x1)
|
|
|
|
#define MM_DATAFILE_SEGMENT (0x2)
|
|
|
|
|
|
|
|
#define MC_CACHE (0)
|
|
|
|
#define MC_USER (1)
|
2010-10-19 16:58:27 +00:00
|
|
|
#define MC_SYSTEM (2)
|
|
|
|
#define MC_MAXIMUM (3)
|
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
|
|
|
|
|
|
|
|
#define MM_PAGED_POOL_SIZE (100*1024*1024)
|
|
|
|
#define MM_NONPAGED_POOL_SIZE (100*1024*1024)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Paged and non-paged pools are 8-byte aligned
|
|
|
|
*/
|
|
|
|
#define MM_POOL_ALIGNMENT 8
|
|
|
|
|
|
|
|
#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)))
|
|
|
|
|
|
|
|
#define PAGE_FLAGS_VALID_FROM_USER_MODE \
|
|
|
|
(PAGE_READONLY | \
|
|
|
|
PAGE_READWRITE | \
|
|
|
|
PAGE_WRITECOPY | \
|
|
|
|
PAGE_EXECUTE | \
|
|
|
|
PAGE_EXECUTE_READ | \
|
|
|
|
PAGE_EXECUTE_READWRITE | \
|
|
|
|
PAGE_EXECUTE_WRITECOPY | \
|
|
|
|
PAGE_GUARD | \
|
|
|
|
PAGE_NOACCESS | \
|
|
|
|
PAGE_NOCACHE)
|
|
|
|
|
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 | \
|
|
|
|
PAGE_NOACCESS)
|
|
|
|
|
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
|
|
|
|
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)
|
2008-08-16 01:58:59 +00:00
|
|
|
|
2000-04-03 21:54:42 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG Entry[NR_SECTION_PAGE_ENTRIES];
|
2000-04-03 21:54:42 +00:00
|
|
|
} SECTION_PAGE_TABLE, *PSECTION_PAGE_TABLE;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2005-09-14 01:05:50 +00:00
|
|
|
PSECTION_PAGE_TABLE PageTables[NR_SECTION_PAGE_TABLES];
|
2000-04-03 21:54:42 +00:00
|
|
|
} SECTION_PAGE_DIRECTORY, *PSECTION_PAGE_DIRECTORY;
|
|
|
|
|
2001-02-10 22:51:11 +00:00
|
|
|
typedef struct _MM_SECTION_SEGMENT
|
2001-01-12 21:00:08 +00:00
|
|
|
{
|
2007-10-19 23:21:45 +00:00
|
|
|
LONG FileOffset; /* start offset into the file for image sections */
|
2006-07-09 19:37:39 +00:00
|
|
|
ULONG_PTR VirtualAddress; /* dtart offset into the address range for image sections */
|
|
|
|
ULONG RawLength; /* length of the segment which is part of the mapped file */
|
|
|
|
ULONG Length; /* absolute length of the segment */
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG Protection;
|
2006-07-09 19:37:39 +00:00
|
|
|
FAST_MUTEX Lock; /* lock which protects the page directory */
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG ReferenceCount;
|
|
|
|
SECTION_PAGE_DIRECTORY PageDirectory;
|
|
|
|
ULONG Flags;
|
|
|
|
ULONG Characteristics;
|
|
|
|
BOOLEAN WriteCopy;
|
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
|
|
|
{
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG_PTR ImageBase;
|
|
|
|
ULONG_PTR StackReserve;
|
|
|
|
ULONG_PTR StackCommit;
|
|
|
|
ULONG_PTR EntryPoint;
|
2007-08-05 11:27:39 +00:00
|
|
|
USHORT Subsystem;
|
|
|
|
USHORT ImageCharacteristics;
|
2005-09-14 01:05:50 +00:00
|
|
|
USHORT MinorSubsystemVersion;
|
|
|
|
USHORT MajorSubsystemVersion;
|
|
|
|
USHORT Machine;
|
|
|
|
BOOLEAN Executable;
|
|
|
|
ULONG NrSegments;
|
2007-02-23 15:31:45 +00:00
|
|
|
ULONG ImageSize;
|
2005-09-14 01:05:50 +00:00
|
|
|
PMM_SECTION_SEGMENT Segments;
|
2003-06-27 21:28:30 +00:00
|
|
|
} MM_IMAGE_SECTION_OBJECT, *PMM_IMAGE_SECTION_OBJECT;
|
|
|
|
|
2006-05-10 17:47:44 +00:00
|
|
|
typedef struct _ROS_SECTION_OBJECT
|
2003-06-27 21:28:30 +00:00
|
|
|
{
|
2005-09-14 01:05:50 +00:00
|
|
|
CSHORT Type;
|
|
|
|
CSHORT Size;
|
|
|
|
LARGE_INTEGER MaximumSize;
|
|
|
|
ULONG SectionPageProtection;
|
|
|
|
ULONG AllocationAttributes;
|
|
|
|
PFILE_OBJECT FileObject;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
PMM_IMAGE_SECTION_OBJECT ImageSection;
|
|
|
|
PMM_SECTION_SEGMENT Segment;
|
|
|
|
};
|
2006-05-10 17:47:44 +00:00
|
|
|
} ROS_SECTION_OBJECT, *PROS_SECTION_OBJECT;
|
2003-06-01 14:59:02 +00:00
|
|
|
|
[CACHE]
The cache manager rewrite I started years ago has finally appeared in
ReactOS' trunk and although at this point it's not quite perfectly
integrated, it's enough to boot up the bootcd or livecd. To check out
the more mature original, check out arty-newcc-reactos, branch
arty-newcc on bitbucket.org . Amine Khaldi encouraged me quite a bit
to not give up on it, and was able to reach out and be an advocate
when i really wasn't able to. Others agree that the time has come to
begin removing the old cache manager. I expect the remaining problems
in the version going to trunk will be taken care of relatively
quickly.
The motivation for this effort lies in the particularly hairy
relationship between ReactOS' cache manager and data sections. This
code completely removes page sharing between cache manager and section
and reimagines cache manager as being a facility layered on the memory
manager, not really caring about individual pages, but simply managing
data section objects where caching might occur.
It took me about 2 years to do the first pass of this rewrite and most
of this year to fix some lingering issues, properly implement demand
paging in ReactOS (code which didn't come with this patch in a
recognizable form), and finish getting the PrivateCacheMap and
SharedCacheMap relationship correct.
Currently, the new ntoskrnl/cache directory contains an own
implementation of data file sections. After things have settled down,
we can begin to deprecate and remove the parts of ReactOS' section
implementation that depend on a close relationship with cache
manager. Eventually, I think that the extra code added to
ntoskrnl/cache/section will be removed and ReactOS' own sections will
replace the use of the special MM_CACHE_SECTION_SEGMENT in the cache
path.
Note also, that this makes all cache manager (and new section parts)
use wide file offsets. If my section code were to take over other
parts of the ReactOS memory manager, they would also benefit from
these improvements.
I invite anyone who wants to to peek at this code and fix whatever
bugs can be found.
svn path=/trunk/; revision=49423
2010-11-02 02:32:39 +00:00
|
|
|
struct _MM_CACHE_SECTION_SEGMENT;
|
|
|
|
|
2005-01-02 17:55:06 +00:00
|
|
|
typedef struct _MEMORY_AREA
|
1998-09-05 17:34:23 +00:00
|
|
|
{
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID StartingAddress;
|
|
|
|
PVOID EndingAddress;
|
|
|
|
struct _MEMORY_AREA *Parent;
|
|
|
|
struct _MEMORY_AREA *LeftChild;
|
|
|
|
struct _MEMORY_AREA *RightChild;
|
|
|
|
ULONG Type;
|
2005-11-13 17:28:24 +00:00
|
|
|
ULONG Protect;
|
|
|
|
ULONG Flags;
|
2005-09-14 01:05:50 +00:00
|
|
|
BOOLEAN DeleteInProgress;
|
|
|
|
ULONG PageOpCount;
|
2010-10-05 05:07:13 +00:00
|
|
|
PVOID Vad;
|
2005-09-14 01:05:50 +00:00
|
|
|
union
|
2002-06-11 22:09:03 +00:00
|
|
|
{
|
2005-09-14 01:05:50 +00:00
|
|
|
struct
|
|
|
|
{
|
2006-05-10 17:47:44 +00:00
|
|
|
ROS_SECTION_OBJECT* Section;
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG ViewOffset;
|
|
|
|
PMM_SECTION_SEGMENT Segment;
|
|
|
|
LIST_ENTRY RegionListHead;
|
|
|
|
} SectionData;
|
[CACHE]
The cache manager rewrite I started years ago has finally appeared in
ReactOS' trunk and although at this point it's not quite perfectly
integrated, it's enough to boot up the bootcd or livecd. To check out
the more mature original, check out arty-newcc-reactos, branch
arty-newcc on bitbucket.org . Amine Khaldi encouraged me quite a bit
to not give up on it, and was able to reach out and be an advocate
when i really wasn't able to. Others agree that the time has come to
begin removing the old cache manager. I expect the remaining problems
in the version going to trunk will be taken care of relatively
quickly.
The motivation for this effort lies in the particularly hairy
relationship between ReactOS' cache manager and data sections. This
code completely removes page sharing between cache manager and section
and reimagines cache manager as being a facility layered on the memory
manager, not really caring about individual pages, but simply managing
data section objects where caching might occur.
It took me about 2 years to do the first pass of this rewrite and most
of this year to fix some lingering issues, properly implement demand
paging in ReactOS (code which didn't come with this patch in a
recognizable form), and finish getting the PrivateCacheMap and
SharedCacheMap relationship correct.
Currently, the new ntoskrnl/cache directory contains an own
implementation of data file sections. After things have settled down,
we can begin to deprecate and remove the parts of ReactOS' section
implementation that depend on a close relationship with cache
manager. Eventually, I think that the extra code added to
ntoskrnl/cache/section will be removed and ReactOS' own sections will
replace the use of the special MM_CACHE_SECTION_SEGMENT in the cache
path.
Note also, that this makes all cache manager (and new section parts)
use wide file offsets. If my section code were to take over other
parts of the ReactOS memory manager, they would also benefit from
these improvements.
I invite anyone who wants to to peek at this code and fix whatever
bugs can be found.
svn path=/trunk/; revision=49423
2010-11-02 02:32:39 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
LARGE_INTEGER ViewOffset;
|
|
|
|
struct _MM_CACHE_SECTION_SEGMENT *Segment;
|
|
|
|
} CacheData;
|
2005-09-14 01:05:50 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
LIST_ENTRY RegionListHead;
|
|
|
|
} VirtualMemoryData;
|
|
|
|
} Data;
|
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;
|
|
|
|
|
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;
|
2010-09-28 22:41:46 +00:00
|
|
|
USHORT ParityError:1; // HasRmap
|
2009-06-21 03:57:42 +00:00
|
|
|
} MMPFNENTRY;
|
|
|
|
|
|
|
|
typedef struct _MMPFN
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
2010-09-28 22:41:46 +00:00
|
|
|
PFN_NUMBER Flink;
|
|
|
|
ULONG WsIndex; // SavedSwapEntry
|
2009-06-21 03:57:42 +00:00
|
|
|
PKEVENT Event;
|
|
|
|
NTSTATUS ReadStatus;
|
|
|
|
SINGLE_LIST_ENTRY NextStackPfn;
|
|
|
|
} 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
|
|
|
|
{
|
|
|
|
USHORT ReferenceCount; // ReferenceCount
|
|
|
|
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;
|
|
|
|
LONG AweReferenceCount; // 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;
|
|
|
|
} 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_PAGEOP
|
|
|
|
{
|
|
|
|
/* Type of operation. */
|
2005-05-09 01:38:29 +00:00
|
|
|
ULONG OpType;
|
2004-08-01 07:24:59 +00:00
|
|
|
/* Number of threads interested in this operation. */
|
|
|
|
ULONG ReferenceCount;
|
|
|
|
/* Event that will be set when the operation is completed. */
|
|
|
|
KEVENT CompletionEvent;
|
|
|
|
/* Status of the operation once it is completed. */
|
|
|
|
NTSTATUS Status;
|
|
|
|
/* TRUE if the operation was abandoned. */
|
|
|
|
BOOLEAN Abandoned;
|
|
|
|
/* The memory area to be affected by the operation. */
|
|
|
|
PMEMORY_AREA MArea;
|
|
|
|
ULONG Hash;
|
|
|
|
struct _MM_PAGEOP* Next;
|
|
|
|
struct _ETHREAD* Thread;
|
2005-05-09 01:38:29 +00:00
|
|
|
/*
|
2004-08-01 07:24:59 +00:00
|
|
|
* These fields are used to identify the operation if it is against a
|
|
|
|
* virtual memory area.
|
|
|
|
*/
|
2005-01-26 00:03:05 +00:00
|
|
|
HANDLE Pid;
|
2004-08-01 07:24:59 +00:00
|
|
|
PVOID Address;
|
|
|
|
/*
|
|
|
|
* These fields are used to identify the operation if it is against a
|
|
|
|
* section mapping.
|
|
|
|
*/
|
|
|
|
PMM_SECTION_SEGMENT Segment;
|
|
|
|
ULONG Offset;
|
|
|
|
} MM_PAGEOP, *PMM_PAGEOP;
|
|
|
|
|
|
|
|
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;
|
|
|
|
ULONG Length;
|
|
|
|
LIST_ENTRY RegionListEntry;
|
2004-08-01 07:24:59 +00:00
|
|
|
} MM_REGION, *PMM_REGION;
|
2003-05-17 19:16:39 +00:00
|
|
|
|
2008-03-09 21:15:12 +00:00
|
|
|
/* Entry describing free pool memory */
|
|
|
|
typedef struct _MMFREE_POOL_ENTRY
|
|
|
|
{
|
|
|
|
LIST_ENTRY List;
|
|
|
|
PFN_NUMBER Size;
|
|
|
|
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;
|
|
|
|
PMMPTE NextPdeForPagedPoolExpansion;
|
|
|
|
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
|
|
|
|
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,
|
|
|
|
ULONG Length,
|
|
|
|
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
|
|
|
|
);
|
|
|
|
|
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,
|
|
|
|
ULONG_PTR Length,
|
2005-11-13 17:28:24 +00:00
|
|
|
ULONG Protection,
|
2005-09-14 01:05:50 +00:00
|
|
|
PMEMORY_AREA *Result,
|
|
|
|
BOOLEAN FixedAddress,
|
2005-11-13 17:28:24 +00:00
|
|
|
ULONG AllocationFlags,
|
2005-09-14 01:05:50 +00:00
|
|
|
PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
|
|
|
|
);
|
|
|
|
|
|
|
|
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
|
|
|
ULONG_PTR
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-01-02 17:55:06 +00:00
|
|
|
MmFindGapAtAddress(
|
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
|
|
|
|
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
|
|
|
MmFreeMemoryAreaByPtr(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID BaseAddress,
|
|
|
|
PMM_FREE_PAGE_FUNC FreePage,
|
|
|
|
PVOID FreePageContext
|
|
|
|
);
|
2005-01-02 17:55:06 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2009-04-27 10:12:57 +00:00
|
|
|
MmDumpMemoryAreas(PMMSUPPORT AddressSpace);
|
2005-01-02 17:55:06 +00:00
|
|
|
|
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,
|
|
|
|
ULONG_PTR Length
|
|
|
|
);
|
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,
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG_PTR Length,
|
|
|
|
ULONG_PTR Granularity,
|
|
|
|
BOOLEAN TopDown
|
|
|
|
);
|
2005-01-02 17:55:06 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-01-02 17:55:06 +00:00
|
|
|
MmReleaseMemoryAreaIfDecommitted(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID BaseAddress
|
|
|
|
);
|
2004-10-01 20:26:05 +00:00
|
|
|
|
2008-03-13 13:17:57 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmMapMemoryArea(PVOID BaseAddress,
|
|
|
|
ULONG Length,
|
|
|
|
ULONG Consumer,
|
|
|
|
ULONG Protection);
|
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
/* npool.c *******************************************************************/
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiDebugDumpNonPagedPool(BOOLEAN NewOnly);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
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
|
|
|
|
);
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
|
|
|
MmGetMdlPageAddress(
|
|
|
|
PMDL Mdl,
|
|
|
|
PVOID Offset
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2004-08-08 20:33:17 +00:00
|
|
|
/* pool.c *******************************************************************/
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-09-14 01:05:50 +00:00
|
|
|
ExAllocateNonPagedPoolWithTag(
|
|
|
|
POOL_TYPE type,
|
|
|
|
ULONG size,
|
|
|
|
ULONG Tag,
|
|
|
|
PVOID Caller
|
|
|
|
);
|
|
|
|
|
|
|
|
PVOID
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-09-14 01:05:50 +00:00
|
|
|
ExAllocatePagedPoolWithTag(
|
|
|
|
POOL_TYPE Type,
|
|
|
|
ULONG size,
|
|
|
|
ULONG Tag
|
|
|
|
);
|
|
|
|
|
|
|
|
VOID
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-09-14 01:05:50 +00:00
|
|
|
ExFreeNonPagedPool(PVOID block);
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
VOID
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-09-14 01:05:50 +00:00
|
|
|
ExFreePagedPool(IN PVOID Block);
|
|
|
|
|
2009-04-29 09:41:32 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
ExpIsPoolTagDebuggable(ULONG Tag);
|
|
|
|
|
|
|
|
PVOID
|
|
|
|
NTAPI
|
|
|
|
ExpAllocateDebugPool(
|
|
|
|
POOL_TYPE Type,
|
|
|
|
ULONG Size,
|
|
|
|
ULONG Tag,
|
|
|
|
PVOID Caller,
|
|
|
|
BOOLEAN EndOfPage
|
|
|
|
);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
2009-04-29 09:48:31 +00:00
|
|
|
ExpFreeDebugPool(PVOID Block, BOOLEAN PagedPool);
|
2009-04-29 09:41:32 +00:00
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
VOID
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
|
|
|
MmInitializePagedPool(VOID);
|
|
|
|
|
|
|
|
PVOID
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-09-14 01:05:50 +00:00
|
|
|
MiAllocateSpecialPool(
|
|
|
|
IN POOL_TYPE PoolType,
|
|
|
|
IN SIZE_T NumberOfBytes,
|
|
|
|
IN ULONG Tag,
|
|
|
|
IN ULONG Underrun
|
|
|
|
);
|
|
|
|
|
2004-08-08 20:33:17 +00:00
|
|
|
BOOLEAN
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2004-08-08 20:33:17 +00:00
|
|
|
MiRaisePoolQuota(
|
|
|
|
IN POOL_TYPE PoolType,
|
|
|
|
IN ULONG CurrentMaxQuota,
|
|
|
|
OUT PULONG NewMaxQuota
|
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
|
|
|
|
MiShutdownMemoryManager(VOID);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiFreeInitMemory(VOID);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmInitializeMdlImplementation(VOID);
|
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
|
|
|
|
MmDereserveSwapPages(ULONG Nr);
|
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
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmInitPagingFile(VOID);
|
1999-11-25 10:47:58 +00:00
|
|
|
|
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
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmReserveSwapPages(ULONG Nr);
|
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
|
|
|
NTSTATUS
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-09-14 01:05:50 +00:00
|
|
|
MmDumpToPagingFile(
|
|
|
|
ULONG BugCode,
|
|
|
|
ULONG BugCodeParameter1,
|
|
|
|
ULONG BugCodeParameter2,
|
|
|
|
ULONG BugCodeParameter3,
|
|
|
|
ULONG BugCodeParameter4,
|
|
|
|
struct _KTRAP_FRAME* TrapFrame
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmIsAvailableSwapPage(VOID);
|
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
|
|
|
|
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);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
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
|
|
|
|
);
|
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(
|
- 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 BOOLEAN StoreInstruction,
|
|
|
|
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
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
/* anonmem.c *****************************************************************/
|
2000-07-06 14:34:52 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmNotPresentFaultVirtualMemory(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
MEMORY_AREA* MemoryArea,
|
|
|
|
PVOID Address,
|
|
|
|
BOOLEAN Locked
|
|
|
|
);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmPageOutVirtualMemory(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
PMEMORY_AREA MemoryArea,
|
|
|
|
PVOID Address,
|
|
|
|
struct _MM_PAGEOP* PageOp
|
|
|
|
);
|
|
|
|
|
|
|
|
NTSTATUS
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-09-14 01:05:50 +00:00
|
|
|
MmQueryAnonMem(
|
|
|
|
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
|
|
|
);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmFreeVirtualMemory(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS* Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PMEMORY_AREA MemoryArea
|
|
|
|
);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmProtectAnonMem(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
PMEMORY_AREA MemoryArea,
|
|
|
|
PVOID BaseAddress,
|
|
|
|
ULONG Length,
|
|
|
|
ULONG Protect,
|
|
|
|
PULONG OldProtect
|
|
|
|
);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmWritePageVirtualMemory(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
PMEMORY_AREA MArea,
|
|
|
|
PVOID Address,
|
|
|
|
PMM_PAGEOP PageOp
|
|
|
|
);
|
2002-05-13 18:10:41 +00:00
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
/* kmap.c ********************************************************************/
|
2001-02-16 18:32:20 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
|
|
|
ExAllocatePage(VOID);
|
2001-03-13 16:25:55 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
ExUnmapPage(PVOID Addr);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
2010-07-15 22:50:12 +00:00
|
|
|
ExAllocatePageWithPhysPage(PFN_NUMBER Page);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MiCopyFromUserPage(
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER Page,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID SourceAddress
|
|
|
|
);
|
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
|
|
|
MiZeroPage(PFN_NUMBER Page);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
|
|
|
/* memsafe.s *****************************************************************/
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID
|
|
|
|
FASTCALL
|
|
|
|
MmSafeReadPtr(PVOID Source);
|
2005-02-22 01:07:41 +00:00
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
/* pageop.c ******************************************************************/
|
2002-05-14 21:19:21 +00:00
|
|
|
|
|
|
|
VOID
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
2002-05-14 21:19:21 +00:00
|
|
|
MmReleasePageOp(PMM_PAGEOP PageOp);
|
2002-05-13 18:10:41 +00:00
|
|
|
|
|
|
|
PMM_PAGEOP
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
|
|
|
MmGetPageOp(
|
|
|
|
PMEMORY_AREA MArea,
|
|
|
|
HANDLE Pid,
|
|
|
|
PVOID Address,
|
|
|
|
PMM_SECTION_SEGMENT Segment,
|
|
|
|
ULONG Offset,
|
|
|
|
ULONG OpType,
|
2006-01-08 06:23:17 +00:00
|
|
|
BOOLEAN First
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
|
|
|
|
2003-01-11 15:26:59 +00:00
|
|
|
PMM_PAGEOP
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
|
|
|
MmCheckForPageOp(
|
|
|
|
PMEMORY_AREA MArea,
|
|
|
|
HANDLE Pid,
|
|
|
|
PVOID Address,
|
|
|
|
PMM_SECTION_SEGMENT Segment,
|
|
|
|
ULONG Offset
|
|
|
|
);
|
|
|
|
|
2003-01-11 15:26:59 +00:00
|
|
|
VOID
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
2003-01-11 15:26:59 +00:00
|
|
|
MmInitializePageOp(VOID);
|
2001-03-09 14:40:28 +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
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
/* balace.c ******************************************************************/
|
2003-06-27 21:28:30 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmInitializeMemoryConsumer(
|
|
|
|
ULONG Consumer,
|
|
|
|
NTSTATUS (*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed)
|
|
|
|
);
|
|
|
|
|
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
|
|
|
|
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 **************************************************************/
|
|
|
|
|
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
|
|
|
|
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
|
|
|
VOID
|
|
|
|
NTAPI
|
2010-07-15 22:50:12 +00:00
|
|
|
MmSetCleanAllRmaps(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
|
|
|
MmSetDirtyAllRmaps(PFN_NUMBER Page);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2006-01-08 06:23:17 +00:00
|
|
|
BOOLEAN
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
2010-07-15 22:50:12 +00:00
|
|
|
MmIsDirtyPageRmap(PFN_NUMBER Page);
|
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
|
|
|
MmWritePagePhysicalAddress(PFN_NUMBER Page);
|
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
|
|
|
|
|
|
|
/* freelist.c **********************************************************/
|
|
|
|
|
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;
|
- 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 */
|
|
|
|
if ((MiPfnBitMap.Buffer) && !(RtlTestBit(&MiPfnBitMap, 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
|
2010-07-15 22:50:12 +00:00
|
|
|
MmGetLRUNextUserPage(PFN_NUMBER PreviousPage);
|
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
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2010-07-15 22:50:12 +00:00
|
|
|
MmInsertLRULastUserPage(PFN_NUMBER Page);
|
2008-03-13 15:26:17 +00:00
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
2010-07-15 22:50:12 +00:00
|
|
|
MmRemoveLRUUserPage(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
|
|
|
MmLockPage(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
|
|
|
MmUnlockPage(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
|
|
|
MmGetLockCountPage(PFN_NUMBER Page);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2008-02-14 23:39:31 +00:00
|
|
|
VOID
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
|
|
|
MmInitializePageList(
|
2008-02-15 01:19:46 +00:00
|
|
|
VOID
|
2005-09-14 01:05:50 +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-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER
|
2005-09-14 01:05:50 +00:00
|
|
|
NTAPI
|
|
|
|
MmGetContinuousPages(
|
|
|
|
ULONG NumberOfBytes,
|
|
|
|
PHYSICAL_ADDRESS LowestAcceptableAddress,
|
|
|
|
PHYSICAL_ADDRESS HighestAcceptableAddress,
|
2009-06-23 06:32:11 +00:00
|
|
|
PHYSICAL_ADDRESS BoundaryAddressMultiple,
|
|
|
|
BOOLEAN ZeroPages
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-08-01 07:24:59 +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 *****************************************************************/
|
|
|
|
|
|
|
|
extern PEPROCESS HyperProcess;
|
|
|
|
extern KIRQL HyperIrql;
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
2009-03-10 00:31:14 +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
|
|
|
|
MiUnmapPageInHyperSpace(IN PEPROCESS Process,
|
|
|
|
IN PVOID Address,
|
|
|
|
IN KIRQL OldIrql);
|
|
|
|
|
|
|
|
PVOID
|
|
|
|
NTAPI
|
2010-09-27 21:58:54 +00:00
|
|
|
MiMapPagesToZeroInHyperSpace(IN PMMPFN Pfn1,
|
2009-06-23 09:34:45 +00:00
|
|
|
IN PFN_NUMBER NumberOfPages);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress,
|
|
|
|
IN PFN_NUMBER NumberOfPages);
|
2009-03-10 00:31:14 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// ReactOS Compatibility Layer
|
|
|
|
//
|
|
|
|
FORCEINLINE
|
2009-06-22 13:37:49 +00:00
|
|
|
PVOID
|
2009-03-10 00:31:14 +00:00
|
|
|
MmCreateHyperspaceMapping(IN PFN_NUMBER Page)
|
|
|
|
{
|
|
|
|
HyperProcess = (PEPROCESS)KeGetCurrentThread()->ApcState.Process;
|
|
|
|
return MiMapPageInHyperSpace(HyperProcess, Page, &HyperIrql);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
|
|
|
|
|
|
|
|
/* i386/page.c *********************************************************/
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmCreateVirtualMappingForKernel(
|
|
|
|
PVOID Address,
|
|
|
|
ULONG flProtect,
|
2010-07-15 22:50:12 +00:00
|
|
|
PPFN_NUMBER Pages,
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG PageCount
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmCommitPagedPoolAddress(
|
|
|
|
PVOID Address,
|
|
|
|
BOOLEAN Locked
|
|
|
|
);
|
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/ke/i386/exp.c (KiDoubleFaultHandler): Print CR3
correctly.
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/include/internal/ps.h: Added KTHREAD_STACK_LIMIT definition.
* ntoskrnl/ke/i386/tskswitch.S (Ki386ContextSwitch): Force all the
pages of the kernel stack to be accessible from this process.
2002-06-04 David Welch <welch@cwcom.net>
* ntoskrnl/cc/view.c (ReadCacheSegmentChain): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/cc/copy.c (CcRosCreateCacheSegment): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/cc/copy.c (CcFreeCachePage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/include/internal/mm.h: Changed prototypes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/include/internal/ps.h (KPROCESS): Changed type of
page directory base to PHYSICAL_ADDRESS.
* ntoskrnl/include/internal/i386/mm.h: Changed prototypes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kthread.c (KeFreeStackPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kthread.c (KeInitializeThread): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/process.c (KeAttachProcess, KeDetachProcess): Changes
to use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kernel.c (PcrPages, KeApplicationProcessorInit): Changes
to use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MM_ALLOCATION_REQUEST): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MmReleasePageMemoryConsumer): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MmRequestPageMemoryConsumer): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/cont.c (MmFreeContinuousPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/cont.c (MmAllocateContinuousAlignedMemory): Changes to
use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/freelist.c (MmTransferOwnershipPage,
MmGetLRUFirstUserPage, MmGetLRUNextUserPage, MmGetContinuousPages,
MmInitializePageList, MmSetFlagsPage, MmSetRmapListHeadPage,
MmGetRmapListHeadPage, MmMarkPageMapped, MmMarkPageUnmapped,
MmGetFlagsPage, MmSetSavedSwapEntryPage, MmGetSavedSwapEntryPage,
MmReferencePage, MmGetReferenceCountPage, MmIsUsablePage,
MmDereferencePage, MmGetLockCountPage, MmLockPage, MmUnlockPage,
MmAllocPage): Changes to use PHYSICAL_ADDRESS type for physical
addresses.
* ntoskrnl/mm/iospace.c (MmMapIoSpace): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/kmap.c (ExAllocatePage, MiZeroPage, MiCopyFromUserPage,
ExAllocatePageWithPhysPage): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/marea.c (MmFreeMemoryArea): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/mdl.c (MmUnlockPages, MmMapLockedPages,
MmProbeAndLockPages): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/mm.c (MmSharedDataPagePhysicalAddress,
MmCommitPagedPoolAddress, MmNotPresentFault): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/mminit.c (MmInitVirtualMemory): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/ncache.c (MmAllocateNonCachedMemory,
MmFreeNonCachedPage): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/npool.c (grow_kernel_pool): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/rmap.c (MmPageOutPhysicalAddress, MmInsertRmap,
MmDeleteAllRmaps, MmDeleteRmap): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/section.c (MiReadPage, MmNotPresentFaultSectionView,
MmAccessFaultSectionView, MmPageOutDeleteMapping,
MmPageOutSectionView, MmFreeSectionPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/slab.c (ExGrowSlabCache): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/virtual.c (MmPageOutVirtualMemory,
MmNotPresentFaultVirtualMemory, MmFreeVirtualMemoryPage): Changes to
use PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/wset.c (MmTrimUserMemory): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/page.c (Mmi386ReleaseMmInfo, MmCopyMmInfo,
MmGetPhysicalAddressForProcess, MmCreateVirtualMapping,
MmCreateVirtualMappingUnsafe, MmCreateVirtualMappingForProcess,
MmDeleteVirtualMapping): Changes to use PHYSICAL_ADDRESS type for
physical address.
* ntoskrnl/ps/process (PsInitProcessManagment): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/ps/thread.c (PsAllocateCallbackStack): Changes to use
PHYSICAL_ADDRESS type for physical address.
2002-06-04 David Welch <welch@cwcom.net>
* Lots of change since the ChangeLog was last updated.
svn path=/trunk/; revision=3000
2002-06-04 15:26:58 +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,
|
2010-07-15 22:50:12 +00:00
|
|
|
PPFN_NUMBER Pages,
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG PageCount
|
|
|
|
);
|
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,
|
2010-07-15 22:50:12 +00:00
|
|
|
PPFN_NUMBER Pages,
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG PageCount
|
|
|
|
);
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
MmDisableVirtualMapping(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address,
|
2006-01-08 06:23:17 +00:00
|
|
|
BOOLEAN* WasDirty,
|
2010-07-15 22:50:12 +00:00
|
|
|
PPFN_NUMBER Page
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2004-04-22 01:57:49 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmEnableVirtualMapping(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address
|
|
|
|
);
|
2004-04-22 01:57:49 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmRawDeleteVirtualMapping(PVOID Address);
|
2001-12-31 01:53:46 +00:00
|
|
|
|
[CACHE]
The cache manager rewrite I started years ago has finally appeared in
ReactOS' trunk and although at this point it's not quite perfectly
integrated, it's enough to boot up the bootcd or livecd. To check out
the more mature original, check out arty-newcc-reactos, branch
arty-newcc on bitbucket.org . Amine Khaldi encouraged me quite a bit
to not give up on it, and was able to reach out and be an advocate
when i really wasn't able to. Others agree that the time has come to
begin removing the old cache manager. I expect the remaining problems
in the version going to trunk will be taken care of relatively
quickly.
The motivation for this effort lies in the particularly hairy
relationship between ReactOS' cache manager and data sections. This
code completely removes page sharing between cache manager and section
and reimagines cache manager as being a facility layered on the memory
manager, not really caring about individual pages, but simply managing
data section objects where caching might occur.
It took me about 2 years to do the first pass of this rewrite and most
of this year to fix some lingering issues, properly implement demand
paging in ReactOS (code which didn't come with this patch in a
recognizable form), and finish getting the PrivateCacheMap and
SharedCacheMap relationship correct.
Currently, the new ntoskrnl/cache directory contains an own
implementation of data file sections. After things have settled down,
we can begin to deprecate and remove the parts of ReactOS' section
implementation that depend on a close relationship with cache
manager. Eventually, I think that the extra code added to
ntoskrnl/cache/section will be removed and ReactOS' own sections will
replace the use of the special MM_CACHE_SECTION_SEGMENT in the cache
path.
Note also, that this makes all cache manager (and new section parts)
use wide file offsets. If my section code were to take over other
parts of the ReactOS memory manager, they would also benefit from
these improvements.
I invite anyone who wants to to peek at this code and fix whatever
bugs can be found.
svn path=/trunk/; revision=49423
2010-11-02 02:32:39 +00:00
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmGetPageFileMapping(
|
|
|
|
struct _EPROCESS *Process,
|
|
|
|
PVOID Address,
|
|
|
|
SWAPENTRY* SwapEntry);
|
|
|
|
|
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
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmIsPageSwapEntry(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address
|
|
|
|
);
|
2001-12-31 01:53:46 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmTransferOwnershipPage(
|
2010-07-15 22:50:12 +00:00
|
|
|
PFN_NUMBER Page,
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG NewConsumer
|
|
|
|
);
|
2002-08-10 16:41:20 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmSetDirtyPage(
|
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
|
|
|
);
|
|
|
|
|
|
|
|
LONG
|
|
|
|
NTAPI
|
|
|
|
MmAllocPagesSpecifyRange(
|
|
|
|
ULONG Consumer,
|
|
|
|
PHYSICAL_ADDRESS LowestAddress,
|
|
|
|
PHYSICAL_ADDRESS HighestAddress,
|
|
|
|
ULONG NumberOfPages,
|
2010-07-15 22:50:12 +00:00
|
|
|
PPFN_NUMBER Pages
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2005-01-07 16:10:48 +00:00
|
|
|
|
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
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmCreatePageTable(PVOID PAddress);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
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
|
|
|
);
|
|
|
|
|
|
|
|
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
|
|
|
);
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2006-05-18 20:32:17 +00:00
|
|
|
MmReleaseMmInfo(struct _EPROCESS *Process);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2006-05-18 20:32:17 +00:00
|
|
|
Mmi386ReleaseMmInfo(struct _EPROCESS *Process);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmDeleteVirtualMapping(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address,
|
2006-01-08 06:23:17 +00:00
|
|
|
BOOLEAN FreePage,
|
|
|
|
BOOLEAN* WasDirty,
|
2010-07-15 22:50:12 +00:00
|
|
|
PPFN_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
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmIsDirtyPage(
|
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
|
2010-07-15 22:50:12 +00:00
|
|
|
MmMarkPageMapped(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
|
|
|
MmMarkPageUnmapped(PFN_NUMBER Page);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmUpdatePageDir(
|
2006-05-18 20:32:17 +00:00
|
|
|
struct _EPROCESS *Process,
|
2005-09-14 01:05:50 +00:00
|
|
|
PVOID Address,
|
|
|
|
ULONG Size
|
|
|
|
);
|
2004-08-19 21:47:51 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiInitPageDirectoryMap(VOID);
|
2004-09-09 20:42:33 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
ULONG
|
|
|
|
NTAPI
|
|
|
|
MiGetUserPageDirectoryCount(VOID);
|
2004-09-09 20:42:33 +00:00
|
|
|
|
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,
|
|
|
|
ULONG Length,
|
|
|
|
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 *****************************************************************/
|
|
|
|
|
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
|
|
|
);
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
PVOID
|
2006-09-06 12:19:00 +00:00
|
|
|
NTAPI
|
2005-09-14 01:05:50 +00:00
|
|
|
MmAllocateSection(
|
|
|
|
IN ULONG Length,
|
|
|
|
PVOID BaseAddress
|
|
|
|
);
|
2002-08-10 16:41:20 +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,
|
|
|
|
ULONG Length,
|
|
|
|
ULONG Protect,
|
|
|
|
PULONG OldProtect
|
|
|
|
);
|
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
|
|
|
|
MmWritePageSectionView(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
PMEMORY_AREA MArea,
|
|
|
|
PVOID Address,
|
|
|
|
PMM_PAGEOP PageOp
|
|
|
|
);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
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,
|
|
|
|
PVOID Address,
|
|
|
|
BOOLEAN Locked
|
|
|
|
);
|
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
|
|
|
|
MmPageOutSectionView(
|
2009-04-27 10:12:57 +00:00
|
|
|
PMMSUPPORT AddressSpace,
|
2005-09-14 01:05:50 +00:00
|
|
|
PMEMORY_AREA MemoryArea,
|
|
|
|
PVOID Address,
|
|
|
|
struct _MM_PAGEOP *PageOp
|
|
|
|
);
|
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
|
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,
|
|
|
|
PVOID Address,
|
|
|
|
BOOLEAN Locked
|
|
|
|
);
|
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);
|
|
|
|
|
|
|
|
/* mpw.c *********************************************************************/
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmInitMpwThread(VOID);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2007-01-25 18:48:56 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MmInitBsmThread(VOID);
|
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
/* pager.c *******************************************************************/
|
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MiIsPagerThread(VOID);
|
2004-08-01 07:24:59 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiStartPagerThread(VOID);
|
2002-08-14 20:58:39 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiStopPagerThread(VOID);
|
2005-09-13 23:28:21 +00:00
|
|
|
|
2005-09-14 01:05:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
FASTCALL
|
|
|
|
MiQueryVirtualMemory(
|
|
|
|
IN HANDLE ProcessHandle,
|
|
|
|
IN PVOID Address,
|
2006-01-08 06:23:17 +00:00
|
|
|
IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass,
|
2005-09-14 01:05:50 +00:00
|
|
|
OUT PVOID VirtualMemoryInformation,
|
2010-07-16 00:34:26 +00:00
|
|
|
IN SIZE_T Length,
|
|
|
|
OUT PSIZE_T ResultLength
|
2005-09-14 01:05:50 +00:00
|
|
|
);
|
2005-09-13 23:28:21 +00:00
|
|
|
|
2007-02-23 07:13:19 +00:00
|
|
|
/* sysldr.c ******************************************************************/
|
|
|
|
|
2007-02-22 18:02:53 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MiReloadBootLoadedDrivers(
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MiInitializeLoadedModuleList(
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock
|
|
|
|
);
|
|
|
|
|
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(
|
|
|
|
IN PLDR_DATA_TABLE_ENTRY LdrEntry,
|
|
|
|
IN PLIST_ENTRY ListHead
|
|
|
|
);
|
|
|
|
|
2009-04-27 10:12:57 +00:00
|
|
|
extern PMMSUPPORT MmKernelAddressSpace;
|
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
|
|
|
}
|