数学专业英语论文

数学专业英语论文

班级:信计C122 名字:王陈 学号:126515 英语论文内容:

The device driver notifies the application of several methods

Papers Category:Computer Papers - Computer Application Papers Post Time:2013-2-6 9:48:00

In the current popular Windows operating system, device drivers is the lowest level of manipulation of hardware software interface. To share the device driver design process experience, given the device driver notifies the application of the five kinds of ways, each method specifically described the principle and implementation process, hoping to give the designer of the device driver to provide some help.

Operating system in order to ensure peace and stability, and application portability, Windows operating system does not allow applications direct access to the system's hardware resources, but must resort to the appropriate device driver. Device drivers can directly manipulate the hardware, if applications and device drivers to achieve a two-way communication between, also reached the underlying hardware device application control purposes. Communication between them, including two aspects Abstract: On the one hand is the application sent to the device driver data; hand is the device driver sends a message to the application. The former to achieve more easily through CreateFile () function to obtain a handle to the device driver, you can use the Win32 functions such as DeviceIoControl (), ReadFile () or WriteFile (), etc. to achieve application and device driver communication. Implementation of the latter than the former complex and the article describes the situation in this respect less. This does not mean that it is not important, on the contrary, it is in some applications play an important function. Device drivers complete the data collection work, the need to immediately notify the application so that the application can be promptly removed and the data is processed. In cases like these, and so forth.

In view of the device driver notifies the application of the importance, I combined some experience, it was summarized summarized five methods Abstract:

asynchronous procedure call (APC), event mode (VxD), messaging, asynchronous I / O modes and event mode (WDM). Below were the principles of this in several ways, and given of some of the source code.

An asynchronous procedure call (APC)

Win32 applications using CreateFile () function to dynamically load the device driver, and then define a callback function backFunc (), and the address of the callback function% 26amp; backFunc () as a parameter, through DeviceIoControl

() sent to the device driver. Device drivers to get the address of a callback function, it will save it in a global variable (eg callback), the simultaneous calls

Get_Cur_Thread_Handle () function to get its application thread handle, and the handle is stored in a global variable (eg appthread ) in. When conditions are ripe, the device driver calls _VWIN32_QueueUserApc () function to send messages to the Win32 application. This function takes three arguments Abstract: The first parameter is the address of the callback function (already registered); second parameter is passed to the callback message; third parameter to the caller's thread handle (already registered). Win32 application receives a message, the automatic callback function (actually called by the device driver). Callback

function of the input parameters are populated by the device driver, the callback function here is mainly to handle the message.

2 Event mode (VxD)

First, Win32 applications to create an event handler, called Ring3

handle. Because the virtual device driver using events Ring0 handle, so you need to create Ring0 handle. Using LoadLibrary () function to load the dynamic link library undisclosed Kernel32.dll, get dynamic link library handle. Then, call GetProcAddress (), find the function OpenVxDHandle () in the dynamic link

library location. Then, OpenVxDHandle () function will Ring3 event handlers into Ring0 event handler. Win32 applications using CreateFile () function to load the device driver. If the load is successful, call the DeviceIoControl () function will be

passed to the event handler Ring0 VxD; while waiting for the signal to create a worker thread becomes signaled state itself can shop and other things. When conditions are ripe, VxD set Ring0 event to signaled state (called

_VWIN32_SetWin32Event () function), which corresponds to Ring3 immediately trigger event to signaled state. Once Ring3 event handler for the signaled state, Win32 application's worker thread on this news be handled accordingly. 3 message mode

Win32 application calls CreateFile () function to dynamically load the virtual device driver. Loaded successfully, by calling DeviceIoControl () function handles the form sent to VxD, VxD use this handle to form a message. When the conditions are met, VxD calls SHELL_PostMessage () function to send messages to Win32 applications. To make use of this function successfully, you must use # define to customize a message, and even so it is defined in the application; also used in the message loop ON_MESSAGE () to define the

message processing function corresponding to the message so that the message is generated , can call the message handler. SHELL_PostMessage () function's first argument for Win32 window handle, the second parameter is the message ID number, and the third, four parameters are sent to the message processing

function parameters, fifth, six parameters for the callback function and pass to its parameters. Win32 application receives a message, the message is processed. 4 asynchronous I / O mode

Win32 application first calls the CreateFile () function to load the

device driver. Before calling this function, the penultimate two parameter is set to FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, saying that he can file overlapped I / O operations. When the device driver file is successfully created, create an initial state is no signal, you need to manually reset the event, and will pass this event type is OVERLAPPED data structure (eg Overlapped). Then, Overlapped as a parameter passed to DeviceIoControl () function. Device driver put the I / O request packet (IRP) is set to pending status, and set a cancel routine. If the current IRP queue is empty, then the IRP sent to StartIo () routine;

Otherwise, put it IRP queue. Device drivers after completing such work, ending the DeviceIoControl () processing, so do not wait for Win32 applications may IRP processed, from DeviceIoControl () call to return. By determining the return

value, get the IRP handling. If the current IRP is pending, then the main program do some other work, then call WaitForSingleObject () or WaitForMultipleObject () function waits for the event become Overlapped signal state. Device drivers at the appropriate time to handle the queued IRP, processing is complete, call

IoCompleteRequest () function. This function Overlapped the event is set to the signaled state. Win32 applications to respond to this incident immediately exit the wait state, and no signal will be reset to the state of the event, and then call GetOverlappedResult ()

Function to get the result of the IRP process.

5 Event mode (WDM)

Win32 application first creates an event, and then passed to the event handler device drivers, then create a secondary thread, waiting for an event signaled that he will go on other things. Device drivers access the event handle, can be used to convert it to an event pointer register and put it up for later use. When the conditions are met, the device driver will set the event to signaled state, so that the application of the worker thread immediately know the news, then make the appropriate treatment. When the device driver no longer uses this event, the event should be lifted pointer.

6 Conclusion

In the current popular Windows operating system, device drivers is the lowest level of manipulation of hardware software interface. It offers up a user interface and hardware-independent, down directly I / O, hardware interrupts, DMA and memory access and other operations. It applications and hardware details shields, so do not rely on the hardware and software available in portable between

different platforms. This article describes the five kinds of device driver notifies the application, in which the first three methods are mainly used in VxD, the latter two methods is mainly used for WDM. This 5 ways to have been the actual

test. Test results show that they are able to reach the device driver notifies the application purposes.

References Abstract:

[1 European Youth Li, XU Jian-bo, LI Fang-min, etc. virtual device driver VxD inquiry and development. Computer Engineering, 2003

[2 (America) Chris Cant. Windows WDM Device Driver Development Guide. Sun Yi, Ma Libo, the country Xuefei, M., Beijing Abstract: Mechanical Industry Press, 2000

[3 Li Heping DSP-based image reconstruction system to explore ICT, Beijing Abstract: Beijing University of Aeronautics and Astronautics Mechanical Engineering and Automation, 2002

汉语翻译内容:

设备驱动程序通知应用程序的几种方法

文件类别:计算机论文-------计算机应用论文

发表时间:2013-2-6 9:48:00

在目前流行的Windows 操作系统中,设备驱动程序是操纵硬件的最底层软件接口。为了共享在设备驱动程序设计过程中的经验,给出设备驱动程序通知应用程序的5种方法,具体说明每种方法的原理和实现过程,希望能够给设备驱动程序的设计者提供一些帮助。

为了保证操作系统的平安性和稳定性以及应用程序的可移植性,Windows 操作系统不答应应用程序直接访问系统的硬件资源,而是必须借助于相应的设备驱动程序。设备驱动程序可以直接操作硬件,假如应用程序和设备驱动程序之间实现了双向通信,也就达到了应用程序控制底层硬件设备的目的。它们之间的通信包括两个方面摘要:一方面是应用程序传送给设备驱动程序的数据;另一方面是设备驱动程序发送给应用程序的消息。前者的实现较轻易,通过CreateFile()函数获取设备驱动程序的句柄后,就可以使用Win32函数,如DeviceIoControl()、ReadFile()或WriteFile()等实现应用程序和设备驱动程序之间的通

信。后者的实现远比前者复杂,同时介绍这方面情况的文章较少。这不等于说它不重要,相反,它在有些应用场合发挥着重要的功能。设备驱动程序完成数据的采集工作后,需要马上通知应用程序,以便应用程序能够及时将数据取走并进行处理。诸如此类情况,不一而足。 鉴于设备驱动程序通知应用程序的重要性,本人结合一些经验,对它进行了总结,归纳出5种方法摘要:异步过程调用(APC)、事件方式(VxD )、消息方式、异步I/O方式和事件方式(WDM)。下面分别说明这几种方式的原理,并给出实现的部分源代码。

1 异步过程调用(APC)

Win32应用程序使用CreateFile()函数动态加载设备驱动程序,然后定义一个回调函数backFunc(),并且将回调函数的地址%26amp;backFunc()作为参数,通过DeviceIoControl()传送给设备驱动程序。设备驱动程序获得回调函数的地址后,将它保存在一个全局变量(如callback )中,同时调用Get_Cur_Thread_Handle()函数获取它的应用程序线程的句柄,并且将该句柄保存在一个全局变量(如appthread )中。当条件成熟时,设备驱动程序调用_VWIN32_QueueUserApc()函数,向Win32应用程序发送消息。这个函数带有三个参数摘要:第一个参数为回调函数的地址(已经注册);第二个参数为传递给回调函数的消息;第三个参数为调用者的线程句柄(已经注册)。Win32应用程序收到消息后,自动调用回调函数(实际是由设备驱动程序调用)。回调函数的输入参数是由设备驱动程序填入的,回调函数在这里主要是对消息进行处理。

2 事件方式(VxD )

首先,Win32应用程序创建一个事件的句柄,称其为Ring3句柄。由于虚拟设备驱动程序使用事件的Ring0句柄,因此,需要创建Ring0句柄。用LoadLibrary()函数加载未公开的动态链接库Kernel32.dll ,获得动态链接库的句柄。然后,调用GetProcAddress(), 找到函数OpenVxDHandle()在动态链接库中的位置。接着,用OpenVxDHandle()函数将Ring3事件句柄转化为Ring0事件句柄。Win32应用程序用CreateFile()函数加载设备驱动程序。假如加载成功,则调用DeviceIoControl()函数将Ring0事件句柄传给VxD ;同时,创建一个辅助线程等待信号变成有信号状态,本身则可去干其它的事情。当条件成熟时,VxD 置

Ring0事件为有信号状态(调用_VWIN32_SetWin32Event()函数),这马上触发对应的Ring3事件为有信号状态。一旦Ring3事件句柄为有信号状态,Win32应用程序的辅助线程就对这个消息进行相应的处理。

3 消息方式

Win32应用程序调用CreateFile()函数动态加载虚拟设备驱动程序。加载成功后,通过调用DeviceIoControl()函数将窗体句柄传送给VxD ,VxD 利用这个句柄向窗体发消息。当条件满足时,VxD 调用SHELL_PostMessage()函数向Win32应用程序发送消息。要让该函数使用成功,必须用#define来自定义一个消息,并且也要照样在应用程序中定义它;还要在消息循环中使用ON_MESSAGE()来定义消息对应的消息处理函数,以便消息产生时,能够调用消息处理函数。SHELL_PostMessage()函数的第一个参数为Win32窗体句柄,第二个参数为消息ID 号,第三、四个参数为发送给消息处理函数的参数,第五、六个参数为回调函数和传给它的参数。Win32应用程序收到消息后,对消息进行处理。

4 异步I/O方式

Win32应用程序首先调用CreateFile()函数加载设备驱动程序。在调用该函数时,将倒数第2个参数设置为FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED,表示以后可以对文件进行重叠I/O操作。当设备驱动程序文件创建成功后,创建一个初始态为无信号、需要手动复位的事件,并且将这个事件传给类型为OVERLAPPED 的数据结构(如Overlapped )。然后,将Overlapped 作为一个参数,传给DeviceIoControl()函数。设备驱动程序把这个I/O请求包(IRP )设置为挂起状态,并且设置一个取消例程。假如当前IRP 队列为空,则将这个IRP 传送给StartIo()例程;否则,将它放到IRP 队列中。设备驱动程序做完这些工作后,结束这个DeviceIoControl()的处理,于是Win32应用程序可能不等待IRP 处理完,就从DeviceIoControl()的调用中返回。通过判定返回值,得到IRP 的处理情况。假如当前IRP 处于挂起状态,则主程序先做一些其它的工作,然后调用WaitForSingleObject()或WaitForMultipleObject()函数等待Overlapped 中的事件成为有信号状态。设备驱动程序在适当的时候处理排队的IRP ,处理完成后,调用IoCompleteRequest()函数。该函数将

Overlapped 中的事件设置为有信号状态。Win32应用程序对这个事件马上进行响应,退出等待状态,并且将事件复位为无信号状态,然后调用GetOverlappedResult()

函数获取IRP 的处理结果。

5 事件方式(WDM )

Win32应用程序首先创建一个事件,然后将该事件句柄传给设备驱动程序,接着创建一个辅助线程,等待事件的有信号状态,自己则接着干其它事情。设备驱动程序获得该事件的句柄后,将它转换成能够使用的事件指针,并且把它寄存起来,以便后面使用。当条件具备后,设备驱动程序将事件设置为有信号状态,这样应用程序的辅助线程马上知道这个消息,于是进行相应的处理。当设备驱动程序不再使用这个事件时,应该解除该事件的指针。

6 结语

在目前流行的Windows 操作系统中,设备驱动程序是操纵硬件的最底层软件接口。它向上提供和硬件无关的用户接口,向下直接进行I/O、硬件中断、DMA 和内存访问等操作。它将应用程序和硬件细节屏蔽开来,使软件不依靠于硬件并且可在多个不同的平台之间移植。本文介绍了5种设备驱动程序通知应用程序的方法,其中前3种方法主要用于VxD 中,后2种方法主要用于WDM 。这5种方法都经过实际测试。测试结果表明,它们都能够达到设备驱动程序通知应用程序的目的。

参考文献

摘要:

[1欧青立,徐建波,李方敏,等. 虚拟设备驱动程序VxD 的探究和开发. 计算机工程,2003

[2(美)Chris Cant. Windows WDM设备驱动程序开发指南. 孙义, 马莉波, 国雪飞等译. 北京摘要: 机械工业出版社 2000

[3李和平. 基于DSP 的ICT 图像重建系统探究. 北京摘要: 北京航空航天大学机械工程及自动化学院, 2002

数学专业英语论文

班级:信计C122 名字:王陈 学号:126515 英语论文内容:

The device driver notifies the application of several methods

Papers Category:Computer Papers - Computer Application Papers Post Time:2013-2-6 9:48:00

In the current popular Windows operating system, device drivers is the lowest level of manipulation of hardware software interface. To share the device driver design process experience, given the device driver notifies the application of the five kinds of ways, each method specifically described the principle and implementation process, hoping to give the designer of the device driver to provide some help.

Operating system in order to ensure peace and stability, and application portability, Windows operating system does not allow applications direct access to the system's hardware resources, but must resort to the appropriate device driver. Device drivers can directly manipulate the hardware, if applications and device drivers to achieve a two-way communication between, also reached the underlying hardware device application control purposes. Communication between them, including two aspects Abstract: On the one hand is the application sent to the device driver data; hand is the device driver sends a message to the application. The former to achieve more easily through CreateFile () function to obtain a handle to the device driver, you can use the Win32 functions such as DeviceIoControl (), ReadFile () or WriteFile (), etc. to achieve application and device driver communication. Implementation of the latter than the former complex and the article describes the situation in this respect less. This does not mean that it is not important, on the contrary, it is in some applications play an important function. Device drivers complete the data collection work, the need to immediately notify the application so that the application can be promptly removed and the data is processed. In cases like these, and so forth.

In view of the device driver notifies the application of the importance, I combined some experience, it was summarized summarized five methods Abstract:

asynchronous procedure call (APC), event mode (VxD), messaging, asynchronous I / O modes and event mode (WDM). Below were the principles of this in several ways, and given of some of the source code.

An asynchronous procedure call (APC)

Win32 applications using CreateFile () function to dynamically load the device driver, and then define a callback function backFunc (), and the address of the callback function% 26amp; backFunc () as a parameter, through DeviceIoControl

() sent to the device driver. Device drivers to get the address of a callback function, it will save it in a global variable (eg callback), the simultaneous calls

Get_Cur_Thread_Handle () function to get its application thread handle, and the handle is stored in a global variable (eg appthread ) in. When conditions are ripe, the device driver calls _VWIN32_QueueUserApc () function to send messages to the Win32 application. This function takes three arguments Abstract: The first parameter is the address of the callback function (already registered); second parameter is passed to the callback message; third parameter to the caller's thread handle (already registered). Win32 application receives a message, the automatic callback function (actually called by the device driver). Callback

function of the input parameters are populated by the device driver, the callback function here is mainly to handle the message.

2 Event mode (VxD)

First, Win32 applications to create an event handler, called Ring3

handle. Because the virtual device driver using events Ring0 handle, so you need to create Ring0 handle. Using LoadLibrary () function to load the dynamic link library undisclosed Kernel32.dll, get dynamic link library handle. Then, call GetProcAddress (), find the function OpenVxDHandle () in the dynamic link

library location. Then, OpenVxDHandle () function will Ring3 event handlers into Ring0 event handler. Win32 applications using CreateFile () function to load the device driver. If the load is successful, call the DeviceIoControl () function will be

passed to the event handler Ring0 VxD; while waiting for the signal to create a worker thread becomes signaled state itself can shop and other things. When conditions are ripe, VxD set Ring0 event to signaled state (called

_VWIN32_SetWin32Event () function), which corresponds to Ring3 immediately trigger event to signaled state. Once Ring3 event handler for the signaled state, Win32 application's worker thread on this news be handled accordingly. 3 message mode

Win32 application calls CreateFile () function to dynamically load the virtual device driver. Loaded successfully, by calling DeviceIoControl () function handles the form sent to VxD, VxD use this handle to form a message. When the conditions are met, VxD calls SHELL_PostMessage () function to send messages to Win32 applications. To make use of this function successfully, you must use # define to customize a message, and even so it is defined in the application; also used in the message loop ON_MESSAGE () to define the

message processing function corresponding to the message so that the message is generated , can call the message handler. SHELL_PostMessage () function's first argument for Win32 window handle, the second parameter is the message ID number, and the third, four parameters are sent to the message processing

function parameters, fifth, six parameters for the callback function and pass to its parameters. Win32 application receives a message, the message is processed. 4 asynchronous I / O mode

Win32 application first calls the CreateFile () function to load the

device driver. Before calling this function, the penultimate two parameter is set to FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, saying that he can file overlapped I / O operations. When the device driver file is successfully created, create an initial state is no signal, you need to manually reset the event, and will pass this event type is OVERLAPPED data structure (eg Overlapped). Then, Overlapped as a parameter passed to DeviceIoControl () function. Device driver put the I / O request packet (IRP) is set to pending status, and set a cancel routine. If the current IRP queue is empty, then the IRP sent to StartIo () routine;

Otherwise, put it IRP queue. Device drivers after completing such work, ending the DeviceIoControl () processing, so do not wait for Win32 applications may IRP processed, from DeviceIoControl () call to return. By determining the return

value, get the IRP handling. If the current IRP is pending, then the main program do some other work, then call WaitForSingleObject () or WaitForMultipleObject () function waits for the event become Overlapped signal state. Device drivers at the appropriate time to handle the queued IRP, processing is complete, call

IoCompleteRequest () function. This function Overlapped the event is set to the signaled state. Win32 applications to respond to this incident immediately exit the wait state, and no signal will be reset to the state of the event, and then call GetOverlappedResult ()

Function to get the result of the IRP process.

5 Event mode (WDM)

Win32 application first creates an event, and then passed to the event handler device drivers, then create a secondary thread, waiting for an event signaled that he will go on other things. Device drivers access the event handle, can be used to convert it to an event pointer register and put it up for later use. When the conditions are met, the device driver will set the event to signaled state, so that the application of the worker thread immediately know the news, then make the appropriate treatment. When the device driver no longer uses this event, the event should be lifted pointer.

6 Conclusion

In the current popular Windows operating system, device drivers is the lowest level of manipulation of hardware software interface. It offers up a user interface and hardware-independent, down directly I / O, hardware interrupts, DMA and memory access and other operations. It applications and hardware details shields, so do not rely on the hardware and software available in portable between

different platforms. This article describes the five kinds of device driver notifies the application, in which the first three methods are mainly used in VxD, the latter two methods is mainly used for WDM. This 5 ways to have been the actual

test. Test results show that they are able to reach the device driver notifies the application purposes.

References Abstract:

[1 European Youth Li, XU Jian-bo, LI Fang-min, etc. virtual device driver VxD inquiry and development. Computer Engineering, 2003

[2 (America) Chris Cant. Windows WDM Device Driver Development Guide. Sun Yi, Ma Libo, the country Xuefei, M., Beijing Abstract: Mechanical Industry Press, 2000

[3 Li Heping DSP-based image reconstruction system to explore ICT, Beijing Abstract: Beijing University of Aeronautics and Astronautics Mechanical Engineering and Automation, 2002

汉语翻译内容:

设备驱动程序通知应用程序的几种方法

文件类别:计算机论文-------计算机应用论文

发表时间:2013-2-6 9:48:00

在目前流行的Windows 操作系统中,设备驱动程序是操纵硬件的最底层软件接口。为了共享在设备驱动程序设计过程中的经验,给出设备驱动程序通知应用程序的5种方法,具体说明每种方法的原理和实现过程,希望能够给设备驱动程序的设计者提供一些帮助。

为了保证操作系统的平安性和稳定性以及应用程序的可移植性,Windows 操作系统不答应应用程序直接访问系统的硬件资源,而是必须借助于相应的设备驱动程序。设备驱动程序可以直接操作硬件,假如应用程序和设备驱动程序之间实现了双向通信,也就达到了应用程序控制底层硬件设备的目的。它们之间的通信包括两个方面摘要:一方面是应用程序传送给设备驱动程序的数据;另一方面是设备驱动程序发送给应用程序的消息。前者的实现较轻易,通过CreateFile()函数获取设备驱动程序的句柄后,就可以使用Win32函数,如DeviceIoControl()、ReadFile()或WriteFile()等实现应用程序和设备驱动程序之间的通

信。后者的实现远比前者复杂,同时介绍这方面情况的文章较少。这不等于说它不重要,相反,它在有些应用场合发挥着重要的功能。设备驱动程序完成数据的采集工作后,需要马上通知应用程序,以便应用程序能够及时将数据取走并进行处理。诸如此类情况,不一而足。 鉴于设备驱动程序通知应用程序的重要性,本人结合一些经验,对它进行了总结,归纳出5种方法摘要:异步过程调用(APC)、事件方式(VxD )、消息方式、异步I/O方式和事件方式(WDM)。下面分别说明这几种方式的原理,并给出实现的部分源代码。

1 异步过程调用(APC)

Win32应用程序使用CreateFile()函数动态加载设备驱动程序,然后定义一个回调函数backFunc(),并且将回调函数的地址%26amp;backFunc()作为参数,通过DeviceIoControl()传送给设备驱动程序。设备驱动程序获得回调函数的地址后,将它保存在一个全局变量(如callback )中,同时调用Get_Cur_Thread_Handle()函数获取它的应用程序线程的句柄,并且将该句柄保存在一个全局变量(如appthread )中。当条件成熟时,设备驱动程序调用_VWIN32_QueueUserApc()函数,向Win32应用程序发送消息。这个函数带有三个参数摘要:第一个参数为回调函数的地址(已经注册);第二个参数为传递给回调函数的消息;第三个参数为调用者的线程句柄(已经注册)。Win32应用程序收到消息后,自动调用回调函数(实际是由设备驱动程序调用)。回调函数的输入参数是由设备驱动程序填入的,回调函数在这里主要是对消息进行处理。

2 事件方式(VxD )

首先,Win32应用程序创建一个事件的句柄,称其为Ring3句柄。由于虚拟设备驱动程序使用事件的Ring0句柄,因此,需要创建Ring0句柄。用LoadLibrary()函数加载未公开的动态链接库Kernel32.dll ,获得动态链接库的句柄。然后,调用GetProcAddress(), 找到函数OpenVxDHandle()在动态链接库中的位置。接着,用OpenVxDHandle()函数将Ring3事件句柄转化为Ring0事件句柄。Win32应用程序用CreateFile()函数加载设备驱动程序。假如加载成功,则调用DeviceIoControl()函数将Ring0事件句柄传给VxD ;同时,创建一个辅助线程等待信号变成有信号状态,本身则可去干其它的事情。当条件成熟时,VxD 置

Ring0事件为有信号状态(调用_VWIN32_SetWin32Event()函数),这马上触发对应的Ring3事件为有信号状态。一旦Ring3事件句柄为有信号状态,Win32应用程序的辅助线程就对这个消息进行相应的处理。

3 消息方式

Win32应用程序调用CreateFile()函数动态加载虚拟设备驱动程序。加载成功后,通过调用DeviceIoControl()函数将窗体句柄传送给VxD ,VxD 利用这个句柄向窗体发消息。当条件满足时,VxD 调用SHELL_PostMessage()函数向Win32应用程序发送消息。要让该函数使用成功,必须用#define来自定义一个消息,并且也要照样在应用程序中定义它;还要在消息循环中使用ON_MESSAGE()来定义消息对应的消息处理函数,以便消息产生时,能够调用消息处理函数。SHELL_PostMessage()函数的第一个参数为Win32窗体句柄,第二个参数为消息ID 号,第三、四个参数为发送给消息处理函数的参数,第五、六个参数为回调函数和传给它的参数。Win32应用程序收到消息后,对消息进行处理。

4 异步I/O方式

Win32应用程序首先调用CreateFile()函数加载设备驱动程序。在调用该函数时,将倒数第2个参数设置为FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED,表示以后可以对文件进行重叠I/O操作。当设备驱动程序文件创建成功后,创建一个初始态为无信号、需要手动复位的事件,并且将这个事件传给类型为OVERLAPPED 的数据结构(如Overlapped )。然后,将Overlapped 作为一个参数,传给DeviceIoControl()函数。设备驱动程序把这个I/O请求包(IRP )设置为挂起状态,并且设置一个取消例程。假如当前IRP 队列为空,则将这个IRP 传送给StartIo()例程;否则,将它放到IRP 队列中。设备驱动程序做完这些工作后,结束这个DeviceIoControl()的处理,于是Win32应用程序可能不等待IRP 处理完,就从DeviceIoControl()的调用中返回。通过判定返回值,得到IRP 的处理情况。假如当前IRP 处于挂起状态,则主程序先做一些其它的工作,然后调用WaitForSingleObject()或WaitForMultipleObject()函数等待Overlapped 中的事件成为有信号状态。设备驱动程序在适当的时候处理排队的IRP ,处理完成后,调用IoCompleteRequest()函数。该函数将

Overlapped 中的事件设置为有信号状态。Win32应用程序对这个事件马上进行响应,退出等待状态,并且将事件复位为无信号状态,然后调用GetOverlappedResult()

函数获取IRP 的处理结果。

5 事件方式(WDM )

Win32应用程序首先创建一个事件,然后将该事件句柄传给设备驱动程序,接着创建一个辅助线程,等待事件的有信号状态,自己则接着干其它事情。设备驱动程序获得该事件的句柄后,将它转换成能够使用的事件指针,并且把它寄存起来,以便后面使用。当条件具备后,设备驱动程序将事件设置为有信号状态,这样应用程序的辅助线程马上知道这个消息,于是进行相应的处理。当设备驱动程序不再使用这个事件时,应该解除该事件的指针。

6 结语

在目前流行的Windows 操作系统中,设备驱动程序是操纵硬件的最底层软件接口。它向上提供和硬件无关的用户接口,向下直接进行I/O、硬件中断、DMA 和内存访问等操作。它将应用程序和硬件细节屏蔽开来,使软件不依靠于硬件并且可在多个不同的平台之间移植。本文介绍了5种设备驱动程序通知应用程序的方法,其中前3种方法主要用于VxD 中,后2种方法主要用于WDM 。这5种方法都经过实际测试。测试结果表明,它们都能够达到设备驱动程序通知应用程序的目的。

参考文献

摘要:

[1欧青立,徐建波,李方敏,等. 虚拟设备驱动程序VxD 的探究和开发. 计算机工程,2003

[2(美)Chris Cant. Windows WDM设备驱动程序开发指南. 孙义, 马莉波, 国雪飞等译. 北京摘要: 机械工业出版社 2000

[3李和平. 基于DSP 的ICT 图像重建系统探究. 北京摘要: 北京航空航天大学机械工程及自动化学院, 2002


相关文章

  • 上海海洋大学
  • 上 海 海 洋 大 学 2012 年 硕 士 研 究 生 招 生 目 录 专业 代专业名称 码 001 水产与生命学院 071生物学(一级学000 科) 070海洋科学(一级700 学科) 077环境科学与工程600 (一级学科) 0901 ...查看


  • 北京师范大学2014年分省分专业录取
  • 科类文史理工 贫困专项(文史)贫困专项(理工) 投档线[1**********]8 投档人数 91348 录取人数 81248 机动计划使用数 0000 安徽统招分专业录取结果 专业 地理科学化学 计算机科学与技术数学与应用数学物理学历史学 ...查看


  • 考研复习必知常识
  • 一, 考研一共几科? 答:考研一般来说为4科.两门公共课,两门专业课.公共课是政治和外语,专业课分为专业课一和专业课二.对于工科或者经管类的考生,专业课一一般是数学.其他考生的专业课一是有所报考学校命题.总之,政治和外语(英语,日语等),还 ...查看


  • 工商管理学院考研科目
  • 中南财经政法大学 2011 年招收攻读硕士学位研究生专业目录 学院代码及名称 010 工商管理学 院 学科.专业代码. 专业名称.研究方向 020205 产业经济学 02. 工业经济 考试科目 ①101 思想政治理论 ②201 英语一.20 ...查看


  • 湖大教师简介
  • 湖南大学数学与计量经济学院硕士生指导教师简况表 序号 姓 名 "性 别" 出生年月 学位 职 称 "所在二级 学科名称" "主 要 研究方向" 个 人 简 介 1 李庆国 男 19 ...查看


  • 阅读与教研功力的修炼
  • ZHONGXUESHUXUEZAZHI 从以上教学过程中可以看出,课堂中信息的作用是渗透到教学的每一个细小环节的,教师给予学生不同的信息结构,会使学生产生不同性质的思维,这同思维与信息相关第三定理是吻合的.一堂高质量的数学课,不仅是知识的传 ...查看


  • 经管类考研经验交流
  • 研究生入学考试基本情况介绍(含考试科目.院校选择及经验交流) 1. 研究生考试一共分为几类? 三类,分别是学术型研究生即学硕.专业型研究生即专硕.在职研究生.应届生适合报考前两类,即学硕和专硕.二者都是主要针对应届生的全日制研究生,后者在职 ...查看


  • 河北省征集志愿计划_本科二批.对口本科
  • 重要提示: 本征集计划中所涉及的专业要求与<2010年河北省普通高等学校招生计划(文.理)>所列专业要求相同, 考生填报志愿时务请参阅<考试与招生>杂志增刊<2010年河北省普通高等学校招生计划>,并请关 ...查看


  • 2016中国石油大学考研内部信息
  • 2016 年中国石油大学考研内部信息一.中国石油大学研究生院简介中国石油大学(北京)是一所石油特色鲜明.以工为主.多学科协调发展 的教育部直属的全国重点大学,是设有研究生院的高校之一.1997 年,学校首 批进入国家"211 工程 ...查看


  • 招收电子商务研究生的学校
  • 招收电子商务研究生的学校 天津财经大学 (000) 不区分院系所 (120100) 管理科学与工程 (01) 管理信息系统 天津财经大学 (000) 不区分院系所 (120100) 管理科学与工程 (02) 电子商务 1 (101)统考政治 ...查看


热门内容