Solved

Read sector(s) from floppy

Posted on 1998-11-12
6
1,526 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

19 Experts available now in Live!

Get 1:1 Help Now