The MASM Forum

General => The Campus => Topic started by: Raistlin on February 01, 2017, 10:17:16 PM

Title: GetAddrInfoW issues
Post by: Raistlin on February 01, 2017, 10:17:16 PM
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




Title: Re: GetAddrInfoW issues
Post by: jj2007 on February 01, 2017, 10:22:36 PM
W ::)

szHostname db
Title: Re: GetAddrInfoW issues
Post by: Raistlin on February 02, 2017, 06:44:31 AM
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....
Title: Re: GetAddrInfoW issues
Post by: jj2007 on February 02, 2017, 07:25:37 AM
All *W functions require Unicode strings. Yours is db, b as in BYTE :(
Title: Re: GetAddrInfoW issues
Post by: Raistlin on February 02, 2017, 04:10:12 PM
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.