3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: ntoskrnl/ob/handle.c
24 * PURPOSE: Managing handles
25 * PROGRAMMER: David Welch (welch@cwcom.net)
30 /* INCLUDES ****************************************************************/
34 #include <internal/debug.h>
36 #define EX_OBJ_TO_HDR(eob) ((POBJECT_HEADER)((ULONG_PTR)(eob) & \
37 ~(EX_HANDLE_ENTRY_PROTECTFROMCLOSE | EX_HANDLE_ENTRY_INHERITABLE | \
38 EX_HANDLE_ENTRY_AUDITONCLOSE)))
39 #define EX_HTE_TO_HDR(hte) ((POBJECT_HEADER)((ULONG_PTR)((hte)->u1.Object) & \
40 ~(EX_HANDLE_ENTRY_PROTECTFROMCLOSE | EX_HANDLE_ENTRY_INHERITABLE | \
41 EX_HANDLE_ENTRY_AUDITONCLOSE)))
43 /* FUNCTIONS ***************************************************************/
47 ObpDecrementHandleCount(PVOID ObjectBody
)
49 POBJECT_HEADER ObjectHeader
= BODY_TO_HEADER(ObjectBody
);
50 LONG NewHandleCount
= InterlockedDecrement(&ObjectHeader
->HandleCount
);
52 if ((ObjectHeader
->ObjectType
!= NULL
) &&
53 (ObjectHeader
->ObjectType
->Close
!= NULL
))
55 /* the handle count should be decremented but we pass the previous value
57 ObjectHeader
->ObjectType
->Close(ObjectBody
, NewHandleCount
+ 1);
60 if(NewHandleCount
== 0)
62 ObDereferenceObject(ObjectBody
);
68 ObpQueryHandleAttributes(HANDLE Handle
,
69 POBJECT_HANDLE_ATTRIBUTE_INFORMATION HandleInfo
)
72 PHANDLE_TABLE_ENTRY HandleTableEntry
;
73 LONG ExHandle
= HANDLE_TO_EX_HANDLE(Handle
);
77 DPRINT("ObpQueryHandleAttributes(Handle %x)\n", Handle
);
79 KeEnterCriticalRegion();
81 Process
= PsGetCurrentProcess();
83 HandleTableEntry
= ExMapHandleToPointer(Process
->ObjectTable
,
85 if (HandleTableEntry
== NULL
)
87 KeLeaveCriticalRegion();
88 return STATUS_INVALID_HANDLE
;
91 HandleInfo
->Inherit
= (HandleTableEntry
->u1
.ObAttributes
& EX_HANDLE_ENTRY_INHERITABLE
) != 0;
92 HandleInfo
->ProtectFromClose
= (HandleTableEntry
->u1
.ObAttributes
& EX_HANDLE_ENTRY_PROTECTFROMCLOSE
) != 0;
94 ExUnlockHandleTableEntry(Process
->ObjectTable
,
97 KeLeaveCriticalRegion();
99 return STATUS_SUCCESS
;
104 ObpSetHandleAttributes(HANDLE Handle
,
105 POBJECT_HANDLE_ATTRIBUTE_INFORMATION HandleInfo
)
108 PHANDLE_TABLE_ENTRY HandleTableEntry
;
109 LONG ExHandle
= HANDLE_TO_EX_HANDLE(Handle
);
113 DPRINT("ObpSetHandleAttributes(Handle %x)\n", Handle
);
115 Process
= PsGetCurrentProcess();
117 KeEnterCriticalRegion();
119 HandleTableEntry
= ExMapHandleToPointer(Process
->ObjectTable
,
121 if (HandleTableEntry
== NULL
)
123 KeLeaveCriticalRegion();
124 return STATUS_INVALID_HANDLE
;
127 if (HandleInfo
->Inherit
)
128 HandleTableEntry
->u1
.ObAttributes
|= EX_HANDLE_ENTRY_INHERITABLE
;
130 HandleTableEntry
->u1
.ObAttributes
&= ~EX_HANDLE_ENTRY_INHERITABLE
;
132 if (HandleInfo
->ProtectFromClose
)
133 HandleTableEntry
->u1
.ObAttributes
|= EX_HANDLE_ENTRY_PROTECTFROMCLOSE
;
135 HandleTableEntry
->u1
.ObAttributes
&= ~EX_HANDLE_ENTRY_PROTECTFROMCLOSE
;
137 /* FIXME: Do we need to set anything in the object header??? */
139 ExUnlockHandleTableEntry(Process
->ObjectTable
,
142 KeLeaveCriticalRegion();
144 return STATUS_SUCCESS
;
149 ObDuplicateObject(PEPROCESS SourceProcess
,
150 PEPROCESS TargetProcess
,
152 PHANDLE TargetHandle
,
153 ACCESS_MASK DesiredAccess
,
154 BOOLEAN InheritHandle
,
157 PHANDLE_TABLE_ENTRY SourceHandleEntry
;
158 HANDLE_TABLE_ENTRY NewHandleEntry
;
160 POBJECT_HEADER ObjectHeader
;
162 LONG ExSourceHandle
= HANDLE_TO_EX_HANDLE(SourceHandle
);
166 KeEnterCriticalRegion();
168 SourceHandleEntry
= ExMapHandleToPointer(SourceProcess
->ObjectTable
,
170 if (SourceHandleEntry
== NULL
)
172 KeLeaveCriticalRegion();
173 return STATUS_INVALID_HANDLE
;
176 ObjectHeader
= EX_HTE_TO_HDR(SourceHandleEntry
);
177 ObjectBody
= HEADER_TO_BODY(ObjectHeader
);
179 NewHandleEntry
.u1
.Object
= SourceHandleEntry
->u1
.Object
;
181 NewHandleEntry
.u1
.ObAttributes
|= EX_HANDLE_ENTRY_INHERITABLE
;
183 NewHandleEntry
.u1
.ObAttributes
&= ~EX_HANDLE_ENTRY_INHERITABLE
;
184 NewHandleEntry
.u2
.GrantedAccess
= ((Options
& DUPLICATE_SAME_ACCESS
) ?
185 SourceHandleEntry
->u2
.GrantedAccess
:
188 /* reference the object so it doesn't get deleted after releasing the lock
189 and before creating a new handle for it */
190 ObReferenceObject(ObjectBody
);
192 /* increment the handle count of the object, it should always be >= 2 because
193 we're holding a handle lock to this object! if the new handle count was
194 1 here, we're in big trouble... it would've been safe to increment and
195 check the handle count without using interlocked functions because the
196 entry is locked, which means the handle count can't change. */
197 InterlockedIncrement(&ObjectHeader
->HandleCount
);
198 ASSERT(ObjectHeader
->HandleCount
>= 2);
200 ExUnlockHandleTableEntry(SourceProcess
->ObjectTable
,
203 KeLeaveCriticalRegion();
205 /* attempt to create the new handle */
206 ExTargetHandle
= ExCreateHandle(TargetProcess
->ObjectTable
,
208 if (ExTargetHandle
!= EX_INVALID_HANDLE
)
210 if (Options
& DUPLICATE_CLOSE_SOURCE
)
212 ObDeleteHandle(SourceProcess
,
216 ObDereferenceObject(ObjectBody
);
218 *TargetHandle
= EX_HANDLE_TO_HANDLE(ExTargetHandle
);
220 return STATUS_SUCCESS
;
224 /* decrement the handle count we previously incremented, but don't call the
225 closing procedure because we're not closing a handle! */
226 if(InterlockedDecrement(&ObjectHeader
->HandleCount
) == 0)
228 ObDereferenceObject(ObjectBody
);
231 ObDereferenceObject(ObjectBody
);
232 return STATUS_UNSUCCESSFUL
;
240 NtDuplicateObject (IN HANDLE SourceProcessHandle
,
241 IN HANDLE SourceHandle
,
242 IN HANDLE TargetProcessHandle
,
243 OUT PHANDLE TargetHandle
,
244 IN ACCESS_MASK DesiredAccess
,
245 IN BOOLEAN InheritHandle
,
248 * FUNCTION: Copies a handle from one process space to another
250 * SourceProcessHandle = The source process owning the handle. The
251 * source process should have opened
252 * the SourceHandle with PROCESS_DUP_HANDLE
254 * SourceHandle = The handle to the object.
255 * TargetProcessHandle = The destination process owning the handle
256 * TargetHandle (OUT) = Caller should supply storage for the
258 * DesiredAccess = The desired access to the handle.
259 * InheritHandle = Indicates wheter the new handle will be inheritable
261 * Options = Specifies special actions upon duplicating the handle.
262 * Can be one of the values DUPLICATE_CLOSE_SOURCE |
263 * DUPLICATE_SAME_ACCESS. DUPLICATE_CLOSE_SOURCE specifies
264 * that the source handle should be closed after duplicating.
265 * DUPLICATE_SAME_ACCESS specifies to ignore the
266 * DesiredAccess paramter and just grant the same access to
269 * REMARKS: This function maps to the win32 DuplicateHandle.
272 PEPROCESS SourceProcess
;
273 PEPROCESS TargetProcess
;
275 KPROCESSOR_MODE PreviousMode
;
276 NTSTATUS Status
= STATUS_SUCCESS
;
280 PreviousMode
= ExGetPreviousMode();
282 if(PreviousMode
!= KernelMode
)
286 ProbeForWrite(TargetHandle
,
292 Status
= _SEH_GetExceptionCode();
296 if(!NT_SUCCESS(Status
))
302 Status
= ObReferenceObjectByHandle(SourceProcessHandle
,
306 (PVOID
*)&SourceProcess
,
308 if (!NT_SUCCESS(Status
))
313 Status
= ObReferenceObjectByHandle(TargetProcessHandle
,
317 (PVOID
*)&TargetProcess
,
319 if (!NT_SUCCESS(Status
))
321 ObDereferenceObject(SourceProcess
);
325 /* Check for magic handle first */
326 if (SourceHandle
== NtCurrentThread())
330 Status
= ObReferenceObjectByHandle(SourceHandle
,
336 if(NT_SUCCESS(Status
))
338 Status
= ObCreateHandle(TargetProcess
,
344 ObDereferenceObject(ObjectBody
);
346 if (Options
& DUPLICATE_CLOSE_SOURCE
)
348 ObDeleteHandle(SourceProcess
,
355 Status
= ObDuplicateObject(SourceProcess
,
364 ObDereferenceObject(TargetProcess
);
365 ObDereferenceObject(SourceProcess
);
367 if(NT_SUCCESS(Status
))
371 *TargetHandle
= hTarget
;
375 Status
= _SEH_GetExceptionCode();
384 DeleteHandleCallback(PHANDLE_TABLE HandleTable
,
389 POBJECT_HEADER ObjectHeader
;
394 ObjectHeader
= EX_OBJ_TO_HDR(Object
);
395 ObjectBody
= HEADER_TO_BODY(ObjectHeader
);
397 ObpDecrementHandleCount(ObjectBody
);
400 VOID
ObDeleteHandleTable(PEPROCESS Process
)
402 * FUNCTION: Deletes the handle table associated with a process
407 ExDestroyHandleTable(Process
->ObjectTable
,
408 DeleteHandleCallback
,
412 static BOOLEAN STDCALL
413 DuplicateHandleCallback(PHANDLE_TABLE HandleTable
,
414 PHANDLE_TABLE_ENTRY HandleTableEntry
,
417 POBJECT_HEADER ObjectHeader
;
422 Ret
= (HandleTableEntry
->u1
.ObAttributes
& EX_HANDLE_ENTRY_INHERITABLE
) != 0;
425 ObjectHeader
= EX_HTE_TO_HDR(HandleTableEntry
);
426 if(InterlockedIncrement(&ObjectHeader
->HandleCount
) == 1)
428 ObReferenceObjectByPointer(HEADER_TO_BODY(ObjectHeader
),
438 VOID
ObCreateHandleTable(PEPROCESS Parent
,
442 * FUNCTION: Creates a handle table for a process
444 * Parent = Parent process (or NULL if this is the first process)
445 * Inherit = True if the process should inherit its parent's handles
446 * Process = Process whose handle table is to be created
451 DPRINT("ObCreateHandleTable(Parent %x, Inherit %d, Process %x)\n",
452 Parent
,Inherit
,Process
);
455 Process
->ObjectTable
= ExDupHandleTable(Process
,
456 DuplicateHandleCallback
,
458 Parent
->ObjectTable
);
462 Process
->ObjectTable
= ExCreateHandleTable(Process
);
468 ObDeleteHandle(PEPROCESS Process
,
471 PHANDLE_TABLE_ENTRY HandleEntry
;
473 POBJECT_HEADER ObjectHeader
;
474 LONG ExHandle
= HANDLE_TO_EX_HANDLE(Handle
);
478 DPRINT("ObDeleteHandle(Handle %x)\n",Handle
);
480 KeEnterCriticalRegion();
482 HandleEntry
= ExMapHandleToPointer(Process
->ObjectTable
,
484 if(HandleEntry
!= NULL
)
486 if(HandleEntry
->u1
.ObAttributes
& EX_HANDLE_ENTRY_PROTECTFROMCLOSE
)
488 ExUnlockHandleTableEntry(Process
->ObjectTable
,
491 KeLeaveCriticalRegion();
493 return STATUS_HANDLE_NOT_CLOSABLE
;
496 ObjectHeader
= EX_HTE_TO_HDR(HandleEntry
);
497 Body
= HEADER_TO_BODY(ObjectHeader
);
499 ObpDecrementHandleCount(Body
);
501 /* destroy and unlock the handle entry */
502 ExDestroyHandleByEntry(Process
->ObjectTable
,
506 KeLeaveCriticalRegion();
508 return STATUS_SUCCESS
;
510 KeLeaveCriticalRegion();
511 return STATUS_INVALID_HANDLE
;
516 ObCreateHandle(PEPROCESS Process
,
518 ACCESS_MASK GrantedAccess
,
520 PHANDLE HandleReturn
)
522 * FUNCTION: Add a handle referencing an object
524 * obj = Object body that the handle should refer to
525 * RETURNS: The created handle
526 * NOTE: The handle is valid only in the context of the current process
529 HANDLE_TABLE_ENTRY NewEntry
;
530 POBJECT_HEADER ObjectHeader
;
535 DPRINT("ObCreateHandle(Process %x, obj %x)\n",Process
,ObjectBody
);
540 ObjectHeader
= BODY_TO_HEADER(ObjectBody
);
542 ASSERT((ULONG_PTR
)ObjectHeader
& EX_HANDLE_ENTRY_LOCKED
);
544 NewEntry
.u1
.Object
= ObjectHeader
;
546 NewEntry
.u1
.ObAttributes
|= EX_HANDLE_ENTRY_INHERITABLE
;
548 NewEntry
.u1
.ObAttributes
&= ~EX_HANDLE_ENTRY_INHERITABLE
;
549 NewEntry
.u2
.GrantedAccess
= GrantedAccess
;
551 ExHandle
= ExCreateHandle(Process
->ObjectTable
,
553 DPRINT("ObCreateHandle(0x%x)==0x%x [HT:0x%x]\n", ObjectHeader
, *HandleReturn
, Process
->ObjectTable
);
554 if(ExHandle
!= EX_INVALID_HANDLE
)
556 if(InterlockedIncrement(&ObjectHeader
->HandleCount
) == 1)
558 ObReferenceObjectByPointer(ObjectBody
,
564 *HandleReturn
= EX_HANDLE_TO_HANDLE(ExHandle
);
566 return STATUS_SUCCESS
;
569 return STATUS_UNSUCCESSFUL
;
577 ObQueryObjectAuditingByHandle(IN HANDLE Handle
,
578 OUT PBOOLEAN GenerateOnClose
)
580 PHANDLE_TABLE_ENTRY HandleEntry
;
582 LONG ExHandle
= HANDLE_TO_EX_HANDLE(Handle
);
586 DPRINT("ObQueryObjectAuditingByHandle(Handle %x)\n", Handle
);
588 Process
= PsGetCurrentProcess();
590 KeEnterCriticalRegion();
592 HandleEntry
= ExMapHandleToPointer(Process
->ObjectTable
,
594 if(HandleEntry
!= NULL
)
596 *GenerateOnClose
= (HandleEntry
->u1
.ObAttributes
& EX_HANDLE_ENTRY_AUDITONCLOSE
) != 0;
598 ExUnlockHandleTableEntry(Process
->ObjectTable
,
601 KeLeaveCriticalRegion();
603 return STATUS_SUCCESS
;
606 KeLeaveCriticalRegion();
608 return STATUS_INVALID_HANDLE
;
613 * FUNCTION: Increments the reference count for an object and returns a
614 * pointer to its body
616 * Handle = Handle for the object
617 * DesiredAccess = Desired access to the object
620 * Object (OUT) = Points to the object body on return
621 * HandleInformation (OUT) = Contains information about the handle
628 ObReferenceObjectByHandle(HANDLE Handle
,
629 ACCESS_MASK DesiredAccess
,
630 POBJECT_TYPE ObjectType
,
631 KPROCESSOR_MODE AccessMode
,
633 POBJECT_HANDLE_INFORMATION HandleInformation
)
635 PHANDLE_TABLE_ENTRY HandleEntry
;
636 POBJECT_HEADER ObjectHeader
;
638 ACCESS_MASK GrantedAccess
;
639 PGENERIC_MAPPING GenericMapping
;
642 LONG ExHandle
= HANDLE_TO_EX_HANDLE(Handle
);
646 DPRINT("ObReferenceObjectByHandle(Handle %x, DesiredAccess %x, "
647 "ObjectType %x, AccessMode %d, Object %x)\n",Handle
,DesiredAccess
,
648 ObjectType
,AccessMode
,Object
);
651 * Handle special handle names
653 if (Handle
== NtCurrentProcess() &&
654 (ObjectType
== PsProcessType
|| ObjectType
== NULL
))
656 Status
= ObReferenceObjectByPointer(PsGetCurrentProcess(),
660 if (! NT_SUCCESS(Status
))
665 if (HandleInformation
!= NULL
)
667 HandleInformation
->HandleAttributes
= 0;
668 HandleInformation
->GrantedAccess
= PROCESS_ALL_ACCESS
;
671 *Object
= PsGetCurrentProcess();
672 DPRINT("Referencing current process %x\n", PsGetCurrentProcess());
673 return STATUS_SUCCESS
;
675 else if (Handle
== NtCurrentProcess())
678 return(STATUS_OBJECT_TYPE_MISMATCH
);
681 if (Handle
== NtCurrentThread() &&
682 (ObjectType
== PsThreadType
|| ObjectType
== NULL
))
684 Status
= ObReferenceObjectByPointer(PsGetCurrentThread(),
688 if (! NT_SUCCESS(Status
))
693 if (HandleInformation
!= NULL
)
695 HandleInformation
->HandleAttributes
= 0;
696 HandleInformation
->GrantedAccess
= THREAD_ALL_ACCESS
;
699 *Object
= PsGetCurrentThread();
701 return STATUS_SUCCESS
;
703 else if (Handle
== NtCurrentThread())
706 return(STATUS_OBJECT_TYPE_MISMATCH
);
709 KeEnterCriticalRegion();
711 HandleEntry
= ExMapHandleToPointer(PsGetCurrentProcess()->ObjectTable
,
713 if (HandleEntry
== NULL
)
715 KeLeaveCriticalRegion();
716 DPRINT("ExMapHandleToPointer() failed for handle 0x%x\n", Handle
);
717 return(STATUS_INVALID_HANDLE
);
720 ObjectHeader
= EX_HTE_TO_HDR(HandleEntry
);
721 ObjectBody
= HEADER_TO_BODY(ObjectHeader
);
723 DPRINT("locked1: ObjectHeader: 0x%x [HT:0x%x]\n", ObjectHeader
, PsGetCurrentProcess()->ObjectTable
);
725 ObReferenceObjectByPointer(ObjectBody
,
729 Attributes
= HandleEntry
->u1
.ObAttributes
& (EX_HANDLE_ENTRY_PROTECTFROMCLOSE
|
730 EX_HANDLE_ENTRY_INHERITABLE
|
731 EX_HANDLE_ENTRY_AUDITONCLOSE
);
732 GrantedAccess
= HandleEntry
->u2
.GrantedAccess
;
733 GenericMapping
= ObjectHeader
->ObjectType
->Mapping
;
735 if (ObjectType
!= NULL
&& ObjectType
!= ObjectHeader
->ObjectType
)
737 DPRINT("ObjectType mismatch: %wZ vs %wZ (handle 0x%x)\n", &ObjectType
->TypeName
, ObjectHeader
->ObjectType
? &ObjectHeader
->ObjectType
->TypeName
: NULL
, Handle
);
739 ExUnlockHandleTableEntry(PsGetCurrentProcess()->ObjectTable
,
742 KeLeaveCriticalRegion();
744 return(STATUS_OBJECT_TYPE_MISMATCH
);
747 ExUnlockHandleTableEntry(PsGetCurrentProcess()->ObjectTable
,
750 KeLeaveCriticalRegion();
752 if (DesiredAccess
&& AccessMode
!= KernelMode
)
754 RtlMapGenericMask(&DesiredAccess
, GenericMapping
);
756 if (!(GrantedAccess
& DesiredAccess
) &&
757 !((~GrantedAccess
) & DesiredAccess
))
760 return(STATUS_ACCESS_DENIED
);
764 if (HandleInformation
!= NULL
)
766 HandleInformation
->HandleAttributes
= Attributes
;
767 HandleInformation
->GrantedAccess
= GrantedAccess
;
770 *Object
= ObjectBody
;
772 return(STATUS_SUCCESS
);
776 /**********************************************************************
781 * Closes a handle reference to an object.
793 NtClose(IN HANDLE Handle
)
799 Status
= ObDeleteHandle(PsGetCurrentProcess(),
801 if (!NT_SUCCESS(Status
))
803 if(((PEPROCESS
)(KeGetCurrentThread()->ApcState
.Process
))->ExceptionPort
)
804 KeRaiseUserException(Status
);
808 return(STATUS_SUCCESS
);
816 ObInsertObject(IN PVOID Object
,
817 IN PACCESS_STATE PassedAccessState OPTIONAL
,
818 IN ACCESS_MASK DesiredAccess
,
819 IN ULONG AdditionalReferences
,
820 OUT PVOID
* ReferencedObject OPTIONAL
,
823 POBJECT_HEADER ObjectHeader
;
828 Access
= DesiredAccess
;
829 ObjectHeader
= BODY_TO_HEADER(Object
);
831 RtlMapGenericMask(&Access
,
832 ObjectHeader
->ObjectType
->Mapping
);
834 return(ObCreateHandle(PsGetCurrentProcess(),
837 ObjectHeader
->Inherit
,
843 ObpGetHandleCountByHandleTable(PHANDLE_TABLE HandleTable
)
845 return HandleTable
->HandleCount
;
849 * FUNCTION: Searches the handle table of a specified process whether it contains a
850 * valid handle to the Object we're looking for. If not, it'll create one.
853 * The parameters of this function is basically a mixture of some of the parameters
854 * of ObReferenceObjectByHandle() and ObReferenceObjectByPointer(). A little thinking
855 * about what this function does (by it's name) makes clear what parameters it requires.
856 * For example the AccessMode parameter of ObReferenceObjectByHandle/Pointer() is not
857 * required at all as it only has influence on the object security. This function doesn't
858 * want to get access to an object, it just looks for a valid handle and if it can't find
859 * one, it'll just create one. It wouldn't make sense to check for security again as the
860 * caller already has a pointer to the object.
862 * A test on an XP machine shows that this prototype appears to be correct.
865 * Process = This parameter simply describes in which handle table we're looking
866 * for a handle to the object.
867 * Object = The object pointer that we're looking for
868 * ObjectType = Just a sanity check as ObReferenceObjectByHandle() and
869 * ObReferenceObjectByPointer() provides.
870 * HandleInformation = This one has to be the opposite meaning of the usage in
871 * ObReferenceObjectByHandle(). If we actually found a valid
872 * handle in the table, we need to check against the information
873 * provided so we make sure this handle has all access rights
874 * (and attributes?!) we need. If they don't match, we can't
875 * use this handle and keep looking because the caller is likely
876 * to depend on these access rights.
877 * HandleReturn = The last parameter is the same as in ObCreateHandle(). If we could
878 * find a suitable handle in the handle table, return this handle, if
879 * not, we'll just create one using ObCreateHandle() with all access
880 * rights the caller needs.
887 ObFindHandleForObject(IN PEPROCESS Process
,
889 IN POBJECT_TYPE ObjectType
,
890 IN POBJECT_HANDLE_INFORMATION HandleInformation
,
891 OUT PHANDLE HandleReturn
)
894 return STATUS_UNSUCCESSFUL
;
898 ObpGetNextHandleByProcessCount(PSYSTEM_HANDLE_TABLE_ENTRY_INFO pshi
,
905 // pshi->HandleValue;
908 This will never work with ROS! M$, I guess uses 0 -> 65535.
909 Ros uses 0 -> 4294967295!
912 P
= (ULONG
) Process
->UniqueProcessId
;
913 pshi
->UniqueProcessId
= (USHORT
) P
;
915 // KeAcquireSpinLock( &Process->HandleTable.ListLock, &oldIrql );
917 // pshi->GrantedAccess;
919 // pshi->ObjectTypeIndex;
920 // pshi->HandleAttributes;
922 // KeReleaseSpinLock( &Process->HandleTable.ListLock, oldIrql );