svn path=/trunk/; revision=17903
UNICODE_STRING Name;
HANDLE FileHandle;
NTSTATUS Status;
UNICODE_STRING Name;
HANDLE FileHandle;
NTSTATUS Status;
- PUCHAR OrigBootSector;
- PUCHAR NewBootSector;
+ PPARTITION_SECTOR OrigBootSector;
+ PPARTITION_SECTOR NewBootSector;
/* Allocate buffer for original bootsector */
/* 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);
if (OrigBootSector == NULL)
return(STATUS_INSUFFICIENT_RESOURCES);
/* Allocate buffer for new bootsector */
/* 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);
if (NewBootSector == NULL)
{
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
NULL,
&IoStatusBlock,
NewBootSector,
NULL,
&IoStatusBlock,
NewBootSector,
+ sizeof(PARTITION_SECTOR),
NULL,
NULL);
NtClose(FileHandle);
NULL,
NULL);
NtClose(FileHandle);
}
/* Copy partition table from old MBR to new */
}
/* 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);
/* Free the original boot sector */
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
/* C Headers */
#include <ctype.h>
#include <stdio.h>
/* C Headers */
#include <ctype.h>
#include <stdio.h>
/* PSDK/NDK */
#include <windows.h>
/* PSDK/NDK */
#include <windows.h>