/* Driver in fs module loaded by captive_init(fs_path) */
static DRIVER_OBJECT DriverObject;
-/* Handle for the root directory of the mounted volume */
-static HANDLE root_Handle;
-
/* Structure holding the pointer to the toplevel IRP */
static TOP_LEVEL_IRP TopLevelIrp; /* TODO:thread */
* captive_init:
* @fs_path: Host OS file #utf8 pathname of the filesystem module to load.
* %NULL value is forbidden.
- * @image_pathname: Host OS file #utf8 pathname of the disk image to mount.
+ * @image_iochannel: Host OS file of the disk image to mount.
* %NULL value is forbidden.
*
* Initializes %libcaptive and loads the specified filesystem.
*
* Returns: %TRUE if successfuly loaded.
*/
-gboolean captive_init(const gchar *fs_path,const gchar *image_pathname)
+gboolean captive_init(const gchar *fs_path,GIOChannel *image_iochannel)
{
NTSTATUS err;
gboolean errbool;
-OBJECT_ATTRIBUTES root_ObjectAttributes;
-IO_STATUS_BLOCK root_IoStatusBlock;
-FILE_ID_BOTH_DIR_INFORMATION *FileIdBothDirInformation,*FileIdBothDirInformation_next;
-char QueryDirectory_buf[0x10000];
+GIOStatus erriostatus;
#ifdef MAINTAINER_MODE
g_log_set_always_fatal(~(0
#endif
g_return_val_if_fail(fs_path!=NULL,FALSE);
- g_return_val_if_fail(image_pathname!=NULL,FALSE);
+ g_return_val_if_fail(image_iochannel!=NULL,FALSE);
g_return_val_if_fail(active==FALSE,FALSE);
+ erriostatus=g_io_channel_set_encoding(image_iochannel,
+ NULL, /* encoding; force binary data */
+ NULL); /* error */
+ g_assert(erriostatus==G_IO_STATUS_NORMAL);
+
/* Part of reactos/ntoskrnl/ke/main.c/KiSystemStartup() begins. */
/* ExpInitializeExecutive(); */
/* Part of reactos/ntoskrnl/ke/main.c/ExpInitializeExecutive() begins
/* Simulate our PE headers and export the symbols of {NTOSKRNL,HAL} */
captive_kernel_exports();
- errbool=captive_cdrom_init(image_pathname);
+ errbool=captive_cdrom_init(image_iochannel);
g_return_val_if_fail(errbool==TRUE,FALSE);
err=captive_LdrpLoadAndCallImage(
*/
captive_signal_init();
- /* Do not open "\Cdfs"(anything) as it is just the filesystem implementation.
- * ntoskrnl/io/fs.c/IoMountVolume() will map
- * FILE_DEVICE_CD_ROM -> FILE_DEVICE_CD_ROM_FILE_SYSTEM
- * for us automatically when opening the device itself.
- * Also you must put some trailing content there as otherwise
- * IoCreateFile()->ObCreateObject()->ObFindObject()
- * would leave 'ObCreateObject::RemainingPath' as NULL
- * and later IopCreateFile() would consider it FO_DIRECT_DEVICE_OPEN (e.g. w/o any mount!)
- */
- InitializeObjectAttributes(
- &root_ObjectAttributes, /* InitializedAttributes */
- captive_utf8_to_UnicodeString_alloca("\\Device\\CdRom0\\."), /* 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_SYNCHRONOUS_IO_{,NON}ALERT: We need to allow W32 filesystem
- * any waits to not to let it return STATUS_CANT_WAIT us.
- * Alertability should have only effect on asynchronous events
- * from KeWaitForSingleObject() by setting/clearing its parameter 'Alertable'.
- */
- FILE_DIRECTORY_FILE|FILE_SYNCHRONOUS_IO_ALERT, /* 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);
-
-
- err=NtQueryDirectoryFile(
- root_Handle, /* FileHandle */
- NULL, /* PEvent; completion signalling; optional */
- NULL, /* ApcRoutine; optional */
- NULL, /* ApcContext; optional */
- &root_IoStatusBlock, /* IoStatusBlock */
- (gpointer)QueryDirectory_buf, /* FileInformation */
- sizeof(QueryDirectory_buf), /* Length */
- FileIdBothDirectoryInformation, /* FileInformationClass; =>FILE_ID_BOTH_DIR_INFORMATION */
- FALSE, /* ReturnSingleEntry */
- NULL, /* FileName; wildcards possible; optional */
- TRUE); /* RestartScan */
- g_return_val_if_fail(NT_SUCCESS(err),FALSE);
- g_return_val_if_fail(NT_SUCCESS(root_IoStatusBlock.Status),FALSE);
-
- for (FileIdBothDirInformation=(gpointer)QueryDirectory_buf;
- (gpointer)FileIdBothDirInformation < (gpointer)(QueryDirectory_buf+root_IoStatusBlock.Information);
- FileIdBothDirInformation=FileIdBothDirInformation_next) {
-gint i;
-
- FileIdBothDirInformation_next=(gpointer)(((char *)FileIdBothDirInformation)+FileIdBothDirInformation->NextEntryOffset);
- /* do not exceed the returned buffer by this record */
- g_assert((gpointer)FileIdBothDirInformation_next<=(gpointer)(QueryDirectory_buf+root_IoStatusBlock.Information));
-
- printf("@%ld: FileIndex=%lu,EndOfFile=%lld,AllocationSize=%lld,FileId=0x%llX,",
- (long)(((char *)FileIdBothDirInformation)-((char *)QueryDirectory_buf)), /* @%ld */
- FileIdBothDirInformation->FileIndex,
- FileIdBothDirInformation->EndOfFile.QuadPart,
- FileIdBothDirInformation->AllocationSize.QuadPart,
- (unsigned long long)FileIdBothDirInformation->FileId.QuadPart);
- printf("ShortName=\"");
- g_assert((FileIdBothDirInformation->ShortNameLength%sizeof(*FileIdBothDirInformation->ShortName))==0);
- for (i=0;(unsigned)i<FileIdBothDirInformation->ShortNameLength/sizeof(*FileIdBothDirInformation->ShortName);i++) {
-gunichar uc=FileIdBothDirInformation->ShortName[i];
-
- if (g_unichar_isprint(uc) && uc<=0xFF)
- putchar(uc);
- else
- printf("[0x%X]",(unsigned)uc);
- }
- printf("\",");
- printf("FileName: ");
- g_assert((FileIdBothDirInformation->FileNameLength)%sizeof(*FileIdBothDirInformation->FileName)==0);
- for (i=0;(unsigned)i<FileIdBothDirInformation->FileNameLength/sizeof(*FileIdBothDirInformation->FileName);i++) {
-gunichar uc=FileIdBothDirInformation->FileName[i];
-
- if (g_unichar_isprint(uc) && uc<=0xFF)
- putchar(uc);
- else
- printf("[0x%X]",(unsigned)uc);
- }
- printf("\n");
- /* Last entry may be also marked by: 0==FileIdBothDirInformation->NextEntryOffset */
- if (FileIdBothDirInformation_next==FileIdBothDirInformation)
- break;
- }
-
-
active=TRUE;
return TRUE;
}