Sign in to follow this  
Followers 0

HttpQueryInfo & DllCall

5 posts in this topic

I am trying to POST some data to a website, but it seems as in order to correctly do it I need to get the header information and manage the cookies.

Func _HttpQueryInfo($l_Request) 
    Local $v_Struct = DllStructCreate('char[256]')
    DllStructSetData($v_Struct, 1, "")
    Local $ai__HttpQueryInfo = DllCall('wininet.dll', 'long', 'HttpQueryInfo', 'long', $l_Request, 'long', 22, 'ptr', DllStructGetPtr($v_Struct), 'long', 0, 'int', 0)

The return value for HttpQueryInfo is 0 (meaning an error). I don't know how to setup a buffer to take in the headers. Any help would be great. I took the struct idea from wouter, but I have no idea how to use them in theory.

$l_Request is the handle returned by HttpOpenRequest

Share this post

Link to post
Share on other sites

#2 ·  Posted (edited)

Did you find out how it should work, ParoXsitiC? Or maybe anyone else?

VB-example of HttpQueryInfo working:

Delphi-example of HttpQueryInfo working:


Thanks in advance...=)

//Edit #3:

I made some progress:

Func _HTTPQueryInfo($l_Request)
    Local $ai__HttpQueryInfo, $s_Buf = ''
    Local $v_Struct = DllStructCreate('udword')
    DllStructSetData($v_Struct, 1, 1)
    $i = 0
    For $i = 0 To 1
        $ai__HttpQueryInfo = DllCall($dll, 'int', 'HttpQueryInfo', 'long', $l_Request, 'int', 22, 'str', '', 'ptr', DllStructGetPtr($v_Struct), 'dword', 0)
        $s_Buf &= $ai__HttpQueryInfo[3]
    Local $File = FileOpen(@ScriptDir & '\temp\headers.txt', 2)
    FileWriteLine($File, $s_Buf)

It gives me this header:

HTTP/1.1 200 OK

ETag: "390241-3744-463470b1"

Content-Length: 14148

Content-Type: application/zip

Last-Modified: Sun, 29 Apr 2007 10:17:21 GMT

But still not the header(s) that Firefox shows me in LiveHTTPHeader.

I want to recieve this header:

HTTP/1.x 302 Found

Date: Sun, 16 Mar 2008 11:13:32 GMT

Server: Apache/1.3.41 (Unix) mod_deflate/1.0.19 mod_fastcgi/2.4.2 PHP/5.2.5 rus/PL30.22

X-Powered-By: PHP/5.2.5

Location: /map/

Connection: close

Content-Type: text/html; charset=windows-1251

Vary: accept-charset, user-agent

Content-Length: 0

Anyone, please? Edited by Noobster24

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post

Link to post
Share on other sites

Any Progress??

Share this post

Link to post
Share on other sites

#4 ·  Posted (edited)

You could get header "manually" (been writting about this):

Dim $sURL = ''

Dim $www = URLGetHeader($sURL)
MsgBox(0,"Header", $www)

Func URLGetHeader($URL)

    $URL = StringRegExpReplace($URL, '\A(http://|https://)(.*?)/?\Z', '$2') 
    Local $dom = StringRegExpReplace($URL, '\A(.*?)/.*', '$1') 
    Local $ip = TCPNameToIP($dom) 
    If $ip = "" Then Return -1
    Local $get = StringRegExpReplace($URL, '\A(.*?)/(.*)', '$2') 
    If $get = $dom Then $get = '' 
    Local $header = 'GET /' & $get & ' HTTP/1.1' & @CRLF _
             & 'User-Agent: Test' & @CRLF _
             & 'Host:' & @CRLF & @CRLF 

    Local $socket = TCPConnect($ip, 80) 
    If $socket = -1 Then Return -2 
    TCPSend($socket, $header) 
    Local $rcv, $out, $x, $sw, $r, $lenght
    While 1
        If $rcv <> '' Then
            $x = 1
        $rcv = TCPRecv($socket, 1024) 
        $out &= $rcv ; not needed, but who knows
        If $x = 1 Then
            If $rcv = '' Then
                $sw += 1
                If $sw = 10000 Then ExitLoop
                $sw = 0
        Local $loc = StringInStr($rcv, @CRLF & @CRLF)
        If $loc <> 0  Then 
            $out = StringLeft($out, $loc)
    Return $out

Also, read about wininet.dll

Edited by trancexx




Share this post

Link to post
Share on other sites


Thank you for the solution but i wonder if you know about a way to get the headers with the use of wininet.dll

Maybe you can help me and answer my question at the post you stated above

I'm doing benchmarks test for all the ways i knwo to interact with website..

For now i've manged to test curl and winhhtp object.

I'm now stuck with this wininet.dll because I dont even know how to call a dll...

After that i'll try to benchmark autoit tcp commands..

Share this post

Link to post
Share on other sites

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
Sign in to follow this  
Followers 0