xref: /reactos/win32ss/user/ntuser/object.h (revision 9eca7c52)
1 #pragma once
2 
3 typedef struct _USER_REFERENCE_ENTRY
4 {
5    SINGLE_LIST_ENTRY Entry;
6    PVOID obj;
7 } USER_REFERENCE_ENTRY, *PUSER_REFERENCE_ENTRY;
8 
9 extern PUSER_HANDLE_TABLE gHandleTable;
10 VOID FASTCALL UserReferenceObject(PVOID obj);
11 PVOID FASTCALL UserReferenceObjectByHandle(HANDLE handle, HANDLE_TYPE type);
12 BOOL FASTCALL UserDereferenceObject(PVOID obj);
13 PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, struct _DESKTOP* pDesktop, PTHREADINFO pti, HANDLE* h,HANDLE_TYPE type , ULONG size);
14 BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type );
15 PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type );
16 PVOID UserGetObjectNoErr(PUSER_HANDLE_TABLE, HANDLE, HANDLE_TYPE);
17 BOOL FASTCALL UserCreateHandleTable(VOID);
18 BOOL FASTCALL UserObjectInDestroy(HANDLE);
19 void DbgUserDumpHandleTable();
20 PVOID FASTCALL ValidateHandle(HANDLE handle, HANDLE_TYPE type);
21 BOOLEAN UserDestroyObjectsForOwner(PUSER_HANDLE_TABLE Table, PVOID Owner);
22 BOOL FASTCALL UserMarkObjectDestroy(PVOID);
23 PVOID FASTCALL UserAssignmentLock(PVOID *ppvObj, PVOID pvNew);
24 PVOID FASTCALL UserAssignmentUnlock(PVOID *ppvObj);
25 
26 static __inline VOID
UserRefObjectCo(PVOID obj,PUSER_REFERENCE_ENTRY UserReferenceEntry)27 UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
28 {
29     PTHREADINFO W32Thread;
30 
31     W32Thread = PsGetCurrentThreadWin32Thread();
32     ASSERT(W32Thread != NULL);
33     ASSERT(UserReferenceEntry != NULL);
34     UserReferenceEntry->obj = obj;
35     UserReferenceObject(obj);
36     PushEntryList(&W32Thread->ReferencesList, &UserReferenceEntry->Entry);
37 #if DBG
38     W32Thread->cRefObjectCo++;
39 #endif
40 }
41 
42 static __inline VOID
UserDerefObjectCo(PVOID obj)43 UserDerefObjectCo(PVOID obj)
44 {
45     PTHREADINFO W32Thread;
46     PSINGLE_LIST_ENTRY ReferenceEntry;
47     PUSER_REFERENCE_ENTRY UserReferenceEntry;
48 
49     ASSERT(obj != NULL);
50     W32Thread = PsGetCurrentThreadWin32Thread();
51     ASSERT(W32Thread != NULL);
52     ReferenceEntry = PopEntryList(&W32Thread->ReferencesList);
53     ASSERT(ReferenceEntry != NULL);
54     UserReferenceEntry = CONTAINING_RECORD(ReferenceEntry, USER_REFERENCE_ENTRY, Entry);
55     ASSERT(UserReferenceEntry != NULL);
56 
57     ASSERT(obj == UserReferenceEntry->obj);
58     UserDereferenceObject(obj);
59 #if DBG
60     W32Thread->cRefObjectCo--;
61 #endif
62 }
63 
64 void FreeProcMarkObject(_In_ PVOID Object);
65 
66 /* EOF */
67