What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Getting unmanaged dll function params

Pages: (2): « First [ 1 ] 2 » Last »
Getting unmanaged dll function params
Author: Message:
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
O.P. Getting unmanaged dll function params
I'm developing a plugin for msn, but my question isn't related to it directly so I ask it here...

I've got an unmanaged DLL (I guess it's written in C++). I've got some tools to view a list of functions that are in it. The function names describe the function good I hope, and there are some functions I would really like to use in my code. So I want to call them from my C# application. Of course I know I can call external functions like this:

[DllImport("MyDLL.DLL"]
public static extern bool ANiceFunction(String param);

But the problem is, I don't know the return type (bool in example above) and I don't know the params...  I can guess the return type sometimes, but not always... I tried some things but I haven't been able to get a good reaction of the dll (for example when I try int as return type it always returns 0, although I expected 1 or 2)...

I don't think it is possible, but is there a way to detect what params and/or what return type the functions have?? I doesn't have to be C#, if there is another way to detect it, it is fine by me. Or is there a code that just tries several options and can tell me which is correct? It would really help me!!

P.S. There is absolutely no documentation about this dll so I have to find it myself...
08-06-2005 08:34 AM
Profile E-Mail PM Find Quote Report
segosa
Community's Choice
*****


Posts: 1407
Reputation: 92
Joined: Feb 2003
RE: Getting unmanaged dll function params
As far as I know the return type is not stored inside the DLL at all, it's not necessary for the way DLLs work and it's the responsibility of the caller to know what it expects..

The same for the parameters. You get no clue as to what they're for unless you disassemble it and try to understand the assembly. One thing you can find out though is the name of the functions and how many parameters they take.

To do this I suggest you download OllyDbg and open your DLL with it. It'll say that it can't execute them directly and ask if it should launch LOADDLL.EXE, say yes.

Once the DLL is loaded, click on the triangle "play" button (or press F9) so that it executes the DllMain() function. Then go to the Debug -> Call DLL Export menu and you will be provided with a list of functions that were exported in the DLL and (if it is able to find it out successfully) the number of parameters they take.
The previous sentence is false. The following sentence is true.
08-06-2005 03:37 PM
Profile PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
O.P. RE: Getting unmanaged dll function params
Thanks a lot! That is interesting to know... But, it didn't help me...

It doesn't work, only at <ModuleEntryPoint> it says there are 3 parameters, and the rest hasn't been found out... So, thanks for your help, but unfortunatly it didn't help...
08-06-2005 05:24 PM
Profile E-Mail PM Find Quote Report
segosa
Community's Choice
*****


Posts: 1407
Reputation: 92
Joined: Feb 2003
RE: Getting unmanaged dll function params
I don't know what to say... technically that would mean that there are no exported functions in the DLL.. but that method has never failed me either.. dunno, sorry.
The previous sentence is false. The following sentence is true.
08-06-2005 07:17 PM
Profile PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Getting unmanaged dll function params
What DLL are you using? If you can attach it, then I can open it up in PE Explorer and see what's inside.
[Image: spartaafk.png]
08-06-2005 07:20 PM
Profile PM Web Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
O.P. RE: Getting unmanaged dll function params
It's beginning to be interesting....:)

[edit]No attachment? I think it's too big or something... P.M. me if you're interested...[/edit]

This post was edited on 08-06-2005 at 08:02 PM by J-Thread.
08-06-2005 08:01 PM
Profile E-Mail PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Getting unmanaged dll function params
At over 3MB, it most likely is.

This post was edited on 08-06-2005 at 08:45 PM by RaceProUK.
[Image: spartaafk.png]
08-06-2005 08:13 PM
Profile PM Web Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
O.P. RE: Getting unmanaged dll function params
It's 3.51 Mb, so that's the problem...

You got it racepro, so i'm looking forward to hear what you have to say about it :D;)
08-06-2005 08:44 PM
Profile E-Mail PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Getting unmanaged dll function params
I've looked in PE Explorer, and there is an Export table (otherwise no fuctions could be called easily Segosa :P). However, PE Explorer is unable to determine parameters or return types, and I couldn't find anything on the Web. There is, however, a Source SDK that may be of use, though I didn't find it myself.
[Image: spartaafk.png]
08-06-2005 08:45 PM
Profile PM Web Find Quote Report
segosa
Community's Choice
*****


Posts: 1407
Reputation: 92
Joined: Feb 2003
RE: Getting unmanaged dll function params
quote:
Originally posted by raceprouk
I've looked in PE Explorer, and there is an Export table (otherwise no fuctions could be called easily Segosa :P). However, PE Explorer is unable to determine parameters or return types, and I couldn't find anything on the Web. There is, however, a Source SDK that may be of use, though I didn't find it myself.

If there was stuff in the export table it would be the names of the functions. What are they?
The previous sentence is false. The following sentence is true.
08-07-2005 08:53 AM
Profile PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On