[RAMDISK]

- Fix DeviceRelations allocation bug
- Code style: Use sizeof(UNICODE_NULL) where needed; use sizeof(*ptr) for size of type pointed by ptr, when allocating space for ptr.

svn path=/trunk/; revision=66020
This commit is contained in:
Hermès Bélusca-Maïto 2015-01-09 18:26:17 +00:00
parent 64f6189e30
commit 79f472a422

View file

@ -1048,8 +1048,8 @@ RamdiskReadWrite(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp) IN PIRP Irp)
{ {
PRAMDISK_DRIVE_EXTENSION DeviceExtension; PRAMDISK_DRIVE_EXTENSION DeviceExtension;
//ULONG Length; // ULONG Length;
//LARGE_INTEGER ByteOffset; // LARGE_INTEGER ByteOffset;
PIO_STACK_LOCATION IoStackLocation; PIO_STACK_LOCATION IoStackLocation;
NTSTATUS Status, ReturnStatus; NTSTATUS Status, ReturnStatus;
@ -1064,8 +1064,8 @@ RamdiskReadWrite(IN PDEVICE_OBJECT DeviceObject,
/* Capture parameters */ /* Capture parameters */
IoStackLocation = IoGetCurrentIrpStackLocation(Irp); IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
//Length = IoStackLocation->Parameters.Read.Length; // Length = IoStackLocation->Parameters.Read.Length;
//ByteOffset = IoStackLocation->Parameters.Read.ByteOffset; // ByteOffset = IoStackLocation->Parameters.Read.ByteOffset;
/* FIXME: Validate offset */ /* FIXME: Validate offset */
@ -1345,7 +1345,7 @@ RamdiskQueryDeviceRelations(IN DEVICE_RELATION_TYPE Type,
/* Allocate a buffer big enough to contain only one DO */ /* Allocate a buffer big enough to contain only one DO */
DeviceRelations = ExAllocatePoolWithTag(PagedPool, DeviceRelations = ExAllocatePoolWithTag(PagedPool,
sizeof(DeviceRelations), sizeof(*DeviceRelations),
'dmaR'); 'dmaR');
if (DeviceRelations != NULL) if (DeviceRelations != NULL)
{ {
@ -1795,7 +1795,7 @@ RamdiskQueryBusInformation(IN PDEVICE_OBJECT DeviceObject,
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
/* Allocate output memory */ /* Allocate output memory */
PnpBusInfo = ExAllocatePoolWithTag(PagedPool, sizeof(PNP_BUS_INFORMATION), 'dmaR'); PnpBusInfo = ExAllocatePoolWithTag(PagedPool, sizeof(*PnpBusInfo), 'dmaR');
if (PnpBusInfo == NULL) if (PnpBusInfo == NULL)
{ {
Status = STATUS_INSUFFICIENT_RESOURCES; Status = STATUS_INSUFFICIENT_RESOURCES;
@ -2301,8 +2301,7 @@ RamdiskAddDevice(IN PDRIVER_OBJECT DriverObject,
{ {
/* Initialize the bus FDO extension */ /* Initialize the bus FDO extension */
DeviceExtension = DeviceObject->DeviceExtension; DeviceExtension = DeviceObject->DeviceExtension;
RtlZeroMemory(DeviceObject->DeviceExtension, RtlZeroMemory(DeviceExtension, sizeof(*DeviceExtension));
sizeof(RAMDISK_BUS_EXTENSION));
/* Set bus FDO flags */ /* Set bus FDO flags */
DeviceObject->Flags |= DO_POWER_PAGABLE | DO_DIRECT_IO; DeviceObject->Flags |= DO_POWER_PAGABLE | DO_DIRECT_IO;
@ -2349,7 +2348,7 @@ RamdiskAddDevice(IN PDRIVER_OBJECT DriverObject,
/* Are we being booted from setup? Not yet supported */ /* Are we being booted from setup? Not yet supported */
if (KeLoaderBlock->SetupLdrBlock) if (KeLoaderBlock->SetupLdrBlock)
DPRINT1("FIXME: RamdiskAddDevice is UNSUPPORTED when being started from SETUPLDR!\n"); DPRINT1("FIXME: RamdiskAddDevice is UNSUPPORTED when being started from SETUPLDR!\n");
//ASSERT(!KeLoaderBlock->SetupLdrBlock); // ASSERT(!KeLoaderBlock->SetupLdrBlock);
} }
/* All done */ /* All done */
@ -2378,7 +2377,7 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject,
DriverRegistryPath = *RegistryPath; DriverRegistryPath = *RegistryPath;
DriverRegistryPath.Buffer = ExAllocatePoolWithTag(PagedPool, DriverRegistryPath.Buffer = ExAllocatePoolWithTag(PagedPool,
RegistryPath->Length + RegistryPath->Length +
sizeof(WCHAR), sizeof(UNICODE_NULL),
'dmaR'); 'dmaR');
if (!DriverRegistryPath.Buffer) return STATUS_INSUFFICIENT_RESOURCES; if (!DriverRegistryPath.Buffer) return STATUS_INSUFFICIENT_RESOURCES;
RtlCopyUnicodeString(&DriverRegistryPath, RegistryPath); RtlCopyUnicodeString(&DriverRegistryPath, RegistryPath);
@ -2437,7 +2436,7 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject,
/* Installing from Ramdisk isn't supported yet */ /* Installing from Ramdisk isn't supported yet */
if (KeLoaderBlock->SetupLdrBlock) if (KeLoaderBlock->SetupLdrBlock)
DPRINT1("FIXME: Installing from RamDisk is UNSUPPORTED!\n"); DPRINT1("FIXME: Installing from RamDisk is UNSUPPORTED!\n");
//ASSERT(!KeLoaderBlock->SetupLdrBlock); // ASSERT(!KeLoaderBlock->SetupLdrBlock);
/* Are we reporting the device */ /* Are we reporting the device */
if (ReportDetectedDevice) if (ReportDetectedDevice)