mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:12:58 +00:00
Section and general memory manager enhancements including COW
svn path=/trunk/; revision=1617
This commit is contained in:
parent
29c4727f7a
commit
9359db14a0
41 changed files with 2057 additions and 1262 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.14 2001/01/16 09:55:02 dwelch Exp $
|
/* $Id: create.c,v 1.15 2001/02/10 22:51:11 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -446,6 +446,10 @@ VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
FileObject->FsContext = (PVOID)&Fcb->RFCB;
|
FileObject->FsContext = (PVOID)&Fcb->RFCB;
|
||||||
newCCB = ExAllocatePool (NonPagedPool, sizeof (VFATCCB));
|
newCCB = ExAllocatePool (NonPagedPool, sizeof (VFATCCB));
|
||||||
memset (newCCB, 0, sizeof (VFATCCB));
|
memset (newCCB, 0, sizeof (VFATCCB));
|
||||||
|
FileObject->Flags = FileObject->Flags |
|
||||||
|
FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
|
||||||
|
FileObject->SectionObjectPointers =
|
||||||
|
&Fcb->SectionObjectPointers;
|
||||||
FileObject->FsContext2 = newCCB;
|
FileObject->FsContext2 = newCCB;
|
||||||
newCCB->pFcb = Fcb;
|
newCCB->pFcb = Fcb;
|
||||||
newCCB->PtrFileObject = FileObject;
|
newCCB->PtrFileObject = FileObject;
|
||||||
|
@ -563,6 +567,9 @@ VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
|
|
||||||
FileObject->Flags = FileObject->Flags |
|
FileObject->Flags = FileObject->Flags |
|
||||||
FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
|
FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
|
||||||
|
FileObject->SectionObjectPointers = &ParentFcb->SectionObjectPointers;
|
||||||
|
memset(FileObject->SectionObjectPointers, 0,
|
||||||
|
sizeof(SECTION_OBJECT_POINTERS));
|
||||||
FileObject->FsContext = (PVOID)&ParentFcb->RFCB;
|
FileObject->FsContext = (PVOID)&ParentFcb->RFCB;
|
||||||
newCCB = ExAllocatePool (NonPagedPool, sizeof (VFATCCB));
|
newCCB = ExAllocatePool (NonPagedPool, sizeof (VFATCCB));
|
||||||
memset (newCCB, 0, sizeof (VFATCCB));
|
memset (newCCB, 0, sizeof (VFATCCB));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: vfat.h,v 1.24 2001/01/16 09:55:02 dwelch Exp $ */
|
/* $Id: vfat.h,v 1.25 2001/02/10 22:51:11 dwelch Exp $ */
|
||||||
|
|
||||||
#include <ddk/ntifs.h>
|
#include <ddk/ntifs.h>
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ typedef struct
|
||||||
typedef struct _VFATFCB
|
typedef struct _VFATFCB
|
||||||
{
|
{
|
||||||
REACTOS_COMMON_FCB_HEADER RFCB;
|
REACTOS_COMMON_FCB_HEADER RFCB;
|
||||||
|
SECTION_OBJECT_POINTERS SectionObjectPointers;
|
||||||
FATDirEntry entry;
|
FATDirEntry entry;
|
||||||
/* point on filename (250 chars max) in PathName */
|
/* point on filename (250 chars max) in PathName */
|
||||||
WCHAR *ObjectName;
|
WCHAR *ObjectName;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#ifndef _NTOS_CCFUNCS_H
|
#ifndef _NTOS_CCFUNCS_H
|
||||||
#define _NTOS_CCFUNCS_H
|
#define _NTOS_CCFUNCS_H
|
||||||
/* $Id: ccfuncs.h,v 1.5 2000/06/12 14:51:26 ekohl Exp $ */
|
/* $Id: ccfuncs.h,v 1.6 2001/02/10 22:51:07 dwelch Exp $ */
|
||||||
|
|
||||||
/* exported variables */
|
/* exported variables */
|
||||||
/*
|
/*
|
||||||
|
@ -325,4 +325,4 @@ CcZeroData (
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -81,6 +81,6 @@ typedef struct _REACTOS_COMMON_FCB_HEADER
|
||||||
LARGE_INTEGER AllocationSize;
|
LARGE_INTEGER AllocationSize;
|
||||||
LARGE_INTEGER FileSize;
|
LARGE_INTEGER FileSize;
|
||||||
LARGE_INTEGER ValidDataLength;
|
LARGE_INTEGER ValidDataLength;
|
||||||
} REACTOS_COMMON_FCB_HEADER;
|
} REACTOS_COMMON_FCB_HEADER, *PREACTOS_COMMON_FCB_HEADER;
|
||||||
|
|
||||||
#endif /* __INCLUDE_DDK_CCTYPES_H */
|
#endif /* __INCLUDE_DDK_CCTYPES_H */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: iotypes.h,v 1.22 2001/01/08 02:14:05 dwelch Exp $
|
/* $Id: iotypes.h,v 1.23 2001/02/10 22:51:07 dwelch Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -714,4 +714,4 @@ VOID
|
||||||
);
|
);
|
||||||
#endif // (_WIN32_WINNT >= 0x0400)
|
#endif // (_WIN32_WINNT >= 0x0400)
|
||||||
|
|
||||||
#endif __INCLUDE_DDK_IOTYPES_H
|
#endif /* __INCLUDE_DDK_IOTYPES_H */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: rtl.h,v 1.46 2000/12/29 13:47:30 ekohl Exp $
|
/* $Id: rtl.h,v 1.47 2001/02/10 22:51:07 dwelch Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -875,13 +875,8 @@ RtlExtendedMagicDivide (
|
||||||
CCHAR ShiftCount
|
CCHAR ShiftCount
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
RtlFillMemory (PVOID Destination, ULONG Length, UCHAR Fill);
|
||||||
RtlFillMemory (
|
|
||||||
PVOID Destination,
|
|
||||||
ULONG Length,
|
|
||||||
UCHAR Fill
|
|
||||||
);
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
STDCALL
|
||||||
|
@ -1299,13 +1294,8 @@ RtlLookupAtomInAtomTable (
|
||||||
OUT PRTL_ATOM Atom
|
OUT PRTL_ATOM Atom
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
RtlMoveMemory (PVOID Destination, CONST VOID* Source, ULONG Length);
|
||||||
RtlMoveMemory (
|
|
||||||
PVOID Destination,
|
|
||||||
CONST VOID * Source,
|
|
||||||
ULONG Length
|
|
||||||
);
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
|
@ -1787,12 +1777,8 @@ RtlWriteRegistryValue (
|
||||||
ULONG ValueLength
|
ULONG ValueLength
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
RtlZeroMemory (PVOID Destination, ULONG Length);
|
||||||
RtlZeroMemory (
|
|
||||||
PVOID Destination,
|
|
||||||
ULONG Length
|
|
||||||
);
|
|
||||||
|
|
||||||
ULONG
|
ULONG
|
||||||
STDCALL
|
STDCALL
|
||||||
|
|
|
@ -1257,4 +1257,34 @@ struct _LPC_PORT_BASIC_INFORMATION
|
||||||
|
|
||||||
} LPC_PORT_BASIC_INFORMATION, * PLPC_PORT_BASIC_INFORMATION;
|
} LPC_PORT_BASIC_INFORMATION, * PLPC_PORT_BASIC_INFORMATION;
|
||||||
|
|
||||||
|
typedef struct _SECTION_BASIC_INFORMATION
|
||||||
|
{
|
||||||
|
PVOID BaseAddress;
|
||||||
|
ULONG Attributes;
|
||||||
|
LARGE_INTEGER Size;
|
||||||
|
} SECTION_BASIC_INFORMATION, *PSECTION_BASIC_INFORMATION;
|
||||||
|
|
||||||
|
typedef struct _SECTION_IMAGE_INFORMATION
|
||||||
|
{
|
||||||
|
PVOID EntryPoint;
|
||||||
|
ULONG Unknown1;
|
||||||
|
ULONG StackReserve;
|
||||||
|
ULONG StackCommit;
|
||||||
|
ULONG Subsystem;
|
||||||
|
USHORT MinorSubsystemVersion;
|
||||||
|
USHORT MajorSubsystemVersion;
|
||||||
|
ULONG Unknown2;
|
||||||
|
ULONG Characteristics;
|
||||||
|
USHORT ImageNumber;
|
||||||
|
BOOLEAN Executable;
|
||||||
|
UCHAR Unknown3;
|
||||||
|
ULONG Unknown4[3];
|
||||||
|
} SECTION_IMAGE_INFORMATION, *PSECTION_IMAGE_INFORMATION;
|
||||||
|
|
||||||
|
typedef enum _SECTION_INFORMATION_CLASS
|
||||||
|
{
|
||||||
|
SectionBasicInformation,
|
||||||
|
SectionImageInformation,
|
||||||
|
} SECTION_INFORMATION_CLASS;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: rtl.h,v 1.21 2000/12/29 13:47:43 ekohl Exp $
|
/* $Id: rtl.h,v 1.22 2001/02/10 22:51:07 dwelch Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
||||||
#define __INCLUDE_NTDLL_RTL_H
|
#define __INCLUDE_NTDLL_RTL_H
|
||||||
|
|
||||||
#include <napi/teb.h>
|
#include <napi/teb.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
typedef struct _CRITICAL_SECTION_DEBUG {
|
typedef struct _CRITICAL_SECTION_DEBUG {
|
||||||
WORD Type;
|
WORD Type;
|
||||||
|
@ -27,27 +28,6 @@ typedef struct _CRITICAL_SECTION {
|
||||||
DWORD Reserved;
|
DWORD Reserved;
|
||||||
} CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION;
|
} CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _SECTION_IMAGE_INFORMATION
|
|
||||||
{
|
|
||||||
PVOID ProcessEntryPoint;
|
|
||||||
ULONG StackZero;
|
|
||||||
ULONG StackReserve;
|
|
||||||
ULONG StackCommit;
|
|
||||||
ULONG SubsystemType;
|
|
||||||
USHORT MinorImageVersion;
|
|
||||||
USHORT MajorImageVersion;
|
|
||||||
ULONG u4;
|
|
||||||
ULONG Characteristics;
|
|
||||||
USHORT Machine;
|
|
||||||
BOOLEAN Executable;
|
|
||||||
USHORT u6;
|
|
||||||
ULONG u7;
|
|
||||||
ULONG u8;
|
|
||||||
ULONG u9;
|
|
||||||
}SECTION_IMAGE_INFORMATION, *PSECTION_IMAGE_INFORMATION;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _RTL_PROCESS_INFO
|
typedef struct _RTL_PROCESS_INFO
|
||||||
{
|
{
|
||||||
ULONG Size;
|
ULONG Size;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: rtl.c,v 1.3 2000/07/01 17:07:00 ea Exp $
|
/* $Id: rtl.c,v 1.4 2001/02/10 22:51:07 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -11,90 +11,80 @@
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
typedef DWORD ( *RtlFillMemoryType) (DWORD Unknown0, DWORD Unknown1, DWORD Unknown2 );
|
typedef DWORD
|
||||||
|
(*RtlFillMemoryType) (PVOID Destination, ULONG Length, UCHAR Fill);
|
||||||
|
|
||||||
#undef FillMemory
|
#undef FillMemory
|
||||||
DWORD
|
VOID STDCALL
|
||||||
STDCALL
|
RtlFillMemory (PVOID Destination, ULONG Length, UCHAR Fill)
|
||||||
RtlFillMemory (
|
|
||||||
DWORD Unknown0,
|
|
||||||
DWORD Unknown1,
|
|
||||||
DWORD Unknown2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
HINSTANCE hModule;
|
HINSTANCE hModule;
|
||||||
RtlFillMemoryType FillMemory;
|
RtlFillMemoryType FillMemory;
|
||||||
hModule = LoadLibraryA("ntdll.dll");
|
|
||||||
if ( hModule == NULL )
|
|
||||||
return -1;
|
|
||||||
FillMemory = (RtlFillMemoryType)GetProcAddress(hModule, "RtlFillMemory");
|
|
||||||
if ( FillMemory == NULL )
|
|
||||||
return -1;
|
|
||||||
return FillMemory(Unknown0, Unknown1, Unknown2);
|
|
||||||
|
|
||||||
|
|
||||||
|
hModule = LoadLibraryA("ntdll.dll");
|
||||||
|
if (hModule == NULL)
|
||||||
|
return;
|
||||||
|
FillMemory = (RtlFillMemoryType)GetProcAddress(hModule, "RtlFillMemory");
|
||||||
|
if ( FillMemory == NULL )
|
||||||
|
return;
|
||||||
|
FillMemory(Destination, Length, Fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef DWORD ( *RtlMoveMemoryType) (DWORD Unknown0, DWORD Unknown1, DWORD Unknown2 );
|
typedef DWORD
|
||||||
|
(*RtlMoveMemoryType) (PVOID Destination, CONST VOID* Source, ULONG Length);
|
||||||
#undef MoveMemory
|
#undef MoveMemory
|
||||||
DWORD
|
VOID STDCALL
|
||||||
STDCALL
|
RtlMoveMemory (PVOID Destination, CONST VOID* Source, ULONG Length)
|
||||||
RtlMoveMemory (
|
|
||||||
DWORD Unknown0,
|
|
||||||
DWORD Unknown1,
|
|
||||||
DWORD Unknown2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
HINSTANCE hModule;
|
HINSTANCE hModule;
|
||||||
RtlMoveMemoryType MoveMemory;
|
RtlMoveMemoryType MoveMemory;
|
||||||
hModule = LoadLibraryA("ntdll.dll");
|
|
||||||
if ( hModule == NULL )
|
hModule = LoadLibraryA("ntdll.dll");
|
||||||
return -1;
|
if (hModule == NULL)
|
||||||
MoveMemory = (RtlMoveMemoryType)GetProcAddress(hModule, "RtlMoveMemory");
|
return;
|
||||||
if ( MoveMemory == NULL )
|
MoveMemory = (RtlMoveMemoryType)GetProcAddress(hModule, "RtlMoveMemory");
|
||||||
return -1;
|
if (MoveMemory == NULL)
|
||||||
return MoveMemory(Unknown0, Unknown1, Unknown2);
|
return;
|
||||||
|
MoveMemory(Destination, Source, Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef DWORD ( *RtlZeroMemoryType) (DWORD Unknown0, DWORD Unknown1 );
|
typedef DWORD ( *RtlZeroMemoryType) (PVOID Destination, ULONG Length);
|
||||||
#undef ZeroMemory
|
#undef ZeroMemory
|
||||||
DWORD
|
VOID STDCALL
|
||||||
STDCALL
|
RtlZeroMemory (PVOID Destination, ULONG Length)
|
||||||
RtlZeroMemory (
|
|
||||||
DWORD Unknown0,
|
|
||||||
DWORD Unknown1
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
HINSTANCE hModule;
|
HINSTANCE hModule;
|
||||||
RtlZeroMemoryType ZeroMemory;
|
RtlZeroMemoryType ZeroMemory;
|
||||||
hModule = LoadLibraryA("ntdll.dll");
|
|
||||||
if ( hModule == NULL )
|
hModule = LoadLibraryA("ntdll.dll");
|
||||||
return -1;
|
if (hModule == NULL)
|
||||||
ZeroMemory = (RtlZeroMemoryType)GetProcAddress(hModule, "RtlZeroMemory");
|
return;
|
||||||
if ( ZeroMemory == NULL )
|
ZeroMemory = (RtlZeroMemoryType)GetProcAddress(hModule, "RtlZeroMemory");
|
||||||
return -1;
|
if (ZeroMemory == NULL)
|
||||||
return ZeroMemory(Unknown0, Unknown1);
|
return;
|
||||||
|
ZeroMemory(Destination, Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef DWORD ( *RtlUnwindType) (DWORD Unknown0, DWORD Unknown1, DWORD Unknown2, DWORD Unknown3 );
|
typedef DWORD ( *RtlUnwindType) (DWORD Unknown0, DWORD Unknown1, DWORD Unknown2, DWORD Unknown3 );
|
||||||
#undef Unwind
|
#undef Unwind
|
||||||
DWORD
|
VOID
|
||||||
STDCALL
|
STDCALL
|
||||||
RtlUnwind (
|
RtlUnwind (
|
||||||
DWORD Unknown0,
|
ULONG Unknown0,
|
||||||
DWORD Unknown1,
|
ULONG Unknown1,
|
||||||
DWORD Unknown2,
|
ULONG Unknown2,
|
||||||
DWORD Unknown3
|
ULONG Unknown3
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
HINSTANCE hModule;
|
HINSTANCE hModule;
|
||||||
RtlUnwindType Unwind;
|
RtlUnwindType Unwind;
|
||||||
hModule = LoadLibraryA("ntdll.dll");
|
hModule = LoadLibraryA("ntdll.dll");
|
||||||
if ( hModule == NULL )
|
if ( hModule == NULL )
|
||||||
return -1;
|
return;
|
||||||
Unwind = (RtlUnwindType)GetProcAddress(hModule, "RtlUnwind");
|
Unwind = (RtlUnwindType)GetProcAddress(hModule, "RtlUnwind");
|
||||||
if ( Unwind == NULL )
|
if ( Unwind == NULL )
|
||||||
return -1;
|
return;
|
||||||
return Unwind(Unknown0, Unknown1, Unknown2, Unknown3);
|
Unwind(Unknown0, Unknown1, Unknown2, Unknown3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.34 2001/02/10 22:30:21 ekohl Exp $
|
/* $Id: create.c,v 1.35 2001/02/10 22:51:08 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -383,6 +383,8 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
LPTHREAD_START_ROUTINE lpStartAddress = NULL;
|
LPTHREAD_START_ROUTINE lpStartAddress = NULL;
|
||||||
WCHAR TempCommandLine[256];
|
WCHAR TempCommandLine[256];
|
||||||
|
WCHAR ImagePathName[256];
|
||||||
|
UNICODE_STRING ImagePathName_U;
|
||||||
PROCESS_BASIC_INFORMATION ProcessBasicInfo;
|
PROCESS_BASIC_INFORMATION ProcessBasicInfo;
|
||||||
ULONG retlen;
|
ULONG retlen;
|
||||||
PRTL_USER_PROCESS_PARAMETERS Ppb;
|
PRTL_USER_PROCESS_PARAMETERS Ppb;
|
||||||
|
@ -433,6 +435,8 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
|
||||||
256 * sizeof(WCHAR),
|
256 * sizeof(WCHAR),
|
||||||
TempCommandLine,
|
TempCommandLine,
|
||||||
NULL);
|
NULL);
|
||||||
|
wcscpy(ImagePathName, TempCommandLine);
|
||||||
|
RtlInitUnicodeString(&ImagePathName_U, ImagePathName);
|
||||||
|
|
||||||
if (lpCommandLine != NULL)
|
if (lpCommandLine != NULL)
|
||||||
{
|
{
|
||||||
|
@ -453,7 +457,7 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
|
||||||
DPRINT("CommandLine_U %S\n", CommandLine_U.Buffer);
|
DPRINT("CommandLine_U %S\n", CommandLine_U.Buffer);
|
||||||
|
|
||||||
RtlCreateProcessParameters(&Ppb,
|
RtlCreateProcessParameters(&Ppb,
|
||||||
&CommandLine_U,
|
&ImagePathName_U,
|
||||||
NULL,
|
NULL,
|
||||||
(lpCurrentDirectory == NULL) ? NULL : &CurrentDirectoryW,
|
(lpCurrentDirectory == NULL) ? NULL : &CurrentDirectoryW,
|
||||||
&CommandLine_U,
|
&CommandLine_U,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: utils.c,v 1.40 2001/02/10 22:23:30 ekohl Exp $
|
/* $Id: utils.c,v 1.41 2001/02/10 22:51:08 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -155,288 +155,269 @@ LdrLoadDll (IN PWSTR SearchPath OPTIONAL,
|
||||||
IN PUNICODE_STRING Name,
|
IN PUNICODE_STRING Name,
|
||||||
OUT PVOID *BaseAddress OPTIONAL)
|
OUT PVOID *BaseAddress OPTIONAL)
|
||||||
{
|
{
|
||||||
WCHAR SearchPathBuffer[MAX_PATH];
|
WCHAR SearchPathBuffer[MAX_PATH];
|
||||||
WCHAR FullDosName[MAX_PATH];
|
WCHAR FullDosName[MAX_PATH];
|
||||||
UNICODE_STRING AdjustedName;
|
UNICODE_STRING AdjustedName;
|
||||||
UNICODE_STRING FullNtFileName;
|
UNICODE_STRING FullNtFileName;
|
||||||
OBJECT_ATTRIBUTES FileObjectAttributes;
|
OBJECT_ATTRIBUTES FileObjectAttributes;
|
||||||
char BlockBuffer [1024];
|
char BlockBuffer [1024];
|
||||||
PIMAGE_DOS_HEADER DosHeader;
|
PIMAGE_DOS_HEADER DosHeader;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PIMAGE_NT_HEADERS NTHeaders;
|
PIMAGE_NT_HEADERS NTHeaders;
|
||||||
ULONG ImageSize;
|
ULONG ImageSize;
|
||||||
ULONG InitialViewSize;
|
ULONG InitialViewSize;
|
||||||
PVOID ImageBase;
|
PVOID ImageBase;
|
||||||
HANDLE FileHandle;
|
HANDLE FileHandle;
|
||||||
HANDLE SectionHandle;
|
HANDLE SectionHandle;
|
||||||
PDLLMAIN_FUNC Entrypoint = NULL;
|
PDLLMAIN_FUNC Entrypoint = NULL;
|
||||||
PLDR_MODULE Module;
|
PLDR_MODULE Module;
|
||||||
|
|
||||||
|
if (Name == NULL)
|
||||||
|
{
|
||||||
|
*BaseAddress = NtCurrentPeb()->ImageBaseAddress;
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
*BaseAddress = NULL;
|
||||||
|
|
||||||
|
DPRINT("LdrLoadDll(Name \"%wZ\" BaseAddress %x)\n",
|
||||||
|
Name, BaseAddress);
|
||||||
|
|
||||||
|
/* adjust the full dll name */
|
||||||
|
LdrAdjustDllName (&AdjustedName,
|
||||||
|
Name,
|
||||||
|
FALSE);
|
||||||
|
DPRINT("AdjustedName: %wZ\n", &AdjustedName);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test if dll is already loaded.
|
||||||
|
*/
|
||||||
|
if (LdrFindDll(&Module, &AdjustedName) == STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
DPRINT("DLL %wZ already loaded.\n", &AdjustedName);
|
||||||
|
if (Module->LoadCount != -1)
|
||||||
|
Module->LoadCount++;
|
||||||
|
*BaseAddress = Module->BaseAddress;
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
DPRINT("Loading \"%wZ\"\n", Name);
|
||||||
|
|
||||||
|
if (SearchPath == NULL)
|
||||||
|
{
|
||||||
|
PKUSER_SHARED_DATA SharedUserData =
|
||||||
|
(PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE;
|
||||||
|
|
||||||
|
SearchPath = SearchPathBuffer;
|
||||||
|
wcscpy (SearchPathBuffer, SharedUserData->NtSystemRoot);
|
||||||
|
wcscat (SearchPathBuffer, L"\\system32;");
|
||||||
|
wcscat (SearchPathBuffer, SharedUserData->NtSystemRoot);
|
||||||
|
}
|
||||||
|
|
||||||
if ( Name == NULL )
|
DPRINT("SearchPath %S\n", SearchPath);
|
||||||
{
|
|
||||||
*BaseAddress = NtCurrentPeb()->ImageBaseAddress;
|
if (RtlDosSearchPath_U (SearchPath,
|
||||||
return STATUS_SUCCESS;
|
AdjustedName.Buffer,
|
||||||
}
|
NULL,
|
||||||
|
MAX_PATH,
|
||||||
*BaseAddress = NULL;
|
FullDosName,
|
||||||
|
NULL) == 0)
|
||||||
DPRINT("LdrLoadDll(Name \"%wZ\" BaseAddress %x)\n",
|
return STATUS_DLL_NOT_FOUND;
|
||||||
Name, BaseAddress);
|
|
||||||
|
DPRINT("FullDosName %S\n", FullDosName);
|
||||||
/* adjust the full dll name */
|
|
||||||
LdrAdjustDllName (&AdjustedName,
|
RtlFreeUnicodeString (&AdjustedName);
|
||||||
Name,
|
|
||||||
FALSE);
|
if (!RtlDosPathNameToNtPathName_U (FullDosName,
|
||||||
DPRINT("AdjustedName: %wZ\n", &AdjustedName);
|
&FullNtFileName,
|
||||||
|
NULL,
|
||||||
/*
|
NULL))
|
||||||
* Test if dll is already loaded.
|
return STATUS_DLL_NOT_FOUND;
|
||||||
*/
|
|
||||||
if (LdrFindDll(&Module, &AdjustedName) == STATUS_SUCCESS)
|
DPRINT("FullNtFileName %wZ\n", &FullNtFileName);
|
||||||
{
|
|
||||||
DPRINT("DLL %wZ already loaded.\n", &AdjustedName);
|
InitializeObjectAttributes(&FileObjectAttributes,
|
||||||
if (Module->LoadCount != -1)
|
&FullNtFileName,
|
||||||
Module->LoadCount++;
|
0,
|
||||||
*BaseAddress = Module->BaseAddress;
|
NULL,
|
||||||
return STATUS_SUCCESS;
|
NULL);
|
||||||
}
|
|
||||||
DPRINT("Loading \"%wZ\"\n", Name);
|
DPRINT("Opening dll \"%wZ\"\n", &FullNtFileName);
|
||||||
|
|
||||||
if (SearchPath == NULL)
|
Status = ZwOpenFile(&FileHandle,
|
||||||
{
|
FILE_ALL_ACCESS,
|
||||||
PKUSER_SHARED_DATA SharedUserData =
|
&FileObjectAttributes,
|
||||||
(PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE;
|
NULL,
|
||||||
|
0,
|
||||||
SearchPath = SearchPathBuffer;
|
0);
|
||||||
wcscpy (SearchPathBuffer, SharedUserData->NtSystemRoot);
|
if (!NT_SUCCESS(Status))
|
||||||
wcscat (SearchPathBuffer, L"\\system32;");
|
{
|
||||||
wcscat (SearchPathBuffer, SharedUserData->NtSystemRoot);
|
DbgPrint("Dll open of %wZ failed: Status = 0x%08x\n",
|
||||||
}
|
&FullNtFileName, Status);
|
||||||
|
RtlFreeUnicodeString (&FullNtFileName);
|
||||||
DPRINT("SearchPath %S\n", SearchPath);
|
return Status;
|
||||||
|
}
|
||||||
if (RtlDosSearchPath_U (SearchPath,
|
RtlFreeUnicodeString (&FullNtFileName);
|
||||||
AdjustedName.Buffer,
|
|
||||||
NULL,
|
Status = ZwReadFile(FileHandle,
|
||||||
MAX_PATH,
|
0,
|
||||||
FullDosName,
|
0,
|
||||||
NULL) == 0)
|
0,
|
||||||
return STATUS_DLL_NOT_FOUND;
|
0,
|
||||||
|
BlockBuffer,
|
||||||
DPRINT("FullDosName %S\n", FullDosName);
|
sizeof(BlockBuffer),
|
||||||
|
0,
|
||||||
RtlFreeUnicodeString (&AdjustedName);
|
0);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
if (!RtlDosPathNameToNtPathName_U (FullDosName,
|
{
|
||||||
&FullNtFileName,
|
DPRINT("Dll header read failed: Status = 0x%08x\n", Status);
|
||||||
NULL,
|
ZwClose(FileHandle);
|
||||||
NULL))
|
return Status;
|
||||||
return STATUS_DLL_NOT_FOUND;
|
}
|
||||||
|
/*
|
||||||
DPRINT("FullNtFileName %wZ\n", &FullNtFileName);
|
* Overlay DOS and NT headers structures to the
|
||||||
|
* buffer with DLL's header raw data.
|
||||||
InitializeObjectAttributes(
|
*/
|
||||||
& FileObjectAttributes,
|
DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer;
|
||||||
& FullNtFileName,
|
NTHeaders = (PIMAGE_NT_HEADERS) (BlockBuffer + DosHeader->e_lfanew);
|
||||||
0,
|
/*
|
||||||
NULL,
|
* Check it is a PE image file.
|
||||||
NULL
|
*/
|
||||||
);
|
if ((DosHeader->e_magic != IMAGE_DOS_MAGIC)
|
||||||
|
|| (DosHeader->e_lfanew == 0L)
|
||||||
DPRINT("Opening dll \"%wZ\"\n", &FullNtFileName);
|
|| (*(PULONG)(NTHeaders) != IMAGE_PE_MAGIC))
|
||||||
|
{
|
||||||
Status = ZwOpenFile(
|
DPRINT("NTDLL format invalid\n");
|
||||||
& FileHandle,
|
ZwClose(FileHandle);
|
||||||
FILE_ALL_ACCESS,
|
|
||||||
& FileObjectAttributes,
|
return STATUS_UNSUCCESSFUL;
|
||||||
NULL,
|
}
|
||||||
0,
|
|
||||||
0
|
ImageBase = (PVOID) NTHeaders->OptionalHeader.ImageBase;
|
||||||
);
|
ImageSize = NTHeaders->OptionalHeader.SizeOfImage;
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
DPRINT("ImageBase 0x%08x\n", ImageBase);
|
||||||
DbgPrint("Dll open of %wZ failed: Status = 0x%08x\n",
|
|
||||||
&FullNtFileName, Status);
|
|
||||||
RtlFreeUnicodeString (&FullNtFileName);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
RtlFreeUnicodeString (&FullNtFileName);
|
|
||||||
|
|
||||||
Status = ZwReadFile(
|
|
||||||
FileHandle,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
BlockBuffer,
|
|
||||||
sizeof BlockBuffer,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT("Dll header read failed: Status = 0x%08x\n", Status);
|
|
||||||
ZwClose(FileHandle);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Overlay DOS and NT headers structures to the
|
|
||||||
* buffer with DLL's header raw data.
|
|
||||||
*/
|
|
||||||
DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer;
|
|
||||||
NTHeaders = (PIMAGE_NT_HEADERS) (BlockBuffer + DosHeader->e_lfanew);
|
|
||||||
/*
|
|
||||||
* Check it is a PE image file.
|
|
||||||
*/
|
|
||||||
if ((DosHeader->e_magic != IMAGE_DOS_MAGIC)
|
|
||||||
|| (DosHeader->e_lfanew == 0L)
|
|
||||||
|| (*(PULONG)(NTHeaders) != IMAGE_PE_MAGIC))
|
|
||||||
{
|
|
||||||
DPRINT("NTDLL format invalid\n");
|
|
||||||
ZwClose(FileHandle);
|
|
||||||
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageBase = (PVOID) NTHeaders->OptionalHeader.ImageBase;
|
|
||||||
ImageSize = NTHeaders->OptionalHeader.SizeOfImage;
|
|
||||||
|
|
||||||
DPRINT("ImageBase 0x%08x\n", ImageBase);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a section for dll.
|
* Create a section for dll.
|
||||||
*/
|
*/
|
||||||
Status = ZwCreateSection(
|
Status = ZwCreateSection(&SectionHandle,
|
||||||
& SectionHandle,
|
SECTION_ALL_ACCESS,
|
||||||
SECTION_ALL_ACCESS,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
PAGE_READWRITE,
|
||||||
PAGE_READWRITE,
|
SEC_COMMIT | SEC_IMAGE,
|
||||||
MEM_COMMIT,
|
FileHandle);
|
||||||
FileHandle
|
if (!NT_SUCCESS(Status))
|
||||||
);
|
{
|
||||||
if (!NT_SUCCESS(Status))
|
DPRINT("NTDLL create section failed: Status = 0x%08x\n", Status);
|
||||||
{
|
ZwClose(FileHandle);
|
||||||
DPRINT("NTDLL create section failed: Status = 0x%08x\n", Status);
|
return Status;
|
||||||
ZwClose(FileHandle);
|
}
|
||||||
return Status;
|
|
||||||
}
|
/*
|
||||||
|
* Map the dll into the process.
|
||||||
/*
|
*/
|
||||||
* Map the dll into the process.
|
InitialViewSize = 0;
|
||||||
*/
|
ImageBase = 0;
|
||||||
InitialViewSize =
|
Status = ZwMapViewOfSection(SectionHandle,
|
||||||
DosHeader->e_lfanew
|
NtCurrentProcess(),
|
||||||
+ sizeof (IMAGE_NT_HEADERS)
|
&ImageBase,
|
||||||
+ sizeof (IMAGE_SECTION_HEADER) * NTHeaders->FileHeader.NumberOfSections;
|
0,
|
||||||
Status = ZwMapViewOfSection(
|
InitialViewSize,
|
||||||
SectionHandle,
|
NULL,
|
||||||
NtCurrentProcess(),
|
&InitialViewSize,
|
||||||
(PVOID*)&ImageBase,
|
0,
|
||||||
0,
|
MEM_COMMIT,
|
||||||
InitialViewSize,
|
PAGE_READWRITE);
|
||||||
NULL,
|
if (!NT_SUCCESS(Status))
|
||||||
&InitialViewSize,
|
{
|
||||||
0,
|
DbgPrint("NTDLL.LDR: map view of section failed (Status %x)\n",
|
||||||
MEM_COMMIT,
|
Status);
|
||||||
PAGE_READWRITE
|
ZwClose(FileHandle);
|
||||||
);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint("NTDLL.LDR: map view of section failed (Status %x)\n",
|
|
||||||
Status);
|
|
||||||
ZwClose(FileHandle);
|
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
ZwClose(FileHandle);
|
ZwClose(FileHandle);
|
||||||
|
|
||||||
/* relocate dll and fixup import table */
|
/* relocate dll and fixup import table */
|
||||||
if ((NTHeaders->FileHeader.Characteristics & IMAGE_FILE_DLL) ==
|
if ((NTHeaders->FileHeader.Characteristics & IMAGE_FILE_DLL) ==
|
||||||
IMAGE_FILE_DLL)
|
IMAGE_FILE_DLL)
|
||||||
|
{
|
||||||
|
Entrypoint =
|
||||||
|
(PDLLMAIN_FUNC) LdrPEStartup(ImageBase, SectionHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* build module entry */
|
||||||
|
Module = RtlAllocateHeap(RtlGetProcessHeap(),
|
||||||
|
0,
|
||||||
|
sizeof (LDR_MODULE));
|
||||||
|
Module->BaseAddress = (PVOID)ImageBase;
|
||||||
|
Module->EntryPoint = NTHeaders->OptionalHeader.AddressOfEntryPoint;
|
||||||
|
if (Module->EntryPoint != 0)
|
||||||
|
Module->EntryPoint += (ULONG)Module->BaseAddress;
|
||||||
|
Module->SizeOfImage = ImageSize;
|
||||||
|
if (NtCurrentPeb()->Ldr->Initialized == TRUE)
|
||||||
|
{
|
||||||
|
/* loading while app is running */
|
||||||
|
Module->LoadCount = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* loading while app is initializing
|
||||||
|
* dll must not be unloaded
|
||||||
|
*/
|
||||||
|
Module->LoadCount = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Module->TlsIndex = 0;
|
||||||
|
Module->CheckSum = NTHeaders->OptionalHeader.CheckSum;
|
||||||
|
Module->TimeDateStamp = NTHeaders->FileHeader.TimeDateStamp;
|
||||||
|
|
||||||
|
RtlCreateUnicodeString (&Module->FullDllName,
|
||||||
|
FullDosName);
|
||||||
|
RtlCreateUnicodeString (&Module->BaseDllName,
|
||||||
|
wcsrchr(FullDosName, L'\\') + 1);
|
||||||
|
DPRINT ("BaseDllName %wZ\n", &Module->BaseDllName);
|
||||||
|
|
||||||
|
/* FIXME: aquire loader lock */
|
||||||
|
InsertTailList(&NtCurrentPeb()->Ldr->InLoadOrderModuleList,
|
||||||
|
&Module->InLoadOrderModuleList);
|
||||||
|
InsertTailList(&NtCurrentPeb()->Ldr->InInitializationOrderModuleList,
|
||||||
|
&Module->InInitializationOrderModuleList);
|
||||||
|
/* FIXME: release loader lock */
|
||||||
|
|
||||||
|
/* initialize dll */
|
||||||
|
if ((NTHeaders->FileHeader.Characteristics & IMAGE_FILE_DLL) ==
|
||||||
|
IMAGE_FILE_DLL)
|
||||||
|
{
|
||||||
|
if (Module->EntryPoint != 0)
|
||||||
{
|
{
|
||||||
Entrypoint =
|
Entrypoint = (PDLLMAIN_FUNC)Module->EntryPoint;
|
||||||
(PDLLMAIN_FUNC) LdrPEStartup(
|
|
||||||
ImageBase,
|
DPRINT("Calling entry point at 0x%08x\n", Entrypoint);
|
||||||
SectionHandle
|
if (FALSE == Entrypoint(Module->BaseAddress,
|
||||||
);
|
DLL_PROCESS_ATTACH,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
DPRINT("NTDLL.LDR: DLL \"%wZ\" failed to initialize\n",
|
||||||
|
&Module->BaseDllName);
|
||||||
|
/* FIXME: should clean up and fail */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT("NTDLL.LDR: DLL \"%wZ\" initialized successfully\n",
|
||||||
|
&Module->BaseDllName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/* build module entry */
|
|
||||||
Module = RtlAllocateHeap(
|
|
||||||
RtlGetProcessHeap(),
|
|
||||||
0,
|
|
||||||
sizeof (LDR_MODULE)
|
|
||||||
);
|
|
||||||
Module->BaseAddress = (PVOID)ImageBase;
|
|
||||||
Module->EntryPoint = NTHeaders->OptionalHeader.AddressOfEntryPoint;
|
|
||||||
if (Module->EntryPoint != 0)
|
|
||||||
Module->EntryPoint += (ULONG)Module->BaseAddress;
|
|
||||||
Module->SizeOfImage = ImageSize;
|
|
||||||
if (NtCurrentPeb()->Ldr->Initialized == TRUE)
|
|
||||||
{
|
{
|
||||||
/* loading while app is running */
|
DPRINT("NTDLL.LDR: Entrypoint is NULL for \"%wZ\"\n",
|
||||||
Module->LoadCount = 1;
|
&Module->BaseDllName);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
/*
|
*BaseAddress = Module->BaseAddress;
|
||||||
* loading while app is initializing
|
return STATUS_SUCCESS;
|
||||||
* dll must not be unloaded
|
|
||||||
*/
|
|
||||||
Module->LoadCount = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Module->TlsIndex = 0;
|
|
||||||
Module->CheckSum = NTHeaders->OptionalHeader.CheckSum;
|
|
||||||
Module->TimeDateStamp = NTHeaders->FileHeader.TimeDateStamp;
|
|
||||||
|
|
||||||
RtlCreateUnicodeString (&Module->FullDllName,
|
|
||||||
FullDosName);
|
|
||||||
RtlCreateUnicodeString (&Module->BaseDllName,
|
|
||||||
wcsrchr(FullDosName, L'\\') + 1);
|
|
||||||
DPRINT ("BaseDllName %wZ\n", &Module->BaseDllName);
|
|
||||||
|
|
||||||
/* FIXME: aquire loader lock */
|
|
||||||
InsertTailList(&NtCurrentPeb()->Ldr->InLoadOrderModuleList,
|
|
||||||
&Module->InLoadOrderModuleList);
|
|
||||||
InsertTailList(&NtCurrentPeb()->Ldr->InInitializationOrderModuleList,
|
|
||||||
&Module->InInitializationOrderModuleList);
|
|
||||||
/* FIXME: release loader lock */
|
|
||||||
|
|
||||||
/* initialize dll */
|
|
||||||
if ((NTHeaders->FileHeader.Characteristics & IMAGE_FILE_DLL) ==
|
|
||||||
IMAGE_FILE_DLL)
|
|
||||||
{
|
|
||||||
if (Module->EntryPoint != 0)
|
|
||||||
{
|
|
||||||
Entrypoint = (PDLLMAIN_FUNC)Module->EntryPoint;
|
|
||||||
|
|
||||||
DPRINT("Calling entry point at 0x%08x\n", Entrypoint);
|
|
||||||
if (FALSE == Entrypoint(
|
|
||||||
Module->BaseAddress,
|
|
||||||
DLL_PROCESS_ATTACH,
|
|
||||||
NULL
|
|
||||||
))
|
|
||||||
{
|
|
||||||
DPRINT("NTDLL.LDR: DLL \"%wZ\" failed to initialize\n",
|
|
||||||
&Module->BaseDllName);
|
|
||||||
/* FIXME: should clean up and fail */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DPRINT("NTDLL.LDR: DLL \"%wZ\" initialized successfully\n",
|
|
||||||
&Module->BaseDllName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DPRINT("NTDLL.LDR: Entrypoint is NULL for \"%wZ\"\n",
|
|
||||||
&Module->BaseDllName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*BaseAddress = Module->BaseAddress;
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -493,84 +474,6 @@ static NTSTATUS LdrFindDll(PLDR_MODULE *Dll, PUNICODE_STRING Name)
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* NAME
|
|
||||||
* LdrMapSections
|
|
||||||
*
|
|
||||||
* DESCRIPTION
|
|
||||||
*
|
|
||||||
* ARGUMENTS
|
|
||||||
*
|
|
||||||
* RETURN VALUE
|
|
||||||
*
|
|
||||||
* REVISIONS
|
|
||||||
*
|
|
||||||
* NOTE
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
NTSTATUS LdrMapSections(HANDLE ProcessHandle,
|
|
||||||
PVOID ImageBase,
|
|
||||||
HANDLE SectionHandle,
|
|
||||||
PIMAGE_NT_HEADERS NTHeaders)
|
|
||||||
{
|
|
||||||
ULONG i;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
for (i = 0; (i < NTHeaders->FileHeader.NumberOfSections); i++)
|
|
||||||
{
|
|
||||||
PIMAGE_SECTION_HEADER Sections;
|
|
||||||
LARGE_INTEGER Offset;
|
|
||||||
ULONG Base;
|
|
||||||
ULONG Size;
|
|
||||||
|
|
||||||
Sections = (PIMAGE_SECTION_HEADER) SECHDROFFSET(ImageBase);
|
|
||||||
Base = (ULONG) (Sections[i].VirtualAddress + ImageBase);
|
|
||||||
Offset.u.LowPart = Sections[i].PointerToRawData;
|
|
||||||
Offset.u.HighPart = 0;
|
|
||||||
|
|
||||||
Size = max(Sections[i].Misc.VirtualSize, Sections[i].SizeOfRawData);
|
|
||||||
|
|
||||||
DPRINT("Mapping section %d offset %x base %x size %x\n",
|
|
||||||
i, Offset.u.LowPart, Base, Sections[i].Misc.VirtualSize);
|
|
||||||
DPRINT("Size %x\n", Sections[i].SizeOfRawData);
|
|
||||||
if( Offset.u.LowPart )
|
|
||||||
{ // only map section if it is initialized
|
|
||||||
Status = ZwMapViewOfSection(SectionHandle,
|
|
||||||
ProcessHandle,
|
|
||||||
(PVOID*)&Base,
|
|
||||||
0,
|
|
||||||
Size,
|
|
||||||
&Offset,
|
|
||||||
(PULONG)&Size,
|
|
||||||
0,
|
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("Failed to map section");
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// allocate pure memory for uninitialized section
|
|
||||||
Status = NtAllocateVirtualMemory( NtCurrentProcess(),
|
|
||||||
(PVOID *)&Base,
|
|
||||||
0,
|
|
||||||
&Size,
|
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE );
|
|
||||||
if( !NT_SUCCESS( Status ) )
|
|
||||||
{
|
|
||||||
DPRINT1( "Failed to allocate memory for uninitialized section\n" );
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME LOCAL
|
* NAME LOCAL
|
||||||
* LdrFixupForward
|
* LdrFixupForward
|
||||||
|
@ -1097,17 +1000,6 @@ PEPFUNC LdrPEStartup (PVOID ImageBase,
|
||||||
DosHeader = (PIMAGE_DOS_HEADER) ImageBase;
|
DosHeader = (PIMAGE_DOS_HEADER) ImageBase;
|
||||||
NTHeaders = (PIMAGE_NT_HEADERS) (ImageBase + DosHeader->e_lfanew);
|
NTHeaders = (PIMAGE_NT_HEADERS) (ImageBase + DosHeader->e_lfanew);
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize image sections.
|
|
||||||
*/
|
|
||||||
if (SectionHandle != NULL)
|
|
||||||
{
|
|
||||||
LdrMapSections(NtCurrentProcess(),
|
|
||||||
ImageBase,
|
|
||||||
SectionHandle,
|
|
||||||
NTHeaders);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the base address is different from the
|
* If the base address is different from the
|
||||||
* one the DLL is actually loaded, perform any
|
* one the DLL is actually loaded, perform any
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: view.c,v 1.13 2001/01/01 04:42:11 dwelch Exp $
|
/* $Id: view.c,v 1.14 2001/02/10 22:51:08 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -186,6 +186,18 @@ CcRequestCacheSegment(PBCB Bcb,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID CcFreeCachePage(PVOID Context, PVOID Address)
|
||||||
|
{
|
||||||
|
ULONG PhysAddr;
|
||||||
|
|
||||||
|
PhysAddr = MmGetPhysicalAddressForProcess(NULL, Address);
|
||||||
|
if (PhysAddr != 0)
|
||||||
|
{
|
||||||
|
MmDereferencePage((PVOID)PhysAddr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
CcFreeCacheSegment(PBCB Bcb,
|
CcFreeCacheSegment(PBCB Bcb,
|
||||||
PCACHE_SEGMENT CacheSeg)
|
PCACHE_SEGMENT CacheSeg)
|
||||||
|
@ -196,7 +208,8 @@ CcFreeCacheSegment(PBCB Bcb,
|
||||||
MmFreeMemoryArea(NULL,
|
MmFreeMemoryArea(NULL,
|
||||||
CacheSeg->BaseAddress,
|
CacheSeg->BaseAddress,
|
||||||
Bcb->CacheSegmentSize,
|
Bcb->CacheSegmentSize,
|
||||||
TRUE);
|
CcFreeCachePage,
|
||||||
|
NULL);
|
||||||
ExFreePool(CacheSeg);
|
ExFreePool(CacheSeg);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: registry.c,v 1.53 2001/01/28 21:37:37 ekohl Exp $
|
/* $Id: registry.c,v 1.54 2001/02/10 22:51:08 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/ob.h>
|
#include <internal/ob.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
|
|
||||||
struct _EPROCESS;
|
struct _EPROCESS;
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
* Page access attributes (or these together)
|
* Page access attributes (or these together)
|
||||||
*/
|
*/
|
||||||
#define PA_READ (1<<0)
|
#define PA_READ (1<<0)
|
||||||
#define PA_WRITE ((1<<0)+(1<<1))
|
#define PA_WRITE ((1<<0)+(1<<1))
|
||||||
#define PA_EXECUTE PA_READ
|
#define PA_EXECUTE PA_READ
|
||||||
#define PA_PCD (1<<4)
|
#define PA_PCD (1<<4)
|
||||||
#define PA_PWT (1<<3)
|
#define PA_PWT (1<<3)
|
||||||
|
@ -21,6 +22,7 @@ struct _EPROCESS;
|
||||||
*/
|
*/
|
||||||
#define PA_USER (1<<2)
|
#define PA_USER (1<<2)
|
||||||
#define PA_SYSTEM (0)
|
#define PA_SYSTEM (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PAGESIZE (4096)
|
#define PAGESIZE (4096)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: kd.h,v 1.2 2000/12/28 03:38:07 dwelch Exp $
|
/* $Id: kd.h,v 1.3 2001/02/10 22:51:08 dwelch Exp $
|
||||||
*
|
*
|
||||||
* kernel debugger prototypes
|
* kernel debugger prototypes
|
||||||
*/
|
*/
|
||||||
|
@ -9,4 +9,11 @@
|
||||||
ULONG
|
ULONG
|
||||||
KdpPrintString (PANSI_STRING String);
|
KdpPrintString (PANSI_STRING String);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
DebugLogWrite(PCH String);
|
||||||
|
VOID
|
||||||
|
DebugLogInit(VOID);
|
||||||
|
VOID
|
||||||
|
DebugLogInit2(VOID);
|
||||||
|
|
||||||
#endif /* __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H */
|
#endif /* __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H */
|
||||||
|
|
|
@ -71,14 +71,25 @@ typedef struct
|
||||||
PSECTION_PAGE_TABLE PageTables[NR_SECTION_PAGE_TABLES];
|
PSECTION_PAGE_TABLE PageTables[NR_SECTION_PAGE_TABLES];
|
||||||
} SECTION_PAGE_DIRECTORY, *PSECTION_PAGE_DIRECTORY;
|
} SECTION_PAGE_DIRECTORY, *PSECTION_PAGE_DIRECTORY;
|
||||||
|
|
||||||
typedef struct
|
#define MM_PAGEFILE_SECTION (0x1)
|
||||||
|
#define MM_IMAGE_SECTION (0x2)
|
||||||
|
|
||||||
|
#define MM_SECTION_SEGMENT_BSS (0x1)
|
||||||
|
|
||||||
|
typedef struct _MM_SECTION_SEGMENT
|
||||||
{
|
{
|
||||||
ULONG FileOffset;
|
ULONG FileOffset;
|
||||||
ULONG Protection;
|
ULONG Protection;
|
||||||
ULONG Attributes;
|
ULONG Attributes;
|
||||||
SECTION_PAGE_DIRECTORY PageDirectory;
|
ULONG Length;
|
||||||
|
ULONG RawLength;
|
||||||
KMUTEX Lock;
|
KMUTEX Lock;
|
||||||
} MM_SECTION_SEGMENT;
|
ULONG ReferenceCount;
|
||||||
|
SECTION_PAGE_DIRECTORY PageDirectory;
|
||||||
|
ULONG Flags;
|
||||||
|
PVOID VirtualAddress;
|
||||||
|
ULONG Characteristics;
|
||||||
|
} MM_SECTION_SEGMENT, *PMM_SECTION_SEGMENT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -91,8 +102,19 @@ typedef struct
|
||||||
LIST_ENTRY ViewListHead;
|
LIST_ENTRY ViewListHead;
|
||||||
KSPIN_LOCK ViewListLock;
|
KSPIN_LOCK ViewListLock;
|
||||||
KMUTEX Lock;
|
KMUTEX Lock;
|
||||||
SECTION_PAGE_DIRECTORY PageDirectory;
|
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
|
ULONG NrSegments;
|
||||||
|
PMM_SECTION_SEGMENT Segments;
|
||||||
|
PVOID ImageBase;
|
||||||
|
PVOID EntryPoint;
|
||||||
|
ULONG StackReserve;
|
||||||
|
ULONG StackCommit;
|
||||||
|
ULONG Subsystem;
|
||||||
|
ULONG MinorSubsystemVersion;
|
||||||
|
ULONG MajorSubsystemVersion;
|
||||||
|
ULONG ImageCharacteristics;
|
||||||
|
USHORT Machine;
|
||||||
|
BOOLEAN Executable;
|
||||||
} SECTION_OBJECT, *PSECTION_OBJECT;
|
} SECTION_OBJECT, *PSECTION_OBJECT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -111,6 +133,7 @@ typedef struct
|
||||||
SECTION_OBJECT* Section;
|
SECTION_OBJECT* Section;
|
||||||
ULONG ViewOffset;
|
ULONG ViewOffset;
|
||||||
LIST_ENTRY ViewListEntry;
|
LIST_ENTRY ViewListEntry;
|
||||||
|
PMM_SECTION_SEGMENT Segment;
|
||||||
} SectionData;
|
} SectionData;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -135,7 +158,6 @@ typedef struct _MADDRESS_SPACE
|
||||||
ULONG PageTableRefCountTableSize;
|
ULONG PageTableRefCountTableSize;
|
||||||
} MADDRESS_SPACE, *PMADDRESS_SPACE;
|
} MADDRESS_SPACE, *PMADDRESS_SPACE;
|
||||||
|
|
||||||
|
|
||||||
/* FUNCTIONS */
|
/* FUNCTIONS */
|
||||||
|
|
||||||
VOID MmLockAddressSpace(PMADDRESS_SPACE AddressSpace);
|
VOID MmLockAddressSpace(PMADDRESS_SPACE AddressSpace);
|
||||||
|
@ -161,7 +183,8 @@ VOID ExInitNonPagedPool(ULONG BaseAddress);
|
||||||
NTSTATUS MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
|
NTSTATUS MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
BOOLEAN FreePages);
|
VOID (*FreePage)(PVOID Context, PVOID Address),
|
||||||
|
PVOID FreePageContext);
|
||||||
VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead);
|
VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead);
|
||||||
NTSTATUS MmLockMemoryArea(MEMORY_AREA* MemoryArea);
|
NTSTATUS MmLockMemoryArea(MEMORY_AREA* MemoryArea);
|
||||||
NTSTATUS MmUnlockMemoryArea(MEMORY_AREA* MemoryArea);
|
NTSTATUS MmUnlockMemoryArea(MEMORY_AREA* MemoryArea);
|
||||||
|
@ -199,8 +222,8 @@ PVOID MmGetMdlPageAddress(PMDL Mdl, PVOID Offset);
|
||||||
VOID MiShutdownMemoryManager(VOID);
|
VOID MiShutdownMemoryManager(VOID);
|
||||||
ULONG MmGetPhysicalAddressForProcess(struct _EPROCESS* Process,
|
ULONG MmGetPhysicalAddressForProcess(struct _EPROCESS* Process,
|
||||||
PVOID Address);
|
PVOID Address);
|
||||||
NTSTATUS STDCALL MmUnmapViewOfSection(struct _EPROCESS* Process,
|
NTSTATUS STDCALL
|
||||||
PMEMORY_AREA MemoryArea);
|
MmUnmapViewOfSection(struct _EPROCESS* Process, PVOID BaseAddress);
|
||||||
NTSTATUS MmSafeCopyFromUser(PVOID Dest, PVOID Src, ULONG NumberOfBytes);
|
NTSTATUS MmSafeCopyFromUser(PVOID Dest, PVOID Src, ULONG NumberOfBytes);
|
||||||
NTSTATUS MmSafeCopyToUser(PVOID Dest, PVOID Src, ULONG NumberOfBytes);
|
NTSTATUS MmSafeCopyToUser(PVOID Dest, PVOID Src, ULONG NumberOfBytes);
|
||||||
VOID MmInitPagingFile(VOID);
|
VOID MmInitPagingFile(VOID);
|
||||||
|
@ -263,12 +286,11 @@ ULONG MmTrimWorkingSet(struct _EPROCESS* Process,
|
||||||
ULONG ReduceHint);
|
ULONG ReduceHint);
|
||||||
VOID MmRemovePageFromWorkingSet(struct _EPROCESS* Process,
|
VOID MmRemovePageFromWorkingSet(struct _EPROCESS* Process,
|
||||||
PVOID Address);
|
PVOID Address);
|
||||||
VOID
|
VOID MmAddPageToWorkingSet(struct _EPROCESS* Process,
|
||||||
MmAddPageToWorkingSet(struct _EPROCESS* Process, PVOID Address);
|
PVOID Address);
|
||||||
|
|
||||||
VOID MmInitPagingFile(VOID);
|
VOID MmInitPagingFile(VOID);
|
||||||
BOOLEAN
|
BOOLEAN MmReserveSwapPages(ULONG Nr);
|
||||||
MmReserveSwapPages(ULONG Nr);
|
|
||||||
VOID MmDereserveSwapPages(ULONG Nr);
|
VOID MmDereserveSwapPages(ULONG Nr);
|
||||||
SWAPENTRY MmAllocSwapPage(VOID);
|
SWAPENTRY MmAllocSwapPage(VOID);
|
||||||
VOID MmFreeSwapPage(SWAPENTRY Entry);
|
VOID MmFreeSwapPage(SWAPENTRY Entry);
|
||||||
|
@ -331,4 +353,17 @@ MmGetContinuousPages(ULONG NumberOfBytes,
|
||||||
|
|
||||||
#define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
|
#define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
|
MEMORY_AREA* MemoryArea,
|
||||||
|
PVOID Address);
|
||||||
|
ULONG
|
||||||
|
MmGetPageProtect(struct _EPROCESS* Process, PVOID Address);
|
||||||
|
PVOID
|
||||||
|
ExAllocatePageWithPhysPage(ULONG PhysPage);
|
||||||
|
ULONG
|
||||||
|
MmGetReferenceCountPage(PVOID PhysicalAddress);
|
||||||
|
BOOLEAN
|
||||||
|
MmIsUsablePage(PVOID PhysicalAddress);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -206,6 +206,7 @@ VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Irp->Overlay.AsynchronousParameters.UserApcRoutine != NULL)
|
if (Irp->Overlay.AsynchronousParameters.UserApcRoutine != NULL)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.35 2001/01/08 02:14:05 dwelch Exp $
|
/* $Id: create.c,v 1.36 2001/02/10 22:51:09 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -108,9 +108,8 @@ IopCreateFile (PVOID ObjectBody,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( (DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM)
|
if ((DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM)
|
||||||
&& (DeviceObject->DeviceType != FILE_DEVICE_DISK)
|
&& (DeviceObject->DeviceType != FILE_DEVICE_DISK))
|
||||||
)
|
|
||||||
{
|
{
|
||||||
DPRINT ("Device was wrong type\n");
|
DPRINT ("Device was wrong type\n");
|
||||||
return (STATUS_UNSUCCESSFUL);
|
return (STATUS_UNSUCCESSFUL);
|
||||||
|
@ -322,8 +321,9 @@ IoCreateFile (
|
||||||
//FileObject->Flags |= FileObject->Flags | FO_SYNCHRONOUS_IO;
|
//FileObject->Flags |= FileObject->Flags | FO_SYNCHRONOUS_IO;
|
||||||
FileObject->Flags |= FO_SYNCHRONOUS_IO;
|
FileObject->Flags |= FO_SYNCHRONOUS_IO;
|
||||||
}
|
}
|
||||||
|
KeInitializeEvent (&FileObject->Lock, NotificationEvent, TRUE);
|
||||||
KeInitializeEvent (&Event, NotificationEvent, FALSE);
|
KeInitializeEvent (&Event, NotificationEvent, FALSE);
|
||||||
|
|
||||||
DPRINT("FileObject %x\n", FileObject);
|
DPRINT("FileObject %x\n", FileObject);
|
||||||
DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject);
|
DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject);
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: xhaldisp.c,v 1.2 2000/08/21 00:14:04 ekohl Exp $
|
/* $Id: xhaldisp.c,v 1.3 2001/02/10 22:51:09 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -45,4 +45,5 @@ HAL_PRIVATE_DISPATCH EXPORTED HalPrivateDispatchTable =
|
||||||
// any more??
|
// any more??
|
||||||
};
|
};
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: kdebug.c,v 1.17 2001/01/06 21:40:13 rex Exp $
|
/* $Id: kdebug.c,v 1.18 2001/02/10 22:51:09 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -27,6 +27,7 @@
|
||||||
#define ScreenDebug (0x1)
|
#define ScreenDebug (0x1)
|
||||||
#define SerialDebug (0x2)
|
#define SerialDebug (0x2)
|
||||||
#define BochsDebug (0x4)
|
#define BochsDebug (0x4)
|
||||||
|
#define FileLogDebug (0x8)
|
||||||
|
|
||||||
/* VARIABLES ***************************************************************/
|
/* VARIABLES ***************************************************************/
|
||||||
|
|
||||||
|
@ -43,7 +44,6 @@ static BOOLEAN KdpBreakPending = FALSE;
|
||||||
static BOOLEAN KdpBreakRecieved = FALSE;
|
static BOOLEAN KdpBreakRecieved = FALSE;
|
||||||
static ULONG KdpDebugType = ScreenDebug | BochsDebug;
|
static ULONG KdpDebugType = ScreenDebug | BochsDebug;
|
||||||
|
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS ********************************************************/
|
/* PRIVATE FUNCTIONS ********************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -116,7 +116,12 @@ KdInitSystem (
|
||||||
}
|
}
|
||||||
p1 = p2;
|
p1 = p2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DBGPRINT_FILE_LOG
|
||||||
|
KdpDebugType |= FileLogDebug;
|
||||||
|
DebugLogInit();
|
||||||
|
#endif /* DBGPRINT_FILE_LOG */
|
||||||
|
|
||||||
/* check for 'BAUDRATE' */
|
/* check for 'BAUDRATE' */
|
||||||
p1 = (PCHAR)LoaderBlock->CommandLine;
|
p1 = (PCHAR)LoaderBlock->CommandLine;
|
||||||
while (p1 && (p2 = strchr (p1, '/')))
|
while (p1 && (p2 = strchr (p1, '/')))
|
||||||
|
@ -215,6 +220,10 @@ KdInitSystem (
|
||||||
PrintString ("\n Serial debugging enabled: COM%ld %ld Baud\n\n",
|
PrintString ("\n Serial debugging enabled: COM%ld %ld Baud\n\n",
|
||||||
PortInfo.ComPort, PortInfo.BaudRate);
|
PortInfo.ComPort, PortInfo.BaudRate);
|
||||||
}
|
}
|
||||||
|
if (KdpDebugType & FileLogDebug)
|
||||||
|
{
|
||||||
|
PrintString("\n File log debugging enabled\n\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
PrintString ("\n Debugging disabled\n\n");
|
PrintString ("\n Debugging disabled\n\n");
|
||||||
|
@ -262,7 +271,12 @@ ULONG KdpPrintString (PANSI_STRING String)
|
||||||
pch++;
|
pch++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUGPRINT_LOG_WRITE
|
||||||
|
if (KdpDebugType & FileLogDebug)
|
||||||
|
{
|
||||||
|
DebugLogWrite(String->Buffer);
|
||||||
|
}
|
||||||
|
#endif /* DEBUGPRINT_LOG_WRITE */
|
||||||
return (ULONG)String->Length;
|
return (ULONG)String->Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,8 @@ exception_handler(struct trap_frame* tf)
|
||||||
if (PsGetCurrentThread() != NULL &&
|
if (PsGetCurrentThread() != NULL &&
|
||||||
tf->esp < (ULONG)PsGetCurrentThread()->Tcb.StackLimit)
|
tf->esp < (ULONG)PsGetCurrentThread()->Tcb.StackLimit)
|
||||||
{
|
{
|
||||||
DbgPrint("Stack underflow\n");
|
DbgPrint("Stack underflow (tf->esp %x Limit %x)\n",
|
||||||
|
tf->esp, (ULONG)PsGetCurrentThread()->Tcb.StackLimit);
|
||||||
tf->type = 12;
|
tf->type = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <internal/trap.h>
|
#include <internal/trap.h>
|
||||||
#include <internal/mm.h>
|
#include <internal/mm.h>
|
||||||
#include <internal/i386/segment.h>
|
#include <internal/i386/segment.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
//#define NDEBUG
|
//#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: main.c,v 1.77 2001/02/06 00:11:18 dwelch Exp $
|
/* $Id: main.c,v 1.78 2001/02/10 22:51:09 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -26,6 +26,7 @@
|
||||||
#include <internal/i386/segment.h>
|
#include <internal/i386/segment.h>
|
||||||
#include <napi/shared_data.h>
|
#include <napi/shared_data.h>
|
||||||
#include <internal/v86m.h>
|
#include <internal/v86m.h>
|
||||||
|
#include <internal/kd.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -574,6 +575,12 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUGPRINT_FILE_LOG
|
||||||
|
/* On the assumption that we can now access disks start up the debug
|
||||||
|
logger thread */
|
||||||
|
DebugLogInit2();
|
||||||
|
#endif /* DEBUGPRINT_FILE_LOG */
|
||||||
|
|
||||||
/* Create the SystemRoot symbolic link */
|
/* Create the SystemRoot symbolic link */
|
||||||
DbgPrint("CommandLine: %s\n", (PUCHAR)KeLoaderBlock.CommandLine);
|
DbgPrint("CommandLine: %s\n", (PUCHAR)KeLoaderBlock.CommandLine);
|
||||||
CreateSystemRootLink ((PUCHAR)KeLoaderBlock.CommandLine);
|
CreateSystemRootLink ((PUCHAR)KeLoaderBlock.CommandLine);
|
||||||
|
|
|
@ -91,7 +91,7 @@ NTSTATUS LdrLoadInitialProcess (VOID)
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
PAGE_READWRITE,
|
PAGE_READWRITE,
|
||||||
MEM_COMMIT,
|
SEC_COMMIT | SEC_IMAGE,
|
||||||
FileHandle);
|
FileHandle);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: rtl.c,v 1.11 2000/10/22 16:36:51 ekohl Exp $
|
/* $Id: rtl.c,v 1.12 2001/02/10 22:51:09 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -23,19 +23,14 @@
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
|
||||||
PIMAGE_NT_HEADERS STDCALL RtlImageNtHeader (IN PVOID BaseAddress)
|
PIMAGE_NT_HEADERS STDCALL
|
||||||
|
RtlImageNtHeader (IN PVOID BaseAddress)
|
||||||
{
|
{
|
||||||
PIMAGE_DOS_HEADER DosHeader;
|
PIMAGE_DOS_HEADER DosHeader;
|
||||||
PIMAGE_NT_HEADERS NTHeaders;
|
PIMAGE_NT_HEADERS NTHeaders;
|
||||||
|
|
||||||
DPRINT("BaseAddress %x\n", BaseAddress);
|
|
||||||
DosHeader = (PIMAGE_DOS_HEADER)BaseAddress;
|
DosHeader = (PIMAGE_DOS_HEADER)BaseAddress;
|
||||||
DPRINT("DosHeader %x\n", DosHeader);
|
|
||||||
NTHeaders = (PIMAGE_NT_HEADERS)(BaseAddress + DosHeader->e_lfanew);
|
NTHeaders = (PIMAGE_NT_HEADERS)(BaseAddress + DosHeader->e_lfanew);
|
||||||
DPRINT("NTHeaders %x\n", NTHeaders);
|
|
||||||
DPRINT("DosHeader->e_magic %x DosHeader->e_lfanew %x\n",
|
|
||||||
DosHeader->e_magic, DosHeader->e_lfanew);
|
|
||||||
DPRINT("*NTHeaders %x\n", *(PULONG)NTHeaders);
|
|
||||||
if ((DosHeader->e_magic != IMAGE_DOS_MAGIC)
|
if ((DosHeader->e_magic != IMAGE_DOS_MAGIC)
|
||||||
|| (DosHeader->e_lfanew == 0L)
|
|| (DosHeader->e_lfanew == 0L)
|
||||||
|| (*(PULONG) NTHeaders != IMAGE_PE_MAGIC))
|
|| (*(PULONG) NTHeaders != IMAGE_PE_MAGIC))
|
||||||
|
@ -47,12 +42,10 @@ PIMAGE_NT_HEADERS STDCALL RtlImageNtHeader (IN PVOID BaseAddress)
|
||||||
|
|
||||||
|
|
||||||
PVOID STDCALL
|
PVOID STDCALL
|
||||||
RtlImageDirectoryEntryToData (
|
RtlImageDirectoryEntryToData (IN PVOID BaseAddress,
|
||||||
IN PVOID BaseAddress,
|
IN BOOLEAN ImageLoaded,
|
||||||
IN BOOLEAN ImageLoaded,
|
IN ULONG Directory,
|
||||||
IN ULONG Directory,
|
OUT PULONG Size)
|
||||||
OUT PULONG Size
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
PIMAGE_NT_HEADERS NtHeader;
|
PIMAGE_NT_HEADERS NtHeader;
|
||||||
PIMAGE_SECTION_HEADER SectionHeader;
|
PIMAGE_SECTION_HEADER SectionHeader;
|
||||||
|
@ -149,6 +142,7 @@ RtlImageRvaToVa (
|
||||||
Section->VirtualAddress);
|
Section->VirtualAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define RVA(m, b) ((ULONG)b + m)
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
LdrGetProcedureAddress (IN PVOID BaseAddress,
|
LdrGetProcedureAddress (IN PVOID BaseAddress,
|
||||||
|
@ -164,24 +158,57 @@ LdrGetProcedureAddress (IN PVOID BaseAddress,
|
||||||
|
|
||||||
/* get the pointer to the export directory */
|
/* get the pointer to the export directory */
|
||||||
ExportDir = (PIMAGE_EXPORT_DIRECTORY)
|
ExportDir = (PIMAGE_EXPORT_DIRECTORY)
|
||||||
RtlImageDirectoryEntryToData (BaseAddress, TRUE, IMAGE_DIRECTORY_ENTRY_EXPORT, &i);
|
RtlImageDirectoryEntryToData (BaseAddress, TRUE,
|
||||||
|
IMAGE_DIRECTORY_ENTRY_EXPORT, &i);
|
||||||
|
|
||||||
if (!ExportDir || !i || !ProcedureAddress)
|
if (!ExportDir || !i || !ProcedureAddress)
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER;
|
return(STATUS_INVALID_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressPtr = (PULONG)((ULONG)BaseAddress + (ULONG)ExportDir->AddressOfFunctions);
|
AddressPtr = (PULONG)RVA(BaseAddress, ExportDir->AddressOfFunctions);
|
||||||
if (Name && Name->Length)
|
if (Name && Name->Length)
|
||||||
{
|
{
|
||||||
|
ULONG minn, maxn;
|
||||||
|
|
||||||
/* by name */
|
/* by name */
|
||||||
OrdinalPtr = (PUSHORT)((ULONG)BaseAddress + (ULONG)ExportDir->AddressOfNameOrdinals);
|
OrdinalPtr =
|
||||||
NamePtr = (PULONG)((ULONG)BaseAddress + (ULONG)ExportDir->AddressOfNames);
|
(PUSHORT)RVA(BaseAddress, ExportDir->AddressOfNameOrdinals);
|
||||||
|
NamePtr = (PULONG)RVA(BaseAddress, ExportDir->AddressOfNames);
|
||||||
|
|
||||||
|
minn = 0; maxn = ExportDir->NumberOfNames;
|
||||||
|
while (minn <= maxn)
|
||||||
|
{
|
||||||
|
ULONG mid;
|
||||||
|
LONG res;
|
||||||
|
|
||||||
|
mid = (minn + maxn) / 2;
|
||||||
|
res = _strnicmp(Name->Buffer, (PCH)RVA(BaseAddress, NamePtr[mid]),
|
||||||
|
Name->Length);
|
||||||
|
if (res == 0)
|
||||||
|
{
|
||||||
|
*ProcedureAddress =
|
||||||
|
(PVOID)RVA(BaseAddress, AddressPtr[OrdinalPtr[mid]]);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
else if (res > 0)
|
||||||
|
{
|
||||||
|
maxn = mid - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
minn = mid + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < ExportDir->NumberOfNames; i++, NamePtr++, OrdinalPtr++)
|
for (i = 0; i < ExportDir->NumberOfNames; i++, NamePtr++, OrdinalPtr++)
|
||||||
{
|
{
|
||||||
if (!_strnicmp(Name->Buffer, (char*)(BaseAddress + *NamePtr), Name->Length))
|
if (!_strnicmp(Name->Buffer,
|
||||||
|
(char*)(BaseAddress + *NamePtr), Name->Length))
|
||||||
{
|
{
|
||||||
*ProcedureAddress = (PVOID)((ULONG)BaseAddress + (ULONG)AddressPtr[*OrdinalPtr]);
|
*ProcedureAddress =
|
||||||
|
(PVOID)((ULONG)BaseAddress +
|
||||||
|
(ULONG)AddressPtr[*OrdinalPtr]);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,10 +220,13 @@ LdrGetProcedureAddress (IN PVOID BaseAddress,
|
||||||
Ordinal &= 0x0000FFFF;
|
Ordinal &= 0x0000FFFF;
|
||||||
if (Ordinal - ExportDir->Base < ExportDir->NumberOfFunctions)
|
if (Ordinal - ExportDir->Base < ExportDir->NumberOfFunctions)
|
||||||
{
|
{
|
||||||
*ProcedureAddress = (PVOID)((ULONG)BaseAddress + (ULONG)AddressPtr[Ordinal - ExportDir->Base]);
|
*ProcedureAddress =
|
||||||
|
(PVOID)((ULONG)BaseAddress +
|
||||||
|
(ULONG)AddressPtr[Ordinal - ExportDir->Base]);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
DbgPrint("LdrGetProcedureAddress: Can't resolve symbol @%d\n", Ordinal);
|
DbgPrint("LdrGetProcedureAddress: Can't resolve symbol @%d\n",
|
||||||
|
Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
return STATUS_PROCEDURE_NOT_FOUND;
|
return STATUS_PROCEDURE_NOT_FOUND;
|
||||||
|
|
|
@ -76,10 +76,9 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
UNICODE_STRING DllPathname;
|
UNICODE_STRING DllPathname;
|
||||||
PIMAGE_DOS_HEADER DosHeader;
|
PIMAGE_DOS_HEADER DosHeader;
|
||||||
PIMAGE_NT_HEADERS NTHeaders;
|
PIMAGE_NT_HEADERS NTHeaders;
|
||||||
ULONG InitialViewSize;
|
|
||||||
ULONG i;
|
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
ANSI_STRING ProcedureName;
|
ANSI_STRING ProcedureName;
|
||||||
|
ULONG ViewSize;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Locate and open NTDLL to determine ImageBase
|
* Locate and open NTDLL to determine ImageBase
|
||||||
|
@ -146,7 +145,7 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
PAGE_READWRITE,
|
PAGE_READWRITE,
|
||||||
MEM_COMMIT,
|
SEC_IMAGE | SEC_COMMIT,
|
||||||
FileHandle);
|
FileHandle);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -159,17 +158,15 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
/*
|
/*
|
||||||
* Map the NTDLL into the process
|
* Map the NTDLL into the process
|
||||||
*/
|
*/
|
||||||
InitialViewSize = DosHeader->e_lfanew +
|
ViewSize = 0;
|
||||||
sizeof (IMAGE_NT_HEADERS) +
|
ImageBase = 0;
|
||||||
(sizeof (IMAGE_SECTION_HEADER) * NTHeaders->FileHeader.NumberOfSections);
|
|
||||||
DPRINT("Mapping view of section\n");
|
|
||||||
Status = ZwMapViewOfSection(NTDllSectionHandle,
|
Status = ZwMapViewOfSection(NTDllSectionHandle,
|
||||||
ProcessHandle,
|
ProcessHandle,
|
||||||
(PVOID*)&ImageBase,
|
(PVOID*)&ImageBase,
|
||||||
0,
|
0,
|
||||||
InitialViewSize,
|
ViewSize,
|
||||||
NULL,
|
NULL,
|
||||||
&InitialViewSize,
|
&ViewSize,
|
||||||
0,
|
0,
|
||||||
MEM_COMMIT,
|
MEM_COMMIT,
|
||||||
PAGE_READWRITE);
|
PAGE_READWRITE);
|
||||||
|
@ -180,40 +177,6 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < NTHeaders->FileHeader.NumberOfSections; i++)
|
|
||||||
{
|
|
||||||
PIMAGE_SECTION_HEADER Sections;
|
|
||||||
LARGE_INTEGER Offset;
|
|
||||||
ULONG Base;
|
|
||||||
|
|
||||||
DPRINT("Mapping view of section %d\n", i);
|
|
||||||
Sections = (PIMAGE_SECTION_HEADER) SECHDROFFSET(BlockBuffer);
|
|
||||||
DPRINT("Sections %x\n", Sections);
|
|
||||||
Base = Sections[i].VirtualAddress + ImageBase;
|
|
||||||
DPRINT("Base %x\n", Base);
|
|
||||||
Offset.u.LowPart = Sections[i].PointerToRawData;
|
|
||||||
Offset.u.HighPart = 0;
|
|
||||||
DPRINT("Mapping view of section\n");
|
|
||||||
Status = ZwMapViewOfSection(NTDllSectionHandle,
|
|
||||||
ProcessHandle,
|
|
||||||
(PVOID*)&Base,
|
|
||||||
0,
|
|
||||||
Sections[i].Misc.VirtualSize,
|
|
||||||
&Offset,
|
|
||||||
(PULONG)&Sections[i].Misc.VirtualSize,
|
|
||||||
0,
|
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint("NTDLL map view of secion failed (Status %x)\n", Status);
|
|
||||||
ZwClose(NTDllSectionHandle);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DPRINT("Finished mapping\n");
|
|
||||||
|
|
||||||
|
|
||||||
DPRINT("Referencing process\n");
|
DPRINT("Referencing process\n");
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_ALL_ACCESS,
|
PROCESS_ALL_ACCESS,
|
||||||
|
@ -233,74 +196,86 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
/*
|
/*
|
||||||
* retrieve ntdll's startup address
|
* retrieve ntdll's startup address
|
||||||
*/
|
*/
|
||||||
RtlInitAnsiString (&ProcedureName,
|
if (SystemDllEntryPoint == NULL)
|
||||||
"LdrInitializeThunk");
|
|
||||||
Status = LdrGetProcedureAddress ((PVOID)ImageBase,
|
|
||||||
&ProcedureName,
|
|
||||||
0,
|
|
||||||
&SystemDllEntryPoint);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
RtlInitAnsiString (&ProcedureName,
|
||||||
KeDetachProcess();
|
"LdrInitializeThunk");
|
||||||
ObDereferenceObject(Process);
|
Status = LdrGetProcedureAddress ((PVOID)ImageBase,
|
||||||
ZwClose(NTDllSectionHandle);
|
&ProcedureName,
|
||||||
return (Status);
|
0,
|
||||||
|
&SystemDllEntryPoint);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
||||||
|
KeDetachProcess();
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
ZwClose(NTDllSectionHandle);
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
|
*LdrStartupAddr = SystemDllEntryPoint;
|
||||||
}
|
}
|
||||||
*LdrStartupAddr = SystemDllEntryPoint;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Retrieve the offset of the APC dispatcher from NTDLL
|
* Retrieve the offset of the APC dispatcher from NTDLL
|
||||||
*/
|
*/
|
||||||
RtlInitAnsiString (&ProcedureName,
|
if (SystemDllApcDispatcher == NULL)
|
||||||
"KiUserApcDispatcher");
|
|
||||||
Status = LdrGetProcedureAddress ((PVOID)ImageBase,
|
|
||||||
&ProcedureName,
|
|
||||||
0,
|
|
||||||
&SystemDllApcDispatcher);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
RtlInitAnsiString (&ProcedureName,
|
||||||
KeDetachProcess();
|
"KiUserApcDispatcher");
|
||||||
ObDereferenceObject(Process);
|
Status = LdrGetProcedureAddress ((PVOID)ImageBase,
|
||||||
ZwClose(NTDllSectionHandle);
|
&ProcedureName,
|
||||||
return (Status);
|
0,
|
||||||
|
&SystemDllApcDispatcher);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
||||||
|
KeDetachProcess();
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
ZwClose(NTDllSectionHandle);
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Retrieve the offset of the exception dispatcher from NTDLL
|
* Retrieve the offset of the exception dispatcher from NTDLL
|
||||||
*/
|
*/
|
||||||
RtlInitAnsiString (&ProcedureName,
|
if (SystemDllExceptionDispatcher == NULL)
|
||||||
"KiUserExceptionDispatcher");
|
|
||||||
Status = LdrGetProcedureAddress ((PVOID)ImageBase,
|
|
||||||
&ProcedureName,
|
|
||||||
0,
|
|
||||||
&SystemDllExceptionDispatcher);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
RtlInitAnsiString (&ProcedureName,
|
||||||
KeDetachProcess();
|
"KiUserExceptionDispatcher");
|
||||||
ObDereferenceObject(Process);
|
Status = LdrGetProcedureAddress ((PVOID)ImageBase,
|
||||||
ZwClose(NTDllSectionHandle);
|
&ProcedureName,
|
||||||
return (Status);
|
0,
|
||||||
|
&SystemDllExceptionDispatcher);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
||||||
|
KeDetachProcess();
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
ZwClose(NTDllSectionHandle);
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Retrieve the offset of the callback dispatcher from NTDLL
|
* Retrieve the offset of the callback dispatcher from NTDLL
|
||||||
*/
|
*/
|
||||||
RtlInitAnsiString (&ProcedureName,
|
if (SystemDllCallbackDispatcher == NULL)
|
||||||
"KiUserCallbackDispatcher");
|
|
||||||
Status = LdrGetProcedureAddress ((PVOID)ImageBase,
|
|
||||||
&ProcedureName,
|
|
||||||
0,
|
|
||||||
&SystemDllCallbackDispatcher);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
RtlInitAnsiString (&ProcedureName,
|
||||||
KeDetachProcess();
|
"KiUserCallbackDispatcher");
|
||||||
ObDereferenceObject(Process);
|
Status = LdrGetProcedureAddress ((PVOID)ImageBase,
|
||||||
ZwClose(NTDllSectionHandle);
|
&ProcedureName,
|
||||||
return (Status);
|
0,
|
||||||
|
&SystemDllCallbackDispatcher);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
||||||
|
KeDetachProcess();
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
ZwClose(NTDllSectionHandle);
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeDetachProcess();
|
KeDetachProcess();
|
||||||
|
|
|
@ -40,188 +40,29 @@ NTSTATUS LdrpMapImage(HANDLE ProcessHandle,
|
||||||
* RETURNS: Status
|
* RETURNS: Status
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PVOID ImageBase;
|
ULONG ViewSize;
|
||||||
NTSTATUS Status;
|
PVOID ImageBase;
|
||||||
PIMAGE_NT_HEADERS NTHeaders;
|
NTSTATUS Status;
|
||||||
ULONG InitialViewSize;
|
|
||||||
ULONG i;
|
ViewSize = 0;
|
||||||
PEPROCESS Process;
|
ImageBase = 0;
|
||||||
PVOID FinalBase;
|
|
||||||
ULONG NumberOfSections;
|
Status = ZwMapViewOfSection(SectionHandle,
|
||||||
|
ProcessHandle,
|
||||||
DPRINT("Referencing process\n");
|
(PVOID*)&ImageBase,
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
0,
|
||||||
PROCESS_ALL_ACCESS,
|
ViewSize,
|
||||||
PsProcessType,
|
NULL,
|
||||||
KernelMode,
|
&ViewSize,
|
||||||
(PVOID*)&Process,
|
0,
|
||||||
NULL);
|
MEM_COMMIT,
|
||||||
if (!NT_SUCCESS(Status))
|
PAGE_READWRITE);
|
||||||
{
|
if (!NT_SUCCESS(Status))
|
||||||
DbgPrint("ObReferenceObjectByProcess() failed (Status %x)\n", Status);
|
{
|
||||||
return(Status);
|
DbgPrint("Image map view of section failed (Status %x)", Status);
|
||||||
}
|
return(Status);
|
||||||
|
}
|
||||||
/*
|
|
||||||
* map the dos header into the process
|
|
||||||
*/
|
|
||||||
DPRINT("Mapping view of section\n");
|
|
||||||
InitialViewSize = sizeof(IMAGE_DOS_HEADER);
|
|
||||||
ImageBase = NULL;
|
|
||||||
|
|
||||||
Status = ZwMapViewOfSection(SectionHandle,
|
|
||||||
ProcessHandle,
|
|
||||||
(PVOID*)&ImageBase,
|
|
||||||
0,
|
|
||||||
InitialViewSize,
|
|
||||||
NULL,
|
|
||||||
&InitialViewSize,
|
|
||||||
0,
|
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint("Image map view of section failed (Status %x)", Status);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Map the pe headers into the process
|
|
||||||
*/
|
|
||||||
DPRINT("Attaching to process\n");
|
|
||||||
KeAttachProcess(Process);
|
|
||||||
InitialViewSize = ((PIMAGE_DOS_HEADER)ImageBase)->e_lfanew +
|
|
||||||
sizeof(IMAGE_NT_HEADERS);
|
|
||||||
DPRINT("InitialViewSize %d\n", InitialViewSize);
|
|
||||||
KeDetachProcess();
|
|
||||||
|
|
||||||
DPRINT("Unmapping view of section\n");
|
|
||||||
Status = ZwUnmapViewOfSection(ProcessHandle,
|
|
||||||
ImageBase);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint("ZwUnmapViewOfSection failed (Status %x)\n", Status);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("Mapping view of section\n");
|
|
||||||
ImageBase = NULL;
|
|
||||||
Status = ZwMapViewOfSection(SectionHandle,
|
|
||||||
ProcessHandle,
|
|
||||||
(PVOID*)&ImageBase,
|
|
||||||
0,
|
|
||||||
InitialViewSize,
|
|
||||||
NULL,
|
|
||||||
&InitialViewSize,
|
|
||||||
0,
|
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint("Image map view of section failed (Status %x)", Status);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("ImageBase %x\n", ImageBase);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TBD
|
|
||||||
*/
|
|
||||||
DPRINT("Attaching to process\n");
|
|
||||||
KeAttachProcess(Process);
|
|
||||||
NTHeaders = RtlImageNtHeader(ImageBase);
|
|
||||||
DPRINT("NTHeaders %x\n", NTHeaders);
|
|
||||||
InitialViewSize = ((PIMAGE_DOS_HEADER)ImageBase)->e_lfanew +
|
|
||||||
sizeof(IMAGE_NT_HEADERS) +
|
|
||||||
(sizeof (IMAGE_SECTION_HEADER) * NTHeaders->FileHeader.NumberOfSections);
|
|
||||||
DPRINT("InitialViewSize %x\n", InitialViewSize);
|
|
||||||
FinalBase = (PVOID)NTHeaders->OptionalHeader.ImageBase;
|
|
||||||
DPRINT("FinalBase %x\n", FinalBase);
|
|
||||||
NumberOfSections = NTHeaders->FileHeader.NumberOfSections;
|
|
||||||
DPRINT("NrSections %d\n", NumberOfSections);
|
|
||||||
KeDetachProcess();
|
|
||||||
|
|
||||||
DPRINT("Unmapping view of section\n");
|
|
||||||
Status = ZwUnmapViewOfSection(ProcessHandle,
|
|
||||||
ImageBase);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint("ZwUnmapViewOfSection failed (Status %x)\n", Status);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageBase = FinalBase;
|
|
||||||
|
|
||||||
DPRINT("Mapping view of section\n");
|
|
||||||
Status = ZwMapViewOfSection(SectionHandle,
|
|
||||||
ProcessHandle,
|
|
||||||
(PVOID*)&ImageBase,
|
|
||||||
0,
|
|
||||||
InitialViewSize,
|
|
||||||
NULL,
|
|
||||||
&InitialViewSize,
|
|
||||||
0,
|
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint("Image map view of section failed (Status %x)", Status);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DPRINT("Mapping view of all sections\n");
|
|
||||||
for (i = 0; i < NumberOfSections; i++)
|
|
||||||
{
|
|
||||||
PIMAGE_SECTION_HEADER Sections;
|
|
||||||
LARGE_INTEGER Offset;
|
|
||||||
ULONG Base;
|
|
||||||
ULONG Size;
|
|
||||||
|
|
||||||
KeAttachProcess(Process);
|
|
||||||
Sections = (PIMAGE_SECTION_HEADER) SECHDROFFSET(ImageBase);
|
|
||||||
DPRINT("Sections %x\n", Sections);
|
|
||||||
Base = (ULONG)(Sections[i].VirtualAddress + ImageBase);
|
|
||||||
Offset.u.LowPart = Sections[i].PointerToRawData;
|
|
||||||
Offset.u.HighPart = 0;
|
|
||||||
Size = Sections[i].Misc.VirtualSize;
|
|
||||||
KeDetachProcess();
|
|
||||||
|
|
||||||
if( Offset.u.LowPart )
|
|
||||||
{ // map the section if it is initialized
|
|
||||||
Status = ZwMapViewOfSection(SectionHandle,
|
|
||||||
ProcessHandle,
|
|
||||||
(PVOID *)&Base,
|
|
||||||
0,
|
|
||||||
Size,
|
|
||||||
&Offset,
|
|
||||||
(PULONG)&Size,
|
|
||||||
0,
|
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint("Image map view of secion failed (Status %x)\n", Status);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// allocate the section if it is uninitialized
|
|
||||||
Status = NtAllocateVirtualMemory( ProcessHandle,
|
|
||||||
(PVOID *)&Base,
|
|
||||||
0,
|
|
||||||
&Size,
|
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE );
|
|
||||||
if( !NT_SUCCESS( Status ) )
|
|
||||||
{
|
|
||||||
DPRINT1( "Failed to allocate memory for uninitialized section\n" );
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("Returning\n");
|
|
||||||
*ReturnedImageBase = ImageBase;
|
*ReturnedImageBase = ImageBase;
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: cont.c,v 1.6 2001/01/08 02:14:05 dwelch Exp $
|
/* $Id: cont.c,v 1.7 2001/02/10 22:51:10 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -18,6 +18,17 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
VOID static
|
||||||
|
MmFreeContinuousPage(PVOID Context, PVOID Address)
|
||||||
|
{
|
||||||
|
ULONG PhysAddr;
|
||||||
|
|
||||||
|
PhysAddr = MmGetPhysicalAddressForProcess(NULL, Address);
|
||||||
|
if (PhysAddr != 0)
|
||||||
|
{
|
||||||
|
MmDereferencePage((PVOID)PhysAddr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME EXPORTED
|
* NAME EXPORTED
|
||||||
|
@ -74,7 +85,8 @@ MmAllocateContiguousMemory (IN ULONG NumberOfBytes,
|
||||||
MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
0,
|
0,
|
||||||
TRUE);
|
NULL,
|
||||||
|
NULL);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / 4096); i++)
|
for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / 4096); i++)
|
||||||
|
@ -116,7 +128,8 @@ MmFreeContiguousMemory(IN PVOID BaseAddress)
|
||||||
MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
0,
|
0,
|
||||||
TRUE);
|
MmFreeContinuousPage,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -358,6 +358,56 @@ VOID MmReferencePage(PVOID PhysicalAddress)
|
||||||
KeReleaseSpinLock(&PageListLock, oldIrql);
|
KeReleaseSpinLock(&PageListLock, oldIrql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
MmGetReferenceCountPage(PVOID PhysicalAddress)
|
||||||
|
{
|
||||||
|
ULONG Start = (ULONG)PhysicalAddress / PAGESIZE;
|
||||||
|
KIRQL oldIrql;
|
||||||
|
ULONG RCount;
|
||||||
|
|
||||||
|
DPRINT("MmGetReferenceCountPage(PhysicalAddress %x)\n", PhysicalAddress);
|
||||||
|
|
||||||
|
if (((ULONG)PhysicalAddress) == 0)
|
||||||
|
{
|
||||||
|
KeBugCheck(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&PageListLock, &oldIrql);
|
||||||
|
|
||||||
|
if (MM_PTYPE(MmPageArray[Start].Flags) != MM_PHYSICAL_PAGE_USED)
|
||||||
|
{
|
||||||
|
DbgPrint("Getting reference count for free page\n");
|
||||||
|
KeBugCheck(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
RCount = MmPageArray[Start].ReferenceCount;
|
||||||
|
|
||||||
|
KeReleaseSpinLock(&PageListLock, oldIrql);
|
||||||
|
return(RCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
MmIsUsablePage(PVOID PhysicalAddress)
|
||||||
|
{
|
||||||
|
ULONG Start = (ULONG)PhysicalAddress / PAGESIZE;
|
||||||
|
|
||||||
|
DPRINT("MmGetReferenceCountPage(PhysicalAddress %x)\n", PhysicalAddress);
|
||||||
|
|
||||||
|
if (((ULONG)PhysicalAddress) == 0)
|
||||||
|
{
|
||||||
|
KeBugCheck(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MM_PTYPE(MmPageArray[Start].Flags) != MM_PHYSICAL_PAGE_USED &&
|
||||||
|
MM_PTYPE(MmPageArray[Start].Flags) != MM_PHYSICAL_PAGE_BIOS)
|
||||||
|
{
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID MmDereferencePage(PVOID PhysicalAddress)
|
VOID MmDereferencePage(PVOID PhysicalAddress)
|
||||||
{
|
{
|
||||||
ULONG Start = (ULONG)PhysicalAddress / PAGESIZE;
|
ULONG Start = (ULONG)PhysicalAddress / PAGESIZE;
|
||||||
|
@ -377,27 +427,27 @@ VOID MmDereferencePage(PVOID PhysicalAddress)
|
||||||
DbgPrint("Dereferencing free page\n");
|
DbgPrint("Dereferencing free page\n");
|
||||||
KeBugCheck(0);
|
KeBugCheck(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MmStats.NrFreePages++;
|
|
||||||
MmStats.NrSystemPages--;
|
|
||||||
|
|
||||||
MmPageArray[Start].ReferenceCount--;
|
MmPageArray[Start].ReferenceCount--;
|
||||||
if (MmPageArray[Start].ReferenceCount == 0)
|
if (MmPageArray[Start].ReferenceCount == 0)
|
||||||
{
|
{
|
||||||
RemoveEntryList(&MmPageArray[Start].ListEntry);
|
MmStats.NrFreePages++;
|
||||||
if (MmPageArray[Start].LockCount > 0)
|
MmStats.NrSystemPages--;
|
||||||
{
|
RemoveEntryList(&MmPageArray[Start].ListEntry);
|
||||||
DbgPrint("Freeing locked page\n");
|
if (MmPageArray[Start].LockCount > 0)
|
||||||
KeBugCheck(0);
|
{
|
||||||
}
|
DbgPrint("Freeing locked page\n");
|
||||||
if (MmPageArray[Start].Flags != MM_PHYSICAL_PAGE_USED)
|
KeBugCheck(0);
|
||||||
{
|
}
|
||||||
DbgPrint("Freeing page with flags %x\n",
|
if (MmPageArray[Start].Flags != MM_PHYSICAL_PAGE_USED)
|
||||||
MmPageArray[Start].Flags);
|
{
|
||||||
KeBugCheck(0);
|
DbgPrint("Freeing page with flags %x\n",
|
||||||
}
|
MmPageArray[Start].Flags);
|
||||||
MmPageArray[Start].Flags = MM_PHYSICAL_PAGE_FREE;
|
KeBugCheck(0);
|
||||||
InsertTailList(&FreePageListHead, &MmPageArray[Start].ListEntry);
|
}
|
||||||
|
MmPageArray[Start].Flags = MM_PHYSICAL_PAGE_FREE;
|
||||||
|
InsertTailList(&FreePageListHead, &MmPageArray[Start].ListEntry);
|
||||||
}
|
}
|
||||||
KeReleaseSpinLock(&PageListLock, oldIrql);
|
KeReleaseSpinLock(&PageListLock, oldIrql);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: page.c,v 1.18 2001/02/06 00:11:19 dwelch Exp $
|
/* $Id: page.c,v 1.19 2001/02/10 22:51:11 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top directory
|
* COPYRIGHT: See COPYING in the top directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -30,10 +30,14 @@
|
||||||
#define PA_BIT_ACCESSED (5)
|
#define PA_BIT_ACCESSED (5)
|
||||||
#define PA_BIT_DIRTY (6)
|
#define PA_BIT_DIRTY (6)
|
||||||
|
|
||||||
#define PA_PRESENT (1 << PA_BIT_PRESENT)
|
#define PA_PRESENT (1 << PA_BIT_PRESENT)
|
||||||
#define PA_DIRTY (1 << PA_BIT_DIRTY)
|
#define PA_READWRITE (1 << PA_BIT_READWRITE)
|
||||||
#define PA_WT (1 << PA_BIT_WT)
|
#define PA_USER (1 << PA_BIT_USER)
|
||||||
#define PA_CD (1 << PA_BIT_CD)
|
#define PA_DIRTY (1 << PA_BIT_DIRTY)
|
||||||
|
#define PA_WT (1 << PA_BIT_WT)
|
||||||
|
#define PA_CD (1 << PA_BIT_CD)
|
||||||
|
#define PA_ACCESSED (1 << PA_BIT_ACCESSED)
|
||||||
|
#define PA_DIRTY (1 << PA_BIT_DIRTY)
|
||||||
|
|
||||||
#define PAGETABLE_MAP (0xf0000000)
|
#define PAGETABLE_MAP (0xf0000000)
|
||||||
#define PAGEDIRECTORY_MAP (0xf0000000 + (PAGETABLE_MAP / (1024)))
|
#define PAGEDIRECTORY_MAP (0xf0000000 + (PAGETABLE_MAP / (1024)))
|
||||||
|
@ -60,22 +64,22 @@ ProtectToPTE(ULONG flProtect)
|
||||||
}
|
}
|
||||||
if (flProtect & PAGE_READWRITE || flProtect & PAGE_EXECUTE_READWRITE)
|
if (flProtect & PAGE_READWRITE || flProtect & PAGE_EXECUTE_READWRITE)
|
||||||
{
|
{
|
||||||
Attributes = PA_WRITE;
|
Attributes = PA_PRESENT | PA_READWRITE;
|
||||||
}
|
}
|
||||||
if (flProtect & PAGE_READONLY || flProtect & PAGE_EXECUTE ||
|
if (flProtect & PAGE_READONLY || flProtect & PAGE_EXECUTE ||
|
||||||
flProtect & PAGE_EXECUTE_READ)
|
flProtect & PAGE_EXECUTE_READ)
|
||||||
{
|
{
|
||||||
Attributes = PA_READ;
|
Attributes = PA_PRESENT;
|
||||||
}
|
}
|
||||||
if (!(flProtect & PAGE_SYSTEM))
|
if (!(flProtect & PAGE_SYSTEM))
|
||||||
{
|
{
|
||||||
Attributes = Attributes | PA_USER;
|
Attributes = Attributes | PA_USER;
|
||||||
}
|
}
|
||||||
if (!(flProtect & PAGE_NOCACHE))
|
if (flProtect & PAGE_NOCACHE)
|
||||||
{
|
{
|
||||||
Attributes = Attributes | PA_CD;
|
Attributes = Attributes | PA_CD;
|
||||||
}
|
}
|
||||||
if (!(flProtect & PAGE_WRITETHROUGH))
|
if (flProtect & PAGE_WRITETHROUGH)
|
||||||
{
|
{
|
||||||
Attributes = Attributes | PA_WT;
|
Attributes = Attributes | PA_WT;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +293,8 @@ VOID MmDeleteVirtualMapping(PEPROCESS Process, PVOID Address, BOOL FreePage)
|
||||||
PULONG Pte;
|
PULONG Pte;
|
||||||
PULONG Pde;
|
PULONG Pde;
|
||||||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
||||||
|
BOOLEAN WasValid;
|
||||||
|
|
||||||
if (Process != NULL && Process != CurrentProcess)
|
if (Process != NULL && Process != CurrentProcess)
|
||||||
{
|
{
|
||||||
KeAttachProcess(Process);
|
KeAttachProcess(Process);
|
||||||
|
@ -304,12 +309,13 @@ VOID MmDeleteVirtualMapping(PEPROCESS Process, PVOID Address, BOOL FreePage)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pte = ADDR_TO_PTE(Address);
|
Pte = ADDR_TO_PTE(Address);
|
||||||
if (FreePage && PAGE_MASK(*Pte) != 0)
|
WasValid = (PAGE_MASK(*Pte) != 0);
|
||||||
|
if (FreePage && WasValid)
|
||||||
{
|
{
|
||||||
MmDereferencePage((PVOID)PAGE_MASK(*Pte));
|
MmDereferencePage((PVOID)PAGE_MASK(*Pte));
|
||||||
}
|
}
|
||||||
*Pte = 0;
|
*Pte = 0;
|
||||||
if (Process != NULL &&
|
if (Process != NULL && WasValid &&
|
||||||
Process->AddressSpace.PageTableRefCountTable != NULL &&
|
Process->AddressSpace.PageTableRefCountTable != NULL &&
|
||||||
ADDR_TO_PAGE_TABLE(Address) < 768)
|
ADDR_TO_PAGE_TABLE(Address) < 768)
|
||||||
{
|
{
|
||||||
|
@ -318,10 +324,12 @@ VOID MmDeleteVirtualMapping(PEPROCESS Process, PVOID Address, BOOL FreePage)
|
||||||
Ptrc = Process->AddressSpace.PageTableRefCountTable;
|
Ptrc = Process->AddressSpace.PageTableRefCountTable;
|
||||||
|
|
||||||
Ptrc[ADDR_TO_PAGE_TABLE(Address)]--;
|
Ptrc[ADDR_TO_PAGE_TABLE(Address)]--;
|
||||||
|
#if 0
|
||||||
if (Ptrc[ADDR_TO_PAGE_TABLE(Address)] == 0)
|
if (Ptrc[ADDR_TO_PAGE_TABLE(Address)] == 0)
|
||||||
{
|
{
|
||||||
MmFreePageTable(Process, Address);
|
MmFreePageTable(Process, Address);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (Process != NULL && Process != CurrentProcess)
|
if (Process != NULL && Process != CurrentProcess)
|
||||||
{
|
{
|
||||||
|
@ -431,6 +439,11 @@ NTSTATUS MmCreateVirtualMapping(PEPROCESS Process,
|
||||||
PULONG Pte;
|
PULONG Pte;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
if (!MmIsUsablePage((PVOID)PhysicalAddress))
|
||||||
|
{
|
||||||
|
KeBugCheck(0);
|
||||||
|
}
|
||||||
|
|
||||||
Attributes = ProtectToPTE(flProtect);
|
Attributes = ProtectToPTE(flProtect);
|
||||||
|
|
||||||
if (Process != NULL && Process != CurrentProcess)
|
if (Process != NULL && Process != CurrentProcess)
|
||||||
|
@ -467,6 +480,29 @@ NTSTATUS MmCreateVirtualMapping(PEPROCESS Process,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
MmGetPageProtect(PEPROCESS Process, PVOID Address)
|
||||||
|
{
|
||||||
|
ULONG Entry;
|
||||||
|
ULONG Protect;
|
||||||
|
|
||||||
|
Entry = MmGetPageEntryForProcess1(Process, Address);
|
||||||
|
|
||||||
|
if (!(Entry & PA_PRESENT))
|
||||||
|
{
|
||||||
|
Protect = PAGE_NOACCESS;
|
||||||
|
}
|
||||||
|
else if (Entry & PA_READWRITE)
|
||||||
|
{
|
||||||
|
Protect = PAGE_READWRITE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Protect = PAGE_EXECUTE_READ;
|
||||||
|
}
|
||||||
|
return(Protect);
|
||||||
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
MmSetPageProtect(PEPROCESS Process, PVOID Address, ULONG flProtect)
|
MmSetPageProtect(PEPROCESS Process, PVOID Address, ULONG flProtect)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: iospace.c,v 1.7 2001/01/08 02:14:05 dwelch Exp $
|
/* $Id: iospace.c,v 1.8 2001/02/10 22:51:10 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -121,7 +121,8 @@ VOID STDCALL MmUnmapIoSpace (IN PVOID BaseAddress,
|
||||||
(VOID)MmFreeMemoryArea(&PsGetCurrentProcess()->AddressSpace,
|
(VOID)MmFreeMemoryArea(&PsGetCurrentProcess()->AddressSpace,
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
NumberOfBytes,
|
NumberOfBytes,
|
||||||
FALSE);
|
NULL,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: kmap.c,v 1.5 2001/01/08 02:14:06 dwelch Exp $
|
/* $Id: kmap.c,v 1.6 2001/02/10 22:51:10 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -51,20 +51,27 @@ ExUnmapPage(PVOID Addr)
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
ExAllocatePage(VOID)
|
ExAllocatePage(VOID)
|
||||||
|
{
|
||||||
|
ULONG PhysPage;
|
||||||
|
|
||||||
|
PhysPage = (ULONG)MmAllocPage(0);
|
||||||
|
DPRINT("Allocated page %x\n",PhysPage);
|
||||||
|
if (PhysPage == 0)
|
||||||
|
{
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(ExAllocatePageWithPhysPage(PhysPage));
|
||||||
|
}
|
||||||
|
|
||||||
|
PVOID
|
||||||
|
ExAllocatePageWithPhysPage(ULONG PhysPage)
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
ULONG addr;
|
ULONG addr;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
ULONG PhysPage;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
PhysPage = (ULONG)MmAllocPage(0);
|
|
||||||
DPRINT("Allocated page %x\n",PhysPage);
|
|
||||||
if (PhysPage == 0)
|
|
||||||
{
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
KeAcquireSpinLock(&AllocMapLock, &oldlvl);
|
KeAcquireSpinLock(&AllocMapLock, &oldlvl);
|
||||||
for (i=1; i<ALLOC_MAP_SIZE;i++)
|
for (i=1; i<ALLOC_MAP_SIZE;i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -269,14 +269,15 @@ NTSTATUS MmInitMemoryAreas(VOID)
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
|
NTSTATUS
|
||||||
PVOID BaseAddress,
|
MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
|
||||||
ULONG Length,
|
PVOID BaseAddress,
|
||||||
BOOLEAN FreePages)
|
ULONG Length,
|
||||||
|
VOID (*FreePage)(PVOID Context, PVOID Address),
|
||||||
|
PVOID FreePageContext)
|
||||||
{
|
{
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
LARGE_INTEGER PhysicalAddr;
|
|
||||||
|
|
||||||
DPRINT("MmFreeMemoryArea(AddressSpace %x, BaseAddress %x, Length %x,"
|
DPRINT("MmFreeMemoryArea(AddressSpace %x, BaseAddress %x, Length %x,"
|
||||||
"FreePages %d)\n",AddressSpace,BaseAddress,Length,FreePages);
|
"FreePages %d)\n",AddressSpace,BaseAddress,Length,FreePages);
|
||||||
|
@ -288,16 +289,12 @@ NTSTATUS MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
|
||||||
KeBugCheck(0);
|
KeBugCheck(0);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
if (FreePages)
|
if (FreePage != NULL)
|
||||||
{
|
{
|
||||||
for (i=0;i<=(MemoryArea->Length/PAGESIZE);i++)
|
for (i=0;i<=(MemoryArea->Length/PAGESIZE);i++)
|
||||||
{
|
{
|
||||||
PhysicalAddr = MmGetPhysicalAddress(MemoryArea->BaseAddress +
|
FreePage(FreePageContext,
|
||||||
(i*PAGESIZE));
|
MemoryArea->BaseAddress + (i * PAGESIZE));
|
||||||
if (PhysicalAddr.u.LowPart != 0)
|
|
||||||
{
|
|
||||||
MmDereferencePage((PVOID)(ULONG)(PhysicalAddr.u.LowPart));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=0; i<=(MemoryArea->Length/PAGESIZE); i++)
|
for (i=0; i<=(MemoryArea->Length/PAGESIZE); i++)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: mdl.c,v 1.27 2001/01/08 02:14:06 dwelch Exp $
|
/* $Id: mdl.c,v 1.28 2001/02/10 22:51:10 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -60,15 +60,12 @@ VOID STDCALL MmUnlockPages(PMDL Mdl)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MmLockAddressSpace(&Mdl->Process->AddressSpace);
|
|
||||||
|
|
||||||
MdlPages = (PULONG)(Mdl + 1);
|
MdlPages = (PULONG)(Mdl + 1);
|
||||||
for (i=0; i<(PAGE_ROUND_UP(Mdl->ByteCount+Mdl->ByteOffset)/PAGESIZE); i++)
|
for (i=0; i<(PAGE_ROUND_UP(Mdl->ByteCount+Mdl->ByteOffset)/PAGESIZE); i++)
|
||||||
{
|
{
|
||||||
MmUnlockPage((PVOID)MdlPages[i]);
|
MmUnlockPage((PVOID)MdlPages[i]);
|
||||||
MmDereferencePage((PVOID)MdlPages[i]);
|
MmDereferencePage((PVOID)MdlPages[i]);
|
||||||
}
|
}
|
||||||
MmUnlockAddressSpace(&Mdl->Process->AddressSpace);
|
|
||||||
Mdl->MdlFlags = Mdl->MdlFlags & (~MDL_PAGES_LOCKED);
|
Mdl->MdlFlags = Mdl->MdlFlags & (~MDL_PAGES_LOCKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +138,8 @@ VOID STDCALL MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl)
|
||||||
(VOID)MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
(VOID)MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
||||||
BaseAddress - Mdl->ByteOffset,
|
BaseAddress - Mdl->ByteOffset,
|
||||||
Mdl->ByteCount,
|
Mdl->ByteCount,
|
||||||
FALSE);
|
NULL,
|
||||||
|
NULL);
|
||||||
Mdl->MdlFlags = Mdl->MdlFlags & ~MDL_MAPPED_TO_SYSTEM_VA;
|
Mdl->MdlFlags = Mdl->MdlFlags & ~MDL_MAPPED_TO_SYSTEM_VA;
|
||||||
Mdl->MappedSystemVa = NULL;
|
Mdl->MappedSystemVa = NULL;
|
||||||
MmUnlockAddressSpace(MmGetKernelAddressSpace());
|
MmUnlockAddressSpace(MmGetKernelAddressSpace());
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: mm.c,v 1.40 2001/01/08 02:14:06 dwelch Exp $
|
/* $Id: mm.c,v 1.41 2001/02/10 22:51:10 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top directory
|
* COPYRIGHT: See COPYING in the top directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -41,20 +41,30 @@ NTSTATUS MmReleaseMemoryArea(PEPROCESS Process, PMEMORY_AREA Marea)
|
||||||
DPRINT("Releasing %x between %x %x\n",
|
DPRINT("Releasing %x between %x %x\n",
|
||||||
Marea, Marea->BaseAddress, Marea->BaseAddress + Marea->Length);
|
Marea, Marea->BaseAddress, Marea->BaseAddress + Marea->Length);
|
||||||
|
|
||||||
if (Marea->Type == MEMORY_AREA_SECTION_VIEW_COMMIT ||
|
switch (Marea->Type)
|
||||||
Marea->Type == MEMORY_AREA_SECTION_VIEW_RESERVE)
|
|
||||||
{
|
{
|
||||||
MmUnmapViewOfSection(Process, Marea);
|
case MEMORY_AREA_SECTION_VIEW_COMMIT:
|
||||||
|
case MEMORY_AREA_SECTION_VIEW_RESERVE:
|
||||||
|
MmUnmapViewOfSection(Process, Marea->BaseAddress);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
|
||||||
|
case MEMORY_AREA_VIRTUAL_MEMORY:
|
||||||
|
for (i = Marea->BaseAddress;
|
||||||
|
i < (Marea->BaseAddress + Marea->Length);
|
||||||
|
i = i + PAGESIZE)
|
||||||
|
{
|
||||||
|
MmDeleteVirtualMapping(Process, i, TRUE);
|
||||||
|
}
|
||||||
|
ExFreePool(Marea);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MEMORY_AREA_SHARED_DATA:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
KeBugCheck(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = Marea->BaseAddress;
|
|
||||||
i < (Marea->BaseAddress + Marea->Length);
|
|
||||||
i = i+PAGESIZE)
|
|
||||||
{
|
|
||||||
MmDeleteVirtualMapping(Process, i, TRUE);
|
|
||||||
}
|
|
||||||
ExFreePool(Marea);
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +79,7 @@ NTSTATUS MmReleaseMmInfo(PEPROCESS Process)
|
||||||
|
|
||||||
while (!IsListEmpty(&Process->AddressSpace.MAreaListHead))
|
while (!IsListEmpty(&Process->AddressSpace.MAreaListHead))
|
||||||
{
|
{
|
||||||
CurrentEntry = RemoveHeadList(
|
CurrentEntry = RemoveHeadList(&Process->AddressSpace.MAreaListHead);
|
||||||
&Process->AddressSpace.MAreaListHead);
|
|
||||||
Current = CONTAINING_RECORD(CurrentEntry, MEMORY_AREA, Entry);
|
Current = CONTAINING_RECORD(CurrentEntry, MEMORY_AREA, Entry);
|
||||||
|
|
||||||
MmReleaseMemoryArea(Process, Current);
|
MmReleaseMemoryArea(Process, Current);
|
||||||
|
@ -122,7 +131,79 @@ BOOLEAN STDCALL MmIsAddressValid(PVOID VirtualAddress)
|
||||||
NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
|
NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
|
||||||
ULONG Address)
|
ULONG Address)
|
||||||
{
|
{
|
||||||
return(STATUS_UNSUCCESSFUL);
|
PMADDRESS_SPACE AddressSpace;
|
||||||
|
MEMORY_AREA* MemoryArea;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
|
||||||
|
|
||||||
|
if (KeGetCurrentIrql() >= DISPATCH_LEVEL)
|
||||||
|
{
|
||||||
|
DbgPrint("Page fault at high IRQL was %d\n", KeGetCurrentIrql());
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
if (PsGetCurrentProcess() == NULL)
|
||||||
|
{
|
||||||
|
DbgPrint("No current process\n");
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Find the memory area for the faulting address
|
||||||
|
*/
|
||||||
|
if (Address >= KERNEL_BASE)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Check permissions
|
||||||
|
*/
|
||||||
|
if (Mode != KernelMode)
|
||||||
|
{
|
||||||
|
DbgPrint("%s:%d\n",__FILE__,__LINE__);
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
AddressSpace = MmGetKernelAddressSpace();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddressSpace = &PsGetCurrentProcess()->AddressSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace, (PVOID)Address);
|
||||||
|
if (MemoryArea == NULL)
|
||||||
|
{
|
||||||
|
DbgPrint("%s:%d\n",__FILE__,__LINE__);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (MemoryArea->Type)
|
||||||
|
{
|
||||||
|
case MEMORY_AREA_SYSTEM:
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MEMORY_AREA_SECTION_VIEW_COMMIT:
|
||||||
|
Status = MmAccessFaultSectionView(AddressSpace,
|
||||||
|
MemoryArea,
|
||||||
|
(PVOID)Address);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MEMORY_AREA_VIRTUAL_MEMORY:
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MEMORY_AREA_SHARED_DATA:
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DPRINT("Completed page fault handling\n");
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
|
NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: ncache.c,v 1.7 2001/01/08 02:14:06 dwelch Exp $
|
/* $Id: ncache.c,v 1.8 2001/02/10 22:51:10 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -80,7 +80,17 @@ MmAllocateNonCachedMemory(IN ULONG NumberOfBytes)
|
||||||
return ((PVOID)Result);
|
return ((PVOID)Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID static
|
||||||
|
MmFreeNonCachedPage(PVOID Context, PVOID Address)
|
||||||
|
{
|
||||||
|
ULONG PhysAddr;
|
||||||
|
|
||||||
|
PhysAddr = MmGetPhysicalAddressForProcess(NULL, Address);
|
||||||
|
if (PhysAddr != 0)
|
||||||
|
{
|
||||||
|
MmDereferencePage((PVOID)PhysAddr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME EXPORTED
|
* NAME EXPORTED
|
||||||
|
@ -113,7 +123,8 @@ VOID STDCALL MmFreeNonCachedMemory (IN PVOID BaseAddress,
|
||||||
MmFreeMemoryArea (MmGetKernelAddressSpace(),
|
MmFreeMemoryArea (MmGetKernelAddressSpace(),
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
NumberOfBytes,
|
NumberOfBytes,
|
||||||
TRUE);
|
MmFreeNonCachedPage,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: virtual.c,v 1.37 2001/01/21 14:54:29 dwelch Exp $
|
/* $Id: virtual.c,v 1.38 2001/02/10 22:51:10 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top directory
|
* COPYRIGHT: See COPYING in the top directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -1013,7 +1013,8 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
MmFreeMemoryArea(&Process->AddressSpace,
|
MmFreeMemoryArea(&Process->AddressSpace,
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
0,
|
0,
|
||||||
FALSE);
|
NULL,
|
||||||
|
NULL);
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: thread.c,v 1.68 2001/01/28 17:38:40 ekohl Exp $
|
/* $Id: thread.c,v 1.69 2001/02/10 22:51:11 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -114,8 +114,8 @@ VOID PsDumpThreads(VOID)
|
||||||
DbgPrint("current %x current->Tcb.State %d eip %x/%x ",
|
DbgPrint("current %x current->Tcb.State %d eip %x/%x ",
|
||||||
current, current->Tcb.State,
|
current, current->Tcb.State,
|
||||||
0, current->Tcb.LastEip);
|
0, current->Tcb.LastEip);
|
||||||
// KeDumpStackFrames((PVOID)current->Tcb.Context.esp0,
|
KeDumpStackFrames((PVOID)current->Tcb.KernelStack,
|
||||||
// 16);
|
16);
|
||||||
DbgPrint("PID %d ", current->ThreadsProcess->UniqueProcessId);
|
DbgPrint("PID %d ", current->ThreadsProcess->UniqueProcessId);
|
||||||
DbgPrint("\n");
|
DbgPrint("\n");
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: regio.c,v 1.2 2000/05/09 21:30:27 ekohl Exp $
|
/* $Id: regio.c,v 1.3 2001/02/10 22:51:11 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -155,4 +155,4 @@ WRITE_REGISTER_BUFFER_ULONG (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -18,6 +18,7 @@ endif
|
||||||
ifeq ($(HOST),mingw32-linux)
|
ifeq ($(HOST),mingw32-linux)
|
||||||
NASM_FORMAT = win32
|
NASM_FORMAT = win32
|
||||||
PREFIX = i586-mingw32-
|
PREFIX = i586-mingw32-
|
||||||
|
#PREFIX = /usr/mingw32-cvs-000207/bin/mingw32-cvs-000207-
|
||||||
EXE_POSTFIX =
|
EXE_POSTFIX =
|
||||||
EXE_PREFIX = ./
|
EXE_PREFIX = ./
|
||||||
#CP = cp
|
#CP = cp
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue