Nah, still not there yet :sad: I still find problems in having the parameters passed for the VirtualAlloc function.


mov eax,lpBufferQuery
mov edx,dword ptr  ;edx = second dword in buffer
mov eax,dword ptr  ;eax = first dword in buffer


I understand the above, but how would I have them passed to the function? Homer can you please explain

Thanks,

C K
Posted on 2009-05-06 07:57:26 by karthikeyanck
Why do you want to call VirtualAlloc again , you already called it.
lpBufferQuery contains the pointer to the buffer you already allocated.
If you allocated a large enough buffer in the first place, you're ready to start reading file data  via InternetReadFile..

.data

pBuffer dd 0
dBytesDidRead dd 0
dBufferSize dd 4096
dContentSize dd 0
.code

invoke VirtualAlloc, NULL, dBufferSize , MEM_COMMIT, PAGE_READWRITE
mov pBuffer , eax

invoke HttpQueryInfo, hRequest, HTTP_QUERY_CONTENT_LENGTH, pBuffer , ADDR dContentSize , NULL

.repeat
  invoke InternetReadFile,hFile,lpBufferQuery,dBufferSize ,addr dBytesDidRead
  .if eax==TRUE
    ;dBytesDidRead now contains the amount of data we have read from file
    ;The actual data is, of course, in our buffer.

    ;<-- DO SOMETHING WITH DATA HERE

    ;Subtract the amount we managed to read from the total count
    mov eax,dBytesDidRead
    sub dContentSize,eax
  .else
    ;Something went wrong, maybe we should look up this api function on MSDN
  .endif
.until dContentSize==0    ;repeat until we have read all the data

Posted on 2009-05-06 08:34:33 by Homer