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
November 2011
----- 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
16 participants
274 discussions
Start a n
N
ew thread
[fireball] 54434: [RTL/HEAP] - Bring more awesomeness to the heap manager by zefklop's request: * Add support for settable user values and flags in RtlAllocateHeap and RtlReAllocateHeap. * Return e...
by fireball@svn.reactos.org
Author: fireball Date: Sat Nov 19 11:02:24 2011 New Revision: 54434 URL:
http://svn.reactos.org/svn/reactos?rev=54434&view=rev
Log: [RTL/HEAP] - Bring more awesomeness to the heap manager by zefklop's request: * Add support for settable user values and flags in RtlAllocateHeap and RtlReAllocateHeap. * Return error if RtlSetUserValueHeap was unable to set the value. * Fixes remaining 2 failures of the kernel32_winetest alloc test. Modified: trunk/reactos/lib/rtl/heap.c trunk/reactos/lib/rtl/heap.h Modified: trunk/reactos/lib/rtl/heap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap.c?rev=54434&r…
============================================================================== --- trunk/reactos/lib/rtl/heap.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/heap.c [iso-8859-1] Sat Nov 19 11:02:24 2011 @@ -1722,15 +1722,31 @@ PHEAP_ENTRY NTAPI RtlpSplitEntry(PHEAP Heap, + ULONG Flags, PHEAP_FREE_ENTRY FreeBlock, SIZE_T AllocationSize, SIZE_T Index, SIZE_T Size) { PHEAP_FREE_ENTRY SplitBlock, SplitBlock2; - UCHAR FreeFlags; + UCHAR FreeFlags, EntryFlags = HEAP_ENTRY_BUSY; PHEAP_ENTRY InUseEntry; SIZE_T FreeSize; + + /* Add extra flags in case of settable user value feature is requested, + or there is a tag (small or normal) or there is a request to + capture stack backtraces */ + if ((Flags & HEAP_EXTRA_FLAGS_MASK) || + Heap->PseudoTagEntries) + { + /* Add flag which means that the entry will have extra stuff attached */ + EntryFlags |= HEAP_ENTRY_EXTRA_PRESENT; + + /* NB! AllocationSize is already adjusted by RtlAllocateHeap */ + } + + /* Add settable user flags, if any */ + EntryFlags |= (Flags & HEAP_SETTABLE_USER_FLAGS) >> 4; /* Save flags, update total free size */ FreeFlags = FreeBlock->Flags; @@ -1738,7 +1754,7 @@ /* Make this block an in-use one */ InUseEntry = (PHEAP_ENTRY)FreeBlock; - InUseEntry->Flags = HEAP_ENTRY_BUSY; + InUseEntry->Flags = EntryFlags; InUseEntry->SmallTagIndex = 0; /* Calculate the extra amount */ @@ -1877,7 +1893,7 @@ RemoveEntryList(&FreeBlock->FreeList); /* Split it */ - InUseEntry = RtlpSplitEntry(Heap, FreeBlock, AllocationSize, Index, Size); + InUseEntry = RtlpSplitEntry(Heap, Flags, FreeBlock, AllocationSize, Index, Size); /* Release the lock */ if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); @@ -1926,7 +1942,7 @@ RemoveEntryList(&FreeBlock->FreeList); /* Split it */ - InUseEntry = RtlpSplitEntry(Heap, FreeBlock, AllocationSize, Index, Size); + InUseEntry = RtlpSplitEntry(Heap, Flags, FreeBlock, AllocationSize, Index, Size); /* Release the lock */ if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); @@ -2003,7 +2019,7 @@ PLIST_ENTRY FreeListHead; PHEAP_ENTRY InUseEntry; PHEAP_FREE_ENTRY FreeBlock; - UCHAR FreeFlags; + UCHAR FreeFlags, EntryFlags = HEAP_ENTRY_BUSY; EXCEPTION_RECORD ExceptionRecord; BOOLEAN HeapLocked = FALSE; PHEAP_VIRTUAL_ALLOC_ENTRY VirtualBlock = NULL; @@ -2039,6 +2055,23 @@ else AllocationSize = 1; AllocationSize = (AllocationSize + Heap->AlignRound) & Heap->AlignMask; + + /* Add extra flags in case of settable user value feature is requested, + or there is a tag (small or normal) or there is a request to + capture stack backtraces */ + if ((Flags & HEAP_EXTRA_FLAGS_MASK) || + Heap->PseudoTagEntries) + { + /* Add flag which means that the entry will have extra stuff attached */ + EntryFlags |= HEAP_ENTRY_EXTRA_PRESENT; + + /* Account for extra stuff size */ + AllocationSize += sizeof(HEAP_ENTRY_EXTRA); + } + + /* Add settable user flags, if any */ + EntryFlags |= (Flags & HEAP_SETTABLE_USER_FLAGS) >> 4; + Index = AllocationSize >> HEAP_ENTRY_SHIFT; /* Acquire the lock if necessary */ @@ -2070,7 +2103,7 @@ /* Initialize this block */ InUseEntry = (PHEAP_ENTRY)FreeBlock; - InUseEntry->Flags = HEAP_ENTRY_BUSY | (FreeFlags & HEAP_ENTRY_LAST_ENTRY); + InUseEntry->Flags = EntryFlags | (FreeFlags & HEAP_ENTRY_LAST_ENTRY); InUseEntry->UnusedBytes = (UCHAR)(AllocationSize - Size); InUseEntry->SmallTagIndex = 0; } @@ -2113,7 +2146,7 @@ RtlpRemoveFreeBlock(Heap, FreeBlock, TRUE, FALSE); /* Split it */ - InUseEntry = RtlpSplitEntry(Heap, FreeBlock, AllocationSize, Index, Size); + InUseEntry = RtlpSplitEntry(Heap, Flags, FreeBlock, AllocationSize, Index, Size); } /* Release the lock */ @@ -2175,7 +2208,7 @@ /* Initialize the newly allocated block */ VirtualBlock->BusyBlock.Size = (USHORT)(AllocationSize - Size); - VirtualBlock->BusyBlock.Flags = HEAP_ENTRY_VIRTUAL_ALLOC | HEAP_ENTRY_EXTRA_PRESENT | HEAP_ENTRY_BUSY; + VirtualBlock->BusyBlock.Flags = EntryFlags | HEAP_ENTRY_VIRTUAL_ALLOC | HEAP_ENTRY_EXTRA_PRESENT; VirtualBlock->CommitSize = AllocationSize; VirtualBlock->ReserveSize = AllocationSize; @@ -2536,41 +2569,41 @@ } } + /* Properly "zero out" (and fill!) the space */ + if (Flags & HEAP_ZERO_MEMORY) + { + RtlZeroMemory((PCHAR)(InUseEntry + 1) + PrevSize, Size - PrevSize); + } + else if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) + { + /* Calculate tail part which we need to fill */ + TailPart = PrevSize & (sizeof(ULONG) - 1); + + /* "Invert" it as usual */ + if (TailPart) TailPart = 4 - TailPart; + + if (Size > (PrevSize + TailPart)) + AddedSize = (Size - (PrevSize + TailPart)) & ~(sizeof(ULONG) - 1); + + if (AddedSize) + { + RtlFillMemoryUlong((PCHAR)(InUseEntry + 1) + PrevSize + TailPart, + AddedSize, + ARENA_INUSE_FILLER); + } + } + + /* Fill the new tail */ + if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) + { + RtlFillMemory((PCHAR)(InUseEntry + 1) + Size, + HEAP_ENTRY_SIZE, + HEAP_TAIL_FILL); + } + /* Copy user settable flags */ InUseEntry->Flags &= ~HEAP_ENTRY_SETTABLE_FLAGS; InUseEntry->Flags |= ((Flags & HEAP_SETTABLE_USER_FLAGS) >> 4); - - /* Properly "zero out" (and fill!) the space */ - if (Flags & HEAP_ZERO_MEMORY) - { - RtlZeroMemory((PCHAR)(InUseEntry + 1) + PrevSize, Size - PrevSize); - } - else if (Heap->Flags & HEAP_FREE_CHECKING_ENABLED) - { - /* Calculate tail part which we need to fill */ - TailPart = PrevSize & (sizeof(ULONG) - 1); - - /* "Invert" it as usual */ - if (TailPart) TailPart = 4 - TailPart; - - if (Size > (PrevSize + TailPart)) - AddedSize = (Size - (PrevSize + TailPart)) & ~(sizeof(ULONG) - 1); - - if (AddedSize) - { - RtlFillMemoryUlong((PCHAR)(InUseEntry + 1) + PrevSize + TailPart, - AddedSize, - ARENA_INUSE_FILLER); - } - } - - /* Fill the new tail */ - if (Heap->Flags & HEAP_TAIL_CHECKING_ENABLED) - { - RtlFillMemory((PCHAR)(InUseEntry + 1) + Size, - HEAP_ENTRY_SIZE, - HEAP_TAIL_FILL); - } /* Return success */ return TRUE; @@ -3728,7 +3761,7 @@ PHEAP Heap = (PHEAP)HeapHandle; PHEAP_ENTRY HeapEntry; PHEAP_ENTRY_EXTRA Extra; - BOOLEAN HeapLocked = FALSE; + BOOLEAN HeapLocked = FALSE, ValueSet = FALSE; /* Force flags */ Flags |= Heap->Flags; @@ -3765,13 +3798,16 @@ /* Use extra to store the value */ Extra = RtlpGetExtraStuffPointer(HeapEntry); Extra->Settable = (ULONG_PTR)UserValue; + + /* Indicate that value was set */ + ValueSet = TRUE; } /* Release the heap lock if it was acquired */ if (HeapLocked) RtlLeaveHeapLock(Heap->LockVariable); - return TRUE; + return ValueSet; } /* Modified: trunk/reactos/lib/rtl/heap.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap.h?rev=54434&r…
============================================================================== --- trunk/reactos/lib/rtl/heap.h [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/heap.h [iso-8859-1] Sat Nov 19 11:02:24 2011 @@ -31,10 +31,11 @@ #define HEAP_GLOBAL_TAG 0x0800 #define HEAP_PSEUDO_TAG_FLAG 0x8000 #define HEAP_TAG_MASK (HEAP_MAXIMUM_TAG << HEAP_TAG_SHIFT) +#define HEAP_TAGS_MASK (HEAP_TAG_MASK ^ (0xFF << HEAP_TAG_SHIFT)) #define HEAP_EXTRA_FLAGS_MASK (HEAP_CAPTURE_STACK_BACKTRACES | \ HEAP_SETTABLE_USER_VALUE | \ - (HEAP_TAG_MASK ^ (0xFF << HEAP_TAG_SHIFT))) + HEAP_TAGS_MASK) /* Heap entry flags */ #define HEAP_ENTRY_BUSY 0x01
13 years, 1 month
1
0
0
0
[pschweitzer] 54433: [CRT] _fpclass never returns SNaN class, but only QNaN class. This fixes 4 more tests
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Sat Nov 19 10:49:11 2011 New Revision: 54433 URL:
http://svn.reactos.org/svn/reactos?rev=54433&view=rev
Log: [CRT] _fpclass never returns SNaN class, but only QNaN class. This fixes 4 more tests Modified: trunk/reactos/lib/sdk/crt/float/fpclass.c Modified: trunk/reactos/lib/sdk/crt/float/fpclass.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/float/fpclass.…
============================================================================== --- trunk/reactos/lib/sdk/crt/float/fpclass.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/float/fpclass.c [iso-8859-1] Sat Nov 19 10:49:11 2011 @@ -48,5 +48,5 @@ return _FPCLASS_QNAN; } } - return _FPCLASS_SNAN; + return _FPCLASS_QNAN; }
13 years, 1 month
1
0
0
0
[pschweitzer] 54432: [CRT] Fix _fpclass prototype Fix headers included Remove internal defines that were useless and even not matching real defines. This fixes 4 tests
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Sat Nov 19 10:39:58 2011 New Revision: 54432 URL:
http://svn.reactos.org/svn/reactos?rev=54432&view=rev
Log: [CRT] Fix _fpclass prototype Fix headers included Remove internal defines that were useless and even not matching real defines. This fixes 4 tests Modified: trunk/reactos/lib/sdk/crt/float/fpclass.c Modified: trunk/reactos/lib/sdk/crt/float/fpclass.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/float/fpclass.…
============================================================================== --- trunk/reactos/lib/sdk/crt/float/fpclass.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/float/fpclass.c [iso-8859-1] Sat Nov 19 10:39:58 2011 @@ -9,43 +9,13 @@ */ #include <precomp.h> -#include <math.h> +#include <float.h> #include <internal/ieee.h> - - -#define _FPCLASS_SNAN 0x0001 /* signaling NaN */ -#define _FPCLASS_QNAN 0x0002 /* quiet NaN */ -#define _FPCLASS_NINF 0x0004 /* negative infinity */ -#define _FPCLASS_NN 0x0008 /* negative normal */ -#define _FPCLASS_ND 0x0010 /* negative denormal */ -#define _FPCLASS_NZ 0x0020 /* -0 */ -#define _FPCLASS_PZ 0x0040 /* +0 */ -#define _FPCLASS_PD 0x0080 /* positive denormal */ -#define _FPCLASS_PN 0x0100 /* positive normal */ -#define _FPCLASS_PINF 0x0200 /* positive infinity */ - - -//#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3 - -#define FP_SNAN 0x0001 // signaling NaN -#define FP_QNAN 0x0002 // quiet NaN -#define FP_NINF 0x0004 // negative infinity -#define FP_PINF 0x0200 // positive infinity -#define FP_NDENORM 0x0008 // negative denormalized non-zero -#define FP_PDENORM 0x0010 // positive denormalized non-zero -#define FP_NZERO 0x0020 // negative zero -#define FP_PZERO 0x0040 // positive zero -#define FP_NNORM 0x0080 // negative normalized non-zero -#define FP_PNORM 0x0100 // positive normalized non-zero - -//#endif - -typedef int fpclass_t; /* * @implemented */ -fpclass_t _fpclass(double __d) +int _fpclass(double __d) { union { @@ -57,26 +27,26 @@ if ( d.d->exponent == 0 ) { if ( d.d->mantissah == 0 && d.d->mantissal == 0 ) { if ( d.d->sign == 0 ) - return FP_PZERO; + return _FPCLASS_PZ; else - return FP_NZERO; + return _FPCLASS_NZ; } else { if ( d.d->sign == 0 ) - return FP_PDENORM; + return _FPCLASS_PD; else - return FP_NDENORM; + return _FPCLASS_ND; } } else if (d.d->exponent == 0x7ff ) { if ( d.d->mantissah == 0 && d.d->mantissal == 0 ) { if ( d.d->sign == 0 ) - return FP_PINF; + return _FPCLASS_PINF; else - return FP_NINF; + return _FPCLASS_NINF; } else if ( (d.d->mantissah & 0x80000) != 0 ) { - return FP_QNAN; + return _FPCLASS_QNAN; } } - return FP_SNAN; + return _FPCLASS_SNAN; }
13 years, 1 month
1
0
0
0
[pschweitzer] 54431: [CRT] Windows has no _isnanl, _isinfl functions
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Sat Nov 19 09:46:40 2011 New Revision: 54431 URL:
http://svn.reactos.org/svn/reactos?rev=54431&view=rev
Log: [CRT] Windows has no _isnanl, _isinfl functions Modified: trunk/reactos/lib/sdk/crt/float/isnan.c Modified: trunk/reactos/lib/sdk/crt/float/isnan.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/float/isnan.c?…
============================================================================== --- trunk/reactos/lib/sdk/crt/float/isnan.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/float/isnan.c [iso-8859-1] Sat Nov 19 09:46:40 2011 @@ -19,7 +19,6 @@ #include <precomp.h> - /* * @implemented */ @@ -32,26 +31,6 @@ } x; x.__x = &__x; return ( x.x->exponent == 0x7ff && ( x.x->mantissah != 0 || x.x->mantissal != 0 )); -} - -int _isnanl(long double __x) -{ - /* Intel's extended format has the normally implicit 1 explicit - present. Sigh! */ - union - { - long double* __x; - long_double_s* x; - } x; - x.__x = &__x; - - - /* IEEE 854 NaN's have the maximum possible - exponent and a nonzero mantissa. */ - - return (( x.x->exponent == 0x7fff) - && ( (x.x->mantissah & 0x80000) != 0) - && ( (x.x->mantissah & (unsigned int)0x7fffffff) != 0 || x.x->mantissal != 0 )); } /* @@ -69,25 +48,3 @@ return ((x.x->exponent & 0x7ff) != 0x7ff); } - -int _isinfl(long double __x) -{ - /* Intel's extended format has the normally implicit 1 explicit - present. Sigh! */ - union - { - long double* __x; - long_double_s* x; - } x; - - x.__x = &__x; - - - /* An IEEE 854 infinity has an exponent with the - maximum possible value and a zero mantissa. */ - - - if ( x.x->exponent == 0x7fff && ( (x.x->mantissah == 0x80000 ) && x.x->mantissal == 0 )) - return x.x->sign ? -1 : 1; - return 0; -}
13 years, 1 month
1
0
0
0
[pschweitzer] 54430: [MSVCRT_APITEST] Add more tests
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Sat Nov 19 09:44:49 2011 New Revision: 54430 URL:
http://svn.reactos.org/svn/reactos?rev=54430&view=rev
Log: [MSVCRT_APITEST] Add more tests Modified: trunk/rostests/apitests/msvcrt/ieee.c Modified: trunk/rostests/apitests/msvcrt/ieee.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/msvcrt/ieee.c?re…
============================================================================== --- trunk/rostests/apitests/msvcrt/ieee.c [iso-8859-1] (original) +++ trunk/rostests/apitests/msvcrt/ieee.c [iso-8859-1] Sat Nov 19 09:44:49 2011 @@ -22,6 +22,8 @@ ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); tested.l = 0xFFF8000000000001LL; ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); + tested.l = 0xFFF8000000000000LL; + ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); tested.l = 0xFFF7FFFFFFFFFFFFLL; ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); tested.l = 0xFFF0000000000001LL; @@ -71,6 +73,12 @@ tested.l = 0xFFF8000000000001LL; class = _fpclass(tested.d); ok(class == _FPCLASS_QNAN, "class = %d\n", class); + tested.l = 0xFFF8000000000000LL; + class = _fpclass(tested.d); + /* Normally it has no class, but w2k3 defines it + * like that + */ + ok(class == _FPCLASS_QNAN, "class = %d\n", class); tested.l = 0xFFF7FFFFFFFFFFFFLL; class = _fpclass(tested.d); /* According to IEEE, it should be Signaling NaN, but @@ -150,6 +158,8 @@ tested.l = 0xFFFFFFFFFFFFFFFFLL; ok(_isnan(tested.d) == TRUE, "_isnan = FALSE\n"); tested.l = 0xFFF8000000000001LL; + ok(_isnan(tested.d) == TRUE, "_isnan = FALSE\n"); + tested.l = 0xFFF8000000000000LL; ok(_isnan(tested.d) == TRUE, "_isnan = FALSE\n"); tested.l = 0xFFF7FFFFFFFFFFFFLL; ok(_isnan(tested.d) == TRUE, "_isnan = FALSE\n");
13 years, 1 month
1
0
0
0
[jimtabor] 54429: - Removes next phase for DesktopWndProcA.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Sat Nov 19 05:35:35 2011 New Revision: 54429 URL:
http://svn.reactos.org/svn/reactos?rev=54429&view=rev
Log: - Removes next phase for DesktopWndProcA. Modified: trunk/reactos/dll/win32/user32/windows/message.c Modified: trunk/reactos/dll/win32/user32/windows/message.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/m…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] Sat Nov 19 05:35:35 2011 @@ -1896,33 +1896,6 @@ return Ret; } -LRESULT -WINAPI -DesktopWndProcA( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) -{ - LRESULT Result; - MSG AnsiMsg, UcMsg; - - ERR("Desktop A Class Atom! hWnd 0x%x, Msg %d\n", hwnd, message); - - AnsiMsg.hwnd = hwnd; - AnsiMsg.message = message; - AnsiMsg.wParam = wParam; - AnsiMsg.lParam = lParam; - - // Desktop is always Unicode so convert Ansi here. - if (!MsgiAnsiToUnicodeMessage(hwnd, &UcMsg, &AnsiMsg)) - { - return FALSE; - } - - Result = DesktopWndProcW(hwnd, message, UcMsg.wParam, UcMsg.lParam); - - MsgiAnsiToUnicodeCleanup(&UcMsg, &AnsiMsg); - - return Result; -} - static VOID IntConvertMsgToAnsi(LPMSG lpMsg) {
13 years, 1 month
1
0
0
0
[jimtabor] 54428: [User32] - Updating MsgiAnsiToUnicodeReply fixed bug 4856 and 6650. Mirrored with it's counterpart. More work is needed. - Adding some future DBCS char support. - Miscellaneous ch...
by jimtabor@svn.reactos.org
Author: jimtabor Date: Sat Nov 19 05:33:26 2011 New Revision: 54428 URL:
http://svn.reactos.org/svn/reactos?rev=54428&view=rev
Log: [User32] - Updating MsgiAnsiToUnicodeReply fixed bug 4856 and 6650. Mirrored with it's counterpart. More work is needed. - Adding some future DBCS char support. - Miscellaneous changes. Modified: trunk/reactos/dll/win32/user32/windows/message.c Modified: trunk/reactos/dll/win32/user32/windows/message.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/m…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] Sat Nov 19 05:33:26 2011 @@ -90,6 +90,20 @@ #undef SET +/* check whether a combobox expects strings or ids in CB_ADDSTRING/CB_INSERTSTRING */ +static BOOL FASTCALL combobox_has_strings( HWND hwnd ) +{ + DWORD style = GetWindowLongA( hwnd, GWL_STYLE ); + return (!(style & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) || (style & CBS_HASSTRINGS)); +} + +/* check whether a listbox expects strings or ids in LB_ADDSTRING/LB_INSERTSTRING */ +static BOOL FASTCALL listbox_has_strings( HWND hwnd ) +{ + DWORD style = GetWindowLongA( hwnd, GWL_STYLE ); + return (!(style & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) || (style & LBS_HASSTRINGS)); +} + /* DDE message exchange * * - Session initialization @@ -234,24 +248,24 @@ { PKMDDELPARAM DdeLparam; DdeLparam = HeapAlloc(GetProcessHeap(), 0, sizeof(KMDDELPARAM)); - if (NULL == DdeLparam || !UnpackDDElParam( - UMMsg->message, UMMsg->lParam, - &DdeLparam->uiLo, &DdeLparam->uiHi)) return FALSE; - /* - If this is a reply to WM_DDE_EXECUTE then - uiHi will contain a hMem, hence >= 0x10000. - Otherwise, it will be be an atom, a 16-bit value. + if (!DdeLparam || + !UnpackDDElParam( UMMsg->message, UMMsg->lParam, &DdeLparam->uiLo, &DdeLparam->uiHi)) + return FALSE; + /* + If this is a reply to WM_DDE_EXECUTE then + uiHi will contain a hMem, hence >= 0x10000. + Otherwise, it will be be an atom, a 16-bit value. */ - if(DdeLparam->uiHi >= 0x10000) - { - HGLOBAL h = DdeGetPair((HGLOBAL)(ULONG_PTR)DdeLparam->uiHi); - if (NULL != h) - { - GlobalFree((HGLOBAL)(ULONG_PTR)DdeLparam->uiHi); - DdeLparam->uiHi = (UINT_PTR) h; - } - } - FreeDDElParam(UMMsg->message, UMMsg->lParam); + if (!IS_ATOM(DdeLparam->uiHi)) + { + HGLOBAL h = DdeGetPair((HGLOBAL)(ULONG_PTR)DdeLparam->uiHi); + if (h) + { + GlobalFree((HGLOBAL)(ULONG_PTR)DdeLparam->uiHi); + DdeLparam->uiHi = (UINT_PTR) h; + } + } + FreeDDElParam(UMMsg->message, UMMsg->lParam); KMMsg->lParam = (LPARAM) DdeLparam; } break; @@ -264,17 +278,17 @@ Size = GlobalSize((HGLOBAL) UMMsg->lParam); Data = GlobalLock((HGLOBAL) UMMsg->lParam); - if (NULL == Data) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } + if (!Data) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } KMDdeExecuteData = HeapAlloc(GetProcessHeap(), 0, sizeof(KMDDEEXECUTEDATA) + Size); - if (NULL == KMDdeExecuteData) - { - SetLastError(ERROR_OUTOFMEMORY); - return FALSE; - } + if (!KMDdeExecuteData) + { + SetLastError(ERROR_OUTOFMEMORY); + return FALSE; + } KMDdeExecuteData->Sender = (HWND) UMMsg->wParam; KMDdeExecuteData->ClientMem = (HGLOBAL) UMMsg->lParam; memcpy((PVOID) (KMDdeExecuteData + 1), Data, Size); @@ -291,11 +305,11 @@ pKMCopyData = HeapAlloc(GetProcessHeap(), 0, sizeof(COPYDATASTRUCT) + pUMCopyData->cbData); - if (pKMCopyData == NULL) - { + if (!pKMCopyData) + { SetLastError(ERROR_OUTOFMEMORY); return FALSE; - } + } pKMCopyData->dwData = pUMCopyData->dwData; pKMCopyData->cbData = pUMCopyData->cbData; @@ -365,7 +379,7 @@ { PKMDDELPARAM DdeLparam = (PKMDDELPARAM) KMMsg->lParam; UMMsg->lParam = PackDDElParam(KMMsg->message, DdeLparam->uiLo, DdeLparam->uiHi); - } + } break; case WM_DDE_EXECUTE: @@ -376,23 +390,23 @@ KMDdeExecuteData = (PKMDDEEXECUTEDATA) KMMsg->lParam; GlobalData = GlobalAlloc(GMEM_MOVEABLE, KMMsg->wParam - sizeof(KMDDEEXECUTEDATA)); - if (NULL == GlobalData) - { - return FALSE; - } + if (!GlobalData) + { + return FALSE; + } Data = GlobalLock(GlobalData); - if (NULL == Data) - { - GlobalFree(GlobalData); - return FALSE; - } + if (!Data) + { + GlobalFree(GlobalData); + return FALSE; + } memcpy(Data, (PVOID) (KMDdeExecuteData + 1), KMMsg->wParam - sizeof(KMDDEEXECUTEDATA)); GlobalUnlock(GlobalData); - if (! DdeAddPair(KMDdeExecuteData->ClientMem, GlobalData)) - { - GlobalFree(GlobalData); - return FALSE; - } + if (!DdeAddPair(KMDdeExecuteData->ClientMem, GlobalData)) + { + GlobalFree(GlobalData); + return FALSE; + } UMMsg->wParam = (WPARAM) KMDdeExecuteData->Sender; UMMsg->lParam = (LPARAM) GlobalData; } @@ -484,9 +498,7 @@ case LB_FINDSTRINGEXACT: case LB_SELECTSTRING: { - DWORD dwStyle = GetWindowLongPtrW(AnsiMsg->hwnd, GWL_STYLE); - if (!(dwStyle & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) && - (dwStyle & LBS_HASSTRINGS)) + if (listbox_has_strings(AnsiMsg->hwnd)) { RtlCreateUnicodeStringFromAsciiz(&UnicodeString, (LPSTR)AnsiMsg->lParam); UnicodeMsg->lParam = (LPARAM)UnicodeString.Buffer; @@ -500,9 +512,7 @@ case CB_FINDSTRINGEXACT: case CB_SELECTSTRING: { - DWORD dwStyle = GetWindowLongPtrW(AnsiMsg->hwnd, GWL_STYLE); - if (!(dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) && - (dwStyle & CBS_HASSTRINGS)) + if (combobox_has_strings(AnsiMsg->hwnd)) { RtlCreateUnicodeStringFromAsciiz(&UnicodeString, (LPSTR)AnsiMsg->lParam); UnicodeMsg->lParam = (LPARAM)UnicodeString.Buffer; @@ -579,7 +589,6 @@ return TRUE; } - static BOOL FASTCALL MsgiAnsiToUnicodeCleanup(LPMSG UnicodeMsg, LPMSG AnsiMsg) { @@ -617,9 +626,7 @@ case LB_FINDSTRINGEXACT: case LB_SELECTSTRING: { - DWORD dwStyle = GetWindowLongPtrW(AnsiMsg->hwnd, GWL_STYLE); - if (!(dwStyle & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) && - (dwStyle & LBS_HASSTRINGS)) + if (listbox_has_strings(AnsiMsg->hwnd)) { RtlInitUnicodeString(&UnicodeString, (PCWSTR)UnicodeMsg->lParam); RtlFreeUnicodeString(&UnicodeString); @@ -633,9 +640,7 @@ case CB_FINDSTRINGEXACT: case CB_SELECTSTRING: { - DWORD dwStyle = GetWindowLongPtrW(AnsiMsg->hwnd, GWL_STYLE); - if (!(dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) && - (dwStyle & CBS_HASSTRINGS)) + if (combobox_has_strings(AnsiMsg->hwnd)) { RtlInitUnicodeString(&UnicodeString, (PCWSTR)UnicodeMsg->lParam); RtlFreeUnicodeString(&UnicodeString); @@ -686,10 +691,10 @@ return(TRUE); } - static BOOL FASTCALL MsgiAnsiToUnicodeReply(LPMSG UnicodeMsg, LPMSG AnsiMsg, LRESULT *Result) { + LRESULT Size; switch (AnsiMsg->message) { case WM_GETTEXT: @@ -698,20 +703,48 @@ LPWSTR Buffer = (LPWSTR)UnicodeMsg->lParam; LPSTR AnsiBuffer = (LPSTR)AnsiMsg->lParam; if (UnicodeMsg->wParam > 0 && - !WideCharToMultiByte(CP_ACP, 0, Buffer, -1, - AnsiBuffer, UnicodeMsg->wParam, NULL, NULL)) - { + !WideCharToMultiByte(CP_ACP, 0, Buffer, -1, AnsiBuffer, UnicodeMsg->wParam, NULL, NULL)) + { AnsiBuffer[UnicodeMsg->wParam - 1] = 0; - } + } break; } + case LB_GETTEXT: + { + LPWSTR Buffer = (LPWSTR) UnicodeMsg->lParam; + LPSTR AnsiBuffer = (LPSTR) AnsiMsg->lParam; + if (!listbox_has_strings( UnicodeMsg->hwnd )) break; + Size = SendMessageW( UnicodeMsg->hwnd, LB_GETTEXTLEN, UnicodeMsg->wParam, 0 ); + if (Size == LB_ERR) break; + Size = Size + 1; + if (Size > 1 && + !WideCharToMultiByte(CP_ACP, 0, Buffer, -1, AnsiBuffer, Size, NULL, NULL)) + { + AnsiBuffer[Size - 1] = 0; + } + break; + } + case CB_GETLBTEXT: + { + LPWSTR Buffer = (LPWSTR) UnicodeMsg->lParam; + LPSTR AnsiBuffer = (LPSTR) AnsiMsg->lParam; + if (!combobox_has_strings( UnicodeMsg->hwnd )) break; + Size = SendMessageW( UnicodeMsg->hwnd, CB_GETLBTEXTLEN, UnicodeMsg->wParam, 0 ); + if (Size == CB_ERR) break; + Size = Size + 1; + if (Size > 1 && + !WideCharToMultiByte(CP_ACP, 0, Buffer, -1, AnsiBuffer, Size, NULL, NULL)) + { + AnsiBuffer[Size - 1] = 0; + } + break; + } } MsgiAnsiToUnicodeCleanup(UnicodeMsg, AnsiMsg); return TRUE; } - static BOOL FASTCALL MsgiUnicodeToAnsiMessage(HWND hwnd, LPMSG AnsiMsg, LPMSG UnicodeMsg) @@ -809,9 +842,7 @@ case LB_FINDSTRINGEXACT: case LB_SELECTSTRING: { - DWORD dwStyle = GetWindowLongPtrW(AnsiMsg->hwnd, GWL_STYLE); - if (!(dwStyle & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) && - (dwStyle & LBS_HASSTRINGS)) + if (listbox_has_strings(AnsiMsg->hwnd)) { RtlInitUnicodeString(&UnicodeString, (PWSTR) UnicodeMsg->lParam); if (! NT_SUCCESS(RtlUnicodeStringToAnsiString(&AnsiString, @@ -831,9 +862,7 @@ case CB_FINDSTRINGEXACT: case CB_SELECTSTRING: { - DWORD dwStyle = GetWindowLongPtrW(AnsiMsg->hwnd, GWL_STYLE); - if (!(dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) && - (dwStyle & CBS_HASSTRINGS)) + if (combobox_has_strings(AnsiMsg->hwnd)) { RtlInitUnicodeString(&UnicodeString, (PWSTR) UnicodeMsg->lParam); if (! NT_SUCCESS(RtlUnicodeStringToAnsiString(&AnsiString, @@ -896,7 +925,6 @@ return TRUE; } - static BOOL FASTCALL MsgiUnicodeToAnsiCleanup(LPMSG AnsiMsg, LPMSG UnicodeMsg) { @@ -942,9 +970,7 @@ case LB_FINDSTRINGEXACT: case LB_SELECTSTRING: { - DWORD dwStyle = GetWindowLongPtrW(AnsiMsg->hwnd, GWL_STYLE); - if (!(dwStyle & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) && - (dwStyle & LBS_HASSTRINGS)) + if (listbox_has_strings(AnsiMsg->hwnd)) { RtlInitAnsiString(&AnsiString, (PSTR) AnsiMsg->lParam); RtlFreeAnsiString(&AnsiString); @@ -987,10 +1013,10 @@ return TRUE; } - static BOOL FASTCALL MsgiUnicodeToAnsiReply(LPMSG AnsiMsg, LPMSG UnicodeMsg, LRESULT *Result) { + LRESULT Size; switch (UnicodeMsg->message) { case WM_GETTEXT: @@ -1000,9 +1026,39 @@ LPWSTR UBuffer = (LPWSTR) UnicodeMsg->lParam; if (0 < AnsiMsg->wParam && ! MultiByteToWideChar(CP_ACP, 0, Buffer, -1, UBuffer, UnicodeMsg->wParam)) - { + { UBuffer[UnicodeMsg->wParam - 1] = L'\0'; - } + } + break; + } + case LB_GETTEXT: + { + LPSTR Buffer = (LPSTR) AnsiMsg->lParam; + LPWSTR UBuffer = (LPWSTR) UnicodeMsg->lParam; + if (!listbox_has_strings( UnicodeMsg->hwnd )) break; + Size = SendMessageW( UnicodeMsg->hwnd, LB_GETTEXTLEN, UnicodeMsg->wParam, 0 ); + if (Size == LB_ERR) break; + Size = Size + 1; + if (1 < Size && + ! MultiByteToWideChar(CP_ACP, 0, Buffer, -1, UBuffer, Size)) + { + UBuffer[Size - 1] = L'\0'; + } + break; + } + case CB_GETLBTEXT: + { + LPSTR Buffer = (LPSTR) AnsiMsg->lParam; + LPWSTR UBuffer = (LPWSTR) UnicodeMsg->lParam; + if (!combobox_has_strings( UnicodeMsg->hwnd )) break; + Size = SendMessageW( UnicodeMsg->hwnd, CB_GETLBTEXTLEN, UnicodeMsg->wParam, 0 ); + if (Size == CB_ERR) break; + Size = Size + 1; + if (1 < Size && + ! MultiByteToWideChar(CP_ACP, 0, Buffer, -1, UBuffer, Size)) + { + UBuffer[Size - 1] = L'\0'; + } break; } } @@ -1020,34 +1076,83 @@ static WPARAM map_wparam_AtoW( UINT message, WPARAM wparam ) { + char ch[2]; + WCHAR wch[2]; + + wch[0] = wch[1] = 0; switch(message) { + case WM_CHAR: + /* WM_CHAR is magic: a DBCS char can be sent/posted as two consecutive WM_CHAR + * messages, in which case the first char is stored, and the conversion + * to Unicode only takes place once the second char is sent/posted. + */ +#if 0 + if (mapping != WMCHAR_MAP_NOMAPPING) // NlsMbCodePageTag + { + PCLIENTINFO pci = GetWin32ClientInfo(); + + struct wm_char_mapping_data *data = get_user_thread_info()->wmchar_data; + + BYTE low = LOBYTE(wparam); + + if (HIBYTE(wparam)) + { + ch[0] = low; + ch[1] = HIBYTE(wparam); + RtlMultiByteToUnicodeN( wch, sizeof(wch), NULL, ch, 2 ); + TRACE( "map %02x,%02x -> %04x mapping %u\n", (BYTE)ch[0], (BYTE)ch[1], wch[0], mapping ); + if (data) data->lead_byte[mapping] = 0; + } + else if (data && data->lead_byte[mapping]) + { + ch[0] = data->lead_byte[mapping]; + ch[1] = low; + RtlMultiByteToUnicodeN( wch, sizeof(wch), NULL, ch, 2 ); + TRACE( "map stored %02x,%02x -> %04x mapping %u\n", (BYTE)ch[0], (BYTE)ch[1], wch[0], mapping ); + data->lead_byte[mapping] = 0; + } + else if (!IsDBCSLeadByte( low )) + { + ch[0] = low; + RtlMultiByteToUnicodeN( wch, sizeof(wch), NULL, ch, 1 ); + TRACE( "map %02x -> %04x\n", (BYTE)ch[0], wch[0] ); + if (data) data->lead_byte[mapping] = 0; + } + else /* store it and wait for trail byte */ + { + if (!data) + { + if (!(data = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data) ))) + return FALSE; + get_user_thread_info()->wmchar_data = data; + } + TRACE( "storing lead byte %02x mapping %u\n", low, mapping ); + data->lead_byte[mapping] = low; + return FALSE; + } + wparam = MAKEWPARAM(wch[0], wch[1]); + break; + } +#endif + /* else fall through */ case WM_CHARTOITEM: case EM_SETPASSWORDCHAR: - case WM_CHAR: case WM_DEADCHAR: case WM_SYSCHAR: case WM_SYSDEADCHAR: case WM_MENUCHAR: - { - char ch[2]; - WCHAR wch[2]; - ch[0] = (wparam & 0xff); - ch[1] = (wparam >> 8); - MultiByteToWideChar(CP_ACP, 0, ch, 2, wch, 2); - wparam = MAKEWPARAM(wch[0], wch[1]); - } + ch[0] = LOBYTE(wparam); + ch[1] = HIBYTE(wparam); + RtlMultiByteToUnicodeN( wch, sizeof(wch), NULL, ch, 2 ); + wparam = MAKEWPARAM(wch[0], wch[1]); break; case WM_IME_CHAR: - { - char ch[2]; - WCHAR wch; - ch[0] = (wparam >> 8); - ch[1] = (wparam & 0xff); - if (ch[0]) MultiByteToWideChar(CP_ACP, 0, ch, 2, &wch, 1); - else MultiByteToWideChar(CP_ACP, 0, &ch[1], 1, &wch, 1); - wparam = MAKEWPARAM( wch, HIWORD(wparam) ); - } + ch[0] = HIBYTE(wparam); + ch[1] = LOBYTE(wparam); + if (ch[0]) RtlMultiByteToUnicodeN( wch, sizeof(wch[0]), NULL, ch, 2 ); + else RtlMultiByteToUnicodeN( wch, sizeof(wch[0]), NULL, ch + 1, 1 ); + wparam = MAKEWPARAM(wch[0], HIWORD(wparam)); break; } return wparam; @@ -1791,6 +1896,33 @@ return Ret; } +LRESULT +WINAPI +DesktopWndProcA( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) +{ + LRESULT Result; + MSG AnsiMsg, UcMsg; + + ERR("Desktop A Class Atom! hWnd 0x%x, Msg %d\n", hwnd, message); + + AnsiMsg.hwnd = hwnd; + AnsiMsg.message = message; + AnsiMsg.wParam = wParam; + AnsiMsg.lParam = lParam; + + // Desktop is always Unicode so convert Ansi here. + if (!MsgiAnsiToUnicodeMessage(hwnd, &UcMsg, &AnsiMsg)) + { + return FALSE; + } + + Result = DesktopWndProcW(hwnd, message, UcMsg.wParam, UcMsg.lParam); + + MsgiAnsiToUnicodeCleanup(&UcMsg, &AnsiMsg); + + return Result; +} + static VOID IntConvertMsgToAnsi(LPMSG lpMsg) { @@ -1818,9 +1950,9 @@ */ BOOL WINAPI GetMessageA(LPMSG lpMsg, - HWND hWnd, - UINT wMsgFilterMin, - UINT wMsgFilterMax) + HWND hWnd, + UINT wMsgFilterMin, + UINT wMsgFilterMax) { BOOL Res; @@ -1846,9 +1978,9 @@ */ BOOL WINAPI GetMessageW(LPMSG lpMsg, - HWND hWnd, - UINT wMsgFilterMin, - UINT wMsgFilterMax) + HWND hWnd, + UINT wMsgFilterMin, + UINT wMsgFilterMax) { BOOL Res;
13 years, 1 month
1
0
0
0
[rharabien] 54427: [SYSSETUP] - Close opened handles - Improve code a bit
by rharabien@svn.reactos.org
Author: rharabien Date: Sat Nov 19 00:24:58 2011 New Revision: 54427 URL:
http://svn.reactos.org/svn/reactos?rev=54427&view=rev
Log: [SYSSETUP] - Close opened handles - Improve code a bit Modified: trunk/reactos/dll/win32/syssetup/install.c Modified: trunk/reactos/dll/win32/syssetup/install.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/install…
============================================================================== --- trunk/reactos/dll/win32/syssetup/install.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/syssetup/install.c [iso-8859-1] Sat Nov 19 00:24:58 2011 @@ -44,57 +44,64 @@ /* FUNCTIONS ****************************************************************/ static VOID -DebugPrint(char* fmt,...) -{ - char buffer[512]; +FatalError(char *pszFmt,...) +{ + char szBuffer[512]; va_list ap; - va_start(ap, fmt); - vsprintf(buffer, fmt, ap); + va_start(ap, pszFmt); + vsprintf(szBuffer, pszFmt, ap); va_end(ap); LogItem(SYSSETUP_SEVERITY_FATAL_ERROR, L"Failed"); - strcat(buffer, "\nRebooting now!"); + strcat(szBuffer, "\nRebooting now!"); MessageBoxA(NULL, - buffer, + szBuffer, "ReactOS Setup", MB_OK); } - -HRESULT CreateShellLink(LPCTSTR linkPath, LPCTSTR cmd, LPCTSTR arg, LPCTSTR dir, LPCTSTR iconPath, int icon_nr, LPCTSTR comment) -{ - IShellLink* psl; - IPersistFile* ppf; +static HRESULT +CreateShellLink( + LPCTSTR pszLinkPath, + LPCTSTR pszCmd, + LPCTSTR pszArg, + LPCTSTR pszDir, + LPCTSTR pszIconPath, + int iIconNr, + LPCTSTR pszComment) +{ + IShellLink *psl; + IPersistFile *ppf; #ifndef _UNICODE - WCHAR buffer[MAX_PATH]; + WCHAR wszBuf[MAX_PATH]; #endif /* _UNICODE */ HRESULT hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (LPVOID*)&psl); if (SUCCEEDED(hr)) { - hr = psl->lpVtbl->SetPath(psl, cmd); - - if (arg) - { - hr = psl->lpVtbl->SetArguments(psl, arg); - } - - if (dir) - { - hr = psl->lpVtbl->SetWorkingDirectory(psl, dir); - } - - if (iconPath) - { - hr = psl->lpVtbl->SetIconLocation(psl, iconPath, icon_nr); - } - - if (comment) - { - hr = psl->lpVtbl->SetDescription(psl, comment); + hr = psl->lpVtbl->SetPath(psl, pszCmd); + + if (pszArg) + { + hr = psl->lpVtbl->SetArguments(psl, pszArg); + } + + if (pszDir) + { + hr = psl->lpVtbl->SetWorkingDirectory(psl, pszDir); + } + + if (pszIconPath) + { + hr = psl->lpVtbl->SetIconLocation(psl, pszIconPath, iIconNr); + } + + if (pszComment) + { + hr = psl->lpVtbl->SetDescription(psl, pszComment); } hr = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, (LPVOID*)&ppf); @@ -102,11 +109,11 @@ if (SUCCEEDED(hr)) { #ifdef _UNICODE - hr = ppf->lpVtbl->Save(ppf, linkPath, TRUE); + hr = ppf->lpVtbl->Save(ppf, pszLinkPath, TRUE); #else /* _UNICODE */ - MultiByteToWideChar(CP_ACP, 0, linkPath, -1, buffer, MAX_PATH); - - hr = ppf->lpVtbl->Save(ppf, buffer, TRUE); + MultiByteToWideChar(CP_ACP, 0, pszLinkPath, -1, wszBuf, MAX_PATH); + + hr = ppf->lpVtbl->Save(ppf, wszBuf, TRUE); #endif /* _UNICODE */ ppf->lpVtbl->Release(ppf); @@ -120,101 +127,105 @@ static BOOL -CreateShortcut(int csidl, LPCTSTR folder, UINT nIdName, LPCTSTR command, UINT nIdTitle, BOOL bCheckExistence, INT iIconNr) -{ - TCHAR path[MAX_PATH]; - TCHAR exeName[MAX_PATH]; - TCHAR title[256]; - TCHAR name[256]; - LPTSTR p = path; - TCHAR szWorkingDir[MAX_PATH]; - LPTSTR lpWorkingDir = NULL; +CreateShortcut( + int csidl, + LPCTSTR pszFolder, + UINT nIdName, + LPCTSTR pszCommand, + UINT nIdTitle, + BOOL bCheckExistence, + INT iIconNr) +{ + TCHAR szPath[MAX_PATH]; + TCHAR szExeName[MAX_PATH]; + TCHAR szTitle[256]; + TCHAR szName[256]; + LPTSTR Ptr = szPath; + TCHAR szWorkingDirBuf[MAX_PATH]; + LPTSTR pszWorkingDir = NULL; LPTSTR lpFilePart; DWORD dwLen; - if (ExpandEnvironmentStrings(command, - path, - sizeof(path) / sizeof(path[0])) == 0) - { - _tcscpy(path, - command); + if (ExpandEnvironmentStrings(pszCommand, + szPath, + sizeof(szPath) / sizeof(szPath[0])) == 0) + { + _tcscpy(szPath, pszCommand); } if (bCheckExistence) { - if ((_taccess(path, 0 )) == -1) + if ((_taccess(szPath, 0 )) == -1) /* Expected error, don't return FALSE */ return TRUE; } - dwLen = GetFullPathName(path, - sizeof(szWorkingDir) / sizeof(szWorkingDir[0]), - szWorkingDir, + dwLen = GetFullPathName(szPath, + sizeof(szWorkingDirBuf) / sizeof(szWorkingDirBuf[0]), + szWorkingDirBuf, &lpFilePart); - if (dwLen != 0 && dwLen <= sizeof(szWorkingDir) / sizeof(szWorkingDir[0])) + if (dwLen != 0 && dwLen <= sizeof(szWorkingDirBuf) / sizeof(szWorkingDirBuf[0])) { /* Since those should only be called with (.exe) files, lpFilePart has not to be NULL */ ASSERT(lpFilePart != NULL); /* Save the file name */ - _tcscpy(exeName, lpFilePart); + _tcscpy(szExeName, lpFilePart); /* We're only interested in the path. Cut the file name off. Also remove the trailing backslash unless the working directory is only going to be a drive, ie. C:\ */ *(lpFilePart--) = _T('\0'); - if (!(lpFilePart - szWorkingDir == 2 && szWorkingDir[1] == _T(':') && - szWorkingDir[2] == _T('\\'))) + if (!(lpFilePart - szWorkingDirBuf == 2 && szWorkingDirBuf[1] == _T(':') && + szWorkingDirBuf[2] == _T('\\'))) { *lpFilePart = _T('\0'); } - lpWorkingDir = szWorkingDir; - } - - - if (!SHGetSpecialFolderPath(0, path, csidl, TRUE)) + pszWorkingDir = szWorkingDirBuf; + } + + + if (!SHGetSpecialFolderPath(0, szPath, csidl, TRUE)) return FALSE; - if (folder) - { - p = PathAddBackslash(p); - _tcscpy(p, folder); - } - - p = PathAddBackslash(p); - - if (!LoadString(hDllInstance, nIdName, name, sizeof(name)/sizeof(name[0]))) + if (pszFolder) + { + Ptr = PathAddBackslash(Ptr); + _tcscpy(Ptr, pszFolder); + } + + Ptr = PathAddBackslash(Ptr); + + if (!LoadString(hDllInstance, nIdName, szName, sizeof(szName)/sizeof(szName[0]))) return FALSE; - _tcscpy(p, name); - - if (!LoadString(hDllInstance, nIdTitle, title, sizeof(title)/sizeof(title[0]))) + _tcscpy(Ptr, szName); + + if (!LoadString(hDllInstance, nIdTitle, szTitle, sizeof(szTitle)/sizeof(szTitle[0]))) return FALSE; // FIXME: we should pass 'command' straight in here, but shell32 doesn't expand it - return SUCCEEDED(CreateShellLink(path, exeName, _T(""), lpWorkingDir, exeName, iIconNr, title)); -} - + return SUCCEEDED(CreateShellLink(szPath, szExeName, _T(""), pszWorkingDir, szExeName, iIconNr, szTitle)); +} static BOOL -CreateShortcutFolder(int csidl, UINT nID, LPTSTR name, int nameLen) -{ - TCHAR path[MAX_PATH]; +CreateShortcutFolder(int csidl, UINT nID, LPTSTR pszName, int cchNameLen) +{ + TCHAR szPath[MAX_PATH]; LPTSTR p; - if (!SHGetSpecialFolderPath(0, path, csidl, TRUE)) + if (!SHGetSpecialFolderPath(0, szPath, csidl, TRUE)) return FALSE; - if (!LoadString(hDllInstance, nID, name, nameLen)) + if (!LoadString(hDllInstance, nID, pszName, cchNameLen)) return FALSE; - p = PathAddBackslash(path); - _tcscpy(p, name); - - return CreateDirectory(path, NULL) || GetLastError()==ERROR_ALREADY_EXISTS; -} - + p = PathAddBackslash(szPath); + _tcscpy(p, pszName); + + return CreateDirectory(szPath, NULL) || GetLastError()==ERROR_ALREADY_EXISTS; +} static BOOL CreateRandomSid( @@ -243,7 +254,6 @@ return NT_SUCCESS(Status); } - static VOID AppendRidToSid( OUT PSID *Dst, @@ -279,7 +289,6 @@ Dst); } - static VOID CreateTempDir( IN LPCWSTR VarName) @@ -293,9 +302,9 @@ L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", 0, KEY_QUERY_VALUE, - &hKey)) - { - DebugPrint("Error: %lu\n", GetLastError()); + &hKey) != ERROR_SUCCESS) + { + FatalError("Error: %lu\n", GetLastError()); return; } @@ -306,11 +315,10 @@ NULL, NULL, (LPBYTE)szBuffer, - &dwLength)) - { - DebugPrint("Error: %lu\n", GetLastError()); - RegCloseKey(hKey); - return; + &dwLength) != ERROR_SUCCESS) + { + FatalError("Error: %lu\n", GetLastError()); + goto cleanup; } /* Expand it */ @@ -318,9 +326,8 @@ szTempDir, MAX_PATH)) { - DebugPrint("Error: %lu\n", GetLastError()); - RegCloseKey(hKey); - return; + FatalError("Error: %lu\n", GetLastError()); + goto cleanup; } /* Create profiles directory */ @@ -328,22 +335,21 @@ { if (GetLastError() != ERROR_ALREADY_EXISTS) { - DebugPrint("Error: %lu\n", GetLastError()); - RegCloseKey(hKey); - return; - } - } - + FatalError("Error: %lu\n", GetLastError()); + goto cleanup; + } + } + +cleanup: RegCloseKey(hKey); } - -BOOL +static BOOL InstallSysSetupInfDevices(VOID) { INFCONTEXT InfContext; - WCHAR LineBuffer[256]; - DWORD LineLength; + WCHAR szLineBuffer[256]; + DWORD dwLineLength; if (!SetupFindFirstLineW(hSysSetupInf, L"DeviceInfsToInstall", @@ -357,14 +363,14 @@ { if (!SetupGetStringFieldW(&InfContext, 0, - LineBuffer, - sizeof(LineBuffer)/sizeof(LineBuffer[0]), - &LineLength)) + szLineBuffer, + sizeof(szLineBuffer)/sizeof(szLineBuffer[0]), + &dwLineLength)) { return FALSE; } - if (!SetupDiInstallClassW(NULL, LineBuffer, DI_QUIETINSTALL, NULL)) + if (!SetupDiInstallClassW(NULL, szLineBuffer, DI_QUIETINSTALL, NULL)) { return FALSE; } @@ -373,12 +379,13 @@ return TRUE; } -BOOL + +static BOOL InstallSysSetupInfComponents(VOID) { INFCONTEXT InfContext; - WCHAR NameBuffer[256]; - WCHAR SectionBuffer[256]; + WCHAR szNameBuffer[256]; + WCHAR szSectionBuffer[256]; HINF hComponentInf = INVALID_HANDLE_VALUE; if (!SetupFindFirstLineW(hSysSetupInf, @@ -394,40 +401,40 @@ { if (!SetupGetStringFieldW(&InfContext, 1, // Get the component name - NameBuffer, - sizeof(NameBuffer)/sizeof(NameBuffer[0]), + szNameBuffer, + sizeof(szNameBuffer)/sizeof(szNameBuffer[0]), NULL)) { - DebugPrint("Error while trying to get component name \n"); + FatalError("Error while trying to get component name \n"); return FALSE; } if (!SetupGetStringFieldW(&InfContext, 2, // Get the component install section - SectionBuffer, - sizeof(SectionBuffer)/sizeof(SectionBuffer[0]), + szSectionBuffer, + sizeof(szSectionBuffer)/sizeof(szSectionBuffer[0]), NULL)) { - DebugPrint("Error while trying to get component install section \n"); + FatalError("Error while trying to get component install section \n"); return FALSE; } - DPRINT("Trying to execute install section '%S' from '%S' \n", SectionBuffer , NameBuffer); - - hComponentInf = SetupOpenInfFileW(NameBuffer, + DPRINT("Trying to execute install section '%S' from '%S' \n", szSectionBuffer, szNameBuffer); + + hComponentInf = SetupOpenInfFileW(szNameBuffer, NULL, INF_STYLE_WIN4, NULL); if (hComponentInf == INVALID_HANDLE_VALUE) { - DebugPrint("SetupOpenInfFileW() failed to open '%S' (Error: %lu)\n", NameBuffer ,GetLastError()); + FatalError("SetupOpenInfFileW() failed to open '%S' (Error: %lu)\n", szNameBuffer, GetLastError()); return FALSE; } if (!SetupInstallFromInfSectionW(NULL, hComponentInf, - SectionBuffer, + szSectionBuffer, SPINST_ALL, NULL, NULL, @@ -437,7 +444,7 @@ NULL, NULL)) { - DebugPrint("Error while trying to install : %S (Error: %lu)\n", NameBuffer, GetLastError()); + FatalError("Error while trying to install : %S (Error: %lu)\n", szNameBuffer, GetLastError()); SetupCloseInfFile(hComponentInf); return FALSE; } @@ -455,7 +462,7 @@ { SC_HANDLE hSCManager = NULL; SC_HANDLE hService = NULL; - BOOL ret = FALSE; + BOOL bRet = FALSE; hSCManager = OpenSCManagerW(NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE); if (hSCManager == NULL) @@ -474,35 +481,34 @@ goto cleanup; } - ret = ChangeServiceConfigW(hService, + bRet = ChangeServiceConfigW(hService, SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - if (!ret) + if (!bRet) { DPRINT1("Unable to change the service configuration\n"); goto cleanup; } - ret = StartServiceW(hService, 0, NULL); - if ((!ret) && (GetLastError() != ERROR_SERVICE_ALREADY_RUNNING)) + bRet = StartServiceW(hService, 0, NULL); + if (!bRet && (GetLastError() != ERROR_SERVICE_ALREADY_RUNNING)) { DPRINT1("Unable to start service\n"); goto cleanup; } - ret = TRUE; + bRet = TRUE; cleanup: if (hSCManager != NULL) CloseServiceHandle(hSCManager); if (hService != NULL) CloseServiceHandle(hService); - return ret; -} - + return bRet; +} static INT_PTR CALLBACK StatusMessageWindowProc( @@ -527,7 +533,6 @@ } return FALSE; } - static DWORD WINAPI ShowStatusMessageThread( @@ -568,7 +573,7 @@ LONG rc; DWORD dwType; DWORD cbData = 0; - LPWSTR Value; + LPWSTR pwszValue; if (!pValue) return ERROR_INVALID_PARAMETER; @@ -579,29 +584,29 @@ return rc; if (dwType != REG_SZ) return ERROR_FILE_NOT_FOUND; - Value = HeapAlloc(GetProcessHeap(), 0, cbData + sizeof(WCHAR)); - if (!Value) + pwszValue = HeapAlloc(GetProcessHeap(), 0, cbData + sizeof(WCHAR)); + if (!pwszValue) return ERROR_NOT_ENOUGH_MEMORY; - rc = RegQueryValueExW(hKey, pszKey, NULL, NULL, (LPBYTE)Value, &cbData); + rc = RegQueryValueExW(hKey, pszKey, NULL, NULL, (LPBYTE)pwszValue, &cbData); if (rc != ERROR_SUCCESS) { - HeapFree(GetProcessHeap(), 0, Value); + HeapFree(GetProcessHeap(), 0, pwszValue); return rc; } /* NULL-terminate the string */ - Value[cbData / sizeof(WCHAR)] = '\0'; - - *pValue = Value; + pwszValue[cbData / sizeof(WCHAR)] = '\0'; + + *pValue = pwszValue; return ERROR_SUCCESS; } static BOOL IsConsoleBoot(VOID) { - HKEY ControlKey = NULL; - LPWSTR SystemStartOptions = NULL; - LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */ - BOOL ConsoleBoot = FALSE; + HKEY hControlKey = NULL; + LPWSTR pwszSystemStartOptions = NULL; + LPWSTR pwszCurrentOption, pwszNextOption; /* Pointers into SystemStartOptions */ + BOOL bConsoleBoot = FALSE; LONG rc; rc = RegOpenKeyExW( @@ -609,33 +614,36 @@ L"SYSTEM\\CurrentControlSet\\Control", 0, KEY_QUERY_VALUE, - &ControlKey); - - rc = ReadRegSzKey(ControlKey, L"SystemStartOptions", &SystemStartOptions); + &hControlKey); if (rc != ERROR_SUCCESS) goto cleanup; + rc = ReadRegSzKey(hControlKey, L"SystemStartOptions", &pwszSystemStartOptions); + if (rc != ERROR_SUCCESS) + goto cleanup; + /* Check for CMDCONS in SystemStartOptions */ - CurrentOption = SystemStartOptions; - while (CurrentOption) - { - NextOption = wcschr(CurrentOption, L' '); - if (NextOption) - *NextOption = L'\0'; - if (wcsicmp(CurrentOption, L"CONSOLE") == 0) - { - DPRINT("Found %S. Switching to console boot\n", CurrentOption); - ConsoleBoot = TRUE; + pwszCurrentOption = pwszSystemStartOptions; + while (pwszCurrentOption) + { + pwszNextOption = wcschr(pwszCurrentOption, L' '); + if (pwszNextOption) + *pwszNextOption = L'\0'; + if (wcsicmp(pwszCurrentOption, L"CONSOLE") == 0) + { + DPRINT("Found %S. Switching to console boot\n", pwszCurrentOption); + bConsoleBoot = TRUE; goto cleanup; } - CurrentOption = NextOption ? NextOption + 1 : NULL; + pwszCurrentOption = pwszNextOption ? pwszNextOption + 1 : NULL; } cleanup: - if (ControlKey != NULL) - RegCloseKey(ControlKey); - HeapFree(GetProcessHeap(), 0, SystemStartOptions); - return ConsoleBoot; + if (hControlKey != NULL) + RegCloseKey(hControlKey); + if (pwszSystemStartOptions) + HeapFree(GetProcessHeap(), 0, pwszSystemStartOptions); + return bConsoleBoot; } static BOOL @@ -650,53 +658,58 @@ NULL); if (hSysSetupInf == INVALID_HANDLE_VALUE) { - DebugPrint("SetupOpenInfFileW() failed to open 'syssetup.inf' (Error: %lu)\n", GetLastError()); + FatalError("SetupOpenInfFileW() failed to open 'syssetup.inf' (Error: %lu)\n", GetLastError()); return FALSE; } if (!InstallSysSetupInfDevices()) { - DebugPrint("InstallSysSetupInfDevices() failed!\n"); - SetupCloseInfFile(hSysSetupInf); - return FALSE; + FatalError("InstallSysSetupInfDevices() failed!\n"); + goto error; } if(!InstallSysSetupInfComponents()) { - DebugPrint("InstallSysSetupInfComponents() failed!\n"); - SetupCloseInfFile(hSysSetupInf); - return FALSE; + FatalError("InstallSysSetupInfComponents() failed!\n"); + goto error; } if (!IsConsoleBoot()) { - CreateThread( + HANDLE hThread; + + hThread = CreateThread( NULL, 0, ShowStatusMessageThread, (LPVOID)&hWnd, 0, NULL); + + if (hThread) + CloseHandle(hThread); } if (!EnableUserModePnpManager()) { - DebugPrint("EnableUserModePnpManager() failed!\n"); - SetupCloseInfFile(hSysSetupInf); - EndDialog(hWnd, 0); - return FALSE; + FatalError("EnableUserModePnpManager() failed!\n"); + goto error; } if (CMP_WaitNoPendingInstallEvents(INFINITE) != WAIT_OBJECT_0) { - DebugPrint("CMP_WaitNoPendingInstallEvents() failed!\n"); - SetupCloseInfFile(hSysSetupInf); - EndDialog(hWnd, 0); - return FALSE; + FatalError("CMP_WaitNoPendingInstallEvents() failed!\n"); + goto error; } EndDialog(hWnd, 0); return TRUE; + +error: + if (hWnd) + EndDialog(hWnd, 0); + SetupCloseInfFile(hSysSetupInf); + return FALSE; } DWORD WINAPI @@ -704,10 +717,10 @@ { STARTUPINFOW StartupInfo; PROCESS_INFORMATION ProcessInformation; - BOOL res; + BOOL bRes; if (!CommonInstall()) - goto cleanup; + goto error; SetupCloseInfFile(hSysSetupInf); /* Run the shell */ @@ -718,7 +731,7 @@ StartupInfo.dwFlags = 0; StartupInfo.cbReserved2 = 0; StartupInfo.lpReserved2 = 0; - res = CreateProcessW( + bRes = CreateProcessW( L"userinit.exe", NULL, NULL, @@ -729,12 +742,15 @@ NULL, &StartupInfo, &ProcessInformation); - if (!res) - goto cleanup; + if (!bRes) + goto error; + + CloseHandle(ProcessInformation.hThread); + CloseHandle(ProcessInformation.hProcess); return 0; -cleanup: +error: MessageBoxW( NULL, L"Failed to load LiveCD! You can shutdown your computer, or press ENTER to reboot.", @@ -855,34 +871,34 @@ if (!InitializeProfiles()) { - DebugPrint("InitializeProfiles() failed"); + FatalError("InitializeProfiles() failed"); return 0; } if (!CreateShortcuts()) { - DebugPrint("InitializeProfiles() failed"); + FatalError("InitializeProfiles() failed"); return 0; } /* Initialize the Security Account Manager (SAM) */ if (!SamInitializeSAM()) { - DebugPrint("SamInitializeSAM() failed!"); + FatalError("SamInitializeSAM() failed!"); return 0; } /* Create the semi-random Domain-SID */ if (!CreateRandomSid(&DomainSid)) { - DebugPrint("Domain-SID creation failed!"); + FatalError("Domain-SID creation failed!"); return 0; } /* Set the Domain SID (aka Computer SID) */ if (!SamSetDomainSid(DomainSid)) { - DebugPrint("SamSetDomainSid() failed!"); + FatalError("SamSetDomainSid() failed!"); RtlFreeSid(DomainSid); return 0; } @@ -939,7 +955,7 @@ LastError = GetLastError(); if (LastError != ERROR_USER_EXISTS) { - DebugPrint("SamCreateUser() failed!"); + FatalError("SamCreateUser() failed!"); RtlFreeSid(AdminSid); RtlFreeSid(DomainSid); return 0; @@ -962,7 +978,7 @@ ret = LogonUserW(L"Administrator", L"", L"", LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &hToken); if (!ret) { - DebugPrint("LogonUserW() failed!"); + FatalError("LogonUserW() failed!"); return 0; } ZeroMemory(&ProfileInfo, sizeof(PROFILEINFOW)); @@ -988,7 +1004,7 @@ /* Get shutdown privilege */ if (! OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token)) { - DebugPrint("OpenProcessToken() failed!"); + FatalError("OpenProcessToken() failed!"); return 0; } if (!LookupPrivilegeValue( @@ -996,7 +1012,7 @@ SE_SHUTDOWN_NAME, &privs.Privileges[0].Luid)) { - DebugPrint("LookupPrivilegeValue() failed!"); + FatalError("LookupPrivilegeValue() failed!"); return 0; } privs.PrivilegeCount = 1; @@ -1009,7 +1025,7 @@ (PTOKEN_PRIVILEGES)NULL, NULL) == 0) { - DebugPrint("AdjustTokenPrivileges() failed!"); + FatalError("AdjustTokenPrivileges() failed!"); return 0; }
13 years, 1 month
1
0
0
0
[pschweitzer] 54426: [CRT] Reimplemented _finite properly. Removed unused _isinf function.
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Fri Nov 18 22:53:13 2011 New Revision: 54426 URL:
http://svn.reactos.org/svn/reactos?rev=54426&view=rev
Log: [CRT] Reimplemented _finite properly. Removed unused _isinf function. Modified: trunk/reactos/lib/sdk/crt/float/isnan.c Modified: trunk/reactos/lib/sdk/crt/float/isnan.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/float/isnan.c?…
============================================================================== --- trunk/reactos/lib/sdk/crt/float/isnan.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/float/isnan.c [iso-8859-1] Fri Nov 18 22:53:13 2011 @@ -54,7 +54,10 @@ && ( (x.x->mantissah & (unsigned int)0x7fffffff) != 0 || x.x->mantissal != 0 )); } -int _isinf(double __x) +/* + * @implemented + */ +int _finite(double __x) { union { @@ -63,15 +66,8 @@ } x; x.__x = &__x; - return ( x.x->exponent == 0x7ff && ( x.x->mantissah == 0 && x.x->mantissal == 0 )); -} -/* - * @implemented - */ -int _finite( double x ) -{ - return !_isinf(x); + return ((x.x->exponent & 0x7ff) != 0x7ff); } int _isinfl(long double __x)
13 years, 1 month
1
0
0
0
[pschweitzer] 54425: [MSVCRT_APITEST] Add test suite for IEEE floatting-point functions. It's been tested on w2k3 and it has 0 failed tests. Some are failing on ReactOS.
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Fri Nov 18 22:26:35 2011 New Revision: 54425 URL:
http://svn.reactos.org/svn/reactos?rev=54425&view=rev
Log: [MSVCRT_APITEST] Add test suite for IEEE floatting-point functions. It's been tested on w2k3 and it has 0 failed tests. Some are failing on ReactOS. Added: trunk/rostests/apitests/msvcrt/ieee.c (with props) Modified: trunk/rostests/apitests/msvcrt/CMakeLists.txt trunk/rostests/apitests/msvcrt/msvcrt_apitest.rbuild trunk/rostests/apitests/msvcrt/testlist.c Modified: trunk/rostests/apitests/msvcrt/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/msvcrt/CMakeList…
============================================================================== --- trunk/rostests/apitests/msvcrt/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/msvcrt/CMakeLists.txt [iso-8859-1] Fri Nov 18 22:26:35 2011 @@ -2,6 +2,7 @@ add_definitions(-D_DLL -D__USE_CRTIMP) list(APPEND SOURCE + ieee.c splitpath.c testlist.c) Added: trunk/rostests/apitests/msvcrt/ieee.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/msvcrt/ieee.c?re…
============================================================================== --- trunk/rostests/apitests/msvcrt/ieee.c (added) +++ trunk/rostests/apitests/msvcrt/ieee.c [iso-8859-1] Fri Nov 18 22:26:35 2011 @@ -1,0 +1,197 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Tests for IEEE floatting-point functions + * PROGRAMMER: Pierre Schweitzer (pierre(a)reactos.org) + */ + +#include <wine/test.h> +#include <float.h> + +typedef union +{ + double d; + long long l; +} ieee_double; + +void test_finite(void) +{ + ieee_double tested; + + tested.l = 0xFFFFFFFFFFFFFFFFLL; + ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); + tested.l = 0xFFF8000000000001LL; + ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); + tested.l = 0xFFF7FFFFFFFFFFFFLL; + ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); + tested.l = 0xFFF0000000000001LL; + ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); + tested.l = 0xFFF0000000000000LL; + ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); + tested.l = 0xFFEFFFFFFFFFFFFFLL; + ok(_finite(tested.d) == TRUE, "_finite = FALSE\n"); + tested.l = 0x8010000000000000LL; + ok(_finite(tested.d) == TRUE, "_finite = FALSE\n"); + tested.l = 0x800FFFFFFFFFFFFFLL; + ok(_finite(tested.d) == TRUE, "_finite = FALSE\n"); + tested.l = 0x8000000000000001LL; + ok(_finite(tested.d) == TRUE, "_finite = FALSE\n"); + tested.l = 0x8000000000000000LL; + ok(_finite(tested.d) == TRUE, "_finite = FALSE\n"); + tested.l = 0x0000000000000000LL; + ok(_finite(tested.d) == TRUE, "_finite = FALSE\n"); + tested.l = 0x0000000000000001LL; + ok(_finite(tested.d) == TRUE, "_finite = FALSE\n"); + tested.l = 0x000FFFFFFFFFFFFFLL; + ok(_finite(tested.d) == TRUE, "_finite = FALSE\n"); + tested.l = 0x0010000000000000LL; + ok(_finite(tested.d) == TRUE, "_finite = FALSE\n"); + tested.l = 0x7FEFFFFFFFFFFFFFLL; + ok(_finite(tested.d) == TRUE, "_finite = FALSE\n"); + tested.l = 0x7FF0000000000000LL; + ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); + tested.l = 0x7FF0000000000001LL; + ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); + tested.l = 0x7FF7FFFFFFFFFFFFLL; + ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); + tested.l = 0x7FF8000000000000LL; + ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); + tested.l = 0x7FFFFFFFFFFFFFFFLL; + ok(_finite(tested.d) == FALSE, "_finite = TRUE\n"); +} + +void test_fpclass(void) +{ + int class; + ieee_double tested; + + tested.l = 0xFFFFFFFFFFFFFFFFLL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_QNAN, "class = %d\n", class); + tested.l = 0xFFF8000000000001LL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_QNAN, "class = %d\n", class); + tested.l = 0xFFF7FFFFFFFFFFFFLL; + class = _fpclass(tested.d); + /* According to IEEE, it should be Signaling NaN, but + * on w2k3, it's Quiet NAN + * ok(class == _FPCLASS_SNAN, "class = %d\n", class); + */ + ok(class == _FPCLASS_QNAN, "class = %d\n", class); + tested.l = 0xFFF0000000000001LL; + class = _fpclass(tested.d); + /* According to IEEE, it should be Signaling NaN, but + * on w2k3, it's Quiet NAN + * ok(class == _FPCLASS_SNAN, "class = %d\n", class); + */ + ok(class == _FPCLASS_QNAN, "class = %d\n", class); + tested.l = 0xFFF0000000000000LL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_NINF, "class = %d\n", class); + tested.l = 0xFFEFFFFFFFFFFFFFLL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_NN, "class = %d\n", class); + tested.l = 0x8010000000000000LL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_NN, "class = %d\n", class); + tested.l = 0x800FFFFFFFFFFFFFLL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_ND, "class = %d\n", class); + tested.l = 0x8000000000000001LL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_ND, "class = %d\n", class); + tested.l = 0x8000000000000000LL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_NZ, "class = %d\n", class); + tested.l = 0x0000000000000000LL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_PZ, "class = %d\n", class); + tested.l = 0x0000000000000001LL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_PD, "class = %d\n", class); + tested.l = 0x000FFFFFFFFFFFFFLL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_PD, "class = %d\n", class); + tested.l = 0x0010000000000000LL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_PN, "class = %d\n", class); + tested.l = 0x7FEFFFFFFFFFFFFFLL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_PN, "class = %d\n", class); + tested.l = 0x7FF0000000000000LL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_PINF, "class = %d\n", class); + tested.l = 0x7FF0000000000001LL; + class = _fpclass(tested.d); + /* According to IEEE, it should be Signaling NaN, but + * on w2k3, it's Quiet NAN + * ok(class == _FPCLASS_SNAN, "class = %d\n", class); + */ + ok(class == _FPCLASS_QNAN, "class = %d\n", class); + tested.l = 0x7FF7FFFFFFFFFFFFLL; + class = _fpclass(tested.d); + /* According to IEEE, it should be Signaling NaN, but + * on w2k3, it's Quiet NAN + * ok(class == _FPCLASS_SNAN, "class = %d\n", class); + */ + ok(class == _FPCLASS_QNAN, "class = %d\n", class); + tested.l = 0x7FF8000000000000LL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_QNAN, "class = %d\n", class); + tested.l = 0x7FFFFFFFFFFFFFFFLL; + class = _fpclass(tested.d); + ok(class == _FPCLASS_QNAN, "class = %d\n", class); +} + +void test_isnan(void) +{ + ieee_double tested; + + tested.l = 0xFFFFFFFFFFFFFFFFLL; + ok(_isnan(tested.d) == TRUE, "_isnan = FALSE\n"); + tested.l = 0xFFF8000000000001LL; + ok(_isnan(tested.d) == TRUE, "_isnan = FALSE\n"); + tested.l = 0xFFF7FFFFFFFFFFFFLL; + ok(_isnan(tested.d) == TRUE, "_isnan = FALSE\n"); + tested.l = 0xFFF0000000000001LL; + ok(_isnan(tested.d) == TRUE, "_isnan = FALSE\n"); + tested.l = 0xFFF0000000000000LL; + ok(_isnan(tested.d) == FALSE, "_isnan = TRUE\n"); + tested.l = 0xFFEFFFFFFFFFFFFFLL; + ok(_isnan(tested.d) == FALSE, "_isnan = TRUE\n"); + tested.l = 0x8010000000000000LL; + ok(_isnan(tested.d) == FALSE, "_isnan = TRUE\n"); + tested.l = 0x800FFFFFFFFFFFFFLL; + ok(_isnan(tested.d) == FALSE, "_isnan = TRUE\n"); + tested.l = 0x8000000000000001LL; + ok(_isnan(tested.d) == FALSE, "_isnan = TRUE\n"); + tested.l = 0x8000000000000000LL; + ok(_isnan(tested.d) == FALSE, "_isnan = TRUE\n"); + tested.l = 0x0000000000000000LL; + ok(_isnan(tested.d) == FALSE, "_isnan = TRUE\n"); + tested.l = 0x0000000000000001LL; + ok(_isnan(tested.d) == FALSE, "_isnan = TRUE\n"); + tested.l = 0x000FFFFFFFFFFFFFLL; + ok(_isnan(tested.d) == FALSE, "_isnan = TRUE\n"); + tested.l = 0x0010000000000000LL; + ok(_isnan(tested.d) == FALSE, "_isnan = TRUE\n"); + tested.l = 0x7FEFFFFFFFFFFFFFLL; + ok(_isnan(tested.d) == FALSE, "_isnan = TRUE\n"); + tested.l = 0x7FF0000000000000LL; + ok(_isnan(tested.d) == FALSE, "_isnan = TRUE\n"); + tested.l = 0x7FF0000000000001LL; + ok(_isnan(tested.d) == TRUE, "_isnan = FALSE\n"); + tested.l = 0x7FF7FFFFFFFFFFFFLL; + ok(_isnan(tested.d) == TRUE, "_isnan = FALSE\n"); + tested.l = 0x7FF8000000000000LL; + ok(_isnan(tested.d) == TRUE, "_isnan = FALSE\n"); + tested.l = 0x7FFFFFFFFFFFFFFFLL; + ok(_isnan(tested.d) == TRUE, "_isnan = FALSE\n"); +} + +START_TEST(ieee) +{ + test_finite(); + test_fpclass(); + test_isnan(); +} Propchange: trunk/rostests/apitests/msvcrt/ieee.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/rostests/apitests/msvcrt/msvcrt_apitest.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/msvcrt/msvcrt_ap…
============================================================================== --- trunk/rostests/apitests/msvcrt/msvcrt_apitest.rbuild [iso-8859-1] (original) +++ trunk/rostests/apitests/msvcrt/msvcrt_apitest.rbuild [iso-8859-1] Fri Nov 18 22:26:35 2011 @@ -7,6 +7,7 @@ <library>pseh</library> <file>testlist.c</file> + <file>ieee.c</file> <file>splitpath.c</file> </module> Modified: trunk/rostests/apitests/msvcrt/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/msvcrt/testlist.…
============================================================================== --- trunk/rostests/apitests/msvcrt/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/msvcrt/testlist.c [iso-8859-1] Fri Nov 18 22:26:35 2011 @@ -5,10 +5,12 @@ #define STANDALONE #include "wine/test.h" +extern void func_ieee(void); extern void func_splitpath(void); const struct test winetest_testlist[] = { + { "ieee", func_ieee }, { "splitpath", func_splitpath }, { 0, 0 }
13 years, 1 month
1
0
0
0
← Newer
1
...
10
11
12
13
14
15
16
...
28
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Results per page:
10
25
50
100
200