VOID
PiBeforeBeginThread(CONTEXT c)
{
- DPRINT("PiBeforeBeginThread(Eip %x)\n", c.Eip);
KeLowerIrql(PASSIVE_LEVEL);
}
KeInitializeSpinLock(&Thread->ActiveTimerListLock);
InitializeListHead(&Thread->IrpList);
Thread->Cid.UniqueThread = (HANDLE)InterlockedIncrement(
- &PiNextThreadUniqueId);
+ (LONG *)&PiNextThreadUniqueId);
Thread->Cid.UniqueProcess = (HANDLE)Thread->ThreadsProcess->UniqueProcessId;
Thread->DeadThread = 0;
Thread->Win32Thread = 0;
PsCreateTeb(HANDLE ProcessHandle,
PTEB *TebPtr,
PETHREAD Thread,
- PINITIAL_TEB InitialTeb)
+ PUSER_STACK UserStack)
{
MEMORY_BASIC_INFORMATION Info;
NTSTATUS Status;
DPRINT ("TebBase %p TebSize %lu\n", TebBase, TebSize);
+ RtlZeroMemory(&Teb, sizeof(TEB));
/* set all pointers to and from the TEB */
Teb.Tib.Self = TebBase;
if (Thread->ThreadsProcess)
}
DPRINT("Teb.Peb %x\n", Teb.Peb);
- /* store stack information from InitialTeb */
- if (InitialTeb != NULL)
- {
- Teb.Tib.StackBase = InitialTeb->StackBase;
- Teb.Tib.StackLimit = InitialTeb->StackLimit;
- Teb.DeallocationStack = InitialTeb->StackAllocate;
- }
+ /* store stack information from UserStack */
+ if(UserStack != NULL)
+ {
+ /* fixed-size stack */
+ if(UserStack->FixedStackBase && UserStack->FixedStackLimit)
+ {
+ Teb.Tib.StackBase = UserStack->FixedStackBase;
+ Teb.Tib.StackLimit = UserStack->FixedStackLimit;
+ Teb.DeallocationStack = UserStack->FixedStackLimit;
+ }
+ /* expandable stack */
+ else
+ {
+ Teb.Tib.StackBase = UserStack->ExpandableStackBase;
+ Teb.Tib.StackLimit = UserStack->ExpandableStackLimit;
+ Teb.DeallocationStack = UserStack->ExpandableStackBottom;
+ }
+ }
/* more initialization */
Teb.Cid.UniqueThread = Thread->Cid.UniqueThread;
HANDLE ProcessHandle,
PCLIENT_ID Client,
PCONTEXT ThreadContext,
- PINITIAL_TEB InitialTeb,
+ PUSER_STACK UserStack,
BOOLEAN CreateSuspended)
{
PETHREAD Thread;
Status = PsCreateTeb(ProcessHandle,
&TebBase,
Thread,
- InitialTeb);
+ UserStack);
if (!NT_SUCCESS(Status))
{
return(Status);