Using Windows virtual device driver (VxD) 2

Source: Internet
Author: User

Eight, VxD initialization

When VMM Initializes a VxD, do the following:

1, load Real mode initialization section and invoke the real mode initialization process. This process can be done to prevent the Mount VxD from starting Windows, specifying device instance data and selecting pages in memory to

Equipment-specific work.

2, load the other segment of VxD to 32-bit flat memory mode of protected mode memory, and discard the real mode initialization segment.

3, send Sys_critical_init message to the device control process. Disables hardware interrupts, so a VxD should do its own initialization in less time as possible.

4, send Device_init message to the device control process. Allow the hardware to break, so you must be prepared to let VxD manage interrupts from the device.

5, send Init_complete message to the device control process.

6, discard initialization code and data segment, release other used memory. A VxD cannot attempt to access procedures and data in these segments after processing the init_complete message.

At any point in the initialization process, a VxD can set a carry flag to return to VMM to prevent loading a VxD. Some VMM services, such as initialization information services, are valid only during initialization.

Nine, Real mode initialization

Any static device driver can provide a real-mode initialization process to perform an initialization task before Windows switches to protected mode. This procedure is called when the VMM loads a VxD, which checks

About the Windows environment, including the settings in the registry and initialization files to determine if the VxD should be loaded. The process can also return information to Windows to assume that each virtual machine's actual

example specifies that the physical memory page is reserved for device-specific and data item addresses. For more information on real mode initialization, refer to the relevant information.

Ten, VxD service

A VxD can provide a service function (a function or a procedure-a translator's note) for VMM and other VxD. These services allow other VxD to directly access the characteristics of the VxD, allowing you to test and modify the features and capabilities of the VxD.

A VxD cannot draw a function like a Windows DLL, in which the VMM provides a dynamic link to the VXD service through INT 20H, which uses the service number to determine the support service's

VXD, the interrupt processing process also uses the service number to query the service address in the VxD service table.

The following section describes how to define a service in a VxD, declare a VxD service table, and introduce a service from one VxD to another.

1. Define Service

VXD uses BEGINPROC and ENDPROC macros, as well as service and Async_service options, to define services. Macros mark the start and end of the service procedure Code, which identifies the process as a service.

The following example gives the definition of the Vsampled_get_version service:

Beginproc Vsampled_get_version, Service

mov ax, 030Ah

Clc

Ret

Endproc vsampled_get_version

The Async_service option identifies that the service can be invoked asynchronously, meaning that it is invoked during processing of interrupts. The asynchronous service must be reentrant and cannot invoke VMM and not an asynchronous suit

Service of the VxD.

VMM and standard VXD use two calling conventions for services: the invocation convention based on registers and the calling convention based on the 32-bit C language. The two calling conventions have different service name formats and parameter passes

and return value methods and register protection.

For a service based on registers, the service name should not begin with an underscore (_), all parameters are passed through registers, and the result is returned through registers, and service protection is not explicitly used to return

Value of the register.

For services based on the C language, the service name must begin with an underscore (_), all parameters passed through the 32-bit value in the stack, and the result (if present) through the EAX register (32-bit value)

or EAX and edx registers (64-bit value) returns, service protection EBX, ES, FS and GS registers, and ESI and EDI registers, only flag registers and eax, EBX, edx registers are modified.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.