S
Soren S. Jorgensen
Hi,
I'm trying to read some messages (native structs) from a kernel mode
mini-filter driver. I'm using my own implementation of IAsyncResult to
pack/unpack the NativeOverlapped structure, and waiting for the result to
arrive.
To read the messages frm the kernek driver i'm using native function:
HRESULT WINAPI FilterGetMessage(
IN HANDLE hPort,
IN OUT PFILTER_MESSAGE_HEADER lpMessageBuffer,
IN DWORD dwMessageBufferSize,
IN LPOVERLAPPED lpOverlapped OPTIONAL);
- in C# it looks like:
[DllImport("FltLib", CallingConvention = CallingConvention.Winapi, CharSet =
CharSet.Auto)]
unsafe private static extern int FilterGetMessage(
SafeFileHandle hPort,
IntPtr lpMessageBuffer,
int dwMessageBufferSize,
NativeOverlapped* lpOverlapped);
The code at first glance seems to be working - no errors on either side (not
in the driver and not in the user mode app) - but the data that's being
transferred are invalid. The data is a simple structure of ULONG's with a
total size of 24 bytes.
I know what is written from kernel mode (i wrote the driver myself), but
when the data is received in user mode it's changed!!
One the that puzzles me is that the C# counter part of the data structure
has to be 16 bytes longer than the C++ structure, which perhaps can be
explained by the four int's reserved at the end of the NativeOverlapped??
I'm able to send data to the driver (synchronously, not using overlapped)
with no problems.
Has anyone gotten NativeOverlapped to work, and if so, please point me to
examples.
I build my code greatly inspired from the "Concurrent Affairs" article in
MSDN magazine june 2007 by Jeffrey Richter
Thanks SSJ
I'm trying to read some messages (native structs) from a kernel mode
mini-filter driver. I'm using my own implementation of IAsyncResult to
pack/unpack the NativeOverlapped structure, and waiting for the result to
arrive.
To read the messages frm the kernek driver i'm using native function:
HRESULT WINAPI FilterGetMessage(
IN HANDLE hPort,
IN OUT PFILTER_MESSAGE_HEADER lpMessageBuffer,
IN DWORD dwMessageBufferSize,
IN LPOVERLAPPED lpOverlapped OPTIONAL);
- in C# it looks like:
[DllImport("FltLib", CallingConvention = CallingConvention.Winapi, CharSet =
CharSet.Auto)]
unsafe private static extern int FilterGetMessage(
SafeFileHandle hPort,
IntPtr lpMessageBuffer,
int dwMessageBufferSize,
NativeOverlapped* lpOverlapped);
The code at first glance seems to be working - no errors on either side (not
in the driver and not in the user mode app) - but the data that's being
transferred are invalid. The data is a simple structure of ULONG's with a
total size of 24 bytes.
I know what is written from kernel mode (i wrote the driver myself), but
when the data is received in user mode it's changed!!
One the that puzzles me is that the C# counter part of the data structure
has to be 16 bytes longer than the C++ structure, which perhaps can be
explained by the four int's reserved at the end of the NativeOverlapped??
I'm able to send data to the driver (synchronously, not using overlapped)
with no problems.
Has anyone gotten NativeOverlapped to work, and if so, please point me to
examples.
I build my code greatly inspired from the "Concurrent Affairs" article in
MSDN magazine june 2007 by Jeffrey Richter
Thanks SSJ
