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.

396 lines
8.1 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. LOGICAL
  140. IopNotifyPnpWhenChainDereferenced(
  141. IN PDEVICE_OBJECT *PhysicalDeviceObjects,
  142. IN ULONG DeviceObjectCount,
  143. IN BOOLEAN Query,
  144. OUT PDEVICE_OBJECT *VetoingDevice
  145. );
  146. VOID
  147. FORCEINLINE
  148. IopQueueThreadIrp(
  149. IN PIRP Irp
  150. )
  151. /*++
  152. Routine Description:
  153. This routine queues the specified I/O Request Packet (IRP) to the thread
  154. whose TCB address is stored in the packet.
  155. Arguments:
  156. Irp - Supplies the IRP to be queued for the specified thread.
  157. Return Value:
  158. None.
  159. --*/
  160. {
  161. PETHREAD Thread;
  162. PLIST_ENTRY Head, Entry;
  163. Thread = Irp->Tail.Overlay.Thread;
  164. Head = &Thread->IrpList;
  165. Entry = &Irp->ThreadListEntry;
  166. KeEnterGuardedRegionThread (&Thread->Tcb);
  167. InsertHeadList( Head,
  168. Entry );
  169. KeLeaveGuardedRegionThread (&Thread->Tcb);
  170. }
  171. PDRIVER_OBJECT
  172. IopReferenceDriverObjectByName (
  173. IN PUNICODE_STRING DriverName
  174. );
  175. BOOLEAN
  176. IopSafebootDriverLoad(
  177. PUNICODE_STRING DriverId
  178. );
  179. NTSTATUS
  180. IopSetupRemoteBootCard(
  181. IN PLOADER_PARAMETER_BLOCK LoaderBlock,
  182. IN HANDLE UniqueIdHandle,
  183. IN PUNICODE_STRING UnicodeDeviceInstance
  184. );
  185. extern PVOID IopLoaderBlock;
  186. extern POBJECT_TYPE IoDriverObjectType;
  187. extern POBJECT_TYPE IoFileObjectType;
  188. //
  189. // Title Index to set registry key value
  190. //
  191. #define TITLE_INDEX_VALUE 0
  192. //++
  193. //
  194. // VOID
  195. // IopWstrToUnicodeString(
  196. // OUT PUNICODE_STRING u,
  197. // IN PCWSTR p
  198. // )
  199. //
  200. //--
  201. #define IopWstrToUnicodeString(u, p) \
  202. \
  203. (u)->Length = ((u)->MaximumLength = sizeof((p))) - sizeof(WCHAR); \
  204. (u)->Buffer = (p)
  205. //
  206. // Remote Boot exports to PNP
  207. //
  208. NTSTATUS
  209. IopStartTcpIpForRemoteBoot (
  210. PLOADER_PARAMETER_BLOCK LoaderBlock
  211. );
  212. //
  213. // Remote Boot exports to IO
  214. //
  215. NTSTATUS
  216. IopAddRemoteBootValuesToRegistry (
  217. PLOADER_PARAMETER_BLOCK LoaderBlock
  218. );
  219. NTSTATUS
  220. IopStartNetworkForRemoteBoot (
  221. PLOADER_PARAMETER_BLOCK LoaderBlock
  222. );
  223. //
  224. // PNP Manager exports to IO
  225. //
  226. typedef struct _DEVICE_NODE DEVICE_NODE, *PDEVICE_NODE;
  227. VOID
  228. IopChainDereferenceComplete(
  229. IN PDEVICE_OBJECT PhysicalDeviceObject,
  230. IN BOOLEAN OnCleanStack
  231. );
  232. NTSTATUS
  233. IopCreateRegistryKeyEx(
  234. OUT PHANDLE Handle,
  235. IN HANDLE BaseHandle OPTIONAL,
  236. IN PUNICODE_STRING KeyName,
  237. IN ACCESS_MASK DesiredAccess,
  238. IN ULONG CreateOptions,
  239. OUT PULONG Disposition OPTIONAL
  240. );
  241. NTSTATUS
  242. IopInitializePlugPlayServices(
  243. IN PLOADER_PARAMETER_BLOCK LoaderBlock,
  244. IN ULONG Phase
  245. );
  246. NTSTATUS
  247. IopOpenRegistryKeyEx(
  248. OUT PHANDLE Handle,
  249. IN HANDLE BaseHandle OPTIONAL,
  250. IN PUNICODE_STRING KeyName,
  251. IN ACCESS_MASK DesiredAccess
  252. );
  253. VOID
  254. IopDestroyDeviceNode(
  255. PDEVICE_NODE DeviceNode
  256. );
  257. NTSTATUS
  258. IopDriverLoadingFailed(
  259. IN HANDLE KeyHandle OPTIONAL,
  260. IN PUNICODE_STRING KeyName OPTIONAL
  261. );
  262. BOOLEAN
  263. IopInitializeBootDrivers(
  264. IN PLOADER_PARAMETER_BLOCK LoaderBlock,
  265. OUT PDRIVER_OBJECT *PreviousDriver
  266. );
  267. BOOLEAN
  268. IopInitializeSystemDrivers(
  269. VOID
  270. );
  271. BOOLEAN
  272. IopIsLegacyDriver (
  273. IN PDRIVER_OBJECT DriverObject
  274. );
  275. VOID
  276. IopMarkHalDeviceNode(
  277. VOID
  278. );
  279. NTSTATUS
  280. IopPrepareDriverLoading(
  281. IN PUNICODE_STRING KeyName,
  282. IN HANDLE KeyHandle,
  283. IN PVOID ImageBase,
  284. IN BOOLEAN IsFilter
  285. );
  286. NTSTATUS
  287. IopPnpDriverStarted(
  288. IN PDRIVER_OBJECT DriverObject,
  289. IN HANDLE KeyHandle,
  290. IN PUNICODE_STRING ServiceName
  291. );
  292. NTSTATUS
  293. IopSynchronousCall(
  294. IN PDEVICE_OBJECT DeviceObject,
  295. IN PIO_STACK_LOCATION TopStackLocation,
  296. OUT PULONG_PTR Information
  297. );
  298. NTSTATUS
  299. IopUnloadDriver(
  300. IN PUNICODE_STRING DriverServiceName,
  301. IN BOOLEAN InvokedByPnpMgr
  302. );
  303. VOID
  304. IopIncrementDeviceObjectHandleCount(
  305. IN PDEVICE_OBJECT DeviceObject
  306. );
  307. VOID
  308. IopDecrementDeviceObjectHandleCount(
  309. IN PDEVICE_OBJECT DeviceObject
  310. );
  311. NTSTATUS
  312. IopBuildFullDriverPath(
  313. IN PUNICODE_STRING KeyName,
  314. IN HANDLE KeyHandle,
  315. OUT PUNICODE_STRING FullPath
  316. );
  317. #endif // _IOPCMN_