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

396 lines
8.0 KiB

  1. /*++ BUILD Version: 0002
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. iop.h
  5. Abstract:
  6. This module contains the private structure definitions and APIs used by
  7. the NT I/O system.
  8. Author:
  9. Darryl E. Havens (darrylh) 17-Apr-1989
  10. Revision History:
  11. --*/
  12. #ifndef _IOPCMN_
  13. #define _IOPCMN_
  14. //
  15. // This macro returns the pointer to the beginning of the data
  16. // area of KEY_VALUE_FULL_INFORMATION structure.
  17. // In the macro, k is a pointer to KEY_VALUE_FULL_INFORMATION structure.
  18. //
  19. #define KEY_VALUE_DATA(k) ((PCHAR)(k) + (k)->DataOffset)
  20. #define ALIGN_POINTER(Offset) (PVOID) \
  21. ((((ULONG_PTR)(Offset) + sizeof(ULONG_PTR)-1)) & (~(sizeof(ULONG_PTR) - 1)))
  22. #define ALIGN_POINTER_OFFSET(Offset) (ULONG_PTR) ALIGN_POINTER(Offset)
  23. //
  24. // IO manager exports to Driver Verifier
  25. //
  26. NTSTATUS
  27. IopInvalidDeviceRequest(
  28. IN PDEVICE_OBJECT DeviceObject,
  29. IN PIRP Irp
  30. );
  31. extern POBJECT_TYPE IoDeviceObjectType;
  32. #include "pnpmgr\pplastgood.h"
  33. //++
  34. //
  35. // VOID
  36. // IopInitializeIrp(
  37. // IN OUT PIRP Irp,
  38. // IN USHORT PacketSize,
  39. // IN CCHAR StackSize
  40. // )
  41. //
  42. // Routine Description:
  43. //
  44. // Initializes an IRP.
  45. //
  46. // Arguments:
  47. //
  48. // Irp - a pointer to the IRP to initialize.
  49. //
  50. // PacketSize - length, in bytes, of the IRP.
  51. //
  52. // StackSize - Number of stack locations in the IRP.
  53. //
  54. // Return Value:
  55. //
  56. // None.
  57. //
  58. //--
  59. #define IopInitializeIrp( Irp, PacketSize, StackSize ) { \
  60. RtlZeroMemory( (Irp), (PacketSize) ); \
  61. (Irp)->Type = (CSHORT) IO_TYPE_IRP; \
  62. (Irp)->Size = (USHORT) ((PacketSize)); \
  63. (Irp)->StackCount = (CCHAR) ((StackSize)); \
  64. (Irp)->CurrentLocation = (CCHAR) ((StackSize) + 1); \
  65. (Irp)->ApcEnvironment = KeGetCurrentApcEnvironment(); \
  66. InitializeListHead (&(Irp)->ThreadListEntry); \
  67. (Irp)->Tail.Overlay.CurrentStackLocation = \
  68. ((PIO_STACK_LOCATION) ((UCHAR *) (Irp) + \
  69. sizeof( IRP ) + \
  70. ( (StackSize) * sizeof( IO_STACK_LOCATION )))); }
  71. //
  72. // IO manager exports to PNP
  73. //
  74. BOOLEAN
  75. IopCallBootDriverReinitializationRoutines(
  76. );
  77. BOOLEAN
  78. IopCallDriverReinitializationRoutines(
  79. );
  80. VOID
  81. IopCreateArcNames(
  82. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  83. );
  84. PSECURITY_DESCRIPTOR
  85. IopCreateDefaultDeviceSecurityDescriptor(
  86. IN DEVICE_TYPE DeviceType,
  87. IN ULONG DeviceCharacteristics,
  88. IN BOOLEAN DeviceHasName,
  89. IN PUCHAR Buffer,
  90. OUT PACL *AllocatedAcl,
  91. OUT PSECURITY_INFORMATION SecurityInformation OPTIONAL
  92. );
  93. NTSTATUS
  94. IopGetDriverNameFromKeyNode(
  95. IN HANDLE KeyHandle,
  96. OUT PUNICODE_STRING DriverName
  97. );
  98. NTSTATUS
  99. IopGetRegistryKeyInformation(
  100. IN HANDLE KeyHandle,
  101. OUT PKEY_FULL_INFORMATION *Information
  102. );
  103. NTSTATUS
  104. IopGetRegistryValue(
  105. IN HANDLE KeyHandle,
  106. IN PWSTR ValueName,
  107. OUT PKEY_VALUE_FULL_INFORMATION *Information
  108. );
  109. NTSTATUS
  110. IopInitializeBuiltinDriver(
  111. IN PUNICODE_STRING DriverName,
  112. IN PUNICODE_STRING RegistryPath,
  113. IN PDRIVER_INITIALIZE DriverInitializeRoutine,
  114. IN PKLDR_DATA_TABLE_ENTRY TableEntry,
  115. IN BOOLEAN IsFilter,
  116. OUT PDRIVER_OBJECT *DriverObject
  117. );
  118. NTSTATUS
  119. IopInvalidateVolumesForDevice(
  120. IN PDEVICE_OBJECT DeviceObject
  121. );
  122. BOOLEAN
  123. IopIsRemoteBootCard(
  124. IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements,
  125. IN PLOADER_PARAMETER_BLOCK LoaderBlock,
  126. IN PWCHAR HwIds
  127. );
  128. NTSTATUS
  129. IopLoadDriver(
  130. IN HANDLE KeyHandle,
  131. IN BOOLEAN CheckForSafeBoot,
  132. IN BOOLEAN IsFilter,
  133. OUT NTSTATUS *DriverEntryStatus
  134. );
  135. BOOLEAN
  136. IopMarkBootPartition(
  137. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  138. );
  139. BOOLEAN
  140. IopNotifyPnpWhenChainDereferenced(
  141. IN PDEVICE_OBJECT *PhysicalDeviceObjects,
  142. IN ULONG DeviceObjectCount,
  143. IN BOOLEAN Query,
  144. OUT PDEVICE_OBJECT *VetoingDevice
  145. );
  146. NTSTATUS
  147. IopOpenRegistryKey(
  148. OUT PHANDLE Handle,
  149. IN HANDLE BaseHandle OPTIONAL,
  150. IN PUNICODE_STRING KeyName,
  151. IN ACCESS_MASK DesiredAccess,
  152. IN BOOLEAN Create
  153. );
  154. //+
  155. // VOID
  156. // IopQueueThreadIrp(
  157. // IN PIRP Irp
  158. // )
  159. //
  160. // Routine Description:
  161. //
  162. // This routine queues the specified I/O Request Packet (IRP) to the thread
  163. // whose TCB address is stored in the packet.
  164. //
  165. // Arguments:
  166. //
  167. // Irp - Supplies the IRP to be queued for the specified thread.
  168. //
  169. // Return Value:
  170. //
  171. // None.
  172. //
  173. //-
  174. #define IopQueueThreadIrp( Irp ) { \
  175. KIRQL irql; \
  176. KeRaiseIrql( APC_LEVEL, &irql ); \
  177. InsertHeadList( &Irp->Tail.Overlay.Thread->IrpList, \
  178. &Irp->ThreadListEntry ); \
  179. KeLowerIrql( irql ); \
  180. }
  181. PDRIVER_OBJECT
  182. IopReferenceDriverObjectByName (
  183. IN PUNICODE_STRING DriverName
  184. );
  185. BOOLEAN
  186. IopSafebootDriverLoad(
  187. PUNICODE_STRING DriverId
  188. );
  189. NTSTATUS
  190. IopSetupRemoteBootCard(
  191. IN PLOADER_PARAMETER_BLOCK LoaderBlock,
  192. IN HANDLE UniqueIdHandle,
  193. IN PUNICODE_STRING UnicodeDeviceInstance
  194. );
  195. extern PVOID IopLoaderBlock;
  196. extern POBJECT_TYPE IoDriverObjectType;
  197. extern POBJECT_TYPE IoFileObjectType;
  198. //
  199. // Title Index to set registry key value
  200. //
  201. #define TITLE_INDEX_VALUE 0
  202. //++
  203. //
  204. // VOID
  205. // IopWstrToUnicodeString(
  206. // OUT PUNICODE_STRING u,
  207. // IN PCWSTR p
  208. // )
  209. //
  210. //--
  211. #define IopWstrToUnicodeString(u, p) \
  212. \
  213. (u)->Length = ((u)->MaximumLength = sizeof((p))) - sizeof(WCHAR); \
  214. (u)->Buffer = (p)
  215. //
  216. // Remote Boot exports to PNP
  217. //
  218. NTSTATUS
  219. IopStartTcpIpForRemoteBoot (
  220. PLOADER_PARAMETER_BLOCK LoaderBlock
  221. );
  222. //
  223. // Remote Boot exports to IO
  224. //
  225. NTSTATUS
  226. IopAddRemoteBootValuesToRegistry (
  227. PLOADER_PARAMETER_BLOCK LoaderBlock
  228. );
  229. NTSTATUS
  230. IopStartNetworkForRemoteBoot (
  231. PLOADER_PARAMETER_BLOCK LoaderBlock
  232. );
  233. //
  234. // PNP Manager exports to IO
  235. //
  236. typedef struct _DEVICE_NODE DEVICE_NODE, *PDEVICE_NODE;
  237. VOID
  238. IopChainDereferenceComplete(
  239. IN PDEVICE_OBJECT PhysicalDeviceObject,
  240. IN BOOLEAN OnCleanStack
  241. );
  242. NTSTATUS
  243. IopCreateRegistryKeyEx(
  244. OUT PHANDLE Handle,
  245. IN HANDLE BaseHandle OPTIONAL,
  246. IN PUNICODE_STRING KeyName,
  247. IN ACCESS_MASK DesiredAccess,
  248. IN ULONG CreateOptions,
  249. OUT PULONG Disposition OPTIONAL
  250. );
  251. NTSTATUS
  252. IopInitializePlugPlayServices(
  253. IN PLOADER_PARAMETER_BLOCK LoaderBlock,
  254. IN ULONG Phase
  255. );
  256. NTSTATUS
  257. IopOpenRegistryKeyEx(
  258. OUT PHANDLE Handle,
  259. IN HANDLE BaseHandle OPTIONAL,
  260. IN PUNICODE_STRING KeyName,
  261. IN ACCESS_MASK DesiredAccess
  262. );
  263. VOID
  264. IopDestroyDeviceNode(
  265. PDEVICE_NODE DeviceNode
  266. );
  267. NTSTATUS
  268. IopDriverLoadingFailed(
  269. IN HANDLE KeyHandle OPTIONAL,
  270. IN PUNICODE_STRING KeyName OPTIONAL
  271. );
  272. BOOLEAN
  273. IopInitializeBootDrivers(
  274. IN PLOADER_PARAMETER_BLOCK LoaderBlock,
  275. OUT PDRIVER_OBJECT *PreviousDriver
  276. );
  277. BOOLEAN
  278. IopInitializeSystemDrivers(
  279. VOID
  280. );
  281. BOOLEAN
  282. IopIsLegacyDriver (
  283. IN PDRIVER_OBJECT DriverObject
  284. );
  285. VOID
  286. IopMarkHalDeviceNode(
  287. VOID
  288. );
  289. NTSTATUS
  290. IopPrepareDriverLoading(
  291. IN PUNICODE_STRING KeyName,
  292. IN HANDLE KeyHandle,
  293. IN PVOID ImageBase,
  294. IN BOOLEAN IsFilter
  295. );
  296. NTSTATUS
  297. IopPnpDriverStarted(
  298. IN PDRIVER_OBJECT DriverObject,
  299. IN HANDLE KeyHandle,
  300. IN PUNICODE_STRING ServiceName
  301. );
  302. NTSTATUS
  303. IopSynchronousCall(
  304. IN PDEVICE_OBJECT DeviceObject,
  305. IN PIO_STACK_LOCATION TopStackLocation,
  306. OUT PULONG_PTR Information
  307. );
  308. NTSTATUS
  309. IopUnloadDriver(
  310. IN PUNICODE_STRING DriverServiceName,
  311. IN BOOLEAN InvokedByPnpMgr
  312. );
  313. VOID
  314. IopIncrementDeviceObjectHandleCount(
  315. IN PDEVICE_OBJECT DeviceObject
  316. );
  317. VOID
  318. IopDecrementDeviceObjectHandleCount(
  319. IN PDEVICE_OBJECT DeviceObject
  320. );
  321. NTSTATUS
  322. IopBuildFullDriverPath(
  323. IN PUNICODE_STRING KeyName,
  324. IN HANDLE KeyHandle,
  325. OUT PUNICODE_STRING FullPath
  326. );
  327. #endif // _IOPCMN_