There is an existing API function which does only allow the plugin(DLL) to receive three parameters and perform some action:
int ProcessMe(int nCommand, unsigned int wParam, long lParam);
Now, from the main program(exe), would like to pass two variables to the plugin, and require plugin to modify their content, and main program will read them again, to perform some task.
My question is, from the above function, can I perform this, without changing the function parameters?
Example:
int ProcessMe(int nCommand, unsigned int wParam, long lParam)
{
// modify the parameters//
return 0;
}
int main()
{
BOOL bSave = TRUE;
int nOption = 0;
ProcessMe(0, (unsigned int)(&bSave), (long)(&nOption));
if(FALSE==bSave)
printf("bSave is modified!");
return 1;
}
Place the variables to modify in a struct and pass the pointer to the sturuct to the plug in:
Use it like this:
Strictly speaking this is undefined behavior. You need to check, whether it works on your platform.
Note: I used a struct here, because this way you can also pass more variables or larger variables such as double to the function.