mirror of
https://github.com/reactos/reactos.git
synced 2024-11-19 13:33:42 +00:00
[NtUser]
- Fixed crash, see bug 7226. - AttachThreadInput is new to ReactOS, it passes the wine tests, help is needed, white papers are welcome. svn path=/trunk/; revision=57045
This commit is contained in:
parent
a69cee87a7
commit
a90234288c
3 changed files with 36 additions and 4 deletions
|
@ -394,6 +394,26 @@ NtUserBlockInput(
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PTHREADINFO FASTCALL
|
||||||
|
IsThreadAttach(PTHREADINFO ptiTo)
|
||||||
|
{
|
||||||
|
PATTACHINFO pai;
|
||||||
|
|
||||||
|
if (!gpai) return NULL;
|
||||||
|
|
||||||
|
pai = gpai;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (pai->pti2 == ptiTo) break;
|
||||||
|
pai = pai->paiNext;
|
||||||
|
} while (pai);
|
||||||
|
|
||||||
|
if (!pai) return NULL;
|
||||||
|
|
||||||
|
// Return ptiFrom.
|
||||||
|
return pai->pti1;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL FASTCALL
|
BOOL FASTCALL
|
||||||
UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
|
UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
|
||||||
{
|
{
|
||||||
|
@ -419,7 +439,7 @@ UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
|
||||||
pai->pti1 = ptiFrom;
|
pai->pti1 = ptiFrom;
|
||||||
pai->pti2 = ptiTo;
|
pai->pti2 = ptiTo;
|
||||||
gpai = pai;
|
gpai = pai;
|
||||||
TRACE("Attach Allocated! ptiFrom 0x%p ptiTo 0x%p\n",ptiFrom,ptiTo);
|
ERR("Attach Allocated! ptiFrom 0x%p ptiTo 0x%p\n",ptiFrom,ptiTo);
|
||||||
|
|
||||||
ptiTo->MessageQueue->iCursorLevel -= ptiFrom->iCursorLevel;
|
ptiTo->MessageQueue->iCursorLevel -= ptiFrom->iCursorLevel;
|
||||||
ptiFrom->pqAttach = ptiFrom->MessageQueue;
|
ptiFrom->pqAttach = ptiFrom->MessageQueue;
|
||||||
|
@ -457,7 +477,7 @@ UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
|
||||||
if (paiprev) paiprev->paiNext = pai->paiNext;
|
if (paiprev) paiprev->paiNext = pai->paiNext;
|
||||||
|
|
||||||
ExFreePoolWithTag(pai, USERTAG_ATTACHINFO);
|
ExFreePoolWithTag(pai, USERTAG_ATTACHINFO);
|
||||||
TRACE("Attach Free! ptiFrom 0x%p ptiTo 0x%p\n",ptiFrom,ptiTo);
|
ERR("Attach Free! ptiFrom 0x%p ptiTo 0x%p\n",ptiFrom,ptiTo);
|
||||||
|
|
||||||
ptiFrom->MessageQueue = ptiFrom->pqAttach;
|
ptiFrom->MessageQueue = ptiFrom->pqAttach;
|
||||||
// FIXME: conditions?
|
// FIXME: conditions?
|
||||||
|
|
|
@ -63,6 +63,7 @@ INIT_FUNCTION NTSTATUS NTAPI InitInputImpl(VOID);
|
||||||
BOOL FASTCALL IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt);
|
BOOL FASTCALL IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt);
|
||||||
DWORD NTAPI CreateSystemThreads(UINT Type);
|
DWORD NTAPI CreateSystemThreads(UINT Type);
|
||||||
BOOL FASTCALL UserAttachThreadInput(PTHREADINFO,PTHREADINFO,BOOL);
|
BOOL FASTCALL UserAttachThreadInput(PTHREADINFO,PTHREADINFO,BOOL);
|
||||||
|
PTHREADINFO FASTCALL IsThreadAttach(PTHREADINFO);
|
||||||
VOID FASTCALL DoTheScreenSaver(VOID);
|
VOID FASTCALL DoTheScreenSaver(VOID);
|
||||||
#define ThreadHasInputAccess(W32Thread) (TRUE)
|
#define ThreadHasInputAccess(W32Thread) (TRUE)
|
||||||
|
|
||||||
|
|
|
@ -247,6 +247,8 @@ UserCreateThreadInfo(struct _ETHREAD *Thread)
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACE_CH(UserThread,"Create pti 0x%p eThread 0x%p\n", ptiCurrent, Thread);
|
||||||
|
|
||||||
RtlZeroMemory(ptiCurrent, sizeof(THREADINFO));
|
RtlZeroMemory(ptiCurrent, sizeof(THREADINFO));
|
||||||
|
|
||||||
PsSetThreadWin32Thread(Thread, ptiCurrent);
|
PsSetThreadWin32Thread(Thread, ptiCurrent);
|
||||||
|
@ -391,7 +393,7 @@ UserDestroyThreadInfo(struct _ETHREAD *Thread)
|
||||||
|
|
||||||
ASSERT(ptiCurrent);
|
ASSERT(ptiCurrent);
|
||||||
|
|
||||||
TRACE_CH(UserThread,"Destroying pti 0x%p\n", ptiCurrent);
|
TRACE_CH(UserThread,"Destroying pti 0x%p eThread 0x%p\n", ptiCurrent, Thread);
|
||||||
|
|
||||||
ptiCurrent->TIF_flags |= TIF_INCLEANUP;
|
ptiCurrent->TIF_flags |= TIF_INCLEANUP;
|
||||||
ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
|
ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
|
||||||
|
@ -470,11 +472,20 @@ UserDestroyThreadInfo(struct _ETHREAD *Thread)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ptiTo
|
||||||
|
if (IsThreadAttach(ptiCurrent))
|
||||||
|
{
|
||||||
|
PTHREADINFO ptiFrom = IsThreadAttach(ptiCurrent);
|
||||||
|
TRACE_CH(UserThread,"Attached Thread ptiTo is getting switched!\n");
|
||||||
|
UserAttachThreadInput(ptiFrom, ptiCurrent, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ptiFrom
|
||||||
if (ptiCurrent->pqAttach && ptiCurrent->MessageQueue)
|
if (ptiCurrent->pqAttach && ptiCurrent->MessageQueue)
|
||||||
{
|
{
|
||||||
PTHREADINFO ptiTo;
|
PTHREADINFO ptiTo;
|
||||||
ptiTo = PsGetThreadWin32Thread(ptiCurrent->MessageQueue->Thread);
|
ptiTo = PsGetThreadWin32Thread(ptiCurrent->MessageQueue->Thread);
|
||||||
TRACE_CH(UserThread,"Attached Thread is getting switched!\n");
|
TRACE_CH(UserThread,"Attached Thread ptiFrom is getting switched!\n");
|
||||||
UserAttachThreadInput( ptiCurrent, ptiTo, FALSE);
|
UserAttachThreadInput( ptiCurrent, ptiTo, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue