From f8852fda40659c3735f14690b992e692f1c3fe57 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Sat, 17 Sep 2005 22:00:35 +0000 Subject: [PATCH] Do not overwrite the disk signature, if we install the boot code into the mbr. svn path=/trunk/; revision=17903 --- reactos/subsys/system/usetup/bootsup.c | 24 ++++++++++++------------ reactos/subsys/system/usetup/usetup.h | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/reactos/subsys/system/usetup/bootsup.c b/reactos/subsys/system/usetup/bootsup.c index 8059aad27be..22ce2164c57 100644 --- a/reactos/subsys/system/usetup/bootsup.c +++ b/reactos/subsys/system/usetup/bootsup.c @@ -1002,13 +1002,13 @@ InstallMbrBootCodeToDisk (PWSTR SrcPath, UNICODE_STRING Name; HANDLE FileHandle; NTSTATUS Status; - PUCHAR OrigBootSector; - PUCHAR NewBootSector; + PPARTITION_SECTOR OrigBootSector; + PPARTITION_SECTOR NewBootSector; /* Allocate buffer for original bootsector */ - OrigBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap, - 0, - SECTORSIZE); + OrigBootSector = (PPARTITION_SECTOR)RtlAllocateHeap(ProcessHeap, + 0, + sizeof(PARTITION_SECTOR)); if (OrigBootSector == NULL) return(STATUS_INSUFFICIENT_RESOURCES); @@ -1052,9 +1052,9 @@ InstallMbrBootCodeToDisk (PWSTR SrcPath, /* Allocate buffer for new bootsector */ - NewBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap, - 0, - SECTORSIZE); + NewBootSector = (PPARTITION_SECTOR)RtlAllocateHeap(ProcessHeap, + 0, + sizeof(PARTITION_SECTOR)); if (NewBootSector == NULL) { RtlFreeHeap(ProcessHeap, 0, OrigBootSector); @@ -1090,7 +1090,7 @@ InstallMbrBootCodeToDisk (PWSTR SrcPath, NULL, &IoStatusBlock, NewBootSector, - SECTORSIZE, + sizeof(PARTITION_SECTOR), NULL, NULL); NtClose(FileHandle); @@ -1102,9 +1102,9 @@ InstallMbrBootCodeToDisk (PWSTR SrcPath, } /* Copy partition table from old MBR to new */ - RtlCopyMemory ((NewBootSector + 446), - (OrigBootSector + 446), - 4*16 /* Length of partition table */); + RtlCopyMemory (&NewBootSector->Signature, + &OrigBootSector->Signature, + sizeof(PARTITION_SECTOR) - offsetof(PARTITION_SECTOR, Signature) /* Length of partition table */); /* Free the original boot sector */ RtlFreeHeap(ProcessHeap, 0, OrigBootSector); diff --git a/reactos/subsys/system/usetup/usetup.h b/reactos/subsys/system/usetup/usetup.h index 7a5a7de3a5a..191f8b185f9 100644 --- a/reactos/subsys/system/usetup/usetup.h +++ b/reactos/subsys/system/usetup/usetup.h @@ -30,6 +30,7 @@ /* C Headers */ #include #include +#include /* PSDK/NDK */ #include -- 2.17.1