Previous DOS edition to read, write, format the No. 0 track of the 1th magnetic field, the program is roughly as follows:
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; /* For read, the for write, the for format */
int86x (0x13,®,®,&sreg);
then convert to call DeviceIoControl under Windows to format, read, and write to the magnetic track, dioc_registers this struct in DOS int21 for HDD or FDD parameters to format is int21 also have , but it is also available under 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 =::d Eviceiocontrol (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 =::d Eviceiocontrol (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 =::d Eviceiocontrol (Hdevice, vwin32_dioc_dos_int13,
&reg, sizeof (dioc_registers), &reg,
sizeof (dioc_registers), &CB, 0);
if (!dwresult | | (Reg.reg_flags & 0x0001))
{
}