谁再帮我看看这程序,100啊,MACH你还在吗?
程序中我还有很多具体的问题,我写上了注释,能不能帮我看一下,谢谢了!
不好意思,好人做到底啊!
code segment assume cs:code,ds:code org 100h
addprog proc far mov ax,cs mov ds,ax
mov psp,es mov es,ax mov save_ss,ss
mov save_sp,sp mov sp,cs mov ss,sp
mov sp,offset stack_ptr mov ax,psp
add souc_seg,ax add souc_seg,10h
mov cx,6;为什么是六,是循环次数吗?input: mov ah,9 lea dx,dirmsg
int 21h push cx;为什么要进栈保留起来? mov cx,32
lea di,passwordget_input: mov ah,8 int 21h
stosb cmp al,0dh jz compare
mov ah,2 mov dl,42;是输出ascii码是42的字符吗?"b"?
int 21h loop get_input
compare: pop cx;用到了刚才保留起来的cx,干什么用? mov dl,0dh mov ah,2
int 21h lea si,password add si,4;为什么要加四?
mov di,siload: lodsb not al;为什么要取反 stosb
cmp al,0ffh jz on_comp cmp al,0f2h
jnz loadon_comp: lea si,keyword lea di,password
add di,4comp: cmpsb jnz wr_input dec si
lodsb cmp al,0f2h jz end_comp
jmp compwr_input: mov ah,9 lea dx,wrong
int 21h loop input
jmp cs:reset;跳转到什么地方去,cs是段基址,reset是偏移量是吗?那么reset现在是什么?赋过值了吗?
end_comp: lea dx,right mov ah,9 int 21h
chain_back: cmp byte ptr isexe,0 je com_back
lea bx,password mov ax,[bx];以下这几句是在干什么?为什么要相加,bx+2是要干什么?
add souc_seg,ax mov ax,[bx+2] add souc_off,ax
jmp returncom_back: lea bx,password mov ax,psp
mov es,ax lea si,head_save mov di,100h
mov cx,10h;为什么循环10次?loadw: lodsw xor ax,[bx];为什么要异或?
xor ax,[bx+2] stosw loop loadw
return: mov sp,save_sp push cs:souc_seg
push cs:souc_off mov dx,psp mov es,dx
mov ds,dx xor si,si xor di,di retf
save_ss dw ?save_sp dw ?souc_off dw ?souc_seg dw ?
dirmsg db 09h,09h,'Enter your PASSWORD here ... $'
right db 0dh,0ah,09h,09h,' Program continued ... ',0dh,0ah,'$'
wrong db 0dh,0ah,09h,09h,' Wrong password !',0dh,0ah,'$'
reset label dwordreset_off dw 0fff0hreset_seg dw 0f000h
psp dw ?isexe db 0head_save db 20h dup(0)
pro_stack dw 20h dup(0)stack_ptr dw 0keyword db 16 dup(0)
password db 32 dup(0)buff db 1024 dup (0)endprog label word
addprog endpmain: mov ax,ds
mov cs:psp_seg,ax ;psp_seg现在是什么内容,是将它的首地址做偏移地址吗?
push cs pop es
mov al,byte ptr ds:[80h] ;[80]是什么意思,80从何而来? push cs
pop ds cmp al,0 jz main_help
call get_name jnc continue lea dx,dmsg1
mov ah,9 int 21h lea dx,keybuf
mov ax,0c0ah ;get keyboard buffer ;0a是功能号吧?我没查到0a号功能是做什么的
int 21hcontinue: call get_pass ;这段里用了jc,有cf标志位判断是否跳转,可它所调用的子
程序中并没有修改标志位呀? jc main_ret call find_file
jc main_ret call add_file jc main_ret
mov bx,handle mov ah,3eh
int 21h ;close file lea dx,msg4
mov ah,9 int 21hmain_ret: mov ax,4c00h
int 21h ;main program endmain_help: mov ah,9
lea dx,help int 21h jmp main_ret
get_name proc near push ds mov ax,psp_seg
mov ds,ax mov si,82h ;为什么是82,从何而来?
lea di,filename mov ds,cs:psp_seg
call parsename mov al,0 stosb
inc si mov ch,00 mov cl,byte ptr ds:[80h]
add cx,82h cmp cx,si jne get_word
stc pop ds retget_word: lea di,key_cs
call parsename mov al,0dh stosb
pop ds retparsename: cld
m01: cmp byte ptr [si],' ';以下这一段是表示,用户敲空格,分号,/,逗号等都可表示密码输入结束吗?
jne m02 inc si jmp m01
m02: cmp byte ptr [si],';' je m03
cmp byte ptr [si],' ' je m03
cmp byte ptr [si],'/' je m03
cmp byte ptr [si],',' je m03
cmp byte ptr [si],0dh je m03
cmp byte ptr [si],0ffh je m03 movsb
jmp m02m03: retget_name endpget_pass proc near
lea si,chars lea di,keyword ;get password
get_char: lodsb not al stosb cmp al,0ffh
jz get_ret cmp al,0f2h jnz get_char
get_ret: retget_pass endpfind_file proc near lea dx,buffer
mov ah,1ah int 21h lea dx,filename
mov ah,4eh int 21h jnc openfile1
lea dx,msg1ferr_ret: mov ah,9 int 21h stc
retopenfile1: lea dx,filename mov al,2
mov ah,3dh int 21h ;open file for read/write
mov handle,ax lea dx,msg2 jc ferr_ret
retfind_file endpadd_file proc near
lea dx,buffer ;read file head mov bx,handle
mov cx,20h mov ah,3fh int 21h
or ax,ax jz point_err lea di,buffer
cmp [di],5a4dh ;EXE file ;比较文件的头是不是5a4d?为什么?如果是
就是exe文件吗?这是它的特点吗? jnz no_exe mov isexe,1
call head_dealwrite: call to_head ;move pointer to head
call write_head jc point_err
call to_tail ;move pointer to tail call write_file
jc point_err retpoint_err: lea dx,msg2
mov ah,9 int 21h stc ret
no_exe: mov isexe,0 lea si,buffer lea di,head_save
mov cx,10htransfer: lodsw ;为什么要循环10次
xor ax,key_ip,这两句是什么意思? xor ax,key_cs stosw
loop transfer mov souc_off,100h
mov souc_seg,0fff0h call to_tail add ax,1fh
and ax,0fff0h mov cs:file_low,ax
mov cs:file_high,dx mov cl,4 shr ax,cl
mov cx,20h lea si,com_head lea di,buffer
mov [si+1ah],ax mov [si+18h],0630h rep movsb
jmp writecom_head: mov dx,cs mov ax,cs:[11ah]
add ax,dx push ax mov ax,100h
push ax retfnull db 20h dup(0)sub_ret: ret
add_file endphead_deal proc near mov ax,[di+14h]
sub ax,key_ip mov souc_off,ax ;source code offset
mov ax,[di+16h] sub ax,key_cs
mov souc_seg,ax ;source code segment call to_tail
add ax,1fh adc dx,0 and ax,0fff0h
mov cs:file_low,ax mov cs:file_high,dx
mov cx,10h div cx sub ax,10h
sub ax,[di+08h] mov word ptr [di+14h],100h ;new cs offset
mov word ptr [di+16h],ax ;new cs segment
mov ax,cs:file_low mov dx,cs:file_high
lea cx,endprog sub cx,100h add ax,cx
adc dx,0 mov cx,200h div cx inc ax
mov [di+2],dx mov [di+4],ax ret
head_deal endpto_tail proc near
mov ax,4202h ;move pointer to file tail mov cx,0
mov dx,0 int 21h retto_tail endp
to_head proc near mov ax,4200h ;move pointer to file head
mov cx,0 mov dx,0 int 21h ret
to_head endpwrite_head proc near
mov ah,40h ;write file head lea dx,buffer
mov cx,20h;cx代表写入字节数,这里为什么写入20个字节 int 21h ret
write_head endpwrite_file proc near mov dx,100h
mov cx,cs:file_low ;file_low从何而来?
sub cx,ax ;这几句中的甲减运算是什么意思? sub dx,cx
mov ax,cx lea cx,endprog add cx,ax
sub cx,100h mov ah,40h int 21h ret
write_file endp
help db 'LOCK (R) Version 4.00a Copyright (C) Technique Department 1993-
94.' db 0dh,0ah,'Examples:'
db 0dh,0ah,' LOCK drive:\path\[filename]'
db 0dh,0ah,' LOCK [filename] [password]'
db 24h
dmsg1 db 'Software (R) File Lock Utility (tm) Version 4.00a'
db 0dh,0ah
db 'Copyright (C) Technique Department 1993-94. All rights reserved.
' db 0dh,0ah,0dh,0ah
db 'KEYWORD of source file (at least 5 characters): $'
msg1 db 0dh,0ah,'File can not find.$'
msg2 db 0dh,0ah,'File can not read or disk is full.$'
msg3 db 0dh,0ah,'Not EXE file.$'
msg4 db 0dh,0ah,'File lock successfully.$'psp_seg dw 0
file_low dw 0file_high dw 0keybuf db 32humchar db 0
key_cs dw 0key_ip dw 0chars db 28h dup(0)handle dw 0
filename db 16h dup(?)buffer db 20h dup(?)buff1 db 1024 dup (0)
code ends end main