Solved

Read sector(s) from floppy

Posted on 1998-11-12
6
1,525 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
Comment Utility
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
Comment Utility
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
Comment Utility
ps..sorry that's such a bloody mess:-)
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Expert Comment

by:skatan_187
Comment Utility
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
Comment Utility
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
Comment Utility
Hi, any progress?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now