Communicate between c# interface application and injected to another process dll
My application inject dll(written using c++) to another process and send some information to the interface form. Interface was made using MFC. Injected code communicates with in开发者_Go百科terface via sending messages WM_COPYDATA like this:
::SendMessage(hWnd, WM_COPYDATA, 0, (LPARAM) &cd);
and interface form has method for recieving the messages:
BOOL CInterfaceDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
I am going to make interface form using WPF. How could I communicate between WPF interface and injected to another process dll? Some information, which should be sended from dll to interface, I am going to store in xml files. But how I should signal to interface to receive info from xml?
WPF handles messages and handles a bit different than you are used to. Read this article to understand what is possible and what is not.
An important part of this article:
All WPF elements on the screen are ultimately backed by a HWND. When you create a WPF Window, WPF creates a top-level HWND, and uses an HwndSource to put the Window and its WPF content inside the HWND. The rest of your WPF content in the application shares that singular HWND. An exception is menus, combo box drop downs, and other pop-ups. These elements create their own top-level window, which is why a WPF menu can potentially go past the edge of the window HWND that contains it. When you use HwndHost to put an HWND inside WPF, WPF informs Win32 how to position the new child HWND relative to the WPF Window HWND.
精彩评论