1 / 23
文档名称:

WDM内部培训资料.ppt

格式:ppt   页数:23
下载后只包含 1 个 PPT 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

WDM内部培训资料.ppt

上传人:企业资源 2012/2/16 文件大小:0 KB

下载得到文件列表

WDM内部培训资料.ppt

文档介绍

文档介绍:1
WDM (Windows Driver Model)
. Hua
2005-04-29
2
Requirements
Familiar with c, c++ programming
Somewhat familiar with windows programming
3
Driver Model used on various OS
NT4 KMD (Kernel Model Driver)
Win95 VxD (Virtual Device Driver)
Win98/Me VxD, WDM
Win2000/XP KMD, WDM
4
Use driver to access hardware
application
User mode
Kernel mode
driver
I/O port
Physical memory
hardware
5
Driver building environment
Visual studio piler, linker, editor
Win98/Me/2000/XP DDK library, header file for driver
6
Driver loading
Static load, boot-time load - Load driver when os booting - Win98/Me only
Dynamic load, run-time load - Load driver when application open driver - Win2k/Xp can static or dynamic
7
Static load
1. Copy driver to <windir>\system32\drivers 98/Me/XP <windir> = c:\windows, 2k <windir> = c:\winnt
2. Add Registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\TESTDRV
3. Add Registry value under added TESTDRV key ErrorControl = 1 (DWORD) Type = 1 (DWORD) Start = 1 (DWORD)
4. puter
8
Service
Only on win2k/xp.
Service is a special program independent from multi-user session.
It can be running before user login.
2 kind of service. Application service and driver service.
Driver service is for dynamic load.
9
Application call driver
main()
{
CreateDriverService(); // for dynamic load only
HANDLE h=OpenDriver();

DeviceIoControl(h,,,); // ask driver do something
CloseHandle(h);
DeleteDriverService(); // for dynamic load only
}
Green color is Win32 API.
Yellow color is sub function.
10
DeviceIoControl()
BOOL DeviceIoControl(
HANDLE hDevice, // in - handle to device
DWORD dwIoControlCode, // in - operation control code
LPVOID lpInBuffer, // in - input data buffer
DWORD nInBufferSize, // in - size of input data buffer
LPVOID lpOutBuffer, // out - output data buffer
DWORD nOutBufferSize, // in - size of output data buffer
LPDWORD lpBytesReturned, // out - byte count
LPOVERLAPPED lpOverlapped // in