mirror of
https://github.com/reactos/reactos.git
synced 2024-07-05 12:15:46 +00:00
Minor fix to teb allocation.
svn path=/trunk/; revision=690
This commit is contained in:
parent
a77eef4a53
commit
8578ba8ac6
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: thread.c,v 1.27 1999/10/07 23:38:30 ekohl Exp $
|
/* $Id: thread.c,v 1.28 1999/10/11 20:43:10 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -416,58 +416,27 @@ PsCreateTeb (HANDLE ProcessHandle,
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
Status = NtQueryVirtualMemory(ProcessHandle,
|
/* The TEB must reside in user space */
|
||||||
TebBase,
|
Status = NtAllocateVirtualMemory(ProcessHandle,
|
||||||
MemoryBasicInformation,
|
&TebBase,
|
||||||
&Info,
|
0,
|
||||||
sizeof(MEMORY_BASIC_INFORMATION),
|
&TebSize,
|
||||||
&ByteCount);
|
MEM_COMMIT,
|
||||||
if (!NT_SUCCESS(Status))
|
PAGE_READWRITE);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DbgPrint ("NtQueryVirtualMemory (Status %x)\n",Status);
|
DPRINT ("TEB allocated at %x\n", TebBase);
|
||||||
return Status;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
if (Info.State == MEM_FREE)
|
|
||||||
{
|
|
||||||
DbgPrint("Virtual memory at %p is free.\n",
|
|
||||||
TebBase);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DbgPrint("Virtual memory at %p is allocated (BaseAddress %p RegionSize %x).\n",
|
DPRINT ("TEB allocation failed! Status %x\n",Status);
|
||||||
TebBase, Info.BaseAddress, Info.RegionSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Info.State == MEM_FREE)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
TebBase = Info.BaseAddress - TebSize;
|
TebBase = Info.BaseAddress - TebSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (Info.State != MEM_FREE)
|
DPRINT ("TebBase %p TebSize %lu\n", TebBase, TebSize);
|
||||||
// return STATUS_SUCCESS;
|
|
||||||
|
|
||||||
|
|
||||||
/* The TEB must reside in user space */
|
|
||||||
Status = NtAllocateVirtualMemory(ProcessHandle,
|
|
||||||
&TebBase,
|
|
||||||
0,
|
|
||||||
&TebSize,
|
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint ("TEB allocation failed!\n");
|
|
||||||
DbgPrint ("Status %x\n",Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
DbgPrint ("TebBase %p TebSize %lu\n", TebBase, TebSize);
|
|
||||||
|
|
||||||
|
|
||||||
/* set all pointers to and from the TEB */
|
/* set all pointers to and from the TEB */
|
||||||
Teb.Tib.Self = TebBase;
|
Teb.Tib.Self = TebBase;
|
||||||
|
@ -506,7 +475,7 @@ PsCreateTeb (HANDLE ProcessHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* free TEB */
|
/* free TEB */
|
||||||
DbgPrint ("Writing TEB failed!\n");
|
DPRINT ("Writing TEB failed!\n");
|
||||||
|
|
||||||
RegionSize = 0;
|
RegionSize = 0;
|
||||||
NtFreeVirtualMemory(ProcessHandle,
|
NtFreeVirtualMemory(ProcessHandle,
|
||||||
|
@ -524,7 +493,7 @@ PsCreateTeb (HANDLE ProcessHandle,
|
||||||
// *TebPtr = (PNT_TEB)TebBase;
|
// *TebPtr = (PNT_TEB)TebBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
DbgPrint ("TEB allocated at %p\n", TebBase);
|
DPRINT ("TEB allocated at %p\n", TebBase);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue