News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

HttpOpenRequest problem

Started by statis, July 19, 2011, 02:25:01 PM

Previous topic - Next topic

statis

Quote from: Gunner on July 26, 2011, 10:51:57 PM
You actually don't say what you are trying to send, and send where... to a php/cgi script, to a form etc... are you trying to send form data? A picture? a zip file?  some other binary data?

You do say you found this c sample... 


Winsock should have no compatibility problems with anything.  It is windows version of sockets, problem is you have to do EVERYTHING yourself, that is why WinINET came about to make life easier for programmers, it "hides" a lot from you, but its tougher to do somethings.
after
That is only a code snippet you have data mixed in with code.... need to see the exact code you have, that is the only way we can see what is wrong.  unless you are trying to post binary data to a form/php/cgi you don't need multi-part, application/x-www-form-urlencoded will work just fine.

I mentioned a few times, the boundry is what you make it to be... can be --------myboundry >>>>> --------myboundry--

---HeYsTaRtHeRe >>>> ---HeYsTaRtHeRe-- doesn't matter as long as the last boundry marker matches the first one with  two dashes at the end.. that is the correct way...  but if you don't want to show the code you have, I am done here, good luck in your journey..

the code is :

NAME   db "xxxxxx",0 ;hided for this post
OUT     db "xxxxxx",0 ;hided for this post
lpszVerbpost   db "POST",0
lphttp        db "HTTP/1.1",0
formact2   db "/default.html",0

text1 db "Content-Type: multipart/form-data; boundary=AaB03x",0dh,0ah,0  ;i have try with final 0 delete to all part for have final bloc in finaltext

text2 db "--AaB03x",0dh,0ah
        db 'Content-Disposition: form-data; name="EventSource"',0dh,0ah,0dh,0ah
        db 'quickSearch_searchFieldId_',0dh,0ah,0

;textx
;texty

finaltext db "--AaB03x--",0dh,0ah,0

hSession dd ?
hConnect dd ?

INVOKE InternetOpen,offset NAME,INTERNET_OPEN_TYPE_PRECONFIG,0,0,0
mov hSession,eax
or   eax,eax
jz   GetError ;special subroutine

invoke InternetConnect,hSession,offset OUT,PORT,0,0,3,0,1 ;PORT is port number hided for this post, same hided OUT, it's work for alls access server
mov hConnect, eax
or   eax,eax
jz   GetError ;special subroutine

;
;after many operations section to go to multipart form
;
;

invoke HttpOpenRequest,hConnect,offset lpszVerbpost,offset formact,offset lphttp,0,0,0,1
mov hRequest, eax
or   eax,eax
jz   GetError ;special subroutine

invoke HttpAddRequestHeaders,hRequest,offset text1,-1,HTTP_ADDREQ_FLAG_ADD
if eax==0
   ;jump to subroutine for extract error code and print to screen
.endif
;
;NO ERROR AT THIS POINT, if i try complete bloc sending subroutine return error code
;
;
invoke HttpAddRequestHeaders,hRequest,offset text2,-1,HTTP_ADDREQ_FLAG_ADD
if eax==0
   ;subroutine return error code
.endif

i have only this information on formulary :
<form name="menuForm" method="post" action="/default.html" enctype="multipart/form-data">

all data's are text format...


morgot

hello
Sorry for bad English.
Where can I get a file winhttp.inc? I like it very necessary to masm32.

dedndave

good question   :bg

i looked for winhttp.h online
it does not seem to be very large - you could probably convert it to ASM syntax without too much difficulty

hutch--

Use wininet.inc and wininet.lib.


include \masm32\include\wininet.inc
includelib \masm32\lib\wininet.lib
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

dang - my eyes must be REALLY bad - lol
i looked in that file and must have skipped over something   :P

morgot

Quote from: dedndave on January 19, 2012, 08:27:18 PM
good question   :bg

i looked for winhttp.h online
it does not seem to be very large - you could probably convert it to ASM syntax without too much difficulty
I can not. I thought maybe someone else has already created such for their needs. I'm ready to buy this file.

hutch -, thanks, but Microsoft says that wininet bad multi-threaded and does not work in the context of the service. A socket for me too complicated.

dedndave

what Hutch is telling you is...
the functions are prototyped in the wininet.inc file...
InternetOpen, InternetConnect, HttpOpenRequest, HttpAddRequestHeaders

as for the constants, they may or may not be defined in windows.inc
they are not hard to add, however

EDIT - it appears that the constants are defined in windows.inc

morgot

Sorry, my English is not very good. But i want a function from winhttp and not from wininet. Where can i find them ? In my masm (version 11), there is not prototypes of winhttp functions and constants.

dedndave

ok - i found something you might be able to use   :P

Yves (ToutEnMasm) has a winhttp.inc file in his "ready to use windows sdk"
http://www.masm32.com/board/index.php?topic=8542.0

EDIT: more correctly, the file is named winhttp.sdk, which is similar to an INC file
it has the equates, structures, and prototypes
you can create an import library from the prototypes

the fun part is - everything is in French
is your French better than your English ?   :bg
what language do you speak ?

hutch--

morgot,

You are confusing the C++ header file name with the LOCATION of the function which is in wininet.lib.

winhttp.h = C++ header file 45829 bytes.

Function (API) is in WININET.LIB.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

i don't understand what you are saying, Hutch
this looks like a different group of functions

from "About WinHTTP"
QuoteMicrosoft Windows HTTP Services (WinHTTP) provides developers with a server-supported,
high-level interface to the HTTP/1.1 Internet protocol. WinHTTP is designed to be used
primarily in server-based scenarios by server applications
that communicate with HTTP servers.

WinINet was designed as an HTTP client platform for interactive desktop applications, such as
Microsoft Internet Explorer, Microsoft Office, and Microsoft Money. WinINet displays a user interface
for some operations such as collecting user credentials. WinHTTP, however, handles these operations
programmatically. Server applications that require HTTP client services should use WinHTTP instead of WinINet.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa382925%28v=vs.85%29.aspx

and, from WinHttpSendRequest...
QuoteHeader Winhttp.h
Library Winhttp.lib
DLL Winhttp.dll
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384110%28v=vs.85%29.aspx

hutch--

This is the content of winhttp.lib. It provides "WinHttpOpenRequest", not "HttpOpenRequest" which occurs in wininet.lib in both ANSI and UNICODE.



; --------------------------------------------------------------------------------------------------
;                           winhttp.inc Copyright The MASM32 SDK 1998-2010
; --------------------------------------------------------------------------------------------------

IFNDEF WINHTTP_INC
WINHTTP_INC equ <1>

SvchostPushServiceGlobals PROTO STDCALL :DWORD
WinHttpAddRequestHeaders PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WinHttpAutoProxySvcMain PROTO STDCALL :DWORD,:DWORD
WinHttpCheckPlatform PROTO STDCALL
WinHttpCloseHandle PROTO STDCALL :DWORD
WinHttpConnect PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WinHttpCrackUrl PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WinHttpCreateUrl PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WinHttpDetectAutoProxyConfigUrl PROTO STDCALL :DWORD,:DWORD
WinHttpGetDefaultProxyConfiguration PROTO STDCALL :DWORD
WinHttpGetIEProxyConfigForCurrentUser PROTO STDCALL :DWORD
WinHttpGetProxyForUrl PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WinHttpOpen PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WinHttpOpenRequest PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WinHttpQueryAuthSchemes PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WinHttpQueryDataAvailable PROTO STDCALL :DWORD,:DWORD
WinHttpQueryHeaders PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WinHttpQueryOption PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WinHttpReadData PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WinHttpReceiveResponse PROTO STDCALL :DWORD,:DWORD
WinHttpSendRequest PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WinHttpSetCredentials PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WinHttpSetDefaultProxyConfiguration PROTO STDCALL :DWORD
WinHttpSetOption PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WinHttpSetStatusCallback PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
WinHttpSetTimeouts PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WinHttpTimeFromSystemTime PROTO STDCALL :DWORD,:DWORD
WinHttpTimeToSystemTime PROTO STDCALL :DWORD,:DWORD
WinHttpWriteData PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD

ELSE
  echo ------------------------------------------
  echo WARNING duplicate include file winhttp.inc
  echo ------------------------------------------
ENDIF
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

gotcha   :U

i think there was a little confusion because of the language barrier
the code in the original post seems to represent the WinInet code he wants to replace, using WinHttp   :P

at any rate, it is a relatively small and simple include/lib pair
most of it is equates

dedndave

SvchostPushServiceGlobals
dunno where you got that one
it appears to be an undocumented seclogon.dll (secure logon) function   :P