Trust me, WDM requires you to understand way more than KMDF does. Think
of it this way, WDM requires you to do everything, even the things you
don’t care about just to get your driver running (like setting the Flags
on your device object, why does it matter for a filter?). KMDF, on the
other hand, lets you focus only on what you are trying to do, focusing
in on only on the things that you need to think about.
The IOCTL value is a ULONG. Normally a driver knows the IOCTL values it
will support and the contracts that come with that IOCTL and how it is
processed. In this case drivers treat the IOCTL as 32 bit value. You
are reverse engineering the ioctl, so you will have to break the IOCTL
value into its 4 pieces. Bug, given your previous posts, you have the
IOCTL values. Look at the macro CTL_CODE in wdm.h
#define CTL_CODE( DeviceType, Function, Method, Access ) (
\
((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) |
(Method) \
)
The 4 pieces are device type, function, method, access. You can focus
on method and ignore the other 3 for determining where the buffers live
in the IRP. Again, from wdm.h
//
// Macro to extract buffering method out of the device io control code
//
#define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3))
//
// Define the method codes for how buffers are passed for I/O and FS
controls
//
#define METHOD_BUFFERED 0
#define METHOD_IN_DIRECT 1
#define METHOD_OUT_DIRECT 2
#define METHOD_NEITHER 3
You can use METHOD_FROM_CTL_CODE to extract the method and then look at
the buffers based on the method returned to you. I will leave it up to
you to figure out which method maps to what buffer in the PIRP (and as
an additional plug for KMDF, KMDF takes care of all of this for you and
just gives you a buffer
). Again, given your previous post, you are
dealing only with METHOD_BUFFERED.
In light of this where you have the app which is talking to the smport
driver, I don’t really see what value you are getting by adding a
filter. Your filter will see the same data that your application does,
the filter will not give you any window into how smport writes the data
to the output buffer though.
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Thursday, May 24, 2007 11:22 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] [NOOB] [FILTER DRIVER] problem setting flag after
iocreatedevice
Thank’s.
Ok i promise you i will have a look to
%wdkroot%\6000\src\kmdf\toaster\filter
After all if an effort is done to make my life simpler, it’s a good
thing to honnor the effort.
The thing afraid me, is to have to begin something new again.
I’m in a dynamic way and i never try to do something like that before.
I’m very afraid to give up if i do not understand KMDF.
Doron Holan said:
“As for what to do with the incoming IOCTLs, that is a tough problem.
Since you don’t know what the definitions or structures related to the
IOCTLs are, you have a lot of reverse engineering to do. The buffering
type (neither, direct, buffered) for an IOCTL is encoded in the IOCTL
value itself (vs the buffering type for reads and writes which is set on
the device).”
Let see if i understand well what you are saying:
IOCTL value is a code that say the buffering method, the acces type
(read or write) and so on.
So if my next step is just to say… something read or something write.
I have to decode IOCTL value? right?
So if i’m right i think it’s a DWORD value (32 bits).
I assume it’s a dword because the msdn said:
The DeviceIoControl function sends a control code directly to a
specified device driver, causing the corresponding device to perform the
corresponding operation.
and the prototype is
BOOL DeviceIoControl(
HANDLE hDevice,
DWORD dwIoControlCode,
LPVOID lpInBuffer,
DWORD nInBufferSize,
LPVOID lpOutBuffer,
DWORD nOutBufferSize,
LPDWORD lpBytesReturned,
LPOVERLAPPED lpOverlapped
);
Ok, so if i understand well the second parameter is the IOCTL we are
currently talking to.
If i’m able to decode this value, i should at least know what is the
function called in the driver and the buffering method.
Right?
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer