2003-05-19 01:16:18 +08:00
|
|
|
/*
|
2011-09-21 03:41:33 +08:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PURPOSE: User handle manager
|
2015-11-11 01:41:55 +08:00
|
|
|
* FILE: win32ss/user/ntuser/object.c
|
2011-09-21 03:41:33 +08:00
|
|
|
* PROGRAMER: Copyright (C) 2001 Alexandre Julliard
|
2001-06-13 01:51:51 +08:00
|
|
|
*/
|
2005-09-08 04:59:26 +08:00
|
|
|
|
2010-04-26 21:58:46 +08:00
|
|
|
#include <win32k.h>
|
2011-08-21 20:38:52 +08:00
|
|
|
DBG_DEFAULT_CHANNEL(UserObj);
|
2001-06-13 01:51:51 +08:00
|
|
|
|
2009-07-25 08:41:22 +08:00
|
|
|
//int usedHandles=0;
|
2006-04-05 16:05:55 +08:00
|
|
|
PUSER_HANDLE_TABLE gHandleTable = NULL;
|
2001-06-13 01:51:51 +08:00
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
/* Forward declarations */
|
2015-03-10 08:12:41 +08:00
|
|
|
_Success_(return!=NULL)
|
2014-09-22 01:44:40 +08:00
|
|
|
static PVOID AllocThreadObject(
|
|
|
|
_In_ PDESKTOP pDesk,
|
|
|
|
_In_ PTHREADINFO pti,
|
|
|
|
_In_ SIZE_T Size,
|
|
|
|
_Out_ PVOID* HandleOwner)
|
|
|
|
{
|
|
|
|
PTHROBJHEAD ObjHead;
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(pDesk);
|
|
|
|
|
|
|
|
ASSERT(Size > sizeof(*ObjHead));
|
|
|
|
ASSERT(pti != NULL);
|
|
|
|
|
|
|
|
ObjHead = UserHeapAlloc(Size);
|
|
|
|
if (!ObjHead)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
RtlZeroMemory(ObjHead, Size);
|
|
|
|
|
|
|
|
ObjHead->pti = pti;
|
|
|
|
IntReferenceThreadInfo(pti);
|
|
|
|
*HandleOwner = pti;
|
|
|
|
/* It's a thread object, but it still count as one for the process */
|
|
|
|
pti->ppi->UserHandleCount++;
|
|
|
|
|
|
|
|
return ObjHead;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void FreeThreadObject(
|
|
|
|
_In_ PVOID Object)
|
|
|
|
{
|
|
|
|
PTHROBJHEAD ObjHead = (PTHROBJHEAD)Object;
|
|
|
|
PTHREADINFO pti = ObjHead->pti;
|
|
|
|
|
|
|
|
UserHeapFree(ObjHead);
|
|
|
|
|
|
|
|
pti->ppi->UserHandleCount--;
|
|
|
|
IntDereferenceThreadInfo(pti);
|
|
|
|
}
|
|
|
|
|
2015-03-10 08:12:41 +08:00
|
|
|
_Success_(return!=NULL)
|
2014-09-22 01:44:40 +08:00
|
|
|
static PVOID AllocDeskThreadObject(
|
|
|
|
_In_ PDESKTOP pDesk,
|
|
|
|
_In_ PTHREADINFO pti,
|
|
|
|
_In_ SIZE_T Size,
|
|
|
|
_Out_ PVOID* HandleOwner)
|
|
|
|
{
|
|
|
|
PTHRDESKHEAD ObjHead;
|
|
|
|
|
|
|
|
ASSERT(Size > sizeof(*ObjHead));
|
|
|
|
ASSERT(pti != NULL);
|
|
|
|
|
|
|
|
if (!pDesk)
|
|
|
|
pDesk = pti->rpdesk;
|
|
|
|
|
|
|
|
ObjHead = DesktopHeapAlloc(pDesk, Size);
|
|
|
|
if (!ObjHead)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
RtlZeroMemory(ObjHead, Size);
|
|
|
|
|
|
|
|
ObjHead->pSelf = ObjHead;
|
|
|
|
ObjHead->rpdesk = pDesk;
|
|
|
|
ObjHead->pti = pti;
|
|
|
|
IntReferenceThreadInfo(pti);
|
|
|
|
*HandleOwner = pti;
|
|
|
|
/* It's a thread object, but it still count as one for the process */
|
|
|
|
pti->ppi->UserHandleCount++;
|
|
|
|
|
|
|
|
return ObjHead;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void FreeDeskThreadObject(
|
|
|
|
_In_ PVOID Object)
|
|
|
|
{
|
|
|
|
PTHRDESKHEAD ObjHead = (PTHRDESKHEAD)Object;
|
|
|
|
PDESKTOP pDesk = ObjHead->rpdesk;
|
|
|
|
PTHREADINFO pti = ObjHead->pti;
|
|
|
|
|
|
|
|
DesktopHeapFree(pDesk, Object);
|
|
|
|
|
|
|
|
pti->ppi->UserHandleCount--;
|
|
|
|
IntDereferenceThreadInfo(pti);
|
|
|
|
}
|
|
|
|
|
2015-03-10 08:12:41 +08:00
|
|
|
_Success_(return!=NULL)
|
2014-09-22 01:44:40 +08:00
|
|
|
static PVOID AllocDeskProcObject(
|
|
|
|
_In_ PDESKTOP pDesk,
|
|
|
|
_In_ PTHREADINFO pti,
|
|
|
|
_In_ SIZE_T Size,
|
|
|
|
_Out_ PVOID* HandleOwner)
|
|
|
|
{
|
|
|
|
PPROCDESKHEAD ObjHead;
|
|
|
|
PPROCESSINFO ppi;
|
|
|
|
|
|
|
|
ASSERT(Size > sizeof(*ObjHead));
|
|
|
|
ASSERT(pDesk != NULL);
|
|
|
|
ASSERT(pti != NULL);
|
|
|
|
|
|
|
|
ObjHead = DesktopHeapAlloc(pDesk, Size);
|
|
|
|
if (!ObjHead)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
RtlZeroMemory(ObjHead, Size);
|
|
|
|
|
|
|
|
ppi = pti->ppi;
|
|
|
|
|
|
|
|
ObjHead->pSelf = ObjHead;
|
|
|
|
ObjHead->rpdesk = pDesk;
|
|
|
|
ObjHead->hTaskWow = (DWORD_PTR)ppi;
|
|
|
|
ppi->UserHandleCount++;
|
|
|
|
IntReferenceProcessInfo(ppi);
|
|
|
|
*HandleOwner = ppi;
|
|
|
|
|
|
|
|
return ObjHead;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void FreeDeskProcObject(
|
|
|
|
_In_ PVOID Object)
|
|
|
|
{
|
|
|
|
PPROCDESKHEAD ObjHead = (PPROCDESKHEAD)Object;
|
|
|
|
PDESKTOP pDesk = ObjHead->rpdesk;
|
|
|
|
PPROCESSINFO ppi = (PPROCESSINFO)ObjHead->hTaskWow;
|
|
|
|
|
|
|
|
ppi->UserHandleCount--;
|
|
|
|
IntDereferenceProcessInfo(ppi);
|
|
|
|
|
|
|
|
DesktopHeapFree(pDesk, Object);
|
|
|
|
}
|
|
|
|
|
2015-03-10 08:12:41 +08:00
|
|
|
_Success_(return!=NULL)
|
2014-09-22 01:44:40 +08:00
|
|
|
static PVOID AllocProcMarkObject(
|
|
|
|
_In_ PDESKTOP pDesk,
|
|
|
|
_In_ PTHREADINFO pti,
|
|
|
|
_In_ SIZE_T Size,
|
|
|
|
_Out_ PVOID* HandleOwner)
|
|
|
|
{
|
|
|
|
PPROCMARKHEAD ObjHead;
|
|
|
|
PPROCESSINFO ppi = pti->ppi;
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(pDesk);
|
|
|
|
|
|
|
|
ASSERT(Size > sizeof(*ObjHead));
|
|
|
|
|
|
|
|
ObjHead = UserHeapAlloc(Size);
|
|
|
|
if (!ObjHead)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
RtlZeroMemory(ObjHead, Size);
|
|
|
|
|
|
|
|
ObjHead->ppi = ppi;
|
|
|
|
IntReferenceProcessInfo(ppi);
|
|
|
|
*HandleOwner = ppi;
|
|
|
|
ppi->UserHandleCount++;
|
|
|
|
|
|
|
|
return ObjHead;
|
|
|
|
}
|
|
|
|
|
2014-10-22 03:57:03 +08:00
|
|
|
void FreeProcMarkObject(
|
2014-09-22 01:44:40 +08:00
|
|
|
_In_ PVOID Object)
|
|
|
|
{
|
|
|
|
PPROCESSINFO ppi = ((PPROCMARKHEAD)Object)->ppi;
|
|
|
|
|
|
|
|
UserHeapFree(Object);
|
|
|
|
|
|
|
|
ppi->UserHandleCount--;
|
|
|
|
IntDereferenceProcessInfo(ppi);
|
|
|
|
}
|
|
|
|
|
2015-03-10 08:12:41 +08:00
|
|
|
_Success_(return!=NULL)
|
2014-09-22 01:44:40 +08:00
|
|
|
static PVOID AllocSysObject(
|
|
|
|
_In_ PDESKTOP pDesk,
|
|
|
|
_In_ PTHREADINFO pti,
|
|
|
|
_In_ SIZE_T Size,
|
|
|
|
_Out_ PVOID* ObjectOwner)
|
|
|
|
{
|
|
|
|
PVOID Object;
|
|
|
|
|
|
|
|
UNREFERENCED_PARAMETER(pDesk);
|
|
|
|
UNREFERENCED_PARAMETER(pti);
|
|
|
|
|
|
|
|
ASSERT(Size > sizeof(HEAD));
|
|
|
|
|
|
|
|
Object = UserHeapAlloc(Size);
|
|
|
|
if (!Object)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
*ObjectOwner = NULL;
|
|
|
|
|
|
|
|
RtlZeroMemory(Object, Size);
|
|
|
|
return Object;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void FreeSysObject(
|
|
|
|
_In_ PVOID Object)
|
|
|
|
{
|
|
|
|
UserHeapFree(Object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
PVOID (*ObjectAlloc)(PDESKTOP, PTHREADINFO, SIZE_T, PVOID*);
|
|
|
|
BOOLEAN (*ObjectDestroy)(PVOID);
|
|
|
|
void (*ObjectFree)(PVOID);
|
|
|
|
} ObjectCallbacks[TYPE_CTYPES] =
|
|
|
|
{
|
|
|
|
{ NULL, NULL, NULL }, /* TYPE_FREE */
|
|
|
|
{ AllocDeskThreadObject, co_UserDestroyWindow, FreeDeskThreadObject }, /* TYPE_WINDOW */
|
|
|
|
{ AllocDeskProcObject, UserDestroyMenuObject, FreeDeskProcObject }, /* TYPE_MENU */
|
2014-10-22 03:57:03 +08:00
|
|
|
{ AllocProcMarkObject, IntDestroyCurIconObject, FreeCurIconObject }, /* TYPE_CURSOR */
|
2014-09-22 01:44:40 +08:00
|
|
|
{ AllocSysObject, /*UserSetWindowPosCleanup*/NULL, FreeSysObject }, /* TYPE_SETWINDOWPOS */
|
|
|
|
{ AllocDeskThreadObject, IntRemoveHook, FreeDeskThreadObject }, /* TYPE_HOOK */
|
|
|
|
{ AllocSysObject, /*UserClipDataCleanup*/NULL,FreeSysObject }, /* TYPE_CLIPDATA */
|
|
|
|
{ AllocDeskProcObject, DestroyCallProc, FreeDeskProcObject }, /* TYPE_CALLPROC */
|
|
|
|
{ AllocProcMarkObject, UserDestroyAccelTable, FreeProcMarkObject }, /* TYPE_ACCELTABLE */
|
|
|
|
{ NULL, NULL, NULL }, /* TYPE_DDEACCESS */
|
|
|
|
{ NULL, NULL, NULL }, /* TYPE_DDECONV */
|
|
|
|
{ NULL, NULL, NULL }, /* TYPE_DDEXACT */
|
|
|
|
{ AllocSysObject, /*UserMonitorCleanup*/NULL, FreeSysObject }, /* TYPE_MONITOR */
|
|
|
|
{ AllocSysObject, /*UserKbdLayoutCleanup*/NULL,FreeSysObject }, /* TYPE_KBDLAYOUT */
|
|
|
|
{ AllocSysObject, /*UserKbdFileCleanup*/NULL, FreeSysObject }, /* TYPE_KBDFILE */
|
|
|
|
{ AllocThreadObject, IntRemoveEvent, FreeThreadObject }, /* TYPE_WINEVENTHOOK */
|
|
|
|
{ AllocSysObject, /*UserTimerCleanup*/NULL, FreeSysObject }, /* TYPE_TIMER */
|
|
|
|
{ NULL, NULL, NULL }, /* TYPE_INPUTCONTEXT */
|
|
|
|
{ NULL, NULL, NULL }, /* TYPE_HIDDATA */
|
|
|
|
{ NULL, NULL, NULL }, /* TYPE_DEVICEINFO */
|
|
|
|
{ NULL, NULL, NULL }, /* TYPE_TOUCHINPUTINFO */
|
|
|
|
{ NULL, NULL, NULL }, /* TYPE_GESTUREINFOOBJ */
|
|
|
|
};
|
|
|
|
|
2012-10-28 00:39:18 +08:00
|
|
|
#if DBG
|
|
|
|
|
2015-09-04 08:11:49 +08:00
|
|
|
void DbgUserDumpHandleTable(VOID)
|
2012-10-28 00:39:18 +08:00
|
|
|
{
|
2012-12-30 03:14:30 +08:00
|
|
|
int HandleCounts[TYPE_CTYPES];
|
2012-10-28 00:39:18 +08:00
|
|
|
PPROCESSINFO ppiList;
|
|
|
|
int i;
|
|
|
|
PWCHAR TypeNames[] = {L"Free",L"Window",L"Menu", L"CursorIcon", L"SMWP", L"Hook", L"ClipBoardData", L"CallProc",
|
|
|
|
L"Accel", L"DDEaccess", L"DDEconv", L"DDExact", L"Monitor", L"KBDlayout", L"KBDfile",
|
|
|
|
L"Event", L"Timer", L"InputContext", L"HidData", L"DeviceInfo", L"TouchInput",L"GestureInfo"};
|
|
|
|
|
2013-09-02 07:58:37 +08:00
|
|
|
ERR("Total handles count: %lu\n", gpsi->cHandleEntries);
|
2012-10-28 00:39:18 +08:00
|
|
|
|
|
|
|
memset(HandleCounts, 0, sizeof(HandleCounts));
|
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
/* First of all count the number of handles per type */
|
2012-10-28 00:39:18 +08:00
|
|
|
ppiList = gppiList;
|
|
|
|
while (ppiList)
|
|
|
|
{
|
2013-09-02 07:58:37 +08:00
|
|
|
ERR("Process %s (%p) handles count: %d\n\t", ppiList->peProcess->ImageFileName, ppiList->peProcess->UniqueProcessId, ppiList->UserHandleCount);
|
2012-10-28 00:39:18 +08:00
|
|
|
|
2012-12-30 03:14:30 +08:00
|
|
|
for (i = 1 ;i < TYPE_CTYPES; i++)
|
2012-10-28 00:39:18 +08:00
|
|
|
{
|
|
|
|
HandleCounts[i] += ppiList->DbgHandleCount[i];
|
|
|
|
|
2013-09-02 07:58:37 +08:00
|
|
|
DbgPrint("%S: %lu, ", TypeNames[i], ppiList->DbgHandleCount[i]);
|
2012-10-28 00:39:18 +08:00
|
|
|
if (i % 6 == 0)
|
|
|
|
DbgPrint("\n\t");
|
|
|
|
}
|
|
|
|
DbgPrint("\n");
|
|
|
|
|
|
|
|
ppiList = ppiList->ppiNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print total type counts */
|
|
|
|
ERR("Total handles of the running processes: \n\t");
|
2012-12-30 03:14:30 +08:00
|
|
|
for (i = 1 ;i < TYPE_CTYPES; i++)
|
2012-10-28 00:39:18 +08:00
|
|
|
{
|
|
|
|
DbgPrint("%S: %d, ", TypeNames[i], HandleCounts[i]);
|
|
|
|
if (i % 6 == 0)
|
|
|
|
DbgPrint("\n\t");
|
|
|
|
}
|
|
|
|
DbgPrint("\n");
|
|
|
|
|
|
|
|
/* Now count the handle counts that are allocated from the handle table */
|
|
|
|
memset(HandleCounts, 0, sizeof(HandleCounts));
|
|
|
|
for (i = 0; i < gHandleTable->nb_handles; i++)
|
|
|
|
HandleCounts[gHandleTable->handles[i].type]++;
|
|
|
|
|
|
|
|
ERR("Total handles count allocated: \n\t");
|
2012-12-30 03:14:30 +08:00
|
|
|
for (i = 1 ;i < TYPE_CTYPES; i++)
|
2012-10-28 00:39:18 +08:00
|
|
|
{
|
|
|
|
DbgPrint("%S: %d, ", TypeNames[i], HandleCounts[i]);
|
|
|
|
if (i % 6 == 0)
|
|
|
|
DbgPrint("\n\t");
|
|
|
|
}
|
|
|
|
DbgPrint("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2001-06-13 01:51:51 +08:00
|
|
|
|
2005-09-08 04:59:26 +08:00
|
|
|
PUSER_HANDLE_ENTRY handle_to_entry(PUSER_HANDLE_TABLE ht, HANDLE handle )
|
2001-06-13 01:51:51 +08:00
|
|
|
{
|
2005-09-08 05:25:42 +08:00
|
|
|
unsigned short generation;
|
2018-03-18 22:53:52 +08:00
|
|
|
int index = (LOWORD(handle) - FIRST_USER_HANDLE) >> 1;
|
2005-09-08 05:25:42 +08:00
|
|
|
if (index < 0 || index >= ht->nb_handles)
|
|
|
|
return NULL;
|
|
|
|
if (!ht->handles[index].type)
|
|
|
|
return NULL;
|
2018-03-18 22:53:52 +08:00
|
|
|
generation = HIWORD(handle);
|
2005-09-08 05:25:42 +08:00
|
|
|
if (generation == ht->handles[index].generation || !generation || generation == 0xffff)
|
|
|
|
return &ht->handles[index];
|
|
|
|
return NULL;
|
2005-09-08 04:59:26 +08:00
|
|
|
}
|
2005-05-08 10:11:54 +08:00
|
|
|
|
2005-11-29 07:35:35 +08:00
|
|
|
__inline static HANDLE entry_to_handle(PUSER_HANDLE_TABLE ht, PUSER_HANDLE_ENTRY ptr )
|
2005-09-08 04:59:26 +08:00
|
|
|
{
|
2005-09-08 05:25:42 +08:00
|
|
|
int index = ptr - ht->handles;
|
2018-03-18 22:53:52 +08:00
|
|
|
return (HANDLE)((((INT_PTR)index << 1) + FIRST_USER_HANDLE) + (ptr->generation << 16));
|
2001-06-13 01:51:51 +08:00
|
|
|
}
|
|
|
|
|
2005-11-29 07:35:35 +08:00
|
|
|
__inline static PUSER_HANDLE_ENTRY alloc_user_entry(PUSER_HANDLE_TABLE ht)
|
2001-06-13 01:51:51 +08:00
|
|
|
{
|
2005-09-08 05:25:42 +08:00
|
|
|
PUSER_HANDLE_ENTRY entry;
|
2013-09-02 07:58:37 +08:00
|
|
|
TRACE("handles used %lu\n", gpsi->cHandleEntries);
|
2005-09-11 22:48:32 +08:00
|
|
|
|
2005-09-08 05:25:42 +08:00
|
|
|
if (ht->freelist)
|
|
|
|
{
|
|
|
|
entry = ht->freelist;
|
|
|
|
ht->freelist = entry->ptr;
|
|
|
|
|
2009-07-25 08:41:22 +08:00
|
|
|
gpsi->cHandleEntries++;
|
2005-09-08 05:25:42 +08:00
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
2011-12-14 12:07:06 +08:00
|
|
|
if (ht->nb_handles >= ht->allocated_handles) /* Need to grow the array */
|
2005-09-08 05:25:42 +08:00
|
|
|
{
|
2013-09-02 07:58:37 +08:00
|
|
|
ERR("Out of user handles! Used -> %lu, NM_Handle -> %d\n", gpsi->cHandleEntries, ht->nb_handles);
|
2012-10-28 00:39:18 +08:00
|
|
|
|
|
|
|
#if DBG
|
|
|
|
DbgUserDumpHandleTable();
|
|
|
|
#endif
|
|
|
|
|
2005-09-08 05:25:42 +08:00
|
|
|
return NULL;
|
2005-09-08 04:59:26 +08:00
|
|
|
#if 0
|
2006-04-05 16:05:55 +08:00
|
|
|
PUSER_HANDLE_ENTRY new_handles;
|
2011-12-14 12:07:06 +08:00
|
|
|
/* Grow array by 50% (but at minimum 32 entries) */
|
2006-04-05 16:05:55 +08:00
|
|
|
int growth = max( 32, ht->allocated_handles / 2 );
|
|
|
|
int new_size = min( ht->allocated_handles + growth, (LAST_USER_HANDLE-FIRST_USER_HANDLE+1) >> 1 );
|
|
|
|
if (new_size <= ht->allocated_handles)
|
2005-09-08 05:25:42 +08:00
|
|
|
return NULL;
|
2006-04-05 16:05:55 +08:00
|
|
|
if (!(new_handles = UserHeapReAlloc( ht->handles, new_size * sizeof(*ht->handles) )))
|
2005-09-08 05:25:42 +08:00
|
|
|
return NULL;
|
2006-04-05 16:05:55 +08:00
|
|
|
ht->handles = new_handles;
|
|
|
|
ht->allocated_handles = new_size;
|
2005-09-08 05:25:42 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
entry = &ht->handles[ht->nb_handles++];
|
|
|
|
|
|
|
|
entry->generation = 1;
|
|
|
|
|
2009-07-25 08:41:22 +08:00
|
|
|
gpsi->cHandleEntries++;
|
2005-09-08 05:25:42 +08:00
|
|
|
|
|
|
|
return entry;
|
2001-06-13 01:51:51 +08:00
|
|
|
}
|
|
|
|
|
2005-09-08 04:59:26 +08:00
|
|
|
VOID UserInitHandleTable(PUSER_HANDLE_TABLE ht, PVOID mem, ULONG bytes)
|
2001-06-13 01:51:51 +08:00
|
|
|
{
|
2005-09-08 04:59:26 +08:00
|
|
|
ht->freelist = NULL;
|
|
|
|
ht->handles = mem;
|
2005-09-08 05:25:42 +08:00
|
|
|
|
|
|
|
ht->nb_handles = 0;
|
2005-09-08 04:59:26 +08:00
|
|
|
ht->allocated_handles = bytes / sizeof(USER_HANDLE_ENTRY);
|
2001-06-13 01:51:51 +08:00
|
|
|
}
|
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
|
2005-11-29 07:35:35 +08:00
|
|
|
__inline static void *free_user_entry(PUSER_HANDLE_TABLE ht, PUSER_HANDLE_ENTRY entry)
|
2001-06-13 01:51:51 +08:00
|
|
|
{
|
2005-09-08 05:25:42 +08:00
|
|
|
void *ret;
|
2012-10-28 00:39:18 +08:00
|
|
|
|
|
|
|
#if DBG
|
2014-09-22 01:44:40 +08:00
|
|
|
{
|
|
|
|
PPROCESSINFO ppi;
|
|
|
|
switch (entry->type)
|
|
|
|
{
|
|
|
|
case TYPE_WINDOW:
|
|
|
|
case TYPE_HOOK:
|
|
|
|
case TYPE_WINEVENTHOOK:
|
|
|
|
ppi = ((PTHREADINFO)entry->pi)->ppi;
|
|
|
|
break;
|
|
|
|
case TYPE_MENU:
|
|
|
|
case TYPE_CURSOR:
|
|
|
|
case TYPE_CALLPROC:
|
|
|
|
case TYPE_ACCELTABLE:
|
|
|
|
ppi = entry->pi;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ppi = NULL;
|
|
|
|
}
|
|
|
|
if (ppi)
|
|
|
|
ppi->DbgHandleCount[entry->type]--;
|
|
|
|
}
|
2012-10-28 00:39:18 +08:00
|
|
|
#endif
|
|
|
|
|
2005-09-08 05:25:42 +08:00
|
|
|
ret = entry->ptr;
|
|
|
|
entry->ptr = ht->freelist;
|
|
|
|
entry->type = 0;
|
2010-01-14 21:33:04 +08:00
|
|
|
entry->flags = 0;
|
2007-11-15 13:42:44 +08:00
|
|
|
entry->pi = NULL;
|
2005-09-08 05:25:42 +08:00
|
|
|
ht->freelist = entry;
|
|
|
|
|
2009-07-25 08:41:22 +08:00
|
|
|
gpsi->cHandleEntries--;
|
2005-09-08 05:25:42 +08:00
|
|
|
|
|
|
|
return ret;
|
2001-06-13 01:51:51 +08:00
|
|
|
}
|
|
|
|
|
2005-09-08 04:59:26 +08:00
|
|
|
/* allocate a user handle for a given object */
|
2014-09-22 01:44:40 +08:00
|
|
|
HANDLE UserAllocHandle(
|
|
|
|
_Inout_ PUSER_HANDLE_TABLE ht,
|
|
|
|
_In_ PVOID object,
|
|
|
|
_In_ HANDLE_TYPE type,
|
|
|
|
_In_ PVOID HandleOwner)
|
2001-06-13 01:51:51 +08:00
|
|
|
{
|
2005-09-08 05:25:42 +08:00
|
|
|
PUSER_HANDLE_ENTRY entry = alloc_user_entry(ht);
|
|
|
|
if (!entry)
|
|
|
|
return 0;
|
|
|
|
entry->ptr = object;
|
|
|
|
entry->type = type;
|
2010-01-14 21:33:04 +08:00
|
|
|
entry->flags = 0;
|
2014-09-22 01:44:40 +08:00
|
|
|
entry->pi = HandleOwner;
|
2005-09-08 05:25:42 +08:00
|
|
|
if (++entry->generation >= 0xffff)
|
|
|
|
entry->generation = 1;
|
2008-02-13 08:46:23 +08:00
|
|
|
|
|
|
|
/* We have created a handle, which is a reference! */
|
|
|
|
UserReferenceObject(object);
|
|
|
|
|
2005-09-08 05:25:42 +08:00
|
|
|
return entry_to_handle(ht, entry );
|
2001-06-13 01:51:51 +08:00
|
|
|
}
|
|
|
|
|
2012-08-13 15:16:01 +08:00
|
|
|
/* return a pointer to a user object from its handle without setting an error */
|
2012-12-30 03:14:30 +08:00
|
|
|
PVOID UserGetObjectNoErr(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type )
|
2012-08-13 15:16:01 +08:00
|
|
|
{
|
|
|
|
PUSER_HANDLE_ENTRY entry;
|
|
|
|
|
|
|
|
ASSERT(ht);
|
|
|
|
|
|
|
|
if (!(entry = handle_to_entry(ht, handle )) || entry->type != type)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return entry->ptr;
|
|
|
|
}
|
|
|
|
|
2005-09-08 04:59:26 +08:00
|
|
|
/* return a pointer to a user object from its handle */
|
2012-12-30 03:14:30 +08:00
|
|
|
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type )
|
2001-06-13 01:51:51 +08:00
|
|
|
{
|
2005-09-08 05:25:42 +08:00
|
|
|
PUSER_HANDLE_ENTRY entry;
|
2005-05-08 10:11:54 +08:00
|
|
|
|
2005-09-08 05:25:42 +08:00
|
|
|
ASSERT(ht);
|
2001-06-13 01:51:51 +08:00
|
|
|
|
2005-09-08 05:25:42 +08:00
|
|
|
if (!(entry = handle_to_entry(ht, handle )) || entry->type != type)
|
|
|
|
{
|
2010-12-25 19:01:14 +08:00
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
2005-09-08 05:25:42 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return entry->ptr;
|
2001-06-13 01:51:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-14 12:07:06 +08:00
|
|
|
/* Get the full handle (32bit) for a possibly truncated (16bit) handle */
|
2005-09-08 04:59:26 +08:00
|
|
|
HANDLE get_user_full_handle(PUSER_HANDLE_TABLE ht, HANDLE handle )
|
2001-06-13 01:51:51 +08:00
|
|
|
{
|
2005-09-08 05:25:42 +08:00
|
|
|
PUSER_HANDLE_ENTRY entry;
|
2001-06-13 01:51:51 +08:00
|
|
|
|
2018-03-18 22:53:52 +08:00
|
|
|
if ((ULONG_PTR)handle >> 16)
|
2005-09-08 05:25:42 +08:00
|
|
|
return handle;
|
|
|
|
if (!(entry = handle_to_entry(ht, handle )))
|
|
|
|
return handle;
|
|
|
|
return entry_to_handle( ht, entry );
|
2001-06-13 01:51:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-14 12:07:06 +08:00
|
|
|
/* Same as get_user_object plus set the handle to the full 32-bit value */
|
2012-12-30 03:14:30 +08:00
|
|
|
void *get_user_object_handle(PUSER_HANDLE_TABLE ht, HANDLE* handle, HANDLE_TYPE type )
|
2001-06-13 01:51:51 +08:00
|
|
|
{
|
2005-09-08 05:25:42 +08:00
|
|
|
PUSER_HANDLE_ENTRY entry;
|
2005-05-08 10:11:54 +08:00
|
|
|
|
2005-09-08 05:25:42 +08:00
|
|
|
if (!(entry = handle_to_entry(ht, *handle )) || entry->type != type)
|
|
|
|
return NULL;
|
|
|
|
*handle = entry_to_handle( ht, entry );
|
|
|
|
return entry->ptr;
|
2001-06-13 01:51:51 +08:00
|
|
|
}
|
|
|
|
|
2005-09-08 05:25:42 +08:00
|
|
|
|
2005-05-08 10:11:54 +08:00
|
|
|
|
2009-08-25 04:09:58 +08:00
|
|
|
BOOL FASTCALL UserCreateHandleTable(VOID)
|
2001-06-13 01:51:51 +08:00
|
|
|
{
|
2005-09-08 04:59:26 +08:00
|
|
|
PVOID mem;
|
2012-10-28 02:06:10 +08:00
|
|
|
INT HandleCount = 1024 * 4;
|
2005-09-08 04:59:26 +08:00
|
|
|
|
2011-12-14 12:07:06 +08:00
|
|
|
// FIXME: Don't alloc all at once! Must be mapped into umode also...
|
2012-10-28 02:06:10 +08:00
|
|
|
mem = UserHeapAlloc(sizeof(USER_HANDLE_ENTRY) * HandleCount);
|
2005-09-08 04:59:26 +08:00
|
|
|
if (!mem)
|
|
|
|
{
|
2011-08-21 20:38:52 +08:00
|
|
|
ERR("Failed creating handle table\n");
|
2005-09-08 04:59:26 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
2005-09-08 05:25:42 +08:00
|
|
|
|
2006-04-05 16:05:55 +08:00
|
|
|
gHandleTable = UserHeapAlloc(sizeof(USER_HANDLE_TABLE));
|
|
|
|
if (gHandleTable == NULL)
|
|
|
|
{
|
|
|
|
UserHeapFree(mem);
|
2011-08-21 20:38:52 +08:00
|
|
|
ERR("Failed creating handle table\n");
|
2006-04-05 16:05:55 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-12-14 12:07:06 +08:00
|
|
|
// FIXME: Make auto growable
|
2012-10-28 02:06:10 +08:00
|
|
|
UserInitHandleTable(gHandleTable, mem, sizeof(USER_HANDLE_ENTRY) * HandleCount);
|
2005-09-08 05:25:42 +08:00
|
|
|
|
2005-09-08 04:59:26 +08:00
|
|
|
return TRUE;
|
2001-06-13 01:51:51 +08:00
|
|
|
}
|
2010-01-14 21:33:04 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// New
|
|
|
|
//
|
|
|
|
PVOID
|
|
|
|
FASTCALL
|
2010-01-15 21:47:25 +08:00
|
|
|
UserCreateObject( PUSER_HANDLE_TABLE ht,
|
|
|
|
PDESKTOP pDesktop,
|
2012-10-28 18:34:41 +08:00
|
|
|
PTHREADINFO pti,
|
2010-01-15 21:47:25 +08:00
|
|
|
HANDLE* h,
|
2012-12-30 03:14:30 +08:00
|
|
|
HANDLE_TYPE type,
|
2010-01-15 21:47:25 +08:00
|
|
|
ULONG size)
|
2010-01-14 21:33:04 +08:00
|
|
|
{
|
|
|
|
HANDLE hi;
|
|
|
|
PVOID Object;
|
2014-09-22 01:44:40 +08:00
|
|
|
PVOID ObjectOwner;
|
2012-10-28 18:34:41 +08:00
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
/* Some sanity checks. Other checks will be made in the allocator */
|
|
|
|
ASSERT(type < TYPE_CTYPES);
|
|
|
|
ASSERT(type != TYPE_FREE);
|
|
|
|
ASSERT(ht != NULL);
|
2010-01-14 21:33:04 +08:00
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
/* Allocate the object */
|
|
|
|
ASSERT(ObjectCallbacks[type].ObjectAlloc != NULL);
|
|
|
|
Object = ObjectCallbacks[type].ObjectAlloc(pDesktop, pti, size, &ObjectOwner);
|
|
|
|
if (!Object)
|
2010-01-14 21:33:04 +08:00
|
|
|
{
|
2014-09-22 01:44:40 +08:00
|
|
|
ERR("User object allocation failed. Out of memory!\n");
|
|
|
|
return NULL;
|
2010-01-14 21:33:04 +08:00
|
|
|
}
|
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
hi = UserAllocHandle(ht, Object, type, ObjectOwner);
|
|
|
|
if (hi == NULL)
|
2010-01-14 21:33:04 +08:00
|
|
|
{
|
2014-09-22 01:44:40 +08:00
|
|
|
ERR("Out of user handles!\n");
|
|
|
|
ObjectCallbacks[type].ObjectFree(Object);
|
|
|
|
return NULL;
|
2010-01-14 21:33:04 +08:00
|
|
|
}
|
|
|
|
|
2012-10-28 00:39:18 +08:00
|
|
|
#if DBG
|
2014-09-22 01:44:40 +08:00
|
|
|
if (pti)
|
|
|
|
pti->ppi->DbgHandleCount[type]++;
|
2012-10-28 00:39:18 +08:00
|
|
|
#endif
|
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
/* Give this object its identity. */
|
2010-01-14 21:33:04 +08:00
|
|
|
((PHEAD)Object)->h = hi;
|
2014-09-22 01:44:40 +08:00
|
|
|
|
|
|
|
/* The caller will get a locked object.
|
|
|
|
* Note: with the reference from the handle, that makes two */
|
|
|
|
UserReferenceObject(Object);
|
2010-01-14 21:33:04 +08:00
|
|
|
|
|
|
|
if (h)
|
|
|
|
*h = hi;
|
|
|
|
return Object;
|
|
|
|
}
|
|
|
|
|
2016-09-29 00:51:53 +08:00
|
|
|
BOOL
|
|
|
|
FASTCALL
|
|
|
|
UserMarkObjectDestroy(PVOID Object)
|
|
|
|
{
|
|
|
|
PUSER_HANDLE_ENTRY entry;
|
|
|
|
PHEAD ObjHead = Object;
|
|
|
|
|
|
|
|
entry = handle_to_entry(gHandleTable, ObjHead->h);
|
|
|
|
|
|
|
|
ASSERT(entry != NULL);
|
|
|
|
|
|
|
|
entry->flags |= HANDLEENTRY_DESTROY;
|
|
|
|
|
|
|
|
if (ObjHead->cLockObj > 1)
|
|
|
|
{
|
|
|
|
entry->flags &= ~HANDLEENTRY_INDESTROY;
|
|
|
|
TRACE("Count %d\n",ObjHead->cLockObj);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2010-01-15 21:47:25 +08:00
|
|
|
|
2010-01-14 21:33:04 +08:00
|
|
|
BOOL
|
|
|
|
FASTCALL
|
2014-09-22 01:44:40 +08:00
|
|
|
UserDereferenceObject(PVOID Object)
|
2010-01-14 21:33:04 +08:00
|
|
|
{
|
2015-02-13 18:11:50 +08:00
|
|
|
PHEAD ObjHead = Object;
|
2010-01-14 21:33:04 +08:00
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
ASSERT(ObjHead->cLockObj >= 1);
|
2015-02-13 18:11:50 +08:00
|
|
|
ASSERT(ObjHead->cLockObj < 0x10000);
|
2010-01-16 13:56:22 +08:00
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
if (--ObjHead->cLockObj == 0)
|
|
|
|
{
|
|
|
|
PUSER_HANDLE_ENTRY entry;
|
|
|
|
HANDLE_TYPE type;
|
2010-01-14 21:33:04 +08:00
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
entry = handle_to_entry(gHandleTable, ObjHead->h);
|
2010-01-16 13:56:22 +08:00
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
ASSERT(entry != NULL);
|
|
|
|
/* The entry should be marked as in deletion */
|
|
|
|
ASSERT(entry->flags & HANDLEENTRY_INDESTROY);
|
2010-01-16 13:56:22 +08:00
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
type = entry->type;
|
|
|
|
ASSERT(type != TYPE_FREE);
|
|
|
|
ASSERT(type < TYPE_CTYPES);
|
|
|
|
|
|
|
|
/* We can now get rid of everything */
|
|
|
|
free_user_entry(gHandleTable, entry );
|
2010-01-14 21:33:04 +08:00
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
#if 0
|
|
|
|
/* Call the object destructor */
|
|
|
|
ASSERT(ObjectCallbacks[type].ObjectCleanup != NULL);
|
|
|
|
ObjectCallbacks[type].ObjectCleanup(Object);
|
|
|
|
#endif
|
2010-01-14 21:33:04 +08:00
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
/* And free it */
|
|
|
|
ASSERT(ObjectCallbacks[type].ObjectFree != NULL);
|
|
|
|
ObjectCallbacks[type].ObjectFree(Object);
|
2010-01-15 21:47:25 +08:00
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2010-01-14 21:33:04 +08:00
|
|
|
}
|
|
|
|
|
2010-01-16 13:56:22 +08:00
|
|
|
BOOL
|
|
|
|
FASTCALL
|
|
|
|
UserFreeHandle(PUSER_HANDLE_TABLE ht, HANDLE handle )
|
|
|
|
{
|
|
|
|
PUSER_HANDLE_ENTRY entry;
|
|
|
|
|
|
|
|
if (!(entry = handle_to_entry( ht, handle )))
|
|
|
|
{
|
|
|
|
SetLastNtError( STATUS_INVALID_HANDLE );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry->flags = HANDLEENTRY_INDESTROY;
|
|
|
|
|
|
|
|
return UserDereferenceObject(entry->ptr);
|
|
|
|
}
|
|
|
|
|
2012-06-02 11:34:04 +08:00
|
|
|
BOOL
|
|
|
|
FASTCALL
|
|
|
|
UserObjectInDestroy(HANDLE h)
|
|
|
|
{
|
|
|
|
PUSER_HANDLE_ENTRY entry;
|
|
|
|
|
|
|
|
if (!(entry = handle_to_entry( gHandleTable, h )))
|
|
|
|
{
|
|
|
|
SetLastNtError( STATUS_INVALID_HANDLE );
|
2013-05-12 03:26:18 +08:00
|
|
|
return TRUE;
|
2012-06-02 11:34:04 +08:00
|
|
|
}
|
|
|
|
return (entry->flags & HANDLEENTRY_INDESTROY);
|
|
|
|
}
|
|
|
|
|
2010-01-14 21:33:04 +08:00
|
|
|
BOOL
|
|
|
|
FASTCALL
|
2012-12-30 03:14:30 +08:00
|
|
|
UserDeleteObject(HANDLE h, HANDLE_TYPE type )
|
2010-01-14 21:33:04 +08:00
|
|
|
{
|
|
|
|
PVOID body = UserGetObject(gHandleTable, h, type);
|
2011-08-14 04:10:40 +08:00
|
|
|
|
2010-01-14 21:33:04 +08:00
|
|
|
if (!body) return FALSE;
|
|
|
|
|
|
|
|
ASSERT( ((PHEAD)body)->cLockObj >= 1);
|
2015-02-13 18:11:50 +08:00
|
|
|
ASSERT( ((PHEAD)body)->cLockObj < 0x10000);
|
2010-01-14 21:33:04 +08:00
|
|
|
|
2010-01-15 21:47:25 +08:00
|
|
|
return UserFreeHandle(gHandleTable, h);
|
2010-01-14 21:33:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
FASTCALL
|
2010-01-15 21:47:25 +08:00
|
|
|
UserReferenceObject(PVOID obj)
|
2010-01-14 21:33:04 +08:00
|
|
|
{
|
2015-02-13 18:11:50 +08:00
|
|
|
PHEAD ObjHead = obj;
|
|
|
|
ASSERT(ObjHead->cLockObj < 0x10000);
|
2010-01-14 21:33:04 +08:00
|
|
|
|
2015-02-13 18:11:50 +08:00
|
|
|
ObjHead->cLockObj++;
|
2010-01-14 21:33:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
PVOID
|
|
|
|
FASTCALL
|
2012-12-30 03:14:30 +08:00
|
|
|
UserReferenceObjectByHandle(HANDLE handle, HANDLE_TYPE type)
|
2010-01-14 21:33:04 +08:00
|
|
|
{
|
|
|
|
PVOID object;
|
|
|
|
|
|
|
|
object = UserGetObject(gHandleTable, handle, type);
|
|
|
|
if (object)
|
|
|
|
{
|
2010-01-15 21:47:25 +08:00
|
|
|
UserReferenceObject(object);
|
2010-01-14 21:33:04 +08:00
|
|
|
}
|
|
|
|
return object;
|
|
|
|
}
|
2011-08-27 20:38:23 +08:00
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
BOOLEAN
|
|
|
|
UserDestroyObjectsForOwner(PUSER_HANDLE_TABLE Table, PVOID Owner)
|
2013-10-20 13:16:52 +08:00
|
|
|
{
|
2014-09-22 01:44:40 +08:00
|
|
|
int i;
|
|
|
|
PUSER_HANDLE_ENTRY Entry;
|
|
|
|
BOOLEAN Ret = TRUE;
|
2014-03-14 10:39:18 +08:00
|
|
|
|
2014-09-22 01:44:40 +08:00
|
|
|
/* Sweep the whole handle table */
|
|
|
|
for (i = 0; i < Table->allocated_handles; i++)
|
|
|
|
{
|
|
|
|
Entry = &Table->handles[i];
|
|
|
|
|
|
|
|
if (Entry->pi != Owner)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Do not destroy if it's already been done */
|
|
|
|
if (Entry->flags & HANDLEENTRY_INDESTROY)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Call destructor */
|
|
|
|
if (!ObjectCallbacks[Entry->type].ObjectDestroy(Entry->ptr))
|
|
|
|
{
|
|
|
|
ERR("Failed destructing object %p, type %u.\n", Entry->ptr, Entry->type);
|
|
|
|
/* Don't return immediately, we must continue destroying the other objects */
|
|
|
|
Ret = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ret;
|
2014-03-14 10:39:18 +08:00
|
|
|
}
|
2015-03-02 01:36:12 +08:00
|
|
|
|
2011-08-27 20:38:23 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Status
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtUserValidateHandleSecure(
|
2015-09-09 21:49:39 +08:00
|
|
|
HANDLE handle)
|
2011-08-27 20:38:23 +08:00
|
|
|
{
|
2014-04-28 11:55:23 +08:00
|
|
|
UINT uType;
|
|
|
|
PPROCESSINFO ppi;
|
|
|
|
PUSER_HANDLE_ENTRY entry;
|
|
|
|
|
|
|
|
DECLARE_RETURN(BOOL);
|
|
|
|
UserEnterExclusive();
|
|
|
|
|
|
|
|
if (!(entry = handle_to_entry(gHandleTable, handle )))
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
RETURN( FALSE);
|
|
|
|
}
|
|
|
|
uType = entry->type;
|
|
|
|
switch (uType)
|
2011-08-27 20:38:23 +08:00
|
|
|
{
|
2012-12-30 03:14:30 +08:00
|
|
|
case TYPE_WINDOW:
|
2014-04-28 11:55:23 +08:00
|
|
|
case TYPE_INPUTCONTEXT:
|
|
|
|
ppi = ((PTHREADINFO)entry->pi)->ppi;
|
|
|
|
break;
|
2012-12-30 03:14:30 +08:00
|
|
|
case TYPE_MENU:
|
|
|
|
case TYPE_ACCELTABLE:
|
|
|
|
case TYPE_CURSOR:
|
|
|
|
case TYPE_HOOK:
|
|
|
|
case TYPE_CALLPROC:
|
2014-04-28 11:55:23 +08:00
|
|
|
case TYPE_SETWINDOWPOS:
|
|
|
|
ppi = entry->pi;
|
|
|
|
break;
|
2011-08-27 20:38:23 +08:00
|
|
|
default:
|
2014-04-28 11:55:23 +08:00
|
|
|
ppi = NULL;
|
|
|
|
break;
|
2011-08-27 20:38:23 +08:00
|
|
|
}
|
2014-04-28 11:55:23 +08:00
|
|
|
|
|
|
|
if (!ppi) RETURN( FALSE);
|
|
|
|
|
|
|
|
// Same process job returns TRUE.
|
|
|
|
if (gptiCurrent->ppi->pW32Job == ppi->pW32Job) RETURN( TRUE);
|
|
|
|
|
|
|
|
RETURN( FALSE);
|
|
|
|
|
|
|
|
CLEANUP:
|
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
2011-08-27 20:38:23 +08:00
|
|
|
}
|