我能够修改MBR被0值覆盖。但是,是否有可能使我只覆盖MBR(Boot Signature)的最后2个字节(55h AAh)变为00h 00h? 我的代码是:
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...
结果证明成功但写入MBR的值是错误的。我对C ++很陌生,因此对此有点困惑。任何帮助将不胜感激。感谢