Author: tkreuzer
Date: Wed Jul 20 17:00:28 2011
New Revision: 52742
URL:
http://svn.reactos.org/svn/reactos?rev=52742&view=rev
Log:
[USETUP]
Patch by Dmitry Gorbachev:
Don't overwrite the OemName field in the bootsector. Although this field could
theoretically contain any string, MS recommends using "MSWIN4.0" and MSDOS does
even rely on it being this (or having higher last 2 characters)
This way we preserve what is being put there when the disk is formatted, which is
"MSWIN4.0"
See issue #6386 for more details.
Modified:
trunk/reactos/base/setup/usetup/bootsup.c
Modified: trunk/reactos/base/setup/usetup/bootsup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/bootsup.…
==============================================================================
--- trunk/reactos/base/setup/usetup/bootsup.c [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/bootsup.c [iso-8859-1] Wed Jul 20 17:00:28 2011
@@ -788,13 +788,13 @@
UNICODE_STRING Name;
HANDLE FileHandle;
NTSTATUS Status;
- PUCHAR OrigBootSector;
- PUCHAR NewBootSector;
+ PFAT_BOOTSECTOR OrigBootSector;
+ PFAT_BOOTSECTOR NewBootSector;
/* Allocate buffer for original bootsector */
- OrigBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap,
- 0,
- SECTORSIZE);
+ OrigBootSector = RtlAllocateHeap(ProcessHeap,
+ 0,
+ SECTORSIZE);
if (OrigBootSector == NULL)
return(STATUS_INSUFFICIENT_RESOURCES);
@@ -836,11 +836,10 @@
return(Status);
}
-
/* Allocate buffer for new bootsector */
- NewBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap,
- 0,
- SECTORSIZE);
+ NewBootSector = RtlAllocateHeap(ProcessHeap,
+ 0,
+ SECTORSIZE);
if (NewBootSector == NULL)
{
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
@@ -888,7 +887,10 @@
}
/* Adjust bootsector (copy a part of the FAT BPB) */
- memcpy((NewBootSector + 11), (OrigBootSector + 11), 51 /*fat BPB length*/);
+ memcpy(&NewBootSector->OemName,
+ &OrigBootSector->OemName,
+ FIELD_OFFSET(FAT32_BOOTSECTOR, BootCodeAndData) -
+ FIELD_OFFSET(FAT32_BOOTSECTOR, OemName));
/* Free the original boot sector */
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
@@ -951,14 +953,14 @@
UNICODE_STRING Name;
HANDLE FileHandle;
NTSTATUS Status;
- PUCHAR OrigBootSector;
- PUCHAR NewBootSector;
+ PFAT32_BOOTSECTOR OrigBootSector;
+ PFAT32_BOOTSECTOR NewBootSector;
LARGE_INTEGER FileOffset;
/* Allocate buffer for original bootsector */
- OrigBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap,
- 0,
- SECTORSIZE);
+ OrigBootSector = RtlAllocateHeap(ProcessHeap,
+ 0,
+ SECTORSIZE);
if (OrigBootSector == NULL)
return(STATUS_INSUFFICIENT_RESOURCES);
@@ -1001,9 +1003,9 @@
}
/* Allocate buffer for new bootsector (2 sectors) */
- NewBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap,
- 0,
- 2 * SECTORSIZE);
+ NewBootSector = RtlAllocateHeap(ProcessHeap,
+ 0,
+ 2 * SECTORSIZE);
if (NewBootSector == NULL)
{
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
@@ -1051,13 +1053,13 @@
}
/* Adjust bootsector (copy a part of the FAT32 BPB) */
- memcpy((NewBootSector + 3),
- (OrigBootSector + 3),
- 87); /* FAT32 BPB length */
+ memcpy(&NewBootSector->OemName,
+ &OrigBootSector->OemName,
+ FIELD_OFFSET(FAT32_BOOTSECTOR, BootCodeAndData) -
+ FIELD_OFFSET(FAT32_BOOTSECTOR, OemName));
/* Disable the backup boot sector */
- NewBootSector[0x32] = 0x00;
- NewBootSector[0x33] = 0x00;
+ NewBootSector->BackupBootSector = 0;
/* Free the original boot sector */
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
@@ -1416,9 +1418,10 @@
}
/* Adjust bootsector (copy a part of the FAT16 BPB) */
- memcpy(&NewBootSector->BytesPerSector,
- &OrigBootSector->BytesPerSector,
- 51); /* FAT16 BPB length */
+ memcpy(&NewBootSector->OemName,
+ &OrigBootSector->OemName,
+ FIELD_OFFSET(FAT32_BOOTSECTOR, BootCodeAndData) -
+ FIELD_OFFSET(FAT32_BOOTSECTOR, OemName));
PartInfo =
&PartitionList->CurrentPartition->PartInfo[PartitionList->CurrentPartitionNumber];
NewBootSector->HiddenSectors = PartInfo->HiddenSectors;
@@ -1582,9 +1585,10 @@
}
/* Adjust bootsector (copy a part of the FAT32 BPB) */
- memcpy(&NewBootSector->BytesPerSector,
- &OrigBootSector->BytesPerSector,
- 79); /* FAT32 BPB length */
+ memcpy(&NewBootSector->OemName,
+ &OrigBootSector->OemName,
+ FIELD_OFFSET(FAT32_BOOTSECTOR, BootCodeAndData) -
+ FIELD_OFFSET(FAT32_BOOTSECTOR, OemName));
PartInfo =
&PartitionList->CurrentPartition->PartInfo[PartitionList->CurrentPartitionNumber];
NewBootSector->HiddenSectors = PartInfo->HiddenSectors;