%define REPTIMES (( @end-@loop) +1) /2
%define HIDEREPTIMES ( @hide - @mover +1) /2
%define JUMPSPACE 870
%define FIRSTJUMPSPACE 870
%define BYTESCALLFAR 300
%define COPYREP (@end-@hide +1) /2
%define UNTILLSHOW 120
;
; 1. initialization
;
@start:
;Speed things up =D
mov cx, 010h
@waitloop:
wait
wait
wait
wait
loop @waitloop
cld
;MUST BE AX for the copier
mov bp, ax
;store
mov bx, ax
mov di,@end-@hide + 1
mov cx, ss
mov es, cx
add ax, @hide-@start
mov si,ax
mov cx, COPYREP
rep movsw
;end of store
mov cx, cs
mov es, cx
mov ds, cx
mov dx, bp
add dx, @mover-@start
mov bx, UNTILLSHOW
mov bp, FIRSTJUMPSPACE + (@hide - @mover) ; less to move =D
xor ch,ch
mov ax, @end-@hide + 1 ;for the mov si less to carry =D
@mover:
dec bx
jz @extract
mov si, dx
add dx,bp ;FIRSTJUMPSPACE + (@hide - @mover)
mov di, dx
mov cl, HIDEREPTIMES
rep movsw
jmp dx
@extract:
;extract
mov si, ax ; @end-@hide + 1
mov bp, ss
mov ds, bp
mov bl, @hide-@mover
add bx, dx
mov di,bx
mov cl, COPYREP
rep movsw
;end of extract
;what to hide in stack
@hide:
;start the setting
;dx SHOULD POINT TO THE START OF THE CODE (@mover)
;ASSUMES ES is set to CS
;ES is set to be the same as DS so we write
;and read from the arena
;es is also set to ds(cs) for the hider
mov bx, cs
mov ds, bx
;sets stack postion to be code segment
mov ss,bx
;DX is set to the first byte of our
;copycat code (only the part that is copied
add dx, @loop-@mover
; Copying loop
; and setting it to go forward
mov al, 0aah ;hider code dump
; Mov numberic consts to registers to save bytes
mov bx, JUMPSPACE + (@end - @loop)
jmp @copy
@loop: ;calls far here =D
loop @call_far
jmp @copy ;no more call fars.
@call_far:
call far [di] ;calls to @loop
@copy:
;set stack pointer to be before the code
mov sp, dx
;maybe should be removed
mov si, dx
add dx, bx ;JUMPSPACE + (@end - @loop)
mov di, dx
mov cl,REPTIMES
@write:
rep movsw
mov [di],dx
mov [di+2],cs
mov cl, BYTESCALLFAR / 4
call far [di] ;calls to @loop
@end:
nop
;just for the dump