--------------------------------------code.asm--------------
Code:
format PE GUI 4.0
entry start
include 'win32a.inc'
include 'cmd.inc'
start:
invoke GetProcessHeap
mov [_hheap],eax
invoke HeapAlloc,[_hheap],HEAP_ZERO_MEMORY,1000h
mov [_b1],eax
mov [_b2],eax
call GetMainArgs
mov esi,[_argv]
mov ebx,[_argc]
add esi,4
cinvoke wsprintf,[_b1],_fmt,[esi]
add esi,4
cinvoke wsprintf,[_b2],_fmt,[esi]
invoke URLDownloadToFileA,0,[_b1],[_b2],0,0
invoke Sleep,7000
invoke HeapFree,[_hheap],0,[_argv]
invoke HeapFree,[_hheap],0,[_b1]
invoke HeapFree,[_hheap],0,[_b2]
invoke ExitProcess,0
_fmt db '"%s"',0
_hheap dd ?
_b1 dd ?
_b2 dd ?
data import
library kernel,'KERNEL32.DLL',\
urlmon,'urlmon.dll',\
user,'USER32.DLL'
import kernel,\
GetCommandLine,'GetCommandLineA',\
GetProcessHeap,'GetProcessHeap',\
HeapAlloc,'HeapAlloc',\
HeapFree,'HeapFree',\
Sleep, 'Sleep',\
ExitProcess,'ExitProcess'
import user,\
wsprintf,'wsprintfA'
import urlmon,\
URLDownloadToFileA,'URLDownloadToFileA'
end data
Ok, the problem is in this line:
invoke URLDownloadToFileA,0,[_b1],[_b2],0,0
when i invoke the function defining _b1 and _b2 like:
_b1 db 'LINK',0
_b2 db 'FILE',0
and invoking like:
invoke URLDownloadToFileA,0,_b1,_b2,0,0
it works pretty good, but if i try to do it with the given cmd parameters it just doesnt work.
How can i get it work using the given parameters?
Thanks for the help!
-----------------------------------------cmd.inc--------------------
Code:
; GetMainArgs v1.01
; Copyright © 2003 Theodor-Iulian Ciobanu
; uses heap instead of local
GetMainArgs:
pusha
invoke GetCommandLine ;_argc - number of args, _argv - ptr to arg table
mov [_argc],0
xor ebx,ebx
cmp byte [eax],22h ;quotation mark
jz .startquote
mov [_argc],1
push eax
.count:
cmp byte [eax],0
jz .endcount
cmp byte [eax],22h ;quotation mark
jz .solvequote
cmp ebx,1 ;is in quote
jz .isinquote
cmp byte [eax],20h ;space
jz .pusharg
cmp byte [eax],09h ;tab
jz .pusharg
.isinquote:
inc eax
jmp .count
.pusharg:
mov byte [eax],0
inc eax
.remspaces:
cmp byte [eax],0
jz .endcount
cmp byte [eax],22h ;quotation mark
jz .startquote
cmp byte [eax],20h ;space
jz .isspace
cmp byte [eax],09h ;tab
jnz .endremspaces
.isspace:
inc eax
jmp .remspaces
.endremspaces:
inc [_argc]
push eax
jmp .count
.solvequote:
cmp ebx,1
jz .endquote
.startquote:
mov ebx,1
inc eax
jmp .endremspaces
.endquote:
mov ebx,0
jmp .pusharg
.endcount:
mov eax,[_argc]
mov ecx,4
mul ecx
push eax
invoke HeapAlloc,[_hheap],HEAP_ZERO_MEMORY,eax
mov [_argv],eax
pop eax
sub eax,4
mov esi,[_argv]
add esi,eax
.saveargs:
cmp esi,[_argv]
jb .endsaveargs
pop eax
mov [esi],eax
sub esi,4
jmp .saveargs
.endsaveargs:
popa
ret
_argc dd ?
_argv dd ?

