You just created a new Stream Interface driver, but it isn’t being loaded. I hear this a lot and thought it would be good to look into the possible causes. Hopefully, if you are here you have already reviewed Windows CE: A Stream Interface Driver Shell which provides a very basic driver an all of code and other files to demonstrate a driver that actually loads.
The first things to check:
1.       Is the driver in you OS image? Check to see that it is in %_FLATRELEASEDIR%\ce.bib.
2.     Do all of the functions return a value that indicates success?
3.       Are the driver’s registry settings in the OS image? Check for them in %_FLATRELEASEDIR%\reginit.ini.
4.       Did you load the OS image with the new driver? This is worth checking, really it is.
So you have checked the basics, and the driver is in the image and the registry settings are there to load the driver, but it still isn’t being loaded. The next thing to check is that you have exported the basic functions that are needed for the device manager to load the driver.
If you don’t have the proper functions exported, device manager may not load the driver. When the device manager is loading a driver, it checks to see if the driver has the exported functions that it will need. The logic looks like this:
·         The driver must have Init and Deinit functions.
·         If the driver prefix exists in the registry then
o   It must have Open and Close functions
o   It must have at least one of the following functions; Read, Write, Seek and IoControl
o   If the function PreClose exists, there must also be a PreDeinit function.
If the driver is not loaded becuase the driver failes the above test, the debug output from a debug build will be:
UDEVICE!CreateDevice: illegal entry point combination in driver DLL 'MyDriver.dll'
Dumpbin can be used to tell you which functions have been exported from a DLL. The EXPORTS argument tells dumpbin to show the exported functions. Here is the output from running dumpbin /EXPORTS on DriverShell.dll.
_FLATRELEASEDIR>dumpbin /exports DriverShell.dll
Microsoft (R) COFF/PE Dumper Version 7.10.4017
Copyright (C) Microsoft Corporation. All rights reserved.
 
 
Dump of file DriverShell.dll
 
File Type: DLL
 
 Section contains the following exports for DriverExample.dll
 
    00000000 characteristics
    488A2DD5 time date stamp Fri Jul 25 15:47:33 2008
        0.00 version
           1 ordinal base
          10 number of functions
          10 number of names
 
    ordinal hint RVA      name
 
          1    0 00001230 XXX_Close
          2    1 00001188 XXX_Deinit
          3    2 00001250 XXX_IOControl
          4    3 00001190 XXX_Init
          5    4 0000122C XXX_Open
          6    5 00001228 XXX_PowerDown
          7    6 00001224 XXX_PowerUp
          8    7 00001238 XXX_Read
          9    8 00001248 XXX_Seek
         10    9 00001240 XXX_Write
 
 Summary
 
        1000 .data
        1000 .pdata
        1000 .reloc
        1000 .text
The output shows that the necessary functions are exported. But what if your dumbin output doesn’t include the functions? Of course the first thing to check is that your driver includes the functions. The next step is to export the functions using either a def file like I did in DriverShell or by indicating that the function should be exported in the source code itself.
One last thing to check, are all of the DLLs that your driver links to included in the OS image?  See  Platform Builder: My Stream Interface Driver Does Not Load
These are the reasons that I can think of for a driver to fail to load, add a comment if you can think of other reasons. I have left out of this discussion reasons why a driver does load, but then fails, that is a different discussion.
Tags:
Copyright © 2008 – Bruce Eitman
All Rights Reserved