Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 660 of file bootsup.c.
Referenced by InstallFatBootcodeToPartition().
{ OBJECT_ATTRIBUTES ObjectAttributes; IO_STATUS_BLOCK IoStatusBlock; UNICODE_STRING Name; HANDLE FileHandle; NTSTATUS Status; PUCHAR BootSector; /* Allocate buffer for bootsector */ BootSector = RtlAllocateHeap(ProcessHeap, 0, SECTORSIZE); if (BootSector == NULL) return STATUS_INSUFFICIENT_RESOURCES; /* Read current boot sector into buffer */ RtlInitUnicodeString(&Name, RootPath); InitializeObjectAttributes(&ObjectAttributes, &Name, OBJ_CASE_INSENSITIVE, NULL, NULL); Status = NtOpenFile(&FileHandle, GENERIC_READ, &ObjectAttributes, &IoStatusBlock, 0, FILE_SYNCHRONOUS_IO_NONALERT); if (!NT_SUCCESS(Status)) { RtlFreeHeap(ProcessHeap, 0, BootSector); return Status; } Status = NtReadFile(FileHandle, NULL, NULL, NULL, &IoStatusBlock, BootSector, SECTORSIZE, NULL, NULL); NtClose(FileHandle); if (!NT_SUCCESS(Status)) { RtlFreeHeap(ProcessHeap, 0, BootSector); return Status; } /* Write bootsector to DstPath */ RtlInitUnicodeString(&Name, DstPath); InitializeObjectAttributes(&ObjectAttributes, &Name, 0, NULL, NULL); Status = NtCreateFile(&FileHandle, GENERIC_WRITE, &ObjectAttributes, &IoStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, 0, FILE_SUPERSEDE, FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY, NULL, 0); if (!NT_SUCCESS(Status)) { RtlFreeHeap(ProcessHeap, 0, BootSector); return Status; } Status = NtWriteFile(FileHandle, NULL, NULL, NULL, &IoStatusBlock, BootSector, SECTORSIZE, NULL, NULL); NtClose(FileHandle); /* Free the new boot sector */ RtlFreeHeap(ProcessHeap, 0, BootSector); return Status; }