2002-08-17 David Welch <welch@computer2.darkstar.org>

* ntoskrnl/ps/create.c (PiDeleteThread): Don't dereference
	the thread's process while holding the thread list lock.

2002-08-17  David Welch  <welch@computer2.darkstar.org>

	* ntoskrnl/mm/section.c (MmMapViewOfSection): Check there is
	enough space for all parts of an image before mapping it; if
	there isn't enough space free at the preferred base address
	then try to choose a different one.

2002-08-17  David Welch  <welch@computer2.darkstar.org>

	* ntoskrnl/mm/mpw.c (MmInitMpwThread): Run the MPW thread at
	idle priority.

2002-08-17  David Welch  <welch@computer2.darkstar.org>

	* ntoskrnl/mm/kmap.c (ExUnmapPage, ExAllocatePageWithPhysPage,
	MiFreeNonPagedPoolRegion, MiAllocNonPagedPoolRegion): Maintain
	a hint of the next free page; makes running with whole page
	allocation more bearable.

2002-08-17  David Welch  <welch@computer2.darkstar.org>

	* ntoskrnl/mm/anonmem.c (MmPageOutVirtualMemory): Show an
	out of swap space message if we are out of swap space.
	* ntoskrnl/mm/section.c (MmPageOutSectionView): Show an
	out of swap space message if we are out of swap space.
	* ntoskrnl/mm/pagefile.c (MmAllocSwapPage): Don't automatically
	show an out of swap space message on failure.
	* ntoskrnl/mm/pagefile.c (MmShowOutOfSpaceMessagePagingFile): New
	function to notify the user that the pagefile is full.

2002-08-17  David Welch  <welch@computer2.darkstar.org>

	* drivers/lib/zlib/Makefile: Create a dummy zlib.sym

svn path=/trunk/; revision=3335
This commit is contained in:
David Welch 2002-08-17 01:42:03 +00:00
parent 1052bedeed
commit 1a46ca7d8a
12 changed files with 210 additions and 160 deletions

View file

@ -1,3 +1,42 @@
2002-08-17 David Welch <welch@computer2.darkstar.org>
* ntoskrnl/ps/create.c (PiDeleteThread): Don't dereference
the thread's process while holding the thread list lock.
2002-08-17 David Welch <welch@computer2.darkstar.org>
* ntoskrnl/mm/section.c (MmMapViewOfSection): Check there is
enough space for all parts of an image before mapping it; if
there isn't enough space free at the preferred base address
then try to choose a different one.
2002-08-17 David Welch <welch@computer2.darkstar.org>
* ntoskrnl/mm/mpw.c (MmInitMpwThread): Run the MPW thread at
idle priority.
2002-08-17 David Welch <welch@computer2.darkstar.org>
* ntoskrnl/mm/kmap.c (ExUnmapPage, ExAllocatePageWithPhysPage,
MiFreeNonPagedPoolRegion, MiAllocNonPagedPoolRegion): Maintain
a hint of the next free page; makes running with whole page
allocation more bearable.
2002-08-17 David Welch <welch@computer2.darkstar.org>
* ntoskrnl/mm/anonmem.c (MmPageOutVirtualMemory): Show an
out of swap space message if we are out of swap space.
* ntoskrnl/mm/section.c (MmPageOutSectionView): Show an
out of swap space message if we are out of swap space.
* ntoskrnl/mm/pagefile.c (MmAllocSwapPage): Don't automatically
show an out of swap space message on failure.
* ntoskrnl/mm/pagefile.c (MmShowOutOfSpaceMessagePagingFile): New
function to notify the user that the pagefile is full.
2002-08-17 David Welch <welch@computer2.darkstar.org>
* drivers/lib/zlib/Makefile: Create a dummy zlib.sym
2002-08-16 David Welch <welch@computer2.darkstar.org>
* ntoskrnl/mm/npool.c (ExAllocateWholePageBlock): Converted

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.4 2002/06/16 06:05:28 sedwards Exp $
# $Id: Makefile,v 1.5 2002/08/17 01:42:01 dwelch Exp $
PATH_TO_TOP = ../../..
@ -18,6 +18,9 @@ include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
zlib.sym:
@echo FIXME!>$@
# FIXME: this rule should be defined in helper.mk
$(TARGET_NAME).nostrip.a:
@echo FIXME!

View file

@ -288,7 +288,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
MEMORY_AREA* MmOpenMemoryAreaByRegion(PMADDRESS_SPACE AddressSpace,
PVOID Address,
ULONG Length);
PVOID MmFindGap(PMADDRESS_SPACE AddressSpace, ULONG Length);
VOID ExUnmapPage(PVOID Addr);
PVOID ExAllocatePage(VOID);
@ -604,5 +604,7 @@ MmIsDirtyPageRmap(PHYSICAL_ADDRESS PhysicalAddress);
NTSTATUS MmInitMpwThread(VOID);
BOOLEAN
MmIsAvailableSwapPage(VOID);
VOID
MmShowOutOfSpaceMessagePagingFile(VOID);
#endif

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: ps.h,v 1.40 2002/08/16 01:39:16 dwelch Exp $
/* $Id: ps.h,v 1.41 2002/08/17 01:42:02 dwelch Exp $
*
* FILE: ntoskrnl/ke/kthread.c
* PURPOSE: Process manager definitions
@ -419,7 +419,6 @@ VOID PiKillMostProcesses(VOID);
NTSTATUS STDCALL PiTerminateProcess(PEPROCESS Process, NTSTATUS ExitStatus);
VOID PiInitApcManagement(VOID);
VOID STDCALL PiDeleteThread(PVOID ObjectBody);
VOID STDCALL PiCloseThread(PVOID ObjectBody, ULONG HandleCount);
VOID PsReapThreads(VOID);
NTSTATUS
PsInitializeThread(HANDLE ProcessHandle,

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: anonmem.c,v 1.2 2002/08/14 20:58:36 dwelch Exp $
/* $Id: anonmem.c,v 1.3 2002/08/17 01:42:02 dwelch Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/anonmem.c
@ -187,6 +187,7 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
SwapEntry = MmAllocSwapPage();
if (SwapEntry == 0)
{
MmShowOutOfSpaceMessagePagingFile();
MmEnableVirtualMapping(MemoryArea->Process, Address);
PageOp->Status = STATUS_UNSUCCESSFUL;
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);

View file

@ -1,4 +1,4 @@
/* $Id: kmap.c,v 1.17 2002/06/04 15:26:56 dwelch Exp $
/* $Id: kmap.c,v 1.18 2002/08/17 01:42:02 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -13,6 +13,7 @@
#include <internal/mm.h>
#include <internal/ntoskrnl.h>
#include <internal/pool.h>
#include <ntos/minmax.h>
#define NDEBUG
#include <internal/debug.h>
@ -25,8 +26,9 @@
* One bit for each page in the kmalloc region
* If set then the page is used by a kmalloc block
*/
static unsigned int AllocMap[ALLOC_MAP_SIZE/32]={0,};
static ULONG AllocMap[ALLOC_MAP_SIZE/32]={0,};
static KSPIN_LOCK AllocMapLock;
static ULONG AllocMapHint = 1;
static PVOID NonPagedPoolBase;
@ -41,9 +43,10 @@ ExUnmapPage(PVOID Addr)
DPRINT("ExUnmapPage(Addr %x)\n",Addr);
DPRINT("i %x\n",i);
KeAcquireSpinLock(&AllocMapLock, &oldIrql);
MmDeleteVirtualMapping(NULL, (PVOID)Addr, FALSE, NULL, NULL);
KeAcquireSpinLock(&AllocMapLock, &oldIrql);
AllocMap[i / 32] &= (~(1 << (i % 32)));
AllocMapHint = min(AllocMapHint, i);
KeReleaseSpinLock(&AllocMapLock, oldIrql);
}
@ -101,12 +104,13 @@ ExAllocatePageWithPhysPage(PHYSICAL_ADDRESS PhysPage)
NTSTATUS Status;
KeAcquireSpinLock(&AllocMapLock, &oldlvl);
for (i = 1; i < ALLOC_MAP_SIZE; i++)
for (i = AllocMapHint; i < ALLOC_MAP_SIZE; i++)
{
if (!(AllocMap[i / 32] & (1 << (i % 32))))
{
DPRINT("i %x\n",i);
AllocMap[i / 32] |= (1 << (i % 32));
AllocMapHint = i + 1;
addr = (ULONG)(NonPagedPoolBase + (i*PAGESIZE));
Status = MmCreateVirtualMapping(NULL,
(PVOID)addr,
@ -142,10 +146,11 @@ MiFreeNonPagedPoolRegion(PVOID Addr, ULONG Count, BOOLEAN Free)
KIRQL oldlvl;
KeAcquireSpinLock(&AllocMapLock, &oldlvl);
AllocMapHint = min(AllocMapHint, Base);
for (i = 0; i < Count; i++)
{
Offset = Base + i;
AllocMap[Offset / 32] &= (~(1 << (Offset % 32)));
AllocMap[Offset / 32] &= (~(1 << (Offset % 32)));
MmDeleteVirtualMapping(NULL,
Addr + (i * PAGESIZE),
Free,
@ -167,7 +172,7 @@ MiAllocNonPagedPoolRegion(ULONG nr_pages)
KIRQL oldlvl;
KeAcquireSpinLock(&AllocMapLock, &oldlvl);
for (i=1; i<ALLOC_MAP_SIZE;i++)
for (i=AllocMapHint; i<ALLOC_MAP_SIZE;i++)
{
if (!(AllocMap[i/32] & (1 << (i % 32))))
{
@ -182,22 +187,23 @@ MiAllocNonPagedPoolRegion(ULONG nr_pages)
}
if (length==nr_pages)
{
for (j=start;j<(start+length);j++)
{
AllocMap[j / 32] |= (1 << (j % 32));
}
DPRINT("returning %x\n",((start*PAGESIZE)+NonPagedPoolBase));
KeReleaseSpinLock(&AllocMapLock, oldlvl);
return(((start*PAGESIZE)+NonPagedPoolBase));
AllocMapHint = start + length;
for (j=start;j<(start+length);j++)
{
AllocMap[j / 32] |= (1 << (j % 32));
}
DPRINT("returning %x\n",((start*PAGESIZE)+NonPagedPoolBase));
KeReleaseSpinLock(&AllocMapLock, oldlvl);
return(((start*PAGESIZE)+NonPagedPoolBase));
}
}
else
{
start=0;
length=0;
}
else
{
start=0;
length=0;
}
}
DbgPrint("CRITICAL: Out of non-paged pool space\n");
for(;;);
KeBugCheck(0);
return(0);
}

View file

@ -71,8 +71,6 @@ MEMORY_AREA* MmOpenMemoryAreaByAddress(PMADDRESS_SPACE AddressSpace,
DPRINT("MmOpenMemoryAreaByAddress(AddressSpace %x, Address %x)\n",
AddressSpace, Address);
// MmDumpMemoryAreas(&AddressSpace->MAreaListHead);
previous_entry = &AddressSpace->MAreaListHead;
current_entry = AddressSpace->MAreaListHead.Flink;
while (current_entry != &AddressSpace->MAreaListHead)
@ -80,22 +78,7 @@ MEMORY_AREA* MmOpenMemoryAreaByAddress(PMADDRESS_SPACE AddressSpace,
current = CONTAINING_RECORD(current_entry,
MEMORY_AREA,
Entry);
DPRINT("Scanning %x BaseAddress %x Length %x\n",
current, current->BaseAddress, current->Length);
assert(current_entry->Blink->Flink == current_entry);
if (current_entry->Flink->Blink != current_entry)
{
DPRINT1("BaseAddress %x\n", current->BaseAddress);
DPRINT1("current_entry->Flink %x ", current_entry->Flink);
DPRINT1("&current_entry->Flink %x\n",
&current_entry->Flink);
DPRINT1("current_entry->Flink->Blink %x\n",
current_entry->Flink->Blink);
DPRINT1("&current_entry->Flink->Blink %x\n",
&current_entry->Flink->Blink);
DPRINT1("&current_entry->Flink %x\n",
&current_entry->Flink);
}
assert(current_entry->Flink->Blink == current_entry);
assert(previous_entry->Flink == current_entry);
if (current->BaseAddress <= Address &&
@ -184,38 +167,24 @@ static VOID MmInsertMemoryArea(PMADDRESS_SPACE AddressSpace,
ListHead = &AddressSpace->MAreaListHead;
current_entry = ListHead->Flink;
CHECKPOINT;
if (IsListEmpty(ListHead))
{
CHECKPOINT;
InsertHeadList(ListHead,&marea->Entry);
DPRINT("Inserting at list head\n");
CHECKPOINT;
return;
}
CHECKPOINT;
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
CHECKPOINT;
if (current->BaseAddress > marea->BaseAddress)
{
CHECKPOINT;
InsertHeadList(ListHead,&marea->Entry);
DPRINT("Inserting at list head\n");
CHECKPOINT;
return;
}
CHECKPOINT;
while (current_entry->Flink!=ListHead)
{
// CHECKPOINT;
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
next = CONTAINING_RECORD(current_entry->Flink,MEMORY_AREA,Entry);
// assert(current->BaseAddress != marea->BaseAddress);
// assert(next->BaseAddress != marea->BaseAddress);
if (current->BaseAddress < marea->BaseAddress &&
current->Entry.Flink==ListHead)
{
DPRINT("Insert after %x\n", current_entry);
current_entry->Flink = inserted_entry;
inserted_entry->Flink=ListHead;
inserted_entry->Blink=current_entry;
@ -225,7 +194,6 @@ static VOID MmInsertMemoryArea(PMADDRESS_SPACE AddressSpace,
if (current->BaseAddress < marea->BaseAddress &&
next->BaseAddress > marea->BaseAddress)
{
DPRINT("Inserting before %x\n", current_entry);
inserted_entry->Flink = current_entry->Flink;
inserted_entry->Blink = current_entry;
inserted_entry->Flink->Blink = inserted_entry;
@ -234,13 +202,10 @@ static VOID MmInsertMemoryArea(PMADDRESS_SPACE AddressSpace,
}
current_entry = current_entry->Flink;
}
CHECKPOINT;
DPRINT("Inserting at list tail\n");
InsertTailList(ListHead,inserted_entry);
}
static PVOID MmFindGap(PMADDRESS_SPACE AddressSpace,
ULONG Length)
PVOID MmFindGap(PMADDRESS_SPACE AddressSpace, ULONG Length)
{
PLIST_ENTRY ListHead;
PLIST_ENTRY current_entry;
@ -257,12 +222,7 @@ static PVOID MmFindGap(PMADDRESS_SPACE AddressSpace,
{
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
next = CONTAINING_RECORD(current_entry->Flink,MEMORY_AREA,Entry);
DPRINT("current %x current->BaseAddress %x ",current,
current->BaseAddress);
DPRINT("current->Length %x\n",current->Length);
DPRINT("next %x next->BaseAddress %x ",next,next->BaseAddress);
Gap = (next->BaseAddress ) -(current->BaseAddress + current->Length);
DPRINT("Base %x Gap %x\n",current->BaseAddress,Gap);
if (Gap >= Length)
{
return(current->BaseAddress + PAGE_ROUND_UP(current->Length));
@ -276,8 +236,6 @@ static PVOID MmFindGap(PMADDRESS_SPACE AddressSpace,
}
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
//DbgPrint("current %x returning %x\n",current,current->BaseAddress+
// current->Length);
return(current->BaseAddress + PAGE_ROUND_UP(current->Length));
}
@ -294,15 +252,17 @@ NTSTATUS
MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
PVOID BaseAddress,
ULONG Length,
VOID (*FreePage)(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
PHYSICAL_ADDRESS PhysAddr, SWAPENTRY SwapEntry, BOOLEAN Dirty),
VOID (*FreePage)(PVOID Context, MEMORY_AREA* MemoryArea,
PVOID Address, PHYSICAL_ADDRESS PhysAddr,
SWAPENTRY SwapEntry, BOOLEAN Dirty),
PVOID FreePageContext)
{
MEMORY_AREA* MemoryArea;
ULONG i;
DPRINT("MmFreeMemoryArea(AddressSpace %x, BaseAddress %x, Length %x,"
"FreePageContext %d)\n",AddressSpace,BaseAddress,Length,FreePageContext);
"FreePageContext %d)\n",AddressSpace,BaseAddress,Length,
FreePageContext);
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
BaseAddress);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: mpw.c,v 1.8 2002/08/14 20:58:36 dwelch Exp $
/* $Id: mpw.c,v 1.9 2002/08/17 01:42:02 dwelch Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/mpw.c
@ -74,55 +74,62 @@ MmWriteDirtyPages(ULONG Target, PULONG Actual)
NTSTATUS STDCALL
MmMpwThreadMain(PVOID Ignored)
{
NTSTATUS Status;
ULONG PagesWritten;
LARGE_INTEGER Timeout;
Timeout.QuadPart = -50000000;
for(;;)
{
Status = KeWaitForSingleObject(&MpwThreadEvent,
0,
KernelMode,
FALSE,
&Timeout);
if (!NT_SUCCESS(Status))
{
DbgPrint("MpwThread: Wait failed\n");
KeBugCheck(0);
return(STATUS_UNSUCCESSFUL);
}
if (MpwThreadShouldTerminate)
{
DbgPrint("MpwThread: Terminating\n");
return(STATUS_SUCCESS);
}
PagesWritten = 0;
MmWriteDirtyPages(128, &PagesWritten);
CcRosFlushDirtyPages(128, &PagesWritten);
}
NTSTATUS Status;
ULONG PagesWritten;
LARGE_INTEGER Timeout;
Timeout.QuadPart = -50000000;
for(;;)
{
Status = KeWaitForSingleObject(&MpwThreadEvent,
0,
KernelMode,
FALSE,
&Timeout);
if (!NT_SUCCESS(Status))
{
DbgPrint("MpwThread: Wait failed\n");
KeBugCheck(0);
return(STATUS_UNSUCCESSFUL);
}
if (MpwThreadShouldTerminate)
{
DbgPrint("MpwThread: Terminating\n");
return(STATUS_SUCCESS);
}
PagesWritten = 0;
MmWriteDirtyPages(128, &PagesWritten);
CcRosFlushDirtyPages(128, &PagesWritten);
}
}
NTSTATUS MmInitMpwThread(VOID)
{
NTSTATUS Status;
MpwThreadShouldTerminate = FALSE;
KeInitializeEvent(&MpwThreadEvent, SynchronizationEvent, FALSE);
Status = PsCreateSystemThread(&MpwThreadHandle,
THREAD_ALL_ACCESS,
NULL,
NULL,
&MpwThreadId,
MmMpwThreadMain,
NULL);
if (!NT_SUCCESS(Status))
{
return(Status);
KPRIORITY Priority;
NTSTATUS Status;
MpwThreadShouldTerminate = FALSE;
KeInitializeEvent(&MpwThreadEvent, SynchronizationEvent, FALSE);
Status = PsCreateSystemThread(&MpwThreadHandle,
THREAD_ALL_ACCESS,
NULL,
NULL,
&MpwThreadId,
MmMpwThreadMain,
NULL);
if (!NT_SUCCESS(Status))
{
return(Status);
}
return(STATUS_SUCCESS);
Priority = 1;
NtSetInformationThread(MpwThreadHandle,
ThreadPriority,
&Priority,
sizeof(Priority));
return(STATUS_SUCCESS);
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: pagefile.c,v 1.22 2002/08/14 20:58:36 dwelch Exp $
/* $Id: pagefile.c,v 1.23 2002/08/17 01:42:02 dwelch Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/pagefile.c
@ -105,8 +105,20 @@ ULONG MmCoreDumpType;
#define OFFSET_FROM_ENTRY(i) (((i) & 0xffffff) - 1)
#define ENTRY_FROM_FILE_OFFSET(i, j) (((i) << 24) | ((j) + 1))
static BOOLEAN MmSwapSpaceMessage = FALSE;
/* FUNCTIONS *****************************************************************/
VOID
MmShowOutOfSpaceMessagePagingFile(VOID)
{
if (!MmSwapSpaceMessage)
{
DPRINT1("MM: Out of swap space.\n");
MmSwapSpaceMessage = TRUE;
}
}
NTSTATUS MmWriteToSwapPage(SWAPENTRY SwapEntry, PMDL Mdl)
{
ULONG i, offset;
@ -316,19 +328,13 @@ MmAllocSwapPage(VOID)
KIRQL oldIrql;
ULONG i;
ULONG off;
SWAPENTRY entry;
static BOOLEAN SwapSpaceMessage = FALSE;
SWAPENTRY entry;
KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
if (MiFreeSwapPages == 0)
{
KeReleaseSpinLock(&PagingFileListLock, oldIrql);
if (!SwapSpaceMessage)
{
DPRINT1("MM: Out of swap space.\n");
SwapSpaceMessage = TRUE;
}
KeReleaseSpinLock(&PagingFileListLock, oldIrql);
return(0);
}
@ -354,11 +360,7 @@ MmAllocSwapPage(VOID)
}
KeReleaseSpinLock(&PagingFileListLock, oldIrql);
if (!SwapSpaceMessage)
{
DPRINT1("MM: Out of swap space.\n");
SwapSpaceMessage = TRUE;
}
KeBugCheck(0);
return(0);
}
@ -658,6 +660,9 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
}
}
NtClose(FileHandle);
MmSwapSpaceMessage = FALSE;
return(STATUS_SUCCESS);
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: section.c,v 1.89 2002/08/14 20:58:37 dwelch Exp $
/* $Id: section.c,v 1.90 2002/08/17 01:42:02 dwelch Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c
@ -1387,6 +1387,8 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
SwapEntry = MmAllocSwapPage();
if (SwapEntry == 0)
{
MmShowOutOfSpaceMessagePagingFile();
/*
* For private pages restore the old mappings.
*/
@ -3286,16 +3288,56 @@ MmMapViewOfSection(IN PVOID SectionObject,
if (Section->AllocationAttributes & SEC_IMAGE)
{
ULONG i;
PVOID ImageBase;
ULONG ImageSize;
ImageBase = *BaseAddress;
if (ImageBase == NULL)
{
ImageBase = Section->ImageBase;
}
ImageSize = 0;
for (i = 0; i < Section->NrSegments; i++)
{
PVOID SBaseAddress;
if (!(Section->Segments[i].Characteristics & IMAGE_SECTION_NOLOAD))
{
ULONG MaxExtent;
MaxExtent = (ULONG)(Section->Segments[i].VirtualAddress +
Section->Segments[i].Length);
ImageSize = max(ImageSize, MaxExtent);
}
}
/* Check there is enough space to map the section at that point. */
if (MmOpenMemoryAreaByRegion(AddressSpace, ImageBase,
ImageSize) != NULL)
{
/* Fail if the user requested a fixed base address. */
if ((*BaseAddress) != NULL)
{
MmUnlockSection(Section);
MmUnlockAddressSpace(AddressSpace);
return(Status);
}
/* Otherwise find a gap to map the image. */
ImageBase = MmFindGap(AddressSpace, ImageSize);
if (ImageBase == NULL)
{
MmUnlockSection(Section);
MmUnlockAddressSpace(AddressSpace);
return(Status);
}
}
for (i = 0; i < Section->NrSegments; i++)
{
PVOID SBaseAddress;
if (!(Section->Segments[i].Characteristics & IMAGE_SECTION_NOLOAD))
{
SBaseAddress = (PVOID)
((ULONG)Section->ImageBase +
(ULONG)Section->Segments[i].VirtualAddress);
(ImageBase + (ULONG_PTR)Section->Segments[i].VirtualAddress);
MmLockSectionSegment(&Section->Segments[i]);
Status = MmMapViewOfSegment(Process,
@ -3315,7 +3357,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
}
}
}
*BaseAddress = Section->ImageBase;
*BaseAddress = ImageBase;
}
else
{

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.50 2002/08/14 20:58:38 dwelch Exp $
/* $Id: create.c,v 1.51 2002/08/17 01:42:03 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -279,24 +279,21 @@ PiDeleteThread(PVOID ObjectBody)
KIRQL oldIrql;
PETHREAD Thread;
ULONG i;
Thread = (PETHREAD)ObjectBody;
DPRINT("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
Thread = (PETHREAD)ObjectBody;
ObDereferenceObject(Thread->ThreadsProcess);
Thread->ThreadsProcess = NULL;
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
for (i = 0; i < PiThreadNotifyRoutineCount; i++)
{
PiThreadNotifyRoutine[i](Thread->Cid.UniqueProcess,
Thread->Cid.UniqueThread,
FALSE);
}
DPRINT("Process %x(%d)\n",
Thread->ThreadsProcess,
ObGetObjectPointerCount(Thread->ThreadsProcess));
ObDereferenceObject(Thread->ThreadsProcess);
Thread->ThreadsProcess = NULL;
}
PiNrThreads--;
RemoveEntryList(&Thread->Tcb.ThreadListEntry);
KeReleaseThread(Thread);
@ -304,17 +301,6 @@ PiDeleteThread(PVOID ObjectBody)
DPRINT("PiDeleteThread() finished\n");
}
VOID STDCALL
PiCloseThread(PVOID ObjectBody,
ULONG HandleCount)
{
DPRINT("PiCloseThread(ObjectBody %x)\n", ObjectBody);
DPRINT("ObGetObjectPointerCount(ObjectBody) %d "
"ObGetObjectHandleCount(ObjectBody) %d\n",
ObGetObjectPointerCount(ObjectBody),
ObGetObjectHandleCount(ObjectBody));
}
NTSTATUS
PsInitializeThread(HANDLE ProcessHandle,
PETHREAD* ThreadPtr,

View file

@ -1,4 +1,4 @@
/* $Id: thread.c,v 1.102 2002/08/16 01:39:16 dwelch Exp $
/* $Id: thread.c,v 1.103 2002/08/17 01:42:03 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -426,7 +426,7 @@ PsInitThreadManagment(VOID)
PsThreadType->Mapping = &PiThreadMapping;
PsThreadType->Dump = NULL;
PsThreadType->Open = NULL;
PsThreadType->Close = PiCloseThread;
PsThreadType->Close = NULL;
PsThreadType->Delete = PiDeleteThread;
PsThreadType->Parse = NULL;
PsThreadType->Security = NULL;