From 9031a3a34b90533f5d4ae6e95a4e6f9aa85c0535 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 16 Jun 2011 22:16:31 +0000 Subject: [PATCH] [VFATLIB] - Write the boot sector signature to the new boot sector after formatting - Volumes formatted after setup are now mountable svn path=/trunk/; revision=52285 --- reactos/lib/fslib/vfatlib/fat12.c | 9 ++++++--- reactos/lib/fslib/vfatlib/fat16.c | 9 ++++++--- reactos/lib/fslib/vfatlib/fat32.c | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/reactos/lib/fslib/vfatlib/fat12.c b/reactos/lib/fslib/vfatlib/fat12.c index 032895a4fab..fc701cf4c3e 100644 --- a/reactos/lib/fslib/vfatlib/fat12.c +++ b/reactos/lib/fslib/vfatlib/fat12.c @@ -56,11 +56,11 @@ Fat12WriteBootSector(IN HANDLE FileHandle, { IO_STATUS_BLOCK IoStatusBlock; NTSTATUS Status; - PUCHAR NewBootSector; + PFAT16_BOOT_SECTOR NewBootSector; LARGE_INTEGER FileOffset; /* Allocate buffer for new bootsector */ - NewBootSector = (PUCHAR)RtlAllocateHeap(RtlGetProcessHeap (), + NewBootSector = (PFAT16_BOOT_SECTOR)RtlAllocateHeap(RtlGetProcessHeap (), 0, BootSector->BytesPerSector); if (NewBootSector == NULL) @@ -70,10 +70,13 @@ Fat12WriteBootSector(IN HANDLE FileHandle, memset(NewBootSector, 0, BootSector->BytesPerSector); /* Copy FAT16 BPB to new bootsector */ - memcpy((NewBootSector + 3), + memcpy(&NewBootSector->OEMName[0], &BootSector->OEMName[0], 59); /* FAT16 BPB length (up to (not including) Res2) */ + /* Write the boot sector signature */ + NewBootSector->Signature1 = 0xAA550000; + /* Write sector 0 */ FileOffset.QuadPart = 0ULL; Status = NtWriteFile(FileHandle, diff --git a/reactos/lib/fslib/vfatlib/fat16.c b/reactos/lib/fslib/vfatlib/fat16.c index 1194de905e7..221ad81d501 100644 --- a/reactos/lib/fslib/vfatlib/fat16.c +++ b/reactos/lib/fslib/vfatlib/fat16.c @@ -56,11 +56,11 @@ Fat16WriteBootSector(IN HANDLE FileHandle, { IO_STATUS_BLOCK IoStatusBlock; NTSTATUS Status; - PUCHAR NewBootSector; + PFAT16_BOOT_SECTOR NewBootSector; LARGE_INTEGER FileOffset; /* Allocate buffer for new bootsector */ - NewBootSector = (PUCHAR)RtlAllocateHeap(RtlGetProcessHeap(), + NewBootSector = (PFAT16_BOOT_SECTOR)RtlAllocateHeap(RtlGetProcessHeap(), 0, BootSector->BytesPerSector); if (NewBootSector == NULL) @@ -70,10 +70,13 @@ Fat16WriteBootSector(IN HANDLE FileHandle, memset(NewBootSector, 0, BootSector->BytesPerSector); /* Copy FAT16 BPB to new bootsector */ - memcpy((NewBootSector + 3), + memcpy(&NewBootSector->OEMName[0], &BootSector->OEMName[0], 59); /* FAT16 BPB length (up to (not including) Res2) */ + /* Write the boot sector signature */ + NewBootSector->Signature1 = 0xAA550000; + /* Write sector 0 */ FileOffset.QuadPart = 0ULL; Status = NtWriteFile(FileHandle, diff --git a/reactos/lib/fslib/vfatlib/fat32.c b/reactos/lib/fslib/vfatlib/fat32.c index 9be3e050b12..1b5e4983a1b 100644 --- a/reactos/lib/fslib/vfatlib/fat32.c +++ b/reactos/lib/fslib/vfatlib/fat32.c @@ -56,11 +56,11 @@ Fat32WriteBootSector(IN HANDLE FileHandle, { IO_STATUS_BLOCK IoStatusBlock; NTSTATUS Status; - PUCHAR NewBootSector; + PFAT32_BOOT_SECTOR NewBootSector; LARGE_INTEGER FileOffset; /* Allocate buffer for new bootsector */ - NewBootSector = (PUCHAR)RtlAllocateHeap(RtlGetProcessHeap(), + NewBootSector = (PFAT32_BOOT_SECTOR)RtlAllocateHeap(RtlGetProcessHeap(), 0, BootSector->BytesPerSector); if (NewBootSector == NULL) @@ -70,10 +70,13 @@ Fat32WriteBootSector(IN HANDLE FileHandle, memset(NewBootSector, 0, BootSector->BytesPerSector); /* Copy FAT32 BPB to new bootsector */ - memcpy((NewBootSector + 3), + memcpy(&NewBootSector->OEMName[0], &BootSector->OEMName[0], 87); /* FAT32 BPB length (up to (not including) Res2) */ + /* Write the boot sector signature */ + NewBootSector->Signature1 = 0xAA550000; + /* Write sector 0 */ FileOffset.QuadPart = 0ULL; Status = NtWriteFile(FileHandle,