[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
This commit is contained in:
Cameron Gutman 2011-06-16 22:16:31 +00:00
parent 67000c5688
commit 9031a3a34b
3 changed files with 18 additions and 9 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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,