Currently I’m working on a redir, which is my first driver and first ever
kernel mode application. The filesystem driver consists of two parts, a
Kernel Mode (C) part and a User Mode (Managed C++) part. For the
interaction between User and Kernel Mode I use DeviceIoControl to send a
buffer to the Kernel Mode, using METHOD_NEITHER. The filesystem driver
puts the IRP/buffer onto a queue so it can be used in the future as
request buffer. At this point the User Mode thread (Managed C++) is
waiting for response. At some point in time my filesystem driver gets
takes this IRP/buffer from the queue and uses it for a request to the User
Mode part. The kernel mode driver will wait for a notification event. Now
comes the problem, as the request buffer was send to the fsd using a
different thread, as when it is used by the fsd as a request buffer, the
memory addresses are incorrect. Even worse is the fact that the response
can come from a even different (response)thread (by design), so when it
arrives at the fsd again the pointer to my KEVENT is invalid and the
requestor will keep on waiting forever.
Does anyone have/know a solution to my problem? Do I have to translate the
virtual addresses to physical addresses (how??)?
Thanks,
Alexander
I assume the buffer is the problem and not the KEVENT (which you create in
FSD or user mode?)
For the buffer, it is enough to do IoAllocateMdl, MmProbeAndLockPages and
MmGetSystemAddressForMdlSafe on the user buffer, and it (address returned by
MmGetSystemAddressForMdlSafe) can be used in any thread.
Regards, Dejan.
Alexander wrote:
Currently I’m working on a redir, which is my first driver and first ever
kernel mode application. The filesystem driver consists of two parts, a
Kernel Mode (C) part and a User Mode (Managed C++) part. For the
interaction between User and Kernel Mode I use DeviceIoControl to send a
buffer to the Kernel Mode, using METHOD_NEITHER. The filesystem driver
puts the IRP/buffer onto a queue so it can be used in the future as
request buffer. At this point the User Mode thread (Managed C++) is
waiting for response. At some point in time my filesystem driver gets
takes this IRP/buffer from the queue and uses it for a request to the User
Mode part. The kernel mode driver will wait for a notification event. Now
comes the problem, as the request buffer was send to the fsd using a
different thread, as when it is used by the fsd as a request buffer, the
memory addresses are incorrect. Even worse is the fact that the response
can come from a even different (response)thread (by design), so when it
arrives at the fsd again the pointer to my KEVENT is invalid and the
requestor will keep on waiting forever.
Does anyone have/know a solution to my problem? Do I have to translate the
virtual addresses to physical addresses (how??)?
Thanks,
Alexander
You are currently subscribed to ntfsd as: xxxxx@alfasp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
–
Kind regards, Dejan M. MVP for DDK
http://www.alfasp.com E-mail: xxxxx@alfasp.com
Alfa Transparent File Encryptor - Transparent file encryption services.
Alfa File Protector - File protection and hiding library for Win32 developers.
Alfa File Monitor - File monitoring library for Win32 developers.
Do not use METHOD_NEITHER, use one of the other methods,
if the data is short use METHOD_BUFFER else use METHOD_DIRECT.
For a good article on how to do what you are looking to do see
http://www.osronline.com/article.cfm?id=39
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
----- Original Message -----
From: “Alexander”
To: “Windows File Systems Devs Interest List”
Sent: Monday, October 20, 2003 4:37 AM
Subject: [ntfsd] Connection Kernel-Mode User-Mode and Multithreading failes.
> Currently I’m working on a redir, which is my first driver and first ever
> kernel mode application. The filesystem driver consists of two parts, a
> Kernel Mode (C) part and a User Mode (Managed C++) part. For the
> interaction between User and Kernel Mode I use DeviceIoControl to send a
> buffer to the Kernel Mode, using METHOD_NEITHER. The filesystem driver
> puts the IRP/buffer onto a queue so it can be used in the future as
> request buffer. At this point the User Mode thread (Managed C++) is
> waiting for response. At some point in time my filesystem driver gets
> takes this IRP/buffer from the queue and uses it for a request to the User
> Mode part. The kernel mode driver will wait for a notification event. Now
> comes the problem, as the request buffer was send to the fsd using a
> different thread, as when it is used by the fsd as a request buffer, the
> memory addresses are incorrect. Even worse is the fact that the response
> can come from a even different (response)thread (by design), so when it
> arrives at the fsd again the pointer to my KEVENT is invalid and the
> requestor will keep on waiting forever.
>
> Does anyone have/know a solution to my problem? Do I have to translate the
> virtual addresses to physical addresses (how??)?
>
> Thanks,
> Alexander
>
> —
> You are currently subscribed to ntfsd as: xxxxx@acm.org
> To unsubscribe send a blank email to xxxxx@lists.osr.com