CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2010
    Posts
    3

    Get the handle of Socket Notification Sink

    I would like to know how to find the handle of the Socket Notification Sink hidden window. My goal is to detect the WM_SOCKET_NOTIFY message, so any other way to do this would be appreciate.

    Thanks.

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Re: Get the handle of Socket Notification Sink

    You can get the handle to the Socket Window with AfxGetCeSocketWindow().

    The WM_SOCKET_NOTIFY message informs the socket window that a socket event has occurred. But, you can only send the WM_SOCKET_NOTIFY message to a window returned by the AfxGetCeSocketWindow WCE MFC global function. This message is only exposed publicly in Windows CE.

    See also http://www.microsoft.com/communities...9-b5efa115a44d
    Last edited by olivthill2; June 2nd, 2010 at 08:27 AM.

  3. #3
    Join Date
    Jun 2010
    Posts
    3

    Re: Get the handle of Socket Notification Sink

    That function would work only in Windows CE, I want something in regular Windows.

  4. #4
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Get the handle of Socket Notification Sink

    Is your question directed to the hidden notification window used by MFC's CAsyncSocket class? If so, then based on the source code for MFC CAsyncSocket class (found in sockcore.cpp), the following might work:
    Code:
    HANDLE CMyAsyncSocket::GetHiddenWindowHandle()
    {
      AFX_MODULE_THREAD_STATE* pState = AfxGetModuleThreadState();
      return pState->m_hSocketWindow;
    }
    Each thread has only one hidden window for socket notifications, and it is shared among all sockets created by that thread.

    Why do you need to detect the WM_SOCKET_NOTIFY message?

    Mike

  5. #5
    Join Date
    Jun 2010
    Posts
    3

    Re: Get the handle of Socket Notification Sink

    Quote Originally Posted by MikeAThon View Post
    Is your question directed to the hidden notification window used by MFC's CAsyncSocket class? If so, then based on the source code for MFC CAsyncSocket class (found in sockcore.cpp), the following might work:
    Code:
    HANDLE CMyAsyncSocket::GetHiddenWindowHandle()
    {
      AFX_MODULE_THREAD_STATE* pState = AfxGetModuleThreadState();
      return pState->m_hSocketWindow;
    }
    Each thread has only one hidden window for socket notifications, and it is shared among all sockets created by that thread.

    Why do you need to detect the WM_SOCKET_NOTIFY message?

    Mike
    Thanks.

    I need to get that handle to send a WM_SOCKET_NOTIFY to that window, then write into recv() buffer and call select(), in order to force the program to read the recv() as a new packet were arrived from the server. It's a way to inject such packet into the client.

    The tool I'm programming will be used to discover protocols and detect malware.

    If you know any better way to do this, please tell me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured