This repository has been archived by the owner on Mar 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
genav.pas
505 lines (463 loc) · 12 KB
/
genav.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
{
Name : GENAV 1.02f
Purpose : Generic Anti-Virus
Coder : SSG
Update info:
------------
Version 1.01
6th Aug 94 - 20:35 - La conversione de la Englissione texte due tue
Turkisce goode...
6th Aug 94 - 21:06 - Added critical error handler...
7th Aug 94 - 18:32 - Added X1 support...
7th Aug 94 - 19:34 - Added BarGraph to show percentage...
7th Aug 94 - 20:05 - Added command line parameters...
7th Aug 94 - 20:10 - Added Cascade-1661 support...
Version 1.02
8th Aug 94 - 22:19 - Added TVision support...
22nd Aug 94 - 00:01 - Added Mumcu support...
(Damn this xvhc! I've overwritten genav.pas!)
(Fortunately, my backups were new)
22nd Aug 94 - 00:15 - When cleaning Mumcu, first three bytes of COM
are not recovered... Fixed this bug..
16th Nov 94 - 00:51 - Recompiled with new FatalVision...
13th Dec 94 - 21:37 - Recompiled with newer FatalVision...
21nd May 96 - 16:02 - Removing TV support...
}
uses
ATB,Mirage,X1,X2,X3,C1661,Mumcu,TaiPan,
Dos,Drivers,XProtect,XVir;
const
gVersion = '1.03e';
cmScan = 56905;
cmClean = 56906;
cmAbout = 56907;
cmScanFile = 56908;
gmDestroyed : string[20] = 'Virs yok edildi';
gmNA : string[20] = 'Virs yok edilemedi';
Ctx_Help = hcNoContext;
type
PInfoWindow = ^TInfoWindow;
TInfoWindow = object(Tools.TDialog)
Topic : PTopic;
constructor Init;
procedure ChangeBounds(var R:TRect);virtual;
end;
PVirusCollection = ^TVirusCollection;
TVirusCollection = object(TCollection)
procedure FreeItem(Item:Pointer);virtual;
end;
TMain = object(TSystem)
HL : PInfoWindow;
constructor Init;
destructor Done;virtual;
function CheckMem:boolean;
function GetScanFileName:FNameStr;
procedure HandleEvent(var Event:TEvent);virtual;
end;
PInfo = ^TInfo;
TInfo = record
Scanning : string[40];
Scanned,
Infected,
Repaired : longint;
end;
PStatWindow = ^TStatWindow;
TStatWindow = object(GView.TWindow)
Graph : PBarGraph;
constructor Init(Ahdr:string);
end;
var
VirusList : PVirusCollection;
ParamScan : boolean;
DriveScan : boolean;
constructor TInfoWindow.Init;
var
R:TRect;
R1:TRect;
begin
R.Assign(0,0,400,250);
inherited Init(R,'Bilgi Bankasi');
Options := Options or Ocf_Centered or Ocf_ReSize;
GetVisibleBounds(R);
R.Move(-r.a.x,-r.a.y);
New(Topic,Init(R,0));
Insert(Topic);
end;
procedure TInfoWindow.ChangeBounds;
begin
Lock;
inherited ChangeBounds(R);
GetVisibleBounds(R);
Topic^.ChangeBounds(R);
UnLock;
end;
constructor TStatWindow.Init(AHdr:string);
var
R:TRect;
begin
R.Assign(0,0,0,0);
inherited Init(R,AHdr);
Options := Options and not Ocf_ReSize;
InsertBlock(GetBlock(5,5,mnfVertical+mnfNoSelect,
NewInputItem ('Dosya ad ',40,Idc_StrDefault,
NewNInputItem('Kontrol edilenler ',12,Stf_Longint,12,0,0,
NewNInputItem('Virsl dosyalar ',12,Stf_Longint,12,0,0,
NewNInputItem('Onarlan dosyalar ',12,Stf_Longint,12,0,0,
NIL))))));
FitBounds;
GetVisibleBounds(R);
R.Grow(-5,-5);
R.Move(-r.a.x,-r.a.y);
R.A.X := 253;
R.A.Y := 21;
New(Graph,Init(R,0,0));
Insert(Graph);
end;
procedure TVirusCollection.FreeItem;
begin
Dispose(PVirus(Item),Done);
end;
function TMain.CheckMem;
var
n:integer;
P:PWindow;
Graph:PBarGraph;
R:TRect;
PV:PVirus;
begin
CheckMem := false;
R.Assign(0,0,0,0);
New(P,Init(R,'Hafza Taranyor'));
R.Assign(0,0,320,60);
R.Move(5,5);
Graph := New(PBarGraph,Init(R,VirusList^.Count-1,0));
P^.Insert(Graph);
P^.Options := P^.Options or Ocf_Centered and not (Ocf_Close+Ocf_ReSize);
P^.FitBounds;
Insert(P);
for n := 0 to VirusList^.Count - 1 do begin
PV := PVirus(VirusList^.At(n));
if PV^.InMem then begin
MessageBox(^C+PV^.GetName+' virs hafzada bulundu'#13+
^C'Programdan ‡kt§nzda tekrar bulaŸabilir'#13+
^C'Program temiz bir sistem disketinden ‡alŸtrn',0,mfWarning);
exit;
end;
Graph^.Update(VirusList^.Count-1,n);
end;
Dispose(P,Done);
CheckMem := True;
end;
procedure InitViruses;
procedure Install(P:PVirus);
begin
VirusList^.Insert(P);
end;
begin
New(VirusList,Init(10,10));
Install(New(PMirage,Init));
Install(New(PATB,Init));
Install(New(PMumcu,Init));
Install(New(PX1,Init));
Install(New(PX2,Init));
Install(New(PX3,Init));
Install(New(PC1661,Init));
Install(New(PTaiPan,Init));
end;
constructor TMain.Init;
var
P:PMenuBar;
R:TRect;
begin
asm
mov ax,3
int 10h
end;
writeln('GenAv '+gVersion+' - (c) 1994..1996 SSG'#13#10);
InitCRH;
InitHelpSystem('GENAV');
inherited Init;
SetSysPalette;
if XIsParam('NOMEM') = 0 then begin
if not CheckMem then begin
Done;
writeln('Temiz bir sistem disketinden a‡may unutmayn...');
halt(1);
end;
end;
GetExtent(R);
New(P,Init(R,NewMenu(
NewSubMenu('~GenAv',
NewMenu(
NewItem('~Sadece virs ara',cmScan,
NewItem('~Virs ara ve buldu§unda yoket',cmClean,
NewItem('Tek ~dosyay ara',cmScanFile,
NewLine(
NewItem('~Program hakknda',cmAbout,
NewLine(
NewItem('~€kŸ',XTypes.cmQuit,NIL)
))))))),
NIL))));
Insert(P);
if ParamScan then Message(@Self,evCommand,cmScanFile,nil) else if
DriveScan then Message(@Self,evCommand,cmScan,nil);
end;
destructor TMain.Done;
begin
DoneCRH;
Dispose(VirusList,Done);
inherited Done;
end;
function TMain.GetScanFileName:FNameStr;
begin
if not XFileExists(ParamStr(1)) then GetScanFileName := ExecuteFileDialog('*.EXE','Dosya Se‡imi','Dosya ad')
else GetScanFileName := ParamStr(1);
end;
procedure TMain.HandleEvent;
var
Info:TInfo;
iw:PStatWindow;
Graph:PBarGraph;
AHdr:String;
Clean:boolean;
Cancelled:boolean;
totaldirs:longint;
currentdir:longint;
type
TProc = procedure(S:FNameStr);
procedure ScanDisk(S:FNameStr);
var
dirinfo:SearchRec;
Attr:word;
F:File;
T:TDosStream;
procedure SubOfSub;
var
n:integer;
PV:PVirus;
begin
if Cancelled then exit;
Assign(F,S+dirinfo.name);
GetFAttr(F,Attr);
SetFAttr(F,Archive);
T.Init(S+dirinfo.name,stOpen);
Info.Scanning := S+dirinfo.name;
iw^.SetData(Info);
for n:=0 to VirusList^.Count-1 do begin
PV := VirusList^.At(n);
if PV^.Scan(T) then begin
MessageBox(^C+PV^.GetName+' virs'+#13#3+
S+dirinfo.name+' isimli dosyada bulundu',0,mfWarning);
inc(Info.Infected);
if Clean then case PV^.Clean(T) of
True : begin
MessageBox(^C+gmDestroyed,0,mfInfo);
inc(Info.Repaired);
end;
False : MessageBox(^C+gmNA,0,mfWarning);
end;
end;
end;
if keypressed then if readkey = #27 then
if MessageBox(^C'˜Ÿlemi iptal etmek istiyor musunuz?',0,mfYesNo+mfConfirm) = cmYes then
Cancelled := true;
inc(Info.Scanned);
iw^.SetData(Info);
T.Done;
SetFAttr(F,Attr);
end;
begin
if Cancelled then exit;
FindFirst(S+'*.COM',Archive+ReadOnly+Hidden+SysFile,dirinfo);
while DosError = 0 do begin
SubOfSub;
FindNext(dirinfo);
end;
FindFirst(S+'*.EXE',Archive+ReadOnly+Hidden+SysFile,dirinfo);
while DosError = 0 do begin
SubOfSub;
FindNext(dirinfo);
end;
end;
procedure ForEachDir(S:FNameStr);
var
dirinfo:SearchRec;
begin
if Cancelled then exit;
inc(currentdir);
iw^.Graph^.Update(totaldirs,currentdir);
ScanDisk(S);
FindFirst(S+'*.*',Directory+Hidden,dirinfo);
while DosError = 0 do begin
if (dirinfo.name[1] <> '.') and (dirinfo.attr and directory > 0)
then ForEachDir(S+dirinfo.name+'\');
FindNext(dirinfo);
end;
end;
function GetDrive:byte;
var
P:PDialog;
View:PView;
R:TRect;
b:byte;
code:word;
procedure PutDrive(c:char);
begin
View := New(PButton,Init(R.A.x,r.a.y,'~'+c+':',cmOK));
View^.GetBounds(R);
R.A.X := R.B.X + 5;
P^.Insert(View);
end;
begin
GetDrive := 255;
R.Assign(0,0,0,0);
New(P,Init(R,'Src Se‡imi'));
P^.Options := P^.Options or Ocf_Centered;
r.a.y := 5;
r.a.x := 5;
for b:=0 to GetDDC-1 do PutDrive(char(b+65));
P^.Insert(New(PButton,Init(R.A.x,r.a.y,'Vazge‡',cmCancel)));
P^.FitBounds;
P^.SelectNext(True);
code := ExecView(P);
if code = cmOK then GetDrive := byte(PButton(P^.Current)^.Text^[1])-65;
Dispose(P,Done);
end;
procedure SubScan(path:FNameStr);
var
dirinfo:SearchRec;
begin
inc(totaldirs);
FindFirst(path+'*.*',Directory+Hidden,dirinfo);
while DosError = 0 do begin
if (dirinfo.name[1] <> '.') and (dirinfo.attr and directory > 0) then SubScan(path+dirinfo.name+'\');
FindNext(dirinfo);
end;
end;
procedure Off;
var
drive:char;
s:string[1];
begin
currentdir := 0;
s := ParamStr(1);
if DriveScan then drive := upcase(s[1])
else drive := char(GetDrive+65);
if drive = #255 then exit;
StartJob('Directory''ler okunuyor');
totaldirs := 0;
SubScan(drive+':\');
EndJob;
New(iw,Init(AHdr));
iw^.Options := (iw^.Options and not (Ocf_ReSize+Ocf_Close)) or Ocf_Centered;;
Insert(iw);
FillChar(Info,SizeOf(Info),0);
Cancelled := false;
ForEachDir(drive+':\');
MessageBox(^C'˜Ÿlem tamamland',0,mfInfo);
Dispose(iw,Done);
if DriveScan then begin
Done;
Halt;
end;
end;
procedure DamnedScan;
begin
AHdr := 'Taranyor';
Clean := false;
Off;
end;
procedure DamnedClean;
begin
AHdr := 'Temizleniyor';
Clean := true;
Off;
end;
procedure About;
begin
MessageBox(^C'GenAv'#13+
^C'Version '+gVersion+#13#32#13+
^C'Program'#13+
^C'Sedat Kapano§lu'#13#32#13+
^C'FatalVision'#13+
^C'Sedat Kapano§lu'#13+
^C'Meri‡ žentunal'#13#32#13+
^C'(c) 1994 K.I.S.S.',0,mfInfo);
end;
procedure ScanFile;
var
f:FNameStr;
T:TDosStream;
PV:PVirus;
n:integer;
found:boolean;
begin
f := GetScanFileName;
if f = '' then exit;
T.Init(f,stOpen);
found := false;
for n:=0 to VirusList^.Count-1 do begin
PV := VirusList^.At(n);
if PV^.Scan(T) then begin
found := true;
if MessageBox(^C+'Dosyada '+PV^.GetName+' virs bulundu'#13+
^C'Virs yok etmek istiyor musunuz?',0,mfConfirm+mfYesNo) = cmYes then
begin
if PV^.Clean(T) then MessageBox(^C+gmDestroyed,0,mfInfo)
else MessageBox(^C+gmNA,0,mfWarning);
end;
end;
end;
if not found then MessageBox(^C'Dosyada herhangi bir virse rastlanmad',0,mfInfo);
T.Done;
if ParamScan then begin
Done;
Halt;
end;
end;
begin
if Event.What = evCommand then if
Event.Command = cmHelp then if HelpOK then begin
if HL = NIL then begin
New(HL,Init);
HL^.HelpContext := Ctx_Help;
ExecView(HL);
if HL <> NIL then Dispose(HL,Done);
HL := NIL;
end else
if Current <> PView(HL) then HL^.Select;
end;
inherited HandleEvent(Event);
case Event.What of
evCommand : case Event.Command of
cmScan : DamnedScan;
cmScanFile : ScanFile;
cmClean : DamnedClean;
cmAbout : About;
end;
evKeyDown : case Event.KeyCode of
kbF1 : Message(@Self,evCommand,cmHelp,NIL);
kbF2 : DamnedScan;
kbF3 : DamnedClean;
end;
end;
end;
var
T:TMain;
s:string[1];
begin
if (not EXEOK) and (XIsParam('DEVPARM') = 0) then begin
writeln('GenAv bozuk...');
halt(1);
end;
if XIsParam('?') > 0 then XAbort('Usage: GENAV [drive|filename] [/NOMEM]');
ParamScan := XFileExists(ParamStr(1));
if (not ParamScan) and (ParamCount > 0) then begin
s := ParamStr(1);
DriveScan := (s <> '-') and (s <> '/');
end else DriveScan := false;
InitViruses;
T.Init;
T.Run;
T.Done;
end.