ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
May 2016
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
18 participants
260 discussions
Start a n
N
ew thread
[tfaber] 71240: [WIN32K:NTUSER] - Desktops should keep a reference to their parent window station CORE-11124
by tfaber@svn.reactos.org
Author: tfaber Date: Tue May 3 12:50:35 2016 New Revision: 71240 URL:
http://svn.reactos.org/svn/reactos?rev=71240&view=rev
Log: [WIN32K:NTUSER] - Desktops should keep a reference to their parent window station CORE-11124 Modified: trunk/reactos/win32ss/user/ntuser/desktop.c Modified: trunk/reactos/win32ss/user/ntuser/desktop.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/deskto…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] Tue May 3 12:50:35 2016 @@ -166,6 +166,9 @@ /* Free the heap */ IntFreeDesktopHeap(pdesk); + + ObDereferenceObject(pdesk->rpwinstaParent); + return STATUS_SUCCESS; } @@ -1217,6 +1220,7 @@ RtlZeroMemory(pdesk, sizeof(DESKTOP)); /* Link the desktop with the parent window station */ + ObReferenceObject(pwinsta); pdesk->rpwinstaParent = pwinsta; InsertTailList(&pwinsta->DesktopListHead, &pdesk->ListEntry);
8 years, 7 months
1
0
0
0
[tfaber] 71239: [WIN32K:NTUSER] - In IntDesktopObjectDelete, correctly handle the case where pDeskInfo could not be allocated CORE-11124
by tfaber@svn.reactos.org
Author: tfaber Date: Tue May 3 12:38:41 2016 New Revision: 71239 URL:
http://svn.reactos.org/svn/reactos?rev=71239&view=rev
Log: [WIN32K:NTUSER] - In IntDesktopObjectDelete, correctly handle the case where pDeskInfo could not be allocated CORE-11124 Modified: trunk/reactos/win32ss/user/ntuser/desktop.c Modified: trunk/reactos/win32ss/user/ntuser/desktop.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/deskto…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] Tue May 3 12:38:41 2016 @@ -151,10 +151,12 @@ TRACE("Deleting desktop object 0x%p\n", pdesk); - ASSERT(pdesk->pDeskInfo->spwnd->spwndChild == NULL); - - if (pdesk->pDeskInfo->spwnd) + if (pdesk->pDeskInfo && + pdesk->pDeskInfo->spwnd) + { + ASSERT(pdesk->pDeskInfo->spwnd->spwndChild == NULL); co_UserDestroyWindow(pdesk->pDeskInfo->spwnd); + } if (pdesk->spwndMessage) co_UserDestroyWindow(pdesk->spwndMessage);
8 years, 7 months
1
0
0
0
[tfaber] 71238: [WIN32K:NTUSER] - Fix indentation. No functional changes.
by tfaber@svn.reactos.org
Author: tfaber Date: Tue May 3 12:24:28 2016 New Revision: 71238 URL:
http://svn.reactos.org/svn/reactos?rev=71238&view=rev
Log: [WIN32K:NTUSER] - Fix indentation. No functional changes. Modified: trunk/reactos/win32ss/user/ntuser/desktop.c Modified: trunk/reactos/win32ss/user/ntuser/desktop.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/deskto…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] Tue May 3 12:24:28 2016 @@ -147,24 +147,24 @@ _In_ PVOID Parameters) { PWIN32_DELETEMETHOD_PARAMETERS DeleteParameters = Parameters; - PDESKTOP pdesk = (PDESKTOP)DeleteParameters->Object; - - TRACE("Deleting desktop object 0x%p\n", pdesk); - - ASSERT(pdesk->pDeskInfo->spwnd->spwndChild == NULL); - - if (pdesk->pDeskInfo->spwnd) - co_UserDestroyWindow(pdesk->pDeskInfo->spwnd); - - if (pdesk->spwndMessage) - co_UserDestroyWindow(pdesk->spwndMessage); - - /* Remove the desktop from the window station's list of associcated desktops */ - RemoveEntryList(&pdesk->ListEntry); - - /* Free the heap */ - IntFreeDesktopHeap(pdesk); - return STATUS_SUCCESS; + PDESKTOP pdesk = (PDESKTOP)DeleteParameters->Object; + + TRACE("Deleting desktop object 0x%p\n", pdesk); + + ASSERT(pdesk->pDeskInfo->spwnd->spwndChild == NULL); + + if (pdesk->pDeskInfo->spwnd) + co_UserDestroyWindow(pdesk->pDeskInfo->spwnd); + + if (pdesk->spwndMessage) + co_UserDestroyWindow(pdesk->spwndMessage); + + /* Remove the desktop from the window station's list of associcated desktops */ + RemoveEntryList(&pdesk->ListEntry); + + /* Free the heap */ + IntFreeDesktopHeap(pdesk); + return STATUS_SUCCESS; } NTSTATUS @@ -215,7 +215,7 @@ { /* This happens when the process leaks desktop handles. * At this point the PPROCESSINFO is already destroyed */ - return STATUS_SUCCESS; + return STATUS_SUCCESS; } return IntUnmapDesktopView((PDESKTOP)CloseParameters->Object); @@ -265,7 +265,7 @@ len = swprintf(buffer, L"ReactOS Version %S %S", KERNEL_VERSION_STR, KERNEL_VERSION_BUILD_STR); #endif - return len; + return len; } @@ -275,133 +275,133 @@ HWINSTA *hWinSta, HDESK *hDesktop) { - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING ObjectName; - NTSTATUS Status; - WCHAR wstrWinstaFullName[MAX_PATH], *pwstrWinsta = NULL, *pwstrDesktop = NULL; - - ASSERT(hWinSta); - ASSERT(hDesktop); - ASSERT(DesktopPath); - - *hWinSta = NULL; - *hDesktop = NULL; - - if(DesktopPath->Buffer != NULL && DesktopPath->Length > sizeof(WCHAR)) - { - /* - * Parse the desktop path string which can be in the form "WinSta\Desktop" - * or just "Desktop". In latter case WinSta0 will be used. - */ - - pwstrDesktop = wcschr(DesktopPath->Buffer, L'\\'); - if(pwstrDesktop != NULL) - { - *pwstrDesktop = 0; - pwstrDesktop++; - pwstrWinsta = DesktopPath->Buffer; - } - else - { - pwstrDesktop = DesktopPath->Buffer; - pwstrWinsta = NULL; - } - - TRACE("IntParseDesktopPath pwstrWinsta:%S pwstrDesktop:%S\n", pwstrWinsta, pwstrDesktop); - } + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING ObjectName; + NTSTATUS Status; + WCHAR wstrWinstaFullName[MAX_PATH], *pwstrWinsta = NULL, *pwstrDesktop = NULL; + + ASSERT(hWinSta); + ASSERT(hDesktop); + ASSERT(DesktopPath); + + *hWinSta = NULL; + *hDesktop = NULL; + + if(DesktopPath->Buffer != NULL && DesktopPath->Length > sizeof(WCHAR)) + { + /* + * Parse the desktop path string which can be in the form "WinSta\Desktop" + * or just "Desktop". In latter case WinSta0 will be used. + */ + + pwstrDesktop = wcschr(DesktopPath->Buffer, L'\\'); + if(pwstrDesktop != NULL) + { + *pwstrDesktop = 0; + pwstrDesktop++; + pwstrWinsta = DesktopPath->Buffer; + } + else + { + pwstrDesktop = DesktopPath->Buffer; + pwstrWinsta = NULL; + } + + TRACE("IntParseDesktopPath pwstrWinsta:%S pwstrDesktop:%S\n", pwstrWinsta, pwstrDesktop); + } #if 0 - /* Search the process handle table for (inherited) window station - handles, use a more appropriate one than WinSta0 if possible. */ - if (!ObFindHandleForObject(Process, - NULL, - ExWindowStationObjectType, - NULL, - (PHANDLE)hWinSta)) + /* Search the process handle table for (inherited) window station + handles, use a more appropriate one than WinSta0 if possible. */ + if (!ObFindHandleForObject(Process, + NULL, + ExWindowStationObjectType, + NULL, + (PHANDLE)hWinSta)) #endif - { - /* We had no luck searching for opened handles, use WinSta0 now */ - if(!pwstrWinsta) - pwstrWinsta = L"WinSta0"; - } + { + /* We had no luck searching for opened handles, use WinSta0 now */ + if(!pwstrWinsta) + pwstrWinsta = L"WinSta0"; + } #if 0 - /* Search the process handle table for (inherited) desktop - handles, use a more appropriate one than Default if possible. */ - if (!ObFindHandleForObject(Process, - NULL, - ExDesktopObjectType, - NULL, - (PHANDLE)hDesktop)) + /* Search the process handle table for (inherited) desktop + handles, use a more appropriate one than Default if possible. */ + if (!ObFindHandleForObject(Process, + NULL, + ExDesktopObjectType, + NULL, + (PHANDLE)hDesktop)) #endif - { - /* We had no luck searching for opened handles, use Desktop now */ - if(!pwstrDesktop) - pwstrDesktop = L"Default"; - } - - if(*hWinSta == NULL) - { - swprintf(wstrWinstaFullName, L"%wZ\\%ws", &gustrWindowStationsDir, pwstrWinsta); - RtlInitUnicodeString( &ObjectName, wstrWinstaFullName); - - TRACE("parsed initial winsta: %wZ\n", &ObjectName); - - /* Open the window station */ - InitializeObjectAttributes(&ObjectAttributes, - &ObjectName, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - - Status = ObOpenObjectByName(&ObjectAttributes, - ExWindowStationObjectType, - KernelMode, - NULL, - WINSTA_ACCESS_ALL, - NULL, - (HANDLE*)hWinSta); - - if(!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - ERR("Failed to reference window station %wZ PID: --!\n", &ObjectName ); - return Status; - } - } - - if(*hDesktop == NULL) - { - RtlInitUnicodeString(&ObjectName, pwstrDesktop); - - TRACE("parsed initial desktop: %wZ\n", &ObjectName); - - /* Open the desktop object */ - InitializeObjectAttributes(&ObjectAttributes, - &ObjectName, - OBJ_CASE_INSENSITIVE, - *hWinSta, - NULL); - - Status = ObOpenObjectByName(&ObjectAttributes, - ExDesktopObjectType, - KernelMode, - NULL, - DESKTOP_ALL_ACCESS, - NULL, - (HANDLE*)hDesktop); - - if(!NT_SUCCESS(Status)) - { - *hDesktop = NULL; - NtClose(*hWinSta); - *hWinSta = NULL; - SetLastNtError(Status); - ERR("Failed to reference desktop %wZ PID: --!\n", &ObjectName); - return Status; - } - } - return STATUS_SUCCESS; + { + /* We had no luck searching for opened handles, use Desktop now */ + if(!pwstrDesktop) + pwstrDesktop = L"Default"; + } + + if(*hWinSta == NULL) + { + swprintf(wstrWinstaFullName, L"%wZ\\%ws", &gustrWindowStationsDir, pwstrWinsta); + RtlInitUnicodeString( &ObjectName, wstrWinstaFullName); + + TRACE("parsed initial winsta: %wZ\n", &ObjectName); + + /* Open the window station */ + InitializeObjectAttributes(&ObjectAttributes, + &ObjectName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + + Status = ObOpenObjectByName(&ObjectAttributes, + ExWindowStationObjectType, + KernelMode, + NULL, + WINSTA_ACCESS_ALL, + NULL, + (HANDLE*)hWinSta); + + if(!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + ERR("Failed to reference window station %wZ PID: --!\n", &ObjectName ); + return Status; + } + } + + if(*hDesktop == NULL) + { + RtlInitUnicodeString(&ObjectName, pwstrDesktop); + + TRACE("parsed initial desktop: %wZ\n", &ObjectName); + + /* Open the desktop object */ + InitializeObjectAttributes(&ObjectAttributes, + &ObjectName, + OBJ_CASE_INSENSITIVE, + *hWinSta, + NULL); + + Status = ObOpenObjectByName(&ObjectAttributes, + ExDesktopObjectType, + KernelMode, + NULL, + DESKTOP_ALL_ACCESS, + NULL, + (HANDLE*)hDesktop); + + if(!NT_SUCCESS(Status)) + { + *hDesktop = NULL; + NtClose(*hWinSta); + *hWinSta = NULL; + SetLastNtError(Status); + ERR("Failed to reference desktop %wZ PID: --!\n", &ObjectName); + return Status; + } + } + return STATUS_SUCCESS; } /* @@ -416,34 +416,34 @@ NTSTATUS FASTCALL IntValidateDesktopHandle( - HDESK Desktop, - KPROCESSOR_MODE AccessMode, - ACCESS_MASK DesiredAccess, - PDESKTOP *Object) -{ - NTSTATUS Status; - - Status = ObReferenceObjectByHandle( - Desktop, - DesiredAccess, - ExDesktopObjectType, - AccessMode, - (PVOID*)Object, - NULL); - - TRACE("IntValidateDesktopHandle: handle:0x%p obj:0x%p access:0x%x Status:0x%lx\n", - Desktop, *Object, DesiredAccess, Status); - - if (!NT_SUCCESS(Status)) - SetLastNtError(Status); - - return Status; + HDESK Desktop, + KPROCESSOR_MODE AccessMode, + ACCESS_MASK DesiredAccess, + PDESKTOP *Object) +{ + NTSTATUS Status; + + Status = ObReferenceObjectByHandle( + Desktop, + DesiredAccess, + ExDesktopObjectType, + AccessMode, + (PVOID*)Object, + NULL); + + TRACE("IntValidateDesktopHandle: handle:0x%p obj:0x%p access:0x%x Status:0x%lx\n", + Desktop, *Object, DesiredAccess, Status); + + if (!NT_SUCCESS(Status)) + SetLastNtError(Status); + + return Status; } PDESKTOP FASTCALL IntGetActiveDesktop(VOID) { - return gpdeskInputDesktop; + return gpdeskInputDesktop; } /* @@ -452,165 +452,165 @@ HDESK FASTCALL IntGetDesktopObjectHandle(PDESKTOP DesktopObject) { - NTSTATUS Status; - HDESK Ret; - - ASSERT(DesktopObject); - - if (!ObFindHandleForObject(PsGetCurrentProcess(), - DesktopObject, - ExDesktopObjectType, - NULL, - (PHANDLE)&Ret)) - { - Status = ObOpenObjectByPointer(DesktopObject, - 0, - NULL, - 0, - ExDesktopObjectType, - UserMode, - (PHANDLE)&Ret); - if(!NT_SUCCESS(Status)) - { - /* Unable to create a handle */ - ERR("Unable to create a desktop handle\n"); - return NULL; - } - } - else - { - TRACE("Got handle: %p\n", Ret); - } - - return Ret; + NTSTATUS Status; + HDESK Ret; + + ASSERT(DesktopObject); + + if (!ObFindHandleForObject(PsGetCurrentProcess(), + DesktopObject, + ExDesktopObjectType, + NULL, + (PHANDLE)&Ret)) + { + Status = ObOpenObjectByPointer(DesktopObject, + 0, + NULL, + 0, + ExDesktopObjectType, + UserMode, + (PHANDLE)&Ret); + if(!NT_SUCCESS(Status)) + { + /* Unable to create a handle */ + ERR("Unable to create a desktop handle\n"); + return NULL; + } + } + else + { + TRACE("Got handle: %p\n", Ret); + } + + return Ret; } PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID) { - PDESKTOP pdo = IntGetActiveDesktop(); - if (!pdo) - { - TRACE("No active desktop\n"); - return(NULL); - } - return (PUSER_MESSAGE_QUEUE)pdo->ActiveMessageQueue; + PDESKTOP pdo = IntGetActiveDesktop(); + if (!pdo) + { + TRACE("No active desktop\n"); + return(NULL); + } + return (PUSER_MESSAGE_QUEUE)pdo->ActiveMessageQueue; } VOID FASTCALL IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue) { - PUSER_MESSAGE_QUEUE Old; - PDESKTOP pdo = IntGetActiveDesktop(); - if (!pdo) - { - TRACE("No active desktop\n"); - return; - } - if(NewQueue != NULL) - { - if(NewQueue->Desktop != NULL) - { - TRACE("Message Queue already attached to another desktop!\n"); - return; - } - IntReferenceMessageQueue(NewQueue); - (void)InterlockedExchangePointer((PVOID*)&NewQueue->Desktop, pdo); - } - Old = (PUSER_MESSAGE_QUEUE)InterlockedExchangePointer((PVOID*)&pdo->ActiveMessageQueue, NewQueue); - if(Old != NULL) - { - (void)InterlockedExchangePointer((PVOID*)&Old->Desktop, 0); - gpqForegroundPrev = Old; - IntDereferenceMessageQueue(Old); - } - // Only one Q can have active foreground even when there are more than one desktop. - if (NewQueue) - { - gpqForeground = pdo->ActiveMessageQueue; - } - else - { - gpqForeground = NULL; - ERR("ptiLastInput is CLEARED!!\n"); - ptiLastInput = NULL; // ReactOS hacks,,,, should check for process death. - } + PUSER_MESSAGE_QUEUE Old; + PDESKTOP pdo = IntGetActiveDesktop(); + if (!pdo) + { + TRACE("No active desktop\n"); + return; + } + if(NewQueue != NULL) + { + if(NewQueue->Desktop != NULL) + { + TRACE("Message Queue already attached to another desktop!\n"); + return; + } + IntReferenceMessageQueue(NewQueue); + (void)InterlockedExchangePointer((PVOID*)&NewQueue->Desktop, pdo); + } + Old = (PUSER_MESSAGE_QUEUE)InterlockedExchangePointer((PVOID*)&pdo->ActiveMessageQueue, NewQueue); + if(Old != NULL) + { + (void)InterlockedExchangePointer((PVOID*)&Old->Desktop, 0); + gpqForegroundPrev = Old; + IntDereferenceMessageQueue(Old); + } + // Only one Q can have active foreground even when there are more than one desktop. + if (NewQueue) + { + gpqForeground = pdo->ActiveMessageQueue; + } + else + { + gpqForeground = NULL; + ERR("ptiLastInput is CLEARED!!\n"); + ptiLastInput = NULL; // ReactOS hacks,,,, should check for process death. + } } PWND FASTCALL IntGetThreadDesktopWindow(PTHREADINFO pti) { - if (!pti) pti = PsGetCurrentThreadWin32Thread(); - if (pti->pDeskInfo) return pti->pDeskInfo->spwnd; - return NULL; + if (!pti) pti = PsGetCurrentThreadWin32Thread(); + if (pti->pDeskInfo) return pti->pDeskInfo->spwnd; + return NULL; } PWND FASTCALL co_GetDesktopWindow(PWND pWnd) { - if (pWnd->head.rpdesk && - pWnd->head.rpdesk->pDeskInfo) - return pWnd->head.rpdesk->pDeskInfo->spwnd; - return NULL; + if (pWnd->head.rpdesk && + pWnd->head.rpdesk->pDeskInfo) + return pWnd->head.rpdesk->pDeskInfo->spwnd; + return NULL; } HWND FASTCALL IntGetDesktopWindow(VOID) { - PDESKTOP pdo = IntGetActiveDesktop(); - if (!pdo) - { - TRACE("No active desktop\n"); - return NULL; - } - return pdo->DesktopWindow; + PDESKTOP pdo = IntGetActiveDesktop(); + if (!pdo) + { + TRACE("No active desktop\n"); + return NULL; + } + return pdo->DesktopWindow; } PWND FASTCALL UserGetDesktopWindow(VOID) { - PDESKTOP pdo = IntGetActiveDesktop(); - - if (!pdo) - { - TRACE("No active desktop\n"); - return NULL; - } - // return pdo->pDeskInfo->spwnd; - return UserGetWindowObject(pdo->DesktopWindow); + PDESKTOP pdo = IntGetActiveDesktop(); + + if (!pdo) + { + TRACE("No active desktop\n"); + return NULL; + } + // return pdo->pDeskInfo->spwnd; + return UserGetWindowObject(pdo->DesktopWindow); } HWND FASTCALL IntGetMessageWindow(VOID) { - PDESKTOP pdo = IntGetActiveDesktop(); - - if (!pdo) - { - TRACE("No active desktop\n"); - return NULL; - } - return pdo->spwndMessage->head.h; + PDESKTOP pdo = IntGetActiveDesktop(); + + if (!pdo) + { + TRACE("No active desktop\n"); + return NULL; + } + return pdo->spwndMessage->head.h; } PWND FASTCALL UserGetMessageWindow(VOID) { - PDESKTOP pdo = IntGetActiveDesktop(); - - if (!pdo) - { - TRACE("No active desktop\n"); - return NULL; - } - return pdo->spwndMessage; + PDESKTOP pdo = IntGetActiveDesktop(); + + if (!pdo) + { + TRACE("No active desktop\n"); + return NULL; + } + return pdo->spwndMessage; } HWND FASTCALL IntGetCurrentThreadDesktopWindow(VOID) { - PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); - PDESKTOP pdo = pti->rpdesk; - if (NULL == pdo) - { - ERR("Thread doesn't have a desktop\n"); - return NULL; - } - return pdo->DesktopWindow; + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PDESKTOP pdo = pti->rpdesk; + if (NULL == pdo) + { + ERR("Thread doesn't have a desktop\n"); + return NULL; + } + return pdo->DesktopWindow; } /* PUBLIC FUNCTIONS ***********************************************************/ @@ -618,87 +618,87 @@ BOOL FASTCALL DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult) { - PAINTSTRUCT Ps; - ULONG Value; - //ERR("DesktopWindowProc\n"); - - *lResult = 0; - - switch (Msg) - { - case WM_NCCREATE: - if (!Wnd->fnid) - { - Wnd->fnid = FNID_DESKTOP; - } - *lResult = (LRESULT)TRUE; - return TRUE; - - case WM_CREATE: - Value = HandleToULong(PsGetCurrentProcessId()); - // Save Process ID - co_UserSetWindowLong(UserHMGetHandle(Wnd), DT_GWL_PROCESSID, Value, FALSE); - Value = HandleToULong(PsGetCurrentThreadId()); - // Save Thread ID - co_UserSetWindowLong(UserHMGetHandle(Wnd), DT_GWL_THREADID, Value, FALSE); - case WM_CLOSE: - return TRUE; - - case WM_DISPLAYCHANGE: - co_WinPosSetWindowPos(Wnd, 0, 0, 0, LOWORD(lParam), HIWORD(lParam), SWP_NOZORDER | SWP_NOACTIVATE); - return TRUE; - - case WM_ERASEBKGND: - IntPaintDesktop((HDC)wParam); - *lResult = 1; - return TRUE; - - case WM_PAINT: - { - if (IntBeginPaint(Wnd, &Ps)) - { - IntEndPaint(Wnd, &Ps); - } - return TRUE; - } - case WM_SYSCOLORCHANGE: - co_UserRedrawWindow(Wnd, NULL, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); - return TRUE; - - case WM_SETCURSOR: - { - PCURICON_OBJECT pcurOld, pcurNew; - pcurNew = UserGetCurIconObject(gDesktopCursor); - if (!pcurNew) - { - return TRUE; - } - - pcurNew->CURSORF_flags |= CURSORF_CURRENT; - pcurOld = UserSetCursor(pcurNew, FALSE); - if (pcurOld) - { - pcurOld->CURSORF_flags &= ~CURSORF_CURRENT; - UserDereferenceObject(pcurOld); - } - return TRUE; - } - - case WM_WINDOWPOSCHANGING: - { - PWINDOWPOS pWindowPos = (PWINDOWPOS)lParam; - if((pWindowPos->flags & SWP_SHOWWINDOW) != 0) - { - HDESK hdesk = IntGetDesktopObjectHandle(gpdeskInputDesktop); - IntSetThreadDesktop(hdesk, FALSE); - } - break; - } - default: - TRACE("DWP calling IDWP Msg %d\n",Msg); - //*lResult = IntDefWindowProc(Wnd, Msg, wParam, lParam, FALSE); - } - return TRUE; /* We are done. Do not do any callbacks to user mode */ + PAINTSTRUCT Ps; + ULONG Value; + //ERR("DesktopWindowProc\n"); + + *lResult = 0; + + switch (Msg) + { + case WM_NCCREATE: + if (!Wnd->fnid) + { + Wnd->fnid = FNID_DESKTOP; + } + *lResult = (LRESULT)TRUE; + return TRUE; + + case WM_CREATE: + Value = HandleToULong(PsGetCurrentProcessId()); + // Save Process ID + co_UserSetWindowLong(UserHMGetHandle(Wnd), DT_GWL_PROCESSID, Value, FALSE); + Value = HandleToULong(PsGetCurrentThreadId()); + // Save Thread ID + co_UserSetWindowLong(UserHMGetHandle(Wnd), DT_GWL_THREADID, Value, FALSE); + case WM_CLOSE: + return TRUE; + + case WM_DISPLAYCHANGE: + co_WinPosSetWindowPos(Wnd, 0, 0, 0, LOWORD(lParam), HIWORD(lParam), SWP_NOZORDER | SWP_NOACTIVATE); + return TRUE; + + case WM_ERASEBKGND: + IntPaintDesktop((HDC)wParam); + *lResult = 1; + return TRUE; + + case WM_PAINT: + { + if (IntBeginPaint(Wnd, &Ps)) + { + IntEndPaint(Wnd, &Ps); + } + return TRUE; + } + case WM_SYSCOLORCHANGE: + co_UserRedrawWindow(Wnd, NULL, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); + return TRUE; + + case WM_SETCURSOR: + { + PCURICON_OBJECT pcurOld, pcurNew; + pcurNew = UserGetCurIconObject(gDesktopCursor); + if (!pcurNew) + { + return TRUE; + } + + pcurNew->CURSORF_flags |= CURSORF_CURRENT; + pcurOld = UserSetCursor(pcurNew, FALSE); + if (pcurOld) + { + pcurOld->CURSORF_flags &= ~CURSORF_CURRENT; + UserDereferenceObject(pcurOld); + } + return TRUE; + } + + case WM_WINDOWPOSCHANGING: + { + PWINDOWPOS pWindowPos = (PWINDOWPOS)lParam; + if((pWindowPos->flags & SWP_SHOWWINDOW) != 0) + { + HDESK hdesk = IntGetDesktopObjectHandle(gpdeskInputDesktop); + IntSetThreadDesktop(hdesk, FALSE); + } + break; + } + default: + TRACE("DWP calling IDWP Msg %d\n",Msg); + //*lResult = IntDefWindowProc(Wnd, Msg, wParam, lParam, FALSE); + } + return TRUE; /* We are done. Do not do any callbacks to user mode */ } BOOL FASTCALL @@ -791,72 +791,72 @@ NTSTATUS FASTCALL co_IntShowDesktop(PDESKTOP Desktop, ULONG Width, ULONG Height, BOOL bRedraw) { - PWND pwnd = Desktop->pDeskInfo->spwnd; - UINT flags = SWP_NOACTIVATE|SWP_NOZORDER|SWP_SHOWWINDOW; - ASSERT(pwnd); - - if(!bRedraw) - flags |= SWP_NOREDRAW; - - co_WinPosSetWindowPos(pwnd, NULL, 0, 0, Width, Height, flags); - - if(bRedraw) - co_UserRedrawWindow( pwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_INVALIDATE ); - - return STATUS_SUCCESS; + PWND pwnd = Desktop->pDeskInfo->spwnd; + UINT flags = SWP_NOACTIVATE|SWP_NOZORDER|SWP_SHOWWINDOW; + ASSERT(pwnd); + + if(!bRedraw) + flags |= SWP_NOREDRAW; + + co_WinPosSetWindowPos(pwnd, NULL, 0, 0, Width, Height, flags); + + if(bRedraw) + co_UserRedrawWindow( pwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_INVALIDATE ); + + return STATUS_SUCCESS; } NTSTATUS FASTCALL IntHideDesktop(PDESKTOP Desktop) { - PWND DesktopWnd; - - DesktopWnd = IntGetWindowObject(Desktop->DesktopWindow); - if (! DesktopWnd) - { - return ERROR_INVALID_WINDOW_HANDLE; - } - DesktopWnd->style &= ~WS_VISIBLE; - - return STATUS_SUCCESS; + PWND DesktopWnd; + + DesktopWnd = IntGetWindowObject(Desktop->DesktopWindow); + if (! DesktopWnd) + { + return ERROR_INVALID_WINDOW_HANDLE; + } + DesktopWnd->style &= ~WS_VISIBLE; + + return STATUS_SUCCESS; } static HWND* FASTCALL UserBuildShellHookHwndList(PDESKTOP Desktop) { - ULONG entries=0; - PLIST_ENTRY ListEntry; - PSHELL_HOOK_WINDOW Current; - HWND* list; - - /* FIXME: If we save nb elements in desktop, we don't have to loop to find nb entries */ - ListEntry = Desktop->ShellHookWindows.Flink; - while (ListEntry != &Desktop->ShellHookWindows) - { - ListEntry = ListEntry->Flink; - entries++; - } - - if (!entries) return NULL; - - list = ExAllocatePoolWithTag(PagedPool, sizeof(HWND) * (entries + 1), USERTAG_WINDOWLIST); /* alloc one extra for nullterm */ - if (list) - { - HWND* cursor = list; - - ListEntry = Desktop->ShellHookWindows.Flink; - while (ListEntry != &Desktop->ShellHookWindows) - { - Current = CONTAINING_RECORD(ListEntry, SHELL_HOOK_WINDOW, ListEntry); - ListEntry = ListEntry->Flink; - *cursor++ = Current->hWnd; - } - - *cursor = NULL; /* Nullterm list */ - } - - return list; + ULONG entries=0; + PLIST_ENTRY ListEntry; + PSHELL_HOOK_WINDOW Current; + HWND* list; + + /* FIXME: If we save nb elements in desktop, we don't have to loop to find nb entries */ + ListEntry = Desktop->ShellHookWindows.Flink; + while (ListEntry != &Desktop->ShellHookWindows) + { + ListEntry = ListEntry->Flink; + entries++; + } + + if (!entries) return NULL; + + list = ExAllocatePoolWithTag(PagedPool, sizeof(HWND) * (entries + 1), USERTAG_WINDOWLIST); /* alloc one extra for nullterm */ + if (list) + { + HWND* cursor = list; + + ListEntry = Desktop->ShellHookWindows.Flink; + while (ListEntry != &Desktop->ShellHookWindows) + { + Current = CONTAINING_RECORD(ListEntry, SHELL_HOOK_WINDOW, ListEntry); + ListEntry = ListEntry->Flink; + *cursor++ = Current->hWnd; + } + + *cursor = NULL; /* Nullterm list */ + } + + return list; } /* @@ -866,54 +866,54 @@ */ VOID co_IntShellHookNotify(WPARAM Message, WPARAM wParam, LPARAM lParam) { - PDESKTOP Desktop = IntGetActiveDesktop(); - HWND* HwndList; - - if (!gpsi->uiShellMsg) - { - gpsi->uiShellMsg = IntAddAtom(L"SHELLHOOK"); - - TRACE("MsgType = %x\n", gpsi->uiShellMsg); - if (!gpsi->uiShellMsg) - ERR("LastError: %x\n", EngGetLastError()); - } - - if (!Desktop) - { - TRACE("IntShellHookNotify: No desktop!\n"); - return; - } - - // Allow other devices have a shot at foreground. - if (Message == HSHELL_APPCOMMAND) ptiLastInput = NULL; - - // FIXME: System Tray Support. - - HwndList = UserBuildShellHookHwndList(Desktop); - if (HwndList) - { - HWND* cursor = HwndList; - - for (; *cursor; cursor++) - { - TRACE("Sending notify\n"); - UserPostMessage(*cursor, - gpsi->uiShellMsg, - Message, - (Message == HSHELL_LANGUAGE ? lParam : (LPARAM)wParam) ); -/* co_IntPostOrSendMessage(*cursor, - gpsi->uiShellMsg, - Message, - (Message == HSHELL_LANGUAGE ? lParam : (LPARAM)wParam) );*/ - } - - ExFreePoolWithTag(HwndList, USERTAG_WINDOWLIST); - } - - if (ISITHOOKED(WH_SHELL)) - { - co_HOOK_CallHooks(WH_SHELL, Message, wParam, lParam); - } + PDESKTOP Desktop = IntGetActiveDesktop(); + HWND* HwndList; + + if (!gpsi->uiShellMsg) + { + gpsi->uiShellMsg = IntAddAtom(L"SHELLHOOK"); + + TRACE("MsgType = %x\n", gpsi->uiShellMsg); + if (!gpsi->uiShellMsg) + ERR("LastError: %x\n", EngGetLastError()); + } + + if (!Desktop) + { + TRACE("IntShellHookNotify: No desktop!\n"); + return; + } + + // Allow other devices have a shot at foreground. + if (Message == HSHELL_APPCOMMAND) ptiLastInput = NULL; + + // FIXME: System Tray Support. + + HwndList = UserBuildShellHookHwndList(Desktop); + if (HwndList) + { + HWND* cursor = HwndList; + + for (; *cursor; cursor++) + { + TRACE("Sending notify\n"); + UserPostMessage(*cursor, + gpsi->uiShellMsg, + Message, + (Message == HSHELL_LANGUAGE ? lParam : (LPARAM)wParam) ); +/* co_IntPostOrSendMessage(*cursor, + gpsi->uiShellMsg, + Message, + (Message == HSHELL_LANGUAGE ? lParam : (LPARAM)wParam) );*/ + } + + ExFreePoolWithTag(HwndList, USERTAG_WINDOWLIST); + } + + if (ISITHOOKED(WH_SHELL)) + { + co_HOOK_CallHooks(WH_SHELL, Message, wParam, lParam); + } } /* @@ -926,29 +926,29 @@ */ BOOL IntRegisterShellHookWindow(HWND hWnd) { - PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); - PDESKTOP Desktop = pti->rpdesk; - PSHELL_HOOK_WINDOW Entry; - - TRACE("IntRegisterShellHookWindow\n"); - - /* First deregister the window, so we can be sure it's never twice in the - * list. - */ - IntDeRegisterShellHookWindow(hWnd); - - Entry = ExAllocatePoolWithTag(PagedPool, - sizeof(SHELL_HOOK_WINDOW), - TAG_WINSTA); - - if (!Entry) - return FALSE; - - Entry->hWnd = hWnd; - - InsertTailList(&Desktop->ShellHookWindows, &Entry->ListEntry); - - return TRUE; + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PDESKTOP Desktop = pti->rpdesk; + PSHELL_HOOK_WINDOW Entry; + + TRACE("IntRegisterShellHookWindow\n"); + + /* First deregister the window, so we can be sure it's never twice in the + * list. + */ + IntDeRegisterShellHookWindow(hWnd); + + Entry = ExAllocatePoolWithTag(PagedPool, + sizeof(SHELL_HOOK_WINDOW), + TAG_WINSTA); + + if (!Entry) + return FALSE; + + Entry->hWnd = hWnd; + + InsertTailList(&Desktop->ShellHookWindows, &Entry->ListEntry); + + return TRUE; } /* @@ -958,25 +958,25 @@ */ BOOL IntDeRegisterShellHookWindow(HWND hWnd) { - PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); - PDESKTOP Desktop = pti->rpdesk; - PLIST_ENTRY ListEntry; - PSHELL_HOOK_WINDOW Current; - - ListEntry = Desktop->ShellHookWindows.Flink; - while (ListEntry != &Desktop->ShellHookWindows) - { - Current = CONTAINING_RECORD(ListEntry, SHELL_HOOK_WINDOW, ListEntry); - ListEntry = ListEntry->Flink; - if (Current->hWnd == hWnd) - { - RemoveEntryList(&Current->ListEntry); - ExFreePoolWithTag(Current, TAG_WINSTA); - return TRUE; - } - } - - return FALSE; + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PDESKTOP Desktop = pti->rpdesk; + PLIST_ENTRY ListEntry; + PSHELL_HOOK_WINDOW Current; + + ListEntry = Desktop->ShellHookWindows.Flink; + while (ListEntry != &Desktop->ShellHookWindows) + { + Current = CONTAINING_RECORD(ListEntry, SHELL_HOOK_WINDOW, ListEntry); + ListEntry = ListEntry->Flink; + if (Current->hWnd == hWnd) + { + RemoveEntryList(&Current->ListEntry); + ExFreePoolWithTag(Current, TAG_WINSTA); + return TRUE; + } + } + + return FALSE; } static VOID @@ -1058,12 +1058,12 @@ /* Fill in the area that the bitmap is not going to cover */ if (x > 0 || y > 0) { - /* FIXME: Clip out the bitmap - can be replaced with "NtGdiPatBlt(hDC, x, y, WinSta->cxWallpaper, WinSta->cyWallpaper, PATCOPY | DSTINVERT);" - once we support DSTINVERT */ - PreviousBrush = NtGdiSelectBrush(hDC, DesktopBrush); - NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY); - NtGdiSelectBrush(hDC, PreviousBrush); + /* FIXME: Clip out the bitmap + can be replaced with "NtGdiPatBlt(hDC, x, y, WinSta->cxWallpaper, WinSta->cyWallpaper, PATCOPY | DSTINVERT);" + once we support DSTINVERT */ + PreviousBrush = NtGdiSelectBrush(hDC, DesktopBrush); + NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY); + NtGdiSelectBrush(hDC, PreviousBrush); } /* Do not fill the background after it is painted no matter the size of the picture */ @@ -1223,38 +1223,38 @@ pdesk->pheapDesktop = UserCreateHeap(&pdesk->hsectionDesktop, &DesktopHeapSystemBase, HeapSize); - if (pdesk->pheapDesktop == NULL) - { - ERR("Failed to create desktop heap!\n"); - return STATUS_NO_MEMORY; - } - - /* Create DESKTOPINFO */ - DesktopInfoSize = sizeof(DESKTOPINFO) + DesktopName->Length + sizeof(WCHAR); - pdesk->pDeskInfo = RtlAllocateHeap(pdesk->pheapDesktop, - HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY, - DesktopInfoSize); - if (pdesk->pDeskInfo == NULL) - { - ERR("Failed to create the DESKTOP structure!\n"); - return STATUS_NO_MEMORY; - } - - /* Initialize the DESKTOPINFO */ - pdesk->pDeskInfo->pvDesktopBase = DesktopHeapSystemBase; - pdesk->pDeskInfo->pvDesktopLimit = (PVOID)((ULONG_PTR)DesktopHeapSystemBase + HeapSize); - RtlCopyMemory(pdesk->pDeskInfo->szDesktopName, - DesktopName->Buffer, - DesktopName->Length + sizeof(WCHAR)); - for (i = 0; i < NB_HOOKS; i++) - { - InitializeListHead(&pdesk->pDeskInfo->aphkStart[i]); - } - - InitializeListHead(&pdesk->ShellHookWindows); - InitializeListHead(&pdesk->PtiList); - - return STATUS_SUCCESS; + if (pdesk->pheapDesktop == NULL) + { + ERR("Failed to create desktop heap!\n"); + return STATUS_NO_MEMORY; + } + + /* Create DESKTOPINFO */ + DesktopInfoSize = sizeof(DESKTOPINFO) + DesktopName->Length + sizeof(WCHAR); + pdesk->pDeskInfo = RtlAllocateHeap(pdesk->pheapDesktop, + HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY, + DesktopInfoSize); + if (pdesk->pDeskInfo == NULL) + { + ERR("Failed to create the DESKTOP structure!\n"); + return STATUS_NO_MEMORY; + } + + /* Initialize the DESKTOPINFO */ + pdesk->pDeskInfo->pvDesktopBase = DesktopHeapSystemBase; + pdesk->pDeskInfo->pvDesktopLimit = (PVOID)((ULONG_PTR)DesktopHeapSystemBase + HeapSize); + RtlCopyMemory(pdesk->pDeskInfo->szDesktopName, + DesktopName->Buffer, + DesktopName->Length + sizeof(WCHAR)); + for (i = 0; i < NB_HOOKS; i++) + { + InitializeListHead(&pdesk->pDeskInfo->aphkStart[i]); + } + + InitializeListHead(&pdesk->ShellHookWindows); + InitializeListHead(&pdesk->PtiList); + + return STATUS_SUCCESS; } /* SYSCALLS *******************************************************************/ @@ -1294,167 +1294,167 @@ HDESK APIENTRY NtUserCreateDesktop( - POBJECT_ATTRIBUTES ObjectAttributes, - PUNICODE_STRING lpszDesktopDevice, - LPDEVMODEW lpdmw, - DWORD dwFlags, - ACCESS_MASK dwDesiredAccess) -{ - PDESKTOP pdesk = NULL; - NTSTATUS Status = STATUS_SUCCESS; - HDESK hdesk; - BOOLEAN Context = FALSE; - UNICODE_STRING ClassName; - LARGE_STRING WindowName; - BOOL NoHooks = FALSE; - PWND pWnd = NULL; - CREATESTRUCTW Cs; - PTHREADINFO ptiCurrent; - PCLS pcls; - - DECLARE_RETURN(HDESK); - - TRACE("Enter NtUserCreateDesktop\n"); - UserEnterExclusive(); - - ptiCurrent = PsGetCurrentThreadWin32Thread(); - ASSERT(ptiCurrent); - ASSERT(gptiDesktopThread); - - /* Turn off hooks when calling any CreateWindowEx from inside win32k. */ - NoHooks = (ptiCurrent->TIF_flags & TIF_DISABLEHOOKS); - ptiCurrent->TIF_flags |= TIF_DISABLEHOOKS; - ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags; - - /* - * Try to open already existing desktop + POBJECT_ATTRIBUTES ObjectAttributes, + PUNICODE_STRING lpszDesktopDevice, + LPDEVMODEW lpdmw, + DWORD dwFlags, + ACCESS_MASK dwDesiredAccess) +{ + PDESKTOP pdesk = NULL; + NTSTATUS Status = STATUS_SUCCESS; + HDESK hdesk; + BOOLEAN Context = FALSE; + UNICODE_STRING ClassName; + LARGE_STRING WindowName; + BOOL NoHooks = FALSE; + PWND pWnd = NULL; + CREATESTRUCTW Cs; + PTHREADINFO ptiCurrent; + PCLS pcls; + + DECLARE_RETURN(HDESK); + + TRACE("Enter NtUserCreateDesktop\n"); + UserEnterExclusive(); + + ptiCurrent = PsGetCurrentThreadWin32Thread(); + ASSERT(ptiCurrent); + ASSERT(gptiDesktopThread); + + /* Turn off hooks when calling any CreateWindowEx from inside win32k. */ + NoHooks = (ptiCurrent->TIF_flags & TIF_DISABLEHOOKS); + ptiCurrent->TIF_flags |= TIF_DISABLEHOOKS; + ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags; + + /* + * Try to open already existing desktop + */ + Status = ObOpenObjectByName( + ObjectAttributes, + ExDesktopObjectType, + UserMode, + NULL, + dwDesiredAccess, + (PVOID)&Context, + (HANDLE*)&hdesk); + if (!NT_SUCCESS(Status)) + { + ERR("ObOpenObjectByName failed to open/create desktop\n"); + SetLastNtError(Status); + RETURN(NULL); + } + + /* In case the object was not created (eg if it existed), return now */ + if (Context == FALSE) + { + TRACE("NtUserCreateDesktop opened desktop %wZ\n", ObjectAttributes->ObjectName); + RETURN( hdesk); + } + + /* Reference the desktop */ + Status = ObReferenceObjectByHandle(hdesk, + 0, + ExDesktopObjectType, + KernelMode, + (PVOID*)&pdesk, + NULL); + if (!NT_SUCCESS(Status)) + { + ERR("Failed to reference desktop object\n"); + SetLastNtError(Status); + RETURN(NULL); + } + + /* Get the desktop window class. The thread desktop does not belong to any desktop + * so the classes created there (including the desktop class) are allocated in the shared heap + * It would cause problems if we used a class that belongs to the caller + */ + ClassName.Buffer = WC_DESKTOP; + ClassName.Length = 0; + pcls = IntGetAndReferenceClass(&ClassName, 0, TRUE); + if (pcls == NULL) + { + ASSERT(FALSE); + RETURN(NULL); + } + + RtlZeroMemory(&WindowName, sizeof(WindowName)); + RtlZeroMemory(&Cs, sizeof(Cs)); + Cs.x = UserGetSystemMetrics(SM_XVIRTUALSCREEN), + Cs.y = UserGetSystemMetrics(SM_YVIRTUALSCREEN), + Cs.cx = UserGetSystemMetrics(SM_CXVIRTUALSCREEN), + Cs.cy = UserGetSystemMetrics(SM_CYVIRTUALSCREEN), + Cs.style = WS_POPUP|WS_CLIPCHILDREN; + Cs.hInstance = hModClient; // hModuleWin; // Server side winproc! + Cs.lpszName = (LPCWSTR) &WindowName; + Cs.lpszClass = (LPCWSTR) &ClassName; + + /* Use IntCreateWindow instead of co_UserCreateWindowEx cause the later expects a thread with a desktop */ + pWnd = IntCreateWindow(&Cs, &WindowName, pcls, NULL, NULL, NULL, pdesk); + if (pWnd == NULL) + { + ERR("Failed to create desktop window for the new desktop\n"); + RETURN(NULL); + } + + pdesk->dwSessionId = PsGetCurrentProcessSessionId(); + pdesk->DesktopWindow = pWnd->head.h; + pdesk->pDeskInfo->spwnd = pWnd; + pWnd->fnid = FNID_DESKTOP; + + ClassName.Buffer = MAKEINTATOM(gpsi->atomSysClass[ICLS_HWNDMESSAGE]); + ClassName.Length = 0; + pcls = IntGetAndReferenceClass(&ClassName, 0, TRUE); + if (pcls == NULL) + { + ASSERT(FALSE); + RETURN(NULL); + } + + RtlZeroMemory(&WindowName, sizeof(WindowName)); + RtlZeroMemory(&Cs, sizeof(Cs)); + Cs.cx = Cs.cy = 100; + Cs.style = WS_POPUP|WS_CLIPCHILDREN; + Cs.hInstance = hModClient; // hModuleWin; // Server side winproc! + Cs.lpszName = (LPCWSTR) &WindowName; + Cs.lpszClass = (LPCWSTR) &ClassName; + pWnd = IntCreateWindow(&Cs, &WindowName, pcls, NULL, NULL, NULL, pdesk); + if (pWnd == NULL) + { + ERR("Failed to create message window for the new desktop\n"); + RETURN(NULL); + } + + pdesk->spwndMessage = pWnd; + pWnd->fnid = FNID_MESSAGEWND; + + /* Now,,, + if !(WinStaObject->Flags & WSF_NOIO) is (not set) for desktop input output mode (see wiki) + Create Tooltip. Saved in DesktopObject->spwndTooltip. + Tooltip dwExStyle: WS_EX_TOOLWINDOW|WS_EX_TOPMOST + hWndParent are spwndMessage. Use hModuleWin for server side winproc! + The rest is same as message window. +
http://msdn.microsoft.com/en-us/library/bb760250(VS.85).aspx
*/ - Status = ObOpenObjectByName( - ObjectAttributes, - ExDesktopObjectType, - UserMode, - NULL, - dwDesiredAccess, - (PVOID)&Context, - (HANDLE*)&hdesk); - if (!NT_SUCCESS(Status)) - { - ERR("ObOpenObjectByName failed to open/create desktop\n"); - SetLastNtError(Status); - RETURN(NULL); - } - - /* In case the object was not created (eg if it existed), return now */ - if (Context == FALSE) - { - TRACE("NtUserCreateDesktop opened desktop %wZ\n", ObjectAttributes->ObjectName); - RETURN( hdesk); - } - - /* Reference the desktop */ - Status = ObReferenceObjectByHandle(hdesk, - 0, - ExDesktopObjectType, - KernelMode, - (PVOID*)&pdesk, - NULL); - if (!NT_SUCCESS(Status)) - { - ERR("Failed to reference desktop object\n"); - SetLastNtError(Status); - RETURN(NULL); - } - - /* Get the desktop window class. The thread desktop does not belong to any desktop - * so the classes created there (including the desktop class) are allocated in the shared heap - * It would cause problems if we used a class that belongs to the caller - */ - ClassName.Buffer = WC_DESKTOP; - ClassName.Length = 0; - pcls = IntGetAndReferenceClass(&ClassName, 0, TRUE); - if (pcls == NULL) - { - ASSERT(FALSE); - RETURN(NULL); - } - - RtlZeroMemory(&WindowName, sizeof(WindowName)); - RtlZeroMemory(&Cs, sizeof(Cs)); - Cs.x = UserGetSystemMetrics(SM_XVIRTUALSCREEN), - Cs.y = UserGetSystemMetrics(SM_YVIRTUALSCREEN), - Cs.cx = UserGetSystemMetrics(SM_CXVIRTUALSCREEN), - Cs.cy = UserGetSystemMetrics(SM_CYVIRTUALSCREEN), - Cs.style = WS_POPUP|WS_CLIPCHILDREN; - Cs.hInstance = hModClient; // hModuleWin; // Server side winproc! - Cs.lpszName = (LPCWSTR) &WindowName; - Cs.lpszClass = (LPCWSTR) &ClassName; - - /* Use IntCreateWindow instead of co_UserCreateWindowEx cause the later expects a thread with a desktop */ - pWnd = IntCreateWindow(&Cs, &WindowName, pcls, NULL, NULL, NULL, pdesk); - if (pWnd == NULL) - { - ERR("Failed to create desktop window for the new desktop\n"); - RETURN(NULL); - } - - pdesk->dwSessionId = PsGetCurrentProcessSessionId(); - pdesk->DesktopWindow = pWnd->head.h; - pdesk->pDeskInfo->spwnd = pWnd; - pWnd->fnid = FNID_DESKTOP; - - ClassName.Buffer = MAKEINTATOM(gpsi->atomSysClass[ICLS_HWNDMESSAGE]); - ClassName.Length = 0; - pcls = IntGetAndReferenceClass(&ClassName, 0, TRUE); - if (pcls == NULL) - { - ASSERT(FALSE); - RETURN(NULL); - } - - RtlZeroMemory(&WindowName, sizeof(WindowName)); - RtlZeroMemory(&Cs, sizeof(Cs)); - Cs.cx = Cs.cy = 100; - Cs.style = WS_POPUP|WS_CLIPCHILDREN; - Cs.hInstance = hModClient; // hModuleWin; // Server side winproc! - Cs.lpszName = (LPCWSTR) &WindowName; - Cs.lpszClass = (LPCWSTR) &ClassName; - pWnd = IntCreateWindow(&Cs, &WindowName, pcls, NULL, NULL, NULL, pdesk); - if (pWnd == NULL) - { - ERR("Failed to create message window for the new desktop\n"); - RETURN(NULL); - } - - pdesk->spwndMessage = pWnd; - pWnd->fnid = FNID_MESSAGEWND; - - /* Now,,, - if !(WinStaObject->Flags & WSF_NOIO) is (not set) for desktop input output mode (see wiki) - Create Tooltip. Saved in DesktopObject->spwndTooltip. - Tooltip dwExStyle: WS_EX_TOOLWINDOW|WS_EX_TOPMOST - hWndParent are spwndMessage. Use hModuleWin for server side winproc! - The rest is same as message window. -
http://msdn.microsoft.com/en-us/library/bb760250(VS.85).aspx
- */ - RETURN( hdesk); + RETURN( hdesk); CLEANUP: - if (pdesk != NULL) - { - ObDereferenceObject(pdesk); - } - if (_ret_ == NULL && hdesk != NULL) - { - ObCloseHandle(hdesk, UserMode); - } - if (!NoHooks) - { - ptiCurrent->TIF_flags &= ~TIF_DISABLEHOOKS; - ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags; - } - TRACE("Leave NtUserCreateDesktop, ret=%p\n",_ret_); - UserLeave(); - END_CLEANUP; + if (pdesk != NULL) + { + ObDereferenceObject(pdesk); + } + if (_ret_ == NULL && hdesk != NULL) + { + ObCloseHandle(hdesk, UserMode); + } + if (!NoHooks) + { + ptiCurrent->TIF_flags &= ~TIF_DISABLEHOOKS; + ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags; + } + TRACE("Leave NtUserCreateDesktop, ret=%p\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -1481,32 +1481,32 @@ HDESK APIENTRY NtUserOpenDesktop( - POBJECT_ATTRIBUTES ObjectAttributes, - DWORD dwFlags, - ACCESS_MASK dwDesiredAccess) -{ - NTSTATUS Status; - HDESK Desktop; - - Status = ObOpenObjectByName( - ObjectAttributes, - ExDesktopObjectType, - UserMode, - NULL, - dwDesiredAccess, - NULL, - (HANDLE*)&Desktop); - - if (!NT_SUCCESS(Status)) - { - ERR("Failed to open desktop\n"); - SetLastNtError(Status); - return 0; - } - - TRACE("Opened desktop %S with handle 0x%p\n", ObjectAttributes->ObjectName->Buffer, Desktop); - - return Desktop; + POBJECT_ATTRIBUTES ObjectAttributes, + DWORD dwFlags, + ACCESS_MASK dwDesiredAccess) +{ + NTSTATUS Status; + HDESK Desktop; + + Status = ObOpenObjectByName( + ObjectAttributes, + ExDesktopObjectType, + UserMode, + NULL, + dwDesiredAccess, + NULL, + (HANDLE*)&Desktop); + + if (!NT_SUCCESS(Status)) + { + ERR("Failed to open desktop\n"); + SetLastNtError(Status); + return 0; + } + + TRACE("Opened desktop %S with handle 0x%p\n", ObjectAttributes->ObjectName->Buffer, Desktop); + + return Desktop; } /* @@ -1533,38 +1533,38 @@ HDESK APIENTRY NtUserOpenInputDesktop( - DWORD dwFlags, - BOOL fInherit, - ACCESS_MASK dwDesiredAccess) -{ - NTSTATUS Status; - HDESK hdesk = NULL; - ULONG HandleAttributes = 0; - - UserEnterExclusive(); - TRACE("Enter NtUserOpenInputDesktop gpdeskInputDesktop 0x%p\n",gpdeskInputDesktop); - - if(fInherit) HandleAttributes = OBJ_INHERIT; - - /* Create a new handle to the object */ - Status = ObOpenObjectByPointer( - gpdeskInputDesktop, - HandleAttributes, - NULL, - dwDesiredAccess, - ExDesktopObjectType, - UserMode, - (PHANDLE)&hdesk); - - if (!NT_SUCCESS(Status)) - { - ERR("Failed to open input desktop object\n"); - SetLastNtError(Status); - } - - TRACE("NtUserOpenInputDesktop returning 0x%p\n",hdesk); - UserLeave(); - return hdesk; + DWORD dwFlags, + BOOL fInherit, + ACCESS_MASK dwDesiredAccess) +{ + NTSTATUS Status; + HDESK hdesk = NULL; + ULONG HandleAttributes = 0; + + UserEnterExclusive(); + TRACE("Enter NtUserOpenInputDesktop gpdeskInputDesktop 0x%p\n",gpdeskInputDesktop); + + if(fInherit) HandleAttributes = OBJ_INHERIT; + + /* Create a new handle to the object */ + Status = ObOpenObjectByPointer( + gpdeskInputDesktop, + HandleAttributes, + NULL, + dwDesiredAccess, + ExDesktopObjectType, + UserMode, + (PHANDLE)&hdesk); + + if (!NT_SUCCESS(Status)) + { + ERR("Failed to open input desktop object\n"); + SetLastNtError(Status); + } + + TRACE("NtUserOpenInputDesktop returning 0x%p\n",hdesk); + UserLeave(); + return hdesk; } /* @@ -1592,43 +1592,43 @@ BOOL APIENTRY NtUserCloseDesktop(HDESK hDesktop) { - PDESKTOP pdesk; - NTSTATUS Status; - DECLARE_RETURN(BOOL); - - TRACE("NtUserCloseDesktop called (0x%p)\n", hDesktop); - UserEnterExclusive(); - - if( hDesktop == gptiCurrent->hdesk || hDesktop == gptiCurrent->ppi->hdeskStartup) - { - ERR("Attempted to close thread desktop\n"); - EngSetLastError(ERROR_BUSY); - RETURN(FALSE); - } - - Status = IntValidateDesktopHandle( hDesktop, UserMode, 0, &pdesk); - if (!NT_SUCCESS(Status)) - { - ERR("Validation of desktop handle (0x%p) failed\n", hDesktop); - RETURN(FALSE); - } - - ObDereferenceObject(pdesk); - - Status = ZwClose(hDesktop); - if (!NT_SUCCESS(Status)) - { - ERR("Failed to close desktop handle 0x%p\n", hDesktop); - SetLastNtError(Status); - RETURN(FALSE); - } - - RETURN(TRUE); + PDESKTOP pdesk; + NTSTATUS Status; + DECLARE_RETURN(BOOL); + + TRACE("NtUserCloseDesktop called (0x%p)\n", hDesktop); + UserEnterExclusive(); + + if( hDesktop == gptiCurrent->hdesk || hDesktop == gptiCurrent->ppi->hdeskStartup) + { + ERR("Attempted to close thread desktop\n"); + EngSetLastError(ERROR_BUSY); + RETURN(FALSE); + } + + Status = IntValidateDesktopHandle( hDesktop, UserMode, 0, &pdesk); + if (!NT_SUCCESS(Status)) + { + ERR("Validation of desktop handle (0x%p) failed\n", hDesktop); + RETURN(FALSE); + } + + ObDereferenceObject(pdesk); + + Status = ZwClose(hDesktop); + if (!NT_SUCCESS(Status)) + { + ERR("Failed to close desktop handle 0x%p\n", hDesktop); + SetLastNtError(Status); + RETURN(FALSE); + } + + RETURN(TRUE); CLEANUP: - TRACE("Leave NtUserCloseDesktop, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; + TRACE("Leave NtUserCloseDesktop, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -1649,13 +1649,13 @@ BOOL APIENTRY NtUserPaintDesktop(HDC hDC) { - BOOL Ret; - UserEnterExclusive(); - TRACE("Enter NtUserPaintDesktop\n"); - Ret = IntPaintDesktop(hDC); - TRACE("Leave NtUserPaintDesktop, ret=%i\n",Ret); - UserLeave(); - return Ret; + BOOL Ret; + UserEnterExclusive(); + TRACE("Enter NtUserPaintDesktop\n"); + Ret = IntPaintDesktop(hDC); + TRACE("Leave NtUserPaintDesktop, ret=%i\n",Ret); + UserLeave(); + return Ret; } /* @@ -1774,90 +1774,90 @@ BOOL APIENTRY NtUserSwitchDesktop(HDESK hdesk) { - PDESKTOP pdesk; - NTSTATUS Status; - BOOL bRedrawDesktop; - DECLARE_RETURN(BOOL); - - UserEnterExclusive(); - TRACE("Enter NtUserSwitchDesktop(0x%p)\n", hdesk); - - Status = IntValidateDesktopHandle( hdesk, UserMode, 0, &pdesk); - if (!NT_SUCCESS(Status)) - { - ERR("Validation of desktop handle (0x%p) failed\n", hdesk); - RETURN(FALSE); - } - - if (PsGetCurrentProcessSessionId() != pdesk->rpwinstaParent->dwSessionId) - { - ObDereferenceObject(pdesk); - ERR("NtUserSwitchDesktop called for a desktop of a different session\n"); - RETURN(FALSE); - } - - if(pdesk == gpdeskInputDesktop) - { - ObDereferenceObject(pdesk); - WARN("NtUserSwitchDesktop called for active desktop\n"); - RETURN(TRUE); - } - - /* - * Don't allow applications switch the desktop if it's locked, unless the caller - * is the logon application itself - */ - if((pdesk->rpwinstaParent->Flags & WSS_LOCKED) && - gpidLogon != PsGetCurrentProcessId()) - { - ObDereferenceObject(pdesk); - ERR("Switching desktop 0x%p denied because the window station is locked!\n", hdesk); - RETURN(FALSE); - } - - if(pdesk->rpwinstaParent != InputWindowStation) - { - ObDereferenceObject(pdesk); - ERR("Switching desktop 0x%p denied because desktop doesn't belong to the interactive winsta!\n", hdesk); - RETURN(FALSE); - } - - /* FIXME: Fail if the process is associated with a secured - desktop such as Winlogon or Screen-Saver */ - /* FIXME: Connect to input device */ - - TRACE("Switching from desktop 0x%p to 0x%p\n", gpdeskInputDesktop, pdesk); - - bRedrawDesktop = FALSE; - - /* The first time SwitchDesktop is called, gpdeskInputDesktop is NULL */ - if(gpdeskInputDesktop != NULL) - { - if((gpdeskInputDesktop->pDeskInfo->spwnd->style & WS_VISIBLE) == WS_VISIBLE) - bRedrawDesktop = TRUE; - - /* Hide the previous desktop window */ - IntHideDesktop(gpdeskInputDesktop); - } - - /* Set the active desktop in the desktop's window station. */ - InputWindowStation->ActiveDesktop = pdesk; - - /* Set the global state. */ - gpdeskInputDesktop = pdesk; - - /* Show the new desktop window */ - co_IntShowDesktop(pdesk, UserGetSystemMetrics(SM_CXSCREEN), UserGetSystemMetrics(SM_CYSCREEN), bRedrawDesktop); - - TRACE("SwitchDesktop gpdeskInputDesktop 0x%p\n",gpdeskInputDesktop); - ObDereferenceObject(pdesk); - - RETURN(TRUE); + PDESKTOP pdesk; + NTSTATUS Status; + BOOL bRedrawDesktop; + DECLARE_RETURN(BOOL); + + UserEnterExclusive(); + TRACE("Enter NtUserSwitchDesktop(0x%p)\n", hdesk); + + Status = IntValidateDesktopHandle( hdesk, UserMode, 0, &pdesk); + if (!NT_SUCCESS(Status)) + { + ERR("Validation of desktop handle (0x%p) failed\n", hdesk); + RETURN(FALSE); + } + + if (PsGetCurrentProcessSessionId() != pdesk->rpwinstaParent->dwSessionId) + { + ObDereferenceObject(pdesk); + ERR("NtUserSwitchDesktop called for a desktop of a different session\n"); + RETURN(FALSE); + } + + if(pdesk == gpdeskInputDesktop) + { + ObDereferenceObject(pdesk); + WARN("NtUserSwitchDesktop called for active desktop\n"); + RETURN(TRUE); + } + + /* + * Don't allow applications switch the desktop if it's locked, unless the caller + * is the logon application itself + */ + if((pdesk->rpwinstaParent->Flags & WSS_LOCKED) && + gpidLogon != PsGetCurrentProcessId()) + { + ObDereferenceObject(pdesk); + ERR("Switching desktop 0x%p denied because the window station is locked!\n", hdesk); + RETURN(FALSE); + } + + if(pdesk->rpwinstaParent != InputWindowStation) + { + ObDereferenceObject(pdesk); + ERR("Switching desktop 0x%p denied because desktop doesn't belong to the interactive winsta!\n", hdesk); + RETURN(FALSE); + } + + /* FIXME: Fail if the process is associated with a secured + desktop such as Winlogon or Screen-Saver */ + /* FIXME: Connect to input device */ + + TRACE("Switching from desktop 0x%p to 0x%p\n", gpdeskInputDesktop, pdesk); + + bRedrawDesktop = FALSE; + + /* The first time SwitchDesktop is called, gpdeskInputDesktop is NULL */ + if(gpdeskInputDesktop != NULL) + { + if((gpdeskInputDesktop->pDeskInfo->spwnd->style & WS_VISIBLE) == WS_VISIBLE) + bRedrawDesktop = TRUE; + + /* Hide the previous desktop window */ + IntHideDesktop(gpdeskInputDesktop); + } + + /* Set the active desktop in the desktop's window station. */ + InputWindowStation->ActiveDesktop = pdesk; + + /* Set the global state. */ + gpdeskInputDesktop = pdesk; + + /* Show the new desktop window */ + co_IntShowDesktop(pdesk, UserGetSystemMetrics(SM_CXSCREEN), UserGetSystemMetrics(SM_CYSCREEN), bRedrawDesktop); + + TRACE("SwitchDesktop gpdeskInputDesktop 0x%p\n",gpdeskInputDesktop); + ObDereferenceObject(pdesk); + + RETURN(TRUE); CLEANUP: - TRACE("Leave NtUserSwitchDesktop, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; + TRACE("Leave NtUserSwitchDesktop, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -1870,80 +1870,80 @@ HDESK APIENTRY NtUserGetThreadDesktop(DWORD dwThreadId, DWORD Unknown1) { - NTSTATUS Status; - PETHREAD Thread; - PDESKTOP DesktopObject; - HDESK Ret, hThreadDesktop; - OBJECT_HANDLE_INFORMATION HandleInformation; - DECLARE_RETURN(HDESK); - - UserEnterExclusive(); - TRACE("Enter NtUserGetThreadDesktop\n"); - - if(!dwThreadId) - { - EngSetLastError(ERROR_INVALID_PARAMETER); - RETURN(0); - } - - Status = PsLookupThreadByThreadId((HANDLE)(DWORD_PTR)dwThreadId, &Thread); - if(!NT_SUCCESS(Status)) - { - EngSetLastError(ERROR_INVALID_PARAMETER); - RETURN(0); - } - - if(Thread->ThreadsProcess == PsGetCurrentProcess()) - { - /* Just return the handle, we queried the desktop handle of a thread running - in the same context */ - Ret = ((PTHREADINFO)Thread->Tcb.Win32Thread)->hdesk; - ObDereferenceObject(Thread); - RETURN(Ret); - } - - /* Get the desktop handle and the desktop of the thread */ - if(!(hThreadDesktop = ((PTHREADINFO)Thread->Tcb.Win32Thread)->hdesk) || - !(DesktopObject = ((PTHREADINFO)Thread->Tcb.Win32Thread)->rpdesk)) - { - ObDereferenceObject(Thread); - ERR("Desktop information of thread 0x%x broken!?\n", dwThreadId); - RETURN(NULL); - } - - /* We could just use DesktopObject instead of looking up the handle, but latter - may be a bit safer (e.g. when the desktop is being destroyed */ - /* Switch into the context of the thread we're trying to get the desktop from, - so we can use the handle */ - KeAttachProcess(&Thread->ThreadsProcess->Pcb); - Status = ObReferenceObjectByHandle(hThreadDesktop, - GENERIC_ALL, - ExDesktopObjectType, - UserMode, - (PVOID*)&DesktopObject, - &HandleInformation); - KeDetachProcess(); - - /* The handle couldn't be found, there's nothing to get... */ - if(!NT_SUCCESS(Status)) - { - ObDereferenceObject(Thread); - RETURN(NULL); - } - - /* Lookup our handle table if we can find a handle to the desktop object, - if not, create one */ - Ret = IntGetDesktopObjectHandle(DesktopObject); - - /* All done, we got a valid handle to the desktop */ - ObDereferenceObject(DesktopObject); - ObDereferenceObject(Thread); - RETURN(Ret); + NTSTATUS Status; + PETHREAD Thread; + PDESKTOP DesktopObject; + HDESK Ret, hThreadDesktop; + OBJECT_HANDLE_INFORMATION HandleInformation; + DECLARE_RETURN(HDESK); + + UserEnterExclusive(); + TRACE("Enter NtUserGetThreadDesktop\n"); + + if(!dwThreadId) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + RETURN(0); + } + + Status = PsLookupThreadByThreadId((HANDLE)(DWORD_PTR)dwThreadId, &Thread); + if(!NT_SUCCESS(Status)) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + RETURN(0); + } + + if(Thread->ThreadsProcess == PsGetCurrentProcess()) + { + /* Just return the handle, we queried the desktop handle of a thread running + in the same context */ + Ret = ((PTHREADINFO)Thread->Tcb.Win32Thread)->hdesk; + ObDereferenceObject(Thread); + RETURN(Ret); + } + + /* Get the desktop handle and the desktop of the thread */ + if(!(hThreadDesktop = ((PTHREADINFO)Thread->Tcb.Win32Thread)->hdesk) || + !(DesktopObject = ((PTHREADINFO)Thread->Tcb.Win32Thread)->rpdesk)) + { + ObDereferenceObject(Thread); + ERR("Desktop information of thread 0x%x broken!?\n", dwThreadId); + RETURN(NULL); + } + + /* We could just use DesktopObject instead of looking up the handle, but latter + may be a bit safer (e.g. when the desktop is being destroyed */ + /* Switch into the context of the thread we're trying to get the desktop from, + so we can use the handle */ + KeAttachProcess(&Thread->ThreadsProcess->Pcb); + Status = ObReferenceObjectByHandle(hThreadDesktop, + GENERIC_ALL, + ExDesktopObjectType, + UserMode, + (PVOID*)&DesktopObject, + &HandleInformation); + KeDetachProcess(); + + /* The handle couldn't be found, there's nothing to get... */ + if(!NT_SUCCESS(Status)) + { + ObDereferenceObject(Thread); + RETURN(NULL); + } + + /* Lookup our handle table if we can find a handle to the desktop object, + if not, create one */ + Ret = IntGetDesktopObjectHandle(DesktopObject); + + /* All done, we got a valid handle to the desktop */ + ObDereferenceObject(DesktopObject); + ObDereferenceObject(Thread); + RETURN(Ret); CLEANUP: - TRACE("Leave NtUserGetThreadDesktop, ret=%p\n",_ret_); - UserLeave(); - END_CLEANUP; + TRACE("Leave NtUserGetThreadDesktop, ret=%p\n",_ret_); + UserLeave(); + END_CLEANUP; } static NTSTATUS @@ -2114,8 +2114,8 @@ /* Desktop is being re-set so clear out foreground. */ if (pti->rpdesk != pdesk && pti->MessageQueue == gpqForeground) { - // Like above, there shouldn't be any windows, hooks or anything active on this threads desktop! - IntSetFocusMessageQueue(NULL); + // Like above, there shouldn't be any windows, hooks or anything active on this threads desktop! + IntSetFocusMessageQueue(NULL); } /* Before doing the switch, map the new desktop heap and allocate the new pcti */ @@ -2160,9 +2160,9 @@ pdeskOld = pti->rpdesk; hdeskOld = pti->hdesk; if (pti->pcti != &pti->cti) - pctiOld = pti->pcti; + pctiOld = pti->pcti; else - pctiOld = NULL; + pctiOld = NULL; /* do the switch */ if(pdesk != NULL) @@ -2229,19 +2229,19 @@ BOOL APIENTRY NtUserSetThreadDesktop(HDESK hDesktop) { - BOOL ret = FALSE; - - UserEnterExclusive(); - - // FIXME: IntSetThreadDesktop validates the desktop handle, it should happen - // here too and set the NT error level. Q. Is it necessary to have the validation - // in IntSetThreadDesktop? Is it needed there too? - if (hDesktop || (!hDesktop && PsGetCurrentProcess() == gpepCSRSS)) - ret = IntSetThreadDesktop(hDesktop, FALSE); - - UserLeave(); - - return ret; + BOOL ret = FALSE; + + UserEnterExclusive(); + + // FIXME: IntSetThreadDesktop validates the desktop handle, it should happen + // here too and set the NT error level. Q. Is it necessary to have the validation + // in IntSetThreadDesktop? Is it needed there too? + if (hDesktop || (!hDesktop && PsGetCurrentProcess() == gpepCSRSS)) + ret = IntSetThreadDesktop(hDesktop, FALSE); + + UserLeave(); + + return ret; } /* EOF */
8 years, 7 months
1
0
0
0
[gadamopoulos] 71237: [SHELL32] - lnk files are .. files so don't pretend that CDrivesFolder and CControlPanelFolder can contain lnk files. - Don't create a full pidl just to parse it right away (w...
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Tue May 3 09:15:36 2016 New Revision: 71237 URL:
http://svn.reactos.org/svn/reactos?rev=71237&view=rev
Log: [SHELL32] - lnk files are .. files so don't pretend that CDrivesFolder and CControlPanelFolder can contain lnk files. - Don't create a full pidl just to parse it right away (which is a costly operation) when an IShellLink is queried from a folder. - Fix a bug in CDesktopFolder::GetDisplayNameOf that was exposed by changes above. Modified: trunk/reactos/dll/win32/shell32/CShellLink.cpp trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp trunk/reactos/dll/win32/shell32/wine/shell32_main.h trunk/reactos/dll/win32/shell32/wine/shellord.c Modified: trunk/reactos/dll/win32/shell32/CShellLink.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/CShellLi…
============================================================================== --- trunk/reactos/dll/win32/shell32/CShellLink.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/CShellLink.cpp [iso-8859-1] Tue May 3 09:15:36 2016 @@ -2231,33 +2231,25 @@ /************************************************************************** * IShellLink_ConstructFromFile */ -HRESULT WINAPI IShellLink_ConstructFromFile(IUnknown *pUnkOuter, REFIID riid, LPCITEMIDLIST pidl, LPVOID *ppv) -{ - CComPtr<IUnknown> psl; - - HRESULT hr = CShellLink::_CreatorClass::CreateInstance(NULL, riid, (void**)&psl); - - if (SUCCEEDED(hr)) - { - CComPtr<IPersistFile> ppf; - - *ppv = NULL; - - hr = psl->QueryInterface(IID_PPV_ARG(IPersistFile, &ppf)); - - if (SUCCEEDED(hr)) - { - WCHAR path[MAX_PATH]; - - if (SHGetPathFromIDListW(pidl, path)) - hr = ppf->Load(path, 0); - else - hr = E_FAIL; - - if (SUCCEEDED(hr)) - *ppv = psl.Detach(); - } - } - - return hr; -} +HRESULT WINAPI IShellLink_ConstructFromPath(WCHAR *path, REFIID riid, LPVOID *ppv) +{ + CComPtr<IPersistFile> ppf; + HRESULT hr = CShellLink::_CreatorClass::CreateInstance(NULL, IID_PPV_ARG(IPersistFile, &ppf)); + if (FAILED(hr)) + return hr; + + hr = ppf->Load(path, 0); + if (FAILED(hr)) + return hr; + + return ppf->QueryInterface(riid, ppv); +} + +HRESULT WINAPI IShellLink_ConstructFromFile(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv) +{ + WCHAR path[MAX_PATH]; + if (!ILGetDisplayNameExW(psf, pidl, path, 0)) + return E_FAIL; + + return IShellLink_ConstructFromPath(path, riid, ppv); +} Modified: trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
============================================================================== --- trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp [iso-8859-1] Tue May 3 09:15:36 2016 @@ -472,7 +472,6 @@ HRESULT WINAPI CControlPanelFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) { - LPITEMIDLIST pidl; LPVOID pObj = NULL; HRESULT hr = E_INVALIDARG; @@ -502,12 +501,6 @@ hr = IDataObject_Constructor(hwndOwner, pidlRoot, apidl, cidl, (IDataObject **)&pObj); } else if ((IsEqualIID(riid, IID_IExtractIconA) || IsEqualIID(riid, IID_IExtractIconW)) && (cidl == 1)) { hr = CCPLExtractIcon_CreateInstance(this, apidl[0], riid, &pObj); - - } else if ((IsEqualIID(riid, IID_IShellLinkW) || IsEqualIID(riid, IID_IShellLinkA)) - && (cidl == 1)) { - pidl = ILCombine(pidlRoot, apidl[0]); - hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj); - SHFree(pidl); } else { hr = E_NOINTERFACE; } Modified: trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
============================================================================== --- trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp [iso-8859-1] Tue May 3 09:15:36 2016 @@ -589,7 +589,6 @@ UINT *prgfInOut, LPVOID *ppvOut) { - LPITEMIDLIST pidl; LPVOID pObj = NULL; HRESULT hr = E_INVALIDARG; @@ -624,9 +623,7 @@ else if ((IsEqualIID(riid, IID_IShellLinkW) || IsEqualIID(riid, IID_IShellLinkA)) && (cidl == 1)) { - pidl = ILCombine (pidlRoot, apidl[0]); - hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj); - SHFree (pidl); + hr = IShellLink_ConstructFromFile(this, apidl[0], riid, &pObj); } else hr = E_NOINTERFACE; @@ -682,7 +679,7 @@ int cLen = 0; /* file system folder or file rooted at the desktop */ - if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) && + if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) && (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER)) { lstrcpynW(pszPath, sPathTarget, MAX_PATH - 1); @@ -697,7 +694,7 @@ if (GetFileAttributes(pszPath) == INVALID_FILE_ATTRIBUTES) { /* file system folder or file rooted at the AllUsers desktop */ - if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) && + if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) && (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER)) { SHGetSpecialFolderPathW(0, pszPath, CSIDL_COMMON_DESKTOPDIRECTORY, FALSE); Modified: trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
============================================================================== --- trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp [iso-8859-1] Tue May 3 09:15:36 2016 @@ -435,7 +435,6 @@ UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT *prgfInOut, LPVOID *ppvOut) { - LPITEMIDLIST pidl; LPVOID pObj = NULL; HRESULT hr = E_INVALIDARG; @@ -465,13 +464,6 @@ IDropTarget * pDt = NULL; hr = this->QueryInterface(IID_PPV_ARG(IDropTarget, &pDt)); pObj = pDt; - } - else if ((IsEqualIID(riid, IID_IShellLinkW) || - IsEqualIID(riid, IID_IShellLinkA)) && (cidl == 1)) - { - pidl = ILCombine (pidlRoot, apidl[0]); - hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*) &pObj); - SHFree (pidl); } else hr = E_NOINTERFACE; Modified: trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
============================================================================== --- trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp [iso-8859-1] Tue May 3 09:15:36 2016 @@ -487,7 +487,6 @@ REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) { - LPITEMIDLIST pidl; LPVOID pObj = NULL; HRESULT hr = E_INVALIDARG; @@ -532,9 +531,7 @@ else if ((IsEqualIID(riid, IID_IShellLinkW) || IsEqualIID(riid, IID_IShellLinkA)) && (cidl == 1)) { - pidl = ILCombine (pidlRoot, apidl[0]); - hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj); - SHFree (pidl); + hr = IShellLink_ConstructFromFile(this, apidl[0], riid, &pObj); } else hr = E_NOINTERFACE; @@ -1426,7 +1423,7 @@ hr = E_FAIL; break; } - hr = IShellLink_ConstructFromFile(NULL, IID_IPersistFile, ILCombine(pidl, apidl[i]), (LPVOID*)&ppf); + hr = IShellLink_ConstructFromFile(this, apidl[i], IID_PPV_ARG(IPersistFile, &ppf)); if (FAILED(hr)) { ERR("Error constructing link from file"); break; Modified: trunk/reactos/dll/win32/shell32/wine/shell32_main.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/wine/she…
============================================================================== --- trunk/reactos/dll/win32/shell32/wine/shell32_main.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/wine/shell32_main.h [iso-8859-1] Tue May 3 09:15:36 2016 @@ -74,7 +74,8 @@ HRESULT WINAPI CDefViewDual_Constructor(REFIID riid, LPVOID * ppvOut); HRESULT WINAPI CShell_Constructor(REFIID riid, LPVOID * ppvOut); -HRESULT WINAPI IShellLink_ConstructFromFile(IUnknown * pUnkOuter, REFIID riid, LPCITEMIDLIST pidl, LPVOID * ppv); +HRESULT WINAPI IShellLink_ConstructFromPath(WCHAR *path, REFIID riid, LPVOID *ppv); +HRESULT WINAPI IShellLink_ConstructFromFile(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv); HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV); HRESULT WINAPI CPanel_ExtractIconA(LPITEMIDLIST pidl, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) DECLSPEC_HIDDEN; HRESULT WINAPI CPanel_ExtractIconW(LPITEMIDLIST pidl, LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) DECLSPEC_HIDDEN; Modified: trunk/reactos/dll/win32/shell32/wine/shellord.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/wine/she…
============================================================================== --- trunk/reactos/dll/win32/shell32/wine/shellord.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/wine/shellord.c [iso-8859-1] Tue May 3 09:15:36 2016 @@ -823,8 +823,13 @@ ext = strrchr(doc_name, '.'); if (!lstrcmpiA(ext, ".lnk")) { + WCHAR doc_nameW[MAX_PATH]; IShellLinkA* ShellLink; - IShellLink_ConstructFromFile(NULL, &IID_IShellLinkA, (LPCITEMIDLIST)SHSimpleIDListFromPathA(doc_name), (LPVOID*)&ShellLink); + int nLength = MultiByteToWideChar(CP_ACP, 0, doc_name, -1, doc_nameW, MAX_PATH); + if (nLength == 0) + return; + + IShellLink_ConstructFromPath(doc_nameW, &IID_IShellLinkA, (LPVOID*)&ShellLink); IShellLinkA_GetPath(ShellLink, doc_name, MAX_PATH, NULL, 0); IShellLinkA_Release(ShellLink); }
8 years, 7 months
1
0
0
0
[tfaber] 71236: [REG_WINETEST] - Addendum to r71232: we no longer need to skip this test. ROSTESTS-200
by tfaber@svn.reactos.org
Author: tfaber Date: Mon May 2 20:30:59 2016 New Revision: 71236 URL:
http://svn.reactos.org/svn/reactos?rev=71236&view=rev
Log: [REG_WINETEST] - Addendum to r71232: we no longer need to skip this test. ROSTESTS-200 Modified: trunk/rostests/winetests/reg/reg.c Modified: trunk/rostests/winetests/reg/reg.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/reg/reg.c?rev=7…
============================================================================== --- trunk/rostests/winetests/reg/reg.c [iso-8859-1] (original) +++ trunk/rostests/winetests/reg/reg.c [iso-8859-1] Mon May 2 20:30:59 2016 @@ -450,10 +450,7 @@ return; } - if (!winetest_interactive) - skip("ROSTESTS-200: Skipping test_add because of exceptions in Cm.\n"); - else - test_add(); + test_add(); test_delete(); test_query(); test_v_flags();
8 years, 7 months
1
0
0
0
[pschweitzer] 71235: [USER32] Import Wine commit: - bfb7e167cb399dbba0a889b797bc11ece8b9e687, Check bounds before dereferencing.
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Mon May 2 17:45:42 2016 New Revision: 71235 URL:
http://svn.reactos.org/svn/reactos?rev=71235&view=rev
Log: [USER32] Import Wine commit: - bfb7e167cb399dbba0a889b797bc11ece8b9e687, Check bounds before dereferencing. Modified: trunk/reactos/win32ss/user/user32/controls/edit.c Modified: trunk/reactos/win32ss/user/user32/controls/edit.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/contro…
============================================================================== --- trunk/reactos/win32ss/user/user32/controls/edit.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/controls/edit.c [iso-8859-1] Mon May 2 17:45:42 2016 @@ -299,7 +299,7 @@ case WB_RIGHT: if (!count) break; - while (s[index] && index < count && !es->logAttr[index].fSoftBreak) + while (index < count && s[index] && !es->logAttr[index].fSoftBreak) index++; ret = index; break;
8 years, 7 months
1
0
0
0
[pschweitzer] 71234: [COMDLG32] Import Wine commit: - d288d8d333f6faea9d64a0af944f125663a449d8, Check for overflow before dereferencing.
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Mon May 2 17:45:39 2016 New Revision: 71234 URL:
http://svn.reactos.org/svn/reactos?rev=71234&view=rev
Log: [COMDLG32] Import Wine commit: - d288d8d333f6faea9d64a0af944f125663a449d8, Check for overflow before dereferencing. Modified: trunk/reactos/dll/win32/comdlg32/filedlg.c Modified: trunk/reactos/dll/win32/comdlg32/filedlg.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comdlg32/filedlg…
============================================================================== --- trunk/reactos/dll/win32/comdlg32/filedlg.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/comdlg32/filedlg.c [iso-8859-1] Mon May 2 17:45:39 2016 @@ -621,7 +621,7 @@ if ( lpstrEdit[nStrCharCount]=='"' ) { nStrCharCount++; - while ((lpstrEdit[nStrCharCount]!='"') && (nStrCharCount <= nStrLen)) + while ((nStrCharCount <= nStrLen) && (lpstrEdit[nStrCharCount]!='"')) { (*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount]; nStrCharCount++;
8 years, 7 months
1
0
0
0
[gadamopoulos] 71233: [SHELL32] - Fix loading shortcut icons. The previous code passed a full pidl to GetUIObjectOf which is really wrong. CORE-11158
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Mon May 2 13:50:13 2016 New Revision: 71233 URL:
http://svn.reactos.org/svn/reactos?rev=71233&view=rev
Log: [SHELL32] - Fix loading shortcut icons. The previous code passed a full pidl to GetUIObjectOf which is really wrong. CORE-11158 Modified: trunk/reactos/dll/win32/shell32/folders.cpp Modified: trunk/reactos/dll/win32/shell32/folders.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders.…
============================================================================== --- trunk/reactos/dll/win32/shell32/folders.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/folders.cpp [iso-8859-1] Mon May 2 13:50:13 2016 @@ -370,21 +370,17 @@ else if (!lstrcmpiA(sTemp, "lnkfile")) { /* extract icon from shell shortcut */ - CComPtr<IShellFolder> dsf; CComPtr<IShellLinkW> psl; - if (SUCCEEDED(SHGetDesktopFolder(&dsf))) - { - HRESULT hr = dsf->GetUIObjectOf(NULL, 1, &pidl, IID_NULL_PPV_ARG(IShellLinkW, &psl)); - - if (SUCCEEDED(hr)) - { - hr = psl->GetIconLocation(wTemp, MAX_PATH, &icon_idx); - - if (SUCCEEDED(hr) && *sTemp) - found = TRUE; - - } + HRESULT hr = psf->GetUIObjectOf(NULL, 1, &pidl, IID_NULL_PPV_ARG(IShellLinkW, &psl)); + + if (SUCCEEDED(hr)) + { + hr = psl->GetIconLocation(wTemp, MAX_PATH, &icon_idx); + + if (SUCCEEDED(hr) && *sTemp) + found = TRUE; + } } }
8 years, 7 months
1
0
0
0
[tfaber] 71232: [NTOS:CM] - Correctly handle NULL Data with nonzero DataSize in NtSetValueKey ROSTESTS-200 #resolve
by tfaber@svn.reactos.org
Author: tfaber Date: Mon May 2 13:19:44 2016 New Revision: 71232 URL:
http://svn.reactos.org/svn/reactos?rev=71232&view=rev
Log: [NTOS:CM] - Correctly handle NULL Data with nonzero DataSize in NtSetValueKey ROSTESTS-200 #resolve Added: trunk/rostests/apitests/ntdll/NtSetValueKey.c (with props) Modified: trunk/reactos/ntoskrnl/config/ntapi.c trunk/rostests/apitests/ntdll/CMakeLists.txt trunk/rostests/apitests/ntdll/testlist.c Modified: trunk/reactos/ntoskrnl/config/ntapi.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/ntapi.c?re…
============================================================================== --- trunk/reactos/ntoskrnl/config/ntapi.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/config/ntapi.c [iso-8859-1] Mon May 2 13:19:44 2016 @@ -630,11 +630,11 @@ Data = NULL; /* Probe and copy the data */ - if ((PreviousMode != KernelMode) && Data) + if ((PreviousMode != KernelMode) && (DataSize != 0)) { PVOID DataCopy = ExAllocatePoolWithTag(PagedPool, DataSize, TAG_CM); if (!DataCopy) - return STATUS_NO_MEMORY; + return STATUS_INSUFFICIENT_RESOURCES; _SEH2_TRY { ProbeForRead(Data, DataSize, 1); Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/CMakeLists…
============================================================================== --- trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] Mon May 2 13:19:44 2016 @@ -18,6 +18,7 @@ NtQuerySystemEnvironmentValue.c NtQueryVolumeInformationFile.c NtSaveKey.c + NtSetValueKey.c RtlAllocateHeap.c RtlBitmap.c RtlCopyMappedMemory.c Added: trunk/rostests/apitests/ntdll/NtSetValueKey.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/NtSetValue…
============================================================================== --- trunk/rostests/apitests/ntdll/NtSetValueKey.c (added) +++ trunk/rostests/apitests/ntdll/NtSetValueKey.c [iso-8859-1] Mon May 2 13:19:44 2016 @@ -0,0 +1,209 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory + * PURPOSE: Test for NtSetValueKey + * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org> + */ + +#include <apitest.h> + +#include <winreg.h> +#define WIN32_NO_STATUS +#include <ndk/cmfuncs.h> +#include <ndk/obfuncs.h> +#include <ndk/rtlfuncs.h> +#include <strsafe.h> + +START_TEST(NtSetValueKey) +{ + NTSTATUS Status; + HANDLE ParentKeyHandle; + HANDLE KeyHandle; + UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"SOFTWARE\\ntdll-apitest-NtSetValueKey"); + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING ValueName; + WCHAR Default[] = L"Default"; + WCHAR Hello[] = L"Hello"; + WCHAR Empty[] = L""; + NTSTATUS QueryStatus; + PKEY_VALUE_PARTIAL_INFORMATION PartialInfo; + ULONG PartialInfoLength; + ULONG ResultLength; + const struct + { + ULONG Type; + PVOID Data; + ULONG DataSize; + NTSTATUS StatusExisting; + NTSTATUS StatusNew; + NTSTATUS StatusExisting2; + NTSTATUS StatusNew2; + } Tests[] = + { + { REG_NONE, NULL, 0, STATUS_SUCCESS, STATUS_SUCCESS }, /* Empty REG_NONE value */ + { REG_SZ, Hello, sizeof(Hello), STATUS_SUCCESS, STATUS_SUCCESS }, /* Regular string */ + { REG_SZ, Empty, sizeof(Empty), STATUS_SUCCESS, STATUS_SUCCESS }, /* Empty string */ + { REG_SZ, NULL, 0, STATUS_SUCCESS, STATUS_SUCCESS }, /* Zero length */ + { REG_SZ, Hello, 0, STATUS_SUCCESS, STATUS_SUCCESS }, /* Zero length, non-null data */ + { REG_SZ, (PVOID)(LONG_PTR)-4, 0, STATUS_SUCCESS, STATUS_SUCCESS }, /* Zero length, kernel data */ + { REG_SZ, NULL, 1, STATUS_ACCESS_VIOLATION, STATUS_ACCESS_VIOLATION }, /* Non-zero length (odd), null data */ + { REG_SZ, NULL, 2, STATUS_ACCESS_VIOLATION, STATUS_ACCESS_VIOLATION }, /* Non-zero length (even), null data */ + { REG_SZ, NULL, 4, STATUS_ACCESS_VIOLATION, STATUS_ACCESS_VIOLATION }, /* CM_KEY_VALUE_SMALL, null data */ + { REG_SZ, NULL, 5, STATUS_INVALID_PARAMETER, STATUS_ACCESS_VIOLATION, /* CM_KEY_VALUE_SMALL+1, null data */ + STATUS_ACCESS_VIOLATION, STATUS_INSUFFICIENT_RESOURCES }, /* win7 */ + { REG_SZ, NULL, 6, STATUS_INVALID_PARAMETER, STATUS_ACCESS_VIOLATION, /* CM_KEY_VALUE_SMALL+2, null data */ + STATUS_ACCESS_VIOLATION, STATUS_INSUFFICIENT_RESOURCES }, /* win7 */ + { REG_SZ, NULL, 0x7fff0000, STATUS_INVALID_PARAMETER, STATUS_INSUFFICIENT_RESOURCES, /* MI_USER_PROBE_ADDRESS, null data */ + STATUS_INSUFFICIENT_RESOURCES, STATUS_INSUFFICIENT_RESOURCES }, /* win7 */ + { REG_SZ, NULL, 0x7fff0001, STATUS_ACCESS_VIOLATION, STATUS_ACCESS_VIOLATION, /* MI_USER_PROBE_ADDRESS+1, null data */ + STATUS_INSUFFICIENT_RESOURCES, STATUS_INSUFFICIENT_RESOURCES }, /* win7 */ + { REG_SZ, NULL, 0x7fffffff, STATUS_ACCESS_VIOLATION, STATUS_ACCESS_VIOLATION, /* <2GB, null data */ + STATUS_INVALID_PARAMETER, STATUS_INVALID_PARAMETER }, /* win7 */ + { REG_SZ, NULL, 0x80000000, STATUS_ACCESS_VIOLATION, STATUS_ACCESS_VIOLATION, /* 2GB, null data */ + STATUS_INVALID_PARAMETER, STATUS_INVALID_PARAMETER }, /* win7 */ + { REG_BINARY, NULL, 5, STATUS_INVALID_PARAMETER, STATUS_ACCESS_VIOLATION, /* ROSTESTS-200 */ + STATUS_ACCESS_VIOLATION, STATUS_INSUFFICIENT_RESOURCES }, /* win7 */ + }; + ULONG i; + + Status = RtlOpenCurrentUser(READ_CONTROL, &ParentKeyHandle); + ok(Status == STATUS_SUCCESS, "RtlOpenCurrentUser returned %lx\n", Status); + if (!NT_SUCCESS(Status)) + { + skip("No user key handle\n"); + return; + } + + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + ParentKeyHandle, + NULL); + Status = NtCreateKey(&KeyHandle, + KEY_QUERY_VALUE | KEY_SET_VALUE | DELETE, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + NULL); + ok(Status == STATUS_SUCCESS, "NtCreateKey returned %lx\n", Status); + if (!NT_SUCCESS(Status)) + { + NtClose(ParentKeyHandle); + skip("No key handle\n"); + return; + } + + PartialInfoLength = FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[128]); + PartialInfo = HeapAlloc(GetProcessHeap(), 0, PartialInfoLength); + if (PartialInfo == NULL) + { + NtDeleteKey(KeyHandle); + NtClose(KeyHandle); + NtClose(ParentKeyHandle); + skip("No key handle\n"); + return; + } + + for (i = 0; i < RTL_NUMBER_OF(Tests); i++) + { + /* + * Existing value + */ + /* Make sure it exists */ + RtlInitUnicodeString(&ValueName, L"ExistingValue"); + Status = NtSetValueKey(KeyHandle, &ValueName, 0, REG_SZ, Default, sizeof(Default)); + ok(Status == STATUS_SUCCESS, "[%lu] NtSetValueKey failed with %lx", i, Status); + + /* Set it */ + Status = NtSetValueKey(KeyHandle, &ValueName, 0, Tests[i].Type, Tests[i].Data, Tests[i].DataSize); + if (Status == Tests[i].StatusExisting2) + ok(Status == Tests[i].StatusExisting || Status == Tests[i].StatusExisting2, "[%lu, %p, %lu] NtSetValueKey returned %lx, expected %lx or %lx\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, Status, Tests[i].StatusExisting, Tests[i].StatusExisting2); + else + ok(Status == Tests[i].StatusExisting, "[%lu, %p, %lu] NtSetValueKey returned %lx, expected %lx\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, Status, Tests[i].StatusExisting); + + /* Check it */ + RtlZeroMemory(PartialInfo, PartialInfoLength); + QueryStatus = NtQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation, PartialInfo, PartialInfoLength, &ResultLength); + ok(QueryStatus == STATUS_SUCCESS, "[%lu, %p, %lu] NtQueryValueKey failed with %lx\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, QueryStatus); + if (NT_SUCCESS(QueryStatus)) + { + if (NT_SUCCESS(Status)) + { + ok(PartialInfo->TitleIndex == 0, "[%lu, %p, %lu] TitleIndex = %lu\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, PartialInfo->TitleIndex); + ok(PartialInfo->Type == Tests[i].Type, "[%lu, %p, %lu] Type = %lu\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, PartialInfo->Type); + ok(PartialInfo->DataLength == Tests[i].DataSize, "[%lu, %p, %lu] DataLength = %lu\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, PartialInfo->DataLength); + ok(!memcmp(PartialInfo->Data, Tests[i].Data, Tests[i].DataSize), "[%lu, %p, %lu] Data does not match set value\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize); + } + else + { + ok(PartialInfo->TitleIndex == 0, "[%lu, %p, %lu] TitleIndex = %lu\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, PartialInfo->TitleIndex); + ok(PartialInfo->Type == REG_SZ, "[%lu, %p, %lu] Type = %lu\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, PartialInfo->Type); + ok(PartialInfo->DataLength == sizeof(Default), "[%lu, %p, %lu] DataLength = %lu\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, PartialInfo->DataLength); + ok(!memcmp(PartialInfo->Data, Default, sizeof(Default)), "[%lu, %p, %lu] Data does not match default\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize); + } + } + + /* + * New value + */ + /* Make sure it doesn't exist */ + RtlInitUnicodeString(&ValueName, L"NewValue"); + Status = NtDeleteValueKey(KeyHandle, &ValueName); + ok(Status == STATUS_SUCCESS || Status == STATUS_OBJECT_NAME_NOT_FOUND, + "[%lu] NtDeleteValueKey failed with %lx", i, Status); + + /* Set it */ + Status = NtSetValueKey(KeyHandle, &ValueName, 0, Tests[i].Type, Tests[i].Data, Tests[i].DataSize); + if (Tests[i].StatusNew2) + ok(Status == Tests[i].StatusNew || Status == Tests[i].StatusNew2, "[%lu, %p, %lu] NtSetValueKey returned %lx, expected %lx or %lx\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, Status, Tests[i].StatusNew, Tests[i].StatusNew2); + else + ok(Status == Tests[i].StatusNew, "[%lu, %p, %lu] NtSetValueKey returned %lx, expected %lx\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, Status, Tests[i].StatusNew); + + /* Check it */ + RtlZeroMemory(PartialInfo, PartialInfoLength); + QueryStatus = NtQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation, PartialInfo, PartialInfoLength, &ResultLength); + if (NT_SUCCESS(Status)) + { + ok(QueryStatus == STATUS_SUCCESS, "[%lu, %p, %lu] NtQueryValueKey failed with %lx\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, QueryStatus); + if (NT_SUCCESS(QueryStatus)) + { + ok(PartialInfo->TitleIndex == 0, "[%lu, %p, %lu] TitleIndex = %lu\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, PartialInfo->TitleIndex); + ok(PartialInfo->Type == Tests[i].Type, "[%lu, %p, %lu] Type = %lu\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, PartialInfo->Type); + ok(PartialInfo->DataLength == Tests[i].DataSize, "[%lu, %p, %lu] DataLength = %lu\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, PartialInfo->DataLength); + ok(!memcmp(PartialInfo->Data, Tests[i].Data, Tests[i].DataSize), "[%lu, %p, %lu] Data does not match set value\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize); + } + } + else + { + ok(QueryStatus == STATUS_OBJECT_NAME_NOT_FOUND, "[%lu, %p, %lu] QueryStatus = %lx\n", + Tests[i].Type, Tests[i].Data, Tests[i].DataSize, QueryStatus); + } + } + + HeapFree(GetProcessHeap(), 0, PartialInfo); + Status = NtDeleteKey(KeyHandle); + ok(Status == STATUS_SUCCESS, "NtDeleteKey returned %lx\n", Status); + Status = NtClose(KeyHandle); + ok(Status == STATUS_SUCCESS, "NtClose returned %lx\n", Status); + Status = NtClose(ParentKeyHandle); + ok(Status == STATUS_SUCCESS, "NtClose returned %lx\n", Status); +} Propchange: trunk/rostests/apitests/ntdll/NtSetValueKey.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/rostests/apitests/ntdll/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/testlist.c…
============================================================================== --- trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] Mon May 2 13:19:44 2016 @@ -21,6 +21,7 @@ extern void func_NtQuerySystemEnvironmentValue(void); extern void func_NtQueryVolumeInformationFile(void); extern void func_NtSaveKey(void); +extern void func_NtSetValueKey(void); extern void func_NtSystemInformation(void); extern void func_RtlAllocateHeap(void); extern void func_RtlBitmap(void); @@ -63,6 +64,7 @@ { "NtQuerySystemEnvironmentValue", func_NtQuerySystemEnvironmentValue }, { "NtQueryVolumeInformationFile", func_NtQueryVolumeInformationFile }, { "NtSaveKey", func_NtSaveKey}, + { "NtSetValueKey", func_NtSetValueKey}, { "NtSystemInformation", func_NtSystemInformation }, { "RtlAllocateHeap", func_RtlAllocateHeap }, { "RtlBitmapApi", func_RtlBitmap },
8 years, 7 months
1
0
0
0
[jimtabor] 71231: [User32] - Patch by Herschel Ralston : Fix scroll bar glitch. See CORE-3923 and CORE-11155.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Mon May 2 02:46:03 2016 New Revision: 71231 URL:
http://svn.reactos.org/svn/reactos?rev=71231&view=rev
Log: [User32] - Patch by Herschel Ralston : Fix scroll bar glitch. See CORE-3923 and CORE-11155. Modified: trunk/reactos/win32ss/user/user32/controls/scrollbar.c Modified: trunk/reactos/win32ss/user/user32/controls/scrollbar.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/contro…
============================================================================== --- trunk/reactos/win32ss/user/user32/controls/scrollbar.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/controls/scrollbar.c [iso-8859-1] Mon May 2 02:46:03 2016 @@ -855,6 +855,7 @@ NewInfo.rgstate[ScrollTrackHitTest] = ScrollBarInfo.rgstate[ScrollTrackHitTest]; NtUserSetScrollBarInfo(Wnd, IntScrollGetObjectId(SBType), &NewInfo); + IntDrawScrollInterior(Wnd,Dc,SBType,Vertical,&ScrollBarInfo); IntDrawScrollArrows(Dc, &ScrollBarInfo, Vertical); break;
8 years, 7 months
1
0
0
0
← Newer
1
...
22
23
24
25
26
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Results per page:
10
25
50
100
200