User kernel communication model l.jpg
This presentation is the property of its rightful owner.
Sponsored Links
1 / 11

User / Kernel Communication Model PowerPoint PPT Presentation


  • 330 Views
  • Uploaded on
  • Presentation posted in: General

User / Kernel Communication Model. Advantages. Bi-directional messaging facility Minifilter defines the security on the channel Fast User-to-Kernel messaging, no buffering Efficient Kernel-to-User messaging with the capability for user mode to reply back to the filter.

Download Presentation

User / Kernel Communication Model

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


User kernel communication model l.jpg

User / Kernel Communication Model

© 2004 Microsoft Corporation. All rights reserved.


Advantages l.jpg

Advantages

  • Bi-directional messaging facility

  • Minifilter defines the security on the channel

  • Fast User-to-Kernel messaging, no buffering

  • Efficient Kernel-to-User messaging with the capability for user mode to reply back to the filter.

  • Can associate I/O completion ports for Kernel-to-User communication

© 2004 Microsoft Corporation. All rights reserved.


Communication ports l.jpg

Communication Ports

  • Filter creates a named communication port

  • Filter implicitly begins to listen for incoming connections on the port

  • Connection will be denied if user doesn’t have sufficient access as specified by security descriptor on listener port

  • Each connection to the listener port gets its own message queue and private endpoints

© 2004 Microsoft Corporation. All rights reserved.


Communication ports cont d l.jpg

Communication Ports (cont’d)

  • Closing either endpoint (kernel/user) terminates that connection

  • Closing listener port handle prevents future connections

    • Existing connections will not be terminated

  • Unload safe

    • When minifilter unloads, Filter manager forcibly terminates existing connections

© 2004 Microsoft Corporation. All rights reserved.


Creating communication port l.jpg

Creating Communication Port

  • Minifilter creates a named port with:

    • FltCreateCommunicationPort(

      IN PFLT_FILTER Filter,

      OUT PFLT_PORT *ServerPort,

      IN POBJECT_ATTRIBUTES ObjectAttributes,

      IN PVOID ServerPortCookie OPTIONAL,

      IN PFLT_CONNECT_NOTIFY ConnectNotifyCallback,

      IN PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback,

      IN PFLT_MESSAGE_NOTIFY MessageNotifyCallback,

      IN ULONG MaxConnections);

  • Minifilter closes named port with:

    • FltCloseCommunicationPort()

© 2004 Microsoft Corporation. All rights reserved.


Establishing a connection from user mode l.jpg

Establishing a Connection from User-Mode

  • Application connects to named port with:

    • FilterConnectCommunicationPort(

      IN LPCWSTR lpPortName,

      IN DWORD dwOptions,

      IN LPVOID lpContext OPTIONAL,

      IN WORD wSizeOfContext,

      IN LPSECURITY_ATTRIBUTES lpSecurityAttributes OPTIONAL,

      OUT HANDLE *hPort);

  • Application disconnects from named port with:

    • CloseHandle()

© 2004 Microsoft Corporation. All rights reserved.


Establishing a connection cont d l.jpg

Establishing a Connection (cont’d)

  • User connect triggers ConnectNotify() callback in minifilter

    • Receives a handle to the new connection just created

  • On return, user-mode receives a separate handle representing its endpoint to the connection

  • User-mode handle is a file handle

    • Can be used to associate I/O completion ports

© 2004 Microsoft Corporation. All rights reserved.


User to kernel messaging l.jpg

User-to-Kernel Messaging

  • FilterSendMessage()

    • Sends synchronous message from user to kernel

  • Minifilter receives message via MessageNotify() callback

  • Buffers are raw user buffers

    • Must use try-except(), probe/capture, etc., to safely access buffers

© 2004 Microsoft Corporation. All rights reserved.


Kernel to user messaging l.jpg

Kernel-to-User Messaging

  • FltSendMessage()

    • Sends message to waiting user-mode receiver

    • Can block if no user-mode receivers are available

    • Timeout may be specified, use with care

  • FilterGetMessage()

    • Called by user mode application to receive a message from the minifilter

    • Recommend that you use overlapped structure to issue multiple asynchronous gets

  • FilterReplyMessage()

    • Applications reply to a specific message

  • Requires agreed upon message protocol between application and minifilter

© 2004 Microsoft Corporation. All rights reserved.


Terminating a connection l.jpg

Terminating a Connection

  • User-mode close of handle triggers DisconnectNotify() in minifilter

    • Filter then calls FltCloseClientPort() to finish closing the connection

  • Minifilter unload also triggers DisconnectNotify()

© 2004 Microsoft Corporation. All rights reserved.


Sample l.jpg

Sample

  • Look at Scanner minifilter sample

© 2004 Microsoft Corporation. All rights reserved.


  • Login