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
October 2012
----- 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
14 participants
211 discussions
Start a n
N
ew thread
[jgardou] 57641: [WIN32K] - Properly handle deletion of cursor/Icon objects - Gracefully change object owner when process closes - Remove useless check in a macro
by jgardou@svn.reactos.org
Author: jgardou Date: Sun Oct 28 14:45:35 2012 New Revision: 57641 URL:
http://svn.reactos.org/svn/reactos?rev=57641&view=rev
Log: [WIN32K] - Properly handle deletion of cursor/Icon objects - Gracefully change object owner when process closes - Remove useless check in a macro Modified: trunk/reactos/win32ss/gdi/ntgdi/misc.h trunk/reactos/win32ss/user/ntuser/cursoricon.c trunk/reactos/win32ss/user/ntuser/object.c trunk/reactos/win32ss/user/ntuser/object.h Modified: trunk/reactos/win32ss/gdi/ntgdi/misc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/misc.h?r…
============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/misc.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/misc.h [iso-8859-1] Sun Oct 28 14:45:35 2012 @@ -163,6 +163,6 @@ #define LIST_FOR_EACH_SAFE(cursor, cursor2, list, type, field) \ for ((cursor) = CONTAINING_RECORD((list)->Flink, type, field), \ (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field); \ - &(cursor)->field != (list) && ((&((cursor)->field)) != NULL); \ + &(cursor)->field != (list); \ (cursor) = (cursor2), \ (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field)) Modified: trunk/reactos/win32ss/user/ntuser/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/cursor…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/cursoricon.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/cursoricon.c [iso-8859-1] Sun Oct 28 14:45:35 2012 @@ -234,55 +234,54 @@ } BOOLEAN FASTCALL -IntDestroyCurIconObject(PCURICON_OBJECT CurIcon, BOOL ProcessCleanup) +IntDestroyCurIconObject(PCURICON_OBJECT CurIcon, PPROCESSINFO ppi) { PSYSTEM_CURSORINFO CurInfo; HBITMAP bmpMask, bmpColor; - BOOLEAN Ret; + BOOLEAN Ret, bListEmpty, bFound = FALSE; PCURICON_PROCESS Current = NULL; - PPROCESSINFO W32Process = PsGetCurrentProcessWin32Process(); - - /* Private objects can only be destroyed by their own process */ - if (NULL == CurIcon->hModule) - { - ASSERT(CurIcon->ProcessList.Flink->Flink == &CurIcon->ProcessList); - Current = CONTAINING_RECORD(CurIcon->ProcessList.Flink, CURICON_PROCESS, ListEntry); - if (Current->Process != W32Process) - { - ERR("Trying to destroy private icon/cursor of another process\n"); - return FALSE; - } - } - else if (! ProcessCleanup) - { - TRACE("Trying to destroy shared icon/cursor\n"); - return FALSE; - } + + /* For handles created without any data (error handling) */ + if(IsListEmpty(&CurIcon->ProcessList)) + goto emptyList; /* Now find this process in the list of processes referencing this object and remove it from that list */ LIST_FOR_EACH(Current, &CurIcon->ProcessList, CURICON_PROCESS, ListEntry) { - if (Current->Process == W32Process) - { - RemoveEntryList(&Current->ListEntry); + if (Current->Process == ppi) + { + bFound = TRUE; + bListEmpty = RemoveEntryList(&Current->ListEntry); break; } } + + if(!bFound) + { + /* This object doesn't belong to this process */ + EngSetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } ExFreeToPagedLookasideList(pgProcessLookasideList, Current); /* If there are still processes referencing this object we can't destroy it yet */ - if (! IsListEmpty(&CurIcon->ProcessList)) - { + if (!bListEmpty) + { + if(CurIcon->head.ppi == ppi) + { + /* Set the first process of the list as owner */ + Current = CONTAINING_RECORD(CurIcon->ProcessList.Flink, CURICON_PROCESS, ListEntry); + UserSetObjectOwner(CurIcon, otCursorIcon, Current->Process); + } + UserDereferenceObject(CurIcon); return TRUE; } - - if (! ProcessCleanup) - { - RemoveEntryList(&CurIcon->ListEntry); - } +emptyList: + /* Remove it from the list */ + RemoveEntryList(&CurIcon->ListEntry); CurInfo = IntGetSysCursorInfo(); @@ -320,33 +319,13 @@ IntCleanupCurIcons(struct _EPROCESS *Process, PPROCESSINFO Win32Process) { PCURICON_OBJECT CurIcon, tmp; - PCURICON_PROCESS ProcessData; - + + /* Run through the list of icon objects */ LIST_FOR_EACH_SAFE(CurIcon, tmp, &gCurIconList, CURICON_OBJECT, ListEntry) { UserReferenceObject(CurIcon); - // if(NT_SUCCESS(UserReferenceObjectByPointer(Object, otCursorIcon))) - { - LIST_FOR_EACH(ProcessData, &CurIcon->ProcessList, CURICON_PROCESS, ListEntry) - { - if (Win32Process == ProcessData->Process) - { - RemoveEntryList(&CurIcon->ListEntry); - IntDestroyCurIconObject(CurIcon, TRUE); - CurIcon = NULL; - break; - } - } - -// UserDereferenceObject(Object); - } - - if (CurIcon) - { - UserDereferenceObject(CurIcon); - } - } - + IntDestroyCurIconObject(CurIcon, Win32Process); + } } @@ -649,7 +628,7 @@ RETURN(FALSE); } - ret = IntDestroyCurIconObject(CurIcon, FALSE); + ret = IntDestroyCurIconObject(CurIcon, PsGetCurrentProcessWin32Process()); /* Note: IntDestroyCurIconObject will remove our reference for us! */ RETURN(ret); Modified: trunk/reactos/win32ss/user/ntuser/object.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/object…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/object.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/object.c [iso-8859-1] Sun Oct 28 14:45:35 2012 @@ -516,6 +516,38 @@ return object; } +VOID +FASTCALL +UserSetObjectOwner(PVOID obj, USER_OBJECT_TYPE type, PVOID owner) +{ + PUSER_HANDLE_ENTRY entry = handle_to_entry(gHandleTable, ((PHEAD)obj)->h ); + PPROCESSINFO ppi, oldppi; + + /* This must be called with a valid object */ + ASSERT(entry); + + /* For now, only supported for CursorIcon object */ + switch(type) + { + case otCursorIcon: + ppi = (PPROCESSINFO)owner; + entry->pi = ppi; + oldppi = ((PPROCMARKHEAD)obj)->ppi; + ((PPROCMARKHEAD)obj)->ppi = ppi; + break; + default: + ASSERT(FALSE); + return; + } + + oldppi->UserHandleCount--; + ppi->UserHandleCount++; +#if DBG + oldppi->DbgHandleCount[type]--; + ppi->DbgHandleCount[type]++; +#endif +} + /* * NtUserValidateHandleSecure * Modified: trunk/reactos/win32ss/user/ntuser/object.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/object…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/object.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/object.h [iso-8859-1] Sun Oct 28 14:45:35 2012 @@ -40,6 +40,7 @@ BOOL FASTCALL UserCreateHandleTable(VOID); BOOL FASTCALL UserObjectInDestroy(HANDLE); void DbgUserDumpHandleTable(); +VOID FASTCALL UserSetObjectOwner(PVOID obj, USER_OBJECT_TYPE type, PVOID owner); static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
12 years, 1 month
1
0
0
0
[jgardou] 57640: [WIN32K] - Plug an icon leak.
by jgardou@svn.reactos.org
Author: jgardou Date: Sun Oct 28 14:37:40 2012 New Revision: 57640 URL:
http://svn.reactos.org/svn/reactos?rev=57640&view=rev
Log: [WIN32K] - Plug an icon leak. Modified: trunk/reactos/win32ss/user/ntuser/painting.c Modified: trunk/reactos/win32ss/user/ntuser/painting.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/painti…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/painting.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/painting.c [iso-8859-1] Sun Oct 28 14:37:40 2012 @@ -2003,6 +2003,7 @@ LONG x = Rect.left - cx/2 + 1 + (Rect.bottom - Rect.top)/2; // this is really what Window does LONG y = (Rect.top + Rect.bottom)/2 - cy/2; // center UserDrawIconEx(hDc, x, y, pIcon, cx, cy, 0, NULL, DI_NORMAL); + UserDereferenceObject(pIcon); } }
12 years, 1 month
1
0
0
0
[ekohl] 57639: [SAMSRV] Implement SamrRemoveMemberFromAlias and SamrRemoveMultipleMembersFromAlias.
by ekohl@svn.reactos.org
Author: ekohl Date: Sun Oct 28 13:53:39 2012 New Revision: 57639 URL:
http://svn.reactos.org/svn/reactos?rev=57639&view=rev
Log: [SAMSRV] Implement SamrRemoveMemberFromAlias and SamrRemoveMultipleMembersFromAlias. Modified: trunk/reactos/dll/win32/samsrv/samrpc.c Modified: trunk/reactos/dll/win32/samsrv/samrpc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/samrpc.c?…
============================================================================== --- trunk/reactos/dll/win32/samsrv/samrpc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/samsrv/samrpc.c [iso-8859-1] Sun Oct 28 13:53:39 2012 @@ -7,18 +7,18 @@ * PROGRAMMERS: Eric Kohl */ -/* INCLUDES ****************************************************************/ +/* INCLUDES ******************************************************************/ #include "samsrv.h" WINE_DEFAULT_DEBUG_CHANNEL(samsrv); -/* GLOBALS ********************************************************************/ +/* GLOBALS *******************************************************************/ static SID_IDENTIFIER_AUTHORITY NtSidAuthority = {SECURITY_NT_AUTHORITY}; -/* FUNCTIONS ***************************************************************/ +/* FUNCTIONS *****************************************************************/ VOID SampStartRpcServer(VOID) @@ -4187,9 +4187,125 @@ SamrRemoveMemberFromAlias(IN SAMPR_HANDLE AliasHandle, IN PRPC_SID MemberId) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -} + PSAM_DB_OBJECT AliasObject; + LPWSTR MemberIdString = NULL; + HANDLE MembersKeyHandle = NULL; + HANDLE MemberKeyHandle = NULL; + ULONG ulValueCount; + NTSTATUS Status; + + TRACE("SamrRemoveMemberFromAlias(%p %p)\n", + AliasHandle, MemberId); + + /* Validate the alias handle */ + Status = SampValidateDbObject(AliasHandle, + SamDbAliasObject, + ALIAS_REMOVE_MEMBER, + &AliasObject); + if (!NT_SUCCESS(Status)) + { + TRACE("failed with status 0x%08lx\n", Status); + return Status; + } + + ConvertSidToStringSidW(MemberId, &MemberIdString); + TRACE("Member SID: %S\n", MemberIdString); + + Status = SampRegOpenKey(AliasObject->MembersKeyHandle, + MemberIdString, + KEY_WRITE | KEY_QUERY_VALUE, + &MemberKeyHandle); + if (!NT_SUCCESS(Status)) + { + TRACE("SampRegOpenKey failed with status 0x%08lx\n", Status); + goto done; + } + + Status = SampRegDeleteValue(MemberKeyHandle, + AliasObject->Name); + if (!NT_SUCCESS(Status)) + { + TRACE("SampRegDeleteValue failed with status 0x%08lx\n", Status); + goto done; + } + + Status = SampRegQueryKeyInfo(MemberKeyHandle, + NULL, + &ulValueCount); + if (!NT_SUCCESS(Status)) + { + TRACE("SampRegQueryKeyInfo failed with status 0x%08lx\n", Status); + goto done; + } + + if (ulValueCount == 0) + { + SampRegCloseKey(MemberKeyHandle); + MemberKeyHandle = NULL; + + Status = SampRegDeleteKey(AliasObject->MembersKeyHandle, + MemberIdString); + if (!NT_SUCCESS(Status)) + { + TRACE("SampRegDeleteKey failed with status 0x%08lx\n", Status); + goto done; + } + } + + Status = SampRegOpenKey(AliasObject->KeyHandle, + L"Members", + KEY_WRITE | KEY_QUERY_VALUE, + &MembersKeyHandle); + if (!NT_SUCCESS(Status)) + { + TRACE("SampRegOpenKey failed with status 0x%08lx\n", Status); + goto done; + } + + Status = SampRegDeleteValue(MembersKeyHandle, + MemberIdString); + if (!NT_SUCCESS(Status)) + { + TRACE("SampRegDeleteValue failed with status 0x%08lx\n", Status); + goto done; + } + + Status = SampRegQueryKeyInfo(MembersKeyHandle, + NULL, + &ulValueCount); + if (!NT_SUCCESS(Status)) + { + TRACE("SampRegQueryKeyInfo failed with status 0x%08lx\n", Status); + goto done; + } + + if (ulValueCount == 0) + { + SampRegCloseKey(MembersKeyHandle); + MembersKeyHandle = NULL; + + Status = SampRegDeleteKey(AliasObject->KeyHandle, + L"Members"); + if (!NT_SUCCESS(Status)) + { + TRACE("SampRegDeleteKey failed with status 0x%08lx\n", Status); + goto done; + } + } + +done: + if (MemberKeyHandle != NULL) + SampRegCloseKey(MemberKeyHandle); + + if (MembersKeyHandle != NULL) + SampRegCloseKey(MembersKeyHandle); + + if (MemberIdString != NULL) + LocalFree(MemberIdString); + + return Status; +} + /* Function 33 */ NTSTATUS @@ -6338,9 +6454,27 @@ SamrRemoveMultipleMembersFromAlias(IN SAMPR_HANDLE AliasHandle, IN PSAMPR_PSID_ARRAY MembersBuffer) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -} + ULONG i; + NTSTATUS Status = STATUS_SUCCESS; + + TRACE("SamrRemoveMultipleMembersFromAlias(%p %p)\n", + AliasHandle, MembersBuffer); + + for (i = 0; i < MembersBuffer->Count; i++) + { + Status = SamrRemoveMemberFromAlias(AliasHandle, + ((PSID *)MembersBuffer->Sids)[i]); + + if (Status == STATUS_MEMBER_IN_ALIAS) + Status = STATUS_SUCCESS; + + if (!NT_SUCCESS(Status)) + break; + } + + return Status; +} + /* Function 54 */ NTSTATUS
12 years, 1 month
1
0
0
0
[hbelusca] 57638: Fix part of build.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sun Oct 28 12:57:03 2012 New Revision: 57638 URL:
http://svn.reactos.org/svn/reactos?rev=57638&view=rev
Log: Fix part of build. Modified: branches/ros-csrss/win32ss/pch.h Modified: branches/ros-csrss/win32ss/pch.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/pch.h?rev=576…
============================================================================== --- branches/ros-csrss/win32ss/pch.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/pch.h [iso-8859-1] Sun Oct 28 12:57:03 2012 @@ -73,7 +73,7 @@ /* CSRSS Header */ #include <csr/csr.h> -#include <csr/csrss.h> // FIXME: data header. +#include <win/winmsg.h> /* Public Win32K headers */ #include <include/callback.h>
12 years, 1 month
1
0
0
0
[hbelusca] 57637: Synchronize with trunk's revision r57636.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sun Oct 28 12:33:23 2012 New Revision: 57637 URL:
http://svn.reactos.org/svn/reactos?rev=57637&view=rev
Log: Synchronize with trunk's revision r57636. Modified: branches/ros-csrss/boot/freeldr/freeldr/fs/fat.c Modified: branches/ros-csrss/boot/freeldr/freeldr/fs/fat.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/boot/freeldr/freeldr/…
============================================================================== --- branches/ros-csrss/boot/freeldr/freeldr/fs/fat.c [iso-8859-1] (original) +++ branches/ros-csrss/boot/freeldr/freeldr/fs/fat.c [iso-8859-1] Sun Oct 28 12:33:23 2012 @@ -906,16 +906,16 @@ UINT32 ThisFatEntOffset; ULONG SectorCount; PUCHAR ReadBuffer; - BOOLEAN status = TRUE;; + BOOLEAN status = TRUE; //TRACE("FatGetFatEntry() Retrieving FAT entry for cluster %d.\n", Cluster); - // We need a buffer for 2 secors - ReadBuffer = HeapAllocate(FrLdrTempHeap, 2 * Volume->BytesPerSector, 'xTAF'); - if (!ReadBuffer) - { - return FALSE; - } + // We need a buffer for 2 secors + ReadBuffer = HeapAllocate(FrLdrTempHeap, 2 * Volume->BytesPerSector, 'xTAF'); + if (!ReadBuffer) + { + return FALSE; + } switch(Volume->FatType) { @@ -929,7 +929,6 @@ TRACE("ThisFatSecNum: %d\n", ThisFatSecNum); TRACE("ThisFatEntOffset: %d\n", ThisFatEntOffset); - if (ThisFatEntOffset == (Volume->BytesPerSector - 1)) { SectorCount = 2; @@ -939,11 +938,11 @@ SectorCount = 1; } - if (!FatReadVolumeSectors(Volume, ThisFatSecNum, SectorCount, ReadBuffer)) - { - status = FALSE; - break; - } + if (!FatReadVolumeSectors(Volume, ThisFatSecNum, SectorCount, ReadBuffer)) + { + status = FALSE; + break; + } fat = *((USHORT *) (ReadBuffer + ThisFatEntOffset)); fat = SWAPW(fat); @@ -963,8 +962,8 @@ if (!FatReadVolumeSectors(Volume, ThisFatSecNum, 1, ReadBuffer)) { - status = FALSE; - break; + status = FALSE; + break; } fat = *((USHORT *) (ReadBuffer + ThisFatEntOffset)); @@ -992,17 +991,17 @@ default: ERR("Unknown FAT type %d\n", Volume->FatType); - status = FALSE; - break; + status = FALSE; + break; } //TRACE("FAT entry is 0x%x.\n", fat); - HeapFree(FrLdrTempHeap, ReadBuffer, 'xTAF'); + HeapFree(FrLdrTempHeap, ReadBuffer, 'xTAF'); *ClusterPointer = fat; - return TRUE; + return status; } ULONG FatCountClustersInChain(PFAT_VOLUME_INFO Volume, ULONG StartCluster)
12 years, 1 month
1
0
0
0
[hbelusca] 57636: [FREELDR] Really use the 'status' variable.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sun Oct 28 12:32:31 2012 New Revision: 57636 URL:
http://svn.reactos.org/svn/reactos?rev=57636&view=rev
Log: [FREELDR] Really use the 'status' variable. Modified: trunk/reactos/boot/freeldr/freeldr/fs/fat.c Modified: trunk/reactos/boot/freeldr/freeldr/fs/fat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/fs/fa…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/fs/fat.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/fs/fat.c [iso-8859-1] Sun Oct 28 12:32:31 2012 @@ -906,16 +906,16 @@ UINT32 ThisFatEntOffset; ULONG SectorCount; PUCHAR ReadBuffer; - BOOLEAN status = TRUE;; + BOOLEAN status = TRUE; //TRACE("FatGetFatEntry() Retrieving FAT entry for cluster %d.\n", Cluster); - // We need a buffer for 2 secors - ReadBuffer = HeapAllocate(FrLdrTempHeap, 2 * Volume->BytesPerSector, 'xTAF'); - if (!ReadBuffer) - { - return FALSE; - } + // We need a buffer for 2 secors + ReadBuffer = HeapAllocate(FrLdrTempHeap, 2 * Volume->BytesPerSector, 'xTAF'); + if (!ReadBuffer) + { + return FALSE; + } switch(Volume->FatType) { @@ -929,7 +929,6 @@ TRACE("ThisFatSecNum: %d\n", ThisFatSecNum); TRACE("ThisFatEntOffset: %d\n", ThisFatEntOffset); - if (ThisFatEntOffset == (Volume->BytesPerSector - 1)) { SectorCount = 2; @@ -939,11 +938,11 @@ SectorCount = 1; } - if (!FatReadVolumeSectors(Volume, ThisFatSecNum, SectorCount, ReadBuffer)) - { - status = FALSE; - break; - } + if (!FatReadVolumeSectors(Volume, ThisFatSecNum, SectorCount, ReadBuffer)) + { + status = FALSE; + break; + } fat = *((USHORT *) (ReadBuffer + ThisFatEntOffset)); fat = SWAPW(fat); @@ -963,8 +962,8 @@ if (!FatReadVolumeSectors(Volume, ThisFatSecNum, 1, ReadBuffer)) { - status = FALSE; - break; + status = FALSE; + break; } fat = *((USHORT *) (ReadBuffer + ThisFatEntOffset)); @@ -992,17 +991,17 @@ default: ERR("Unknown FAT type %d\n", Volume->FatType); - status = FALSE; - break; + status = FALSE; + break; } //TRACE("FAT entry is 0x%x.\n", fat); - HeapFree(FrLdrTempHeap, ReadBuffer, 'xTAF'); + HeapFree(FrLdrTempHeap, ReadBuffer, 'xTAF'); *ClusterPointer = fat; - return TRUE; + return status; } ULONG FatCountClustersInChain(PFAT_VOLUME_INFO Volume, ULONG StartCluster)
12 years, 1 month
1
0
0
0
[hbelusca] 57635: - Synchronize with trunk's revision r57633. [WIN32CSR/BOOTDATA] - Finally get rid of win32csr, being replaced by winsrv and consrv. - Remove it from the subsystem command-line. [W...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sun Oct 28 12:13:03 2012 New Revision: 57635 URL:
http://svn.reactos.org/svn/reactos?rev=57635&view=rev
Log: - Synchronize with trunk's revision r57633. [WIN32CSR/BOOTDATA] - Finally get rid of win32csr, being replaced by winsrv and consrv. - Remove it from the subsystem command-line. [WINSRV] - Move a hack from win32csr to winsrv. Removed: branches/ros-csrss/win32ss/user/win32csr/ Modified: branches/ros-csrss/ (props changed) branches/ros-csrss/boot/bootdata/hivesys_amd64.inf branches/ros-csrss/boot/bootdata/hivesys_arm.inf branches/ros-csrss/boot/bootdata/hivesys_i386.inf branches/ros-csrss/ntoskrnl/ex/win32k.c branches/ros-csrss/ntoskrnl/ps/win32.c branches/ros-csrss/win32ss/CMakeLists.txt branches/ros-csrss/win32ss/gdi/ntgdi/device.c branches/ros-csrss/win32ss/pch.h branches/ros-csrss/win32ss/user/ntuser/accelerator.c branches/ros-csrss/win32ss/user/ntuser/callback.c branches/ros-csrss/win32ss/user/ntuser/callproc.c branches/ros-csrss/win32ss/user/ntuser/class.c branches/ros-csrss/win32ss/user/ntuser/class.h branches/ros-csrss/win32ss/user/ntuser/clipboard.c branches/ros-csrss/win32ss/user/ntuser/csr.c branches/ros-csrss/win32ss/user/ntuser/cursoricon.c branches/ros-csrss/win32ss/user/ntuser/desktop.c branches/ros-csrss/win32ss/user/ntuser/desktop.h branches/ros-csrss/win32ss/user/ntuser/event.c branches/ros-csrss/win32ss/user/ntuser/hook.c branches/ros-csrss/win32ss/user/ntuser/input.c branches/ros-csrss/win32ss/user/ntuser/kbdlayout.c branches/ros-csrss/win32ss/user/ntuser/main.c branches/ros-csrss/win32ss/user/ntuser/menu.c branches/ros-csrss/win32ss/user/ntuser/message.c branches/ros-csrss/win32ss/user/ntuser/monitor.c branches/ros-csrss/win32ss/user/ntuser/msgqueue.c branches/ros-csrss/win32ss/user/ntuser/msgqueue.h branches/ros-csrss/win32ss/user/ntuser/object.c branches/ros-csrss/win32ss/user/ntuser/object.h branches/ros-csrss/win32ss/user/ntuser/simplecall.c branches/ros-csrss/win32ss/user/ntuser/timer.c branches/ros-csrss/win32ss/user/ntuser/window.c branches/ros-csrss/win32ss/user/ntuser/window.h branches/ros-csrss/win32ss/user/ntuser/winsta.c branches/ros-csrss/win32ss/user/user32/windows/cursoricon.c branches/ros-csrss/win32ss/user/winsrv/harderror.c branches/ros-csrss/win32ss/user/winsrv/init.c branches/ros-csrss/win32ss/user/winsrv/shutdown.c Propchange: branches/ros-csrss/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 28 12:13:03 2012 @@ -13,4 +13,4 @@ /branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859 /branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567 /branches/wlan-bringup:54809-54998 -/trunk/reactos:57561-57633 +/trunk/reactos:57561-57634 Modified: branches/ros-csrss/boot/bootdata/hivesys_amd64.inf URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/boot/bootdata/hivesys…
============================================================================== --- branches/ros-csrss/boot/bootdata/hivesys_amd64.inf [iso-8859-1] (original) +++ branches/ros-csrss/boot/bootdata/hivesys_amd64.inf [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -1239,7 +1239,7 @@ HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Optional",0x00010000,"Posix" HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Posix",0x00020000,"%SystemRoot%\system32\psxss.exe" HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Required",0x00010000,"Debug","Windows" -HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Windows",0x00020000,"%SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,12288,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=consrv:ConServerDllInitialization,2 ServerDll=win32csr:Win32CsrInitialization,4 ProfileControl=Off MaxRequestThreads=16" +HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Windows",0x00020000,"%SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,12288,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=consrv:ConServerDllInitialization,2 ProfileControl=Off MaxRequestThreads=16" ; WOW Support HKLM,"SYSTEM\CurrentControlSet\Control\Wow","",0x00000000,"" Modified: branches/ros-csrss/boot/bootdata/hivesys_arm.inf URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/boot/bootdata/hivesys…
============================================================================== --- branches/ros-csrss/boot/bootdata/hivesys_arm.inf [iso-8859-1] (original) +++ branches/ros-csrss/boot/bootdata/hivesys_arm.inf [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -794,7 +794,7 @@ HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Optional",0x00010000,"Posix" HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Posix",0x00020000,"%SystemRoot%\system32\psxss.exe" HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Required",0x00010000,"Debug","Windows" -HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Windows",0x00020000,"%SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,12288,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=consrv:ConServerDllInitialization,2 ServerDll=win32csr:Win32CsrInitialization,4 ProfileControl=Off MaxRequestThreads=16" +HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Windows",0x00020000,"%SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,12288,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=consrv:ConServerDllInitialization,2 ProfileControl=Off MaxRequestThreads=16" ; WOW Support HKLM,"SYSTEM\CurrentControlSet\Control\Wow","",0x00000000,"" Modified: branches/ros-csrss/boot/bootdata/hivesys_i386.inf URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/boot/bootdata/hivesys…
============================================================================== --- branches/ros-csrss/boot/bootdata/hivesys_i386.inf [iso-8859-1] (original) +++ branches/ros-csrss/boot/bootdata/hivesys_i386.inf [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -1239,7 +1239,7 @@ HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Optional",0x00010000,"Posix" HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Posix",0x00020000,"%SystemRoot%\system32\psxss.exe" HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Required",0x00010000,"Debug","Windows" -HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Windows",0x00020000,"%SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,12288,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=consrv:ConServerDllInitialization,2 ServerDll=win32csr:Win32CsrInitialization,4 ProfileControl=Off MaxRequestThreads=16" +HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems","Windows",0x00020000,"%SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,12288,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=consrv:ConServerDllInitialization,2 ProfileControl=Off MaxRequestThreads=16" ; WOW Support HKLM,"SYSTEM\CurrentControlSet\Control\Wow","",0x00000000,"" Modified: branches/ros-csrss/ntoskrnl/ex/win32k.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/ntoskrnl/ex/win32k.c?…
============================================================================== --- branches/ros-csrss/ntoskrnl/ex/win32k.c [iso-8859-1] (original) +++ branches/ros-csrss/ntoskrnl/ex/win32k.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -40,6 +40,8 @@ PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExpWindowStationObjectOkToClose = NULL; PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExpDesktopObjectOkToClose = NULL; PKWIN32_DELETEMETHOD_CALLOUT ExpDesktopObjectDelete = NULL; +PKWIN32_OPENMETHOD_CALLOUT ExpDesktopObjectOpen = NULL; +PKWIN32_CLOSEMETHOD_CALLOUT ExpDesktopObjectClose = NULL; /* FUNCTIONS ****************************************************************/ @@ -131,6 +133,44 @@ /* Call the Registered Callback */ ExpDesktopObjectDelete(&Parameters); +} + +NTSTATUS +NTAPI +ExpDesktopOpen(IN OB_OPEN_REASON Reason, + IN PEPROCESS Process OPTIONAL, + IN PVOID ObjectBody, + IN ACCESS_MASK GrantedAccess, + IN ULONG HandleCount) +{ + WIN32_OPENMETHOD_PARAMETERS Parameters; + + Parameters.OpenReason = Reason; + Parameters.Process = Process; + Parameters.Object = ObjectBody; + Parameters.GrantedAccess = GrantedAccess; + Parameters.HandleCount = HandleCount; + + return ExpDesktopObjectOpen(&Parameters); +} + +VOID +NTAPI +ExpDesktopClose(IN PEPROCESS Process OPTIONAL, + IN PVOID Object, + IN ACCESS_MASK GrantedAccess, + IN ULONG ProcessHandleCount, + IN ULONG SystemHandleCount) +{ + WIN32_CLOSEMETHOD_PARAMETERS Parameters; + + Parameters.Process = Process; + Parameters.Object = Object; + Parameters.AccessMask = GrantedAccess; + Parameters.ProcessHandleCount = ProcessHandleCount; + Parameters.SystemHandleCount = SystemHandleCount; + + ExpDesktopObjectClose(&Parameters); } BOOLEAN @@ -169,6 +209,8 @@ ObjectTypeInitializer.DeleteProcedure = ExpDesktopDelete; ObjectTypeInitializer.ParseProcedure = NULL; ObjectTypeInitializer.OkayToCloseProcedure = ExpDesktopOkToClose; + ObjectTypeInitializer.OpenProcedure = ExpDesktopOpen; + ObjectTypeInitializer.CloseProcedure = ExpDesktopClose; ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, Modified: branches/ros-csrss/ntoskrnl/ps/win32.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/ntoskrnl/ps/win32.c?r…
============================================================================== --- branches/ros-csrss/ntoskrnl/ps/win32.c [iso-8859-1] (original) +++ branches/ros-csrss/ntoskrnl/ps/win32.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -23,6 +23,8 @@ extern PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExpWindowStationObjectOkToClose; extern PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExpDesktopObjectOkToClose; extern PKWIN32_DELETEMETHOD_CALLOUT ExpDesktopObjectDelete; +extern PKWIN32_OPENMETHOD_CALLOUT ExpDesktopObjectOpen; +extern PKWIN32_CLOSEMETHOD_CALLOUT ExpDesktopObjectClose; extern PKWIN32_POWEREVENT_CALLOUT PopEventCallout; /* PRIVATE FUNCTIONS *********************************************************/ @@ -121,6 +123,8 @@ ExpWindowStationObjectOkToClose = CalloutData->WindowStationOkToCloseProcedure; ExpDesktopObjectOkToClose = CalloutData->DesktopOkToCloseProcedure; ExpDesktopObjectDelete = CalloutData->DesktopDeleteProcedure; + ExpDesktopObjectOpen = CalloutData->DesktopOpenProcedure; + ExpDesktopObjectClose = CalloutData->DesktopCloseProcedure; PopEventCallout = CalloutData->PowerEventCallout; KeGdiFlushUserBatch = CalloutData->BatchFlushRoutine; } Modified: branches/ros-csrss/win32ss/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/CMakeLists.tx…
============================================================================== --- branches/ros-csrss/win32ss/CMakeLists.txt [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/CMakeLists.txt [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -14,7 +14,6 @@ add_subdirectory(reactx) add_subdirectory(user/consrv) add_subdirectory(user/user32) -add_subdirectory(user/win32csr) add_subdirectory(user/winsrv) spec2def(win32k.sys win32k.spec ADD_IMPORTLIB) Modified: branches/ros-csrss/win32ss/gdi/ntgdi/device.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/gdi/ntgdi/dev…
============================================================================== --- branches/ros-csrss/win32ss/gdi/ntgdi/device.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/gdi/ntgdi/device.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -32,15 +32,15 @@ SURFOBJ *pso; PDESKTOP rpDesk; + /* Create surface */ + pso = &PDEVOBJ_pSurface(gppdevPrimary)->SurfObj; + SurfSize = pso->sizlBitmap; + /* Attach monitor */ UserAttachMonitor((HDEV)gppdevPrimary); DPRINT("IntCreatePrimarySurface, gppdevPrimary=%p, gppdevPrimary->pSurface = %p\n", gppdevPrimary, gppdevPrimary->pSurface); - - /* Create surface */ - pso = &PDEVOBJ_pSurface(gppdevPrimary)->SurfObj; - SurfSize = pso->sizlBitmap; /* Put the pointer in the center of the screen */ gpsi->ptCursor.x = pso->sizlBitmap.cx / 2; Modified: branches/ros-csrss/win32ss/pch.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/pch.h?rev=576…
============================================================================== --- branches/ros-csrss/win32ss/pch.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/pch.h [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -36,6 +36,7 @@ /* Win32 headers */ /* FIXME: Defines in winbase.h that we need... */ typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; +#define MAKEINTATOM(i) (LPWSTR)((ULONG_PTR)((WORD)(i))) #define WINBASEAPI #define STARTF_USESIZE 2 #define STARTF_USEPOSITION 4 Modified: branches/ros-csrss/win32ss/user/ntuser/accelerator.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/a…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/accelerator.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/accelerator.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -257,7 +257,7 @@ RETURN( (HACCEL) NULL ); } - Accel = UserCreateObject(gHandleTable, NULL, (PHANDLE)&hAccel, otAccel, sizeof(ACCELERATOR_TABLE)); + Accel = UserCreateObject(gHandleTable, NULL, NULL, (PHANDLE)&hAccel, otAccel, sizeof(ACCELERATOR_TABLE)); if (Accel == NULL) { Modified: branches/ros-csrss/win32ss/user/ntuser/callback.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/callback.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/callback.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -130,6 +130,9 @@ BOOL bResult; ULONG_PTR pLibNameBuffer = 0, pInitFuncBuffer = 0; + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); + TRACE("co_IntClientLoadLibrary: %S, %S, %d, %d\n", pstrLibName->Buffer, pstrLibName->Buffer, Unload, ApiHook); /* Calculate the size of the argument */ @@ -235,6 +238,9 @@ PWND pWnd; ULONG ResultLength; NTSTATUS Status; + + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); Arguments.Callback = CompletionCallback; Arguments.Wnd = hWnd; @@ -280,6 +286,9 @@ ULONG ResultLength; ULONG ArgumentLength; LRESULT Result; + + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); if (0 < lParamBufferSize) { @@ -363,6 +372,9 @@ NTSTATUS Status; PVOID ResultPointer; ULONG ResultLength; + + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); ResultPointer = NULL; ResultLength = sizeof(LRESULT); @@ -394,6 +406,8 @@ return (HMENU)Result; } +extern HCURSOR gDesktopCursor; + BOOL APIENTRY co_IntLoadDefaultCursors(VOID) { @@ -402,8 +416,11 @@ ULONG ResultLength; BOOL DefaultCursor = TRUE; + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); + ResultPointer = NULL; - ResultLength = sizeof(LRESULT); + ResultLength = sizeof(HCURSOR); UserLeaveCo(); @@ -414,6 +431,9 @@ &ResultLength); UserEnterCo(); + + /* HACK: The desktop class doen't have a proper cursor yet, so set it here */ + gDesktopCursor = *((HCURSOR*)ResultPointer); if (!NT_SUCCESS(Status)) { @@ -448,6 +468,8 @@ UINT lParamSize = 0; ASSERT(Proc); + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); pti = PsGetCurrentThreadWin32Thread(); if (pti->TIF_flags & TIF_INCLEANUP) @@ -834,6 +856,9 @@ ULONG ArgumentLength, ResultLength; PVOID Argument, ResultPointer; + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); + ArgumentLength = ResultLength = 0; Argument = ResultPointer = NULL; Modified: branches/ros-csrss/win32ss/user/ntuser/callproc.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/callproc.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/callproc.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -35,6 +35,7 @@ NewCallProc = (PCALLPROCDATA)UserCreateObject(gHandleTable, Desktop, + NULL, &Handle, otCallProc, sizeof(CALLPROCDATA)); Modified: branches/ros-csrss/win32ss/user/ntuser/class.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/class.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/class.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -641,9 +641,17 @@ PCLS Class; ASSERT(BaseClass->pclsBase == BaseClass); - Class = IntGetClassForDesktop(BaseClass, - ClassLink, - Desktop); + if (Desktop != NULL) + { + Class = IntGetClassForDesktop(BaseClass, + ClassLink, + Desktop); + } + else + { + Class = BaseClass; + } + if (Class != NULL) { Class->cWndReferenceCount++; @@ -1286,13 +1294,16 @@ } PCLS -IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance) +IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance, BOOL bDesktopThread) { PCLS *ClassLink, Class = NULL; RTL_ATOM ClassAtom; PTHREADINFO pti; - pti = PsGetCurrentThreadWin32Thread(); + if (bDesktopThread) + pti = gptiDesktopThread; + else + pti = PsGetCurrentThreadWin32Thread(); if ( !(pti->ppi->W32PF_flags & W32PF_CLASSESREGISTERED )) { Modified: branches/ros-csrss/win32ss/user/ntuser/class.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/class.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/class.h [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -39,7 +39,7 @@ IN PPROCESSINFO pi); PCLS -IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance); +IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance, BOOL bDesktopThread); BOOL FASTCALL UserRegisterSystemClasses(VOID); Modified: branches/ros-csrss/win32ss/user/ntuser/clipboard.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/clipboard.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/clipboard.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -182,6 +182,7 @@ /* Create the clipboard data */ pClipboardData = (PCLIPBOARDDATA)UserCreateObject(gHandleTable, NULL, + NULL, &hMem, otClipBoardData, cjDataSize); @@ -293,7 +294,7 @@ PCLIPBOARDDATA pMemObj; HANDLE hMem; - pMemObj = (PCLIPBOARDDATA)UserCreateObject(gHandleTable, NULL, &hMem, otClipBoardData, + pMemObj = (PCLIPBOARDDATA)UserCreateObject(gHandleTable, NULL, NULL, &hMem, otClipBoardData, sizeof(CLIPBOARDDATA) + sizeof(LCID)); if (pMemObj) { @@ -1080,7 +1081,7 @@ UserEnterExclusive(); /* Create Clipboard data object */ - pMemObj = UserCreateObject(gHandleTable, NULL, &hMem, otClipBoardData, sizeof(CLIPBOARDDATA) + cbData); + pMemObj = UserCreateObject(gHandleTable, NULL, NULL, &hMem, otClipBoardData, sizeof(CLIPBOARDDATA) + cbData); if (!pMemObj) goto cleanup; Modified: branches/ros-csrss/win32ss/user/ntuser/csr.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/csr.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/csr.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -93,74 +93,4 @@ return Status; } - -NTSTATUS -APIENTRY -CsrInsertObject(HANDLE ObjectHandle, - ACCESS_MASK DesiredAccess, - PHANDLE Handle) -{ - NTSTATUS Status; - HANDLE CsrProcessHandle; - OBJECT_ATTRIBUTES ObjectAttributes; - CLIENT_ID Cid; - - /* Put CSR'S CID */ - Cid.UniqueProcess = CsrProcess->UniqueProcessId; - Cid.UniqueThread = 0; - - /* Empty Attributes */ - InitializeObjectAttributes(&ObjectAttributes, - NULL, - 0, - NULL, - NULL); - - /* Get a Handle to Csrss */ - Status = ZwOpenProcess(&CsrProcessHandle, - PROCESS_DUP_HANDLE, - &ObjectAttributes, - &Cid); - - if ((NT_SUCCESS(Status))) - { - /* Duplicate the Handle */ - Status = ZwDuplicateObject(NtCurrentProcess(), - ObjectHandle, - CsrProcessHandle, - Handle, - DesiredAccess, - OBJ_INHERIT, - 0); - - /* Close our handle to CSRSS */ - ZwClose(CsrProcessHandle); - } - - return Status; -} - -NTSTATUS FASTCALL -CsrCloseHandle(HANDLE Handle) -{ - NTSTATUS Status; - PEPROCESS OldProcess; - - /* Switch to the process in which the handle is valid */ - OldProcess = PsGetCurrentProcess(); - if (CsrProcess != OldProcess) - { - KeAttachProcess(&CsrProcess->Pcb); - } - - Status = ZwClose(Handle); - - if (CsrProcess != OldProcess) - { - KeDetachProcess(); - } - - return Status; -} - /* EOF */ Modified: branches/ros-csrss/win32ss/user/ntuser/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/cursoricon.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/cursoricon.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -209,7 +209,7 @@ PCURICON_OBJECT CurIcon; HANDLE hCurIcon; - CurIcon = UserCreateObject(gHandleTable, NULL, &hCurIcon, otCursorIcon, sizeof(CURICON_OBJECT)); + CurIcon = UserCreateObject(gHandleTable, NULL, NULL, &hCurIcon, otCursorIcon, sizeof(CURICON_OBJECT)); if (!CurIcon) { Modified: branches/ros-csrss/win32ss/user/ntuser/desktop.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/d…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/desktop.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/desktop.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -11,11 +11,17 @@ #include <win32k.h> DBG_DEFAULT_CHANNEL(UserDesktop); -static -VOID -IntFreeDesktopHeap( - IN OUT PDESKTOP Desktop -); +static NTSTATUS +UserInitializeDesktop(PDESKTOP pdesk, PUNICODE_STRING DesktopName, PWINSTATION_OBJECT pwinsta); + +static NTSTATUS +IntMapDesktopView(IN PDESKTOP pdesk); + +static NTSTATUS +IntUnmapDesktopView(IN PDESKTOP pdesk); + +static VOID +IntFreeDesktopHeap(IN PDESKTOP pdesk); /* GLOBALS *******************************************************************/ @@ -23,6 +29,8 @@ PDESKTOP InputDesktop = NULL; HDESK InputDesktopHandle = NULL; HDC ScreenDeviceContext = NULL; +PTHREADINFO gptiDesktopThread; +HCURSOR gDesktopCursor = NULL; /* OBJECT CALLBACKS **********************************************************/ @@ -112,17 +120,16 @@ sizeof(DESKTOP), 0, 0, - (PVOID)&Desktop); + (PVOID*)&Desktop); if (!NT_SUCCESS(Status)) return Status; - /* Initialize shell hook window list and set the parent */ - RtlZeroMemory(Desktop, sizeof(DESKTOP)); - InitializeListHead(&Desktop->ShellHookWindows); - Desktop->rpwinstaParent = (PWINSTATION_OBJECT)ParseObject; - - /* Put the desktop on the window station's list of associated desktops */ - InsertTailList(&Desktop->rpwinstaParent->DesktopListHead, - &Desktop->ListEntry); + /* Initialize the desktop */ + Status = UserInitializeDesktop(Desktop, RemainingName, WinStaObject); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(Desktop); + return Status; + } /* Set the desktop object and return success */ *Object = Desktop; @@ -133,22 +140,29 @@ VOID APIENTRY IntDesktopObjectDelete(PWIN32_DELETEMETHOD_PARAMETERS Parameters) { - PDESKTOP Desktop = (PDESKTOP)Parameters->Object; - - TRACE("Deleting desktop object 0x%p\n", Desktop); + PDESKTOP pdesk = (PDESKTOP)Parameters->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(&Desktop->ListEntry); - - IntFreeDesktopHeap(Desktop); + RemoveEntryList(&pdesk->ListEntry); + + /* Free the heap */ + IntFreeDesktopHeap(pdesk); } NTSTATUS NTAPI IntDesktopOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters) { - PTHREADINFO pti; - - pti = PsGetCurrentThreadWin32Thread(); + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); if( pti == NULL) { @@ -165,6 +179,29 @@ return STATUS_SUCCESS; } + +NTSTATUS NTAPI IntDesktopObjectOpen(PWIN32_OPENMETHOD_PARAMETERS Parameters) +{ + PPROCESSINFO ppi = PsGetProcessWin32Process(Parameters->Process); + if (ppi == NULL) + return STATUS_SUCCESS; + + return IntMapDesktopView((PDESKTOP)Parameters->Object); +} + +NTSTATUS NTAPI IntDesktopObjectClose(PWIN32_CLOSEMETHOD_PARAMETERS Parameters) +{ + PPROCESSINFO ppi = PsGetProcessWin32Process(Parameters->Process); + if (ppi == NULL) + { + /* This happens when the process leaks desktop handles. + * At this point the PPROCESSINFO is already destroyed */ + return STATUS_SUCCESS; + } + + return IntUnmapDesktopView((PDESKTOP)Parameters->Object); +} + /* PRIVATE FUNCTIONS **********************************************************/ @@ -596,8 +633,66 @@ case WM_SYSCOLORCHANGE: co_UserRedrawWindow(Wnd, NULL, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); return TRUE; - } - return FALSE; // Not processed so go with callback. + case WM_SETCURSOR: + { + PCURICON_OBJECT pcurOld, pcurNew; + pcurNew = UserGetCurIconObject(gDesktopCursor); + if (!pcurNew) + { + return TRUE; + } + pcurOld = UserSetCursor(pcurNew, FALSE); + if (pcurOld) + { + UserDereferenceObject(pcurOld); + } + } + } + return TRUE; /* We are done. Do not do any callbacks to user mode */ +} + +BOOL FASTCALL +UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult) +{ + *lResult = 0; + + switch(Msg) + { + case WM_NCCREATE: + pwnd->fnid |= FNID_MESSAGEWND; + *lResult = (LRESULT)TRUE; + break; + case WM_DESTROY: + pwnd->fnid |= FNID_DESTROY; + break; + } + + return TRUE; /* We are done. Do not do any callbacks to user mode */ +} + +VOID NTAPI DesktopThreadMain() +{ + BOOL Ret; + MSG Msg; + + gptiDesktopThread = PsGetCurrentThreadWin32Thread(); + + UserEnterExclusive(); + + /* Register system classes. This thread does not belong to any desktop so the + classes will be allocated from the shared heap */ + UserRegisterSystemClasses(); + + while(TRUE) + { + Ret = co_IntGetPeekMessage(&Msg, 0, 0, 0, PM_REMOVE, TRUE); + if (Ret) + { + IntDispatchMessage(&Msg); + } + } + + UserLeave(); } HDC FASTCALL @@ -813,6 +908,8 @@ static VOID IntFreeDesktopHeap(IN OUT PDESKTOP Desktop) { + /* FIXME: Disable until unmapping works in mm */ +#if 0 if (Desktop->pheapDesktop != NULL) { MmUnmapViewInSessionSpace(Desktop->pheapDesktop); @@ -824,6 +921,7 @@ ObDereferenceObject(Desktop->hsectionDesktop); Desktop->hsectionDesktop = NULL; } +#endif } BOOL FASTCALL @@ -1030,6 +1128,61 @@ return TRUE; } +static NTSTATUS +UserInitializeDesktop(PDESKTOP pdesk, PUNICODE_STRING DesktopName, PWINSTATION_OBJECT pwinsta) +{ + PVOID DesktopHeapSystemBase = NULL; + ULONG_PTR HeapSize = 400 * 1024; + SIZE_T DesktopInfoSize; + ULONG i; + + TRACE("UserInitializeDesktop desktop 0x%p with name %wZ\n", pdesk, DesktopName); + + RtlZeroMemory(pdesk, sizeof(DESKTOP)); + + /* Link the desktop with the parent window station */ + pdesk->rpwinstaParent = pwinsta; + InsertTailList(&pwinsta->DesktopListHead, &pdesk->ListEntry); + + /* Create the desktop heap */ + pdesk->hsectionDesktop = NULL; + 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; +} + /* SYSCALLS *******************************************************************/ /* @@ -1073,43 +1226,35 @@ DWORD dwFlags, ACCESS_MASK dwDesiredAccess) { - PDESKTOP DesktopObject; - UNICODE_STRING DesktopName; + PDESKTOP pdesk = NULL; NTSTATUS Status = STATUS_SUCCESS; - HDESK Desktop; - CSR_API_MESSAGE Request; - PVOID DesktopHeapSystemBase = NULL; - SIZE_T DesktopInfoSize; + HDESK hdesk; BOOLEAN Context; - ULONG_PTR HeapSize = 400 * 1024; /* FIXME: Windows uses 200KB by default */ UNICODE_STRING ClassName; LARGE_STRING WindowName; BOOL NoHooks = FALSE; PWND pWnd = NULL; CREATESTRUCTW Cs; - INT i; PTHREADINFO ptiCurrent; + PCLS pcls; + DECLARE_RETURN(HDESK); TRACE("Enter NtUserCreateDesktop\n"); UserEnterExclusive(); ptiCurrent = PsGetCurrentThreadWin32Thread(); - if (ptiCurrent) - { + 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; - } - /*else - {ERR("NtUserCreateDesktop: No ptiCurrent\n");}*/ - DesktopName.Buffer = NULL; + 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, @@ -1117,142 +1262,98 @@ NULL, dwDesiredAccess, (PVOID)&Context, - (HANDLE*)&Desktop); - if (!NT_SUCCESS(Status)) RETURN(NULL); + (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( Desktop); - } - - /* Capture desktop name */ - _SEH2_TRY - { - ProbeForRead( ObjectAttributes, sizeof(OBJECT_ATTRIBUTES), 1); - - Status = IntSafeCopyUnicodeStringTerminateNULL(&DesktopName, ObjectAttributes->ObjectName); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Status = _SEH2_GetExceptionCode(); - } - _SEH2_END - - if (! NT_SUCCESS(Status)) - { - ERR("Failed reading Object Attributes from user space.\n"); - SetLastNtError(Status); - RETURN( NULL); + RETURN( hdesk); } /* Reference the desktop */ - Status = ObReferenceObjectByHandle(Desktop, + Status = ObReferenceObjectByHandle(hdesk, 0, ExDesktopObjectType, KernelMode, - (PVOID)&DesktopObject, + (PVOID*)&pdesk, NULL); if (!NT_SUCCESS(Status)) { ERR("Failed to reference desktop object\n"); + SetLastNtError(Status); RETURN(NULL); } - TRACE("NtUserCreateDesktop created desktop 0x%p with name %wZ\n", DesktopObject, &DesktopName); - - DesktopObject->hsectionDesktop = NULL; - DesktopObject->pheapDesktop = UserCreateHeap(&DesktopObject->hsectionDesktop, - &DesktopHeapSystemBase, - HeapSize); - if (DesktopObject->pheapDesktop == NULL) - { - ObDereferenceObject(DesktopObject); - ERR("Failed to create desktop heap!\n"); - RETURN(NULL); - } - - DesktopInfoSize = sizeof(DESKTOPINFO) + DesktopName.Length + sizeof(WCHAR); - - DesktopObject->pDeskInfo = RtlAllocateHeap(DesktopObject->pheapDesktop, - HEAP_NO_SERIALIZE, - DesktopInfoSize); - - if (DesktopObject->pDeskInfo == NULL) - { - ObDereferenceObject(DesktopObject); - ERR("Failed to create the DESKTOP structure!\n"); - RETURN(NULL); - } - - RtlZeroMemory(DesktopObject->pDeskInfo, - DesktopInfoSize); - - DesktopObject->pDeskInfo->pvDesktopBase = DesktopHeapSystemBase; - DesktopObject->pDeskInfo->pvDesktopLimit = (PVOID)((ULONG_PTR)DesktopHeapSystemBase + HeapSize); - RtlCopyMemory(DesktopObject->pDeskInfo->szDesktopName, - DesktopName.Buffer, - DesktopName.Length + sizeof(WCHAR)); - - /* Initialize some local (to win32k) desktop state. */ - InitializeListHead(&DesktopObject->PtiList); - DesktopObject->ActiveMessageQueue = NULL; - - /* Setup Global Hooks. */ - for (i = 0; i < NB_HOOKS; i++) - { - InitializeListHead(&DesktopObject->pDeskInfo->aphkStart[i]); - } - - /* - * Create a handle for CSRSS and notify CSRSS for Creating Desktop Background Windows and Threads. + if (!ptiCurrent->rpdesk) IntSetThreadDesktop(hdesk,FALSE); + + /* 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 */ - Request.ApiNumber = CSR_CREATE_API_NUMBER(CSR_GUI, CREATE_DESKTOP); - Status = CsrInsertObject(Desktop, - GENERIC_ALL, - (HANDLE*)&Request.Data.CreateDesktopRequest.DesktopHandle); - if (! NT_SUCCESS(Status)) - { - ERR("Failed to create desktop handle for CSRSS\n"); - ZwClose(Desktop); - SetLastNtError(Status); - RETURN( NULL); - } - - Status = co_CsrNotify((PCSR_API_MESSAGE)&Request, - sizeof(CSR_API_MESSAGE)); - if (! NT_SUCCESS(Status)) - { - CsrCloseHandle(Request.Data.CreateDesktopRequest.DesktopHandle); - ERR("Failed to notify CSRSS about new desktop\n"); - ZwClose(Desktop); - SetLastNtError(Status); - RETURN( NULL); - } - - if (ptiCurrent && !ptiCurrent->rpdesk) IntSetThreadDesktop(Desktop,FALSE); - - ClassName.Buffer = ((PWSTR)((ULONG_PTR)(WORD)(gpsi->atomSysClass[ICLS_HWNDMESSAGE]))); + 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->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! Leave it to Timo to not pass on notes! + Cs.hInstance = hModClient; // hModuleWin; // Server side winproc! Cs.lpszName = (LPCWSTR) &WindowName; Cs.lpszClass = (LPCWSTR) &ClassName; - - pWnd = co_UserCreateWindowEx(&Cs, &ClassName, &WindowName, NULL); - if (!pWnd) - { - ERR("Failed to create Message window handle\n"); - } - else - { - DesktopObject->spwndMessage = pWnd; - } + 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) @@ -1262,14 +1363,18 @@ The rest is same as message window.
http://msdn.microsoft.com/en-us/library/bb760250(VS.85).aspx
*/ - RETURN( Desktop); + RETURN( hdesk); CLEANUP: - if(DesktopName.Buffer != NULL) - { - ExFreePoolWithTag(DesktopName.Buffer, TAG_STRING); - } - if (!NoHooks && ptiCurrent) + 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; Modified: branches/ros-csrss/win32ss/user/ntuser/desktop.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/d…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/desktop.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/desktop.h [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -73,6 +73,7 @@ extern HDESK InputDesktopHandle; extern PCLS DesktopWindowClass; extern HDC ScreenDeviceContext; +extern PTHREADINFO gptiDesktopThread; typedef struct _SHELL_HOOK_WINDOW { @@ -104,6 +105,12 @@ NTSTATUS NTAPI IntDesktopOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters); +NTSTATUS NTAPI +IntDesktopObjectOpen(PWIN32_OPENMETHOD_PARAMETERS Parameters); + +NTSTATUS NTAPI +IntDesktopObjectClose(PWIN32_CLOSEMETHOD_PARAMETERS Parameters); + HDC FASTCALL IntGetScreenDC(VOID); @@ -283,4 +290,6 @@ PWND FASTCALL co_GetDesktopWindow(PWND); BOOL FASTCALL IntPaintDesktop(HDC); BOOL FASTCALL DesktopWindowProc(PWND, UINT, WPARAM, LPARAM, LRESULT *); +BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult); +VOID NTAPI DesktopThreadMain(); /* EOF */ Modified: branches/ros-csrss/win32ss/user/ntuser/event.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/e…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/event.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/event.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -378,7 +378,7 @@ } } // Creator, pti is set here. - pEH = UserCreateObject(gHandleTable, NULL, &Handle, otEvent, sizeof(EVENTHOOK)); + pEH = UserCreateObject(gHandleTable, NULL, NULL, &Handle, otEvent, sizeof(EVENTHOOK)); if (pEH) { InsertTailList(&GlobalEvents->Events, &pEH->Chain); Modified: branches/ros-csrss/win32ss/user/ntuser/hook.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/h…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/hook.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/hook.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -1569,7 +1569,7 @@ } ObDereferenceObject(WinStaObj); - Hook = UserCreateObject(gHandleTable, NULL, (PHANDLE)&Handle, otHook, sizeof(HOOK)); + Hook = UserCreateObject(gHandleTable, NULL, NULL, (PHANDLE)&Handle, otHook, sizeof(HOOK)); if (!Hook) { Modified: branches/ros-csrss/win32ss/user/ntuser/input.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/i…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/input.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/input.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -304,6 +304,7 @@ switch (Type) { case 0: RawInputThreadMain(); break; + case 1: DesktopThreadMain(); break; default: ERR("Wrong type: %x\n", Type); } Modified: branches/ros-csrss/win32ss/user/ntuser/kbdlayout.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/k…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/kbdlayout.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/kbdlayout.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -131,7 +131,7 @@ L"Control\\Keyboard Layouts\\"; /* Create keyboard layout file object */ - pkf = UserCreateObject(gHandleTable, NULL, NULL, otKBDfile, sizeof(KBDFILE)); + pkf = UserCreateObject(gHandleTable, NULL, NULL, NULL, otKBDfile, sizeof(KBDFILE)); if (!pkf) { ERR("Failed to create object!\n"); @@ -206,7 +206,7 @@ PKL pKl; /* Create keyboard layout object */ - pKl = UserCreateObject(gHandleTable, NULL, NULL, otKBDlayout, sizeof(KL)); + pKl = UserCreateObject(gHandleTable, NULL, NULL, NULL, otKBDlayout, sizeof(KL)); if (!pKl) { ERR("Failed to create object!\n"); Modified: branches/ros-csrss/win32ss/user/ntuser/main.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/m…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/main.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/main.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -304,6 +304,7 @@ if (ptiCurrent->KeyboardLayout) UserReferenceObject(ptiCurrent->KeyboardLayout); ptiCurrent->TIF_flags &= ~TIF_INCLEANUP; + ptiCurrent->pcti = &ptiCurrent->cti; /* Initialize the CLIENTINFO */ pci = (PCLIENTINFO)pTeb->Win32ClientInfo; @@ -624,14 +625,16 @@ DPRINT("Win32k hInstance 0x%p!\n",hModuleWin); /* Register Object Manager Callbacks */ + CalloutData.ProcessCallout = Win32kProcessCallback; + CalloutData.ThreadCallout = Win32kThreadCallback; CalloutData.WindowStationParseProcedure = IntWinStaObjectParse; CalloutData.WindowStationDeleteProcedure = IntWinStaObjectDelete; + CalloutData.WindowStationOkToCloseProcedure = IntWinstaOkToClose; + CalloutData.DesktopOkToCloseProcedure = IntDesktopOkToClose; CalloutData.DesktopDeleteProcedure = IntDesktopObjectDelete; - CalloutData.ProcessCallout = Win32kProcessCallback; - CalloutData.ThreadCallout = Win32kThreadCallback; + CalloutData.DesktopCloseProcedure = IntDesktopObjectClose; + CalloutData.DesktopOpenProcedure = IntDesktopObjectOpen; CalloutData.BatchFlushRoutine = NtGdiFlushUserBatch; - CalloutData.DesktopOkToCloseProcedure = IntDesktopOkToClose; - CalloutData.WindowStationOkToCloseProcedure = IntWinstaOkToClose; /* Register our per-process and per-thread structures. */ PsEstablishWin32Callouts((PWIN32_CALLOUTS_FPNS)&CalloutData); Modified: branches/ros-csrss/win32ss/user/ntuser/menu.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/m…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/menu.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/menu.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -249,7 +249,8 @@ PPROCESSINFO CurrentWin32Process; Menu = (PMENU_OBJECT)UserCreateObject( gHandleTable, - NULL, + NULL, + NULL, Handle, otMenu, sizeof(MENU_OBJECT)); @@ -360,8 +361,9 @@ return NULL; Menu = (PMENU_OBJECT)UserCreateObject( gHandleTable, - NULL, - &hMenu, + NULL, + NULL, + &hMenu, otMenu, sizeof(MENU_OBJECT)); if(!Menu) Modified: branches/ros-csrss/win32ss/user/ntuser/message.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/m…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/message.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/message.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -714,6 +714,13 @@ pMsg->lParam, &retval); break; + case FNID_MESSAGEWND: + DoCallBack = !UserMessageWindowProc( Window, + pMsg->message, + pMsg->wParam, + pMsg->lParam, + &retval); + break; } } @@ -1306,6 +1313,9 @@ { case FNID_DESKTOP: DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParam,(LRESULT*)&Result); + break; + case FNID_MESSAGEWND: + DoCallBack = !UserMessageWindowProc(Window, Msg, wParam, lParam,(LRESULT*)&Result); break; } if (!DoCallBack) @@ -1589,6 +1599,9 @@ { case FNID_DESKTOP: DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParamPacked, (LRESULT*)&Result); + break; + case FNID_MESSAGEWND: + DoCallBack = !UserMessageWindowProc(Window, Msg, wParam, lParam,(LRESULT*)&Result); break; } } @@ -2233,6 +2246,16 @@ } break; } + + case FNID_MESSAGEWND: + { + Window = UserGetWindowObject(hWnd); + if (Window) + { + Ret = !UserMessageWindowProc(Window, Msg, wParam, lParam,&lResult); + } + break; + } case FNID_DEFWINDOWPROC: /* Validate input */ if (hWnd) Modified: branches/ros-csrss/win32ss/user/ntuser/monitor.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/m…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/monitor.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/monitor.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -32,7 +32,7 @@ PMONITOR IntCreateMonitorObject() { - return UserCreateObject(gHandleTable, NULL, NULL, otMonitor, sizeof(MONITOR)); + return UserCreateObject(gHandleTable, NULL, NULL, NULL, otMonitor, sizeof(MONITOR)); } /* IntDestroyMonitorObject Modified: branches/ros-csrss/win32ss/user/ntuser/msgqueue.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/m…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/msgqueue.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/msgqueue.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -101,7 +101,7 @@ } /* Window has not been found */ - return NULL; + return pwndDesktop; } PCURICON_OBJECT Modified: branches/ros-csrss/win32ss/user/ntuser/msgqueue.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/m…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/msgqueue.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/msgqueue.h [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -298,4 +298,13 @@ DWORD APIENTRY IntGetQueueStatus(DWORD); UINT lParamMemorySize(UINT Msg, WPARAM wParam, LPARAM lParam); + +BOOL FASTCALL +co_IntGetPeekMessage( PMSG pMsg, + HWND hWnd, + UINT MsgFilterMin, + UINT MsgFilterMax, + UINT RemoveMsg, + BOOL bGMSG ); + /* EOF */ Modified: branches/ros-csrss/win32ss/user/ntuser/object.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/o…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/object.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/object.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -315,20 +315,24 @@ FASTCALL UserCreateObject( PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, + PTHREADINFO pti, HANDLE* h, USER_OBJECT_TYPE type, ULONG size) { HANDLE hi; PVOID Object; - PTHREADINFO pti; PPROCESSINFO ppi; BOOL dt; PDESKTOP rpdesk = pDesktop; - pti = GetW32ThreadInfo(); + /* We could get the desktop for the new object from the pti however this is + * not always the case for example when creating a new desktop window for + * the desktop thread*/ + + if (!pti) pti = GetW32ThreadInfo(); + if (!pDesktop) rpdesk = pti->rpdesk; ppi = pti->ppi; - if (!pDesktop) rpdesk = pti->rpdesk; switch (type) { Modified: branches/ros-csrss/win32ss/user/ntuser/object.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/o…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/object.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/object.h [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -33,7 +33,7 @@ VOID FASTCALL UserReferenceObject(PVOID obj); PVOID FASTCALL UserReferenceObjectByHandle(HANDLE handle, USER_OBJECT_TYPE type); BOOL FASTCALL UserDereferenceObject(PVOID obj); -PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, struct _DESKTOP* pDesktop, HANDLE* h,USER_OBJECT_TYPE type , ULONG size); +PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, struct _DESKTOP* pDesktop, PTHREADINFO pti, HANDLE* h,USER_OBJECT_TYPE type , ULONG size); BOOL FASTCALL UserDeleteObject(HANDLE h, USER_OBJECT_TYPE type ); PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, USER_OBJECT_TYPE type ); PVOID UserGetObjectNoErr(PUSER_HANDLE_TABLE, HANDLE, USER_OBJECT_TYPE); Modified: branches/ros-csrss/win32ss/user/ntuser/simplecall.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/s…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/simplecall.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/simplecall.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -184,7 +184,8 @@ if (count == 0) count = 8; psmwp = (PSMWP) UserCreateObject( gHandleTable, - NULL, + NULL, + NULL, (PHANDLE)&hDwp, otSMWP, sizeof(SMWP)); Modified: branches/ros-csrss/win32ss/user/ntuser/timer.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/t…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/timer.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/timer.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -56,7 +56,7 @@ HANDLE Handle; PTIMER Ret = NULL; - Ret = UserCreateObject(gHandleTable, NULL, &Handle, otTimer, sizeof(TIMER)); + Ret = UserCreateObject(gHandleTable, NULL, NULL, &Handle, otTimer, sizeof(TIMER)); if (Ret) { Ret->head.h = Handle; Modified: branches/ros-csrss/win32ss/user/ntuser/window.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/w…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/window.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/window.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -1661,7 +1661,8 @@ PCLS Class, PWND ParentWindow, PWND OwnerWindow, - PVOID acbiBuffer) + PVOID acbiBuffer, + PDESKTOP pdeskCreated) { PWND pWnd = NULL; HWND hWnd; @@ -1670,7 +1671,7 @@ BOOL MenuChanged; BOOL bUnicodeWindow; - pti = PsGetCurrentThreadWin32Thread(); + pti = pdeskCreated ? gptiDesktopThread : GetW32ThreadInfo(); if (!(Cs->dwExStyle & WS_EX_LAYOUTRTL)) { @@ -1690,8 +1691,7 @@ */ if ( Class->fnid != FNID_DIALOG ) { - PPROCESSINFO ppi = PsGetCurrentProcessWin32Process(); - if (ppi->dwLayout & LAYOUT_RTL) + if (pti->ppi->dwLayout & LAYOUT_RTL) { Cs->dwExStyle |= WS_EX_LAYOUTRTL; } @@ -1713,7 +1713,8 @@ /* Allocate the new window */ pWnd = (PWND) UserCreateObject( gHandleTable, - pti->rpdesk, + pdeskCreated ? pdeskCreated : pti->rpdesk, + pti, (PHANDLE)&hWnd, otWindow, sizeof(WND) + Class->cbwndExtra); @@ -1723,14 +1724,14 @@ goto AllocError; } - TRACE("Created object with handle %X\n", hWnd); - - if (NULL == pti->rpdesk->DesktopWindow) + TRACE("Created window object with handle %X\n", hWnd); + + if (pdeskCreated && pdeskCreated->DesktopWindow == NULL ) { /* HACK: Helper for win32csr/desktopbg.c */ /* If there is no desktop window yet, we must be creating it */ TRACE("CreateWindow setting desktop.\n"); - pti->rpdesk->DesktopWindow = hWnd; - pti->rpdesk->pDeskInfo->spwnd = pWnd; + pdeskCreated->DesktopWindow = hWnd; + pdeskCreated->pDeskInfo->spwnd = pWnd; } /* @@ -2010,7 +2011,7 @@ pCbtCreate = NULL; /* Get the class and reference it */ - Class = IntGetAndReferenceClass(ClassName, Cs->hInstance); + Class = IntGetAndReferenceClass(ClassName, Cs->hInstance, FALSE); if(!Class) { ERR("Failed to find class %wZ\n", ClassName); @@ -2059,7 +2060,8 @@ Class, ParentWindow, OwnerWindow, - acbiBuffer); + acbiBuffer, + NULL); if(!Window) { ERR("IntCreateWindow failed!\n"); @@ -2540,12 +2542,15 @@ TRACE("co_UserDestroyWindow \n"); - /* Check for owner thread */ - if ( (Window->head.pti->pEThread != PsGetCurrentThread()) || - Window->head.pti != PsGetCurrentThreadWin32Thread() ) - { - EngSetLastError(ERROR_ACCESS_DENIED); - return FALSE; + /* Check for owner thread */ + if ( Window->head.pti != PsGetCurrentThreadWin32Thread()) + { + /* Check if we are destroying the desktop window */ + if (! ((Window->head.rpdesk->dwDTFlags & DF_DESTROYED) && Window == Window->head.rpdesk->pDeskInfo->spwnd)) + { + EngSetLastError(ERROR_ACCESS_DENIED); + return FALSE; + } } /* If window was created successfully and it is hooked */ Modified: branches/ros-csrss/win32ss/user/ntuser/window.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/w…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/window.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/window.h [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -47,7 +47,13 @@ BOOL FASTCALL IntShowOwnedPopups( PWND owner, BOOL fShow ); LRESULT FASTCALL IntDefWindowProc( PWND Window, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi); VOID FASTCALL IntNotifyWinEvent(DWORD, PWND, LONG, LONG, DWORD); -PWND FASTCALL co_UserCreateWindowEx(CREATESTRUCTW*, PUNICODE_STRING, PLARGE_STRING, PVOID); +PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs, + PLARGE_STRING WindowName, + PCLS Class, + PWND ParentWindow, + PWND OwnerWindow, + PVOID acbiBuffer, + PDESKTOP pdeskCreated); BOOL FASTCALL IntEnableWindow(HWND,BOOL); BOOL FASTCALL IntIsWindowVisible(PWND); DWORD FASTCALL GetNCHitEx(PWND,POINT); Modified: branches/ros-csrss/win32ss/user/ntuser/winsta.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/w…
============================================================================== --- branches/ros-csrss/win32ss/user/ntuser/winsta.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/ntuser/winsta.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -229,10 +229,7 @@ { TEXTMETRICW tmw; UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY"); - if (! IntCreatePrimarySurface()) - { - return FALSE; - } + ScreenDeviceContext = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE); if (NULL == ScreenDeviceContext) { @@ -240,6 +237,11 @@ return FALSE; } GreSetDCOwner(ScreenDeviceContext, GDI_OBJ_HMGR_PUBLIC); + + if (! IntCreatePrimarySurface()) + { + return FALSE; + } /* Setup the cursor */ co_IntLoadDefaultCursors(); Modified: branches/ros-csrss/win32ss/user/user32/windows/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/user32/w…
============================================================================== --- branches/ros-csrss/win32ss/user/user32/windows/cursoricon.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/user32/windows/cursoricon.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -2137,21 +2137,23 @@ ULONG ArgumentLength) { BOOL *DefaultCursor = (BOOL*)Arguments; - LRESULT Result = TRUE; + HCURSOR hCursor; if(*DefaultCursor) { /* set default cursor */ - SetCursor(LoadCursorW(0, (LPCWSTR)IDC_ARROW)); + hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW); + SetCursor(hCursor); } else { /* FIXME load system cursor scheme */ SetCursor(0); - SetCursor(LoadCursorW(0, (LPCWSTR)IDC_ARROW)); - } - - return(ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS)); + hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW); + SetCursor(hCursor); + } + + return(ZwCallbackReturn(&hCursor, sizeof(HCURSOR), STATUS_SUCCESS)); } BOOL get_icon_size(HICON hIcon, SIZE *size) Modified: branches/ros-csrss/win32ss/user/winsrv/harderror.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/winsrv/h…
============================================================================== --- branches/ros-csrss/win32ss/user/winsrv/harderror.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/winsrv/harderror.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -141,6 +141,9 @@ UNICODE_STRING TempStringU, ParamStringU; ANSI_STRING TempStringA; + if (SizeOfAllUnicodeStrings) + *SizeOfAllUnicodeStrings = 0; + /* Read all strings from client space */ for (nParam = 0; nParam < HardErrorMessage->NumberOfParameters; nParam++) { @@ -227,7 +230,9 @@ return Status; } - *SizeOfAllUnicodeStrings = Size; + if (SizeOfAllUnicodeStrings) + *SizeOfAllUnicodeStrings = Size; + return Status; } Modified: branches/ros-csrss/win32ss/user/winsrv/init.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/winsrv/i…
============================================================================== --- branches/ros-csrss/win32ss/user/winsrv/init.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/winsrv/init.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -356,6 +356,28 @@ NtUserCallOneParam(Check, ONEPARAM_ROUTINE_CSRSS_GUICHECK); } +static HHOOK hhk = NULL; + +/*** HACK from win32csr... ***/ +LRESULT +CALLBACK +KeyboardHookProc(int nCode, + WPARAM wParam, + LPARAM lParam) +{ + return CallNextHookEx(hhk, nCode, wParam, lParam); +} +/*** END - HACK from win32csr... ***/ + +DWORD +WINAPI +CreateSystemThreads(PVOID pParam) +{ + NtUserCallOneParam((DWORD)pParam, ONEPARAM_ROUTINE_CREATESYSTEMTHREADS); + DPRINT1("This thread should not terminate!\n"); + return 0; +} + CSR_SERVER_DLL_INIT(UserServerDllInitialization) { /* @@ -377,6 +399,13 @@ } return Status; */ + +/*** From win32csr... ***/ + HANDLE ServerThread; + CLIENT_ID ClientId; + NTSTATUS Status; + UINT i; +/*** END - From win32csr... ***/ /* Initialize memory */ UserSrvHeap = RtlGetProcessHeap(); // Initialize our own heap. @@ -399,6 +428,21 @@ // LoadedServerDll->NewProcessCallback = Win32CsrDuplicateHandleTable; LoadedServerDll->HardErrorCallback = Win32CsrHardError; +/*** From win32csr... ***/ + /* Start the Raw Input Thread and the Desktop Thread */ + for (i = 0; i < 2; ++i) + { + Status = RtlCreateUserThread(NtCurrentProcess(), NULL, TRUE, 0, 0, 0, (PTHREAD_START_ROUTINE)CreateSystemThreads, (PVOID)i, &ServerThread, &ClientId); + if (NT_SUCCESS(Status)) + { + NtResumeThread(ServerThread, NULL); + NtClose(ServerThread); + } + else + DPRINT1("Cannot start Raw Input Thread!\n"); + } +/*** END - From win32csr... ***/ + /* All done */ return STATUS_SUCCESS; } @@ -422,6 +466,18 @@ if (DLL_PROCESS_ATTACH == dwReason) { DllHandle = hDll; + +/*** HACK from win32csr... ***/ + +// +// HACK HACK HACK ReactOS to BOOT! Initialization BUG ALERT! See bug 5655. +// + hhk = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProc, NULL, 0); +// BUG ALERT! BUG ALERT! BUG ALERT! BUG ALERT! BUG ALERT! BUG ALERT! BUG ALERT! +// BUG ALERT! BUG ALERT! BUG ALERT! BUG ALERT! BUG ALERT! BUG ALERT! BUG ALERT! +// BUG ALERT! BUG ALERT! BUG ALERT! BUG ALERT! BUG ALERT! BUG ALERT! BUG ALERT! + +/*** END - HACK from win32csr... ***/ } return TRUE; Modified: branches/ros-csrss/win32ss/user/winsrv/shutdown.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/winsrv/s…
============================================================================== --- branches/ros-csrss/win32ss/user/winsrv/shutdown.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/winsrv/shutdown.c [iso-8859-1] Sun Oct 28 12:13:03 2012 @@ -471,7 +471,7 @@ return TRUE; } -/*** Taken from win32ss/user/win32csr/desktopbg.c ***/ +/*** Taken from win32ss/user/consrv/console.c ***/ BOOL FASTCALL DtbgIsDesktopVisible(VOID) { @@ -485,9 +485,7 @@ return VisibleDesktopWindow != NULL; } -/****************************************************/ - -/*** Taken from win32ss/user/consrv/console.c ***/ + /* TODO: Find another way to do it. */ VOID FASTCALL ConioConsoleCtrlEventTimeout(DWORD Event, PCSR_PROCESS ProcessData, DWORD Timeout)
12 years, 1 month
1
0
0
0
[hbelusca] 57634: Update properties
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sun Oct 28 12:00:19 2012 New Revision: 57634 URL:
http://svn.reactos.org/svn/reactos?rev=57634&view=rev
Log: Update properties Modified: branches/ros-csrss/ (props changed) Propchange: branches/ros-csrss/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 28 12:00:19 2012 @@ -13,4 +13,4 @@ /branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859 /branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567 /branches/wlan-bringup:54809-54998 -/trunk/reactos:57561-57630 +/trunk/reactos:57561-57633
12 years, 1 month
1
0
0
0
[gadamopoulos] 57633: - Fix build I wonder how ninja managed to compile this locally
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Sun Oct 28 10:43:48 2012 New Revision: 57633 URL:
http://svn.reactos.org/svn/reactos?rev=57633&view=rev
Log: - Fix build I wonder how ninja managed to compile this locally Modified: trunk/reactos/win32ss/user/ntuser/window.c Modified: trunk/reactos/win32ss/user/ntuser/window.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/window…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/window.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/window.c [iso-8859-1] Sun Oct 28 10:43:48 2012 @@ -2504,7 +2504,7 @@ UserEnterExclusive(); /* Call the internal function */ - pwnd = co_UserCreateWindowEx(&Cs, &ustrClassName, plstrWindowName, acbiBuffer, NULL); + pwnd = co_UserCreateWindowEx(&Cs, &ustrClassName, plstrWindowName, acbiBuffer); if(!pwnd) {
12 years, 1 month
1
0
0
0
[gadamopoulos] 57632: - Rewrite NtUserCreateDesktop and move the desktop thread completely in win32k like in windows in order to let desktop objects to be destroyed - Disable deleting the desktop h...
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Sun Oct 28 10:34:41 2012 New Revision: 57632 URL:
http://svn.reactos.org/svn/reactos?rev=57632&view=rev
Log: - Rewrite NtUserCreateDesktop and move the desktop thread completely in win32k like in windows in order to let desktop objects to be destroyed - Disable deleting the desktop heap until CORE-6729 is fixed - See CORE-6723 for more details Modified: trunk/reactos/ntoskrnl/ex/win32k.c trunk/reactos/ntoskrnl/ps/win32.c trunk/reactos/win32ss/gdi/ntgdi/device.c trunk/reactos/win32ss/pch.h trunk/reactos/win32ss/user/ntuser/accelerator.c trunk/reactos/win32ss/user/ntuser/callback.c trunk/reactos/win32ss/user/ntuser/callproc.c trunk/reactos/win32ss/user/ntuser/class.c trunk/reactos/win32ss/user/ntuser/class.h trunk/reactos/win32ss/user/ntuser/clipboard.c trunk/reactos/win32ss/user/ntuser/csr.c trunk/reactos/win32ss/user/ntuser/cursoricon.c trunk/reactos/win32ss/user/ntuser/desktop.c trunk/reactos/win32ss/user/ntuser/desktop.h trunk/reactos/win32ss/user/ntuser/event.c trunk/reactos/win32ss/user/ntuser/hook.c trunk/reactos/win32ss/user/ntuser/input.c trunk/reactos/win32ss/user/ntuser/kbdlayout.c trunk/reactos/win32ss/user/ntuser/main.c trunk/reactos/win32ss/user/ntuser/menu.c trunk/reactos/win32ss/user/ntuser/message.c trunk/reactos/win32ss/user/ntuser/monitor.c trunk/reactos/win32ss/user/ntuser/msgqueue.c trunk/reactos/win32ss/user/ntuser/msgqueue.h trunk/reactos/win32ss/user/ntuser/object.c trunk/reactos/win32ss/user/ntuser/object.h trunk/reactos/win32ss/user/ntuser/simplecall.c trunk/reactos/win32ss/user/ntuser/timer.c trunk/reactos/win32ss/user/ntuser/window.c trunk/reactos/win32ss/user/ntuser/window.h trunk/reactos/win32ss/user/ntuser/winsta.c trunk/reactos/win32ss/user/user32/windows/cursoricon.c trunk/reactos/win32ss/user/win32csr/desktopbg.c trunk/reactos/win32ss/user/win32csr/dllmain.c Modified: trunk/reactos/ntoskrnl/ex/win32k.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/win32k.c?rev=5…
============================================================================== --- trunk/reactos/ntoskrnl/ex/win32k.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ex/win32k.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -40,6 +40,8 @@ PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExpWindowStationObjectOkToClose = NULL; PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExpDesktopObjectOkToClose = NULL; PKWIN32_DELETEMETHOD_CALLOUT ExpDesktopObjectDelete = NULL; +PKWIN32_OPENMETHOD_CALLOUT ExpDesktopObjectOpen = NULL; +PKWIN32_CLOSEMETHOD_CALLOUT ExpDesktopObjectClose = NULL; /* FUNCTIONS ****************************************************************/ @@ -131,6 +133,44 @@ /* Call the Registered Callback */ ExpDesktopObjectDelete(&Parameters); +} + +NTSTATUS +NTAPI +ExpDesktopOpen(IN OB_OPEN_REASON Reason, + IN PEPROCESS Process OPTIONAL, + IN PVOID ObjectBody, + IN ACCESS_MASK GrantedAccess, + IN ULONG HandleCount) +{ + WIN32_OPENMETHOD_PARAMETERS Parameters; + + Parameters.OpenReason = Reason; + Parameters.Process = Process; + Parameters.Object = ObjectBody; + Parameters.GrantedAccess = GrantedAccess; + Parameters.HandleCount = HandleCount; + + return ExpDesktopObjectOpen(&Parameters); +} + +VOID +NTAPI +ExpDesktopClose(IN PEPROCESS Process OPTIONAL, + IN PVOID Object, + IN ACCESS_MASK GrantedAccess, + IN ULONG ProcessHandleCount, + IN ULONG SystemHandleCount) +{ + WIN32_CLOSEMETHOD_PARAMETERS Parameters; + + Parameters.Process = Process; + Parameters.Object = Object; + Parameters.AccessMask = GrantedAccess; + Parameters.ProcessHandleCount = ProcessHandleCount; + Parameters.SystemHandleCount = SystemHandleCount; + + ExpDesktopObjectClose(&Parameters); } BOOLEAN @@ -169,6 +209,8 @@ ObjectTypeInitializer.DeleteProcedure = ExpDesktopDelete; ObjectTypeInitializer.ParseProcedure = NULL; ObjectTypeInitializer.OkayToCloseProcedure = ExpDesktopOkToClose; + ObjectTypeInitializer.OpenProcedure = ExpDesktopOpen; + ObjectTypeInitializer.CloseProcedure = ExpDesktopClose; ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, Modified: trunk/reactos/ntoskrnl/ps/win32.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/win32.c?rev=57…
============================================================================== --- trunk/reactos/ntoskrnl/ps/win32.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ps/win32.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -23,6 +23,8 @@ extern PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExpWindowStationObjectOkToClose; extern PKWIN32_OKTOCLOSEMETHOD_CALLOUT ExpDesktopObjectOkToClose; extern PKWIN32_DELETEMETHOD_CALLOUT ExpDesktopObjectDelete; +extern PKWIN32_OPENMETHOD_CALLOUT ExpDesktopObjectOpen; +extern PKWIN32_CLOSEMETHOD_CALLOUT ExpDesktopObjectClose; extern PKWIN32_POWEREVENT_CALLOUT PopEventCallout; /* PRIVATE FUNCTIONS *********************************************************/ @@ -121,6 +123,8 @@ ExpWindowStationObjectOkToClose = CalloutData->WindowStationOkToCloseProcedure; ExpDesktopObjectOkToClose = CalloutData->DesktopOkToCloseProcedure; ExpDesktopObjectDelete = CalloutData->DesktopDeleteProcedure; + ExpDesktopObjectOpen = CalloutData->DesktopOpenProcedure; + ExpDesktopObjectClose = CalloutData->DesktopCloseProcedure; PopEventCallout = CalloutData->PowerEventCallout; KeGdiFlushUserBatch = CalloutData->BatchFlushRoutine; } Modified: trunk/reactos/win32ss/gdi/ntgdi/device.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/device.c…
============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/device.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/device.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -32,15 +32,15 @@ SURFOBJ *pso; PDESKTOP rpDesk; + /* Create surface */ + pso = &PDEVOBJ_pSurface(gppdevPrimary)->SurfObj; + SurfSize = pso->sizlBitmap; + /* Attach monitor */ UserAttachMonitor((HDEV)gppdevPrimary); DPRINT("IntCreatePrimarySurface, gppdevPrimary=%p, gppdevPrimary->pSurface = %p\n", gppdevPrimary, gppdevPrimary->pSurface); - - /* Create surface */ - pso = &PDEVOBJ_pSurface(gppdevPrimary)->SurfObj; - SurfSize = pso->sizlBitmap; /* Put the pointer in the center of the screen */ gpsi->ptCursor.x = pso->sizlBitmap.cx / 2; Modified: trunk/reactos/win32ss/pch.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/pch.h?rev=57632&r1…
============================================================================== --- trunk/reactos/win32ss/pch.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/pch.h [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -36,6 +36,7 @@ /* Win32 headers */ /* FIXME: Defines in winbase.h that we need... */ typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; +#define MAKEINTATOM(i) (LPWSTR)((ULONG_PTR)((WORD)(i))) #define WINBASEAPI #define STARTF_USESIZE 2 #define STARTF_USEPOSITION 4 Modified: trunk/reactos/win32ss/user/ntuser/accelerator.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/accele…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/accelerator.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/accelerator.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -257,7 +257,7 @@ RETURN( (HACCEL) NULL ); } - Accel = UserCreateObject(gHandleTable, NULL, (PHANDLE)&hAccel, otAccel, sizeof(ACCELERATOR_TABLE)); + Accel = UserCreateObject(gHandleTable, NULL, NULL, (PHANDLE)&hAccel, otAccel, sizeof(ACCELERATOR_TABLE)); if (Accel == NULL) { Modified: trunk/reactos/win32ss/user/ntuser/callback.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/callba…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/callback.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/callback.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -130,6 +130,9 @@ BOOL bResult; ULONG_PTR pLibNameBuffer = 0, pInitFuncBuffer = 0; + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); + TRACE("co_IntClientLoadLibrary: %S, %S, %d, %d\n", pstrLibName->Buffer, pstrLibName->Buffer, Unload, ApiHook); /* Calculate the size of the argument */ @@ -235,6 +238,9 @@ PWND pWnd; ULONG ResultLength; NTSTATUS Status; + + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); Arguments.Callback = CompletionCallback; Arguments.Wnd = hWnd; @@ -280,6 +286,9 @@ ULONG ResultLength; ULONG ArgumentLength; LRESULT Result; + + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); if (0 < lParamBufferSize) { @@ -363,6 +372,9 @@ NTSTATUS Status; PVOID ResultPointer; ULONG ResultLength; + + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); ResultPointer = NULL; ResultLength = sizeof(LRESULT); @@ -394,6 +406,8 @@ return (HMENU)Result; } +extern HCURSOR gDesktopCursor; + BOOL APIENTRY co_IntLoadDefaultCursors(VOID) { @@ -402,8 +416,11 @@ ULONG ResultLength; BOOL DefaultCursor = TRUE; + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); + ResultPointer = NULL; - ResultLength = sizeof(LRESULT); + ResultLength = sizeof(HCURSOR); UserLeaveCo(); @@ -414,6 +431,9 @@ &ResultLength); UserEnterCo(); + + /* HACK: The desktop class doen't have a proper cursor yet, so set it here */ + gDesktopCursor = *((HCURSOR*)ResultPointer); if (!NT_SUCCESS(Status)) { @@ -448,6 +468,8 @@ UINT lParamSize = 0; ASSERT(Proc); + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); pti = PsGetCurrentThreadWin32Thread(); if (pti->TIF_flags & TIF_INCLEANUP) @@ -834,6 +856,9 @@ ULONG ArgumentLength, ResultLength; PVOID Argument, ResultPointer; + /* Do not allow the desktop thread to do callback to user mode */ + ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread); + ArgumentLength = ResultLength = 0; Argument = ResultPointer = NULL; Modified: trunk/reactos/win32ss/user/ntuser/callproc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/callpr…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/callproc.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/callproc.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -35,6 +35,7 @@ NewCallProc = (PCALLPROCDATA)UserCreateObject(gHandleTable, Desktop, + NULL, &Handle, otCallProc, sizeof(CALLPROCDATA)); Modified: trunk/reactos/win32ss/user/ntuser/class.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/class.…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/class.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/class.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -641,9 +641,17 @@ PCLS Class; ASSERT(BaseClass->pclsBase == BaseClass); - Class = IntGetClassForDesktop(BaseClass, - ClassLink, - Desktop); + if (Desktop != NULL) + { + Class = IntGetClassForDesktop(BaseClass, + ClassLink, + Desktop); + } + else + { + Class = BaseClass; + } + if (Class != NULL) { Class->cWndReferenceCount++; @@ -1286,13 +1294,16 @@ } PCLS -IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance) +IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance, BOOL bDesktopThread) { PCLS *ClassLink, Class = NULL; RTL_ATOM ClassAtom; PTHREADINFO pti; - pti = PsGetCurrentThreadWin32Thread(); + if (bDesktopThread) + pti = gptiDesktopThread; + else + pti = PsGetCurrentThreadWin32Thread(); if ( !(pti->ppi->W32PF_flags & W32PF_CLASSESREGISTERED )) { Modified: trunk/reactos/win32ss/user/ntuser/class.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/class.…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/class.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/class.h [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -39,7 +39,7 @@ IN PPROCESSINFO pi); PCLS -IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance); +IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance, BOOL bDesktopThread); BOOL FASTCALL UserRegisterSystemClasses(VOID); Modified: trunk/reactos/win32ss/user/ntuser/clipboard.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/clipbo…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/clipboard.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/clipboard.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -182,6 +182,7 @@ /* Create the clipboard data */ pClipboardData = (PCLIPBOARDDATA)UserCreateObject(gHandleTable, NULL, + NULL, &hMem, otClipBoardData, cjDataSize); @@ -293,7 +294,7 @@ PCLIPBOARDDATA pMemObj; HANDLE hMem; - pMemObj = (PCLIPBOARDDATA)UserCreateObject(gHandleTable, NULL, &hMem, otClipBoardData, + pMemObj = (PCLIPBOARDDATA)UserCreateObject(gHandleTable, NULL, NULL, &hMem, otClipBoardData, sizeof(CLIPBOARDDATA) + sizeof(LCID)); if (pMemObj) { @@ -1080,7 +1081,7 @@ UserEnterExclusive(); /* Create Clipboard data object */ - pMemObj = UserCreateObject(gHandleTable, NULL, &hMem, otClipBoardData, sizeof(CLIPBOARDDATA) + cbData); + pMemObj = UserCreateObject(gHandleTable, NULL, NULL, &hMem, otClipBoardData, sizeof(CLIPBOARDDATA) + cbData); if (!pMemObj) goto cleanup; Modified: trunk/reactos/win32ss/user/ntuser/csr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/csr.c?…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/csr.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/csr.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -88,74 +88,4 @@ return Status; } - -NTSTATUS -APIENTRY -CsrInsertObject(HANDLE ObjectHandle, - ACCESS_MASK DesiredAccess, - PHANDLE Handle) -{ - NTSTATUS Status; - HANDLE CsrProcessHandle; - OBJECT_ATTRIBUTES ObjectAttributes; - CLIENT_ID Cid; - - /* Put CSR'S CID */ - Cid.UniqueProcess = CsrProcess->UniqueProcessId; - Cid.UniqueThread = 0; - - /* Empty Attributes */ - InitializeObjectAttributes(&ObjectAttributes, - NULL, - 0, - NULL, - NULL); - - /* Get a Handle to Csrss */ - Status = ZwOpenProcess(&CsrProcessHandle, - PROCESS_DUP_HANDLE, - &ObjectAttributes, - &Cid); - - if ((NT_SUCCESS(Status))) - { - /* Duplicate the Handle */ - Status = ZwDuplicateObject(NtCurrentProcess(), - ObjectHandle, - CsrProcessHandle, - Handle, - DesiredAccess, - OBJ_INHERIT, - 0); - - /* Close our handle to CSRSS */ - ZwClose(CsrProcessHandle); - } - - return Status; -} - -NTSTATUS FASTCALL -CsrCloseHandle(HANDLE Handle) -{ - NTSTATUS Status; - PEPROCESS OldProcess; - - /* Switch to the process in which the handle is valid */ - OldProcess = PsGetCurrentProcess(); - if (CsrProcess != OldProcess) - { - KeAttachProcess(&CsrProcess->Pcb); - } - - Status = ZwClose(Handle); - - if (CsrProcess != OldProcess) - { - KeDetachProcess(); - } - - return Status; -} - /* EOF */ Modified: trunk/reactos/win32ss/user/ntuser/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/cursor…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/cursoricon.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/cursoricon.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -209,7 +209,7 @@ PCURICON_OBJECT CurIcon; HANDLE hCurIcon; - CurIcon = UserCreateObject(gHandleTable, NULL, &hCurIcon, otCursorIcon, sizeof(CURICON_OBJECT)); + CurIcon = UserCreateObject(gHandleTable, NULL, NULL, &hCurIcon, otCursorIcon, sizeof(CURICON_OBJECT)); if (!CurIcon) { 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] Sun Oct 28 10:34:41 2012 @@ -11,11 +11,17 @@ #include <win32k.h> DBG_DEFAULT_CHANNEL(UserDesktop); -static -VOID -IntFreeDesktopHeap( - IN OUT PDESKTOP Desktop -); +static NTSTATUS +UserInitializeDesktop(PDESKTOP pdesk, PUNICODE_STRING DesktopName, PWINSTATION_OBJECT pwinsta); + +static NTSTATUS +IntMapDesktopView(IN PDESKTOP pdesk); + +static NTSTATUS +IntUnmapDesktopView(IN PDESKTOP pdesk); + +static VOID +IntFreeDesktopHeap(IN PDESKTOP pdesk); /* GLOBALS *******************************************************************/ @@ -23,6 +29,8 @@ PDESKTOP InputDesktop = NULL; HDESK InputDesktopHandle = NULL; HDC ScreenDeviceContext = NULL; +PTHREADINFO gptiDesktopThread; +HCURSOR gDesktopCursor = NULL; /* OBJECT CALLBACKS **********************************************************/ @@ -112,17 +120,16 @@ sizeof(DESKTOP), 0, 0, - (PVOID)&Desktop); + (PVOID*)&Desktop); if (!NT_SUCCESS(Status)) return Status; - /* Initialize shell hook window list and set the parent */ - RtlZeroMemory(Desktop, sizeof(DESKTOP)); - InitializeListHead(&Desktop->ShellHookWindows); - Desktop->rpwinstaParent = (PWINSTATION_OBJECT)ParseObject; - - /* Put the desktop on the window station's list of associated desktops */ - InsertTailList(&Desktop->rpwinstaParent->DesktopListHead, - &Desktop->ListEntry); + /* Initialize the desktop */ + Status = UserInitializeDesktop(Desktop, RemainingName, WinStaObject); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(Desktop); + return Status; + } /* Set the desktop object and return success */ *Object = Desktop; @@ -133,22 +140,29 @@ VOID APIENTRY IntDesktopObjectDelete(PWIN32_DELETEMETHOD_PARAMETERS Parameters) { - PDESKTOP Desktop = (PDESKTOP)Parameters->Object; - - TRACE("Deleting desktop object 0x%p\n", Desktop); + PDESKTOP pdesk = (PDESKTOP)Parameters->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(&Desktop->ListEntry); - - IntFreeDesktopHeap(Desktop); + RemoveEntryList(&pdesk->ListEntry); + + /* Free the heap */ + IntFreeDesktopHeap(pdesk); } NTSTATUS NTAPI IntDesktopOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters) { - PTHREADINFO pti; - - pti = PsGetCurrentThreadWin32Thread(); + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); if( pti == NULL) { @@ -165,6 +179,29 @@ return STATUS_SUCCESS; } + +NTSTATUS NTAPI IntDesktopObjectOpen(PWIN32_OPENMETHOD_PARAMETERS Parameters) +{ + PPROCESSINFO ppi = PsGetProcessWin32Process(Parameters->Process); + if (ppi == NULL) + return STATUS_SUCCESS; + + return IntMapDesktopView((PDESKTOP)Parameters->Object); +} + +NTSTATUS NTAPI IntDesktopObjectClose(PWIN32_CLOSEMETHOD_PARAMETERS Parameters) +{ + PPROCESSINFO ppi = PsGetProcessWin32Process(Parameters->Process); + if (ppi == NULL) + { + /* This happens when the process leaks desktop handles. + * At this point the PPROCESSINFO is already destroyed */ + return STATUS_SUCCESS; + } + + return IntUnmapDesktopView((PDESKTOP)Parameters->Object); +} + /* PRIVATE FUNCTIONS **********************************************************/ @@ -596,8 +633,66 @@ case WM_SYSCOLORCHANGE: co_UserRedrawWindow(Wnd, NULL, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); return TRUE; - } - return FALSE; // Not processed so go with callback. + case WM_SETCURSOR: + { + PCURICON_OBJECT pcurOld, pcurNew; + pcurNew = UserGetCurIconObject(gDesktopCursor); + if (!pcurNew) + { + return TRUE; + } + pcurOld = UserSetCursor(pcurNew, FALSE); + if (pcurOld) + { + UserDereferenceObject(pcurOld); + } + } + } + return TRUE; /* We are done. Do not do any callbacks to user mode */ +} + +BOOL FASTCALL +UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult) +{ + *lResult = 0; + + switch(Msg) + { + case WM_NCCREATE: + pwnd->fnid |= FNID_MESSAGEWND; + *lResult = (LRESULT)TRUE; + break; + case WM_DESTROY: + pwnd->fnid |= FNID_DESTROY; + break; + } + + return TRUE; /* We are done. Do not do any callbacks to user mode */ +} + +VOID NTAPI DesktopThreadMain() +{ + BOOL Ret; + MSG Msg; + + gptiDesktopThread = PsGetCurrentThreadWin32Thread(); + + UserEnterExclusive(); + + /* Register system classes. This thread does not belong to any desktop so the + classes will be allocated from the shared heap */ + UserRegisterSystemClasses(); + + while(TRUE) + { + Ret = co_IntGetPeekMessage(&Msg, 0, 0, 0, PM_REMOVE, TRUE); + if (Ret) + { + IntDispatchMessage(&Msg); + } + } + + UserLeave(); } HDC FASTCALL @@ -813,6 +908,8 @@ static VOID IntFreeDesktopHeap(IN OUT PDESKTOP Desktop) { + /* FIXME: Disable until unmapping works in mm */ +#if 0 if (Desktop->pheapDesktop != NULL) { MmUnmapViewInSessionSpace(Desktop->pheapDesktop); @@ -824,6 +921,7 @@ ObDereferenceObject(Desktop->hsectionDesktop); Desktop->hsectionDesktop = NULL; } +#endif } BOOL FASTCALL @@ -1030,6 +1128,61 @@ return TRUE; } +static NTSTATUS +UserInitializeDesktop(PDESKTOP pdesk, PUNICODE_STRING DesktopName, PWINSTATION_OBJECT pwinsta) +{ + PVOID DesktopHeapSystemBase = NULL; + ULONG_PTR HeapSize = 400 * 1024; + SIZE_T DesktopInfoSize; + ULONG i; + + TRACE("UserInitializeDesktop desktop 0x%p with name %wZ\n", pdesk, DesktopName); + + RtlZeroMemory(pdesk, sizeof(DESKTOP)); + + /* Link the desktop with the parent window station */ + pdesk->rpwinstaParent = pwinsta; + InsertTailList(&pwinsta->DesktopListHead, &pdesk->ListEntry); + + /* Create the desktop heap */ + pdesk->hsectionDesktop = NULL; + 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; +} + /* SYSCALLS *******************************************************************/ /* @@ -1073,43 +1226,35 @@ DWORD dwFlags, ACCESS_MASK dwDesiredAccess) { - PDESKTOP DesktopObject; - UNICODE_STRING DesktopName; + PDESKTOP pdesk = NULL; NTSTATUS Status = STATUS_SUCCESS; - HDESK Desktop; - CSR_API_MESSAGE Request; - PVOID DesktopHeapSystemBase = NULL; - SIZE_T DesktopInfoSize; + HDESK hdesk; BOOLEAN Context; - ULONG_PTR HeapSize = 400 * 1024; /* FIXME: Windows uses 200KB by default */ UNICODE_STRING ClassName; LARGE_STRING WindowName; BOOL NoHooks = FALSE; PWND pWnd = NULL; CREATESTRUCTW Cs; - INT i; PTHREADINFO ptiCurrent; + PCLS pcls; + DECLARE_RETURN(HDESK); TRACE("Enter NtUserCreateDesktop\n"); UserEnterExclusive(); ptiCurrent = PsGetCurrentThreadWin32Thread(); - if (ptiCurrent) - { + 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; - } - /*else - {ERR("NtUserCreateDesktop: No ptiCurrent\n");}*/ - DesktopName.Buffer = NULL; + 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, @@ -1117,141 +1262,98 @@ NULL, dwDesiredAccess, (PVOID)&Context, - (HANDLE*)&Desktop); - if (!NT_SUCCESS(Status)) RETURN(NULL); + (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( Desktop); - } - - /* Capture desktop name */ - _SEH2_TRY - { - ProbeForRead( ObjectAttributes, sizeof(OBJECT_ATTRIBUTES), 1); - - Status = IntSafeCopyUnicodeStringTerminateNULL(&DesktopName, ObjectAttributes->ObjectName); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Status = _SEH2_GetExceptionCode(); - } - _SEH2_END - - if (! NT_SUCCESS(Status)) - { - ERR("Failed reading Object Attributes from user space.\n"); - SetLastNtError(Status); - RETURN( NULL); + RETURN( hdesk); } /* Reference the desktop */ - Status = ObReferenceObjectByHandle(Desktop, + Status = ObReferenceObjectByHandle(hdesk, 0, ExDesktopObjectType, KernelMode, - (PVOID)&DesktopObject, + (PVOID*)&pdesk, NULL); if (!NT_SUCCESS(Status)) { ERR("Failed to reference desktop object\n"); + SetLastNtError(Status); RETURN(NULL); } - TRACE("NtUserCreateDesktop created desktop 0x%p with name %wZ\n", DesktopObject, &DesktopName); - - DesktopObject->hsectionDesktop = NULL; - DesktopObject->pheapDesktop = UserCreateHeap(&DesktopObject->hsectionDesktop, - &DesktopHeapSystemBase, - HeapSize); - if (DesktopObject->pheapDesktop == NULL) - { - ObDereferenceObject(DesktopObject); - ERR("Failed to create desktop heap!\n"); - RETURN(NULL); - } - - DesktopInfoSize = sizeof(DESKTOPINFO) + DesktopName.Length + sizeof(WCHAR); - - DesktopObject->pDeskInfo = RtlAllocateHeap(DesktopObject->pheapDesktop, - HEAP_NO_SERIALIZE, - DesktopInfoSize); - - if (DesktopObject->pDeskInfo == NULL) - { - ObDereferenceObject(DesktopObject); - ERR("Failed to create the DESKTOP structure!\n"); - RETURN(NULL); - } - - RtlZeroMemory(DesktopObject->pDeskInfo, - DesktopInfoSize); - - DesktopObject->pDeskInfo->pvDesktopBase = DesktopHeapSystemBase; - DesktopObject->pDeskInfo->pvDesktopLimit = (PVOID)((ULONG_PTR)DesktopHeapSystemBase + HeapSize); - RtlCopyMemory(DesktopObject->pDeskInfo->szDesktopName, - DesktopName.Buffer, - DesktopName.Length + sizeof(WCHAR)); - - /* Initialize some local (to win32k) desktop state. */ - InitializeListHead(&DesktopObject->PtiList); - DesktopObject->ActiveMessageQueue = NULL; - - /* Setup Global Hooks. */ - for (i = 0; i < NB_HOOKS; i++) - { - InitializeListHead(&DesktopObject->pDeskInfo->aphkStart[i]); - } - - /* - * Create a handle for CSRSS and notify CSRSS for Creating Desktop Background Windows and Threads. + if (!ptiCurrent->rpdesk) IntSetThreadDesktop(hdesk,FALSE); + + /* 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 */ - Request.Type = MAKE_CSR_API(CREATE_DESKTOP, CSR_GUI); - Status = CsrInsertObject(Desktop, - GENERIC_ALL, - (HANDLE*)&Request.Data.CreateDesktopRequest.DesktopHandle); - if (! NT_SUCCESS(Status)) - { - ERR("Failed to create desktop handle for CSRSS\n"); - ZwClose(Desktop); - SetLastNtError(Status); - RETURN( NULL); - } - - Status = co_CsrNotify(&Request); - if (! NT_SUCCESS(Status)) - { - CsrCloseHandle(Request.Data.CreateDesktopRequest.DesktopHandle); - ERR("Failed to notify CSRSS about new desktop\n"); - ZwClose(Desktop); - SetLastNtError(Status); - RETURN( NULL); - } - - if (ptiCurrent && !ptiCurrent->rpdesk) IntSetThreadDesktop(Desktop,FALSE); - - ClassName.Buffer = ((PWSTR)((ULONG_PTR)(WORD)(gpsi->atomSysClass[ICLS_HWNDMESSAGE]))); + 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->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! Leave it to Timo to not pass on notes! + Cs.hInstance = hModClient; // hModuleWin; // Server side winproc! Cs.lpszName = (LPCWSTR) &WindowName; Cs.lpszClass = (LPCWSTR) &ClassName; - - pWnd = co_UserCreateWindowEx(&Cs, &ClassName, &WindowName, NULL); - if (!pWnd) - { - ERR("Failed to create Message window handle\n"); - } - else - { - DesktopObject->spwndMessage = pWnd; - } + 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) @@ -1261,14 +1363,18 @@ The rest is same as message window.
http://msdn.microsoft.com/en-us/library/bb760250(VS.85).aspx
*/ - RETURN( Desktop); + RETURN( hdesk); CLEANUP: - if(DesktopName.Buffer != NULL) - { - ExFreePoolWithTag(DesktopName.Buffer, TAG_STRING); - } - if (!NoHooks && ptiCurrent) + 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; Modified: trunk/reactos/win32ss/user/ntuser/desktop.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/deskto…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/desktop.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/desktop.h [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -73,6 +73,7 @@ extern HDESK InputDesktopHandle; extern PCLS DesktopWindowClass; extern HDC ScreenDeviceContext; +extern PTHREADINFO gptiDesktopThread; typedef struct _SHELL_HOOK_WINDOW { @@ -104,6 +105,12 @@ NTSTATUS NTAPI IntDesktopOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters); +NTSTATUS NTAPI +IntDesktopObjectOpen(PWIN32_OPENMETHOD_PARAMETERS Parameters); + +NTSTATUS NTAPI +IntDesktopObjectClose(PWIN32_CLOSEMETHOD_PARAMETERS Parameters); + HDC FASTCALL IntGetScreenDC(VOID); @@ -283,4 +290,6 @@ PWND FASTCALL co_GetDesktopWindow(PWND); BOOL FASTCALL IntPaintDesktop(HDC); BOOL FASTCALL DesktopWindowProc(PWND, UINT, WPARAM, LPARAM, LRESULT *); +BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult); +VOID NTAPI DesktopThreadMain(); /* EOF */ Modified: trunk/reactos/win32ss/user/ntuser/event.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/event.…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/event.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/event.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -378,7 +378,7 @@ } } // Creator, pti is set here. - pEH = UserCreateObject(gHandleTable, NULL, &Handle, otEvent, sizeof(EVENTHOOK)); + pEH = UserCreateObject(gHandleTable, NULL, NULL, &Handle, otEvent, sizeof(EVENTHOOK)); if (pEH) { InsertTailList(&GlobalEvents->Events, &pEH->Chain); Modified: trunk/reactos/win32ss/user/ntuser/hook.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/hook.c…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/hook.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/hook.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -1569,7 +1569,7 @@ } ObDereferenceObject(WinStaObj); - Hook = UserCreateObject(gHandleTable, NULL, (PHANDLE)&Handle, otHook, sizeof(HOOK)); + Hook = UserCreateObject(gHandleTable, NULL, NULL, (PHANDLE)&Handle, otHook, sizeof(HOOK)); if (!Hook) { 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] Sun Oct 28 10:34:41 2012 @@ -304,6 +304,7 @@ switch (Type) { case 0: RawInputThreadMain(); break; + case 1: DesktopThreadMain(); break; default: ERR("Wrong type: %x\n", Type); } Modified: trunk/reactos/win32ss/user/ntuser/kbdlayout.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/kbdlay…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/kbdlayout.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/kbdlayout.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -131,7 +131,7 @@ L"Control\\Keyboard Layouts\\"; /* Create keyboard layout file object */ - pkf = UserCreateObject(gHandleTable, NULL, NULL, otKBDfile, sizeof(KBDFILE)); + pkf = UserCreateObject(gHandleTable, NULL, NULL, NULL, otKBDfile, sizeof(KBDFILE)); if (!pkf) { ERR("Failed to create object!\n"); @@ -206,7 +206,7 @@ PKL pKl; /* Create keyboard layout object */ - pKl = UserCreateObject(gHandleTable, NULL, NULL, otKBDlayout, sizeof(KL)); + pKl = UserCreateObject(gHandleTable, NULL, NULL, NULL, otKBDlayout, sizeof(KL)); if (!pKl) { ERR("Failed to create object!\n"); 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] Sun Oct 28 10:34:41 2012 @@ -304,6 +304,7 @@ if (ptiCurrent->KeyboardLayout) UserReferenceObject(ptiCurrent->KeyboardLayout); ptiCurrent->TIF_flags &= ~TIF_INCLEANUP; + ptiCurrent->pcti = &ptiCurrent->cti; /* Initialize the CLIENTINFO */ pci = (PCLIENTINFO)pTeb->Win32ClientInfo; @@ -624,14 +625,16 @@ DPRINT("Win32k hInstance 0x%p!\n",hModuleWin); /* Register Object Manager Callbacks */ + CalloutData.ProcessCallout = Win32kProcessCallback; + CalloutData.ThreadCallout = Win32kThreadCallback; CalloutData.WindowStationParseProcedure = IntWinStaObjectParse; CalloutData.WindowStationDeleteProcedure = IntWinStaObjectDelete; + CalloutData.WindowStationOkToCloseProcedure = IntWinstaOkToClose; + CalloutData.DesktopOkToCloseProcedure = IntDesktopOkToClose; CalloutData.DesktopDeleteProcedure = IntDesktopObjectDelete; - CalloutData.ProcessCallout = Win32kProcessCallback; - CalloutData.ThreadCallout = Win32kThreadCallback; + CalloutData.DesktopCloseProcedure = IntDesktopObjectClose; + CalloutData.DesktopOpenProcedure = IntDesktopObjectOpen; CalloutData.BatchFlushRoutine = NtGdiFlushUserBatch; - CalloutData.DesktopOkToCloseProcedure = IntDesktopOkToClose; - CalloutData.WindowStationOkToCloseProcedure = IntWinstaOkToClose; /* Register our per-process and per-thread structures. */ PsEstablishWin32Callouts((PWIN32_CALLOUTS_FPNS)&CalloutData); Modified: trunk/reactos/win32ss/user/ntuser/menu.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/menu.c…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/menu.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/menu.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -249,7 +249,8 @@ PPROCESSINFO CurrentWin32Process; Menu = (PMENU_OBJECT)UserCreateObject( gHandleTable, - NULL, + NULL, + NULL, Handle, otMenu, sizeof(MENU_OBJECT)); @@ -360,8 +361,9 @@ return NULL; Menu = (PMENU_OBJECT)UserCreateObject( gHandleTable, - NULL, - &hMenu, + NULL, + NULL, + &hMenu, otMenu, sizeof(MENU_OBJECT)); if(!Menu) Modified: trunk/reactos/win32ss/user/ntuser/message.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/messag…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/message.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/message.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -714,6 +714,13 @@ pMsg->lParam, &retval); break; + case FNID_MESSAGEWND: + DoCallBack = !UserMessageWindowProc( Window, + pMsg->message, + pMsg->wParam, + pMsg->lParam, + &retval); + break; } } @@ -1306,6 +1313,9 @@ { case FNID_DESKTOP: DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParam,(LRESULT*)&Result); + break; + case FNID_MESSAGEWND: + DoCallBack = !UserMessageWindowProc(Window, Msg, wParam, lParam,(LRESULT*)&Result); break; } if (!DoCallBack) @@ -1589,6 +1599,9 @@ { case FNID_DESKTOP: DoCallBack = !DesktopWindowProc(Window, Msg, wParam, lParamPacked, (LRESULT*)&Result); + break; + case FNID_MESSAGEWND: + DoCallBack = !UserMessageWindowProc(Window, Msg, wParam, lParam,(LRESULT*)&Result); break; } } @@ -2233,6 +2246,16 @@ } break; } + + case FNID_MESSAGEWND: + { + Window = UserGetWindowObject(hWnd); + if (Window) + { + Ret = !UserMessageWindowProc(Window, Msg, wParam, lParam,&lResult); + } + break; + } case FNID_DEFWINDOWPROC: /* Validate input */ if (hWnd) Modified: trunk/reactos/win32ss/user/ntuser/monitor.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/monito…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/monitor.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/monitor.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -32,7 +32,7 @@ PMONITOR IntCreateMonitorObject() { - return UserCreateObject(gHandleTable, NULL, NULL, otMonitor, sizeof(MONITOR)); + return UserCreateObject(gHandleTable, NULL, NULL, NULL, otMonitor, sizeof(MONITOR)); } /* IntDestroyMonitorObject Modified: trunk/reactos/win32ss/user/ntuser/msgqueue.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/msgque…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/msgqueue.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/msgqueue.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -101,7 +101,7 @@ } /* Window has not been found */ - return NULL; + return pwndDesktop; } PCURICON_OBJECT Modified: trunk/reactos/win32ss/user/ntuser/msgqueue.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/msgque…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/msgqueue.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/msgqueue.h [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -298,4 +298,13 @@ DWORD APIENTRY IntGetQueueStatus(DWORD); UINT lParamMemorySize(UINT Msg, WPARAM wParam, LPARAM lParam); + +BOOL FASTCALL +co_IntGetPeekMessage( PMSG pMsg, + HWND hWnd, + UINT MsgFilterMin, + UINT MsgFilterMax, + UINT RemoveMsg, + BOOL bGMSG ); + /* EOF */ Modified: trunk/reactos/win32ss/user/ntuser/object.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/object…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/object.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/object.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -315,20 +315,24 @@ FASTCALL UserCreateObject( PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, + PTHREADINFO pti, HANDLE* h, USER_OBJECT_TYPE type, ULONG size) { HANDLE hi; PVOID Object; - PTHREADINFO pti; PPROCESSINFO ppi; BOOL dt; PDESKTOP rpdesk = pDesktop; - pti = GetW32ThreadInfo(); + /* We could get the desktop for the new object from the pti however this is + * not always the case for example when creating a new desktop window for + * the desktop thread*/ + + if (!pti) pti = GetW32ThreadInfo(); + if (!pDesktop) rpdesk = pti->rpdesk; ppi = pti->ppi; - if (!pDesktop) rpdesk = pti->rpdesk; switch (type) { Modified: trunk/reactos/win32ss/user/ntuser/object.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/object…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/object.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/object.h [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -33,7 +33,7 @@ VOID FASTCALL UserReferenceObject(PVOID obj); PVOID FASTCALL UserReferenceObjectByHandle(HANDLE handle, USER_OBJECT_TYPE type); BOOL FASTCALL UserDereferenceObject(PVOID obj); -PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, struct _DESKTOP* pDesktop, HANDLE* h,USER_OBJECT_TYPE type , ULONG size); +PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, struct _DESKTOP* pDesktop, PTHREADINFO pti, HANDLE* h,USER_OBJECT_TYPE type , ULONG size); BOOL FASTCALL UserDeleteObject(HANDLE h, USER_OBJECT_TYPE type ); PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, USER_OBJECT_TYPE type ); PVOID UserGetObjectNoErr(PUSER_HANDLE_TABLE, HANDLE, USER_OBJECT_TYPE); Modified: trunk/reactos/win32ss/user/ntuser/simplecall.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/simple…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/simplecall.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/simplecall.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -183,7 +183,8 @@ if (count == 0) count = 8; psmwp = (PSMWP) UserCreateObject( gHandleTable, - NULL, + NULL, + NULL, (PHANDLE)&hDwp, otSMWP, sizeof(SMWP)); Modified: trunk/reactos/win32ss/user/ntuser/timer.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/timer.…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/timer.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/timer.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -56,7 +56,7 @@ HANDLE Handle; PTIMER Ret = NULL; - Ret = UserCreateObject(gHandleTable, NULL, &Handle, otTimer, sizeof(TIMER)); + Ret = UserCreateObject(gHandleTable, NULL, NULL, &Handle, otTimer, sizeof(TIMER)); if (Ret) { Ret->head.h = Handle; Modified: trunk/reactos/win32ss/user/ntuser/window.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/window…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/window.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/window.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -1661,7 +1661,8 @@ PCLS Class, PWND ParentWindow, PWND OwnerWindow, - PVOID acbiBuffer) + PVOID acbiBuffer, + PDESKTOP pdeskCreated) { PWND pWnd = NULL; HWND hWnd; @@ -1670,7 +1671,7 @@ BOOL MenuChanged; BOOL bUnicodeWindow; - pti = PsGetCurrentThreadWin32Thread(); + pti = pdeskCreated ? gptiDesktopThread : GetW32ThreadInfo(); if (!(Cs->dwExStyle & WS_EX_LAYOUTRTL)) { @@ -1690,8 +1691,7 @@ */ if ( Class->fnid != FNID_DIALOG ) { - PPROCESSINFO ppi = PsGetCurrentProcessWin32Process(); - if (ppi->dwLayout & LAYOUT_RTL) + if (pti->ppi->dwLayout & LAYOUT_RTL) { Cs->dwExStyle |= WS_EX_LAYOUTRTL; } @@ -1713,7 +1713,8 @@ /* Allocate the new window */ pWnd = (PWND) UserCreateObject( gHandleTable, - pti->rpdesk, + pdeskCreated ? pdeskCreated : pti->rpdesk, + pti, (PHANDLE)&hWnd, otWindow, sizeof(WND) + Class->cbwndExtra); @@ -1723,14 +1724,14 @@ goto AllocError; } - TRACE("Created object with handle %X\n", hWnd); - - if (NULL == pti->rpdesk->DesktopWindow) + TRACE("Created window object with handle %X\n", hWnd); + + if (pdeskCreated && pdeskCreated->DesktopWindow == NULL ) { /* HACK: Helper for win32csr/desktopbg.c */ /* If there is no desktop window yet, we must be creating it */ TRACE("CreateWindow setting desktop.\n"); - pti->rpdesk->DesktopWindow = hWnd; - pti->rpdesk->pDeskInfo->spwnd = pWnd; + pdeskCreated->DesktopWindow = hWnd; + pdeskCreated->pDeskInfo->spwnd = pWnd; } /* @@ -2010,7 +2011,7 @@ pCbtCreate = NULL; /* Get the class and reference it */ - Class = IntGetAndReferenceClass(ClassName, Cs->hInstance); + Class = IntGetAndReferenceClass(ClassName, Cs->hInstance, FALSE); if(!Class) { ERR("Failed to find class %wZ\n", ClassName); @@ -2059,7 +2060,8 @@ Class, ParentWindow, OwnerWindow, - acbiBuffer); + acbiBuffer, + NULL); if(!Window) { ERR("IntCreateWindow failed!\n"); @@ -2502,7 +2504,7 @@ UserEnterExclusive(); /* Call the internal function */ - pwnd = co_UserCreateWindowEx(&Cs, &ustrClassName, plstrWindowName, acbiBuffer); + pwnd = co_UserCreateWindowEx(&Cs, &ustrClassName, plstrWindowName, acbiBuffer, NULL); if(!pwnd) { @@ -2540,12 +2542,15 @@ TRACE("co_UserDestroyWindow \n"); - /* Check for owner thread */ - if ( (Window->head.pti->pEThread != PsGetCurrentThread()) || - Window->head.pti != PsGetCurrentThreadWin32Thread() ) - { - EngSetLastError(ERROR_ACCESS_DENIED); - return FALSE; + /* Check for owner thread */ + if ( Window->head.pti != PsGetCurrentThreadWin32Thread()) + { + /* Check if we are destroying the desktop window */ + if (! ((Window->head.rpdesk->dwDTFlags & DF_DESTROYED) && Window == Window->head.rpdesk->pDeskInfo->spwnd)) + { + EngSetLastError(ERROR_ACCESS_DENIED); + return FALSE; + } } /* If window was created successfully and it is hooked */ Modified: trunk/reactos/win32ss/user/ntuser/window.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/window…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/window.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/window.h [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -47,7 +47,13 @@ BOOL FASTCALL IntShowOwnedPopups( PWND owner, BOOL fShow ); LRESULT FASTCALL IntDefWindowProc( PWND Window, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi); VOID FASTCALL IntNotifyWinEvent(DWORD, PWND, LONG, LONG, DWORD); -PWND FASTCALL co_UserCreateWindowEx(CREATESTRUCTW*, PUNICODE_STRING, PLARGE_STRING, PVOID); +PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs, + PLARGE_STRING WindowName, + PCLS Class, + PWND ParentWindow, + PWND OwnerWindow, + PVOID acbiBuffer, + PDESKTOP pdeskCreated); BOOL FASTCALL IntEnableWindow(HWND,BOOL); BOOL FASTCALL IntIsWindowVisible(PWND); DWORD FASTCALL GetNCHitEx(PWND,POINT); Modified: trunk/reactos/win32ss/user/ntuser/winsta.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/winsta…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/winsta.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/winsta.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -229,10 +229,7 @@ { TEXTMETRICW tmw; UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY"); - if (! IntCreatePrimarySurface()) - { - return FALSE; - } + ScreenDeviceContext = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE); if (NULL == ScreenDeviceContext) { @@ -240,6 +237,11 @@ return FALSE; } GreSetDCOwner(ScreenDeviceContext, GDI_OBJ_HMGR_PUBLIC); + + if (! IntCreatePrimarySurface()) + { + return FALSE; + } /* Setup the cursor */ co_IntLoadDefaultCursors(); Modified: trunk/reactos/win32ss/user/user32/windows/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
============================================================================== --- trunk/reactos/win32ss/user/user32/windows/cursoricon.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/cursoricon.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -2137,21 +2137,23 @@ ULONG ArgumentLength) { BOOL *DefaultCursor = (BOOL*)Arguments; - LRESULT Result = TRUE; + HCURSOR hCursor; if(*DefaultCursor) { /* set default cursor */ - SetCursor(LoadCursorW(0, (LPCWSTR)IDC_ARROW)); + hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW); + SetCursor(hCursor); } else { /* FIXME load system cursor scheme */ SetCursor(0); - SetCursor(LoadCursorW(0, (LPCWSTR)IDC_ARROW)); - } - - return(ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS)); + hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW); + SetCursor(hCursor); + } + + return(ZwCallbackReturn(&hCursor, sizeof(HCURSOR), STATUS_SUCCESS)); } BOOL get_icon_size(HICON hIcon, SIZE *size) Modified: trunk/reactos/win32ss/user/win32csr/desktopbg.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/win32csr/desk…
============================================================================== --- trunk/reactos/win32ss/user/win32csr/desktopbg.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/win32csr/desktopbg.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -1,341 +1,27 @@ -/* - * win32ss/user/win32csr/desktopbg.c - * - * Desktop background window functions - * - * ReactOS Operating System - * - * Looks as a hax fix to a problem of not having a proper class window proc support - * which ReactOS has now. - * - * Notes on reason why this is here: - *
http://www.reactos.org/archives/public/ros-kernel/2003-November/000538.html
- *
http://www.reactos.org/archives/public/ros-kernel/2003-November/000545.html
- *
http://www.reactos.org/archives/public/ros-kernel/2003-November/000586.html
- *
http://www.reactos.org/archives/public/ros-kernel/2003-November/000674.html
- * Revision 6908 Move desktop window proc from WIN32K to CSRSS - * Bugs 42, 48 and 57. - * - *
http://www.reactos.org/archives/public/ros-kernel/2003-December/001186.html
- * - - Now this is used to start Desktops Threads with TEB support. - These first three are Application, Winlogon and ScreenSaver desktops. - - */ - #define NDEBUG #include "w32csr.h" #include <debug.h> -#define DESKTOP_WINDOW_ATOM 32769 - -#define PM_SHOW_DESKTOP 1 -#define PM_HIDE_DESKTOP 2 - -typedef struct tagDTBG_THREAD_DATA -{ - HDESK Desktop; - HANDLE Event; - NTSTATUS Status; -} DTBG_THREAD_DATA, *PDTBG_THREAD_DATA; - -typedef struct tagPRIVATE_NOTIFY_DESKTOP -{ - NMHDR hdr; - struct /* PM_SHOW_DESKTOP */ - { - int Width; - int Height; - } ShowDesktop; -} PRIVATE_NOTIFY_DESKTOP, *PPRIVATE_NOTIFY_DESKTOP; - -static BOOL BgInitialized = FALSE; -static HWND VisibleDesktopWindow = NULL; -#if 0 -static -LRESULT -CALLBACK -DtbgWindowProc(HWND Wnd, - UINT Msg, - WPARAM wParam, - LPARAM lParam) -{ - PAINTSTRUCT PS; - - switch (Msg) - { - case WM_ERASEBKGND: - PaintDesktop((HDC)wParam); - return 1; - - case WM_PAINT: - if (BeginPaint(Wnd, &PS)) - EndPaint(Wnd, &PS); - return 0; - - case WM_SETCURSOR: - return (LRESULT)SetCursor(LoadCursorW(0, (LPCWSTR)IDC_ARROW)); - - case WM_NCCREATE: - return (LRESULT)TRUE; - - case WM_CREATE: - NtUserSetWindowFNID(Wnd, FNID_DESKTOP); // Anti-ReactOS hack! - case WM_CLOSE: - return 0; - - case WM_DISPLAYCHANGE: - MoveWindow(Wnd, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE); - break; - - case WM_NOTIFY: - { - PPRIVATE_NOTIFY_DESKTOP nmh = (PPRIVATE_NOTIFY_DESKTOP)lParam; - - /* Use WM_NOTIFY for private messages since - * it can't be sent between processes! - */ - switch (nmh->hdr.code) - { - case PM_SHOW_DESKTOP: - { - LRESULT Result; - - Result = !SetWindowPos(Wnd, NULL, 0, 0, - nmh->ShowDesktop.Width, - nmh->ShowDesktop.Height, - SWP_NOACTIVATE | SWP_NOZORDER | - SWP_SHOWWINDOW); - - UpdateWindow(Wnd); - VisibleDesktopWindow = Wnd; - return Result; - } - - case PM_HIDE_DESKTOP: - { - LRESULT Result; - - Result = !SetWindowPos(Wnd, NULL, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOZORDER | - SWP_NOMOVE | SWP_NOSIZE | SWP_HIDEWINDOW); - - UpdateWindow(Wnd); - VisibleDesktopWindow = NULL; - return Result; - } - - default: - DPRINT("Unknown notification code 0x%x sent to the desktop window!\n", - nmh->hdr.code); - return 0; - } - } - - default: - return DefWindowProcW(Wnd, Msg, wParam, lParam); - } - - return 0; -} - -static -BOOL -FASTCALL -DtbgInit(VOID) -{ - WNDCLASSEXW Class; - ATOM ClassAtom; - - /* - * Create the desktop window class - */ - Class.cbSize = sizeof(WNDCLASSEXW); - Class.style = 0; // Local Class - Class.lpfnWndProc = DtbgWindowProc; - Class.cbClsExtra = 0; - Class.cbWndExtra = 0; - Class.hInstance = (HINSTANCE)GetModuleHandleW(NULL); - Class.hIcon = NULL; - Class.hCursor = NULL; - Class.hbrBackground = GetSysColorBrush(COLOR_BACKGROUND); - Class.lpszMenuName = NULL; - Class.lpszClassName = (LPCWSTR)DESKTOP_WINDOW_ATOM; - ClassAtom = RegisterClassExW(&Class); - - if (ClassAtom == INVALID_ATOM) - { - DPRINT1("Unable to register desktop background class (error %d)\n", - GetLastError()); - - return FALSE; - } - - VisibleDesktopWindow = NULL; - - return TRUE; -} -#endif -static -DWORD -WINAPI -DtbgDesktopThread(PVOID Data) -{ - HWND BackgroundWnd; - MSG msg; - PDTBG_THREAD_DATA ThreadData = (PDTBG_THREAD_DATA)Data; - - DPRINT("DtbgDesktopThread\n"); - - if (!SetThreadDesktop(ThreadData->Desktop)) - { - DPRINT1("Failed to set thread desktop\n"); - ThreadData->Status = STATUS_UNSUCCESSFUL; - SetEvent(ThreadData->Event); - return 1; - } - - BackgroundWnd = CreateWindowW((LPCWSTR)DESKTOP_WINDOW_ATOM, - L"", - WS_POPUP | WS_CLIPCHILDREN, - GetSystemMetrics(SM_XVIRTUALSCREEN), - GetSystemMetrics(SM_YVIRTUALSCREEN), - GetSystemMetrics(SM_CXVIRTUALSCREEN), - GetSystemMetrics(SM_CYVIRTUALSCREEN), - NULL, NULL, - (HINSTANCE)GetModuleHandleW(L"user32.dll"), // Run in win32k/user32. - NULL); - - if (NULL == BackgroundWnd) - { - DPRINT1("Failed to create desktop background window\n"); - ThreadData->Status = STATUS_UNSUCCESSFUL; - SetEvent(ThreadData->Event); - return 1; - } - - DPRINT("BackgroundWnd 0x%p\n",BackgroundWnd); - - ThreadData->Status = STATUS_SUCCESS; - SetEvent(ThreadData->Event); - - while (GetMessageW(&msg, NULL, 0, 0)) - { - if (msg.message == WM_QUIT) - { - DPRINT1("DtbgDesktopThread WM_QUIT\n"); - } - TranslateMessage(&msg); - DispatchMessageW(&msg); - } - - DPRINT1("DtbgDesktopThread Exit\n"); - return 1; -} - CSR_API(CsrCreateDesktop) { - DTBG_THREAD_DATA ThreadData; - HANDLE ThreadHandle; - - DPRINT("CsrCreateDesktop\n"); - - if (!BgInitialized) - { - BgInitialized = TRUE; - - // if (!DtbgInit()) - // return STATUS_UNSUCCESSFUL; - } - - /* - * The desktop handle we got from win32k is in - * the scope of CSRSS so we can just use it. - */ - ThreadData.Desktop = Request->Data.CreateDesktopRequest.DesktopHandle; - - ThreadData.Event = CreateEventW(NULL, FALSE, FALSE, NULL); - - if (NULL == ThreadData.Event) - { - DPRINT1("Failed to create event (error %d)\n", GetLastError()); - return STATUS_UNSUCCESSFUL; - } - - ThreadHandle = CreateThread(NULL, - 0, - DtbgDesktopThread, - (PVOID)&ThreadData, - 0, - NULL); - - if (NULL == ThreadHandle) - { - CloseHandle(ThreadData.Event); - DPRINT1("Failed to create desktop window thread.\n"); - return STATUS_UNSUCCESSFUL; - } - - CloseHandle(ThreadHandle); - - WaitForSingleObject(ThreadData.Event, INFINITE); - CloseHandle(ThreadData.Event); - - return ThreadData.Status; + return STATUS_SUCCESS; } CSR_API(CsrShowDesktop) { -#if 0 - PRIVATE_NOTIFY_DESKTOP nmh; - DPRINT("CsrShowDesktop\n"); - - nmh.hdr.hwndFrom = Request->Data.ShowDesktopRequest.DesktopWindow; - nmh.hdr.idFrom = 0; - nmh.hdr.code = PM_SHOW_DESKTOP; - - nmh.ShowDesktop.Width = (int)Request->Data.ShowDesktopRequest.Width; - nmh.ShowDesktop.Height = (int)Request->Data.ShowDesktopRequest.Height; - - if (SendMessageW(Request->Data.ShowDesktopRequest.DesktopWindow, - WM_NOTIFY, - (WPARAM)nmh.hdr.hwndFrom, - (LPARAM)&nmh)) - { - return STATUS_UNSUCCESSFUL; - } -#endif return STATUS_SUCCESS; } CSR_API(CsrHideDesktop) { -#if 0 - PRIVATE_NOTIFY_DESKTOP nmh; - DPRINT("CsrHideDesktop\n"); - - nmh.hdr.hwndFrom = Request->Data.ShowDesktopRequest.DesktopWindow; - nmh.hdr.idFrom = 0; - nmh.hdr.code = PM_HIDE_DESKTOP; - - if (SendMessageW(Request->Data.ShowDesktopRequest.DesktopWindow, - WM_NOTIFY, - (WPARAM)nmh.hdr.hwndFrom, - (LPARAM)&nmh)) - { - return STATUS_UNSUCCESSFUL; - } -#endif return STATUS_SUCCESS; } BOOL -FASTCALL -DtbgIsDesktopVisible(VOID) +FASTCALL DtbgIsDesktopVisible(VOID) { - VisibleDesktopWindow = GetDesktopWindow(); // DESKTOPWNDPROC + HWND VisibleDesktopWindow = GetDesktopWindow(); // DESKTOPWNDPROC if (VisibleDesktopWindow != NULL && !IsWindowVisible(VisibleDesktopWindow)) Modified: trunk/reactos/win32ss/user/win32csr/dllmain.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/win32csr/dllm…
============================================================================== --- trunk/reactos/win32ss/user/win32csr/dllmain.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/win32csr/dllmain.c [iso-8859-1] Sun Oct 28 10:34:41 2012 @@ -331,6 +331,7 @@ HANDLE ServerThread; CLIENT_ID ClientId; NTSTATUS Status; + UINT i; Win32CsrApiHeap = RtlGetProcessHeap(); @@ -352,15 +353,18 @@ RtlInitializeCriticalSection(&Win32CsrDefineDosDeviceCritSec); InitializeListHead(&DosDeviceHistory); - /* Start Raw Input Threads */ - Status = RtlCreateUserThread(NtCurrentProcess(), NULL, TRUE, 0, 0, 0, (PTHREAD_START_ROUTINE)CreateSystemThreads, (PVOID)0, &ServerThread, &ClientId); - if (NT_SUCCESS(Status)) - { - NtResumeThread(ServerThread, NULL); - NtClose(ServerThread); - } - else - DPRINT1("Cannot start Raw Input Thread!\n"); + /* Start the Raw Input Thread and the Desktop Thread */ + for (i = 0; i < 2; ++i) + { + Status = RtlCreateUserThread(NtCurrentProcess(), NULL, TRUE, 0, 0, 0, (PTHREAD_START_ROUTINE)CreateSystemThreads, (PVOID)i, &ServerThread, &ClientId); + if (NT_SUCCESS(Status)) + { + NtResumeThread(ServerThread, NULL); + NtClose(ServerThread); + } + else + DPRINT1("Cannot start Raw Input Thread!\n"); + } return STATUS_SUCCESS; }
12 years, 1 month
1
0
0
0
← Newer
1
2
3
4
5
6
...
22
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
Results per page:
10
25
50
100
200