⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vxd-e3.html

📁 介绍vxd驱动编写的入门和实际代码,让你对硬件驱动和window下的汇编有个初步认识
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<font face="Arial,Helvetica"><font size=-1><b><font color="#66FF99">CtrlProc</font></b><font color="#FFFFFF">
The name of the </font><b><font color="#FFFF99">device control procedure</font></b><font color="#FFFFFF">
for your VxD. A device control procedure is a function that receives and
processes control messages for a VxD. You can think of a device control
procedure as the window procedure equivalence. Since we will use </font><b><font color="#FFFF99">Begin_Control_Dispatch</font></b><font color="#FFFFFF">
macro to create our device control procedure, we should use the standard
name which is in the form of </font><b><font color="#99FF99">VxDName</font><font color="#FFFF99">_Control</font></b><font color="#FFFFFF">.
</font><b><font color="#FFFF99">Begin_Control_Dispatch</font></b><font color="#FFFFFF">
macro appends </font><b><font color="#FFFF99">_Control</font></b><font color="#FFFFFF">
to the name passed to it ( and we usually pass the name of the VxD to it)
so we should specify the name of our VxD appended by </font><b><font color="#FFFF99">_Control</font></b><font color="#FFFFFF">
in </font><b><font color="#66FF99">CtrlProc</font></b><font color="#FFFFFF">
parameter.</font></font></font></li>

<li>
<font face="Arial,Helvetica"><font size=-1><b><font color="#66FF99">DeviceID</font></b><font color="#FFFFFF">
The 16-bit unique identifier of your VxD. You need the ID if and only if
your VxD must handle one of the situations below</font></font></font></li>

<ul>
<li>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Your VxD
exports VxD services for other VxDs to use. Since int 20h interface uses
the device ID to locate/identify the VxD, it's imperative that your VxD
must have a unique identifier.</font></font></font></li>

<li>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Your VxD
broadcasts your existence to real-mode applications during initialization
with int 2Fh function 1607h.</font></font></font></li>

<li>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Some real-mode
software (TSR) will use int 2Fh, function 1605h to load your VxD.</font></font></font></li>
</ul>
<font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">If your
VxD doesn't need a unique device ID, you can specify </font><b><font color="#FFFF99">UNDEFINED_DEVICE_ID
</font></b><font color="#FFFFFF">in
this field. If you do need a unique ID, you have to ask Microsoft for one</font></font></font>
<li>
<font face="Arial,Helvetica"><font size=-1><b><font color="#66FF99">InitOrder</font></b><font color="#FFFFFF">
Initialization order, or in short, load order. VMM loads VxDs in the order
specified. Each VxD will have a load order number. For example,</font></font></font></li>
</ul>

<ul>
<ul><b><tt><font color="#FFFFFF"><font size=-1>VMM_INIT_ORDER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
EQU 000000000H</font></font></tt></b>
<br><b><tt><font color="#FFFFFF"><font size=-1>DEBUG_INIT_ORDER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
EQU 000000000H</font></font></tt></b>
<br><b><tt><font color="#FFFFFF"><font size=-1>DEBUGCMD_INIT_ORDER&nbsp;&nbsp;
EQU 000000000H</font></font></tt></b>
<br><b><tt><font color="#FFFFFF"><font size=-1>PERF_INIT_ORDER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
EQU 000900000H</font></font></tt></b>
<br><b><tt><font color="#FFFFFF"><font size=-1>APM_INIT_ORDER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
EQU 001000000H</font></font></tt></b></ul>

<p><br><font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">You
can see that </font><b><font color="#FFFF99">VMM</font></b><font color="#FFFFFF">,
</font><b><font color="#FFFF99">DEBUG</font></b><font color="#FFFFFF">
and </font><b><font color="#FFFF99">DEBUGCMD</font></b><font color="#FFFFFF">
are the first VxDs that are loaded, followed by </font><b><font color="#FFFF99">PERF</font></b><font color="#FFFFFF">
and </font><b><font color="#FFFF99">APM</font></b><font color="#FFFFFF">.
The VxD with lower value of initialization order is loaded first. If your
VxD requires the services of other VxD during initialization, you should
specify an initialization order value that is larger than that of the VxD
you want to call so that by the time your VxD is loaded, that VxD is already
there in memory, ready for you. If your VxD doesn't care about initialization
order, specify </font><b><font color="#FFFF99">UNDEFINED_INIT_ORDER </font></b><font color="#FFFFFF">in
this parameter.</font></font></font>
<li>
<font face="Arial,Helvetica"><font size=-1><b><font color="#FFFF99">V86Proc</font></b><font color="#FFFFFF">
and </font><b><font color="#FFFF99">PMProc</font></b><font color="#FFFFFF">
Your VxD can export API for use by V86 and protected-mode programs. V86Proc
and PMProc specify the addresses of those API. Remember that, VxDs exist
primarily for supervising VMs and a VM other than the system VM runs a
DOS or protected-mode application. It stands to reason for VxDs to provide
API support for DOS and protected-mode programs. If you don't export those
API, you can omit these fields.</font></font></font></li>

<li>
<font face="Arial,Helvetica"><font size=-1><b><font color="#66FF99">RefData</font></b><font color="#FFFFFF">
Reference data used by </font><b><font color="#FFFF99">Input Output Supervisor
(IOS)</font></b><font color="#FFFFFF">. The only occasion you would use
this field is when you code a layer block driver for use with IOS. You
can omit this field if your VxD is not a layer driver.</font></font></font></li>
</ul>
<font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">Next we
have </font><b><font color="#FFFF99">Begin_Control_Dispatch</font></b><font color="#FFFFFF">
macro.</font></font></font>
<blockquote><b><font face="Arial,Helvetica"><font size=-1><font color="#FFCC33">Begin_control_dispatch</font><font color="#66FF99">
FIRSTVXD</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font size=-1><font color="#FFCC33">End_control_dispatch
</font><font color="#66FF99">FIRSTVXD</font></font></font></b></blockquote>
<font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">This macro
and its counterpart define the device control procedure which is the function
that VMM calls when there are control messages for your VxD. You must specify
the first half of the name of the device control procedure, in our example
we use </font><b><font color="#66FF99">FIRSTVXD</font></b><font color="#FFFFFF">.
The macro will append </font><b><font color="#FFFF99">_Control</font></b><font color="#FFFFFF">
to the name you supplied.This name must match the one you specify in </font><b><font color="#66FF99">CtrlProc</font></b><font color="#FFFFFF">
parameter of </font><b><font color="#FFFF99">Declare_virtual_device</font></b><font color="#FFFFFF">
macro. The device control procedure is always in a locked segment (</font><b><font color="#FFFF99">VxD_LOCKED_CODE_SEG</font></b><font color="#FFFFFF">).
The above device control procedure does nothing. You have to specify what
control messages your VxD is interested in handling and the functions that
will handle them. You use </font><b><font color="#FFFF99">Control_Dispatch</font></b><font color="#FFFFFF">
macro for this purpose.</font></font></font>
<blockquote><font face="Arial,Helvetica"><font size=-1><b><font color="#FFFF99">Control_Dispatch
</font></b><i><font color="#66FFFF">message, function</font></i></font></font></blockquote>
<font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">For example,
if your VxD processes only </font><b><font color="#FFFF99">Device_Init
</font></b><font color="#FFFFFF">message, your device control procedure
would look like this:</font></font></font>
<blockquote><b><font face="Arial,Helvetica"><font size=-1><font color="#FFCC33">Begin_Control_Dispatch</font><font color="#FFFFFF">&nbsp;</font><font color="#66FF99">
FIRSTVXD</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">&nbsp;
</font><font color="#FFCC33">Control_Dispatch</font><font color="#FFFFFF">&nbsp;
Device_Init, OnDeviceInit</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font size=-1><font color="#FFCC33">End_Control_Dispatch</font><font color="#66FF99">FIRSTVXD</font></font></font></b></blockquote>
<font face="Arial,Helvetica"><font size=-1><b><font color="#FFFF99">OnDeviceInit</font></b><font color="#FFFFFF">
is the name of the function that will handle </font><b><font color="#FFFF99">Device_Init</font></b><font color="#FFFFFF">
message. You can name your function anything you like.</font></font></font>
<br><font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">You
end the VxD source code with </font><b><font color="#FFFF99">end</font></b><font color="#FFFFFF">
directive.</font></font></font>
<br><font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">To
recapitulate, at a minimum, a VxD must have a device control block and
a device control procedure. You declare a device control block with </font><b><font color="#FFFF99">Declare_Virtual_Device</font></b><font color="#FFFFFF">
macro and a device control procedure with </font><b><font color="#FFFF99">Begin_Control_Dispatch</font></b><font color="#FFFFFF">
macro. You must export the device control block by specifying its name
under </font><b><font color="#FFFF99">EXPORTS</font></b><font color="#FFFFFF">
directive in .DEF file.</font></font></font>
<h3>
<font face="Arial,Helvetica"><font color="#66FFFF"><font size=+0>Assembling
the VxD</font></font></font></h3>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>The assembling
process is the same as the one used in assembling normal win32 applications.
You invoke ml.exe on the asm source code and then link the object file
with link.exe. The differences are in the command line switches used by
ml.exe and link.exe</font></font></font>
<p><font face="Arial,Helvetica"><font size=-1><b><font color="#66FFFF">&nbsp;ml</font></b><font color="#FFFFFF">
-</font><b><font color="#FFFF99">coff -c -Cx -DMASM6 -DBLD_COFF -DIS_32&nbsp;
</font><font color="#66FF99">firstvxd.asm</font></b></font></font>
<p><font face="Arial,Helvetica"><font size=-1><b><font color="#FFFF99">-coff&nbsp;</font></b><font color="#FFFFFF">
Specify the COFF object format</font></font></font>
<br><font face="Arial,Helvetica"><font size=-1><b><font color="#FFFF99">-c&nbsp;</font></b><font color="#FFFFFF">&nbsp;
Assemble only. Do not call the linker to link the object file, since we
will call link.exe later with more parameters.</font></font></font>
<br><font face="Arial,Helvetica"><font size=-1><b><font color="#FFFF99">-Cx</font></b><font color="#FFFFFF">&nbsp;
Preserve the case of public, extern labels.</font></font></font>
<br><font face="Arial,Helvetica"><font size=-1><b><font color="#FFFF99">-D&lt;text></font></b><font color="#FFFFFF">
defines a text macro. For example, -DBLD_COFF defines a text macro BLD_COFF
which will be used in conditional assembly. If you're interested, you can
search for BLD_COFF in the include files and see for yourself what effect
it has on the assembly process. So in the command line switches above,
three text macros are defined: BLD_COFF, IS_32, and MASM6. If you're familiar
with C, this process is identical to:</font></font></font>
<blockquote><b><font face="Arial,Helvetica"><font color="#66FF99"><font size=-1>#define
BLD_COFF</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font color="#66FF99"><font size=-1>#define
IS_32</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font color="#66FF99"><font size=-1>#define
MASM6</font></font></font></b></blockquote>
<b><font face="Arial,Helvetica"><font size=-1><font color="#66FFFF">link
</font><font color="#FFFF99">-vxd
-def:firstvxd.def&nbsp; </font><font color="#66FF99">firstvxd.obj</font></font></font></b>
<p><font face="Arial,Helvetica"><font size=-1><b><font color="#FFFF99">-vxd
</font></b><font color="#FFFFFF">specifies
that we want to build a VxD from the object file</font></font></font>
<br><font face="Arial,Helvetica"><font size=-1><b><font color="#FFFF99">-def:&lt;.DEF
file></font></b><font color="#FFFFFF"> specifies the name of the module
definition file of the VxD</font></font></font>
<p><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>I find
it more convenient to use makefile but you can create a batch file to automate
the assembling process if you don't like makefile approach. Here's my makefile.</font></font></font>
<p><b><font face="Arial,Helvetica"><font color="#FFCC33"><font size=-1>NAME=firstvxd</font></font></font></b>
<p><b><font face="Arial,Helvetica"><font color="#FFCC33"><font size=-1>$(NAME).vxd:$(NAME).obj</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font color="#FFCC33"><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
link -vxd -def:$(NAME).def $(NAME).obj</font></font></font></b>
<p><b><font face="Arial,Helvetica"><font color="#FFCC33"><font size=-1>$(NAME).obj:$(NAME).asm</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font color="#FFCC33"><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ml -coff -c -Cx&nbsp; -DMASM6 -DBLD_COFF -DIS_32 $(NAME).asm</font></font></font></b>
<br>
<hr WIDTH="100%">
<center><b>[<a href="http://win32asm.cjb.net">Iczelion's Win32 Assembly
Homepage</a>]</b></center>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -