From b1f04786e1ee6d576383c4d30b1bba6bb0ec96d9 Mon Sep 17 00:00:00 2001 From: Ahmed Arif Date: Mon, 8 Jun 2026 00:14:11 +0200 Subject: [PATCH] [NTOS:FSTUB] Clear the whole partition table in FstubCreateDiskRaw (#9124) FstubCreateDiskRaw is supposed to wipe the MBR when it makes a RAW disk. Before this fix, that function only cleared the first of the 4 partition entries, so one entry (16 bytes) instead of the whole table (64). As a consequence, the wiped MBR written back to disk still had entries 2, 3 and 4 sitting there with old data, and those came back as ghost/garbage partitions. --- ntoskrnl/fstub/fstubex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntoskrnl/fstub/fstubex.c b/ntoskrnl/fstub/fstubex.c index e4e5b4bfa1d..88c20822556 100644 --- a/ntoskrnl/fstub/fstubex.c +++ b/ntoskrnl/fstub/fstubex.c @@ -487,7 +487,7 @@ FstubCreateDiskRaw(IN PDEVICE_OBJECT DeviceObject) /* Only zero useful stuff */ MasterBootRecord = (PMASTER_BOOT_RECORD)Disk->Buffer; MasterBootRecord->Signature = 0; - RtlZeroMemory(MasterBootRecord->PartitionTable, sizeof(PARTITION_TABLE_ENTRY)); + RtlZeroMemory(MasterBootRecord->PartitionTable, sizeof(PARTITION_TABLE_ENTRY) * NUM_PARTITION_TABLE_ENTRIES); MasterBootRecord->MasterBootRecordMagic = 0; /* Write back that destroyed MBR */