-
Notifications
You must be signed in to change notification settings - Fork 1
/
OSSYSTEM.PAS
1565 lines (1425 loc) · 53.9 KB
/
OSSYSTEM.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
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{************************************************}
{ }
{ Operating System / Memory Specific Routines }
{ Carl Eric Codere }
{ Montreal, Canada }
{ VERSION 2.00 }
{************************************************}
{ UNIT MAX HEAP USAGE: 000000 BYTES }
{************************************************}
(* Copyright (C) 1996 Carl Eric Codere *)
(* All rights reserved. (This is not freeware) *)
(* - you have the right to modify this source code as long as I it is not *)
(* re-released in source code form. *)
(* - for commercial use of this code, you must contact me *)
(* - no re-release of this source code can be done without my cosent *)
(* -> There is no warranty whatsoever that this program will not kill *)
(* -> your computer, even though it has been tested successfully on three *)
(* -> PC's *)
(* Contact me at: carl.codere@evening.magicnet.com *)
(* From 1995-1998 you can also contact me at: *)
(* cecodere@andrew.sca.usherb.ca (preferred) *)
Unit OSSystem;
(* Operating System / Shell Specific Code. Detects type of Multitasker *)
(* at startup. Also detects if TAME is loaded at Startup. *)
(* . *)
(**************************************************************************)
(* Tested under the following Shells/Operating Systems: *)
(* Novell using Windows 3.11 for Workgroups *)
(* Desqview *)
(* Tame *)
(* Windows 3.1 *)
(* DOS and NDOS / real and protected modes. *)
(* Windows'95 using Novell and Ndos as primary shell *)
(**************************************************************************)
{$IFDEF WINDOWS}
ERROR: This Program must Run Under the DOS Platform.
{$ENDIF}
{$IFNDEF CPU86}
ERROR: This Program Requires a x86 Machine.
{$ENDIF}
{$IFNDEF VER70}
ERROR: This program uses TP v7.0 syntax
{$ENDIF}
{$O-} (* Unit Cannot be overlaid *)
Interface
{$IFDEF DPMI}
Uses Objects, WinAPI, DOS;
{$ELSE}
Uses Objects, DOS;
{$ENDIF}
(*************************************************************************)
(* TESTSHELL POSSIBLE VALUES *)
(*************************************************************************)
Const
ShellNone = $00; (* Running under COMMAND.COM *)
ShellNDos = $01; (* Running NDOS/4DOS Shell *)
ShellNovell = $02; (* Running Novell Network under COMMAND*)
ShellNDosNovell = $03; (* Running Novell + NDOS / 4DOS *)
(*************************************************************************)
(* TESTOS POSSIBLE VALUES *)
(*************************************************************************)
(* THESE WILL AFFECT MULTITASKING ABILITIES *)
OSNone = $00; (* Running Under DOS / DOS 5.0+ or true clone *)
OSOS2 = $01; (* Running Under OS/2 Version 2.x *)
OSWindows = $02; (* Running Under Windows/386 *)
OSDesqview = $03; (* Running Desqview / Topview *)
OSDoubleDos = $04; (* Running DoubleDOS *)
OSCPMDOS = $05; (* Running Concurrent DOS MultiUser *)
OSDPMI = $06; (* Running DPMI Host V1.0+ *)
OSNT = $07; (* Running under Windows NT *)
(* THESE MUST BE PUT BY HAND IN TESTOS - NOT DETECTED *)
OSMultiLink = $20; (* Not Detect by Detect Shell Routine *)
OSOmniview = $21; (* Not Detected By Detect Shell Routine *)
OSMultiDos = $22; (* Not Detected By Detect Shell Routine *)
OSPCMOS386 = $23; (* Not Detected By Detect Shell Routine *)
(*************************************************************************)
(* GLOBAL SYSTEM VARIABLES *)
(*************************************************************************)
VAR
TestDPMI: Word; { Returns DPMI Version, 0000 if not running DPMI }
TestXMS: Word; { Returns XMS Version, 0000 if not running XMS }
TestEMS: Word; { Returns EMS Version, 0000 if not running EMS }
TestShell: Byte; { TYPE OF SHELL RUNNING - See Above }
TestOS: Byte; { TYPE OF OS RUNNING - See Above }
TestTame: Boolean; { TRUE if TAME is Running }
(*************************************************************************)
(* MultiTasking Objects *)
(*************************************************************************)
(* PROCEDURE GiveTimeSlice: Gives The Rest of the Time Slice to the OS. *)
(* PROCEDURE BeginCritical: Stops Task-Swtiching until EndCritical called*)
(* PROCEDURE EndCritical: Starts Task-switching again *)
(* CONSTRUCTOR Init: Presently Does Nothing. *)
(* DESTRUCTOR Done: Presently Does Nothing *)
(*************************************************************************)
TYPE
(* This Object which is also the base object should be used when *)
(* the following is detected: OS/2, PC-MOS/386, DOS 5.00 and later *)
(* Can also be called by DOS which is below ver 5.00, but will do *)
(* nothing. *)
PMultiTask = ^TMultiTask;
TMultiTask = Object
Universal: Boolean; { Is the universal Give Time slice proc supported }
Constructor Init;
Procedure GiveTimeSlice; Virtual;
Procedure BeginCritical; Virtual;
Procedure EndCritical; Virtual;
Destructor Done; Virtual;
end;
(* Should be called under MultiDOS - WHICH IS NOT DETECTED AT STARTUP *)
PMultiDos = ^TMultiDOS;
TMultiDOS = Object(TmultiTask)
Constructor Init;
Procedure GiveTimeSlice; Virtual;
Procedure BeginCritical; Virtual;
Procedure EndCritical; Virtual;
end;
(* Should be called under DoubleDOS *)
PDoubleDos = ^TDoubleDos;
TDoubleDOS = Object(TMultiTask)
Constructor Init;
Procedure GiveTimeSlice; Virtual;
Procedure BeginCritical; Virtual;
Procedure EndCritical; Virtual;
end;
(* Should be called under CSwitch - WHICH IS NOT DETECTED AT START UP *)
PCswitch = ^TCSwitch;
TCSwitch = Object(TMultiTask)
Constructor Init;
Procedure GiveTimeSlice; Virtual;
end;
(* Should be called under Multilink Advanced - NOT DETECTED AT START UP *)
PMultiLink = ^TMultiLink;
TMultiLink = Object(TMultiTask)
Constructor Init;
Procedure GiveTimeSlice; Virtual;
end;
(* Should be called by Real Mode applications under Windows Enhanced *)
Pwindows = ^TWindows;
TWindows = Object(TMultiTask)
Constructor Init;
Procedure GiveTimeSlice; Virtual;
Procedure BeginCritical; Virtual;
Procedure EndCritical; Virtual;
end;
(* Should be called when Running under Concurrent DOS MultiUser *)
PMultiUserDos = ^TMultiUserDos;
TMultiUserDOS = Object(TMultiTask)
Constructor Init;
Procedure GiveTimeSlice; Virtual;
end;
(* Should be called when Running under desqview / Topview / Taskview *)
PDesqview = ^TDesqview;
TDesqview = Object(TMultiTask)
Constructor Init;
Procedure GiveTimeSlice; Virtual;
Procedure BeginCritical; Virtual;
Procedure EndCritical; Virtual;
end;
(*********************************************************************)
(* PROTECTED MODE TYPES *)
(*********************************************************************)
LongRec = record
Selector, Segment : word;
end;
DoubleWord = record
Lo, Hi : word;
end;
QuadrupleByte = record
Lo, Hi, sLo, sHi : byte;
end;
TDPMIRegisters = record
EDI, ESI, EBP, Reserved, EBX, EDX, ECX, EAX : longint;
Flags, ES, DS, FS, GS, IP, CS, SP, SS : word;
end;
(*************************************************************************)
(* FUNCTION VerifyEMSPresent: Returns TRUE if EMS Driver Present in Mem *)
(* FUNCTION VerifyXMSPresent: Returns TRUE if XMS Driver Present in Mem *)
(* FUNCTION VerifyDPMIPresent: Returns TRUE if DPMI Driver Present in Mem *)
(* FUNCTION GetXMSVersion: Returns XMS Driver Version Number *)
(* FUNCTION GetDPMIVersion: Returns DPMI Driver Version Number *)
(* FUNCTION GetEMSVersion: Returns EMS Driver Version Number *)
(* FUNCTION DetectShell: Returns the Type of OS/ Shell Running *)
(* FUNCTION TameInstalled: Returns TRUE is Tame is present in memory *)
(*************************************************************************)
FUNCTION VerifyEMSPresent: Boolean; Far; { IN DPMI CHECKS IF DPMI EMS SERVER }
FUNCTION VerifyXMSPresent: Boolean; Far; { IN DPMI CHECKS IF DPMI XMS SERVER }
FUNCTION VerifyDPMIPresent: Boolean; Far; { PROTECTED/REAL MODES }
FUNCTION GetXMSVersion: Word; Far; { DPMI: GET XMS DPMI SERVER VERSION }
FUNCTION GetEMSVersion: Word; Far; { DPMI: GET EMS DPMI SERVER VERSION }
FUNCTION GetDPMIVersion: Word; Far; { PROTECTED/REAL MODES }
FUNCTION GetFreeEMS: Word; Far;
FUNCTION GetFreeXMS: Word; Far;
FUNCTION DetectShell: Word; { PROTECTED/REAL MODES }
FUNCTION TameInstalled: Boolean; { PROTECTED/REAL MODES }
(*********************************************************************)
(* PROTECTED MODE MEMORY MANAGEMENT ROUTINES. *)
(* RealModeInt -> Call a real mode interrupt via DPMI server. *)
(* IntNo -> Real mode interrupt to invoke *)
(* Regs -> Registers to use in calling interrupt. *)
(* UNUSED REGISTERS SHOULD BE SET TO ZERO! *)
(* XGlobalDOSAlloc -> Allocate some DOS memory (Real Seg:Ofs) *)
(* Returns word -> Segment of allocated memory block.(Real) *)
(* P: Pointer -> Selector:Offset of allocated block (Prot). *)
(* XGlobalDOSFree -> Free DOS Memory *)
(* P: Pointer -> Selector:Offset of allocated block to free *)
(*********************************************************************)
{$IFDEF DPMI}
Procedure RealModeInt(IntNo : word; var Regs : TDPMIRegisters);
function XGlobalDosAlloc(Size : longint; var P : Pointer) : word;
Procedure XGlobalDOSFree(Var P: Pointer);
{$ENDIF}
(* DOS Specific Procedures/Functions *)
Procedure MakeFileBackup(Const BackOn:Boolean;FName:FNameStr;Buf:Pointer;Size:Word);
(* Writes output to disk on FName, if BackOn is true, and if file alredy exists *)
(* then old file is renamed with a .BAK extension before be rewritten. *)
(* Writes everything from pointer of a size size bytes *)
Function GetAltKey:Boolean; (* Returns true if the Alt-Key is pressed *)
Function VerifyFilePresence(Const FName:FNameStr):Boolean;
(* Verifies if a file is present in a directory *)
Implementation
Const
API4DOS = $D44D;
APINDOS = $E44D;
TSRInterrupt = $2F;
Dos_Function = $21;
Function VerifyEMSPresent:Boolean;
(*********************************************************************)
(* FUNCTION VerifyEMSPresent: Boolean *)
(* *)
(* Returns TRUE if there is an EMS manager present in *)
(* memory. Otherwise returns False. *)
(* BTW THE Intr SHOULD CRASH ON A DPMI, SO WATCH OUT!!! *)
(*********************************************************************)
Var
Emm_Device_Name : string[8];
Int_67_Device_Name : string[8];
Position : integer;
Regs : registers;
EMSVector : Pointer;
Begin
Int_67_Device_Name := '';
Emm_Device_Name := 'EMMXXXX0';
with Regs do
Begin
{------------------------------------------------------}
{ Get the code segment pointed to by interrupt 67h, }
{ the EMM interrupt by using DOS function 35h. }
{ (get interrupt vector) }
{------------------------------------------------------}
GetIntVec($67, EMSVector);
For Position := 0 to 7 do
Int_67_Device_Name :=
Int_67_Device_Name+Chr(Mem[Seg(EMSVector^):Position+$0A]);
{------------------------------------------------------}
{ If the string is the EMM manager signature, }
{ 'EMMXXXX0', then EMM is installed and ready for }
{ use. If not, then EMM is not present. }
{------------------------------------------------------}
If Int_67_Device_Name = Emm_Device_Name
then VerifyEMSPresent := True
Else VerifyEMSPresent := False
end; { with Regs do }
End;
Function VerifyXMSPresent:Boolean;Assembler;
(*********************************************************************)
(* FUNCTION VerifyXMSPresent: Boolean *)
(* *)
(* Returns TRUE if there is an XMS Driver in memory, *)
(* otherwise returns FALSE. *)
(*********************************************************************)
ASM
MOV AX,4300h; { AX = 4300h to Call Function }
INT 2Fh; { Call Function: XMS Driver Install Check }
CMP AL,80h; { If AL = 80h then Driver is Present }
JNZ @Nope; { ZF = 0 so AL <> 80h JMP To Label }
MOV AL, TRUE ; { Function = TRUE, Driver is Present }
RET (* No Parameters, Direct Return from PROC *)
@Nope:
XOR AL,AL; { Function = FALSE, Driver is Not Present }
RET (* No Parameters, Direct Return From PROC *)
end;
{$IFNDEF DPMI}
Function VerifyDPMIPresent: Boolean; Assembler;
(*********************************************************************)
(* FUNCTION VerifyDPMIPresent: Boolean; *)
(* *)
(* Returns TRUE if a DPMI server is Present in memory, *)
(* otherwise returns FALSE. *)
(*********************************************************************)
ASM
MOV AX, 1687h
INT 2Fh
CMP AX, 0000h
JNE @NoDPMI ; (* If AX <> 0000 then NO DPMI Server *)
MOV AL, TRUE
RET
@NoDPMI:
MOV AL, FALSE
RET
end;
{$ELSE}
(*********************************************************************)
(* FUNCTION VerifyDPMIPresent: Boolean; *)
(* *)
(* Returns TRUE. IN PROTECTED MODE APPLICATIONS, THERE MUST BE *)
(* A DPMI SERVER, OTHERWISE THE PROGRAM WILL NOT RUN! *)
(*********************************************************************)
FUNCTION VerifyDPMIPresent: Boolean; Assembler;
ASM
MOV AL, 01h
end;
{$ENDIF}
{$IFNDEF DPMI}
(*************************************************************************)
(* FUNCTION GetDPMIVersion: Word *)
(* Returns the version of the DPMI Server *)
(* *)
(* Returns HIGH BYTE = MAJOR DPMI Version *)
(* Returns LOW BYTE = MINOR DPMI Version *)
(* Returns 0000 if DPMI not installed. *)
(*************************************************************************)
Function GetDPMIVersion: Word; Assembler;
ASM
MOV AX, 1687h ; { Prepare Interrupt service routine }
INT 2Fh ; { Call MultiPlex Interrupt }
CMP AX, 0000h ; { If AX = 0000h then DPMI installed }
JNE @NoDPMI
{ Nil } ; { Version stored in DX }
MOV AX, DX ; { Put Result into AX (Function Result }
RET ; { Return from procedure }
@NoDPMI: ; { No DPMI Installed }
MOV AX, 0000h ; { Result of Function is zero }
RET ; { Return from procedure }
end;
{$ELSE}
(*************************************************************************)
(* FUNCTION GetDPMIVersion: Word *)
(* Returns the version of the DPMI Server *)
(* *)
(* Returns HIGH BYTE = MAJOR DPMI Version *)
(* Returns LOW BYTE = MINOR DPMI Version *)
(* THIS IS FOR DPMI APPLICATIONS THEREFORE ALWAYS RETURNS VERSION *)
(*************************************************************************)
Function GetDPMIVersion: Word; Assembler;
ASM
MOV AX, 0400h ; { Prepare Interrupt service routine }
INT 31h ; { Call MultiPlex Interrupt }
{ Value is directly returned in AX }
end;
{$ENDIF}
(*************************************************************************)
(* FUNCTION GetXMSVersion: Word; *)
(* *)
(* Returns the Version of the XMS Server, 0000 if not installed. *)
(* *)
(* Returns HIGH BYTE = MAJOR XMS Version *)
(* Returns LOW BYTE = MINOR XMS Version *)
(*************************************************************************)
Function GetXMSVersion: Word; Assembler;
Var
Proc: Pointer;
ASM
MOV AX, 4300h ; { Set up interrupt service routine }
INT 2Fh
CMP AL, 80h ; { AL = 80h then XMS driver in mem }
JNE @NoXMSDriver ; { AL <> 80h , then no driver }
MOV AX, 4310h ; { Get entry point of XMS driver }
INT 2Fh
MOV WORD PTR [Proc], BX ; { ES:BX -> Entry point pointer }
MOV WORD PTR [Proc+2], ES
MOV AH, 00h ; { Set up Function Call XMS Version }
CALL [Proc] ; { Call Entry point driver }
{ Nil } ; { Version number stored in AX }
JMP @End
@NoXMSDriver:
MOV AX, 0000h ; { Function returns 0000, no driver }
JMP @End
@End:
end;
(*************************************************************************)
(* FUNCTION GetEMSVersion: Word; *)
(* *)
(* Returns the Version of the EMS Server, 0000 if not installed. *)
(* *)
(* Returns HIGH BYTE = MAJOR EMS Version *)
(* Returns LOW BYTE = MINOR EMS Version *)
(*************************************************************************)
Function GetEMSVersion: Word;
VAR
Regs: Registers;
TmpVal:Record
LLow: Byte;
LHi: Byte;
end;
Begin
If VerifyEMSPresent then
BEGIN
Regs.AH := $46;
Intr($67, Regs);
IF Regs.AH <> $00 THEN
BEGIN
GetEMSVersion := $00;
Exit;
END
ELSE
BEGIN
TmpVal.LLow := Regs.AL AND $0F;
TmpVal.LHi := (Regs.AL AND $F0) SHR 4;
GetEMSVersion:= Word(TmpVal);
END;
END
ELSE
GetEMSVersion := $0000;
end;
(*************************************************************************)
(* FUNCTION GetFreeEMS: Word; *)
(* *)
(* Returns the number Kilobytes that is still free in EMS. *)
(* *)
(*************************************************************************)
Function GetFreeEMS: Word;
Var
Value: Word;
Regs: Registers;
Begin
GetFreeEMS := 000;
Value := GetEMSVersion; (* This must be called to get EMS Version FIRST *)
(* since DOS 6.0 will CRASH in AUTO MODE if this *)
(* is not done. *)
If Value = $0000 then Exit; (* EMS not installed *)
ASM
MOV AH, 42h
INT 67h
CMP AH, 00h
JNE @Error
SHL BX, 1 ; (* Number of KBytes free: Pages * 16 *)
SHL BX, 1
SHL BX, 1
SHL BX, 1
MOV @Result, BX
@Error:
end;
end;
(*************************************************************************)
(* FUNCTION GetFreeXMS: Word; *)
(* *)
(* Returns the LARGEST XMS Free Block in XMS. *)
(* *)
(*************************************************************************)
Function GetFreeXMS: Word; Assembler;
Var
Proc: Pointer;
ASM
MOV AX, 4300h ; { Set up interrupt service routine }
INT 2Fh
CMP AL, 80h ; { AL = 80h then XMS driver in mem }
JNE @NoXMSDriver ; { AL <> 80h , then no driver }
MOV AX, 4310h ; { Get entry point of XMS driver }
INT 2Fh
MOV WORD PTR [Proc], BX ; { ES:BX -> Entry point pointer }
MOV WORD PTR [Proc+2], ES
MOV AH, 08h ; { Set up Function Call Get Memory }
CALL [Proc] ; { Call Entry point driver }
{ Nil } ; { Largest KByte Free stored in AX }
CMP BL, 80h ; { XMS Function Not implemented ERROR }
JE @NoXMSDriver
CMP BL, 81h ; { VDISK Detected ERROR }
JE @NoXMsDriver
CMP BL, 0A0h ; { No More XMS Memory ERROR }
JE @NoXMSDriver
JMP @End
@NoXMSDriver:
MOV AX, 0000h ; { Function returns 0000, no driver }
JMP @End
@End:
end;
{$IFDEF DPMI}
(*************************************************************************)
(* FUNCTION DetectShell: Word; *)
(* *)
(* This function returns the shell type presently running. *)
(* PROTECTED MODE VERSION. *)
(* LOW BYTE = Shell Type *)
(* HIGH BYTE = Operating System Type *)
(*************************************************************************)
Function DetectShell: Word;
(* Low Byte = Shell Type *)
(* High Byte = OS Type *)
Var
ShellVal: Byte; { Temporary storage of Shell Value }
Regs: TDPMIRegisters;
OS: Byte;
Begin
(***********************************************)
(* 4DOS / NDOS INSTALLATION CHECK *)
(***********************************************)
FillChar(Regs, SizeOf(Regs), #0);
Regs.EAX := Api4DOS;
Regs.EBX := $0000;
RealModeInt($2F, Regs);
If Regs.EAX = $44DD then
ShellVal := ShellNDos
else
ShellVal := ShellNone;
FillChar(Regs, SizeOf(Regs), #0);
Regs.EAX := ApiNDOS;
Regs.EBX := $0000;
RealModeInt($2F, Regs);
If Regs.EAX = $44EE then
ShellVal := ShellNDos;
(***********************************************)
(* NOVELL NET INSTALLATION CHECK *)
(***********************************************)
FillChar(Regs, SizeOf(Regs), #0);
Regs.EAX := $7A00;
RealModeInt($2F, Regs);
If QuadrupleByte(Regs.EAX).Lo = $FF then
Inc(ShellVal, ShellNovell);
(* We have to check for the following multitaskers: *)
(* - OS/2 Version 2.0+ *)
(* - Windows Enhanced Mode TESTED *)
(* - Desqview / TopView TESTED *)
(* - DoubleDos *)
(* - Protected Mode Server 1.0+ TESTED *)
(* - Concurrent DOS/ MultiUser Version *)
(***********************************************)
(* OS/2 VER 2+ INSTALLATION CHECK *)
(***********************************************)
FillChar(Regs, SizeOf(Regs), #0);
Regs.EAX := $4010;
RealModeInt($2F, Regs);
If Regs.EAX <> $4010 then
Begin
ASM
MOV AL, [ShellVal]
MOV AH, OSOs2
MOV [@Result], AX
end;
Exit;
end;
(************************************************)
(* WINDOWS/386 - Windows95/Windows98/WinMe *)
(* INSTALLATION CHECK *)
(************************************************)
FillChar(Regs, SizeOf(Regs), #0);
Regs.EAX := $1600;
RealModeInt($2F, Regs);
If NOT (QuadrupleByte(Regs.EAX).Lo in [$00, $80]) then
(* Neither Windows/386 2.x nor Windows/386 3 Running if IN AL = $00 *)
(* If AL = 80h then XMS Driver present, no windows if AL = $80 *)
{ Therefore the opposite tells us that Windows is running }
Begin
ASM
MOV AL, [ShellVal]
MOV AH, OSWindows
MOV [@Result], AX
end;
Exit;
end;
(***********************************************)
(* WINDOWS NT INSTALLATION CHECK *)
(***********************************************)
FillChar(Regs, SizeOf(Regs), #0);
Regs.EAX := $3306;
RealModeInt($21, Regs);
if (QuadrupleByte(Regs.EAX).Lo <> $ff) and (QuadrupleByte(Regs.EBX).Hi < 100) and
(QuadrupleByte(Regs.EBX).Lo >= 5) then
begin
if (QuadrupleByte(Regs.EBX).Hi = 50) and (QuadrupleByte(Regs.EBX).Lo = 5) then
begin
DetectShell:=(OSNT shl 8) or ShellVal;
exit;
end;
end;
(***********************************************)
(* DESQVIEW/TOPVIEW INSTALLATION CHECK *)
(***********************************************)
FillChar(Regs, SizeOf(Regs), #0);
Regs.EAX := $2B01;
Regs.ECX := $4445;
Regs.EDX := $5351;
RealModeInt($21, Regs);
If QuadrupleByte(Regs.EAX).Lo <> $FF then
(* If AL = FFh then Desqview is NOT loaded *)
Begin
ASM
MOV AL, [ShellVal]
MOV AH, OSDesqview
MOV [@Result], AX
end;
Exit;
end;
(* Check For Topview *)
FillChar(Regs, SizeOf(Regs), #0);
Regs.EAX := $1022;
Regs.EBX := $0000;
RealModeInt($15, Regs);
If Regs.EBX <> $0000 then
Begin
ASM
MOV AL, [ShellVal]
MOV AH, OSDesqview
MOV [@Result], AX
end;
Exit;
end;
(***********************************************)
(* DOUBLEDOS INSTALLATION CHECK *)
(***********************************************)
FillChar(Regs, SizeOf(Regs), #0);
Regs.EAX := $E400;
RealModeInt($21, Regs);
If QuadrupleByte(Regs.EAX).Lo <> 00 then
Begin
ASM
MOV AL, [ShellVal]
MOV AH, OSDoubleDOS
MOV [@Result], AX
end;
Exit;
end;
(***********************************************)
(* DPMI V1.0+ INSTALLATION CHECK *)
(***********************************************)
If Hi(GetDPMIVersion) >= 1 then
Begin
ASM
MOV AL, [ShellVal]
MOV AH, OSDPMI
MOV [@Result], AX
end;
Exit;
end;
(***********************************************)
(* Concurrent INSTALLATION CHECK *)
(***********************************************)
FillChar(Regs, SizeOf(Regs), #0);
Regs.EAX := $4451;
RealModeInt($21, Regs);
{ Verify if error, and verify is truly a multi user version }
If ((Regs.Flags AND fCarry) = $00) and (QuadrupleByte(Regs.EAX).Lo = $14) then
Begin
ASM
MOV AL, [ShellVal]
MOV AH, OSCPMDOS
MOV [@Result], AX
end;
Exit;
end;
(***********************************************)
(* NORMAL DOS RUNNING *)
(***********************************************)
(* RUNNING NORMAL DOS *)
ASM
MOV AL, [ShellVal]
MOV AH, OSNone
MOV [@Result], AX
end;
end;
{$ELSE}
(*************************************************************************)
(* FUNCTION DetectShell: Word; *)
(* *)
(* This function returns the shell type presently running. *)
(* *)
(* LOW BYTE = Shell Type *)
(* HIGH BYTE = Operating System Type *)
(*************************************************************************)
Function DetectShell: Word; Assembler;
(* Low Byte = Shell Type *)
(* High Byte = OS Type *)
Var
ShellVal: Byte; { Temporary storage of Shell Value }
ASM
(***********************************************)
(* 4DOS / NDOS INSTALLATION CHECK *)
(***********************************************)
MOV AX, Api4DOS ; (* API Function Call 4DOS - Installation Check *)
MOV BH, 00h
INT TSRInterrupt
CMP AX, 44DDh
JE @4DOS
MOV AX, ApiNDos ; (* API Function Call NDOS - Installation Check *)
MOV BH, 00h
INT TSRInterrupt
CMP AX, 44EEh
JE @4DOS
JMP @Not4DOS
@4DOS: ;(* Running 4DOS/NDOS - Set Correct Shell Var. *)
MOV [ShellVal], ShellNDos
JMP @NovellCheck
@Not4DOS: ; (* Running Standard Shell *)
MOV [ShellVal], ShellNone
JMP @NovellCheck
(***********************************************)
(* NOVELL NET INSTALLATION CHECK *)
(***********************************************)
@NovellCheck: ;(* Continue by checking if running Novell Net *)
MOV AX, 7A00h
INT TSRInterrupt
CMP AL, 0FFh
JE @NovellPresent
JMP @Continue
@NovellPresent:
ADD [ShellVal], ShellNovell ;(* Add Novell Value and continue *)
@Continue:
(* We have to check for the following multitaskers: *)
(* - OS/2 Version 2.0+ *)
(* - Windows Enhanced Mode TESTED *)
(* - Desqview / TopView TESTED *)
(* - DoubleDos *)
(* - Protected Mode Server 1.0+ TESTED *)
(* - Concurrent DOS/ MultiUser Version *)
(***********************************************)
(* OS/2 VER 2+ INSTALLATION CHECK *)
(***********************************************)
MOV AX, 4010h
INT TSRInterrupt
CMP AX, 4010h
JE @NoOS2
MOV AH, OSOS2 ; (* OS/2 Version 2.0+ Is Running *)
MOV AL, [ShellVal] ; (* Get Type of Shell Running *)
JMP @End ; (* Return from Function, we got all info *)
@NoOS2:
(***********************************************)
(* WINDOWS/386 INSTALLATION CHECK *)
(***********************************************)
MOV AX, 1600h ; (* Prepare Windows Check *)
INT TSRInterrupt
CMP AL, 00h ; (* Neither Windows/386 2.x nor Windows/386 3 Running *)
JE @NoWindows
CMP AL, 80h ; (* If AL = 80h then XMS Driver present, no windows *)
JE @NoWindows
MOV AL, [ShellVal] ; (* Get Type of Shell Running *)
MOV AH, OSWindows ; (* Windows enhanced mode is running *)
JMP @End ; (* Return From Function , we got all info *)
@NoWindows:
(***********************************************)
(* WINDOWS NT INSTALLATION CHECK *)
(***********************************************)
MOV AX,3306h
INT DOS_Function
CMP AL,0FFh
JE @NoNT
CMP BH,100
JG @NoNT
CMP BL,5
JNE @NoNT
CMP BH,50
JNE @NoNT
MOV AL, [ShellVal]
MOV AH, OSNT
JMP @End
@NoNT:
(***********************************************)
(* DESQVIEW/TOPVIEW INSTALLATION CHECK *)
(***********************************************)
MOV AH, 2Bh
MOV CX, 4445h
MOV DX, 5351h
MOV AL, 01h
INT Dos_Function
CMP AL, 0FFh ; (* If AL = FFh then Desqview is NOT loaded *)
JE @NoDV
MOV AL, [ShellVal]
MOV AH, OSDesqview
JMP @End ; (* Return from Function, we got all info *)
@NoDV:
(* Check For Topview *)
MOV AX, 1022h
MOV BX, 0000h
INT 15h
CMP BX, 0000h ; (* If BX = 0000h then Topview or compatible is NOT loaded *)
JE @NoTopview
MOV AL, [ShellVal]
MOV AH, OSDesqview
JMP @End
@NoTopview:
(***********************************************)
(* DOUBLEDOS INSTALLATION CHECK *)
(***********************************************)
MOV AX, 0E400h
INT DOS_Function
CMP AL, 00h
JE @NoDoubleDos
MOV AL, [ShellVal]
MOV AH, OsDoubleDos
JMP @End
@NoDoubleDos:
(***********************************************)
(* DPMI V1.0+ INSTALLATION CHECK *)
(***********************************************)
MOV AX, 1687h
INT TSRInterrupt
CMP AX, 0000h
JNE @NoDPMI ; (* If AX <> 0000 then NO DPMI Server *)
CMP DH, 01 ; (* We need version 1.0+ only *)
JL @NoDPMI ; (* Less then Version 1.00, we do not need *)
MOV AL, [ShellVal]
MOV AH, OSDPMI ; (* DOS Protected Mode Server present V1.0+ *)
JMP @End
@NoDPMI:
(***********************************************)
(* Concurrent INSTALLATION CHECK *)
(***********************************************)
MOV AX, 4451h
INT DOS_Function
JC @NoConcurDOS
CMP AH, 14h ; (* Verify if we are truly using Multiuser version *)
JNE @NoConcurDOS ; (* This is not a Multi-User version *)
MOV AL, [ShellVAl]
MOV AH, OSCpmDOS ; (* Return Concurrent DOS MultiUser *)
JMP @End
@NoConcurDOS:
(***********************************************)
(* NORMAL DOS RUNNING *)
(***********************************************)
(* RUNNING NORMAL DOS *)
MOV AL, [ShellVal]
MOV AH, OSNone
@End:
end;
{$ENDIF}
{$IFDEF DPMI}
(*************************************************************************)
(* FUNCTION TameInstalled: Boolean; *)
(* *)
(* This function returns TRUE if TAME is installed in memory. *)
(* PROTECTED MODE VERSION. *)
(*************************************************************************)
Function TameInstalled: Boolean;
Var
Regs: TDPMIRegisters;
Begin
FillChar(Regs, SizeOf(Regs), #0);
Regs.EAX := $2B01;
Regs.ECX := $5441;
Regs.EDX := $4D45;
RealModeInt($21, Regs);
If QuadrupleByte(Regs.EAX).Lo = $02 then
TameInstalled := TRUE
ELSE
TameInstalled := FALSE;
end;
{$ELSE}
(*************************************************************************)
(* FUNCTION TameInstalled: Boolean; *)
(* *)
(* This function returns TRUE if TAME is installed in memory. *)
(* *)
(*************************************************************************)
Function TameInstalled: Boolean; Assembler;
ASM
(* Check for the presence of TAME *)
(* Multitasker enhancer *)
MOV AX, 2B01h
MOV CX, 5441h
MOV DX, 4D45h
INT DOS_Function
CMP AL, 02h
JNE @NoTame ; (* If AL <> 02 then TAME is NOT Installed *)
MOV AL, TRUE
RET
@NoTame:
MOV AL, FALSE
end;
{$ENDIF}
(*************************************************************************)
(* Object Implementation *)
(*************************************************************************)
(* WHEN THERE IS NOTHING -> IT MEANS THAT THE SERVICE IS NOT SUPPORTED *)
(* BY THAT SHELL OS. *)
Constructor TMultiTask.Init;
{ THIS INTERRUPT IS CHECKED BOTH IN PROTECTED MODE AND REAL MODE }
Begin
{ Check if universal Give Time slice interrupt is supported }
ASM
MOV AX, 1680h ; { Set up Service - Give Time Slice }
INT 2Fh ; { Call Multiplex interrupt service }
CMP AL, 00h ; { If AL = 00h service supported }
LES DI, [Self] ; { Get pointer to this object }
JE @Support
MOV ES:[DI].Universal, FALSE ; { Service is not supported }
JMP @End
@Support:
MOV ES:[DI].Universal, TRUE ; { Service is supported }
@End:
end;
end;
{$IFDEF DPMI}
Procedure TMultiTask.GiveTimeSlice;
Var
Regs: TDPMIRegisters;
Begin
{ If universal time slice giver is supported use it! }
IF Universal THEN
Begin
ASM
MOV AX, 1680h
INT TSRInterrupt
end;
end
else
Begin
{ If Novell Netware installed use it by calling real mode INT }
{ I do not know , if Novell also works under Protected mode }
If TestShell in [ShellNovell, ShellNDOSNovell] then
Begin
FillChar(Regs, SizeOf(Regs), #0);
Regs.EBX := $000A;
RealModeInt($7A, Regs);
end;
end;
end;
{$ELSE}
Procedure TMultiTask.GiveTimeSlice; Assembler;