0

I have a DLL in which I know the functions implemented and the classes names. However, I don't know much more. I would like to create an object from this class in the DLL and use the methods. How can I perform this? I successfully get function from this dll with the following example:

typedef int (__stdcall *f_dll)();
std::string filename = "C:\\Test.dll";
std::wstring tmp = s2ws(filename);
HINSTANCE hGetProcIDDLL = LoadLibrary(tmp.c_str());

if (!hGetProcIDDLL)
{
    std::cerr << "Failed to load DLL" << std::endl;
    return EXIT_FAILURE;
}

// resolve function address here
f_dll func = (f_dll)GetProcAddress(hGetProcIDDLL, "function");
if (!func)
{
    std::cout << "Failed to load function inside DLL" << std::endl;
    return EXIT_FAILURE;
}
froz
  • 163
  • 1
  • 12

1 Answers1

0

Depends, what dou you know -if you have header file you may look: Dynamically load a function from a DLL Maybe, the header of function is incorrect. L

If you don't have header you may use nm (tool from gcc), but it works only on files compiled by gcc-family. You should get some symbols if they are provided for debugging, which contain

  • I do not know the headers unfortunately. I will check nm but I am coding on windows... Hope it is compatible – froz May 17 '19 at 13:42