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», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

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

Интервал:

Закладка:

Сделать

CloseServiceHandle(hSCManager);

CloseServiceHandle(hDriver);

return FALSE;

}

}

CloseServiceHandle(hDriver);

}

return TRUE;

}

//////////////////////////////////////////////////////////////////////

// Create driver service

hDriver = CreateService(hSCManager, DriverName.DriverName, SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, SERVICE_AUTO_START,

SERVICE_ERROR_NORMAL, Drivers, NULL, NULL,"parport\0\0", NULL, NULL);

if (hDriver==NULL) {

AfxMessageBox("Could not install driver with Service Control Manager");

CloseServiceHandle(hSCManager);

return FALSE;

}

//////////////////////////////////////////////////////////////////////

CloseServiceHandle(hSCManager);

return TRUE;

}

///////////////////////////////////////////////////////////////////////

BOOL StartDriver(CString DriverName) {

//////////////////////////////////////////////////////////////////////

// Open service control manager

SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);

if (hSCManager==NULL) {

AfxMessageBox("Could not open Service Control Manager");

return FALSE;

}

//////////////////////////////////////////////////////////////////////

// Driver isn't there

SC_HANDLE hDriver = OpenService(hSCManager,DriverName,SERVICE_ALL_ACCESS);

if (hDriver==NULL) {

AfxMessageBox("Could not open driver service");

CloseServiceHandle(hSCManager);

return FALSE;

}

SERVICE_STATUS ss;

if (!ControlService(hDriver, SERVICE_CONTROL_INTERROGATE, &ss) ss.dwCurrentState!=SERVICE_STOPPED) {

AfxMessageBox("Could not interrogate driver service");

CloseServiceHandle(hSCManager);

CloseServiceHandle(hDriver);

return FALSE;

}

if (!StartService(hDriver, 0, NULL)) {

AfxMessageBox("Could not start driver");

CloseServiceHandle(hSCManager);

CloseServiceHandle(hDriver);

return FALSE;

}

// Give it 10 seconds to start

BOOL Started = FALSE;

for (int seconds=0; seconds<10; seconds++) {

Sleep(1000);

if (ControlService(hDriver, SERVICE_CONTROL_INTERROGATE, &ss) & ss.dwCurrentState==SERVICE_RUNNING) {

Started = TRUE;

break;

}

}

if (!Started) {

AfxMessageBox("Could not start driver");

CloseServiceHandle(hSCManager);

CloseServiceHandle(hDriver);

return FALSE;

}

CloseServiceHandle(hDriver);

CloseServiceHandle(hSCManager);

return TRUE;

}

///////////////////////////////////////////////////////////////////////

//Try to find Match in MultiSz, including Match's terminating \0

int FindInMultiSz(LPTSTR MultiSz, int MultiSzLen, LPTSTR Match) {

int MatchLen = strlen(Match);

_TCHAR FirstChar = *Match;

for (int i=0; i

if (*MultiSz++ == FirstChar) {

BOOL Found = TRUE;

LPTSTR Try = MultiSz;

for (int j=1; j<=MatchLen; j++)

if (*Try++ != Match[j]) {

Found = FALSE;

break;

}

if (Found) return i;

}

}

return –1;

}

///////////////////////////////////////////////////////////////////////

Note: A revised version of NTNinstall.cpp is available on the book's web site, www.phdcc.com/wdmbook. This updated version fixes a problem to make it work in W2000.

Chapter 12

Windows Management Instrumentation

This chapter looks at Windows Management Instrumentation (WMI), the first of two methods of reporting management information to system administrators. The alternative — NT events for NT 3.51, NT 4, and Windows 2000 drivers — is covered in the next chapter. NT events are not recorded in Windows 98.

Windows Management Instrumentation is supposed to work in most Windows platforms. However, it did not work for me in Windows 98. As well as reporting information and firing events, WMI lets users set values that control the operation of a device or even invoke driver methods.

If possible, a driver should support the "WMI extensions for WDM". Although not mandatory, it can make it easier to debug or control your driver in the field. WMI support is required for some system functions (e.g., if you want to support user control of Power Management options in the device properties tab). If you do not support WMI, please provide a default WMI IRP handler such as in the Wdm1SystemControl routine.

The example Wdm3 driver builds on the Wdm2 driver, adding WMI and NT event support. It handles the standard MSPower_DeviceEnable WMI data block and defines its own custom WMI data block called Wdm3Information . The Wdm3Information data block returns three pieces of information to a user for each Wdm3 device: the length of the buffer, the first DWORD of the buffer contents, and the symbolic link name of the device.

I was not able to get these two further aspects of WMI working in the Beta version of W2000. A user is supposed to be able to invoke a function within the driver. The driver is supposed to be able to fire a WMI event that will be displayed in a user application.

I must first start with an overview of WMI. Although this overview appears quite complicated, it is actually fairly straightforward to support WMI in a driver.

Overview

A driver that implements the WMI extensions for WDM provides information and events to user applications, and these applications can invoke driver methods. The emphasis is on providing diagnostic and management information and tools, not the regular control of a driver.

WMI is part of the Web-Based Enterprise Management (WBEM) initiative that aims to reduce the total cost of computer ownership. WBEM is on-line at www.microsoft.com/management/wbem/. WBEM gives network professionals easy access to all the resources under their control. As the name suggests, the emphasis is on using browsers to access the information across a whole enterprise, either using COM ActiveX controls or a Java API on top of the HyperMedia Management Protocol (HMMP). Standard Win32 user programs can access WBEM repositories using COM APIs.

The WBEM core components are installed by default in Windows 2000 and are available in Windows 98 [30] In Windows 98, select the Control Panel "Add/Remove Programs" applet. Click the Windows Setup tab. Highlight the Internet Tools options. Click on Details. Check the "Web-based Enterprise Mgmt" box. Click OK to proceed with the installation. You will need the WBEM core kit and possibly other components for NT 4 and Windows 95. . To inspect the WBEM repository, you will need the WBEM SDK, available on-line and on the MSDN CDs.

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

Интервал:

Закладка:

Сделать

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

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


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

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

x