home *** CD-ROM | disk | FTP | other *** search
/ Software Recommendations - 1998 Season 1 / DNBCD4.iso / share / compress / exe / untiny / CUNP / CUNP.ASM < prev    next >
Encoding:
Assembly Source File  |  1997-08-09  |  24.5 KB  |  920 lines

  1. ; MASM 6.0, TASM 3.x
  2.  
  3. .model  tiny
  4. .code
  5. .startup
  6. .386
  7.  
  8. DEBUG equ TRUE                          ;; 4 debugging
  9. isSCHARF equ 123                        ;; int 21 aktiv?
  10.  
  11. ;; --─────────────────────────────────────────────────────────────────────---
  12. @KBD_On Macro
  13.  
  14.         in      al, 21h
  15.         and     al, not(2)
  16.         out     21h, al
  17. ENDM
  18. ;; --─────────────────────────────────────────────────────────────────────---
  19. @NebelBomb Macro
  20.         push    bx                      ;; AX = b8, BX = bb, DX = ba
  21.         db      0bbh                    ;; Nebelbombe (Mov ax, 03ebh)
  22.         jmp     $+6                     ;; für Sourcer
  23.         pop     bx
  24.         jmp     $-3                     ;; Lästig für TD
  25.         db      09Ah                    ;; Falscher Opcode für TD
  26.         ;; hier gehts weiter
  27. ENDM
  28.  
  29. @NebelBombSmall Macro                   ;; 10.10.94
  30.         jmp     $+4
  31.         dw      $ + 8181h
  32. ENDM
  33. ;; --─────────────────────────────────────────────────────────────────────---
  34. clear_trap macro
  35.         @NebelBombSmall
  36.         push    ax
  37.         pushf
  38.         pop     ax
  39.         and     ax,0feffh
  40.         push    ax
  41.         popf
  42.         pop     ax
  43.         endm
  44.  
  45.  
  46. _start:
  47.         pushad
  48.         jmp     start
  49. orig100 dd      0123456eah
  50. lastax  dw      -3                      ; last AX, when invoked Int21
  51. lastip  dw      -2
  52. lastcs  dw      -1
  53. scharf  dw      -1
  54.  
  55. @NebelBomb
  56. introut:
  57.         pusha                           ; cs, ip, flags
  58.         pushf
  59.         push    ds
  60.         push    es
  61.         mov     di,sp
  62.         nop
  63.         add     di,18h                  ;di auf sp
  64.  
  65. ;       mov     ax, ss:[di]             ; save IP
  66. ;       mov     cs:lastip, ax
  67.  
  68.         mov     ax,cs
  69.         cmp     word ptr ss:[di+2],ax   ;im eigenen code?
  70.         je      rause
  71.         mov     ax,word ptr cs:[newseg]
  72.         nop
  73.         cmp     word ptr ss:[di+2],ax   ; segment kleiner als entryseg
  74.         nop
  75.         ja      rause
  76.         mov     ax,word ptr ss:[di]     ; offset des rücksprungs
  77.         cmp     ax,word ptr cs:[maxip]  ; größer als maxip
  78.         ja      rause
  79.         cmp     ax,word ptr cs:[minip]  ; kleiner als minip?
  80.         jb      rause
  81.  
  82.         jmp     done                    ; wieder in meine routine zurück
  83.  
  84. rause:
  85.         clear_trap
  86.         pop     es
  87.         pop     ds
  88.         popf
  89.         popa
  90. weiter:
  91.         ret
  92.  
  93. rc_count db     1
  94.  
  95. ;*************************************************************************
  96. ;
  97. ; This handler handels int 0, 1, 3 and 24h calls
  98. ;
  99. ;*************************************************************************
  100. IRet_Handler    proc far
  101.  
  102.         mov     al, 3
  103.         iret
  104.  
  105. IRet_Handler ENDP
  106.  
  107. ;**************************************************************************
  108. ;
  109. ; This handler is invoked by the own code, so be carefully by fakeing it
  110. ;
  111. ;**************************************************************************
  112. @NebelBomb
  113. int_21:
  114.         mov     cs:lastAX, AX           ; save AX, IP
  115.         push    ax
  116.         push    bp
  117.         cli
  118.         mov     bp, sp
  119.         mov     ax, ss:[bp+4]
  120.         mov     cs:lastIP, AX
  121.         mov     ax, ss:[bp+6]
  122.         mov     cs:lastCS, AX
  123.         pop     bp
  124.         pop     ax
  125.  
  126.         cmp     cs:scharf, isSCHARF       ; 0.17 - April, 8th
  127.         jne     int_21_skip
  128.  
  129.         cmp     ah, 4ah                 ; malloc?
  130.         jz      int_21_skip
  131.         cmp     ah, 0bh
  132.         jz      int_21_skip
  133.         cmp     ah, 9h                  ; print?
  134.         jnz     int_21w1
  135.         mov     si, dx                  ; index mode
  136.         cmp     word ptr ds:[si], "iG"  ; unrec patch
  137.         jz      done
  138.  
  139.         cmp     byte ptr ds:[si], "$"   ; rcc patch
  140. ifdef ELITE
  141.         jz      int_21_skip
  142. ;       jnz     int_21w1
  143. ;       cmp     cs:lastIp, 8000h
  144. ;       ja      int_21w1
  145. ;       dec     cs:rc_count
  146. ;       cmp     cs:rc_count, 0
  147. ;       jz      done
  148. else
  149.         jz      done
  150. endif
  151.  
  152. int_21w1:
  153. ;;---------------------------------------rcc 286/hard--------------------
  154.         cmp     ah, 2fh
  155.         jz      int_21_skip
  156. ifdef ELITE
  157.         cmp     ah, 3dh
  158.         jz      int_21_skip
  159.         cmp     ah, 25h
  160.         jz      int_21_skip
  161. ENDIF
  162.         cmp     ah, 35h
  163.         jz      int_21_skip
  164. ;;---------------------------------------rcc 286/hard--------------------
  165.         cmp     ah, 30h                 ; get dos ver?
  166.         jz      int_21_skip
  167.  
  168.         call    introut
  169.  
  170. int_21_skip:
  171.         db      0eah                    ;farjump
  172.         old21ofs dw -1
  173.         old21seg dw -2
  174.  
  175. @NebelBomb
  176. int_09:
  177.         call    introut
  178.         db      0eah
  179.         old09ofs dw 9
  180.         old09seg dw 10
  181.  
  182. @NebelBomb
  183. int_10:
  184.         cmp     ah, 3
  185.         jz      int_10_skip
  186.         call introut
  187. int_10_skip:
  188.         db      0eah
  189.         old10ofs dw -3
  190.         old10seg dw -4
  191.  
  192. @NebelBomb
  193. int_20:
  194.         call    introut
  195. ;       jmp     nosucc
  196.         db      0eah
  197.         old20ofs dw -5
  198.         old20seg dw -6
  199.  
  200. ;********************************************
  201. ;
  202. ; The Main Unpacker starts here....
  203. ;
  204. ;********************************************
  205. start:
  206.         clear_trap                      ; no tracing please! :))
  207.         mov     dword ptr _start, eax   ; for lame COM dumpers
  208.         @NebelBomb
  209.         cld
  210.         mov     dx, offset Intro
  211.         call    Write
  212.         @NebelBomb
  213.         mov     dword ptr start, eax    ; for lame COM dumpers
  214.  
  215.         xor     ax, ax
  216.         mov     al,byte ptr ds:[80h]    ;wenn ja al auf die länge
  217.         cmp     ax, 4
  218.         ja      paramok
  219.         mov     dx, offset help
  220.         call    Write
  221.         jmp     wech
  222. paramok:
  223.         mov     di,ax                   ;dann auf die für []
  224.         mov     byte ptr [81h+di], ah   ;null hinten hin für ah=3dh
  225.         mov     dx,82h                  ;offset vom parameter(81h=leerzeichen)
  226.  
  227.         mov     ax,3d02h
  228.         int     21h
  229.         jnc     okopen
  230.         mov     dx,offset erroropen
  231.         jmp     error
  232. okopen:
  233.         xchg    ax,bx
  234.         mov     word ptr [handle],bx    ;handle sichern
  235.         mov     ax,4202h
  236.         xor     cx,cx
  237.         cwd
  238.         int     21h                     ;ans ende seeken
  239.         jc      fopen_err
  240.         or      dx,dx
  241.         je      oksize
  242. fopen_err:
  243.         mov     dx,offset errorsize
  244.         jmp     error
  245. oksize:
  246.         mov     word ptr [filesize],ax  ;filesize sichern
  247.  
  248.         call    saveints
  249.         call    readconf
  250.         call    readfile                ; Sets up NewSeg etc.!
  251. call    setints
  252.  
  253.         push    ds
  254.         pop     es
  255.         push    cs
  256.         pop     ds
  257.  
  258.         mov     ah, 9
  259.         mov     dx, offset FileInfos
  260.         int     21h
  261.  
  262.         mov     ax, newseg
  263.         call    printax
  264.         mov     ax, minip
  265.         call    printax
  266.         mov     ax, maxip
  267.         call    printax
  268.         mov     dx, offset SizeDesc
  269.         mov     ah, 9
  270.         int     21h
  271.         sub     eax, eax
  272.         mov     ax, filesize
  273.         call    WriteDecimal
  274.  
  275.         call    SetupEnvIron
  276.  
  277.         mov     dx,offset jumping
  278.         int     21h
  279.  
  280.         mov     dx, word ptr cs:[newseg]
  281.         mov     es, dx
  282.         mov     ds, dx
  283.         mov     ss, dx
  284.         popad                           ;; from START
  285.         mov     sp, 0fffeh              ;; here bug fix for DOS
  286.  
  287.         mov     cs:scharf, isSCHARF     ;; scharf machen!
  288.  
  289.         jmp     dword ptr cs:[newofs]   ;hinspringen
  290.  
  291. protecterror:
  292.         pushad
  293.         push    ds
  294.         push    cs
  295.         pop     ds
  296.         mov     dx, offset ProtM_Msg
  297.         mov     ah, 9
  298.         int     21h
  299.         pop     ds
  300.         popad
  301.         jmp     done
  302.  
  303. int22h_handler:
  304. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  305. ; By Setting The 0Ah and the 0Ch addresses To This Code, (PSP:0Ah = INT 22)
  306. ; When Program Process ends (INT 22) it will return to here
  307.  
  308.         pushad
  309.                 push    ds
  310.                 mov     bx,cs
  311.                 mov     ah,50h                  ; Set current Proccess ID back
  312.                 int     21h                     ; To Our CODE
  313.                 pop     ds
  314.         popad
  315.  
  316. done:
  317.         mov     sp,0fffeh
  318.         push    cs
  319.         pop     ds
  320.         push    cs
  321.         pop     es
  322.         push    cs
  323.         pop     ss
  324.         call    restoreints
  325.  
  326.         push    cs
  327.         pop     ds
  328.         mov     dx, offset Back_Msg
  329.         mov     ah, 9
  330.         int     21h
  331.  
  332.         mov     ax, lastAX
  333.         call    printAX
  334.         mov     dx, offset csip
  335.         mov     ah, 9
  336.         int     21h
  337.         mov     ax, lastCS
  338.         call    printax
  339.         mov     ax, lastIP
  340.         call    printAX
  341.         mov     ah, 9
  342.         mov     dx, offset crlf
  343.         int     21h
  344.  
  345. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  346.  
  347.         PUSH    DS
  348.         mov     ds,word ptr cs:[newseg]
  349.         mov     eax, dword ptr ds:[100h]
  350.         POP     DS
  351.         cmp     eax, cs:orig100
  352.         jnz     hostchanged
  353.         mov     dx, offset notch
  354.         jmp     error
  355.  
  356. hostchanged:
  357. ;; File writeing...
  358.         mov     bx,word ptr cs:[handle] ;handle wieder her
  359.  
  360.         mov     ax,4200h
  361.         xor     cx,cx
  362.         cwd
  363.         int     21h
  364.  
  365.         mov     ds,word ptr cs:[newseg]
  366.         mov     dx,100h
  367.         mov     cx, word ptr cs:searchlen  ;!!!!!!!Filesize!!!!!!!
  368.         mov     si, cx
  369.         add     si, dx
  370.  
  371. ;; -----------------------------------nop's
  372. nopscan:
  373.         dec     si
  374.         cmp     byte ptr ds:[si], 90h
  375.         jnz     brk_nopscan
  376.         dec     cx
  377.         jnz     nopscan
  378. ;; -----------------------------------nop's
  379. brk_nopscan:
  380.         pusha
  381.         push    cs
  382.         pop     ds
  383.         mov     ah, 9
  384.         mov     dx, offset newCX
  385.         int     21h
  386.         sub     eax,eax
  387.         mov     ax, cx
  388.         call    WriteDecimal
  389.         mov     dx, offset crlf
  390.         mov     ah, 9
  391.         int     21h
  392.         popa
  393.  
  394.         mov     ds,word ptr cs:[newseg]
  395.         mov     ah,40h
  396.         int     21h
  397.         mov     ah,3eh
  398.         int     21h                     ;datei schliessen
  399.  
  400.         push    cs
  401.         pop     ds
  402.         mov     ah,09
  403.         mov     dx,offset unpacked
  404.         int     21h
  405.  
  406.         mov     dx,offset term
  407.         mov     ah,09
  408.         int     21h
  409.         jmp     wech
  410.  
  411. error2:
  412.         pusha
  413.         call    RestoreInts
  414.         popa
  415. error:
  416.         push    cs
  417.         pop     ds
  418.         mov     ah,09
  419.         int     21h
  420. wech:
  421.         in      al,21h
  422.         and     al,0fdh
  423.         out     21h,al
  424.         mov     al, 0aeh
  425.         out     64h, al
  426.  
  427.         mov     ax, 4c00h
  428.         int     21h
  429.  
  430. nosucc:
  431.         push    cs
  432.         pop     ds
  433.         push    cs
  434.         pop     es
  435.         push    cs
  436.         pop     ss
  437.         mov     sp,0fffeh
  438.         call    restoreints
  439.         in      al,21h
  440.         and     al,0fdh
  441.         out     21h,al
  442.         mov     ah,09
  443.         push    cs
  444.         pop     ds
  445.         mov     dx,offset nothin
  446.         int     21h
  447.  
  448.         jmp     wech
  449.  
  450. ; ---=[ Functions ]=---------------------------------------------------
  451. saveints:
  452.         push    0
  453.         pop     ds
  454.         xor     si,si
  455.         mov     di,offset inttab        ;ES points to DATA
  456.         mov     cx,100h                 ;komplette int-tab
  457.         cli
  458.         rep     movsd
  459.         sti
  460.         push    cs
  461.         pop     ds
  462.         mov     ax,3509h                ;benutzte ints
  463.         int     21h                     ;getrennt sichern
  464.         mov     word ptr [old09ofs],bx
  465.         mov     word ptr [old09seg],es
  466.  
  467.         mov     ax,3510h                ;benutzte ints
  468.         int     21h                     ;getrennt sichern
  469.         mov     word ptr [old10ofs],bx
  470.         mov     word ptr [old10seg],es
  471.         mov     al,20h
  472.         int     21h
  473.         mov     word ptr [old20ofs],bx
  474.         mov     word ptr [old20seg],es
  475.         mov     al,21h
  476.         int     21h
  477.         mov     word ptr [old21ofs],bx
  478.         mov     word ptr [old21seg],es
  479.         ret
  480.  
  481. ; ---=[ Functions ]=---------------------------------------------------
  482. setints:
  483.         push    cs
  484.         pop     ds
  485.         mov     ah,09
  486.         mov     dx,offset setting
  487.         int     21h
  488.         mov     ax,2509h                ;keyb int setzen
  489.         mov     dx,offset int_09
  490.         int     21h
  491.         mov     ax,2510h                ;video int setzen
  492.         mov     dx,offset int_10
  493.         int     21h
  494.         mov     al,20h                  ;int 20h
  495.         mov     dx,offset int_20
  496.         int     21h
  497.         mov     al,21h                  ;int 21h
  498.         mov     dx,offset int_21
  499.         int     21h
  500. ;----------------------------------------Protected Mode Handler---------
  501.         mov     ax, 2506h
  502.         mov     dx, offset protecterror
  503.         int     21h
  504.         mov     al, 0dh
  505.         int     21h
  506.         mov     al, 0ch
  507.         int     21h
  508. ;----------------------------------------Int 01h, int 03h Handler-------
  509.         mov     ax, 2500h
  510.         mov     dx, offset iret_handler
  511.         int     21h
  512. ifndef DEBUG
  513.         mov     al, 1
  514.         int     21h                     ; debugging int
  515.         mov     al, 3
  516.         int     21h
  517. endif
  518.         mov     al, 24h
  519.         int     21h
  520. ;----------------------------------------Int 20h, int 22h Handler-------
  521.         mov     al, 22h
  522.         mov     dx, offset int22h_handler
  523.         int     21h
  524.         mov     al, 20h
  525.         int     21h
  526.  
  527.         ret
  528.  
  529.  
  530. ; ----=[ Setup Env ]=--------------------Set up the Environment---------
  531.  
  532. SetupEnvIron proc near
  533.  
  534.         push    cs
  535.         pop     ds
  536.         mov     dx,offset trans
  537.         mov     ah,09
  538.         int     21h
  539.  
  540.         mov     ax, newseg
  541.         call    printax
  542.         mov     ah, 9
  543.         mov     dx, offset crlf
  544.         int     21h
  545.  
  546.         mov     ah,26h                  ; Create New PSP
  547.         mov     dx, newseg            ; Seg. of Allocated Mem
  548.         int     21h
  549.  
  550.         mov     bx,word ptr cs:newseg
  551.         mov     ah,50h                  ; Set current Proccess ID
  552.         int     21h                     ; to COMFILE's PSP
  553.  
  554.         push    cs
  555.         pop     ds
  556.         mov     ax,word ptr ds:newseg
  557.         mov     es,ax
  558.  
  559.         xor     si,si
  560.         xor     di,di
  561.         mov     cx,100h
  562.         rep     movsb                   ;psp übertragen
  563.         mov     byte ptr es:[80h],0     ;parameter auf 0
  564.  
  565.         mov     word ptr es:0Ah, offset int22h_handler ; COMFile-1:0001h = COMFile Seg.
  566.         mov     word ptr es:0Ch,cs      ; On CONTINUE:
  567. ;       mov     word ptr es:[080h],0D00h
  568.  
  569.         ret
  570.  
  571. SetUpEnvIron ENDP
  572.  
  573. ; ---=[ Functions ]=---------------------------------------------------
  574. RestoreInts:
  575.         ;int 3
  576. pushad
  577.         ;;      Restore INT 21h 4 printing
  578.  
  579.         mov     eax, dword ptr cs:[old21ofs]
  580.         push    0
  581.         pop     ds
  582.         mov     dword ptr ds:[21h*4], eax
  583.  
  584.         push    cs
  585.         pop     ds
  586.         mov     ah,09
  587.         mov     dx,offset restoring
  588.         int     21h
  589.         cli
  590.         push    0
  591.         pop     es
  592.         xor     di,di
  593.         mov     si,offset inttab
  594.         mov     cx,100h
  595.         cld
  596.         rep     movsd
  597.         sti
  598. popad
  599.         ret
  600.  
  601. ; ---=[ Functions ]=---------------------------------------------------
  602. readconf proc   near,
  603.  
  604.         mov     ah,09
  605.         mov     dx,offset rconf
  606.         int     21h
  607.         mov     ax,3d00h
  608.         mov     dx,offset cfile
  609.         int     21h
  610.         jnc     okopen2
  611. readc_err1:
  612.         mov     dx,offset erroropen2
  613.         mov     ah, 9
  614.         int     21h
  615.         jmp     readc_err
  616. okopen2:
  617.         xchg    ax,bx
  618.         mov     ah,3fh
  619.         mov     cx, 7
  620.         mov     dx,offset minip         ;min und max einlesen
  621.         int     21h
  622.         jc      readc_err1
  623.  
  624. readc_err:
  625.         mov     ah,3eh                  ;datei schliessen
  626.         int     21h
  627.         ret
  628.  
  629. ReadConf ENDP
  630.  
  631. ; ---=[ Functions ]=---------------------------------------------------
  632. readfile proc   near                    ; reads host
  633.  
  634.         push    cs
  635.         pop     ds
  636.         mov     ah,09h
  637.         mov     dx,offset reading
  638.         int     21h
  639.         mov     bx,word ptr [handle]    ;handle wieder her
  640.         mov     ax,4200h
  641.         xor     cx,cx
  642.         cwd
  643.         int     21h                     ;zum anfang seeken
  644.  
  645.         mov     cx, word ptr [filesize]
  646.         mov     dx, offset errorsize
  647. ;       mov     ax, 0fdf0h
  648. ;       sub     ax, offset lastbyte     ; fucking TASM!
  649.         cmp     cx, 0fd00h
  650.         jae     error2
  651.         mov     dx,100h
  652.         mov     ax,ds
  653.         add     ax,0ffffh / 16 +1       ;1 Segment above!
  654.         mov     ds,ax                   ;segmente richten
  655.         mov     word ptr cs:[newseg],ds
  656.         mov     ah,3fh
  657.         int     21h                     ;Datei einlesen
  658. ;; -[EXE-Head?]--------------------------------------------
  659.         mov     ax, word ptr ds:[100h]
  660.         mov     dx, offset noexe
  661.  
  662.         cmp     ax, "MZ"
  663.         jz      error2
  664.         cmp     ax, "ZM"
  665.         jz      error2
  666.  
  667.         mov     eax, dword ptr ds:[100h]
  668.         mov     cs:orig100, eax
  669.  
  670. ;; -------------------------- Noppen
  671.         mov     si, 101h
  672.         add     si, cs:[filesize]
  673.         mov     cx, 0fef0h
  674.         sub     cx, si
  675.         cmp     cx, 0f800h
  676.         ja      readnop_ret
  677.  
  678. readnop:
  679.         mov     byte ptr ds:[si], 90h
  680.         inc     si
  681.         loop    readnop
  682.  
  683. readnop_ret:
  684.         ret
  685.  
  686. readfile endp
  687.  
  688. ;
  689. ; This routine prints the contents of AX as a four-byte hex number.
  690. ;
  691.  
  692. ; ---=[ Functions ]=---------------------------------------------------
  693. printax proc    near,
  694.  
  695.         push    ax
  696.         call    print_hex
  697.         pop     ax
  698.         xchg    ah, al
  699.         call    print_hex
  700.         mov     dl, "h"
  701.         int     21h
  702.         mov     dl, 32
  703.         int     21h
  704.         ret
  705.  
  706. print_hex:
  707.         mov     al,ah
  708.         shr     ah,4
  709.         cmp     ah,9
  710.         jbe     next1
  711.         add     ah,7
  712. next1:
  713.         add     ah,'0'
  714.         and     al,0fh
  715.         cmp     al,9
  716.         jbe     next2
  717.         add     al,7
  718. next2:
  719.         add     al,'0'
  720.         push    cx
  721.         mov     cl,ah
  722.         mov     ch,al
  723.         mov     Ah,02
  724.         mov     Dl,cl
  725.         int     21h
  726.         mov     Ah,02
  727.         mov     Dl,ch
  728.         int     21h
  729.         pop     cx
  730.         ret
  731. printax endp
  732.  
  733. .DATA
  734. restoring: db   " ■ Restoring interrupts 00h to 0FFh",0ah,0dh,"$"
  735. term:   db      " ■ Program terminated.",0ah,0dh,"$"
  736. unpacked: db    " ■ Writing now the decrypted file to disk :-)",0ah,0dh
  737.         db      " ■ File sucessfully unpacked!?",0ah,0dh,"$"
  738. trans:  db      13, 10, " ■ Transfering PSP/PID to $"
  739. nothin: db      " ■ Could not unpack the file successful!",0ah,0dh,"$"
  740. FileInfos: db   " ■ CS, Min IP, Max IP, filelength: $"
  741. newCX:  db      " ■ New file length calculated: $"
  742. noexe:  db      " ■ EXE file header detected. Sorry, no EXE files yet supported!", 7
  743. crlf:   db      13, 10, "$"
  744. notch:  db      " ■ Sorry, host file can't be unpacked (unchanged)! Aborting!", 7, 13, 10, 7, "$"
  745. ProtM_Msg: db   " ■ pROTECTED mODE fATAL eRROR - Unpacking stopped!", 7, 13, 10, 7, "$"
  746. Back_Msg:  db   " ■ Control passed back to your handler!", 13, 10
  747.            db   " ■ Last iNT 21h call was AX=$"
  748. csip:   db      "CS:IP=$"
  749. inttab: db      400h dup (0), " thnkx to rand0m "
  750. filename: db    "CUNP_CRK.COM",0,13,10,"$"
  751. handle: dw      0
  752. filesize dw     0
  753. minip   dw      100h
  754. maxip   dw      0f600h
  755. searchlen dw    0f600h
  756. use386  db      0
  757. newofs  dw      100h
  758. newseg  dw      0
  759.  
  760. .code
  761. write   proc    near,
  762.  
  763. pusha
  764.         push    ds
  765.         pop     es
  766.         mov     si, dx
  767.         lea     bp, [volne]
  768.         mov     ah, 0fh
  769.         int     10h                     ; Get current video mode
  770.                                         ; BH - cislo aktivnej stranky
  771. zopakuj:
  772.         mov     di, bp
  773.         xor     cx, cx
  774. zoberznak:
  775.         lodsb
  776.         cmp     al, '$'
  777.         je      kresli
  778.  
  779.         or      al, al                  ; 0 -> new color
  780.         jnz     zapis
  781.         lodsb
  782.         mov     ah, al                  ; fetch new color
  783.         jmp     zoberznak
  784.  
  785. zapis:
  786.         inc     cx
  787.  
  788.         cmp     al, 20h
  789.         jnb     znak
  790.         stosb                           ; toto bude kod
  791.         jmp     co_dalej
  792.  
  793. znak:
  794.         stosw                           ; a toto znak
  795.  
  796. co_dalej:
  797.         cmp     di, offset volne+78
  798.         jna     zoberznak
  799.  
  800. kresli:
  801.         push    ax
  802.         push    cx
  803.         mov     ah, 03h                 ; read cursor pos
  804.         int     10h
  805.         pop     cx
  806.  
  807.         mov     ax, 1303h               ; write string
  808.         int     10h
  809.  
  810.         pop     ax
  811.         cmp     al, '$'
  812.         jne     zopakuj
  813. ; retazec je vypisany
  814.         popa
  815.         ret
  816. write   endp
  817.  
  818.  
  819. WriteDecimal proc near
  820.       push eax
  821.       push ebx
  822.       push ecx
  823.       push edx
  824.  
  825.       test eax, 10000000000000000000000000000000b   ; negative
  826.       je short @@3
  827.       neg eax          ; reverse the number
  828.       push eax
  829.       mov ah, 02h
  830.       mov dl, '-'      ; print a '-'
  831.       int 21h
  832.       pop eax
  833.  
  834. @@3:
  835.       mov ebx, 10
  836.       xor cx, cx
  837.  
  838. @@1:  xor edx, edx
  839.       div ebx        ; (exd:eax) / 10
  840.       push dx        ; the lowest decimal number
  841.       inc cx
  842.       or eax, eax    ; eax=0 ?
  843.       jne @@1
  844.  
  845.       mov ah, 02h
  846. @@2:  pop dx         ; number in dans dl
  847.       add dl, '0'
  848.       int 21h
  849.       dec cx
  850.       or cx, cx
  851.       jne @@2
  852.  
  853.       pop edx
  854.       pop ecx
  855.       pop ebx
  856.       pop eax
  857.  
  858.       ret
  859. WriteDecimal endp
  860.  
  861.  
  862.  
  863. .data
  864. volne   db      256 dup (7h)
  865.  
  866.  
  867. lastbyte equ    $
  868.  
  869. Intro:  db      13, 10, 0, 14
  870. db      '─┼─────── ── ─ ─ ∙·   °  .     °   ·-·-  -=[',0,3+16," 1996-97 ",0,14,']=-  -·', 13, 10
  871. db      ' │     °                                          °        ∙', 13, 10
  872. db      " .     ─═■ ",0,3+16," ROSE's Generic COM file unpacker 0.16ß ",0,14," ■═─    │", 13, 10
  873. db      " │         ─═■",0,3," Basic concept by [Ka0t & ROSE]",0,14," ■═─         .", 13, 10
  874. db      " ∙  °     ─═■",0,3," Unpacks almost EVERY real COM file ",0,14,"■═─    °  │", 13, 10
  875. db      " │     °     ",0,3,"           eLiTE vERSi0N?: ", 0,14
  876. ifdef   ELITE
  877.         db      "YES"
  878. else
  879.         db      "No!"
  880. endif
  881. db      0,14,"       °        ∙", 13, 10
  882. db      " · - -=[",0,3+16," 386++ required! ",0,14,"]=- °   .      °  ·∙ ─ ─ ── ──────┼─", 13, 10
  883. db  0,3," Immune against anti load and generic anti debugger tricks",0,14," |", 0, 7
  884. db      13,     10, "$"
  885.  
  886. help:   db      0, 3
  887.         db      " (C) by ROSE Softwareentwicklung, Dipl.-Ing. (FH) Ralph Roth, ", 13, 10
  888.         db      " Finkenweg 24, D 78658 Zimmern, FAX: +49.741-32647, Fido: 2:246/2101.2"
  889.         db      13, 10, 0, 7, 13, 10
  890.         db      "This sucker can unpack/unprotect at least:", 13, 10
  891.         db      0, 14
  892.         db      " - Protect/COM: 2.0, 4.0, 5.0, 5.5, 5.6 & 6.0", 13, 10
  893.         db      " - [GENERIC] Scrambler/Crypters: ComLock, Moshe, Rand0m, NSP,", 13, 10
  894.         db      "             Cryptcom, Rcrypt, Scramble, HDKiller, etc.", 13, 10
  895.         db      " - Pklite 1.00 - 2.01 & Scrunch 1.0x: Perfect unpacking!", 13, 10
  896.         db      " - Diet/COM 1.00 - 1.45f, Elite/COM 2.00, EXECode 1.00", 13, 10
  897.         db      " - Compack, AVPack etc.", 13, 10
  898.         db      " - ICE, Shrink, Synopsis COM Protect, Iceman Protection etc.", 13, 10
  899.         db      0, 7
  900.         db      13, 10
  901.         db      "To get the best results for Protect 5.6/6.0 etc. use the config file editor!"
  902.         db      13, 10
  903. ifndef ELITE
  904.         db      "Note... Cunp CAN UNPACK HACKSTOP and RC286 from ROSE - but NOT in this", 13, 10
  905.         db      "        public release... "
  906. endif
  907.         db      "$"
  908. ;;-----------------------------------------------------------------------------
  909.  
  910. jumping: db     " ■ Executing now the encrypted code...",0ah,0dh,"$"
  911. setting: db     " ■ Setting INTs 10h, 20h, 21h, 22h etc. Setting Protect Mode Handlers.",0ah,0dh,"$"
  912. reading: db     " ■ Reading file in buffer...",0ah,0dh,"$"
  913. rconf:  db      " ■ Reading config file "
  914. cfile:  db      "CUNP.CFG",0, 0ah,0dh,"$"
  915. SizeDesc: db    " Length: $"
  916. errorsize: db   " ■ Sorry, files only files smaller than approx. 60 KB allowed!",0ah,0dh,"$"
  917. erroropen: db   " ■ Sorry, can't open this fuckin' filez...",0ah,0dh,"$"
  918. erroropen2: db  " ■ Sorry, can't open config file! - Using default values!",0ah,0dh,"$"
  919. end
  920.