I’m loading a DLL on a win32 executable with this code:
int _tmain(int argc, _TCHAR* argv[])
{
DWORD somevar = 0;
HINSTANCE hDLL;
hDLL = LoadLibrary( argv[1] );
if ( !hDLL ){
MessageBox(NULL, _T("Unable to load dll."), _T("Fatal Error"), MB_ICONERROR);
return -1;
}
}
Once the DLL is loaded, can a DLL access the variable of its parent executable, say the DWORD variable somevar above?
The scenario is that the actual executable that loads the DLL is already compiled and is used in production, so I can’t add any code in the parent executable. I only have the source code for reference.
In order to access the somevar variable you should pass the address the of the var. I mean to pass the var as pointer to the dll.
—IN your code