magnetic field of Read Magnetic disc

Source: Internet
Author: User
Tags pack

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


{


}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.