LCF-AT

WinSock problem

53 posts in this topic

Hi kao,

so I wanna use wpsrint API with longer format lines with %s between.Similar like the webclient does use in the header.

"GET /%s HTTP/1.0\r\nUser-Agent: %s\r\nAccept:*/*\r\n\r\n"

So the header datas are dynamic later.So I would like to use it too on that way with %s so then I dont need to use lstrcat to add each line by line etc you know but MASM / WInASM cant handle that \r\n if I use.I dont know whether there is any macro for this or something what the compiler tells to make CRLF etc.

greetz

Share this post


Link to post
Share on other sites

Might have to construct some basic defined strings to use later on with wsprintf, along with some buffers

 

.data
szHTTPHeader        DB "GET /%s HTTP/1.0",13,10,"User-Agent: %s",13,10,"Accept:*/*",13,10,13,10,0
szUserAgent         DB "My User Agent 1.0",0
szGetUrl            DB 256 DUP (0)
szOutBuffer         DB 1024 DUP (0)


Then call like so (assume szGetUrl buffer was filled in previously somewhere and is correct):

Invoke wsprintf, Addr szOutBuffer, Addr szHTTPHeader, Addr szGetUrl, Addr szUserAgent

 

1 person likes this

Share this post


Link to post
Share on other sites

EDIT: @fearless was faster, saying the exact same thing.. :)

See my previous post, it tells you exactly how to use CRLF eith Masm. This example should work just fine with wsprintfA and Masm:

buffer db 400h dup (0)
	strGetRequest db "GET /%s HTTP/1.0", 0Dh, 0Ah, "User-Agent: %s", 0Dh, 0Ah, "Accept:*/*", 0Dh, 0Ah, 0Dh, 0Ah, 0
	strServer db "www.test.com", 0
	strUserAgent db "MyMobilePhone", 0
	invoke wsprintfA, offset buffer, offset strGetRequest, offset strServer, offset strUserAgent
Edited by kao
2 people like this

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