By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,022 Members | 856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,022 IT Pros & Developers. It's quick & easy.

How to call a function dynamically from a DLL?

P: 1
Hi All,

I have a scenario where a windows application tries to load a 3rd party DLL and call any functions defined in that DLL.

How to call a function dynamically from a DLL

There are certain restrictions implied to this implementation, which includes:

1) Return values should be an int
2) Only primitive datatypes can be used as function parameters.

The 32-bit version of the application have this implemented with the help of inline-assemblies. Now I'm to porting this to 64-bit and have a restriction of using inline-assemblies.

So I have a scenario where I need to re-write this implementation and having trouble in identifying the signature of the function and the type of the function parameters dynamically.

Note: The existing logic is like this:

- the requested function name to call is already passed along with the values
- Loads any dll using loadLibrary()
- Get the requested function name address using getProcAddress
- Based on the count of function arguments, each argument is checked for its type and then is pushed into a custom Stack ( using Inline assemblies __asm)
- Once all the function arguments are pushed, the function pointer address is called using Inline again (call address) and everything works fine.

- now with my case, I'm able to push arguments in my own stack, but not how to pop it(because not sure about the type of the argument).

If any one had done implementations similar to this, please share your knowledge. Ur reply will be highly appreciated.

Also please let me know for any questions (i know my writing is messy )

Thanks in Advance,
Manesh S
Oct 1 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.