captive_init(): +fs mount
authorshort <>
Sat, 2 Nov 2002 23:49:19 +0000 (23:49 +0000)
committershort <>
Sat, 2 Nov 2002 23:49:19 +0000 (23:49 +0000)
 - not working yet

src/libcaptive/client/init.c

index 37e4f92..b9eb336 100644 (file)
@@ -34,6 +34,7 @@
 #include "reactos/ddk/kefuncs.h"       /* for KeInitializeSpinLock() */
 #include "reactos/internal/ntoskrnl.h" /* for RtlpInitNlsTables() and IoInit() */
 #include "reactos/internal/ps.h"       /* for PsInitProcessManagment() and PsInitThreadManagment() */
+#include "reactos/ddk/iofuncs.h"       /* for IoCreateFile() */
 
 
 /* Are we initialized? */
@@ -43,7 +44,10 @@ static gboolean active;
 static PMODULE_OBJECT ModuleObject;
 
 /* Driver in fs module loaded by captive_init(fs_path) */
-static DRIVER_OBJECT DriverObject_static;
+static DRIVER_OBJECT DriverObject;
+
+/* Handle for the root directory of the mounted volume */
+static HANDLE root_Handle;
 
 /**
  * captive_init:
@@ -56,6 +60,8 @@ static DRIVER_OBJECT DriverObject_static;
 gboolean captive_init(const gchar *fs_path)
 {
 NTSTATUS err;
+OBJECT_ATTRIBUTES root_ObjectAttributes;
+IO_STATUS_BLOCK root_IoStatusBlock;
 
 #ifdef MAINTAINER_MODE
        g_log_set_always_fatal(~(0
@@ -103,18 +109,47 @@ NTSTATUS err;
                /* 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} */
        captive_kernel_exports();
 
        err=captive_LdrpLoadAndCallImage(
                        &ModuleObject,  /* ModuleObjectp */
                        captive_utf8_to_UnicodeString_alloca(fs_path),  /* ModuleName */
-                       &DriverObject_static,   /* DriverEntry_DriverObject */
+                       &DriverObject,  /* DriverEntry_DriverObject */
                        captive_utf8_to_UnicodeString_alloca("\\FIXME\\FIXME"));        /* DriverEntry_RegistryPath */
        g_return_val_if_fail(NT_SUCCESS(err),FALSE);
        
+       /* FIXME: root_ObjectAttributes: InitializeObjectAttributes() */
+       InitializeObjectAttributes(
+                       &root_ObjectAttributes, /* InitializedAttributes */
+                       captive_utf8_to_UnicodeString_alloca("\\Cdfs"), /* ObjectName */
+                       0,      /* Attributes; I hope no OBJ_KERNEL_HANDLE as we are 'system process' */
+                       NULL,   /* RootDirectory */
+                       NULL);  /* SecurityDescriptor; ignored */
+
+       /* wanted: * IoCreateFile()->ObCreateObject(,,,IoFileObjectType)->
+        * ->(IoFileObjectType->Create==IopCreateFile)()->IoMountVolume()
+        */
+       err=IoCreateFile(
+                       &root_Handle,   /* FileHandle */
+                       FILE_LIST_DIRECTORY,    /* DesiredAccess */
+                       &root_ObjectAttributes, /* ObjectAttributes */
+                       &root_IoStatusBlock,    /* IoStatusBlock */
+                       NULL,   /* AllocationSize; ignored for open */
+                       FILE_ATTRIBUTE_NORMAL,  /* FileAttributes; ignored for open */
+                       0,      /* ShareAccess; 0 means exclusive */
+                       FILE_OPEN,      /* CreateDisposition */
+                       FILE_DIRECTORY_FILE,    /* CreateOptions */
+                       NULL,   /* EaBuffer */
+                       0,      /* EaLength */
+                       CreateFileTypeNone,     /* CreateFileType */
+                       NULL,   /* ExtraCreateParameters */
+                       0);     /* Options */
+       g_return_val_if_fail(NT_SUCCESS(err),FALSE);
+       g_return_val_if_fail(NT_SUCCESS(root_IoStatusBlock.Status),FALSE);
+       g_return_val_if_fail(root_IoStatusBlock.Information==FILE_OPENED,FALSE);
+
+
        active=TRUE;
        return TRUE;
 }