Archived

This topic is now archived and is closed to further replies.

jtech

DLLs and passing data

Recommended Posts

jtech    108
Is it safe to return a function pointer from a DLL (the function body is in the DLL) and use that function pointer in a program that loaded the DLL? So, this is almost like exporting a function from a DLL and using GetProcAddress, except I''m passing the function pointer explicitly through another exported function.

Share this post


Link to post
Share on other sites
GoofProg    127
Sure why not.. just make sure you access your pointers correctly. The last time I read someone talking about GetProcAddress was in a windows assembly book i was reading a few years ago. Whew =)


This is a view of ideas at work

Share this post


Link to post
Share on other sites
Brannon    122
It''s safe, until you call FreeLibrary() on the DLL. Once you call FreeLibrary() all bets are off. The system could unload the DLL at any point after that, and then your pointer would point into memory that you aren''t allowed to touch (or worse, the memory region could have been reused, and then really bad things can happen).



-Brannon

Share this post


Link to post
Share on other sites
jtech    108
Thanks, I had a feeling it was ok, but wasn''t sure.

The only reason why I want to do something like this is to
have a single point of entry into my DLL. All other functions
in the DLL can then simply be passed through a single exported
function.

Share this post


Link to post
Share on other sites