I am trying to understand and anticipate how to reference functions in a DLL.
When we reference some functions in a couple of DLLs that we are accessing to do some calculations, in some of the functions, we simply use the process name as the argument lpProcName (e.g. "my_calc_function"). However, in some of the other functions (for a different DLL) we have to add various decorations to the lpProcName (e.g. "?my_other_calc_function@@YA....")
in one case
m_lpfn_my_calc_function_pointer = (lpfn_my_calc_func)::GetProcAddress(m_hOneDll,"this_address_works");
in another case
m_lpfn_my_other_calc_function_pointer = (lpfn_my_calc_func)::GetProcAddress(m_hAnotherDll,"?this_address_has@@YAXNPEAN00PEAH@Z");
Both of these work, however, I would like to understand what the decorations mean and where I can reference them so that I can anticipate them when I am writing my code.
The decorations (or, name mangling) are based to the fact that you can have functions with the same name but different arguments.
DLL exports do not include function signatures, only a name. Therefore, the name is "decorated" to reflect on these arguments (classes, namespaces, arguments, return type, calling convention etc).
To remove the decoration, declare the function inside an
extern "C"block.