forked from galazwoj/dosidle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DOSidle_132.asm
2553 lines (2332 loc) · 48.8 KB
/
DOSidle_132.asm
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
;
; 100% bytecode identical with disassembled dosidle (ie with dosidle.asm)
;
PAGE 59,132
.586p
SAMESIZE = 1
seg_a segment byte public use16 'code'
assume cs:seg_a, ds:seg_a, ss:stack_seg_b
mem_lallocate proc near
push bx
mov bx,cx
mov ah,48h
int 21h ; DOS Services ah=function 48h
; allocate memory, bx=bytes/16
pop bx
retn
mem_lallocate endp
mem_lrelease proc near
push ax
push es
mov es,ax
mov ah,49h
int 21h ; DOS Services ah=function 49h
; release memory block, es=seg
pop es
pop ax
retn
mem_lrelease endp
mem_lresize proc near
push ax
push bx
push es
mov es,ax
mov bx,cx
mov ah,4Ah
int 21h ; DOS Services ah=function 4Ah
; change memory allocation
; bx=bytes/16, es=mem segment
pop es
pop bx
pop ax
retn
mem_lresize endp
mem_lallocate_all proc near
push bx
mov bx,0FFFFh
mov ah,48h
int 21h ; DOS Services ah=function 48h
; allocate memory, bx=bytes/16
mov ax,bx
mov cx,bx
pop bx
retn
mem_lallocate_all endp
intr_vec_struc struc
number db ?
old_isr dd ?
new_isr dd ?
intr_vec_struc ends
intr_suspend_struc struc
byte1 db ?
bytes25 dd ?
intr_suspend_struc ends
par_item struc
switch db 11 dup (0)
proc_offset dw 0
par_item ends
INTR_14H_BIOS = 14h * 4
INTR_16H_BIOS = 16h * 4
INTR_21H_BIOS = 21h * 4
INTR_2DH_BIOS = 2dh * 4
PSP_envirn_seg = 2Ch
tsr_kernel_id dw 0
tsr_psp_seg dw 0
tsr_env_seg dw 0
new_int_2dh dd isr_2dh
old_int_2dh dd 0
intr_vectors intr_vec_struc 30 dup (<>)
vectors_hooked dw 0
suspend_vectors intr_suspend_struc 30 dup (<>)
vectors_suspend dw 0
TSR_ID = 0FEADh
ACTION_TEST = 0
ACTION_UNINSTALL = 1
ACTION_SUSPEND = 2
ACTION_REACTIVATE = 3
isr_2dh proc far
cmp dx, cs:tsr_kernel_id ; db 2Eh, 3Bh, 16h, 31h, 00h, 74h
jz short loc_1 ; db 05h
loc_2:
jmp dword ptr cs:old_int_2dh
loc_1:
cmp bx,ACTION_TEST
jne short loc_3 ; Jump if not equal
mov ax,TSR_ID
sti ; Enable interrupts
iret ; Interrupt return
loc_3:
cmp bx,ACTION_UNINSTALL
jne short loc_10 ; Jump if not equal
cli ; Disable interrupts
push cx
push si
push di
push ds
push es
mov ax,cs
mov ds,ax
xor ax,ax ; Zero register
mov es,ax
mov eax,new_int_2dh
cmp es:[INTR_2DH_BIOS],eax
jne short loc_8 ; Jump if not equal
mov si,offset intr_vectors
mov cx,vectors_hooked
test cx,cx
jz short loc_7 ; Jump if zero
locloop_4:
movzx di, [(intr_vec_struc ptr [si]).number] ; Mov w/zero extend
shl di,2 ; Shift w/zeros fill
mov eax,[(intr_vec_struc ptr [si]).old_isr]
cmp es:[di],eax
je short loc_5 ; Jump if equal
mov eax,[(intr_vec_struc ptr [si]).new_isr]
cmp es:[di],eax
jne short loc_8 ; Jump if not equal
loc_5:
add si,size intr_vec_struc
loop locloop_4 ; Loop if cx > 0
mov si,offset intr_vectors
mov cx,vectors_hooked
locloop_6:
mov eax,[(intr_vec_struc ptr [si]).old_isr]
movzx di,[(intr_vec_struc ptr [si]).number] ; Mov w/zero extend
shl di,2 ; Shift w/zeros fill
mov es:[di],eax
add si,size intr_vec_struc
loop locloop_6 ; Loop if cx > 0
loc_7:
mov eax,old_int_2dh
mov es:INTR_2DH_BIOS,eax
mov ax,tsr_psp_seg
call mem_lrelease
mov ax,1
jmp short loc_9
loc_8:
xor ax,ax ; Zero register
loc_9:
pop es
pop ds
pop di
pop si
pop cx
sti ; Enable interrupts
iret ; Interrupt return
loc_10:
cmp bx,ACTION_SUSPEND
jne short loc_15 ; Jump if not equal
cli ; Disable interrupts
push ebx
push cx
push si
push di
push ds
push es
mov ax,cs
mov ds,ax
cmp vectors_suspend,0
jne short loc_13 ; Jump if not equal
mov si,offset intr_vectors
mov di,offset suspend_vectors
mov cx,vectors_hooked
mov vectors_suspend,cx
test cx,cx
jz short loc_12 ; Jump if zero
locloop_11:
mov ebx,[(intr_vec_struc ptr [si]).new_isr]
ror ebx,10h ; Rotate
mov es,bx
rol ebx,10h ; Rotate
mov al,es:[bx]
mov [(intr_suspend_struc ptr [di]).byte1],al
mov eax,es:[bx+1]
mov [di+1],eax
mov eax,[si+1]
mov byte ptr es:[bx],0EAh
mov es:[bx+1],eax
add si, size intr_vec_struc
add di,size intr_suspend_struc
loop locloop_11 ; Loop if cx > 0
loc_12:
mov ax,1
jmp short loc_14
loc_13:
xor ax,ax ; Zero register
loc_14:
pop es
pop ds
pop di
pop si
pop cx
pop ebx
sti ; Enable interrupts
iret ; Interrupt return
loc_15:
cmp bx,ACTION_REACTIVATE
jne loc_2 ; Jump if not equal
cli ; Disable interrupts
push ebx
push cx
push si
push di
push ds
push es
mov ax,cs
mov ds,ax
cmp vectors_suspend,0
je short loc_18 ; Jump if equal
mov si,offset intr_vectors
mov di,offset suspend_vectors
mov cx,vectors_hooked
mov vectors_suspend,0
test cx,cx
jz short loc_17 ; Jump if zero
locloop_16:
mov ebx,[(intr_vec_struc ptr [si]).new_isr]
ror ebx,10h ; Rotate
mov es,bx
rol ebx,10h ; Rotate
mov al,[(intr_suspend_struc ptr [di]).byte1]
mov es:[bx],al
mov eax,[(intr_suspend_struc ptr [di]).bytes25]
mov es:[bx+1],eax
add si,size intr_vec_struc
add di,size intr_suspend_struc
loop locloop_16 ; Loop if cx > 0
loc_17:
mov ax,1
jmp short loc_19
loc_18:
xor ax,ax ; Zero register
loc_19:
pop es
pop ds
pop di
pop si
pop cx
pop ebx
sti ; Enable interrupts
iret ; Interrupt return
isr_2dh endp
hex_table db '0123456789ABCDEF' ; Data table (indexed access)
VIDEO_SEG = 0B800h
video_offset dw 0
video_attribute db 0Eh
video_writestring proc near
push ax
push si
push es
mov ax,VIDEO_SEG
mov es,ax
loc_20:
mov al,[si]
test al,al
jz short loc_21 ; Jump if zero
call video_writech
inc si
jmp short loc_20
loc_21:
pop es
pop si
pop ax
retn
video_writestring endp
video_set_nl proc near
push ax
call video_writestring
call video_get_pos
inc al
call video_set_pos
pop ax
retn
video_set_nl endp
video_writech proc near
push ax
push di
mov di,VIDEO_SEG
mov es,di
mov di,video_offset
mov ah,video_attribute
mov es:[di],ax
add video_offset,2
pop di
pop ax
retn
video_writech endp
video_writedec proc near
push eax
push ebx
push cx
push edx
push es
mov bx,VIDEO_SEG
mov es,bx
mov ebx,0Ah
xor cx,cx ; Zero register
loc_22:
xor edx,edx ; Zero register
div ebx ; ax,dx rem=dx:ax/reg
push dx
inc cl
test eax,eax
jnz loc_22 ; Jump if not zero
locloop_23:
pop bx
mov al,hex_table[bx] ; ('0123456789ABCDEF')
call video_writech
loop locloop_23 ; Loop if cx > 0
pop es
pop edx
pop cx
pop ebx
pop eax
retn
video_writedec endp
video_writehex proc near
push ax
push ebx
push cx
push si
push es
mov bx,VIDEO_SEG
mov es,bx
mov ebx,eax
mov cx,8
locloop_24:
rol ebx,4 ; Rotate
mov si,bx
and si,0Fh
test si,si
loopz locloop_24 ; Loop if zf=1, cx>0
jcxz short loc_26 ; Jump if cx=0
ror ebx,4 ; Rotate
inc cx
locloop_25:
rol ebx,4 ; Rotate
mov si,bx
and si,0Fh
mov al,hex_table[si] ; ('0123456789ABCDEF')
call video_writech
loop locloop_25 ; Loop if cx > 0
jmp short loc_27
loc_26:
mov al,30h ; '0'
call video_writech
loc_27:
mov al,68h ; 'h'
call video_writech
pop es
pop si
pop cx
pop ebx
pop ax
retn
video_writehex endp
video_attribute_special proc near
push ax
push cx
push es
call video_get_attribute
push ax
mov ax,VIDEO_SEG
mov es,ax
mov cx,7D0h
mov al,0Fh
call video_set_attribute
mov al,20h ; ' '
locloop_28:
call video_writech
loop locloop_28 ; Loop if cx > 0
pop ax
call video_set_attribute
pop es
pop cx
pop ax
retn
video_attribute_special endp
video_get_attribute proc near
mov al,video_attribute
retn
video_get_attribute endp
video_set_attribute proc near
mov video_attribute,al
retn
video_set_attribute endp
video_get_pos proc near
push dx
mov ax,video_offset
mov dx,0A0h
div dx ; ax,dx rem=dx:ax/reg
shr dx,1 ; Shift w/zeros fill
mov ah,dl
pop dx
retn
video_get_pos endp
video_set_pos proc near
push ax
push dx
mov dh,ah
mov dl,0A0h
mul dl ; ax = reg * al
shr dx,7 ; Shift w/zeros fill
and dl,0FEh
add ax,dx
mov video_offset,ax
pop dx
pop ax
retn
video_set_pos endp
IDLE_MODE_1 = 1 ;enable TESTOMODE
IDLE_MODE_2 = 2 ;disable FORCEMODE
idle_mode db 0
IFDEF SAMESIZE
xchg bx,bx
ENDIF
old_intr_21h dd 0
new_intr_21h_1 dd isr_21h_1
new_intr_21h_2 dd isr_21h_2
intr_21h_delay dd 0
intr_21h_halts dd 0
intr_21h_calls dd 0
intr_21h_halts_msg db ' int 21h HLTs executed.', 0
intr_21h_calls_msg db ' int 21h calls.', 0
isr_21h_halt_1 proc near
test cs:idle_mode,IDLE_MODE_2
jnz short loc_ret_29 ; Jump if not zero
inc cs:intr_21h_delay
cmp cs:intr_21h_delay,0Ah
jb short loc_ret_29 ; Jump if below
sti ; Enable interrupts
hlt ; Halt processor
inc cs:intr_21h_halts
loc_ret_29:
retn
isr_21h_halt_1 endp
isr_21h_halt_2 proc near
push ax
sti ; Enable interrupts
loc_30:
mov ah,0Bh
pushf ; Push flags
call dword ptr cs:old_intr_21h
test ax,ax
jnz short loc_31 ; Jump if not zero
hlt ; Halt processor
inc cs:intr_21h_halts
jmp short loc_30
loc_31:
pop ax
retn
isr_21h_halt_2 endp
IFDEF SAMESIZE
xchg bx,bx
xchg bx,bx
xchg bx,bx
nop
ENDIF
isr_21h_1 proc far
cmp ah,2Ch ; ','
ja short loc_34 ; Jump if above
jnz short loc_32 ; Jump if not zero
call isr_21h_halt_1
jmp short loc_35
loc_32:
cmp ah,8
je short loc_33 ; Jump if equal
cmp ah,7
je short loc_33 ; Jump if equal
cmp ah,1
jne short loc_34 ; Jump if not equal
loc_33:
call isr_21h_halt_2
jmp short loc_35
loc_34:
mov dword ptr cs:intr_21h_delay,0
mov dword ptr cs:intr_16h_delay,0
loc_35:
jmp dword ptr cs:old_intr_21h
isr_21h_1 endp
IFDEF SAMESIZE
xchg bx,bx
xchg bx,bx
xchg bx,bx
nop
ENDIF
isr_21h_2 proc far
push eax
push si
push ds
mov ax,cs
mov ds,ax
mov al,1
mov ah,37h ; '7'
call video_set_pos
mov al,0Ch
call video_set_attribute
mov eax,intr_21h_calls
inc intr_21h_calls
call video_writedec
mov al,0Eh
call video_set_attribute
mov si,offset intr_21h_calls_msg ; (' int 21h calls.')
call video_writestring
mov eax,[esp+4]
cmp ah,2Ch ; ','
ja short loc_38 ; Jump if above
jnz short loc_36 ; Jump if not zero
mov ax,1
call video_set_pos
mov al,0Ch
call video_set_attribute
mov eax,intr_21h_halts
call video_writedec
mov al,0Eh
call video_set_attribute
mov si,offset intr_21h_halts_msg ; (' int 21h HLTs executed.')
call video_writestring
call isr_21h_halt_1
jmp short loc_39
loc_36:
cmp ah,8
je short loc_37 ; Jump if equal
cmp ah,7
je short loc_37 ; Jump if equal
cmp ah,1
jne short loc_38 ; Jump if not equal
loc_37:
mov ax,1
call video_set_pos
mov al,0Ch
call video_set_attribute
mov eax,intr_21h_halts
call video_writedec
mov al,0Eh
call video_set_attribute
mov si,offset intr_21h_halts_msg ; (' int 21h HLTs executed.')
call video_writestring
call isr_21h_halt_2
jmp short loc_39
loc_38:
mov dword ptr intr_21h_delay,0
mov dword ptr intr_16h_delay,0
loc_39:
pop ds
pop si
pop eax
jmp dword ptr cs:old_intr_21h
isr_21h_2 endp
IFDEF SAMESIZE
xchg bx,bx
ENDIF
old_intr_16h dd 0
new_intr_16h_1 dd isr_16h_1
new_intr_16h_2 dd isr_16h_2
intr_16h_delay dd 0
intr_16h_halts dd 0
intr_16h_calls dd 0
intr_16h_halts_msg db ' int 16h HLTs executed.', 0
intr_16h_calls_msg db ' int 16h calls.', 0
isr_16h_halt_1 proc near
test cs:idle_mode,IDLE_MODE_2
jnz short loc_ret_40 ; Jump if not zero
inc cs:intr_16h_delay
cmp cs:intr_16h_delay,0Ah
jb short loc_ret_40 ; Jump if below
sti ; Enable interrupts
hlt ; Halt processor
inc cs:intr_16h_halts
loc_ret_40:
retn
isr_16h_halt_1 endp
isr_16h_halt_2 proc near
push ax
push cx
inc ah
mov ch,ah
sti ; Enable interrupts
loc_41:
pushf ; Push flags
call dword ptr cs:old_intr_16h
jnz short loc_42 ; Jump if not zero
hlt ; Halt processor
inc cs:intr_16h_halts
mov ah,ch
jmp short loc_41
loc_42:
pop cx
pop ax
retn
isr_16h_halt_2 endp
IFDEF SAMESIZE
xchg bx,bx
xchg bx,bx
xchg bx,bx
xchg bx,bx
xchg bx,bx
nop
ENDIF
isr_16h_1 proc far
cmp ah,12h
ja short loc_46 ; Jump if above
jz short loc_43 ; Jump if zero
cmp ah,11h
je short loc_43 ; Jump if equal
cmp ah,2
je short loc_43 ; Jump if equal
cmp ah,1
jne short loc_44 ; Jump if not equal
loc_43:
call isr_16h_halt_1
jmp short loc_47
loc_44:
cmp ah,10h
je short loc_45 ; Jump if equal
test ah,ah
jnz short loc_46 ; Jump if not zero
loc_45:
call isr_16h_halt_2
jmp short loc_47
loc_46:
mov dword ptr cs:intr_16h_delay,0
mov dword ptr cs:intr_21h_delay,0
loc_47:
jmp dword ptr cs:old_intr_16h
isr_16h_1 endp
IFDEF SAMESIZE
xchg bx,bx
xchg bx,bx
xchg bx,bx
xchg bx,bx
xchg bx,bx
xchg bx,bx
xchg bx,bx
ENDIF
isr_16h_2 proc far
push eax
push si
push ds
mov ax,cs
mov ds,ax
mov ah,37h ; '7'
xor al,al ; Zero register
call video_set_pos
mov al,0Ch
call video_set_attribute
mov eax,intr_16h_calls
inc intr_16h_calls
call video_writedec
mov al,0Eh
call video_set_attribute
mov si,offset intr_16h_calls_msg ; (' int 16h calls.')
call video_writestring
mov eax,[esp+4]
cmp ah,12h
ja short loc_51 ; Jump if above
jz short loc_48 ; Jump if zero
cmp ah,11h
je short loc_48 ; Jump if equal
cmp ah,2
je short loc_48 ; Jump if equal
cmp ah,1
jne short loc_49 ; Jump if not equal
loc_48:
xor ax,ax ; Zero register
call video_set_pos
mov al,0Ch
call video_set_attribute
mov eax,intr_16h_halts
call video_writedec
mov al,0Eh
call video_set_attribute
mov si,offset intr_16h_halts_msg ; (' int 16h HLTs executed.')
call video_writestring
call isr_16h_halt_1
jmp short loc_52
loc_49:
cmp ah,10h
je short loc_50 ; Jump if equal
test ah,ah
jnz short loc_51 ; Jump if not zero
loc_50:
xor ax,ax ; Zero register
call video_set_pos
mov al,0Ch
call video_set_attribute
mov eax,intr_16h_halts
call video_writedec
mov al,0Eh
call video_set_attribute
mov si,offset intr_16h_halts_msg ; (' int 16h HLTs executed.')
call video_writestring
mov eax,[esp+4]
call isr_16h_halt_2
jmp short loc_52
loc_51:
mov dword ptr intr_16h_delay,0
mov dword ptr intr_21h_delay,0
loc_52:
pop ds
pop si
pop eax
jmp dword ptr cs:old_intr_16h
isr_16h_2 endp
IFDEF SAMESIZE
nop
ENDIF
old_intr_14h dd 0
new_intr_14h_1 dd isr_14h_1
new_intr_14h_2 dd isr_14h_2
dd 0
intr_14h_calls dd 0
intr_14h_halts dd 0
intr_14h_halts_msg db ' int 14h HALTs executed.', 0
intr_14h_calls_msg db ' int 14h calls.', 0
isr_14h_halt_1 proc near
push ax
sti ; Enable interrupts
loc_53:
mov ah,3
pushf ; Push flags
call dword ptr cs:old_intr_14h
test ah,1
jnz short loc_54 ; Jump if not zero
hlt ; Halt processor
inc cs:intr_14h_calls
jmp short loc_53
loc_54:
pop ax
retn
isr_14h_halt_1 endp
IFDEF SAMESIZE
nop
ENDIF
isr_14h_1 proc far
cmp ah,2
jne short loc_55 ; Jump if not equal
call isr_14h_halt_1
loc_55:
jmp dword ptr cs:old_intr_14h
isr_14h_1 endp
IFDEF SAMESIZE
xchg bx,bx
nop
ENDIF
isr_14h_2 proc far
push eax
push si
push ds
mov ax,cs
mov ds,ax
mov al,2
mov ah,37h ; '7'
call video_set_pos
mov al,0Ch
call video_set_attribute
mov eax,intr_14h_halts
inc intr_14h_halts
call video_writedec
mov al,0Eh
call video_set_attribute
mov si,offset intr_14h_calls_msg ; (' int 14h calls.')
call video_writestring
mov eax,[esp+4]
cmp ah,2
jne short loc_56 ; Jump if not equal
mov ax,2
call video_set_pos
mov al,0Ch
call video_set_attribute
mov eax,intr_14h_calls
call video_writedec
mov al,0Eh
call video_set_attribute
mov si,offset intr_14h_halts_msg ; (' int 14h HALTs executed.')
call video_writestring
call isr_14h_halt_1
loc_56:
pop ds
pop si
pop eax
jmp dword ptr cs:old_intr_14h
isr_14h_2 endp
IFDEF SAMESIZE
nop
ENDIF
old_irq_01h dd 00000h
new_irq_01h_1 dd isr_01h_1
new_irq_01h_2 dd isr_01h_2
irq_01h_calls dd 0
irq_01h_calls_msg db ' IRQ 01h calls.', 0
isr_01h_1 proc far
mov dword ptr cs:intr_16h_delay,0
mov dword ptr cs:intr_21h_delay,0
jmp dword ptr cs:old_irq_01h
isr_01h_1 endp
IFDEF SAMESIZE
xchg bx,bx
xchg bx,bx
xchg bx,bx
nop
ENDIF
isr_01h_2 proc far
pushf
call dword ptr cs:old_irq_01h
push eax
push si
push ds
mov ax,cs
mov ds,ax
mov al,3
mov ah,37h
call video_set_pos
mov al,0Ch
call video_set_attribute
mov eax, irq_01h_calls
inc irq_01h_calls
call video_writedec
mov al,0Eh
call video_set_attribute
mov si,offset irq_01h_calls_msg
call video_writestring
mov dword ptr intr_16h_delay,0
mov dword ptr intr_21h_delay,0
pop ds
pop si
pop eax
iret
isr_01h_2 endp
tsr_instcheck proc near
push bx
xor bx,bx ; Zero register
int 2Dh ; ??INT Non-standard interrupt
cmp ax,TSR_ID
sete al ; Set byte if equal
mov ah,0
pop bx
retn
tsr_instcheck endp
tsr_uninstall proc near
push bx
mov bx,ACTION_UNINSTALL
int 2Dh ; ??INT Non-standard interrupt
pop bx
retn
tsr_uninstall endp
tsr_suspend proc near
push bx
mov bx,ACTION_SUSPEND
int 2Dh ; ??INT Non-standard interrupt
pop bx
retn
tsr_suspend endp
tsr_reactivate proc near
push bx
mov bx,ACTION_REACTIVATE
int 2Dh ; ??INT Non-standard interrupt
pop bx
retn
tsr_reactivate endp
tsr_hookint proc near
pushf ; Push flags
pushad ; Save all regs
push es
cli ; Disable interrupts
xor esi,esi ; Zero register
mov es,si
mov ecx, size intr_vec_struc
mov si,vectors_hooked
inc vectors_hooked
imul esi,ecx ; reg = reg * reg
add si,offset intr_vectors
mov [(intr_vec_struc ptr [si]).number],bl
mov [(intr_vec_struc ptr [si]).new_isr],eax
xor bh,bh ; Zero register
shl bx,2 ; Shift w/zeros fill
xchg es:[bx],eax
mov [(intr_vec_struc ptr [si]).old_isr],eax
sti ; Enable interrupts
pop es
popad ; Restore all regs
popf ; Pop flags
retn
tsr_hookint endp
tsr_install proc near
cli ; Disable interrupts
mov tsr_kernel_id,dx
mov tsr_psp_seg,bx
mov tsr_env_seg,ax
xor ax,ax ; Zero register
mov es,ax
mov eax,es:INTR_2DH_BIOS
mov old_int_2dh,eax
mov eax,new_int_2dh
mov es:INTR_2DH_BIOS,eax
mov ax,tsr_env_seg
call mem_lrelease
mov ax,cx
shr ax,4 ; Shift w/zeros fill
add ax,20h
mov dx,ax
mov ax,3100h
int 21h ; DOS Services ah=function 31h
; terminate & stay resident
; al=return code,dx=paragraphs
ret
tsr_install endp
KERNEL_ID equ 0DEEDh ; ID number of this program.
SYS_RAW = 01h ;
SYS_VCPI = 02h ; Flags for PM hosts driving the