winehq.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
2025
February
January
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
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
May 2022
----- 2025 -----
February 2025
January 2025
----- 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
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
907 discussions
Start a n
N
ew thread
Rémi Bernon : ntdll: Call valgrind alloc notifications at the topmost level.
by Alexandre Julliard
31 May '22
31 May '22
Module: wine Branch: master Commit: 0b4266c7a482ea45781135e57b08cecef095a97c URL:
https://source.winehq.org/git/wine.git/?a=commit;h=0b4266c7a482ea45781135e5…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue May 31 11:12:04 2022 +0200 ntdll: Call valgrind alloc notifications at the topmost level. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> --- dlls/ntdll/heap.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 57ceff9cdd1..4050c00c265 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -377,7 +377,7 @@ static inline void initialize_block( void *ptr, SIZE_T size, SIZE_T unused, DWOR } /* notify that a new block of memory has been allocated for debugging purposes */ -static inline void notify_alloc( void *ptr, SIZE_T size, BOOL init ) +static inline void valgrind_notify_alloc( void const *ptr, SIZE_T size, BOOL init ) { #ifdef VALGRIND_MALLOCLIKE_BLOCK VALGRIND_MALLOCLIKE_BLOCK( ptr, size, 0, init ); @@ -385,14 +385,14 @@ static inline void notify_alloc( void *ptr, SIZE_T size, BOOL init ) } /* notify that a block of memory has been freed for debugging purposes */ -static inline void notify_free( void const *ptr ) +static inline void valgrind_notify_free( void const *ptr ) { #ifdef VALGRIND_FREELIKE_BLOCK VALGRIND_FREELIKE_BLOCK( ptr, 0 ); #endif } -static inline void notify_realloc( void const *ptr, SIZE_T size_old, SIZE_T size_new ) +static inline void valgrind_notify_resize( void const *ptr, SIZE_T size_old, SIZE_T size_new ) { #ifdef VALGRIND_RESIZEINPLACE_BLOCK /* zero is not a valid size */ @@ -400,7 +400,7 @@ static inline void notify_realloc( void const *ptr, SIZE_T size_old, SIZE_T size #endif } -static void notify_free_all( SUBHEAP *subheap ) +static void valgrind_notify_free_all( SUBHEAP *subheap ) { #ifdef VALGRIND_FREELIKE_BLOCK struct block *block; @@ -411,7 +411,7 @@ static void notify_free_all( SUBHEAP *subheap ) for (block = first_block( subheap ); block; block = next_block( subheap, block )) { if (block_get_flags( block ) & BLOCK_FLAG_FREE) continue; - if (block_get_type( block ) == ARENA_INUSE_MAGIC) notify_free( block + 1 ); + if (block_get_type( block ) == ARENA_INUSE_MAGIC) valgrind_notify_free( block + 1 ); } #endif } @@ -801,7 +801,6 @@ static void *allocate_large_block( HEAP *heap, DWORD flags, SIZE_T size ) arena->magic = ARENA_LARGE_MAGIC; mark_block_tail( (char *)(arena + 1) + size, block_size - sizeof(*arena) - size, flags ); list_add_tail( &heap->large_list, &arena->entry ); - notify_alloc( arena + 1, size, flags & HEAP_ZERO_MEMORY ); return arena + 1; } @@ -833,11 +832,7 @@ static void *realloc_large_block( HEAP *heap, DWORD flags, void *ptr, SIZE_T siz SIZE_T unused = arena->block_size - sizeof(*arena) - size; /* FIXME: we could remap zero-pages instead */ -#ifdef VALGRIND_RESIZEINPLACE_BLOCK - if (RUNNING_ON_VALGRIND) - notify_realloc( arena + 1, arena->data_size, size ); - else -#endif + valgrind_notify_resize( arena + 1, arena->data_size, size ); if (size > arena->data_size) initialize_block( (char *)ptr + arena->data_size, size - arena->data_size, unused, flags ); else @@ -851,9 +846,10 @@ static void *realloc_large_block( HEAP *heap, DWORD flags, void *ptr, SIZE_T siz WARN("Could not allocate block for %08lx bytes\n", size ); return NULL; } + valgrind_notify_alloc( new_ptr, size, 0 ); memcpy( new_ptr, ptr, arena->data_size ); + valgrind_notify_free( ptr ); free_large_block( heap, ptr ); - notify_free( ptr ); return new_ptr; } @@ -1473,13 +1469,13 @@ HANDLE WINAPI RtlDestroyHeap( HANDLE heap ) LIST_FOR_EACH_ENTRY_SAFE( subheap, next, &heapPtr->subheap_list, SUBHEAP, entry ) { if (subheap == &heapPtr->subheap) continue; /* do this one last */ - notify_free_all( subheap ); + valgrind_notify_free_all( subheap ); list_remove( &subheap->entry ); size = 0; addr = ROUND_ADDR( subheap, COMMIT_MASK ); NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE ); } - notify_free_all( &heapPtr->subheap ); + valgrind_notify_free_all( &heapPtr->subheap ); size = 0; addr = heap; NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE ); @@ -1510,8 +1506,6 @@ static NTSTATUS heap_allocate( HEAP *heap, ULONG flags, SIZE_T size, void **ret block_set_type( block, ARENA_INUSE_MAGIC ); shrink_used_block( subheap, block, 0, old_block_size, block_size, size ); - - notify_alloc( block + 1, size, flags & HEAP_ZERO_MEMORY ); initialize_block( block + 1, size, block->unused_bytes, flags ); *ret = block + 1; @@ -1536,6 +1530,8 @@ void *WINAPI DECLSPEC_HOTPATCH RtlAllocateHeap( HANDLE heap, ULONG flags, SIZE_T heap_unlock( heapPtr, flags ); } + if (!status) valgrind_notify_alloc( ptr, size, flags & HEAP_ZERO_MEMORY ); + TRACE( "heap %p, flags %#x, size %#Ix, return %p, status %#x.\n", heap, flags, size, ptr, status ); heap_set_status( heapPtr, flags, status ); return ptr; @@ -1547,9 +1543,6 @@ static NTSTATUS heap_free( HEAP *heap, void *ptr ) ARENA_INUSE *block; SUBHEAP *subheap; - /* Inform valgrind we are trying to free memory, so it can throw up an error message */ - notify_free( ptr ); - if (!(block = unsafe_block_from_ptr( heap, ptr, &subheap ))) return STATUS_INVALID_PARAMETER; if (!subheap) free_large_block( heap, ptr ); else free_used_block( subheap, block ); @@ -1567,6 +1560,8 @@ BOOLEAN WINAPI DECLSPEC_HOTPATCH RtlFreeHeap( HANDLE heap, ULONG flags, void *pt if (!ptr) return TRUE; + valgrind_notify_free( ptr ); + if (!(heapPtr = HEAP_GetPtr( heap ))) status = STATUS_INVALID_PARAMETER; else @@ -1614,23 +1609,24 @@ static NTSTATUS heap_reallocate( HEAP *heap, ULONG flags, void *ptr, SIZE_T size list_remove( &entry->entry ); old_block_size += block_get_size( next ); if (!subheap_commit( subheap, block, block_size )) return STATUS_NO_MEMORY; - notify_realloc( block + 1, old_size, size ); + valgrind_notify_resize( block + 1, old_size, size ); shrink_used_block( subheap, block, block_get_flags( block ), old_block_size, block_size, size ); } else { if (flags & HEAP_REALLOC_IN_PLACE_ONLY) return STATUS_NO_MEMORY; if ((status = heap_allocate( heap, flags & ~HEAP_ZERO_MEMORY, size, ret ))) return status; + valgrind_notify_alloc( *ret, size, 0 ); memcpy( *ret, block + 1, old_size ); if (flags & HEAP_ZERO_MEMORY) memset( (char *)*ret + old_size, 0, size - old_size ); - notify_free( ptr ); + valgrind_notify_free( ptr ); free_used_block( subheap, block ); return STATUS_SUCCESS; } } else { - notify_realloc( block + 1, old_size, size ); + valgrind_notify_resize( block + 1, old_size, size ); shrink_used_block( subheap, block, block_get_flags( block ), old_block_size, block_size, size ); }
1
0
0
0
Rémi Bernon : ntdll: Correctly free pending pointer in RtlDestroyHeap.
by Alexandre Julliard
31 May '22
31 May '22
Module: wine Branch: master Commit: 3f52b3a7413e9e0e9a29dd57c24bc66569690fca URL:
https://source.winehq.org/git/wine.git/?a=commit;h=3f52b3a7413e9e0e9a29dd57…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Mon May 30 19:57:55 2022 +0200 ntdll: Correctly free pending pointer in RtlDestroyHeap. It's allocated from the heap itself, should be freed even for the main process heap, and before destroying the CS or notifying valgrind of used block being freed. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> --- dlls/ntdll/heap.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index f9cdb6d8c26..57ceff9cdd1 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -1431,6 +1431,7 @@ HANDLE WINAPI RtlDestroyHeap( HANDLE heap ) HEAP *heapPtr = HEAP_GetPtr( heap ); SUBHEAP *subheap, *next; ARENA_LARGE *arena, *arena_next; + struct block **pending, **tmp; SIZE_T size; void *addr; @@ -1443,6 +1444,15 @@ HANDLE WINAPI RtlDestroyHeap( HANDLE heap ) } if (!heapPtr) return heap; + if ((pending = heapPtr->pending_free)) + { + heapPtr->pending_free = NULL; + for (tmp = pending; *tmp && tmp != pending + MAX_FREE_PENDING; ++tmp) + if ((subheap = find_subheap( heap, *tmp, FALSE ))) + free_used_block( subheap, *tmp ); + RtlFreeHeap( heap, 0, pending ); + } + if (heap == processHeap) return heap; /* cannot delete the main process heap */ /* remove it from the per-process list */ @@ -1470,7 +1480,6 @@ HANDLE WINAPI RtlDestroyHeap( HANDLE heap ) NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE ); } notify_free_all( &heapPtr->subheap ); - RtlFreeHeap( GetProcessHeap(), 0, heapPtr->pending_free ); size = 0; addr = heap; NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE );
1
0
0
0
Rémi Bernon : ntdll: Split valgrind memory access control to separate helpers.
by Alexandre Julliard
31 May '22
31 May '22
Module: wine Branch: master Commit: e4e8cabf2f71f2e5a6d80101060ed7a9022a00ae URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e4e8cabf2f71f2e5a6d80101…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Mon May 30 20:44:59 2022 +0200 ntdll: Split valgrind memory access control to separate helpers. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> --- dlls/ntdll/heap.c | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 7697b8f0354..f9cdb6d8c26 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -307,54 +307,56 @@ static inline BOOL check_subheap( const SUBHEAP *subheap ) static BOOL heap_validate( const HEAP *heap ); -/* mark a block of memory as free for debugging purposes */ -static inline void mark_block_free( void *ptr, SIZE_T size, DWORD flags ) +/* mark a block of memory as innacessible for debugging purposes */ +static inline void valgrind_make_noaccess( void const *ptr, SIZE_T size ) { - if (flags & HEAP_FREE_CHECKING_ENABLED) - { - SIZE_T i; - for (i = 0; i < size / sizeof(DWORD); i++) ((DWORD *)ptr)[i] = ARENA_FREE_FILLER; - } #if defined(VALGRIND_MAKE_MEM_NOACCESS) - VALGRIND_DISCARD( VALGRIND_MAKE_MEM_NOACCESS( ptr, size )); -#elif defined( VALGRIND_MAKE_NOACCESS) - VALGRIND_DISCARD( VALGRIND_MAKE_NOACCESS( ptr, size )); + VALGRIND_DISCARD( VALGRIND_MAKE_MEM_NOACCESS( ptr, size ) ); +#elif defined(VALGRIND_MAKE_NOACCESS) + VALGRIND_DISCARD( VALGRIND_MAKE_NOACCESS( ptr, size ) ); #endif } /* mark a block of memory as initialized for debugging purposes */ -static inline void mark_block_initialized( void *ptr, SIZE_T size ) +static inline void valgrind_make_readable( void const *ptr, SIZE_T size ) { #if defined(VALGRIND_MAKE_MEM_DEFINED) - VALGRIND_DISCARD( VALGRIND_MAKE_MEM_DEFINED( ptr, size )); + VALGRIND_DISCARD( VALGRIND_MAKE_MEM_DEFINED( ptr, size ) ); #elif defined(VALGRIND_MAKE_READABLE) - VALGRIND_DISCARD( VALGRIND_MAKE_READABLE( ptr, size )); + VALGRIND_DISCARD( VALGRIND_MAKE_READABLE( ptr, size ) ); #endif } /* mark a block of memory as uninitialized for debugging purposes */ -static inline void mark_block_uninitialized( void *ptr, SIZE_T size ) +static inline void valgrind_make_writable( void const *ptr, SIZE_T size ) { #if defined(VALGRIND_MAKE_MEM_UNDEFINED) - VALGRIND_DISCARD( VALGRIND_MAKE_MEM_UNDEFINED( ptr, size )); + VALGRIND_DISCARD( VALGRIND_MAKE_MEM_UNDEFINED( ptr, size ) ); #elif defined(VALGRIND_MAKE_WRITABLE) - VALGRIND_DISCARD( VALGRIND_MAKE_WRITABLE( ptr, size )); + VALGRIND_DISCARD( VALGRIND_MAKE_WRITABLE( ptr, size ) ); #endif } +/* mark a block of memory as free for debugging purposes */ +static inline void mark_block_free( void *ptr, SIZE_T size, DWORD flags ) +{ + if (flags & HEAP_FREE_CHECKING_ENABLED) + { + SIZE_T i; + for (i = 0; i < size / sizeof(DWORD); i++) ((DWORD *)ptr)[i] = ARENA_FREE_FILLER; + } + valgrind_make_noaccess( ptr, size ); +} + /* mark a block of memory as a tail block */ static inline void mark_block_tail( void *ptr, SIZE_T size, DWORD flags ) { if (flags & HEAP_TAIL_CHECKING_ENABLED) { - mark_block_uninitialized( ptr, size ); + valgrind_make_writable( ptr, size ); memset( ptr, ARENA_TAIL_FILLER, size ); } -#if defined(VALGRIND_MAKE_MEM_NOACCESS) - VALGRIND_DISCARD( VALGRIND_MAKE_MEM_NOACCESS( ptr, size )); -#elif defined( VALGRIND_MAKE_NOACCESS) - VALGRIND_DISCARD( VALGRIND_MAKE_NOACCESS( ptr, size )); -#endif + valgrind_make_noaccess( ptr, size ); } /* initialize contents of a newly created block of memory */ @@ -362,17 +364,13 @@ static inline void initialize_block( void *ptr, SIZE_T size, SIZE_T unused, DWOR { if (flags & HEAP_ZERO_MEMORY) { - mark_block_initialized( ptr, size ); + valgrind_make_writable( ptr, size ); memset( ptr, 0, size ); } - else + else if (flags & HEAP_FREE_CHECKING_ENABLED) { - mark_block_uninitialized( ptr, size ); - if (flags & HEAP_FREE_CHECKING_ENABLED) - { - memset( ptr, ARENA_INUSE_FILLER, size ); - mark_block_uninitialized( ptr, size ); - } + valgrind_make_writable( ptr, size ); + memset( ptr, ARENA_INUSE_FILLER, size ); } mark_block_tail( (char *)ptr + size, unused, flags ); @@ -679,7 +677,7 @@ static void create_free_block( SUBHEAP *subheap, struct block *block, SIZE_T blo DWORD flags = heap->flags; struct block *next; - mark_block_uninitialized( block, sizeof(*entry) ); + valgrind_make_writable( block, sizeof(*entry) ); block_set_type( block, ARENA_FREE_MAGIC ); block_set_size( block, BLOCK_FLAG_FREE, block_size ); @@ -702,7 +700,7 @@ static void create_free_block( SUBHEAP *subheap, struct block *block, SIZE_T blo { /* set the next block PREV_FREE flag and back pointer */ block_set_size( next, BLOCK_FLAG_PREV_FREE, block_get_size( next ) ); - mark_block_initialized( (struct block **)next - 1, sizeof(struct block *) ); + valgrind_make_writable( (struct block **)next - 1, sizeof(struct block *) ); *((struct block **)next - 1) = block; }
1
0
0
0
Rémi Bernon : ntdll: Fix handling of back pointer in heap_set_debug_flags.
by Alexandre Julliard
31 May '22
31 May '22
Module: wine Branch: master Commit: 75f2af284f160985d95d427dbb9ee2026b5ef1f2 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=75f2af284f160985d95d427d…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Mon May 30 15:14:02 2022 +0200 ntdll: Fix handling of back pointer in heap_set_debug_flags. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> --- dlls/ntdll/heap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 16abc158e55..7697b8f0354 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -1337,8 +1337,9 @@ static void heap_set_debug_flags( HANDLE handle ) if (block_get_flags( block ) & BLOCK_FLAG_FREE) { char *data = (char *)block + block_get_overhead( block ), *end = (char *)block + block_get_size( block ); - if (end >= commit_end) mark_block_free( data, commit_end - data, flags ); - else mark_block_free( data, end - sizeof(struct block *) - data, flags ); + if (next_block( subheap, block )) end -= sizeof(struct block *); + if (end > commit_end) mark_block_free( data, commit_end - data, flags ); + else mark_block_free( data, end - data, flags ); } else {
1
0
0
0
Jinoh Kang : ntdll: Properly parse UDF instruction in ARM.
by Alexandre Julliard
31 May '22
31 May '22
Module: wine Branch: master Commit: e2412025b20e63f8fcad3467c0ffcd7235f3d991 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e2412025b20e63f8fcad3467…
Author: Jinoh Kang <jinoh.kang.kr(a)gmail.com> Date: Sun Dec 5 19:57:16 2021 +0900 ntdll: Properly parse UDF instruction in ARM. Today, the UDF instruction handler code assumes Thumb mode code, and cannot recognise the UDF.W form or equivalent instructions in ARM mode encoding. Fix this by generalising the UDF instruction parser code. Signed-off-by: Jinoh Kang <jinoh.kang.kr(a)gmail.com> --- dlls/ntdll/unix/signal_arm.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/dlls/ntdll/unix/signal_arm.c b/dlls/ntdll/unix/signal_arm.c index ead14303436..c8edf22b170 100644 --- a/dlls/ntdll/unix/signal_arm.c +++ b/dlls/ntdll/unix/signal_arm.c @@ -360,6 +360,35 @@ static inline WORD get_error_code( const ucontext_t *sigcontext ) } +/*********************************************************************** + * get_udf_immediate + * + * Get the immediate operand if the PC is at a UDF instruction. + */ +static inline int get_udf_immediate( const ucontext_t *sigcontext ) +{ + if (CPSR_sig(sigcontext) & 0x20) + { + WORD thumb_insn = *(WORD *)PC_sig(sigcontext); + if ((thumb_insn >> 8) == 0xde) return thumb_insn & 0xff; + if ((thumb_insn & 0xfff0) == 0xf7f0) /* udf.w */ + { + WORD ext = *(WORD *)(PC_sig(sigcontext) + 2); + if ((ext & 0xf000) == 0xa000) return ((thumb_insn & 0xf) << 12) | (ext & 0x0fff); + } + } + else + { + DWORD arm_insn = *(DWORD *)PC_sig(sigcontext); + if ((arm_insn & 0xfff000f0) == 0xe7f000f0) + { + return ((arm_insn >> 4) & 0xfff0) | (arm_insn & 0xf); + } + } + return -1; +} + + /*********************************************************************** * save_context * @@ -812,9 +841,9 @@ static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext ) switch (get_trap_code(signal, context)) { case TRAP_ARM_PRIVINFLT: /* Invalid opcode exception */ - switch (*(WORD *)PC_sig(context)) + switch (get_udf_immediate( context )) { - case 0xdefb: /* __fastfail */ + case 0xfb: /* __fastfail */ { CONTEXT ctx; save_context( &ctx, sigcontext ); @@ -826,7 +855,7 @@ static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext ) NtRaiseException( &rec, &ctx, FALSE ); return; } - case 0xdefe: /* breakpoint */ + case 0xfe: /* breakpoint */ rec.ExceptionCode = EXCEPTION_BREAKPOINT; rec.NumberParameters = 1; break;
1
0
0
0
Jinoh Kang : ntdll: Implement __fastfail().
by Alexandre Julliard
31 May '22
31 May '22
Module: wine Branch: master Commit: c4c9a6951be4299850ca220450b21eeb8843fde5 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=c4c9a6951be4299850ca2204…
Author: Jinoh Kang <jinoh.kang.kr(a)gmail.com> Date: Sun Dec 5 19:56:22 2021 +0900 ntdll: Implement __fastfail(). __fastfail() is used by the Visual C++ runtime and Windows system libraries to signal that the in-process state is corrupted and unrecoverable. If __fastfail() is invoked, the NT kernel raises a second-chance non-continuable exception STATUS_STACK_BUFFER_OVERRUN. This quickly terminates the process, bypassing all in-process exception handlers (since they all rely on the potentially corrupted process state). Signed-off-by: Jinoh Kang <jinoh.kang.kr(a)gmail.com> --- dlls/ntdll/tests/exception.c | 1 - dlls/ntdll/unix/signal_arm.c | 19 +++++++++++++++++-- dlls/ntdll/unix/signal_arm64.c | 16 ++++++++++++++++ dlls/ntdll/unix/signal_i386.c | 8 ++++++++ dlls/ntdll/unix/signal_x86_64.c | 8 ++++++++ 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 0086b18d678..3e76b001147 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -8466,7 +8466,6 @@ static void subtest_fastfail(unsigned int code) } while (de.dwDebugEventCode != EXIT_PROCESS_DEBUG_EVENT); - todo_wine ok(had_ff || broken(had_se) /* Win7 */, "fast fail did not occur\n"); wait_child_process( pi.hProcess ); diff --git a/dlls/ntdll/unix/signal_arm.c b/dlls/ntdll/unix/signal_arm.c index 1fea76f6563..ead14303436 100644 --- a/dlls/ntdll/unix/signal_arm.c +++ b/dlls/ntdll/unix/signal_arm.c @@ -812,13 +812,28 @@ static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext ) switch (get_trap_code(signal, context)) { case TRAP_ARM_PRIVINFLT: /* Invalid opcode exception */ - if (*(WORD *)PC_sig(context) == 0xdefe) /* breakpoint */ + switch (*(WORD *)PC_sig(context)) { + case 0xdefb: /* __fastfail */ + { + CONTEXT ctx; + save_context( &ctx, sigcontext ); + rec.ExceptionCode = STATUS_STACK_BUFFER_OVERRUN; + rec.ExceptionAddress = (void *)ctx.Pc; + rec.ExceptionFlags = EH_NONCONTINUABLE; + rec.NumberParameters = 1; + rec.ExceptionInformation[0] = ctx.R0; + NtRaiseException( &rec, &ctx, FALSE ); + return; + } + case 0xdefe: /* breakpoint */ rec.ExceptionCode = EXCEPTION_BREAKPOINT; rec.NumberParameters = 1; break; + default: + rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; + break; } - rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; break; case TRAP_ARM_PAGEFLT: /* Page fault */ rec.NumberParameters = 2; diff --git a/dlls/ntdll/unix/signal_arm64.c b/dlls/ntdll/unix/signal_arm64.c index 1df97f16f13..45cb3d1bf13 100644 --- a/dlls/ntdll/unix/signal_arm64.c +++ b/dlls/ntdll/unix/signal_arm64.c @@ -908,6 +908,7 @@ static void bus_handler( int signal, siginfo_t *siginfo, void *sigcontext ) static void trap_handler( int signal, siginfo_t *siginfo, void *sigcontext ) { EXCEPTION_RECORD rec = { 0 }; + ucontext_t *context = sigcontext; switch (siginfo->si_code) { @@ -916,6 +917,21 @@ static void trap_handler( int signal, siginfo_t *siginfo, void *sigcontext ) break; case TRAP_BRKPT: default: + /* debug exceptions do not update ESR on Linux, so we fetch the instruction directly. */ + if (!(PSTATE_sig( context ) & 0x10) && /* AArch64 (not WoW) */ + !(PC_sig( context ) & 3) && + *(ULONG *)PC_sig( context ) == 0xd43e0060UL) /* brk #0xf003 -> __fastfail */ + { + CONTEXT ctx; + save_context( &ctx, sigcontext ); + rec.ExceptionCode = STATUS_STACK_BUFFER_OVERRUN; + rec.ExceptionAddress = (void *)ctx.Pc; + rec.ExceptionFlags = EH_NONCONTINUABLE; + rec.NumberParameters = 1; + rec.ExceptionInformation[0] = ctx.u.X[0]; + NtRaiseException( &rec, &ctx, FALSE ); + return; + } rec.ExceptionCode = EXCEPTION_BREAKPOINT; rec.NumberParameters = 1; break; diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c index e2a6148d609..7be0c39c424 100644 --- a/dlls/ntdll/unix/signal_i386.c +++ b/dlls/ntdll/unix/signal_i386.c @@ -1676,6 +1676,14 @@ static BOOL handle_interrupt( unsigned int interrupt, ucontext_t *sigcontext, vo switch(interrupt) { + case 0x29: + /* __fastfail: process state is corrupted */ + rec->ExceptionCode = STATUS_STACK_BUFFER_OVERRUN; + rec->ExceptionFlags = EH_NONCONTINUABLE; + rec->NumberParameters = 1; + rec->ExceptionInformation[0] = context->Ecx; + NtRaiseException( rec, context, FALSE ); + return TRUE; case 0x2d: if (!is_wow64) { diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c index e3179e2f1b0..6c87e347eac 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -2486,6 +2486,14 @@ static inline BOOL handle_interrupt( ucontext_t *sigcontext, EXCEPTION_RECORD *r switch (ERROR_sig(sigcontext) >> 3) { + case 0x29: + /* __fastfail: process state is corrupted */ + rec->ExceptionCode = STATUS_STACK_BUFFER_OVERRUN; + rec->ExceptionFlags = EH_NONCONTINUABLE; + rec->NumberParameters = 1; + rec->ExceptionInformation[0] = context->Rcx; + NtRaiseException( rec, context, FALSE ); + return TRUE; case 0x2c: rec->ExceptionCode = STATUS_ASSERTION_FAILURE; break;
1
0
0
0
Jinoh Kang : ntdll/tests: Add tests for __fastfail().
by Alexandre Julliard
31 May '22
31 May '22
Module: wine Branch: master Commit: 7fbe8b8ebfa0d13dd318fd1d3beaf04872a47ed0 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=7fbe8b8ebfa0d13dd318fd1d…
Author: Jinoh Kang <jinoh.kang.kr(a)gmail.com> Date: Wed Dec 8 03:14:06 2021 +0900 ntdll/tests: Add tests for __fastfail(). Signed-off-by: Jinoh Kang <jinoh.kang.kr(a)gmail.com> --- dlls/ntdll/tests/exception.c | 93 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 14ffdb00d78..0086b18d678 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -8417,6 +8417,91 @@ static void test_ripevent(DWORD numexc) pRtlRemoveVectoredExceptionHandler(vectored_handler); } +static void subtest_fastfail(unsigned int code) +{ + char cmdline[MAX_PATH]; + PROCESS_INFORMATION pi; + STARTUPINFOA si = { 0 }; + DEBUG_EVENT de; + DWORD continuestatus; + BOOL ret; + BOOL had_ff = FALSE, had_se = FALSE; + + sprintf(cmdline, "%s %s %s %u", my_argv[0], my_argv[1], "fastfail", code); + si.cb = sizeof(si); + ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, DEBUG_PROCESS, NULL, NULL, &si, &pi); + ok(ret, "could not create child process error: %lu\n", GetLastError()); + if (!ret) + return; + + do + { + continuestatus = DBG_CONTINUE; + ok(WaitForDebugEvent(&de, INFINITE), "reading debug event\n"); + + if (de.dwDebugEventCode == EXCEPTION_DEBUG_EVENT) + { + if (de.u.Exception.ExceptionRecord.ExceptionCode == STATUS_STACK_BUFFER_OVERRUN) + { + ok(!de.u.Exception.dwFirstChance, "must be a second chance exception\n"); + ok(de.u.Exception.ExceptionRecord.NumberParameters == 1, "expected exactly one parameter, got %lu\n", + de.u.Exception.ExceptionRecord.NumberParameters); + ok(de.u.Exception.ExceptionRecord.ExceptionInformation[0] == code, "expected %u for code, got %Iu\n", + code, de.u.Exception.ExceptionRecord.ExceptionInformation[0]); + had_ff = TRUE; + } + + if (de.u.Exception.dwFirstChance) + { + continuestatus = DBG_EXCEPTION_NOT_HANDLED; + } + else + { + had_se = TRUE; + pNtTerminateProcess(pi.hProcess, 0); + } + } + + ContinueDebugEvent(de.dwProcessId, de.dwThreadId, continuestatus); + + } while (de.dwDebugEventCode != EXIT_PROCESS_DEBUG_EVENT); + + todo_wine + ok(had_ff || broken(had_se) /* Win7 */, "fast fail did not occur\n"); + + wait_child_process( pi.hProcess ); + ret = CloseHandle(pi.hThread); + ok(ret, "error %lu\n", GetLastError()); + ret = CloseHandle(pi.hProcess); + ok(ret, "error %lu\n", GetLastError()); + + return; +} + +static void test_fastfail(void) +{ + unsigned int codes[] = { + FAST_FAIL_LEGACY_GS_VIOLATION, + FAST_FAIL_VTGUARD_CHECK_FAILURE, + FAST_FAIL_STACK_COOKIE_CHECK_FAILURE, + FAST_FAIL_CORRUPT_LIST_ENTRY, + FAST_FAIL_INCORRECT_STACK, + FAST_FAIL_INVALID_ARG, + FAST_FAIL_GS_COOKIE_INIT, + FAST_FAIL_FATAL_APP_EXIT, + FAST_FAIL_INVALID_FAST_FAIL_CODE, + 0xdeadbeefUL, + }; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(codes); i++) + { + winetest_push_context("__fastfail(%#x)", codes[i]); + subtest_fastfail(codes[i]); + winetest_pop_context(); + } +} + static DWORD breakpoint_exceptions; static LONG CALLBACK breakpoint_handler(EXCEPTION_POINTERS *ExceptionInfo) @@ -10664,6 +10749,13 @@ START_TEST(exception) if (my_argc >= 4) { void *addr; + + if (strcmp(my_argv[2], "fastfail") == 0) + { + __fastfail(strtoul(my_argv[3], NULL, 0)); + return; + } + sscanf( my_argv[3], "%p", &addr ); if (addr != &test_stage) @@ -10811,6 +10903,7 @@ START_TEST(exception) test_thread_context(); test_outputdebugstring(1, FALSE); test_ripevent(1); + test_fastfail(); test_breakpoint(1); test_closehandle(0, (HANDLE)0xdeadbeef); /* Call of Duty WWII writes to BeingDebugged then closes an invalid handle,
1
0
0
0
Jinoh Kang : include: Define fast fail codes and the __fastfail() intrinsic.
by Alexandre Julliard
31 May '22
31 May '22
Module: wine Branch: master Commit: 253a2e2edb618371d7ab63e7c406134f1342e2c4 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=253a2e2edb618371d7ab63e7…
Author: Jinoh Kang <jinoh.kang.kr(a)gmail.com> Date: Wed Dec 8 03:12:41 2021 +0900 include: Define fast fail codes and the __fastfail() intrinsic. Signed-off-by: Jinoh Kang <jinoh.kang.kr(a)gmail.com> --- include/winnt.h | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/include/winnt.h b/include/winnt.h index 7aafbcf0cfe..87c4b4da92d 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -934,6 +934,78 @@ NTSYSAPI PSLIST_ENTRY WINAPI RtlInterlockedPushEntrySList(PSLIST_HEADER, PSLIST_ NTSYSAPI WORD WINAPI RtlQueryDepthSList(PSLIST_HEADER); +/* Fast fail (__fastfail) codes */ + +#define FAST_FAIL_LEGACY_GS_VIOLATION 0 +#define FAST_FAIL_VTGUARD_CHECK_FAILURE 1 +#define FAST_FAIL_STACK_COOKIE_CHECK_FAILURE 2 +#define FAST_FAIL_CORRUPT_LIST_ENTRY 3 +#define FAST_FAIL_INCORRECT_STACK 4 +#define FAST_FAIL_INVALID_ARG 5 +#define FAST_FAIL_GS_COOKIE_INIT 6 +#define FAST_FAIL_FATAL_APP_EXIT 7 +#define FAST_FAIL_RANGE_CHECK_FAILURE 8 +#define FAST_FAIL_UNSAFE_REGISTRY_ACCESS 9 +#define FAST_FAIL_GUARD_ICALL_CHECK_FAILURE 10 +#define FAST_FAIL_GUARD_WRITE_CHECK_FAILURE 11 +#define FAST_FAIL_INVALID_FIBER_SWITCH 12 +#define FAST_FAIL_INVALID_SET_OF_CONTEXT 13 +#define FAST_FAIL_INVALID_REFERENCE_COUNT 14 +#define FAST_FAIL_INVALID_JUMP_BUFFER 18 +#define FAST_FAIL_MRDATA_MODIFIED 19 +#define FAST_FAIL_CERTIFICATION_FAILURE 20 +#define FAST_FAIL_INVALID_EXCEPTION_CHAIN 21 +#define FAST_FAIL_CRYPTO_LIBRARY 22 +#define FAST_FAIL_INVALID_CALL_IN_DLL_CALLOUT 23 +#define FAST_FAIL_INVALID_IMAGE_BASE 24 +#define FAST_FAIL_DLOAD_PROTECTION_FAILURE 25 +#define FAST_FAIL_UNSAFE_EXTENSION_CALL 26 +#define FAST_FAIL_DEPRECATED_SERVICE_INVOKED 27 +#define FAST_FAIL_INVALID_BUFFER_ACCESS 28 +#define FAST_FAIL_INVALID_BALANCED_TREE 29 +#define FAST_FAIL_INVALID_NEXT_THREAD 30 +#define FAST_FAIL_GUARD_ICALL_CHECK_SUPPRESSED 31 +#define FAST_FAIL_APCS_DISABLED 32 +#define FAST_FAIL_INVALID_IDLE_STATE 33 +#define FAST_FAIL_MRDATA_PROTECTION_FAILURE 34 +#define FAST_FAIL_UNEXPECTED_HEAP_EXCEPTION 35 +#define FAST_FAIL_INVALID_LOCK_STATE 36 +#define FAST_FAIL_GUARD_JUMPTABLE 37 +#define FAST_FAIL_INVALID_LONGJUMP_TARGET 38 +#define FAST_FAIL_INVALID_DISPATCH_CONTEXT 39 +#define FAST_FAIL_INVALID_THREAD 40 +#define FAST_FAIL_INVALID_SYSCALL_NUMBER 41 +#define FAST_FAIL_INVALID_FILE_OPERATION 42 +#define FAST_FAIL_LPAC_ACCESS_DENIED 43 +#define FAST_FAIL_GUARD_SS_FAILURE 44 +#define FAST_FAIL_LOADER_CONTINUITY_FAILURE 45 +#define FAST_FAIL_GUARD_EXPORT_SUPPRESSION_FAILURE 46 +#define FAST_FAIL_INVALID_CONTROL_STACK 47 +#define FAST_FAIL_SET_CONTEXT_DENIED 48 +#define FAST_FAIL_INVALID_IAT 49 +#define FAST_FAIL_HEAP_METADATA_CORRUPTION 50 +#define FAST_FAIL_PAYLOAD_RESTRICTION_VIOLATION 51 +#define FAST_FAIL_LOW_LABEL_ACCESS_DENIED 52 +#define FAST_FAIL_ENCLAVE_CALL_FAILURE 53 +#define FAST_FAIL_UNHANDLED_LSS_EXCEPTON 54 +#define FAST_FAIL_ADMINLESS_ACCESS_DENIED 55 +#define FAST_FAIL_UNEXPECTED_CALL 56 +#define FAST_FAIL_CONTROL_INVALID_RETURN_ADDRESS 57 +#define FAST_FAIL_UNEXPECTED_HOST_BEHAVIOR 58 +#define FAST_FAIL_FLAGS_CORRUPTION 59 +#define FAST_FAIL_VEH_CORRUPTION 60 +#define FAST_FAIL_ETW_CORRUPTION 61 +#define FAST_FAIL_RIO_ABORT 62 +#define FAST_FAIL_INVALID_PFN 63 +#define FAST_FAIL_GUARD_ICALL_CHECK_FAILURE_XFG 64 +#define FAST_FAIL_CAST_GUARD 65 +#define FAST_FAIL_HOST_VISIBILITY_CHANGE 66 +#define FAST_FAIL_KERNEL_CET_SHADOW_STACK_ASSIST 67 +#define FAST_FAIL_PATCH_CALLBACK_FAILED 68 +#define FAST_FAIL_NTDLL_PATCH_FAILED 69 +#define FAST_FAIL_INVALID_FLS_DATA 70 +#define FAST_FAIL_INVALID_FAST_FAIL_CODE 0xFFFFFFFF + /* Heap flags */ #define HEAP_NO_SERIALIZE 0x00000001 @@ -6318,6 +6390,7 @@ typedef enum _PROCESS_MITIGATION_POLICY #pragma intrinsic(_InterlockedDecrement16) #pragma intrinsic(_InterlockedOr) #pragma intrinsic(_InterlockedXor) +#pragma intrinsic(__fastfail) BOOLEAN _BitScanForward(unsigned long*,unsigned long); BOOLEAN _BitScanReverse(unsigned long*,unsigned long); @@ -6332,6 +6405,7 @@ long _InterlockedIncrement(long volatile*); short _InterlockedIncrement16(short volatile*); long _InterlockedOr(long volatile *,long); long _InterlockedXor(long volatile *,long); +DECLSPEC_NORETURN void __fastfail(unsigned int); static FORCEINLINE long InterlockedAdd( long volatile *dest, long val ) { @@ -6514,6 +6588,19 @@ static FORCEINLINE void MemoryBarrier(void) __sync_synchronize(); } +static FORCEINLINE DECLSPEC_NORETURN void __fastfail(unsigned int code) +{ +#if defined(__x86_64__) || defined(__i386__) + for (;;) __asm__ __volatile__( "int $0x29" :: "c" ((ULONG_PTR)code) : "memory" ); +#elif defined(__aarch64__) + register ULONG_PTR val __asm__("x0") = code; + for (;;) __asm__ __volatile__( "brk #0xf003" :: "r" (val) : "memory" ); +#elif defined(__arm__) + register ULONG_PTR val __asm__("r0") = code; + for (;;) __asm__ __volatile__( "udf #0xfb" :: "r" (val) : "memory" ); +#endif +} + #endif /* __GNUC__ */ #ifdef _WIN64
1
0
0
0
Alexandre Julliard : make_unicode: Get rid of the old collation table.
by Alexandre Julliard
31 May '22
31 May '22
Module: wine Branch: master Commit: 66fb3bf63134647f4ca4d326ea8b857da868e8f0 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=66fb3bf63134647f4ca4d326…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon May 30 22:41:06 2022 +0200 make_unicode: Get rid of the old collation table. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/Makefile.in | 1 - dlls/kernelbase/collation.c | 1393 ------------------------------------------- tools/make_unicode | 105 ---- 3 files changed, 1499 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=66fb3bf63134647f4ca4…
1
0
0
0
Alexandre Julliard : kernelbase: Remove no longer needed case table initialization.
by Alexandre Julliard
31 May '22
31 May '22
Module: wine Branch: master Commit: 99cbbb8998b58f9279a7785689eb5842782902be URL:
https://source.winehq.org/git/wine.git/?a=commit;h=99cbbb8998b58f9279a77856…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue May 31 11:42:38 2022 +0200 kernelbase: Remove no longer needed case table initialization. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/locale.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c index 7152490268f..6ec80596355 100644 --- a/dlls/kernelbase/locale.c +++ b/dlls/kernelbase/locale.c @@ -300,7 +300,8 @@ struct norm_table /* WORD[] composition character sequences */ }; -static NLSTABLEINFO nls_info; +static CPTABLEINFO ansi_cpinfo; +static CPTABLEINFO oem_cpinfo; static UINT unix_cp = CP_UTF8; static LCID system_lcid; static LCID user_lcid; @@ -1933,7 +1934,8 @@ void init_locale( HMODULE module ) ansi_ptr = NtCurrentTeb()->Peb->AnsiCodePageData ? NtCurrentTeb()->Peb->AnsiCodePageData : utf8; oem_ptr = NtCurrentTeb()->Peb->OemCodePageData ? NtCurrentTeb()->Peb->OemCodePageData : utf8; - RtlInitNlsTables( ansi_ptr, oem_ptr, (USHORT *)sort.casemap, &nls_info ); + RtlInitCodePageTable( ansi_ptr, &ansi_cpinfo ); + RtlInitCodePageTable( oem_ptr, &oem_cpinfo ); RegCreateKeyExW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Nls", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &nls_key, NULL ); @@ -2092,14 +2094,14 @@ static WCHAR compose_chars( WCHAR ch1, WCHAR ch2 ) static UINT get_locale_codepage( const NLS_LOCALE_DATA *locale, ULONG flags ) { UINT ret = locale->idefaultansicodepage; - if ((flags & LOCALE_USE_CP_ACP) || ret == CP_UTF8) ret = nls_info.AnsiTableInfo.CodePage; + if ((flags & LOCALE_USE_CP_ACP) || ret == CP_UTF8) ret = ansi_cpinfo.CodePage; return ret; } static UINT get_lcid_codepage( LCID lcid, ULONG flags ) { - UINT ret = nls_info.AnsiTableInfo.CodePage; + UINT ret = ansi_cpinfo.CodePage; if (!(flags & LOCALE_USE_CP_ACP) && lcid != system_lcid) { @@ -2121,9 +2123,9 @@ static const CPTABLEINFO *get_codepage_table( UINT codepage ) switch (codepage) { case CP_ACP: - return &nls_info.AnsiTableInfo; + return &ansi_cpinfo; case CP_OEMCP: - return &nls_info.OemTableInfo; + return &oem_cpinfo; case CP_MACCP: codepage = system_locale->idefaultmaccodepage; break; @@ -2131,8 +2133,8 @@ static const CPTABLEINFO *get_codepage_table( UINT codepage ) codepage = get_lcid_codepage( NtCurrentTeb()->CurrentLocale, 0 ); break; } - if (codepage == nls_info.AnsiTableInfo.CodePage) return &nls_info.AnsiTableInfo; - if (codepage == nls_info.OemTableInfo.CodePage) return &nls_info.OemTableInfo; + if (codepage == ansi_cpinfo.CodePage) return &ansi_cpinfo; + if (codepage == oem_cpinfo.CodePage) return &oem_cpinfo; if (codepage == CP_UTF8) return &utf8_cpinfo; if (codepage == CP_UTF7) return &utf7_cpinfo; @@ -5271,7 +5273,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH FormatMessageW( DWORD flags, const void *source, */ UINT WINAPI GetACP(void) { - return nls_info.AnsiTableInfo.CodePage; + return ansi_cpinfo.CodePage; } @@ -5653,7 +5655,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetNLSVersionEx( NLS_FUNCTION func, const WCHAR *l */ UINT WINAPI GetOEMCP(void) { - return nls_info.OemTableInfo.CodePage; + return oem_cpinfo.CodePage; } @@ -6149,7 +6151,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH IsCharXDigitW( WCHAR wc ) */ BOOL WINAPI DECLSPEC_HOTPATCH IsDBCSLeadByte( BYTE testchar ) { - return nls_info.AnsiTableInfo.DBCSCodePage && nls_info.AnsiTableInfo.DBCSOffsets[testchar]; + return ansi_cpinfo.DBCSCodePage && ansi_cpinfo.DBCSOffsets[testchar]; }
1
0
0
0
← Newer
1
2
3
4
5
6
...
91
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
Results per page:
10
25
50
100
200