3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ob/ntobj.c
6 * PURPOSE: User mode interface to object manager
7 * PROGRAMMER: David Welch (welch@cwcom.net)
12 /* INCLUDES *****************************************************************/
14 #include <ddk/ntddk.h>
15 #include <internal/ob.h>
16 #include <internal/id.h>
19 #include <internal/debug.h>
22 /* FUNCTIONS ************************************************************/
26 /**********************************************************************
28 * NtSetInformationObject
39 NtSetInformationObject (IN HANDLE ObjectHandle,
40 IN CINT ObjectInformationClass,
41 IN PVOID ObjectInformation,
47 #endif /* LIBCAPTIVE */
52 POBJECT_HEADER ObjectHeader,
53 PUNICODE_STRING string)
54 /* So, what's the purpose of this function?
55 It will take any OBJECT_HEADER and traverse the Parent structure up to the root
56 and form the name, i.e. this will only work on objects where the Parent/Name fields
57 have any meaning (not files) */
60 if (ObjectHeader->Parent)
62 status = internalNameBuilder(BODY_TO_HEADER(ObjectHeader->Parent),string);
63 if (status != STATUS_SUCCESS)
68 if (ObjectHeader->Name.Buffer)
70 status = RtlAppendUnicodeToString(string, REACTOS_UCS2(L"\\"));
71 if (status != STATUS_SUCCESS) return status;
72 return RtlAppendUnicodeStringToString(string, &ObjectHeader->Name);
74 return STATUS_SUCCESS;
79 /*Very, very, very new implementation. Test it!
81 Probably we should add meaning to QueryName in POBJECT_TYPE, no matter if we know
82 the correct parameters or not. For FILE_OBJECTs, it would probably look like the code
83 for ObjectNameInformation below. You give it a POBJECT and a PUNICODE_STRING, and it
84 returns the full path in the PUNICODE_STRING
86 If we don't do it this way, we should anyway add switches and separate functions to handle
87 the different object types*/
89 /**********************************************************************
102 NtQueryObject (IN HANDLE ObjectHandle,
103 IN CINT ObjectInformationClass,
104 OUT PVOID ObjectInformation,
106 OUT PULONG ReturnLength)
108 POBJECT_TYPE_INFORMATION typeinfo;
109 POBJECT_HEADER ObjectHeader;
113 Status = ObReferenceObjectByHandle (ObjectHandle,
119 if (!NT_SUCCESS (Status))
124 ObjectHeader = BODY_TO_HEADER(Object);
126 switch (ObjectInformationClass)
128 case ObjectNameInformation:
129 Status = ObQueryNameString (Object,
130 (POBJECT_NAME_INFORMATION)ObjectInformation,
135 case ObjectTypeInformation:
136 typeinfo = (POBJECT_TYPE_INFORMATION)ObjectInformation;
137 if (Length!=sizeof(OBJECT_TYPE_INFORMATION))
138 return STATUS_INVALID_BUFFER_SIZE;
140 // FIXME: Is this supposed to only be the header's Name field?
141 // Can somebody check/verify this?
142 RtlCopyUnicodeString(&typeinfo->Name,&ObjectHeader->Name);
144 if (Status != STATUS_SUCCESS)
149 RtlCopyUnicodeString(&typeinfo->Type,&ObjectHeader->ObjectType->TypeName);
150 //This should be info from the object header, not the object type, right?
151 typeinfo->TotalHandles = ObjectHeader-> HandleCount;
152 typeinfo->ReferenceCount = ObjectHeader -> RefCount;
156 Status = STATUS_NOT_IMPLEMENTED;
160 ObDereferenceObject(Object);
166 /**********************************************************************
168 * ObMakeTemporaryObject
181 ObMakeTemporaryObject (IN PVOID ObjectBody)
183 POBJECT_HEADER ObjectHeader;
185 ObjectHeader = BODY_TO_HEADER(ObjectBody);
186 ObjectHeader->Permanent = FALSE;
190 /**********************************************************************
192 * NtMakeTemporaryObject
204 NtMakeTemporaryObject (IN HANDLE Handle)
206 POBJECT_HEADER ObjectHeader;
210 Status = ObReferenceObjectByHandle(Handle,
216 if (Status != STATUS_SUCCESS)
221 ObjectHeader = BODY_TO_HEADER(Object);
222 ObjectHeader->Permanent = FALSE;
224 ObDereferenceObject(Object);
226 return STATUS_SUCCESS;
229 #endif /* LIBCAPTIVE */