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.

1085 lines
26 KiB

  1. /*++ BUILD Version: 0002 // Increment this if a change has global effects
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. ob.h
  5. Abstract:
  6. This module contains the object manager structure public data
  7. structures and procedure prototypes to be used within the NT
  8. system.
  9. Author:
  10. Steve Wood (stevewo) 28-Mar-1989
  11. Revision History:
  12. --*/
  13. #ifndef _OB_
  14. #define _OB_
  15. //
  16. // System Initialization procedure for OB subcomponent of NTOS
  17. //
  18. BOOLEAN
  19. ObInitSystem( VOID );
  20. VOID
  21. ObShutdownSystem(
  22. IN ULONG Phase
  23. );
  24. NTSTATUS
  25. ObInitProcess(
  26. PEPROCESS ParentProcess OPTIONAL,
  27. PEPROCESS NewProcess
  28. );
  29. VOID
  30. ObInitProcess2(
  31. PEPROCESS NewProcess
  32. );
  33. VOID
  34. ObKillProcess(
  35. PEPROCESS Process
  36. );
  37. VOID
  38. ObClearProcessHandleTable (
  39. PEPROCESS Process
  40. );
  41. VOID
  42. ObDereferenceProcessHandleTable (
  43. PEPROCESS SourceProcess
  44. );
  45. PHANDLE_TABLE
  46. ObReferenceProcessHandleTable (
  47. PEPROCESS SourceProcess
  48. );
  49. ULONG
  50. ObGetProcessHandleCount (
  51. PEPROCESS Process
  52. );
  53. NTSTATUS
  54. ObDuplicateObject (
  55. IN PEPROCESS SourceProcess,
  56. IN HANDLE SourceHandle,
  57. IN PEPROCESS TargetProcess OPTIONAL,
  58. OUT PHANDLE TargetHandle OPTIONAL,
  59. IN ACCESS_MASK DesiredAccess,
  60. IN ULONG HandleAttributes,
  61. IN ULONG Options,
  62. IN KPROCESSOR_MODE PreviousMode
  63. );
  64. // begin_ntddk begin_wdm begin_nthal begin_ntosp begin_ntifs
  65. //
  66. // Object Manager types
  67. //
  68. typedef struct _OBJECT_HANDLE_INFORMATION {
  69. ULONG HandleAttributes;
  70. ACCESS_MASK GrantedAccess;
  71. } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
  72. // end_ntddk end_wdm end_nthal end_ntifs
  73. typedef struct _OBJECT_DUMP_CONTROL {
  74. PVOID Stream;
  75. ULONG Detail;
  76. } OB_DUMP_CONTROL, *POB_DUMP_CONTROL;
  77. typedef VOID (*OB_DUMP_METHOD)(
  78. IN PVOID Object,
  79. IN POB_DUMP_CONTROL Control OPTIONAL
  80. );
  81. typedef enum _OB_OPEN_REASON {
  82. ObCreateHandle,
  83. ObOpenHandle,
  84. ObDuplicateHandle,
  85. ObInheritHandle,
  86. ObMaxOpenReason
  87. } OB_OPEN_REASON;
  88. typedef NTSTATUS (*OB_OPEN_METHOD)(
  89. IN OB_OPEN_REASON OpenReason,
  90. IN PEPROCESS Process OPTIONAL,
  91. IN PVOID Object,
  92. IN ACCESS_MASK GrantedAccess,
  93. IN ULONG HandleCount
  94. );
  95. typedef BOOLEAN (*OB_OKAYTOCLOSE_METHOD)(
  96. IN PEPROCESS Process OPTIONAL,
  97. IN PVOID Object,
  98. IN HANDLE Handle,
  99. IN KPROCESSOR_MODE PreviousMode
  100. );
  101. typedef VOID (*OB_CLOSE_METHOD)(
  102. IN PEPROCESS Process OPTIONAL,
  103. IN PVOID Object,
  104. IN ACCESS_MASK GrantedAccess,
  105. IN ULONG ProcessHandleCount,
  106. IN ULONG SystemHandleCount
  107. );
  108. typedef VOID (*OB_DELETE_METHOD)(
  109. IN PVOID Object
  110. );
  111. typedef NTSTATUS (*OB_PARSE_METHOD)(
  112. IN PVOID ParseObject,
  113. IN PVOID ObjectType,
  114. IN OUT PACCESS_STATE AccessState,
  115. IN KPROCESSOR_MODE AccessMode,
  116. IN ULONG Attributes,
  117. IN OUT PUNICODE_STRING CompleteName,
  118. IN OUT PUNICODE_STRING RemainingName,
  119. IN OUT PVOID Context OPTIONAL,
  120. IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
  121. OUT PVOID *Object
  122. );
  123. typedef NTSTATUS (*OB_SECURITY_METHOD)(
  124. IN PVOID Object,
  125. IN SECURITY_OPERATION_CODE OperationCode,
  126. IN PSECURITY_INFORMATION SecurityInformation,
  127. IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
  128. IN OUT PULONG CapturedLength,
  129. IN OUT PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
  130. IN POOL_TYPE PoolType,
  131. IN PGENERIC_MAPPING GenericMapping
  132. );
  133. typedef NTSTATUS (*OB_QUERYNAME_METHOD)(
  134. IN PVOID Object,
  135. IN BOOLEAN HasObjectName,
  136. OUT POBJECT_NAME_INFORMATION ObjectNameInfo,
  137. IN ULONG Length,
  138. OUT PULONG ReturnLength
  139. );
  140. /*
  141. A security method and its caller must obey the following w.r.t.
  142. capturing and probing parameters:
  143. For a query operation, the caller must pass a kernel space address for
  144. CapturedLength. The caller should be able to assume that it points to
  145. valid data that will not change. In addition, the SecurityDescriptor
  146. parameter (which will receive the result of the query operation) must
  147. be probed for write up to the length given in CapturedLength. The
  148. security method itself must always write to the SecurityDescriptor
  149. buffer in a try clause in case the caller de-allocates it.
  150. For a set operation, the SecurityDescriptor parameter must have
  151. been captured via SeCaptureSecurityDescriptor. This parameter is
  152. not optional, and therefore may not be NULL.
  153. */
  154. //
  155. // Prototypes for Win32 WindowStation and Desktop object callout routines
  156. //
  157. typedef struct _WIN32_OPENMETHOD_PARAMETERS {
  158. OB_OPEN_REASON OpenReason;
  159. PEPROCESS Process;
  160. PVOID Object;
  161. ACCESS_MASK GrantedAccess;
  162. ULONG HandleCount;
  163. } WIN32_OPENMETHOD_PARAMETERS, *PKWIN32_OPENMETHOD_PARAMETERS;
  164. typedef
  165. NTSTATUS
  166. (*PKWIN32_OPENMETHOD_CALLOUT) ( PKWIN32_OPENMETHOD_PARAMETERS );
  167. extern PKWIN32_OPENMETHOD_CALLOUT ExDesktopOpenProcedureCallout;
  168. extern PKWIN32_OPENMETHOD_CALLOUT ExWindowStationOpenProcedureCallout;
  169. typedef struct _WIN32_OKAYTOCLOSEMETHOD_PARAMETERS {
  170. PEPROCESS Process;
  171. PVOID Object;
  172. HANDLE Handle;
  173. KPROCESSOR_MODE PreviousMode;
  174. } WIN32_OKAYTOCLOSEMETHOD_PARAMETERS, *PKWIN32_OKAYTOCLOSEMETHOD_PARAMETERS;
  175. typedef
  176. NTSTATUS
  177. (*PKWIN32_OKTOCLOSEMETHOD_CALLOUT) ( PKWIN32_OKAYTOCLOSEMETHOD_PARAMETERS );
  178. extern PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExDesktopOkToCloseProcedureCallout;
  179. extern PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExWindowStationOkToCloseProcedureCallout;
  180. typedef struct _WIN32_CLOSEMETHOD_PARAMETERS {
  181. PEPROCESS Process;
  182. PVOID Object;
  183. ACCESS_MASK GrantedAccess;
  184. ULONG ProcessHandleCount;
  185. ULONG SystemHandleCount;
  186. } WIN32_CLOSEMETHOD_PARAMETERS, *PKWIN32_CLOSEMETHOD_PARAMETERS;
  187. typedef
  188. NTSTATUS
  189. (*PKWIN32_CLOSEMETHOD_CALLOUT) ( PKWIN32_CLOSEMETHOD_PARAMETERS );
  190. extern PKWIN32_CLOSEMETHOD_CALLOUT ExDesktopCloseProcedureCallout;
  191. extern PKWIN32_CLOSEMETHOD_CALLOUT ExWindowStationCloseProcedureCallout;
  192. typedef struct _WIN32_DELETEMETHOD_PARAMETERS {
  193. PVOID Object;
  194. } WIN32_DELETEMETHOD_PARAMETERS, *PKWIN32_DELETEMETHOD_PARAMETERS;
  195. typedef
  196. NTSTATUS
  197. (*PKWIN32_DELETEMETHOD_CALLOUT) ( PKWIN32_DELETEMETHOD_PARAMETERS );
  198. extern PKWIN32_DELETEMETHOD_CALLOUT ExDesktopDeleteProcedureCallout;
  199. extern PKWIN32_DELETEMETHOD_CALLOUT ExWindowStationDeleteProcedureCallout;
  200. typedef struct _WIN32_PARSEMETHOD_PARAMETERS {
  201. PVOID ParseObject;
  202. PVOID ObjectType;
  203. PACCESS_STATE AccessState;
  204. KPROCESSOR_MODE AccessMode;
  205. ULONG Attributes;
  206. PUNICODE_STRING CompleteName;
  207. PUNICODE_STRING RemainingName;
  208. PVOID Context OPTIONAL;
  209. PSECURITY_QUALITY_OF_SERVICE SecurityQos;
  210. PVOID *Object;
  211. } WIN32_PARSEMETHOD_PARAMETERS, *PKWIN32_PARSEMETHOD_PARAMETERS;
  212. typedef
  213. NTSTATUS
  214. (*PKWIN32_PARSEMETHOD_CALLOUT) ( PKWIN32_PARSEMETHOD_PARAMETERS );
  215. extern PKWIN32_PARSEMETHOD_CALLOUT ExWindowStationParseProcedureCallout;
  216. //
  217. // Object Type Structure
  218. //
  219. typedef struct _OBJECT_TYPE_INITIALIZER {
  220. USHORT Length;
  221. BOOLEAN UseDefaultObject;
  222. BOOLEAN CaseInsensitive;
  223. ULONG InvalidAttributes;
  224. GENERIC_MAPPING GenericMapping;
  225. ULONG ValidAccessMask;
  226. BOOLEAN SecurityRequired;
  227. BOOLEAN MaintainHandleCount;
  228. BOOLEAN MaintainTypeList;
  229. POOL_TYPE PoolType;
  230. ULONG DefaultPagedPoolCharge;
  231. ULONG DefaultNonPagedPoolCharge;
  232. OB_DUMP_METHOD DumpProcedure;
  233. OB_OPEN_METHOD OpenProcedure;
  234. OB_CLOSE_METHOD CloseProcedure;
  235. OB_DELETE_METHOD DeleteProcedure;
  236. OB_PARSE_METHOD ParseProcedure;
  237. OB_SECURITY_METHOD SecurityProcedure;
  238. OB_QUERYNAME_METHOD QueryNameProcedure;
  239. OB_OKAYTOCLOSE_METHOD OkayToCloseProcedure;
  240. } OBJECT_TYPE_INITIALIZER, *POBJECT_TYPE_INITIALIZER;
  241. #define OBJECT_LOCK_COUNT 4
  242. typedef struct _OBJECT_TYPE {
  243. ERESOURCE Mutex;
  244. LIST_ENTRY TypeList;
  245. UNICODE_STRING Name; // Copy from object header for convenience
  246. PVOID DefaultObject;
  247. ULONG Index;
  248. ULONG TotalNumberOfObjects;
  249. ULONG TotalNumberOfHandles;
  250. ULONG HighWaterNumberOfObjects;
  251. ULONG HighWaterNumberOfHandles;
  252. OBJECT_TYPE_INITIALIZER TypeInfo;
  253. #ifdef POOL_TAGGING
  254. ULONG Key;
  255. #endif //POOL_TAGGING
  256. ERESOURCE ObjectLocks[ OBJECT_LOCK_COUNT ];
  257. } OBJECT_TYPE, *POBJECT_TYPE;
  258. //
  259. // Object Directory Structure
  260. //
  261. #define NUMBER_HASH_BUCKETS 37
  262. typedef struct _OBJECT_DIRECTORY {
  263. struct _OBJECT_DIRECTORY_ENTRY *HashBuckets[ NUMBER_HASH_BUCKETS ];
  264. EX_PUSH_LOCK Lock;
  265. struct _DEVICE_MAP *DeviceMap;
  266. USHORT Reserved;
  267. USHORT SymbolicLinkUsageCount;
  268. } OBJECT_DIRECTORY, *POBJECT_DIRECTORY;
  269. // end_ntosp
  270. //
  271. // Object Directory Entry Structure
  272. //
  273. typedef struct _OBJECT_DIRECTORY_ENTRY {
  274. struct _OBJECT_DIRECTORY_ENTRY *ChainLink;
  275. PVOID Object;
  276. } OBJECT_DIRECTORY_ENTRY, *POBJECT_DIRECTORY_ENTRY;
  277. //
  278. // Symbolic Link Object Structure
  279. //
  280. typedef struct _OBJECT_SYMBOLIC_LINK {
  281. LARGE_INTEGER CreationTime;
  282. UNICODE_STRING LinkTarget;
  283. UNICODE_STRING LinkTargetRemaining;
  284. PVOID LinkTargetObject;
  285. ULONG DosDeviceDriveIndex; // 1-based index into KUSER_SHARED_DATA.DosDeviceDriveType
  286. } OBJECT_SYMBOLIC_LINK, *POBJECT_SYMBOLIC_LINK;
  287. //
  288. // Device Map Structure
  289. //
  290. typedef struct _DEVICE_MAP {
  291. POBJECT_DIRECTORY DosDevicesDirectory;
  292. POBJECT_DIRECTORY GlobalDosDevicesDirectory;
  293. ULONG ReferenceCount;
  294. ULONG DriveMap;
  295. UCHAR DriveType[ 32 ];
  296. } DEVICE_MAP, *PDEVICE_MAP;
  297. extern PDEVICE_MAP ObSystemDeviceMap;
  298. //
  299. // Object Handle Count Database
  300. //
  301. typedef struct _OBJECT_HANDLE_COUNT_ENTRY {
  302. PEPROCESS Process;
  303. ULONG HandleCount;
  304. } OBJECT_HANDLE_COUNT_ENTRY, *POBJECT_HANDLE_COUNT_ENTRY;
  305. typedef struct _OBJECT_HANDLE_COUNT_DATABASE {
  306. ULONG CountEntries;
  307. OBJECT_HANDLE_COUNT_ENTRY HandleCountEntries[ 1 ];
  308. } OBJECT_HANDLE_COUNT_DATABASE, *POBJECT_HANDLE_COUNT_DATABASE;
  309. //
  310. // Object Header Structure
  311. //
  312. // The SecurityQuotaCharged is the amount of quota charged to cover
  313. // the GROUP and DISCRETIONARY ACL fields of the security descriptor
  314. // only. The OWNER and SYSTEM ACL fields get charged for at a fixed
  315. // rate that may be less than or greater than the amount actually used.
  316. //
  317. // If the object has no security, then the SecurityQuotaCharged and the
  318. // SecurityQuotaInUse fields are set to zero.
  319. //
  320. // Modification of the OWNER and SYSTEM ACL fields should never fail
  321. // due to quota exceeded problems. Modifications to the GROUP and
  322. // DISCRETIONARY ACL fields may fail due to quota exceeded problems.
  323. //
  324. //
  325. typedef struct _OBJECT_CREATE_INFORMATION {
  326. ULONG Attributes;
  327. HANDLE RootDirectory;
  328. PVOID ParseContext;
  329. KPROCESSOR_MODE ProbeMode;
  330. ULONG PagedPoolCharge;
  331. ULONG NonPagedPoolCharge;
  332. ULONG SecurityDescriptorCharge;
  333. PSECURITY_DESCRIPTOR SecurityDescriptor;
  334. PSECURITY_QUALITY_OF_SERVICE SecurityQos;
  335. SECURITY_QUALITY_OF_SERVICE SecurityQualityOfService;
  336. } OBJECT_CREATE_INFORMATION;
  337. // begin_ntosp
  338. typedef struct _OBJECT_CREATE_INFORMATION *POBJECT_CREATE_INFORMATION;;
  339. typedef struct _OBJECT_HEADER {
  340. LONG PointerCount;
  341. union {
  342. LONG HandleCount;
  343. PVOID NextToFree;
  344. };
  345. POBJECT_TYPE Type;
  346. UCHAR NameInfoOffset;
  347. UCHAR HandleInfoOffset;
  348. UCHAR QuotaInfoOffset;
  349. UCHAR Flags;
  350. union {
  351. POBJECT_CREATE_INFORMATION ObjectCreateInfo;
  352. PVOID QuotaBlockCharged;
  353. };
  354. PSECURITY_DESCRIPTOR SecurityDescriptor;
  355. QUAD Body;
  356. } OBJECT_HEADER, *POBJECT_HEADER;
  357. // end_ntosp
  358. typedef struct _OBJECT_HEADER_QUOTA_INFO {
  359. ULONG PagedPoolCharge;
  360. ULONG NonPagedPoolCharge;
  361. ULONG SecurityDescriptorCharge;
  362. PEPROCESS ExclusiveProcess;
  363. #ifdef _WIN64
  364. ULONG64 Reserved; // Win64 requires these structures to be 16 byte aligned.
  365. #endif
  366. } OBJECT_HEADER_QUOTA_INFO, *POBJECT_HEADER_QUOTA_INFO;
  367. typedef struct _OBJECT_HEADER_HANDLE_INFO {
  368. union {
  369. POBJECT_HANDLE_COUNT_DATABASE HandleCountDataBase;
  370. OBJECT_HANDLE_COUNT_ENTRY SingleEntry;
  371. };
  372. } OBJECT_HEADER_HANDLE_INFO, *POBJECT_HEADER_HANDLE_INFO;
  373. // begin_ntosp
  374. typedef struct _OBJECT_HEADER_NAME_INFO {
  375. POBJECT_DIRECTORY Directory;
  376. UNICODE_STRING Name;
  377. ULONG QueryReferences;
  378. #if DBG
  379. ULONG Reserved2;
  380. LONG DbgDereferenceCount;
  381. #ifdef _WIN64
  382. ULONG64 Reserved3; // Win64 requires these structures to be 16 byte aligned.
  383. #endif
  384. #endif
  385. } OBJECT_HEADER_NAME_INFO, *POBJECT_HEADER_NAME_INFO;
  386. // end_ntosp
  387. typedef struct _OBJECT_HEADER_CREATOR_INFO {
  388. LIST_ENTRY TypeList;
  389. HANDLE CreatorUniqueProcess;
  390. USHORT CreatorBackTraceIndex;
  391. USHORT Reserved;
  392. } OBJECT_HEADER_CREATOR_INFO, *POBJECT_HEADER_CREATOR_INFO;
  393. #define OB_FLAG_NEW_OBJECT 0x01
  394. #define OB_FLAG_KERNEL_OBJECT 0x02
  395. #define OB_FLAG_CREATOR_INFO 0x04
  396. #define OB_FLAG_EXCLUSIVE_OBJECT 0x08
  397. #define OB_FLAG_PERMANENT_OBJECT 0x10
  398. #define OB_FLAG_DEFAULT_SECURITY_QUOTA 0x20
  399. #define OB_FLAG_SINGLE_HANDLE_ENTRY 0x40
  400. #define OB_FLAG_DELETED_INLINE 0x80
  401. // begin_ntosp
  402. #define OBJECT_TO_OBJECT_HEADER( o ) \
  403. CONTAINING_RECORD( (o), OBJECT_HEADER, Body )
  404. // end_ntosp
  405. #define OBJECT_HEADER_TO_EXCLUSIVE_PROCESS( oh ) ((oh->Flags & OB_FLAG_EXCLUSIVE_OBJECT) == 0 ? \
  406. NULL : (((POBJECT_HEADER_QUOTA_INFO)((PCHAR)(oh) - (oh)->QuotaInfoOffset))->ExclusiveProcess))
  407. #define OBJECT_HEADER_TO_QUOTA_INFO( oh ) ((POBJECT_HEADER_QUOTA_INFO) \
  408. ((oh)->QuotaInfoOffset == 0 ? NULL : ((PCHAR)(oh) - (oh)->QuotaInfoOffset)))
  409. #define OBJECT_HEADER_TO_HANDLE_INFO( oh ) ((POBJECT_HEADER_HANDLE_INFO) \
  410. ((oh)->HandleInfoOffset == 0 ? NULL : ((PCHAR)(oh) - (oh)->HandleInfoOffset)))
  411. // begin_ntosp
  412. #define OBJECT_HEADER_TO_NAME_INFO( oh ) ((POBJECT_HEADER_NAME_INFO) \
  413. ((oh)->NameInfoOffset == 0 ? NULL : ((PCHAR)(oh) - (oh)->NameInfoOffset)))
  414. #define OBJECT_HEADER_TO_CREATOR_INFO( oh ) ((POBJECT_HEADER_CREATOR_INFO) \
  415. (((oh)->Flags & OB_FLAG_CREATOR_INFO) == 0 ? NULL : ((PCHAR)(oh) - sizeof(OBJECT_HEADER_CREATOR_INFO))))
  416. NTKERNELAPI
  417. NTSTATUS
  418. ObCreateObjectType(
  419. IN PUNICODE_STRING TypeName,
  420. IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer,
  421. IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL,
  422. OUT POBJECT_TYPE *ObjectType
  423. );
  424. // end_ntosp
  425. VOID
  426. FASTCALL
  427. ObFreeObjectCreateInfoBuffer(
  428. IN POBJECT_CREATE_INFORMATION ObjectCreateInfo
  429. );
  430. NTSTATUS
  431. ObSetDirectoryDeviceMap (
  432. OUT PDEVICE_MAP *ppDeviceMap OPTIONAL,
  433. IN HANDLE DirectoryHandle
  434. );
  435. ULONG
  436. ObIsLUIDDeviceMapsEnabled (
  437. );
  438. BOOLEAN
  439. ObIsObjectDeletionInline(
  440. IN PVOID Object
  441. );
  442. // begin_nthal
  443. NTKERNELAPI
  444. VOID
  445. ObDeleteCapturedInsertInfo(
  446. IN PVOID Object
  447. );
  448. // begin_ntosp
  449. NTKERNELAPI
  450. NTSTATUS
  451. ObCreateObject(
  452. IN KPROCESSOR_MODE ProbeMode,
  453. IN POBJECT_TYPE ObjectType,
  454. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  455. IN KPROCESSOR_MODE OwnershipMode,
  456. IN OUT PVOID ParseContext OPTIONAL,
  457. IN ULONG ObjectBodySize,
  458. IN ULONG PagedPoolCharge,
  459. IN ULONG NonPagedPoolCharge,
  460. OUT PVOID *Object
  461. );
  462. //
  463. // These inlines correct an issue where the compiler refetches
  464. // the output object over and over again because it thinks its
  465. // a possible alias for other stores.
  466. //
  467. FORCEINLINE
  468. NTSTATUS
  469. _ObCreateObject(
  470. IN KPROCESSOR_MODE ProbeMode,
  471. IN POBJECT_TYPE ObjectType,
  472. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  473. IN KPROCESSOR_MODE OwnershipMode,
  474. IN OUT PVOID ParseContext OPTIONAL,
  475. IN ULONG ObjectBodySize,
  476. IN ULONG PagedPoolCharge,
  477. IN ULONG NonPagedPoolCharge,
  478. OUT PVOID *pObject
  479. )
  480. {
  481. PVOID Object;
  482. NTSTATUS Status;
  483. Status = ObCreateObject (ProbeMode,
  484. ObjectType,
  485. ObjectAttributes,
  486. OwnershipMode,
  487. ParseContext,
  488. ObjectBodySize,
  489. PagedPoolCharge,
  490. NonPagedPoolCharge,
  491. &Object);
  492. *pObject = Object;
  493. return Status;
  494. }
  495. #define ObCreateObject _ObCreateObject
  496. NTKERNELAPI
  497. NTSTATUS
  498. ObInsertObject(
  499. IN PVOID Object,
  500. IN PACCESS_STATE PassedAccessState OPTIONAL,
  501. IN ACCESS_MASK DesiredAccess OPTIONAL,
  502. IN ULONG ObjectPointerBias,
  503. OUT PVOID *NewObject OPTIONAL,
  504. OUT PHANDLE Handle OPTIONAL
  505. );
  506. // end_nthal
  507. NTKERNELAPI // ntddk wdm nthal ntifs
  508. NTSTATUS // ntddk wdm nthal ntifs
  509. ObReferenceObjectByHandle( // ntddk wdm nthal ntifs
  510. IN HANDLE Handle, // ntddk wdm nthal ntifs
  511. IN ACCESS_MASK DesiredAccess, // ntddk wdm nthal ntifs
  512. IN POBJECT_TYPE ObjectType OPTIONAL, // ntddk wdm nthal ntifs
  513. IN KPROCESSOR_MODE AccessMode, // ntddk wdm nthal ntifs
  514. OUT PVOID *Object, // ntddk wdm nthal ntifs
  515. OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL // ntddk wdm nthal ntifs
  516. ); // ntddk wdm nthal ntifs
  517. FORCEINLINE
  518. NTSTATUS
  519. _ObReferenceObjectByHandle(
  520. IN HANDLE Handle,
  521. IN ACCESS_MASK DesiredAccess,
  522. IN POBJECT_TYPE ObjectType OPTIONAL,
  523. IN KPROCESSOR_MODE AccessMode,
  524. OUT PVOID *pObject,
  525. OUT POBJECT_HANDLE_INFORMATION pHandleInformation OPTIONAL
  526. )
  527. {
  528. PVOID Object;
  529. NTSTATUS Status;
  530. Status = ObReferenceObjectByHandle (Handle,
  531. DesiredAccess,
  532. ObjectType,
  533. AccessMode,
  534. &Object,
  535. pHandleInformation);
  536. *pObject = Object;
  537. return Status;
  538. }
  539. #define ObReferenceObjectByHandle _ObReferenceObjectByHandle
  540. NTKERNELAPI
  541. NTSTATUS
  542. ObReferenceFileObjectForWrite(
  543. IN HANDLE Handle,
  544. IN KPROCESSOR_MODE AccessMode,
  545. OUT PVOID *FileObject,
  546. OUT POBJECT_HANDLE_INFORMATION HandleInformation
  547. );
  548. NTKERNELAPI
  549. NTSTATUS
  550. ObOpenObjectByName(
  551. IN POBJECT_ATTRIBUTES ObjectAttributes,
  552. IN POBJECT_TYPE ObjectType,
  553. IN KPROCESSOR_MODE AccessMode,
  554. IN OUT PACCESS_STATE PassedAccessState OPTIONAL,
  555. IN ACCESS_MASK DesiredAccess OPTIONAL,
  556. IN OUT PVOID ParseContext OPTIONAL,
  557. OUT PHANDLE Handle
  558. );
  559. NTKERNELAPI // ntifs
  560. NTSTATUS // ntifs
  561. ObOpenObjectByPointer( // ntifs
  562. IN PVOID Object, // ntifs
  563. IN ULONG HandleAttributes, // ntifs
  564. IN PACCESS_STATE PassedAccessState OPTIONAL, // ntifs
  565. IN ACCESS_MASK DesiredAccess OPTIONAL, // ntifs
  566. IN POBJECT_TYPE ObjectType OPTIONAL, // ntifs
  567. IN KPROCESSOR_MODE AccessMode, // ntifs
  568. OUT PHANDLE Handle // ntifs
  569. ); // ntifs
  570. NTSTATUS
  571. ObReferenceObjectByName(
  572. IN PUNICODE_STRING ObjectName,
  573. IN ULONG Attributes,
  574. IN PACCESS_STATE PassedAccessState OPTIONAL,
  575. IN ACCESS_MASK DesiredAccess OPTIONAL,
  576. IN POBJECT_TYPE ObjectType,
  577. IN KPROCESSOR_MODE AccessMode,
  578. IN OUT PVOID ParseContext OPTIONAL,
  579. OUT PVOID *Object
  580. );
  581. // end_ntosp
  582. NTKERNELAPI // ntifs
  583. VOID // ntifs
  584. ObMakeTemporaryObject( // ntifs
  585. IN PVOID Object // ntifs
  586. ); // ntifs
  587. // begin_ntosp
  588. NTKERNELAPI
  589. BOOLEAN
  590. ObFindHandleForObject(
  591. IN PEPROCESS Process,
  592. IN PVOID Object,
  593. IN POBJECT_TYPE ObjectType OPTIONAL,
  594. IN POBJECT_HANDLE_INFORMATION MatchCriteria OPTIONAL,
  595. OUT PHANDLE Handle
  596. );
  597. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  598. #define ObDereferenceObject(a) \
  599. ObfDereferenceObject(a)
  600. #define ObReferenceObject(Object) ObfReferenceObject(Object)
  601. NTKERNELAPI
  602. LONG
  603. FASTCALL
  604. ObfReferenceObject(
  605. IN PVOID Object
  606. );
  607. NTKERNELAPI
  608. NTSTATUS
  609. ObReferenceObjectByPointer(
  610. IN PVOID Object,
  611. IN ACCESS_MASK DesiredAccess,
  612. IN POBJECT_TYPE ObjectType,
  613. IN KPROCESSOR_MODE AccessMode
  614. );
  615. NTKERNELAPI
  616. LONG
  617. FASTCALL
  618. ObfDereferenceObject(
  619. IN PVOID Object
  620. );
  621. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  622. NTKERNELAPI
  623. BOOLEAN
  624. FASTCALL
  625. ObReferenceObjectSafe (
  626. IN PVOID Object
  627. );
  628. NTKERNELAPI
  629. LONG
  630. FASTCALL
  631. ObReferenceObjectEx (
  632. IN PVOID Object,
  633. IN ULONG Count
  634. );
  635. LONG
  636. FASTCALL
  637. ObDereferenceObjectEx (
  638. IN PVOID Object,
  639. IN ULONG Count
  640. );
  641. NTSTATUS
  642. ObWaitForSingleObject(
  643. IN HANDLE Handle,
  644. IN BOOLEAN Alertable,
  645. IN PLARGE_INTEGER Timeout OPTIONAL
  646. );
  647. VOID
  648. ObDereferenceObjectDeferDelete (
  649. IN PVOID Object
  650. );
  651. // begin_ntifs begin_ntosp
  652. NTKERNELAPI
  653. NTSTATUS
  654. ObQueryNameString(
  655. IN PVOID Object,
  656. OUT POBJECT_NAME_INFORMATION ObjectNameInfo,
  657. IN ULONG Length,
  658. OUT PULONG ReturnLength
  659. );
  660. // end_ntifs end_ntosp
  661. #if DBG
  662. PUNICODE_STRING
  663. ObGetObjectName(
  664. IN PVOID Object
  665. );
  666. #endif // DBG
  667. NTSTATUS
  668. ObQueryTypeName(
  669. IN PVOID Object,
  670. PUNICODE_STRING ObjectTypeName,
  671. IN ULONG Length,
  672. OUT PULONG ReturnLength
  673. );
  674. NTSTATUS
  675. ObQueryTypeInfo(
  676. IN POBJECT_TYPE ObjectType,
  677. OUT POBJECT_TYPE_INFORMATION ObjectTypeInfo,
  678. IN ULONG Length,
  679. OUT PULONG ReturnLength
  680. );
  681. NTSTATUS
  682. ObDumpObjectByHandle(
  683. IN HANDLE Handle,
  684. IN POB_DUMP_CONTROL Control OPTIONAL
  685. );
  686. NTSTATUS
  687. ObDumpObjectByPointer(
  688. IN PVOID Object,
  689. IN POB_DUMP_CONTROL Control OPTIONAL
  690. );
  691. NTSTATUS
  692. ObSetDeviceMap(
  693. IN PEPROCESS TargetProcess,
  694. IN HANDLE DirectoryHandle
  695. );
  696. NTSTATUS
  697. ObQueryDeviceMapInformation(
  698. IN PEPROCESS TargetProcess,
  699. OUT PPROCESS_DEVICEMAP_INFORMATION DeviceMapInformation,
  700. IN ULONG Flags
  701. );
  702. VOID
  703. ObInheritDeviceMap(
  704. IN PEPROCESS NewProcess,
  705. IN PEPROCESS ParentProcess
  706. );
  707. VOID
  708. ObDereferenceDeviceMap(
  709. IN PEPROCESS Process
  710. );
  711. // begin_ntifs begin_ntddk begin_wdm begin_ntosp
  712. NTSTATUS
  713. ObGetObjectSecurity(
  714. IN PVOID Object,
  715. OUT PSECURITY_DESCRIPTOR *SecurityDescriptor,
  716. OUT PBOOLEAN MemoryAllocated
  717. );
  718. VOID
  719. ObReleaseObjectSecurity(
  720. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  721. IN BOOLEAN MemoryAllocated
  722. );
  723. // end_ntifs end_ntddk end_wdm end_ntosp
  724. NTSTATUS
  725. ObLogSecurityDescriptor (
  726. IN PSECURITY_DESCRIPTOR InputSecurityDescriptor,
  727. OUT PSECURITY_DESCRIPTOR *OutputSecurityDescriptor,
  728. ULONG RefBias
  729. );
  730. VOID
  731. ObDereferenceSecurityDescriptor (
  732. PSECURITY_DESCRIPTOR SecurityDescriptor,
  733. ULONG Count
  734. );
  735. VOID
  736. ObReferenceSecurityDescriptor (
  737. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  738. IN ULONG Count
  739. );
  740. NTSTATUS
  741. ObAssignObjectSecurityDescriptor(
  742. IN PVOID Object,
  743. IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL,
  744. IN POOL_TYPE PoolType
  745. );
  746. NTSTATUS
  747. ObValidateSecurityQuota(
  748. IN PVOID Object,
  749. IN ULONG NewSize
  750. );
  751. // begin_ntosp
  752. NTKERNELAPI
  753. BOOLEAN
  754. ObCheckCreateObjectAccess(
  755. IN PVOID DirectoryObject,
  756. IN ACCESS_MASK CreateAccess,
  757. IN PACCESS_STATE AccessState OPTIONAL,
  758. IN PUNICODE_STRING ComponentName,
  759. IN BOOLEAN TypeMutexLocked,
  760. IN KPROCESSOR_MODE PreviousMode,
  761. OUT PNTSTATUS AccessStatus
  762. );
  763. NTKERNELAPI
  764. BOOLEAN
  765. ObCheckObjectAccess(
  766. IN PVOID Object,
  767. IN PACCESS_STATE AccessState,
  768. IN BOOLEAN TypeMutexLocked,
  769. IN KPROCESSOR_MODE AccessMode,
  770. OUT PNTSTATUS AccessStatus
  771. );
  772. NTKERNELAPI
  773. NTSTATUS
  774. ObAssignSecurity(
  775. IN PACCESS_STATE AccessState,
  776. IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
  777. IN PVOID Object,
  778. IN POBJECT_TYPE ObjectType
  779. );
  780. // end_ntosp
  781. NTSTATUS // ntifs
  782. ObQueryObjectAuditingByHandle( // ntifs
  783. IN HANDLE Handle, // ntifs
  784. OUT PBOOLEAN GenerateOnClose // ntifs
  785. ); // ntifs
  786. // begin_ntosp
  787. NTSTATUS
  788. ObSetSecurityObjectByPointer (
  789. IN PVOID Object,
  790. IN SECURITY_INFORMATION SecurityInformation,
  791. IN PSECURITY_DESCRIPTOR SecurityDescriptor
  792. );
  793. NTSTATUS
  794. ObSetHandleAttributes (
  795. IN HANDLE Handle,
  796. IN POBJECT_HANDLE_FLAG_INFORMATION HandleFlags,
  797. IN KPROCESSOR_MODE PreviousMode
  798. );
  799. NTSTATUS
  800. ObCloseHandle (
  801. IN HANDLE Handle,
  802. IN KPROCESSOR_MODE PreviousMode
  803. );
  804. // end_ntosp
  805. #if DEVL
  806. typedef BOOLEAN (*OB_ENUM_OBJECT_TYPE_ROUTINE)(
  807. IN PVOID Object,
  808. IN PUNICODE_STRING ObjectName,
  809. IN ULONG HandleCount,
  810. IN ULONG PointerCount,
  811. IN PVOID Parameter
  812. );
  813. NTSTATUS
  814. ObEnumerateObjectsByType(
  815. IN POBJECT_TYPE ObjectType,
  816. IN OB_ENUM_OBJECT_TYPE_ROUTINE EnumerationRoutine,
  817. IN PVOID Parameter
  818. );
  819. NTSTATUS
  820. ObGetHandleInformation(
  821. OUT PSYSTEM_HANDLE_INFORMATION HandleInformation,
  822. IN ULONG Length,
  823. OUT PULONG ReturnLength OPTIONAL
  824. );
  825. NTSTATUS
  826. ObGetHandleInformationEx (
  827. OUT PSYSTEM_HANDLE_INFORMATION_EX HandleInformation,
  828. IN ULONG Length,
  829. OUT PULONG ReturnLength OPTIONAL
  830. );
  831. NTSTATUS
  832. ObGetObjectInformation(
  833. IN PCHAR UserModeBufferAddress,
  834. OUT PSYSTEM_OBJECTTYPE_INFORMATION ObjectInformation,
  835. IN ULONG Length,
  836. OUT PULONG ReturnLength OPTIONAL
  837. );
  838. // begin_ntosp
  839. NTKERNELAPI
  840. NTSTATUS
  841. ObSetSecurityDescriptorInfo(
  842. IN PVOID Object,
  843. IN PSECURITY_INFORMATION SecurityInformation,
  844. IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
  845. IN OUT PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
  846. IN POOL_TYPE PoolType,
  847. IN PGENERIC_MAPPING GenericMapping
  848. );
  849. // end_ntosp
  850. NTKERNELAPI
  851. NTSTATUS
  852. ObQuerySecurityDescriptorInfo(
  853. IN PVOID Object,
  854. IN PSECURITY_INFORMATION SecurityInformation,
  855. OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
  856. IN OUT PULONG Length,
  857. IN PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor
  858. );
  859. NTSTATUS
  860. ObDeassignSecurity (
  861. IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor
  862. );
  863. VOID
  864. ObAuditObjectAccess(
  865. IN HANDLE Handle,
  866. IN POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL,
  867. IN KPROCESSOR_MODE AccessMode,
  868. IN ACCESS_MASK DesiredAccess
  869. );
  870. NTKERNELAPI
  871. VOID
  872. FASTCALL
  873. ObInitializeFastReference (
  874. IN PEX_FAST_REF FastRef,
  875. IN PVOID Object
  876. );
  877. NTKERNELAPI
  878. PVOID
  879. FASTCALL
  880. ObFastReferenceObject (
  881. IN PEX_FAST_REF FastRef
  882. );
  883. NTKERNELAPI
  884. PVOID
  885. FASTCALL
  886. ObFastReferenceObjectLocked (
  887. IN PEX_FAST_REF FastRef
  888. );
  889. NTKERNELAPI
  890. VOID
  891. FASTCALL
  892. ObFastDereferenceObject (
  893. IN PEX_FAST_REF FastRef,
  894. IN PVOID Object
  895. );
  896. NTKERNELAPI
  897. PVOID
  898. FASTCALL
  899. ObFastReplaceObject (
  900. IN PEX_FAST_REF FastRef,
  901. IN PVOID Object
  902. );
  903. #endif // DEVL
  904. #endif // _OB_