Jump to content
Tuts 4 You

HttpSendRequest problem


Recommended Posts

Hi guys,

need again some help.I wanna access the internet again with specific set Header datas but this with WinInet functions.So before I always used WinSock or WinInet with InternetOpenUrl API and all was going good.But as I said I wanna send specific header datas and this I cant do with InternetOpenUrl API and have to use HttpOpenRequest / HttpAddRequestHeaders & HttpSendRequest APIs but I dont get it work.



GET https://www.google.com/imghp HTTP/1.1
Host: www.google.com
Connection: close
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)

TEST1        BYTE "Host: www.google.com", 13, 10
             BYTE "Connection: close", 13, 10
             BYTE "User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)", 13, 10, 13, 10, 0

mov InternetHandle,eax

invoke InternetConnect,InternetHandle,chr$("www.google.com"),INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,NULL,NULL


invoke HttpAddRequestHeaders,REQUESTHANDLE,offset TEST1,eax,HTTP_ADDREQ_FLAG_ADD

invoke HttpSendRequest,REQUESTHANDLE, 0,0,NULL,NULL

Mostly I get failed after HttpSendRequest API or at InternetReadFile gets nothing into buffer back etc.Does anyone see the problem above?

Thank you

Link to comment

Hi kao,

ahhh ok now it works kao. :) Thanks again.

One more little question just about a problem with a EDIT Control I have created to enter datas to send.I have created a edit control with style ES_Multiline & Wantreturn etc to enter datas in this edit control.I also do use a other font and text + background color + using SetBkMode Transparent API and this I set at WM_CTLCOLOREDIT.All is working find so just so long till I enter something into this edit control so then the letters / signs etc I do enter getting smudge and looks totally bad.If I remeve ES_Multiline then all is ok or also if I remove SetBkMode API then all is ok too with the letters.So does anyone know how to fix this draw problems etc?Below a picture.



Link to comment
  • 2 weeks later...

Hi again,

I have another questions about WinInet functions.

Problem 1: I got any strange problem with InternetReadFile API.Example: I call InternetQueryDataAvailable and get the lenght of bytes back and now I call InternetReadFile API and get the bytes into my buffer but also I get zero back in eax after calling this API = false = no success and into lpdwNumberOfBytesRead I get also 0 back and as lasterror I get ERROR_SXS_MANIFEST_FORMAT_ERROR (00002EE4) 12004.Why this?I got something into buffer = same lenght like I got from InternetQueryDataAvailable API but InternetReadFile API failed at return etc.Thats strange.

Problem 2: If I use INTERNET_DEFAULT_HTTPS_PORT  paramter for InternetConnect API then I cant call some http sites anymore and get Bad Request as answer.I can switch to INTERNET_DEFAULT_HTTP_PORT paramter to get it work again but I would like to use paramter commands who handle this automatically so that I dont need to choose https or http + other paramter commands for following APIs where I need to set flags for this.So are there any paramter for this too?Normaly I have set the APIs to use https like INTERNET_DEFAULT_HTTPS_PORT & INTERNET_FLAG_SECURE to call https sites but in the case of http I get now such trouble.Does anyone have again any hints which same paramter I should use for this APIs to get success for https & http (200 OK)?Normaly I would like to call a site one time only without to check the response for problems and to call the site again with other paramters etc you know.Maybe you got some easy hints for me how to handle this issue.

Thank you

Link to comment
  • 1 month later...

Hi guys,

short question about WInInet InternetReadFile API.So I got a strange error I get from that API called 998 from system (Invalid access to memory location).But I dont know why I get this.Also the strange thing is that I get this error not always.....

Example:I start my app and enter some request datas GET xy etc.Now on the first time after I did start my app it always works but if I request the same request to site xy again I get this error above and for all next times too for this same site.If I now change the site to google for example then it works!=?Thats the strange this so for some sites it works as it should and for some I get this error (except if I restart my app again then it works on first try only).

So it cant be a API problem or any API paramter so then it shouldnt work for all right.Also I dont get this problem using WinSock APIs.For WinInet I use ssl...


InternetConnect =

....but shouldnt be the problem.I cant use ssl with WinSock so simple as for WinInet without to do some certificate stuff etc you know.

Here a example site where I get this error from above.

GET / HTTP/1.1
Host: www.rocktv.co
Connection: close

Maybe anyone of you could test this also with WinInet functions a few times to check whether you got same trouble or not.So I have really no idea what the reason for this problem could be.Just strange.

Thank you

Link to comment

Hi again,

short info.So I found the problem.I just used a wrong paramter for InternetReadFile API (dwNumberOfBytesToRead) so there I used a Pointer address. :) Sorry,was my fault again.But was also strange that it workt mostly always before.


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...