ReactOS 0.4.17-dev-37-g0bfb40d
virtual.c
Go to the documentation of this file.
1/*
2 * Unit test suite for the virtual memory APIs.
3 *
4 * Copyright 2019 Remi Bernon for CodeWeavers
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 <stdio.h>
22
23#include "ntstatus.h"
24#define WIN32_NO_STATUS
25#include "windef.h"
26#include "winternl.h"
27#include "wine/test.h"
28#include "ddk/wdm.h"
29
30static unsigned int page_size;
31
32static DWORD64 (WINAPI *pGetEnabledXStateFeatures)(void);
33static NTSTATUS (WINAPI *pRtlCreateUserStack)(SIZE_T, SIZE_T, ULONG, SIZE_T, SIZE_T, INITIAL_TEB *);
34static NTSTATUS (WINAPI *pRtlCreateUserThread)(HANDLE, SECURITY_DESCRIPTOR*, BOOLEAN, ULONG, SIZE_T,
36static ULONG64 (WINAPI *pRtlGetEnabledExtendedFeatures)(ULONG64);
37static NTSTATUS (WINAPI *pRtlFreeUserStack)(void *);
38static void * (WINAPI *pRtlFindExportedRoutineByName)(HMODULE,const char*);
39static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
40static NTSTATUS (WINAPI *pRtlGetNativeSystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG);
41static BOOLEAN (WINAPI *pRtlIsEcCode)(const void *);
42static NTSTATUS (WINAPI *pNtAllocateVirtualMemoryEx)(HANDLE, PVOID *, SIZE_T *, ULONG, ULONG,
44static NTSTATUS (WINAPI *pNtMapViewOfSectionEx)(HANDLE, HANDLE, PVOID *, const LARGE_INTEGER *, SIZE_T *,
46static NTSTATUS (WINAPI *pNtSetInformationVirtualMemory)(HANDLE, VIRTUAL_MEMORY_INFORMATION_CLASS,
48 PVOID, ULONG);
49
50static const BOOL is_win64 = sizeof(void*) != sizeof(int);
52
54
55static HANDLE create_target_process(const char *arg)
56{
57 char **argv;
58 char cmdline[MAX_PATH];
60 BOOL ret;
61 STARTUPINFOA si = { 0 };
62 si.cb = sizeof(si);
63
65 sprintf(cmdline, "%s %s %s", argv[0], argv[1], arg);
67 ok(ret, "error: %lu\n", GetLastError());
69 ok(ret, "error %lu\n", GetLastError());
70 return pi.hProcess;
71}
72
74{
75 UINT_PTR z = 0;
76
77#ifdef _WIN64
78 if (p >= 0xffffffff)
79 return (~(UINT_PTR)0) >> get_zero_bits(p >> 32);
80#endif
81
82 if (p == 0) return 0;
83 while ((p >> (31 - z)) != 1) z++;
84 return z;
85}
86
88{
89 if (z >= 32)
90 {
91 z = get_zero_bits(z);
92#ifdef _WIN64
93 if (z >= 32) return z;
94#endif
95 }
96 return (~(UINT32)0) >> z;
97}
98
100{
101 void *addr1, *addr2;
103 SIZE_T size;
104 ULONG_PTR zero_bits;
105
106 /* simple allocation should success */
107 size = 0x1000;
108 addr1 = NULL;
111 ok(status == STATUS_SUCCESS, "NtAllocateVirtualMemory returned %08lx\n", status);
112
113 /* allocation conflicts because of 64k align */
114 size = 0x1000;
115 addr2 = (char *)addr1 + 0x1000;
118 ok(status == STATUS_CONFLICTING_ADDRESSES, "NtAllocateVirtualMemory returned %08lx\n", status);
119
120 /* it should conflict, even when zero_bits is explicitly set */
121 size = 0x1000;
122 addr2 = (char *)addr1 + 0x1000;
125 ok(status == STATUS_CONFLICTING_ADDRESSES, "NtAllocateVirtualMemory returned %08lx\n", status);
126
127 /* 1 zero bits should zero 63-31 upper bits */
128 size = 0x1000;
129 addr2 = NULL;
130 zero_bits = 1;
131 status = NtAllocateVirtualMemory(NtCurrentProcess(), &addr2, zero_bits, &size,
136 "NtAllocateVirtualMemory returned %08lx\n", status);
137 if (status == STATUS_SUCCESS)
138 {
139 ok(((UINT_PTR)addr2 >> (32 - zero_bits)) == 0,
140 "NtAllocateVirtualMemory returned address: %p\n", addr2);
141
142 size = 0;
144 ok(status == STATUS_SUCCESS, "NtFreeVirtualMemory return %08lx, addr2: %p\n", status, addr2);
145 }
146
147 for (zero_bits = 2; zero_bits <= 20; zero_bits++)
148 {
149 size = 0x1000;
150 addr2 = NULL;
151 status = NtAllocateVirtualMemory(NtCurrentProcess(), &addr2, zero_bits, &size,
155 broken(zero_bits == 20 && status == STATUS_CONFLICTING_ADDRESSES) /* w1064v1809 */,
156 "NtAllocateVirtualMemory with %d zero_bits returned %08lx\n", (int)zero_bits, status);
157 if (status == STATUS_SUCCESS)
158 {
159 ok(((UINT_PTR)addr2 >> (32 - zero_bits)) == 0,
160 "NtAllocateVirtualMemory with %d zero_bits returned address %p\n", (int)zero_bits, addr2);
161
162 size = 0;
164 ok(status == STATUS_SUCCESS, "NtFreeVirtualMemory return %08lx, addr2: %p\n", status, addr2);
165 }
166 }
167
168 /* 21 zero bits never succeeds */
169 size = 0x1000;
170 addr2 = NULL;
174 "NtAllocateVirtualMemory returned %08lx\n", status);
175 if (status == STATUS_SUCCESS)
176 {
177 size = 0;
179 ok(status == STATUS_SUCCESS, "NtFreeVirtualMemory return %08lx, addr2: %p\n", status, addr2);
180 }
181
182 /* 22 zero bits is invalid */
183 size = 0x1000;
184 addr2 = NULL;
188 "NtAllocateVirtualMemory returned %08lx\n", status);
189
190 /* zero bits > 31 should be considered as a leading zeroes bitmask on 64bit and WoW64 */
191 size = 0x1000;
192 addr2 = NULL;
193 zero_bits = 0x1aaaaaaa;
194 status = NtAllocateVirtualMemory(NtCurrentProcess(), &addr2, zero_bits, &size,
197
198 if (!is_win64 && !is_wow64)
199 {
200 ok(status == STATUS_INVALID_PARAMETER_3, "NtAllocateVirtualMemory returned %08lx\n", status);
201 }
202 else
203 {
205 "NtAllocateVirtualMemory returned %08lx\n", status);
206 if (status == STATUS_SUCCESS)
207 {
208 ok(((UINT_PTR)addr2 & ~get_zero_bits_mask(zero_bits)) == 0 &&
209 ((UINT_PTR)addr2 & ~zero_bits) != 0, /* only the leading zeroes matter */
210 "NtAllocateVirtualMemory returned address %p\n", addr2);
211
212 size = 0;
214 ok(status == STATUS_SUCCESS, "NtFreeVirtualMemory return %08lx, addr2: %p\n", status, addr2);
215 }
216 }
217
218 /* AT_ROUND_TO_PAGE flag is not supported for NtAllocateVirtualMemory */
219 size = 0x1000;
220 addr2 = (char *)addr1 + 0x1000;
224 "NtAllocateVirtualMemory returned %08lx\n", status);
225
226 size = 0;
228 ok(status == STATUS_SUCCESS, "NtFreeVirtualMemory failed\n");
229
230 /* NtFreeVirtualMemory tests */
231
232 size = 0x10000;
233 addr1 = NULL;
236 ok(status == STATUS_SUCCESS, "NtAllocateVirtualMemory returned %08lx\n", status);
237
238 size = 2;
239 addr2 = (char *)addr1 + 0x1fff;
241 ok(status == STATUS_SUCCESS, "NtFreeVirtualMemory failed %lx\n", status);
242 ok( size == 0x2000, "wrong size %Ix\n", size );
243 ok( addr2 == (char *)addr1 + 0x1000, "wrong addr %p\n", addr2 );
244
245 size = 0;
246 addr2 = (char *)addr1 + 0x1001;
248 ok(status == STATUS_FREE_VM_NOT_AT_BASE, "NtFreeVirtualMemory failed %lx\n", status);
249 ok( size == 0, "wrong size %Ix\n", size );
250 ok( addr2 == (char *)addr1 + 0x1001, "wrong addr %p\n", addr2 );
251
252 size = 0;
253 addr2 = (char *)addr1 + 0xffe;
255 ok(status == STATUS_SUCCESS, "NtFreeVirtualMemory failed %lx\n", status);
256 ok( size == 0 || broken(size == 0x10000) /* <= win10 1709 */, "wrong size %Ix\n", size );
257 ok( addr2 == addr1, "wrong addr %p\n", addr2 );
258
259 size = 0;
260 addr2 = (char *)addr1 + 0x1001;
262 ok(status == STATUS_FREE_VM_NOT_AT_BASE, "NtFreeVirtualMemory failed %lx\n", status);
263 ok( size == 0, "wrong size %Ix\n", size );
264 ok( addr2 == (char *)addr1 + 0x1001, "wrong addr %p\n", addr2 );
265
266 size = 0;
267 addr2 = (char *)addr1 + 0xfff;
269 ok(status == STATUS_SUCCESS, "NtFreeVirtualMemory failed %lx\n", status);
270 ok( size == 0x10000, "wrong size %Ix\n", size );
271 ok( addr2 == addr1, "wrong addr %p\n", addr2 );
272
273 /* Placeholder functionality */
274 size = 0x10000;
275 addr1 = NULL;
277 ok(!!status, "Unexpected status %08lx.\n", status);
278}
279
280#define check_region_size(p, s) check_region_size_(p, s, __LINE__)
281static void check_region_size_(void *p, SIZE_T s, unsigned int line)
282{
285 SIZE_T size;
286
287 memset(&mbi, 0, sizeof(mbi));
289 ok_(__FILE__,line)( !status, "Unexpected return value %08lx\n", status );
290 ok_(__FILE__,line)( size == sizeof(mbi), "Unexpected return value.\n");
291 ok_(__FILE__,line)( mbi.RegionSize == s, "Unexpected size %Iu, expected %Iu.\n", mbi.RegionSize, s);
292}
293
295{
298 char *p, *p1, *p2, *p3;
299 void *addresses[16];
300 SIZE_T size, size2;
301 ULONG granularity;
304 void *addr1;
305
306 if (!pNtAllocateVirtualMemoryEx)
307 {
308 win_skip("NtAllocateVirtualMemoryEx() is missing\n");
309 return;
310 }
311
312 size = 0x1000;
313 addr1 = NULL;
314 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_COMMIT,
316 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
317
318 size = 0;
320 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
321
322 /* specifying a count of >0 with NULL parameters should fail */
323 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_COMMIT,
325 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
326
327 /* NULL process handle */
328 size = 0x1000;
329 addr1 = NULL;
330 status = pNtAllocateVirtualMemoryEx(NULL, &addr1, &size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE, NULL, 0);
331 ok(status == STATUS_INVALID_HANDLE, "Unexpected status %08lx.\n", status);
332
333 /* Placeholder functionality */
334 size = 0x10000;
335 addr1 = NULL;
337 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
338
339 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
340 PAGE_READWRITE, NULL, 0);
341 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
342
343 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
344 PAGE_NOACCESS, NULL, 0);
345 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
346
347 size = 0x10000;
348 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_COMMIT | MEM_REPLACE_PLACEHOLDER,
349 PAGE_READWRITE, NULL, 0);
350 ok(!status, "Unexpected status %08lx.\n", status);
351
352 memset(addr1, 0xcc, size);
353
355 ok(!status, "Unexpected status %08lx.\n", status);
356
357 size = 0x10000;
358 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_COMMIT | MEM_REPLACE_PLACEHOLDER,
359 PAGE_READONLY, NULL, 0);
360 ok(!status, "Unexpected status %08lx.\n", status);
361
362 ok(!*(unsigned int *)addr1, "Got %#x.\n", *(unsigned int *)addr1);
363
364 status = NtQueryVirtualMemory( NtCurrentProcess(), addr1, MemoryBasicInformation, &mbi, sizeof(mbi), &size );
365 ok(!status, "Unexpected status %08lx.\n", status);
366 ok(mbi.AllocationProtect == PAGE_READONLY, "Unexpected protection %#lx.\n", mbi.AllocationProtect);
367 ok(mbi.State == MEM_COMMIT, "Unexpected state %#lx.\n", mbi.State);
368 ok(mbi.Type == MEM_PRIVATE, "Unexpected type %#lx.\n", mbi.Type);
369 ok(mbi.RegionSize == 0x10000, "Unexpected size.\n");
370
371 size = 0x10000;
373 ok(!status, "Unexpected status %08lx.\n", status);
374
375 status = NtQueryVirtualMemory( NtCurrentProcess(), addr1, MemoryBasicInformation, &mbi, sizeof(mbi), &size );
376 ok(!status, "Unexpected status %08lx.\n", status);
377 ok(mbi.AllocationProtect == PAGE_NOACCESS, "Unexpected protection %#lx.\n", mbi.AllocationProtect);
378 ok(mbi.State == MEM_RESERVE, "Unexpected state %#lx.\n", mbi.State);
379 ok(mbi.Type == MEM_PRIVATE, "Unexpected type %#lx.\n", mbi.Type);
380 ok(mbi.RegionSize == 0x10000, "Unexpected size.\n");
381
382 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
383 PAGE_NOACCESS, NULL, 0);
384 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
385
386 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE,
387 PAGE_NOACCESS, NULL, 0);
388 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
389
390 size = 0x1000;
391 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_REPLACE_PLACEHOLDER,
392 PAGE_NOACCESS, NULL, 0);
393 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
394
395 size = 0x10000;
396 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_COMMIT, PAGE_READWRITE, NULL, 0);
397 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
398
399 size = 0x10000;
400 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, NULL, 0);
401 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
402
403 size = 0x10000;
404 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_COMMIT | MEM_REPLACE_PLACEHOLDER,
405 PAGE_READWRITE, NULL, 0);
406 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
407
408 size = 0x10000;
409 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size,
411 PAGE_READONLY, NULL, 0);
412 ok(!status || broken(status == STATUS_INVALID_PARAMETER) /* Win10 1809, the version where
413 NtAllocateVirtualMemoryEx is introduced */, "Unexpected status %08lx.\n", status);
414
415 if (!status)
416 {
417 size = 0x10000;
418 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_COMMIT, PAGE_READWRITE, NULL, 0);
419 ok(!status, "Unexpected status %08lx.\n", status);
420
421 status = NtQueryVirtualMemory( NtCurrentProcess(), addr1, MemoryBasicInformation, &mbi, sizeof(mbi), &size );
422 ok(!status, "Unexpected status %08lx.\n", status);
423 ok(mbi.AllocationProtect == PAGE_READONLY, "Unexpected protection %#lx.\n", mbi.AllocationProtect);
424 ok(mbi.State == MEM_COMMIT, "Unexpected state %#lx.\n", mbi.State);
425 ok(mbi.Type == MEM_PRIVATE, "Unexpected type %#lx.\n", mbi.Type);
426 ok(mbi.RegionSize == 0x10000, "Unexpected size.\n");
427
428 size = 0x10000;
429 count = ARRAY_SIZE(addresses);
431 addresses, &count, &granularity );
432 ok(!status, "Unexpected status %08lx.\n", status);
433 ok(!count, "Unexpected count %u.\n", (unsigned int)count);
434 *((char *)addr1 + 0x1000) = 1;
435 count = ARRAY_SIZE(addresses);
437 addresses, &count, &granularity );
438 ok(!status, "Unexpected status %08lx.\n", status);
439 ok(count == 1, "Unexpected count %u.\n", (unsigned int)count);
440 ok(addresses[0] == (char *)addr1 + 0x1000, "Unexpected address %p.\n", addresses[0]);
441
442 size = 0;
444 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
445 }
446
447 /* Placeholder region splitting. */
448 addr1 = NULL;
449 size = 0x10000;
450 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE,
451 PAGE_NOACCESS, NULL, 0);
452 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
453 p = addr1;
455 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
456 ok(size == 0x10000, "Unexpected size %#Ix.\n", size);
458 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
459 ok(size == 0x10000, "Unexpected size %#Ix.\n", size);
460 ok(p == addr1, "Unexpected addr %p, expected %p.\n", p, addr1);
461
462
463 /* Split in three regions. */
464 addr1 = NULL;
465 size = 0x10000;
466 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
467 PAGE_NOACCESS, NULL, 0);
468 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
469
471 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
472
473 p = addr1;
474 p1 = p + size / 2;
475 p2 = p1 + size / 4;
476 size2 = size / 4;
478 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
479 ok(size2 == 0x4000, "Unexpected size %#Ix.\n", size2);
480 ok(p1 == p + size / 2, "Unexpected addr %p, expected %p.\n", p, p + size / 2);
481
483 check_region_size(p1, size / 4);
484 check_region_size(p2, size - size / 2 - size / 4);
485
487 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
488 ok(size2 == 0x4000, "Unexpected size %#Ix.\n", size2);
489 ok(p == addr1, "Unexpected addr %p, expected %p.\n", p, addr1);
490 status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE);
491 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
492 ok(size2 == 0x4000, "Unexpected size %#Ix.\n", size2);
493 ok(p1 == p + size / 2, "Unexpected addr %p, expected %p.\n", p1, p + size / 2);
494 status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE);
495 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
496 ok(size2 == 0x4000, "Unexpected size %#Ix.\n", size2);
497 ok(p2 == p1 + size / 4, "Unexpected addr %p, expected %p.\n", p2, p1 + size / 4);
498
499 /* Split in two regions, specifying lower part. */
500 addr1 = NULL;
501 size = 0x10000;
502 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
503 PAGE_NOACCESS, NULL, 0);
504 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
505
506 size2 = 0;
508 ok(status == STATUS_INVALID_PARAMETER_3, "Unexpected status %08lx.\n", status);
509 ok(!size2, "Unexpected size %#Ix.\n", size2);
510
511 p1 = addr1;
512 p2 = p1 + size / 4;
513 p3 = p2 + size / 4;
514 size2 = size / 4;
516 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
517 ok(p1 == addr1, "Unexpected address.\n");
518 ok(size2 == 0x4000, "Unexpected size %#Ix.\n", size2);
519 ok(p1 == addr1, "Unexpected addr %p, expected %p.\n", p1, addr1);
520
522 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
523
524 check_region_size(p1, p2 - p1);
525 check_region_size(p2, p3 - p2);
526 check_region_size(p3, size - (p3 - p1));
527
529 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
530
532 ok(status == STATUS_INVALID_PARAMETER_4, "Unexpected status %08lx.\n", status);
533
534 size2 = size + 0x1000;
536 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
537
538 size2 = size - 0x1000;
540 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
541
542 p1 = (char *)addr1 + 0x1000;
544 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
545 p1 = addr1;
546
547 size2 = 0;
549 ok(status == STATUS_INVALID_PARAMETER_3, "Unexpected status %08lx.\n", status);
550
552 ok(status == STATUS_UNABLE_TO_FREE_VM, "Unexpected status %08lx.\n", status);
553
555 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
556 ok(size == 0x10000, "Unexpected size %#Ix.\n", size);
557 ok(p1 == addr1, "Unexpected addr %p, expected %p.\n", p1, addr1);
559
560 size2 = size / 4;
562 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
563 ok(size2 == 0x4000, "Unexpected size %#Ix.\n", size2);
564 ok(p1 == addr1, "Unexpected addr %p, expected %p.\n", p1, addr1);
565 check_region_size(p1, size / 4);
566 check_region_size(p2, size - size / 4);
567
568 size2 = size - size / 4;
569 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), (void **)&p2, &size2, MEM_RESERVE | MEM_REPLACE_PLACEHOLDER,
570 PAGE_READWRITE, NULL, 0);
571 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
572
574 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
575
576 size2 = size - size / 4;
577 status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE);
578 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
579 ok(size2 == 0xc000, "Unexpected size %#Ix.\n", size2);
580 ok(p2 == p1 + size / 4, "Unexpected addr %p, expected %p.\n", p2, p1 + size / 4);
581
583 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
584
585 size2 = size / 4;
586 status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE);
587 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
588 ok(size2 == 0x4000, "Unexpected size %#Ix.\n", size2);
589 ok(p1 == addr1, "Unexpected addr %p, expected %p.\n", p1, addr1);
590
591 size2 = 0;
592 status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p3, &size2, MEM_RELEASE);
593 ok(status == STATUS_MEMORY_NOT_ALLOCATED, "Unexpected status %08lx.\n", status);
594
595 /* Split in two regions, specifying second half. */
596 addr1 = NULL;
597 size = 0x10000;
598 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
599 PAGE_NOACCESS, NULL, 0);
600 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
601 ok(size == 0x10000, "Unexpected size %#Ix.\n", size);
602
603 p1 = addr1;
604 p2 = p1 + size / 2;
605
606 size2 = size / 2;
608 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
609 ok(size2 == 0x8000, "Unexpected size %#Ix.\n", size2);
610 ok(p2 == p1 + size / 2, "Unexpected addr %p, expected %p.\n", p2, p1 + size / 2);
611 check_region_size(p1, size / 2);
612 check_region_size(p2, size / 2);
613 status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE);
614 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
615 ok(size2 == 0x8000, "Unexpected size %#Ix.\n", size2);
616 ok(p1 == addr1, "Unexpected addr %p, expected %p.\n", p1, addr1);
617 status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE);
618 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
619 ok(size2 == 0x8000, "Unexpected size %#Ix.\n", size2);
620 ok(p2 == p1 + size / 2, "Unexpected addr %p, expected %p.\n", p2, p1 + size / 2);
621
622 memset( ext, 0, sizeof(ext) );
624 ext[0].ULong = 0;
626 ext[1].ULong = 0;
627 size = 0x10000;
628 addr1 = NULL;
629 status = pNtAllocateVirtualMemoryEx( NtCurrentProcess(), &addr1, &size, MEM_RESERVE,
631 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
633 status = pNtAllocateVirtualMemoryEx( NtCurrentProcess(), &addr1, &size, MEM_RESERVE,
635 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
636
637 memset( ext, 0, sizeof(ext) );
640 size = 0x10000;
641 addr1 = NULL;
642 status = pNtAllocateVirtualMemoryEx( NtCurrentProcess(), &addr1, &size, MEM_RESERVE,
644#ifdef __x86_64__
645 if (pRtlGetNativeSystemInformation)
646 {
647 SYSTEM_CPU_INFORMATION cpu_info;
648
649 pRtlGetNativeSystemInformation( SystemCpuInformation, &cpu_info, sizeof(cpu_info), NULL );
651 {
652 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
653 if (pRtlIsEcCode) ok( pRtlIsEcCode( addr1 ), "not EC code %p\n", addr1 );
654 size = 0;
656
657 size = 0x10000;
658 addr1 = NULL;
659 status = pNtAllocateVirtualMemoryEx( NtCurrentProcess(), &addr1, &size, MEM_RESERVE,
661 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
662 if (pRtlIsEcCode) ok( !pRtlIsEcCode( addr1 ), "EC code %p\n", addr1 );
663 size = 0x1000;
664 status = pNtAllocateVirtualMemoryEx( NtCurrentProcess(), &addr1, &size, MEM_COMMIT,
666 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
667 if (pRtlIsEcCode)
668 {
669 ok( pRtlIsEcCode( addr1 ), "not EC code %p\n", addr1 );
670 ok( !pRtlIsEcCode( (char *)addr1 + 0x1000 ), "EC code %p\n", (char *)addr1 + 0x1000 );
671 }
672 size = 0x2000;
673 status = pNtAllocateVirtualMemoryEx( NtCurrentProcess(), &addr1, &size, MEM_COMMIT,
675 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
676 if (pRtlIsEcCode)
677 {
678 ok( pRtlIsEcCode( addr1 ), "not EC code %p\n", addr1 );
679 ok( !pRtlIsEcCode( (char *)addr1 + 0x1000 ), "EC code %p\n", (char *)addr1 + 0x1000 );
680 }
681
683 if (pRtlIsEcCode) ok( pRtlIsEcCode( addr1 ), "not EC code %p\n", addr1 );
684
685 size = 0x2000;
686 ext[0].ULong = 0;
687 status = pNtAllocateVirtualMemoryEx( NtCurrentProcess(), &addr1, &size, MEM_COMMIT,
689 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
690 if (pRtlIsEcCode)
691 {
692 ok( pRtlIsEcCode( addr1 ), "not EC code %p\n", addr1 );
693 ok( !pRtlIsEcCode( (char *)addr1 + 0x1000 ), "EC code %p\n", (char *)addr1 + 0x1000 );
694 }
695
696 size = 0;
698 return;
699 }
700 }
701#endif
703 "Unexpected status %08lx.\n", status);
704}
705
707{
712 SIZE_T size;
713 void *addr;
714
715 if (!pNtAllocateVirtualMemoryEx)
716 {
717 win_skip("NtAllocateVirtualMemoryEx() is missing\n");
718 return;
719 }
720
722
723 memset(&ext, 0, sizeof(ext));
724 ext[0].Type = 0;
725 size = 0x1000;
726 addr = NULL;
727 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE | MEM_COMMIT,
729 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
730
731 memset(&ext, 0, sizeof(ext));
733 size = 0x1000;
734 addr = NULL;
735 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE | MEM_COMMIT,
737 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
738
739 memset(&a, 0, sizeof(a));
741 ext[0].Pointer = &a;
742 size = 0x1000;
743 addr = NULL;
744 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE | MEM_COMMIT,
746 ok(!status, "Unexpected status %08lx.\n", status);
747 size = 0;
749 ok(!status, "Unexpected status %08lx.\n", status);
750
751 ext[1] = ext[0];
752 size = 0x1000;
753 addr = NULL;
754 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE | MEM_COMMIT,
756 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
757
758 a.LowestStartingAddress = NULL;
759 a.Alignment = 0;
760
761 a.HighestEndingAddress = (void *)(0x20001000 + 1);
762 size = 0x10000;
763 addr = NULL;
764 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
766 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
767
768 a.HighestEndingAddress = (void *)(0x20001000 - 2);
769 size = 0x10000;
770 addr = NULL;
771 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
773 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
774
775 a.HighestEndingAddress = (void *)(0x20000800 - 1);
776 size = 0x10000;
777 addr = NULL;
778 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
780 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
781
782 a.HighestEndingAddress = (char *)si.lpMaximumApplicationAddress + 0x1000;
783 size = 0x10000;
784 addr = NULL;
785 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
787 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
788
789 a.HighestEndingAddress = (char *)si.lpMaximumApplicationAddress;
790 size = 0x10000;
791 addr = NULL;
792 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
794 ok(!status, "Unexpected status %08lx.\n", status);
795 size = 0;
797 ok(!status, "Unexpected status %08lx.\n", status);
798
799 a.HighestEndingAddress = (void *)(0x20001000 - 1);
800 size = 0x40000;
801 addr = NULL;
802 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
804 ok(!status, "Unexpected status %08lx.\n", status);
805 ok(!((ULONG_PTR)addr & 0xffff), "Unexpected addr %p.\n", addr);
806 ok((ULONG_PTR)addr + size <= 0x20001000, "Unexpected addr %p.\n", addr);
807
808 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_COMMIT,
810 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
811
812 size = 0;
814 ok(!status, "Unexpected status %08lx.\n", status);
815
816
817 size = 0x40000;
818 a.HighestEndingAddress = (void *)(0x20001000 - 1);
819 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
821 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
822
826 "Unexpected status %08lx.\n", status);
827
830 if (is_win64 || is_wow64)
831 ok(!status || status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
832 else
834 "Unexpected status %08lx.\n", status);
835
836 if (!status)
837 {
838 size = 0;
840 ok(!status, "Unexpected status %08lx.\n", status);
841 }
842
843 a.HighestEndingAddress = NULL;
844 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
846 ok(!status || status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
847 if (!status)
848 {
849 size = 0;
851 ok(!status, "Unexpected status %08lx.\n", status);
852 }
853
854
855 a.HighestEndingAddress = (void *)(0x20001000 - 1);
856 a.Alignment = 0x10000;
857 size = 0x1000;
858 addr = NULL;
859 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
861 ok(!status, "Unexpected status %08lx.\n", status);
862 ok(!((ULONG_PTR)addr & 0xffff), "Unexpected addr %p.\n", addr);
863 ok((ULONG_PTR)addr + size < 0x20001000, "Unexpected addr %p.\n", addr);
864 size = 0;
866 ok(!status, "Unexpected status %08lx.\n", status);
867
868 a.HighestEndingAddress = (void *)(0x20001000 - 1);
869 a.Alignment = 0x20000000;
870 size = 0x2000;
871 addr = NULL;
872 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
874 ok(status == STATUS_NO_MEMORY, "Unexpected status %08lx.\n", status);
875
876 a.HighestEndingAddress = NULL;
877 a.Alignment = 0x8000;
878 size = 0x1000;
879 addr = NULL;
880 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
882 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
883
884 a.Alignment = 0x30000;
885 size = 0x1000;
886 addr = NULL;
887 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
889 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
890
891 a.Alignment = 0x40000;
892 size = 0x1000;
893 addr = NULL;
894 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
896 ok(!status, "Unexpected status %08lx.\n", status);
897 ok(!((ULONG_PTR)addr & 0x3ffff), "Unexpected addr %p.\n", addr);
898 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_COMMIT,
900 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
901
902 size = 0;
904 ok(!status, "Unexpected status %08lx.\n", status);
905
906 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
908 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
909
910 a.LowestStartingAddress = (void *)0x20001000;
911 a.Alignment = 0;
912 size = 0x1000;
913 addr = NULL;
914 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
916 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
917
918 a.LowestStartingAddress = (void *)(0x20001000 - 1);
919 size = 0x1000;
920 addr = NULL;
921 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
923 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
924
925 a.LowestStartingAddress = (void *)(0x20001000 + 1);
926 size = 0x1000;
927 addr = NULL;
928 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
930 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
931
932 a.LowestStartingAddress = (void *)0x30000000;
933 a.HighestEndingAddress = (void *)0x20000000;
934 size = 0x1000;
935 addr = NULL;
936 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
938 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
939
940 a.LowestStartingAddress = (void *)0x20000000;
941 a.HighestEndingAddress = 0;
942 size = 0x1000;
943 addr = NULL;
944 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
946 ok(!status, "Unexpected status %08lx.\n", status);
947 ok(addr >= (void *)0x20000000, "Unexpected addr %p.\n", addr);
948 size = 0;
950 ok(!status, "Unexpected status %08lx.\n", status);
951
952 a.LowestStartingAddress = (void *)0x20000000;
953 a.HighestEndingAddress = (void *)0x2fffffff;
954 size = 0x1000;
955 addr = NULL;
956 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
958 ok(!status, "Unexpected status %08lx.\n", status);
959 ok(addr >= (void *)0x20000000 && addr < (void *)0x30000000, "Unexpected addr %p.\n", addr);
960 size = 0;
962 ok(!status, "Unexpected status %08lx.\n", status);
963
964 a.LowestStartingAddress = (char *)si.lpMaximumApplicationAddress + 1;
965 a.HighestEndingAddress = 0;
966 size = 0x10000;
967 addr = NULL;
968 status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr, &size, MEM_RESERVE,
970 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
971}
972
974{
977};
978
980{
981 volatile int buffer[0x2000];
982 int i;
983
984 for (i = 0; i < ARRAY_SIZE(buffer); i++) buffer[i] = 0xdeadbeef;
985 (void)buffer[0];
986}
987
989{
990 volatile int buffer[0x400];
991 int i;
992
993 for (i = 0; i < ARRAY_SIZE(buffer); i++) buffer[i] = 0xdeadbeef;
994 (void)buffer[0];
995}
996
998{
1002 SIZE_T size, guard_size;
1003 DWORD committed, reserved;
1004 void *addr;
1005
1006 committed = (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->Tib.StackLimit;
1007 reserved = (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->DeallocationStack;
1008 todo_wine ok( committed == args->expect_committed || broken(committed == 0x1000), "unexpected stack committed size %lx, expected %lx\n", committed, args->expect_committed );
1009 ok( reserved == args->expect_reserved, "unexpected stack reserved size %lx, expected %lx\n", reserved, args->expect_reserved );
1010
1011 addr = (char *)NtCurrentTeb()->DeallocationStack;
1013 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1014 ok( mbi.AllocationBase == NtCurrentTeb()->DeallocationStack, "unexpected AllocationBase %p, expected %p\n", mbi.AllocationBase, NtCurrentTeb()->DeallocationStack );
1015 ok( mbi.AllocationProtect == PAGE_READWRITE, "unexpected AllocationProtect %#lx, expected %#x\n", mbi.AllocationProtect, PAGE_READWRITE );
1016 ok( mbi.BaseAddress == addr, "unexpected BaseAddress %p, expected %p\n", mbi.BaseAddress, addr );
1017 todo_wine ok( mbi.State == MEM_RESERVE, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_RESERVE );
1018 todo_wine ok( mbi.Protect == 0, "unexpected Protect %#lx, expected %#x\n", mbi.Protect, 0 );
1019 ok( mbi.Type == MEM_PRIVATE, "unexpected Type %#lx, expected %#x\n", mbi.Type, MEM_PRIVATE );
1020
1021
1023
1024 committed = (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->Tib.StackLimit;
1025 reserved = (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->DeallocationStack;
1026 todo_wine ok( committed == 0x9000, "unexpected stack committed size %lx, expected 9000\n", committed );
1027 ok( reserved == args->expect_reserved, "unexpected stack reserved size %lx, expected %lx\n", reserved, args->expect_reserved );
1028
1029
1030 /* reserved area shrinks whenever stack grows */
1031
1032 addr = (char *)NtCurrentTeb()->DeallocationStack;
1034 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1035 ok( mbi.AllocationBase == NtCurrentTeb()->DeallocationStack, "unexpected AllocationBase %p, expected %p\n", mbi.AllocationBase, NtCurrentTeb()->DeallocationStack );
1036 ok( mbi.AllocationProtect == PAGE_READWRITE, "unexpected AllocationProtect %#lx, expected %#x\n", mbi.AllocationProtect, PAGE_READWRITE );
1037 ok( mbi.BaseAddress == addr, "unexpected BaseAddress %p, expected %p\n", mbi.BaseAddress, addr );
1038 todo_wine ok( mbi.State == MEM_RESERVE, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_RESERVE );
1039 todo_wine ok( mbi.Protect == 0, "unexpected Protect %#lx, expected %#x\n", mbi.Protect, 0 );
1040 ok( mbi.Type == MEM_PRIVATE, "unexpected Type %#lx, expected %#x\n", mbi.Type, MEM_PRIVATE );
1041
1042 guard_size = reserved - committed - mbi.RegionSize;
1043 ok( guard_size == 0x1000 || guard_size == 0x2000 || guard_size == 0x3000, "unexpected guard_size %I64x, expected 1000, 2000 or 3000\n", (UINT64)guard_size );
1044
1045 /* the commit area is initially preceded by guard pages */
1046
1047 addr = (char *)NtCurrentTeb()->DeallocationStack + mbi.RegionSize;
1049 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1050 ok( mbi.AllocationBase == NtCurrentTeb()->DeallocationStack, "unexpected AllocationBase %p, expected %p\n", mbi.AllocationBase, NtCurrentTeb()->DeallocationStack );
1051 ok( mbi.AllocationProtect == PAGE_READWRITE, "unexpected AllocationProtect %#lx, expected %#x\n", mbi.AllocationProtect, PAGE_READWRITE );
1052 ok( mbi.BaseAddress == addr, "unexpected BaseAddress %p, expected %p\n", mbi.BaseAddress, addr );
1053 ok( mbi.RegionSize == guard_size, "unexpected RegionSize %I64x, expected 3000\n", (UINT64)mbi.RegionSize );
1054 ok( mbi.State == MEM_COMMIT, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_COMMIT );
1055 ok( mbi.Protect == (PAGE_READWRITE|PAGE_GUARD), "unexpected Protect %#lx, expected %#x\n", mbi.Protect, PAGE_READWRITE|PAGE_GUARD );
1056 ok( mbi.Type == MEM_PRIVATE, "unexpected Type %#lx, expected %#x\n", mbi.Type, MEM_PRIVATE );
1057
1058 addr = (char *)NtCurrentTeb()->Tib.StackLimit;
1060 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1061 ok( mbi.AllocationBase == NtCurrentTeb()->DeallocationStack, "unexpected AllocationBase %p, expected %p\n", mbi.AllocationBase, NtCurrentTeb()->DeallocationStack );
1062 ok( mbi.AllocationProtect == PAGE_READWRITE, "unexpected AllocationProtect %#lx, expected %#x\n", mbi.AllocationProtect, PAGE_READWRITE );
1063 ok( mbi.BaseAddress == addr, "unexpected BaseAddress %p, expected %p\n", mbi.BaseAddress, addr );
1064 ok( mbi.RegionSize == committed, "unexpected RegionSize %I64x, expected %I64x\n", (UINT64)mbi.RegionSize, (UINT64)committed );
1065 ok( mbi.State == MEM_COMMIT, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_COMMIT );
1066 ok( mbi.Protect == PAGE_READWRITE, "unexpected Protect %#lx, expected %#x\n", mbi.Protect, PAGE_READWRITE );
1067 ok( mbi.Type == MEM_PRIVATE, "unexpected Type %#lx, expected %#x\n", mbi.Type, MEM_PRIVATE );
1068
1069 return 0;
1070}
1071
1073{
1076 SIZE_T size, guard_size;
1077 DWORD committed;
1078 void *addr;
1079 DWORD prot;
1080 void *tmp;
1081
1083 if (!is_win64) return 0;
1084
1085 addr = (char *)NtCurrentTeb()->DeallocationStack;
1087 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1088
1089 guard_size = (char *)NtCurrentTeb()->Tib.StackLimit - (char *)NtCurrentTeb()->DeallocationStack - mbi.RegionSize;
1090 ok( guard_size == 0x1000 || guard_size == 0x2000 || guard_size == 0x3000, "unexpected guard_size %I64x, expected 1000, 2000 or 3000\n", (UINT64)guard_size );
1091
1092 /* setting a guard page shrinks stack automatically */
1093
1094 addr = (char *)NtCurrentTeb()->Tib.StackLimit + 0x2000;
1095 size = 0x1000;
1097 ok( !status, "NtAllocateVirtualMemory returned %08lx\n", status );
1098
1099 committed = (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->Tib.StackLimit;
1100 todo_wine ok( committed == 0x6000, "unexpected stack committed size %lx, expected 6000\n", committed );
1101
1102 status = NtQueryVirtualMemory( NtCurrentProcess(), (char *)addr - 0x2000, MemoryBasicInformation, &mbi, sizeof(mbi), &size );
1103 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1104 ok( mbi.RegionSize == 0x2000, "unexpected RegionSize %I64x, expected 2000\n", (UINT64)mbi.RegionSize );
1105 ok( mbi.State == MEM_COMMIT, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_COMMIT );
1106 ok( mbi.Protect == PAGE_READWRITE, "unexpected Protect %#lx, expected %#x\n", mbi.Protect, PAGE_READWRITE );
1107
1109 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1110 ok( mbi.RegionSize == 0x1000, "unexpected RegionSize %I64x, expected 1000\n", (UINT64)mbi.RegionSize );
1111 ok( mbi.State == MEM_COMMIT, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_COMMIT );
1112 ok( mbi.Protect == (PAGE_READWRITE|PAGE_GUARD), "unexpected Protect %#lx, expected %#x\n", mbi.Protect, (PAGE_READWRITE|PAGE_GUARD) );
1113
1114 addr = (char *)NtCurrentTeb()->Tib.StackLimit;
1116 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1117 todo_wine ok( mbi.RegionSize == 0x6000, "unexpected RegionSize %I64x, expected 6000\n", (UINT64)mbi.RegionSize );
1118 ok( mbi.State == MEM_COMMIT, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_COMMIT );
1119 ok( mbi.Protect == PAGE_READWRITE, "unexpected Protect %#lx, expected %#x\n", mbi.Protect, PAGE_READWRITE );
1120
1121
1122 /* guard pages are restored as the stack grows back */
1123
1124 addr = (char *)NtCurrentTeb()->Tib.StackLimit + 0x4000;
1125 tmp = (char *)addr - guard_size - 0x1000;
1126 size = 0x1000;
1128 ok( !status, "NtAllocateVirtualMemory returned %08lx\n", status );
1129
1130 committed = (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->Tib.StackLimit;
1131 todo_wine ok( committed == 0x1000, "unexpected stack committed size %lx, expected 1000\n", committed );
1132
1134 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1135 todo_wine ok( mbi.RegionSize == guard_size + 0x1000, "unexpected RegionSize %I64x, expected %I64x\n", (UINT64)mbi.RegionSize, (UINT64)(guard_size + 0x1000) );
1136 ok( mbi.State == MEM_COMMIT, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_COMMIT );
1137 todo_wine ok( mbi.Protect == PAGE_READWRITE, "unexpected Protect %#lx, expected %#x\n", mbi.Protect, PAGE_READWRITE );
1138
1140
1141 committed = (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->Tib.StackLimit;
1142 todo_wine ok( committed == 0x2000, "unexpected stack committed size %lx, expected 2000\n", committed );
1143
1145 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1146 ok( mbi.RegionSize == 0x1000, "unexpected RegionSize %I64x, expected 1000\n", (UINT64)mbi.RegionSize );
1147 ok( mbi.State == MEM_COMMIT, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_COMMIT );
1148 todo_wine ok( mbi.Protect == PAGE_READWRITE, "unexpected Protect %#lx, expected %#x\n", mbi.Protect, PAGE_READWRITE );
1149
1150 status = NtQueryVirtualMemory( NtCurrentProcess(), (char *)tmp + 0x1000, MemoryBasicInformation, &mbi, sizeof(mbi), &size );
1151 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1152 ok( mbi.RegionSize == guard_size, "unexpected RegionSize %I64x, expected %I64x\n", (UINT64)mbi.RegionSize, (UINT64)guard_size );
1153 ok( mbi.State == MEM_COMMIT, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_COMMIT );
1154 todo_wine ok( mbi.Protect == (PAGE_READWRITE|PAGE_GUARD), "unexpected Protect %#lx, expected %#x\n", mbi.Protect, (PAGE_READWRITE|PAGE_GUARD) );
1155
1156
1157 /* forcing stack limit over guard pages still shrinks the stack on page fault */
1158
1159 addr = (char *)tmp + guard_size + 0x1000;
1160 size = 0x1000;
1162 ok( !status, "NtAllocateVirtualMemory returned %08lx\n", status );
1163
1164 NtCurrentTeb()->Tib.StackLimit = (char *)tmp;
1165
1166 status = NtQueryVirtualMemory( NtCurrentProcess(), (char *)tmp + 0x1000, MemoryBasicInformation, &mbi, sizeof(mbi), &size );
1167 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1168 todo_wine ok( mbi.RegionSize == guard_size + 0x1000, "unexpected RegionSize %I64x, expected %I64x\n", (UINT64)mbi.RegionSize, (UINT64)(guard_size + 0x1000) );
1169 ok( mbi.State == MEM_COMMIT, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_COMMIT );
1170 todo_wine ok( mbi.Protect == (PAGE_READWRITE|PAGE_GUARD), "unexpected Protect %#lx, expected %#x\n", mbi.Protect, (PAGE_READWRITE|PAGE_GUARD) );
1171
1173
1174 committed = (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->Tib.StackLimit;
1175 todo_wine ok( committed == 0x2000, "unexpected stack committed size %lx, expected 2000\n", committed );
1176
1177
1178 /* it works with NtProtectVirtualMemory as well */
1179
1181
1182 addr = (char *)NtCurrentTeb()->Tib.StackLimit + 0x2000;
1183 size = 0x1000;
1185 ok( !status, "NtProtectVirtualMemory returned %08lx\n", status );
1186 todo_wine ok( prot == PAGE_READWRITE, "unexpected prot %#lx, expected %#x\n", prot, PAGE_READWRITE );
1187
1188 committed = (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->Tib.StackLimit;
1189 todo_wine ok( committed == 0x6000, "unexpected stack committed size %lx, expected 6000\n", committed );
1190
1191 status = NtQueryVirtualMemory( NtCurrentProcess(), (char *)addr - 0x2000, MemoryBasicInformation, &mbi, sizeof(mbi), &size );
1192 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1193 todo_wine ok( mbi.RegionSize == 0x2000, "unexpected RegionSize %I64x, expected 2000\n", (UINT64)mbi.RegionSize );
1194 ok( mbi.State == MEM_COMMIT, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_COMMIT );
1195 todo_wine ok( mbi.Protect == PAGE_READWRITE, "unexpected Protect %#lx, expected %#x\n", mbi.Protect, PAGE_READWRITE );
1196
1198 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1199 ok( mbi.RegionSize == 0x1000, "unexpected RegionSize %I64x, expected 1000\n", (UINT64)mbi.RegionSize );
1200 ok( mbi.State == MEM_COMMIT, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_COMMIT );
1201 ok( mbi.Protect == (PAGE_READWRITE|PAGE_GUARD), "unexpected Protect %#lx, expected %#x\n", mbi.Protect, (PAGE_READWRITE|PAGE_GUARD) );
1202
1203 addr = (char *)NtCurrentTeb()->Tib.StackLimit;
1205 ok( !status, "NtQueryVirtualMemory returned %08lx\n", status );
1206 todo_wine ok( mbi.RegionSize == 0x6000, "unexpected RegionSize %I64x, expected 6000\n", (UINT64)mbi.RegionSize );
1207 ok( mbi.State == MEM_COMMIT, "unexpected State %#lx, expected %#x\n", mbi.State, MEM_COMMIT );
1208 todo_wine ok( mbi.Protect == PAGE_READWRITE, "unexpected Protect %#lx, expected %#x\n", mbi.Protect, PAGE_READWRITE );
1209
1210
1211 /* clearing the guard pages doesn't change StackLimit back */
1212
1214
1215 addr = (char *)NtCurrentTeb()->Tib.StackLimit + 0x2000;
1216 size = 0x1000;
1218 ok( !status, "NtProtectVirtualMemory returned %08lx\n", status );
1219 todo_wine ok( prot == PAGE_READWRITE, "unexpected prot %#lx, expected %#x\n", prot, PAGE_READWRITE );
1220
1221 committed = (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->Tib.StackLimit;
1222 todo_wine ok( committed == 0x6000, "unexpected stack committed size %lx, expected 6000\n", committed );
1223
1225 ok( !status, "NtProtectVirtualMemory returned %08lx\n", status );
1226 ok( prot == (PAGE_READWRITE | PAGE_GUARD), "unexpected prot %#lx, expected %#x\n", prot, (PAGE_READWRITE | PAGE_GUARD) );
1227
1228 committed = (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->Tib.StackLimit;
1229 todo_wine ok( committed == 0x6000, "unexpected stack committed size %lx, expected 6000\n", committed );
1230
1231 /* and as we messed with it and it now doesn't fault, it doesn't grow back either */
1232
1234
1235 committed = (char *)NtCurrentTeb()->Tib.StackBase - (char *)NtCurrentTeb()->Tib.StackLimit;
1236 todo_wine ok( committed == 0x6000, "unexpected stack committed size %lx, expected 6000\n", committed );
1237
1238 ExitThread(0);
1239}
1240
1242{
1243 return 0;
1244}
1245
1247{
1250 SIZE_T default_commit = nt->OptionalHeader.SizeOfStackCommit;
1251 SIZE_T default_reserve = nt->OptionalHeader.SizeOfStackReserve;
1252 INITIAL_TEB stack = {0};
1253 unsigned int i;
1254 NTSTATUS ret;
1255 HANDLE thread;
1256 CLIENT_ID id;
1257
1258 struct
1259 {
1260 SIZE_T commit, reserve, commit_align, reserve_align, expect_commit, expect_reserve;
1261 }
1262 tests[] =
1263 {
1264 { 0, 0, 1, 1, default_commit, default_reserve},
1265 { 0x2000, 0, 1, 1, 0x2000, default_reserve},
1266 { 0x4000, 0, 1, 1, 0x4000, default_reserve},
1267 { 0, 0x200000, 1, 1, default_commit, 0x200000},
1268 { 0x4000, 0x200000, 1, 1, 0x4000, 0x200000},
1269 {0x100000, 0x100000, 1, 1, 0x100000, 0x100000},
1270 { 0x20000, 0x20000, 1, 1, 0x20000, 0x100000},
1271
1272 { 0, 0x110000, 1, 1, default_commit, 0x110000},
1273 { 0, 0x110000, 1, 0x40000, default_commit, 0x140000},
1274 { 0, 0x140000, 1, 0x40000, default_commit, 0x140000},
1275 { 0x11000, 0x140000, 1, 0x40000, 0x11000, 0x140000},
1276 { 0x11000, 0x140000, 0x4000, 0x40000, 0x14000, 0x140000},
1277 { 0, 0, 0x4000, 0x400000,
1278 (default_commit + 0x3fff) & ~0x3fff,
1279 (default_reserve + 0x3fffff) & ~0x3fffff},
1280 };
1281
1282 if (!pRtlCreateUserStack)
1283 {
1284 win_skip("RtlCreateUserStack() is missing\n");
1285 return;
1286 }
1287
1288 for (i = 0; i < ARRAY_SIZE(tests); ++i)
1289 {
1290 memset(&stack, 0xcc, sizeof(stack));
1291 ret = pRtlCreateUserStack(tests[i].commit, tests[i].reserve, 0,
1292 tests[i].commit_align, tests[i].reserve_align, &stack);
1293 ok(!ret, "%u: got status %#lx\n", i, ret);
1294 ok(!stack.OldStackBase, "%u: got OldStackBase %p\n", i, stack.OldStackBase);
1295 ok(!stack.OldStackLimit, "%u: got OldStackLimit %p\n", i, stack.OldStackLimit);
1296 ok(!((ULONG_PTR)stack.DeallocationStack & (page_size - 1)),
1297 "%u: got unaligned memory %p\n", i, stack.DeallocationStack);
1298 ok((ULONG_PTR)stack.StackBase - (ULONG_PTR)stack.DeallocationStack == tests[i].expect_reserve,
1299 "%u: got reserve %#Ix\n", i, (ULONG_PTR)stack.StackBase - (ULONG_PTR)stack.DeallocationStack);
1300 todo_wine ok((ULONG_PTR)stack.StackBase - (ULONG_PTR)stack.StackLimit == tests[i].expect_commit,
1301 "%u: got commit %#Ix\n", i, (ULONG_PTR)stack.StackBase - (ULONG_PTR)stack.StackLimit);
1302 pRtlFreeUserStack(stack.DeallocationStack);
1303 }
1304
1305 ret = pRtlCreateUserStack(0x11000, 0x110000, 0, 1, 0, &stack);
1306 ok(ret == STATUS_INVALID_PARAMETER, "got %#lx\n", ret);
1307
1308 ret = pRtlCreateUserStack(0x11000, 0x110000, 0, 0, 1, &stack);
1309 ok(ret == STATUS_INVALID_PARAMETER, "got %#lx\n", ret);
1310
1311 args.expect_committed = 0x4000;
1312 args.expect_reserved = default_reserve;
1316
1317 args.expect_committed = default_commit < 0x2000 ? 0x2000 : default_commit;
1318 args.expect_reserved = 0x400000;
1322
1323 if (is_win64)
1324 {
1326 ok(thread != NULL, "CreateThread with huge stack failed\n");
1329 }
1330
1331 args.expect_committed = default_commit < 0x2000 ? 0x2000 : default_commit;
1332 args.expect_reserved = 0x100000;
1333 for (i = 0; i < 32; i++)
1334 {
1335 ULONG mask = ~0u >> i;
1336 NTSTATUS expect_ret = STATUS_SUCCESS;
1337
1338 if (i == 12) expect_ret = STATUS_CONFLICTING_ADDRESSES;
1339 else if (i >= 13) expect_ret = STATUS_INVALID_PARAMETER;
1340 ret = pRtlCreateUserStack( args.expect_committed, args.expect_reserved, i, 0x1000, 0x1000, &stack );
1341 ok( ret == expect_ret || ret == STATUS_NO_MEMORY ||
1343 broken( i == 1 && ret == STATUS_INVALID_PARAMETER_3 ), /* win7 */
1344 "%u: got %lx / %lx\n", i, ret, expect_ret );
1345 if (!ret) pRtlFreeUserStack( stack.DeallocationStack );
1346 ret = pRtlCreateUserThread( GetCurrentProcess(), NULL, FALSE, i,
1347 args.expect_reserved, args.expect_committed,
1348 (void *)test_stack_size_thread, &args, &thread, &id );
1349 ok( ret == expect_ret || ret == STATUS_NO_MEMORY ||
1351 broken( i == 1 && ret == STATUS_INVALID_PARAMETER_3 ), /* win7 */
1352 "%u: got %lx / %lx\n", i, ret, expect_ret );
1353 if (!ret)
1354 {
1357 }
1358
1359 if (mask <= 31) continue;
1360 if (!is_win64 && !is_wow64) expect_ret = STATUS_INVALID_PARAMETER_3;
1361 ret = pRtlCreateUserStack( args.expect_committed, args.expect_reserved, mask, 0x1000, 0x1000, &stack );
1362 ok( ret == expect_ret || ret == STATUS_NO_MEMORY ||
1364 "%08lx: got %lx / %lx\n", mask, ret, expect_ret );
1365 if (!ret) pRtlFreeUserStack( stack.DeallocationStack );
1366 ret = pRtlCreateUserThread( GetCurrentProcess(), NULL, FALSE, mask,
1367 args.expect_reserved, args.expect_committed,
1368 (void *)test_stack_size_thread, &args, &thread, &id );
1369 ok( ret == expect_ret || ret == STATUS_NO_MEMORY ||
1371 "%08lx: got %lx / %lx\n", mask, ret, expect_ret );
1372 if (!ret)
1373 {
1376 }
1377 }
1378}
1379
1381{
1382 static const char testfile[] = "testfile.xxx";
1383 static const char data[] = "test data for NtMapViewOfSection";
1384 char buffer[sizeof(data)];
1386 void *ptr, *ptr2;
1387 BOOL ret;
1388 DWORD status, written;
1391 ULONG_PTR zero_bits;
1392
1393 if (!pIsWow64Process || !pIsWow64Process(NtCurrentProcess(), &is_wow64)) is_wow64 = FALSE;
1394
1396 ok(file != INVALID_HANDLE_VALUE, "Failed to create test file\n");
1397 WriteFile(file, data, sizeof(data), &written, NULL);
1400
1401 /* read/write mapping */
1402
1404 ok(mapping != 0, "CreateFileMapping failed\n");
1405
1406 process = create_target_process("sleep");
1407 ok(process != NULL, "Can't start process\n");
1408
1409 ptr = NULL;
1410 size = 0;
1411 offset.QuadPart = 0;
1413 ok(status == STATUS_INVALID_HANDLE, "NtMapViewOfSection returned %08lx\n", status);
1414
1415 ptr = NULL;
1416 size = 0;
1417 offset.QuadPart = 0;
1419 ok(status == STATUS_SUCCESS, "NtMapViewOfSection returned %08lx\n", status);
1420 ok(!((ULONG_PTR)ptr & 0xffff), "returned memory %p is not aligned to 64k\n", ptr);
1421
1423 ok(ret, "ReadProcessMemory failed\n");
1424 ok(result == sizeof(buffer), "ReadProcessMemory didn't read all data (%Ix)\n", result);
1425 ok(!memcmp(buffer, data, sizeof(buffer)), "Wrong data read\n");
1426
1427 /* 1 zero bits should zero 63-31 upper bits */
1428 ptr2 = NULL;
1429 size = 0;
1430 zero_bits = 1;
1431 offset.QuadPart = 0;
1434 "NtMapViewOfSection returned %08lx\n", status);
1435 if (status == STATUS_SUCCESS)
1436 {
1437 ok(((UINT_PTR)ptr2 >> (32 - zero_bits)) == 0,
1438 "NtMapViewOfSection returned address: %p\n", ptr2);
1439
1441 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1442 }
1443
1444 for (zero_bits = 2; zero_bits <= 20; zero_bits++)
1445 {
1446 ptr2 = NULL;
1447 size = 0;
1448 offset.QuadPart = 0;
1451 "NtMapViewOfSection with %d zero_bits returned %08lx\n", (int)zero_bits, status);
1452 if (status == STATUS_SUCCESS)
1453 {
1454 ok(((UINT_PTR)ptr2 >> (32 - zero_bits)) == 0,
1455 "NtMapViewOfSection with %d zero_bits returned address %p\n", (int)zero_bits, ptr2);
1456
1458 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1459 }
1460 }
1461
1462 /* 21 zero bits never succeeds */
1463 ptr2 = NULL;
1464 size = 0;
1465 offset.QuadPart = 0;
1466 status = NtMapViewOfSection(mapping, process, &ptr2, 21, 0, &offset, &size, 1, 0, PAGE_READWRITE);
1468 "NtMapViewOfSection returned %08lx\n", status);
1469
1470 /* 22 zero bits is invalid */
1471 ptr2 = NULL;
1472 size = 0;
1473 offset.QuadPart = 0;
1474 status = NtMapViewOfSection(mapping, process, &ptr2, 22, 0, &offset, &size, 1, 0, PAGE_READWRITE);
1476 "NtMapViewOfSection returned %08lx\n", status);
1477
1478 /* zero bits > 31 should be considered as a leading zeroes bitmask on 64bit and WoW64 */
1479 ptr2 = NULL;
1480 size = 0;
1481 zero_bits = 0x1aaaaaaa;
1482 offset.QuadPart = 0;
1484
1485 if (!is_win64 && !is_wow64)
1486 {
1487 ok(status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %08lx\n", status);
1488 }
1489 else
1490 {
1492 "NtMapViewOfSection returned %08lx\n", status);
1493 if (status == STATUS_SUCCESS)
1494 {
1495 ok(((UINT_PTR)ptr2 & ~get_zero_bits_mask(zero_bits)) == 0 &&
1496 ((UINT_PTR)ptr2 & ~zero_bits) != 0, /* only the leading zeroes matter */
1497 "NtMapViewOfSection returned address %p\n", ptr2);
1498
1500 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1501 }
1502 }
1503
1504 /* mapping at the same page conflicts */
1505 ptr2 = ptr;
1506 size = 0;
1507 offset.QuadPart = 0;
1509 ok(status == STATUS_CONFLICTING_ADDRESSES, "NtMapViewOfSection returned %08lx\n", status);
1510
1511 /* offset has to be aligned */
1512 ptr2 = ptr;
1513 size = 0;
1514 offset.QuadPart = 1;
1516 ok(status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %08lx\n", status);
1517
1518 /* ptr has to be aligned */
1519 ptr2 = (char *)ptr + 42;
1520 size = 0;
1521 offset.QuadPart = 0;
1523 ok(status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %08lx\n", status);
1524
1525 /* still not 64k aligned */
1526 ptr2 = (char *)ptr + 0x1000;
1527 size = 0;
1528 offset.QuadPart = 0;
1530 ok(status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %08lx\n", status);
1531
1532 /* when an address is passed, it has to satisfy the provided number of zero bits */
1533 ptr2 = (char *)ptr + 0x1000;
1534 size = 0;
1535 offset.QuadPart = 0;
1536 zero_bits = get_zero_bits(((UINT_PTR)ptr2) >> 1);
1537 status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE);
1539 "NtMapViewOfSection returned %08lx\n", status);
1540
1541 ptr2 = (char *)ptr + 0x1000;
1542 size = 0;
1543 offset.QuadPart = 0;
1544 zero_bits = get_zero_bits((UINT_PTR)ptr2);
1545 status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE);
1546 ok(status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %08lx\n", status);
1547
1548 if (!is_win64 && !is_wow64)
1549 {
1550 /* new memory region conflicts with previous mapping */
1551 ptr2 = ptr;
1552 size = 0;
1553 offset.QuadPart = 0;
1556 ok(status == STATUS_CONFLICTING_ADDRESSES, "NtMapViewOfSection returned %08lx\n", status);
1557
1558 ptr2 = (char *)ptr + 42;
1559 size = 0;
1560 offset.QuadPart = 0;
1563 ok(status == STATUS_CONFLICTING_ADDRESSES, "NtMapViewOfSection returned %08lx\n", status);
1564
1565 /* in contrary to regular NtMapViewOfSection, only 4kb align is enforced */
1566 ptr2 = (char *)ptr + 0x1000;
1567 size = 0;
1568 offset.QuadPart = 0;
1571 ok(status == STATUS_SUCCESS, "NtMapViewOfSection returned %08lx\n", status);
1572 ok((char *)ptr2 == (char *)ptr + 0x1000,
1573 "expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2);
1575 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1576
1577 /* the address is rounded down if not on a page boundary */
1578 ptr2 = (char *)ptr + 0x1001;
1579 size = 0;
1580 offset.QuadPart = 0;
1583 ok(status == STATUS_SUCCESS, "NtMapViewOfSection returned %08lx\n", status);
1584 ok((char *)ptr2 == (char *)ptr + 0x1000,
1585 "expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2);
1587 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1588
1589 ptr2 = (char *)ptr + 0x2000;
1590 size = 0;
1591 offset.QuadPart = 0;
1594 ok(status == STATUS_SUCCESS, "NtMapViewOfSection returned %08lx\n", status);
1595 ok((char *)ptr2 == (char *)ptr + 0x2000,
1596 "expected address %p, got %p\n", (char *)ptr + 0x2000, ptr2);
1598 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1599 }
1600 else
1601 {
1602 ptr2 = (char *)ptr + 0x1000;
1603 size = 0;
1604 offset.QuadPart = 0;
1607 todo_wine
1609 "NtMapViewOfSection returned %08lx\n", status);
1610 }
1611
1613 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1614
1616
1618 DeleteFileA(testfile);
1619
1620 /* test zero_bits > 31 with a 64-bit DLL file image mapping */
1621 if (is_win64)
1622 {
1623 file = CreateFileA("c:\\windows\\system32\\version.dll", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
1624 ok(file != INVALID_HANDLE_VALUE, "Failed to open version.dll\n");
1625
1627 ok(mapping != 0, "CreateFileMapping failed\n");
1628
1629 ptr = NULL;
1630 size = 0;
1631 offset.QuadPart = 0;
1632 zero_bits = 0x7fffffff;
1633 status = NtMapViewOfSection(mapping, process, &ptr, zero_bits, 0, &offset, &size, 1, 0, PAGE_READONLY);
1634
1635 ok(status == STATUS_SUCCESS || status == STATUS_IMAGE_NOT_AT_BASE, "NtMapViewOfSection returned %08lx\n", status);
1636 ok(!((ULONG_PTR)ptr & 0xffff), "returned memory %p is not aligned to 64k\n", ptr);
1637#ifdef __REACTOS__
1638 if (GetNTVersion() < _WIN32_WINNT_WIN7 && !is_reactos())
1639 win_skip("Skipping test on pre-Win7, because it's broken\n");
1640 else
1641#endif
1642 ok(((UINT_PTR)ptr & ~get_zero_bits_mask(zero_bits)) == 0, "NtMapViewOfSection returned address %p\n", ptr);
1643
1645 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1646
1649 }
1650
1653}
1654
1656{
1657 static const char testfile[] = "testfile.xxx";
1658 static const char data[] = "test data for NtMapViewOfSectionEx";
1659 char buffer[sizeof(data)];
1664 DWORD status, written;
1667 void *ptr, *ptr2;
1668 BOOL ret;
1669
1670 if (!pNtMapViewOfSectionEx)
1671 {
1672 win_skip("NtMapViewOfSectionEx() is not supported.\n");
1673 return;
1674 }
1675
1676 if (!pIsWow64Process || !pIsWow64Process(NtCurrentProcess(), &is_wow64)) is_wow64 = FALSE;
1677 GetSystemInfo(&si);
1678
1680 ok(file != INVALID_HANDLE_VALUE, "Failed to create test file\n");
1681 WriteFile(file, data, sizeof(data), &written, NULL);
1682 SetFilePointer(file, 0x40000, NULL, FILE_BEGIN);
1684
1685 /* read/write mapping */
1686
1688 ok(mapping != 0, "CreateFileMapping failed\n");
1689
1690 process = create_target_process("sleep");
1691 ok(process != NULL, "Can't start process\n");
1692
1693 ptr = NULL;
1694 size = 0x1000;
1695 offset.QuadPart = 0;
1696 status = pNtMapViewOfSectionEx(mapping, NULL, &ptr, &offset, &size, 0, PAGE_READWRITE, NULL, 0);
1697 ok(status == STATUS_INVALID_HANDLE, "Unexpected status %08lx\n", status);
1698
1699 ptr = NULL;
1700 size = 0x1000;
1701 offset.QuadPart = 0;
1702 status = pNtMapViewOfSectionEx(mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, NULL, 0);
1703 ok(status == STATUS_SUCCESS, "Unexpected status %08lx\n", status);
1704 ok(!((ULONG_PTR)ptr & 0xffff), "returned memory %p is not aligned to 64k\n", ptr);
1705
1707 ok(ret, "ReadProcessMemory failed\n");
1708 ok(result == sizeof(buffer), "ReadProcessMemory didn't read all data (%Ix)\n", result);
1709 ok(!memcmp(buffer, data, sizeof(buffer)), "Wrong data read\n");
1710
1711 /* mapping at the same page conflicts */
1712 ptr2 = ptr;
1713 size = 0;
1714 offset.QuadPart = 0;
1715 status = pNtMapViewOfSectionEx(mapping, process, &ptr2, &offset, &size, 0, PAGE_READWRITE, NULL, 0);
1716 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx\n", status);
1717
1718 /* offset has to be aligned */
1719 ptr2 = ptr;
1720 size = 0;
1721 offset.QuadPart = 1;
1722 status = pNtMapViewOfSectionEx(mapping, process, &ptr2, &offset, &size, 0, PAGE_READWRITE, NULL, 0);
1723 ok(status == STATUS_MAPPED_ALIGNMENT, "Unexpected status %08lx\n", status);
1724
1725 /* ptr has to be aligned */
1726 ptr2 = (char *)ptr + 42;
1727 size = 0;
1728 offset.QuadPart = 0;
1729 status = pNtMapViewOfSectionEx(mapping, process, &ptr2, &offset, &size, 0, PAGE_READWRITE, NULL, 0);
1730 ok(status == STATUS_MAPPED_ALIGNMENT, "Unexpected status %08lx\n", status);
1731
1732 /* still not 64k aligned */
1733 ptr2 = (char *)ptr + 0x1000;
1734 size = 0;
1735 offset.QuadPart = 0;
1736 status = pNtMapViewOfSectionEx(mapping, process, &ptr2, &offset, &size, 0, PAGE_READWRITE, NULL, 0);
1737 ok(status == STATUS_MAPPED_ALIGNMENT, "Unexpected status %08lx\n", status);
1738
1739 if (!is_win64 && !is_wow64)
1740 {
1741 /* new memory region conflicts with previous mapping */
1742 ptr2 = ptr;
1743 size = 0x1000;
1744 offset.QuadPart = 0;
1745 status = pNtMapViewOfSectionEx(mapping, process, &ptr2, &offset, &size, AT_ROUND_TO_PAGE, PAGE_READWRITE, NULL, 0);
1746 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx\n", status);
1747
1748 ptr2 = (char *)ptr + 42;
1749 size = 0x1000;
1750 offset.QuadPart = 0;
1751 status = pNtMapViewOfSectionEx(mapping, process, &ptr2, &offset, &size, AT_ROUND_TO_PAGE, PAGE_READWRITE, NULL, 0);
1752 ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx\n", status);
1753
1754 /* in contrary to regular NtMapViewOfSection, only 4kb align is enforced */
1755 ptr2 = (char *)ptr + 0x1000;
1756 size = 0x1000;
1757 offset.QuadPart = 0;
1758 status = pNtMapViewOfSectionEx(mapping, process, &ptr2, &offset, &size, AT_ROUND_TO_PAGE, PAGE_READWRITE, NULL, 0);
1759 ok(status == STATUS_SUCCESS, "Unexpected status %08lx\n", status);
1760 ok((char *)ptr2 == (char *)ptr + 0x1000,
1761 "expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2);
1763 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1764
1765 /* the address is rounded down if not on a page boundary */
1766 ptr2 = (char *)ptr + 0x1001;
1767 size = 0x1000;
1768 offset.QuadPart = 0;
1769 status = pNtMapViewOfSectionEx(mapping, process, &ptr2, &offset, &size, AT_ROUND_TO_PAGE, PAGE_READWRITE, NULL, 0);
1770 ok(status == STATUS_SUCCESS, "Unexpected status %08lx\n", status);
1771 ok((char *)ptr2 == (char *)ptr + 0x1000,
1772 "expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2);
1774 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1775
1776 ptr2 = (char *)ptr + 0x2000;
1777 size = 0x1000;
1778 offset.QuadPart = 0;
1779 status = pNtMapViewOfSectionEx(mapping, process, &ptr2, &offset, &size, AT_ROUND_TO_PAGE, PAGE_READWRITE, NULL, 0);
1780 ok(status == STATUS_SUCCESS, "Unexpected status %08lx\n", status);
1781 ok((char *)ptr2 == (char *)ptr + 0x2000,
1782 "expected address %p, got %p\n", (char *)ptr + 0x2000, ptr2);
1784 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1785 }
1786 else
1787 {
1788 ptr2 = (char *)ptr + 0x1000;
1789 size = 0;
1790 offset.QuadPart = 0;
1791 status = pNtMapViewOfSectionEx(mapping, process, &ptr2, &offset, &size, AT_ROUND_TO_PAGE, PAGE_READWRITE, NULL, 0);
1792 todo_wine
1794 "NtMapViewOfSection returned %08lx\n", status);
1795 }
1796
1798 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1799
1800 /* extended parameters */
1801
1802 memset(&ext, 0, sizeof(ext));
1803 ext[0].Type = 0;
1804 size = 0x1000;
1805 ptr = NULL;
1806 offset.QuadPart = 0;
1807 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, ext, 1 );
1808 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
1809
1810 memset(&ext, 0, sizeof(ext));
1811 ext[0].Type = MemExtendedParameterMax;
1812 size = 0x1000;
1813 ptr = NULL;
1814 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, ext, 1 );
1815 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
1816
1817 memset(&a, 0, sizeof(a));
1819 ext[0].Pointer = &a;
1820 size = 0x1000;
1821 ptr = NULL;
1822 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, ext, 1 );
1823 ok(!status, "Unexpected status %08lx.\n", status);
1825 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1826
1827 ext[1] = ext[0];
1828 size = 0x1000;
1829 ptr = NULL;
1830 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, ext, 2 );
1831 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
1832
1833 a.LowestStartingAddress = NULL;
1834 a.Alignment = 0;
1835 a.HighestEndingAddress = (void *)(0x20001000 + 1);
1836 size = 0x10000;
1837 ptr = NULL;
1838 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, ext, 1 );
1839 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
1840
1841 a.HighestEndingAddress = (void *)(0x20001000 - 2);
1842 size = 0x10000;
1843 ptr = NULL;
1844 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, ext, 1 );
1845 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
1846
1847 a.HighestEndingAddress = (void *)(0x20000800 - 1);
1848 size = 0x10000;
1849 ptr = NULL;
1850 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, ext, 1 );
1851 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
1852
1853 a.HighestEndingAddress = (char *)si.lpMaximumApplicationAddress + 0x1000;
1854 size = 0x10000;
1855 ptr = NULL;
1856 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, ext, 1 );
1857 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
1858
1859 a.HighestEndingAddress = (char *)si.lpMaximumApplicationAddress;
1860 size = 0x10000;
1861 ptr = NULL;
1862 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, ext, 1 );
1863 ok(!status, "Unexpected status %08lx.\n", status);
1865 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1866
1867 a.HighestEndingAddress = (void *)(0x20001000 - 1);
1868 size = 0x40000;
1869 ptr = NULL;
1870 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, ext, 1 );
1871 ok(!status, "Unexpected status %08lx.\n", status);
1872 ok(!((ULONG_PTR)ptr & 0xffff), "Unexpected addr %p.\n", ptr);
1873 ok((ULONG_PTR)ptr + size <= 0x20001000, "Unexpected addr %p.\n", ptr);
1875 ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08lx\n", status);
1876
1877 size = 0x40000;
1878 a.HighestEndingAddress = (void *)(0x20001000 - 1);
1879 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, ext, 1 );
1880 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
1881
1882 a.HighestEndingAddress = NULL;
1883 a.Alignment = 0x30000;
1884 size = 0x1000;
1885 ptr = NULL;
1886 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, ext, 1 );
1887 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
1888
1889 for (a.Alignment = 1; a.Alignment; a.Alignment *= 2)
1890 {
1891 size = 0x1000;
1892 ptr = NULL;
1893 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, ext, 1 );
1894 ok(status == STATUS_INVALID_PARAMETER, "Align %Ix unexpected status %08lx.\n", a.Alignment, status);
1895 }
1896
1898
1900 DeleteFileA(testfile);
1901
1902 file = CreateFileA( "c:\\windows\\system32\\version.dll", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0 );
1903 ok( file != INVALID_HANDLE_VALUE, "Failed to open version.dll\n" );
1905 ok( mapping != 0, "CreateFileMapping failed\n" );
1906
1907 memset(&ext, 0, sizeof(ext));
1909 ext[0].ULong = 0;
1910 ptr = NULL;
1911 size = 0;
1912 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READONLY, ext, 1 );
1914 {
1915 ok(status == STATUS_SUCCESS || status == STATUS_IMAGE_NOT_AT_BASE, "NtMapViewOfSection returned %08lx\n", status);
1917
1919 ext[1].ULong = 0;
1920 ptr = NULL;
1921 size = 0;
1922 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READONLY, ext, 2 );
1923 ok(status == STATUS_INVALID_PARAMETER, "NtMapViewOfSection returned %08lx\n", status);
1924
1925 ext[0].ULong = IMAGE_FILE_MACHINE_R3000;
1926 ext[1].ULong = IMAGE_FILE_MACHINE_R4000;
1927 ptr = NULL;
1928 size = 0;
1929 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READONLY, ext, 2 );
1930 ok(status == STATUS_INVALID_PARAMETER, "NtMapViewOfSection returned %08lx\n", status);
1931
1932 ptr = NULL;
1933 size = 0;
1934 status = pNtMapViewOfSectionEx( mapping, process, &ptr, &offset, &size, 0, PAGE_READONLY, ext, 1 );
1935 ok(status == STATUS_NOT_SUPPORTED, "NtMapViewOfSection returned %08lx\n", status);
1936 }
1937 else win_skip( "MemExtendedParameterImageMachine not supported\n" );
1938
1941
1944}
1945
1946#define SUPPORTED_XSTATE_FEATURES ((1 << XSTATE_LEGACY_FLOATING_POINT) | (1 << XSTATE_LEGACY_SSE) | (1 << XSTATE_AVX))
1947
1948static void test_user_shared_data(void)
1949{
1950 struct old_xstate_configuration
1951 {
1952 ULONG64 EnabledFeatures;
1953 ULONG Size;
1954 ULONG OptimizedSave:1;
1955 ULONG CompactionEnabled:1;
1957 };
1958
1959 static const ULONG feature_offsets[] =
1960 {
1961 0,
1962 160, /*offsetof(XMM_SAVE_AREA32, XmmRegisters)*/
1963 512 /* sizeof(XMM_SAVE_AREA32) */ + offsetof(XSTATE, YmmContext),
1964 };
1965 static const ULONG feature_sizes[] =
1966 {
1967 160,
1968 256, /*sizeof(M128A) * 16 */
1969 sizeof(YMMCONTEXT),
1970 };
1971 const KSHARED_USER_DATA *user_shared_data = (void *)0x7ffe0000;
1972 XSTATE_CONFIGURATION xstate = user_shared_data->XState;
1974 unsigned int i;
1975
1976 ok(user_shared_data->NumberOfPhysicalPages == sbi.MmNumberOfPhysicalPages,
1977 "Got number of physical pages %#lx, expected %#lx.\n",
1978 user_shared_data->NumberOfPhysicalPages, sbi.MmNumberOfPhysicalPages);
1979
1980#if defined(__i386__) || defined(__x86_64__)
1981 ok(user_shared_data->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] /* Supported since Pentium CPUs. */,
1982 "_RDTSC not available.\n");
1983#endif
1984 ok(user_shared_data->ActiveProcessorCount == NtCurrentTeb()->Peb->NumberOfProcessors
1985 || broken(!user_shared_data->ActiveProcessorCount) /* before Win7 */,
1986 "Got unexpected ActiveProcessorCount %lu.\n", user_shared_data->ActiveProcessorCount);
1987 ok(user_shared_data->ActiveGroupCount == 1
1988 || broken(!user_shared_data->ActiveGroupCount) /* before Win7 */,
1989 "Got unexpected ActiveGroupCount %u.\n", user_shared_data->ActiveGroupCount);
1990
1991 if (!pRtlGetEnabledExtendedFeatures)
1992 {
1993 win_skip("RtlGetEnabledExtendedFeatures is not available.\n");
1994 return;
1995 }
1996
1997 feature_mask = pRtlGetEnabledExtendedFeatures(~(ULONG64)0);
1998 if (!feature_mask)
1999 {
2000 skip("XState features are not available.\n");
2001 return;
2002 }
2003
2004 if (!xstate.EnabledFeatures)
2005 {
2006 struct old_xstate_configuration *xs_old
2007 = (struct old_xstate_configuration *)((char *)user_shared_data + 0x3e0);
2008
2009 ok(feature_mask == xs_old->EnabledFeatures, "Got unexpected xs_old->EnabledFeatures %s.\n",
2010 wine_dbgstr_longlong(xs_old->EnabledFeatures));
2011 win_skip("Old structure layout.\n");
2012 return;
2013 }
2014
2015 trace("XState EnabledFeatures %#I64x, EnabledSupervisorFeatures %#I64x, EnabledVolatileFeatures %I64x.\n",
2017 feature_mask = pRtlGetEnabledExtendedFeatures(0);
2018 ok(!feature_mask, "Got unexpected feature_mask %s.\n", wine_dbgstr_longlong(feature_mask));
2019 feature_mask = pRtlGetEnabledExtendedFeatures(~(ULONG64)0);
2020 ok(feature_mask == (xstate.EnabledFeatures | xstate.EnabledSupervisorFeatures), "Got unexpected feature_mask %s.\n",
2022 feature_mask = pGetEnabledXStateFeatures();
2023 ok(feature_mask == (xstate.EnabledFeatures | xstate.EnabledSupervisorFeatures), "Got unexpected feature_mask %s.\n",
2026 "Got unexpected EnabledFeatures %s.\n", wine_dbgstr_longlong(xstate.EnabledFeatures));
2028 "Got unexpected EnabledVolatileFeatures %s.\n", wine_dbgstr_longlong(xstate.EnabledVolatileFeatures));
2029 ok(xstate.Size >= 512 + sizeof(XSTATE), "Got unexpected Size %lu.\n", xstate.Size);
2030 if (xstate.CompactionEnabled)
2031 ok(xstate.OptimizedSave, "Got zero OptimizedSave with compaction enabled.\n");
2032 ok(!xstate.AlignedFeatures, "Got unexpected AlignedFeatures %s.\n",
2034 ok(xstate.AllFeatureSize >= 512 + sizeof(XSTATE)
2035 || !xstate.AllFeatureSize /* win8 on CPUs without XSAVEC */,
2036 "Got unexpected AllFeatureSize %lu.\n", xstate.AllFeatureSize);
2037
2038 for (i = 0; i < ARRAY_SIZE(feature_sizes); ++i)
2039 {
2040 ok(xstate.AllFeatures[i] == feature_sizes[i]
2041 || !xstate.AllFeatures[i] /* win8+ on CPUs without XSAVEC */,
2042 "Got unexpected AllFeatures[%u] %lu, expected %lu.\n", i,
2043 xstate.AllFeatures[i], feature_sizes[i]);
2044 ok(xstate.Features[i].Size == feature_sizes[i], "Got unexpected Features[%u].Size %lu, expected %lu.\n", i,
2045 xstate.Features[i].Size, feature_sizes[i]);
2046 ok(xstate.Features[i].Offset == feature_offsets[i], "Got unexpected Features[%u].Offset %lu, expected %lu.\n",
2047 i, xstate.Features[i].Offset, feature_offsets[i]);
2048 }
2049}
2050
2051static void perform_relocations( void *module, INT_PTR delta )
2052{
2055 const IMAGE_DATA_DIRECTORY *relocs;
2056 const IMAGE_SECTION_HEADER *sec;
2057 ULONG protect_old[96], i;
2058
2061 if (!relocs->VirtualAddress || !relocs->Size) return;
2062 sec = IMAGE_FIRST_SECTION( nt );
2063 for (i = 0; i < nt->FileHeader.NumberOfSections; i++)
2064 {
2065 void *addr = (char *)module + sec[i].VirtualAddress;
2066 SIZE_T size = sec[i].SizeOfRawData;
2068 &size, PAGE_READWRITE, &protect_old[i] );
2069 }
2070 rel = (IMAGE_BASE_RELOCATION *)((char *)module + relocs->VirtualAddress);
2071 end = (IMAGE_BASE_RELOCATION *)((char *)rel + relocs->Size);
2072 while (rel && rel < end - 1 && rel->SizeOfBlock)
2073 rel = LdrProcessRelocationBlock( (char *)module + rel->VirtualAddress,
2074 (rel->SizeOfBlock - sizeof(*rel)) / sizeof(USHORT),
2075 (USHORT *)(rel + 1), delta );
2076 for (i = 0; i < nt->FileHeader.NumberOfSections; i++)
2077 {
2078 void *addr = (char *)module + sec[i].VirtualAddress;
2079 SIZE_T size = sec[i].SizeOfRawData;
2081 &size, protect_old[i], &protect_old[i] );
2082 }
2083}
2084
2085
2086static void test_syscalls(void)
2087{
2088 HMODULE module = GetModuleHandleW( L"ntdll.dll" );
2089 HANDLE handle;
2091 NTSTATUS (WINAPI *pNtClose)(HANDLE);
2094 INT_PTR delta;
2095 void *ptr;
2096
2097 /* initial image */
2098 pNtClose = (void *)GetProcAddress( module, "NtClose" );
2100 ok( handle != 0, "CreateEventWfailed %lu\n", GetLastError() );
2101 status = pNtClose( handle );
2102 ok( !status, "NtClose failed %lx\n", status );
2103 status = pNtClose( handle );
2104 ok( status == STATUS_INVALID_HANDLE, "NtClose failed %lx\n", status );
2105
2106 /* syscall thunk copy */
2108 ok( ptr != NULL, "VirtualAlloc failed\n" );
2109 memcpy( ptr, pNtClose, 32 );
2110 pNtClose = ptr;
2112 ok( handle != 0, "CreateEventWfailed %lu\n", GetLastError() );
2113 status = pNtClose( handle );
2114 ok( !status, "NtClose failed %lx\n", status );
2115 status = pNtClose( handle );
2116 ok( status == STATUS_INVALID_HANDLE, "NtClose failed %lx\n", status );
2117 VirtualFree( ptr, 0, MEM_FREE );
2118
2119 /* new mapping */
2122 ok( file != INVALID_HANDLE_VALUE, "can't open %s: %lu\n", wine_dbgstr_w(path), GetLastError() );
2124 ok( mapping != NULL, "CreateFileMappingW failed err %lu\n", GetLastError() );
2125 ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
2126 ok( ptr != NULL, "MapViewOfFile failed err %lu\n", GetLastError() );
2128 delta = (char *)ptr - (char *)module;
2129
2130 if (memcmp( ptr, module, 0x1000 ))
2131 {
2132 skip( "modules are not identical (non-PE build?)\n" );
2134 CloseHandle( file );
2135 return;
2136 }
2137 perform_relocations( ptr, delta );
2138 pNtClose = (void *)GetProcAddress( module, "NtClose" );
2139
2141 {
2142 void *func = pRtlFindExportedRoutineByName( module, "NtClose" );
2143 ok( func == (void *)pNtClose, "wrong ptr %p / %p\n", func, pNtClose );
2144 func = pRtlFindExportedRoutineByName( ptr, "NtClose" );
2145 ok( (char *)func - (char *)pNtClose == delta, "wrong ptr %p / %p\n", func, pNtClose );
2146 }
2147 else win_skip( "RtlFindExportedRoutineByName not supported\n" );
2148
2149 if (!memcmp( pNtClose, (char *)pNtClose + delta, 32 ))
2150 {
2151 pNtClose = (void *)((char *)pNtClose + delta);
2153 ok( handle != 0, "CreateEventWfailed %lu\n", GetLastError() );
2154 status = pNtClose( handle );
2155 ok( !status, "NtClose failed %lx\n", status );
2156 status = pNtClose( handle );
2157 ok( status == STATUS_INVALID_HANDLE, "NtClose failed %lx\n", status );
2158 }
2159 else
2160 {
2161#ifdef __i386__
2162 NTSTATUS (WINAPI *pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, void *, ULONG, ULONG *);
2164 void *exec_mem, *va_ptr;
2165 ULONG size;
2166 BOOL ret;
2167
2169 ok( !!exec_mem, "got NULL.\n" );
2170
2171 /* NtQueryInformationProcess is special. */
2172 pNtQueryInformationProcess = (void *)GetProcAddress( module, "NtQueryInformationProcess" );
2174 (char *)pNtQueryInformationProcess - (char *)module, NULL );
2175 ok( !!va_ptr, "offset not found %p / %p\n", pNtQueryInformationProcess, module );
2176 ret = SetFilePointer( file, (char *)va_ptr - (char *)module, NULL, FILE_BEGIN );
2177 ok( ret, "got %d, err %lu.\n", ret, GetLastError() );
2178 ret = ReadFile( file, exec_mem, 32, NULL, NULL );
2179 ok( ret, "got %d, err %lu.\n", ret, GetLastError() );
2180 if (!memcmp( exec_mem, pNtQueryInformationProcess, 5 ))
2181 {
2182 pNtQueryInformationProcess = exec_mem;
2183 /* The thunk still works without relocation. */
2184 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), &size );
2185 ok( !status, "got %#lx.\n", status );
2186 ok( size == sizeof(pbi), "got %lu.\n", size );
2187 ok( pbi.PebBaseAddress == NtCurrentTeb()->Peb, "got %p, %p.\n", pbi.PebBaseAddress, NtCurrentTeb()->Peb );
2188 }
2189 else
2190 ok( 0, "file on disk doesn't match syscall %x / %x\n",
2191 *(UINT *)pNtQueryInformationProcess, *(UINT *)exec_mem );
2192
2193 VirtualFree( exec_mem, 0, MEM_RELEASE );
2194#elif defined __x86_64__
2195 ok( 0, "syscall thunk relocated\n" );
2196#else
2197 skip( "syscall thunk relocated\n" );
2198#endif
2199 }
2200 CloseHandle( file );
2202}
2203
2205{
2206 void *addr1, *addr;
2208 SIZE_T size;
2209
2210 size = 0x10000;
2211 addr1 = NULL;
2213 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2214
2215 size = 0;
2217 ok(status == STATUS_INVALID_HANDLE, "Unexpected status %08lx.\n", status);
2218
2219 addr = (char *)addr1 + 0x1000;
2220 size = 0;
2222 ok(status == STATUS_FREE_VM_NOT_AT_BASE, "Unexpected status %08lx.\n", status);
2223
2224 size = 0x11000;
2226 ok(status == STATUS_UNABLE_TO_FREE_VM, "Unexpected status %08lx.\n", status);
2227
2228 addr = (char *)addr1 + 0x1001;
2229 size = 0xffff;
2231 ok(status == STATUS_UNABLE_TO_FREE_VM, "Unexpected status %08lx.\n", status);
2232 ok(size == 0xffff, "Unexpected size %p.\n", (void *)size);
2233 ok(addr == (char *)addr1 + 0x1001, "Got addr %p, addr1 %p.\n", addr, addr1);
2234
2235 size = 0xfff;
2236 addr = (char *)addr1 + 0x1001;
2238 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2239 *(volatile char *)addr1 = 1;
2240 *((volatile char *)addr1 + 0x2000) = 1;
2241 ok(size == 0x1000, "Unexpected size %p.\n", (void *)size);
2242 ok(addr == (char *)addr1 + 0x1000, "Got addr %p, addr1 %p.\n", addr, addr1);
2243
2244 size = 0xfff;
2245 addr = (char *)addr1 + 1;
2247 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2248 *((volatile char *)addr1 + 0x2000) = 1;
2249 ok(size == 0x1000, "Unexpected size %p.\n", (void *)size);
2250 ok(addr == addr1, "Got addr %p, addr1 %p.\n", addr, addr1);
2251
2252 size = 0x1000;
2253 addr = addr1;
2255 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2256 ok(addr == addr1, "Unexpected addr %p, addr1 %p.\n", addr, addr1);
2257 ok(size == 0x1000, "Unexpected size %p.\n", (void *)size);
2258
2259 size = 0x10000;
2261 ok(status == STATUS_UNABLE_TO_FREE_VM, "Unexpected status %08lx.\n", status);
2262
2263 size = 0x10000;
2265 ok(status == STATUS_UNABLE_TO_FREE_VM, "Unexpected status %08lx.\n", status);
2266
2267 size = 0;
2268 addr = (char *)addr1 + 0x1000;
2270 ok(status == STATUS_MEMORY_NOT_ALLOCATED, "Unexpected status %08lx.\n", status);
2271
2272 size = 0x1000;
2273 addr = (char *)addr1 + 0x1000;
2275 ok(status == STATUS_MEMORY_NOT_ALLOCATED, "Unexpected status %08lx.\n", status);
2276
2277 size = 0;
2278 addr = (char *)addr1 + 0x2000;
2280 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2281
2282 size = 0x1000;
2284 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2285}
2286
2287static void test_prefetch(void)
2288{
2290 MEMORY_RANGE_ENTRY entries[2] = {{ 0 }};
2291 ULONG reservedarg = 0;
2292 char stackmem[] = "Test stack mem";
2293 static char testmem[] = "Test memory range data";
2294
2295 if (!pNtSetInformationVirtualMemory)
2296 {
2297 skip("no NtSetInformationVirtualMemory in ntdll\n");
2298 return;
2299 }
2300
2301 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), -1, 1, entries, NULL, 32);
2303 "NtSetInformationVirtualMemory unexpected status on invalid info class (1): %08lx\n", status);
2304
2305 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), -1, 0, NULL, NULL, 0);
2307 "NtSetInformationVirtualMemory unexpected status on invalid info class (2): %08lx\n", status);
2308
2309 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), -1, 1, NULL, NULL, 32);
2311 "NtSetInformationVirtualMemory unexpected status on invalid info class (3): %08lx\n", status);
2312
2313 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2314 1, entries, NULL, 0 );
2316 broken( is_wow64 && status == STATUS_INVALID_PARAMETER_6 ) /* win10 1507 */,
2317 "NtSetInformationVirtualMemory unexpected status on NULL info data (1): %08lx\n", status);
2318
2319 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2320 1, NULL, NULL, 0 );
2322 "NtSetInformationVirtualMemory unexpected status on NULL info data (2): %08lx\n", status);
2323
2324 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2325 0, NULL, NULL, 0 );
2327 "NtSetInformationVirtualMemory unexpected status on NULL info data (3): %08lx\n", status);
2328
2329 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2330 1, entries, &reservedarg, sizeof(reservedarg) * 2 );
2332 "NtSetInformationVirtualMemory unexpected status on extended info data (1): %08lx\n", status);
2333
2334 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2335 0, NULL, &reservedarg, sizeof(reservedarg) * 2 );
2337 "NtSetInformationVirtualMemory unexpected status on extended info data (2): %08lx\n", status);
2338
2339 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2340 1, entries, &reservedarg, sizeof(reservedarg) / 2 );
2342 "NtSetInformationVirtualMemory unexpected status on shrunk info data (1): %08lx\n", status);
2343
2344 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2345 0, NULL, &reservedarg, sizeof(reservedarg) / 2 );
2347 "NtSetInformationVirtualMemory unexpected status on shrunk info data (2): %08lx\n", status);
2348
2349 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2350 0, NULL, &reservedarg, sizeof(reservedarg) );
2352 "NtSetInformationVirtualMemory unexpected status on 0 entries: %08lx\n", status);
2353
2354 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2355 1, NULL, &reservedarg, sizeof(reservedarg) );
2357 "NtSetInformationVirtualMemory unexpected status on NULL entries: %08lx\n", status);
2358
2359 entries[0].VirtualAddress = NULL;
2360 entries[0].NumberOfBytes = 0;
2361 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2362 1, entries, &reservedarg, sizeof(reservedarg) );
2364 broken( is_wow64 && status == STATUS_INVALID_PARAMETER_6 ) /* win10 1507 */,
2365 "NtSetInformationVirtualMemory unexpected status on 1 empty entry: %08lx\n", status);
2366
2367 entries[0].VirtualAddress = NULL;
2368 entries[0].NumberOfBytes = page_size;
2369 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2370 1, entries, &reservedarg, sizeof(reservedarg) );
2371 ok( status == STATUS_SUCCESS ||
2372 broken( is_wow64 && status == STATUS_INVALID_PARAMETER_6 ) /* win10 1507 */,
2373 "NtSetInformationVirtualMemory unexpected status on 1 NULL address entry: %08lx\n", status);
2374
2375 entries[0].VirtualAddress = (void *)((ULONG_PTR)testmem & -(ULONG_PTR)page_size);
2376 entries[0].NumberOfBytes = page_size;
2377 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2378 1, entries, &reservedarg, sizeof(reservedarg) );
2379 ok( status == STATUS_SUCCESS ||
2380 broken( is_wow64 && status == STATUS_INVALID_PARAMETER_6 ) /* win10 1507 */,
2381 "NtSetInformationVirtualMemory unexpected status on 1 page-aligned entry: %08lx\n", status);
2382
2383 entries[0].VirtualAddress = testmem;
2384 entries[0].NumberOfBytes = sizeof(testmem);
2385 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2386 1, entries, &reservedarg, sizeof(reservedarg) );
2387 ok( status == STATUS_SUCCESS ||
2388 broken( is_wow64 && status == STATUS_INVALID_PARAMETER_6 ) /* win10 1507 */,
2389 "NtSetInformationVirtualMemory unexpected status on 1 entry: %08lx\n", status);
2390
2391 entries[0].VirtualAddress = NULL;
2392 entries[0].NumberOfBytes = page_size;
2393 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2394 1, entries, &reservedarg, sizeof(reservedarg) );
2395 ok( status == STATUS_SUCCESS ||
2396 broken( is_wow64 && status == STATUS_INVALID_PARAMETER_6 ) /* win10 1507 */,
2397 "NtSetInformationVirtualMemory unexpected status on 1 unmapped entry: %08lx\n", status);
2398
2399 entries[0].VirtualAddress = (void *)((ULONG_PTR)testmem & -(ULONG_PTR)page_size);
2400 entries[0].NumberOfBytes = page_size;
2401 entries[1].VirtualAddress = (void *)((ULONG_PTR)stackmem & -(ULONG_PTR)page_size);
2402 entries[1].NumberOfBytes = page_size;
2403 status = pNtSetInformationVirtualMemory( NtCurrentProcess(), VmPrefetchInformation,
2404 2, entries, &reservedarg, sizeof(reservedarg) );
2405 ok( status == STATUS_SUCCESS ||
2406 broken( is_wow64 && status == STATUS_INVALID_PARAMETER_6 ) /* win10 1507 */,
2407 "NtSetInformationVirtualMemory unexpected status on 2 page-aligned entries: %08lx\n", status);
2408}
2409
2411{
2414 SIZE_T len, size;
2417 void *ptr;
2418
2419 size = 0x10000;
2420 ptr = NULL;
2422 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2423
2424#ifdef _WIN64
2427 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2430 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2433 ok(status == STATUS_INFO_LENGTH_MISMATCH, "Unexpected status %08lx.\n", status);
2434#endif
2435
2436 len = 0;
2437 memset(&info, 0x11, sizeof(info));
2439 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2440 ok(info.AllocationBase == ptr, "Unexpected base %p.\n", info.AllocationBase);
2441 ok(info.AllocationProtect == PAGE_READWRITE, "Unexpected protection %lu.\n", info.AllocationProtect);
2442 ok(!info.Private, "Unexpected flag %d.\n", info.Private);
2443 ok(!info.MappedDataFile, "Unexpected flag %d.\n", info.MappedDataFile);
2444 ok(!info.MappedImage, "Unexpected flag %d.\n", info.MappedImage);
2445 ok(!info.MappedPageFile, "Unexpected flag %d.\n", info.MappedPageFile);
2446 ok(!info.MappedPhysical, "Unexpected flag %d.\n", info.MappedPhysical);
2447 ok(!info.DirectMapped, "Unexpected flag %d.\n", info.DirectMapped);
2448 ok(info.RegionSize == size, "Unexpected region size.\n");
2449
2450 size = 0;
2452 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2453
2454 /* Committed size */
2455 size = 0x10000;
2456 ptr = NULL;
2458 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2459
2460 memset(&info, 0x11, sizeof(info));
2462 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2463 ok(info.AllocationBase == ptr, "Unexpected base %p.\n", info.AllocationBase);
2464 ok(info.AllocationProtect == PAGE_READWRITE, "Unexpected protection %lu.\n", info.AllocationProtect);
2465 ok(!info.Private, "Unexpected flag %d.\n", info.Private);
2466 ok(!info.MappedDataFile, "Unexpected flag %d.\n", info.MappedDataFile);
2467 ok(!info.MappedImage, "Unexpected flag %d.\n", info.MappedImage);
2468 ok(!info.MappedPageFile, "Unexpected flag %d.\n", info.MappedPageFile);
2469 ok(!info.MappedPhysical, "Unexpected flag %d.\n", info.MappedPhysical);
2470 ok(!info.DirectMapped, "Unexpected flag %d.\n", info.DirectMapped);
2471 ok(info.RegionSize == size, "Unexpected region size.\n");
2472
2473 size = 0;
2475 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2476
2477 /* Pagefile mapping */
2479 ok(mapping != 0, "CreateFileMapping failed\n");
2480
2481 ptr = NULL;
2482 size = 0;
2483 offset.QuadPart = 0;
2485 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2486
2487 memset(&info, 0x11, sizeof(info));
2489 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2490 ok(info.AllocationBase == ptr, "Unexpected base %p.\n", info.AllocationBase);
2491 ok(info.AllocationProtect == PAGE_READONLY, "Unexpected protection %lu.\n", info.AllocationProtect);
2492 ok(!info.Private, "Unexpected flag %d.\n", info.Private);
2493 ok(!info.MappedDataFile, "Unexpected flag %d.\n", info.MappedDataFile);
2494 ok(!info.MappedImage, "Unexpected flag %d.\n", info.MappedImage);
2495 ok(!info.MappedPageFile, "Unexpected flag %d.\n", info.MappedPageFile);
2496 ok(!info.MappedPhysical, "Unexpected flag %d.\n", info.MappedPhysical);
2497 ok(!info.DirectMapped, "Unexpected flag %d.\n", info.DirectMapped);
2498 ok(info.RegionSize == 4096, "Unexpected region size.\n");
2499
2501 ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
2502
2504}
2505
2507{
2511 SIZE_T len, size;
2514 void *ptr;
2515
2516 /* virtual allocation */
2517
2518 size = 0x8000;
2519 ptr = NULL;
2521 ok( status == STATUS_SUCCESS, "Unexpected status %08lx\n", status );
2522
2523 len = 0xdead;
2524 memset( &info, 0xcc, sizeof(info) );
2526 &info, sizeof(info), &len );
2528 {
2529 win_skip( "MemoryImageInformation not supported\n" );
2531 return;
2532 }
2533 ok( status == STATUS_SUCCESS, "Unexpected status %08lx\n", status );
2534 ok( len == sizeof(info), "wrong len %Ix\n", len );
2535 ok( !info.ImageBase, "wrong image base %p/%p\n", info.ImageBase, ptr );
2536 ok( !info.SizeOfImage, "wrong size %Ix/%Ix\n", info.SizeOfImage, size );
2537 ok( !info.ImageFlags, "wrong flags %lx\n", info.ImageFlags );
2538
2539 len = 0xdead;
2541 &info, sizeof(info) + 2, &len );
2542 ok( status == STATUS_SUCCESS, "Unexpected status %08lx\n", status );
2543 ok( len == sizeof(info), "wrong len %Ix\n", len );
2544
2545 len = 0xdead;
2547 &info, sizeof(info) - 1, &len );
2548 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Unexpected status %08lx\n", status );
2549 ok( len == 0xdead, "wrong len %Ix\n", len );
2550
2551 len = 0xdead;
2553 &info, sizeof(info), &len );
2554 ok( status == STATUS_INVALID_ADDRESS, "Unexpected status %08lx\n", status );
2555 ok( len == 0xdead || broken(len == sizeof(info)), "wrong len %Ix\n", len );
2556
2557 memset( &info, 0xcc, sizeof(info) );
2559 &info, sizeof(info), &len );
2560 ok( status == STATUS_SUCCESS, "Unexpected status %08lx\n", status );
2561 ok( !info.ImageBase, "wrong image base %p/%p\n", info.ImageBase, ptr );
2562 ok( !info.SizeOfImage, "wrong size %Ix/%Ix\n", info.SizeOfImage, size );
2563 ok( !info.ImageFlags, "wrong flags %lx\n", info.ImageFlags );
2564
2565 size = 0;
2567
2568 /* mapped dll */
2569
2570 ptr = GetModuleHandleA( "ntdll.dll" );
2571 nt = RtlImageNtHeader( ptr );
2572 memset( &info, 0xcc, sizeof(info) );
2574 &info, sizeof(info), &len );
2575 ok( status == STATUS_SUCCESS, "Unexpected status %08lx\n", status );
2576 ok( info.ImageBase == ptr, "wrong image base %p/%p\n", info.ImageBase, ptr );
2577 ok( info.SizeOfImage == nt->OptionalHeader.SizeOfImage, "wrong size %Ix/%x\n",
2578 info.SizeOfImage, (UINT)nt->OptionalHeader.SizeOfImage );
2579 ok( !info.ImagePartialMap, "wrong partial map\n" );
2580 ok( !info.ImageNotExecutable, "wrong not executable\n" );
2581 ok( info.ImageSigningLevel == 0 || info.ImageSigningLevel == 12,
2582 "wrong signing level %u\n", info.ImageSigningLevel );
2583
2584 /* image mapping */
2585
2586 file = CreateFileA( "c:\\windows\\system32\\kernel32.dll", GENERIC_READ, FILE_SHARE_READ, NULL,
2587 OPEN_EXISTING, 0, 0 );
2589 ok( mapping != 0, "CreateFileMapping failed\n" );
2590
2591 ptr = NULL;
2592 size = 0;
2593 offset.QuadPart = 0;
2595 ok( status == STATUS_IMAGE_NOT_AT_BASE, "Unexpected status %08lx\n", status );
2596 NtClose( mapping );
2597
2598 memset( &info, 0xcc, sizeof(info) );
2600 &info, sizeof(info), &len );
2601 ok( status == STATUS_SUCCESS, "Unexpected status %08lx\n", status );
2602 ok( info.ImageBase == ptr, "wrong image base %p/%p\n", info.ImageBase, ptr );
2603 ok( info.SizeOfImage == size, "wrong size %Ix/%Ix\n", info.SizeOfImage, size );
2604 ok( !info.ImagePartialMap, "wrong partial map\n" );
2605 ok( !info.ImageNotExecutable, "wrong not executable\n" );
2606 ok( info.ImageSigningLevel == 0 || info.ImageSigningLevel == 12,
2607 "wrong signing level %u\n", info.ImageSigningLevel );
2608
2610
2611 /* partial image mapping */
2612
2613 file = CreateFileA( "c:\\windows\\system32\\kernel32.dll", GENERIC_READ, FILE_SHARE_READ, NULL,
2614 OPEN_EXISTING, 0, 0 );
2616 ok( mapping != 0, "CreateFileMapping failed\n" );
2617
2618 ptr = NULL;
2619 size = 0;
2620 offset.QuadPart = 0;
2622 ok( status == STATUS_IMAGE_NOT_AT_BASE, "Unexpected status %08lx\n", status );
2623 todo_wine
2624 ok( size == 0x4000, "wrong size %Ix\n", size );
2625 NtClose( mapping );
2626
2627 nt = RtlImageNtHeader( ptr );
2628 memset( &info, 0xcc, sizeof(info) );
2630 &info, sizeof(info), &len );
2631 ok( status == STATUS_SUCCESS, "Unexpected status %08lx\n", status );
2632 ok( info.ImageBase == ptr, "wrong image base %p/%p\n", info.ImageBase, ptr );
2633 ok( info.SizeOfImage == nt->OptionalHeader.SizeOfImage, "wrong size %Ix/%x\n",
2634 info.SizeOfImage, (UINT)nt->OptionalHeader.SizeOfImage );
2635 todo_wine
2636 ok( info.ImagePartialMap, "wrong partial map\n" );
2637 ok( !info.ImageNotExecutable, "wrong not executable\n" );
2638 ok( info.ImageSigningLevel == 0 || info.ImageSigningLevel == 12,
2639 "wrong signing level %u\n", info.ImageSigningLevel );
2640
2642
2643 file = CreateFileA( "c:\\windows\\system32\\kernel32.dll", GENERIC_READ, FILE_SHARE_READ, NULL,
2644 OPEN_EXISTING, 0, 0 );
2646 ok( mapping != 0, "CreateFileMapping failed\n" );
2647
2648 ptr = NULL;
2649 size = 0x5000;
2650 offset.QuadPart = 0;
2652 ok( status == STATUS_IMAGE_NOT_AT_BASE, "Unexpected status %08lx\n", status );
2653 todo_wine
2654 ok( size == 0x5000, "wrong size %Ix\n", size );
2655 NtClose( mapping );
2656
2657 nt = RtlImageNtHeader( ptr );
2658 memset( &info, 0xcc, sizeof(info) );
2660 &info, sizeof(info), &len );
2661 ok( status == STATUS_SUCCESS, "Unexpected status %08lx\n", status );
2662 ok( info.ImageBase == ptr, "wrong image base %p/%p\n", info.ImageBase, ptr );
2663 ok( info.SizeOfImage == nt->OptionalHeader.SizeOfImage, "wrong size %Ix/%x\n",
2664 info.SizeOfImage, (UINT)nt->OptionalHeader.SizeOfImage );
2665 todo_wine
2666 ok( info.ImagePartialMap, "wrong partial map\n" );
2667 ok( !info.ImageNotExecutable, "wrong not executable\n" );
2668 ok( info.ImageSigningLevel == 0 || info.ImageSigningLevel == 12,
2669 "wrong signing level %u\n", info.ImageSigningLevel );
2670
2672
2673 /* non-image mapping */
2674
2676 ok( mapping != 0, "CreateFileMapping failed\n" );
2677
2678 ptr = NULL;
2679 size = 0;
2680 offset.QuadPart = 0;
2682 ok( status == STATUS_SUCCESS, "Unexpected status %08lx\n", status );
2683 NtClose( mapping );
2684
2685 memset( &info, 0xcc, sizeof(info) );
2687 &info, sizeof(info), &len );
2688 ok( status == STATUS_SUCCESS, "Unexpected status %08lx\n", status );
2689 ok( !info.ImageBase, "wrong image base %p/%p\n", info.ImageBase, ptr );
2690 ok( !info.SizeOfImage, "wrong size %Ix/%Ix\n", info.SizeOfImage, size );
2691 ok( !info.ImageFlags, "wrong flags %lx\n", info.ImageFlags );
2692
2694
2695 /* pagefile mapping */
2696
2698 ok( mapping != 0, "CreateFileMapping failed\n" );
2699
2700 ptr = NULL;
2701 size = 0;
2702 offset.QuadPart = 0;
2704 ok( status == STATUS_SUCCESS, "Unexpected status %08lx\n", status );
2705 NtClose( mapping );
2706
2707 memset( &info, 0xcc, sizeof(info) );
2709 &info, sizeof(info), &len );
2710 ok( status == STATUS_SUCCESS, "Unexpected status %08lx\n", status );
2711 ok( !info.ImageBase, "wrong image base %p/%p\n", info.ImageBase, ptr );
2712 ok( !info.SizeOfImage, "wrong size %Ix/%Ix\n", info.SizeOfImage, size );
2713 ok( !info.ImageFlags, "wrong flags %lx\n", info.ImageFlags );
2714
2716 NtClose( file );
2717}
2718
2719static int *write_addr;
2720static int got_exception;
2721
2723{
2724 MANAGE_WRITES_TO_EXECUTABLE_MEMORY mem = { .Version = 2, .ThreadAllowWrites = 1 };
2725 EXCEPTION_RECORD *rec = ptrs->ExceptionRecord;
2727
2728 got_exception++;
2729 ok( rec->ExceptionCode == STATUS_IN_PAGE_ERROR, "wrong exception %lx\n", rec->ExceptionCode );
2730 ok( rec->NumberParameters == 3, "wrong params %lx\n", rec->NumberParameters );
2731 ok( rec->ExceptionInformation[0] == 1, "not write access %Ix\n", rec->ExceptionInformation[0] );
2732 ok( (int *)rec->ExceptionInformation[1] == write_addr,
2733 "wrong address %p / %p\n", (void *)rec->ExceptionInformation[1], write_addr );
2734 ok( rec->ExceptionInformation[2] == STATUS_EXECUTABLE_MEMORY_WRITE, "wrong status %Ix\n",
2735 rec->ExceptionInformation[2] );
2736
2738 &mem, sizeof(mem) );
2739 ok( !status, "NtSetInformationThread failed %lx\n", status );
2740 *write_addr = 0; /* make the page dirty to prevent further exceptions */
2741 mem.ThreadAllowWrites = 0;
2743 &mem, sizeof(mem) );
2744 ok( !status, "NtSetInformationThread failed %lx\n", status );
2746}
2747
2749{
2751 void *ptr, *handler;
2752 MANAGE_WRITES_TO_EXECUTABLE_MEMORY mem = { .Version = 2 };
2754 ULONG flag, len, granularity;
2756 void *addresses[4];
2757 DWORD old_prot;
2759 HANDLE file;
2761
2763 &mem, sizeof(mem) );
2764#ifdef __aarch64__
2765 ok( !status, "NtSetInformationProcess failed %lx\n", status );
2766#else
2767 if (!status)
2768 {
2770 ULONG len;
2771
2773 ok (info.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM64, "succeeded on non-ARM64\n" );
2774 mem.ProcessEnableWriteExceptions = 1;
2776 &mem, sizeof(mem) );
2777 skip( "skipping test on ARM64EC\n" );
2778 return;
2779 }
2781 "NtSetInformationProcess failed %lx\n", status );
2782#endif
2783 if (status) return;
2785
2786 /* test anon mapping */
2787
2789 write_addr = (int *)ptr + 3;
2790
2791 mem.ProcessEnableWriteExceptions = 1;
2793 &mem, sizeof(mem) );
2794 ok( !status, "NtSetInformationProcess failed %lx\n", status );
2795
2796 got_exception = 0;
2797 *write_addr = 0x123456;
2798 ok( got_exception == 0, "wrong number of exceptions %u\n", got_exception );
2799 write_addr++;
2800
2802 got_exception = 0;
2803 *write_addr = 0x123456;
2804 ok( got_exception == 1, "wrong number of exceptions %u\n", got_exception );
2805 write_addr++;
2806
2807 /* no longer failing on dirty page */
2808 got_exception = 0;
2809 *write_addr = 0x123456;
2810 ok( got_exception == 0, "wrong number of exceptions %u\n", got_exception );
2811 write_addr++;
2812
2813 /* setting permissions resets protection */
2815 got_exception = 0;
2816 *write_addr = 0x123456;
2817 ok( got_exception == 1, "wrong number of exceptions %u\n", got_exception );
2818 write_addr++;
2819
2820 /* clearing dirty state also resets protection */
2821 range.VirtualAddress = ptr;
2822 range.NumberOfBytes = 1;
2823 flag = 0;
2824 status = pNtSetInformationVirtualMemory( GetCurrentProcess(), VmPageDirtyStateInformation,
2825 1, &range, &flag, sizeof(flag) );
2826 ok( !status, "NtSetInformationVirtualMemory failed %lx\n", status );
2827
2828 /* making page dirty is not allowed */
2829 flag = 1;
2830 status = pNtSetInformationVirtualMemory( GetCurrentProcess(), VmPageDirtyStateInformation,
2831 1, &range, &flag, sizeof(flag) );
2832 ok( status == STATUS_INVALID_PARAMETER_5, "NtSetInformationVirtualMemory failed %lx\n", status );
2833
2834 got_exception = 0;
2835 *write_addr = 0x123456;
2836 ok( got_exception == 1, "wrong number of exceptions %u\n", got_exception );
2837 write_addr++;
2838
2841 ok( file != INVALID_HANDLE_VALUE, "can't open %s: %lu\n", debugstr_w(path), GetLastError() );
2842 /* reading into protected page crashes on Windows */
2843 if (0) VirtualProtect( ptr, page_size, PAGE_EXECUTE_READWRITE, &old_prot );
2844 status = NtReadFile( file, 0, NULL, NULL, &io, write_addr, 8, NULL, NULL );
2845 ok( !status, "NtReadFile failed %lx\n", status );
2846 CloseHandle( file );
2847
2849
2850 /* test PE mapping */
2851
2853 write_addr = (int *)ptr + 3;
2855
2856 got_exception = 0;
2857 *write_addr = 0;
2858 ok( got_exception == 1, "wrong number of exceptions %u\n", got_exception );
2859 write_addr++;
2860
2861 got_exception = 0;
2862 *write_addr = 0;
2863 ok( got_exception == 0, "wrong number of exceptions %u\n", got_exception );
2864 write_addr++;
2865
2867 got_exception = 0;
2868 *write_addr = 0;
2869 ok( got_exception == 1, "wrong number of exceptions %u\n", got_exception );
2870 write_addr++;
2871
2872 range.VirtualAddress = write_addr;
2873 range.NumberOfBytes = 1;
2874 flag = 0;
2875 status = pNtSetInformationVirtualMemory( GetCurrentProcess(), VmPageDirtyStateInformation,
2876 1, &range, &flag, sizeof(flag) );
2877 ok( !status, "NtSetInformationVirtualMemory failed %lx\n", status );
2878 got_exception = 0;
2879 *write_addr = 0;
2880 ok( got_exception == 1, "wrong number of exceptions %u\n", got_exception );
2881 write_addr++;
2882
2883 /* test interactions with write watches */
2884
2886 write_addr = (int *)ptr + 3;
2887
2889 got_exception = 0;
2890 *write_addr = 0x123456;
2891 ok( got_exception == 1, "wrong number of exceptions %u\n", got_exception );
2892 write_addr++;
2893
2894 count = ARRAY_SIZE(addresses);
2895 status = NtGetWriteWatch( GetCurrentProcess(), 0, ptr, page_size, addresses, &count, &granularity );
2896 ok( !status, "NtGetWriteWatch failed %lx\n", status );
2897 ok( count == 1, "got count %Iu\n", count );
2898 ok( addresses[0] == ptr, "wrong ptr %p / %p\n", addresses[0], ptr );
2899
2900 got_exception = 0;
2901 *write_addr = 0x123456;
2902 ok( got_exception == 0, "wrong number of exceptions %u\n", got_exception );
2903 write_addr++;
2904
2905 count = ARRAY_SIZE(addresses);
2907 ptr, page_size, addresses, &count, &granularity );
2908 ok( !status, "NtGetWriteWatch failed %lx\n", status );
2909 ok( count == 1, "got count %Iu\n", count );
2910 ok( addresses[0] == ptr, "wrong ptr %p / %p\n", addresses[0], ptr );
2911
2912 got_exception = 0;
2913 *write_addr = 0x123456;
2914 ok( got_exception == 1, "wrong number of exceptions %u\n", got_exception );
2915 write_addr++;
2916
2917 count = ARRAY_SIZE(addresses);
2918 status = NtGetWriteWatch( GetCurrentProcess(), 0, ptr, page_size, addresses, &count, &granularity );
2919 ok( !status, "NtGetWriteWatch failed %lx\n", status );
2920 ok( count == 1, "got count %Iu\n", count );
2921 ok( addresses[0] == ptr, "wrong ptr %p / %p\n", addresses[0], ptr );
2922
2923 range.VirtualAddress = ptr;
2924 range.NumberOfBytes = 1;
2925 flag = 0;
2926 status = pNtSetInformationVirtualMemory( GetCurrentProcess(), VmPageDirtyStateInformation,
2927 1, &range, &flag, sizeof(flag) );
2928 ok( !status, "NtSetInformationVirtualMemory failed %lx\n", status );
2929
2930 count = ARRAY_SIZE(addresses);
2931 status = NtGetWriteWatch( GetCurrentProcess(), 0, ptr, page_size, addresses, &count, &granularity );
2932 ok( !status, "NtGetWriteWatch failed %lx\n", status );
2933 ok( count == 0, "got count %Iu\n", count );
2934
2935 got_exception = 0;
2936 *write_addr = 0x123456;
2937 ok( got_exception == 1, "wrong number of exceptions %u\n", got_exception );
2938 write_addr++;
2939
2940 /* test some invalid calls */
2941
2943 flag = 0;
2944 status = pNtSetInformationVirtualMemory( GetCurrentProcess(), VmPageDirtyStateInformation,
2945 1, &range, &flag, sizeof(flag) );
2946 ok( status == STATUS_MEMORY_NOT_ALLOCATED, "NtSetInformationVirtualMemory failed %lx\n", status );
2947
2948 mem.ProcessEnableWriteExceptions = 0;
2950 &mem, sizeof(mem) );
2951
2952 status = pNtSetInformationVirtualMemory( GetCurrentProcess(), VmPageDirtyStateInformation,
2953 1, &range, &flag, sizeof(flag) );
2954 ok( status == STATUS_NOT_SUPPORTED, "NtSetInformationVirtualMemory failed %lx\n", status );
2956 &mem, sizeof(mem), &len );
2957 ok( status == STATUS_INVALID_INFO_CLASS, "NtQueryInformationProcess failed %lx\n", status );
2958
2959 mem.ProcessEnableWriteExceptions = 1;
2960 mem.ThreadAllowWrites = 1;
2962 &mem, sizeof(mem) );
2963 ok( status == STATUS_INVALID_PARAMETER, "NtSetInformationProcess failed %lx\n", status );
2965 &mem, sizeof(mem) );
2966 ok( status == STATUS_INVALID_PARAMETER, "NtSetInformationThread failed %lx\n", status );
2967 mem.ProcessEnableWriteExceptions = 0;
2968 mem.ThreadAllowWrites = 0;
2969 mem.Version = 3;
2971 &mem, sizeof(mem) );
2972 ok( status == STATUS_REVISION_MISMATCH, "NtSetInformationThread failed %lx\n", status );
2974 &mem, sizeof(mem) );
2975 ok( status == STATUS_REVISION_MISMATCH, "NtSetInformationProcess failed %lx\n", status );
2976 mem.Version = 2;
2978 &mem, sizeof(mem) - 1 );
2979 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtSetInformationThread failed %lx\n", status );
2981 &mem, sizeof(mem) + 1 );
2982 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtSetInformationThread failed %lx\n", status );
2984 &mem, sizeof(mem) - 1 );
2985 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtSetInformationProcess failed %lx\n", status );
2987 &mem, sizeof(mem) + 1 );
2988 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtSetInformationProcess failed %lx\n", status );
2989
2991}
2992
2994{
2995 HMODULE mod;
2996
2997 int argc;
2998 char **argv;
3000
3001 if (argc >= 3)
3002 {
3003 if (!strcmp(argv[2], "sleep"))
3004 {
3005 Sleep(5000); /* spawned process runs for at most 5 seconds */
3006 return;
3007 }
3008 return;
3009 }
3010
3011 mod = GetModuleHandleA("kernel32.dll");
3012 pIsWow64Process = (void *)GetProcAddress(mod, "IsWow64Process");
3013 pGetEnabledXStateFeatures = (void *)GetProcAddress(mod, "GetEnabledXStateFeatures");
3014 mod = GetModuleHandleA("ntdll.dll");
3015 pRtlCreateUserStack = (void *)GetProcAddress(mod, "RtlCreateUserStack");
3016 pRtlCreateUserThread = (void *)GetProcAddress(mod, "RtlCreateUserThread");
3017 pRtlFreeUserStack = (void *)GetProcAddress(mod, "RtlFreeUserStack");
3018 pRtlFindExportedRoutineByName = (void *)GetProcAddress(mod, "RtlFindExportedRoutineByName");
3019 pRtlGetEnabledExtendedFeatures = (void *)GetProcAddress(mod, "RtlGetEnabledExtendedFeatures");
3020 pRtlGetNativeSystemInformation = (void *)GetProcAddress(mod, "RtlGetNativeSystemInformation");
3021 pRtlIsEcCode = (void *)GetProcAddress(mod, "RtlIsEcCode");
3022 pNtAllocateVirtualMemoryEx = (void *)GetProcAddress(mod, "NtAllocateVirtualMemoryEx");
3023 pNtMapViewOfSectionEx = (void *)GetProcAddress(mod, "NtMapViewOfSectionEx");
3024 pNtSetInformationVirtualMemory = (void *)GetProcAddress(mod, "NtSetInformationVirtualMemory");
3025
3027 trace("system page size %#lx\n", sbi.PageSize);
3029 if (!pIsWow64Process || !pIsWow64Process(NtCurrentProcess(), &is_wow64)) is_wow64 = FALSE;
3030
3038 test_prefetch();
3040 test_syscalls();
3044}
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3485
NTSTATUS NTAPI NtMapViewOfSection(IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
Definition: section.c:3259
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:64
COMPILER_DEPENDENT_UINT64 UINT64
Definition: actypes.h:131
#define GetNTVersion()
Definition: apitest.h:17
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ok_(x1, x2)
Definition: atltest.h:61
LONG NTSTATUS
Definition: precomp.h:26
#define ARRAY_SIZE(A)
Definition: main.h:20
static HANDLE thread
Definition: service.c:33
@ ProcessBasicInformation
Definition: cicbase.cpp:63
enum _PROCESSINFOCLASS PROCESSINFOCLASS
Definition: loader.c:66
#define STATUS_INVALID_HANDLE
Definition: d3dkmdt.h:40
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
PIMAGE_NT_HEADERS nt
Definition: delayimp.cpp:445
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static BOOL reserve(struct dynamic_array *array, int count, int itemsize)
Definition: mesh.c:5392
#define NTSTATUS
Definition: precomp.h:19
#define CloseHandle
Definition: compat.h:739
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:758
#define PAGE_READONLY
Definition: compat.h:138
#define FILE_BEGIN
Definition: compat.h:761
#define UnmapViewOfFile
Definition: compat.h:746
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define SetFilePointer
Definition: compat.h:743
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define GetCurrentProcess()
Definition: compat.h:759
#define GENERIC_READ
Definition: compat.h:135
#define RtlImageRvaToVa
Definition: compat.h:807
#define RtlImageNtHeader
Definition: compat.h:806
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_MAP_READ
Definition: compat.h:776
#define CALLBACK
Definition: compat.h:35
#define MapViewOfFile
Definition: compat.h:745
#define FILE_SHARE_READ
Definition: compat.h:136
static const WCHAR *const ext[]
Definition: module.c:53
PPEB Peb
Definition: dllmain.c:27
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:988
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1376
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:365
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(const char *app_name, char *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const char *cur_dir, STARTUPINFOA *startup_info, PROCESS_INFORMATION *info)
Definition: process.c:686
static const struct _KUSER_SHARED_DATA * user_shared_data
Definition: sync.c:43
MonoAssembly int argc
Definition: metahost.c:107
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7512
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
r reserved
Definition: btrfs.c:3006
#define INFINITE
Definition: serial.h:102
HANDLE NTAPI CreateFileMappingA(IN HANDLE hFile, IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes, IN DWORD flProtect, IN DWORD dwMaximumSizeHigh, IN DWORD dwMaximumSizeLow, IN LPCSTR lpName)
Definition: filemap.c:23
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
@ SystemBasicInformation
Definition: ntddk_ex.h:11
enum _SYSTEM_INFORMATION_CLASS SYSTEM_INFORMATION_CLASS
#define STATUS_ACCESS_VIOLATION
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLuint GLuint end
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum func
Definition: glext.h:6028
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLenum GLint GLuint mask
Definition: glext.h:6028
GLenum GLint * range
Definition: glext.h:7539
GLenum const GLvoid * addr
Definition: glext.h:9621
GLuint64EXT * result
Definition: glext.h:11304
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLuint id
Definition: glext.h:5910
GLdouble GLdouble z
Definition: glext.h:5874
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 flag
Definition: glfuncs.h:52
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
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 * u
Definition: glfuncs.h:240
#define EXCEPTION_CONTINUE_EXECUTION
Definition: excpt.h:92
#define NtCurrentTeb
#define a
Definition: ke_i.h:78
#define debugstr_w
Definition: kernel32.h:32
#define wine_dbgstr_w
Definition: kernel32.h:34
PIMAGE_BASE_RELOCATION NTAPI LdrProcessRelocationBlock(_In_ ULONG_PTR Address, _In_ ULONG Count, _In_ PUSHORT TypeOffset, _In_ LONG_PTR Delta)
Definition: ldrapi.c:1570
#define win_skip
Definition: minitest.h:67
#define todo_wine
Definition: minitest.h:80
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CREATE_ALWAYS
Definition: disk.h:72
unsigned __int64 ULONG64
Definition: imports.h:198
static PVOID ptr
Definition: dispmode.c:27
static struct test_info tests[]
#define sprintf
Definition: sprintf.c:45
static PROCESS_INFORMATION pi
Definition: debugger.c:2303
static DWORD page_size
Definition: loader.c:54
static const OBJECT_ATTRIBUTES const LARGE_INTEGER ULONG
Definition: virtual.c:44
static const OBJECT_ATTRIBUTES const LARGE_INTEGER HANDLE
Definition: virtual.c:45
static BOOL is_wow64
Definition: virtual.c:40
static HANDLE create_target_process(const char *arg)
Definition: virtual.c:62
static PVOID ULONG_PTR
Definition: virtual.c:46
static SYSTEM_INFO si
Definition: virtual.c:39
static PBOOL
Definition: virtual.c:51
static SIZE_T
Definition: virtual.c:41
static PVOID
Definition: virtual.c:43
static ULONG64 feature_mask
Definition: exception.c:78
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
Definition: file.c:72
static void check_region_size_(void *p, SIZE_T s, unsigned int line)
Definition: virtual.c:281
static void test_NtAllocateVirtualMemoryEx(void)
Definition: virtual.c:294
static void *WINAPI * pRtlFindExportedRoutineByName(HMODULE, const char *)
static int got_exception
Definition: virtual.c:2720
static void test_syscalls(void)
Definition: virtual.c:2086
static INITIAL_TEB *static SECURITY_DESCRIPTOR BOOLEAN
Definition: virtual.c:34
static void test_query_region_information(void)
Definition: virtual.c:2410
#define check_region_size(p, s)
Definition: virtual.c:280
static PMEMORY_RANGE_ENTRY
Definition: virtual.c:47
static UINT_PTR get_zero_bits(UINT_PTR p)
Definition: virtual.c:73
static void DECLSPEC_NOINLINE force_stack_grow(void)
Definition: virtual.c:979
static DWORD WINAPI test_stack_growth_thread(void *ptr)
Definition: virtual.c:1072
static DWORD WINAPI test_stack_size_dummy_thread(void *ptr)
Definition: virtual.c:1241
static INITIAL_TEB *static SECURITY_DESCRIPTOR PRTL_THREAD_START_ROUTINE
Definition: virtual.c:35
static void test_NtMapViewOfSection(void)
Definition: virtual.c:1380
static VIRTUAL_MEMORY_INFORMATION_CLASS
Definition: virtual.c:46
static void test_user_shared_data(void)
Definition: virtual.c:1948
static UINT_PTR get_zero_bits_mask(ULONG_PTR z)
Definition: virtual.c:87
static void test_NtAllocateVirtualMemoryEx_address_requirements(void)
Definition: virtual.c:706
static void test_prefetch(void)
Definition: virtual.c:2287
static void test_NtAllocateVirtualMemory(void)
Definition: virtual.c:99
static const BOOL is_win64
Definition: virtual.c:50
#define SUPPORTED_XSTATE_FEATURES
Definition: virtual.c:1946
static void perform_relocations(void *module, INT_PTR delta)
Definition: virtual.c:2051
static void test_NtMapViewOfSectionEx(void)
Definition: virtual.c:1655
static void DECLSPEC_NOINLINE force_stack_grow_small(void)
Definition: virtual.c:988
static LONG CALLBACK exec_write_handler(EXCEPTION_POINTERS *ptrs)
Definition: virtual.c:2722
static void test_query_image_information(void)
Definition: virtual.c:2506
static void test_NtFreeVirtualMemory(void)
Definition: virtual.c:2204
static DWORD WINAPI test_stack_size_thread(void *ptr)
Definition: virtual.c:997
static int * write_addr
Definition: virtual.c:2719
static void test_RtlCreateUserStack(void)
Definition: virtual.c:1246
static SYSTEM_BASIC_INFORMATION sbi
Definition: virtual.c:53
static PULONG
Definition: virtual.c:40
static void test_exec_memory_writes(void)
Definition: virtual.c:2748
#define argv
Definition: mplay32.c:18
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
unsigned int UINT
Definition: ndis.h:50
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T CommitSize
Definition: mmfuncs.h:406
__kernel_entry _Inout_ _Inout_ PSIZE_T RegionSize
Definition: mmfuncs.h:172
@ MemoryBasicInformation
Definition: mmtypes.h:183
#define SEC_IMAGE
Definition: mmtypes.h:97
#define MEM_WRITE_WATCH
Definition: mmtypes.h:86
#define MEM_TOP_DOWN
Definition: nt_native.h:1324
#define MEM_FREE
Definition: nt_native.h:1320
#define MEM_DECOMMIT
Definition: nt_native.h:1318
#define PAGE_READWRITE
Definition: nt_native.h:1307
#define MEM_PRIVATE
Definition: nt_native.h:1321
#define NtCurrentProcess()
Definition: nt_native.h:1660
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define PAGE_EXECUTE_WRITECOPY
Definition: nt_native.h:1312
#define BOOL
Definition: nt_native.h:43
#define MEM_RESERVE
Definition: nt_native.h:1317
#define MEM_RELEASE
Definition: nt_native.h:1319
#define GENERIC_WRITE
Definition: nt_native.h:90
#define MEM_COMMIT
Definition: nt_native.h:1316
#define PAGE_NOACCESS
Definition: nt_native.h:1305
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1311
#define PAGE_GUARD
Definition: nt_native.h:1313
#define DECLSPEC_NOINLINE
Definition: ntbasedef.h:229
#define IMAGE_FIRST_SECTION(NtHeader)
Definition: ntimage.h:427
NTSTATUS NTAPI NtGetWriteWatch(IN HANDLE ProcessHandle, IN ULONG Flags, IN PVOID BaseAddress, IN SIZE_T RegionSize, IN PVOID *UserAddressArray, OUT PULONG_PTR EntriesInUserAddressArray, OUT PULONG Granularity)
Definition: virtual.c:4122
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5192
NTSTATUS NTAPI NtProtectVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UnsafeBaseAddress, IN OUT SIZE_T *UnsafeNumberOfBytesToProtect, IN ULONG NewAccessProtection, OUT PULONG UnsafeOldAccessProtection)
Definition: virtual.c:3076
NTSTATUS NTAPI NtQueryVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, IN MEMORY_INFORMATION_CLASS MemoryInformationClass, OUT PVOID MemoryInformation, IN SIZE_T MemoryInformationLength, OUT PSIZE_T ReturnLength)
Definition: virtual.c:4374
NTSTATUS NTAPI NtAllocateVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UBaseAddress, IN ULONG_PTR ZeroBits, IN OUT PSIZE_T URegionSize, IN ULONG AllocationType, IN ULONG Protect)
Definition: virtual.c:4457
NTSTATUS NTAPI NtSetInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _In_reads_bytes_(ProcessInformationLength) PVOID ProcessInformation, _In_ ULONG ProcessInformationLength)
Definition: query.c:1390
NTSTATUS NTAPI NtSetInformationThread(_In_ HANDLE ThreadHandle, _In_ THREADINFOCLASS ThreadInformationClass, _In_reads_bytes_(ThreadInformationLength) PVOID ThreadInformation, _In_ ULONG ThreadInformationLength)
Definition: query.c:2269
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_writes_bytes_to_opt_(ProcessInformationLength, *ReturnLength) PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:211
#define STATUS_INVALID_ADDRESS
Definition: ntstatus.h:651
#define STATUS_MAPPED_ALIGNMENT
Definition: ntstatus.h:798
#define STATUS_UNABLE_TO_FREE_VM
Definition: ntstatus.h:356
#define STATUS_MEMORY_NOT_ALLOCATED
Definition: ntstatus.h:490
#define STATUS_INVALID_PARAMETER_9
Definition: ntstatus.h:577
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:572
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:570
#define STATUS_FREE_VM_NOT_AT_BASE
Definition: ntstatus.h:489
#define STATUS_EXECUTABLE_MEMORY_WRITE
Definition: ntstatus.h:1332
#define STATUS_INVALID_PARAMETER_6
Definition: ntstatus.h:574
#define STATUS_IN_PAGE_ERROR
Definition: ntstatus.h:336
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:354
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:333
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:571
#define STATUS_IMAGE_NOT_AT_BASE
Definition: ntstatus.h:192
#define STATUS_INVALID_PARAMETER_5
Definition: ntstatus.h:573
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:419
short WCHAR
Definition: pedump.c:58
#define IMAGE_DIRECTORY_ENTRY_BASERELOC
Definition: pedump.c:264
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define IMAGE_FILE_MACHINE_R4000
Definition: pedump.c:176
#define IMAGE_FILE_MACHINE_R3000
Definition: pedump.c:175
#define offsetof(TYPE, MEMBER)
int winetest_get_mainargs(char ***pargv)
#define memset(x, y, z)
Definition: compat.h:39
#define _WIN32_WINNT_WIN7
Definition: sdkddkver.h:28
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
TCHAR * cmdline
Definition: stretchblt.cpp:32
PEXCEPTION_RECORD ExceptionRecord
Definition: rtltypes.h:200
DWORD ExceptionCode
Definition: compat.h:208
DWORD NumberParameters
Definition: compat.h:212
ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]
Definition: compat.h:213
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
Definition: winternl.h:2504
PVOID VirtualAddress
Definition: winternl.h:2505
SIZE_T NumberOfBytes
Definition: winternl.h:2506
ULONG NumberOfProcessors
Definition: ntddk_ex.h:269
PVOID ImageBaseAddress
Definition: ntddk_ex.h:245
PVOID lpMaximumApplicationAddress
Definition: winbase.h:900
XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES]
Definition: ketypes.h:1370
ULONG64 EnabledSupervisorFeatures
Definition: ketypes.h:1372
ULONG64 EnabledVolatileFeatures
Definition: ketypes.h:1357
ULONG64 EnabledFeatures
Definition: ketypes.h:1355
ULONG AllFeatures[MAXIMUM_XSTATE_FEATURES]
Definition: ketypes.h:1375
ULONG64 AlignedFeatures
Definition: ketypes.h:1373
Definition: winnt.h:146
Definition: match.c:390
Definition: fci.c:127
Definition: parser.c:49
Definition: mem.c:349
Definition: format.c:80
Definition: ps.c:97
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:726
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:587
int32_t INT_PTR
Definition: typedefs.h:64
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint64_t DWORD64
Definition: typedefs.h:67
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t UINT32
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
LPVOID NTAPI VirtualAlloc(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flAllocationType, IN DWORD flProtect)
Definition: virtmem.c:65
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
Definition: virtmem.c:135
BOOL NTAPI VirtualFree(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD dwFreeType)
Definition: virtmem.c:119
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1146
#define STACK_SIZE_PARAM_IS_A_RESERVATION
Definition: winbase.h:224
_Inout_ PERBANDINFO * pbi
Definition: winddi.h:3917
#define WINAPI
Definition: msvc.h:6
@ MemoryRegionInformation
Definition: winternl.h:2388
@ MemoryImageInformation
Definition: winternl.h:2391
NTSYSAPI ULONG WINAPI RtlRemoveVectoredExceptionHandler(PVOID)
@ VmPageDirtyStateInformation
Definition: winternl.h:2496
@ VmPrefetchInformation
Definition: winternl.h:2493
@ ThreadManageWritesToExecutableMemory
Definition: winternl.h:2329
NTSYSAPI NTSTATUS WINAPI RtlGetNativeSystemInformation(SYSTEM_INFORMATION_CLASS, void *, ULONG, ULONG *)
@ ProcessManageWritesToExecutableMemory
Definition: winternl.h:1965
NTSYSAPI PVOID WINAPI RtlAddVectoredExceptionHandler(ULONG, PVECTORED_EXCEPTION_HANDLER)
@ SystemCpuInformation
Definition: winternl.h:2014
struct _YMMCONTEXT YMMCONTEXT
#define WRITE_WATCH_FLAG_RESET
Definition: winnt_old.h:616
MEM_EXTENDED_PARAMETER
Definition: winnt_old.h:1265
#define MEM_REPLACE_PLACEHOLDER
Definition: winnt_old.h:576
#define AT_ROUND_TO_PAGE
Definition: winnt_old.h:621
#define MEM_EXTENDED_PARAMETER_EC_CODE
Definition: winnt_old.h:597
#define PROCESSOR_ARCHITECTURE_ARM64
Definition: winnt_old.h:503
#define MEM_PRESERVE_PLACEHOLDER
Definition: winnt_old.h:579
#define MEM_RESERVE_PLACEHOLDER
Definition: winnt_old.h:577
#define MEM_COALESCE_PLACEHOLDERS
Definition: winnt_old.h:578
@ MemExtendedParameterAttributeFlags
Definition: winnt_old.h:1237
@ MemExtendedParameterAddressRequirements
Definition: winnt_old.h:1233
@ MemExtendedParameterImageMachine
Definition: winnt_old.h:1238
@ MemExtendedParameterMax
Definition: winnt_old.h:1239
#define MAXIMUM_XSTATE_FEATURES
Definition: ketypes.h:1346
#define PF_RDTSC_INSTRUCTION_AVAILABLE
Definition: ketypes.h:184