Load order in non PnP driver

T

Thomas Johansen

Hi

I have written 2 none PnP device driver, that is based on very simple driver
code. (Lecacy)
They are launch with the following registry values: (From the INF file)

DisplayName = %MyDrv.SVCDESC%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 2 ; SERVICE_AUTO_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\MyDrv.sys
LoadOrderGroup = MyGroup

1:
If I read the DDK dokumentation about load order, the LoadOrderGroup is only
valid for driveres with StartType 0 and 1.
Is this true?

From DDK Documentation:

"The Service Control Manager loads drivers of StartType SERVICE_AUTO_START
that are not yet loaded.
The Service Control Manager processes the service database information with
respect to the services' DependOnGroup and DependOnServices. This
information is from Dependencies entries in INF AddService entries. Note
that the Dependencies information is only processed for non-PnP drivers
because any necessary PnP drivers were loaded in an earlier step of system
startup. The Service Control Manager ignores INF LoadOrderGroup information.
"

If I set an diffrent LoadOrderGroup in my drivers I can see that they are
loaded in an diffrent order. Why is that if Service Control Manager ignores
the LoadOrderGroup ????


2: One of my drivers makes the system crash at boot if I select a StartType
og 0 or 1 for it (SERVICE_BOOT_START or SERVICE_SYSTEM_START), but there
DriverEntry() function is more or less the same (The crashing driver is
spawning a thread.) Any idea what could be wrong ?

Thomas
 
S

Slava M. Usov

Thomas Johansen said:
Hi

I have written 2 none PnP device driver, that is based on very simple
driver code. (Lecacy)
They are launch with the following registry values: (From the INF file)

DisplayName = %MyDrv.SVCDESC%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 2 ; SERVICE_AUTO_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\MyDrv.sys
LoadOrderGroup = MyGroup

1:
If I read the DDK dokumentation about load order, the LoadOrderGroup is
only valid for driveres with StartType 0 and 1.
Is this true?
Yes.


[...]

If I set an diffrent LoadOrderGroup in my drivers I can see that they are
loaded in an diffrent order. Why is that if Service Control Manager
ignores the LoadOrderGroup ????

Which OS?
2: One of my drivers makes the system crash at boot if I select a
StartType og 0 or 1 for it (SERVICE_BOOT_START or SERVICE_SYSTEM_START),
but there DriverEntry() function is more or less the same (The crashing
driver is spawning a thread.) Any idea what could be wrong ?

You should attach a debugger and see what happens. At the very least, make
you driver emit debug messages as it proceeds and monitor them with
sysinternals' DbgViewer. Or make it write to a file.

Generally, boot and system-start drivers execute in a not completely
initialized environment, so some registry, file and network functions can
fail. Some other underlying drivers may not be ready, too. The driver must
carefully check return codes and make no "it cannot fail" assumptions.

S
 
M

Maxim S. Shatskih

Generally, boot and system-start drivers execute in a not completely
initialized environment, so some registry, file and network functions can

The init paths of the Boot drivers cannot access any filesystems.
The init paths of the System drivers can access the \SystemRoot\... paths only.

SOFTWARE registry is mounted by far later, so, it is mauvetone to use it in the
drivers.
SYSTEM registry, in turn, is accessible to any drivers read-write, even Boot
ones.
 
T

Thomas Johansen

If I read the DDK dokumentation about load order, the LoadOrderGroup is

How can I then be sure, that my own driver (with Start = 0x02) is started
before my application ?? or is this allways the case ?

Is there any way of specify when the driver with Start = 0x02 has to be
started ?
[...]
If I set an diffrent LoadOrderGroup in my drivers I can see that they are
loaded in an diffrent order. Why is that if Service Control Manager
ignores the LoadOrderGroup ????

Which OS?

WinXP embedded
 
S

Slava M. Usov

How can I then be sure, that my own driver (with Start = 0x02) is started
before my application ?? or is this allways the case ?

If your application is a service, you might try dependencies. If it is a
user application, I seem to remember there is some policy setting that
prevents users from logging on until services have been started. May be
wrong, though.
Is there any way of specify when the driver with Start = 0x02 has to be
started ?

Your application might just start it when it needs it.
WinXP embedded

It starts auto-start drivers and services asynchronously, so the order is
generally unpredictable.

S
 
T

Thomas Johansen

It starts auto-start drivers and services asynchronously, so the order is
generally unpredictable.

Ok.. But my application that need the drivers, isn't a service but an
application launched from the StartUp folder. But there still ain't any
garantie that my drivers are started when my App. is launched ?
 
K

Kirk Ferdmann

Thomas Johansen said:
Ok.. But my application that need the drivers, isn't a service but an
application launched from the StartUp folder. But there still ain't any
garantie that my drivers are started when my App. is launched ?

No guaranties. It's a common case for programs like background antivirus
scanners, personal firewalls, etc. You might notice that when you log on
they usually start in a "disconnected" state. They poll for the driver to be
ready and switch into "functional" state.

-Kirk
 
S

Slava M. Usov

Thomas Johansen said:
Ok.. But my application that need the drivers, isn't a service but an
application launched from the StartUp folder. But there still ain't any
garantie that my drivers are started when my App. is launched ?

You have to poll. Or make it demand-start and start it manually. Or make it
boot or system-start.

S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top