mirror of
https://github.com/reactos/reactos.git
synced 2025-07-03 13:21:23 +00:00
A few minor changes
svn path=/trunk/; revision=2585
This commit is contained in:
parent
8acb48f0de
commit
8e5647c51a
1 changed files with 66 additions and 25 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include <ntddk.h>
|
#include <ntddk.h>
|
||||||
#include "ramdrv.h"
|
#include "ramdrv.h"
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
#include "../../../lib/bzip2/bzlib.h"
|
||||||
|
|
||||||
NTSTATUS STDCALL RamdrvDispatchReadWrite(PDEVICE_OBJECT DeviceObject,
|
NTSTATUS STDCALL RamdrvDispatchReadWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
PIRP Irp)
|
PIRP Irp)
|
||||||
|
@ -51,6 +52,9 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
||||||
IO_STATUS_BLOCK iosb;
|
IO_STATUS_BLOCK iosb;
|
||||||
LARGE_INTEGER allocsize;
|
LARGE_INTEGER allocsize;
|
||||||
HANDLE event;
|
HANDLE event;
|
||||||
|
void *tbuff;
|
||||||
|
unsigned int dstlen = 1024 * 1440;
|
||||||
|
FILE_STANDARD_INFORMATION finfo;
|
||||||
|
|
||||||
DbgPrint("Ramdisk driver\n");
|
DbgPrint("Ramdisk driver\n");
|
||||||
|
|
||||||
|
@ -80,15 +84,15 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
||||||
devext->Buffer = ExAllocatePool( PagedPool, devext->Size );
|
devext->Buffer = ExAllocatePool( PagedPool, devext->Size );
|
||||||
if( !devext->Buffer )
|
if( !devext->Buffer )
|
||||||
{
|
{
|
||||||
IoDeleteDevice( DeviceObject );
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
goto cleandevice;
|
||||||
}
|
}
|
||||||
RtlInitUnicodeString( &LinkName, L"\\ArcName\\virt(0)disk(0)ram(0)" );
|
RtlInitUnicodeString( &LinkName, L"\\ArcName\\virt(0)disk(0)ram(0)" );
|
||||||
IoAssignArcName( &LinkName, &DeviceName );
|
IoAssignArcName( &LinkName, &DeviceName );
|
||||||
RtlInitUnicodeString( &LinkName, L"\\??\\Z:" );
|
RtlInitUnicodeString( &LinkName, L"\\??\\Z:" );
|
||||||
IoCreateSymbolicLink( &LinkName, &DeviceName );
|
IoCreateSymbolicLink( &LinkName, &DeviceName );
|
||||||
|
|
||||||
RtlInitUnicodeString( &LinkName, L"\\Device\\Floppy0" );
|
RtlInitUnicodeString( &LinkName, L"\\Device\\Floppy0\\ramdisk.bz2" );
|
||||||
InitializeObjectAttributes( &objattr,
|
InitializeObjectAttributes( &objattr,
|
||||||
&LinkName,
|
&LinkName,
|
||||||
0,
|
0,
|
||||||
|
@ -96,22 +100,19 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
||||||
0 );
|
0 );
|
||||||
allocsize.u.LowPart = allocsize.u.HighPart = 0;
|
allocsize.u.LowPart = allocsize.u.HighPart = 0;
|
||||||
|
|
||||||
Status = NtCreateFile( &file,
|
Status = NtOpenFile( &file,
|
||||||
GENERIC_READ | GENERIC_WRITE,
|
GENERIC_READ,
|
||||||
&objattr,
|
&objattr,
|
||||||
&iosb,
|
&iosb,
|
||||||
&allocsize,
|
FILE_SHARE_READ,
|
||||||
0,
|
FILE_NO_INTERMEDIATE_BUFFERING );
|
||||||
0,
|
|
||||||
OPEN_EXISTING,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0 );
|
|
||||||
if( !NT_SUCCESS( Status ) )
|
if( !NT_SUCCESS( Status ) )
|
||||||
{
|
{
|
||||||
DPRINT( "Failed to open floppy\n" );
|
DPRINT( "Failed to open floppy\n" );
|
||||||
return STATUS_SUCCESS;
|
goto cleanbuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeObjectAttributes( &objattr,
|
InitializeObjectAttributes( &objattr,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -125,8 +126,26 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
||||||
if( !NT_SUCCESS( Status ) )
|
if( !NT_SUCCESS( Status ) )
|
||||||
{
|
{
|
||||||
DPRINT( "Failed to create event\n" );
|
DPRINT( "Failed to create event\n" );
|
||||||
NtClose( file );
|
goto cleanfile;
|
||||||
return STATUS_SUCCESS;
|
}
|
||||||
|
|
||||||
|
Status = NtQueryInformationFile( file,
|
||||||
|
&iosb,
|
||||||
|
&finfo,
|
||||||
|
sizeof( finfo ),
|
||||||
|
FileStandardInformation );
|
||||||
|
|
||||||
|
if( !NT_SUCCESS( Status ) )
|
||||||
|
{
|
||||||
|
DPRINT1( "Failed to query file information\n" );
|
||||||
|
goto cleanevent;
|
||||||
|
}
|
||||||
|
tbuff = ExAllocatePool( PagedPool, finfo.EndOfFile.u.LowPart );
|
||||||
|
if( !tbuff )
|
||||||
|
{
|
||||||
|
DPRINT1( "Failed to allocate buffer of size %d\n", finfo.EndOfFile.u.LowPart );
|
||||||
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
goto cleanevent;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = NtReadFile( file,
|
Status = NtReadFile( file,
|
||||||
|
@ -134,27 +153,49 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
&iosb,
|
&iosb,
|
||||||
devext->Buffer,
|
tbuff,
|
||||||
1440 * 1024,
|
finfo.EndOfFile.u.LowPart,
|
||||||
&allocsize,
|
&allocsize,
|
||||||
0 );
|
0 );
|
||||||
|
|
||||||
if( !NT_SUCCESS( Status ) )
|
if( !NT_SUCCESS( Status ) )
|
||||||
{
|
{
|
||||||
NtClose( file );
|
|
||||||
NtClose( event );
|
|
||||||
DPRINT( "Failed to read floppy\n" );
|
DPRINT( "Failed to read floppy\n" );
|
||||||
return STATUS_SUCCESS;
|
goto cleantbuff;
|
||||||
}
|
}
|
||||||
Status = NtWaitForSingleObject( event, FALSE, 0 );
|
Status = NtWaitForSingleObject( event, FALSE, 0 );
|
||||||
if( Status != STATUS_WAIT_0 || !NT_SUCCESS( iosb.Status ) )
|
if( Status != STATUS_WAIT_0 || !NT_SUCCESS( iosb.Status ) )
|
||||||
{
|
{
|
||||||
DPRINT( "Failed to read floppy\n" );
|
DPRINT( "Failed to read floppy\n" );
|
||||||
NtClose( file );
|
goto cleantbuff;
|
||||||
NtClose( event );
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
DPRINT( "Read in %d bytes, decompressing now\n", iosb.Information );
|
||||||
|
asm( "int3" );
|
||||||
|
BZ2_bzBuffToBuffDecompress( devext->Buffer,
|
||||||
|
&dstlen,
|
||||||
|
tbuff,
|
||||||
|
iosb.Information,
|
||||||
|
1,
|
||||||
|
0 );
|
||||||
|
DPRINT( "Decompressed\n" );
|
||||||
|
ExFreePool( tbuff );
|
||||||
NtClose( file );
|
NtClose( file );
|
||||||
NtClose( event );
|
NtClose( event );
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
|
cleantbuff:
|
||||||
|
ExFreePool( tbuff );
|
||||||
|
cleanevent:
|
||||||
|
NtClose( event );
|
||||||
|
cleanfile:
|
||||||
|
NtClose( file );
|
||||||
|
cleanbuffer:
|
||||||
|
ExFreePool( devext->Buffer );
|
||||||
|
|
||||||
|
cleandevice:
|
||||||
|
IoDeleteDevice( DeviceObject );
|
||||||
|
for(;;);
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue