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
September 2017
----- 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
446 discussions
Start a n
N
ew thread
Alexandre Julliard : ntdll: Ignore attempts to commit pages in an already committed anonymous mapping.
by Alexandre Julliard
08 Sep '17
08 Sep '17
Module: wine Branch: master Commit: 26c59d845e8dd1111c976c54e1667504f2888652 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=26c59d845e8dd1111c976c54e…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Fri Sep 8 15:47:28 2017 +0200 ntdll: Ignore attempts to commit pages in an already committed anonymous mapping. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/tests/virtual.c | 96 ++++++++++++++++++++++++++++++++++++++++++- dlls/ntdll/virtual.c | 2 +- 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 76953d5..9b99464 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -775,7 +775,7 @@ static void test_MapViewOfFile(void) /* read/write mapping with SEC_RESERVE */ mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE | SEC_RESERVE, 0, MAPPING_SIZE, NULL); - ok(mapping != INVALID_HANDLE_VALUE, "CreateFileMappingA failed with error %d\n", GetLastError()); + ok(mapping != 0, "CreateFileMappingA failed with error %d\n", GetLastError()); status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info, sizeof(section_info), NULL ); ok( !status, "NtQuerySection failed err %x\n", status ); @@ -863,6 +863,100 @@ static void test_MapViewOfFile(void) ok(ret, "UnmapViewOfFile failed with error %d\n", GetLastError()); CloseHandle(mapping); + /* same thing with SEC_COMMIT */ + mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE | SEC_COMMIT, 0, MAPPING_SIZE, NULL); + ok(mapping != 0, "CreateFileMappingA failed with error %d\n", GetLastError()); + status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info, + sizeof(section_info), NULL ); + ok( !status, "NtQuerySection failed err %x\n", status ); + ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr %08x\n", + section_info.Attributes ); + ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress ); + ok( section_info.Size.QuadPart == MAPPING_SIZE, "NtQuerySection wrong size %x%08x / %08x\n", + section_info.Size.u.HighPart, section_info.Size.u.LowPart, MAPPING_SIZE ); + + ptr = MapViewOfFile(mapping, FILE_MAP_WRITE, 0, 0, 0); + ok(ptr != NULL, "MapViewOfFile failed with error %d\n", GetLastError()); + + ret = VirtualQuery(ptr, &info, sizeof(info)); + ok(ret, "VirtualQuery failed with error %d\n", GetLastError()); + ok(info.BaseAddress == ptr, "wrong BaseAddress %p/%p\n", ptr, info.BaseAddress); + ok(info.AllocationBase == ptr, "wrong AllocationBase %p/%p\n", ptr, info.AllocationBase); + ok(info.RegionSize == MAPPING_SIZE, "wrong RegionSize 0x%lx\n", info.RegionSize); + ok(info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State); + ok(info.AllocationProtect == PAGE_READWRITE, "wrong AllocationProtect 0x%x\n", info.AllocationProtect); + ok(info.Protect == PAGE_READWRITE, "wrong Protect 0x%x\n", info.Protect); + ok(info.Type == MEM_MAPPED, "wrong Type 0x%x\n", info.Type); + + ptr = VirtualAlloc(ptr, 0x10000, MEM_COMMIT, PAGE_READONLY); + ok(ptr != NULL, "VirtualAlloc failed with error %d\n", GetLastError()); + + ret = VirtualQuery(ptr, &info, sizeof(info)); + ok(ret, "VirtualQuery failed with error %d\n", GetLastError()); + ok(info.BaseAddress == ptr, "wrong BaseAddress %p/%p\n", ptr, info.BaseAddress); + ok(info.AllocationBase == ptr, "wrong AllocationBase %p/%p\n", ptr, info.AllocationBase); + ok(info.RegionSize == 0x10000, "wrong RegionSize 0x%lx\n", info.RegionSize); + ok(info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State); + ok(info.AllocationProtect == PAGE_READWRITE, "wrong AllocationProtect 0x%x\n", info.AllocationProtect); + ok(info.Protect == PAGE_READONLY, "wrong Protect 0x%x\n", info.Protect); + ok(info.Type == MEM_MAPPED, "wrong Type 0x%x\n", info.Type); + + addr = VirtualAlloc( ptr, MAPPING_SIZE, MEM_RESET, PAGE_READONLY ); + ok( addr == ptr, "VirtualAlloc failed with error %u\n", GetLastError() ); + + ret = VirtualFree( ptr, 0x10000, MEM_DECOMMIT ); + ok( !ret, "VirtualFree succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "VirtualFree failed with %u\n", GetLastError() ); + + ret = UnmapViewOfFile(ptr); + ok(ret, "UnmapViewOfFile failed with error %d\n", GetLastError()); + CloseHandle(mapping); + + /* same thing with SEC_NOCACHE (only supported on recent Windows versions) */ + mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE | SEC_COMMIT | SEC_NOCACHE, + 0, MAPPING_SIZE, NULL); + ok(mapping != 0, "CreateFileMappingA failed with error %d\n", GetLastError()); + status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info, + sizeof(section_info), NULL ); + ok( !status, "NtQuerySection failed err %x\n", status ); + ok( section_info.Attributes == (SEC_COMMIT | SEC_NOCACHE) || + broken(section_info.Attributes == SEC_COMMIT), + "NtQuerySection wrong attr %08x\n", section_info.Attributes ); + if (section_info.Attributes & SEC_NOCACHE) + { + ptr = MapViewOfFile(mapping, FILE_MAP_WRITE, 0, 0, 0); + ok(ptr != NULL, "MapViewOfFile failed with error %d\n", GetLastError()); + + ret = VirtualQuery(ptr, &info, sizeof(info)); + ok(ret, "VirtualQuery failed with error %d\n", GetLastError()); + ok(info.BaseAddress == ptr, "wrong BaseAddress %p/%p\n", ptr, info.BaseAddress); + ok(info.AllocationBase == ptr, "wrong AllocationBase %p/%p\n", ptr, info.AllocationBase); + ok(info.RegionSize == MAPPING_SIZE, "wrong RegionSize 0x%lx\n", info.RegionSize); + ok(info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State); + ok(info.AllocationProtect == (PAGE_READWRITE | PAGE_NOCACHE), + "wrong AllocationProtect 0x%x\n", info.AllocationProtect); + ok(info.Protect == (PAGE_READWRITE | PAGE_NOCACHE), "wrong Protect 0x%x\n", info.Protect); + ok(info.Type == MEM_MAPPED, "wrong Type 0x%x\n", info.Type); + + ptr = VirtualAlloc(ptr, 0x10000, MEM_COMMIT, PAGE_READONLY); + ok(ptr != NULL, "VirtualAlloc failed with error %d\n", GetLastError()); + + ret = VirtualQuery(ptr, &info, sizeof(info)); + ok(ret, "VirtualQuery failed with error %d\n", GetLastError()); + ok(info.BaseAddress == ptr, "wrong BaseAddress %p/%p\n", ptr, info.BaseAddress); + ok(info.AllocationBase == ptr, "wrong AllocationBase %p/%p\n", ptr, info.AllocationBase); + ok(info.RegionSize == 0x10000, "wrong RegionSize 0x%lx\n", info.RegionSize); + ok(info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State); + ok(info.AllocationProtect == (PAGE_READWRITE | PAGE_NOCACHE), + "wrong AllocationProtect 0x%x\n", info.AllocationProtect); + ok(info.Protect == (PAGE_READONLY | PAGE_NOCACHE), "wrong Protect 0x%x\n", info.Protect); + ok(info.Type == MEM_MAPPED, "wrong Type 0x%x\n", info.Type); + + ret = UnmapViewOfFile(ptr); + ok(ret, "UnmapViewOfFile failed with error %d\n", GetLastError()); + } + CloseHandle(mapping); + addr = VirtualAlloc(NULL, 0x10000, MEM_COMMIT, PAGE_READONLY ); ok( addr != NULL, "VirtualAlloc failed with error %u\n", GetLastError() ); diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 8cf09bd..0505617 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -2165,7 +2165,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_ else /* commit the pages */ { if (!(view = VIRTUAL_FindView( base, size ))) status = STATUS_NOT_MAPPED_VIEW; - else if (view->mapping && !(view->protect & SEC_RESERVE)) status = STATUS_ALREADY_COMMITTED; + else if (view->protect & SEC_FILE) status = STATUS_ALREADY_COMMITTED; else if (!VIRTUAL_SetProt( view, base, size, vprot )) status = STATUS_ACCESS_DENIED; else if (view->protect & SEC_RESERVE) {
1
0
0
0
Alexandre Julliard : ntdll: Store the SEC_* section flags directly in the view protection.
by Alexandre Julliard
08 Sep '17
08 Sep '17
Module: wine Branch: master Commit: 5073beaefe73de6cae50c97c3c3ec91d3d26b27f URL:
http://source.winehq.org/git/wine.git/?a=commit;h=5073beaefe73de6cae50c97c3…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Fri Sep 8 15:37:12 2017 +0200 ntdll: Store the SEC_* section flags directly in the view protection. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/virtual.c | 45 +++++++++++++++++++----------------------- include/wine/server_protocol.h | 6 ++---- server/protocol.def | 6 ++---- 3 files changed, 24 insertions(+), 33 deletions(-) diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 8fb11e8..8cf09bd 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -72,7 +72,7 @@ struct file_view size_t size; /* size in bytes */ HANDLE mapping; /* handle to the file mapping */ unsigned int map_protect; /* mapping protection */ - unsigned int protect; /* protection for all pages at allocation time */ + unsigned int protect; /* protection for all pages at allocation time and SEC_* flags */ }; @@ -727,11 +727,11 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz * * Convert page protections to Win32 flags. */ -static DWORD VIRTUAL_GetWin32Prot( BYTE vprot ) +static DWORD VIRTUAL_GetWin32Prot( BYTE vprot, unsigned int map_prot ) { DWORD ret = VIRTUAL_Win32Flags[vprot & 0x0f]; - if (vprot & VPROT_NOCACHE) ret |= PAGE_NOCACHE; if (vprot & VPROT_GUARD) ret |= PAGE_GUARD; + if (map_prot & SEC_NOCACHE) ret |= PAGE_NOCACHE; return ret; } @@ -785,7 +785,6 @@ static NTSTATUS get_vprot_flags( DWORD protect, unsigned int *vprot, BOOL image return STATUS_INVALID_PAGE_PROTECTION; } if (protect & PAGE_GUARD) *vprot |= VPROT_GUARD; - if (protect & PAGE_NOCACHE) *vprot |= VPROT_NOCACHE; return STATUS_SUCCESS; } @@ -1148,7 +1147,7 @@ static SIZE_T get_committed_size( struct file_view *view, void *base, BYTE *vpro start = ((char *)base - (char *)view->base) >> page_shift; *vprot = get_page_vprot( base ); - if (view->mapping && !(view->protect & VPROT_COMMITTED)) + if (view->protect & SEC_RESERVE) { SIZE_T ret = 0; SERVER_START_REQ( get_mapping_committed_range ) @@ -1295,12 +1294,12 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz server_enter_uninterrupted_section( &csVirtual, &sigset ); if (base >= (char *)address_space_start) /* make sure the DOS area remains free */ - status = map_view( &view, base, total_size, mask, FALSE, - VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY | VPROT_IMAGE ); + status = map_view( &view, base, total_size, mask, FALSE, SEC_IMAGE | SEC_FILE | + VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY ); if (status != STATUS_SUCCESS) - status = map_view( &view, NULL, total_size, mask, FALSE, - VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY | VPROT_IMAGE ); + status = map_view( &view, NULL, total_size, mask, FALSE, SEC_IMAGE | SEC_FILE | + VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY ); if (status != STATUS_SUCCESS) goto error; @@ -1633,7 +1632,7 @@ NTSTATUS virtual_create_builtin_view( void *module ) size = ROUND_SIZE( module, size ); base = ROUND_ADDR( module, page_mask ); server_enter_uninterrupted_section( &csVirtual, &sigset ); - status = create_view( &view, base, size, VPROT_SYSTEM | VPROT_IMAGE | + status = create_view( &view, base, size, SEC_IMAGE | SEC_FILE | VPROT_SYSTEM | VPROT_COMMITTED | VPROT_READ | VPROT_WRITECOPY | VPROT_EXEC ); if (!status) TRACE( "created %p-%p\n", base, (char *)base + size ); server_leave_uninterrupted_section( &csVirtual, &sigset ); @@ -2103,6 +2102,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_ if (vprot & VPROT_WRITECOPY) return STATUS_INVALID_PAGE_PROTECTION; vprot |= VPROT_VALLOC; if (type & MEM_COMMIT) vprot |= VPROT_COMMITTED; + if (protect & PAGE_NOCACHE) vprot |= SEC_NOCACHE; if (*ret) { @@ -2165,9 +2165,9 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_ else /* commit the pages */ { if (!(view = VIRTUAL_FindView( base, size ))) status = STATUS_NOT_MAPPED_VIEW; - else if (view->mapping && (view->protect & VPROT_COMMITTED)) status = STATUS_ALREADY_COMMITTED; + else if (view->mapping && !(view->protect & SEC_RESERVE)) status = STATUS_ALREADY_COMMITTED; else if (!VIRTUAL_SetProt( view, base, size, vprot )) status = STATUS_ACCESS_DENIED; - else if (view->mapping && !(view->protect & VPROT_COMMITTED)) + else if (view->protect & SEC_RESERVE) { SERVER_START_REQ( add_mapping_committed_range ) { @@ -2358,7 +2358,7 @@ NTSTATUS WINAPI NtProtectVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T /* Make sure all the pages are committed */ if (get_committed_size( view, base, &vprot ) >= size && (vprot & VPROT_COMMITTED)) { - if (!(status = get_vprot_flags( new_prot, &new_vprot, view->protect & VPROT_IMAGE ))) + if (!(status = get_vprot_flags( new_prot, &new_vprot, view->protect & SEC_IMAGE ))) { if ((new_vprot & VPROT_WRITECOPY) && (view->protect & VPROT_VALLOC)) status = STATUS_INVALID_PAGE_PROTECTION; @@ -2367,9 +2367,7 @@ NTSTATUS WINAPI NtProtectVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T if (!view->mapping || is_compatible_protection( view, new_vprot )) { new_vprot |= VPROT_COMMITTED; - if (view->protect & VPROT_NOCACHE) new_vprot |= VPROT_NOCACHE; - else new_vprot &= ~VPROT_NOCACHE; - if (old_prot) *old_prot = VIRTUAL_GetWin32Prot( vprot ); + if (old_prot) *old_prot = VIRTUAL_GetWin32Prot( vprot, view->protect ); if (!VIRTUAL_SetProt( view, base, size, new_vprot )) status = STATUS_ACCESS_DENIED; } else status = STATUS_INVALID_PAGE_PROTECTION; @@ -2556,9 +2554,9 @@ NTSTATUS WINAPI NtQueryVirtualMemory( HANDLE process, LPCVOID addr, SIZE_T range_size = get_committed_size( view, base, &vprot ); info->State = (vprot & VPROT_COMMITTED) ? MEM_COMMIT : MEM_RESERVE; - info->Protect = (vprot & VPROT_COMMITTED) ? VIRTUAL_GetWin32Prot( vprot ) : 0; - info->AllocationProtect = VIRTUAL_GetWin32Prot( view->protect ); - if (view->protect & VPROT_IMAGE) info->Type = MEM_IMAGE; + info->Protect = (vprot & VPROT_COMMITTED) ? VIRTUAL_GetWin32Prot( vprot, view->protect ) : 0; + info->AllocationProtect = VIRTUAL_GetWin32Prot( view->protect, view->protect ); + if (view->protect & SEC_IMAGE) info->Type = MEM_IMAGE; else if (view->protect & VPROT_VALLOC) info->Type = MEM_PRIVATE; else info->Type = MEM_MAPPED; for (ptr = base; ptr < base + range_size; ptr += page_size) @@ -2807,10 +2805,6 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p SERVER_END_REQ; if (res) return res; - if (!(sec_flags & SEC_RESERVE)) map_vprot |= VPROT_COMMITTED; - if (sec_flags & SEC_NOCACHE) map_vprot |= VPROT_NOCACHE; - if (sec_flags & SEC_IMAGE) map_vprot |= VPROT_IMAGE; - if ((res = server_get_unix_fd( handle, 0, &unix_handle, &needs_close, NULL, NULL ))) goto done; if (sec_flags & SEC_IMAGE) @@ -2875,7 +2869,8 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p server_enter_uninterrupted_section( &csVirtual, &sigset ); get_vprot_flags( protect, &vprot, sec_flags & SEC_IMAGE ); - vprot |= (map_vprot & VPROT_COMMITTED); + vprot |= sec_flags; + if (!(sec_flags & SEC_RESERVE)) vprot |= VPROT_COMMITTED; res = map_view( &view, *addr_ptr, size, mask, FALSE, vprot ); if (res) { @@ -3225,7 +3220,7 @@ NTSTATUS WINAPI NtAreMappedFilesTheSame(PVOID addr1, PVOID addr2) status = STATUS_CONFLICTING_ADDRESSES; else if (view1 == view2) status = STATUS_SUCCESS; - else if (!(view1->protect & VPROT_IMAGE) || !(view2->protect & VPROT_IMAGE)) + else if (!(view1->protect & SEC_IMAGE) || !(view2->protect & SEC_IMAGE)) status = STATUS_NOT_SAME_DEVICE; else if (!stat_mapping_file( view1, &st1 ) && !stat_mapping_file( view2, &st2 ) && st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index f54cd1b..de4fd98 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -2192,11 +2192,9 @@ struct create_mapping_reply #define VPROT_EXEC 0x04 #define VPROT_WRITECOPY 0x08 #define VPROT_GUARD 0x10 -#define VPROT_NOCACHE 0x20 -#define VPROT_COMMITTED 0x40 -#define VPROT_WRITEWATCH 0x80 +#define VPROT_COMMITTED 0x20 +#define VPROT_WRITEWATCH 0x40 -#define VPROT_IMAGE 0x0100 #define VPROT_SYSTEM 0x0200 #define VPROT_VALLOC 0x0400 diff --git a/server/protocol.def b/server/protocol.def index e3d5d42..8f2509e 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1704,11 +1704,9 @@ enum char_info_mode #define VPROT_EXEC 0x04 #define VPROT_WRITECOPY 0x08 #define VPROT_GUARD 0x10 -#define VPROT_NOCACHE 0x20 -#define VPROT_COMMITTED 0x40 -#define VPROT_WRITEWATCH 0x80 +#define VPROT_COMMITTED 0x20 +#define VPROT_WRITEWATCH 0x40 /* per-mapping protection flags */ -#define VPROT_IMAGE 0x0100 /* mapping for an exe image */ #define VPROT_SYSTEM 0x0200 /* system view (underlying mmap not under our control) */ #define VPROT_VALLOC 0x0400 /* allocated by VirtualAlloc */
1
0
0
0
Alexandre Julliard : ntdll: Remove the no longer used VPROT_NOEXEC flag.
by Alexandre Julliard
08 Sep '17
08 Sep '17
Module: wine Branch: master Commit: b2624ab99a12cc8748d959e15ebc449f68303d3a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=b2624ab99a12cc8748d959e15…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Fri Sep 8 12:46:47 2017 +0200 ntdll: Remove the no longer used VPROT_NOEXEC flag. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/virtual.c | 8 +++----- include/wine/server_protocol.h | 1 - server/protocol.def | 1 - 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index f398fcc..8fb11e8 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -713,7 +713,7 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz *view_ret = view; VIRTUAL_DEBUG_DUMP_VIEW( view ); - if (force_exec_prot && !(vprot & VPROT_NOEXEC) && (unix_prot & PROT_READ) && !(unix_prot & PROT_EXEC)) + if (force_exec_prot && (unix_prot & PROT_READ) && !(unix_prot & PROT_EXEC)) { TRACE( "forcing exec permission on %p-%p\n", base, (char *)base + size - 1 ); mprotect( base, size, unix_prot | PROT_EXEC ); @@ -797,8 +797,7 @@ static NTSTATUS get_vprot_flags( DWORD protect, unsigned int *vprot, BOOL image */ static inline int mprotect_exec( void *base, size_t size, int unix_prot, unsigned int view_protect ) { - if (force_exec_prot && !(view_protect & VPROT_NOEXEC) && - (unix_prot & PROT_READ) && !(unix_prot & PROT_EXEC)) + if (force_exec_prot && (unix_prot & PROT_READ) && !(unix_prot & PROT_EXEC)) { TRACE( "forcing exec permission on %p-%p\n", base, (char *)base + size - 1 ); if (!mprotect( base, size, unix_prot | PROT_EXEC )) return 0; @@ -1096,7 +1095,7 @@ static NTSTATUS map_file_into_view( struct file_view *view, int fd, size_t start assert( start < view->size ); assert( start + size <= view->size ); - if (force_exec_prot && !(vprot & VPROT_NOEXEC) && (vprot & VPROT_READ)) + if (force_exec_prot && (vprot & VPROT_READ)) { TRACE( "forcing exec permission on mapping %p-%p\n", (char *)view->base + start, (char *)view->base + start + size - 1 ); @@ -1972,7 +1971,6 @@ void VIRTUAL_SetForceExec( BOOL enable ) { BYTE commit = view->mapping ? VPROT_COMMITTED : 0; /* file mappings are always accessible */ - if (view->protect & VPROT_NOEXEC) continue; mprotect_range( view, view->base, view->size, commit, 0 ); } } diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 932a25c..f54cd1b 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -2199,7 +2199,6 @@ struct create_mapping_reply #define VPROT_IMAGE 0x0100 #define VPROT_SYSTEM 0x0200 #define VPROT_VALLOC 0x0400 -#define VPROT_NOEXEC 0x0800 diff --git a/server/protocol.def b/server/protocol.def index 6a4d3fc..e3d5d42 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1711,7 +1711,6 @@ enum char_info_mode #define VPROT_IMAGE 0x0100 /* mapping for an exe image */ #define VPROT_SYSTEM 0x0200 /* system view (underlying mmap not under our control) */ #define VPROT_VALLOC 0x0400 /* allocated by VirtualAlloc */ -#define VPROT_NOEXEC 0x0800 /* don't force exec permission */ /* Open a mapping */
1
0
0
0
Alexandre Julliard : ntdll: Disallow changing PAGE_NOCACHE flag for individual pages.
by Alexandre Julliard
08 Sep '17
08 Sep '17
Module: wine Branch: master Commit: 08acac0864521e1f6886682ad1ac06fa61e3c351 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=08acac0864521e1f6886682ad…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Fri Sep 8 12:41:01 2017 +0200 ntdll: Disallow changing PAGE_NOCACHE flag for individual pages. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/tests/virtual.c | 69 +++++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/virtual.c | 2 ++ 2 files changed, 71 insertions(+) diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 538de70..76953d5 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -362,6 +362,75 @@ static void test_VirtualAlloc(void) ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n"); + /* PAGE_NOCACHE cannot be set per page in recent Windows */ + addr1 = VirtualAlloc( NULL, 0x2000, MEM_COMMIT, PAGE_READWRITE | PAGE_NOCACHE ); + ok( addr1 != NULL, "VirtualAlloc failed\n"); + ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info), "VirtualQuery failed\n"); + ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1); + ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1); + ok(info.AllocationProtect == (PAGE_READWRITE | PAGE_NOCACHE), + "wrong protect %x\n", info.AllocationProtect); + ok(info.RegionSize == 0x2000, "wrong size %lx\n", info.RegionSize); + ok(info.State == MEM_COMMIT, "wrong state %x\n", info.State); + ok(info.Protect == (PAGE_READWRITE | PAGE_NOCACHE), "wrong protect %x\n", info.Protect); + ok(info.Type == MEM_PRIVATE, "wrong type %x\n", info.Type); + + ok(VirtualProtect(addr1, 0x1000, PAGE_READWRITE, &old_prot), "VirtualProtect failed\n"); + ok( old_prot == (PAGE_READWRITE | PAGE_NOCACHE), "wrong protect %x\n", old_prot ); + ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info), "VirtualQuery failed\n"); + ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1); + ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1); + ok(info.AllocationProtect == (PAGE_READWRITE | PAGE_NOCACHE), + "wrong protect %x\n", info.AllocationProtect); + ok(info.RegionSize == 0x2000 || broken(info.RegionSize == 0x1000), + "wrong size %lx\n", info.RegionSize); + ok(info.State == MEM_COMMIT, "wrong state %x\n", info.State); + ok(info.Protect == (PAGE_READWRITE | PAGE_NOCACHE) || broken(info.Protect == PAGE_READWRITE), + "wrong protect %x\n", info.Protect); + ok(info.Type == MEM_PRIVATE, "wrong type %x\n", info.Type); + + ok(VirtualProtect(addr1, 0x1000, PAGE_READONLY, &old_prot), "VirtualProtect failed\n"); + ok( old_prot == (PAGE_READWRITE | PAGE_NOCACHE) || broken(old_prot == PAGE_READWRITE), + "wrong protect %x\n", old_prot ); + ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info), "VirtualQuery failed\n"); + ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1); + ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1); + ok(info.AllocationProtect == (PAGE_READWRITE | PAGE_NOCACHE), + "wrong protect %x\n", info.AllocationProtect); + ok(info.RegionSize == 0x1000, "wrong size %lx\n", info.RegionSize); + ok(info.State == MEM_COMMIT, "wrong state %x\n", info.State); + ok(info.Protect == (PAGE_READONLY | PAGE_NOCACHE) || broken(info.Protect == PAGE_READONLY), + "wrong protect %x\n", info.Protect); + ok(info.Type == MEM_PRIVATE, "wrong type %x\n", info.Type); + + ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n"); + + addr1 = VirtualAlloc( NULL, 0x2000, MEM_COMMIT, PAGE_READWRITE ); + ok( addr1 != NULL, "VirtualAlloc failed\n"); + ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info), "VirtualQuery failed\n"); + ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1); + ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1); + ok(info.AllocationProtect == PAGE_READWRITE, + "wrong protect %x\n", info.AllocationProtect); + ok(info.RegionSize == 0x2000, "wrong size %lx\n", info.RegionSize); + ok(info.State == MEM_COMMIT, "wrong state %x\n", info.State); + ok(info.Protect == PAGE_READWRITE, "wrong protect %x\n", info.Protect); + ok(info.Type == MEM_PRIVATE, "wrong type %x\n", info.Type); + + ok(VirtualProtect(addr1, 0x1000, PAGE_READONLY | PAGE_NOCACHE, &old_prot), "VirtualProtect failed\n"); + ok( old_prot == PAGE_READWRITE, "wrong protect %x\n", old_prot ); + ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info), "VirtualQuery failed\n"); + ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1); + ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1); + ok(info.AllocationProtect == PAGE_READWRITE, "wrong protect %x\n", info.AllocationProtect); + ok(info.RegionSize == 0x1000, "wrong size %lx\n", info.RegionSize); + ok(info.State == MEM_COMMIT, "wrong state %x\n", info.State); + ok(info.Protect == PAGE_READONLY || broken(info.Protect == (PAGE_READONLY | PAGE_NOCACHE)), + "wrong protect %x\n", info.Protect); + ok(info.Type == MEM_PRIVATE, "wrong type %x\n", info.Type); + + ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n"); + /* memory returned by VirtualAlloc should be aligned to 64k */ addr1 = VirtualAlloc(0, 0x2000, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); ok(addr1 != NULL, "VirtualAlloc failed\n"); diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 990b754..f398fcc 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -2369,6 +2369,8 @@ NTSTATUS WINAPI NtProtectVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T if (!view->mapping || is_compatible_protection( view, new_vprot )) { new_vprot |= VPROT_COMMITTED; + if (view->protect & VPROT_NOCACHE) new_vprot |= VPROT_NOCACHE; + else new_vprot &= ~VPROT_NOCACHE; if (old_prot) *old_prot = VIRTUAL_GetWin32Prot( vprot ); if (!VIRTUAL_SetProt( view, base, size, new_vprot )) status = STATUS_ACCESS_DENIED; }
1
0
0
0
Alexandre Julliard : server: Enforce valid flags for file mappings.
by Alexandre Julliard
08 Sep '17
08 Sep '17
Module: wine Branch: master Commit: e5c39a565a4f1ff7db2f228253d43aa397dd3e2a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=e5c39a565a4f1ff7db2f22825…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Fri Sep 8 12:15:03 2017 +0200 server: Enforce valid flags for file mappings. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/tests/virtual.c | 112 +++++++++++++++++++++++++++++++++++++++++- dlls/kernel32/virtual.c | 4 +- server/mapping.c | 34 +++++++++---- 3 files changed, 138 insertions(+), 12 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=e5c39a565a4f1ff7db2f2…
1
0
0
0
Martin Storsjo : msvcrt: Implement setjmp/longjmp on aarch64.
by Alexandre Julliard
08 Sep '17
08 Sep '17
Module: wine Branch: master Commit: 3d3d0806886b7a4d6470ed97a6368926059dc034 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=3d3d0806886b7a4d6470ed97a…
Author: Martin Storsjo <martin(a)martin.st> Date: Fri Sep 8 09:47:33 2017 +0300 msvcrt: Implement setjmp/longjmp on aarch64. Also include the rest of except_*.c (based on except_arm.c) as stubs. Signed-off-by: Martin Storsjo <martin(a)martin.st> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- .../api-ms-win-crt-private-l1-1-0.spec | 16 +- .../api-ms-win-crt-runtime-l1-1-0.spec | 4 +- dlls/crtdll/crtdll.spec | 6 +- dlls/msvcr100/Makefile.in | 1 + dlls/msvcr100/msvcr100.spec | 20 +- dlls/msvcr110/Makefile.in | 1 + dlls/msvcr110/msvcr110.spec | 20 +- dlls/msvcr120/Makefile.in | 1 + dlls/msvcr120/msvcr120.spec | 20 +- dlls/msvcr120_app/msvcr120_app.spec | 20 +- dlls/msvcr70/Makefile.in | 1 + dlls/msvcr70/msvcr70.spec | 14 +- dlls/msvcr71/Makefile.in | 1 + dlls/msvcr71/msvcr71.spec | 16 +- dlls/msvcr80/Makefile.in | 1 + dlls/msvcr80/msvcr80.spec | 20 +- dlls/msvcr90/Makefile.in | 1 + dlls/msvcr90/msvcr90.spec | 20 +- dlls/msvcrt/Makefile.in | 1 + dlls/msvcrt/except_arm64.c | 237 +++++++++++++++++++++ dlls/msvcrt/msvcrt.h | 22 ++ dlls/msvcrt/msvcrt.spec | 20 +- dlls/msvcrt20/msvcrt20.spec | 8 +- dlls/msvcrt40/msvcrt40.spec | 8 +- dlls/msvcrtd/msvcrtd.spec | 8 +- dlls/ucrtbase/Makefile.in | 1 + dlls/ucrtbase/ucrtbase.spec | 20 +- dlls/vcruntime140/vcruntime140.spec | 16 +- include/msvcrt/setjmp.h | 27 +++ include/winnt.h | 39 ++++ 30 files changed, 462 insertions(+), 128 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=3d3d0806886b7a4d6470e…
1
0
0
0
Alistair Leslie-Hughes : include: Add IMFSinkWriterEx interface.
by Alexandre Julliard
08 Sep '17
08 Sep '17
Module: wine Branch: master Commit: 40083c2b8dffe9971df26406de435ef1b001acfc URL:
http://source.winehq.org/git/wine.git/?a=commit;h=40083c2b8dffe9971df26406d…
Author: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com> Date: Fri Sep 8 05:29:39 2017 +0000 include: Add IMFSinkWriterEx interface. Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- include/mfreadwrite.idl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/include/mfreadwrite.idl b/include/mfreadwrite.idl index 5cb3501..834aa09 100644 --- a/include/mfreadwrite.idl +++ b/include/mfreadwrite.idl @@ -15,10 +15,9 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -import "unknwn.idl"; -import "objidl.idl"; -import "oaidl.idl"; + import "mfobjects.idl"; +import "mftransform.idl"; enum { @@ -121,6 +120,17 @@ interface IMFSinkWriter : IUnknown HRESULT GetStatistics([in] DWORD index, [out] MF_SINK_WRITER_STATISTICS *stats); }; +[ + object, + uuid(588d72ab-5Bc1-496a-8714-b70617141b25), + local +] +interface IMFSinkWriterEx : IMFSinkWriter +{ + HRESULT GetTransformForStream([in] DWORD index, [in] DWORD tindex, [out] GUID *category, + [out] IMFTransform **transform); +} + cpp_quote( "HRESULT WINAPI MFCreateSourceReaderFromByteStream(IMFByteStream *stream, IMFAttributes *attributes," ) cpp_quote( " IMFSourceReader **reader);" ) cpp_quote( "HRESULT WINAPI MFCreateSourceReaderFromMediaSource(IMFMediaSource *source, IMFAttributes *attributes," )
1
0
0
0
Vincent Povirk : windowscodecs: Generate a palette for color-keyed grayscale PNG's.
by Alexandre Julliard
08 Sep '17
08 Sep '17
Module: wine Branch: master Commit: 66b126b67539d23c61645e1dcff2191d42fc0249 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=66b126b67539d23c61645e1dc…
Author: Vincent Povirk <vincent(a)codeweavers.com> Date: Thu Sep 7 15:52:05 2017 -0500 windowscodecs: Generate a palette for color-keyed grayscale PNG's. Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- configure | 16 ----- configure.ac | 4 +- dlls/windowscodecs/pngformat.c | 124 +++++++++++++++++++---------------- dlls/windowscodecs/tests/pngformat.c | 8 +-- include/config.h.in | 3 - 5 files changed, 73 insertions(+), 82 deletions(-) diff --git a/configure b/configure index 5138198..47a41cd 100755 --- a/configure +++ b/configure @@ -13890,23 +13890,7 @@ cat >>confdefs.h <<_ACEOF #define SONAME_LIBPNG "$ac_cv_lib_soname_png" _ACEOF - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <png.h> -int -main () -{ -typeof(png_set_expand_gray_1_2_4_to_8) *p - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : -$as_echo "#define HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8 1" >>confdefs.h - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi else PNG_CFLAGS="" diff --git a/configure.ac b/configure.ac index a2ef1b4..cd5a50b 100644 --- a/configure.ac +++ b/configure.ac @@ -1647,9 +1647,7 @@ then [AC_CHECK_HEADERS([png.h]) if test "$ac_cv_header_png_h" = "yes" then - WINE_CHECK_SONAME(png,png_create_read_struct, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <png.h>]],[[typeof(png_set_expand_gray_1_2_4_to_8) *p]])], - [AC_DEFINE(HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8,1,[Define to 1 if libpng has the png_set_expand_gray_1_2_4_to_8 function.])])], + WINE_CHECK_SONAME(png,png_create_read_struct,, [PNG_CFLAGS=""],[$PNG_LIBS -lm -lz],[[libpng[[0-9]]*]]) else PNG_CFLAGS="" diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c index b4fd346..9e837ca 100644 --- a/dlls/windowscodecs/pngformat.c +++ b/dlls/windowscodecs/pngformat.c @@ -319,11 +319,6 @@ MAKE_FUNCPTR(png_get_tRNS); MAKE_FUNCPTR(png_set_bgr); MAKE_FUNCPTR(png_set_crc_action); MAKE_FUNCPTR(png_set_error_fn); -#ifdef HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8 -MAKE_FUNCPTR(png_set_expand_gray_1_2_4_to_8); -#else -MAKE_FUNCPTR(png_set_gray_1_2_4_to_8); -#endif MAKE_FUNCPTR(png_set_filler); MAKE_FUNCPTR(png_set_filter); MAKE_FUNCPTR(png_set_gray_to_rgb); @@ -388,11 +383,6 @@ static void *load_libpng(void) LOAD_FUNCPTR(png_set_bgr); LOAD_FUNCPTR(png_set_crc_action); LOAD_FUNCPTR(png_set_error_fn); -#ifdef HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8 - LOAD_FUNCPTR(png_set_expand_gray_1_2_4_to_8); -#else - LOAD_FUNCPTR(png_set_gray_1_2_4_to_8); -#endif LOAD_FUNCPTR(png_set_filler); LOAD_FUNCPTR(png_set_filter); LOAD_FUNCPTR(png_set_gray_to_rgb); @@ -651,43 +641,18 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p /* check for color-keyed alpha */ transparency = ppng_get_tRNS(This->png_ptr, This->info_ptr, &trans, &num_trans, &trans_values); - if (transparency && color_type != PNG_COLOR_TYPE_PALETTE) + if (transparency && (color_type == PNG_COLOR_TYPE_RGB || + (color_type == PNG_COLOR_TYPE_GRAY && bit_depth == 16))) { /* expand to RGBA */ if (color_type == PNG_COLOR_TYPE_GRAY) - { - if (bit_depth < 8) - { -#ifdef HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8 - ppng_set_expand_gray_1_2_4_to_8(This->png_ptr); -#else - ppng_set_gray_1_2_4_to_8(This->png_ptr); -#endif - bit_depth = 8; - } ppng_set_gray_to_rgb(This->png_ptr); - } ppng_set_tRNS_to_alpha(This->png_ptr); color_type = PNG_COLOR_TYPE_RGB_ALPHA; } switch (color_type) { - case PNG_COLOR_TYPE_GRAY: - This->bpp = bit_depth; - switch (bit_depth) - { - case 1: This->format = &GUID_WICPixelFormatBlackWhite; break; - case 2: This->format = &GUID_WICPixelFormat2bppGray; break; - case 4: This->format = &GUID_WICPixelFormat4bppGray; break; - case 8: This->format = &GUID_WICPixelFormat8bppGray; break; - case 16: This->format = &GUID_WICPixelFormat16bppGray; break; - default: - ERR("invalid grayscale bit depth: %i\n", bit_depth); - hr = E_FAIL; - goto end; - } - break; case PNG_COLOR_TYPE_GRAY_ALPHA: /* WIC does not support grayscale alpha formats so use RGBA */ ppng_set_gray_to_rgb(This->png_ptr); @@ -707,6 +672,25 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p goto end; } break; + case PNG_COLOR_TYPE_GRAY: + This->bpp = bit_depth; + if (!transparency) + { + switch (bit_depth) + { + case 1: This->format = &GUID_WICPixelFormatBlackWhite; break; + case 2: This->format = &GUID_WICPixelFormat2bppGray; break; + case 4: This->format = &GUID_WICPixelFormat4bppGray; break; + case 8: This->format = &GUID_WICPixelFormat8bppGray; break; + case 16: This->format = &GUID_WICPixelFormat16bppGray; break; + default: + ERR("invalid grayscale bit depth: %i\n", bit_depth); + hr = E_FAIL; + goto end; + } + break; + } + /* else fall through */ case PNG_COLOR_TYPE_PALETTE: This->bpp = bit_depth; switch (bit_depth) @@ -1034,7 +1018,7 @@ static HRESULT WINAPI PngDecoder_Frame_CopyPalette(IWICBitmapFrameDecode *iface, IWICPalette *pIPalette) { PngDecoder *This = impl_from_IWICBitmapFrameDecode(iface); - png_uint_32 ret; + png_uint_32 ret, color_type, bit_depth; png_colorp png_palette; int num_palette; WICColor palette[256]; @@ -1048,30 +1032,58 @@ static HRESULT WINAPI PngDecoder_Frame_CopyPalette(IWICBitmapFrameDecode *iface, EnterCriticalSection(&This->lock); - ret = ppng_get_PLTE(This->png_ptr, This->info_ptr, &png_palette, &num_palette); - if (!ret) - { - hr = WINCODEC_ERR_PALETTEUNAVAILABLE; - goto end; - } + color_type = ppng_get_color_type(This->png_ptr, This->info_ptr); + bit_depth = ppng_get_bit_depth(This->png_ptr, This->info_ptr); - if (num_palette > 256) + if (color_type == PNG_COLOR_TYPE_PALETTE) { - ERR("palette has %i colors?!\n", num_palette); - hr = E_FAIL; - goto end; + ret = ppng_get_PLTE(This->png_ptr, This->info_ptr, &png_palette, &num_palette); + if (!ret) + { + hr = WINCODEC_ERR_PALETTEUNAVAILABLE; + goto end; + } + + if (num_palette > 256) + { + ERR("palette has %i colors?!\n", num_palette); + hr = E_FAIL; + goto end; + } + + ret = ppng_get_tRNS(This->png_ptr, This->info_ptr, &trans_alpha, &num_trans, &trans_values); + if (!ret) num_trans = 0; + + for (i=0; i<num_palette; i++) + { + BYTE alpha = (i < num_trans) ? trans_alpha[i] : 0xff; + palette[i] = (alpha << 24 | + png_palette[i].red << 16| + png_palette[i].green << 8| + png_palette[i].blue); + } } + else if (color_type == PNG_COLOR_TYPE_GRAY) { + ret = ppng_get_tRNS(This->png_ptr, This->info_ptr, &trans_alpha, &num_trans, &trans_values); - ret = ppng_get_tRNS(This->png_ptr, This->info_ptr, &trans_alpha, &num_trans, &trans_values); - if (!ret) num_trans = 0; + if (!ret) + { + hr = WINCODEC_ERR_PALETTEUNAVAILABLE; + goto end; + } - for (i=0; i<num_palette; i++) + num_palette = 1 << bit_depth; + + for (i=0; i<num_palette; i++) + { + BYTE alpha = (i == trans_values[0].gray) ? 0 : 0xff; + BYTE val = i * 255 / (num_palette - 1); + palette[i] = (alpha << 24 | val << 16 | val << 8 | val); + } + } + else { - BYTE alpha = (i < num_trans) ? trans_alpha[i] : 0xff; - palette[i] = (alpha << 24 | - png_palette[i].red << 16| - png_palette[i].green << 8| - png_palette[i].blue); + hr = WINCODEC_ERR_PALETTEUNAVAILABLE; } end: diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c index f34711d..4b84cce 100644 --- a/dlls/windowscodecs/tests/pngformat.c +++ b/dlls/windowscodecs/tests/pngformat.c @@ -674,10 +674,10 @@ static void test_color_formats(void) { 24, 2, NULL, NULL, NULL }, { 32, 2, NULL, NULL, NULL }, /* 0 - PNG_COLOR_TYPE_GRAY */ - { 1, 0, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormat1bppIndexed, TRUE }, - { 2, 0, &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppIndexed, TRUE }, - { 4, 0, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppIndexed, TRUE }, - { 8, 0, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppIndexed, TRUE }, + { 1, 0, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormat1bppIndexed }, + { 2, 0, &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppIndexed }, + { 4, 0, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppIndexed }, + { 8, 0, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppIndexed }, { 16, 0, &GUID_WICPixelFormat16bppGray, &GUID_WICPixelFormat16bppGray, &GUID_WICPixelFormat64bppRGBA }, { 24, 0, NULL, NULL, NULL }, { 32, 0, NULL, NULL, NULL }, diff --git a/include/config.h.in b/include/config.h.in index b0b5925..dd7a3a2 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -711,9 +711,6 @@ /* Define to 1 if you have the <png.h> header file. */ #undef HAVE_PNG_H -/* Define to 1 if libpng has the png_set_expand_gray_1_2_4_to_8 function. */ -#undef HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8 - /* Define to 1 if you have the `poll' function. */ #undef HAVE_POLL
1
0
0
0
Dmitry Timoshkov : windowscodecs/tests: Add more tests for loading PNG images in various color formats.
by Alexandre Julliard
08 Sep '17
08 Sep '17
Module: wine Branch: master Commit: 9991e4f2ae5dfc7178656cc3180c779ff2e26cd4 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9991e4f2ae5dfc7178656cc31…
Author: Dmitry Timoshkov <dmitry(a)baikal.ru> Date: Thu Sep 7 15:52:04 2017 -0500 windowscodecs/tests: Add more tests for loading PNG images in various color formats. Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/windowscodecs/tests/pngformat.c | 218 +++++++++++++++++++++++++++++++++-- 1 file changed, 208 insertions(+), 10 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=9991e4f2ae5dfc7178656…
1
0
0
0
Dmitry Timoshkov : windowscodecs/tests: Make create_decoder() return an error code in PNG tests.
by Alexandre Julliard
08 Sep '17
08 Sep '17
Module: wine Branch: master Commit: c87e06bb92407b8fcaabea09a99e543b48950818 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c87e06bb92407b8fcaabea09a…
Author: Dmitry Timoshkov <dmitry(a)baikal.ru> Date: Thu Sep 7 15:52:03 2017 -0500 windowscodecs/tests: Make create_decoder() return an error code in PNG tests. Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/windowscodecs/tests/pngformat.c | 63 ++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c index d266910..7fb9abf 100644 --- a/dlls/windowscodecs/tests/pngformat.c +++ b/dlls/windowscodecs/tests/pngformat.c @@ -276,37 +276,38 @@ static const char png_color_profile[] = { static IWICImagingFactory *factory; -static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size) +static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitmapDecoder **decoder) { HRESULT hr; - IWICBitmapDecoder *decoder = NULL; IStream *stream; GUID format; LONG refcount; ULARGE_INTEGER pos; LARGE_INTEGER zero; + *decoder = NULL; + stream = SHCreateMemStream (image_data, image_size); ok(stream != NULL, "SHCreateMemStream error\n"); - hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); - ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); - if (FAILED(hr)) return NULL; - - hr = IWICBitmapDecoder_GetContainerFormat(decoder, &format); - ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); - ok(IsEqualGUID(&format, &GUID_ContainerFormatPng), - "wrong container format %s\n", wine_dbgstr_guid(&format)); - - zero.QuadPart = 0; - IStream_Seek (stream, zero, STREAM_SEEK_CUR, &pos); - ok(pos.QuadPart < image_size, "seek beyond the end of stream: %x%08x >= %x\n", - (UINT)(pos.QuadPart >> 32), (UINT)pos.QuadPart, image_size); - - refcount = IStream_Release(stream); - ok(refcount > 0, "expected stream refcount > 0\n"); + hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, decoder); + if (hr == S_OK) + { + hr = IWICBitmapDecoder_GetContainerFormat(*decoder, &format); + ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_ContainerFormatPng), + "wrong container format %s\n", wine_dbgstr_guid(&format)); + + zero.QuadPart = 0; + IStream_Seek (stream, zero, STREAM_SEEK_CUR, &pos); + ok(pos.QuadPart < image_size, "seek beyond the end of stream: %x%08x >= %x\n", + (UINT)(pos.QuadPart >> 32), (UINT)pos.QuadPart, image_size); + + refcount = IStream_Release(stream); + ok(refcount > 0, "expected stream refcount > 0\n"); + } - return decoder; + return hr; } static WCHAR *save_profile( BYTE *buffer, UINT size ) @@ -342,9 +343,9 @@ static void test_color_contexts(void) BYTE *buffer; BOOL ret; - decoder = create_decoder(png_no_color_profile, sizeof(png_no_color_profile)); - ok(decoder != 0, "Failed to load PNG image data\n"); - if (!decoder) return; + hr = create_decoder(png_no_color_profile, sizeof(png_no_color_profile), &decoder); + ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr); + if (hr != S_OK) return; /* global color context */ hr = IWICBitmapDecoder_GetColorContexts(decoder, 0, NULL, NULL); @@ -370,9 +371,9 @@ static void test_color_contexts(void) IWICBitmapFrameDecode_Release(frame); IWICBitmapDecoder_Release(decoder); - decoder = create_decoder(png_color_profile, sizeof(png_color_profile)); - ok(decoder != 0, "Failed to load PNG image data\n"); - if (!decoder) return; + hr = create_decoder(png_color_profile, sizeof(png_color_profile), &decoder); + ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr); + if (hr != S_OK) return; /* global color context */ count = 0xdeadbeef; @@ -548,9 +549,9 @@ static void test_png_palette(void) UINT count, ret; WICColor color[256]; - decoder = create_decoder(png_PLTE_tRNS, sizeof(png_PLTE_tRNS)); - ok(decoder != 0, "Failed to load PNG image data\n"); - if (!decoder) return; + hr = create_decoder(png_PLTE_tRNS, sizeof(png_PLTE_tRNS), &decoder); + ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr); + if (hr != S_OK) return; hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); ok(hr == S_OK, "GetFrame error %#x\n", hr); @@ -618,9 +619,9 @@ static void test_color_formats(void) buf[24] = td[i].bit_depth; buf[25] = td[i].color_type; - decoder = create_decoder(buf, sizeof(buf)); - ok(decoder != NULL, "Failed to load PNG image data\n"); - if (!decoder) continue; + hr = create_decoder(buf, sizeof(buf), &decoder); + ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr); + if (hr != S_OK) return; hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); ok(hr == S_OK, "GetFrame error %#x\n", hr);
1
0
0
0
← Newer
1
...
34
35
36
37
38
39
40
...
45
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
Results per page:
10
25
50
100
200