msi: Add Polish translation.
[wine] / dlls / kernel32 / tests / virtual.c
1 /*
2  * Unit test suite for Virtual* family of APIs.
3  *
4  * Copyright 2004 Dmitry Timoshkov
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winerror.h"
27 #include "wine/test.h"
28
29 #define NUM_THREADS 4
30
31 static HANDLE create_target_process(const char *arg)
32 {
33     char **argv;
34     char cmdline[MAX_PATH];
35     PROCESS_INFORMATION pi;
36     STARTUPINFO si = { 0 };
37     si.cb = sizeof(si);
38
39     winetest_get_mainargs( &argv );
40     sprintf(cmdline, "%s %s %s", argv[0], argv[1], arg);
41     ok(CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL,
42                      &si, &pi) != 0, "error: %u\n", GetLastError());
43     ok(CloseHandle(pi.hThread) != 0, "error %u\n", GetLastError());
44     return pi.hProcess;
45 }
46
47 static void test_VirtualAllocEx(void)
48 {
49     const unsigned int alloc_size = 1<<15;
50     char *src, *dst;
51     unsigned long bytes_written = 0, bytes_read = 0, i;
52     void *addr1, *addr2;
53     BOOL b;
54     DWORD old_prot;
55     MEMORY_BASIC_INFORMATION info;
56     HANDLE hProcess;
57
58     hProcess = create_target_process("sleep");
59     ok(hProcess != NULL, "Can't start process\n");
60
61     SetLastError(0xdeadbeef);
62     addr1 = VirtualAllocEx(hProcess, NULL, alloc_size, MEM_COMMIT,
63                            PAGE_EXECUTE_READWRITE);
64     if (!addr1 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
65     {   /* Win9x */
66         trace("VirtualAllocEx is not implemented, skipping the test\n");
67         TerminateProcess(hProcess, 0);
68         CloseHandle(hProcess);
69         return;
70     }
71
72     src = (char *) HeapAlloc( GetProcessHeap(), 0, alloc_size );
73     dst = (char *) HeapAlloc( GetProcessHeap(), 0, alloc_size );
74     for (i = 0; i < alloc_size; i++)
75         src[i] = 0xcafedead + i;
76
77     todo_wine ok(addr1 != NULL, "VirtualAllocEx error %u\n", GetLastError());
78     b = WriteProcessMemory(hProcess, addr1, src, alloc_size, &bytes_written);
79     ok(b && (bytes_written == alloc_size), "%lu bytes written\n",
80        bytes_written);
81     b = ReadProcessMemory(hProcess, addr1, dst, alloc_size, &bytes_read);
82     ok(b && (bytes_read == alloc_size), "%lu bytes read\n", bytes_read);
83     ok(!memcmp(src, dst, alloc_size), "Data from remote process differs\n");
84     b = VirtualFreeEx(hProcess, addr1, 0, MEM_RELEASE);
85     todo_wine ok(b != 0, "VirtualFreeEx, error %u\n", GetLastError());
86
87     HeapFree( GetProcessHeap(), 0, src );
88     HeapFree( GetProcessHeap(), 0, dst );
89
90     /*
91      * The following tests parallel those in test_VirtualAlloc()
92      */
93
94     SetLastError(0xdeadbeef);
95     addr1 = VirtualAllocEx(hProcess, 0, 0, MEM_RESERVE, PAGE_NOACCESS);
96     ok(addr1 == NULL, "VirtualAllocEx should fail on zero-sized allocation\n");
97     ok(GetLastError() == ERROR_INVALID_PARAMETER /* NT */ ||
98        GetLastError() == ERROR_NOT_ENOUGH_MEMORY, /* Win9x */
99         "got %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
100
101     addr1 = VirtualAllocEx(hProcess, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
102     todo_wine ok(addr1 != NULL, "VirtualAllocEx failed\n");
103
104     /* test a not committed memory */
105     memset(&info, 'q', sizeof(info));
106     todo_wine ok(VirtualQueryEx(hProcess, addr1, &info, sizeof(info))
107                  == sizeof(info), "VirtualQueryEx failed\n");
108     todo_wine ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress,
109                  addr1);
110     todo_wine ok(info.AllocationBase == addr1, "%p != %p\n",
111                  info.AllocationBase, addr1);
112     todo_wine ok(info.AllocationProtect == PAGE_NOACCESS,
113                  "%x != PAGE_NOACCESS\n", info.AllocationProtect);
114     todo_wine ok(info.RegionSize == 0x10000, "%lx != 0x10000\n",
115                  info.RegionSize);
116     todo_wine ok(info.State == MEM_RESERVE, "%x != MEM_RESERVE\n", info.State);
117     /* NT reports Protect == 0 for a not committed memory block */
118     todo_wine ok(info.Protect == 0 /* NT */ ||
119        info.Protect == PAGE_NOACCESS, /* Win9x */
120         "%x != PAGE_NOACCESS\n", info.Protect);
121     todo_wine ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
122
123     SetLastError(0xdeadbeef);
124     ok(!VirtualProtectEx(hProcess, addr1, 0xFFFC, PAGE_READONLY, &old_prot),
125        "VirtualProtectEx should fail on a not committed memory\n");
126     todo_wine ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
127        GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
128         "got %u, expected ERROR_INVALID_ADDRESS\n", GetLastError());
129
130     addr2 = VirtualAllocEx(hProcess, addr1, 0x1000, MEM_COMMIT, PAGE_NOACCESS);
131     ok(addr1 == addr2, "VirtualAllocEx failed\n");
132
133     /* test a committed memory */
134     todo_wine ok(VirtualQueryEx(hProcess, addr1, &info, sizeof(info))
135                  == sizeof(info),
136         "VirtualQueryEx failed\n");
137     todo_wine ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress,
138                  addr1);
139     todo_wine ok(info.AllocationBase == addr1, "%p != %p\n",
140                  info.AllocationBase, addr1);
141     todo_wine ok(info.AllocationProtect == PAGE_NOACCESS,
142                  "%x != PAGE_NOACCESS\n", info.AllocationProtect);
143     todo_wine ok(info.RegionSize == 0x1000, "%lx != 0x1000\n", info.RegionSize);
144     todo_wine ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
145     /* this time NT reports PAGE_NOACCESS as well */
146     todo_wine ok(info.Protect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.Protect);
147     todo_wine ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
148
149     /* this should fail, since not the whole range is committed yet */
150     SetLastError(0xdeadbeef);
151     ok(!VirtualProtectEx(hProcess, addr1, 0xFFFC, PAGE_READONLY, &old_prot),
152         "VirtualProtectEx should fail on a not committed memory\n");
153     todo_wine ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
154        GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
155         "got %u, expected ERROR_INVALID_ADDRESS\n", GetLastError());
156
157     todo_wine ok(VirtualProtectEx(hProcess, addr1, 0x1000, PAGE_READONLY,
158                                   &old_prot), "VirtualProtectEx failed\n");
159     todo_wine ok(old_prot == PAGE_NOACCESS,
160         "wrong old protection: got %04x instead of PAGE_NOACCESS\n", old_prot);
161
162     todo_wine ok(VirtualProtectEx(hProcess, addr1, 0x1000, PAGE_READWRITE,
163                                   &old_prot), "VirtualProtectEx failed\n");
164     todo_wine ok(old_prot == PAGE_READONLY,
165         "wrong old protection: got %04x instead of PAGE_READONLY\n", old_prot);
166
167     ok(!VirtualFreeEx(hProcess, addr1, 0x10000, 0),
168        "VirtualFreeEx should fail with type 0\n");
169     todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER,
170         "got %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
171
172     todo_wine ok(VirtualFreeEx(hProcess, addr1, 0x10000, MEM_DECOMMIT),
173                  "VirtualFreeEx failed\n");
174
175     /* if the type is MEM_RELEASE, size must be 0 */
176     ok(!VirtualFreeEx(hProcess, addr1, 1, MEM_RELEASE),
177        "VirtualFreeEx should fail\n");
178     todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER,
179         "got %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
180
181     todo_wine ok(VirtualFreeEx(hProcess, addr1, 0, MEM_RELEASE),
182                  "VirtualFreeEx failed\n");
183
184     TerminateProcess(hProcess, 0);
185     CloseHandle(hProcess);
186 }
187
188 static void test_VirtualAlloc(void)
189 {
190     void *addr1, *addr2;
191     DWORD old_prot;
192     MEMORY_BASIC_INFORMATION info;
193
194     SetLastError(0xdeadbeef);
195     addr1 = VirtualAlloc(0, 0, MEM_RESERVE, PAGE_NOACCESS);
196     ok(addr1 == NULL, "VirtualAlloc should fail on zero-sized allocation\n");
197     ok(GetLastError() == ERROR_INVALID_PARAMETER /* NT */ ||
198        GetLastError() == ERROR_NOT_ENOUGH_MEMORY, /* Win9x */
199         "got %d, expected ERROR_INVALID_PARAMETER\n", GetLastError());
200
201     addr1 = VirtualAlloc(0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
202     ok(addr1 != NULL, "VirtualAlloc failed\n");
203
204     /* test a not committed memory */
205     ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info),
206         "VirtualQuery failed\n");
207     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
208     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
209     ok(info.AllocationProtect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.AllocationProtect);
210     ok(info.RegionSize == 0x10000, "%lx != 0x10000\n", info.RegionSize);
211     ok(info.State == MEM_RESERVE, "%x != MEM_RESERVE\n", info.State);
212     /* NT reports Protect == 0 for a not committed memory block */
213     ok(info.Protect == 0 /* NT */ ||
214        info.Protect == PAGE_NOACCESS, /* Win9x */
215         "%x != PAGE_NOACCESS\n", info.Protect);
216     ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
217
218     SetLastError(0xdeadbeef);
219     ok(!VirtualProtect(addr1, 0xFFFC, PAGE_READONLY, &old_prot),
220        "VirtualProtect should fail on a not committed memory\n");
221     ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
222        GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
223         "got %d, expected ERROR_INVALID_ADDRESS\n", GetLastError());
224
225     addr2 = VirtualAlloc(addr1, 0x1000, MEM_COMMIT, PAGE_NOACCESS);
226     ok(addr1 == addr2, "VirtualAlloc failed\n");
227
228     /* test a committed memory */
229     ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info),
230         "VirtualQuery failed\n");
231     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
232     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
233     ok(info.AllocationProtect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.AllocationProtect);
234     ok(info.RegionSize == 0x1000, "%lx != 0x1000\n", info.RegionSize);
235     ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
236     /* this time NT reports PAGE_NOACCESS as well */
237     ok(info.Protect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.Protect);
238     ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
239
240     /* this should fail, since not the whole range is committed yet */
241     SetLastError(0xdeadbeef);
242     ok(!VirtualProtect(addr1, 0xFFFC, PAGE_READONLY, &old_prot),
243         "VirtualProtect should fail on a not committed memory\n");
244     ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
245        GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
246         "got %d, expected ERROR_INVALID_ADDRESS\n", GetLastError());
247
248     ok(VirtualProtect(addr1, 0x1000, PAGE_READONLY, &old_prot), "VirtualProtect failed\n");
249     ok(old_prot == PAGE_NOACCESS,
250         "wrong old protection: got %04x instead of PAGE_NOACCESS\n", old_prot);
251
252     ok(VirtualProtect(addr1, 0x1000, PAGE_READWRITE, &old_prot), "VirtualProtect failed\n");
253     ok(old_prot == PAGE_READONLY,
254         "wrong old protection: got %04x instead of PAGE_READONLY\n", old_prot);
255
256     ok(!VirtualFree(addr1, 0x10000, 0), "VirtualFree should fail with type 0\n");
257     ok(GetLastError() == ERROR_INVALID_PARAMETER,
258         "got %d, expected ERROR_INVALID_PARAMETER\n", GetLastError());
259
260     ok(VirtualFree(addr1, 0x10000, MEM_DECOMMIT), "VirtualFree failed\n");
261
262     /* if the type is MEM_RELEASE, size must be 0 */
263     ok(!VirtualFree(addr1, 1, MEM_RELEASE), "VirtualFree should fail\n");
264     ok(GetLastError() == ERROR_INVALID_PARAMETER,
265         "got %d, expected ERROR_INVALID_PARAMETER\n", GetLastError());
266
267     ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n");
268 }
269
270 static void test_MapViewOfFile(void)
271 {
272     static const char testfile[] = "testfile.xxx";
273     HANDLE file, mapping;
274     void *ptr;
275
276     file = CreateFileA( testfile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
277     ok( file != INVALID_HANDLE_VALUE, "Failed to create test file\n" );
278     SetFilePointer( file, 4096, NULL, FILE_BEGIN );
279     SetEndOfFile( file );
280
281     /* read/write mapping */
282
283     mapping = CreateFileMappingA( file, NULL, PAGE_READWRITE, 0, 4096, NULL );
284     ok( mapping != 0, "CreateFileMapping failed\n" );
285
286     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
287     ok( ptr != NULL, "MapViewOfFile FILE_MAPE_READ failed\n" );
288     UnmapViewOfFile( ptr );
289
290     /* this fails on win9x but succeeds on NT */
291     ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
292     if (ptr) UnmapViewOfFile( ptr );
293     else ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n", GetLastError() );
294
295     ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
296     ok( ptr != NULL, "MapViewOfFile 0 failed\n" );
297     UnmapViewOfFile( ptr );
298
299     ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 4096 );
300     ok( ptr != NULL, "MapViewOfFile FILE_MAP_WRITE failed\n" );
301     UnmapViewOfFile( ptr );
302     CloseHandle( mapping );
303
304     /* read-only mapping */
305
306     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 4096, NULL );
307     ok( mapping != 0, "CreateFileMapping failed\n" );
308
309     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
310     ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ failed\n" );
311     UnmapViewOfFile( ptr );
312
313     /* this fails on win9x but succeeds on NT */
314     ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
315     if (ptr) UnmapViewOfFile( ptr );
316     else ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n", GetLastError() );
317
318     ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
319     ok( ptr != NULL, "MapViewOfFile 0 failed\n" );
320     UnmapViewOfFile( ptr );
321
322     ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 4096 );
323     ok( !ptr, "MapViewOfFile FILE_MAP_WRITE succeeded\n" );
324     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
325         GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
326     CloseHandle( mapping );
327
328     /* copy-on-write mapping */
329
330     mapping = CreateFileMappingA( file, NULL, PAGE_WRITECOPY, 0, 4096, NULL );
331     ok( mapping != 0, "CreateFileMapping failed\n" );
332
333     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
334     ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ failed\n" );
335     UnmapViewOfFile( ptr );
336
337     ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
338     ok( ptr != NULL, "MapViewOfFile FILE_MAP_COPY failed\n" );
339     UnmapViewOfFile( ptr );
340
341     ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
342     ok( ptr != NULL, "MapViewOfFile 0 failed\n" );
343     UnmapViewOfFile( ptr );
344
345     ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 4096 );
346     ok( !ptr, "MapViewOfFile FILE_MAP_WRITE succeeded\n" );
347     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
348         GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
349     CloseHandle( mapping );
350
351     /* no access mapping */
352
353     mapping = CreateFileMappingA( file, NULL, PAGE_NOACCESS, 0, 4096, NULL );
354     /* fails on NT but succeeds on win9x */
355     if (!mapping) ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n", GetLastError() );
356     else
357     {
358         ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
359         ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ failed\n" );
360         UnmapViewOfFile( ptr );
361
362         ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
363         ok( !ptr, "MapViewOfFile FILE_MAP_COPY succeeded\n" );
364         ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n", GetLastError() );
365
366         ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
367         ok( ptr != NULL, "MapViewOfFile 0 failed\n" );
368         UnmapViewOfFile( ptr );
369
370         ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 4096 );
371         ok( !ptr, "MapViewOfFile FILE_MAP_WRITE succeeded\n" );
372         ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n", GetLastError() );
373
374         CloseHandle( mapping );
375     }
376
377     CloseHandle( file );
378
379     /* now try read-only file */
380
381     file = CreateFileA( testfile, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0 );
382     ok( file != INVALID_HANDLE_VALUE, "Failed to create test file\n" );
383
384     mapping = CreateFileMappingA( file, NULL, PAGE_READWRITE, 0, 4096, NULL );
385     ok( !mapping, "CreateFileMapping PAGE_READWRITE succeeded\n" );
386     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
387         GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
388
389     mapping = CreateFileMappingA( file, NULL, PAGE_WRITECOPY, 0, 4096, NULL );
390     ok( mapping != 0, "CreateFileMapping PAGE_WRITECOPY failed\n" );
391     CloseHandle( mapping );
392
393     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 4096, NULL );
394     ok( mapping != 0, "CreateFileMapping PAGE_READONLY failed\n" );
395     CloseHandle( mapping );
396     CloseHandle( file );
397
398     /* now try no access file */
399
400     file = CreateFileA( testfile, 0, 0, NULL, OPEN_EXISTING, 0, 0 );
401     ok( file != INVALID_HANDLE_VALUE, "Failed to create test file\n" );
402
403     mapping = CreateFileMappingA( file, NULL, PAGE_READWRITE, 0, 4096, NULL );
404     ok( !mapping, "CreateFileMapping PAGE_READWRITE succeeded\n" );
405     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
406         GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
407
408     mapping = CreateFileMappingA( file, NULL, PAGE_WRITECOPY, 0, 4096, NULL );
409     ok( !mapping, "CreateFileMapping PAGE_WRITECOPY succeeded\n" );
410     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
411         GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
412
413     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 4096, NULL );
414     ok( !mapping, "CreateFileMapping PAGE_READONLY succeeded\n" );
415     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
416         GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
417
418     CloseHandle( file );
419
420     CloseHandle( file );
421     DeleteFileA( testfile );
422 }
423
424 START_TEST(virtual)
425 {
426     int argc;
427     char **argv;
428     argc = winetest_get_mainargs( &argv );
429
430     if (argc >= 3)
431     {
432         if (!strcmp(argv[2], "sleep"))
433         {
434             Sleep(5000); /* spawned process runs for at most 5 seconds */
435             return;
436         }
437         while (1)
438         {
439             void *mem;
440             BOOL ret;
441             mem = VirtualAlloc(NULL, 1<<20, MEM_COMMIT|MEM_RESERVE,
442                                PAGE_EXECUTE_READWRITE);
443             ok(mem != NULL, "VirtualAlloc failed %u\n", GetLastError());
444             if (mem == NULL) break;
445             ret = VirtualFree(mem, 0, MEM_RELEASE);
446             ok(ret, "VirtualFree failed %u\n", GetLastError());
447             if (!ret) break;
448         }
449         return;
450     }
451
452     test_VirtualAllocEx();
453     test_VirtualAlloc();
454     test_MapViewOfFile();
455 }