Getting unmanaged dll function params - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Getting unmanaged dll function params (/showthread.php?tid=48561)
Getting unmanaged dll function params by J-Thread on 08-06-2005 at 08:34 AM
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...
RE: Getting unmanaged dll function params by segosa on 08-06-2005 at 03:37 PM
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.
RE: Getting unmanaged dll function params by J-Thread on 08-06-2005 at 05:24 PM
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...
RE: Getting unmanaged dll function params by segosa on 08-06-2005 at 07:17 PM
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.
RE: Getting unmanaged dll function params by RaceProUK on 08-06-2005 at 07:20 PM
What DLL are you using? If you can attach it, then I can open it up in PE Explorer and see what's inside.
RE: Getting unmanaged dll function params by J-Thread on 08-06-2005 at 08:01 PM
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]
RE: Getting unmanaged dll function params by RaceProUK on 08-06-2005 at 08:13 PM
At over 3MB, it most likely is.
RE: Getting unmanaged dll function params by J-Thread on 08-06-2005 at 08:44 PM
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
RE: Getting unmanaged dll function params by RaceProUK on 08-06-2005 at 08:45 PM
I've looked in PE Explorer, and there is an Export table (otherwise no fuctions could be called easily Segosa ). 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.
RE: Getting unmanaged dll function params by segosa on 08-07-2005 at 08:53 AM
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 ). 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?
RE: Getting unmanaged dll function params by J-Thread on 08-07-2005 at 08:59 AM
quote: There is, however, a Source SDK that may be of use, though I didn't find it myself.
Unfortunatly, i can't find the source of that dll... It's all about the game dll's and not about this one...
RE: Getting unmanaged dll function params by RaceProUK on 08-07-2005 at 04:55 PM
quote: Originally posted by Segosa
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 ). 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?
What? All 130+ of them?
|