![]() |
Read Absolute Disk Sector
hello dear DP people,
is there anybody how can me tell, what i must do to read the data from a disk sector ? Wbw, terence |
AW: Read Absolute Disk Sector
You can use
![]() |
AW: Read Absolute Disk Sector
|
AW: Read Absolute Disk Sector
http://michael-puff.de/Programmierung/Delphi/Programme/-> DiskImageNT
|
AW: Read Absolute Disk Sector
Liste der Anhänge anzeigen (Anzahl: 2)
Hello and thanks for your answers.
In the meanwhile i have check out some freeware stuff from other people. It works fine on floppy drives and usb drives. Under win vista i've to run the executable with admin rights to read drive c: without errors. But that's okay. Here are my results. Wbw, terence. |
AW: Read Absolute Disk Sector
Liste der Anhänge anzeigen (Anzahl: 4)
Zitat:
have some tries at this afternoon, using your idea of "createfile()". Works fine with "\\.\A:" for floppy and "\\.\F:" for mounted usb drive under win vista. Failed on hdd drives like "\\.\C:" using administrator privileges, of coz. But i'm still on the way to solve this. Here my attempts with a simple test program. Wbw, have a nice weekend, terence. |
AW: Read Absolute Disk Sector
If hDevice is valid, the static sector size might be your problem. You should call RaiseLastOSError() after a failed API call to display a specific error message.
Zitat:
|
AW: Read Absolute Disk Sector
Liste der Anhänge anzeigen (Anzahl: 2)
EXE appended.
Delphi-Quellcode:
procedure TForm1.bReadBootSectorClick(Sender: TObject);
begin prvSector:=0; EBSectorNumber.Text:=IntToStr(prvSector); _read_sector2(prvSector); // <------------------ end; function ReadNTSectors(Drive: Byte; FirstSector: DWord; SectorCount: Word; Buffer: Pointer): Boolean; var hDrive: THandle; DriveRoot: string; BytesRead: Cardinal; ReadCount: Cardinal; begin Result := False; ReadCount := 512 * SectorCount; DriveRoot := '\\.\' + Chr(64 + Drive) + ':'; hDrive := CreateFile(PChar(DriveRoot), GENERIC_READ, FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if (hDrive <> INVALID_HANDLE_VALUE) then begin FileSeek(hDrive, Int64(FirstSector * 512), 0); BytesRead := FileRead(hDrive, Buffer^, ReadCount); Result := (BytesRead = (512 * SectorCount)); FileClose(hDrive); end; end; procedure TForm1._read_sector2(mySector: cardinal); var dr : byte; Buf : array[0..511] of byte; i : integer; s : string[32]; ok : boolean; begin LBSectorData.Clear; FillChar(Buf, SizeOf(Buf), 0); dr:=Ord(UpCase(DCBDrive.Drive)) - Ord('A') + 1; ok:= ReadNTSectors(dr, mySector, 1, @Buf); if ok then begin s:=''; for i:=0 to 511 do begin if ((buf[i] > 31) and (buf[i] < 128)) then s:=s+Chr(buf[i]) else s:=s+'.'; case i of 31,63,95,127,159,191,223,255,287,319,351,383,415,447,479,511: begin LBSectorData.Items.Add(s); s:=''; end; end; {case} end; end else begin LBSectorData.Items.Add('Error Read Sector '+IntToStr(mySector)); end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:01 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz