Memory sharing between two Kernel mode drivers

Hi Experts,
I am writing two Windows drivers which need to communicate between each other,

  1. VCOM port driver which is running fine with some issues.
    Problem with VCOM port driver(Built from the FakeModem driver sample) is i can send and receive data but not getting the DataReceived Event in the .net application.(I must be missing some interrupt handling ) … Please help.
  2. WSK driver running as a service with a connection oriented socket to a remote IP address. Its also working fine by sending and receiving data to a server.

The problem is i want to bridge the TCP port to the COM port, The data received from the TCP should be sent to the COM port, so that the application which has opened the com port receives it and vice versa.

I am looking at the IRP method of communication but i am not getting how to get the COM ports Device Object to send in IOCallDriver function, which will be called from the WSK driver running as service.

Since the data exchange will be more and frequent, can we directly access the function of one driver in another and write to buffers directly, Please point to some example code as i am from Embedded systems background and new to Windows driver programming.

You can create a named section object to share memory between the two
drivers.

Driver 1:
ZwCreateSection()
ZwMapViewOfSection()

Driver 2:
ZwOpenSection()
ZwMapViewOfSection()

On Thu, Jan 1, 2015 at 8:56 AM, wrote:

> Hi Experts,
> I am writing two Windows drivers which need to communicate between each
> other,
> 1) VCOM port driver which is running fine with some issues.
> Problem with VCOM port driver(Built from the FakeModem driver sample) is i
> can send and receive data but not getting the DataReceived Event in the
> .net application.(I must be missing some interrupt handling ) … Please
> help.
> 2) WSK driver running as a service with a connection oriented socket to a
> remote IP address. Its also working fine by sending and receiving data to a
> server.
>
> The problem is i want to bridge the TCP port to the COM port, The data
> received from the TCP should be sent to the COM port, so that the
> application which has opened the com port receives it and vice versa.
>
> I am looking at the IRP method of communication but i am not getting how
> to get the COM ports Device Object to send in IOCallDriver function, which
> will be called from the WSK driver running as service.
>
> Since the data exchange will be more and frequent, can we directly access
> the function of one driver in another and write to buffers directly, Please
> point to some example code as i am from Embedded systems background and new
> to Windows driver programming.
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>


Jamey Kirby
Disrupting the establishment since 1964

This is a personal email account and as such, emails are not subject to
archiving. Nothing else really matters.

Why not take care of this in user mode? It should be relatively easy to write a service that simply forwards data from one device object to another. Since you are dealing with low speed communication, performance shouldn’t be an issue. Doing this would allow you to use the normal driver read/write mechanisms (buffered/direct) and would alleviate the need to perform your own synchronization on a shared buffer.

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Jamey Kirby
Sent: Thursday, January 1, 2015 10:01
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Memory sharing between two Kernel mode drivers

You can create a named section object to share memory between the two drivers.

Driver 1:

ZwCreateSection()

ZwMapViewOfSection()

Driver 2:

ZwOpenSection()

ZwMapViewOfSection()

On Thu, Jan 1, 2015 at 8:56 AM, > wrote:

Hi Experts,
I am writing two Windows drivers which need to communicate between each other,
1) VCOM port driver which is running fine with some issues.
Problem with VCOM port driver(Built from the FakeModem driver sample) is i can send and receive data but not getting the DataReceived Event in the .net application.(I must be missing some interrupt handling ) … Please help.
2) WSK driver running as a service with a connection oriented socket to a remote IP address. Its also working fine by sending and receiving data to a server.

The problem is i want to bridge the TCP port to the COM port, The data received from the TCP should be sent to the COM port, so that the application which has opened the com port receives it and vice versa.

I am looking at the IRP method of communication but i am not getting how to get the COM ports Device Object to send in IOCallDriver function, which will be called from the WSK driver running as service.

Since the data exchange will be more and frequent, can we directly access the function of one driver in another and write to buffers directly, Please point to some example code as i am from Embedded systems background and new to Windows driver programming.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer



Jamey Kirby
Disrupting the establishment since 1964

This is a personal email account and as such, emails are not subject to archiving. Nothing else really matters.

— NTDEV is sponsored by OSR Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev OSR is HIRING!! See http://www.osr.com/careers For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

xxxxx@gmail.com wroteThursday, January 01, 2015 3:56 PM
To Windows System Software Devs Interest List
Subject: [ntdev] Memory sharing between two Kernel mode drivers

I am writing two Windows drivers which need to communicate between
each other,

  1. VCOM port driver which is running fine with some issues.
  2. WSK driver running as a service with a connection oriented socket
    to a remote IP address.

The problem is I want to bridge the TCP port to the COM port,
The data received from the TCP should be sent to the COM port,
so that the application which has opened the com port receives it and
vice versa.

Are there specific reasons for writing two separate drivers instead of
single virtual COM driver with TCP lower edge?

Best regards,
Alex Krol

Thank you Jamey Kirby, Dan Kelly, Alex Krol for your quick reply. :slight_smile:

My concept is when i create a COM port it should bind to an remote IP address and start transacting,

I also want to avoid the kernel memory sharing, but since i didnt find any examples/info on sending IRP from one driver to another totally different driver of different type i came down to kernel memory sharing.

If only one driver can do it then it would be awesome. But i did search for ways of implementing it but did not find much information, may be i was not using the right terms for search. If someone can point me towards information on such an implementation, that would be very helpful.

I would prefer kernel mode driver only implementation to reduce the complexity and one user mode application will be however be there with a GUI to create and delete ports and exit after that.

I did try to implement both the driver in one by copying the WSK socket driver code into Fakemodem driver code, I have called the driver entry of WSK driver in fakemodem driver entry code, as shown in the Generic.sys Specific.sys edge/mini driver implementation. I have removed the WSK driver INF file and kept only the Fakemodem INF file as it is. But it keeps asking for the WSK.sys is missing which is mentioned in INF, even after the INF file is deleted.

Hi,
Thank you for the reply,
That would be great if it can be implemented, but i am not able to find any information/example of such driver. If you can please give me links towards such implementations it will be very helpful.
Regards,
Ravi

On Jan 1, 2015, at 11:34 PM, xxxxx@gmail.com wrote:

That would be great if it can be implemented, but i am not able to find any information/example of such driver. If you can please give me links towards such implementations it will be very helpful.

Do not fall into the newbie trap of believing that the only drivers that can be implemented are ones that match the samples. When you have a virtual COM port driver, it always has to be communicating with something. Sometimes it’s a USB device. Sometimes it’s an application. In your case, it will be a TCP port. It’s not that hard to envision.

However, I have to think you are going about this the wrong way. From user mode, it is easier to communicate with a TCP port than it is to talk to a serial port. Why not just forget about all of this silly translation and change the application layer? You can provide a DLL with a couple of helper functions, then provide one version that talks serial port and one that talks TCP. No drivers necessary.

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.