41{
44 const BYTE CmpMem[] = {
45 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
46 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
47 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
48 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
49 };
50 const BYTE CmpMemOverlap[] = {
51 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
52 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
53 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
54 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
55 };
56 const BYTE ZeroMem[10] = {0};
60 ULONG uBytesRead, uBytesWritten;
62 STATSTG Stats;
63
67
69
70 hr =
CoCreateInstance(&CLSID_WICImagingFactory,
NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (
void**)&pFactory);
72 skip(
"CoCreateInstance returned with %#x, expected %#x\n",
hr,
S_OK);
73 return;
74 }
75
76 hr = IWICImagingFactory_CreateStream(pFactory, &pStream);
77 ok(
hr ==
S_OK,
"CreateStream returned with %#x, expected %#x\n",
hr,
S_OK);
79 skip(
"Failed to create stream\n");
80 return;
81 }
82
83
84 hr = IWICStream_InitializeFromMemory(pStream,
NULL,
sizeof(
Memory));
86
87 hr = IWICStream_InitializeFromMemory(pStream,
Memory, 0);
88 ok(
hr ==
S_OK,
"InitializeFromMemory returned with %#x, expected %#x\n",
hr,
S_OK);
89
90 hr = IWICStream_InitializeFromMemory(pStream,
Memory,
sizeof(
Memory));
92
93
94 IWICStream_Release(pStream);
95 hr = IWICImagingFactory_CreateStream(pFactory, &pStream);
96 ok(
hr ==
S_OK,
"CreateStream failed with %#x\n",
hr);
97
98 hr = IWICStream_InitializeFromMemory(pStream,
Memory,
sizeof(
Memory));
99 ok(
hr ==
S_OK,
"InitializeFromMemory returned with %#x, expected %#x\n",
hr,
S_OK);
100
101
103 hr = IWICStream_Read(pStream, MemBuf,
sizeof(ZeroMem), &uBytesRead);
104 ok(
hr ==
S_OK,
"Read returned with %#x, expected %#x\n",
hr,
S_OK);
106 ok(uBytesRead ==
sizeof(ZeroMem),
"Read %u bytes\n", uBytesRead);
107 ok(
memcmp(MemBuf, ZeroMem,
sizeof(ZeroMem)) == 0,
"Read returned invalid data!\n");
108 }
109
110 IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET,
NULL);
111
112 hr = IWICStream_Write(pStream, CmpMem,
sizeof(CmpMem), &uBytesWritten);
113 ok(
hr ==
S_OK,
"Read returned with %#x, expected %#x\n",
hr,
S_OK);
114
115
116 hr = IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, &uNewPos);
117 ok(
hr ==
S_OK,
"Seek returned with %#x, expected %#x\n",
hr,
S_OK);
118 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);
119
120 hr = IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET,
NULL);
121 ok(
hr ==
S_OK,
"Seek returned with %#x, expected %#x\n",
hr,
S_OK);
122
123 LargeInt.
u.HighPart = 1;
124 LargeInt.
u.LowPart = 0;
125 uNewPos.
u.HighPart = 0xdeadbeef;
126 uNewPos.
u.LowPart = 0xdeadbeef;
127 hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_SET, &uNewPos);
129 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);
131
133 uNewPos.
u.HighPart = 0xdeadbeef;
134 uNewPos.
u.LowPart = 0xdeadbeef;
135 hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_SET, &uNewPos);
137 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);
139
141 uNewPos.
u.HighPart = 0xdeadbeef;
142 uNewPos.
u.LowPart = 0xdeadbeef;
143 hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_END, &uNewPos);
145 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);
147
149 hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_END, &uNewPos);
150 ok(
hr ==
S_OK,
"Seek returned with %#x, expected %#x\n",
hr,
S_OK);
151 ok(uNewPos.
u.HighPart == 0 && uNewPos.
u.LowPart ==
sizeof(
Memory) - 1,
"bSeek cursor moved to position (%u;%u)\n", uNewPos.
u.HighPart, uNewPos.
u.LowPart);
152
153 IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, &uNewPos);
155 uNewPos.
u.HighPart = 0xdeadbeef;
156 uNewPos.
u.LowPart = 0xdeadbeef;
157 hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_END, &uNewPos);
160 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);
162 IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET,
NULL);
163
164
165 hr = IWICStream_Read(pStream, MemBuf, 12, &uBytesRead);
166 ok(
hr ==
S_OK,
"Read returned with %#x, expected %#x\n",
hr,
S_OK);
168 ok(uBytesRead == 12,
"Read %u bytes, expected %u\n", uBytesRead, 12);
169 ok(
memcmp(MemBuf, CmpMem, 12) == 0,
"Read returned invalid data!\n");
170
171
173 }
174
175 IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET,
NULL);
176
177 hr = IWICStream_Read(pStream,
Memory, 10, &uBytesRead);
178 ok(
hr ==
S_OK,
"Read returned with %#x, expected %#x\n",
hr,
S_OK);
180 ok(uBytesRead == 10,
"Read %u bytes, expected %u\n", uBytesRead, 10);
181 ok(
memcmp(
Memory, CmpMem, uBytesRead) == 0,
"Read returned invalid data!\n");
182 }
183
184 IWICStream_Seek(pStream, SeekPos, STREAM_SEEK_SET,
NULL);
185
186 hr = IWICStream_Read(pStream,
Memory, 10, &uBytesRead);
187 ok(
hr ==
S_OK,
"Read returned with %#x, expected %#x\n",
hr,
S_OK);
189 ok(uBytesRead == 10,
"Read %u bytes, expected %u\n", uBytesRead, 10);
190 ok(
memcmp(
Memory, CmpMemOverlap, uBytesRead) == 0,
"Read returned invalid data!\n");
191 }
192
194
195 IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET,
NULL);
196
197 hr = IWICStream_Read(pStream,
Memory,
sizeof(
Memory) + 10, &uBytesRead);
198 ok(
hr ==
S_OK,
"Read returned with %#x, expected %#x\n",
hr,
S_OK);
200 ok(uBytesRead ==
sizeof(
Memory),
"Read %u bytes\n", uBytesRead);
201 ok(
memcmp(
Memory, CmpMem, uBytesRead) == 0,
"Read returned invalid data!\n");
202 }
203
204 hr = IWICStream_Read(pStream,
NULL, 1, &uBytesRead);
206
207 hr = IWICStream_Read(pStream, MemBuf, 0, &uBytesRead);
208 ok(
hr ==
S_OK,
"Read returned with %#x, expected %#x\n",
hr,
S_OK);
209
210 hr = IWICStream_Read(pStream,
NULL, 0, &uBytesRead);
212
215
216 hr = IWICStream_Read(pStream, MemBuf, 1,
NULL);
217 ok(
hr ==
S_OK,
"Read returned with %#x, expected %#x\n",
hr,
S_OK);
218
219 IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET,
NULL);
221 hr = IWICStream_Read(pStream, MemBuf,
sizeof(
Memory) + 10, &uBytesRead);
222 ok(
hr ==
S_OK,
"Read returned with %#x, expected %#x\n",
hr,
S_OK);
224 ok(uBytesRead ==
sizeof(
Memory),
"Read %u bytes\n", uBytesRead);
225 ok(
memcmp(
Memory, CmpMem, 64) == 0,
"Read returned invalid data!\n");
226 }
227 IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET,
NULL);
228
229
230
231 MemBuf[0] = CmpMem[0] + 1;
232 MemBuf[1] = CmpMem[1] + 1;
233 MemBuf[2] = CmpMem[2] + 1;
234 hr = IWICStream_Write(pStream, MemBuf, 3, &uBytesWritten);
235 ok(
hr ==
S_OK,
"Write returned with %#x, expected %#x\n",
hr,
S_OK);
237 ok(uBytesWritten == 3,
"Wrote %u bytes, expected %u\n", uBytesWritten, 3);
238 ok(
memcmp(MemBuf,
Memory, 3) == 0,
"Wrote returned invalid data!\n");
239
240
242 }
243 IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET,
NULL);
244
245 hr = IWICStream_Write(pStream, MemBuf, 0, &uBytesWritten);
246 ok(
hr ==
S_OK,
"Read returned with %#x, expected %#x\n",
hr,
S_OK);
247
248
249 hr = IWICStream_Write(pStream, CmpMem,
sizeof(CmpMem), &uBytesWritten);
250 ok(
hr ==
S_OK,
"Read returned with %#x, expected %#x\n",
hr,
S_OK);
251
252 IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET,
NULL);
253
254
255 hr = IWICStream_Write(pStream,
Memory + 5, 10, &uBytesWritten);
256 ok(
hr ==
S_OK,
"Write returned with %#x, expected %#x\n",
hr,
S_OK);
258 ok(uBytesWritten == 10,
"Wrote %u bytes, expected %u\n", uBytesWritten, 10);
259 ok(
memcmp(CmpMemOverlap,
Memory,
sizeof(CmpMemOverlap)) == 0,
"Wrote returned invalid data!\n");
260 }
261
262 IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET,
NULL);
263
264 uBytesWritten = 0xdeadbeef;
265 hr = IWICStream_Write(pStream,
NULL, 3, &uBytesWritten);
267 ok(uBytesWritten == 0xdeadbeef,
"Expected uBytesWritten to be unchanged, got %u\n", uBytesWritten);
269
270 uBytesWritten = 0xdeadbeef;
271 hr = IWICStream_Write(pStream,
NULL, 0, &uBytesWritten);
273 ok(uBytesWritten == 0xdeadbeef,
"Expected uBytesWritten to be unchanged, got %u\n", uBytesWritten);
275
276 uBytesWritten = 0xdeadbeef;
277 hr = IWICStream_Write(pStream, CmpMem,
sizeof(
Memory) + 10, &uBytesWritten);
279 ok(uBytesWritten == 0xdeadbeef,
"Expected uBytesWritten to be unchanged, got %u\n", uBytesWritten);
281 IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET,
NULL);
282
283
284
285 uNewPos.
u.HighPart = 0;
286 uNewPos.
u.LowPart =
sizeof(
Memory) + 10;
287 hr = IWICStream_SetSize(pStream, uNewPos);
289
290 uNewPos.
u.HighPart = 0;
291 uNewPos.
u.LowPart =
sizeof(
Memory);
292 hr = IWICStream_SetSize(pStream, uNewPos);
294
295 uNewPos.
u.HighPart = 0;
296 uNewPos.
u.LowPart =
sizeof(
Memory) - 10;
297 hr = IWICStream_SetSize(pStream, uNewPos);
299
300 uNewPos.
u.HighPart = 0;
301 uNewPos.
u.LowPart = 0;
302 hr = IWICStream_SetSize(pStream, uNewPos);
304
306 hr = IWICStream_SetSize(pStream, uNewPos);
308
309
310
311 uNewPos.
u.HighPart = 0;
312 uNewPos.
u.LowPart = 5;
315
316 hr = IWICImagingFactory_CreateStream(pFactory, &pBufStream);
317 ok(
hr ==
S_OK,
"CreateStream failed with %#x\n",
hr);
318
319 hr = IWICStream_InitializeFromMemory(pBufStream,
Memory,
sizeof(
Memory));
320 ok(
hr ==
S_OK,
"InitializeFromMemory returned with %#x, expected %#x\n",
hr,
S_OK);
321
324 IWICStream_Release(pBufStream);
325
326
327
328 hr = IWICStream_Commit(pStream, STGC_DEFAULT);
330
331 hr = IWICStream_Commit(pStream, STGC_OVERWRITE);
333
334 hr = IWICStream_Commit(pStream, STGC_ONLYIFCURRENT);
336
337 hr = IWICStream_Commit(pStream, STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE);
339
340 hr = IWICStream_Commit(pStream, STGC_CONSOLIDATE);
342
343
344
345 IWICStream_Write(pStream, &MemBuf[5], 6,
NULL);
346 hr = IWICStream_Revert(pStream);
349
350
351
352 hr = IWICStream_LockRegion(pStream, uLargeNull, uLargeNull, 0);
354
355 hr = IWICStream_UnlockRegion(pStream, uLargeNull, uLargeNull, 0);
357
358
359
360 hr = IWICStream_Stat(pStream,
NULL, 0);
362
363 hr = IWICStream_Stat(pStream, &Stats, 0);
365 ok(Stats.pwcsName ==
NULL,
"Stat returned name %p, expected %p\n", Stats.pwcsName,
NULL);
366 ok(Stats.type == STGTY_STREAM,
"Stat returned type %d, expected %d\n", Stats.type, STGTY_STREAM);
367 ok(Stats.cbSize.u.HighPart == 0 && Stats.cbSize.u.LowPart ==
sizeof(
Memory),
"Stat returned size (%u;%u)\n", Stats.cbSize.u.HighPart, Stats.cbSize.u.LowPart);
368 ok(Stats.mtime.dwHighDateTime == 0 && Stats.mtime.dwLowDateTime == 0,
"Stat returned mtime (%u;%u), expected (%u;%u)\n", Stats.mtime.dwHighDateTime, Stats.mtime.dwLowDateTime, 0, 0);
369 ok(Stats.ctime.dwHighDateTime == 0 && Stats.ctime.dwLowDateTime == 0,
"Stat returned ctime (%u;%u), expected (%u;%u)\n", Stats.ctime.dwHighDateTime, Stats.ctime.dwLowDateTime, 0, 0);
370 ok(Stats.atime.dwHighDateTime == 0 && Stats.atime.dwLowDateTime == 0,
"Stat returned atime (%u;%u), expected (%u;%u)\n", Stats.atime.dwHighDateTime, Stats.atime.dwLowDateTime, 0, 0);
371 ok(Stats.grfMode == 0,
"Stat returned access mode %d, expected %d\n", Stats.grfMode, 0);
372 ok(Stats.grfLocksSupported == 0,
"Stat returned supported locks %#x, expected %#x\n", Stats.grfLocksSupported, 0);
373 ok(Stats.grfStateBits == 0,
"Stat returned state bits %#x, expected %#x\n", Stats.grfStateBits, 0);
374
375
376
377 hr = IWICStream_Clone(pStream, (
IStream**)&pBufStream);
379
380
381 IWICStream_Release(pStream);
382 IWICImagingFactory_Release(pFactory);
383}
struct _LARGE_INTEGER::@2302 u
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
#define WINCODEC_ERR_WRONGSTATE