0

I am trying to export dlls and load it dynamically during runtime. dumpbin export output for the constructor for the class gives me the below output.

1 0 000111B8 ??4myclass@nmspace@@QAEAAV01@ABV01@@Z = @ILT+435(??4myclass@nmspace@@QAEAAV01@ABV01@@Z)

typedef void (WINAPI * PCTOR) ();

I am trying to get the virtual address using below two lines.

PCTOR pCtor = (PCTOR)GetProcAddress(hinstLib, (LPCSTR)DWORD(1)); PCTOR pCtor = (PCTOR)GetProcAddress(hinstLib, "??4myclass@nmspace@@QAEAAV01@ABV01@@Z");

Then I call the constructor with the below line
pCtor ();

When I use the DWORD(1)
pCtor value - nmspace::myclass::operator=(class nmspace::myclass const &)

pCtor() works fine.

But for the second line using the actual value for the exported function pCtor value - nmspace::myclass::myclass(void)

pCtor() gives me ESP was not properly saved... error.

Can I get some help on what is the problem in this case.

Subhasis P
  • 11
  • 1
  • 3
  • Write C wrapper for C++ library, and load dynamically this C wrapper. http://stackoverflow.com/questions/7691035/c-wrapper-for-c In this answer replace SomeObj* with void* in C wrapper functions. – Alex F Apr 09 '14 at 14:53
  • Are you trying to invoke methods from a C++ class using C code? There are more things to consider...why don't you simply export classes then? If you need a C interface then embed it where classes reside. – Adriano Repetti Apr 09 '14 at 14:54
  • I have an 3rd Party c++ library which is used in my application. I want to load dlls only when my application needs it.So, I tried to use help from [here](http://www.codeproject.com/Articles/9405/Using-classes-exported-from-a-DLL-using-LoadLibrar) ..I tried to use the getProcaddress as mentioned in my question. It works fine with the syntax using DWORD. But I want to understand the basic difference between the two function pointers returned in both cases. – Subhasis P Apr 10 '14 at 06:39

0 Answers0