Chris Cant - Writing Windows WDM Device Drivers

Здесь есть возможность читать онлайн «Chris Cant - Writing Windows WDM Device Drivers» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: Lawrence, Kansas 66046, ISBN: , Издательство: R & D Books, Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Writing Windows WDM Device Drivers: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Writing Windows WDM Device Drivers»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

Writing Windows WDM Device Drivers — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Writing Windows WDM Device Drivers», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

USB\VID_046A&PID_0001

In Windows 2000, this Hardware ID is found in INPUT. INF. The installation section prompts the loading of the HID class drivers and the HID USB minidriver.

The HID USB minidriver is loaded for the new device. It generates a new Hardware ID to represent the HID device.

HID\VID_046A&PID_0001

In Windows 2000, this Hardware ID is found in KEYBOARD.INF. The installation section loads the system keyboard driver and the driver that provides the keyboard interface to the HID class drivers.

In Windows 98, the Cherry HID USB keyboard is installed in one step, because the KEYBOARD. INF detects the USB\VID_046A&PID_0001 Hardware ID.

NT Style Driver Installation

NT style (non-WDM) kernel mode drivers for NT 3.51, NT 4, and Windows 2000 [28] NT style drivers may well work in Windows 98, as well. See the next section for details. can be installed by hand. This means copying the driver executable to the Windows System32\Drivers directory, making the right registry settings and rebooting the system. However, it is far safer to write an installation program to do the job [29] NT 4 driver writers can write an OEMSETUP.INF or TXTSETUP.OEM script to install their drivers. See the NT 4 DDK for details. .

You need to use the appropriate Win32 function calls to copy files and alter the registry. In addition, you must use the Windows 2000 Service Control Manager functions.

The code in install.cpp (on the book's CD-ROM) shows how to install an NT style driver. This is not a complete Win32 program. You must embed it in your own installation application.

The InstallDriver routine controls the whole installation process. It calls CreateDriver and StartDriver , when appropriate. FindInMultiSz is used to see if the driver name is in a REG_MULTI_SZ value. The code follows the logic laid out in the following sections to install a driver called "AbcDriver".

install.cpp installs two sets of registry values that I have not mentioned before.

• Event log registry entries are added. See Chapter 13 for details.

• The driver has a Parameters subkey. The values in this subkey are used to control some global features of the driver. You might like to write a Control Panel applet or other control application to let users modify these values.

Install Process

1. Get the Windows System32 directory using GetSystemDirectory . Use CopyFile to copy your driver to the System32\Drivers directory.

2. Create the driver service (or stop the existing driver) — see the following.

3. Make the appropriate driver registry key, e.g., HKLM\SYSTEM\CurrentControlSet\Services\AbcDriver using RegCreateKeyEx .

Set ErrorControl, Start, and Type registry values in the previous key using RegSetValueEx.

If desired, set Group, DependOnGroup, and DependOnService registry values, etc. as described later.

4. If desired, make a Parameters registry key (e.g., HKLM\SYSTEM\CurrentControlSet\Services\AbcDriver\Parameters) and set any appropriate values.

5. Open the event log registry key at HKLM\SYSTEM\CurrentControlSet\Services\EventLog\System.

Read the Sources value from this key.

See if your driver is in this list. If not, add your null-terminated driver name to Sources and write it back to the registry.

6. Create the driver event log registry key at HKLM\SYSTEM\CurrentControlSet\Services\EventLog\System\AbcDriver.

Set the TypesSupported and EventMessageFile values.

7. Start the driver — see the following.

Creating or Stopping a Driver Service

1. Open the Service Control Manager using OpenSCManager .

2. Try to open your driver service using OpenService .

If OpenService exists, see if it is currently running using ControlService SERVICE_CONTROL_INTERROGATE.

If OpenService is running, stop it using ControlService SERVICE_CONTROL_STOP.

Give the driver 10 seconds to stop, checking every second with ControlService SERVICE_CONTROL_INTERROGATE.

Close the driver service handle using CloseServiceHandle . Return.

3. Create the driver service using CreateService .

4. Close the Service Control Manager using CloseServiceHandle .

Starting a Driver

1. Open the Service Control Manager using OpenSCManager .

2. Open your driver service using OpenService .

3. Get the driver run state using ControlService SERVICE_CONTROL_INTERROGATE.

4. If need be, call StartService to start your driver.

Give it 10 seconds to start, checking every second with ControlService SERVICE_CONTROL_INTERROGATE.

5. Close the driver service and Service Control Manager using CloseServiceHandle .

Driver Load Order

In NT 3.51, NT 4, and Windows 2000 various registry entries affect the load order of drivers. While these entries can be used for WDM device drivers, the Plug and Plug enumeration process usually ensures that drivers are loaded in the right order.

Each driver can be put in a group. Tags determine the driver load order within a group. Each driver can insist that it is loaded after a particular group or driver has loaded. Groups are loaded in a ServiceGroupOrder.

The DependOnGroup entry in a driver's service registry key is a REG_MULTI_SZ stating which groups must be loaded before this driver. Similarly, DependOnService is a REG_MULTI_SZ listing the drivers and services that must be loaded before this driver.

The Group entry is a REG_SZ giving the driver's group name. Tag is a REG_DWORD giving the driver tag number. The HKLM\SYSTEM\CurrentControlSet\Control\GroupOrderList registry key has a REG_BINARY entry for each group. The first byte of this binary data is the tag count. The following DWORDs contain the tags of the drivers in the order that they should be loaded. Three NULL bytes pad out the binary data.

The HKLM\SYSTEM\CurrentControlSet\Control\ServiceOrderList registry key has a REG_ MULTI_SZ entry called List. The strings in the list are the driver group names in the order that they should be loaded.

A driver's Start setting, shown in Table 11.4, will override all these driver loading rules.

NT 4 Control Panel Devices Applet

In NT 4 and NT 3.51, the Control Panel Devices applet can be used to start and stop drivers and set the Startup option. Figure 11.2 shows the Devices applet in action.

Figure 11.2 NT 4 Control Panel Devices

Windows 2000 Device Management

In Windows 2000, the recommended tool for most device management tasks is the Computer Management console. This is found in the Start menu Programs+Administrative tools+Computer Management option. The Device Manager is also available from the Control Panel System applet.

Figure 11.3 shows the Computer Management console running on my computer with the Device Manager Devices selected. You can get this same view from the Control Panel System applet; select the Hardware tab and click on Device Manager.

You can see Wdm1 and Wdm2 devices in the "Other Devices" (Unknown) category, along with the DebugPrint driver. Right-click on the driver name to uninstall it or update the driver from its properties box.

You can see any non-WDM drivers by right-clicking on Devices. Select View in the pop up menu. Check the "Show hidden devices" option. The devices display now includes a "Non-Plug and Play Drivers" category. You can start and stop the NT style drivers and change their startup options.

Figure 11.3 W2000 Computer Management console

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Writing Windows WDM Device Drivers»

Представляем Вашему вниманию похожие книги на «Writing Windows WDM Device Drivers» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Writing Windows WDM Device Drivers»

Обсуждение, отзывы о книге «Writing Windows WDM Device Drivers» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x