I am having problem with the contents of a pointer passed as the wParam from a 32-bit C# application is changing along the way to a 64-bit C++ process.
There are two processes 32.exe (in C#) and 64.exe (in C++). 64.exe is started as a child process of 32.exe. 32.exe post window message for 64.exe, one of which has a wParam that is a pointer to an array of RECT structures. Both 64.exe and 32.exe have a common DLL (written in C++, but compiled for different platforms, of course), called 32.dll and 64.dll.
A function expecting a RECT* in 32.dll is called directly from 32.exe with the same RECT* that is later posted, and this works well. Afterwards it posts a message to 64.exe, which calls the same function and casts the wParam to RECT*:
else if (WM_SetDisabledAreas == message)
{
SetDisabledAreas((RECT*)wParam, (UINT)lParam);
}
The message is posted as follows:
if (Is64Bit() && SubProcess64 != null)
{
Win32.PostMessage(SubProcess64.MainWindowHandle, WindowMessages.SetDisabledAreas,
(uint)pointer.ToInt32(), length);
}
MessageBox.Show(pointer.ToString());
DLL32.SetDisabledAreas(pointer, length);
By debugging I've validated that the message is received, however the wParam address is not the same as it was before. This is not unexpected, but the contents of the memory it now points to is undefined (and I get an access violation when attempting to see what is there).
What is happening here?