Relative include path fixed to absolute path.
[reactos.git] / reactos / drivers / dd / ramdrv / ramdrv.c
index c3b273b..1219ae3 100644 (file)
@@ -1,7 +1,48 @@
 #include <ntddk.h>
 #include "ramdrv.h"
 #include <debug.h>
-#include "../../../lib/bzip2/bzlib.h"
+#include "../../lib/bzip2/bzlib.h"
+
+NTSTATUS STDCALL RamdrvDispatchDeviceControl(PDEVICE_OBJECT DeviceObject,
+                                            PIRP Irp)
+{
+   PIO_STACK_LOCATION IrpStack;
+   ULONG ControlCode, InputLength, OutputLength;
+   NTSTATUS Status;
+
+   DPRINT("RamdrvDispatchDeviceControl\n");
+
+   IrpStack = IoGetCurrentIrpStackLocation(Irp);
+   ControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
+   InputLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
+   OutputLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
+
+   switch (ControlCode)
+   {
+      case IOCTL_DISK_GET_DRIVE_GEOMETRY:
+         if (OutputLength < sizeof(DISK_GEOMETRY))
+         {
+            Status = STATUS_INVALID_PARAMETER;
+        }
+        else
+        {
+            PDISK_GEOMETRY Geometry = Irp->AssociatedIrp.SystemBuffer;
+            Geometry->MediaType = F3_1Pt44_512;
+            Geometry->Cylinders.QuadPart = 80;
+            Geometry->TracksPerCylinder = 2 * 18;
+            Geometry->SectorsPerTrack = 18;
+            Geometry->BytesPerSector = 512;
+            Status = STATUS_SUCCESS;
+            Irp->IoStatus.Information = sizeof(DISK_GEOMETRY);
+        }
+        break;
+     default:
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+   }
+   Irp->IoStatus.Status = Status;
+   IoCompleteRequest(Irp, NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT);   
+   return Status;
+}
 
 NTSTATUS STDCALL RamdrvDispatchReadWrite(PDEVICE_OBJECT DeviceObject,
                                         PIRP Irp)
@@ -42,7 +83,7 @@ NTSTATUS STDCALL RamdrvDispatchOpenClose(PDEVICE_OBJECT DeviceObject,
 NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
                             IN PUNICODE_STRING RegistryPath)
 {
-  UNICODE_STRING DeviceName;
+  UNICODE_STRING DeviceName = UNICODE_STRING_INITIALIZER(L"\\Device\\Ramdisk");
   NTSTATUS Status;
   PDEVICE_OBJECT DeviceObject;
   PRAMDRV_DEVICE_EXTENSION devext;
@@ -64,12 +105,10 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
   DriverObject->MajorFunction[IRP_MJ_CLOSE] = RamdrvDispatchOpenClose;
   DriverObject->MajorFunction[IRP_MJ_READ] = RamdrvDispatchReadWrite;
   DriverObject->MajorFunction[IRP_MJ_WRITE] = RamdrvDispatchReadWrite;
-  //   DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
-  //   RamdrvDispatchDeviceControl;
+  DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = RamdrvDispatchDeviceControl;
   
   
   // create device and symbolic link
-  RtlInitUnicodeString( &DeviceName, L"\\Device\\Ramdisk" );
   Status = IoCreateDevice( DriverObject,
                           sizeof( RAMDRV_DEVICE_EXTENSION ),
                           &DeviceName,
@@ -88,10 +127,10 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
       Status = STATUS_INSUFFICIENT_RESOURCES;
       goto cleandevice;
     }
-  RtlInitUnicodeString( &LinkName, L"\\??\\Z:" );
+  RtlInitUnicodeStringFromLiteral( &LinkName, L"\\??\\Z:" );
   IoCreateSymbolicLink( &LinkName, &DeviceName );
 
-  RtlInitUnicodeString( &LinkName, L"\\Device\\Floppy0\\ramdisk.bz2" );
+  RtlInitUnicodeStringFromLiteral( &LinkName, L"\\Device\\Floppy0\\ramdisk.bz2" );
   InitializeObjectAttributes( &objattr,
                              &LinkName,
                              0,
@@ -176,7 +215,9 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
                                    1,
                                    0 );
   if( err == 0 )
+  {
     DPRINT( "RAMDRV: Image Decompressed\n");
+  }
   else DbgPrint( "RAMDRV: Failed to decomparess image, error: %d\n", err );
   ExFreePool( tbuff );
   NtClose( file );