1998-09-13 15:55:36 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: include/internal/objmgr.h
|
|
|
|
* PURPOSE: Object manager definitions
|
|
|
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE_INTERNAL_OBJMGR_H
|
|
|
|
#define __INCLUDE_INTERNAL_OBJMGR_H
|
|
|
|
|
2003-05-28 Casper S. Hornstrup <chorns@users.sourceforge.net>
Changes for compiling with w32api
* include/ddk/haltypes.h: Move ...
* include/ntos/haltypes.h: ... here.
* include/ddk/obtypes.h: Move ...
* include/ntos/obtypes.h: ... here.
* include/ddk/i386/tss.h: Move ...
* include/ntos/tss.h: ... here.
* include/errors.h, include/windows.h: #include_next <windows.h>.
* include/ntos.h: Include "ntos/haltypes.h", "ntos/obtypes.h", and
"ntos/tss.h".
* include/ddk/defines.h (EXPORTED, IMPORTED): Move to
include/ntos/types.h.
* include/ddk/exfuncs.h, include/ddk/mmtypes.h, include/ntos/except.h,
include/ntos/file.h, include/ole32/guiddef.h, include/win32k/color.h,
lib/msafd/include/debug.h, lib/user32/include/debug.h,
lib/ws2_32/include/debug.h, lib/ws2help/debug.h,
ntoskrnl/include/internal/debug.h, ntoskrnl/ke/i386/bthread.S,
ntoskrnl/rtl/error.c: Don't define macros if previously defined.
* include/ddk/halfuncs.h: Include <ntos/haltypes.h>.
* include/ddk/iotypes.h: Include <ntos/obtypes.h>.
* include/ddk/ketypes.h (MB_FLAGS_*, LOADER_MODULE, ADDRESS_RANGE,
LOADER_PARAMETER_BLOCK): Move to include/ntos/types.h.
* include/ddk/ntddk.h: #include_next <ddk/ntddk.h>.
* include/ddk/ntifs.h: #include_next <ddk/ntifs.h>.
* include/napi/shared_data.h (SharedUserData): Undefine before defining.
* include/ntos/rtl.h (RtlUpcaseUnicodeString): Correct prototype.
* include/ntos/zwtypes.h (THREAD_STATE): Add.
* lib/ntdll/rtl/unicode.c (RtlUpcaseUnicodeString): Match new prototype.
* ntoskrnl/rtl/unicode.c (RtlUpcaseUnicodeString): Ditto.
* lib/string/Makefile: Include Makefile.$(ARCH). Don't include
makefile.$(ARCH).
* ntoskrnl/ex/sysinfo.c, ntoskrnl/include/internal/ntoskrnl.h,
* ntoskrnl/include/internal/ob.h, ntoskrnl/ob/handle.c: Include <ntos.h>.
* ntoskrnl/ke/i386/syscall.S: Don't include <ddk/defines.h>.
(KernelMode, UserMode): Define.
* ntoskrnl/ke/i386/stkswitch.S, ntoskrnl/ke/i386/tskswitch.S,
ntoskrnl/ke/i386/v86m_sup.S: Include <ntos/tss.h>
svn path=/trunk/; revision=4789
2003-05-28 18:09:10 +00:00
|
|
|
#define NTOS_MODE_KERNEL
|
|
|
|
#include <ntos.h>
|
1998-09-13 15:55:36 +00:00
|
|
|
|
2004-10-31 20:27:08 +00:00
|
|
|
#define TAG_OBJECT_TYPE TAG('O', 'b', 'j', 'T')
|
|
|
|
|
2000-07-04 08:52:47 +00:00
|
|
|
struct _EPROCESS;
|
|
|
|
|
2002-02-19 00:09:25 +00:00
|
|
|
typedef struct
|
1998-09-13 15:55:36 +00:00
|
|
|
{
|
|
|
|
CSHORT Type;
|
|
|
|
CSHORT Size;
|
|
|
|
} COMMON_BODY_HEADER, *PCOMMON_BODY_HEADER;
|
|
|
|
|
|
|
|
typedef PVOID POBJECT;
|
|
|
|
|
2005-01-04 04:45:00 +00:00
|
|
|
|
|
|
|
typedef struct _OBJECT_TYPE
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* PURPOSE: Tag to be used when allocating objects of this type
|
|
|
|
*/
|
|
|
|
ULONG Tag;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Name of the type
|
|
|
|
*/
|
|
|
|
UNICODE_STRING TypeName;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Total number of objects of this type
|
|
|
|
*/
|
|
|
|
ULONG TotalObjects;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Total number of handles of this type
|
|
|
|
*/
|
|
|
|
ULONG TotalHandles;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Peak objects of this type
|
|
|
|
*/
|
|
|
|
ULONG PeakObjects;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Peak handles of this type
|
|
|
|
*/
|
|
|
|
ULONG PeakHandles;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Paged pool charge
|
|
|
|
*/
|
|
|
|
ULONG PagedPoolCharge;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Nonpaged pool charge
|
|
|
|
*/
|
|
|
|
ULONG NonpagedPoolCharge;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Mapping of generic access rights
|
|
|
|
*/
|
|
|
|
PGENERIC_MAPPING Mapping;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Dumps the object
|
|
|
|
* NOTE: To be defined
|
|
|
|
*/
|
|
|
|
VOID STDCALL_FUNC (*Dump)(VOID);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Opens the object
|
|
|
|
* NOTE: To be defined
|
|
|
|
*/
|
|
|
|
VOID STDCALL_FUNC (*Open)(VOID);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Called to close an object if OkayToClose returns true
|
|
|
|
*/
|
|
|
|
VOID STDCALL_FUNC (*Close)(PVOID ObjectBody,
|
|
|
|
ULONG HandleCount);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Called to delete an object when the last reference is removed
|
|
|
|
*/
|
|
|
|
VOID STDCALL_FUNC (*Delete)(PVOID ObjectBody);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Called when an open attempts to open a file apparently
|
|
|
|
* residing within the object
|
|
|
|
* RETURNS
|
|
|
|
* STATUS_SUCCESS NextObject was found
|
|
|
|
* STATUS_UNSUCCESSFUL NextObject not found
|
|
|
|
* STATUS_REPARSE Path changed, restart parsing the path
|
|
|
|
*/
|
|
|
|
NTSTATUS STDCALL_FUNC (*Parse)(PVOID ParsedObject,
|
|
|
|
PVOID *NextObject,
|
|
|
|
PUNICODE_STRING FullPath,
|
|
|
|
PWSTR *Path,
|
|
|
|
ULONG Attributes);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Called to set, query, delete or assign a security-descriptor
|
|
|
|
* to the object
|
|
|
|
* RETURNS
|
|
|
|
* STATUS_SUCCESS NextObject was found
|
|
|
|
*/
|
|
|
|
NTSTATUS STDCALL_FUNC (*Security)(PVOID ObjectBody,
|
|
|
|
SECURITY_OPERATION_CODE OperationCode,
|
|
|
|
SECURITY_INFORMATION SecurityInformation,
|
|
|
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
|
|
|
PULONG BufferLength);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Called to query the name of the object
|
|
|
|
* RETURNS
|
|
|
|
* STATUS_SUCCESS NextObject was found
|
|
|
|
*/
|
|
|
|
NTSTATUS STDCALL_FUNC (*QueryName)(PVOID ObjectBody,
|
|
|
|
POBJECT_NAME_INFORMATION ObjectNameInfo,
|
|
|
|
ULONG Length,
|
|
|
|
PULONG ReturnLength);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Called when a process asks to close the object
|
|
|
|
*/
|
|
|
|
VOID STDCALL_FUNC (*OkayToClose)(VOID);
|
|
|
|
|
|
|
|
NTSTATUS STDCALL_FUNC (*Create)(PVOID ObjectBody,
|
|
|
|
PVOID Parent,
|
|
|
|
PWSTR RemainingPath,
|
|
|
|
struct _OBJECT_ATTRIBUTES* ObjectAttributes);
|
|
|
|
|
|
|
|
VOID STDCALL_FUNC (*DuplicationNotify)(PEPROCESS DuplicateTo,
|
|
|
|
PEPROCESS DuplicateFrom,
|
|
|
|
PVOID Object);
|
|
|
|
} OBJECT_TYPE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _OBJECT_HEADER
|
|
|
|
/*
|
|
|
|
* PURPOSE: Header for every object managed by the object manager
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
UNICODE_STRING Name;
|
|
|
|
LIST_ENTRY Entry;
|
|
|
|
LONG RefCount;
|
|
|
|
LONG HandleCount;
|
|
|
|
BOOLEAN CloseInProcess;
|
|
|
|
BOOLEAN Permanent;
|
|
|
|
BOOLEAN Inherit;
|
|
|
|
struct _DIRECTORY_OBJECT* Parent;
|
|
|
|
POBJECT_TYPE ObjectType;
|
|
|
|
PSECURITY_DESCRIPTOR SecurityDescriptor;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Object type
|
|
|
|
* NOTE: This overlaps the first member of the object body
|
|
|
|
*/
|
|
|
|
CSHORT Type;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Object size
|
|
|
|
* NOTE: This overlaps the second member of the object body
|
|
|
|
*/
|
|
|
|
CSHORT Size;
|
|
|
|
|
|
|
|
|
|
|
|
} OBJECT_HEADER, *POBJECT_HEADER;
|
|
|
|
|
|
|
|
|
1998-09-13 15:55:36 +00:00
|
|
|
typedef struct _DIRECTORY_OBJECT
|
2002-03-01 00:47:40 +00:00
|
|
|
{
|
1998-09-13 15:55:36 +00:00
|
|
|
CSHORT Type;
|
|
|
|
CSHORT Size;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PURPOSE: Head of the list of our subdirectories
|
|
|
|
*/
|
|
|
|
LIST_ENTRY head;
|
|
|
|
KSPIN_LOCK Lock;
|
|
|
|
} DIRECTORY_OBJECT, *PDIRECTORY_OBJECT;
|
|
|
|
|
2003-10-14 14:45:23 +00:00
|
|
|
typedef struct _SYMLINK_OBJECT
|
|
|
|
{
|
|
|
|
CSHORT Type;
|
|
|
|
CSHORT Size;
|
|
|
|
UNICODE_STRING TargetName;
|
|
|
|
LARGE_INTEGER CreateTime;
|
|
|
|
} SYMLINK_OBJECT, *PSYMLINK_OBJECT;
|
|
|
|
|
|
|
|
|
2002-03-01 00:47:40 +00:00
|
|
|
typedef struct _TYPE_OBJECT
|
|
|
|
{
|
|
|
|
CSHORT Type;
|
|
|
|
CSHORT Size;
|
|
|
|
|
|
|
|
/* pointer to object type data */
|
|
|
|
POBJECT_TYPE ObjectType;
|
|
|
|
} TYPE_OBJECT, *PTYPE_OBJECT;
|
|
|
|
|
|
|
|
|
1998-09-13 15:55:36 +00:00
|
|
|
/*
|
|
|
|
* Enumeration of object types
|
|
|
|
*/
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
OBJTYP_INVALID,
|
|
|
|
OBJTYP_TYPE,
|
|
|
|
OBJTYP_DIRECTORY,
|
|
|
|
OBJTYP_SYMLNK,
|
|
|
|
OBJTYP_DEVICE,
|
|
|
|
OBJTYP_THREAD,
|
|
|
|
OBJTYP_FILE,
|
1998-10-05 04:01:30 +00:00
|
|
|
OBJTYP_PROCESS,
|
|
|
|
OBJTYP_SECTION,
|
1998-09-13 15:55:36 +00:00
|
|
|
OBJTYP_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-09-25 20:09:56 +00:00
|
|
|
#define OBJECT_ALLOC_SIZE(ObjectSize) ((ObjectSize)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER))
|
2002-02-19 00:09:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern PDIRECTORY_OBJECT NameSpaceRoot;
|
2003-02-25 16:43:45 +00:00
|
|
|
extern POBJECT_TYPE ObSymbolicLinkType;
|
1998-09-13 15:55:36 +00:00
|
|
|
|
|
|
|
|
2000-10-07 13:41:58 +00:00
|
|
|
POBJECT_HEADER BODY_TO_HEADER(PVOID body);
|
|
|
|
PVOID HEADER_TO_BODY(POBJECT_HEADER obj);
|
1998-09-13 15:55:36 +00:00
|
|
|
|
2002-02-19 00:09:25 +00:00
|
|
|
VOID ObpAddEntryDirectory(PDIRECTORY_OBJECT Parent,
|
|
|
|
POBJECT_HEADER Header,
|
|
|
|
PWSTR Name);
|
|
|
|
VOID ObpRemoveEntryDirectory(POBJECT_HEADER Header);
|
1998-10-05 04:01:30 +00:00
|
|
|
|
2003-02-25 16:43:45 +00:00
|
|
|
VOID
|
|
|
|
ObInitSymbolicLinkImplementation(VOID);
|
1998-10-05 04:01:30 +00:00
|
|
|
|
1998-09-13 15:55:36 +00:00
|
|
|
|
2000-07-04 08:52:47 +00:00
|
|
|
NTSTATUS ObCreateHandle(struct _EPROCESS* Process,
|
1999-02-06 18:34:14 +00:00
|
|
|
PVOID ObjectBody,
|
|
|
|
ACCESS_MASK GrantedAccess,
|
|
|
|
BOOLEAN Inherit,
|
|
|
|
PHANDLE Handle);
|
2000-07-04 08:52:47 +00:00
|
|
|
VOID ObCreateHandleTable(struct _EPROCESS* Parent,
|
1999-02-06 18:34:14 +00:00
|
|
|
BOOLEAN Inherit,
|
2000-07-04 08:52:47 +00:00
|
|
|
struct _EPROCESS* Process);
|
1999-03-25 00:37:06 +00:00
|
|
|
NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
|
|
|
|
PVOID* ReturnedObject,
|
2000-08-24 19:15:20 +00:00
|
|
|
PUNICODE_STRING RemainingPath,
|
|
|
|
POBJECT_TYPE ObjectType);
|
2000-07-04 08:52:47 +00:00
|
|
|
VOID ObCloseAllHandles(struct _EPROCESS* Process);
|
|
|
|
VOID ObDeleteHandleTable(struct _EPROCESS* Process);
|
2003-10-21 15:50:51 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ObDeleteHandle(PEPROCESS Process,
|
|
|
|
HANDLE Handle,
|
|
|
|
PVOID *ObjectBody);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ObpQueryHandleAttributes(HANDLE Handle,
|
|
|
|
POBJECT_HANDLE_ATTRIBUTE_INFORMATION HandleInfo);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ObpSetHandleAttributes(HANDLE Handle,
|
|
|
|
POBJECT_HANDLE_ATTRIBUTE_INFORMATION HandleInfo);
|
1999-02-06 18:34:14 +00:00
|
|
|
|
2002-03-01 00:47:40 +00:00
|
|
|
NTSTATUS
|
|
|
|
ObpCreateTypeObject(POBJECT_TYPE ObjectType);
|
|
|
|
|
2002-03-05 00:20:54 +00:00
|
|
|
ULONG
|
|
|
|
ObGetObjectHandleCount(PVOID Object);
|
2002-06-11 22:09:03 +00:00
|
|
|
NTSTATUS
|
|
|
|
ObDuplicateObject(PEPROCESS SourceProcess,
|
|
|
|
PEPROCESS TargetProcess,
|
|
|
|
HANDLE SourceHandle,
|
|
|
|
PHANDLE TargetHandle,
|
|
|
|
ACCESS_MASK DesiredAccess,
|
|
|
|
BOOLEAN InheritHandle,
|
|
|
|
ULONG Options);
|
2002-03-05 00:20:54 +00:00
|
|
|
|
2004-07-16 17:20:23 +00:00
|
|
|
ULONG
|
|
|
|
ObpGetHandleCountByHandleTable(PHANDLE_TABLE HandleTable);
|
|
|
|
|
2004-11-21 06:51:18 +00:00
|
|
|
VOID
|
|
|
|
STDCALL
|
|
|
|
ObQueryDeviceMapInformation(PEPROCESS Process, PPROCESS_DEVICEMAP_INFORMATION DeviceMapInfo);
|
2004-07-16 17:20:23 +00:00
|
|
|
|
|
|
|
/* Security descriptor cache functions */
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ObpInitSdCache(VOID);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ObpAddSecurityDescriptor(IN PSECURITY_DESCRIPTOR SourceSD,
|
|
|
|
OUT PSECURITY_DESCRIPTOR *DestinationSD);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ObpRemoveSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor);
|
2004-05-02 04:40:25 +00:00
|
|
|
|
2004-07-23 21:44:10 +00:00
|
|
|
VOID
|
|
|
|
ObpReferenceCachedSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ObpDereferenceCachedSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor);
|
|
|
|
|
2004-05-02 04:40:25 +00:00
|
|
|
|
1998-09-13 15:55:36 +00:00
|
|
|
#endif /* __INCLUDE_INTERNAL_OBJMGR_H */
|