[KERNEL32]

- SwitchToFiber: instead of doing a ret to the return address on the stack (which wouldn't work for a newly created fiber) store the returnaddress in the Eip field old fiber context and do a jmp to the Eip of the new fiber.
- BasepInitializeContext: set the Eip member of the Context to BaseFiberStartup for fibers
CreateFiberEx: initialize the fiber context, instead of an unused context on the stack.
- BaseFiberStartup: Use GetCurrentFiber, not GetFiberData to get the current fiber.
Fixes kernel32_wintest fiber

svn path=/trunk/; revision=47232
This commit is contained in:
Timo Kreuzer
2010-05-16 00:30:11 +00:00
parent de96a18171
commit fa5c83b451
3 changed files with 13 additions and 10 deletions
+1 -1
View File
@@ -364,7 +364,7 @@ BasepInitializeContext(IN PCONTEXT Context,
}
else if (ContextType == 2) /* For Fibers */
{
//Context->Eip = (ULONG)BaseFiberStartup;
Context->Eip = (ULONG)BaseFiberStartup;
}
else /* For first thread in a Process */
{
+4 -5
View File
@@ -146,9 +146,8 @@ CreateFiberEx(SIZE_T dwStackCommitSize,
PFIBER pfCurFiber;
NTSTATUS nErrCode;
INITIAL_TEB usFiberInitialTeb;
CONTEXT ctxFiberContext;
PVOID ActivationContextStack = NULL;
DPRINT1("Creating Fiber\n");
DPRINT("Creating Fiber\n");
#ifdef SXS_SUPPORT_ENABLED
/* Allocate the Activation Context Stack */
@@ -203,7 +202,7 @@ CreateFiberEx(SIZE_T dwStackCommitSize,
}
/* initialize the context for the fiber */
BasepInitializeContext(&ctxFiberContext,
BasepInitializeContext(&pfCurFiber->Context,
lpParameter,
lpStartAddress,
usFiberInitialTeb.StackBase,
@@ -253,10 +252,10 @@ WINAPI
BaseFiberStartup(VOID)
{
#ifdef _M_IX86
PFIBER Fiber = GetFiberData();
PFIBER Fiber = GetCurrentFiber();
/* Call the Thread Startup Routine */
DPRINT1("Starting Fiber\n");
DPRINT("Starting Fiber\n");
BaseThreadStartup((LPTHREAD_START_ROUTINE)Fiber->Context.Eax,
(LPVOID)Fiber->Context.Ebx);
#else
@@ -24,7 +24,11 @@ _SwitchToFiber@4:
mov [eax+FIBER_CONTEXT_ESI], esi
mov [eax+FIBER_CONTEXT_EDI], edi
mov [eax+FIBER_CONTEXT_EBP], ebp
/* Save the return address */
mov ebx, [esp]
mov [eax+FIBER_CONTEXT_EIP], ebx
/* Check if we're to save FPU State */
cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL | CONTEXT_FLOATING_POINT
jnz NoFpuStateSave
@@ -115,7 +119,7 @@ NoFpuStateRestore:
mov eax, [ecx+FIBER_FLS_DATA]
mov [edx+TEB_FLS_DATA], eax
/* Return */
ret 4
/* Jump to new fiber */
jmp [ecx+FIBER_CONTEXT_EIP]
/* EOF */