Magnetic zone with BCB

zhaozj2021-02-08  263

Magnetic area

First, the previous DOS version is read, write, format the first magnetic zone of the 0th track, the program is approximately 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; / * 02 for read, 03 for Write, 05 for format * / int86X (0x13, & reg, & reg, & SREG);

Then convert it under Windows to format, read, write this track, Dioc_registers This Struct is in the set of DOS INT21 to HDD or FDD's parameters to format it is int21, but Windows Also provided.

L # 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 def.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 def.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, V Win32_dioc_dos_int13, & reg, sizeof (dioc_registers), & reg, sizeof (dioc_registers), & cb, 0); if (! Dwresult || (reg.reg_flags & 0x0001)) {}

转载请注明原文地址:https://www.9cbs.com/read-1545.html

New Post(0)