Hi, Everyone,
I am a beginner and I am reading a .asm file. This .asm project is for encrypting a file. It runs under DOS mode,
the command to run this file is : crypt32.exe *.* key, *.* is the file which want to be encrypted and the key is the keyword for encrypting.
The following is the .asm snippet which I need help:
****************************************************************************
.code
start:
invoke GetCommandLine
mov edi, eax
invoke lstrlen, eax ;??get the length of the commandline?
sub eax, 2 ;??why substract the length by 2
mov ebx, eax
xor eax, eax
xor ecx, ecx
.while ecx!=ebx
mov edx, edi
add edx, ecx
cmp (byte ptr ), 34 ; what is the meaning ? ,why compared with 34?
sete ah ;what is the meaning of sete?
and al, ah
.if al!=0
add edx, 2
mov edi, edx
.break
.endif
inc al
inc ecx
.endw
.if ecx!=ebx
mov eax, edi
invoke lstrlen, eax
mov ebx, eax
xor ecx, ecx
.while ecx!=ebx
mov esi, edi
add esi, ecx
.if (byte ptr )==" "
mov (byte ptr ), 0
inc esi
.break
.endif
inc ecx
.endw
cmp ecx, ebx
je error
; edi = filename
; esi = crypt key
xor eax, eax
xor ebx, ebx
mov bl,
.while bl!=0
sub bl, "0"
mov ecx, eax
add eax, eax
shl ecx, 3
add eax, ecx
add eax, ebx
inc esi
mov bl,
.endw
invoke CryptFile, edi, al
.else
error: invoke MessageBox, 0, ADDR szMessage, ADDR szAppTitle, MB_OK OR MB_ICONASTERISK OR MB_APPLMODAL
jmp done
.endif
done: invoke ExitProcess, eax
********************************************************************************
Seems the function of this code snippet is to seperate the command line into two parts, one is the name of the file to be encrypted and the other is the key to encrypt to file. they are store in edi and al and used to invoke the function CryptFile...but there are still many questions and I attached them in the code above .
Please help me and thanks in advance.
waitting online....
Ian
Dec.,9,2002
:confused:
I am a beginner and I am reading a .asm file. This .asm project is for encrypting a file. It runs under DOS mode,
the command to run this file is : crypt32.exe *.* key, *.* is the file which want to be encrypted and the key is the keyword for encrypting.
The following is the .asm snippet which I need help:
****************************************************************************
.code
start:
invoke GetCommandLine
mov edi, eax
invoke lstrlen, eax ;??get the length of the commandline?
sub eax, 2 ;??why substract the length by 2
mov ebx, eax
xor eax, eax
xor ecx, ecx
.while ecx!=ebx
mov edx, edi
add edx, ecx
cmp (byte ptr ), 34 ; what is the meaning ? ,why compared with 34?
sete ah ;what is the meaning of sete?
and al, ah
.if al!=0
add edx, 2
mov edi, edx
.break
.endif
inc al
inc ecx
.endw
.if ecx!=ebx
mov eax, edi
invoke lstrlen, eax
mov ebx, eax
xor ecx, ecx
.while ecx!=ebx
mov esi, edi
add esi, ecx
.if (byte ptr )==" "
mov (byte ptr ), 0
inc esi
.break
.endif
inc ecx
.endw
cmp ecx, ebx
je error
; edi = filename
; esi = crypt key
xor eax, eax
xor ebx, ebx
mov bl,
.while bl!=0
sub bl, "0"
mov ecx, eax
add eax, eax
shl ecx, 3
add eax, ecx
add eax, ebx
inc esi
mov bl,
.endw
invoke CryptFile, edi, al
.else
error: invoke MessageBox, 0, ADDR szMessage, ADDR szAppTitle, MB_OK OR MB_ICONASTERISK OR MB_APPLMODAL
jmp done
.endif
done: invoke ExitProcess, eax
********************************************************************************
Seems the function of this code snippet is to seperate the command line into two parts, one is the name of the file to be encrypted and the other is the key to encrypt to file. they are store in edi and al and used to invoke the function CryptFile...but there are still many questions and I attached them in the code above .
Please help me and thanks in advance.
waitting online....
Ian
Dec.,9,2002
:confused:
i Can't :mad:
Hi, drakoforma,
You are so kind... :)
You are so kind... :)
invoke lstrlen, eax ;??get the length of the commandline?
** Yes **
sub eax, 2 ;??why substract the length by 2
** Because it assume the command line is wrapped in inverted commas (")
cmp (byte ptr ), 34 ; what is the meaning ? ,why compared with 34?
** Because 34 is ASCII character code for "
sete ah ;what is the meaning of sete?
** sete is an instruction, it sets the byte size register specified (it only works on byte long registers) to NOT(Zero_Flag). This instruction is the same as setz.
Mirno
** Yes **
sub eax, 2 ;??why substract the length by 2
** Because it assume the command line is wrapped in inverted commas (")
cmp (byte ptr ), 34 ; what is the meaning ? ,why compared with 34?
** Because 34 is ASCII character code for "
sete ah ;what is the meaning of sete?
** sete is an instruction, it sets the byte size register specified (it only works on byte long registers) to NOT(Zero_Flag). This instruction is the same as setz.
Mirno
Mirno,
Thank you very much for your help!
Ian
Dec.,9,2002
Thank you very much for your help!
Ian
Dec.,9,2002