1 #ifndef _WIN32K_OBJECT_H
2 #define _WIN32K_OBJECT_H
8 #define FIRST_USER_HANDLE 0x0020 /* first possible value for low word of user handle */
9 #define LAST_USER_HANDLE 0xffef /* last possible value for low word of user handle */
11 #define HANDLEENTRY_INDESTROY 1
13 typedef struct _USER_HANDLE_ENTRY
15 void *ptr
; /* pointer to object */
19 PTHREADINFO pti
; // pointer to Win32ThreadInfo
20 PPROCESSINFO ppi
; // pointer to W32ProcessInfo
22 unsigned char type
; /* object type (0 if free) */
24 unsigned short generation
; /* generation counter */
25 } USER_HANDLE_ENTRY
, * PUSER_HANDLE_ENTRY
;
29 typedef struct _USER_HANDLE_TABLE
31 PUSER_HANDLE_ENTRY handles
;
32 PUSER_HANDLE_ENTRY freelist
;
34 int allocated_handles
;
35 } USER_HANDLE_TABLE
, * PUSER_HANDLE_TABLE
;
39 typedef enum _USER_OBJECT_TYPE
65 typedef struct _USER_REFERENCE_ENTRY
67 SINGLE_LIST_ENTRY Entry
;
69 } USER_REFERENCE_ENTRY
, *PUSER_REFERENCE_ENTRY
;
73 #define USER_ASSERT(exp,file,line) \
74 if (!(exp)) {RtlAssert(#exp,(PVOID)file,line,"");}
77 UserAssertLastRef(PVOID obj
, const char *file
, int line
)
79 PTHREADINFO W32Thread
;
80 PSINGLE_LIST_ENTRY ReferenceEntry
;
81 PUSER_REFERENCE_ENTRY UserReferenceEntry
;
83 USER_ASSERT(obj
!= NULL
, file
, line
);
84 W32Thread
= PsGetCurrentThreadWin32Thread();
85 USER_ASSERT(W32Thread
!= NULL
, file
, line
);
86 ReferenceEntry
= W32Thread
->ReferencesList
.Next
;
87 USER_ASSERT(ReferenceEntry
!= NULL
, file
, line
);
88 UserReferenceEntry
= CONTAINING_RECORD(ReferenceEntry
, USER_REFERENCE_ENTRY
, Entry
);
89 USER_ASSERT(UserReferenceEntry
!= NULL
, file
, line
);
90 USER_ASSERT(obj
== UserReferenceEntry
->obj
, file
, line
);
92 #define ASSERT_LAST_REF(_obj_) UserAssertLastRef(_obj,__FILE__,__LINE__)
96 extern PUSER_HANDLE_TABLE gHandleTable
;
97 VOID FASTCALL
UserReferenceObject(PVOID obj
);
98 PVOID FASTCALL
UserReferenceObjectByHandle(HANDLE handle
, USER_OBJECT_TYPE type
);
99 BOOL FASTCALL
UserDereferenceObject(PVOID obj
);
100 PVOID FASTCALL
UserCreateObject(PUSER_HANDLE_TABLE ht
, struct _DESKTOP
* pDesktop
, HANDLE
* h
,USER_OBJECT_TYPE type
, ULONG size
);
101 BOOL FASTCALL
UserDeleteObject(HANDLE h
, USER_OBJECT_TYPE type
);
102 PVOID
UserGetObject(PUSER_HANDLE_TABLE ht
, HANDLE handle
, USER_OBJECT_TYPE type
);
103 HANDLE
UserAllocHandle(PUSER_HANDLE_TABLE ht
, PVOID object
, USER_OBJECT_TYPE type
);
104 BOOL FASTCALL
UserFreeHandle(PUSER_HANDLE_TABLE ht
, HANDLE handle
);
105 PVOID
UserGetNextHandle(PUSER_HANDLE_TABLE ht
, HANDLE
* handle
, USER_OBJECT_TYPE type
);
106 PUSER_HANDLE_ENTRY
handle_to_entry(PUSER_HANDLE_TABLE ht
, HANDLE handle
);
107 BOOL FASTCALL
UserCreateHandleTable(VOID
);
108 VOID
UserInitHandleTable(PUSER_HANDLE_TABLE ht
, PVOID mem
, ULONG bytes
);
112 UserRefObjectCo(PVOID obj
, PUSER_REFERENCE_ENTRY UserReferenceEntry
)
114 PTHREADINFO W32Thread
;
116 W32Thread
= PsGetCurrentThreadWin32Thread();
117 ASSERT(W32Thread
!= NULL
);
118 ASSERT(UserReferenceEntry
!= NULL
);
119 UserReferenceEntry
->obj
= obj
;
120 UserReferenceObject(obj
);
121 PushEntryList(&W32Thread
->ReferencesList
, &UserReferenceEntry
->Entry
);
125 UserDerefObjectCo(PVOID obj
)
127 PTHREADINFO W32Thread
;
128 PSINGLE_LIST_ENTRY ReferenceEntry
;
129 PUSER_REFERENCE_ENTRY UserReferenceEntry
;
132 W32Thread
= PsGetCurrentThreadWin32Thread();
133 ASSERT(W32Thread
!= NULL
);
134 ReferenceEntry
= PopEntryList(&W32Thread
->ReferencesList
);
135 ASSERT(ReferenceEntry
!= NULL
);
136 UserReferenceEntry
= CONTAINING_RECORD(ReferenceEntry
, USER_REFERENCE_ENTRY
, Entry
);
137 ASSERT(UserReferenceEntry
!= NULL
);
139 ASSERT(obj
== UserReferenceEntry
->obj
);
140 UserDereferenceObject(obj
);
143 VOID FASTCALL
CreateStockObjects (VOID
);
144 VOID FASTCALL
CreateSysColorObjects (VOID
);
146 PPOINT FASTCALL
GDI_Bezier (const POINT
*Points
, INT count
, PINT nPtsOut
);
148 #endif /* _WIN32K_OBJECT_H */