Книга: Writing Windows WDM Device Drivers

Cross-Platform and WDM INF Files

Cross-Platform and WDM INF Files

You can create a single INF file that handles all the necessary details for the different Windows 2000 platforms and Windows 98.

The Version section Signature entry value is not used to determine the supported platforms. Instead, each platform has a different install section indicating what to do for that platform. The sections have a common base name, with additional "decoration" characters at the end of the section name to indicate the platform. If there are no section platform variants, the basic section covers all W2000 platforms and W98.

If there are sections with different platform variants, the following rules apply. If there is no decoration, the section covers W98. .NTx86 covers the W2000 x86 platform. .NTalpha covers the W2000 alpha platform. . NT covers all W2000 platforms. You need to supply only the relevant sections.

This install section covers all platforms:

[Abc_Install]

These two sections handle Windows 98 and Windows 2000 x86 cases.

[Def_Install] ; Windows 98

[Def_Install .NTx86]
; Windows 2000 x86 platform

Note that the Windows 98 setup code needs commas for all the optional values, while Windows 2000 can survive without them. For example, in the SourceDisksFiles section, each entry is documented as

filename = diskid[,[subdir][,size]]

The filename entry has two optional values. If you are going to leave these out in an INF file, make sure that you put two commas in, so that it works in Windows 98.

filename=diskid,,

Installing Wdm1 in Windows 2000

The Wdm1free.INF installation file in Listing 11.1 has separate installation instructions for Windows 2000.

The base section name for the Wdm1 device installation is Wdm1.Install. As there is a section named Wdm1.Install.NTx86 present, this section's instructions are used for the Windows 2000 x86 platform.

Wdm1.Install.NTx86 has just a CopyFiles directive. The Wdm1.Files. Driver.NTx86 section lists just Wdm1.sys, as before. This time, %COPYFLG_NOSKIP% is specified in the fourth field.

This indicates that the user cannot skip this file. There is no point in skipping the driver file in a Wdm1 installation. Note how the COPYFLG_NOSKIP string is used to hide the value 2.

[Wdm1.Files.Driver.NTx86]
Wdm1.sys,,,%COPYFLG_NOSKIP%
[Strings]
COPYFLG_NOSKIP=2 ; Do not allow user to skip file

Windows 2000 Service Registry Entries

A Windows 2000 device driver needs to be installed as a service. This means creating a registry key with the same name as the driver executable in HKLMSystemCurrentControlSetServices.

The default installer finds the Wdm1.Install.NTx86.Services section. It first adds the relevant decoration .NTx86 and then adds .Services. This section lists the services that must be added. The service is called Wdm1. The %SPSVCINST_ASSOCSERVICE% value means that the service is associated with a device. The final field says that the Wdm1.Service section has the service registry details.

[Wdm1.Install.NTx86.Services]
AddService = Wdm1, %SPSVCINST_ASSOCSERVICE%, Wdm1.Service
[Wdm1.Service]
DisplayName = %Wdm1.ServiceName%
ServiceType =%SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_NORMAL%
ServiceBinary = %10%System32DriversWdm1.sys

A Windows 2000 service key must have ServiceType, StartType, ErrorControl, and ServiceBinary entries. These eventually appear as Type, Start, ErrorControl, and ImagePath registry entries, respectively. A DisplayName value and registry entry are usually added, as well.

The ServiceType entry must be %SERVICE_KERNEL_DRIVER% (1) for a kernel mode driver. Various other bits can be set such as %SERVICE_FILE_SYSTEM_DRIVER% (2).

The StartType entry specifies when the driver must be started, as shown in the list in Table 11.4. WDM device drivers should specify %SERVICE_DEMAND_START% (3).

Table 11.4 Service StartType values

Value Constant Description
0 SERVICE_BOOT_START Start when W2000 is loaded.
1 SERVICE_SYSTEM_START Start when W2000 is initializing itself.
2 SERVICE_AUTO_START Start when W2000 is up and running.
3 SERVICE_DEMAND_START Start manually or when an associated device is added.
4 SERVICE_DISABLED Never start.

The ErrorControl entry specifies how the system should respond if the driver cannot load, as shown in the list in Table 11.5. The Wdm1 installation opts for normal error logging.

Table 11.5 Service ErrorControl values

Value Constant Description
0 SERVICE_ERROR_IGNORE Log error but do not display a message to the user.
1 SERVICE_ERROR_NORMAL Log error and display a warning message.
2 SERVICE_ERROR_SEVERE Log error and restart with last known good configuration.
3 SERVICE_ERROR_CRITICAL Log error. Try last known good configuration. If this fails, force a bugcheck.

The AddService directive may also contain a further field, which specifies a section that is used to install NT event logging registries. I found that this did not work in the Beta 2 version of Windows 2000.

Several other entries may appear in a Services section that let you insert further registry entries. Some of these are used to determine the load order of drivers that are auto-started, as described in the following text.

Оглавление книги


Генерация: 0.029. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз