[NTDLL_APITEST]
[reactos.git] / rostests / apitests / ntdll / RtlMemoryStream.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for the Rtl*MemoryStream* series of functions
5 * PROGRAMMER: David Quintana <gigaherz@gmail.com>
6 */
7
8 #define COBJMACROS
9
10 #include <apitest.h>
11 #include <ndk/rtlfuncs.h>
12 #include <ole2.h>
13 #include <wtypes.h>
14
15 ULONG finalReleaseCallCount = 0;
16
17 VOID
18 NTAPI
19 CustomFinalReleaseMemoryStream(PRTL_MEMORY_STREAM stream)
20 {
21 finalReleaseCallCount++;
22 trace("FinalRelease CALLED.\n");
23 }
24
25 VOID
26 NTAPI
27 CustomFinalReleaseOutOfProcessMemoryStream(PRTL_MEMORY_STREAM stream)
28 {
29 finalReleaseCallCount++;
30 trace("FinalRelease CALLED.\n");
31 RtlFinalReleaseOutOfProcessMemoryStream(stream);
32 }
33
34 BOOL CompareStructsAndSaveForLater(PRTL_MEMORY_STREAM pold, PRTL_MEMORY_STREAM pnew, PSTR at)
35 {
36 BOOL equal = TRUE;
37
38 // Compare
39 if (pold->Vtbl != pnew->Vtbl) { if (equal) { trace("%s: \n", at); equal = FALSE; } trace("Vtbl changed from %p to %p\n", pold->Vtbl, pnew->Vtbl);}
40 if (pold->RefCount != pnew->RefCount) { if (equal) { trace("%s: \n", at); equal = FALSE; } trace("RefCount changed from %p to %p\n", pold->RefCount, pnew->RefCount); }
41 if (pold->Unk1 != pnew->Unk1) { if (equal) { trace("%s: \n", at); equal = FALSE; } trace("Unk1 changed from %p to %p\n", pold->Unk1, pnew->Unk1); }
42 if (pold->Current != pnew->Current) { if (equal) { trace("%s: \n", at); equal = FALSE; } trace("Current changed from %p to %p\n", pold->Current, pnew->Current); }
43 if (pold->Start != pnew->Start) { if (equal) { trace("%s: \n", at); equal = FALSE; } trace("Start changed from %p to %p\n", pold->Start, pnew->Start); }
44 if (pold->End != pnew->End) { if (equal) { trace("%s: \n", at); equal = FALSE; } trace("End changed from %p to %p\n", pold->End, pnew->End); }
45 if (pold->FinalRelease != pnew->FinalRelease) { if (equal) { trace("%s: \n", at); equal = FALSE; } trace("FinalRelease changed from %p to %p\n", pold->FinalRelease, pnew->FinalRelease); }
46 if (pold->ProcessHandle != pnew->ProcessHandle) { if (equal) { trace("%s: \n", at); equal = FALSE; } trace("ProcessHandle changed from %p to %p\n", pold->ProcessHandle, pnew->ProcessHandle); }
47
48 // Save
49 pold->Vtbl = pnew->Vtbl;
50 pold->RefCount = pnew->RefCount;
51 pold->Unk1 = pnew->Unk1;
52 pold->Current = pnew->Current;
53 pold->Start = pnew->Start;
54 pold->End = pnew->End;
55 pold->FinalRelease = pnew->FinalRelease;
56 pold->ProcessHandle = pnew->ProcessHandle;
57
58 return equal;
59 }
60
61 void test_InProcess()
62 {
63 LARGE_INTEGER move;
64 ULARGE_INTEGER size;
65 HRESULT res;
66 ULONG i;
67
68 RTL_MEMORY_STREAM stream;
69 RTL_MEMORY_STREAM previous;
70
71 IStream * istream;
72
73 UCHAR buffer[80];
74 UCHAR buffer2[180];
75 ULONG bytesRead;
76
77 STATSTG stat;
78
79 finalReleaseCallCount = 0;
80
81 for (i = 0; i < sizeof(buffer2); i++)
82 {
83 buffer2[i] = i % UCHAR_MAX;
84 }
85
86 memset(&stream, 0x90, sizeof(stream));
87 memset(&previous, 0x00, sizeof(previous));
88
89 StartSeh()
90 RtlInitMemoryStream(NULL);
91 EndSeh(STATUS_ACCESS_VIOLATION);
92
93 StartSeh()
94 RtlInitMemoryStream(&stream);
95 EndSeh(STATUS_SUCCESS);
96
97 CompareStructsAndSaveForLater(&previous, &stream, "After init");
98
99 ok(stream.RefCount == 0, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 0);
100
101 stream.Current = buffer2;
102 stream.Start = buffer2;
103 stream.End = buffer2 + sizeof(buffer2);
104 stream.FinalRelease = CustomFinalReleaseMemoryStream;
105
106 CompareStructsAndSaveForLater(&previous, &stream, "After assigning");
107
108 StartSeh()
109 res = IStream_QueryInterface((struct IStream*)&stream, NULL, NULL);
110 ok(res == E_INVALIDARG, "QueryInterface to IStream returned wrong hResult: 0x%08x.\n", res);
111 ok(stream.RefCount == 0, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 2);
112 EndSeh(STATUS_ACCESS_VIOLATION);
113
114 StartSeh()
115 res = IStream_QueryInterface((struct IStream*)&stream, &IID_IStream, NULL);
116 ok(res == E_INVALIDARG, "QueryInterface to IStream returned wrong hResult: 0x%08x.\n", res);
117 ok(stream.RefCount == 1, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 2);
118 EndSeh(STATUS_ACCESS_VIOLATION);
119
120 StartSeh()
121 res = IStream_QueryInterface((struct IStream*)&stream, NULL, (void**)&istream);
122 ok(res == E_INVALIDARG, "QueryInterface to IStream returned wrong hResult: 0x%08x.\n", res);
123 ok(stream.RefCount == 1, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 2);
124 EndSeh(STATUS_ACCESS_VIOLATION);
125
126 StartSeh()
127 res = IStream_QueryInterface((struct IStream*)&stream, &IID_IStream, (void**)&istream);
128 ok(res == S_OK, "QueryInterface to IStream returned wrong hResult: 0x%08x.\n", res);
129 ok(stream.RefCount == 2, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 2);
130 EndSeh(STATUS_SUCCESS);
131
132 CompareStructsAndSaveForLater(&previous, &stream, "After QueryInterface");
133
134 StartSeh()
135 res = IStream_Stat(istream, NULL, 0);
136 ok(res == STG_E_INVALIDPOINTER, "Stat to IStream returned wrong hResult: 0x%08x.\n", res);
137 EndSeh(STATUS_SUCCESS);
138
139 StartSeh()
140 res = IStream_Stat(istream, &stat, STATFLAG_NONAME);
141 ok(res == S_OK, "Stat to IStream returned wrong hResult: 0x%08x.\n", res);
142 EndSeh(STATUS_SUCCESS);
143
144 ok(stream.Current == buffer2,
145 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
146 stream.Current, buffer2);
147 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
148 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
149
150 ok(stat.cbSize.QuadPart == ((PUCHAR)stream.End - (PUCHAR)stream.Start),
151 "stat.cbSize has the wrong value %lld (expected %d)\n",
152 stat.cbSize.QuadPart, (PUCHAR)stream.End - (PUCHAR)stream.Start);
153
154 CompareStructsAndSaveForLater(&previous, &stream, "After Stat");
155
156 StartSeh()
157 res = IStream_AddRef(istream);
158 ok(res == 3, "AddRef to IStream returned wrong hResult: %d.\n", res);
159 EndSeh(STATUS_SUCCESS);
160
161 StartSeh()
162 res = IStream_AddRef(istream);
163 ok(res == 4, "AddRef to IStream returned wrong hResult: %d.\n", res);
164 EndSeh(STATUS_SUCCESS);
165
166 StartSeh()
167 res = IStream_Release(istream);
168 ok(res == 3, "Release to IStream returned wrong hResult: %d.\n", res);
169 EndSeh(STATUS_SUCCESS);
170
171 StartSeh()
172 res = IStream_AddRef(istream);
173 ok(res == 4, "AddRef to IStream returned wrong hResult: %d.\n", res);
174 EndSeh(STATUS_SUCCESS);
175
176 StartSeh()
177 res = IStream_Release(istream);
178 ok(res == 3, "Release to IStream returned wrong hResult: %d.\n", res);
179 EndSeh(STATUS_SUCCESS);
180
181 StartSeh()
182 res = IStream_Release(istream);
183 ok(res == 2, "Release to IStream returned wrong hResult: %d.\n", res);
184 EndSeh(STATUS_SUCCESS);
185
186 CompareStructsAndSaveForLater(&previous, &stream, "After AddRef");
187
188 StartSeh()
189 res = IStream_Read(istream, NULL, 0, &bytesRead);
190 ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08x.\n", res);
191 EndSeh(STATUS_SUCCESS);
192
193 StartSeh()
194 res = IStream_Read(istream, buffer, 40, NULL);
195 ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08x.\n", res);
196 EndSeh(STATUS_ACCESS_VIOLATION);
197
198 StartSeh()
199 res = IStream_Read(istream, buffer + 40, 39, &bytesRead);
200 ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08x.\n", res);
201 EndSeh(STATUS_SUCCESS);
202
203 if (SUCCEEDED(res))
204 {
205 bytesRead += 40;
206 for (i = 0; i < bytesRead; i++)
207 {
208 ok(buffer[i] == i, "Buffer[%d] contains a wrong number %d (expected %d).\n", i, buffer[i], i);
209 }
210 }
211
212 ok(stream.Current == buffer2 + 79,
213 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
214 stream.Current, buffer2);
215 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
216 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
217
218 CompareStructsAndSaveForLater(&previous, &stream, "After Read 1");
219
220 size.QuadPart = 0x9090909090909090ull;
221
222 StartSeh()
223 move.QuadPart = -1;
224 res = IStream_Seek(istream, move, STREAM_SEEK_END, &size);
225 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
226 ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error (0x%08x,0x%08x).\n", size.HighPart, size.LowPart);
227 EndSeh(STATUS_SUCCESS);
228
229 StartSeh()
230 move.QuadPart = 0;
231 res = IStream_Seek(istream, move, STREAM_SEEK_END, &size);
232 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
233 ok(size.QuadPart == (PUCHAR)stream.End - (PUCHAR)stream.Start, "Seek new location unexpected value: 0x%08x.\n", size.LowPart);
234 EndSeh(STATUS_SUCCESS);
235
236 size.QuadPart = 0x9090909090909090ull;
237
238 StartSeh()
239 move.QuadPart = 1;
240 res = IStream_Seek(istream, move, STREAM_SEEK_END, &size);
241 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
242 ok(size.QuadPart == (PUCHAR)stream.End - (PUCHAR)stream.Start - 1, "Seek new location unexpected value: 0x%08x.\n", size.LowPart);
243 EndSeh(STATUS_SUCCESS);
244
245 size.QuadPart = 0x9090909090909090ull;
246
247 StartSeh()
248 move.QuadPart = 2;
249 res = IStream_Seek(istream, move, STREAM_SEEK_END, &size);
250 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
251 ok(size.QuadPart == (PUCHAR)stream.End - (PUCHAR)stream.Start - 2, "Seek new location unexpected value: 0x%08x.\n", size.LowPart);
252 EndSeh(STATUS_SUCCESS);
253
254 size.QuadPart = 0x9090909090909090ull;
255
256 StartSeh()
257 move.QuadPart = -20;
258 res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size);
259 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
260 ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error.\n");
261 EndSeh(STATUS_SUCCESS);
262
263 StartSeh()
264 move.QuadPart = 4000;
265 res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size);
266 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
267 ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error.\n");
268 EndSeh(STATUS_SUCCESS);
269
270 StartSeh()
271 move.QuadPart = 0x100000000ull;
272 res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size);
273 #ifdef _WIN64
274 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
275 ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error (0x%08x,0x%08x).\n", size.HighPart, size.LowPart);
276 #else
277 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
278 ok(size.QuadPart == 0, "Seek new location unexpected value: 0x%08x.\n", size.LowPart);
279 #endif
280 EndSeh(STATUS_SUCCESS);
281
282 #ifdef _WIN64
283 StartSeh()
284 move.QuadPart = 0;
285 res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size);
286 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
287 ok(size.QuadPart == 0, "Seek new location unexpected value: 0x%08x.\n", size.LowPart);
288 EndSeh(STATUS_SUCCESS);
289 #endif
290
291 size.QuadPart = 0x9090909090909090ull;
292
293 StartSeh()
294 move.QuadPart = -20;
295 res = IStream_Seek(istream, move, STREAM_SEEK_CUR, &size);
296 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
297 ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error (0x%08x,0x%08x).\n", size.HighPart, size.LowPart);
298 EndSeh(STATUS_SUCCESS);
299
300 StartSeh()
301 move.QuadPart = 0x100000000ull;
302 res = IStream_Seek(istream, move, STREAM_SEEK_CUR, &size);
303 #ifdef _WIN64
304 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
305 ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error (0x%08x,0x%08x).\n", size.HighPart, size.LowPart);
306 #else
307 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
308 ok(size.QuadPart == 0, "Seek new location unexpected value: 0x%08x.\n", size.LowPart);
309 #endif
310 EndSeh(STATUS_SUCCESS);
311
312 StartSeh()
313 move.QuadPart = 40;
314 res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size);
315 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
316 EndSeh(STATUS_SUCCESS);
317
318 ok(size.QuadPart == 40,
319 "Seek returned wrong offset %lld (expected %d)\n",
320 size.QuadPart, 40);
321
322 ok(stream.Current == buffer2 + 40,
323 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
324 stream.Current, buffer2);
325 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
326 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
327
328 CompareStructsAndSaveForLater(&previous, &stream, "After Seek");
329
330 res = IStream_Read(istream, buffer, sizeof(buffer), &bytesRead);
331
332 ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08x.\n", res);
333
334 if (SUCCEEDED(res))
335 {
336 for (i = 0; i < bytesRead; i++)
337 {
338 ok(buffer[i] == (i + 40), "Buffer[%d] contains a wrong number %d (expected %d).\n", i, buffer[i], i + 40);
339 }
340 }
341
342 ok(stream.Current == buffer2 + 40 + sizeof(buffer),
343 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
344 stream.Current, buffer2);
345 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
346 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
347
348 CompareStructsAndSaveForLater(&previous, &stream, "After Read 2");
349
350 res = IStream_Release(istream);
351
352 ok(res == 1, "Release to IStream returned wrong hResult: 0x%08x.\n", res);
353
354 ok(stream.RefCount == 1, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 1);
355
356 res = IStream_Release(istream);
357
358 ok(res == S_OK, "Release to IStream returned wrong hResult: 0x%08x.\n", res);
359
360 ok(stream.RefCount == 0, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 0);
361
362 ok(finalReleaseCallCount == 1, "FinalRelease was called %d times instead of 1.\n", finalReleaseCallCount);
363 }
364
365 void test_OutOfProcess()
366 {
367 LARGE_INTEGER move;
368 ULARGE_INTEGER size;
369 HRESULT res;
370 HANDLE process;
371 ULONG i;
372
373 RTL_MEMORY_STREAM stream;
374 RTL_MEMORY_STREAM previous;
375
376 IStream * istream;
377
378 UCHAR buffer[80];
379 UCHAR buffer2[180];
380 ULONG bytesRead;
381
382 STATSTG stat;
383
384 finalReleaseCallCount = 0;
385
386 for (i = 0; i < sizeof(buffer2); i++)
387 {
388 buffer2[i] = i % UCHAR_MAX;
389 }
390
391 memset(&stream, 0x90, sizeof(stream));
392 memset(&previous, 0x00, sizeof(previous));
393
394 process = GetCurrentProcess();
395
396 RtlInitOutOfProcessMemoryStream(&stream);
397
398 ok(stream.FinalRelease == RtlFinalReleaseOutOfProcessMemoryStream,
399 "stream.FinalRelease unexpected %p != %p.\n",
400 stream.FinalRelease, RtlFinalReleaseOutOfProcessMemoryStream);
401
402 ok(stream.RefCount == 0, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 0);
403
404 CompareStructsAndSaveForLater(&previous, &stream, "After init");
405
406 stream.Current = buffer2;
407 stream.Start = buffer2;
408 stream.End = buffer2 + sizeof(buffer2);
409 stream.ProcessHandle = process;
410 stream.FinalRelease = CustomFinalReleaseOutOfProcessMemoryStream;
411
412 CompareStructsAndSaveForLater(&previous, &stream, "After assigning");
413
414 res = IStream_QueryInterface((struct IStream*)&stream, &IID_IStream, (void**)&istream);
415
416 ok(res == S_OK, "QueryInterface to IStream returned wrong hResult: 0x%08x.\n", res);
417
418 ok(stream.RefCount == 1, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 1);
419
420 ok(stream.ProcessHandle == process,
421 "ProcessHandle changed unexpectedly: 0x%08x (expected 0x%p)\n",
422 stream.ProcessHandle, process);
423
424 CompareStructsAndSaveForLater(&previous, &stream, "After QueryInterface");
425
426 res = IStream_Stat(istream, &stat, STATFLAG_NONAME);
427
428 ok(res == S_OK, "Stat to IStream returned wrong hResult: 0x%08x.\n", res);
429
430 ok(stream.Current == buffer2,
431 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
432 stream.Current, buffer2);
433 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
434 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
435 ok(stream.ProcessHandle == process,
436 "ProcessHandle changed unexpectedly: 0x%08x (expected 0x%p)\n",
437 stream.ProcessHandle, process);
438
439 ok(stat.cbSize.QuadPart == ((PUCHAR)stream.End - (PUCHAR)stream.Start),
440 "stat.cbSize has the wrong value %lld (expected %d)\n",
441 stat.cbSize.QuadPart, (PUCHAR)stream.End - (PUCHAR)stream.Start);
442
443 CompareStructsAndSaveForLater(&previous, &stream, "After Stat");
444
445 res = IStream_Read(istream, buffer, sizeof(buffer), &bytesRead);
446
447 ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08x.\n", res);
448
449 if (SUCCEEDED(res))
450 {
451 for (i = 0; i < bytesRead; i++)
452 {
453 ok(buffer[i] == i, "Buffer[%d] contains a wrong number %d (expected %d).\n", i, buffer[i], i);
454 }
455 }
456
457 ok(stream.Current == buffer2 + sizeof(buffer),
458 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
459 stream.Current, buffer2);
460 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
461 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
462 ok(stream.ProcessHandle == process,
463 "ProcessHandle changed unexpectedly: 0x%08x (expected 0x%p)\n",
464 stream.ProcessHandle, process);
465
466 CompareStructsAndSaveForLater(&previous, &stream, "After Read 1");
467
468 move.QuadPart = 40;
469
470 res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size);
471
472 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08x.\n", res);
473
474 ok(size.QuadPart == 40,
475 "Seek returned wrong offset %lld (expected %d)\n",
476 size.QuadPart, 40);
477
478 ok(stream.Current == buffer2 + 40,
479 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
480 stream.Current, buffer2);
481 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
482 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
483 ok(stream.ProcessHandle == process,
484 "ProcessHandle changed unexpectedly: 0x%08x (expected 0x%p)\n",
485 stream.ProcessHandle, process);
486
487 CompareStructsAndSaveForLater(&previous, &stream, "After Seek");
488
489 res = IStream_Read(istream, buffer, sizeof(buffer), &bytesRead);
490
491 ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08x.\n", res);
492
493 if (SUCCEEDED(res))
494 {
495 for (i = 0; i < bytesRead; i++)
496 {
497 ok(buffer[i] == (i + 40), "Buffer[%d] contains a wrong number %d (expected %d).\n", i, buffer[i], i + 40);
498 }
499 }
500
501 ok(stream.Current == buffer2 + 40 + sizeof(buffer),
502 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
503 stream.Current, buffer2);
504 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
505 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
506 ok(stream.ProcessHandle == process,
507 "ProcessHandle changed unexpectedly: 0x%08x (expected 0x%p)\n",
508 stream.ProcessHandle, process);
509
510 CompareStructsAndSaveForLater(&previous, &stream, "After Read 2");
511
512 res = IStream_Release(istream);
513
514 ok(res == S_OK, "Release to IStream returned wrong hResult: 0x%08x.\n", res);
515
516 ok(stream.RefCount == 0, "RefCount has a wrong value: %d (expected %d).\n", stream.RefCount, 0);
517
518 ok(finalReleaseCallCount == 1, "FinalRelease was called %d times instead of 1.\n", finalReleaseCallCount);
519 }
520
521 START_TEST(RtlMemoryStream)
522 {
523 test_InProcess();
524 test_OutOfProcess();
525 }