- Remove unused ldr/userldr.c
authorAlex Ionescu <aionescu@gmail.com>
Fri, 5 Aug 2005 03:44:24 +0000 (03:44 +0000)
committerAlex Ionescu <aionescu@gmail.com>
Fri, 5 Aug 2005 03:44:24 +0000 (03:44 +0000)
- Rename LdrLoadInitialProcess to Exp... and move to executive initialization.
- Removed ldr/init.c
- Renamed ldr/sysdll.c functions to Psp (correct naming) and deleted file.
- Renamed SystemDll... ntdll pointers to correct Ke names
- Use direct Ke names instead of going through an API call.
- Make ExpInit... functions STDCALL

svn path=/trunk/; revision=17053

29 files changed:
reactos/ntoskrnl/ex/callback.c
reactos/ntoskrnl/ex/event.c
reactos/ntoskrnl/ex/evtpair.c
reactos/ntoskrnl/ex/init.c
reactos/ntoskrnl/ex/lookas.c
reactos/ntoskrnl/ex/mutant.c
reactos/ntoskrnl/ex/profile.c
reactos/ntoskrnl/ex/sem.c
reactos/ntoskrnl/ex/time.c
reactos/ntoskrnl/ex/timer.c
reactos/ntoskrnl/ex/uuid.c
reactos/ntoskrnl/ex/win32k.c
reactos/ntoskrnl/ex/work.c
reactos/ntoskrnl/include/internal/ex.h
reactos/ntoskrnl/include/internal/ke.h
reactos/ntoskrnl/include/internal/ldr.h
reactos/ntoskrnl/include/internal/ps.h
reactos/ntoskrnl/ke/apc.c
reactos/ntoskrnl/ke/catch.c
reactos/ntoskrnl/ke/i386/exp.c
reactos/ntoskrnl/ke/main.c
reactos/ntoskrnl/ke/usercall.c
reactos/ntoskrnl/ldr/init.c [deleted file]
reactos/ntoskrnl/ldr/sysdll.c [deleted file]
reactos/ntoskrnl/ldr/userldr.c [deleted file]
reactos/ntoskrnl/ntoskrnl.xml
reactos/ntoskrnl/ps/process.c
reactos/ntoskrnl/ps/psmgr.c
reactos/ntoskrnl/ps/thread.c

index f18f339..371064b 100644 (file)
@@ -71,6 +71,8 @@ KEVENT ExpCallbackEvent;
  * TRUE if the Callback Object Type was successfully created.
  */
 VOID
+INIT_FUNCTION
+STDCALL
 ExpInitializeCallbacks(VOID)
 {
    OBJECT_ATTRIBUTES ObjectAttributes;
index 7625168..368e79d 100644 (file)
@@ -34,6 +34,7 @@ static const INFORMATION_CLASS_INFO ExEventInfoClass[] = {
 
 VOID
 INIT_FUNCTION
+STDCALL
 ExpInitializeEventImplementation(VOID)
 {
   OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
index 545ffef..0ce88dc 100644 (file)
@@ -31,6 +31,7 @@ static GENERIC_MAPPING ExEventPairMapping = {
 
 VOID
 INIT_FUNCTION
+STDCALL
 ExpInitializeEventPairImplementation(VOID)
 {
   OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
index 8f471f0..fdf708d 100644 (file)
@@ -405,6 +405,79 @@ ExpDisplayNotice(VOID)
     HalDisplayString(str);
     
 }
+
+INIT_FUNCTION
+NTSTATUS
+ExpLoadInitialProcess(PHANDLE ProcessHandle,
+                      PHANDLE ThreadHandle)
+{
+    UNICODE_STRING ImagePath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\smss.exe");
+    HANDLE SystemProcessHandle;
+    NTSTATUS Status;
+    PRTL_USER_PROCESS_PARAMETERS Params=NULL;
+    RTL_USER_PROCESS_INFORMATION Info;
+
+    /* Create a handle to the process */
+    Status = ObpCreateHandle(PsGetCurrentProcess(),
+                             PsInitialSystemProcess,
+                             PROCESS_CREATE_PROCESS | PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION,
+                             FALSE,
+                             &SystemProcessHandle);
+    if(!NT_SUCCESS(Status))
+    {
+        DPRINT1("Failed to create a handle for the system process!\n");
+        return Status;
+    }
+
+    /* Create the Parameters */
+    Status = RtlCreateProcessParameters(&Params,
+                                        &ImagePath,
+                                        NULL,
+                                        NULL,
+                                        NULL,
+                                        NULL,
+                                        NULL,
+                                        NULL,
+                                        NULL,
+                                        NULL);
+    if(!NT_SUCCESS(Status))
+    {
+        DPRINT1("Failed to create ppb!\n");
+        ZwClose(SystemProcessHandle);
+        return Status;
+    }
+
+    DPRINT("Creating process\n");
+    Status = RtlCreateUserProcess(&ImagePath,
+                                  OBJ_CASE_INSENSITIVE,
+                                  Params,
+                                  NULL,
+                                  NULL,
+                                  SystemProcessHandle,
+                                  FALSE,
+                                  NULL,
+                                  NULL,
+                                  &Info);
+    
+    /* Close the handle and free the params */
+    ZwClose(SystemProcessHandle);
+    RtlDestroyProcessParameters(Params);
+
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("NtCreateProcess() failed (Status %lx)\n", Status);
+        return(Status);
+    }
+
+    /* Start it up */
+    ZwResumeThread(Info.ThreadHandle, NULL);
+
+    /* Return Handles */
+    *ProcessHandle = Info.ProcessHandle;
+    *ThreadHandle = Info.ThreadHandle;
+    DPRINT("Process created successfully\n");
+    return STATUS_SUCCESS;
+}
    
 VOID
 INIT_FUNCTION
@@ -468,7 +541,7 @@ ExpInitializeExecutive(VOID)
     ObInit();
 
     /* Initialize Lookaside Lists */
-    ExInit2();
+    ExpInitLookasideLists();
 
     /* Set up Region Maps, Sections and the Paging File */
     MmInit2();
@@ -506,7 +579,7 @@ ExpInitializeExecutive(VOID)
     HalInitSystem(1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
 
     /* Initialize Basic System Objects and Worker Threads */
-    ExInit3();
+    ExInit2();
 
     /* Create the system handle table, assign it to the system process, create
        the client id table and assign a PID for the system process. This needs
@@ -575,7 +648,7 @@ ExpInitializeExecutive(VOID)
     IoInit3();
 
     /* Load the System DLL and its Entrypoints */
-    LdrpInitializeSystemDll();
+    PsLocateSystemDll();
 
     /* Initialize the Default Locale */
     PiInitDefaultLocale();
@@ -604,7 +677,7 @@ ExpInitializeExecutive(VOID)
     }
 
     /* Launch initial process */
-    Status = LdrLoadInitialProcess(&ProcessHandle,
+    Status = ExpLoadInitialProcess(&ProcessHandle,
                                    &ThreadHandle);
 
     /* Check for success, Bugcheck if we failed */
@@ -671,25 +744,21 @@ ExpInitializeExecutive(VOID)
     ZwClose(ProcessHandle);
 }
 
-VOID INIT_FUNCTION
+VOID
+STDCALL
+INIT_FUNCTION
 ExInit2(VOID)
 {
-  ExpInitLookasideLists();
-}
-
-VOID INIT_FUNCTION
-ExInit3 (VOID)
-{
-  ExpInitializeEventImplementation();
-  ExpInitializeEventPairImplementation();
-  ExpInitializeMutantImplementation();
-  ExpInitializeSemaphoreImplementation();
-  ExpInitializeTimerImplementation();
-  LpcpInitSystem();
-  ExpInitializeProfileImplementation();
-  ExpWin32kInit();
-  ExpInitUuids();
-  ExpInitializeHandleTables();
+    ExpInitializeEventImplementation();
+    ExpInitializeEventPairImplementation();
+    ExpInitializeMutantImplementation();
+    ExpInitializeSemaphoreImplementation();
+    ExpInitializeTimerImplementation();
+    LpcpInitSystem();
+    ExpInitializeProfileImplementation();
+    ExpWin32kInit();
+    ExpInitUuids();
+    ExpInitializeHandleTables();
 }
 
 /* EOF */
index 770faeb..4076a7e 100644 (file)
@@ -26,6 +26,7 @@ KSPIN_LOCK ExpPagedLookasideListLock;
 
 VOID 
 INIT_FUNCTION
+STDCALL
 ExpInitLookasideLists()
 {
     /* Initialize Lock and Listhead */
index 8790ce2..52ca69e 100644 (file)
@@ -51,6 +51,7 @@ ExpDeleteMutant(PVOID ObjectBody)
 
 VOID
 INIT_FUNCTION
+STDCALL
 ExpInitializeMutantImplementation(VOID)
 {
     OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
index 6dd5249..0644d96 100644 (file)
@@ -74,6 +74,7 @@ ExpDeleteProfile(PVOID ObjectBody)
 
 VOID
 INIT_FUNCTION
+STDCALL
 ExpInitializeProfileImplementation(VOID)
 {
     OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
index b4d85c0..55d886e 100644 (file)
@@ -32,6 +32,7 @@ static const INFORMATION_CLASS_INFO ExSemaphoreInfoClass[] = {
 
 VOID
 INIT_FUNCTION
+STDCALL
 ExpInitializeSemaphoreImplementation(VOID)
 {
     OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
index 89f5ad9..6e34248 100644 (file)
@@ -27,7 +27,9 @@ ULONG ExpTimeZoneId;
 
 /* FUNCTIONS ****************************************************************/
 
-VOID INIT_FUNCTION
+VOID
+INIT_FUNCTION
+STDCALL
 ExpInitTimeZoneInfo(VOID)
 {
   LARGE_INTEGER CurrentTime;
index 9bbaadf..1237fb5 100644 (file)
@@ -221,6 +221,7 @@ ExpTimerApcKernelRoutine(PKAPC Apc,
 
 VOID
 INIT_FUNCTION
+STDCALL
 ExpInitializeTimerImplementation(VOID)
 {
     OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
index 7bb4156..bfb7558 100644 (file)
@@ -41,7 +41,9 @@ static ULONG UuidCount;
 
 /* FUNCTIONS ****************************************************************/
 
-VOID INIT_FUNCTION
+VOID
+INIT_FUNCTION
+STDCALL
 ExpInitUuids(VOID)
 {
   ExInitializeFastMutex(&UuidMutex);
index 6d969f5..7f86bb2 100644 (file)
@@ -119,6 +119,7 @@ ExpDesktopDelete(PVOID DeletedObject)
 
 VOID
 INIT_FUNCTION
+STDCALL
 ExpWin32kInit(VOID)
 {
     OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
index 90608d1..ff6a24c 100644 (file)
@@ -132,6 +132,7 @@ ExpInitializeWorkQueue(WORK_QUEUE_TYPE WorkQueueType,
 
 VOID
 INIT_FUNCTION
+STDCALL
 ExpInitializeWorkerThreads(VOID)
 {
     ULONG WorkQueueType;
index 7f33226..7b0cf90 100644 (file)
@@ -11,27 +11,31 @@ extern POBJECT_TYPE ExEventPairObjectType;
 /* INITIALIZATION FUNCTIONS *************************************************/
 
 VOID
+STDCALL
 ExpWin32kInit(VOID);
 
 VOID
+STDCALL
 ExInit2(VOID);
 
 VOID
-ExInit3(VOID);
-
-VOID
+STDCALL
 ExpInitTimeZoneInfo(VOID);
 
 VOID
+STDCALL
 ExpInitializeWorkerThreads(VOID);
 
 VOID
+STDCALL
 ExpInitLookasideLists(VOID);
 
 VOID
+STDCALL
 ExpInitializeCallbacks(VOID);
 
 VOID
+STDCALL
 ExpInitUuids(VOID);
 
 VOID
@@ -39,24 +43,31 @@ STDCALL
 ExpInitializeExecutive(VOID);
 
 VOID
+STDCALL
 ExpInitializeEventImplementation(VOID);
 
 VOID
+STDCALL
 ExpInitializeEventImplementation(VOID);
 
 VOID
+STDCALL
 ExpInitializeEventPairImplementation(VOID);
 
 VOID
+STDCALL
 ExpInitializeSemaphoreImplementation(VOID);
 
 VOID
+STDCALL
 ExpInitializeMutantImplementation(VOID);
 
 VOID
+STDCALL
 ExpInitializeTimerImplementation(VOID);
 
 VOID
+STDCALL
 ExpInitializeProfileImplementation(VOID);
 
 /* HANDLE TABLE FUNCTIONS ***************************************************/
index 4083089..77d5b51 100644 (file)
@@ -19,6 +19,11 @@ struct _KPCR;
 struct _KPRCB;
 struct _KEXCEPTION_FRAME;
 
+extern PVOID KeUserApcDispatcher;
+extern PVOID KeUserCallbackDispatcher;
+extern PVOID KeUserExceptionDispatcher;
+extern PVOID KeRaiseUserExceptionDispatcher;
+
 #define IPI_REQUEST_FUNCTIONCALL    0
 #define IPI_REQUEST_APC                    1
 #define IPI_REQUEST_DPC                    2
index 7cfaec7..73bfde3 100644 (file)
@@ -20,36 +20,6 @@ LdrLoadAutoConfigDrivers (VOID);
 VOID
 LdrInitModuleManagement (VOID);
 
-NTSTATUS
-STDCALL
-LdrpMapSystemDll(
-    PEPROCESS Process,
-    PVOID *DllBase
-);
-
-NTSTATUS
-STDCALL
-LdrpInitializeSystemDll(VOID);
-
-NTSTATUS
-STDCALL
-LdrpGetSystemDllEntryPoints(VOID);
-
-PVOID
-LdrpGetSystemDllEntryPoint (VOID);
-
-PVOID
-LdrpGetSystemDllApcDispatcher(VOID);
-
-PVOID
-LdrpGetSystemDllExceptionDispatcher(VOID);
-
-PVOID
-LdrpGetSystemDllCallbackDispatcher(VOID);
-
-PVOID
-LdrpGetSystemDllRaiseExceptionDispatcher(VOID);
-
 NTSTATUS
 LdrpMapImage(
     HANDLE     ProcessHandle,
index 2894640..12f4f13 100644 (file)
@@ -199,6 +199,21 @@ VOID
 STDCALL
 PspDestroyQuotaBlock(PEPROCESS Process);
 
+NTSTATUS
+STDCALL
+PspMapSystemDll(
+    PEPROCESS Process,
+    PVOID *DllBase
+);
+
+NTSTATUS
+STDCALL
+PsLocateSystemDll(VOID);
+
+NTSTATUS
+STDCALL
+PspGetSystemDllEntryPoints(VOID);
+
 /* CLIENT ID */
 
 NTSTATUS PsCreateCidHandle(PVOID Object, POBJECT_TYPE ObjectType, PHANDLE Handle);
index 5036825..ef5e425 100644 (file)
@@ -847,7 +847,7 @@ KiInitializeUserApc(IN PVOID Reserved,
     Esp[3] = (ULONG)SystemArgument1;
     Esp[4] = (ULONG)SystemArgument2;
     Esp[5] = (ULONG)Context;
-    TrapFrame->Eip = (ULONG)LdrpGetSystemDllApcDispatcher();
+    TrapFrame->Eip = (ULONG)KeUserApcDispatcher;
     DPRINT("TrapFrame->Eip: %x\n", TrapFrame->Eip);
     TrapFrame->Esp = (ULONG)Esp;
 }
index 56a552d..97a83f5 100644 (file)
@@ -161,7 +161,7 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
                     DPRINT1("User-mode stack was invalid. Terminating target thread\n");
                 }
                 /* Set EIP to the User-mode Dispathcer */
-                Tf->Eip = (ULONG)LdrpGetSystemDllExceptionDispatcher();
+                Tf->Eip = (ULONG)KeRaiseUserExceptionDispatcher;
                 return;
             }
 
index fadbf12..f21c45e 100644 (file)
@@ -923,7 +923,7 @@ KeRaiseUserException(IN NTSTATUS ExceptionCode)
     } _SEH_END;
 
    OldEip = Thread->TrapFrame->Eip;
-   Thread->TrapFrame->Eip = (ULONG_PTR)LdrpGetSystemDllRaiseExceptionDispatcher();
+   Thread->TrapFrame->Eip = (ULONG_PTR)KeRaiseUserExceptionDispatcher;
    return((NTSTATUS)OldEip);
 }
 
index f999e5f..70e19f7 100644 (file)
@@ -41,6 +41,11 @@ ULONG_PTR FirstKrnlPhysAddr;
 ULONG_PTR LastKrnlPhysAddr;
 ULONG_PTR LastKernelAddress;
 
+PVOID KeUserApcDispatcher = NULL;
+PVOID KeUserCallbackDispatcher = NULL;
+PVOID KeUserExceptionDispatcher = NULL;
+PVOID KeRaiseUserExceptionDispatcher = NULL;
+
 ULONG KeLargestCacheLine = 0x40; /* FIXME: Arch-specific */
 
 /* We allocate 4 pages, but we only use 3. The 4th is to guarantee page alignment */
index 9659295..b7f7ac0 100644 (file)
@@ -207,7 +207,7 @@ KeUserModeCallback(IN ULONG RoutineIndex,
   NewFrame = (PKTRAP_FRAME)((char*)NewStack + StackSize - sizeof(KTRAP_FRAME) - sizeof(FX_SAVE_AREA));
   /* We need the stack pointer to remain 4-byte aligned */
   NewFrame->Esp -= (((ArgumentLength + 3) & (~ 0x3)) + (4 * sizeof(ULONG)));
-  NewFrame->Eip = (ULONG)LdrpGetSystemDllCallbackDispatcher();
+  NewFrame->Eip = (ULONG)KeUserCallbackDispatcher;
   UserEsp = (PULONG)NewFrame->Esp;
   UserEsp[0] = 0;     /* Return address. */
   UserEsp[1] = RoutineIndex;
diff --git a/reactos/ntoskrnl/ldr/init.c b/reactos/ntoskrnl/ldr/init.c
deleted file mode 100644 (file)
index 2ceac6a..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/* $Id$
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/ldr/init.c
- * PURPOSE:         Loaders for PE executables
- *
- * PROGRAMMERS:     Jean Michault
- *                  Rex Jolliff (rex@lvcablemodem.com)
- */
-
-/* INCLUDES *****************************************************************/
-
-
-#include <ntoskrnl.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-/* FUNCTIONS *****************************************************************/
-
-INIT_FUNCTION
-NTSTATUS
-LdrLoadInitialProcess(PHANDLE ProcessHandle,
-                     PHANDLE ThreadHandle)
-{
-   UNICODE_STRING ImagePath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\smss.exe");
-   HANDLE SystemProcessHandle;
-   NTSTATUS Status;
-   PRTL_USER_PROCESS_PARAMETERS Params=NULL;
-   RTL_USER_PROCESS_INFORMATION Info;
-
-   Status = ObpCreateHandle(
-      PsGetCurrentProcess(),
-      PsInitialSystemProcess,
-      PROCESS_CREATE_PROCESS | PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION,
-      FALSE,
-      &SystemProcessHandle
-      );
-
-   if(!NT_SUCCESS(Status))
-   {
-      DPRINT1("Failed to create a handle for the system process!\n");
-      return Status;
-   }
-
-
-   Status = RtlCreateProcessParameters(
-      &Params,
-      &ImagePath,
-      NULL,
-      NULL,
-      NULL,
-      NULL,
-      NULL,
-      NULL,
-      NULL,
-      NULL
-      );
-
-  if(!NT_SUCCESS(Status))
-  {
-    DPRINT1("Failed to create ppb!\n");
-    ZwClose(SystemProcessHandle);
-    return Status;
-  }
-
-
-   DPRINT("Creating process\n");
-
-   Status = RtlCreateUserProcess(
-      &ImagePath,
-      OBJ_CASE_INSENSITIVE, //Valid are OBJ_INHERIT and OBJ_CASE_INSENSITIVE.
-      Params,
-      NULL,
-      NULL,
-      SystemProcessHandle,
-      FALSE,
-      NULL,
-      NULL,
-      &Info
-      );
-
-   ZwClose(SystemProcessHandle);
-   RtlDestroyProcessParameters(Params);
-
-   if (!NT_SUCCESS(Status))
-   {
-      DPRINT1("NtCreateProcess() failed (Status %lx)\n", Status);
-      return(Status);
-   }
-
-   ZwResumeThread(Info.ThreadHandle, NULL);
-
-   *ProcessHandle = Info.ProcessHandle;
-   *ThreadHandle= Info.ThreadHandle;
-
-   DPRINT("Process created successfully\n");
-
-   return(STATUS_SUCCESS);
-}
-
-/* EOF */
diff --git a/reactos/ntoskrnl/ldr/sysdll.c b/reactos/ntoskrnl/ldr/sysdll.c
deleted file mode 100644 (file)
index 44e6989..0000000
+++ /dev/null
@@ -1,278 +0,0 @@
-/* $Id$
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/ldr/sysdll.c
- * PURPOSE:         Loaders for PE executables
- *
- * PROGRAMMERS:     Jean Michault
- *                  Rex Jolliff (rex@lvcablemodem.com)
- *                  Skywing
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ntoskrnl.h>
-#define NDEBUG
-#include <internal/debug.h>
-
-/* GLOBALS *******************************************************************/
-
-PVOID SystemDllEntryPoint = NULL;
-PVOID SystemDllApcDispatcher = NULL;
-PVOID SystemDllCallbackDispatcher = NULL;
-PVOID SystemDllExceptionDispatcher = NULL;
-PVOID SystemDllRaiseExceptionDispatcher = NULL;
-
-PVOID LdrpSystemDllBase = NULL;
-PVOID LdrpSystemDllSection = NULL;
-
-/* FUNCTIONS *****************************************************************/
-
-PVOID LdrpGetSystemDllExceptionDispatcher(VOID)
-{
-  return(SystemDllExceptionDispatcher);
-}
-
-PVOID LdrpGetSystemDllCallbackDispatcher(VOID)
-{
-  return(SystemDllCallbackDispatcher);
-}
-
-PVOID LdrpGetSystemDllEntryPoint(VOID)
-{
-   return(SystemDllEntryPoint);
-}
-
-PVOID LdrpGetSystemDllApcDispatcher(VOID)
-{
-   return(SystemDllApcDispatcher);
-}
-
-PVOID LdrpGetSystemDllRaiseExceptionDispatcher(VOID)
-{
-   return(SystemDllRaiseExceptionDispatcher);
-}
-
-NTSTATUS
-STDCALL
-INIT_FUNCTION
-LdrpGetSystemDllEntryPoints(VOID)
-{
-    ANSI_STRING ProcedureName;
-    NTSTATUS Status;
-
-    /* Retrieve ntdll's startup address */
-    DPRINT("Getting Entrypoint: %p\n", LdrpSystemDllBase);
-    RtlInitAnsiString(&ProcedureName, "LdrInitializeThunk");
-    Status = LdrGetProcedureAddress((PVOID)LdrpSystemDllBase,
-                                    &ProcedureName,
-                                    0,
-                                    &SystemDllEntryPoint);
-
-    if (!NT_SUCCESS(Status)) {
-
-        DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status);
-        return (Status);
-    }
-
-    /* Get User APC Dispatcher */
-    DPRINT("Getting Entrypoint\n");
-    RtlInitAnsiString(&ProcedureName, "KiUserApcDispatcher");
-    Status = LdrGetProcedureAddress((PVOID)LdrpSystemDllBase,
-                                    &ProcedureName,
-                                    0,
-                                    &SystemDllApcDispatcher);
-
-    if (!NT_SUCCESS(Status)) {
-
-        DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status);
-        return (Status);
-    }
-
-    /* Get Exception Dispatcher */
-    DPRINT("Getting Entrypoint\n");
-    RtlInitAnsiString(&ProcedureName, "KiUserExceptionDispatcher");
-    Status = LdrGetProcedureAddress((PVOID)LdrpSystemDllBase,
-                                    &ProcedureName,
-                                    0,
-                                    &SystemDllExceptionDispatcher);
-
-    if (!NT_SUCCESS(Status)) {
-
-        DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status);
-        return (Status);
-    }
-
-    /* Get Callback Dispatcher */
-    DPRINT("Getting Entrypoint\n");
-    RtlInitAnsiString(&ProcedureName, "KiUserCallbackDispatcher");
-    Status = LdrGetProcedureAddress((PVOID)LdrpSystemDllBase,
-                                    &ProcedureName,
-                                    0,
-                                    &SystemDllCallbackDispatcher);
-
-    if (!NT_SUCCESS(Status)) {
-
-        DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status);
-        return (Status);
-    }
-
-    /* Get Raise Exception Dispatcher */
-    DPRINT("Getting Entrypoint\n");
-    RtlInitAnsiString(&ProcedureName, "KiRaiseUserExceptionDispatcher");
-    Status = LdrGetProcedureAddress((PVOID)LdrpSystemDllBase,
-                                    &ProcedureName,
-                                    0,
-                                    &SystemDllRaiseExceptionDispatcher);
-
-    if (!NT_SUCCESS(Status)) {
-
-        DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status);
-        return (Status);
-    }
-
-    /* Return success */
-    return(STATUS_SUCCESS);
-}
-
-NTSTATUS
-STDCALL
-LdrpMapSystemDll(PEPROCESS Process,
-                 PVOID *DllBase)
-{
-    NTSTATUS Status;
-    ULONG ViewSize = 0;
-    PVOID ImageBase = 0;
-
-    /* Map the System DLL */
-    DPRINT("Mapping System DLL\n");
-    Status = MmMapViewOfSection(LdrpSystemDllSection,
-                                Process,
-                                (PVOID*)&ImageBase,
-                                0,
-                                0,
-                                NULL,
-                                &ViewSize,
-                                0,
-                                MEM_COMMIT,
-                                PAGE_READWRITE);
-
-    if (!NT_SUCCESS(Status)) {
-
-        DPRINT1("Failed to map System DLL Into Process\n");
-    }
-
-    if (DllBase) *DllBase = ImageBase;
-
-    return Status;
-}
-
-NTSTATUS
-STDCALL
-INIT_FUNCTION
-LdrpInitializeSystemDll(VOID)
-{
-    UNICODE_STRING DllPathname = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntdll.dll");
-    OBJECT_ATTRIBUTES FileObjectAttributes;
-    IO_STATUS_BLOCK Iosb;
-    HANDLE FileHandle;
-    HANDLE NTDllSectionHandle;
-    NTSTATUS Status;
-    CHAR BlockBuffer[1024];
-    PIMAGE_DOS_HEADER DosHeader;
-    PIMAGE_NT_HEADERS NTHeaders;
-
-    /* Locate and open NTDLL to determine ImageBase and LdrStartup */
-    InitializeObjectAttributes(&FileObjectAttributes,
-                               &DllPathname,
-                               0,
-                               NULL,
-                               NULL);
-
-    DPRINT("Opening NTDLL\n");
-    Status = ZwOpenFile(&FileHandle,
-                        FILE_READ_ACCESS,
-                        &FileObjectAttributes,
-                        &Iosb,
-                        FILE_SHARE_READ,
-                        FILE_SYNCHRONOUS_IO_NONALERT);
-
-    if (!NT_SUCCESS(Status)) {
-        DPRINT1("NTDLL open failed (Status %x)\n", Status);
-        return Status;
-     }
-
-     /* Load NTDLL is valid */
-     DPRINT("Reading NTDLL\n");
-     Status = ZwReadFile(FileHandle,
-                         0,
-                         0,
-                         0,
-                         &Iosb,
-                         BlockBuffer,
-                         sizeof(BlockBuffer),
-                         0,
-                         0);
-    if (!NT_SUCCESS(Status) || Iosb.Information != sizeof(BlockBuffer)) {
-
-        DPRINT1("NTDLL header read failed (Status %x)\n", Status);
-        ZwClose(FileHandle);
-        return Status;
-    }
-
-    /* Check if it's valid */
-    DosHeader = (PIMAGE_DOS_HEADER)BlockBuffer;
-    NTHeaders = (PIMAGE_NT_HEADERS)(BlockBuffer + DosHeader->e_lfanew);
-
-    if ((DosHeader->e_magic != IMAGE_DOS_SIGNATURE) ||
-        (DosHeader->e_lfanew == 0L) ||
-        (*(PULONG) NTHeaders != IMAGE_NT_SIGNATURE)) {
-
-        DPRINT1("NTDLL format invalid\n");
-        ZwClose(FileHandle);
-        return(STATUS_UNSUCCESSFUL);
-    }
-
-    /* Create a section for NTDLL */
-    DPRINT("Creating section\n");
-    Status = ZwCreateSection(&NTDllSectionHandle,
-                             SECTION_ALL_ACCESS,
-                             NULL,
-                             NULL,
-                             PAGE_READONLY,
-                             SEC_IMAGE | SEC_COMMIT,
-                             FileHandle);
-    if (!NT_SUCCESS(Status)) {
-
-        DPRINT1("NTDLL create section failed (Status %x)\n", Status);
-        ZwClose(FileHandle);
-        return(Status);
-    }
-    ZwClose(FileHandle);
-
-    /* Reference the Section */
-    DPRINT("ObReferenceObjectByHandle section: %d\n", NTDllSectionHandle);
-    Status = ObReferenceObjectByHandle(NTDllSectionHandle,
-                                       SECTION_ALL_ACCESS,
-                                       MmSectionObjectType,
-                                       KernelMode,
-                                       (PVOID*)&LdrpSystemDllSection,
-                                       NULL);
-    if (!NT_SUCCESS(Status)) {
-
-        DPRINT1("NTDLL section reference failed (Status %x)\n", Status);
-        return(Status);
-    }
-
-    /* Map it */
-    LdrpMapSystemDll(PsGetCurrentProcess(), &LdrpSystemDllBase);
-    DPRINT("LdrpSystemDllBase: %x\n", LdrpSystemDllBase);
-
-    /* Now get the Entrypoints */
-    LdrpGetSystemDllEntryPoints();
-
-    return STATUS_SUCCESS;
-}
-
-/* EOF */
diff --git a/reactos/ntoskrnl/ldr/userldr.c b/reactos/ntoskrnl/ldr/userldr.c
deleted file mode 100644 (file)
index 136ef09..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* $Id$
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/ldr/userldr.c
- * PURPOSE:         Loaders for PE executables
- *
- * PROGRAMMERS:     Jean Michault
- *                  Rex Jolliff (rex@lvcablemodem.com)
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ntoskrnl.h>
-#define NDEBUG
-#include <internal/debug.h>
-
-
-/* FUNCTIONS *****************************************************************/
-
-NTSTATUS LdrpMapImage(HANDLE ProcessHandle,
-                     HANDLE SectionHandle,
-                     PVOID* ReturnedImageBase)
-/*
- * FUNCTION: LdrpMapImage maps a user-mode image into an address space
- * PARAMETERS:
- *   ProcessHandle
- *              Points to the process to map the image into
- *
- *   SectionHandle
- *              Points to the section to map
- *
- * RETURNS: Status
- */
-{
-  ULONG ViewSize;
-  PVOID ImageBase;
-  NTSTATUS Status;
-
-  ViewSize = 0;
-  ImageBase = 0;
-
-  Status = ZwMapViewOfSection(SectionHandle,
-                             ProcessHandle,
-                             (PVOID*)&ImageBase,
-                             0,
-                             ViewSize,
-                             NULL,
-                             &ViewSize,
-                             0,
-                             MEM_COMMIT,
-                             PAGE_READWRITE);
-  if (!NT_SUCCESS(Status))
-    {
-      CPRINT("Image map view of section failed (Status %x)", Status);
-      return(Status);
-    }
-
-   *ReturnedImageBase = ImageBase;
-
-   return(STATUS_SUCCESS);
-}
index 8da017e..8445ea9 100644 (file)
                <file>kdmain.c</file>
        </directory>
        <directory name="ldr">
-               <file>init.c</file>
                <file>loader.c</file>
                <file>resource.c</file>
                <file>rtl.c</file>
-               <file>sysdll.c</file>
-               <file>userldr.c</file>
        </directory>
        <directory name="lpc">
                <file>close.c</file>
index a73ea57..06de86f 100644 (file)
@@ -357,7 +357,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
     {
         /* Map the System Dll */
         DPRINT("Mapping System DLL\n");
-        LdrpMapSystemDll(Process, NULL);
+        PspMapSystemDll(Process, NULL);
     }
 
     /* Create a handle for the Process */
index 4b5ea86..b68a454 100644 (file)
@@ -36,6 +36,14 @@ static GENERIC_MAPPING PiThreadMapping = {
 extern ULONG NtBuildNumber;
 extern ULONG NtMajorVersion;
 extern ULONG NtMinorVersion;
+extern PVOID KeUserApcDispatcher;
+extern PVOID KeUserCallbackDispatcher;
+extern PVOID KeUserExceptionDispatcher;
+extern PVOID KeRaiseUserExceptionDispatcher;
+
+PVOID PspSystemDllBase = NULL;
+PVOID PspSystemDllSection = NULL;
+PVOID PspSystemDllEntryPoint = NULL;
 
 VOID
 INIT_FUNCTION
@@ -274,6 +282,229 @@ PspPostInitSystemProcess(VOID)
     KEBUGCHECK(0);
   }
 }
+
+NTSTATUS
+STDCALL
+INIT_FUNCTION
+PspLookupKernelUserEntryPoints(VOID)
+{
+    ANSI_STRING ProcedureName;
+    NTSTATUS Status;
+
+    /* Retrieve ntdll's startup address */
+    DPRINT("Getting Entrypoint: %p\n", PspSystemDllBase);
+    RtlInitAnsiString(&ProcedureName, "LdrInitializeThunk");
+    Status = LdrGetProcedureAddress((PVOID)PspSystemDllBase,
+                                    &ProcedureName,
+                                    0,
+                                    &PspSystemDllEntryPoint);
+
+    if (!NT_SUCCESS(Status)) {
+
+        DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status);
+        return (Status);
+    }
+
+    /* Get User APC Dispatcher */
+    DPRINT("Getting Entrypoint\n");
+    RtlInitAnsiString(&ProcedureName, "KiUserApcDispatcher");
+    Status = LdrGetProcedureAddress((PVOID)PspSystemDllBase,
+                                    &ProcedureName,
+                                    0,
+                                    &KeUserApcDispatcher);
+
+    if (!NT_SUCCESS(Status)) {
+
+        DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status);
+        return (Status);
+    }
+
+    /* Get Exception Dispatcher */
+    DPRINT("Getting Entrypoint\n");
+    RtlInitAnsiString(&ProcedureName, "KiUserExceptionDispatcher");
+    Status = LdrGetProcedureAddress((PVOID)PspSystemDllBase,
+                                    &ProcedureName,
+                                    0,
+                                    &KeUserExceptionDispatcher);
+
+    if (!NT_SUCCESS(Status)) {
+
+        DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status);
+        return (Status);
+    }
+
+    /* Get Callback Dispatcher */
+    DPRINT("Getting Entrypoint\n");
+    RtlInitAnsiString(&ProcedureName, "KiUserCallbackDispatcher");
+    Status = LdrGetProcedureAddress((PVOID)PspSystemDllBase,
+                                    &ProcedureName,
+                                    0,
+                                    &KeUserCallbackDispatcher);
+
+    if (!NT_SUCCESS(Status)) {
+
+        DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status);
+        return (Status);
+    }
+
+    /* Get Raise Exception Dispatcher */
+    DPRINT("Getting Entrypoint\n");
+    RtlInitAnsiString(&ProcedureName, "KiRaiseUserExceptionDispatcher");
+    Status = LdrGetProcedureAddress((PVOID)PspSystemDllBase,
+                                    &ProcedureName,
+                                    0,
+                                    &KeRaiseUserExceptionDispatcher);
+
+    if (!NT_SUCCESS(Status)) {
+
+        DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status);
+        return (Status);
+    }
+
+    /* Return success */
+    return(STATUS_SUCCESS);
+}
+
+NTSTATUS
+STDCALL
+PspMapSystemDll(PEPROCESS Process,
+                PVOID *DllBase)
+{
+    NTSTATUS Status;
+    ULONG ViewSize = 0;
+    PVOID ImageBase = 0;
+
+    /* Map the System DLL */
+    DPRINT("Mapping System DLL\n");
+    Status = MmMapViewOfSection(PspSystemDllSection,
+                                Process,
+                                (PVOID*)&ImageBase,
+                                0,
+                                0,
+                                NULL,
+                                &ViewSize,
+                                0,
+                                MEM_COMMIT,
+                                PAGE_READWRITE);
+
+    if (!NT_SUCCESS(Status)) {
+
+        DPRINT1("Failed to map System DLL Into Process\n");
+    }
+
+    if (DllBase) *DllBase = ImageBase;
+
+    return Status;
+}
+
+NTSTATUS
+STDCALL
+INIT_FUNCTION
+PsLocateSystemDll(VOID)
+{
+    UNICODE_STRING DllPathname = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntdll.dll");
+    OBJECT_ATTRIBUTES FileObjectAttributes;
+    IO_STATUS_BLOCK Iosb;
+    HANDLE FileHandle;
+    HANDLE NTDllSectionHandle;
+    NTSTATUS Status;
+    CHAR BlockBuffer[1024];
+    PIMAGE_DOS_HEADER DosHeader;
+    PIMAGE_NT_HEADERS NTHeaders;
+
+    /* Locate and open NTDLL to determine ImageBase and LdrStartup */
+    InitializeObjectAttributes(&FileObjectAttributes,
+                               &DllPathname,
+                               0,
+                               NULL,
+                               NULL);
+
+    DPRINT("Opening NTDLL\n");
+    Status = ZwOpenFile(&FileHandle,
+                        FILE_READ_ACCESS,
+                        &FileObjectAttributes,
+                        &Iosb,
+                        FILE_SHARE_READ,
+                        FILE_SYNCHRONOUS_IO_NONALERT);
+
+    if (!NT_SUCCESS(Status)) {
+        DPRINT1("NTDLL open failed (Status %x)\n", Status);
+        return Status;
+     }
+
+     /* Load NTDLL is valid */
+     DPRINT("Reading NTDLL\n");
+     Status = ZwReadFile(FileHandle,
+                         0,
+                         0,
+                         0,
+                         &Iosb,
+                         BlockBuffer,
+                         sizeof(BlockBuffer),
+                         0,
+                         0);
+    if (!NT_SUCCESS(Status) || Iosb.Information != sizeof(BlockBuffer)) {
+
+        DPRINT1("NTDLL header read failed (Status %x)\n", Status);
+        ZwClose(FileHandle);
+        return Status;
+    }
+
+    /* Check if it's valid */
+    DosHeader = (PIMAGE_DOS_HEADER)BlockBuffer;
+    NTHeaders = (PIMAGE_NT_HEADERS)(BlockBuffer + DosHeader->e_lfanew);
+
+    if ((DosHeader->e_magic != IMAGE_DOS_SIGNATURE) ||
+        (DosHeader->e_lfanew == 0L) ||
+        (*(PULONG) NTHeaders != IMAGE_NT_SIGNATURE)) {
+
+        DPRINT1("NTDLL format invalid\n");
+        ZwClose(FileHandle);
+        return(STATUS_UNSUCCESSFUL);
+    }
+
+    /* Create a section for NTDLL */
+    DPRINT("Creating section\n");
+    Status = ZwCreateSection(&NTDllSectionHandle,
+                             SECTION_ALL_ACCESS,
+                             NULL,
+                             NULL,
+                             PAGE_READONLY,
+                             SEC_IMAGE | SEC_COMMIT,
+                             FileHandle);
+    if (!NT_SUCCESS(Status)) {
+
+        DPRINT1("NTDLL create section failed (Status %x)\n", Status);
+        ZwClose(FileHandle);
+        return(Status);
+    }
+    ZwClose(FileHandle);
+
+    /* Reference the Section */
+    DPRINT("ObReferenceObjectByHandle section: %d\n", NTDllSectionHandle);
+    Status = ObReferenceObjectByHandle(NTDllSectionHandle,
+                                       SECTION_ALL_ACCESS,
+                                       MmSectionObjectType,
+                                       KernelMode,
+                                       (PVOID*)&PspSystemDllSection,
+                                       NULL);
+    if (!NT_SUCCESS(Status)) {
+
+        DPRINT1("NTDLL section reference failed (Status %x)\n", Status);
+        return(Status);
+    }
+
+    /* Map it */
+    PspMapSystemDll(PsGetCurrentProcess(), &PspSystemDllBase);
+    DPRINT("LdrpSystemDllBase: %x\n", PspSystemDllBase);
+
+    /* Now get the Entrypoints */
+    PspLookupKernelUserEntryPoints();
+
+    return STATUS_SUCCESS;
+}
+
+
 /**********************************************************************
  * NAME                                                        EXPORTED
  *     PsGetVersion
index 763ea5f..3838dfd 100644 (file)
@@ -18,6 +18,7 @@
 
 extern LIST_ENTRY PsActiveProcessHead;
 extern PEPROCESS PsIdleProcess;
+extern PVOID PspSystemDllEntryPoint;
 
 POBJECT_TYPE EXPORTED PsThreadType = NULL;
 
@@ -57,7 +58,7 @@ PspUserThreadStartup(PKSTART_ROUTINE StartRoutine,
                         OriginalApcEnvironment,
                         PspThreadSpecialApc,
                         NULL,
-                        LdrpGetSystemDllEntryPoint(),
+                        PspSystemDllEntryPoint,
                         UserMode,
                         NULL);