views:

1109

answers:

1

I am pulling my hair out on this one. I am trying to send a message to a window in another process. I keep getting Access Denied (0x5) from GetLastError() after calling SendMessage or PostMessage or PostThreadMessage. I have tried turning off UAC. I have also accounted for UIPI by ensuring that the Integrity Levels match accross processes. (I checked with Process Explorer from SysInternals, now MS) I also turned off Windows Defender with no luck. I can send a message to the window from inside the process just fine, but from outside I get bupkus! This seems like some sort of security issue but I have no idea what it is as both processes have the same Integrity Level (medium - decimal 8192)

Code from DLL sending the message

UINT MsgCode = ::RegisterWindowMessage(_T("MESSAGE_CODING_STRING"));
::ChangeWindowMessageFilter(MsgCode,MSGFLT_ADD);
::PostMessage(hwnd1,MsgCode,(WPARAM)1,(LPARAM)1);
DWORD errorcode = ::GetLastError();

Selected Code from recieving Window

BEGIN_MESSAGE_MAP(CMessageMailBox, CDialog)
    ON_REGISTERED_MESSAGE(MsgCode, TextFromApp)
END_MESSAGE_MAP()

// Class Constructor    
CMessageMailBox::CMessageMailBox(CWnd* pParent /*=NULL*/)
        : CDialog(CMessageMailBox::IDD, pParent){
       MsgCode = ::RegisterWindowMessage(_T("MESSAGE_CODING_STRING"));
       ::ChangeWindowMessageFilter(MsgCode,MSGFLT_ADD);
    }

//Message Handler   
    afx_msg LRESULT CMessageMailBox::TextFromApp(WPARAM wParam,LPARAM lParam){
        ::MessageBox(NULL,L"message recieved",L"yea!",MB_OK);
        return 0L;
    }
+1  A: 

Does it have to be a message? There are plenty of ways to communication between different processes:

  • Pipes
  • Sockets
  • Shared Memory
  • Files
beef2k
I think I will have to go with one of those options if I cant get this to work. I didn't want to go to the trouble for such a small notification.
JohnG
Pipes are actually pretty simple to implement. Probably the best choice for your problem.
beef2k