mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 20:03:12 +00:00
Corrected mutex implementation
Added proper locking to the memory managment svn path=/trunk/; revision=1093
This commit is contained in:
parent
3bd2a11130
commit
9d6388ae05
32 changed files with 915 additions and 700 deletions
|
@ -1,6 +1,6 @@
|
||||||
#ifndef _INCLUDE_DDK_IOFUNCS_H
|
#ifndef _INCLUDE_DDK_IOFUNCS_H
|
||||||
#define _INCLUDE_DDK_IOFUNCS_H
|
#define _INCLUDE_DDK_IOFUNCS_H
|
||||||
/* $Id: iofuncs.h,v 1.8 2000/03/26 19:38:10 ea Exp $ */
|
/* $Id: iofuncs.h,v 1.9 2000/03/29 13:11:51 dwelch Exp $ */
|
||||||
|
|
||||||
/* --- EXPORTED BY NTOSKRNL --- */
|
/* --- EXPORTED BY NTOSKRNL --- */
|
||||||
|
|
||||||
|
@ -649,15 +649,10 @@ IoOpenDeviceInstanceKey (
|
||||||
DWORD Unknown3,
|
DWORD Unknown3,
|
||||||
DWORD Unknown4
|
DWORD Unknown4
|
||||||
);
|
);
|
||||||
NTSTATUS
|
NTSTATUS STDCALL IoPageRead (PFILE_OBJECT FileObject,
|
||||||
STDCALL
|
PMDL Mdl,
|
||||||
IoPageRead (
|
PLARGE_INTEGER Offset,
|
||||||
PFILE_OBJECT FileObject,
|
PIO_STATUS_BLOCK StatusBlock);
|
||||||
PMDL Mdl,
|
|
||||||
PLARGE_INTEGER Offset,
|
|
||||||
PIO_STATUS_BLOCK StatusBlock,
|
|
||||||
DWORD Unknown4
|
|
||||||
);
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
IoQueryDeviceDescription (
|
IoQueryDeviceDescription (
|
||||||
|
|
|
@ -1,23 +1,28 @@
|
||||||
|
|
||||||
enum
|
typedef struct _MADDRESS_SPACE
|
||||||
{
|
{
|
||||||
MDL_MAPPED_TO_SYSTEM_VA = 0x1,
|
LIST_ENTRY MAreaListHead;
|
||||||
MDL_PAGES_LOCKED = 0x2,
|
KMUTEX Lock;
|
||||||
MDL_SOURCE_IS_NONPAGED_POOL = 0x4,
|
ULONG LowestAddress;
|
||||||
MDL_ALLOCATED_FIXED_SIZE = 0x8,
|
} MADDRESS_SPACE, *PMADDRESS_SPACE;
|
||||||
MDL_PARTIAL = 0x10,
|
|
||||||
MDL_PARTIAL_HAS_BEEN_MAPPED = 0x20,
|
#define MDL_MAPPED_TO_SYSTEM_VA (0x1)
|
||||||
MDL_IO_PAGE_READ = 0x40,
|
#define MDL_PAGES_LOCKED (0x2)
|
||||||
MDL_WRITE_OPERATION = 0x80,
|
#define MDL_SOURCE_IS_NONPAGED_POOL (0x4)
|
||||||
MDL_PARENT_MAPPED_SYSTEM_VA = 0x100,
|
#define MDL_ALLOCATED_FIXED_SIZE (0x8)
|
||||||
MDL_LOCK_HELD = 0x200,
|
#define MDL_PARTIAL (0x10)
|
||||||
MDL_SCATTER_GATHER_VA = 0x400,
|
#define MDL_PARTIAL_HAS_BEEN_MAPPED (0x20)
|
||||||
MDL_IO_SPACE = 0x800,
|
#define MDL_IO_PAGE_READ (0x40)
|
||||||
MDL_NETWORK_HEADER = 0x1000,
|
#define MDL_WRITE_OPERATION (0x80)
|
||||||
MDL_MAPPING_CAN_FAIL = 0x2000,
|
#define MDL_PARENT_MAPPED_SYSTEM_VA (0x100)
|
||||||
MDL_ALLOCATED_MUST_SUCCEED = 0x4000,
|
#define MDL_LOCK_HELD (0x200)
|
||||||
MDL_64_BIT_VA = 0x8000,
|
#define MDL_SCATTER_GATHER_VA (0x400)
|
||||||
};
|
#define MDL_IO_SPACE (0x800)
|
||||||
|
#define MDL_NETWORK_HEADER (0x1000)
|
||||||
|
#define MDL_MAPPING_CAN_FAIL (0x2000)
|
||||||
|
#define MDL_ALLOCATED_MUST_SUCCEED (0x4000)
|
||||||
|
#define MDL_64_BIT_VA (0x8000)
|
||||||
|
|
||||||
|
|
||||||
typedef struct _MDL
|
typedef struct _MDL
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -234,7 +234,7 @@ typedef struct _KPROCESS
|
||||||
/*
|
/*
|
||||||
* Added by David Welch (welch@mcmail.com)
|
* Added by David Welch (welch@mcmail.com)
|
||||||
*/
|
*/
|
||||||
LIST_ENTRY MemoryAreaList;
|
MADDRESS_SPACE AddressSpace;
|
||||||
HANDLE_TABLE HandleTable;
|
HANDLE_TABLE HandleTable;
|
||||||
LIST_ENTRY ProcessListEntry;
|
LIST_ENTRY ProcessListEntry;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: io.h,v 1.9 2000/03/26 19:38:14 ea Exp $
|
/* $Id: io.h,v 1.10 2000/03/29 13:11:51 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -44,13 +44,10 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
|
||||||
PDEVICE_OBJECT DeviceToMount);
|
PDEVICE_OBJECT DeviceToMount);
|
||||||
VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost);
|
VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS IopCreateFile (PVOID ObjectBody,
|
||||||
IopCreateFile (
|
PVOID Parent,
|
||||||
PVOID ObjectBody,
|
PWSTR RemainingPath,
|
||||||
PVOID Parent,
|
POBJECT_ATTRIBUTES ObjectAttributes);
|
||||||
PWSTR RemainingPath,
|
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes
|
|
||||||
);
|
|
||||||
NTSTATUS IopCreateDevice(PVOID ObjectBody,
|
NTSTATUS IopCreateDevice(PVOID ObjectBody,
|
||||||
PVOID Parent,
|
PVOID Parent,
|
||||||
PWSTR RemainingPath,
|
PWSTR RemainingPath,
|
||||||
|
|
|
@ -61,22 +61,26 @@ typedef struct
|
||||||
|
|
||||||
/* FUNCTIONS */
|
/* FUNCTIONS */
|
||||||
|
|
||||||
PVOID
|
VOID MmLockAddressSpace(PMADDRESS_SPACE AddressSpace);
|
||||||
STDCALL
|
VOID MmUnlockAddressSpace(PMADDRESS_SPACE AddressSpace);
|
||||||
MmAllocateSection (
|
VOID MmInitializeKernelAddressSpace(VOID);
|
||||||
IN ULONG Length
|
PMADDRESS_SPACE MmGetCurrentAddressSpace(VOID);
|
||||||
);
|
PMADDRESS_SPACE MmGetKernelAddressSpace(VOID);
|
||||||
NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
|
NTSTATUS MmInitializeAddressSpace(PMADDRESS_SPACE AddressSpace);
|
||||||
PEPROCESS Process,
|
NTSTATUS MmDestroyAddressSpace(PMADDRESS_SPACE AddressSpace);
|
||||||
|
PVOID STDCALL MmAllocateSection (IN ULONG Length);
|
||||||
|
NTSTATUS MmCreateMemoryArea(PEPROCESS Process,
|
||||||
|
PMADDRESS_SPACE AddressSpace,
|
||||||
ULONG Type,
|
ULONG Type,
|
||||||
PVOID* BaseAddress,
|
PVOID* BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
ULONG Attributes,
|
ULONG Attributes,
|
||||||
MEMORY_AREA** Result);
|
MEMORY_AREA** Result);
|
||||||
MEMORY_AREA* MmOpenMemoryAreaByAddress(PEPROCESS Process, PVOID Address);
|
MEMORY_AREA* MmOpenMemoryAreaByAddress(PMADDRESS_SPACE AddressSpace,
|
||||||
|
PVOID Address);
|
||||||
NTSTATUS MmInitMemoryAreas(VOID);
|
NTSTATUS MmInitMemoryAreas(VOID);
|
||||||
VOID ExInitNonPagedPool(ULONG BaseAddress);
|
VOID ExInitNonPagedPool(ULONG BaseAddress);
|
||||||
NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
|
NTSTATUS MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
BOOLEAN FreePages);
|
BOOLEAN FreePages);
|
||||||
|
@ -90,6 +94,7 @@ NTSTATUS MmInitSectionImplementation(VOID);
|
||||||
#define MM_LOWEST_USER_ADDRESS (4096)
|
#define MM_LOWEST_USER_ADDRESS (4096)
|
||||||
|
|
||||||
PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
|
PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
|
||||||
|
PMADDRESS_SPACE AddressSpace,
|
||||||
PMEMORY_AREA OriginalMemoryArea,
|
PMEMORY_AREA OriginalMemoryArea,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
|
|
|
@ -9,6 +9,7 @@ cp lib/kernel32/kernel32.dll $1/reactos/system32
|
||||||
cp lib/crtdll/crtdll.dll $1/reactos/system32
|
cp lib/crtdll/crtdll.dll $1/reactos/system32
|
||||||
cp lib/fmifs/fmifs.dll $1/reactos/system32
|
cp lib/fmifs/fmifs.dll $1/reactos/system32
|
||||||
cp lib/gdi32/gdi32.dll $1/reactos/system32
|
cp lib/gdi32/gdi32.dll $1/reactos/system32
|
||||||
|
cp lib/advapi32/advapi32.dll $1/reactos/system32
|
||||||
cp apps/hello/hello.exe $1/reactos/bin
|
cp apps/hello/hello.exe $1/reactos/bin
|
||||||
cp apps/args/args.exe $1/reactos/bin
|
cp apps/args/args.exe $1/reactos/bin
|
||||||
cp apps/bench/bench-thread.exe $1/reactos/bin
|
cp apps/bench/bench-thread.exe $1/reactos/bin
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
VOID NdrClientInitializeNew(PRPC_MESSAGE Message,
|
|
||||||
PMIDL_STUB_MESSAGE StubMsg,
|
|
||||||
PMIDL_STUB_DESC StubDesc,
|
|
||||||
ULONG a)
|
|
||||||
{
|
|
||||||
NdrClientInitialize(Message,
|
|
||||||
StubMsg,
|
|
||||||
StubDesc,
|
|
||||||
a);
|
|
||||||
if (StubDe)
|
|
||||||
{
|
|
||||||
NdrpSetRpcSsDefaults([eax], [eax+4])
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,6 +5,30 @@ pointer_default(unique)
|
||||||
]
|
]
|
||||||
interface hello
|
interface hello
|
||||||
{
|
{
|
||||||
void HelloProc([in] int pszString);
|
struct _hello_struct
|
||||||
void Shutdown(void);
|
{
|
||||||
|
int hello_member;
|
||||||
|
int hello1_member;
|
||||||
|
float hello3_member;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _hello2_struct
|
||||||
|
{
|
||||||
|
int hello2_member;
|
||||||
|
} __hello2_struct;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int hello3_member;
|
||||||
|
} hello3_typedef;
|
||||||
|
|
||||||
|
typedef int hello_t;
|
||||||
|
|
||||||
|
void Hello4Proc([in] hello3_typedef ii);
|
||||||
|
void Hello3Proc([in] __hello2_struct h);
|
||||||
|
void Hello2Proc([in] struct _hello_struct h);
|
||||||
|
void HelloProc([in] hello_t pszString);
|
||||||
|
void Shutdown(void);
|
||||||
|
void RpcBenchmark(handle_t Server,
|
||||||
|
[out, size_is(32768)] unsigned char* pcOutBuffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ int nr_errors = 0;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
DIGIT [0-9]
|
DIGIT [0-9]
|
||||||
ID [a-zA-Z][a-zA-Z0-9]*
|
ID [a-zA-Z_][a-zA-Z0-9_]*
|
||||||
UUID [a-z0-9]*
|
UUID [a-z0-9]*
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
@ -23,8 +23,30 @@ version { TOK(VERSION_KEYWORD); }
|
||||||
pointer_default { TOK(POINTER_DEFAULT_KEYWORD); }
|
pointer_default { TOK(POINTER_DEFAULT_KEYWORD); }
|
||||||
unique { TOK(UNIQUE_KEYWORD); }
|
unique { TOK(UNIQUE_KEYWORD); }
|
||||||
interface { TOK(INTERFACE_KEYWORD); }
|
interface { TOK(INTERFACE_KEYWORD); }
|
||||||
|
aggregatable { TOK(AGGREGATABLE_KEYWORD); }
|
||||||
|
allocate { TOK(ALLOCATE_KEYWORD); }
|
||||||
|
appobject { TOK(APPOBJECT_KEYWORD); }
|
||||||
|
|
||||||
|
|
||||||
|
all_nodes { TOK(ALL_NODES_KEYWORD); }
|
||||||
|
single_node { TOK(SINGLE_NODE_KEYWORD); }
|
||||||
|
free { TOK(FREE_KEYWORD); }
|
||||||
|
dont_free { TOK(DONT_FREE_KEYWORD); }
|
||||||
|
|
||||||
|
typedef { TOK(TYPEDEF_KEYWORD); }
|
||||||
|
struct { TOK(STRUCT_KEYWORD); }
|
||||||
|
const { TOK(CONST_KEYWORD); }
|
||||||
|
|
||||||
|
signed { TOK(SIGNED_KEYWORD); }
|
||||||
|
unsigned { TOK(UNSIGNED_KEYWORD); }
|
||||||
|
|
||||||
in { TOK(IN_KEYWORD); }
|
in { TOK(IN_KEYWORD); }
|
||||||
out { TOK(OUT_KEYWORD); }
|
out { TOK(OUT_KEYWORD); }
|
||||||
|
string { TOK(STRING_KEYWORD); }
|
||||||
|
implicit_handle { TOK(IMPLICIT_HANDLE_KEYWORD); }
|
||||||
|
auto_handle { TOK(AUTO_HANDLE_KEYWORD); }
|
||||||
|
size_is { TOK(SIZE_IS_KEYWORD); }
|
||||||
|
length_is { TOK(LENGTH_IS_KEYWORD); }
|
||||||
|
|
||||||
{ID} { int n;
|
{ID} { int n;
|
||||||
if ((n = token_to_type(yytext)) != 0)
|
if ((n = token_to_type(yytext)) != 0)
|
||||||
|
@ -66,6 +88,10 @@ out { TOK(OUT_KEYWORD); }
|
||||||
|
|
||||||
"]" { TOK(RSQBRACKET); }
|
"]" { TOK(RSQBRACKET); }
|
||||||
|
|
||||||
|
"*" { TOK(STAR); }
|
||||||
|
|
||||||
|
"=" { TOK(ASSIGNMENT); }
|
||||||
|
|
||||||
\n lineno++;
|
\n lineno++;
|
||||||
|
|
||||||
[ \t\r]+ ;
|
[ \t\r]+ ;
|
||||||
|
|
|
@ -26,16 +26,41 @@ int major;
|
||||||
%token POINTER_DEFAULT_KEYWORD
|
%token POINTER_DEFAULT_KEYWORD
|
||||||
%token <token> UNIQUE_KEYWORD
|
%token <token> UNIQUE_KEYWORD
|
||||||
%token INTERFACE_KEYWORD
|
%token INTERFACE_KEYWORD
|
||||||
|
%token IMPLICIT_HANDLE_KEYWORD
|
||||||
|
%token AUTO_HANDLE_KEYWORD
|
||||||
|
%token AGGREGATABLE_KEYWORD
|
||||||
|
%token ALLOCATE_KEYWORD
|
||||||
|
%token APPOBJECT_KEYWORD
|
||||||
|
|
||||||
%token IN_KEYWORD, OUT_KEYWORD,
|
%token ALL_NODES_KEYWORD
|
||||||
|
%token SINGLE_NODE_KEYWORD
|
||||||
|
%token FREE_KEYWORD
|
||||||
|
%token DONT_FREE_KEYWORD
|
||||||
|
|
||||||
|
%token TYPEDEF_KEYWORD
|
||||||
|
%token STRUCT_KEYWORD
|
||||||
|
%token CONST_KEYWORD
|
||||||
|
|
||||||
|
%token IN_KEYWORD
|
||||||
|
%token OUT_KEYWORD
|
||||||
|
%token STRING_KEYWORD
|
||||||
|
%token SIZE_IS_KEYWORD
|
||||||
|
%token LENGTH_IS_KEYWORD
|
||||||
|
|
||||||
|
%token UNSIGNED_KEYWORD
|
||||||
|
%token SIGNED_KEYWORD
|
||||||
|
|
||||||
%token LSQBRACKET, RSQBRACKET, LBRACKET, RBRACKET
|
%token LSQBRACKET, RSQBRACKET, LBRACKET, RBRACKET
|
||||||
%token LCURLY_BRACKET, RCURLY_BRACKET, LINE_TERMINATOR, COMMA
|
%token LCURLY_BRACKET, RCURLY_BRACKET, LINE_TERMINATOR, COMMA
|
||||||
%token LEFT_BRACKET, RIGHT_BRACKET
|
%token LEFT_BRACKET, RIGHT_BRACKET
|
||||||
|
%token STAR
|
||||||
|
%token ASSIGNMENT
|
||||||
|
|
||||||
%token <tval> TYPE_KEYWORD
|
%token <tval> TYPE_KEYWORD
|
||||||
|
|
||||||
%type <tval> type
|
%type <tval> type
|
||||||
|
%type <tval> sign
|
||||||
|
%type <tval> struct_def
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
@ -63,7 +88,16 @@ interface: { start_interface(); }
|
||||||
|
|
||||||
functions:
|
functions:
|
||||||
| function LINE_TERMINATOR functions
|
| function LINE_TERMINATOR functions
|
||||||
;
|
| TYPEDEF_KEYWORD typedef LINE_TERMINATOR functions
|
||||||
|
| const LINE_TERMINATOR functions
|
||||||
|
| STRUCT_KEYWORD struct_def RCURLY_BRACKET LINE_TERMINATOR functions
|
||||||
|
;
|
||||||
|
|
||||||
|
const: CONST_KEYWORD type ID_TOKEN ASSIGNMENT ID_TOKEN
|
||||||
|
| CONST_KEYWORD type ID_TOKEN ASSIGNMENT NUMBER_TOKEN
|
||||||
|
;
|
||||||
|
|
||||||
|
typedef: type ID_TOKEN { add_typedef($2, $1); };
|
||||||
|
|
||||||
function: { start_function(); }
|
function: { start_function(); }
|
||||||
type ID_TOKEN LEFT_BRACKET argument_list RIGHT_BRACKET
|
type ID_TOKEN LEFT_BRACKET argument_list RIGHT_BRACKET
|
||||||
|
@ -80,12 +114,59 @@ argument_list:
|
||||||
| argument COMMA argument_list
|
| argument COMMA argument_list
|
||||||
;
|
;
|
||||||
|
|
||||||
argument:
|
argument: arg_attrs type ID_TOKEN { add_argument($2, $3); }
|
||||||
LSQBRACKET direction RSQBRACKET type ID_TOKEN { add_argument($4, $5); }
|
| type ID_TOKEN { add_argument($1, $2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
type: TYPE_KEYWORD;
|
type: sign TYPE_KEYWORD STAR { $$ = $2 | POINTER_TYPE_OPTION | $1; }
|
||||||
|
| sign TYPE_KEYWORD { $$ = $2 | $1; }
|
||||||
|
| TYPE_KEYWORD { $$ = $1; }
|
||||||
|
| TYPE_KEYWORD STAR { $$ = $1 | POINTER_TYPE_OPTION; }
|
||||||
|
| STRUCT_KEYWORD struct_def RCURLY_BRACKET { $$ = $2; }
|
||||||
|
| STRUCT_KEYWORD ID_TOKEN { $$ = struct_to_type($2); }
|
||||||
|
;
|
||||||
|
|
||||||
direction:
|
struct_def: ID_TOKEN { start_struct($1); } LCURLY_BRACKET
|
||||||
IN_KEYWORD
|
struct_members { $$ = end_struct(); }
|
||||||
|
| { start_struct(NULL); } LCURLY_BRACKET
|
||||||
|
struct_members { $$ = end_struct(); }
|
||||||
|
;
|
||||||
|
|
||||||
|
struct_members:
|
||||||
|
| type ID_TOKEN LINE_TERMINATOR struct_members
|
||||||
|
{ add_struct_member($2, $1); }
|
||||||
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Rules for the optional sign for an integer type
|
||||||
|
*/
|
||||||
|
sign: UNSIGNED_KEYWORD { $$ = UNSIGNED_TYPE_OPTION; }
|
||||||
|
| SIGNED_KEYWORD { $$ = SIGNED_TYPE_OPTION; }
|
||||||
|
;
|
||||||
|
|
||||||
|
arg_attrs: LSQBRACKET arg_attr_list RSQBRACKET
|
||||||
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Rules for the list of attributes for arguments
|
||||||
|
*/
|
||||||
|
arg_attr_list: arg_attr
|
||||||
|
| arg_attr COMMA arg_attr_list
|
||||||
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Rules for the various attributes for arguments
|
||||||
|
*/
|
||||||
|
arg_attr: IN_KEYWORD
|
||||||
|
| OUT_KEYWORD
|
||||||
|
| STRING_KEYWORD
|
||||||
|
| LENGTH_IS_KEYWORD BRACKETED_QUANTITY
|
||||||
|
| SIZE_IS_KEYWORD BRACKETED_QUANTITY
|
||||||
;
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
BRACKETED_QUANTITY: LEFT_BRACKET NUMBER_TOKEN RIGHT_BRACKET
|
||||||
|
| LEFT_BRACKET ID_TOKEN RIGHT_BRACKET
|
||||||
|
;
|
||||||
|
|
|
@ -4,14 +4,37 @@
|
||||||
|
|
||||||
#include "midl.h"
|
#include "midl.h"
|
||||||
|
|
||||||
|
struct _type;
|
||||||
|
|
||||||
|
typedef struct _struct_member
|
||||||
|
{
|
||||||
|
char* name;
|
||||||
|
unsigned int value;
|
||||||
|
struct _struct_member* next;
|
||||||
|
} struct_member;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
{
|
||||||
|
struct_member* member_list;
|
||||||
|
char* tag;
|
||||||
|
struct _type* type_value;
|
||||||
|
} struct_type;
|
||||||
|
|
||||||
|
typedef struct _type
|
||||||
{
|
{
|
||||||
char* name;
|
char* name;
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
unsigned int default_sign;
|
unsigned int default_sign;
|
||||||
|
struct_type* struct_desc;
|
||||||
} type;
|
} type;
|
||||||
|
|
||||||
static type types[] = {
|
static struct_type struct_types[255];
|
||||||
|
|
||||||
|
static int next_struct_slot_free = 0;
|
||||||
|
static struct_type* current_struct;
|
||||||
|
|
||||||
|
static type types[255] = {
|
||||||
|
{NULL, 0, 0},
|
||||||
{"boolean", BOOLEAN_TYPE, UNSIGNED_TYPE_OPTION},
|
{"boolean", BOOLEAN_TYPE, UNSIGNED_TYPE_OPTION},
|
||||||
{"byte", BYTE_TYPE, 0},
|
{"byte", BYTE_TYPE, 0},
|
||||||
{"char", CHAR_TYPE, UNSIGNED_TYPE_OPTION},
|
{"char", CHAR_TYPE, UNSIGNED_TYPE_OPTION},
|
||||||
|
@ -32,15 +55,119 @@ static type types[] = {
|
||||||
{NULL, 0, 0}
|
{NULL, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int next_free_slot = 18;
|
||||||
|
|
||||||
|
unsigned int struct_to_type(char* tag)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < next_struct_slot_free; i++)
|
||||||
|
{
|
||||||
|
if (strcmp(tag, struct_types[i].tag) == 0)
|
||||||
|
{
|
||||||
|
return(struct_types[i].type_value->value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void start_struct(char* tag)
|
||||||
|
{
|
||||||
|
char* name;
|
||||||
|
|
||||||
|
if (tag == NULL)
|
||||||
|
{
|
||||||
|
tag = malloc(255);
|
||||||
|
sprintf(tag, "__unnamed_struct%d", next_struct_slot_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
name = malloc(strlen("struct ") + strlen(tag) + 1);
|
||||||
|
strcpy(name, "struct ");
|
||||||
|
strcat(name, tag);
|
||||||
|
|
||||||
|
struct_types[next_struct_slot_free].tag = strdup(tag);
|
||||||
|
struct_types[next_struct_slot_free].member_list = NULL;
|
||||||
|
current_struct = &struct_types[next_struct_slot_free];
|
||||||
|
|
||||||
|
types[next_free_slot].name = name;
|
||||||
|
types[next_free_slot].value = next_free_slot << 8;
|
||||||
|
types[next_free_slot].default_sign = 0;
|
||||||
|
types[next_free_slot].struct_desc =
|
||||||
|
&struct_types[next_struct_slot_free];
|
||||||
|
|
||||||
|
struct_types[next_struct_slot_free].type_value = &types[next_free_slot];
|
||||||
|
|
||||||
|
next_struct_slot_free++;
|
||||||
|
next_free_slot++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_struct_member(char* name, unsigned int type)
|
||||||
|
{
|
||||||
|
struct_member* member;
|
||||||
|
|
||||||
|
member = malloc(sizeof(struct_member));
|
||||||
|
|
||||||
|
member->name = strdup(name);
|
||||||
|
member->value = type;
|
||||||
|
member->next = current_struct->member_list;
|
||||||
|
current_struct->member_list = member;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int end_struct(void)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
struct_member* cur;
|
||||||
|
|
||||||
|
printf("Defining struct %s {\n", current_struct->tag);
|
||||||
|
|
||||||
|
cur = current_struct->member_list;
|
||||||
|
while (cur != NULL)
|
||||||
|
{
|
||||||
|
print_type(cur->value);
|
||||||
|
printf(" %s\n", cur->name);
|
||||||
|
|
||||||
|
cur = cur->next;
|
||||||
|
}
|
||||||
|
printf("}\n");
|
||||||
|
|
||||||
|
n = current_struct->type_value->value;
|
||||||
|
current_struct = NULL;
|
||||||
|
return(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_typedef(char* name, int type)
|
||||||
|
{
|
||||||
|
printf("Adding typedef %s to ", name);
|
||||||
|
print_type(type);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
types[next_free_slot].name = strdup(name);
|
||||||
|
types[next_free_slot].value = type;
|
||||||
|
types[next_free_slot].default_sign = 0;
|
||||||
|
next_free_slot++;
|
||||||
|
}
|
||||||
|
|
||||||
void print_type(int tval)
|
void print_type(int tval)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; types[i].name != NULL; i++)
|
for (i = 1; i < next_free_slot; i++)
|
||||||
{
|
{
|
||||||
if (tval == types[i].value)
|
if ((tval & BASE_TYPE_MASK) == types[i].value)
|
||||||
{
|
{
|
||||||
|
if (tval & UNSIGNED_TYPE_OPTION)
|
||||||
|
{
|
||||||
|
printf("unsigned ");
|
||||||
|
}
|
||||||
|
if (tval & SIGNED_TYPE_OPTION)
|
||||||
|
{
|
||||||
|
printf("signed ");
|
||||||
|
}
|
||||||
printf("%s", types[i].name);
|
printf("%s", types[i].name);
|
||||||
|
if (tval & POINTER_TYPE_OPTION)
|
||||||
|
{
|
||||||
|
printf("*");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +178,7 @@ int token_to_type(char* token)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; types[i].name != NULL; i++)
|
for (i = 1; i < next_free_slot; i++)
|
||||||
{
|
{
|
||||||
if (strcmp(types[i].name, token) == 0)
|
if (strcmp(types[i].name, token) == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
#ifndef __TYPES_H
|
#ifndef __TYPES_H
|
||||||
#define __TYPES_H
|
#define __TYPES_H
|
||||||
|
|
||||||
|
#define BASE_TYPE_MASK (~0xff)
|
||||||
|
|
||||||
#define BOOLEAN_TYPE (0x100)
|
#define BOOLEAN_TYPE (0x100)
|
||||||
#define BYTE_TYPE (0x200)
|
#define BYTE_TYPE (0x200)
|
||||||
#define CHAR_TYPE (0x400)
|
#define CHAR_TYPE (0x300)
|
||||||
#define DOUBLE_TYPE (0x800)
|
#define DOUBLE_TYPE (0x400)
|
||||||
#define ERROR_STATUS_TYPE (0x1000)
|
#define ERROR_STATUS_TYPE (0x500)
|
||||||
#define FLOAT_TYPE (0x2000)
|
#define FLOAT_TYPE (0x600)
|
||||||
#define HANDLE_TYPE (0x4000)
|
#define HANDLE_TYPE (0x700)
|
||||||
#define HYPER_TYPE (0x8000)
|
#define HYPER_TYPE (0x800)
|
||||||
#define INT_TYPE (0x10000)
|
#define INT_TYPE (0x900)
|
||||||
#define INT32_TYPE (0x20000)
|
#define INT32_TYPE (0xA00)
|
||||||
#define INT32OR64_TYPE (0x40000)
|
#define INT32OR64_TYPE (0xB00)
|
||||||
#define INT64_TYPE (0x80000)
|
#define INT64_TYPE (0xC00)
|
||||||
#define LONG_TYPE (0x100000)
|
#define LONG_TYPE (0xD00)
|
||||||
#define SHORT_TYPE (0x200000)
|
#define SHORT_TYPE (0xE00)
|
||||||
#define SMALL_TYPE (0x400000)
|
#define SMALL_TYPE (0xF00)
|
||||||
#define VOID_TYPE (0x800000)
|
#define VOID_TYPE (0x1000)
|
||||||
#define WCHAR_TYPE (0x1000000)
|
#define WCHAR_TYPE (0x1100)
|
||||||
|
|
||||||
#define UNSIGNED_TYPE_OPTION (0x1)
|
#define UNSIGNED_TYPE_OPTION (0x1)
|
||||||
#define SIGNED_TYPE_OPTION (0x2)
|
#define SIGNED_TYPE_OPTION (0x2)
|
||||||
|
@ -29,5 +31,12 @@
|
||||||
|
|
||||||
int token_to_type(char* token);
|
int token_to_type(char* token);
|
||||||
void print_type(int tval);
|
void print_type(int tval);
|
||||||
|
void add_typedef(char* name, int type);
|
||||||
|
|
||||||
|
void start_struct(char* tag);
|
||||||
|
void add_struct_member(char* name, unsigned int type);
|
||||||
|
unsigned int end_struct(void);
|
||||||
|
|
||||||
|
unsigned int struct_to_type(char* tag);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
37
reactos/lib/rpcrt4/srv/ep.c
Normal file
37
reactos/lib/rpcrt4/srv/ep.c
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
RPC_STATUS RpcServerUseProtseqEpA(unsigned char* Protseq,
|
||||||
|
unsigned int MaxCalls,
|
||||||
|
unsigned char* Endpoint,
|
||||||
|
void* SecurityDescriptor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RPC_STATUS RpcServerUseProtseqEpW(unsigned short* Protseq,
|
||||||
|
unsigned int MaxCalls,
|
||||||
|
unsigned short* Endpoint,
|
||||||
|
void* SecurityDescriptor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RPC_STATUS RpcServerRegisterIf(RPC_IF_HANDLE IfSpec,
|
||||||
|
UUID* MgrTypeUuid,
|
||||||
|
RPC_MGR_EPV* MgrEpv)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
RPC_STATUS RpcServerListen(unsigned int MinimumCallThreads,
|
||||||
|
unsigned int MaxCalls,
|
||||||
|
unsigned int DontWait)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
21
reactos/lib/rpcrt4/srv/impersonate.c
Normal file
21
reactos/lib/rpcrt4/srv/impersonate.c
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
RPC_STATUS RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RPC_STATUS RpcRevertToSelfEx(RPC_BINDING_HANDLE BindingHandle)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RPC_STATUS RpcRevertToSelf()
|
||||||
|
{
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.29 2000/03/26 19:38:21 ea Exp $
|
/* $Id: create.c,v 1.30 2000/03/29 13:11:53 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -320,7 +320,7 @@ IoCreateFile (
|
||||||
KEVENT Event;
|
KEVENT Event;
|
||||||
PIO_STACK_LOCATION StackLoc;
|
PIO_STACK_LOCATION StackLoc;
|
||||||
|
|
||||||
DPRINT1("IoCreateFile(FileHandle %x, DesiredAccess %x, "
|
DPRINT("IoCreateFile(FileHandle %x, DesiredAccess %x, "
|
||||||
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
|
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
|
||||||
FileHandle,DesiredAccess,ObjectAttributes,
|
FileHandle,DesiredAccess,ObjectAttributes,
|
||||||
ObjectAttributes->ObjectName->Buffer);
|
ObjectAttributes->ObjectName->Buffer);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: page.c,v 1.6 2000/03/26 19:38:26 ea Exp $
|
/* $Id: page.c,v 1.7 2000/03/29 13:11:53 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -19,15 +19,10 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL IoPageRead(PFILE_OBJECT FileObject,
|
||||||
STDCALL
|
PMDL Mdl,
|
||||||
IoPageRead (
|
PLARGE_INTEGER Offset,
|
||||||
PFILE_OBJECT FileObject,
|
PIO_STATUS_BLOCK StatusBlock)
|
||||||
PMDL Mdl,
|
|
||||||
PLARGE_INTEGER Offset,
|
|
||||||
PIO_STATUS_BLOCK StatusBlock,
|
|
||||||
DWORD Unknown4
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
KEVENT Event;
|
KEVENT Event;
|
||||||
|
@ -72,18 +67,14 @@ IoPageRead (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL IoSynchronousPageWrite (DWORD Unknown0,
|
||||||
STDCALL
|
DWORD Unknown1,
|
||||||
IoSynchronousPageWrite (
|
DWORD Unknown2,
|
||||||
DWORD Unknown0,
|
DWORD Unknown3,
|
||||||
DWORD Unknown1,
|
DWORD Unknown4)
|
||||||
DWORD Unknown2,
|
|
||||||
DWORD Unknown3,
|
|
||||||
DWORD Unknown4
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
return (STATUS_NOT_IMPLEMENTED);
|
return (STATUS_NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ asmlinkage void exception_handler(unsigned int edi,
|
||||||
DbgPrint("EDI: %.8x EFLAGS: %.8x ",edi,eflags);
|
DbgPrint("EDI: %.8x EFLAGS: %.8x ",edi,eflags);
|
||||||
if ((cs&0xffff) == KERNEL_CS)
|
if ((cs&0xffff) == KERNEL_CS)
|
||||||
{
|
{
|
||||||
DbgPrint("kESP %.8x\n",esp);
|
DbgPrint("kESP %.8x ",esp);
|
||||||
if (PsGetCurrentThread() != NULL)
|
if (PsGetCurrentThread() != NULL)
|
||||||
{
|
{
|
||||||
DbgPrint("kernel stack base %x\n",
|
DbgPrint("kernel stack base %x\n",
|
||||||
|
@ -285,9 +285,8 @@ asmlinkage void exception_handler(unsigned int edi,
|
||||||
stack = (PULONG) (esp + 24);
|
stack = (PULONG) (esp + 24);
|
||||||
// stack = (PULONG)(((ULONG)stack) & (~0x3));
|
// stack = (PULONG)(((ULONG)stack) & (~0x3));
|
||||||
|
|
||||||
DbgPrint("stack: %p\n", stack);
|
DbgPrint("stack<%p>: ", stack);
|
||||||
|
|
||||||
DbgPrint("Stack:\n");
|
|
||||||
for (i = 0; i < 16; i = i + 4)
|
for (i = 0; i < 16; i = i + 4)
|
||||||
{
|
{
|
||||||
DbgPrint("%.8x %.8x %.8x %.8x\n",
|
DbgPrint("%.8x %.8x %.8x %.8x\n",
|
||||||
|
|
|
@ -33,7 +33,12 @@ LONG KeReadStateMutex(PKMUTEX Mutex)
|
||||||
LONG KeReleaseMutex(PKMUTEX Mutex, BOOLEAN Wait)
|
LONG KeReleaseMutex(PKMUTEX Mutex, BOOLEAN Wait)
|
||||||
{
|
{
|
||||||
KeAcquireDispatcherDatabaseLock(Wait);
|
KeAcquireDispatcherDatabaseLock(Wait);
|
||||||
KeDispatcherObjectWake(&Mutex->Header);
|
Mutex->Header.SignalState--;
|
||||||
|
assert(Mutex->Header.SignalState >= 0);
|
||||||
|
if (Mutex->Header.SignalState == 0)
|
||||||
|
{
|
||||||
|
KeDispatcherObjectWake(&Mutex->Header);
|
||||||
|
}
|
||||||
KeReleaseDispatcherDatabaseLock(Wait);
|
KeReleaseDispatcherDatabaseLock(Wait);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,8 @@ VOID KeReleaseDispatcherDatabaseLock(BOOLEAN Wait)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID KiSideEffectsBeforeWake(DISPATCHER_HEADER* hdr)
|
VOID KiSideEffectsBeforeWake(DISPATCHER_HEADER* hdr,
|
||||||
|
PKTHREAD Thread)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Perform side effects on object before a wait for a thread is
|
* FUNCTION: Perform side effects on object before a wait for a thread is
|
||||||
* satisfied
|
* satisfied
|
||||||
|
@ -104,6 +105,18 @@ VOID KiSideEffectsBeforeWake(DISPATCHER_HEADER* hdr)
|
||||||
case InternalNotificationTimer:
|
case InternalNotificationTimer:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case InternalMutexType:
|
||||||
|
{
|
||||||
|
PKMUTEX Mutex;
|
||||||
|
|
||||||
|
Mutex = CONTAINING_RECORD(hdr,
|
||||||
|
KMUTEX,
|
||||||
|
Header);
|
||||||
|
hdr->SignalState++;
|
||||||
|
Mutex->OwnerThread = Thread;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DbgPrint("(%s:%d) Dispatcher object %x has unknown type\n",
|
DbgPrint("(%s:%d) Dispatcher object %x has unknown type\n",
|
||||||
__FILE__,__LINE__,hdr);
|
__FILE__,__LINE__,hdr);
|
||||||
|
@ -112,14 +125,39 @@ VOID KiSideEffectsBeforeWake(DISPATCHER_HEADER* hdr)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOLEAN KiIsObjectSignalled(DISPATCHER_HEADER* hdr)
|
static BOOLEAN KiIsObjectSignalled(DISPATCHER_HEADER* hdr,
|
||||||
|
PKTHREAD Thread)
|
||||||
{
|
{
|
||||||
|
if (hdr->Type == InternalMutexType)
|
||||||
|
{
|
||||||
|
PKMUTEX Mutex;
|
||||||
|
|
||||||
|
Mutex = CONTAINING_RECORD(hdr,
|
||||||
|
KMUTEX,
|
||||||
|
Header);
|
||||||
|
|
||||||
|
if ((hdr->SignalState <= 0 &&
|
||||||
|
Mutex->OwnerThread == Thread) ||
|
||||||
|
hdr->SignalState > 0)
|
||||||
|
{
|
||||||
|
KiSideEffectsBeforeWake(hdr,
|
||||||
|
Thread);
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (hdr->SignalState <= 0)
|
if (hdr->SignalState <= 0)
|
||||||
{
|
{
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
KiSideEffectsBeforeWake(hdr);
|
else
|
||||||
return(TRUE);
|
{
|
||||||
|
KiSideEffectsBeforeWake(hdr, Thread);
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID KeRemoveAllWaitsThread(PETHREAD Thread, NTSTATUS WaitStatus)
|
VOID KeRemoveAllWaitsThread(PETHREAD Thread, NTSTATUS WaitStatus)
|
||||||
|
@ -166,7 +204,8 @@ static BOOLEAN KeDispatcherObjectWakeAll(DISPATCHER_HEADER* hdr)
|
||||||
while (!IsListEmpty(&(hdr->WaitListHead)))
|
while (!IsListEmpty(&(hdr->WaitListHead)))
|
||||||
{
|
{
|
||||||
current_entry = RemoveHeadList(&hdr->WaitListHead);
|
current_entry = RemoveHeadList(&hdr->WaitListHead);
|
||||||
current = CONTAINING_RECORD(current_entry,KWAIT_BLOCK,
|
current = CONTAINING_RECORD(current_entry,
|
||||||
|
KWAIT_BLOCK,
|
||||||
WaitListEntry);
|
WaitListEntry);
|
||||||
DPRINT("Waking %x\n",current->Thread);
|
DPRINT("Waking %x\n",current->Thread);
|
||||||
if (current->WaitType == WaitAny)
|
if (current->WaitType == WaitAny)
|
||||||
|
@ -200,10 +239,13 @@ static BOOLEAN KeDispatcherObjectWakeAll(DISPATCHER_HEADER* hdr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KiSideEffectsBeforeWake(hdr);
|
KiSideEffectsBeforeWake(hdr, current->Thread);
|
||||||
Status = current->WaitKey;
|
Status = current->WaitKey;
|
||||||
if( current->Thread->WaitBlockList == NULL )
|
if (current->Thread->WaitBlockList == NULL)
|
||||||
PsUnfreezeThread( CONTAINING_RECORD( current->Thread,ETHREAD,Tcb ), &Status );
|
{
|
||||||
|
PsUnfreezeThread(CONTAINING_RECORD(current->Thread,ETHREAD,Tcb),
|
||||||
|
&Status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
@ -260,9 +302,10 @@ static BOOLEAN KeDispatcherObjectWakeOne(DISPATCHER_HEADER* hdr)
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("Waking %x\n",current->Thread);
|
DPRINT("Waking %x\n",current->Thread);
|
||||||
KiSideEffectsBeforeWake(hdr);
|
KiSideEffectsBeforeWake(hdr, current->Thread);
|
||||||
Status = current->WaitKey;
|
Status = current->WaitKey;
|
||||||
PsUnfreezeThread( CONTAINING_RECORD( current->Thread, ETHREAD, Tcb ), &Status );
|
PsUnfreezeThread(CONTAINING_RECORD(current->Thread, ETHREAD, Tcb),
|
||||||
|
&Status);
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +409,7 @@ NTSTATUS KeWaitForSingleObject(PVOID Object,
|
||||||
|
|
||||||
DPRINT("hdr->SignalState %d\n", hdr->SignalState);
|
DPRINT("hdr->SignalState %d\n", hdr->SignalState);
|
||||||
|
|
||||||
if (KiIsObjectSignalled(hdr))
|
if (KiIsObjectSignalled(hdr, CurrentThread))
|
||||||
{
|
{
|
||||||
KeReleaseDispatcherDatabaseLock(FALSE);
|
KeReleaseDispatcherDatabaseLock(FALSE);
|
||||||
if (Timeout != NULL)
|
if (Timeout != NULL)
|
||||||
|
@ -457,7 +500,7 @@ NTSTATUS KeWaitForMultipleObjects(ULONG Count,
|
||||||
|
|
||||||
DPRINT("hdr->SignalState %d\n", hdr->SignalState);
|
DPRINT("hdr->SignalState %d\n", hdr->SignalState);
|
||||||
|
|
||||||
if (KiIsObjectSignalled(hdr))
|
if (KiIsObjectSignalled(hdr, CurrentThread))
|
||||||
{
|
{
|
||||||
CountSignaled++;
|
CountSignaled++;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile_rex,v 1.64 2000/03/26 19:38:17 ea Exp $
|
# $Id: makefile_rex,v 1.65 2000/03/29 13:11:52 dwelch Exp $
|
||||||
#
|
#
|
||||||
# ReactOS Operating System
|
# ReactOS Operating System
|
||||||
#
|
#
|
||||||
|
@ -37,7 +37,7 @@ KE_I386_OBJECTS = ke/i386/thread.o ke/i386/usercall.o ke/i386/exp.o
|
||||||
MM_OBJECTS = mm/mm.o mm/freelist.o mm/pool.o mm/virtual.o \
|
MM_OBJECTS = mm/mm.o mm/freelist.o mm/pool.o mm/virtual.o \
|
||||||
mm/mdl.o mm/zone.o mm/paging.o mm/section.o \
|
mm/mdl.o mm/zone.o mm/paging.o mm/section.o \
|
||||||
mm/marea.o mm/ppool.o mm/npool.o mm/pagefile.o \
|
mm/marea.o mm/ppool.o mm/npool.o mm/pagefile.o \
|
||||||
mm/cont.o mm/iospace.o mm/ncache.o
|
mm/cont.o mm/iospace.o mm/ncache.o mm/aspace.o
|
||||||
|
|
||||||
|
|
||||||
MM_I386_OBJECTS = mm/i386/page.o mm/i386/memsafe.o
|
MM_I386_OBJECTS = mm/i386/page.o mm/i386/memsafe.o
|
||||||
|
|
66
reactos/ntoskrnl/mm/aspace.c
Normal file
66
reactos/ntoskrnl/mm/aspace.c
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/* $Id: aspace.c,v 1.1 2000/03/29 13:11:54 dwelch Exp $
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: ntoskrnl/mm/aspace.c
|
||||||
|
* PURPOSE: Manages address spaces
|
||||||
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 22/05/98
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <internal/mm.h>
|
||||||
|
|
||||||
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
|
static MADDRESS_SPACE KernelAddressSpace;
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
VOID MmLockAddressSpace(PMADDRESS_SPACE AddressSpace)
|
||||||
|
{
|
||||||
|
(VOID)KeWaitForMutexObject(&AddressSpace->Lock,
|
||||||
|
0,
|
||||||
|
KernelMode,
|
||||||
|
FALSE,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MmUnlockAddressSpace(PMADDRESS_SPACE AddressSpace)
|
||||||
|
{
|
||||||
|
KeReleaseMutex(&AddressSpace->Lock, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MmInitializeKernelAddressSpace(VOID)
|
||||||
|
{
|
||||||
|
MmInitializeAddressSpace(&KernelAddressSpace);
|
||||||
|
KernelAddressSpace.LowestAddress = KERNEL_BASE;
|
||||||
|
}
|
||||||
|
|
||||||
|
PMADDRESS_SPACE MmGetCurrentAddressSpace(VOID)
|
||||||
|
{
|
||||||
|
return(&PsGetCurrentProcess()->Pcb.AddressSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
PMADDRESS_SPACE MmGetKernelAddressSpace(VOID)
|
||||||
|
{
|
||||||
|
return(&KernelAddressSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS MmInitializeAddressSpace(PMADDRESS_SPACE AddressSpace)
|
||||||
|
{
|
||||||
|
InitializeListHead(&AddressSpace->MAreaListHead);
|
||||||
|
KeInitializeMutex(&AddressSpace->Lock, 1);
|
||||||
|
AddressSpace->LowestAddress = MM_LOWEST_USER_ADDRESS;
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS MmDestroyAddressSpace(PMADDRESS_SPACE AddressSpace)
|
||||||
|
{
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: cont.c,v 1.3 2000/03/19 09:14:51 ea Exp $
|
/* $Id: cont.c,v 1.4 2000/03/29 13:11:54 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -44,14 +44,11 @@
|
||||||
* REVISIONS
|
* REVISIONS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
PVOID
|
PVOID STDCALL MmAllocateContiguousMemory (
|
||||||
STDCALL
|
IN ULONG NumberOfBytes,
|
||||||
MmAllocateContiguousMemory (
|
IN PHYSICAL_ADDRESS HighestAcceptableAddress)
|
||||||
IN ULONG NumberOfBytes,
|
|
||||||
IN PHYSICAL_ADDRESS HighestAcceptableAddress
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,13 +74,9 @@ MmAllocateContiguousMemory (
|
||||||
* REVISIONS
|
* REVISIONS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
VOID
|
VOID STDCALL MmFreeContiguousMemory(IN PVOID BaseAddress)
|
||||||
STDCALL
|
|
||||||
MmFreeContiguousMemory (
|
|
||||||
IN OUT PVOID BaseAddress
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: iospace.c,v 1.2 2000/03/19 09:14:51 ea Exp $
|
/* $Id: iospace.c,v 1.3 2000/03/29 13:11:54 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME EXPORTED
|
* NAME EXPORTED
|
||||||
* MmMapIoSpace@16
|
* MmMapIoSpace@16
|
||||||
|
@ -47,58 +46,41 @@
|
||||||
* REVISIONS
|
* REVISIONS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
PVOID
|
PVOID STDCALL MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress,
|
||||||
STDCALL
|
IN ULONG NumberOfBytes,
|
||||||
MmMapIoSpace (
|
IN BOOLEAN CacheEnable)
|
||||||
IN PHYSICAL_ADDRESS PhysicalAddress,
|
|
||||||
IN ULONG NumberOfBytes,
|
|
||||||
IN BOOLEAN CacheEnable
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
PVOID Result;
|
PVOID Result;
|
||||||
MEMORY_AREA * marea;
|
MEMORY_AREA* marea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
ULONG Attributes;
|
ULONG Attributes;
|
||||||
|
|
||||||
Result = NULL;
|
Result = NULL;
|
||||||
Status = MmCreateMemoryArea (
|
Status = MmCreateMemoryArea (NULL,
|
||||||
KernelMode,
|
MmGetKernelAddressSpace(),
|
||||||
PsGetCurrentProcess (),
|
MEMORY_AREA_IO_MAPPING,
|
||||||
MEMORY_AREA_IO_MAPPING,
|
&Result,
|
||||||
& Result,
|
NumberOfBytes,
|
||||||
NumberOfBytes,
|
0,
|
||||||
0,
|
&marea);
|
||||||
& marea
|
if (!NT_SUCCESS(STATUS_SUCCESS))
|
||||||
);
|
{
|
||||||
if (STATUS_SUCCESS != Status)
|
return (NULL);
|
||||||
{
|
}
|
||||||
return (NULL);
|
Attributes = PA_WRITE | PA_READ | PA_EXECUTE | PA_SYSTEM;
|
||||||
}
|
if (!CacheEnable)
|
||||||
Attributes = ( PA_WRITE
|
{
|
||||||
| PA_READ
|
Attributes |= (PA_PWT | PA_PCD);
|
||||||
| PA_EXECUTE
|
}
|
||||||
| PA_SYSTEM
|
for (i = 0; (i <= (NumberOfBytes / PAGESIZE)); i++)
|
||||||
);
|
{
|
||||||
if (!CacheEnable)
|
MmSetPage (NULL,
|
||||||
{
|
(Result + (i * PAGESIZE)),
|
||||||
Attributes |= (PA_PWT | PA_PCD);
|
PAGE_READWRITE,
|
||||||
}
|
(PhysicalAddress.u.LowPart + (i * PAGESIZE)));
|
||||||
for ( i = 0;
|
}
|
||||||
(i <= (NumberOfBytes / PAGESIZE));
|
return ((PVOID)Result);
|
||||||
i ++
|
|
||||||
)
|
|
||||||
{
|
|
||||||
MmSetPage (
|
|
||||||
NULL,
|
|
||||||
(Result + (i * PAGESIZE)),
|
|
||||||
PAGE_READWRITE,
|
|
||||||
( PhysicalAddress.u.LowPart
|
|
||||||
+ (i * PAGESIZE)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return ((PVOID) Result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,19 +107,13 @@ MmMapIoSpace (
|
||||||
* REVISIONS
|
* REVISIONS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
VOID
|
VOID STDCALL MmUnmapIoSpace (IN PVOID BaseAddress,
|
||||||
STDCALL
|
IN ULONG NumberOfBytes)
|
||||||
MmUnmapIoSpace (
|
|
||||||
IN PVOID BaseAddress,
|
|
||||||
IN ULONG NumberOfBytes
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
(VOID) MmFreeMemoryArea (
|
(VOID)MmFreeMemoryArea(&PsGetCurrentProcess()->Pcb.AddressSpace,
|
||||||
PsGetCurrentProcess (),
|
BaseAddress,
|
||||||
BaseAddress,
|
NumberOfBytes,
|
||||||
NumberOfBytes,
|
FALSE);
|
||||||
FALSE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,6 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
|
||||||
|
|
||||||
static LIST_ENTRY SystemAreaList;
|
|
||||||
static KSPIN_LOCK SystemAreaListLock;
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
|
VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
|
||||||
|
@ -44,97 +39,23 @@ VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
|
||||||
DbgPrint("Finished MmDumpMemoryAreas()\n");
|
DbgPrint("Finished MmDumpMemoryAreas()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID MmLockMemoryAreaList(PVOID Address, PKIRQL oldlvl)
|
MEMORY_AREA* MmOpenMemoryAreaByAddress(PMADDRESS_SPACE AddressSpace,
|
||||||
{
|
PVOID Address)
|
||||||
if (Address >= (PVOID)KERNEL_BASE)
|
|
||||||
{
|
|
||||||
KeAcquireSpinLock(&SystemAreaListLock,oldlvl);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PKPROCESS CurrentProcess = KeGetCurrentProcess();
|
|
||||||
|
|
||||||
KeAcquireSpinLock(&(CurrentProcess->SpinLock),oldlvl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID MmUnlockMemoryAreaList(PVOID Address, PKIRQL oldlvl)
|
|
||||||
{
|
|
||||||
if (Address >= (PVOID)KERNEL_BASE)
|
|
||||||
{
|
|
||||||
KeReleaseSpinLock(&SystemAreaListLock,*oldlvl);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PKPROCESS CurrentProcess = KeGetCurrentProcess();
|
|
||||||
KeReleaseSpinLock(&(CurrentProcess->SpinLock),*oldlvl);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID MmLockMemoryAreaListByMode(KPROCESSOR_MODE Mode, PKIRQL oldlvl)
|
|
||||||
{
|
|
||||||
if (Mode == KernelMode)
|
|
||||||
{
|
|
||||||
KeAcquireSpinLock(&SystemAreaListLock,oldlvl);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PKPROCESS CurrentProcess = KeGetCurrentProcess();
|
|
||||||
|
|
||||||
KeAcquireSpinLock(&(CurrentProcess->SpinLock),oldlvl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID MmUnlockMemoryAreaListByMode(KPROCESSOR_MODE Mode, PKIRQL oldlvl)
|
|
||||||
{
|
|
||||||
if (Mode == KernelMode)
|
|
||||||
{
|
|
||||||
KeReleaseSpinLock(&SystemAreaListLock,*oldlvl);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PKPROCESS CurrentProcess = KeGetCurrentProcess();
|
|
||||||
KeReleaseSpinLock(&(CurrentProcess->SpinLock),*oldlvl);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static PLIST_ENTRY MmGetRelatedListHead(PEPROCESS Process, PVOID BaseAddress)
|
|
||||||
{
|
|
||||||
if (BaseAddress >= (PVOID)KERNEL_BASE)
|
|
||||||
{
|
|
||||||
return(&SystemAreaList);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return(&(Process->Pcb.MemoryAreaList));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
|
|
||||||
PVOID Address)
|
|
||||||
{
|
{
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
MEMORY_AREA* current;
|
MEMORY_AREA* current;
|
||||||
PLIST_ENTRY previous_entry;
|
PLIST_ENTRY previous_entry;
|
||||||
|
|
||||||
// MmDumpMemoryAreas();
|
DPRINT("MmOpenMemoryAreaByAddress(AddressSpace %x, Address %x)\n",
|
||||||
|
AddressSpace, Address);
|
||||||
|
|
||||||
DPRINT("MmInternalOpenMemoryAreaByAddress(ListHead %x, Address %x)\n",
|
previous_entry = &AddressSpace->MAreaListHead;
|
||||||
ListHead,Address);
|
current_entry = AddressSpace->MAreaListHead.Flink;
|
||||||
|
while (current_entry != &AddressSpace->MAreaListHead)
|
||||||
if (ListHead==NULL)
|
|
||||||
{
|
{
|
||||||
return(NULL);
|
current = CONTAINING_RECORD(current_entry,
|
||||||
}
|
MEMORY_AREA,
|
||||||
|
Entry);
|
||||||
previous_entry = ListHead;
|
|
||||||
current_entry = ListHead->Flink;
|
|
||||||
while (current_entry!=ListHead)
|
|
||||||
{
|
|
||||||
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
|
||||||
DPRINT("Scanning %x BaseAddress %x Length %x\n",
|
DPRINT("Scanning %x BaseAddress %x Length %x\n",
|
||||||
current, current->BaseAddress, current->Length);
|
current, current->BaseAddress, current->Length);
|
||||||
assert(current_entry->Blink->Flink == current_entry);
|
assert(current_entry->Blink->Flink == current_entry);
|
||||||
|
@ -171,30 +92,30 @@ static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MEMORY_AREA* MmOpenMemoryAreaByRegion(PMADDRESS_SPACE AddressSpace,
|
||||||
MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
PVOID Address,
|
||||||
PVOID Address,
|
ULONG Length)
|
||||||
ULONG Length)
|
|
||||||
{
|
{
|
||||||
|
MEMORY_AREA* Result;
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
MEMORY_AREA* current;
|
MEMORY_AREA* current;
|
||||||
ULONG Extent;
|
ULONG Extent;
|
||||||
|
|
||||||
DPRINT("MmInternalOpenMemoryAreaByRegion(ListHead %x, Address %x, "
|
DPRINT("MmOpenMemoryByRegion(AddressSpace %x, Address %x, Length %x)\n",
|
||||||
"Length %x)\n",ListHead,Address,Length);
|
AddressSpace, Address, Length);
|
||||||
|
|
||||||
// MmDumpMemoryAreas(ListHead);
|
current_entry = AddressSpace->MAreaListHead.Flink;
|
||||||
|
while (current_entry != &AddressSpace->MAreaListHead)
|
||||||
current_entry = ListHead->Flink;
|
|
||||||
while (current_entry!=ListHead)
|
|
||||||
{
|
{
|
||||||
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
current = CONTAINING_RECORD(current_entry,
|
||||||
|
MEMORY_AREA,
|
||||||
|
Entry);
|
||||||
DPRINT("current->BaseAddress %x current->Length %x\n",
|
DPRINT("current->BaseAddress %x current->Length %x\n",
|
||||||
current->BaseAddress,current->Length);
|
current->BaseAddress,current->Length);
|
||||||
if (current->BaseAddress >= Address &&
|
if (current->BaseAddress >= Address &&
|
||||||
current->BaseAddress < (Address+Length))
|
current->BaseAddress < (Address+Length))
|
||||||
{
|
{
|
||||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
DPRINT("Finished MmOpenMemoryAreaByRegion() = %x\n",
|
||||||
current);
|
current);
|
||||||
return(current);
|
return(current);
|
||||||
}
|
}
|
||||||
|
@ -202,87 +123,32 @@ MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
||||||
if (Extent > (ULONG)Address &&
|
if (Extent > (ULONG)Address &&
|
||||||
Extent < (ULONG)(Address+Length))
|
Extent < (ULONG)(Address+Length))
|
||||||
{
|
{
|
||||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
DPRINT("Finished MmOpenMemoryAreaByRegion() = %x\n",
|
||||||
current);
|
current);
|
||||||
return(current);
|
return(current);
|
||||||
}
|
}
|
||||||
if (current->BaseAddress <= Address &&
|
if (current->BaseAddress <= Address &&
|
||||||
Extent >= (ULONG)(Address+Length))
|
Extent >= (ULONG)(Address+Length))
|
||||||
{
|
{
|
||||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
DPRINT("Finished MmOpenMemoryAreaByRegion() = %x\n",
|
||||||
current);
|
current);
|
||||||
return(current);
|
return(current);
|
||||||
}
|
}
|
||||||
if (current->BaseAddress >= (Address+Length))
|
if (current->BaseAddress >= (Address+Length))
|
||||||
{
|
{
|
||||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()= NULL\n",0);
|
DPRINT("Finished MmOpenMemoryAreaByRegion()= NULL\n",0);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = NULL\n",0);
|
DPRINT("Finished MmOpenMemoryAreaByRegion() = NULL\n",0);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
|
||||||
|
|
||||||
MEMORY_AREA* MmOpenMemoryAreaByRegion(PEPROCESS Process,
|
|
||||||
PVOID Address,
|
|
||||||
ULONG Length)
|
|
||||||
{
|
|
||||||
KIRQL oldlvl;
|
|
||||||
MEMORY_AREA* Result;
|
|
||||||
PLIST_ENTRY ListHead;
|
|
||||||
|
|
||||||
DPRINT("MmOpenMemoryByRegion(Process %x, Address %x, Length %x)\n",
|
|
||||||
Process,Address,Length);
|
|
||||||
|
|
||||||
MmLockMemoryAreaList(Address,&oldlvl);
|
|
||||||
ListHead = MmGetRelatedListHead(Process,Address);
|
|
||||||
Result = MmInternalOpenMemoryAreaByRegion(ListHead,Address,Length);
|
|
||||||
MmUnlockMemoryAreaList(Address,&oldlvl);
|
|
||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VOID MmInsertMemoryArea(PMADDRESS_SPACE AddressSpace,
|
||||||
MEMORY_AREA* MmOpenMemoryAreaByRegionWithoutLock(PEPROCESS Process,
|
MEMORY_AREA* marea)
|
||||||
PVOID Address,
|
|
||||||
ULONG Length)
|
|
||||||
{
|
|
||||||
MEMORY_AREA* Result;
|
|
||||||
PLIST_ENTRY ListHead;
|
|
||||||
|
|
||||||
ListHead = MmGetRelatedListHead(Process, Address);
|
|
||||||
Result = MmInternalOpenMemoryAreaByRegion(ListHead,Address,Length);
|
|
||||||
return(Result);
|
|
||||||
}
|
|
||||||
|
|
||||||
MEMORY_AREA* MmOpenMemoryAreaByAddress(PEPROCESS Process, PVOID Address)
|
|
||||||
{
|
|
||||||
KIRQL oldlvl;
|
|
||||||
MEMORY_AREA* Result;
|
|
||||||
PLIST_ENTRY ListHead;
|
|
||||||
|
|
||||||
DPRINT("MmOpenMemoryAreaByAddress(Address %x)\n",Address);
|
|
||||||
|
|
||||||
MmLockMemoryAreaList(Address,&oldlvl);
|
|
||||||
ListHead = MmGetRelatedListHead(Process, Address);
|
|
||||||
Result = MmInternalOpenMemoryAreaByAddress(ListHead,Address);
|
|
||||||
MmUnlockMemoryAreaList(Address,&oldlvl);
|
|
||||||
return(Result);
|
|
||||||
}
|
|
||||||
|
|
||||||
MEMORY_AREA* MmOpenMemoryAreaByAddressWithoutLock(PEPROCESS Process,
|
|
||||||
PVOID Address)
|
|
||||||
{
|
|
||||||
MEMORY_AREA* Result;
|
|
||||||
PLIST_ENTRY ListHead;
|
|
||||||
|
|
||||||
ListHead = MmGetRelatedListHead(Process, Address);
|
|
||||||
Result = MmInternalOpenMemoryAreaByAddress(ListHead, Address);
|
|
||||||
return(Result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
|
|
||||||
MEMORY_AREA* marea)
|
|
||||||
{
|
{
|
||||||
PLIST_ENTRY ListHead;
|
PLIST_ENTRY ListHead;
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
|
@ -290,13 +156,11 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
|
||||||
MEMORY_AREA* current;
|
MEMORY_AREA* current;
|
||||||
MEMORY_AREA* next;
|
MEMORY_AREA* next;
|
||||||
|
|
||||||
DPRINT("MmInsertMemoryAreaWithoutLock(marea %x)\n",marea);
|
DPRINT("MmInsertMemoryArea(marea %x)\n", marea);
|
||||||
DPRINT("marea->BaseAddress %x\n",marea->BaseAddress);
|
DPRINT("marea->BaseAddress %x\n", marea->BaseAddress);
|
||||||
DPRINT("marea->Length %x\n",marea->Length);
|
DPRINT("marea->Length %x\n", marea->Length);
|
||||||
|
|
||||||
ListHead=MmGetRelatedListHead(Process,marea->BaseAddress);
|
ListHead = &AddressSpace->MAreaListHead;
|
||||||
|
|
||||||
// MmDumpMemoryAreas(ListHead);
|
|
||||||
|
|
||||||
current_entry = ListHead->Flink;
|
current_entry = ListHead->Flink;
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
@ -354,8 +218,8 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
|
||||||
InsertTailList(ListHead,inserted_entry);
|
InsertTailList(ListHead,inserted_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PVOID MmFindGapWithoutLock(PEPROCESS Process,
|
static PVOID MmFindGap(PMADDRESS_SPACE AddressSpace,
|
||||||
KPROCESSOR_MODE Mode, ULONG Length)
|
ULONG Length)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY ListHead;
|
PLIST_ENTRY ListHead;
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
|
@ -363,18 +227,9 @@ static PVOID MmFindGapWithoutLock(PEPROCESS Process,
|
||||||
MEMORY_AREA* next;
|
MEMORY_AREA* next;
|
||||||
ULONG Gap;
|
ULONG Gap;
|
||||||
|
|
||||||
DPRINT("MmFindGapWithoutLock(Mode %x Length %x)\n",Mode,Length);
|
DPRINT("MmFindGap(Length %x)\n",Length);
|
||||||
|
|
||||||
|
|
||||||
if (Mode == KernelMode)
|
|
||||||
{
|
|
||||||
ListHead = &SystemAreaList;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ListHead = &(Process->Pcb.MemoryAreaList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ListHead = &AddressSpace->MAreaListHead;
|
||||||
|
|
||||||
current_entry = ListHead->Flink;
|
current_entry = ListHead->Flink;
|
||||||
while (current_entry->Flink!=ListHead)
|
while (current_entry->Flink!=ListHead)
|
||||||
|
@ -396,8 +251,7 @@ static PVOID MmFindGapWithoutLock(PEPROCESS Process,
|
||||||
|
|
||||||
if (current_entry == ListHead)
|
if (current_entry == ListHead)
|
||||||
{
|
{
|
||||||
assert(Mode==UserMode);
|
return((PVOID)AddressSpace->LowestAddress);
|
||||||
return((PVOID)MM_LOWEST_USER_ADDRESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
||||||
|
@ -412,44 +266,25 @@ NTSTATUS MmInitMemoryAreas(VOID)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DPRINT("MmInitMemoryAreas()\n",0);
|
DPRINT("MmInitMemoryAreas()\n",0);
|
||||||
InitializeListHead(&SystemAreaList);
|
|
||||||
KeInitializeSpinLock(&SystemAreaListLock);
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
|
NTSTATUS MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
BOOLEAN FreePages)
|
BOOLEAN FreePages)
|
||||||
{
|
{
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
KIRQL oldlvl;
|
|
||||||
LARGE_INTEGER PhysicalAddr;
|
LARGE_INTEGER PhysicalAddr;
|
||||||
|
|
||||||
DPRINT("MmFreeMemoryArea(Process %x, BaseAddress %x, Length %x,"
|
DPRINT("MmFreeMemoryArea(AddressSpace %x, BaseAddress %x, Length %x,"
|
||||||
"FreePages %d)\n",Process,BaseAddress,Length,FreePages);
|
"FreePages %d)\n",AddressSpace,BaseAddress,Length,FreePages);
|
||||||
|
|
||||||
if (SystemAreaList.Flink != (&SystemAreaList) &&
|
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||||
SystemAreaList.Flink->Flink != (&SystemAreaList))
|
BaseAddress);
|
||||||
|
if (MemoryArea == NULL)
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
|
||||||
PMEMORY_AREA Snd = CONTAINING_RECORD(SystemAreaList.Flink->Flink,
|
|
||||||
MEMORY_AREA,
|
|
||||||
Entry);
|
|
||||||
DPRINT("SystemAreaList.Flink->Flink->BaseAddress %x\n",
|
|
||||||
Snd->BaseAddress);
|
|
||||||
#endif
|
|
||||||
// assert(Snd->BaseAddress == (PVOID)0x0c001c000);
|
|
||||||
}
|
|
||||||
|
|
||||||
MmLockMemoryAreaList(BaseAddress, &oldlvl);
|
|
||||||
|
|
||||||
MemoryArea = MmOpenMemoryAreaByAddressWithoutLock(Process,
|
|
||||||
BaseAddress);
|
|
||||||
if (MemoryArea==NULL)
|
|
||||||
{
|
|
||||||
MmUnlockMemoryAreaList(BaseAddress, &oldlvl);
|
|
||||||
KeBugCheck(0);
|
KeBugCheck(0);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
@ -472,67 +307,42 @@ NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
|
||||||
|
|
||||||
RemoveEntryList(&(MemoryArea->Entry));
|
RemoveEntryList(&(MemoryArea->Entry));
|
||||||
ExFreePool(MemoryArea);
|
ExFreePool(MemoryArea);
|
||||||
MmUnlockMemoryAreaList(BaseAddress, &oldlvl);
|
|
||||||
|
|
||||||
if (SystemAreaList.Flink != (&SystemAreaList) &&
|
|
||||||
SystemAreaList.Flink->Flink != (&SystemAreaList))
|
|
||||||
{
|
|
||||||
#ifndef NDEBUG
|
|
||||||
PMEMORY_AREA Snd = CONTAINING_RECORD(SystemAreaList.Flink->Flink,
|
|
||||||
MEMORY_AREA,
|
|
||||||
Entry);
|
|
||||||
DPRINT("SystemAreaList.Flink->Flink->BaseAddress %x\n",
|
|
||||||
Snd->BaseAddress);
|
|
||||||
#endif
|
|
||||||
// assert(Snd->BaseAddress == (PVOID)0x0c001c000);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
|
PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
|
||||||
|
PMADDRESS_SPACE AddressSpace,
|
||||||
PMEMORY_AREA OriginalMemoryArea,
|
PMEMORY_AREA OriginalMemoryArea,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
ULONG NewType,
|
ULONG NewType,
|
||||||
ULONG NewAttributes)
|
ULONG NewAttributes)
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
|
||||||
PMEMORY_AREA Result;
|
PMEMORY_AREA Result;
|
||||||
PMEMORY_AREA Split;
|
PMEMORY_AREA Split;
|
||||||
|
|
||||||
Result = ExAllocatePool(NonPagedPool,sizeof(MEMORY_AREA));
|
Result = ExAllocatePool(NonPagedPool,sizeof(MEMORY_AREA));
|
||||||
RtlZeroMemory(Result,sizeof(MEMORY_AREA));
|
RtlZeroMemory(Result,sizeof(MEMORY_AREA));
|
||||||
Result->Type=NewType;
|
Result->Type = NewType;
|
||||||
Result->BaseAddress=BaseAddress;
|
Result->BaseAddress = BaseAddress;
|
||||||
Result->Length=Length;
|
Result->Length = Length;
|
||||||
Result->Attributes=NewAttributes;
|
Result->Attributes = NewAttributes;
|
||||||
Result->LockCount=0;
|
Result->LockCount = 0;
|
||||||
Result->Process = Process;
|
Result->Process = Process;
|
||||||
|
|
||||||
MmLockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
|
|
||||||
|
|
||||||
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
|
|
||||||
|
|
||||||
if (BaseAddress == OriginalMemoryArea->BaseAddress)
|
if (BaseAddress == OriginalMemoryArea->BaseAddress)
|
||||||
{
|
{
|
||||||
OriginalMemoryArea->BaseAddress = BaseAddress + Length;
|
OriginalMemoryArea->BaseAddress = BaseAddress + Length;
|
||||||
OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length;
|
OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length;
|
||||||
MmInsertMemoryAreaWithoutLock(Process,Result);
|
MmInsertMemoryArea(AddressSpace, Result);
|
||||||
MmUnlockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
|
|
||||||
|
|
||||||
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
|
|
||||||
|
|
||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
if ((BaseAddress + Length) ==
|
if ((BaseAddress + Length) ==
|
||||||
(OriginalMemoryArea->BaseAddress + OriginalMemoryArea->Length))
|
(OriginalMemoryArea->BaseAddress + OriginalMemoryArea->Length))
|
||||||
{
|
{
|
||||||
OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length;
|
OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length;
|
||||||
MmInsertMemoryAreaWithoutLock(Process,Result);
|
MmInsertMemoryArea(AddressSpace, Result);
|
||||||
MmUnlockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
|
|
||||||
|
|
||||||
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
|
|
||||||
|
|
||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
@ -545,57 +355,40 @@ PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
|
||||||
|
|
||||||
OriginalMemoryArea->Length = BaseAddress - OriginalMemoryArea->BaseAddress;
|
OriginalMemoryArea->Length = BaseAddress - OriginalMemoryArea->BaseAddress;
|
||||||
|
|
||||||
MmUnlockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
|
|
||||||
|
|
||||||
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
|
|
||||||
|
|
||||||
return(Split);
|
return(Split);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
|
NTSTATUS MmCreateMemoryArea(PEPROCESS Process,
|
||||||
PEPROCESS Process,
|
PMADDRESS_SPACE AddressSpace,
|
||||||
ULONG Type,
|
ULONG Type,
|
||||||
PVOID* BaseAddress,
|
PVOID* BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
ULONG Attributes,
|
ULONG Attributes,
|
||||||
MEMORY_AREA** Result)
|
MEMORY_AREA** Result)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Create a memory area
|
||||||
|
* ARGUMENTS:
|
||||||
|
* AddressSpace = Address space to create the area in
|
||||||
|
* Type = Type of the address space
|
||||||
|
* BaseAddress =
|
||||||
|
* Length = Length to allocate
|
||||||
|
* Attributes = Protection attributes for the memory area
|
||||||
|
* Result = Receives a pointer to the memory area on exit
|
||||||
|
* RETURNS: Status
|
||||||
|
* NOTES: Lock the address space before calling this function
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
DPRINT("MmCreateMemoryArea(Type %d, BaseAddress %x,"
|
||||||
|
|
||||||
DPRINT("MmCreateMemoryArea(Mode %x, Type %d, BaseAddress %x,"
|
|
||||||
"*BaseAddress %x, Length %x, Attributes %x, Result %x)\n",
|
"*BaseAddress %x, Length %x, Attributes %x, Result %x)\n",
|
||||||
Mode,Type,BaseAddress,*BaseAddress,Length,Attributes,Result);
|
Type,BaseAddress,*BaseAddress,Length,Attributes,Result);
|
||||||
|
|
||||||
if (SystemAreaList.Flink != (&SystemAreaList) &&
|
|
||||||
SystemAreaList.Flink->Flink != (&SystemAreaList))
|
|
||||||
{
|
|
||||||
#ifndef NDEBUG
|
|
||||||
PMEMORY_AREA Snd = CONTAINING_RECORD(SystemAreaList.Flink->Flink,
|
|
||||||
MEMORY_AREA,
|
|
||||||
Entry);
|
|
||||||
DPRINT("SystemAreaList.Flink->Flink->BaseAddress %x\n",
|
|
||||||
Snd->BaseAddress);
|
|
||||||
// assert(Snd->BaseAddress == (PVOID)0x0c001c000);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((*BaseAddress)==0)
|
if ((*BaseAddress)==0)
|
||||||
{
|
{
|
||||||
MmLockMemoryAreaListByMode(Mode,&oldlvl);
|
*BaseAddress = MmFindGap(AddressSpace,
|
||||||
}
|
PAGE_ROUND_UP(Length) +(PAGESIZE*2));
|
||||||
else
|
|
||||||
{
|
|
||||||
MmLockMemoryAreaList(*BaseAddress,&oldlvl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((*BaseAddress)==0)
|
|
||||||
{
|
|
||||||
*BaseAddress = MmFindGapWithoutLock(Process,Mode,PAGE_ROUND_UP(Length)
|
|
||||||
+(PAGESIZE*2));
|
|
||||||
if ((*BaseAddress)==0)
|
if ((*BaseAddress)==0)
|
||||||
{
|
{
|
||||||
DPRINT("No suitable gap\n");
|
DPRINT("No suitable gap\n");
|
||||||
MmUnlockMemoryAreaListByMode(Mode,&oldlvl);
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
(*BaseAddress)=(*BaseAddress)+PAGESIZE;
|
(*BaseAddress)=(*BaseAddress)+PAGESIZE;
|
||||||
|
@ -603,40 +396,24 @@ NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(*BaseAddress) = (PVOID)PAGE_ROUND_DOWN((*BaseAddress));
|
(*BaseAddress) = (PVOID)PAGE_ROUND_DOWN((*BaseAddress));
|
||||||
if (MmOpenMemoryAreaByRegionWithoutLock(Process,
|
if (MmOpenMemoryAreaByRegion(AddressSpace,
|
||||||
*BaseAddress,
|
*BaseAddress,
|
||||||
Length)!=NULL)
|
Length)!=NULL)
|
||||||
{
|
{
|
||||||
DPRINT("Memory area already occupied\n");
|
DPRINT("Memory area already occupied\n");
|
||||||
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*Result = ExAllocatePool(NonPagedPool,sizeof(MEMORY_AREA));
|
*Result = ExAllocatePool(NonPagedPool,sizeof(MEMORY_AREA));
|
||||||
RtlZeroMemory(*Result,sizeof(MEMORY_AREA));
|
RtlZeroMemory(*Result,sizeof(MEMORY_AREA));
|
||||||
(*Result)->Type=Type;
|
(*Result)->Type = Type;
|
||||||
(*Result)->BaseAddress=*BaseAddress;
|
(*Result)->BaseAddress = *BaseAddress;
|
||||||
(*Result)->Length=Length;
|
(*Result)->Length = Length;
|
||||||
(*Result)->Attributes=Attributes;
|
(*Result)->Attributes = Attributes;
|
||||||
(*Result)->LockCount=0;
|
(*Result)->LockCount = 0;
|
||||||
(*Result)->Process = Process;
|
(*Result)->Process = Process;
|
||||||
|
|
||||||
MmInsertMemoryAreaWithoutLock(Process,*Result);
|
MmInsertMemoryArea(AddressSpace, *Result);
|
||||||
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
|
|
||||||
|
|
||||||
if (SystemAreaList.Flink != (&SystemAreaList) &&
|
|
||||||
SystemAreaList.Flink->Flink != (&SystemAreaList))
|
|
||||||
{
|
|
||||||
#ifndef NDEBUG
|
|
||||||
PMEMORY_AREA Snd = CONTAINING_RECORD(SystemAreaList.Flink->Flink,
|
|
||||||
MEMORY_AREA,
|
|
||||||
Entry);
|
|
||||||
DPRINT("SystemAreaList.Flink->Flink->BaseAddress %x\n",
|
|
||||||
Snd->BaseAddress);
|
|
||||||
#endif
|
|
||||||
// assert(Snd->BaseAddress == (PVOID)0x0c001c000);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,8 @@ PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
|
||||||
DPRINT("PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE) %x\n",
|
DPRINT("PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE) %x\n",
|
||||||
PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE);
|
PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE);
|
||||||
|
|
||||||
MmCreateMemoryArea(KernelMode,
|
MmCreateMemoryArea(NULL,
|
||||||
NULL,
|
MmGetKernelAddressSpace(),
|
||||||
MEMORY_AREA_MDL_MAPPING,
|
MEMORY_AREA_MDL_MAPPING,
|
||||||
&base,
|
&base,
|
||||||
Mdl->ByteCount + Mdl->ByteOffset,
|
Mdl->ByteCount + Mdl->ByteOffset,
|
||||||
|
@ -96,7 +96,7 @@ VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DPRINT("MmUnmapLockedPages(BaseAddress %x, Mdl %x)\n", Mdl, BaseAddress);
|
DPRINT("MmUnmapLockedPages(BaseAddress %x, Mdl %x)\n", Mdl, BaseAddress);
|
||||||
(void)MmFreeMemoryArea(NULL,
|
(void)MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
||||||
BaseAddress-Mdl->ByteOffset,
|
BaseAddress-Mdl->ByteOffset,
|
||||||
Mdl->ByteCount,
|
Mdl->ByteCount,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
@ -145,11 +145,21 @@ VOID MmProbeAndLockPages(PMDL Mdl,
|
||||||
int i;
|
int i;
|
||||||
MEMORY_AREA* marea;
|
MEMORY_AREA* marea;
|
||||||
PVOID Address;
|
PVOID Address;
|
||||||
|
PMADDRESS_SPACE AddressSpace;
|
||||||
|
|
||||||
DPRINT("MmProbeAndLockPages(Mdl %x)\n",Mdl);
|
DPRINT("MmProbeAndLockPages(Mdl %x)\n",Mdl);
|
||||||
DPRINT("StartVa %x\n",Mdl->StartVa);
|
DPRINT("StartVa %x\n",Mdl->StartVa);
|
||||||
|
|
||||||
marea = MmOpenMemoryAreaByAddress(Mdl->Process,
|
if (Mdl->StartVa > (PVOID)KERNEL_BASE)
|
||||||
|
{
|
||||||
|
AddressSpace = MmGetKernelAddressSpace();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddressSpace = &Mdl->Process->Pcb.AddressSpace;
|
||||||
|
}
|
||||||
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
marea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||||
Mdl->StartVa);
|
Mdl->StartVa);
|
||||||
DPRINT("marea %x\n",marea);
|
DPRINT("marea %x\n",marea);
|
||||||
|
|
||||||
|
@ -161,6 +171,7 @@ VOID MmProbeAndLockPages(PMDL Mdl,
|
||||||
if (marea==NULL )
|
if (marea==NULL )
|
||||||
{
|
{
|
||||||
DbgPrint("(%s:%d) Area is invalid\n",__FILE__,__LINE__);
|
DbgPrint("(%s:%d) Area is invalid\n",__FILE__,__LINE__);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ExRaiseStatus(STATUS_INVALID_PARAMETER);
|
ExRaiseStatus(STATUS_INVALID_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +192,7 @@ VOID MmProbeAndLockPages(PMDL Mdl,
|
||||||
mdl_pages[i] = (MmGetPhysicalAddress(Address)).u.LowPart;
|
mdl_pages[i] = (MmGetPhysicalAddress(Address)).u.LowPart;
|
||||||
DPRINT("mdl_pages[i] %x\n",mdl_pages[i]);
|
DPRINT("mdl_pages[i] %x\n",mdl_pages[i]);
|
||||||
}
|
}
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG MmGetMdlByteCount(PMDL Mdl)
|
ULONG MmGetMdlByteCount(PMDL Mdl)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: mm.c,v 1.25 2000/03/26 19:38:30 ea Exp $
|
/* $Id: mm.c,v 1.26 2000/03/29 13:11:54 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top directory
|
* COPYRIGHT: See COPYING in the top directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -53,11 +53,6 @@ static MEMORY_AREA* kernel_data_desc = NULL;
|
||||||
static MEMORY_AREA* kernel_param_desc = NULL;
|
static MEMORY_AREA* kernel_param_desc = NULL;
|
||||||
static MEMORY_AREA* kernel_pool_desc = NULL;
|
static MEMORY_AREA* kernel_pool_desc = NULL;
|
||||||
|
|
||||||
/*
|
|
||||||
* All pagefaults are synchronized on this
|
|
||||||
*/
|
|
||||||
static KSPIN_LOCK MiPageFaultLock;
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
VOID MiShutdownMemoryManager(VOID)
|
VOID MiShutdownMemoryManager(VOID)
|
||||||
|
@ -80,7 +75,7 @@ VOID MmInitVirtualMemory(boot_param* bp)
|
||||||
DPRINT("MmInitVirtualMemory(%x)\n",bp);
|
DPRINT("MmInitVirtualMemory(%x)\n",bp);
|
||||||
|
|
||||||
MmInitMemoryAreas();
|
MmInitMemoryAreas();
|
||||||
ExInitNonPagedPool(KERNEL_BASE+ PAGE_ROUND_UP(kernel_len) + PAGESIZE);
|
ExInitNonPagedPool(KERNEL_BASE + PAGE_ROUND_UP(kernel_len) + PAGESIZE);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -89,8 +84,13 @@ VOID MmInitVirtualMemory(boot_param* bp)
|
||||||
BaseAddress = (PVOID)KERNEL_BASE;
|
BaseAddress = (PVOID)KERNEL_BASE;
|
||||||
Length = PAGE_ROUND_UP(((ULONG)&etext)) - KERNEL_BASE;
|
Length = PAGE_ROUND_UP(((ULONG)&etext)) - KERNEL_BASE;
|
||||||
ParamLength = ParamLength - Length;
|
ParamLength = ParamLength - Length;
|
||||||
MmCreateMemoryArea(KernelMode,NULL,MEMORY_AREA_SYSTEM,&BaseAddress,
|
MmCreateMemoryArea(NULL,
|
||||||
Length,0,&kernel_text_desc);
|
MmGetKernelAddressSpace(),
|
||||||
|
MEMORY_AREA_SYSTEM,
|
||||||
|
&BaseAddress,
|
||||||
|
Length,
|
||||||
|
0,
|
||||||
|
&kernel_text_desc);
|
||||||
|
|
||||||
Length = PAGE_ROUND_UP(((ULONG)&_bss_end__)) -
|
Length = PAGE_ROUND_UP(((ULONG)&_bss_end__)) -
|
||||||
PAGE_ROUND_UP(((ULONG)&etext));
|
PAGE_ROUND_UP(((ULONG)&etext));
|
||||||
|
@ -98,8 +98,8 @@ VOID MmInitVirtualMemory(boot_param* bp)
|
||||||
DPRINT("Length %x\n",Length);
|
DPRINT("Length %x\n",Length);
|
||||||
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&etext));
|
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&etext));
|
||||||
DPRINT("BaseAddress %x\n",BaseAddress);
|
DPRINT("BaseAddress %x\n",BaseAddress);
|
||||||
MmCreateMemoryArea(KernelMode,
|
MmCreateMemoryArea(NULL,
|
||||||
NULL,
|
MmGetKernelAddressSpace(),
|
||||||
MEMORY_AREA_SYSTEM,
|
MEMORY_AREA_SYSTEM,
|
||||||
&BaseAddress,
|
&BaseAddress,
|
||||||
Length,
|
Length,
|
||||||
|
@ -108,27 +108,34 @@ VOID MmInitVirtualMemory(boot_param* bp)
|
||||||
|
|
||||||
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&end));
|
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&end));
|
||||||
Length = ParamLength;
|
Length = ParamLength;
|
||||||
MmCreateMemoryArea(KernelMode,NULL,MEMORY_AREA_SYSTEM,&BaseAddress,
|
MmCreateMemoryArea(NULL,
|
||||||
Length,0,&kernel_param_desc);
|
MmGetKernelAddressSpace(),
|
||||||
|
MEMORY_AREA_SYSTEM,
|
||||||
|
&BaseAddress,
|
||||||
|
Length,
|
||||||
|
0,
|
||||||
|
&kernel_param_desc);
|
||||||
|
|
||||||
BaseAddress = (PVOID)(KERNEL_BASE + PAGE_ROUND_UP(kernel_len) + PAGESIZE);
|
BaseAddress = (PVOID)(KERNEL_BASE + PAGE_ROUND_UP(kernel_len) + PAGESIZE);
|
||||||
Length = NONPAGED_POOL_SIZE;
|
Length = NONPAGED_POOL_SIZE;
|
||||||
MmCreateMemoryArea(KernelMode,NULL,MEMORY_AREA_SYSTEM,&BaseAddress,
|
MmCreateMemoryArea(NULL,
|
||||||
Length,0,&kernel_pool_desc);
|
MmGetKernelAddressSpace(),
|
||||||
|
MEMORY_AREA_SYSTEM,
|
||||||
|
&BaseAddress,
|
||||||
|
Length,
|
||||||
|
0,
|
||||||
|
&kernel_pool_desc);
|
||||||
|
|
||||||
// MmDumpMemoryAreas();
|
// MmDumpMemoryAreas();
|
||||||
DPRINT("MmInitVirtualMemory() done\n");
|
DPRINT("MmInitVirtualMemory() done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS MmCommitedSectionHandleFault(MEMORY_AREA* MemoryArea, PVOID Address)
|
NTSTATUS MmCommitedSectionHandleFault(PMADDRESS_SPACE AddressSpace,
|
||||||
|
MEMORY_AREA* MemoryArea,
|
||||||
|
PVOID Address)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
|
||||||
|
|
||||||
KeAcquireSpinLock(&MiPageFaultLock, &oldIrql);
|
|
||||||
|
|
||||||
if (MmIsPagePresent(NULL, Address))
|
if (MmIsPagePresent(NULL, Address))
|
||||||
{
|
{
|
||||||
KeReleaseSpinLock(&MiPageFaultLock, oldIrql);
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,12 +144,11 @@ NTSTATUS MmCommitedSectionHandleFault(MEMORY_AREA* MemoryArea, PVOID Address)
|
||||||
MemoryArea->Attributes,
|
MemoryArea->Attributes,
|
||||||
(ULONG)MmAllocPage());
|
(ULONG)MmAllocPage());
|
||||||
|
|
||||||
KeReleaseSpinLock(&MiPageFaultLock, oldIrql);
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS MmSectionHandleFault(MEMORY_AREA* MemoryArea,
|
NTSTATUS MmSectionHandleFault(PMADDRESS_SPACE AddressSpace,
|
||||||
|
MEMORY_AREA* MemoryArea,
|
||||||
PVOID Address)
|
PVOID Address)
|
||||||
{
|
{
|
||||||
LARGE_INTEGER Offset;
|
LARGE_INTEGER Offset;
|
||||||
|
@ -150,16 +156,12 @@ NTSTATUS MmSectionHandleFault(MEMORY_AREA* MemoryArea,
|
||||||
PMDL Mdl;
|
PMDL Mdl;
|
||||||
PVOID Page;
|
PVOID Page;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
KIRQL oldIrql;
|
|
||||||
|
|
||||||
DPRINT("MmSectionHandleFault(MemoryArea %x, Address %x)\n",
|
DPRINT("MmSectionHandleFault(MemoryArea %x, Address %x)\n",
|
||||||
MemoryArea,Address);
|
MemoryArea,Address);
|
||||||
|
|
||||||
KeAcquireSpinLock(&MiPageFaultLock, &oldIrql);
|
|
||||||
|
|
||||||
if (MmIsPagePresent(NULL, Address))
|
if (MmIsPagePresent(NULL, Address))
|
||||||
{
|
{
|
||||||
KeReleaseSpinLock(&MiPageFaultLock, oldIrql);
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,25 +200,22 @@ NTSTATUS MmSectionHandleFault(MEMORY_AREA* MemoryArea,
|
||||||
|
|
||||||
Page = MmGetMdlPageAddress(Mdl, 0);
|
Page = MmGetMdlPageAddress(Mdl, 0);
|
||||||
|
|
||||||
KeReleaseSpinLock(&MiPageFaultLock, oldIrql);
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
|
|
||||||
Status = IoPageRead(MemoryArea->Data.SectionData.Section->FileObject,
|
Status = IoPageRead(MemoryArea->Data.SectionData.Section->FileObject,
|
||||||
Mdl,
|
Mdl,
|
||||||
&Offset,
|
&Offset,
|
||||||
&IoStatus,
|
&IoStatus);
|
||||||
0 /* FIXME: UNKNOWN ARG */
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeAcquireSpinLock(&MiPageFaultLock, &oldIrql);
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
|
||||||
if (MmIsPagePresent(NULL, Address))
|
if (MmIsPagePresent(NULL, Address))
|
||||||
{
|
{
|
||||||
KeReleaseSpinLock(&MiPageFaultLock, oldIrql);
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,8 +224,6 @@ NTSTATUS MmSectionHandleFault(MEMORY_AREA* MemoryArea,
|
||||||
MemoryArea->Attributes,
|
MemoryArea->Attributes,
|
||||||
(ULONG)Page);
|
(ULONG)Page);
|
||||||
|
|
||||||
KeReleaseSpinLock(&MiPageFaultLock, oldIrql);
|
|
||||||
|
|
||||||
DPRINT("Returning from MmSectionHandleFault()\n");
|
DPRINT("Returning from MmSectionHandleFault()\n");
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
|
@ -237,7 +234,7 @@ ULONG MmPageFault(ULONG cs, ULONG eip, ULONG error_code)
|
||||||
* FUNCTION: Handle a page fault
|
* FUNCTION: Handle a page fault
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
KPROCESSOR_MODE FaultMode;
|
PMADDRESS_SPACE AddressSpace;
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
unsigned int cr2;
|
unsigned int cr2;
|
||||||
|
@ -251,9 +248,9 @@ ULONG MmPageFault(ULONG cs, ULONG eip, ULONG error_code)
|
||||||
// DPRINT1("Page fault address %x eip %x process %x code %x cr3 %x\n",cr2,eip,
|
// DPRINT1("Page fault address %x eip %x process %x code %x cr3 %x\n",cr2,eip,
|
||||||
// PsGetCurrentProcess(), error_code, cr3);
|
// PsGetCurrentProcess(), error_code, cr3);
|
||||||
|
|
||||||
MmSetPageProtect(PsGetCurrentProcess(),
|
// MmSetPageProtect(PsGetCurrentProcess(),
|
||||||
(PVOID)PAGE_ROUND_DOWN(PsGetCurrentProcess()),
|
// (PVOID)PAGE_ROUND_DOWN(PsGetCurrentProcess()),
|
||||||
0x7);
|
// 0x7);
|
||||||
|
|
||||||
cr2 = PAGE_ROUND_DOWN(cr2);
|
cr2 = PAGE_ROUND_DOWN(cr2);
|
||||||
|
|
||||||
|
@ -290,17 +287,20 @@ ULONG MmPageFault(ULONG cs, ULONG eip, ULONG error_code)
|
||||||
DbgPrint("%s:%d\n",__FILE__,__LINE__);
|
DbgPrint("%s:%d\n",__FILE__,__LINE__);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
FaultMode = UserMode;
|
AddressSpace = &PsGetCurrentProcess()->Pcb.AddressSpace;
|
||||||
|
AddressSpace = MmGetKernelAddressSpace();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FaultMode = KernelMode;
|
AddressSpace = &PsGetCurrentProcess()->Pcb.AddressSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryArea = MmOpenMemoryAreaByAddress(PsGetCurrentProcess(),(PVOID)cr2);
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace, (PVOID)cr2);
|
||||||
if (MemoryArea == NULL)
|
if (MemoryArea == NULL)
|
||||||
{
|
{
|
||||||
DbgPrint("%s:%d\n",__FILE__,__LINE__);
|
DbgPrint("%s:%d\n",__FILE__,__LINE__);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,11 +311,15 @@ ULONG MmPageFault(ULONG cs, ULONG eip, ULONG error_code)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MEMORY_AREA_SECTION_VIEW_COMMIT:
|
case MEMORY_AREA_SECTION_VIEW_COMMIT:
|
||||||
Status = MmSectionHandleFault(MemoryArea, (PVOID)cr2);
|
Status = MmSectionHandleFault(AddressSpace,
|
||||||
|
MemoryArea,
|
||||||
|
(PVOID)cr2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MEMORY_AREA_COMMIT:
|
case MEMORY_AREA_COMMIT:
|
||||||
Status = MmCommitedSectionHandleFault(MemoryArea,(PVOID)cr2);
|
Status = MmCommitedSectionHandleFault(AddressSpace,
|
||||||
|
MemoryArea,
|
||||||
|
(PVOID)cr2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -323,6 +327,7 @@ ULONG MmPageFault(ULONG cs, ULONG eip, ULONG error_code)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DPRINT("Completed page fault handling\n");
|
DPRINT("Completed page fault handling\n");
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
return(NT_SUCCESS(Status));
|
return(NT_SUCCESS(Status));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,10 +373,10 @@ void MmInitialize(boot_param* bp, ULONG LastKernelAddress)
|
||||||
* Free physical memory not used by the kernel
|
* Free physical memory not used by the kernel
|
||||||
*/
|
*/
|
||||||
LastKernelAddress = (ULONG)MmInitializePageList(
|
LastKernelAddress = (ULONG)MmInitializePageList(
|
||||||
(PVOID)first_krnl_phys_addr,
|
(PVOID)first_krnl_phys_addr,
|
||||||
(PVOID)last_krnl_phys_addr,
|
(PVOID)last_krnl_phys_addr,
|
||||||
1024,
|
1024,
|
||||||
PAGE_ROUND_UP(LastKernelAddress));
|
PAGE_ROUND_UP(LastKernelAddress));
|
||||||
kernel_len = last_krnl_phys_addr - first_krnl_phys_addr;
|
kernel_len = last_krnl_phys_addr - first_krnl_phys_addr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -405,20 +410,20 @@ void MmInitialize(boot_param* bp, ULONG LastKernelAddress)
|
||||||
MmInitVirtualMemory(bp);
|
MmInitVirtualMemory(bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID MmInitSystem (ULONG Phase, boot_param* bp, ULONG LastKernelAddress)
|
||||||
MmInitSystem (ULONG Phase, boot_param* bp, ULONG LastKernelAddress)
|
|
||||||
{
|
{
|
||||||
if (Phase == 0)
|
if (Phase == 0)
|
||||||
{
|
{
|
||||||
/* Phase 0 Initialization */
|
/* Phase 0 Initialization */
|
||||||
MmInitialize (bp, LastKernelAddress);
|
MmInitializeKernelAddressSpace();
|
||||||
}
|
MmInitialize (bp, LastKernelAddress);
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
/* Phase 1 Initialization */
|
{
|
||||||
MmInitSectionImplementation();
|
/* Phase 1 Initialization */
|
||||||
MmInitPagingFile();
|
MmInitSectionImplementation();
|
||||||
}
|
MmInitPagingFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: ncache.c,v 1.3 2000/03/19 09:14:51 ea Exp $
|
/* $Id: ncache.c,v 1.4 2000/03/29 13:11:54 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -43,44 +43,33 @@
|
||||||
* REVISIONS
|
* REVISIONS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
PVOID
|
PVOID STDCALL MmAllocateNonCachedMemory(IN ULONG NumberOfBytes)
|
||||||
STDCALL
|
|
||||||
MmAllocateNonCachedMemory (
|
|
||||||
IN ULONG NumberOfBytes
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
PVOID Result;
|
PVOID Result;
|
||||||
MEMORY_AREA * marea;
|
MEMORY_AREA* marea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
Result = NULL;
|
Result = NULL;
|
||||||
Status = MmCreateMemoryArea (
|
Status = MmCreateMemoryArea (NULL,
|
||||||
KernelMode,
|
MmGetKernelAddressSpace(),
|
||||||
PsGetCurrentProcess (),
|
MEMORY_AREA_NO_CACHE,
|
||||||
MEMORY_AREA_NO_CACHE,
|
&Result,
|
||||||
& Result,
|
NumberOfBytes,
|
||||||
NumberOfBytes,
|
0,
|
||||||
0,
|
&marea);
|
||||||
& marea
|
if (!NT_SUCCESS(Status))
|
||||||
);
|
{
|
||||||
if (STATUS_SUCCESS != Status)
|
return (NULL);
|
||||||
{
|
}
|
||||||
return (NULL);
|
for (i = 0; (i <= (NumberOfBytes / PAGESIZE)); i++)
|
||||||
|
{
|
||||||
|
MmSetPage (NULL,
|
||||||
|
(Result + (i * PAGESIZE)),
|
||||||
|
PAGE_READWRITE,
|
||||||
|
(ULONG)MmAllocPage());
|
||||||
}
|
}
|
||||||
for ( i = 0;
|
return ((PVOID)Result);
|
||||||
(i <= (NumberOfBytes / PAGESIZE));
|
|
||||||
i ++
|
|
||||||
)
|
|
||||||
{
|
|
||||||
MmSetPage (
|
|
||||||
NULL,
|
|
||||||
(Result + (i * PAGESIZE)),
|
|
||||||
PAGE_READWRITE,
|
|
||||||
(ULONG) MmAllocPage ()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return ((PVOID) Result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,19 +99,13 @@ MmAllocateNonCachedMemory (
|
||||||
* REVISIONS
|
* REVISIONS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
VOID
|
VOID STDCALL MmFreeNonCachedMemory (IN PVOID BaseAddress,
|
||||||
STDCALL
|
IN ULONG NumberOfBytes)
|
||||||
MmFreeNonCachedMemory (
|
|
||||||
IN PVOID BaseAddress,
|
|
||||||
IN ULONG NumberOfBytes
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
MmFreeMemoryArea (
|
MmFreeMemoryArea (&PsGetCurrentProcess()->Pcb.AddressSpace,
|
||||||
PsGetCurrentProcess (),
|
BaseAddress,
|
||||||
BaseAddress,
|
NumberOfBytes,
|
||||||
NumberOfBytes,
|
TRUE);
|
||||||
TRUE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: section.c,v 1.25 2000/03/26 19:38:32 ea Exp $
|
/* $Id: section.c,v 1.26 2000/03/29 13:11:54 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -342,6 +342,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
ULONG ViewOffset;
|
ULONG ViewOffset;
|
||||||
|
PMADDRESS_SPACE AddressSpace;
|
||||||
|
|
||||||
DPRINT("NtMapViewOfSection(Section:%08lx, Process:%08lx,\n"
|
DPRINT("NtMapViewOfSection(Section:%08lx, Process:%08lx,\n"
|
||||||
" Base:%08lx, ZeroBits:%08lx, CommitSize:%08lx,\n"
|
" Base:%08lx, ZeroBits:%08lx, CommitSize:%08lx,\n"
|
||||||
|
@ -381,6 +382,8 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AddressSpace = &Process->Pcb.AddressSpace;
|
||||||
|
|
||||||
DPRINT("Process %x\n", Process);
|
DPRINT("Process %x\n", Process);
|
||||||
DPRINT("ViewSize %x\n",ViewSize);
|
DPRINT("ViewSize %x\n",ViewSize);
|
||||||
|
|
||||||
|
@ -399,8 +402,9 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("Creating memory area\n");
|
DPRINT("Creating memory area\n");
|
||||||
Status = MmCreateMemoryArea(UserMode,
|
MmLockAddressSpace(AddressSpace);
|
||||||
Process,
|
Status = MmCreateMemoryArea(Process,
|
||||||
|
&Process->Pcb.AddressSpace,
|
||||||
MEMORY_AREA_SECTION_VIEW_COMMIT,
|
MEMORY_AREA_SECTION_VIEW_COMMIT,
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
*ViewSize,
|
*ViewSize,
|
||||||
|
@ -410,6 +414,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtMapViewOfSection() = %x\n",Status);
|
DPRINT("NtMapViewOfSection() = %x\n",Status);
|
||||||
|
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
ObDereferenceObject(Section);
|
ObDereferenceObject(Section);
|
||||||
|
|
||||||
|
@ -428,6 +433,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
||||||
|
|
||||||
|
|
||||||
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
|
|
||||||
DPRINT("NtMapViewOfSection() returning (Status %x)\n", STATUS_SUCCESS);
|
DPRINT("NtMapViewOfSection() returning (Status %x)\n", STATUS_SUCCESS);
|
||||||
|
@ -472,6 +478,7 @@ NTSTATUS STDCALL NtUnmapViewOfSection (HANDLE ProcessHandle,
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PMEMORY_AREA MemoryArea;
|
PMEMORY_AREA MemoryArea;
|
||||||
|
PMADDRESS_SPACE AddressSpace;
|
||||||
|
|
||||||
DPRINT("NtUnmapViewOfSection(ProcessHandle %x, BaseAddress %x)\n",
|
DPRINT("NtUnmapViewOfSection(ProcessHandle %x, BaseAddress %x)\n",
|
||||||
ProcessHandle, BaseAddress);
|
ProcessHandle, BaseAddress);
|
||||||
|
@ -489,22 +496,28 @@ NTSTATUS STDCALL NtUnmapViewOfSection (HANDLE ProcessHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AddressSpace = &Process->Pcb.AddressSpace;
|
||||||
|
|
||||||
DPRINT("Opening memory area Process %x BaseAddress %x\n",
|
DPRINT("Opening memory area Process %x BaseAddress %x\n",
|
||||||
Process, BaseAddress);
|
Process, BaseAddress);
|
||||||
MemoryArea = MmOpenMemoryAreaByAddress(Process, BaseAddress);
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||||
|
BaseAddress);
|
||||||
if (MemoryArea == NULL)
|
if (MemoryArea == NULL)
|
||||||
{
|
{
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = MmUnmapViewOfSection(Process, MemoryArea);
|
Status = MmUnmapViewOfSection(Process,
|
||||||
|
MemoryArea);
|
||||||
|
|
||||||
Status = MmFreeMemoryArea(Process,
|
Status = MmFreeMemoryArea(&Process->Pcb.AddressSpace,
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
0,
|
0,
|
||||||
TRUE);
|
TRUE);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -557,47 +570,40 @@ NTSTATUS STDCALL NtExtendSection(IN HANDLE SectionHandle,
|
||||||
* REVISIONS
|
* REVISIONS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
PVOID
|
PVOID STDCALL MmAllocateSection (IN ULONG Length)
|
||||||
STDCALL
|
|
||||||
MmAllocateSection (
|
|
||||||
IN ULONG Length
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
PVOID Result;
|
PVOID Result;
|
||||||
MEMORY_AREA * marea;
|
MEMORY_AREA* marea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
PMADDRESS_SPACE AddressSpace;
|
||||||
|
|
||||||
DPRINT("MmAllocateSection(Length %x)\n",Length);
|
DPRINT("MmAllocateSection(Length %x)\n",Length);
|
||||||
|
|
||||||
Result = NULL;
|
AddressSpace = MmGetKernelAddressSpace();
|
||||||
Status = MmCreateMemoryArea (
|
Result = NULL;
|
||||||
KernelMode,
|
MmLockAddressSpace(AddressSpace);
|
||||||
PsGetCurrentProcess (),
|
Status = MmCreateMemoryArea (NULL,
|
||||||
MEMORY_AREA_SYSTEM,
|
AddressSpace,
|
||||||
& Result,
|
MEMORY_AREA_SYSTEM,
|
||||||
Length,
|
&Result,
|
||||||
0,
|
Length,
|
||||||
& marea
|
0,
|
||||||
);
|
&marea);
|
||||||
if (STATUS_SUCCESS != Status)
|
if (STATUS_SUCCESS != Status)
|
||||||
{
|
{
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
DPRINT("Result %p\n",Result);
|
DPRINT("Result %p\n",Result);
|
||||||
for ( i = 0;
|
for (i = 0; (i <= (Length / PAGESIZE)); i++)
|
||||||
(i <= (Length / PAGESIZE));
|
{
|
||||||
i ++
|
MmSetPage (NULL,
|
||||||
)
|
(Result + (i * PAGESIZE)),
|
||||||
{
|
PAGE_READWRITE,
|
||||||
MmSetPage (
|
(ULONG) MmAllocPage ());
|
||||||
NULL,
|
}
|
||||||
(Result + (i * PAGESIZE)),
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
PAGE_READWRITE,
|
return ((PVOID)Result);
|
||||||
(ULONG) MmAllocPage ()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return ((PVOID) Result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,9 +59,12 @@ NTSTATUS MmReleaseMmInfo(PEPROCESS Process)
|
||||||
|
|
||||||
DPRINT("MmReleaseMmInfo(Process %x)\n",Process);
|
DPRINT("MmReleaseMmInfo(Process %x)\n",Process);
|
||||||
|
|
||||||
while (!IsListEmpty(&Process->Pcb.MemoryAreaList))
|
MmLockAddressSpace(&Process->Pcb.AddressSpace);
|
||||||
|
|
||||||
|
while (!IsListEmpty(&Process->Pcb.AddressSpace.MAreaListHead))
|
||||||
{
|
{
|
||||||
CurrentEntry = RemoveHeadList(&Process->Pcb.MemoryAreaList);
|
CurrentEntry = RemoveHeadList(
|
||||||
|
&Process->Pcb.AddressSpace.MAreaListHead);
|
||||||
Current = CONTAINING_RECORD(CurrentEntry, MEMORY_AREA, Entry);
|
Current = CONTAINING_RECORD(CurrentEntry, MEMORY_AREA, Entry);
|
||||||
|
|
||||||
MmReleaseMemoryArea(Process, Current);
|
MmReleaseMemoryArea(Process, Current);
|
||||||
|
@ -69,6 +72,8 @@ NTSTATUS MmReleaseMmInfo(PEPROCESS Process)
|
||||||
|
|
||||||
Mmi386ReleaseMmInfo(Process);
|
Mmi386ReleaseMmInfo(Process);
|
||||||
|
|
||||||
|
MmUnlockAddressSpace(&Process->Pcb.AddressSpace);
|
||||||
|
|
||||||
DPRINT("Finished MmReleaseMmInfo()\n");
|
DPRINT("Finished MmReleaseMmInfo()\n");
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -91,14 +96,20 @@ BOOLEAN MmIsAddressValid(PVOID VirtualAddress)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
|
PMADDRESS_SPACE AddressSpace;
|
||||||
|
|
||||||
MemoryArea = MmOpenMemoryAreaByAddress(PsGetCurrentProcess(),
|
AddressSpace = &PsGetCurrentProcess()->Pcb.AddressSpace;
|
||||||
|
|
||||||
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||||
VirtualAddress);
|
VirtualAddress);
|
||||||
|
|
||||||
if (MemoryArea == NULL)
|
if (MemoryArea == NULL)
|
||||||
{
|
{
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,6 +153,7 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
ULONG Type;
|
ULONG Type;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PMADDRESS_SPACE AddressSpace;
|
||||||
|
|
||||||
DPRINT("NtAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
|
DPRINT("NtAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
|
||||||
"ZeroBits %d, *RegionSize %x, AllocationType %x, Protect %x)\n",
|
"ZeroBits %d, *RegionSize %x, AllocationType %x, Protect %x)\n",
|
||||||
|
@ -169,9 +181,13 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
Type = MEMORY_AREA_COMMIT;
|
Type = MEMORY_AREA_COMMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AddressSpace = &Process->Pcb.AddressSpace;
|
||||||
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
|
||||||
if ((*BaseAddress) != 0)
|
if ((*BaseAddress) != 0)
|
||||||
{
|
{
|
||||||
MemoryArea = MmOpenMemoryAreaByAddress(Process, *BaseAddress);
|
MemoryArea = MmOpenMemoryAreaByAddress(&Process->Pcb.AddressSpace,
|
||||||
|
*BaseAddress);
|
||||||
|
|
||||||
if (MemoryArea != NULL)
|
if (MemoryArea != NULL)
|
||||||
{
|
{
|
||||||
|
@ -181,17 +197,20 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
MemoryArea->Type = Type;
|
MemoryArea->Type = Type;
|
||||||
MemoryArea->Attributes =Protect;
|
MemoryArea->Attributes =Protect;
|
||||||
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryArea = MmSplitMemoryArea(Process,
|
MemoryArea = MmSplitMemoryArea(Process,
|
||||||
|
&Process->Pcb.AddressSpace,
|
||||||
MemoryArea,
|
MemoryArea,
|
||||||
*BaseAddress,
|
*BaseAddress,
|
||||||
*RegionSize,
|
*RegionSize,
|
||||||
Type,
|
Type,
|
||||||
Protect);
|
Protect);
|
||||||
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -200,8 +219,8 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
// FIXME RegionSize should be passed as pointer
|
// FIXME RegionSize should be passed as pointer
|
||||||
// dwelch: Why?
|
// dwelch: Why?
|
||||||
|
|
||||||
Status = MmCreateMemoryArea(UserMode,
|
Status = MmCreateMemoryArea(Process,
|
||||||
Process,
|
&Process->Pcb.AddressSpace,
|
||||||
Type,
|
Type,
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
*RegionSize,
|
*RegionSize,
|
||||||
|
@ -211,11 +230,13 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
if (Status != STATUS_SUCCESS)
|
if (Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT("NtAllocateVirtualMemory() = %x\n",Status);
|
DPRINT("NtAllocateVirtualMemory() = %x\n",Status);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -260,6 +281,7 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
|
PMADDRESS_SPACE AddressSpace;
|
||||||
|
|
||||||
DPRINT("NtFreeVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
|
DPRINT("NtFreeVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
|
||||||
"*RegionSize %x, FreeType %x)\n",ProcessHandle,*BaseAddress,
|
"*RegionSize %x, FreeType %x)\n",ProcessHandle,*BaseAddress,
|
||||||
|
@ -277,9 +299,14 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryArea = MmOpenMemoryAreaByAddress(Process,*BaseAddress);
|
AddressSpace = &Process->Pcb.AddressSpace;
|
||||||
|
|
||||||
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||||
|
*BaseAddress);
|
||||||
if (MemoryArea == NULL)
|
if (MemoryArea == NULL)
|
||||||
{
|
{
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
@ -289,27 +316,32 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
case MEM_RELEASE:
|
case MEM_RELEASE:
|
||||||
if (MemoryArea->BaseAddress != (*BaseAddress))
|
if (MemoryArea->BaseAddress != (*BaseAddress))
|
||||||
{
|
{
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
MmFreeMemoryArea(PsGetCurrentProcess(),
|
MmFreeMemoryArea(&Process->Pcb.AddressSpace,
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
0,
|
0,
|
||||||
TRUE);
|
TRUE);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
|
|
||||||
case MEM_DECOMMIT:
|
case MEM_DECOMMIT:
|
||||||
MmSplitMemoryArea(PsGetCurrentProcess(),
|
MmSplitMemoryArea(Process,
|
||||||
|
&Process->Pcb.AddressSpace,
|
||||||
MemoryArea,
|
MemoryArea,
|
||||||
*BaseAddress,
|
*BaseAddress,
|
||||||
*RegionSize,
|
*RegionSize,
|
||||||
MEMORY_AREA_RESERVE,
|
MEMORY_AREA_RESERVE,
|
||||||
MemoryArea->Attributes);
|
MemoryArea->Attributes);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
return(STATUS_NOT_IMPLEMENTED);
|
return(STATUS_NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +366,9 @@ VOID MmChangeAreaProtection(PEPROCESS Process,
|
||||||
{
|
{
|
||||||
if (MmIsPagePresent(Process, BaseAddress + (i*PAGESIZE)))
|
if (MmIsPagePresent(Process, BaseAddress + (i*PAGESIZE)))
|
||||||
{
|
{
|
||||||
MmSetPageProtect(Process, BaseAddress + (i*PAGESIZE), Protect);
|
MmSetPageProtect(Process,
|
||||||
|
BaseAddress + (i*PAGESIZE),
|
||||||
|
Protect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,6 +383,7 @@ NTSTATUS STDCALL NtProtectVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
PMEMORY_AREA MemoryArea;
|
PMEMORY_AREA MemoryArea;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PMADDRESS_SPACE AddressSpace;
|
||||||
|
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_VM_OPERATION,
|
PROCESS_VM_OPERATION,
|
||||||
|
@ -362,10 +397,15 @@ NTSTATUS STDCALL NtProtectVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryArea = MmOpenMemoryAreaByAddress(Process,BaseAddress);
|
AddressSpace = &Process->Pcb.AddressSpace;
|
||||||
|
|
||||||
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||||
|
BaseAddress);
|
||||||
if (MemoryArea == NULL)
|
if (MemoryArea == NULL)
|
||||||
{
|
{
|
||||||
DPRINT("NtProtectVirtualMemory() = %x\n",STATUS_UNSUCCESSFUL);
|
DPRINT("NtProtectVirtualMemory() = %x\n",STATUS_UNSUCCESSFUL);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
@ -380,29 +420,29 @@ NTSTATUS STDCALL NtProtectVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MemoryArea = MmSplitMemoryArea(Process,
|
MemoryArea = MmSplitMemoryArea(Process,
|
||||||
|
&Process->Pcb.AddressSpace,
|
||||||
MemoryArea,
|
MemoryArea,
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
NumberOfBytesToProtect,
|
NumberOfBytesToProtect,
|
||||||
MemoryArea->Type,
|
MemoryArea->Type,
|
||||||
NewAccessProtection);
|
NewAccessProtection);
|
||||||
}
|
}
|
||||||
MmChangeAreaProtection(Process,BaseAddress,NumberOfBytesToProtect,
|
MmChangeAreaProtection(Process,
|
||||||
|
BaseAddress,
|
||||||
|
NumberOfBytesToProtect,
|
||||||
NewAccessProtection);
|
NewAccessProtection);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtQueryVirtualMemory (IN HANDLE ProcessHandle,
|
||||||
STDCALL
|
IN PVOID Address,
|
||||||
NtQueryVirtualMemory (
|
IN CINT VirtualMemoryInformationClass,
|
||||||
IN HANDLE ProcessHandle,
|
OUT PVOID VirtualMemoryInformation,
|
||||||
IN PVOID Address,
|
IN ULONG Length,
|
||||||
IN CINT VirtualMemoryInformationClass,
|
OUT PULONG ResultLength)
|
||||||
OUT PVOID VirtualMemoryInformation,
|
|
||||||
IN ULONG Length,
|
|
||||||
OUT PULONG ResultLength
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
|
@ -420,6 +460,7 @@ NtQueryVirtualMemory (
|
||||||
{
|
{
|
||||||
PMEMORY_BASIC_INFORMATION Info =
|
PMEMORY_BASIC_INFORMATION Info =
|
||||||
(PMEMORY_BASIC_INFORMATION)VirtualMemoryInformation;
|
(PMEMORY_BASIC_INFORMATION)VirtualMemoryInformation;
|
||||||
|
PMADDRESS_SPACE AddressSpace;
|
||||||
|
|
||||||
if (Length < sizeof(MEMORY_BASIC_INFORMATION))
|
if (Length < sizeof(MEMORY_BASIC_INFORMATION))
|
||||||
{
|
{
|
||||||
|
@ -445,13 +486,16 @@ NtQueryVirtualMemory (
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryArea = MmOpenMemoryAreaByAddress(Process,
|
AddressSpace = &Process->Pcb.AddressSpace;
|
||||||
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||||
Address);
|
Address);
|
||||||
|
|
||||||
if (MemoryArea == NULL)
|
if (MemoryArea == NULL)
|
||||||
{
|
{
|
||||||
Info->State = MEM_FREE;
|
Info->State = MEM_FREE;
|
||||||
DPRINT("Virtual memory at %p is free.\n", Address);
|
DPRINT("Virtual memory at %p is free.\n", Address);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return (STATUS_SUCCESS);
|
return (STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -471,6 +515,7 @@ NtQueryVirtualMemory (
|
||||||
DPRINT("BaseAddress %p, RegionSize %x State %x\n",
|
DPRINT("BaseAddress %p, RegionSize %x State %x\n",
|
||||||
Info->BaseAddress, Info->RegionSize, Info->State);
|
Info->BaseAddress, Info->RegionSize, Info->State);
|
||||||
|
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntoskrnl.def,v 1.63 2000/03/26 19:38:17 ea Exp $
|
; $Id: ntoskrnl.def,v 1.64 2000/03/29 13:11:53 dwelch Exp $
|
||||||
;
|
;
|
||||||
; reactos/ntoskrnl/ntoskrnl.def
|
; reactos/ntoskrnl/ntoskrnl.def
|
||||||
;
|
;
|
||||||
|
@ -228,7 +228,7 @@ IoInitializeTimer@12
|
||||||
IoIsOperationSynchronous@4
|
IoIsOperationSynchronous@4
|
||||||
IoMakeAssociatedIrp@8
|
IoMakeAssociatedIrp@8
|
||||||
IoOpenDeviceInstanceKey@20
|
IoOpenDeviceInstanceKey@20
|
||||||
IoPageRead@20
|
IoPageRead@16
|
||||||
IoQueryDeviceDescription@32
|
IoQueryDeviceDescription@32
|
||||||
IoQueryDeviceEnumInfo@8
|
IoQueryDeviceEnumInfo@8
|
||||||
IoQueryFileInformation@20
|
IoQueryFileInformation@20
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntoskrnl.edf,v 1.50 2000/03/26 19:38:18 ea Exp $
|
; $Id: ntoskrnl.edf,v 1.51 2000/03/29 13:11:53 dwelch Exp $
|
||||||
;
|
;
|
||||||
; reactos/ntoskrnl/ntoskrnl.def
|
; reactos/ntoskrnl/ntoskrnl.def
|
||||||
;
|
;
|
||||||
|
@ -227,7 +227,7 @@ IoInitializeTimer=IoInitializeTimer@12
|
||||||
IoIsOperationSynchronous=IoIsOperationSynchronous@4
|
IoIsOperationSynchronous=IoIsOperationSynchronous@4
|
||||||
IoMakeAssociatedIrp=IoMakeAssociatedIrp@8
|
IoMakeAssociatedIrp=IoMakeAssociatedIrp@8
|
||||||
IoOpenDeviceInstanceKey=IoOpenDeviceInstanceKey@20
|
IoOpenDeviceInstanceKey=IoOpenDeviceInstanceKey@20
|
||||||
IoPageRead=IoPageRead@20
|
IoPageRead=IoPageRead@16
|
||||||
IoQueryDeviceDescription=IoQueryDeviceDescription@32
|
IoQueryDeviceDescription=IoQueryDeviceDescription@32
|
||||||
IoQueryDeviceEnumInfo=IoQueryDeviceEnumInfo@8
|
IoQueryDeviceEnumInfo=IoQueryDeviceEnumInfo@8
|
||||||
IoQueryFileInformation=IoQueryFileInformation@20
|
IoQueryFileInformation=IoQueryFileInformation@20
|
||||||
|
|
|
@ -162,7 +162,7 @@ VOID PsInitProcessManagment(VOID)
|
||||||
FALSE);
|
FALSE);
|
||||||
KProcess = &SystemProcess->Pcb;
|
KProcess = &SystemProcess->Pcb;
|
||||||
|
|
||||||
InitializeListHead(&(KProcess->MemoryAreaList));
|
MmInitializeAddressSpace(&SystemProcess->Pcb.AddressSpace);
|
||||||
ObCreateHandleTable(NULL,FALSE,SystemProcess);
|
ObCreateHandleTable(NULL,FALSE,SystemProcess);
|
||||||
KProcess->PageTableDirectory = get_page_directory();
|
KProcess->PageTableDirectory = get_page_directory();
|
||||||
SystemProcess->UniqueProcessId =
|
SystemProcess->UniqueProcessId =
|
||||||
|
@ -330,7 +330,7 @@ NTSTATUS STDCALL NtCreateProcess (OUT PHANDLE ProcessHandle,
|
||||||
KProcess = &Process->Pcb;
|
KProcess = &Process->Pcb;
|
||||||
|
|
||||||
KProcess->BasePriority = PROCESS_PRIO_NORMAL;
|
KProcess->BasePriority = PROCESS_PRIO_NORMAL;
|
||||||
InitializeListHead(&(KProcess->MemoryAreaList));
|
MmInitializeAddressSpace(&KProcess->AddressSpace);
|
||||||
Process->UniqueProcessId = InterlockedIncrement(&PiNextProcessUniqueId);
|
Process->UniqueProcessId = InterlockedIncrement(&PiNextProcessUniqueId);
|
||||||
Process->InheritedFromUniqueProcessId = ParentProcess->UniqueProcessId;
|
Process->InheritedFromUniqueProcessId = ParentProcess->UniqueProcessId;
|
||||||
ObCreateHandleTable(ParentProcess,
|
ObCreateHandleTable(ParentProcess,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue