diff --git "a/win32ss/user/ntuser/object.c" "b/win32ss/user/ntuser/object.c" index 36be69bedd4..d298ea74fa1 100644 --- "a/win32ss/user/ntuser/object.c" +++ "b/win32ss/user/ntuser/object.c" @@ -12,6 +12,8 @@ DBG_DEFAULT_CHANNEL(UserObj); //int usedHandles=0; PUSER_HANDLE_TABLE gHandleTable = NULL; +ULONG gUserHandleQuota = 10000; // This is the default on Win 10 (see HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\USERProcessHandleQuota) + /* Forward declarations */ _Success_(return!=NULL) static PVOID AllocThreadObject( @@ -27,6 +29,12 @@ static PVOID AllocThreadObject( ASSERT(Size > sizeof(*ObjHead)); ASSERT(pti != NULL); + if (pti->ppi->UserHandleCount >= gUserHandleQuota) + { + ERR("UserHandleQuota exceeded for process %p\n", pti->ppi); + return NULL; + } + ObjHead = UserHeapAlloc(Size); if (!ObjHead) return NULL; @@ -66,6 +74,12 @@ static PVOID AllocDeskThreadObject( ASSERT(Size > sizeof(*ObjHead)); ASSERT(pti != NULL); + if (pti->ppi->UserHandleCount >= gUserHandleQuota) + { + ERR("UserHandleQuota exceeded for process %p\n", pti->ppi); + return NULL; + } + if (!pDesk) pDesk = pti->rpdesk; @@ -113,6 +127,12 @@ static PVOID AllocDeskProcObject( ASSERT(pDesk != NULL); ASSERT(pti != NULL); + if (pti->ppi->UserHandleCount >= gUserHandleQuota) + { + ERR("UserHandleQuota exceeded for process %p\n", pti->ppi); + return NULL; + } + ObjHead = DesktopHeapAlloc(pDesk, Size); if (!ObjHead) return NULL; @@ -158,6 +178,12 @@ static PVOID AllocProcMarkObject( ASSERT(Size > sizeof(*ObjHead)); + if (ppi->UserHandleCount >= gUserHandleQuota) + { + ERR("UserHandleQuota exceeded for process %p\n", pti->ppi); + return NULL; + } + ObjHead = UserHeapAlloc(Size); if (!ObjHead) return NULL; @@ -536,7 +562,7 @@ void *get_user_object_handle(PUSER_HANDLE_TABLE ht, HANDLE* handle, HANDLE_TYPE BOOL FASTCALL UserCreateHandleTable(VOID) { PVOID mem; - INT HandleCount = 1024 * 4; + INT HandleCount = 1024 * 32; // FIXME: Don't alloc all at once! Must be mapped into umode also... mem = UserHeapAlloc(sizeof(USER_HANDLE_ENTRY) * HandleCount);