Jump to content
Sign in to follow this  
megahyperion

Dll Call to return a value/data from dll? Help me

Recommended Posts

Ok I am pretty lost on the whole dllcall.

Heres what I would like to do, I have a dll that will tell me my characters current hp in a game ( I know you guys hate these game questions and Im sorry for asking) but how would I get that information from the dll ?

I am not a new when it comes to autoit but I am a newb when it comes to anything dll related.

I have a .vbs file that uses commands to get the info from the dll but I dont know what it would mean in .AU3 language or if its even what Im looking for.

Here is a sample of what is in the vbs

'function getPlayerHP(ByRef obj)

There is the nulled out function and later down the code here is the function.

'[propget, id(13), helpstring("property PlayerHP-Health")] HRESULT PlayerHP([out, retval] LONG* pVal);
function getPlayerHP(ByRef obj)
    on error resume next
    obj.UpdateData
    getPlayerHP = obj.PlayerHP
    if Err.Number <> 0 then
        getPlayerHP = -1
    end if
    on error goto 0
end function

Anything usefull there?

Here is what I was using to try to figure it out on my own but its been 2 days and Im dead in the mud

sleep(2000)
DllOpen ("my.dll")
$data = DllCall("my.dll", "str", "dunno what goes here")
DllClose ("my.dll")
MsgBox(4096, "Test", $data, 10)

Is it even a str that I am trying to call ?

I read over the help file in autoit and looked and played with the examples multiple times but still dont understand how to get the data from the .dll

I really have no clue what im doing when it comes to dll's

Any help apreciated.

Share this post


Link to post
Share on other sites

dllcall returns an array so the return value is in $data[0]


[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

Ok do I want to keep str ? or use something else where str is ?

Also what do I put where I have "dunno what goes here" ?

Is there anything useful in the sameple vbs code that i posted ?

Share this post


Link to post
Share on other sites

This is what I have but I keep getting "subscript used with non array variable" error

sleep(500)

DllOpen ("mydll.dll")

$result = Dllcall("mydll.dll","str")

MsgBox(4096, "Test", $result[0])

DllClose ("mydll.dll")

Now I just need to know what I need after STR and if I should even be using STR , it is a string I want to return right ?

Share this post


Link to post
Share on other sites

Your example shows the use of a COM object. Is the DLL a COM server? If so, register it and use it with AutoIt as such.

Share this post


Link to post
Share on other sites

Your example shows the use of a COM object.  Is the DLL a COM server?  If so, register it and use it with AutoIt as such.

<{POST_SNAPBACK}>

Whats a com server and how would I go about using it as such in autoit ?

Thanks

Share this post


Link to post
Share on other sites

A DLL is kinda like a AutoIt include file, except it's used at runtime. The DLL needs to provide some sort of interface to be used, such as function calls or objects. You could use DllCall on some DLL's while on others you can use the AutoIt COM functions. Depends on the DLL.

We need more info on your DLL like what exactly is the name of your DLL? Where did you get it from? If its a common DLL then info on how to use it should be available.

Edited by steveR

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites

If its a  common DLL then info on how to use it should be available.

<{POST_SNAPBACK}>

Can you show us a web site with a list of common DLL's and how to use them? Edited by quick_sliver007

.

Share this post


Link to post
Share on other sites

By 'common DLL', I meant ones that are in regular use. The arthour of the DLL will usually provide info on how to use it. http://msdn.microsoft.com/library/default.asp will have info on MS DLLs.

<{POST_SNAPBACK}>

I have a hard time making heads from tails in the msdn libraray. LOL. Maybe we should make a topic in the scripts and scraps section called " DLLs with instructions" for people to post there DLLs. Or is that too much of a virus risk? Edited by quick_sliver007

.

Share this post


Link to post
Share on other sites

Go on google and look up 'free Active X componets'. There are tons of sites devoted to them. A lot written in VB. Pick one you find interesting, and read the authors instructions on how to use it. Try to make it work with AutoIt's COM commands.

It might help to read up on the Visual Basic language. It's easy to understand. And it can teach you about using DLLs and ActiveX components. Here is a great link full of info and written down to earth.

http://www.garybeene.com/

Edited by steveR

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites

Go on google and look up 'free Active X componets'. There are tons of sites devoted to them. A lot written in VB. Pick one you find interesting, and read the authors instructions on how to use it. Try to make it work with AutoIt's COM commands.

<{POST_SNAPBACK}>

I have not got around to learning the COM side of autoIt3. I just start to get a small gasp of dllcall. But, Thank you very much for all the Infomation.

.

Share this post


Link to post
Share on other sites

Ok my .dll is a dll to grab info from a game, like memlocs and all that jazz.

I got it a while ago off the net and its seems I cant track down any info on it really.

We will say its call Gamereader.dll (unless you really want the name of it)

Here is everything I have on it, and please excuse me for being a total .dll newb.

The .dll should be capable of returning multiple things like player mp, hp, position, etc.. etc..

I ran the .dll through Dumpbin.exe using the exports switch and got this.

1 ordinal base

4 number of functions

4 number of names

and heres the names of the 4 functions, I also have the ordinal , hint, and rva that it spit out if any of that is needed.,

DLLCanUnloadNow

DLLGetClassObject

DLLRegisterServer

DLLUnregisterServer

Thats them.

Now I also have a file that looks to contain some C++ about the .dll

I posted a snippet of it before but here goes again, here is a snippet of one of the functions, the rest is just the same as this over and over with different function names.

'[propget, id(2), helpstring("property PlayerStatus")] HRESULT PlayerStatus([out, retval] LONG* pVal);
function getPlayerStatus(ByRef obj)
    on error resume next
    obj.UpdateData
    getPlayerStatus = obj.PlayerStatus
    if Err.Number <> 0 then
        getPlayerStatus = -1
    end if
    on error goto 0
end function

I thought maybe there was something useful up in that nulled out part of the function, like I said total .dll newb here and I know nuthing of c++ to top it off.

Theres also a function in the .dll to return the .dll version. I seen it here in the .txt file

'function getreaderVersion(ByRef obj) //Returns a string of the gamereader.dll version.

and heres the function it points to

'[propget, id(243), helpstring("property ReaderVersion")] HRESULT ReaderVersion([out, retval] BSTR* pVal);
function getReaderVersion(ByRef obj)' //Gets the current version
    on error resume next
    obj.UpdateData
    getReaderVersion = obj.ReaderVersion
    if (Err.Number <> 0) then
        getReaderVersion = "<INVALID>
    end if
    on error goto 0
end function

Is any of that usefull ?

Share this post


Link to post
Share on other sites
  • Dll is a COM server like I said.
  • Code looks to be Visual Basic.
  • Run regsvr32 on the DLL to registry it.
  • Port the code from Visual Basic to AutoIt, that should not be hard. It should more or less just changes in syntax.

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...