[ros-diffs] [tkreuzer] 47232: [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

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Sun May 16 02:30:12 CEST 2010


Author: tkreuzer
Date: Sun May 16 02:30:11 2010
New Revision: 47232

URL: http://svn.reactos.org/svn/reactos?rev=47232&view=rev
Log:
[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

Modified:
    trunk/reactos/dll/win32/kernel32/misc/utils.c
    trunk/reactos/dll/win32/kernel32/thread/fiber.c
    trunk/reactos/dll/win32/kernel32/thread/i386/fiber.S

Modified: trunk/reactos/dll/win32/kernel32/misc/utils.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/utils.c?rev=47232&r1=47231&r2=47232&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/utils.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/utils.c [iso-8859-1] Sun May 16 02:30:11 2010
@@ -364,7 +364,7 @@
     }
     else if (ContextType == 2) /* For Fibers */
     {
-        //Context->Eip = (ULONG)BaseFiberStartup;
+        Context->Eip = (ULONG)BaseFiberStartup;
     }
     else                       /* For first thread in a Process */
     {

Modified: trunk/reactos/dll/win32/kernel32/thread/fiber.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/thread/fiber.c?rev=47232&r1=47231&r2=47232&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/thread/fiber.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/thread/fiber.c [iso-8859-1] Sun May 16 02:30:11 2010
@@ -146,9 +146,8 @@
     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 @@
     }
 
     /* initialize the context for the fiber */
-    BasepInitializeContext(&ctxFiberContext,
+    BasepInitializeContext(&pfCurFiber->Context,
                            lpParameter,
                            lpStartAddress,
                            usFiberInitialTeb.StackBase,
@@ -253,10 +252,10 @@
 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

Modified: trunk/reactos/dll/win32/kernel32/thread/i386/fiber.S
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/thread/i386/fiber.S?rev=47232&r1=47231&r2=47232&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/thread/i386/fiber.S [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/thread/i386/fiber.S [iso-8859-1] Sun May 16 02:30:11 2010
@@ -24,7 +24,11 @@
     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 @@
     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 */




More information about the Ros-diffs mailing list