Details all interfaces of C ++ language VXD and external communication

zhaozj2021-02-08  303

Detailed C language of all interfaces to communicate with the outside of VxD: Ma Wenxiao a VxD ---- from what is a multitasking operating system since Windows 3.1, any computer in a physical device which can be x-based or Windows-Dos? Multiple processes are used, this one-to-many relationship is called "device virtualization", each process is accessed by the VXD (Virtual X Device Driver) running on the core layer, the operating system is provided to the user's software service You can also be implemented with VXD. Other resources in the computer, such as CPU, memory, etc., can also be used simultaneously by multiple processes, and each process enters such resources in a virtual machine (VM) environment provided by the system. ---- VXD The core layer can be loaded by the virtual machine manager (VMM) (called static loading, " Plus a row "device = this VXD file name"), or by the application real-time load (called dynamic loading), then, each process can access the VXD data area in memory to control the behavior of VXD in real time. The internal structure of VXD prevents two processes from simultaneously accessing its data area. VXD is interacting with the outside world by responding to VMM. --- Windows 95, DOS-based each process runs in separate VMs ( It is said to run in V86 mode), which can be run in the DOS single process, run in low internal memory (called in real mode), and the advantages of multi-process environment can be used throughout memory (called in protection mode) Under running to access a memory high-end Windows graphics environment with a DPMI interface of 95. The other 16-bit or 32-bit applications run in the same system VM. ---- The following only discusses VXD in the 95 environment......................................................................................................................................................................................................................................... VXD creation: ---- 1. Create vxd by assembly language: You need to install Microsoft's Win32 SDK and DDK. ---- 2. Create vxd from C or C language: You need to install VC2.0 or BC4.0, And Vireo Software's VToolsd Package .vtoolsd contains 3 utilities: you can create a VXD frame for QuickVxd; VxD loader that can be dynamically unloaded; VxD Viewer with memory Vxd feature; ---- QuickVXD contains 7 dialogue : ---- (1) Device Parameters page includes: up to 8 characters VXD name, unique identification number (ID), relative to other VXDs (Vxd Viewer can display a VXD load order value init order) If the order in which the new VXD is specified is less than this init order, the new VXD will be in this V. Before XD is loaded), realize language (C or C ), static, dynamic load mode, etc. ---- (2) VXD Services page includes: interface accessible by other VXDs (called VXD service), require The ID> 0 of this VXD does not conflict with the ID value of the memory VXD. This ID can be applied to Microsoft, or Vireo's Vireo_Test_ID (3180H) is known as the interface ID. ------ (3) The API page includes: the application can be accessed in the real mode / V86 mode, in the protection mode, the DPMI's real mode / V86 mode, the interface (collective application interface) accessed in the DPMI protection mode, the first two requirements This VXD provides an interface ID, and the last two only require this VXD to provide a unique identity string ending at 0; before access, first static or dynamically loaded this VXD (4th requires static loading). 1,3 Access by ordinary assembler, the 2,4 can be accessed by Windows program generated on the BC's Windows 3.x (16) platform. ---- (4) Control Messages page includes: pair in Windows 3.1 and Windows The response of each message in 95, if the Dynamic_init message when static is loaded. ---- (5) Windows95 Control Messages page includes: a response to each message that appears in Windows 95, such as the SYS_DYNAMIC_INIT message when dynamic loading. ---- (6) Use C

When implementing VXD, the classs page includes: from the virtual device driver class VDEvice class name (such as MyDevice), this class member function will receive most of the messages appeared in the (4) and (5). ---- From the VM instance class VVIRTUALMACHINE, the class name (such as myvm), the member function of this class will receive each message throughout the VM Life, such as the system VM initial message SYS_VM_INIT; ---- From thread instance class Vthread derived class Name (such as Mythread). This type of member function will receive each message throughout the thread life, such as the new thread initial message thread_init; ---- (7) Output Files page includes: 3 VXD files that reflect the above (.h, .c or .cpp, .mak) will be stored in the directory location. ---- 3. C language VXD and external communication all interface: We will briefly implement the application interface and service of My.VXD, They are all active members of the class, stored in my.h, my.cpp. ---- (1) Interface accessible by 32-bit C application: ---- Application first opens VXD with CREATEFILE, DeviceioControl gives VMM send W32_Deviceiocontrol messages to VXD: ---- Handle H; Char IBUF [2], OBUF [2]; BOOL R; DWORD OC; OVERLAPPED O; ---- h = CreateFile (". // MY. VXD ", 0, 0, 0, 0, file_flag_delete_on_close, 0); // Open Static My.VXD, or dynamically load my.vxd ---- r = deviceioControl (h, command code C, IBUF, SIZEOF (IBUF ), OBUF, SIZEOF (OBUF), & OC, NULL or & O); / * Exchange data with my.vxd's event onw32deviceioControl, use IBUF to VXD data, with OBUF from VXD data, VXD back it back Put in OC * / ---- CloseHandle (h); // Close or dynamically remove VXD ---- my.vxd should choose W32_DeviceioControl event on Windows 95 Control Messages page, in DWord MyDevice :: OnW32Deviceiocontrol p) Write in the event: Switch (P-> DIOC_IOCTLCOD e) {case command code C: Use P to point to the IOCTLPAR AMS structure, exchange data with the application; if (success) return (0); / * Make the return value of Deviceiocontrol R is true * / else return (1); Default : Return (0);} ---- The above approach requires VXD to exchange data (synchronous communication), value file_flag_delete_on_close indicates that CloseHandle will not reserve the reference number 0 in memory. ---- VXD can also be delayed At this time, the application first pass value file_flag_delete_on_close | file_flag_overlapped --- to createfile, create an event with o.hevent = createEvent (0, true, 0, null), then the address to DeviceIocontrol, then use GetoverlappedResult (h , Sleep on o. ---- At this point, p-> lpoOverlapped must be larger than 0, VXD can use VMM service _LinPageLock, press the page lock P-> Dioc_inbuf to point to the application IBUF area, P -> Dioc_outbuf pointing to the OBUF zone, P-> LPOOVERLAPPED pointing to the O structure. When you exchange data, you can use the total data and data to P-> Dioc_outbuf and P-> LPOOVERLAPPED-> O_InternalHigh, then call VMM services --- - vwin32_dioccompletionRoutine (p-> lpooverlapped->

O_internal) Wake the application. - VMM Dynamically hand unloading VXD, send W32_DEVICEIOCONTROL messages to vxd by command code 0 and -1, so Vireo recommends that the command code C is taking [2048, 4095]. ---- (2) Interfaces accessed by the 16-bit application in REAL / V86 mode: ---- my.vxd first specify interface ID (such as 3180h), then select the REAL / V86 MODE tab in the Standard Application Entry Points box on the API page, You can generate a MyDevice :: V86_API_Entry entry, accessing its assembler is: Entry DD? MOV AX, 1684H; function number MOV BX, 3180H; interface ID INT 2FH; ENT / Dunction to ES / DI, time , DI and ES return non-zero-value MOV AX, ES OR AX, DI JZ L0 MOV WORD PTR [Entry], DI MoV Word PTR [Entry 2], ES MOV AH, Code C Call [Entry] ---- L0 : Error handling myDevice :: v86_api_entry (vmhandle hvm, client_struct * p) The entrance can be: if (p-> cbrs.client_ah == code c) P-> cbrs.client_al = 0; ---- (3) protected The 16-bit application access interface: ---- and (2) are similar, but select the protected mode tag, you can generate a MyDevice :: PM_API_Entry entry, access it, is: int Pascal WinMain (Handle H1, Handle H0 , Ilpstr lpcmdline, int ncmdshow) {FARPROC ENTRY; / / 32 bits _ASM {MOV AX, 1684H MOV BX, 3180H INT 2FH; selectors / offset to ES / DI, DI and ES return non-non- Zero Value MOV AX, ES OR AX, DI JZ L0 MOV WORD PTR [ENTRY], DI MOV WORD PTR [ENTRY 2], ES MOV AH, Code c call [Entry]} ---- Processing for PM_API_ENTRY ( 3.2). ---- (4) Access to 16-bit applications under the real mode / V86 mode of DPMI Interface: ---- A similar to (2), but select the REAL / V86 MODE tab in the Vendor Specific Application Entry Point on the API page, and then enter the unique identity string my_v86vendore :: in the Vendor ID String. Handler entry, access to its program is: STR DB 'my', 0; VXD unique identity string ENTRY DD? MOV AX, 168AH; function number LEA SI, STR; requires DS / Si value to be STR segment value / offset Value INT 2FH; Access port segment / offset to ES / DI, when successful, Al returns 0 CMP Al, 0 JNE L0 MOV WORD PTR [Entry], Di Mov Word PTR [Entry 2], ES ... CALL [Entry] ---- Treatment of Handler, such as (3.2). ---- (5) Interfaces accessed by 16-bit applications under the protection mode of DPMI: Similar to (4), but select Protected Mode tag, ie You can generate a MY_PROTVENDORENTRY :: Handler entry, accessing its programs: int Pascal Winmain (Handle H1, Handle H0, LPSTR LPCMDLINE, INT NCMDSHOW) {char * id = "my"; farproc entry; _ASM {MOV AX, 168AH MOV Si , ID INT 2FH;

转载请注明原文地址:https://www.9cbs.com/read-1522.html

New Post(0)