WINUI3 Receive another app postmessage exception #4331
Replies: 3 comments
-
A pointer in a process has no meaning in another process |
Beta Was this translation helpful? Give feedback.
-
i tried WM_COPYDATA , but i can not receive WM_COPYDATA message at all, |
Beta Was this translation helpful? Give feedback.
-
Yes, weird, I just tested with an old app and I only receive it in the same instance |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
Marshal.PtrToStringAnsi
Steps to reproduce the bug
1、 a app called sendmessage
var messageBytes = Encoding.UTF8.GetBytes(message);
var messagePtr = Marshal.AllocHGlobal(messageBytes.Length + 1);
Marshal.Copy(messageBytes, 0, messagePtr, messageBytes.Length);
var targetHandle = NativeMethods.FindWindow(null, "AppDisplayName".GetLocalized());
if (targetHandle != IntPtr.Zero)
{
NativeMethods.PostMessage(targetHandle, NativeMethods.WM_MY_MESSAGE, IntPtr.Zero, messagePtr);
Marshal.FreeHGlobal(messagePtr);
}
2、b app receive
var msg = Marshal.PtrToStringAnsi(lParam); ///exception here
System.AccessViolationException:“Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”
Expected behavior
No response
Screenshots
NuGet package version
None
Packaging type
Unpackaged
Windows version
No response
IDE
Visual Studio 2022
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions