读磁片磁区

爱乐购美妆

爱乐购美妆

2016-02-19 15:06

下面是个简单易学的读磁片磁区教程,图老师小编详细图解介绍包你轻松学会,喜欢的朋友赶紧get起来吧!

  一、以前的dos版要读、写、格式化第0轨的第1个磁区,程式大致如下:

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/bianchengyuyan/)

  

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,&reg,&reg,&sreg);

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/bianchengyuyan/)

  那麽在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, &reg, sizeof(dioc_registers), &reg,
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,
                   &reg, sizeof(dioc_registers), &reg,
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,
                   &reg, sizeof(dioc_registers), &reg,
sizeof(dioc_registers), &cb, 0);
    if (!dwresult || (reg.reg_flags & 0x0001))
    {
}

展开更多 50%)
分享

猜你喜欢

读磁片磁区

编程语言 网络编程
读磁片磁区

Linux 指令篇:磁片工具--fdformat

Linux Linux命令 Linux安装 Linux编程 Linux桌面 Linux软件 Linux内核 Linux管理
Linux 指令篇:磁片工具--fdformat

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

Linux 指令篇:磁片工具--mformat

Linux Linux命令 Linux安装 Linux编程 Linux桌面 Linux软件 Linux内核 Linux管理
Linux 指令篇:磁片工具--mformat

Linux 指令篇:磁片工具--mkdosfs

Linux Linux命令 Linux安装 Linux编程 Linux桌面 Linux软件 Linux内核 Linux管理
Linux 指令篇:磁片工具--mkdosfs

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

奶酪怎么设置已读消息为未读

手机软件 应用软件
奶酪怎么设置已读消息为未读

Linux指令篇:磁片工具--mkdosfs

Linux Linux命令 Linux安装 Linux编程 Linux桌面 Linux软件 Linux内核 Linux管理
Linux指令篇:磁片工具--mkdosfs

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

如何在PowerPoint2010中插入公式

如何在PowerPoint2010中插入公式

罗云彬VxD教程--虚拟设备驱动程序初步

罗云彬VxD教程--虚拟设备驱动程序初步
下拉加载更多内容 ↓