Board index » delphi » How to find out parameters of DLL functions ?

How to find out parameters of DLL functions ?

We cannot find our header file for a DLL we have written and are
trying to find out the parameters of the exported functions in a DLL.

We have the IMPDEF utility which tells us the function names but not
the parameters.

Can anyone offer any suggestions ?

 

Re:How to find out parameters of DLL functions ?


Quote
Steve Govis wrote:

> We cannot find our header file for a DLL we have written and are
> trying to find out the parameters of the exported functions in a DLL.

> We have the IMPDEF utility which tells us the function names but not
> the parameters.

        I could be wrong, but I'm pretty certain that this is literally
impossible - "what are the parameters" is simply not part of the
application-dll interface.

        I mean impossible, not just tricky: My impression is that if
you have a dll function

ADllFunction(b: byte; n: longint);

and you call it passing the parameters in the wrong order it won't
matter, the function will simply take the first byte of the longint
you pass and treat it as the b parameter, and take the byte and
the rest of the long and treat it as the n parameter. ("Won't
matter": of course you won't get the results you want if you do
that, but unless I have it all wrong there's no way for the dll
to know that you had the parameters backwards - it's just looking
for 5 bytes on the stack.)

--
David Ullrich

?his ?s ?avid ?llrich's ?ig ?ile
(Someone undeleted it for me...)

Re:How to find out parameters of DLL functions ?


David Ullrich <ullr...@math.okstate.edu> wrote in article
<3330370F.5...@math.okstate.edu>...

Quote
> Steve Govis wrote:

> > We cannot find our header file for a DLL we have written and are
> > trying to find out the parameters of the exported functions in a DLL.

[...]

Quote
>    I could be wrong, but I'm pretty certain that this is literally
> impossible - "what are the parameters" is simply not part of the
> application-dll interface.

>    I mean impossible, not just tricky: My impression is that if
> you have a dll function

"Impossible" is pretty strong language in this business.

In their book "Undocumented Windows" (Schulman, Maxey, Pietrak
Addison Wesley 1992) the authors outline some clever techniques for
working this stuff out.  They did it, in fact, for a number of
undocumented exports in the Win31 DLLs.

It's tricky, possibly very time consuming, and probably not
worth the trouble in most cases.

But not impossible.

//ns

--
Nello Sestini
Chiangmai                       ne...@loxinfo.co.th
THAILAND                        fax: 66 53 429-302
GMT+7                           PGP public key avail by request

Re:How to find out parameters of DLL functions ?


Quote
David Ullrich <ullr...@math.okstate.edu> wrote:
>Steve Govis wrote:

>> We cannot find our header file for a DLL we have written and are
>> trying to find out the parameters of the exported functions in a DLL.

>> We have the IMPDEF utility which tells us the function names but not
>> the parameters.

>    I could be wrong, but I'm pretty certain that this is literally
>impossible - "what are the parameters" is simply not part of the
>application-dll interface.

>    I mean impossible, not just tricky: My impression is that if
>you have a dll function

There  *may*  be a trick which uses the name mangling used by many C++
compilers. I have NEVER done this, would not know HOW to do this - it is just an
idea which MAY yield a result.

You are definitely better off finding the header file.
--
Stefan.Hoffmeis...@UNI-Passau.DE
http://kakadu.rz.uni-passau.de/~w4hoff01/
University of Passau, Bavaria, Germany

Re:How to find out parameters of DLL functions ?


Quote
Nello Sestini wrote:

> David Ullrich <ullr...@math.okstate.edu> wrote in article
> <3330370F.5...@math.okstate.edu>...
> > Steve Govis wrote:

> > > We cannot find our header file for a DLL we have written and are
> > > trying to find out the parameters of the exported functions in a DLL.

> [...]

> >       I could be wrong, but I'm pretty certain that this is literally
> > impossible - "what are the parameters" is simply not part of the
> > application-dll interface.

> >       I mean impossible, not just tricky: My impression is that if
> > you have a dll function

> "Impossible" is pretty strong language in this business.

> In their book "Undocumented Windows" (Schulman, Maxey, Pietrak
> Addison Wesley 1992) the authors outline some clever techniques for
> working this stuff out.  They did it, in fact, for a number of
> undocumented exports in the Win31 DLLs.

> It's tricky, possibly very time consuming, and probably not
> worth the trouble in most cases.

> But not impossible.

        Do they work it out by trying this and that to see what
works? Of course that's possible - when I say this is impossible
what I mean is that the information about what type the parameters
are supposed to be is not stored anywhere in the dll.

        Or do they do some sort of disassembly???

        It _is_ true, is it not, that if the dll function wants
a byte and a long and you pass it a long and a byte there's
no way to determine that there was an error (except by noticing
that the function did the wrong thing - there's literally no
way to determine this at compile time?)

        OK, let's put it this way: It's "easy" to write something
that displays the names of the exported functions in a dll. Is
it possible to write something that displays the parameters
required by looking at the dll, without executing anything?

--
David Ullrich

?his ?s ?avid ?llrich's ?ig ?ile
(Someone undeleted it for me...)

Other Threads