Pnp driver + inf file + This device cannot start. (Code 10)

Hi

I wrote a PnP driver and inf file to test it. First I used devcon and then I installed driver and it worked , DebugView showed my DbgPrints…
But something wrong.
This is my inf file:

****************************
[Version]
Signature=“$WINDOWS NT$”
Class=System
ClassGuid={4D36E97D-E325-11CE-BFC1-08002BE10318}
Provider=%Serimc%

[SourcesDisksNames]
1=%INSTDISK%

[SourceDisksFiles]
Deneme.sys=1,objchk_wlh_x86\i386

[DestinationDirs]
DefaultDestDir=12

[Manufacturer]
%Mfg%=Serimc_Company

[Serimc_company]
%DESCRIPTION%=DenemeInstall, root\SerimcDeneme

[DenemeInstall]
CopyFiles=SYS.CopyList

[SYS.CopyList]
Deneme.sys

[DenemeInstall.Services]
AddService=Deneme,%SPSVCINST_ASSOCSERVICE%,Driver_Service

[Driver_Service]
DisplayName=%SerViceName%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\Deneme.sys

[Strings]
Mfg=“Serimc Company Ltd”
Serimc=“Serimc Soft”
INSTDISK=“Serimc Soft Driver CD”
DESCRIPTION=“Deneme Bus Enumarator”
SPSVCINST_ASSOCSERVICE=0x00000002
SerViceName=“Serimc Driver Service”

*************************************
I have 2 questions.

1-) Device Manager shows :
“This device cannot start. (Code 10)”
Also i updated driver. Then It started to show Error Code 9. Why device man. shows these?

2-) In inf file, StartType is 3 (Demand start) but Windows loads it while starting. I can see the device object in WinObj.exe. Is something wrong in my inf file? I don’t understand why it is so.
In fact , i don’t know how i can load/unload Pnp Drivers on demand by command tool or etc. I want to load and unload Pnp Drivers (like OsrLoader), how can i do this?

Attach a debugger and start debugging. Code 10 means that your driver loaded by failed to process AddDevice or IRP_MN_START_DEVICE. While your driver is demand start, you are loading on a root enumerated device. The root bus will enumerate your device during boot so by the time the machine is ready for user input, the OS has attempted to start your device.

If you want to unload/reload your driver from the cmd line, use devcon disable/enable. These map to the same commands that you can run in device manager.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, January 27, 2009 11:04 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Pnp driver + inf file + This device cannot start. (Code 10)

Hi

I wrote a PnP driver and inf file to test it. First I used devcon and then I installed driver and it worked , DebugView showed my DbgPrints…
But something wrong.
This is my inf file:

****************************
[Version]
Signature=“$WINDOWS NT$”
Class=System
ClassGuid={4D36E97D-E325-11CE-BFC1-08002BE10318}
Provider=%Serimc%

[SourcesDisksNames]
1=%INSTDISK%

[SourceDisksFiles]
Deneme.sys=1,objchk_wlh_x86\i386

[DestinationDirs]
DefaultDestDir=12

[Manufacturer]
%Mfg%=Serimc_Company

[Serimc_company]
%DESCRIPTION%=DenemeInstall, root\SerimcDeneme

[DenemeInstall]
CopyFiles=SYS.CopyList

[SYS.CopyList]
Deneme.sys

[DenemeInstall.Services]
AddService=Deneme,%SPSVCINST_ASSOCSERVICE%,Driver_Service

[Driver_Service]
DisplayName=%SerViceName%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\Deneme.sys

[Strings]
Mfg=“Serimc Company Ltd”
Serimc=“Serimc Soft”
INSTDISK=“Serimc Soft Driver CD”
DESCRIPTION=“Deneme Bus Enumarator”
SPSVCINST_ASSOCSERVICE=0x00000002
SerViceName=“Serimc Driver Service”

*************************************
I have 2 questions.

1-) Device Manager shows :
“This device cannot start. (Code 10)”
Also i updated driver. Then It started to show Error Code 9. Why device man. shows these?

2-) In inf file, StartType is 3 (Demand start) but Windows loads it while starting. I can see the device object in WinObj.exe. Is something wrong in my inf file? I don’t understand why it is so.
In fact , i don’t know how i can load/unload Pnp Drivers on demand by command tool or etc. I want to load and unload Pnp Drivers (like OsrLoader), how can i do this?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

xxxxx@gmail.com wrote:

I wrote a PnP driver and inf file to test it. First I used devcon and then I installed driver and it worked , DebugView showed my DbgPrints…
But something wrong.
This is my inf file:

I have 2 questions.

1-) Device Manager shows :
“This device cannot start. (Code 10)”
Also i updated driver. Then It started to show Error Code 9. Why device man. shows these?

I thought you said it was running fine. Code 10 means the driver failed
to load; either there was a problem with the binary, or it returned an
error from DriverEntry. Code 9 usually means something in the registry
entry for your driver is not valid.

2-) In inf file, StartType is 3 (Demand start) but Windows loads it while starting. I can see the device object in WinObj.exe. Is something wrong in my inf file? I don’t understand why it is so.

Right. Your driver IS being loaded by demand. It just so happens that
“root” enumerated devices (which you have chosen) are demand loaded
while Windows is starting. If YOU want to control the loading and
unloading, then you do not want a PnP driver. You want a legacy
driver. PnP driver loading is controlled by the PnP subsystem.

In fact , i don’t know how i can load/unload Pnp Drivers on demand by command tool or etc. I want to load and unload Pnp Drivers (like OsrLoader), how can i do this?

OsrLoader does not handle PnP drivers. It handles legacy service
drivers, which can be manually controlled.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

OK. Thank you. Understood what you mean.

I unistalled and removed devices, drivers and registry keys to start at the beginning. Now while installing Windows add hardware wizard tell me:
“A service installation section in this INF is invalid”.

I don’t understand what can be wrong is:
[Driver_Service]
DisplayName=%SerViceName%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\Deneme.sys

(I read some painful messages(experiences) about inf files, yeah, now i understand…)

xxxxx@gmail.com wrote:

I unistalled and removed devices, drivers and registry keys to start at the beginning. Now while installing Windows add hardware wizard tell me:
“A service installation section in this INF is invalid”.

I don’t understand what can be wrong is:
[Driver_Service]
DisplayName=%SerViceName%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\Deneme.sys

(I read some painful messages(experiences) about inf files, yeah, now i understand…)

The only thing Chkinf didn’t like about your INF file was that you
misspelled [SourceDisksNames] (you have it SourcesDisksNames with an
extra “s”). Beyond that, it seems fine.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thank you Tim Roberts. I corrected it.

Now, When wizard starts, it copies driver to system32\drivers. But it started to show:
“The system cannot find the file specified”

It is in here:objchk_wlh_x86\i386 . But it shows that error. I do not understand…

xxxxx@gmail.com wrote:

Thank you Tim Roberts. I corrected it.

Now, When wizard starts, it copies driver to system32\drivers. But it started to show:
“The system cannot find the file specified”

It is in here:objchk_wlh_x86\i386 . But it shows that error. I do not understand…

The documentation shows that the paths in the SourceDisksFiles section
must start with a backslash, even though they are relative.

However, allow me to offer some advice. Do not try to do your
installations directly from your build directory, as you are doing. By
doing that, you will have to change your INF file when you are ready to
switch from checked to free build, among other problems. Instead, when
you are ready to do an install, write a batch file that copies the files
you need to a “disk image” directory (I call mine “lag” for “latest and
greatest”). Then, you can do the installation from there, without
having to use subdirectories.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

OK. I changed it and at at last, it worked…

Your advices are always welcome. Thank you.