PCDINFO CdInfo)
{
PPVD Pvd;
- ULONG i;
+ USHORT i;
PUCHAR pc;
PWCHAR pw;
for (i = 0; i < 2048; i += 4)
{
/* DON'T optimize this to ULONG!!! (breaks overflow) */
- Serial.Part[0] += Buffer[i+3];
- Serial.Part[1] += Buffer[i+2];
- Serial.Part[2] += Buffer[i+1];
Serial.Part[3] += Buffer[i+0];
+ Serial.Part[2] += Buffer[i+1];
+ Serial.Part[1] += Buffer[i+2];
+ Serial.Part[0] += Buffer[i+3];
}
CdInfo->SerialNumber = Serial.Value;
/* Extract the volume label */
pc = Pvd->VolumeId;
pw = CdInfo->VolumeLabel;
- for (i = 0; i < MAXIMUM_VOLUME_LABEL_LENGTH && *pc != ' '; i++)
+ for (i = 0; i < (MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)) - 1; i++)
{
*pw++ = (WCHAR)*pc++;
}
*pw = 0;
+
+ /* Trim trailing spaces */
+ while (pw > CdInfo->VolumeLabel)
+ {
+ if (*--pw != ' ') break;
+
+ /* Remove the space */
+ *pw = '\0';
+
+ /* Decrease size */
+ i--;
+ }
+
CdInfo->VolumeLabelLength = i * sizeof(WCHAR);
CdInfo->VolumeSpaceSize = Pvd->VolumeSpaceSizeL;
Vpb->SerialNumber = CdInfo.SerialNumber;
Vpb->VolumeLabelLength = CdInfo.VolumeLabelLength;
- RtlCopyMemory(Vpb->VolumeLabel, CdInfo.VolumeLabel, CdInfo.VolumeLabelLength * sizeof(WCHAR));
+ RtlCopyMemory(Vpb->VolumeLabel, CdInfo.VolumeLabel, CdInfo.VolumeLabelLength);
RtlCopyMemory(&DeviceExt->CdInfo, &CdInfo, sizeof(CDINFO));
NewDeviceObject->Vpb = DeviceToMount->Vpb;
switch (Stack->MinorFunction)
{
+ case IRP_MN_KERNEL_CALL:
case IRP_MN_USER_FS_REQUEST:
switch (Stack->Parameters.DeviceIoControl.IoControlCode)
{