mirror of
https://github.com/pbatard/rufus.git
synced 2025-06-02 07:39:54 -04:00
[fat] improve FAT32 boot record setup
* write primary and secondary boot records * add offset provision for sector write * improved detection reports for MBR, FAT16 and FAT32
This commit is contained in:
parent
36fa9cee23
commit
0600005a09
4 changed files with 85 additions and 50 deletions
|
@ -71,7 +71,12 @@ int read_sectors(HANDLE hDrive, size_t SectorSize,
|
|||
return Size;
|
||||
}
|
||||
|
||||
/* Use a bastardized fp that contains a Windows handle and the sector size */
|
||||
/*
|
||||
* The following calls use a bastardized fp on Windows that contains:
|
||||
* fp->_ptr: a Windows handle
|
||||
* fp->_bufsiz: the sector size
|
||||
* fp->_cnt: a file offset
|
||||
*/
|
||||
int contains_data(FILE *fp, size_t Position,
|
||||
const void *pData, size_t Len)
|
||||
{
|
||||
|
@ -79,6 +84,7 @@ int contains_data(FILE *fp, size_t Position,
|
|||
HANDLE hDrive = (HANDLE)fp->_ptr;
|
||||
size_t SectorSize = (size_t)fp->_bufsiz;
|
||||
size_t StartSector, EndSector, NumSectors;
|
||||
Position += (size_t)fp->_cnt;
|
||||
|
||||
StartSector = Position/SectorSize;
|
||||
EndSector = (Position+Len+SectorSize-1)/SectorSize;
|
||||
|
@ -107,6 +113,7 @@ int write_data(FILE *fp, size_t Position,
|
|||
HANDLE hDrive = (HANDLE)fp->_ptr;
|
||||
size_t SectorSize = (size_t)fp->_bufsiz;
|
||||
size_t StartSector, EndSector, NumSectors;
|
||||
Position += (size_t)fp->_cnt;
|
||||
|
||||
StartSector = Position/SectorSize;
|
||||
EndSector = (Position+Len+SectorSize-1)/SectorSize;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue