Loading dll in c++
-
Use the LoadLibraryEx()[^] function.
It's time for a new signature.
Yeah,I have loaded the dll and its returning 0x11000000 value in HINSTANCE But while getting the address of that function,its returning value 0x00000000. Whats the reason? If we open a dll in notepad, it should contain the function names right? but this is dll is not showing any fn names in notepad. Please tell me why GetProcAdress is returning NULL value? Thanks,
-
Yeah,I have loaded the dll and its returning 0x11000000 value in HINSTANCE But while getting the address of that function,its returning value 0x00000000. Whats the reason? If we open a dll in notepad, it should contain the function names right? but this is dll is not showing any fn names in notepad. Please tell me why GetProcAdress is returning NULL value? Thanks,
Maybe a function name mangling issue. Why don't you use the
Dependecy Walker
tool [^] to see function names? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Yeah,I have loaded the dll and its returning 0x11000000 value in HINSTANCE But while getting the address of that function,its returning value 0x00000000. Whats the reason? If we open a dll in notepad, it should contain the function names right? but this is dll is not showing any fn names in notepad. Please tell me why GetProcAdress is returning NULL value? Thanks,
-
Yeah,I have loaded the dll and its returning 0x11000000 value in HINSTANCE But while getting the address of that function,its returning value 0x00000000. Whats the reason? If we open a dll in notepad, it should contain the function names right? but this is dll is not showing any fn names in notepad. Please tell me why GetProcAdress is returning NULL value? Thanks,
Put this before class and function names that you want to export from the dll.
extern "C"
This will prevent the C++ way of mangling the names. Theres nothing wrong in mangling but if you export a function like
int Sum(int, int)
C++ will NOT reduce that to _Sum, like C and like you might expect. That means when you import that into your program, you can't simply search for "Sum" but have to follow C++ name mangling rules and search for THAT name.
...byte till it megahertz...
-
Maybe a function name mangling issue. Why don't you use the
Dependecy Walker
tool [^] to see function names? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Have you correctly exported your function names with
__declspec(dllexport)
?It's time for a new signature.
-
Karthika85 wrote:
This dll is given by a vendor.
Then they are the people you need to talk to, as they should have both the source code and the instructions on how to use the functions.
It's time for a new signature.
-
Yes.I have used Dependency walker. But its showing only 4 functions DllCanUnLoadNow,DllGetClassObject,DllRegisterServer,DllUnregisterServer. But I can use the functions in .net. In c++ only, its not working.
Karthika85 wrote:
only 4 functions DllCanUnLoadNow,DllGetClassObject,DllRegisterServer,DllUnregisterServer.
That's because it is a
COM
server and you have to use theCOM
way (e.g. viaCoCreateInstance
[^] function) to access it's functionality. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]