Re: Unable to load custom driver on WinCE 6
- From: "silver" <moc.liamtoh@gnirrevliseht>
- Date: Thu, 5 Mar 2009 10:11:28 -0800
<mecha083@xxxxxxxxx> wrote in message news:da9c83d9-1ea1-45ac-b901-63175f49c047@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,
I'm trying to make and load a simple DLL on WinCE 6 by following the
guide at http://msdn.microsoft.com/en-us/library/aa459176.aspx .
The target device is actually a i.MX27 ADS evaluation board. I've
managed to build a working WinCE 6 image with the BSP provided by
Freescale.
This is what I did so far:
- I've made a subproject at PB project to include the simple DLL
(following the guide from the MSDN link above).
- The MyDriver DLL subproject compiled without errors.
- I've ran dumpbin -exports mydriver.dll to check the export
functions. The export functions matched the screenshot in the MSDN
link.
- At the target device, the mydriver.dll file is in the Windows
directory.
- At the target device, the registry entry at "Drivers" directory is
correct. Below is the registry entry.
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Sample]
"Dll" = "mydriver.Dll"
"Prefix" = "DEM"
"Index" = dword:1
"Order" = dword:0
"FriendlyName" = "Demo Driver"
"Ioctl" = dword:0
- At the target device, there is no entry pertaining mydriver.dll in
the Drivers > Active directory like the screenshot shown. Therefore,
the driver is loaded.
- I wrote a simple application to load the driver dynamically
following an example from the web (using ActivateDeviceEx() API).
GetLastError() return 0x0000002 and handle value is 0. Below is the
function:
void LoadDriver(void)
{
HANDLE hDriverShell = INVALID_HANDLE_VALUE;
BOOL RetVal = FALSE;
if( hDriverShell == INVALID_HANDLE_VALUE )
{
hDriverShell = ActivateDeviceEx(_T("Drivers\\BuiltIn\
\Sample"), NULL, 0, NULL);
if ((hDriverShell != INVALID_HANDLE_VALUE) && (hDriverShell !=
0))
{
RetVal = TRUE;
}
else
{
// Note: the driver may have succeded to load if the
handle is zero
//RETAILMSG( 1, (TEXT("Failed to activate driver %d\n"),
GetLastError() ));
RetVal = FALSE;
}
}
}
What should I do to load the driver successfully on WinCE 6?
Thanks.
Are you correctly exporting the necessary functions from the DLL? Show us which ones are present, ie the dumpbin output
See here for the exports applicable to you:
http://msdn.microsoft.com/en-us/library/aa930506.aspx
Did you forget to put a DllMain in your dll?
Next, the builtin key will load the driver for you at boot time, you do not need to use ActivateDeviceEx to start it.
The order is rather low (0), this will not affect use by activatedevice though.
BTW ActivateDeviceEx returns NULL on failure, not INVALID_HANDLE_VALUE. CreateFile is the only one that uses INVALID_HANDLE_VALUE, yes the inconsistency is irritating.
- It is also possible that the driver is loaded then unload immediately if DEM_Init fails. Put a RETAILMSG in there to see if it gets called.
All of that said it may be as simple as this:
Prove that mydriver.dll is in your image (is it part of the ce.bib file in the release dir?) -OR- is RELFSD part of your image and KITL is connected?
Geoff
--
.
- Follow-Ups:
- Re: Unable to load custom driver on WinCE 6
- From: mecha083
- Re: Unable to load custom driver on WinCE 6
- References:
- Unable to load custom driver on WinCE 6
- From: mecha083
- Unable to load custom driver on WinCE 6
- Prev by Date: Re: Unable to load custom driver on WinCE 6
- Next by Date: Win CE Time Zone
- Previous by thread: Re: Unable to load custom driver on WinCE 6
- Next by thread: Re: Unable to load custom driver on WinCE 6
- Index(es):
Relevant Pages
|