bootstrap
[reactos.git] / ntoskrnl / ldr / loader.c
index eba5f27..cf2b120 100644 (file)
@@ -52,8 +52,10 @@ LIST_ENTRY ModuleListHead;
 KSPIN_LOCK ModuleListLock;
 
 LIST_ENTRY ModuleTextListHead;
+#ifndef LIBCAPTIVE
 STATIC MODULE_TEXT_SECTION NtoskrnlTextSection;
 STATIC MODULE_TEXT_SECTION LdrHalTextSection;
+#endif /* LIBCAPTIVE */
 ULONG_PTR LdrHalBase;
 
 #define TAG_DRIVER_MEM  TAG('D', 'R', 'V', 'M')
@@ -88,10 +90,12 @@ LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject,
                      PCHAR Name,
                      USHORT Hint);
 
+#ifndef LIBCAPTIVE
 static PVOID
 LdrSafePEGetExportAddress(PVOID ImportModuleBase,
                          PCHAR Name,
                          USHORT Hint);
+#endif /* LIBCAPTIVE */
 
 static PVOID
 LdrPEFixupForward(PCHAR ForwardName);
@@ -99,6 +103,8 @@ LdrPEFixupForward(PCHAR ForwardName);
 
 /* FUNCTIONS *****************************************************************/
 
+#ifndef LIBCAPTIVE
+
 VOID
 LdrInitDebug(PLOADER_MODULE Module, PWCH Name)
 {
@@ -418,6 +424,7 @@ LdrLoadModule(PUNICODE_STRING Filename,
   return(STATUS_SUCCESS);
 }
 
+#endif /* LIBCAPTIVE */
 
 NTSTATUS
 LdrUnloadModule(PMODULE_OBJECT ModuleObject)
@@ -449,6 +456,7 @@ LdrUnloadModule(PMODULE_OBJECT ModuleObject)
   return(STATUS_SUCCESS);
 }
 
+#ifndef LIBCAPTIVE
 
 NTSTATUS
 LdrInitializeBootStartDriver(PVOID ModuleLoadBase,
@@ -546,6 +554,7 @@ LdrInitializeBootStartDriver(PVOID ModuleLoadBase,
   return(Status);
 }
 
+#endif /* LIBCAPTIVE */
 
 NTSTATUS
 LdrProcessModule(PVOID ModuleLoadBase,
@@ -583,6 +592,7 @@ LdrGetExportAddress(PMODULE_OBJECT ModuleObject,
     }
 }
 
+#ifndef LIBCAPTIVE
 
 NTSTATUS
 LdrpQueryModuleInformation(PVOID Buffer,
@@ -663,6 +673,7 @@ LdrpQueryModuleInformation(PVOID Buffer,
   return(STATUS_SUCCESS);
 }
 
+#endif /* LIBCAPTIVE */
 
 static VOID
 LdrpBuildModuleBaseName(PUNICODE_STRING BaseName,
@@ -970,10 +981,10 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
     {
       NumRelocs = (RelocDir->SizeOfBlock - sizeof(RELOCATION_DIRECTORY)) / 
         sizeof(WORD);
-/*      DPRINT("RelocDir at %08lx for VA %08lx with %08lx relocs\n",
+      DPRINT("RelocDir at %08lx for VA %08lx with %08lx relocs\n",
              RelocDir, 
              RelocDir->VirtualAddress,
-             NumRelocs);*/
+             NumRelocs);
       RelocEntry = (PRELOCATION_ENTRY) ((DWORD)RelocDir + 
         sizeof(RELOCATION_DIRECTORY));
       for (Idx = 0; Idx < NumRelocs; Idx++)
@@ -986,12 +997,12 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
           Type = (RelocEntry[Idx].TypeOffset >> 12) & 0xf;
           RelocItem = (PDWORD)(DriverBase + RelocDir->VirtualAddress + 
                                Offset);
-/*        DPRINT("  reloc at %08lx %x %s old:%08lx new:%08lx\n", 
+          DPRINT("  reloc at %08lx %x %s old:%08lx new:%08lx\n", 
                  RelocItem,
                  Type,
                  Type ? "HIGHLOW" : "ABS",
                  *RelocItem,
-                 (*RelocItem) + RelocDelta); */
+                 (*RelocItem) + RelocDelta);
           if (Type == 3)
             {
               (*RelocItem) += RelocDelta;
@@ -1034,7 +1045,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
           if (LibraryModuleObject == NULL)
             {
               CPRINT("Module '%wZ' not loaded yet\n", &ModuleName);
-              wcscpy(NameBuffer, L"\\SystemRoot\\system32\\drivers\\");
+              wcscpy(NameBuffer, REACTOS_UCS2(L"\\SystemRoot\\system32\\drivers\\"));
               wcscat(NameBuffer, ModuleName.Buffer);
               RtlInitUnicodeString(&NameString, NameBuffer);
               Status = LdrLoadModule(&NameString, &LibraryModuleObject);
@@ -1195,6 +1206,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
   return STATUS_SUCCESS;
 }
 
+#ifndef LIBCAPTIVE
 
 PVOID
 LdrSafePEProcessModule(PVOID ModuleLoadBase,
@@ -1435,6 +1447,7 @@ LdrSafePEProcessModule(PVOID ModuleLoadBase,
   return(0);
 }
 
+#endif /* LIBCAPTIVE */
 
 static PVOID
 LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject,
@@ -1494,8 +1507,12 @@ LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject,
     }
   else  /*  use hint  */
     {
+#ifndef LIBCAPTIVE
       ExportAddress = (PVOID) ((DWORD)ModuleObject->Base +
         FunctionList[Hint - ExportDir->Base]);
+#else /* !LIBCAPTIVE */
+      /* Ordinals not supported by libcaptive */
+#endif /* !LIBCAPTIVE */
     }
 
   if (ExportAddress == NULL)
@@ -1509,6 +1526,7 @@ LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject,
   return(ExportAddress);
 }
 
+#ifndef LIBCAPTIVE
 
 static PVOID
 LdrSafePEGetExportAddress(PVOID ImportModuleBase,
@@ -1570,6 +1588,7 @@ LdrSafePEGetExportAddress(PVOID ImportModuleBase,
   return ExportAddress;
 }
 
+#endif /* LIBCAPTIVE */
 
 static PVOID
 LdrPEFixupForward(PCHAR ForwardName)