-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstudio_tools.pas
904 lines (830 loc) · 23.8 KB
/
studio_tools.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
unit studio_tools;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
interface
{$IFDEF WIN32}
uses Windows, classes;
{$DEFINE WINDOWS}
{$ELSE}
{$IFDEF WIN64}
uses Windows, classes;
{$DEFINE WINDOWS}
{$ELSE}
uses classes;
{$ENDIF}
{$ENDIF}
const AppVersion = '1.0beta1';
{$IFDEF WIN32}
const AppPlatform = 'WIN32';
{$DEFINE WINDOWS}
{$ELSE}
{$IFDEF WIN64}
const AppPlatform = 'WIN64';
{$DEFINE WINDOWS}
{$ELSE}
const AppPlatform = 'unknown';
{$ENDIF}
{$ENDIF}
type
ProgressEvent = function (Progress : Int64; Error : DWORD) : Boolean of object;
function LoadDiskFile(FileName : String) : String;
procedure SaveDiskFile(FileName : String; Data : String);
function LoadDiskResource(Name : String) : String;
function SaveDiskResource(ExeName : String; Name : TStringList; Data : TStringList) : Boolean;
procedure CreateExe(FileName : String; Stub : String);
procedure ShowError(Action : String);
function GetSize(h : THandle) : Int64;
procedure DoDD(InFile : String; OutFile : String; BlockSize : Int64; Count : Int64; Skip : Int64; Seek : int64; NoTruncateOut : Boolean; StopType : Boolean; Callback : ProgressEvent);
function StartsWith(S : String; Start : String; var Value : String) : Boolean;
function EndsWith(S : String; Ends : String; var Value : String) : Boolean;
function GetDriveStrings(StringList : TStringList) : Boolean;
function GetDriveTypeDescription(DriveType : Integer) : String;
implementation
{$IFDEF WINDOWS}
uses sysutils, debug, Native, WinBinFile, md5, dialogs, WinIOCTL, persrc, MT19937;
{$ELSE}
uses zlib, sysutils, debug, UnixBinFile, md5, persrc;
{$ENDIF}
procedure ShowError(Action : String);
begin
{$IFDEF WINDOWS}
Log('Error ' + Action + ': ' + IntToStr(Windows.GetLastError) + ' ' + SysErrorMessage(Windows.GetLastError));
{$ELSE}
Log('Error ' + Action + ': perror NYI');
{$ENDIF}
end;
function LoadDiskFile(FileName : String) : String;
var
BinFile : TBinaryFile;
begin
BinFile := TBinaryFile.Create;
try
BinFile.Assign(FileName);
BinFile.Open(OPEN_READ_ONLY);
SetLength(Result, BinFile.FileSize);
BinFile.BlockRead2(PChar(Result), BinFile.FileSize);
finally
BinFile.Free;
end;
end;
procedure SaveDiskFile(FileName : String; Data : String);
var
BinFile : TBinaryFile;
begin
BinFile := TBinaryFile.Create;
try
BinFile.Assign(FileName);
if not BinFile.CreateNew then
begin
BinFile.Open(OPEN_WRITE_ONLY);
BinFile.TruncateTo(0);
end;
BinFile.BlockWrite2(PChar(Data), Length(Data));
finally
BinFile.Free;
end;
end;
{$IFDEF WINDOWS}
function LoadDiskResource(Name : String) : String;
var
h : THandle;
gh : THandle;
data : PChar;
Res : String;
begin
h := FindResource(0, PChar(Name), 'DISK');
if h > 0 then
begin
gh := LoadResource(0, h);
if gh > 0 then
begin
Data := LockResource(gh);
if Data <> nil then
begin
SetLength(Res,SizeofResource(0, h));
CopyMemory(PChar(Res), Data, Length(Res));
//Result := ZDecompressStr(res);
Result := Res;
end
else
begin
// error
end;
end
else
begin
// error
end;
end
else
begin
// error
end;
end;
{$ELSE}
function LoadDiskResource(Name : String) : String;
begin
// use my code to load it...
Log('LoadDiskResource NYI');
Result := '';
end;
{$ENDIF}
// alas, I had to write my own
// Data should already be compressed
function SaveDiskResource(ExeName : String; Name : TStringList; Data : TStringList) : Boolean;
var
i : Integer;
Len : Integer;
PEFile : TPEFile;
NewResource : TResourceTreeNode;
begin
Result := True;
PEFile := TPEFile.Create(ExeName);
if Assigned(PEFile.GetRsrcRoot) then
begin
for i := 0 to Name.Count - 1 do
begin
Len := Length(Data[i]);
Log('Adding resource ' + Name[i] + ' (' + IntToStr(Len) + ')');
NewResource := PEFile.GetRsrcRoot.GetNodeByName('DISK');
if not Assigned(NewResource) then
begin
NewResource := PEFile.GetRsrcRoot.CreateNode;
NewResource.SetName('DISK');
end;
if Assigned(NewResource) then
begin
NewResource := NewResource.CreateNode;
if Assigned(NewResource) then
begin
NewResource.SetName(Name[i]);
// The data goes on the language node
NewResource := NewResource.CreateNode;
if Assigned(NewResource) then
begin
NewResource.SetLeafData(Data[i], 0);
end;
end;
end;
end;
end;
PEFile.Save;
end;
function CopyStub(Target : String; StubFile : String) : Boolean;
var
BinFile : TBinaryFile;
Stub : String;
begin
Result := false;
if Length(StubFile) = 0 then
begin
Stub := LoadDiskResource('STUB');
try
Stub := '';//Zlib.ZDecompressStr(Stub);
except
end;
if Length(Stub) = 0 then
begin
exit;
end;
end
else
begin
// use a specifc stub file
BinFile := TBinaryFile.Create;
try
BinFile.Assign(StubFile);
BinFile.Open(0);
SetLength(Stub, BinFile.FileSize);
BinFile.BlockRead2(PChar(Stub), Length(Stub));
BinFile.Close;
finally
BinFile.Free;
end;
end;
BinFile := TBinaryFile.Create;
try
BinFile.Assign(Target);
BinFile.Delete;
BinFile.CreateNew;
BinFile.BlockWrite2(PChar(Stub), Length(Stub));
BinFile.Close;
Result := True;
finally
BinFile.Free;
end;
end;
procedure CreateExe(FileName : String; Stub : String);
var
Config : TStringList;
Chopper : TStringList;
i : Integer;
Target : String;
DiskName : String;
Line : String;
Data : String;
ZData : String;
TotalSize : Integer;
Checksum : String;
NameList : TStringList;
DataList : TStringList;
begin
Config := TStringList.Create;
NameList := TStringList.Create;
DataList := TStringList.Create;
TotalSize := 0;
try
Config.LoadFromFile(FileName);
if Config.Count > 0 then
begin
Target := ChangeFileExt(FileName, '.exe');
if not CopyStub(Target, Stub) then
begin
Log('Can''t load stub resource. Try using --stub');
exit;
end;
for i := 1 to Config.Count - 1 do
begin
Line := Trim(Config[i]);
if Length(Line) > 0 then
begin
Chopper := TStringList.Create;
try
Chopper.CommaText := Config[i];
if Chopper.Count = 4 then
begin
if FileExists(Chopper[0]) then
begin
Log('Loading ' + Chopper[0]);
Data := LoadDiskFile(Chopper[0]);
Checksum := MD5Print(MD5String(Data));
ZData := '';//ZCompressStr(Data, zcMax);
DiskName := 'DISK' + IntToStr(i);
Chopper.Add(DiskName);
Chopper.Add(Checksum);
NameList.Add(DiskName);
DataList.Add(ZData);
TotalSize := TotalSize + Length(ZData);
Config[i] := Chopper.CommaText;
end
else
begin
Log('File not found ' + Chopper[0] + ' on line ' + IntToStr(i + 1));
end;
end
else
begin
Log('Wrong number of arguements for line ' + IntToStr(i + 1));
end
finally
Chopper.Free;
end;
end;
end;
// we could compress the config info but it makes it hard to debug
//DataList.Add(ZCompressStr(Config.Text, zcMax));
NameList.Add('DISKINFO');
DataList.Add(Config.Text);
SaveDiskResource(Target, NameList, DataList);
end;
finally
Config.Free;
end;
Log('Compressed payload size is ' + IntToStr(TotalSize) + ' bytes');
end;
function StartsWith(S : String; Start : String; var Value : String) : Boolean;
var
p : Integer;
begin
p := Pos(Start, S);
if p = 1 then
begin
Result := True;
Value := Copy(S, p + Length(Start), Length(S));
end
else
begin
Result := False;
end;
end;
function EndsWith(S : String; Ends : String; var Value : String) : Boolean;
begin
if Copy(S, Length(S) - Length(Ends) + 1, Length(Ends)) = Ends then
begin
Result := True;
Value := Copy(S, 1, Length(S) - Length(Ends));
end
else
begin
Result := False;
end;
end;
{$IFDEF WINDOWS}
function GetSize(h : THandle) : Int64;
var
NewDevice : String;
NewOffset : Int64;
NewLength : Int64;
begin
if GetDiskExtents(h, NewDevice, NewOffset, NewLength) then
begin
Result := NewLength;
end
else
begin
Result := GetPartitionSize(h);
end;
if Result = 0 then
begin
Result := GetDiskSize(h);
end;
end;
procedure DoDD(InFile : String; OutFile : String; BlockSize : Int64; Count : Int64; Skip : Int64; Seek : int64; NoTruncateOut : Boolean; StopType : Boolean; Callback : ProgressEvent);
var
InBinFile : TBinaryFile;
OutBinFile : TBinaryFile;
InSize : Int64;
OutSize : Int64;
ThisBlock : Int64;
MagicZero : Boolean;
MagicRandom : Boolean;
StdOut : Boolean;
MagicNull : Boolean;
(*
In95Disk : T95Disk;
Out95Disk : T95Disk;
Out95SectorCount : LongInt;
*)
Value : String;
h : THandle;
Actual : DWORD;
Actual2 : DWORD;
Buffer : String;
i : Integer;
FullBlocksIn : Int64;
HalfBlocksIn : Int64;
FullBlocksOut : Int64;
HalfBlocksOut : Int64;
BytesOut : Int64;
StdinSkip : Int64;
begin
// Log('InFile = ' + InFile);
// Log('OutFile = ' + OutFile);
// Log('BlockSize = ' + IntToStr(BlockSize));
// Log('Count = ' + IntToStr(Count));
// Log('Skip = ' + IntToStr(Skip));
// Log('Seek = ' + IntToStr(Seek));
FullBlocksIn := 0;
HalfBlocksIn := 0;
FullBlocksOut := 0;
HalfBlocksOut := 0;
BytesOut := 0;
InBinFile := nil;
InSize := 0;
OutBinFile := nil;
OutSize := 0;
(* In95Disk := nil;
Out95Disk := nil;
Out95SectorCount := 0;
*)
MagicZero := False;
MagicRandom := False;
StdOut := False;
MagicNull := False;
// open the files....
InBinFile := TBinaryFile.Create;
try
if (InFile = '/dev/zero') or (InFile = 'DEVZERO') then
begin
MagicZero := True;
end
else if InFile = '/dev/random' then
begin
MagicRandom := True;
randomize_MT19937;
end
else if InFile = '-' then
begin
h := GetStdHandle(STD_INPUT_HANDLE);
if h <> INVALID_HANDLE_VALUE then
begin
InBinFile.AssignHandle(h);
end
else
begin
ShowError('native opening standard input');
exit;
end;
end
else if StartsWith(InFile, '\\:\', Value) then
begin
// a resource name
Log('NYI Reading DISK ' + Value);
exit;
end
else if StartsWith(InFile, '\\?\', Value) then
begin
// do a native open
Value := '\' + Value;
//Log('ntopen ' + Value);
h := NTCreateFile(PChar(Value), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, FILE_SHARE_READ);
if h <> INVALID_HANDLE_VALUE then
begin
InBinFile.AssignHandle(h);
if StopType then
begin
InSize := GetSize(h);
end;
end
else
begin
ShowError('native open input file');
exit;
end;
end
else
begin
// winbinfile it
// special 95 block device access
if (Length(InFile) = 2) and (InFile[2] = ':') then
begin
Log('read 95 disk NYI');
end;
//Log('open ' + InFile);
InBinFile.Assign(InFile);
if not InBinFile.Open(OPEN_READ_ONLY) then
begin
ShowError('opening input file');
exit;
end;
end;
// skip over the required amount of input
if Skip > 0 then
begin
if InFile = '-' then
begin
// can't seek on stdin, we will just read it...
StdinSkip := Skip;
while StdinSkip > 0 do
begin
SetLength(Buffer, BlockSize);
Actual := InBinFile.BlockRead2(PChar(Buffer), BlockSize);
// error checking?
StdinSkip := StdinSkip - BlockSize;
end;
end
else
begin
InBinFile.Seek(Skip);
Log('skip to ' + IntToStr(InBinFile.GetPos));
end;
end;
// open the output file
try
if (Length(OutFile) = 2) and (OutFile[2] = ':') then
begin
Log('read from 95 disk is not supported in this version of dd');
(* Out95Disk := T95Disk.Create;
Out95Disk.SetDiskByName(OutFile);
Out95SectorCount := 0;*)
end
else
begin
OutBinFile := TBinaryFile.Create;
if OutFile = '/dev/null' then
begin
MagicNull := True;
end
else if OutFile = '-' then
begin
h := GetStdHandle(STD_OUTPUT_HANDLE);
if h <> INVALID_HANDLE_VALUE then
begin
OutBinFile.AssignHandle(h);
end
else
begin
ShowError('native opening standard output');
exit;
end;
end
else if StartsWith(OutFile, '\\?\', Value) then
begin
// Log('Native write NYI');
// do a native open
Value := '\' + Value;
//Log('ntopen ' + Value);
h := NTCreateFile(PChar(Value), GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, 0);
if h <> INVALID_HANDLE_VALUE then
begin
OutBinFile.AssignHandle(h);
if StopType then
begin
OutSize := GetSize(h);
end;
end
else
begin
ShowError('native opening file');
exit;
end;
end
else
begin
// winbinfile it
//Log('open ' + OutFile);
OutBinFile.Assign(OutFile);
if not OutBinFile.CreateNew then
begin
if not OutBinFile.Open(OPEN_WRITE_ONLY) then
begin
ShowError('opening output file');
exit;
end;
end;
end;
end;
// seek over the required amount of output
if Seek > 0 then
begin
if Assigned(OutBinFile) then
begin
if not MagicNull then
begin
OutBinFile.Seek(Seek);
end;
end
(*else if Assigned(Out95Disk) then
begin
Out95SectorCount := Seek div 512;
end*);
//Log('seek to ' + IntToStr(OutBinFile.GetPos));
end;
if Assigned(Callback) then
begin
Callback(BytesOut, Windows.GetLastError);
end;
// Manage the InSize and OutSize
// if we have one or the other, make sure we only use the mimimum
if StopType then
begin
if InSize > 0 then
begin
if (OutSize > 0) and (OutSize < InSize) then
begin
InSize := OutSize;
//Log('Clamping InSize at OutSize ' + IntToStr(OutSize));
end;
end
else if OutSize > 0 then
begin
// OutSize and no InSize
InSize := OutSize;
//Log('Forcing InSize to ' + IntToStr(OutSize));
end;
end;
i := 0;
while (i < Count) or (Count = -1) do
begin
ThisBlock := BlockSize;
if StopType and (InSize > 0) then
begin
// for USB devices, make sure we don't read past the end of the device
if Skip + ((i + 1) * BlockSize) > InSize then
begin
// we need to recuce the read size...
ThisBlock := InSize - (Skip + (i * BlockSize));
//Log('Trimming the last block from ' + IntToStr(BlockSize) + ' down to ' + IntToStr(ThisBlock));
if ThisBlock = 0 then
begin
break; // All done.
end;
end;
end;
//Log('Reading block ' + IntToStr(i) + ' len = ' + IntToStr(BlockSize));
SetLength(Buffer, ThisBlock);
if MagicZero then
begin
if i = 0 then
begin
FillMemory(PChar(Buffer), ThisBlock, 0);
end;
Actual := ThisBlock;
end
else if MagicRandom then
begin
FillBuffer_MT19937(PChar(Buffer), ThisBlock);
Actual := ThisBlock;
end
else
begin
Actual := InBinFile.BlockRead2(PChar(Buffer), ThisBlock);
end;
//Log('actual = ' + IntToStr(Actual));
if Actual = BlockSize then
begin
FullBlocksIn := FullBlocksIn + 1;
end
else if Actual > 0 then // many USB devices don;t support this...
begin
HalfBlocksIn := HalfBlocksIn + 1;
end
else
begin
if Windows.GetLastError > 0 then
begin
if Windows.GetLastError = 109 then
begin
// End of pipe
end
else
begin
ShowError('reading file');
end;
end;
break;
end;
// write the output...
//Log('Writing block ' + IntToStr(i) + ' len = ' + IntToStr(Actual));
if assigned(OutBinFile) then
begin
if MagicNull then
begin
Actual2 := Actual;
end
else
begin
Actual2 := OutBinFile.BlockWrite2(PChar(Buffer), Actual);
if (Actual2 = 0) and (Actual <> BlockSize) then
begin
if Windows.GetLastError = 87 then
begin
// non aligned writes don't work on block devices...
// round up and try again
FillMemory(PChar(Buffer) + Actual, BlockSize - Actual, 0);
Actual2 := OutBinFile.BlockWrite2(PChar(Buffer), BlockSize);
if Actual2 = BlockSize then
begin
Actual2 := Actual;
end;
end;
end;
end;
end
(*else if assigned(Out95Disk) then
begin
if Out95Disk.WriteSector(Out95SectorCount, PChar(Buffer), Actual div 512) then
begin
Actual2 := Actual;
Out95SectorCount := Out95SectorCount + (Actual div 512);
end
else
begin
Actual2 := 0;
end;
end*)
else
begin
// no device to write to... must be an error
Actual2 := 0;
end;
if Actual2 = Actual then
begin
// full write
if Actual2 = BlockSize then
begin
FullBlocksOut := FullBlocksOut + 1;
end
else
begin
HalfBlocksOut := HalfBlocksOut + 1;
end;
end
else if Actual2 > 0 then
begin
// partial write
// this is half of a half, what do we call that???
HalfBlocksOut := HalfBlocksOut + 2; // ??
end
else
begin
if Windows.GetLastError > 0 then
begin
ShowError('writing file');
if Assigned(Callback) then
begin
if Callback(BytesOut, Windows.GetLastError) then
begin
break;
end;
end;
end;
break;
end;
BytesOut := BytesOut + Actual2;
if Assigned(Callback) then
begin
if Callback(BytesOut, 0) then
begin
break;
end;
end;
if ThisBlock < BlockSize then
begin
break;
end;
i := i + 1;
// Log(Buffer);
end;
if Assigned(Callback) then
begin
Log('');
end;
Log(IntToStr(FullBlocksIn) + '+' + IntToStr(HalfBlocksIn) + ' records in');
Log(IntToStr(FullBlocksOut) + '+' + IntToStr(HalfBlocksOut) + ' records out');
finally
if Assigned(OutBinFile) then
begin
OutBinFile.Free;
end;
end;
finally
if Assigned(InBinFile) then
begin
InBinFile.Free;
end;
end;
end;
{$ELSE}
procedure DoDD(InFile : String; OutFile : String; BlockSize : Int64; Count : Int64; Skip : Int64; Seek : int64; NoTruncateOut : Boolean; StopType : Boolean; Callback : ProgressEvent);
begin
end;
{$ENDIF}
{$IFDEF WINDOWS}
function GetDriveStrings(StringList : TStringList) : Boolean;
var
Error : DWORD;
Buffer : String;
i : DWORD;
S : String;
DriveType : UINT;
begin
SetLength(Buffer, 4096);
Error := GetLogicalDriveStrings(Length(Buffer), PCHAR(Buffer));
if Error = 0 then
begin
Result := false;
exit;
end;
SetLength(Buffer, Error);
S := '';
i := 1;
while i <= Error do
begin
if Buffer[i] = #0 then
begin
DriveType := GetDriveType(PCHAR(S));
StringList.AddObject(S, TObject(DriveType));
S := '';
end
else
begin
S := S + Buffer[i];
end;
i := i + 1;
end;
Result := True;
end;
// Pass in the drive type as returned by GetDriveStrings or GetDriveType
function GetDriveTypeDescription(DriveType : Integer) : String;
begin
case DriveType of
DRIVE_UNKNOWN: Result := 'drive type cannot be determined';
DRIVE_NO_ROOT_DIR: Result := 'no volume mounted';
DRIVE_REMOVABLE: Result := 'removeable media';
DRIVE_FIXED: Result := 'fixed media';
DRIVE_REMOTE: Result := 'network drive';
DRIVE_CDROM: Result := 'CD-ROM';
DRIVE_RAMDISK: Result := 'RAM disk';
else
Result := 'Unknown';
end;
end;
{$ELSE}
function GetDriveStrings(StringList : TStringList) : Boolean;
begin
StringList.Add('/');
Result := True;
end;
function GetDriveTypeDescription(DriveType : Integer) : String;
begin
Result := 'Fileststem';
end;
{$ENDIF}
{
boot.img,x86 boot disk,For CD install where booting from CD is not supported,TRUE
boot_drv.img,x86 driver disk,Extra drivers for x86 boot disk,FALSE
bootnet.img,x86 network boot disk,For Network installs,FALSE
}
end.