3 typedef struct _USER_REFERENCE_ENTRY
5 SINGLE_LIST_ENTRY Entry
;
7 } USER_REFERENCE_ENTRY
, *PUSER_REFERENCE_ENTRY
;
9 #define USER_ASSERT(exp,file,line) \
10 if (!(exp)) {RtlAssert(#exp,(PVOID)file,line,"");}
13 UserAssertLastRef(PVOID obj
, const char *file
, int line
)
15 PTHREADINFO W32Thread
;
16 PSINGLE_LIST_ENTRY ReferenceEntry
;
17 PUSER_REFERENCE_ENTRY UserReferenceEntry
;
19 USER_ASSERT(obj
!= NULL
, file
, line
);
20 W32Thread
= PsGetCurrentThreadWin32Thread();
21 USER_ASSERT(W32Thread
!= NULL
, file
, line
);
22 ReferenceEntry
= W32Thread
->ReferencesList
.Next
;
23 USER_ASSERT(ReferenceEntry
!= NULL
, file
, line
);
24 UserReferenceEntry
= CONTAINING_RECORD(ReferenceEntry
, USER_REFERENCE_ENTRY
, Entry
);
25 USER_ASSERT(UserReferenceEntry
!= NULL
, file
, line
);
26 USER_ASSERT(obj
== UserReferenceEntry
->obj
, file
, line
);
28 #define ASSERT_LAST_REF(_obj_) UserAssertLastRef(_obj,__FILE__,__LINE__)
32 extern PUSER_HANDLE_TABLE gHandleTable
;
33 VOID FASTCALL
UserReferenceObject(PVOID obj
);
34 PVOID FASTCALL
UserReferenceObjectByHandle(HANDLE handle
, USER_OBJECT_TYPE type
);
35 BOOL FASTCALL
UserDereferenceObject(PVOID obj
);
36 PVOID FASTCALL
UserCreateObject(PUSER_HANDLE_TABLE ht
, struct _DESKTOP
* pDesktop
, HANDLE
* h
,USER_OBJECT_TYPE type
, ULONG size
);
37 BOOL FASTCALL
UserDeleteObject(HANDLE h
, USER_OBJECT_TYPE type
);
38 PVOID
UserGetObject(PUSER_HANDLE_TABLE ht
, HANDLE handle
, USER_OBJECT_TYPE type
);
39 PVOID
UserGetObjectNoErr(PUSER_HANDLE_TABLE
, HANDLE
, USER_OBJECT_TYPE
);
40 BOOL FASTCALL
UserCreateHandleTable(VOID
);
41 BOOL FASTCALL
UserObjectInDestroy(HANDLE
);
42 void DbgUserDumpHandleTable();
45 UserRefObjectCo(PVOID obj
, PUSER_REFERENCE_ENTRY UserReferenceEntry
)
47 PTHREADINFO W32Thread
;
49 W32Thread
= PsGetCurrentThreadWin32Thread();
50 ASSERT(W32Thread
!= NULL
);
51 ASSERT(UserReferenceEntry
!= NULL
);
52 UserReferenceEntry
->obj
= obj
;
53 UserReferenceObject(obj
);
54 PushEntryList(&W32Thread
->ReferencesList
, &UserReferenceEntry
->Entry
);
58 UserDerefObjectCo(PVOID obj
)
60 PTHREADINFO W32Thread
;
61 PSINGLE_LIST_ENTRY ReferenceEntry
;
62 PUSER_REFERENCE_ENTRY UserReferenceEntry
;
65 W32Thread
= PsGetCurrentThreadWin32Thread();
66 ASSERT(W32Thread
!= NULL
);
67 ReferenceEntry
= PopEntryList(&W32Thread
->ReferencesList
);
68 ASSERT(ReferenceEntry
!= NULL
);
69 UserReferenceEntry
= CONTAINING_RECORD(ReferenceEntry
, USER_REFERENCE_ENTRY
, Entry
);
70 ASSERT(UserReferenceEntry
!= NULL
);
72 ASSERT(obj
== UserReferenceEntry
->obj
);
73 UserDereferenceObject(obj
);