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
January 2020
----- 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
21 participants
133 discussions
Start a n
N
ew thread
[reactos] 02/02: [WIN32K:NTGDI] Add missing probe to NtGdiGetPath.
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5b83d86af52907ff7c77f…
commit 5b83d86af52907ff7c77fff9c2fea3f5d714f5e6 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Tue Dec 31 21:07:39 2019 +0100 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Fri Jan 3 11:21:24 2020 +0100 [WIN32K:NTGDI] Add missing probe to NtGdiGetPath. --- win32ss/gdi/ntgdi/path.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/win32ss/gdi/ntgdi/path.c b/win32ss/gdi/ntgdi/path.c index 4a5277a9fe1..552bc9c4f54 100644 --- a/win32ss/gdi/ntgdi/path.c +++ b/win32ss/gdi/ntgdi/path.c @@ -222,7 +222,7 @@ BOOL PATH_RestorePath( DC *dst, DC *src ) PATH_AssignGdiPath(pdstPath, psrcPath); PATH_UnlockPath(pdstPath); - PATH_UnlockPath(psrcPath); + PATH_UnlockPath(psrcPath); } else { @@ -1405,7 +1405,7 @@ PATH_PathToRegion( INT Mode, PREGION Rgn) { - int i, pos, polygons; + int i, pos, polygons; PULONG counts; int Ret; @@ -2694,8 +2694,21 @@ NtGdiGetPath( { INT ret = -1; PPATH pPath; + DC *dc; + + _SEH2_TRY + { + ProbeForWrite(Points, nSize * sizeof(*Points), sizeof(ULONG)); + ProbeForWrite(Types, nSize, 1); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + SetLastNtError(_SEH2_GetExceptionCode()); + _SEH2_YIELD(return -1); + } + _SEH2_END - DC *dc = DC_LockDc(hDC); + dc = DC_LockDc(hDC); DPRINT("NtGdiGetPath start\n"); if (!dc) {
4 years, 11 months
1
0
0
0
[reactos] 01/02: [WIN32K:NTGDI] Avoid breakpoints in syscalls.
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f0d2bd385253d8bb6d89e…
commit f0d2bd385253d8bb6d89e3bd4cd00bc9ffc14b95 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Tue Dec 31 21:06:43 2019 +0100 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Fri Jan 3 11:21:21 2020 +0100 [WIN32K:NTGDI] Avoid breakpoints in syscalls. --- win32ss/gdi/ntgdi/brush.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/win32ss/gdi/ntgdi/brush.cpp b/win32ss/gdi/ntgdi/brush.cpp index 5671324bbe5..41d13184b12 100644 --- a/win32ss/gdi/ntgdi/brush.cpp +++ b/win32ss/gdi/ntgdi/brush.cpp @@ -543,7 +543,7 @@ NtGdiSetBrushAttributes( _In_ HBRUSH hbr, _In_ DWORD dwFlags) { - __debugbreak(); + FIXME("NtGdiSetBrushAttributes is unimplemented\n"); return NULL; } @@ -554,7 +554,7 @@ NtGdiClearBrushAttributes( _In_ HBRUSH hbr, _In_ DWORD dwFlags) { - __debugbreak(); + FIXME("NtGdiClearBrushAttributes is unimplemented\n"); return NULL; }
4 years, 11 months
1
0
0
0
[reactos] 01/01: [NTOS:IO] Fix indentation. No code changes!
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9538c3ccd781c22a16363…
commit 9538c3ccd781c22a16363222de30a28acc17d185 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Thu Jan 2 23:13:18 2020 +0100 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Thu Jan 2 23:25:26 2020 +0100 [NTOS:IO] Fix indentation. No code changes! --- ntoskrnl/io/pnpmgr/pnpres.c | 851 ++++++++++++++++++++++---------------------- 1 file changed, 430 insertions(+), 421 deletions(-) diff --git a/ntoskrnl/io/pnpmgr/pnpres.c b/ntoskrnl/io/pnpmgr/pnpres.c index ef77e7f8790..2711e1a1dac 100644 --- a/ntoskrnl/io/pnpmgr/pnpres.c +++ b/ntoskrnl/io/pnpmgr/pnpres.c @@ -14,42 +14,44 @@ static BOOLEAN -IopCheckDescriptorForConflict(PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) +IopCheckDescriptorForConflict( + PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, + OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) { - CM_RESOURCE_LIST CmList; - NTSTATUS Status; - - CmList.Count = 1; - CmList.List[0].InterfaceType = InterfaceTypeUndefined; - CmList.List[0].BusNumber = 0; - CmList.List[0].PartialResourceList.Version = 1; - CmList.List[0].PartialResourceList.Revision = 1; - CmList.List[0].PartialResourceList.Count = 1; - CmList.List[0].PartialResourceList.PartialDescriptors[0] = *CmDesc; - - Status = IopDetectResourceConflict(&CmList, TRUE, ConflictingDescriptor); - if (Status == STATUS_CONFLICTING_ADDRESSES) - return TRUE; - - return FALSE; + CM_RESOURCE_LIST CmList; + NTSTATUS Status; + + CmList.Count = 1; + CmList.List[0].InterfaceType = InterfaceTypeUndefined; + CmList.List[0].BusNumber = 0; + CmList.List[0].PartialResourceList.Version = 1; + CmList.List[0].PartialResourceList.Revision = 1; + CmList.List[0].PartialResourceList.Count = 1; + CmList.List[0].PartialResourceList.PartialDescriptors[0] = *CmDesc; + + Status = IopDetectResourceConflict(&CmList, TRUE, ConflictingDescriptor); + if (Status == STATUS_CONFLICTING_ADDRESSES) + return TRUE; + + return FALSE; } static BOOLEAN IopFindBusNumberResource( - IN PIO_RESOURCE_DESCRIPTOR IoDesc, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) + IN PIO_RESOURCE_DESCRIPTOR IoDesc, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) { - ULONG Start; - CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; + ULONG Start; + CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; - ASSERT(IoDesc->Type == CmDesc->Type); - ASSERT(IoDesc->Type == CmResourceTypeBusNumber); + ASSERT(IoDesc->Type == CmDesc->Type); + ASSERT(IoDesc->Type == CmResourceTypeBusNumber); - for (Start = IoDesc->u.BusNumber.MinBusNumber; - Start <= IoDesc->u.BusNumber.MaxBusNumber - IoDesc->u.BusNumber.Length + 1; - Start++) - { + for (Start = IoDesc->u.BusNumber.MinBusNumber; + Start <= IoDesc->u.BusNumber.MaxBusNumber - IoDesc->u.BusNumber.Length + 1; + Start++) + { CmDesc->u.BusNumber.Length = IoDesc->u.BusNumber.Length; CmDesc->u.BusNumber.Start = Start; @@ -62,30 +64,31 @@ IopFindBusNumberResource( DPRINT1("Satisfying bus number requirement with 0x%x (length: 0x%x)\n", Start, CmDesc->u.BusNumber.Length); return TRUE; } - } + } - return FALSE; + return FALSE; } static BOOLEAN IopFindMemoryResource( - IN PIO_RESOURCE_DESCRIPTOR IoDesc, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) + IN PIO_RESOURCE_DESCRIPTOR IoDesc, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) { - ULONGLONG Start; - CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; + ULONGLONG Start; + CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; - ASSERT(IoDesc->Type == CmDesc->Type); - ASSERT(IoDesc->Type == CmResourceTypeMemory); + ASSERT(IoDesc->Type == CmDesc->Type); + ASSERT(IoDesc->Type == CmResourceTypeMemory); - /* HACK */ - if (IoDesc->u.Memory.Alignment == 0) IoDesc->u.Memory.Alignment = 1; + /* HACK */ + if (IoDesc->u.Memory.Alignment == 0) + IoDesc->u.Memory.Alignment = 1; - for (Start = (ULONGLONG)IoDesc->u.Memory.MinimumAddress.QuadPart; - Start <= (ULONGLONG)IoDesc->u.Memory.MaximumAddress.QuadPart - IoDesc->u.Memory.Length + 1; - Start += IoDesc->u.Memory.Alignment) - { + for (Start = (ULONGLONG)IoDesc->u.Memory.MinimumAddress.QuadPart; + Start <= (ULONGLONG)IoDesc->u.Memory.MaximumAddress.QuadPart - IoDesc->u.Memory.Length + 1; + Start += IoDesc->u.Memory.Alignment) + { CmDesc->u.Memory.Length = IoDesc->u.Memory.Length; CmDesc->u.Memory.Start.QuadPart = (LONGLONG)Start; @@ -99,30 +102,31 @@ IopFindMemoryResource( DPRINT1("Satisfying memory requirement with 0x%I64x (length: 0x%x)\n", Start, CmDesc->u.Memory.Length); return TRUE; } - } + } - return FALSE; + return FALSE; } static BOOLEAN IopFindPortResource( - IN PIO_RESOURCE_DESCRIPTOR IoDesc, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) + IN PIO_RESOURCE_DESCRIPTOR IoDesc, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) { - ULONGLONG Start; - CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; + ULONGLONG Start; + CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; - ASSERT(IoDesc->Type == CmDesc->Type); - ASSERT(IoDesc->Type == CmResourceTypePort); + ASSERT(IoDesc->Type == CmDesc->Type); + ASSERT(IoDesc->Type == CmResourceTypePort); - /* HACK */ - if (IoDesc->u.Port.Alignment == 0) IoDesc->u.Port.Alignment = 1; + /* HACK */ + if (IoDesc->u.Port.Alignment == 0) + IoDesc->u.Port.Alignment = 1; - for (Start = (ULONGLONG)IoDesc->u.Port.MinimumAddress.QuadPart; - Start <= (ULONGLONG)IoDesc->u.Port.MaximumAddress.QuadPart - IoDesc->u.Port.Length + 1; - Start += IoDesc->u.Port.Alignment) - { + for (Start = (ULONGLONG)IoDesc->u.Port.MinimumAddress.QuadPart; + Start <= (ULONGLONG)IoDesc->u.Port.MaximumAddress.QuadPart - IoDesc->u.Port.Length + 1; + Start += IoDesc->u.Port.Alignment) + { CmDesc->u.Port.Length = IoDesc->u.Port.Length; CmDesc->u.Port.Start.QuadPart = (LONGLONG)Start; @@ -135,27 +139,27 @@ IopFindPortResource( DPRINT("Satisfying port requirement with 0x%I64x (length: 0x%x)\n", Start, CmDesc->u.Port.Length); return TRUE; } - } + } - DPRINT1("IopFindPortResource failed!\n"); - return FALSE; + DPRINT1("IopFindPortResource failed!\n"); + return FALSE; } static BOOLEAN IopFindDmaResource( - IN PIO_RESOURCE_DESCRIPTOR IoDesc, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) + IN PIO_RESOURCE_DESCRIPTOR IoDesc, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) { - ULONG Channel; + ULONG Channel; - ASSERT(IoDesc->Type == CmDesc->Type); - ASSERT(IoDesc->Type == CmResourceTypeDma); + ASSERT(IoDesc->Type == CmDesc->Type); + ASSERT(IoDesc->Type == CmResourceTypeDma); - for (Channel = IoDesc->u.Dma.MinimumChannel; - Channel <= IoDesc->u.Dma.MaximumChannel; - Channel++) - { + for (Channel = IoDesc->u.Dma.MinimumChannel; + Channel <= IoDesc->u.Dma.MaximumChannel; + Channel++) + { CmDesc->u.Dma.Channel = Channel; CmDesc->u.Dma.Port = 0; @@ -164,26 +168,26 @@ IopFindDmaResource( DPRINT1("Satisfying DMA requirement with channel 0x%x\n", Channel); return TRUE; } - } + } - return FALSE; + return FALSE; } static BOOLEAN IopFindInterruptResource( - IN PIO_RESOURCE_DESCRIPTOR IoDesc, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) + IN PIO_RESOURCE_DESCRIPTOR IoDesc, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) { - ULONG Vector; + ULONG Vector; - ASSERT(IoDesc->Type == CmDesc->Type); - ASSERT(IoDesc->Type == CmResourceTypeInterrupt); + ASSERT(IoDesc->Type == CmDesc->Type); + ASSERT(IoDesc->Type == CmResourceTypeInterrupt); - for (Vector = IoDesc->u.Interrupt.MinimumVector; - Vector <= IoDesc->u.Interrupt.MaximumVector; - Vector++) - { + for (Vector = IoDesc->u.Interrupt.MinimumVector; + Vector <= IoDesc->u.Interrupt.MaximumVector; + Vector++) + { CmDesc->u.Interrupt.Vector = Vector; CmDesc->u.Interrupt.Level = Vector; CmDesc->u.Interrupt.Affinity = (KAFFINITY)-1; @@ -193,15 +197,15 @@ IopFindInterruptResource( DPRINT1("Satisfying interrupt requirement with IRQ 0x%x\n", Vector); return TRUE; } - } + } - return FALSE; + return FALSE; } NTSTATUS NTAPI IopFixupResourceListWithRequirements( - IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList, - OUT PCM_RESOURCE_LIST *ResourceList) + IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList, + OUT PCM_RESOURCE_LIST *ResourceList) { ULONG i, OldCount; BOOLEAN AlternateRequired = FALSE; @@ -537,388 +541,393 @@ IopFixupResourceListWithRequirements( static BOOLEAN IopCheckResourceDescriptor( - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc, - IN PCM_RESOURCE_LIST ResourceList, - IN BOOLEAN Silent, - OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc, + IN PCM_RESOURCE_LIST ResourceList, + IN BOOLEAN Silent, + OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) { - ULONG i, ii; - BOOLEAN Result = FALSE; + ULONG i, ii; + BOOLEAN Result = FALSE; - for (i = 0; i < ResourceList->Count; i++) - { - PCM_PARTIAL_RESOURCE_LIST ResList = &ResourceList->List[i].PartialResourceList; - for (ii = 0; ii < ResList->Count; ii++) - { - PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc2 = &ResList->PartialDescriptors[ii]; + for (i = 0; i < ResourceList->Count; i++) + { + PCM_PARTIAL_RESOURCE_LIST ResList = &ResourceList->List[i].PartialResourceList; + for (ii = 0; ii < ResList->Count; ii++) + { + PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc2 = &ResList->PartialDescriptors[ii]; - /* We don't care about shared resources */ - if (ResDesc->ShareDisposition == CmResourceShareShared && - ResDesc2->ShareDisposition == CmResourceShareShared) - continue; + /* We don't care about shared resources */ + if (ResDesc->ShareDisposition == CmResourceShareShared && + ResDesc2->ShareDisposition == CmResourceShareShared) + continue; - /* Make sure we're comparing the same types */ - if (ResDesc->Type != ResDesc2->Type) - continue; + /* Make sure we're comparing the same types */ + if (ResDesc->Type != ResDesc2->Type) + continue; - switch (ResDesc->Type) - { - case CmResourceTypeMemory: - if (((ULONGLONG)ResDesc->u.Memory.Start.QuadPart < (ULONGLONG)ResDesc2->u.Memory.Start.QuadPart && - (ULONGLONG)ResDesc->u.Memory.Start.QuadPart + ResDesc->u.Memory.Length > - (ULONGLONG)ResDesc2->u.Memory.Start.QuadPart) || ((ULONGLONG)ResDesc2->u.Memory.Start.QuadPart < - (ULONGLONG)ResDesc->u.Memory.Start.QuadPart && (ULONGLONG)ResDesc2->u.Memory.Start.QuadPart + - ResDesc2->u.Memory.Length > (ULONGLONG)ResDesc->u.Memory.Start.QuadPart)) - { - if (!Silent) - { - DPRINT1("Resource conflict: Memory (0x%I64x to 0x%I64x vs. 0x%I64x to 0x%I64x)\n", - ResDesc->u.Memory.Start.QuadPart, ResDesc->u.Memory.Start.QuadPart + - ResDesc->u.Memory.Length, ResDesc2->u.Memory.Start.QuadPart, - ResDesc2->u.Memory.Start.QuadPart + ResDesc2->u.Memory.Length); - } - - Result = TRUE; - - goto ByeBye; - } - break; - - case CmResourceTypePort: - if (((ULONGLONG)ResDesc->u.Port.Start.QuadPart < (ULONGLONG)ResDesc2->u.Port.Start.QuadPart && - (ULONGLONG)ResDesc->u.Port.Start.QuadPart + ResDesc->u.Port.Length > - (ULONGLONG)ResDesc2->u.Port.Start.QuadPart) || ((ULONGLONG)ResDesc2->u.Port.Start.QuadPart < - (ULONGLONG)ResDesc->u.Port.Start.QuadPart && (ULONGLONG)ResDesc2->u.Port.Start.QuadPart + - ResDesc2->u.Port.Length > (ULONGLONG)ResDesc->u.Port.Start.QuadPart)) - { - if (!Silent) - { - DPRINT1("Resource conflict: Port (0x%I64x to 0x%I64x vs. 0x%I64x to 0x%I64x)\n", - ResDesc->u.Port.Start.QuadPart, ResDesc->u.Port.Start.QuadPart + - ResDesc->u.Port.Length, ResDesc2->u.Port.Start.QuadPart, - ResDesc2->u.Port.Start.QuadPart + ResDesc2->u.Port.Length); - } - - Result = TRUE; - - goto ByeBye; - } - break; - - case CmResourceTypeInterrupt: - if (ResDesc->u.Interrupt.Vector == ResDesc2->u.Interrupt.Vector) - { - if (!Silent) - { - DPRINT1("Resource conflict: IRQ (0x%x 0x%x vs. 0x%x 0x%x)\n", - ResDesc->u.Interrupt.Vector, ResDesc->u.Interrupt.Level, - ResDesc2->u.Interrupt.Vector, ResDesc2->u.Interrupt.Level); - } - - Result = TRUE; - - goto ByeBye; - } - break; - - case CmResourceTypeBusNumber: - if ((ResDesc->u.BusNumber.Start < ResDesc2->u.BusNumber.Start && - ResDesc->u.BusNumber.Start + ResDesc->u.BusNumber.Length > - ResDesc2->u.BusNumber.Start) || (ResDesc2->u.BusNumber.Start < - ResDesc->u.BusNumber.Start && ResDesc2->u.BusNumber.Start + - ResDesc2->u.BusNumber.Length > ResDesc->u.BusNumber.Start)) - { - if (!Silent) - { - DPRINT1("Resource conflict: Bus number (0x%x to 0x%x vs. 0x%x to 0x%x)\n", - ResDesc->u.BusNumber.Start, ResDesc->u.BusNumber.Start + - ResDesc->u.BusNumber.Length, ResDesc2->u.BusNumber.Start, - ResDesc2->u.BusNumber.Start + ResDesc2->u.BusNumber.Length); - } - - Result = TRUE; - - goto ByeBye; - } - break; - - case CmResourceTypeDma: - if (ResDesc->u.Dma.Channel == ResDesc2->u.Dma.Channel) - { - if (!Silent) - { - DPRINT1("Resource conflict: Dma (0x%x 0x%x vs. 0x%x 0x%x)\n", - ResDesc->u.Dma.Channel, ResDesc->u.Dma.Port, - ResDesc2->u.Dma.Channel, ResDesc2->u.Dma.Port); - } - - Result = TRUE; - - goto ByeBye; - } - break; - } - } - } + switch (ResDesc->Type) + { + case CmResourceTypeMemory: + if (((ULONGLONG)ResDesc->u.Memory.Start.QuadPart < (ULONGLONG)ResDesc2->u.Memory.Start.QuadPart && + (ULONGLONG)ResDesc->u.Memory.Start.QuadPart + ResDesc->u.Memory.Length > + (ULONGLONG)ResDesc2->u.Memory.Start.QuadPart) || ((ULONGLONG)ResDesc2->u.Memory.Start.QuadPart < + (ULONGLONG)ResDesc->u.Memory.Start.QuadPart && (ULONGLONG)ResDesc2->u.Memory.Start.QuadPart + + ResDesc2->u.Memory.Length > (ULONGLONG)ResDesc->u.Memory.Start.QuadPart)) + { + if (!Silent) + { + DPRINT1("Resource conflict: Memory (0x%I64x to 0x%I64x vs. 0x%I64x to 0x%I64x)\n", + ResDesc->u.Memory.Start.QuadPart, ResDesc->u.Memory.Start.QuadPart + + ResDesc->u.Memory.Length, ResDesc2->u.Memory.Start.QuadPart, + ResDesc2->u.Memory.Start.QuadPart + ResDesc2->u.Memory.Length); + } -ByeBye: + Result = TRUE; - if (Result && ConflictingDescriptor) - { - RtlCopyMemory(ConflictingDescriptor, - ResDesc, - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); - } + goto ByeBye; + } + break; - return Result; -} + case CmResourceTypePort: + if (((ULONGLONG)ResDesc->u.Port.Start.QuadPart < (ULONGLONG)ResDesc2->u.Port.Start.QuadPart && + (ULONGLONG)ResDesc->u.Port.Start.QuadPart + ResDesc->u.Port.Length > + (ULONGLONG)ResDesc2->u.Port.Start.QuadPart) || ((ULONGLONG)ResDesc2->u.Port.Start.QuadPart < + (ULONGLONG)ResDesc->u.Port.Start.QuadPart && (ULONGLONG)ResDesc2->u.Port.Start.QuadPart + + ResDesc2->u.Port.Length > (ULONGLONG)ResDesc->u.Port.Start.QuadPart)) + { + if (!Silent) + { + DPRINT1("Resource conflict: Port (0x%I64x to 0x%I64x vs. 0x%I64x to 0x%I64x)\n", + ResDesc->u.Port.Start.QuadPart, ResDesc->u.Port.Start.QuadPart + + ResDesc->u.Port.Length, ResDesc2->u.Port.Start.QuadPart, + ResDesc2->u.Port.Start.QuadPart + ResDesc2->u.Port.Length); + } -static -NTSTATUS -IopUpdateControlKeyWithResources(IN PDEVICE_NODE DeviceNode) -{ - UNICODE_STRING EnumRoot = RTL_CONSTANT_STRING(ENUM_ROOT); - UNICODE_STRING Control = RTL_CONSTANT_STRING(L"Control"); - UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"AllocConfig"); - HANDLE EnumKey, InstanceKey, ControlKey; - NTSTATUS Status; - OBJECT_ATTRIBUTES ObjectAttributes; + Result = TRUE; - /* Open the Enum key */ - Status = IopOpenRegistryKeyEx(&EnumKey, NULL, &EnumRoot, KEY_ENUMERATE_SUB_KEYS); - if (!NT_SUCCESS(Status)) - return Status; + goto ByeBye; + } + break; - /* Open the instance key (eg. Root\PNP0A03) */ - Status = IopOpenRegistryKeyEx(&InstanceKey, EnumKey, &DeviceNode->InstancePath, KEY_ENUMERATE_SUB_KEYS); - ZwClose(EnumKey); + case CmResourceTypeInterrupt: + if (ResDesc->u.Interrupt.Vector == ResDesc2->u.Interrupt.Vector) + { + if (!Silent) + { + DPRINT1("Resource conflict: IRQ (0x%x 0x%x vs. 0x%x 0x%x)\n", + ResDesc->u.Interrupt.Vector, ResDesc->u.Interrupt.Level, + ResDesc2->u.Interrupt.Vector, ResDesc2->u.Interrupt.Level); + } - if (!NT_SUCCESS(Status)) - return Status; + Result = TRUE; - /* Create/Open the Control key */ - InitializeObjectAttributes(&ObjectAttributes, - &Control, - OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, - InstanceKey, - NULL); - Status = ZwCreateKey(&ControlKey, - KEY_SET_VALUE, - &ObjectAttributes, - 0, - NULL, - REG_OPTION_VOLATILE, - NULL); - ZwClose(InstanceKey); + goto ByeBye; + } + break; - if (!NT_SUCCESS(Status)) - return Status; + case CmResourceTypeBusNumber: + if ((ResDesc->u.BusNumber.Start < ResDesc2->u.BusNumber.Start && + ResDesc->u.BusNumber.Start + ResDesc->u.BusNumber.Length > + ResDesc2->u.BusNumber.Start) || (ResDesc2->u.BusNumber.Start < + ResDesc->u.BusNumber.Start && ResDesc2->u.BusNumber.Start + + ResDesc2->u.BusNumber.Length > ResDesc->u.BusNumber.Start)) + { + if (!Silent) + { + DPRINT1("Resource conflict: Bus number (0x%x to 0x%x vs. 0x%x to 0x%x)\n", + ResDesc->u.BusNumber.Start, ResDesc->u.BusNumber.Start + + ResDesc->u.BusNumber.Length, ResDesc2->u.BusNumber.Start, + ResDesc2->u.BusNumber.Start + ResDesc2->u.BusNumber.Length); + } - /* Write the resource list */ - Status = ZwSetValueKey(ControlKey, - &ValueName, - 0, - REG_RESOURCE_LIST, - DeviceNode->ResourceList, - PnpDetermineResourceListSize(DeviceNode->ResourceList)); - ZwClose(ControlKey); + Result = TRUE; - if (!NT_SUCCESS(Status)) - return Status; + goto ByeBye; + } + break; - return STATUS_SUCCESS; + case CmResourceTypeDma: + if (ResDesc->u.Dma.Channel == ResDesc2->u.Dma.Channel) + { + if (!Silent) + { + DPRINT1("Resource conflict: Dma (0x%x 0x%x vs. 0x%x 0x%x)\n", + ResDesc->u.Dma.Channel, ResDesc->u.Dma.Port, + ResDesc2->u.Dma.Channel, ResDesc2->u.Dma.Port); + } + + Result = TRUE; + + goto ByeBye; + } + break; + } + } + } + +ByeBye: + + if (Result && ConflictingDescriptor) + { + RtlCopyMemory(ConflictingDescriptor, + ResDesc, + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); + } + + return Result; } static NTSTATUS -IopFilterResourceRequirements(IN PDEVICE_NODE DeviceNode) +IopUpdateControlKeyWithResources( + IN PDEVICE_NODE DeviceNode) { - IO_STACK_LOCATION Stack; - IO_STATUS_BLOCK IoStatusBlock; - NTSTATUS Status; - - DPRINT("Sending IRP_MN_FILTER_RESOURCE_REQUIREMENTS to device stack\n"); + UNICODE_STRING EnumRoot = RTL_CONSTANT_STRING(ENUM_ROOT); + UNICODE_STRING Control = RTL_CONSTANT_STRING(L"Control"); + UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"AllocConfig"); + HANDLE EnumKey, InstanceKey, ControlKey; + NTSTATUS Status; + OBJECT_ATTRIBUTES ObjectAttributes; + + /* Open the Enum key */ + Status = IopOpenRegistryKeyEx(&EnumKey, NULL, &EnumRoot, KEY_ENUMERATE_SUB_KEYS); + if (!NT_SUCCESS(Status)) + return Status; + + /* Open the instance key (eg. Root\PNP0A03) */ + Status = IopOpenRegistryKeyEx(&InstanceKey, EnumKey, &DeviceNode->InstancePath, KEY_ENUMERATE_SUB_KEYS); + ZwClose(EnumKey); + + if (!NT_SUCCESS(Status)) + return Status; + + /* Create/Open the Control key */ + InitializeObjectAttributes(&ObjectAttributes, + &Control, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + InstanceKey, + NULL); + Status = ZwCreateKey(&ControlKey, + KEY_SET_VALUE, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + NULL); + ZwClose(InstanceKey); + + if (!NT_SUCCESS(Status)) + return Status; + + /* Write the resource list */ + Status = ZwSetValueKey(ControlKey, + &ValueName, + 0, + REG_RESOURCE_LIST, + DeviceNode->ResourceList, + PnpDetermineResourceListSize(DeviceNode->ResourceList)); + ZwClose(ControlKey); + + if (!NT_SUCCESS(Status)) + return Status; + + return STATUS_SUCCESS; +} - Stack.Parameters.FilterResourceRequirements.IoResourceRequirementList = DeviceNode->ResourceRequirements; - Status = IopInitiatePnpIrp( - DeviceNode->PhysicalDeviceObject, - &IoStatusBlock, - IRP_MN_FILTER_RESOURCE_REQUIREMENTS, - &Stack); - if (!NT_SUCCESS(Status) && Status != STATUS_NOT_SUPPORTED) - { - DPRINT1("IopInitiatePnpIrp(IRP_MN_FILTER_RESOURCE_REQUIREMENTS) failed\n"); - return Status; - } - else if (NT_SUCCESS(Status) && IoStatusBlock.Information) - { - DeviceNode->ResourceRequirements = (PIO_RESOURCE_REQUIREMENTS_LIST)IoStatusBlock.Information; - } +static +NTSTATUS +IopFilterResourceRequirements( + IN PDEVICE_NODE DeviceNode) +{ + IO_STACK_LOCATION Stack; + IO_STATUS_BLOCK IoStatusBlock; + NTSTATUS Status; + + DPRINT("Sending IRP_MN_FILTER_RESOURCE_REQUIREMENTS to device stack\n"); + + Stack.Parameters.FilterResourceRequirements.IoResourceRequirementList = DeviceNode->ResourceRequirements; + Status = IopInitiatePnpIrp(DeviceNode->PhysicalDeviceObject, + &IoStatusBlock, + IRP_MN_FILTER_RESOURCE_REQUIREMENTS, + &Stack); + if (!NT_SUCCESS(Status) && Status != STATUS_NOT_SUPPORTED) + { + DPRINT1("IopInitiatePnpIrp(IRP_MN_FILTER_RESOURCE_REQUIREMENTS) failed\n"); + return Status; + } + else if (NT_SUCCESS(Status) && IoStatusBlock.Information) + { + DeviceNode->ResourceRequirements = (PIO_RESOURCE_REQUIREMENTS_LIST)IoStatusBlock.Information; + } - return STATUS_SUCCESS; + return STATUS_SUCCESS; } NTSTATUS -IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2Key) +IopUpdateResourceMap( + IN PDEVICE_NODE DeviceNode, + PWCHAR Level1Key, + PWCHAR Level2Key) { - NTSTATUS Status; - ULONG Disposition; - HANDLE PnpMgrLevel1, PnpMgrLevel2, ResourceMapKey; - UNICODE_STRING KeyName; - OBJECT_ATTRIBUTES ObjectAttributes; - - RtlInitUnicodeString(&KeyName, - L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP"); - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_KERNEL_HANDLE, - NULL, - NULL); - Status = ZwCreateKey(&ResourceMapKey, - KEY_ALL_ACCESS, - &ObjectAttributes, - 0, - NULL, - REG_OPTION_VOLATILE, - &Disposition); - if (!NT_SUCCESS(Status)) - return Status; - - RtlInitUnicodeString(&KeyName, Level1Key); - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_KERNEL_HANDLE, - ResourceMapKey, - NULL); - Status = ZwCreateKey(&PnpMgrLevel1, - KEY_ALL_ACCESS, - &ObjectAttributes, - 0, - NULL, - REG_OPTION_VOLATILE, - &Disposition); - ZwClose(ResourceMapKey); - if (!NT_SUCCESS(Status)) - return Status; - - RtlInitUnicodeString(&KeyName, Level2Key); - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_KERNEL_HANDLE, - PnpMgrLevel1, - NULL); - Status = ZwCreateKey(&PnpMgrLevel2, - KEY_ALL_ACCESS, - &ObjectAttributes, - 0, - NULL, - REG_OPTION_VOLATILE, - &Disposition); - ZwClose(PnpMgrLevel1); - if (!NT_SUCCESS(Status)) - return Status; - - if (DeviceNode->ResourceList) - { - UNICODE_STRING NameU; - UNICODE_STRING RawSuffix, TranslatedSuffix; - ULONG OldLength = 0; - - ASSERT(DeviceNode->ResourceListTranslated); - - RtlInitUnicodeString(&TranslatedSuffix, L".Translated"); - RtlInitUnicodeString(&RawSuffix, L".Raw"); - - Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject, - DevicePropertyPhysicalDeviceObjectName, - 0, - NULL, - &OldLength); - if (Status == STATUS_BUFFER_OVERFLOW || Status == STATUS_BUFFER_TOO_SMALL) - { - ASSERT(OldLength); + NTSTATUS Status; + ULONG Disposition; + HANDLE PnpMgrLevel1, PnpMgrLevel2, ResourceMapKey; + UNICODE_STRING KeyName; + OBJECT_ATTRIBUTES ObjectAttributes; + + RtlInitUnicodeString(&KeyName, + L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP"); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_KERNEL_HANDLE, + NULL, + NULL); + Status = ZwCreateKey(&ResourceMapKey, + KEY_ALL_ACCESS, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + &Disposition); + if (!NT_SUCCESS(Status)) + return Status; + + RtlInitUnicodeString(&KeyName, Level1Key); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_KERNEL_HANDLE, + ResourceMapKey, + NULL); + Status = ZwCreateKey(&PnpMgrLevel1, + KEY_ALL_ACCESS, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + &Disposition); + ZwClose(ResourceMapKey); + if (!NT_SUCCESS(Status)) + return Status; + + RtlInitUnicodeString(&KeyName, Level2Key); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_KERNEL_HANDLE, + PnpMgrLevel1, + NULL); + Status = ZwCreateKey(&PnpMgrLevel2, + KEY_ALL_ACCESS, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + &Disposition); + ZwClose(PnpMgrLevel1); + if (!NT_SUCCESS(Status)) + return Status; + + if (DeviceNode->ResourceList) + { + UNICODE_STRING NameU; + UNICODE_STRING RawSuffix, TranslatedSuffix; + ULONG OldLength = 0; - NameU.Buffer = ExAllocatePool(PagedPool, OldLength + TranslatedSuffix.Length); - if (!NameU.Buffer) - { - ZwClose(PnpMgrLevel2); - return STATUS_INSUFFICIENT_RESOURCES; - } + ASSERT(DeviceNode->ResourceListTranslated); - NameU.Length = 0; - NameU.MaximumLength = (USHORT)OldLength + TranslatedSuffix.Length; + RtlInitUnicodeString(&TranslatedSuffix, L".Translated"); + RtlInitUnicodeString(&RawSuffix, L".Raw"); - Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject, - DevicePropertyPhysicalDeviceObjectName, - NameU.MaximumLength, - NameU.Buffer, - &OldLength); - if (!NT_SUCCESS(Status)) - { - ZwClose(PnpMgrLevel2); - ExFreePool(NameU.Buffer); - return Status; - } - } - else if (!NT_SUCCESS(Status)) - { - /* Some failure */ - ZwClose(PnpMgrLevel2); - return Status; - } - else - { - /* This should never happen */ - ASSERT(FALSE); - } + Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject, + DevicePropertyPhysicalDeviceObjectName, + 0, + NULL, + &OldLength); + if (Status == STATUS_BUFFER_OVERFLOW || Status == STATUS_BUFFER_TOO_SMALL) + { + ASSERT(OldLength); - NameU.Length = (USHORT)OldLength; + NameU.Buffer = ExAllocatePool(PagedPool, OldLength + TranslatedSuffix.Length); + if (!NameU.Buffer) + { + ZwClose(PnpMgrLevel2); + return STATUS_INSUFFICIENT_RESOURCES; + } - RtlAppendUnicodeStringToString(&NameU, &RawSuffix); + NameU.Length = 0; + NameU.MaximumLength = (USHORT)OldLength + TranslatedSuffix.Length; - Status = ZwSetValueKey(PnpMgrLevel2, - &NameU, - 0, - REG_RESOURCE_LIST, - DeviceNode->ResourceList, - PnpDetermineResourceListSize(DeviceNode->ResourceList)); - if (!NT_SUCCESS(Status)) - { - ZwClose(PnpMgrLevel2); - ExFreePool(NameU.Buffer); - return Status; - } + Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject, + DevicePropertyPhysicalDeviceObjectName, + NameU.MaximumLength, + NameU.Buffer, + &OldLength); + if (!NT_SUCCESS(Status)) + { + ZwClose(PnpMgrLevel2); + ExFreePool(NameU.Buffer); + return Status; + } + } + else if (!NT_SUCCESS(Status)) + { + /* Some failure */ + ZwClose(PnpMgrLevel2); + return Status; + } + else + { + /* This should never happen */ + ASSERT(FALSE); + } - /* "Remove" the suffix by setting the length back to what it used to be */ - NameU.Length = (USHORT)OldLength; + NameU.Length = (USHORT)OldLength; - RtlAppendUnicodeStringToString(&NameU, &TranslatedSuffix); + RtlAppendUnicodeStringToString(&NameU, &RawSuffix); - Status = ZwSetValueKey(PnpMgrLevel2, - &NameU, - 0, - REG_RESOURCE_LIST, - DeviceNode->ResourceListTranslated, - PnpDetermineResourceListSize(DeviceNode->ResourceListTranslated)); - ZwClose(PnpMgrLevel2); - ExFreePool(NameU.Buffer); + Status = ZwSetValueKey(PnpMgrLevel2, + &NameU, + 0, + REG_RESOURCE_LIST, + DeviceNode->ResourceList, + PnpDetermineResourceListSize(DeviceNode->ResourceList)); + if (!NT_SUCCESS(Status)) + { + ZwClose(PnpMgrLevel2); + ExFreePool(NameU.Buffer); + return Status; + } - if (!NT_SUCCESS(Status)) - return Status; - } - else - { - ZwClose(PnpMgrLevel2); - } - - return STATUS_SUCCESS; + /* "Remove" the suffix by setting the length back to what it used to be */ + NameU.Length = (USHORT)OldLength; + + RtlAppendUnicodeStringToString(&NameU, &TranslatedSuffix); + + Status = ZwSetValueKey(PnpMgrLevel2, + &NameU, + 0, + REG_RESOURCE_LIST, + DeviceNode->ResourceListTranslated, + PnpDetermineResourceListSize(DeviceNode->ResourceListTranslated)); + ZwClose(PnpMgrLevel2); + ExFreePool(NameU.Buffer); + + if (!NT_SUCCESS(Status)) + return Status; + } + else + { + ZwClose(PnpMgrLevel2); + } + + return STATUS_SUCCESS; } NTSTATUS -IopUpdateResourceMapForPnPDevice(IN PDEVICE_NODE DeviceNode) +IopUpdateResourceMapForPnPDevice( + IN PDEVICE_NODE DeviceNode) { - return IopUpdateResourceMap(DeviceNode, L"PnP Manager", L"PnpManager"); + return IopUpdateResourceMap(DeviceNode, L"PnP Manager", L"PnpManager"); } static
4 years, 11 months
1
0
0
0
[reactos] 04/04: [LSASRV] Add parameter validation in LsapSetLogonSessionData().
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cf7981fe4e5c2cbdf62d9…
commit cf7981fe4e5c2cbdf62d93b6132085a3ad383881 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Tue Jun 18 02:27:47 2019 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Thu Jan 2 22:17:03 2020 +0100 [LSASRV] Add parameter validation in LsapSetLogonSessionData(). --- dll/win32/lsasrv/session.c | 64 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/dll/win32/lsasrv/session.c b/dll/win32/lsasrv/session.c index 2cc37bdc518..69775dba982 100644 --- a/dll/win32/lsasrv/session.c +++ b/dll/win32/lsasrv/session.c @@ -71,6 +71,7 @@ LsapSetLogonSessionData( _In_ PUNICODE_STRING LogonDomain, _In_ PSID Sid) { + NTSTATUS Status; PLSAP_LOGON_SESSION Session; ULONG Length; @@ -83,8 +84,15 @@ LsapSetLogonSessionData( TRACE("LogonType %lu\n", LogonType); Session->LogonType = LogonType; + Status = RtlValidateUnicodeString(0, UserName); + if (!NT_SUCCESS(Status)) + return STATUS_INVALID_PARAMETER; + + /* UserName is mandatory and cannot be an empty string */ TRACE("UserName %wZ\n", UserName); - Session->UserName.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, UserName->MaximumLength); + Session->UserName.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + UserName->MaximumLength); if (Session->UserName.Buffer == NULL) return STATUS_INSUFFICIENT_RESOURCES; @@ -92,19 +100,53 @@ LsapSetLogonSessionData( Session->UserName.MaximumLength = UserName->MaximumLength; RtlCopyMemory(Session->UserName.Buffer, UserName->Buffer, UserName->MaximumLength); - TRACE("LogonDomain %wZ\n", LogonDomain); - Session->LogonDomain.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, LogonDomain->MaximumLength); - if (Session->LogonDomain.Buffer == NULL) - return STATUS_INSUFFICIENT_RESOURCES; + Status = RtlValidateUnicodeString(0, LogonDomain); + if (!NT_SUCCESS(Status)) + { + /* Cleanup and fail */ + if (Session->UserName.Buffer != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, Session->UserName.Buffer); - Session->LogonDomain.Length = LogonDomain->Length; - Session->LogonDomain.MaximumLength = LogonDomain->MaximumLength; - RtlCopyMemory(Session->LogonDomain.Buffer, LogonDomain->Buffer, LogonDomain->MaximumLength); + return STATUS_INVALID_PARAMETER; + } + + /* LogonDomain is optional and can be an empty string */ + TRACE("LogonDomain %wZ\n", LogonDomain); + if (LogonDomain->Length) + { + Session->LogonDomain.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + LogonDomain->MaximumLength); + if (Session->LogonDomain.Buffer == NULL) + { + /* Cleanup and fail */ + if (Session->UserName.Buffer != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, Session->UserName.Buffer); + + return STATUS_INSUFFICIENT_RESOURCES; + } + + Session->LogonDomain.Length = LogonDomain->Length; + Session->LogonDomain.MaximumLength = LogonDomain->MaximumLength; + RtlCopyMemory(Session->LogonDomain.Buffer, LogonDomain->Buffer, LogonDomain->MaximumLength); + } + else + { + RtlInitEmptyUnicodeString(&Session->LogonDomain, NULL, 0); + } Length = RtlLengthSid(Sid); Session->Sid = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, Length); - if (Session->UserName.Buffer == NULL) + if (Session->Sid == NULL) + { + /* Cleanup and fail */ + if (Session->LogonDomain.Buffer != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, Session->LogonDomain.Buffer); + if (Session->UserName.Buffer != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, Session->UserName.Buffer); + return STATUS_INSUFFICIENT_RESOURCES; + } RtlCopyMemory(Session->Sid, Sid, Length); @@ -397,10 +439,9 @@ LsapGetLogonSessionData(IN OUT PLSA_API_MSG RequestMsg) RtlCopyLuid(&LocalSessionData->LogonId, &RequestMsg->GetLogonSessionData.Request.LogonId); - /* Copy the UserName string*/ + /* Copy the UserName string */ LocalSessionData->UserName.Length = Session->UserName.Length; LocalSessionData->UserName.MaximumLength = Session->UserName.MaximumLength; - if (Session->UserName.MaximumLength != 0) { RtlCopyMemory(Ptr, Session->UserName.Buffer, Session->UserName.MaximumLength); @@ -479,7 +520,6 @@ LsapGetLogonSessionData(IN OUT PLSA_API_MSG RequestMsg) Ptr = (PUCHAR)((ULONG_PTR)Ptr + Session->Upn.MaximumLength); } - InitializeObjectAttributes(&ObjectAttributes, NULL, 0,
4 years, 11 months
1
0
0
0
[reactos] 03/04: [MSV1_0] Extend parameter validation in LsaApLogonUserEx2() and MsvpChangePassword(); fix crash in LsaApLogonUserEx2() when LogonDomainName points to a NULL string.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8210396cb42420abc57f1…
commit 8210396cb42420abc57f121d0c278dee8fbfc671 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Tue Jun 18 02:27:08 2019 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Thu Jan 2 22:16:58 2020 +0100 [MSV1_0] Extend parameter validation in LsaApLogonUserEx2() and MsvpChangePassword(); fix crash in LsaApLogonUserEx2() when LogonDomainName points to a NULL string. --- dll/win32/msv1_0/msv1_0.c | 130 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 116 insertions(+), 14 deletions(-) diff --git a/dll/win32/msv1_0/msv1_0.c b/dll/win32/msv1_0/msv1_0.c index 39360caa38d..b7cdf46d9aa 100644 --- a/dll/win32/msv1_0/msv1_0.c +++ b/dll/win32/msv1_0/msv1_0.c @@ -496,6 +496,7 @@ MsvpChangePassword(IN PLSA_CLIENT_REQUEST ClientRequest, OUT PULONG ReturnBufferLength, OUT PNTSTATUS ProtocolStatus) { + NTSTATUS Status; PMSV1_0_CHANGEPASSWORD_REQUEST RequestBuffer; ULONG_PTR PtrOffset; @@ -506,7 +507,6 @@ MsvpChangePassword(IN PLSA_CLIENT_REQUEST ClientRequest, RPC_UNICODE_STRING Names[1]; SAMPR_ULONG_ARRAY RelativeIds = {0, NULL}; SAMPR_ULONG_ARRAY Use = {0, NULL}; - NTSTATUS Status; ENCRYPTED_NT_OWF_PASSWORD OldNtPassword; ENCRYPTED_NT_OWF_PASSWORD NewNtPassword; @@ -524,17 +524,48 @@ MsvpChangePassword(IN PLSA_CLIENT_REQUEST ClientRequest, PENCRYPTED_LM_OWF_PASSWORD pOldLmEncryptedWithNewLm = NULL; PENCRYPTED_LM_OWF_PASSWORD pNewLmEncryptedWithOldLm = NULL; - TRACE("()\n"); + TRACE("MsvpChangePassword()\n"); + + /* Parameters validation */ + + if (SubmitBufferLength < sizeof(MSV1_0_CHANGEPASSWORD_REQUEST)) + { + ERR("Invalid SubmitBufferLength %lu\n", SubmitBufferLength); + return STATUS_INVALID_PARAMETER; + } RequestBuffer = (PMSV1_0_CHANGEPASSWORD_REQUEST)ProtocolSubmitBuffer; /* Fix-up pointers in the request buffer info */ PtrOffset = (ULONG_PTR)ProtocolSubmitBuffer - (ULONG_PTR)ClientBufferBase; + Status = RtlValidateUnicodeString(0, &RequestBuffer->DomainName); + if (!NT_SUCCESS(Status)) + return STATUS_INVALID_PARAMETER; + // TODO: Check for Buffer limits wrt. ClientBufferBase and alignment. RequestBuffer->DomainName.Buffer = FIXUP_POINTER(RequestBuffer->DomainName.Buffer, PtrOffset); + RequestBuffer->DomainName.MaximumLength = RequestBuffer->DomainName.Length; + + Status = RtlValidateUnicodeString(0, &RequestBuffer->AccountName); + if (!NT_SUCCESS(Status)) + return STATUS_INVALID_PARAMETER; + // TODO: Check for Buffer limits wrt. ClientBufferBase and alignment. RequestBuffer->AccountName.Buffer = FIXUP_POINTER(RequestBuffer->AccountName.Buffer, PtrOffset); + RequestBuffer->AccountName.MaximumLength = RequestBuffer->AccountName.Length; + + Status = RtlValidateUnicodeString(0, &RequestBuffer->OldPassword); + if (!NT_SUCCESS(Status)) + return STATUS_INVALID_PARAMETER; + // TODO: Check for Buffer limits wrt. ClientBufferBase and alignment. RequestBuffer->OldPassword.Buffer = FIXUP_POINTER(RequestBuffer->OldPassword.Buffer, PtrOffset); + RequestBuffer->OldPassword.MaximumLength = RequestBuffer->OldPassword.Length; + + Status = RtlValidateUnicodeString(0, &RequestBuffer->NewPassword); + if (!NT_SUCCESS(Status)) + return STATUS_INVALID_PARAMETER; + // TODO: Check for Buffer limits wrt. ClientBufferBase and alignment. RequestBuffer->NewPassword.Buffer = FIXUP_POINTER(RequestBuffer->NewPassword.Buffer, PtrOffset); + RequestBuffer->NewPassword.MaximumLength = RequestBuffer->NewPassword.Length; TRACE("Domain: %S\n", RequestBuffer->DomainName.Buffer); TRACE("Account: %S\n", RequestBuffer->AccountName.Buffer); @@ -942,15 +973,15 @@ LsaApCallPackage(IN PLSA_CLIENT_REQUEST ClientRequest, OUT PULONG ReturnBufferLength, OUT PNTSTATUS ProtocolStatus) { - ULONG MessageType; NTSTATUS Status; + MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType; TRACE("LsaApCallPackage()\n"); if (SubmitBufferLength < sizeof(MSV1_0_PROTOCOL_MESSAGE_TYPE)) return STATUS_INVALID_PARAMETER; - MessageType = (ULONG)*((PMSV1_0_PROTOCOL_MESSAGE_TYPE)ProtocolSubmitBuffer); + MessageType = *((PMSV1_0_PROTOCOL_MESSAGE_TYPE)ProtocolSubmitBuffer); *ProtocolReturnBuffer = NULL; *ReturnBufferLength = 0; @@ -1140,6 +1171,11 @@ LsaApLogonUserEx2(IN PLSA_CLIENT_REQUEST ClientRequest, OUT PSECPKG_PRIMARY_CRED PrimaryCredentials, /* Not supported yet */ OUT PSECPKG_SUPPLEMENTAL_CRED_ARRAY *SupplementalCredentials) /* Not supported yet */ { + static const UNICODE_STRING NtAuthorityU = RTL_CONSTANT_STRING(L"NT AUTHORITY"); + static const UNICODE_STRING LocalServiceU = RTL_CONSTANT_STRING(L"LocalService"); + static const UNICODE_STRING NetworkServiceU = RTL_CONSTANT_STRING(L"NetworkService"); + + NTSTATUS Status; PMSV1_0_INTERACTIVE_LOGON LogonInfo; WCHAR ComputerName[MAX_COMPUTERNAME_LENGTH + 1]; SAMPR_HANDLE ServerHandle = NULL; @@ -1157,9 +1193,8 @@ LsaApLogonUserEx2(IN PLSA_CLIENT_REQUEST ClientRequest, LARGE_INTEGER PasswordLastSet; DWORD ComputerNameSize; BOOL SpecialAccount = FALSE; - NTSTATUS Status; - TRACE("LsaApLogonUser()\n"); + TRACE("LsaApLogonUserEx2()\n"); TRACE("LogonType: %lu\n", LogonType); TRACE("ProtocolSubmitBuffer: %p\n", ProtocolSubmitBuffer); @@ -1171,40 +1206,107 @@ LsaApLogonUserEx2(IN PLSA_CLIENT_REQUEST ClientRequest, *AccountName = NULL; *AuthenticatingAuthority = NULL; + /* Parameters validation */ if (LogonType == Interactive || LogonType == Batch || LogonType == Service) { ULONG_PTR PtrOffset; + if (SubmitBufferSize < sizeof(MSV1_0_INTERACTIVE_LOGON)) + { + ERR("Invalid SubmitBufferSize %lu\n", SubmitBufferSize); + return STATUS_INVALID_PARAMETER; + } + LogonInfo = (PMSV1_0_INTERACTIVE_LOGON)ProtocolSubmitBuffer; + if (LogonInfo->MessageType != MsV1_0InteractiveLogon && + LogonInfo->MessageType != MsV1_0WorkstationUnlockLogon) + { + ERR("Invalid MessageType %lu\n", LogonInfo->MessageType); + return STATUS_BAD_VALIDATION_CLASS; + } + +#if 0 // FIXME: These checks happen to be done on Windows. We however keep them general on ReactOS for now... + if (LogonInfo->UserName.Length > 512) // CRED_MAX_STRING_LENGTH * sizeof(WCHAR) or (CREDUI_MAX_USERNAME_LENGTH (== CRED_MAX_USERNAME_LENGTH) - 1) * sizeof(WCHAR) + { + ERR("UserName too long (%lu, maximum 512)\n", LogonInfo->UserName.Length); + return STATUS_NAME_TOO_LONG; + } + if (LogonInfo->Password.Length > 512) // CREDUI_MAX_PASSWORD_LENGTH * sizeof(WCHAR) + { + ERR("Password too long (%lu, maximum 512)\n", LogonInfo->Password.Length); + return STATUS_NAME_TOO_LONG; + } +#endif + /* Fix-up pointers in the authentication info */ PtrOffset = (ULONG_PTR)ProtocolSubmitBuffer - (ULONG_PTR)ClientBufferBase; - LogonInfo->LogonDomainName.Buffer = FIXUP_POINTER(LogonInfo->LogonDomainName.Buffer, PtrOffset); + Status = RtlValidateUnicodeString(0, &LogonInfo->LogonDomainName); + if (!NT_SUCCESS(Status)) + return STATUS_INVALID_PARAMETER; + /* LogonDomainName is optional and can be an empty string */ + if (LogonInfo->LogonDomainName.Length) + { + // TODO: Check for Buffer limits wrt. ClientBufferBase and alignment. + LogonInfo->LogonDomainName.Buffer = FIXUP_POINTER(LogonInfo->LogonDomainName.Buffer, PtrOffset); + LogonInfo->LogonDomainName.MaximumLength = LogonInfo->LogonDomainName.Length; + } + else + { + LogonInfo->LogonDomainName.Buffer = NULL; + LogonInfo->LogonDomainName.MaximumLength = 0; + } + + Status = RtlValidateUnicodeString(0, &LogonInfo->UserName); + if (!NT_SUCCESS(Status)) + return STATUS_INVALID_PARAMETER; + /* UserName is mandatory and cannot be an empty string */ + // TODO: Check for Buffer limits wrt. ClientBufferBase and alignment. LogonInfo->UserName.Buffer = FIXUP_POINTER(LogonInfo->UserName.Buffer, PtrOffset); - LogonInfo->Password.Buffer = FIXUP_POINTER(LogonInfo->Password.Buffer, PtrOffset); + LogonInfo->UserName.MaximumLength = LogonInfo->UserName.Length; + + Status = RtlValidateUnicodeString(0, &LogonInfo->Password); + if (!NT_SUCCESS(Status)) + return STATUS_INVALID_PARAMETER; + /* Password is optional and can be an empty string */ + if (LogonInfo->Password.Length) + { + // TODO: Check for Buffer limits wrt. ClientBufferBase and alignment. + LogonInfo->Password.Buffer = FIXUP_POINTER(LogonInfo->Password.Buffer, PtrOffset); + LogonInfo->Password.MaximumLength = LogonInfo->Password.Length; + } + else + { + LogonInfo->Password.Buffer = NULL; + LogonInfo->Password.MaximumLength = 0; + } TRACE("Domain: %S\n", LogonInfo->LogonDomainName.Buffer); TRACE("User: %S\n", LogonInfo->UserName.Buffer); TRACE("Password: %S\n", LogonInfo->Password.Buffer); + + // TODO: If LogonType == Service, do some extra work using LogonInfo->Password. } else { FIXME("LogonType %lu is not supported yet!\n", LogonType); return STATUS_NOT_IMPLEMENTED; } + // TODO: Add other LogonType validity checks. /* Get the logon time */ NtQuerySystemTime(&LogonTime); /* Get the computer name */ - ComputerNameSize = MAX_COMPUTERNAME_LENGTH + 1; + ComputerNameSize = ARRAYSIZE(ComputerName); GetComputerNameW(ComputerName, &ComputerNameSize); /* Check for special accounts */ - if (_wcsicmp(LogonInfo->LogonDomainName.Buffer, L"NT AUTHORITY") == 0) + // FIXME: Windows does not do this that way!! (msv1_0 does not contain these hardcoded values) + if (RtlEqualUnicodeString(&LogonInfo->LogonDomainName, &NtAuthorityU, TRUE)) { SpecialAccount = TRUE; @@ -1216,7 +1318,7 @@ LsaApLogonUserEx2(IN PLSA_CLIENT_REQUEST ClientRequest, return Status; } - if (_wcsicmp(LogonInfo->UserName.Buffer, L"LocalService") == 0) + if (RtlEqualUnicodeString(&LogonInfo->UserName, &LocalServiceU, TRUE)) { TRACE("SpecialAccount: LocalService\n"); @@ -1235,7 +1337,7 @@ LsaApLogonUserEx2(IN PLSA_CLIENT_REQUEST ClientRequest, UserInfo->All.UserId = SECURITY_LOCAL_SERVICE_RID; UserInfo->All.PrimaryGroupId = SECURITY_LOCAL_SERVICE_RID; } - else if (_wcsicmp(LogonInfo->UserName.Buffer, L"NetworkService") == 0) + else if (RtlEqualUnicodeString(&LogonInfo->UserName, &NetworkServiceU, TRUE)) { TRACE("SpecialAccount: NetworkService\n"); @@ -1345,7 +1447,7 @@ LsaApLogonUserEx2(IN PLSA_CLIENT_REQUEST ClientRequest, /* Check the password */ if ((UserInfo->All.UserAccountControl & USER_PASSWORD_NOT_REQUIRED) == 0) { - Status = MsvpCheckPassword(&(LogonInfo->Password), + Status = MsvpCheckPassword(&LogonInfo->Password, UserInfo); if (!NT_SUCCESS(Status)) { @@ -1567,7 +1669,7 @@ done: Status = STATUS_LOGON_FAILURE; } - TRACE("LsaApLogonUser done (Status 0x%08lx SubStatus 0x%08lx)\n", Status, *SubStatus); + TRACE("LsaApLogonUserEx2 done (Status 0x%08lx, SubStatus 0x%08lx)\n", Status, *SubStatus); return Status; }
4 years, 11 months
1
0
0
0
[reactos] 02/04: [RTL] Fix RtlValidateUnicodeString() regarding the tests and add some SAL annotations.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=127fa1afc6c7fa6a264ce…
commit 127fa1afc6c7fa6a264ce0eb442e8a7523a8327f Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Thu Jan 2 21:10:42 2020 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Thu Jan 2 21:11:28 2020 +0100 [RTL] Fix RtlValidateUnicodeString() regarding the tests and add some SAL annotations. --- sdk/lib/rtl/unicode.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/sdk/lib/rtl/unicode.c b/sdk/lib/rtl/unicode.c index 7d2470a9591..7f045401326 100644 --- a/sdk/lib/rtl/unicode.c +++ b/sdk/lib/rtl/unicode.c @@ -2541,22 +2541,24 @@ RtlDuplicateUnicodeString( */ NTSTATUS NTAPI -RtlValidateUnicodeString(IN ULONG Flags, - IN PCUNICODE_STRING UnicodeString) +RtlValidateUnicodeString( + _In_ ULONG Flags, + _In_ PCUNICODE_STRING String) { - /* currently no flags are supported! */ - ASSERT(Flags == 0); - - if ((Flags == 0) && - ((UnicodeString == NULL) || - ((UnicodeString->Length != 0) && - (UnicodeString->Buffer != NULL) && - ((UnicodeString->Length % sizeof(WCHAR)) == 0) && - ((UnicodeString->MaximumLength % sizeof(WCHAR)) == 0) && - (UnicodeString->MaximumLength >= UnicodeString->Length)))) - { - /* a NULL pointer as a unicode string is considered to be a valid unicode - string! */ + /* In Windows <= 2003 no flags are supported yet! */ + if (Flags != 0) + return STATUS_INVALID_PARAMETER; + + /* NOTE: a NULL Unicode string pointer is considered to be a valid one! */ + if (String == NULL) + { + return STATUS_SUCCESS; + } + else if (!((String->Buffer == NULL) && (String->Length != 0 || String->MaximumLength != 0)) && + (String->Length % sizeof(WCHAR) == 0) && + (String->MaximumLength % sizeof(WCHAR) == 0) && + (String->Length <= String->MaximumLength)) + { return STATUS_SUCCESS; } else
4 years, 11 months
1
0
0
0
[reactos] 01/04: [NTDLL_APITEST] Add a test for RtlValidateUnicodeString().
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ae8c9a1fa2246b2d5b2c5…
commit ae8c9a1fa2246b2d5b2c583da413183c51e79b40 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Thu Jan 2 21:09:32 2020 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Thu Jan 2 21:11:27 2020 +0100 [NTDLL_APITEST] Add a test for RtlValidateUnicodeString(). --- modules/rostests/apitests/ntdll/CMakeLists.txt | 1 + .../apitests/ntdll/RtlValidateUnicodeString.c | 105 +++++++++++++++++++++ modules/rostests/apitests/ntdll/testlist.c | 2 + 3 files changed, 108 insertions(+) diff --git a/modules/rostests/apitests/ntdll/CMakeLists.txt b/modules/rostests/apitests/ntdll/CMakeLists.txt index 0cce35587ed..64b147bdeec 100644 --- a/modules/rostests/apitests/ntdll/CMakeLists.txt +++ b/modules/rostests/apitests/ntdll/CMakeLists.txt @@ -65,6 +65,7 @@ list(APPEND SOURCE RtlReAllocateHeap.c RtlUnicodeStringToAnsiString.c RtlUpcaseUnicodeStringToCountedOemString.c + RtlValidateUnicodeString.c StackOverflow.c SystemInfo.c Timer.c diff --git a/modules/rostests/apitests/ntdll/RtlValidateUnicodeString.c b/modules/rostests/apitests/ntdll/RtlValidateUnicodeString.c new file mode 100644 index 00000000000..8c900613d0e --- /dev/null +++ b/modules/rostests/apitests/ntdll/RtlValidateUnicodeString.c @@ -0,0 +1,105 @@ +/* + * PROJECT: ReactOS API Tests + * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) + * PURPOSE: Test for RtlValidateUnicodeString + * COPYRIGHT: Copyright 2020 Hermes Belusca-Maito + */ + +#include "precomp.h" + +START_TEST(RtlValidateUnicodeString) +{ + NTSTATUS Status; + UNICODE_STRING String; + UNICODE_STRING ValidString = RTL_CONSTANT_STRING(L"My Wild String!"); + + /* Start with a valid Unicode string */ + String = ValidString; + + /* Non-zero flags are unsupported! */ + Status = RtlValidateUnicodeString(0, &String); + ok(Status == STATUS_SUCCESS, "Status = 0x%lx\n", Status); + Status = RtlValidateUnicodeString(1, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + Status = RtlValidateUnicodeString(0xdeadbeef, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + + /* Empty string is allowed. Test also the flags. */ + RtlInitEmptyUnicodeString(&String, NULL, 0); + Status = RtlValidateUnicodeString(0, &String); + ok(Status == STATUS_SUCCESS, "Status = 0x%lx\n", Status); + Status = RtlValidateUnicodeString(1, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + Status = RtlValidateUnicodeString(0xdeadbeef, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + + // With a non-NULL but empty buffer, and zero lengths. + String.Buffer = L""; + Status = RtlValidateUnicodeString(0, &String); + ok(Status == STATUS_SUCCESS, "Status = 0x%lx\n", Status); + Status = RtlValidateUnicodeString(1, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + Status = RtlValidateUnicodeString(0xdeadbeef, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + + // With a non-NULL but empty buffer, and zero Length, non-zero MaximumLength. + String.Buffer = L""; + String.Length = 0; + Status = RtlValidateUnicodeString(0, &String); + ok(Status == STATUS_SUCCESS, "Status = 0x%lx\n", Status); + Status = RtlValidateUnicodeString(1, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + Status = RtlValidateUnicodeString(0xdeadbeef, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + + /* NULL pointer is also allowed! Test also the flags. */ + Status = RtlValidateUnicodeString(0, NULL); + ok(Status == STATUS_SUCCESS, "Status = 0x%lx\n", Status); + Status = RtlValidateUnicodeString(1, NULL); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + Status = RtlValidateUnicodeString(0xdeadbeef, NULL); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + + + /* + * Now test invalid strings. + */ + + // NULL buffer but non-zero lengths. + String = ValidString; + String.Buffer = NULL; + Status = RtlValidateUnicodeString(0, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + + // NULL buffer, zero Length, non-zero MaximumLength. + String = ValidString; + String.Buffer = NULL; + String.Length = 0; + Status = RtlValidateUnicodeString(0, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + + // NULL buffer, non-zero Length, zero MaximumLength. + String = ValidString; + String.Buffer = NULL; + String.MaximumLength = 0; + Status = RtlValidateUnicodeString(0, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + + // Non-NULL buffer, non-zero Length, zero MaximumLength. + String = ValidString; + String.MaximumLength = 0; + Status = RtlValidateUnicodeString(0, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + + /* Non-NULL buffer, odd lengths */ + + String = ValidString; + String.Length--; // Length was already >= 2 so it remains > 0. + Status = RtlValidateUnicodeString(0, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); + + String = ValidString; + String.MaximumLength--; // MaximumLength was already >= 2 so it remains > 0. + Status = RtlValidateUnicodeString(0, &String); + ok(Status == STATUS_INVALID_PARAMETER, "Status = 0x%lx\n", Status); +} diff --git a/modules/rostests/apitests/ntdll/testlist.c b/modules/rostests/apitests/ntdll/testlist.c index 9359f36808b..7624c3c23af 100644 --- a/modules/rostests/apitests/ntdll/testlist.c +++ b/modules/rostests/apitests/ntdll/testlist.c @@ -64,6 +64,7 @@ extern void func_RtlQueryTimeZoneInformation(void); extern void func_RtlReAllocateHeap(void); extern void func_RtlUnicodeStringToAnsiString(void); extern void func_RtlUpcaseUnicodeStringToCountedOemString(void); +extern void func_RtlValidateUnicodeString(void); extern void func_StackOverflow(void); extern void func_TimerResolution(void); @@ -130,6 +131,7 @@ const struct test winetest_testlist[] = { "RtlReAllocateHeap", func_RtlReAllocateHeap }, { "RtlUnicodeStringToAnsiString", func_RtlUnicodeStringToAnsiString }, { "RtlUpcaseUnicodeStringToCountedOemString", func_RtlUpcaseUnicodeStringToCountedOemString }, + { "RtlValidateUnicodeString", func_RtlValidateUnicodeString }, { "StackOverflow", func_StackOverflow }, { "TimerResolution", func_TimerResolution },
4 years, 11 months
1
0
0
0
[reactos] 01/01: [DISK_NEW] Return correct info size in failure case of DiskIoctlGetPartitionInfoEx.
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0d745e0698846e01eee65…
commit 0d745e0698846e01eee65f5e7f567cd83d4c1178 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Thu Jan 2 16:26:50 2020 +0100 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Thu Jan 2 16:36:15 2020 +0100 [DISK_NEW] Return correct info size in failure case of DiskIoctlGetPartitionInfoEx. --- drivers/storage/class/disk_new/disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/storage/class/disk_new/disk.c b/drivers/storage/class/disk_new/disk.c index 3e3ec30f74f..1aad80609a1 100644 --- a/drivers/storage/class/disk_new/disk.c +++ b/drivers/storage/class/disk_new/disk.c @@ -6053,7 +6053,7 @@ DiskIoctlGetPartitionInfoEx( status = STATUS_BUFFER_TOO_SMALL; Irp->IoStatus.Status = status; - Irp->IoStatus.Information = sizeof(PARTITION_INFORMATION); + Irp->IoStatus.Information = sizeof(PARTITION_INFORMATION_EX); return status; }
4 years, 11 months
1
0
0
0
[reactos] 01/01: [CDROM] Return the correct data length for IOCTL_DISK_GET_LENGTH_INFO. CORE-16607
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2fa7b1dcc1ddd8a9cf857…
commit 2fa7b1dcc1ddd8a9cf857286685c5e317119dfc2 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Thu Jan 2 13:27:19 2020 +0100 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Thu Jan 2 14:08:46 2020 +0100 [CDROM] Return the correct data length for IOCTL_DISK_GET_LENGTH_INFO. CORE-16607 --- drivers/storage/class/cdrom/cdrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/storage/class/cdrom/cdrom.c b/drivers/storage/class/cdrom/cdrom.c index 220eb1fcf4f..2794e62f2ea 100644 --- a/drivers/storage/class/cdrom/cdrom.c +++ b/drivers/storage/class/cdrom/cdrom.c @@ -3287,7 +3287,7 @@ CdRomDeviceControlCompletion( // update information field. // - realIrp->IoStatus.Information = sizeof(DISK_GEOMETRY); + realIrp->IoStatus.Information = sizeof(GET_LENGTH_INFORMATION); break; }
4 years, 11 months
1
0
0
0
[reactos] 01/01: [SHELL32] Fix extra fixme (#1975)
by Maxim Smirnov
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=06eb8cda99ed5a16b387e…
commit 06eb8cda99ed5a16b387e3c12e798de9a3954a39 Author: Maxim Smirnov <Maxim.like.Python(a)ya.ru> AuthorDate: Thu Jan 2 15:35:32 2020 +0300 Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> CommitDate: Thu Jan 2 13:35:32 2020 +0100 [SHELL32] Fix extra fixme (#1975) This patch removes this line from the log: `fixme:(dll\win32\shell32\shlexec.cpp:1810) flags ignored: 0x00000004` --- dll/win32/shell32/shlexec.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dll/win32/shell32/shlexec.cpp b/dll/win32/shell32/shlexec.cpp index 049426dd7da..099a964c93e 100644 --- a/dll/win32/shell32/shlexec.cpp +++ b/dll/win32/shell32/shlexec.cpp @@ -1845,7 +1845,11 @@ static BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc) if (sei_tmp.fMask & unsupportedFlags) { - FIXME("flags ignored: 0x%08x\n", sei_tmp.fMask & unsupportedFlags); + // SEE_MASK_IDLIST is not in unsupportedFlags, but the check above passes because SEE_MASK_INVOKEIDLIST is in it + if ((sei_tmp.fMask & unsupportedFlags) != SEE_MASK_IDLIST) + { + FIXME("flags ignored: 0x%08x\n", sei_tmp.fMask & unsupportedFlags); + } } /* process the IDList */
4 years, 11 months
1
0
0
0
← Newer
1
...
9
10
11
12
13
14
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Results per page:
10
25
50
100
200