Author: akhaldi
Date: Fri Jan 9 16:57:24 2015
New Revision: 66018
URL:
http://svn.reactos.org/svn/reactos?rev=66018&view=rev
Log:
[RAMDISK] Fix some comment typos. Convert comments to C style. No code changes.
Modified:
trunk/reactos/drivers/storage/class/ramdisk/ramdisk.c
Modified: trunk/reactos/drivers/storage/class/ramdisk/ramdisk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/class/ramd…
==============================================================================
--- trunk/reactos/drivers/storage/class/ramdisk/ramdisk.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/storage/class/ramdisk/ramdisk.c [iso-8859-1] Fri Jan 9 16:57:24
2015
@@ -90,14 +90,10 @@
typedef struct _RAMDISK_DRIVE_EXTENSION
{
- //
- // Inherited base class
- //
+ /* Inherited base class */
RAMDISK_EXTENSION;
- //
- // Data we get from the creator
- //
+ /* Data we get from the creator */
GUID DiskGuid;
UNICODE_STRING GuidString;
UNICODE_STRING SymbolicLinkName;
@@ -108,9 +104,7 @@
WCHAR DriveLetter;
ULONG BasePage;
- //
- // Data we get from the disk
- //
+ /* Data we get from the disk */
ULONG BytesPerSector;
ULONG SectorsPerTrack;
ULONG NumberOfHeads;
@@ -141,9 +135,7 @@
ULONG MinView, DefView, MinViewLength, DefViewLength, MaxViewLength;
RTL_QUERY_REGISTRY_TABLE QueryTable[10];
- //
- // Set defaults
- //
+ /* Set defaults */
MaximumViewLength = 0x10000000u;
MaximumPerDiskViewLength = 0x10000000u;
ReportDetectedDevice = 0;
@@ -154,9 +146,7 @@
MinimumViewLength = 0x10000u;
DefaultViewLength = 0x100000u;
- //
- // Setup the query table and query the registry
- //
+ /* Setup the query table and query the registry */
RtlZeroMemory(QueryTable, sizeof(QueryTable));
QueryTable[0].Flags = 1;
QueryTable[0].Name = L"Parameters";
@@ -193,9 +183,7 @@
NULL,
NULL);
- //
- // Parse minimum view count, cannot be bigger than 256 or smaller than 2
- //
+ /* Parse minimum view count, cannot be bigger than 256 or smaller than 2 */
MinView = MinimumViewCount;
if (MinimumViewCount >= 2)
{
@@ -207,9 +195,7 @@
}
MinimumViewCount = MinView;
- //
- // Parse default view count, cannot be bigger than 256 or smaller than minimum
- //
+ /* Parse default view count, cannot be bigger than 256 or smaller than minimum */
DefView = DefaultViewCount;
if (DefaultViewCount >= MinView)
{
@@ -221,9 +207,7 @@
}
DefaultViewCount = DefView;
- //
- // Parse maximum view count, cannot be bigger than 256 or smaller than default
- //
+ /* Parse maximum view count, cannot be bigger than 256 or smaller than default */
if (MaximumViewCount >= DefView)
{
if (MaximumViewCount > 256) MaximumViewCount = 256;
@@ -233,9 +217,7 @@
MaximumViewCount = DefView;
}
- //
- // Parse minimum view length, cannot be bigger than 1GB or smaller than 64KB
- //
+ /* Parse minimum view length, cannot be bigger than 1GB or smaller than 64KB */
MinViewLength = MinimumViewLength;
if (MinimumViewLength >= 0x10000)
{
@@ -247,9 +229,7 @@
}
MinimumViewLength = MinViewLength;
- //
- // Parse default view length, cannot be bigger than 1GB or smaller than minimum
- //
+ /* Parse default view length, cannot be bigger than 1GB or smaller than minimum */
DefViewLength = DefaultViewLength;
if (DefaultViewLength >= MinViewLength)
{
@@ -261,9 +241,7 @@
}
DefaultViewLength = DefViewLength;
- //
- // Parse maximum view length, cannot be bigger than 1GB or smaller than default
- //
+ /* Parse maximum view length, cannot be bigger than 1GB or smaller than default */
MaxViewLength = MaximumViewLength;
if (MaximumViewLength >= DefViewLength)
{
@@ -275,9 +253,7 @@
}
MaximumViewLength = MaxViewLength;
- //
- // Parse maximum view length per disk, cannot be smaller than 16MB
- //
+ /* Parse maximum view length per disk, cannot be smaller than 16MB */
if (MaximumPerDiskViewLength >= 0x1000000)
{
if (MaxViewLength > 0xFFFFFFFF) MaximumPerDiskViewLength = -1;
@@ -302,54 +278,34 @@
LARGE_INTEGER ActualOffset;
LARGE_INTEGER ActualPages;
- //
- // We only support boot disks for now
- //
+ /* We only support boot disks for now */
ASSERT(DeviceExtension->DiskType == RAMDISK_BOOT_DISK);
- //
- // Calculate the actual offset in the drive
- //
+ /* Calculate the actual offset in the drive */
ActualOffset.QuadPart = DeviceExtension->DiskOffset + Offset.QuadPart;
- //
- // Convert to pages
- //
+ /* Convert to pages */
ActualPages.QuadPart = ActualOffset.QuadPart >> PAGE_SHIFT;
- //
- // Now add the base page
- //
+ /* Now add the base page */
ActualPages.QuadPart = DeviceExtension->BasePage + ActualPages.QuadPart;
- //
- // Calculate final amount of bytes
- //
+ /* Calculate final amount of bytes */
PhysicalAddress.QuadPart = ActualPages.QuadPart << PAGE_SHIFT;
- //
- // Calculate pages spanned for the mapping
- //
+ /* Calculate pages spanned for the mapping */
ActualLength = ADDRESS_AND_SIZE_TO_SPAN_PAGES(ActualOffset.QuadPart, Length);
- //
- // And convert this back to bytes
- //
+ /* And convert this back to bytes */
ActualLength <<= PAGE_SHIFT;
- //
- // Get the offset within the page
- //
+ /* Get the offset within the page */
PageOffset = BYTE_OFFSET(ActualOffset.QuadPart);
- //
- // Map the I/O Space from the loader
- //
+ /* Map the I/O Space from the loader */
MappedBase = MmMapIoSpace(PhysicalAddress, ActualLength, MmCached);
- //
- // Return actual offset within the page as well as the length
- //
+ /* Return actual offset within the page as well as the length */
if (MappedBase) MappedBase = (PVOID)((ULONG_PTR)MappedBase + PageOffset);
*OutputLength = Length;
return MappedBase;
@@ -366,39 +322,25 @@
SIZE_T ActualLength;
ULONG PageOffset;
- //
- // We only support boot disks for now
- //
+ /* We only support boot disks for now */
ASSERT(DeviceExtension->DiskType == RAMDISK_BOOT_DISK);
- //
- // Calculate the actual offset in the drive
- //
+ /* Calculate the actual offset in the drive */
ActualOffset.QuadPart = DeviceExtension->DiskOffset + Offset.QuadPart;
- //
- // Calculate pages spanned for the mapping
- //
+ /* Calculate pages spanned for the mapping */
ActualLength = ADDRESS_AND_SIZE_TO_SPAN_PAGES(ActualOffset.QuadPart, Length);
- //
- // And convert this back to bytes
- //
+ /* And convert this back to bytes */
ActualLength <<= PAGE_SHIFT;
- //
- // Get the offset within the page
- //
+ /* Get the offset within the page */
PageOffset = BYTE_OFFSET(ActualOffset.QuadPart);
- //
- // Calculate actual base address where we mapped this
- //
+ /* Calculate actual base address where we mapped this */
BaseAddress = (PVOID)((ULONG_PTR)BaseAddress - PageOffset);
- //
- // Unmap the I/O space we got from the loader
- //
+ /* Unmap the I/O space we got from the loader */
MmUnmapIoSpace(BaseAddress, ActualLength);
}
@@ -424,26 +366,18 @@
LARGE_INTEGER CurrentOffset, CylinderSize, DiskLength;
ULONG CylinderCount, SizeByCylinders;
- //
- // Check if we're a boot RAM disk
- //
+ /* Check if we're a boot RAM disk */
DiskType = Input->DiskType;
if (DiskType >= RAMDISK_BOOT_DISK)
{
- //
- // Check if we're an ISO
- //
+ /* Check if we're an ISO */
if (DiskType == RAMDISK_BOOT_DISK)
{
- //
- // NTLDR mounted us somewhere
- //
+ /* NTLDR mounted us somewhere */
BasePage = Input->BasePage;
if (!BasePage) return STATUS_INVALID_PARAMETER;
- //
- // Sanitize disk options
- //
+ /* Sanitize disk options */
Input->Options.Fixed = TRUE;
Input->Options.Readonly = Input->Options.ExportAsCd |
Input->Options.Readonly;
@@ -453,25 +387,17 @@
}
else
{
- //
- // The only other possibility is a WIM disk
- //
+ /* The only other possibility is a WIM disk */
if (DiskType != RAMDISK_WIM_DISK)
{
- //
- // Fail
- //
+ /* Fail */
return STATUS_INVALID_PARAMETER;
}
- //
- // Read the view count instead
- //
+ /* Read the view count instead */
// ViewCount = Input->ViewCount;
- //
- // Sanitize disk options
- //
+ /* Sanitize disk options */
Input->Options.Hidden = FALSE;
Input->Options.NoDosDevice = FALSE;
Input->Options.Readonly = FALSE;
@@ -479,52 +405,36 @@
Input->Options.Fixed = TRUE;
}
- //
- // Are we just validating and returning to the user?
- //
+ /* Are we just validating and returning to the user? */
if (ValidateOnly) return STATUS_SUCCESS;
- //
- // Build the GUID string
- //
+ /* Build the GUID string */
Status = RtlStringFromGUID(&Input->DiskGuid, &GuidString);
if (!(NT_SUCCESS(Status)) || !(GuidString.Buffer))
{
- //
- // Fail
- //
+ /* Fail */
Status = STATUS_INSUFFICIENT_RESOURCES;
goto FailCreate;
}
- //
- // Allocate our device name
- //
+ /* Allocate our device name */
Length = GuidString.Length + 32;
- Buffer = ExAllocatePoolWithTag(NonPagedPool,
- Length,
- 'dmaR');
+ Buffer = ExAllocatePoolWithTag(NonPagedPool, Length, 'dmaR');
if (!Buffer)
{
- //
- // Fail
- //
+ /* Fail */
Status = STATUS_INSUFFICIENT_RESOURCES;
goto FailCreate;
}
- //
- // Build the device name string
- //
+ /* Build the device name string */
DeviceName.Buffer = Buffer;
DeviceName.Length = Length - 2;
DeviceName.MaximumLength = Length;
wcsncpy(Buffer, L"\\Device\\Ramdisk", Length / sizeof(WCHAR));
wcsncat(Buffer, GuidString.Buffer, Length / sizeof(WCHAR));
- //
- // Create the drive device
- //
+ /* Create the drive device */
Status = IoCreateDevice(DeviceExtension->DeviceObject->DriverObject,
sizeof(RAMDISK_DRIVE_EXTENSION),
&DeviceName,
@@ -535,19 +445,13 @@
&DeviceObject);
if (!NT_SUCCESS(Status)) goto FailCreate;
- //
- // Grab the drive extension
- //
+ /* Grab the drive extension */
DriveExtension = DeviceObject->DeviceExtension;
- //
- // Check if we need a DOS device
- //
+ /* Check if we need a DOS device */
if (!Input->Options.NoDosDevice)
{
- //
- // Build the symbolic link name
- //
+ /* Build the symbolic link name */
SymbolicLinkName.MaximumLength = GuidString.Length + 36;
SymbolicLinkName.Length = GuidString.Length + 34;
Buffer = ExAllocatePoolWithTag(NonPagedPool,
@@ -556,9 +460,7 @@
SymbolicLinkName.Buffer = Buffer;
if (Buffer)
{
- //
- // Create it
- //
+ /* Create it */
wcsncpy(Buffer,
L"\\GLOBAL??\\Ramdisk",
SymbolicLinkName.MaximumLength / sizeof(WCHAR));
@@ -568,9 +470,7 @@
Status = IoCreateSymbolicLink(&SymbolicLinkName, &DeviceName);
if (!NT_SUCCESS(Status))
{
- //
- // Nevermind...
- //
+ /* Nevermind... */
Input->Options.NoDosDevice = TRUE;
ExFreePool(Buffer);
SymbolicLinkName.Buffer = NULL;
@@ -578,25 +478,17 @@
}
else
{
- //
- // No DOS device
- //
+ /* No DOS device */
Input->Options.NoDosDevice = TRUE;
}
- //
- // It this an ISO boot ramdisk?
- //
+ /* Is this an ISO boot ramdisk? */
if (Input->DiskType == RAMDISK_BOOT_DISK)
{
- //
- // Does it need a drive letter?
- //
+ /* Does it need a drive letter? */
if (!Input->Options.NoDriveLetter)
{
- //
- // Build it and take over the existing symbolic link
- //
+ /* Build it and take over the existing symbolic link */
_snwprintf(LocalBuffer,
30,
L"\\DosDevices\\%wc:",
@@ -605,32 +497,23 @@
IoDeleteSymbolicLink(&DriveString);
IoCreateSymbolicLink(&DriveString, &DeviceName);
- //
- // Save the drive letter
- //
+ /* Save the drive letter */
DriveExtension->DriveLetter = Input->DriveLetter;
}
}
}
- //
- // Setup the device object flags
- //
+ /* Setup the device object flags */
DeviceObject->Flags |= (DO_XIP | DO_POWER_PAGABLE | DO_DIRECT_IO);
DeviceObject->AlignmentRequirement = 1;
- //
- // Build the drive FDO
- //
+ /* Build the drive FDO */
*NewDriveExtension = DriveExtension;
DriveExtension->Type = RamdiskDrive;
DiskLength = Input->DiskLength;
ExInitializeFastMutex(&DriveExtension->DiskListLock);
- IoInitializeRemoveLock(&DriveExtension->RemoveLock,
- 'dmaR',
- 1,
- 0);
+ IoInitializeRemoveLock(&DriveExtension->RemoveLock, 'dmaR', 1,
0);
DriveExtension->DriveDeviceName = DeviceName;
DriveExtension->SymbolicLinkName = SymbolicLinkName;
DriveExtension->GuidString = GuidString;
@@ -647,23 +530,17 @@
DriveExtension->SectorsPerTrack = 0;
DriveExtension->NumberOfHeads = 0;
- //
- // Make sure we don't free it later
- //
+ /* Make sure we don't free it later */
DeviceName.Buffer = NULL;
SymbolicLinkName.Buffer = NULL;
GuidString.Buffer = NULL;
- //
- // Check if this is an boot disk, or a registry ram drive
- //
+ /* Check if this is a boot disk, or a registry ram drive */
if (!(Input->Options.ExportAsCd) &&
(Input->DiskType == RAMDISK_BOOT_DISK))
{
- //
- // Not an ISO boot, but it's a boot FS -- map it to figure out the
- // drive settings
- //
+ /* Not an ISO boot, but it's a boot FS -- map it to figure out the
+ * drive settings */
CurrentOffset.QuadPart = 0;
BaseAddress = RamdiskMapPages(DriveExtension,
CurrentOffset,
@@ -671,25 +548,19 @@
&BytesRead);
if (BaseAddress)
{
- //
- // Get the data
- //
+ /* Get the data */
BootSector = (PPACKED_BOOT_SECTOR)BaseAddress;
FatUnpackBios(&BiosBlock, &BootSector->PackedBpb);
BytesPerSector = BiosBlock.BytesPerSector;
SectorsPerTrack = BiosBlock.SectorsPerTrack;
Heads = BiosBlock.Heads;
- //
- // Save it
- //
+ /* Save it */
DriveExtension->BytesPerSector = BytesPerSector;
DriveExtension->SectorsPerTrack = SectorsPerTrack;
DriveExtension->NumberOfHeads = Heads;
- //
- // Unmap now
- //
+ /* Unmap now */
CurrentOffset.QuadPart = 0;
RamdiskUnmapPages(DriveExtension,
BaseAddress,
@@ -698,47 +569,35 @@
}
else
{
- //
- // Fail
- //
+ /* Fail */
Status = STATUS_INSUFFICIENT_RESOURCES;
goto FailCreate;
}
}
- //
- // Check if the drive settings haven't been set yet
- //
+ /* Check if the drive settings haven't been set yet */
if ((DriveExtension->BytesPerSector == 0) ||
(DriveExtension->SectorsPerTrack == 0) ||
(DriveExtension->NumberOfHeads == 0))
{
- //
- // Check if this is a CD
- //
+ /* Check if this is a CD */
if (Input->Options.ExportAsCd)
{
- //
- // Setup partition parameters default for ISO 9660
- //
+ /* Setup partition parameters default for ISO 9660 */
DriveExtension->BytesPerSector = 2048;
DriveExtension->SectorsPerTrack = 32;
DriveExtension->NumberOfHeads = 64;
}
else
{
- //
- // Setup partition parameters default for FAT
- //
+ /* Setup partition parameters default for FAT */
DriveExtension->BytesPerSector = 512;
DriveExtension->SectorsPerTrack = 128;
DriveExtension->NumberOfHeads = 16;
}
}
- //
- // Calculate the cylinder size
- //
+ /* Calculate the cylinder size */
CylinderSize.QuadPart = DriveExtension->BytesPerSector *
DriveExtension->SectorsPerTrack *
DriveExtension->NumberOfHeads;
@@ -747,32 +606,22 @@
DriveExtension->Cylinders = CylinderCount;
if ((DiskLength.HighPart > 0) || (SizeByCylinders < DiskLength.LowPart))
{
- //
- // Align cylinder size up
- //
+ /* Align cylinder size up */
DriveExtension->Cylinders++;
}
- //
- // Acquire the disk lock
- //
+ /* Acquire the disk lock */
KeEnterCriticalRegion();
ExAcquireFastMutex(&DeviceExtension->DiskListLock);
- //
- // Insert us
- //
+ /* Insert us */
InsertTailList(&DeviceExtension->DiskList,
&DriveExtension->DiskList);
- //
- // Release the lock
- //
+ /* Release the lock */
ExReleaseFastMutex(&DeviceExtension->DiskListLock);
KeLeaveCriticalRegion();
- //
- // Clear init flag
- //
+ /* Clear init flag */
DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
return STATUS_SUCCESS;
}
@@ -797,92 +646,63 @@
NTSTATUS Status;
PIO_STACK_LOCATION IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
- //
- // Get the device extension and our input data
- //
+ /* Get the device extension and our input data */
DeviceExtension = DeviceObject->DeviceExtension;
Length = IoStackLocation->Parameters.DeviceIoControl.InputBufferLength;
Input = (PRAMDISK_CREATE_INPUT)Irp->AssociatedIrp.SystemBuffer;
- //
- // Validate input parameters
- //
+ /* Validate input parameters */
if ((Length < sizeof(RAMDISK_CREATE_INPUT)) ||
(Input->Version != sizeof(RAMDISK_CREATE_INPUT)))
{
- //
- // Invalid input
- //
return STATUS_INVALID_PARAMETER;
}
- //
- // Validate the disk type
- //
+ /* Validate the disk type */
DiskType = Input->DiskType;
if (DiskType == RAMDISK_WIM_DISK) return STATUS_INVALID_PARAMETER;
- //
- // Look at the disk type
- //
+ /* Look at the disk type */
if (DiskType == RAMDISK_BOOT_DISK)
{
- //
- // We only allow this as an early-init boot
- //
+ /* We only allow this as an early-init boot */
if (!KeLoaderBlock) return STATUS_INVALID_PARAMETER;
- //
- // Save command-line flags
- //
+ /* Save command-line flags */
if (ExportBootDiskAsCd) Input->Options.ExportAsCd = TRUE;
if (IsWinPEBoot) Input->Options.NoDriveLetter = TRUE;
}
- //
- // Validate the disk type
- //
+ /* Validate the disk type */
if ((Input->Options.ExportAsCd) && (DiskType != RAMDISK_BOOT_DISK))
{
- //
- // If the type isn't CDFS, it has to at least be raw CD
- //
+ /* If the type isn't CDFS, it has to at least be raw CD */
if (DiskType != RAMDISK_MEMORY_MAPPED_DISK) return STATUS_INVALID_PARAMETER;
}
- //
- // Check if this is an actual file
- //
+ /* Check if this is an actual file */
if (DiskType <= RAMDISK_MEMORY_MAPPED_DISK)
{
- //
- // Validate the file name
- //
+ /* Validate the file name */
FileNameStart = (PWCHAR)((ULONG_PTR)Input + Length);
FileNameEnd = Input->FileName + 1;
while ((FileNameEnd < FileNameStart) && *(FileNameEnd))
FileNameEnd++;
if (FileNameEnd == FileNameStart) return STATUS_INVALID_PARAMETER;
}
- //
- // Create the actual device
- //
+ /* Create the actual device */
Status = RamdiskCreateDiskDevice(DeviceExtension,
Input,
ValidateOnly,
&DriveExtension);
if (NT_SUCCESS(Status))
{
- //
- // Invalidate and set success
- //
+ /* Invalidate and set success */
IoInvalidateDeviceRelations(DeviceExtension->PhysicalDeviceObject, 0);
Irp->IoStatus.Information = STATUS_SUCCESS;
}
- //
- // We're done
- //
+ /* We're done */
return Status;
}
@@ -898,40 +718,30 @@
ULONG Length;
PIO_STACK_LOCATION IoStackLocation;
- //
- // Validate the length
- //
+ /* Validate the length */
IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
if (IoStackLocation->Parameters.DeviceIoControl.
OutputBufferLength < sizeof(PARTITION_INFORMATION))
{
- //
- // Invalid length
- //
+ /* Invalid length */
Status = STATUS_BUFFER_TOO_SMALL;
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
return Status;
}
- //
- // Map the partition table
- //
+ /* Map the partition table */
BaseAddress = RamdiskMapPages(DeviceExtension, Zero, PAGE_SIZE, &Length);
if (!BaseAddress)
{
- //
- // No memory
- //
+ /* No memory */
Status = STATUS_INSUFFICIENT_RESOURCES;
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
return Status;
}
- //
- // Fill out the information
- //
+ /* Fill out the information */
PartitionInfo = Irp->AssociatedIrp.SystemBuffer;
PartitionInfo->StartingOffset.QuadPart = DeviceExtension->BytesPerSector;
PartitionInfo->PartitionLength.QuadPart = DeviceExtension->BytesPerSector *
@@ -947,14 +757,10 @@
PartitionType);
PartitionInfo->RewritePartition = FALSE;
- //
- // Unmap the partition table
- //
+ /* Unmap the partition table */
RamdiskUnmapPages(DeviceExtension, BaseAddress, Zero, Length);
- //
- // Done
- //
+ /* Done */
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = sizeof(PARTITION_INFORMATION);
return STATUS_SUCCESS;
@@ -972,9 +778,7 @@
LARGE_INTEGER Zero = {{0, 0}};
PPARTITION_INFORMATION PartitionInfo;
- //
- // First validate input
- //
+ /* First validate input */
Stack = IoGetCurrentIrpStackLocation(Irp);
if (Stack->Parameters.DeviceIoControl.InputBufferLength <
sizeof(PARTITION_INFORMATION))
{
@@ -982,9 +786,7 @@
goto SetAndQuit;
}
- //
- // Map to get MBR
- //
+ /* Map to get MBR */
BaseAddress = RamdiskMapPages(DeviceExtension, Zero, PAGE_SIZE, &BytesRead);
if (BaseAddress == NULL)
{
@@ -992,16 +794,11 @@
goto SetAndQuit;
}
- //
- // Set the new partition type
- // On partition 0, field system indicator
- //
+ /* Set the new partition type on partition 0, field system indicator */
PartitionInfo = (PPARTITION_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
*((PCHAR)BaseAddress + 450) = PartitionInfo->PartitionType;
- //
- // And unmap
- //
+ /* And unmap */
RamdiskUnmapPages(DeviceExtension, BaseAddress, Zero, BytesRead);
Status = STATUS_SUCCESS;
@@ -1021,46 +818,30 @@
PIO_STACK_LOCATION IoStackLocation;
PIRP Irp = Context;
- //
- // Get the stack location
- //
+ /* Get the stack location */
IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
- //
- // Free the work item
- //
+ /* Free the work item */
IoFreeWorkItem(Irp->Tail.Overlay.DriverContext[0]);
- //
- // Grab the device extension and lock it
- //
+ /* Grab the device extension and lock it */
DeviceExtension = DeviceObject->DeviceExtension;
Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, Irp);
if (NT_SUCCESS(Status))
{
- //
- // Discriminate by major code
- //
+ /* Discriminate by major code */
switch (IoStackLocation->MajorFunction)
{
- //
- // Device control
- //
+ /* Device control */
case IRP_MJ_DEVICE_CONTROL:
{
- //
- // Let's take a look at the IOCTL
- //
+ /* Let's take a look at the IOCTL */
switch (IoStackLocation->Parameters.DeviceIoControl.IoControlCode)
{
- //
- // Ramdisk create request
- //
+ /* Ramdisk create request */
case FSCTL_CREATE_RAM_DISK:
{
- //
- // This time we'll do it for real
- //
+ /* This time we'll do it for real */
Status = RamdiskCreateRamdisk(DeviceObject, Irp, FALSE);
break;
}
@@ -1086,45 +867,34 @@
break;
}
- //
- // We're here
- //
+ /* We're here */
break;
}
- //
- // Read or write request
- //
+ /* Read or write request */
case IRP_MJ_READ:
case IRP_MJ_WRITE:
UNIMPLEMENTED_DBGBREAK("Read/Write request\n");
break;
- //
- // Internal request (SCSI?)
- //
+ /* Internal request (SCSI?) */
case IRP_MJ_INTERNAL_DEVICE_CONTROL:
UNIMPLEMENTED_DBGBREAK("SCSI request\n");
break;
- //
- // Flush request
- //
+ /* Flush request */
case IRP_MJ_FLUSH_BUFFERS:
UNIMPLEMENTED_DBGBREAK("Flush request\n");
break;
- //
- // Anything else
- //
+ /* Anything else */
default:
- UNIMPLEMENTED_DBGBREAK("Invalid request: %lx\n",
IoStackLocation->MajorFunction);
+ UNIMPLEMENTED_DBGBREAK("Invalid request: %lx\n",
+ IoStackLocation->MajorFunction);
break;
}
- //
- // Complete the I/O
- //
+ /* Complete the I/O */
IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp);
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
@@ -1132,9 +902,7 @@
return;
}
- //
- // Fail the I/O
- //
+ /* Fail the I/O */
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -1147,29 +915,21 @@
{
PIO_WORKITEM WorkItem;
- //
- // Mark the IRP pending
- //
+ /* Mark the IRP pending */
IoMarkIrpPending(Irp);
- //
- // Allocate a work item
- //
+ /* Allocate a work item */
WorkItem = IoAllocateWorkItem(DeviceObject);
if (WorkItem)
{
- //
- // Queue it up
- //
+ /* Queue it up */
Irp->Tail.Overlay.DriverContext[0] = WorkItem;
IoQueueWorkItem(WorkItem, RamdiskWorkerThread, DelayedWorkQueue, Irp);
return STATUS_PENDING;
}
else
{
- //
- // Fail
- //
+ /* Fail */
return STATUS_INSUFFICIENT_RESOURCES;
}
}
@@ -1187,22 +947,16 @@
PVOID Source, Destination;
NTSTATUS Status;
- //
- // Get the MDL and check if it's mapped
- //
+ /* Get the MDL and check if it's mapped */
Mdl = Irp->MdlAddress;
if (Mdl->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | MDL_SOURCE_IS_NONPAGED_POOL))
{
- //
- // Use the mapped address
- //
+ /* Use the mapped address */
SystemVa = Mdl->MappedSystemVa;
}
else
{
- //
- // Map it ourselves
- //
+ /* Map it ourselves */
SystemVa = MmMapLockedPagesSpecifyCache(Mdl,
0,
MmCached,
@@ -1211,98 +965,67 @@
NormalPagePriority);
}
- //
- // Make sure we were able to map it
- //
+ /* Make sure we were able to map it */
CurrentBase = SystemVa;
if (!SystemVa) return STATUS_INSUFFICIENT_RESOURCES;
- //
- // Initialize default
- //
+ /* Initialize default */
Irp->IoStatus.Information = 0;
- //
- // Get the I/O Stack Location and capture the data
- //
+ /* Get the I/O Stack Location and capture the data */
IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
CurrentOffset = IoStackLocation->Parameters.Read.ByteOffset;
BytesLeft = IoStackLocation->Parameters.Read.Length;
if (!BytesLeft) return STATUS_INVALID_PARAMETER;
- //
- // Do the copy loop
- //
+ /* Do the copy loop */
while (TRUE)
{
- //
- // Map the pages
- //
+ /* Map the pages */
BaseAddress = RamdiskMapPages(DeviceExtension,
CurrentOffset,
BytesLeft,
&BytesRead);
if (!BaseAddress) return STATUS_INSUFFICIENT_RESOURCES;
- //
- // Update our lengths
- //
+ /* Update our lengths */
Irp->IoStatus.Information += BytesRead;
CopyLength = BytesRead;
- //
- // Check if this was a read or write
- //
+ /* Check if this was a read or write */
Status = STATUS_SUCCESS;
if (IoStackLocation->MajorFunction == IRP_MJ_READ)
{
- //
- // Set our copy parameters
- //
+ /* Set our copy parameters */
Destination = CurrentBase;
Source = BaseAddress;
goto DoCopy;
}
else if (IoStackLocation->MajorFunction == IRP_MJ_WRITE)
{
- //
- // Set our copy parameters
- //
+ /* Set our copy parameters */
Destination = BaseAddress;
Source = CurrentBase;
DoCopy:
- //
- // Copy the data
- //
+ /* Copy the data */
RtlCopyMemory(Destination, Source, CopyLength);
}
else
{
- //
- // Prepare us for failure
- //
+ /* Prepare us for failure */
BytesLeft = CopyLength;
Status = STATUS_INVALID_PARAMETER;
}
- //
- // Unmap the pages
- //
- RamdiskUnmapPages(DeviceExtension,
- BaseAddress,
- CurrentOffset,
- BytesRead);
-
- //
- // Update offset and bytes left
- //
+ /* Unmap the pages */
+ RamdiskUnmapPages(DeviceExtension, BaseAddress, CurrentOffset, BytesRead);
+
+ /* Update offset and bytes left */
BytesLeft -= BytesRead;
CurrentOffset.QuadPart += BytesRead;
CurrentBase = (PVOID)((ULONG_PTR)CurrentBase + BytesRead);
- //
- // Check if we're done
- //
+ /* Check if we're done */
if (!BytesLeft) return Status;
}
}
@@ -1312,9 +1035,7 @@
RamdiskOpenClose(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- //
- // Complete the IRP
- //
+ /* Complete the IRP */
Irp->IoStatus.Information = 1;
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -1327,87 +1048,61 @@
IN PIRP Irp)
{
PRAMDISK_DRIVE_EXTENSION DeviceExtension;
- // ULONG Length;
- // LARGE_INTEGER ByteOffset;
+ //ULONG Length;
+ //LARGE_INTEGER ByteOffset;
PIO_STACK_LOCATION IoStackLocation;
NTSTATUS Status, ReturnStatus;
- //
- // Get the device extension and make sure this isn't a bus
- //
+ /* Get the device extension and make sure this isn't a bus */
DeviceExtension = DeviceObject->DeviceExtension;
if (DeviceExtension->Type == RamdiskBus)
{
- //
- // Fail
- //
+ /* Fail */
Status = STATUS_INVALID_DEVICE_REQUEST;
goto Complete;
}
- //
- // Capture parameters
- //
+ /* Capture parameters */
IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
- // Length = IoStackLocation->Parameters.Read.Length;
- // ByteOffset = IoStackLocation->Parameters.Read.ByteOffset;
-
- //
- // FIXME: Validate offset
- //
-
- //
- // FIXME: Validate sector
- //
-
- //
- // Validate write
- //
+ //Length = IoStackLocation->Parameters.Read.Length;
+ //ByteOffset = IoStackLocation->Parameters.Read.ByteOffset;
+
+ /* FIXME: Validate offset */
+
+ /* FIXME: Validate sector */
+
+ /* Validate write */
if ((IoStackLocation->MajorFunction == IRP_MJ_WRITE) &&
(DeviceExtension->DiskOptions.Readonly))
{
- //
- // Fail, this is read-only
- //
+ /* Fail, this is read-only */
Status = STATUS_MEDIA_WRITE_PROTECTED;
goto Complete;
}
- //
- // See if we want to do this sync or async
- //
+ /* See if we want to do this sync or async */
if (DeviceExtension->DiskType > RAMDISK_MEMORY_MAPPED_DISK)
{
- //
- // Do it sync
- //
+ /* Do it sync */
Status = RamdiskReadWriteReal(Irp, DeviceExtension);
goto Complete;
}
- //
- // Queue it to the worker
- //
+ /* Queue it to the worker */
Status = SendIrpToThread(DeviceObject, Irp);
ReturnStatus = STATUS_PENDING;
- //
- // Check if we're pending or not
- //
+ /* Check if we're pending or not */
if (Status != STATUS_PENDING)
{
Complete:
- //
- // Complete the IRP
- //
+ /* Complete the IRP */
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_DISK_INCREMENT);
ReturnStatus = Status;
}
- //
- // Return to caller
- //
+ /* Return to caller */
return ReturnStatus;
}
@@ -1424,45 +1119,31 @@
PCDROM_TOC Toc;
PDISK_GEOMETRY DiskGeometry;
- //
- // Grab the remove lock
- //
+ /* Grab the remove lock */
Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, Irp);
if (!NT_SUCCESS(Status))
{
- //
- // Fail the IRP
- //
+ /* Fail the IRP */
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
- //
- // Setup some defaults
- //
+ /* Setup some defaults */
Status = STATUS_INVALID_DEVICE_REQUEST;
Information = 0;
- //
- // Check if this is an bus device or the drive
- //
+ /* Check if this is an bus device or the drive */
if (DeviceExtension->Type == RamdiskBus)
{
- //
- // Check what the request is
- //
+ /* Check what the request is */
switch (IoStackLocation->Parameters.DeviceIoControl.IoControlCode)
{
- //
- // Request to create a ramdisk
- //
+ /* Request to create a ramdisk */
case FSCTL_CREATE_RAM_DISK:
{
- //
- // Do it
- //
+ /* Do it */
Status = RamdiskCreateRamdisk(DeviceObject, Irp, TRUE);
if (!NT_SUCCESS(Status)) goto CompleteRequest;
break;
@@ -1470,18 +1151,15 @@
default:
{
- //
- // We don't handle anything else yet
- //
- UNIMPLEMENTED_DBGBREAK("FSCTL: 0x%lx is UNSUPPORTED!\n",
IoStackLocation->Parameters.DeviceIoControl.IoControlCode);
+ /* We don't handle anything else yet */
+ UNIMPLEMENTED_DBGBREAK("FSCTL: 0x%lx is UNSUPPORTED!\n",
+
IoStackLocation->Parameters.DeviceIoControl.IoControlCode);
}
}
}
else
{
- //
- // Check what the request is
- //
+ /* Check what the request is */
switch (IoStackLocation->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_DISK_CHECK_VERIFY:
@@ -1489,9 +1167,7 @@
case IOCTL_STORAGE_CHECK_VERIFY2:
case IOCTL_CDROM_CHECK_VERIFY:
{
- //
- // Just pretend it's OK, don't do more
- //
+ /* Just pretend it's OK, don't do more */
Status = STATUS_SUCCESS;
break;
}
@@ -1501,22 +1177,16 @@
case IOCTL_DISK_GET_DRIVE_GEOMETRY:
case IOCTL_CDROM_GET_DRIVE_GEOMETRY:
{
- //
- // Validate the length
- //
+ /* Validate the length */
if (IoStackLocation->Parameters.DeviceIoControl.
OutputBufferLength < sizeof(DISK_GEOMETRY))
{
- //
- // Invalid length
- //
+ /* Invalid length */
Status = STATUS_BUFFER_TOO_SMALL;
break;
}
- //
- // Fill it out
- //
+ /* Fill it out */
DiskGeometry = Irp->AssociatedIrp.SystemBuffer;
DiskGeometry->Cylinders.QuadPart = DriveExtension->Cylinders;
DiskGeometry->BytesPerSector = DriveExtension->BytesPerSector;
@@ -1525,9 +1195,7 @@
DiskGeometry->MediaType = DriveExtension->DiskOptions.Fixed ?
FixedMedia : RemovableMedia;
- //
- // We're done
- //
+ /* We're done */
Status = STATUS_SUCCESS;
Information = sizeof(DISK_GEOMETRY);
break;
@@ -1535,28 +1203,20 @@
case IOCTL_CDROM_READ_TOC:
{
- //
- // Validate the length
- //
+ /* Validate the length */
if (IoStackLocation->Parameters.DeviceIoControl.
OutputBufferLength < sizeof(CDROM_TOC))
{
- //
- // Invalid length
- //
+ /* Invalid length */
Status = STATUS_BUFFER_TOO_SMALL;
break;
}
- //
- // Clear the TOC
- //
+ /* Clear the TOC */
Toc = Irp->AssociatedIrp.SystemBuffer;
RtlZeroMemory(Toc, sizeof(CDROM_TOC));
- //
- // Fill it out
- //
+ /* Fill it out */
Toc->Length[0] = 0;
Toc->Length[1] = RAMDISK_TOC_SIZE - sizeof(Toc->Length);
Toc->FirstTrack = 1;
@@ -1565,9 +1225,7 @@
Toc->TrackData[0].Control = TOC_DATA_TRACK;
Toc->TrackData[0].TrackNumber = 1;
- //
- // We're done
- //
+ /* We're done */
Status = STATUS_SUCCESS;
Information = RAMDISK_TOC_SIZE;
break;
@@ -1581,40 +1239,28 @@
case IOCTL_DISK_GET_PARTITION_INFO:
{
- //
- // Validate the length
- //
+ /* Validate the length */
if (IoStackLocation->Parameters.DeviceIoControl.
OutputBufferLength < sizeof(PARTITION_INFORMATION))
{
- //
- // Invalid length
- //
+ /* Invalid length */
Status = STATUS_BUFFER_TOO_SMALL;
break;
}
- //
- // Check if we need to do this sync or async
- //
+ /* Check if we need to do this sync or async */
if (DriveExtension->DiskType > RAMDISK_MEMORY_MAPPED_DISK)
{
- //
- // Call the helper function
- //
+ /* Call the helper function */
Status = RamdiskGetPartitionInfo(Irp, DriveExtension);
}
else
{
- //
- // Do it asynchronously later
- //
+ /* Do it asynchronously later */
goto CallWorker;
}
- //
- // We're done
- //
+ /* We're done */
Information = Irp->IoStatus.Information;
break;
}
@@ -1631,50 +1277,40 @@
case IOCTL_VOLUME_GET_GPT_ATTRIBUTES:
case IOCTL_VOLUME_OFFLINE:
{
- UNIMPLEMENTED_DBGBREAK("IOCTL: 0x%lx is UNIMPLEMENTED!\n",
IoStackLocation->Parameters.DeviceIoControl.IoControlCode);
+ UNIMPLEMENTED_DBGBREAK("IOCTL: 0x%lx is UNIMPLEMENTED!\n",
+
IoStackLocation->Parameters.DeviceIoControl.IoControlCode);
break;
}
default:
{
- //
- // Drive code not emulated
- //
- DPRINT1("IOCTL: 0x%lx is UNSUPPORTED!\n",
IoStackLocation->Parameters.DeviceIoControl.IoControlCode);
+ /* Drive code not emulated */
+ DPRINT1("IOCTL: 0x%lx is UNSUPPORTED!\n",
+ IoStackLocation->Parameters.DeviceIoControl.IoControlCode);
break;
}
}
- //
- // If requests drop down here, we just return them complete them
- //
+ /* If requests drop down here, we just return them complete them */
goto CompleteRequest;
}
- //
- // Queue the request to our worker thread
- //
+ /* Queue the request to our worker thread */
CallWorker:
Status = SendIrpToThread(DeviceObject, Irp);
CompleteRequest:
- //
- // Release the lock
- //
+ /* Release the lock */
IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp);
if (Status != STATUS_PENDING)
{
- //
- // Complete the request
- //
+ /* Complete the request */
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = Information;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
- //
- // Return status
- //
+ /* Return status */
return Status;
}
@@ -1692,18 +1328,14 @@
PDEVICE_OBJECT* DriveDeviceObject;
RAMDISK_DEVICE_STATE State;
- //
- // Get the device extension and check if this is a drive
- //
+ /* Get the device extension and check if this is a drive */
DeviceExtension = DeviceObject->DeviceExtension;
if (DeviceExtension->Type == RamdiskDrive)
{
NTSTATUS Status;
PDEVICE_RELATIONS DeviceRelations;
- //
- // We're a child device, only handle target device relations
- //
+ /* We're a child device, only handle target device relations */
if (Type != TargetDeviceRelation)
{
Status = Irp->IoStatus.Status;
@@ -1711,15 +1343,13 @@
return Status;
}
- //
- // Allocate a buffer big enough to contain only one DO
- //
- DeviceRelations = ExAllocatePoolWithTag(PagedPool, sizeof(DeviceRelations),
'dmaR');
+ /* Allocate a buffer big enough to contain only one DO */
+ DeviceRelations = ExAllocatePoolWithTag(PagedPool,
+ sizeof(DeviceRelations),
+ 'dmaR');
if (DeviceRelations != NULL)
{
- //
- // Reference the DO and add it to the buffer
- //
+ /* Reference the DO and add it to the buffer */
ObReferenceObject(DeviceObject);
DeviceRelations->Objects[0] = DeviceObject;
DeviceRelations->Count = 1;
@@ -1730,75 +1360,53 @@
Status = STATUS_INSUFFICIENT_RESOURCES;
}
- //
- // Return our processing & complete
- //
+ /* Return our processing & complete */
Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
- //
- // Anything but bus relations, we don't handle
- //
+ /* We don't handle anything but bus relations */
if (Type != BusRelations) goto PassToNext;
- //
- // Acquire the disk list lock
- //
+ /* Acquire the disk list lock */
KeEnterCriticalRegion();
ExAcquireFastMutex(&DeviceExtension->DiskListLock);
- //
- // Did a device already fill relations?
- //
+ /* Did a device already fill relations? */
DeviceRelations = (PDEVICE_RELATIONS)Irp->IoStatus.Information;
if (DeviceRelations)
{
- //
- // Use the data
- //
+ /* Use the data */
Count = DeviceRelations->Count;
}
else
{
- //
- // We're the first
- //
+ /* We're the first */
Count = 0;
}
- //
- // Now loop our drives
- //
+ /* Now loop our drives */
DiskCount = 0;
ListHead = &DeviceExtension->DiskList;
NextEntry = ListHead->Flink;
while (NextEntry != ListHead)
{
- //
- // As long as it wasn't removed, count it in
- //
+ /* As long as it wasn't removed, count it in */
DriveExtension = CONTAINING_RECORD(NextEntry,
RAMDISK_DRIVE_EXTENSION,
DiskList);
if (DriveExtension->State < RamdiskStateBusRemoved) DiskCount++;
- //
- // Move to the next one
- //
+ /* Move to the next one */
NextEntry = NextEntry->Flink;
}
- //
- // Now we know our final count
- //
+ /* Now we know our final count */
FinalCount = Count + DiskCount;
- //
- // Allocate the structure
- //
+ /* Allocate the structure */
OurDeviceRelations = ExAllocatePoolWithTag(PagedPool,
FIELD_OFFSET(DEVICE_RELATIONS,
Objects) +
@@ -1807,9 +1415,7 @@
'dmaR');
if (!OurDeviceRelations)
{
- //
- // Fail
- //
+ /* Fail */
ExReleaseFastMutex(&DeviceExtension->DiskListLock);
KeLeaveCriticalRegion();
Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
@@ -1817,101 +1423,69 @@
return STATUS_INSUFFICIENT_RESOURCES;
}
- //
- // Check if we already had some relations
- //
+ /* Check if we already had some relations */
if (Count)
{
- //
- // Copy them in
- //
+ /* Copy them in */
RtlCopyMemory(OurDeviceRelations->Objects,
DeviceRelations->Objects,
Count * sizeof(PDEVICE_OBJECT));
}
- //
- // Save the count
- //
+ /* Save the count */
OurDeviceRelations->Count = FinalCount;
- //
- // Now loop our drives again
- //
+ /* Now loop our drives again */
ListHead = &DeviceExtension->DiskList;
NextEntry = ListHead->Flink;
while (NextEntry != ListHead)
{
- //
- // Go to the end of the list
- //
+ /* Go to the end of the list */
DriveDeviceObject = &OurDeviceRelations->Objects[Count];
- //
- // Get the drive state
- //
+ /* Get the drive state */
DriveExtension = CONTAINING_RECORD(NextEntry,
RAMDISK_DRIVE_EXTENSION,
DiskList);
State = DriveExtension->State;
- //
- // If it was removed or enumerated, we don't touch the device object
- //
+ /* If it was removed or enumerated, we don't touch the device object */
if (State >= RamdiskStateBusRemoved)
{
- //
- // If it was removed, we still have to keep track of this though
- //
+ /* If it was removed, we still have to keep track of this though */
if (State == RamdiskStateBusRemoved)
{
- //
- // Mark it as enumerated now, but don't actually reference it
- //
+ /* Mark it as enumerated now, but don't actually reference it */
DriveExtension->State = RamdiskStateEnumerated;
}
}
else
{
- //
- // First time it's enumerated, reference the device object
- //
+ /* First time it's enumerated, reference the device object */
ObReferenceObject(DriveExtension->DeviceObject);
- //
- // Save the object pointer, and move on
- //
+ /* Save the object pointer and move on */
*DriveDeviceObject++ = DriveExtension->PhysicalDeviceObject;
}
if (DriveExtension->State < RamdiskStateBusRemoved) DiskCount++;
- //
- // Move to the next one
- //
+ /* Move to the next one */
NextEntry = NextEntry->Flink;
}
- //
- // Release the lock
- //
+ /* Release the lock */
ExReleaseFastMutex(&DeviceExtension->DiskListLock);
KeLeaveCriticalRegion();
- //
- // Cleanup old relations
- //
+ /* Cleanup old relations */
if (DeviceRelations) ExFreePool(DeviceRelations);
- //
- // Complete our IRP
- //
+ /* Complete our IRP */
Irp->IoStatus.Information = (ULONG_PTR)OurDeviceRelations;
Irp->IoStatus.Status = STATUS_SUCCESS;
- //
- // Pass to the next driver
- //
+ /* Pass to the next driver */
PassToNext:
IoCopyCurrentIrpStackLocationToNext(Irp);
return IoCallDriver(DeviceExtension->AttachedDevice, Irp);
@@ -1938,15 +1512,11 @@
DeviceExtension = DeviceObject->DeviceExtension;
- //
- // Acquire disks list lock
- //
+ /* Acquire disks list lock */
KeEnterCriticalRegion();
ExAcquireFastMutex(&DeviceExtension->DiskListLock);
- //
- // Loop over drives
- //
+ /* Loop over drives */
ListHead = &DeviceExtension->DiskList;
NextEntry = ListHead->Flink;
while (NextEntry != ListHead)
@@ -1955,78 +1525,50 @@
RAMDISK_DRIVE_EXTENSION,
DiskList);
- //
- // Delete the disk
- //
+ /* Delete the disk */
IoAcquireRemoveLock(&DriveExtension->RemoveLock, NULL);
RamdiskDeleteDiskDevice(DriveExtension->PhysicalDeviceObject, NULL);
- //
- // RamdiskDeleteDiskDevice releases list lock, so reacquire it
- //
+ /* RamdiskDeleteDiskDevice releases list lock, so reacquire it */
KeEnterCriticalRegion();
ExAcquireFastMutex(&DeviceExtension->DiskListLock);
}
- //
- // Release disks list lock
- //
+ /* Release disks list lock */
ExReleaseFastMutex(&DeviceExtension->DiskListLock);
KeLeaveCriticalRegion();
- //
- // Prepare to pass to the lower driver
- //
+ /* Prepare to pass to the lower driver */
IoSkipCurrentIrpStackLocation(Irp);
- //
- // Here everything went fine
- //
+ /* Here everything went fine */
Irp->IoStatus.Status = STATUS_SUCCESS;
- //
- // Call lower driver
- //
+ /* Call lower driver */
Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp);
- //
- // Update state
- //
+ /* Update state */
DeviceExtension->State = RamdiskStateBusRemoved;
- //
- // Release the lock, and ensure that everyone
- // has finished its job before we continue
- // The lock has been acquired by the dispatcher
- //
+ /* Release the lock and ensure that everyone has finished its job before
+ * we continue. The lock has been acquired by the dispatcher */
IoReleaseRemoveLockAndWait(&DeviceExtension->RemoveLock, Irp);
- //
- // If there's a drive name
- //
+ /* If there's a drive name */
if (DeviceExtension->DriveDeviceName.Buffer)
{
- //
- // Inform it's going to be disabled
- // and free the drive name
- //
+ /* Inform it's going to be disabled and free the drive name */
IoSetDeviceInterfaceState(&DeviceExtension->DriveDeviceName, FALSE);
RtlFreeUnicodeString(&DeviceExtension->DriveDeviceName);
}
- //
- // Part from the stack, detach from lower device
- //
+ /* Part from the stack, detach from lower device */
IoDetachDevice(DeviceExtension->AttachedDevice);
- //
- // Finally, delete device
- //
+ /* Finally, delete device */
RamdiskBusFdo = NULL;
IoDeleteDevice(DeviceObject);
- //
- // Return status from lower driver
- //
+ /* Return status from lower driver */
return Status;
}
@@ -2043,18 +1585,14 @@
Status = STATUS_SUCCESS;
IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
- //
- // Get what is being queried
- //
+ /* Get what is being queried */
switch (IoStackLocation->Parameters.QueryId.IdType)
{
case BusQueryDeviceID:
{
- //
- // Allocate a buffer long enough to receive Ramdisk\RamDisk in any case
- // In case we don't have RAMDISK_REGISTRY_DISK, we then need two more
- // chars to store Ramdisk\RamVolume instead
- //
+ /* Allocate a buffer long enough to receive Ramdisk\RamDisk in any case
+ * In case we don't have RAMDISK_REGISTRY_DISK, we then need two more
+ * chars to store Ramdisk\RamVolume instead */
StringLength = 4 * (DriveExtension->DiskType != RAMDISK_REGISTRY_DISK) +
sizeof(L"Ramdisk\\RamDisk");
OutputString = ExAllocatePoolWithTag(PagedPool, StringLength,
'dmaR');
if (OutputString == NULL)
@@ -2078,13 +1616,11 @@
case BusQueryHardwareIDs:
{
- //
- // Allocate a buffer long enough to receive Ramdisk\RamDisk in any case
- // In case we don't have RAMDISK_REGISTRY_DISK, we then need two more
- // chars to store Ramdisk\RamVolume instead
- // We also need an extra char, because it is required that the string
- // is null-terminated twice
- //
+ /* Allocate a buffer long enough to receive Ramdisk\RamDisk in any case
+ * In case we don't have RAMDISK_REGISTRY_DISK, we then need two more
+ * chars to store Ramdisk\RamVolume instead
+ * We also need an extra char, because it is required that the string
+ * is null-terminated twice */
StringLength = 4 * (DriveExtension->DiskType != RAMDISK_REGISTRY_DISK) +
sizeof(UNICODE_NULL) + sizeof(L"Ramdisk\\RamDisk");
OutputString = ExAllocatePoolWithTag(PagedPool, StringLength,
'dmaR');
@@ -2132,23 +1668,25 @@
case BusQueryInstanceID:
{
- OutputString = ExAllocatePoolWithTag(PagedPool,
DriveExtension->GuidString.MaximumLength, 'dmaR');
+ OutputString = ExAllocatePoolWithTag(PagedPool,
+
DriveExtension->GuidString.MaximumLength,
+ 'dmaR');
if (OutputString == NULL)
{
Status = STATUS_INSUFFICIENT_RESOURCES;
break;
}
- wcsncpy(OutputString, DriveExtension->GuidString.Buffer,
DriveExtension->GuidString.MaximumLength / sizeof(WCHAR));
+ wcsncpy(OutputString,
+ DriveExtension->GuidString.Buffer,
+ DriveExtension->GuidString.MaximumLength / sizeof(WCHAR));
break;
}
case BusQueryDeviceSerialNumber:
{
- //
- // Nothing to do
- //
+ /* Nothing to do */
break;
}
}
@@ -2173,18 +1711,15 @@
DeviceCapabilities = IoStackLocation->Parameters.DeviceCapabilities.Capabilities;
DriveExtension = DeviceObject->DeviceExtension;
- //
- // Validate our input buffer
- //
- if (DeviceCapabilities->Version != 1 || DeviceCapabilities->Size <
sizeof(DEVICE_CAPABILITIES))
+ /* Validate our input buffer */
+ if (DeviceCapabilities->Version != 1 ||
+ DeviceCapabilities->Size < sizeof(DEVICE_CAPABILITIES))
{
Status = STATUS_UNSUCCESSFUL;
}
else
{
- //
- // And set everything we know about our capabilities
- //
+ /* And set everything we know about our capabilities */
DeviceCapabilities->Removable = MarkRamdisksAsRemovable;
DeviceCapabilities->UniqueID = TRUE;
DeviceCapabilities->SilentInstall = TRUE;
@@ -2213,9 +1748,7 @@
DeviceTextType = IoStackLocation->Parameters.QueryDeviceText.DeviceTextType;
Status = STATUS_SUCCESS;
- //
- // Just copy our constants, according to the input
- //
+ /* Just copy our constants, according to the input */
switch (DeviceTextType)
{
case DeviceTextDescription:
@@ -2261,9 +1794,7 @@
PPNP_BUS_INFORMATION PnpBusInfo;
NTSTATUS Status = STATUS_SUCCESS;
- //
- // Allocate output memory
- //
+ /* Allocate output memory */
PnpBusInfo = ExAllocatePoolWithTag(PagedPool, sizeof(PNP_BUS_INFORMATION),
'dmaR');
if (PnpBusInfo == NULL)
{
@@ -2271,9 +1802,7 @@
}
else
{
- //
- // Copy our bus GUID and set our legacy type
- //
+ /* Copy our bus GUID and set our legacy type */
RtlCopyMemory(&PnpBusInfo->BusTypeGuid, &GUID_BUS_TYPE_RAMDISK,
sizeof(GUID));
PnpBusInfo->LegacyBusType = PNPBus;
PnpBusInfo->BusNumber = 0;
@@ -2292,9 +1821,7 @@
IN PVOID Context)
{
- //
- // Just set the event to unlock caller
- //
+ /* Just set the event to unlock caller */
KeSetEvent((PKEVENT)Context, 0, FALSE);
return STATUS_MORE_PROCESSING_REQUIRED;
@@ -2311,26 +1838,18 @@
UCHAR Minor;
KEVENT Event;
- //
- // Get the device extension and stack location
- //
+ /* Get the device extension and stack location */
DeviceExtension = DeviceObject->DeviceExtension;
IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
Minor = IoStackLocation->MinorFunction;
- //
- // Check if the bus is removed
- //
+ /* Check if the bus is removed */
if (DeviceExtension->State == RamdiskStateBusRemoved)
{
- //
- // Only remove-device and query-id are allowed
- //
+ /* Only remove-device and query-id are allowed */
if ((Minor != IRP_MN_REMOVE_DEVICE) && (Minor != IRP_MN_QUERY_ID))
{
- //
- // Fail anything else
- //
+ /* Fail anything else */
Status = STATUS_NO_SUCH_DEVICE;
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -2338,24 +1857,18 @@
}
}
- //
- // Acquire the remove lock
- //
+ /* Acquire the remove lock */
Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, Irp);
if (!NT_SUCCESS(Status))
{
- //
- // Fail the IRP
- //
+ /* Fail the IRP */
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
- //
- // Query the IRP type
- //
+ /* Query the IRP type */
switch (Minor)
{
case IRP_MN_START_DEVICE:
@@ -2366,17 +1879,13 @@
DEVICE_INSTALL_STATE InstallState;
PRAMDISK_DRIVE_EXTENSION DriveExtension =
(PRAMDISK_DRIVE_EXTENSION)DeviceExtension;
- //
- // If we already have a drive name, free it
- //
+ /* If we already have a drive name, free it */
if (DriveExtension->DriveDeviceName.Buffer)
{
ExFreePool(DriveExtension->DriveDeviceName.Buffer);
}
- //
- // Register our device interface
- //
+ /* Register our device interface */
if (DriveExtension->DiskType != RAMDISK_REGISTRY_DISK)
{
Status = IoRegisterDeviceInterface(DeviceObject,
@@ -2392,11 +1901,8 @@
&DriveExtension->DriveDeviceName);
}
- //
- // If we were asked not to assign a drive letter or
- // if getting a name failed, just return saying
- // we're now started
- //
+ /* If we were asked not to assign a drive letter or if getting
+ * a name failed, just return saying we're now started */
if (DriveExtension->DiskOptions.NoDriveLetter ||
DriveExtension->DriveDeviceName.Buffer == NULL)
{
@@ -2405,49 +1911,38 @@
break;
}
- //
- // Now get our installation state
- //
- Status = IoGetDeviceProperty(DeviceObject, DevicePropertyInstallState,
- sizeof(InstallState), &InstallState,
&ResultLength);
- //
- // If querying the information failed, assume success
- //
+ /* Now get our installation state */
+ Status = IoGetDeviceProperty(DeviceObject,
+ DevicePropertyInstallState,
+ sizeof(InstallState),
+ &InstallState,
+ &ResultLength);
+ /* If querying the information failed, assume success */
if (!NT_SUCCESS(Status))
{
InstallState = InstallStateInstalled;
}
- //
- // If we were properly installed, then, enable the interface
- //
+ /* If we were properly installed, then, enable the interface */
if (InstallState == InstallStateInstalled)
{
Status =
IoSetDeviceInterfaceState(&DriveExtension->DriveDeviceName, TRUE);
}
- //
- // We're fine & up
- //
+ /* We're fine & up */
DriveExtension->State = RamdiskStateStarted;
Irp->IoStatus.Status = Status;
break;
}
- //
- // Prepare next stack to pass it down
- //
+ /* Prepare next stack to pass it down */
IoCopyCurrentIrpStackLocationToNext(Irp);
- //
- // Initialize our notification event & our completion routine
- //
+ /* Initialize our notification event & our completion routine */
KeInitializeEvent(&Event, NotificationEvent, FALSE);
IoSetCompletionRoutine(Irp, RamdiskIoCompletionRoutine, &Event, TRUE,
TRUE, TRUE);
- //
- // Call lower driver
- //
+ /* Call lower driver */
Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp);
if (Status == STATUS_PENDING)
{
@@ -2455,9 +1950,7 @@
Status = Irp->IoStatus.Status;
}
- //
- // If it succeed to start, then, enable ourselve and we're up!
- //
+ /* If it succeed to start then enable ourselves and we're up! */
if (NT_SUCCESS(Status))
{
Status =
IoSetDeviceInterfaceState(&DeviceExtension->DriveDeviceName, TRUE);
@@ -2480,28 +1973,22 @@
case IRP_MN_REMOVE_DEVICE:
{
- //
- // Remove the proper device
- //
+ /* Remove the proper device */
if (DeviceExtension->Type == RamdiskBus)
{
Status = RamdiskRemoveBusDevice(DeviceObject, Irp);
- //
- // Return here, lower device has already been called
- // And remove lock released. This is needed by the function.
- //
+ /* Return here, lower device has already been called
+ * And remove lock released. This is needed by the function. */
return Status;
}
else
{
Status = RamdiskDeleteDiskDevice(DeviceObject, Irp);
- //
- // Complete the IRP here and return
- // Here again we don't have to release remove lock
- // This has already been done by the function.
- //
+ /* Complete the IRP here and return
+ * Here again we don't have to release remove lock
+ * This has already been done by the function. */
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
@@ -2514,9 +2001,7 @@
case IRP_MN_QUERY_ID:
{
- //
- // Are we a drive?
- //
+ /* Are we a drive? */
if (DeviceExtension->Type == RamdiskDrive)
{
Status = RamdiskQueryId((PRAMDISK_DRIVE_EXTENSION)DeviceExtension, Irp);
@@ -2526,9 +2011,7 @@
case IRP_MN_QUERY_BUS_INFORMATION:
{
- //
- // Are we a drive?
- //
+ /* Are we a drive? */
if (DeviceExtension->Type == RamdiskDrive)
{
Status = RamdiskQueryBusInformation(DeviceObject, Irp);
@@ -2542,9 +2025,7 @@
case IRP_MN_QUERY_DEVICE_TEXT:
{
- //
- // Are we a drive?
- //
+ /* Are we a drive? */
if (DeviceExtension->Type == RamdiskDrive)
{
Status =
RamdiskQueryDeviceText((PRAMDISK_DRIVE_EXTENSION)DeviceExtension, Irp);
@@ -2554,9 +2035,7 @@
case IRP_MN_QUERY_DEVICE_RELATIONS:
{
- //
- // Call our main routine
- //
+ /* Call our main routine */
Status = RamdiskQueryDeviceRelations(IoStackLocation->
Parameters.
QueryDeviceRelations.Type,
@@ -2567,9 +2046,7 @@
case IRP_MN_QUERY_CAPABILITIES:
{
- //
- // Are we a drive?
- //
+ /* Are we a drive? */
if (DeviceExtension->Type == RamdiskDrive)
{
Status = RamdiskQueryCapabilities(DeviceObject, Irp);
@@ -2580,9 +2057,7 @@
case IRP_MN_QUERY_RESOURCES:
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
{
- //
- // Complete immediately without touching it
- //
+ /* Complete immediately without touching it */
IoCompleteRequest(Irp, IO_NO_INCREMENT);
goto ReleaseAndReturn;
}
@@ -2592,27 +2067,19 @@
break;
}
- //
- // Are we the bus?
- //
+ /* Are we the bus? */
if (DeviceExtension->Type == RamdiskBus)
{
- //
- // Do we have an attached device?
- //
+ /* Do we have an attached device? */
if (DeviceExtension->AttachedDevice)
{
- //
- // Forward the IRP
- //
+ /* Forward the IRP */
IoSkipCurrentIrpStackLocation(Irp);
Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp);
}
}
- //
- // Release the lock and return status
- //
+ /* Release the lock and return status */
ReleaseAndReturn:
IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp);
return Status;
@@ -2629,27 +2096,18 @@
DeviceExtension = DeviceObject->DeviceExtension;
- //
- // If we have a device extension, take extra caution
- // with the lower driver
- //
+ /* If we have a device extension, take extra caution with the lower driver */
if (DeviceExtension != NULL)
{
PoStartNextPowerIrp(Irp);
- //
- // Device has not been removed yet, so
- // pass to the attached/lower driver
- //
+ /* Device has not been removed yet, so pass to the attached/lower driver */
if (DeviceExtension->State < RamdiskStateBusRemoved)
{
IoSkipCurrentIrpStackLocation(Irp);
return PoCallDriver(DeviceExtension->AttachedDevice, Irp);
}
- //
- // Otherwise, simply complete the IRP
- // Notifying that deletion is pending
- //
+ /* Otherwise, simply complete the IRP notifying that deletion is pending */
else
{
Irp->IoStatus.Status = STATUS_DELETE_PENDING;
@@ -2658,26 +2116,19 @@
}
}
- //
- // Get stack and deal with minor functions
- //
+ /* Get stack and deal with minor functions */
IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
switch (IoStackLocation->MinorFunction)
{
case IRP_MN_SET_POWER:
{
- //
- // If setting device power state
- // it's all fine and return success
- //
+ /* If setting device power state it's all fine and return success */
if (DevicePowerState)
{
Irp->IoStatus.Status = STATUS_SUCCESS;
}
- //
- // Get appropriate status for return
- //
+ /* Get appropriate status for return */
Status = Irp->IoStatus.Status;
PoStartNextPowerIrp(Irp);
IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -2686,12 +2137,8 @@
case IRP_MN_QUERY_POWER:
{
- //
- // We can obviously accept all states
- // So just return success
- //
- Status =
- Irp->IoStatus.Status = STATUS_SUCCESS;
+ /* We can obviously accept all states so just return success */
+ Status = Irp->IoStatus.Status = STATUS_SUCCESS;
PoStartNextPowerIrp(Irp);
IoCompleteRequest(Irp, IO_NO_INCREMENT);
break;
@@ -2699,9 +2146,7 @@
default:
{
- //
- // Just complete and save status for return
- //
+ /* Just complete and save status for return */
Status = Irp->IoStatus.Status;
PoStartNextPowerIrp(Irp);
IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -2722,19 +2167,14 @@
DeviceExtension = DeviceObject->DeviceExtension;
- //
- // If we have a device extension, forward the IRP
- // to the attached device
- //
+ /* If we have a device extension, forward the IRP to the attached device */
if (DeviceExtension != NULL)
{
IoSkipCurrentIrpStackLocation(Irp);
Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp);
}
- //
- // Otherwise just complete the request
- // And return the status with which we complete it
- //
+ /* Otherwise just complete the request
+ * And return the status with which we complete it */
else
{
Status = Irp->IoStatus.Status;
@@ -2754,36 +2194,28 @@
DeviceExtension = DeviceObject->DeviceExtension;
- //
- // Having a proper device is mandatory
- //
+ /* Having a proper device is mandatory */
if (DeviceExtension->State > RamdiskStateStopped)
{
Status = STATUS_DEVICE_DOES_NOT_EXIST;
goto CompleteIRP;
}
- //
- // Acquire the remove lock
- //
+ /* Acquire the remove lock */
Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, Irp);
if (!NT_SUCCESS(Status))
{
goto CompleteIRP;
}
- //
- // Queue the IRP for worker
- //
+ /* Queue the IRP for worker */
Status = SendIrpToThread(DeviceObject, Irp);
if (Status != STATUS_PENDING)
{
goto CompleteIRP;
}
- //
- // Release the remove lock
- //
+ /* Release the remove lock */
IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp);
goto Quit;
@@ -2806,11 +2238,9 @@
DeviceExtension = DeviceObject->DeviceExtension;
- //
- // Ensure we have drive extension
- // Only perform flush on disks that have been created
- // from registry entries
- //
+ /* Ensure we have drive extension
+ * Only perform flush on disks that have been created
+ * from registry entries */
if (DeviceExtension->Type != RamdiskDrive ||
DeviceExtension->DiskType > RAMDISK_MEMORY_MAPPED_DISK)
{
@@ -2820,16 +2250,11 @@
return STATUS_SUCCESS;
}
- //
- // Queue the IRP for worker
- //
+ /* Queue the IRP for worker */
Status = SendIrpToThread(DeviceObject, Irp);
if (Status != STATUS_PENDING)
{
- //
- // Queueing failed - complete the IRP
- // and return failure
- //
+ /* Queuing failed - complete the IRP and return failure */
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -2842,9 +2267,7 @@
NTAPI
RamdiskUnload(IN PDRIVER_OBJECT DriverObject)
{
- //
- // Just release registry path if previously allocated
- //
+ /* Just release registry path if previously allocated */
if (DriverRegistryPath.Buffer)
{
ExFreePoolWithTag(DriverRegistryPath.Buffer, 'dmaR');
@@ -2862,14 +2285,10 @@
UNICODE_STRING DeviceName;
PDEVICE_OBJECT DeviceObject;
- //
- // Only create the bus FDO once
- //
+ /* Only create the bus FDO once */
if (RamdiskBusFdo) return STATUS_DEVICE_ALREADY_ATTACHED;
- //
- // Create the bus FDO
- //
+ /* Create the bus FDO */
RtlInitUnicodeString(&DeviceName, L"\\Device\\Ramdisk");
Status = IoCreateDevice(DriverObject,
sizeof(RAMDISK_BUS_EXTENSION),
@@ -2880,92 +2299,65 @@
&DeviceObject);
if (NT_SUCCESS(Status))
{
- //
- // Initialize the bus FDO extension
- //
+ /* Initialize the bus FDO extension */
DeviceExtension = DeviceObject->DeviceExtension;
RtlZeroMemory(DeviceObject->DeviceExtension,
sizeof(RAMDISK_BUS_EXTENSION));
- //
- // Set bus FDO flags
- //
+ /* Set bus FDO flags */
DeviceObject->Flags |= DO_POWER_PAGABLE | DO_DIRECT_IO;
- //
- // Setup the bus FDO extension
- //
+ /* Setup the bus FDO extension */
DeviceExtension->Type = RamdiskBus;
ExInitializeFastMutex(&DeviceExtension->DiskListLock);
- IoInitializeRemoveLock(&DeviceExtension->RemoveLock,
- 'dmaR',
- 1,
- 0);
+ IoInitializeRemoveLock(&DeviceExtension->RemoveLock, 'dmaR', 1,
0);
InitializeListHead(&DeviceExtension->DiskList);
DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
DeviceExtension->DeviceObject = DeviceObject;
- //
- // Register the RAM disk device interface
- //
+ /* Register the RAM disk device interface */
Status = IoRegisterDeviceInterface(PhysicalDeviceObject,
&RamdiskBusInterface,
NULL,
&DeviceExtension->BusDeviceName);
if (!NT_SUCCESS(Status))
{
- //
- // Fail
- //
+ /* Fail */
IoDeleteDevice(DeviceObject);
return Status;
}
- //
- // Attach us to the device stack
- //
+ /* Attach us to the device stack */
AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject,
PhysicalDeviceObject);
DeviceExtension->AttachedDevice = AttachedDevice;
if (!AttachedDevice)
{
- //
- // Fail
- //
+ /* Fail */
IoSetDeviceInterfaceState(&DeviceExtension->BusDeviceName, 0);
RtlFreeUnicodeString(&DeviceExtension->BusDeviceName);
IoDeleteDevice(DeviceObject);
return STATUS_NO_SUCH_DEVICE;
}
- //
- // Bus FDO is initialized
- //
+ /* Bus FDO is initialized */
RamdiskBusFdo = DeviceObject;
- //
- // Loop for loader block
- //
+ /* Loop for loader block */
if (KeLoaderBlock)
{
- //
- // Are we being booted from setup? Not yet supported
- //
+ /* Are we being booted from setup? Not yet supported */
if (KeLoaderBlock->SetupLdrBlock)
DPRINT1("FIXME: RamdiskAddDevice is UNSUPPORTED when being started
from SETUPLDR!\n");
- // ASSERT(!KeLoaderBlock->SetupLdrBlock);
- }
-
- //
- // All done
- //
+ //ASSERT(!KeLoaderBlock->SetupLdrBlock);
+ }
+
+ /* All done */
DeviceObject->Flags &= DO_DEVICE_INITIALIZING;
Status = STATUS_SUCCESS;
}
- //
- // Return status
- //
+ /* Return status */
return Status;
}
@@ -2979,14 +2371,10 @@
NTSTATUS Status;
DPRINT("RAM Disk Driver Initialized\n");
- //
- // Query ramdisk parameters
- //
+ /* Query ramdisk parameters */
QueryParameters(RegistryPath);
- //
- // Save the registry path
- //
+ /* Save the registry path */
DriverRegistryPath = *RegistryPath;
DriverRegistryPath.Buffer = ExAllocatePoolWithTag(PagedPool,
RegistryPath->Length +
@@ -2995,9 +2383,7 @@
if (!DriverRegistryPath.Buffer) return STATUS_INSUFFICIENT_RESOURCES;
RtlCopyUnicodeString(&DriverRegistryPath, RegistryPath);
- //
- // Set device routines
- //
+ /* Set device routines */
DriverObject->MajorFunction[IRP_MJ_CREATE] = RamdiskOpenClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = RamdiskOpenClose;
DriverObject->MajorFunction[IRP_MJ_READ] = RamdiskReadWrite;
@@ -3011,53 +2397,35 @@
DriverObject->DriverExtension->AddDevice = RamdiskAddDevice;
DriverObject->DriverUnload = RamdiskUnload;
- //
- // Check for a loader block
- //
+ /* Check for a loader block */
if (KeLoaderBlock)
{
- //
- // Get the boot device name
- //
+ /* Get the boot device name */
BootDeviceName = KeLoaderBlock->ArcBootDeviceName;
if (BootDeviceName)
{
- //
- // Check if we're booting from ramdisk
- //
+ /* Check if we're booting from ramdisk */
if ((strlen(BootDeviceName) >= 10) &&
!(_strnicmp(BootDeviceName, "ramdisk(0)", 10)))
{
- //
- // We'll have to tell the PnP Manager
- //
+ /* We'll have to tell the PnP Manager */
ReportDetectedDevice = TRUE;
- //
- // Check for a command line
- //
+ /* Check for a command line */
CommandLine = KeLoaderBlock->LoadOptions;
if (CommandLine)
{
- //
- // Check if this is an ISO boot
- //
+ /* Check if this is an ISO boot */
if (strstr(CommandLine, "RDEXPORTASCD"))
{
- //
- // Remember for later
- //
+ /* Remember for later */
ExportBootDiskAsCd = TRUE;
}
- //
- // Check if this is PE boot
- //
+ /* Check if this is PE boot */
if (strstr(CommandLine, "MININT"))
{
- //
- // Remember for later
- //
+ /* Remember for later */
IsWinPEBoot = TRUE;
}
}
@@ -3066,21 +2434,15 @@
}
}
- //
- // Installing from Ramdisk isn't supported yet
- //
+ /* Installing from Ramdisk isn't supported yet */
if (KeLoaderBlock->SetupLdrBlock)
DPRINT1("FIXME: Installing from RamDisk is UNSUPPORTED!\n");
- // ASSERT(!KeLoaderBlock->SetupLdrBlock);
-
- //
- // Are we reporting the device
- //
+ //ASSERT(!KeLoaderBlock->SetupLdrBlock);
+
+ /* Are we reporting the device */
if (ReportDetectedDevice)
{
- //
- // Do it
- //
+ /* Do it */
Status = IoReportDetectedDevice(DriverObject,
InterfaceTypeUndefined,
0xFFFFFFFF,
@@ -3091,15 +2453,11 @@
&PhysicalDeviceObject);
if (NT_SUCCESS(Status))
{
- //
- // Create the device object
- //
+ /* Create the device object */
Status = RamdiskAddDevice(DriverObject, PhysicalDeviceObject);
if (NT_SUCCESS(Status))
{
- //
- // We're done
- //
+ /* We're done */
PhysicalDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
Status = STATUS_SUCCESS;
}
@@ -3107,14 +2465,10 @@
}
else
{
- //
- // Done
- //
+ /* Done */
Status = STATUS_SUCCESS;
}
- //
- // Done
- //
+ /* Done */
return Status;
}