[1/3] shlwapi: SHCreateMemStream added to shlwapi.h
Where it belongs according to its documentation. Signed-off-by: Viktor Semykin <thesame.ml(a)gmail.com> --- include/shlwapi.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/shlwapi.h b/include/shlwapi.h index 2c68b7f..c19ca31 100644 --- a/include/shlwapi.h +++ b/include/shlwapi.h @@ -978,6 +978,7 @@ HRESULT WINAPI SHCreateStreamOnFileA(LPCSTR,DWORD,struct IStream**); HRESULT WINAPI SHCreateStreamOnFileW(LPCWSTR,DWORD,struct IStream**); #define SHCreateStreamOnFile WINELIB_NAME_AW(SHCreateStreamOnFile) +struct IStream * WINAPI SHCreateMemStream(const BYTE *lpbData, UINT dwDataLen); HRESULT WINAPI SHCreateStreamOnFileEx(LPCWSTR,DWORD,DWORD,BOOL,struct IStream*,struct IStream**); HRESULT WINAPI SHCreateStreamWrapper(LPBYTE,DWORD,DWORD,struct IStream**); -- 2.12.1
Signed-off-by: Viktor Semykin <thesame.ml(a)gmail.com> --- dlls/windowscodecs/tests/Makefile.in | 2 +- dlls/windowscodecs/tests/pngformat.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/dlls/windowscodecs/tests/Makefile.in b/dlls/windowscodecs/tests/Makefile.in index e11d184..e006e3d 100644 --- a/dlls/windowscodecs/tests/Makefile.in +++ b/dlls/windowscodecs/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = windowscodecs.dll -IMPORTS = windowscodecs oleaut32 ole32 user32 gdi32 +IMPORTS = windowscodecs oleaut32 ole32 user32 gdi32 shlwapi C_SRCS = \ bitmap.c \ diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c index 34cb533..20b6e93 100644 --- a/dlls/windowscodecs/tests/pngformat.c +++ b/dlls/windowscodecs/tests/pngformat.c @@ -25,6 +25,7 @@ #include "windef.h" #include "wincodec.h" #include "wine/test.h" +#include "shlwapi.h" /* 1x1 pixel PNG image */ static const char png_no_color_profile[] = { @@ -277,21 +278,16 @@ static IWICImagingFactory *factory; static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size) { - HGLOBAL hmem; - BYTE *data; HRESULT hr; IWICBitmapDecoder *decoder = NULL; IStream *stream; GUID format; LONG refcount; + ULARGE_INTEGER pos; + LARGE_INTEGER zero; - hmem = GlobalAlloc(0, image_size); - data = GlobalLock(hmem); - memcpy(data, image_data, image_size); - GlobalUnlock(hmem); - - hr = CreateStreamOnHGlobal(hmem, TRUE, &stream); - ok(hr == S_OK, "CreateStreamOnHGlobal error %#x\n", hr); + stream = SHCreateMemStream (image_data, image_size); + ok(stream != NULL, "SHCreateMemStream error\n"); hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); @@ -302,6 +298,11 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size ok(IsEqualGUID(&format, &GUID_ContainerFormatPng), "wrong container format %s\n", wine_dbgstr_guid(&format)); + zero.QuadPart = 0; + IStream_Seek (stream, zero, STREAM_SEEK_CUR, &pos); + todo_wine ok(pos.QuadPart < image_size, "seek beyond the end of stream: %lu >= %u\n", + pos.QuadPart, image_size); + refcount = IStream_Release(stream); ok(refcount > 0, "expected stream refcount > 0\n"); -- 2.12.1
Png decoder was making one extra seek after it met IEND chunk. This led to crashes of some software. Signed-off-by: Viktor Semykin <thesame.ml(a)gmail.com> --- dlls/windowscodecs/pngformat.c | 7 +++---- dlls/windowscodecs/tests/pngformat.c | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c index 990dcf6..c98a6a7 100644 --- a/dlls/windowscodecs/pngformat.c +++ b/dlls/windowscodecs/pngformat.c @@ -774,11 +774,12 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p /* Find the metadata chunks in the file. */ seek.QuadPart = 8; - hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, &chunk_start); - if (FAILED(hr)) goto end; do { + hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, &chunk_start); + if (FAILED(hr)) goto end; + hr = read_png_chunk(pIStream, chunk_type, NULL, &chunk_size); if (FAILED(hr)) goto end; @@ -816,8 +817,6 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p } seek.QuadPart = chunk_start.QuadPart + chunk_size + 12; /* skip data and CRC */ - hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, &chunk_start); - if (FAILED(hr)) goto end; } while (memcmp(chunk_type, "IEND", 4)); This->stream = pIStream; diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c index 20b6e93..18304a5 100644 --- a/dlls/windowscodecs/tests/pngformat.c +++ b/dlls/windowscodecs/tests/pngformat.c @@ -300,7 +300,7 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size zero.QuadPart = 0; IStream_Seek (stream, zero, STREAM_SEEK_CUR, &pos); - todo_wine ok(pos.QuadPart < image_size, "seek beyond the end of stream: %lu >= %u\n", + ok(pos.QuadPart < image_size, "seek beyond the end of stream: %lu >= %u\n", pos.QuadPart, image_size); refcount = IStream_Release(stream); -- 2.12.1
participants (1)
-
Viktor Semykin