#include "captive/signal.h" /* for captive_signal_init() */
#include "reactos/ddk/psfuncs.h" /* for PsGetCurrentThread() */
#include <stdio.h>
-#include "reactos/internal/ex.h" /* for ExpInitLookasideLists() */
#include <popt.h>
#include <glib/gstrfuncs.h>
+#include <glib/glist.h>
/* Are we initialized? */
enum captive_option_media captive_option_media=CAPTIVE_OPTION_MEDIA_DISK;
GIOChannel *captive_image_iochannel;
guint64 captive_image_size;
+static GList *captive_load_module;
static gchar *captive_popt_optarg;
captive_option_filesystem=g_strdup(captive_popt_optarg);
}
+static void arg_load_module(void)
+{
+ captive_load_module=g_list_append(captive_load_module,g_strdup(captive_popt_optarg));
+}
+
static void arg_ro(void)
{
captive_option_rwmode=CAPTIVE_OPTION_RWMODE_RO;
#define CAPTIVE_POPT_NONE(longname,descripP) \
CAPTIVE_POPT(longname,POPT_ARG_NONE ,NULL ,descripP,NULL )
- CAPTIVE_POPT_STRING("filesystem",N_("Path to .sys or .so filesystem module file"),N_("pathname")),
- CAPTIVE_POPT_NONE( "ro" ,N_("Read/write mode: Any write access will be forbidden")),
- CAPTIVE_POPT_NONE( "blind" ,N_("Read/write mode: All writes are just simulated in memory (default)")),
- CAPTIVE_POPT_NONE( "rw" ,N_("Read/write mode: Write directly to the image file/device")),
- CAPTIVE_POPT_NONE( "cdrom" ,N_("Media type: CD-ROM")),
- CAPTIVE_POPT_NONE( "disk" ,N_("Media type: Disk (default)")),
+ CAPTIVE_POPT_STRING("filesystem" ,N_("Path to .sys or .so filesystem module file"),N_("pathname")),
+ CAPTIVE_POPT_STRING("load-module",N_("Path to any W32 module to load w/o initialization"),N_("pathname")),
+ CAPTIVE_POPT_NONE( "ro" ,N_("Read/write mode: Any write access will be forbidden")),
+ CAPTIVE_POPT_NONE( "blind" ,N_("Read/write mode: All writes are just simulated in memory (default)")),
+ CAPTIVE_POPT_NONE( "rw" ,N_("Read/write mode: Write directly to the image file/device")),
+ CAPTIVE_POPT_NONE( "cdrom" ,N_("Media type: CD-ROM")),
+ CAPTIVE_POPT_NONE( "disk" ,N_("Media type: Disk (default)")),
#undef CAPTIVE_POPT_NONE
#undef CAPTIVE_POPT_STRING
static void (*const popt_func_table[])(void)={
arg_filesystem,
+ arg_load_module,
arg_ro,
arg_blind,
arg_rw,
/* Part of reactos/ntoskrnl/ps/psmgr.c/PiInitProcessManager() ends. */
/*...*/
IoInit();
- /* Exinit(); */
- /* Part of reactos/ntoskrnl/ex/init.c/Exinit() begins. */
- ExpInitLookasideLists();
- /* Part of reactos/ntoskrnl/ex/init.c/Exinit() ends. */
/*...*/
/* LdrInitModuleManagement(); */
/* Part of reactos/ntoskrnl/ldr/loader.c/LdrInitModuleManagement() begins
/* Part of reactos/ntoskrnl/ke/main.c/ExpInitializeExecutive() ends. */
/* Part of reactos/ntoskrnl/ke/main.c/KiSystemStartup() ends. */
- /* Simulate our PE headers and export the symbols of {NTOSKRNL,HAL} */
+ /* Simulate our PE headers and export the symbols of our complete libraries */
captive_kernel_exports();
errbool=captive_cdrom_init();
errbool=captive_disk_init();
g_return_val_if_fail(errbool==TRUE,FALSE);
- err=captive_LdrpLoadAndCallImage(
- &ModuleObject, /* ModuleObjectp */
- captive_utf8_to_UnicodeString_alloca(captive_option_filesystem), /* ModuleName */
- &DriverObject, /* DriverEntry_DriverObject */
- captive_utf8_to_UnicodeString_alloca("\\captive\\filesystem")); /* DriverEntry_RegistryPath */
- g_return_val_if_fail(NT_SUCCESS(err),FALSE);
+ while (captive_load_module) {
+gchar *modulename=captive_load_module->data;
+PMODULE_OBJECT ModuleObject_tmp;
+NTSTATUS err;
+
+ /* load the module */
+ err=LdrLoadModule(
+ captive_utf8_to_UnicodeString_alloca(modulename), /* ModuleName */
+ &ModuleObject_tmp); /* ModuleObjectp */
+ g_return_val_if_fail(NT_SUCCESS(err),FALSE);
+
+ captive_load_module=g_list_remove(captive_load_module,modulename);
+ }
+
+ /* Patch 'ntoskrnl.exe' loaded by 'captive_load_module' above. */
+ captive_kernel_patches();
/* set TopLevelIrp() - FIXME: where is it set by native reactos? */
PsGetCurrentThread()->TopLevelIrp=&TopLevelIrp; /* otherwise Io{Get,Set}TopLevelIrp() would SIGSEGV */
*/
captive_signal_init();
+ /* You must have already captive_signal_init() passed here as the module may
+ * call some functions from W32 ntoskrnl.exe.
+ */
+ err=captive_LdrpLoadAndCallImage(
+ &ModuleObject, /* ModuleObjectp */
+ captive_utf8_to_UnicodeString_alloca(captive_option_filesystem), /* ModuleName */
+ &DriverObject, /* DriverEntry_DriverObject */
+ captive_utf8_to_UnicodeString_alloca("\\captive\\filesystem")); /* DriverEntry_RegistryPath */
+ g_return_val_if_fail(NT_SUCCESS(err),FALSE);
+
return TRUE;
}