读磁片磁区[VC/C++编程]
本文“读磁片磁区[VC/C++编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
从前的dos版要读、写、格局化第0轨的第1个磁区,程式大致以下:
char buffer[512];
reg.x.dx=0 ; /* for drive a *
reg.x.cx=0x0001 /* for boot sector */
reg.x.bx=fp_off(buffer);
sreg.es=fp_seg(buffer);
resg.x.ax=0x0201; /* 02 for read, 03 for write ,05 for format */
int86x(0x13,®,®,&sreg);
那麽在windows 下转换为呼唤 deviceiocontrol 以便格局化、读取、写入该磁轨,dioc_registers 这struct 在套上 dos 下 int21对hdd或fdd 的各项参数如要格局化是int21也是有, 但windows下也还有供应.
#pragma pack(push, 1)
struct dioc_registers {
dword reg_ebx;
dword reg_edx;
dword reg_ecx;
dword reg_eax;
dword reg_edi;
dword reg_esi;
dword reg_flags;
};
#pragma pack(pop)
sdiskimageinfo->hdevice = ::createfile("\\\\.\\vwin32", 0, 0, null, 0, file_flag_delete_on_close, null);
if( sdiskimageinfo->hdevice == invalid_handle_value)
brunnext = false;
// reset floppy disk
reg.reg_ebx = 0;
reg.reg_eax = 0x0000; // ioctl for block devices
reg.reg_edx = sdiskimageinfo->driver;
reg.reg_edi = 0; reg.reg_esi= 0;
reg.reg_flags = 0x0001; // assume error (carry flag is set)
dwresult = ::deviceiocontrol( sdiskimageinfo->hdevice, vwin32_dioc_dos_int13, ®, sizeof(dioc_registers), ®,
sizeof(dioc_registers), &cb, 0);
// seek floppy
reg.reg_ebx = 0;
reg.reg_eax = 0x0c00; // ioctl for block devices
reg.reg_ecx = ( sdiskimageinfo->nc << 8) | sdiskimageinfo->ns;
reg.reg_edx = ( sdiskimageinfo->nh << 8) | sdiskimageinfo->driver;
reg.reg_edi = 0;
reg.reg_esi= 0;
reg.reg_flags = 0x0001; // assume error (carry flag is set)
dwresult = ::deviceiocontrol( sdiskimageinfo->hdevice,
vwin32_dioc_dos_int13,
®, sizeof(dioc_registers), ®,
sizeof(dioc_registers), &cb, 0);
// read floppy
r_creatediskimagefile:
reg.reg_ebx = 0;
reg.reg_eax = 0x0200 | 0x01; // ioctl for block devices
reg.reg_ecx = ( sdiskimageinfo->nc << 8) | sdiskimageinfo->ns;
reg.reg_edx = ( sdiskimageinfo->nh << 8) | sdiskimageinfo->driver;
reg.reg_ebx = (dword) &m_buf;
reg.reg_edi = 0;
reg.reg_esi= 0;
reg.reg_flags = 0x0001; // assume error (carry flag is set)
dwresult = ::deviceiocontrol( hdevice, vwin32_dioc_dos_int13,
®, sizeof(dioc_registers), ®,
sizeof(dioc_registers), &cb, 0);
if (!dwresult || (reg.reg_flags & 0x0001))
{
}
以上是“读磁片磁区[VC/C++编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |
- ·上一篇文章:如安在BCB中利用CodeGuard
- ·下一篇文章:编程标准-程序员们都应当这样写代码
- ·中查找“读磁片磁区”更多相关内容
- ·中查找“读磁片磁区”更多相关内容