Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 57 of file install.c.
Referenced by FatSwapFat32BootSector(), InstallFat32BootCodeToDisk(), and main().
{ HANDLE hBackupFile; TCHAR szFileName[MAX_PATH]; ULONG Count; BYTE BootSectorBuffer[512]; DWORD dwNumberOfBytesWritten; BOOL bRetVal; // // Find the next unused filename and open it // for (Count=0; ; Count++) { // // Generate the next filename // _stprintf(szFileName, _T("%s\\bootsect.%03ld"), lpszVolumeName, Count); // // Try to create a new file, fail if exists // hBackupFile = CreateFile(szFileName, GENERIC_WRITE, 0, NULL, CREATE_NEW, /*FILE_ATTRIBUTE_SYSTEM*/0, NULL); // // Check to see if it worked // if (hBackupFile != INVALID_HANDLE_VALUE) { break; } // // Nope, didn't work // Check to see if it already existed // if (!(GetLastError() != ERROR_ALREADY_EXISTS)) { _tprintf(_T("%s:%d: "), __FILE__, __LINE__); _tprintf(_T("Boot sector backup failed. Error code %ld.\n"), GetLastError()); return FALSE; } } // // Try to read the boot sector // if (!ReadVolumeSector(0, BootSectorBuffer)) { CloseHandle(hBackupFile); return FALSE; } // // Try to write the boot sector data to the file // bRetVal = WriteFile(hBackupFile, BootSectorBuffer, 512, &dwNumberOfBytesWritten, NULL); if (!bRetVal || (dwNumberOfBytesWritten != 512)) { CloseHandle(hBackupFile); _tprintf(_T("%s:%d: "), __FILE__, __LINE__); _tprintf(_T("WriteFile() failed. Error code %ld.\n"), GetLastError()); return FALSE; } _tprintf(_T("Boot sector backed up to file: %s\n"), szFileName); CloseHandle(hBackupFile); return TRUE; }