Solved

Read sector(s) from floppy

Posted on 1998-11-12
6
1,529 Views
Last Modified: 2012-05-04
Hi, I want to read a floppy sector-by-sector.

E.G.
...
  asm
    mov ah, 02h   //function 2 : read sector
    mov dl, 00h    //first drive A:
    mov dh, 00h  //head 0
    mov ch, 00h  //track 0
    mov cl, 01h   //sector 1
    mov al, 01h   //read 1 sector
    mov es, SEG buff  //segment address of buffer
    mov bx, OFFSET buff  //offset address of buffer
    int 13h      //read sector with interrupt 13
  end;
...

But, "SEG" is not available in Delphi2,
so what do I do then???
0
Comment
Question by:8BEE
6 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1346643
This won't work with 32bit windows. You'll have to use CreateFile and DeviceIOControl instead. Please look in the win32 help file for a topic called "Calling DeviceIOControl on Windows 95" or "Using DeviceIOControl...".

Sorry, have no sources available at this moment...   :-(

Regards, Madshi.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1346644
Hello
Here is a demo from dejanews  
It shows how to change the serial numberof a floppy disk using deviceiocontrol. it may be of assistance if only to help you understand how to use deviceiocontrol

InThe

USE IT AT YOUR OWN RISK!!!

unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics,
  Controls, Forms, Dialogs, StdCtrls, ComCtrls;type  TForm1 = class(TForm)
    Button1: TButton;    procedure Button1Click(Sender: TObject);  private
    { Private-Deklarationen }  public    { Public-Deklarationen }  end;var
  Form1: TForm1;const  VWin32_DIOC_DOS_Int25 = 2; // direkter Lesezugriff
                                              // direct read access
  VWin32_DIOC_DOS_Int26 = 3; // direkter Schreibzugriff
                                              // direct write accesstype
  TDevIoCtl_Reg = packed Record  Reg_EBX   : DWord;  Reg_EDX   : DWord;
  Reg_ECX   : DWord;  Reg_EAX   : DWord;  Reg_EDI   : DWord;  Reg_ESI   : DWord;
  Reg_Flags : DWord;end;type  TDiskIO = packed record  StartSektor    : DWord;
  AnzahlSektoren : Word;  PBuffer        : DWord;end;implementation{$R *.DFM}
// Bootsektor lesen, Seriennummer ändern und// Bootsektor zurückschreiben
// read boot sector, change serial number, and// write boot sector back
procedure TForm1.Button1Click(Sender: TObject);var  DevIoHandle   : THandle;
  BytesReturned : DWord;  Reg           : TDevIoCtl_Reg;
  DiskIO        : TDiskIO;
  DatenBuffer   : Array [0..511] of Byte;   //  = 512 Bytes
  // Die Sektorgröße kann man mit GetDiskFreeSpace ermitteln
  // (normalerweise = 512 Bytes, bei CD-ROMs = 2048 Bytes).
  // The size of one sector can be found out with GetDiskFreeSpace
  // (normaly = 512 bytes, CD-ROMs = 2048 bytes).begin
  // DiskIO und Reg initialisieren  // initialize DiskIO and Reg  with DiskIO do
    begin      StartSektor := 0;          // ab Sektor 0 / from sector 0
      AnzahlSektoren := 1;       // 1 Sektor lesen / read 1 sector
      PBuffer := DWord(@DatenBuffer);    end;  with Reg do    begin
      reg_EAX := 0;              // Laufwerk: / drive: 0 = A, 1 = B usw.
      reg_EBX := DWord(@DiskIO);
      reg_ECX := $FFFF;          // benutze / use DiskIO    end;
  // Handle für DeviceIoControl holen.  // retrieve handle for DeviceIoControl
  DevIoHandle := CreateFile(                 '\\.\vwin32',
                 Generic_Read,
                 File_Share_Read or File_Share_Write,                 nil,
                 Open_Existing,                 File_Attribute_Normal,
                 0);  // Nur weiter, wenn Handle gültig ist.
  // only proceed, if handle is valid
  if DevIoHandle <> Invalid_Handle_Value then    begin
      // direkter Lesezugriff      // direct read access
      DeviceIoControl(DevIoHandle,                      VWin32_DIOC_DOS_Int25,
                      @Reg,                      SizeOf(Reg),
                      @Reg,                      SizeOf(Reg),
                      BytesReturned,                      nil);
      // neue Seriennummer = $12345678      // new serial number = $12345678
      DatenBuffer[39] := $78;      DatenBuffer[40] := $56;
      DatenBuffer[41] := $34;      DatenBuffer[42] := $12;
      // direkter Schreibzugriff      // direct write access
      DeviceIoControl(DevIoHandle,                      VWin32_DIOC_DOS_Int26,
                      @Reg,                      SizeOf(Reg),
                      @Reg,                      SizeOf(Reg),
                      BytesReturned,                      nil);
      // Handle freigeben      // release handle      CloseHandle(DevIoHandle);
    end;end;end.

0
 
LVL 17

Expert Comment

by:inthe
ID: 1346645
ps..sorry that's such a bloody mess:-)
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Expert Comment

by:skatan_187
ID: 1346646
I am looking for a function that reads a disk until there is an error and then give the sector
as result .. So actually I am looking for the same stuff you are looking for. If I find something
i'll inform you about it ;-)

SkAtAn
0
 
LVL 4

Accepted Solution

by:
dwwang earned 200 total points
ID: 1346647
This is a new component that can read sectors from any disk:

http://vcl.vclxx.com/DELPHI/D32FREE/DIO.ZIP

download and have a try.
0
 
LVL 4

Expert Comment

by:dwwang
ID: 1346648
Hi, any progress?
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question