News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

GetAddrInfoW issues

Started by Raistlin, February 01, 2017, 10:17:16 PM

Previous topic - Next topic

Raistlin

Hi all,

I've read MSDN 's docs on Winsock 2 but ca'nt figure why the API : GetAddrInfoW
never wants to resolve the host always returning ERRORCODE : 11001 <- host-name not found in database
even though the API for getting the value for host-name returned correctly via API : gethostname
// I even tried gethostbyname (MSDN not recommended as host-name) still same result

.data

szHostname db              17 dup (0)         
hints            addrinfo     <0,AF_UNSPEC,SOCK_STREAM,IPPROTO_TCP,0,0,0>   ; 7 x dd
hndlResult   dd               0

.code

;----init code and WSA setup here

invoke gethostname, addr szHostname, sizeof szHostname

;---returns without error - name of host correct - then later....

invoke GetAddrInfoW, addr szHostname, NULL, addr hints, addr hndlResult

;--- return eax never zero - therefore always fail ? - why ?

MSDN link sample: https://msdn.microsoft.com/en-us/library/windows/desktop/ms738520(v=vs.85).aspx

Thanks
Raistlin




Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

jj2007


Raistlin

OK JJ, even for you that is seriously criptic....
did you mean address too or something else....
as in don't use Unicode. Sorry, very confused....
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

jj2007

All *W functions require Unicode strings. Yours is db, b as in BYTE :(

Raistlin

Thanks JJ and Twell - that makes sense - I only used 'W' because the ANSI
version API call does'nt show up in RADASM (among loads of others) - probably need newer includes etc.
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...