2 * PROJECT: ReactOS API Tests
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Test for NtAllocateVirtualMemory
5 * COPYRIGHT: Copyright 2011 Thomas Faber <thomas.faber@reactos.org>
6 * Copyright 2013 Timo Kreuzer <timo.kreuzer@reactos.org>
7 * Copyright 2015 Jérôme Gardou <jerome.gardou@reactos.org>
8 * Copyright 2018 Serge Gautherie <reactos-git_serge_171003@gautherie.fr>
13 static PVOID Allocations
[4096] = { NULL
};
14 static ULONG CurrentAllocation
= 0;
18 ValidateAllocations(VOID
)
22 ASSERT(CurrentAllocation
< sizeof(Allocations
) / sizeof(Allocations
[0]));
23 for (i
= 0; i
< CurrentAllocation
; ++i
)
25 PUCHAR UserBuffer
= Allocations
[i
];
26 SIZE_T AllocationSize
;
29 if (UserBuffer
== NULL
)
32 AllocationSize
= ((PSIZE_T
)UserBuffer
)[-2];
33 DataSize
= ((PSIZE_T
)UserBuffer
)[-1];
34 ASSERT(AllocationSize
!= 0);
35 ASSERT(AllocationSize
% PAGE_SIZE
== 0);
36 ASSERT(DataSize
!= 0);
37 ASSERT(((SIZE_T
)UserBuffer
+ DataSize
) % PAGE_SIZE
== 0);
47 PVOID AllocationStart
= NULL
;
48 SIZE_T AllocationSize
= PAGE_ROUND_UP(DataSize
+ PAGE_SIZE
+ 2 * sizeof(SIZE_T
));
50 SIZE_T NumberOfPages
= AllocationSize
/ PAGE_SIZE
;
54 Status
= NtAllocateVirtualMemory(NtCurrentProcess(), &AllocationStart
, 0, &AllocationSize
, MEM_RESERVE
, PAGE_NOACCESS
);
56 if (!NT_SUCCESS(Status
))
59 FirstPageStart
= (PUCHAR
)AllocationStart
+ AllocationSize
- PAGE_SIZE
* NumberOfPages
;
60 Size
= (NumberOfPages
- 1) * PAGE_SIZE
;
61 Status
= NtAllocateVirtualMemory(NtCurrentProcess(), &FirstPageStart
, 0, &Size
, MEM_COMMIT
, PAGE_READWRITE
);
62 if (!NT_SUCCESS(Status
))
65 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &AllocationStart
, &AllocationSize
, MEM_RELEASE
);
66 ASSERT(Status
== STATUS_SUCCESS
);
69 ASSERT(Size
% sizeof(ULONG
) == 0);
70 ASSERT(RtlCompareMemoryUlong(FirstPageStart
, Size
, 0) == Size
);
72 UserBuffer
= AllocationStart
;
73 UserBuffer
+= AllocationSize
- PAGE_SIZE
- DataSize
;
74 RtlFillMemory(FirstPageStart
, UserBuffer
- (PUCHAR
)FirstPageStart
, 0xae);
75 RtlZeroMemory(UserBuffer
, DataSize
);
76 ((PSIZE_T
)UserBuffer
)[-2] = AllocationSize
;
77 ((PSIZE_T
)UserBuffer
)[-1] = DataSize
;
79 Allocations
[CurrentAllocation
++] = UserBuffer
;
80 ValidateAllocations();
90 PVOID AllocationStart
;
92 SIZE_T AllocationSize
;
96 AllocationSize
= ((PSIZE_T
)UserBuffer
)[-2];
97 DataSize
= ((PSIZE_T
)UserBuffer
)[-1];
98 ASSERT(DataSize
!= 0);
100 AllocationStart
= (PUCHAR
)UserBuffer
+ DataSize
+ PAGE_SIZE
- AllocationSize
;
101 ASSERT((SIZE_T
)AllocationStart
% PAGE_SIZE
== 0);
103 RtlFillMemory(UserBuffer
, DataSize
, 0xbe);
104 ((PSIZE_T
)UserBuffer
)[-1] = 0;
105 ((PSIZE_T
)UserBuffer
)[-2] = 0xFAFBFCFD;
107 for (i
= 0; i
< CurrentAllocation
; ++i
)
108 if (Allocations
[i
] == UserBuffer
)
110 Allocations
[i
] = NULL
;
113 ValidateAllocations();
115 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &AllocationStart
, &Zero
, MEM_RELEASE
);
116 ASSERT(Status
== STATUS_SUCCESS
);
128 OldDataSize
= ((PSIZE_T
)OldUserBuffer
)[-1];
129 ASSERT(OldDataSize
!= 0);
131 NewUserBuffer
= Allocate(NewDataSize
);
132 ASSERT(((PSIZE_T
)OldUserBuffer
)[-1] == OldDataSize
);
133 RtlCopyMemory(NewUserBuffer
, OldUserBuffer
, min(OldDataSize
, NewDataSize
));
134 ASSERT(((PSIZE_T
)OldUserBuffer
)[-1] == OldDataSize
);
136 return NewUserBuffer
;
145 PBYTE Buffer
= UserBuffer
;
148 for (i
= 0; i
< DataSize
; ++i
)
149 Buffer
[i
] = LOBYTE(i
);
158 PBYTE Buffer
= UserBuffer
;
161 for (i
= 0; i
< DataSize
; ++i
)
162 if (Buffer
[i
] != LOBYTE(i
))
164 trace("Mismatch in region %p at index %lu. Value=%02x\n", UserBuffer
, (ULONG
)i
, Buffer
[i
]);
177 PBYTE Buffer
= UserBuffer
;
180 for (i
= 0; i
< DataSize
; ++i
)
181 Buffer
[i
] = UCHAR_MAX
- LOBYTE(i
);
190 PBYTE Buffer
= UserBuffer
;
193 for (i
= 0; i
< DataSize
; ++i
)
194 if (Buffer
[i
] != UCHAR_MAX
- LOBYTE(i
))
196 trace("Mismatch in region %p at index %lu. Value=%02x\n", UserBuffer
, (ULONG
)i
, Buffer
[i
]);
204 CheckSize(ULONG_PTR Base
, SIZE_T InSize
, SIZE_T ExpectedSize
)
211 BaseAddress
= (PVOID
)Base
;
213 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
219 ok(NT_SUCCESS(Status
), "NtAllocateVirtualMemory failed!\n");
220 ok(BaseAddress
== (PVOID
)(Base
& ~((ULONG_PTR
)0xFFFF)), "Got back wrong base address: %p\n", BaseAddress
);
221 ok(Size
== ExpectedSize
, "Alloc of 0x%Ix: got back wrong size: 0x%Ix, expected 0x%Ix\n", InSize
, Size
, ExpectedSize
);
222 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
223 ok(NT_SUCCESS(Status
), "NtFreeVirtualMemory failed!\n");
233 CheckSize(0x50000000, 0x0001, 0x1000);
234 CheckSize(0x50008000, 0x0001, 0x9000);
235 CheckSize(0x50000010, 0x1000, 0x2000);
236 CheckSize(0x50010000, 0x2000, 0x2000);
237 CheckSize(0x5000FFFF, 0x3000, 0x13000);
238 CheckSize(0x50001010, 0x7000, 0x9000);
239 CheckSize(0x50001010, 0xC000, 0xe000);
241 /* Reserve memory not aligned to allocation granularity */
242 BaseAddress
= UlongToPtr(0x50001010);
244 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
250 ok_ntstatus(Status
, STATUS_SUCCESS
);
251 ok(BaseAddress
== UlongToPtr(0x50000000), "Got back wrong base address: %p", BaseAddress
);
252 ok(Size
== 0x3000, "Got back wrong size: 0x%Ix", Size
);
254 /* Try to reserve again in the same 64k region */
255 BaseAddress
= UlongToPtr(0x50008000);
257 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
263 ok_ntstatus(Status
, STATUS_CONFLICTING_ADDRESSES
);
266 BaseAddress
= UlongToPtr(0x50002000);
268 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
274 ok_ntstatus(Status
, STATUS_SUCCESS
);
275 ok(BaseAddress
== UlongToPtr(0x50002000), "Got back wrong base address: %p", BaseAddress
);
276 ok(Size
== 0x1000, "Got back wrong size: 0x%Ix", Size
);
278 /* Commit the same address again with a different protection */
279 BaseAddress
= UlongToPtr(0x50002000);
281 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
287 ok_ntstatus(Status
, STATUS_SUCCESS
);
288 ok(BaseAddress
== UlongToPtr(0x50002000), "Got back wrong base address: %p", BaseAddress
);
289 ok(Size
== 0x1000, "Got back wrong size: 0x%Ix", Size
);
291 /* Commit memory at a too high address */
292 BaseAddress
= UlongToPtr(0x50003000);
294 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
300 ok_ntstatus(Status
, STATUS_CONFLICTING_ADDRESSES
);
302 /* Decommit the memory, even those pages that were not committed */
303 BaseAddress
= UlongToPtr(0x50000000);
305 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_DECOMMIT
);
306 ok_ntstatus(Status
, STATUS_SUCCESS
);
308 /* Try to release memory in a different 64k region */
309 BaseAddress
= UlongToPtr(0x50010000);
311 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
312 ok_ntstatus(Status
, STATUS_MEMORY_NOT_ALLOCATED
);
314 /* Release the memory in the same 64k region at a different address */
315 BaseAddress
= UlongToPtr(0x50008000);
317 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
318 ok_ntstatus(Status
, STATUS_MEMORY_NOT_ALLOCATED
);
320 /* Release the memory at the correct address but with wrong size */
321 BaseAddress
= UlongToPtr(0x50000000);
323 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
324 ok_ntstatus(Status
, STATUS_UNABLE_TO_FREE_VM
);
326 /* Release the memory */
327 BaseAddress
= UlongToPtr(0x50000000);
329 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
330 ok_ntstatus(Status
, STATUS_SUCCESS
);
332 /* Reserve and commit at once */
333 BaseAddress
= UlongToPtr(0x50004080);
335 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
339 MEM_RESERVE
| MEM_COMMIT
,
341 ok_ntstatus(Status
, STATUS_SUCCESS
);
342 ok(BaseAddress
== UlongToPtr(0x50000000), "Got back wrong base address: %p", BaseAddress
);
343 ok(Size
== 0x6000, "Got back wrong size: 0x%Ix", Size
);
347 *(int*)BaseAddress
= 1;
348 *(int*)UlongToPtr(0x50004080) = 1;
350 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
352 ok(0, "Got exception\n");
356 /* Release the memory */
357 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
358 ok_ntstatus(Status
, STATUS_SUCCESS
);
369 MEMORY_BASIC_INFORMATION MemoryBasicInfo
;
371 /* Reserve a full 64k region */
372 BaseAddress
= UlongToPtr(0x50000000);
374 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
380 ok_ntstatus(Status
, STATUS_SUCCESS
);
381 if (!NT_SUCCESS(Status
))
384 /* Reserve another 64k region, but with 64k between */
385 BaseAddress
= UlongToPtr(0x50020000);
387 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
393 ok_ntstatus(Status
, STATUS_SUCCESS
);
394 if (!NT_SUCCESS(Status
))
397 /* Try to free the whole at once */
398 BaseAddress
= UlongToPtr(0x50000000);
400 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
401 ok_ntstatus(Status
, STATUS_UNABLE_TO_FREE_VM
);
403 /* Reserve the part in the middle */
404 BaseAddress
= UlongToPtr(0x50010000);
406 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
412 ok_ntstatus(Status
, STATUS_SUCCESS
);
414 /* Try to commit memory covering 2 allocations */
415 BaseAddress
= UlongToPtr(0x50004000);
417 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
423 ok_ntstatus(Status
, STATUS_CONFLICTING_ADDRESSES
);
426 BaseAddress
= UlongToPtr(0x50000000);
428 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
434 ok_ntstatus(Status
, STATUS_SUCCESS
);
436 /* Commit another page */
437 BaseAddress
= UlongToPtr(0x50002000);
439 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
445 ok_ntstatus(Status
, STATUS_SUCCESS
);
449 *(int*)UlongToPtr(0x50000000) = 1;
451 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
453 ok(0, "Got exception\n");
459 (void)*(volatile int*)UlongToPtr(0x50002000);
461 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
463 Status
= _SEH2_GetExceptionCode();
466 ok_ntstatus(Status
, STATUS_ACCESS_VIOLATION
);
468 /* Allocate 3 pages, on top of the previous 2 */
469 BaseAddress
= UlongToPtr(0x50000000);
471 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
477 ok_ntstatus(Status
, STATUS_SUCCESS
);
481 *(int*)UlongToPtr(0x50000000) = 1;
483 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
485 Status
= _SEH2_GetExceptionCode();
488 ok_ntstatus(Status
, STATUS_ACCESS_VIOLATION
);
490 /* Commit a page at the end of the first region */
491 BaseAddress
= UlongToPtr(0x5000F000);
493 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
499 ok_ntstatus(Status
, STATUS_SUCCESS
);
500 ok_ptr(BaseAddress
, UlongToPtr(0x5000F000));
502 /* See where is the base of this newly committed area
503 * (choose a base address in the middle of it) */
504 Status
= NtQueryVirtualMemory(NtCurrentProcess(),
505 UlongToPtr(0x5000F700),
506 MemoryBasicInformation
,
508 sizeof(MemoryBasicInfo
),
510 ok_ntstatus(Status
, STATUS_SUCCESS
);
511 /* The base address is the beginning of the committed area */
512 ok_ptr(MemoryBasicInfo
.BaseAddress
, UlongToPtr(0x5000F000));
513 /* The allocation base address is the beginning of the whole region */
514 ok_ptr(MemoryBasicInfo
.AllocationBase
, UlongToPtr(0x50000000));
515 /* This is the protection of the memory when it was reserved. */
516 ok_long(MemoryBasicInfo
.AllocationProtect
, PAGE_NOACCESS
);
517 /* This is the size of the committed region. (ie, smallest chunk size) */
518 ok_long(MemoryBasicInfo
.RegionSize
, 0x1000);
519 /* This is the state of the queried address */
520 ok_long(MemoryBasicInfo
.State
, MEM_COMMIT
);
521 /* This is the protection of the queried address */
522 ok_long(MemoryBasicInfo
.Protect
, PAGE_READWRITE
);
523 /* NtAllocateVirtualMemory makes it MEM_PRIVATE */
524 ok_long(MemoryBasicInfo
.Type
, MEM_PRIVATE
);
526 /* Try to free the whole region at once */
527 BaseAddress
= UlongToPtr(0x50000000);
529 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
530 ok_ntstatus(Status
, STATUS_UNABLE_TO_FREE_VM
);
532 BaseAddress
= UlongToPtr(0x50000000);
534 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
535 ok_ntstatus(Status
, STATUS_SUCCESS
);
537 BaseAddress
= UlongToPtr(0x50010000);
539 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
540 ok_ntstatus(Status
, STATUS_SUCCESS
);
542 BaseAddress
= UlongToPtr(0x50020000);
544 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
545 ok_ntstatus(Status
, STATUS_SUCCESS
);
547 /* Reserve 3 full 64k region */
548 BaseAddress
= UlongToPtr(0x50000000);
550 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
556 ok_ntstatus(Status
, STATUS_SUCCESS
);
557 if (!NT_SUCCESS(Status
))
560 /* Release the 64k region in the middle */
561 BaseAddress
= UlongToPtr(0x50010000);
563 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
564 ok_ntstatus(Status
, STATUS_SUCCESS
);
570 CheckSomeDefaultAddresses(VOID
)
578 /* Reserve memory dynamically, not at 0x00000000 */
581 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
587 ok_ntstatus(Status
, STATUS_SUCCESS
);
588 ok(BaseAddress
!= 0x00000000, "Unexpected BaseAddress = 0x00000000\n");
589 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
590 ok_ntstatus(Status
, STATUS_SUCCESS
);
592 // 0x00000000, 64k: Free.
594 /* Reserve and commit memory at 0x00000000, after round down */
595 BaseAddress
= UlongToPtr(0x00000000 + 0x0FFF);
597 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
601 MEM_RESERVE
| MEM_COMMIT
,
603 ok_ntstatus(Status
, STATUS_SUCCESS
);
604 ok_ptr(BaseAddress
, 0x00000000);
606 // Double-check that it is not forbidden "in order to catch null pointer accesses".
608 *(int*)UlongToPtr(0x00000000) = 1;
609 EndSeh(STATUS_SUCCESS
)
611 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
612 ok_ntstatus(Status
, STATUS_SUCCESS
);
614 /* Reserve memory above 0x00000000 */
615 BaseAddress
= UlongToPtr(0x00000000 + 0x1000);
617 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
623 ok_ntstatus(Status
, STATUS_SUCCESS
);
624 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
625 ok_ntstatus(Status
, STATUS_SUCCESS
);
627 /* The following checks assume very default addresses,
628 * no address space layout randomization (ASLR). */
630 ok(FALSE
, "ToDo, 64-bit: Check/Adapt 32-bit results\n");
633 // 0x00010000, 4k: Private Data.
634 // 0x00011000, 60k: Unusable.
636 /* Reserve memory below 0x00010000 */
637 BaseAddress
= UlongToPtr(0x00010000 - 0x1000);
639 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
645 ok_ntstatus(Status
, STATUS_SUCCESS
);
646 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
647 ok_ntstatus(Status
, STATUS_SUCCESS
);
649 /* Reserve memory at 0x00010000:
650 * Windows NT legacy default executable image base */
651 BaseAddress
= UlongToPtr(0x00010000);
653 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
659 ok_ntstatus(Status
, STATUS_CONFLICTING_ADDRESSES
);
660 if (NT_SUCCESS(Status
))
661 { // Unexpected, cleanup.
662 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
663 ok_ntstatus(Status
, STATUS_SUCCESS
);
666 // 0x00400000: Image base.
668 /* Reserve memory below 0x00400000 */
669 BaseAddress
= UlongToPtr(0x00400000 - 0x1000);
671 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
677 if (NT_SUCCESS(Status
))
679 trace("Below 0x00400000 is available, as on ReactOS and Windows S03\n");
680 // 0x003F0000, 64k: Free.
681 ok_ntstatus(Status
, STATUS_SUCCESS
);
682 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
683 ok_ntstatus(Status
, STATUS_SUCCESS
);
687 trace("Below 0x00400000 is not available, as on Windows XP\n");
688 // 0x003F0000, 4k: Shareable.
689 // 0x003F1000, 60k: Unusable.
690 ok_ntstatus(Status
, STATUS_CONFLICTING_ADDRESSES
);
693 /* Reserve memory at 0x00400000:
694 * Windows NT legacy default DLL image base,
695 * (ReactOS and) Windows 95 new default executable image base */
696 BaseAddress
= UlongToPtr(0x00400000);
698 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
704 ok_ntstatus(Status
, STATUS_CONFLICTING_ADDRESSES
);
705 if (NT_SUCCESS(Status
))
706 { // Unexpected, cleanup.
707 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
708 ok_ntstatus(Status
, STATUS_SUCCESS
);
713 /* Reserve memory below 0x10000000 */
714 BaseAddress
= UlongToPtr(0x10000000 - 0x1000);
716 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
722 ok_ntstatus(Status
, STATUS_SUCCESS
);
723 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
724 ok_ntstatus(Status
, STATUS_SUCCESS
);
726 /* Reserve memory at 0x10000000:
727 * Windows new default non-OS DLL image base */
728 BaseAddress
= UlongToPtr(0x10000000);
730 Status
= NtAllocateVirtualMemory(NtCurrentProcess(),
736 ok_ntstatus(Status
, STATUS_SUCCESS
);
737 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &BaseAddress
, &Size
, MEM_RELEASE
);
738 ok_ntstatus(Status
, STATUS_SUCCESS
);
741 skip("ToDo, 64-bit: Add 0x140000000/Exe and 0x180000000/DLL checks\n");
747 START_TEST(NtAllocateVirtualMemory
)
755 CheckSomeDefaultAddresses();
758 Mem1
= Allocate(Size1
);
759 AccessMemory1(Mem1
, Size1
);
761 Mem2
= Allocate(Size2
);
762 AccessMemory2(Mem2
, Size2
);
763 for (i
= 0; i
< RUNS
; ++i
)
766 ok(CheckMemory1(Mem1
, Size1
) == TRUE
, "CheckMemory1 failure\n");
767 New
= ReAllocate(Mem1
, Size1
* 3 / 2);
770 skip("Realloc failure\n");
774 ok(CheckMemory1(Mem1
, Size1
) == TRUE
, "CheckMemory1 failure\n");
775 Size1
= Size1
* 3 / 2;
776 AccessMemory1(Mem1
, Size1
);
778 ok(CheckMemory2(Mem2
, Size2
) == TRUE
, "CheckMemory2 failure\n");
779 New
= ReAllocate(Mem2
, Size2
+ 128);
782 skip("Realloc failure\n");
786 ok(CheckMemory2(Mem2
, Size2
) == TRUE
, "CheckMemory2 failure\n");
788 AccessMemory2(Mem2
, Size2
);
790 ok(CheckMemory2(Mem2
, Size2
) == TRUE
, "CheckMemory2 failure\n");
792 ok(CheckMemory1(Mem1
, Size1
) == TRUE
, "CheckMemory1 failure\n");