;****************************************************************************
; NOTA PARA LOS LECTORES DE VZM. COMO PODEIS VER ESTE ES UN CODIGO MUY VIEJO
; NO HA SIDO REVISADO DESDE LA ULTIMA FECHA APUNTADA. PUEDE ESTAR MAL,
; NO HAGO CARGO (ni a mi ni a VZM) DE (im)POSIBLES DA¥OS. TRASTEA CON ALGUNAS
; INTERRUPCIONES, ESO QUIERE DECIR QUE TU ORDENATA SE PUEDE (o no) QUEDAR
; COLGADO. NO OBSTANTE SUPONGO QUE FUNCIONARA BIEN  :-)
; SIENTO LO DE LOS COMENTARIOS EN INGLES (man¡as de democoder) NO OBSTANTE
; CREO QUE EL TEXTO ES COMPRENSIBLE.  ;D
; UNA ULTIMA COSA. EL ARTICULO QUE ACOMPA¥A A ESTE PROGRAMA ES MUY CORTO Y
; EXPLICA LA TEORIA, PERO NO LA IMPLEMENTACION. Y ESTE PROGRAMA ESTA LLENO
; DE COMENTARIOS IMBECILES NO RELACCIONADOS CON EL CODIGO. ASI QUE SI QUIERES
; EXPLICACIONES ESCRIBEME:
;                               Luis Angel Rodil Fernandez
;                               c/La Paz 5, 4§D
;                               Avil‚s   33400
;                               Asturias
;
; SE ASUME UN CONOCIMIENTO MINIMO DE ENSAMBLADOR Y UN POCO SOBRE INTs  ;)
; PARA COMPRENDER SU FUNCIONAMIENTO DEBES DE TRAZAR ESTE PROGRAMA, CON
; EL TURBO DEBUGGER POR EJEMPLO. 8-)
;****************************************************************************
;****************************************************************************
;--------------------------------------------------------------------------------
; Hi! thiz is Dr.Jekyll at the keyboard. The code you're about to see is used
; to hook the 1st & 3rd interrupt in order to make your program "uncrackable"
; But remember that every thing you do to protect your program could be
; cracked sooner or latter; it only depends of the patience of the cracker.
;
; _Luis_(Dr.Jekyll)         02/01/95  0:37   #-]
;-----------------------------------------------------------------------------
;
; NOTE: This is a very old code, but a couple of days ago a friend told me that
; hooking this interrupts is a technique called ARMOURING. (I've reinvented the
; wheel once again). :_)
;
; CopyWrong-AnarchyRights (A) INFIDELIA Demo Division
; Coded by Dr.Jekyll            07/07/95  8:00pm
;------------------------------------------------------------------------------
DOSSEG
.Model Small
.Stack 100h
.386p        ; Change if U disagree

.Data

 ;INT1 = 1
 ;INT3 = 3

 OldINT1  dd ?
 OldINT3  dd ?

 CR EQU 13
 LF EQU 10
 EOL EQU CR,LF
 EOM EQU '$'

 Int1Msg Label Byte
     db 'Armouring makes your life a bit harder but, try it again!',EOL,EOM

 Int3Msg Label Byte
     db 'Real programmers write their own code. Are U any kind of LAMMER?',EOL,EOM

 ;-----------------------------
 ; SOLO EN LA VERSION PARA VZM
 PrgMsg Label Byte
     db 'Este programa no hace nada, simplemente espera a que pulses ESC.',EOL
     db 'Esto es simplemente una prueba de la t‚cnica ARMOURING. Para ver',EOL
     db 'como funciona traza el programa con el Turbo Debugger por ejemplo.',EOL
     db EOL
     db 'CopyWrong-AnarchyRights (A) INFIDELIA Demo Division',EOL,EOM
 ;-----------------------------

 ByeMsg Label Byte
     db 'Another Dr.Jekyll LEARNWARE release.',EOL
     db 'CopyWrong-AnarchyRights (A) INFIDELIA Demo Division ''95.',EOL,EOM

 ;ppx dw ?
 ;ppy dw ?
 ;ppcol db ?



.Code

;--[Exiting MACRO ]--------------------------
_Exit    MACRO Errlev, Msg

         Mov   Ax,@Data  ; Not needed but looks fine ;)
         Mov   Ds,Ax     ; ooopppss...!!!

         Mov   Ax,0003h  ; Sets an unknown video mode
         Int   10h

         Mov   Dx,OFFSET Msg   ; Displays any kind of cabalistic message
         Mov   Ah,09h
         Int   21h

         Mov   Ax,4C00h    ; Returns to the best from Bill Gate$ (DOS)  ;-)
         Add   Ax,ErrLev
         Int   21h         ; Theez is any kind of weird interrupt
      ENDM

;--[End Of Interrupt Macro ]----------------
; NOT USED IN THIZ PROGGY
_EOI    MACRO

        Mov Al,20h    ; This macro is used to tell the PIC that a hardware INT
        Out 20h,Al    ; ...has reached its end.
    ENDM
                      ; PIC stands for Programmable Interrupt Controller.

;--[NEW ISRs]--------------------------------
NewInt1 PROC  FAR       ; INT #1 is the trace interrupt. It's triggered when ...
       ;Pushf           ; ...somebody is tracing our program.
       ;Pusha
       _Exit 1,Int1Msg  ; If somebody is looking around then exit w/ error level
                        ; errlev = 1 an displays the message Int1Msg
       ;Popa
       ;Popf
       Iret             ; Thiz mnemonic is used to return from interrupts...
                        ;... a normal RET closing statement is not valid.
NewInt1 ENDP
;-----------------------

NewInt3 PROC  FAR       ; This is the BreakPoint Interrupt. It's triggered when
                        ; your program reaches a breakpoint set by the tracer.
       ;Pushf
       ;Pusha


       _Exit 1,Int3Msg
       ;Popa
       ;Popf
       Iret
NewInt3 ENDP
;------------------------
;--[FUNNY STUFF]---------
COMMENT #
PutPixel  PROC Near ; I know this routine sux ...
                    ; ...but try to understand me, it is just a test
     Pusha
     Mov   Dx,[ppy]
     Mov   Ax,Dx
     Shl   Dx,6
     Xchg  Ah,Al
     Add   Ax,Dx
     Add   Ax,[ppx]
     Mov   Di,Ax
     Mov   Dl,[ppcol]
     Mov   Es:[Di],Dl
     Popa
     Ret
PutPixel ENDP
#


Main PROC

     Mov    Ax,@Data
     Mov    Ds,Ax

     Mov    Ax,0003h
     Int    10h

     ; A¤adido para la version de VZM
     Mov    Dx,OFFSET PrgMsg
     Mov    Ah,09h
     Int    21h
     ;-------------------------------

     Mov    Ax,3501h
     Int    21h

     Mov    Word ptr ds:OldInt1,Bx
     Mov    Word ptr ds:OldInt1+2,Es

     Mov    Ax,3503h
     Int    21h

     Mov    Word ptr ds:OldInt3,Bx
     Mov    Word ptr ds:OldInt3+2,Es

     Push   Ds
     Push   Cs

     Pop    Ds

     Mov    Ax,2501h
     Mov    Dx,OFFSET NewInt1
     Int    21h

     Mov    Ax,2503h
     Mov    Dx,OFFSET NewInt3
     Int    21h

     Pop    Ds


     ; --------------------------------------------------------------
     ; The things between comments, are another way of getting &
     ; setting interrupts. This way works with all interrupts
     ; except with INT 1 & INT 3 (the ones we are hooking now)
     ; (At least this method does not work when usig Turbo Debuger)
     ; I let them Be in the release version because i think it
     ; is interesting to now diferent ways of doing things even
     ; if they don't work in this case.  ;-)
     ;---------------------------------------------------------------

     COMMENT #
     Xor    Ax,Ax
     Mov    Es,Ax

     Mov    Ax,Es:[INT1*4]
     Mov    Word ptr OldInt1,Ax
     Mov    Ax,Es:[INT1*4+2]
     Mov    Word Ptr OldInt1+2,Ax

     Mov    Ax,Es:[INT3*4]
     Mov    Word ptr OldInt3,Ax
     Mov    Ax,Es:[INT3*4+2]
     Mov    Word ptr OldInt3+2,Ax

     cli
     Mov    Word ptr Es:[INT1*4],Offset NewInt1
     Mov    Word ptr Es:[INT1*4+2],Cs

     Mov    Word ptr Es:[Int3*4],Offset NewInt3
     Mov    Word ptr Es:[Int3*4+2],Cs
     Sti
     #
     ; Now both interrupts are pointing to our shame-on-you routines X-DD
     ; Now I'm going to do a little (armoured) proggy.
     COMMENT #
     Mov   Ax,0013h
     Int   10h

     Mov   Ax,0A000h
     Mov   Es,Ax

     Mov   [ppx],160
     Mov   [ppy],100
     Mov   [ppcol],15
     Call  PutPixel  #

WaitESC:
     In    Al,60h
     Cmp   Al,01
     Jne   WaitESC

     Push  Ds
     Mov   Dx,Word ptr ds:OldInt1
     Mov   Ax,Word ptr ds:OldInt1+2
     Mov   Ds,Ax
     Mov   Ax,2501h
     Int   21h

     Mov   Dx,Word ptr ds:OldInt3
     Mov   Ax,Word ptr ds:oldInt3+2
     Mov   Ds,Ax
     Mov   Ax,2503h
     Int   21h

     Pop   Ds

     COMMENT #
     Xor   Ax,AX
     Mov   Ax,Es
     cli
     Mov   Ax,Word ptr ds:[OldInt1]
     Mov   Word Ptr Es:[INT1*4],Ax
     Mov   Ax,Word ptr ds:[OldInt1+2]
     Mov   Word ptr Es:[INT1*4+2],Ax

     Mov   Ax,Word ptr ds:[OldInt3]
     Mov   Word ptr Es:[INT3*4],Ax
     Mov   Ax,Word ptr ds:[OldInt3+2]
     Mov   Word ptr Es:[INT3*4+2],Ax
     Sti#


     _Exit 0, ByeMsg

Main ENDp

     END Main


