Jump to content

Need HELP from experienced DllCall user...


dv8
 Share

Recommended Posts

I need some help from experienced DllCall user, to call the function gethostbyaddr from Ws2_32.dll.

I made this:

$test = DllCall("WS2_32.DLL","ptr","gethostbyaddr","string","10.1.128.101","int",4,"int","AF_INET")
MsgBox(64,"","Error: "&@error)

and I get no error. (@error=0)

But the gethostbyaddr function returns a pointer to the hostent structure, and I don't know what to do with it... :P

Please, any suggestions??? :whistle:

;)

Link to comment
Share on other sites

mmm try to create the structure by :

$rep=dllstructcreate("long;long;long") before to call this dll

it seems to be an easy function, and useful

will take a look on it, because i need some train ^^

struct HOSTENT* FAR gethostbyaddr(

const char* addr,

int len,

int type

);

FYI your not in the support forum here :/

with 93 messages, it's not good

Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

so, did you try to create the structure before to call the function

if you want some more help, look at the functions of paulIA : AutoIT3Lib

edit : oups,your problems are over ^^

Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

Larry, please be more specific. I tried to find this function in the helpfiles, with no luck. I serched the forums and still no luck. :whistle:

so, did you try to create the structure before to call the function

if you want some more help, look at the functions of paulIA : AutoIT3Lib

edit : oups,your problems are over ^^

I tried this:

$Hostent = DllStructCreate("char;char;short;short;char")
MsgBox(0,"StructCreateError:",@error)

$Test = DllStructGetSize($Hostent)
MsgBox(0,"StructSize:",$Test)

$pHostent = DllStructGetPtr($Hostent)
MsgBox(0,"GetPtrError:",@error)

$pHostent = DllCall("WS2_32.DLL","ptr","gethostbyaddr","string","10.1.128.108","int",4,"int","AF_INET")
MsgBox(0,"DllCallError:",@error)

$Test = DllStructGetSize($Hostent)
MsgBox(0,"StructSize:",$Test)

$Test1 = DllStructGetData($Hostent,1)
MsgBox(0,"GetData1",$Test1)
$Test1 = DllStructGetData($Hostent,2)
MsgBox(0,"GetData2",$Test1)
$Test1 = DllStructGetData($Hostent,3)
MsgBox(0,"GetData3",$Test1)
$Test1 = DllStructGetData($Hostent,4)
MsgBox(0,"GetData4",$Test1)
$Test1 = DllStructGetData($Hostent,5)
MsgBox(0,"GetData5",$Test1)

But it still doesn't work. ;)

Link to comment
Share on other sites

I Think your going to need to write a wrapper for that in C++, because the actual return value of that function is a structure.

LPSTR DLL_EXPORT GETHOSTADDRESS(LPSTR Address)
{
    HOSTENT* MyInfo = gethostbyaddr(Address, sizeof(Address), AF_INET);
    return (LPSTR)MyInfo->h_name;
}

maybe something like that....

Edited by CHRIS95219
Link to comment
Share on other sites

Larry, please be more specific. I tried to find this function in the helpfiles, with no luck. I serched the forums and still no luck. :whistle:

I tried this:

$Hostent = DllStructCreate("char;char;short;short;char")
MsgBox(0,"StructCreateError:",@error)

$Test = DllStructGetSize($Hostent)
MsgBox(0,"StructSize:",$Test)

$pHostent = DllStructGetPtr($Hostent)
MsgBox(0,"GetPtrError:",@error)

$pHostent = DllCall("WS2_32.DLL","ptr","gethostbyaddr","string","10.1.128.108","int",4,"int","AF_INET")
MsgBox(0,"DllCallError:",@error)

$Test = DllStructGetSize($Hostent)
MsgBox(0,"StructSize:",$Test)

$Test1 = DllStructGetData($Hostent,1)
MsgBox(0,"GetData1",$Test1)
$Test1 = DllStructGetData($Hostent,2)
MsgBox(0,"GetData2",$Test1)
$Test1 = DllStructGetData($Hostent,3)
MsgBox(0,"GetData3",$Test1)
$Test1 = DllStructGetData($Hostent,4)
MsgBox(0,"GetData4",$Test1)
$Test1 = DllStructGetData($Hostent,5)
MsgBox(0,"GetData5",$Test1)

But it still doesn't work. ;)

I believe Larry meant TCPNameToIP(). Not sure though.

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

arcker, did you try anything about this function?

I couldn't make it run properly.

I need it for my program VNC Control.

Now I'm using NBTSTAT.EXE and parsing the output, but it does not work properly on some computers.

That's why I need this funcion.

Please, anyone, any ideas?

:whistle:

Have you tried to parse the output from nslookup.exe? You will need a properly configured reverse DNS zone for the IP ranges you are trying to query.

---------Arthur B

Link to comment
Share on other sites

  • 2 weeks later...

I still need help on this PLS. ;)

did you even try to use the search function of the forum????

Searching for gethostbyaddr gave me this:

http://www.autoitscript.com/forum/index.ph...st&p=267014

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

did you even try to use the search function of the forum????

Searching for gethostbyaddr gave me this:

http://www.autoitscript.com/forum/index.ph...st&p=267014

Cheers

Kurt

I tryed, but this post wasn't there when I first started this topic... :">

Thank you for pointing it out!!!

I think this will solve my problem. ;)

Link to comment
Share on other sites

I tryed, but this post wasn't there when I first started this topic... :">

Thank you for pointing it out!!!

I think this will solve my problem. ;)

never mind, maybe piccaso was inspired by your request....

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...