Identifying parameter(s) on Functions in unmanaged DLLs

H

harifajri

Hi All,

We know that if we want to list down all methods/functions on an
unmanaged DLL,
we can use command-line tools 'dumpbin' or 'link '
For example, if we want to know method from user32.dll:
dumpbin /exports user32.dll
OR
link /dump /exports user32.dll

by running that comand, i could create a method (Entry Point) like
this:
using System.Runtime.InteropServices;
...
[DllImport("user32.dll", EntryPoint="MessageBoxA")]
public static extern int MsgBox( PARMETER??? );

How to identify parameter on a specific function on a DLLs?

Rgds

HF
 
N

Nicholas Paldino [.NET/C# MVP]

HF,

Are you trying to do this at run time in a program, or are you trying to
figure out what the parameters of a function are so that you can create a
P/Invoke declaration in your program? If the answer is the former, then I
really don't have an answer on how that can be done.

If the answer is the latter, then you should have examples, or better
yet, a header file which you can get the function signature from and then
figure out what the appropriate declaration in .NET should be. If it is a
Windows API function, you can look in the documentation for the signature,
the header files which come with the SDK, or you can go to
http://www.pinvoke.net which has a large number of the Windows API
signatures that you can copy and paste into .NET code. Even better, it has
a plugin which will make the process even easier.

Hope this helps.
 
H

harifajri

HF,

Are you trying to do this at run time in a program, or are you trying to
figure out what the parameters of a function are so that you can create a
P/Invoke declaration in your program? If the answer is the former, then I
really don't have an answer on how that can be done.

If the answer is the latter, then you should have examples, or better
yet, a header file which you can get the function signature from and then
figure out what the appropriate declaration in .NET should be. If it is a
Windows API function, you can look in the documentation for the signature,
the header files which come with the SDK, or you can go tohttp://www.pinvoke.netwhich has a large number of the Windows API
signatures that you can copy and paste into .NET code. Even better, it has
a plugin which will make the process even easier.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




We know that if we want to list down all methods/functions on an
unmanaged DLL,
we can use command-line tools 'dumpbin' or 'link '
For example, if we want to know method from user32.dll:
dumpbin /exports user32.dll
OR
link /dump /exports user32.dll
by running that comand, i could create a method (Entry Point) like
this:
using System.Runtime.InteropServices;
...
[DllImport("user32.dll", EntryPoint="MessageBoxA")]
public static extern int MsgBox( PARMETER??? );
How to identify parameter on a specific function on a DLLs?

HF- Hide quoted text -

- Show quoted text -


Thanks for the reply Nicholas Paldino,

I am not trying it at run time. I just try to create declaration to
invoke method on some unmanaged DLL (i.e.: yahoo messanger), which has
no SDK.

Is it possible to guess of what parameter on a functions on dll?

Rgds

HF
 
N

Nicholas Paldino [.NET/C# MVP]

I would say no, but I can't say for sure, as I've never had to hack a
dll like this. You might get some luck in a Visual C++ group to see if
there is a way to find the signatures and parameter types from just the DLL.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

HF,

Are you trying to do this at run time in a program, or are you trying
to
figure out what the parameters of a function are so that you can create a
P/Invoke declaration in your program? If the answer is the former, then
I
really don't have an answer on how that can be done.

If the answer is the latter, then you should have examples, or better
yet, a header file which you can get the function signature from and then
figure out what the appropriate declaration in .NET should be. If it is
a
Windows API function, you can look in the documentation for the
signature,
the header files which come with the SDK, or you can go
tohttp://www.pinvoke.netwhich has a large number of the Windows API
signatures that you can copy and paste into .NET code. Even better, it
has
a plugin which will make the process even easier.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




We know that if we want to list down all methods/functions on an
unmanaged DLL,
we can use command-line tools 'dumpbin' or 'link '
For example, if we want to know method from user32.dll:
dumpbin /exports user32.dll
OR
link /dump /exports user32.dll
by running that comand, i could create a method (Entry Point) like
this:
using System.Runtime.InteropServices;
...
[DllImport("user32.dll", EntryPoint="MessageBoxA")]
public static extern int MsgBox( PARMETER??? );
How to identify parameter on a specific function on a DLLs?

HF- Hide quoted text -

- Show quoted text -


Thanks for the reply Nicholas Paldino,

I am not trying it at run time. I just try to create declaration to
invoke method on some unmanaged DLL (i.e.: yahoo messanger), which has
no SDK.

Is it possible to guess of what parameter on a functions on dll?

Rgds

HF
 
W

Willy Denoyette [MVP]

HF,

Are you trying to do this at run time in a program, or are you trying to
figure out what the parameters of a function are so that you can create a
P/Invoke declaration in your program? If the answer is the former, then I
really don't have an answer on how that can be done.

If the answer is the latter, then you should have examples, or better
yet, a header file which you can get the function signature from and then
figure out what the appropriate declaration in .NET should be. If it is a
Windows API function, you can look in the documentation for the signature,
the header files which come with the SDK, or you can go tohttp://www.pinvoke.netwhich has
a large number of the Windows API
signatures that you can copy and paste into .NET code. Even better, it has
a plugin which will make the process even easier.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




We know that if we want to list down all methods/functions on an
unmanaged DLL,
we can use command-line tools 'dumpbin' or 'link '
For example, if we want to know method from user32.dll:
dumpbin /exports user32.dll
OR
link /dump /exports user32.dll
by running that comand, i could create a method (Entry Point) like
this:
using System.Runtime.InteropServices;
...
[DllImport("user32.dll", EntryPoint="MessageBoxA")]
public static extern int MsgBox( PARMETER??? );
How to identify parameter on a specific function on a DLLs?

HF- Hide quoted text -

- Show quoted text -


Thanks for the reply Nicholas Paldino,

I am not trying it at run time. I just try to create declaration to
invoke method on some unmanaged DLL (i.e.: yahoo messanger), which has
no SDK.

Is it possible to guess of what parameter on a functions on dll?

No you can't, more you shouldn't even use this function at all. If it's not documented it
means it's not a public interface, the author can remove the function or change it's
signature for every new release of the DLL.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top