}
else if (ContextType == 2) /* For Fibers */
{
- //Context->Eip = (ULONG)BaseFiberStartup;
+ Context->Eip = (ULONG)BaseFiberStartup;
}
else /* For first thread in a Process */
{
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 */
}
/* initialize the context for the fiber */
- BasepInitializeContext(&ctxFiberContext,
+ BasepInitializeContext(&pfCurFiber->Context,
lpParameter,
lpStartAddress,
usFiberInitialTeb.StackBase,
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
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
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 */