-
Notifications
You must be signed in to change notification settings - Fork 12
/
filter.htm
executable file
·371 lines (330 loc) · 17.4 KB
/
filter.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 11">
<meta name=Originator content="Microsoft Word 11">
<link rel=File-List href="filter_files/filelist.xml">
<title>passthru</title>
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:SpellingState>Clean</w:SpellingState>
<w:GrammarState>Clean</w:GrammarState>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;
mso-font-alt:"\FF2D\FF33 \660E\671D";
mso-font-charset:128;
mso-generic-font-family:modern;
mso-font-pitch:fixed;
mso-font-signature:-1610612033 1757936891 16 0 131231 0;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:536871559 0 0 0 415 0;}
@font-face
{font-family:"\@MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;
mso-font-charset:128;
mso-generic-font-family:modern;
mso-font-pitch:fixed;
mso-font-signature:-1610612033 1757936891 16 0 131231 0;}
@font-face
{font-family:"MS Sans Serif";
panose-1:0 0 0 0 0 0 0 0 0 0;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-format:other;
mso-font-pitch:variable;
mso-font-signature:3 0 0 0 1 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
color:black;}
h2
{mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
mso-outline-level:2;
font-size:18.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"MS Mincho";
color:black;
font-weight:bold;}
h3
{mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
mso-outline-level:3;
font-size:13.5pt;
font-family:"Times New Roman";
mso-fareast-font-family:"MS Mincho";
color:black;
font-weight:bold;}
h4
{mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
mso-outline-level:4;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"MS Mincho";
color:black;
font-weight:bold;}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;
text-underline:single;}
p
{mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
color:black;}
pre
{margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
font-size:10.0pt;
font-family:"Courier New";
mso-fareast-font-family:"Courier New";
color:black;}
span.SpellE
{mso-style-name:"";
mso-spl-e:yes;}
span.GramE
{mso-style-name:"";
mso-gram-e:yes;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]-->
<meta name=Template content="C:\Program Files\Microsoft Office\Office\html.dot">
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="5122"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1"/>
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor=white lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>
<div class=Section1>
<h2><a name=MYSAMPLE><span style='font-family:Verdana'>NDISLWF.SYS - Sample
NDIS 6.0 Filter Driver</span></a><span style='font-family:Verdana'><o:p></o:p></span></h2>
<p class=MsoNormal>Note: the sample driver is still in development phase, it
might contain some extra code which is for testing purpose or for demonstration
purpose. At this time, filter driver should not try to issue OID requests to
underlying drivers and NDIS doesn’t pass any OID requests to filter drivers
either.</p>
<h3><span style='font-family:Verdana'>SUMMARY<o:p></o:p></span></h3>
<p><span class=SpellE><b><span style='font-family:Verdana'>Ndislwf</span></b></span><b><span
style='font-family:Verdana'> NDIS 6.0 Filter Driver<o:p></o:p></span></b></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>The <span class=SpellE>Ndislwf</span>
sample is currently a do-nothing pass-through NDIS 6 filter driver that
demonstrates the basic principles underlying an NDIS 6.0 Filter driver. The
sample is a replacement of NDIS 5 Sample Intermediate <span class=GramE>Driver(</span><span
class=SpellE>Passthru</span> driver).This driver exposes a virtual device to
handle <span class=SpellE>IOCTLs</span> from user applications.<o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>Although the filter
driver is of type of modifying filter driver, the filter driver currently doesn’t
modify the send data and it only re-packages and sends down all requests and
sends submitted to one of the filter modules in this filter driver. The filter
driver can be modified to change the data before passing it along or generate
new send data and send it down. For example, it could encrypt/compress outgoing
and decrypt/decompress incoming data.<o:p></o:p></span></p>
<p><span class=SpellE><span style='font-size:10.0pt;font-family:Verdana'>Ndislwf</span></span><span
style='font-size:10.0pt;font-family:Verdana'> also indicates up all received
data and status indications that it receives. It can be modified to change the
data or status indications before indicating it up, and also the filter driver
can generate status indications and receive data.<o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>BUILDING THE SAMPLE<o:p></o:p></span></h3>
<p><span style='font-size:10.0pt;font-family:Verdana'>Run the <b>build</b>
command from this directory to build the sample—it creates the binary <span
class=SpellE>Ndislwf.sys</span>. <o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>To install this driver on
Windows Vista (or above), use <span class=SpellE>netlwf.INF</span> also found
in this DDK.<o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>INSTALLING THE SAMPLE<o:p></o:p></span></h3>
<p><span class=SpellE><span style='font-size:10.0pt;font-family:Verdana'>Ndislwf</span></span><span
style='font-size:10.0pt;font-family:Verdana'> is installed as a service (called
“NDIS Sample <span class=SpellE>LightWeight</span> Filter” in the supplied
INF). To install, follow the steps below.<o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>Prepare a floppy disk (or
installation directory) that contains these files: <span class=SpellE>netlwf.inf</span>
and <span class=SpellE>ndislwf.sys</span>.<o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>On the desktop, click <b
style='mso-bidi-font-weight:normal'>Start</b>, then open <b style='mso-bidi-font-weight:
normal'>Control Panel</b>, then open <b style='mso-bidi-font-weight:normal'>Network
and Internet Connections</b>, then open <b style='mso-bidi-font-weight:normal'>Network
Connections</b>, then right-click on the relevant Local Area Connection icon
and choose <b>Properties</b>. <o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>Click <b>Install</b>,
then <b>Service</b>, then <b>Add</b>, <span class=GramE>then</span> <b>Have
Disk</b>. <o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>Browse to the
drive/directory containing the files listed above. Click <b>OK</b>. This should
show “NDIS Sample <span class=SpellE>LightWeight</span> Filter” in a list of
Network Services. Highlight this and click <b>OK</b>. This should install the <span
class=SpellE>Ndislwf</span> filter driver. <o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>Click <b>OK</b> or <b>Yes</b>
each time if the system prompts with a warning regarding installation of
unsigned files. This is necessary because binaries generated via the LDK build
environment are not signed.<o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>CODE TOUR<o:p></o:p></span></h3>
<h4><span style='font-family:Verdana'>File Manifest<o:p></o:p></span></h4>
<pre><u>File<span style='mso-tab-count:2'> </span>Description<o:p></o:p></u></pre><pre><o:p> </o:p></pre><pre><span
class=SpellE><span class=GramE>makefile</span></span><span style='mso-tab-count:
1'> </span>Used during compilation to create the object and sys files</pre><pre><span
class=SpellE><span class=GramE>filter.c</span></span><span style='mso-tab-count:
1'> </span>Filter driver entry points and related functions in the <span
class=SpellE>Ndislwf</span> filter driver</pre><pre><span class=SpellE><span
class=GramE>netlwf.inf</span></span><span style='mso-tab-count:1'> </span>Installation INF for the service </pre><pre><span
class=SpellE><span class=GramE>device.c</span></span><span style='mso-tab-count:
1'> </span>Virtual device related routines such as registering a device and handling <span
class=SpellE>IOCTLs</span> </pre><pre><span class=SpellE><span class=GramE>filter.h</span></span><span
style='mso-tab-count:1'> </span>Prototypes of all functions and data structures used by the <span
class=SpellE>Ndislwf</span> driver</pre><pre><span class=GramE>filter.htm</span><span
style='mso-tab-count:1'> </span>Documentation for the filter driver (this file)</pre><pre><span
class=SpellE><span class=GramE>filter.rc</span></span><span style='mso-tab-count:
1'> </span>Resource file for the <span class=SpellE>Ndislwf</span> driver</pre><pre><span
class=SpellE><span class=GramE>precomp.h</span></span><span style='mso-tab-count:
1'> </span><span class=SpellE>Precompile</span> header file</pre><pre><span
class=SpellE><span class=GramE>flt_dbg.c</span></span><span style='mso-spacerun:yes'> </span>Debug-related code</pre><pre><span
class=SpellE><span class=GramE>flt_dbg.h</span></span><span style='mso-spacerun:yes'> </span>Debug code definitions and structures</pre><pre><span
class=GramE>sources</span><span style='mso-tab-count:2'> </span>List of source files that are compiled and linked to create the <span
class=SpellE>ndislwf</span> driver. </pre>
<h4 style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-family:Verdana'>Programming Tour<o:p></o:p></span></h4>
<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-size:10.0pt;font-family:Verdana'>Basic steps in attaching and
detaching of <span class=SpellE>Ndislwf</span> driver:<o:p></o:p></span></p>
<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-size:10.0pt;font-family:Verdana'>1) During <span class=SpellE>DriverEntry</span>,
the <span class=SpellE>ndislwf</span> driver registers as a NDIS 6 filter
driver.<o:p></o:p></span></p>
<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-size:10.0pt;font-family:Verdana'>2) Later on, NDIS calls <span
class=SpellE>Ndislwf</span> <span class=SpellE>FilterAttach</span> handler, for
each underlying NDIS adapter on which it is configured to attach.<o:p></o:p></span></p>
<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-size:10.0pt;font-family:Verdana'>3) In the context of <span
class=SpellE>FilterAttach</span> Handler, filter driver call <span
class=SpellE>NdisFAttribute</span> to register its filter module context with
NDIS. After that, filter driver can read its own setting in registry by calling
<span class=SpellE>NdisOpenConfigurationEx</span>, and calls <span
class=SpellE>NdisXXX</span> functions.<o:p></o:p></span></p>
<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-size:10.0pt;font-family:Verdana'>4) After <span class=SpellE>FilterAttach</span>
successfully returns, NDIS restarts the filter later by calling <span
class=SpellE>FilterRestart</span> handler. <span class=SpellE>FilterRestart</span>
should prepare to handle send/receive data. After restart return successfully,
filter driver should be able to process send/receive.<o:p></o:p></span></p>
<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-size:10.0pt;font-family:Verdana'>5) All requests and sends coming
from overlying drivers for the <span class=SpellE>Ndislwf</span> filter driver
are repackaged if necessary and sent down to NDIS, to be passed to the
underlying NDIS driver.<o:p></o:p></span></p>
<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-size:10.0pt;font-family:Verdana'>6) All indications arriving from
an underlying NDIS driver are forwarded up by <span class=SpellE>Ndislwf</span>
filter driver.<o:p></o:p></span></p>
<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-size:10.0pt;font-family:Verdana'>7) NDIS call <span class=SpellE>FilterPause</span>
handler when NDIS needs to detach the filter from the stack or there is some
configuration changes in the stack. In processing the pause request from NDIS,
the <span class=SpellE>Ndislwf</span> driver <span class=SpellE>waitsfor</span>
all its own outstanding requests to be completed before it completes the pause
request.<o:p></o:p></span></p>
<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-size:10.0pt;font-family:Verdana'>7) NDIS calls the <span
class=SpellE>Ndislwf</span> driver’s <span class=SpellE>FilterDetach</span>
entry point when NDIS needs to detach a filter module from NDIS stack. <span
class=SpellE>FilterDetach</span> handler should free all the memory allocation
done in <span class=SpellE>FilterAttach</span>, and undo the operations it did
in <span class=SpellE>FilterAttach</span> Handler.<o:p></o:p></span></p>
<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-size:10.0pt;font-family:Verdana'><o:p> </o:p></span></p>
<p align=center style='text-align:center;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><a
href="#top"><span style='font-size:10.0pt;font-family:Verdana'>Top of page</span></a><span
style='font-size:10.0pt;font-family:Verdana'> <o:p></o:p></span></p>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=624
style='width:6.5in;mso-cellspacing:0in;mso-padding-alt:0in 0in 0in 0in'>
<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes;
height:1.5pt'>
<td style='background:aqua;padding:.75pt .75pt .75pt .75pt;height:1.5pt'>
<p class=MsoNormal><o:p> </o:p></p>
</td>
</tr>
</table>
<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
style='font-size:7.5pt;font-family:"MS Sans Serif"'>© 1999 Microsoft
Corporation</span><span style='font-size:10.0pt;font-family:Verdana'> <o:p></o:p></span></p>
</div>
</body>
</html>