Skip to content
Permalink
Browse files

fix many compiler warnings

  • Loading branch information...
darealshinji committed Jan 22, 2019
1 parent 0863b0b commit 9fda70d1564a1f59bd0425fec30fe0f4e37f8d1b
Showing with 70 additions and 64 deletions.
  1. +4 −4 GPTMBR.pas
  2. +2 −4 dbases_sqlite.pas
  3. +44 −33 diskmodule.pas
  4. +3 −3 quickhash.lpr
  5. +17 −20 unit2.pas
@@ -93,18 +93,18 @@ implementation
function MBR_or_GPT(SelectedDisk : widestring) : string;

const
PARTITION_STYLE_MBR = 0;
PARTITION_STYLE_GPT = 1;
PARTITION_STYLE_RAW = 2;
//PARTITION_STYLE_MBR = 0;
//PARTITION_STYLE_GPT = 1;
//PARTITION_STYLE_RAW = 2;

IOCTL_DISK_GET_DRIVE_LAYOUT_EX = $00070050;
var
i: Integer;
Drive: widestring;
hDevice: THandle;
DriveLayoutInfo: TDriveLayoutInformationEx;
BytesReturned: DWORD;
begin
BytesReturned := 0;
result := '';
Drive := SelectedDisk;
// This particular handle assignment does not require admin rights as it allows
@@ -111,7 +111,6 @@ implementation

procedure TfrmSQLiteDBases.FormCreate(Sender: TObject);
var
i : integer;
guid : TGuid;
SQLiteLibraryPath, strFileNameRandomiser, SafePlaceForDB : string;
{$ifdef Linux}
@@ -350,7 +349,7 @@ function TfrmSQLiteDBases.CountGridRows(DBGrid : TDBGrid) : integer;
// If big volume, uses file stream.
procedure TfrmSQLiteDBases.SaveFILESTabToHTML(DBGrid : TDBGrid; Filename : string);
var
strTitle, FileNameCell, FilePathCell, FileHashCell, AllRowCells : string;
strTitle, FileNameCell, FilePathCell, FileHashCell : string;
NoOfRowsInGrid : integer;
sl : TStringList;
fs : TFileStreamUTF8;
@@ -1061,15 +1060,14 @@ procedure TfrmSQLiteDBases.ShowAllCOPYGRID(DBGrid : TDBGrid);
procedure TfrmSQLiteDBases.SaveCOPYWindowToHTML(DBGrid : TDBGrid; Filename : string);
var
strTitle, SourceFilename, DestinationFileName, DateAttributes, SourceFileHash, DestinationFileHash : string;
i, NoOfRowsInGrid : integer;
NoOfRowsInGrid : integer;
sl : TStringList;
fs : TFileStreamUTF8;

const
strHTMLHeader = '<HTML>' ;
strTITLEHeader = '<TITLE>QuickHash HTML Output' ;
strBODYHeader = '<BODY>' ;
strTABLEHeader = '<table>' ;
strTABLEROWStart = '<TR>' ;
strTABLEDATAStart = '<TD>' ;
strTABLEDataEnd = '</TD>' ;
@@ -103,7 +103,7 @@ TfrmDiskHashingModule = class(TForm)
function InitialiseHashChoice(Sender : TObject) : Integer;
procedure cbdisksChange(Sender: TObject);
function GetDiskTechnicalSpecs(Sender: TObject) : Integer;
function GetDiskTechnicalSpecsLinux(Sender: TObject) : Integer;
procedure GetDiskTechnicalSpecsLinux(Sender: TObject);
procedure InvokeDiskHashScheduler (Sender : TObject);
procedure CheckSchedule(DesiredStartTime : TDateTime);

@@ -144,7 +144,7 @@ TfrmDiskHashingModule = class(TForm)
{$endif}

{$ifdef Unix}
function ListDrivesLinux : string;
procedure ListDrivesLinux();
function GetOSNameLinux() : string;
function GetBlockCountLinux(s : string) : string;
function GetBlockSizeLinux(DiskDevName : string) : Integer;
@@ -166,11 +166,8 @@ implementation

// Enable or disable elements depending on the OS hosting the application
procedure TfrmDiskHashingModule.FormCreate(Sender: TObject);
var
MissingFileCount : integer;
begin
Stop := false;
MissingFileCount := 0;
ExecutionCount := 0;
ledtComputedHashA.Enabled := false;
ledtComputedHashB.Enabled := false;
@@ -339,12 +336,15 @@ function GetDiskLabels(DiskDevName : string) : string;
var

DiskInfoProcess : TProcess;
DiskInfoProcessUDISKS : TProcess;
diskinfo, diskinfoUDISKS : TStringList;
diskinfo : TStringList;
i : Integer;
stmp, strModel, strVendor, strType, strSerial : String;

begin
strModel := '';
strVendor := '';
strType := '';
strSerial := '';

// Probe all attached disks and populate the interface
DiskInfoProcess:=TProcess.Create(nil);
@@ -468,14 +468,14 @@ procedure TfrmDiskHashingModule.cbdisksChange(Sender: TObject);


{$ifdef UNIX}
function ListDrivesLinux : string;
procedure ListDrivesLinux();
var
DisksProcess: TProcess;
i: Integer;
intPhysDiskSize, intLogDiskSize : QWord;
slDisklist: TSTringList;
PhyDiskNode, PartitionNoNode, DriveLetterNode : TTreeNode;
strPhysDiskSize, strLogDiskSize, DiskDevName, DiskLabels, dmCryptDiscovered : string;
PhyDiskNode, DriveLetterNode : TTreeNode;
strPhysDiskSize, strLogDiskSize, DiskDevName, DiskLabels, dmCryptDiscovered : string;
begin
intPhysDiskSize := 0;
DisksProcess:=TProcess.Create(nil);
@@ -529,7 +529,7 @@ function ListDrivesLinux : string;
frmDiskHashingModule.Treeview1.AlphaSort;
slDisklist.Free;
DisksProcess.Free;
end;
end;


// Returns a string holding the disk block COUNT (not size) as extracted from the string from
@@ -553,14 +553,12 @@ function GetBlockCountLinux(s : string) : string;
function GetBlockSizeLinux(DiskDevName : string) : Integer;
var
DiskProcess: TProcess;
BlockSize, StartOffset, i : Integer;
i : Integer;
slDevDisk: TSTringList;
strBlockSize : string;
RelLine : boolean;

begin
RelLine := false;
BlockSize := 0;
result := 0;
DiskProcess:=TProcess.Create(nil);
DiskProcess.Options:=[poWaitOnExit, poUsePipes];
DiskProcess.CommandLine:='udisksctl info -b ' + DiskDevName; //get all disks/partitions list
@@ -581,9 +579,9 @@ function GetBlockSizeLinux(DiskDevName : string) : Integer;
// Extracts the byte value "Size: " from the output of udisksctl info -b /dev/sdX
function GetByteCountLinux(DiskDevName : string) : QWord;
var
DiskProcess: TProcess;
StartOffset, i : Integer;
slDevDisk: TSTringList;
DiskProcess : TProcess;
i : Integer;
slDevDisk : TSTringList;
strByteCount : string;
ScanDiskData : boolean;
intByteCount : QWord;
@@ -635,6 +633,7 @@ function ExtractNumbers(s: string): string;
// Returns the exact disk size for BOTH physical disks and logical drives as
// reported by the Windows API and is used during the imaging stage
function GetDiskLengthInBytes(hSelectedDisk : THandle) : Int64;
{$ifdef Windows}
const
// These are defined at the MSDN.Microsoft.com website for DeviceIOControl
// and https://forum.tuts4you.com/topic/22361-deviceiocontrol-ioctl-codes/
@@ -702,10 +701,13 @@ function GetDiskLengthInBytes(hSelectedDisk : THandle) : Int64;
BytesReturned: DWORD;
DLength: TDiskLength;

{$endif}

begin
result := 0;
{$ifdef Windows}
ByteSize := 0;
BytesReturned := 0;
{$ifdef Windows}
// https://msdn.microsoft.com/en-us/library/aa365178%28v=vs.85%29.aspx
if not DeviceIOControl(hSelectedDisk,
IOCTL_DISK_GET_LENGTH_INFO,
@@ -892,12 +894,13 @@ function TfrmDiskHashingModule.GetDiskTechnicalSpecs(Sender : TObject) : integer
slDiskSpecs : TStringList;
{$endif}
begin
{$ifdef Unix}
GetDiskTechnicalSpecsLinux(Sender);
{$endif}
result := -1;

{$ifdef Unix}
GetDiskTechnicalSpecsLinux(Sender);
{$endif}

{$ifdef Windows}
result := -1;
{$ifdef Windows}
DiskName := '';
Size := 0;
TotalHeads := 0;
@@ -1019,7 +1022,7 @@ function TfrmDiskHashingModule.GetDiskTechnicalSpecs(Sender : TObject) : integer
{$endif}
end;

function TfrmDiskHashingModule.GetDiskTechnicalSpecsLinux(Sender : TObject) : integer;
procedure TfrmDiskHashingModule.GetDiskTechnicalSpecsLinux(Sender : TObject);
var
DiskInfoProcessUDISKS : TProcess;
diskinfoUDISKS : TStringList;
@@ -1044,6 +1047,7 @@ function TfrmDiskHashingModule.GetDiskTechnicalSpecsLinux(Sender : TObject) : in
// menHashDiskClick - OnClick event for right clicking a disk in the treeview and choosing "Hash this disk"
// Makes a call to HashDisk after collecting all data about the disk first
procedure TfrmDiskHashingModule.menHashDiskClick(Sender: TObject);
{$ifdef Windows}
const
// These values are needed for For FSCTL_ALLOW_EXTENDED_DASD_IO to work properly
// on logical volumes. They are sourced from
@@ -1054,21 +1058,25 @@ procedure TfrmDiskHashingModule.menHashDiskClick(Sender: TObject);
FSCTL_ALLOW_EXTENDED_DASD_IO = ((FILE_DEVICE_FILE_SYSTEM shl 16)
or (FILE_ANY_ACCESS shl 14)
or (32 shl 2) or METHOD_NEITHER);
{$endif}

var
SourceDevice : widestring;
hSelectedDisk : THandle;
ExactDiskSize, SectorCount, HashResult : Int64;
ExactSectorSize : integer;
ExactDiskSize, HashResult : Int64;
//SectorCount : Int64;
//ExactSectorSize : integer;
slHashLog : TStringList;
{$ifdef Windows}
BytesReturned : DWORD;
{$endif}
StartedAt, EndedAt, TimeTakenToHash : TDateTime;

begin
{$ifdef Windows}
BytesReturned := 0;
{$endif}
ExactDiskSize := 0;
ExactSectorSize := 0;
SectorCount := 0;
HashResult := 0;
HashChoice := -1;
StartedAt := 0;
@@ -1122,14 +1130,14 @@ procedure TfrmDiskHashingModule.menHashDiskClick(Sender: TObject);
// Now query the sector size.
// 512 bytes is common with MBR but with GPT disks, 1024 or 4096 is likely
{$ifdef Windows}
ExactSectorSize := GetSectorSizeInBytes(hSelectedDisk);
//ExactSectorSize := GetSectorSizeInBytes(hSelectedDisk);
{$endif}
{$ifdef Unix}
ExactSectorSize := GetBlockSizeLinux(SourceDevice);
//ExactSectorSize := GetBlockSizeLinux(SourceDevice);
{$endif}

// Now we can assign a sector count based on sector size and disk size
SectorCount := ExactDiskSize DIV ExactSectorSize;
//SectorCount := ExactDiskSize DIV ExactSectorSize;

frmProgress.lblTotalBytesSource.Caption := ' bytes hashed of ' + IntToStr(ExactDiskSize);

@@ -1587,8 +1595,10 @@ function HashDisk(hDiskHandle : THandle; DiskSize : Int64; HashChoice : Integer)


procedure TfrmDiskHashingModule.menShowDiskManagerClick(Sender: TObject);
{$ifdef Windows}
var
ProcDiskManager : TProcess;
{$endif}
begin
{$ifdef Windows}
try
@@ -1813,6 +1823,7 @@ function GetVolumeName(DriveLetter: Char): string;
oldmode : LongInt;

begin
dummy := 0;
oldmode := SetErrorMode(SEM_FAILCRITICALERRORS);
try
// After stripping it out for GetDriveIDFromLetter to work,
@@ -1846,7 +1857,7 @@ function GetSectorSizeInBytes(hSelectedDisk : THandle) : Int64;
IOCTL_DISK_GET_DRIVE_GEOMETRY = $0070000;
var
DG : TDiskGeometry;
SectorSizeInBytes, BytesReturned : Integer;
BytesReturned : Integer;

begin
if not DeviceIOControl(hSelectedDisk,
@@ -75,9 +75,9 @@
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, lazdbexport, Unit2, FindAllFilesEnhanced, diskmodule, uDisplayGrid,
diskspecification, uProgress, frmAboutUnit, zvdatetimectrls, dbases_sqlite,
uKnownHashLists;
//FindAllFilesEnhanced, uKnownHashLists,
Forms, lazdbexport, Unit2, diskmodule, uDisplayGrid,
diskspecification, uProgress, frmAboutUnit, zvdatetimectrls, dbases_sqlite;

{$R *.res}

0 comments on commit 9fda70d

Please sign in to comment.
You can’t perform that action at this time.