Hello,

I am building a stream device driver composed by
a DLL and an EXE with eVC4.0
and I am using CEPB 4.2 x86 architecture.


I'm following this example
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnembedded/html/spotwincerambl.asp

Unfortunately this article is good but incomplete and not enough exhaustive
and MS provide no valid starting point, so I'm trying to resume all the test
I've done hoping some expert could help me to define the last steps to make
this driver working.

I added in Project.reg file

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Sample]
"Dll" = "mydriver.Dll"
"Prefix" = "DEM"
"Index" = dword:1
"Order" = dword:0
"FriendlyName" = "Demo Driver"
"Ioctl" = dword:0

Then I added my EXE and my DLL into NK.BIN image,
with this PROJECT.BIB

MODULES
; Name Path Memory
Type
; -------------- --------------------------------------------- ----------

FILES
; Name Path Memory
Type
; -------------- --------------------------------------------- ----------

MyDriver.dll $(_FLATRELEASEDIR)\MyDriver.dll NK S
MyDriverTest.exe $(_FLATRELEASEDIR)\MyDriverTest.exe NK S


I always rebuild all (like suggested in many messages in this NG)
And that I can see and launch the new files (MyDriver.dll and
MyDriverTest.dll)
in the \Windows directory of the target system


But unfortunately when I launch the Remote System Information application my
device is not shown and my EXE can't open the dll and I get back "Failed to
open Driver..." error message.

What I am missing ?
TIA

/helix

Re: Stream Device Driver by Yannick

Yannick
Mon May 03 10:08:32 CDT 2004

I'd rather put the dll & exe in the module section.

From PB, can you see your dll launched (in the list of modules launched)

In a first approach, I'd rather launch the driver dynamically (i.e, not put
the registry entries in the Builtin section, and use the ActivateDeviceEx
function from the exe to mount the driver dynamically). It will allow you an
easier check of the driver activation : if you add som log message in your
DEM_Init function, you should see them when calling the ActivateDeviceEx.

--
----------------------------------------------------------------
Yannick Chamming's (eMVP)
ADESET
Windows Embedded Manager
ychammings AT adeset DOT com>
http://www.adeset.com
Tél : +33 (0)4.72.18.57.77
Fax : +33 (0)4.72.18.57.78
----------------------------------------------------------------

"Helix" <helix-remove@despammed.com> a écrit dans le message de
news:OZQ1sTRMEHA.3944@tk2msftngp13.phx.gbl...
> Hello,
>
> I am building a stream device driver composed by
> a DLL and an EXE with eVC4.0
> and I am using CEPB 4.2 x86 architecture.
>
>
> I'm following this example
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnembedded/html/spotwincerambl.asp
>
> Unfortunately this article is good but incomplete and not enough
exhaustive
> and MS provide no valid starting point, so I'm trying to resume all the
test
> I've done hoping some expert could help me to define the last steps to
make
> this driver working.
>
> I added in Project.reg file
>
> [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Sample]
> "Dll" = "mydriver.Dll"
> "Prefix" = "DEM"
> "Index" = dword:1
> "Order" = dword:0
> "FriendlyName" = "Demo Driver"
> "Ioctl" = dword:0
>
> Then I added my EXE and my DLL into NK.BIN image,
> with this PROJECT.BIB
>
> MODULES
> ; Name Path Memory
> Type
>
-------------- --------------------------------------------- ----------
>
> FILES
> ; Name Path Memory
> Type
>
-------------- --------------------------------------------- ----------
>
> MyDriver.dll $(_FLATRELEASEDIR)\MyDriver.dll NK S
> MyDriverTest.exe $(_FLATRELEASEDIR)\MyDriverTest.exe NK S
>
>
> I always rebuild all (like suggested in many messages in this NG)
> And that I can see and launch the new files (MyDriver.dll and
> MyDriverTest.dll)
> in the \Windows directory of the target system
>
>
> But unfortunately when I launch the Remote System Information application
my
> device is not shown and my EXE can't open the dll and I get back "Failed
to
> open Driver..." error message.
>
> What I am missing ?
> TIA
>
> /helix
>
>



Re: Stream Device Driver by Bruce

Bruce
Mon May 03 11:12:35 CDT 2004

Did you do the Testing the Functions section? Did the results match the
results in that article?

Did you look for the debug messages? What was output?

--
Bruce Eitman (eMVP)
Senior Engineer
Accelent Systems Inc.
www.accelent.com



Re: Stream Device Driver by Helix

Helix
Mon May 03 11:58:38 CDT 2004

Thank you everybody for answering :-)

> Did you do the Testing the Functions section? Did the results match the
> results in that article?

Yes I did,
1. with Dumpbin /exports mydriver.dll I see every entry point.
2. with CE Remote Registry Editor I see the entry I placed in
HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Sample
3. with Windows CE Remote System Information I can't see my driver entry !

> Did you look for the debug messages? What was output?

MY TEST APPLICATION
--------------------
OutputDebugString(L"===> 1 \n");
HANDLE TSP = ActivateDeviceEx(_T("\\Windows\\MyDriver"),NULL,0,NULL);


OutputDebugString(L"===> 2 \n");
HANDLE h = RegisterDevice(TEXT("DEM"), 1, TEXT("MyDriver.dll"), 0) ;

OutputDebugString(L"===> 3 \n");
if (h == 0)
OutputDebugString(L"*** RegisterDevice failed\n");



OutputDebugString(L"===> 4 \n");
HINSTANCE hc = LoadLibrary(L"MyDriver.dll") ;
if (hc != NULL)
{

ReadFromDriver() ;

}
else
OutputDebugString(L"*** Failed LoadLibrary\n");


CEPB OUTPUT
------------
4294885534 PID:3d6c3aa TID:3d65252 ===> 1
4294885535 PID:43f982c2 TID:3d65252 0x83d65000:
DEVICE!ActivateDeviceEx(\Windows\MyDriver) entered
4294885536 PID:43f982c2 TID:3d65252 0x83d65000: DEVICE!StartOneDriver
RegOpenKeyEx(\Windows\MyDriver) returned 2.
4294885537 PID:3d6c3aa TID:3d65252 ===> 2
4294885644 PID:43f982c2 TID:3d65252 0x83d65000: >>> Loading module
MyDriver.dll at address 0x01F00000-0x01F07000
Loaded symbols for 'D:\WINCE420\PUBLIC\MYPROJECT\MYFILES\MyDriver.DLL'
4294885647 PID:43f982c2 TID:3d65252 MyDriver - DLL_PROCESS_ATTACH
4294885648 PID:43f982c2 TID:3d65252 MyDriver - DLL_PROCESS_DETACH
4294885650 PID:43f982c2 TID:3d65252 0x83d65000: <<< Unloading module
MyDriver.dll at address 0x01F00000-0x01F07000
Unloaded symbols for 'D:\WINCE420\PUBLIC\MYPROJECT\MYFILES\MyDriver.DLL'
4294885653 PID:3d6c3aa TID:3d65252 ===> 3
4294885654 PID:3d6c3aa TID:3d65252 *** RegisterDevice failed
4294885655 PID:3d6c3aa TID:3d65252 ===> 4
4294885679 PID:3d6c3aa TID:3d65252 0x83d65000: >>> Loading module
MyDriver.dll at address 0x01F00000-0x01F07000
Loaded symbols for 'D:\WINCE420\PUBLIC\MYPROJECT\MYFILES\MyDriver.DLL'
4294885732 PID:3d6c3aa TID:3d65252 MyDriver - DLL_PROCESS_ATTACH
4294885733 PID:3d6c3aa TID:3d65252 Failed to open Driver...



Re: Stream Device Driver by Helix

Helix
Mon May 03 12:06:31 CDT 2004

Thank you everybody for answering :-)

> From PB, can you see your dll launched (in the list of modules launched)
I'm testing in this way...


> In a first approach, I'd rather launch the driver dynamically (i.e, not
put
> the registry entries in the Builtin section, and use the ActivateDeviceEx
> function from the exe to mount the driver dynamically). It will allow you
an
> easier check of the driver activation : if you add som log message in your
> DEM_Init function, you should see them when calling the ActivateDeviceEx.

OutputDebugString(L"===> 1 \n");
HANDLE TSP = ActivateDeviceEx(_T("\\Windows\\MyDriver"),NULL,0,NULL);
OutputDebugString(L"===> 2 \n");

CEPB OUTPUT
------------
4294885534 PID:3d6c3aa TID:3d65252 ===> 1
4294885535 PID:43f982c2 TID:3d65252 0x83d65000:
DEVICE!ActivateDeviceEx(\Windows\MyDriver) entered
4294885536 PID:43f982c2 TID:3d65252 0x83d65000: DEVICE!StartOneDriver
RegOpenKeyEx(\Windows\MyDriver) returned 2.
4294885537 PID:3d6c3aa TID:3d65252 ===> 2




Re: Stream Device Driver by Yannick

Yannick
Tue May 04 08:44:36 CDT 2004

If you call the ActivateDeviceEx, you should not put your reg entry in
builtin subkey, so that the driver would not be mounted at startup.

Furthermore, the first prm of ActivateDeviceEx is not the path of your
driver, but the registry base key that contain your driver's settings.

Finally, when you use the ActivateDeviceEx function, don't use the
registerdevice function in addition, and to connect to your driver once
mounted, you should use CreateFile API instead of loadlibrary.

In fact, you should have the following reg settings and code :

registry :

[HKEY_LOCAL_MACHINE\Drivers\Sample]
"Dll" = "mydriver.Dll"
"Prefix" = "DEM"
"Index" = dword:1
"Order" = dword:0
"FriendlyName" = "Demo Driver"
"Ioctl" = dword:0

App code :

OutputDebugString(L"===> 1 \n");
HANDLE TSP = ActivateDeviceEx(_T("Drivers\\Sample",NULL,0,NULL);


OutputDebugString(L"===> 2 \n");

OutputDebugString(L"===> 3 \n");
if (h == 0)
OutputDebugString(L"*** RegisterDevice failed\n");



OutputDebugString(L"===> 4 \n");
HANDLE hc = CreateFile(L"DEM1:", ...) ;
if (hc != INVALID_HANDLE_VALUE)
{

ReadFromDriver() ;

}
else
OutputDebugString(L"*** Failed CreateFile\n");




--
----------------------------------------------------------------
Yannick Chamming's (eMVP)
ADESET
Windows Embedded Manager
ychammings AT adeset DOT com>
http://www.adeset.com
Tél : +33 (0)4.72.18.57.77
Fax : +33 (0)4.72.18.57.78
----------------------------------------------------------------

"Helix" <helix-remove@despammed.com> a écrit dans le message de
news:%23XOgN$SMEHA.3380@TK2MSFTNGP11.phx.gbl...
> Thank you everybody for answering :-)
>
> > Did you do the Testing the Functions section? Did the results match the
> > results in that article?
>
> Yes I did,
> 1. with Dumpbin /exports mydriver.dll I see every entry point.
> 2. with CE Remote Registry Editor I see the entry I placed in
> HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Sample
> 3. with Windows CE Remote System Information I can't see my driver entry !
>
> > Did you look for the debug messages? What was output?
>
> MY TEST APPLICATION
> --------------------
> OutputDebugString(L"===> 1 \n");
> HANDLE TSP = ActivateDeviceEx(_T("\\Windows\\MyDriver"),NULL,0,NULL);
>
>
> OutputDebugString(L"===> 2 \n");
> HANDLE h = RegisterDevice(TEXT("DEM"), 1, TEXT("MyDriver.dll"), 0) ;
>
> OutputDebugString(L"===> 3 \n");
> if (h == 0)
> OutputDebugString(L"*** RegisterDevice failed\n");
>
>
>
> OutputDebugString(L"===> 4 \n");
> HINSTANCE hc = LoadLibrary(L"MyDriver.dll") ;
> if (hc != NULL)
> {
>
> ReadFromDriver() ;
>
> }
> else
> OutputDebugString(L"*** Failed LoadLibrary\n");
>
>
> CEPB OUTPUT
> ------------
> 4294885534 PID:3d6c3aa TID:3d65252 ===> 1
> 4294885535 PID:43f982c2 TID:3d65252 0x83d65000:
> DEVICE!ActivateDeviceEx(\Windows\MyDriver) entered
> 4294885536 PID:43f982c2 TID:3d65252 0x83d65000: DEVICE!StartOneDriver
> RegOpenKeyEx(\Windows\MyDriver) returned 2.
> 4294885537 PID:3d6c3aa TID:3d65252 ===> 2
> 4294885644 PID:43f982c2 TID:3d65252 0x83d65000: >>> Loading module
> MyDriver.dll at address 0x01F00000-0x01F07000
> Loaded symbols for 'D:\WINCE420\PUBLIC\MYPROJECT\MYFILES\MyDriver.DLL'
> 4294885647 PID:43f982c2 TID:3d65252 MyDriver - DLL_PROCESS_ATTACH
> 4294885648 PID:43f982c2 TID:3d65252 MyDriver - DLL_PROCESS_DETACH
> 4294885650 PID:43f982c2 TID:3d65252 0x83d65000: <<< Unloading module
> MyDriver.dll at address 0x01F00000-0x01F07000
> Unloaded symbols for 'D:\WINCE420\PUBLIC\MYPROJECT\MYFILES\MyDriver.DLL'
> 4294885653 PID:3d6c3aa TID:3d65252 ===> 3
> 4294885654 PID:3d6c3aa TID:3d65252 *** RegisterDevice failed
> 4294885655 PID:3d6c3aa TID:3d65252 ===> 4
> 4294885679 PID:3d6c3aa TID:3d65252 0x83d65000: >>> Loading module
> MyDriver.dll at address 0x01F00000-0x01F07000
> Loaded symbols for 'D:\WINCE420\PUBLIC\MYPROJECT\MYFILES\MyDriver.DLL'
> 4294885732 PID:3d6c3aa TID:3d65252 MyDriver - DLL_PROCESS_ATTACH
> 4294885733 PID:3d6c3aa TID:3d65252 Failed to open Driver...
>
>



Re: Stream Device Driver by Helix

Helix
Tue May 04 12:17:18 CDT 2004

Yannick,
thank you for answering.

I am going to follow your suggestions, but these are completely different
from the sample published on MSDN site
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnembedded/html/spotwincerambl.asp

So I wonder why MS release so 'weird' articles.
I see in the MG that my questions is a top ten FAQ so why nobody (MS)
release a sample and *functional* stream driver here ? Is it super keep
secret ?
I don't understand.
Thanks



Re: Stream Device Driver by Bruce

Bruce
Tue May 04 12:35:29 CDT 2004

Not that weird, you are just changing it. The application in that article
does not call any of the functions that you are having trouble with.
Instead, it tells you to use Platform Builder, which you don't seem to be
using, and builds the driver, application and registry into the device's OS
image.

Since you are not doing that, you need to follow Yannick's advice.

There are many sample and functional stream interface drivers available with
Platform Builder as well as much user documentation. You can order or
download the evaluation from http://msdn.microsoft.com/embedded/. It is a
big download, but ordering the CD or DVD is only a few dollars.

--
Bruce Eitman (eMVP)
Senior Engineer
Accelent Systems Inc.
www.accelent.com



Re: Stream Device Driver by Helix

Helix
Tue May 04 12:47:32 CDT 2004

Bruce,
actually I started this driver test asking weeks ago the right way and
someone told me to use this mode.

I asked "should I start from RegEnum sample in CEPB ?"
and Steve Maillet (eMVP) told me
"RegEnum isn't a particularly good sample of a stream driver as it's more of
a bus enumerator"
See post on 18-04-2004
So now I'm here *really* confused.

I have got a valid CEPB and a valid CLA at the moment.

So what about provide in the NG a sample skeleton ?
TIA

/helix

> Not that weird, you are just changing it. The application in that article
> does not call any of the functions that you are having trouble with.
> Instead, it tells you to use Platform Builder, which you don't seem to be
> using, and builds the driver, application and registry into the device's
OS
> image.
>
> Since you are not doing that, you need to follow Yannick's advice.
>
> There are many sample and functional stream interface drivers available
with
> Platform Builder as well as much user documentation. You can order or
> download the evaluation from http://msdn.microsoft.com/embedded/. It is a
> big download, but ordering the CD or DVD is only a few dollars.
>
> --
> Bruce Eitman (eMVP)
> Senior Engineer
> Accelent Systems Inc.
> www.accelent.com
>
>



Re: Stream Device Driver by Bruce

Bruce
Tue May 04 13:06:35 CDT 2004

Well, he told you that regenum wasn't a good example, but that doesn't mean
that there are not good examples provided. In this case, Steve and I are
both right.

The skeleton that you have from the article is good, you just aren't
following the example for the app. This may because the article assumed
that you already knew how to work with PB and did not tell you to build
within PB. At least on my quick review of the article, I did not see where
it actually told you to build your image, but it did tell you to use PB.

I tend to trust that if Mike Hall wrote it and Nat Frampton tested it that
the code works. But I don't know that to be a fact.

Follow Yannick's advice and see where it takes you. OR you could use PB and
follow the article, but when it tells you to run the app and the driver,
first build your project.


--
Bruce Eitman (eMVP)
Senior Engineer
Accelent Systems Inc.
www.accelent.com