[NTOS:MM] Fix ViewSize parameter passed to MiInsertVadEx() from MiCreatePebOrTeb()
[reactos.git] / ntoskrnl / fstub / fstubex.c
index beb66fb..b9be7fa 100644 (file)
@@ -963,8 +963,12 @@ FstubReadPartitionTableEFI(IN PDISK_INFORMATION Disk,
     ULONG NumberOfEntries;
     PEFI_PARTITION_HEADER EfiHeader;
     EFI_PARTITION_ENTRY PartitionEntry;
+#if 0
     BOOLEAN UpdatedPartitionTable = FALSE;
     ULONGLONG SectorsForPartitions, PartitionEntryLBA;
+#else
+    ULONGLONG PartitionEntryLBA;
+#endif
     PDRIVE_LAYOUT_INFORMATION_EX DriveLayoutEx = NULL;
     ULONG i, PartitionCount, PartitionIndex, PartitionsPerSector;
     PAGED_CODE();
@@ -996,6 +1000,7 @@ FstubReadPartitionTableEFI(IN PDISK_INFORMATION Disk,
         return STATUS_INSUFFICIENT_RESOURCES;
     }
 
+#if 0
     if (!ReadBackupTable)
     {
         /* If we weren't ask to read backup table,
@@ -1006,7 +1011,7 @@ FstubReadPartitionTableEFI(IN PDISK_INFORMATION Disk,
         if ((Disk->SectorCount - 1ULL) != EfiHeader->AlternateLBA)
         {
             /* We'll update it. First, count number of sectors needed to store partitions */
-            SectorsForPartitions = (EfiHeader->NumberOfEntries * PARTITION_ENTRY_SIZE) / Disk->SectorSize;
+            SectorsForPartitions = ((ULONGLONG)EfiHeader->NumberOfEntries * PARTITION_ENTRY_SIZE) / Disk->SectorSize;
             /* Then set first usable LBA: Legacy MBR + GPT header + Partitions entries */
             EfiHeader->FirstUsableLBA = SectorsForPartitions + 2;
             /* Then set last usable LBA: Last sector - GPT header - Partitions entries */
@@ -1015,6 +1020,7 @@ FstubReadPartitionTableEFI(IN PDISK_INFORMATION Disk,
             UpdatedPartitionTable = TRUE;
         }
     }
+#endif
 
     DriveLayoutEx->PartitionStyle = PARTITION_STYLE_GPT;
     /* Translate LBA -> Offset */
@@ -1083,12 +1089,14 @@ FstubReadPartitionTableEFI(IN PDISK_INFORMATION Disk,
     }
     DriveLayoutEx->PartitionCount = PartitionCount;
 
+#if 0
     /* If we updated partition table using backup table, rewrite partition table */
     if (UpdatedPartitionTable)
     {
         IoWritePartitionTableEx(Disk->DeviceObject,
                                 DriveLayoutEx);
     }
+#endif
 
     /* Finally, return read data */
     *DriveLayout = DriveLayoutEx;
@@ -1313,7 +1321,7 @@ FstubVerifyPartitionTableEFI(IN PDISK_INFORMATION Disk,
     }
 
     /* Compute sectors taken by partitions */
-    SectorsForPartitions = ((EFIHeader->NumberOfEntries * PARTITION_ENTRY_SIZE) + Disk->SectorSize - 1) / Disk->SectorSize;
+    SectorsForPartitions = (((ULONGLONG)EFIHeader->NumberOfEntries * PARTITION_ENTRY_SIZE) + Disk->SectorSize - 1) / Disk->SectorSize;
     if (PrimaryValid)
     {
         WriteBackup = TRUE;
@@ -2474,7 +2482,7 @@ IoWritePartitionTableEx(IN PDEVICE_OBJECT DeviceObject,
                     NumberOfEntries = EfiHeader->NumberOfEntries;
                     RtlCopyMemory(&DiskGuid, &EfiHeader->DiskGUID, sizeof(GUID));
                     /* Count number of sectors needed to store partitions */
-                    SectorsForPartitions = (NumberOfEntries * PARTITION_ENTRY_SIZE) / Disk->SectorSize;
+                    SectorsForPartitions = ((ULONGLONG)NumberOfEntries * PARTITION_ENTRY_SIZE) / Disk->SectorSize;
                     /* Set first usable LBA: Legacy MBR + GPT header + Partitions entries */
                     FirstUsableLBA = SectorsForPartitions + 2;
                     /* Set last usable LBA: Last sector - GPT header - Partitions entries */
@@ -2501,6 +2509,10 @@ IoWritePartitionTableEx(IN PDEVICE_OBJECT DeviceObject,
                                                              DriveLayout->PartitionEntry);
                     }
                 }
+                else
+                {
+                    Status = STATUS_INVALID_PARAMETER;
+                }
             }
             break;