mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +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
|
||||
#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 --- */
|
||||
|
||||
|
@ -649,15 +649,10 @@ IoOpenDeviceInstanceKey (
|
|||
DWORD Unknown3,
|
||||
DWORD Unknown4
|
||||
);
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
IoPageRead (
|
||||
PFILE_OBJECT FileObject,
|
||||
PMDL Mdl,
|
||||
PLARGE_INTEGER Offset,
|
||||
PIO_STATUS_BLOCK StatusBlock,
|
||||
DWORD Unknown4
|
||||
);
|
||||
NTSTATUS STDCALL IoPageRead (PFILE_OBJECT FileObject,
|
||||
PMDL Mdl,
|
||||
PLARGE_INTEGER Offset,
|
||||
PIO_STATUS_BLOCK StatusBlock);
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
IoQueryDeviceDescription (
|
||||
|
|
|
@ -1,23 +1,28 @@
|
|||
|
||||
enum
|
||||
typedef struct _MADDRESS_SPACE
|
||||
{
|
||||
MDL_MAPPED_TO_SYSTEM_VA = 0x1,
|
||||
MDL_PAGES_LOCKED = 0x2,
|
||||
MDL_SOURCE_IS_NONPAGED_POOL = 0x4,
|
||||
MDL_ALLOCATED_FIXED_SIZE = 0x8,
|
||||
MDL_PARTIAL = 0x10,
|
||||
MDL_PARTIAL_HAS_BEEN_MAPPED = 0x20,
|
||||
MDL_IO_PAGE_READ = 0x40,
|
||||
MDL_WRITE_OPERATION = 0x80,
|
||||
MDL_PARENT_MAPPED_SYSTEM_VA = 0x100,
|
||||
MDL_LOCK_HELD = 0x200,
|
||||
MDL_SCATTER_GATHER_VA = 0x400,
|
||||
MDL_IO_SPACE = 0x800,
|
||||
MDL_NETWORK_HEADER = 0x1000,
|
||||
MDL_MAPPING_CAN_FAIL = 0x2000,
|
||||
MDL_ALLOCATED_MUST_SUCCEED = 0x4000,
|
||||
MDL_64_BIT_VA = 0x8000,
|
||||
};
|
||||
LIST_ENTRY MAreaListHead;
|
||||
KMUTEX Lock;
|
||||
ULONG LowestAddress;
|
||||
} MADDRESS_SPACE, *PMADDRESS_SPACE;
|
||||
|
||||
#define MDL_MAPPED_TO_SYSTEM_VA (0x1)
|
||||
#define MDL_PAGES_LOCKED (0x2)
|
||||
#define MDL_SOURCE_IS_NONPAGED_POOL (0x4)
|
||||
#define MDL_ALLOCATED_FIXED_SIZE (0x8)
|
||||
#define MDL_PARTIAL (0x10)
|
||||
#define MDL_PARTIAL_HAS_BEEN_MAPPED (0x20)
|
||||
#define MDL_IO_PAGE_READ (0x40)
|
||||
#define MDL_WRITE_OPERATION (0x80)
|
||||
#define MDL_PARENT_MAPPED_SYSTEM_VA (0x100)
|
||||
#define MDL_LOCK_HELD (0x200)
|
||||
#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
|
||||
/*
|
||||
|
|
|
@ -234,7 +234,7 @@ typedef struct _KPROCESS
|
|||
/*
|
||||
* Added by David Welch (welch@mcmail.com)
|
||||
*/
|
||||
LIST_ENTRY MemoryAreaList;
|
||||
MADDRESS_SPACE AddressSpace;
|
||||
HANDLE_TABLE HandleTable;
|
||||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -44,13 +44,10 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
|
|||
PDEVICE_OBJECT DeviceToMount);
|
||||
VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost);
|
||||
|
||||
NTSTATUS
|
||||
IopCreateFile (
|
||||
PVOID ObjectBody,
|
||||
PVOID Parent,
|
||||
PWSTR RemainingPath,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes
|
||||
);
|
||||
NTSTATUS IopCreateFile (PVOID ObjectBody,
|
||||
PVOID Parent,
|
||||
PWSTR RemainingPath,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes);
|
||||
NTSTATUS IopCreateDevice(PVOID ObjectBody,
|
||||
PVOID Parent,
|
||||
PWSTR RemainingPath,
|
||||
|
|
|
@ -61,22 +61,26 @@ typedef struct
|
|||
|
||||
/* FUNCTIONS */
|
||||
|
||||
PVOID
|
||||
STDCALL
|
||||
MmAllocateSection (
|
||||
IN ULONG Length
|
||||
);
|
||||
NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
|
||||
PEPROCESS Process,
|
||||
VOID MmLockAddressSpace(PMADDRESS_SPACE AddressSpace);
|
||||
VOID MmUnlockAddressSpace(PMADDRESS_SPACE AddressSpace);
|
||||
VOID MmInitializeKernelAddressSpace(VOID);
|
||||
PMADDRESS_SPACE MmGetCurrentAddressSpace(VOID);
|
||||
PMADDRESS_SPACE MmGetKernelAddressSpace(VOID);
|
||||
NTSTATUS MmInitializeAddressSpace(PMADDRESS_SPACE AddressSpace);
|
||||
NTSTATUS MmDestroyAddressSpace(PMADDRESS_SPACE AddressSpace);
|
||||
PVOID STDCALL MmAllocateSection (IN ULONG Length);
|
||||
NTSTATUS MmCreateMemoryArea(PEPROCESS Process,
|
||||
PMADDRESS_SPACE AddressSpace,
|
||||
ULONG Type,
|
||||
PVOID* BaseAddress,
|
||||
ULONG Length,
|
||||
ULONG Attributes,
|
||||
MEMORY_AREA** Result);
|
||||
MEMORY_AREA* MmOpenMemoryAreaByAddress(PEPROCESS Process, PVOID Address);
|
||||
MEMORY_AREA* MmOpenMemoryAreaByAddress(PMADDRESS_SPACE AddressSpace,
|
||||
PVOID Address);
|
||||
NTSTATUS MmInitMemoryAreas(VOID);
|
||||
VOID ExInitNonPagedPool(ULONG BaseAddress);
|
||||
NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
|
||||
NTSTATUS MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
|
||||
PVOID BaseAddress,
|
||||
ULONG Length,
|
||||
BOOLEAN FreePages);
|
||||
|
@ -90,6 +94,7 @@ NTSTATUS MmInitSectionImplementation(VOID);
|
|||
#define MM_LOWEST_USER_ADDRESS (4096)
|
||||
|
||||
PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
|
||||
PMADDRESS_SPACE AddressSpace,
|
||||
PMEMORY_AREA OriginalMemoryArea,
|
||||
PVOID BaseAddress,
|
||||
ULONG Length,
|
||||
|
|
|
@ -9,6 +9,7 @@ cp lib/kernel32/kernel32.dll $1/reactos/system32
|
|||
cp lib/crtdll/crtdll.dll $1/reactos/system32
|
||||
cp lib/fmifs/fmifs.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/args/args.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
|
||||
{
|
||||
void HelloProc([in] int pszString);
|
||||
void Shutdown(void);
|
||||
struct _hello_struct
|
||||
{
|
||||
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]
|
||||
ID [a-zA-Z][a-zA-Z0-9]*
|
||||
ID [a-zA-Z_][a-zA-Z0-9_]*
|
||||
UUID [a-z0-9]*
|
||||
|
||||
%%
|
||||
|
@ -23,8 +23,30 @@ version { TOK(VERSION_KEYWORD); }
|
|||
pointer_default { TOK(POINTER_DEFAULT_KEYWORD); }
|
||||
unique { TOK(UNIQUE_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); }
|
||||
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;
|
||||
if ((n = token_to_type(yytext)) != 0)
|
||||
|
@ -66,6 +88,10 @@ out { TOK(OUT_KEYWORD); }
|
|||
|
||||
"]" { TOK(RSQBRACKET); }
|
||||
|
||||
"*" { TOK(STAR); }
|
||||
|
||||
"=" { TOK(ASSIGNMENT); }
|
||||
|
||||
\n lineno++;
|
||||
|
||||
[ \t\r]+ ;
|
||||
|
|
|
@ -26,16 +26,41 @@ int major;
|
|||
%token POINTER_DEFAULT_KEYWORD
|
||||
%token <token> UNIQUE_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 LCURLY_BRACKET, RCURLY_BRACKET, LINE_TERMINATOR, COMMA
|
||||
%token LEFT_BRACKET, RIGHT_BRACKET
|
||||
%token STAR
|
||||
%token ASSIGNMENT
|
||||
|
||||
%token <tval> TYPE_KEYWORD
|
||||
|
||||
%type <tval> type
|
||||
%type <tval> sign
|
||||
%type <tval> struct_def
|
||||
|
||||
%%
|
||||
|
||||
|
@ -63,7 +88,16 @@ interface: { start_interface(); }
|
|||
|
||||
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(); }
|
||||
type ID_TOKEN LEFT_BRACKET argument_list RIGHT_BRACKET
|
||||
|
@ -80,12 +114,59 @@ argument_list:
|
|||
| argument COMMA argument_list
|
||||
;
|
||||
|
||||
argument:
|
||||
LSQBRACKET direction RSQBRACKET type ID_TOKEN { add_argument($4, $5); }
|
||||
argument: arg_attrs type ID_TOKEN { add_argument($2, $3); }
|
||||
| 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:
|
||||
IN_KEYWORD
|
||||
struct_def: ID_TOKEN { start_struct($1); } LCURLY_BRACKET
|
||||
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"
|
||||
|
||||
struct _type;
|
||||
|
||||
typedef struct _struct_member
|
||||
{
|
||||
char* name;
|
||||
unsigned int value;
|
||||
struct _struct_member* next;
|
||||
} struct_member;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct_member* member_list;
|
||||
char* tag;
|
||||
struct _type* type_value;
|
||||
} struct_type;
|
||||
|
||||
typedef struct _type
|
||||
{
|
||||
char* name;
|
||||
unsigned int value;
|
||||
unsigned int default_sign;
|
||||
struct_type* struct_desc;
|
||||
} 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},
|
||||
{"byte", BYTE_TYPE, 0},
|
||||
{"char", CHAR_TYPE, UNSIGNED_TYPE_OPTION},
|
||||
|
@ -32,15 +55,119 @@ static type types[] = {
|
|||
{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)
|
||||
{
|
||||
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);
|
||||
if (tval & POINTER_TYPE_OPTION)
|
||||
{
|
||||
printf("*");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +178,7 @@ int token_to_type(char* token)
|
|||
{
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
#ifndef __TYPES_H
|
||||
#define __TYPES_H
|
||||
|
||||
#define BASE_TYPE_MASK (~0xff)
|
||||
|
||||
#define BOOLEAN_TYPE (0x100)
|
||||
#define BYTE_TYPE (0x200)
|
||||
#define CHAR_TYPE (0x400)
|
||||
#define DOUBLE_TYPE (0x800)
|
||||
#define ERROR_STATUS_TYPE (0x1000)
|
||||
#define FLOAT_TYPE (0x2000)
|
||||
#define HANDLE_TYPE (0x4000)
|
||||
#define HYPER_TYPE (0x8000)
|
||||
#define INT_TYPE (0x10000)
|
||||
#define INT32_TYPE (0x20000)
|
||||
#define INT32OR64_TYPE (0x40000)
|
||||
#define INT64_TYPE (0x80000)
|
||||
#define LONG_TYPE (0x100000)
|
||||
#define SHORT_TYPE (0x200000)
|
||||
#define SMALL_TYPE (0x400000)
|
||||
#define VOID_TYPE (0x800000)
|
||||
#define WCHAR_TYPE (0x1000000)
|
||||
#define CHAR_TYPE (0x300)
|
||||
#define DOUBLE_TYPE (0x400)
|
||||
#define ERROR_STATUS_TYPE (0x500)
|
||||
#define FLOAT_TYPE (0x600)
|
||||
#define HANDLE_TYPE (0x700)
|
||||
#define HYPER_TYPE (0x800)
|
||||
#define INT_TYPE (0x900)
|
||||
#define INT32_TYPE (0xA00)
|
||||
#define INT32OR64_TYPE (0xB00)
|
||||
#define INT64_TYPE (0xC00)
|
||||
#define LONG_TYPE (0xD00)
|
||||
#define SHORT_TYPE (0xE00)
|
||||
#define SMALL_TYPE (0xF00)
|
||||
#define VOID_TYPE (0x1000)
|
||||
#define WCHAR_TYPE (0x1100)
|
||||
|
||||
#define UNSIGNED_TYPE_OPTION (0x1)
|
||||
#define SIGNED_TYPE_OPTION (0x2)
|
||||
|
@ -29,5 +31,12 @@
|
|||
|
||||
int token_to_type(char* token);
|
||||
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
|
||||
|
|
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -320,7 +320,7 @@ IoCreateFile (
|
|||
KEVENT Event;
|
||||
PIO_STACK_LOCATION StackLoc;
|
||||
|
||||
DPRINT1("IoCreateFile(FileHandle %x, DesiredAccess %x, "
|
||||
DPRINT("IoCreateFile(FileHandle %x, DesiredAccess %x, "
|
||||
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
|
||||
FileHandle,DesiredAccess,ObjectAttributes,
|
||||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -19,15 +19,10 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
IoPageRead (
|
||||
PFILE_OBJECT FileObject,
|
||||
PMDL Mdl,
|
||||
PLARGE_INTEGER Offset,
|
||||
PIO_STATUS_BLOCK StatusBlock,
|
||||
DWORD Unknown4
|
||||
)
|
||||
NTSTATUS STDCALL IoPageRead(PFILE_OBJECT FileObject,
|
||||
PMDL Mdl,
|
||||
PLARGE_INTEGER Offset,
|
||||
PIO_STATUS_BLOCK StatusBlock)
|
||||
{
|
||||
PIRP Irp;
|
||||
KEVENT Event;
|
||||
|
@ -72,18 +67,14 @@ IoPageRead (
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
IoSynchronousPageWrite (
|
||||
DWORD Unknown0,
|
||||
DWORD Unknown1,
|
||||
DWORD Unknown2,
|
||||
DWORD Unknown3,
|
||||
DWORD Unknown4
|
||||
)
|
||||
NTSTATUS STDCALL IoSynchronousPageWrite (DWORD Unknown0,
|
||||
DWORD Unknown1,
|
||||
DWORD Unknown2,
|
||||
DWORD Unknown3,
|
||||
DWORD Unknown4)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return (STATUS_NOT_IMPLEMENTED);
|
||||
UNIMPLEMENTED;
|
||||
return (STATUS_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ asmlinkage void exception_handler(unsigned int edi,
|
|||
DbgPrint("EDI: %.8x EFLAGS: %.8x ",edi,eflags);
|
||||
if ((cs&0xffff) == KERNEL_CS)
|
||||
{
|
||||
DbgPrint("kESP %.8x\n",esp);
|
||||
DbgPrint("kESP %.8x ",esp);
|
||||
if (PsGetCurrentThread() != NULL)
|
||||
{
|
||||
DbgPrint("kernel stack base %x\n",
|
||||
|
@ -285,9 +285,8 @@ asmlinkage void exception_handler(unsigned int edi,
|
|||
stack = (PULONG) (esp + 24);
|
||||
// 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)
|
||||
{
|
||||
DbgPrint("%.8x %.8x %.8x %.8x\n",
|
||||
|
|
|
@ -33,7 +33,12 @@ LONG KeReadStateMutex(PKMUTEX Mutex)
|
|||
LONG KeReleaseMutex(PKMUTEX Mutex, BOOLEAN Wait)
|
||||
{
|
||||
KeAcquireDispatcherDatabaseLock(Wait);
|
||||
KeDispatcherObjectWake(&Mutex->Header);
|
||||
Mutex->Header.SignalState--;
|
||||
assert(Mutex->Header.SignalState >= 0);
|
||||
if (Mutex->Header.SignalState == 0)
|
||||
{
|
||||
KeDispatcherObjectWake(&Mutex->Header);
|
||||
}
|
||||
KeReleaseDispatcherDatabaseLock(Wait);
|
||||
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
|
||||
* satisfied
|
||||
|
@ -104,6 +105,18 @@ VOID KiSideEffectsBeforeWake(DISPATCHER_HEADER* hdr)
|
|||
case InternalNotificationTimer:
|
||||
break;
|
||||
|
||||
case InternalMutexType:
|
||||
{
|
||||
PKMUTEX Mutex;
|
||||
|
||||
Mutex = CONTAINING_RECORD(hdr,
|
||||
KMUTEX,
|
||||
Header);
|
||||
hdr->SignalState++;
|
||||
Mutex->OwnerThread = Thread;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
DbgPrint("(%s:%d) Dispatcher object %x has unknown type\n",
|
||||
__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)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
KiSideEffectsBeforeWake(hdr);
|
||||
return(TRUE);
|
||||
else
|
||||
{
|
||||
KiSideEffectsBeforeWake(hdr, Thread);
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
VOID KeRemoveAllWaitsThread(PETHREAD Thread, NTSTATUS WaitStatus)
|
||||
|
@ -166,7 +204,8 @@ static BOOLEAN KeDispatcherObjectWakeAll(DISPATCHER_HEADER* hdr)
|
|||
while (!IsListEmpty(&(hdr->WaitListHead)))
|
||||
{
|
||||
current_entry = RemoveHeadList(&hdr->WaitListHead);
|
||||
current = CONTAINING_RECORD(current_entry,KWAIT_BLOCK,
|
||||
current = CONTAINING_RECORD(current_entry,
|
||||
KWAIT_BLOCK,
|
||||
WaitListEntry);
|
||||
DPRINT("Waking %x\n",current->Thread);
|
||||
if (current->WaitType == WaitAny)
|
||||
|
@ -200,10 +239,13 @@ static BOOLEAN KeDispatcherObjectWakeAll(DISPATCHER_HEADER* hdr)
|
|||
}
|
||||
}
|
||||
}
|
||||
KiSideEffectsBeforeWake(hdr);
|
||||
KiSideEffectsBeforeWake(hdr, current->Thread);
|
||||
Status = current->WaitKey;
|
||||
if( current->Thread->WaitBlockList == NULL )
|
||||
PsUnfreezeThread( CONTAINING_RECORD( current->Thread,ETHREAD,Tcb ), &Status );
|
||||
if (current->Thread->WaitBlockList == NULL)
|
||||
{
|
||||
PsUnfreezeThread(CONTAINING_RECORD(current->Thread,ETHREAD,Tcb),
|
||||
&Status);
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
@ -260,9 +302,10 @@ static BOOLEAN KeDispatcherObjectWakeOne(DISPATCHER_HEADER* hdr)
|
|||
}
|
||||
|
||||
DPRINT("Waking %x\n",current->Thread);
|
||||
KiSideEffectsBeforeWake(hdr);
|
||||
KiSideEffectsBeforeWake(hdr, current->Thread);
|
||||
Status = current->WaitKey;
|
||||
PsUnfreezeThread( CONTAINING_RECORD( current->Thread, ETHREAD, Tcb ), &Status );
|
||||
PsUnfreezeThread(CONTAINING_RECORD(current->Thread, ETHREAD, Tcb),
|
||||
&Status);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
@ -366,7 +409,7 @@ NTSTATUS KeWaitForSingleObject(PVOID Object,
|
|||
|
||||
DPRINT("hdr->SignalState %d\n", hdr->SignalState);
|
||||
|
||||
if (KiIsObjectSignalled(hdr))
|
||||
if (KiIsObjectSignalled(hdr, CurrentThread))
|
||||
{
|
||||
KeReleaseDispatcherDatabaseLock(FALSE);
|
||||
if (Timeout != NULL)
|
||||
|
@ -457,7 +500,7 @@ NTSTATUS KeWaitForMultipleObjects(ULONG Count,
|
|||
|
||||
DPRINT("hdr->SignalState %d\n", hdr->SignalState);
|
||||
|
||||
if (KiIsObjectSignalled(hdr))
|
||||
if (KiIsObjectSignalled(hdr, CurrentThread))
|
||||
{
|
||||
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
|
||||
#
|
||||
|
@ -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/mdl.o mm/zone.o mm/paging.o mm/section.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
|
||||
|
|
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -44,14 +44,11 @@
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
PVOID
|
||||
STDCALL
|
||||
MmAllocateContiguousMemory (
|
||||
IN ULONG NumberOfBytes,
|
||||
IN PHYSICAL_ADDRESS HighestAcceptableAddress
|
||||
)
|
||||
PVOID STDCALL MmAllocateContiguousMemory (
|
||||
IN ULONG NumberOfBytes,
|
||||
IN PHYSICAL_ADDRESS HighestAcceptableAddress)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,13 +74,9 @@ MmAllocateContiguousMemory (
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
MmFreeContiguousMemory (
|
||||
IN OUT PVOID BaseAddress
|
||||
)
|
||||
VOID STDCALL MmFreeContiguousMemory(IN 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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -19,7 +19,6 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* NAME EXPORTED
|
||||
* MmMapIoSpace@16
|
||||
|
@ -47,58 +46,41 @@
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
PVOID
|
||||
STDCALL
|
||||
MmMapIoSpace (
|
||||
IN PHYSICAL_ADDRESS PhysicalAddress,
|
||||
IN ULONG NumberOfBytes,
|
||||
IN BOOLEAN CacheEnable
|
||||
)
|
||||
PVOID STDCALL MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress,
|
||||
IN ULONG NumberOfBytes,
|
||||
IN BOOLEAN CacheEnable)
|
||||
{
|
||||
PVOID Result;
|
||||
MEMORY_AREA * marea;
|
||||
NTSTATUS Status;
|
||||
ULONG i;
|
||||
ULONG Attributes;
|
||||
PVOID Result;
|
||||
MEMORY_AREA* marea;
|
||||
NTSTATUS Status;
|
||||
ULONG i;
|
||||
ULONG Attributes;
|
||||
|
||||
Result = NULL;
|
||||
Status = MmCreateMemoryArea (
|
||||
KernelMode,
|
||||
PsGetCurrentProcess (),
|
||||
MEMORY_AREA_IO_MAPPING,
|
||||
& Result,
|
||||
NumberOfBytes,
|
||||
0,
|
||||
& marea
|
||||
);
|
||||
if (STATUS_SUCCESS != Status)
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
Attributes = ( PA_WRITE
|
||||
| PA_READ
|
||||
| PA_EXECUTE
|
||||
| PA_SYSTEM
|
||||
);
|
||||
if (!CacheEnable)
|
||||
{
|
||||
Attributes |= (PA_PWT | PA_PCD);
|
||||
}
|
||||
for ( i = 0;
|
||||
(i <= (NumberOfBytes / PAGESIZE));
|
||||
i ++
|
||||
)
|
||||
{
|
||||
MmSetPage (
|
||||
NULL,
|
||||
(Result + (i * PAGESIZE)),
|
||||
PAGE_READWRITE,
|
||||
( PhysicalAddress.u.LowPart
|
||||
+ (i * PAGESIZE)
|
||||
)
|
||||
);
|
||||
}
|
||||
return ((PVOID) Result);
|
||||
Result = NULL;
|
||||
Status = MmCreateMemoryArea (NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
MEMORY_AREA_IO_MAPPING,
|
||||
&Result,
|
||||
NumberOfBytes,
|
||||
0,
|
||||
&marea);
|
||||
if (!NT_SUCCESS(STATUS_SUCCESS))
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
Attributes = PA_WRITE | PA_READ | PA_EXECUTE | PA_SYSTEM;
|
||||
if (!CacheEnable)
|
||||
{
|
||||
Attributes |= (PA_PWT | PA_PCD);
|
||||
}
|
||||
for (i = 0; (i <= (NumberOfBytes / PAGESIZE)); i++)
|
||||
{
|
||||
MmSetPage (NULL,
|
||||
(Result + (i * PAGESIZE)),
|
||||
PAGE_READWRITE,
|
||||
(PhysicalAddress.u.LowPart + (i * PAGESIZE)));
|
||||
}
|
||||
return ((PVOID)Result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,19 +107,13 @@ MmMapIoSpace (
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
MmUnmapIoSpace (
|
||||
IN PVOID BaseAddress,
|
||||
IN ULONG NumberOfBytes
|
||||
)
|
||||
VOID STDCALL MmUnmapIoSpace (IN PVOID BaseAddress,
|
||||
IN ULONG NumberOfBytes)
|
||||
{
|
||||
(VOID) MmFreeMemoryArea (
|
||||
PsGetCurrentProcess (),
|
||||
BaseAddress,
|
||||
NumberOfBytes,
|
||||
FALSE
|
||||
);
|
||||
(VOID)MmFreeMemoryArea(&PsGetCurrentProcess()->Pcb.AddressSpace,
|
||||
BaseAddress,
|
||||
NumberOfBytes,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,11 +17,6 @@
|
|||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
static LIST_ENTRY SystemAreaList;
|
||||
static KSPIN_LOCK SystemAreaListLock;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
|
||||
|
@ -44,97 +39,23 @@ VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
|
|||
DbgPrint("Finished MmDumpMemoryAreas()\n");
|
||||
}
|
||||
|
||||
VOID MmLockMemoryAreaList(PVOID Address, PKIRQL oldlvl)
|
||||
{
|
||||
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)
|
||||
MEMORY_AREA* MmOpenMemoryAreaByAddress(PMADDRESS_SPACE AddressSpace,
|
||||
PVOID Address)
|
||||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
MEMORY_AREA* current;
|
||||
PLIST_ENTRY previous_entry;
|
||||
|
||||
// MmDumpMemoryAreas();
|
||||
DPRINT("MmOpenMemoryAreaByAddress(AddressSpace %x, Address %x)\n",
|
||||
AddressSpace, Address);
|
||||
|
||||
DPRINT("MmInternalOpenMemoryAreaByAddress(ListHead %x, Address %x)\n",
|
||||
ListHead,Address);
|
||||
|
||||
if (ListHead==NULL)
|
||||
previous_entry = &AddressSpace->MAreaListHead;
|
||||
current_entry = AddressSpace->MAreaListHead.Flink;
|
||||
while (current_entry != &AddressSpace->MAreaListHead)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
previous_entry = ListHead;
|
||||
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("Scanning %x BaseAddress %x Length %x\n",
|
||||
current, current->BaseAddress, current->Length);
|
||||
assert(current_entry->Blink->Flink == current_entry);
|
||||
|
@ -171,30 +92,30 @@ static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
|
|||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
||||
PVOID Address,
|
||||
ULONG Length)
|
||||
MEMORY_AREA* MmOpenMemoryAreaByRegion(PMADDRESS_SPACE AddressSpace,
|
||||
PVOID Address,
|
||||
ULONG Length)
|
||||
{
|
||||
MEMORY_AREA* Result;
|
||||
PLIST_ENTRY current_entry;
|
||||
MEMORY_AREA* current;
|
||||
ULONG Extent;
|
||||
|
||||
DPRINT("MmInternalOpenMemoryAreaByRegion(ListHead %x, Address %x, "
|
||||
"Length %x)\n",ListHead,Address,Length);
|
||||
DPRINT("MmOpenMemoryByRegion(AddressSpace %x, Address %x, Length %x)\n",
|
||||
AddressSpace, Address, Length);
|
||||
|
||||
// MmDumpMemoryAreas(ListHead);
|
||||
|
||||
current_entry = ListHead->Flink;
|
||||
while (current_entry!=ListHead)
|
||||
current_entry = AddressSpace->MAreaListHead.Flink;
|
||||
while (current_entry != &AddressSpace->MAreaListHead)
|
||||
{
|
||||
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
||||
current = CONTAINING_RECORD(current_entry,
|
||||
MEMORY_AREA,
|
||||
Entry);
|
||||
DPRINT("current->BaseAddress %x current->Length %x\n",
|
||||
current->BaseAddress,current->Length);
|
||||
if (current->BaseAddress >= Address &&
|
||||
current->BaseAddress < (Address+Length))
|
||||
{
|
||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
||||
DPRINT("Finished MmOpenMemoryAreaByRegion() = %x\n",
|
||||
current);
|
||||
return(current);
|
||||
}
|
||||
|
@ -202,87 +123,32 @@ MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
|||
if (Extent > (ULONG)Address &&
|
||||
Extent < (ULONG)(Address+Length))
|
||||
{
|
||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
||||
DPRINT("Finished MmOpenMemoryAreaByRegion() = %x\n",
|
||||
current);
|
||||
return(current);
|
||||
}
|
||||
if (current->BaseAddress <= Address &&
|
||||
Extent >= (ULONG)(Address+Length))
|
||||
{
|
||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
||||
DPRINT("Finished MmOpenMemoryAreaByRegion() = %x\n",
|
||||
current);
|
||||
return(current);
|
||||
}
|
||||
if (current->BaseAddress >= (Address+Length))
|
||||
{
|
||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()= NULL\n",0);
|
||||
DPRINT("Finished MmOpenMemoryAreaByRegion()= NULL\n",0);
|
||||
return(NULL);
|
||||
}
|
||||
current_entry = current_entry->Flink;
|
||||
}
|
||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = NULL\n",0);
|
||||
DPRINT("Finished MmOpenMemoryAreaByRegion() = NULL\n",0);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
MEMORY_AREA* MmOpenMemoryAreaByRegionWithoutLock(PEPROCESS Process,
|
||||
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)
|
||||
static VOID MmInsertMemoryArea(PMADDRESS_SPACE AddressSpace,
|
||||
MEMORY_AREA* marea)
|
||||
{
|
||||
PLIST_ENTRY ListHead;
|
||||
PLIST_ENTRY current_entry;
|
||||
|
@ -290,13 +156,11 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
|
|||
MEMORY_AREA* current;
|
||||
MEMORY_AREA* next;
|
||||
|
||||
DPRINT("MmInsertMemoryAreaWithoutLock(marea %x)\n",marea);
|
||||
DPRINT("marea->BaseAddress %x\n",marea->BaseAddress);
|
||||
DPRINT("marea->Length %x\n",marea->Length);
|
||||
DPRINT("MmInsertMemoryArea(marea %x)\n", marea);
|
||||
DPRINT("marea->BaseAddress %x\n", marea->BaseAddress);
|
||||
DPRINT("marea->Length %x\n", marea->Length);
|
||||
|
||||
ListHead=MmGetRelatedListHead(Process,marea->BaseAddress);
|
||||
|
||||
// MmDumpMemoryAreas(ListHead);
|
||||
ListHead = &AddressSpace->MAreaListHead;
|
||||
|
||||
current_entry = ListHead->Flink;
|
||||
CHECKPOINT;
|
||||
|
@ -354,8 +218,8 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
|
|||
InsertTailList(ListHead,inserted_entry);
|
||||
}
|
||||
|
||||
static PVOID MmFindGapWithoutLock(PEPROCESS Process,
|
||||
KPROCESSOR_MODE Mode, ULONG Length)
|
||||
static PVOID MmFindGap(PMADDRESS_SPACE AddressSpace,
|
||||
ULONG Length)
|
||||
{
|
||||
PLIST_ENTRY ListHead;
|
||||
PLIST_ENTRY current_entry;
|
||||
|
@ -363,19 +227,10 @@ static PVOID MmFindGapWithoutLock(PEPROCESS Process,
|
|||
MEMORY_AREA* next;
|
||||
ULONG Gap;
|
||||
|
||||
DPRINT("MmFindGapWithoutLock(Mode %x Length %x)\n",Mode,Length);
|
||||
|
||||
|
||||
if (Mode == KernelMode)
|
||||
{
|
||||
ListHead = &SystemAreaList;
|
||||
}
|
||||
else
|
||||
{
|
||||
ListHead = &(Process->Pcb.MemoryAreaList);
|
||||
}
|
||||
|
||||
DPRINT("MmFindGap(Length %x)\n",Length);
|
||||
|
||||
ListHead = &AddressSpace->MAreaListHead;
|
||||
|
||||
current_entry = ListHead->Flink;
|
||||
while (current_entry->Flink!=ListHead)
|
||||
{
|
||||
|
@ -396,8 +251,7 @@ static PVOID MmFindGapWithoutLock(PEPROCESS Process,
|
|||
|
||||
if (current_entry == ListHead)
|
||||
{
|
||||
assert(Mode==UserMode);
|
||||
return((PVOID)MM_LOWEST_USER_ADDRESS);
|
||||
return((PVOID)AddressSpace->LowestAddress);
|
||||
}
|
||||
|
||||
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
||||
|
@ -412,44 +266,25 @@ NTSTATUS MmInitMemoryAreas(VOID)
|
|||
*/
|
||||
{
|
||||
DPRINT("MmInitMemoryAreas()\n",0);
|
||||
InitializeListHead(&SystemAreaList);
|
||||
KeInitializeSpinLock(&SystemAreaListLock);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
|
||||
NTSTATUS MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
|
||||
PVOID BaseAddress,
|
||||
ULONG Length,
|
||||
BOOLEAN FreePages)
|
||||
{
|
||||
MEMORY_AREA* MemoryArea;
|
||||
ULONG i;
|
||||
KIRQL oldlvl;
|
||||
LARGE_INTEGER PhysicalAddr;
|
||||
|
||||
DPRINT("MmFreeMemoryArea(Process %x, BaseAddress %x, Length %x,"
|
||||
"FreePages %d)\n",Process,BaseAddress,Length,FreePages);
|
||||
DPRINT("MmFreeMemoryArea(AddressSpace %x, BaseAddress %x, Length %x,"
|
||||
"FreePages %d)\n",AddressSpace,BaseAddress,Length,FreePages);
|
||||
|
||||
if (SystemAreaList.Flink != (&SystemAreaList) &&
|
||||
SystemAreaList.Flink->Flink != (&SystemAreaList))
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||
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);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
@ -472,67 +307,42 @@ NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
|
|||
|
||||
RemoveEntryList(&(MemoryArea->Entry));
|
||||
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);
|
||||
}
|
||||
|
||||
PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
|
||||
PMADDRESS_SPACE AddressSpace,
|
||||
PMEMORY_AREA OriginalMemoryArea,
|
||||
PVOID BaseAddress,
|
||||
ULONG Length,
|
||||
ULONG NewType,
|
||||
ULONG NewAttributes)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
PMEMORY_AREA Result;
|
||||
PMEMORY_AREA Split;
|
||||
|
||||
Result = ExAllocatePool(NonPagedPool,sizeof(MEMORY_AREA));
|
||||
RtlZeroMemory(Result,sizeof(MEMORY_AREA));
|
||||
Result->Type=NewType;
|
||||
Result->BaseAddress=BaseAddress;
|
||||
Result->Length=Length;
|
||||
Result->Attributes=NewAttributes;
|
||||
Result->LockCount=0;
|
||||
Result->Type = NewType;
|
||||
Result->BaseAddress = BaseAddress;
|
||||
Result->Length = Length;
|
||||
Result->Attributes = NewAttributes;
|
||||
Result->LockCount = 0;
|
||||
Result->Process = Process;
|
||||
|
||||
MmLockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
|
||||
|
||||
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
|
||||
|
||||
if (BaseAddress == OriginalMemoryArea->BaseAddress)
|
||||
{
|
||||
OriginalMemoryArea->BaseAddress = BaseAddress + Length;
|
||||
OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length;
|
||||
MmInsertMemoryAreaWithoutLock(Process,Result);
|
||||
MmUnlockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
|
||||
|
||||
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
|
||||
|
||||
MmInsertMemoryArea(AddressSpace, Result);
|
||||
return(Result);
|
||||
}
|
||||
if ((BaseAddress + Length) ==
|
||||
(OriginalMemoryArea->BaseAddress + OriginalMemoryArea->Length))
|
||||
{
|
||||
OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length;
|
||||
MmInsertMemoryAreaWithoutLock(Process,Result);
|
||||
MmUnlockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
|
||||
|
||||
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
|
||||
MmInsertMemoryArea(AddressSpace, Result);
|
||||
|
||||
return(Result);
|
||||
}
|
||||
|
@ -545,57 +355,40 @@ PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
|
|||
|
||||
OriginalMemoryArea->Length = BaseAddress - OriginalMemoryArea->BaseAddress;
|
||||
|
||||
MmUnlockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
|
||||
|
||||
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
|
||||
|
||||
return(Split);
|
||||
}
|
||||
|
||||
NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
|
||||
PEPROCESS Process,
|
||||
NTSTATUS MmCreateMemoryArea(PEPROCESS Process,
|
||||
PMADDRESS_SPACE AddressSpace,
|
||||
ULONG Type,
|
||||
PVOID* BaseAddress,
|
||||
ULONG Length,
|
||||
ULONG Attributes,
|
||||
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(Mode %x, Type %d, BaseAddress %x,"
|
||||
DPRINT("MmCreateMemoryArea(Type %d, BaseAddress %x,"
|
||||
"*BaseAddress %x, Length %x, Attributes %x, Result %x)\n",
|
||||
Mode,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)
|
||||
{
|
||||
MmLockMemoryAreaListByMode(Mode,&oldlvl);
|
||||
}
|
||||
else
|
||||
{
|
||||
MmLockMemoryAreaList(*BaseAddress,&oldlvl);
|
||||
}
|
||||
Type,BaseAddress,*BaseAddress,Length,Attributes,Result);
|
||||
|
||||
if ((*BaseAddress)==0)
|
||||
{
|
||||
*BaseAddress = MmFindGapWithoutLock(Process,Mode,PAGE_ROUND_UP(Length)
|
||||
+(PAGESIZE*2));
|
||||
*BaseAddress = MmFindGap(AddressSpace,
|
||||
PAGE_ROUND_UP(Length) +(PAGESIZE*2));
|
||||
if ((*BaseAddress)==0)
|
||||
{
|
||||
DPRINT("No suitable gap\n");
|
||||
MmUnlockMemoryAreaListByMode(Mode,&oldlvl);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
(*BaseAddress)=(*BaseAddress)+PAGESIZE;
|
||||
|
@ -603,40 +396,24 @@ NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
|
|||
else
|
||||
{
|
||||
(*BaseAddress) = (PVOID)PAGE_ROUND_DOWN((*BaseAddress));
|
||||
if (MmOpenMemoryAreaByRegionWithoutLock(Process,
|
||||
*BaseAddress,
|
||||
Length)!=NULL)
|
||||
if (MmOpenMemoryAreaByRegion(AddressSpace,
|
||||
*BaseAddress,
|
||||
Length)!=NULL)
|
||||
{
|
||||
DPRINT("Memory area already occupied\n");
|
||||
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
}
|
||||
|
||||
*Result = ExAllocatePool(NonPagedPool,sizeof(MEMORY_AREA));
|
||||
RtlZeroMemory(*Result,sizeof(MEMORY_AREA));
|
||||
(*Result)->Type=Type;
|
||||
(*Result)->BaseAddress=*BaseAddress;
|
||||
(*Result)->Length=Length;
|
||||
(*Result)->Attributes=Attributes;
|
||||
(*Result)->LockCount=0;
|
||||
(*Result)->Type = Type;
|
||||
(*Result)->BaseAddress = *BaseAddress;
|
||||
(*Result)->Length = Length;
|
||||
(*Result)->Attributes = Attributes;
|
||||
(*Result)->LockCount = 0;
|
||||
(*Result)->Process = Process;
|
||||
|
||||
MmInsertMemoryAreaWithoutLock(Process,*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);
|
||||
}
|
||||
|
||||
MmInsertMemoryArea(AddressSpace, *Result);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -64,8 +64,8 @@ PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
|
|||
DPRINT("PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE) %x\n",
|
||||
PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE);
|
||||
|
||||
MmCreateMemoryArea(KernelMode,
|
||||
NULL,
|
||||
MmCreateMemoryArea(NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
MEMORY_AREA_MDL_MAPPING,
|
||||
&base,
|
||||
Mdl->ByteCount + Mdl->ByteOffset,
|
||||
|
@ -96,7 +96,7 @@ VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl)
|
|||
*/
|
||||
{
|
||||
DPRINT("MmUnmapLockedPages(BaseAddress %x, Mdl %x)\n", Mdl, BaseAddress);
|
||||
(void)MmFreeMemoryArea(NULL,
|
||||
(void)MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
||||
BaseAddress-Mdl->ByteOffset,
|
||||
Mdl->ByteCount,
|
||||
FALSE);
|
||||
|
@ -145,11 +145,21 @@ VOID MmProbeAndLockPages(PMDL Mdl,
|
|||
int i;
|
||||
MEMORY_AREA* marea;
|
||||
PVOID Address;
|
||||
PMADDRESS_SPACE AddressSpace;
|
||||
|
||||
DPRINT("MmProbeAndLockPages(Mdl %x)\n",Mdl);
|
||||
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);
|
||||
DPRINT("marea %x\n",marea);
|
||||
|
||||
|
@ -161,6 +171,7 @@ VOID MmProbeAndLockPages(PMDL Mdl,
|
|||
if (marea==NULL )
|
||||
{
|
||||
DbgPrint("(%s:%d) Area is invalid\n",__FILE__,__LINE__);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ExRaiseStatus(STATUS_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
|
@ -181,6 +192,7 @@ VOID MmProbeAndLockPages(PMDL Mdl,
|
|||
mdl_pages[i] = (MmGetPhysicalAddress(Address)).u.LowPart;
|
||||
DPRINT("mdl_pages[i] %x\n",mdl_pages[i]);
|
||||
}
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
}
|
||||
|
||||
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
|
||||
* 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_pool_desc = NULL;
|
||||
|
||||
/*
|
||||
* All pagefaults are synchronized on this
|
||||
*/
|
||||
static KSPIN_LOCK MiPageFaultLock;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
VOID MiShutdownMemoryManager(VOID)
|
||||
|
@ -80,7 +75,7 @@ VOID MmInitVirtualMemory(boot_param* bp)
|
|||
DPRINT("MmInitVirtualMemory(%x)\n",bp);
|
||||
|
||||
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;
|
||||
Length = PAGE_ROUND_UP(((ULONG)&etext)) - KERNEL_BASE;
|
||||
ParamLength = ParamLength - Length;
|
||||
MmCreateMemoryArea(KernelMode,NULL,MEMORY_AREA_SYSTEM,&BaseAddress,
|
||||
Length,0,&kernel_text_desc);
|
||||
MmCreateMemoryArea(NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
MEMORY_AREA_SYSTEM,
|
||||
&BaseAddress,
|
||||
Length,
|
||||
0,
|
||||
&kernel_text_desc);
|
||||
|
||||
Length = PAGE_ROUND_UP(((ULONG)&_bss_end__)) -
|
||||
PAGE_ROUND_UP(((ULONG)&etext));
|
||||
|
@ -98,8 +98,8 @@ VOID MmInitVirtualMemory(boot_param* bp)
|
|||
DPRINT("Length %x\n",Length);
|
||||
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&etext));
|
||||
DPRINT("BaseAddress %x\n",BaseAddress);
|
||||
MmCreateMemoryArea(KernelMode,
|
||||
NULL,
|
||||
MmCreateMemoryArea(NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
MEMORY_AREA_SYSTEM,
|
||||
&BaseAddress,
|
||||
Length,
|
||||
|
@ -108,27 +108,34 @@ VOID MmInitVirtualMemory(boot_param* bp)
|
|||
|
||||
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&end));
|
||||
Length = ParamLength;
|
||||
MmCreateMemoryArea(KernelMode,NULL,MEMORY_AREA_SYSTEM,&BaseAddress,
|
||||
Length,0,&kernel_param_desc);
|
||||
MmCreateMemoryArea(NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
MEMORY_AREA_SYSTEM,
|
||||
&BaseAddress,
|
||||
Length,
|
||||
0,
|
||||
&kernel_param_desc);
|
||||
|
||||
BaseAddress = (PVOID)(KERNEL_BASE + PAGE_ROUND_UP(kernel_len) + PAGESIZE);
|
||||
Length = NONPAGED_POOL_SIZE;
|
||||
MmCreateMemoryArea(KernelMode,NULL,MEMORY_AREA_SYSTEM,&BaseAddress,
|
||||
Length,0,&kernel_pool_desc);
|
||||
MmCreateMemoryArea(NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
MEMORY_AREA_SYSTEM,
|
||||
&BaseAddress,
|
||||
Length,
|
||||
0,
|
||||
&kernel_pool_desc);
|
||||
|
||||
// MmDumpMemoryAreas();
|
||||
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))
|
||||
{
|
||||
KeReleaseSpinLock(&MiPageFaultLock, oldIrql);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -137,12 +144,11 @@ NTSTATUS MmCommitedSectionHandleFault(MEMORY_AREA* MemoryArea, PVOID Address)
|
|||
MemoryArea->Attributes,
|
||||
(ULONG)MmAllocPage());
|
||||
|
||||
KeReleaseSpinLock(&MiPageFaultLock, oldIrql);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS MmSectionHandleFault(MEMORY_AREA* MemoryArea,
|
||||
NTSTATUS MmSectionHandleFault(PMADDRESS_SPACE AddressSpace,
|
||||
MEMORY_AREA* MemoryArea,
|
||||
PVOID Address)
|
||||
{
|
||||
LARGE_INTEGER Offset;
|
||||
|
@ -150,16 +156,12 @@ NTSTATUS MmSectionHandleFault(MEMORY_AREA* MemoryArea,
|
|||
PMDL Mdl;
|
||||
PVOID Page;
|
||||
NTSTATUS Status;
|
||||
KIRQL oldIrql;
|
||||
|
||||
DPRINT("MmSectionHandleFault(MemoryArea %x, Address %x)\n",
|
||||
MemoryArea,Address);
|
||||
|
||||
KeAcquireSpinLock(&MiPageFaultLock, &oldIrql);
|
||||
|
||||
if (MmIsPagePresent(NULL, Address))
|
||||
{
|
||||
KeReleaseSpinLock(&MiPageFaultLock, oldIrql);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -198,25 +200,22 @@ NTSTATUS MmSectionHandleFault(MEMORY_AREA* MemoryArea,
|
|||
|
||||
Page = MmGetMdlPageAddress(Mdl, 0);
|
||||
|
||||
KeReleaseSpinLock(&MiPageFaultLock, oldIrql);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
|
||||
Status = IoPageRead(MemoryArea->Data.SectionData.Section->FileObject,
|
||||
Mdl,
|
||||
&Offset,
|
||||
&IoStatus,
|
||||
0 /* FIXME: UNKNOWN ARG */
|
||||
);
|
||||
&IoStatus);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
KeAcquireSpinLock(&MiPageFaultLock, &oldIrql);
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
|
||||
if (MmIsPagePresent(NULL, Address))
|
||||
{
|
||||
KeReleaseSpinLock(&MiPageFaultLock, oldIrql);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -225,8 +224,6 @@ NTSTATUS MmSectionHandleFault(MEMORY_AREA* MemoryArea,
|
|||
MemoryArea->Attributes,
|
||||
(ULONG)Page);
|
||||
|
||||
KeReleaseSpinLock(&MiPageFaultLock, oldIrql);
|
||||
|
||||
DPRINT("Returning from MmSectionHandleFault()\n");
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
|
@ -237,7 +234,7 @@ ULONG MmPageFault(ULONG cs, ULONG eip, ULONG error_code)
|
|||
* FUNCTION: Handle a page fault
|
||||
*/
|
||||
{
|
||||
KPROCESSOR_MODE FaultMode;
|
||||
PMADDRESS_SPACE AddressSpace;
|
||||
MEMORY_AREA* MemoryArea;
|
||||
NTSTATUS Status;
|
||||
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,
|
||||
// PsGetCurrentProcess(), error_code, cr3);
|
||||
|
||||
MmSetPageProtect(PsGetCurrentProcess(),
|
||||
(PVOID)PAGE_ROUND_DOWN(PsGetCurrentProcess()),
|
||||
0x7);
|
||||
// MmSetPageProtect(PsGetCurrentProcess(),
|
||||
// (PVOID)PAGE_ROUND_DOWN(PsGetCurrentProcess()),
|
||||
// 0x7);
|
||||
|
||||
cr2 = PAGE_ROUND_DOWN(cr2);
|
||||
|
||||
|
@ -290,17 +287,20 @@ ULONG MmPageFault(ULONG cs, ULONG eip, ULONG error_code)
|
|||
DbgPrint("%s:%d\n",__FILE__,__LINE__);
|
||||
return(0);
|
||||
}
|
||||
FaultMode = UserMode;
|
||||
AddressSpace = &PsGetCurrentProcess()->Pcb.AddressSpace;
|
||||
AddressSpace = MmGetKernelAddressSpace();
|
||||
}
|
||||
else
|
||||
{
|
||||
FaultMode = KernelMode;
|
||||
AddressSpace = &PsGetCurrentProcess()->Pcb.AddressSpace;
|
||||
}
|
||||
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(PsGetCurrentProcess(),(PVOID)cr2);
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace, (PVOID)cr2);
|
||||
if (MemoryArea == NULL)
|
||||
{
|
||||
DbgPrint("%s:%d\n",__FILE__,__LINE__);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -311,11 +311,15 @@ ULONG MmPageFault(ULONG cs, ULONG eip, ULONG error_code)
|
|||
break;
|
||||
|
||||
case MEMORY_AREA_SECTION_VIEW_COMMIT:
|
||||
Status = MmSectionHandleFault(MemoryArea, (PVOID)cr2);
|
||||
Status = MmSectionHandleFault(AddressSpace,
|
||||
MemoryArea,
|
||||
(PVOID)cr2);
|
||||
break;
|
||||
|
||||
case MEMORY_AREA_COMMIT:
|
||||
Status = MmCommitedSectionHandleFault(MemoryArea,(PVOID)cr2);
|
||||
Status = MmCommitedSectionHandleFault(AddressSpace,
|
||||
MemoryArea,
|
||||
(PVOID)cr2);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -323,6 +327,7 @@ ULONG MmPageFault(ULONG cs, ULONG eip, ULONG error_code)
|
|||
break;
|
||||
}
|
||||
DPRINT("Completed page fault handling\n");
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
return(NT_SUCCESS(Status));
|
||||
}
|
||||
|
||||
|
@ -368,10 +373,10 @@ void MmInitialize(boot_param* bp, ULONG LastKernelAddress)
|
|||
* Free physical memory not used by the kernel
|
||||
*/
|
||||
LastKernelAddress = (ULONG)MmInitializePageList(
|
||||
(PVOID)first_krnl_phys_addr,
|
||||
(PVOID)last_krnl_phys_addr,
|
||||
1024,
|
||||
PAGE_ROUND_UP(LastKernelAddress));
|
||||
(PVOID)first_krnl_phys_addr,
|
||||
(PVOID)last_krnl_phys_addr,
|
||||
1024,
|
||||
PAGE_ROUND_UP(LastKernelAddress));
|
||||
kernel_len = last_krnl_phys_addr - first_krnl_phys_addr;
|
||||
|
||||
/*
|
||||
|
@ -405,20 +410,20 @@ void MmInitialize(boot_param* bp, ULONG LastKernelAddress)
|
|||
MmInitVirtualMemory(bp);
|
||||
}
|
||||
|
||||
VOID
|
||||
MmInitSystem (ULONG Phase, boot_param* bp, ULONG LastKernelAddress)
|
||||
VOID MmInitSystem (ULONG Phase, boot_param* bp, ULONG LastKernelAddress)
|
||||
{
|
||||
if (Phase == 0)
|
||||
{
|
||||
/* Phase 0 Initialization */
|
||||
MmInitialize (bp, LastKernelAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Phase 1 Initialization */
|
||||
MmInitSectionImplementation();
|
||||
MmInitPagingFile();
|
||||
}
|
||||
if (Phase == 0)
|
||||
{
|
||||
/* Phase 0 Initialization */
|
||||
MmInitializeKernelAddressSpace();
|
||||
MmInitialize (bp, LastKernelAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Phase 1 Initialization */
|
||||
MmInitSectionImplementation();
|
||||
MmInitPagingFile();
|
||||
}
|
||||
}
|
||||
|
||||
/* 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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -43,44 +43,33 @@
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
PVOID
|
||||
STDCALL
|
||||
MmAllocateNonCachedMemory (
|
||||
IN ULONG NumberOfBytes
|
||||
)
|
||||
PVOID STDCALL MmAllocateNonCachedMemory(IN ULONG NumberOfBytes)
|
||||
{
|
||||
PVOID Result;
|
||||
MEMORY_AREA * marea;
|
||||
NTSTATUS Status;
|
||||
ULONG i;
|
||||
PVOID Result;
|
||||
MEMORY_AREA* marea;
|
||||
NTSTATUS Status;
|
||||
ULONG i;
|
||||
|
||||
Result = NULL;
|
||||
Status = MmCreateMemoryArea (
|
||||
KernelMode,
|
||||
PsGetCurrentProcess (),
|
||||
MEMORY_AREA_NO_CACHE,
|
||||
& Result,
|
||||
NumberOfBytes,
|
||||
0,
|
||||
& marea
|
||||
);
|
||||
if (STATUS_SUCCESS != Status)
|
||||
{
|
||||
return (NULL);
|
||||
Result = NULL;
|
||||
Status = MmCreateMemoryArea (NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
MEMORY_AREA_NO_CACHE,
|
||||
&Result,
|
||||
NumberOfBytes,
|
||||
0,
|
||||
&marea);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
for (i = 0; (i <= (NumberOfBytes / PAGESIZE)); i++)
|
||||
{
|
||||
MmSetPage (NULL,
|
||||
(Result + (i * PAGESIZE)),
|
||||
PAGE_READWRITE,
|
||||
(ULONG)MmAllocPage());
|
||||
}
|
||||
for ( i = 0;
|
||||
(i <= (NumberOfBytes / PAGESIZE));
|
||||
i ++
|
||||
)
|
||||
{
|
||||
MmSetPage (
|
||||
NULL,
|
||||
(Result + (i * PAGESIZE)),
|
||||
PAGE_READWRITE,
|
||||
(ULONG) MmAllocPage ()
|
||||
);
|
||||
}
|
||||
return ((PVOID) Result);
|
||||
return ((PVOID)Result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,19 +99,13 @@ MmAllocateNonCachedMemory (
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
STDCALL
|
||||
MmFreeNonCachedMemory (
|
||||
IN PVOID BaseAddress,
|
||||
IN ULONG NumberOfBytes
|
||||
)
|
||||
VOID STDCALL MmFreeNonCachedMemory (IN PVOID BaseAddress,
|
||||
IN ULONG NumberOfBytes)
|
||||
{
|
||||
MmFreeMemoryArea (
|
||||
PsGetCurrentProcess (),
|
||||
BaseAddress,
|
||||
NumberOfBytes,
|
||||
TRUE
|
||||
);
|
||||
MmFreeMemoryArea (&PsGetCurrentProcess()->Pcb.AddressSpace,
|
||||
BaseAddress,
|
||||
NumberOfBytes,
|
||||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -342,6 +342,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
|||
NTSTATUS Status;
|
||||
KIRQL oldIrql;
|
||||
ULONG ViewOffset;
|
||||
PMADDRESS_SPACE AddressSpace;
|
||||
|
||||
DPRINT("NtMapViewOfSection(Section:%08lx, Process:%08lx,\n"
|
||||
" Base:%08lx, ZeroBits:%08lx, CommitSize:%08lx,\n"
|
||||
|
@ -381,6 +382,8 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
|||
return Status;
|
||||
}
|
||||
|
||||
AddressSpace = &Process->Pcb.AddressSpace;
|
||||
|
||||
DPRINT("Process %x\n", Process);
|
||||
DPRINT("ViewSize %x\n",ViewSize);
|
||||
|
||||
|
@ -399,8 +402,9 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
|||
}
|
||||
|
||||
DPRINT("Creating memory area\n");
|
||||
Status = MmCreateMemoryArea(UserMode,
|
||||
Process,
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
Status = MmCreateMemoryArea(Process,
|
||||
&Process->Pcb.AddressSpace,
|
||||
MEMORY_AREA_SECTION_VIEW_COMMIT,
|
||||
BaseAddress,
|
||||
*ViewSize,
|
||||
|
@ -410,6 +414,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
|||
{
|
||||
DPRINT("NtMapViewOfSection() = %x\n",Status);
|
||||
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
ObDereferenceObject(Section);
|
||||
|
||||
|
@ -428,6 +433,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
|||
|
||||
|
||||
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
|
||||
DPRINT("NtMapViewOfSection() returning (Status %x)\n", STATUS_SUCCESS);
|
||||
|
@ -472,6 +478,7 @@ NTSTATUS STDCALL NtUnmapViewOfSection (HANDLE ProcessHandle,
|
|||
PEPROCESS Process;
|
||||
NTSTATUS Status;
|
||||
PMEMORY_AREA MemoryArea;
|
||||
PMADDRESS_SPACE AddressSpace;
|
||||
|
||||
DPRINT("NtUnmapViewOfSection(ProcessHandle %x, BaseAddress %x)\n",
|
||||
ProcessHandle, BaseAddress);
|
||||
|
@ -489,22 +496,28 @@ NTSTATUS STDCALL NtUnmapViewOfSection (HANDLE ProcessHandle,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
AddressSpace = &Process->Pcb.AddressSpace;
|
||||
|
||||
DPRINT("Opening memory area Process %x BaseAddress %x\n",
|
||||
Process, BaseAddress);
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(Process, BaseAddress);
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||
BaseAddress);
|
||||
if (MemoryArea == NULL)
|
||||
{
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
Status = MmUnmapViewOfSection(Process, MemoryArea);
|
||||
Status = MmUnmapViewOfSection(Process,
|
||||
MemoryArea);
|
||||
|
||||
Status = MmFreeMemoryArea(Process,
|
||||
Status = MmFreeMemoryArea(&Process->Pcb.AddressSpace,
|
||||
BaseAddress,
|
||||
0,
|
||||
TRUE);
|
||||
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
|
||||
return Status;
|
||||
|
@ -557,47 +570,40 @@ NTSTATUS STDCALL NtExtendSection(IN HANDLE SectionHandle,
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
PVOID
|
||||
STDCALL
|
||||
MmAllocateSection (
|
||||
IN ULONG Length
|
||||
)
|
||||
PVOID STDCALL MmAllocateSection (IN ULONG Length)
|
||||
{
|
||||
PVOID Result;
|
||||
MEMORY_AREA * marea;
|
||||
NTSTATUS Status;
|
||||
ULONG i;
|
||||
PVOID Result;
|
||||
MEMORY_AREA* marea;
|
||||
NTSTATUS Status;
|
||||
ULONG i;
|
||||
PMADDRESS_SPACE AddressSpace;
|
||||
|
||||
DPRINT("MmAllocateSection(Length %x)\n",Length);
|
||||
DPRINT("MmAllocateSection(Length %x)\n",Length);
|
||||
|
||||
Result = NULL;
|
||||
Status = MmCreateMemoryArea (
|
||||
KernelMode,
|
||||
PsGetCurrentProcess (),
|
||||
MEMORY_AREA_SYSTEM,
|
||||
& Result,
|
||||
Length,
|
||||
0,
|
||||
& marea
|
||||
);
|
||||
if (STATUS_SUCCESS != Status)
|
||||
{
|
||||
return (NULL);
|
||||
AddressSpace = MmGetKernelAddressSpace();
|
||||
Result = NULL;
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
Status = MmCreateMemoryArea (NULL,
|
||||
AddressSpace,
|
||||
MEMORY_AREA_SYSTEM,
|
||||
&Result,
|
||||
Length,
|
||||
0,
|
||||
&marea);
|
||||
if (STATUS_SUCCESS != Status)
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
DPRINT("Result %p\n",Result);
|
||||
for ( i = 0;
|
||||
(i <= (Length / PAGESIZE));
|
||||
i ++
|
||||
)
|
||||
{
|
||||
MmSetPage (
|
||||
NULL,
|
||||
(Result + (i * PAGESIZE)),
|
||||
PAGE_READWRITE,
|
||||
(ULONG) MmAllocPage ()
|
||||
);
|
||||
}
|
||||
return ((PVOID) Result);
|
||||
DPRINT("Result %p\n",Result);
|
||||
for (i = 0; (i <= (Length / PAGESIZE)); i++)
|
||||
{
|
||||
MmSetPage (NULL,
|
||||
(Result + (i * PAGESIZE)),
|
||||
PAGE_READWRITE,
|
||||
(ULONG) MmAllocPage ());
|
||||
}
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
return ((PVOID)Result);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,9 +59,12 @@ NTSTATUS MmReleaseMmInfo(PEPROCESS 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);
|
||||
|
||||
MmReleaseMemoryArea(Process, Current);
|
||||
|
@ -69,6 +72,8 @@ NTSTATUS MmReleaseMmInfo(PEPROCESS Process)
|
|||
|
||||
Mmi386ReleaseMmInfo(Process);
|
||||
|
||||
MmUnlockAddressSpace(&Process->Pcb.AddressSpace);
|
||||
|
||||
DPRINT("Finished MmReleaseMmInfo()\n");
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -91,14 +96,20 @@ BOOLEAN MmIsAddressValid(PVOID VirtualAddress)
|
|||
*/
|
||||
{
|
||||
MEMORY_AREA* MemoryArea;
|
||||
PMADDRESS_SPACE AddressSpace;
|
||||
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(PsGetCurrentProcess(),
|
||||
AddressSpace = &PsGetCurrentProcess()->Pcb.AddressSpace;
|
||||
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||
VirtualAddress);
|
||||
|
||||
if (MemoryArea == NULL)
|
||||
{
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
return(FALSE);
|
||||
}
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
@ -142,6 +153,7 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
|||
MEMORY_AREA* MemoryArea;
|
||||
ULONG Type;
|
||||
NTSTATUS Status;
|
||||
PMADDRESS_SPACE AddressSpace;
|
||||
|
||||
DPRINT("NtAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
|
||||
"ZeroBits %d, *RegionSize %x, AllocationType %x, Protect %x)\n",
|
||||
|
@ -169,9 +181,13 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
|||
Type = MEMORY_AREA_COMMIT;
|
||||
}
|
||||
|
||||
AddressSpace = &Process->Pcb.AddressSpace;
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
|
||||
if ((*BaseAddress) != 0)
|
||||
{
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(Process, *BaseAddress);
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(&Process->Pcb.AddressSpace,
|
||||
*BaseAddress);
|
||||
|
||||
if (MemoryArea != NULL)
|
||||
{
|
||||
|
@ -181,17 +197,20 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
|||
MemoryArea->Type = Type;
|
||||
MemoryArea->Attributes =Protect;
|
||||
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
MemoryArea = MmSplitMemoryArea(Process,
|
||||
&Process->Pcb.AddressSpace,
|
||||
MemoryArea,
|
||||
*BaseAddress,
|
||||
*RegionSize,
|
||||
Type,
|
||||
Protect);
|
||||
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -200,8 +219,8 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
|||
// FIXME RegionSize should be passed as pointer
|
||||
// dwelch: Why?
|
||||
|
||||
Status = MmCreateMemoryArea(UserMode,
|
||||
Process,
|
||||
Status = MmCreateMemoryArea(Process,
|
||||
&Process->Pcb.AddressSpace,
|
||||
Type,
|
||||
BaseAddress,
|
||||
*RegionSize,
|
||||
|
@ -211,11 +230,13 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
|||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
DPRINT("NtAllocateVirtualMemory() = %x\n",Status);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -260,6 +281,7 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
|||
MEMORY_AREA* MemoryArea;
|
||||
NTSTATUS Status;
|
||||
PEPROCESS Process;
|
||||
PMADDRESS_SPACE AddressSpace;
|
||||
|
||||
DPRINT("NtFreeVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
|
||||
"*RegionSize %x, FreeType %x)\n",ProcessHandle,*BaseAddress,
|
||||
|
@ -276,10 +298,15 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
|||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(Process,*BaseAddress);
|
||||
|
||||
AddressSpace = &Process->Pcb.AddressSpace;
|
||||
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||
*BaseAddress);
|
||||
if (MemoryArea == NULL)
|
||||
{
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
@ -289,27 +316,32 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
|||
case MEM_RELEASE:
|
||||
if (MemoryArea->BaseAddress != (*BaseAddress))
|
||||
{
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
MmFreeMemoryArea(PsGetCurrentProcess(),
|
||||
MmFreeMemoryArea(&Process->Pcb.AddressSpace,
|
||||
BaseAddress,
|
||||
0,
|
||||
TRUE);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
return(STATUS_SUCCESS);
|
||||
|
||||
case MEM_DECOMMIT:
|
||||
MmSplitMemoryArea(PsGetCurrentProcess(),
|
||||
MmSplitMemoryArea(Process,
|
||||
&Process->Pcb.AddressSpace,
|
||||
MemoryArea,
|
||||
*BaseAddress,
|
||||
*RegionSize,
|
||||
MEMORY_AREA_RESERVE,
|
||||
MemoryArea->Attributes);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
ObDereferenceObject(Process);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
return(STATUS_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
|
@ -334,7 +366,9 @@ VOID MmChangeAreaProtection(PEPROCESS Process,
|
|||
{
|
||||
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;
|
||||
PEPROCESS Process;
|
||||
NTSTATUS Status;
|
||||
PMADDRESS_SPACE AddressSpace;
|
||||
|
||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||
PROCESS_VM_OPERATION,
|
||||
|
@ -362,10 +397,15 @@ NTSTATUS STDCALL NtProtectVirtualMemory(IN HANDLE ProcessHandle,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(Process,BaseAddress);
|
||||
AddressSpace = &Process->Pcb.AddressSpace;
|
||||
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||
BaseAddress);
|
||||
if (MemoryArea == NULL)
|
||||
{
|
||||
DPRINT("NtProtectVirtualMemory() = %x\n",STATUS_UNSUCCESSFUL);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
@ -380,29 +420,29 @@ NTSTATUS STDCALL NtProtectVirtualMemory(IN HANDLE ProcessHandle,
|
|||
else
|
||||
{
|
||||
MemoryArea = MmSplitMemoryArea(Process,
|
||||
&Process->Pcb.AddressSpace,
|
||||
MemoryArea,
|
||||
BaseAddress,
|
||||
NumberOfBytesToProtect,
|
||||
MemoryArea->Type,
|
||||
NewAccessProtection);
|
||||
}
|
||||
MmChangeAreaProtection(Process,BaseAddress,NumberOfBytesToProtect,
|
||||
MmChangeAreaProtection(Process,
|
||||
BaseAddress,
|
||||
NumberOfBytesToProtect,
|
||||
NewAccessProtection);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtQueryVirtualMemory (
|
||||
IN HANDLE ProcessHandle,
|
||||
IN PVOID Address,
|
||||
IN CINT VirtualMemoryInformationClass,
|
||||
OUT PVOID VirtualMemoryInformation,
|
||||
IN ULONG Length,
|
||||
OUT PULONG ResultLength
|
||||
)
|
||||
NTSTATUS STDCALL NtQueryVirtualMemory (IN HANDLE ProcessHandle,
|
||||
IN PVOID Address,
|
||||
IN CINT VirtualMemoryInformationClass,
|
||||
OUT PVOID VirtualMemoryInformation,
|
||||
IN ULONG Length,
|
||||
OUT PULONG ResultLength)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PEPROCESS Process;
|
||||
|
@ -420,7 +460,8 @@ NtQueryVirtualMemory (
|
|||
{
|
||||
PMEMORY_BASIC_INFORMATION Info =
|
||||
(PMEMORY_BASIC_INFORMATION)VirtualMemoryInformation;
|
||||
|
||||
PMADDRESS_SPACE AddressSpace;
|
||||
|
||||
if (Length < sizeof(MEMORY_BASIC_INFORMATION))
|
||||
{
|
||||
ObDereferenceObject(Process);
|
||||
|
@ -445,13 +486,16 @@ NtQueryVirtualMemory (
|
|||
return(Status);
|
||||
}
|
||||
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(Process,
|
||||
AddressSpace = &Process->Pcb.AddressSpace;
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||
Address);
|
||||
|
||||
if (MemoryArea == NULL)
|
||||
{
|
||||
Info->State = MEM_FREE;
|
||||
DPRINT("Virtual memory at %p is free.\n", Address);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -470,7 +514,8 @@ NtQueryVirtualMemory (
|
|||
|
||||
DPRINT("BaseAddress %p, RegionSize %x State %x\n",
|
||||
Info->BaseAddress, Info->RegionSize, Info->State);
|
||||
|
||||
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
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
|
||||
;
|
||||
|
@ -228,7 +228,7 @@ IoInitializeTimer@12
|
|||
IoIsOperationSynchronous@4
|
||||
IoMakeAssociatedIrp@8
|
||||
IoOpenDeviceInstanceKey@20
|
||||
IoPageRead@20
|
||||
IoPageRead@16
|
||||
IoQueryDeviceDescription@32
|
||||
IoQueryDeviceEnumInfo@8
|
||||
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
|
||||
;
|
||||
|
@ -227,7 +227,7 @@ IoInitializeTimer=IoInitializeTimer@12
|
|||
IoIsOperationSynchronous=IoIsOperationSynchronous@4
|
||||
IoMakeAssociatedIrp=IoMakeAssociatedIrp@8
|
||||
IoOpenDeviceInstanceKey=IoOpenDeviceInstanceKey@20
|
||||
IoPageRead=IoPageRead@20
|
||||
IoPageRead=IoPageRead@16
|
||||
IoQueryDeviceDescription=IoQueryDeviceDescription@32
|
||||
IoQueryDeviceEnumInfo=IoQueryDeviceEnumInfo@8
|
||||
IoQueryFileInformation=IoQueryFileInformation@20
|
||||
|
|
|
@ -162,7 +162,7 @@ VOID PsInitProcessManagment(VOID)
|
|||
FALSE);
|
||||
KProcess = &SystemProcess->Pcb;
|
||||
|
||||
InitializeListHead(&(KProcess->MemoryAreaList));
|
||||
MmInitializeAddressSpace(&SystemProcess->Pcb.AddressSpace);
|
||||
ObCreateHandleTable(NULL,FALSE,SystemProcess);
|
||||
KProcess->PageTableDirectory = get_page_directory();
|
||||
SystemProcess->UniqueProcessId =
|
||||
|
@ -330,7 +330,7 @@ NTSTATUS STDCALL NtCreateProcess (OUT PHANDLE ProcessHandle,
|
|||
KProcess = &Process->Pcb;
|
||||
|
||||
KProcess->BasePriority = PROCESS_PRIO_NORMAL;
|
||||
InitializeListHead(&(KProcess->MemoryAreaList));
|
||||
MmInitializeAddressSpace(&KProcess->AddressSpace);
|
||||
Process->UniqueProcessId = InterlockedIncrement(&PiNextProcessUniqueId);
|
||||
Process->InheritedFromUniqueProcessId = ParentProcess->UniqueProcessId;
|
||||
ObCreateHandleTable(ParentProcess,
|
||||
|
|
Loading…
Reference in a new issue