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
February 2019
----- 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
23 participants
208 discussions
Start a n
N
ew thread
[reactos] 01/01: [SNDVOL32] Take the balance between channels into account for the volume trackbar of the tray window.
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0185ee46d5065cfd41a47…
commit 0185ee46d5065cfd41a478c7210e423485c00430 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Tue Feb 5 20:33:43 2019 +0100 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Tue Feb 5 20:33:43 2019 +0100 [SNDVOL32] Take the balance between channels into account for the volume trackbar of the tray window. --- base/applications/sndvol32/tray.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/base/applications/sndvol32/tray.c b/base/applications/sndvol32/tray.c index 5970adcd21..59d5874aeb 100644 --- a/base/applications/sndvol32/tray.c +++ b/base/applications/sndvol32/tray.c @@ -125,15 +125,13 @@ OnTrayInitMixer( if (mixerGetControlDetails((HMIXEROBJ)pDialogData->hMixer, &mxcd, MIXER_OBJECTF_HMIXER | MIXER_GETCONTROLDETAILSF_VALUE) != MMSYSERR_NOERROR) return; - pDialogData->maxVolume = pDialogData->volumeInitValues[0].dwValue; - pDialogData->maxChannel = 0; - for (i = 1; i < pDialogData->volumeChannels; i++) + pDialogData->maxVolume = 0; + for (i = 0; i < pDialogData->volumeChannels; i++) { + pDialogData->volumeCurrentValues[i].dwValue = pDialogData->volumeInitValues[i].dwValue; + if (pDialogData->volumeInitValues[i].dwValue > pDialogData->maxVolume) - { pDialogData->maxVolume = pDialogData->volumeInitValues[i].dwValue; - pDialogData->maxChannel = i; - } } /* Initialize the volume trackbar */ @@ -209,18 +207,30 @@ OnVScroll( LPARAM lParam) { MIXERCONTROLDETAILS mxcd; - DWORD dwPos, dwVolume, i; + DWORD dwPosition, dwVolume, i; switch (LOWORD(wParam)) { - case TB_THUMBTRACK: + case TB_THUMBPOSITION: + break; + + case TB_ENDTRACK: + PlaySound((LPCTSTR)SND_ALIAS_SYSTEMDEFAULT, NULL, SND_ASYNC | SND_ALIAS_ID); + break; + + default: + dwPosition = VOLUME_MAX - (DWORD)SendDlgItemMessage(hwndDlg, IDC_LINE_SLIDER_VERT, TBM_GETPOS, 0, 0); - dwPos = VOLUME_MAX - (DWORD)SendDlgItemMessage(hwndDlg, IDC_LINE_SLIDER_VERT, TBM_GETPOS, 0, 0); - dwVolume = (dwPos * pDialogData->volumeStep) + pDialogData->volumeMinimum; + if (dwPosition == VOLUME_MIN) + dwVolume = pDialogData->volumeMinimum; + else if (dwPosition == VOLUME_MAX) + dwVolume = pDialogData->volumeMaximum; + else + dwVolume = (dwPosition * pDialogData->volumeStep) + pDialogData->volumeMinimum; for (i = 0; i < pDialogData->volumeChannels; i++) { - if (i == pDialogData->maxChannel) + if (pDialogData->volumeInitValues[i].dwValue == pDialogData->maxVolume) { pDialogData->volumeCurrentValues[i].dwValue = dwVolume; } @@ -242,13 +252,6 @@ OnVScroll( &mxcd, MIXER_OBJECTF_HMIXER | MIXER_SETCONTROLDETAILSF_VALUE); break; - - case TB_ENDTRACK: - PlaySound((LPCTSTR)SND_ALIAS_SYSTEMDEFAULT, NULL, SND_ASYNC | SND_ALIAS_ID); - break; - - default: - break; } }
5 years, 10 months
1
0
0
0
[reactos] 01/01: [MMSYS] Take the balance between channels into account for the master volume trackbar.
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d5ceace41906dbce2ebd4…
commit d5ceace41906dbce2ebd44697f7ba421f651c813 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Mon Feb 4 23:54:04 2019 +0100 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Mon Feb 4 23:54:04 2019 +0100 [MMSYS] Take the balance between channels into account for the master volume trackbar. --- dll/cpl/mmsys/speakervolume.c | 14 ++++-- dll/cpl/mmsys/volume.c | 109 +++++++++++++++++++++++++++++++++--------- 2 files changed, 96 insertions(+), 27 deletions(-) diff --git a/dll/cpl/mmsys/speakervolume.c b/dll/cpl/mmsys/speakervolume.c index 63eb9d4e38..a21c9406dc 100644 --- a/dll/cpl/mmsys/speakervolume.c +++ b/dll/cpl/mmsys/speakervolume.c @@ -151,7 +151,7 @@ OnHScroll( LPARAM lParam) { MIXERCONTROLDETAILS mxcd; - DWORD dwValue, dwPos; + DWORD dwValue, dwPosition; INT id, idx, i, j; id = (INT)GetWindowLongPtr((HWND)lParam, GWLP_ID); @@ -161,8 +161,14 @@ OnHScroll( if ((id - 9475) % 4 != 0) return; - dwPos = (DWORD)SendDlgItemMessage(hwndDlg, id, TBM_GETPOS, 0, 0); - dwValue = (dwPos * pPageData->volumeStep) + pPageData->volumeMinimum; + dwPosition = (DWORD)SendDlgItemMessage(hwndDlg, id, TBM_GETPOS, 0, 0); + + if (dwPosition == VOLUME_MIN) + dwValue = pPageData->volumeMinimum; + else if (dwPosition == VOLUME_MAX) + dwValue = pPageData->volumeMaximum; + else + dwValue = (dwPosition * pPageData->volumeStep) + pPageData->volumeMinimum; if (pPageData->volumeSync) { @@ -170,7 +176,7 @@ OnHScroll( { j = 9475 + (i * 4); if (j != id) - SendDlgItemMessage(hwndDlg, j, TBM_SETPOS, (WPARAM)TRUE, dwPos); + SendDlgItemMessage(hwndDlg, j, TBM_SETPOS, (WPARAM)TRUE, dwPosition); pPageData->volumeValues[i].dwValue = dwValue; } diff --git a/dll/cpl/mmsys/volume.c b/dll/cpl/mmsys/volume.c index 2d08037484..10f61f8222 100644 --- a/dll/cpl/mmsys/volume.c +++ b/dll/cpl/mmsys/volume.c @@ -31,10 +31,15 @@ typedef struct _GLOBAL_DATA DWORD muteControlID; DWORD volumeControlID; + DWORD volumeChannels; DWORD volumeMinimum; DWORD volumeMaximum; - DWORD volumeValue; DWORD volumeStep; + + DWORD maxVolume; + PMIXERCONTROLDETAILS_UNSIGNED volumeInitValues; + PMIXERCONTROLDETAILS_UNSIGNED volumeCurrentValues; + } GLOBAL_DATA, *PGLOBAL_DATA; @@ -154,6 +159,8 @@ GetVolumeControl(PGLOBAL_DATA pGlobalData) != MMSYSERR_NOERROR) return; + pGlobalData->volumeChannels = mxln.cChannels; + mxlc.cbStruct = sizeof(MIXERLINECONTROLS); mxlc.dwLineID = mxln.dwLineID; mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME; @@ -168,54 +175,92 @@ GetVolumeControl(PGLOBAL_DATA pGlobalData) pGlobalData->volumeMaximum = mxc.Bounds.dwMaximum; pGlobalData->volumeControlID = mxc.dwControlID; pGlobalData->volumeStep = (pGlobalData->volumeMaximum - pGlobalData->volumeMinimum) / (VOLUME_MAX - VOLUME_MIN); + + pGlobalData->volumeInitValues = HeapAlloc(GetProcessHeap(), + 0, + mxln.cChannels * sizeof(MIXERCONTROLDETAILS_UNSIGNED)); + if (pGlobalData->volumeInitValues == NULL) + return; + + pGlobalData->volumeCurrentValues = HeapAlloc(GetProcessHeap(), + 0, + mxln.cChannels * sizeof(MIXERCONTROLDETAILS_UNSIGNED)); + if (pGlobalData->volumeCurrentValues == NULL) + return; } VOID GetVolumeValue(PGLOBAL_DATA pGlobalData) { - MIXERCONTROLDETAILS_UNSIGNED mxcdVolume; MIXERCONTROLDETAILS mxcd; + DWORD i; if (pGlobalData->hMixer == NULL) return; mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS); mxcd.dwControlID = pGlobalData->volumeControlID; - mxcd.cChannels = 1; + mxcd.cChannels = pGlobalData->volumeChannels; mxcd.cMultipleItems = 0; mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED); - mxcd.paDetails = &mxcdVolume; + mxcd.paDetails = pGlobalData->volumeInitValues; if (mixerGetControlDetails((HMIXEROBJ)pGlobalData->hMixer, &mxcd, MIXER_OBJECTF_HMIXER | MIXER_GETCONTROLDETAILSF_VALUE) != MMSYSERR_NOERROR) return; - pGlobalData->volumeValue = mxcdVolume.dwValue; + pGlobalData->maxVolume = 0; + for (i = 0; i < pGlobalData->volumeChannels; i++) + { + pGlobalData->volumeCurrentValues[i].dwValue = pGlobalData->volumeInitValues[i].dwValue; + + if (pGlobalData->volumeInitValues[i].dwValue > pGlobalData->maxVolume) + pGlobalData->maxVolume = pGlobalData->volumeInitValues[i].dwValue; + } } VOID -SetVolumeValue(PGLOBAL_DATA pGlobalData){ - MIXERCONTROLDETAILS_UNSIGNED mxcdVolume; +SetVolumeValue(PGLOBAL_DATA pGlobalData, + DWORD dwPosition) +{ MIXERCONTROLDETAILS mxcd; + DWORD dwVolume, i; if (pGlobalData->hMixer == NULL) return; - mxcdVolume.dwValue = pGlobalData->volumeValue; + if (dwPosition == VOLUME_MIN) + dwVolume = pGlobalData->volumeMinimum; + else if (dwPosition == VOLUME_MAX) + dwVolume = pGlobalData->volumeMaximum; + else + dwVolume = (dwPosition * pGlobalData->volumeStep) + pGlobalData->volumeMinimum; + + for (i = 0; i < pGlobalData->volumeChannels; i++) + { + if (pGlobalData->volumeInitValues[i].dwValue == pGlobalData->maxVolume) + { + pGlobalData->volumeCurrentValues[i].dwValue = dwVolume; + } + else + { + pGlobalData->volumeCurrentValues[i].dwValue = + pGlobalData->volumeInitValues[i].dwValue * dwVolume / pGlobalData-> maxVolume; + } + } + mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS); mxcd.dwControlID = pGlobalData->volumeControlID; - mxcd.cChannels = 1; + mxcd.cChannels = pGlobalData->volumeChannels; mxcd.cMultipleItems = 0; mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED); - mxcd.paDetails = &mxcdVolume; + mxcd.paDetails = pGlobalData->volumeCurrentValues; if (mixerSetControlDetails((HMIXEROBJ)pGlobalData->hMixer, &mxcd, MIXER_OBJECTF_HMIXER | MIXER_SETCONTROLDETAILSF_VALUE) != MMSYSERR_NOERROR) return; - - pGlobalData->volumeValue = mxcdVolume.dwValue; } @@ -306,7 +351,7 @@ InitVolumeControls(HWND hwndDlg, PGLOBAL_DATA pGlobalData) SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(VOLUME_MIN, VOLUME_MAX)); SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETTICFREQ, VOLUME_TICFREQ, 0); SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPAGESIZE, 0, VOLUME_PAGESIZE); - SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->volumeValue - pGlobalData->volumeMinimum) / pGlobalData->volumeStep); + SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->maxVolume - pGlobalData->volumeMinimum) / pGlobalData->volumeStep); } VOID @@ -362,7 +407,7 @@ VolumeDlgProc(HWND hwndDlg, case MM_MIXM_CONTROL_CHANGE: { GetVolumeValue(pGlobalData); - SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->volumeValue - pGlobalData->volumeMinimum) / pGlobalData->volumeStep); + SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->maxVolume - pGlobalData->volumeMinimum) / pGlobalData->volumeStep); break; } case WM_INITDIALOG: @@ -454,21 +499,39 @@ VolumeDlgProc(HWND hwndDlg, HWND hVolumeTrackbar = GetDlgItem(hwndDlg, IDC_VOLUME_TRACKBAR); if (hVolumeTrackbar == (HWND)lParam) { - pGlobalData->volumeValue = ((DWORD)SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_GETPOS, 0, 0) * pGlobalData->volumeStep) + pGlobalData->volumeMinimum; - SetVolumeValue(pGlobalData); + switch (LOWORD(wParam)) + { + case TB_THUMBPOSITION: + break; + + case TB_ENDTRACK: + PlaySound((LPCTSTR)SND_ALIAS_SYSTEMDEFAULT, NULL, SND_ALIAS_ID | SND_ASYNC); + break; - if (LOWORD(wParam) == TB_ENDTRACK) - PlaySound((LPCTSTR)SND_ALIAS_SYSTEMDEFAULT, NULL, SND_ALIAS_ID | SND_ASYNC); + default: + SetVolumeValue(pGlobalData, + (DWORD)SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_GETPOS, 0, 0)); + break; + } } break; } case WM_DESTROY: - mixerClose(pGlobalData->hMixer); - DestroyIcon(pGlobalData->hIconMuted); - DestroyIcon(pGlobalData->hIconUnMuted); - DestroyIcon(pGlobalData->hIconNoHW); - HeapFree(GetProcessHeap(), 0, pGlobalData); + if (pGlobalData) + { + if (pGlobalData->volumeInitValues) + HeapFree(GetProcessHeap(), 0, pGlobalData->volumeInitValues); + + if (pGlobalData->volumeCurrentValues) + HeapFree(GetProcessHeap(), 0, pGlobalData->volumeCurrentValues); + + mixerClose(pGlobalData->hMixer); + DestroyIcon(pGlobalData->hIconMuted); + DestroyIcon(pGlobalData->hIconUnMuted); + DestroyIcon(pGlobalData->hIconNoHW); + HeapFree(GetProcessHeap(), 0, pGlobalData); + } break; case WM_NOTIFY:
5 years, 10 months
1
0
0
0
[reactos] 01/01: [WINDOWSCODECS_WINETEST] Sync with Wine Staging 4.0. CORE-15682
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eea81f5274c93e8d65f02…
commit eea81f5274c93e8d65f02bd294d8122d25cc9544 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Feb 4 13:12:58 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Feb 4 13:12:58 2019 +0100 [WINDOWSCODECS_WINETEST] Sync with Wine Staging 4.0. CORE-15682 --- .../winetests/windowscodecs/CMakeLists.txt | 4 +- modules/rostests/winetests/windowscodecs/bitmap.c | 216 ++++++++++++ .../rostests/winetests/windowscodecs/converter.c | 88 ++--- .../rostests/winetests/windowscodecs/icoformat.c | 207 +++++++---- modules/rostests/winetests/windowscodecs/info.c | 43 ++- .../rostests/winetests/windowscodecs/metadata.c | 57 ++-- modules/rostests/winetests/windowscodecs/palette.c | 2 +- .../rostests/winetests/windowscodecs/pngformat.c | 146 ++++++-- modules/rostests/winetests/windowscodecs/stream.c | 378 ++++++++++++++++++--- .../rostests/winetests/windowscodecs/tiffformat.c | 117 ++++++- 10 files changed, 1040 insertions(+), 218 deletions(-) diff --git a/modules/rostests/winetests/windowscodecs/CMakeLists.txt b/modules/rostests/winetests/windowscodecs/CMakeLists.txt index 0cffe520e8..6bae33b891 100644 --- a/modules/rostests/winetests/windowscodecs/CMakeLists.txt +++ b/modules/rostests/winetests/windowscodecs/CMakeLists.txt @@ -1,5 +1,7 @@ -add_definitions(-DUSE_WINE_TODOS) +add_definitions( + -DUSE_WINE_TODOS + -DWINETEST_USE_DBGSTR_LONGLONG) list(APPEND SOURCE bitmap.c diff --git a/modules/rostests/winetests/windowscodecs/bitmap.c b/modules/rostests/winetests/windowscodecs/bitmap.c index 6e01f0b1d1..d4b597900d 100644 --- a/modules/rostests/winetests/windowscodecs/bitmap.c +++ b/modules/rostests/winetests/windowscodecs/bitmap.c @@ -452,6 +452,19 @@ static void test_createbitmapfromsource(void) hr = IWICBitmap_SetResolution(bitmap, 12.0, 34.0); ok(hr == S_OK, "IWICBitmap_SetResolution failed hr=%x\n", hr); + /* WICBitmapNoCache */ + hr = IWICImagingFactory_CreateBitmapFromSource(factory, (IWICBitmapSource *)bitmap, + WICBitmapNoCache, &bitmap2); + ok(hr == S_OK, "IWICImagingFactory_CreateBitmapFromSource failed hr=%x\n", hr); + ok(bitmap2 == bitmap, "Unexpected bitmap instance.\n"); + + IWICBitmap_Release(bitmap2); + + bitmap2 = (void *)0xdeadbeef; + hr = IWICImagingFactory_CreateBitmapFromSource(factory, &bitmapsource, WICBitmapNoCache, &bitmap2); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + ok(bitmap2 == (void *)0xdeadbeef, "Unexpected pointer %p.\n", bitmap2); + hr = IWICImagingFactory_CreateBitmapFromSource(factory, (IWICBitmapSource*)bitmap, WICBitmapCacheOnLoad, &bitmap2); ok(hr == S_OK, "IWICImagingFactory_CreateBitmapFromSource failed hr=%x\n", hr); @@ -538,6 +551,43 @@ static void test_createbitmapfromsource(void) ok(width == 3, "got %d, expected 3\n", width); ok(height == 3, "got %d, expected 3\n", height); + /* CreateBitmapFromSourceRect */ + hr = IWICImagingFactory_CreateBitmapFromSourceRect(factory, (IWICBitmapSource *)bitmap2, 0, 0, 16, 32, &bitmap); + ok(hr == S_OK, "Failed to create a bitmap, hr %#x.\n", hr); + hr = IWICBitmap_GetSize(bitmap, &width, &height); + ok(hr == S_OK, "Failed to get bitmap size, hr %#x.\n", hr); + ok(width == 3, "Unexpected width %u.\n", width); + ok(height == 3, "Unexpected height %u.\n", height); + IWICBitmap_Release(bitmap); + + hr = IWICImagingFactory_CreateBitmapFromSourceRect(factory, (IWICBitmapSource *)bitmap2, 0, 0, 1, 1, &bitmap); + ok(hr == S_OK, "Failed to create a bitmap, hr %#x.\n", hr); + hr = IWICBitmap_GetSize(bitmap, &width, &height); + ok(hr == S_OK, "Failed to get bitmap size, hr %#x.\n", hr); + ok(width == 1, "Unexpected width %u.\n", width); + ok(height == 1, "Unexpected height %u.\n", height); + IWICBitmap_Release(bitmap); + + hr = IWICImagingFactory_CreateBitmapFromSourceRect(factory, (IWICBitmapSource *)bitmap2, 2, 1, 16, 32, &bitmap); + ok(hr == S_OK, "Failed to create a bitmap, hr %#x.\n", hr); + hr = IWICBitmap_GetSize(bitmap, &width, &height); + ok(hr == S_OK, "Failed to get bitmap size, hr %#x.\n", hr); + ok(width == 1, "Unexpected width %u.\n", width); + ok(height == 2, "Unexpected height %u.\n", height); + IWICBitmap_Release(bitmap); + + hr = IWICImagingFactory_CreateBitmapFromSourceRect(factory, (IWICBitmapSource *)bitmap2, 0, 0, 0, 2, &bitmap); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICImagingFactory_CreateBitmapFromSourceRect(factory, (IWICBitmapSource *)bitmap2, 0, 0, 2, 0, &bitmap); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICImagingFactory_CreateBitmapFromSourceRect(factory, (IWICBitmapSource *)bitmap2, 1, 3, 16, 32, &bitmap); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICImagingFactory_CreateBitmapFromSourceRect(factory, (IWICBitmapSource *)bitmap2, 3, 1, 16, 32, &bitmap); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + IWICBitmap_Release(bitmap2); } @@ -1030,6 +1080,171 @@ static void test_WICCreateBitmapFromSectionEx(void) CloseHandle(hsection); } +static void test_bitmap_scaler(void) +{ + WICPixelFormatGUID pixel_format; + IWICBitmapScaler *scaler; + IWICPalette *palette; + double res_x, res_y; + IWICBitmap *bitmap; + UINT width, height; + HRESULT hr; + + hr = IWICImagingFactory_CreateBitmap(factory, 4, 2, &GUID_WICPixelFormat24bppBGR, WICBitmapCacheOnLoad, &bitmap); + ok(hr == S_OK, "Failed to create a bitmap, hr %#x.\n", hr); + + hr = IWICBitmap_GetSize(bitmap, &width, &height); + ok(hr == S_OK, "Failed to get bitmap size, hr %#x.\n", hr); + ok(width == 4, "Unexpected width %u.\n", width); + ok(height == 2, "Unexpected height %u.\n", height); + + hr = IWICBitmap_GetResolution(bitmap, &res_x, &res_y); + ok(hr == S_OK, "Failed to get bitmap resolution, hr %#x.\n", hr); + ok(res_x == 0.0 && res_y == 0.0, "Unexpected resolution %f x %f.\n", res_x, res_y); + + hr = IWICImagingFactory_CreateBitmapScaler(factory, &scaler); + ok(hr == S_OK, "Failed to create bitmap scaler, hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, NULL, 0, 0, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 0, 0, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, NULL, &height); + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, &width, NULL); + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetResolution(scaler, NULL, NULL); + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + + res_x = 0.1; + hr = IWICBitmapScaler_GetResolution(scaler, &res_x, NULL); + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + ok(res_x == 0.1, "Unexpected resolution %f.\n", res_x); + + hr = IWICBitmapScaler_GetResolution(scaler, NULL, &res_y); + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetResolution(scaler, &res_x, &res_y); + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetPixelFormat(scaler, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + memset(&pixel_format, 0, sizeof(pixel_format)); + hr = IWICBitmapScaler_GetPixelFormat(scaler, &pixel_format); + ok(hr == S_OK, "Failed to get pixel format, hr %#x.\n", hr); + ok(IsEqualGUID(&pixel_format, &GUID_WICPixelFormatDontCare), "Unexpected pixel format %s.\n", + wine_dbgstr_guid(&pixel_format)); + + width = 123; + height = 321; + hr = IWICBitmapScaler_GetSize(scaler, &width, &height); + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + ok(width == 123, "Unexpected width %u.\n", width); + ok(height == 321, "Unexpected height %u.\n", height); + + hr = IWICBitmapScaler_CopyPalette(scaler, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICImagingFactory_CreatePalette(factory, &palette); + ok(hr == S_OK, "Failed to create a palette, hr %#x.\n", hr); + hr = IWICBitmapScaler_CopyPalette(scaler, palette); + ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "Unexpected hr %#x.\n", hr); + IWICPalette_Release(palette); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 4, 0, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, &width, &height); + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 0, 2, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, &width, &height); + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, NULL, 8, 4, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Failed to initialize bitmap scaler, hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 8, 4, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == S_OK, "Failed to initialize bitmap scaler, hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 0, 4, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 8, 0, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, NULL, 8, 4, WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 8, 4, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == WINCODEC_ERR_WRONGSTATE, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, &width, &height); + ok(hr == S_OK, "Failed to get scaler size, hr %#x.\n", hr); + ok(width == 8, "Unexpected width %u.\n", width); + ok(height == 4, "Unexpected height %u.\n", height); + + hr = IWICBitmapScaler_GetSize(scaler, NULL, &height); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, &width, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, NULL, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetPixelFormat(scaler, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + memset(&pixel_format, 0, sizeof(pixel_format)); + hr = IWICBitmapScaler_GetPixelFormat(scaler, &pixel_format); + ok(hr == S_OK, "Failed to get pixel format, hr %#x.\n", hr); + ok(IsEqualGUID(&pixel_format, &GUID_WICPixelFormat24bppBGR), "Unexpected pixel format %s.\n", + wine_dbgstr_guid(&pixel_format)); + + hr = IWICBitmapScaler_GetResolution(scaler, NULL, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + res_x = 0.1; + hr = IWICBitmapScaler_GetResolution(scaler, &res_x, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + ok(res_x == 0.1, "Unexpected resolution %f.\n", res_x); + + hr = IWICBitmapScaler_GetResolution(scaler, NULL, &res_y); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + res_x = res_y = 1.0; + hr = IWICBitmapScaler_GetResolution(scaler, &res_x, &res_y); + ok(hr == S_OK, "Failed to get scaler resolution, hr %#x.\n", hr); + ok(res_x == 0.0 && res_y == 0.0, "Unexpected resolution %f x %f.\n", res_x, res_y); + + hr = IWICImagingFactory_CreatePalette(factory, &palette); + ok(hr == S_OK, "Failed to create a palette, hr %#x.\n", hr); + hr = IWICBitmapScaler_CopyPalette(scaler, palette); + ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "Unexpected hr %#x.\n", hr); + IWICPalette_Release(palette); + + IWICBitmapScaler_Release(scaler); + + IWICBitmap_Release(bitmap); +} + START_TEST(bitmap) { HRESULT hr; @@ -1046,6 +1261,7 @@ START_TEST(bitmap) test_CreateBitmapFromHICON(); test_CreateBitmapFromHBITMAP(); test_clipper(); + test_bitmap_scaler(); IWICImagingFactory_Release(factory); diff --git a/modules/rostests/winetests/windowscodecs/converter.c b/modules/rostests/winetests/windowscodecs/converter.c index 91deda2010..8682f87061 100644 --- a/modules/rostests/winetests/windowscodecs/converter.c +++ b/modules/rostests/winetests/windowscodecs/converter.c @@ -904,16 +904,6 @@ static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format) ok(samples == 1, "wrong samples %d\n", samples); ok(colormap == 6, "wrong colormap %d\n", colormap); } - else if (IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed)) - { - ok(width == 32, "wrong width %u\n", width); - ok(height == 2, "wrong height %u\n", height); - - ok(bps == 2, "wrong bps %d\n", bps); - ok(photo == 3, "wrong photometric %d\n", photo); - ok(samples == 1, "wrong samples %d\n", samples); - ok(colormap == 12, "wrong colormap %d\n", colormap); - } else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed)) { ok(width == 32, "wrong width %u\n", width); @@ -976,18 +966,6 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format) ok(bih.bV5ClrUsed == 256, "wrong ClrUsed %d\n", bih.bV5ClrUsed); ok(bih.bV5ClrImportant == 256, "wrong ClrImportant %d\n", bih.bV5ClrImportant); } - else if (IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed)) - { - ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %08x\n", bfh.bfOffBits); - - ok(bih.bV5Width == 32, "wrong width %u\n", bih.bV5Width); - ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height); - - ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes); - ok(bih.bV5BitCount == 2, "wrong BitCount %d\n", bih.bV5BitCount); - ok(bih.bV5ClrUsed == 256, "wrong ClrUsed %d\n", bih.bV5ClrUsed); - ok(bih.bV5ClrImportant == 256, "wrong ClrImportant %d\n", bih.bV5ClrImportant); - } else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed)) { ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %08x\n", bfh.bfOffBits); @@ -1243,6 +1221,7 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls const struct bitmap_data **dsts, const CLSID *clsid_decoder, WICRect *rc, const struct setting *settings, const char *name, IWICPalette *palette) { + const GUID *container_format = NULL; HRESULT hr; IWICBitmapEncoder *encoder; BitmapTestSrc *src_obj; @@ -1253,6 +1232,7 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls IWICBitmapDecoder *decoder; IWICBitmapFrameDecode *framedecode; WICPixelFormatGUID pixelformat; + GUID guid; int i; hr = CoCreateInstance(clsid_encoder, NULL, CLSCTX_INPROC_SERVER, @@ -1262,6 +1242,28 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); ok(SUCCEEDED(hr), "CreateStreamOnHGlobal failed, hr=%x\n", hr); + hr = IWICBitmapEncoder_GetContainerFormat(encoder, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + if (IsEqualGUID(clsid_encoder, &CLSID_WICPngEncoder)) + container_format = &GUID_ContainerFormatPng; + else if (IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder)) + container_format = &GUID_ContainerFormatBmp; + else if (IsEqualGUID(clsid_encoder, &CLSID_WICTiffEncoder)) + container_format = &GUID_ContainerFormatTiff; + else if (IsEqualGUID(clsid_encoder, &CLSID_WICJpegEncoder)) + container_format = &GUID_ContainerFormatJpeg; + else + ok(0, "Unknown encoder %s.\n", wine_dbgstr_guid(clsid_encoder)); + + if (container_format) + { + memset(&guid, 0, sizeof(guid)); + hr = IWICBitmapEncoder_GetContainerFormat(encoder, &guid); + ok(SUCCEEDED(hr), "Failed to get container format, hr %#x.\n", hr); + ok(IsEqualGUID(container_format, &guid), "Unexpected container format %s.\n", wine_dbgstr_guid(&guid)); + } + hr = IWICBitmapEncoder_Initialize(encoder, stream, WICBitmapEncoderNoCache); ok(SUCCEEDED(hr), "Initialize failed, hr=%x\n", hr); @@ -1288,6 +1290,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls if (hglobal && SUCCEEDED(hr)) { + IWICBitmapEncoderInfo *info = NULL; + if (palette) { hr = IWICBitmapEncoder_SetPalette(encoder, palette); @@ -1307,6 +1311,20 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls hr = S_OK; } + hr = IWICBitmapEncoder_GetEncoderInfo(encoder, &info); + ok(hr == S_OK || hr == WINCODEC_ERR_COMPONENTNOTFOUND, "wrong error %#x\n", hr); + if (SUCCEEDED(hr)) + { + CLSID clsid; + + hr = IWICBitmapEncoderInfo_GetCLSID(info, &clsid); + ok(hr == S_OK, "wrong error %#x\n", hr); + ok(!IsEqualGUID(&clsid_encoder, &clsid), "wrong CLSID %s (%s)\n", + wine_dbgstr_guid(clsid_encoder), wine_dbgstr_guid(&clsid)); + + IWICBitmapEncoderInfo_Release(info); + } + i=0; while (SUCCEEDED(hr) && srcs[i]) { @@ -1353,9 +1371,9 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls hr = IWICBitmapFrameEncode_SetPixelFormat(frameencode, &pixelformat); ok(SUCCEEDED(hr), "SetPixelFormat failed, hr=%x\n", hr); ok(IsEqualGUID(&pixelformat, dsts[i]->format) || - broken(IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder) && srcs[i]->bpp == 2 && IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed)) || - broken(IsEqualGUID(clsid_encoder, &CLSID_WICTiffEncoder) && srcs[i]->bpp == 2 && IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed)), - "SetPixelFormat changed the format to %s (%s)\n", wine_dbgstr_guid(&pixelformat), name); + (IsEqualGUID(clsid_encoder, &CLSID_WICTiffEncoder) && srcs[i]->bpp == 2 && IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed)) || + (IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder) && srcs[i]->bpp == 2 && IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed)), + "SetPixelFormat changed the format to %s (%s)\n", wine_dbgstr_guid(&pixelformat), name); hr = IWICBitmapFrameEncode_SetSize(frameencode, srcs[i]->width, srcs[i]->height); ok(SUCCEEDED(hr), "SetSize failed, hr=%x\n", hr); @@ -1390,8 +1408,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls ok(SUCCEEDED(hr), "WriteSource(%dx%d) failed, hr=%x (%s)\n", rc->Width, rc->Height, hr, name); else ok(hr == S_OK || - broken(hr == E_INVALIDARG && IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder) && srcs[i]->bpp == 2) /* XP */ || - broken(hr == E_INVALIDARG && IsEqualGUID(clsid_encoder, &CLSID_WICTiffEncoder) && srcs[i]->bpp == 2) /* XP */ || + (hr == E_NOTIMPL && IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder) && srcs[i]->bpp == 2) || + (hr == E_NOTIMPL && IsEqualGUID(clsid_encoder, &CLSID_WICTiffEncoder) && srcs[i]->bpp == 2) || broken(hr == E_INVALIDARG && IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder) && IsEqualGUID(srcs[i]->format, &GUID_WICPixelFormatBlackWhite)) /* XP */, "WriteSource(NULL) failed, hr=%x (%s)\n", hr, name); } @@ -1529,15 +1547,6 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls ok(colors[4] == 0xff555555, "got %08x (%s)\n", colors[4], name); ok(colors[5] == 0xff000000, "got %08x (%s)\n", colors[5], name); } - else if (IsEqualGUID(&pixelformat, &GUID_WICPixelFormat2bppIndexed)) - { - ok(count == 4, "expected 4, got %u (%s)\n", count, name); - - ok(colors[0] == 0xff111111, "got %08x (%s)\n", colors[0], name); - ok(colors[1] == 0xff222222, "got %08x (%s)\n", colors[1], name); - ok(colors[2] == 0xff333333, "got %08x (%s)\n", colors[2], name); - ok(colors[3] == 0xff444444, "got %08x (%s)\n", colors[3], name); - } else if (IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed)) { ok(count == 16, "expected 16, got %u (%s)\n", count, name); @@ -1828,8 +1837,6 @@ START_TEST(converter) &IID_IWICImagingFactory, (void **)&factory); ok(hr == S_OK, "failed to create factory: %#x\n", hr); - test_converter_8bppIndexed(); - 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); @@ -1870,6 +1877,7 @@ START_TEST(converter) test_invalid_conversion(); test_default_converter(); + test_converter_8bppIndexed(); test_encoder(&testdata_8bppIndexed, &CLSID_WICGifEncoder, &testdata_8bppIndexed, &CLSID_WICGifDecoder, "GIF encoder 8bppIndexed"); @@ -1897,7 +1905,7 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in test_encoder(&testdata_1bppIndexed, &CLSID_WICBmpEncoder, &testdata_1bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder 1bppIndexed"); test_encoder(&testdata_2bppIndexed, &CLSID_WICBmpEncoder, - &testdata_2bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder 2bppIndexed"); + &testdata_4bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder 2bppIndexed"); test_encoder(&testdata_4bppIndexed, &CLSID_WICBmpEncoder, &testdata_4bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder 4bppIndexed"); test_encoder(&testdata_8bppIndexed, &CLSID_WICBmpEncoder, @@ -1910,7 +1918,7 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in test_encoder(&testdata_1bppIndexed, &CLSID_WICTiffEncoder, &testdata_1bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 1bppIndexed"); test_encoder(&testdata_2bppIndexed, &CLSID_WICTiffEncoder, - &testdata_2bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 2bppIndexed"); + &testdata_4bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 2bppIndexed"); test_encoder(&testdata_4bppIndexed, &CLSID_WICTiffEncoder, &testdata_4bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 4bppIndexed"); test_encoder(&testdata_8bppIndexed, &CLSID_WICTiffEncoder, diff --git a/modules/rostests/winetests/windowscodecs/icoformat.c b/modules/rostests/winetests/windowscodecs/icoformat.c index c53739dbd6..38db51c376 100644 --- a/modules/rostests/winetests/windowscodecs/icoformat.c +++ b/modules/rostests/winetests/windowscodecs/icoformat.c @@ -26,72 +26,114 @@ #include "wincodec.h" #include "wine/test.h" -static unsigned char testico_bad_icondirentry_size[] = { - /* ICONDIR */ - 0, 0, /* reserved */ - 1, 0, /* type */ - 1, 0, /* count */ +#include "pshpack1.h" + +struct ICONHEADER +{ + WORD idReserved; + WORD idType; + WORD idCount; +}; + +struct ICONDIRENTRY +{ + BYTE bWidth; + BYTE bHeight; + BYTE bColorCount; + BYTE bReserved; + WORD wPlanes; + WORD wBitCount; + DWORD dwDIBSize; + DWORD dwDIBOffset; +}; + +struct test_ico +{ + struct ICONHEADER header; + struct ICONDIRENTRY direntry; + BITMAPINFOHEADER bmi; + unsigned char data[512]; +}; + +static const struct test_ico ico_1 = +{ + /* ICONHEADER */ + { + 0, /* reserved */ + 1, /* type */ + 1, /* count */ + }, /* ICONDIRENTRY */ - 2, /* width */ - 2, /* height */ - 2, /* colorCount */ - 0, /* reserved */ - 1,0, /* planes */ - 8,0, /* bitCount */ - (40+2*4+16*16+16*4) & 0xFF,((40+2*4+16*16+16*4) >> 8) & 0xFF,0,0, /* bytesInRes */ - 22,0,0,0, /* imageOffset */ + { + 16, /* width */ + 16, /* height */ + 2, /* color count */ + 0, /* reserved */ + 1, /* planes */ + 8, /* bitcount*/ + 40 + 2*4 + 16 * 16 + 16 * 4, /* data size */ + 22 /* data offset */ + }, /* BITMAPINFOHEADER */ - 40,0,0,0, /* header size */ - 16,0,0,0, /* width */ - 2*16,0,0,0, /* height (XOR+AND rows) */ - 1,0, /* planes */ - 8,0, /* bit count */ - 0,0,0,0, /* compression */ - 0,0,0,0, /* sizeImage */ - 0,0,0,0, /* x pels per meter */ - 0,0,0,0, /* y pels per meter */ - 2,0,0,0, /* clrUsed */ - 0,0,0,0, /* clrImportant */ - /* palette */ - 0,0,0,0, - 0xFF,0xFF,0xFF,0, - /* XOR mask */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0, - 0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0, - 0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0, - 0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0, - 0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0, - 0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0, - 0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0, - 0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0, - 0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0, - 0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - /* AND mask */ - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0 + { + sizeof(BITMAPINFOHEADER), /* header size */ + 16, /* width */ + 2*16, /* height (XOR+AND rows) */ + 1, /* planes */ + 8, /* bit count */ + 0, /* compression */ + 0, /* sizeImage */ + 0, /* x pels per meter */ + 0, /* y pels per meter */ + 2, /* clrUsed */ + 0, /* clrImportant */ + }, + { + /* palette */ + 0,0,0,0, + 0xFF,0xFF,0xFF,0, + /* XOR mask */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0, + 0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0, + 0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0, + 0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0, + 0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0, + 0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0, + 0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0, + 0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0, + 0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0, + 0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0, + 0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + /* AND mask */ + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0 + } }; -static void test_bad_icondirentry_size(void) +#include "poppack.h" + +#define test_ico_data(a, b, c) test_ico_data_(a, b, c, 0, __LINE__) +#define test_ico_data_todo(a, b, c) test_ico_data_(a, b, c, 1, __LINE__) +static void test_ico_data_(void *data, DWORD data_size, HRESULT init_hr, int todo, unsigned int line) { IWICBitmapDecoder *decoder; IWICImagingFactory *factory; @@ -108,8 +150,7 @@ static void test_bad_icondirentry_size(void) ok(hr == S_OK, "CreateStream failed, hr=%x\n", hr); if (SUCCEEDED(hr)) { - hr = IWICStream_InitializeFromMemory(icostream, testico_bad_icondirentry_size, - sizeof(testico_bad_icondirentry_size)); + hr = IWICStream_InitializeFromMemory(icostream, data, data_size); ok(hr == S_OK, "InitializeFromMemory failed, hr=%x\n", hr); if (SUCCEEDED(hr)) @@ -123,7 +164,8 @@ static void test_bad_icondirentry_size(void) { hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)icostream, WICDecodeMetadataCacheOnDemand); - ok(hr == S_OK, "Initialize failed, hr=%x\n", hr); + todo_wine_if(todo) + ok_(__FILE__, line)(hr == init_hr, "Initialize failed, hr=%x\n", hr); if (SUCCEEDED(hr)) { @@ -163,11 +205,44 @@ static void test_bad_icondirentry_size(void) IWICImagingFactory_Release(factory); } +static void test_decoder(void) +{ + struct test_ico ico; + + /* Icon size specified in ICONDIRENTRY does not match bitmap header. */ + ico = ico_1; + ico.direntry.bWidth = 2; + ico.direntry.bHeight = 2; + test_ico_data(&ico, sizeof(ico), S_OK); + + /* Invalid DIRENTRY data size/offset. */ + ico = ico_1; + ico.direntry.dwDIBOffset = sizeof(ico); + test_ico_data(&ico, sizeof(ico), WINCODEC_ERR_BADIMAGE); + + ico = ico_1; + ico.direntry.dwDIBSize = sizeof(ico); + test_ico_data(&ico, sizeof(ico), WINCODEC_ERR_BADIMAGE); + + /* Header fields validation. */ + ico = ico_1; + ico.header.idReserved = 1; + test_ico_data_todo(&ico, sizeof(ico), S_OK); + ico.header.idReserved = 0; + ico.header.idType = 100; + test_ico_data_todo(&ico, sizeof(ico), S_OK); + + /* Premature end of data. */ + ico = ico_1; + test_ico_data(&ico, sizeof(ico.header) - 1, WINCODEC_ERR_STREAMREAD); + test_ico_data(&ico, sizeof(ico.header) + sizeof(ico.direntry) - 1, WINCODEC_ERR_BADIMAGE); +} + START_TEST(icoformat) { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); - test_bad_icondirentry_size(); + test_decoder(); CoUninitialize(); } diff --git a/modules/rostests/winetests/windowscodecs/info.c b/modules/rostests/winetests/windowscodecs/info.c index d00e9d8338..ee95784166 100644 --- a/modules/rostests/winetests/windowscodecs/info.c +++ b/modules/rostests/winetests/windowscodecs/info.c @@ -119,7 +119,7 @@ static void test_decoder_info(void) UINT num_formats, count; int i, j; - for (i = 0; i < sizeof(decoder_info_tests)/sizeof(decoder_info_tests[0]); i++) + for (i = 0; i < ARRAY_SIZE(decoder_info_tests); i++) { struct decoder_info_test *test = &decoder_info_tests[i]; IWICBitmapDecoder *decoder, *decoder2; @@ -149,8 +149,8 @@ static void test_decoder_info(void) } IWICBitmapDecoder_Release(decoder); - MultiByteToWideChar(CP_ACP, 0, test->mimetype, -1, mimetypeW, sizeof(mimetypeW)/sizeof(mimetypeW[0])); - MultiByteToWideChar(CP_ACP, 0, test->extensions, -1, extensionsW, sizeof(extensionsW)/sizeof(extensionsW[0])); + MultiByteToWideChar(CP_ACP, 0, test->mimetype, -1, mimetypeW, ARRAY_SIZE(mimetypeW)); + MultiByteToWideChar(CP_ACP, 0, test->extensions, -1, extensionsW, ARRAY_SIZE(extensionsW)); hr = get_component_info(test->clsid, &info); ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr); @@ -234,8 +234,8 @@ static void test_decoder_info(void) ok(hr == E_INVALIDARG, "GetPixelFormats failed, hr=%x\n", hr); count = 0xdeadbeef; - hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, sizeof(pixelformats)/sizeof(pixelformats[0]), - pixelformats, &count); + hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, ARRAY_SIZE(pixelformats), + pixelformats, &count); ok(hr == S_OK, "GetPixelFormats failed, hr=%x\n", hr); ok(count == num_formats, "got %d formats, expected %d\n", count, num_formats); @@ -637,6 +637,38 @@ todo_wine IWICImagingFactory_Release(factory); } +static void test_imagingfactory_interfaces(void) +{ + IWICComponentFactory *component_factory; + IWICImagingFactory2 *factory2; + IWICImagingFactory *factory; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, + &IID_IWICImagingFactory2, (void **)&factory2); + if (FAILED(hr)) + { + win_skip("IWICImagingFactory2 is not supported.\n"); + return; + } + + hr = IWICImagingFactory2_QueryInterface(factory2, &IID_IWICComponentFactory, (void **)&component_factory); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IWICComponentFactory_QueryInterface(component_factory, &IID_IWICImagingFactory, (void **)&factory); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(factory == (IWICImagingFactory *)component_factory, "Unexpected factory pointer.\n"); + IWICImagingFactory_Release(factory); + + hr = IWICImagingFactory2_QueryInterface(factory2, &IID_IWICImagingFactory, (void **)&factory); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(factory == (IWICImagingFactory *)component_factory, "Unexpected factory pointer.\n"); + + IWICComponentFactory_Release(component_factory); + IWICImagingFactory2_Release(factory2); + IWICImagingFactory_Release(factory); +} + START_TEST(info) { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); @@ -644,6 +676,7 @@ START_TEST(info) test_decoder_info(); test_reader_info(); test_pixelformat_info(); + test_imagingfactory_interfaces(); CoUninitialize(); } diff --git a/modules/rostests/winetests/windowscodecs/metadata.c b/modules/rostests/winetests/windowscodecs/metadata.c index 1d4203d5cf..91a5d20f37 100644 --- a/modules/rostests/winetests/windowscodecs/metadata.c +++ b/modules/rostests/winetests/windowscodecs/metadata.c @@ -23,6 +23,9 @@ #include <assert.h> #define COBJMACROS +#ifdef __REACTOS__ +#define CONST_VTABLE +#endif #include "windef.h" #include "objbase.h" @@ -816,7 +819,7 @@ static void test_metadata_IFD(void) hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count); compare_metadata(reader, td, count); @@ -832,7 +835,7 @@ static void test_metadata_IFD(void) load_stream((IUnknown *)reader, IFD_data_swapped, sizeof(IFD_data), persist_options); hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count); compare_metadata(reader, td, count); HeapFree(GetProcessHeap(), 0, IFD_data_swapped); @@ -1271,7 +1274,7 @@ static void test_metadata_gif(void) hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(gif_LSD)/sizeof(gif_LSD[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(gif_LSD), "unexpected count %u\n", count); compare_metadata(reader, gif_LSD, count); @@ -1320,7 +1323,7 @@ static void test_metadata_gif(void) hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(gif_IMD)/sizeof(gif_IMD[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(gif_IMD), "unexpected count %u\n", count); compare_metadata(reader, gif_IMD, count); @@ -1374,7 +1377,7 @@ static void test_metadata_gif(void) hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(animated_gif_LSD)/sizeof(animated_gif_LSD[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(animated_gif_LSD), "unexpected count %u\n", count); compare_metadata(reader, animated_gif_LSD, count); @@ -1393,7 +1396,7 @@ static void test_metadata_gif(void) hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(animated_gif_APE)/sizeof(animated_gif_APE[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(animated_gif_APE), "unexpected count %u\n", count); compare_metadata(reader, animated_gif_APE, count); @@ -1412,7 +1415,7 @@ static void test_metadata_gif(void) hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(animated_gif_comment_1)/sizeof(animated_gif_comment_1[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(animated_gif_comment_1), "unexpected count %u\n", count); compare_metadata(reader, animated_gif_comment_1, count); @@ -1431,7 +1434,7 @@ static void test_metadata_gif(void) hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(animated_gif_plain_1)/sizeof(animated_gif_plain_1[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(animated_gif_plain_1), "unexpected count %u\n", count); compare_metadata(reader, animated_gif_plain_1, count); @@ -1480,7 +1483,7 @@ static void test_metadata_gif(void) hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(animated_gif_IMD)/sizeof(animated_gif_IMD[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(animated_gif_IMD), "unexpected count %u\n", count); compare_metadata(reader, animated_gif_IMD, count); @@ -1499,7 +1502,7 @@ static void test_metadata_gif(void) hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(animated_gif_comment_2)/sizeof(animated_gif_comment_2[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(animated_gif_comment_2), "unexpected count %u\n", count); if (count == 1) compare_metadata(reader, animated_gif_comment_2, count); @@ -1519,7 +1522,7 @@ static void test_metadata_gif(void) hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(animated_gif_plain_2)/sizeof(animated_gif_plain_2[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(animated_gif_plain_2), "unexpected count %u\n", count); compare_metadata(reader, animated_gif_plain_2, count); @@ -1538,7 +1541,7 @@ static void test_metadata_gif(void) hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(animated_gif_GCE)/sizeof(animated_gif_GCE[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(animated_gif_GCE), "unexpected count %u\n", count); compare_metadata(reader, animated_gif_GCE, count); @@ -1599,13 +1602,17 @@ static void test_metadata_gif(void) ok(len == 2, "expected 2, got %u\n", len); ok(!lstrcmpW(name, rootW), "expected '/', got %s\n", wine_dbgstr_w(name)); - for (i = 0; i < sizeof(decoder_data)/sizeof(decoder_data[0]); i++) + for (i = 0; i < ARRAY_SIZE(decoder_data); i++) { WCHAR queryW[256]; if (winetest_debug > 1) trace("query: %s\n", decoder_data[i].query); MultiByteToWideChar(CP_ACP, 0, decoder_data[i].query, -1, queryW, 256); + + hr = IWICMetadataQueryReader_GetMetadataByName(queryreader, queryW, NULL); + ok(hr == decoder_data[i].hr, "GetMetadataByName(%s) returned %#x, expected %#x\n", wine_dbgstr_w(queryW), hr, decoder_data[i].hr); + PropVariantInit(&value); hr = IWICMetadataQueryReader_GetMetadataByName(queryreader, queryW, &value); ok(hr == decoder_data[i].hr, "GetMetadataByName(%s) returned %#x, expected %#x\n", wine_dbgstr_w(queryW), hr, decoder_data[i].hr); @@ -1622,7 +1629,7 @@ static void test_metadata_gif(void) ok(len == lstrlenW(queryW) + 1, "expected %u, got %u\n", lstrlenW(queryW) + 1, len); ok(!lstrcmpW(name, queryW), "expected %s, got %s\n", wine_dbgstr_w(queryW), wine_dbgstr_w(name)); - for (j = 0; j < sizeof(decoder_data)/sizeof(decoder_data[0]); j++) + for (j = 0; j < ARRAY_SIZE(decoder_data); j++) { MultiByteToWideChar(CP_ACP, 0, decoder_data[j].query, -1, queryW, 256); @@ -1698,7 +1705,7 @@ static void test_metadata_gif(void) ok(len == 2, "expected 2, got %u\n", len); ok(!lstrcmpW(name, rootW), "expected '/', got %s\n", wine_dbgstr_w(name)); - for (i = 0; i < sizeof(frame_data)/sizeof(frame_data[0]); i++) + for (i = 0; i < ARRAY_SIZE(frame_data); i++) { if (winetest_debug > 1) trace("query: %s\n", frame_data[i].query); @@ -1812,7 +1819,7 @@ static void test_metadata_LSD(void) { hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count); compare_metadata(reader, td, count); @@ -1890,7 +1897,7 @@ static void test_metadata_IMD(void) { hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count); compare_metadata(reader, td, count); @@ -1965,7 +1972,7 @@ static void test_metadata_GCE(void) { hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count); compare_metadata(reader, td, count); @@ -2038,7 +2045,7 @@ static void test_metadata_APE(void) { hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count); compare_metadata(reader, td, count); @@ -2122,7 +2129,7 @@ static void test_metadata_GIF_comment(void) { hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#x\n", hr); - ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count); + ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count); compare_metadata(reader, td, count); @@ -2425,9 +2432,9 @@ static void test_WICMapSchemaToName(void) return; } - for (i = 0; i < sizeof(guid_list)/sizeof(guid_list[0]); i++) + for (i = 0; i < ARRAY_SIZE(guid_list); i++) { - for (j = 0; j < sizeof(schema_list)/sizeof(schema_list[0]); j++) + for (j = 0; j < ARRAY_SIZE(schema_list); j++) { hr = WICMapSchemaToName(guid_list[i], schema_list[j], 0, NULL, &len); if (IsEqualGUID(guid_list[i], &GUID_MetadataFormatXMP) || @@ -2685,7 +2692,7 @@ static HRESULT WINAPI mdr_GetEnumerator(IWICMetadataReader *iface, IWICEnumMetad return E_NOTIMPL; } -static /* const */ IWICMetadataReaderVtbl mdr_vtbl = +static const IWICMetadataReaderVtbl mdr_vtbl = { mdr_QueryInterface, mdr_AddRef, @@ -2775,7 +2782,7 @@ static HRESULT WINAPI mdbr_GetEnumerator(IWICMetadataBlockReader *iface, IEnumUn return E_NOTIMPL; } -static /* const */ IWICMetadataBlockReaderVtbl mdbr_vtbl = +static const IWICMetadataBlockReaderVtbl mdbr_vtbl = { mdbr_QueryInterface, mdbr_AddRef, @@ -2959,7 +2966,7 @@ static void test_queryreader(void) hr = IWICComponentFactory_CreateQueryReaderFromBlockReader(factory, &mdbr, &reader); ok(hr == S_OK, "CreateQueryReaderFromBlockReader error %#x\n", hr); - for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++) + for (i = 0; i < ARRAY_SIZE(test_data); i++) { current_metadata = test_data[i].data; diff --git a/modules/rostests/winetests/windowscodecs/palette.c b/modules/rostests/winetests/windowscodecs/palette.c index 33fd119f65..5bb25fa427 100644 --- a/modules/rostests/winetests/windowscodecs/palette.c +++ b/modules/rostests/winetests/windowscodecs/palette.c @@ -462,7 +462,7 @@ static void test_predefined_palette(void) ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr); IWICPalette_Release(palette); - for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) + for (i = 0; i < ARRAY_SIZE(td); i++) { hr = IWICImagingFactory_CreatePalette(factory, &palette); ok(hr == S_OK, "%u: CreatePalette error %#x\n", i, hr); diff --git a/modules/rostests/winetests/windowscodecs/pngformat.c b/modules/rostests/winetests/windowscodecs/pngformat.c index 3a0ea28ead..8c33d3b964 100644 --- a/modules/rostests/winetests/windowscodecs/pngformat.c +++ b/modules/rostests/winetests/windowscodecs/pngformat.c @@ -306,6 +306,8 @@ static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitma refcount = IStream_Release(stream); ok(refcount > 0, "expected stream refcount > 0\n"); } + else + IStream_Release(stream); return hr; } @@ -539,6 +541,15 @@ static const char png_PLTE_tRNS[] = { 0x00,0x00,0x00,0x00,'I','E','N','D',0xae,0x42,0x60,0x82 }; +/* grayscale 16 bpp 1x1 pixel PNG image with tRNS chunk */ +static const char png_gray_tRNS[] = { + 0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a, + 0x00,0x00,0x00,0x0d,'I','H','D','R',0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x10,0x00,0x00,0x00,0x00,0x6a,0xee,0x47,0x16, + 0x00,0x00,0x00,0x02,'t','R','N','S',0x00,0x00,0x76,0x93,0xcd,0x38, + 0x00,0x00,0x00,0x0b,'I','D','A','T',0x78,0x9c,0x63,0x60,0x60,0x00,0x00,0x00,0x03,0x00,0x01,0xb8,0xad,0x3a,0x63, + 0x00,0x00,0x00,0x00,'I','E','N','D',0xae,0x42,0x60,0x82 +}; + static void test_png_palette(void) { HRESULT hr; @@ -548,6 +559,7 @@ static void test_png_palette(void) GUID format; UINT count, ret; WICColor color[256]; + char *buf; hr = create_decoder(png_PLTE_tRNS, sizeof(png_PLTE_tRNS), &decoder); ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr); @@ -579,6 +591,64 @@ static void test_png_palette(void) IWICPalette_Release(palette); IWICBitmapFrameDecode_Release(frame); IWICBitmapDecoder_Release(decoder); + + hr = create_decoder(png_gray_tRNS, sizeof(png_gray_tRNS), &decoder); + ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr); + if (hr != S_OK) return; + + hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); + ok(hr == S_OK, "GetFrame error %#x\n", hr); + + hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); + ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_WICPixelFormat64bppRGBA), + "got wrong format %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 == WINCODEC_ERR_PALETTEUNAVAILABLE, "CopyPalette error %#x\n", hr); + + IWICPalette_Release(palette); + IWICBitmapFrameDecode_Release(frame); + IWICBitmapDecoder_Release(decoder); + + /* test 8 bpp grayscale PNG image with tRNS chunk */ + buf = HeapAlloc(GetProcessHeap(), 0, sizeof(png_gray_tRNS)); + memcpy(buf, png_gray_tRNS, sizeof(png_gray_tRNS)); + buf[24] = 8; /* override bit depth */ + + hr = create_decoder(buf, sizeof(png_gray_tRNS), &decoder); + ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr); + if (hr != S_OK) return; + + hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); + ok(hr == S_OK, "GetFrame error %#x\n", hr); + + hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); + ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_WICPixelFormat8bppIndexed), + "got wrong format %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] == 0x00000000, "expected 0x00000000, got %#x\n", color[0]); + ok(color[1] == 0xff010101, "expected 0xff010101, got %#x\n", color[1]); + + HeapFree(GetProcessHeap(), 0, buf); + IWICPalette_Release(palette); + IWICBitmapFrameDecode_Release(frame); + IWICBitmapDecoder_Release(decoder); } /* RGB 24 bpp 1x1 pixel PNG image */ @@ -624,23 +694,29 @@ static const char png_1x1_data[] = { 0x00,0x00,0x00,0x00,'I','E','N','D',0xae,0x42,0x60,0x82 }; +#define PNG_COLOR_TYPE_GRAY 0 +#define PNG_COLOR_TYPE_RGB 2 +#define PNG_COLOR_TYPE_PALETTE 3 +#define PNG_COLOR_TYPE_GRAY_ALPHA 4 +#define PNG_COLOR_TYPE_RGB_ALPHA 6 + static BOOL is_valid_png_type_depth(int color_type, int bit_depth, BOOL plte) { switch (color_type) { - case 0: /* Grayscale */ + case PNG_COLOR_TYPE_GRAY: return bit_depth == 1 || bit_depth == 2 || bit_depth == 4 || bit_depth == 8 || bit_depth == 16; - case 2: /* True Color */ + case PNG_COLOR_TYPE_RGB: return bit_depth == 8 || bit_depth == 16; - case 3: /* Indexed Color */ + case PNG_COLOR_TYPE_PALETTE: return (bit_depth == 1 || bit_depth == 2 || bit_depth == 4 || bit_depth == 8) && plte; - case 4: /* Grayscale with alpha */ + case PNG_COLOR_TYPE_GRAY_ALPHA: return bit_depth == 8 || bit_depth == 16; - case 6: /* True Color with alpha */ + case PNG_COLOR_TYPE_RGB_ALPHA: return bit_depth == 8 || bit_depth == 16; default: @@ -662,33 +738,44 @@ static void test_color_formats(void) } td[] = { /* 2 - PNG_COLOR_TYPE_RGB */ - { 1, 2, NULL, NULL, NULL }, - { 2, 2, NULL, NULL, NULL }, - { 4, 2, NULL, NULL, NULL }, - { 8, 2, &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat24bppBGR }, + { 1, PNG_COLOR_TYPE_RGB, NULL, NULL, NULL }, + { 2, PNG_COLOR_TYPE_RGB, NULL, NULL, NULL }, + { 4, PNG_COLOR_TYPE_RGB, NULL, NULL, NULL }, + { 8, PNG_COLOR_TYPE_RGB, + &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat24bppBGR }, /* libpng refuses to load our test image complaining about extra compressed data, * but libpng is still able to load the image with other combination of type/depth * making RGB 16 bpp case special for some reason. Therefore todo = TRUE. */ - { 16, 2, &GUID_WICPixelFormat48bppRGB, &GUID_WICPixelFormat48bppRGB, &GUID_WICPixelFormat48bppRGB, TRUE, TRUE }, - { 24, 2, NULL, NULL, NULL }, - { 32, 2, NULL, NULL, NULL }, + { 16, PNG_COLOR_TYPE_RGB, + &GUID_WICPixelFormat48bppRGB, &GUID_WICPixelFormat48bppRGB, &GUID_WICPixelFormat48bppRGB, TRUE, TRUE }, + { 24, PNG_COLOR_TYPE_RGB, NULL, NULL, NULL }, + { 32, PNG_COLOR_TYPE_RGB, NULL, NULL, NULL }, /* 0 - PNG_COLOR_TYPE_GRAY */ - { 1, 0, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormat1bppIndexed }, - { 2, 0, &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppIndexed }, - { 4, 0, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppIndexed }, - { 8, 0, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppIndexed }, - { 16, 0, &GUID_WICPixelFormat16bppGray, &GUID_WICPixelFormat16bppGray, &GUID_WICPixelFormat64bppRGBA }, - { 24, 0, NULL, NULL, NULL }, - { 32, 0, NULL, NULL, NULL }, + { 1, PNG_COLOR_TYPE_GRAY, + &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormat1bppIndexed }, + { 2, PNG_COLOR_TYPE_GRAY, + &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppIndexed }, + { 4, PNG_COLOR_TYPE_GRAY, + &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppIndexed }, + { 8, PNG_COLOR_TYPE_GRAY, + &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppIndexed }, + { 16, PNG_COLOR_TYPE_GRAY, + &GUID_WICPixelFormat16bppGray, &GUID_WICPixelFormat16bppGray, &GUID_WICPixelFormat64bppRGBA }, + { 24, PNG_COLOR_TYPE_GRAY, NULL, NULL, NULL }, + { 32, PNG_COLOR_TYPE_GRAY, NULL, NULL, NULL }, /* 3 - PNG_COLOR_TYPE_PALETTE */ - { 1, 3, &GUID_WICPixelFormat1bppIndexed, &GUID_WICPixelFormat1bppIndexed, &GUID_WICPixelFormat1bppIndexed }, - { 2, 3, &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat2bppIndexed }, - { 4, 3, &GUID_WICPixelFormat4bppIndexed, &GUID_WICPixelFormat4bppIndexed, &GUID_WICPixelFormat4bppIndexed }, - { 8, 3, &GUID_WICPixelFormat8bppIndexed, &GUID_WICPixelFormat8bppIndexed, &GUID_WICPixelFormat8bppIndexed }, - { 16, 3, NULL, NULL, NULL }, - { 24, 3, NULL, NULL, NULL }, - { 32, 3, NULL, NULL, NULL }, + { 1, PNG_COLOR_TYPE_PALETTE, + &GUID_WICPixelFormat1bppIndexed, &GUID_WICPixelFormat1bppIndexed, &GUID_WICPixelFormat1bppIndexed }, + { 2, PNG_COLOR_TYPE_PALETTE, + &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat2bppIndexed }, + { 4, PNG_COLOR_TYPE_PALETTE, + &GUID_WICPixelFormat4bppIndexed, &GUID_WICPixelFormat4bppIndexed, &GUID_WICPixelFormat4bppIndexed }, + { 8, PNG_COLOR_TYPE_PALETTE, + &GUID_WICPixelFormat8bppIndexed, &GUID_WICPixelFormat8bppIndexed, &GUID_WICPixelFormat8bppIndexed }, + { 16, PNG_COLOR_TYPE_PALETTE, NULL, NULL, NULL }, + { 24, PNG_COLOR_TYPE_PALETTE, NULL, NULL, NULL }, + { 32, PNG_COLOR_TYPE_PALETTE, NULL, NULL, NULL }, }; char buf[sizeof(png_1x1_data)]; HRESULT hr; @@ -717,7 +804,7 @@ static void test_color_formats(void) * with tEXt id. */ - for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) + for (i = 0; i < ARRAY_SIZE(td); i++) { /* with the tRNS and PLTE chunks */ memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); @@ -829,6 +916,11 @@ todo_wine_if(td[i].todo) IWICBitmapDecoder_Release(decoder); } } +#undef PNG_COLOR_TYPE_GRAY +#undef PNG_COLOR_TYPE_RGB +#undef PNG_COLOR_TYPE_PALETTE +#undef PNG_COLOR_TYPE_GRAY_ALPHA +#undef PNG_COLOR_TYPE_RGB_ALPHA START_TEST(pngformat) { diff --git a/modules/rostests/winetests/windowscodecs/stream.c b/modules/rostests/winetests/windowscodecs/stream.c index 5f311b897b..3750c32f3c 100644 --- a/modules/rostests/winetests/windowscodecs/stream.c +++ b/modules/rostests/winetests/windowscodecs/stream.c @@ -21,6 +21,22 @@ #define COBJMACROS #include "wincodec.h" +#define CHECK_CUR_POS(a, b) _check_cur_pos((IStream *)a, b, FALSE, __LINE__) +#define CHECK_CUR_POS_TODO(a, b) _check_cur_pos((IStream *)a, b, TRUE, __LINE__) +static void _check_cur_pos(IStream *stream, ULONGLONG expected_pos, BOOL todo, unsigned int line) +{ + LARGE_INTEGER offset; + ULARGE_INTEGER pos; + HRESULT hr; + + offset.QuadPart = 0; + hr = IStream_Seek(stream, offset, STREAM_SEEK_CUR, &pos); + ok_(__FILE__, line)(hr == S_OK, "Failed to get current position, hr %#x.\n", hr); +todo_wine_if(todo) + ok_(__FILE__, line)(pos.QuadPart == expected_pos, "Unexpected stream position %s.\n", + wine_dbgstr_longlong(pos.QuadPart)); +} + static void test_StreamOnMemory(void) { IWICImagingFactory *pFactory; @@ -51,8 +67,6 @@ static void test_StreamOnMemory(void) memcpy(Memory, CmpMem, sizeof(CmpMem)); - CoInitialize(NULL); - hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void**)&pFactory); if(FAILED(hr)) { skip("CoCreateInstance returned with %#x, expected %#x\n", hr, S_OK); @@ -113,9 +127,7 @@ static void test_StreamOnMemory(void) hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_SET, &uNewPos); ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), "Seek returned with %#x, expected %#x\n", hr, HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW)); ok(uNewPos.u.HighPart == 0xdeadbeef && uNewPos.u.LowPart == 0xdeadbeef, "Seek cursor initialized to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0xdeadbeef, 0xdeadbeef); - hr = IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); + CHECK_CUR_POS(pStream, 0); LargeInt.QuadPart = sizeof(Memory) + 10; uNewPos.u.HighPart = 0xdeadbeef; @@ -123,9 +135,7 @@ static void test_StreamOnMemory(void) hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_SET, &uNewPos); ok(hr == E_INVALIDARG, "Seek returned with %#x, expected %#x\n", hr, E_INVALIDARG); ok(uNewPos.u.HighPart == 0xdeadbeef && uNewPos.u.LowPart == 0xdeadbeef, "Seek cursor initialized to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0xdeadbeef, 0xdeadbeef); - hr = IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); + CHECK_CUR_POS(pStream, 0); LargeInt.QuadPart = 1; uNewPos.u.HighPart = 0xdeadbeef; @@ -133,9 +143,7 @@ static void test_StreamOnMemory(void) hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_END, &uNewPos); ok(hr == E_INVALIDARG, "Seek returned with %#x, expected %#x\n", hr, E_INVALIDARG); ok(uNewPos.u.HighPart == 0xdeadbeef && uNewPos.u.LowPart == 0xdeadbeef, "Seek cursor initialized to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0xdeadbeef, 0xdeadbeef); - hr = IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); + CHECK_CUR_POS(pStream, 0); LargeInt.QuadPart = -1; hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_END, &uNewPos); @@ -150,12 +158,9 @@ static void test_StreamOnMemory(void) ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), "Seek returned with %#x, expected %#x\n", hr, HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW)); ok(uNewPos.u.HighPart == 0xdeadbeef && uNewPos.u.LowPart == 0xdeadbeef, "Seek cursor initialized to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0xdeadbeef, 0xdeadbeef); - hr = IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); /* remains unchanged */ + CHECK_CUR_POS(pStream, 0); IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL); - /* Read */ hr = IWICStream_Read(pStream, MemBuf, 12, &uBytesRead); ok(hr == S_OK, "Read returned with %#x, expected %#x\n", hr, S_OK); @@ -164,8 +169,7 @@ static void test_StreamOnMemory(void) ok(memcmp(MemBuf, CmpMem, 12) == 0, "Read returned invalid data!\n"); /* check whether the seek pointer has moved correctly */ - IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == uBytesRead, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, uBytesRead); + CHECK_CUR_POS(pStream, uBytesRead); } IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL); @@ -234,8 +238,7 @@ static void test_StreamOnMemory(void) ok(memcmp(MemBuf, Memory, 3) == 0, "Wrote returned invalid data!\n"); /* make sure we're writing directly */ /* check whether the seek pointer has moved correctly */ - IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == uBytesWritten, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, uBytesWritten); + CHECK_CUR_POS(pStream, uBytesWritten); } IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL); @@ -262,22 +265,19 @@ static void test_StreamOnMemory(void) hr = IWICStream_Write(pStream, NULL, 3, &uBytesWritten); ok(hr == E_INVALIDARG, "Write returned with %#x, expected %#x\n", hr, E_INVALIDARG); ok(uBytesWritten == 0xdeadbeef, "Expected uBytesWritten to be unchanged, got %u\n", uBytesWritten); - IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); + CHECK_CUR_POS(pStream, 0); uBytesWritten = 0xdeadbeef; hr = IWICStream_Write(pStream, NULL, 0, &uBytesWritten); ok(hr == E_INVALIDARG, "Write returned with %#x, expected %#x\n", hr, E_INVALIDARG); ok(uBytesWritten == 0xdeadbeef, "Expected uBytesWritten to be unchanged, got %u\n", uBytesWritten); - IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); + CHECK_CUR_POS(pStream, 0); uBytesWritten = 0xdeadbeef; hr = IWICStream_Write(pStream, CmpMem, sizeof(Memory) + 10, &uBytesWritten); ok(hr == STG_E_MEDIUMFULL, "Write returned with %#x, expected %#x\n", hr, STG_E_MEDIUMFULL); ok(uBytesWritten == 0xdeadbeef, "Expected uBytesWritten to be unchanged, got %u\n", uBytesWritten); - IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); + CHECK_CUR_POS(pStream, 0); IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL); @@ -380,7 +380,6 @@ static void test_StreamOnMemory(void) IWICStream_Release(pStream); IWICImagingFactory_Release(pFactory); - CoUninitialize(); } static void test_StreamOnStreamRange(void) @@ -441,13 +440,16 @@ static void test_StreamOnStreamRange(void) } /* Seek */ + CHECK_CUR_POS(pStream, 0); hr = IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_END, &uNewPos); ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 20, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 20); ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK); + CHECK_CUR_POS(pStream, 0); hr = IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_SET, &uNewPos); ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK); ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); + CHECK_CUR_POS(pStream, 0); hr = IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_SET, NULL); ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK); @@ -459,9 +461,7 @@ static void test_StreamOnStreamRange(void) hr = IWICStream_Seek(pSubStream, LargeInt, STREAM_SEEK_SET, &uNewPos); ok(hr == WINCODEC_ERR_VALUEOUTOFRANGE, "Seek returned with %#x, expected %#x\n", hr, WINCODEC_ERR_VALUEOUTOFRANGE); ok(uNewPos.u.HighPart == 0xdeadbeef && uNewPos.u.LowPart == 0xdeadbeef, "Seek cursor initialized to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0xdeadbeef, 0xdeadbeef); - hr = IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); + CHECK_CUR_POS(pStream, 0); LargeInt.QuadPart = 30; uNewPos.u.HighPart = 0xdeadbeef; @@ -469,9 +469,7 @@ static void test_StreamOnStreamRange(void) hr = IWICStream_Seek(pSubStream, LargeInt, STREAM_SEEK_SET, &uNewPos); ok(hr == WINCODEC_ERR_VALUEOUTOFRANGE, "Seek returned with %#x, expected %#x\n", hr, WINCODEC_ERR_VALUEOUTOFRANGE); ok(uNewPos.u.HighPart == 0xdeadbeef && uNewPos.u.LowPart == 0xdeadbeef, "Seek cursor initialized to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0xdeadbeef, 0xdeadbeef); - hr = IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); + CHECK_CUR_POS(pStream, 0); LargeInt.QuadPart = 1; uNewPos.u.HighPart = 0xdeadbeef; @@ -479,14 +477,13 @@ static void test_StreamOnStreamRange(void) hr = IWICStream_Seek(pSubStream, LargeInt, STREAM_SEEK_END, &uNewPos); ok(hr == WINCODEC_ERR_VALUEOUTOFRANGE, "Seek returned with %#x, expected %#x\n", hr, WINCODEC_ERR_VALUEOUTOFRANGE); ok(uNewPos.u.HighPart == 0xdeadbeef && uNewPos.u.LowPart == 0xdeadbeef, "Seek cursor initialized to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0xdeadbeef, 0xdeadbeef); - hr = IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); + CHECK_CUR_POS(pStream, 0); LargeInt.QuadPart = -1; hr = IWICStream_Seek(pSubStream, LargeInt, STREAM_SEEK_END, &uNewPos); ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK); ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 19, "bSeek cursor moved to position (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart); + CHECK_CUR_POS(pStream, 0); IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_SET, &uNewPos); /* reset seek pointer */ LargeInt.QuadPart = -25; @@ -496,9 +493,7 @@ static void test_StreamOnStreamRange(void) ok(hr == WINCODEC_ERR_VALUEOUTOFRANGE, "Seek returned with %#x, expected %#x\n", hr, HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW)); ok(uNewPos.u.HighPart == 0xdeadbeef && uNewPos.u.LowPart == 0xdeadbeef, "Seek cursor initialized to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0xdeadbeef, 0xdeadbeef); - hr = IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(hr == S_OK, "Seek returned with %#x, expected %#x\n", hr, S_OK); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); /* remains unchanged */ + CHECK_CUR_POS(pStream, 0); IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_SET, NULL); @@ -510,8 +505,8 @@ static void test_StreamOnStreamRange(void) ok(memcmp(MemBuf, CmpMem+20, 12) == 0, "Read returned invalid data!\n"); /* check whether the seek pointer has moved correctly */ - IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == uBytesRead, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, uBytesRead); + CHECK_CUR_POS(pSubStream, uBytesRead); + CHECK_CUR_POS(pStream, 0); } IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_SET, NULL); @@ -522,6 +517,7 @@ static void test_StreamOnStreamRange(void) ok(uBytesRead == 10, "Read %u bytes, expected %u\n", uBytesRead, 10); ok(memcmp(Memory, CmpMem+20, uBytesRead) == 0, "Read returned invalid data!\n"); } + CHECK_CUR_POS(pStream, 0); IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_SET, NULL); @@ -531,6 +527,7 @@ static void test_StreamOnStreamRange(void) ok(uBytesRead == 20, "Read %u bytes\n", uBytesRead); ok(memcmp(Memory, CmpMem+20, uBytesRead) == 0, "Read returned invalid data!\n"); } + CHECK_CUR_POS(pStream, 0); IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_SET, NULL); uBytesRead = 0xdeadbeef; @@ -574,8 +571,8 @@ static void test_StreamOnStreamRange(void) ok(memcmp(MemBuf, Memory+20, 3) == 0, "Wrote returned invalid data!\n"); /* make sure we're writing directly */ /* check whether the seek pointer has moved correctly */ - IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == uBytesWritten, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, uBytesWritten); + CHECK_CUR_POS(pSubStream, uBytesWritten); + CHECK_CUR_POS(pStream, 0); } IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_SET, NULL); @@ -586,21 +583,21 @@ static void test_StreamOnStreamRange(void) hr = IWICStream_Write(pSubStream, NULL, 3, &uBytesWritten); ok(hr == E_INVALIDARG, "Write returned with %#x, expected %#x\n", hr, E_INVALIDARG); ok(uBytesWritten == 0xdeadbeef, "Expected uBytesWritten to be unchanged, got %u\n", uBytesWritten); - IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); + CHECK_CUR_POS(pSubStream, 0); + CHECK_CUR_POS(pStream, 0); uBytesWritten = 0xdeadbeef; hr = IWICStream_Write(pSubStream, NULL, 0, &uBytesWritten); ok(hr == E_INVALIDARG, "Write returned with %#x, expected %#x\n", hr, E_INVALIDARG); ok(uBytesWritten == 0xdeadbeef, "Expected uBytesWritten to be unchanged, got %u\n", uBytesWritten); - IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); + CHECK_CUR_POS(pSubStream, 0); + CHECK_CUR_POS(pStream, 0); hr = IWICStream_Write(pSubStream, CmpMem, 30, &uBytesWritten); ok(hr == S_OK, "Write returned with %#x, expected %#x\n", hr, STG_E_MEDIUMFULL); ok(uBytesWritten == 20, "Wrote %u bytes, expected %u\n", uBytesWritten, 0); - IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == uBytesWritten, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, uBytesWritten); + CHECK_CUR_POS(pSubStream, uBytesWritten); + CHECK_CUR_POS(pStream, 0); IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_SET, NULL); @@ -727,9 +724,8 @@ static void test_StreamOnStreamRange(void) hr = IWICStream_Write(pSubStream, CmpMem, 32, &uBytesWritten); ok(hr == STG_E_MEDIUMFULL, "Write returned with %#x, expected %#x\n", hr, STG_E_MEDIUMFULL); ok(uBytesWritten == 0xdeadbeef, "Expected uBytesWritten to be unchanged, got %u\n", uBytesWritten); - IWICStream_Seek(pSubStream, LargeNull, STREAM_SEEK_CUR, &uNewPos); - ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "Seek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); - + CHECK_CUR_POS(pSubStream, 0); + CHECK_CUR_POS(pStream, 0); IWICStream_Release(pSubStream); IWICStream_Release(pStream); @@ -737,8 +733,288 @@ static void test_StreamOnStreamRange(void) CoUninitialize(); } +static void test_StreamOnIStream(void) +{ + static const BYTE data[] = + { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + }; + static const LARGE_INTEGER zero_pos; + static const ULARGE_INTEGER uzero; + IWICStream *stream, *substream; + IWICImagingFactory *factory; + BYTE memory[64], buff[64]; + ULONG read_len, written; + ULARGE_INTEGER newpos; + IStream *copy_stream; + LARGE_INTEGER pos; + unsigned int i; + STATSTG stats; + HRESULT hr; + + memcpy(memory, data, sizeof(data)); + + hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, + &IID_IWICImagingFactory, (void **)&factory); + ok(hr == S_OK, "Failed to create a factory, hr %#x.\n", hr); + + hr = IWICImagingFactory_CreateStream(factory, &stream); + ok(hr == S_OK, "Failed to create a stream, hr %#x.\n", hr); + + hr = IWICStream_InitializeFromMemory(stream, memory, sizeof(memory)); + ok(hr == S_OK, "Failed to initialize stream, hr %#x.", hr); + + hr = IWICImagingFactory_CreateStream(factory, &substream); + ok(hr == S_OK, "Failed to create a stream, hr %#x.\n", hr); + + pos.QuadPart = 1; + hr = IWICStream_Seek(stream, pos, STREAM_SEEK_SET, &newpos); + ok(hr == S_OK, "Failed to set position, hr %#x.\n", hr); + CHECK_CUR_POS(stream, 1); + + hr = IWICStream_InitializeFromIStream(substream, (IStream *)stream); + ok(hr == S_OK, "Failed to initialize stream, hr %#x.\n", hr); + CHECK_CUR_POS(substream, 1); + + /* Seek */ + CHECK_CUR_POS(stream, 1); + hr = IWICStream_Seek(substream, zero_pos, STREAM_SEEK_END, &newpos); + ok(hr == S_OK, "Failed to seek a stream, hr %#x.\n", hr); + ok(newpos.QuadPart == sizeof(memory), "Unexpected position %s.\n", wine_dbgstr_longlong(newpos.QuadPart)); + CHECK_CUR_POS(substream, sizeof(memory)); + CHECK_CUR_POS(stream, sizeof(memory)); + + hr = IWICStream_Seek(substream, zero_pos, STREAM_SEEK_SET, &newpos); + ok(hr == S_OK, "Failed to seek a stream, hr %#x.\n", hr); + ok(newpos.QuadPart == 0, "Unexpected position %s.\n", wine_dbgstr_longlong(newpos.QuadPart)); + CHECK_CUR_POS(stream, 0); + CHECK_CUR_POS(substream, 0); + + hr = IWICStream_Seek(substream, zero_pos, STREAM_SEEK_SET, NULL); + ok(hr == S_OK, "Failed to seek a stream, hr %#x.\n", hr); + + pos.u.HighPart = 1; + pos.u.LowPart = 0; + newpos.u.HighPart = 0xdeadbeef; + newpos.u.LowPart = 0xdeadbeef; + hr = IWICStream_Seek(substream, pos, STREAM_SEEK_SET, &newpos); + ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), "Unexpected hr %#x.\n", hr); + ok(newpos.u.HighPart == 0xdeadbeef && newpos.u.LowPart == 0xdeadbeef, "Unexpected position %s.\n", + wine_dbgstr_longlong(newpos.QuadPart)); + CHECK_CUR_POS(stream, 0); + CHECK_CUR_POS(substream, 0); + + pos.QuadPart = sizeof(memory) + 1; + newpos.u.HighPart = 0xdeadbeef; + newpos.u.LowPart = 0xdeadbeef; + hr = IWICStream_Seek(substream, pos, STREAM_SEEK_SET, &newpos); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + ok(newpos.u.HighPart == 0xdeadbeef && newpos.u.LowPart == 0xdeadbeef, "Unexpected position %s.\n", + wine_dbgstr_longlong(newpos.QuadPart)); + CHECK_CUR_POS(stream, 0); + CHECK_CUR_POS(substream, 0); + + pos.QuadPart = 1; + newpos.u.HighPart = 0xdeadbeef; + newpos.u.LowPart = 0xdeadbeef; + hr = IWICStream_Seek(substream, pos, STREAM_SEEK_END, &newpos); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + ok(newpos.u.HighPart == 0xdeadbeef && newpos.u.LowPart == 0xdeadbeef, "Unexpected position %s.\n", + wine_dbgstr_longlong(newpos.QuadPart)); + CHECK_CUR_POS(stream, 0); + CHECK_CUR_POS(substream, 0); + + pos.QuadPart = -1; + hr = IWICStream_Seek(substream, pos, STREAM_SEEK_END, &newpos); + ok(hr == S_OK, "Failed to seek a stream, hr %#x.\n", hr); + ok(newpos.QuadPart == sizeof(memory) - 1, "Unexpected position %s.\n", wine_dbgstr_longlong(newpos.QuadPart)); + CHECK_CUR_POS(stream, sizeof(memory) - 1); + CHECK_CUR_POS(substream, sizeof(memory) - 1); + + IWICStream_Seek(substream, zero_pos, STREAM_SEEK_SET, NULL); + + /* Read */ + hr = IWICStream_Read(substream, buff, 12, &read_len); + ok(hr == S_OK, "Failed to read from stream, hr %#x.\n", hr); + ok(read_len == 12, "Unexpected read length %u.\n", read_len); + ok(!memcmp(buff, data, 12), "Unexpected data.\n"); + CHECK_CUR_POS(substream, read_len); + CHECK_CUR_POS(stream, read_len); + + IWICStream_Seek(substream, zero_pos, STREAM_SEEK_SET, NULL); + CHECK_CUR_POS(stream, 0); + + hr = IWICStream_Read(substream, memory, 10, &read_len); /* source = dest */ + ok(hr == S_OK, "Failed to read from stream, hr %#x.\n", hr); + ok(read_len == 10, "Unexpected read length %u.\n", read_len); + ok(!memcmp(memory, data, read_len), "Unexpected data.\n"); + CHECK_CUR_POS(stream, 10); + + IWICStream_Seek(substream, zero_pos, STREAM_SEEK_SET, NULL); + hr = IWICStream_Read(substream, memory, 2 * sizeof(data), &read_len); /* request too many bytes */ + ok(hr == S_OK, "Failed to read from stream, hr %#x.\n", hr); + ok(read_len == 64, "Unexpected read length %u.\n", read_len); + ok(!memcmp(memory, data, read_len), "Unexpected data.\n"); + CHECK_CUR_POS(stream, sizeof(data)); + + IWICStream_Seek(substream, zero_pos, STREAM_SEEK_SET, NULL); + read_len = 0xdeadbeef; + hr = IWICStream_Read(substream, NULL, 1, &read_len); /* destination buffer = NULL */ + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + ok(read_len == 0xdeadbeef, "Unexpected read length %u.\n", read_len); + + read_len = 1; + hr = IWICStream_Read(substream, buff, 0, &read_len); /* read 0 bytes */ + ok(hr == S_OK, "Failed to read from stream, hr %#x.\n", hr); + ok(read_len == 0, "Unexpected read length %u.\n", read_len); + + read_len = 0xdeadbeef; + hr = IWICStream_Read(substream, NULL, 0, &read_len); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + ok(read_len == 0xdeadbeef, "Unexpected read length %u.\n", read_len); + + hr = IWICStream_Read(substream, NULL, 0, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICStream_Read(substream, buff, 1, NULL); + ok(hr == S_OK, "Failed to read from stream, hr %#x.\n", hr); + CHECK_CUR_POS(substream, 1); + CHECK_CUR_POS(stream, 1); + IWICStream_Seek(substream, zero_pos, STREAM_SEEK_SET, NULL); + + /* Write */ + for (i = 0; i < 3; ++i) + buff[i] = data[i] + 1; + + hr = IWICStream_Write(substream, buff, 3, &written); + ok(hr == S_OK, "Failed to write to stream, hr %#x.\n", hr); + ok(written == 3, "Unexpected written length %u.\n", written); + ok(!memcmp(buff, memory, 3), "Unexpected stream data.\n"); + CHECK_CUR_POS(substream, written); + CHECK_CUR_POS(stream, written); + IWICStream_Seek(substream, zero_pos, STREAM_SEEK_SET, NULL); + + hr = IWICStream_Write(substream, buff, 0, &written); + ok(hr == S_OK, "Failed to write to stream, hr %#x.\n", hr); + + written = 0xdeadbeef; + hr = IWICStream_Write(substream, NULL, 3, &written); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + ok(written == 0xdeadbeef, "Unexpected written length %u.\n", written); + CHECK_CUR_POS(substream, 0); + CHECK_CUR_POS(stream, 0); + + written = 0xdeadbeef; + hr = IWICStream_Write(substream, NULL, 0, &written); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + ok(written == 0xdeadbeef, "Unexpected written length %u.\n", written); + CHECK_CUR_POS(substream, 0); + CHECK_CUR_POS(stream, 0); + + /* SetSize */ + newpos.u.HighPart = 0; + newpos.u.LowPart = sizeof(memory) + 10; + hr = IWICStream_SetSize(substream, newpos); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + newpos.u.HighPart = 0; + newpos.u.LowPart = sizeof(memory); + hr = IWICStream_SetSize(substream, newpos); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + newpos.u.HighPart = 0; + newpos.u.LowPart = sizeof(memory) - 10; + hr = IWICStream_SetSize(substream, newpos); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + newpos.QuadPart = 0; + hr = IWICStream_SetSize(substream, newpos); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + newpos.QuadPart = -10; + hr = IWICStream_SetSize(substream, newpos); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + /* CopyTo */ + newpos.u.HighPart = 0; + newpos.u.LowPart = 30; + hr = IWICStream_CopyTo(substream, NULL, newpos, NULL, NULL); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + hr = CreateStreamOnHGlobal(NULL, TRUE, ©_stream); + ok(hr == S_OK, "Failed to create a stream, hr %#x.\n", hr); + + hr = IWICStream_CopyTo(substream, copy_stream, newpos, NULL, NULL); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + IStream_Release(copy_stream); + + /* Commit */ + hr = IWICStream_Commit(substream, STGC_DEFAULT); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + hr = IWICStream_Commit(substream, STGC_OVERWRITE); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + hr = IWICStream_Commit(substream, STGC_ONLYIFCURRENT); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + hr = IWICStream_Commit(substream, STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + hr = IWICStream_Commit(substream, STGC_CONSOLIDATE); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + /* Revert */ + IWICStream_Write(substream, buff + 5, 6, NULL); + hr = IWICStream_Revert(substream); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + memcpy(memory, data, sizeof(memory)); + + /* LockRegion/UnlockRegion */ + hr = IWICStream_LockRegion(substream, uzero, uzero, 0); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + hr = IWICStream_UnlockRegion(substream, uzero, uzero, 0); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + /* Stat */ + hr = IWICStream_Stat(substream, NULL, 0); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICStream_Stat(substream, &stats, 0); + ok(hr == S_OK, "Failed to get stream stats, hr %#x.\n", hr); + ok(stats.pwcsName == NULL, "Unexpected name %p.\n", stats.pwcsName); + ok(stats.type == STGTY_STREAM, "Unexpected type %d.\n", stats.type); + ok(stats.cbSize.QuadPart == sizeof(data), "Unexpected size %s.\n", wine_dbgstr_longlong(stats.cbSize.QuadPart)); + ok(stats.mtime.dwHighDateTime == 0 && stats.mtime.dwLowDateTime == 0, "Unexpected mtime (%u;%u).\n", + stats.mtime.dwHighDateTime, stats.mtime.dwLowDateTime); + ok(stats.ctime.dwHighDateTime == 0 && stats.ctime.dwLowDateTime == 0, "Unexpected ctime (%u;%u).\n", + stats.ctime.dwHighDateTime, stats.ctime.dwLowDateTime); + ok(stats.atime.dwHighDateTime == 0 && stats.atime.dwLowDateTime == 0, "Unexpected atime (%u;%u).\n", + stats.atime.dwHighDateTime, stats.atime.dwLowDateTime); + ok(stats.grfMode == 0, "Unexpected mode %d.\n", stats.grfMode); + ok(stats.grfLocksSupported == 0, "Unexpected locks support %#x.\n", stats.grfLocksSupported); + ok(stats.grfStateBits == 0, "Unexpected state bits %#x.\n", stats.grfStateBits); + + /* Clone */ + hr = IWICStream_Clone(substream, ©_stream); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + + IWICStream_Release(substream); + IWICStream_Release(stream); + IWICImagingFactory_Release(factory); +} + START_TEST(stream) { + CoInitialize(NULL); + test_StreamOnMemory(); test_StreamOnStreamRange(); + test_StreamOnIStream(); + + CoUninitialize(); } diff --git a/modules/rostests/winetests/windowscodecs/tiffformat.c b/modules/rostests/winetests/windowscodecs/tiffformat.c index 5671dfbfbc..289e061145 100644 --- a/modules/rostests/winetests/windowscodecs/tiffformat.c +++ b/modules/rostests/winetests/windowscodecs/tiffformat.c @@ -26,6 +26,15 @@ #include "wincodec.h" #include "wine/test.h" +#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); +} + #define IFD_BYTE 1 #define IFD_ASCII 2 #define IFD_SHORT 3 @@ -253,6 +262,46 @@ static struct tiff_resolution_image_data { 72, 1 }, /* value will be filled with test data */ { 0x11, 0x22, 0x33, 0 } }; + +static const struct tiff_24bpp_data +{ + USHORT byte_order; + USHORT version; + ULONG dir_offset; + USHORT number_of_entries; + struct IFD_entry entry[13]; + ULONG next_IFD; + struct IFD_rational res; + BYTE pixel_data[3]; +} tiff_24bpp_data = +{ +#ifdef WORDS_BIGENDIAN + 'M' | 'M' << 8, +#else + 'I' | 'I' << 8, +#endif + 42, + FIELD_OFFSET(struct tiff_1bpp_data, number_of_entries), + 13, + { + { 0xff, IFD_SHORT, 1, 0 }, /* SUBFILETYPE */ + { 0x100, IFD_LONG, 1, 1 }, /* IMAGEWIDTH */ + { 0x101, IFD_LONG, 1, 1 }, /* IMAGELENGTH */ + { 0x102, IFD_SHORT, 1, 8 }, /* 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_24bpp_data, pixel_data) }, /* STRIPOFFSETS */ + { 0x115, IFD_SHORT, 1, 3 }, /* SAMPLESPERPIXEL */ + { 0x116, IFD_LONG, 1, 1 }, /* ROWSPERSTRIP */ + { 0x117, IFD_LONG, 1, 3 }, /* STRIPBYTECOUNT */ + { 0x11a, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_24bpp_data, res) }, /* XRESOLUTION */ + { 0x11b, IFD_RATIONAL, 1, FIELD_OFFSET(struct tiff_24bpp_data, res) }, /* YRESOLUTION */ + { 0x128, IFD_SHORT, 1, 2 }, /* RESOLUTIONUNIT */ + }, + 0, + { 900, 3 }, + { 0x11, 0x22, 0x33 } +}; #include "poppack.h" static IWICImagingFactory *factory; @@ -517,8 +566,11 @@ static void test_tiff_8bpp_alpha(void) ok(hr == S_OK, "GetFrameCount error %#x\n", hr); ok(frame_count == 1, "expected 1, got %u\n", frame_count); + EXPECT_REF(decoder, 1); hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); ok(hr == S_OK, "GetFrame error %#x\n", hr); + EXPECT_REF(decoder, 2); + IWICBitmapDecoder_Release(decoder); hr = IWICBitmapFrameDecode_GetSize(frame, &width, &height); ok(hr == S_OK, "GetSize error %#x\n", hr); @@ -553,7 +605,6 @@ static void test_tiff_8bpp_alpha(void) ok(data[i] == expected_data[i], "%u: expected %02x, got %02x\n", i, expected_data[i], data[i]); IWICBitmapFrameDecode_Release(frame); - IWICBitmapDecoder_Release(decoder); } static void generate_tiff_palette(void *buf, unsigned count) @@ -642,7 +693,7 @@ static void test_tiff_resolution(void) double dpi_x, dpi_y; int i; - for (i = 0; i < sizeof(tiff_resolution_test_data)/sizeof(tiff_resolution_test_data[0]); i++) + for (i = 0; i < ARRAY_SIZE(tiff_resolution_test_data); i++) { const struct tiff_resolution_test_data *test_data = &tiff_resolution_test_data[i]; tiff_resolution_image_data.resx = test_data->resx; @@ -686,6 +737,67 @@ static void test_tiff_resolution(void) } } +static void test_tiff_24bpp(void) +{ + HRESULT hr; + IWICBitmapDecoder *decoder; + IWICBitmapFrameDecode *frame; + UINT count, width, height, i, stride; + double dpi_x, dpi_y; + GUID format; + WICRect rc; + BYTE data[3]; + static const BYTE expected_data[] = { 0x33,0x22,0x11 }; + + hr = create_decoder(&tiff_24bpp_data, sizeof(tiff_24bpp_data), &decoder); + ok(hr == S_OK, "got %#x\n", hr); + ok(decoder != NULL, "Failed to load TIFF image data\n"); + + hr = IWICBitmapDecoder_GetFrameCount(decoder, &count); + ok(hr == S_OK, "GetFrameCount error %#x\n", hr); + ok(count == 1, "got %u\n", count); + + hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); + ok(hr == S_OK, "GetFrame error %#x\n", hr); + + hr = IWICBitmapFrameDecode_GetSize(frame, &width, &height); + ok(hr == S_OK, "GetSize error %#x\n", hr); + ok(width == 1, "got %u\n", width); + ok(height == 1, "got %u\n", height); + + hr = IWICBitmapFrameDecode_GetResolution(frame, &dpi_x, &dpi_y); + ok(hr == S_OK, "GetResolution error %#x\n", hr); + ok(dpi_x == 300.0, "got %f\n", dpi_x); + ok(dpi_y == 300.0, "got %f\n", dpi_y); + + hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); + ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_WICPixelFormat24bppBGR), + "got wrong format %s\n", wine_dbgstr_guid(&format)); + + for (stride = 0; stride <= 32; stride++) + { + memset(data, 0, sizeof(data)); + rc.X = 0; + rc.Y = 0; + rc.Width = 1; + rc.Height = 1; + hr = IWICBitmapFrameDecode_CopyPixels(frame, &rc, stride, sizeof(data), data); + if (stride < 3) + ok(hr == E_INVALIDARG, "CopyPixels(%u) should fail: %#x\n", stride, hr); + else + { + ok(hr == S_OK, "CopyPixels(%u) error %#x\n", stride, hr); + + for (i = 0; i < sizeof(data); i++) + ok(data[i] == expected_data[i], "%u: expected %02x, got %02x\n", i, expected_data[i], data[i]); + } + } + + IWICBitmapFrameDecode_Release(frame); + IWICBitmapDecoder_Release(decoder); +} + #include "pshpack2.h" static const struct tiff_1x1_data { @@ -1083,6 +1195,7 @@ START_TEST(tiffformat) test_QueryCapability(); test_tiff_8bpp_alpha(); test_tiff_resolution(); + test_tiff_24bpp(); IWICImagingFactory_Release(factory); CoUninitialize();
5 years, 10 months
1
0
0
0
[reactos] 01/01: [WINDOWSCODECS] Sync with Wine Staging 4.0. CORE-15682
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e98ef4992e0e6de35e022…
commit e98ef4992e0e6de35e0221aeb2a2570fd367e4a7 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Feb 4 13:12:26 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Feb 4 13:12:26 2019 +0100 [WINDOWSCODECS] Sync with Wine Staging 4.0. CORE-15682 --- dll/win32/windowscodecs/bitmap.c | 6 +- dll/win32/windowscodecs/bmpdecode.c | 2 +- dll/win32/windowscodecs/bmpencode.c | 16 +- dll/win32/windowscodecs/clipper.c | 4 +- dll/win32/windowscodecs/clsfactory.c | 3 +- dll/win32/windowscodecs/colortransform.c | 2 +- dll/win32/windowscodecs/converter.c | 2 +- dll/win32/windowscodecs/fliprotate.c | 2 +- dll/win32/windowscodecs/gifformat.c | 2 +- dll/win32/windowscodecs/icnsformat.c | 2 +- dll/win32/windowscodecs/icoformat.c | 36 ++- dll/win32/windowscodecs/imgfactory.c | 387 ++++++++++++++++++++++++---- dll/win32/windowscodecs/info.c | 10 +- dll/win32/windowscodecs/jpegformat.c | 20 +- dll/win32/windowscodecs/main.c | 4 +- dll/win32/windowscodecs/metadataquery.c | 12 +- dll/win32/windowscodecs/palette.c | 2 +- dll/win32/windowscodecs/pngformat.c | 26 +- dll/win32/windowscodecs/proxy.c | 17 +- dll/win32/windowscodecs/regsvr.c | 4 +- dll/win32/windowscodecs/scaler.c | 24 +- dll/win32/windowscodecs/stream.c | 130 ++++++---- dll/win32/windowscodecs/tgaformat.c | 2 +- dll/win32/windowscodecs/tiffformat.c | 25 +- dll/win32/windowscodecs/wincodecs_private.h | 10 +- dll/win32/windowscodecs/windowscodecs.spec | 6 +- media/doc/README.WINE | 2 +- 27 files changed, 574 insertions(+), 184 deletions(-) diff --git a/dll/win32/windowscodecs/bitmap.c b/dll/win32/windowscodecs/bitmap.c index 734c211c68..a44f5bd7b3 100644 --- a/dll/win32/windowscodecs/bitmap.c +++ b/dll/win32/windowscodecs/bitmap.c @@ -361,7 +361,7 @@ static HRESULT WINAPI BitmapImpl_CopyPixels(IWICBitmap *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { BitmapImpl *This = impl_from_IWICBitmap(iface); - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); return copy_pixels(This->bpp, This->data, This->width, This->height, This->stride, prc, cbStride, cbBufferSize, pbBuffer); @@ -374,7 +374,7 @@ static HRESULT WINAPI BitmapImpl_Lock(IWICBitmap *iface, const WICRect *prcLock, BitmapLockImpl *result; WICRect rc; - TRACE("(%p,%p,%x,%p)\n", iface, prcLock, flags, ppILock); + TRACE("(%p,%s,%x,%p)\n", iface, debug_wic_rect(prcLock), flags, ppILock); if (!(flags & (WICBitmapLockRead|WICBitmapLockWrite)) || !ppILock) return E_INVALIDARG; @@ -568,7 +568,7 @@ static HRESULT WINAPI IMILBitmapImpl_GetPixelFormat(IMILBitmapSource *iface, *format = 0; - for (i = 0; i < sizeof(pixel_fmt_map)/sizeof(pixel_fmt_map[0]); i++) + for (i = 0; i < ARRAY_SIZE(pixel_fmt_map); i++) { if (IsEqualGUID(pixel_fmt_map[i].WIC_format, &This->pixelformat)) { diff --git a/dll/win32/windowscodecs/bmpdecode.c b/dll/win32/windowscodecs/bmpdecode.c index 1b8e4d1f37..f5a2589d68 100644 --- a/dll/win32/windowscodecs/bmpdecode.c +++ b/dll/win32/windowscodecs/bmpdecode.c @@ -321,7 +321,7 @@ static HRESULT WINAPI BmpFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, BmpDecoder *This = impl_from_IWICBitmapFrameDecode(iface); HRESULT hr=S_OK; UINT width, height; - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); EnterCriticalSection(&This->lock); if (!This->imagedata) diff --git a/dll/win32/windowscodecs/bmpencode.c b/dll/win32/windowscodecs/bmpencode.c index a81cc53223..3b77517a8d 100644 --- a/dll/win32/windowscodecs/bmpencode.c +++ b/dll/win32/windowscodecs/bmpencode.c @@ -189,6 +189,11 @@ static HRESULT WINAPI BmpFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface if (!This->initialized || This->bits) return WINCODEC_ERR_WRONGSTATE; + if (IsEqualGUID(pPixelFormat, &GUID_WICPixelFormatBlackWhite)) + *pPixelFormat = GUID_WICPixelFormat1bppIndexed; + else if (IsEqualGUID(pPixelFormat, &GUID_WICPixelFormat2bppIndexed)) + *pPixelFormat = GUID_WICPixelFormat4bppIndexed; + for (i=0; formats[i].guid; i++) { if (IsEqualGUID(formats[i].guid, pPixelFormat)) @@ -196,8 +201,6 @@ static HRESULT WINAPI BmpFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface } if (!formats[i].guid) i = 0; - else if (IsEqualGUID(pPixelFormat, &GUID_WICPixelFormatBlackWhite)) - i = 2; /* GUID_WICPixelFormat1bppIndexed */ This->format = &formats[i]; memcpy(pPixelFormat, This->format->guid, sizeof(GUID)); @@ -301,7 +304,7 @@ static HRESULT WINAPI BmpFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, { BmpFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface); HRESULT hr; - TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc); + TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc)); if (!This->initialized) return WINCODEC_ERR_WRONGSTATE; @@ -498,6 +501,11 @@ static HRESULT WINAPI BmpEncoder_Initialize(IWICBitmapEncoder *iface, static HRESULT WINAPI BmpEncoder_GetContainerFormat(IWICBitmapEncoder *iface, GUID *pguidContainerFormat) { + TRACE("(%p,%p)\n", iface, pguidContainerFormat); + + if (!pguidContainerFormat) + return E_INVALIDARG; + memcpy(pguidContainerFormat, &GUID_ContainerFormatBmp, sizeof(GUID)); return S_OK; } @@ -566,7 +574,7 @@ static HRESULT WINAPI BmpEncoder_CreateNewFrame(IWICBitmapEncoder *iface, if (ppIEncoderOptions) { - hr = CreatePropertyBag2(opts, sizeof(opts)/sizeof(opts[0]), ppIEncoderOptions); + hr = CreatePropertyBag2(opts, ARRAY_SIZE(opts), ppIEncoderOptions); if (FAILED(hr)) return hr; } diff --git a/dll/win32/windowscodecs/clipper.c b/dll/win32/windowscodecs/clipper.c index 94127f3df1..02e0d967f5 100644 --- a/dll/win32/windowscodecs/clipper.c +++ b/dll/win32/windowscodecs/clipper.c @@ -167,7 +167,7 @@ static HRESULT WINAPI BitmapClipper_CopyPixels(IWICBitmapClipper *iface, BitmapClipper *This = impl_from_IWICBitmapClipper(iface); WICRect rect; - TRACE("(%p,%p,%u,%u,%p)\n", iface, rc, stride, buffer_size, buffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(rc), stride, buffer_size, buffer); if (!This->source) return WINCODEC_ERR_WRONGSTATE; @@ -199,7 +199,7 @@ static HRESULT WINAPI BitmapClipper_Initialize(IWICBitmapClipper *iface, UINT width, height; HRESULT hr = S_OK; - TRACE("(%p,%p,%p)\n", iface, source, rc); + TRACE("(%p,%p,%s)\n", iface, source, debug_wic_rect(rc)); EnterCriticalSection(&This->lock); diff --git a/dll/win32/windowscodecs/clsfactory.c b/dll/win32/windowscodecs/clsfactory.c index 98938eb872..2de518a00c 100644 --- a/dll/win32/windowscodecs/clsfactory.c +++ b/dll/win32/windowscodecs/clsfactory.c @@ -43,7 +43,8 @@ typedef struct { } classinfo; static const classinfo wic_classes[] = { - {&CLSID_WICImagingFactory, ComponentFactory_CreateInstance}, + {&CLSID_WICImagingFactory, ImagingFactory_CreateInstance}, + {&CLSID_WICImagingFactory2, ImagingFactory_CreateInstance}, {&CLSID_WICBmpDecoder, BmpDecoder_CreateInstance}, {&CLSID_WICPngDecoder, PngDecoder_CreateInstance}, {&CLSID_WICPngEncoder, PngEncoder_CreateInstance}, diff --git a/dll/win32/windowscodecs/colortransform.c b/dll/win32/windowscodecs/colortransform.c index 5b1c7e8b70..af66c67443 100644 --- a/dll/win32/windowscodecs/colortransform.c +++ b/dll/win32/windowscodecs/colortransform.c @@ -133,7 +133,7 @@ static HRESULT WINAPI ColorTransform_CopyPixels(IWICColorTransform *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { ColorTransform *This = impl_from_IWICColorTransform(iface); - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); return IWICBitmapSource_CopyPixels(This->dst, prc, cbStride, cbBufferSize, pbBuffer); } diff --git a/dll/win32/windowscodecs/converter.c b/dll/win32/windowscodecs/converter.c index 0d3414a146..c3476c3efa 100644 --- a/dll/win32/windowscodecs/converter.c +++ b/dll/win32/windowscodecs/converter.c @@ -1583,7 +1583,7 @@ static HRESULT WINAPI FormatConverter_CopyPixels(IWICFormatConverter *iface, FormatConverter *This = impl_from_IWICFormatConverter(iface); WICRect rc; HRESULT hr; - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); if (This->source) { diff --git a/dll/win32/windowscodecs/fliprotate.c b/dll/win32/windowscodecs/fliprotate.c index 72d1e8a287..46402237ee 100644 --- a/dll/win32/windowscodecs/fliprotate.c +++ b/dll/win32/windowscodecs/fliprotate.c @@ -161,7 +161,7 @@ static HRESULT WINAPI FlipRotator_CopyPixels(IWICBitmapFlipRotator *iface, WICRect rc; WICRect rect; - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); if (!This->source) return WINCODEC_ERR_WRONGSTATE; diff --git a/dll/win32/windowscodecs/gifformat.c b/dll/win32/windowscodecs/gifformat.c index 78ac427d9a..d4d23ff6f3 100644 --- a/dll/win32/windowscodecs/gifformat.c +++ b/dll/win32/windowscodecs/gifformat.c @@ -801,7 +801,7 @@ static HRESULT WINAPI GifFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { GifFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface); - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); if (This->frame->ImageDesc.Interlace) { diff --git a/dll/win32/windowscodecs/icnsformat.c b/dll/win32/windowscodecs/icnsformat.c index aa9640417f..02e8ee97e6 100644 --- a/dll/win32/windowscodecs/icnsformat.c +++ b/dll/win32/windowscodecs/icnsformat.c @@ -390,7 +390,7 @@ static HRESULT WINAPI IcnsFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface); HRESULT hr; - TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc); + TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc)); if (!This->initialized) return WINCODEC_ERR_WRONGSTATE; diff --git a/dll/win32/windowscodecs/icoformat.c b/dll/win32/windowscodecs/icoformat.c index 5e38ee0d0f..d2a6196cd0 100644 --- a/dll/win32/windowscodecs/icoformat.c +++ b/dll/win32/windowscodecs/icoformat.c @@ -176,7 +176,7 @@ static HRESULT WINAPI IcoFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { IcoFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface); - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); return copy_pixels(32, This->bits, This->width, This->height, This->width * 4, prc, cbStride, cbBufferSize, pbBuffer); @@ -511,6 +511,9 @@ static HRESULT WINAPI IcoDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p LARGE_INTEGER seek; HRESULT hr; ULONG bytesread; + STATSTG statstg; + unsigned int i; + TRACE("(%p,%p,%x)\n", iface, pIStream, cacheOptions); EnterCriticalSection(&This->lock); @@ -527,14 +530,41 @@ static HRESULT WINAPI IcoDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p hr = IStream_Read(pIStream, &This->header, sizeof(ICONHEADER), &bytesread); if (FAILED(hr)) goto end; - if (bytesread != sizeof(ICONHEADER) || - This->header.idReserved != 0 || + + if (bytesread != sizeof(ICONHEADER)) + { + hr = WINCODEC_ERR_STREAMREAD; + goto end; + } + + if (This->header.idReserved != 0 || This->header.idType != 1) { hr = E_FAIL; goto end; } + hr = IStream_Stat(pIStream, &statstg, STATFLAG_NONAME); + if (FAILED(hr)) + { + WARN("Stat() failed, hr %#x.\n", hr); + goto end; + } + + for (i = 0; i < This->header.idCount; i++) + { + ICONDIRENTRY direntry; + + hr = IStream_Read(pIStream, &direntry, sizeof(direntry), &bytesread); + if (FAILED(hr)) goto end; + + if (bytesread != sizeof(direntry) || (direntry.dwDIBSize + direntry.dwDIBOffset > statstg.cbSize.QuadPart)) + { + hr = WINCODEC_ERR_BADIMAGE; + goto end; + } + } + This->initialized = TRUE; This->stream = pIStream; IStream_AddRef(pIStream); diff --git a/dll/win32/windowscodecs/imgfactory.c b/dll/win32/windowscodecs/imgfactory.c index 180e745f46..e127e40557 100644 --- a/dll/win32/windowscodecs/imgfactory.c +++ b/dll/win32/windowscodecs/imgfactory.c @@ -19,6 +19,7 @@ #include "config.h" +#include <assert.h> #include <stdarg.h> #define COBJMACROS @@ -36,19 +37,25 @@ WINE_DEFAULT_DEBUG_CHANNEL(wincodecs); typedef struct { + IWICImagingFactory2 IWICImagingFactory2_iface; IWICComponentFactory IWICComponentFactory_iface; LONG ref; -} ComponentFactory; +} ImagingFactory; -static inline ComponentFactory *impl_from_IWICComponentFactory(IWICComponentFactory *iface) +static inline ImagingFactory *impl_from_IWICComponentFactory(IWICComponentFactory *iface) { - return CONTAINING_RECORD(iface, ComponentFactory, IWICComponentFactory_iface); + return CONTAINING_RECORD(iface, ImagingFactory, IWICComponentFactory_iface); } -static HRESULT WINAPI ComponentFactory_QueryInterface(IWICComponentFactory *iface, REFIID iid, +static inline ImagingFactory *impl_from_IWICImagingFactory2(IWICImagingFactory2 *iface) +{ + return CONTAINING_RECORD(iface, ImagingFactory, IWICImagingFactory2_iface); +} + +static HRESULT WINAPI ImagingFactory_QueryInterface(IWICImagingFactory2 *iface, REFIID iid, void **ppv) { - ComponentFactory *This = impl_from_IWICComponentFactory(iface); + ImagingFactory *This = impl_from_IWICImagingFactory2(iface); TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv); if (!ppv) return E_INVALIDARG; @@ -59,6 +66,10 @@ static HRESULT WINAPI ComponentFactory_QueryInterface(IWICComponentFactory *ifac { *ppv = &This->IWICComponentFactory_iface; } + else if (IsEqualIID(&IID_IWICImagingFactory2, iid)) + { + *ppv = &This->IWICImagingFactory2_iface; + } else { *ppv = NULL; @@ -69,9 +80,9 @@ static HRESULT WINAPI ComponentFactory_QueryInterface(IWICComponentFactory *ifac return S_OK; } -static ULONG WINAPI ComponentFactory_AddRef(IWICComponentFactory *iface) +static ULONG WINAPI ImagingFactory_AddRef(IWICImagingFactory2 *iface) { - ComponentFactory *This = impl_from_IWICComponentFactory(iface); + ImagingFactory *This = impl_from_IWICImagingFactory2(iface); ULONG ref = InterlockedIncrement(&This->ref); TRACE("(%p) refcount=%u\n", iface, ref); @@ -79,9 +90,9 @@ static ULONG WINAPI ComponentFactory_AddRef(IWICComponentFactory *iface) return ref; } -static ULONG WINAPI ComponentFactory_Release(IWICComponentFactory *iface) +static ULONG WINAPI ImagingFactory_Release(IWICImagingFactory2 *iface) { - ComponentFactory *This = impl_from_IWICComponentFactory(iface); + ImagingFactory *This = impl_from_IWICImagingFactory2(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) refcount=%u\n", iface, ref); @@ -92,8 +103,8 @@ static ULONG WINAPI ComponentFactory_Release(IWICComponentFactory *iface) return ref; } -static HRESULT WINAPI ComponentFactory_CreateDecoderFromFilename( - IWICComponentFactory *iface, LPCWSTR wzFilename, const GUID *pguidVendor, +static HRESULT WINAPI ImagingFactory_CreateDecoderFromFilename( + IWICImagingFactory2 *iface, LPCWSTR wzFilename, const GUID *pguidVendor, DWORD dwDesiredAccess, WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder) { @@ -110,7 +121,7 @@ static HRESULT WINAPI ComponentFactory_CreateDecoderFromFilename( if (SUCCEEDED(hr)) { - hr = IWICComponentFactory_CreateDecoderFromStream(iface, (IStream*)stream, + hr = IWICImagingFactory2_CreateDecoderFromStream(iface, (IStream*)stream, pguidVendor, metadataOptions, ppIDecoder); } @@ -174,6 +185,7 @@ static HRESULT find_decoder(IStream *pIStream, const GUID *pguidVendor, IWICBitmapDecoder_Release(*decoder); IWICBitmapDecoderInfo_Release(decoderinfo); IUnknown_Release(unkdecoderinfo); + IEnumUnknown_Release(enumdecoders); *decoder = NULL; return res; } @@ -194,8 +206,8 @@ static HRESULT find_decoder(IStream *pIStream, const GUID *pguidVendor, return WINCODEC_ERR_COMPONENTNOTFOUND; } -static HRESULT WINAPI ComponentFactory_CreateDecoderFromStream( - IWICComponentFactory *iface, IStream *pIStream, const GUID *pguidVendor, +static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream( + IWICImagingFactory2 *iface, IStream *pIStream, const GUID *pguidVendor, WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder) { HRESULT res; @@ -236,8 +248,8 @@ static HRESULT WINAPI ComponentFactory_CreateDecoderFromStream( } } -static HRESULT WINAPI ComponentFactory_CreateDecoderFromFileHandle( - IWICComponentFactory *iface, ULONG_PTR hFile, const GUID *pguidVendor, +static HRESULT WINAPI ImagingFactory_CreateDecoderFromFileHandle( + IWICImagingFactory2 *iface, ULONG_PTR hFile, const GUID *pguidVendor, WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder) { IWICStream *stream; @@ -252,7 +264,7 @@ static HRESULT WINAPI ComponentFactory_CreateDecoderFromFileHandle( hr = stream_initialize_from_filehandle(stream, (HANDLE)hFile); if (SUCCEEDED(hr)) { - hr = IWICComponentFactory_CreateDecoderFromStream(iface, (IStream*)stream, + hr = IWICImagingFactory2_CreateDecoderFromStream(iface, (IStream*)stream, pguidVendor, metadataOptions, ppIDecoder); } IWICStream_Release(stream); @@ -260,14 +272,14 @@ static HRESULT WINAPI ComponentFactory_CreateDecoderFromFileHandle( return hr; } -static HRESULT WINAPI ComponentFactory_CreateComponentInfo(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateComponentInfo(IWICImagingFactory2 *iface, REFCLSID clsidComponent, IWICComponentInfo **ppIInfo) { TRACE("(%p,%s,%p)\n", iface, debugstr_guid(clsidComponent), ppIInfo); return CreateComponentInfo(clsidComponent, ppIInfo); } -static HRESULT WINAPI ComponentFactory_CreateDecoder(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateDecoder(IWICImagingFactory2 *iface, REFGUID guidContainerFormat, const GUID *pguidVendor, IWICBitmapDecoder **ppIDecoder) { @@ -350,7 +362,7 @@ static HRESULT WINAPI ComponentFactory_CreateDecoder(IWICComponentFactory *iface return WINCODEC_ERR_COMPONENTNOTFOUND; } -static HRESULT WINAPI ComponentFactory_CreateEncoder(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateEncoder(IWICImagingFactory2 *iface, REFGUID guidContainerFormat, const GUID *pguidVendor, IWICBitmapEncoder **ppIEncoder) { @@ -415,20 +427,20 @@ static HRESULT WINAPI ComponentFactory_CreateEncoder(IWICComponentFactory *iface } } -static HRESULT WINAPI ComponentFactory_CreatePalette(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreatePalette(IWICImagingFactory2 *iface, IWICPalette **ppIPalette) { TRACE("(%p,%p)\n", iface, ppIPalette); return PaletteImpl_Create(ppIPalette); } -static HRESULT WINAPI ComponentFactory_CreateFormatConverter(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateFormatConverter(IWICImagingFactory2 *iface, IWICFormatConverter **ppIFormatConverter) { return FormatConverter_CreateInstance(&IID_IWICFormatConverter, (void**)ppIFormatConverter); } -static HRESULT WINAPI ComponentFactory_CreateBitmapScaler(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateBitmapScaler(IWICImagingFactory2 *iface, IWICBitmapScaler **ppIBitmapScaler) { TRACE("(%p,%p)\n", iface, ppIBitmapScaler); @@ -436,42 +448,42 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapScaler(IWICComponentFactory * return BitmapScaler_Create(ppIBitmapScaler); } -static HRESULT WINAPI ComponentFactory_CreateBitmapClipper(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateBitmapClipper(IWICImagingFactory2 *iface, IWICBitmapClipper **ppIBitmapClipper) { TRACE("(%p,%p)\n", iface, ppIBitmapClipper); return BitmapClipper_Create(ppIBitmapClipper); } -static HRESULT WINAPI ComponentFactory_CreateBitmapFlipRotator(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateBitmapFlipRotator(IWICImagingFactory2 *iface, IWICBitmapFlipRotator **ppIBitmapFlipRotator) { TRACE("(%p,%p)\n", iface, ppIBitmapFlipRotator); return FlipRotator_Create(ppIBitmapFlipRotator); } -static HRESULT WINAPI ComponentFactory_CreateStream(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateStream(IWICImagingFactory2 *iface, IWICStream **ppIWICStream) { TRACE("(%p,%p)\n", iface, ppIWICStream); return StreamImpl_Create(ppIWICStream); } -static HRESULT WINAPI ComponentFactory_CreateColorContext(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateColorContext(IWICImagingFactory2 *iface, IWICColorContext **ppIColorContext) { TRACE("(%p,%p)\n", iface, ppIColorContext); return ColorContext_Create(ppIColorContext); } -static HRESULT WINAPI ComponentFactory_CreateColorTransformer(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateColorTransformer(IWICImagingFactory2 *iface, IWICColorTransform **ppIColorTransform) { TRACE("(%p,%p)\n", iface, ppIColorTransform); return ColorTransform_Create(ppIColorTransform); } -static HRESULT WINAPI ComponentFactory_CreateBitmap(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateBitmap(IWICImagingFactory2 *iface, UINT uiWidth, UINT uiHeight, REFWICPixelFormatGUID pixelFormat, WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap) { @@ -480,9 +492,8 @@ static HRESULT WINAPI ComponentFactory_CreateBitmap(IWICComponentFactory *iface, return BitmapImpl_Create(uiWidth, uiHeight, 0, 0, NULL, 0, pixelFormat, option, ppIBitmap); } -static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFactory *iface, - IWICBitmapSource *piBitmapSource, WICBitmapCreateCacheOption option, - IWICBitmap **ppIBitmap) +static HRESULT create_bitmap_from_source_rect(IWICBitmapSource *piBitmapSource, const WICRect *rect, + WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap) { IWICBitmap *result; IWICBitmapLock *lock; @@ -496,13 +507,29 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFacto IWICPixelFormatInfo2 *formatinfo; WICPixelFormatNumericRepresentation format_type; - TRACE("(%p,%p,%u,%p)\n", iface, piBitmapSource, option, ppIBitmap); + assert(!rect || option == WICBitmapCacheOnLoad); if (!piBitmapSource || !ppIBitmap) return E_INVALIDARG; + if (option == WICBitmapNoCache && SUCCEEDED(IWICBitmapSource_QueryInterface(piBitmapSource, + &IID_IWICBitmap, (void **)&result))) + { + *ppIBitmap = result; + return S_OK; + } + hr = IWICBitmapSource_GetSize(piBitmapSource, &width, &height); + if (SUCCEEDED(hr) && rect) + { + if (rect->X >= width || rect->Y >= height || rect->Width == 0 || rect->Height == 0) + return E_INVALIDARG; + + width = min(width - rect->X, rect->Width); + height = min(height - rect->Y, rect->Height); + } + if (SUCCEEDED(hr)) hr = IWICBitmapSource_GetPixelFormat(piBitmapSource, &pixelformat); @@ -533,7 +560,14 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFacto { UINT stride, buffersize; BYTE *buffer; - rc.X = rc.Y = 0; + + if (rect) + { + rc.X = rect->X; + rc.Y = rect->Y; + } + else + rc.X = rc.Y = 0; rc.Width = width; rc.Height = height; @@ -586,16 +620,33 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFacto return hr; } -static HRESULT WINAPI ComponentFactory_CreateBitmapFromSourceRect(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateBitmapFromSource(IWICImagingFactory2 *iface, + IWICBitmapSource *piBitmapSource, WICBitmapCreateCacheOption option, + IWICBitmap **ppIBitmap) +{ + TRACE("(%p,%p,%u,%p)\n", iface, piBitmapSource, option, ppIBitmap); + + return create_bitmap_from_source_rect(piBitmapSource, NULL, option, ppIBitmap); +} + +static HRESULT WINAPI ImagingFactory_CreateBitmapFromSourceRect(IWICImagingFactory2 *iface, IWICBitmapSource *piBitmapSource, UINT x, UINT y, UINT width, UINT height, IWICBitmap **ppIBitmap) { - FIXME("(%p,%p,%u,%u,%u,%u,%p): stub\n", iface, piBitmapSource, x, y, width, + WICRect rect; + + TRACE("(%p,%p,%u,%u,%u,%u,%p)\n", iface, piBitmapSource, x, y, width, height, ppIBitmap); - return E_NOTIMPL; + + rect.X = x; + rect.Y = y; + rect.Width = width; + rect.Height = height; + + return create_bitmap_from_source_rect(piBitmapSource, &rect, WICBitmapCacheOnLoad, ppIBitmap); } -static HRESULT WINAPI ComponentFactory_CreateBitmapFromMemory(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateBitmapFromMemory(IWICImagingFactory2 *iface, UINT width, UINT height, REFWICPixelFormatGUID format, UINT stride, UINT size, BYTE *buffer, IWICBitmap **bitmap) { @@ -671,7 +722,7 @@ static BOOL get_16bpp_format(HBITMAP hbm, WICPixelFormatGUID *format) return ret; } -static HRESULT WINAPI ComponentFactory_CreateBitmapFromHBITMAP(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateBitmapFromHBITMAP(IWICImagingFactory2 *iface, HBITMAP hbm, HPALETTE hpal, WICBitmapAlphaChannelOption option, IWICBitmap **bitmap) { BITMAP bm; @@ -794,7 +845,7 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromHBITMAP(IWICComponentFact return hr; } -static HRESULT WINAPI ComponentFactory_CreateBitmapFromHICON(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateBitmapFromHICON(IWICImagingFactory2 *iface, HICON hicon, IWICBitmap **bitmap) { IWICBitmapLock *lock; @@ -931,30 +982,30 @@ failed: return hr; } -static HRESULT WINAPI ComponentFactory_CreateComponentEnumerator(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateComponentEnumerator(IWICImagingFactory2 *iface, DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown) { TRACE("(%p,%u,%u,%p)\n", iface, componentTypes, options, ppIEnumUnknown); return CreateComponentEnumerator(componentTypes, options, ppIEnumUnknown); } -static HRESULT WINAPI ComponentFactory_CreateFastMetadataEncoderFromDecoder( - IWICComponentFactory *iface, IWICBitmapDecoder *pIDecoder, +static HRESULT WINAPI ImagingFactory_CreateFastMetadataEncoderFromDecoder( + IWICImagingFactory2 *iface, IWICBitmapDecoder *pIDecoder, IWICFastMetadataEncoder **ppIFastEncoder) { FIXME("(%p,%p,%p): stub\n", iface, pIDecoder, ppIFastEncoder); return E_NOTIMPL; } -static HRESULT WINAPI ComponentFactory_CreateFastMetadataEncoderFromFrameDecode( - IWICComponentFactory *iface, IWICBitmapFrameDecode *pIFrameDecoder, +static HRESULT WINAPI ImagingFactory_CreateFastMetadataEncoderFromFrameDecode( + IWICImagingFactory2 *iface, IWICBitmapFrameDecode *pIFrameDecoder, IWICFastMetadataEncoder **ppIFastEncoder) { FIXME("(%p,%p,%p): stub\n", iface, pIFrameDecoder, ppIFastEncoder); return E_NOTIMPL; } -static HRESULT WINAPI ComponentFactory_CreateQueryWriter(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateQueryWriter(IWICImagingFactory2 *iface, REFGUID guidMetadataFormat, const GUID *pguidVendor, IWICMetadataQueryWriter **ppIQueryWriter) { @@ -963,7 +1014,7 @@ static HRESULT WINAPI ComponentFactory_CreateQueryWriter(IWICComponentFactory *i return E_NOTIMPL; } -static HRESULT WINAPI ComponentFactory_CreateQueryWriterFromReader(IWICComponentFactory *iface, +static HRESULT WINAPI ImagingFactory_CreateQueryWriterFromReader(IWICImagingFactory2 *iface, IWICMetadataQueryReader *pIQueryReader, const GUID *pguidVendor, IWICMetadataQueryWriter **ppIQueryWriter) { @@ -972,6 +1023,237 @@ static HRESULT WINAPI ComponentFactory_CreateQueryWriterFromReader(IWICComponent return E_NOTIMPL; } +#ifndef __REACTOS__ +static HRESULT WINAPI ImagingFactory_CreateImageEncoder(IWICImagingFactory2 *iface, ID2D1Device *device, IWICImageEncoder **encoder) +{ + FIXME("%p,%p,%p stub.\n", iface, device, encoder); + return E_NOTIMPL; +} +#endif + +static const IWICImagingFactory2Vtbl ImagingFactory_Vtbl = { + ImagingFactory_QueryInterface, + ImagingFactory_AddRef, + ImagingFactory_Release, + ImagingFactory_CreateDecoderFromFilename, + ImagingFactory_CreateDecoderFromStream, + ImagingFactory_CreateDecoderFromFileHandle, + ImagingFactory_CreateComponentInfo, + ImagingFactory_CreateDecoder, + ImagingFactory_CreateEncoder, + ImagingFactory_CreatePalette, + ImagingFactory_CreateFormatConverter, + ImagingFactory_CreateBitmapScaler, + ImagingFactory_CreateBitmapClipper, + ImagingFactory_CreateBitmapFlipRotator, + ImagingFactory_CreateStream, + ImagingFactory_CreateColorContext, + ImagingFactory_CreateColorTransformer, + ImagingFactory_CreateBitmap, + ImagingFactory_CreateBitmapFromSource, + ImagingFactory_CreateBitmapFromSourceRect, + ImagingFactory_CreateBitmapFromMemory, + ImagingFactory_CreateBitmapFromHBITMAP, + ImagingFactory_CreateBitmapFromHICON, + ImagingFactory_CreateComponentEnumerator, + ImagingFactory_CreateFastMetadataEncoderFromDecoder, + ImagingFactory_CreateFastMetadataEncoderFromFrameDecode, + ImagingFactory_CreateQueryWriter, + ImagingFactory_CreateQueryWriterFromReader, +#ifndef __REACTOS__ + ImagingFactory_CreateImageEncoder, +#endif +}; + +static HRESULT WINAPI ComponentFactory_QueryInterface(IWICComponentFactory *iface, REFIID iid, void **ppv) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_QueryInterface(&This->IWICImagingFactory2_iface, iid, ppv); +} + +static ULONG WINAPI ComponentFactory_AddRef(IWICComponentFactory *iface) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_AddRef(&This->IWICImagingFactory2_iface); +} + +static ULONG WINAPI ComponentFactory_Release(IWICComponentFactory *iface) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_Release(&This->IWICImagingFactory2_iface); +} + +static HRESULT WINAPI ComponentFactory_CreateDecoderFromFilename(IWICComponentFactory *iface, LPCWSTR filename, + const GUID *vendor, DWORD desired_access, WICDecodeOptions options, IWICBitmapDecoder **decoder) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateDecoderFromFilename(&This->IWICImagingFactory2_iface, filename, vendor, + desired_access, options, decoder); +} + +static HRESULT WINAPI ComponentFactory_CreateDecoderFromStream(IWICComponentFactory *iface, IStream *stream, + const GUID *vendor, WICDecodeOptions options, IWICBitmapDecoder **decoder) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateDecoderFromStream(&This->IWICImagingFactory2_iface, stream, vendor, + options, decoder); +} + +static HRESULT WINAPI ComponentFactory_CreateDecoderFromFileHandle(IWICComponentFactory *iface, ULONG_PTR hFile, + const GUID *vendor, WICDecodeOptions options, IWICBitmapDecoder **decoder) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateDecoderFromFileHandle(&This->IWICImagingFactory2_iface, hFile, vendor, + options, decoder); +} + +static HRESULT WINAPI ComponentFactory_CreateComponentInfo(IWICComponentFactory *iface, REFCLSID component, + IWICComponentInfo **info) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateComponentInfo(&This->IWICImagingFactory2_iface, component, info); +} + +static HRESULT WINAPI ComponentFactory_CreateDecoder(IWICComponentFactory *iface, REFGUID format, const GUID *vendor, + IWICBitmapDecoder **decoder) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateDecoder(&This->IWICImagingFactory2_iface, format, vendor, decoder); +} + +static HRESULT WINAPI ComponentFactory_CreateEncoder(IWICComponentFactory *iface, REFGUID format, const GUID *vendor, + IWICBitmapEncoder **encoder) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateEncoder(&This->IWICImagingFactory2_iface, format, vendor, encoder); +} + +static HRESULT WINAPI ComponentFactory_CreatePalette(IWICComponentFactory *iface, IWICPalette **palette) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreatePalette(&This->IWICImagingFactory2_iface, palette); +} + +static HRESULT WINAPI ComponentFactory_CreateFormatConverter(IWICComponentFactory *iface, IWICFormatConverter **converter) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateFormatConverter(&This->IWICImagingFactory2_iface, converter); +} + +static HRESULT WINAPI ComponentFactory_CreateBitmapScaler(IWICComponentFactory *iface, IWICBitmapScaler **scaler) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateBitmapScaler(&This->IWICImagingFactory2_iface, scaler); +} + +static HRESULT WINAPI ComponentFactory_CreateBitmapClipper(IWICComponentFactory *iface, IWICBitmapClipper **clipper) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateBitmapClipper(&This->IWICImagingFactory2_iface, clipper); +} + +static HRESULT WINAPI ComponentFactory_CreateBitmapFlipRotator(IWICComponentFactory *iface, IWICBitmapFlipRotator **fliprotator) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateBitmapFlipRotator(&This->IWICImagingFactory2_iface, fliprotator); +} + +static HRESULT WINAPI ComponentFactory_CreateStream(IWICComponentFactory *iface, IWICStream **stream) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateStream(&This->IWICImagingFactory2_iface, stream); +} + +static HRESULT WINAPI ComponentFactory_CreateColorContext(IWICComponentFactory *iface, IWICColorContext **context) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateColorContext(&This->IWICImagingFactory2_iface, context); +} + +static HRESULT WINAPI ComponentFactory_CreateColorTransformer(IWICComponentFactory *iface, IWICColorTransform **transformer) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateColorTransformer(&This->IWICImagingFactory2_iface, transformer); +} + +static HRESULT WINAPI ComponentFactory_CreateBitmap(IWICComponentFactory *iface, UINT width, UINT height, REFWICPixelFormatGUID pixel_format, + WICBitmapCreateCacheOption option, IWICBitmap **bitmap) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateBitmap(&This->IWICImagingFactory2_iface, width, height, pixel_format, option, bitmap); +} + +static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFactory *iface, IWICBitmapSource *source, + WICBitmapCreateCacheOption option, IWICBitmap **bitmap) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateBitmapFromSource(&This->IWICImagingFactory2_iface, source, option, bitmap); +} + +static HRESULT WINAPI ComponentFactory_CreateBitmapFromSourceRect(IWICComponentFactory *iface, IWICBitmapSource *source, + UINT x, UINT y, UINT width, UINT height, IWICBitmap **bitmap) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateBitmapFromSourceRect(&This->IWICImagingFactory2_iface, source, x, y, width, height, bitmap); +} + +static HRESULT WINAPI ComponentFactory_CreateBitmapFromMemory(IWICComponentFactory *iface, UINT width, UINT height, + REFWICPixelFormatGUID format, UINT stride, UINT size, BYTE *buffer, IWICBitmap **bitmap) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateBitmapFromMemory(&This->IWICImagingFactory2_iface, width, height, format, stride, + size, buffer, bitmap); +} + +static HRESULT WINAPI ComponentFactory_CreateBitmapFromHBITMAP(IWICComponentFactory *iface, HBITMAP hbm, HPALETTE hpal, + WICBitmapAlphaChannelOption option, IWICBitmap **bitmap) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateBitmapFromHBITMAP(&This->IWICImagingFactory2_iface, hbm, hpal, option, bitmap); +} + +static HRESULT WINAPI ComponentFactory_CreateBitmapFromHICON(IWICComponentFactory *iface, HICON hicon, IWICBitmap **bitmap) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateBitmapFromHICON(&This->IWICImagingFactory2_iface, hicon, bitmap); +} + +static HRESULT WINAPI ComponentFactory_CreateComponentEnumerator(IWICComponentFactory *iface, DWORD component_types, + DWORD options, IEnumUnknown **enumerator) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateComponentEnumerator(&This->IWICImagingFactory2_iface, component_types, + options, enumerator); +} + +static HRESULT WINAPI ComponentFactory_CreateFastMetadataEncoderFromDecoder(IWICComponentFactory *iface, IWICBitmapDecoder *decoder, + IWICFastMetadataEncoder **encoder) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateFastMetadataEncoderFromDecoder(&This->IWICImagingFactory2_iface, decoder, encoder); +} + +static HRESULT WINAPI ComponentFactory_CreateFastMetadataEncoderFromFrameDecode(IWICComponentFactory *iface, + IWICBitmapFrameDecode *frame_decode, IWICFastMetadataEncoder **encoder) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateFastMetadataEncoderFromFrameDecode(&This->IWICImagingFactory2_iface, frame_decode, encoder); +} + +static HRESULT WINAPI ComponentFactory_CreateQueryWriter(IWICComponentFactory *iface, REFGUID format, const GUID *vendor, + IWICMetadataQueryWriter **writer) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateQueryWriter(&This->IWICImagingFactory2_iface, format, vendor, writer); +} + +static HRESULT WINAPI ComponentFactory_CreateQueryWriterFromReader(IWICComponentFactory *iface, IWICMetadataQueryReader *reader, + const GUID *vendor, IWICMetadataQueryWriter **writer) +{ + ImagingFactory *This = impl_from_IWICComponentFactory(iface); + return IWICImagingFactory2_CreateQueryWriterFromReader(&This->IWICImagingFactory2_iface, reader, vendor, writer); +} + static HRESULT WINAPI ComponentFactory_CreateMetadataReader(IWICComponentFactory *iface, REFGUID format, const GUID *vendor, DWORD options, IStream *stream, IWICMetadataReader **reader) { @@ -1185,23 +1467,24 @@ static const IWICComponentFactoryVtbl ComponentFactory_Vtbl = { ComponentFactory_CreateEncoderPropertyBag }; -HRESULT ComponentFactory_CreateInstance(REFIID iid, void** ppv) +HRESULT ImagingFactory_CreateInstance(REFIID iid, void** ppv) { - ComponentFactory *This; + ImagingFactory *This; HRESULT ret; TRACE("(%s,%p)\n", debugstr_guid(iid), ppv); *ppv = NULL; - This = HeapAlloc(GetProcessHeap(), 0, sizeof(ComponentFactory)); + This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); if (!This) return E_OUTOFMEMORY; + This->IWICImagingFactory2_iface.lpVtbl = &ImagingFactory_Vtbl; This->IWICComponentFactory_iface.lpVtbl = &ComponentFactory_Vtbl; This->ref = 1; - ret = IWICComponentFactory_QueryInterface(&This->IWICComponentFactory_iface, iid, ppv); - IWICComponentFactory_Release(&This->IWICComponentFactory_iface); + ret = IWICImagingFactory2_QueryInterface(&This->IWICImagingFactory2_iface, iid, ppv); + IWICImagingFactory2_Release(&This->IWICImagingFactory2_iface); return ret; } diff --git a/dll/win32/windowscodecs/info.c b/dll/win32/windowscodecs/info.c index 0a86266396..8c8157445f 100644 --- a/dll/win32/windowscodecs/info.c +++ b/dll/win32/windowscodecs/info.c @@ -222,7 +222,7 @@ typedef struct { static inline BitmapDecoderInfo *impl_from_IWICBitmapDecoderInfo(IWICBitmapDecoderInfo *iface) { - return CONTAINING_RECORD(iface, BitmapDecoderInfo, base.IWICComponentInfo_iface); + return CONTAINING_RECORD((IWICComponentInfo*)iface, BitmapDecoderInfo, base.IWICComponentInfo_iface); } static HRESULT WINAPI BitmapDecoderInfo_QueryInterface(IWICBitmapDecoderInfo *iface, REFIID iid, @@ -713,7 +713,7 @@ typedef struct { static inline BitmapEncoderInfo *impl_from_IWICBitmapEncoderInfo(IWICBitmapEncoderInfo *iface) { - return CONTAINING_RECORD(iface, BitmapEncoderInfo, base.IWICComponentInfo_iface); + return CONTAINING_RECORD((IWICComponentInfo*)iface, BitmapEncoderInfo, base.IWICComponentInfo_iface); } static HRESULT WINAPI BitmapEncoderInfo_QueryInterface(IWICBitmapEncoderInfo *iface, REFIID iid, @@ -1005,7 +1005,7 @@ typedef struct { static inline FormatConverterInfo *impl_from_IWICFormatConverterInfo(IWICFormatConverterInfo *iface) { - return CONTAINING_RECORD(iface, FormatConverterInfo, base.IWICComponentInfo_iface); + return CONTAINING_RECORD((IWICComponentInfo*)iface, FormatConverterInfo, base.IWICComponentInfo_iface); } static HRESULT WINAPI FormatConverterInfo_QueryInterface(IWICFormatConverterInfo *iface, REFIID iid, @@ -1219,7 +1219,7 @@ typedef struct { static inline PixelFormatInfo *impl_from_IWICPixelFormatInfo2(IWICPixelFormatInfo2 *iface) { - return CONTAINING_RECORD(iface, PixelFormatInfo, base.IWICComponentInfo_iface); + return CONTAINING_RECORD((IWICComponentInfo*)iface, PixelFormatInfo, base.IWICComponentInfo_iface); } static HRESULT WINAPI PixelFormatInfo_QueryInterface(IWICPixelFormatInfo2 *iface, REFIID iid, @@ -1531,7 +1531,7 @@ static struct metadata_container *get_metadata_container(MetadataReaderInfo *inf static inline MetadataReaderInfo *impl_from_IWICMetadataReaderInfo(IWICMetadataReaderInfo *iface) { - return CONTAINING_RECORD(iface, MetadataReaderInfo, base.IWICComponentInfo_iface); + return CONTAINING_RECORD((IWICComponentInfo*)iface, MetadataReaderInfo, base.IWICComponentInfo_iface); } static HRESULT WINAPI MetadataReaderInfo_QueryInterface(IWICMetadataReaderInfo *iface, diff --git a/dll/win32/windowscodecs/jpegformat.c b/dll/win32/windowscodecs/jpegformat.c index 26dc76c772..1df898f28c 100644 --- a/dll/win32/windowscodecs/jpegformat.c +++ b/dll/win32/windowscodecs/jpegformat.c @@ -467,7 +467,7 @@ static HRESULT WINAPI JpegDecoder_CopyPalette(IWICBitmapDecoder *iface, static HRESULT WINAPI JpegDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface, IWICMetadataQueryReader **reader) { - FIXME("(%p,%p): stub\n", iface, reader); + TRACE("(%p,%p)\n", iface, reader); if (!reader) return E_INVALIDARG; @@ -644,7 +644,7 @@ static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface, { JpegDecoder *This = impl_from_IWICBitmapFrameDecode(iface); - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); return copy_pixels(This->bpp, This->image_data, This->cinfo.output_width, This->cinfo.output_height, This->stride, @@ -1168,7 +1168,7 @@ static HRESULT WINAPI JpegEncoder_Frame_WriteSource(IWICBitmapFrameEncode *iface { JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface); HRESULT hr; - TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc); + TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc)); if (!This->frame_initialized) return WINCODEC_ERR_WRONGSTATE; @@ -1345,11 +1345,15 @@ static HRESULT WINAPI JpegEncoder_Initialize(IWICBitmapEncoder *iface, return S_OK; } -static HRESULT WINAPI JpegEncoder_GetContainerFormat(IWICBitmapEncoder *iface, - GUID *pguidContainerFormat) +static HRESULT WINAPI JpegEncoder_GetContainerFormat(IWICBitmapEncoder *iface, GUID *format) { - FIXME("(%p,%s): stub\n", iface, debugstr_guid(pguidContainerFormat)); - return E_NOTIMPL; + TRACE("(%p,%p)\n", iface, format); + + if (!format) + return E_INVALIDARG; + + memcpy(format, &GUID_ContainerFormatJpeg, sizeof(*format)); + return S_OK; } static HRESULT WINAPI JpegEncoder_GetEncoderInfo(IWICBitmapEncoder *iface, IWICBitmapEncoderInfo **info) @@ -1438,7 +1442,7 @@ static HRESULT WINAPI JpegEncoder_CreateNewFrame(IWICBitmapEncoder *iface, if (ppIEncoderOptions) { - hr = CreatePropertyBag2(opts, sizeof(opts)/sizeof(opts[0]), ppIEncoderOptions); + hr = CreatePropertyBag2(opts, ARRAY_SIZE(opts), ppIEncoderOptions); if (FAILED(hr)) { LeaveCriticalSection(&This->lock); diff --git a/dll/win32/windowscodecs/main.c b/dll/win32/windowscodecs/main.c index 6f781b812b..78281519b8 100644 --- a/dll/win32/windowscodecs/main.c +++ b/dll/win32/windowscodecs/main.c @@ -82,7 +82,7 @@ HRESULT copy_pixels(UINT bpp, const BYTE *srcbuffer, if (dststride < bytesperrow) return E_INVALIDARG; - if ((dststride * (rc->Height-1)) + ((rc->Width * bpp) + 7)/8 > dstbuffersize) + if ((dststride * (rc->Height-1)) + bytesperrow > dstbuffersize) return E_INVALIDARG; /* if the whole bitmap is copied and the buffer format matches then it's a matter of a single memcpy */ @@ -182,7 +182,7 @@ HRESULT write_source(IWICBitmapFrameEncode *iface, if (FAILED(hr)) { ERR("Failed to convert source, target format %s, %#x\n", debugstr_guid(format), hr); - return hr; + return E_NOTIMPL; } stride = (bpp * width + 7)/8; diff --git a/dll/win32/windowscodecs/metadataquery.c b/dll/win32/windowscodecs/metadataquery.c index e33884881b..c4c188d8c9 100644 --- a/dll/win32/windowscodecs/metadataquery.c +++ b/dll/win32/windowscodecs/metadataquery.c @@ -164,7 +164,7 @@ static VARTYPE map_type(struct string_t *str) { UINT i; - for (i = 0; i < sizeof(str2vt)/sizeof(str2vt[0]); i++) + for (i = 0; i < ARRAY_SIZE(str2vt); i++) { if (str2vt[i].len == str->len) { @@ -589,7 +589,7 @@ static HRESULT WINAPI mqr_GetMetadataByName(IWICMetadataQueryReader *iface, LPCW PropVariantClear(&tk_id); PropVariantClear(&tk_schema); - if (hr == S_OK) + if (hr == S_OK && value) *value = new_value; else PropVariantClear(&new_value); @@ -743,7 +743,7 @@ HRESULT WINAPI WICMapGuidToShortName(REFGUID guid, UINT len, WCHAR *name, UINT * if (!guid) return E_INVALIDARG; - for (i = 0; i < sizeof(guid2name)/sizeof(guid2name[0]); i++) + for (i = 0; i < ARRAY_SIZE(guid2name); i++) { if (IsEqualGUID(guid, guid2name[i].guid)) { @@ -774,7 +774,7 @@ HRESULT WINAPI WICMapShortNameToGuid(PCWSTR name, GUID *guid) if (!name || !guid) return E_INVALIDARG; - for (i = 0; i < sizeof(guid2name)/sizeof(guid2name[0]); i++) + for (i = 0; i < ARRAY_SIZE(guid2name); i++) { if (!lstrcmpiW(name, guid2name[i].name)) { @@ -884,7 +884,7 @@ static const WCHAR *map_shortname_to_schema(const GUID *format, const WCHAR *nam !IsEqualGUID(format, &GUID_MetadataFormatXMPStruct)) return NULL; - for (i = 0; i < sizeof(name2schema)/sizeof(name2schema[0]); i++) + for (i = 0; i < ARRAY_SIZE(name2schema); i++) { if (!lstrcmpW(name2schema[i].name, name)) return name2schema[i].schema; @@ -909,7 +909,7 @@ HRESULT WINAPI WICMapSchemaToName(REFGUID format, LPWSTR schema, UINT len, WCHAR !IsEqualGUID(format, &GUID_MetadataFormatXMPStruct)) return WINCODEC_ERR_PROPERTYNOTFOUND; - for (i = 0; i < sizeof(name2schema)/sizeof(name2schema[0]); i++) + for (i = 0; i < ARRAY_SIZE(name2schema); i++) { if (!lstrcmpW(name2schema[i].schema, schema)) { diff --git a/dll/win32/windowscodecs/palette.c b/dll/win32/windowscodecs/palette.c index a8370ff103..1c1e85834b 100644 --- a/dll/win32/windowscodecs/palette.c +++ b/dll/win32/windowscodecs/palette.c @@ -681,7 +681,7 @@ static HRESULT WINAPI PaletteImpl_InitializeFromBitmap(IWICPalette *palette, else rgb24_source = source; - hr = ComponentFactory_CreateInstance(&IID_IWICImagingFactory, (void **)&factory); + hr = ImagingFactory_CreateInstance(&IID_IWICImagingFactory, (void **)&factory); if (hr != S_OK) goto fail; hr = IWICImagingFactory_CreateBitmapFromSource(factory, rgb24_source, WICBitmapCacheOnLoad, &rgb24_bitmap); diff --git a/dll/win32/windowscodecs/pngformat.c b/dll/win32/windowscodecs/pngformat.c index 42c905cdac..7050c95121 100644 --- a/dll/win32/windowscodecs/pngformat.c +++ b/dll/win32/windowscodecs/pngformat.c @@ -844,7 +844,7 @@ static HRESULT WINAPI PngDecoder_CopyPalette(IWICBitmapDecoder *iface, static HRESULT WINAPI PngDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface, IWICMetadataQueryReader **reader) { - FIXME("(%p,%p): stub\n", iface, reader); + TRACE("(%p,%p)\n", iface, reader); if (!reader) return E_INVALIDARG; @@ -1061,7 +1061,7 @@ static HRESULT WINAPI PngDecoder_Frame_CopyPalette(IWICBitmapFrameDecode *iface, png_palette[i].blue); } } - else if (color_type == PNG_COLOR_TYPE_GRAY) { + else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth <= 8) { ret = ppng_get_tRNS(This->png_ptr, This->info_ptr, &trans_alpha, &num_trans, &trans_values); if (!ret) @@ -1098,7 +1098,7 @@ static HRESULT WINAPI PngDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { PngDecoder *This = impl_from_IWICBitmapFrameDecode(iface); - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); return copy_pixels(This->bpp, This->image_bits, This->width, This->height, This->stride, @@ -1244,7 +1244,7 @@ static HRESULT WINAPI PngDecoder_Block_GetReaderByIndex(IWICMetadataBlockReader This->metadata_blocks[nIndex].ofs, This->metadata_blocks[nIndex].len); if (SUCCEEDED(hr)) - hr = ComponentFactory_CreateInstance(&IID_IWICComponentFactory, (void**)&factory); + hr = ImagingFactory_CreateInstance(&IID_IWICComponentFactory, (void**)&factory); if (SUCCEEDED(hr)) { @@ -1445,7 +1445,7 @@ static HRESULT WINAPI PngFrameEncode_Initialize(IWICBitmapFrameEncode *iface, if (pIEncoderOptions) { - hr = IPropertyBag2_Read(pIEncoderOptions, sizeof(opts)/sizeof(opts[0]), opts, NULL, opt_values, opt_hres); + hr = IPropertyBag2_Read(pIEncoderOptions, ARRAY_SIZE(opts), opts, NULL, opt_values, opt_hres); if (FAILED(hr)) return hr; @@ -1749,7 +1749,7 @@ static HRESULT WINAPI PngFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, { PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface); HRESULT hr; - TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc); + TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc)); if (!This->frame_initialized) return WINCODEC_ERR_WRONGSTATE; @@ -1972,11 +1972,15 @@ static HRESULT WINAPI PngEncoder_Initialize(IWICBitmapEncoder *iface, return S_OK; } -static HRESULT WINAPI PngEncoder_GetContainerFormat(IWICBitmapEncoder *iface, - GUID *pguidContainerFormat) +static HRESULT WINAPI PngEncoder_GetContainerFormat(IWICBitmapEncoder *iface, GUID *format) { - FIXME("(%p,%s): stub\n", iface, debugstr_guid(pguidContainerFormat)); - return E_NOTIMPL; + TRACE("(%p,%p)\n", iface, format); + + if (!format) + return E_INVALIDARG; + + memcpy(format, &GUID_ContainerFormatPng, sizeof(*format)); + return S_OK; } static HRESULT WINAPI PngEncoder_GetEncoderInfo(IWICBitmapEncoder *iface, IWICBitmapEncoderInfo **info) @@ -2061,7 +2065,7 @@ static HRESULT WINAPI PngEncoder_CreateNewFrame(IWICBitmapEncoder *iface, if (ppIEncoderOptions) { - hr = CreatePropertyBag2(opts, sizeof(opts)/sizeof(opts[0]), ppIEncoderOptions); + hr = CreatePropertyBag2(opts, ARRAY_SIZE(opts), ppIEncoderOptions); if (FAILED(hr)) { LeaveCriticalSection(&This->lock); diff --git a/dll/win32/windowscodecs/proxy.c b/dll/win32/windowscodecs/proxy.c index a28b38681e..34b618e8d9 100644 --- a/dll/win32/windowscodecs/proxy.c +++ b/dll/win32/windowscodecs/proxy.c @@ -626,6 +626,21 @@ HRESULT WINAPI IWICStream_InitializeFromMemory_Proxy_W(IWICStream *iface, return IWICStream_InitializeFromMemory(iface, pbBuffer, cbBufferSize); } +HRESULT WINAPI IWICPixelFormatInfo_GetBitsPerPixel_Proxy_W(IWICPixelFormatInfo *iface, UINT *bpp) +{ + return IWICPixelFormatInfo_GetBitsPerPixel(iface, bpp); +} + +HRESULT WINAPI IWICPixelFormatInfo_GetChannelCount_Proxy_W(IWICPixelFormatInfo *iface, UINT *count) +{ + return IWICPixelFormatInfo_GetChannelCount(iface, count); +} + +HRESULT WINAPI IWICPixelFormatInfo_GetChannelMask_Proxy_W(IWICPixelFormatInfo *iface, UINT channel, UINT buffer_size, BYTE *buffer, UINT *actual) +{ + return IWICPixelFormatInfo_GetChannelMask(iface, channel, buffer_size, buffer, actual); +} + HRESULT WINAPI WICCreateColorContext_Proxy(IWICImagingFactory *iface, IWICColorContext **ppIWICColorContext) { TRACE("%p, %p\n", iface, ppIWICColorContext); @@ -637,7 +652,7 @@ HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT SDKVersion, IWICImagingFactory { TRACE("%x, %p\n", SDKVersion, ppIImagingFactory); - return ComponentFactory_CreateInstance(&IID_IWICImagingFactory, (void**)ppIImagingFactory); + return ImagingFactory_CreateInstance(&IID_IWICImagingFactory, (void**)ppIImagingFactory); } HRESULT WINAPI WICSetEncoderFormat_Proxy(IWICBitmapSource *pSourceIn, diff --git a/dll/win32/windowscodecs/regsvr.c b/dll/win32/windowscodecs/regsvr.c index 328ea54c84..158329dd84 100644 --- a/dll/win32/windowscodecs/regsvr.c +++ b/dll/win32/windowscodecs/regsvr.c @@ -1032,10 +1032,10 @@ static HRESULT register_pixelformats(struct regsvr_pixelformat const *list) if (res != ERROR_SUCCESS) goto error_close_clsid_key; if (list->channelmasks) { + static const WCHAR valuename_format[] = {'%','d',0}; HKEY masks_key; UINT i, mask_size; WCHAR mask_valuename[11]; - const WCHAR valuename_format[] = {'%','d',0}; mask_size = (list->bitsperpixel + 7)/8; @@ -1354,7 +1354,6 @@ static GUID const * const bmp_encode_formats[] = { &GUID_WICPixelFormat32bppBGR, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormat1bppIndexed, - &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat4bppIndexed, &GUID_WICPixelFormat8bppIndexed, NULL @@ -1383,7 +1382,6 @@ static GUID const * const tiff_encode_formats[] = { &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat1bppIndexed, - &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat4bppIndexed, &GUID_WICPixelFormat8bppIndexed, &GUID_WICPixelFormat24bppBGR, diff --git a/dll/win32/windowscodecs/scaler.c b/dll/win32/windowscodecs/scaler.c index 3801ea5ecd..d19e219fea 100644 --- a/dll/win32/windowscodecs/scaler.c +++ b/dll/win32/windowscodecs/scaler.c @@ -119,12 +119,12 @@ static HRESULT WINAPI BitmapScaler_GetSize(IWICBitmapScaler *iface, BitmapScaler *This = impl_from_IWICBitmapScaler(iface); TRACE("(%p,%p,%p)\n", iface, puiWidth, puiHeight); + if (!This->source) + return WINCODEC_ERR_NOTINITIALIZED; + if (!puiWidth || !puiHeight) return E_INVALIDARG; - if (!This->source) - return WINCODEC_ERR_WRONGSTATE; - *puiWidth = This->width; *puiHeight = This->height; @@ -141,7 +141,10 @@ static HRESULT WINAPI BitmapScaler_GetPixelFormat(IWICBitmapScaler *iface, return E_INVALIDARG; if (!This->source) - return WINCODEC_ERR_WRONGSTATE; + { + memcpy(pPixelFormat, &GUID_WICPixelFormatDontCare, sizeof(*pPixelFormat)); + return S_OK; + } return IWICBitmapSource_GetPixelFormat(This->source, pPixelFormat); } @@ -152,12 +155,12 @@ static HRESULT WINAPI BitmapScaler_GetResolution(IWICBitmapScaler *iface, BitmapScaler *This = impl_from_IWICBitmapScaler(iface); TRACE("(%p,%p,%p)\n", iface, pDpiX, pDpiY); + if (!This->source) + return WINCODEC_ERR_NOTINITIALIZED; + if (!pDpiX || !pDpiY) return E_INVALIDARG; - if (!This->source) - return WINCODEC_ERR_WRONGSTATE; - return IWICBitmapSource_GetResolution(This->source, pDpiX, pDpiY); } @@ -171,7 +174,7 @@ static HRESULT WINAPI BitmapScaler_CopyPalette(IWICBitmapScaler *iface, return E_INVALIDARG; if (!This->source) - return WINCODEC_ERR_WRONGSTATE; + return WINCODEC_ERR_PALETTEUNAVAILABLE; return IWICBitmapSource_CopyPalette(This->source, pIPalette); } @@ -215,7 +218,7 @@ static HRESULT WINAPI BitmapScaler_CopyPixels(IWICBitmapScaler *iface, ULONG buffer_size; UINT y; - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); EnterCriticalSection(&This->lock); @@ -320,6 +323,9 @@ static HRESULT WINAPI BitmapScaler_Initialize(IWICBitmapScaler *iface, TRACE("(%p,%p,%u,%u,%u)\n", iface, pISource, uiWidth, uiHeight, mode); + if (!pISource || !uiWidth || !uiHeight) + return E_INVALIDARG; + EnterCriticalSection(&This->lock); if (This->source) diff --git a/dll/win32/windowscodecs/stream.c b/dll/win32/windowscodecs/stream.c index 308ef8e02b..366d11b111 100644 --- a/dll/win32/windowscodecs/stream.c +++ b/dll/win32/windowscodecs/stream.c @@ -101,7 +101,8 @@ static HRESULT WINAPI StreamOnMemory_Read(IStream *iface, { StreamOnMemory *This = StreamOnMemory_from_IStream(iface); ULONG uBytesRead; - TRACE("(%p)\n", This); + + TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead); if (!pv) return E_INVALIDARG; @@ -121,7 +122,8 @@ static HRESULT WINAPI StreamOnMemory_Write(IStream *iface, { StreamOnMemory *This = StreamOnMemory_from_IStream(iface); HRESULT hr; - TRACE("(%p)\n", This); + + TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbWritten); if (!pv) return E_INVALIDARG; @@ -146,7 +148,8 @@ static HRESULT WINAPI StreamOnMemory_Seek(IStream *iface, StreamOnMemory *This = StreamOnMemory_from_IStream(iface); LARGE_INTEGER NewPosition; HRESULT hr=S_OK; - TRACE("(%p)\n", This); + + TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition); EnterCriticalSection(&This->lock); if (dwOrigin == STREAM_SEEK_SET) NewPosition.QuadPart = dlibMove.QuadPart; @@ -174,7 +177,7 @@ static HRESULT WINAPI StreamOnMemory_Seek(IStream *iface, static HRESULT WINAPI StreamOnMemory_SetSize(IStream *iface, ULARGE_INTEGER libNewSize) { - TRACE("(%p)\n", iface); + TRACE("(%p, %s)\n", iface, wine_dbgstr_longlong(libNewSize.QuadPart)); return E_NOTIMPL; } @@ -182,7 +185,7 @@ static HRESULT WINAPI StreamOnMemory_SetSize(IStream *iface, static HRESULT WINAPI StreamOnMemory_CopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten) { - TRACE("(%p)\n", iface); + TRACE("(%p, %p, %s, %p, %p)\n", iface, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten); return E_NOTIMPL; } @@ -190,7 +193,7 @@ static HRESULT WINAPI StreamOnMemory_CopyTo(IStream *iface, static HRESULT WINAPI StreamOnMemory_Commit(IStream *iface, DWORD grfCommitFlags) { - TRACE("(%p)\n", iface); + TRACE("(%p, %#x)\n", iface, grfCommitFlags); return E_NOTIMPL; } @@ -205,7 +208,8 @@ static HRESULT WINAPI StreamOnMemory_Revert(IStream *iface) static HRESULT WINAPI StreamOnMemory_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) { - TRACE("(%p)\n", iface); + TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart), + wine_dbgstr_longlong(cb.QuadPart), dwLockType); return E_NOTIMPL; } @@ -213,7 +217,8 @@ static HRESULT WINAPI StreamOnMemory_LockRegion(IStream *iface, static HRESULT WINAPI StreamOnMemory_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) { - TRACE("(%p)\n", iface); + TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart), + wine_dbgstr_longlong(cb.QuadPart), dwLockType); return E_NOTIMPL; } @@ -221,7 +226,7 @@ static HRESULT WINAPI StreamOnMemory_Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag) { StreamOnMemory *This = StreamOnMemory_from_IStream(iface); - TRACE("(%p)\n", This); + TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag); if (!pstatstg) return E_INVALIDARG; @@ -236,7 +241,7 @@ static HRESULT WINAPI StreamOnMemory_Stat(IStream *iface, static HRESULT WINAPI StreamOnMemory_Clone(IStream *iface, IStream **ppstm) { - TRACE("(%p)\n", iface); + TRACE("(%p, %p)\n", iface, ppstm); return E_NOTIMPL; } @@ -331,7 +336,7 @@ static HRESULT WINAPI StreamOnFileHandle_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead) { StreamOnFileHandle *This = StreamOnFileHandle_from_IStream(iface); - TRACE("(%p)\n", This); + TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead); return IWICStream_Read(This->stream, pv, cb, pcbRead); } @@ -339,7 +344,7 @@ static HRESULT WINAPI StreamOnFileHandle_Read(IStream *iface, static HRESULT WINAPI StreamOnFileHandle_Write(IStream *iface, void const *pv, ULONG cb, ULONG *pcbWritten) { - ERR("(%p)\n", iface); + ERR("(%p, %p, %u, %p)\n", iface, pv, cb, pcbWritten); return HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED); } @@ -347,7 +352,7 @@ static HRESULT WINAPI StreamOnFileHandle_Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) { StreamOnFileHandle *This = StreamOnFileHandle_from_IStream(iface); - TRACE("(%p)\n", This); + TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition); return IWICStream_Seek(This->stream, dlibMove, dwOrigin, plibNewPosition); } @@ -355,21 +360,21 @@ static HRESULT WINAPI StreamOnFileHandle_Seek(IStream *iface, static HRESULT WINAPI StreamOnFileHandle_SetSize(IStream *iface, ULARGE_INTEGER libNewSize) { - TRACE("(%p)\n", iface); + TRACE("(%p, %s)\n", iface, wine_dbgstr_longlong(libNewSize.QuadPart)); return E_NOTIMPL; } static HRESULT WINAPI StreamOnFileHandle_CopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten) { - TRACE("(%p)\n", iface); + TRACE("(%p, %p, %s, %p, %p)\n", iface, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten); return E_NOTIMPL; } static HRESULT WINAPI StreamOnFileHandle_Commit(IStream *iface, DWORD grfCommitFlags) { - TRACE("(%p)\n", iface); + TRACE("(%p, %#x)\n", iface, grfCommitFlags); return E_NOTIMPL; } @@ -382,14 +387,16 @@ static HRESULT WINAPI StreamOnFileHandle_Revert(IStream *iface) static HRESULT WINAPI StreamOnFileHandle_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) { - TRACE("(%p)\n", iface); + TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart), + wine_dbgstr_longlong(cb.QuadPart), dwLockType); return E_NOTIMPL; } static HRESULT WINAPI StreamOnFileHandle_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) { - TRACE("(%p)\n", iface); + TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart), + wine_dbgstr_longlong(cb.QuadPart), dwLockType); return E_NOTIMPL; } @@ -397,7 +404,7 @@ static HRESULT WINAPI StreamOnFileHandle_Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag) { StreamOnFileHandle *This = StreamOnFileHandle_from_IStream(iface); - TRACE("(%p)\n", This); + TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag); return IWICStream_Stat(This->stream, pstatstg, grfStatFlag); } @@ -405,11 +412,10 @@ static HRESULT WINAPI StreamOnFileHandle_Stat(IStream *iface, static HRESULT WINAPI StreamOnFileHandle_Clone(IStream *iface, IStream **ppstm) { - TRACE("(%p)\n", iface); + TRACE("(%p, %p)\n", iface, ppstm); return E_NOTIMPL; } - static const IStreamVtbl StreamOnFileHandle_Vtbl = { /*** IUnknown methods ***/ @@ -509,7 +515,8 @@ static HRESULT WINAPI StreamOnStreamRange_Read(IStream *iface, HRESULT hr; ULARGE_INTEGER OldPosition; LARGE_INTEGER SetPosition; - TRACE("(%p)\n", This); + + TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead); if (!pv) return E_INVALIDARG; @@ -552,7 +559,7 @@ static HRESULT WINAPI StreamOnStreamRange_Write(IStream *iface, ULARGE_INTEGER OldPosition; LARGE_INTEGER SetPosition; ULONG uBytesWritten=0; - TRACE("(%p)\n", This); + TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbWritten); if (!pv) return E_INVALIDARG; @@ -594,7 +601,7 @@ static HRESULT WINAPI StreamOnStreamRange_Seek(IStream *iface, ULARGE_INTEGER NewPosition, actual_size; HRESULT hr=S_OK; STATSTG statstg; - TRACE("(%p)\n", This); + TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition); EnterCriticalSection(&This->lock); actual_size = This->max_size; @@ -631,7 +638,7 @@ static HRESULT WINAPI StreamOnStreamRange_Seek(IStream *iface, static HRESULT WINAPI StreamOnStreamRange_SetSize(IStream *iface, ULARGE_INTEGER libNewSize) { - TRACE("(%p)\n", iface); + TRACE("(%p, %s)\n", iface, wine_dbgstr_longlong(libNewSize.QuadPart)); return E_NOTIMPL; } @@ -639,7 +646,8 @@ static HRESULT WINAPI StreamOnStreamRange_SetSize(IStream *iface, static HRESULT WINAPI StreamOnStreamRange_CopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten) { - TRACE("(%p)\n", iface); + TRACE("(%p, %p, %s, %p, %p)\n", iface, pstm, wine_dbgstr_longlong(cb.QuadPart), + pcbRead, pcbWritten); return E_NOTIMPL; } @@ -647,7 +655,7 @@ static HRESULT WINAPI StreamOnStreamRange_CopyTo(IStream *iface, static HRESULT WINAPI StreamOnStreamRange_Commit(IStream *iface, DWORD grfCommitFlags) { - TRACE("(%p)\n", iface); + TRACE("(%p, %#x)\n", iface, grfCommitFlags); return E_NOTIMPL; } @@ -662,7 +670,8 @@ static HRESULT WINAPI StreamOnStreamRange_Revert(IStream *iface) static HRESULT WINAPI StreamOnStreamRange_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) { - TRACE("(%p)\n", iface); + TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart), + wine_dbgstr_longlong(cb.QuadPart), dwLockType); return E_NOTIMPL; } @@ -670,7 +679,8 @@ static HRESULT WINAPI StreamOnStreamRange_LockRegion(IStream *iface, static HRESULT WINAPI StreamOnStreamRange_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) { - TRACE("(%p)\n", iface); + TRACE("(%p, %s, %s, %d)\n", iface, wine_dbgstr_longlong(libOffset.QuadPart), + wine_dbgstr_longlong(cb.QuadPart), dwLockType); return E_NOTIMPL; } @@ -679,7 +689,7 @@ static HRESULT WINAPI StreamOnStreamRange_Stat(IStream *iface, { StreamOnStreamRange *This = StreamOnStreamRange_from_IStream(iface); HRESULT hr; - TRACE("(%p)\n", This); + TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag); if (!pstatstg) return E_INVALIDARG; @@ -701,11 +711,10 @@ static HRESULT WINAPI StreamOnStreamRange_Stat(IStream *iface, static HRESULT WINAPI StreamOnStreamRange_Clone(IStream *iface, IStream **ppstm) { - TRACE("(%p)\n", iface); + TRACE("(%p, %p)\n", iface, ppstm); return E_NOTIMPL; } - static const IStreamVtbl StreamOnStreamRange_Vtbl = { /*** IUnknown methods ***/ @@ -795,7 +804,7 @@ static HRESULT WINAPI IWICStreamImpl_Read(IWICStream *iface, void *pv, ULONG cb, ULONG *pcbRead) { IWICStreamImpl *This = impl_from_IWICStream(iface); - TRACE("(%p): relay\n", This); + TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbRead); if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED; return IStream_Read(This->pStream, pv, cb, pcbRead); @@ -805,7 +814,7 @@ static HRESULT WINAPI IWICStreamImpl_Write(IWICStream *iface, void const *pv, ULONG cb, ULONG *pcbWritten) { IWICStreamImpl *This = impl_from_IWICStream(iface); - TRACE("(%p): relay\n", This); + TRACE("(%p, %p, %u, %p)\n", This, pv, cb, pcbWritten); if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED; return IStream_Write(This->pStream, pv, cb, pcbWritten); @@ -815,7 +824,8 @@ static HRESULT WINAPI IWICStreamImpl_Seek(IWICStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) { IWICStreamImpl *This = impl_from_IWICStream(iface); - TRACE("(%p): relay\n", This); + TRACE("(%p, %s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), + dwOrigin, plibNewPosition); if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED; return IStream_Seek(This->pStream, dlibMove, dwOrigin, plibNewPosition); @@ -825,7 +835,7 @@ static HRESULT WINAPI IWICStreamImpl_SetSize(IWICStream *iface, ULARGE_INTEGER libNewSize) { IWICStreamImpl *This = impl_from_IWICStream(iface); - TRACE("(%p): relay\n", This); + TRACE("(%p, %s)\n", This, wine_dbgstr_longlong(libNewSize.QuadPart)); if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED; return IStream_SetSize(This->pStream, libNewSize); @@ -835,7 +845,7 @@ static HRESULT WINAPI IWICStreamImpl_CopyTo(IWICStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten) { IWICStreamImpl *This = impl_from_IWICStream(iface); - TRACE("(%p): relay\n", This); + TRACE("(%p, %p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten); if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED; return IStream_CopyTo(This->pStream, pstm, cb, pcbRead, pcbWritten); @@ -845,7 +855,7 @@ static HRESULT WINAPI IWICStreamImpl_Commit(IWICStream *iface, DWORD grfCommitFlags) { IWICStreamImpl *This = impl_from_IWICStream(iface); - TRACE("(%p): relay\n", This); + TRACE("(%p, %#x)\n", This, grfCommitFlags); if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED; return IStream_Commit(This->pStream, grfCommitFlags); @@ -854,7 +864,7 @@ static HRESULT WINAPI IWICStreamImpl_Commit(IWICStream *iface, static HRESULT WINAPI IWICStreamImpl_Revert(IWICStream *iface) { IWICStreamImpl *This = impl_from_IWICStream(iface); - TRACE("(%p): relay\n", This); + TRACE("(%p)\n", This); if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED; return IStream_Revert(This->pStream); @@ -864,7 +874,8 @@ static HRESULT WINAPI IWICStreamImpl_LockRegion(IWICStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) { IWICStreamImpl *This = impl_from_IWICStream(iface); - TRACE("(%p): relay\n", This); + TRACE("(%p, %s, %s, %d)\n", This, wine_dbgstr_longlong(libOffset.QuadPart), + wine_dbgstr_longlong(cb.QuadPart), dwLockType); if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED; return IStream_LockRegion(This->pStream, libOffset, cb, dwLockType); @@ -874,7 +885,8 @@ static HRESULT WINAPI IWICStreamImpl_UnlockRegion(IWICStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) { IWICStreamImpl *This = impl_from_IWICStream(iface); - TRACE("(%p): relay\n", This); + TRACE("(%p, %s, %s, %d)\n", This, wine_dbgstr_longlong(libOffset.QuadPart), + wine_dbgstr_longlong(cb.QuadPart), dwLockType); if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED; return IStream_UnlockRegion(This->pStream, libOffset, cb, dwLockType); @@ -884,7 +896,7 @@ static HRESULT WINAPI IWICStreamImpl_Stat(IWICStream *iface, STATSTG *pstatstg, DWORD grfStatFlag) { IWICStreamImpl *This = impl_from_IWICStream(iface); - TRACE("(%p): relay\n", This); + TRACE("(%p, %p, %#x)\n", This, pstatstg, grfStatFlag); if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED; return IStream_Stat(This->pStream, pstatstg, grfStatFlag); @@ -894,22 +906,32 @@ static HRESULT WINAPI IWICStreamImpl_Clone(IWICStream *iface, IStream **ppstm) { IWICStreamImpl *This = impl_from_IWICStream(iface); - TRACE("(%p): relay\n", This); + TRACE("(%p, %p)\n", This, ppstm); if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED; return IStream_Clone(This->pStream, ppstm); } -static HRESULT WINAPI IWICStreamImpl_InitializeFromIStream(IWICStream *iface, - IStream *pIStream) +static HRESULT WINAPI IWICStreamImpl_InitializeFromIStream(IWICStream *iface, IStream *stream) { - ULARGE_INTEGER offset, size; - TRACE("(%p): relay\n", iface); + IWICStreamImpl *This = impl_from_IWICStream(iface); + HRESULT hr = S_OK; + + TRACE("(%p, %p)\n", iface, stream); + + if (!stream) return E_INVALIDARG; + if (This->pStream) return WINCODEC_ERR_WRONGSTATE; + + IStream_AddRef(stream); - offset.QuadPart = 0; - size.u.LowPart = 0xffffffff; - size.u.HighPart = 0xffffffff; - return IWICStream_InitializeFromIStreamRegion(iface, pIStream, offset, size); + if (InterlockedCompareExchangePointer((void **)&This->pStream, stream, NULL)) + { + /* Some other thread set the stream first. */ + IStream_Release(stream); + hr = WINCODEC_ERR_WRONGSTATE; + } + + return hr; } static HRESULT WINAPI IWICStreamImpl_InitializeFromFilename(IWICStream *iface, @@ -967,7 +989,7 @@ static HRESULT WINAPI IWICStreamImpl_InitializeFromMemory(IWICStream *iface, { IWICStreamImpl *This = impl_from_IWICStream(iface); StreamOnMemory *pObject; - TRACE("(%p,%p)\n", iface, pbBuffer); + TRACE("(%p, %p, %u)\n", iface, pbBuffer, cbBufferSize); if (!pbBuffer) return E_INVALIDARG; if (This->pStream) return WINCODEC_ERR_WRONGSTATE; @@ -1068,7 +1090,9 @@ static HRESULT WINAPI IWICStreamImpl_InitializeFromIStreamRegion(IWICStream *ifa { IWICStreamImpl *This = impl_from_IWICStream(iface); StreamOnStreamRange *pObject; - TRACE("(%p,%p)\n", iface, pIStream); + + TRACE("(%p,%p,%s,%s)\n", iface, pIStream, wine_dbgstr_longlong(ulOffset.QuadPart), + wine_dbgstr_longlong(ulMaxSize.QuadPart)); if (!pIStream) return E_INVALIDARG; if (This->pStream) return WINCODEC_ERR_WRONGSTATE; diff --git a/dll/win32/windowscodecs/tgaformat.c b/dll/win32/windowscodecs/tgaformat.c index b3d9aeae26..72c9baa016 100644 --- a/dll/win32/windowscodecs/tgaformat.c +++ b/dll/win32/windowscodecs/tgaformat.c @@ -890,7 +890,7 @@ static HRESULT WINAPI TgaDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface, TgaDecoder *This = impl_from_IWICBitmapFrameDecode(iface); HRESULT hr; - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); hr = TgaDecoder_ReadImage(This); diff --git a/dll/win32/windowscodecs/tiffformat.c b/dll/win32/windowscodecs/tiffformat.c index d1ee44087f..d9b7c4c609 100644 --- a/dll/win32/windowscodecs/tiffformat.c +++ b/dll/win32/windowscodecs/tiffformat.c @@ -504,7 +504,7 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info) break; default: FIXME("unhandled indexed bit count %u\n", bps); - return E_FAIL; + return E_NOTIMPL; } break; @@ -836,6 +836,7 @@ static HRESULT WINAPI TiffDecoder_GetFrame(IWICBitmapDecoder *iface, result->IWICMetadataBlockReader_iface.lpVtbl = &TiffFrameDecode_BlockVtbl; result->ref = 1; result->parent = This; + IWICBitmapDecoder_AddRef(iface); result->index = index; result->decode_info = decode_info; result->cached_tile_x = -1; @@ -846,7 +847,7 @@ static HRESULT WINAPI TiffDecoder_GetFrame(IWICBitmapDecoder *iface, else { hr = E_OUTOFMEMORY; - HeapFree(GetProcessHeap(), 0, result); + IWICBitmapFrameDecode_Release(&result->IWICBitmapFrameDecode_iface); } } else hr = E_OUTOFMEMORY; @@ -921,6 +922,7 @@ static ULONG WINAPI TiffFrameDecode_Release(IWICBitmapFrameDecode *iface) if (ref == 0) { + IWICBitmapDecoder_Release(&This->parent->IWICBitmapDecoder_iface); HeapFree(GetProcessHeap(), 0, This->cached_tile); HeapFree(GetProcessHeap(), 0, This); } @@ -1286,7 +1288,7 @@ static HRESULT WINAPI TiffFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, UINT bytesperrow; WICRect rect; - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); if (!prc) { @@ -1308,7 +1310,7 @@ static HRESULT WINAPI TiffFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, if (cbStride < bytesperrow) return E_INVALIDARG; - if ((cbStride * (prc->Height-1)) + ((prc->Width * This->decode_info.bpp) + 7)/8 > cbBufferSize) + if ((cbStride * (prc->Height-1)) + bytesperrow > cbBufferSize) return E_INVALIDARG; min_tile_x = prc->X / This->decode_info.tile_width; @@ -1623,7 +1625,6 @@ static const struct tiff_encode_format formats[] = { {&GUID_WICPixelFormat64bppRGBA, 2, 16, 4, 64, 1, 2, 0}, {&GUID_WICPixelFormat64bppPRGBA, 2, 16, 4, 64, 1, 1, 0}, {&GUID_WICPixelFormat1bppIndexed, 3, 1, 1, 1, 0, 0, 0}, - {&GUID_WICPixelFormat2bppIndexed, 3, 2, 1, 2, 0, 0, 0}, {&GUID_WICPixelFormat4bppIndexed, 3, 4, 1, 4, 0, 0, 0}, {&GUID_WICPixelFormat8bppIndexed, 3, 8, 1, 8, 0, 0, 0}, {0} @@ -1797,9 +1798,12 @@ static HRESULT WINAPI TiffFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *ifac return WINCODEC_ERR_WRONGSTATE; } + if (IsEqualGUID(pPixelFormat, &GUID_WICPixelFormat2bppIndexed)) + *pPixelFormat = GUID_WICPixelFormat4bppIndexed; + for (i=0; formats[i].guid; i++) { - if (memcmp(formats[i].guid, pPixelFormat, sizeof(GUID)) == 0) + if (IsEqualGUID(formats[i].guid, pPixelFormat)) break; } @@ -1961,7 +1965,7 @@ static HRESULT WINAPI TiffFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, TiffFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface); HRESULT hr; - TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc); + TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc)); if (!This->initialized) return WINCODEC_ERR_WRONGSTATE; @@ -2117,6 +2121,11 @@ exit: static HRESULT WINAPI TiffEncoder_GetContainerFormat(IWICBitmapEncoder *iface, GUID *pguidContainerFormat) { + TRACE("(%p,%p)\n", iface, pguidContainerFormat); + + if (!pguidContainerFormat) + return E_INVALIDARG; + memcpy(pguidContainerFormat, &GUID_ContainerFormatTiff, sizeof(GUID)); return S_OK; } @@ -2202,7 +2211,7 @@ static HRESULT WINAPI TiffEncoder_CreateNewFrame(IWICBitmapEncoder *iface, if (ppIEncoderOptions && SUCCEEDED(hr)) { - hr = CreatePropertyBag2(opts, sizeof(opts)/sizeof(opts[0]), ppIEncoderOptions); + hr = CreatePropertyBag2(opts, ARRAY_SIZE(opts), ppIEncoderOptions); if (SUCCEEDED(hr)) { VARIANT v; diff --git a/dll/win32/windowscodecs/wincodecs_private.h b/dll/win32/windowscodecs/wincodecs_private.h index 264520492c..22af9a12fb 100644 --- a/dll/win32/windowscodecs/wincodecs_private.h +++ b/dll/win32/windowscodecs/wincodecs_private.h @@ -21,6 +21,8 @@ #include "wincodec.h" #include "wincodecsdk.h" + +#include "wine/debug.h" #include "wine/unicode.h" DEFINE_GUID(CLSID_WineTgaDecoder, 0xb11fc79a,0x67cc,0x43e6,0xa9,0xce,0xe3,0xd5,0x49,0x45,0xd3,0x04); @@ -138,7 +140,7 @@ HRESULT create_instance(CLSID *clsid, const IID *iid, void **ppv) DECLSPEC_HIDDE typedef HRESULT(*class_constructor)(REFIID,void**); extern HRESULT FormatConverter_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN; -extern HRESULT ComponentFactory_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN; +extern HRESULT ImagingFactory_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN; extern HRESULT BmpDecoder_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN; extern HRESULT PngDecoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN; extern HRESULT PngEncoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN; @@ -242,4 +244,10 @@ static inline WCHAR *heap_strdupW(const WCHAR *src) return dst; } +static inline const char *debug_wic_rect(const WICRect *rect) +{ + if (!rect) return "(null)"; + return wine_dbg_sprintf("(%u,%u)-(%u,%u)", rect->X, rect->Y, rect->Width, rect->Height); +} + #endif /* WINCODECS_PRIVATE_H */ diff --git a/dll/win32/windowscodecs/windowscodecs.spec b/dll/win32/windowscodecs/windowscodecs.spec index 424b3075ce..ae3660c6f3 100644 --- a/dll/win32/windowscodecs/windowscodecs.spec +++ b/dll/win32/windowscodecs/windowscodecs.spec @@ -99,9 +99,9 @@ @ stdcall IWICPalette_InitializeFromBitmap_Proxy(ptr ptr long long) IWICPalette_InitializeFromBitmap_Proxy_W @ stdcall IWICPalette_InitializeFromPalette_Proxy(ptr ptr) IWICPalette_InitializeFromPalette_Proxy_W @ stdcall IWICPalette_InitializePredefined_Proxy(ptr long long) IWICPalette_InitializePredefined_Proxy_W -@ stdcall IWICPixelFormatInfo_GetBitsPerPixel_Proxy(ptr ptr) -@ stdcall IWICPixelFormatInfo_GetChannelCount_Proxy(ptr ptr) -@ stdcall IWICPixelFormatInfo_GetChannelMask_Proxy(ptr long long ptr ptr) +@ stdcall IWICPixelFormatInfo_GetBitsPerPixel_Proxy(ptr ptr) IWICPixelFormatInfo_GetBitsPerPixel_Proxy_W +@ stdcall IWICPixelFormatInfo_GetChannelCount_Proxy(ptr ptr) IWICPixelFormatInfo_GetChannelCount_Proxy_W +@ stdcall IWICPixelFormatInfo_GetChannelMask_Proxy(ptr long long ptr ptr) IWICPixelFormatInfo_GetChannelMask_Proxy_W @ stdcall IWICStream_InitializeFromIStream_Proxy(ptr ptr) IWICStream_InitializeFromIStream_Proxy_W @ stdcall IWICStream_InitializeFromMemory_Proxy(ptr ptr long) IWICStream_InitializeFromMemory_Proxy_W @ stdcall WICConvertBitmapSource(ptr ptr ptr) diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 218b028e45..a073dcc37a 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -196,7 +196,7 @@ reactos/dll/win32/version # Synced to WineStaging-4.0 reactos/dll/win32/vssapi # Synced to WineStaging-2.9 reactos/dll/win32/wbemdisp # Synced to WineStaging-4.0 reactos/dll/win32/wbemprox # Synced to WineStaging-4.0 -reactos/dll/win32/windowscodecs # Synced to WineStaging-3.9 +reactos/dll/win32/windowscodecs # Synced to WineStaging-4.0 reactos/dll/win32/windowscodecsext # Synced to WineStaging-2.9 reactos/dll/win32/winemp3.acm # Synced to WineStaging-3.3 reactos/dll/win32/wing32 # Synced to WineStaging-3.3
5 years, 10 months
1
0
0
0
[reactos] 01/01: [PSDK] Update wincodec.idl. CORE-15682
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a587a0e68e60fa03e10e5…
commit a587a0e68e60fa03e10e5a787da519818a6fb429 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Feb 4 13:11:54 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Feb 4 13:11:54 2019 +0100 [PSDK] Update wincodec.idl. CORE-15682 --- sdk/include/psdk/wincodec.idl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sdk/include/psdk/wincodec.idl b/sdk/include/psdk/wincodec.idl index 3bb635067b..7dcd22378e 100644 --- a/sdk/include/psdk/wincodec.idl +++ b/sdk/include/psdk/wincodec.idl @@ -859,7 +859,9 @@ interface IWICFastMetadataEncoder : IUnknown [out] IWICMetadataQueryWriter **ppIMetadataQueryWriter); } -cpp_quote("DEFINE_GUID(CLSID_WICImagingFactory, 0xcacaf262,0x9370,0x4615,0xa1,0x3b,0x9f,0x55,0x39,0xda,0x4c,0x0a);") +cpp_quote("DEFINE_GUID(CLSID_WICImagingFactory, 0xcacaf262,0x9370,0x4615,0xa1,0x3b,0x9f,0x55,0x39,0xda,0x4c,0x0a);") +cpp_quote("DEFINE_GUID(CLSID_WICImagingFactory1, 0xcacaf262,0x9370,0x4615,0xa1,0x3b,0x9f,0x55,0x39,0xda,0x4c,0x0a);") +cpp_quote("DEFINE_GUID(CLSID_WICImagingFactory2, 0x317d06e8,0x5f24,0x433d,0xbd,0xf7,0x79,0xce,0x68,0xd8,0xab,0xc2);") [ object, @@ -987,6 +989,15 @@ interface IWICImagingFactory : IUnknown [out] IWICMetadataQueryWriter **ppIQueryWriter); } +[ + object, + uuid(7b816b45-1996-4476-b132-de9e247c8af0), + local +] +interface IWICImagingFactory2 : IWICImagingFactory +{ +} + [ local, object,
5 years, 10 months
1
0
0
0
[reactos] 01/01: [WBEMPROX_WINETEST] Sync with Wine Staging 4.0. CORE-15682
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d9bd8eaba3ad3a8bc5b0d…
commit d9bd8eaba3ad3a8bc5b0df328fee168eb8712156 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Feb 4 13:11:26 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Feb 4 13:11:26 2019 +0100 [WBEMPROX_WINETEST] Sync with Wine Staging 4.0. CORE-15682 --- modules/rostests/winetests/wbemprox/query.c | 210 +++++++++++++++++++++---- modules/rostests/winetests/wbemprox/services.c | 2 +- 2 files changed, 181 insertions(+), 31 deletions(-) diff --git a/modules/rostests/winetests/wbemprox/query.c b/modules/rostests/winetests/wbemprox/query.c index d95fdd970b..0fa6b5e966 100644 --- a/modules/rostests/winetests/wbemprox/query.c +++ b/modules/rostests/winetests/wbemprox/query.c @@ -141,7 +141,7 @@ static void test_select( IWbemServices *services ) hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result ); ok( hr == WBEM_E_INVALID_PARAMETER, "query failed %08x\n", hr ); - for (i = 0; i < sizeof(test)/sizeof(test[0]); i++) + for (i = 0; i < ARRAY_SIZE( test ); i++) { hr = exec_query( services, test[i], &result ); ok( hr == S_OK, "query %u failed: %08x\n", i, hr ); @@ -168,7 +168,7 @@ static void test_associators( IWbemServices *services ) IEnumWbemClassObject *result; UINT i; - for (i = 0; i < sizeof(test)/sizeof(test[0]); i++) + for (i = 0; i < ARRAY_SIZE( test ); i++) { hr = exec_query( services, test[i], &result ); todo_wine ok( hr == S_OK, "query %u failed: %08x\n", i, hr ); @@ -398,7 +398,7 @@ static void test_Win32_Bios( IWbemServices *services ) SysFreeString( wql ); } -static void test_Win32_Process( IWbemServices *services ) +static void test_Win32_Process( IWbemServices *services, BOOL use_full_path ) { static const WCHAR returnvalueW[] = {'R','e','t','u','r','n','V','a','l','u','e',0}; static const WCHAR getownerW[] = {'G','e','t','O','w','n','e','r',0}; @@ -408,18 +408,33 @@ static void test_Win32_Process( IWbemServices *services ) static const WCHAR idW[] = {'I','D',0}; static const WCHAR fmtW[] = {'W','i','n','3','2','_','P','r','o','c','e','s','s','.', 'H','a','n','d','l','e','=','"','%','u','"',0}; + static const WCHAR full_path_fmt[] = + {'\\','\\','%','s','\\','R','O','O','T','\\','C','I','M','V','2',':',0}; static const LONG expected_flavor = WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE | WBEM_FLAVOR_ORIGIN_PROPAGATED; + WCHAR full_path[MAX_COMPUTERNAME_LENGTH + ARRAY_SIZE(full_path_fmt)]; BSTR class, method; - IWbemClassObject *process, *out; + IWbemClassObject *process, *sig_in, *out; IWbemQualifierSet *qualifiers; VARIANT user, domain, retval, val; + DWORD full_path_len = 0; LONG flavor; CIMTYPE type; HRESULT hr; - class = SysAllocString( processW ); + if (use_full_path) + { + WCHAR server[MAX_COMPUTERNAME_LENGTH+1]; + + full_path_len = ARRAY_SIZE(server); + ok( GetComputerNameW(server, &full_path_len), "GetComputerName failed\n" ); + full_path_len = wsprintfW(full_path, full_path_fmt, server); + } + + class = SysAllocStringLen( NULL, full_path_len + ARRAY_SIZE( processW ) ); + memcpy( class, full_path, full_path_len * sizeof(WCHAR) ); + memcpy( class + full_path_len, processW, sizeof(processW) ); hr = IWbemServices_GetObject( services, class, 0, NULL, &process, NULL ); SysFreeString( class ); if (hr != S_OK) @@ -427,14 +442,17 @@ static void test_Win32_Process( IWbemServices *services ) win_skip( "Win32_Process not available\n" ); return; } - hr = IWbemClassObject_GetMethod( process, getownerW, 0, NULL, NULL ); + sig_in = (void*)0xdeadbeef; + hr = IWbemClassObject_GetMethod( process, getownerW, 0, &sig_in, NULL ); ok( hr == S_OK, "failed to get GetOwner method %08x\n", hr ); + ok( !sig_in, "sig_in != NULL\n"); IWbemClassObject_Release( process ); out = NULL; method = SysAllocString( getownerW ); - class = SysAllocStringLen( NULL, sizeof(fmtW)/sizeof(fmtW[0]) + 10 ); - wsprintfW( class, fmtW, GetCurrentProcessId() ); + class = SysAllocStringLen( NULL, full_path_len + ARRAY_SIZE( fmtW ) + 10 ); + memcpy( class, full_path, full_path_len * sizeof(WCHAR) ); + wsprintfW( class + full_path_len, fmtW, GetCurrentProcessId() ); hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, NULL, &out, NULL ); ok( hr == S_OK, "failed to execute method %08x\n", hr ); SysFreeString( method ); @@ -524,13 +542,13 @@ static void test_Win32_ComputerSystem( IWbemServices *services ) WCHAR username[128]; DWORD len, count; - len = sizeof(compname) / sizeof(compname[0]); + len = ARRAY_SIZE( compname ); if (!GetComputerNameW( compname, &len )) compname[0] = 0; lstrcpyW( username, compname ); lstrcatW( username, backslashW ); - len = sizeof(username) / sizeof(username[0]) - lstrlenW( username ); + len = ARRAY_SIZE( username ) - lstrlenW( username ); if (!GetUserNameW( username + lstrlenW( username ), &len )) username[0] = 0; @@ -704,6 +722,7 @@ static void test_Win32_SystemEnclosure( IWbemServices *services ) static void test_StdRegProv( IWbemServices *services ) { + static const WCHAR createkeyW[] = {'C','r','e','a','t','e','K','e','y',0}; static const WCHAR enumkeyW[] = {'E','n','u','m','K','e','y',0}; static const WCHAR enumvaluesW[] = {'E','n','u','m','V','a','l','u','e','s',0}; static const WCHAR getstringvalueW[] = {'G','e','t','S','t','r','i','n','g','V','a','l','u','e',0}; @@ -719,11 +738,14 @@ static void test_StdRegProv( IWbemServices *services ) static const WCHAR windowsW[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\', 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',0}; - BSTR class = SysAllocString( stdregprovW ), method; - IWbemClassObject *reg, *sig_in, *in, *out; + static const WCHAR regtestW[] = + {'S','o','f','t','w','a','r','e','\\','S','t','d','R','e','g','P','r','o','v','T','e','s','t',0}; + BSTR class = SysAllocString( stdregprovW ), method, name; + IWbemClassObject *reg, *sig_in, *sig_out, *in, *out; VARIANT defkey, subkey, retval, names, types, value, valuename; CIMTYPE type; HRESULT hr; + LONG res; hr = IWbemServices_GetObject( services, class, 0, NULL, ®, NULL ); if (hr != S_OK) @@ -731,6 +753,67 @@ static void test_StdRegProv( IWbemServices *services ) win_skip( "StdRegProv not available\n" ); return; } + + hr = IWbemClassObject_BeginMethodEnumeration( reg, 0 ); + ok( hr == S_OK, "got %08x\n", hr ); + + while (IWbemClassObject_NextMethod( reg, 0, &name, &sig_in, &sig_out ) == S_OK) + { + SysFreeString( name ); + IWbemClassObject_Release( sig_in ); + IWbemClassObject_Release( sig_out ); + } + + hr = IWbemClassObject_EndMethodEnumeration( reg ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = IWbemClassObject_BeginEnumeration( reg, 0 ); + ok( hr == S_OK, "got %08x\n", hr ); + + while (IWbemClassObject_Next( reg, 0, &name, NULL, NULL, NULL ) == S_OK) + SysFreeString( name ); + + hr = IWbemClassObject_EndEnumeration( reg ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = IWbemClassObject_GetMethod( reg, createkeyW, 0, &sig_in, NULL ); + ok( hr == S_OK, "failed to get CreateKey method %08x\n", hr ); + + hr = IWbemClassObject_SpawnInstance( sig_in, 0, &in ); + ok( hr == S_OK, "failed to spawn instance %08x\n", hr ); + + V_VT( &defkey ) = VT_I4; + V_I4( &defkey ) = 0x80000001; + hr = IWbemClassObject_Put( in, defkeyW, 0, &defkey, 0 ); + ok( hr == S_OK, "failed to set root %08x\n", hr ); + + V_VT( &subkey ) = VT_BSTR; + V_BSTR( &subkey ) = SysAllocString( regtestW ); + hr = IWbemClassObject_Put( in, subkeynameW, 0, &subkey, 0 ); + ok( hr == S_OK, "failed to set subkey %08x\n", hr ); + + out = NULL; + method = SysAllocString( createkeyW ); + hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, in, &out, NULL ); + ok( hr == S_OK, "failed to execute method %08x\n", hr ); + SysFreeString( method ); + + type = 0xdeadbeef; + VariantInit( &retval ); + hr = IWbemClassObject_Get( out, returnvalueW, 0, &retval, &type, NULL ); + ok( hr == S_OK, "failed to get return value %08x\n", hr ); + ok( V_VT( &retval ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &retval ) ); + ok( !V_I4( &retval ), "unexpected error %u\n", V_UI4( &retval ) ); + ok( type == CIM_UINT32, "unexpected type 0x%x\n", type ); + + res = RegDeleteKeyW( HKEY_CURRENT_USER, regtestW ); + ok( !res, "got %d\n", res ); + + VariantClear( &subkey ); + IWbemClassObject_Release( in ); + IWbemClassObject_Release( out ); + IWbemClassObject_Release( sig_in ); + hr = IWbemClassObject_GetMethod( reg, enumkeyW, 0, &sig_in, NULL ); ok( hr == S_OK, "failed to get EnumKey method %08x\n", hr ); @@ -1126,6 +1209,14 @@ static void test_Win32_OperatingSystem( IWbemServices *services ) hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count ); ok( hr == S_OK, "IEnumWbemClassObject_Next failed %08x\n", hr ); + hr = IWbemClassObject_BeginEnumeration( obj, 0 ); + ok( hr == S_OK, "got %08x\n", hr ); + + while (IWbemClassObject_Next( obj, 0, NULL, NULL, NULL, NULL ) == S_OK) {} + + hr = IWbemClassObject_EndEnumeration( obj ); + ok( hr == S_OK, "got %08x\n", hr ); + type = 0xdeadbeef; VariantInit( &val ); hr = IWbemClassObject_Get( obj, buildnumberW, 0, &val, &type, NULL ); @@ -1368,25 +1459,28 @@ static void test_Win32_PhysicalMemory( IWbemServices *services ) hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count ); ok( hr == S_OK, "got %08x\n", hr ); - type = 0xdeadbeef; - VariantInit( &val ); - hr = IWbemClassObject_Get( obj, capacityW, 0, &val, &type, NULL ); - ok( hr == S_OK, "failed to get capacity %08x\n", hr ); - ok( V_VT( &val ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &val ) ); - ok( type == CIM_UINT64, "unexpected type 0x%x\n", type ); - trace( "capacity %s\n", wine_dbgstr_w(V_BSTR( &val )) ); - VariantClear( &val ); + if (count > 0) + { + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( obj, capacityW, 0, &val, &type, NULL ); + ok( hr == S_OK, "failed to get capacity %08x\n", hr ); + ok( V_VT( &val ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &val ) ); + ok( type == CIM_UINT64, "unexpected type 0x%x\n", type ); + trace( "capacity %s\n", wine_dbgstr_w(V_BSTR( &val )) ); + VariantClear( &val ); - type = 0xdeadbeef; - VariantInit( &val ); - hr = IWbemClassObject_Get( obj, memorytypeW, 0, &val, &type, NULL ); - ok( hr == S_OK, "failed to get memory type %08x\n", hr ); - ok( V_VT( &val ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &val ) ); - ok( type == CIM_UINT16, "unexpected type 0x%x\n", type ); - trace( "memorytype %u\n", V_I4( &val ) ); - VariantClear( &val ); + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( obj, memorytypeW, 0, &val, &type, NULL ); + ok( hr == S_OK, "failed to get memory type %08x\n", hr ); + ok( V_VT( &val ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &val ) ); + ok( type == CIM_UINT16, "unexpected type 0x%x\n", type ); + trace( "memorytype %u\n", V_I4( &val ) ); + VariantClear( &val ); - IWbemClassObject_Release( obj ); + IWbemClassObject_Release( obj ); + } IEnumWbemClassObject_Release( result ); SysFreeString( query ); SysFreeString( wql ); @@ -1450,6 +1544,7 @@ static void test_Win32_IP4RouteTable( IWbemServices *services ) IWbemClassObject_Release( obj ); } + IEnumWbemClassObject_Release( result ); SysFreeString( query ); SysFreeString( wql ); } @@ -1562,6 +1657,7 @@ static void test_Win32_Processor( IWbemServices *services ) IWbemClassObject_Release( obj ); } + IEnumWbemClassObject_Release( result ); SysFreeString( query ); SysFreeString( wql ); } @@ -1637,6 +1733,7 @@ static void test_Win32_VideoController( IWbemServices *services ) IWbemClassObject_Release( obj ); } + IEnumWbemClassObject_Release( result ); SysFreeString( query ); SysFreeString( wql ); } @@ -1702,10 +1799,61 @@ static void test_Win32_Printer( IWbemServices *services ) IWbemClassObject_Release( obj ); } + IEnumWbemClassObject_Release( result ); SysFreeString( query ); SysFreeString( wql ); } +static void test_Win32_PnPEntity( IWbemServices *services ) +{ + HRESULT hr; + IEnumWbemClassObject *enm; + IWbemClassObject *obj; + VARIANT val; + CIMTYPE type; + ULONG count, i; + BSTR bstr; + + static WCHAR win32_pnpentityW[] = {'W','i','n','3','2','_','P','n','P','E','n','t','i','t','y',0}; + static const WCHAR deviceidW[] = {'D','e','v','i','c','e','I','d',0}; + + bstr = SysAllocString( win32_pnpentityW ); + + hr = IWbemServices_CreateInstanceEnum( services, bstr, 0, NULL, &enm ); + ok( hr == S_OK, "got %08x\n", hr ); + + SysFreeString( bstr ); + bstr = SysAllocString( deviceidW ); + + while (1) + { + hr = IEnumWbemClassObject_Next( enm, 1000, 1, &obj, &count ); + ok( (count == 1 && (hr == WBEM_S_FALSE || hr == WBEM_S_NO_ERROR)) || + (count == 0 && (hr == WBEM_S_FALSE || hr == WBEM_S_TIMEDOUT)), + "got %08x with %u objects returned\n", hr, count ); + + if (count == 0) + break; + + for (i = 0; i < count; ++i) + { + hr = IWbemClassObject_Get( obj, bstr, 0, &val, &type, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + if (SUCCEEDED( hr )) + { + ok( V_VT( &val ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &val ) ); + ok( type == CIM_STRING, "unexpected type 0x%x\n", type ); + VariantClear( &val ); + } + } + } + + SysFreeString( bstr ); + + IEnumWbemClassObject_Release( enm ); +} + START_TEST(query) { static const WCHAR cimv2W[] = {'R','O','O','T','\\','C','I','M','V','2',0}; @@ -1734,7 +1882,8 @@ START_TEST(query) test_select( services ); test_associators( services ); test_Win32_Bios( services ); - test_Win32_Process( services ); + test_Win32_Process( services, FALSE ); + test_Win32_Process( services, TRUE ); test_Win32_Service( services ); test_Win32_ComputerSystem( services ); test_Win32_SystemEnclosure( services ); @@ -1750,6 +1899,7 @@ START_TEST(query) test_Win32_Processor( services ); test_Win32_VideoController( services ); test_Win32_Printer( services ); + test_Win32_PnPEntity( services ); SysFreeString( path ); IWbemServices_Release( services ); diff --git a/modules/rostests/winetests/wbemprox/services.c b/modules/rostests/winetests/wbemprox/services.c index a6774751f3..da10e72fe1 100644 --- a/modules/rostests/winetests/wbemprox/services.c +++ b/modules/rostests/winetests/wbemprox/services.c @@ -164,7 +164,7 @@ static void test_IWbemLocator(void) } ok( hr == S_OK, "failed to create IWbemLocator interface %08x\n", hr ); - for (i = 0; i < sizeof(test) / sizeof(test[0]); i++) + for (i = 0; i < ARRAY_SIZE( test ); i++) { resource = SysAllocString( test[i].path ); hr = IWbemLocator_ConnectServer( locator, resource, NULL, NULL, NULL, 0, NULL, NULL, &services );
5 years, 10 months
1
0
0
0
[reactos] 01/01: [WBEMPROX] Sync with Wine Staging 4.0. CORE-15682
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=46add00db53659fbdbd77…
commit 46add00db53659fbdbd777cb73acfbfd38eea2fa Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Feb 4 13:10:55 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Feb 4 13:10:55 2019 +0100 [WBEMPROX] Sync with Wine Staging 4.0. CORE-15682 --- dll/win32/wbemprox/CMakeLists.txt | 2 +- dll/win32/wbemprox/builtin.c | 255 ++++++++++++++++++++++++++++------ dll/win32/wbemprox/class.c | 32 +++-- dll/win32/wbemprox/qualifier.c | 4 +- dll/win32/wbemprox/query.c | 63 ++++++--- dll/win32/wbemprox/reg.c | 63 ++++++++- dll/win32/wbemprox/services.c | 39 +++++- dll/win32/wbemprox/wbemlocator.c | 8 +- dll/win32/wbemprox/wbemprox_private.h | 4 +- dll/win32/wbemprox/wql.tab.c | 26 ++-- dll/win32/wbemprox/wql.y | 26 ++-- media/doc/README.WINE | 2 +- 12 files changed, 409 insertions(+), 115 deletions(-) diff --git a/dll/win32/wbemprox/CMakeLists.txt b/dll/win32/wbemprox/CMakeLists.txt index ac67fdf9cf..5aea8b6621 100644 --- a/dll/win32/wbemprox/CMakeLists.txt +++ b/dll/win32/wbemprox/CMakeLists.txt @@ -31,7 +31,7 @@ add_library(wbemprox SHARED set_source_files_properties(wbemprox.rc PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/wbemprox.rgs) set_module_type(wbemprox win32dll) target_link_libraries(wbemprox uuid wine) -add_importlibs(wbemprox iphlpapi oleaut32 advapi32 user32 gdi32 version winspool ws2_32 rpcrt4 msvcrt kernel32 ntdll) +add_importlibs(wbemprox iphlpapi oleaut32 advapi32 user32 gdi32 version winspool ws2_32 rpcrt4 setupapi msvcrt kernel32 ntdll) add_dependencies(wbemprox d3d_idl_headers) add_pch(wbemprox precomp.h SOURCE) add_cd_file(TARGET wbemprox DESTINATION reactos/system32/wbem FOR all) diff --git a/dll/win32/wbemprox/builtin.c b/dll/win32/wbemprox/builtin.c index bec0ed20b8..5f689635cf 100644 --- a/dll/win32/wbemprox/builtin.c +++ b/dll/win32/wbemprox/builtin.c @@ -37,6 +37,7 @@ #ifdef __MINGW32__ # include "winsock2.h" # include "ws2tcpip.h" +# define WS_AF_INET AF_INET # define WS_AF_UNSPEC AF_UNSPEC # define WS_NI_MAXHOST NI_MAXHOST # define WS_NI_NAMEREQD NI_NAMEREQD @@ -49,6 +50,7 @@ #include "wbemcli.h" #include "wbemprov.h" #include "iphlpapi.h" +#include "netioapi.h" #include "tlhelp32.h" #ifndef __REACTOS__ #include "d3d10.h" @@ -61,8 +63,10 @@ #include "ntsecapi.h" #ifdef __REACTOS__ #include <wingdi.h> +#include <winreg.h> #endif #include "winspool.h" +#include "setupapi.h" #include "wine/debug.h" #include "wbemprox_private.h" @@ -108,6 +112,8 @@ static const WCHAR class_physicalmediaW[] = {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0}; static const WCHAR class_physicalmemoryW[] = {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0}; +static const WCHAR class_pnpentityW[] = + {'W','i','n','3','2','_','P','n','P','E','n','t','i','t','y',0}; static const WCHAR class_printerW[] = {'W','i','n','3','2','_','P','r','i','n','t','e','r',0}; static const WCHAR class_process_getowner_outW[] = @@ -272,10 +278,14 @@ static const WCHAR prop_interfacetypeW[] = {'I','n','t','e','r','f','a','c','e','T','y','p','e',0}; static const WCHAR prop_intvalueW[] = {'I','n','t','e','g','e','r','V','a','l','u','e',0}; +static const WCHAR prop_ipaddressW[] = + {'I','P','A','d','d','r','e','s','s',0}; static const WCHAR prop_ipconnectionmetricW[] = {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0}; static const WCHAR prop_ipenabledW[] = {'I','P','E','n','a','b','l','e','d',0}; +static const WCHAR prop_ipsubnet[] = + {'I','P','S','u','b','n','e','t',0}; static const WCHAR prop_lastbootuptimeW[] = {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0}; static const WCHAR prop_levelW[] = @@ -572,8 +582,10 @@ static const struct column col_networkadapterconfig[] = { prop_dnshostnameW, CIM_STRING|COL_FLAG_DYNAMIC }, { prop_dnsserversearchorderW, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC }, { prop_indexW, CIM_UINT32|COL_FLAG_KEY, VT_I4 }, + { prop_ipaddressW, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC }, { prop_ipconnectionmetricW, CIM_UINT32, VT_I4 }, { prop_ipenabledW, CIM_BOOLEAN }, + { prop_ipsubnet, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC }, { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC }, { prop_settingidW, CIM_STRING|COL_FLAG_DYNAMIC } }; @@ -624,6 +636,10 @@ static const struct column col_physicalmemory[] = { prop_capacityW, CIM_UINT64 }, { prop_memorytypeW, CIM_UINT16, VT_I4 } }; +static const struct column col_pnpentity[] = +{ + { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC }, +}; static const struct column col_printer[] = { { prop_attributesW, CIM_UINT32 }, @@ -716,6 +732,7 @@ static const struct column col_sounddevice[] = }; static const struct column col_stdregprov[] = { + { method_createkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }, { method_enumkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }, { method_enumvaluesW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }, { method_getstringvalueW, CIM_FLAG_ARRAY|COL_FLAG_METHOD } @@ -994,8 +1011,10 @@ struct record_networkadapterconfig const WCHAR *dnshostname; const struct array *dnsserversearchorder; UINT32 index; + const struct array *ipaddress; UINT32 ipconnectionmetric; int ipenabled; + const struct array *ipsubnet; const WCHAR *mac_address; const WCHAR *settingid; }; @@ -1046,6 +1065,10 @@ struct record_physicalmemory UINT64 capacity; UINT16 memorytype; }; +struct record_pnpentity +{ + const WCHAR *device_id; +}; struct record_printer { UINT32 attributes; @@ -1138,6 +1161,7 @@ struct record_sounddevice }; struct record_stdregprov { + class_method *createkey; class_method *enumkey; class_method *enumvalues; class_method *getstringvalue; @@ -1202,6 +1226,9 @@ static const struct record_param data_param[] = { class_serviceW, method_resumeserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 }, { class_serviceW, method_startserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 }, { class_serviceW, method_stopserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 }, + { class_stdregprovW, method_createkeyW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 }, + { class_stdregprovW, method_createkeyW, 1, param_subkeynameW, CIM_STRING }, + { class_stdregprovW, method_createkeyW, -1, param_returnvalueW, CIM_UINT32, VT_I4 }, { class_stdregprovW, method_enumkeyW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 }, { class_stdregprovW, method_enumkeyW, 1, param_subkeynameW, CIM_STRING }, { class_stdregprovW, method_enumkeyW, -1, param_returnvalueW, CIM_UINT32, VT_I4 }, @@ -1240,7 +1267,7 @@ static const struct record_sounddevice data_sounddevice[] = }; static const struct record_stdregprov data_stdregprov[] = { - { reg_enum_key, reg_enum_values, reg_get_stringvalue } + { reg_create_key, reg_enum_key, reg_enum_values, reg_get_stringvalue } }; static UINT16 systemenclosure_chassistypes[] = { @@ -1248,7 +1275,7 @@ static UINT16 systemenclosure_chassistypes[] = }; static const struct array systemenclosure_chassistypes_array = { - SIZEOF(systemenclosure_chassistypes), + ARRAY_SIZE(systemenclosure_chassistypes), &systemenclosure_chassistypes }; static const struct record_systemenclosure data_systemenclosure[] = @@ -1785,7 +1812,7 @@ static WCHAR *get_file_version( const WCHAR *filename ) void *block; WCHAR *ret; - if (!(ret = heap_alloc( (4 * 5 + sizeof(fmtW) / sizeof(fmtW[0])) * sizeof(WCHAR) ))) return NULL; + if (!(ret = heap_alloc( (4 * 5 + ARRAY_SIZE( fmtW )) * sizeof(WCHAR) ))) return NULL; if (!(size = GetFileVersionInfoSizeW( filename, NULL )) || !(block = heap_alloc( size ))) { heap_free( ret ); @@ -2044,7 +2071,7 @@ static enum fill_status fill_diskdrive( struct table *table, const struct expr * { static const WCHAR fmtW[] = {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0}; - WCHAR device_id[sizeof(fmtW)/sizeof(fmtW[0]) + 10], root[] = {'A',':','\\',0}; + WCHAR device_id[ARRAY_SIZE( fmtW ) + 10], root[] = {'A',':','\\',0}; struct record_diskdrive *rec; UINT i, row = 0, offset = 0, index = 0, type; UINT64 size = 1024 * 1024 * 1024; @@ -2211,7 +2238,7 @@ static enum fill_status fill_ip4routetable( struct table *table, const struct ex static WCHAR *get_volumename( const WCHAR *root ) { WCHAR buf[MAX_PATH + 1] = {0}; - GetVolumeInformationW( root, buf, sizeof(buf)/sizeof(buf[0]), NULL, NULL, NULL, NULL, 0 ); + GetVolumeInformationW( root, buf, ARRAY_SIZE( buf ), NULL, NULL, NULL, NULL, 0 ); return heap_strdupW( buf ); } static WCHAR *get_volumeserialnumber( const WCHAR *root ) @@ -2381,7 +2408,7 @@ static WCHAR *get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS *addr ) WCHAR buf[NI_MAXHOST]; if (!addr) return NULL; - if (GetNameInfoW( sa->lpSockaddr, sa->iSockaddrLength, buf, sizeof(buf)/sizeof(buf[0]), NULL, + if (GetNameInfoW( sa->lpSockaddr, sa->iSockaddrLength, buf, ARRAY_SIZE( buf ), NULL, 0, NI_NAMEREQD )) return NULL; return heap_strdupW( buf ); } @@ -2403,7 +2430,7 @@ static struct array *get_defaultipgateway( IP_ADAPTER_GATEWAY_ADDRESS *list ) } for (gateway = list; gateway; gateway = gateway->Next) { - buflen = sizeof(buf)/sizeof(buf[0]); + buflen = ARRAY_SIZE( buf ); if (WSAAddressToStringW( gateway->Address.lpSockaddr, gateway->Address.iSockaddrLength, NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf ))) { @@ -2435,7 +2462,7 @@ static struct array *get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS *li } for (server = list; server; server = server->Next) { - buflen = sizeof(buf)/sizeof(buf[0]); + buflen = ARRAY_SIZE( buf ); if (WSAAddressToStringW( server->Address.lpSockaddr, server->Address.iSockaddrLength, NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf ))) { @@ -2450,6 +2477,96 @@ static struct array *get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS *li ret->ptr = ptr; return ret; } + +#ifndef __REACTOS__ + +static struct array *get_ipaddress( IP_ADAPTER_UNICAST_ADDRESS_LH *list ) +{ + IP_ADAPTER_UNICAST_ADDRESS_LH *address; + struct array *ret; + ULONG buflen, i = 0, count = 0; + WCHAR **ptr, buf[54]; /* max IPv6 address length */ + + if (!list) return NULL; + for (address = list; address; address = address->Next) count++; + + if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL; + if (!(ptr = heap_alloc( sizeof(*ptr) * count ))) + { + heap_free( ret ); + return NULL; + } + for (address = list; address; address = address->Next) + { + buflen = ARRAY_SIZE( buf ); + if (WSAAddressToStringW( address->Address.lpSockaddr, address->Address.iSockaddrLength, + NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf ))) + { + for (; i > 0; i--) heap_free( ptr[i - 1] ); + heap_free( ptr ); + heap_free( ret ); + return NULL; + } + } + ret->count = count; + ret->ptr = ptr; + return ret; +} +static struct array *get_ipsubnet( IP_ADAPTER_UNICAST_ADDRESS_LH *list ) +{ + IP_ADAPTER_UNICAST_ADDRESS_LH *address; + struct array *ret; + ULONG i = 0, count = 0; + WCHAR **ptr; + + if (!list) return NULL; + for (address = list; address; address = address->Next) count++; + + if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL; + if (!(ptr = heap_alloc( sizeof(*ptr) * count ))) + { + heap_free( ret ); + return NULL; + } + for (address = list; address; address = address->Next) + { + if (address->Address.lpSockaddr->sa_family == WS_AF_INET) + { + WCHAR buf[INET_ADDRSTRLEN]; + SOCKADDR_IN addr; + ULONG buflen = ARRAY_SIZE( buf ); + + memset( &addr, 0, sizeof(addr) ); + addr.sin_family = WS_AF_INET; + if (ConvertLengthToIpv4Mask( address->OnLinkPrefixLength, &addr.sin_addr.S_un.S_addr ) != NO_ERROR + || WSAAddressToStringW( (SOCKADDR*)&addr, sizeof(addr), NULL, buf, &buflen)) + ptr[i] = NULL; + else + ptr[i] = heap_strdupW( buf ); + } + else + { + static const WCHAR fmtW[] = {'%','u',0}; + WCHAR buf[11]; + + sprintfW(buf, fmtW, address->OnLinkPrefixLength); + ptr[i] = heap_strdupW( buf ); + } + if (!ptr[i++]) + { + for (; i > 0; i--) heap_free( ptr[i - 1] ); + heap_free( ptr ); + heap_free( ret ); + return NULL; + } + } + ret->count = count; + ret->ptr = ptr; + return ret; +} + +#endif /* !__REACTOS__ */ + static WCHAR *get_settingid( UINT32 index ) { GUID guid; @@ -2499,8 +2616,14 @@ static enum fill_status fill_networkadapterconfig( struct table *table, const st rec->dnshostname = get_dnshostname( aa->FirstUnicastAddress ); rec->dnsserversearchorder = get_dnsserversearchorder( aa->FirstDnsServerAddress ); rec->index = aa->u.s.IfIndex; +#ifndef __REACTOS__ + rec->ipaddress = get_ipaddress( aa->FirstUnicastAddress ); +#endif rec->ipconnectionmetric = 20; rec->ipenabled = -1; +#ifndef __REACTOS__ + rec->ipsubnet = get_ipsubnet( aa->FirstUnicastAddress ); +#endif rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength ); rec->settingid = get_settingid( rec->index ); if (!match_row( table, row, cond, &status )) @@ -2537,6 +2660,53 @@ static enum fill_status fill_physicalmemory( struct table *table, const struct e return status; } +static enum fill_status fill_pnpentity( struct table *table, const struct expr *cond ) +{ + struct record_pnpentity *rec; + enum fill_status status = FILL_STATUS_UNFILTERED; + HDEVINFO device_info_set; + SP_DEVINFO_DATA devinfo = {0}; + DWORD idx; + + device_info_set = SetupDiGetClassDevsW( NULL, NULL, NULL, DIGCF_ALLCLASSES|DIGCF_PRESENT ); + + devinfo.cbSize = sizeof(devinfo); + + idx = 0; + while (SetupDiEnumDeviceInfo( device_info_set, idx++, &devinfo )) + { + /* noop */ + } + + resize_table( table, idx, sizeof(*rec) ); + table->num_rows = 0; + rec = (struct record_pnpentity *)table->data; + + idx = 0; + while (SetupDiEnumDeviceInfo( device_info_set, idx++, &devinfo )) + { + WCHAR device_id[MAX_PATH]; + if (SetupDiGetDeviceInstanceIdW( device_info_set, &devinfo, device_id, + ARRAY_SIZE(device_id), NULL )) + { + rec->device_id = heap_strdupW( device_id ); + + table->num_rows++; + if (!match_row( table, table->num_rows - 1, cond, &status )) + { + free_row_values( table, table->num_rows - 1 ); + table->num_rows--; + } + else + rec++; + } + } + + SetupDiDestroyDeviceInfoList( device_info_set ); + + return status; +} + static enum fill_status fill_printer( struct table *table, const struct expr *cond ) { static const WCHAR fmtW[] = {'P','r','i','n','t','e','r','%','d',0}; @@ -2928,7 +3098,7 @@ static WCHAR *get_oscaption( OSVERSIONINFOEXW *ver ) {'8','.','1',' ','P','r','o',0}; static const WCHAR win10W[] = {'1','0',' ','P','r','o',0}; - int len = sizeof(windowsW)/sizeof(windowsW[0]); + int len = ARRAY_SIZE( windowsW ); WCHAR *ret; if (!(ret = heap_alloc( len * sizeof(WCHAR) + sizeof(win2003W) ))) return NULL; @@ -3110,7 +3280,7 @@ static enum fill_status fill_service( struct table *table, const struct expr *co ENUM_SERVICE_STATUS_PROCESSW *tmp, *services = NULL; SERVICE_STATUS_PROCESS *status; WCHAR sysnameW[MAX_COMPUTERNAME_LENGTH + 1]; - DWORD len = sizeof(sysnameW) / sizeof(sysnameW[0]); + DWORD len = ARRAY_SIZE( sysnameW ); UINT i, row = 0, offset = 0, size = 256, needed, count; enum fill_status fill_status = FILL_STATUS_FAILED; BOOL ret; @@ -3391,39 +3561,40 @@ done: static struct table builtin_classes[] = { - { class_baseboardW, SIZEOF(col_baseboard), col_baseboard, SIZEOF(data_baseboard), 0, (BYTE *)data_baseboard }, - { class_biosW, SIZEOF(col_bios), col_bios, SIZEOF(data_bios), 0, (BYTE *)data_bios }, - { class_cdromdriveW, SIZEOF(col_cdromdrive), col_cdromdrive, 0, 0, NULL, fill_cdromdrive }, - { class_compsysW, SIZEOF(col_compsys), col_compsys, 0, 0, NULL, fill_compsys }, - { class_compsysproductW, SIZEOF(col_compsysproduct), col_compsysproduct, 0, 0, NULL, fill_compsysproduct }, - { class_datafileW, SIZEOF(col_datafile), col_datafile, 0, 0, NULL, fill_datafile }, - { class_desktopmonitorW, SIZEOF(col_desktopmonitor), col_desktopmonitor, 0, 0, NULL, fill_desktopmonitor }, - { class_directoryW, SIZEOF(col_directory), col_directory, 0, 0, NULL, fill_directory }, - { class_diskdriveW, SIZEOF(col_diskdrive), col_diskdrive, 0, 0, NULL, fill_diskdrive }, - { class_diskpartitionW, SIZEOF(col_diskpartition), col_diskpartition, 0, 0, NULL, fill_diskpartition }, - { class_ip4routetableW, SIZEOF(col_ip4routetable), col_ip4routetable, 0, 0, NULL, fill_ip4routetable }, - { class_logicaldiskW, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk }, - { class_logicaldisk2W, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk }, - { class_networkadapterW, SIZEOF(col_networkadapter), col_networkadapter, 0, 0, NULL, fill_networkadapter }, - { class_networkadapterconfigW, SIZEOF(col_networkadapterconfig), col_networkadapterconfig, 0, 0, NULL, fill_networkadapterconfig }, - { class_osW, SIZEOF(col_os), col_os, 0, 0, NULL, fill_os }, - { class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), 0, (BYTE *)data_param }, - { class_physicalmediaW, SIZEOF(col_physicalmedia), col_physicalmedia, SIZEOF(data_physicalmedia), 0, (BYTE *)data_physicalmedia }, - { class_physicalmemoryW, SIZEOF(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory }, - { class_printerW, SIZEOF(col_printer), col_printer, 0, 0, NULL, fill_printer }, - { class_processW, SIZEOF(col_process), col_process, 0, 0, NULL, fill_process }, - { class_processorW, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor }, - { class_processor2W, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor }, - { class_qualifiersW, SIZEOF(col_qualifier), col_qualifier, SIZEOF(data_qualifier), 0, (BYTE *)data_qualifier }, - { class_serviceW, SIZEOF(col_service), col_service, 0, 0, NULL, fill_service }, - { class_sidW, SIZEOF(col_sid), col_sid, 0, 0, NULL, fill_sid }, - { class_sounddeviceW, SIZEOF(col_sounddevice), col_sounddevice, SIZEOF(data_sounddevice), 0, (BYTE *)data_sounddevice }, - { class_stdregprovW, SIZEOF(col_stdregprov), col_stdregprov, SIZEOF(data_stdregprov), 0, (BYTE *)data_stdregprov }, - { class_systemsecurityW, SIZEOF(col_systemsecurity), col_systemsecurity, SIZEOF(data_systemsecurity), 0, (BYTE *)data_systemsecurity }, - { class_systemenclosureW, SIZEOF(col_systemenclosure), col_systemenclosure, SIZEOF(data_systemenclosure), 0, (BYTE *)data_systemenclosure }, + { class_baseboardW, ARRAY_SIZE(col_baseboard), col_baseboard, ARRAY_SIZE(data_baseboard), 0, (BYTE *)data_baseboard }, + { class_biosW, ARRAY_SIZE(col_bios), col_bios, ARRAY_SIZE(data_bios), 0, (BYTE *)data_bios }, + { class_cdromdriveW, ARRAY_SIZE(col_cdromdrive), col_cdromdrive, 0, 0, NULL, fill_cdromdrive }, + { class_compsysW, ARRAY_SIZE(col_compsys), col_compsys, 0, 0, NULL, fill_compsys }, + { class_compsysproductW, ARRAY_SIZE(col_compsysproduct), col_compsysproduct, 0, 0, NULL, fill_compsysproduct }, + { class_datafileW, ARRAY_SIZE(col_datafile), col_datafile, 0, 0, NULL, fill_datafile }, + { class_desktopmonitorW, ARRAY_SIZE(col_desktopmonitor), col_desktopmonitor, 0, 0, NULL, fill_desktopmonitor }, + { class_directoryW, ARRAY_SIZE(col_directory), col_directory, 0, 0, NULL, fill_directory }, + { class_diskdriveW, ARRAY_SIZE(col_diskdrive), col_diskdrive, 0, 0, NULL, fill_diskdrive }, + { class_diskpartitionW, ARRAY_SIZE(col_diskpartition), col_diskpartition, 0, 0, NULL, fill_diskpartition }, + { class_ip4routetableW, ARRAY_SIZE(col_ip4routetable), col_ip4routetable, 0, 0, NULL, fill_ip4routetable }, + { class_logicaldiskW, ARRAY_SIZE(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk }, + { class_logicaldisk2W, ARRAY_SIZE(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk }, + { class_networkadapterW, ARRAY_SIZE(col_networkadapter), col_networkadapter, 0, 0, NULL, fill_networkadapter }, + { class_networkadapterconfigW, ARRAY_SIZE(col_networkadapterconfig), col_networkadapterconfig, 0, 0, NULL, fill_networkadapterconfig }, + { class_osW, ARRAY_SIZE(col_os), col_os, 0, 0, NULL, fill_os }, + { class_paramsW, ARRAY_SIZE(col_param), col_param, ARRAY_SIZE(data_param), 0, (BYTE *)data_param }, + { class_physicalmediaW, ARRAY_SIZE(col_physicalmedia), col_physicalmedia, ARRAY_SIZE(data_physicalmedia), 0, (BYTE *)data_physicalmedia }, + { class_physicalmemoryW, ARRAY_SIZE(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory }, + { class_pnpentityW, ARRAY_SIZE(col_pnpentity), col_pnpentity, 0, 0, NULL, fill_pnpentity }, + { class_printerW, ARRAY_SIZE(col_printer), col_printer, 0, 0, NULL, fill_printer }, + { class_processW, ARRAY_SIZE(col_process), col_process, 0, 0, NULL, fill_process }, + { class_processorW, ARRAY_SIZE(col_processor), col_processor, 0, 0, NULL, fill_processor }, + { class_processor2W, ARRAY_SIZE(col_processor), col_processor, 0, 0, NULL, fill_processor }, + { class_qualifiersW, ARRAY_SIZE(col_qualifier), col_qualifier, ARRAY_SIZE(data_qualifier), 0, (BYTE *)data_qualifier }, + { class_serviceW, ARRAY_SIZE(col_service), col_service, 0, 0, NULL, fill_service }, + { class_sidW, ARRAY_SIZE(col_sid), col_sid, 0, 0, NULL, fill_sid }, + { class_sounddeviceW, ARRAY_SIZE(col_sounddevice), col_sounddevice, ARRAY_SIZE(data_sounddevice), 0, (BYTE *)data_sounddevice }, + { class_stdregprovW, ARRAY_SIZE(col_stdregprov), col_stdregprov, ARRAY_SIZE(data_stdregprov), 0, (BYTE *)data_stdregprov }, + { class_systemsecurityW, ARRAY_SIZE(col_systemsecurity), col_systemsecurity, ARRAY_SIZE(data_systemsecurity), 0, (BYTE *)data_systemsecurity }, + { class_systemenclosureW, ARRAY_SIZE(col_systemenclosure), col_systemenclosure, ARRAY_SIZE(data_systemenclosure), 0, (BYTE *)data_systemenclosure }, #ifndef __REACTOS__ /* Requires dxgi.dll */ - { class_videocontrollerW, SIZEOF(col_videocontroller), col_videocontroller, 0, 0, NULL, fill_videocontroller } + { class_videocontrollerW, ARRAY_SIZE(col_videocontroller), col_videocontroller, 0, 0, NULL, fill_videocontroller } #endif }; @@ -3432,6 +3603,6 @@ void init_table_list( void ) static struct list tables = LIST_INIT( tables ); UINT i; - for (i = 0; i < SIZEOF(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry ); + for (i = 0; i < ARRAY_SIZE(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry ); table_list = &tables; } diff --git a/dll/win32/wbemprox/class.c b/dll/win32/wbemprox/class.c index 27229bd69a..a005204791 100644 --- a/dll/win32/wbemprox/class.c +++ b/dll/win32/wbemprox/class.c @@ -532,8 +532,11 @@ static HRESULT WINAPI class_object_Next( SysFreeString( prop ); return hr; } + obj->index_property = i + 1; - *strName = prop; + if (strName) *strName = prop; + else SysFreeString( prop ); + return S_OK; } return WBEM_S_NO_MORE_DATA; @@ -582,7 +585,7 @@ static BSTR get_body_text( const struct table *table, UINT row, UINT *len ) { if ((value = get_value_bstr( table, row, i ))) { - *len += sizeof(fmtW) / sizeof(fmtW[0]); + *len += ARRAY_SIZE( fmtW ); *len += strlenW( table->columns[i].name ); *len += SysStringLen( value ); SysFreeString( value ); @@ -608,7 +611,7 @@ static BSTR get_object_text( const struct view *view, UINT index ) UINT len, len_body, row = view->result[index]; BSTR ret, body; - len = sizeof(fmtW) / sizeof(fmtW[0]); + len = ARRAY_SIZE( fmtW ); len += strlenW( view->table->name ); if (!(body = get_body_text( view->table, row, &len_body ))) return NULL; len += len_body; @@ -804,7 +807,7 @@ static WCHAR *build_signature_table_name( const WCHAR *class, const WCHAR *metho static const WCHAR fmtW[] = {'_','_','%','s','_','%','s','_','%','s',0}; static const WCHAR outW[] = {'O','U','T',0}; static const WCHAR inW[] = {'I','N',0}; - UINT len = SIZEOF(fmtW) + SIZEOF(outW) + strlenW( class ) + strlenW( method ); + UINT len = ARRAY_SIZE(fmtW) + ARRAY_SIZE(outW) + strlenW( class ) + strlenW( method ); WCHAR *ret; if (!(ret = heap_alloc( len * sizeof(WCHAR) ))) return NULL; @@ -823,7 +826,7 @@ HRESULT create_signature( const WCHAR *class, const WCHAR *method, enum param_di 'D','i','r','e','c','t','i','o','n','%','s',0}; static const WCHAR geW[] = {'>','=','0',0}; static const WCHAR leW[] = {'<','=','0',0}; - UINT len = SIZEOF(selectW) + SIZEOF(geW); + UINT len = ARRAY_SIZE(selectW) + ARRAY_SIZE(geW); IEnumWbemClassObject *iter; WCHAR *query, *name; HRESULT hr; @@ -836,6 +839,13 @@ HRESULT create_signature( const WCHAR *class, const WCHAR *method, enum param_di heap_free( query ); if (hr != S_OK) return hr; + if (!count_instances( iter )) + { + *sig = NULL; + IEnumWbemClassObject_Release( iter ); + return S_OK; + } + if (!(name = build_signature_table_name( class, method, dir ))) { IEnumWbemClassObject_Release( iter ); @@ -870,9 +880,9 @@ static HRESULT WINAPI class_object_GetMethod( if (hr == S_OK) { if (ppInSignature) *ppInSignature = in; - else IWbemClassObject_Release( in ); + else if (in) IWbemClassObject_Release( in ); if (ppOutSignature) *ppOutSignature = out; - else IWbemClassObject_Release( out ); + else if (out) IWbemClassObject_Release( out ); } else IWbemClassObject_Release( in ); return hr; @@ -907,11 +917,6 @@ static HRESULT WINAPI class_object_BeginMethodEnumeration( if (lEnumFlags) FIXME("flags 0x%08x not supported\n", lEnumFlags); - if (co->iter) - { - WARN("not allowed on instance\n"); - return WBEM_E_ILLEGAL_OPERATION; - } co->index_method = 0; return S_OK; } @@ -941,7 +946,8 @@ static HRESULT WINAPI class_object_NextMethod( if (hr != S_OK) { SysFreeString( method ); - IWbemClassObject_Release( *ppInSignature ); + if (*ppInSignature) + IWbemClassObject_Release( *ppInSignature ); } else { diff --git a/dll/win32/wbemprox/qualifier.c b/dll/win32/wbemprox/qualifier.c index 4da34454ae..06dcc59e31 100644 --- a/dll/win32/wbemprox/qualifier.c +++ b/dll/win32/wbemprox/qualifier.c @@ -109,8 +109,8 @@ static HRESULT create_qualifier_enum( const WCHAR *class, const WCHAR *member, c if (!member) member = noneW; len = strlenW( class ) + strlenW( member ); - if (name) len += strlenW( name ) + SIZEOF(fmtW); - else len += SIZEOF(fmt2W); + if (name) len += strlenW( name ) + ARRAY_SIZE(fmtW); + else len += ARRAY_SIZE(fmt2W); if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return E_OUTOFMEMORY; if (name) sprintfW( query, fmtW, class, member, name ); diff --git a/dll/win32/wbemprox/query.c b/dll/win32/wbemprox/query.c index 76f5caa634..d193574a39 100644 --- a/dll/win32/wbemprox/query.c +++ b/dll/win32/wbemprox/query.c @@ -507,7 +507,7 @@ static BOOL is_system_prop( const WCHAR *name ) static BSTR build_servername( const struct view *view ) { WCHAR server[MAX_COMPUTERNAME_LENGTH + 1], *p; - DWORD len = sizeof(server)/sizeof(server[0]); + DWORD len = ARRAY_SIZE( server ); if (view->proplist) return NULL; @@ -668,50 +668,71 @@ static HRESULT get_system_propval( const struct view *view, UINT index, const WC if (!strcmpiW( name, classW )) { - V_VT( ret ) = VT_BSTR; - V_BSTR( ret ) = build_classname( view ); + if (ret) + { + V_VT( ret ) = VT_BSTR; + V_BSTR( ret ) = build_classname( view ); + } if (type) *type = CIM_STRING; return S_OK; } if (!strcmpiW( name, genusW )) { - V_VT( ret ) = VT_I4; - V_I4( ret ) = WBEM_GENUS_INSTANCE; /* FIXME */ + if (ret) + { + V_VT( ret ) = VT_I4; + V_I4( ret ) = WBEM_GENUS_INSTANCE; /* FIXME */ + } if (type) *type = CIM_SINT32; return S_OK; } else if (!strcmpiW( name, namespaceW )) { - V_VT( ret ) = VT_BSTR; - V_BSTR( ret ) = build_namespace( view ); + if (ret) + { + V_VT( ret ) = VT_BSTR; + V_BSTR( ret ) = build_namespace( view ); + } if (type) *type = CIM_STRING; return S_OK; } else if (!strcmpiW( name, pathW )) { - V_VT( ret ) = VT_BSTR; - V_BSTR( ret ) = build_path( view, index, name ); + if (ret) + { + V_VT( ret ) = VT_BSTR; + V_BSTR( ret ) = build_path( view, index, name ); + } if (type) *type = CIM_STRING; return S_OK; } if (!strcmpiW( name, propcountW )) { - V_VT( ret ) = VT_I4; - V_I4( ret ) = count_selected_properties( view ); + if (ret) + { + V_VT( ret ) = VT_I4; + V_I4( ret ) = count_selected_properties( view ); + } if (type) *type = CIM_SINT32; return S_OK; } else if (!strcmpiW( name, relpathW )) { - V_VT( ret ) = VT_BSTR; - V_BSTR( ret ) = build_relpath( view, index, name ); + if (ret) + { + V_VT( ret ) = VT_BSTR; + V_BSTR( ret ) = build_relpath( view, index, name ); + } if (type) *type = CIM_STRING; return S_OK; } else if (!strcmpiW( name, serverW )) { - V_VT( ret ) = VT_BSTR; - V_BSTR( ret ) = build_servername( view ); + if (ret) + { + V_VT( ret ) = VT_BSTR; + V_BSTR( ret ) = build_servername( view ); + } if (type) *type = CIM_STRING; return S_OK; } @@ -835,6 +856,11 @@ HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VAR hr = get_value( view->table, row, column, &val ); if (hr != S_OK) return hr; + if (type) *type = view->table->columns[column].type & COL_TYPE_MASK; + if (flavor) *flavor = 0; + + if (!ret) return S_OK; + vartype = view->table->columns[column].vartype; if (view->table->columns[column].type & CIM_FLAG_ARRAY) { @@ -843,8 +869,10 @@ HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VAR val_ptr = to_safearray( (const struct array *)(INT_PTR)val, basetype ); if (!val_ptr) vartype = VT_NULL; else if (!vartype) vartype = to_vartype( basetype ) | VT_ARRAY; - goto done; + set_variant( vartype, val, val_ptr, ret ); + return S_OK; } + switch (view->table->columns[column].type & COL_TYPE_MASK) { case CIM_BOOLEAN: @@ -891,10 +919,7 @@ HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VAR return WBEM_E_FAILED; } -done: set_variant( vartype, val, val_ptr, ret ); - if (type) *type = view->table->columns[column].type & COL_TYPE_MASK; - if (flavor) *flavor = 0; return S_OK; } diff --git a/dll/win32/wbemprox/reg.c b/dll/win32/wbemprox/reg.c index b0bacd7ab8..c45cbbef78 100644 --- a/dll/win32/wbemprox/reg.c +++ b/dll/win32/wbemprox/reg.c @@ -80,13 +80,74 @@ static HRESULT to_i4_array( DWORD *values, DWORD count, VARIANT *var ) return S_OK; } +static HRESULT create_key( HKEY root, const WCHAR *subkey, VARIANT *retval ) +{ + LONG res; + HKEY hkey; + + TRACE("%p, %s\n", root, debugstr_w(subkey)); + + res = RegCreateKeyExW( root, subkey, 0, NULL, 0, 0, NULL, &hkey, NULL ); + set_variant( VT_UI4, res, NULL, retval ); + if (!res) + { + RegCloseKey( hkey ); + return S_OK; + } + return HRESULT_FROM_WIN32( res ); +} + +HRESULT reg_create_key( IWbemClassObject *obj, IWbemClassObject *in, IWbemClassObject **out ) +{ + VARIANT defkey, subkey, retval; + IWbemClassObject *sig, *out_params = NULL; + HRESULT hr; + + TRACE("%p, %p\n", in, out); + + hr = IWbemClassObject_Get( in, param_defkeyW, 0, &defkey, NULL, NULL ); + if (hr != S_OK) return hr; + hr = IWbemClassObject_Get( in, param_subkeynameW, 0, &subkey, NULL, NULL ); + if (hr != S_OK) return hr; + + hr = create_signature( class_stdregprovW, method_createkeyW, PARAM_OUT, &sig ); + if (hr != S_OK) + { + VariantClear( &subkey ); + return hr; + } + if (out) + { + hr = IWbemClassObject_SpawnInstance( sig, 0, &out_params ); + if (hr != S_OK) + { + VariantClear( &subkey ); + IWbemClassObject_Release( sig ); + return hr; + } + } + hr = create_key( (HKEY)(INT_PTR)V_I4(&defkey), V_BSTR(&subkey), &retval ); + if (hr == S_OK && out_params) + hr = IWbemClassObject_Put( out_params, param_returnvalueW, 0, &retval, CIM_UINT32 ); + + VariantClear( &subkey ); + IWbemClassObject_Release( sig ); + if (hr == S_OK && out) + { + *out = out_params; + IWbemClassObject_AddRef( out_params ); + } + if (out_params) IWbemClassObject_Release( out_params ); + return hr; +} + static HRESULT enum_key( HKEY root, const WCHAR *subkey, VARIANT *names, VARIANT *retval ) { HKEY hkey; HRESULT hr = S_OK; WCHAR buf[256]; BSTR *strings, *tmp; - DWORD count = 2, len = sizeof(buf)/sizeof(buf[0]); + DWORD count = 2, len = ARRAY_SIZE( buf ); LONG res, i = 0; TRACE("%p, %s\n", root, debugstr_w(subkey)); diff --git a/dll/win32/wbemprox/services.c b/dll/win32/wbemprox/services.c index fd87feb12e..599a421ced 100644 --- a/dll/win32/wbemprox/services.c +++ b/dll/win32/wbemprox/services.c @@ -338,15 +338,46 @@ static HRESULT parse_path( const WCHAR *str, struct path **ret ) if (!(path = heap_alloc_zero( sizeof(*path) ))) return E_OUTOFMEMORY; + if (*p == '\\') + { + static const WCHAR cimv2W[] = {'R','O','O','T','\\','C','I','M','V','2'}; + + WCHAR server[MAX_COMPUTERNAME_LENGTH+1]; + DWORD server_len = ARRAY_SIZE(server); + + p++; + if (*p != '\\') return WBEM_E_INVALID_OBJECT_PATH; + p++; + + q = p; + while (*p && *p != '\\') p++; + if (!*p) return WBEM_E_INVALID_OBJECT_PATH; + + len = p - q; + if (!GetComputerNameW( server, &server_len ) || server_len != len + || memcmp( q, server, server_len * sizeof(WCHAR) )) + return WBEM_E_NOT_SUPPORTED; + + q = ++p; + while (*p && *p != ':') p++; + if (!*p) return WBEM_E_INVALID_OBJECT_PATH; + + len = p - q; + if (len != ARRAY_SIZE(cimv2W) || memcmp( q, cimv2W, sizeof(cimv2W) )) + return WBEM_E_INVALID_NAMESPACE; + p++; + } + + q = p; while (*p && *p != '.') p++; - len = p - str; + len = p - q; if (!(path->class = heap_alloc( (len + 1) * sizeof(WCHAR) ))) { heap_free( path ); return E_OUTOFMEMORY; } - memcpy( path->class, str, len * sizeof(WCHAR) ); + memcpy( path->class, q, len * sizeof(WCHAR) ); path->class[len] = 0; path->class_len = len; @@ -389,13 +420,13 @@ static WCHAR *query_from_path( const struct path *path ) if (path->filter) { - len = path->class_len + path->filter_len + SIZEOF(selectW); + len = path->class_len + path->filter_len + ARRAY_SIZE(selectW); if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return NULL; sprintfW( query, selectW, path->class, path->filter ); } else { - len = path->class_len + SIZEOF(select_allW); + len = path->class_len + ARRAY_SIZE(select_allW); if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return NULL; strcpyW( query, select_allW ); strcatW( query, path->class ); diff --git a/dll/win32/wbemprox/wbemlocator.c b/dll/win32/wbemprox/wbemlocator.c index 6ed0aed59e..fe26a871b5 100644 --- a/dll/win32/wbemprox/wbemlocator.c +++ b/dll/win32/wbemprox/wbemlocator.c @@ -91,7 +91,7 @@ static BOOL is_local_machine( const WCHAR *server ) static const WCHAR dotW[] = {'.',0}; static const WCHAR localhostW[] = {'l','o','c','a','l','h','o','s','t',0}; WCHAR buffer[MAX_COMPUTERNAME_LENGTH + 1]; - DWORD len = sizeof(buffer) / sizeof(buffer[0]); + DWORD len = ARRAY_SIZE( buffer ); if (!server || !strcmpW( server, dotW ) || !strcmpiW( server, localhostW )) return TRUE; if (GetComputerNameW( buffer, &len ) && !strcmpiW( server, buffer )) return TRUE; @@ -133,7 +133,7 @@ static HRESULT parse_resource( const WCHAR *resource, WCHAR **server, WCHAR **na p = q; while (*q && *q != '\\' && *q != '/') q++; len = q - p; - if (len >= sizeof(rootW) / sizeof(rootW[0]) && memicmpW( rootW, p, len )) goto done; + if (len >= ARRAY_SIZE( rootW ) && memicmpW( rootW, p, len )) goto done; if (!*q) { hr = S_OK; @@ -141,8 +141,8 @@ static HRESULT parse_resource( const WCHAR *resource, WCHAR **server, WCHAR **na } q++; len = strlenW( q ); - if ((len != sizeof(cimv2W) / sizeof(cimv2W[0]) || memicmpW( q, cimv2W, len )) && - (len != sizeof(defaultW) / sizeof(defaultW[0]) || memicmpW( q, defaultW, len ))) + if ((len != ARRAY_SIZE( cimv2W ) || memicmpW( q, cimv2W, len )) && + (len != ARRAY_SIZE( defaultW ) || memicmpW( q, defaultW, len ))) goto done; if (!(*namespace = heap_alloc( (len + 1) * sizeof(WCHAR) ))) hr = E_OUTOFMEMORY; else diff --git a/dll/win32/wbemprox/wbemprox_private.h b/dll/win32/wbemprox/wbemprox_private.h index a2696bb459..596ad21d51 100644 --- a/dll/win32/wbemprox/wbemprox_private.h +++ b/dll/win32/wbemprox/wbemprox_private.h @@ -26,8 +26,6 @@ IClientSecurity client_security DECLSPEC_HIDDEN; struct list *table_list DECLSPEC_HIDDEN; -#define SIZEOF(array) (sizeof(array)/sizeof((array)[0])) - enum param_direction { PARAM_OUT = -1, @@ -220,6 +218,7 @@ HRESULT EnumWbemClassObject_create(struct query *, LPVOID *) DECLSPEC_HIDDEN; HRESULT WbemQualifierSet_create(const WCHAR *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN; HRESULT process_get_owner(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN; +HRESULT reg_create_key(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN; HRESULT reg_enum_key(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN; HRESULT reg_enum_values(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN; HRESULT reg_get_stringvalue(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN; @@ -245,6 +244,7 @@ static const WCHAR class_systemsecurityW[] = {'_','_','S','y','s','t','e','m','S static const WCHAR prop_nameW[] = {'N','a','m','e',0}; +static const WCHAR method_createkeyW[] = {'C','r','e','a','t','e','K','e','y',0}; static const WCHAR method_enumkeyW[] = {'E','n','u','m','K','e','y',0}; static const WCHAR method_enumvaluesW[] = {'E','n','u','m','V','a','l','u','e','s',0}; static const WCHAR method_getownerW[] = {'G','e','t','O','w','n','e','r',0}; diff --git a/dll/win32/wbemprox/wql.tab.c b/dll/win32/wbemprox/wql.tab.c index 13baba575c..42e8232854 100644 --- a/dll/win32/wbemprox/wql.tab.c +++ b/dll/win32/wbemprox/wql.tab.c @@ -2155,18 +2155,18 @@ static const WCHAR whereW[] = {'W','H','E','R','E'}; static const struct keyword keyword_table[] = { - { andW, SIZEOF(andW), TK_AND }, - { byW, SIZEOF(byW), TK_BY }, - { falseW, SIZEOF(falseW), TK_FALSE }, - { fromW, SIZEOF(fromW), TK_FROM }, - { isW, SIZEOF(isW), TK_IS }, - { likeW, SIZEOF(likeW), TK_LIKE }, - { notW, SIZEOF(notW), TK_NOT }, - { nullW, SIZEOF(nullW), TK_NULL }, - { orW, SIZEOF(orW), TK_OR }, - { selectW, SIZEOF(selectW), TK_SELECT }, - { trueW, SIZEOF(trueW), TK_TRUE }, - { whereW, SIZEOF(whereW), TK_WHERE } + { andW, ARRAY_SIZE(andW), TK_AND }, + { byW, ARRAY_SIZE(byW), TK_BY }, + { falseW, ARRAY_SIZE(falseW), TK_FALSE }, + { fromW, ARRAY_SIZE(fromW), TK_FROM }, + { isW, ARRAY_SIZE(isW), TK_IS }, + { likeW, ARRAY_SIZE(likeW), TK_LIKE }, + { notW, ARRAY_SIZE(notW), TK_NOT }, + { nullW, ARRAY_SIZE(nullW), TK_NULL }, + { orW, ARRAY_SIZE(orW), TK_OR }, + { selectW, ARRAY_SIZE(selectW), TK_SELECT }, + { trueW, ARRAY_SIZE(trueW), TK_TRUE }, + { whereW, ARRAY_SIZE(whereW), TK_WHERE } }; static int cmp_keyword( const void *arg1, const void *arg2 ) @@ -2190,7 +2190,7 @@ static int keyword_type( const WCHAR *str, unsigned int len ) key.name = str; key.len = len; key.type = 0; - ret = bsearch( &key, keyword_table, SIZEOF(keyword_table), sizeof(struct keyword), cmp_keyword ); + ret = bsearch( &key, keyword_table, ARRAY_SIZE(keyword_table), sizeof(struct keyword), cmp_keyword ); if (ret) return ret->type; return TK_ID; } diff --git a/dll/win32/wbemprox/wql.y b/dll/win32/wbemprox/wql.y index 88da2b9b0f..0c48c98b73 100644 --- a/dll/win32/wbemprox/wql.y +++ b/dll/win32/wbemprox/wql.y @@ -559,18 +559,18 @@ static const WCHAR whereW[] = {'W','H','E','R','E'}; static const struct keyword keyword_table[] = { - { andW, SIZEOF(andW), TK_AND }, - { byW, SIZEOF(byW), TK_BY }, - { falseW, SIZEOF(falseW), TK_FALSE }, - { fromW, SIZEOF(fromW), TK_FROM }, - { isW, SIZEOF(isW), TK_IS }, - { likeW, SIZEOF(likeW), TK_LIKE }, - { notW, SIZEOF(notW), TK_NOT }, - { nullW, SIZEOF(nullW), TK_NULL }, - { orW, SIZEOF(orW), TK_OR }, - { selectW, SIZEOF(selectW), TK_SELECT }, - { trueW, SIZEOF(trueW), TK_TRUE }, - { whereW, SIZEOF(whereW), TK_WHERE } + { andW, ARRAY_SIZE(andW), TK_AND }, + { byW, ARRAY_SIZE(byW), TK_BY }, + { falseW, ARRAY_SIZE(falseW), TK_FALSE }, + { fromW, ARRAY_SIZE(fromW), TK_FROM }, + { isW, ARRAY_SIZE(isW), TK_IS }, + { likeW, ARRAY_SIZE(likeW), TK_LIKE }, + { notW, ARRAY_SIZE(notW), TK_NOT }, + { nullW, ARRAY_SIZE(nullW), TK_NULL }, + { orW, ARRAY_SIZE(orW), TK_OR }, + { selectW, ARRAY_SIZE(selectW), TK_SELECT }, + { trueW, ARRAY_SIZE(trueW), TK_TRUE }, + { whereW, ARRAY_SIZE(whereW), TK_WHERE } }; static int cmp_keyword( const void *arg1, const void *arg2 ) @@ -594,7 +594,7 @@ static int keyword_type( const WCHAR *str, unsigned int len ) key.name = str; key.len = len; key.type = 0; - ret = bsearch( &key, keyword_table, SIZEOF(keyword_table), sizeof(struct keyword), cmp_keyword ); + ret = bsearch( &key, keyword_table, ARRAY_SIZE(keyword_table), sizeof(struct keyword), cmp_keyword ); if (ret) return ret->type; return TK_ID; } diff --git a/media/doc/README.WINE b/media/doc/README.WINE index f81e450da1..218b028e45 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -195,7 +195,7 @@ reactos/dll/win32/vbscript # Synced to WineStaging-4.0 reactos/dll/win32/version # Synced to WineStaging-4.0 reactos/dll/win32/vssapi # Synced to WineStaging-2.9 reactos/dll/win32/wbemdisp # Synced to WineStaging-4.0 -reactos/dll/win32/wbemprox # Synced to WineStaging-3.9 +reactos/dll/win32/wbemprox # Synced to WineStaging-4.0 reactos/dll/win32/windowscodecs # Synced to WineStaging-3.9 reactos/dll/win32/windowscodecsext # Synced to WineStaging-2.9 reactos/dll/win32/winemp3.acm # Synced to WineStaging-3.3
5 years, 10 months
1
0
0
0
[reactos] 01/01: [WBEMDISP_WINETEST] Sync with Wine Staging 4.0. CORE-15682
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e054ebd54c9bf0b407811…
commit e054ebd54c9bf0b4078110cd4c74896e55fac8f2 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Feb 4 13:10:24 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Feb 4 13:10:24 2019 +0100 [WBEMDISP_WINETEST] Sync with Wine Staging 4.0. CORE-15682 --- modules/rostests/winetests/wbemdisp/wbemdisp.c | 94 ++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 5 deletions(-) diff --git a/modules/rostests/winetests/wbemdisp/wbemdisp.c b/modules/rostests/winetests/wbemdisp/wbemdisp.c index 0c426c569a..57baf848cc 100644 --- a/modules/rostests/winetests/wbemdisp/wbemdisp.c +++ b/modules/rostests/winetests/wbemdisp/wbemdisp.c @@ -48,6 +48,11 @@ static void test_ParseDisplayName(void) static const WCHAR name4[] = {'w','i','n','m','g','m','t','s',':','\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':', 'W','i','n','3','2','_','S','e','r','v','i','c','e',0}; + static const WCHAR stdregprovW[] = + {'w','i','n','m','g','m','t','s',':','\\','\\','.','\\','r','o','o','t','\\','d','e','f','a','u','l','t',':', + 'S','t','d','R','e','g','P','r','o','v',0}; + static const WCHAR getstringvalueW[] = + {'G','e','t','S','t','r','i','n','g','V','a','l','u','e',0}; static const struct { const WCHAR *name; @@ -56,10 +61,10 @@ static void test_ParseDisplayName(void) ULONG eaten; } tests[] = { - { name1, S_OK, &IID_ISWbemServices, sizeof(name1)/sizeof(name1[0]) - 1 }, - { name2, S_OK, &IID_ISWbemServices, sizeof(name2)/sizeof(name2[0]) - 1 }, - { name3, S_OK, &IID_ISWbemObject, sizeof(name3)/sizeof(name3[0]) - 1 }, - { name4, S_OK, &IID_ISWbemObject, sizeof(name4)/sizeof(name4[0]) - 1 } + { name1, S_OK, &IID_ISWbemServices, ARRAY_SIZE( name1 ) - 1 }, + { name2, S_OK, &IID_ISWbemServices, ARRAY_SIZE( name2 ) - 1 }, + { name3, S_OK, &IID_ISWbemObject, ARRAY_SIZE( name3 ) - 1 }, + { name4, S_OK, &IID_ISWbemObject, ARRAY_SIZE( name4 ) - 1 } }; IParseDisplayName *displayname; IBindCtx *ctx; @@ -79,7 +84,7 @@ static void test_ParseDisplayName(void) hr = CreateBindCtx( 0, &ctx ); ok( hr == S_OK, "got %x\n", hr ); - for (i =0; i < sizeof(tests)/sizeof(tests[0]); i++) + for (i =0; i < ARRAY_SIZE( tests ); i++) { str = SysAllocString( tests[i].name ); eaten = 0xdeadbeef; @@ -242,6 +247,36 @@ static void test_ParseDisplayName(void) } IBindCtx_Release( ctx ); + + hr = CreateBindCtx( 0, &ctx ); + ok( hr == S_OK, "got %x\n", hr ); + + str = SysAllocString( stdregprovW ); + hr = IParseDisplayName_ParseDisplayName( displayname, NULL, str, &eaten, &moniker ); + ok( hr == S_OK, "got %x\n", hr ); + SysFreeString( str ); + + if (moniker) + { + ISWbemObject *sobj = NULL; + hr = IMoniker_BindToObject( moniker, ctx, NULL, &IID_ISWbemObject, (void **)&sobj ); + ok( hr == S_OK, "got %x\n",hr ); + if (sobj) + { + DISPID dispid = 0xdeadbeef; + + str = SysAllocString( getstringvalueW ); + hr = ISWbemObject_GetIDsOfNames( sobj, &IID_NULL, &str, 1, english, &dispid ); + ok( hr == S_OK, "got %x\n", hr ); + ok( dispid == 0x1000001, "got %x\n", dispid ); + + ISWbemObject_Release( sobj ); + SysFreeString( str ); + } + IMoniker_Release( moniker ); + } + + IBindCtx_Release(ctx); IParseDisplayName_Release( displayname ); } @@ -265,7 +300,11 @@ static void test_locator(void) ISWbemObject *object; ISWbemPropertySet *prop_set; ISWbemProperty *prop; + ISWbemSecurity *security; VARIANT var; + LONG count; + WbemImpersonationLevelEnum imp_level; + WbemAuthenticationLevelEnum auth_level; hr = CoCreateInstance( &CLSID_SWbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_ISWbemLocator, (void **)&locator ); ok( hr == S_OK, "got %x\n", hr ); @@ -284,6 +323,34 @@ static void test_locator(void) SysFreeString( lang_bstr ); SysFreeString( query_bstr ); + hr = ISWbemLocator_get_Security_( locator, &security ); + ok( hr == S_OK, "got %x\n", hr ); + imp_level = 0xdeadbeef; + hr = ISWbemSecurity_get_ImpersonationLevel( security, &imp_level ); + ok( hr == S_OK, "got %x\n", hr ); + ok( imp_level == wbemImpersonationLevelImpersonate, "got %u\n", imp_level ); + hr = ISWbemSecurity_put_ImpersonationLevel( security, wbemImpersonationLevelAnonymous ); + ok( hr == S_OK, "got %x\n", hr ); + imp_level = 0xdeadbeef; + hr = ISWbemSecurity_get_ImpersonationLevel( security, &imp_level ); + ok( hr == S_OK, "got %x\n", hr ); + ok( imp_level == wbemImpersonationLevelAnonymous, "got %u\n", imp_level ); + + auth_level = 0xdeadbeef; + hr = ISWbemSecurity_get_AuthenticationLevel( security, &auth_level ); + todo_wine { + ok( hr == WBEM_E_FAILED, "got %x\n", hr ); + ok( auth_level == 0xdeadbeef, "got %u\n", auth_level ); + } + hr = ISWbemSecurity_put_AuthenticationLevel( security, wbemAuthenticationLevelNone ); + ok( hr == S_OK, "got %x\n", hr ); + auth_level = 0xdeadbeef; + hr = ISWbemSecurity_get_AuthenticationLevel( security, &auth_level ); + ok( hr == S_OK, "got %x\n", hr ); + ok( auth_level == wbemAuthenticationLevelNone, "got %u\n", auth_level ); + ISWbemSecurity_Release( security ); + security = NULL; + hr = ISWbemObjectSet_get__NewEnum( object_set, (IUnknown**)&enum_var ); ok( hr == S_OK, "got %x\n", hr ); @@ -313,11 +380,28 @@ static void test_locator(void) ok( hr == S_OK, "got %x\n", hr ); SysFreeString( procid_bstr ); + count = 0; + hr = ISWbemPropertySet_get_Count( prop_set, &count ); + ok( hr == S_OK, "got %x\n", hr ); + ok( count > 0, "got %d\n", count ); + hr = ISWbemProperty_get_Value( prop, &var ); ok( hr == S_OK, "got %x\n", hr ); ok( V_VT(&var) == VT_BSTR, "got %x\n", V_VT(&var) ); VariantClear( &var ); + hr = ISWbemServices_get_Security_( services, &security ); + ok( hr == S_OK, "got %x\n", hr ); + imp_level = 0xdeadbeef; + hr = ISWbemSecurity_get_ImpersonationLevel( security, &imp_level ); + ok( hr == S_OK, "got %x\n", hr ); + ok( imp_level == wbemImpersonationLevelImpersonate, "got %u\n", imp_level ); + auth_level = 0xdeadbeef; + hr = ISWbemSecurity_get_AuthenticationLevel( security, &auth_level ); + ok( hr == S_OK, "got %x\n", hr ); + ok( auth_level == wbemAuthenticationLevelPktPrivacy, "got %u\n", auth_level ); + + ISWbemSecurity_Release(security); ISWbemProperty_Release( prop ); ISWbemPropertySet_Release( prop_set ); ISWbemObject_Release( object );
5 years, 10 months
1
0
0
0
[reactos] 01/01: [WBEMDISP] Sync with Wine Staging 4.0. CORE-15682
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8786e12d134c1ab46b308…
commit 8786e12d134c1ab46b30878a7aab8fa36020eea4 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Feb 4 13:09:55 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Feb 4 13:09:55 2019 +0100 [WBEMDISP] Sync with Wine Staging 4.0. CORE-15682 --- dll/win32/wbemdisp/locator.c | 145 +++++++++++++++++++++++++++++++------------ dll/win32/wbemdisp/main.c | 2 +- media/doc/README.WINE | 2 +- 3 files changed, 106 insertions(+), 43 deletions(-) diff --git a/dll/win32/wbemdisp/locator.c b/dll/win32/wbemdisp/locator.c index 18d735392e..c307e347cf 100644 --- a/dll/win32/wbemdisp/locator.c +++ b/dll/win32/wbemdisp/locator.c @@ -438,8 +438,19 @@ static HRESULT WINAPI propertyset_Item( ISWbemPropertySet *iface, BSTR name, static HRESULT WINAPI propertyset_get_Count( ISWbemPropertySet *iface, LONG *count ) { - FIXME( "\n" ); - return E_NOTIMPL; + static const WCHAR propcountW[] = {'_','_','P','R','O','P','E','R','T','Y','_','C','O','U','N','T',0}; + struct propertyset *propertyset = impl_from_ISWbemPropertySet( iface ); + HRESULT hr; + VARIANT val; + + TRACE( "%p, %p\n", propertyset, count ); + + hr = IWbemClassObject_Get( propertyset->object, propcountW, 0, &val, NULL, NULL ); + if (SUCCEEDED(hr)) + { + *count = V_I4( &val ); + } + return hr; } static HRESULT WINAPI propertyset_Add( ISWbemPropertySet *iface, BSTR name, WbemCimtypeEnum type, @@ -488,11 +499,13 @@ static HRESULT SWbemPropertySet_create( IWbemClassObject *wbem_object, ISWbemPro return S_OK; } -#define DISPID_BASE 0x1800000 +#define DISPID_BASE 0x1800000 +#define DISPID_BASE_METHOD 0x1000000 struct member { BSTR name; + BOOL is_method; DISPID dispid; }; @@ -504,6 +517,7 @@ struct object struct member *members; UINT nb_members; DISPID last_dispid; + DISPID last_dispid_method; }; static inline struct object *impl_from_ISWbemObject( @@ -585,41 +599,83 @@ static HRESULT WINAPI object_GetTypeInfo( static HRESULT init_members( struct object *object ) { - LONG bound, i; - SAFEARRAY *sa; + IWbemClassObject *sig_in, *sig_out; + LONG i = 0, count = 0; + BSTR name; HRESULT hr; if (object->members) return S_OK; - hr = IWbemClassObject_GetNames( object->object, NULL, 0, NULL, &sa ); - if (FAILED( hr )) return hr; - hr = SafeArrayGetUBound( sa, 1, &bound ); - if (FAILED( hr )) + hr = IWbemClassObject_BeginEnumeration( object->object, 0 ); + if (SUCCEEDED( hr )) { - SafeArrayDestroy( sa ); - return hr; + while (IWbemClassObject_Next( object->object, 0, NULL, NULL, NULL, NULL ) == S_OK) count++; + IWbemClassObject_EndEnumeration( object->object ); + } + + hr = IWbemClassObject_BeginMethodEnumeration( object->object, 0 ); + if (SUCCEEDED( hr )) + { + while (IWbemClassObject_NextMethod( object->object, 0, &name, &sig_in, &sig_out ) == S_OK) + { + count++; + SysFreeString( name ); + IWbemClassObject_Release( sig_in ); + IWbemClassObject_Release( sig_out ); + } + IWbemClassObject_EndMethodEnumeration( object->object ); } - if (!(object->members = heap_alloc( sizeof(struct member) * (bound + 1) ))) + + if (!(object->members = heap_alloc( sizeof(struct member) * count ))) return E_OUTOFMEMORY; + + hr = IWbemClassObject_BeginEnumeration( object->object, 0 ); + if (SUCCEEDED( hr )) { - SafeArrayDestroy( sa ); - return E_OUTOFMEMORY; + while (IWbemClassObject_Next( object->object, 0, &name, NULL, NULL, NULL ) == S_OK) + { + object->members[i].name = name; + object->members[i].is_method = FALSE; + object->members[i].dispid = 0; + if (++i > count) + { + IWbemClassObject_EndEnumeration( object->object ); + goto error; + } + TRACE( "added property %s\n", debugstr_w(name) ); + } + IWbemClassObject_EndEnumeration( object->object ); } - for (i = 0; i <= bound; i++) + + hr = IWbemClassObject_BeginMethodEnumeration( object->object, 0 ); + if (SUCCEEDED( hr )) { - hr = SafeArrayGetElement( sa, &i, &object->members[i].name ); - if (FAILED( hr )) + while (IWbemClassObject_NextMethod( object->object, 0, &name, &sig_in, &sig_out ) == S_OK) { - for (i--; i >= 0; i--) SysFreeString( object->members[i].name ); - SafeArrayDestroy( sa ); - heap_free( object->members ); - object->members = NULL; - return E_OUTOFMEMORY; + object->members[i].name = name; + object->members[i].is_method = TRUE; + object->members[i].dispid = 0; + if (++i > count) + { + IWbemClassObject_EndMethodEnumeration( object->object ); + goto error; + } + IWbemClassObject_Release( sig_in ); + IWbemClassObject_Release( sig_out ); + TRACE( "added method %s\n", debugstr_w(name) ); } - object->members[i].dispid = 0; + IWbemClassObject_EndMethodEnumeration( object->object ); } - object->nb_members = bound + 1; - SafeArrayDestroy( sa ); + + object->nb_members = count; + TRACE( "added %u members\n", object->nb_members ); return S_OK; + +error: + for (--i; i >= 0; i--) SysFreeString( object->members[i].name ); + heap_free( object->members ); + object->members = NULL; + object->nb_members = 0; + return E_FAIL; } static DISPID get_member_dispid( struct object *object, const WCHAR *name ) @@ -629,7 +685,13 @@ static DISPID get_member_dispid( struct object *object, const WCHAR *name ) { if (!strcmpiW( object->members[i].name, name )) { - if (!object->members[i].dispid) object->members[i].dispid = ++object->last_dispid; + if (!object->members[i].dispid) + { + if (object->members[i].is_method) + object->members[i].dispid = ++object->last_dispid_method; + else + object->members[i].dispid = ++object->last_dispid; + } return object->members[i].dispid; } } @@ -701,7 +763,7 @@ static HRESULT WINAPI object_Invoke( TRACE( "%p, %x, %s, %u, %x, %p, %p, %p, %p\n", object, member, debugstr_guid(riid), lcid, flags, params, result, excep_info, arg_err ); - if (member <= DISPID_BASE) + if (member <= DISPID_BASE_METHOD) { hr = get_typeinfo( ISWbemObject_tid, &typeinfo ); if (SUCCEEDED(hr)) @@ -1044,6 +1106,7 @@ static HRESULT SWbemObject_create( IWbemClassObject *wbem_object, ISWbemObject * object->members = NULL; object->nb_members = 0; object->last_dispid = DISPID_BASE; + object->last_dispid_method = DISPID_BASE_METHOD; *obj = &object->ISWbemObject_iface; TRACE( "returning iface %p\n", *obj ); @@ -1641,7 +1704,7 @@ static HRESULT WINAPI services_DeleteAsync( static BSTR build_query_string( const WCHAR *class ) { static const WCHAR selectW[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',0}; - UINT len = strlenW(class) + sizeof(selectW) / sizeof(selectW[0]); + UINT len = strlenW(class) + ARRAY_SIZE(selectW); BSTR ret; if (!(ret = SysAllocStringLen( NULL, len ))) return NULL; @@ -2074,7 +2137,7 @@ static BSTR build_resource_string( BSTR server, BSTR namespace ) if (server && *server) len_server = strlenW( server ); else len_server = 1; if (namespace && *namespace) len_namespace = strlenW( namespace ); - else len_namespace = sizeof(defaultW) / sizeof(defaultW[0]) - 1; + else len_namespace = ARRAY_SIZE(defaultW) - 1; if (!(ret = SysAllocStringLen( NULL, 2 + len_server + 1 + len_namespace ))) return NULL; @@ -2304,7 +2367,7 @@ static HRESULT WINAPI security_Invoke( return hr; } -static HRESULT WINAPI security_get_ImpersonationLevel_( +static HRESULT WINAPI security_get_ImpersonationLevel( ISWbemSecurity *iface, WbemImpersonationLevelEnum *impersonation_level ) { @@ -2318,7 +2381,7 @@ static HRESULT WINAPI security_get_ImpersonationLevel_( return S_OK; } -static HRESULT WINAPI security_put_ImpersonationLevel_( +static HRESULT WINAPI security_put_ImpersonationLevel( ISWbemSecurity *iface, WbemImpersonationLevelEnum impersonation_level ) { @@ -2329,7 +2392,7 @@ static HRESULT WINAPI security_put_ImpersonationLevel_( return S_OK; } -static HRESULT WINAPI security_get_AuthenticationLevel_( +static HRESULT WINAPI security_get_AuthenticationLevel( ISWbemSecurity *iface, WbemAuthenticationLevelEnum *authentication_level ) { @@ -2343,7 +2406,7 @@ static HRESULT WINAPI security_get_AuthenticationLevel_( return S_OK; } -static HRESULT WINAPI security_put_AuthenticationLevel_( +static HRESULT WINAPI security_put_AuthenticationLevel( ISWbemSecurity *iface, WbemAuthenticationLevelEnum authentication_level ) { @@ -2354,7 +2417,7 @@ static HRESULT WINAPI security_put_AuthenticationLevel_( return S_OK; } -static HRESULT WINAPI security_get_Privileges_( +static HRESULT WINAPI security_get_Privileges( ISWbemSecurity *iface, ISWbemPrivilegeSet **privilege_set ) { @@ -2376,11 +2439,11 @@ static const ISWbemSecurityVtbl security_vtbl = security_GetTypeInfo, security_GetIDsOfNames, security_Invoke, - security_get_ImpersonationLevel_, - security_put_ImpersonationLevel_, - security_get_AuthenticationLevel_, - security_put_AuthenticationLevel_, - security_get_Privileges_ + security_get_ImpersonationLevel, + security_put_ImpersonationLevel, + security_get_AuthenticationLevel, + security_put_AuthenticationLevel, + security_get_Privileges }; static HRESULT ISWbemSecurity_create( ISWbemSecurity **obj ) @@ -2392,8 +2455,8 @@ static HRESULT ISWbemSecurity_create( ISWbemSecurity **obj ) if (!(security = heap_alloc( sizeof(*security) ))) return E_OUTOFMEMORY; security->ISWbemSecurity_iface.lpVtbl = &security_vtbl; security->refs = 1; - security->implevel = wbemImpersonationLevelAnonymous; - security->authlevel = wbemAuthenticationLevelDefault; + security->implevel = wbemImpersonationLevelImpersonate; + security->authlevel = wbemAuthenticationLevelPktPrivacy; *obj = &security->ISWbemSecurity_iface; TRACE( "returning iface %p\n", *obj ); diff --git a/dll/win32/wbemdisp/main.c b/dll/win32/wbemdisp/main.c index 9d9b0adf40..aff4d5042b 100644 --- a/dll/win32/wbemdisp/main.c +++ b/dll/win32/wbemdisp/main.c @@ -374,7 +374,7 @@ static HRESULT WINAPI WinMGMTS_ParseDisplayName(IParseDisplayName *iface, IBindC ULONG *pchEaten, IMoniker **ppmkOut) { static const WCHAR prefixW[] = {'w','i','n','m','g','m','t','s',':',0}; - const DWORD prefix_len = sizeof(prefixW) / sizeof(prefixW[0]) - 1; + const DWORD prefix_len = ARRAY_SIZE(prefixW) - 1; ISWbemLocator *locator = NULL; ISWbemServices *services = NULL; ISWbemObject *obj = NULL; diff --git a/media/doc/README.WINE b/media/doc/README.WINE index e63e791d25..f81e450da1 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -194,7 +194,7 @@ reactos/dll/win32/uxtheme # Forked reactos/dll/win32/vbscript # Synced to WineStaging-4.0 reactos/dll/win32/version # Synced to WineStaging-4.0 reactos/dll/win32/vssapi # Synced to WineStaging-2.9 -reactos/dll/win32/wbemdisp # Synced to WineStaging-3.3 +reactos/dll/win32/wbemdisp # Synced to WineStaging-4.0 reactos/dll/win32/wbemprox # Synced to WineStaging-3.9 reactos/dll/win32/windowscodecs # Synced to WineStaging-3.9 reactos/dll/win32/windowscodecsext # Synced to WineStaging-2.9
5 years, 10 months
1
0
0
0
[reactos] 01/01: [VERSION_WINETEST] Sync with Wine Staging 4.0. CORE-15682
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=727f534b9f53134e73e96…
commit 727f534b9f53134e73e96288130349d36e46b67a Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Feb 4 13:09:27 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Feb 4 13:09:27 2019 +0100 [VERSION_WINETEST] Sync with Wine Staging 4.0. CORE-15682 --- modules/rostests/winetests/version/info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/rostests/winetests/version/info.c b/modules/rostests/winetests/version/info.c index 6f16999b08..7cfc1eb32a 100644 --- a/modules/rostests/winetests/version/info.c +++ b/modules/rostests/winetests/version/info.c @@ -548,7 +548,7 @@ static void test_VerQueryValueA(void) ok(len == 0, "VerQueryValue returned %u, expected 0\n", len); ok(p != (char *)0xdeadbeef, "not expected 0xdeadbeef\n"); - for (i = 0; i < sizeof(value_name)/sizeof(value_name[0]); i++) + for (i = 0; i < ARRAY_SIZE(value_name); i++) { sprintf(buf, "\\StringFileInfo\\%08x\\%s", translation, value_name[i]); p = (char *)0xdeadbeef; @@ -815,7 +815,7 @@ static void test_GetFileVersionInfoEx(void) return; } - for (i = 0; i < sizeof(test_flags)/sizeof(test_flags[0]); i++) + for (i = 0; i < ARRAY_SIZE(test_flags); i++) { size = pGetFileVersionInfoSizeExW(test_flags[i], kernel32W, NULL); ok(size, "[%u] GetFileVersionInfoSizeEx(kernel32) error %u\n", i, GetLastError());
5 years, 10 months
1
0
0
0
← Newer
1
...
12
13
14
15
16
17
18
...
21
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
Results per page:
10
25
50
100
200