📄 vxd-e3.html
字号:
are the segment declarations. The declaration consists of three parts:
the name of the segment, the segment class and the desired runtime property
of the segment. You can see that there are many segments based on the same
class, for example, </font><b><font color="#FFFF99">_LPTEXT</font></b><font color="#FFFFFF">,
</font><b><font color="#FFFF99">_LTEXT</font></b><font color="#FFFFFF">,
</font><b><font color="#FFFF99">_LDATA</font></b><font color="#FFFFFF">
are all based on </font><b><font color="#FFFF99">LCODE</font></b><font color="#FFFFFF">
segment class with exactly the same properties. These segments are declared
to make coding easier to understand. For example, </font><b><font color="#FFFF99">LCODE</font></b><font color="#FFFFFF">
can contain both code and data. It'll be easier on the programmer if he
can store the data in </font><b><font color="#FFFF99">_LDATA</font></b><font color="#FFFFFF">
segment and the code in </font><b><font color="#FFFF99">_LTEXT</font></b><font color="#FFFFFF">
segment. Eventually, both segments will be combined into only one segment
in the final executable file.</font></font></font>
<br><font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">A
VxD exports one and only one symbol, its device descriptor block (DDB).
The DDB is actually a structure which contains everything VMM needs to
know about a VxD. You </font><b><font color="#FFFF99">MUST</font></b><font color="#FFFFFF">
export the DDB in the module definition file.</font></font></font>
<br><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Most
of the time, you can use the above .DEF file in new VxD projects. You would
have to change only the name of the VxD in the first and the last lines
of the .DEF file. The segment declarations are overkills for an asm VxD
project. They are for use by a C VxD project but using them in an asm project
is ok. You'll get a lot of warning messages but it will assemble. You can
get rid of the annoying warning messages by deleting the segment declarations
you don't use in your project.</font></font></font>
<br><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>vmm.inc
contains many macros for declaring segments in your source file.</font></font></font>
<br>
<center><table BORDER WIDTH="45%" >
<tr>
<td>_<b><font face="Arial,Helvetica"><font size=-1>LTEXT</font></font></b></td>
<td><b><font face="Arial,Helvetica"><font size=-1>VxD_LOCKED_CODE_SEG</font></font></b></td>
</tr>
<tr>
<td><b><font face="Arial,Helvetica"><font size=-1>_PTEXT</font></font></b></td>
<td><b><font face="Arial,Helvetica"><font size=-1>VxD_PAGEABLE_CODE_SEG</font></font></b></td>
</tr>
<tr>
<td><b><font face="Arial,Helvetica"><font size=-1>_DBOCODE</font></font></b></td>
<td><b><font face="Arial,Helvetica"><font size=-1>VxD_DEBUG_ONLY_CODE_SEG</font></font></b></td>
</tr>
<tr>
<td><b><font face="Arial,Helvetica"><font size=-1>_ITEXT</font></font></b></td>
<td><b><font face="Arial,Helvetica"><font size=-1>VxD_INIT_CODE_SEG</font></font></b></td>
</tr>
<tr>
<td><b><font face="Arial,Helvetica"><font size=-1>_LDATA</font></font></b></td>
<td><b><font face="Arial,Helvetica"><font size=-1>VxD_LOCKED_DATA_SEG</font></font></b></td>
</tr>
<tr>
<td><b><font face="Arial,Helvetica"><font size=-1>_IDATA</font></font></b></td>
<td><b><font face="Arial,Helvetica"><font size=-1>VxD_IDATA_SEG</font></font></b></td>
</tr>
<tr>
<td><b><font face="Arial,Helvetica"><font size=-1>_PDATA</font></font></b></td>
<td><b><font face="Arial,Helvetica"><font size=-1>VxD_PAGEABLE_DATA_SEG</font></font></b></td>
</tr>
<tr>
<td><b><font face="Arial,Helvetica"><font size=-1>_STEXT</font></font></b></td>
<td><b><font face="Arial,Helvetica"><font size=-1>VxD_STATIC_CODE_SEG</font></font></b></td>
</tr>
<tr>
<td><b><font face="Arial,Helvetica"><font size=-1>_SDATA</font></font></b></td>
<td><b><font face="Arial,Helvetica"><font size=-1>VxD_STATIC_DATA_SEG</font></font></b></td>
</tr>
<tr>
<td><b><font face="Arial,Helvetica"><font size=-1>_DBODATA</font></font></b></td>
<td><b><font face="Arial,Helvetica"><font size=-1>VxD_DEBUG_ONLY_DATA_SEG</font></font></b></td>
</tr>
<tr>
<td><b><font face="Arial,Helvetica"><font size=-1>_16ICODE</font></font></b></td>
<td><b><font face="Arial,Helvetica"><font size=-1>VxD_16BIT_INIT_SEG</font></font></b></td>
</tr>
<tr>
<td><b><font face="Arial,Helvetica"><font size=-1>_RCODE</font></font></b></td>
<td><b><font face="Arial,Helvetica"><font size=-1>VxD_REAL_INIT_SEG</font></font></b></td>
</tr>
</table></center>
<p><font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">Each
macro has its ending counterpart. For example, if you want to declare an
</font><b><font color="#FFFF99">_LTEXT</font></b><font color="#FFFFFF">
segment in your source file, you would do it like this:</font></font></font>
<blockquote><b><font face="Arial,Helvetica"><font color="#66FF99"><font size=-1>VxD_LOCKED_CODE_SEG</font></font></font></b>
<p><b><font face="Arial,Helvetica"><font size=-1><put your code here></font></font></b>
<p><b><font face="Arial,Helvetica"><font color="#66FF99"><font size=-1>VxD_LOCKED_CODE_ENDS</font></font></font></b></blockquote>
<h3>
<font face="Arial,Helvetica"><font color="#66FFFF"><font size=+0>VxD Skeleton</font></font></font></h3>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Now that
you know about segments in LE file, we can go on to the source file. One
thing you can observe about VxD programming is the heavy use of macros.
You will find macros everywhere in VxD programming. It takes some getting
used to. Those macros are provided to hide some gory details from programmers
and in some ways, make the source code more portable. If you are curious,
you can read the definition of those macros in various include files such
as vmm.inc.</font></font></font>
<br><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Here
is the VxD skeleton source code:</font></font></font>
<br>
<blockquote><b><font face="Arial,Helvetica"><font color="#66FF99"><font size=-1>.386p</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font color="#66FF99"><font size=-1>include
vmm.inc</font></font></font></b>
<p><b><font face="Arial,Helvetica"><font color="#66FF99"><font size=-1>DECLARE_VIRTUAL_DEVICE
FIRSTVXD,1,0, FIRSTVXD_Control, UNDEFINED_DEVICE_ID, UNDEFINED_INIT_ORDER</font></font></font></b>
<p><b><font face="Arial,Helvetica"><font color="#66FF99"><font size=-1>Begin_control_dispatch
FIRSTVXD</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font color="#66FF99"><font size=-1>End_control_dispatch
FIRSTVXD</font></font></font></b>
<p><b><font face="Arial,Helvetica"><font color="#66FF99"><font size=-1>end</font></font></font></b></blockquote>
<p><br><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>At
first glance, the source code doesn't look like an asm source code. That's
because of the use of macros. Let's analyze this source code and you'll
soon understand it.</font></font></font>
<blockquote><b><font face="Arial,Helvetica"><font color="#FFCC33"><font size=-1>.386p</font></font></font></b></blockquote>
<font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">Tell the
assembler that we want to use 80386 instruction set including the privileged
CPU instructions. You can also use </font><b><font color="#FFCC33">.486p</font></b><font color="#FFFFFF">
or </font><b><font color="#FFCC33">.586p</font></b><font color="#FFFFFF">.</font></font></font>
<blockquote><b><font face="Arial,Helvetica"><font color="#FFCC33"><font size=-1>include
vmm.inc</font></font></font></b></blockquote>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>You must
include vmm.inc in every VxD source code because it contains the definitions
of the macros you use in the source file. You can include other include
files as needed.</font></font></font>
<blockquote><b><font face="Arial,Helvetica"><font color="#FFCC33"><font size=-1>DECLARE_VIRTUAL_DEVICE
FIRSTVXD,1,0, FIRSTVXD_Control, UNDEFINED_DEVICE_ID, UNDEFINED_INIT_ORDER</font></font></font></b></blockquote>
<font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">As stated
previously, the VMM learns everything it needs to know about a VxD from
the VxD's </font><b><font color="#FFFF99">device descriptor block (DDB).
</font></b><font color="#FFFFFF">A
device descriptor block is a structure that contains vital information
about the VxD such as the VxD's name, its device ID, the entrypoints of
its VxD services (if exist) and so on. You can look up this structure in
vmm.inc. It's declared as </font><b><font color="#FFFF99">VxD_Desc_Block</font></b><font color="#FFFFFF">.
You'll export this structure in </font><b><font color="#FFFF99">.DEF</font></b><font color="#FFFFFF">
file. There are 22 members in this structure, but you'll usually need to
fill only some of them. So vmm.inc contains a macro that will initialize
and fill the structure members for you. That macro is D</font><b><font color="#FFFF99">ECLARE_VIRTUAL_DEVICE</font></b><font color="#FFFFFF">.
It has the following format:</font></font></font>
<p><b><font face="Arial,Helvetica"><font size=-1><font color="#66FF99">Declare_Virtual_Device </font><font color="#FFCC33">
Name, MajorVer, MinorVer, CtrlProc, DeviceID, InitOrder, V86Proc, PMProc,
RefData</font></font></font></b>
<p><font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">One
thing you can observe is that, the labels in VxD source code is case-insensitive.
You can use upper- or lowercase characters or combination of them. Let's
examine each parameter of </font><b><font color="#FFFF99">Declare_virtual_device</font></b><font color="#FFFFFF">.</font></font></font>
<ul>
<li>
<font face="Arial,Helvetica"><font size=-1><b><font color="#66FF99">Name</font></b><font color="#FFFFFF">
The name of the VxD. Maximum length is 8 characters. It </font><b><font color="#FFFF99">MUST</font></b><font color="#FFFFFF">
be uppercase. The name should be unique among the VxDs in the system. The
macro also uses the name to create the name of the </font><b><font color="#FFFF99">DDB</font></b><font color="#FFFFFF">
by appending </font><b><font color="#FFFF99">_DDB</font></b><font color="#FFFFFF">
to the device name. So if you use </font><b><font color="#FFFF99">FIRSTVXD</font></b><font color="#FFFFFF">
as the name of the VxD, </font><b><font color="#FFFF99">Declare_Virtual_Device</font></b><font color="#FFFFFF">
macro will declare the name of the DDB as </font><b><font color="#FFFF99">FIRSTVXD_DDB</font></b><font color="#FFFFFF">.
Remember that, you will also have to export the DDB in .DEF file too. You
have to match the label in the source file with the one in the .DEF file.</font></font></font></li>
<li>
<font face="Arial,Helvetica"><font size=-1><b><font color="#66FF99">MajorVer</font></b><font color="#FFFFFF">
and </font><b><font color="#66FF99">MinorVer</font></b><font color="#FFFFFF">
The major and minor versions of your VxD</font></font></font></li>
<li>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -