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.

5666 lines
134 KiB

  1. /*++ BUILD Version: 0013 // Increment this if a change has global effects
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. io.h
  5. Abstract:
  6. This module contains the internal structure definitions and APIs used by
  7. the NT I/O system.
  8. Author:
  9. Darryl E. Havens (darrylh) 12-Apr-1989
  10. Revision History:
  11. --*/
  12. #ifndef _IO_
  13. #define _IO_
  14. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntndis begin_ntosp
  15. //
  16. // Define I/O system data structure type codes. Each major data structure in
  17. // the I/O system has a type code The type field in each structure is at the
  18. // same offset. The following values can be used to determine which type of
  19. // data structure a pointer refers to.
  20. //
  21. #define IO_TYPE_ADAPTER 0x00000001
  22. #define IO_TYPE_CONTROLLER 0x00000002
  23. #define IO_TYPE_DEVICE 0x00000003
  24. #define IO_TYPE_DRIVER 0x00000004
  25. #define IO_TYPE_FILE 0x00000005
  26. #define IO_TYPE_IRP 0x00000006
  27. #define IO_TYPE_MASTER_ADAPTER 0x00000007
  28. #define IO_TYPE_OPEN_PACKET 0x00000008
  29. #define IO_TYPE_TIMER 0x00000009
  30. #define IO_TYPE_VPB 0x0000000a
  31. #define IO_TYPE_ERROR_LOG 0x0000000b
  32. #define IO_TYPE_ERROR_MESSAGE 0x0000000c
  33. #define IO_TYPE_DEVICE_OBJECT_EXTENSION 0x0000000d
  34. //
  35. // Define the major function codes for IRPs.
  36. //
  37. #define IRP_MJ_CREATE 0x00
  38. #define IRP_MJ_CREATE_NAMED_PIPE 0x01
  39. #define IRP_MJ_CLOSE 0x02
  40. #define IRP_MJ_READ 0x03
  41. #define IRP_MJ_WRITE 0x04
  42. #define IRP_MJ_QUERY_INFORMATION 0x05
  43. #define IRP_MJ_SET_INFORMATION 0x06
  44. #define IRP_MJ_QUERY_EA 0x07
  45. #define IRP_MJ_SET_EA 0x08
  46. #define IRP_MJ_FLUSH_BUFFERS 0x09
  47. #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
  48. #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
  49. #define IRP_MJ_DIRECTORY_CONTROL 0x0c
  50. #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
  51. #define IRP_MJ_DEVICE_CONTROL 0x0e
  52. #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
  53. #define IRP_MJ_SHUTDOWN 0x10
  54. #define IRP_MJ_LOCK_CONTROL 0x11
  55. #define IRP_MJ_CLEANUP 0x12
  56. #define IRP_MJ_CREATE_MAILSLOT 0x13
  57. #define IRP_MJ_QUERY_SECURITY 0x14
  58. #define IRP_MJ_SET_SECURITY 0x15
  59. #define IRP_MJ_POWER 0x16
  60. #define IRP_MJ_SYSTEM_CONTROL 0x17
  61. #define IRP_MJ_DEVICE_CHANGE 0x18
  62. #define IRP_MJ_QUERY_QUOTA 0x19
  63. #define IRP_MJ_SET_QUOTA 0x1a
  64. #define IRP_MJ_PNP 0x1b
  65. #define IRP_MJ_PNP_POWER IRP_MJ_PNP // Obsolete....
  66. #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
  67. //
  68. // Make the Scsi major code the same as internal device control.
  69. //
  70. #define IRP_MJ_SCSI IRP_MJ_INTERNAL_DEVICE_CONTROL
  71. //
  72. // Define the minor function codes for IRPs. The lower 128 codes, from 0x00 to
  73. // 0x7f are reserved to Microsoft. The upper 128 codes, from 0x80 to 0xff, are
  74. // reserved to customers of Microsoft.
  75. //
  76. // end_wdm end_ntndis
  77. //
  78. // Directory control minor function codes
  79. //
  80. #define IRP_MN_QUERY_DIRECTORY 0x01
  81. #define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
  82. //
  83. // File system control minor function codes. Note that "user request" is
  84. // assumed to be zero by both the I/O system and file systems. Do not change
  85. // this value.
  86. //
  87. #define IRP_MN_USER_FS_REQUEST 0x00
  88. #define IRP_MN_MOUNT_VOLUME 0x01
  89. #define IRP_MN_VERIFY_VOLUME 0x02
  90. #define IRP_MN_LOAD_FILE_SYSTEM 0x03
  91. #define IRP_MN_TRACK_LINK 0x04 // To be obsoleted soon
  92. #define IRP_MN_KERNEL_CALL 0x04
  93. //
  94. // Lock control minor function codes
  95. //
  96. #define IRP_MN_LOCK 0x01
  97. #define IRP_MN_UNLOCK_SINGLE 0x02
  98. #define IRP_MN_UNLOCK_ALL 0x03
  99. #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
  100. //
  101. // Read and Write minor function codes for file systems supporting Lan Manager
  102. // software. All of these subfunction codes are invalid if the file has been
  103. // opened with FO_NO_INTERMEDIATE_BUFFERING. They are also invalid in combi-
  104. // nation with synchronous calls (Irp Flag or file open option).
  105. //
  106. // Note that "normal" is assumed to be zero by both the I/O system and file
  107. // systems. Do not change this value.
  108. //
  109. #define IRP_MN_NORMAL 0x00
  110. #define IRP_MN_DPC 0x01
  111. #define IRP_MN_MDL 0x02
  112. #define IRP_MN_COMPLETE 0x04
  113. #define IRP_MN_COMPRESSED 0x08
  114. #define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC)
  115. #define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL)
  116. #define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
  117. // begin_wdm
  118. //
  119. // Device Control Request minor function codes for SCSI support. Note that
  120. // user requests are assumed to be zero.
  121. //
  122. #define IRP_MN_SCSI_CLASS 0x01
  123. //
  124. // PNP minor function codes.
  125. //
  126. #define IRP_MN_START_DEVICE 0x00
  127. #define IRP_MN_QUERY_REMOVE_DEVICE 0x01
  128. #define IRP_MN_REMOVE_DEVICE 0x02
  129. #define IRP_MN_CANCEL_REMOVE_DEVICE 0x03
  130. #define IRP_MN_STOP_DEVICE 0x04
  131. #define IRP_MN_QUERY_STOP_DEVICE 0x05
  132. #define IRP_MN_CANCEL_STOP_DEVICE 0x06
  133. #define IRP_MN_QUERY_DEVICE_RELATIONS 0x07
  134. #define IRP_MN_QUERY_INTERFACE 0x08
  135. #define IRP_MN_QUERY_CAPABILITIES 0x09
  136. #define IRP_MN_QUERY_RESOURCES 0x0A
  137. #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 0x0B
  138. #define IRP_MN_QUERY_DEVICE_TEXT 0x0C
  139. #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
  140. #define IRP_MN_READ_CONFIG 0x0F
  141. #define IRP_MN_WRITE_CONFIG 0x10
  142. #define IRP_MN_EJECT 0x11
  143. #define IRP_MN_SET_LOCK 0x12
  144. #define IRP_MN_QUERY_ID 0x13
  145. #define IRP_MN_QUERY_PNP_DEVICE_STATE 0x14
  146. #define IRP_MN_QUERY_BUS_INFORMATION 0x15
  147. #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16
  148. #define IRP_MN_SURPRISE_REMOVAL 0x17
  149. // end_wdm
  150. #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
  151. // begin_wdm
  152. //
  153. // POWER minor function codes
  154. //
  155. #define IRP_MN_WAIT_WAKE 0x00
  156. #define IRP_MN_POWER_SEQUENCE 0x01
  157. #define IRP_MN_SET_POWER 0x02
  158. #define IRP_MN_QUERY_POWER 0x03
  159. // begin_ntminiport
  160. //
  161. // WMI minor function codes under IRP_MJ_SYSTEM_CONTROL
  162. //
  163. #define IRP_MN_QUERY_ALL_DATA 0x00
  164. #define IRP_MN_QUERY_SINGLE_INSTANCE 0x01
  165. #define IRP_MN_CHANGE_SINGLE_INSTANCE 0x02
  166. #define IRP_MN_CHANGE_SINGLE_ITEM 0x03
  167. #define IRP_MN_ENABLE_EVENTS 0x04
  168. #define IRP_MN_DISABLE_EVENTS 0x05
  169. #define IRP_MN_ENABLE_COLLECTION 0x06
  170. #define IRP_MN_DISABLE_COLLECTION 0x07
  171. #define IRP_MN_REGINFO 0x08
  172. #define IRP_MN_EXECUTE_METHOD 0x09
  173. // Minor code 0x0a is reserved
  174. #define IRP_MN_REGINFO_EX 0x0b
  175. // end_ntminiport
  176. // end_wdm end_ntddk end_nthal end_ntifs end_ntosp
  177. // The following minor code is reserved as a private WMI minor function
  178. // For drivers who cannot include io.h, please see wmikm.h
  179. //
  180. // begin_wmikm
  181. #define IRP_MN_SET_TRACE_NOTIFY 0x0A
  182. // end_wmikm
  183. // begin_wdm begin_ntddk begin_nthal begin_ntifs begin_ntosp
  184. //
  185. // Define option flags for IoCreateFile. Note that these values must be
  186. // exactly the same as the SL_... flags for a create function. Note also
  187. // that there are flags that may be passed to IoCreateFile that are not
  188. // placed in the stack location for the create IRP. These flags start in
  189. // the next byte.
  190. //
  191. #define IO_FORCE_ACCESS_CHECK 0x0001
  192. // end_ntddk end_wdm end_nthal end_ntosp
  193. #define IO_OPEN_PAGING_FILE 0x0002
  194. #define IO_OPEN_TARGET_DIRECTORY 0x0004
  195. //
  196. // Flags not passed to driver
  197. //
  198. // begin_ntddk begin_wdm begin_ntosp
  199. #define IO_NO_PARAMETER_CHECKING 0x0100
  200. //
  201. // Define Information fields for whether or not a REPARSE or a REMOUNT has
  202. // occurred in the file system.
  203. //
  204. #define IO_REPARSE 0x0
  205. #define IO_REMOUNT 0x1
  206. // end_ntddk end_wdm
  207. #define IO_CHECK_CREATE_PARAMETERS 0x0200
  208. #define IO_ATTACH_DEVICE 0x0400
  209. // end_ntosp
  210. // begin_ntifs begin_ntosp
  211. //
  212. // This flag is only meaning full to IoCreateFileSpecifyDeviceObjectHint.
  213. // FileHandles created using IoCreateFileSpecifyDeviceObjectHint with this
  214. // flag set will bypass ShareAccess checks on this file.
  215. //
  216. #define IO_IGNORE_SHARE_ACCESS_CHECK 0x0800 // Ignores share access checks on opens.
  217. // end_ntifs end_ntosp
  218. // Define kernel-only, internal option flags
  219. //
  220. #define IO_ATTACH_DEVICE_API 0x80000000
  221. // end_ntifs
  222. //
  223. // Define the driver interfaces required to write memory dumps.
  224. //
  225. //
  226. // Define stall routine type for the dump driver.
  227. //
  228. // begin_ntosp
  229. typedef
  230. VOID
  231. (*PSTALL_ROUTINE) (
  232. IN ULONG Delay
  233. );
  234. //
  235. // Define the interfaces for the dump driver's routines.
  236. //
  237. typedef
  238. BOOLEAN
  239. (*PDUMP_DRIVER_OPEN) (
  240. IN LARGE_INTEGER PartitionOffset
  241. );
  242. typedef
  243. NTSTATUS
  244. (*PDUMP_DRIVER_WRITE) (
  245. IN PLARGE_INTEGER DiskByteOffset,
  246. IN PMDL Mdl
  247. );
  248. //
  249. // Actions accepted by DRIVER_WRITE_PENDING
  250. //
  251. #define IO_DUMP_WRITE_FULFILL 0 // fulfill IO request as if DRIVER_WAIT
  252. #define IO_DUMP_WRITE_START 1 // start new IO
  253. #define IO_DUMP_WRITE_RESUME 2 // resume pending IO
  254. #define IO_DUMP_WRITE_FINISH 3 // finish pending IO
  255. #define IO_DUMP_WRITE_INIT 4 // initialize locals
  256. // size of data used by WRITE_PENDING that should be preserved
  257. // between the calls
  258. #define IO_DUMP_WRITE_DATA_PAGES 2
  259. #define IO_DUMP_WRITE_DATA_SIZE (IO_DUMP_WRITE_DATA_PAGES << PAGE_SHIFT)
  260. typedef
  261. NTSTATUS
  262. (*PDUMP_DRIVER_WRITE_PENDING) (
  263. IN LONG Action,
  264. IN PLARGE_INTEGER DiskByteOffset,
  265. IN PMDL Mdl,
  266. IN PVOID LocalData
  267. );
  268. typedef
  269. VOID
  270. (*PDUMP_DRIVER_FINISH) (
  271. VOID
  272. );
  273. struct _ADAPTER_OBJECT;
  274. //
  275. // This is the information passed from the system to the disk dump driver
  276. // during the driver's initialization.
  277. //
  278. typedef struct _DUMP_INITIALIZATION_CONTEXT {
  279. ULONG Length;
  280. ULONG Reserved; // Was MBR Checksum. Should be zero now.
  281. PVOID MemoryBlock;
  282. PVOID CommonBuffer[2];
  283. PHYSICAL_ADDRESS PhysicalAddress[2];
  284. PSTALL_ROUTINE StallRoutine;
  285. PDUMP_DRIVER_OPEN OpenRoutine;
  286. PDUMP_DRIVER_WRITE WriteRoutine;
  287. PDUMP_DRIVER_FINISH FinishRoutine;
  288. struct _ADAPTER_OBJECT *AdapterObject;
  289. PVOID MappedRegisterBase;
  290. PVOID PortConfiguration;
  291. BOOLEAN CrashDump;
  292. ULONG MaximumTransferSize;
  293. ULONG CommonBufferSize;
  294. PVOID TargetAddress; //Opaque pointer to target address structure
  295. PDUMP_DRIVER_WRITE_PENDING WritePendingRoutine;
  296. ULONG PartitionStyle;
  297. union {
  298. struct {
  299. ULONG Signature;
  300. ULONG CheckSum;
  301. } Mbr;
  302. struct {
  303. GUID DiskId;
  304. } Gpt;
  305. } DiskInfo;
  306. } DUMP_INITIALIZATION_CONTEXT, *PDUMP_INITIALIZATION_CONTEXT;
  307. // begin_ntddk
  308. //
  309. // Define callout routine type for use in IoQueryDeviceDescription().
  310. //
  311. typedef NTSTATUS (*PIO_QUERY_DEVICE_ROUTINE)(
  312. IN PVOID Context,
  313. IN PUNICODE_STRING PathName,
  314. IN INTERFACE_TYPE BusType,
  315. IN ULONG BusNumber,
  316. IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
  317. IN CONFIGURATION_TYPE ControllerType,
  318. IN ULONG ControllerNumber,
  319. IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
  320. IN CONFIGURATION_TYPE PeripheralType,
  321. IN ULONG PeripheralNumber,
  322. IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation
  323. );
  324. // Defines the order of the information in the array of
  325. // PKEY_VALUE_FULL_INFORMATION.
  326. //
  327. typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
  328. IoQueryDeviceIdentifier = 0,
  329. IoQueryDeviceConfigurationData,
  330. IoQueryDeviceComponentInformation,
  331. IoQueryDeviceMaxData
  332. } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
  333. // begin_wdm begin_ntifs
  334. //
  335. // Define the objects that can be created by IoCreateFile.
  336. //
  337. typedef enum _CREATE_FILE_TYPE {
  338. CreateFileTypeNone,
  339. CreateFileTypeNamedPipe,
  340. CreateFileTypeMailslot
  341. } CREATE_FILE_TYPE;
  342. // end_ntddk end_wdm end_ntifs
  343. //
  344. // Define the named pipe create parameters structure used for internal calls
  345. // to IoCreateFile when a named pipe is being created. This structure allows
  346. // code invoking this routine to pass information specific to this function
  347. // when creating a named pipe.
  348. //
  349. typedef struct _NAMED_PIPE_CREATE_PARAMETERS {
  350. ULONG NamedPipeType;
  351. ULONG ReadMode;
  352. ULONG CompletionMode;
  353. ULONG MaximumInstances;
  354. ULONG InboundQuota;
  355. ULONG OutboundQuota;
  356. LARGE_INTEGER DefaultTimeout;
  357. BOOLEAN TimeoutSpecified;
  358. } NAMED_PIPE_CREATE_PARAMETERS, *PNAMED_PIPE_CREATE_PARAMETERS;
  359. // end_ntosp
  360. //
  361. // Define the mailslot create parameters structure used for internal calls
  362. // to IoCreateFile when a mailslot is being created. This structure allows
  363. // code invoking this routine to pass information specific to this function
  364. // when creating a mailslot.
  365. //
  366. typedef struct _MAILSLOT_CREATE_PARAMETERS {
  367. ULONG MailslotQuota;
  368. ULONG MaximumMessageSize;
  369. LARGE_INTEGER ReadTimeout;
  370. BOOLEAN TimeoutSpecified;
  371. } MAILSLOT_CREATE_PARAMETERS, *PMAILSLOT_CREATE_PARAMETERS;
  372. //
  373. // Define the dump driver stack context structure
  374. //
  375. typedef struct DUMP_STACK_IMAGE{
  376. LIST_ENTRY Link;
  377. PLDR_DATA_TABLE_ENTRY Image;
  378. PVOID ImageBase;
  379. ULONG SizeOfImage;
  380. } DUMP_STACK_IMAGE, *PDUMP_STACK_IMAGE;
  381. typedef struct _DUMP_STACK_CONTEXT {
  382. DUMP_INITIALIZATION_CONTEXT Init;
  383. LARGE_INTEGER PartitionOffset;
  384. PVOID DumpPointers;
  385. ULONG PointersLength;
  386. PWCHAR ModulePrefix;
  387. LIST_ENTRY DriverList;
  388. ANSI_STRING InitMsg;
  389. ANSI_STRING ProgMsg;
  390. ANSI_STRING DoneMsg;
  391. PVOID FileObject;
  392. enum _DEVICE_USAGE_NOTIFICATION_TYPE UsageType;
  393. } DUMP_STACK_CONTEXT, *PDUMP_STACK_CONTEXT;
  394. #define IO_DUMP_MAX_MDL_PAGES 8
  395. #define IO_DUMP_MEMORY_BLOCK_PAGES 8
  396. #define IO_DUMP_COMMON_BUFFER_SIZE 0x2000
  397. NTSTATUS
  398. IoGetDumpStack(
  399. IN PWCHAR ModulePrefix,
  400. OUT PDUMP_STACK_CONTEXT *DumpStack,
  401. IN enum _DEVICE_USAGE_NOTIFICATION_TYPE UsageType,
  402. IN ULONG IgnoreDeviceUsageFailure
  403. );
  404. NTSTATUS
  405. IoInitializeDumpStack(
  406. IN PDUMP_STACK_CONTEXT DumpStack,
  407. IN PUCHAR MessageBuffer OPTIONAL
  408. );
  409. typedef enum _CRASHDUMP_CONFIGURATION {
  410. CrashDumpDisable = 0,
  411. CrashDumpReconfigure
  412. } CRASHDUMP_CONFIGURATION;
  413. NTSTATUS
  414. IoConfigureCrashDump(
  415. CRASHDUMP_CONFIGURATION Config
  416. );
  417. BOOLEAN
  418. IoInitializeCrashDump(
  419. IN HANDLE Pagefile
  420. );
  421. VOID
  422. IoGetDumpHiberRanges (
  423. IN PVOID HiberContext,
  424. IN PDUMP_STACK_CONTEXT DumpStack
  425. );
  426. NTKERNELAPI
  427. BOOLEAN
  428. IoWriteCrashDump(
  429. IN ULONG BugCheckCode,
  430. IN ULONG_PTR BugCheckParameter1,
  431. IN ULONG_PTR BugCheckParameter2,
  432. IN ULONG_PTR BugCheckParameter3,
  433. IN ULONG_PTR BugCheckParameter4,
  434. IN PVOID ContextSave,
  435. IN PKTHREAD Thread,
  436. OUT PBOOLEAN Reboot
  437. );
  438. BOOLEAN
  439. IoIsTriageDumpEnabled(
  440. VOID
  441. );
  442. BOOLEAN
  443. IoAddTriageDumpDataBlock(
  444. IN PVOID Address,
  445. IN ULONG Length
  446. );
  447. VOID
  448. IoFreeDumpStack(
  449. IN PDUMP_STACK_CONTEXT DumpStack
  450. );
  451. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  452. //
  453. // Define the structures used by the I/O system
  454. //
  455. //
  456. // Define empty typedefs for the _IRP, _DEVICE_OBJECT, and _DRIVER_OBJECT
  457. // structures so they may be referenced by function types before they are
  458. // actually defined.
  459. //
  460. struct _DEVICE_DESCRIPTION;
  461. struct _DEVICE_OBJECT;
  462. struct _DMA_ADAPTER;
  463. struct _DRIVER_OBJECT;
  464. struct _DRIVE_LAYOUT_INFORMATION;
  465. struct _DISK_PARTITION;
  466. struct _FILE_OBJECT;
  467. struct _IRP;
  468. struct _SCSI_REQUEST_BLOCK;
  469. struct _SCATTER_GATHER_LIST;
  470. //
  471. // Define the I/O version of a DPC routine.
  472. //
  473. typedef
  474. VOID
  475. (*PIO_DPC_ROUTINE) (
  476. IN PKDPC Dpc,
  477. IN struct _DEVICE_OBJECT *DeviceObject,
  478. IN struct _IRP *Irp,
  479. IN PVOID Context
  480. );
  481. //
  482. // Define driver timer routine type.
  483. //
  484. typedef
  485. VOID
  486. (*PIO_TIMER_ROUTINE) (
  487. IN struct _DEVICE_OBJECT *DeviceObject,
  488. IN PVOID Context
  489. );
  490. //
  491. // Define driver initialization routine type.
  492. //
  493. typedef
  494. NTSTATUS
  495. (*PDRIVER_INITIALIZE) (
  496. IN struct _DRIVER_OBJECT *DriverObject,
  497. IN PUNICODE_STRING RegistryPath
  498. );
  499. // end_wdm
  500. //
  501. // Define driver reinitialization routine type.
  502. //
  503. typedef
  504. VOID
  505. (*PDRIVER_REINITIALIZE) (
  506. IN struct _DRIVER_OBJECT *DriverObject,
  507. IN PVOID Context,
  508. IN ULONG Count
  509. );
  510. // begin_wdm begin_ntndis
  511. //
  512. // Define driver cancel routine type.
  513. //
  514. typedef
  515. VOID
  516. (*PDRIVER_CANCEL) (
  517. IN struct _DEVICE_OBJECT *DeviceObject,
  518. IN struct _IRP *Irp
  519. );
  520. //
  521. // Define driver dispatch routine type.
  522. //
  523. typedef
  524. NTSTATUS
  525. (*PDRIVER_DISPATCH) (
  526. IN struct _DEVICE_OBJECT *DeviceObject,
  527. IN struct _IRP *Irp
  528. );
  529. //
  530. // Define driver start I/O routine type.
  531. //
  532. typedef
  533. VOID
  534. (*PDRIVER_STARTIO) (
  535. IN struct _DEVICE_OBJECT *DeviceObject,
  536. IN struct _IRP *Irp
  537. );
  538. //
  539. // Define driver unload routine type.
  540. //
  541. typedef
  542. VOID
  543. (*PDRIVER_UNLOAD) (
  544. IN struct _DRIVER_OBJECT *DriverObject
  545. );
  546. //
  547. // Define driver AddDevice routine type.
  548. //
  549. typedef
  550. NTSTATUS
  551. (*PDRIVER_ADD_DEVICE) (
  552. IN struct _DRIVER_OBJECT *DriverObject,
  553. IN struct _DEVICE_OBJECT *PhysicalDeviceObject
  554. );
  555. // end_ntddk end_wdm end_nthal end_ntndis end_ntosp
  556. //
  557. // Define driver FS notification change routine type.
  558. //
  559. typedef
  560. VOID
  561. (*PDRIVER_FS_NOTIFICATION) (
  562. IN struct _DEVICE_OBJECT *DeviceObject,
  563. IN BOOLEAN FsActive
  564. );
  565. // begin_ntddk begin_wdm begin_ntosp
  566. //
  567. // Define fast I/O procedure prototypes.
  568. //
  569. // Fast I/O read and write procedures.
  570. //
  571. typedef
  572. BOOLEAN
  573. (*PFAST_IO_CHECK_IF_POSSIBLE) (
  574. IN struct _FILE_OBJECT *FileObject,
  575. IN PLARGE_INTEGER FileOffset,
  576. IN ULONG Length,
  577. IN BOOLEAN Wait,
  578. IN ULONG LockKey,
  579. IN BOOLEAN CheckForReadOperation,
  580. OUT PIO_STATUS_BLOCK IoStatus,
  581. IN struct _DEVICE_OBJECT *DeviceObject
  582. );
  583. typedef
  584. BOOLEAN
  585. (*PFAST_IO_READ) (
  586. IN struct _FILE_OBJECT *FileObject,
  587. IN PLARGE_INTEGER FileOffset,
  588. IN ULONG Length,
  589. IN BOOLEAN Wait,
  590. IN ULONG LockKey,
  591. OUT PVOID Buffer,
  592. OUT PIO_STATUS_BLOCK IoStatus,
  593. IN struct _DEVICE_OBJECT *DeviceObject
  594. );
  595. typedef
  596. BOOLEAN
  597. (*PFAST_IO_WRITE) (
  598. IN struct _FILE_OBJECT *FileObject,
  599. IN PLARGE_INTEGER FileOffset,
  600. IN ULONG Length,
  601. IN BOOLEAN Wait,
  602. IN ULONG LockKey,
  603. IN PVOID Buffer,
  604. OUT PIO_STATUS_BLOCK IoStatus,
  605. IN struct _DEVICE_OBJECT *DeviceObject
  606. );
  607. //
  608. // Fast I/O query basic and standard information procedures.
  609. //
  610. typedef
  611. BOOLEAN
  612. (*PFAST_IO_QUERY_BASIC_INFO) (
  613. IN struct _FILE_OBJECT *FileObject,
  614. IN BOOLEAN Wait,
  615. OUT PFILE_BASIC_INFORMATION Buffer,
  616. OUT PIO_STATUS_BLOCK IoStatus,
  617. IN struct _DEVICE_OBJECT *DeviceObject
  618. );
  619. typedef
  620. BOOLEAN
  621. (*PFAST_IO_QUERY_STANDARD_INFO) (
  622. IN struct _FILE_OBJECT *FileObject,
  623. IN BOOLEAN Wait,
  624. OUT PFILE_STANDARD_INFORMATION Buffer,
  625. OUT PIO_STATUS_BLOCK IoStatus,
  626. IN struct _DEVICE_OBJECT *DeviceObject
  627. );
  628. //
  629. // Fast I/O lock and unlock procedures.
  630. //
  631. typedef
  632. BOOLEAN
  633. (*PFAST_IO_LOCK) (
  634. IN struct _FILE_OBJECT *FileObject,
  635. IN PLARGE_INTEGER FileOffset,
  636. IN PLARGE_INTEGER Length,
  637. PEPROCESS ProcessId,
  638. ULONG Key,
  639. BOOLEAN FailImmediately,
  640. BOOLEAN ExclusiveLock,
  641. OUT PIO_STATUS_BLOCK IoStatus,
  642. IN struct _DEVICE_OBJECT *DeviceObject
  643. );
  644. typedef
  645. BOOLEAN
  646. (*PFAST_IO_UNLOCK_SINGLE) (
  647. IN struct _FILE_OBJECT *FileObject,
  648. IN PLARGE_INTEGER FileOffset,
  649. IN PLARGE_INTEGER Length,
  650. PEPROCESS ProcessId,
  651. ULONG Key,
  652. OUT PIO_STATUS_BLOCK IoStatus,
  653. IN struct _DEVICE_OBJECT *DeviceObject
  654. );
  655. typedef
  656. BOOLEAN
  657. (*PFAST_IO_UNLOCK_ALL) (
  658. IN struct _FILE_OBJECT *FileObject,
  659. PEPROCESS ProcessId,
  660. OUT PIO_STATUS_BLOCK IoStatus,
  661. IN struct _DEVICE_OBJECT *DeviceObject
  662. );
  663. typedef
  664. BOOLEAN
  665. (*PFAST_IO_UNLOCK_ALL_BY_KEY) (
  666. IN struct _FILE_OBJECT *FileObject,
  667. PVOID ProcessId,
  668. ULONG Key,
  669. OUT PIO_STATUS_BLOCK IoStatus,
  670. IN struct _DEVICE_OBJECT *DeviceObject
  671. );
  672. //
  673. // Fast I/O device control procedure.
  674. //
  675. typedef
  676. BOOLEAN
  677. (*PFAST_IO_DEVICE_CONTROL) (
  678. IN struct _FILE_OBJECT *FileObject,
  679. IN BOOLEAN Wait,
  680. IN PVOID InputBuffer OPTIONAL,
  681. IN ULONG InputBufferLength,
  682. OUT PVOID OutputBuffer OPTIONAL,
  683. IN ULONG OutputBufferLength,
  684. IN ULONG IoControlCode,
  685. OUT PIO_STATUS_BLOCK IoStatus,
  686. IN struct _DEVICE_OBJECT *DeviceObject
  687. );
  688. //
  689. // Define callbacks for NtCreateSection to synchronize correctly with
  690. // the file system. It pre-acquires the resources that will be needed
  691. // when calling to query and set file/allocation size in the file system.
  692. //
  693. typedef
  694. VOID
  695. (*PFAST_IO_ACQUIRE_FILE) (
  696. IN struct _FILE_OBJECT *FileObject
  697. );
  698. typedef
  699. VOID
  700. (*PFAST_IO_RELEASE_FILE) (
  701. IN struct _FILE_OBJECT *FileObject
  702. );
  703. //
  704. // Define callback for drivers that have device objects attached to lower-
  705. // level drivers' device objects. This callback is made when the lower-level
  706. // driver is deleting its device object.
  707. //
  708. typedef
  709. VOID
  710. (*PFAST_IO_DETACH_DEVICE) (
  711. IN struct _DEVICE_OBJECT *SourceDevice,
  712. IN struct _DEVICE_OBJECT *TargetDevice
  713. );
  714. //
  715. // This structure is used by the server to quickly get the information needed
  716. // to service a server open call. It is takes what would be two fast io calls
  717. // one for basic information and the other for standard information and makes
  718. // it into one call.
  719. //
  720. typedef
  721. BOOLEAN
  722. (*PFAST_IO_QUERY_NETWORK_OPEN_INFO) (
  723. IN struct _FILE_OBJECT *FileObject,
  724. IN BOOLEAN Wait,
  725. OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer,
  726. OUT struct _IO_STATUS_BLOCK *IoStatus,
  727. IN struct _DEVICE_OBJECT *DeviceObject
  728. );
  729. //
  730. // Define Mdl-based routines for the server to call
  731. //
  732. typedef
  733. BOOLEAN
  734. (*PFAST_IO_MDL_READ) (
  735. IN struct _FILE_OBJECT *FileObject,
  736. IN PLARGE_INTEGER FileOffset,
  737. IN ULONG Length,
  738. IN ULONG LockKey,
  739. OUT PMDL *MdlChain,
  740. OUT PIO_STATUS_BLOCK IoStatus,
  741. IN struct _DEVICE_OBJECT *DeviceObject
  742. );
  743. typedef
  744. BOOLEAN
  745. (*PFAST_IO_MDL_READ_COMPLETE) (
  746. IN struct _FILE_OBJECT *FileObject,
  747. IN PMDL MdlChain,
  748. IN struct _DEVICE_OBJECT *DeviceObject
  749. );
  750. typedef
  751. BOOLEAN
  752. (*PFAST_IO_PREPARE_MDL_WRITE) (
  753. IN struct _FILE_OBJECT *FileObject,
  754. IN PLARGE_INTEGER FileOffset,
  755. IN ULONG Length,
  756. IN ULONG LockKey,
  757. OUT PMDL *MdlChain,
  758. OUT PIO_STATUS_BLOCK IoStatus,
  759. IN struct _DEVICE_OBJECT *DeviceObject
  760. );
  761. typedef
  762. BOOLEAN
  763. (*PFAST_IO_MDL_WRITE_COMPLETE) (
  764. IN struct _FILE_OBJECT *FileObject,
  765. IN PLARGE_INTEGER FileOffset,
  766. IN PMDL MdlChain,
  767. IN struct _DEVICE_OBJECT *DeviceObject
  768. );
  769. //
  770. // If this routine is present, it will be called by FsRtl
  771. // to acquire the file for the mapped page writer.
  772. //
  773. typedef
  774. NTSTATUS
  775. (*PFAST_IO_ACQUIRE_FOR_MOD_WRITE) (
  776. IN struct _FILE_OBJECT *FileObject,
  777. IN PLARGE_INTEGER EndingOffset,
  778. OUT struct _ERESOURCE **ResourceToRelease,
  779. IN struct _DEVICE_OBJECT *DeviceObject
  780. );
  781. typedef
  782. NTSTATUS
  783. (*PFAST_IO_RELEASE_FOR_MOD_WRITE) (
  784. IN struct _FILE_OBJECT *FileObject,
  785. IN struct _ERESOURCE *ResourceToRelease,
  786. IN struct _DEVICE_OBJECT *DeviceObject
  787. );
  788. //
  789. // If this routine is present, it will be called by FsRtl
  790. // to acquire the file for the mapped page writer.
  791. //
  792. typedef
  793. NTSTATUS
  794. (*PFAST_IO_ACQUIRE_FOR_CCFLUSH) (
  795. IN struct _FILE_OBJECT *FileObject,
  796. IN struct _DEVICE_OBJECT *DeviceObject
  797. );
  798. typedef
  799. NTSTATUS
  800. (*PFAST_IO_RELEASE_FOR_CCFLUSH) (
  801. IN struct _FILE_OBJECT *FileObject,
  802. IN struct _DEVICE_OBJECT *DeviceObject
  803. );
  804. typedef
  805. BOOLEAN
  806. (*PFAST_IO_READ_COMPRESSED) (
  807. IN struct _FILE_OBJECT *FileObject,
  808. IN PLARGE_INTEGER FileOffset,
  809. IN ULONG Length,
  810. IN ULONG LockKey,
  811. OUT PVOID Buffer,
  812. OUT PMDL *MdlChain,
  813. OUT PIO_STATUS_BLOCK IoStatus,
  814. OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
  815. IN ULONG CompressedDataInfoLength,
  816. IN struct _DEVICE_OBJECT *DeviceObject
  817. );
  818. typedef
  819. BOOLEAN
  820. (*PFAST_IO_WRITE_COMPRESSED) (
  821. IN struct _FILE_OBJECT *FileObject,
  822. IN PLARGE_INTEGER FileOffset,
  823. IN ULONG Length,
  824. IN ULONG LockKey,
  825. IN PVOID Buffer,
  826. OUT PMDL *MdlChain,
  827. OUT PIO_STATUS_BLOCK IoStatus,
  828. IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
  829. IN ULONG CompressedDataInfoLength,
  830. IN struct _DEVICE_OBJECT *DeviceObject
  831. );
  832. typedef
  833. BOOLEAN
  834. (*PFAST_IO_MDL_READ_COMPLETE_COMPRESSED) (
  835. IN struct _FILE_OBJECT *FileObject,
  836. IN PMDL MdlChain,
  837. IN struct _DEVICE_OBJECT *DeviceObject
  838. );
  839. typedef
  840. BOOLEAN
  841. (*PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED) (
  842. IN struct _FILE_OBJECT *FileObject,
  843. IN PLARGE_INTEGER FileOffset,
  844. IN PMDL MdlChain,
  845. IN struct _DEVICE_OBJECT *DeviceObject
  846. );
  847. typedef
  848. BOOLEAN
  849. (*PFAST_IO_QUERY_OPEN) (
  850. IN struct _IRP *Irp,
  851. OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
  852. IN struct _DEVICE_OBJECT *DeviceObject
  853. );
  854. //
  855. // Define the structure to describe the Fast I/O dispatch routines. Any
  856. // additions made to this structure MUST be added monotonically to the end
  857. // of the structure, and fields CANNOT be removed from the middle.
  858. //
  859. typedef struct _FAST_IO_DISPATCH {
  860. ULONG SizeOfFastIoDispatch;
  861. PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible;
  862. PFAST_IO_READ FastIoRead;
  863. PFAST_IO_WRITE FastIoWrite;
  864. PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo;
  865. PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo;
  866. PFAST_IO_LOCK FastIoLock;
  867. PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle;
  868. PFAST_IO_UNLOCK_ALL FastIoUnlockAll;
  869. PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey;
  870. PFAST_IO_DEVICE_CONTROL FastIoDeviceControl;
  871. PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection;
  872. PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection;
  873. PFAST_IO_DETACH_DEVICE FastIoDetachDevice;
  874. PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo;
  875. PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite;
  876. PFAST_IO_MDL_READ MdlRead;
  877. PFAST_IO_MDL_READ_COMPLETE MdlReadComplete;
  878. PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite;
  879. PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete;
  880. PFAST_IO_READ_COMPRESSED FastIoReadCompressed;
  881. PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed;
  882. PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed;
  883. PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed;
  884. PFAST_IO_QUERY_OPEN FastIoQueryOpen;
  885. PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite;
  886. PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush;
  887. PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush;
  888. } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
  889. // end_ntddk end_wdm end_ntosp
  890. //
  891. // Valid values for FS_FILTER_PARAMETERS.AcquireForSectionSynchronization.SyncType
  892. //
  893. typedef enum _FS_FILTER_SECTION_SYNC_TYPE {
  894. SyncTypeOther = 0,
  895. SyncTypeCreateSection
  896. } FS_FILTER_SECTION_SYNC_TYPE, *PFS_FILTER_SECTION_SYNC_TYPE;
  897. //
  898. // Parameters union for the operations that
  899. // are exposed to the filters through the
  900. // FsFilterCallbacks registration mechanism.
  901. //
  902. typedef union _FS_FILTER_PARAMETERS {
  903. //
  904. // AcquireForModifiedPageWriter
  905. //
  906. struct {
  907. PLARGE_INTEGER EndingOffset;
  908. } AcquireForModifiedPageWriter;
  909. //
  910. // ReleaseForModifiedPageWriter
  911. //
  912. struct {
  913. PERESOURCE ResourceToRelease;
  914. } ReleaseForModifiedPageWriter;
  915. //
  916. // AcquireForSectionSynchronization
  917. //
  918. struct {
  919. FS_FILTER_SECTION_SYNC_TYPE SyncType;
  920. ULONG PageProtection;
  921. } AcquireForSectionSynchronization;
  922. //
  923. // Other
  924. //
  925. struct {
  926. PVOID Argument1;
  927. PVOID Argument2;
  928. PVOID Argument3;
  929. PVOID Argument4;
  930. PVOID Argument5;
  931. } Others;
  932. } FS_FILTER_PARAMETERS, *PFS_FILTER_PARAMETERS;
  933. //
  934. // These are the valid values for the Operation field
  935. // of the FS_FILTER_CALLBACK_DATA structure.
  936. //
  937. #define FS_FILTER_ACQUIRE_FOR_SECTION_SYNCHRONIZATION (UCHAR)-1
  938. #define FS_FILTER_RELEASE_FOR_SECTION_SYNCHRONIZATION (UCHAR)-2
  939. #define FS_FILTER_ACQUIRE_FOR_MOD_WRITE (UCHAR)-3
  940. #define FS_FILTER_RELEASE_FOR_MOD_WRITE (UCHAR)-4
  941. #define FS_FILTER_ACQUIRE_FOR_CC_FLUSH (UCHAR)-5
  942. #define FS_FILTER_RELEASE_FOR_CC_FLUSH (UCHAR)-6
  943. typedef struct _FS_FILTER_CALLBACK_DATA {
  944. ULONG SizeOfFsFilterCallbackData;
  945. UCHAR Operation;
  946. UCHAR Reserved;
  947. struct _DEVICE_OBJECT *DeviceObject;
  948. struct _FILE_OBJECT *FileObject;
  949. FS_FILTER_PARAMETERS Parameters;
  950. } FS_FILTER_CALLBACK_DATA, *PFS_FILTER_CALLBACK_DATA;
  951. //
  952. // Prototype for the callbacks received before an operation
  953. // is passed to the base file system.
  954. //
  955. // A filter can fail this operation, but consistant failure
  956. // will halt system progress.
  957. //
  958. typedef
  959. NTSTATUS
  960. (*PFS_FILTER_CALLBACK) (
  961. IN PFS_FILTER_CALLBACK_DATA Data,
  962. OUT PVOID *CompletionContext
  963. );
  964. //
  965. // Prototype for the completion callback received after an
  966. // operation is completed.
  967. //
  968. typedef
  969. VOID
  970. (*PFS_FILTER_COMPLETION_CALLBACK) (
  971. IN PFS_FILTER_CALLBACK_DATA Data,
  972. IN NTSTATUS OperationStatus,
  973. IN PVOID CompletionContext
  974. );
  975. //
  976. // This is the structure that the file system filter fills in to
  977. // receive notifications for these locking operations.
  978. //
  979. // A filter should set the field to NULL for any notification callback
  980. // it doesn't wish to receive.
  981. //
  982. typedef struct _FS_FILTER_CALLBACKS {
  983. ULONG SizeOfFsFilterCallbacks;
  984. ULONG Reserved; // For alignment
  985. PFS_FILTER_CALLBACK PreAcquireForSectionSynchronization;
  986. PFS_FILTER_COMPLETION_CALLBACK PostAcquireForSectionSynchronization;
  987. PFS_FILTER_CALLBACK PreReleaseForSectionSynchronization;
  988. PFS_FILTER_COMPLETION_CALLBACK PostReleaseForSectionSynchronization;
  989. PFS_FILTER_CALLBACK PreAcquireForCcFlush;
  990. PFS_FILTER_COMPLETION_CALLBACK PostAcquireForCcFlush;
  991. PFS_FILTER_CALLBACK PreReleaseForCcFlush;
  992. PFS_FILTER_COMPLETION_CALLBACK PostReleaseForCcFlush;
  993. PFS_FILTER_CALLBACK PreAcquireForModifiedPageWriter;
  994. PFS_FILTER_COMPLETION_CALLBACK PostAcquireForModifiedPageWriter;
  995. PFS_FILTER_CALLBACK PreReleaseForModifiedPageWriter;
  996. PFS_FILTER_COMPLETION_CALLBACK PostReleaseForModifiedPageWriter;
  997. } FS_FILTER_CALLBACKS, *PFS_FILTER_CALLBACKS;
  998. NTKERNELAPI
  999. NTSTATUS
  1000. FsRtlRegisterFileSystemFilterCallbacks (
  1001. IN struct _DRIVER_OBJECT *FilterDriverObject,
  1002. IN PFS_FILTER_CALLBACKS Callbacks
  1003. );
  1004. // begin_ntddk begin_wdm begin_nthal begin_ntosp
  1005. //
  1006. // Define the actions that a driver execution routine may request of the
  1007. // adapter/controller allocation routines upon return.
  1008. //
  1009. typedef enum _IO_ALLOCATION_ACTION {
  1010. KeepObject = 1,
  1011. DeallocateObject,
  1012. DeallocateObjectKeepRegisters
  1013. } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION;
  1014. //
  1015. // Define device driver adapter/controller execution routine.
  1016. //
  1017. typedef
  1018. IO_ALLOCATION_ACTION
  1019. (*PDRIVER_CONTROL) (
  1020. IN struct _DEVICE_OBJECT *DeviceObject,
  1021. IN struct _IRP *Irp,
  1022. IN PVOID MapRegisterBase,
  1023. IN PVOID Context
  1024. );
  1025. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  1026. //
  1027. // Define the I/O system's structure for a connected interrupt. This is
  1028. // useful for connecting an ISR to several different processors.
  1029. //
  1030. typedef struct _IO_INTERRUPT_STRUCTURE {
  1031. KINTERRUPT InterruptObject;
  1032. PKINTERRUPT InterruptArray[MAXIMUM_PROCESSORS];
  1033. KSPIN_LOCK SpinLock;
  1034. } IO_INTERRUPT_STRUCTURE, *PIO_INTERRUPT_STRUCTURE;
  1035. // begin_ntddk begin_wdm begin_ntifs begin_ntosp
  1036. //
  1037. // Define the I/O system's security context type for use by file system's
  1038. // when checking access to volumes, files, and directories.
  1039. //
  1040. typedef struct _IO_SECURITY_CONTEXT {
  1041. PSECURITY_QUALITY_OF_SERVICE SecurityQos;
  1042. PACCESS_STATE AccessState;
  1043. ACCESS_MASK DesiredAccess;
  1044. ULONG FullCreateOptions;
  1045. } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
  1046. // end_ntddk end_wdm end_ntifs end_ntosp
  1047. //
  1048. // Define the I/O system's version of a timer.
  1049. //
  1050. typedef struct _IO_TIMER {
  1051. CSHORT Type;
  1052. CSHORT TimerFlag;
  1053. LIST_ENTRY TimerList;
  1054. PIO_TIMER_ROUTINE TimerRoutine;
  1055. PVOID Context;
  1056. struct _DEVICE_OBJECT *DeviceObject;
  1057. } IO_TIMER, *PIO_TIMER;
  1058. //
  1059. // Define the client driver object extension header.
  1060. //
  1061. typedef struct _IO_CLIENT_EXTENSION {
  1062. struct _IO_CLIENT_EXTENSION *NextExtension;
  1063. PVOID ClientIdentificationAddress;
  1064. } IO_CLIENT_EXTENSION, *PIO_CLIENT_EXTENSION;
  1065. // begin_ntddk begin_nthal begin_ntifs begin_ntosp
  1066. //
  1067. // Define Volume Parameter Block (VPB) flags.
  1068. //
  1069. #define VPB_MOUNTED 0x00000001
  1070. #define VPB_LOCKED 0x00000002
  1071. #define VPB_PERSISTENT 0x00000004
  1072. #define VPB_REMOVE_PENDING 0x00000008
  1073. #define VPB_RAW_MOUNT 0x00000010
  1074. //
  1075. // Volume Parameter Block (VPB)
  1076. //
  1077. #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR)) // 32 characters
  1078. typedef struct _VPB {
  1079. CSHORT Type;
  1080. CSHORT Size;
  1081. USHORT Flags;
  1082. USHORT VolumeLabelLength; // in bytes
  1083. struct _DEVICE_OBJECT *DeviceObject;
  1084. struct _DEVICE_OBJECT *RealDevice;
  1085. ULONG SerialNumber;
  1086. ULONG ReferenceCount;
  1087. WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
  1088. } VPB, *PVPB;
  1089. #if defined(_WIN64)
  1090. //
  1091. // Use __inline DMA macros (hal.h)
  1092. //
  1093. #ifndef USE_DMA_MACROS
  1094. #define USE_DMA_MACROS
  1095. #endif
  1096. //
  1097. // Only PnP drivers!
  1098. //
  1099. #ifndef NO_LEGACY_DRIVERS
  1100. #define NO_LEGACY_DRIVERS
  1101. #endif
  1102. #endif // _WIN64
  1103. #if defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_) || defined(_NTOSP_))
  1104. // begin_wdm
  1105. //
  1106. // Define object type specific fields of various objects used by the I/O system
  1107. //
  1108. typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
  1109. // end_wdm
  1110. #else
  1111. //
  1112. // Define object type specific fields of various objects used by the I/O system
  1113. //
  1114. typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; // ntndis
  1115. #endif // USE_DMA_MACROS && (_NTDDK_ || _NTDRIVER_ || _NTOSP_)
  1116. // begin_wdm
  1117. //
  1118. // Define Wait Context Block (WCB)
  1119. //
  1120. typedef struct _WAIT_CONTEXT_BLOCK {
  1121. KDEVICE_QUEUE_ENTRY WaitQueueEntry;
  1122. PDRIVER_CONTROL DeviceRoutine;
  1123. PVOID DeviceContext;
  1124. ULONG NumberOfMapRegisters;
  1125. PVOID DeviceObject;
  1126. PVOID CurrentIrp;
  1127. PKDPC BufferChainingDpc;
  1128. } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
  1129. // end_wdm
  1130. typedef struct _CONTROLLER_OBJECT {
  1131. CSHORT Type;
  1132. CSHORT Size;
  1133. PVOID ControllerExtension;
  1134. KDEVICE_QUEUE DeviceWaitQueue;
  1135. ULONG Spare1;
  1136. LARGE_INTEGER Spare2;
  1137. } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
  1138. // begin_wdm
  1139. //
  1140. // Define Device Object (DO) flags
  1141. //
  1142. // end_wdm end_ntddk end_nthal end_ntifs
  1143. #define DO_VERIFY_VOLUME 0x00000002 // ntddk nthal ntifs
  1144. #define DO_BUFFERED_IO 0x00000004 // ntddk nthal ntifs wdm
  1145. #define DO_EXCLUSIVE 0x00000008 // ntddk nthal ntifs wdm
  1146. #define DO_DIRECT_IO 0x00000010 // ntddk nthal ntifs wdm
  1147. #define DO_MAP_IO_BUFFER 0x00000020 // ntddk nthal ntifs wdm
  1148. #define DO_DEVICE_HAS_NAME 0x00000040 // ntddk nthal ntifs
  1149. #define DO_DEVICE_INITIALIZING 0x00000080 // ntddk nthal ntifs wdm
  1150. #define DO_SYSTEM_BOOT_PARTITION 0x00000100 // ntddk nthal ntifs
  1151. #define DO_LONG_TERM_REQUESTS 0x00000200 // ntddk nthal ntifs
  1152. #define DO_NEVER_LAST_DEVICE 0x00000400 // ntddk nthal ntifs
  1153. #define DO_SHUTDOWN_REGISTERED 0x00000800 // ntddk nthal ntifs wdm
  1154. #define DO_BUS_ENUMERATED_DEVICE 0x00001000 // ntddk nthal ntifs wdm
  1155. #define DO_POWER_PAGABLE 0x00002000 // ntddk nthal ntifs wdm
  1156. #define DO_POWER_INRUSH 0x00004000 // ntddk nthal ntifs wdm
  1157. #define DO_POWER_NOOP 0x00008000
  1158. #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 // ntddk nthal ntifs
  1159. #define DO_XIP 0x00020000
  1160. // begin_wdm begin_ntddk begin_nthal begin_ntifs
  1161. //
  1162. // Device Object structure definition
  1163. //
  1164. typedef struct DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) _DEVICE_OBJECT {
  1165. CSHORT Type;
  1166. USHORT Size;
  1167. LONG ReferenceCount;
  1168. struct _DRIVER_OBJECT *DriverObject;
  1169. struct _DEVICE_OBJECT *NextDevice;
  1170. struct _DEVICE_OBJECT *AttachedDevice;
  1171. struct _IRP *CurrentIrp;
  1172. PIO_TIMER Timer;
  1173. ULONG Flags; // See above: DO_...
  1174. ULONG Characteristics; // See ntioapi: FILE_...
  1175. PVPB Vpb;
  1176. PVOID DeviceExtension;
  1177. DEVICE_TYPE DeviceType;
  1178. CCHAR StackSize;
  1179. union {
  1180. LIST_ENTRY ListEntry;
  1181. WAIT_CONTEXT_BLOCK Wcb;
  1182. } Queue;
  1183. ULONG AlignmentRequirement;
  1184. KDEVICE_QUEUE DeviceQueue;
  1185. KDPC Dpc;
  1186. //
  1187. // The following field is for exclusive use by the filesystem to keep
  1188. // track of the number of Fsp threads currently using the device
  1189. //
  1190. ULONG ActiveThreadCount;
  1191. PSECURITY_DESCRIPTOR SecurityDescriptor;
  1192. KEVENT DeviceLock;
  1193. USHORT SectorSize;
  1194. USHORT Spare1;
  1195. struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
  1196. PVOID Reserved;
  1197. } DEVICE_OBJECT;
  1198. typedef struct _DEVICE_OBJECT *PDEVICE_OBJECT; // ntndis
  1199. // end_ntddk end_nthal end_ntifs end_wdm end_ntosp
  1200. //
  1201. // Define the Device Object Extension Flags
  1202. //
  1203. #define DOE_UNLOAD_PENDING 0x00000001
  1204. #define DOE_DELETE_PENDING 0x00000002
  1205. #define DOE_REMOVE_PENDING 0x00000004
  1206. #define DOE_REMOVE_PROCESSED 0x00000008
  1207. #define DOE_START_PENDING 0x00000010
  1208. #define DOE_STARTIO_REQUESTED 0x00000020
  1209. #define DOE_STARTIO_REQUESTED_BYKEY 0x00000040
  1210. #define DOE_STARTIO_CANCELABLE 0x00000080
  1211. #define DOE_STARTIO_DEFERRED 0x00000100 // Use non-recursive startio
  1212. #define DOE_STARTIO_NO_CANCEL 0x00000200 // Pass non-cancelable IRP to startio
  1213. // begin_ntddk begin_nthal begin_ntifs begin_wdm begin_ntosp
  1214. struct _DEVICE_OBJECT_POWER_EXTENSION;
  1215. typedef struct _DEVOBJ_EXTENSION {
  1216. CSHORT Type;
  1217. USHORT Size;
  1218. //
  1219. // Public part of the DeviceObjectExtension structure
  1220. //
  1221. PDEVICE_OBJECT DeviceObject; // owning device object
  1222. // end_ntddk end_nthal end_ntifs end_wdm end_ntosp
  1223. //
  1224. // Universal Power Data - all device objects must have this
  1225. //
  1226. ULONG PowerFlags; // see ntos\po\pop.h
  1227. // WARNING: Access via PO macros
  1228. // and with PO locking rules ONLY.
  1229. //
  1230. // Pointer to the non-universal power data
  1231. // Power data that only some device objects need is stored in the
  1232. // device object power extension -> DOPE
  1233. // see po.h
  1234. //
  1235. struct _DEVICE_OBJECT_POWER_EXTENSION *Dope;
  1236. //
  1237. // power state information
  1238. //
  1239. //
  1240. // Device object extension flags. Protected by the IopDatabaseLock.
  1241. //
  1242. ULONG ExtensionFlags;
  1243. //
  1244. // PnP manager fields
  1245. //
  1246. PVOID DeviceNode;
  1247. //
  1248. // AttachedTo is a pointer to the device object that this device
  1249. // object is attached to. The attachment chain is now doubly
  1250. // linked: this pointer and DeviceObject->AttachedDevice provide the
  1251. // linkage.
  1252. //
  1253. PDEVICE_OBJECT AttachedTo;
  1254. //
  1255. // The next two fields are used to prevent recursion in IoStartNextPacket
  1256. // interfaces.
  1257. //
  1258. LONG StartIoCount; // Used to keep track of number of pending start ios.
  1259. LONG StartIoKey; // Next startio key
  1260. ULONG StartIoFlags; // Start Io Flags. Need a separate flag so that it can be accessed without locks
  1261. PVPB Vpb; // If not NULL contains the VPB of the mounted volume.
  1262. // Set in the filesystem's volume device object.
  1263. // This is a reverse VPB pointer.
  1264. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  1265. } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
  1266. //
  1267. // Define Driver Object (DRVO) flags
  1268. //
  1269. #define DRVO_UNLOAD_INVOKED 0x00000001
  1270. #define DRVO_LEGACY_DRIVER 0x00000002
  1271. #define DRVO_BUILTIN_DRIVER 0x00000004 // Driver objects for Hal, PnP Mgr
  1272. // end_wdm
  1273. #define DRVO_REINIT_REGISTERED 0x00000008
  1274. #define DRVO_INITIALIZED 0x00000010
  1275. #define DRVO_BOOTREINIT_REGISTERED 0x00000020
  1276. #define DRVO_LEGACY_RESOURCES 0x00000040
  1277. // end_ntddk end_nthal end_ntifs end_ntosp
  1278. #define DRVO_BASE_FILESYSTEM_DRIVER 0x00000080 // A driver that is at the bottom of the filesystem stack.
  1279. // begin_ntddk begin_nthal begin_ntifs begin_ntosp
  1280. // begin_wdm
  1281. typedef struct _DRIVER_EXTENSION {
  1282. //
  1283. // Back pointer to Driver Object
  1284. //
  1285. struct _DRIVER_OBJECT *DriverObject;
  1286. //
  1287. // The AddDevice entry point is called by the Plug & Play manager
  1288. // to inform the driver when a new device instance arrives that this
  1289. // driver must control.
  1290. //
  1291. PDRIVER_ADD_DEVICE AddDevice;
  1292. //
  1293. // The count field is used to count the number of times the driver has
  1294. // had its registered reinitialization routine invoked.
  1295. //
  1296. ULONG Count;
  1297. //
  1298. // The service name field is used by the pnp manager to determine
  1299. // where the driver related info is stored in the registry.
  1300. //
  1301. UNICODE_STRING ServiceKeyName;
  1302. //
  1303. // Note: any new shared fields get added here.
  1304. //
  1305. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  1306. //
  1307. // The client driver object extension field is used by class driver
  1308. // to store per driver information.
  1309. //
  1310. PIO_CLIENT_EXTENSION ClientDriverExtension;
  1311. //
  1312. // The file system filter callback extension field is used
  1313. // to safely notify filters of system operations that were
  1314. // previously not shown to file system filters.
  1315. //
  1316. PFS_FILTER_CALLBACKS FsFilterCallbacks;
  1317. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  1318. } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
  1319. typedef struct _DRIVER_OBJECT {
  1320. CSHORT Type;
  1321. CSHORT Size;
  1322. //
  1323. // The following links all of the devices created by a single driver
  1324. // together on a list, and the Flags word provides an extensible flag
  1325. // location for driver objects.
  1326. //
  1327. PDEVICE_OBJECT DeviceObject;
  1328. ULONG Flags;
  1329. //
  1330. // The following section describes where the driver is loaded. The count
  1331. // field is used to count the number of times the driver has had its
  1332. // registered reinitialization routine invoked.
  1333. //
  1334. PVOID DriverStart;
  1335. ULONG DriverSize;
  1336. PVOID DriverSection;
  1337. PDRIVER_EXTENSION DriverExtension;
  1338. //
  1339. // The driver name field is used by the error log thread
  1340. // determine the name of the driver that an I/O request is/was bound.
  1341. //
  1342. UNICODE_STRING DriverName;
  1343. //
  1344. // The following section is for registry support. Thise is a pointer
  1345. // to the path to the hardware information in the registry
  1346. //
  1347. PUNICODE_STRING HardwareDatabase;
  1348. //
  1349. // The following section contains the optional pointer to an array of
  1350. // alternate entry points to a driver for "fast I/O" support. Fast I/O
  1351. // is performed by invoking the driver routine directly with separate
  1352. // parameters, rather than using the standard IRP call mechanism. Note
  1353. // that these functions may only be used for synchronous I/O, and when
  1354. // the file is cached.
  1355. //
  1356. PFAST_IO_DISPATCH FastIoDispatch;
  1357. //
  1358. // The following section describes the entry points to this particular
  1359. // driver. Note that the major function dispatch table must be the last
  1360. // field in the object so that it remains extensible.
  1361. //
  1362. PDRIVER_INITIALIZE DriverInit;
  1363. PDRIVER_STARTIO DriverStartIo;
  1364. PDRIVER_UNLOAD DriverUnload;
  1365. PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
  1366. } DRIVER_OBJECT;
  1367. typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT; // ntndis
  1368. // end_ntddk end_wdm end_ntifs end_ntosp
  1369. //
  1370. // Device Handler Object. There is one of these objects per PnP
  1371. // device. This object is given to the device driver as a PVOID
  1372. // and is used by the driver to refer to a particular device.
  1373. //
  1374. typedef struct _DEVICE_HANDLER_OBJECT {
  1375. CSHORT Type;
  1376. USHORT Size;
  1377. //
  1378. // Indentifies which bus extender this device handler
  1379. // object is associated with
  1380. //
  1381. struct _BUS_HANDLER *BusHandler;
  1382. //
  1383. // The associated SlotNumber for this device handler
  1384. //
  1385. ULONG SlotNumber;
  1386. // end_nthal
  1387. //
  1388. // System internal fields
  1389. //
  1390. //
  1391. // Pnp stuff
  1392. //
  1393. UNICODE_STRING ServiceKeyName;
  1394. ULONG InstanceOrdinal;
  1395. // begin_nthal
  1396. } DEVICE_HANDLER_OBJECT, *PDEVICE_HANDLER_OBJECT;
  1397. // begin_ntddk begin_wdm begin_ntifs begin_ntosp
  1398. //
  1399. // The following structure is pointed to by the SectionObject pointer field
  1400. // of a file object, and is allocated by the various NT file systems.
  1401. //
  1402. typedef struct _SECTION_OBJECT_POINTERS {
  1403. PVOID DataSectionObject;
  1404. PVOID SharedCacheMap;
  1405. PVOID ImageSectionObject;
  1406. } SECTION_OBJECT_POINTERS;
  1407. typedef SECTION_OBJECT_POINTERS *PSECTION_OBJECT_POINTERS;
  1408. //
  1409. // Define the format of a completion message.
  1410. //
  1411. typedef struct _IO_COMPLETION_CONTEXT {
  1412. PVOID Port;
  1413. PVOID Key;
  1414. } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
  1415. //
  1416. // Define File Object (FO) flags
  1417. //
  1418. #define FO_FILE_OPEN 0x00000001
  1419. #define FO_SYNCHRONOUS_IO 0x00000002
  1420. #define FO_ALERTABLE_IO 0x00000004
  1421. #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
  1422. #define FO_WRITE_THROUGH 0x00000010
  1423. #define FO_SEQUENTIAL_ONLY 0x00000020
  1424. #define FO_CACHE_SUPPORTED 0x00000040
  1425. #define FO_NAMED_PIPE 0x00000080
  1426. #define FO_STREAM_FILE 0x00000100
  1427. #define FO_MAILSLOT 0x00000200
  1428. #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
  1429. #define FO_DIRECT_DEVICE_OPEN 0x00000800
  1430. #define FO_FILE_MODIFIED 0x00001000
  1431. #define FO_FILE_SIZE_CHANGED 0x00002000
  1432. #define FO_CLEANUP_COMPLETE 0x00004000
  1433. #define FO_TEMPORARY_FILE 0x00008000
  1434. #define FO_DELETE_ON_CLOSE 0x00010000
  1435. #define FO_OPENED_CASE_SENSITIVE 0x00020000
  1436. #define FO_HANDLE_CREATED 0x00040000
  1437. #define FO_FILE_FAST_IO_READ 0x00080000
  1438. #define FO_RANDOM_ACCESS 0x00100000
  1439. #define FO_FILE_OPEN_CANCELLED 0x00200000
  1440. #define FO_VOLUME_OPEN 0x00400000
  1441. #define FO_FILE_OBJECT_HAS_EXTENSION 0x00800000
  1442. #define FO_REMOTE_ORIGIN 0x01000000
  1443. typedef struct _FILE_OBJECT {
  1444. CSHORT Type;
  1445. CSHORT Size;
  1446. PDEVICE_OBJECT DeviceObject;
  1447. PVPB Vpb;
  1448. PVOID FsContext;
  1449. PVOID FsContext2;
  1450. PSECTION_OBJECT_POINTERS SectionObjectPointer;
  1451. PVOID PrivateCacheMap;
  1452. NTSTATUS FinalStatus;
  1453. struct _FILE_OBJECT *RelatedFileObject;
  1454. BOOLEAN LockOperation;
  1455. BOOLEAN DeletePending;
  1456. BOOLEAN ReadAccess;
  1457. BOOLEAN WriteAccess;
  1458. BOOLEAN DeleteAccess;
  1459. BOOLEAN SharedRead;
  1460. BOOLEAN SharedWrite;
  1461. BOOLEAN SharedDelete;
  1462. ULONG Flags;
  1463. UNICODE_STRING FileName;
  1464. LARGE_INTEGER CurrentByteOffset;
  1465. ULONG Waiters;
  1466. ULONG Busy;
  1467. PVOID LastLock;
  1468. KEVENT Lock;
  1469. KEVENT Event;
  1470. PIO_COMPLETION_CONTEXT CompletionContext;
  1471. } FILE_OBJECT;
  1472. typedef struct _FILE_OBJECT *PFILE_OBJECT; // ntndis
  1473. //
  1474. // Define I/O Request Packet (IRP) flags
  1475. //
  1476. #define IRP_NOCACHE 0x00000001
  1477. #define IRP_PAGING_IO 0x00000002
  1478. #define IRP_MOUNT_COMPLETION 0x00000002
  1479. #define IRP_SYNCHRONOUS_API 0x00000004
  1480. #define IRP_ASSOCIATED_IRP 0x00000008
  1481. #define IRP_BUFFERED_IO 0x00000010
  1482. #define IRP_DEALLOCATE_BUFFER 0x00000020
  1483. #define IRP_INPUT_OPERATION 0x00000040
  1484. #define IRP_SYNCHRONOUS_PAGING_IO 0x00000040
  1485. #define IRP_CREATE_OPERATION 0x00000080
  1486. #define IRP_READ_OPERATION 0x00000100
  1487. #define IRP_WRITE_OPERATION 0x00000200
  1488. #define IRP_CLOSE_OPERATION 0x00000400
  1489. // end_wdm
  1490. #define IRP_DEFER_IO_COMPLETION 0x00000800
  1491. #define IRP_OB_QUERY_NAME 0x00001000
  1492. #define IRP_HOLD_DEVICE_QUEUE 0x00002000
  1493. #define IRP_RETRY_IO_COMPLETION 0x00004000
  1494. #define IRP_CLASS_CACHE_OPERATION 0x00008000
  1495. #define IRP_SET_USER_EVENT IRP_CLOSE_OPERATION
  1496. // begin_wdm
  1497. //
  1498. // Define I/O request packet (IRP) alternate flags for allocation control.
  1499. //
  1500. #define IRP_QUOTA_CHARGED 0x01
  1501. #define IRP_ALLOCATED_MUST_SUCCEED 0x02
  1502. #define IRP_ALLOCATED_FIXED_SIZE 0x04
  1503. #define IRP_LOOKASIDE_ALLOCATION 0x08
  1504. //
  1505. // I/O Request Packet (IRP) definition
  1506. //
  1507. typedef struct _IRP {
  1508. CSHORT Type;
  1509. USHORT Size;
  1510. //
  1511. // Define the common fields used to control the IRP.
  1512. //
  1513. //
  1514. // Define a pointer to the Memory Descriptor List (MDL) for this I/O
  1515. // request. This field is only used if the I/O is "direct I/O".
  1516. //
  1517. PMDL MdlAddress;
  1518. //
  1519. // Flags word - used to remember various flags.
  1520. //
  1521. ULONG Flags;
  1522. //
  1523. // The following union is used for one of three purposes:
  1524. //
  1525. // 1. This IRP is an associated IRP. The field is a pointer to a master
  1526. // IRP.
  1527. //
  1528. // 2. This is the master IRP. The field is the count of the number of
  1529. // IRPs which must complete (associated IRPs) before the master can
  1530. // complete.
  1531. //
  1532. // 3. This operation is being buffered and the field is the address of
  1533. // the system space buffer.
  1534. //
  1535. union {
  1536. struct _IRP *MasterIrp;
  1537. LONG IrpCount;
  1538. PVOID SystemBuffer;
  1539. } AssociatedIrp;
  1540. //
  1541. // Thread list entry - allows queueing the IRP to the thread pending I/O
  1542. // request packet list.
  1543. //
  1544. LIST_ENTRY ThreadListEntry;
  1545. //
  1546. // I/O status - final status of operation.
  1547. //
  1548. IO_STATUS_BLOCK IoStatus;
  1549. //
  1550. // Requestor mode - mode of the original requestor of this operation.
  1551. //
  1552. KPROCESSOR_MODE RequestorMode;
  1553. //
  1554. // Pending returned - TRUE if pending was initially returned as the
  1555. // status for this packet.
  1556. //
  1557. BOOLEAN PendingReturned;
  1558. //
  1559. // Stack state information.
  1560. //
  1561. CHAR StackCount;
  1562. CHAR CurrentLocation;
  1563. //
  1564. // Cancel - packet has been canceled.
  1565. //
  1566. BOOLEAN Cancel;
  1567. //
  1568. // Cancel Irql - Irql at which the cancel spinlock was acquired.
  1569. //
  1570. KIRQL CancelIrql;
  1571. //
  1572. // ApcEnvironment - Used to save the APC environment at the time that the
  1573. // packet was initialized.
  1574. //
  1575. CCHAR ApcEnvironment;
  1576. //
  1577. // Allocation control flags.
  1578. //
  1579. UCHAR AllocationFlags;
  1580. //
  1581. // User parameters.
  1582. //
  1583. PIO_STATUS_BLOCK UserIosb;
  1584. PKEVENT UserEvent;
  1585. union {
  1586. struct {
  1587. PIO_APC_ROUTINE UserApcRoutine;
  1588. PVOID UserApcContext;
  1589. } AsynchronousParameters;
  1590. LARGE_INTEGER AllocationSize;
  1591. } Overlay;
  1592. //
  1593. // CancelRoutine - Used to contain the address of a cancel routine supplied
  1594. // by a device driver when the IRP is in a cancelable state.
  1595. //
  1596. PDRIVER_CANCEL CancelRoutine;
  1597. //
  1598. // Note that the UserBuffer parameter is outside of the stack so that I/O
  1599. // completion can copy data back into the user's address space without
  1600. // having to know exactly which service was being invoked. The length
  1601. // of the copy is stored in the second half of the I/O status block. If
  1602. // the UserBuffer field is NULL, then no copy is performed.
  1603. //
  1604. PVOID UserBuffer;
  1605. //
  1606. // Kernel structures
  1607. //
  1608. // The following section contains kernel structures which the IRP needs
  1609. // in order to place various work information in kernel controller system
  1610. // queues. Because the size and alignment cannot be controlled, they are
  1611. // placed here at the end so they just hang off and do not affect the
  1612. // alignment of other fields in the IRP.
  1613. //
  1614. union {
  1615. struct {
  1616. union {
  1617. //
  1618. // DeviceQueueEntry - The device queue entry field is used to
  1619. // queue the IRP to the device driver device queue.
  1620. //
  1621. KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
  1622. struct {
  1623. //
  1624. // The following are available to the driver to use in
  1625. // whatever manner is desired, while the driver owns the
  1626. // packet.
  1627. //
  1628. PVOID DriverContext[4];
  1629. } ;
  1630. } ;
  1631. //
  1632. // Thread - pointer to caller's Thread Control Block.
  1633. //
  1634. PETHREAD Thread;
  1635. //
  1636. // Auxiliary buffer - pointer to any auxiliary buffer that is
  1637. // required to pass information to a driver that is not contained
  1638. // in a normal buffer.
  1639. //
  1640. PCHAR AuxiliaryBuffer;
  1641. //
  1642. // The following unnamed structure must be exactly identical
  1643. // to the unnamed structure used in the minipacket header used
  1644. // for completion queue entries.
  1645. //
  1646. struct {
  1647. //
  1648. // List entry - used to queue the packet to completion queue, among
  1649. // others.
  1650. //
  1651. LIST_ENTRY ListEntry;
  1652. union {
  1653. //
  1654. // Current stack location - contains a pointer to the current
  1655. // IO_STACK_LOCATION structure in the IRP stack. This field
  1656. // should never be directly accessed by drivers. They should
  1657. // use the standard functions.
  1658. //
  1659. struct _IO_STACK_LOCATION *CurrentStackLocation;
  1660. //
  1661. // Minipacket type.
  1662. //
  1663. ULONG PacketType;
  1664. };
  1665. };
  1666. //
  1667. // Original file object - pointer to the original file object
  1668. // that was used to open the file. This field is owned by the
  1669. // I/O system and should not be used by any other drivers.
  1670. //
  1671. PFILE_OBJECT OriginalFileObject;
  1672. } Overlay;
  1673. //
  1674. // APC - This APC control block is used for the special kernel APC as
  1675. // well as for the caller's APC, if one was specified in the original
  1676. // argument list. If so, then the APC is reused for the normal APC for
  1677. // whatever mode the caller was in and the "special" routine that is
  1678. // invoked before the APC gets control simply deallocates the IRP.
  1679. //
  1680. KAPC Apc;
  1681. //
  1682. // CompletionKey - This is the key that is used to distinguish
  1683. // individual I/O operations initiated on a single file handle.
  1684. //
  1685. PVOID CompletionKey;
  1686. } Tail;
  1687. } IRP, *PIRP;
  1688. //
  1689. // Define completion routine types for use in stack locations in an IRP
  1690. //
  1691. typedef
  1692. NTSTATUS
  1693. (*PIO_COMPLETION_ROUTINE) (
  1694. IN PDEVICE_OBJECT DeviceObject,
  1695. IN PIRP Irp,
  1696. IN PVOID Context
  1697. );
  1698. //
  1699. // Define stack location control flags
  1700. //
  1701. #define SL_PENDING_RETURNED 0x01
  1702. #define SL_INVOKE_ON_CANCEL 0x20
  1703. #define SL_INVOKE_ON_SUCCESS 0x40
  1704. #define SL_INVOKE_ON_ERROR 0x80
  1705. //
  1706. // Define flags for various functions
  1707. //
  1708. //
  1709. // Create / Create Named Pipe
  1710. //
  1711. // The following flags must exactly match those in the IoCreateFile call's
  1712. // options. The case sensitive flag is added in later, by the parse routine,
  1713. // and is not an actual option to open. Rather, it is part of the object
  1714. // manager's attributes structure.
  1715. //
  1716. #define SL_FORCE_ACCESS_CHECK 0x01
  1717. #define SL_OPEN_PAGING_FILE 0x02
  1718. #define SL_OPEN_TARGET_DIRECTORY 0x04
  1719. #define SL_CASE_SENSITIVE 0x80
  1720. //
  1721. // Read / Write
  1722. //
  1723. #define SL_KEY_SPECIFIED 0x01
  1724. #define SL_OVERRIDE_VERIFY_VOLUME 0x02
  1725. #define SL_WRITE_THROUGH 0x04
  1726. #define SL_FT_SEQUENTIAL_WRITE 0x08
  1727. //
  1728. // Device I/O Control
  1729. //
  1730. //
  1731. // Same SL_OVERRIDE_VERIFY_VOLUME as for read/write above.
  1732. //
  1733. #define SL_READ_ACCESS_GRANTED 0x01
  1734. #define SL_WRITE_ACCESS_GRANTED 0x04 // Gap for SL_OVERRIDE_VERIFY_VOLUME
  1735. //
  1736. // Lock
  1737. //
  1738. #define SL_FAIL_IMMEDIATELY 0x01
  1739. #define SL_EXCLUSIVE_LOCK 0x02
  1740. //
  1741. // QueryDirectory / QueryEa / QueryQuota
  1742. //
  1743. #define SL_RESTART_SCAN 0x01
  1744. #define SL_RETURN_SINGLE_ENTRY 0x02
  1745. #define SL_INDEX_SPECIFIED 0x04
  1746. //
  1747. // NotifyDirectory
  1748. //
  1749. #define SL_WATCH_TREE 0x01
  1750. //
  1751. // FileSystemControl
  1752. //
  1753. // minor: mount/verify volume
  1754. //
  1755. #define SL_ALLOW_RAW_MOUNT 0x01
  1756. //
  1757. // Define PNP/POWER types required by IRP_MJ_PNP/IRP_MJ_POWER.
  1758. //
  1759. typedef enum _DEVICE_RELATION_TYPE {
  1760. BusRelations,
  1761. EjectionRelations,
  1762. PowerRelations,
  1763. RemovalRelations,
  1764. TargetDeviceRelation,
  1765. SingleBusRelations
  1766. } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
  1767. typedef struct _DEVICE_RELATIONS {
  1768. ULONG Count;
  1769. PDEVICE_OBJECT Objects[1]; // variable length
  1770. } DEVICE_RELATIONS, *PDEVICE_RELATIONS;
  1771. typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
  1772. DeviceUsageTypeUndefined,
  1773. DeviceUsageTypePaging,
  1774. DeviceUsageTypeHibernation,
  1775. DeviceUsageTypeDumpFile
  1776. } DEVICE_USAGE_NOTIFICATION_TYPE;
  1777. // begin_ntminiport
  1778. // workaround overloaded definition (rpc generated headers all define INTERFACE
  1779. // to match the class name).
  1780. #undef INTERFACE
  1781. typedef struct _INTERFACE {
  1782. USHORT Size;
  1783. USHORT Version;
  1784. PVOID Context;
  1785. PINTERFACE_REFERENCE InterfaceReference;
  1786. PINTERFACE_DEREFERENCE InterfaceDereference;
  1787. // interface specific entries go here
  1788. } INTERFACE, *PINTERFACE;
  1789. // end_ntminiport
  1790. typedef struct _DEVICE_CAPABILITIES {
  1791. USHORT Size;
  1792. USHORT Version; // the version documented here is version 1
  1793. ULONG DeviceD1:1;
  1794. ULONG DeviceD2:1;
  1795. ULONG LockSupported:1;
  1796. ULONG EjectSupported:1; // Ejectable in S0
  1797. ULONG Removable:1;
  1798. ULONG DockDevice:1;
  1799. ULONG UniqueID:1;
  1800. ULONG SilentInstall:1;
  1801. ULONG RawDeviceOK:1;
  1802. ULONG SurpriseRemovalOK:1;
  1803. ULONG WakeFromD0:1;
  1804. ULONG WakeFromD1:1;
  1805. ULONG WakeFromD2:1;
  1806. ULONG WakeFromD3:1;
  1807. ULONG HardwareDisabled:1;
  1808. ULONG NonDynamic:1;
  1809. ULONG WarmEjectSupported:1;
  1810. ULONG NoDisplayInUI:1;
  1811. ULONG Reserved:14;
  1812. ULONG Address;
  1813. ULONG UINumber;
  1814. DEVICE_POWER_STATE DeviceState[POWER_SYSTEM_MAXIMUM];
  1815. SYSTEM_POWER_STATE SystemWake;
  1816. DEVICE_POWER_STATE DeviceWake;
  1817. ULONG D1Latency;
  1818. ULONG D2Latency;
  1819. ULONG D3Latency;
  1820. } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
  1821. typedef struct _POWER_SEQUENCE {
  1822. ULONG SequenceD1;
  1823. ULONG SequenceD2;
  1824. ULONG SequenceD3;
  1825. } POWER_SEQUENCE, *PPOWER_SEQUENCE;
  1826. typedef enum {
  1827. BusQueryDeviceID = 0, // <Enumerator>\<Enumerator-specific device id>
  1828. BusQueryHardwareIDs = 1, // Hardware ids
  1829. BusQueryCompatibleIDs = 2, // compatible device ids
  1830. BusQueryInstanceID = 3, // persistent id for this instance of the device
  1831. BusQueryDeviceSerialNumber = 4 // serial number for this device
  1832. } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
  1833. typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
  1834. #define PNP_DEVICE_DISABLED 0x00000001
  1835. #define PNP_DEVICE_DONT_DISPLAY_IN_UI 0x00000002
  1836. #define PNP_DEVICE_FAILED 0x00000004
  1837. #define PNP_DEVICE_REMOVED 0x00000008
  1838. #define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
  1839. #define PNP_DEVICE_NOT_DISABLEABLE 0x00000020
  1840. typedef enum {
  1841. DeviceTextDescription = 0, // DeviceDesc property
  1842. DeviceTextLocationInformation = 1 // DeviceLocation property
  1843. } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
  1844. //
  1845. // Define I/O Request Packet (IRP) stack locations
  1846. //
  1847. #if !defined(_AMD64_) && !defined(_IA64_)
  1848. #include "pshpack4.h"
  1849. #endif
  1850. // begin_ntndis
  1851. #if defined(_WIN64)
  1852. #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
  1853. #else
  1854. #define POINTER_ALIGNMENT
  1855. #endif
  1856. // end_ntndis
  1857. typedef struct _IO_STACK_LOCATION {
  1858. UCHAR MajorFunction;
  1859. UCHAR MinorFunction;
  1860. UCHAR Flags;
  1861. UCHAR Control;
  1862. //
  1863. // The following user parameters are based on the service that is being
  1864. // invoked. Drivers and file systems can determine which set to use based
  1865. // on the above major and minor function codes.
  1866. //
  1867. union {
  1868. //
  1869. // System service parameters for: NtCreateFile
  1870. //
  1871. struct {
  1872. PIO_SECURITY_CONTEXT SecurityContext;
  1873. ULONG Options;
  1874. USHORT POINTER_ALIGNMENT FileAttributes;
  1875. USHORT ShareAccess;
  1876. ULONG POINTER_ALIGNMENT EaLength;
  1877. } Create;
  1878. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  1879. //
  1880. // System service parameters for: NtCreateNamedPipeFile
  1881. //
  1882. // Notice that the fields in the following parameter structure must
  1883. // match those for the create structure other than the last longword.
  1884. // This is so that no distinctions need be made by the I/O system's
  1885. // parse routine other than for the last longword.
  1886. //
  1887. struct {
  1888. PIO_SECURITY_CONTEXT SecurityContext;
  1889. ULONG Options;
  1890. USHORT POINTER_ALIGNMENT Reserved;
  1891. USHORT ShareAccess;
  1892. PNAMED_PIPE_CREATE_PARAMETERS Parameters;
  1893. } CreatePipe;
  1894. //
  1895. // System service parameters for: NtCreateMailslotFile
  1896. //
  1897. // Notice that the fields in the following parameter structure must
  1898. // match those for the create structure other than the last longword.
  1899. // This is so that no distinctions need be made by the I/O system's
  1900. // parse routine other than for the last longword.
  1901. //
  1902. struct {
  1903. PIO_SECURITY_CONTEXT SecurityContext;
  1904. ULONG Options;
  1905. USHORT POINTER_ALIGNMENT Reserved;
  1906. USHORT ShareAccess;
  1907. PMAILSLOT_CREATE_PARAMETERS Parameters;
  1908. } CreateMailslot;
  1909. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  1910. //
  1911. // System service parameters for: NtReadFile
  1912. //
  1913. struct {
  1914. ULONG Length;
  1915. ULONG POINTER_ALIGNMENT Key;
  1916. LARGE_INTEGER ByteOffset;
  1917. } Read;
  1918. //
  1919. // System service parameters for: NtWriteFile
  1920. //
  1921. struct {
  1922. ULONG Length;
  1923. ULONG POINTER_ALIGNMENT Key;
  1924. LARGE_INTEGER ByteOffset;
  1925. } Write;
  1926. // end_ntddk end_wdm end_nthal
  1927. //
  1928. // System service parameters for: NtQueryDirectoryFile
  1929. //
  1930. struct {
  1931. ULONG Length;
  1932. PSTRING FileName;
  1933. FILE_INFORMATION_CLASS FileInformationClass;
  1934. ULONG POINTER_ALIGNMENT FileIndex;
  1935. } QueryDirectory;
  1936. //
  1937. // System service parameters for: NtNotifyChangeDirectoryFile
  1938. //
  1939. struct {
  1940. ULONG Length;
  1941. ULONG POINTER_ALIGNMENT CompletionFilter;
  1942. } NotifyDirectory;
  1943. // begin_ntddk begin_wdm begin_nthal
  1944. //
  1945. // System service parameters for: NtQueryInformationFile
  1946. //
  1947. struct {
  1948. ULONG Length;
  1949. FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
  1950. } QueryFile;
  1951. //
  1952. // System service parameters for: NtSetInformationFile
  1953. //
  1954. struct {
  1955. ULONG Length;
  1956. FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
  1957. PFILE_OBJECT FileObject;
  1958. union {
  1959. struct {
  1960. BOOLEAN ReplaceIfExists;
  1961. BOOLEAN AdvanceOnly;
  1962. };
  1963. ULONG ClusterCount;
  1964. HANDLE DeleteHandle;
  1965. };
  1966. } SetFile;
  1967. // end_ntddk end_wdm end_nthal end_ntosp
  1968. //
  1969. // System service parameters for: NtQueryEaFile
  1970. //
  1971. struct {
  1972. ULONG Length;
  1973. PVOID EaList;
  1974. ULONG EaListLength;
  1975. ULONG POINTER_ALIGNMENT EaIndex;
  1976. } QueryEa;
  1977. //
  1978. // System service parameters for: NtSetEaFile
  1979. //
  1980. struct {
  1981. ULONG Length;
  1982. } SetEa;
  1983. // begin_ntddk begin_wdm begin_nthal begin_ntosp
  1984. //
  1985. // System service parameters for: NtQueryVolumeInformationFile
  1986. //
  1987. struct {
  1988. ULONG Length;
  1989. FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
  1990. } QueryVolume;
  1991. // end_ntddk end_wdm end_nthal end_ntosp
  1992. //
  1993. // System service parameters for: NtSetVolumeInformationFile
  1994. //
  1995. struct {
  1996. ULONG Length;
  1997. FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
  1998. } SetVolume;
  1999. // begin_ntosp
  2000. //
  2001. // System service parameters for: NtFsControlFile
  2002. //
  2003. // Note that the user's output buffer is stored in the UserBuffer field
  2004. // and the user's input buffer is stored in the SystemBuffer field.
  2005. //
  2006. struct {
  2007. ULONG OutputBufferLength;
  2008. ULONG POINTER_ALIGNMENT InputBufferLength;
  2009. ULONG POINTER_ALIGNMENT FsControlCode;
  2010. PVOID Type3InputBuffer;
  2011. } FileSystemControl;
  2012. //
  2013. // System service parameters for: NtLockFile/NtUnlockFile
  2014. //
  2015. struct {
  2016. PLARGE_INTEGER Length;
  2017. ULONG POINTER_ALIGNMENT Key;
  2018. LARGE_INTEGER ByteOffset;
  2019. } LockControl;
  2020. // begin_ntddk begin_wdm begin_nthal
  2021. //
  2022. // System service parameters for: NtFlushBuffersFile
  2023. //
  2024. // No extra user-supplied parameters.
  2025. //
  2026. // end_ntddk end_wdm end_nthal
  2027. // end_ntosp
  2028. //
  2029. // System service parameters for: NtCancelIoFile
  2030. //
  2031. // No extra user-supplied parameters.
  2032. //
  2033. // begin_ntddk begin_wdm begin_nthal begin_ntosp
  2034. //
  2035. // System service parameters for: NtDeviceIoControlFile
  2036. //
  2037. // Note that the user's output buffer is stored in the UserBuffer field
  2038. // and the user's input buffer is stored in the SystemBuffer field.
  2039. //
  2040. struct {
  2041. ULONG OutputBufferLength;
  2042. ULONG POINTER_ALIGNMENT InputBufferLength;
  2043. ULONG POINTER_ALIGNMENT IoControlCode;
  2044. PVOID Type3InputBuffer;
  2045. } DeviceIoControl;
  2046. // end_wdm
  2047. //
  2048. // System service parameters for: NtQuerySecurityObject
  2049. //
  2050. struct {
  2051. SECURITY_INFORMATION SecurityInformation;
  2052. ULONG POINTER_ALIGNMENT Length;
  2053. } QuerySecurity;
  2054. //
  2055. // System service parameters for: NtSetSecurityObject
  2056. //
  2057. struct {
  2058. SECURITY_INFORMATION SecurityInformation;
  2059. PSECURITY_DESCRIPTOR SecurityDescriptor;
  2060. } SetSecurity;
  2061. // begin_wdm
  2062. //
  2063. // Non-system service parameters.
  2064. //
  2065. // Parameters for MountVolume
  2066. //
  2067. struct {
  2068. PVPB Vpb;
  2069. PDEVICE_OBJECT DeviceObject;
  2070. } MountVolume;
  2071. //
  2072. // Parameters for VerifyVolume
  2073. //
  2074. struct {
  2075. PVPB Vpb;
  2076. PDEVICE_OBJECT DeviceObject;
  2077. } VerifyVolume;
  2078. //
  2079. // Parameters for Scsi with internal device contorl.
  2080. //
  2081. struct {
  2082. struct _SCSI_REQUEST_BLOCK *Srb;
  2083. } Scsi;
  2084. // end_ntddk end_wdm end_nthal end_ntosp
  2085. //
  2086. // System service parameters for: NtQueryQuotaInformationFile
  2087. //
  2088. struct {
  2089. ULONG Length;
  2090. PSID StartSid;
  2091. PFILE_GET_QUOTA_INFORMATION SidList;
  2092. ULONG SidListLength;
  2093. } QueryQuota;
  2094. //
  2095. // System service parameters for: NtSetQuotaInformationFile
  2096. //
  2097. struct {
  2098. ULONG Length;
  2099. } SetQuota;
  2100. // begin_ntddk begin_wdm begin_nthal begin_ntosp
  2101. //
  2102. // Parameters for IRP_MN_QUERY_DEVICE_RELATIONS
  2103. //
  2104. struct {
  2105. DEVICE_RELATION_TYPE Type;
  2106. } QueryDeviceRelations;
  2107. //
  2108. // Parameters for IRP_MN_QUERY_INTERFACE
  2109. //
  2110. struct {
  2111. CONST GUID *InterfaceType;
  2112. USHORT Size;
  2113. USHORT Version;
  2114. PINTERFACE Interface;
  2115. PVOID InterfaceSpecificData;
  2116. } QueryInterface;
  2117. // end_ntifs
  2118. //
  2119. // Parameters for IRP_MN_QUERY_CAPABILITIES
  2120. //
  2121. struct {
  2122. PDEVICE_CAPABILITIES Capabilities;
  2123. } DeviceCapabilities;
  2124. //
  2125. // Parameters for IRP_MN_FILTER_RESOURCE_REQUIREMENTS
  2126. //
  2127. struct {
  2128. PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
  2129. } FilterResourceRequirements;
  2130. //
  2131. // Parameters for IRP_MN_READ_CONFIG and IRP_MN_WRITE_CONFIG
  2132. //
  2133. struct {
  2134. ULONG WhichSpace;
  2135. PVOID Buffer;
  2136. ULONG Offset;
  2137. ULONG POINTER_ALIGNMENT Length;
  2138. } ReadWriteConfig;
  2139. //
  2140. // Parameters for IRP_MN_SET_LOCK
  2141. //
  2142. struct {
  2143. BOOLEAN Lock;
  2144. } SetLock;
  2145. //
  2146. // Parameters for IRP_MN_QUERY_ID
  2147. //
  2148. struct {
  2149. BUS_QUERY_ID_TYPE IdType;
  2150. } QueryId;
  2151. //
  2152. // Parameters for IRP_MN_QUERY_DEVICE_TEXT
  2153. //
  2154. struct {
  2155. DEVICE_TEXT_TYPE DeviceTextType;
  2156. LCID POINTER_ALIGNMENT LocaleId;
  2157. } QueryDeviceText;
  2158. //
  2159. // Parameters for IRP_MN_DEVICE_USAGE_NOTIFICATION
  2160. //
  2161. struct {
  2162. BOOLEAN InPath;
  2163. BOOLEAN Reserved[3];
  2164. DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
  2165. } UsageNotification;
  2166. //
  2167. // Parameters for IRP_MN_WAIT_WAKE
  2168. //
  2169. struct {
  2170. SYSTEM_POWER_STATE PowerState;
  2171. } WaitWake;
  2172. //
  2173. // Parameter for IRP_MN_POWER_SEQUENCE
  2174. //
  2175. struct {
  2176. PPOWER_SEQUENCE PowerSequence;
  2177. } PowerSequence;
  2178. //
  2179. // Parameters for IRP_MN_SET_POWER and IRP_MN_QUERY_POWER
  2180. //
  2181. struct {
  2182. ULONG SystemContext;
  2183. POWER_STATE_TYPE POINTER_ALIGNMENT Type;
  2184. POWER_STATE POINTER_ALIGNMENT State;
  2185. POWER_ACTION POINTER_ALIGNMENT ShutdownType;
  2186. } Power;
  2187. //
  2188. // Parameters for StartDevice
  2189. //
  2190. struct {
  2191. PCM_RESOURCE_LIST AllocatedResources;
  2192. PCM_RESOURCE_LIST AllocatedResourcesTranslated;
  2193. } StartDevice;
  2194. // begin_ntifs
  2195. //
  2196. // Parameters for Cleanup
  2197. //
  2198. // No extra parameters supplied
  2199. //
  2200. //
  2201. // WMI Irps
  2202. //
  2203. struct {
  2204. ULONG_PTR ProviderId;
  2205. PVOID DataPath;
  2206. ULONG BufferSize;
  2207. PVOID Buffer;
  2208. } WMI;
  2209. //
  2210. // Others - driver-specific
  2211. //
  2212. struct {
  2213. PVOID Argument1;
  2214. PVOID Argument2;
  2215. PVOID Argument3;
  2216. PVOID Argument4;
  2217. } Others;
  2218. } Parameters;
  2219. //
  2220. // Save a pointer to this device driver's device object for this request
  2221. // so it can be passed to the completion routine if needed.
  2222. //
  2223. PDEVICE_OBJECT DeviceObject;
  2224. //
  2225. // The following location contains a pointer to the file object for this
  2226. //
  2227. PFILE_OBJECT FileObject;
  2228. //
  2229. // The following routine is invoked depending on the flags in the above
  2230. // flags field.
  2231. //
  2232. PIO_COMPLETION_ROUTINE CompletionRoutine;
  2233. //
  2234. // The following is used to store the address of the context parameter
  2235. // that should be passed to the CompletionRoutine.
  2236. //
  2237. PVOID Context;
  2238. } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
  2239. #if !defined(_AMD64_) && !defined(_IA64_)
  2240. #include "poppack.h"
  2241. #endif
  2242. //
  2243. // Define the share access structure used by file systems to determine
  2244. // whether or not another accessor may open the file.
  2245. //
  2246. typedef struct _SHARE_ACCESS {
  2247. ULONG OpenCount;
  2248. ULONG Readers;
  2249. ULONG Writers;
  2250. ULONG Deleters;
  2251. ULONG SharedRead;
  2252. ULONG SharedWrite;
  2253. ULONG SharedDelete;
  2254. } SHARE_ACCESS, *PSHARE_ACCESS;
  2255. // end_wdm
  2256. //
  2257. // The following structure is used by drivers that are initializing to
  2258. // determine the number of devices of a particular type that have already
  2259. // been initialized. It is also used to track whether or not the AtDisk
  2260. // address range has already been claimed. Finally, it is used by the
  2261. // NtQuerySystemInformation system service to return device type counts.
  2262. //
  2263. typedef struct _CONFIGURATION_INFORMATION {
  2264. //
  2265. // This field indicates the total number of disks in the system. This
  2266. // number should be used by the driver to determine the name of new
  2267. // disks. This field should be updated by the driver as it finds new
  2268. // disks.
  2269. //
  2270. ULONG DiskCount; // Count of hard disks thus far
  2271. ULONG FloppyCount; // Count of floppy disks thus far
  2272. ULONG CdRomCount; // Count of CD-ROM drives thus far
  2273. ULONG TapeCount; // Count of tape drives thus far
  2274. ULONG ScsiPortCount; // Count of SCSI port adapters thus far
  2275. ULONG SerialCount; // Count of serial devices thus far
  2276. ULONG ParallelCount; // Count of parallel devices thus far
  2277. //
  2278. // These next two fields indicate ownership of one of the two IO address
  2279. // spaces that are used by WD1003-compatable disk controllers.
  2280. //
  2281. BOOLEAN AtDiskPrimaryAddressClaimed; // 0x1F0 - 0x1FF
  2282. BOOLEAN AtDiskSecondaryAddressClaimed; // 0x170 - 0x17F
  2283. //
  2284. // Indicates the structure version, as anything value belong this will have been added.
  2285. // Use the structure size as the version.
  2286. //
  2287. ULONG Version;
  2288. //
  2289. // Indicates the total number of medium changer devices in the system.
  2290. // This field will be updated by the drivers as it determines that
  2291. // new devices have been found and will be supported.
  2292. //
  2293. ULONG MediumChangerCount;
  2294. } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
  2295. // end_ntddk end_nthal end_ntosp
  2296. //
  2297. // The following are global counters used by the I/O system to indicate the
  2298. // amount of I/O being performed in the system. The first three counters
  2299. // are just that, counts of operations that have been requested, while the
  2300. // last three counters track the amount of data transferred for each type
  2301. // of I/O request.
  2302. //
  2303. extern KSPIN_LOCK IoStatisticsLock;
  2304. extern ULONG IoReadOperationCount;
  2305. extern ULONG IoWriteOperationCount;
  2306. extern ULONG IoOtherOperationCount;
  2307. extern LARGE_INTEGER IoReadTransferCount;
  2308. extern LARGE_INTEGER IoWriteTransferCount;
  2309. extern LARGE_INTEGER IoOtherTransferCount;
  2310. //
  2311. // It is difficult for cached file systems to properly charge quota
  2312. // for the storage that they allocate on behalf of user file handles,
  2313. // so the following amount of additional quota is charged against each
  2314. // handle as a "best guess" as to the amount of quota the file system
  2315. // will allocate on behalf of this handle.
  2316. //
  2317. //
  2318. // These numbers are totally arbitrary, and can be changed if it turns out
  2319. // that the file systems actually allocate more (or less) on behalf of
  2320. // their file objects. The non-paged pool charge constant is added to the
  2321. // size of a FILE_OBJECT to get the actual charge amount.
  2322. //
  2323. #define IO_FILE_OBJECT_NON_PAGED_POOL_CHARGE 64
  2324. #define IO_FILE_OBJECT_PAGED_POOL_CHARGE 1024
  2325. // begin_ntddk begin_wdm begin_nthal begin_ntosp
  2326. //
  2327. // Public I/O routine definitions
  2328. //
  2329. NTKERNELAPI
  2330. VOID
  2331. IoAcquireCancelSpinLock(
  2332. OUT PKIRQL Irql
  2333. );
  2334. // end_ntddk end_wdm end_nthal end_ntosp
  2335. NTKERNELAPI
  2336. VOID
  2337. IoAcquireVpbSpinLock(
  2338. OUT PKIRQL Irql
  2339. );
  2340. // begin_ntddk begin_nthal end_ntifs begin_ntosp
  2341. DECLSPEC_DEPRECATED_DDK // Use AllocateAdapterChannel
  2342. NTKERNELAPI
  2343. NTSTATUS
  2344. IoAllocateAdapterChannel(
  2345. IN PADAPTER_OBJECT AdapterObject,
  2346. IN PDEVICE_OBJECT DeviceObject,
  2347. IN ULONG NumberOfMapRegisters,
  2348. IN PDRIVER_CONTROL ExecutionRoutine,
  2349. IN PVOID Context
  2350. );
  2351. NTKERNELAPI
  2352. VOID
  2353. IoAllocateController(
  2354. IN PCONTROLLER_OBJECT ControllerObject,
  2355. IN PDEVICE_OBJECT DeviceObject,
  2356. IN PDRIVER_CONTROL ExecutionRoutine,
  2357. IN PVOID Context
  2358. );
  2359. // begin_wdm
  2360. NTKERNELAPI
  2361. NTSTATUS
  2362. IoAllocateDriverObjectExtension(
  2363. IN PDRIVER_OBJECT DriverObject,
  2364. IN PVOID ClientIdentificationAddress,
  2365. IN ULONG DriverObjectExtensionSize,
  2366. OUT PVOID *DriverObjectExtension
  2367. );
  2368. // begin_ntifs
  2369. NTKERNELAPI
  2370. PVOID
  2371. IoAllocateErrorLogEntry(
  2372. IN PVOID IoObject,
  2373. IN UCHAR EntrySize
  2374. );
  2375. NTKERNELAPI
  2376. PIRP
  2377. IoAllocateIrp(
  2378. IN CCHAR StackSize,
  2379. IN BOOLEAN ChargeQuota
  2380. );
  2381. NTKERNELAPI
  2382. PMDL
  2383. IoAllocateMdl(
  2384. IN PVOID VirtualAddress,
  2385. IN ULONG Length,
  2386. IN BOOLEAN SecondaryBuffer,
  2387. IN BOOLEAN ChargeQuota,
  2388. IN OUT PIRP Irp OPTIONAL
  2389. );
  2390. // end_wdm end_ntifs
  2391. //++
  2392. //
  2393. // VOID
  2394. // IoAssignArcName(
  2395. // IN PUNICODE_STRING ArcName,
  2396. // IN PUNICODE_STRING DeviceName
  2397. // )
  2398. //
  2399. // Routine Description:
  2400. //
  2401. // This routine is invoked by drivers of bootable media to create a symbolic
  2402. // link between the ARC name of their device and its NT name. This allows
  2403. // the system to determine which device in the system was actually booted
  2404. // from since the ARC firmware only deals in ARC names, and NT only deals
  2405. // in NT names.
  2406. //
  2407. // Arguments:
  2408. //
  2409. // ArcName - Supplies the Unicode string representing the ARC name.
  2410. //
  2411. // DeviceName - Supplies the name to which the ARCname refers.
  2412. //
  2413. // Return Value:
  2414. //
  2415. // None.
  2416. //
  2417. //--
  2418. #define IoAssignArcName( ArcName, DeviceName ) ( \
  2419. IoCreateSymbolicLink( (ArcName), (DeviceName) ) )
  2420. DECLSPEC_DEPRECATED_DDK // Use Pnp or IoReprtDetectedDevice
  2421. NTKERNELAPI
  2422. NTSTATUS
  2423. IoAssignResources (
  2424. IN PUNICODE_STRING RegistryPath,
  2425. IN PUNICODE_STRING DriverClassName OPTIONAL,
  2426. IN PDRIVER_OBJECT DriverObject,
  2427. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  2428. IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources,
  2429. IN OUT PCM_RESOURCE_LIST *AllocatedResources
  2430. );
  2431. // end_ntddk end_nthal end_ntosp
  2432. NTKERNELAPI
  2433. NTSTATUS
  2434. IoAsynchronousPageWrite(
  2435. IN PFILE_OBJECT FileObject,
  2436. IN PMDL MemoryDescriptorList,
  2437. IN PLARGE_INTEGER StartingOffset,
  2438. IN PIO_APC_ROUTINE ApcRoutine,
  2439. IN PVOID ApcContext,
  2440. OUT PIO_STATUS_BLOCK IoStatusBlock,
  2441. OUT PIRP *Irp OPTIONAL
  2442. );
  2443. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  2444. NTKERNELAPI
  2445. NTSTATUS
  2446. IoAttachDevice(
  2447. IN PDEVICE_OBJECT SourceDevice,
  2448. IN PUNICODE_STRING TargetDevice,
  2449. OUT PDEVICE_OBJECT *AttachedDevice
  2450. );
  2451. // end_wdm
  2452. DECLSPEC_DEPRECATED_DDK // Use IoAttachDeviceToDeviceStack
  2453. NTKERNELAPI
  2454. NTSTATUS
  2455. IoAttachDeviceByPointer(
  2456. IN PDEVICE_OBJECT SourceDevice,
  2457. IN PDEVICE_OBJECT TargetDevice
  2458. );
  2459. // begin_wdm
  2460. NTKERNELAPI
  2461. PDEVICE_OBJECT
  2462. IoAttachDeviceToDeviceStack(
  2463. IN PDEVICE_OBJECT SourceDevice,
  2464. IN PDEVICE_OBJECT TargetDevice
  2465. );
  2466. NTKERNELAPI
  2467. PIRP
  2468. IoBuildAsynchronousFsdRequest(
  2469. IN ULONG MajorFunction,
  2470. IN PDEVICE_OBJECT DeviceObject,
  2471. IN OUT PVOID Buffer OPTIONAL,
  2472. IN ULONG Length OPTIONAL,
  2473. IN PLARGE_INTEGER StartingOffset OPTIONAL,
  2474. IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL
  2475. );
  2476. NTKERNELAPI
  2477. PIRP
  2478. IoBuildDeviceIoControlRequest(
  2479. IN ULONG IoControlCode,
  2480. IN PDEVICE_OBJECT DeviceObject,
  2481. IN PVOID InputBuffer OPTIONAL,
  2482. IN ULONG InputBufferLength,
  2483. OUT PVOID OutputBuffer OPTIONAL,
  2484. IN ULONG OutputBufferLength,
  2485. IN BOOLEAN InternalDeviceIoControl,
  2486. IN PKEVENT Event,
  2487. OUT PIO_STATUS_BLOCK IoStatusBlock
  2488. );
  2489. NTKERNELAPI
  2490. VOID
  2491. IoBuildPartialMdl(
  2492. IN PMDL SourceMdl,
  2493. IN OUT PMDL TargetMdl,
  2494. IN PVOID VirtualAddress,
  2495. IN ULONG Length
  2496. );
  2497. typedef struct _BOOTDISK_INFORMATION {
  2498. LONGLONG BootPartitionOffset;
  2499. LONGLONG SystemPartitionOffset;
  2500. ULONG BootDeviceSignature;
  2501. ULONG SystemDeviceSignature;
  2502. } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION;
  2503. //
  2504. // This structure should follow the previous structure field for field.
  2505. //
  2506. typedef struct _BOOTDISK_INFORMATION_EX {
  2507. LONGLONG BootPartitionOffset;
  2508. LONGLONG SystemPartitionOffset;
  2509. ULONG BootDeviceSignature;
  2510. ULONG SystemDeviceSignature;
  2511. GUID BootDeviceGuid;
  2512. GUID SystemDeviceGuid;
  2513. BOOLEAN BootDeviceIsGpt;
  2514. BOOLEAN SystemDeviceIsGpt;
  2515. } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX;
  2516. NTKERNELAPI
  2517. NTSTATUS
  2518. IoGetBootDiskInformation(
  2519. IN OUT PBOOTDISK_INFORMATION BootDiskInformation,
  2520. IN ULONG Size
  2521. );
  2522. // end_ntddk end_nthal end_wdm end_ntifs end_ntosp
  2523. NTSTATUS
  2524. IoBuildPoDeviceNotifyList (
  2525. IN OUT PVOID Order
  2526. );
  2527. VOID
  2528. IoMovePoNotifyChildren(
  2529. IN PVOID Notify,
  2530. IN PVOID Order
  2531. );
  2532. PVOID
  2533. IoGetPoNotifyParent(
  2534. PVOID Notify
  2535. );
  2536. NTSTATUS
  2537. IoNotifyPowerOperationVetoed(
  2538. IN POWER_ACTION VetoedPowerOperation,
  2539. IN PDEVICE_OBJECT TargetedDeviceObject OPTIONAL,
  2540. IN PDEVICE_OBJECT VetoingDeviceObject
  2541. );
  2542. // begin_ntddk begin_nthal begin_wdm begin_ntifs begin_ntosp
  2543. NTKERNELAPI
  2544. PIRP
  2545. IoBuildSynchronousFsdRequest(
  2546. IN ULONG MajorFunction,
  2547. IN PDEVICE_OBJECT DeviceObject,
  2548. IN OUT PVOID Buffer OPTIONAL,
  2549. IN ULONG Length OPTIONAL,
  2550. IN PLARGE_INTEGER StartingOffset OPTIONAL,
  2551. IN PKEVENT Event,
  2552. OUT PIO_STATUS_BLOCK IoStatusBlock
  2553. );
  2554. NTKERNELAPI
  2555. NTSTATUS
  2556. FASTCALL
  2557. IofCallDriver(
  2558. IN PDEVICE_OBJECT DeviceObject,
  2559. IN OUT PIRP Irp
  2560. );
  2561. #define IoCallDriver(a,b) \
  2562. IofCallDriver(a,b)
  2563. NTKERNELAPI
  2564. BOOLEAN
  2565. IoCancelIrp(
  2566. IN PIRP Irp
  2567. );
  2568. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  2569. NTKERNELAPI
  2570. VOID
  2571. IoCancelThreadIo(
  2572. IN PETHREAD Thread
  2573. );
  2574. // begin_ntifs
  2575. NTKERNELAPI
  2576. NTSTATUS
  2577. IoCheckDesiredAccess(
  2578. IN OUT PACCESS_MASK DesiredAccess,
  2579. IN ACCESS_MASK GrantedAccess
  2580. );
  2581. NTKERNELAPI
  2582. NTSTATUS
  2583. IoCheckEaBufferValidity(
  2584. IN PFILE_FULL_EA_INFORMATION EaBuffer,
  2585. IN ULONG EaLength,
  2586. OUT PULONG ErrorOffset
  2587. );
  2588. NTKERNELAPI
  2589. NTSTATUS
  2590. IoCheckFunctionAccess(
  2591. IN ACCESS_MASK GrantedAccess,
  2592. IN UCHAR MajorFunction,
  2593. IN UCHAR MinorFunction,
  2594. IN ULONG IoControlCode,
  2595. IN PVOID Arg1 OPTIONAL,
  2596. IN PVOID Arg2 OPTIONAL
  2597. );
  2598. NTKERNELAPI
  2599. NTSTATUS
  2600. IoCheckQuerySetFileInformation(
  2601. IN FILE_INFORMATION_CLASS FileInformationClass,
  2602. IN ULONG Length,
  2603. IN BOOLEAN SetOperation
  2604. );
  2605. NTKERNELAPI
  2606. NTSTATUS
  2607. IoCheckQuerySetVolumeInformation(
  2608. IN FS_INFORMATION_CLASS FsInformationClass,
  2609. IN ULONG Length,
  2610. IN BOOLEAN SetOperation
  2611. );
  2612. NTKERNELAPI
  2613. NTSTATUS
  2614. IoCheckQuotaBufferValidity(
  2615. IN PFILE_QUOTA_INFORMATION QuotaBuffer,
  2616. IN ULONG QuotaLength,
  2617. OUT PULONG ErrorOffset
  2618. );
  2619. // begin_ntddk begin_wdm begin_nthal begin_ntosp
  2620. NTKERNELAPI
  2621. NTSTATUS
  2622. IoCheckShareAccess(
  2623. IN ACCESS_MASK DesiredAccess,
  2624. IN ULONG DesiredShareAccess,
  2625. IN OUT PFILE_OBJECT FileObject,
  2626. IN OUT PSHARE_ACCESS ShareAccess,
  2627. IN BOOLEAN Update
  2628. );
  2629. //
  2630. // This value should be returned from completion routines to continue
  2631. // completing the IRP upwards. Otherwise, STATUS_MORE_PROCESSING_REQUIRED
  2632. // should be returned.
  2633. //
  2634. #define STATUS_CONTINUE_COMPLETION STATUS_SUCCESS
  2635. //
  2636. // Completion routines can also use this enumeration in place of status codes.
  2637. //
  2638. typedef enum _IO_COMPLETION_ROUTINE_RESULT {
  2639. ContinueCompletion = STATUS_CONTINUE_COMPLETION,
  2640. StopCompletion = STATUS_MORE_PROCESSING_REQUIRED
  2641. } IO_COMPLETION_ROUTINE_RESULT, *PIO_COMPLETION_ROUTINE_RESULT;
  2642. NTKERNELAPI
  2643. VOID
  2644. FASTCALL
  2645. IofCompleteRequest(
  2646. IN PIRP Irp,
  2647. IN CCHAR PriorityBoost
  2648. );
  2649. #define IoCompleteRequest(a,b) \
  2650. IofCompleteRequest(a,b)
  2651. // end_ntifs
  2652. NTKERNELAPI
  2653. NTSTATUS
  2654. IoConnectInterrupt(
  2655. OUT PKINTERRUPT *InterruptObject,
  2656. IN PKSERVICE_ROUTINE ServiceRoutine,
  2657. IN PVOID ServiceContext,
  2658. IN PKSPIN_LOCK SpinLock OPTIONAL,
  2659. IN ULONG Vector,
  2660. IN KIRQL Irql,
  2661. IN KIRQL SynchronizeIrql,
  2662. IN KINTERRUPT_MODE InterruptMode,
  2663. IN BOOLEAN ShareVector,
  2664. IN KAFFINITY ProcessorEnableMask,
  2665. IN BOOLEAN FloatingSave
  2666. );
  2667. // end_wdm
  2668. NTKERNELAPI
  2669. PCONTROLLER_OBJECT
  2670. IoCreateController(
  2671. IN ULONG Size
  2672. );
  2673. // begin_wdm begin_ntifs
  2674. NTKERNELAPI
  2675. NTSTATUS
  2676. IoCreateDevice(
  2677. IN PDRIVER_OBJECT DriverObject,
  2678. IN ULONG DeviceExtensionSize,
  2679. IN PUNICODE_STRING DeviceName OPTIONAL,
  2680. IN DEVICE_TYPE DeviceType,
  2681. IN ULONG DeviceCharacteristics,
  2682. IN BOOLEAN Exclusive,
  2683. OUT PDEVICE_OBJECT *DeviceObject
  2684. );
  2685. #define WDM_MAJORVERSION 0x01
  2686. #define WDM_MINORVERSION 0x20
  2687. NTKERNELAPI
  2688. BOOLEAN
  2689. IoIsWdmVersionAvailable(
  2690. IN UCHAR MajorVersion,
  2691. IN UCHAR MinorVersion
  2692. );
  2693. // end_nthal
  2694. NTKERNELAPI
  2695. NTSTATUS
  2696. IoCreateFile(
  2697. OUT PHANDLE FileHandle,
  2698. IN ACCESS_MASK DesiredAccess,
  2699. IN POBJECT_ATTRIBUTES ObjectAttributes,
  2700. OUT PIO_STATUS_BLOCK IoStatusBlock,
  2701. IN PLARGE_INTEGER AllocationSize OPTIONAL,
  2702. IN ULONG FileAttributes,
  2703. IN ULONG ShareAccess,
  2704. IN ULONG Disposition,
  2705. IN ULONG CreateOptions,
  2706. IN PVOID EaBuffer OPTIONAL,
  2707. IN ULONG EaLength,
  2708. IN CREATE_FILE_TYPE CreateFileType,
  2709. IN PVOID ExtraCreateParameters OPTIONAL,
  2710. IN ULONG Options
  2711. );
  2712. // end_ntddk end_wdm end_ntosp
  2713. NTKERNELAPI
  2714. PFILE_OBJECT
  2715. IoCreateStreamFileObject(
  2716. IN PFILE_OBJECT FileObject OPTIONAL,
  2717. IN PDEVICE_OBJECT DeviceObject OPTIONAL
  2718. );
  2719. NTKERNELAPI
  2720. PFILE_OBJECT
  2721. IoCreateStreamFileObjectEx(
  2722. IN PFILE_OBJECT FileObject OPTIONAL,
  2723. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  2724. OUT PHANDLE FileObjectHandle OPTIONAL
  2725. );
  2726. NTKERNELAPI
  2727. PFILE_OBJECT
  2728. IoCreateStreamFileObjectLite(
  2729. IN PFILE_OBJECT FileObject OPTIONAL,
  2730. IN PDEVICE_OBJECT DeviceObject OPTIONAL
  2731. );
  2732. // begin_nthal begin_ntddk begin_wdm begin_ntosp
  2733. NTKERNELAPI
  2734. PKEVENT
  2735. IoCreateNotificationEvent(
  2736. IN PUNICODE_STRING EventName,
  2737. OUT PHANDLE EventHandle
  2738. );
  2739. NTKERNELAPI
  2740. NTSTATUS
  2741. IoCreateSymbolicLink(
  2742. IN PUNICODE_STRING SymbolicLinkName,
  2743. IN PUNICODE_STRING DeviceName
  2744. );
  2745. NTKERNELAPI
  2746. PKEVENT
  2747. IoCreateSynchronizationEvent(
  2748. IN PUNICODE_STRING EventName,
  2749. OUT PHANDLE EventHandle
  2750. );
  2751. NTKERNELAPI
  2752. NTSTATUS
  2753. IoCreateUnprotectedSymbolicLink(
  2754. IN PUNICODE_STRING SymbolicLinkName,
  2755. IN PUNICODE_STRING DeviceName
  2756. );
  2757. // end_wdm
  2758. //++
  2759. //
  2760. // VOID
  2761. // IoDeassignArcName(
  2762. // IN PUNICODE_STRING ArcName
  2763. // )
  2764. //
  2765. // Routine Description:
  2766. //
  2767. // This routine is invoked by drivers to deassign an ARC name that they
  2768. // created to a device. This is generally only called if the driver is
  2769. // deleting the device object, which means that the driver is probably
  2770. // unloading.
  2771. //
  2772. // Arguments:
  2773. //
  2774. // ArcName - Supplies the ARC name to be removed.
  2775. //
  2776. // Return Value:
  2777. //
  2778. // None.
  2779. //
  2780. //--
  2781. #define IoDeassignArcName( ArcName ) ( \
  2782. IoDeleteSymbolicLink( (ArcName) ) )
  2783. // end_ntifs
  2784. NTKERNELAPI
  2785. VOID
  2786. IoDeleteController(
  2787. IN PCONTROLLER_OBJECT ControllerObject
  2788. );
  2789. // begin_wdm begin_ntifs
  2790. NTKERNELAPI
  2791. VOID
  2792. IoDeleteDevice(
  2793. IN PDEVICE_OBJECT DeviceObject
  2794. );
  2795. NTKERNELAPI
  2796. NTSTATUS
  2797. IoDeleteSymbolicLink(
  2798. IN PUNICODE_STRING SymbolicLinkName
  2799. );
  2800. NTKERNELAPI
  2801. VOID
  2802. IoDetachDevice(
  2803. IN OUT PDEVICE_OBJECT TargetDevice
  2804. );
  2805. // end_ntifs
  2806. NTKERNELAPI
  2807. VOID
  2808. IoDisconnectInterrupt(
  2809. IN PKINTERRUPT InterruptObject
  2810. );
  2811. // end_ntddk end_wdm end_nthal
  2812. NTKERNELAPI
  2813. VOID
  2814. IoEnqueueIrp(
  2815. IN PIRP Irp
  2816. );
  2817. // end_ntosp
  2818. NTKERNELAPI // ntifs
  2819. BOOLEAN // ntifs
  2820. IoFastQueryNetworkAttributes( // ntifs
  2821. IN POBJECT_ATTRIBUTES ObjectAttributes, // ntifs
  2822. IN ACCESS_MASK DesiredAccess, // ntifs
  2823. IN ULONG OpenOptions, // ntifs
  2824. OUT PIO_STATUS_BLOCK IoStatus, // ntifs
  2825. OUT PFILE_NETWORK_OPEN_INFORMATION Buffer // ntifs
  2826. ); // ntifs
  2827. // begin_ntddk begin_nthal begin_ntosp
  2828. NTKERNELAPI
  2829. VOID
  2830. IoFreeController(
  2831. IN PCONTROLLER_OBJECT ControllerObject
  2832. );
  2833. // begin_wdm begin_ntifs
  2834. NTKERNELAPI
  2835. VOID
  2836. IoFreeIrp(
  2837. IN PIRP Irp
  2838. );
  2839. NTKERNELAPI
  2840. VOID
  2841. IoFreeMdl(
  2842. IN PMDL Mdl
  2843. );
  2844. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  2845. VOID
  2846. IoFreePoDeviceNotifyList (
  2847. IN OUT PVOID Order
  2848. );
  2849. NTSTATUS
  2850. IoGetDeviceInstanceName(
  2851. IN PDEVICE_OBJECT PhysicalDeviceObject,
  2852. OUT PUNICODE_STRING InstanceName
  2853. );
  2854. NTSTATUS
  2855. IoGetLegacyVetoList(
  2856. OUT PWSTR *VetoList OPTIONAL,
  2857. OUT PPNP_VETO_TYPE VetoType
  2858. );
  2859. // begin_ntifs begin_ntosp
  2860. NTKERNELAPI
  2861. PDEVICE_OBJECT
  2862. IoGetAttachedDevice(
  2863. IN PDEVICE_OBJECT DeviceObject
  2864. );
  2865. NTKERNELAPI // ntddk wdm nthal
  2866. PDEVICE_OBJECT // ntddk wdm nthal
  2867. IoGetAttachedDeviceReference( // ntddk wdm nthal
  2868. IN PDEVICE_OBJECT DeviceObject // ntddk wdm nthal
  2869. ); // ntddk wdm nthal
  2870. // ntddk wdm nthal
  2871. NTKERNELAPI
  2872. PDEVICE_OBJECT
  2873. IoGetBaseFileSystemDeviceObject(
  2874. IN PFILE_OBJECT FileObject
  2875. );
  2876. NTKERNELAPI // ntddk nthal ntosp
  2877. PCONFIGURATION_INFORMATION // ntddk nthal ntosp
  2878. IoGetConfigurationInformation( VOID ); // ntddk nthal ntosp
  2879. // begin_ntddk begin_wdm begin_nthal
  2880. //++
  2881. //
  2882. // PIO_STACK_LOCATION
  2883. // IoGetCurrentIrpStackLocation(
  2884. // IN PIRP Irp
  2885. // )
  2886. //
  2887. // Routine Description:
  2888. //
  2889. // This routine is invoked to return a pointer to the current stack location
  2890. // in an I/O Request Packet (IRP).
  2891. //
  2892. // Arguments:
  2893. //
  2894. // Irp - Pointer to the I/O Request Packet.
  2895. //
  2896. // Return Value:
  2897. //
  2898. // The function value is a pointer to the current stack location in the
  2899. // packet.
  2900. //
  2901. //--
  2902. #define IoGetCurrentIrpStackLocation( Irp ) ( (Irp)->Tail.Overlay.CurrentStackLocation )
  2903. // end_nthal end_wdm
  2904. NTKERNELAPI
  2905. PDEVICE_OBJECT
  2906. IoGetDeviceToVerify(
  2907. IN PETHREAD Thread
  2908. );
  2909. // begin_wdm
  2910. NTKERNELAPI
  2911. PVOID
  2912. IoGetDriverObjectExtension(
  2913. IN PDRIVER_OBJECT DriverObject,
  2914. IN PVOID ClientIdentificationAddress
  2915. );
  2916. NTKERNELAPI
  2917. PEPROCESS
  2918. IoGetCurrentProcess(
  2919. VOID
  2920. );
  2921. // begin_nthal
  2922. NTKERNELAPI
  2923. NTSTATUS
  2924. IoGetDeviceObjectPointer(
  2925. IN PUNICODE_STRING ObjectName,
  2926. IN ACCESS_MASK DesiredAccess,
  2927. OUT PFILE_OBJECT *FileObject,
  2928. OUT PDEVICE_OBJECT *DeviceObject
  2929. );
  2930. NTKERNELAPI
  2931. struct _DMA_ADAPTER *
  2932. IoGetDmaAdapter(
  2933. IN PDEVICE_OBJECT PhysicalDeviceObject, OPTIONAL // required for PnP drivers
  2934. IN struct _DEVICE_DESCRIPTION *DeviceDescription,
  2935. IN OUT PULONG NumberOfMapRegisters
  2936. );
  2937. NTKERNELAPI
  2938. BOOLEAN
  2939. IoForwardIrpSynchronously(
  2940. IN PDEVICE_OBJECT DeviceObject,
  2941. IN PIRP Irp
  2942. );
  2943. #define IoForwardAndCatchIrp IoForwardIrpSynchronously
  2944. // end_wdm
  2945. NTKERNELAPI
  2946. PGENERIC_MAPPING
  2947. IoGetFileObjectGenericMapping(
  2948. VOID
  2949. );
  2950. // end_nthal
  2951. // begin_wdm
  2952. //++
  2953. //
  2954. // ULONG
  2955. // IoGetFunctionCodeFromCtlCode(
  2956. // IN ULONG ControlCode
  2957. // )
  2958. //
  2959. // Routine Description:
  2960. //
  2961. // This routine extracts the function code from IOCTL and FSCTL function
  2962. // control codes.
  2963. // This routine should only be used by kernel mode code.
  2964. //
  2965. // Arguments:
  2966. //
  2967. // ControlCode - A function control code (IOCTL or FSCTL) from which the
  2968. // function code must be extracted.
  2969. //
  2970. // Return Value:
  2971. //
  2972. // The extracted function code.
  2973. //
  2974. // Note:
  2975. //
  2976. // The CTL_CODE macro, used to create IOCTL and FSCTL function control
  2977. // codes, is defined in ntioapi.h
  2978. //
  2979. //--
  2980. #define IoGetFunctionCodeFromCtlCode( ControlCode ) (\
  2981. ( ControlCode >> 2) & 0x00000FFF )
  2982. // begin_nthal
  2983. NTKERNELAPI
  2984. PVOID
  2985. IoGetInitialStack(
  2986. VOID
  2987. );
  2988. NTKERNELAPI
  2989. VOID
  2990. IoGetStackLimits (
  2991. OUT PULONG_PTR LowLimit,
  2992. OUT PULONG_PTR HighLimit
  2993. );
  2994. //
  2995. // The following function is used to tell the caller how much stack is available
  2996. //
  2997. FORCEINLINE
  2998. ULONG_PTR
  2999. IoGetRemainingStackSize (
  3000. VOID
  3001. )
  3002. {
  3003. ULONG_PTR Top;
  3004. ULONG_PTR Bottom;
  3005. IoGetStackLimits( &Bottom, &Top );
  3006. return((ULONG_PTR)(&Top) - Bottom );
  3007. }
  3008. //++
  3009. //
  3010. // PIO_STACK_LOCATION
  3011. // IoGetNextIrpStackLocation(
  3012. // IN PIRP Irp
  3013. // )
  3014. //
  3015. // Routine Description:
  3016. //
  3017. // This routine is invoked to return a pointer to the next stack location
  3018. // in an I/O Request Packet (IRP).
  3019. //
  3020. // Arguments:
  3021. //
  3022. // Irp - Pointer to the I/O Request Packet.
  3023. //
  3024. // Return Value:
  3025. //
  3026. // The function value is a pointer to the next stack location in the packet.
  3027. //
  3028. //--
  3029. #define IoGetNextIrpStackLocation( Irp ) (\
  3030. (Irp)->Tail.Overlay.CurrentStackLocation - 1 )
  3031. NTKERNELAPI
  3032. PDEVICE_OBJECT
  3033. IoGetRelatedDeviceObject(
  3034. IN PFILE_OBJECT FileObject
  3035. );
  3036. // end_ntddk end_wdm end_nthal
  3037. NTKERNELAPI
  3038. ULONG
  3039. IoGetRequestorProcessId(
  3040. IN PIRP Irp
  3041. );
  3042. NTKERNELAPI
  3043. PEPROCESS
  3044. IoGetRequestorProcess(
  3045. IN PIRP Irp
  3046. );
  3047. // end_ntosp
  3048. NTKERNELAPI
  3049. PIRP
  3050. IoGetTopLevelIrp(
  3051. VOID
  3052. );
  3053. // begin_ntddk begin_wdm begin_nthal begin_ntosp
  3054. //++
  3055. //
  3056. // VOID
  3057. // IoInitializeDpcRequest(
  3058. // IN PDEVICE_OBJECT DeviceObject,
  3059. // IN PIO_DPC_ROUTINE DpcRoutine
  3060. // )
  3061. //
  3062. // Routine Description:
  3063. //
  3064. // This routine is invoked to initialize the DPC in a device object for a
  3065. // device driver during its initialization routine. The DPC is used later
  3066. // when the driver interrupt service routine requests that a DPC routine
  3067. // be queued for later execution.
  3068. //
  3069. // Arguments:
  3070. //
  3071. // DeviceObject - Pointer to the device object that the request is for.
  3072. //
  3073. // DpcRoutine - Address of the driver's DPC routine to be executed when
  3074. // the DPC is dequeued for processing.
  3075. //
  3076. // Return Value:
  3077. //
  3078. // None.
  3079. //
  3080. //--
  3081. #define IoInitializeDpcRequest( DeviceObject, DpcRoutine ) (\
  3082. KeInitializeDpc( &(DeviceObject)->Dpc, \
  3083. (PKDEFERRED_ROUTINE) (DpcRoutine), \
  3084. (DeviceObject) ) )
  3085. NTKERNELAPI
  3086. VOID
  3087. IoInitializeIrp(
  3088. IN OUT PIRP Irp,
  3089. IN USHORT PacketSize,
  3090. IN CCHAR StackSize
  3091. );
  3092. NTKERNELAPI
  3093. NTSTATUS
  3094. IoInitializeTimer(
  3095. IN PDEVICE_OBJECT DeviceObject,
  3096. IN PIO_TIMER_ROUTINE TimerRoutine,
  3097. IN PVOID Context
  3098. );
  3099. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  3100. // begin_ntddk begin_wdm begin_ntifs begin_ntosp
  3101. NTKERNELAPI
  3102. VOID
  3103. IoReuseIrp(
  3104. IN OUT PIRP Irp,
  3105. IN NTSTATUS Iostatus
  3106. );
  3107. // end_wdm
  3108. NTKERNELAPI
  3109. VOID
  3110. IoCancelFileOpen(
  3111. IN PDEVICE_OBJECT DeviceObject,
  3112. IN PFILE_OBJECT FileObject
  3113. );
  3114. // end_ntddk end_ntifs end_ntosp
  3115. NTKERNELAPI
  3116. BOOLEAN
  3117. IoInitSystem(
  3118. PLOADER_PARAMETER_BLOCK LoaderBlock
  3119. );
  3120. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  3121. //++
  3122. //
  3123. // BOOLEAN
  3124. // IoIsErrorUserInduced(
  3125. // IN NTSTATUS Status
  3126. // )
  3127. //
  3128. // Routine Description:
  3129. //
  3130. // This routine is invoked to determine if an error was as a
  3131. // result of user actions. Typically these error are related
  3132. // to removable media and will result in a pop-up.
  3133. //
  3134. // Arguments:
  3135. //
  3136. // Status - The status value to check.
  3137. //
  3138. // Return Value:
  3139. // The function value is TRUE if the user induced the error,
  3140. // otherwise FALSE is returned.
  3141. //
  3142. //--
  3143. #define IoIsErrorUserInduced( Status ) ((BOOLEAN) \
  3144. (((Status) == STATUS_DEVICE_NOT_READY) || \
  3145. ((Status) == STATUS_IO_TIMEOUT) || \
  3146. ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \
  3147. ((Status) == STATUS_NO_MEDIA_IN_DEVICE) || \
  3148. ((Status) == STATUS_VERIFY_REQUIRED) || \
  3149. ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \
  3150. ((Status) == STATUS_WRONG_VOLUME)))
  3151. // end_ntddk end_wdm end_nthal end_ntosp
  3152. //++
  3153. //
  3154. // BOOLEAN
  3155. // IoIsFileOpenedExclusively(
  3156. // IN PFILE_OBJECT FileObject
  3157. // )
  3158. //
  3159. // Routine Description:
  3160. //
  3161. // This routine is invoked to determine whether the file open represented
  3162. // by the specified file object is opened exclusively.
  3163. //
  3164. // Arguments:
  3165. //
  3166. // FileObject - Pointer to the file object that represents the open instance
  3167. // of the target file to be tested for exclusive access.
  3168. //
  3169. // Return Value:
  3170. //
  3171. // The function value is TRUE if the open instance of the file is exclusive;
  3172. // otherwise FALSE is returned.
  3173. //
  3174. //--
  3175. #define IoIsFileOpenedExclusively( FileObject ) (\
  3176. (BOOLEAN) !((FileObject)->SharedRead || (FileObject)->SharedWrite || (FileObject)->SharedDelete))
  3177. NTKERNELAPI
  3178. BOOLEAN
  3179. IoIsOperationSynchronous(
  3180. IN PIRP Irp
  3181. );
  3182. NTKERNELAPI
  3183. BOOLEAN
  3184. IoIsSystemThread(
  3185. IN PETHREAD Thread
  3186. );
  3187. NTKERNELAPI
  3188. BOOLEAN
  3189. IoIsValidNameGraftingBuffer(
  3190. IN PIRP Irp,
  3191. IN PREPARSE_DATA_BUFFER ReparseBuffer
  3192. );
  3193. // begin_ntddk begin_nthal begin_ntosp
  3194. NTKERNELAPI
  3195. PIRP
  3196. IoMakeAssociatedIrp(
  3197. IN PIRP Irp,
  3198. IN CCHAR StackSize
  3199. );
  3200. // begin_wdm
  3201. //++
  3202. //
  3203. // VOID
  3204. // IoMarkIrpPending(
  3205. // IN OUT PIRP Irp
  3206. // )
  3207. //
  3208. // Routine Description:
  3209. //
  3210. // This routine marks the specified I/O Request Packet (IRP) to indicate
  3211. // that an initial status of STATUS_PENDING was returned to the caller.
  3212. // This is used so that I/O completion can determine whether or not to
  3213. // fully complete the I/O operation requested by the packet.
  3214. //
  3215. // Arguments:
  3216. //
  3217. // Irp - Pointer to the I/O Request Packet to be marked pending.
  3218. //
  3219. // Return Value:
  3220. //
  3221. // None.
  3222. //
  3223. //--
  3224. #define IoMarkIrpPending( Irp ) ( \
  3225. IoGetCurrentIrpStackLocation( (Irp) )->Control |= SL_PENDING_RETURNED )
  3226. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  3227. NTKERNELAPI
  3228. BOOLEAN
  3229. IoPageFileCreated(
  3230. IN HANDLE FileHandle
  3231. );
  3232. NTKERNELAPI // ntifs
  3233. NTSTATUS // ntifs
  3234. IoPageRead( // ntifs
  3235. IN PFILE_OBJECT FileObject, // ntifs
  3236. IN PMDL MemoryDescriptorList, // ntifs
  3237. IN PLARGE_INTEGER StartingOffset, // ntifs
  3238. IN PKEVENT Event, // ntifs
  3239. OUT PIO_STATUS_BLOCK IoStatusBlock // ntifs
  3240. ); // ntifs
  3241. NTKERNELAPI
  3242. NTSTATUS
  3243. IoAsynchronousPageRead(
  3244. IN PFILE_OBJECT FileObject,
  3245. IN PMDL MemoryDescriptorList,
  3246. IN PLARGE_INTEGER StartingOffset,
  3247. IN PKEVENT Event,
  3248. OUT PIO_STATUS_BLOCK IoStatusBlock
  3249. );
  3250. // begin_ntddk begin_ntosp
  3251. DECLSPEC_DEPRECATED_DDK // Use IoGetDeviceProperty
  3252. NTKERNELAPI
  3253. NTSTATUS
  3254. IoQueryDeviceDescription(
  3255. IN PINTERFACE_TYPE BusType OPTIONAL,
  3256. IN PULONG BusNumber OPTIONAL,
  3257. IN PCONFIGURATION_TYPE ControllerType OPTIONAL,
  3258. IN PULONG ControllerNumber OPTIONAL,
  3259. IN PCONFIGURATION_TYPE PeripheralType OPTIONAL,
  3260. IN PULONG PeripheralNumber OPTIONAL,
  3261. IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
  3262. IN PVOID Context
  3263. );
  3264. // end_ntddk end_ntosp
  3265. // begin_ntifs
  3266. NTSTATUS
  3267. IoQueryFileDosDeviceName(
  3268. IN PFILE_OBJECT FileObject,
  3269. OUT POBJECT_NAME_INFORMATION *ObjectNameInformation
  3270. );
  3271. NTKERNELAPI
  3272. NTSTATUS
  3273. IoQueryFileInformation(
  3274. IN PFILE_OBJECT FileObject,
  3275. IN FILE_INFORMATION_CLASS FileInformationClass,
  3276. IN ULONG Length,
  3277. OUT PVOID FileInformation,
  3278. OUT PULONG ReturnedLength
  3279. );
  3280. NTKERNELAPI
  3281. NTSTATUS
  3282. IoQueryVolumeInformation(
  3283. IN PFILE_OBJECT FileObject,
  3284. IN FS_INFORMATION_CLASS FsInformationClass,
  3285. IN ULONG Length,
  3286. OUT PVOID FsInformation,
  3287. OUT PULONG ReturnedLength
  3288. );
  3289. // begin_ntosp
  3290. NTKERNELAPI
  3291. VOID
  3292. IoQueueThreadIrp(
  3293. IN PIRP Irp
  3294. );
  3295. // end_ntosp
  3296. // begin_ntddk begin_nthal begin_ntosp
  3297. NTKERNELAPI
  3298. VOID
  3299. IoRaiseHardError(
  3300. IN PIRP Irp,
  3301. IN PVPB Vpb OPTIONAL,
  3302. IN PDEVICE_OBJECT RealDeviceObject
  3303. );
  3304. NTKERNELAPI
  3305. BOOLEAN
  3306. IoRaiseInformationalHardError(
  3307. IN NTSTATUS ErrorStatus,
  3308. IN PUNICODE_STRING String OPTIONAL,
  3309. IN PKTHREAD Thread OPTIONAL
  3310. );
  3311. NTKERNELAPI
  3312. BOOLEAN
  3313. IoSetThreadHardErrorMode(
  3314. IN BOOLEAN EnableHardErrors
  3315. );
  3316. NTKERNELAPI
  3317. VOID
  3318. IoRegisterBootDriverReinitialization(
  3319. IN PDRIVER_OBJECT DriverObject,
  3320. IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
  3321. IN PVOID Context
  3322. );
  3323. NTKERNELAPI
  3324. VOID
  3325. IoRegisterDriverReinitialization(
  3326. IN PDRIVER_OBJECT DriverObject,
  3327. IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
  3328. IN PVOID Context
  3329. );
  3330. // end_ntddk end_nthal end_ntosp
  3331. NTKERNELAPI
  3332. VOID
  3333. IoRegisterFileSystem(
  3334. IN OUT PDEVICE_OBJECT DeviceObject
  3335. );
  3336. NTKERNELAPI
  3337. NTSTATUS
  3338. IoRegisterFsRegistrationChange(
  3339. IN PDRIVER_OBJECT DriverObject,
  3340. IN PDRIVER_FS_NOTIFICATION DriverNotificationRoutine
  3341. );
  3342. // begin_ntddk begin_nthal begin_ntosp
  3343. NTKERNELAPI
  3344. NTSTATUS
  3345. IoRegisterShutdownNotification(
  3346. IN PDEVICE_OBJECT DeviceObject
  3347. );
  3348. NTKERNELAPI
  3349. NTSTATUS
  3350. IoRegisterLastChanceShutdownNotification(
  3351. IN PDEVICE_OBJECT DeviceObject
  3352. );
  3353. // begin_wdm
  3354. NTKERNELAPI
  3355. VOID
  3356. IoReleaseCancelSpinLock(
  3357. IN KIRQL Irql
  3358. );
  3359. // end_ntddk end_nthal end_wdm end_ntosp
  3360. NTKERNELAPI
  3361. VOID
  3362. IoReleaseVpbSpinLock(
  3363. IN KIRQL Irql
  3364. );
  3365. // begin_ntddk begin_nthal begin_ntosp
  3366. NTKERNELAPI
  3367. VOID
  3368. IoRemoveShareAccess(
  3369. IN PFILE_OBJECT FileObject,
  3370. IN OUT PSHARE_ACCESS ShareAccess
  3371. );
  3372. // end_ntddk end_ntifs end_ntosp
  3373. NTKERNELAPI
  3374. NTSTATUS
  3375. IoReportHalResourceUsage(
  3376. IN PUNICODE_STRING HalName,
  3377. IN PCM_RESOURCE_LIST RawResourceList,
  3378. IN PCM_RESOURCE_LIST TranslatedResourceList,
  3379. IN ULONG ResourceListSize
  3380. );
  3381. // begin_ntddk begin_ntifs begin_ntosp
  3382. DECLSPEC_DEPRECATED_DDK // Use IoReportResourceForDetection
  3383. NTKERNELAPI
  3384. NTSTATUS
  3385. IoReportResourceUsage(
  3386. IN PUNICODE_STRING DriverClassName OPTIONAL,
  3387. IN PDRIVER_OBJECT DriverObject,
  3388. IN PCM_RESOURCE_LIST DriverList OPTIONAL,
  3389. IN ULONG DriverListSize OPTIONAL,
  3390. IN PDEVICE_OBJECT DeviceObject,
  3391. IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
  3392. IN ULONG DeviceListSize OPTIONAL,
  3393. IN BOOLEAN OverrideConflict,
  3394. OUT PBOOLEAN ConflictDetected
  3395. );
  3396. // begin_wdm
  3397. //++
  3398. //
  3399. // VOID
  3400. // IoRequestDpc(
  3401. // IN PDEVICE_OBJECT DeviceObject,
  3402. // IN PIRP Irp,
  3403. // IN PVOID Context
  3404. // )
  3405. //
  3406. // Routine Description:
  3407. //
  3408. // This routine is invoked by the device driver's interrupt service routine
  3409. // to request that a DPC routine be queued for later execution at a lower
  3410. // IRQL.
  3411. //
  3412. // Arguments:
  3413. //
  3414. // DeviceObject - Device object for which the request is being processed.
  3415. //
  3416. // Irp - Pointer to the current I/O Request Packet (IRP) for the specified
  3417. // device.
  3418. //
  3419. // Context - Provides a general context parameter to be passed to the
  3420. // DPC routine.
  3421. //
  3422. // Return Value:
  3423. //
  3424. // None.
  3425. //
  3426. //--
  3427. #define IoRequestDpc( DeviceObject, Irp, Context ) ( \
  3428. KeInsertQueueDpc( &(DeviceObject)->Dpc, (Irp), (Context) ) )
  3429. //++
  3430. //
  3431. // PDRIVER_CANCEL
  3432. // IoSetCancelRoutine(
  3433. // IN PIRP Irp,
  3434. // IN PDRIVER_CANCEL CancelRoutine
  3435. // )
  3436. //
  3437. // Routine Description:
  3438. //
  3439. // This routine is invoked to set the address of a cancel routine which
  3440. // is to be invoked when an I/O packet has been canceled.
  3441. //
  3442. // Arguments:
  3443. //
  3444. // Irp - Pointer to the I/O Request Packet itself.
  3445. //
  3446. // CancelRoutine - Address of the cancel routine that is to be invoked
  3447. // if the IRP is cancelled.
  3448. //
  3449. // Return Value:
  3450. //
  3451. // Previous value of CancelRoutine field in the IRP.
  3452. //
  3453. //--
  3454. #define IoSetCancelRoutine( Irp, NewCancelRoutine ) ( \
  3455. (PDRIVER_CANCEL) InterlockedExchangePointer( (PVOID *) &(Irp)->CancelRoutine, (PVOID) (NewCancelRoutine) ) )
  3456. //++
  3457. //
  3458. // VOID
  3459. // IoSetCompletionRoutine(
  3460. // IN PIRP Irp,
  3461. // IN PIO_COMPLETION_ROUTINE CompletionRoutine,
  3462. // IN PVOID Context,
  3463. // IN BOOLEAN InvokeOnSuccess,
  3464. // IN BOOLEAN InvokeOnError,
  3465. // IN BOOLEAN InvokeOnCancel
  3466. // )
  3467. //
  3468. // Routine Description:
  3469. //
  3470. // This routine is invoked to set the address of a completion routine which
  3471. // is to be invoked when an I/O packet has been completed by a lower-level
  3472. // driver.
  3473. //
  3474. // Arguments:
  3475. //
  3476. // Irp - Pointer to the I/O Request Packet itself.
  3477. //
  3478. // CompletionRoutine - Address of the completion routine that is to be
  3479. // invoked once the next level driver completes the packet.
  3480. //
  3481. // Context - Specifies a context parameter to be passed to the completion
  3482. // routine.
  3483. //
  3484. // InvokeOnSuccess - Specifies that the completion routine is invoked when the
  3485. // operation is successfully completed.
  3486. //
  3487. // InvokeOnError - Specifies that the completion routine is invoked when the
  3488. // operation completes with an error status.
  3489. //
  3490. // InvokeOnCancel - Specifies that the completion routine is invoked when the
  3491. // operation is being canceled.
  3492. //
  3493. // Return Value:
  3494. //
  3495. // None.
  3496. //
  3497. //--
  3498. #define IoSetCompletionRoutine( Irp, Routine, CompletionContext, Success, Error, Cancel ) { \
  3499. PIO_STACK_LOCATION __irpSp; \
  3500. ASSERT( (Success) | (Error) | (Cancel) ? (Routine) != NULL : TRUE ); \
  3501. __irpSp = IoGetNextIrpStackLocation( (Irp) ); \
  3502. __irpSp->CompletionRoutine = (Routine); \
  3503. __irpSp->Context = (CompletionContext); \
  3504. __irpSp->Control = 0; \
  3505. if ((Success)) { __irpSp->Control = SL_INVOKE_ON_SUCCESS; } \
  3506. if ((Error)) { __irpSp->Control |= SL_INVOKE_ON_ERROR; } \
  3507. if ((Cancel)) { __irpSp->Control |= SL_INVOKE_ON_CANCEL; } }
  3508. NTSTATUS
  3509. IoSetCompletionRoutineEx(
  3510. IN PDEVICE_OBJECT DeviceObject,
  3511. IN PIRP Irp,
  3512. IN PIO_COMPLETION_ROUTINE CompletionRoutine,
  3513. IN PVOID Context,
  3514. IN BOOLEAN InvokeOnSuccess,
  3515. IN BOOLEAN InvokeOnError,
  3516. IN BOOLEAN InvokeOnCancel
  3517. );
  3518. // end_ntddk end_wdm end_nthal end_ntosp
  3519. NTKERNELAPI
  3520. VOID
  3521. IoSetDeviceToVerify(
  3522. IN PETHREAD Thread,
  3523. IN PDEVICE_OBJECT DeviceObject
  3524. );
  3525. // begin_ntddk begin_nthal begin_ntosp
  3526. NTKERNELAPI
  3527. VOID
  3528. IoSetHardErrorOrVerifyDevice(
  3529. IN PIRP Irp,
  3530. IN PDEVICE_OBJECT DeviceObject
  3531. );
  3532. // end_ntddk end_nthal
  3533. NTKERNELAPI
  3534. NTSTATUS
  3535. IoSetInformation(
  3536. IN PFILE_OBJECT FileObject,
  3537. IN FILE_INFORMATION_CLASS FileInformationClass,
  3538. IN ULONG Length,
  3539. IN PVOID FileInformation
  3540. );
  3541. // end_ntosp
  3542. // begin_ntddk begin_wdm begin_nthal begin_ntosp
  3543. //++
  3544. //
  3545. // VOID
  3546. // IoSetNextIrpStackLocation (
  3547. // IN OUT PIRP Irp
  3548. // )
  3549. //
  3550. // Routine Description:
  3551. //
  3552. // This routine is invoked to set the current IRP stack location to
  3553. // the next stack location, i.e. it "pushes" the stack.
  3554. //
  3555. // Arguments:
  3556. //
  3557. // Irp - Pointer to the I/O Request Packet (IRP).
  3558. //
  3559. // Return Value:
  3560. //
  3561. // None.
  3562. //
  3563. //--
  3564. #define IoSetNextIrpStackLocation( Irp ) { \
  3565. (Irp)->CurrentLocation--; \
  3566. (Irp)->Tail.Overlay.CurrentStackLocation--; }
  3567. //++
  3568. //
  3569. // VOID
  3570. // IoCopyCurrentIrpStackLocationToNext(
  3571. // IN PIRP Irp
  3572. // )
  3573. //
  3574. // Routine Description:
  3575. //
  3576. // This routine is invoked to copy the IRP stack arguments and file
  3577. // pointer from the current IrpStackLocation to the next
  3578. // in an I/O Request Packet (IRP).
  3579. //
  3580. // If the caller wants to call IoCallDriver with a completion routine
  3581. // but does not wish to change the arguments otherwise,
  3582. // the caller first calls IoCopyCurrentIrpStackLocationToNext,
  3583. // then IoSetCompletionRoutine, then IoCallDriver.
  3584. //
  3585. // Arguments:
  3586. //
  3587. // Irp - Pointer to the I/O Request Packet.
  3588. //
  3589. // Return Value:
  3590. //
  3591. // None.
  3592. //
  3593. //--
  3594. #define IoCopyCurrentIrpStackLocationToNext( Irp ) { \
  3595. PIO_STACK_LOCATION __irpSp; \
  3596. PIO_STACK_LOCATION __nextIrpSp; \
  3597. __irpSp = IoGetCurrentIrpStackLocation( (Irp) ); \
  3598. __nextIrpSp = IoGetNextIrpStackLocation( (Irp) ); \
  3599. RtlCopyMemory( __nextIrpSp, __irpSp, FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); \
  3600. __nextIrpSp->Control = 0; }
  3601. //++
  3602. //
  3603. // VOID
  3604. // IoSkipCurrentIrpStackLocation (
  3605. // IN PIRP Irp
  3606. // )
  3607. //
  3608. // Routine Description:
  3609. //
  3610. // This routine is invoked to increment the current stack location of
  3611. // a given IRP.
  3612. //
  3613. // If the caller wishes to call the next driver in a stack, and does not
  3614. // wish to change the arguments, nor does he wish to set a completion
  3615. // routine, then the caller first calls IoSkipCurrentIrpStackLocation
  3616. // and the calls IoCallDriver.
  3617. //
  3618. // Arguments:
  3619. //
  3620. // Irp - Pointer to the I/O Request Packet.
  3621. //
  3622. // Return Value:
  3623. //
  3624. // None
  3625. //
  3626. //--
  3627. #define IoSkipCurrentIrpStackLocation( Irp ) { \
  3628. (Irp)->CurrentLocation++; \
  3629. (Irp)->Tail.Overlay.CurrentStackLocation++; }
  3630. NTKERNELAPI
  3631. VOID
  3632. IoSetShareAccess(
  3633. IN ACCESS_MASK DesiredAccess,
  3634. IN ULONG DesiredShareAccess,
  3635. IN OUT PFILE_OBJECT FileObject,
  3636. OUT PSHARE_ACCESS ShareAccess
  3637. );
  3638. // end_ntddk end_wdm end_nthal end_ntosp
  3639. NTKERNELAPI
  3640. VOID
  3641. IoSetTopLevelIrp(
  3642. IN PIRP Irp
  3643. );
  3644. // end_ntifs
  3645. // begin_ntddk begin_wdm begin_ntosp
  3646. typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
  3647. typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
  3648. BOOLEAN Removed;
  3649. BOOLEAN Reserved [3];
  3650. LONG IoCount;
  3651. KEVENT RemoveEvent;
  3652. } IO_REMOVE_LOCK_COMMON_BLOCK;
  3653. typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
  3654. LONG Signature;
  3655. LONG HighWatermark;
  3656. LONGLONG MaxLockedTicks;
  3657. LONG AllocateTag;
  3658. LIST_ENTRY LockList;
  3659. KSPIN_LOCK Spin;
  3660. LONG LowMemoryCount;
  3661. ULONG Reserved1[4];
  3662. PVOID Reserved2;
  3663. PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
  3664. } IO_REMOVE_LOCK_DBG_BLOCK;
  3665. typedef struct _IO_REMOVE_LOCK {
  3666. IO_REMOVE_LOCK_COMMON_BLOCK Common;
  3667. #if DBG
  3668. IO_REMOVE_LOCK_DBG_BLOCK Dbg;
  3669. #endif
  3670. } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
  3671. #define IoInitializeRemoveLock(Lock, Tag, Maxmin, HighWater) \
  3672. IoInitializeRemoveLockEx (Lock, Tag, Maxmin, HighWater, sizeof (IO_REMOVE_LOCK))
  3673. NTSYSAPI
  3674. VOID
  3675. NTAPI
  3676. IoInitializeRemoveLockEx(
  3677. IN PIO_REMOVE_LOCK Lock,
  3678. IN ULONG AllocateTag, // Used only on checked kernels
  3679. IN ULONG MaxLockedMinutes, // Used only on checked kernels
  3680. IN ULONG HighWatermark, // Used only on checked kernels
  3681. IN ULONG RemlockSize // are we checked or free
  3682. );
  3683. //
  3684. // Initialize a remove lock.
  3685. //
  3686. // Note: Allocation for remove locks needs to be within the device extension,
  3687. // so that the memory for this structure stays allocated until such time as the
  3688. // device object itself is deallocated.
  3689. //
  3690. #define IoAcquireRemoveLock(RemoveLock, Tag) \
  3691. IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK))
  3692. NTSYSAPI
  3693. NTSTATUS
  3694. NTAPI
  3695. IoAcquireRemoveLockEx (
  3696. IN PIO_REMOVE_LOCK RemoveLock,
  3697. IN OPTIONAL PVOID Tag, // Optional
  3698. IN PCSTR File,
  3699. IN ULONG Line,
  3700. IN ULONG RemlockSize // are we checked or free
  3701. );
  3702. //
  3703. // Routine Description:
  3704. //
  3705. // This routine is called to acquire the remove lock for a device object.
  3706. // While the lock is held, the caller can assume that no pending pnp REMOVE
  3707. // requests will be completed.
  3708. //
  3709. // The lock should be acquired immediately upon entering a dispatch routine.
  3710. // It should also be acquired before creating any new reference to the
  3711. // device object if there's a chance of releasing the reference before the
  3712. // new one is done, in addition to references to the driver code itself,
  3713. // which is removed from memory when the last device object goes.
  3714. //
  3715. // Arguments:
  3716. //
  3717. // RemoveLock - A pointer to an initialized REMOVE_LOCK structure.
  3718. //
  3719. // Tag - Used for tracking lock allocation and release. The same tag
  3720. // specified when acquiring the lock must be used to release the lock.
  3721. // Tags are only checked in checked versions of the driver.
  3722. //
  3723. // File - set to __FILE__ as the location in the code where the lock was taken.
  3724. //
  3725. // Line - set to __LINE__.
  3726. //
  3727. // Return Value:
  3728. //
  3729. // Returns whether or not the remove lock was obtained.
  3730. // If successful the caller should continue with work calling
  3731. // IoReleaseRemoveLock when finished.
  3732. //
  3733. // If not successful the lock was not obtained. The caller should abort the
  3734. // work but not call IoReleaseRemoveLock.
  3735. //
  3736. #define IoReleaseRemoveLock(RemoveLock, Tag) \
  3737. IoReleaseRemoveLockEx(RemoveLock, Tag, sizeof (IO_REMOVE_LOCK))
  3738. NTSYSAPI
  3739. VOID
  3740. NTAPI
  3741. IoReleaseRemoveLockEx(
  3742. IN PIO_REMOVE_LOCK RemoveLock,
  3743. IN PVOID Tag, // Optional
  3744. IN ULONG RemlockSize // are we checked or free
  3745. );
  3746. //
  3747. //
  3748. // Routine Description:
  3749. //
  3750. // This routine is called to release the remove lock on the device object. It
  3751. // must be called when finished using a previously locked reference to the
  3752. // device object. If an Tag was specified when acquiring the lock then the
  3753. // same Tag must be specified when releasing the lock.
  3754. //
  3755. // When the lock count reduces to zero, this routine will signal the waiting
  3756. // event to release the waiting thread deleting the device object protected
  3757. // by this lock.
  3758. //
  3759. // Arguments:
  3760. //
  3761. // DeviceObject - the device object to lock
  3762. //
  3763. // Tag - The TAG (if any) specified when acquiring the lock. This is used
  3764. // for lock tracking purposes
  3765. //
  3766. // Return Value:
  3767. //
  3768. // none
  3769. //
  3770. #define IoReleaseRemoveLockAndWait(RemoveLock, Tag) \
  3771. IoReleaseRemoveLockAndWaitEx(RemoveLock, Tag, sizeof (IO_REMOVE_LOCK))
  3772. NTSYSAPI
  3773. VOID
  3774. NTAPI
  3775. IoReleaseRemoveLockAndWaitEx(
  3776. IN PIO_REMOVE_LOCK RemoveLock,
  3777. IN PVOID Tag,
  3778. IN ULONG RemlockSize // are we checked or free
  3779. );
  3780. //
  3781. //
  3782. // Routine Description:
  3783. //
  3784. // This routine is called when the client would like to delete the
  3785. // remove-locked resource. This routine will block until all the remove
  3786. // locks have released.
  3787. //
  3788. // This routine MUST be called after acquiring the lock.
  3789. //
  3790. // Arguments:
  3791. //
  3792. // RemoveLock
  3793. //
  3794. // Return Value:
  3795. //
  3796. // none
  3797. //
  3798. // end_ntddk end_wdm end_ntosp
  3799. NTKERNELAPI
  3800. VOID
  3801. IoShutdownSystem(
  3802. IN ULONG Phase
  3803. );
  3804. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  3805. //++
  3806. //
  3807. // USHORT
  3808. // IoSizeOfIrp(
  3809. // IN CCHAR StackSize
  3810. // )
  3811. //
  3812. // Routine Description:
  3813. //
  3814. // Determines the size of an IRP given the number of stack locations
  3815. // the IRP will have.
  3816. //
  3817. // Arguments:
  3818. //
  3819. // StackSize - Number of stack locations for the IRP.
  3820. //
  3821. // Return Value:
  3822. //
  3823. // Size in bytes of the IRP.
  3824. //
  3825. //--
  3826. #define IoSizeOfIrp( StackSize ) \
  3827. ((USHORT) (sizeof( IRP ) + ((StackSize) * (sizeof( IO_STACK_LOCATION )))))
  3828. // end_ntifs
  3829. NTKERNELAPI
  3830. VOID
  3831. IoStartNextPacket(
  3832. IN PDEVICE_OBJECT DeviceObject,
  3833. IN BOOLEAN Cancelable
  3834. );
  3835. NTKERNELAPI
  3836. VOID
  3837. IoStartNextPacketByKey(
  3838. IN PDEVICE_OBJECT DeviceObject,
  3839. IN BOOLEAN Cancelable,
  3840. IN ULONG Key
  3841. );
  3842. NTKERNELAPI
  3843. VOID
  3844. IoStartPacket(
  3845. IN PDEVICE_OBJECT DeviceObject,
  3846. IN PIRP Irp,
  3847. IN PULONG Key OPTIONAL,
  3848. IN PDRIVER_CANCEL CancelFunction OPTIONAL
  3849. );
  3850. VOID
  3851. IoSetStartIoAttributes(
  3852. IN PDEVICE_OBJECT DeviceObject,
  3853. IN BOOLEAN DeferredStartIo,
  3854. IN BOOLEAN NonCancelable
  3855. );
  3856. // begin_ntifs
  3857. NTKERNELAPI
  3858. VOID
  3859. IoStartTimer(
  3860. IN PDEVICE_OBJECT DeviceObject
  3861. );
  3862. NTKERNELAPI
  3863. VOID
  3864. IoStopTimer(
  3865. IN PDEVICE_OBJECT DeviceObject
  3866. );
  3867. // end_ntddk end_wdm end_nthal end_ntosp
  3868. NTKERNELAPI
  3869. NTSTATUS
  3870. IoSynchronousPageWrite(
  3871. IN PFILE_OBJECT FileObject,
  3872. IN PMDL MemoryDescriptorList,
  3873. IN PLARGE_INTEGER StartingOffset,
  3874. IN PKEVENT Event,
  3875. OUT PIO_STATUS_BLOCK IoStatusBlock
  3876. );
  3877. // begin_ntosp
  3878. NTKERNELAPI
  3879. PEPROCESS
  3880. IoThreadToProcess(
  3881. IN PETHREAD Thread
  3882. );
  3883. // end_ntosp
  3884. NTKERNELAPI
  3885. VOID
  3886. IoUnregisterFileSystem(
  3887. IN OUT PDEVICE_OBJECT DeviceObject
  3888. );
  3889. NTKERNELAPI
  3890. VOID
  3891. IoUnregisterFsRegistrationChange(
  3892. IN PDRIVER_OBJECT DriverObject,
  3893. IN PDRIVER_FS_NOTIFICATION DriverNotificationRoutine
  3894. );
  3895. // begin_ntddk begin_wdm begin_nthal begin_ntosp
  3896. NTKERNELAPI
  3897. VOID
  3898. IoUnregisterShutdownNotification(
  3899. IN PDEVICE_OBJECT DeviceObject
  3900. );
  3901. // end_wdm
  3902. NTKERNELAPI
  3903. VOID
  3904. IoUpdateShareAccess(
  3905. IN PFILE_OBJECT FileObject,
  3906. IN OUT PSHARE_ACCESS ShareAccess
  3907. );
  3908. // end_ntddk end_nthal
  3909. NTKERNELAPI
  3910. NTSTATUS
  3911. IoVerifyVolume(
  3912. IN PDEVICE_OBJECT DeviceObject,
  3913. IN BOOLEAN AllowRawMount
  3914. );
  3915. NTKERNELAPI // ntddk wdm nthal
  3916. VOID // ntddk wdm nthal
  3917. IoWriteErrorLogEntry( // ntddk wdm nthal
  3918. IN PVOID ElEntry // ntddk wdm nthal
  3919. ); // ntddk wdm nthal
  3920. // end_ntifs end_ntosp
  3921. typedef BOOLEAN (*PIO_TRAVERSE_WORKER)(
  3922. IN ULONG Level,
  3923. IN PVOID DeviceNode,
  3924. IN PDEVICE_OBJECT DeviceObject,
  3925. IN PVOID Context
  3926. );
  3927. typedef BOOLEAN (*PIO_LEVEL_END_WORKER)(
  3928. IN ULONG Level,
  3929. IN PVOID Context
  3930. );
  3931. //
  3932. // Used by PO to traverse DevNode tree
  3933. //
  3934. VOID
  3935. IoTraverseDeviceTree(
  3936. IN BOOLEAN Inverted,
  3937. IN LONG CurrentLevel,
  3938. IN PIO_TRAVERSE_WORKER WorkerFunction,
  3939. IN PIO_LEVEL_END_WORKER LevelEndFunction,
  3940. IN PVOID Context
  3941. );
  3942. // begin_nthal begin_ntosp
  3943. NTKERNELAPI
  3944. NTSTATUS
  3945. IoCreateDriver (
  3946. IN PUNICODE_STRING DriverName, OPTIONAL
  3947. IN PDRIVER_INITIALIZE InitializationFunction
  3948. );
  3949. NTKERNELAPI
  3950. VOID
  3951. IoDeleteDriver (
  3952. IN PDRIVER_OBJECT DriverObject
  3953. );
  3954. // end_nthal end_ntosp
  3955. #define _WMIKM_
  3956. //
  3957. // This defines the codes used to define what a request must do
  3958. //
  3959. typedef enum tagWMIACTIONCODE
  3960. {
  3961. WmiGetAllData = IRP_MN_QUERY_ALL_DATA,
  3962. WmiGetSingleInstance = IRP_MN_QUERY_SINGLE_INSTANCE,
  3963. WmiChangeSingleInstance = IRP_MN_CHANGE_SINGLE_INSTANCE,
  3964. WmiChangeSingleItem = IRP_MN_CHANGE_SINGLE_ITEM,
  3965. WmiEnableEvents = IRP_MN_ENABLE_EVENTS,
  3966. WmiDisableEvents = IRP_MN_DISABLE_EVENTS,
  3967. WmiEnableCollection = IRP_MN_ENABLE_COLLECTION,
  3968. WmiDisableCollection = IRP_MN_DISABLE_COLLECTION,
  3969. WmiRegisterInfo = IRP_MN_REGINFO,
  3970. WmiExecuteMethodCall = IRP_MN_EXECUTE_METHOD
  3971. } WMIACTIONCODE;
  3972. //
  3973. // This is the prototype for the callback WMI will make to a data provider
  3974. //
  3975. typedef NTSTATUS (*WMIENTRY)(
  3976. IN WMIACTIONCODE ActionCode,
  3977. IN PVOID DataPath,
  3978. IN ULONG BufferSize,
  3979. IN OUT PVOID Buffer,
  3980. IN PVOID Context,
  3981. OUT PULONG Size
  3982. );
  3983. #define WMIREG_FLAG_CALLBACK 0x80000000
  3984. // begin_wmikm
  3985. //
  3986. // The following is set for a KM provider who is considered private to
  3987. // kernel tracing
  3988. //
  3989. #define WMIREG_FLAG_TRACE_PROVIDER 0x00010000
  3990. //
  3991. // The following mask is to extract the trace callout class
  3992. //
  3993. #define WMIREG_FLAG_TRACE_NOTIFY_MASK 0x00F00000
  3994. //
  3995. // We use 4 bits for the trace callout classes.
  3996. //
  3997. #define WMIREG_NOTIFY_DISK_IO 1 << 20
  3998. #define WMIREG_NOTIFY_TDI_IO 2 << 20
  3999. // end_wmikm
  4000. // begin_ntddk begin_wdm begin_ntifs begin_ntosp begin_ntosp
  4001. typedef struct _IO_WORKITEM *PIO_WORKITEM;
  4002. typedef
  4003. VOID
  4004. (*PIO_WORKITEM_ROUTINE) (
  4005. IN PDEVICE_OBJECT DeviceObject,
  4006. IN PVOID Context
  4007. );
  4008. PIO_WORKITEM
  4009. IoAllocateWorkItem(
  4010. PDEVICE_OBJECT DeviceObject
  4011. );
  4012. VOID
  4013. IoFreeWorkItem(
  4014. PIO_WORKITEM IoWorkItem
  4015. );
  4016. VOID
  4017. IoQueueWorkItem(
  4018. IN PIO_WORKITEM IoWorkItem,
  4019. IN PIO_WORKITEM_ROUTINE WorkerRoutine,
  4020. IN WORK_QUEUE_TYPE QueueType,
  4021. IN PVOID Context
  4022. );
  4023. NTKERNELAPI
  4024. NTSTATUS
  4025. IoWMIRegistrationControl(
  4026. IN PDEVICE_OBJECT DeviceObject,
  4027. IN ULONG Action
  4028. );
  4029. //
  4030. // Action code for IoWMIRegistrationControl api
  4031. //
  4032. #define WMIREG_ACTION_REGISTER 1
  4033. #define WMIREG_ACTION_DEREGISTER 2
  4034. #define WMIREG_ACTION_REREGISTER 3
  4035. #define WMIREG_ACTION_UPDATE_GUIDS 4
  4036. #define WMIREG_ACTION_BLOCK_IRPS 5
  4037. //
  4038. // Code passed in IRP_MN_REGINFO WMI irp
  4039. //
  4040. #define WMIREGISTER 0
  4041. #define WMIUPDATE 1
  4042. NTKERNELAPI
  4043. NTSTATUS
  4044. IoWMIAllocateInstanceIds(
  4045. IN GUID *Guid,
  4046. IN ULONG InstanceCount,
  4047. OUT ULONG *FirstInstanceId
  4048. );
  4049. NTKERNELAPI
  4050. NTSTATUS
  4051. IoWMISuggestInstanceName(
  4052. IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
  4053. IN PUNICODE_STRING SymbolicLinkName OPTIONAL,
  4054. IN BOOLEAN CombineNames,
  4055. OUT PUNICODE_STRING SuggestedInstanceName
  4056. );
  4057. NTKERNELAPI
  4058. NTSTATUS
  4059. IoWMIWriteEvent(
  4060. IN PVOID WnodeEventItem
  4061. );
  4062. #if defined(_WIN64)
  4063. NTKERNELAPI
  4064. ULONG IoWMIDeviceObjectToProviderId(
  4065. PDEVICE_OBJECT DeviceObject
  4066. );
  4067. #else
  4068. #define IoWMIDeviceObjectToProviderId(DeviceObject) ((ULONG)(DeviceObject))
  4069. #endif
  4070. NTKERNELAPI
  4071. NTSTATUS IoWMIOpenBlock(
  4072. IN GUID *DataBlockGuid,
  4073. IN ULONG DesiredAccess,
  4074. OUT PVOID *DataBlockObject
  4075. );
  4076. NTKERNELAPI
  4077. NTSTATUS IoWMIQueryAllData(
  4078. IN PVOID DataBlockObject,
  4079. IN OUT ULONG *InOutBufferSize,
  4080. OUT /* non paged */ PVOID OutBuffer
  4081. );
  4082. NTKERNELAPI
  4083. NTSTATUS
  4084. IoWMIQueryAllDataMultiple(
  4085. IN PVOID *DataBlockObjectList,
  4086. IN ULONG ObjectCount,
  4087. IN OUT ULONG *InOutBufferSize,
  4088. OUT /* non paged */ PVOID OutBuffer
  4089. );
  4090. NTKERNELAPI
  4091. NTSTATUS
  4092. IoWMIQuerySingleInstance(
  4093. IN PVOID DataBlockObject,
  4094. IN PUNICODE_STRING InstanceName,
  4095. IN OUT ULONG *InOutBufferSize,
  4096. OUT /* non paged */ PVOID OutBuffer
  4097. );
  4098. NTKERNELAPI
  4099. NTSTATUS
  4100. IoWMIQuerySingleInstanceMultiple(
  4101. IN PVOID *DataBlockObjectList,
  4102. IN PUNICODE_STRING InstanceNames,
  4103. IN ULONG ObjectCount,
  4104. IN OUT ULONG *InOutBufferSize,
  4105. OUT /* non paged */ PVOID OutBuffer
  4106. );
  4107. NTKERNELAPI
  4108. NTSTATUS
  4109. IoWMISetSingleInstance(
  4110. IN PVOID DataBlockObject,
  4111. IN PUNICODE_STRING InstanceName,
  4112. IN ULONG Version,
  4113. IN ULONG ValueBufferSize,
  4114. IN PVOID ValueBuffer
  4115. );
  4116. NTKERNELAPI
  4117. NTSTATUS
  4118. IoWMISetSingleItem(
  4119. IN PVOID DataBlockObject,
  4120. IN PUNICODE_STRING InstanceName,
  4121. IN ULONG DataItemId,
  4122. IN ULONG Version,
  4123. IN ULONG ValueBufferSize,
  4124. IN PVOID ValueBuffer
  4125. );
  4126. NTKERNELAPI
  4127. NTSTATUS
  4128. IoWMIExecuteMethod(
  4129. IN PVOID DataBlockObject,
  4130. IN PUNICODE_STRING InstanceName,
  4131. IN ULONG MethodId,
  4132. IN ULONG InBufferSize,
  4133. IN OUT PULONG OutBufferSize,
  4134. IN OUT PUCHAR InOutBuffer
  4135. );
  4136. typedef VOID (*WMI_NOTIFICATION_CALLBACK)(
  4137. PVOID Wnode,
  4138. PVOID Context
  4139. );
  4140. NTKERNELAPI
  4141. NTSTATUS
  4142. IoWMISetNotificationCallback(
  4143. IN PVOID Object,
  4144. IN WMI_NOTIFICATION_CALLBACK Callback,
  4145. IN PVOID Context
  4146. );
  4147. NTKERNELAPI
  4148. NTSTATUS
  4149. IoWMIHandleToInstanceName(
  4150. IN PVOID DataBlockObject,
  4151. IN HANDLE FileHandle,
  4152. OUT PUNICODE_STRING InstanceName
  4153. );
  4154. NTKERNELAPI
  4155. NTSTATUS
  4156. IoWMIDeviceObjectToInstanceName(
  4157. IN PVOID DataBlockObject,
  4158. IN PDEVICE_OBJECT DeviceObject,
  4159. OUT PUNICODE_STRING InstanceName
  4160. );
  4161. // end_ntddk end_wdm end_ntifs end_ntosp
  4162. NTKERNELAPI
  4163. BOOLEAN
  4164. WMIInitialize(
  4165. ULONG Phase,
  4166. PVOID LoaderBlock
  4167. );
  4168. //
  4169. // IoRemoteBootClient indicates whether the system was booted as a remote
  4170. // boot client.
  4171. //
  4172. extern BOOLEAN IoRemoteBootClient;
  4173. #if defined(REMOTE_BOOT)
  4174. extern BOOLEAN IoCscInitializationFailed;
  4175. #endif // defined(REMOTE_BOOT)
  4176. // Used to convert a handle to a device stack.
  4177. NTSTATUS
  4178. IoGetRelatedTargetDevice(
  4179. IN PFILE_OBJECT FileObject,
  4180. OUT PDEVICE_OBJECT *DeviceObject
  4181. );
  4182. // begin_ntosp
  4183. NTKERNELAPI
  4184. NTSTATUS
  4185. IoSetIoCompletion (
  4186. IN PVOID IoCompletion,
  4187. IN PVOID KeyContext,
  4188. IN PVOID ApcContext,
  4189. IN NTSTATUS IoStatus,
  4190. IN ULONG_PTR IoStatusInformation,
  4191. IN BOOLEAN Quota
  4192. );
  4193. // end_ntosp
  4194. //
  4195. // Safeboot definitions - placeholder until a home can be found.
  4196. //
  4197. typedef struct _BOOT_LOG_RECORD {
  4198. UNICODE_STRING LoadedString;
  4199. UNICODE_STRING NotLoadedString;
  4200. UNICODE_STRING LogFileName;
  4201. UNICODE_STRING HeaderString;
  4202. ERESOURCE Resource;
  4203. ULONG NextKey;
  4204. BOOLEAN FileLogging;
  4205. } BOOT_LOG_RECORD, *PBOOT_LOG_RECORD;
  4206. VOID
  4207. IopCopyBootLogRegistryToFile(
  4208. VOID
  4209. );
  4210. VOID
  4211. IopInitializeBootLogging(
  4212. PLOADER_PARAMETER_BLOCK LoaderBlock,
  4213. PCHAR HeaderString
  4214. );
  4215. VOID
  4216. IopBootLog(
  4217. PUNICODE_STRING LogEntry,
  4218. BOOLEAN Loaded
  4219. );
  4220. NTSTATUS
  4221. IopSetRegistryStringValue(
  4222. IN HANDLE KeyHandle,
  4223. IN PUNICODE_STRING ValueName,
  4224. IN PUNICODE_STRING ValueData
  4225. );
  4226. NTKERNELAPI
  4227. NTSTATUS
  4228. IoGetRequestorSessionId(
  4229. IN PIRP Irp,
  4230. OUT PULONG pSessionId
  4231. );
  4232. NTSTATUS
  4233. IoShutdownPnpDevices(
  4234. VOID
  4235. );
  4236. VOID
  4237. IovFreeIrp(
  4238. IN PIRP Irp
  4239. );
  4240. PIRP
  4241. IovAllocateIrp(
  4242. IN CCHAR StackSize,
  4243. IN BOOLEAN ChargeQuota
  4244. );
  4245. VOID
  4246. IoVerifierInit(
  4247. IN ULONG VerifierFlags
  4248. );
  4249. NTSTATUS
  4250. FASTCALL
  4251. IovCallDriver(
  4252. IN PDEVICE_OBJECT DeviceObject,
  4253. IN OUT PIRP Irp
  4254. );
  4255. VOID
  4256. FASTCALL
  4257. IovCompleteRequest(
  4258. IN PIRP Irp,
  4259. IN CCHAR PriorityBoost
  4260. );
  4261. PIRP
  4262. IovBuildAsynchronousFsdRequest(
  4263. IN ULONG MajorFunction,
  4264. IN PDEVICE_OBJECT DeviceObject,
  4265. IN OUT PVOID Buffer OPTIONAL,
  4266. IN ULONG Length OPTIONAL,
  4267. IN PLARGE_INTEGER StartingOffset OPTIONAL,
  4268. IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL
  4269. );
  4270. PIRP
  4271. IovBuildDeviceIoControlRequest(
  4272. IN ULONG IoControlCode,
  4273. IN PDEVICE_OBJECT DeviceObject,
  4274. IN PVOID InputBuffer OPTIONAL,
  4275. IN ULONG InputBufferLength,
  4276. OUT PVOID OutputBuffer OPTIONAL,
  4277. IN ULONG OutputBufferLength,
  4278. IN BOOLEAN InternalDeviceIoControl,
  4279. IN PKEVENT Event,
  4280. OUT PIO_STATUS_BLOCK IoStatusBlock
  4281. );
  4282. NTSTATUS
  4283. IovInitializeTimer(
  4284. IN PDEVICE_OBJECT DeviceObject,
  4285. IN PIO_TIMER_ROUTINE TimerRoutine,
  4286. IN PVOID Context
  4287. );
  4288. NTKERNELAPI
  4289. PVOID
  4290. IoAllocateGenericErrorLogEntry(
  4291. IN UCHAR EntrySize
  4292. );
  4293. VOID
  4294. IoRetryIrpCompletions(
  4295. VOID
  4296. );
  4297. // begin_ntddk begin_wdm begin_ntifs begin_ntosp
  4298. #if defined(_WIN64)
  4299. BOOLEAN
  4300. IoIs32bitProcess(
  4301. IN PIRP Irp
  4302. );
  4303. #endif
  4304. // end_ntddk end_wdm end_ntifs end_ntosp
  4305. // begin_ntosp
  4306. NTKERNELAPI
  4307. VOID
  4308. FASTCALL
  4309. IoAssignDriveLetters(
  4310. PLOADER_PARAMETER_BLOCK LoaderBlock,
  4311. PSTRING NtDeviceName,
  4312. OUT PUCHAR NtSystemPath,
  4313. OUT PSTRING NtSystemPathString
  4314. );
  4315. // end_ntosp
  4316. // begin_ntddk
  4317. NTKERNELAPI
  4318. VOID
  4319. FASTCALL
  4320. HalExamineMBR(
  4321. IN PDEVICE_OBJECT DeviceObject,
  4322. IN ULONG SectorSize,
  4323. IN ULONG MBRTypeIdentifier,
  4324. OUT PVOID *Buffer
  4325. );
  4326. DECLSPEC_DEPRECATED_DDK // Use IoReadPartitionTableEx
  4327. NTKERNELAPI
  4328. NTSTATUS
  4329. FASTCALL
  4330. IoReadPartitionTable(
  4331. IN PDEVICE_OBJECT DeviceObject,
  4332. IN ULONG SectorSize,
  4333. IN BOOLEAN ReturnRecognizedPartitions,
  4334. OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer
  4335. );
  4336. DECLSPEC_DEPRECATED_DDK // Use IoSetPartitionInformationEx
  4337. NTKERNELAPI
  4338. NTSTATUS
  4339. FASTCALL
  4340. IoSetPartitionInformation(
  4341. IN PDEVICE_OBJECT DeviceObject,
  4342. IN ULONG SectorSize,
  4343. IN ULONG PartitionNumber,
  4344. IN ULONG PartitionType
  4345. );
  4346. // begin_ntosp
  4347. DECLSPEC_DEPRECATED_DDK // Use IoWritePartitionTableEx
  4348. NTKERNELAPI
  4349. NTSTATUS
  4350. FASTCALL
  4351. IoWritePartitionTable(
  4352. IN PDEVICE_OBJECT DeviceObject,
  4353. IN ULONG SectorSize,
  4354. IN ULONG SectorsPerTrack,
  4355. IN ULONG NumberOfHeads,
  4356. IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer
  4357. );
  4358. NTKERNELAPI
  4359. NTSTATUS
  4360. IoCreateDisk(
  4361. IN PDEVICE_OBJECT DeviceObject,
  4362. IN struct _CREATE_DISK* Disk
  4363. );
  4364. NTKERNELAPI
  4365. NTSTATUS
  4366. IoReadPartitionTableEx(
  4367. IN PDEVICE_OBJECT DeviceObject,
  4368. IN struct _DRIVE_LAYOUT_INFORMATION_EX** DriveLayout
  4369. );
  4370. NTKERNELAPI
  4371. NTSTATUS
  4372. IoWritePartitionTableEx(
  4373. IN PDEVICE_OBJECT DeviceObject,
  4374. IN struct _DRIVE_LAYOUT_INFORMATION_EX* DriveLayout
  4375. );
  4376. NTKERNELAPI
  4377. NTSTATUS
  4378. IoSetPartitionInformationEx(
  4379. IN PDEVICE_OBJECT DeviceObject,
  4380. IN ULONG PartitionNumber,
  4381. IN struct _SET_PARTITION_INFORMATION_EX* PartitionInfo
  4382. );
  4383. NTKERNELAPI
  4384. NTSTATUS
  4385. IoUpdateDiskGeometry(
  4386. IN PDEVICE_OBJECT DeviceObject,
  4387. IN struct _DISK_GEOMETRY_EX* OldDiskGeometry,
  4388. IN struct _DISK_GEOMETRY_EX* NewDiskGeometry
  4389. );
  4390. NTKERNELAPI
  4391. NTSTATUS
  4392. IoVerifyPartitionTable(
  4393. IN PDEVICE_OBJECT DeviceObject,
  4394. IN BOOLEAN FixErrors
  4395. );
  4396. typedef struct _DISK_SIGNATURE {
  4397. ULONG PartitionStyle;
  4398. union {
  4399. struct {
  4400. ULONG Signature;
  4401. ULONG CheckSum;
  4402. } Mbr;
  4403. struct {
  4404. GUID DiskId;
  4405. } Gpt;
  4406. };
  4407. } DISK_SIGNATURE, *PDISK_SIGNATURE;
  4408. NTKERNELAPI
  4409. NTSTATUS
  4410. IoReadDiskSignature(
  4411. IN PDEVICE_OBJECT DeviceObject,
  4412. IN ULONG BytesPerSector,
  4413. OUT PDISK_SIGNATURE Signature
  4414. );
  4415. // end_ntosp
  4416. // end_ntddk
  4417. // begin_ntosp begin_ntifs begin_ntddk
  4418. NTSTATUS
  4419. IoVolumeDeviceToDosName(
  4420. IN PVOID VolumeDeviceObject,
  4421. OUT PUNICODE_STRING DosName
  4422. );
  4423. // end_ntosp end_ntifs end_ntddk
  4424. // begin_ntosp begin_ntifs
  4425. NTSTATUS
  4426. IoEnumerateDeviceObjectList(
  4427. IN PDRIVER_OBJECT DriverObject,
  4428. IN PDEVICE_OBJECT *DeviceObjectList,
  4429. IN ULONG DeviceObjectListSize,
  4430. OUT PULONG ActualNumberDeviceObjects
  4431. );
  4432. PDEVICE_OBJECT
  4433. IoGetLowerDeviceObject(
  4434. IN PDEVICE_OBJECT DeviceObject
  4435. );
  4436. PDEVICE_OBJECT
  4437. IoGetDeviceAttachmentBaseRef(
  4438. IN PDEVICE_OBJECT DeviceObject
  4439. );
  4440. NTSTATUS
  4441. IoGetDiskDeviceObject(
  4442. IN PDEVICE_OBJECT FileSystemDeviceObject,
  4443. OUT PDEVICE_OBJECT *DiskDeviceObject
  4444. );
  4445. // end_ntosp end_ntifs
  4446. // begin_ntosp begin_ntifs begin_ntddk
  4447. NTSTATUS
  4448. IoSetSystemPartition(
  4449. PUNICODE_STRING VolumeNameString
  4450. );
  4451. // begin_wdm
  4452. VOID
  4453. IoFreeErrorLogEntry(
  4454. PVOID ElEntry
  4455. );
  4456. // Cancel SAFE API set start
  4457. //
  4458. // The following APIs are to help ease the pain of writing queue packages that
  4459. // handle the cancellation race well. The idea of this set of APIs is to not
  4460. // force a single queue data structure but allow the cancel logic to be hidden
  4461. // from the drivers. A driver implements a queue and as part of its header
  4462. // includes the IO_CSQ structure. In its initialization routine it calls
  4463. // IoInitializeCsq. Then in the dispatch routine when the driver wants to
  4464. // insert an IRP into the queue it calls IoCsqInsertIrp. When the driver wants
  4465. // to remove something from the queue it calls IoCsqRemoveIrp. Note that Insert
  4466. // can fail if the IRP was cancelled in the meantime. Remove can also fail if
  4467. // the IRP was already cancelled.
  4468. //
  4469. // There are typically two modes where drivers queue IRPs. These two modes are
  4470. // covered by the cancel safe queue API set.
  4471. //
  4472. // Mode 1:
  4473. // One is where the driver queues the IRP and at some later
  4474. // point in time dequeues an IRP and issues the IO request.
  4475. // For this mode the driver should use IoCsqInsertIrp and IoCsqRemoveNextIrp.
  4476. // The driver in this case is expected to pass NULL to the irp context
  4477. // parameter in IoInsertIrp.
  4478. //
  4479. // Mode 2:
  4480. // In this the driver queues theIRP, issues the IO request (like issuing a DMA
  4481. // request or writing to a register) and when the IO request completes (either
  4482. // using a DPC or timer) the driver dequeues the IRP and completes it. For this
  4483. // mode the driver should use IoCsqInsertIrp and IoCsqRemoveIrp. In this case
  4484. // the driver should allocate an IRP context and pass it in to IoCsqInsertIrp.
  4485. // The cancel API code creates an association between the IRP and the context
  4486. // and thus ensures that when the time comes to remove the IRP it can ascertain
  4487. // correctly.
  4488. //
  4489. // Note that the cancel API set assumes that the field DriverContext[3] is
  4490. // always available for use and that the driver does not use it.
  4491. //
  4492. //
  4493. // Bookkeeping structure. This should be opaque to drivers.
  4494. // Drivers typically include this as part of their queue headers.
  4495. // Given a CSQ pointer the driver should be able to get its
  4496. // queue header using CONTAINING_RECORD macro
  4497. //
  4498. typedef struct _IO_CSQ IO_CSQ, *PIO_CSQ;
  4499. #define IO_TYPE_CSQ_IRP_CONTEXT 1
  4500. #define IO_TYPE_CSQ 2
  4501. //
  4502. // IRP context structure. This structure is necessary if the driver is using
  4503. // the second mode.
  4504. //
  4505. typedef struct _IO_CSQ_IRP_CONTEXT {
  4506. ULONG Type;
  4507. PIRP Irp;
  4508. PIO_CSQ Csq;
  4509. } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
  4510. //
  4511. // Routines that insert/remove IRP
  4512. //
  4513. typedef VOID
  4514. (*PIO_CSQ_INSERT_IRP)(
  4515. IN struct _IO_CSQ *Csq,
  4516. IN PIRP Irp
  4517. );
  4518. typedef VOID
  4519. (*PIO_CSQ_REMOVE_IRP)(
  4520. IN PIO_CSQ Csq,
  4521. IN PIRP Irp
  4522. );
  4523. //
  4524. // Retrieves next entry after Irp from the queue.
  4525. // Returns NULL if there are no entries in the queue.
  4526. // If Irp is NUL, returns the entry in the head of the queue.
  4527. // This routine does not remove the IRP from the queue.
  4528. //
  4529. typedef PIRP
  4530. (*PIO_CSQ_PEEK_NEXT_IRP)(
  4531. IN PIO_CSQ Csq,
  4532. IN PIRP Irp,
  4533. IN PVOID PeekContext
  4534. );
  4535. //
  4536. // Lock routine that protects the cancel safe queue.
  4537. //
  4538. typedef VOID
  4539. (*PIO_CSQ_ACQUIRE_LOCK)(
  4540. IN PIO_CSQ Csq,
  4541. OUT PKIRQL Irql
  4542. );
  4543. typedef VOID
  4544. (*PIO_CSQ_RELEASE_LOCK)(
  4545. IN PIO_CSQ Csq,
  4546. IN KIRQL Irql
  4547. );
  4548. //
  4549. // Completes the IRP with STATUS_CANCELLED. IRP is guaranteed to be valid
  4550. // In most cases this routine just calls IoCompleteRequest(Irp, STATUS_CANCELLED);
  4551. //
  4552. typedef VOID
  4553. (*PIO_CSQ_COMPLETE_CANCELED_IRP)(
  4554. IN PIO_CSQ Csq,
  4555. IN PIRP Irp
  4556. );
  4557. //
  4558. // Bookkeeping structure. This should be opaque to drivers.
  4559. // Drivers typically include this as part of their queue headers.
  4560. // Given a CSQ pointer the driver should be able to get its
  4561. // queue header using CONTAINING_RECORD macro
  4562. //
  4563. typedef struct _IO_CSQ {
  4564. ULONG Type;
  4565. PIO_CSQ_INSERT_IRP CsqInsertIrp;
  4566. PIO_CSQ_REMOVE_IRP CsqRemoveIrp;
  4567. PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp;
  4568. PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock;
  4569. PIO_CSQ_RELEASE_LOCK CsqReleaseLock;
  4570. PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp;
  4571. PVOID ReservePointer; // Future expansion
  4572. } IO_CSQ, *PIO_CSQ;
  4573. //
  4574. // Initializes the cancel queue structure.
  4575. //
  4576. NTSTATUS
  4577. IoCsqInitialize(
  4578. IN PIO_CSQ Csq,
  4579. IN PIO_CSQ_INSERT_IRP CsqInsertIrp,
  4580. IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
  4581. IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp,
  4582. IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock,
  4583. IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock,
  4584. IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp
  4585. );
  4586. //
  4587. // The caller calls this routine to insert the IRP and return STATUS_PENDING.
  4588. //
  4589. VOID
  4590. IoCsqInsertIrp(
  4591. IN PIO_CSQ Csq,
  4592. IN PIRP Irp,
  4593. IN PIO_CSQ_IRP_CONTEXT Context
  4594. );
  4595. //
  4596. // Returns an IRP if one can be found. NULL otherwise.
  4597. //
  4598. PIRP
  4599. IoCsqRemoveNextIrp(
  4600. IN PIO_CSQ Csq,
  4601. IN PVOID PeekContext
  4602. );
  4603. //
  4604. // This routine is called from timeout or DPCs.
  4605. // The context is presumably part of the DPC or timer context.
  4606. // If succesfull returns the IRP associated with context.
  4607. //
  4608. PIRP
  4609. IoCsqRemoveIrp(
  4610. IN PIO_CSQ Csq,
  4611. IN PIO_CSQ_IRP_CONTEXT Context
  4612. );
  4613. // Cancel SAFE API set end
  4614. // end_ntosp end_ntifs end_ntddk end_wdm
  4615. // begin_ntosp begin_ntifs
  4616. NTSTATUS
  4617. IoCreateFileSpecifyDeviceObjectHint(
  4618. OUT PHANDLE FileHandle,
  4619. IN ACCESS_MASK DesiredAccess,
  4620. IN POBJECT_ATTRIBUTES ObjectAttributes,
  4621. OUT PIO_STATUS_BLOCK IoStatusBlock,
  4622. IN PLARGE_INTEGER AllocationSize OPTIONAL,
  4623. IN ULONG FileAttributes,
  4624. IN ULONG ShareAccess,
  4625. IN ULONG Disposition,
  4626. IN ULONG CreateOptions,
  4627. IN PVOID EaBuffer OPTIONAL,
  4628. IN ULONG EaLength,
  4629. IN CREATE_FILE_TYPE CreateFileType,
  4630. IN PVOID ExtraCreateParameters OPTIONAL,
  4631. IN ULONG Options,
  4632. IN PVOID DeviceObject
  4633. );
  4634. NTSTATUS
  4635. IoAttachDeviceToDeviceStackSafe(
  4636. IN PDEVICE_OBJECT SourceDevice,
  4637. IN PDEVICE_OBJECT TargetDevice,
  4638. OUT PDEVICE_OBJECT *AttachedToDeviceObject
  4639. );
  4640. // end_ntosp
  4641. NTKERNELAPI
  4642. BOOLEAN
  4643. IoIsFileOriginRemote(
  4644. IN PFILE_OBJECT FileObject
  4645. );
  4646. NTKERNELAPI
  4647. NTSTATUS
  4648. IoSetFileOrigin(
  4649. IN PFILE_OBJECT FileObject,
  4650. IN BOOLEAN Remote
  4651. );
  4652. // end_ntifs
  4653. PVOID
  4654. IoGetFileObjectFilterContext(
  4655. IN PFILE_OBJECT FileObject
  4656. );
  4657. NTSTATUS
  4658. IoChangeFileObjectFilterContext(
  4659. IN PFILE_OBJECT FileObject,
  4660. IN PVOID FilterContext,
  4661. IN BOOLEAN Set
  4662. );
  4663. BOOLEAN
  4664. IoIsDeviceEjectable(
  4665. IN PDEVICE_OBJECT
  4666. );
  4667. NTSTATUS
  4668. IoComputeDesiredAccessFileObject(
  4669. IN PFILE_OBJECT FileObject,
  4670. OUT PNTSTATUS DesiredAccess
  4671. );
  4672. // begin_ntosp begin_ntifs begin_ntddk
  4673. NTSTATUS
  4674. IoValidateDeviceIoControlAccess(
  4675. IN PIRP Irp,
  4676. IN ULONG RequiredAccess
  4677. );
  4678. // end_ntosp end_ntifs end_ntddk end_wdm
  4679. #endif // _IO_