mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Added new MEMORY_AREA_NO_ACCESS type.
Make the top and bottom 64KB of process memory space and the 60KB above the shared user page from unaccessible. Introduced MmSystemRangeStart. svn path=/trunk/; revision=4705
This commit is contained in:
parent
e1c437438c
commit
397169c1a8
5 changed files with 91 additions and 21 deletions
|
@ -28,6 +28,7 @@ typedef ULONG SWAPENTRY;
|
|||
#define MEMORY_AREA_SHARED_DATA (10)
|
||||
#define MEMORY_AREA_KERNEL_STACK (11)
|
||||
#define MEMORY_AREA_PAGED_POOL (12)
|
||||
#define MEMORY_AREA_NO_ACCESS (13)
|
||||
|
||||
#define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
|
||||
((x) / (4*1024*1024))
|
||||
|
@ -151,6 +152,12 @@ typedef struct _MADDRESS_SPACE
|
|||
ULONG PageTableRefCountTableSize;
|
||||
} MADDRESS_SPACE, *PMADDRESS_SPACE;
|
||||
|
||||
|
||||
/* VARIABLES */
|
||||
|
||||
extern PVOID MmSystemRangeStart;
|
||||
|
||||
|
||||
/* FUNCTIONS */
|
||||
|
||||
VOID MmLockAddressSpace(PMADDRESS_SPACE AddressSpace);
|
||||
|
|
|
@ -218,7 +218,7 @@ PVOID MmFindGapBottomUp(PMADDRESS_SPACE AddressSpace, ULONG Length)
|
|||
DPRINT("MmFindGapBottomUp(Length %x)\n",Length);
|
||||
|
||||
ListHead = &AddressSpace->MAreaListHead;
|
||||
|
||||
|
||||
current_entry = ListHead->Flink;
|
||||
while (current_entry->Flink!=ListHead)
|
||||
{
|
||||
|
@ -273,9 +273,9 @@ PVOID MmFindGapTopDown(PMADDRESS_SPACE AddressSpace, ULONG Length)
|
|||
|
||||
DPRINT("MmFindGapTopDown(Length %lx)\n",Length);
|
||||
|
||||
if (AddressSpace->LowestAddress < KERNEL_BASE)
|
||||
if (AddressSpace->LowestAddress < KERNEL_BASE) //(ULONG_PTR)MmSystemRangeStart)
|
||||
{
|
||||
HighestAddress = (PVOID)0x7FFE0000; /* Start below the PEB */
|
||||
HighestAddress = MmHighestUserAddress;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -294,12 +294,12 @@ PVOID MmFindGapTopDown(PMADDRESS_SPACE AddressSpace, ULONG Length)
|
|||
|
||||
if (BottomAddress < HighestAddress)
|
||||
{
|
||||
Gap = TopAddress - BottomAddress;
|
||||
Gap = TopAddress - BottomAddress + 1;
|
||||
DPRINT("Bottom %p Top %p Gap %lx\n", BottomAddress, TopAddress, Gap);
|
||||
if (Gap >= Length)
|
||||
{
|
||||
DPRINT1("Found gap at %p\n", TopAddress - Length);
|
||||
return(TopAddress - Length);
|
||||
DPRINT("Found gap at %p\n", TopAddress - Length);
|
||||
return(TopAddress - Length + 1);
|
||||
}
|
||||
TopAddress = current->BaseAddress;
|
||||
}
|
||||
|
@ -308,11 +308,11 @@ PVOID MmFindGapTopDown(PMADDRESS_SPACE AddressSpace, ULONG Length)
|
|||
|
||||
if (current_entry == ListHead)
|
||||
{
|
||||
Address = (PVOID)HighestAddress - Length;
|
||||
Address = (PVOID)HighestAddress - Length + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Address = TopAddress - Length;
|
||||
Address = TopAddress - Length + 1;
|
||||
}
|
||||
|
||||
/* Check if enough space for the block */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: mm.c,v 1.60 2002/09/08 10:23:35 chorns Exp $
|
||||
/* $Id: mm.c,v 1.61 2003/05/17 19:16:02 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -41,9 +41,11 @@
|
|||
|
||||
/* GLOBALS *****************************************************************/
|
||||
|
||||
PVOID EXPORTED MmUserProbeAddress = NULL;
|
||||
PVOID EXPORTED MmUserProbeAddress = NULL;
|
||||
PVOID EXPORTED MmHighestUserAddress = NULL;
|
||||
MM_STATS MmStats;
|
||||
|
||||
PVOID MmSystemRangeStart = NULL;
|
||||
MM_STATS MmStats;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
@ -76,6 +78,9 @@ NTSTATUS MmReleaseMemoryArea(PEPROCESS Process, PMEMORY_AREA Marea)
|
|||
NULL);
|
||||
break;
|
||||
|
||||
case MEMORY_AREA_NO_ACCESS:
|
||||
return(STATUS_SUCCESS);
|
||||
|
||||
default:
|
||||
KeBugCheck(0);
|
||||
}
|
||||
|
@ -210,24 +215,24 @@ NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
|
|||
break;
|
||||
|
||||
case MEMORY_AREA_PAGED_POOL:
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case MEMORY_AREA_SECTION_VIEW:
|
||||
Status = MmAccessFaultSectionView(AddressSpace,
|
||||
MemoryArea,
|
||||
(PVOID)Address,
|
||||
Locked);
|
||||
break;
|
||||
|
||||
|
||||
case MEMORY_AREA_VIRTUAL_MEMORY:
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
break;
|
||||
|
||||
|
||||
case MEMORY_AREA_SHARED_DATA:
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
break;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: mminit.c,v 1.45 2003/05/17 15:28:58 ekohl Exp $
|
||||
/* $Id: mminit.c,v 1.46 2003/05/17 19:16:03 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -248,6 +248,7 @@ VOID MmInit1(ULONG FirstKrnlPhysAddr,
|
|||
/*
|
||||
* FIXME: Set this based on the system command line
|
||||
*/
|
||||
MmSystemRangeStart = (PVOID)KERNEL_BASE; // 0xC0000000
|
||||
MmUserProbeAddress = (PVOID)0x7fff0000;
|
||||
MmHighestUserAddress = (PVOID)0x7ffeffff;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: process.c,v 1.100 2003/05/17 15:29:50 ekohl Exp $
|
||||
/* $Id: process.c,v 1.101 2003/05/17 19:16:39 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -585,9 +585,66 @@ NtCreateProcess(OUT PHANDLE ProcessHandle,
|
|||
/*
|
||||
* Now we have created the process proper
|
||||
*/
|
||||
|
||||
/* Create the shared data page */
|
||||
|
||||
MmLockAddressSpace(&Process->AddressSpace);
|
||||
|
||||
/* Protect the highest 64KB of the process address space */
|
||||
BaseAddress = MmUserProbeAddress;
|
||||
Status = MmCreateMemoryArea(Process,
|
||||
&Process->AddressSpace,
|
||||
MEMORY_AREA_NO_ACCESS,
|
||||
&BaseAddress,
|
||||
0x10000,
|
||||
PAGE_NOACCESS,
|
||||
&MemoryArea,
|
||||
FALSE,
|
||||
FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
MmUnlockAddressSpace(&Process->AddressSpace);
|
||||
DPRINT1("Failed to protect the highest 64KB of the process address space\n");
|
||||
KeBugCheck(0);
|
||||
}
|
||||
|
||||
/* Protect the lowest 64KB of the process address space */
|
||||
#if 0
|
||||
BaseAddress = (PVOID)0x00000000;
|
||||
Status = MmCreateMemoryArea(Process,
|
||||
&Process->AddressSpace,
|
||||
MEMORY_AREA_NO_ACCESS,
|
||||
&BaseAddress,
|
||||
0x10000,
|
||||
PAGE_NOACCESS,
|
||||
&MemoryArea,
|
||||
FALSE,
|
||||
FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
MmUnlockAddressSpace(&Process->AddressSpace);
|
||||
DPRINT1("Failed to protect the lowest 64KB of the process address space\n");
|
||||
KeBugCheck(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Protect the 60KB above the shared user page */
|
||||
BaseAddress = (PVOID)USER_SHARED_DATA + PAGE_SIZE;
|
||||
Status = MmCreateMemoryArea(Process,
|
||||
&Process->AddressSpace,
|
||||
MEMORY_AREA_NO_ACCESS,
|
||||
&BaseAddress,
|
||||
0x10000 - PAGE_SIZE,
|
||||
PAGE_NOACCESS,
|
||||
&MemoryArea,
|
||||
FALSE,
|
||||
FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
MmUnlockAddressSpace(&Process->AddressSpace);
|
||||
DPRINT1("Failed to protect the memory above the shared user page\n");
|
||||
KeBugCheck(0);
|
||||
}
|
||||
|
||||
/* Create the shared data page */
|
||||
BaseAddress = (PVOID)USER_SHARED_DATA;
|
||||
Status = MmCreateMemoryArea(Process,
|
||||
&Process->AddressSpace,
|
||||
|
|
Loading…
Reference in a new issue