Leaked source code of windows server 2003
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.

5763 lines
142 KiB

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