I searched a lot to get write - access to the boot sector (Master File Table ). I used CreateFile
function with write access parameters like, GENERIC_WRITE
. Then used SetFilePointer
and WriteFile
to write on a particular memory address. But what I always get is System.AccessViolationException
(Windows 7). Am I doing something wrong here ?
I want to know if there is any alternative to CreateFile - WriteFile functions to get wrtie - access to boot sector ?
OR I was thinking if there is any way to use Interrup Service Routine to write on particular disk sectors in VC++ (C++/Cli) ?
According to Microsoft KB you have to call
CreateFile
withFILE_SHARE_READ
andFILE_SHARE_WRITE
on"\\.\PhysicalDriveN"
, whereN
is zero-based physical drive index. Then you can access the entire drive as one huge file. You have to be an administrator on your machine for this to work!Update: I did some research and I found out that starting Vista you have to obtain the lock on the volume or dismount it. Otherwise the writes would fail. In the docs Microsoft says: