📄 generic.htm
字号:
<html>
<head>
<title>The GENERIC Sample</title>
</head>
<body>
<h2>The GENERIC Sample</h2>
<p>The GENERIC Sample is a kernel-mode library used by most of the book sample
drivers.</p>
<p>The sample includes one component:</p>
<ul type=disc>
<li>GENERIC.SYS is a WDM library.
</ul>
<p>You may find differences in the electronic copy of GENERIC and the code
described in the book. Those differences have arisen because I continued (and
still continue) to improve GENERIC after the book was frozen by the editorial
process.</p>
<p>[Note: the WIN98SAFE conditional compilation switch was added in SP-10 to
overcome a bug in the initial release of Windows 98. In that version, the
system would incorrectly interpret the return value from a DllInitialize
function, leading to a failure to load a driver. If you #define WIN98SAFE in
driver.h and remove the export definitions of DllInitialize and DllUnload from
generic.def, you can build a version of GENERIC.SYS that will work correctly in
Win98. Your version will not, however, unload in Win2K/Xp.]</p>
<h3>Building GENERIC</h3>
<p>To build GENERIC.SYS, follow the <a href="..\wdmbook.htm#wdmbuild">general
instructions for building a WDM sample</a>. The Microsoft Visual C++ project
file is named GENERIC.DSP.</p>
<h3>Testing GENERIC</h3>
<p>It抯 not necessary for you to specifically install GENERIC.SYS. In fact, the
setup program for the book samples automatically does this for you because most
of the other samples depend on it being present. If you rebuild the DEBUG
version of GENERIC, the build script will copy your new GENERIC.SYS module to
the Drivers directory. It will be used the next time you restart your system.</p>
<p>If you're using a separate machine for testing than where you installed the
sample programs, be sure to copy the original and any rebuilt version of
GENERIC.SYS from the OBJCHK_WXP_X86\I386 directory to the drivers directory by hand.</p>
<h3>Documentation</h3>
<p>Extensive documentation of GENERIC is available in the hypertext help file
<a href="html\generic.chm">GENERIC.CHM</a>.
<h3>Redistributing GENERIC</h3>
<p>You may not redistribute the GENERIC.SYS library. You may, however, build a
library from this project under a different name and redistribute that. Here抯
how to accomplish this:</p>
<ol>
<li>Pick a new name that's customized to the name of your company
so that it will be unlikely to conflict with a driver already installed on the
end user's computer. For purposes of illustration, I'll proceed as if you had
settled on FRED.SYS.
<li>Copy the entire GENERIC directory (not including any
subdirectories) to a new directory named FRED.
<li>Rename GENERIC.DSP to FRED.DSP. Delete the files with
extensions DSW, MAK, NCB, OPT, and PLG.
<li>Start Visual Studio. Open FRED.DSP *as a text file* and
globally replace "generic.sys" with "fred.sys". Save this
file.
<li>Open FRED.DSP as a Visual Studio project. <i>Don抰 forget that
you will be using the DDK compiler for building this project; follow the
link in "Building GENERIC" above if you抮e doubtful about what this remark
means.</i> It's a good idea to set the option that generates a browse database.
<li>Change the first line of GENERIC.DEF to read "NAME FRED.SYS".
<li>Do a Build All for the checked and release builds. At this point, you will
have objchk_wxp_x86\i386 and objfre_wxp_x86\i386 subdirectories that contain fred.sys and
fred.lib along with other intermediate files.
<li>Use fred.lib instead of generic.lib in your build script.
Distribute fred.sys instead of generic.sys. Your driver's demand for functions
in the GENERIC library are being satisifed by exports of those functions from
FRED.SYS.
</ol>
<p>Please do not distribute the checked version of your new
library: you will be embarrassed when your knowledgeable end users call up and
complain about the debug spew!</p>
<h3>What to look for</h3>
<p>GENERIC is a library for production use and not primarily a sample.</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -