home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / XINE-1.ZIP / XINE-1.011 < prev    next >
Text File  |  1996-10-25  |  22KB  |  805 lines

  1.  
  2.                                         /-----------------------------\
  3.                                         | Xine - issue #1 - Phile 011 |
  4.                                         \-----------------------------/
  5.  
  6. ;
  7. ; Methyl [Immortal Riot/Genesis] proudly presents:
  8. ;
  9. ;
  10. ;                 ┌───────────────────────────────────────┐
  11. ;                 │               Tunneling               │
  12. ;                 │                 with                  │
  13. ;                 │            Single step mode           │
  14. ;                 │                                       │
  15. ;                 │            EXAMPLE PROGRAM            │
  16. ;                 └───────────────────────────────────────┘
  17. ;
  18. ;   So you can code a good tunneling routine now, but which one should you 
  19. ;choose?  A good method of working out which handler you want to use is to 
  20. ;first have a look at how each method performs on YOUR system, and then maybe
  21. ;on other systems if you have them available.  So as to save you unknown
  22. ;coding time, I have assembled all the methods you have learnt so far into
  23. ;this example program, which will simply show you the results of each type
  24. ;of tunneling method.
  25. ;
  26. ;   Please note there are no anti-anti-tunneling routines in here, as they are
  27. ;not really needed for an example program such as this.  Also note that this is
  28. ;NOT a virus, it is an EXAMPLE PROGRAM!  Almost all of the code in here, at
  29. ;least the major portions of the INT 1 handlers, was copied straight from
  30. ;my document, cut+paste style, just to prove the routines I provided you are
  31. ;ready to run without modification!
  32. ;
  33. codesg segment para public 'code'
  34.     assume cs:codesg, ds:codesg, es:codesg, ss:codesg
  35.     org 0100h
  36. start:
  37.     jmp begin
  38.     orig_1         dw 0, 0
  39.     return_address dw 0, 0
  40.     m_startup   db 'Methyl''s example interrupt tunneler$'
  41.     m_segment_o_13 db 0dh, 0ah, 'SEGMENT CHECK, int 13, BIOS method    - $'
  42.     m_segment_n_13 db 0dh, 0ah, 'SEGMENT CHECK, int 13, IO method      - $'
  43.     m_segment_21   db 0dh, 0ah, 'SEGMENT CHECK, int 21                 - $'
  44.     m_hand_o_13    db 0dh, 0ah, 'HAND METHOD, int 13, BIOS method      - $'
  45.     m_hand_n_13    db 0dh, 0ah, 'HAND METHOD, int 13, IO  method       - $'
  46.     m_hand_21      db 0dh, 0ah, 'HAND METHOD, int 21                   - $'
  47.     m_opcode_13    db 0dh, 0ah, 'OPCODE CHECK, int 13                  - $'
  48.     m_opcode_21    db 0dh, 0ah, 'OPCODE CHECK, int 21                  - $'
  49.     m_list_13      db 0dh, 0ah, 'CS:LIST METHOD, int 13                - $'
  50.     m_list_21      db 0dh, 0ah, 'CS:LIST METHOD, int 21                - $'
  51.     m_iret_13      db 0dh, 0ah, 'IRET CHECK, int 13                    - $'
  52.     m_iret_21      db 0dh, 0ah, 'IRET CHECK, int 21                    - $'
  53.     m_desq         db 0dh, 0ah, 'DESQView detected, exitting', 0dh, 0ah, '$'
  54.     m_end       db 0dh, 0ah, 'End of example program', 0dh, 0ah, '$'
  55. begin proc near
  56.     mov ah, 9
  57.     lea dx, [m_startup]
  58.     int 021h                    ; Show startup message
  59.  
  60.     mov ax, 03501h
  61.     int 021h
  62.     mov [orig_1], bx
  63.     mov [orig_1+2], es          ; Save original INT 1 handler
  64.  
  65.     mov ax, 02b01h
  66.     mov cx, 'DE'
  67.     mov dx, 'SQ'
  68.     int 021h
  69.     cmp al, -1
  70.     je desqview_not_here        ; Exit if DESQView found
  71.  
  72.     mov ah, 9
  73.     lea dx, [m_desq]
  74.     int 021h
  75.     mov ax, 04c01h
  76.     int 021h
  77.  
  78. desqview_not_here:
  79.     mov ah, 9
  80.     lea dx, [m_segment_o_13]
  81.     int 021h
  82.     call segment_o_13
  83.     call show_int_address
  84.  
  85.     mov ah, 9
  86.     lea dx, [m_segment_n_13]
  87.     int 021h
  88.     call segment_n_13
  89.     call show_int_address
  90.  
  91.     mov ah, 9
  92.     lea dx, [m_segment_21]
  93.     int 021h
  94.     call segment_21
  95.     call show_int_address
  96.  
  97.     mov ah, 9
  98.     lea dx, [m_hand_o_13]
  99.     int 021h
  100.     call hand_o_13
  101.     call show_int_address
  102.  
  103.     mov ah, 9
  104.     lea dx, [m_hand_n_13]
  105.     int 021h
  106.     call hand_n_13
  107.     call show_int_address
  108.  
  109.     mov ah, 9
  110.     lea dx, [m_hand_21]
  111.     int 021h
  112.     call hand_21
  113.     call show_int_address
  114.  
  115.     mov ah, 9
  116.     lea dx, [m_opcode_13]
  117.     int 021h
  118.     call opcode_13
  119.     call show_int_address
  120.  
  121.     mov ah, 9
  122.     lea dx, [m_opcode_21]
  123.     int 021h
  124.     call opcode_21
  125.     call show_int_address
  126.  
  127.     mov ah, 9
  128.     lea dx, [m_list_13]
  129.     int 021h
  130.     call list_13
  131.     call show_int_address
  132.  
  133.     mov ah, 9
  134.     lea dx, [m_list_21]
  135.     int 021h
  136.     call list_21
  137.     call show_int_address
  138.  
  139.     mov ah, 9
  140.     lea dx, [m_iret_13]
  141.     int 021h
  142.     call iret_13
  143.     call show_int_address
  144.  
  145.     mov ah, 9
  146.     lea dx, [m_iret_21]
  147.     int 021h
  148.     call iret_21
  149.     call show_int_address
  150.  
  151.     mov ah, 9
  152.     lea dx, [m_end]
  153.     int 021h                    ; Show exit message
  154.  
  155.     xor ax, ax
  156.     mov es, ax
  157.     cli
  158.     mov ax, [orig_1]
  159.     mov [es:4], ax
  160.     mov ax, [orig_1+2]
  161.     mov [es:6], ax
  162.     sti                         ; Reset original interrupt 1 address
  163.  
  164.     push cs
  165.     pop ds
  166.     
  167.     mov ax, 04c00h
  168.     int 021h
  169. begin endp
  170. ; ───────────────────────────────────────────────────────────────────────────
  171. segment_o_13 proc near
  172.     push ds
  173.     xor ax, ax
  174.     mov es, ax
  175.     cli
  176.     mov word ptr [es:4], offset segment_handler
  177.     mov [es:6], cs
  178.     sti                         ; redirect INT 1 to our routine
  179.     mov [return_address], 0
  180.     mov [return_address+2], 0   ; Clear return address
  181.     mov byte ptr [segment_status], -1
  182.     mov byte ptr [segment_type], 2
  183.                                 ; Set us up to start tunneling
  184.     xor ax, ax
  185.     mov ds, ax                  ; Point DS to IVT
  186.     pushf
  187.     pushf
  188.     pop ax
  189.     or ah, 1
  190.     push ax
  191.     popf                        ; Set TF
  192.     mov ah, 1
  193.     pushf
  194.     call far ptr [(013h*4)]     ; Simulate interrupt call
  195.     
  196.     popf
  197.     pop ds                      ; Restore our DS
  198.     ret
  199. segment_o_13 endp
  200. segment_n_13 proc near
  201.     push ds
  202.     xor ax, ax
  203.     mov es, ax
  204.     cli
  205.     mov word ptr [es:4], offset segment_handler
  206.     mov [es:6], cs
  207.     sti                         ; redirect INT 1 to our routine
  208.     mov [return_address], 0
  209.     mov [return_address+2], 0   ; Clear return address
  210.     mov byte ptr [segment_status], -1
  211.     mov byte ptr [segment_type], 1
  212.                                 ; Set us up to start tunneling
  213.     xor ax, ax
  214.     mov ds, ax                  ; Point DS to IVT
  215.     pushf
  216.     pushf
  217.     pop ax
  218.     or ah, 1
  219.     push ax
  220.     popf                        ; Set TF
  221.     mov ah, 1
  222.     pushf
  223.     call far ptr [(013h*4)]     ; Simulate interrupt call
  224.     
  225.     popf
  226.     pop ds                      ; Restore our DS
  227.     ret
  228. segment_n_13 endp
  229. segment_21 proc near
  230.     push ds
  231.     xor ax, ax
  232.     mov es, ax
  233.     cli
  234.     mov word ptr [es:4], offset segment_handler
  235.     mov [es:6], cs
  236.     sti                         ; redirect INT 1 to our routine
  237.     mov ah, 030h
  238.     int 021h                    ; DOS version check
  239.     cmp al, 3
  240.     jb alternative_segment
  241.     mov ah, 052h
  242.     int 021h
  243.     mov ax, [es:bx-2]
  244.     mov [first_mcb], ax         ; Setup first MCB address
  245.     jmp segment_done
  246. alternative_segment:
  247.     mov word ptr [first_mcb], 0300h
  248. segment_done:
  249.     mov [return_address], 0
  250.     mov [return_address+2], 0   ; Clear return address
  251.     mov byte ptr [segment_status], -1
  252.     mov byte ptr [segment_type], 0
  253.                                 ; Set us up to start tunneling
  254.     xor ax, ax
  255.     mov ds, ax                  ; Point DS to IVT
  256.     pushf
  257.     pushf
  258.     pop ax
  259.     or ah, 1
  260.     push ax
  261.     popf                        ; Set TF
  262.     mov ah, 052h
  263.     pushf
  264.     call far ptr [(021h*4)]     ; Simulate interrupt call
  265.     
  266.     popf
  267.     pop ds                      ; Restore our DS
  268.     ret
  269. segment_21 endp
  270. hand_o_13 proc near
  271.     push ds
  272.     xor ax, ax
  273.     mov es, ax
  274.     cli
  275.     mov word ptr [es:4], offset hand_handler
  276.     mov [es:6], cs
  277.     sti                         ; redirect INT 1 to our routine
  278.     mov [return_address], 0
  279.     mov [return_address+2], 0   ; Clear return address
  280.     mov word ptr [hand_segment], 0
  281.     mov byte ptr [hand_type], 1
  282.                                 ; Set us up to start tunneling
  283.     xor ax, ax
  284.     mov ds, ax                  ; Point DS to IVT
  285.     pushf
  286.     pushf
  287.     pop ax
  288.     or ah, 1
  289.     push ax
  290.     popf                        ; Set TF
  291.     mov ah, 1
  292.     pushf
  293.     call far ptr [(013h*4)]     ; Simulate interrupt call
  294.     
  295.     popf
  296.     pop ds                      ; Restore our DS
  297.     ret
  298. hand_o_13 endp
  299. hand_n_13 proc near
  300.     push ds
  301.     xor ax, ax
  302.     mov es, ax
  303.     cli
  304.     mov word ptr [es:4], offset hand_handler
  305.     mov [es:6], cs
  306.     sti                         ; redirect INT 1 to our routine
  307.     mov [return_address], 0
  308.     mov [return_address+2], 0   ; Clear return address
  309.     mov word ptr [hand_segment], -1
  310.     mov byte ptr [hand_type], 0
  311.                                 ; Set us up to start tunneling
  312.     xor ax, ax
  313.     mov ds, ax                  ; Point DS to IVT
  314.     pushf
  315.     pushf
  316.     pop ax
  317.     or ah, 1
  318.     push ax
  319.     popf                        ; Set TF
  320.     mov ah, 1
  321.     pushf
  322.     call far ptr [(013h*4)]     ; Simulate interrupt call
  323.     
  324.     popf
  325.     pop ds                      ; Restore our DS
  326.     ret
  327. hand_n_13 endp
  328. hand_21 proc near
  329.     push ds
  330.     xor ax, ax
  331.     mov es, ax
  332.     cli
  333.     mov word ptr [es:4], offset hand_handler
  334.     mov [es:6], cs
  335.     sti                         ; redirect INT 1 to our routine
  336.     mov [return_address], 0
  337.     mov [return_address+2], 0   ; Clear return address
  338.     mov word ptr [hand_segment], -1
  339.     mov byte ptr [hand_type], 0
  340.                                 ; Set us up to start tunneling
  341.     xor ax, ax
  342.     mov ds, ax                  ; Point DS to IVT
  343.     pushf
  344.     pushf
  345.     pop ax
  346.     or ah, 1
  347.     push ax
  348.     popf                        ; Set TF
  349.     mov ah, 052h
  350.     pushf
  351.     call far ptr [(021h*4)]     ; Simulate interrupt call
  352.     
  353.     popf
  354.     pop ds                      ; Restore our DS
  355.     ret
  356. hand_21 endp
  357. opcode_13 proc near
  358.     push ds
  359.     xor ax, ax
  360.     mov es, ax
  361.     cli
  362.     mov word ptr [es:4], offset opcode_handler
  363.     mov [es:6], cs
  364.     sti                         ; redirect INT 1 to our routine
  365.     mov [return_address], 0
  366.     mov [return_address+2], 0   ; Clear return address
  367.     xor ax, ax
  368.     mov ds, ax                  ; Point DS to IVT
  369.     pushf
  370.     pushf
  371.     pop ax
  372.     or ah, 1
  373.     push ax
  374.     popf                        ; Set TF
  375.     mov ah, 1
  376.     pushf
  377.     call far ptr [(013h*4)]     ; Simulate interrupt call
  378.     
  379.     popf
  380.     pop ds                      ; Restore our DS
  381.     ret
  382. opcode_13 endp
  383. opcode_21 proc near
  384.     push ds
  385.     xor ax, ax
  386.     mov es, ax
  387.     cli
  388.     mov word ptr [es:4], offset opcode_handler
  389.     mov [es:6], cs
  390.     sti                         ; redirect INT 1 to our routine
  391.     mov [return_address], 0
  392.     mov [return_address+2], 0   ; Clear return address
  393.     xor ax, ax
  394.     mov ds, ax                  ; Point DS to IVT
  395.     pushf
  396.     pushf
  397.     pop ax
  398.     or ah, 1
  399.     push ax
  400.     popf                        ; Set TF
  401.     mov ah, 052h
  402.     pushf
  403.     call far ptr [(021h*4)]     ; Simulate interrupt call
  404.     
  405.     popf
  406.     pop ds                      ; Restore our DS
  407.     ret
  408. opcode_21 endp
  409. list_13 proc near
  410.     push ds
  411.     xor ax, ax
  412.     mov es, ax
  413.     cli
  414.     mov word ptr [es:4], offset list_handler
  415.     mov [es:6], cs
  416.     sti                         ; redirect INT 1 to our routine
  417.     mov [return_address], 0
  418.     mov [return_address+2], 0   ; Clear return address
  419.  
  420.     lea bx, [offset list_begin]
  421. zero_loop_13:
  422.     mov word ptr [bx], 0
  423.     add bx, 2
  424.     cmp bx, offset list_end
  425.     jne zero_loop_13            ; Zero out list
  426.     mov word ptr [list_begin], cs        
  427.  
  428.     xor ax, ax
  429.     mov ds, ax                  ; Point DS to IVT
  430.     pushf
  431.     pushf
  432.     pop ax
  433.     or ah, 1
  434.     push ax
  435.     popf                        ; Set TF
  436.     mov ah, 1
  437.     pushf
  438.     call far ptr [(013h*4)]     ; Simulate interrupt call
  439.     
  440.     popf
  441.     pop ds                      ; Restore our DS
  442.     ret
  443. list_13 endp
  444. list_21 proc near
  445.     push ds
  446.     xor ax, ax
  447.     mov es, ax
  448.     cli
  449.     mov word ptr [es:4], offset list_handler
  450.     mov [es:6], cs
  451.     sti                         ; redirect INT 1 to our routine
  452.     mov [return_address], 0
  453.     mov [return_address+2], 0   ; Clear return address
  454.  
  455.     lea bx, [offset list_begin]
  456. zero_loop_21:
  457.     mov word ptr [bx], 0
  458.     add bx, 2
  459.     cmp bx, offset list_end
  460.     jne zero_loop_21            ; Zero out list
  461.     mov word ptr [list_begin], cs        
  462.  
  463.     xor ax, ax
  464.     mov ds, ax                  ; Point DS to IVT
  465.     pushf
  466.     pushf
  467.     pop ax
  468.     or ah, 1
  469.     push ax
  470.     popf                        ; Set TF
  471.     mov ah, 052h
  472.     pushf
  473.     call far ptr [(021h*4)]     ; Simulate interrupt call
  474.     
  475.     popf
  476.     pop ds                      ; Restore our DS
  477.     ret
  478. list_21 endp
  479. iret_13 proc near
  480.     push ds
  481.     xor ax, ax
  482.     mov es, ax
  483.     cli
  484.     mov word ptr [es:4], offset iret_handler
  485.     mov [es:6], cs
  486.     sti                         ; redirect INT 1 to our routine
  487.     mov [return_address], 0
  488.     mov [return_address+2], 0   ; Clear return address
  489.     mov byte ptr [iret_status], -1
  490.                                 ; Set us up to start tunneling
  491.     xor ax, ax
  492.     mov ds, ax                  ; Point DS to IVT
  493.     pushf
  494.     pushf
  495.     pop ax
  496.     or ah, 1
  497.     push ax
  498.     popf                        ; Set TF
  499.     mov ah, 1
  500.     pushf
  501.     call far ptr [(013h*4)]     ; Simulate interrupt call
  502.     
  503.     popf
  504.     pop ds                      ; Restore our DS
  505.     ret
  506. iret_13 endp
  507. iret_21 proc near
  508.     push ds
  509.     xor ax, ax
  510.     mov es, ax
  511.     cli
  512.     mov word ptr [es:4], offset iret_handler
  513.     mov [es:6], cs
  514.     sti                         ; redirect INT 1 to our routine
  515.     mov ah, 052h
  516.     int 021h
  517.     mov ax, [es:bx-2]
  518.     mov [first_mcb], ax         ; Setup first MCB address
  519.     mov [return_address], 0
  520.     mov [return_address+2], 0   ; Clear return address
  521.     mov byte ptr [iret_status], -1
  522.                                 ; Set us up to start tunneling
  523.     xor ax, ax
  524.     mov ds, ax                  ; Point DS to IVT
  525.     pushf
  526.     pushf
  527.     pop ax
  528.     or ah, 1
  529.     push ax
  530.     popf                        ; Set TF
  531.     mov ah, 052h
  532.     pushf
  533.     call far ptr [(021h*4)]     ; Simulate interrupt call
  534.     
  535.     popf
  536.     pop ds                      ; Restore our DS
  537.     ret
  538. iret_21 endp
  539. ; ───────────────────────────────────────────────────────────────────────────
  540. ; Start of INT 1 handler using SEGMENT CHECK method
  541.     first_mcb      dw 0
  542.     segment_status db -1
  543.     segment_type   db 0             ; 0=DOS KERNEL scan
  544.                                     ; 1=IO KERNEL scan
  545.                                     ; 2=ROM BIOS scan
  546. segment_handler proc far
  547.     push bp
  548.     mov bp, sp
  549.     push ax
  550.     cmp [cs:segment_status], 0
  551.     je segment_exit                 ; exit if we've finished tunneling already    
  552.     mov ax, [bp+4]                  ; get CS:
  553.     cmp [cs:segment_type], 1
  554.     je segment_io_scan
  555.     cmp [cs:segment_type], 2
  556.     je segment_bios_scan
  557.     cmp ax, [cs:first_mcb]
  558.     jb segment_found                ; check CS: is in DOS kernel
  559.     jmp segment_exit
  560. segment_io_scan:
  561.     cmp ax, 070h
  562.     je segment_found
  563.     jmp segment_exit                ; check CS: is in IO kernel
  564. segment_bios_scan:
  565.     cmp ax, 0c800h                  ; check for XT bios
  566.     je segment_found
  567.     cmp ax, 0f000h                  ; check for XT+ bios
  568.     je segment_found
  569. segment_exit:
  570.     pop ax
  571.     pop bp
  572.     iret
  573. segment_found:
  574.     mov ax, [bp+4]
  575.     mov [cs:return_address+2], ax
  576.     mov ax, [bp+2]
  577.     mov [cs:return_address], ax     ; save CS:IP
  578.     mov [cs:segment_status], 0      ; indicate to stop tunneling
  579.     jmp segment_exit
  580. segment_handler endp
  581. ; End of INT 1 handler using SEGMENT CHECK method
  582. ; Start of INT 1 handler using OPCODE CHECK method
  583. _override dw 0                      ; used to store current override
  584. _cs       dw 0                      ; CS of instruction being executed, needed
  585.                                     ; to simplify override usage
  586. _ds       dw 0                      ; DS before we modified it, needed to 
  587.                                     ; simplify override usage
  588.  
  589. opcode_handler proc far
  590.     push bp
  591.     mov bp, sp
  592.     push ax
  593.     push si
  594.     push ds                         ; save registers
  595.     mov ax, [bp+4]
  596.     mov [cs:_cs], ax                ; save CS
  597.     mov [cs:_ds], ds                ; save DS
  598.     mov [cs:_override], ds          ; setup override as default
  599.     lds si, [bp+2]                  ; get address of instruction into DS:SI
  600.     cld
  601. read_opcode:
  602.     lodsb
  603.     cmp al, 026h
  604.     je es_override                  ; use ES override
  605.     cmp al, 036h
  606.     je ss_override                  ; use SS override
  607.     cmp al, 02eh
  608.     je cs_override                  ; use CS override
  609.     cmp al, 03eh
  610.     je ds_override                  ; use DS override
  611.  
  612.     cmp al, 0eah
  613.     je immediate                    ; jmp far off:seg
  614.     dec si
  615.     lodsw
  616.     cmp ax, 02effh
  617.     je variable                     ; jmp far [variable]
  618.     cmp ax, 09ah
  619.     je immediate                    ; call far off:seg
  620.     cmp ax, 01effh
  621.     je variable                     ; call far [variable]
  622.  
  623. opcode_exit:
  624.     pop ds
  625.     pop si
  626.     pop ax
  627.     pop bp
  628.     iret
  629.  
  630. immediate:
  631.     lodsw
  632.     mov [cs:return_address], ax
  633.     lodsw
  634.     mov [cs:return_address+2], ax   ; save address of area we're going into
  635.     jmp opcode_exit
  636.  
  637. variable:
  638.     lodsw
  639.     mov si, ax
  640.     mov ax, [cs:_override]
  641.     mov ds, ax
  642.     jmp immediate                   ; extract off:seg
  643.  
  644. ds_override:
  645.     mov ax, [cs:_ds]
  646.     mov [cs:_override], ax
  647.     jmp read_opcode
  648. cs_override:
  649.     mov ax, [cs:_cs]
  650.     mov [cs:_override], ax
  651.     jmp read_opcode
  652. es_override:
  653.     mov [cs:_override], es
  654.     jmp read_opcode
  655. ss_override:
  656.     mov [cs:_override], ss
  657.     jmp read_opcode    
  658. opcode_handler endp
  659. ; End of INT 1 handler using OPCODE CHECK method
  660. ; Start of INT 1 handler using CS:LIST method
  661. list_begin: 
  662.     dw 015h dup(0)
  663. list_end:
  664.  
  665. list_handler proc far
  666.     push bp
  667.     mov bp, sp
  668.     push ax
  669.     push bx
  670.     mov ax, [bp+4]
  671.     lea bx, [list_begin]
  672. list_traverse:
  673.     cmp bx, offset list_end
  674.     je list_error                   ; this is a check to make sure the 
  675.                                     ; list of CS: values doesn't outgrow
  676.                                     ; the space allocated for them
  677.     cmp [cs:bx], ax
  678.     je list_exit                    ; this is if the CS: is already on the 
  679.                                     ; list
  680.     cmp word ptr [cs:bx], 0
  681.     je list_insert                  ; add us to the list if we've reached the
  682.                                     ; end of defined values
  683.     add bx, 2
  684.     jmp list_traverse               ; this moves down to the next item on 
  685.                                     ; the CS: list
  686. list_insert:
  687.     mov [cs:bx], ax                 ; put us on the list
  688.     mov [cs:return_address+2], ax
  689.     mov ax, [bp+2]
  690.     mov [cs:return_address], ax     ; save CS:IP value
  691.     jmp list_exit
  692.  
  693. list_error:
  694.     mov [cs:return_address], 0
  695.     mov [cs:return_address+2], 0    ; set error indicator
  696.  
  697. list_exit:
  698.     pop bx
  699.     pop ax
  700.     pop bp
  701.     iret
  702. list_handler endp
  703. ; End of INT 1 handler using CS:LIST method
  704. ; Start of INT 1 handler using HAND-over-HAND method
  705. hand_segment dw 0                   ; Where we save our CS: values
  706. hand_type    db 0                   ; 0=Go down
  707.                                     ; 1=Go up
  708. hand_handler proc far
  709.     push bp
  710.     mov bp, sp
  711.     push ax
  712.     mov ax, [bp+4]
  713.     cmp byte ptr [cs:hand_type], 1
  714.     je go_up
  715. go_down:
  716.     cmp ax, [cs:hand_segment]
  717.     jb hand_over_hand
  718.     jmp hand_exit
  719. go_up:
  720.     cmp ax, [cs:hand_segment]
  721.     ja hand_over_hand           
  722. hand_exit:
  723.     pop ax
  724.     pop bp
  725.     iret
  726. hand_over_hand:
  727.     mov [cs:return_address+2], ax
  728.     mov [cs:hand_segment], ax
  729.     mov ax, [bp+2]
  730.     mov [cs:return_address], ax     ; save CS:IP
  731.     jmp hand_exit
  732. hand_handler endp
  733. ; End of INT 1 handler using HAND-over-HAND method
  734. ; Start of INT 1 handler using IRET method
  735. iret_status db -1
  736. iret_handler proc far
  737.     push bp
  738.     mov bp, sp
  739.     push ax
  740.     push ds
  741.     push si
  742.     cmp [cs:iret_status], 0
  743.     je iret_exit
  744.     mov ax, [cs:return_address+2]
  745.     cmp [bp+4], ax
  746.     jne iret_save
  747.     lds si, [bp+2]
  748.     lodsb
  749.     cmp al, 0cfh
  750.     je iret_exit_detected
  751. iret_exit:
  752.     pop si
  753.     pop ds
  754.     pop ax
  755.     pop bp
  756.     iret
  757. iret_save:
  758.     mov ax, [bp+4]
  759.     mov [cs:return_address+2], ax
  760.     mov ax, [bp+2]
  761.     mov [cs:return_address], ax     ; save CS:IP
  762.     jmp iret_exit
  763. iret_exit_detected:
  764.     mov [cs:iret_status], 0
  765.     jmp iret_exit
  766. iret_handler endp
  767. ; End of INT 1 handler using IRET method
  768. ; ───────────────────────────────────────────────────────────────────────────
  769. show_int_address proc near      ; displays return_address
  770.     mov bx, [return_address+2]
  771.     call show_hex
  772.     call show_colon
  773.     mov bx, [return_address]
  774.     call show_hex
  775.     ret    
  776. show_int_address endp
  777. show_colon proc near            ; displays a colon on screen
  778.     mov ah, 2
  779.     mov dl, ':'
  780.     int 021h
  781.     ret
  782. show_colon endp
  783. show_hex proc near              ; displays a HEX number on screen
  784.     mov ch, 4
  785. rotate:
  786.     mov cl, 4
  787.     rol bx, cl
  788.     mov al, bl
  789.     and al, 0fh
  790.     add al, 030h
  791.     cmp al, '9'+1
  792.     jl print_it
  793.     add al, 07h
  794. print_it:
  795.     mov dl, al
  796.     mov ah, 2
  797.     int 021h
  798.     dec ch
  799.     jnz rotate
  800.     ret
  801. show_hex endp
  802. codesg ends
  803. end start
  804.  
  805.