reactos/reactos/ntoskrnl/include/internal/ob.h

320 lines
7 KiB
C
Raw Normal View History

/*
* 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>
#define TAG_OBJECT_TYPE TAG('O', 'b', 'j', 'T')
struct _EPROCESS;
typedef struct
{
CSHORT Type;
CSHORT Size;
} COMMON_BODY_HEADER, *PCOMMON_BODY_HEADER;
typedef PVOID POBJECT;
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;
typedef struct _DIRECTORY_OBJECT
{
CSHORT Type;
CSHORT Size;
/*
* PURPOSE: Head of the list of our subdirectories
*/
LIST_ENTRY head;
KSPIN_LOCK Lock;
} DIRECTORY_OBJECT, *PDIRECTORY_OBJECT;
typedef struct _SYMLINK_OBJECT
{
CSHORT Type;
CSHORT Size;
UNICODE_STRING TargetName;
LARGE_INTEGER CreateTime;
} SYMLINK_OBJECT, *PSYMLINK_OBJECT;
typedef struct _TYPE_OBJECT
{
CSHORT Type;
CSHORT Size;
/* pointer to object type data */
POBJECT_TYPE ObjectType;
} TYPE_OBJECT, *PTYPE_OBJECT;
/*
* Enumeration of object types
*/
enum
{
OBJTYP_INVALID,
OBJTYP_TYPE,
OBJTYP_DIRECTORY,
OBJTYP_SYMLNK,
OBJTYP_DEVICE,
OBJTYP_THREAD,
OBJTYP_FILE,
OBJTYP_PROCESS,
OBJTYP_SECTION,
OBJTYP_MAX,
};
#define OBJECT_ALLOC_SIZE(ObjectSize) ((ObjectSize)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER))
extern PDIRECTORY_OBJECT NameSpaceRoot;
extern POBJECT_TYPE ObSymbolicLinkType;
POBJECT_HEADER BODY_TO_HEADER(PVOID body);
PVOID HEADER_TO_BODY(POBJECT_HEADER obj);
VOID ObpAddEntryDirectory(PDIRECTORY_OBJECT Parent,
POBJECT_HEADER Header,
PWSTR Name);
VOID ObpRemoveEntryDirectory(POBJECT_HEADER Header);
VOID
ObInitSymbolicLinkImplementation(VOID);
NTSTATUS ObCreateHandle(struct _EPROCESS* Process,
PVOID ObjectBody,
ACCESS_MASK GrantedAccess,
BOOLEAN Inherit,
PHANDLE Handle);
VOID ObCreateHandleTable(struct _EPROCESS* Parent,
BOOLEAN Inherit,
struct _EPROCESS* Process);
NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
PVOID* ReturnedObject,
PUNICODE_STRING RemainingPath,
POBJECT_TYPE ObjectType);
VOID ObCloseAllHandles(struct _EPROCESS* Process);
VOID ObDeleteHandleTable(struct _EPROCESS* Process);
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);
NTSTATUS
ObpCreateTypeObject(POBJECT_TYPE ObjectType);
ULONG
ObGetObjectHandleCount(PVOID Object);
2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk> * subsys/system/winlogon/winlogon.c (WinMain): Check for failure when creating a window system. 2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk> * ntoskrnl/ob/handle.c (ObDuplicateObject): Added this internal function for duplicating objects. * ntoskrnl/ps/process.c (NtCreateProcess): Duplicate the parent process's window station to the child process. * ntoskrnl/ps/process.c (PsInitProcessManagement): Initialize the first process's window station. 2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk> * ntoskrnl/mm/marea.c (MmCreateMemoryArea): Initialise page operation structure members. * ntoskrnl/mm/pageop.c (MmReleasePageOp, MmGetPageOp): Increment or decrement the page operation count in the memory area. * ntoskrnl/mm/virtual.c (MmNotPresentFaultVirtualMemory, MmPageOutVirtualMemory): Check for a deleted memory area before handling the fault. * ntoskrnl/mm/virtual.c (MmFreeVirtualMemory): Wait for all page operations to finish before freeing the memory area. 2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk> * ntoskrnl/ke/i386/syscall.S (interrupt_handler2e): Corrected test for previous mode, upper 16-bit of CS on the stack after an interrupt are arbitary. 2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk> * lib/user32/misc/winsta.c: Cleaned up indentation. 2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk> * apps/tests/winhello/winhello.c (WinMain, MainWndProc): Cleaned up formatting, some more error checks. 2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk> * ntoskrnl/mm/virtual.c (MmSecureVirtualMemory, MmUnsecureVirtualMemory, NtQueryVirtualMemory): Corrected indentation. svn path=/trunk/; revision=3050
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);
ULONG
ObpGetHandleCountByHandleTable(PHANDLE_TABLE HandleTable);
VOID
STDCALL
ObQueryDeviceMapInformation(PEPROCESS Process, PPROCESS_DEVICEMAP_INFORMATION DeviceMapInfo);
/* Security descriptor cache functions */
NTSTATUS
ObpInitSdCache(VOID);
NTSTATUS
ObpAddSecurityDescriptor(IN PSECURITY_DESCRIPTOR SourceSD,
OUT PSECURITY_DESCRIPTOR *DestinationSD);
NTSTATUS
ObpRemoveSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor);
VOID
ObpReferenceCachedSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor);
VOID
ObpDereferenceCachedSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor);
#endif /* __INCLUDE_INTERNAL_OBJMGR_H */