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
;
72 #define USER_ASSERT(exp,file,line) \
73 if (!(exp)) {RtlAssert(#exp,(PVOID)file,line,"");}
76 UserAssertLastRef(PVOID obj
, const char *file
, int line
)
78 PTHREADINFO W32Thread
;
79 PSINGLE_LIST_ENTRY ReferenceEntry
;
80 PUSER_REFERENCE_ENTRY UserReferenceEntry
;
82 USER_ASSERT(obj
!= NULL
, file
, line
);
83 W32Thread
= PsGetCurrentThreadWin32Thread();
84 USER_ASSERT(W32Thread
!= NULL
, file
, line
);
85 ReferenceEntry
= W32Thread
->ReferencesList
.Next
;
86 USER_ASSERT(ReferenceEntry
!= NULL
, file
, line
);
87 UserReferenceEntry
= CONTAINING_RECORD(ReferenceEntry
, USER_REFERENCE_ENTRY
, Entry
);
88 USER_ASSERT(UserReferenceEntry
!= NULL
, file
, line
);
89 USER_ASSERT(obj
== UserReferenceEntry
->obj
, file
, line
);
91 #define ASSERT_LAST_REF(_obj_) UserAssertLastRef(_obj,__FILE__,__LINE__)
95 extern PUSER_HANDLE_TABLE gHandleTable
;
96 VOID FASTCALL
UserReferenceObject(PVOID obj
);
97 PVOID FASTCALL
UserReferenceObjectByHandle(HANDLE handle
, USER_OBJECT_TYPE type
);
98 BOOL FASTCALL
UserDereferenceObject(PVOID obj
);
99 PVOID FASTCALL
UserCreateObject(PUSER_HANDLE_TABLE ht
, struct _DESKTOP
* pDesktop
, HANDLE
* h
,USER_OBJECT_TYPE type
, ULONG size
);
100 BOOL FASTCALL
UserDeleteObject(HANDLE h
, USER_OBJECT_TYPE type
);
101 PVOID
UserGetObject(PUSER_HANDLE_TABLE ht
, HANDLE handle
, USER_OBJECT_TYPE type
);
102 HANDLE
UserAllocHandle(PUSER_HANDLE_TABLE ht
, PVOID object
, USER_OBJECT_TYPE type
);
103 BOOL FASTCALL
UserFreeHandle(PUSER_HANDLE_TABLE ht
, HANDLE handle
);
104 PVOID
UserGetNextHandle(PUSER_HANDLE_TABLE ht
, HANDLE
* handle
, USER_OBJECT_TYPE type
);
105 PUSER_HANDLE_ENTRY
handle_to_entry(PUSER_HANDLE_TABLE ht
, HANDLE handle
);
106 BOOL FASTCALL
UserCreateHandleTable(VOID
);
107 VOID
UserInitHandleTable(PUSER_HANDLE_TABLE ht
, PVOID mem
, ULONG bytes
);
111 UserRefObjectCo(PVOID obj
, PUSER_REFERENCE_ENTRY UserReferenceEntry
)
113 PTHREADINFO W32Thread
;
115 W32Thread
= PsGetCurrentThreadWin32Thread();
116 ASSERT(W32Thread
!= NULL
);
117 ASSERT(UserReferenceEntry
!= NULL
);
118 UserReferenceEntry
->obj
= obj
;
119 UserReferenceObject(obj
);
120 PushEntryList(&W32Thread
->ReferencesList
, &UserReferenceEntry
->Entry
);
124 UserDerefObjectCo(PVOID obj
)
126 PTHREADINFO W32Thread
;
127 PSINGLE_LIST_ENTRY ReferenceEntry
;
128 PUSER_REFERENCE_ENTRY UserReferenceEntry
;
131 W32Thread
= PsGetCurrentThreadWin32Thread();
132 ASSERT(W32Thread
!= NULL
);
133 ReferenceEntry
= PopEntryList(&W32Thread
->ReferencesList
);
134 ASSERT(ReferenceEntry
!= NULL
);
135 UserReferenceEntry
= CONTAINING_RECORD(ReferenceEntry
, USER_REFERENCE_ENTRY
, Entry
);
136 ASSERT(UserReferenceEntry
!= NULL
);
138 ASSERT(obj
== UserReferenceEntry
->obj
);
139 UserDereferenceObject(obj
);
142 VOID FASTCALL
CreateStockObjects (VOID
);
143 VOID FASTCALL
CreateSysColorObjects (VOID
);
145 PPOINT FASTCALL
GDI_Bezier (const POINT
*Points
, INT count
, PINT nPtsOut
);