|
-
June 13th, 2009, 05:48 AM
#1
Calling DLL function that is not imported(MFC and WinMain)
Hi
We know that, WinMain is buried in the MFC Framework. OK but how can Windows call it?
I opened MFC project in VC++ and tried to find out how it imports the dll(Mfc90ud.dll) and functions in that dll. But i couldn't find it. I also disassembled the mfc90ud.dll but there is no function like WinMain in exported function list. Function names are just numbers.
So, I have 2 questions.
1-) How does VS knows that Mfc90ud.dll must be imported and Windows know that it must call a function in a dll that is imported by EXE?
2-) If i import a dll and although i do not use one of the imported function in that dll, OS can still call that function? Or OS can only call imported dll functions which are used by exe?? If the function doesn't import by exe, it is never be called?
Thanks...
-
June 13th, 2009, 10:47 AM
#2
Re: Calling DLL function that is not imported(MFC and WinMain)
There are two common ways to access code in a dll, one is to load it into your process space explicitly through the LoadLibrary() and associated functions and the other is to link your code to a library that is essentially a stub that handles all the loading and mapping.
-
June 13th, 2009, 12:15 PM
#3
Re: Calling DLL function that is not imported(MFC and WinMain)
 Originally Posted by sawer
1-) How does VS knows that Mfc90ud.dll must be imported and Windows know that it must call a function in a dll that is imported by EXE?
In your project settings you specify if you want to use MFC, if you want to use unicode and if you want to link against debug or release library statically or dynamically. The IDE figures out what it should tell the linker.
2-) If i import a dll and although i do not use one of the imported function in that dll, OS can still call that function? Or OS can only call imported dll functions which are used by exe?? If the function doesn't import by exe, it is never be called?
I don't understand what you mean with the OS calling a function in your dll. How is it going to do that?
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
-
June 13th, 2009, 01:31 PM
#4
Re: Calling DLL function that is not imported(MFC and WinMain)
WinMain, main are functions called by framework when .exe or Dll are loaded. They have different rules and not included to exported functions list. See /ENTRY linker option:
http://msdn.microsoft.com/en-us/libr...2e(VS.80).aspx
Linker creates executable with entry point address. Entry point function is called when executable is loaded.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|