DLL needs to access the symbols of your application

In C ++, is it possible for a DLL to access some symbols of a loaded application? I have an application that loads plugins (dll), and these plugins need to access some application API.

Is it possible to achieve this without creating a new DLL sharing this API?

Is the structure of function pointers appropriate in this situation?

Example

: the bool Log (char *) function defined in the host application and the plugin that should log some events.

+3
source share
3 answers

Another vote for passing the callback interface to the pluggable DLL. That is, the callback interface ...

class IHostApplication
  {
  public:
    virtual bool Log(const wchar_t* ip_log_string) = 0;
  };

DLL

class IPlugin
  {
  public:
    virtual void InitializePlugin(IHostApplication *ip_host) = 0;
  };

DLL (, ), IHostApplication * , , , , .

+2

, .

EXE , DLL, GetProcAddress , .

, - -? .

, ( ), . (, , ) .., .

-.

+1

, - . Dll Dll. Dll , , , .

0

Source: https://habr.com/ru/post/1780003/


All Articles