mirror of
https://github.com/reactos/reactos.git
synced 2024-08-29 22:58:34 +00:00
More bug fixes.
svn path=/trunk/; revision=1158
This commit is contained in:
parent
1001fb267c
commit
3e519811c4
|
@ -26,8 +26,10 @@ enum
|
||||||
MEMORY_AREA_CACHE_SEGMENT,
|
MEMORY_AREA_CACHE_SEGMENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) ((x) / (4*1024*1024))
|
#define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
|
||||||
#define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) (((x) % 4*1024*1024) / (4*1024))
|
((x) / (4*1024*1024))
|
||||||
|
#define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
|
||||||
|
((((x)) % (4*1024*1024)) / (4*1024))
|
||||||
|
|
||||||
#define NR_SECTION_PAGE_TABLES (1024)
|
#define NR_SECTION_PAGE_TABLES (1024)
|
||||||
#define NR_SECTION_PAGE_ENTRIES (1024)
|
#define NR_SECTION_PAGE_ENTRIES (1024)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: startup.c,v 1.22 2000/03/22 18:35:51 dwelch Exp $
|
/* $Id: startup.c,v 1.23 2000/05/24 22:29:35 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,7 +18,7 @@
|
||||||
#include <csrss/csrss.h>
|
#include <csrss/csrss.h>
|
||||||
#include <ntdll/csr.h>
|
#include <ntdll/csr.h>
|
||||||
|
|
||||||
#define NDEBUG
|
//#define NDEBUG
|
||||||
#include <ntdll/ntdll.h>
|
#include <ntdll/ntdll.h>
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
@ -57,7 +57,7 @@ VOID LdrStartup(VOID)
|
||||||
if (ImageBase <= (PVOID)0x1000)
|
if (ImageBase <= (PVOID)0x1000)
|
||||||
{
|
{
|
||||||
DPRINT("ImageBase is null\n");
|
DPRINT("ImageBase is null\n");
|
||||||
for(;;);
|
ZwTerminateProcess(NtCurrentProcess(), STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
NtGlobalFlag = Peb->NtGlobalFlag;
|
NtGlobalFlag = Peb->NtGlobalFlag;
|
||||||
|
@ -70,7 +70,7 @@ VOID LdrStartup(VOID)
|
||||||
*(PULONG)((PUCHAR)ImageBase + PEDosHeader->e_lfanew) != IMAGE_PE_MAGIC)
|
*(PULONG)((PUCHAR)ImageBase + PEDosHeader->e_lfanew) != IMAGE_PE_MAGIC)
|
||||||
{
|
{
|
||||||
DbgPrint("Image has bad header\n");
|
DbgPrint("Image has bad header\n");
|
||||||
ZwTerminateProcess(NULL, STATUS_UNSUCCESSFUL);
|
ZwTerminateProcess(NtCurrentProcess(), STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* normalize process parameters */
|
/* normalize process parameters */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: kdebug.c,v 1.10 2000/04/08 19:09:30 ekohl Exp $
|
/* $Id: kdebug.c,v 1.11 2000/05/24 22:29:36 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -43,7 +43,7 @@ KdDebuggerNotPresent = TRUE; /* EXPORTED */
|
||||||
|
|
||||||
static BOOLEAN KdpBreakPending = FALSE;
|
static BOOLEAN KdpBreakPending = FALSE;
|
||||||
static BOOLEAN KdpBreakRecieved = FALSE;
|
static BOOLEAN KdpBreakRecieved = FALSE;
|
||||||
static ULONG KdpDebugType = 0;
|
static ULONG KdpDebugType = BochsDebug;
|
||||||
|
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS ********************************************************/
|
/* PRIVATE FUNCTIONS ********************************************************/
|
||||||
|
@ -134,7 +134,7 @@ KdInitSystem (
|
||||||
if (Value > 0)
|
if (Value > 0)
|
||||||
{
|
{
|
||||||
KdDebuggerEnabled = TRUE;
|
KdDebuggerEnabled = TRUE;
|
||||||
KdpDebugType = SerialDebug;
|
KdpDebugType = KdpDebugType | SerialDebug;
|
||||||
PortInfo.BaudRate = Value;
|
PortInfo.BaudRate = Value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -152,7 +152,7 @@ KdInitSystem (
|
||||||
{
|
{
|
||||||
p2 += 5;
|
p2 += 5;
|
||||||
KdDebuggerEnabled = TRUE;
|
KdDebuggerEnabled = TRUE;
|
||||||
KdpDebugType = SerialDebug;
|
KdpDebugType = KdpDebugType | SerialDebug;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
p1 = p2;
|
p1 = p2;
|
||||||
|
|
|
@ -339,6 +339,20 @@ asmlinkage void exception_handler(unsigned int edi,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (MmIsPagePresent(NULL, (PVOID)eip))
|
||||||
|
{
|
||||||
|
char instrs[512];
|
||||||
|
|
||||||
|
memcpy(instrs, (PVOID)eip, 512);
|
||||||
|
|
||||||
|
DbgPrint("Instrs: ");
|
||||||
|
|
||||||
|
for (i=0; i<10; i++)
|
||||||
|
{
|
||||||
|
DbgPrint("%x ", instrs[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: usercall.c,v 1.11 2000/05/13 13:51:05 dwelch Exp $
|
/* $Id: usercall.c,v 1.12 2000/05/24 22:29:36 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -57,7 +57,7 @@ void PsBeginThreadWithContextInternal(void);
|
||||||
|
|
||||||
VOID KiSystemCallHook(ULONG Nr, ...)
|
VOID KiSystemCallHook(ULONG Nr, ...)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 0
|
||||||
va_list ap;
|
va_list ap;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: mm.c,v 1.29 2000/05/13 13:51:05 dwelch Exp $
|
/* $Id: mm.c,v 1.30 2000/05/24 22:29:36 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top directory
|
* COPYRIGHT: See COPYING in the top directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -146,7 +146,7 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT1("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
|
DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
|
||||||
|
|
||||||
if (KeGetCurrentIrql() >= DISPATCH_LEVEL)
|
if (KeGetCurrentIrql() >= DISPATCH_LEVEL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: section.c,v 1.30 2000/05/13 13:51:05 dwelch Exp $
|
/* $Id: section.c,v 1.31 2000/05/24 22:29:38 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -56,6 +56,8 @@ VOID MmSetPageEntrySection(PSECTION_OBJECT Section,
|
||||||
Table =
|
Table =
|
||||||
Section->PageDirectory.PageTables[DirectoryOffset] =
|
Section->PageDirectory.PageTables[DirectoryOffset] =
|
||||||
ExAllocatePool(NonPagedPool, sizeof(SECTION_PAGE_TABLE));
|
ExAllocatePool(NonPagedPool, sizeof(SECTION_PAGE_TABLE));
|
||||||
|
memset(Table, 0, sizeof(SECTION_PAGE_TABLE));
|
||||||
|
DPRINT("Table %x\n", Table);
|
||||||
}
|
}
|
||||||
TableOffset = PAGE_TO_SECTION_PAGE_TABLE_OFFSET(Offset);
|
TableOffset = PAGE_TO_SECTION_PAGE_TABLE_OFFSET(Offset);
|
||||||
Table->Pages[TableOffset] = Entry;
|
Table->Pages[TableOffset] = Entry;
|
||||||
|
@ -69,8 +71,11 @@ PVOID MmGetPageEntrySection(PSECTION_OBJECT Section,
|
||||||
ULONG DirectoryOffset;
|
ULONG DirectoryOffset;
|
||||||
ULONG TableOffset;
|
ULONG TableOffset;
|
||||||
|
|
||||||
|
DPRINT("MmGetPageEntrySection(Offset %x)\n", Offset);
|
||||||
|
|
||||||
DirectoryOffset = PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(Offset);
|
DirectoryOffset = PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(Offset);
|
||||||
Table = Section->PageDirectory.PageTables[DirectoryOffset];
|
Table = Section->PageDirectory.PageTables[DirectoryOffset];
|
||||||
|
DPRINT("Table %x\n", Table);
|
||||||
if (Table == NULL)
|
if (Table == NULL)
|
||||||
{
|
{
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
@ -80,6 +85,70 @@ PVOID MmGetPageEntrySection(PSECTION_OBJECT Section,
|
||||||
return(Entry);
|
return(Entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS MmOldLoadPageForSection(PMADDRESS_SPACE AddressSpace,
|
||||||
|
MEMORY_AREA* MemoryArea,
|
||||||
|
PVOID Address)
|
||||||
|
{
|
||||||
|
LARGE_INTEGER Offset;
|
||||||
|
IO_STATUS_BLOCK IoStatus;
|
||||||
|
PMDL Mdl;
|
||||||
|
PVOID Page;
|
||||||
|
NTSTATUS Status;
|
||||||
|
ULONG PAddress;
|
||||||
|
PSECTION_OBJECT Section;
|
||||||
|
|
||||||
|
DPRINT("MmOldLoadPageForSection(MemoryArea %x, Address %x)\n",
|
||||||
|
MemoryArea,Address);
|
||||||
|
|
||||||
|
if (MmIsPagePresent(NULL, Address))
|
||||||
|
{
|
||||||
|
DPRINT("Page is already present\n");
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
PAddress = (ULONG)PAGE_ROUND_DOWN(((ULONG)Address));
|
||||||
|
Offset.QuadPart = (PAddress - (ULONG)MemoryArea->BaseAddress) +
|
||||||
|
MemoryArea->Data.SectionData.ViewOffset;
|
||||||
|
|
||||||
|
DPRINT("MemoryArea->BaseAddress %x\n", MemoryArea->BaseAddress);
|
||||||
|
DPRINT("MemoryArea->Data.SectionData.ViewOffset %x\n",
|
||||||
|
MemoryArea->Data.SectionData.ViewOffset);
|
||||||
|
DPRINT("Got offset %x\n", Offset.QuadPart);
|
||||||
|
|
||||||
|
Section = MemoryArea->Data.SectionData.Section;
|
||||||
|
|
||||||
|
DPRINT("Section %x\n", Section);
|
||||||
|
|
||||||
|
MmLockSection(Section);
|
||||||
|
|
||||||
|
Mdl = MmCreateMdl(NULL, NULL, PAGESIZE);
|
||||||
|
MmBuildMdlFromPages(Mdl);
|
||||||
|
Page = MmGetMdlPageAddress(Mdl, 0);
|
||||||
|
MmUnlockSection(Section);
|
||||||
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
|
DPRINT("Reading file offset %x\n", Offset.QuadPart);
|
||||||
|
Status = IoPageRead(MemoryArea->Data.SectionData.Section->FileObject,
|
||||||
|
Mdl,
|
||||||
|
&Offset,
|
||||||
|
&IoStatus);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
MmLockSection(Section);
|
||||||
|
|
||||||
|
MmSetPage(NULL,
|
||||||
|
Address,
|
||||||
|
MemoryArea->Attributes,
|
||||||
|
(ULONG)Page);
|
||||||
|
MmUnlockSection(Section);
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
MEMORY_AREA* MemoryArea,
|
MEMORY_AREA* MemoryArea,
|
||||||
PVOID Address)
|
PVOID Address)
|
||||||
|
@ -98,6 +167,7 @@ NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
|
|
||||||
if (MmIsPagePresent(NULL, Address))
|
if (MmIsPagePresent(NULL, Address))
|
||||||
{
|
{
|
||||||
|
DPRINT("Page is already present\n");
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,11 +175,25 @@ NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
Offset.QuadPart = (PAddress - (ULONG)MemoryArea->BaseAddress) +
|
Offset.QuadPart = (PAddress - (ULONG)MemoryArea->BaseAddress) +
|
||||||
MemoryArea->Data.SectionData.ViewOffset;
|
MemoryArea->Data.SectionData.ViewOffset;
|
||||||
|
|
||||||
|
if ((MemoryArea->Data.SectionData.ViewOffset % PAGESIZE) != 0)
|
||||||
|
{
|
||||||
|
return(MmOldLoadPageForSection(AddressSpace, MemoryArea, Address));
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("MemoryArea->BaseAddress %x\n", MemoryArea->BaseAddress);
|
||||||
|
DPRINT("MemoryArea->Data.SectionData.ViewOffset %x\n",
|
||||||
|
MemoryArea->Data.SectionData.ViewOffset);
|
||||||
|
DPRINT("Got offset %x\n", Offset.QuadPart);
|
||||||
|
|
||||||
Section = MemoryArea->Data.SectionData.Section;
|
Section = MemoryArea->Data.SectionData.Section;
|
||||||
|
|
||||||
|
DPRINT("Section %x\n", Section);
|
||||||
|
|
||||||
MmLockSection(Section);
|
MmLockSection(Section);
|
||||||
|
|
||||||
Entry = MmGetPageEntrySection(Section, Offset.QuadPart);
|
Entry = MmGetPageEntrySection(Section, Offset.u.LowPart);
|
||||||
|
|
||||||
|
DPRINT("Entry %x\n", Entry);
|
||||||
|
|
||||||
if (Entry == NULL)
|
if (Entry == NULL)
|
||||||
{
|
{
|
||||||
|
@ -118,6 +202,7 @@ NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
Page = MmGetMdlPageAddress(Mdl, 0);
|
Page = MmGetMdlPageAddress(Mdl, 0);
|
||||||
MmUnlockSection(Section);
|
MmUnlockSection(Section);
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
|
DPRINT("Reading file offset %x\n", Offset.QuadPart);
|
||||||
Status = IoPageRead(MemoryArea->Data.SectionData.Section->FileObject,
|
Status = IoPageRead(MemoryArea->Data.SectionData.Section->FileObject,
|
||||||
Mdl,
|
Mdl,
|
||||||
&Offset,
|
&Offset,
|
||||||
|
@ -294,6 +379,7 @@ NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle,
|
||||||
InitializeListHead(&Section->ViewListHead);
|
InitializeListHead(&Section->ViewListHead);
|
||||||
KeInitializeSpinLock(&Section->ViewListLock);
|
KeInitializeSpinLock(&Section->ViewListLock);
|
||||||
KeInitializeMutex(&Section->Lock, 0);
|
KeInitializeMutex(&Section->Lock, 0);
|
||||||
|
memset(&Section->PageDirectory, 0, sizeof(Section->PageDirectory));
|
||||||
|
|
||||||
if (FileHandle != (HANDLE)0xffffffff)
|
if (FileHandle != (HANDLE)0xffffffff)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue