Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

366 lines
16 KiB

  1. <html xmlns:v="urn:schemas-microsoft-com:vml"
  2. xmlns:o="urn:schemas-microsoft-com:office:office"
  3. xmlns:w="urn:schemas-microsoft-com:office:word"
  4. xmlns="http://www.w3.org/TR/REC-html40">
  5. <head>
  6. <meta http-equiv=Content-Type content="text/html; charset=windows-1252">
  7. <meta name=ProgId content=Word.Document>
  8. <meta name=Generator content="Microsoft Word 9">
  9. <meta name=Originator content="Microsoft Word 9">
  10. <link rel=File-List href="./passthru_files/filelist.xml">
  11. <title>passthru</title>
  12. <style>
  13. <!--
  14. /* Font Definitions */
  15. @font-face
  16. {font-family:"MS Sans Serif";
  17. panose-1:0 0 0 0 0 0 0 0 0 0;
  18. mso-font-charset:0;
  19. mso-generic-font-family:swiss;
  20. mso-font-format:other;
  21. mso-font-pitch:variable;
  22. mso-font-signature:3 0 0 0 1 0;}
  23. @font-face
  24. {font-family:Verdana;
  25. panose-1:2 11 6 4 3 5 4 4 2 4;
  26. mso-font-charset:0;
  27. mso-generic-font-family:swiss;
  28. mso-font-pitch:variable;
  29. mso-font-signature:536871559 0 0 0 415 0;}
  30. /* Style Definitions */
  31. p.MsoNormal, li.MsoNormal, div.MsoNormal
  32. {mso-style-parent:"";
  33. margin:0in;
  34. margin-bottom:.0001pt;
  35. mso-pagination:widow-orphan;
  36. font-size:12.0pt;
  37. font-family:"Times New Roman";
  38. mso-fareast-font-family:"Times New Roman";
  39. color:black;}
  40. h2
  41. {margin-right:0in;
  42. mso-margin-top-alt:auto;
  43. mso-margin-bottom-alt:auto;
  44. margin-left:0in;
  45. mso-pagination:widow-orphan;
  46. mso-outline-level:2;
  47. font-size:18.0pt;
  48. font-family:"Times New Roman";
  49. color:black;
  50. font-weight:bold;}
  51. h3
  52. {margin-right:0in;
  53. mso-margin-top-alt:auto;
  54. mso-margin-bottom-alt:auto;
  55. margin-left:0in;
  56. mso-pagination:widow-orphan;
  57. mso-outline-level:3;
  58. font-size:13.5pt;
  59. font-family:"Times New Roman";
  60. color:black;
  61. font-weight:bold;}
  62. h4
  63. {margin-right:0in;
  64. mso-margin-top-alt:auto;
  65. mso-margin-bottom-alt:auto;
  66. margin-left:0in;
  67. mso-pagination:widow-orphan;
  68. mso-outline-level:4;
  69. font-size:12.0pt;
  70. font-family:"Times New Roman";
  71. color:black;
  72. font-weight:bold;}
  73. a:link, span.MsoHyperlink
  74. {color:blue;
  75. text-decoration:underline;
  76. text-underline:single;}
  77. a:visited, span.MsoHyperlinkFollowed
  78. {color:purple;
  79. text-decoration:underline;
  80. text-underline:single;}
  81. p
  82. {margin-right:0in;
  83. mso-margin-top-alt:auto;
  84. mso-margin-bottom-alt:auto;
  85. margin-left:0in;
  86. mso-pagination:widow-orphan;
  87. font-size:12.0pt;
  88. font-family:"Times New Roman";
  89. mso-fareast-font-family:"Times New Roman";
  90. color:black;}
  91. pre
  92. {margin:0in;
  93. margin-bottom:.0001pt;
  94. mso-pagination:widow-orphan;
  95. 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;
  96. font-size:10.0pt;
  97. font-family:"Courier New";
  98. mso-fareast-font-family:"Courier New";
  99. color:black;}
  100. @page Section1
  101. {size:8.5in 11.0in;
  102. margin:1.0in 1.25in 1.0in 1.25in;
  103. mso-header-margin:.5in;
  104. mso-footer-margin:.5in;
  105. mso-paper-source:0;}
  106. div.Section1
  107. {page:Section1;}
  108. -->
  109. </style>
  110. <!--[if gte mso 9]><xml>
  111. <o:shapedefaults v:ext="edit" spidmax="1027"/>
  112. </xml><![endif]--><!--[if gte mso 9]><xml>
  113. <o:shapelayout v:ext="edit">
  114. <o:idmap v:ext="edit" data="1"/>
  115. </o:shapelayout></xml><![endif]-->
  116. <meta name=Template content="C:\Program Files\Microsoft Office\Office\html.dot">
  117. </head>
  118. <body bgcolor=white lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>
  119. <div class=Section1>
  120. <h2><a name=MYSAMPLE></a><a name=top></a><span style='mso-bookmark:MYSAMPLE'>
  121. <!doctype HTML>
  122. <span style='font-family:Verdana'><! ---------------- Snip Snip ---------------- >PASSTHRU.SYS
  123. - Sample NDIS Intermediate Driver</span></span><span style='font-family:Verdana'><o:p></o:p></span></h2>
  124. <h3><span style='font-family:Verdana'>SUMMARY<o:p></o:p></span></h3>
  125. <p><b><span style='font-family:Verdana'>Passthru Intermediate Miniport Driver<o:p></o:p></span></b></p>
  126. <p><span style='font-size:10.0pt;font-family:Verdana'>The Passthru sample is a do-nothing
  127. pass-through NDIS 5 driver that demonstrates the basic principles underlying an
  128. NDIS Intermediate Miniport (IM) driver. This driver exposes a virtual adapter
  129. for each binding to a real or virtual NDIS adapter. Protocols bind to these
  130. virtual adapters as if they are real adapters. <o:p></o:p></span></p>
  131. <p><span style='font-size:10.0pt;font-family:Verdana'>The Passthru driver
  132. re-packages and sends down all requests and sends submitted to this virtual
  133. adapter. The Passthru driver can be modified to change the data before passing
  134. it along. For example, it could encrypt/compress outgoing and
  135. decrypt/decompress incoming data.<o:p></o:p></span></p>
  136. <p><span style='font-size:10.0pt;font-family:Verdana'>Passthru also re-packages
  137. and indicates up all received data and status indications that it receives at
  138. its lower (protocol) edge.<o:p></o:p></span></p>
  139. <p><span style='font-size:10.0pt;font-family:Verdana'>A related sample is the PASSTHRU
  140. notification object sample found under network\ndis\Passthru\notifyob in this
  141. DDK.<o:p></o:p></span></p>
  142. <h3><span style='font-family:Verdana'>BUILDING THE SAMPLE<o:p></o:p></span></h3>
  143. <p><span style='font-size:10.0pt;font-family:Verdana'>Run the <b>build</b>
  144. command from this directory to build the sample�it creates the binary
  145. Passthru.sys. <o:p></o:p></span></p>
  146. <p><span style='font-size:10.0pt;font-family:Verdana'>To install this driver on
  147. Windows� 2000, use the PASSTHRU sample notification object and INFs, also found
  148. in this DDK.<o:p></o:p></span></p>
  149. <h3><span style='font-family:Verdana'>INSTALLING THE SAMPLE<o:p></o:p></span></h3>
  150. <p><span style='font-size:10.0pt;font-family:Verdana'>Passthru is installed as
  151. a service (called �Passthru Driver� in the supplied INFs/notification object).
  152. To install, follow the steps below.<o:p></o:p></span></p>
  153. <p><span style='font-size:10.0pt;font-family:Verdana'>Prepare a floppy disk (or
  154. installation directory) that contains these files: netsf.inf, netsf_m.inf,
  155. passthru.sys and passthru.dll (notification object DLL, built in this DDK at
  156. network\ndis\Passthru\notifyob).<o:p></o:p></span></p>
  157. <p><span style='font-size:10.0pt;font-family:Verdana'>On the desktop,
  158. right-click the <b>My Network Places</b> icon and choose <b>Properties</b>. <o:p></o:p></span></p>
  159. <p><span style='font-size:10.0pt;font-family:Verdana'>Right-click on the
  160. relevant Local Area Connection icon and choose <b>Properties</b>. <o:p></o:p></span></p>
  161. <p><span style='font-size:10.0pt;font-family:Verdana'>Click <b>Install</b>,
  162. then <b>Service</b>, then <b>Add</b>, then <b>Have Disk</b>. <o:p></o:p></span></p>
  163. <p><span style='font-size:10.0pt;font-family:Verdana'>Browse to the
  164. drive/directory containing the files listed above. Click <b>OK</b>. This should
  165. show �Passthru Driver� in a list of Network Services. Highlight this and click <b>OK</b>.
  166. This should install the Passthru driver. <o:p></o:p></span></p>
  167. <p><span style='font-size:10.0pt;font-family:Verdana'>Click <b>OK</b> or <b>Yes</b>
  168. each time the system prompts with a warning regarding installation of unsigned
  169. files. This is necessary because binaries generated via the DDK build
  170. environment are not signed.<o:p></o:p></span></p>
  171. <p><span style='font-size:10.0pt;font-family:Verdana'>Two .INF files are needed
  172. rather than one because Passthru is installed both as a protocol and a
  173. miniport.<o:p></o:p></span></p>
  174. <h3><span style='font-family:Verdana'>CODE TOUR<o:p></o:p></span></h3>
  175. <h4><span style='font-family:Verdana'>File Manifest<o:p></o:p></span></h4>
  176. <pre><u>File<span style='mso-tab-count:2'>���������� </span>Description<o:p></o:p></u></pre><pre><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></pre><pre>Makefile<span
  177. style='mso-tab-count:1'>������ </span>Used during compilation to create the object and sys files</pre><pre>Miniport.c<span
  178. style='mso-tab-count:1'>���� </span>Miniport related functions of the passthru driver</pre><pre>Netsf.inf<span
  179. style='mso-tab-count:1'>����� </span>Installation INF for the service (protocol side installation)</pre><pre>Netsf_m.inf<span
  180. style='mso-tab-count:1'>��� </span>Installation INF for the miniport (virtual device installation)</pre><pre>Passthru.c<span
  181. style='mso-tab-count:1'>���� </span>DriverEntry routine and any routines common to the passthru miniport and protocol </pre><pre>Passthru.h<span
  182. style='mso-tab-count:1'>���� </span>Prototypes of all functions and data structures used by the Passthru driver</pre><pre>Passthru.htm<span
  183. style='mso-tab-count:1'>�� </span>Documentation for the Passthru driver (this file)</pre><pre>Passthru.rc<span
  184. style='mso-tab-count:1'>��� </span>Resource file for the Passthru driver</pre><pre>Precomp.h<span
  185. style='mso-tab-count:1'>����� </span>Precompile header file</pre><pre>Protocol.c<span
  186. style='mso-tab-count:1'>���� </span>Protocol related functions of the Passthru driver</pre><pre>Sources<span
  187. style='mso-tab-count:2'>������� </span>List of source files that are compiled and linked to create the passthru driver. This can be modified to create binaries that operate on previous Windows versions (e.g. Windows 2000).</pre>
  188. <h4><span style='font-family:Verdana'>Programming Tour<o:p></o:p></span></h4>
  189. <p><span style='font-size:10.0pt;font-family:Verdana'>Basic steps in
  190. initializing and halting of Passthru driver:<o:p></o:p></span></p>
  191. <p><span style='font-size:10.0pt;font-family:Verdana'>1) During DriverEntry,
  192. the Passthru driver registers as a protocol and an Intermediate miniport
  193. driver.<o:p></o:p></span></p>
  194. <p><span style='font-size:10.0pt;font-family:Verdana'>2) Later on, NDIS calls
  195. Passthru�s BindAdapterHandler, PtBindAdapter, for each underlying NDIS adapter
  196. to which it is configured to bind.<o:p></o:p></span></p>
  197. <p><span style='font-size:10.0pt;font-family:Verdana'>3) In the context of
  198. BindAdapterHandler and after successfully opening a binding to the underlying
  199. adapter, the Passthru driver queries the reserved keyword
  200. &quot;UpperBindings&quot; to get a list of device names for the virtual
  201. adapters that this particular binding is to expose. Since this driver
  202. implements a 1:1 relationship between lower bindings and virtual adapters, this
  203. list contains a single name. �Mux� IM drivers that expose multiple virtual
  204. adapters over a single underlying adapter will process multiple entries in
  205. UpperBindings.<o:p></o:p></span></p>
  206. <p><span style='font-size:10.0pt;font-family:Verdana'>4) For each device name,
  207. the Passthru driver calls NdisIMInitializeDeviceInstanceEx.<o:p></o:p></span></p>
  208. <p><span style='font-size:10.0pt;font-family:Verdana'>5) In response, NDIS will
  209. eventually call back Passthru miniport�s MiniportInitialize entry point,
  210. MPInitialize.<o:p></o:p></span></p>
  211. <p><span style='font-size:10.0pt;font-family:Verdana'>6) After MPInitialize successfully
  212. returns, NDIS takes care of getting upper-layer protocols to bind to the newly
  213. created virtual adapter(s).<o:p></o:p></span></p>
  214. <p><span style='font-size:10.0pt;font-family:Verdana'>7) All requests and sends
  215. coming from upper-layer protocols for the Passthru miniport driver are
  216. repackaged and sent down to NDIS, to be passed to the underlying NDIS adapter.<o:p></o:p></span></p>
  217. <p><span style='font-size:10.0pt;font-family:Verdana'>8) All indications
  218. arriving from bindings to an underlying NDIS adapter are forwarded up as if
  219. they generated from Passthru�s virtual adapters.<o:p></o:p></span></p>
  220. <p><span style='font-size:10.0pt;font-family:Verdana'>9) NDIS calls the
  221. Passthru driver�s ProtocolUnbind entry point to request it to close the binding
  222. between an underlying adapter and Passthru protocol. In processing this, the
  223. Passthru driver first calls NdisIMDeInitializeDeviceInstance for the virtual
  224. adapter(s) representing that particular binding.<o:p></o:p></span></p>
  225. <p><span style='font-size:10.0pt;font-family:Verdana'>10) NDIS in turn will
  226. close all the bindings between upper-layer protocols and virtual Passthru
  227. adapter.<o:p></o:p></span></p>
  228. <p><span style='font-size:10.0pt;font-family:Verdana'>11) After all the
  229. bindings are closed, NDIS calls the Passthru driver�s MiniportHalt entry point
  230. (MPHalt) for the virtual adapter.<o:p></o:p></span></p>
  231. <p><span style='font-size:10.0pt;font-family:Verdana'>12) The Passthru protocol
  232. then closes the binding to the underlying adapter by calling NdisCloseAdapter,
  233. and completes the unbind request issued in step 9.<o:p></o:p></span></p>
  234. <p><span style='font-size:10.0pt;font-family:Verdana'>13) <b>Handling Power
  235. Management</b><o:p></o:p></span></p>
  236. <p><span style='font-size:10.0pt;font-family:Verdana'>13.1 During
  237. initialization, the Passthru miniport should set the Attribute '<i>NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND</i>'
  238. in its call to NdisMSetAttributesEx. <o:p></o:p></span></p>
  239. <p><span style='font-size:10.0pt;font-family:Verdana'>13.2 When the Passthru
  240. miniport is requested to report its Plug and Play capabilities
  241. (OID_PNP_CAPABILITIES), the Passthru miniport must pass the request to the
  242. underlying miniport. If this request succeeds, then the Passthru miniport
  243. should overwrite the following fields before successfully completing the
  244. original request: <o:p></o:p></span></p>
  245. <p><span style='font-size:10.0pt;font-family:Verdana'>NDIS_DEVICE_POWER_STATE<span
  246. style='mso-tab-count:1'>�������� </span>MinMagicPacketWakeUp =
  247. NdisDeviceStateUnspecified;<o:p></o:p></span></p>
  248. <p><span style='font-size:10.0pt;font-family:Verdana'>NDIS_DEVICE_POWER_STATE<span
  249. style='mso-tab-count:1'>�������� </span>MinPatternWakeUp=
  250. NdisDeviceStateUnspecified;<o:p></o:p></span></p>
  251. <p><span style='font-size:10.0pt;font-family:Verdana'>NDIS_DEVICE_POWER_STATE<span
  252. style='mso-tab-count:1'>�������� </span>MinLinkChangeWakeUp=NdisDeviceStateUnspecified<o:p></o:p></span></p>
  253. <p><span style='font-size:10.0pt;font-family:Verdana'>If the miniport below the
  254. Passthru protocol fails this request, then the status that was returned should
  255. be used to respond to the original request that was made to the Passthru
  256. miniport. <o:p></o:p></span></p>
  257. <p><span style='font-size:10.0pt;font-family:Verdana'>13.3 OID_PNP_SET_POWER
  258. and OID_PNP_QUERY_POWER should not be passed to the miniport below the Passthru
  259. protocol, as those miniports will receive independent requests from NDIS.<o:p></o:p></span></p>
  260. <p><span style='font-size:10.0pt;font-family:Verdana'>13.4 NDIS calls the
  261. Passthru driver�s ProtocolPnPEvent entry point (PtPnPHandler) whenever the
  262. underlying adapter is transitioned to a different power state. If the
  263. underlying adapter is transitioning to a low power state, the IM driver should
  264. wait for all outstanding sends and requests to complete.<o:p></o:p></span></p>
  265. <p><span style='font-size:10.0pt;font-family:Verdana'>14) <b>NDIS 5.1 Features</b><o:p></o:p></span></p>
  266. <p><span style='font-size:10.0pt;font-family:Verdana'>14.1 All NDIS 5.1
  267. features in Passthru are identified by #ifdef NDIS51 compiler directives. The
  268. following major features are illustrated (refer to the DDK documentation for
  269. more information on these):<o:p></o:p></span></p>
  270. <p><b><span style='font-size:10.0pt;font-family:Verdana'>Packet stacking</span></b><span
  271. style='font-size:10.0pt;font-family:Verdana'>: this allows an IM driver to
  272. reuse a packet submitted to its protocol or miniport edge to forward data down
  273. (or up) to the adjacent layer.<o:p></o:p></span></p>
  274. <p><b><span style='font-size:10.0pt;font-family:Verdana'>Canceling Sends</span></b><span
  275. style='font-size:10.0pt;font-family:Verdana'>: Passthru propagates send
  276. cancellations from protocols above it to lower miniports.<o:p></o:p></span></p>
  277. <p><b><span style='font-size:10.0pt;font-family:Verdana'>PnP Event Propagation</span></b><span
  278. style='font-size:10.0pt;font-family:Verdana'>: Passthru propagates PnP events
  279. arriving at its protocol (lower) edge to higher layer protocols that are bound
  280. to its virtual adapter.<o:p></o:p></span></p>
  281. <p><b><span style='font-size:10.0pt;font-family:Verdana'>NdisQueryPendingIOCount</span></b><span
  282. style='font-size:10.0pt;font-family:Verdana'>: Passthru uses this new API to
  283. determine if any I/O operations are in progress on its lower binding.<o:p></o:p></span></p>
  284. <p><span style='font-size:10.0pt;font-family:Verdana'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
  285. <p><span style='font-size:10.0pt;font-family:Verdana'><span
  286. style="mso-spacerun: yes">�</span><o:p></o:p></span></p>
  287. <p align=center style='text-align:center'><a href="#top"><span
  288. style='font-size:10.0pt;font-family:Verdana'>Top of page</span></a><span
  289. style='font-size:10.0pt;font-family:Verdana'> <o:p></o:p></span></p>
  290. <table border=0 cellspacing=0 cellpadding=0 width=624 style='width:6.5in;
  291. mso-cellspacing:0in;mso-padding-alt:0in 0in 0in 0in'>
  292. <tr style='height:1.5pt'>
  293. <td style='background:aqua;padding:.75pt .75pt .75pt .75pt;height:1.5pt'>
  294. <p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
  295. </td>
  296. </tr>
  297. </table>
  298. <p><span style='font-size:7.5pt;font-family:"MS Sans Serif"'>� 1999 Microsoft
  299. Corporation</span><span style='font-size:10.0pt;font-family:Verdana'> <o:p></o:p></span></p>
  300. </div>
  301. </body>
  302. </html>