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.

822 lines
93 KiB

  1. ��<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html xmlns:v="urn:schemas-microsoft-com:vml"
  3. xmlns:o="urn:schemas-microsoft-com:office:office"
  4. xmlns:w="urn:schemas-microsoft-com:office:word"
  5. xmlns="http://www.w3.org/TR/REC-html40">
  6. <head>
  7. <meta http-equiv=Content-Type content="text/html; charset=unicode">
  8. <meta name=ProgId content=Word.Document>
  9. <meta name=Generator content="Microsoft Word 9">
  10. <meta name=Originator content="Microsoft Word 9">
  11. <link rel=File-List href="./spti_files/filelist.xml">
  12. <!--[if gte mso 9]><xml>
  13. <w:WordDocument>
  14. <w:ActiveWritingStyle Lang="EN-US" VendorID="64" DLLVersion="131077"
  15. NLCheck="1">1</w:ActiveWritingStyle>
  16. </w:WordDocument>
  17. </xml><![endif]-->
  18. <style>
  19. <!--
  20. /* Font Definitions */
  21. @font-face
  22. {font-family:"MS Sans Serif";
  23. panose-1:0 0 0 0 0 0 0 0 0 0;
  24. mso-font-charset:0;
  25. mso-generic-font-family:swiss;
  26. mso-font-format:other;
  27. mso-font-pitch:variable;
  28. mso-font-signature:3 0 0 0 1 0;}
  29. @font-face
  30. {font-family:Wingdings;
  31. panose-1:5 0 0 0 0 0 0 0 0 0;
  32. mso-font-charset:2;
  33. mso-generic-font-family:auto;
  34. mso-font-pitch:variable;
  35. mso-font-signature:0 268435456 0 0 -2147483648 0;}
  36. @font-face
  37. {font-family:"MS Mincho";
  38. panose-1:0 0 0 0 0 0 0 0 0 0;
  39. mso-font-alt:"-�3� fg";
  40. mso-font-charset:128;
  41. mso-generic-font-family:roman;
  42. mso-font-format:other;
  43. mso-font-pitch:fixed;
  44. mso-font-signature:1 134676480 16 0 131072 0;}
  45. @font-face
  46. {font-family:Verdana;
  47. panose-1:2 11 6 4 3 5 4 4 2 4;
  48. mso-font-charset:0;
  49. mso-generic-font-family:swiss;
  50. mso-font-pitch:variable;
  51. mso-font-signature:536871559 0 0 0 415 0;}
  52. @font-face
  53. {font-family:"\@MS Mincho";
  54. panose-1:0 0 0 0 0 0 0 0 0 0;
  55. mso-font-charset:128;
  56. mso-generic-font-family:roman;
  57. mso-font-format:other;
  58. mso-font-pitch:fixed;
  59. mso-font-signature:1 134676480 16 0 131072 0;}
  60. /* Style Definitions */
  61. p.MsoNormal, li.MsoNormal, div.MsoNormal
  62. {mso-style-parent:"";
  63. margin:0in;
  64. margin-bottom:.0001pt;
  65. mso-pagination:widow-orphan;
  66. font-size:12.0pt;
  67. font-family:"Times New Roman";
  68. mso-fareast-font-family:"Times New Roman";
  69. color:black;}
  70. h2
  71. {margin-right:0in;
  72. mso-margin-top-alt:auto;
  73. mso-margin-bottom-alt:auto;
  74. margin-left:0in;
  75. mso-pagination:widow-orphan;
  76. mso-outline-level:2;
  77. font-size:18.0pt;
  78. font-family:"Times New Roman";
  79. color:black;
  80. font-weight:bold;}
  81. h3
  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. mso-outline-level:3;
  88. font-size:13.5pt;
  89. font-family:"Times New Roman";
  90. color:black;
  91. font-weight:bold;}
  92. h4
  93. {margin-right:0in;
  94. mso-margin-top-alt:auto;
  95. mso-margin-bottom-alt:auto;
  96. margin-left:0in;
  97. mso-pagination:widow-orphan;
  98. mso-outline-level:4;
  99. font-size:12.0pt;
  100. font-family:"Times New Roman";
  101. color:black;
  102. font-weight:bold;}
  103. a:link, span.MsoHyperlink
  104. {color:blue;
  105. text-decoration:underline;
  106. text-underline:single;}
  107. a:visited, span.MsoHyperlinkFollowed
  108. {color:purple;
  109. text-decoration:underline;
  110. text-underline:single;}
  111. p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
  112. {margin:0in;
  113. margin-bottom:.0001pt;
  114. mso-pagination:widow-orphan;
  115. font-size:10.0pt;
  116. font-family:"Courier New";
  117. mso-fareast-font-family:"Times New Roman";
  118. mso-bidi-font-family:"Times New Roman";
  119. color:windowtext;}
  120. p
  121. {margin-right:0in;
  122. mso-margin-top-alt:auto;
  123. mso-margin-bottom-alt:auto;
  124. margin-left:0in;
  125. mso-pagination:widow-orphan;
  126. font-size:12.0pt;
  127. font-family:"Times New Roman";
  128. mso-fareast-font-family:"Times New Roman";
  129. color:black;}
  130. pre
  131. {margin:0in;
  132. margin-bottom:.0001pt;
  133. mso-pagination:widow-orphan;
  134. 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;
  135. font-size:10.0pt;
  136. font-family:"Courier New";
  137. mso-fareast-font-family:"Courier New";
  138. mso-bidi-font-family:"Times New Roman";
  139. color:black;}
  140. @page Section1
  141. {size:8.5in 11.0in;
  142. margin:1.0in 1.25in 1.0in 1.25in;
  143. mso-header-margin:.5in;
  144. mso-footer-margin:.5in;
  145. mso-paper-source:0;}
  146. div.Section1
  147. {page:Section1;}
  148. /* List Definitions */
  149. @list l0
  150. {mso-list-id:1019158786;
  151. mso-list-type:hybrid;
  152. mso-list-template-ids:-386474800 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
  153. @list l0:level1
  154. {mso-level-number-format:bullet;
  155. mso-level-text:��;
  156. mso-level-tab-stop:.5in;
  157. mso-level-number-position:left;
  158. text-indent:-.25in;
  159. font-family:Symbol;}
  160. ol
  161. {margin-bottom:0in;}
  162. ul
  163. {margin-bottom:0in;}
  164. -->
  165. </style>
  166. <!--[if gte mso 9]><xml>
  167. <o:shapedefaults v:ext="edit" spidmax="1027"/>
  168. </xml><![endif]--><!--[if gte mso 9]><xml>
  169. <o:shapelayout v:ext="edit">
  170. <o:idmap v:ext="edit" data="1"/>
  171. </o:shapelayout></xml><![endif]-->
  172. <meta content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot"
  173. name=Template>
  174. </head>
  175. <body bgcolor=white lang=EN-US link=blue vlink=purple style='tab-interval:.5in'
  176. leftmargin=8>
  177. <div class=Section1>
  178. <h2><a name="_Communicating_with_SCSI"></a><span style='font-family:Verdana'>Communicating
  179. with SCSI devices via Win32 application <o:p></o:p></span></h2>
  180. <p class=MsoNormal><span style='font-family:Verdana;color:red'>[This is
  181. preliminary documentation and subject to change.]</span><span style='font-family:
  182. Verdana'> <o:p></o:p></span></p>
  183. <h3><span style='font-family:Verdana'>SUMMARY<o:p></o:p></span></h3>
  184. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  185. mso-fareast-font-family:"MS Mincho"'>Win32 applications can communicate
  186. directly with SCSI devices using the Win32 API DeviceIoControl and specifying the
  187. appropriate I/O control code (IOCTL).<span style="mso-spacerun: yes">�
  188. </span>Before DeviceIoControl can be used, a valid handle to the device must be
  189. obtained.<span style="mso-spacerun: yes">� </span>The handle is obtained using
  190. the Win32 API CreateFile.<o:p></o:p></span></p>
  191. <p><b><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  192. mso-fareast-font-family:"MS Mincho"'>New for Windows 2000:<span
  193. style="mso-spacerun: yes">� </span></span></b><span style='font-size:10.0pt;
  194. mso-bidi-font-size:12.0pt;font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>When
  195. using the SCSI pass through IOCTLs (described below), you must specify an
  196. access mode of <span style="mso-spacerun: yes">�</span>(GENERIC_READ | GENERIC_WRITE)
  197. in CreateFile or the DeviceIoControl call will fail with ERROR_ACCESS_DENIED
  198. (5L).<span style="mso-spacerun: yes">� </span>The access mode is specified in
  199. the second parameter to CreateFile, dwDesiredAccess.<span style="mso-spacerun:
  200. yes">� </span>Refer to the MSDN documentation for specific information about
  201. the Win32 APIs CreateFile and DeviceIoControl.<o:p></o:p></span></p>
  202. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  203. mso-fareast-font-family:"MS Mincho"'>There are several IOCTLs that the SCSI
  204. port driver supports.<span style="mso-spacerun: yes">� </span>Refer to the DDK
  205. file NTDDSCSI.H for the most current information regarding the supported
  206. IOCTLs.<span style="mso-spacerun: yes">� </span>This sample will demonstrate
  207. the following IOCTLs: <a href="#_IOCTL_SCSI_GET_INQUIRY_DATA">IOCTL_SCSI_GET_INQUIRY_DATA</a>,
  208. <a href="#_IOCTL_SCSI_GET_CAPABILITIES">IOCTL_SCSI_GET_CAPABILITIES</a>, <a
  209. href="#_IOCTL_SCSI_PASS_THROUGH_and_IOCTL_SCSI_">IOCTL_SCSI_PASS_THROUGH</a>,
  210. and <a href="#_IOCTL_SCSI_PASS_THROUGH_and_IOCTL_SCSI_">IOCTL_SCSI_PASS_THROUGH_DIRECT</a>.<o:p></o:p></span></p>
  211. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  212. mso-fareast-font-family:"MS Mincho"'>To issue these IOCTLs, the user must be
  213. either the administrator or a member of the Administrator's group.<span
  214. style="mso-spacerun: yes">� </span>If the user does not have the correct privilege
  215. level, the CreateFile call will fail with ERROR_ACCESS_DENIED (5L).<span
  216. style="mso-spacerun: yes">� </span><o:p></o:p></span></p>
  217. <p style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1;
  218. tab-stops:list .5in'><![if !supportLists]><span style='font-size:10.0pt;
  219. mso-bidi-font-size:12.0pt;font-family:Symbol;mso-fareast-font-family:"MS Mincho"'>�<span
  220. style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  221. </span></span><![endif]><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  222. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>If CreateFile fails
  223. with ERROR_ACCESS_DENIED, the user doesn't have the correct privilege
  224. level.<span style="mso-spacerun: yes">� </span><o:p></o:p></span></p>
  225. <p style='margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1;
  226. tab-stops:list .5in'><![if !supportLists]><span style='font-size:10.0pt;
  227. mso-bidi-font-size:12.0pt;font-family:Symbol;mso-fareast-font-family:"MS Mincho"'>�<span
  228. style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  229. </span></span><![endif]><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  230. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>If DeviceIoControl
  231. fails with ERROR_ACCESS_DENIED, the access mode (GENERIC_READ | GENERIC_WRITE) was
  232. not specified in the CreateFile call.<o:p></o:p></span></p>
  233. <h4><a name="_IOCTL_SCSI_GET_INQUIRY_DATA"></a><span style='font-family:Verdana;
  234. mso-fareast-font-family:"MS Mincho"'>IOCTL_SCSI_GET_INQUIRY_DATA<o:p></o:p></span></h4>
  235. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  236. mso-fareast-font-family:"MS Mincho"'>IOCTL_SCSI_GET_INQUIRY_DATA returns a
  237. SCSI_ADAPTER_BUS_INFO structure for all devices that are on the SCSI bus.<span
  238. style="mso-spacerun: yes">� </span>The structure member, BusData, is a
  239. structure of type SCSI_BUS_DATA.<span style="mso-spacerun: yes">� </span>It
  240. contains an offset to the SCSI Inquiry data, which is also stored as a
  241. structure, SCSI_INQUIRY_DATA.<span style="mso-spacerun: yes">� </span>See
  242. NTDDSCSI.H for more details about these structures.<span style="mso-spacerun:
  243. yes">� </span><o:p></o:p></span></p>
  244. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  245. mso-fareast-font-family:"MS Mincho"'>Within the SCSI_INQUIRY_DATA structure is
  246. a member named DeviceClaimed.<span style="mso-spacerun: yes">�
  247. </span>DeviceClaimed indicates whether or not a class driver has claimed this
  248. particular SCSI device.<span style="mso-spacerun: yes">� </span>If a device is
  249. claimed, all SCSI pass through requests must be sent first through the class driver,
  250. which will typically pass the request unmodified to the SCSI port driver.<span
  251. style="mso-spacerun: yes">� </span>The class driver is allowed to fail the SCSI
  252. pass through request if it desires.<span style="mso-spacerun: yes">�
  253. </span>However, the drivers currently shipped by Microsoft simply pass the SCSI
  254. pass through requests on to the SCSI port driver.<span style="mso-spacerun:
  255. yes">� </span>If the device is unclaimed, the SCSI pass through requests are
  256. sent directly to the SCSI port driver.<span style="mso-spacerun: yes">�
  257. </span>See <a href="#_Obtaining_a_handle">Obtaining a handle to a device</a>
  258. for more details.<o:p></o:p></span></p>
  259. <h4><a name="_IOCTL_SCSI_GET_CAPABILITIES"></a><span style='font-family:Verdana;
  260. mso-fareast-font-family:"MS Mincho"'>IOCTL_SCSI_GET_CAPABILITIES<o:p></o:p></span></h4>
  261. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  262. mso-fareast-font-family:"MS Mincho"'>IOCTL_SCSI_GET_CAPABILITIES returns an
  263. IO_SCSI_CAPABILITIES structure (also found in NTDDSCSI.H).<span
  264. style="mso-spacerun: yes">� </span>This structure contains valuable information
  265. about the capabilities of the SCSI adapter.<span style="mso-spacerun: yes">�
  266. </span>Two items of note are the MaximumTransferLength, which is a byte value
  267. indicating the largest data block that can be transferred in a single SRB, and
  268. the MaximumPhysicalPages, which is the maximum number of physical pages that a
  269. data buffer can span.<span style="mso-spacerun: yes">� </span>The
  270. MaximumPhysicalPages indicates how many Scatter/Gather entries the SCSI
  271. miniport driver and adapter can support.<o:p></o:p></span></p>
  272. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  273. mso-fareast-font-family:"MS Mincho"'>To determine the largest transfer that an
  274. adapter can handle, you have to first convert the MaximumPhysicalPages into a
  275. byte value that we ll refer to here as MaximumPhysicalPages_in_bytes.<span
  276. style="mso-spacerun: yes">� </span>Subtract one from MaximumPhysicalPages and
  277. then multiply this value by the system PAGE_SIZE (defined in NTDDK.H) to get
  278. the MaximumPhysicalPages_in_bytes.<span style="mso-spacerun: yes">� </span>Then
  279. the largest transfer that can be issued on an adapter is the smaller of
  280. MaximumTransferLength and MaximumPhysicalPages_in_bytes.<o:p></o:p></span></p>
  281. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  282. mso-fareast-font-family:"MS Mincho"'>For example, assume a system has PAGE_SIZE
  283. = 4KB, and the SCSI capabilities indicate MaximumTransferLength = 16MB and
  284. MaximumPhysicalPages = 17.<span style="mso-spacerun: yes">� </span>Then, the
  285. largest transfer on this adapter would be 64KB based on the following
  286. calculations:<o:p></o:p></span></p>
  287. <p style='margin-left:.5in'><span style='font-size:10.0pt;mso-bidi-font-size:
  288. 12.0pt;font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>MaximumPhysicalPages
  289.  1 = 17  1 = 16 * PAGE_SIZE = 16 * 4096 = 64KB<o:p></o:p></span></p>
  290. <p style='margin-left:.5in'><span style='font-size:10.0pt;mso-bidi-font-size:
  291. 12.0pt;font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>largest
  292. transfer = min(MaximumTransferLength, MaximumPhysicalPages_in_bytes) =
  293. min(16MB, 64KB) = 64KB<o:p></o:p></span></p>
  294. <h4><a name="_IOCTL_SCSI_PASS_THROUGH_and_IOCTL_SCSI_"></a><span
  295. style='font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>IOCTL_SCSI_PASS_THROUGH
  296. and IOCTL_SCSI_PASS_THROUGH_DIRECT<o:p></o:p></span></h4>
  297. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  298. mso-fareast-font-family:"MS Mincho"'>The two IOCTLs IOCTL_SCSI_PASS_THROUGH and
  299. IOCTL_SCSI_PASS_THROUGH_DIRECT allow SCSI CDBs (Command Descriptor Blocks) to
  300. be sent from a Win32 application to a SCSI device.<span style="mso-spacerun:
  301. yes">� </span>Depending on which IOCTL is sent, a corresponding pass through structure
  302. is filled out by the Win32 application.<span style="mso-spacerun: yes">�
  303. </span>IOCTL_SCSI_PASS_THROUGH uses the structure SCSI_PASS_THROUGH.<span
  304. style="mso-spacerun: yes">� </span>IOCTL_SCSI_PASS_THROUGH_DIRECT uses the
  305. structure SCSI_PASS_THROUGH_DIRECT.<span style="mso-spacerun: yes">� </span>See
  306. NTDDSCSI.H for more details about these structures.<o:p></o:p></span></p>
  307. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  308. mso-fareast-font-family:"MS Mincho"'>The structures SCSI_PASS_THROUGH and
  309. SCSI_PASS_THROUGH_DIRECT are virtually identical.<span style="mso-spacerun:
  310. yes">� </span>The only difference is that the data buffer for the
  311. SCSI_PASS_THROUGH structure must be contiguous with the structure.<span
  312. style="mso-spacerun: yes">� </span>This structure member is called
  313. DataBufferOffset and is of type ULONG.<span style="mso-spacerun: yes">�
  314. </span>The data buffer for the SCSI_PASS_THROUGH_DIRECT structure does not have
  315. to be contiguous with the structure.<span style="mso-spacerun: yes">�
  316. </span>This structure member is called DataBuffer and is of type PVOID.<span
  317. style="mso-spacerun: yes">� </span>This is the only difference between the two
  318. structures.<o:p></o:p></span></p>
  319. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  320. mso-fareast-font-family:"MS Mincho"'>IOCTL_SCSI_PASS_THROUGH and
  321. IOCTL_SCSI_PASS_THROUGH_DIRECT are not substitutes for a SCSI class driver and
  322. should only be used for infrequent I/O processing.<span style="mso-spacerun:
  323. yes">� </span>For situations in which frequent SCSI commands need to be sent to
  324. a device, with strict error processing and high performance requirements, the
  325. best solution is to write a SCSI class driver that will send these CDBs to the
  326. respective devices.<span style="mso-spacerun: yes">� </span>SCSI pass through
  327. requests are handled synchronously by the SCSI port driver, even if the Win32
  328. application has the proper code to handle the requests as overlapped I/O.<o:p></o:p></span></p>
  329. <h4><a name="_Obtaining_a_handle"></a><u><span style='font-family:Verdana;
  330. mso-fareast-font-family:"MS Mincho"'>Obtaining a handle to a device</span></u><u><span
  331. style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  332. mso-fareast-font-family:"MS Mincho"'><o:p></o:p></span></u></h4>
  333. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  334. mso-fareast-font-family:"MS Mincho"'>Before any IOCTLs can be sent to a SCSI
  335. device, a handle for the device must be obtained.<span style="mso-spacerun:
  336. yes">� </span>The Win32 API CreateFile is used to obtain this handle and to
  337. define the sharing mode and the access mode.<span style="mso-spacerun: yes">�
  338. </span>The access mode must be specified as (GENERIC_READ |
  339. GENERIC_WRITE).<span style="mso-spacerun: yes">� </span>The key to obtaining a
  340. valid handle is to supply the proper filename for the device that is to be
  341. opened.<span style="mso-spacerun: yes">� </span>It is possible to obtain a
  342. handle to the device via either the SCSI port driver or the appropriate SCSI
  343. class driver, depending on whether the device was claimed (see the
  344. DeviceClaimed information returned from <a href="#_IOCTL_SCSI_GET_INQUIRY_DATA">IOCTL_SCSI_GET_INQUIRY_DATA</a>).<span
  345. style="mso-spacerun: yes">� </span><o:p></o:p></span></p>
  346. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  347. mso-fareast-font-family:"MS Mincho"'>If the device is claimed by a class
  348. driver, then you have to specify a filename that will route requests through
  349. the class driver.<span style="mso-spacerun: yes">� </span>In the case of fixed
  350. disks and optical storage devices, the filename is typically the corresponding
  351. drive letter.<span style="mso-spacerun: yes">� </span>&quot;\\.\I:&quot; can be
  352. used to obtain a handle to a CD-ROM drive that has been mapped to driver
  353. &quot;I:&quot;.<span style="mso-spacerun: yes">� </span>In the case of SCSI
  354. printers, the filename is &quot;LPTn&quot;, where n = 1, 2, etc.<span
  355. style="mso-spacerun: yes">� </span>For all remaining SCSI devices, the SCSI
  356. class driver defines the appropriate name.<span style="mso-spacerun: yes">�
  357. </span>Typically the name is related to the device (e.g. -
  358. &quot;\\.\Scanner0&quot;, &quot;\\.\Tape1&quot;).<span style="mso-spacerun:
  359. yes">� </span>Except for COMn and LPTn, all device filenames must be prepended
  360. with a \\.\ to inform the I/O Manager that this is a device and not a standard
  361. file name. <o:p></o:p></span></p>
  362. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  363. mso-fareast-font-family:"MS Mincho"'>If the device is unclaimed by a SCSI class
  364. driver, then a handle to the SCSI port driver is required.<span
  365. style="mso-spacerun: yes">� </span>The filename in this case is
  366. &quot;\\.\ScsiN:&quot;, where N = 0, 1, 2, etc.<span style="mso-spacerun:
  367. yes">� </span>The number N corresponds to the SCSI host adapter card number
  368. that controls the desired SCSI device.<span style="mso-spacerun: yes">�
  369. </span>When the SCSI port name is used, the Win32 application must set the
  370. proper PathId, TargetId, and Lun in the SCSI pass through structure.<span
  371. style="mso-spacerun: yes">� </span>Failure to set this SCSI address information
  372. will cause the SCSI request to fail (if directed to a target device claimed by
  373. a class driver) or possibly cause data corruption (if the unexpected target
  374. device processed the I/O request).<o:p></o:p></span></p>
  375. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  376. mso-fareast-font-family:"MS Mincho"'>If the device is claimed by a class driver
  377. but a handle to the SCSI port driver is used, the DeviceIoControl call will
  378. fail the IOCTL_SCSI_PASS_THROUGH and IOCTL_SCSI_PASS_THROUGH_DIRECT with
  379. ERROR_INVALID_PARAMETER (87L).<span style="mso-spacerun: yes">� </span>The
  380. Win32 API QueryDosDevice can be used to display the symbolic links between the
  381. Win32 device names and their corresponding kernel mode names.<span
  382. style="mso-spacerun: yes">� </span>If you are unsure of which device name to
  383. specify for CreateFile, one should be able to examine the output from
  384. QueryDosDevice to determine the correct name.<o:p></o:p></span></p>
  385. <p><b><u><span style='font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>Initializing
  386. the structures</span></u></b><span style='font-size:10.0pt;mso-bidi-font-size:
  387. 12.0pt;font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><o:p></o:p></span></p>
  388. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  389. mso-fareast-font-family:"MS Mincho"'>Once a valid handle is obtained to a SCSI
  390. device, then appropriate input and output buffers for the requested IOCTL must
  391. be allocated and, in some cases, filled in correctly.<span style="mso-spacerun:
  392. yes">� </span>This section describes general guidelines for setting up the
  393. parameters for the DeviceIoControl call.<span style="mso-spacerun: yes">�
  394. </span><o:p></o:p></span></p>
  395. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  396. mso-fareast-font-family:"MS Mincho"'>For IOCTL_SCSI_GET_INQUIRY_DATA, no data
  397. is sent to the device - data is only read from the device.<span
  398. style="mso-spacerun: yes">� </span>Set lpInBuffer to NULL and nInBufferSize to
  399. zero.<span style="mso-spacerun: yes">� </span>The output buffer might be quite
  400. large, as each SCSI device on the bus will provide data that will fill three
  401. structures for each device:<span style="mso-spacerun: yes">�
  402. </span>SCSI_ADAPTER_BUS_INFO, SCSI_BUS_DATA, and SCSI_INQUIRY_DATA.<span
  403. style="mso-spacerun: yes">� </span>Allocate a buffer that will hold the
  404. information for all the devices on that particular SCSI adapter.<span
  405. style="mso-spacerun: yes">� </span>Set lpOutBuffer to point to this allocated
  406. buffer and nOutBufferSize to the size of the allocated buffer.<o:p></o:p></span></p>
  407. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  408. mso-fareast-font-family:"MS Mincho"'>For IOCTL_SCSI_GET_CAPABILITIES, no data
  409. is sent to the device - data is only read from the device.<span
  410. style="mso-spacerun: yes">� </span>Set lpInBuffer to NULL and nInBufferSize to
  411. zero.<span style="mso-spacerun: yes">� </span>Set lpOutBuffer to a pointer to
  412. hold the IO_SCSI_CAPABILITIES structure, and nOutBufferSize to
  413. sizeof(IO_SCSI_CAPABILITIES).<span style="mso-spacerun: yes">� </span>A larger
  414. output buffer can be used, but the output buffer length must be set as
  415. described here.<o:p></o:p></span></p>
  416. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  417. mso-fareast-font-family:"MS Mincho"'>For the two SCSI pass through IOCTLs,
  418. IOCTL_SCSI_PASS_THROUGH and IOCTL_SCSI_PASS_THROUGH_DIRECT, both lpInBuffer and
  419. lpOutBuffer can vary in size depending on the Request Sense buffer size and the
  420. data buffer size.<span style="mso-spacerun: yes">� </span>In all cases,
  421. nInBufferSize and nOutBufferSize must be at least the size of the
  422. SCSI_PASS_THROUGH (or SCSI_PASS_THROUGH_DIRECT) structure.<span
  423. style="mso-spacerun: yes">� </span>If the SCSI port driver detects that one of
  424. the two buffers is too small, then the DeviceIoControl API will fail with
  425. ERROR_INVALID_PARAMETER.<span style="mso-spacerun: yes">� </span><o:p></o:p></span></p>
  426. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  427. mso-fareast-font-family:"MS Mincho"'>Once the appropriate input and output
  428. buffers have been allocated, then the appropriate structure must be
  429. initialized.<span style="mso-spacerun: yes">� </span>The SCSI_PASS_THROUGH
  430. structure is defined in NTDDSCSI.H as follows:<o:p></o:p></span></p>
  431. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  432. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  433. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>typedef struct
  434. _SCSI_PASS_THROUGH {<o:p></o:p></span></p>
  435. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  436. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  437. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><span
  438. style="mso-spacerun: yes">� </span><span style="mso-spacerun:
  439. yes">��</span>USHORT Length;<o:p></o:p></span></p>
  440. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  441. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  442. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><span
  443. style="mso-spacerun: yes">��� </span>UCHAR ScsiStatus;<o:p></o:p></span></p>
  444. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  445. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  446. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><span
  447. style="mso-spacerun: yes">��� </span>UCHAR PathId;<o:p></o:p></span></p>
  448. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  449. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  450. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><span
  451. style="mso-spacerun: yes">��� </span>UCHAR TargetId;<o:p></o:p></span></p>
  452. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  453. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  454. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><span
  455. style="mso-spacerun: yes">��� </span>UCHAR Lun;<o:p></o:p></span></p>
  456. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  457. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  458. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><span
  459. style="mso-spacerun: yes">��� </span>UCHAR CdbLength;<o:p></o:p></span></p>
  460. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  461. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  462. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><span
  463. style="mso-spacerun: yes">��� </span>UCHAR SenseInfoLength;<o:p></o:p></span></p>
  464. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  465. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  466. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><span
  467. style="mso-spacerun: yes">��� </span>UCHAR DataIn;<o:p></o:p></span></p>
  468. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  469. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  470. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><span
  471. style="mso-spacerun: yes">��� </span>ULONG DataTransferLength;<o:p></o:p></span></p>
  472. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  473. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  474. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><span
  475. style="mso-spacerun: yes">��� </span>ULONG TimeOutValue;<o:p></o:p></span></p>
  476. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  477. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  478. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><span
  479. style="mso-spacerun: yes">��� </span>ULONG DataBufferOffset;<o:p></o:p></span></p>
  480. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  481. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  482. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><span
  483. style="mso-spacerun: yes">��� </span>ULONG SenseInfoOffset;<o:p></o:p></span></p>
  484. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  485. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  486. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><span
  487. style="mso-spacerun: yes">��� </span>UCHAR Cdb[16];<o:p></o:p></span></p>
  488. <p style='margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;
  489. margin-bottom:.0001pt'><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  490. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>}SCSI_PASS_THROUGH,
  491. *PSCSI_PASS_THROUGH;<o:p></o:p></span></p>
  492. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  493. mso-fareast-font-family:"MS Mincho"'>The Length is the size of the
  494. SCSI_PASS_THROUGH structure.<span style="mso-spacerun: yes">� </span>The
  495. ScsiStatus should be initialized to 0.<span style="mso-spacerun: yes">�
  496. </span>The SCSI status of the requested SCSI operation is returned in this structure
  497. member.<span style="mso-spacerun: yes">� </span>The possible SCSI statuses are
  498. defined in SCSI.H and are of the form SCSISTAT_xxx. The PathId is the bus
  499. number for the SCSI host adapter that controls the SCSI device in question.<span
  500. style="mso-spacerun: yes">� </span>Typically, this value will be 0, but there
  501. are SCSI host adapters that have more than one SCSI bus on the adapter.<span
  502. style="mso-spacerun: yes">� </span>The TargetId and Lun are the SCSI ID number
  503. and logical unit number for the device.<span style="mso-spacerun: yes">�
  504. </span>If the handle was obtained for a claimed device, then the PathId,
  505. TargetId and Lun as defined in this structure will be ignored and the
  506. appropriate class driver will provide this SCSI address information.<span
  507. style="mso-spacerun: yes">� </span>If the handle was obtained for the SCSI port
  508. driver, then the PathId, TargetId and Lun must be correct for the device
  509. intended.<span style="mso-spacerun: yes">� </span><o:p></o:p></span></p>
  510. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  511. mso-fareast-font-family:"MS Mincho"'>The CdbLength is the length of the CDB.
  512. Typical values are 6, 10, and 12 up to the maximum of 16.<span
  513. style="mso-spacerun: yes">� </span>The SenseInfoLength is the length of the
  514. SenseInfo buffer.<span style="mso-spacerun: yes">� </span>DataIn has three
  515. possible values which are defined in NTDDSCSI.H;<span style="mso-spacerun:
  516. yes">� </span>SCSI_IOCTL_DATA_OUT, SCSI_IOCTL_DATA_IN and
  517. SCSI_IOCTL_DATA_UNSPECIFIED. <span style="mso-spacerun:
  518. yes">�</span>SCSI_IOCTL_DATA_UNSPECIFIED should be used only if the appropriate
  519. SCSI miniport driver supports its usage.<span style="mso-spacerun: yes">�
  520. </span>The DataTransferLength is the byte size of the data buffer.<span
  521. style="mso-spacerun: yes">� </span>The TimeOutValue is the length of time, in
  522. seconds, until a time-out error should occur.<span style="mso-spacerun: yes">�
  523. </span>This can range from 0 to a maximum of 30 minutes (108000 seconds).<span
  524. style="mso-spacerun: yes">� </span><o:p></o:p></span></p>
  525. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  526. mso-fareast-font-family:"MS Mincho"'>The DataBufferOffset is the offset of the
  527. data buffer from the beginning of the pass through structure.<span
  528. style="mso-spacerun: yes">� </span>For the SCSI_PASS_THROUGH_DIRECT structure,
  529. this value is not an offset, but rather is a pointer to a data buffer.<span
  530. style="mso-spacerun: yes">� </span>The SenseInfoOffset is similarly an offset
  531. to the SenseInfo buffer from the beginning of the pass through structure.
  532. Finally, the sixteen remaining bytes are for the CDB data.<span
  533. style="mso-spacerun: yes">� </span>The format of this data must conform to the
  534. SCSI-2 standard as defined by ANSI.<o:p></o:p></span></p>
  535. <p><b><u><span style='font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>Buffer
  536. Alignment</span></u></b><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  537. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><o:p></o:p></span></p>
  538. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  539. mso-fareast-font-family:"MS Mincho"'>The AlignmentMask member returned in the
  540. structure via the IOCTL_SCSI_GET_CAPABILITIES indicates the buffer alignment
  541. requirements of the SCSI adapter.<span style="mso-spacerun: yes">�
  542. </span>Buffer alignment is handled using two methods for assuring that buffers
  543. are aligned on the appropriate boundaries.<span style="mso-spacerun: yes">�
  544. </span><o:p></o:p></span></p>
  545. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  546. mso-fareast-font-family:"MS Mincho"'>The first method uses the compiler to
  547. align the buffer on the correct boundary.<span style="mso-spacerun: yes">�
  548. </span>The structure SCSI_PASS_THROUGH_WITH_BUFFERS contains a member, Filler
  549. that is of type ULONG.<span style="mso-spacerun: yes">� </span>The compiler
  550. aligns Filler on a ULONG (double word) boundary.<span style="mso-spacerun:
  551. yes">� </span>The structure member that follows Filler, ucSenseBuf, is also
  552. aligned on a double word boundary.<span style="mso-spacerun: yes">� </span>The
  553. ucSenseBuf array is of a size that is a multiple of a double word, and so this
  554. makes the last structure member, ucDataBuf, also begin on a double word
  555. boundary. <o:p></o:p></span></p>
  556. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  557. mso-fareast-font-family:"MS Mincho"'>A second method to ensure buffer alignment
  558. is demonstrated in the AllocateAlignedBuffer procedure.<span
  559. style="mso-spacerun: yes">� </span>This procedure depends on the fact that a
  560. buffer aligned on a certain boundary will have 0's in its least significant
  561. bits indicating the buffer alignment.<span style="mso-spacerun: yes">� </span>A
  562. buffer allocation request is made using the C runtime call (malloc) that is the
  563. size of the requested buffer plus the AlignmentMask value as returned by
  564. IOCTL_SCSI_GET_CAPABILITIES.<span style="mso-spacerun: yes">� </span>A pointer
  565. is manipulated so that it is pointing to the first possible address in the
  566. buffer that meets the alignment requirements.<o:p></o:p></span></p>
  567. <p><b><u><span style='font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>Direct
  568. versus Buffered<o:p></o:p></span></u></b></p>
  569. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  570. mso-fareast-font-family:"MS Mincho"'>Here's the big difference between
  571. IOCTL_SCSI_PASS_THROUGH versus IOCTL_SCSI_PASS_THROUGH_DIRECT: the SCSI data is
  572. transferred directly into the specified ucDataBuf for
  573. IOCTL_SCSI_PASS_THROUGH_DIRECT while the data will be buffered in an
  574. intermediate I/O manager allocated buffer for IOCTL_SCSI_PASS_THROUGH.<o:p></o:p></span></p>
  575. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  576. mso-fareast-font-family:"MS Mincho"'>The various IOCTLs that are demonstrated
  577. in this sample are defined by the SCSI port driver (see NTDDSCSI.H for
  578. details).<span style="mso-spacerun: yes">� </span>The memory buffering for
  579. these IOCTLs is METHOD_BUFFERED.<span style="mso-spacerun: yes">� </span>What
  580. this means is that the I/O manager examines the length lpInBuffer and the
  581. length of lpOutBuffer as defined by the DeviceIoControl parameters and
  582. allocates a contiguous buffer that is the size of the larger of the two
  583. buffers.<span style="mso-spacerun: yes">� </span>On entry to the I/O manager
  584. (i.e. the call to DeviceIoControl), the contents of the Win32 application's
  585. lpInBuffer is copied to the buffer that was allocated by the I/O manager.<span
  586. style="mso-spacerun: yes">� </span>The nInBufferSize controls the amount of
  587. data copied.<span style="mso-spacerun: yes">� </span>The I/O manager then calls
  588. the appropriate SCSI class driver's (or port driver's) DeviceIoControl routine
  589. passing it the new buffer.<span style="mso-spacerun: yes">� </span>On exit, the
  590. reverse process occurs and the data in the new buffer is copied back into the
  591. Win32 application's lpOutBuffer.<span style="mso-spacerun: yes">� </span>This
  592. behavior is not user configurable.<o:p></o:p></span></p>
  593. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  594. mso-fareast-font-family:"MS Mincho"'>When using IOCTL_SCSI_PASS_THROUGH, the
  595. SCSI data buffer (ucDataBuf) is part of lpInBuffer.<span style="mso-spacerun:
  596. yes">� </span>Therefore, the data in ucDataBuf is copied into the new buffer
  597. (allocated by the I/O manager) and presented to the SCSI port driver and the
  598. SCSI miniport driver.<span style="mso-spacerun: yes">� </span>On completion,
  599. the new buffer is copied back to the ucDataBuf.<o:p></o:p></span></p>
  600. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  601. mso-fareast-font-family:"MS Mincho"'>When using IOCTL_SCSI_PASS_THROUGH_DIRECT,
  602. the SCSI data buffer (ucDataBuf) is not part of lpInBuffer.<span
  603. style="mso-spacerun: yes">� </span>Recall that the SCSI_PASS_THROUGH_DIRECT has
  604. a PVOID DataBuffer member.<span style="mso-spacerun: yes">� </span>That is,
  605. DataBuffer is a pointer to the data buffer, and the data buffer does not have
  606. to be contiguous with the SCSI_PASS_THROUGH_DIRECT structure.<span
  607. style="mso-spacerun: yes">� </span>When the Win32 application calls
  608. DeviceIoControl, the lpInBuffer is copied into an I/O manager allocated buffer,
  609. and this new buffer is passed to the SCSI port driver.<span
  610. style="mso-spacerun: yes">� </span>In the SCSI port driver, the
  611. SCSI_PASS_THROUGH_DIRECT structure is examined, the pointer to the DataBuffer
  612. is retrieved from the structure, and the user's buffer is probed and locked for
  613. direct access.<span style="mso-spacerun: yes">� </span><o:p></o:p></span></p>
  614. <p><b><u><span style='font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>Running
  615. the SPTI.EXE sample</span></u></b><span style='font-size:10.0pt;mso-bidi-font-size:
  616. 12.0pt;font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><o:p></o:p></span></p>
  617. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  618. mso-fareast-font-family:"MS Mincho"'>Two command line parameters can be used
  619. with SPTI.EXE.<o:p></o:p></span></p>
  620. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  621. mso-fareast-font-family:"MS Mincho"'>The first parameter is mandatory.<span
  622. style="mso-spacerun: yes">� </span>It is the name of the device to be
  623. opened.<span style="mso-spacerun: yes">� </span>Typical values for this are
  624. drive letters such as &quot;C:&quot;, or device names as defined by a class
  625. driver such as Scanner0, or the SCSI port driver name, ScsiN:, where N = 0, 1,
  626. 2, etc.<span style="mso-spacerun: yes">� </span>See <a
  627. href="#_Obtaining_a_handle">Obtaining a handle for a device</a> for details on
  628. this first parameter.<o:p></o:p></span></p>
  629. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  630. mso-fareast-font-family:"MS Mincho"'>The second parameter is optional and is
  631. used to set the share mode (note that access mode and share mode are different
  632. things) and sector size.<span style="mso-spacerun: yes">� </span>The default
  633. share mode is (FILE_SHARE_READ | FILE_SHARE_WRITE) and the default sector size
  634. is 512.<span style="mso-spacerun: yes">� </span>A parameter of &quot;r&quot;
  635. changes the share mode to only FILE_SHARE_READ.<span style="mso-spacerun:
  636. yes">� </span>A parameter of &quot;w&quot; changes the share mode to only
  637. FILE_SHARE_WRITE.<span style="mso-spacerun: yes">� </span>A parameter of
  638. &quot;c&quot; changes the share mode to only FILE_SHARE_READ and also changes
  639. the sector size to 2048.<span style="mso-spacerun: yes">� </span>Typically, a
  640. CD-ROM device would use the &quot;c&quot; parameter.<span style="mso-spacerun:
  641. yes">� </span><o:p></o:p></span></p>
  642. <p><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;
  643. mso-fareast-font-family:"MS Mincho"'>The examples below assume that there is a
  644. system with a disk drive &quot;c:&quot;, CD-ROM &quot;d:&quot;, and an
  645. unclaimed SCSI device on the second SCSI adapter (scsi1:).<o:p></o:p></span></p>
  646. <p style='margin:0in;margin-bottom:.0001pt'><b><span style='font-size:10.0pt;
  647. mso-bidi-font-size:12.0pt;font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>spti
  648. c:</span></b><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
  649. font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><o:p></o:p></span></p>
  650. <p style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.0pt;
  651. mso-bidi-font-size:12.0pt;font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>To
  652. send SCSI commands to the disk drive. <o:p></o:p></span></p>
  653. <p style='margin-bottom:0in;margin-bottom:.0001pt'><b><span style='font-size:
  654. 10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;mso-fareast-font-family:
  655. "MS Mincho"'>spti d: c</span></b><span style='font-size:10.0pt;mso-bidi-font-size:
  656. 12.0pt;font-family:Verdana;mso-fareast-font-family:"MS Mincho"'><o:p></o:p></span></p>
  657. <p style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.0pt;
  658. mso-bidi-font-size:12.0pt;font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>To
  659. send SCSI commands to the CD-ROM device.<span style="mso-spacerun: yes">�
  660. </span>Remember that CD-ROM devices typically use 2048 sector size, so the
  661. &quot;c&quot; parameter should be used. <o:p></o:p></span></p>
  662. <p style='margin-bottom:0in;margin-bottom:.0001pt'><b><span style='font-size:
  663. 10.0pt;mso-bidi-font-size:12.0pt;font-family:Verdana;mso-fareast-font-family:
  664. "MS Mincho"'>spti scsi1:</span></b><span style='font-size:10.0pt;mso-bidi-font-size:
  665. 12.0pt;font-family:Verdana;mso-fareast-font-family:"MS Mincho"'> <o:p></o:p></span></p>
  666. <p style='margin-top:0in'><span style='font-size:10.0pt;mso-bidi-font-size:
  667. 12.0pt;font-family:Verdana;mso-fareast-font-family:"MS Mincho"'>To send SCSI
  668. commands to the unclaimed SCSI device.<span style="mso-spacerun: yes">�
  669. </span>Make sure that the SCSI pass through structure has the correct PathId, TargetId
  670. and Lun, filled in.<span style="mso-spacerun: yes">� </span>If the SCSI address
  671. information is incorrectly set, the request might fail or be directed towards
  672. the wrong device.<span style="mso-spacerun: yes">� </span><o:p></o:p></span></p>
  673. <p><b><u>BUILDING THE SAMPLE<o:p></o:p></u></b></p>
  674. <p><span style='font-size:10.0pt;font-family:Verdana'>Click the Free Build
  675. Environment or Checked Build Environment icon under your <b>Development Kits </b>program
  676. group to set basic environment variables needed by the build utility. <o:p></o:p></span></p>
  677. <p><span style='font-size:10.0pt;font-family:Verdana'>Change to the directory
  678. containing the device source code.<o:p></o:p></span></p>
  679. <p><span style='font-size:10.0pt;font-family:Verdana'>To build the sample, run <b>build
  680. -ceZ</b>, or use the macro <b>BLD</b>.<span style="mso-spacerun: yes">�
  681. </span>The &quot;e&quot; option produces a log file (buildXXX.log), a warning
  682. file (buildXXX.wrn), and an error file (buildXXX.err) where XXX means either <b>fre</b>
  683. or <b>chk, </b>depending on the environment chosen.<span style="mso-spacerun:
  684. yes">� </span>If there are no warnings, then the warning file will not be built
  685. and if there are no errors, there will be no error file built.<span
  686. style="mso-spacerun: yes">��� </span>If the build succeeds, the Win32
  687. application spti.exe will be placed in a subdirectory of either the objfre (for
  688. free build) or objchk (for checked build) directories. <o:p></o:p></span></p>
  689. No INF file is needed to install this application. <P>
  690. <h3><span style='font-family:Verdana'>CODE TOUR<o:p></o:p></span></h3>
  691. <h4><span style='font-family:Verdana'>File Manifest<o:p></o:p></span></h4>
  692. <pre><u><span style='mso-bidi-font-family:"Courier New"'>File<span
  693. style='mso-tab-count:2'>���������� </span>Description<o:p></o:p></span></u></pre><pre><span
  694. style='mso-bidi-font-family:"Courier New"'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
  695. style='mso-bidi-font-family:"Courier New"'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
  696. style='mso-bidi-font-family:"Courier New"'>spti.htm<span style='mso-tab-count:
  697. 1'>������ </span>The documentation for these samples (this file)<o:p></o:p></span></pre><pre><span
  698. style='mso-bidi-font-family:"Courier New"'>spti.c<span style="mso-spacerun: yes">�������� </span>Implements the Win32 application to communicate with the SCSI devices.<o:p></o:p></span></pre><pre><span
  699. style='mso-bidi-font-family:"Courier New"'>spti.h<span style="mso-spacerun: yes">�������� </span>Header file for spti.c<o:p></o:p></span></pre><pre><span
  700. style='mso-bidi-font-family:"Courier New"'>Sources<span style="mso-spacerun: yes">������� </span>DDK build instructions<o:p></o:p></span></pre>
  701. <p style='margin:0in;margin-bottom:.0001pt;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
  702. style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Courier New"'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
  703. <p style='margin:0in;margin-bottom:.0001pt;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
  704. style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Courier New"'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
  705. <p align=center style='margin:0in;margin-bottom:.0001pt;text-align:center;
  706. 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
  707. style='font-size:10.0pt;font-family:Verdana;mso-fareast-font-family:"Courier New";
  708. mso-bidi-font-family:"Courier New"'><a href="#_Communicating_with_SCSI">Top of
  709. page </a></span><span class=MsoHyperlink><span style='font-size:10.0pt;
  710. font-family:Verdana;mso-fareast-font-family:"Courier New";mso-bidi-font-family:
  711. "Courier New"'><o:p></o:p></span></span></p>
  712. <pre><span style='mso-bidi-font-family:"Courier New"'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre>
  713. <table border=0 cellspacing=0 cellpadding=0 width=624 style='width:6.5in;
  714. mso-cellspacing:0in;mso-padding-alt:0in 0in 0in 0in'>
  715. <tr style='height:1.5pt'>
  716. <td style='background:aqua;padding:.75pt .75pt .75pt .75pt;height:1.5pt'>
  717. <p class=MsoNormal>&nbsp;</p>
  718. </td>
  719. </tr>
  720. </table>
  721. <pre><span style='mso-bidi-font-family:"Courier New"'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
  722. style='mso-bidi-font-family:"Courier New"'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre>
  723. <p style='margin:0in;margin-bottom:.0001pt;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
  724. style='font-size:7.5pt;font-family:"MS Sans Serif";mso-fareast-font-family:
  725. "Courier New";mso-bidi-font-family:"Courier New"'>� 1999 Microsoft Corporation</span><span
  726. style='font-size:10.0pt;font-family:Verdana;mso-fareast-font-family:"Courier New";
  727. mso-bidi-font-family:"Courier New"'> <o:p></o:p></span></p>
  728. </div>
  729. </body>
  730. </html>