17static PVOID AllocThreadObject(
40 pti->ppi->UserHandleCount++;
53 pti->
ppi->UserHandleCount--;
58static PVOID AllocDeskThreadObject(
78 ObjHead->
pSelf = ObjHead;
84 pti->ppi->UserHandleCount++;
98 pti->
ppi->UserHandleCount--;
103static PVOID AllocDeskProcObject(
124 ObjHead->
pSelf = ObjHead;
127 ppi->UserHandleCount++;
141 ppi->UserHandleCount--;
148static PVOID AllocProcMarkObject(
170 ppi->UserHandleCount++;
182 ppi->UserHandleCount--;
187static PVOID AllocSysObject(
211static PVOID AllocSysObjectCB(
229 ERR(
"ExAllocatePoolZero failed. No object created.\n");
287 PWCHAR TypeNames[] = {
L"Free",
L"Window",
L"Menu",
L"CursorIcon",
L"SMWP",
L"Hook",
L"ClipBoardData",
L"CallProc",
288 L"Accel",
L"DDEaccess",
L"DDEconv",
L"DDExact",
L"Monitor",
L"KBDlayout",
L"KBDfile",
289 L"Event",
L"Timer",
L"InputContext",
L"HidData",
L"DeviceInfo",
L"TouchInput",
L"GestureInfo"};
293 memset(HandleCounts, 0,
sizeof(HandleCounts));
299 ERR(
"Process %s (%p) handles count: %d\n\t", ppiList->peProcess->ImageFileName, ppiList->peProcess->UniqueProcessId, ppiList->UserHandleCount);
303 HandleCounts[
i] += ppiList->DbgHandleCount[
i];
305 DbgPrint(
"%S: %lu, ", TypeNames[
i], ppiList->DbgHandleCount[
i]);
315 ERR(
"Total handles of the running processes: \n\t");
318 DbgPrint(
"%S: %d, ", TypeNames[
i], HandleCounts[
i]);
325 memset(HandleCounts, 0,
sizeof(HandleCounts));
329 ERR(
"Total handles count allocated: \n\t");
332 DbgPrint(
"%S: %d, ", TypeNames[
i], HandleCounts[
i]);
345 if (index < 0 || index >=
ht->nb_handles)
375 if (
ht->nb_handles >=
ht->allocated_handles)
387 int growth =
max( 32,
ht->allocated_handles / 2 );
389 if (new_size <= ht->allocated_handles)
393 ht->handles = new_handles;
394 ht->allocated_handles = new_size;
400 entry->generation = 1;
441 ppi->DbgHandleCount[
entry->type]--;
470 entry->pi = HandleOwner;
471 if (++
entry->generation >= 0xffff)
472 entry->generation = 1;
539 INT HandleCount = 1024 * 4;
545 ERR(
"Failed creating handle table\n");
553 ERR(
"Failed creating handle table\n");
589 ERR(
"User object allocation failed. Out of memory!\n");
596 ERR(
"Out of user handles!\n");
603 pti->
ppi->DbgHandleCount[
type]++;
634 entry->flags &= ~HANDLEENTRY_INDESTROY;
761 for (
i = 0;
i <
Table->allocated_handles;
i++)
775 ERR(
"Failed destructing object %p, type %u.\n",
Entry->ptr,
Entry->type);
841 PVOID pvOld = *ppvObj;
844 if (pvOld && pvOld == pvNew)
862 PVOID pvOld = *ppvObj;
static unsigned char bytes[4]
#define DBG_DEFAULT_CHANNEL(ch)
BOOLEAN DestroyCallProc(_Inout_ PVOID Object)
#define STATUS_INVALID_HANDLE
#define ERROR_INVALID_HANDLE
_In_ uint64_t _In_ uint64_t _In_ uint64_t generation
GLuint GLuint GLsizei GLenum type
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static const struct newhuff ht[]
struct _USER_HANDLE_ENTRY USER_HANDLE_ENTRY
#define HANDLEENTRY_INDESTROY
struct _PROCMARKHEAD * PPROCMARKHEAD
struct _PROCDESKHEAD * PPROCDESKHEAD
enum _HANDLE_TYPE HANDLE_TYPE
#define HANDLEENTRY_DESTROY
struct _THRDESKHEAD * PTHRDESKHEAD
struct _THROBJHEAD * PTHROBJHEAD
#define FIRST_USER_HANDLE
#define ExFreePoolWithTag(_P, _T)
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ SaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ OwnerSize PSID Owner
#define UNREFERENCED_PARAMETER(P)
BOOLEAN IntRemoveHook(PVOID Object)
VOID FASTCALL UserLeave(VOID)
VOID FASTCALL UserEnterExclusive(VOID)
struct _THREADINFO * PTHREADINFO
struct _PROCESSINFO * PPROCESSINFO
void DbgUserDumpHandleTable()
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
base of all file and directory entries
struct _PROCESSINFO * ppi
PUSER_HANDLE_ENTRY handles
#define RtlZeroMemory(Destination, Length)
BOOLEAN co_UserDestroyWindow(PVOID Object)
static __inline PVOID UserHeapAlloc(SIZE_T Bytes)
static __inline BOOL UserHeapFree(PVOID lpMem)
static __inline PVOID UserHeapReAlloc(PVOID lpMem, SIZE_T Bytes)
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
#define IntDereferenceThreadInfo(pti)
#define IntReferenceProcessInfo(ppi)
#define IntReferenceThreadInfo(pti)
#define IntDereferenceProcessInfo(ppi)
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
BOOLEAN UserDestroyAccelTable(PVOID Object)
VOID FreeCurIconObject(_In_ PVOID Object)
BOOLEAN IntDestroyCurIconObject(_In_ PVOID Object)
struct _DESKTOP * PDESKTOP
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
static __inline BOOL DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem)
BOOLEAN IntRemoveEvent(PVOID Object)
PVOID AllocInputContextObject(PDESKTOP pDesk, PTHREADINFO pti, SIZE_T Size, PVOID *HandleOwner)
BOOLEAN UserDestroyInputContext(PVOID Object)
VOID UserFreeInputContext(PVOID Object)
static __inline PUSER_HANDLE_ENTRY alloc_user_entry(PUSER_HANDLE_TABLE ht)
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
BOOLEAN UserDestroyObjectsForOwner(PUSER_HANDLE_TABLE Table, PVOID Owner)
BOOL FASTCALL UserMarkObjectDestroy(PVOID Object)
PVOID FASTCALL UserAssignmentLock(PVOID *ppvObj, PVOID pvNew)
BOOL FASTCALL UserDereferenceObject(PVOID Object)
PVOID FASTCALL UserReferenceObjectByHandle(HANDLE handle, HANDLE_TYPE type)
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
PUSER_HANDLE_TABLE gHandleTable
VOID UserInitHandleTable(PUSER_HANDLE_TABLE ht, PVOID mem, ULONG bytes)
BOOLEAN(* ObjectDestroy)(PVOID)
BOOL FASTCALL UserObjectInDestroy(HANDLE h)
void FreeProcMarkObject(_In_ PVOID Object)
BOOL FASTCALL UserCreateHandleTable(VOID)
void * get_user_object_handle(PUSER_HANDLE_TABLE ht, HANDLE *handle, HANDLE_TYPE type)
static void FreeDeskThreadObject(_In_ PVOID Object)
HANDLE get_user_full_handle(PUSER_HANDLE_TABLE ht, HANDLE handle)
HANDLE UserAllocHandle(_Inout_ PUSER_HANDLE_TABLE ht, _In_ PVOID object, _In_ HANDLE_TYPE type, _In_ PVOID HandleOwner)
PVOID(* ObjectAlloc)(PDESKTOP, PTHREADINFO, SIZE_T, PVOID *)
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
BOOL APIENTRY NtUserValidateHandleSecure(HANDLE handle)
static void FreeSysObject(_In_ PVOID Object)
PVOID FASTCALL UserAssignmentUnlock(PVOID *ppvObj)
void(* ObjectFree)(PVOID)
static void FreeSysObjectCB(_In_ PVOID Object)
static void FreeThreadObject(_In_ PVOID Object)
static __inline HANDLE entry_to_handle(PUSER_HANDLE_TABLE ht, PUSER_HANDLE_ENTRY ptr)
BOOL FASTCALL UserFreeHandle(PUSER_HANDLE_TABLE ht, HANDLE handle)
static __inline void * free_user_entry(PUSER_HANDLE_TABLE ht, PUSER_HANDLE_ENTRY entry)
PVOID UserGetObjectNoErr(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
VOID FASTCALL UserReferenceObject(PVOID obj)
static const struct @5135 ObjectCallbacks[TYPE_CTYPES]
PUSER_HANDLE_ENTRY handle_to_entry(PUSER_HANDLE_TABLE ht, HANDLE handle)
static void FreeDeskProcObject(_In_ PVOID Object)
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)