Author: jimtabor
Date: Mon Aug 6 03:13:27 2012
New Revision: 57045
URL:
http://svn.reactos.org/svn/reactos?rev=57045&view=rev
Log:
[NtUser]
- Fixed crash, see bug 7226.
- AttachThreadInput is new to ReactOS, it passes the wine tests, help is needed, white
papers are welcome.
Modified:
trunk/reactos/win32ss/user/ntuser/input.c
trunk/reactos/win32ss/user/ntuser/input.h
trunk/reactos/win32ss/user/ntuser/main.c
Modified: trunk/reactos/win32ss/user/ntuser/input.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/input.…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/input.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/input.c [iso-8859-1] Mon Aug 6 03:13:27 2012
@@ -394,6 +394,26 @@
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
UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
{
@@ -419,7 +439,7 @@
pai->pti1 = ptiFrom;
pai->pti2 = ptiTo;
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;
ptiFrom->pqAttach = ptiFrom->MessageQueue;
@@ -457,7 +477,7 @@
if (paiprev) paiprev->paiNext = pai->paiNext;
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;
// FIXME: conditions?
Modified: trunk/reactos/win32ss/user/ntuser/input.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/input.…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/input.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/input.h [iso-8859-1] Mon Aug 6 03:13:27 2012
@@ -63,6 +63,7 @@
BOOL FASTCALL IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt);
DWORD NTAPI CreateSystemThreads(UINT Type);
BOOL FASTCALL UserAttachThreadInput(PTHREADINFO,PTHREADINFO,BOOL);
+PTHREADINFO FASTCALL IsThreadAttach(PTHREADINFO);
VOID FASTCALL DoTheScreenSaver(VOID);
#define ThreadHasInputAccess(W32Thread) (TRUE)
Modified: trunk/reactos/win32ss/user/ntuser/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/main.c…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/main.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/main.c [iso-8859-1] Mon Aug 6 03:13:27 2012
@@ -247,6 +247,8 @@
return STATUS_NO_MEMORY;
}
+ TRACE_CH(UserThread,"Create pti 0x%p eThread 0x%p\n", ptiCurrent, Thread);
+
RtlZeroMemory(ptiCurrent, sizeof(THREADINFO));
PsSetThreadWin32Thread(Thread, ptiCurrent);
@@ -391,7 +393,7 @@
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->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
@@ -470,11 +472,20 @@
}
}
+ // 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)
{
PTHREADINFO ptiTo;
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);
}