A customer contacted me about a debug message that he had. The message was something like:
Driver ERROR INVALID IOCTL CODE 0x010303FF
He wanted to know what this IOCTL meant and why the driver was called with that value. The following is how I went about answering the question.
1.       I opened up my favorite search tool. I have mentioned this before, but it is worth mentioning again, if you are working with Platform Builder it is very important that you have a really good search tool. The search tool should be fast, which really means that you can set the file types to be searched to include only the source code and other source files, like reg and bib. I use Examine32, which is grep like tool with a GUI, I like it because I like grep and it allows me to click on the results to open files.
2.       I knew that I needed to find the definition of CTL_CODE to be able to figure out what 0x010303FF meant so I searched Public\Common\SDK\Inc which is where I expected to find the definition.  I found it in Winioctl.h:
#define CTL_CODE( DeviceType, Function, Method, Access ) (                 \
    ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
)
 
3.       That allowed me to break up 0x010303FF into its smaller pieces. They are:
a.       DeviceType 0x103
b.      Access 0x0
c.       Function 0xFF
d.      Method 0x3
4.       A quick search for 103 in the same file, winioctl.h, and I found that FILE_DEVICE_PSL is defined to be 0x103.
5.       So now I needed to find where FILE_DEVICE_PSL is used with CTL_CODE. I searched for CTL_CODE and FILE_DEVICE_PSL. I didn’t find it in SDK\Inc, so I moved over to OAK\Inc where I found it in plfuncs.h:
 
#define IOCTL_PSL_NOTIFY CTL_CODE(FILE_DEVICE_PSL, 255, METHOD_NEITHER, FILE_ANY_ACCESS)
 
6.       With a little more searching, I confirmed that METHOD_NEITHER is defined to be 0x3 and FILE_ANY_ACCESS is defined to be 0. And of course the function, 0xFF, is equal to 255.
Now I know that 0x010303FF is IOCTL_PSL_NOTIFY and with similar searching you can reverse engineer any other IOCTL values. Now a quick search of Platform Builder Help and I will know what IOCTL_PSL_NOTIFY is used for.
 
Copyright © 2009 – Bruce Eitman
All Rights Reserved