Hello everybody, I have the following code

.model flat,stdcall
include windows.inc
include kernel32.inc
include user32.inc
include wininet.inc

includelib wininet.lib
includelib kernel32.lib
includelib user32.lib
BUFFSIZE equ 65536
Browser db "Mozilla",0
SiteUrl    db "http://google.com",0
szBuff db BUFFSIZE dup(?)
hInet dd ?
hOpenUrl dd ?
bRead dd ?
hInstance dd ?
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke InternetOpen,offset Browser,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0
mov hInet,eax
invoke InternetOpenUrl,hInet,offset SiteUrl,NULL,0,INTERNET_FLAG_RELOAD,0
mov hOpenUrl,eax
invoke InternetReadFile, hOpenUrl,offset szBuff,BUFFSIZE,offset bRead
invoke InternetCloseHandle, hInet
invoke InternetCloseHandle, hOpenUrl
invoke MessageBox,NULL,offset szBuff,NULL,MB_OK
invoke ExitProcess,0
end start

The problem is that after InternetReadFile I get in buffer truncated content and can't figure out what I am doing wrong. I also tried to allocate memory with GlobalAlloc and write the content there, but i get the same truncated thing :(
Also I tried to read data in a loop, as a result I get a little bit more content but it is not full =(

lea esi,szBuff
add esi,
invoke InternetReadFile, hOpenUrl,esi,1024,offset bRead
cmp ,0
jne read

P.S. Sorry  for my poor english
P.P.P.S. Thank you very much.
Posted on 2010-08-05 17:18:50 by int20h
use InternetQueryDataAvailable right before your call to InternetReadFile.  It is truncated because your buffer is too small. InternetQueryDataAvailable will tell you how much data is gonna come your way so you can allocate a buffer big enough.
Posted on 2010-10-13 18:39:06 by Gunner