ReactOS 0.4.15-dev-7842-g558ab78
RtlMemoryStream.c File Reference
#include "precomp.h"
#include <ole2.h>
#include <wtypes.h>
Include dependency graph for RtlMemoryStream.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

VOID NTAPI CustomFinalReleaseMemoryStream (PRTL_MEMORY_STREAM stream)
 
VOID NTAPI CustomFinalReleaseOutOfProcessMemoryStream (PRTL_MEMORY_STREAM stream)
 
BOOL CompareStructsAndSaveForLater (PRTL_MEMORY_STREAM pold, PRTL_MEMORY_STREAM pnew, PSTR at)
 
void test_InProcess ()
 
void test_OutOfProcess ()
 
 START_TEST (RtlMemoryStream)
 

Variables

ULONG finalReleaseCallCount = 0
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 10 of file RtlMemoryStream.c.

Function Documentation

◆ CompareStructsAndSaveForLater()

BOOL CompareStructsAndSaveForLater ( PRTL_MEMORY_STREAM  pold,
PRTL_MEMORY_STREAM  pnew,
PSTR  at 
)

Definition at line 33 of file RtlMemoryStream.c.

34{
35 BOOL equal = TRUE;
36
37 // Compare
38 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);}
39 if (pold->RefCount != pnew->RefCount) { if (equal) { trace("%s:\n", at); equal = FALSE; } trace("RefCount changed from %ld to %ld\n", pold->RefCount, pnew->RefCount); }
40 if (pold->Unk1 != pnew->Unk1) { if (equal) { trace("%s:\n", at); equal = FALSE; } trace("Unk1 changed from %lu to %lu\n", pold->Unk1, pnew->Unk1); }
41 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); }
42 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); }
43 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); }
44 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); }
45 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); }
46
47 // Save
48 pold->Vtbl = pnew->Vtbl;
49 pold->RefCount = pnew->RefCount;
50 pold->Unk1 = pnew->Unk1;
51 pold->Current = pnew->Current;
52 pold->Start = pnew->Start;
53 pold->End = pnew->End;
54 pold->FinalRelease = pnew->FinalRelease;
55 pold->ProcessHandle = pnew->ProcessHandle;
56
57 return equal;
58}
#define trace
Definition: atltest.h:70
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define equal(x, y)
Definition: reader.cc:56

Referenced by test_InProcess(), and test_OutOfProcess().

◆ CustomFinalReleaseMemoryStream()

VOID NTAPI CustomFinalReleaseMemoryStream ( PRTL_MEMORY_STREAM  stream)

Definition at line 18 of file RtlMemoryStream.c.

19{
21 trace("FinalRelease CALLED.\n");
22}
ULONG finalReleaseCallCount

Referenced by test_InProcess().

◆ CustomFinalReleaseOutOfProcessMemoryStream()

VOID NTAPI CustomFinalReleaseOutOfProcessMemoryStream ( PRTL_MEMORY_STREAM  stream)

Definition at line 26 of file RtlMemoryStream.c.

27{
29 trace("FinalRelease CALLED.\n");
31}
VOID NTAPI RtlFinalReleaseOutOfProcessMemoryStream(_In_ PRTL_MEMORY_STREAM Stream)
Definition: memstream.c:97
Definition: parse.h:23

Referenced by test_OutOfProcess().

◆ START_TEST()

START_TEST ( RtlMemoryStream  )

Definition at line 514 of file RtlMemoryStream.c.

515{
518}
void test_OutOfProcess()
void test_InProcess()

◆ test_InProcess()

void test_InProcess ( )

Definition at line 60 of file RtlMemoryStream.c.

61{
62 LARGE_INTEGER move;
65 ULONG i;
66
67 RTL_MEMORY_STREAM stream;
68 RTL_MEMORY_STREAM previous;
69
71
72 UCHAR buffer[80];
73 UCHAR buffer2[180];
74 ULONG bytesRead;
75
76 STATSTG stat;
77
79
80 for (i = 0; i < sizeof(buffer2); i++)
81 {
82 buffer2[i] = i % UCHAR_MAX;
83 }
84
85 memset(&stream, 0x90, sizeof(stream));
86 memset(&previous, 0x00, sizeof(previous));
87
88 StartSeh()
91
92 StartSeh()
95
96 CompareStructsAndSaveForLater(&previous, &stream, "After init");
97
98 ok(stream.RefCount == 0, "RefCount has a wrong value: %ld (expected %d).\n", stream.RefCount, 0);
99
100 stream.Current = buffer2;
101 stream.Start = buffer2;
102 stream.End = buffer2 + sizeof(buffer2);
104
105 CompareStructsAndSaveForLater(&previous, &stream, "After assigning");
106
107 StartSeh()
108 IStream_QueryInterface((struct IStream*)&stream, NULL, NULL);
110
111 StartSeh()
112 IStream_QueryInterface((struct IStream*)&stream, &IID_IStream, NULL);
114
115 StartSeh()
116 IStream_QueryInterface((struct IStream*)&stream, NULL, (void**)&istream);
118
119 StartSeh()
120 res = IStream_QueryInterface((struct IStream*)&stream, &IID_IStream, (void**)&istream);
121 ok(res == S_OK, "QueryInterface to IStream returned wrong hResult: 0x%08lx.\n", res);
122 ok(stream.RefCount == 2, "RefCount has a wrong value: %ld (expected %d).\n", stream.RefCount, 2);
124
126
127 StartSeh()
128 res = IStream_Stat(istream, NULL, 0);
129 ok(res == STG_E_INVALIDPOINTER, "Stat to IStream returned wrong hResult: 0x%08lx.\n", res);
131
132 StartSeh()
133 res = IStream_Stat(istream, &stat, STATFLAG_NONAME);
134 ok(res == S_OK, "Stat to IStream returned wrong hResult: 0x%08lx.\n", res);
136
137 ok(stream.Current == buffer2,
138 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
139 stream.Current, buffer2);
140 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
141 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
142
143 ok(stat.cbSize.QuadPart == ((PUCHAR)stream.End - (PUCHAR)stream.Start),
144 "stat.cbSize has the wrong value %I64u (expected %d)\n",
145 stat.cbSize.QuadPart, (PUCHAR)stream.End - (PUCHAR)stream.Start);
146
147 CompareStructsAndSaveForLater(&previous, &stream, "After Stat");
148
149 StartSeh()
150 res = IStream_AddRef(istream);
151 ok(res == 3, "AddRef to IStream returned wrong hResult: %ld.\n", res);
153
154 StartSeh()
155 res = IStream_AddRef(istream);
156 ok(res == 4, "AddRef to IStream returned wrong hResult: %ld.\n", res);
158
159 StartSeh()
160 res = IStream_Release(istream);
161 ok(res == 3, "Release to IStream returned wrong hResult: %ld.\n", res);
163
164 StartSeh()
165 res = IStream_AddRef(istream);
166 ok(res == 4, "AddRef to IStream returned wrong hResult: %ld.\n", res);
168
169 StartSeh()
170 res = IStream_Release(istream);
171 ok(res == 3, "Release to IStream returned wrong hResult: %ld.\n", res);
173
174 StartSeh()
175 res = IStream_Release(istream);
176 ok(res == 2, "Release to IStream returned wrong hResult: %ld.\n", res);
178
179 CompareStructsAndSaveForLater(&previous, &stream, "After AddRef");
180
181 StartSeh()
182 res = IStream_Read(istream, NULL, 0, &bytesRead);
183 ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08lx.\n", res);
185
186 StartSeh()
187 res = IStream_Read(istream, buffer, 40, NULL);
188 ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08lx.\n", res);
190
191 StartSeh()
192 res = IStream_Read(istream, buffer + 40, 39, &bytesRead);
193 ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08lx.\n", res);
195
196 if (SUCCEEDED(res))
197 {
198 bytesRead += 40;
199 for (i = 0; i < bytesRead; i++)
200 {
201 ok(buffer[i] == i, "Buffer[%lu] contains a wrong number %u (expected %lu).\n", i, buffer[i], i);
202 }
203 }
204
205 ok(stream.Current == buffer2 + 79,
206 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
207 stream.Current, buffer2);
208 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
209 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
210
211 CompareStructsAndSaveForLater(&previous, &stream, "After Read 1");
212
213 size.QuadPart = 0x9090909090909090ull;
214
215 StartSeh()
216 move.QuadPart = -1;
217 res = IStream_Seek(istream, move, STREAM_SEEK_END, &size);
218 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
219 ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error (0x%08lx,0x%08lx).\n", size.HighPart, size.LowPart);
221
222 StartSeh()
223 move.QuadPart = 0;
224 res = IStream_Seek(istream, move, STREAM_SEEK_END, &size);
225 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
226 ok(size.QuadPart == (PUCHAR)stream.End - (PUCHAR)stream.Start, "Seek new location unexpected value: 0x%08lx.\n", size.LowPart);
228
229 size.QuadPart = 0x9090909090909090ull;
230
231 StartSeh()
232 move.QuadPart = 1;
233 res = IStream_Seek(istream, move, STREAM_SEEK_END, &size);
234 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
235 ok(size.QuadPart == (PUCHAR)stream.End - (PUCHAR)stream.Start - 1, "Seek new location unexpected value: 0x%08lx.\n", size.LowPart);
237
238 size.QuadPart = 0x9090909090909090ull;
239
240 StartSeh()
241 move.QuadPart = 2;
242 res = IStream_Seek(istream, move, STREAM_SEEK_END, &size);
243 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
244 ok(size.QuadPart == (PUCHAR)stream.End - (PUCHAR)stream.Start - 2, "Seek new location unexpected value: 0x%08lx.\n", size.LowPart);
246
247 size.QuadPart = 0x9090909090909090ull;
248
249 StartSeh()
250 move.QuadPart = -20;
251 res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size);
252 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
253 ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error.\n");
255
256 StartSeh()
257 move.QuadPart = 4000;
258 res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size);
259 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
260 ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error.\n");
262
263 StartSeh()
264 move.QuadPart = 0x100000000ull;
265 res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size);
266#ifdef _WIN64
267 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
268 ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error (0x%08lx,0x%08lx).\n", size.HighPart, size.LowPart);
269#else
270 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
271 ok(size.QuadPart == 0, "Seek new location unexpected value: 0x%08lx.\n", size.LowPart);
272#endif
274
275#ifdef _WIN64
276 StartSeh()
277 move.QuadPart = 0;
278 res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size);
279 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
280 ok(size.QuadPart == 0, "Seek new location unexpected value: 0x%08lx.\n", size.LowPart);
282#endif
283
284 size.QuadPart = 0x9090909090909090ull;
285
286 StartSeh()
287 move.QuadPart = -20;
288 res = IStream_Seek(istream, move, STREAM_SEEK_CUR, &size);
289 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
290 ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error (0x%08lx,0x%08lx).\n", size.HighPart, size.LowPart);
292
293 StartSeh()
294 move.QuadPart = 0x100000000ull;
295 res = IStream_Seek(istream, move, STREAM_SEEK_CUR, &size);
296#ifdef _WIN64
297 ok(res == STG_E_INVALIDPOINTER, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
298 ok(size.QuadPart == 0x9090909090909090ull, "Seek modified the new location in an error (0x%08lx,0x%08lx).\n", size.HighPart, size.LowPart);
299#else
300 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
301 ok(size.QuadPart == 0, "Seek new location unexpected value: 0x%08lx.\n", size.LowPart);
302#endif
304
305 StartSeh()
306 move.QuadPart = 40;
307 res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size);
308 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
310
311 ok(size.QuadPart == 40,
312 "Seek returned wrong offset %I64u (expected %d)\n",
313 size.QuadPart, 40);
314
315 ok(stream.Current == buffer2 + 40,
316 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
317 stream.Current, buffer2);
318 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
319 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
320
321 CompareStructsAndSaveForLater(&previous, &stream, "After Seek");
322
323 res = IStream_Read(istream, buffer, sizeof(buffer), &bytesRead);
324
325 ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08lx.\n", res);
326
327 if (SUCCEEDED(res))
328 {
329 for (i = 0; i < bytesRead; i++)
330 {
331 ok(buffer[i] == (i + 40), "Buffer[%lu] contains a wrong number %u (expected %lu).\n", i, buffer[i], i + 40);
332 }
333 }
334
335 ok(stream.Current == buffer2 + 40 + sizeof(buffer),
336 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
337 stream.Current, buffer2);
338 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
339 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
340
341 CompareStructsAndSaveForLater(&previous, &stream, "After Read 2");
342
343 res = IStream_Release(istream);
344
345 ok(res == 1, "Release to IStream returned wrong hResult: 0x%08lx.\n", res);
346
347 ok(stream.RefCount == 1, "RefCount has a wrong value: %ld (expected %d).\n", stream.RefCount, 1);
348
349 res = IStream_Release(istream);
350
351 ok(res == S_OK, "Release to IStream returned wrong hResult: 0x%08lx.\n", res);
352
353 ok(stream.RefCount == 0, "RefCount has a wrong value: %ld (expected %d).\n", stream.RefCount, 0);
354
355 ok(finalReleaseCallCount == 1, "FinalRelease was called %lu times instead of 1.\n", finalReleaseCallCount);
356}
VOID NTAPI CustomFinalReleaseMemoryStream(PRTL_MEMORY_STREAM stream)
BOOL CompareStructsAndSaveForLater(PRTL_MEMORY_STREAM pold, PRTL_MEMORY_STREAM pnew, PSTR at)
basic_istream< char, char_traits< char > > istream
Definition: _iosfwd.h:120
#define StartSeh()
Definition: _sntprintf.h:16
#define EndSeh(ExpectedStatus)
Definition: _sntprintf.h:17
#define stat
Definition: acwin.h:99
#define ok(value,...)
Definition: atltest.h:57
_In_ BOOLEAN Release
Definition: cdrom.h:920
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLsizeiptr size
Definition: glext.h:5919
GLdouble n
Definition: glext.h:7729
GLuint res
Definition: glext.h:9613
GLuint address
Definition: glext.h:9393
GLuint buffer
Definition: glext.h:5915
GLuint in
Definition: glext.h:9616
GLfloat GLfloat p
Definition: glext.h:8902
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLsizei const GLfloat * points
Definition: glext.h:8112
GLintptr offset
Definition: glext.h:5920
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_CRTIMP void __cdecl unexpected(void)
#define UCHAR_MAX
Definition: limits.h:25
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define d
Definition: ke_i.h:81
#define Stat
Definition: syshdrs.h:78
if(dx< 0)
Definition: linetemp.h:194
VOID NTAPI RtlInitMemoryStream(_Out_ PRTL_MEMORY_STREAM Stream)
Definition: memstream.c:72
#define error(str)
Definition: mkdosfs.c:1605
BOOL expected
Definition: store.c:2063
static HRESULT QueryInterface(REFIID, void **)
Definition: events.c:2587
static HRESULT WINAPI Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: clist.c:174
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:90
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define memset(x, y, z)
Definition: compat.h:39
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ BOOLEAN Read
Definition: strmini.h:479
Definition: stat.h:55
#define new(TYPE, numElems)
Definition: treelist.c:54
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:94
@ Start
Definition: partlist.h:33
#define STG_E_INVALIDPOINTER
Definition: winerror.h:2571
static int init
Definition: wintirpc.c:33
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
ret QuadPart
Definition: rtlfuncs.h:3089
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by START_TEST().

◆ test_OutOfProcess()

void test_OutOfProcess ( )

Definition at line 358 of file RtlMemoryStream.c.

359{
360 LARGE_INTEGER move;
362 HRESULT res;
364 ULONG i;
365
366 RTL_MEMORY_STREAM stream;
367 RTL_MEMORY_STREAM previous;
368
370
371 UCHAR buffer[80];
372 UCHAR buffer2[180];
373 ULONG bytesRead;
374
375 STATSTG stat;
376
378
379 for (i = 0; i < sizeof(buffer2); i++)
380 {
381 buffer2[i] = i % UCHAR_MAX;
382 }
383
384 memset(&stream, 0x90, sizeof(stream));
385 memset(&previous, 0x00, sizeof(previous));
386
388
390
392 "stream.FinalRelease unexpected %p != %p.\n",
394
395 ok(stream.RefCount == 0, "RefCount has a wrong value: %ld (expected %d).\n", stream.RefCount, 0);
396
397 CompareStructsAndSaveForLater(&previous, &stream, "After init");
398
399 stream.Current = buffer2;
400 stream.Start = buffer2;
401 stream.End = buffer2 + sizeof(buffer2);
402 stream.ProcessHandle = process;
404
405 CompareStructsAndSaveForLater(&previous, &stream, "After assigning");
406
407 res = IStream_QueryInterface((struct IStream*)&stream, &IID_IStream, (void**)&istream);
408
409 ok(res == S_OK, "QueryInterface to IStream returned wrong hResult: 0x%08lx.\n", res);
410
411 ok(stream.RefCount == 1, "RefCount has a wrong value: %ld (expected %d).\n", stream.RefCount, 1);
412
413 ok(stream.ProcessHandle == process,
414 "ProcessHandle changed unexpectedly: 0x%p (expected 0x%p)\n",
415 stream.ProcessHandle, process);
416
417 CompareStructsAndSaveForLater(&previous, &stream, "After QueryInterface");
418
419 res = IStream_Stat(istream, &stat, STATFLAG_NONAME);
420
421 ok(res == S_OK, "Stat to IStream returned wrong hResult: 0x%08lx.\n", res);
422
423 ok(stream.Current == buffer2,
424 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
425 stream.Current, buffer2);
426 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
427 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
428 ok(stream.ProcessHandle == process,
429 "ProcessHandle changed unexpectedly: 0x%p (expected 0x%p)\n",
430 stream.ProcessHandle, process);
431
432 ok(stat.cbSize.QuadPart == ((PUCHAR)stream.End - (PUCHAR)stream.Start),
433 "stat.cbSize has the wrong value %I64u (expected %d)\n",
434 stat.cbSize.QuadPart, (PUCHAR)stream.End - (PUCHAR)stream.Start);
435
436 CompareStructsAndSaveForLater(&previous, &stream, "After Stat");
437
438 res = IStream_Read(istream, buffer, sizeof(buffer), &bytesRead);
439
440 ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08lx.\n", res);
441
442 if (SUCCEEDED(res))
443 {
444 for (i = 0; i < bytesRead; i++)
445 {
446 ok(buffer[i] == i, "Buffer[%lu] contains a wrong number %u (expected %lu).\n", i, buffer[i], i);
447 }
448 }
449
450 ok(stream.Current == buffer2 + sizeof(buffer),
451 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
452 stream.Current, buffer2);
453 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
454 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
455 ok(stream.ProcessHandle == process,
456 "ProcessHandle changed unexpectedly: 0x%p (expected 0x%p)\n",
457 stream.ProcessHandle, process);
458
459 CompareStructsAndSaveForLater(&previous, &stream, "After Read 1");
460
461 move.QuadPart = 40;
462
463 res = IStream_Seek(istream, move, STREAM_SEEK_SET, &size);
464
465 ok(res == S_OK, "Seek to IStream returned wrong hResult: 0x%08lx.\n", res);
466
467 ok(size.QuadPart == 40,
468 "Seek returned wrong offset %I64u (expected %d)\n",
469 size.QuadPart, 40);
470
471 ok(stream.Current == buffer2 + 40,
472 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
473 stream.Current, buffer2);
474 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
475 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
476 ok(stream.ProcessHandle == process,
477 "ProcessHandle changed unexpectedly: 0x%p (expected 0x%p)\n",
478 stream.ProcessHandle, process);
479
480 CompareStructsAndSaveForLater(&previous, &stream, "After Seek");
481
482 res = IStream_Read(istream, buffer, sizeof(buffer), &bytesRead);
483
484 ok(res == S_OK, "Read to IStream returned wrong hResult: 0x%08lx.\n", res);
485
486 if (SUCCEEDED(res))
487 {
488 for (i = 0; i < bytesRead; i++)
489 {
490 ok(buffer[i] == (i + 40), "Buffer[%lu] contains a wrong number %u (expected %lu).\n", i, buffer[i], i + 40);
491 }
492 }
493
494 ok(stream.Current == buffer2 + 40 + sizeof(buffer),
495 "stream.Current points to the wrong address 0x%p (expected 0x%p)\n",
496 stream.Current, buffer2);
497 ok(stream.Start == buffer2, "stream.Start was changed unexpectedly\n");
498 ok(stream.End == buffer2 + sizeof(buffer2), "stream.End was changed unexpectedly\n");
499 ok(stream.ProcessHandle == process,
500 "ProcessHandle changed unexpectedly: 0x%p (expected 0x%p)\n",
501 stream.ProcessHandle, process);
502
503 CompareStructsAndSaveForLater(&previous, &stream, "After Read 2");
504
505 res = IStream_Release(istream);
506
507 ok(res == S_OK, "Release to IStream returned wrong hResult: 0x%08lx.\n", res);
508
509 ok(stream.RefCount == 0, "RefCount has a wrong value: %ld (expected %d).\n", stream.RefCount, 0);
510
511 ok(finalReleaseCallCount == 1, "FinalRelease was called %lu times instead of 1.\n", finalReleaseCallCount);
512}
VOID NTAPI CustomFinalReleaseOutOfProcessMemoryStream(PRTL_MEMORY_STREAM stream)
#define GetCurrentProcess()
Definition: compat.h:759
VOID NTAPI RtlInitOutOfProcessMemoryStream(_Out_ PRTL_MEMORY_STREAM Stream)
Definition: memstream.c:84
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by START_TEST().

Variable Documentation

◆ finalReleaseCallCount