There are two ways of doing this :
Dynamic Loading
- Windows:
GetModuleFileName() with hModule = NULL this gives the path of the executable.
Use LoadLibrary(Executable_Name) to load itself in the memory.
- Linux : Use
dloopen() with NULL and it loads itself in memory.
In both Windows and Linux you can define a void* (function*)() pointer. This always works with all signatures without parameters. This does not work on class methods.
Using Namespace System
This namespace would be easy you can use the Inspect functionality and InvokeMember methods to dynamically call class methods and access variable from inside the class.