dmloader: Declare some functions static.
[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     src = (char *) HeapAlloc( GetProcessHeap(), 0, alloc_size );
62     dst = (char *) HeapAlloc( GetProcessHeap(), 0, alloc_size );
63     for (i = 0; i < alloc_size; i++)
64         src[i] = 0xcafedead + i;
65
66     addr1 = VirtualAllocEx(hProcess, NULL, alloc_size, MEM_COMMIT,
67                            PAGE_EXECUTE_READWRITE);
68     todo_wine ok(addr1 != NULL, "VirtualAllocEx error %u\n", GetLastError());
69     b = WriteProcessMemory(hProcess, addr1, src, alloc_size, &bytes_written);
70     ok(b && (bytes_written == alloc_size), "%lu bytes written\n",
71        bytes_written);
72     b = ReadProcessMemory(hProcess, addr1, dst, alloc_size, &bytes_read);
73     ok(b && (bytes_read == alloc_size), "%lu bytes read\n", bytes_read);
74     ok(!memcmp(src, dst, alloc_size), "Data from remote process differs\n");
75     b = VirtualFreeEx(hProcess, addr1, 0, MEM_RELEASE);
76     todo_wine ok(b != 0, "VirtualFreeEx, error %u\n", GetLastError());
77
78     HeapFree( GetProcessHeap(), 0, src );
79     HeapFree( GetProcessHeap(), 0, dst );
80
81     /*
82      * The following tests parallel those in test_VirtualAlloc()
83      */
84
85     SetLastError(0xdeadbeef);
86     addr1 = VirtualAllocEx(hProcess, 0, 0, MEM_RESERVE, PAGE_NOACCESS);
87     ok(addr1 == NULL, "VirtualAllocEx should fail on zero-sized allocation\n");
88     ok(GetLastError() == ERROR_INVALID_PARAMETER /* NT */ ||
89        GetLastError() == ERROR_NOT_ENOUGH_MEMORY, /* Win9x */
90         "got %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
91
92     addr1 = VirtualAllocEx(hProcess, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
93     todo_wine ok(addr1 != NULL, "VirtualAllocEx failed\n");
94
95     /* test a not committed memory */
96     memset(&info, 'q', sizeof(info));
97     todo_wine ok(VirtualQueryEx(hProcess, addr1, &info, sizeof(info))
98                  == sizeof(info), "VirtualQueryEx failed\n");
99     todo_wine ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress,
100                  addr1);
101     todo_wine ok(info.AllocationBase == addr1, "%p != %p\n",
102                  info.AllocationBase, addr1);
103     todo_wine ok(info.AllocationProtect == PAGE_NOACCESS,
104                  "%x != PAGE_NOACCESS\n", info.AllocationProtect);
105     todo_wine ok(info.RegionSize == 0x10000, "%lx != 0x10000\n",
106                  info.RegionSize);
107     todo_wine ok(info.State == MEM_RESERVE, "%x != MEM_RESERVE\n", info.State);
108     /* NT reports Protect == 0 for a not committed memory block */
109     todo_wine ok(info.Protect == 0 /* NT */ ||
110        info.Protect == PAGE_NOACCESS, /* Win9x */
111         "%x != PAGE_NOACCESS\n", info.Protect);
112     todo_wine ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
113
114     SetLastError(0xdeadbeef);
115     ok(!VirtualProtectEx(hProcess, addr1, 0xFFFC, PAGE_READONLY, &old_prot),
116        "VirtualProtectEx should fail on a not committed memory\n");
117     todo_wine ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
118        GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
119         "got %u, expected ERROR_INVALID_ADDRESS\n", GetLastError());
120
121     addr2 = VirtualAllocEx(hProcess, addr1, 0x1000, MEM_COMMIT, PAGE_NOACCESS);
122     ok(addr1 == addr2, "VirtualAllocEx failed\n");
123
124     /* test a committed memory */
125     todo_wine ok(VirtualQueryEx(hProcess, addr1, &info, sizeof(info))
126                  == sizeof(info),
127         "VirtualQueryEx failed\n");
128     todo_wine ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress,
129                  addr1);
130     todo_wine ok(info.AllocationBase == addr1, "%p != %p\n",
131                  info.AllocationBase, addr1);
132     todo_wine ok(info.AllocationProtect == PAGE_NOACCESS,
133                  "%x != PAGE_NOACCESS\n", info.AllocationProtect);
134     todo_wine ok(info.RegionSize == 0x1000, "%lx != 0x1000\n", info.RegionSize);
135     todo_wine ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
136     /* this time NT reports PAGE_NOACCESS as well */
137     todo_wine ok(info.Protect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.Protect);
138     todo_wine ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
139
140     /* this should fail, since not the whole range is committed yet */
141     SetLastError(0xdeadbeef);
142     ok(!VirtualProtectEx(hProcess, addr1, 0xFFFC, PAGE_READONLY, &old_prot),
143         "VirtualProtectEx should fail on a not committed memory\n");
144     todo_wine ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
145        GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
146         "got %u, expected ERROR_INVALID_ADDRESS\n", GetLastError());
147
148     todo_wine ok(VirtualProtectEx(hProcess, addr1, 0x1000, PAGE_READONLY,
149                                   &old_prot), "VirtualProtectEx failed\n");
150     todo_wine ok(old_prot == PAGE_NOACCESS,
151         "wrong old protection: got %04x instead of PAGE_NOACCESS\n", old_prot);
152
153     todo_wine ok(VirtualProtectEx(hProcess, addr1, 0x1000, PAGE_READWRITE,
154                                   &old_prot), "VirtualProtectEx failed\n");
155     todo_wine ok(old_prot == PAGE_READONLY,
156         "wrong old protection: got %04x instead of PAGE_READONLY\n", old_prot);
157
158     ok(!VirtualFreeEx(hProcess, addr1, 0x10000, 0),
159        "VirtualFreeEx should fail with type 0\n");
160     todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER,
161         "got %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
162
163     todo_wine ok(VirtualFreeEx(hProcess, addr1, 0x10000, MEM_DECOMMIT),
164                  "VirtualFreeEx failed\n");
165
166     /* if the type is MEM_RELEASE, size must be 0 */
167     ok(!VirtualFreeEx(hProcess, addr1, 1, MEM_RELEASE),
168        "VirtualFreeEx should fail\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, 0, MEM_RELEASE),
173                  "VirtualFreeEx failed\n");
174
175     TerminateProcess(hProcess, 0);
176     CloseHandle(hProcess);
177 }
178
179 static void test_VirtualAlloc(void)
180 {
181     void *addr1, *addr2;
182     DWORD old_prot;
183     MEMORY_BASIC_INFORMATION info;
184
185     SetLastError(0xdeadbeef);
186     addr1 = VirtualAlloc(0, 0, MEM_RESERVE, PAGE_NOACCESS);
187     ok(addr1 == NULL, "VirtualAlloc should fail on zero-sized allocation\n");
188     ok(GetLastError() == ERROR_INVALID_PARAMETER /* NT */ ||
189        GetLastError() == ERROR_NOT_ENOUGH_MEMORY, /* Win9x */
190         "got %d, expected ERROR_INVALID_PARAMETER\n", GetLastError());
191
192     addr1 = VirtualAlloc(0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
193     ok(addr1 != NULL, "VirtualAlloc failed\n");
194
195     /* test a not committed memory */
196     ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info),
197         "VirtualQuery failed\n");
198     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
199     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
200     ok(info.AllocationProtect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.AllocationProtect);
201     ok(info.RegionSize == 0x10000, "%lx != 0x10000\n", info.RegionSize);
202     ok(info.State == MEM_RESERVE, "%x != MEM_RESERVE\n", info.State);
203     /* NT reports Protect == 0 for a not committed memory block */
204     ok(info.Protect == 0 /* NT */ ||
205        info.Protect == PAGE_NOACCESS, /* Win9x */
206         "%x != PAGE_NOACCESS\n", info.Protect);
207     ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
208
209     SetLastError(0xdeadbeef);
210     ok(!VirtualProtect(addr1, 0xFFFC, PAGE_READONLY, &old_prot),
211        "VirtualProtect should fail on a not committed memory\n");
212     ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
213        GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
214         "got %d, expected ERROR_INVALID_ADDRESS\n", GetLastError());
215
216     addr2 = VirtualAlloc(addr1, 0x1000, MEM_COMMIT, PAGE_NOACCESS);
217     ok(addr1 == addr2, "VirtualAlloc failed\n");
218
219     /* test a committed memory */
220     ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info),
221         "VirtualQuery failed\n");
222     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
223     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
224     ok(info.AllocationProtect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.AllocationProtect);
225     ok(info.RegionSize == 0x1000, "%lx != 0x1000\n", info.RegionSize);
226     ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
227     /* this time NT reports PAGE_NOACCESS as well */
228     ok(info.Protect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.Protect);
229     ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
230
231     /* this should fail, since not the whole range is committed yet */
232     SetLastError(0xdeadbeef);
233     ok(!VirtualProtect(addr1, 0xFFFC, PAGE_READONLY, &old_prot),
234         "VirtualProtect should fail on a not committed memory\n");
235     ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
236        GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
237         "got %d, expected ERROR_INVALID_ADDRESS\n", GetLastError());
238
239     ok(VirtualProtect(addr1, 0x1000, PAGE_READONLY, &old_prot), "VirtualProtect failed\n");
240     ok(old_prot == PAGE_NOACCESS,
241         "wrong old protection: got %04x instead of PAGE_NOACCESS\n", old_prot);
242
243     ok(VirtualProtect(addr1, 0x1000, PAGE_READWRITE, &old_prot), "VirtualProtect failed\n");
244     ok(old_prot == PAGE_READONLY,
245         "wrong old protection: got %04x instead of PAGE_READONLY\n", old_prot);
246
247     ok(!VirtualFree(addr1, 0x10000, 0), "VirtualFree should fail with type 0\n");
248     ok(GetLastError() == ERROR_INVALID_PARAMETER,
249         "got %d, expected ERROR_INVALID_PARAMETER\n", GetLastError());
250
251     ok(VirtualFree(addr1, 0x10000, MEM_DECOMMIT), "VirtualFree failed\n");
252
253     /* if the type is MEM_RELEASE, size must be 0 */
254     ok(!VirtualFree(addr1, 1, MEM_RELEASE), "VirtualFree should fail\n");
255     ok(GetLastError() == ERROR_INVALID_PARAMETER,
256         "got %d, expected ERROR_INVALID_PARAMETER\n", GetLastError());
257
258     ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n");
259 }
260
261 static void test_MapViewOfFile(void)
262 {
263     static const char testfile[] = "testfile.xxx";
264     HANDLE file, mapping;
265     void *ptr;
266
267     file = CreateFileA( testfile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
268     ok( file != INVALID_HANDLE_VALUE, "Failed to create test file\n" );
269     SetFilePointer( file, 4096, NULL, FILE_BEGIN );
270     SetEndOfFile( file );
271
272     /* read/write mapping */
273
274     mapping = CreateFileMappingA( file, NULL, PAGE_READWRITE, 0, 4096, NULL );
275     ok( mapping != 0, "CreateFileMapping failed\n" );
276
277     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
278     ok( ptr != NULL, "MapViewOfFile FILE_MAPE_READ failed\n" );
279     UnmapViewOfFile( ptr );
280
281     /* this fails on win9x but succeeds on NT */
282     ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
283     if (ptr) UnmapViewOfFile( ptr );
284     else ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n", GetLastError() );
285
286     ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
287     ok( ptr != NULL, "MapViewOfFile 0 failed\n" );
288     UnmapViewOfFile( ptr );
289
290     ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 4096 );
291     ok( ptr != NULL, "MapViewOfFile FILE_MAP_WRITE failed\n" );
292     UnmapViewOfFile( ptr );
293     CloseHandle( mapping );
294
295     /* read-only mapping */
296
297     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 4096, NULL );
298     ok( mapping != 0, "CreateFileMapping failed\n" );
299
300     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
301     ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ failed\n" );
302     UnmapViewOfFile( ptr );
303
304     /* this fails on win9x but succeeds on NT */
305     ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
306     if (ptr) UnmapViewOfFile( ptr );
307     else ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n", GetLastError() );
308
309     ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
310     ok( ptr != NULL, "MapViewOfFile 0 failed\n" );
311     UnmapViewOfFile( ptr );
312
313     ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 4096 );
314     ok( !ptr, "MapViewOfFile FILE_MAP_WRITE succeeded\n" );
315     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
316         GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
317     CloseHandle( mapping );
318
319     /* copy-on-write mapping */
320
321     mapping = CreateFileMappingA( file, NULL, PAGE_WRITECOPY, 0, 4096, NULL );
322     ok( mapping != 0, "CreateFileMapping failed\n" );
323
324     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
325     ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ failed\n" );
326     UnmapViewOfFile( ptr );
327
328     ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
329     ok( ptr != NULL, "MapViewOfFile FILE_MAP_COPY failed\n" );
330     UnmapViewOfFile( ptr );
331
332     ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
333     ok( ptr != NULL, "MapViewOfFile 0 failed\n" );
334     UnmapViewOfFile( ptr );
335
336     ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 4096 );
337     ok( !ptr, "MapViewOfFile FILE_MAP_WRITE succeeded\n" );
338     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
339         GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
340     CloseHandle( mapping );
341
342     /* no access mapping */
343
344     mapping = CreateFileMappingA( file, NULL, PAGE_NOACCESS, 0, 4096, NULL );
345     /* fails on NT but succeeds on win9x */
346     if (!mapping) ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n", GetLastError() );
347     else
348     {
349         ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
350         ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ failed\n" );
351         UnmapViewOfFile( ptr );
352
353         ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
354         ok( !ptr, "MapViewOfFile FILE_MAP_COPY succeeded\n" );
355         ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n", GetLastError() );
356
357         ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
358         ok( ptr != NULL, "MapViewOfFile 0 failed\n" );
359         UnmapViewOfFile( ptr );
360
361         ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 4096 );
362         ok( !ptr, "MapViewOfFile FILE_MAP_WRITE succeeded\n" );
363         ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n", GetLastError() );
364
365         CloseHandle( mapping );
366     }
367
368     CloseHandle( file );
369
370     /* now try read-only file */
371
372     file = CreateFileA( testfile, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0 );
373     ok( file != INVALID_HANDLE_VALUE, "Failed to create test file\n" );
374
375     mapping = CreateFileMappingA( file, NULL, PAGE_READWRITE, 0, 4096, NULL );
376     ok( !mapping, "CreateFileMapping PAGE_READWRITE succeeded\n" );
377     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
378         GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
379
380     mapping = CreateFileMappingA( file, NULL, PAGE_WRITECOPY, 0, 4096, NULL );
381     ok( mapping != 0, "CreateFileMapping PAGE_WRITECOPY failed\n" );
382     CloseHandle( mapping );
383
384     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 4096, NULL );
385     ok( mapping != 0, "CreateFileMapping PAGE_READONLY failed\n" );
386     CloseHandle( mapping );
387     CloseHandle( file );
388
389     /* now try no access file */
390
391     file = CreateFileA( testfile, 0, 0, NULL, OPEN_EXISTING, 0, 0 );
392     ok( file != INVALID_HANDLE_VALUE, "Failed to create test file\n" );
393
394     mapping = CreateFileMappingA( file, NULL, PAGE_READWRITE, 0, 4096, NULL );
395     ok( !mapping, "CreateFileMapping PAGE_READWRITE succeeded\n" );
396     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
397         GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
398
399     mapping = CreateFileMappingA( file, NULL, PAGE_WRITECOPY, 0, 4096, NULL );
400     ok( !mapping, "CreateFileMapping PAGE_WRITECOPY succeeded\n" );
401     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
402         GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
403
404     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 4096, NULL );
405     ok( !mapping, "CreateFileMapping PAGE_READONLY succeeded\n" );
406     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
407         GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
408
409     CloseHandle( file );
410
411     CloseHandle( file );
412     DeleteFileA( testfile );
413 }
414
415 START_TEST(virtual)
416 {
417     int argc;
418     char **argv;
419     argc = winetest_get_mainargs( &argv );
420
421     if (argc >= 3)
422     {
423         if (!strcmp(argv[2], "sleep"))
424         {
425             Sleep(5000); /* spawned process runs for at most 5 seconds */
426             return;
427         }
428         while (1)
429         {
430             void *mem;
431             BOOL ret;
432             mem = VirtualAlloc(NULL, 1<<20, MEM_COMMIT|MEM_RESERVE,
433                                PAGE_EXECUTE_READWRITE);
434             ok(mem != NULL, "VirtualAlloc failed %u\n", GetLastError());
435             if (mem == NULL) break;
436             ret = VirtualFree(mem, 0, MEM_RELEASE);
437             ok(ret, "VirtualFree failed %u\n", GetLastError());
438             if (!ret) break;
439         }
440         return;
441     }
442
443     test_VirtualAllocEx();
444     test_VirtualAlloc();
445     test_MapViewOfFile();
446 }