Express VXD with VC6.0 integrated environment

zhaozj2021-02-08  314

Author / Ma Fei Tao

VXD (Virtual Device Driver), the virtual device driver, is a driver running at the processor RING0 privilege level, which can perform any processor instructions to access any of the data registers in the machine. VXD is used as an interface between Windows 9x systems and physical devices that extend the core services of the Windows system, access and control the actual hardware environment.

With Win 2000 and new generation equipment driver WDM (Windows Driver Model) More than 90% of the market share. How can I master a method of saving a time-time efficient development VXD, it is a problem that programmers urgently need to solve.

Review the traditional way, write VXD with Microsoft's DDK, is a very cumbersome process:

1 Edit code actually does not have a graphical interface, or in the command line of the DOS, Edit does not support multi-window, view, and replacement code is inconvenient.

2 Compilation can only use VC5.0, not VC6.0. In WIN 98 DDK Help, the System Requirements section, Microsoft clearly reminds you: Note That Visual C 6.0 is not supported for any of the samples.

3 Pair of static VXD, each rewriting the code, you need to add a line in the system.ini file: DEVICE = VXD file name, each rewriting, you must restart your computer, every time you have a long time Waiting for the process, it is simply unbearable.

How to solve the above three problems, the author only to quickly develop VXD methods with the VC6.0 integrated environment, I hope to bring some help to you.

When developing a glowing messenger anti-yellow software, the author adopted VToolsD 3.0 to write a file to protect the VXD module.

Vtoolsd 3.0 is a package developed by Compuware, including several utilities:

1. QuickVXD: Create a VXD C and C Language Framework, which supports VC5.0 and VC6.0, but also supports Borland C 5.x. Similar to the VC's AppWizard, QuickVxd is equivalent to a code generator, and the AppWizard uses the MFC class library to generate a program framework, while QuickVxd uses custom series of macros and classes to generate a program framework.

2. Debug Monitor: Dynamically handled and displays the debug information of VXD, which can not only load dynamic VXD, but also load static VXD. After loading, debugging, whether it is dynamic or static VXD, you can uninstall it at any time. This is a powerful feature sufficient to make Microsoft's trek, successfully avoiding the trouble of writing static VXDs every time, it has a great convenience to the programmer.

3. VxDver.exe: DOS command line tool, you can set VXD version information. This gadget is also important because VXD version information cannot be set with VC6.0, and can only be manually set voxdver.

Here, details the specific steps of rapid development VXDs with a VC6.0 integrated environment:

First use QuickVxD to generate a VXD frame program, click: Start menu / Numega vtoolsd / quickvxd, open QuickVxd, select Device Parameters, set Device Name = my; select Output Files, then press the Generate Now button to generate a vxd frame source Program, which includes 3 files: Header file with .h; the suffix is ​​a .c or CPP code file; the suffix is ​​the project file of .mak. Then, we copied these three files: my.h, my.cpp, and my.mak to the E: / my / my / directory. The traditional method of generating VXD in the command line is as follows: Click: Start Menu / Development Kits / Windows 98 DDK / Checked (Free) Build Environment,

Set the compilation environment, in the command line of the DOS, find the My .mak file, set E: / my as the current directory, enter the instruction: nmake, you can generate a file that is .vxd.

Then we integrate the VXD's framework program and VC6.0 development environment:

1. Integrate VXD project files into the compiler of VC6.0:

Create a workspace file in VC6.0, open VC6.0, select File / New, select Project Tab, click Makefile, Enter My in Project Name, Enter E: / My in Loc, (Note: When New Makefile The name of Project Name is consistent with the local directory name of the location, and in this example, I will click OK. In OUTPUT, change the original My.exe to my.vxd, click Finish.

At this time, VC6.0 automatically generates project file my.dsp and workspace file my.dsw. Then, you can generate VXD with the compiler of VC6.0. The method is as follows: Click on the VC6.0 menu build / build my.vxd.

2. Integrate VXD's source files into the editor of VC6.0:

In the Workspace window of VC6.0, select the FileView page, right-click Source Files, in the shortcut menu, select Add Files to Folder, add the source file my.cpp; if the method is made, add the header file My.h.

At this time, we can observe the VXD class through the Workspace window of VC6.0, click on the Class View page, you can see 3 classes of My.VXD: MyDevice, Mythread, MyVM. At this point, when we edit the VXD code, no need to use the command line Edit.com.

To work in the editor, we also need to set the browsing information to view the class definition and reference with F12. Methods as below:

1) Select the menu of VC6.0: Project / Settings ...

2) Set build command line: nmake / f "my.mak" browse = 1;

3) Set Browse Info File Name: my;

4) Click OK, then select VC6.0 menu File / Open to open my.bsc;

At this time, use the right click to click on the source code window of VC6.0, and 2 options for GOTO Definition of and Goto Reference in will appear in the shortcut menu. Then we can edit the source code of VXD with very familiar interfaces in VC6.0. Is it very convenient? 3. Add Debug Monitor to the Tools menu of VC6.0:

When debugging VXD source code, DPRINTF () or DOUT << is often used to output debugging information, and Debug Monitor can dynamically handle and display the debug information of VXD, we can integrate this debugging tool in VC6.0. Click on the VC6.0 menu Tools / Customize ..., select the Tools item, enter the name of the new menu vxd Monitor or any other name, set the command: c: / program files / numega / vtoolsd / bin / monitor.exe, you can DEBUG MONITOR Add to the Tools menu of VC6.0.

When we debug VXD, you can click on the new VXD Monitor menu just now to run the Debug Monitor. Select Debug Monitor's menu file / open driver ... to load the VXD you want to debug; select Menu File / Start Drive to run VXD, after running, you can see debug information. This feature is equivalent to the trace () of VC6.0. When debugging, when you exit the Debug Monitor, you must pay attention to the menu file / stop driver, stop running VXD, otherwise, when you enter Debug Monitor, you must cause the system to crash.

4. Set the version information of VXD.

When the software is upgraded, the version information of the file plays a vital role. With VC6.0, VXD version information cannot be set, and can only be manually set voxdver. (I hope that a very famous software author in China will also put our own sthvxd.vxd from the version information after reading this method.)

Initially, the author tried to add version information via VC6.0, but whether it is modified the header file of VXD, or sets VC6.0's Resource Files, and it is invalid. After reading the help file of VToolsd, the introduction to the Usage of VXD Ver is also ambiguous, and it does not give an example of explanation, and the initiator of VXD.

The author has found data online and constantly explores, and finally finds the way to set up VXD:

If the VXD to be generated is My.vxd, use Edit to create a named my.vrc, to protect the gauge messenger file to prevent the module Antidel.vxd as an example, My.vrc's content is as follows:

CompanyName = "http://iflower.363.net"

FileDescription = "Antidel file"

Fileversion = "Version 1.01"

INTERNALNAME = "Antidel"

Legalcopyright = "mafeitao@371.net"

OriginalFileName = "Antidel.vxd"

ProductName = "Antidel"

ProductVersion = "Version 1.01"

Translation = 0x409, 0x4e4

The deployment is exit, executes: vxdver.exe my.vcr my.res, then, then re-compiling the version information of MY.VXD, VXD version information is set successfully with VC6.0. In the past, I have always feel that writing VXD is a hard work. In fact, it is not difficult to master the method. I hope this article can write VXD to everyone. Interested friends can come to my page: http://iflower.363.net, welcome everyone to discuss: Mafeitao@sina.com

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

New Post(0)