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.
- At the target device, there is no entry pertaining mydriver.dll in
the Drivers > Active directory like the screenshot shown. Therefore,
the driver is NOT loaded.
Hi,
I'm certainly no expert in this area (I've never used CE 6.0 and only
beginning with CE 5.0) and there may be other issues, but if
GetLastError is 2 and the handle is 0 that means that the dll hasn't
been found. If it's in your Windows directory I would guess that you
would load the dll like this: hDriverShell = ActivateDeviceEx(_T
("mydriver.Dll"), NULL, 0, NULL);
Like I said, I'm new to this too so...
-- keano
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
--
I managed to load the DLL on WinCE 6. The DLL is loaded in user mode
for it to be successful. To do that, I've added anadditional entry in
the registry .reg file. Below is the final registry file I use:
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Sample]
"Dll"="mydriver.dll"
"Prefix" = "DEM"
"Index" = dword:1
"Order" = dword:0
"FriendlyName" = "Demo Driver"
"Ioctl" = dword:0
"Flags" = dword:10
If I want to load the sample DLL in kernel mode, what should I do? I
don't have a certificate to sign the driver. Is there a way to get a
certificate for testing purposes only (for the Freescale i.MX27 ADS
evaluation board)?
Thanks.
You do not need a certificate, you need to put a k. in fornt of it in the
bib file, see here:
http://msdn.microsoft.com/en-us/library/aa909662.aspx
Geoff
--