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
July 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
193 discussions
Start a n
N
ew thread
[ekohl] 56850: [SAMSRV] - Implement SampGetObjectAttributeString to retrieve the size of a string, allocate a buffer and retrieve the string from the registry. - Use SampGetObjectAttributeString to...
by ekohl@svn.reactos.org
Author: ekohl Date: Sun Jul 8 09:33:35 2012 New Revision: 56850 URL:
http://svn.reactos.org/svn/reactos?rev=56850&view=rev
Log: [SAMSRV] - Implement SampGetObjectAttributeString to retrieve the size of a string, allocate a buffer and retrieve the string from the registry. - Use SampGetObjectAttributeString to retrieve string attributes in SamrQueryInformationXxx functions. - Add most missing cases to SamrQueryInformationUser. - Fix a type mismatch in ntsam.h. Modified: trunk/reactos/dll/win32/samsrv/database.c trunk/reactos/dll/win32/samsrv/samrpc.c trunk/reactos/dll/win32/samsrv/samsrv.h trunk/reactos/include/ddk/ntsam.h trunk/reactos/include/reactos/idl/sam.idl Modified: trunk/reactos/dll/win32/samsrv/database.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/database.…
============================================================================== --- trunk/reactos/dll/win32/samsrv/database.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/samsrv/database.c [iso-8859-1] Sun Jul 8 09:33:35 2012 @@ -705,5 +705,59 @@ return Status; } + +NTSTATUS +SampGetObjectAttributeString(PSAM_DB_OBJECT DbObject, + LPWSTR AttributeName, + RPC_UNICODE_STRING *String) +{ + ULONG Length = 0; + NTSTATUS Status; + + Status = SampGetObjectAttribute(DbObject, + AttributeName, + NULL, + NULL, + &Length); + if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + String->Length = Length - sizeof(WCHAR); + String->MaximumLength = Length; + String->Buffer = midl_user_allocate(Length); + if (String->Buffer == NULL) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto done; + } + + TRACE("Length: %lu\n", Length); + Status = SampGetObjectAttribute(DbObject, + AttributeName, + NULL, + (PVOID)String->Buffer, + &Length); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + +done: + if (!NT_SUCCESS(Status)) + { + if (String->Buffer != NULL) + { + midl_user_free(String->Buffer); + String->Buffer = NULL; + } + } + + return Status; +} + /* EOF */ 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 Jul 8 09:33:35 2012 @@ -618,83 +618,35 @@ InfoBuffer->General.DomainServerRole = FixedData.DomainServerRole; InfoBuffer->General.UasCompatibilityRequired = FixedData.UasCompatibilityRequired; - Length = 0; - Status = SampGetObjectAttribute(DomainObject, - L"OemInformation", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status)) - goto done; - - InfoBuffer->General.OemInformation.Length = Length - sizeof(WCHAR); - InfoBuffer->General.OemInformation.MaximumLength = Length; - InfoBuffer->General.OemInformation.Buffer = midl_user_allocate(Length); - if (InfoBuffer->General.OemInformation.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - Status = SampGetObjectAttribute(DomainObject, - L"OemInformation", - NULL, - (PVOID)InfoBuffer->General.OemInformation.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - goto done; - - Length = 0; - Status = SampGetObjectAttribute(DomainObject, - L"Name", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status)) - goto done; - - InfoBuffer->General.DomainName.Length = Length - sizeof(WCHAR); - InfoBuffer->General.DomainName.MaximumLength = Length; - InfoBuffer->General.DomainName.Buffer = midl_user_allocate(Length); - if (InfoBuffer->General.DomainName.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - Status = SampGetObjectAttribute(DomainObject, - L"Name", - NULL, - (PVOID)InfoBuffer->General.DomainName.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - goto done; - - Length = 0; - Status = SampGetObjectAttribute(DomainObject, - L"ReplicaSourceNodeName", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status)) - goto done; - - InfoBuffer->General.ReplicaSourceNodeName.Length = Length - sizeof(WCHAR); - InfoBuffer->General.ReplicaSourceNodeName.MaximumLength = Length; - InfoBuffer->General.ReplicaSourceNodeName.Buffer = midl_user_allocate(Length); - if (InfoBuffer->General.ReplicaSourceNodeName.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - Status = SampGetObjectAttribute(DomainObject, - L"ReplicaSourceNodeName", - NULL, - (PVOID)InfoBuffer->General.ReplicaSourceNodeName.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - goto done; + /* Get the OemInformation string */ + Status = SampGetObjectAttributeString(DomainObject, + L"OemInformation", + &InfoBuffer->General.OemInformation); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the Name string */ + Status = SampGetObjectAttributeString(DomainObject, + L"Name", + &InfoBuffer->General.DomainName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the ReplicaSourceNodeName string */ + Status = SampGetObjectAttributeString(DomainObject, + L"ReplicaSourceNodeName", + &InfoBuffer->General.ReplicaSourceNodeName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } InfoBuffer->General.UserCount = 0; /* FIXME */ InfoBuffer->General.GroupCount = 0; /* FIXME */ @@ -771,7 +723,6 @@ PSAMPR_DOMAIN_INFO_BUFFER *Buffer) { PSAMPR_DOMAIN_INFO_BUFFER InfoBuffer = NULL; - ULONG Length = 0; NTSTATUS Status; *Buffer = NULL; @@ -780,30 +731,15 @@ if (InfoBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES; - Status = SampGetObjectAttribute(DomainObject, - L"OemInformation", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status)) - goto done; - - InfoBuffer->Oem.OemInformation.Length = Length - sizeof(WCHAR); - InfoBuffer->Oem.OemInformation.MaximumLength = Length; - InfoBuffer->Oem.OemInformation.Buffer = midl_user_allocate(Length); - if (InfoBuffer->Oem.OemInformation.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - Status = SampGetObjectAttribute(DomainObject, - L"OemInformation", - NULL, - (PVOID)InfoBuffer->Oem.OemInformation.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - goto done; + /* Get the OemInformation string */ + Status = SampGetObjectAttributeString(DomainObject, + L"OemInformation", + &InfoBuffer->Oem.OemInformation); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } *Buffer = InfoBuffer; @@ -828,7 +764,6 @@ PSAMPR_DOMAIN_INFO_BUFFER *Buffer) { PSAMPR_DOMAIN_INFO_BUFFER InfoBuffer = NULL; - ULONG Length = 0; NTSTATUS Status; *Buffer = NULL; @@ -837,30 +772,15 @@ if (InfoBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES; - Status = SampGetObjectAttribute(DomainObject, - L"Name", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status)) - goto done; - - InfoBuffer->Name.DomainName.Length = Length - sizeof(WCHAR); - InfoBuffer->Name.DomainName.MaximumLength = Length; - InfoBuffer->Name.DomainName.Buffer = midl_user_allocate(Length); - if (InfoBuffer->Name.DomainName.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - Status = SampGetObjectAttribute(DomainObject, - L"Name", - NULL, - (PVOID)InfoBuffer->Name.DomainName.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - goto done; + /* Get the Name string */ + Status = SampGetObjectAttributeString(DomainObject, + L"Name", + &InfoBuffer->Name.DomainName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } *Buffer = InfoBuffer; @@ -885,7 +805,6 @@ PSAMPR_DOMAIN_INFO_BUFFER *Buffer) { PSAMPR_DOMAIN_INFO_BUFFER InfoBuffer = NULL; - ULONG Length = 0; NTSTATUS Status; *Buffer = NULL; @@ -894,30 +813,15 @@ if (InfoBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES; - Status = SampGetObjectAttribute(DomainObject, - L"ReplicaSourceNodeName", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status)) - goto done; - - InfoBuffer->Replication.ReplicaSourceNodeName.Length = Length - sizeof(WCHAR); - InfoBuffer->Replication.ReplicaSourceNodeName.MaximumLength = Length; - InfoBuffer->Replication.ReplicaSourceNodeName.Buffer = midl_user_allocate(Length); - if (InfoBuffer->Replication.ReplicaSourceNodeName.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - Status = SampGetObjectAttribute(DomainObject, - L"ReplicaSourceNodeName", - NULL, - (PVOID)InfoBuffer->Replication.ReplicaSourceNodeName.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - goto done; + /* Get the ReplicaSourceNodeName string */ + Status = SampGetObjectAttributeString(DomainObject, + L"ReplicaSourceNodeName", + &InfoBuffer->Replication.ReplicaSourceNodeName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } *Buffer = InfoBuffer; @@ -1099,83 +1003,35 @@ InfoBuffer->General2.LockoutObservationWindow = FixedData.LockoutObservationWindow; InfoBuffer->General2.LockoutThreshold = FixedData.LockoutThreshold; - Length = 0; - Status = SampGetObjectAttribute(DomainObject, - L"OemInformation", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status)) - goto done; - - InfoBuffer->General2.I1.OemInformation.Length = Length - sizeof(WCHAR); - InfoBuffer->General2.I1.OemInformation.MaximumLength = Length; - InfoBuffer->General2.I1.OemInformation.Buffer = midl_user_allocate(Length); - if (InfoBuffer->General2.I1.OemInformation.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - Status = SampGetObjectAttribute(DomainObject, - L"OemInformation", - NULL, - (PVOID)InfoBuffer->General2.I1.OemInformation.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - goto done; - - Length = 0; - Status = SampGetObjectAttribute(DomainObject, - L"Name", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status)) - goto done; - - InfoBuffer->General2.I1.DomainName.Length = Length - sizeof(WCHAR); - InfoBuffer->General2.I1.DomainName.MaximumLength = Length; - InfoBuffer->General2.I1.DomainName.Buffer = midl_user_allocate(Length); - if (InfoBuffer->General2.I1.DomainName.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - Status = SampGetObjectAttribute(DomainObject, - L"Name", - NULL, - (PVOID)InfoBuffer->General2.I1.DomainName.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - goto done; - - Length = 0; - Status = SampGetObjectAttribute(DomainObject, - L"ReplicaSourceNodeName", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status)) - goto done; - - InfoBuffer->General2.I1.ReplicaSourceNodeName.Length = Length - sizeof(WCHAR); - InfoBuffer->General2.I1.ReplicaSourceNodeName.MaximumLength = Length; - InfoBuffer->General2.I1.ReplicaSourceNodeName.Buffer = midl_user_allocate(Length); - if (InfoBuffer->General2.I1.ReplicaSourceNodeName.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - Status = SampGetObjectAttribute(DomainObject, - L"ReplicaSourceNodeName", - NULL, - (PVOID)InfoBuffer->General2.I1.ReplicaSourceNodeName.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - goto done; + /* Get the OemInformation string */ + Status = SampGetObjectAttributeString(DomainObject, + L"OemInformation", + &InfoBuffer->General2.I1.OemInformation); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the Name string */ + Status = SampGetObjectAttributeString(DomainObject, + L"Name", + &InfoBuffer->General2.I1.DomainName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the ReplicaSourceNodeName string */ + Status = SampGetObjectAttributeString(DomainObject, + L"ReplicaSourceNodeName", + &InfoBuffer->General2.I1.ReplicaSourceNodeName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } InfoBuffer->General2.I1.UserCount = 0; /* FIXME */ InfoBuffer->General2.I1.GroupCount = 0; /* FIXME */ @@ -2549,8 +2405,6 @@ { PSAMPR_ALIAS_INFO_BUFFER InfoBuffer = NULL; HANDLE MembersKeyHandle = NULL; - ULONG NameLength = 0; - ULONG DescriptionLength = 0; NTSTATUS Status; *Buffer = NULL; @@ -2559,65 +2413,18 @@ if (InfoBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES; - Status = SampGetObjectAttribute(AliasObject, - L"Name", - NULL, - NULL, - &NameLength); - TRACE("Status 0x%08lx\n", Status); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) + Status = SampGetObjectAttributeString(AliasObject, + L"Name", + &InfoBuffer->General.Name); + if (!NT_SUCCESS(Status)) { TRACE("Status 0x%08lx\n", Status); goto done; } - InfoBuffer->General.Name.Length = NameLength - sizeof(WCHAR); - InfoBuffer->General.Name.MaximumLength = NameLength; - InfoBuffer->General.Name.Buffer = midl_user_allocate(NameLength); - if (InfoBuffer->General.Name.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - TRACE("Name Length: %lu\n", NameLength); - Status = SampGetObjectAttribute(AliasObject, - L"Name", - NULL, - (PVOID)InfoBuffer->General.Name.Buffer, - &NameLength); - if (!NT_SUCCESS(Status)) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - Status = SampGetObjectAttribute(AliasObject, - L"Description", - NULL, - NULL, - &DescriptionLength); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - InfoBuffer->General.AdminComment.Length = DescriptionLength - sizeof(WCHAR); - InfoBuffer->General.AdminComment.MaximumLength = DescriptionLength; - InfoBuffer->General.AdminComment.Buffer = midl_user_allocate(DescriptionLength); - if (InfoBuffer->General.AdminComment.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - TRACE("Description Length: %lu\n", DescriptionLength); - Status = SampGetObjectAttribute(AliasObject, - L"Description", - NULL, - (PVOID)InfoBuffer->General.AdminComment.Buffer, - &DescriptionLength); + Status = SampGetObjectAttributeString(AliasObject, + L"Description", + &InfoBuffer->General.AdminComment); if (!NT_SUCCESS(Status)) { TRACE("Status 0x%08lx\n", Status); @@ -2674,7 +2481,6 @@ PSAMPR_ALIAS_INFO_BUFFER *Buffer) { PSAMPR_ALIAS_INFO_BUFFER InfoBuffer = NULL; - ULONG Length = 0; NTSTATUS Status; *Buffer = NULL; @@ -2683,32 +2489,9 @@ if (InfoBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES; - Status = SampGetObjectAttribute(AliasObject, - L"Name", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - InfoBuffer->Name.Name.Length = Length - sizeof(WCHAR); - InfoBuffer->Name.Name.MaximumLength = Length; - InfoBuffer->Name.Name.Buffer = midl_user_allocate(Length); - if (InfoBuffer->Name.Name.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - TRACE("Length: %lu\n", Length); - Status = SampGetObjectAttribute(AliasObject, - L"Name", - NULL, - (PVOID)InfoBuffer->Name.Name.Buffer, - &Length); + Status = SampGetObjectAttributeString(AliasObject, + L"Name", + &InfoBuffer->Name.Name); if (!NT_SUCCESS(Status)) { TRACE("Status 0x%08lx\n", Status); @@ -2738,7 +2521,6 @@ PSAMPR_ALIAS_INFO_BUFFER *Buffer) { PSAMPR_ALIAS_INFO_BUFFER InfoBuffer = NULL; - ULONG Length = 0; NTSTATUS Status; *Buffer = NULL; @@ -2747,30 +2529,14 @@ if (InfoBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES; - Status = SampGetObjectAttribute(AliasObject, - L"Description", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) - goto done; - - InfoBuffer->AdminComment.AdminComment.Length = Length - sizeof(WCHAR); - InfoBuffer->AdminComment.AdminComment.MaximumLength = Length; - InfoBuffer->AdminComment.AdminComment.Buffer = midl_user_allocate(Length); - if (InfoBuffer->AdminComment.AdminComment.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - Status = SampGetObjectAttribute(AliasObject, - L"Description", - NULL, - (PVOID)InfoBuffer->AdminComment.AdminComment.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - goto done; + Status = SampGetObjectAttributeString(AliasObject, + L"Description", + &InfoBuffer->AdminComment.AdminComment); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } *Buffer = InfoBuffer; @@ -3180,237 +2946,8 @@ static NTSTATUS -SampQueryUserName(PSAM_DB_OBJECT UserObject, - PSAMPR_USER_INFO_BUFFER *Buffer) -{ - PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; - ULONG Length = 0; - NTSTATUS Status; - - *Buffer = NULL; - - InfoBuffer = midl_user_allocate(sizeof(SAMPR_USER_INFO_BUFFER)); - if (InfoBuffer == NULL) - return STATUS_INSUFFICIENT_RESOURCES; - - Status = SampGetObjectAttribute(UserObject, - L"Name", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - InfoBuffer->Name.UserName.Length = Length - sizeof(WCHAR); - InfoBuffer->Name.UserName.MaximumLength = Length; - InfoBuffer->Name.UserName.Buffer = midl_user_allocate(Length); - if (InfoBuffer->Name.UserName.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - TRACE("Length: %lu\n", Length); - Status = SampGetObjectAttribute(UserObject, - L"Name", - NULL, - (PVOID)InfoBuffer->Name.UserName.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - Length = 0; - Status = SampGetObjectAttribute(UserObject, - L"FullName", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - InfoBuffer->Name.FullName.Length = Length - sizeof(WCHAR); - InfoBuffer->Name.FullName.MaximumLength = Length; - InfoBuffer->Name.FullName.Buffer = midl_user_allocate(Length); - if (InfoBuffer->Name.FullName.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - TRACE("Length: %lu\n", Length); - Status = SampGetObjectAttribute(UserObject, - L"FullName", - NULL, - (PVOID)InfoBuffer->Name.FullName.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - *Buffer = InfoBuffer; - -done: - if (!NT_SUCCESS(Status)) - { - if (InfoBuffer != NULL) - { - if (InfoBuffer->Name.UserName.Buffer != NULL) - midl_user_free(InfoBuffer->Name.UserName.Buffer); - - if (InfoBuffer->Name.FullName.Buffer != NULL) - midl_user_free(InfoBuffer->Name.FullName.Buffer); - - midl_user_free(InfoBuffer); - } - } - - return Status; -} - - -static NTSTATUS -SampQueryUserAccountName(PSAM_DB_OBJECT UserObject, - PSAMPR_USER_INFO_BUFFER *Buffer) -{ - PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; - ULONG Length = 0; - NTSTATUS Status; - - *Buffer = NULL; - - InfoBuffer = midl_user_allocate(sizeof(SAMPR_USER_INFO_BUFFER)); - if (InfoBuffer == NULL) - return STATUS_INSUFFICIENT_RESOURCES; - - Status = SampGetObjectAttribute(UserObject, - L"Name", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - InfoBuffer->AccountName.UserName.Length = Length - sizeof(WCHAR); - InfoBuffer->AccountName.UserName.MaximumLength = Length; - InfoBuffer->AccountName.UserName.Buffer = midl_user_allocate(Length); - if (InfoBuffer->AccountName.UserName.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - TRACE("Length: %lu\n", Length); - Status = SampGetObjectAttribute(UserObject, - L"Name", - NULL, - (PVOID)InfoBuffer->AccountName.UserName.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - *Buffer = InfoBuffer; - -done: - if (!NT_SUCCESS(Status)) - { - if (InfoBuffer != NULL) - { - if (InfoBuffer->AccountName.UserName.Buffer != NULL) - midl_user_free(InfoBuffer->AccountName.UserName.Buffer); - - midl_user_free(InfoBuffer); - } - } - - return Status; -} - - -static NTSTATUS -SampQueryUserFullName(PSAM_DB_OBJECT UserObject, - PSAMPR_USER_INFO_BUFFER *Buffer) -{ - PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; - ULONG Length = 0; - NTSTATUS Status; - - *Buffer = NULL; - - InfoBuffer = midl_user_allocate(sizeof(SAMPR_USER_INFO_BUFFER)); - if (InfoBuffer == NULL) - return STATUS_INSUFFICIENT_RESOURCES; - - Status = SampGetObjectAttribute(UserObject, - L"FullName", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - InfoBuffer->FullName.FullName.Length = Length - sizeof(WCHAR); - InfoBuffer->FullName.FullName.MaximumLength = Length; - InfoBuffer->FullName.FullName.Buffer = midl_user_allocate(Length); - if (InfoBuffer->FullName.FullName.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - TRACE("Length: %lu\n", Length); - Status = SampGetObjectAttribute(UserObject, - L"FullName", - NULL, - (PVOID)InfoBuffer->FullName.FullName.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - *Buffer = InfoBuffer; - -done: - if (!NT_SUCCESS(Status)) - { - if (InfoBuffer != NULL) - { - if (InfoBuffer->FullName.FullName.Buffer != NULL) - midl_user_free(InfoBuffer->FullName.FullName.Buffer); - - midl_user_free(InfoBuffer); - } - } - - return Status; -} - - -static -NTSTATUS -SampQueryUserPrimaryGroup(PSAM_DB_OBJECT UserObject, - PSAMPR_USER_INFO_BUFFER *Buffer) +SampQueryUserGeneral(PSAM_DB_OBJECT UserObject, + PSAMPR_USER_INFO_BUFFER *Buffer) { PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; SAM_USER_FIXED_DATA FixedData; @@ -3432,6 +2969,610 @@ if (!NT_SUCCESS(Status)) goto done; + InfoBuffer->General.PrimaryGroupId = FixedData.PrimaryGroupId; + + /* Get the Name string */ + Status = SampGetObjectAttributeString(UserObject, + L"Name", + &InfoBuffer->General.UserName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the FullName string */ + Status = SampGetObjectAttributeString(UserObject, + L"FullName", + &InfoBuffer->General.FullName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the AdminComment string */ + Status = SampGetObjectAttributeString(UserObject, + L"AdminComment", + &InfoBuffer->General.AdminComment); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the UserComment string */ + Status = SampGetObjectAttributeString(UserObject, + L"UserComment", + &InfoBuffer->General.UserComment); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + *Buffer = InfoBuffer; + +done: + if (!NT_SUCCESS(Status)) + { + if (InfoBuffer != NULL) + { + if (InfoBuffer->General.UserName.Buffer != NULL) + midl_user_free(InfoBuffer->General.UserName.Buffer); + + if (InfoBuffer->General.FullName.Buffer != NULL) + midl_user_free(InfoBuffer->General.FullName.Buffer); + + if (InfoBuffer->General.AdminComment.Buffer != NULL) + midl_user_free(InfoBuffer->General.AdminComment.Buffer); + + if (InfoBuffer->General.UserComment.Buffer != NULL) + midl_user_free(InfoBuffer->General.UserComment.Buffer); + + midl_user_free(InfoBuffer); + } + } + + return Status; +} + + +static +NTSTATUS +SampQueryUserPreferences(PSAM_DB_OBJECT UserObject, + PSAMPR_USER_INFO_BUFFER *Buffer) +{ + PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; + SAM_USER_FIXED_DATA FixedData; + ULONG Length = 0; + NTSTATUS Status; + + *Buffer = NULL; + + InfoBuffer = midl_user_allocate(sizeof(SAMPR_USER_INFO_BUFFER)); + if (InfoBuffer == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + Length = sizeof(SAM_USER_FIXED_DATA); + Status = SampGetObjectAttribute(UserObject, + L"F", + NULL, + (PVOID)&FixedData, + &Length); + if (!NT_SUCCESS(Status)) + goto done; + + InfoBuffer->Preferences.CountryCode = FixedData.CountryCode; + InfoBuffer->Preferences.CodePage = FixedData.CodePage; + + /* Get the UserComment string */ + Status = SampGetObjectAttributeString(UserObject, + L"UserComment", + &InfoBuffer->Preferences.UserComment); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + *Buffer = InfoBuffer; + +done: + if (!NT_SUCCESS(Status)) + { + if (InfoBuffer != NULL) + { + if (InfoBuffer->Preferences.UserComment.Buffer != NULL) + midl_user_free(InfoBuffer->Preferences.UserComment.Buffer); + + midl_user_free(InfoBuffer); + } + } + + return Status; +} + + +static +NTSTATUS +SampQueryUserLogon(PSAM_DB_OBJECT UserObject, + PSAMPR_USER_INFO_BUFFER *Buffer) +{ + PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; + SAM_USER_FIXED_DATA FixedData; + ULONG Length = 0; + NTSTATUS Status; + + *Buffer = NULL; + + InfoBuffer = midl_user_allocate(sizeof(SAMPR_USER_INFO_BUFFER)); + if (InfoBuffer == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + Length = sizeof(SAM_USER_FIXED_DATA); + Status = SampGetObjectAttribute(UserObject, + L"F", + NULL, + (PVOID)&FixedData, + &Length); + if (!NT_SUCCESS(Status)) + goto done; + + InfoBuffer->Logon.UserId = FixedData.UserId; + InfoBuffer->Logon.PrimaryGroupId = FixedData.PrimaryGroupId; + InfoBuffer->Logon.LastLogon.LowPart = FixedData.LastLogon.LowPart; + InfoBuffer->Logon.LastLogon.HighPart = FixedData.LastLogon.HighPart; + InfoBuffer->Logon.LastLogoff.LowPart = FixedData.LastLogoff.LowPart; + InfoBuffer->Logon.LastLogoff.HighPart = FixedData.LastLogoff.HighPart; + InfoBuffer->Logon.PasswordLastSet.LowPart = FixedData.PasswordLastSet.LowPart; + InfoBuffer->Logon.PasswordLastSet.HighPart = FixedData.PasswordLastSet.HighPart; + InfoBuffer->Logon.BadPasswordCount = FixedData.BadPasswordCount; + InfoBuffer->Logon.LogonCount = FixedData.LogonCount; + InfoBuffer->Logon.UserAccountControl = FixedData.UserAccountControl; + +// OLD_LARGE_INTEGER PasswordCanChange; +// OLD_LARGE_INTEGER PasswordMustChange; + + /* Get the Name string */ + Status = SampGetObjectAttributeString(UserObject, + L"Name", + &InfoBuffer->Logon.UserName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the FullName string */ + Status = SampGetObjectAttributeString(UserObject, + L"FullName", + &InfoBuffer->Logon.FullName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the HomeDirectory string */ + Status = SampGetObjectAttributeString(UserObject, + L"HomeDirectory", + &InfoBuffer->Logon.HomeDirectory); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the HomeDirectoryDrive string */ + Status = SampGetObjectAttributeString(UserObject, + L"HomeDirectoryDrive", + &InfoBuffer->Logon.HomeDirectoryDrive); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the ScriptPath string */ + Status = SampGetObjectAttributeString(UserObject, + L"ScriptPath", + &InfoBuffer->Logon.ScriptPath); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the ProfilePath string */ + Status = SampGetObjectAttributeString(UserObject, + L"ProfilePath", + &InfoBuffer->Logon.ProfilePath); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the WorkStations string */ + Status = SampGetObjectAttributeString(UserObject, + L"WorkStations", + &InfoBuffer->Logon.WorkStations); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* FIXME: LogonHours */ + + *Buffer = InfoBuffer; + +done: + if (!NT_SUCCESS(Status)) + { + if (InfoBuffer != NULL) + { + if (InfoBuffer->Logon.UserName.Buffer != NULL) + midl_user_free(InfoBuffer->Logon.UserName.Buffer); + + if (InfoBuffer->Logon.FullName.Buffer != NULL) + midl_user_free(InfoBuffer->Logon.FullName.Buffer); + + if (InfoBuffer->Logon.HomeDirectory.Buffer != NULL) + midl_user_free(InfoBuffer->Logon.HomeDirectory.Buffer); + + if (InfoBuffer->Logon.HomeDirectoryDrive.Buffer != NULL) + midl_user_free(InfoBuffer->Logon.HomeDirectoryDrive.Buffer); + + if (InfoBuffer->Logon.ScriptPath.Buffer != NULL) + midl_user_free(InfoBuffer->Logon.ScriptPath.Buffer); + + if (InfoBuffer->Logon.ProfilePath.Buffer != NULL) + midl_user_free(InfoBuffer->Logon.ProfilePath.Buffer); + + if (InfoBuffer->Logon.WorkStations.Buffer != NULL) + midl_user_free(InfoBuffer->Logon.WorkStations.Buffer); + + if (InfoBuffer->Logon.LogonHours.LogonHours != NULL) + midl_user_free(InfoBuffer->Logon.LogonHours.LogonHours); + + midl_user_free(InfoBuffer); + } + } + + return Status; +} + + + + +static +NTSTATUS +SampQueryUserAccount(PSAM_DB_OBJECT UserObject, + PSAMPR_USER_INFO_BUFFER *Buffer) +{ + PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; + SAM_USER_FIXED_DATA FixedData; + ULONG Length = 0; + NTSTATUS Status; + + *Buffer = NULL; + + InfoBuffer = midl_user_allocate(sizeof(SAMPR_USER_INFO_BUFFER)); + if (InfoBuffer == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + Length = sizeof(SAM_USER_FIXED_DATA); + Status = SampGetObjectAttribute(UserObject, + L"F", + NULL, + (PVOID)&FixedData, + &Length); + if (!NT_SUCCESS(Status)) + goto done; + + InfoBuffer->Account.UserId = FixedData.UserId; + InfoBuffer->Account.PrimaryGroupId = FixedData.PrimaryGroupId; + InfoBuffer->Account.LastLogon.LowPart = FixedData.LastLogon.LowPart; + InfoBuffer->Account.LastLogon.HighPart = FixedData.LastLogon.HighPart; + InfoBuffer->Account.LastLogoff.LowPart = FixedData.LastLogoff.LowPart; + InfoBuffer->Account.LastLogoff.HighPart = FixedData.LastLogoff.HighPart; + InfoBuffer->Account.PasswordLastSet.LowPart = FixedData.PasswordLastSet.LowPart; + InfoBuffer->Account.PasswordLastSet.HighPart = FixedData.PasswordLastSet.HighPart; + InfoBuffer->Account.AccountExpires.LowPart = FixedData.AccountExpires.LowPart; + InfoBuffer->Account.AccountExpires.HighPart = FixedData.AccountExpires.HighPart; + InfoBuffer->Account.BadPasswordCount = FixedData.BadPasswordCount; + InfoBuffer->Account.LogonCount = FixedData.LogonCount; + InfoBuffer->Account.UserAccountControl = FixedData.UserAccountControl; + + /* Get the Name string */ + Status = SampGetObjectAttributeString(UserObject, + L"Name", + &InfoBuffer->Account.UserName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the FullName string */ + Status = SampGetObjectAttributeString(UserObject, + L"FullName", + &InfoBuffer->Account.FullName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the HomeDirectory string */ + Status = SampGetObjectAttributeString(UserObject, + L"HomeDirectory", + &InfoBuffer->Account.HomeDirectory); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the HomeDirectoryDrive string */ + Status = SampGetObjectAttributeString(UserObject, + L"HomeDirectoryDrive", + &InfoBuffer->Account.HomeDirectoryDrive); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the ScriptPath string */ + Status = SampGetObjectAttributeString(UserObject, + L"ScriptPath", + &InfoBuffer->Account.ScriptPath); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the ProfilePath string */ + Status = SampGetObjectAttributeString(UserObject, + L"ProfilePath", + &InfoBuffer->Account.ProfilePath); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the AdminComment string */ + Status = SampGetObjectAttributeString(UserObject, + L"AdminComment", + &InfoBuffer->Account.AdminComment); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the WorkStations string */ + Status = SampGetObjectAttributeString(UserObject, + L"WorkStations", + &InfoBuffer->Account.WorkStations); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* FIXME: LogonHours */ + + *Buffer = InfoBuffer; + +done: + if (!NT_SUCCESS(Status)) + { + if (InfoBuffer != NULL) + { + if (InfoBuffer->Account.UserName.Buffer != NULL) + midl_user_free(InfoBuffer->Account.UserName.Buffer); + + if (InfoBuffer->Account.FullName.Buffer != NULL) + midl_user_free(InfoBuffer->Account.FullName.Buffer); + + if (InfoBuffer->Account.HomeDirectory.Buffer != NULL) + midl_user_free(InfoBuffer->Account.HomeDirectory.Buffer); + + if (InfoBuffer->Account.HomeDirectoryDrive.Buffer != NULL) + midl_user_free(InfoBuffer->Account.HomeDirectoryDrive.Buffer); + + if (InfoBuffer->Account.ScriptPath.Buffer != NULL) + midl_user_free(InfoBuffer->Account.ScriptPath.Buffer); + + if (InfoBuffer->Account.ProfilePath.Buffer != NULL) + midl_user_free(InfoBuffer->Account.ProfilePath.Buffer); + + if (InfoBuffer->Account.AdminComment.Buffer != NULL) + midl_user_free(InfoBuffer->Account.AdminComment.Buffer); + + if (InfoBuffer->Account.WorkStations.Buffer != NULL) + midl_user_free(InfoBuffer->Account.WorkStations.Buffer); + + if (InfoBuffer->Account.LogonHours.LogonHours != NULL) + midl_user_free(InfoBuffer->Account.LogonHours.LogonHours); + + midl_user_free(InfoBuffer); + } + } + + return Status; +} + +/* FIXME: SampQueryUserLogonHours */ + +static +NTSTATUS +SampQueryUserName(PSAM_DB_OBJECT UserObject, + PSAMPR_USER_INFO_BUFFER *Buffer) +{ + PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; + NTSTATUS Status; + + *Buffer = NULL; + + InfoBuffer = midl_user_allocate(sizeof(SAMPR_USER_INFO_BUFFER)); + if (InfoBuffer == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + /* Get the Name string */ + Status = SampGetObjectAttributeString(UserObject, + L"Name", + &InfoBuffer->Name.UserName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + /* Get the FullName string */ + Status = SampGetObjectAttributeString(UserObject, + L"FullName", + &InfoBuffer->Name.FullName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + *Buffer = InfoBuffer; + +done: + if (!NT_SUCCESS(Status)) + { + if (InfoBuffer != NULL) + { + if (InfoBuffer->Name.UserName.Buffer != NULL) + midl_user_free(InfoBuffer->Name.UserName.Buffer); + + if (InfoBuffer->Name.FullName.Buffer != NULL) + midl_user_free(InfoBuffer->Name.FullName.Buffer); + + midl_user_free(InfoBuffer); + } + } + + return Status; +} + + +static NTSTATUS +SampQueryUserAccountName(PSAM_DB_OBJECT UserObject, + PSAMPR_USER_INFO_BUFFER *Buffer) +{ + PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; + NTSTATUS Status; + + *Buffer = NULL; + + InfoBuffer = midl_user_allocate(sizeof(SAMPR_USER_INFO_BUFFER)); + if (InfoBuffer == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + /* Get the Name string */ + Status = SampGetObjectAttributeString(UserObject, + L"Name", + &InfoBuffer->AccountName.UserName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + *Buffer = InfoBuffer; + +done: + if (!NT_SUCCESS(Status)) + { + if (InfoBuffer != NULL) + { + if (InfoBuffer->AccountName.UserName.Buffer != NULL) + midl_user_free(InfoBuffer->AccountName.UserName.Buffer); + + midl_user_free(InfoBuffer); + } + } + + return Status; +} + + +static NTSTATUS +SampQueryUserFullName(PSAM_DB_OBJECT UserObject, + PSAMPR_USER_INFO_BUFFER *Buffer) +{ + PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; + NTSTATUS Status; + + *Buffer = NULL; + + InfoBuffer = midl_user_allocate(sizeof(SAMPR_USER_INFO_BUFFER)); + if (InfoBuffer == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + /* Get the FullName string */ + Status = SampGetObjectAttributeString(UserObject, + L"FullName", + &InfoBuffer->FullName.FullName); + if (!NT_SUCCESS(Status)) + { + TRACE("Status 0x%08lx\n", Status); + goto done; + } + + *Buffer = InfoBuffer; + +done: + if (!NT_SUCCESS(Status)) + { + if (InfoBuffer != NULL) + { + if (InfoBuffer->FullName.FullName.Buffer != NULL) + midl_user_free(InfoBuffer->FullName.FullName.Buffer); + + midl_user_free(InfoBuffer); + } + } + + return Status; +} + + +static +NTSTATUS +SampQueryUserPrimaryGroup(PSAM_DB_OBJECT UserObject, + PSAMPR_USER_INFO_BUFFER *Buffer) +{ + PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; + SAM_USER_FIXED_DATA FixedData; + ULONG Length = 0; + NTSTATUS Status; + + *Buffer = NULL; + + InfoBuffer = midl_user_allocate(sizeof(SAMPR_USER_INFO_BUFFER)); + if (InfoBuffer == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + Length = sizeof(SAM_USER_FIXED_DATA); + Status = SampGetObjectAttribute(UserObject, + L"F", + NULL, + (PVOID)&FixedData, + &Length); + if (!NT_SUCCESS(Status)) + goto done; + InfoBuffer->PrimaryGroup.PrimaryGroupId = FixedData.PrimaryGroupId; *Buffer = InfoBuffer; @@ -3454,7 +3595,6 @@ PSAMPR_USER_INFO_BUFFER *Buffer) { PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; - ULONG Length = 0; NTSTATUS Status; *Buffer = NULL; @@ -3463,65 +3603,20 @@ if (InfoBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES; - Status = SampGetObjectAttribute(UserObject, - L"HomeDirectory", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) + /* Get the HomeDirectory string */ + Status = SampGetObjectAttributeString(UserObject, + L"HomeDirectory", + &InfoBuffer->Home.HomeDirectory); + if (!NT_SUCCESS(Status)) { TRACE("Status 0x%08lx\n", Status); goto done; } - InfoBuffer->Home.HomeDirectory.Length = Length - sizeof(WCHAR); - InfoBuffer->Home.HomeDirectory.MaximumLength = Length; - InfoBuffer->Home.HomeDirectory.Buffer = midl_user_allocate(Length); - if (InfoBuffer->Home.HomeDirectory.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - TRACE("Length: %lu\n", Length); - Status = SampGetObjectAttribute(UserObject, - L"HomeDirectory", - NULL, - (PVOID)InfoBuffer->Home.HomeDirectory.Buffer, - &Length); - if (!NT_SUCCESS(Status)) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - Length = 0; - Status = SampGetObjectAttribute(UserObject, - L"HomeDirectoryDrive", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - InfoBuffer->Home.HomeDirectoryDrive.Length = Length - sizeof(WCHAR); - InfoBuffer->Home.HomeDirectoryDrive.MaximumLength = Length; - InfoBuffer->Home.HomeDirectoryDrive.Buffer = midl_user_allocate(Length); - if (InfoBuffer->Home.HomeDirectoryDrive.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - TRACE("Length: %lu\n", Length); - Status = SampGetObjectAttribute(UserObject, - L"HomeDirectoryDrive", - NULL, - (PVOID)InfoBuffer->Home.HomeDirectoryDrive.Buffer, - &Length); + /* Get the HomeDirectoryDrive string */ + Status = SampGetObjectAttributeString(UserObject, + L"HomeDirectoryDrive", + &InfoBuffer->Home.HomeDirectoryDrive); if (!NT_SUCCESS(Status)) { TRACE("Status 0x%08lx\n", Status); @@ -3554,7 +3649,6 @@ PSAMPR_USER_INFO_BUFFER *Buffer) { PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; - ULONG Length = 0; NTSTATUS Status; *Buffer = NULL; @@ -3563,32 +3657,10 @@ if (InfoBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES; - Status = SampGetObjectAttribute(UserObject, - L"ScriptPath", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - InfoBuffer->Script.ScriptPath.Length = Length - sizeof(WCHAR); - InfoBuffer->Script.ScriptPath.MaximumLength = Length; - InfoBuffer->Script.ScriptPath.Buffer = midl_user_allocate(Length); - if (InfoBuffer->Script.ScriptPath.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - TRACE("Length: %lu\n", Length); - Status = SampGetObjectAttribute(UserObject, - L"ScriptPath", - NULL, - (PVOID)InfoBuffer->Script.ScriptPath.Buffer, - &Length); + /* Get the ScriptPath string */ + Status = SampGetObjectAttributeString(UserObject, + L"ScriptPath", + &InfoBuffer->Script.ScriptPath); if (!NT_SUCCESS(Status)) { TRACE("Status 0x%08lx\n", Status); @@ -3618,7 +3690,6 @@ PSAMPR_USER_INFO_BUFFER *Buffer) { PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; - ULONG Length = 0; NTSTATUS Status; *Buffer = NULL; @@ -3627,32 +3698,10 @@ if (InfoBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES; - Status = SampGetObjectAttribute(UserObject, - L"ProfilePath", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - InfoBuffer->Profile.ProfilePath.Length = Length - sizeof(WCHAR); - InfoBuffer->Profile.ProfilePath.MaximumLength = Length; - InfoBuffer->Profile.ProfilePath.Buffer = midl_user_allocate(Length); - if (InfoBuffer->Profile.ProfilePath.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - TRACE("Length: %lu\n", Length); - Status = SampGetObjectAttribute(UserObject, - L"ProfilePath", - NULL, - (PVOID)InfoBuffer->Profile.ProfilePath.Buffer, - &Length); + /* Get the ProfilePath string */ + Status = SampGetObjectAttributeString(UserObject, + L"ProfilePath", + &InfoBuffer->Profile.ProfilePath); if (!NT_SUCCESS(Status)) { TRACE("Status 0x%08lx\n", Status); @@ -3682,7 +3731,6 @@ PSAMPR_USER_INFO_BUFFER *Buffer) { PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; - ULONG Length = 0; NTSTATUS Status; *Buffer = NULL; @@ -3691,32 +3739,10 @@ if (InfoBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES; - Status = SampGetObjectAttribute(UserObject, - L"AdminComment", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - InfoBuffer->AdminComment.AdminComment.Length = Length - sizeof(WCHAR); - InfoBuffer->AdminComment.AdminComment.MaximumLength = Length; - InfoBuffer->AdminComment.AdminComment.Buffer = midl_user_allocate(Length); - if (InfoBuffer->AdminComment.AdminComment.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - TRACE("Length: %lu\n", Length); - Status = SampGetObjectAttribute(UserObject, - L"AdminComment", - NULL, - (PVOID)InfoBuffer->AdminComment.AdminComment.Buffer, - &Length); + /* Get the AdminComment string */ + Status = SampGetObjectAttributeString(UserObject, + L"AdminComment", + &InfoBuffer->AdminComment.AdminComment); if (!NT_SUCCESS(Status)) { TRACE("Status 0x%08lx\n", Status); @@ -3741,13 +3767,11 @@ } - static NTSTATUS SampQueryUserWorkStations(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer) { PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL; - ULONG Length = 0; NTSTATUS Status; *Buffer = NULL; @@ -3756,32 +3780,10 @@ if (InfoBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES; - Status = SampGetObjectAttribute(UserObject, - L"WorkStations", - NULL, - NULL, - &Length); - if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) - { - TRACE("Status 0x%08lx\n", Status); - goto done; - } - - InfoBuffer->WorkStations.WorkStations.Length = Length - sizeof(WCHAR); - InfoBuffer->WorkStations.WorkStations.MaximumLength = Length; - InfoBuffer->WorkStations.WorkStations.Buffer = midl_user_allocate(Length); - if (InfoBuffer->WorkStations.WorkStations.Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - TRACE("Length: %lu\n", Length); - Status = SampGetObjectAttribute(UserObject, - L"WorkStations", - NULL, - (PVOID)InfoBuffer->WorkStations.WorkStations.Buffer, - &Length); + /* Get the WorkStations string */ + Status = SampGetObjectAttributeString(UserObject, + L"WorkStations", + &InfoBuffer->WorkStations.WorkStations); if (!NT_SUCCESS(Status)) { TRACE("Status 0x%08lx\n", Status); @@ -3959,11 +3961,30 @@ switch (UserInformationClass) { -// case UserGeneralInformation: -// case UserPreferencesInformation: -// case UserLogonInformation: + case UserGeneralInformation: + Status = SampQueryUserGeneral(UserObject, + Buffer); + break; + + case UserPreferencesInformation: + Status = SampQueryUserPreferences(UserObject, + Buffer); + break; + + case UserLogonInformation: + Status = SampQueryUserLogon(UserObject, + Buffer); + break; + // case UserLogonHoursInformation: -// case UserAccountInformation: +// Status = SampQueryUserLogonHours(UserObject, +// Buffer); +// break; + + case UserAccountInformation: + Status = SampQueryUserAccount(UserObject, + Buffer); + break; case UserNameInformation: Status = SampQueryUserName(UserObject, @@ -4026,6 +4047,199 @@ return Status; } + +static NTSTATUS +SampSetUserGeneral(PSAM_DB_OBJECT UserObject, + PSAMPR_USER_INFO_BUFFER Buffer) +{ + SAM_USER_FIXED_DATA FixedData; + ULONG Length = 0; + NTSTATUS Status; + + Length = sizeof(SAM_USER_FIXED_DATA); + Status = SampGetObjectAttribute(UserObject, + L"F", + NULL, + (PVOID)&FixedData, + &Length); + if (!NT_SUCCESS(Status)) + goto done; + + FixedData.PrimaryGroupId = Buffer->General.PrimaryGroupId; + + Status = SampSetObjectAttribute(UserObject, + L"F", + REG_BINARY, + &FixedData, + Length); + if (!NT_SUCCESS(Status)) + goto done; + + Status = SampSetObjectAttribute(UserObject, + L"Name", + REG_SZ, + Buffer->General.UserName.Buffer, + Buffer->General.UserName.MaximumLength); + if (!NT_SUCCESS(Status)) + goto done; + + Status = SampSetObjectAttribute(UserObject, + L"FullName", + REG_SZ, + Buffer->General.FullName.Buffer, + Buffer->General.FullName.MaximumLength); + if (!NT_SUCCESS(Status)) + goto done; + + Status = SampSetObjectAttribute(UserObject, + L"AdminComment", + REG_SZ, + Buffer->General.AdminComment.Buffer, + Buffer->General.AdminComment.MaximumLength); + if (!NT_SUCCESS(Status)) + goto done; + + Status = SampSetObjectAttribute(UserObject, + L"UserComment", + REG_SZ, + Buffer->General.UserComment.Buffer, + Buffer->General.UserComment.MaximumLength); + +done: + return Status; +} + + +static NTSTATUS +SampSetUserPreferences(PSAM_DB_OBJECT UserObject, + PSAMPR_USER_INFO_BUFFER Buffer) +{ + SAM_USER_FIXED_DATA FixedData; + ULONG Length = 0; + NTSTATUS Status; + + Length = sizeof(SAM_USER_FIXED_DATA); + Status = SampGetObjectAttribute(UserObject, + L"F", + NULL, + (PVOID)&FixedData, + &Length); + if (!NT_SUCCESS(Status)) + goto done; + + FixedData.CountryCode = Buffer->Preferences.CountryCode; + FixedData.CodePage = Buffer->Preferences.CodePage; + + Status = SampSetObjectAttribute(UserObject, + L"F", + REG_BINARY, + &FixedData, + Length); + if (!NT_SUCCESS(Status)) + goto done; + + Status = SampSetObjectAttribute(UserObject, + L"UserComment", + REG_SZ, + Buffer->Preferences.UserComment.Buffer, + Buffer->Preferences.UserComment.MaximumLength); + +done: + return Status; +} + + +static NTSTATUS +SampSetUserPrimaryGroup(PSAM_DB_OBJECT UserObject, + PSAMPR_USER_INFO_BUFFER Buffer) +{ + SAM_USER_FIXED_DATA FixedData; + ULONG Length = 0; + NTSTATUS Status; + + Length = sizeof(SAM_USER_FIXED_DATA); + Status = SampGetObjectAttribute(UserObject, + L"F", + NULL, + (PVOID)&FixedData, + &Length); + if (!NT_SUCCESS(Status)) + goto done; + + FixedData.PrimaryGroupId = Buffer->PrimaryGroup.PrimaryGroupId; + + Status = SampSetObjectAttribute(UserObject, + L"F", + REG_BINARY, + &FixedData, + Length); + +done: + return Status; +} + + +static NTSTATUS +SampSetUserControl(PSAM_DB_OBJECT UserObject, + PSAMPR_USER_INFO_BUFFER Buffer) +{ + SAM_USER_FIXED_DATA FixedData; + ULONG Length = 0; + NTSTATUS Status; + + Length = sizeof(SAM_USER_FIXED_DATA); + Status = SampGetObjectAttribute(UserObject, + L"F", + NULL, + (PVOID)&FixedData, + &Length); + if (!NT_SUCCESS(Status)) + goto done; + + FixedData.UserAccountControl = Buffer->Control.UserAccountControl; + + Status = SampSetObjectAttribute(UserObject, + L"F", + REG_BINARY, + &FixedData, + Length); + +done: + return Status; +} + + +static NTSTATUS +SampSetUserExpires(PSAM_DB_OBJECT UserObject, + PSAMPR_USER_INFO_BUFFER Buffer) +{ + SAM_USER_FIXED_DATA FixedData; + ULONG Length = 0; + NTSTATUS Status; + + Length = sizeof(SAM_USER_FIXED_DATA); + Status = SampGetObjectAttribute(UserObject, + L"F", + NULL, + (PVOID)&FixedData, + &Length); + if (!NT_SUCCESS(Status)) + goto done; + + FixedData.AccountExpires.LowPart = Buffer->Expires.AccountExpires.LowPart; + FixedData.AccountExpires.HighPart = Buffer->Expires.AccountExpires.HighPart; + + Status = SampSetObjectAttribute(UserObject, + L"F", + REG_BINARY, + &FixedData, + Length); + +done: + return Status; +} + + /* Function 37 */ NTSTATUS NTAPI @@ -4042,6 +4256,7 @@ switch (UserInformationClass) { + case UserLogonHoursInformation: case UserNameInformation: case UserAccountNameInformation: case UserFullNameInformation: @@ -4056,6 +4271,15 @@ DesiredAccess = USER_WRITE_ACCOUNT; break; + case UserGeneralInformation: + DesiredAccess = USER_WRITE_ACCOUNT | + USER_WRITE_PREFERENCES; + break; + + case UserPreferencesInformation: + DesiredAccess = USER_WRITE_PREFERENCES; + break; + case UserSetPasswordInformation: DesiredAccess = USER_FORCE_PASSWORD_CHANGE; break; @@ -4077,10 +4301,21 @@ switch (UserInformationClass) { -// case UserGeneralInformation: -// case UserPreferencesInformation: -// case UserLogonHoursInformation: - + case UserGeneralInformation: + Status = SampSetUserGeneral(UserObject, + Buffer); + break; + + case UserPreferencesInformation: + Status = SampSetUserPreferences(UserObject, + Buffer); + break; +/* + case UserLogonHoursInformation: + Status = SampSetUserLogonHours(UserObject, + Buffer); + break; +*/ case UserNameInformation: Status = SampSetObjectAttribute(UserObject, L"Name", @@ -4113,15 +4348,10 @@ Buffer->FullName.FullName.MaximumLength); break; -/* case UserPrimaryGroupInformation: - Status = SampSetObjectAttribute(UserObject, - L"PrimaryGroupId", - REG_DWORD, - &Buffer->PrimaryGroup.PrimaryGroupId, - sizeof(ULONG)); - break; -*/ + Status = SampSetUserPrimaryGroup(UserObject, + Buffer); + break; case UserHomeInformation: Status = SampSetObjectAttribute(UserObject, @@ -4182,24 +4412,15 @@ Buffer->SetPassword.Password.MaximumLength); break; -/* case UserControlInformation: - Status = SampSetObjectAttribute(UserObject, - L"UserAccountControl", - REG_DWORD, - &Buffer->Control.UserAccountControl, - sizeof(ULONG)); - break; -*/ -/* + Status = SampSetUserControl(UserObject, + Buffer); + break; + case UserExpiresInformation: - Status = SampSetObjectAttribute(UserObject, - L"AccountExpires", - REG_BINARY, - &Buffer->Expires.AccountExpires, - sizeof(OLD_LARGE_INTEGER)); - break; -*/ + Status = SampSetUserExpires(UserObject, + Buffer); + break; // case UserInternal1Information: // case UserParametersInformation: Modified: trunk/reactos/dll/win32/samsrv/samsrv.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/samsrv.h?…
============================================================================== --- trunk/reactos/dll/win32/samsrv/samsrv.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/samsrv/samsrv.h [iso-8859-1] Sun Jul 8 09:33:35 2012 @@ -149,6 +149,11 @@ LPVOID AttributeData, PULONG AttributeSize); +NTSTATUS +SampGetObjectAttributeString(PSAM_DB_OBJECT DbObject, + LPWSTR AttributeName, + RPC_UNICODE_STRING *String); + /* registry.h */ NTSTATUS SampRegCloseKey(IN HANDLE KeyHandle); Modified: trunk/reactos/include/ddk/ntsam.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/ntsam.h?rev=56…
============================================================================== --- trunk/reactos/include/ddk/ntsam.h [iso-8859-1] (original) +++ trunk/reactos/include/ddk/ntsam.h [iso-8859-1] Sun Jul 8 09:33:35 2012 @@ -185,22 +185,22 @@ AliasAdminCommentInformation } ALIAS_INFORMATION_CLASS, *PALIAS_INFORMATION_CLASS; -typedef struct _SAMPR_ALIAS_GENERAL_INFORMATION +typedef struct _ALIAS_GENERAL_INFORMATION { UNICODE_STRING Name; ULONG MemberCount; UNICODE_STRING AdminComment; -} SAMPR_ALIAS_GENERAL_INFORMATION, *PSAMPR_ALIAS_GENERAL_INFORMATION; - -typedef struct _SAMPR_ALIAS_NAME_INFORMATION +} ALIAS_GENERAL_INFORMATION, *PALIAS_GENERAL_INFORMATION; + +typedef struct _ALIAS_NAME_INFORMATION { UNICODE_STRING Name; -} SAMPR_ALIAS_NAME_INFORMATION, *PSAMPR_ALIAS_NAME_INFORMATION; - -typedef struct _SAMPR_ALIAS_ADM_COMMENT_INFORMATION +} ALIAS_NAME_INFORMATION, *PALIAS_NAME_INFORMATION; + +typedef struct _ALIAS_ADM_COMMENT_INFORMATION { UNICODE_STRING AdminComment; -} SAMPR_ALIAS_ADM_COMMENT_INFORMATION, *PSAMPR_ALIAS_ADM_COMMENT_INFORMATION; +} ALIAS_ADM_COMMENT_INFORMATION, *PALIAS_ADM_COMMENT_INFORMATION; typedef enum _DOMAIN_INFORMATION_CLASS Modified: trunk/reactos/include/reactos/idl/sam.idl URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/idl/sam.id…
============================================================================== --- trunk/reactos/include/reactos/idl/sam.idl [iso-8859-1] (original) +++ trunk/reactos/include/reactos/idl/sam.idl [iso-8859-1] Sun Jul 8 09:33:35 2012 @@ -400,7 +400,6 @@ [case(GroupReplicationInformation)] SAMPR_GROUP_GENERAL_INFORMATION DoNotUse; } SAMPR_GROUP_INFO_BUFFER, *PSAMPR_GROUP_INFO_BUFFER; -cpp_quote("#ifndef _NTSAM_") typedef struct _SAMPR_ALIAS_GENERAL_INFORMATION { RPC_UNICODE_STRING Name; @@ -418,6 +417,7 @@ RPC_UNICODE_STRING AdminComment; } SAMPR_ALIAS_ADM_COMMENT_INFORMATION, *PSAMPR_ALIAS_ADM_COMMENT_INFORMATION; +cpp_quote("#ifndef _NTSAM_") typedef enum _ALIAS_INFORMATION_CLASS { AliasGeneralInformation = 1,
12 years, 5 months
1
0
0
0
[fireball] 56849: [KERNEL32] - Wine doesn't prepend \registry\ to any registry path, which is wrong. Fix that. - Bring back previous implementation of GetGeoInfo & co. - Fix GEO_OFFICIALLANGUAGES i...
by fireball@svn.reactos.org
Author: fireball Date: Sat Jul 7 23:02:14 2012 New Revision: 56849 URL:
http://svn.reactos.org/svn/reactos?rev=56849&view=rev
Log: [KERNEL32] - Wine doesn't prepend \registry\ to any registry path, which is wrong. Fix that. - Bring back previous implementation of GetGeoInfo & co. - Fix GEO_OFFICIALLANGUAGES in the headers. - Thanks to Kamil Hornicek and Samuel Serapion for finding the problem and creating patches. See issue #6595 for more details. Modified: trunk/reactos/dll/cpl/intl/generalp.c trunk/reactos/dll/win32/kernel32/winnls/string/lang.c trunk/reactos/include/psdk/winnls.h Modified: trunk/reactos/dll/cpl/intl/generalp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/generalp.c?re…
============================================================================== --- trunk/reactos/dll/cpl/intl/generalp.c [iso-8859-1] (original) +++ trunk/reactos/dll/cpl/intl/generalp.c [iso-8859-1] Sat Jul 7 23:02:14 2012 @@ -46,10 +46,8 @@ lcid = _tcstoul(lpLocale, NULL, 16); /* Display only languages with installed support */ -/* See bug #4898. if (!IsValidLocale(lcid, LCID_INSTALLED)) return TRUE; -*/ if (lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH), SORT_DEFAULT) || lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), SORT_DEFAULT)) Modified: trunk/reactos/dll/win32/kernel32/winnls/string/lang.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/winnls/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/winnls/string/lang.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/winnls/string/lang.c [iso-8859-1] Sat Jul 7 23:02:14 2012 @@ -60,19 +60,15 @@ #define LOCALE_LOCALEINFOFLAGSMASK (LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP|\ LOCALE_RETURN_NUMBER|LOCALE_RETURN_GENITIVE_NAMES) -static const WCHAR szNlsKeyName[] = { - 'M','a','c','h','i','n','e','\\','S','y','s','t','e','m','\\', - 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', - 'C','o','n','t','r','o','l','\\','N','l','s','\0' -}; - static const WCHAR szLocaleKeyName[] = { + '\\', 'R', 'e', 'g', 'i', 's', 't', 'r', 'y', '\\', 'M','a','c','h','i','n','e','\\','S','y','s','t','e','m','\\', 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', 'C','o','n','t','r','o','l','\\','N','l','s','\\','L','o','c','a','l','e',0 }; static const WCHAR szLangGroupsKeyName[] = { + '\\', 'R', 'e', 'g', 'i', 's', 't', 'r', 'y', '\\', 'M','a','c','h','i','n','e','\\','S','y','s','t','e','m','\\', 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', 'C','o','n','t','r','o','l','\\','N','l','s','\\', @@ -1851,7 +1847,7 @@ HANDLE hkey; RtlInitUnicodeString( &keyName, szKeyName ); - InitializeObjectAttributes(&attr, &keyName, 0, hRootKey, NULL); + InitializeObjectAttributes(&attr, &keyName, OBJ_CASE_INSENSITIVE, hRootKey, NULL); if (NtOpenKey( &hkey, KEY_READ, &attr ) != STATUS_SUCCESS) hkey = 0; @@ -1974,6 +1970,7 @@ /* Registry keys for NLS related information */ static const WCHAR szCountryListName[] = { + '\\','R','e','g','i','s','t','r','y','\\', 'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', @@ -2689,16 +2686,149 @@ return TRUE; } +static int +NLS_GetGeoFriendlyName(GEOID Location, LPWSTR szFriendlyName, int cchData) +{ + HANDLE hKey; + WCHAR szPath[MAX_PATH]; + UNICODE_STRING ValueName; + KEY_VALUE_PARTIAL_INFORMATION *info; + const int info_size = FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data); + DWORD dwSize; + NTSTATUS Status; + int Ret; + + swprintf(szPath, L"\\REGISTRY\\Machine\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Telephony\\Country List\\%d", Location); + + hKey = NLS_RegOpenKey(0, szPath); + if (!hKey) + { + WARN("NLS_RegOpenKey() failed\n"); + return 0; + } + + dwSize = info_size + cchData * sizeof(WCHAR); + + if (!(info = HeapAlloc(GetProcessHeap(), 0, dwSize))) + { + NtClose(hKey); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + RtlInitUnicodeString(&ValueName, L"Name"); + + Status = NtQueryValueKey(hKey, &ValueName, KeyValuePartialInformation, + (LPBYTE)info, dwSize, &dwSize); + + if (!Status) + { + Ret = (dwSize - info_size) / sizeof(WCHAR); + + if (!Ret || ((WCHAR *)info->Data)[Ret-1]) + { + if (Ret < cchData || !szFriendlyName) Ret++; + else + { + WARN("ERROR_INSUFFICIENT_BUFFER\n"); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + Ret = 0; + } + } + + if (Ret && szFriendlyName) + { + memcpy(szFriendlyName, info->Data, (Ret-1) * sizeof(WCHAR)); + szFriendlyName[Ret-1] = 0; + } + } + else if (Status == STATUS_BUFFER_OVERFLOW && !szFriendlyName) + { + Ret = (dwSize - info_size) / sizeof(WCHAR) + 1; + } + else if (Status == STATUS_OBJECT_NAME_NOT_FOUND) + { + Ret = -1; + } + else + { + SetLastError(RtlNtStatusToDosError(Status)); + Ret = 0; + } + + NtClose(hKey); + HeapFree(GetProcessHeap(), 0, info); + + return Ret; +} + +/* + * @implemented + */ INT WINAPI GetGeoInfoW(GEOID GeoId, GEOTYPE GeoType, LPWSTR lpGeoData, - int cchData, LANGID language) -{ - FIXME("%d %d %p %d %d\n", GeoId, GeoType, lpGeoData, cchData, language); + int cchData, LANGID LangId) +{ + TRACE("%d %d %p %d %d\n", GeoId, GeoType, lpGeoData, cchData, LangId); + + switch (GeoType) + { + case GEO_FRIENDLYNAME: + { + return NLS_GetGeoFriendlyName(GeoId, lpGeoData, cchData); + } + case GEO_TIMEZONES: + case GEO_NATION: + case GEO_LATITUDE: + case GEO_LONGITUDE: + case GEO_ISO2: + case GEO_ISO3: + case GEO_RFC1766: + case GEO_LCID: + case GEO_OFFICIALNAME: + case GEO_OFFICIALLANGUAGES: + FIXME("%d %d %p %d %d\n", GeoId, GeoType, lpGeoData, cchData, LangId); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + break; + } + return 0; } +/* + * @implemented + */ INT WINAPI GetGeoInfoA(GEOID GeoId, GEOTYPE GeoType, LPSTR lpGeoData, - int cchData, LANGID language) -{ - FIXME("%d %d %p %d %d\n", GeoId, GeoType, lpGeoData, cchData, language); + int cchData, LANGID LangId) +{ + WCHAR szBuffer[MAX_PATH]; + char szBufferA[sizeof(szBuffer)/sizeof(WCHAR)]; + int Ret; + + TRACE("%d %d %p %d %d\n", GeoId, GeoType, lpGeoData, cchData, LangId); + + switch (GeoType) + { + case GEO_FRIENDLYNAME: + { + Ret = NLS_GetGeoFriendlyName(GeoId, szBuffer, cchData); + WideCharToMultiByte(CP_ACP, 0, szBuffer, -1, szBufferA, sizeof(szBufferA), 0, 0); + strcpy(lpGeoData, szBufferA); + return Ret; + } + case GEO_TIMEZONES: + case GEO_NATION: + case GEO_LATITUDE: + case GEO_LONGITUDE: + case GEO_ISO2: + case GEO_ISO3: + case GEO_RFC1766: + case GEO_LCID: + case GEO_OFFICIALNAME: + case GEO_OFFICIALLANGUAGES: + FIXME("%d %d %p %d %d\n", GeoId, GeoType, lpGeoData, cchData, LangId); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + break; + } + return 0; } Modified: trunk/reactos/include/psdk/winnls.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winnls.h?rev=…
============================================================================== --- trunk/reactos/include/psdk/winnls.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/winnls.h [iso-8859-1] Sat Jul 7 23:02:14 2012 @@ -525,7 +525,7 @@ GEO_FRIENDLYNAME = 0x0008, GEO_OFFICIALNAME = 0x0009, GEO_TIMEZONES = 0x000a, - GEO_OFFICIALLANGUAGES = 0x000a + GEO_OFFICIALLANGUAGES = 0x000b }; typedef struct _cpinfo {
12 years, 5 months
1
0
0
0
[ekohl] 56848: [SERVICES] First step to support control sets.
by ekohl@svn.reactos.org
Author: ekohl Date: Sat Jul 7 18:17:59 2012 New Revision: 56848 URL:
http://svn.reactos.org/svn/reactos?rev=56848&view=rev
Log: [SERVICES] First step to support control sets. Added: trunk/reactos/base/system/services/controlset.c (with props) Modified: trunk/reactos/base/system/services/CMakeLists.txt trunk/reactos/base/system/services/services.c trunk/reactos/base/system/services/services.h Modified: trunk/reactos/base/system/services/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/CMake…
============================================================================== --- trunk/reactos/base/system/services/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/system/services/CMakeLists.txt [iso-8859-1] Sat Jul 7 18:17:59 2012 @@ -9,6 +9,7 @@ list(APPEND SOURCE config.c + controlset.c database.c driver.c groupdb.c Added: trunk/reactos/base/system/services/controlset.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/contr…
============================================================================== --- trunk/reactos/base/system/services/controlset.c (added) +++ trunk/reactos/base/system/services/controlset.c [iso-8859-1] Sat Jul 7 18:17:59 2012 @@ -1,0 +1,105 @@ +/* + * PROJECT: ReactOS Service Control Manager + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/system/services/controlset.c + * PURPOSE: Control Set Management + * COPYRIGHT: Copyright 2012 Eric Kohl + * + */ + +/* INCLUDES *****************************************************************/ + +#include "services.h" + +#define NDEBUG +#include <debug.h> + + +/* GLOBALS *******************************************************************/ + +static DWORD dwCurrentControlSet; +static DWORD dwDefaultControlSet; +static DWORD dwFailedControlSet; +static DWORD dwLastKnownGoodControlSet; + + +/* FUNCTIONS *****************************************************************/ + +BOOL +ScmGetControlSetValues(VOID) +{ + HKEY hSelectKey; + DWORD dwType; + DWORD dwSize; + LONG lError; + + DPRINT("ScmGetControlSetValues() called\n"); + + lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"System\\Select", + 0, + KEY_READ, + &hSelectKey); + if (lError != ERROR_SUCCESS) + return FALSE; + + dwSize = sizeof(DWORD); + lError = RegQueryValueExW(hSelectKey, + L"Current", + 0, + &dwType, + (LPBYTE)&dwCurrentControlSet, + &dwSize); + if (lError != ERROR_SUCCESS) + { + dwCurrentControlSet = 0; + } + + dwSize = sizeof(DWORD); + lError = RegQueryValueExW(hSelectKey, + L"Default", + 0, + &dwType, + (LPBYTE)&dwDefaultControlSet, + &dwSize); + if (lError != ERROR_SUCCESS) + { + dwDefaultControlSet = 0; + } + + dwSize = sizeof(DWORD); + lError = RegQueryValueExW(hSelectKey, + L"Failed", + 0, + &dwType, + (LPBYTE)&dwFailedControlSet, + &dwSize); + if (lError != ERROR_SUCCESS) + { + dwFailedControlSet = 0; + } + + dwSize = sizeof(DWORD); + lError = RegQueryValueExW(hSelectKey, + L"LastKnownGood", + 0, + &dwType, + (LPBYTE)&dwLastKnownGoodControlSet, + &dwSize); + if (lError != ERROR_SUCCESS) + { + dwLastKnownGoodControlSet = 0; + } + + RegCloseKey(hSelectKey); + + DPRINT("ControlSets:\n"); + DPRINT("Current: %lu\n", dwCurrentControlSet); + DPRINT("Default: %lu\n", dwDefaultControlSet); + DPRINT("Failed: %lu\n", dwFailedControlSet); + DPRINT("LastKnownGood: %lu\n", dwLastKnownGoodControlSet); + + return TRUE; +} + +/* EOF */ Propchange: trunk/reactos/base/system/services/controlset.c ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/reactos/base/system/services/controlset.c ------------------------------------------------------------------------------ svn:keywords = author date id revision Modified: trunk/reactos/base/system/services/services.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
============================================================================== --- trunk/reactos/base/system/services/services.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/services.c [iso-8859-1] Sat Jul 7 18:17:59 2012 @@ -403,6 +403,13 @@ /* FIXME: more initialization */ + /* Read the control set values */ + if (!ScmGetControlSetValues()) + { + DPRINT1("SERVICES: failed to read the control set values\n"); + goto done; + } + /* Create the service database */ dwError = ScmCreateServiceDatabase(); if (dwError != ERROR_SUCCESS) Modified: trunk/reactos/base/system/services/services.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
============================================================================== --- trunk/reactos/base/system/services/services.h [iso-8859-1] (original) +++ trunk/reactos/base/system/services/services.h [iso-8859-1] Sat Jul 7 18:17:59 2012 @@ -115,6 +115,11 @@ DWORD *lpdwDependenciesLength); +/* controlset.c */ + +BOOL ScmGetControlSetValues(VOID); + + /* database.c */ DWORD ScmCreateServiceDatabase(VOID);
12 years, 5 months
1
0
0
0
[ekohl] 56847: [SERVICES] Use Unicode functions instead of generic ones and replace all TEXT macros too.
by ekohl@svn.reactos.org
Author: ekohl Date: Sat Jul 7 17:47:25 2012 New Revision: 56847 URL:
http://svn.reactos.org/svn/reactos?rev=56847&view=rev
Log: [SERVICES] Use Unicode functions instead of generic ones and replace all TEXT macros too. Modified: trunk/reactos/base/system/services/services.c Modified: trunk/reactos/base/system/services/services.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
============================================================================== --- trunk/reactos/base/system/services/services.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/services.c [iso-8859-1] Sat Jul 7 17:47:25 2012 @@ -85,17 +85,17 @@ { HANDLE hEvent; - hEvent = CreateEvent(NULL, - TRUE, - FALSE, - TEXT("SvcctrlStartEvent_A3752DX")); + hEvent = CreateEventW(NULL, + TRUE, + FALSE, + L"SvcctrlStartEvent_A3752DX"); if (hEvent == NULL) { if (GetLastError() == ERROR_ALREADY_EXISTS) { - hEvent = OpenEvent(EVENT_ALL_ACCESS, - FALSE, - TEXT("SvcctrlStartEvent_A3752DX")); + hEvent = OpenEventW(EVENT_ALL_ACCESS, + FALSE, + L"SvcctrlStartEvent_A3752DX"); if (hEvent == NULL) { return FALSE; @@ -227,7 +227,7 @@ DPRINT("ScmCreateNamedPipe() - CreateNamedPipe(\"\\\\.\\pipe\\Ntsvcs\")\n"); - hPipe = CreateNamedPipe(TEXT("\\\\.\\pipe\\Ntsvcs"), + hPipe = CreateNamedPipeW(L"\\\\.\\pipe\\Ntsvcs", PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES,
12 years, 5 months
1
0
0
0
[ekohl] 56845: [SERVICES] Fix the build.
by ekohl@svn.reactos.org
Author: ekohl Date: Sat Jul 7 15:39:34 2012 New Revision: 56845 URL:
http://svn.reactos.org/svn/reactos?rev=56845&view=rev
Log: [SERVICES] Fix the build. Modified: trunk/reactos/base/system/services/services.c Modified: trunk/reactos/base/system/services/services.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
============================================================================== --- trunk/reactos/base/system/services/services.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/services.c [iso-8859-1] Sat Jul 7 15:39:34 2012 @@ -403,13 +403,6 @@ /* FIXME: more initialization */ - /* Read the control set values */ - if (!ScmGetControlSetValues()) - { - DPRINT1("SERVICES: failed to read the control set values\n"); - goto done; - } - /* Create the service database */ dwError = ScmCreateServiceDatabase(); if (dwError != ERROR_SUCCESS)
12 years, 5 months
1
0
0
0
[tfaber] 56843: [USERENV] - Simplify AcquireRemoveRestorePrivilege. Improve clean-up & acquire privilege before unloading hive in CreateUserProfileW. Patch by Hermes Belusca See issue #7160 for mor...
by tfaber@svn.reactos.org
Author: tfaber Date: Sat Jul 7 10:11:21 2012 New Revision: 56843 URL:
http://svn.reactos.org/svn/reactos?rev=56843&view=rev
Log: [USERENV] - Simplify AcquireRemoveRestorePrivilege. Improve clean-up & acquire privilege before unloading hive in CreateUserProfileW. Patch by Hermes Belusca See issue #7160 for more details. Modified: trunk/reactos/dll/win32/userenv/profile.c Modified: trunk/reactos/dll/win32/userenv/profile.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/profile.…
============================================================================== --- trunk/reactos/dll/win32/userenv/profile.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/profile.c [iso-8859-1] Sat Jul 7 10:11:21 2012 @@ -104,60 +104,46 @@ BOOL AcquireRemoveRestorePrivilege(IN BOOL bAcquire) { - HANDLE Process; + BOOL bRet = FALSE; HANDLE Token; - PTOKEN_PRIVILEGES TokenPriv; - BOOL bRet; + TOKEN_PRIVILEGES TokenPriv; DPRINT("AcquireRemoveRestorePrivilege(%d)\n", bAcquire); - Process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, GetCurrentProcessId()); - if (!Process) - { - DPRINT1("OpenProcess() failed with error %lu\n", GetLastError()); - return FALSE; - } - bRet = OpenProcessToken(Process, TOKEN_ADJUST_PRIVILEGES, &Token); - CloseHandle(Process); - if (!bRet) + if (OpenProcessToken(GetCurrentProcess(), + TOKEN_ADJUST_PRIVILEGES, + &Token)) + { + TokenPriv.PrivilegeCount = 1; + TokenPriv.Privileges[0].Attributes = (bAcquire ? SE_PRIVILEGE_ENABLED : 0); + + if (LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &TokenPriv.Privileges[0].Luid)) + { + bRet = AdjustTokenPrivileges(Token, FALSE, &TokenPriv, 0, NULL, NULL); + + if (!bRet) + { + DPRINT1("AdjustTokenPrivileges() failed with error %lu\n", GetLastError()); + } + else if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) + { + DPRINT1("AdjustTokenPrivileges() succeeded, but with not all privileges assigned\n"); + bRet = FALSE; + } + } + else + { + DPRINT1("LookupPrivilegeValue() failed with error %lu\n", GetLastError()); + } + + CloseHandle(Token); + } + else { DPRINT1("OpenProcessToken() failed with error %lu\n", GetLastError()); - return FALSE; - } - TokenPriv = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(TOKEN_PRIVILEGES, Privileges) + sizeof(LUID_AND_ATTRIBUTES)); - if (!TokenPriv) - { - DPRINT1("Failed to allocate mem for token privileges\n"); - CloseHandle(Token); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - TokenPriv->PrivilegeCount = 1; - TokenPriv->Privileges[0].Attributes = bAcquire ? SE_PRIVILEGE_ENABLED : 0; - if (!LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &TokenPriv->Privileges[0].Luid)) - { - DPRINT1("LookupPrivilegeValue() failed with error %lu\n", GetLastError()); - HeapFree(GetProcessHeap(), 0, TokenPriv); - CloseHandle(Token); - return FALSE; - } - bRet = AdjustTokenPrivileges( - Token, - FALSE, - TokenPriv, - 0, - NULL, - NULL); - HeapFree(GetProcessHeap(), 0, TokenPriv); - CloseHandle(Token); - - if (!bRet) - { - DPRINT1("AdjustTokenPrivileges() failed with error %lu\n", GetLastError()); - return FALSE; - } - - return TRUE; + } + + return bRet; } @@ -177,6 +163,7 @@ DWORD dwDisposition; UINT i; HKEY hKey; + BOOL bRet = TRUE; LONG Error; DPRINT("CreateUserProfileW() called\n"); @@ -317,9 +304,8 @@ if (Error != ERROR_SUCCESS) { DPRINT1("Error: %lu\n", Error); - LocalFree((HLOCAL)SidString); - SetLastError((DWORD)Error); - return FALSE; + bRet = FALSE; + goto Done; } /* Create non-expanded user profile path */ @@ -337,10 +323,9 @@ if (Error != ERROR_SUCCESS) { DPRINT1("Error: %lu\n", Error); - LocalFree((HLOCAL)SidString); RegCloseKey(hKey); - SetLastError((DWORD)Error); - return FALSE; + bRet = FALSE; + goto Done; } /* Set 'Sid' value */ @@ -353,13 +338,12 @@ if (Error != ERROR_SUCCESS) { DPRINT1("Error: %lu\n", Error); - LocalFree((HLOCAL)SidString); RegCloseKey(hKey); - SetLastError((DWORD)Error); - return FALSE; - } - - RegCloseKey (hKey); + bRet = FALSE; + goto Done; + } + + RegCloseKey(hKey); /* Create user hive name */ wcscpy(szBuffer, szUserProfilePath); @@ -368,9 +352,10 @@ /* Acquire restore privilege */ if (!AcquireRemoveRestorePrivilege(TRUE)) { - DPRINT1("Error: %lu\n", Error); - LocalFree((HLOCAL)SidString); - return FALSE; + Error = GetLastError(); + DPRINT1("Error: %lu\n", Error); + bRet = FALSE; + goto Done; } /* Create new user hive */ @@ -381,26 +366,30 @@ if (Error != ERROR_SUCCESS) { DPRINT1("Error: %lu\n", Error); - LocalFree((HLOCAL)SidString); - SetLastError((DWORD)Error); - return FALSE; + bRet = FALSE; + goto Done; } /* Initialize user hive */ if (!CreateUserHive(SidString, szUserProfilePath)) { - DPRINT1("Error: %lu\n", GetLastError()); - LocalFree((HLOCAL)SidString); - return FALSE; - } - + Error = GetLastError(); + DPRINT1("Error: %lu\n", Error); + bRet = FALSE; + } + + /* Unload the hive */ + AcquireRemoveRestorePrivilege(TRUE); RegUnLoadKeyW(HKEY_USERS, SidString); - + AcquireRemoveRestorePrivilege(FALSE); + +Done: LocalFree((HLOCAL)SidString); + SetLastError((DWORD)Error); DPRINT("CreateUserProfileW() done\n"); - return TRUE; + return bRet; }
12 years, 5 months
1
0
0
0
[jimtabor] 56842: - Fix MSC build.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Thu Jul 5 22:35:06 2012 New Revision: 56842 URL:
http://svn.reactos.org/svn/reactos?rev=56842&view=rev
Log: - Fix MSC build. Modified: trunk/reactos/win32ss/user/user32/windows/defwnd.c Modified: trunk/reactos/win32ss/user/user32/windows/defwnd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
============================================================================== --- trunk/reactos/win32ss/user/user32/windows/defwnd.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/defwnd.c [iso-8859-1] Thu Jul 5 22:35:06 2012 @@ -1216,6 +1216,7 @@ case WM_PAINT: { PAINTSTRUCT Ps; + HDC hDC; /* If already in Paint and Client area is not empty just return. */ if (pWnd->state2 & WNDS2_STARTPAINT && !IsRectEmpty(&pWnd->rcClient)) @@ -1224,7 +1225,7 @@ return 0; } - HDC hDC = BeginPaint(hWnd, &Ps); + hDC = BeginPaint(hWnd, &Ps); if (hDC) { HICON hIcon;
12 years, 5 months
1
0
0
0
[jimtabor] 56841: [User32] - Use zap command when ending dialogs. Check keyboard perfs and cues before sending change GUI states.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Thu Jul 5 22:17:32 2012 New Revision: 56841 URL:
http://svn.reactos.org/svn/reactos?rev=56841&view=rev
Log: [User32] - Use zap command when ending dialogs. Check keyboard perfs and cues before sending change GUI states. Modified: trunk/reactos/win32ss/user/user32/windows/dialog.c trunk/reactos/win32ss/user/user32/windows/winpos.c Modified: trunk/reactos/win32ss/user/user32/windows/dialog.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
============================================================================== --- trunk/reactos/win32ss/user/user32/windows/dialog.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/dialog.c [iso-8859-1] Thu Jul 5 22:17:32 2012 @@ -46,7 +46,6 @@ #define GET_WORD(ptr) (*(WORD *)(ptr)) #define GET_DWORD(ptr) (*(DWORD *)(ptr)) #define DLG_ISANSI 2 -void WINAPI WinPosActivateOtherWindow(HWND hwnd); /* INTERNAL STRUCTS **********************************************************/ @@ -1062,7 +1061,21 @@ return hwnd; } if (modal && ownerEnabled) DIALOG_EnableOwner(owner); - if( IsWindow(hwnd) ) DestroyWindow( hwnd ); + IntNotifyWinEvent(EVENT_SYSTEM_DIALOGEND, hwnd, OBJID_WINDOW, CHILDID_SELF, 0); + if( IsWindow(hwnd) ) + { + DestroyWindow( hwnd ); + //// ReactOS + if (owner) + { ERR("DIALOG_CreateIndirect 1\n"); + if ( NtUserGetThreadState(THREADSTATE_FOREGROUNDTHREAD) && // Rule #1. + !NtUserQueryWindow(owner, QUERY_WINDOW_FOREGROUND) ) + { ERR("DIALOG_CreateIndirect SFW\n"); + SetForegroundWindow(owner); + } + } + //// + } return 0; } @@ -2001,7 +2014,7 @@ /* - * @implemented + * @implemented Modified for ReactOS. */ BOOL WINAPI @@ -2012,6 +2025,7 @@ BOOL wasEnabled = TRUE; DIALOGINFO * dlgInfo; HWND owner; + BOOL wasActive; TRACE("%p %ld\n", hwnd, retval ); @@ -2020,6 +2034,7 @@ ERR("got invalid window handle (%p); buggy app !?\n", hwnd); return FALSE; } + wasActive = (hwnd == GetActiveWindow()); dlgInfo->idResult = retval; dlgInfo->flags |= DF_END; wasEnabled = (dlgInfo->flags & DF_OWNERENABLED); @@ -2030,7 +2045,7 @@ /* Windows sets the focus to the dialog itself in EndDialog */ - if (IsChild(hwnd, GetFocus())) + if (wasActive && IsChild(hwnd, GetFocus())) SetFocus( hwnd ); /* Don't have to send a ShowWindow(SW_HIDE), just do @@ -2039,15 +2054,16 @@ SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_HIDEWINDOW); - if (hwnd == GetActiveWindow()) + if (wasActive && owner) { /* If this dialog was given an owner then set the focus to that owner even when the owner is disabled (normally when a window closes any disabled windows cannot receive the focus). */ - if (owner) - SetForegroundWindow( owner ); - else - WinPosActivateOtherWindow( hwnd ); + SetActiveWindow(owner); + } + else if (hwnd == GetActiveWindow()) // Check it again! + { + NtUserCallNoParam(NOPARAM_ROUTINE_ZAPACTIVEANDFOUS); } /* unblock dialog loop */ @@ -2593,13 +2609,15 @@ //// ReactOS case WM_SYSKEYDOWN: /* If the ALT key is being pressed display the keyboard cues */ - if (HIWORD(lpMsg->lParam) & KF_ALTDOWN) + if ( HIWORD(lpMsg->lParam) & KF_ALTDOWN && + !(gpsi->dwSRVIFlags & SRVINFO_KBDPREF) && !(gpsi->PUSIFlags & PUSIF_KEYBOARDCUES) ) SendMessageW(hDlg, WM_CHANGEUISTATE, MAKEWPARAM(UIS_CLEAR, UISF_HIDEACCEL | UISF_HIDEFOCUS), 0); break; case WM_SYSCOMMAND: /* If the ALT key is being pressed display the keyboard cues */ - if (lpMsg->wParam == SC_KEYMENU) + if ( lpMsg->wParam == SC_KEYMENU && + !(gpsi->dwSRVIFlags & SRVINFO_KBDPREF) && !(gpsi->PUSIFlags & PUSIF_KEYBOARDCUES) ) { SendMessageW(hDlg, WM_CHANGEUISTATE, MAKEWPARAM(UIS_CLEAR, UISF_HIDEACCEL | UISF_HIDEFOCUS), 0); } Modified: trunk/reactos/win32ss/user/user32/windows/winpos.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
============================================================================== --- trunk/reactos/win32ss/user/user32/windows/winpos.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/winpos.c [iso-8859-1] Thu Jul 5 22:17:32 2012 @@ -24,57 +24,6 @@ } /* FUNCTIONS *****************************************************************/ - -/******************************************************************* - * can_activate_window - * - * Check if we can activate the specified window. - */ -static BOOL can_activate_window( HWND hwnd ) -{ - LONG style; - - if (!hwnd) return FALSE; - style = GetWindowLongPtrW( hwnd, GWL_STYLE ); - if (!(style & WS_VISIBLE)) return FALSE; - if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE; - return !(style & WS_DISABLED); -} - - -/******************************************************************* - * WINPOS_ActivateOtherWindow - * - * Activates window other than pWnd. - */ -void -WINAPI -WinPosActivateOtherWindow(HWND hwnd) -{ - HWND hwndTo, fg; - - if ((GetWindowLongPtrW( hwnd, GWL_STYLE ) & WS_POPUP) && (hwndTo = GetWindow( hwnd, GW_OWNER ))) - { - hwndTo = GetAncestor( hwndTo, GA_ROOT ); - if (can_activate_window( hwndTo )) goto done; - } - - hwndTo = hwnd; - for (;;) - { - if (!(hwndTo = GetWindow( hwndTo, GW_HWNDNEXT ))) break; - if (can_activate_window( hwndTo )) break; - } - - done: - fg = GetForegroundWindow(); - TRACE("win = %p fg = %p\n", hwndTo, fg); - if (!fg || (hwnd == fg)) - { - if (SetForegroundWindow( hwndTo )) return; - } - if (!SetActiveWindow( hwndTo )) SetActiveWindow(0); -} #define EMPTYPOINT(pt) ((pt).x == -1 && (pt).y == -1)
12 years, 5 months
1
0
0
0
[jimtabor] 56840: - Fix build.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Thu Jul 5 22:10:03 2012 New Revision: 56840 URL:
http://svn.reactos.org/svn/reactos?rev=56840&view=rev
Log: - Fix build. Modified: trunk/reactos/win32ss/user/user32/windows/defwnd.c Modified: trunk/reactos/win32ss/user/user32/windows/defwnd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
============================================================================== --- trunk/reactos/win32ss/user/user32/windows/defwnd.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/defwnd.c [iso-8859-1] Thu Jul 5 22:10:03 2012 @@ -1027,6 +1027,13 @@ LPARAM lParam, BOOL bUnicode) { + PWND pWnd = NULL; + if (hWnd) + { + pWnd = ValidateHwnd(hWnd); + if (!pWnd) return 0; + } + switch (Msg) { case WM_NCPAINT: @@ -1531,10 +1538,7 @@ case WM_ISACTIVEICON: { - PWND pWnd; BOOL isai; - pWnd = ValidateHwnd(hWnd); - if (!pWnd) return 0; isai = (pWnd->state & WNDS_ACTIVEFRAME) != 0; return isai; }
12 years, 5 months
1
0
0
0
[jimtabor] 56839: [Win32SS] - Paint updates and signaling flags. - WIP: Implement WM_SYNCPAINT support, for synchronize painting to the top-level windows of other threads. - Tested with wine tests ...
by jimtabor@svn.reactos.org
Author: jimtabor Date: Thu Jul 5 22:04:47 2012 New Revision: 56839 URL:
http://svn.reactos.org/svn/reactos?rev=56839&view=rev
Log: [Win32SS] - Paint updates and signaling flags. - WIP: Implement WM_SYNCPAINT support, for synchronize painting to the top-level windows of other threads. - Tested with wine tests and passes,
http://www.winehq.org/pipermail/wine-patches/2012-June/114714.html
http://www.winehq.org/pipermail/wine-patches/2012-June/114715.html
Modified: trunk/reactos/win32ss/user/ntuser/painting.c trunk/reactos/win32ss/user/user32/windows/defwnd.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] Thu Jul 5 22:04:47 2012 @@ -58,8 +58,18 @@ BOOL FASTCALL IntValidateParent(PWND Child, HRGN hValidateRgn, BOOL Recurse) { - PWND ParentWnd = Child->spwndParent; - + PWND ParentWnd = Child; + + if (ParentWnd->style & WS_CHILD) + { + do + ParentWnd = ParentWnd->spwndParent; + while (ParentWnd->style & WS_CHILD); + } +// Hax out for drawing issues. +// if (!(ParentWnd->state & WNDS_SYNCPAINTPENDING)) Recurse = FALSE; + + ParentWnd = Child->spwndParent; while (ParentWnd) { if (ParentWnd->style & WS_CLIPCHILDREN) @@ -79,6 +89,81 @@ } return TRUE; +} + +/* + Synchronize painting to the top-level windows of other threads. +*/ +VOID FASTCALL +IntSendSyncPaint(PWND Wnd, ULONG Flags) +{ + PTHREADINFO ptiCur; + PUSER_MESSAGE_QUEUE MessageQueue; + PUSER_SENT_MESSAGE Message; + PLIST_ENTRY Entry; + BOOL bSend = TRUE; + + MessageQueue = Wnd->head.pti->MessageQueue; + ptiCur = PsGetCurrentThreadWin32Thread(); + /* + Not the current thread, Wnd is in send Nonclient paint also in send erase background and it is visiable. + */ + if ( Wnd->head.pti != ptiCur && + Wnd->state & WNDS_SENDNCPAINT && + Wnd->state & WNDS_SENDERASEBACKGROUND && + Wnd->style & WS_VISIBLE) + { + // For testing, if you see this, break out the Champagne and have a party! + ERR("SendSyncPaint Wnd in State!\n"); + if (!IsListEmpty(&MessageQueue->SentMessagesListHead)) + { + // Scan sent queue messages to see if we received sync paint messages. + Entry = MessageQueue->SentMessagesListHead.Flink; + Message = CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry); + do + { + ERR("LOOP it\n"); + if (Message->Msg.message == WM_SYNCPAINT && + Message->Msg.hwnd == UserHMGetHandle(Wnd)) + { // Already received so exit out. + ERR("SendSyncPaint Found one in the Sent Msg Queue!\n"); + bSend = FALSE; + break; + } + Entry = Message->ListEntry.Flink; + Message = CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry); + } + while (Entry != &MessageQueue->SentMessagesListHead); + } + if (bSend) + { + ERR("Sending WM_SYNCPAINT\n"); + // This message has no parameters. But it does! Pass Flags along. + co_IntSendMessageNoWait(UserHMGetHandle(Wnd), WM_SYNCPAINT, Flags, 0); + Wnd->state |= WNDS_SYNCPAINTPENDING; + } + } + + // Send to all the children if this is the desktop window. + if ( Wnd == UserGetDesktopWindow() ) + { + if ( Flags & RDW_ALLCHILDREN || + ( !(Flags & RDW_NOCHILDREN) && Wnd->style & WS_CLIPCHILDREN)) + { + PWND spwndChild = Wnd->spwndChild; + while(spwndChild) + { + if ( spwndChild->style & WS_CHILD && + spwndChild->head.pti != ptiCur) + { + spwndChild = spwndChild->spwndNext; + continue; + } + IntSendSyncPaint( spwndChild, Flags ); + spwndChild = spwndChild->spwndNext; + } + } + } } /** @@ -166,6 +251,7 @@ { GreDeleteObject(hRgnWindow); GreDeleteObject(hRgnNonClient); + Window->state &= ~WNDS_UPDATEDIRTY; return NULL; } @@ -181,6 +267,7 @@ { IntGdiSetRegionOwner(Window->hrgnUpdate, GDI_OBJ_HMGR_POWNED); GreDeleteObject(Window->hrgnUpdate); + Window->state &= ~WNDS_UPDATEDIRTY; Window->hrgnUpdate = NULL; if (!(Window->state & WNDS_INTERNALPAINT)) MsqDecPaintCountQueue(Window->head.pti->MessageQueue); @@ -210,6 +297,8 @@ HWND hWnd = Wnd->head.h; HRGN TempRegion; + Wnd->state &= ~WNDS_PAINTNOTPROCESSED; + if (Flags & (RDW_ERASENOW | RDW_UPDATENOW)) { if (Wnd->hrgnUpdate) @@ -220,20 +309,26 @@ if (Flags & RDW_UPDATENOW) { - if (Wnd->hrgnUpdate != NULL || - Wnd->state & WNDS_INTERNALPAINT) + if ((Wnd->hrgnUpdate != NULL || + Wnd->state & WNDS_INTERNALPAINT)) { Wnd->state2 |= WNDS2_WMPAINTSENT; co_IntSendMessage(hWnd, WM_PAINT, 0, 0); } } - else + else if (Wnd->head.pti == PsGetCurrentThreadWin32Thread()) { if (Wnd->state & WNDS_SENDNCPAINT) { TempRegion = IntGetNCUpdateRgn(Wnd, TRUE); Wnd->state &= ~WNDS_SENDNCPAINT; - co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)TempRegion, 0); + if ( Wnd == GetW32ThreadInfo()->MessageQueue->spwndActive && + !(Wnd->state & WNDS_ACTIVEFRAME)) + { + Wnd->state |= WNDS_ACTIVEFRAME; + Wnd->state &= ~WNDS_NONCPAINT; + } + if (TempRegion) co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)TempRegion, 0); } if (Wnd->state & WNDS_SENDERASEBACKGROUND) @@ -254,6 +349,10 @@ } } } + } + else + { + Wnd->state &= ~(WNDS_SENDNCPAINT|WNDS_SENDERASEBACKGROUND|WNDS_ERASEBACKGROUND); } /* @@ -306,6 +405,8 @@ TRACE("IntInvalidateWindows start\n"); + Wnd->state |= WNDS_PAINTNOTPROCESSED; + /* * If the nonclient is not to be redrawn, clip the region to the client * rect @@ -362,10 +463,14 @@ if (Flags & RDW_INVALIDATE && RgnType != NULLREGION) { + Wnd->state &= ~WNDS_NONCPAINT; + /* If not the same thread set it dirty. */ if (Wnd->head.pti != PsGetCurrentThreadWin32Thread()) { Wnd->state |= WNDS_UPDATEDIRTY; + if (Wnd->state2 & WNDS2_WMPAINTSENT) + Wnd->state2 |= WNDS2_ENDPAINTINVALIDATE; } if (Flags & RDW_FRAME) @@ -572,6 +677,7 @@ if (Flags & (RDW_ERASENOW | RDW_UPDATENOW)) { + if (Flags & RDW_ERASENOW) IntSendSyncPaint(Window, Flags); co_IntPaintWindows(Window, Flags, FALSE); } @@ -853,7 +959,7 @@ co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)hRgn, 0); if (hRgn != HRGN_WINDOW && hRgn != NULL && GreIsHandleValid(hRgn)) { - /* NOTE: The region can already by deleted! */ + /* NOTE: The region can already be deleted! */ GreDeleteObject(hRgn); } } @@ -928,7 +1034,7 @@ CLEANUP: if (Window) UserDerefObjectCo(Window); - TRACE("Leave NtUserBeginPaint, ret=%i\n",_ret_); + TRACE("Leave NtUserBeginPaint, ret=%p\n",_ret_); UserLeave(); END_CLEANUP; @@ -1869,11 +1975,13 @@ return Ret; } +BOOL FASTCALL IntPaintDesktop(HDC hDC); + INT FASTCALL UserRealizePalette(HDC hdc) { - HWND hWnd; + HWND hWnd, hWndDesktop; DWORD Ret; Ret = IntGdiRealizePalette(hdc); @@ -1882,6 +1990,15 @@ hWnd = IntWindowFromDC(hdc); if (hWnd) // Send broadcast if dc is associated with a window. { // FYI: Thread locked in CallOneParam. + hWndDesktop = IntGetDesktopWindow(); + if ( hWndDesktop != hWnd ) + { + PWND pWnd = UserGetWindowObject(hWndDesktop); + ERR("RealizePalette Desktop."); + hdc = UserGetWindowDC(pWnd); + IntPaintDesktop(hdc); + UserReleaseDC(pWnd,hdc,FALSE); + } UserSendNotifyMessage((HWND)HWND_BROADCAST, WM_PALETTECHANGED, (WPARAM)hWnd, 0); } } Modified: trunk/reactos/win32ss/user/user32/windows/defwnd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
============================================================================== --- trunk/reactos/win32ss/user/user32/windows/defwnd.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/defwnd.c [iso-8859-1] Thu Jul 5 22:04:47 2012 @@ -1209,13 +1209,20 @@ case WM_PAINT: { PAINTSTRUCT Ps; + + /* If already in Paint and Client area is not empty just return. */ + if (pWnd->state2 & WNDS2_STARTPAINT && !IsRectEmpty(&pWnd->rcClient)) + { + ERR("In Paint and Client area is not empty!\n"); + return 0; + } + HDC hDC = BeginPaint(hWnd, &Ps); if (hDC) { HICON hIcon; - if (GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_MINIMIZE && - (hIcon = (HICON)GetClassLongPtrW(hWnd, GCL_HICON)) != NULL) + if (IsIconic(hWnd) && ((hIcon = (HICON)GetClassLongPtrW( hWnd, GCLP_HICON)))) { RECT ClientRect; INT x, y;
12 years, 5 months
1
0
0
0
← Newer
1
...
14
15
16
17
18
19
20
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Results per page:
10
25
50
100
200