ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
June 2017
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
20 participants
526 discussions
Start a n
N
ew thread
[akhaldi] 74871: [WSHOM.OCX] Sync with Wine Staging 2.9. CORE-13362 2619bdb wshom: Fix IWshShell3::Invoke() call to use correct implementation pointer.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Jun 4 01:49:32 2017 New Revision: 74871 URL:
http://svn.reactos.org/svn/reactos?rev=74871&view=rev
Log: [WSHOM.OCX] Sync with Wine Staging 2.9. CORE-13362 2619bdb wshom: Fix IWshShell3::Invoke() call to use correct implementation pointer. Modified: trunk/reactos/dll/win32/wshom.ocx/shell.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/wshom.ocx/shell.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wshom.ocx/shell.…
============================================================================== --- trunk/reactos/dll/win32/wshom.ocx/shell.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wshom.ocx/shell.c [iso-8859-1] Sun Jun 4 01:49:32 2017 @@ -1189,7 +1189,7 @@ hr = get_typeinfo(IWshShell3_tid, &typeinfo); if(SUCCEEDED(hr)) { - hr = ITypeInfo_Invoke(typeinfo, &WshShell3, dispIdMember, wFlags, + hr = ITypeInfo_Invoke(typeinfo, &WshShell3.IWshShell3_iface, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); ITypeInfo_Release(typeinfo); } Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Jun 4 01:49:32 2017 @@ -211,7 +211,7 @@ reactos/dll/win32/wmi # Synced to WineStaging-1.9.11 reactos/dll/win32/wmiutils # Synced to WineStaging-2.9 reactos/dll/win32/wmvcore # Synced to WineStaging-2.2 -reactos/dll/win32/wshom.ocx # Synced to WineStaging-2.2 +reactos/dll/win32/wshom.ocx # Synced to WineStaging-2.9 reactos/dll/win32/wtsapi32 # Synced to WineStaging-1.9.11 reactos/dll/win32/wuapi # Synced to WineStaging-1.9.11 reactos/dll/win32/xinput1_1 # Synced to WineStaging-1.9.11
7 years, 6 months
1
0
0
0
[akhaldi] 74870: [WMIUTILS] Sync with Wine Staging 2.9. CORE-13362 b16f08b wmiutils: Simplify and standardize the heap_xxx() declarations.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Jun 4 01:49:25 2017 New Revision: 74870 URL:
http://svn.reactos.org/svn/reactos?rev=74870&view=rev
Log: [WMIUTILS] Sync with Wine Staging 2.9. CORE-13362 b16f08b wmiutils: Simplify and standardize the heap_xxx() declarations. Modified: trunk/reactos/dll/win32/wmiutils/wmiutils_private.h trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/wmiutils/wmiutils_private.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wmiutils/wmiutil…
============================================================================== --- trunk/reactos/dll/win32/wmiutils/wmiutils_private.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wmiutils/wmiutils_private.h [iso-8859-1] Sun Jun 4 01:49:25 2017 @@ -21,27 +21,24 @@ HRESULT WbemPath_create(LPVOID *) DECLSPEC_HIDDEN; HRESULT WbemStatusCodeText_create(LPVOID *) DECLSPEC_HIDDEN; -static void *heap_alloc( size_t len ) __WINE_ALLOC_SIZE(1); -static inline void *heap_alloc( size_t len ) +static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size) { - return HeapAlloc( GetProcessHeap(), 0, len ); + return HeapAlloc(GetProcessHeap(), 0, size); } -static void *heap_alloc_zero( size_t len ) __WINE_ALLOC_SIZE(1); -static inline void *heap_alloc_zero( size_t len ) +static inline void* __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t size) { - return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len ); + return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); } -static void *heap_realloc( void *mem, size_t len ) __WINE_ALLOC_SIZE(2); -static inline void *heap_realloc( void *mem, size_t len ) +static inline void* __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t size) { - return HeapReAlloc( GetProcessHeap(), 0, mem, len ); + return HeapReAlloc(GetProcessHeap(), 0, mem, size); } -static inline BOOL heap_free( void *mem ) +static inline BOOL heap_free(void *mem) { - return HeapFree( GetProcessHeap(), 0, mem ); + return HeapFree(GetProcessHeap(), 0, mem); } static inline WCHAR *strdupW( const WCHAR *src ) Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Jun 4 01:49:25 2017 @@ -209,7 +209,7 @@ reactos/dll/win32/wintrust # Synced to WineStaging-2.9 reactos/dll/win32/wldap32 # Synced to WineStaging-2.2 reactos/dll/win32/wmi # Synced to WineStaging-1.9.11 -reactos/dll/win32/wmiutils # Synced to WineStaging-1.9.11 +reactos/dll/win32/wmiutils # Synced to WineStaging-2.9 reactos/dll/win32/wmvcore # Synced to WineStaging-2.2 reactos/dll/win32/wshom.ocx # Synced to WineStaging-2.2 reactos/dll/win32/wtsapi32 # Synced to WineStaging-1.9.11
7 years, 6 months
1
0
0
0
[akhaldi] 74869: [WINTRUST] Sync with Wine Staging 2.9. CORE-13362 e420549 wintrust: Verify image hash in WinVerifyTrust. (v2) f1dfc53 wintrust: Fix CryptCATAdminAcquireContext spec file entry.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Jun 4 01:49:20 2017 New Revision: 74869 URL:
http://svn.reactos.org/svn/reactos?rev=74869&view=rev
Log: [WINTRUST] Sync with Wine Staging 2.9. CORE-13362 e420549 wintrust: Verify image hash in WinVerifyTrust. (v2) f1dfc53 wintrust: Fix CryptCATAdminAcquireContext spec file entry. Modified: trunk/reactos/dll/win32/wintrust/softpub.c trunk/reactos/dll/win32/wintrust/wintrust.spec trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/wintrust/softpub.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wintrust/softpub…
============================================================================== --- trunk/reactos/dll/win32/wintrust/softpub.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wintrust/softpub.c [iso-8859-1] Sun Jun 4 01:49:20 2017 @@ -203,77 +203,116 @@ /* See
https://www.cs.auckland.ac.nz/~pgut001/pubs/authenticode.txt
* for details about the hashing. */ -static BOOL SOFTPUB_HashPEFile(BYTE *file, LARGE_INTEGER *size, HCRYPTHASH hash) -{ - IMAGE_DOS_HEADER *dosheader = (IMAGE_DOS_HEADER *)file; - IMAGE_NT_HEADERS *ntheader; - IMAGE_DATA_DIRECTORY *security_dir; - DWORD *checksum; - - if (sizeof(dosheader) > size->QuadPart) +static BOOL SOFTPUB_HashPEFile(HANDLE file, HCRYPTHASH hash) +{ + DWORD pos, checksum, security_dir; + IMAGE_DOS_HEADER dos_header; + union + { + IMAGE_NT_HEADERS32 nt32; + IMAGE_NT_HEADERS64 nt64; + } nt_header; + IMAGE_DATA_DIRECTORY secdir; + LARGE_INTEGER file_size; + DWORD bytes_read; + BYTE buffer[1024]; + BOOL ret; + + if (!GetFileSizeEx(file, &file_size)) return FALSE; - if (dosheader->e_magic != IMAGE_DOS_SIGNATURE) - { - ERR("Unrecognized IMAGE_DOS_HEADER magic %04x\n", dosheader->e_magic); + SetFilePointer(file, 0, NULL, FILE_BEGIN); + ret = ReadFile(file, &dos_header, sizeof(dos_header), &bytes_read, NULL); + if (!ret || bytes_read != sizeof(dos_header)) return FALSE; - } - - if (dosheader->e_lfanew >= 256 * 1024 * 1024) /* see RtlImageNtHeaderEx */ + + if (dos_header.e_magic != IMAGE_DOS_SIGNATURE) + { + ERR("Unrecognized IMAGE_DOS_HEADER magic %04x\n", dos_header.e_magic); return FALSE; - if (dosheader->e_lfanew + FIELD_OFFSET(IMAGE_NT_HEADERS, OptionalHeader.MajorLinkerVersion) > size->QuadPart) + } + if (dos_header.e_lfanew >= 256 * 1024 * 1024) /* see RtlImageNtHeaderEx */ return FALSE; - - ntheader = (IMAGE_NT_HEADERS *)(file + dosheader->e_lfanew); - if (ntheader->Signature != IMAGE_NT_SIGNATURE) - { - ERR("Unrecognized IMAGE_NT_HEADERS signature %08x\n", ntheader->Signature); + if (dos_header.e_lfanew + FIELD_OFFSET(IMAGE_NT_HEADERS, OptionalHeader.MajorLinkerVersion) > file_size.QuadPart) return FALSE; - } - - if (ntheader->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) - { - IMAGE_NT_HEADERS32 *nt32 = (IMAGE_NT_HEADERS32 *)ntheader; - if (dosheader->e_lfanew + sizeof(nt32) > size->QuadPart) + + SetFilePointer(file, dos_header.e_lfanew, NULL, FILE_BEGIN); + ret = ReadFile(file, &nt_header, sizeof(nt_header), &bytes_read, NULL); + if (!ret || bytes_read < FIELD_OFFSET(IMAGE_NT_HEADERS32, OptionalHeader.Magic) + + sizeof(nt_header.nt32.OptionalHeader.Magic)) + return FALSE; + + if (nt_header.nt32.Signature != IMAGE_NT_SIGNATURE) + { + ERR("Unrecognized IMAGE_NT_HEADERS signature %08x\n", nt_header.nt32.Signature); + return FALSE; + } + + if (nt_header.nt32.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) + { + if (bytes_read < sizeof(nt_header.nt32)) return FALSE; - checksum = &nt32->OptionalHeader.CheckSum; - security_dir = &nt32->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY]; - } - else if (ntheader->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) - { - IMAGE_NT_HEADERS64 *nt64 = (IMAGE_NT_HEADERS64 *)ntheader; - if (dosheader->e_lfanew + sizeof(nt64) > size->QuadPart) + checksum = dos_header.e_lfanew + FIELD_OFFSET(IMAGE_NT_HEADERS32, OptionalHeader.CheckSum); + security_dir = dos_header.e_lfanew + FIELD_OFFSET(IMAGE_NT_HEADERS32, OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY]); + secdir = nt_header.nt32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY]; + } + else if (nt_header.nt32.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) + { + if (bytes_read < sizeof(nt_header.nt64)) return FALSE; - checksum = &nt64->OptionalHeader.CheckSum; - security_dir = &nt64->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY]; - } - else - { - ERR("Unrecognized OptionalHeader magic %04x\n", ntheader->OptionalHeader.Magic); + checksum = dos_header.e_lfanew + FIELD_OFFSET(IMAGE_NT_HEADERS64, OptionalHeader.CheckSum); + security_dir = dos_header.e_lfanew + FIELD_OFFSET(IMAGE_NT_HEADERS64, OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY]); + secdir = nt_header.nt64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY]; + } + else + { + ERR("Unrecognized OptionalHeader magic %04x\n", nt_header.nt32.OptionalHeader.Magic); return FALSE; } - if (security_dir->VirtualAddress < (BYTE *)(security_dir + 1) - file) + if (secdir.VirtualAddress < security_dir + sizeof(IMAGE_DATA_DIRECTORY)) return FALSE; - if (security_dir->VirtualAddress > size->QuadPart) + if (secdir.VirtualAddress > file_size.QuadPart) return FALSE; - if (security_dir->VirtualAddress + security_dir->Size != size->QuadPart) + if (secdir.VirtualAddress + secdir.Size != file_size.QuadPart) return FALSE; /* Hash until checksum. */ - if (!CryptHashData(hash, file, (BYTE *)checksum - file, 0)) - return FALSE; + SetFilePointer(file, 0, NULL, FILE_BEGIN); + for (pos = 0; pos < checksum; pos += bytes_read) + { + ret = ReadFile(file, buffer, min(sizeof(buffer), checksum - pos), &bytes_read, NULL); + if (!ret || !bytes_read) + return FALSE; + if (!CryptHashData(hash, buffer, bytes_read, 0)) + return FALSE; + } /* Hash until the DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY] entry. */ - if (!CryptHashData(hash, (BYTE *)(checksum + 1), (BYTE *)security_dir - (BYTE *)(checksum + 1), 0)) - return FALSE; + checksum += sizeof(DWORD); + SetFilePointer(file, checksum, NULL, FILE_BEGIN); + for (pos = checksum; pos < security_dir; pos += bytes_read) + { + ret = ReadFile(file, buffer, min(sizeof(buffer), security_dir - pos), &bytes_read, NULL); + if (!ret || !bytes_read) + return FALSE; + if (!CryptHashData(hash, buffer, bytes_read, 0)) + return FALSE; + } /* Hash until the end of the file. */ - if (!CryptHashData(hash, (BYTE *)(security_dir + 1), - file + security_dir->VirtualAddress - (BYTE *)(security_dir + 1), 0)) - return FALSE; + security_dir += sizeof(IMAGE_DATA_DIRECTORY); + SetFilePointer(file, security_dir, NULL, FILE_BEGIN); + for (pos = security_dir; pos < secdir.VirtualAddress; pos += bytes_read) + { + ret = ReadFile(file, buffer, min(sizeof(buffer), secdir.VirtualAddress - pos), &bytes_read, NULL); + if (!ret || !bytes_read) + return FALSE; + if (!CryptHashData(hash, buffer, bytes_read, 0)) + return FALSE; + } return TRUE; } @@ -282,13 +321,11 @@ { SPC_INDIRECT_DATA_CONTENT *indirect = (SPC_INDIRECT_DATA_CONTENT *)data->u.pPDSip->psIndirectData; DWORD err, hash_size, length; - BYTE *hash_data, *file_map = NULL; - LARGE_INTEGER file_size; + BYTE *hash_data; BOOL release_prov = FALSE; HCRYPTPROV prov = data->hProv; HCRYPTHASH hash = 0; ALG_ID algID; - HANDLE map = NULL; if (((ULONG_PTR)indirect->Data.pszObjId >> 16) == 0 || strcmp(indirect->Data.pszObjId, SPC_PE_IMAGE_DATA_OBJID)) @@ -313,15 +350,7 @@ goto done; } - if (!GetFileSizeEx(file, &file_size) || - !(map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL)) || - !(file_map = MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0))) - { - err = GetLastError(); - goto done; - } - - if (!SOFTPUB_HashPEFile(file_map, &file_size, hash)) + if (!SOFTPUB_HashPEFile(file, hash)) { err = TRUST_E_NOSIGNATURE; goto done; @@ -352,10 +381,6 @@ data->psPfns->pfnFree(hash_data); done: - if (file_map) - UnmapViewOfFile(file_map); - if (map) - CloseHandle(map); if (hash) CryptDestroyHash(hash); if (release_prov) Modified: trunk/reactos/dll/win32/wintrust/wintrust.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wintrust/wintrus…
============================================================================== --- trunk/reactos/dll/win32/wintrust/wintrust.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wintrust/wintrust.spec [iso-8859-1] Sun Jun 4 01:49:20 2017 @@ -1,6 +1,6 @@ @ stub AddPersonalTrustDBPages @ stub CatalogCompactHashDatabase -@ stdcall CryptCATAdminAcquireContext(long ptr long) +@ stdcall CryptCATAdminAcquireContext(ptr ptr long) @ stdcall CryptCATAdminAddCatalog(long wstr wstr long) @ stdcall CryptCATAdminCalcHashFromFileHandle(long ptr ptr long) @ stdcall CryptCATAdminEnumCatalogFromHash(long ptr long long ptr) Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Jun 4 01:49:20 2017 @@ -206,7 +206,7 @@ reactos/dll/win32/winmm/midimap # Forked at Wine-20050628 reactos/dll/win32/winmm/wavemap # Forked at Wine-20050628 reactos/dll/win32/winscard # Synced to WineStaging-2.2 -reactos/dll/win32/wintrust # Synced to WineStaging-2.2 +reactos/dll/win32/wintrust # Synced to WineStaging-2.9 reactos/dll/win32/wldap32 # Synced to WineStaging-2.2 reactos/dll/win32/wmi # Synced to WineStaging-1.9.11 reactos/dll/win32/wmiutils # Synced to WineStaging-1.9.11
7 years, 6 months
1
0
0
0
[akhaldi] 74868: [WININET_WINETEST] Sync with Wine Staging 2.9. CORE-13362
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Jun 4 01:49:09 2017 New Revision: 74868 URL:
http://svn.reactos.org/svn/reactos?rev=74868&view=rev
Log: [WININET_WINETEST] Sync with Wine Staging 2.9. CORE-13362 Modified: trunk/rostests/winetests/wininet/http.c trunk/rostests/winetests/wininet/internet.c Modified: trunk/rostests/winetests/wininet/http.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/http.c?…
============================================================================== --- trunk/rostests/winetests/wininet/http.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wininet/http.c [iso-8859-1] Sun Jun 4 01:49:09 2017 @@ -1116,16 +1116,9 @@ inetbuffers.lpvBuffer = NULL; inetbuffers.dwOffsetHigh = 1234; inetbuffers.dwOffsetLow = 5678; - SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE); - SET_EXPECT(INTERNET_STATUS_RESPONSE_RECEIVED); rc = InternetReadFileExA(hor, &inetbuffers, 0, 0xdeadcafe); ok(rc, "InternetReadFileEx failed with error %u\n", GetLastError()); trace("read %i bytes\n", inetbuffers.dwBufferLength); - todo_wine - { - CHECK_NOT_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); - CHECK_NOT_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); - } rc = InternetReadFileExA(NULL, &inetbuffers, 0, 0xdeadcafe); ok(!rc && (GetLastError() == ERROR_INVALID_HANDLE), @@ -1172,10 +1165,8 @@ CHECK_NOT_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); if (inetbuffers.dwBufferLength) { - todo_wine { CHECK_NOT_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); CHECK_NOT_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); - } } else { @@ -2075,6 +2066,12 @@ "Connection: Keep-Alive\r\n" "Content-Length: 19\r\n\r\n" "HTTP/1.1 211 OK\r\n\r\n"; + +static const char redir_no_host[] = +"HTTP/1.1 302 Found\r\n" +"Location: http:///test1\r\n" +"Server: winetest\r\n" +"\r\n"; struct server_info { HANDLE hEvent; @@ -2486,6 +2483,10 @@ else send(c, noauthmsg, sizeof noauthmsg-1, 0); } + if (strstr(buffer, "GET /test_redirect_no_host")) + { + send(c, redir_no_host, sizeof redir_no_host-1, 0); + } shutdown(c, 2); closesocket(c); c = -1; @@ -3885,6 +3886,68 @@ size = sizeof(buf); ret = HttpQueryInfoA(req, HTTP_QUERY_CONTENT_ENCODING, buf, &size, 0); todo_wine ok(ret, "HttpQueryInfo(HTTP_QUERY_CONTENT_ENCODING) failed: %d\n", GetLastError()); + InternetCloseHandle(req); + + InternetCloseHandle(con); + InternetCloseHandle(ses); + + /* Decompression doesn't work while reading from cache */ + test_cache_gzip = 0; + sprintf(cache_url, cache_url_fmt, port, get_gzip); + DeleteUrlCacheEntryA(cache_url); + + ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); + ok(ses != NULL,"InternetOpen failed with error %u\n", GetLastError()); + + ret = TRUE; + ret = InternetSetOptionA(ses, INTERNET_OPTION_HTTP_DECODING, &ret, sizeof(ret)); + ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %d\n", GetLastError()); + + con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); + ok(con != NULL, "InternetConnect failed with error %u\n", GetLastError()); + + req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0); + ok(req != NULL, "HttpOpenRequest failed\n"); + + ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0); + ok(ret, "HttpSendRequest failed with error %u\n", GetLastError()); + size = 0; + while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read) + size += read; + ok(size == 10, "read %d bytes of data\n", size); + buf[size] = 0; + ok(!strncmp(buf, content, size), "incorrect page content: %s\n", buf); + InternetCloseHandle(req); + + InternetCloseHandle(con); + InternetCloseHandle(ses); + + /* Decompression doesn't work while reading from cache */ + test_cache_gzip = 0; + sprintf(cache_url, cache_url_fmt, port, get_gzip); + DeleteUrlCacheEntryA(cache_url); + + ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); + ok(ses != NULL,"InternetOpen failed with error %u\n", GetLastError()); + + con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); + ok(con != NULL, "InternetConnect failed with error %u\n", GetLastError()); + + ret = TRUE; + ret = InternetSetOptionA(con, INTERNET_OPTION_HTTP_DECODING, &ret, sizeof(ret)); + ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %d\n", GetLastError()); + + req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0); + ok(req != NULL, "HttpOpenRequest failed\n"); + + ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0); + ok(ret, "HttpSendRequest failed with error %u\n", GetLastError()); + size = 0; + while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read) + size += read; + ok(size == 10, "read %d bytes of data\n", size); + buf[size] = 0; + ok(!strncmp(buf, content, size), "incorrect page content: %s\n", buf); InternetCloseHandle(req); InternetCloseHandle(con); @@ -4745,7 +4808,6 @@ if (!ib.dwBufferLength) break; } - todo_wine ok( pending_reads == 1, "expected 1 pending read, got %u\n", pending_reads ); ok( !strcmp(buffer, page1), "unexpected buffer content\n" ); close_async_handle( ses, hCompleteEvent, 2 ); @@ -4812,7 +4874,6 @@ { ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() ); ok( bytes == 0, "expected 0, got %u\n", bytes ); - todo_wine CHECK_NOTIFIED( INTERNET_STATUS_RECEIVING_RESPONSE ); SET_EXPECT( INTERNET_STATUS_REQUEST_COMPLETE ); if (!pending_reads++) @@ -4835,7 +4896,6 @@ if (!bytes) break; } - todo_wine ok( pending_reads == 1, "expected 1 pending read, got %u\n", pending_reads ); ok( !strcmp(buffer, page1), "unexpected buffer content\n" ); close_async_handle( ses, hCompleteEvent, 2 ); @@ -4849,11 +4909,20 @@ send(server_socket, msg, strlen(msg), 0); } +static BOOL skip_receive_notification_tests; +static DWORD received_response_size; + static void WINAPI readex_callback(HINTERNET handle, DWORD_PTR context, DWORD status, void *info, DWORD info_size) { switch(status) { case INTERNET_STATUS_RECEIVING_RESPONSE: + if(!skip_receive_notification_tests) + callback(handle, context, status, info, info_size); + break; case INTERNET_STATUS_RESPONSE_RECEIVED: + if(!skip_receive_notification_tests) + callback(handle, context, status, info, info_size); + received_response_size = *(DWORD*)info; break; default: callback(handle, context, status, info, info_size); @@ -4884,12 +4953,13 @@ SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER); SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST); SET_EXPECT(INTERNET_STATUS_REQUEST_SENT); + if(!skip_receive_notification_tests) + SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE); SetLastError(0xdeadbeef); ret = HttpSendRequestA(req->request, NULL, 0, NULL, 0); ok(!ret, "HttpSendRequestA unexpectedly succeeded\n"); ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError()); - ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error); WaitForSingleObject(server_req_rec_event, INFINITE); @@ -4899,22 +4969,37 @@ CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER); CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST); + if(!skip_receive_notification_tests) { + SET_EXPECT(INTERNET_STATUS_RESPONSE_RECEIVED); + received_response_size = 0xdeadbeef; + } SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); server_send_string(response); WaitForSingleObject(hCompleteEvent, INFINITE); + if(!skip_receive_notification_tests) { + CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); + CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); + todo_wine + ok(received_response_size == strlen(response), "received_response_size = %u\n", received_response_size); + } CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); -} - -#define readex_expect_sync_data_len(a,b,c,d,e,f) _readex_expect_sync_data_len(__LINE__,a,b,c,d,e,f) + ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error); +} + +#define readex_expect_sync_data_len(a,b,c,d,e,f,g) _readex_expect_sync_data_len(__LINE__,a,b,c,d,e,f,g) static void _readex_expect_sync_data_len(unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, - DWORD buf_size, const char *exdata, DWORD len) + DWORD buf_size, const char *exdata, DWORD len, BOOL expect_receive) { BOOL ret; - SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); + if(!skip_receive_notification_tests && expect_receive) { + SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE); + SET_EXPECT(INTERNET_STATUS_RESPONSE_RECEIVED); + received_response_size = 0xdeadbeef; + } memset(buf->lpvBuffer, 0xff, buf_size); buf->dwBufferLength = buf_size; @@ -4924,38 +5009,102 @@ if(len && exdata) ok_(__FILE__,line)(!memcmp(buf->lpvBuffer, exdata, len), "Unexpected data\n"); + if(!skip_receive_notification_tests && expect_receive) { + CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); + CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); + ok_(__FILE__,line)(received_response_size == len, "received_response_size = %u\n", received_response_size); + } +} + +#define readex_expect_sync_data(a,b,c,d,e,f) _readex_expect_sync_data(__LINE__,a,b,c,d,e,f) +static void _readex_expect_sync_data(unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, + DWORD buf_size, const char *exdata, DWORD expect_receive) +{ + _readex_expect_sync_data_len(line, req, flags, buf, buf_size, exdata, strlen(exdata), expect_receive); +} + +#define read_expect_sync_data_len(a,b,c,d,e) _read_expect_sync_data_len(__LINE__,a,b,c,d,e) +static void _read_expect_sync_data_len(unsigned line, HINTERNET req, void *buf, DWORD buf_size, + const char *exdata, DWORD len) +{ + DWORD ret_size = 0xdeadbeef; + BOOL ret; + + SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE); + SET_EXPECT(INTERNET_STATUS_RESPONSE_RECEIVED); + SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); + received_response_size = 0xdeadbeef; + + memset(buf, 0xff, buf_size); + ret = InternetReadFile(req, buf, buf_size, &ret_size); + ok_(__FILE__,line)(ret, "InternetReadFileExW failed: %u\n", GetLastError()); + ok_(__FILE__,line)(ret_size == len, "dwBufferLength = %u, expected %u\n", ret_size, len); + if(len && exdata) + ok_(__FILE__,line)(!memcmp(buf, exdata, len), "Unexpected data\n"); + + CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); + CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); CLEAR_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); -} - -#define readex_expect_sync_data(a,b,c,d,e) _readex_expect_sync_data(__LINE__,a,b,c,d,e) -static void _readex_expect_sync_data(unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, + ok_(__FILE__,line)(received_response_size == len, "received_response_size = %u\n", received_response_size); + ok_(__FILE__,line)(!req_error, "req_error = %u\n", req_error); +} + +#define read_expect_sync_data(a,b,c,d) _read_expect_sync_data(__LINE__,a,b,c,d) +static void _read_expect_sync_data(unsigned line, HINTERNET req, void *buf, DWORD buf_size, const char *exdata) { - _readex_expect_sync_data_len(line, req, flags, buf, buf_size, exdata, strlen(exdata)); -} - -static void send_response_and_wait(const char *response, BOOL close_connection, INTERNET_BUFFERSW *buf) -{ - DWORD orig_size = buf->dwBufferLength; - + _read_expect_sync_data_len(line, req, buf, buf_size, exdata, strlen(exdata)); +} + +static void close_connection(void) +{ + char c; + SetEvent(conn_wait_event); + recv(server_socket, &c, 1, 0); +} + +#define send_response_and_wait(a,b,c,d,e,f,g,h) _send_response_and_wait(__LINE__,a,b,c,d,e,f,g,h) +static void _send_response_and_wait(unsigned line, const char *response, BOOL do_close_connection, + void *buf, DWORD *ret_size, const char *exdata, + DWORD expected_size, DWORD expected_req_error, DWORD expected_receive_size) +{ + if(!skip_receive_notification_tests) + SET_EXPECT(INTERNET_STATUS_RESPONSE_RECEIVED); SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); if(response) server_send_string(response); - if(close_connection) { - char c; - SetEvent(conn_wait_event); - recv(server_socket, &c, 1, 0); - } + if(do_close_connection) + close_connection(); WaitForSingleObject(hCompleteEvent, INFINITE); + if(!skip_receive_notification_tests) + CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + if(!skip_receive_notification_tests && expected_receive_size != -1) + todo_wine_if(received_response_size != expected_receive_size) /* FIXME! remove when wine is fixed */ + ok_(__FILE__,line)(received_response_size == expected_receive_size, + "received_response_size = %u\n", received_response_size); + ok_(__FILE__,line)(req_error == expected_req_error, "req_error = %u, expected %u\n", req_error, expected_req_error); /* If IRF_NO_WAIT is used, buffer is not changed. */ - ok(buf->dwBufferLength == orig_size, "dwBufferLength = %u\n", buf->dwBufferLength); - ok(!*(int*)buf->lpvBuffer, "buffer data changed\n"); + ok_(__FILE__,line)(*ret_size == expected_size, "dwBufferLength = %u\n", *ret_size); + if(exdata) + ok_(__FILE__,line)(!memcmp(buf, exdata, strlen(exdata)), "unexpected buffer data\n"); + else if(buf) + ok_(__FILE__,line)(!*(DWORD*)buf, "buffer data changed\n"); +} + +#define send_response_ex_and_wait(a,b,c,d,e,f) _send_response_ex_and_wait(__LINE__,a,b,c,d,e,f) +static void _send_response_ex_and_wait(unsigned line, const char *response, BOOL close_connection, + INTERNET_BUFFERSW *buf, const char *exdata, DWORD expected_req_error, + DWORD expected_receive_size) +{ + _send_response_and_wait(line, response, close_connection, buf->lpvBuffer, &buf->dwBufferLength, + exdata, exdata ? strlen(exdata) : buf->dwBufferLength, expected_req_error, + expected_receive_size); } static void send_response_len_and_wait(unsigned len, BOOL close_connection, INTERNET_BUFFERSW *buf) @@ -4965,20 +5114,59 @@ response = HeapAlloc(GetProcessHeap(), 0, len+1); memset(response, 'x', len); response[len] = 0; - send_response_and_wait(response, close_connection, buf); + send_response_ex_and_wait(response, close_connection, buf, NULL, 0, -1); HeapFree(GetProcessHeap(), 0, response); } -static void readex_expect_async(HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, DWORD buf_size) -{ +#define readex_expect_async(a,b,c,d,e) _readex_expect_async(__LINE__,a,b,c,d,e) +static void _readex_expect_async(unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, + DWORD buf_size, const char *exdata) +{ + unsigned len = 0; BOOL ret; + + if(!skip_receive_notification_tests) + SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE); memset(buf->lpvBuffer, 0, buf_size); buf->dwBufferLength = buf_size; ret = InternetReadFileExW(req, buf, flags, 0xdeadbeef); + ok_(__FILE__,line)(!ret && GetLastError() == ERROR_IO_PENDING, "InternetReadFileExW returned %x (%u)\n", ret, GetLastError()); + ok_(__FILE__,line)(buf->dwBufferLength == buf_size, "dwBufferLength = %u, expected %u\n", buf->dwBufferLength, buf_size); + if(exdata) { + len = strlen(exdata); + ok_(__FILE__,line)(!memcmp(buf->lpvBuffer, exdata, len), "unexpected buffer data\n"); + }else { + ok_(__FILE__,line)(!*(DWORD*)buf->lpvBuffer, "buffer data changed\n"); + } + + if(!skip_receive_notification_tests) + CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); +} + +static void read_expect_async(HINTERNET req, void *buf, DWORD buf_size, DWORD *ret_size, const char *exdata) +{ + unsigned len = 0; + const char *p; + BOOL ret; + + SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE); + + *ret_size = 0xdeadbeef; + memset(buf, 0, buf_size); + ret = InternetReadFile(req, buf, buf_size, ret_size); ok(!ret && GetLastError() == ERROR_IO_PENDING, "InternetReadFileExW returned %x (%u)\n", ret, GetLastError()); - ok(buf->dwBufferLength == buf_size, "dwBufferLength = %u, expected %u\n", buf->dwBufferLength, buf_size); - ok(!*(int*)buf->lpvBuffer, "buffer data changed\n"); + ok(*ret_size == 0, "dwBufferLength = %u\n", *ret_size); + if(exdata) { + len = strlen(exdata); + ok(!memcmp(buf, exdata, len), "unexpected buffer data\n"); + } + for(p = (const char*)buf + len; p < (const char*)buf + buf_size; p++) { + if(*p) + ok(0, "buffer data changed\n"); + } + + CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); } #define expect_data_available(a,b) _expect_data_available(__LINE__,a,b) @@ -4995,12 +5183,31 @@ return size; } +#define async_query_data_available(a,b) _async_query_data_available(__LINE__,a,b) +static void _async_query_data_available(unsigned line, HINTERNET req, DWORD *size) +{ + BOOL res; + + if(!skip_receive_notification_tests) + SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE); + + *size = 0xdeadbeef; + res = InternetQueryDataAvailable(req, size, 0, 0); + ok_(__FILE__,line)(!res && GetLastError() == ERROR_IO_PENDING, + "InternetQueryDataAvailable returned: %x(%u)\n", res, GetLastError()); + ok_(__FILE__,line)(!*size, "size = %u\n", *size); + + if(!skip_receive_notification_tests) + CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); +} + static void test_http_read(int port) { INTERNET_BUFFERSW ib; test_request_t req; + DWORD read_size; char buf[24000]; - DWORD avail; + DWORD avail, i; if(!is_ie7plus) return; @@ -5009,7 +5216,11 @@ conn_wait_event = CreateEventW(NULL, FALSE, FALSE, NULL); server_req_rec_event = CreateEventW(NULL, FALSE, FALSE, NULL); - trace("Testing InternetReadFileExW with IRF_NO_WAIT flag...\n"); + memset(&ib, 0, sizeof(ib)); + ib.dwStructSize = sizeof(ib); + ib.lpvBuffer = buf; + + trace("Testing InternetReadFileExW with IRF_ASYNC flag...\n"); open_read_test_request(port, &req, "HTTP/1.1 200 OK\r\n" @@ -5017,22 +5228,83 @@ "\r\n" "xx"); - memset(&ib, 0, sizeof(ib)); - ib.dwStructSize = sizeof(ib); - ib.lpvBuffer = buf; - - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "xx"); - - readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf)); - send_response_and_wait("1234567890", FALSE, &ib); - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, 5, "12345"); - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "67890"); - - readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf)); - send_response_and_wait("12345", TRUE, &ib); - - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "12345"); - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), ""); + readex_expect_async(req.request, IRF_ASYNC, &ib, 4, "xx"); + + send_response_ex_and_wait("yy1234567890", FALSE, &ib, "xxyy", 0, 2); + readex_expect_sync_data(req.request, IRF_ASYNC, &ib, 4, "1234", 4); + readex_expect_sync_data(req.request, IRF_ASYNC, &ib, 5, "56789", 5); + + readex_expect_async(req.request, IRF_ASYNC, &ib, sizeof(buf), "0"); + send_response_ex_and_wait("123", TRUE, &ib, "0123", 0, 4); + + close_async_handle(req.session, hCompleteEvent, 2); + + trace("Testing InternetReadFileExW with no flags...\n"); + + open_read_test_request(port, &req, + "HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "\r\n" + "xx"); + + readex_expect_async(req.request, 0, &ib, 4, "xx"); + + send_response_ex_and_wait("yy1234567890", FALSE, &ib, "xxyy", 0, 2); + readex_expect_sync_data(req.request, 0, &ib, 4, "1234", 4); + readex_expect_sync_data(req.request, 0, &ib, 5, "56789", 5); + + readex_expect_async(req.request, 0, &ib, sizeof(buf), "0"); + send_response_ex_and_wait("123", TRUE, &ib, "0123", 0, 4); + + close_async_handle(req.session, hCompleteEvent, 2); + + trace("Testing InternetReadFile...\n"); + + open_read_test_request(port, &req, + "HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "\r\n" + "xx"); + + read_expect_async(req.request, buf, 4, &read_size, "xx"); + + send_response_and_wait("yy1234567890", FALSE, buf, &read_size, "xxyy", 4, 0, 2); + read_expect_sync_data(req.request, buf, 4, "1234"); + read_expect_sync_data(req.request, buf, 5, "56789"); + + read_expect_async(req.request, buf, sizeof(buf), &read_size, "0"); + send_response_and_wait("123", TRUE, buf, &read_size, "0123", 4, 0, 4); + + close_async_handle(req.session, hCompleteEvent, 2); + + trace("Testing InternetReadFileExW with IRF_NO_WAIT flag...\n"); + + open_read_test_request(port, &req, + "HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "\r\n" + "xx"); + + SET_OPTIONAL(INTERNET_STATUS_RECEIVING_RESPONSE); + + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "xx", 0); + + if(notified[INTERNET_STATUS_RECEIVING_RESPONSE]) { + win_skip("Skipping receive notification tests on too old Windows.\n"); + skip_receive_notification_tests = TRUE; + } + CLEAR_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); + + readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL); + send_response_ex_and_wait("1234567890", FALSE, &ib, NULL, 0, 10); + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, 5, "12345", 0); + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "67890", 0); + + readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL); + send_response_ex_and_wait("12345", TRUE, &ib, NULL, 0, 5); + + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "12345", 0); + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "", TRUE); close_async_handle(req.session, hCompleteEvent, 2); @@ -5042,24 +5314,24 @@ "Transfer-Encoding: chunked\r\n" "\r\n" "9\r\n123456789"); - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123456789"); - readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf)); - - send_response_and_wait("\r\n1\r\na\r\n1\r\nb\r", FALSE, &ib); - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab"); - readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf)); - - send_response_and_wait("\n3\r\nab", FALSE, &ib); - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab"); - readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf)); - - send_response_and_wait("c", FALSE, &ib); - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "c"); - readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf)); - - send_response_and_wait("\r\n1\r\nx\r\n0\r\n\r\n", TRUE, &ib); - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "x"); - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), ""); + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123456789", 0); + readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL); + + send_response_ex_and_wait("\r\n1\r\na\r\n1\r\nb\r", FALSE, &ib, NULL, 0, 13); + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab", 0); + readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL); + + send_response_ex_and_wait("\n3\r\nab", FALSE, &ib, NULL, 0, 6); + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab", 0); + readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL); + + send_response_ex_and_wait("c", FALSE, &ib, NULL, 0, 1); + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "c", 0); + readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL); + + send_response_ex_and_wait("\r\n1\r\nx\r\n0\r\n\r\n", TRUE, &ib, NULL, 0, 13); + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "x", 0); + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "", 0); close_async_handle(req.session, hCompleteEvent, 2); @@ -5069,13 +5341,28 @@ "Transfer-Encoding: chunked\r\n" "\r\n" "3\r\n123\r\n"); - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123"); - readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf)); - - send_response_and_wait("0\r\n\r\n", TRUE, &ib); - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), ""); + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123", 0); + readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL); + + send_response_ex_and_wait("0\r\n\r\n", TRUE, &ib, NULL, 0, 5); + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "", 0); close_async_handle(req.session, hCompleteEvent, 2); + + open_read_test_request(port, &req, + "HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "Connection: close\r\n" + "\r\n"); + readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL); + send_response_ex_and_wait("123", TRUE, &ib, NULL, 0, 3); + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123", 0); + + SET_EXPECT(INTERNET_STATUS_CLOSING_CONNECTION); + SET_EXPECT(INTERNET_STATUS_CONNECTION_CLOSED); + close_async_handle(req.session, hCompleteEvent, 2); + CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); + CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); trace("Testing InternetQueryDataAvailable...\n"); @@ -5085,8 +5372,8 @@ "\r\n" "123"); expect_data_available(req.request, 3); - readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123"); - readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf)); + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "123", 0); + readex_expect_async(req.request, IRF_NO_WAIT, &ib, sizeof(buf), NULL); send_response_len_and_wait(20000, TRUE, &ib); avail = expect_data_available(req.request, -1); @@ -5098,9 +5385,82 @@ todo_wine CHECK_NOT_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); todo_wine CHECK_NOT_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); + open_read_test_request(port, &req, + "HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "Connection: close\r\n" + "\r\n" + "123"); + + expect_data_available(req.request, 3); + readex_expect_sync_data(req.request, 0, &ib, 3, "123", 0); + + async_query_data_available(req.request, &read_size); + send_response_and_wait("1234567890", FALSE, NULL, &read_size, NULL, 10, 10, 10); + + readex_expect_sync_data(req.request, 0, &ib, 9, "123456789", 0); + expect_data_available(req.request, 1); + readex_expect_sync_data(req.request, 0, &ib, 1, "0", 0); + + async_query_data_available(req.request, &read_size); + send_response_and_wait("1234567890", FALSE, NULL, &read_size, NULL, 10, 10, 10); + expect_data_available(req.request, 10); + for(i = 0; i < 10; i++) + server_send_string("x"); + expect_data_available(req.request, 10); + + readex_expect_async(req.request, IRF_ASYNC, &ib, 21, "1234567890"); + send_response_ex_and_wait("X", FALSE, &ib, "1234567890xxxxxxxxxxX", 0, 11); + async_query_data_available(req.request, &read_size); + + SET_EXPECT(INTERNET_STATUS_CLOSING_CONNECTION); + SET_EXPECT(INTERNET_STATUS_CONNECTION_CLOSED); + send_response_and_wait(NULL, TRUE, NULL, &read_size, NULL, 0, 0, 0); + CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); + CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); + + close_async_handle(req.session, hCompleteEvent, 2); + CloseHandle(hCompleteEvent); CloseHandle(conn_wait_event); CloseHandle(server_req_rec_event); + + skip_receive_notification_tests = FALSE; +} + +static void test_connection_break(int port) +{ + INTERNET_BUFFERSW ib; + test_request_t req; + char buf[24000]; + + if(!is_ie7plus) + return; + + hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); + conn_wait_event = CreateEventW(NULL, FALSE, FALSE, NULL); + server_req_rec_event = CreateEventW(NULL, FALSE, FALSE, NULL); + + memset(&ib, 0, sizeof(ib)); + ib.dwStructSize = sizeof(ib); + ib.lpvBuffer = buf; + + trace("Testing InternetReadFileExW on broken connection...\n"); + + open_read_test_request(port, &req, + "HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "Content-Length: 10000\r\n" + "\r\n" + "xx"); + + /* close connection and make sure that it's closed on handle release. */ + close_connection(); + SET_EXPECT(INTERNET_STATUS_CLOSING_CONNECTION); + SET_EXPECT(INTERNET_STATUS_CONNECTION_CLOSED); + close_async_handle(req.session, hCompleteEvent, 2); + CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); + CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); } static void test_long_url(int port) @@ -5148,6 +5508,27 @@ ok(ret, "HttpSendRequest failed: %u\n", GetLastError()); test_status_code(req.request, 200); + close_request(&req); +} + +static void test_redirect(int port) +{ + test_request_t req; + BOOL ret; + + open_simple_request(&req, "localhost", port, NULL, "/test_redirect_no_host"); + ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0); + if (ret) + { + trace("Succeeded with status code 302\n"); + test_status_code(req.request, 302); + } + else + { + trace("Failed with error ERROR_INTERNET_INVALID_URL\n"); + ok(GetLastError() == ERROR_INTERNET_INVALID_URL, + "Expected error ERROR_INTERNET_INVALID_URL, got %u\n", GetLastError()); + } close_request(&req); } @@ -5201,8 +5582,10 @@ test_basic_auth_credentials_reuse(si.port); test_async_read(si.port); test_http_read(si.port); + test_connection_break(si.port); test_long_url(si.port); test_remove_dot_segments(si.port); + test_redirect(si.port); /* send the basic request again to shutdown the server thread */ test_basic_request(si.port, "GET", "/quit"); Modified: trunk/rostests/winetests/wininet/internet.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/interne…
============================================================================== --- trunk/rostests/winetests/wininet/internet.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wininet/internet.c [iso-8859-1] Sun Jun 4 01:49:09 2017 @@ -1610,12 +1610,16 @@ return; } + flags = 0; + buffer[0] = 0; res = pInternetGetConnectedStateExA(&flags, buffer, sizeof(buffer), 0); + trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, buffer); +todo_wine + ok (flags & INTERNET_RAS_INSTALLED, "Missing RAS flag\n"); if(!res) { win_skip("InternetGetConnectedStateExA tests require a valid connection\n"); return; } - trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, buffer); res = pInternetGetConnectedStateExA(NULL, NULL, 0, 0); ok(res == TRUE, "Expected TRUE, got %d\n", res); @@ -1623,7 +1627,16 @@ flags = 0; res = pInternetGetConnectedStateExA(&flags, NULL, 0, 0); ok(res == TRUE, "Expected TRUE, got %d\n", res); - ok(flags, "Expected at least one flag set\n"); + if (flags & INTERNET_CONNECTION_CONFIGURED) + { + ok(flags & INTERNET_CONNECTION_MODEM, "Modem connection flag missing\n"); + ok(flags & ~INTERNET_CONNECTION_LAN, "Mixed Modem and LAN flags\n"); + } + else + { + ok(flags & INTERNET_CONNECTION_LAN, "LAN connection flag missing\n"); + ok(flags & ~INTERNET_CONNECTION_MODEM, "Mixed Modem and LAN flags\n"); + } buffer[0] = 0; flags = 0; @@ -1699,12 +1712,16 @@ return; } + flags = 0; + buffer[0] = 0; res = pInternetGetConnectedStateExW(&flags, buffer, sizeof(buffer) / sizeof(buffer[0]), 0); + trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, wine_dbgstr_w(buffer)); +todo_wine + ok (flags & INTERNET_RAS_INSTALLED, "Missing RAS flag\n"); if(!res) { win_skip("InternetGetConnectedStateExW tests require a valid connection\n"); return; } - trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, wine_dbgstr_w(buffer)); res = pInternetGetConnectedStateExW(NULL, NULL, 0, 0); ok(res == TRUE, "Expected TRUE, got %d\n", res); @@ -1712,7 +1729,16 @@ flags = 0; res = pInternetGetConnectedStateExW(&flags, NULL, 0, 0); ok(res == TRUE, "Expected TRUE, got %d\n", res); - ok(flags, "Expected at least one flag set\n"); + if (flags & INTERNET_CONNECTION_CONFIGURED) + { + ok(flags & INTERNET_CONNECTION_MODEM, "Modem connection flag missing\n"); + ok(flags & ~INTERNET_CONNECTION_LAN, "Mixed Modem and LAN flags\n"); + } + else + { + ok(flags & INTERNET_CONNECTION_LAN, "LAN connection flag missing\n"); + ok(flags & ~INTERNET_CONNECTION_MODEM, "Mixed Modem and LAN flags\n"); + } buffer[0] = 0; flags = 0; @@ -1746,14 +1772,20 @@ res = pInternetGetConnectedStateExW(&flags, buffer, sz, 0); ok(res == TRUE, "Expected TRUE, got %d\n", res); ok(flags, "Expected at least one flag set\n"); - ok(sz - 1 == lstrlenW(buffer), "Expected %u bytes, got %u\n", sz - 1, lstrlenW(buffer)); + if (flags & INTERNET_CONNECTION_MODEM) + ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer)); + else + ok(sz - 1 == lstrlenW(buffer), "Expected %u bytes, got %u\n", sz - 1, lstrlenW(buffer)); buffer[0] = 0; flags = 0; res = pInternetGetConnectedStateExW(&flags, buffer, sz / 2, 0); ok(res == TRUE, "Expected TRUE, got %d\n", res); ok(flags, "Expected at least one flag set\n"); - ok(sz / 2 - 1 == lstrlenW(buffer), "Expected %u bytes, got %u\n", sz / 2 - 1, lstrlenW(buffer)); + if (flags & INTERNET_CONNECTION_MODEM) + ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer)); + else + ok(sz / 2 - 1 == lstrlenW(buffer), "Expected %u bytes, got %u\n", sz / 2 - 1, lstrlenW(buffer)); buffer[0] = 0; flags = 0; @@ -1767,7 +1799,10 @@ res = pInternetGetConnectedStateExW(&flags, buffer, 2, 0); ok(res == TRUE, "Expected TRUE, got %d\n", res); ok(flags, "Expected at least one flag set\n"); - ok(lstrlenW(buffer) == 1, "Expected 1 byte, got %u\n", lstrlenW(buffer)); + if (flags & INTERNET_CONNECTION_MODEM) + ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer)); + else + ok(lstrlenW(buffer) == 1, "Expected 1 byte, got %u\n", lstrlenW(buffer)); buffer[0] = 0xDEAD; flags = 0;
7 years, 6 months
1
0
0
0
[akhaldi] 74867: [PSDK] Update winhttp.h and wininet.h. CORE-13362
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Jun 4 01:49:03 2017 New Revision: 74867 URL:
http://svn.reactos.org/svn/reactos?rev=74867&view=rev
Log: [PSDK] Update winhttp.h and wininet.h. CORE-13362 Modified: trunk/reactos/sdk/include/psdk/winhttp.h trunk/reactos/sdk/include/psdk/wininet.h Modified: trunk/reactos/sdk/include/psdk/winhttp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/winhttp.h…
============================================================================== --- trunk/reactos/sdk/include/psdk/winhttp.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/winhttp.h [iso-8859-1] Sun Jun 4 01:49:03 2017 @@ -38,8 +38,11 @@ typedef WORD INTERNET_PORT; typedef INTERNET_PORT *LPINTERNET_PORT; +/* Yes, these values contradict wininet.h */ #define INTERNET_SCHEME_HTTP 1 #define INTERNET_SCHEME_HTTPS 2 +#define INTERNET_SCHEME_FTP 3 +#define INTERNET_SCHEME_SOCKS 4 typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME; #define ICU_ESCAPE 0x80000000 Modified: trunk/reactos/sdk/include/psdk/wininet.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/wininet.h…
============================================================================== --- trunk/reactos/sdk/include/psdk/wininet.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/wininet.h [iso-8859-1] Sun Jun 4 01:49:03 2017 @@ -136,14 +136,14 @@ INTERNET_SCHEME_PARTIAL = -2, INTERNET_SCHEME_UNKNOWN = -1, INTERNET_SCHEME_DEFAULT = 0, - INTERNET_SCHEME_FTP, + INTERNET_SCHEME_FTP, /* yes, this contradicts winhttp.h */ INTERNET_SCHEME_GOPHER, - INTERNET_SCHEME_HTTP, - INTERNET_SCHEME_HTTPS, + INTERNET_SCHEME_HTTP, /* yes, this contradicts winhttp.h */ + INTERNET_SCHEME_HTTPS, /* yes, this contradicts winhttp.h */ INTERNET_SCHEME_FILE, INTERNET_SCHEME_NEWS, INTERNET_SCHEME_MAILTO, - INTERNET_SCHEME_SOCKS, + INTERNET_SCHEME_SOCKS, /* yes, this contradicts winhttp.h */ INTERNET_SCHEME_JAVASCRIPT, INTERNET_SCHEME_VBSCRIPT, INTERNET_SCHEME_RES, @@ -2531,13 +2531,16 @@ #define INTERNET_AUTODIAL_FLAGS_MASK (INTERNET_AUTODIAL_FORCE_ONLINE | INTERNET_AUTODIAL_FORCE_UNATTENDED | INTERNET_AUTODIAL_FAILIFSECURITYCHECK) -BOOLAPI InternetAutodialHangup(_Reserved_ DWORD); -BOOLAPI InternetGetConnectedState(_Out_ LPDWORD, _Reserved_ DWORD); - -#define INTERNET_CONNECTION_MODEM 1 -#define INTERNET_CONNECTION_LAN 2 -#define INTERNET_CONNECTION_PROXY 4 -#define INTERNET_CONNECTION_MODEM_BUSY 8 +BOOL WINAPI InternetAutodialHangup(_Reserved_ DWORD); +BOOL WINAPI InternetGetConnectedState(_Out_ LPDWORD, _Reserved_ DWORD); + +#define INTERNET_CONNECTION_MODEM 0x01 +#define INTERNET_CONNECTION_LAN 0x02 +#define INTERNET_CONNECTION_PROXY 0x04 +#define INTERNET_CONNECTION_MODEM_BUSY 0x08 +#define INTERNET_RAS_INSTALLED 0x10 +#define INTERNET_CONNECTION_OFFLINE 0x20 +#define INTERNET_CONNECTION_CONFIGURED 0x40 typedef DWORD (CALLBACK *PFN_DIAL_HANDLER) (HWND,LPCSTR,DWORD,LPDWORD);
7 years, 6 months
1
0
0
0
[akhaldi] 74866: [WININET] Sync with Wine Staging 2.9. CORE-13362 05c23c9 wininet: Use isspaceW() instead of isspace() for WCHARs. f9d1b16 wininet: Return failure when handling http redirect withou...
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Jun 4 01:48:55 2017 New Revision: 74866 URL:
http://svn.reactos.org/svn/reactos?rev=74866&view=rev
Log: [WININET] Sync with Wine Staging 2.9. CORE-13362 05c23c9 wininet: Use isspaceW() instead of isspace() for WCHARs. f9d1b16 wininet: Return failure when handling http redirect without hostname. 4ca5f42 wininet: Allow to set INTERNET_OPTION_HTTP_DECODING on sessions and connections. 7d8cf31 wininet: Don't use returned read size if read failed in gzip_read. 2952c63 wininet: Get rid of no longer needed get_avail_data from data stream implementations. 295291b wininet: Always use non-blocking reads in HTTP_ReceiveRequestData. fd0ac40 wininet: Get rid of no longer needed blocking_mode_t. 18f9d03 wininet: Get rid of no longer needed BLOCKING_WAITALL. 7eaadab wininet: Merge InternetReadFile and InternetReadFileEx implementations. a546e8a wininet: Reimplemented InternetQueryDataAvailable on top of async_read. 0880874 wininet: Rewrite InternetReadFileEx for http protocol to make use of non-blocking reads. 98bcd00 wininet: Rewrite asynchronous read to try to fill whole buffer and not buffer additional data unless requested. c140a70 wininet: Propagate WSAEWOULDBLOCK from read_http_stream. f42a2cc wininet: Pass blocking mode to HTTPREQ_Read. 67b5677 wininet: Propagate WSAEWOULDBLOCK result from content decoding reads. 36f6387 wininet: Forward InternetGetConnectedState to Ex function. 7b42dc4 wininet: Improved netconn_drain_content. 6caecb6 wininet: Handle query parameters for HTTPS urls in InternetOpenUrlW. e9be490 wininet: Fix some more spec file entries. Modified: trunk/reactos/dll/win32/wininet/ftp.c trunk/reactos/dll/win32/wininet/http.c trunk/reactos/dll/win32/wininet/internet.c trunk/reactos/dll/win32/wininet/internet.h trunk/reactos/dll/win32/wininet/netconnection.c trunk/reactos/dll/win32/wininet/wininet.spec trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/wininet/ftp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/ftp.c?re…
============================================================================== --- trunk/reactos/dll/win32/wininet/ftp.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/ftp.c [iso-8859-1] Sun Jun 4 01:48:55 2017 @@ -1161,7 +1161,8 @@ return INET_QueryOption(hdr, option, buffer, size, unicode); } -static DWORD FTPFILE_ReadFile(object_header_t *hdr, void *buffer, DWORD size, DWORD *read) +static DWORD FTPFILE_ReadFile(object_header_t *hdr, void *buffer, DWORD size, DWORD *read, + DWORD flags, DWORD_PTR context) { ftp_file_t *file = (ftp_file_t*)hdr; int res; @@ -1183,12 +1184,6 @@ WARN("WriteFile failed: %u\n", GetLastError()); } return error; -} - -static DWORD FTPFILE_ReadFileEx(object_header_t *hdr, void *buf, DWORD size, DWORD *ret_size, - DWORD flags, DWORD_PTR context) -{ - return FTPFILE_ReadFile(hdr, buf, size, ret_size); } static DWORD FTPFILE_WriteFile(object_header_t *hdr, const void *buffer, DWORD size, DWORD *written) @@ -1277,7 +1272,6 @@ FTPFILE_QueryOption, INET_SetOption, FTPFILE_ReadFile, - FTPFILE_ReadFileEx, FTPFILE_WriteFile, FTPFILE_QueryDataAvailable, NULL, @@ -2378,7 +2372,6 @@ FTPSESSION_CloseConnection, FTPSESSION_QueryOption, INET_SetOption, - NULL, NULL, NULL, NULL, @@ -3517,7 +3510,6 @@ NULL, FTPFINDNEXT_QueryOption, INET_SetOption, - NULL, NULL, NULL, NULL, Modified: trunk/reactos/dll/win32/wininet/http.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/http.c?r…
============================================================================== --- trunk/reactos/dll/win32/wininet/http.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/http.c [iso-8859-1] Sun Jun 4 01:48:55 2017 @@ -364,16 +364,9 @@ return ret; } -typedef enum { - BLOCKING_ALLOW, - BLOCKING_DISALLOW, - BLOCKING_WAITALL -} blocking_mode_t; - struct data_stream_vtbl_t { - DWORD (*get_avail_data)(data_stream_t*,http_request_t*); BOOL (*end_of_data)(data_stream_t*,http_request_t*); - DWORD (*read)(data_stream_t*,http_request_t*,BYTE*,DWORD,DWORD*,blocking_mode_t); + DWORD (*read)(data_stream_t*,http_request_t*,BYTE*,DWORD,DWORD*,BOOL); BOOL (*drain_content)(data_stream_t*,http_request_t*); void (*destroy)(data_stream_t*); }; @@ -430,12 +423,6 @@ BOOL end_of_data; } gzip_stream_t; -static DWORD gzip_get_avail_data(data_stream_t *stream, http_request_t *req) -{ - /* Allow reading only from read buffer */ - return 0; -} - static BOOL gzip_end_of_data(data_stream_t *stream, http_request_t *req) { gzip_stream_t *gzip_stream = (gzip_stream_t*)stream; @@ -444,7 +431,7 @@ } static DWORD gzip_read(data_stream_t *stream, http_request_t *req, BYTE *buf, DWORD size, - DWORD *read, blocking_mode_t blocking_mode) + DWORD *read, BOOL allow_blocking) { gzip_stream_t *gzip_stream = (gzip_stream_t*)stream; z_stream *zstream = &gzip_stream->zstream; @@ -452,7 +439,7 @@ int zres; DWORD res = ERROR_SUCCESS; - TRACE("(%d %d)\n", size, blocking_mode); + TRACE("(%d %x)\n", size, allow_blocking); while(size && !gzip_stream->end_of_data) { if(!gzip_stream->buf_size) { @@ -462,16 +449,14 @@ gzip_stream->buf_pos = 0; } res = gzip_stream->parent_stream->vtbl->read(gzip_stream->parent_stream, req, gzip_stream->buf+gzip_stream->buf_size, - sizeof(gzip_stream->buf)-gzip_stream->buf_size, ¤t_read, blocking_mode); - gzip_stream->buf_size += current_read; + sizeof(gzip_stream->buf)-gzip_stream->buf_size, ¤t_read, allow_blocking); if(res != ERROR_SUCCESS) break; + gzip_stream->buf_size += current_read; if(!current_read) { - if(blocking_mode != BLOCKING_DISALLOW) { - WARN("unexpected end of data\n"); - gzip_stream->end_of_data = TRUE; - } + WARN("unexpected end of data\n"); + gzip_stream->end_of_data = TRUE; break; } } @@ -497,11 +482,13 @@ break; } - if(ret_read && blocking_mode == BLOCKING_ALLOW) - blocking_mode = BLOCKING_DISALLOW; + if(ret_read) + allow_blocking = FALSE; } TRACE("read %u bytes\n", ret_read); + if(ret_read) + res = ERROR_SUCCESS; *read = ret_read; return res; } @@ -524,7 +511,6 @@ } static const data_stream_vtbl_t gzip_stream_vtbl = { - gzip_get_avail_data, gzip_end_of_data, gzip_read, gzip_drain_content, @@ -2348,11 +2334,6 @@ if (!(req->session->appInfo->proxyPassword = heap_strdupW(buffer))) return ERROR_OUTOFMEMORY; return ERROR_SUCCESS; - case INTERNET_OPTION_HTTP_DECODING: - if(size != sizeof(BOOL)) - return ERROR_INVALID_PARAMETER; - req->decoding = *(BOOL*)buffer; - return ERROR_SUCCESS; } return INET_SetOption(hdr, option, buffer, size); @@ -2565,11 +2546,13 @@ return !req->read_size && req->data_stream->vtbl->end_of_data(req->data_stream, req); } -static DWORD read_http_stream(http_request_t *req, BYTE *buf, DWORD size, DWORD *read, blocking_mode_t blocking_mode) +static DWORD read_http_stream(http_request_t *req, BYTE *buf, DWORD size, DWORD *read, BOOL allow_blocking) { DWORD res; - res = req->data_stream->vtbl->read(req->data_stream, req, buf, size, read, blocking_mode); + res = req->data_stream->vtbl->read(req->data_stream, req, buf, size, read, allow_blocking); + if(res != ERROR_SUCCESS) + *read = 0; assert(*read <= size); if(req->hCacheFile) { @@ -2582,7 +2565,7 @@ FIXME("WriteFile failed: %u\n", GetLastError()); } - if(req->data_stream->vtbl->end_of_data(req->data_stream, req)) + if((res == ERROR_SUCCESS && !*read) || req->data_stream->vtbl->end_of_data(req->data_stream, req)) commit_cache_entry(req); } @@ -2590,7 +2573,7 @@ } /* fetch some more data into the read buffer (the read section must be held) */ -static DWORD refill_read_buffer(http_request_t *req, blocking_mode_t blocking_mode, DWORD *read_bytes) +static DWORD refill_read_buffer(http_request_t *req, BOOL allow_blocking, DWORD *read_bytes) { DWORD res, read=0; @@ -2604,7 +2587,10 @@ } res = read_http_stream(req, req->read_buf+req->read_size, sizeof(req->read_buf) - req->read_size, - &read, blocking_mode); + &read, allow_blocking); + if(res != ERROR_SUCCESS) + return res; + req->read_size += read; TRACE("read %u bytes, read_size %u\n", read, req->read_size); @@ -2613,33 +2599,6 @@ return res; } -/* return the size of data available to be read immediately (the read section must be held) */ -static DWORD get_avail_data( http_request_t *req ) -{ - DWORD avail = req->read_size; - - /* - * Different Windows versions have different limits of returned data, but all - * of them return no more than centrain amount. We use READ_BUFFER_SIZE as a limit. - */ - if(avail < READ_BUFFER_SIZE) - avail += req->data_stream->vtbl->get_avail_data(req->data_stream, req); - - return min(avail, READ_BUFFER_SIZE); -} - -static DWORD netconn_get_avail_data(data_stream_t *stream, http_request_t *req) -{ - netconn_stream_t *netconn_stream = (netconn_stream_t*)stream; - DWORD avail = 0; - - if(is_valid_netconn(req->netconn)) - NETCON_query_data_available(req->netconn, &avail); - return netconn_stream->content_length == ~0u - ? avail - : min(avail, netconn_stream->content_length-netconn_stream->content_read); -} - static BOOL netconn_end_of_data(data_stream_t *stream, http_request_t *req) { netconn_stream_t *netconn_stream = (netconn_stream_t*)stream; @@ -2647,31 +2606,24 @@ } static DWORD netconn_read(data_stream_t *stream, http_request_t *req, BYTE *buf, DWORD size, - DWORD *read, blocking_mode_t blocking_mode) + DWORD *read, BOOL allow_blocking) { netconn_stream_t *netconn_stream = (netconn_stream_t*)stream; DWORD res = ERROR_SUCCESS; - int len = 0, ret = 0; + int ret = 0; size = min(size, netconn_stream->content_length-netconn_stream->content_read); if(size && is_valid_netconn(req->netconn)) { - while((res = NETCON_recv(req->netconn, buf+ret, size-ret, blocking_mode != BLOCKING_DISALLOW, &len)) == ERROR_SUCCESS) { - if(!len) { + res = NETCON_recv(req->netconn, buf, size, allow_blocking, &ret); + if(res == ERROR_SUCCESS) { + if(!ret) netconn_stream->content_length = netconn_stream->content_read; - break; - } - ret += len; - netconn_stream->content_read += len; - if(blocking_mode != BLOCKING_WAITALL || size == ret) - break; - } - - if(ret || (blocking_mode == BLOCKING_DISALLOW && res == WSAEWOULDBLOCK)) - res = ERROR_SUCCESS; - } - - TRACE("read %u bytes\n", ret); + netconn_stream->content_read += ret; + } + } + + TRACE("res %u read %u bytes\n", res, ret); *read = ret; return res; } @@ -2680,17 +2632,20 @@ { netconn_stream_t *netconn_stream = (netconn_stream_t*)stream; BYTE buf[1024]; - int len; - - if(netconn_end_of_data(stream, req)) - return TRUE; - - do { - if(NETCON_recv(req->netconn, buf, sizeof(buf), FALSE, &len) != ERROR_SUCCESS) + int len, res; + size_t size; + + if(netconn_stream->content_length == ~0u) + return FALSE; + + while(netconn_stream->content_read < netconn_stream->content_length) { + size = min(sizeof(buf), netconn_stream->content_length-netconn_stream->content_read); + res = NETCON_recv(req->netconn, buf, size, FALSE, &len); + if(res || !len) return FALSE; netconn_stream->content_read += len; - }while(netconn_stream->content_read < netconn_stream->content_length); + } return TRUE; } @@ -2700,7 +2655,6 @@ } static const data_stream_vtbl_t netconn_stream_vtbl = { - netconn_get_avail_data, netconn_end_of_data, netconn_read, netconn_drain_content, @@ -2722,7 +2676,7 @@ } static DWORD chunked_read(data_stream_t *stream, http_request_t *req, BYTE *buf, DWORD size, - DWORD *read, blocking_mode_t blocking_mode) + DWORD *read, BOOL allow_blocking) { chunked_stream_t *chunked_stream = (chunked_stream_t*)stream; DWORD ret_read = 0, res = ERROR_SUCCESS; @@ -2741,10 +2695,12 @@ case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA: case CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END: chunked_stream->buf_pos = 0; - res = NETCON_recv(req->netconn, chunked_stream->buf, sizeof(chunked_stream->buf), blocking_mode != BLOCKING_DISALLOW, &read_bytes); + res = NETCON_recv(req->netconn, chunked_stream->buf, sizeof(chunked_stream->buf), allow_blocking, &read_bytes); if(res == ERROR_SUCCESS && read_bytes) { chunked_stream->buf_size += read_bytes; }else if(res == WSAEWOULDBLOCK) { + if(ret_read) + res = ERROR_SUCCESS; continue_read = FALSE; continue; }else { @@ -2803,7 +2759,7 @@ chunked_stream->buf_size -= read_bytes; }else { res = NETCON_recv(req->netconn, (char*)buf+ret_read, read_bytes, - blocking_mode != BLOCKING_DISALLOW, (int*)&read_bytes); + allow_blocking, (int*)&read_bytes); if(res != ERROR_SUCCESS) { continue_read = FALSE; break; @@ -2820,8 +2776,7 @@ ret_read += read_bytes; if(!chunked_stream->chunk_size) chunked_stream->state = CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA; - if(blocking_mode == BLOCKING_ALLOW) - blocking_mode = BLOCKING_DISALLOW; + allow_blocking = FALSE; break; case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA: @@ -2848,7 +2803,7 @@ if(ret_read) res = ERROR_SUCCESS; - if(res != ERROR_SUCCESS && res != WSAEWOULDBLOCK) + if(res != ERROR_SUCCESS) return res; TRACE("read %d bytes\n", ret_read); @@ -2856,26 +2811,6 @@ return ERROR_SUCCESS; } -static DWORD chunked_get_avail_data(data_stream_t *stream, http_request_t *req) -{ - chunked_stream_t *chunked_stream = (chunked_stream_t*)stream; - DWORD avail = 0; - - if(chunked_stream->state != CHUNKED_STREAM_STATE_READING_CHUNK) { - DWORD res, read; - - /* try to process to the next chunk */ - res = chunked_read(stream, req, NULL, 0, &read, BLOCKING_DISALLOW); - if(res != ERROR_SUCCESS || chunked_stream->state != CHUNKED_STREAM_STATE_READING_CHUNK) - return 0; - } - - if(is_valid_netconn(req->netconn) && chunked_stream->buf_size < chunked_stream->chunk_size) - NETCON_query_data_available(req->netconn, &avail); - - return min(avail + chunked_stream->buf_size, chunked_stream->chunk_size); -} - static BOOL chunked_drain_content(data_stream_t *stream, http_request_t *req) { chunked_stream_t *chunked_stream = (chunked_stream_t*)stream; @@ -2889,7 +2824,6 @@ } static const data_stream_vtbl_t chunked_stream_vtbl = { - chunked_get_avail_data, chunked_end_of_data, chunked_read, chunked_drain_content, @@ -2941,7 +2875,7 @@ request->contentLength = ~0u; } - if(request->decoding) { + if(request->hdr.decoding) { int encoding_idx; static const WCHAR deflateW[] = {'d','e','f','l','a','t','e',0}; @@ -2980,48 +2914,38 @@ sizeof(INTERNET_ASYNC_RESULT)); } -static void HTTP_ReceiveRequestData(http_request_t *req, BOOL first_notif, DWORD *ret_size) -{ - DWORD res, read = 0, avail = 0; - blocking_mode_t mode; +static void HTTP_ReceiveRequestData(http_request_t *req) +{ + DWORD res, read = 0; TRACE("%p\n", req); EnterCriticalSection( &req->read_section ); - mode = first_notif && req->read_size ? BLOCKING_DISALLOW : BLOCKING_ALLOW; - res = refill_read_buffer(req, mode, &read); + res = refill_read_buffer(req, FALSE, &read); if(res == ERROR_SUCCESS) - avail = get_avail_data(req); + read += req->read_size; LeaveCriticalSection( &req->read_section ); - if(res != ERROR_SUCCESS || (mode != BLOCKING_DISALLOW && !read)) { + if(res != WSAEWOULDBLOCK && (res != ERROR_SUCCESS || !read)) { WARN("res %u read %u, closing connection\n", res, read); http_release_netconn(req, FALSE); } - if(res != ERROR_SUCCESS) { + if(res != ERROR_SUCCESS && res != WSAEWOULDBLOCK) { send_request_complete(req, 0, res); return; } - if(ret_size) - *ret_size = avail; - if(first_notif) - avail = 0; - - send_request_complete(req, req->session->hdr.dwInternalFlags & INET_OPENURL ? (DWORD_PTR)req->hdr.hInternet : 1, avail); + send_request_complete(req, req->session->hdr.dwInternalFlags & INET_OPENURL ? (DWORD_PTR)req->hdr.hInternet : 1, 0); } /* read data from the http connection (the read section must be held) */ -static DWORD HTTPREQ_Read(http_request_t *req, void *buffer, DWORD size, DWORD *read) +static DWORD HTTPREQ_Read(http_request_t *req, void *buffer, DWORD size, DWORD *read, BOOL allow_blocking) { DWORD current_read = 0, ret_read = 0; - blocking_mode_t blocking_mode; DWORD res = ERROR_SUCCESS; - - blocking_mode = req->session->appInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC ? BLOCKING_ALLOW : BLOCKING_WAITALL; EnterCriticalSection( &req->read_section ); @@ -3030,13 +2954,15 @@ memcpy(buffer, req->read_buf+req->read_pos, ret_read); req->read_size -= ret_read; req->read_pos += ret_read; - if(blocking_mode == BLOCKING_ALLOW) - blocking_mode = BLOCKING_DISALLOW; + allow_blocking = FALSE; } if(ret_read < size) { - res = read_http_stream(req, (BYTE*)buffer+ret_read, size-ret_read, ¤t_read, blocking_mode); - ret_read += current_read; + res = read_http_stream(req, (BYTE*)buffer+ret_read, size-ret_read, ¤t_read, allow_blocking); + if(res == ERROR_SUCCESS) + ret_read += current_read; + else if(res == WSAEWOULDBLOCK && ret_read) + res = ERROR_SUCCESS; } LeaveCriticalSection( &req->read_section ); @@ -3044,7 +2970,7 @@ *read = ret_read; TRACE( "retrieved %u bytes (%u)\n", ret_read, req->contentLength ); - if(size && !ret_read) + if(res != WSAEWOULDBLOCK && (!ret_read || res != ERROR_SUCCESS)) http_release_netconn(req, res == ERROR_SUCCESS); return res; @@ -3069,7 +2995,7 @@ DWORD bytes_read, res; BYTE buf[4096]; - res = HTTPREQ_Read(req, buf, sizeof(buf), &bytes_read); + res = HTTPREQ_Read(req, buf, sizeof(buf), &bytes_read, TRUE); if(res != ERROR_SUCCESS) { ret = FALSE; break; @@ -3088,114 +3014,136 @@ task_header_t hdr; void *buf; DWORD size; + DWORD read_pos; DWORD *ret_read; -} read_file_ex_task_t; - -static void AsyncReadFileExProc(task_header_t *hdr) -{ - read_file_ex_task_t *task = (read_file_ex_task_t*)hdr; +} read_file_task_t; + +static void async_read_file_proc(task_header_t *hdr) +{ + read_file_task_t *task = (read_file_task_t*)hdr; http_request_t *req = (http_request_t*)task->hdr.hdr; - DWORD res = ERROR_SUCCESS, read = 0, buffered = 0; - - TRACE("%p\n", req); + DWORD res = ERROR_SUCCESS, read = task->read_pos, complete_arg = 0; + + TRACE("req %p buf %p size %u read_pos %u ret_read %p\n", req, task->buf, task->size, task->read_pos, task->ret_read); + + if(task->buf) { + DWORD read_bytes; + while (read < task->size) { + res = HTTPREQ_Read(req, (char*)task->buf + read, task->size - read, &read_bytes, TRUE); + if (res != ERROR_SUCCESS || !read_bytes) + break; + read += read_bytes; + } + }else { + EnterCriticalSection(&req->read_section); + res = refill_read_buffer(req, TRUE, &read); + LeaveCriticalSection(&req->read_section); + + if(task->ret_read) + complete_arg = read; /* QueryDataAvailable reports read bytes in request complete notification */ + if(res != ERROR_SUCCESS || !read) + http_release_netconn(req, drain_content(req, FALSE)); + } + + TRACE("res %u read %u\n", res, read); if(task->ret_read) - res = HTTPREQ_Read(req, task->buf, task->size, &read); - if(res == ERROR_SUCCESS) - res = refill_read_buffer(req, task->ret_read ? BLOCKING_DISALLOW : BLOCKING_ALLOW, &buffered); - if (res == ERROR_SUCCESS) - { - if(task->ret_read) - *task->ret_read = read; - read += buffered; + *task->ret_read = read; + + /* FIXME: We should report bytes transferred before decoding content. */ + INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, &read, sizeof(read)); + + if(res != ERROR_SUCCESS) + complete_arg = res; + send_request_complete(req, res == ERROR_SUCCESS, complete_arg); +} + +static DWORD async_read(http_request_t *req, void *buf, DWORD size, DWORD read_pos, DWORD *ret_read) +{ + read_file_task_t *task; + + task = alloc_async_task(&req->hdr, async_read_file_proc, sizeof(*task)); + if(!task) + return ERROR_OUTOFMEMORY; + + task->buf = buf; + task->size = size; + task->read_pos = read_pos; + task->ret_read = ret_read; + + INTERNET_AsyncCall(&task->hdr); + return ERROR_IO_PENDING; +} + +static DWORD HTTPREQ_ReadFile(object_header_t *hdr, void *buf, DWORD size, DWORD *ret_read, + DWORD flags, DWORD_PTR context) +{ + http_request_t *req = (http_request_t*)hdr; + DWORD res = ERROR_SUCCESS, read = 0, cread, error = ERROR_SUCCESS; + BOOL allow_blocking, notify_received = FALSE; + + TRACE("(%p %p %u %x)\n", req, buf, size, flags); + + if (flags & ~(IRF_ASYNC|IRF_NO_WAIT)) + FIXME("these dwFlags aren't implemented: 0x%x\n", flags & ~(IRF_ASYNC|IRF_NO_WAIT)); + + allow_blocking = !(req->session->appInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC); + + if(allow_blocking || TryEnterCriticalSection(&req->read_section)) { + if(allow_blocking) + EnterCriticalSection(&req->read_section); + if(hdr->dwError == ERROR_SUCCESS) + hdr->dwError = INTERNET_HANDLE_IN_USE; + else if(hdr->dwError == INTERNET_HANDLE_IN_USE) + hdr->dwError = ERROR_INTERNET_INTERNAL_ERROR; + + if(req->read_size) { + read = min(size, req->read_size); + memcpy(buf, req->read_buf + req->read_pos, read); + req->read_size -= read; + req->read_pos += read; + } + + if(read < size && (!read || !(flags & IRF_NO_WAIT)) && !end_of_read_data(req)) { + LeaveCriticalSection(&req->read_section); + INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); + EnterCriticalSection( &req->read_section ); + notify_received = TRUE; + + while(read < size) { + res = HTTPREQ_Read(req, (char*)buf+read, size-read, &cread, allow_blocking); + read += cread; + if (res != ERROR_SUCCESS || !cread) + break; + } + } + + if(hdr->dwError == INTERNET_HANDLE_IN_USE) + hdr->dwError = ERROR_SUCCESS; + else + error = hdr->dwError; + + LeaveCriticalSection( &req->read_section ); + }else { + res = WSAEWOULDBLOCK; + } + + if(res == WSAEWOULDBLOCK) { + if(!(flags & IRF_NO_WAIT)) + return async_read(req, buf, size, read, ret_read); + if(!read) + return async_read(req, NULL, 0, 0, NULL); + res = ERROR_SUCCESS; + } + + *ret_read = read; + if (res != ERROR_SUCCESS) + return res; + + if(notify_received) INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, &read, sizeof(read)); - } - - send_request_complete(req, res == ERROR_SUCCESS, res); -} - -static DWORD HTTPREQ_ReadFileEx(object_header_t *hdr, void *buf, DWORD size, DWORD *ret_read, - DWORD flags, DWORD_PTR context) -{ - - http_request_t *req = (http_request_t*)hdr; - DWORD res, read, cread, error = ERROR_SUCCESS; - - TRACE("(%p %p %u %x)\n", req, buf, size, flags); - - if (flags & ~(IRF_ASYNC|IRF_NO_WAIT)) - FIXME("these dwFlags aren't implemented: 0x%x\n", flags & ~(IRF_ASYNC|IRF_NO_WAIT)); - - INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); - - if (req->session->appInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC) - { - read_file_ex_task_t *task; - - if (TryEnterCriticalSection( &req->read_section )) - { - if (get_avail_data(req) || end_of_read_data(req)) - { - res = HTTPREQ_Read(req, buf, size, &read); - LeaveCriticalSection( &req->read_section ); - goto done; - } - LeaveCriticalSection( &req->read_section ); - } - - task = alloc_async_task(&req->hdr, AsyncReadFileExProc, sizeof(*task)); - task->buf = buf; - task->size = size; - task->ret_read = (flags & IRF_NO_WAIT) ? NULL : ret_read; - - INTERNET_AsyncCall(&task->hdr); - - return ERROR_IO_PENDING; - } - - read = 0; - - EnterCriticalSection( &req->read_section ); - if(hdr->dwError == ERROR_SUCCESS) - hdr->dwError = INTERNET_HANDLE_IN_USE; - else if(hdr->dwError == INTERNET_HANDLE_IN_USE) - hdr->dwError = ERROR_INTERNET_INTERNAL_ERROR; - - while(1) { - res = HTTPREQ_Read(req, (char*)buf+read, size-read, &cread); - if(res != ERROR_SUCCESS) - break; - - read += cread; - if(read == size || end_of_read_data(req)) - break; - - LeaveCriticalSection( &req->read_section ); - - INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, - &cread, sizeof(cread)); - INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, - INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); - - EnterCriticalSection( &req->read_section ); - } - - if(hdr->dwError == INTERNET_HANDLE_IN_USE) - hdr->dwError = ERROR_SUCCESS; - else - error = hdr->dwError; - - LeaveCriticalSection( &req->read_section ); - -done: - *ret_read = read; - if (res == ERROR_SUCCESS) { - INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, - &read, sizeof(read)); - } - - return res==ERROR_SUCCESS ? error : res; + return error; } static DWORD HTTPREQ_WriteFile(object_header_t *hdr, const void *buffer, DWORD size, DWORD *written) @@ -3214,99 +3162,60 @@ return res; } -static DWORD HTTPREQ_ReadFile(object_header_t *hdr, void *buffer, DWORD size, DWORD *read) +static DWORD HTTPREQ_QueryDataAvailable(object_header_t *hdr, DWORD *available, DWORD flags, DWORD_PTR ctx) { http_request_t *req = (http_request_t*)hdr; - DWORD res; - - if (req->session->appInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC) - { - read_file_ex_task_t *task; - - if (TryEnterCriticalSection( &req->read_section )) - { - if (get_avail_data(req) || end_of_read_data(req)) - { - res = HTTPREQ_Read(req, buffer, size, read); - LeaveCriticalSection( &req->read_section ); - return res; - } - LeaveCriticalSection( &req->read_section ); - } - - task = alloc_async_task(&req->hdr, AsyncReadFileExProc, sizeof(*task)); - task->buf = buffer; - task->size = size; - task->ret_read = read; - - *read = 0; - INTERNET_AsyncCall(&task->hdr); - - return ERROR_IO_PENDING; - } - - EnterCriticalSection( &req->read_section ); - if(hdr->dwError == INTERNET_HANDLE_IN_USE) - hdr->dwError = ERROR_INTERNET_INTERNAL_ERROR; - - res = HTTPREQ_Read(req, buffer, size, read); - if(res == ERROR_SUCCESS) - res = hdr->dwError; - LeaveCriticalSection( &req->read_section ); - - return res; -} - -typedef struct { - task_header_t hdr; - DWORD *ret_size; -} http_data_available_task_t; - -static void AsyncQueryDataAvailableProc(task_header_t *hdr) -{ - http_data_available_task_t *task = (http_data_available_task_t*)hdr; - - HTTP_ReceiveRequestData((http_request_t*)task->hdr.hdr, FALSE, task->ret_size); -} - -static DWORD HTTPREQ_QueryDataAvailable(object_header_t *hdr, DWORD *available, DWORD flags, DWORD_PTR ctx) -{ - http_request_t *req = (http_request_t*)hdr; + DWORD res = ERROR_SUCCESS, avail = 0, error = ERROR_SUCCESS; + BOOL allow_blocking, notify_received = FALSE; TRACE("(%p %p %x %lx)\n", req, available, flags, ctx); - if (req->session->appInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC) - { - http_data_available_task_t *task; - - /* never wait, if we can't enter the section we queue an async request right away */ - if (TryEnterCriticalSection( &req->read_section )) - { - refill_read_buffer(req, BLOCKING_DISALLOW, NULL); - if ((*available = get_avail_data( req ))) goto done; - if (end_of_read_data( req )) goto done; - LeaveCriticalSection( &req->read_section ); - } - - task = alloc_async_task(&req->hdr, AsyncQueryDataAvailableProc, sizeof(*task)); - task->ret_size = available; - INTERNET_AsyncCall(&task->hdr); - return ERROR_IO_PENDING; - } - - EnterCriticalSection( &req->read_section ); - - if (!(*available = get_avail_data( req )) && !end_of_read_data( req )) - { - refill_read_buffer( req, BLOCKING_ALLOW, NULL ); - *available = get_avail_data( req ); - } - -done: - LeaveCriticalSection( &req->read_section ); - - TRACE( "returning %u\n", *available ); - return ERROR_SUCCESS; + if (flags & ~(IRF_ASYNC|IRF_NO_WAIT)) + FIXME("these dwFlags aren't implemented: 0x%x\n", flags & ~(IRF_ASYNC|IRF_NO_WAIT)); + + *available = 0; + allow_blocking = !(req->session->appInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC); + + if(allow_blocking || TryEnterCriticalSection(&req->read_section)) { + if(allow_blocking) + EnterCriticalSection(&req->read_section); + if(hdr->dwError == ERROR_SUCCESS) + hdr->dwError = INTERNET_HANDLE_IN_USE; + else if(hdr->dwError == INTERNET_HANDLE_IN_USE) + hdr->dwError = ERROR_INTERNET_INTERNAL_ERROR; + + avail = req->read_size; + + if(!avail && !end_of_read_data(req)) { + LeaveCriticalSection(&req->read_section); + INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); + EnterCriticalSection( &req->read_section ); + notify_received = TRUE; + + res = refill_read_buffer(req, allow_blocking, &avail); + } + + if(hdr->dwError == INTERNET_HANDLE_IN_USE) + hdr->dwError = ERROR_SUCCESS; + else + error = hdr->dwError; + + LeaveCriticalSection( &req->read_section ); + }else { + res = WSAEWOULDBLOCK; + } + + if(res == WSAEWOULDBLOCK) + return async_read(req, NULL, 0, 0, available); + + if (res != ERROR_SUCCESS) + return res; + + *available = avail; + if(notify_received) + INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, + &avail, sizeof(avail)); + return error; } static DWORD HTTPREQ_LockRequestFile(object_header_t *hdr, req_file_t **ret) @@ -3330,7 +3239,6 @@ HTTPREQ_QueryOption, HTTPREQ_SetOption, HTTPREQ_ReadFile, - HTTPREQ_ReadFileEx, HTTPREQ_WriteFile, HTTPREQ_QueryDataAvailable, NULL, @@ -3365,6 +3273,7 @@ request->hdr.htype = WH_HHTTPREQ; request->hdr.dwFlags = dwFlags; request->hdr.dwContext = dwContext; + request->hdr.decoding = session->hdr.decoding; request->contentLength = ~0u; request->netconn_stream.data_stream.vtbl = &netconn_stream_vtbl; @@ -4137,6 +4046,9 @@ if(!InternetCrackUrlW(lpszUrl, strlenW(lpszUrl), 0, &urlComponents)) return INTERNET_GetLastError(); + if (!urlComponents.dwHostNameLength) + return ERROR_INTERNET_INVALID_URL; + if(urlComponents.nScheme == INTERNET_SCHEME_HTTP) { if(request->hdr.dwFlags & INTERNET_FLAG_SECURE) { TRACE("redirect from secure page to non-secure page\n"); @@ -4380,7 +4292,7 @@ while (isspaceW(*ptr)) ptr++; - for (monthPtr = month; !isspace(*ptr) && + for (monthPtr = month; !isspaceW(*ptr) && monthPtr - month < sizeof(month) / sizeof(month[0]) - 1; monthPtr++, ptr++) *monthPtr = *ptr; @@ -4477,7 +4389,7 @@ while (isspaceW(*ptr)) ptr++; - for (monthPtr = month; !isspace(*ptr) && + for (monthPtr = month; !isspaceW(*ptr) && monthPtr - month < sizeof(month) / sizeof(month[0]) - 1; monthPtr++, ptr++) *monthPtr = *ptr; @@ -5221,7 +5133,7 @@ { if (res == ERROR_SUCCESS) { if(bEndRequest && request->contentLength && request->bytesWritten == request->bytesToWrite) - HTTP_ReceiveRequestData(request, TRUE, NULL); + HTTP_ReceiveRequestData(request); else send_request_complete(request, request->session->hdr.dwInternalFlags & INET_OPENURL ? (DWORD_PTR)request->hdr.hInternet : 1, 0); @@ -5328,7 +5240,7 @@ create_cache_entry(request); if (res == ERROR_SUCCESS && request->contentLength) - HTTP_ReceiveRequestData(request, TRUE, NULL); + HTTP_ReceiveRequestData(request); else send_request_complete(request, res == ERROR_SUCCESS, res); @@ -5818,7 +5730,6 @@ NULL, NULL, NULL, - NULL, NULL }; @@ -5859,6 +5770,7 @@ session->hdr.dwFlags = dwFlags; session->hdr.dwContext = dwContext; session->hdr.dwInternalFlags |= dwInternalFlags; + session->hdr.decoding = hIC->hdr.decoding; WININET_AddRef( &hIC->hdr ); session->appInfo = hIC; Modified: trunk/reactos/dll/win32/wininet/internet.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/internet…
============================================================================== --- trunk/reactos/dll/win32/wininet/internet.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/internet.c [iso-8859-1] Sun Jun 4 01:48:55 2017 @@ -943,7 +943,6 @@ APPINFO_SetOption, NULL, NULL, - NULL, NULL }; @@ -1146,11 +1145,7 @@ { TRACE("(%p, 0x%08x)\n", lpdwStatus, dwReserved); - if (lpdwStatus) { - WARN("always returning LAN connection.\n"); - *lpdwStatus = INTERNET_CONNECTION_LAN; - } - return TRUE; + return InternetGetConnectedStateExW(lpdwStatus, NULL, 0, dwReserved); } @@ -2149,8 +2144,11 @@ return FALSE; } - if(hdr->vtbl->ReadFile) - res = hdr->vtbl->ReadFile(hdr, lpBuffer, dwNumOfBytesToRead, pdwNumOfBytesRead); + if(hdr->vtbl->ReadFile) { + res = hdr->vtbl->ReadFile(hdr, lpBuffer, dwNumOfBytesToRead, pdwNumOfBytesRead, 0, 0); + if(res == ERROR_IO_PENDING) + *pdwNumOfBytesRead = 0; + } WININET_Release(hdr); @@ -2208,8 +2206,8 @@ return FALSE; } - if(hdr->vtbl->ReadFileEx) - res = hdr->vtbl->ReadFileEx(hdr, lpBuffersOut->lpvBuffer, lpBuffersOut->dwBufferLength, + if(hdr->vtbl->ReadFile) + res = hdr->vtbl->ReadFile(hdr, lpBuffersOut->lpvBuffer, lpBuffersOut->dwBufferLength, &lpBuffersOut->dwBufferLength, dwFlags, dwContext); WININET_Release(hdr); @@ -2246,8 +2244,8 @@ return FALSE; } - if(hdr->vtbl->ReadFileEx) - res = hdr->vtbl->ReadFileEx(hdr, lpBuffer->lpvBuffer, lpBuffer->dwBufferLength, &lpBuffer->dwBufferLength, + if(hdr->vtbl->ReadFile) + res = hdr->vtbl->ReadFile(hdr, lpBuffer->lpvBuffer, lpBuffer->dwBufferLength, &lpBuffer->dwBufferLength, dwFlags, dwContext); WININET_Release(hdr); @@ -2839,10 +2837,21 @@ FIXME("Option INTERNET_OPTION_DISABLE_AUTODIAL; STUB\n"); break; case INTERNET_OPTION_HTTP_DECODING: - FIXME("INTERNET_OPTION_HTTP_DECODING; STUB\n"); - SetLastError(ERROR_INTERNET_INVALID_OPTION); - ret = FALSE; + { + if (!lpwhh) + { + SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE); + return FALSE; + } + if (!lpBuffer || dwBufferLength != sizeof(BOOL)) + { + SetLastError(ERROR_INVALID_PARAMETER); + ret = FALSE; + } + else + lpwhh->decoding = *(BOOL *)lpBuffer; break; + } case INTERNET_OPTION_COOKIES_3RD_PARTY: FIXME("INTERNET_OPTION_COOKIES_3RD_PARTY; STUB\n"); SetLastError(ERROR_INTERNET_INVALID_OPTION); @@ -3458,7 +3467,9 @@ if(!InternetCrackUrlW(lpszUrl, strlenW(lpszUrl), 0, &urlComponents)) return NULL; - if(urlComponents.nScheme == INTERNET_SCHEME_HTTP && urlComponents.dwExtraInfoLength) { + if ((urlComponents.nScheme == INTERNET_SCHEME_HTTP || urlComponents.nScheme == INTERNET_SCHEME_HTTPS) && + urlComponents.dwExtraInfoLength) + { assert(urlComponents.lpszUrlPath + urlComponents.dwUrlPathLength == urlComponents.lpszExtraInfo); urlComponents.dwUrlPathLength += urlComponents.dwExtraInfoLength; } Modified: trunk/reactos/dll/win32/wininet/internet.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/internet…
============================================================================== --- trunk/reactos/dll/win32/wininet/internet.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/internet.h [iso-8859-1] Sun Jun 4 01:48:55 2017 @@ -336,8 +336,7 @@ void (*CloseConnection)(object_header_t*); DWORD (*QueryOption)(object_header_t*,DWORD,void*,DWORD*,BOOL); DWORD (*SetOption)(object_header_t*,DWORD,void*,DWORD); - DWORD (*ReadFile)(object_header_t*,void*,DWORD,DWORD*); - DWORD (*ReadFileEx)(object_header_t*,void*,DWORD,DWORD*,DWORD,DWORD_PTR); + DWORD (*ReadFile)(object_header_t*,void*,DWORD,DWORD*,DWORD,DWORD_PTR); DWORD (*WriteFile)(object_header_t*,const void*,DWORD,DWORD*); DWORD (*QueryDataAvailable)(object_header_t*,DWORD*,DWORD,DWORD_PTR); DWORD (*FindNextFileW)(object_header_t*,void*); @@ -358,6 +357,7 @@ ULONG ErrorMask; DWORD dwInternalFlags; LONG refs; + BOOL decoding; INTERNET_STATUS_CALLBACK lpfnStatusCB; struct list entry; struct list children; @@ -454,7 +454,6 @@ DWORD read_size; /* valid data size in read_buf */ BYTE read_buf[READ_BUFFER_SIZE]; /* buffer for already read but not returned data */ - BOOL decoding; data_stream_t *data_stream; netconn_stream_t netconn_stream; } http_request_t; @@ -512,7 +511,6 @@ DWORD NETCON_send(netconn_t *connection, const void *msg, size_t len, int flags, int *sent /* out */) DECLSPEC_HIDDEN; DWORD NETCON_recv(netconn_t*,void*,size_t,BOOL,int*) DECLSPEC_HIDDEN; -BOOL NETCON_query_data_available(netconn_t *connection, DWORD *available) DECLSPEC_HIDDEN; BOOL NETCON_is_alive(netconn_t*) DECLSPEC_HIDDEN; LPCVOID NETCON_GetCert(netconn_t *connection) DECLSPEC_HIDDEN; int NETCON_GetCipherStrength(netconn_t*) DECLSPEC_HIDDEN; Modified: trunk/reactos/dll/win32/wininet/netconnection.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/netconne…
============================================================================== --- trunk/reactos/dll/win32/wininet/netconnection.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/netconnection.c [iso-8859-1] Sun Jun 4 01:48:55 2017 @@ -862,32 +862,6 @@ } } -/****************************************************************************** - * NETCON_query_data_available - * Returns the number of bytes of peeked data plus the number of bytes of - * queued, but unread data. - */ -BOOL NETCON_query_data_available(netconn_t *connection, DWORD *available) -{ - *available = 0; - - if(!connection->secure) - { - ULONG unread; - int retval = ioctlsocket(connection->socket, FIONREAD, &unread); - if (!retval) - { - TRACE("%d bytes of queued, but unread data\n", unread); - *available += unread; - } - } - else - { - *available = connection->peek_len; - } - return TRUE; -} - BOOL NETCON_is_alive(netconn_t *netconn) { int len; Modified: trunk/reactos/dll/win32/wininet/wininet.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/wininet.…
============================================================================== --- trunk/reactos/dll/win32/wininet/wininet.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/wininet.spec [iso-8859-1] Sun Jun 4 01:48:55 2017 @@ -53,8 +53,8 @@ @ stub ForceNexusLookupExW @ stdcall FreeUrlCacheSpaceA(str long long) @ stdcall FreeUrlCacheSpaceW(wstr long long) -@ stdcall FtpCommandA(long long long str ptr ptr) -@ stdcall FtpCommandW(long long long wstr ptr ptr) +@ stdcall FtpCommandA(long long long str long ptr) +@ stdcall FtpCommandW(long long long wstr long ptr) @ stdcall FtpCreateDirectoryA(ptr str) @ stdcall FtpCreateDirectoryW(ptr wstr) @ stdcall FtpDeleteFileA(ptr str) @@ -119,8 +119,8 @@ @ stdcall InternetAutodialHangup(long) @ stdcall InternetCanonicalizeUrlA(str ptr ptr long) @ stdcall InternetCanonicalizeUrlW(wstr ptr ptr long) -@ stdcall InternetCheckConnectionA(ptr long long) -@ stdcall InternetCheckConnectionW(ptr long long) +@ stdcall InternetCheckConnectionA(str long long) +@ stdcall InternetCheckConnectionW(wstr long long) @ stdcall InternetClearAllPerSiteCookieDecisions() @ stdcall InternetCloseHandle(long) @ stdcall InternetCombineUrlA(str str str ptr long) @@ -150,10 +150,10 @@ @ stdcall InternetGetConnectedStateEx(ptr ptr long long) InternetGetConnectedStateExA @ stdcall InternetGetConnectedStateExA(ptr ptr long long) @ stdcall InternetGetConnectedStateExW(ptr ptr long long) -@ stdcall InternetGetCookieA(str str ptr long) +@ stdcall InternetGetCookieA(str str ptr ptr) @ stdcall InternetGetCookieExA(str str ptr ptr long ptr) @ stdcall InternetGetCookieExW(wstr wstr ptr ptr long ptr) -@ stdcall InternetGetCookieW(wstr wstr ptr long) +@ stdcall InternetGetCookieW(wstr wstr ptr ptr) @ stdcall InternetGetLastResponseInfoA(ptr ptr ptr) @ stdcall InternetGetLastResponseInfoW(ptr ptr ptr) @ stdcall InternetGetPerSiteCookieDecisionA(str ptr) @@ -183,8 +183,8 @@ @ stub InternetSecurityProtocolToStringW @ stub InternetServerPushParse @ stdcall InternetSetCookieA(str str str) -@ stdcall InternetSetCookieExA(str str str long ptr) -@ stdcall InternetSetCookieExW(wstr wstr wstr long ptr) +@ stdcall InternetSetCookieExA(str str str long long) +@ stdcall InternetSetCookieExW(wstr wstr wstr long long) @ stdcall InternetSetCookieW(wstr wstr wstr) @ stub InternetSetDialState @ stub InternetSetDialStateA Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Jun 4 01:48:55 2017 @@ -201,7 +201,7 @@ reactos/dll/win32/winemp3.acm # Synced to WineStaging-2.2 reactos/dll/win32/wing32 # Synced to WineStaging-1.9.11 reactos/dll/win32/winhttp # Synced to WineStaging-2.9 -reactos/dll/win32/wininet # Synced to WineStaging-2.2 +reactos/dll/win32/wininet # Synced to WineStaging-2.9 reactos/dll/win32/winmm # Forked at Wine-20050628 reactos/dll/win32/winmm/midimap # Forked at Wine-20050628 reactos/dll/win32/winmm/wavemap # Forked at Wine-20050628
7 years, 6 months
1
0
0
0
[akhaldi] 74865: [WINHTTP_WINETEST] Sync with Wine Staging 2.9. CORE-13362
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Jun 4 01:48:43 2017 New Revision: 74865 URL:
http://svn.reactos.org/svn/reactos?rev=74865&view=rev
Log: [WINHTTP_WINETEST] Sync with Wine Staging 2.9. CORE-13362 Modified: trunk/rostests/winetests/winhttp/winhttp.c Modified: trunk/rostests/winetests/winhttp/winhttp.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/winhttp/winhttp…
============================================================================== --- trunk/rostests/winetests/winhttp/winhttp.c [iso-8859-1] (original) +++ trunk/rostests/winetests/winhttp/winhttp.c [iso-8859-1] Sun Jun 4 01:48:43 2017 @@ -1067,6 +1067,8 @@ trace("lpszSignatureAlgName %s\n", wine_dbgstr_w(info.lpszSignatureAlgName)); trace("lpszEncryptionAlgName %s\n", wine_dbgstr_w(info.lpszEncryptionAlgName)); trace("dwKeySize %u\n", info.dwKeySize); + LocalFree( info.lpszSubjectInfo ); + LocalFree( info.lpszIssuerInfo ); } ret = WinHttpReceiveResponse(req, NULL); @@ -2018,6 +2020,11 @@ "Set-Cookie: NAME = value \r\n" "\r\n"; +static const char cookiemsg2[] = +"HTTP/1.1 200 OK\r\n" +"Set-Cookie: name2=value; Domain = localhost; Path=/cookie5;Expires=Wed, 13 Jan 2021 22:23:01 GMT; HttpOnly; \r\n" +"\r\n"; + static const char nocontentmsg[] = "HTTP/1.1 204 No Content\r\n" "Server: winetest\r\n" @@ -2047,6 +2054,25 @@ static const char headmsg[] = "HTTP/1.1 200 OK\r\n" "Content-Length: 100\r\n" +"\r\n"; + +static const char multiauth[] = +"HTTP/1.1 401 Unauthorized\r\n" +"Server: winetest\r\n" +"WWW-Authenticate: Bearer\r\n" +"WWW-Authenticate: Basic realm=\"placebo\"\r\n" +"WWW-Authenticate: NTLM\r\n" +"Content-Length: 10\r\n" +"Content-Type: text/plain\r\n" +"\r\n"; + +static const char largeauth[] = +"HTTP/1.1 401 Unauthorized\r\n" +"Server: winetest\r\n" +"WWW-Authenticate: Basic realm=\"placebo\"\r\n" +"WWW-Authenticate: NTLM\r\n" +"Content-Length: 10240\r\n" +"Content-Type: text/plain\r\n" "\r\n"; static const char unauthorized[] = "Unauthorized"; @@ -2151,6 +2177,32 @@ send(c, headmsg, sizeof headmsg - 1, 0); continue; } + if (strstr(buffer, "GET /multiauth")) + { + send(c, multiauth, sizeof multiauth - 1, 0); + } + if (strstr(buffer, "GET /largeauth")) + { + if (strstr(buffer, "Authorization: NTLM")) + send(c, okmsg, sizeof(okmsg) - 1, 0); + else + { + send(c, largeauth, sizeof largeauth - 1, 0); + for (i = 0; i < 10240; i++) send(c, "A", 1, 0); + continue; + } + } + if (strstr(buffer, "GET /cookie5")) + { + if (strstr(buffer, "Cookie: name2=value\r\n")) + send(c, okmsg, sizeof(okmsg) - 1, 0); + else + send(c, notokmsg, sizeof(notokmsg) - 1, 0); + } + if (strstr(buffer, "GET /cookie4")) + { + send(c, cookiemsg2, sizeof(cookiemsg2) - 1, 0); + } if (strstr(buffer, "GET /cookie3")) { if (strstr(buffer, "Cookie: name=value2; NAME=value; name=value\r\n") || @@ -2493,6 +2545,93 @@ WinHttpCloseHandle(ses); } +static void test_multi_authentication(int port) +{ + static const WCHAR multiauthW[] = {'/','m','u','l','t','i','a','u','t','h',0}; + static const WCHAR getW[] = {'G','E','T',0}; + HINTERNET ses, con, req; + DWORD supported, first, target; + BOOL ret; + + ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0); + ok(ses != NULL, "failed to open session %u\n", GetLastError()); + + con = WinHttpConnect(ses, localhostW, port, 0); + ok(con != NULL, "failed to open a connection %u\n", GetLastError()); + + req = WinHttpOpenRequest(con, getW, multiauthW, NULL, NULL, NULL, 0); + ok(req != NULL, "failed to open a request %u\n", GetLastError()); + + ret = WinHttpSendRequest(req, WINHTTP_NO_ADDITIONAL_HEADERS, 0, + WINHTTP_NO_REQUEST_DATA,0, 0, 0 ); + ok(ret, "expected success\n"); + + ret = WinHttpReceiveResponse(req, NULL); + ok(ret, "expected success\n"); + + supported = first = target = 0xdeadbeef; + ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target); + ok(ret, "expected success\n"); + ok(supported == (WINHTTP_AUTH_SCHEME_BASIC | WINHTTP_AUTH_SCHEME_NTLM), "got %x\n", supported); + ok(target == WINHTTP_AUTH_TARGET_SERVER, "got %x\n", target); + ok(first == WINHTTP_AUTH_SCHEME_BASIC, "got %x\n", first); + + WinHttpCloseHandle(req); + WinHttpCloseHandle(con); + WinHttpCloseHandle(ses); +} + +static void test_large_data_authentication(int port) +{ + static const WCHAR largeauthW[] = {'/','l','a','r','g','e','a','u','t','h',0}; + static const WCHAR getW[] = {'G','E','T',0}; + static WCHAR userW[] = {'u','s','e','r',0}; + static WCHAR passW[] = {'p','w','d',0}; + HINTERNET ses, con, req; + DWORD status, size; + BOOL ret; + + ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0); + ok(ses != NULL, "failed to open session %u\n", GetLastError()); + + con = WinHttpConnect(ses, localhostW, port, 0); + ok(con != NULL, "failed to open a connection %u\n", GetLastError()); + + req = WinHttpOpenRequest(con, getW, largeauthW, NULL, NULL, NULL, 0); + ok(req != NULL, "failed to open a request %u\n", GetLastError()); + + ret = WinHttpSendRequest(req, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0); + ok(ret, "expected success\n"); + + ret = WinHttpReceiveResponse(req, NULL); + ok(ret, "expected success\n"); + + size = sizeof(status); + ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, + &status, &size, NULL); + ok(ret, "expected success\n"); + ok(status == HTTP_STATUS_DENIED, "got %d\n", status); + + ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_NTLM, userW, passW, NULL); + ok(ret, "expected success\n"); + + ret = WinHttpSendRequest(req, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0); + ok(ret, "expected success %d\n", GetLastError()); + + ret = WinHttpReceiveResponse(req, NULL); + ok(ret, "expected success\n"); + + size = sizeof(status); + ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, + &status, &size, NULL); + ok(ret, "expected success\n"); + ok(status == HTTP_STATUS_OK, "got %d\n", status); + + WinHttpCloseHandle(req); + WinHttpCloseHandle(con); + WinHttpCloseHandle(ses); +} + static void test_no_headers(int port) { static const WCHAR no_headersW[] = {'/','n','o','_','h','e','a','d','e','r','s',0}; @@ -2820,6 +2959,8 @@ static const WCHAR cookieW[] = {'/','c','o','o','k','i','e',0}; static const WCHAR cookie2W[] = {'/','c','o','o','k','i','e','2',0}; static const WCHAR cookie3W[] = {'/','c','o','o','k','i','e','3',0}; + static const WCHAR cookie4W[] = {'/','c','o','o','k','i','e','4',0}; + static const WCHAR cookie5W[] = {'/','c','o','o','k','i','e','5',0}; static const WCHAR cookieheaderW[] = {'C','o','o','k','i','e',':',' ','n','a','m','e','=','v','a','l','u','e','2','\r','\n',0}; HINTERNET ses, con, req; @@ -2926,6 +3067,48 @@ ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL ); ok( ret, "failed to query status code %u\n", GetLastError() ); ok( status == HTTP_STATUS_BAD_REQUEST, "request failed unexpectedly %u\n", status ); + + WinHttpCloseHandle( req ); + WinHttpCloseHandle( con ); + WinHttpCloseHandle( ses ); + + ses = WinHttpOpen( test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 ); + ok( ses != NULL, "failed to open session %u\n", GetLastError() ); + + con = WinHttpConnect( ses, localhostW, port, 0 ); + ok( con != NULL, "failed to open a connection %u\n", GetLastError() ); + + req = WinHttpOpenRequest( con, NULL, cookie4W, NULL, NULL, NULL, 0 ); + ok( req != NULL, "failed to open a request %u\n", GetLastError() ); + + ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 ); + ok( ret, "failed to send request %u\n", GetLastError() ); + + ret = WinHttpReceiveResponse( req, NULL ); + ok( ret, "failed to receive response %u\n", GetLastError() ); + + status = 0xdeadbeef; + size = sizeof(status); + ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL ); + ok( ret, "failed to query status code %u\n", GetLastError() ); + ok( status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status ); + WinHttpCloseHandle( req ); + + req = WinHttpOpenRequest( con, NULL, cookie5W, NULL, NULL, NULL, 0 ); + ok( req != NULL, "failed to open a request %u\n", GetLastError() ); + + ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 ); + ok( ret, "failed to send request %u\n", GetLastError() ); + + ret = WinHttpReceiveResponse( req, NULL ); + ok( ret, "failed to receive response %u\n", GetLastError() ); + + status = 0xdeadbeef; + size = sizeof(status); + ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL ); + ok( ret, "failed to query status code %u\n", GetLastError() ); + ok( status == HTTP_STATUS_OK || broken(status == HTTP_STATUS_BAD_REQUEST) /* < win7 */, + "request failed unexpectedly %u\n", status ); WinHttpCloseHandle( req ); WinHttpCloseHandle( con ); @@ -4248,6 +4431,8 @@ test_head_request(si.port); test_not_modified(si.port); test_basic_authentication(si.port); + test_multi_authentication(si.port); + test_large_data_authentication(si.port); test_bad_header(si.port); test_multiple_reads(si.port); test_cookies(si.port);
7 years, 6 months
1
0
0
0
[akhaldi] 74864: [WINHTTP] Sync with Wine Staging 2.9. CORE-13362 2fa86fd winhttp: Always drain content before sending the next request. 6b6ffb3 winhttp: Ignore unknown schemes in WinHttpQueryAuthS...
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Jun 4 01:48:31 2017 New Revision: 74864 URL:
http://svn.reactos.org/svn/reactos?rev=74864&view=rev
Log: [WINHTTP] Sync with Wine Staging 2.9. CORE-13362 2fa86fd winhttp: Always drain content before sending the next request. 6b6ffb3 winhttp: Ignore unknown schemes in WinHttpQueryAuthSchemes. 08603e5 winhttp: Fix a memory leak in insert_header (Valgrind). be78574 winhttp: Cookie attributes are case-insensitive. 8595cc5 winhttp: Parse cookie attributes. Modified: trunk/reactos/dll/win32/winhttp/cookie.c trunk/reactos/dll/win32/winhttp/request.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/winhttp/cookie.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/cookie.c…
============================================================================== --- trunk/reactos/dll/win32/winhttp/cookie.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/cookie.c [iso-8859-1] Sun Jun 4 01:48:31 2017 @@ -155,17 +155,79 @@ return cookie; } +struct attr +{ + WCHAR *name; + WCHAR *value; +}; + +static void free_attr( struct attr *attr ) +{ + if (!attr) return; + heap_free( attr->name ); + heap_free( attr->value ); + heap_free( attr ); +} + +static struct attr *parse_attr( const WCHAR *str, int *used ) +{ + const WCHAR *p = str, *q; + struct attr *attr; + int len; + + while (*p == ' ') p++; + q = p; + while (*q && *q != ' ' && *q != '=' && *q != ';') q++; + len = q - p; + if (!len) return NULL; + + if (!(attr = heap_alloc( sizeof(struct attr) ))) return NULL; + if (!(attr->name = heap_alloc( (len + 1) * sizeof(WCHAR) ))) + { + heap_free( attr ); + return NULL; + } + memcpy( attr->name, p, len * sizeof(WCHAR) ); + attr->name[len] = 0; + attr->value = NULL; + + p = q; + while (*p == ' ') p++; + if (*p++ == '=') + { + while (*p == ' ') p++; + q = p; + while (*q && *q != ';') q++; + len = q - p; + while (len && p[len - 1] == ' ') len--; + + if (!(attr->value = heap_alloc( (len + 1) * sizeof(WCHAR) ))) + { + free_attr( attr ); + return NULL; + } + memcpy( attr->value, p, len * sizeof(WCHAR) ); + attr->value[len] = 0; + } + + while (*q == ' ') q++; + if (*q == ';') q++; + *used = q - str; + + return attr; +} + BOOL set_cookies( request_t *request, const WCHAR *cookies ) { static const WCHAR pathW[] = {'p','a','t','h',0}; static const WCHAR domainW[] = {'d','o','m','a','i','n',0}; - BOOL ret = FALSE; - WCHAR *buffer, *p, *q, *r; + WCHAR *buffer, *p; WCHAR *cookie_domain = NULL, *cookie_path = NULL; + struct attr *attr, *domain = NULL, *path = NULL; session_t *session = request->connect->session; cookie_t *cookie; - int len; + int len, used; len = strlenW( cookies ); if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE; @@ -179,32 +241,26 @@ heap_free( buffer ); return FALSE; } - if ((q = strstrW( p, domainW ))) /* FIXME: do real attribute parsing */ - { - while (*q && *q != '=') q++; - if (!*q) goto end; - - r = ++q; - while (*r && *r != ';') r++; - len = r - q; - - if (!(cookie_domain = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end; - memcpy( cookie_domain, q, len * sizeof(WCHAR) ); - cookie_domain[len] = 0; - - } - if ((q = strstrW( p, pathW ))) - { - while (*q && *q != '=') q++; - if (!*q) goto end; - - r = ++q; - while (*r && *r != ';') r++; - len = r - q; - - if (!(cookie_path = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end; - memcpy( cookie_path, q, len * sizeof(WCHAR) ); - cookie_path[len] = 0; + len = strlenW( p ); + while (len && (attr = parse_attr( p, &used ))) + { + if (!strcmpiW( attr->name, domainW )) + { + domain = attr; + cookie_domain = attr->value; + } + else if (!strcmpiW( attr->name, pathW )) + { + path = attr; + cookie_path = attr->value; + } + else + { + FIXME( "unhandled attribute %s\n", debugstr_w(attr->name) ); + free_attr( attr ); + } + len -= used; + p += used; } if (!cookie_domain && !(cookie_domain = strdupW( request->connect->servername ))) goto end; if (!cookie_path && !(cookie_path = strdupW( request->path ))) goto end; @@ -214,8 +270,10 @@ end: if (!ret) free_cookie( cookie ); - heap_free( cookie_domain ); - heap_free( cookie_path ); + if (domain) free_attr( domain ); + else heap_free( cookie_domain ); + if (path) free_attr( path ); + else heap_free( cookie_path ); heap_free( buffer ); return ret; } Modified: trunk/reactos/dll/win32/winhttp/request.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/request.…
============================================================================== --- trunk/reactos/dll/win32/winhttp/request.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/request.c [iso-8859-1] Sun Jun 4 01:48:31 2017 @@ -357,25 +357,21 @@ static BOOL insert_header( request_t *request, header_t *header ) { - DWORD count; + DWORD count = request->num_headers + 1; header_t *hdrs; - count = request->num_headers + 1; - if (count > 1) + if (request->headers) hdrs = heap_realloc_zero( request->headers, sizeof(header_t) * count ); else - hdrs = heap_alloc_zero( sizeof(header_t) * count ); - - if (hdrs) - { - request->headers = hdrs; - request->headers[count - 1].field = strdupW( header->field ); - request->headers[count - 1].value = strdupW( header->value ); - request->headers[count - 1].is_request = header->is_request; - request->num_headers++; - return TRUE; - } - return FALSE; + hdrs = heap_alloc_zero( sizeof(header_t) ); + if (!hdrs) return FALSE; + + request->headers = hdrs; + request->headers[count - 1].field = strdupW( header->field ); + request->headers[count - 1].value = strdupW( header->value ); + request->headers[count - 1].is_request = header->is_request; + request->num_headers = count; + return TRUE; } static BOOL delete_header( request_t *request, DWORD index ) @@ -1106,6 +1102,205 @@ } } +/* remove some amount of data from the read buffer */ +static void remove_data( request_t *request, int count ) +{ + if (!(request->read_size -= count)) request->read_pos = 0; + else request->read_pos += count; +} + +/* read some more data into the read buffer */ +static BOOL read_more_data( request_t *request, int maxlen, BOOL notify ) +{ + int len; + BOOL ret; + + if (request->read_chunked_eof) return FALSE; + + if (request->read_size && request->read_pos) + { + /* move existing data to the start of the buffer */ + memmove( request->read_buf, request->read_buf + request->read_pos, request->read_size ); + request->read_pos = 0; + } + if (maxlen == -1) maxlen = sizeof(request->read_buf); + + if (notify) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, NULL, 0 ); + + ret = netconn_recv( &request->netconn, request->read_buf + request->read_size, + maxlen - request->read_size, 0, &len ); + + if (notify) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, &len, sizeof(len) ); + + request->read_size += len; + return ret; +} + +/* discard data contents until we reach end of line */ +static BOOL discard_eol( request_t *request, BOOL notify ) +{ + do + { + char *eol = memchr( request->read_buf + request->read_pos, '\n', request->read_size ); + if (eol) + { + remove_data( request, (eol + 1) - (request->read_buf + request->read_pos) ); + break; + } + request->read_pos = request->read_size = 0; /* discard everything */ + if (!read_more_data( request, -1, notify )) return FALSE; + } while (request->read_size); + return TRUE; +} + +/* read the size of the next chunk */ +static BOOL start_next_chunk( request_t *request, BOOL notify ) +{ + DWORD chunk_size = 0; + + assert(!request->read_chunked_size || request->read_chunked_size == ~0u); + + if (request->read_chunked_eof) return FALSE; + + /* read terminator for the previous chunk */ + if (!request->read_chunked_size && !discard_eol( request, notify )) return FALSE; + + for (;;) + { + while (request->read_size) + { + char ch = request->read_buf[request->read_pos]; + if (ch >= '0' && ch <= '9') chunk_size = chunk_size * 16 + ch - '0'; + else if (ch >= 'a' && ch <= 'f') chunk_size = chunk_size * 16 + ch - 'a' + 10; + else if (ch >= 'A' && ch <= 'F') chunk_size = chunk_size * 16 + ch - 'A' + 10; + else if (ch == ';' || ch == '\r' || ch == '\n') + { + TRACE("reading %u byte chunk\n", chunk_size); + + if (request->content_length == ~0u) request->content_length = chunk_size; + else request->content_length += chunk_size; + + request->read_chunked_size = chunk_size; + if (!chunk_size) request->read_chunked_eof = TRUE; + + return discard_eol( request, notify ); + } + remove_data( request, 1 ); + } + if (!read_more_data( request, -1, notify )) return FALSE; + if (!request->read_size) + { + request->content_length = request->content_read = 0; + request->read_chunked_size = 0; + return TRUE; + } + } +} + +static BOOL refill_buffer( request_t *request, BOOL notify ) +{ + int len = sizeof(request->read_buf); + + if (request->read_chunked) + { + if (request->read_chunked_eof) return FALSE; + if (request->read_chunked_size == ~0u || !request->read_chunked_size) + { + if (!start_next_chunk( request, notify )) return FALSE; + } + len = min( len, request->read_chunked_size ); + } + else if (request->content_length != ~0u) + { + len = min( len, request->content_length - request->content_read ); + } + + if (len <= request->read_size) return TRUE; + if (!read_more_data( request, len, notify )) return FALSE; + if (!request->read_size) request->content_length = request->content_read = 0; + return TRUE; +} + +static void finished_reading( request_t *request ) +{ + static const WCHAR closeW[] = {'c','l','o','s','e',0}; + + BOOL close = FALSE; + WCHAR connection[20]; + DWORD size = sizeof(connection); + + if (request->hdr.disable_flags & WINHTTP_DISABLE_KEEP_ALIVE) close = TRUE; + else if (query_headers( request, WINHTTP_QUERY_CONNECTION, NULL, connection, &size, NULL ) || + query_headers( request, WINHTTP_QUERY_PROXY_CONNECTION, NULL, connection, &size, NULL )) + { + if (!strcmpiW( connection, closeW )) close = TRUE; + } + else if (!strcmpW( request->version, http1_0 )) close = TRUE; + if (close) close_connection( request ); +} + +/* return the size of data available to be read immediately */ +static DWORD get_available_data( request_t *request ) +{ + if (request->read_chunked) return min( request->read_chunked_size, request->read_size ); + return request->read_size; +} + +/* check if we have reached the end of the data to read */ +static BOOL end_of_read_data( request_t *request ) +{ + if (!request->content_length) return TRUE; + if (request->read_chunked) return request->read_chunked_eof; + if (request->content_length == ~0u) return FALSE; + return (request->content_length == request->content_read); +} + +static BOOL read_data( request_t *request, void *buffer, DWORD size, DWORD *read, BOOL async ) +{ + int count, bytes_read = 0; + + if (end_of_read_data( request )) goto done; + + while (size) + { + if (!(count = get_available_data( request ))) + { + if (!refill_buffer( request, async )) goto done; + if (!(count = get_available_data( request ))) goto done; + } + count = min( count, size ); + memcpy( (char *)buffer + bytes_read, request->read_buf + request->read_pos, count ); + remove_data( request, count ); + if (request->read_chunked) request->read_chunked_size -= count; + size -= count; + bytes_read += count; + request->content_read += count; + if (end_of_read_data( request )) goto done; + } + if (request->read_chunked && !request->read_chunked_size) refill_buffer( request, async ); + +done: + TRACE( "retrieved %u bytes (%u/%u)\n", bytes_read, request->content_read, request->content_length ); + + if (async) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, buffer, bytes_read ); + if (read) *read = bytes_read; + if (end_of_read_data( request )) finished_reading( request ); + return TRUE; +} + +/* read any content returned by the server so that the connection can be reused */ +static void drain_content( request_t *request ) +{ + DWORD bytes_read; + char buffer[2048]; + + refill_buffer( request, FALSE ); + for (;;) + { + if (!read_data( request, buffer, sizeof(buffer), &bytes_read, FALSE ) || !bytes_read) return; + } +} + static BOOL send_request( request_t *request, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context, BOOL async ) { @@ -1122,6 +1317,7 @@ DWORD len; clear_response_headers( request ); + drain_content( request ); if (session->agent) process_header( request, attr_user_agent, session->agent, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE ); @@ -1300,7 +1496,7 @@ static BOOL query_auth_schemes( request_t *request, DWORD level, LPDWORD supported, LPDWORD first ) { - DWORD index = 0; + DWORD index = 0, supported_schemes = 0, first_scheme = 0; BOOL ret = FALSE; for (;;) @@ -1321,14 +1517,18 @@ } scheme = auth_scheme_from_header( buffer ); heap_free( buffer ); - if (!scheme) break; - - if (first && index == 1) - *first = *supported = scheme; - else - *supported |= scheme; + if (!scheme) continue; + + if (!first_scheme) first_scheme = scheme; + supported_schemes |= scheme; ret = TRUE; + } + + if (ret) + { + *supported = supported_schemes; + *first = first_scheme; } return ret; } @@ -1894,40 +2094,6 @@ return request->content_length; } -/* read some more data into the read buffer */ -static BOOL read_more_data( request_t *request, int maxlen, BOOL notify ) -{ - int len; - BOOL ret; - - if (request->read_chunked_eof) return FALSE; - - if (request->read_size && request->read_pos) - { - /* move existing data to the start of the buffer */ - memmove( request->read_buf, request->read_buf + request->read_pos, request->read_size ); - request->read_pos = 0; - } - if (maxlen == -1) maxlen = sizeof(request->read_buf); - - if (notify) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, NULL, 0 ); - - ret = netconn_recv( &request->netconn, request->read_buf + request->read_size, - maxlen - request->read_size, 0, &len ); - - if (notify) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, &len, sizeof(len) ); - - request->read_size += len; - return ret; -} - -/* remove some amount of data from the read buffer */ -static void remove_data( request_t *request, int count ) -{ - if (!(request->read_size -= count)) request->read_pos = 0; - else request->read_pos += count; -} - static BOOL read_line( request_t *request, char *buffer, DWORD *len ) { int count, bytes_read, pos = 0; @@ -1963,107 +2129,6 @@ } buffer[*len - 1] = 0; TRACE("returning %s\n", debugstr_a(buffer)); - return TRUE; -} - -/* discard data contents until we reach end of line */ -static BOOL discard_eol( request_t *request, BOOL notify ) -{ - do - { - char *eol = memchr( request->read_buf + request->read_pos, '\n', request->read_size ); - if (eol) - { - remove_data( request, (eol + 1) - (request->read_buf + request->read_pos) ); - break; - } - request->read_pos = request->read_size = 0; /* discard everything */ - if (!read_more_data( request, -1, notify )) return FALSE; - } while (request->read_size); - return TRUE; -} - -/* read the size of the next chunk */ -static BOOL start_next_chunk( request_t *request, BOOL notify ) -{ - DWORD chunk_size = 0; - - assert(!request->read_chunked_size || request->read_chunked_size == ~0u); - - if (request->read_chunked_eof) return FALSE; - - /* read terminator for the previous chunk */ - if (!request->read_chunked_size && !discard_eol( request, notify )) return FALSE; - - for (;;) - { - while (request->read_size) - { - char ch = request->read_buf[request->read_pos]; - if (ch >= '0' && ch <= '9') chunk_size = chunk_size * 16 + ch - '0'; - else if (ch >= 'a' && ch <= 'f') chunk_size = chunk_size * 16 + ch - 'a' + 10; - else if (ch >= 'A' && ch <= 'F') chunk_size = chunk_size * 16 + ch - 'A' + 10; - else if (ch == ';' || ch == '\r' || ch == '\n') - { - TRACE("reading %u byte chunk\n", chunk_size); - - if (request->content_length == ~0u) request->content_length = chunk_size; - else request->content_length += chunk_size; - - request->read_chunked_size = chunk_size; - if (!chunk_size) request->read_chunked_eof = TRUE; - - return discard_eol( request, notify ); - } - remove_data( request, 1 ); - } - if (!read_more_data( request, -1, notify )) return FALSE; - if (!request->read_size) - { - request->content_length = request->content_read = 0; - request->read_chunked_size = 0; - return TRUE; - } - } -} - -/* return the size of data available to be read immediately */ -static DWORD get_available_data( request_t *request ) -{ - if (request->read_chunked) return min( request->read_chunked_size, request->read_size ); - return request->read_size; -} - -/* check if we have reached the end of the data to read */ -static BOOL end_of_read_data( request_t *request ) -{ - if (!request->content_length) return TRUE; - if (request->read_chunked) return request->read_chunked_eof; - if (request->content_length == ~0u) return FALSE; - return (request->content_length == request->content_read); -} - -static BOOL refill_buffer( request_t *request, BOOL notify ) -{ - int len = sizeof(request->read_buf); - - if (request->read_chunked) - { - if (request->read_chunked_eof) return FALSE; - if (request->read_chunked_size == ~0u || !request->read_chunked_size) - { - if (!start_next_chunk( request, notify )) return FALSE; - } - len = min( len, request->read_chunked_size ); - } - else if (request->content_length != ~0u) - { - len = min( len, request->content_length - request->content_read ); - } - - if (len <= request->read_size) return TRUE; - if (!read_more_data( request, len, notify )) return FALSE; - if (!request->read_size) request->content_length = request->content_read = 0; return TRUE; } @@ -2167,70 +2232,6 @@ TRACE("raw headers: %s\n", debugstr_w(raw_headers)); return TRUE; -} - -static void finished_reading( request_t *request ) -{ - static const WCHAR closeW[] = {'c','l','o','s','e',0}; - - BOOL close = FALSE; - WCHAR connection[20]; - DWORD size = sizeof(connection); - - if (request->hdr.disable_flags & WINHTTP_DISABLE_KEEP_ALIVE) close = TRUE; - else if (query_headers( request, WINHTTP_QUERY_CONNECTION, NULL, connection, &size, NULL ) || - query_headers( request, WINHTTP_QUERY_PROXY_CONNECTION, NULL, connection, &size, NULL )) - { - if (!strcmpiW( connection, closeW )) close = TRUE; - } - else if (!strcmpW( request->version, http1_0 )) close = TRUE; - if (close) close_connection( request ); -} - -static BOOL read_data( request_t *request, void *buffer, DWORD size, DWORD *read, BOOL async ) -{ - int count, bytes_read = 0; - - if (end_of_read_data( request )) goto done; - - while (size) - { - if (!(count = get_available_data( request ))) - { - if (!refill_buffer( request, async )) goto done; - if (!(count = get_available_data( request ))) goto done; - } - count = min( count, size ); - memcpy( (char *)buffer + bytes_read, request->read_buf + request->read_pos, count ); - remove_data( request, count ); - if (request->read_chunked) request->read_chunked_size -= count; - size -= count; - bytes_read += count; - request->content_read += count; - if (end_of_read_data( request )) goto done; - } - if (request->read_chunked && !request->read_chunked_size) refill_buffer( request, async ); - -done: - TRACE( "retrieved %u bytes (%u/%u)\n", bytes_read, request->content_read, request->content_length ); - - if (async) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, buffer, bytes_read ); - if (read) *read = bytes_read; - if (end_of_read_data( request )) finished_reading( request ); - return TRUE; -} - -/* read any content returned by the server so that the connection can be reused */ -static void drain_content( request_t *request ) -{ - DWORD bytes_read; - char buffer[2048]; - - refill_buffer( request, FALSE ); - for (;;) - { - if (!read_data( request, buffer, sizeof(buffer), &bytes_read, FALSE ) || !bytes_read) return; - } } static void record_cookies( request_t *request ) @@ -2299,7 +2300,6 @@ heap_free( request->path ); request->path = path; - drain_content( request ); send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_REDIRECT, location, len_url + 1 ); } else @@ -2316,7 +2316,6 @@ request->hdr.flags |= WINHTTP_FLAG_SECURE; } - drain_content( request ); send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_REDIRECT, location, len_url + 1 ); len = uc.dwHostNameLength; @@ -2407,7 +2406,6 @@ if (request->hdr.disable_flags & WINHTTP_DISABLE_AUTHENTICATION) break; if (!handle_authorization( request, status )) break; - drain_content( request ); /* recurse synchronously */ if ((ret = send_request( request, NULL, 0, request->optional, request->optional_len, 0, 0, FALSE ))) continue; Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Jun 4 01:48:31 2017 @@ -200,7 +200,7 @@ reactos/dll/win32/windowscodecsext # Synced to WineStaging-1.9.11 reactos/dll/win32/winemp3.acm # Synced to WineStaging-2.2 reactos/dll/win32/wing32 # Synced to WineStaging-1.9.11 -reactos/dll/win32/winhttp # Synced to WineStaging-2.2 +reactos/dll/win32/winhttp # Synced to WineStaging-2.9 reactos/dll/win32/wininet # Synced to WineStaging-2.2 reactos/dll/win32/winmm # Forked at Wine-20050628 reactos/dll/win32/winmm/midimap # Forked at Wine-20050628
7 years, 6 months
1
0
0
0
[akhaldi] 74863: [WINDOWSCODECS_WINETEST] Sync with Wine Staging 2.9. CORE-13362
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Jun 4 01:48:23 2017 New Revision: 74863 URL:
http://svn.reactos.org/svn/reactos?rev=74863&view=rev
Log: [WINDOWSCODECS_WINETEST] Sync with Wine Staging 2.9. CORE-13362 Modified: trunk/rostests/winetests/windowscodecs/CMakeLists.txt trunk/rostests/winetests/windowscodecs/converter.c trunk/rostests/winetests/windowscodecs/metadata.c trunk/rostests/winetests/windowscodecs/pngformat.c trunk/rostests/winetests/windowscodecs/tiffformat.c Modified: trunk/rostests/winetests/windowscodecs/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/windowscodecs/C…
============================================================================== --- trunk/rostests/winetests/windowscodecs/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/winetests/windowscodecs/CMakeLists.txt [iso-8859-1] Sun Jun 4 01:48:23 2017 @@ -18,7 +18,7 @@ add_executable(windowscodecs_winetest ${SOURCE}) set_module_type(windowscodecs_winetest win32cui) -add_importlibs(windowscodecs_winetest windowscodecs oleaut32 ole32 user32 gdi32 msvcrt kernel32) +add_importlibs(windowscodecs_winetest windowscodecs oleaut32 ole32 user32 gdi32 shlwapi msvcrt kernel32) if(MSVC) add_importlibs(windowscodecs_winetest ntdll) Modified: trunk/rostests/winetests/windowscodecs/converter.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/windowscodecs/c…
============================================================================== --- trunk/rostests/winetests/windowscodecs/converter.c [iso-8859-1] (original) +++ trunk/rostests/winetests/windowscodecs/converter.c [iso-8859-1] Sun Jun 4 01:48:23 2017 @@ -296,6 +296,21 @@ if (!equal && expect->alt_data) equal = compare_bits(expect->alt_data, buffersize, converted_bits); + if (!equal && winetest_debug > 1) + { + UINT i, bps; + bps = expect->bpp / 8; + if (!bps) bps = buffersize; + printf("converted_bits (%u bytes):\n ", buffersize); + for (i = 0; i < buffersize; i++) + { + printf("%u,", converted_bits[i]); + if (!((i + 1) % 32)) printf("\n "); + else if (!((i+1) % bps)) printf(" "); + } + printf("\n"); + } + return equal; } @@ -443,6 +458,10 @@ 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80}; static const struct bitmap_data testdata_32bppBGR = { &GUID_WICPixelFormat32bppBGR, 32, bits_32bppBGR, 32, 2, 96.0, 96.0}; +static const struct bitmap_data testdata_32bppBGRA80 = { + &GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGR, 32, 2, 96.0, 96.0}; +static const struct bitmap_data testdata_32bppRGBA80 = { + &GUID_WICPixelFormat32bppRGBA, 32, bits_32bppBGR, 32, 2, 96.0, 96.0}; static const BYTE bits_32bppBGRA[] = { 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, @@ -455,6 +474,24 @@ 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255}; static const struct bitmap_data testdata_32bppBGRA = { &GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGRA, 32, 2, 96.0, 96.0}; +static const struct bitmap_data testdata_32bppRGBA = { + &GUID_WICPixelFormat32bppRGBA, 32, bits_32bppBGRA, 32, 2, 96.0, 96.0}; +static const struct bitmap_data testdata_32bppRGB = { + &GUID_WICPixelFormat32bppRGB, 32, bits_32bppBGRA, 32, 2, 96.0, 96.0}; + +static const BYTE bits_32bppPBGRA[] = { + 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80, 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80, + 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80, 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80, + 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80, 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80, + 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80, 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80, + 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80, 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80, + 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80, 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80, + 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80, 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80, + 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80, 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80}; +static const struct bitmap_data testdata_32bppPBGRA = { + &GUID_WICPixelFormat32bppPBGRA, 32, bits_32bppPBGRA, 32, 2, 96.0, 96.0}; +static const struct bitmap_data testdata_32bppPRGBA = { + &GUID_WICPixelFormat32bppPRGBA, 32, bits_32bppPBGRA, 32, 2, 96.0, 96.0}; /* XP and 2003 use linear color conversion, later versions use sRGB gamma */ static const float bits_32bppGrayFloat_xp[] = { @@ -520,7 +557,7 @@ hr = WICConvertBitmapSource(dst->format, &src_obj->IWICBitmapSource_iface, &dst_bitmap); todo_wine_if (todo) ok(hr == S_OK || - broken(hr == E_INVALIDARG) /* XP */, "WICConvertBitmapSource(%s) failed, hr=%x\n", name, hr); + broken(hr == E_INVALIDARG || hr == WINCODEC_ERR_COMPONENTNOTFOUND) /* XP */, "WICConvertBitmapSource(%s) failed, hr=%x\n", name, hr); if (hr == S_OK) { @@ -587,11 +624,13 @@ VARTYPE initial_var_type; int i_init_val; float f_init_val; + BOOL skippable; } property_opt_test_data; static const WCHAR wszTiffCompressionMethod[] = {'T','i','f','f','C','o','m','p','r','e','s','s','i','o','n','M','e','t','h','o','d',0}; static const WCHAR wszCompressionQuality[] = {'C','o','m','p','r','e','s','s','i','o','n','Q','u','a','l','i','t','y',0}; static const WCHAR wszInterlaceOption[] = {'I','n','t','e','r','l','a','c','e','O','p','t','i','o','n',0}; +static const WCHAR wszFilterOption[] = {'F','i','l','t','e','r','O','p','t','i','o','n',0}; static const struct property_opt_test_data testdata_tiff_props[] = { { wszTiffCompressionMethod, VT_UI1, VT_UI1, WICTiffCompressionDontCare }, @@ -599,6 +638,12 @@ { NULL } }; +static const struct property_opt_test_data testdata_png_props[] = { + { wszInterlaceOption, VT_BOOL, VT_BOOL, 0 }, + { wszFilterOption, VT_UI1, VT_UI1, WICPngFilterUnspecified, 0.0f, TRUE /* not supported on XP/2k3 */}, + { NULL } +}; + static int find_property_index(const WCHAR* name, PROPBAG2* all_props, int all_prop_cnt) { int i; @@ -624,6 +669,13 @@ pb.pstrName = (LPOLESTR)data[i].name; hr = IPropertyBag2_Read(options, 1, &pb, NULL, &pvarValue, &phrError); + + if (data[i].skippable && idx == -1) + { + win_skip("Property %s is not supported on this machine.\n", wine_dbgstr_w(data[i].name)); + i++; + continue; + } ok(idx >= 0, "Property %s not in output of GetPropertyInfo\n", wine_dbgstr_w(data[i].name)); @@ -712,8 +764,10 @@ (int)cProperties, (int)cProperties2); } - if (clsid_encoder == &CLSID_WICTiffEncoder) + if (IsEqualCLSID(clsid_encoder, &CLSID_WICTiffEncoder)) test_specific_encoder_properties(options, testdata_tiff_props, all_props, cProperties2); + else if (IsEqualCLSID(clsid_encoder, &CLSID_WICPngEncoder)) + test_specific_encoder_properties(options, testdata_png_props, all_props, cProperties2); for (i=0; i < cProperties2; i++) { @@ -727,9 +781,9 @@ HRESULT hr; IWICPersistStream *persist; #ifdef WORDS_BIGENDIAN - DWORD persist_options = WICPersistOptionsBigEndian; + DWORD persist_options = WICPersistOptionBigEndian; #else - DWORD persist_options = WICPersistOptionsLittleEndian; + DWORD persist_options = WICPersistOptionLittleEndian; #endif hr = IUnknown_QueryInterface(reader, &IID_IWICPersistStream, (void **)&persist); @@ -1117,6 +1171,50 @@ void *value; }; +#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__) +static void _expect_ref(IUnknown* obj, ULONG ref, int line) +{ + ULONG rc; + IUnknown_AddRef(obj); + rc = IUnknown_Release(obj); + ok_(__FILE__,line)(rc == ref, "expected refcount %d, got %d\n", ref, rc); +} + +static void test_set_frame_palette(IWICBitmapFrameEncode *frameencode) +{ + IWICComponentFactory *factory; + IWICPalette *palette; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, + &IID_IWICComponentFactory, (void **)&factory); + ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr); + + hr = IWICBitmapFrameEncode_SetPalette(frameencode, NULL); + ok(hr == E_INVALIDARG, "SetPalette failed, hr=%x\n", hr); + + hr = IWICComponentFactory_CreatePalette(factory, &palette); + ok(hr == S_OK, "CreatePalette failed, hr=%x\n", hr); + + hr = IWICBitmapFrameEncode_SetPalette(frameencode, palette); +todo_wine + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr=%x\n", hr); + + hr = IWICPalette_InitializePredefined(palette, WICBitmapPaletteTypeFixedHalftone256, FALSE); + ok(hr == S_OK, "InitializePredefined failed, hr=%x\n", hr); + + EXPECT_REF(palette, 1); + hr = IWICBitmapFrameEncode_SetPalette(frameencode, palette); + ok(hr == S_OK, "SetPalette failed, hr=%x\n", hr); + EXPECT_REF(palette, 1); + + hr = IWICBitmapFrameEncode_SetPalette(frameencode, NULL); + ok(hr == E_INVALIDARG, "SetPalette failed, hr=%x\n", hr); + + IWICPalette_Release(palette); + IWICComponentFactory_Release(factory); +} + static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* clsid_encoder, const struct bitmap_data **dsts, const CLSID *clsid_decoder, WICRect *rc, const struct setting *settings, const char *name, IWICPalette *palette) @@ -1219,6 +1317,9 @@ hr = IWICBitmapFrameEncode_SetSize(frameencode, srcs[i]->width, srcs[i]->height); ok(SUCCEEDED(hr), "SetSize failed, hr=%x\n", hr); + + if (IsEqualGUID(clsid_encoder, &CLSID_WICPngEncoder)) + test_set_frame_palette(frameencode); if (palette) { @@ -1680,7 +1781,7 @@ test_converter_8bppIndexed(); - test_conversion(&testdata_24bppRGB, &testdata_2bppIndexed, "24bppRGB -> 1bppIndexed", TRUE); + test_conversion(&testdata_24bppRGB, &testdata_1bppIndexed, "24bppRGB -> 1bppIndexed", TRUE); test_conversion(&testdata_24bppRGB, &testdata_2bppIndexed, "24bppRGB -> 2bppIndexed", TRUE); test_conversion(&testdata_24bppRGB, &testdata_4bppIndexed, "24bppRGB -> 4bppIndexed", TRUE); test_conversion(&testdata_24bppRGB, &testdata_8bppIndexed, "24bppRGB -> 8bppIndexed", FALSE); @@ -1693,6 +1794,12 @@ test_conversion(&testdata_32bppBGRA, &testdata_32bppBGR, "BGRA -> BGR", FALSE); test_conversion(&testdata_32bppBGR, &testdata_32bppBGRA, "BGR -> BGRA", FALSE); test_conversion(&testdata_32bppBGRA, &testdata_32bppBGRA, "BGRA -> BGRA", FALSE); + test_conversion(&testdata_32bppBGRA80, &testdata_32bppPBGRA, "BGRA -> PBGRA", FALSE); + + test_conversion(&testdata_32bppRGBA, &testdata_32bppRGB, "RGBA -> RGB", FALSE); + test_conversion(&testdata_32bppRGB, &testdata_32bppRGBA, "RGB -> RGBA", FALSE); + test_conversion(&testdata_32bppRGBA, &testdata_32bppRGBA, "RGBA -> RGBA", FALSE); + test_conversion(&testdata_32bppRGBA80, &testdata_32bppPRGBA, "RGBA -> PRGBA", FALSE); test_conversion(&testdata_24bppBGR, &testdata_24bppBGR, "24bppBGR -> 24bppBGR", FALSE); test_conversion(&testdata_24bppBGR, &testdata_24bppRGB, "24bppBGR -> 24bppRGB", FALSE); Modified: trunk/rostests/winetests/windowscodecs/metadata.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/windowscodecs/m…
============================================================================== --- trunk/rostests/winetests/windowscodecs/metadata.c [iso-8859-1] (original) +++ trunk/rostests/winetests/windowscodecs/metadata.c [iso-8859-1] Sun Jun 4 01:48:23 2017 @@ -1,6 +1,6 @@ /* * Copyright 2011 Vincent Povirk for CodeWeavers - * Copyright 2012 Dmitry Timoshkov + * Copyright 2012,2017 Dmitry Timoshkov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -267,7 +267,7 @@ ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr); if (FAILED(hr)) return; - load_stream((IUnknown*)reader, metadata_unknown, sizeof(metadata_unknown), WICPersistOptionsDefault); + load_stream((IUnknown*)reader, metadata_unknown, sizeof(metadata_unknown), WICPersistOptionDefault); hr = IWICMetadataReader_GetEnumerator(reader, &enumerator); ok(hr == S_OK, "GetEnumerator failed, hr=%x\n", hr); @@ -334,7 +334,7 @@ ok(hr == S_OK, "GetCount failed, hr=%x\n", hr); ok(count == 0, "unexpected count %i\n", count); - load_stream((IUnknown*)reader, metadata_tEXt, sizeof(metadata_tEXt), WICPersistOptionsDefault); + load_stream((IUnknown*)reader, metadata_tEXt, sizeof(metadata_tEXt), WICPersistOptionDefault); hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount failed, hr=%x\n", hr); @@ -445,7 +445,7 @@ ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG) /*winxp*/, "CoCreateInstance failed, hr=%x\n", hr); if (FAILED(hr)) return; - load_stream((IUnknown*)reader, metadata_gAMA, sizeof(metadata_gAMA), WICPersistOptionsDefault); + load_stream((IUnknown*)reader, metadata_gAMA, sizeof(metadata_gAMA), WICPersistOptionDefault); hr = IWICMetadataReader_GetMetadataFormat(reader, &format); ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr); @@ -503,7 +503,7 @@ ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG) /*winxp*/, "CoCreateInstance failed, hr=%x\n", hr); if (FAILED(hr)) return; - load_stream((IUnknown*)reader, metadata_cHRM, sizeof(metadata_cHRM), WICPersistOptionsDefault); + load_stream((IUnknown*)reader, metadata_cHRM, sizeof(metadata_cHRM), WICPersistOptionDefault); hr = IWICMetadataReader_GetMetadataFormat(reader, &format); ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr); @@ -797,9 +797,9 @@ GUID format; char *IFD_data_swapped; #ifdef WORDS_BIGENDIAN - DWORD persist_options = WICPersistOptionsBigEndian; + DWORD persist_options = WICPersistOptionBigEndian; #else - DWORD persist_options = WICPersistOptionsLittleEndian; + DWORD persist_options = WICPersistOptionLittleEndian; #endif hr = CoCreateInstance(&CLSID_WICIfdMetadataReader, NULL, CLSCTX_INPROC_SERVER, @@ -822,10 +822,10 @@ compare_metadata(reader, td, count); /* test IFD data with different endianness */ - if (persist_options == WICPersistOptionsLittleEndian) - persist_options = WICPersistOptionsBigEndian; + if (persist_options == WICPersistOptionLittleEndian) + persist_options = WICPersistOptionBigEndian; else - persist_options = WICPersistOptionsLittleEndian; + persist_options = WICPersistOptionLittleEndian; IFD_data_swapped = HeapAlloc(GetProcessHeap(), 0, sizeof(IFD_data)); memcpy(IFD_data_swapped, &IFD_data, sizeof(IFD_data)); @@ -969,22 +969,22 @@ stream = create_stream(metadata_tEXt, sizeof(metadata_tEXt)); hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory, - NULL, NULL, WICPersistOptionsDefault, + NULL, NULL, WICPersistOptionDefault, stream, &reader); ok(hr == E_INVALIDARG, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr); hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory, - &GUID_ContainerFormatPng, NULL, WICPersistOptionsDefault, + &GUID_ContainerFormatPng, NULL, WICPersistOptionDefault, NULL, &reader); ok(hr == E_INVALIDARG, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr); hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory, - &GUID_ContainerFormatPng, NULL, WICPersistOptionsDefault, + &GUID_ContainerFormatPng, NULL, WICPersistOptionDefault, stream, NULL); ok(hr == E_INVALIDARG, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr); hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory, - &GUID_ContainerFormatPng, NULL, WICPersistOptionsDefault, + &GUID_ContainerFormatPng, NULL, WICPersistOptionDefault, stream, &reader); ok(hr == S_OK, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr); @@ -1002,7 +1002,7 @@ } hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory, - &GUID_ContainerFormatWmp, NULL, WICPersistOptionsDefault, + &GUID_ContainerFormatWmp, NULL, WICPersistOptionDefault, stream, &reader); ok(hr == S_OK, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr); @@ -1965,10 +1965,300 @@ IStream_Release(stream); } +static void test_WICMapGuidToShortName(void) +{ + static const WCHAR unkW[] = { 'u','n','k',0 }; + static const WCHAR unknownW[] = { 'u','n','k','n','o','w','n',0 }; + HRESULT hr; + UINT len; + WCHAR name[16]; + + name[0] = 0; + len = 0xdeadbeef; + hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 8, name, &len); + ok(hr == S_OK, "got %#x\n", hr); + ok(len == 8, "got %u\n", len); + ok(!lstrcmpW(name, unknownW), "got %s\n", wine_dbgstr_w(name)); + + name[0] = 0; + hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 8, name, NULL); + ok(hr == S_OK, "got %#x\n", hr); + ok(!lstrcmpW(name, unknownW), "got %s\n", wine_dbgstr_w(name)); + + len = 0xdeadbeef; + hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 8, NULL, &len); + ok(hr == S_OK, "got %#x\n", hr); + ok(len == 8, "got %u\n", len); + + len = 0xdeadbeef; + hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 0, NULL, &len); + ok(hr == S_OK, "got %#x\n", hr); + ok(len == 8, "got %u\n", len); + + hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 0, NULL, NULL); + ok(hr == S_OK, "got %#x\n", hr); + + hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 8, NULL, NULL); + ok(hr == S_OK, "got %#x\n", hr); + + hr = WICMapGuidToShortName(&GUID_NULL, 0, NULL, NULL); + ok(hr == WINCODEC_ERR_PROPERTYNOTFOUND, "got %#x\n", hr); + + name[0] = 0; + len = 0xdeadbeef; + hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 4, name, &len); + ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "got %#x\n", hr); + ok(len == 0xdeadbeef, "got %u\n", len); + ok(!lstrcmpW(name, unkW), "got %s\n", wine_dbgstr_w(name)); + + name[0] = 0; + len = 0xdeadbeef; + hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 0, name, &len); + ok(hr == E_INVALIDARG, "got %#x\n", hr); + ok(len == 0xdeadbeef, "got %u\n", len); + ok(!name[0], "got %s\n", wine_dbgstr_w(name)); + + hr = WICMapGuidToShortName(NULL, 8, name, NULL); + ok(hr == E_INVALIDARG, "got %#x\n", hr); +} + +static void test_WICMapShortNameToGuid(void) +{ + static const WCHAR unkW[] = { 'u','n','k',0 }; + static const WCHAR xmpW[] = { 'x','m','p',0 }; + static const WCHAR XmPW[] = { 'X','m','P',0 }; + static const WCHAR unknownW[] = { 'u','n','k','n','o','w','n',0 }; + HRESULT hr; + GUID guid; + + hr = WICMapShortNameToGuid(NULL, NULL); + ok(hr == E_INVALIDARG, "got %#x\n", hr); + + hr = WICMapShortNameToGuid(NULL, &guid); + ok(hr == E_INVALIDARG, "got %#x\n", hr); + + hr = WICMapShortNameToGuid(unknownW, NULL); + ok(hr == E_INVALIDARG, "got %#x\n", hr); + + hr = WICMapShortNameToGuid(unkW, &guid); + ok(hr == WINCODEC_ERR_PROPERTYNOTFOUND, "got %#x\n", hr); + + hr = WICMapShortNameToGuid(unknownW, &guid); + ok(hr == S_OK, "got %#x\n", hr); + ok(IsEqualGUID(&guid, &GUID_MetadataFormatUnknown), "got %s\n", wine_dbgstr_guid(&guid)); + + hr = WICMapShortNameToGuid(xmpW, &guid); + ok(hr == S_OK, "got %#x\n", hr); + ok(IsEqualGUID(&guid, &GUID_MetadataFormatXMP), "got %s\n", wine_dbgstr_guid(&guid)); + + guid = GUID_NULL; + hr = WICMapShortNameToGuid(XmPW, &guid); + ok(hr == S_OK, "got %#x\n", hr); + ok(IsEqualGUID(&guid, &GUID_MetadataFormatXMP), "got %s\n", wine_dbgstr_guid(&guid)); +} + +static const GUID *guid_list[] = +{ + &GUID_ContainerFormatBmp, + &GUID_ContainerFormatPng, + &GUID_ContainerFormatIco, + &GUID_ContainerFormatJpeg, + &GUID_ContainerFormatTiff, + &GUID_ContainerFormatGif, + &GUID_ContainerFormatWmp, + &GUID_MetadataFormatUnknown, + &GUID_MetadataFormatIfd, + &GUID_MetadataFormatSubIfd, + &GUID_MetadataFormatExif, + &GUID_MetadataFormatGps, + &GUID_MetadataFormatInterop, + &GUID_MetadataFormatApp0, + &GUID_MetadataFormatApp1, + &GUID_MetadataFormatApp13, + &GUID_MetadataFormatIPTC, + &GUID_MetadataFormatIRB, + &GUID_MetadataFormat8BIMIPTC, + &GUID_MetadataFormat8BIMResolutionInfo, + &GUID_MetadataFormat8BIMIPTCDigest, + &GUID_MetadataFormatXMP, + &GUID_MetadataFormatThumbnail, + &GUID_MetadataFormatChunktEXt, + &GUID_MetadataFormatXMPStruct, + &GUID_MetadataFormatXMPBag, + &GUID_MetadataFormatXMPSeq, + &GUID_MetadataFormatXMPAlt, + &GUID_MetadataFormatLSD, + &GUID_MetadataFormatIMD, + &GUID_MetadataFormatGCE, + &GUID_MetadataFormatAPE, + &GUID_MetadataFormatJpegChrominance, + &GUID_MetadataFormatJpegLuminance, + &GUID_MetadataFormatJpegComment, + &GUID_MetadataFormatGifComment, + &GUID_MetadataFormatChunkgAMA, + &GUID_MetadataFormatChunkbKGD, + &GUID_MetadataFormatChunkiTXt, + &GUID_MetadataFormatChunkcHRM, + &GUID_MetadataFormatChunkhIST, + &GUID_MetadataFormatChunkiCCP, + &GUID_MetadataFormatChunksRGB, + &GUID_MetadataFormatChunktIME +}; + +static WCHAR rdf_scheme[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','3','.','o','r','g','/','1','9','9','9','/','0','2','/','2','2','-','r','d','f','-','s','y','n','t','a','x','-','n','s','#',0 }; +static WCHAR dc_scheme[] = { 'h','t','t','p',':','/','/','p','u','r','l','.','o','r','g','/','d','c','/','e','l','e','m','e','n','t','s','/','1','.','1','/',0 }; +static WCHAR xmp_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/',0 }; +static WCHAR xmpidq_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','m','p','/','I','d','e','n','t','i','f','i','e','r','/','q','u','a','l','/','1','.','0','/',0 }; +static WCHAR xmpRights_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','r','i','g','h','t','s','/',0 }; +static WCHAR xmpMM_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','m','m','/',0 }; +static WCHAR xmpBJ_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','b','j','/',0 }; +static WCHAR xmpTPg_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','t','/','p','g','/',0 }; +static WCHAR pdf_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','p','d','f','/','1','.','3','/',0 }; +static WCHAR photoshop_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','p','h','o','t','o','s','h','o','p','/','1','.','0','/',0 }; +static WCHAR tiff_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','t','i','f','f','/','1','.','0','/',0 }; +static WCHAR exif_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','e','x','i','f','/','1','.','0','/',0 }; +static WCHAR stDim_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','s','T','y','p','e','/','D','i','m','e','n','s','i','o','n','s','#',0 }; +static WCHAR xapGImg_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','g','/','i','m','g','/',0 }; +static WCHAR stEvt_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','s','T','y','p','e','/','R','e','s','o','u','r','c','e','E','v','e','n','t','#',0 }; +static WCHAR stRef_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','s','T','y','p','e','/','R','e','s','o','u','r','c','e','R','e','f','#',0 }; +static WCHAR stVer_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','s','T','y','p','e','/','V','e','r','s','i','o','n','#',0 }; +static WCHAR stJob_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','s','T','y','p','e','/','J','o','b','#',0 }; +static WCHAR aux_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','e','x','i','f','/','1','.','0','/','a','u','x','/',0 }; +static WCHAR crs_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','c','a','m','e','r','a','-','r','a','w','-','s','e','t','t','i','n','g','s','/','1','.','0','/',0 }; +static WCHAR xmpDM_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','m','p','/','1','.','0','/','D','y','n','a','m','i','c','M','e','d','i','a','/',0 }; +static WCHAR Iptc4xmpCore_scheme[] = { 'h','t','t','p',':','/','/','i','p','t','c','.','o','r','g','/','s','t','d','/','I','p','t','c','4','x','m','p','C','o','r','e','/','1','.','0','/','x','m','l','n','s','/',0 }; +static WCHAR MicrosoftPhoto_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','p','h','o','t','o','/','1','.','0','/',0 }; +static WCHAR MP_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','p','h','o','t','o','/','1','.','2','/',0 }; +static WCHAR MPRI_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','p','h','o','t','o','/','1','.','2','/','t','/','R','e','g','i','o','n','I','n','f','o','#',0 }; +static WCHAR MPReg_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','p','h','o','t','o','/','1','.','2','/','t','/','R','e','g','i','o','n','#',0 }; + +static WCHAR *schema_list[] = +{ + aux_scheme, + rdf_scheme, + dc_scheme, + xmp_scheme, + xmpidq_scheme, + xmpRights_scheme, + xmpMM_scheme, + xmpBJ_scheme, + xmpTPg_scheme, + pdf_scheme, + photoshop_scheme, + tiff_scheme, + exif_scheme, + stDim_scheme, + xapGImg_scheme, + stEvt_scheme, + stRef_scheme, + stVer_scheme, + stJob_scheme, + crs_scheme, + xmpDM_scheme, + Iptc4xmpCore_scheme, + MicrosoftPhoto_scheme, + MP_scheme, + MPRI_scheme, + MPReg_scheme +}; + +static void test_WICMapSchemaToName(void) +{ + static const WCHAR xmW[] = { 'x','m',0 }; + static const WCHAR xmpW[] = { 'x','m','p',0 }; + static WCHAR schemaW[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/',0 }; + static WCHAR SCHEMAW[] = { 'H','T','T','P',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/',0 }; + HRESULT hr; + UINT len, i, j; + WCHAR name[16]; + + hr = WICMapSchemaToName(&GUID_MetadataFormatUnknown, NULL, 0, NULL, NULL); + ok(hr == E_INVALIDARG, "got %#x\n", hr); + + hr = WICMapSchemaToName(&GUID_MetadataFormatUnknown, schemaW, 0, NULL, NULL); + ok(hr == E_INVALIDARG, "got %#x\n", hr); + + hr = WICMapSchemaToName(&GUID_MetadataFormatUnknown, schemaW, 0, NULL, &len); + ok(hr == WINCODEC_ERR_PROPERTYNOTFOUND, "got %#x\n", hr); + + hr = WICMapSchemaToName(NULL, schemaW, 0, NULL, &len); + ok(hr == E_INVALIDARG, "got %#x\n", hr); + + hr = WICMapSchemaToName(&GUID_MetadataFormatXMP, schemaW, 0, NULL, NULL); + ok(hr == E_INVALIDARG, "got %#x\n", hr); + + len = 0xdeadbeef; + hr = WICMapSchemaToName(&GUID_MetadataFormatXMP, schemaW, 0, NULL, &len); + ok(hr == S_OK, "got %#x\n", hr); + ok(len == 4, "got %u\n", len); + + len = 0xdeadbeef; + hr = WICMapSchemaToName(&GUID_MetadataFormatXMP, schemaW, 4, NULL, &len); + ok(hr == S_OK, "got %#x\n", hr); + ok(len == 4, "got %u\n", len); + + len = 0xdeadbeef; + hr = WICMapSchemaToName(&GUID_MetadataFormatXMP, SCHEMAW, 0, NULL, &len); + ok(hr == WINCODEC_ERR_PROPERTYNOTFOUND, "got %#x\n", hr); + ok(len == 0xdeadbeef, "got %u\n", len); + + name[0] = 0; + len = 0xdeadbeef; + hr = WICMapSchemaToName(&GUID_MetadataFormatXMP, schemaW, 4, name, &len); + ok(hr == S_OK, "got %#x\n", hr); + ok(len == 4, "got %u\n", len); + ok(!lstrcmpW(name, xmpW), "got %s\n", wine_dbgstr_w(name)); + + len = 0xdeadbeef; + hr = WICMapSchemaToName(&GUID_MetadataFormatXMP, schemaW, 0, name, &len); + ok(hr == E_INVALIDARG, "got %#x\n", hr); + ok(len == 0xdeadbeef, "got %u\n", len); + + name[0] = 0; + len = 0xdeadbeef; + hr = WICMapSchemaToName(&GUID_MetadataFormatXMP, schemaW, 3, name, &len); + ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "got %#x\n", hr); + ok(len == 0xdeadbeef, "got %u\n", len); + ok(!lstrcmpW(name, xmW), "got %s\n", wine_dbgstr_w(name)); + + hr = WICMapSchemaToName(&GUID_MetadataFormatXMP, schemaW, 4, name, NULL); + ok(hr == E_INVALIDARG, "got %#x\n", hr); + + /* Check whether modern schemas are supported */ + hr = WICMapSchemaToName(&GUID_MetadataFormatXMP, schema_list[0], 0, NULL, &len); + if (hr == WINCODEC_ERR_PROPERTYNOTFOUND) + { + win_skip("Modern schemas are not supported\n"); + return; + } + + for (i = 0; i < sizeof(guid_list)/sizeof(guid_list[0]); i++) + { + for (j = 0; j < sizeof(schema_list)/sizeof(schema_list[0]); j++) + { + hr = WICMapSchemaToName(guid_list[i], schema_list[j], 0, NULL, &len); + if (IsEqualGUID(guid_list[i], &GUID_MetadataFormatXMP) || + IsEqualGUID(guid_list[i], &GUID_MetadataFormatXMPStruct)) + { + ok(hr == S_OK, "%u: %u: format %s does not support schema %s\n", + i, j, wine_dbgstr_guid(guid_list[i]), wine_dbgstr_w(schema_list[j])); + } + else + { + ok(hr == WINCODEC_ERR_PROPERTYNOTFOUND, "%u: %u: format %s supports schema %s\n", + i, j, wine_dbgstr_guid(guid_list[i]), wine_dbgstr_w(schema_list[j])); + } + } + } +} + START_TEST(metadata) { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + test_WICMapGuidToShortName(); + test_WICMapShortNameToGuid(); + test_WICMapSchemaToName(); test_metadata_unknown(); test_metadata_tEXt(); test_metadata_gAMA(); Modified: trunk/rostests/winetests/windowscodecs/pngformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/windowscodecs/p…
============================================================================== --- trunk/rostests/winetests/windowscodecs/pngformat.c [iso-8859-1] (original) +++ trunk/rostests/winetests/windowscodecs/pngformat.c [iso-8859-1] Sun Jun 4 01:48:23 2017 @@ -31,6 +31,8 @@ #include <ole2.h> #include <wincodec.h> #include <wine/test.h> +#include <winreg.h> +#include <shlwapi.h> /* 1x1 pixel PNG image */ static const char png_no_color_profile[] = { @@ -283,22 +285,17 @@ static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitmapDecoder **decoder) { - HGLOBAL hmem; - BYTE *data; HRESULT hr; IStream *stream; GUID format; LONG refcount; + ULARGE_INTEGER pos; + LARGE_INTEGER zero; *decoder = NULL; - hmem = GlobalAlloc(0, image_size); - data = GlobalLock(hmem); - memcpy(data, image_data, image_size); - GlobalUnlock(hmem); - - hr = CreateStreamOnHGlobal(hmem, TRUE, &stream); - ok(hr == S_OK, "CreateStreamOnHGlobal error %#x\n", hr); + stream = SHCreateMemStream (image_data, image_size); + ok(stream != NULL, "SHCreateMemStream error\n"); hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, decoder); if (hr == S_OK) @@ -307,6 +304,11 @@ 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"); Modified: trunk/rostests/winetests/windowscodecs/tiffformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/windowscodecs/t…
============================================================================== --- trunk/rostests/winetests/windowscodecs/tiffformat.c [iso-8859-1] (original) +++ trunk/rostests/winetests/windowscodecs/tiffformat.c [iso-8859-1] Sun Jun 4 01:48:23 2017 @@ -1,5 +1,5 @@ /* - * Copyright 2012 Dmitry Timoshkov + * Copyright 2012,2016 Dmitry Timoshkov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -140,6 +140,49 @@ { 96, 1 }, { 0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88 } }; + +static const struct tiff_8bpp_data +{ + USHORT byte_order; + USHORT version; + ULONG dir_offset; + USHORT number_of_entries; + struct IFD_entry entry[14]; + ULONG next_IFD; + struct IFD_rational res; + short palette_data[3][256]; + BYTE pixel_data[4]; +} tiff_8bpp_data = +{ +#ifdef WORDS_BIGENDIAN + 'M' | 'M' << 8, +#else + 'I' | 'I' << 8, +#endif + 42, + FIELD_OFFSET(struct tiff_8bpp_data, number_of_entries), + 14, + { + { 0xff, IFD_SHORT, 1, 0 }, /* SUBFILETYPE */ + { 0x100, IFD_LONG, 1, 4 }, /* IMAGEWIDTH */ + { 0x101, IFD_LONG, 1, 1 }, /* IMAGELENGTH */ + { 0x102, IFD_SHORT, 1, 8 }, /* BITSPERSAMPLE: XP doesn't accept IFD_LONG here */ + { 0x103, IFD_SHORT, 1, 1 }, /* COMPRESSION: XP doesn't accept IFD_LONG here */ + { 0x106, IFD_SHORT, 1, 3 }, /* PHOTOMETRIC */ + { 0x111, IFD_LONG, 1, FIELD_OFFSET(struct tiff_8bpp_data, pixel_data) }, /* STRIPOFFSETS */ + { 0x115, IFD_SHORT, 1, 1 }, /* SAMPLESPERPIXEL */ + { 0x116, IFD_LONG, 1, 1 }, /* ROWSPERSTRIP */ + { 0x117, IFD_LONG, 1, 1 }, /* STRIPBYTECOUNT */ + { 0x11a, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_8bpp_data, res) }, + { 0x11b, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_8bpp_data, res) }, + { 0x128, IFD_SHORT, 1, 2 }, /* RESOLUTIONUNIT */ + { 0x140, IFD_SHORT, 256*3, FIELD_OFFSET(struct tiff_8bpp_data, palette_data) } /* COLORMAP */ + }, + 0, + { 96, 1 }, + { { 0 } }, + { 0,1,2,3 } +}; #include "poppack.h" static IWICImagingFactory *factory; @@ -165,29 +208,96 @@ return stream; } -static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size) -{ +static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitmapDecoder **decoder) +{ + HGLOBAL hmem; + BYTE *data; HRESULT hr; IStream *stream; - IWICBitmapDecoder *decoder = NULL; - GUID guid; - - stream = create_stream(image_data, image_size); - - 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, &guid); - ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); - ok(IsEqualGUID(&guid, &GUID_ContainerFormatTiff), "container format is not TIFF\n"); - - IStream_Release(stream); - - return decoder; -} - -static void test_tiff_palette(void) + GUID format; + LONG refcount; + + *decoder = NULL; + + hmem = GlobalAlloc(0, image_size); + data = GlobalLock(hmem); + memcpy(data, image_data, image_size); + GlobalUnlock(hmem); + + hr = CreateStreamOnHGlobal(hmem, TRUE, &stream); + ok(hr == S_OK, "CreateStreamOnHGlobal error %#x\n", hr); + + 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_ContainerFormatTiff), + "wrong container format %s\n", wine_dbgstr_guid(&format)); + + refcount = IStream_Release(stream); + ok(refcount > 0, "expected stream refcount > 0\n"); + } + + return hr; +} + +static HRESULT get_pixelformat_info(const GUID *format, UINT *bpp, UINT *channels, BOOL *trasparency) +{ + HRESULT hr; + IWICComponentInfo *info; + IWICPixelFormatInfo2 *formatinfo; + + hr = IWICImagingFactory_CreateComponentInfo(factory, format, &info); + ok(hr == S_OK, "CreateComponentInfo(%s) error %#x\n", wine_dbgstr_guid(format), hr); + if (hr == S_OK) + { + hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo2, (void **)&formatinfo); + if (hr == S_OK) + { + hr = IWICPixelFormatInfo2_SupportsTransparency(formatinfo, trasparency); + ok(hr == S_OK, "SupportsTransparency error %#x\n", hr); + IWICPixelFormatInfo2_Release(formatinfo); + } + hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo, (void **)&formatinfo); + if (hr == S_OK) + { + hr = IWICPixelFormatInfo2_GetBitsPerPixel(formatinfo, bpp); + ok(hr == S_OK, "GetBitsPerPixel error %#x\n", hr); + hr = IWICPixelFormatInfo2_GetChannelCount(formatinfo, channels); + ok(hr == S_OK, "GetChannelCount error %#x\n", hr); + IWICPixelFormatInfo2_Release(formatinfo); + } + IWICComponentInfo_Release(info); + } + return hr; +} + +static void dump_tiff(void *buf) +{ + UINT count, i; + struct tiff_1bpp_data *tiff; + struct IFD_entry *tag; + + tiff = buf; + count = *(short *)((char *)tiff + tiff->dir_offset); + tag = (struct IFD_entry *)((char *)tiff + tiff->dir_offset + sizeof(short)); + + for (i = 0; i < count; i++) + { + printf("tag %u: id %04x, type %04x, count %u, value %d", + i, tag[i].id, tag[i].type, tag[i].count, tag[i].value); + if (tag[i].id == 0x102 && tag[i].count > 2) + { + short *bps = (short *)((char *)tiff + tag[i].value); + printf(" (%d,%d,%d,%d)\n", bps[0], bps[1], bps[2], bps[3]); + } + else + printf("\n"); + } +} + +static void test_tiff_1bpp_palette(void) { HRESULT hr; IWICBitmapDecoder *decoder; @@ -195,9 +305,9 @@ IWICPalette *palette; GUID format; - decoder = create_decoder(&tiff_1bpp_data, sizeof(tiff_1bpp_data)); - ok(decoder != 0, "Failed to load TIFF image data\n"); - if (!decoder) return; + hr = create_decoder(&tiff_1bpp_data, sizeof(tiff_1bpp_data), &decoder); + ok(hr == S_OK, "Failed to load TIFF 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); @@ -329,9 +439,9 @@ static const BYTE expected_data[16] = { 0x11,0x11,0x11,0x22,0x33,0x33,0x33,0x44, 0x55,0x55,0x55,0x66,0x77,0x77,0x77,0x88 }; - decoder = create_decoder(&tiff_8bpp_alpha, sizeof(tiff_8bpp_alpha)); - ok(decoder != 0, "Failed to load TIFF image data\n"); - if (!decoder) return; + hr = create_decoder(&tiff_8bpp_alpha, sizeof(tiff_8bpp_alpha), &decoder); + ok(hr == S_OK, "Failed to load TIFF image data %#x\n", hr); + if (hr != S_OK) return; hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count); ok(hr == S_OK, "GetFrameCount error %#x\n", hr); @@ -376,6 +486,464 @@ IWICBitmapDecoder_Release(decoder); } +static void generate_tiff_palette(void *buf, unsigned count) +{ + unsigned short *r, *g, *b; + unsigned i; + + r = buf; + g = r + count; + b = g + count; + + r[0] = 0x11 * 257; + g[0] = 0x22 * 257; + b[0] = 0x33 * 257; + r[1] = 0x44 * 257; + g[1] = 0x55 * 257; + b[1] = 0x66 * 257; + r[2] = 0x77 * 257; + g[2] = 0x88 * 257; + b[2] = 0x99 * 257; + r[3] = 0xa1 * 257; + g[3] = 0xb5 * 257; + b[3] = 0xff * 257; + + for (i = 4; i < count; i++) + { + r[i] = i * 257; + g[i] = (i | 0x40) * 257; + b[i] = (i | 0x80) * 257; + } +} + +static void test_tiff_8bpp_palette(void) +{ + char buf[sizeof(tiff_8bpp_data)]; + HRESULT hr; + IWICBitmapDecoder *decoder; + IWICBitmapFrameDecode *frame; + IWICPalette *palette; + GUID format; + UINT count, ret; + WICColor color[256]; + + memcpy(buf, &tiff_8bpp_data, sizeof(tiff_8bpp_data)); + generate_tiff_palette(buf + FIELD_OFFSET(struct tiff_8bpp_data, palette_data), 256); + + hr = create_decoder(buf, sizeof(buf), &decoder); + ok(hr == S_OK, "Failed to load TIFF 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); + + hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); + ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_WICPixelFormat8bppIndexed), + "expected GUID_WICPixelFormat8bppIndexed, got %s\n", wine_dbgstr_guid(&format)); + + hr = IWICImagingFactory_CreatePalette(factory, &palette); + ok(hr == S_OK, "CreatePalette error %#x\n", hr); + hr = IWICBitmapFrameDecode_CopyPalette(frame, palette); + ok(hr == S_OK, "CopyPalette error %#x\n", hr); + + hr = IWICPalette_GetColorCount(palette, &count); + ok(hr == S_OK, "GetColorCount error %#x\n", hr); + ok(count == 256, "expected 256, got %u\n", count); + + hr = IWICPalette_GetColors(palette, 256, color, &ret); + ok(hr == S_OK, "GetColors error %#x\n", hr); + ok(ret == count, "expected %u, got %u\n", count, ret); + ok(color[0] == 0xff112233, "got %#x\n", color[0]); + ok(color[1] == 0xff445566, "got %#x\n", color[1]); + ok(color[2] == 0xff778899, "got %#x\n", color[2]); + ok(color[3] == 0xffa1b5ff, "got %#x\n", color[3]); + + IWICPalette_Release(palette); + IWICBitmapFrameDecode_Release(frame); + IWICBitmapDecoder_Release(decoder); +} + +#include "pshpack2.h" +static const struct tiff_1x1_data +{ + USHORT byte_order; + USHORT version; + ULONG dir_offset; + USHORT number_of_entries; + struct IFD_entry entry[12]; + ULONG next_IFD; + struct IFD_rational res; + short palette_data[3][256]; + short bps_data[4]; + BYTE pixel_data[32]; +} tiff_1x1_data = +{ +#ifdef WORDS_BIGENDIAN + 'M' | 'M' << 8, +#else + 'I' | 'I' << 8, +#endif + 42, + FIELD_OFFSET(struct tiff_1x1_data, number_of_entries), + 12, + { + { 0xff, IFD_SHORT, 1, 0 }, /* SUBFILETYPE */ + { 0x100, IFD_LONG, 1, 1 }, /* IMAGEWIDTH */ + { 0x101, IFD_LONG, 1, 1 }, /* IMAGELENGTH */ + { 0x102, IFD_SHORT, 3, FIELD_OFFSET(struct tiff_1x1_data, bps_data) }, /* BITSPERSAMPLE */ + { 0x103, IFD_SHORT, 1, 1 }, /* COMPRESSION: XP doesn't accept IFD_LONG here */ + { 0x106, IFD_SHORT, 1, 2 }, /* PHOTOMETRIC */ + { 0x111, IFD_LONG, 1, FIELD_OFFSET(struct tiff_1x1_data, pixel_data) }, /* STRIPOFFSETS */ + { 0x115, IFD_SHORT, 1, 3 }, /* SAMPLESPERPIXEL */ + { 0x11a, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_1x1_data, res) }, + { 0x11b, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_1x1_data, res) }, + { 0x128, IFD_SHORT, 1, 2 }, /* RESOLUTIONUNIT */ + { 0x140, IFD_SHORT, 256*3, FIELD_OFFSET(struct tiff_1x1_data, palette_data) } /* COLORMAP */ + }, + 0, + { 96, 1 }, + { { 0 } }, + { 8,8,8,0 }, + { 1,0,2,3,4,5,6,7,8,9,0,1,2,3,4,5 } +}; +#include "poppack.h" + +static UINT width_bytes(UINT width, UINT bpp) +{ + return (width * bpp + 7) / 8; +} + +static void test_color_formats(void) +{ + struct bitmap_data + { + UINT bpp; + UINT width; + UINT height; + const WICPixelFormatGUID *format; + const BYTE *bits; + }; + static const BYTE bits_1bpsBGR[] = { 0,255,0,255,0,255,255,255,0,0,0,255,255,0,0,0,255,255,255,255,255,0,0,0,0,255,0,255,0,255 }; + static const struct bitmap_data data_1bpsBGR = + { + 24, 10, 2, &GUID_WICPixelFormat24bppBGR, bits_1bpsBGR + }; + static const BYTE bits_4bpsBGR[] = { 204,85,85,136,187,51,0,85,85,85,0,68,0,102,0,136,0,119,0,153,0 }; + static const struct bitmap_data data_4bpsBGR = + { + 24, 5, 2, &GUID_WICPixelFormat24bppBGR, bits_4bpsBGR + }; + static const BYTE bits_8bpsBGR[] = { 2,0,1,5,4,3,8,7,6 }; + static const struct bitmap_data data_8bpsBGR = + { + 24, 3, 1, &GUID_WICPixelFormat24bppBGR, bits_8bpsBGR + }; + static const BYTE bits_48bppRGB[] = { 1,0,2,3,4,5,6,7,8,9,0,1 }; + static const struct bitmap_data data_48bppRGB = + { + 48, 2, 1, &GUID_WICPixelFormat48bppRGB, bits_48bppRGB + }; + static const BYTE bits_1bpsBGRA[] = { 0,255,0,255,0,255,0,255,0,255,255,0,255,0,0,255,255,0,255,255,0,0,255,0,0,255,0,255,0,255,0,255,0,0,0,0,0,255,0,0 }; + static const struct bitmap_data data_1bpsBGRA = + { + 32, 5, 2, &GUID_WICPixelFormat32bppBGRA, bits_1bpsBGRA + }; + static const BYTE bits_4bpsBGRA[] = { 204,85,85,51,85,136,187,85,0,68,0,85,0,102,0,119,0,136,0,153,0,0,0,17,0,34,0,51 }; + static const struct bitmap_data data_4bpsBGRA = + { + 32, 5, 2, &GUID_WICPixelFormat32bppBGRA, bits_4bpsBGRA + }; + static const BYTE bits_8bpsBGRA[] = { 2,0,1,3,6,5,4,7,0,9,8,1,4,3,2,5 }; + static const struct bitmap_data data_8bpsBGRA = + { + 32, 4, 1, &GUID_WICPixelFormat32bppBGRA, bits_8bpsBGRA + }; + static const BYTE bits_64bppRGBA[] = { 1,0,2,3,4,5,6,7,8,9,0,1,2,3,4,5 }; + static const struct bitmap_data data_64bppRGBA = + { + 64, 2, 1, &GUID_WICPixelFormat64bppRGBA, bits_64bppRGBA + }; + static const BYTE bits_BlackWhite[] = { 85,195,184,85 }; + static const struct bitmap_data data_BlackWhite = + { + 1, 30, 1, &GUID_WICPixelFormatBlackWhite, bits_BlackWhite + }; + static const BYTE bits_BlackWhite_xp[] = { 85,195,184,84 }; + static const struct bitmap_data data_BlackWhite_xp = + { + 1, 30, 1, &GUID_WICPixelFormatBlackWhite, bits_BlackWhite_xp + }; + static const BYTE bits_4bppGray[] = { 85,195,184,85 }; + static const struct bitmap_data data_4bppGray = + { + 4, 7, 1, &GUID_WICPixelFormat4bppGray, bits_4bppGray + }; + static const BYTE bits_4bppGray_xp[] = { 85,195,184,80 }; + static const struct bitmap_data data_4bppGray_xp = + { + 4, 7, 1, &GUID_WICPixelFormat4bppGray, bits_4bppGray_xp + }; + static const BYTE bits_8bppGray[] = { 1,0,2,3,4,5,6,7,8,9 }; + static const struct bitmap_data data_8bppGray = + { + 8, 10, 1, &GUID_WICPixelFormat8bppGray, bits_8bppGray + }; + static const BYTE bits_16bppGray[] = { 1,0,2,3,4,5 }; + static const struct bitmap_data data_16bppGray = + { + 16, 3, 1, &GUID_WICPixelFormat16bppGray, bits_16bppGray + }; + static const BYTE bits_32bppGrayFloat[] = { 1,0,2,3,4,5,6,7,8,9,0,1 }; + static const struct bitmap_data data_32bppGrayFloat = + { + 32, 3, 1, &GUID_WICPixelFormat32bppGrayFloat, bits_32bppGrayFloat + }; +#if 0 /* FIXME */ + static const BYTE bits_96bpp3Channels[] = { 0 }; + static const struct bitmap_data data_96bpp3Channels = + { + 64, 1, 1, &GUID_WICPixelFormat96bpp3Channels, bits_96bpp3Channels + }; +#endif + static const BYTE bits_128bppRGBAFloat[] = { 1,0,2,3,4,5,6,7,8,9,0,1,2,3,4,5 }; + static const struct bitmap_data data_128bppRGBAFloat = + { + 128, 1, 1, &GUID_WICPixelFormat128bppRGBAFloat, bits_128bppRGBAFloat + }; + static const BYTE bits_1bppIndexed[] = { 85,195,184,85 }; + static const struct bitmap_data data_1bppIndexed = + { + 1, 32, 1, &GUID_WICPixelFormat1bppIndexed, bits_1bppIndexed + }; + static const BYTE bits_4bppIndexed[] = { 85,195,184,85 }; + static const struct bitmap_data data_4bppIndexed = + { + 4, 7, 1, &GUID_WICPixelFormat4bppIndexed, bits_4bppIndexed + }; + static const BYTE bits_4bppIndexed_xp[] = { 85,195,184,80 }; + static const struct bitmap_data data_4bppIndexed_xp = + { + 4, 7, 1, &GUID_WICPixelFormat4bppIndexed, bits_4bppIndexed_xp + }; + static const BYTE bits_8bppIndexed[] = { 1,0,2,3,4,5,6,7,8,9 }; + static const struct bitmap_data data_8bppIndexed = + { + 8, 3, 1, &GUID_WICPixelFormat8bppIndexed, bits_8bppIndexed + }; + static const BYTE bits_32bppCMYK[] = { 1,0,2,3,4,5,6,7,8,9,0,1 }; + static const struct bitmap_data data_32bppCMYK = + { + 32, 3, 1, &GUID_WICPixelFormat32bppCMYK, bits_32bppCMYK + }; + static const BYTE bits_64bppCMYK[] = { 1,0,2,3,4,5,6,7,8,9,0,1,2,3,4,5 }; + static const struct bitmap_data data_64bppCMYK = + { + 64, 2, 1, &GUID_WICPixelFormat64bppCMYK, bits_64bppCMYK + }; + static const struct + { + int photometric; /* PhotometricInterpretation */ + int samples; /* SamplesPerPixel */ + int bps; /* BitsPerSample */ + const struct bitmap_data *data; + const struct bitmap_data *alt_data; + } td[] = + { + /* 2 - RGB */ + { 2, 3, 1, &data_1bpsBGR }, + { 2, 3, 4, &data_4bpsBGR }, + { 2, 3, 8, &data_8bpsBGR }, + { 2, 3, 16, &data_48bppRGB }, + { 2, 3, 24, NULL }, +#if 0 /* FIXME */ + { 2, 3, 32, &data_96bpp3Channels }, +#endif + { 2, 4, 1, &data_1bpsBGRA }, + { 2, 4, 4, &data_4bpsBGRA }, + { 2, 4, 8, &data_8bpsBGRA }, + { 2, 4, 16, &data_64bppRGBA }, + { 2, 4, 24, NULL }, + { 2, 4, 32, &data_128bppRGBAFloat }, + /* 1 - BlackIsZero (Bilevel) */ + { 1, 1, 1, &data_BlackWhite, &data_BlackWhite_xp }, + { 1, 1, 4, &data_4bppGray, &data_4bppGray_xp }, + { 1, 1, 8, &data_8bppGray }, + { 1, 1, 16, &data_16bppGray }, + { 1, 1, 24, NULL }, + { 1, 1, 32, &data_32bppGrayFloat }, + /* 3 - Palette Color */ + { 3, 1, 1, &data_1bppIndexed }, + { 3, 1, 4, &data_4bppIndexed, &data_4bppIndexed_xp }, + { 3, 1, 8, &data_8bppIndexed }, +#if 0 /* FIXME: for some reason libtiff replaces photometric 3 by 1 for bps > 8 */ + { 3, 1, 16, &data_8bppIndexed }, + { 3, 1, 24, &data_8bppIndexed }, + { 3, 1, 32, &data_8bppIndexed }, +#endif + /* 5 - Separated */ + { 5, 4, 1, NULL }, + { 5, 4, 4, NULL }, + { 5, 4, 8, &data_32bppCMYK }, + { 5, 4, 16, &data_64bppCMYK }, + { 5, 4, 24, NULL }, + { 5, 4, 32, NULL }, + }; + BYTE buf[sizeof(tiff_1x1_data)]; + BYTE pixels[256]; + HRESULT hr; + IWICBitmapDecoder *decoder; + IWICBitmapFrameDecode *frame; + GUID format; + UINT count, i, bpp, channels, ret; + BOOL trasparency; + struct IFD_entry *tag, *tag_photo = NULL, *tag_bps = NULL, *tag_samples = NULL, *tag_colormap = NULL; + struct IFD_entry *tag_width = NULL, *tag_height = NULL; + short *bps; + + memcpy(buf, &tiff_1x1_data, sizeof(tiff_1x1_data)); + generate_tiff_palette(buf + FIELD_OFFSET(struct tiff_1x1_data, palette_data), 256); + + count = *(short *)(buf + tiff_1x1_data.dir_offset); + tag = (struct IFD_entry *)(buf + tiff_1x1_data.dir_offset + sizeof(short)); + + /* verify the TIFF structure */ + for (i = 0; i < count; i++) + { + if (tag[i].id == 0x100) /* ImageWidth */ + tag_width = &tag[i]; + else if (tag[i].id == 0x101) /* ImageLength */ + tag_height = &tag[i]; + else if (tag[i].id == 0x102) /* BitsPerSample */ + tag_bps = &tag[i]; + else if (tag[i].id == 0x106) /* PhotometricInterpretation */ + tag_photo = &tag[i]; + else if (tag[i].id == 0x115) /* SamplesPerPixel */ + tag_samples = &tag[i]; + else if (tag[i].id == 0x140) /* ColorMap */ + tag_colormap = &tag[i]; + } + + ok(tag_bps && tag_photo && tag_samples && tag_colormap, "tag 0x102,0x106,0x115 or 0x140 is missing\n"); + if (!tag_bps || !tag_photo || !tag_samples || !tag_colormap) return; + + ok(tag_bps->type == IFD_SHORT, "tag 0x102 should have type IFD_SHORT\n"); + bps = (short *)(buf + tag_bps->value); + ok(bps[0] == 8 && bps[1] == 8 && bps[2] == 8 && bps[3] == 0, + "expected bps 8,8,8,0 got %d,%d,%d,%d\n", bps[0], bps[1], bps[2], bps[3]); + + for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) + { + if (td[i].data) + { + bpp = td[i].samples * td[i].bps; + if (winetest_debug > 1) + trace("samples %u, bps %u, bpp %u, width %u => width_bytes %u\n", td[i].samples, td[i].bps, bpp, + td[i].data->width, width_bytes(td[i].data->width, bpp)); + tag_width->value = td[i].data->width; + tag_height->value = td[i].data->height; + } + else + { + tag_width->value = 1; + tag_height->value = 1; + } + + tag_colormap->count = (1 << td[i].bps) * 3; + + if (td[i].bps < 8) + { + buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data)] = 0x55; + buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data) + 1] = 0xc3; + buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data) + 2] = 0xb8; + buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data) + 3] = 0x55; + } + else + { + buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data)] = 1; + buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data) + 1] = 0; + buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data) + 2] = 2; + buf[FIELD_OFFSET(struct tiff_1x1_data, pixel_data) + 3] = 3; + } + + tag_photo->value = td[i].photometric; + tag_bps->count = td[i].samples; + tag_samples->value = td[i].samples; + + if (td[i].samples == 1) + tag_bps->value = td[i].bps; + else if (td[i].samples == 2) + tag_bps->value = MAKELONG(td[i].bps, td[i].bps); + else if (td[i].samples == 3) + { + tag_bps->value = (BYTE *)bps - buf; + bps[0] = bps[1] = bps[2] = td[i].bps; + } + else if (td[i].samples == 4) + { + tag_bps->value = (BYTE *)bps - buf; + bps[0] = bps[1] = bps[2] = bps[3] = td[i].bps; + } + else + { + ok(0, "%u: unsupported samples count %d\n", i, td[i].samples); + continue; + } + + hr = create_decoder(buf, sizeof(buf), &decoder); + if (!td[i].data) + { + ok(hr == WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT || hr == WINCODEC_ERR_COMPONENTNOTFOUND /* win8+ */ || WINCODEC_ERR_BADIMAGE /* XP */, + "%u: (%d,%d,%d) wrong error %#x\n", i, td[i].photometric, td[i].samples, td[i].bps, hr); + if (hr == S_OK) + { + IWICBitmapDecoder_Release(decoder); + dump_tiff(buf); + } + continue; + } + else + ok(hr == S_OK || broken(hr == WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT || hr == WINCODEC_ERR_BADIMAGE) /* XP */, + "%u: failed to load TIFF image data (%d,%d,%d) %#x\n", + i, td[i].photometric, td[i].samples, td[i].bps, hr); + if (hr != S_OK) continue; + + hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); + ok(hr == S_OK, "%u: GetFrame error %#x\n", i, hr); + + hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); + ok(hr == S_OK, "%u: GetPixelFormat error %#x\n", i, hr); + ok(IsEqualGUID(&format, td[i].data->format), + "%u (%d,%d,%d): expected %s, got %s\n", + i, td[i].photometric, td[i].samples, td[i].bps, + wine_dbgstr_guid(td[i].data->format), wine_dbgstr_guid(&format)); + + trasparency = (td[i].photometric == 2 && td[i].samples == 4); /* for XP */ + hr = get_pixelformat_info(&format, &bpp, &channels, &trasparency); + ok(hr == S_OK, "%u: get_pixelformat_bpp error %#x\n", i, hr); + ok(bpp == td[i].data->bpp, "%u: expected %u, got %u\n", i, td[i].data->bpp, bpp); + ok(channels == td[i].samples, "%u: expected %u, got %u\n", i, td[i].samples, channels); + ok(trasparency == (td[i].photometric == 2 && td[i].samples == 4), "%u: got %u\n", i, trasparency); + + memset(pixels, 0, sizeof(pixels)); + hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, width_bytes(td[i].data->width, bpp), sizeof(pixels), pixels); + ok(hr == S_OK, "%u: CopyPixels error %#x\n", i, hr); + ret = memcmp(pixels, td[i].data->bits, width_bytes(td[i].data->width, bpp)); + if (ret && td[i].alt_data) + ret = memcmp(pixels, td[i].alt_data->bits, width_bytes(td[i].data->width, bpp)); + ok(ret == 0, "%u: (%d,%d,%d) wrong pixel data\n", i, td[i].photometric, td[i].samples, td[i].bps); + if (ret) + { + UINT j, n = width_bytes(td[i].data->width, bpp); + for (j = 0; j < n; j++) + printf("%u%s", pixels[j], (j + 1) < n ? "," : "\n"); + } + + IWICBitmapFrameDecode_Release(frame); + IWICBitmapDecoder_Release(decoder); + } +} + START_TEST(tiffformat) { HRESULT hr; @@ -387,7 +955,9 @@ ok(hr == S_OK, "CoCreateInstance error %#x\n", hr); if (FAILED(hr)) return; - test_tiff_palette(); + test_color_formats(); + test_tiff_1bpp_palette(); + test_tiff_8bpp_palette(); test_QueryCapability(); test_tiff_8bpp_alpha();
7 years, 6 months
1
0
0
0
[akhaldi] 74862: [PSDK] Update wincodecsdk.idl. CORE-13362 [WINDOWSCODECS] Sync with Wine Staging 2.9. CORE-13362 00d3b89 windowscodecs: Simplify a bit comparison of two PROPVARIANTs. 5ea8f41 windo...
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Jun 4 01:48:14 2017 New Revision: 74862 URL:
http://svn.reactos.org/svn/reactos?rev=74862&view=rev
Log: [PSDK] Update wincodecsdk.idl. CORE-13362 [WINDOWSCODECS] Sync with Wine Staging 2.9. CORE-13362 00d3b89 windowscodecs: Simplify a bit comparison of two PROPVARIANTs. 5ea8f41 windowscodecs: Implement IWICMetadataQueryReader::GetContainerFormat. 8890f2e windowscodecs: Implement WICMapSchemaToName. dd7fa09 windowscodecs: Implement WICMapShortNameToGuid. 4cf250c windowscodecs: Implement WICMapGuidToShortName. bb57e0c windowscodecs: Fix 32bppRGB to 32bppRGBA conversion. b1037a9 windowscodecs: Add support for 32bppRGB, 32bppRGBA and 32bppPRGBA to format converter. 4e2cdd5 windowscodecs: Tolerate partial reads in the IFD metadata loader. 213b395 windowscodecs: Add support for 16bpp RGBA format to TIFF decoder. 2133dd1 windowscodecs: Add support for 4bpp RGBA format to TIFF decoder. 41827e1 windowscodecs: Add support for 32bppCMYK and 64bppCMYK formats to TIFF decoder. 306b4d3 windowscodecs: Add support for 128bppRGBAFloat format to TIFF decoder. 74f105d windowscodecs: Add support for 12bpp RGB format to TIFF decoder. 76bbf38 windowscodecs: Add support for 3bps RGB format to TIFF decoder. 2103e19 windowscodecs: Add support for 16bppGray and 32bppGrayFloat formats to TIFF decoder. 150fc32 windowscodecs: Avoid redundant checks when reading a TIFF tile. 266e4ec windowscodecs: Fail earlier in TIFF decoder's Initialize method for unsupported pixel formats. b7306a4 windowscodecs: Fix the SupportsTransparency flag value for various pixel formats. 35483da include: Fix typos in WICPersistOptions enumeration names. 2d5c861 windowscodecs: Fixed loading png from streams. fdccccb windowscodecs: Fix IWICImagingFactory_CreateDecoderFromFileHandle_Proxy spec file entry. 376b075 windowscodecs: Remove dead assignment (clang). b0d04e6 wincodecs: Simplify property name allocation. 5107ef7 wincodecs: Implement FilterOption property for PNG encoder. 6283014 wincodecs: Trigger conversion to target format in WriteSource(). Modified: trunk/reactos/dll/win32/windowscodecs/CMakeLists.txt trunk/reactos/dll/win32/windowscodecs/converter.c trunk/reactos/dll/win32/windowscodecs/gifformat.c trunk/reactos/dll/win32/windowscodecs/imgfactory.c trunk/reactos/dll/win32/windowscodecs/info.c trunk/reactos/dll/win32/windowscodecs/main.c trunk/reactos/dll/win32/windowscodecs/metadatahandler.c trunk/reactos/dll/win32/windowscodecs/metadataquery.c trunk/reactos/dll/win32/windowscodecs/pngformat.c trunk/reactos/dll/win32/windowscodecs/propertybag.c trunk/reactos/dll/win32/windowscodecs/regsvr.c trunk/reactos/dll/win32/windowscodecs/tiffformat.c trunk/reactos/dll/win32/windowscodecs/typeof.h trunk/reactos/dll/win32/windowscodecs/windowscodecs.spec trunk/reactos/media/doc/README.WINE trunk/reactos/sdk/include/psdk/wincodecsdk.idl Modified: trunk/reactos/dll/win32/windowscodecs/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/CM…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/CMakeLists.txt [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -76,6 +76,6 @@ set_module_type(windowscodecs win32dll) target_link_libraries(windowscodecs wine uuid ${PSEH_LIB}) -add_importlibs(windowscodecs ole32 oleaut32 rpcrt4 shlwapi user32 gdi32 advapi32 advapi32_vista msvcrt kernel32 ntdll) +add_importlibs(windowscodecs ole32 oleaut32 rpcrt4 shlwapi user32 gdi32 advapi32 advapi32_vista propsys msvcrt kernel32 ntdll) add_pch(windowscodecs wincodecs_private.h SOURCE) add_cd_file(TARGET windowscodecs DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/dll/win32/windowscodecs/converter.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/co…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/converter.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/converter.c [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -40,8 +40,11 @@ format_24bppRGB, format_32bppGrayFloat, format_32bppBGR, + format_32bppRGB, format_32bppBGRA, + format_32bppRGBA, format_32bppPBGRA, + format_32bppPRGBA, format_48bppRGB, format_64bppRGBA, format_32bppCMYK, @@ -845,6 +848,27 @@ } } +static HRESULT copypixels_to_32bppRGBA(struct FormatConverter *This, const WICRect *prc, + UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format) +{ + HRESULT hr; + + switch (source_format) + { + case format_32bppRGB: + case format_32bppRGBA: + case format_32bppPRGBA: + if (prc) + return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer); + return S_OK; + default: + hr = copypixels_to_32bppBGRA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format); + if (SUCCEEDED(hr) && prc) + reverse_bgr8(4, pbBuffer, prc->Width, prc->Height, cbStride); + return hr; + } +} + static HRESULT copypixels_to_32bppBGR(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format) { @@ -861,6 +885,22 @@ } } +static HRESULT copypixels_to_32bppRGB(struct FormatConverter *This, const WICRect *prc, + UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format) +{ + switch (source_format) + { + case format_32bppRGB: + case format_32bppRGBA: + case format_32bppPRGBA: + if (prc) + return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer); + return S_OK; + default: + return copypixels_to_32bppRGBA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format); + } +} + static HRESULT copypixels_to_32bppPBGRA(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format) { @@ -874,6 +914,39 @@ return S_OK; default: hr = copypixels_to_32bppBGRA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format); + if (SUCCEEDED(hr) && prc) + { + INT x, y; + + for (y=0; y<prc->Height; y++) + for (x=0; x<prc->Width; x++) + { + BYTE alpha = pbBuffer[cbStride*y+4*x+3]; + if (alpha != 255) + { + pbBuffer[cbStride*y+4*x] = pbBuffer[cbStride*y+4*x] * alpha / 255; + pbBuffer[cbStride*y+4*x+1] = pbBuffer[cbStride*y+4*x+1] * alpha / 255; + pbBuffer[cbStride*y+4*x+2] = pbBuffer[cbStride*y+4*x+2] * alpha / 255; + } + } + } + return hr; + } +} + +static HRESULT copypixels_to_32bppPRGBA(struct FormatConverter *This, const WICRect *prc, + UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format) +{ + HRESULT hr; + + switch (source_format) + { + case format_32bppPRGBA: + if (prc) + return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer); + return S_OK; + default: + hr = copypixels_to_32bppRGBA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format); if (SUCCEEDED(hr) && prc) { INT x, y; @@ -1275,8 +1348,11 @@ {format_24bppRGB, &GUID_WICPixelFormat24bppRGB, copypixels_to_24bppRGB}, {format_32bppGrayFloat, &GUID_WICPixelFormat32bppGrayFloat, copypixels_to_32bppGrayFloat}, {format_32bppBGR, &GUID_WICPixelFormat32bppBGR, copypixels_to_32bppBGR}, + {format_32bppRGB, &GUID_WICPixelFormat32bppRGB, copypixels_to_32bppRGB}, {format_32bppBGRA, &GUID_WICPixelFormat32bppBGRA, copypixels_to_32bppBGRA}, + {format_32bppRGBA, &GUID_WICPixelFormat32bppRGBA, copypixels_to_32bppRGBA}, {format_32bppPBGRA, &GUID_WICPixelFormat32bppPBGRA, copypixels_to_32bppPBGRA}, + {format_32bppPRGBA, &GUID_WICPixelFormat32bppPRGBA, copypixels_to_32bppPRGBA}, {format_48bppRGB, &GUID_WICPixelFormat48bppRGB, NULL}, {format_64bppRGBA, &GUID_WICPixelFormat64bppRGBA, NULL}, {format_32bppCMYK, &GUID_WICPixelFormat32bppCMYK, NULL}, Modified: trunk/reactos/dll/win32/windowscodecs/gifformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/gi…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/gifformat.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/gifformat.c [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -553,7 +553,7 @@ } stream = create_stream(data, data_size); - IWICPersistStream_LoadEx(persist, stream, NULL, WICPersistOptionsDefault); + IWICPersistStream_LoadEx(persist, stream, NULL, WICPersistOptionDefault); IStream_Release(stream); IWICPersistStream_Release(persist); @@ -923,7 +923,7 @@ } stream = create_stream(&IMD_data, sizeof(IMD_data)); - IWICPersistStream_LoadEx(persist, stream, NULL, WICPersistOptionsDefault); + IWICPersistStream_LoadEx(persist, stream, NULL, WICPersistOptionDefault); IStream_Release(stream); IWICPersistStream_Release(persist); Modified: trunk/reactos/dll/win32/windowscodecs/imgfactory.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/im…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/imgfactory.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/imgfactory.c [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -1028,7 +1028,7 @@ if (SUCCEEDED(hr)) { hr = IWICPersistStream_LoadEx(wicpersiststream, - stream, vendor, options & WICPersistOptionsMask); + stream, vendor, options & WICPersistOptionMask); IWICPersistStream_Release(wicpersiststream); } @@ -1072,7 +1072,7 @@ if (SUCCEEDED(hr)) { - hr = IWICPersistStream_LoadEx(wicpersiststream, stream, NULL, options & WICPersistOptionsMask); + hr = IWICPersistStream_LoadEx(wicpersiststream, stream, NULL, options & WICPersistOptionMask); IWICPersistStream_Release(wicpersiststream); } Modified: trunk/reactos/dll/win32/windowscodecs/info.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/in…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/info.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/info.c [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -2269,6 +2269,12 @@ return hr; } +static BOOL is_1bpp_format(const WICPixelFormatGUID *format) +{ + return IsEqualGUID(format, &GUID_WICPixelFormatBlackWhite) || + IsEqualGUID(format, &GUID_WICPixelFormat1bppIndexed); +} + HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst) { HRESULT res; @@ -2281,10 +2287,12 @@ BOOL canconvert; ULONG num_fetched; + TRACE("%s,%p,%p\n", debugstr_guid(dstFormat), pISrc, ppIDst); + res = IWICBitmapSource_GetPixelFormat(pISrc, &srcFormat); if (FAILED(res)) return res; - if (IsEqualGUID(&srcFormat, dstFormat)) + if (IsEqualGUID(&srcFormat, dstFormat) || (is_1bpp_format(&srcFormat) && is_1bpp_format(dstFormat))) { IWICBitmapSource_AddRef(pISrc); *ppIDst = pISrc; @@ -2330,7 +2338,6 @@ IWICFormatConverter_Release(converter); converter = NULL; } - res = S_OK; } } Modified: trunk/reactos/dll/win32/windowscodecs/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/ma…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/main.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/main.c [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -103,41 +103,25 @@ } } -static BOOL is_1bpp_format(const WICPixelFormatGUID *format) -{ - return IsEqualGUID(format, &GUID_WICPixelFormatBlackWhite) || - IsEqualGUID(format, &GUID_WICPixelFormat1bppIndexed); -} - HRESULT configure_write_source(IWICBitmapFrameEncode *iface, IWICBitmapSource *source, const WICRect *prc, const WICPixelFormatGUID *format, INT width, INT height, double xres, double yres) { - HRESULT hr=S_OK; - WICPixelFormatGUID src_format, dst_format; + HRESULT hr = S_OK; if (width == 0 || height == 0) return WINCODEC_ERR_WRONGSTATE; - hr = IWICBitmapSource_GetPixelFormat(source, &src_format); - if (FAILED(hr)) return hr; - if (!format) { - dst_format = src_format; - - hr = IWICBitmapFrameEncode_SetPixelFormat(iface, &dst_format); - if (FAILED(hr)) return hr; - - format = &dst_format; - } - - if (!IsEqualGUID(&src_format, format) && !(is_1bpp_format(&src_format) && is_1bpp_format(format))) - { - /* FIXME: should use WICConvertBitmapSource to convert */ - FIXME("format %s unsupported\n", debugstr_guid(&src_format)); - return E_NOTIMPL; + WICPixelFormatGUID src_format; + + hr = IWICBitmapSource_GetPixelFormat(source, &src_format); + if (FAILED(hr)) return hr; + + hr = IWICBitmapFrameEncode_SetPixelFormat(iface, &src_format); + if (FAILED(hr)) return hr; } if (xres == 0.0 || yres == 0.0) @@ -156,6 +140,7 @@ const WICPixelFormatGUID *format, UINT bpp, INT width, INT height) { + IWICBitmapSource *converted_source; HRESULT hr=S_OK; WICRect rc; UINT stride; @@ -176,12 +161,23 @@ if (prc->Width != width || prc->Height <= 0) return E_INVALIDARG; + hr = WICConvertBitmapSource(format, source, &converted_source); + if (FAILED(hr)) + { + ERR("Failed to convert source, target format %s, %#x\n", debugstr_guid(format), hr); + return hr; + } + stride = (bpp * width + 7)/8; pixeldata = HeapAlloc(GetProcessHeap(), 0, stride * prc->Height); - if (!pixeldata) return E_OUTOFMEMORY; - - hr = IWICBitmapSource_CopyPixels(source, prc, stride, + if (!pixeldata) + { + IWICBitmapSource_Release(converted_source); + return E_OUTOFMEMORY; + } + + hr = IWICBitmapSource_CopyPixels(converted_source, prc, stride, stride*prc->Height, pixeldata); if (SUCCEEDED(hr)) @@ -191,6 +187,7 @@ } HeapFree(GetProcessHeap(), 0, pixeldata); + IWICBitmapSource_Release(converted_source); return hr; } Modified: trunk/reactos/dll/win32/windowscodecs/metadatahandler.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/me…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/metadatahandler.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/metadatahandler.c [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -20,7 +20,8 @@ #include "wincodecs_private.h" #include <stdio.h> -#include <winternl.h> +#include <wine/winternl.h> +#include <propvarutil.h> typedef struct MetadataHandler { IWICMetadataWriter IWICMetadataWriter_iface; @@ -197,43 +198,6 @@ return hr; } -static BOOL get_int_value(const PROPVARIANT *pv, LONGLONG *value) -{ - switch (pv->vt) - { - case VT_NULL: - case VT_EMPTY: - *value = 0; - break; - case VT_I1: - *value = pv->u.cVal; - break; - case VT_UI1: - *value = pv->u.bVal; - break; - case VT_I2: - *value = pv->u.iVal; - break; - case VT_UI2: - *value = pv->u.uiVal; - break; - case VT_I4: - *value = pv->u.lVal; - break; - case VT_UI4: - *value = pv->u.ulVal; - break; - case VT_I8: - case VT_UI8: - *value = pv->u.hVal.QuadPart; - break; - default: - FIXME("not supported variant type %d\n", pv->vt); - return FALSE; - } - return TRUE; -} - /* FiXME: Use propsys.PropVariantCompareEx once it's implemented */ static int propvar_cmp(const PROPVARIANT *v1, const PROPVARIANT *v2) { @@ -249,8 +213,8 @@ return lstrcmpiW(v1->u.pwszVal, v2->u.pwszVal); } - if (!get_int_value(v1, &value1)) return -1; - if (!get_int_value(v2, &value2)) return -1; + if (PropVariantToInt64(v1, &value1) != S_OK) return -1; + if (PropVariantToInt64(v2, &value2) != S_OK) return -1; value1 -= value2; if (value1) return value1 < 0 ? -1 : 1; @@ -376,7 +340,7 @@ { MetadataHandler *This = impl_from_IWICPersistStream(iface); TRACE("(%p,%p)\n", iface, pStm); - return IWICPersistStream_LoadEx(&This->IWICPersistStream_iface, pStm, NULL, WICPersistOptionsDefault); + return IWICPersistStream_LoadEx(&This->IWICPersistStream_iface, pStm, NULL, WICPersistOptionDefault); } static HRESULT WINAPI MetadataHandler_Save(IWICPersistStream *iface, @@ -763,7 +727,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry, MetadataItem *item, BOOL native_byte_order) { - ULONG count, value, i, bytesread; + ULONG count, value, i; SHORT type; LARGE_INTEGER pos; HRESULT hr; @@ -805,7 +769,7 @@ item->value.vt |= VT_VECTOR; item->value.u.caub.cElems = count; - item->value.u.caub.pElems = HeapAlloc(GetProcessHeap(), 0, count); + item->value.u.caub.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count); if (!item->value.u.caub.pElems) return E_OUTOFMEMORY; pos.QuadPart = value; @@ -815,9 +779,8 @@ HeapFree(GetProcessHeap(), 0, item->value.u.caub.pElems); return hr; } - hr = IStream_Read(input, item->value.u.caub.pElems, count, &bytesread); - if (bytesread != count) hr = E_FAIL; - if (hr != S_OK) + hr = IStream_Read(input, item->value.u.caub.pElems, count, NULL); + if (FAILED(hr)) { HeapFree(GetProcessHeap(), 0, item->value.u.caub.pElems); return hr; @@ -850,7 +813,7 @@ item->value.vt |= VT_VECTOR; item->value.u.caui.cElems = count; - item->value.u.caui.pElems = HeapAlloc(GetProcessHeap(), 0, count * 2); + item->value.u.caui.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * 2); if (!item->value.u.caui.pElems) return E_OUTOFMEMORY; pos.QuadPart = value; @@ -860,9 +823,8 @@ HeapFree(GetProcessHeap(), 0, item->value.u.caui.pElems); return hr; } - hr = IStream_Read(input, item->value.u.caui.pElems, count * 2, &bytesread); - if (bytesread != count * 2) hr = E_FAIL; - if (hr != S_OK) + hr = IStream_Read(input, item->value.u.caui.pElems, count * 2, NULL); + if (FAILED(hr)) { HeapFree(GetProcessHeap(), 0, item->value.u.caui.pElems); return hr; @@ -883,7 +845,7 @@ item->value.vt |= VT_VECTOR; item->value.u.caul.cElems = count; - item->value.u.caul.pElems = HeapAlloc(GetProcessHeap(), 0, count * 4); + item->value.u.caul.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * 4); if (!item->value.u.caul.pElems) return E_OUTOFMEMORY; pos.QuadPart = value; @@ -893,9 +855,8 @@ HeapFree(GetProcessHeap(), 0, item->value.u.caul.pElems); return hr; } - hr = IStream_Read(input, item->value.u.caul.pElems, count * 4, &bytesread); - if (bytesread != count * 4) hr = E_FAIL; - if (hr != S_OK) + hr = IStream_Read(input, item->value.u.caul.pElems, count * 4, NULL); + if (FAILED(hr)) { HeapFree(GetProcessHeap(), 0, item->value.u.caul.pElems); return hr; @@ -921,8 +882,7 @@ hr = IStream_Seek(input, pos, SEEK_SET, NULL); if (FAILED(hr)) return hr; - hr = IStream_Read(input, &ull, sizeof(ull), &bytesread); - if (bytesread != sizeof(ull)) hr = E_FAIL; + hr = IStream_Read(input, &ull, sizeof(ull), NULL); if (hr != S_OK) return hr; item->value.u.uhVal.QuadPart = ull; @@ -940,7 +900,7 @@ { item->value.vt |= VT_VECTOR; item->value.u.cauh.cElems = count; - item->value.u.cauh.pElems = HeapAlloc(GetProcessHeap(), 0, count * 8); + item->value.u.cauh.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * 8); if (!item->value.u.cauh.pElems) return E_OUTOFMEMORY; pos.QuadPart = value; @@ -950,9 +910,8 @@ HeapFree(GetProcessHeap(), 0, item->value.u.cauh.pElems); return hr; } - hr = IStream_Read(input, item->value.u.cauh.pElems, count * 8, &bytesread); - if (bytesread != count * 8) hr = E_FAIL; - if (hr != S_OK) + hr = IStream_Read(input, item->value.u.cauh.pElems, count * 8, NULL); + if (FAILED(hr)) { HeapFree(GetProcessHeap(), 0, item->value.u.cauh.pElems); return hr; @@ -970,7 +929,7 @@ } break; case IFD_ASCII: - item->value.u.pszVal = HeapAlloc(GetProcessHeap(), 0, count + 1); + item->value.u.pszVal = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count + 1); if (!item->value.u.pszVal) return E_OUTOFMEMORY; if (count <= 4) @@ -988,9 +947,8 @@ HeapFree(GetProcessHeap(), 0, item->value.u.pszVal); return hr; } - hr = IStream_Read(input, item->value.u.pszVal, count, &bytesread); - if (bytesread != count) hr = E_FAIL; - if (hr != S_OK) + hr = IStream_Read(input, item->value.u.pszVal, count, NULL); + if (FAILED(hr)) { HeapFree(GetProcessHeap(), 0, item->value.u.pszVal); return hr; @@ -1005,7 +963,7 @@ break; } - item->value.u.blob.pBlobData = HeapAlloc(GetProcessHeap(), 0, count); + item->value.u.blob.pBlobData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count); if (!item->value.u.blob.pBlobData) return E_OUTOFMEMORY; item->value.u.blob.cbSize = count; @@ -1024,9 +982,8 @@ HeapFree(GetProcessHeap(), 0, item->value.u.blob.pBlobData); return hr; } - hr = IStream_Read(input, item->value.u.blob.pBlobData, count, &bytesread); - if (bytesread != count) hr = E_FAIL; - if (hr != S_OK) + hr = IStream_Read(input, item->value.u.blob.pBlobData, count, NULL); + if (FAILED(hr)) { HeapFree(GetProcessHeap(), 0, item->value.u.blob.pBlobData); return hr; @@ -1052,9 +1009,9 @@ TRACE("\n"); #ifdef WORDS_BIGENDIAN - if (persist_options & WICPersistOptionsLittleEndian) + if (persist_options & WICPersistOptionLittleEndian) #else - if (persist_options & WICPersistOptionsBigEndian) + if (persist_options & WICPersistOptionBigEndian) #endif native_byte_order = FALSE; Modified: trunk/reactos/dll/win32/windowscodecs/metadataquery.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/me…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/metadataquery.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/metadataquery.c [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -1,5 +1,6 @@ /* * Copyright 2016 Andrew Eikum for CodeWeavers + * Copyright 2017 Dmitry Timoshkov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -74,12 +75,13 @@ return ref; } -static HRESULT WINAPI mqr_GetContainerFormat(IWICMetadataQueryReader *iface, - GUID *pguidContainerFormat) -{ - QueryReader *This = impl_from_IWICMetadataQueryReader(iface); - FIXME("(%p,%p)\n", This, pguidContainerFormat); - return E_NOTIMPL; +static HRESULT WINAPI mqr_GetContainerFormat(IWICMetadataQueryReader *iface, GUID *format) +{ + QueryReader *This = impl_from_IWICMetadataQueryReader(iface); + + TRACE("(%p,%p)\n", This, format); + + return IWICMetadataBlockReader_GetContainerFormat(This->block, format); } static HRESULT WINAPI mqr_GetLocation(IWICMetadataQueryReader *iface, @@ -134,3 +136,278 @@ return S_OK; } + +static const WCHAR bmpW[] = { 'b','m','p',0 }; +static const WCHAR pngW[] = { 'p','n','g',0 }; +static const WCHAR icoW[] = { 'i','c','o',0 }; +static const WCHAR jpgW[] = { 'j','p','g',0 }; +static const WCHAR tiffW[] = { 't','i','f','f',0 }; +static const WCHAR gifW[] = { 'g','i','f',0 }; +static const WCHAR wmphotoW[] = { 'w','m','p','h','o','t','o',0 }; +static const WCHAR unknownW[] = { 'u','n','k','n','o','w','n',0 }; +static const WCHAR ifdW[] = { 'i','f','d',0 }; +static const WCHAR subW[] = { 's','u','b',0 }; +static const WCHAR exifW[] = { 'e','x','i','f',0 }; +static const WCHAR gpsW[] = { 'g','p','s',0 }; +static const WCHAR interopW[] = { 'i','n','t','e','r','o','p',0 }; +static const WCHAR app0W[] = { 'a','p','p','0',0 }; +static const WCHAR app1W[] = { 'a','p','p','1',0 }; +static const WCHAR app13W[] = { 'a','p','p','1','3',0 }; +static const WCHAR iptcW[] = { 'i','p','t','c',0 }; +static const WCHAR irbW[] = { 'i','r','b',0 }; +static const WCHAR _8bimiptcW[] = { '8','b','i','m','i','p','t','c',0 }; +static const WCHAR _8bimResInfoW[] = { '8','b','i','m','R','e','s','I','n','f','o',0 }; +static const WCHAR _8bimiptcdigestW[] = { '8','b','i','m','i','p','t','c','d','i','g','e','s','t',0 }; +static const WCHAR xmpW[] = { 'x','m','p',0 }; +static const WCHAR thumbW[] = { 't','h','u','m','b',0 }; +static const WCHAR tEXtW[] = { 't','E','X','t',0 }; +static const WCHAR xmpstructW[] = { 'x','m','p','s','t','r','u','c','t',0 }; +static const WCHAR xmpbagW[] = { 'x','m','p','b','a','g',0 }; +static const WCHAR xmpseqW[] = { 'x','m','p','s','e','q',0 }; +static const WCHAR xmpaltW[] = { 'x','m','p','a','l','t',0 }; +static const WCHAR logscrdescW[] = { 'l','o','g','s','c','r','d','e','s','c',0 }; +static const WCHAR imgdescW[] = { 'i','m','g','d','e','s','c',0 }; +static const WCHAR grctlextW[] = { 'g','r','c','t','l','e','x','t',0 }; +static const WCHAR appextW[] = { 'a','p','p','e','x','t',0 }; +static const WCHAR chrominanceW[] = { 'c','h','r','o','m','i','n','a','n','c','e',0 }; +static const WCHAR luminanceW[] = { 'l','u','m','i','n','a','n','c','e',0 }; +static const WCHAR comW[] = { 'c','o','m',0 }; +static const WCHAR commentextW[] = { 'c','o','m','m','e','n','t','e','x','t',0 }; +static const WCHAR gAMAW[] = { 'g','A','M','A',0 }; +static const WCHAR bKGDW[] = { 'b','K','G','D',0 }; +static const WCHAR iTXtW[] = { 'i','T','X','t',0 }; +static const WCHAR cHRMW[] = { 'c','H','R','M',0 }; +static const WCHAR hISTW[] = { 'h','I','S','T',0 }; +static const WCHAR iCCPW[] = { 'i','C','C','P',0 }; +static const WCHAR sRGBW[] = { 's','R','G','B',0 }; +static const WCHAR tIMEW[] = { 't','I','M','E',0 }; + +static const struct +{ + const GUID *guid; + const WCHAR *name; +} guid2name[] = +{ + { &GUID_ContainerFormatBmp, bmpW }, + { &GUID_ContainerFormatPng, pngW }, + { &GUID_ContainerFormatIco, icoW }, + { &GUID_ContainerFormatJpeg, jpgW }, + { &GUID_ContainerFormatTiff, tiffW }, + { &GUID_ContainerFormatGif, gifW }, + { &GUID_ContainerFormatWmp, wmphotoW }, + { &GUID_MetadataFormatUnknown, unknownW }, + { &GUID_MetadataFormatIfd, ifdW }, + { &GUID_MetadataFormatSubIfd, subW }, + { &GUID_MetadataFormatExif, exifW }, + { &GUID_MetadataFormatGps, gpsW }, + { &GUID_MetadataFormatInterop, interopW }, + { &GUID_MetadataFormatApp0, app0W }, + { &GUID_MetadataFormatApp1, app1W }, + { &GUID_MetadataFormatApp13, app13W }, + { &GUID_MetadataFormatIPTC, iptcW }, + { &GUID_MetadataFormatIRB, irbW }, + { &GUID_MetadataFormat8BIMIPTC, _8bimiptcW }, + { &GUID_MetadataFormat8BIMResolutionInfo, _8bimResInfoW }, + { &GUID_MetadataFormat8BIMIPTCDigest, _8bimiptcdigestW }, + { &GUID_MetadataFormatXMP, xmpW }, + { &GUID_MetadataFormatThumbnail, thumbW }, + { &GUID_MetadataFormatChunktEXt, tEXtW }, + { &GUID_MetadataFormatXMPStruct, xmpstructW }, + { &GUID_MetadataFormatXMPBag, xmpbagW }, + { &GUID_MetadataFormatXMPSeq, xmpseqW }, + { &GUID_MetadataFormatXMPAlt, xmpaltW }, + { &GUID_MetadataFormatLSD, logscrdescW }, + { &GUID_MetadataFormatIMD, imgdescW }, + { &GUID_MetadataFormatGCE, grctlextW }, + { &GUID_MetadataFormatAPE, appextW }, + { &GUID_MetadataFormatJpegChrominance, chrominanceW }, + { &GUID_MetadataFormatJpegLuminance, luminanceW }, + { &GUID_MetadataFormatJpegComment, comW }, + { &GUID_MetadataFormatGifComment, commentextW }, + { &GUID_MetadataFormatChunkgAMA, gAMAW }, + { &GUID_MetadataFormatChunkbKGD, bKGDW }, + { &GUID_MetadataFormatChunkiTXt, iTXtW }, + { &GUID_MetadataFormatChunkcHRM, cHRMW }, + { &GUID_MetadataFormatChunkhIST, hISTW }, + { &GUID_MetadataFormatChunkiCCP, iCCPW }, + { &GUID_MetadataFormatChunksRGB, sRGBW }, + { &GUID_MetadataFormatChunktIME, tIMEW } +}; + +HRESULT WINAPI WICMapGuidToShortName(REFGUID guid, UINT len, WCHAR *name, UINT *ret_len) +{ + UINT i; + + TRACE("%s,%u,%p,%p\n", wine_dbgstr_guid(guid), len, name, ret_len); + + if (!guid) return E_INVALIDARG; + + for (i = 0; i < sizeof(guid2name)/sizeof(guid2name[0]); i++) + { + if (IsEqualGUID(guid, guid2name[i].guid)) + { + if (name) + { + if (!len) return E_INVALIDARG; + + len = min(len - 1, strlenW(guid2name[i].name)); + memcpy(name, guid2name[i].name, len * sizeof(WCHAR)); + name[len] = 0; + + if (len < strlenW(guid2name[i].name)) + return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + } + if (ret_len) *ret_len = strlenW(guid2name[i].name) + 1; + return S_OK; + } + } + + return WINCODEC_ERR_PROPERTYNOTFOUND; +} + +HRESULT WINAPI WICMapShortNameToGuid(const WCHAR *name, GUID *guid) +{ + UINT i; + + TRACE("%s,%p\n", debugstr_w(name), guid); + + if (!name || !guid) return E_INVALIDARG; + + for (i = 0; i < sizeof(guid2name)/sizeof(guid2name[0]); i++) + { + if (!strcmpiW(name, guid2name[i].name)) + { + *guid = *guid2name[i].guid; + return S_OK; + } + } + + return WINCODEC_ERR_PROPERTYNOTFOUND; +} + +static const WCHAR rdf[] = { 'r','d','f',0 }; +static const WCHAR rdf_scheme[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','3','.','o','r','g','/','1','9','9','9','/','0','2','/','2','2','-','r','d','f','-','s','y','n','t','a','x','-','n','s','#',0 }; +static const WCHAR dc[] = { 'd','c',0 }; +static const WCHAR dc_scheme[] = { 'h','t','t','p',':','/','/','p','u','r','l','.','o','r','g','/','d','c','/','e','l','e','m','e','n','t','s','/','1','.','1','/',0 }; +static const WCHAR xmp[] = { 'x','m','p',0 }; +static const WCHAR xmp_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/',0 }; +static const WCHAR xmpidq[] = { 'x','m','p','i','d','q',0 }; +static const WCHAR xmpidq_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','m','p','/','I','d','e','n','t','i','f','i','e','r','/','q','u','a','l','/','1','.','0','/',0 }; +static const WCHAR xmpRights[] = { 'x','m','p','R','i','g','h','t','s',0 }; +static const WCHAR xmpRights_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','r','i','g','h','t','s','/',0 }; +static const WCHAR xmpMM[] = { 'x','m','p','M','M',0 }; +static const WCHAR xmpMM_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','m','m','/',0 }; +static const WCHAR xmpBJ[] = { 'x','m','p','B','J',0 }; +static const WCHAR xmpBJ_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','b','j','/',0 }; +static const WCHAR xmpTPg[] = { 'x','m','p','T','P','g',0 }; +static const WCHAR xmpTPg_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','t','/','p','g','/',0 }; +static const WCHAR pdf[] = { 'p','d','f',0 }; +static const WCHAR pdf_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','p','d','f','/','1','.','3','/',0 }; +static const WCHAR photoshop[] = { 'p','h','o','t','o','s','h','o','p',0 }; +static const WCHAR photoshop_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','p','h','o','t','o','s','h','o','p','/','1','.','0','/',0 }; +static const WCHAR tiff[] = { 't','i','f','f',0 }; +static const WCHAR tiff_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','t','i','f','f','/','1','.','0','/',0 }; +static const WCHAR exif[] = { 'e','x','i','f',0 }; +static const WCHAR exif_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','e','x','i','f','/','1','.','0','/',0 }; +static const WCHAR stDim[] = { 's','t','D','i','m',0 }; +static const WCHAR stDim_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','s','T','y','p','e','/','D','i','m','e','n','s','i','o','n','s','#',0 }; +static const WCHAR xapGImg[] = { 'x','a','p','G','I','m','g',0 }; +static const WCHAR xapGImg_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','g','/','i','m','g','/',0 }; +static const WCHAR stEvt[] = { 's','t','E','v','t',0 }; +static const WCHAR stEvt_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','s','T','y','p','e','/','R','e','s','o','u','r','c','e','E','v','e','n','t','#',0 }; +static const WCHAR stRef[] = { 's','t','R','e','f',0 }; +static const WCHAR stRef_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','s','T','y','p','e','/','R','e','s','o','u','r','c','e','R','e','f','#',0 }; +static const WCHAR stVer[] = { 's','t','V','e','r',0 }; +static const WCHAR stVer_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','s','T','y','p','e','/','V','e','r','s','i','o','n','#',0 }; +static const WCHAR stJob[] = { 's','t','J','o','b',0 }; +static const WCHAR stJob_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','a','p','/','1','.','0','/','s','T','y','p','e','/','J','o','b','#',0 }; +static const WCHAR aux[] = { 'a','u','x',0 }; +static const WCHAR aux_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','e','x','i','f','/','1','.','0','/','a','u','x','/',0 }; +static const WCHAR crs[] = { 'c','r','s',0 }; +static const WCHAR crs_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','c','a','m','e','r','a','-','r','a','w','-','s','e','t','t','i','n','g','s','/','1','.','0','/',0 }; +static const WCHAR xmpDM[] = { 'x','m','p','D','M',0 }; +static const WCHAR xmpDM_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','a','d','o','b','e','.','c','o','m','/','x','m','p','/','1','.','0','/','D','y','n','a','m','i','c','M','e','d','i','a','/',0 }; +static const WCHAR Iptc4xmpCore[] = { 'I','p','t','c','4','x','m','p','C','o','r','e',0 }; +static const WCHAR Iptc4xmpCore_scheme[] = { 'h','t','t','p',':','/','/','i','p','t','c','.','o','r','g','/','s','t','d','/','I','p','t','c','4','x','m','p','C','o','r','e','/','1','.','0','/','x','m','l','n','s','/',0 }; +static const WCHAR MicrosoftPhoto[] = { 'M','i','c','r','o','s','o','f','t','P','h','o','t','o',0 }; +static const WCHAR MicrosoftPhoto_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','p','h','o','t','o','/','1','.','0','/',0 }; +static const WCHAR MP[] = { 'M','P',0 }; +static const WCHAR MP_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','p','h','o','t','o','/','1','.','2','/',0 }; +static const WCHAR MPRI[] = { 'M','P','R','I',0 }; +static const WCHAR MPRI_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','p','h','o','t','o','/','1','.','2','/','t','/','R','e','g','i','o','n','I','n','f','o','#',0 }; +static const WCHAR MPReg[] = { 'M','P','R','e','g',0 }; +static const WCHAR MPReg_scheme[] = { 'h','t','t','p',':','/','/','n','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','p','h','o','t','o','/','1','.','2','/','t','/','R','e','g','i','o','n','#',0 }; + +static const struct +{ + const WCHAR *name; + const WCHAR *schema; +} name2schema[] = +{ + { rdf, rdf_scheme }, + { dc, dc_scheme }, + { xmp, xmp_scheme }, + { xmpidq, xmpidq_scheme }, + { xmpRights, xmpRights_scheme }, + { xmpMM, xmpMM_scheme }, + { xmpBJ, xmpBJ_scheme }, + { xmpTPg, xmpTPg_scheme }, + { pdf, pdf_scheme }, + { photoshop, photoshop_scheme }, + { tiff, tiff_scheme }, + { exif, exif_scheme }, + { stDim, stDim_scheme }, + { xapGImg, xapGImg_scheme }, + { stEvt, stEvt_scheme }, + { stRef, stRef_scheme }, + { stVer, stVer_scheme }, + { stJob, stJob_scheme }, + { aux, aux_scheme }, + { crs, crs_scheme }, + { xmpDM, xmpDM_scheme }, + { Iptc4xmpCore, Iptc4xmpCore_scheme }, + { MicrosoftPhoto, MicrosoftPhoto_scheme }, + { MP, MP_scheme }, + { MPRI, MPRI_scheme }, + { MPReg, MPReg_scheme } +}; + +HRESULT WINAPI WICMapSchemaToName(REFGUID format, const WCHAR *schema, UINT len, WCHAR *name, UINT *ret_len) +{ + UINT i; + + TRACE("%s,%s,%u,%p,%p\n", wine_dbgstr_guid(format), debugstr_w(schema), len, name, ret_len); + + if (!format || !schema || !ret_len) + return E_INVALIDARG; + + /* It appears that the only metadata formats + * that support schemas are xmp and xmpstruct. + */ + if (!IsEqualGUID(format, &GUID_MetadataFormatXMP) && + !IsEqualGUID(format, &GUID_MetadataFormatXMPStruct)) + return WINCODEC_ERR_PROPERTYNOTFOUND; + + for (i = 0; i < sizeof(name2schema)/sizeof(name2schema[0]); i++) + { + if (!strcmpW(name2schema[i].schema, schema)) + { + if (name) + { + if (!len) return E_INVALIDARG; + + len = min(len - 1, strlenW(name2schema[i].name)); + memcpy(name, name2schema[i].name, len * sizeof(WCHAR)); + name[len] = 0; + + if (len < lstrlenW(name2schema[i].name)) + return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + } + + if (ret_len) *ret_len = strlenW(name2schema[i].name) + 1; + return S_OK; + } + } + + return WINCODEC_ERR_PROPERTYNOTFOUND; +} Modified: trunk/reactos/dll/win32/windowscodecs/pngformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/pn…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/pngformat.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/pngformat.c [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -24,8 +24,6 @@ #ifdef HAVE_PNG_H #include <png.h> #endif - -static const WCHAR wszPngInterlaceOption[] = {'I','n','t','e','r','l','a','c','e','O','p','t','i','o','n',0}; static inline ULONG read_ulong_be(BYTE* data) { @@ -308,6 +306,7 @@ MAKE_FUNCPTR(png_set_crc_action); MAKE_FUNCPTR(png_set_error_fn); MAKE_FUNCPTR(png_set_filler); +MAKE_FUNCPTR(png_set_filter); MAKE_FUNCPTR(png_set_gray_to_rgb); MAKE_FUNCPTR(png_set_interlace_handling); MAKE_FUNCPTR(png_set_IHDR); @@ -335,6 +334,9 @@ 0, 0, { (DWORD_PTR)(__FILE__ ": init_png_cs") } }; static CRITICAL_SECTION init_png_cs = { &init_png_cs_debug, -1, 0, 0, 0, 0 }; + +static const WCHAR wszPngInterlaceOption[] = {'I','n','t','e','r','l','a','c','e','O','p','t','i','o','n',0}; +static const WCHAR wszPngFilterOption[] = {'F','i','l','t','e','r','O','p','t','i','o','n',0}; static void *load_libpng(void) { @@ -370,6 +372,7 @@ LOAD_FUNCPTR(png_set_crc_action); LOAD_FUNCPTR(png_set_error_fn); LOAD_FUNCPTR(png_set_filler); + LOAD_FUNCPTR(png_set_filter); LOAD_FUNCPTR(png_set_gray_to_rgb); LOAD_FUNCPTR(png_set_interlace_handling); LOAD_FUNCPTR(png_set_IHDR); @@ -747,11 +750,12 @@ /* Find the metadata chunks in the file. */ seek.QuadPart = 8; - hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, &chunk_start); - if (FAILED(hr)) goto end; do { + hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, &chunk_start); + if (FAILED(hr)) goto end; + hr = read_png_chunk(pIStream, chunk_type, NULL, &chunk_size); if (FAILED(hr)) goto end; @@ -789,8 +793,6 @@ } seek.QuadPart = chunk_start.QuadPart + chunk_size + 12; /* skip data and CRC */ - hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, &chunk_start); - if (FAILED(hr)) goto end; } while (memcmp(chunk_type, "IEND", 4)); This->stream = pIStream; @@ -1340,6 +1342,7 @@ BOOL committed; CRITICAL_SECTION lock; BOOL interlace; + WICPngFilterOption filter; BYTE *data; UINT stride; UINT passes; @@ -1396,31 +1399,44 @@ IPropertyBag2 *pIEncoderOptions) { PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface); + WICPngFilterOption filter; BOOL interlace; - PROPBAG2 opts[1]= {{0}}; - VARIANT opt_values[1]; - HRESULT opt_hres[1]; + PROPBAG2 opts[2]= {{0}}; + VARIANT opt_values[2]; + HRESULT opt_hres[2]; HRESULT hr; TRACE("(%p,%p)\n", iface, pIEncoderOptions); opts[0].pstrName = (LPOLESTR)wszPngInterlaceOption; opts[0].vt = VT_BOOL; + opts[1].pstrName = (LPOLESTR)wszPngFilterOption; + opts[1].vt = VT_UI1; if (pIEncoderOptions) { - hr = IPropertyBag2_Read(pIEncoderOptions, 1, opts, NULL, opt_values, opt_hres); + hr = IPropertyBag2_Read(pIEncoderOptions, sizeof(opts)/sizeof(opts[0]), opts, NULL, opt_values, opt_hres); if (FAILED(hr)) return hr; + + if (V_VT(&opt_values[0]) == VT_EMPTY) + interlace = FALSE; + else + interlace = (V_BOOL(&opt_values[0]) != 0); + + filter = V_UI1(&opt_values[1]); + if (filter > WICPngFilterAdaptive) + { + WARN("Unrecognized filter option value %u.\n", filter); + filter = WICPngFilterUnspecified; + } } else - memset(opt_values, 0, sizeof(opt_values)); - - if (V_VT(&opt_values[0]) == VT_EMPTY) + { interlace = FALSE; - else - interlace = (V_BOOL(&opt_values[0]) != 0); + filter = WICPngFilterUnspecified; + } EnterCriticalSection(&This->lock); @@ -1431,6 +1447,7 @@ } This->interlace = interlace; + This->filter = filter; This->frame_initialized = TRUE; @@ -1653,6 +1670,22 @@ if (This->interlace) This->passes = ppng_set_interlace_handling(This->png_ptr); + if (This->filter != WICPngFilterUnspecified) + { + static const int png_filter_map[] = + { + /* WICPngFilterUnspecified */ PNG_NO_FILTERS, + /* WICPngFilterNone */ PNG_FILTER_NONE, + /* WICPngFilterSub */ PNG_FILTER_SUB, + /* WICPngFilterUp */ PNG_FILTER_UP, + /* WICPngFilterAverage */ PNG_FILTER_AVG, + /* WICPngFilterPaeth */ PNG_FILTER_PAETH, + /* WICPngFilterAdaptive */ PNG_ALL_FILTERS, + }; + + ppng_set_filter(This->png_ptr, 0, png_filter_map[This->filter]); + } + This->info_written = TRUE; } @@ -1983,7 +2016,7 @@ { PngEncoder *This = impl_from_IWICBitmapEncoder(iface); HRESULT hr; - PROPBAG2 opts[1]= {{0}}; + PROPBAG2 opts[2]= {{0}}; TRACE("(%p,%p,%p)\n", iface, ppIFrameEncode, ppIEncoderOptions); @@ -2004,8 +2037,11 @@ opts[0].pstrName = (LPOLESTR)wszPngInterlaceOption; opts[0].vt = VT_BOOL; opts[0].dwType = PROPBAG2_TYPE_DATA; - - hr = CreatePropertyBag2(opts, 1, ppIEncoderOptions); + opts[1].pstrName = (LPOLESTR)wszPngFilterOption; + opts[1].vt = VT_UI1; + opts[1].dwType = PROPBAG2_TYPE_DATA; + + hr = CreatePropertyBag2(opts, sizeof(opts)/sizeof(opts[0]), ppIEncoderOptions); if (FAILED(hr)) { LeaveCriticalSection(&This->lock); Modified: trunk/reactos/dll/win32/windowscodecs/propertybag.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/pr…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/propertybag.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/propertybag.c [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -79,7 +79,7 @@ { for (i=0; i < This->prop_count; i++) { - HeapFree(GetProcessHeap(), 0, This->properties[i].pstrName); + CoTaskMemFree(This->properties[i].pstrName); VariantClear( This->values+i ); } } @@ -198,18 +198,14 @@ return S_OK; } -static HRESULT copy_propbag2(PROPBAG2 *dest, PROPBAG2 *src, BOOL useCoAlloc) +static HRESULT copy_propbag2(PROPBAG2 *dest, PROPBAG2 *src) { dest->cfType = src->cfType; dest->clsid = src->clsid; dest->dwHint = src->dwHint; dest->dwType = src->dwType; dest->vt = src->vt; - if(useCoAlloc) - dest->pstrName = CoTaskMemAlloc((strlenW(src->pstrName)+1) * sizeof(WCHAR)); - else - dest->pstrName = HeapAlloc(GetProcessHeap(), 0, (strlenW(src->pstrName)+1) * sizeof(WCHAR)); - + dest->pstrName = CoTaskMemAlloc((strlenW(src->pstrName)+1) * sizeof(WCHAR)); if(!dest->pstrName) return E_OUTOFMEMORY; @@ -236,7 +232,7 @@ for (i=0; i < *pcProperties; i++) { - res = copy_propbag2(pPropBag+i, This->properties+iProperty+i, TRUE); + res = copy_propbag2(pPropBag+i, This->properties+iProperty+i); if (FAILED(res)) { do { @@ -296,7 +292,7 @@ else for (i=0; i < count; i++) { - res = copy_propbag2(This->properties+i, options+i, FALSE); + res = copy_propbag2(This->properties+i, options+i); if (FAILED(res)) break; This->properties[i].dwHint = i+1; /* 0 means unset, so we start with 1 */ Modified: trunk/reactos/dll/win32/windowscodecs/regsvr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/re…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/regsvr.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/regsvr.c [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -1194,6 +1194,8 @@ &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat8bppGray, + &GUID_WICPixelFormat16bppGray, + &GUID_WICPixelFormat32bppGrayFloat, &GUID_WICPixelFormat1bppIndexed, &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat4bppIndexed, @@ -1205,6 +1207,9 @@ &GUID_WICPixelFormat48bppRGB, &GUID_WICPixelFormat64bppRGBA, &GUID_WICPixelFormat64bppPRGBA, + &GUID_WICPixelFormat32bppCMYK, + &GUID_WICPixelFormat64bppCMYK, + &GUID_WICPixelFormat128bppRGBAFloat, NULL }; @@ -1458,8 +1463,11 @@ &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat24bppRGB, &GUID_WICPixelFormat32bppBGR, + &GUID_WICPixelFormat32bppRGB, &GUID_WICPixelFormat32bppBGRA, + &GUID_WICPixelFormat32bppRGBA, &GUID_WICPixelFormat32bppPBGRA, + &GUID_WICPixelFormat32bppPRGBA, &GUID_WICPixelFormat32bppGrayFloat, &GUID_WICPixelFormat48bppRGB, &GUID_WICPixelFormat64bppRGBA, @@ -1733,6 +1741,11 @@ static BYTE const channel_mask_32bit[] = { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }; +static BYTE const channel_mask_128bit1[] = { 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; +static BYTE const channel_mask_128bit2[] = { 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; +static BYTE const channel_mask_128bit3[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00 }; +static BYTE const channel_mask_128bit4[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff }; + static BYTE const channel_mask_5bit[] = { 0x1f, 0x00 }; static BYTE const channel_mask_5bit2[] = { 0xe0, 0x03 }; static BYTE const channel_mask_5bit3[] = { 0x00, 0x7c }; @@ -1750,6 +1763,7 @@ channel_mask_16bit2, channel_mask_16bit3, channel_mask_16bit4}; static BYTE const * const channel_masks_32bit[] = { channel_mask_32bit }; +static BYTE const * const channel_masks_128bit[] = { channel_mask_128bit1, channel_mask_128bit2, channel_mask_128bit3, channel_mask_128bit4 }; static BYTE const * const channel_masks_BGRA5551[] = { channel_mask_5bit, channel_mask_5bit2, channel_mask_5bit3, channel_mask_5bit4 }; @@ -1767,7 +1781,7 @@ 1, /* channel count */ channel_masks_1bit, WICPixelFormatNumericRepresentationIndexed, - 1 + 0 }, { &GUID_WICPixelFormat2bppIndexed, "The Wine Project", @@ -1778,7 +1792,7 @@ 1, /* channel count */ channel_masks_2bit, WICPixelFormatNumericRepresentationIndexed, - 1 + 0 }, { &GUID_WICPixelFormat4bppIndexed, "The Wine Project", @@ -1789,7 +1803,7 @@ 1, /* channel count */ channel_masks_4bit, WICPixelFormatNumericRepresentationIndexed, - 1 + 0 }, { &GUID_WICPixelFormat8bppIndexed, "The Wine Project", @@ -1800,7 +1814,7 @@ 1, /* channel count */ channel_masks_8bit, WICPixelFormatNumericRepresentationIndexed, - 1 + 0 }, { &GUID_WICPixelFormatBlackWhite, "The Wine Project", @@ -1923,6 +1937,17 @@ WICPixelFormatNumericRepresentationUnsignedInteger, 0 }, + { &GUID_WICPixelFormat32bppRGB, + "The Wine Project", + "32bpp RGB", + NULL, /* no version */ + &GUID_VendorMicrosoft, + 32, /* bitsperpixel */ + 3, /* channel count */ + channel_masks_8bit, + WICPixelFormatNumericRepresentationUnsignedInteger, + 0 + }, { &GUID_WICPixelFormat32bppBGRA, "The Wine Project", "32bpp BGRA", @@ -1934,9 +1959,9 @@ WICPixelFormatNumericRepresentationUnsignedInteger, 1 }, - { &GUID_WICPixelFormat32bppPBGRA, - "The Wine Project", - "32bpp PBGRA", + { &GUID_WICPixelFormat32bppRGBA, + "The Wine Project", + "32bpp RGBA", NULL, /* no version */ &GUID_VendorMicrosoft, 32, /* bitsperpixel */ @@ -1945,6 +1970,28 @@ WICPixelFormatNumericRepresentationUnsignedInteger, 1 }, + { &GUID_WICPixelFormat32bppPBGRA, + "The Wine Project", + "32bpp PBGRA", + NULL, /* no version */ + &GUID_VendorMicrosoft, + 32, /* bitsperpixel */ + 4, /* channel count */ + channel_masks_8bit, + WICPixelFormatNumericRepresentationUnsignedInteger, + 1 + }, + { &GUID_WICPixelFormat32bppPRGBA, + "The Wine Project", + "32bpp PRGBA", + NULL, /* no version */ + &GUID_VendorMicrosoft, + 32, /* bitsperpixel */ + 4, /* channel count */ + channel_masks_8bit, + WICPixelFormatNumericRepresentationUnsignedInteger, + 1 + }, { &GUID_WICPixelFormat32bppGrayFloat, "The Wine Project", "32bpp GrayFloat", @@ -1954,7 +2001,7 @@ 1, /* channel count */ channel_masks_32bit, WICPixelFormatNumericRepresentationFloat, - 1 + 0 }, { &GUID_WICPixelFormat48bppRGB, "The Wine Project", @@ -1999,6 +2046,28 @@ channel_masks_8bit, WICPixelFormatNumericRepresentationUnsignedInteger, 0 + }, + { &GUID_WICPixelFormat64bppCMYK, + "The Wine Project", + "64bpp CMYK", + NULL, /* no version */ + &GUID_VendorMicrosoft, + 64, /* bitsperpixel */ + 4, /* channel count */ + channel_masks_16bit, + WICPixelFormatNumericRepresentationUnsignedInteger, + 0 + }, + { &GUID_WICPixelFormat128bppRGBAFloat, + "The Wine Project", + "128bpp RGBAFloat", + NULL, /* no version */ + &GUID_VendorMicrosoft, + 128, /* bitsperpixel */ + 4, /* channel count */ + channel_masks_128bit, + WICPixelFormatNumericRepresentationFloat, + 1 }, { NULL } /* list terminator */ }; Modified: trunk/reactos/dll/win32/windowscodecs/tiffformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/ti…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/tiffformat.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/tiffformat.c [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -303,6 +303,8 @@ } } decode_info->planar = planar; + + TRACE("planar %u, photometric %u, samples %u, bps %u\n", planar, photometric, samples, bps); switch(photometric) { @@ -368,14 +370,28 @@ } } break; + case 16: + if (samples != 1) + { + FIXME("unhandled 16bpp grayscale sample count %u\n", samples); + return WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT; + } + decode_info->format = &GUID_WICPixelFormat16bppGray; + break; + case 32: + if (samples != 1) + { + FIXME("unhandled 32bpp grayscale sample count %u\n", samples); + return WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT; + } + decode_info->format = &GUID_WICPixelFormat32bppGrayFloat; + break; default: - FIXME("unhandled greyscale bit count %u\n", bps); - return E_FAIL; + WARN("unhandled greyscale bit count %u\n", bps); + return WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT; } break; case 2: /* RGB */ - decode_info->bpp = bps * samples; - if (samples == 4) { ret = pTIFFGetField(tiff, TIFFTAG_EXTRASAMPLES, &extra_sample_count, &extra_samples); @@ -392,8 +408,12 @@ return E_FAIL; } + decode_info->bpp = max(bps, 8) * samples; + decode_info->source_bpp = bps * samples; switch(bps) { + case 1: + case 4: case 8: decode_info->reverse_bgr = 1; if (samples == 3) @@ -431,9 +451,17 @@ return E_FAIL; } break; + case 32: + if (samples != 4) + { + FIXME("unhandled 32bpp RGB sample count %u\n", samples); + return WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT; + } + decode_info->format = &GUID_WICPixelFormat128bppRGBAFloat; + break; default: - FIXME("unhandled RGB bit count %u\n", bps); - return E_FAIL; + WARN("unhandled RGB bit count %u\n", bps); + return WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT; } break; case 3: /* RGB Palette */ @@ -464,8 +492,31 @@ return E_FAIL; } break; + + case 5: /* Separated */ + if (samples != 4) + { + FIXME("unhandled Separated sample count %u\n", samples); + return E_FAIL; + } + + decode_info->bpp = bps * samples; + switch(bps) + { + case 8: + decode_info->format = &GUID_WICPixelFormat32bppCMYK; + break; + case 16: + decode_info->format = &GUID_WICPixelFormat64bppCMYK; + break; + + default: + WARN("unhandled Separated bit count %u\n", bps); + return WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT; + } + break; + case 4: /* Transparency mask */ - case 5: /* CMYK */ case 6: /* YCbCr */ case 8: /* CIELab */ default: @@ -616,6 +667,7 @@ { TiffDecoder *This = impl_from_IWICBitmapDecoder(iface); TIFF *tiff; + tiff_decode_info decode_info; HRESULT hr=S_OK; TRACE("(%p,%p,%x)\n", iface, pIStream, cacheOptions); @@ -629,10 +681,17 @@ } tiff = tiff_open_stream(pIStream, "r"); - if (!tiff) { hr = E_FAIL; + goto exit; + } + + /* make sure that TIFF format is supported */ + hr = tiff_get_decode_info(tiff, &decode_info); + if (hr != S_OK) + { + pTIFFClose(tiff); goto exit; } @@ -951,34 +1010,183 @@ static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT tile_y) { - HRESULT hr=S_OK; tsize_t ret; int swap_bytes; swap_bytes = pTIFFIsByteSwapped(This->parent->tiff); ret = pTIFFSetDirectory(This->parent->tiff, This->index); - if (ret == -1) - hr = E_FAIL; - - if (hr == S_OK) - { - if (This->decode_info.tiled) - { - ret = pTIFFReadEncodedTile(This->parent->tiff, tile_x + tile_y * This->decode_info.tiles_across, This->cached_tile, This->decode_info.tile_size); - } - else - { - ret = pTIFFReadEncodedStrip(This->parent->tiff, tile_y, This->cached_tile, This->decode_info.tile_size); - } - - if (ret == -1) - hr = E_FAIL; - } - + return E_FAIL; + + if (This->decode_info.tiled) + ret = pTIFFReadEncodedTile(This->parent->tiff, tile_x + tile_y * This->decode_info.tiles_across, This->cached_tile, This->decode_info.tile_size); + else + ret = pTIFFReadEncodedStrip(This->parent->tiff, tile_y, This->cached_tile, This->decode_info.tile_size); + + if (ret == -1) + return E_FAIL; + + /* 3bpp RGB */ + if (This->decode_info.source_bpp == 3 && This->decode_info.samples == 3 && This->decode_info.bpp == 24) + { + BYTE *srcdata, *src, *dst; + DWORD x, y, count, width_bytes = (This->decode_info.tile_width * 3 + 7) / 8; + + count = width_bytes * This->decode_info.tile_height; + + srcdata = HeapAlloc(GetProcessHeap(), 0, count); + if (!srcdata) return E_OUTOFMEMORY; + memcpy(srcdata, This->cached_tile, count); + + for (y = 0; y < This->decode_info.tile_height; y++) + { + src = srcdata + y * width_bytes; + dst = This->cached_tile + y * This->decode_info.tile_width * 3; + + for (x = 0; x < This->decode_info.tile_width; x += 8) + { + dst[2] = (src[0] & 0x80) ? 0xff : 0; /* R */ + dst[1] = (src[0] & 0x40) ? 0xff : 0; /* G */ + dst[0] = (src[0] & 0x20) ? 0xff : 0; /* B */ + if (x + 1 < This->decode_info.tile_width) + { + dst[5] = (src[0] & 0x10) ? 0xff : 0; /* R */ + dst[4] = (src[0] & 0x08) ? 0xff : 0; /* G */ + dst[3] = (src[0] & 0x04) ? 0xff : 0; /* B */ + } + if (x + 2 < This->decode_info.tile_width) + { + dst[8] = (src[0] & 0x02) ? 0xff : 0; /* R */ + dst[7] = (src[0] & 0x01) ? 0xff : 0; /* G */ + dst[6] = (src[1] & 0x80) ? 0xff : 0; /* B */ + } + if (x + 3 < This->decode_info.tile_width) + { + dst[11] = (src[1] & 0x40) ? 0xff : 0; /* R */ + dst[10] = (src[1] & 0x20) ? 0xff : 0; /* G */ + dst[9] = (src[1] & 0x10) ? 0xff : 0; /* B */ + } + if (x + 4 < This->decode_info.tile_width) + { + dst[14] = (src[1] & 0x08) ? 0xff : 0; /* R */ + dst[13] = (src[1] & 0x04) ? 0xff : 0; /* G */ + dst[12] = (src[1] & 0x02) ? 0xff : 0; /* B */ + } + if (x + 5 < This->decode_info.tile_width) + { + dst[17] = (src[1] & 0x01) ? 0xff : 0; /* R */ + dst[16] = (src[2] & 0x80) ? 0xff : 0; /* G */ + dst[15] = (src[2] & 0x40) ? 0xff : 0; /* B */ + } + if (x + 6 < This->decode_info.tile_width) + { + dst[20] = (src[2] & 0x20) ? 0xff : 0; /* R */ + dst[19] = (src[2] & 0x10) ? 0xff : 0; /* G */ + dst[18] = (src[2] & 0x08) ? 0xff : 0; /* B */ + } + if (x + 7 < This->decode_info.tile_width) + { + dst[23] = (src[2] & 0x04) ? 0xff : 0; /* R */ + dst[22] = (src[2] & 0x02) ? 0xff : 0; /* G */ + dst[21] = (src[2] & 0x01) ? 0xff : 0; /* B */ + } + src += 3; + dst += 24; + } + } + + HeapFree(GetProcessHeap(), 0, srcdata); + } + /* 12bpp RGB */ + else if (This->decode_info.source_bpp == 12 && This->decode_info.samples == 3 && This->decode_info.bpp == 24) + { + BYTE *srcdata, *src, *dst; + DWORD x, y, count, width_bytes = (This->decode_info.tile_width * 12 + 7) / 8; + + count = width_bytes * This->decode_info.tile_height; + + srcdata = HeapAlloc(GetProcessHeap(), 0, count); + if (!srcdata) return E_OUTOFMEMORY; + memcpy(srcdata, This->cached_tile, count); + + for (y = 0; y < This->decode_info.tile_height; y++) + { + src = srcdata + y * width_bytes; + dst = This->cached_tile + y * This->decode_info.tile_width * 3; + + for (x = 0; x < This->decode_info.tile_width; x += 2) + { + dst[0] = ((src[1] & 0xf0) >> 4) * 17; /* B */ + dst[1] = (src[0] & 0x0f) * 17; /* G */ + dst[2] = ((src[0] & 0xf0) >> 4) * 17; /* R */ + if (x + 1 < This->decode_info.tile_width) + { + dst[5] = (src[1] & 0x0f) * 17; /* B */ + dst[4] = ((src[2] & 0xf0) >> 4) * 17; /* G */ + dst[3] = (src[2] & 0x0f) * 17; /* R */ + } + src += 3; + dst += 6; + } + } + + HeapFree(GetProcessHeap(), 0, srcdata); + } + /* 4bpp RGBA */ + else if (This->decode_info.source_bpp == 4 && This->decode_info.samples == 4 && This->decode_info.bpp == 32) + { + BYTE *src, *dst; + DWORD count; + + /* 1 source byte expands to 2 BGRA samples */ + count = (This->decode_info.tile_width * This->decode_info.tile_height + 1) / 2; + + src = This->cached_tile + count - 1; + dst = This->cached_tile + This->decode_info.tile_size; + + while (count--) + { + BYTE b = *src--; + + dst -= 8; + dst[2] = (b & 0x80) ? 0xff : 0; /* R */ + dst[1] = (b & 0x40) ? 0xff : 0; /* G */ + dst[0] = (b & 0x20) ? 0xff : 0; /* B */ + dst[3] = (b & 0x10) ? 0xff : 0; /* A */ + dst[6] = (b & 0x08) ? 0xff : 0; /* R */ + dst[5] = (b & 0x04) ? 0xff : 0; /* G */ + dst[4] = (b & 0x02) ? 0xff : 0; /* B */ + dst[7] = (b & 0x01) ? 0xff : 0; /* A */ + } + } + /* 16bpp RGBA */ + else if (This->decode_info.source_bpp == 16 && This->decode_info.samples == 4 && This->decode_info.bpp == 32) + { + BYTE *src, *dst; + DWORD count = This->decode_info.tile_width * This->decode_info.tile_height; + + src = This->cached_tile + count * 2; + dst = This->cached_tile + This->decode_info.tile_size; + + while (count--) + { + BYTE b[2]; + + src -= 2; + dst -= 4; + + b[0] = src[0]; + b[1] = src[1]; + + dst[0] = ((b[1] & 0xf0) >> 4) * 17; /* B */ + dst[1] = (b[0] & 0x0f) * 17; /* G */ + dst[2] = ((b[0] & 0xf0) >> 4) * 17; /* R */ + dst[3] = (b[1] & 0x0f) * 17; /* A */ + } + } /* 8bpp grayscale with extra alpha */ - if (hr == S_OK && This->decode_info.source_bpp == 16 && This->decode_info.samples == 2 && This->decode_info.bpp == 32) + else if (This->decode_info.source_bpp == 16 && This->decode_info.samples == 2 && This->decode_info.bpp == 32) { BYTE *src; DWORD *dst, count = This->decode_info.tile_width * This->decode_info.tile_height; @@ -993,7 +1201,7 @@ } } - if (hr == S_OK && This->decode_info.reverse_bgr) + if (This->decode_info.reverse_bgr) { if (This->decode_info.bps == 8) { @@ -1004,7 +1212,7 @@ } } - if (hr == S_OK && swap_bytes && This->decode_info.bps > 8) + if (swap_bytes && This->decode_info.bps > 8) { UINT row, i, samples_per_row; BYTE *sample, temp; @@ -1032,7 +1240,7 @@ } } - if (hr == S_OK && This->decode_info.invert_grayscale) + if (This->decode_info.invert_grayscale) { BYTE *byte, *end; @@ -1048,13 +1256,10 @@ *byte = ~(*byte); } - if (hr == S_OK) - { - This->cached_tile_x = tile_x; - This->cached_tile_y = tile_y; - } - - return hr; + This->cached_tile_x = tile_x; + This->cached_tile_y = tile_y; + + return S_OK; } static HRESULT WINAPI TiffFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, @@ -1297,11 +1502,11 @@ { BOOL byte_swapped = pTIFFIsByteSwapped(This->parent->tiff); #ifdef WORDS_BIGENDIAN - DWORD persist_options = byte_swapped ? WICPersistOptionsLittleEndian : WICPersistOptionsBigEndian; + DWORD persist_options = byte_swapped ? WICPersistOptionLittleEndian : WICPersistOptionBigEndian; #else - DWORD persist_options = byte_swapped ? WICPersistOptionsBigEndian : WICPersistOptionsLittleEndian; + DWORD persist_options = byte_swapped ? WICPersistOptionBigEndian : WICPersistOptionLittleEndian; #endif - persist_options |= WICPersistOptionsNoCacheStream; + persist_options |= WICPersistOptionNoCacheStream; hr = IWICPersistStream_LoadEx(persist, This->parent->stream, NULL, persist_options); if (FAILED(hr)) ERR("IWICPersistStream_LoadEx error %#x\n", hr); @@ -1698,7 +1903,7 @@ for (i = 0; i < This->colors; i++) { - red[i] = (This->palette[i] >> 0) & 0xff00; + red[i] = (This->palette[i] >> 8) & 0xff00; green[i] = This->palette[i] & 0xff00; blue[i] = (This->palette[i] << 8) & 0xff00; } Modified: trunk/reactos/dll/win32/windowscodecs/typeof.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/ty…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/typeof.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/typeof.h [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -78,6 +78,7 @@ typedef void (__cdecl typeof(png_set_crc_action))(struct png_struct_def *, int, int); typedef void (__stdcall typeof(png_set_PLTE))(struct png_struct_def *, struct png_info_def *, const struct png_color_struct *, int); typedef void (__stdcall typeof(png_set_tRNS))(struct png_struct_def *, struct png_info_def *, const unsigned char *, int, const struct png_color_16_struct *); +typedef void (__cdecl typeof(png_set_filter))(struct png_struct_def *, int, int); typedef void *thandle_t_1; typedef int (*TIFFReadWriteProc_1)(thandle_t_1, void *, __typeof_intptr); typedef unsigned int (*TIFFSeekProc_1)(void *, unsigned int, int); Modified: trunk/reactos/dll/win32/windowscodecs/windowscodecs.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/wi…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/windowscodecs.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/windowscodecs.spec [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -72,7 +72,7 @@ @ stdcall IWICImagingFactory_CreateBitmapScaler_Proxy(ptr ptr) IWICImagingFactory_CreateBitmapScaler_Proxy_W @ stdcall IWICImagingFactory_CreateBitmap_Proxy(ptr long long ptr long ptr) IWICImagingFactory_CreateBitmap_Proxy_W @ stdcall IWICImagingFactory_CreateComponentInfo_Proxy(ptr ptr ptr) IWICImagingFactory_CreateComponentInfo_Proxy_W -@ stdcall IWICImagingFactory_CreateDecoderFromFileHandle_Proxy(ptr ptr ptr long ptr) IWICImagingFactory_CreateDecoderFromFileHandle_Proxy_W +@ stdcall IWICImagingFactory_CreateDecoderFromFileHandle_Proxy(ptr long ptr long ptr) IWICImagingFactory_CreateDecoderFromFileHandle_Proxy_W @ stdcall IWICImagingFactory_CreateDecoderFromFilename_Proxy(ptr wstr ptr long long ptr) IWICImagingFactory_CreateDecoderFromFilename_Proxy_W @ stdcall IWICImagingFactory_CreateDecoderFromStream_Proxy(ptr ptr ptr long ptr) IWICImagingFactory_CreateDecoderFromStream_Proxy_W @ stdcall IWICImagingFactory_CreateEncoder_Proxy(ptr ptr ptr ptr) IWICImagingFactory_CreateEncoder_Proxy_W @@ -110,9 +110,9 @@ @ stdcall WICCreateColorContext_Proxy(ptr ptr) @ stdcall WICCreateImagingFactory_Proxy(long ptr) @ stub WICGetMetadataContentSize -@ stub WICMapGuidToShortName -@ stub WICMapSchemaToName -@ stub WICMapShortNameToGuid +@ stdcall WICMapGuidToShortName(ptr long ptr ptr) +@ stdcall WICMapSchemaToName(ptr wstr long ptr ptr) +@ stdcall WICMapShortNameToGuid(wstr ptr) @ stub WICMatchMetadataContent @ stub WICSerializeMetadataContent @ stdcall WICSetEncoderFormat_Proxy(ptr ptr ptr ptr) Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -196,7 +196,7 @@ reactos/dll/win32/vssapi # Synced to WineStaging-1.9.11 reactos/dll/win32/wbemdisp # Synced to WineStaging-2.9 reactos/dll/win32/wbemprox # Synced to WineStaging-2.9 -reactos/dll/win32/windowscodecs # Synced to WineStaging-1.9.23 +reactos/dll/win32/windowscodecs # Synced to WineStaging-2.9 reactos/dll/win32/windowscodecsext # Synced to WineStaging-1.9.11 reactos/dll/win32/winemp3.acm # Synced to WineStaging-2.2 reactos/dll/win32/wing32 # Synced to WineStaging-1.9.11 Modified: trunk/reactos/sdk/include/psdk/wincodecsdk.idl URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/wincodecs…
============================================================================== --- trunk/reactos/sdk/include/psdk/wincodecsdk.idl [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/wincodecsdk.idl [iso-8859-1] Sun Jun 4 01:48:14 2017 @@ -20,13 +20,13 @@ import "wincodec.idl"; typedef enum WICPersistOptions { - WICPersistOptionsDefault = 0x00000000, - WICPersistOptionsLittleEndian = 0x00000000, - WICPersistOptionsBigEndian = 0x00000001, - WICPersistOptionsStrictFormat = 0x00000002, - WICPersistOptionsNoCacheStream = 0x00000004, + WICPersistOptionDefault = 0x00000000, + WICPersistOptionLittleEndian = 0x00000000, + WICPersistOptionBigEndian = 0x00000001, + WICPersistOptionStrictFormat = 0x00000002, + WICPersistOptionNoCacheStream = 0x00000004, WICPersistOptionPreferUTF8 = 0x00000008, - WICPersistOptionsMask = 0x0000FFFF + WICPersistOptionMask = 0x0000FFFF } WICPersistOptions; typedef enum WICMetadataCreationOptions { @@ -50,6 +50,29 @@ cpp_quote("DEFINE_GUID(GUID_MetadataFormatGCE, 0x2a25cad8,0xdeeb,0x4c69,0xa7,0x88,0x0e,0xc2,0x26,0x6d,0xca,0xfd);") cpp_quote("DEFINE_GUID(GUID_MetadataFormatAPE, 0x2e043dc2,0xc967,0x4e05,0x87,0x5e,0x61,0x8b,0xf6,0x7e,0x85,0xc3);") cpp_quote("DEFINE_GUID(GUID_MetadataFormatGifComment, 0xc4b6e0e0,0xcfb4,0x4ad3,0xab,0x33,0x9a,0xad,0x23,0x55,0xa3,0x4a);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatSubIfd, 0x58a2e128,0x2db9,0x4e57,0xbb,0x14,0x51,0x77,0x89,0x1e,0xd3,0x31);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatGps, 0x7134ab8a,0x9351,0x44ad,0xaf,0x62,0x44,0x8d,0xb6,0xb5,0x02,0xec);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatInterop, 0xed686f8e,0x681f,0x4c8b,0xbd,0x41,0xa8,0xad,0xdb,0xf6,0xb3,0xfc);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatApp0, 0x79007028,0x268d,0x45d6,0xa3,0xc2,0x35,0x4e,0x6a,0x50,0x4b,0xc9);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatApp1, 0x8fd3dfc3,0xf951,0x492b,0x81,0x7f,0x69,0xc2,0xe6,0xd9,0xa5,0xb0);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatApp13, 0x326556a2,0xf502,0x4354,0x9c,0xc0,0x8e,0x3f,0x48,0xea,0xf6,0xb5);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatIPTC, 0x4fab0914,0xe129,0x4087,0xa1,0xd1,0xbc,0x81,0x2d,0x45,0xa7,0xb5);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatIRB, 0x16100d66,0x8570,0x4bb9,0xb9,0x2d,0xfd,0xa4,0xb2,0x3e,0xce,0x67);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormat8BIMIPTC, 0x0010568c,0x0852,0x4e6a,0xb1,0x91,0x5c,0x33,0xac,0x5b,0x04,0x30);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormat8BIMResolutionInfo, 0x739f305d,0x81db,0x43cb,0xac,0x5e,0x55,0x01,0x3e,0xf9,0xf0,0x03);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormat8BIMIPTCDigest, 0x1ca32285,0x9ccd,0x4786,0x8b,0xd8,0x79,0x53,0x9d,0xb6,0xa0,0x06);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatThumbnail, 0x243dcee9,0x8703,0x40ee,0x8e,0xf0,0x22,0xa6,0x0,0xb8,0x5,0x8c);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatXMPBag, 0x833cca5f,0xdcb7,0x4516,0x80,0x6f,0x65,0x96,0xab,0x26,0xdc,0xe4);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatXMPSeq, 0x63e8df02,0xeb6c,0x456c,0xa2,0x24,0xb2,0x5e,0x79,0x4f,0xd6,0x48);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatXMPAlt, 0x7b08a675,0x91aa,0x481b,0xa7,0x98,0x4d,0xa9,0x49,0x08,0x61,0x3b);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatJpegChrominance, 0xf73d0dcf,0xcec6,0x4f85,0x9b,0x0e,0x1c,0x39,0x56,0xb1,0xbe,0xf7);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatJpegLuminance, 0x86908007,0xedfc,0x4860,0x8d,0x4b,0x4e,0xe6,0xe8,0x3e,0x60,0x58);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatJpegComment, 0x220e5f33,0xafd3,0x474e,0x9d,0x31,0x7d,0x4f,0xe7,0x30,0xf5,0x57);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunkbKGD, 0xe14d3571,0x6b47,0x4dea,0xb6,0xa,0x87,0xce,0xa,0x78,0xdf,0xb7);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunkiTXt, 0xc2bec729,0xb68,0x4b77,0xaa,0xe,0x62,0x95,0xa6,0xac,0x18,0x14);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunkhIST, 0xc59a82da,0xdb74,0x48a4,0xbd,0x6a,0xb6,0x9c,0x49,0x31,0xef,0x95);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunkiCCP, 0xeb4349ab,0xb685,0x450f,0x91,0xb5,0xe8,0x2,0xe8,0x92,0x53,0x6c);") +cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunksRGB, 0xc115fd36,0xcc6f,0x4e3f,0x83,0x63,0x52,0x4b,0x87,0xc6,0xb0,0xd9);") cpp_quote("DEFINE_GUID(CLSID_WICUnknownMetadataReader, 0x699745c2,0x5066,0x4b82,0xa8,0xe3,0xd4,0x04,0x78,0xdb,0xec,0x8c);") cpp_quote("DEFINE_GUID(CLSID_WICUnknownMetadataWriter, 0xa09cca86,0x27ba,0x4f39,0x90,0x53,0x12,0x1f,0xa4,0xdc,0x08,0xfc);")
7 years, 6 months
1
0
0
0
← Newer
1
...
36
37
38
39
40
41
42
...
53
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
Results per page:
10
25
50
100
200