7 #define FIRST_USER_HANDLE 0x0020 /* first possible value for low word of user handle */
8 #define LAST_USER_HANDLE 0xffef /* last possible value for low word of user handle */
10 #define HANDLEENTRY_INDESTROY 1
12 typedef struct _USER_HANDLE_ENTRY
14 void *ptr
; /* pointer to object */
18 PTHREADINFO pti
; // pointer to Win32ThreadInfo
19 PPROCESSINFO ppi
; // pointer to W32ProcessInfo
21 unsigned char type
; /* object type (0 if free) */
23 unsigned short generation
; /* generation counter */
24 } USER_HANDLE_ENTRY
, * PUSER_HANDLE_ENTRY
;
28 typedef struct _USER_HANDLE_TABLE
30 PUSER_HANDLE_ENTRY handles
;
31 PUSER_HANDLE_ENTRY freelist
;
33 int allocated_handles
;
34 } USER_HANDLE_TABLE
, * PUSER_HANDLE_TABLE
;
38 typedef enum _USER_OBJECT_TYPE
64 typedef struct _USER_REFERENCE_ENTRY
66 SINGLE_LIST_ENTRY Entry
;
68 } USER_REFERENCE_ENTRY
, *PUSER_REFERENCE_ENTRY
;
70 #define USER_ASSERT(exp,file,line) \
71 if (!(exp)) {RtlAssert(#exp,(PVOID)file,line,"");}
74 UserAssertLastRef(PVOID obj
, const char *file
, int line
)
76 PTHREADINFO W32Thread
;
77 PSINGLE_LIST_ENTRY ReferenceEntry
;
78 PUSER_REFERENCE_ENTRY UserReferenceEntry
;
80 USER_ASSERT(obj
!= NULL
, file
, line
);
81 W32Thread
= PsGetCurrentThreadWin32Thread();
82 USER_ASSERT(W32Thread
!= NULL
, file
, line
);
83 ReferenceEntry
= W32Thread
->ReferencesList
.Next
;
84 USER_ASSERT(ReferenceEntry
!= NULL
, file
, line
);
85 UserReferenceEntry
= CONTAINING_RECORD(ReferenceEntry
, USER_REFERENCE_ENTRY
, Entry
);
86 USER_ASSERT(UserReferenceEntry
!= NULL
, file
, line
);
87 USER_ASSERT(obj
== UserReferenceEntry
->obj
, file
, line
);
89 #define ASSERT_LAST_REF(_obj_) UserAssertLastRef(_obj,__FILE__,__LINE__)
93 extern PUSER_HANDLE_TABLE gHandleTable
;
94 VOID FASTCALL
UserReferenceObject(PVOID obj
);
95 PVOID FASTCALL
UserReferenceObjectByHandle(HANDLE handle
, USER_OBJECT_TYPE type
);
96 BOOL FASTCALL
UserDereferenceObject(PVOID obj
);
97 PVOID FASTCALL
UserCreateObject(PUSER_HANDLE_TABLE ht
, struct _DESKTOP
* pDesktop
, HANDLE
* h
,USER_OBJECT_TYPE type
, ULONG size
);
98 BOOL FASTCALL
UserDeleteObject(HANDLE h
, USER_OBJECT_TYPE type
);
99 PVOID
UserGetObject(PUSER_HANDLE_TABLE ht
, HANDLE handle
, USER_OBJECT_TYPE type
);
100 HANDLE
UserAllocHandle(PUSER_HANDLE_TABLE ht
, PVOID object
, USER_OBJECT_TYPE type
);
101 BOOL FASTCALL
UserFreeHandle(PUSER_HANDLE_TABLE ht
, HANDLE handle
);
102 PVOID
UserGetNextHandle(PUSER_HANDLE_TABLE ht
, HANDLE
* handle
, USER_OBJECT_TYPE type
);
103 PUSER_HANDLE_ENTRY
handle_to_entry(PUSER_HANDLE_TABLE ht
, HANDLE handle
);
104 BOOL FASTCALL
UserCreateHandleTable(VOID
);
105 VOID
UserInitHandleTable(PUSER_HANDLE_TABLE ht
, PVOID mem
, ULONG bytes
);
109 UserRefObjectCo(PVOID obj
, PUSER_REFERENCE_ENTRY UserReferenceEntry
)
111 PTHREADINFO W32Thread
;
113 W32Thread
= PsGetCurrentThreadWin32Thread();
114 ASSERT(W32Thread
!= NULL
);
115 ASSERT(UserReferenceEntry
!= NULL
);
116 UserReferenceEntry
->obj
= obj
;
117 UserReferenceObject(obj
);
118 PushEntryList(&W32Thread
->ReferencesList
, &UserReferenceEntry
->Entry
);
122 UserDerefObjectCo(PVOID obj
)
124 PTHREADINFO W32Thread
;
125 PSINGLE_LIST_ENTRY ReferenceEntry
;
126 PUSER_REFERENCE_ENTRY UserReferenceEntry
;
129 W32Thread
= PsGetCurrentThreadWin32Thread();
130 ASSERT(W32Thread
!= NULL
);
131 ReferenceEntry
= PopEntryList(&W32Thread
->ReferencesList
);
132 ASSERT(ReferenceEntry
!= NULL
);
133 UserReferenceEntry
= CONTAINING_RECORD(ReferenceEntry
, USER_REFERENCE_ENTRY
, Entry
);
134 ASSERT(UserReferenceEntry
!= NULL
);
136 ASSERT(obj
== UserReferenceEntry
->obj
);
137 UserDereferenceObject(obj
);
140 VOID FASTCALL
CreateStockObjects (VOID
);
141 VOID FASTCALL
CreateSysColorObjects (VOID
);
143 PPOINT FASTCALL
GDI_Bezier (const POINT
*Points
, INT count
, PINT nPtsOut
);