X-Git-Url: http://git.jankratochvil.net/?p=reactos.git;a=blobdiff_plain;f=ntoskrnl%2Fps%2Fcreate.c;fp=ntoskrnl%2Fps%2Fcreate.c;h=f46d5647b29c0c660fae972b0c0582bfcb259810;hp=72fa987a78b5dead5b92694cd2873bb7679a224b;hb=7c0db166f81fbe8c8b913d7f26048e337d383605;hpb=e3ed2d773259cc445c7ff8181ebd934931365328 diff --git a/ntoskrnl/ps/create.c b/ntoskrnl/ps/create.c index 72fa987..f46d564 100644 --- a/ntoskrnl/ps/create.c +++ b/ntoskrnl/ps/create.c @@ -269,7 +269,6 @@ PsReferenceImpersonationToken(PETHREAD Thread, VOID PiBeforeBeginThread(CONTEXT c) { - DPRINT("PiBeforeBeginThread(Eip %x)\n", c.Eip); KeLowerIrql(PASSIVE_LEVEL); } @@ -370,7 +369,7 @@ PsInitializeThread(HANDLE ProcessHandle, 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; @@ -400,7 +399,7 @@ static NTSTATUS PsCreateTeb(HANDLE ProcessHandle, PTEB *TebPtr, PETHREAD Thread, - PINITIAL_TEB InitialTeb) + PUSER_STACK UserStack) { MEMORY_BASIC_INFORMATION Info; NTSTATUS Status; @@ -448,6 +447,7 @@ PsCreateTeb(HANDLE ProcessHandle, 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) @@ -456,13 +456,24 @@ PsCreateTeb(HANDLE ProcessHandle, } 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; @@ -528,7 +539,7 @@ NtCreateThread(PHANDLE ThreadHandle, HANDLE ProcessHandle, PCLIENT_ID Client, PCONTEXT ThreadContext, - PINITIAL_TEB InitialTeb, + PUSER_STACK UserStack, BOOLEAN CreateSuspended) { PETHREAD Thread; @@ -559,7 +570,7 @@ NtCreateThread(PHANDLE ThreadHandle, Status = PsCreateTeb(ProcessHandle, &TebBase, Thread, - InitialTeb); + UserStack); if (!NT_SUCCESS(Status)) { return(Status);