News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

File downloader

Started by Vortex, December 08, 2025, 06:48:34 PM

Previous topic - Next topic

Vortex

Here is a very simple file downloader :

DownloadFile.exe http://address filename.ext
include     DownloadFile.inc

.data?

buffer      db 512 dup(?)

.code

start:

    call    main
    invoke  ExitProcess,eax

main PROC uses esi

    mov     esi,OFFSET buffer
    invoke  ParseCmdLine,esi
    cmp     eax,3
    jne     finish

    xor     ecx,ecx
    invoke  URLDownloadToFile,ecx,DWORD PTR [esi+4],\
            DWORD PTR [esi+8],BINDF_GETNEWESTVERSION,ecx
finish:

    ret

main ENDP

ParseCmdLine PROC uses esi edi ebx _buffer:DWORD

    push    0
    mov     esi,_buffer
    lea     edi,[esi+256]
    invoke  GetCommandLine
    lea     edx,[eax-1]
    mov     ax,32+256*34
    mov     ch,al
    mov     bx,9+256*9

scan:

    inc     edx
    mov     cl,BYTE PTR [edx]
    test    cl,cl
    jz      finish
    cmp     cl,al
    je      scan
    cmp     cl,bh
    je      scan
    inc     DWORD PTR [esp]
    mov     DWORD PTR [esi],edi
    add     esi,4

restart:

    mov     cl,BYTE PTR [edx]
    test    cl,cl
    jne     @f
    mov     BYTE PTR [edi],cl
    jmp     finish
@@:
    cmp     cl,ch
    je      end_of_line
    cmp     cl,bl
    je      end_of_line
    cmp     cl,ah
    jne     @f
    xor     ch,al
    xor     bl,bh
    jmp     next_char
@@:   
    mov     BYTE PTR [edi],cl
    inc     edi

next_char:

    inc     edx
    jmp     restart

end_of_line:

    mov     BYTE PTR [edi],0
    inc     edi
    jmp     scan
   
finish:

    pop     eax
    ret

ParseCmdLine ENDP

END start
Code it... That's all...