ReactOS 0.4.16-dev-1535-gea189a3
info.c
Go to the documentation of this file.
1/* Unit test suite for *Information* Registry API functions
2 *
3 * Copyright 2005 Paul Vriens
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 *
19 */
20
21#include "ntdll_test.h"
22#include <winnls.h>
23#include <stdio.h>
24
25static NTSTATUS (WINAPI * pRtlDowncaseUnicodeString)(UNICODE_STRING *, const UNICODE_STRING *, BOOLEAN);
26static NTSTATUS (WINAPI * pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG);
27static NTSTATUS (WINAPI * pNtQuerySystemInformationEx)(SYSTEM_INFORMATION_CLASS, void*, ULONG, void*, ULONG, ULONG*);
28static NTSTATUS (WINAPI * pNtPowerInformation)(POWER_INFORMATION_LEVEL, PVOID, ULONG, PVOID, ULONG);
29static NTSTATUS (WINAPI * pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
30static NTSTATUS (WINAPI * pNtQueryInformationThread)(HANDLE, THREADINFOCLASS, PVOID, ULONG, PULONG);
31static NTSTATUS (WINAPI * pNtSetInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG);
32static NTSTATUS (WINAPI * pNtSetInformationThread)(HANDLE, THREADINFOCLASS, PVOID, ULONG);
33static NTSTATUS (WINAPI * pNtReadVirtualMemory)(HANDLE, const void*, void*, SIZE_T, SIZE_T*);
34static NTSTATUS (WINAPI * pNtQueryVirtualMemory)(HANDLE, LPCVOID, MEMORY_INFORMATION_CLASS , PVOID , SIZE_T , SIZE_T *);
37static NTSTATUS (WINAPI * pNtUnmapViewOfSection)(HANDLE,PVOID);
38static NTSTATUS (WINAPI * pNtClose)(HANDLE);
39static ULONG (WINAPI * pNtGetCurrentProcessorNumber)(void);
40static BOOL (WINAPI * pIsWow64Process)(HANDLE, PBOOL);
41static BOOL (WINAPI * pGetLogicalProcessorInformationEx)(LOGICAL_PROCESSOR_RELATIONSHIP,SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*,DWORD*);
42
44
45/* one_before_last_pid is used to be able to compare values of a still running process
46 with the output of the test_query_process_times and test_query_process_handlecount tests.
47*/
49
50#define NTDLL_GET_PROC(func) do { \
51 p ## func = (void*)GetProcAddress(hntdll, #func); \
52 if(!p ## func) { \
53 trace("GetProcAddress(%s) failed\n", #func); \
54 return FALSE; \
55 } \
56 } while(0)
57
59{
60 /* All needed functions are NT based, so using GetModuleHandle is a good check */
63
64 if (!hntdll)
65 {
66 win_skip("Not running on NT\n");
67 return FALSE;
68 }
69
83
84 /* not present before XP */
85 pNtGetCurrentProcessorNumber = (void *) GetProcAddress(hntdll, "NtGetCurrentProcessorNumber");
86
87 pIsWow64Process = (void *)GetProcAddress(hkernel32, "IsWow64Process");
88 if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
89
90 /* starting with Win7 */
91 pNtQuerySystemInformationEx = (void *) GetProcAddress(hntdll, "NtQuerySystemInformationEx");
92 if (!pNtQuerySystemInformationEx)
93 win_skip("NtQuerySystemInformationEx() is not supported, some tests will be skipped.\n");
94
95 pGetLogicalProcessorInformationEx = (void *) GetProcAddress(hkernel32, "GetLogicalProcessorInformationEx");
96
97 return TRUE;
98}
99
100static void test_query_basic(void)
101{
105
106 /* This test also covers some basic parameter testing that should be the same for
107 * every information class
108 */
109
110 /* Use a nonexistent info class */
111 trace("Check nonexistent info class\n");
112 status = pNtQuerySystemInformation(-1, NULL, 0, NULL);
114 "Expected STATUS_INVALID_INFO_CLASS or STATUS_NOT_IMPLEMENTED, got %08x\n", status);
115
116 /* Use an existing class but with a zero-length buffer */
117 trace("Check zero-length buffer\n");
118 status = pNtQuerySystemInformation(SystemBasicInformation, NULL, 0, NULL);
119 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
120
121 /* Use an existing class, correct length but no SystemInformation buffer */
122 trace("Check no SystemInformation buffer\n");
123 status = pNtQuerySystemInformation(SystemBasicInformation, NULL, sizeof(sbi), NULL);
125 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_PARAMETER, got %08x\n", status);
126
127 /* Use an existing class, correct length, a pointer to a buffer but no ReturnLength pointer */
128 trace("Check no ReturnLength pointer\n");
129 status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), NULL);
130 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
131
132 /* Check a too large buffer size */
133 trace("Check a too large buffer size\n");
134 status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi) * 2, &ReturnLength);
135 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
136
137 /* Finally some correct calls */
138 trace("Check with correct parameters\n");
139 status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
140 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
141 ok( sizeof(sbi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
142
143 /* Check if we have some return values */
144 trace("Number of Processors : %d\n", sbi.NumberOfProcessors);
145 ok( sbi.NumberOfProcessors > 0, "Expected more than 0 processors, got %d\n", sbi.NumberOfProcessors);
146}
147
148static void test_query_cpu(void)
149{
153
154 status = pNtQuerySystemInformation(SystemCpuInformation, &sci, sizeof(sci), &ReturnLength);
155 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
156 ok( sizeof(sci) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
157
158 /* Check if we have some return values */
159 trace("Processor FeatureSet : %08x\n", sci.ProcessorFeatureBits);
160 ok( sci.ProcessorFeatureBits != 0, "Expected some features for this processor, got %08x\n", sci.ProcessorFeatureBits);
161}
162
163static void test_query_performance(void)
164{
169
170 status = pNtQuerySystemInformation(SystemPerformanceInformation, buffer, 0, &ReturnLength);
171 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
172
173 status = pNtQuerySystemInformation(SystemPerformanceInformation, buffer, size, &ReturnLength);
175 {
176 /* size is larger on wow64 under w2k8/win7 */
177 size += 16;
178 status = pNtQuerySystemInformation(SystemPerformanceInformation, buffer, size, &ReturnLength);
179 }
180 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
181 ok( ReturnLength == size, "Inconsistent length %d\n", ReturnLength);
182
183 status = pNtQuerySystemInformation(SystemPerformanceInformation, buffer, size + 2, &ReturnLength);
184 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
185 ok( ReturnLength == size || ReturnLength == size + 2,
186 "Inconsistent length %d\n", ReturnLength);
187
188 /* Not return values yet, as struct members are unknown */
189}
190
191static void test_query_timeofday(void)
192{
195
196 /* Copy of our winternl.h structure turned into a private one */
197 typedef struct _SYSTEM_TIMEOFDAY_INFORMATION_PRIVATE {
198 LARGE_INTEGER liKeBootTime;
199 LARGE_INTEGER liKeSystemTime;
200 LARGE_INTEGER liExpTimeZoneBias;
201 ULONG uCurrentTimeZoneId;
202 DWORD dwUnknown1[5];
203 } SYSTEM_TIMEOFDAY_INFORMATION_PRIVATE;
204
205 SYSTEM_TIMEOFDAY_INFORMATION_PRIVATE sti;
206
207 /* The struct size for NT (32 bytes) and Win2K/XP (48 bytes) differ.
208 *
209 * Windows 2000 and XP return STATUS_INFO_LENGTH_MISMATCH if the given buffer size is greater
210 * then 48 and 0 otherwise
211 * Windows NT returns STATUS_INFO_LENGTH_MISMATCH when the given buffer size is not correct
212 * and 0 otherwise
213 *
214 * Windows 2000 and XP copy the given buffer size into the provided buffer, if the return code is STATUS_SUCCESS
215 * NT only fills the buffer if the return code is STATUS_SUCCESS
216 *
217 */
218
219 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, sizeof(sti), &ReturnLength);
220
222 {
223 trace("Windows version is NT, we have to cater for differences with W2K/WinXP\n");
224
225 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 0, &ReturnLength);
226 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
227 ok( 0 == ReturnLength, "ReturnLength should be 0, it is (%d)\n", ReturnLength);
228
229 sti.uCurrentTimeZoneId = 0xdeadbeef;
230 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 28, &ReturnLength);
231 ok(status == STATUS_SUCCESS || broken(status == STATUS_INFO_LENGTH_MISMATCH /* NT4 */), "Expected STATUS_SUCCESS, got %08x\n", status);
232 ok( 0xdeadbeef == sti.uCurrentTimeZoneId, "This part of the buffer should not have been filled\n");
233
234 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 32, &ReturnLength);
235 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
236 ok( 32 == ReturnLength, "ReturnLength should be 0, it is (%d)\n", ReturnLength);
237 }
238 else
239 {
240 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 0, &ReturnLength);
241 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
242 ok( 0 == ReturnLength, "ReturnLength should be 0, it is (%d)\n", ReturnLength);
243
244 sti.uCurrentTimeZoneId = 0xdeadbeef;
245 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 24, &ReturnLength);
246 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
247 ok( 24 == ReturnLength, "ReturnLength should be 24, it is (%d)\n", ReturnLength);
248 ok( 0xdeadbeef == sti.uCurrentTimeZoneId, "This part of the buffer should not have been filled\n");
249
250 sti.uCurrentTimeZoneId = 0xdeadbeef;
251 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 32, &ReturnLength);
252 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
253 ok( 32 == ReturnLength, "ReturnLength should be 32, it is (%d)\n", ReturnLength);
254 ok( 0xdeadbeef != sti.uCurrentTimeZoneId, "Buffer should have been partially filled\n");
255
256 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 49, &ReturnLength);
257 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
258 ok( ReturnLength == 0 || ReturnLength == sizeof(sti) /* vista */,
259 "ReturnLength should be 0, it is (%d)\n", ReturnLength);
260
261 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, sizeof(sti), &ReturnLength);
262 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
263 ok( sizeof(sti) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
264 }
265
266 /* Check if we have some return values */
267 trace("uCurrentTimeZoneId : (%d)\n", sti.uCurrentTimeZoneId);
268}
269
270static void test_query_process(void)
271{
273 DWORD last_pid;
275 int i = 0, k = 0;
276 BOOL is_nt = FALSE;
278
279 /* Copy of our winternl.h structure turned into a private one */
280 typedef struct _SYSTEM_PROCESS_INFORMATION_PRIVATE {
281 ULONG NextEntryOffset;
282 DWORD dwThreadCount;
283 DWORD dwUnknown1[6];
284 FILETIME ftCreationTime;
285 FILETIME ftUserTime;
286 FILETIME ftKernelTime;
287 UNICODE_STRING ProcessName;
288 DWORD dwBasePriority;
289 HANDLE UniqueProcessId;
290 HANDLE ParentProcessId;
291 ULONG HandleCount;
292 DWORD dwUnknown3;
293 DWORD dwUnknown4;
294 VM_COUNTERS vmCounters;
295 IO_COUNTERS ioCounters;
297 } SYSTEM_PROCESS_INFORMATION_PRIVATE;
298
299 ULONG SystemInformationLength = sizeof(SYSTEM_PROCESS_INFORMATION_PRIVATE);
300 SYSTEM_PROCESS_INFORMATION_PRIVATE *spi, *spi_buf = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
301
302 /* test ReturnLength */
303 ReturnLength = 0;
304 status = pNtQuerySystemInformation(SystemProcessInformation, NULL, 0, &ReturnLength);
305 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH got %08x\n", status);
306 ok( ReturnLength > 0 || broken(ReturnLength == 0) /* NT4, Win2K */,
307 "Expected a ReturnLength to show the needed length\n");
308
309 /* W2K3 and later returns the needed length, the rest returns 0, so we have to loop */
310 for (;;)
311 {
312 status = pNtQuerySystemInformation(SystemProcessInformation, spi_buf, SystemInformationLength, &ReturnLength);
313
315
316 spi_buf = HeapReAlloc(GetProcessHeap(), 0, spi_buf , SystemInformationLength *= 2);
317 }
318 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
319 spi = spi_buf;
320
321 /* Get the first NextEntryOffset, from this we can deduce the OS version we're running
322 *
323 * W2K/WinXP/W2K3:
324 * NextEntryOffset for a process is 184 + (no. of threads) * sizeof(SYSTEM_THREAD_INFORMATION)
325 * NT:
326 * NextEntryOffset for a process is 136 + (no. of threads) * sizeof(SYSTEM_THREAD_INFORMATION)
327 * Wine (with every windows version):
328 * NextEntryOffset for a process is 0 if just this test is running
329 * NextEntryOffset for a process is 184 + (no. of threads) * sizeof(SYSTEM_THREAD_INFORMATION) +
330 * ProcessName.MaximumLength
331 * if more wine processes are running
332 *
333 * Note : On windows the first process is in fact the Idle 'process' with a thread for every processor
334 */
335
336 pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
337
338 is_nt = ( spi->NextEntryOffset - (sbi.NumberOfProcessors * sizeof(SYSTEM_THREAD_INFORMATION)) == 136);
339
340 if (is_nt) win_skip("Windows version is NT, we will skip thread tests\n");
341
342 /* Check if we have some return values
343 *
344 * On windows there will be several processes running (Including the always present Idle and System)
345 * On wine we only have one (if this test is the only wine process running)
346 */
347
348 /* Loop through the processes */
349
350 for (;;)
351 {
352 i++;
353
354 last_pid = (DWORD_PTR)spi->UniqueProcessId;
355
357 ok( spi->dwThreadCount > 0, "Expected some threads for this process, got 0\n");
358
359 /* Loop through the threads, skip NT4 for now */
360
361 if (!is_nt)
362 {
363 DWORD j;
364 for ( j = 0; j < spi->dwThreadCount; j++)
365 {
366 k++;
368 ok ( spi->ti[j].ClientId.UniqueProcess == spi->UniqueProcessId,
369 "The owning pid of the thread (%p) doesn't equal the pid (%p) of the process\n",
370 spi->ti[j].ClientId.UniqueProcess, spi->UniqueProcessId);
371 }
372 }
373
374 if (!spi->NextEntryOffset) break;
375
376 one_before_last_pid = last_pid;
377
378 spi = (SYSTEM_PROCESS_INFORMATION_PRIVATE*)((char*)spi + spi->NextEntryOffset);
379 }
380 trace("Total number of running processes : %d\n", i);
381 if (!is_nt) trace("Total number of running threads : %d\n", k);
382
383 if (one_before_last_pid == 0) one_before_last_pid = last_pid;
384
385 HeapFree( GetProcessHeap(), 0, spi_buf);
386}
387
388static void test_query_procperf(void)
389{
392 ULONG NeededLength;
395
396 /* Find out the number of processors */
397 status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
398 ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
400
401 sppi = HeapAlloc(GetProcessHeap(), 0, NeededLength);
402
403 status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi, 0, &ReturnLength);
404 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
405
406 /* Try it for 1 processor */
407 sppi->KernelTime.QuadPart = 0xdeaddead;
408 sppi->UserTime.QuadPart = 0xdeaddead;
409 sppi->IdleTime.QuadPart = 0xdeaddead;
410 status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi,
412 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
414 "Inconsistent length %d\n", ReturnLength);
415 ok (sppi->KernelTime.QuadPart != 0xdeaddead, "KernelTime unchanged\n");
416 ok (sppi->UserTime.QuadPart != 0xdeaddead, "UserTime unchanged\n");
417 ok (sppi->IdleTime.QuadPart != 0xdeaddead, "IdleTime unchanged\n");
418
419 /* Try it for all processors */
420 sppi->KernelTime.QuadPart = 0xdeaddead;
421 sppi->UserTime.QuadPart = 0xdeaddead;
422 sppi->IdleTime.QuadPart = 0xdeaddead;
423 status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi, NeededLength, &ReturnLength);
424 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
425 ok( NeededLength == ReturnLength, "Inconsistent length (%d) <-> (%d)\n", NeededLength, ReturnLength);
426 ok (sppi->KernelTime.QuadPart != 0xdeaddead, "KernelTime unchanged\n");
427 ok (sppi->UserTime.QuadPart != 0xdeaddead, "UserTime unchanged\n");
428 ok (sppi->IdleTime.QuadPart != 0xdeaddead, "IdleTime unchanged\n");
429
430 /* A too large given buffer size */
431 sppi = HeapReAlloc(GetProcessHeap(), 0, sppi , NeededLength + 2);
432 sppi->KernelTime.QuadPart = 0xdeaddead;
433 sppi->UserTime.QuadPart = 0xdeaddead;
434 sppi->IdleTime.QuadPart = 0xdeaddead;
435 status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi, NeededLength + 2, &ReturnLength);
437 "Expected STATUS_SUCCESS or STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
438 ok( NeededLength == ReturnLength, "Inconsistent length (%d) <-> (%d)\n", NeededLength, ReturnLength);
439 if (status == STATUS_SUCCESS)
440 {
441 ok (sppi->KernelTime.QuadPart != 0xdeaddead, "KernelTime unchanged\n");
442 ok (sppi->UserTime.QuadPart != 0xdeaddead, "UserTime unchanged\n");
443 ok (sppi->IdleTime.QuadPart != 0xdeaddead, "IdleTime unchanged\n");
444 }
445 else /* vista and 2008 */
446 {
447 ok (sppi->KernelTime.QuadPart == 0xdeaddead, "KernelTime changed\n");
448 ok (sppi->UserTime.QuadPart == 0xdeaddead, "UserTime changed\n");
449 ok (sppi->IdleTime.QuadPart == 0xdeaddead, "IdleTime changed\n");
450 }
451
452 HeapFree( GetProcessHeap(), 0, sppi);
453}
454
455static void test_query_module(void)
456{
459 ULONG ModuleCount, i;
460
461 ULONG SystemInformationLength = sizeof(RTL_PROCESS_MODULES);
462 RTL_PROCESS_MODULES* smi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
464
465 /* Request the needed length */
466 status = pNtQuerySystemInformation(SystemModuleInformation, smi, 0, &ReturnLength);
467 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
468 ok( ReturnLength > 0, "Expected a ReturnLength to show the needed length\n");
469
470 SystemInformationLength = ReturnLength;
471 smi = HeapReAlloc(GetProcessHeap(), 0, smi , SystemInformationLength);
472 status = pNtQuerySystemInformation(SystemModuleInformation, smi, SystemInformationLength, &ReturnLength);
473 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
474
475 ModuleCount = smi->ModulesCount;
476 sm = &smi->Modules[0];
477 /* our implementation is a stub for now */
478 ok( ModuleCount > 0, "Expected some modules to be loaded\n");
479
480 /* Loop through all the modules/drivers, Wine doesn't get here (yet) */
481 for (i = 0; i < ModuleCount ; i++)
482 {
483 ok( i == sm->LoadOrderIndex, "LoadOrderIndex (%d) should have matched %u\n", sm->LoadOrderIndex, i);
484 sm++;
485 }
486
487 HeapFree( GetProcessHeap(), 0, smi);
488}
489
490static void test_query_handle(void)
491{
493 ULONG ExpectedLength, ReturnLength;
494 ULONG SystemInformationLength = sizeof(SYSTEM_HANDLE_INFORMATION);
495 SYSTEM_HANDLE_INFORMATION* shi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
497 BOOL found;
498 INT i;
499
501 ok( EventHandle != NULL, "CreateEventA failed %u\n", GetLastError() );
502
503 /* Request the needed length : a SystemInformationLength greater than one struct sets ReturnLength */
504 ReturnLength = 0xdeadbeef;
505 status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
506 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
507 ok( ReturnLength != 0xdeadbeef, "Expected valid ReturnLength\n" );
508
509 SystemInformationLength = ReturnLength;
510 shi = HeapReAlloc(GetProcessHeap(), 0, shi , SystemInformationLength);
511 memset(shi, 0x55, SystemInformationLength);
512
513 ReturnLength = 0xdeadbeef;
514 status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
515 while (status == STATUS_INFO_LENGTH_MISMATCH) /* Vista / 2008 */
516 {
517 SystemInformationLength *= 2;
518 shi = HeapReAlloc(GetProcessHeap(), 0, shi, SystemInformationLength);
519 memset(shi, 0x55, SystemInformationLength);
520 status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
521 }
522 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
523 ExpectedLength = FIELD_OFFSET(SYSTEM_HANDLE_INFORMATION, Handle[shi->Count]);
524 ok( ReturnLength == ExpectedLength || broken(ReturnLength == ExpectedLength - sizeof(DWORD)), /* Vista / 2008 */
525 "Expected length %u, got %u\n", ExpectedLength, ReturnLength );
526 ok( shi->Count > 1, "Expected more than 1 handle, got %u\n", shi->Count );
527 ok( shi->Handle[1].HandleValue != 0x5555 || broken( shi->Handle[1].HandleValue == 0x5555 ), /* Vista / 2008 */
528 "Uninitialized second handle\n" );
529 if (shi->Handle[1].HandleValue == 0x5555)
530 {
531 win_skip("Skipping broken SYSTEM_HANDLE_INFORMATION\n");
533 goto done;
534 }
535
536 for (i = 0, found = FALSE; i < shi->Count && !found; i++)
537 found = (shi->Handle[i].OwnerPid == GetCurrentProcessId()) &&
539 ok( found, "Expected to find event handle %p (pid %x) in handle list\n", EventHandle, GetCurrentProcessId() );
540
541 if (!found)
542 for (i = 0; i < shi->Count; i++)
543 trace( "%d: handle %x pid %x\n", i, shi->Handle[i].HandleValue, shi->Handle[i].OwnerPid );
544
546
547 ReturnLength = 0xdeadbeef;
548 status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
549 while (status == STATUS_INFO_LENGTH_MISMATCH) /* Vista / 2008 */
550 {
551 SystemInformationLength *= 2;
552 shi = HeapReAlloc(GetProcessHeap(), 0, shi, SystemInformationLength);
553 status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
554 }
555 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
556 for (i = 0, found = FALSE; i < shi->Count && !found; i++)
557 found = (shi->Handle[i].OwnerPid == GetCurrentProcessId()) &&
559 ok( !found, "Unexpectedly found event handle in handle list\n" );
560
561 status = pNtQuerySystemInformation(SystemHandleInformation, NULL, SystemInformationLength, &ReturnLength);
562 ok( status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", status );
563
564done:
565 HeapFree( GetProcessHeap(), 0, shi);
566}
567
568static void test_query_handle_ex(void)
569{
571 ULONG ExpectedLength, ReturnLength;
572 ULONG SystemInformationLength = sizeof(SYSTEM_HANDLE_INFORMATION_EX);
573 SYSTEM_HANDLE_INFORMATION_EX* shi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
575 BOOL found;
576 INT i;
577
579 ok( EventHandle != NULL, "CreateEventA failed %u\n", GetLastError() );
580
581 ReturnLength = 0xdeadbeef;
582 status = pNtQuerySystemInformation(SystemExtendedHandleInformation, shi, SystemInformationLength, &ReturnLength);
583 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
584 ok( ReturnLength != 0xdeadbeef, "Expected valid ReturnLength\n" );
585
586 SystemInformationLength = ReturnLength;
587 shi = HeapReAlloc(GetProcessHeap(), 0, shi , SystemInformationLength);
588 memset(shi, 0x55, SystemInformationLength);
589
590 ReturnLength = 0xdeadbeef;
591 status = pNtQuerySystemInformation(SystemExtendedHandleInformation, shi, SystemInformationLength, &ReturnLength);
592 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
593 ExpectedLength = FIELD_OFFSET(SYSTEM_HANDLE_INFORMATION_EX, Handles[shi->NumberOfHandles]);
594 ok( ReturnLength == ExpectedLength, "Expected length %u, got %u\n", ExpectedLength, ReturnLength );
595 ok( shi->NumberOfHandles > 1, "Expected more than 1 handle, got %u\n", (DWORD)shi->NumberOfHandles );
596
597 for (i = 0, found = FALSE; i < shi->NumberOfHandles && !found; i++)
598 found = (shi->Handles[i].UniqueProcessId == GetCurrentProcessId()) &&
600 ok( found, "Expected to find event handle %p (pid %x) in handle list\n", EventHandle, GetCurrentProcessId() );
601
602 if (!found)
603 {
604 for (i = 0; i < shi->NumberOfHandles; i++)
605 trace( "%d: handle %x pid %x\n", i, (DWORD)shi->Handles[i].HandleValue, (DWORD)shi->Handles[i].UniqueProcessId );
606 }
607
609
610 ReturnLength = 0xdeadbeef;
611 status = pNtQuerySystemInformation(SystemExtendedHandleInformation, shi, SystemInformationLength, &ReturnLength);
612 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
613 for (i = 0, found = FALSE; i < shi->NumberOfHandles && !found; i++)
614 found = (shi->Handles[i].UniqueProcessId == GetCurrentProcessId()) &&
616 ok( !found, "Unexpectedly found event handle in handle list\n" );
617
618 status = pNtQuerySystemInformation(SystemExtendedHandleInformation, NULL, SystemInformationLength, &ReturnLength);
619 ok( status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", status );
620
621 HeapFree( GetProcessHeap(), 0, shi);
622}
623
624static void test_query_cache(void)
625{
628 BYTE buffer[128];
631 INT i;
632
633 /* the large SYSTEM_CACHE_INFORMATION on WIN64 is not documented */
635 for (i = sizeof(buffer); i>= expected; i--)
636 {
637 ReturnLength = 0xdeadbeef;
638 status = pNtQuerySystemInformation(SystemFileCacheInformation, sci, i, &ReturnLength);
640 "%d: got 0x%x and %u (expected STATUS_SUCCESS and %u)\n", i, status, ReturnLength, expected);
641 }
642
643 /* buffer too small for the full result.
644 Up to win7, the function succeeds with a partial result. */
645 status = pNtQuerySystemInformation(SystemFileCacheInformation, sci, i, &ReturnLength);
646 if (!status)
647 {
648 expected = offsetof(SYSTEM_CACHE_INFORMATION, MinimumWorkingSet);
649 for (; i>= expected; i--)
650 {
651 ReturnLength = 0xdeadbeef;
652 status = pNtQuerySystemInformation(SystemFileCacheInformation, sci, i, &ReturnLength);
654 "%d: got 0x%x and %u (expected STATUS_SUCCESS and %u)\n", i, status, ReturnLength, expected);
655 }
656 }
657
658 /* buffer too small for the result, this call will always fail */
659 ReturnLength = 0xdeadbeef;
660 status = pNtQuerySystemInformation(SystemFileCacheInformation, sci, i, &ReturnLength);
662 ((ReturnLength == expected) || broken(!ReturnLength) || broken(ReturnLength == 0xfffffff0)),
663 "%d: got 0x%x and %u (expected STATUS_INFO_LENGTH_MISMATCH and %u)\n", i, status, ReturnLength, expected);
664
665 if (0) {
666 /* this crashes on some vista / win7 machines */
667 ReturnLength = 0xdeadbeef;
668 status = pNtQuerySystemInformation(SystemFileCacheInformation, sci, 0, &ReturnLength);
670 ((ReturnLength == expected) || broken(!ReturnLength) || broken(ReturnLength == 0xfffffff0)),
671 "0: got 0x%x and %u (expected STATUS_INFO_LENGTH_MISMATCH and %u)\n", status, ReturnLength, expected);
672 }
673}
674
675static void test_query_interrupt(void)
676{
679 ULONG NeededLength;
682
683 /* Find out the number of processors */
684 status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
685 ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
686 NeededLength = sbi.NumberOfProcessors * sizeof(SYSTEM_INTERRUPT_INFORMATION);
687
688 sii = HeapAlloc(GetProcessHeap(), 0, NeededLength);
689
690 status = pNtQuerySystemInformation(SystemInterruptInformation, sii, 0, &ReturnLength);
691 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
692
693 /* Try it for all processors */
694 status = pNtQuerySystemInformation(SystemInterruptInformation, sii, NeededLength, &ReturnLength);
695 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
696
697 /* Windows XP and W2K3 (and others?) always return 0 for the ReturnLength
698 * No test added for this as it's highly unlikely that an app depends on this
699 */
700
701 HeapFree( GetProcessHeap(), 0, sii);
702}
703
704static void test_query_kerndebug(void)
705{
709
710 status = pNtQuerySystemInformation(SystemKernelDebuggerInformation, &skdi, 0, &ReturnLength);
711 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
712
713 status = pNtQuerySystemInformation(SystemKernelDebuggerInformation, &skdi, sizeof(skdi), &ReturnLength);
714 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
715 ok( sizeof(skdi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
716
717 status = pNtQuerySystemInformation(SystemKernelDebuggerInformation, &skdi, sizeof(skdi) + 2, &ReturnLength);
718 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
719 ok( sizeof(skdi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
720}
721
722static void test_query_regquota(void)
723{
727
728 status = pNtQuerySystemInformation(SystemRegistryQuotaInformation, &srqi, 0, &ReturnLength);
729 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
730
731 status = pNtQuerySystemInformation(SystemRegistryQuotaInformation, &srqi, sizeof(srqi), &ReturnLength);
732 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
733 ok( sizeof(srqi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
734
735 status = pNtQuerySystemInformation(SystemRegistryQuotaInformation, &srqi, sizeof(srqi) + 2, &ReturnLength);
736 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
737 ok( sizeof(srqi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
738}
739
740static void test_query_logicalproc(void)
741{
743 ULONG len, i, proc_no;
745 SYSTEM_INFO si;
746
747 GetSystemInfo(&si);
748
749 status = pNtQuerySystemInformation(SystemLogicalProcessorInformation, NULL, 0, &len);
751 {
752 win_skip("SystemLogicalProcessorInformation is not supported\n");
753 return;
754 }
756 {
757 todo_wine ok(0, "SystemLogicalProcessorInformation is not implemented\n");
758 return;
759 }
760 ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
761 ok(len%sizeof(*slpi) == 0, "Incorrect length %d\n", len);
762
763 slpi = HeapAlloc(GetProcessHeap(), 0, len);
764 status = pNtQuerySystemInformation(SystemLogicalProcessorInformation, slpi, len, &len);
765 ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
766
767 proc_no = 0;
768 for(i=0; i<len/sizeof(*slpi); i++) {
769 switch(slpi[i].Relationship) {
771 /* Get number of logical processors */
772 for(; slpi[i].ProcessorMask; slpi[i].ProcessorMask /= 2)
773 proc_no += slpi[i].ProcessorMask%2;
774 break;
775 default:
776 break;
777 }
778 }
779 ok(proc_no > 0, "No processors were found\n");
780 if(si.dwNumberOfProcessors <= 32)
781 ok(proc_no == si.dwNumberOfProcessors, "Incorrect number of logical processors: %d, expected %d\n",
782 proc_no, si.dwNumberOfProcessors);
783
784 HeapFree(GetProcessHeap(), 0, slpi);
785}
786
788{
790 DWORD relationship, len2, len;
792 BOOL ret;
793
794 if (!pNtQuerySystemInformationEx)
795 return;
796
797 len = 0;
798 relationship = RelationProcessorCore;
799 status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), NULL, 0, &len);
800 ok(status == STATUS_INFO_LENGTH_MISMATCH, "got 0x%08x\n", status);
801 ok(len > 0, "got %u\n", len);
802
803 len = 0;
804 relationship = RelationAll;
805 status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), NULL, 0, &len);
806 ok(status == STATUS_INFO_LENGTH_MISMATCH, "got 0x%08x\n", status);
807 ok(len > 0, "got %u\n", len);
808
809 len2 = 0;
810 ret = pGetLogicalProcessorInformationEx(RelationAll, NULL, &len2);
811 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d, error %d\n", ret, GetLastError());
812 ok(len == len2, "got %u, expected %u\n", len2, len);
813
814 if (len && len == len2) {
815 int j, i;
816
819
820 status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), infoex, len, &len);
821 ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
822
823 ret = pGetLogicalProcessorInformationEx(RelationAll, infoex2, &len2);
824 ok(ret, "got %d, error %d\n", ret, GetLastError());
825 ok(!memcmp(infoex, infoex2, len), "returned info data mismatch\n");
826
827 for(i = 0; status == STATUS_SUCCESS && i < len; ){
828 SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *ex = (void*)(((char *)infoex) + i);
829
830 ok(ex->Relationship >= RelationProcessorCore && ex->Relationship <= RelationGroup,
831 "Got invalid relationship value: 0x%x\n", ex->Relationship);
832 if (!ex->Size)
833 {
834 ok(0, "got infoex[%u].Size=0\n", i);
835 break;
836 }
837
838 trace("infoex[%u].Size: %u\n", i, ex->Size);
839 switch(ex->Relationship){
842 trace("infoex[%u].Relationship: 0x%x (Core == 0x0 or Package == 0x3)\n", i, ex->Relationship);
843 trace("infoex[%u].Processor.Flags: 0x%x\n", i, ex->Processor.Flags);
844#ifndef __REACTOS__
845 trace("infoex[%u].Processor.EfficiencyClass: 0x%x\n", i, ex->Processor.EfficiencyClass);
846#endif
847 trace("infoex[%u].Processor.GroupCount: 0x%x\n", i, ex->Processor.GroupCount);
848 for(j = 0; j < ex->Processor.GroupCount; ++j){
849 trace("infoex[%u].Processor.GroupMask[%u].Mask: 0x%lx\n", i, j, ex->Processor.GroupMask[j].Mask);
850 trace("infoex[%u].Processor.GroupMask[%u].Group: 0x%x\n", i, j, ex->Processor.GroupMask[j].Group);
851 }
852 break;
853 case RelationNumaNode:
854 trace("infoex[%u].Relationship: 0x%x (NumaNode)\n", i, ex->Relationship);
855 trace("infoex[%u].NumaNode.NodeNumber: 0x%x\n", i, ex->NumaNode.NodeNumber);
856 trace("infoex[%u].NumaNode.GroupMask.Mask: 0x%lx\n", i, ex->NumaNode.GroupMask.Mask);
857 trace("infoex[%u].NumaNode.GroupMask.Group: 0x%x\n", i, ex->NumaNode.GroupMask.Group);
858 break;
859 case RelationCache:
860 trace("infoex[%u].Relationship: 0x%x (Cache)\n", i, ex->Relationship);
861 trace("infoex[%u].Cache.Level: 0x%x\n", i, ex->Cache.Level);
862 trace("infoex[%u].Cache.Associativity: 0x%x\n", i, ex->Cache.Associativity);
863 trace("infoex[%u].Cache.LineSize: 0x%x\n", i, ex->Cache.LineSize);
864 trace("infoex[%u].Cache.CacheSize: 0x%x\n", i, ex->Cache.CacheSize);
865 trace("infoex[%u].Cache.Type: 0x%x\n", i, ex->Cache.Type);
866 trace("infoex[%u].Cache.GroupMask.Mask: 0x%lx\n", i, ex->Cache.GroupMask.Mask);
867 trace("infoex[%u].Cache.GroupMask.Group: 0x%x\n", i, ex->Cache.GroupMask.Group);
868 break;
869 case RelationGroup:
870 trace("infoex[%u].Relationship: 0x%x (Group)\n", i, ex->Relationship);
871 trace("infoex[%u].Group.MaximumGroupCount: 0x%x\n", i, ex->Group.MaximumGroupCount);
872 trace("infoex[%u].Group.ActiveGroupCount: 0x%x\n", i, ex->Group.ActiveGroupCount);
873 for(j = 0; j < ex->Group.ActiveGroupCount; ++j){
874 trace("infoex[%u].Group.GroupInfo[%u].MaximumProcessorCount: 0x%x\n", i, j, ex->Group.GroupInfo[j].MaximumProcessorCount);
875 trace("infoex[%u].Group.GroupInfo[%u].ActiveProcessorCount: 0x%x\n", i, j, ex->Group.GroupInfo[j].ActiveProcessorCount);
876 trace("infoex[%u].Group.GroupInfo[%u].ActiveProcessorMask: 0x%lx\n", i, j, ex->Group.GroupInfo[j].ActiveProcessorMask);
877 }
878 break;
879 default:
880 break;
881 }
882
883 i += ex->Size;
884 }
885
886 HeapFree(GetProcessHeap(), 0, infoex);
887 HeapFree(GetProcessHeap(), 0, infoex2);
888 }
889}
890
892{
895 ULONG size;
896 SYSTEM_INFO si;
897 int i;
898
899 GetSystemInfo(&si);
901 ppi = HeapAlloc(GetProcessHeap(), 0, size);
902
903 /* If size < (sizeof(PROCESSOR_POWER_INFORMATION) * NumberOfProcessors), Win7 returns
904 * STATUS_BUFFER_TOO_SMALL. WinXP returns STATUS_SUCCESS for any value of size. It copies as
905 * many whole PROCESSOR_POWER_INFORMATION structures that there is room for. Even if there is
906 * not enough room for one structure, WinXP still returns STATUS_SUCCESS having done nothing.
907 *
908 * If ppi == NULL, Win7 returns STATUS_INVALID_PARAMETER while WinXP returns STATUS_SUCCESS
909 * and does nothing.
910 *
911 * The same behavior is seen with CallNtPowerInformation (in powrprof.dll).
912 */
913
914 if (si.dwNumberOfProcessors > 1)
915 {
916 for(i = 0; i < si.dwNumberOfProcessors; i++)
917 ppi[i].Number = 0xDEADBEEF;
918
919 /* Call with a buffer size that is large enough to hold at least one but not large
920 * enough to hold them all. This will be STATUS_SUCCESS on WinXP but not on Win7 */
921 status = pNtPowerInformation(ProcessorInformation, 0, 0, ppi, size - sizeof(PROCESSOR_POWER_INFORMATION));
922 if (status == STATUS_SUCCESS)
923 {
924 /* lax version found on older Windows like WinXP */
925 ok( (ppi[si.dwNumberOfProcessors - 2].Number != 0xDEADBEEF) &&
926 (ppi[si.dwNumberOfProcessors - 1].Number == 0xDEADBEEF),
927 "Expected all but the last record to be overwritten.\n");
928
929 status = pNtPowerInformation(ProcessorInformation, 0, 0, 0, size);
930 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
931
932 for(i = 0; i < si.dwNumberOfProcessors; i++)
933 ppi[i].Number = 0xDEADBEEF;
934 status = pNtPowerInformation(ProcessorInformation, 0, 0, ppi, sizeof(PROCESSOR_POWER_INFORMATION) - 1);
935 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
936 for(i = 0; i < si.dwNumberOfProcessors; i++)
937 if (ppi[i].Number != 0xDEADBEEF) break;
938 ok( i == si.dwNumberOfProcessors, "Expected untouched buffer\n");
939 }
940 else
941 {
942 /* picky version found on newer Windows like Win7 */
943 ok( ppi[1].Number == 0xDEADBEEF, "Expected untouched buffer.\n");
944 ok( status == STATUS_BUFFER_TOO_SMALL, "Expected STATUS_BUFFER_TOO_SMALL, got %08x\n", status);
945
946 status = pNtPowerInformation(ProcessorInformation, 0, 0, 0, size);
948
949 status = pNtPowerInformation(ProcessorInformation, 0, 0, ppi, 0);
951 }
952 }
953 else
954 {
955 skip("Test needs more than one processor.\n");
956 }
957
958 status = pNtPowerInformation(ProcessorInformation, 0, 0, ppi, size);
959 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
960
961 HeapFree(GetProcessHeap(), 0, ppi);
962}
963
965{
968 ULONG_PTR pbi[2], dummy;
969
970 memset(&dummy, 0xcc, sizeof(dummy));
971
972 /* Do not give a handle and buffer */
973 status = pNtQueryInformationProcess(NULL, ProcessWow64Information, NULL, 0, NULL);
974 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
975
976 /* Use a correct info class and buffer size, but still no handle and buffer */
977 status = pNtQueryInformationProcess(NULL, ProcessWow64Information, NULL, sizeof(ULONG_PTR), NULL);
979 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE, got %08x\n", status);
980
981 /* Use a correct info class, buffer size and handle, but no buffer */
982 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessWow64Information, NULL, sizeof(ULONG_PTR), NULL);
983 ok( status == STATUS_ACCESS_VIOLATION , "Expected STATUS_ACCESS_VIOLATION, got %08x\n", status);
984
985 /* Use a correct info class, buffer and buffer size, but no handle */
986 pbi[0] = pbi[1] = dummy;
987 status = pNtQueryInformationProcess(NULL, ProcessWow64Information, pbi, sizeof(ULONG_PTR), NULL);
988 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
989 ok( pbi[0] == dummy, "pbi[0] changed to %lx\n", pbi[0]);
990 ok( pbi[1] == dummy, "pbi[1] changed to %lx\n", pbi[1]);
991
992 /* Use a greater buffer size */
993 pbi[0] = pbi[1] = dummy;
994 status = pNtQueryInformationProcess(NULL, ProcessWow64Information, pbi, sizeof(ULONG_PTR) + 1, NULL);
995 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
996 ok( pbi[0] == dummy, "pbi[0] changed to %lx\n", pbi[0]);
997 ok( pbi[1] == dummy, "pbi[1] changed to %lx\n", pbi[1]);
998
999 /* Use no ReturnLength */
1000 pbi[0] = pbi[1] = dummy;
1001 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessWow64Information, pbi, sizeof(ULONG_PTR), NULL);
1002 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1003 trace( "Platform is_wow64 %d, ProcessInformation of ProcessWow64Information %lx\n", is_wow64, pbi[0]);
1004 ok( is_wow64 == (pbi[0] != 0), "is_wow64 %x, pbi[0] %lx\n", is_wow64, pbi[0]);
1005 ok( pbi[0] != dummy, "pbi[0] %lx\n", pbi[0]);
1006 ok( pbi[1] == dummy, "pbi[1] changed to %lx\n", pbi[1]);
1007 /* Test written size on 64 bit by checking high 32 bit buffer */
1008 if (sizeof(ULONG_PTR) > sizeof(DWORD))
1009 {
1010 DWORD *ptr = (DWORD *)pbi;
1011 ok( ptr[1] != (DWORD)dummy, "ptr[1] unchanged!\n");
1012 }
1013
1014 /* Finally some correct calls */
1015 pbi[0] = pbi[1] = dummy;
1016 ReturnLength = 0xdeadbeef;
1017 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessWow64Information, pbi, sizeof(ULONG_PTR), &ReturnLength);
1018 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1019 ok( is_wow64 == (pbi[0] != 0), "is_wow64 %x, pbi[0] %lx\n", is_wow64, pbi[0]);
1020 ok( pbi[1] == dummy, "pbi[1] changed to %lx\n", pbi[1]);
1021 ok( ReturnLength == sizeof(ULONG_PTR), "Inconsistent length %d\n", ReturnLength);
1022
1023 /* Everything is correct except a too small buffer size */
1024 pbi[0] = pbi[1] = dummy;
1025 ReturnLength = 0xdeadbeef;
1026 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessWow64Information, pbi, sizeof(ULONG_PTR) - 1, &ReturnLength);
1027 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1028 ok( pbi[0] == dummy, "pbi[0] changed to %lx\n", pbi[0]);
1029 ok( pbi[1] == dummy, "pbi[1] changed to %lx\n", pbi[1]);
1030 todo_wine ok( ReturnLength == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", ReturnLength);
1031
1032 /* Everything is correct except a too large buffer size */
1033 pbi[0] = pbi[1] = dummy;
1034 ReturnLength = 0xdeadbeef;
1035 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessWow64Information, pbi, sizeof(ULONG_PTR) + 1, &ReturnLength);
1036 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1037 ok( pbi[0] == dummy, "pbi[0] changed to %lx\n", pbi[0]);
1038 ok( pbi[1] == dummy, "pbi[1] changed to %lx\n", pbi[1]);
1039 todo_wine ok( ReturnLength == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", ReturnLength);
1040}
1041
1043{
1046
1047 typedef struct _PROCESS_BASIC_INFORMATION_PRIVATE {
1049 PPEB PebBaseAddress;
1050 DWORD_PTR AffinityMask;
1051 DWORD_PTR BasePriority;
1052 ULONG_PTR UniqueProcessId;
1053 ULONG_PTR InheritedFromUniqueProcessId;
1055
1057
1058 /* This test also covers some basic parameter testing that should be the same for
1059 * every information class
1060 */
1061
1062 /* Use a nonexistent info class */
1063 trace("Check nonexistent info class\n");
1064 status = pNtQueryInformationProcess(NULL, -1, NULL, 0, NULL);
1066 "Expected STATUS_INVALID_INFO_CLASS or STATUS_NOT_IMPLEMENTED, got %08x\n", status);
1067
1068 /* Do not give a handle and buffer */
1069 trace("Check NULL handle and buffer and zero-length buffersize\n");
1070 status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, NULL, 0, NULL);
1071 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1072
1073 /* Use a correct info class and buffer size, but still no handle and buffer */
1074 trace("Check NULL handle and buffer\n");
1075 status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, NULL, sizeof(pbi), NULL);
1077 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08x\n", status);
1078
1079 /* Use a correct info class and buffer size, but still no handle */
1080 trace("Check NULL handle\n");
1081 status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
1082 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
1083
1084 /* Use a greater buffer size */
1085 trace("Check NULL handle and too large buffersize\n");
1086 status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, &pbi, sizeof(pbi) * 2, NULL);
1087 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1088
1089 /* Use no ReturnLength */
1090 trace("Check NULL ReturnLength\n");
1091 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
1092 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1093
1094 /* Finally some correct calls */
1095 trace("Check with correct parameters\n");
1096 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), &ReturnLength);
1097 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1098 ok( sizeof(pbi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
1099
1100 /* Everything is correct except a too large buffersize */
1101 trace("Too large buffersize\n");
1102 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi) * 2, &ReturnLength);
1103 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1104 ok( sizeof(pbi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
1105
1106 /* Check if we have some return values */
1107 trace("ProcessID : %lx\n", pbi.UniqueProcessId);
1108 ok( pbi.UniqueProcessId > 0, "Expected a ProcessID > 0, got 0\n");
1109}
1110
1111static void dump_vm_counters(const char *header, const VM_COUNTERS *pvi)
1112{
1113 trace("%s:\n", header);
1114 trace("PeakVirtualSize : %lu\n", pvi->PeakVirtualSize);
1115 trace("VirtualSize : %lu\n", pvi->VirtualSize);
1116 trace("PageFaultCount : %u\n", pvi->PageFaultCount);
1117 trace("PeakWorkingSetSize : %lu\n", pvi->PeakWorkingSetSize);
1118 trace("WorkingSetSize : %lu\n", pvi->WorkingSetSize);
1119 trace("QuotaPeakPagedPoolUsage : %lu\n", pvi->QuotaPeakPagedPoolUsage);
1120 trace("QuotaPagedPoolUsage : %lu\n", pvi->QuotaPagedPoolUsage);
1121 trace("QuotaPeakNonPagePoolUsage : %lu\n", pvi->QuotaPeakNonPagedPoolUsage);
1122 trace("QuotaNonPagePoolUsage : %lu\n", pvi->QuotaNonPagedPoolUsage);
1123 trace("PagefileUsage : %lu\n", pvi->PagefileUsage);
1124 trace("PeakPagefileUsage : %lu\n", pvi->PeakPagefileUsage);
1125}
1126
1127static void test_query_process_vm(void)
1128{
1131 VM_COUNTERS pvi;
1132#ifndef __REACTOS__
1133 ULONG old_size = FIELD_OFFSET(VM_COUNTERS,PrivatePageCount);
1134#endif
1136 SIZE_T prev_size;
1137 const SIZE_T alloc_size = 16 * 1024 * 1024;
1138 void *ptr;
1139
1140 status = pNtQueryInformationProcess(NULL, ProcessVmCounters, NULL, sizeof(pvi), NULL);
1142 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08x\n", status);
1143
1144#ifndef __REACTOS__
1145 status = pNtQueryInformationProcess(NULL, ProcessVmCounters, &pvi, old_size, NULL);
1146 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
1147#endif
1148
1149 /* Windows XP and W2K3 will report success for a size of 44 AND 48 !
1150 Windows W2K will only report success for 44.
1151 For now we only care for 44, which is FIELD_OFFSET(VM_COUNTERS,PrivatePageCount))
1152 */
1153
1154 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, 24, &ReturnLength);
1155 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1156
1157#ifndef __REACTOS__
1158 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, old_size, &ReturnLength);
1159 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1160 ok( old_size == ReturnLength, "Inconsistent length %d\n", ReturnLength);
1161#endif
1162
1163 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, 46, &ReturnLength);
1164 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1165#ifndef __REACTOS__
1166 ok( ReturnLength == old_size || ReturnLength == sizeof(pvi), "Inconsistent length %d\n", ReturnLength);
1167#endif
1168
1169 /* Check if we have some return values */
1170 dump_vm_counters("VM counters for GetCurrentProcess", &pvi);
1171 ok( pvi.WorkingSetSize > 0, "Expected a WorkingSetSize > 0\n");
1172 ok( pvi.PagefileUsage > 0, "Expected a PagefileUsage > 0\n");
1173
1175 status = pNtQueryInformationProcess(process, ProcessVmCounters, &pvi, sizeof(pvi), NULL);
1176 ok( status == STATUS_ACCESS_DENIED, "Expected STATUS_ACCESS_DENIED, got %08x\n", status);
1178
1180 status = pNtQueryInformationProcess(process, ProcessVmCounters, &pvi, sizeof(pvi), NULL);
1181 ok( status == STATUS_SUCCESS || broken(!process) /* XP */, "Expected STATUS_SUCCESS, got %08x\n", status);
1183
1184 memset(&pvi, 0, sizeof(pvi));
1186 status = pNtQueryInformationProcess(process, ProcessVmCounters, &pvi, sizeof(pvi), NULL);
1187 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1188
1189 /* Check if we have some return values */
1190 dump_vm_counters("VM counters for GetCurrentProcessId", &pvi);
1191 ok( pvi.WorkingSetSize > 0, "Expected a WorkingSetSize > 0\n");
1192 ok( pvi.PagefileUsage > 0, "Expected a PagefileUsage > 0\n");
1193
1195
1196 /* Check if we have real counters */
1197 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL);
1198 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1199 prev_size = pvi.VirtualSize;
1200 if (winetest_debug > 1)
1201 dump_vm_counters("VM counters before VirtualAlloc", &pvi);
1203 ok( ptr != NULL, "VirtualAlloc failed, err %u\n", GetLastError());
1204 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL);
1205 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1206 if (winetest_debug > 1)
1207 dump_vm_counters("VM counters after VirtualAlloc", &pvi);
1208 todo_wine ok( pvi.VirtualSize >= prev_size + alloc_size,
1209 "Expected to be greater than %lu, got %lu\n", prev_size + alloc_size, pvi.VirtualSize);
1211
1212 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL);
1213 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1214 prev_size = pvi.VirtualSize;
1215 if (winetest_debug > 1)
1216 dump_vm_counters("VM counters before VirtualAlloc", &pvi);
1218 ok( ptr != NULL, "VirtualAlloc failed, err %u\n", GetLastError());
1219 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL);
1220 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1221 if (winetest_debug > 1)
1222 dump_vm_counters("VM counters after VirtualAlloc(MEM_RESERVE)", &pvi);
1223 todo_wine ok( pvi.VirtualSize >= prev_size + alloc_size,
1224 "Expected to be greater than %lu, got %lu\n", prev_size + alloc_size, pvi.VirtualSize);
1225 prev_size = pvi.VirtualSize;
1226
1227 ptr = VirtualAlloc(ptr, alloc_size, MEM_COMMIT, PAGE_READWRITE);
1228 ok( ptr != NULL, "VirtualAlloc failed, err %u\n", GetLastError());
1229 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL);
1230 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1231 if (winetest_debug > 1)
1232 dump_vm_counters("VM counters after VirtualAlloc(MEM_COMMIT)", &pvi);
1233 ok( pvi.VirtualSize == prev_size,
1234 "Expected to equal to %lu, got %lu\n", prev_size, pvi.VirtualSize);
1236}
1237
1238static void test_query_process_io(void)
1239{
1242 IO_COUNTERS pii;
1243
1244 /* NT4 doesn't support this information class, so check for it */
1245 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, sizeof(pii), &ReturnLength);
1247 {
1248 win_skip("ProcessIoCounters information class is not supported\n");
1249 return;
1250 }
1251
1252 status = pNtQueryInformationProcess(NULL, ProcessIoCounters, NULL, sizeof(pii), NULL);
1254 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08x\n", status);
1255
1256 status = pNtQueryInformationProcess(NULL, ProcessIoCounters, &pii, sizeof(pii), NULL);
1257 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
1258
1259 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, 24, &ReturnLength);
1260 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1261
1262 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, sizeof(pii), &ReturnLength);
1263 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1264 ok( sizeof(pii) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
1265
1266 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, sizeof(pii) * 2, &ReturnLength);
1267 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1268 ok( sizeof(pii) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
1269
1270 /* Check if we have some return values */
1271 trace("OtherOperationCount : 0x%s\n", wine_dbgstr_longlong(pii.OtherOperationCount));
1272 todo_wine
1273 {
1274 ok( pii.OtherOperationCount > 0, "Expected an OtherOperationCount > 0\n");
1275 }
1276}
1277
1279{
1283 SYSTEMTIME UTC, Local;
1284 KERNEL_USER_TIMES spti;
1285
1286 status = pNtQueryInformationProcess(NULL, ProcessTimes, NULL, sizeof(spti), NULL);
1288 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08x\n", status);
1289
1290 status = pNtQueryInformationProcess(NULL, ProcessTimes, &spti, sizeof(spti), NULL);
1291 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
1292
1293 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessTimes, &spti, 24, &ReturnLength);
1294 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1295
1297 if (!process)
1298 {
1299 trace("Could not open process with ID : %d, error : %u. Going to use current one.\n", one_before_last_pid, GetLastError());
1301 trace("ProcessTimes for current process\n");
1302 }
1303 else
1304 trace("ProcessTimes for process with ID : %d\n", one_before_last_pid);
1305
1306 status = pNtQueryInformationProcess( process, ProcessTimes, &spti, sizeof(spti), &ReturnLength);
1307 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1308 ok( sizeof(spti) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
1310
1311 FileTimeToSystemTime((const FILETIME *)&spti.CreateTime, &UTC);
1313 trace("CreateTime : %02d/%02d/%04d %02d:%02d:%02d\n", Local.wMonth, Local.wDay, Local.wYear,
1314 Local.wHour, Local.wMinute, Local.wSecond);
1315
1316 FileTimeToSystemTime((const FILETIME *)&spti.ExitTime, &UTC);
1318 trace("ExitTime : %02d/%02d/%04d %02d:%02d:%02d\n", Local.wMonth, Local.wDay, Local.wYear,
1319 Local.wHour, Local.wMinute, Local.wSecond);
1320
1321 FileTimeToSystemTime((const FILETIME *)&spti.KernelTime, &Local);
1322 trace("KernelTime : %02d:%02d:%02d.%03d\n", Local.wHour, Local.wMinute, Local.wSecond, Local.wMilliseconds);
1323
1324 FileTimeToSystemTime((const FILETIME *)&spti.UserTime, &Local);
1325 trace("UserTime : %02d:%02d:%02d.%03d\n", Local.wHour, Local.wMinute, Local.wSecond, Local.wMilliseconds);
1326
1327 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessTimes, &spti, sizeof(spti) * 2, &ReturnLength);
1328 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1329 ok( sizeof(spti) == ReturnLength ||
1330 ReturnLength == 0 /* vista */ ||
1331 broken(is_wow64), /* returns garbage on wow64 */
1332 "Inconsistent length %d\n", ReturnLength);
1333}
1334
1336{
1337 DWORD_PTR debug_port = 0xdeadbeef;
1338 char cmdline[MAX_PATH];
1340 STARTUPINFOA si = { 0 };
1342 BOOL ret;
1343
1344 sprintf(cmdline, "%s %s %s", argv[0], argv[1], "debuggee");
1345
1346 si.cb = sizeof(si);
1348 ok(ret, "CreateProcess failed, last error %#x.\n", GetLastError());
1349 if (!ret) return;
1350
1351 status = pNtQueryInformationProcess(NULL, ProcessDebugPort,
1352 NULL, 0, NULL);
1353 ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %#x.\n", status);
1354
1355 status = pNtQueryInformationProcess(NULL, ProcessDebugPort,
1356 NULL, sizeof(debug_port), NULL);
1358 "Expected STATUS_INVALID_HANDLE, got %#x.\n", status);
1359
1360 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugPort,
1361 NULL, sizeof(debug_port), NULL);
1362 ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %#x.\n", status);
1363
1364 status = pNtQueryInformationProcess(NULL, ProcessDebugPort,
1365 &debug_port, sizeof(debug_port), NULL);
1366 ok(status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %#x.\n", status);
1367
1368 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugPort,
1369 &debug_port, sizeof(debug_port) - 1, NULL);
1370 ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %#x.\n", status);
1371
1372 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugPort,
1373 &debug_port, sizeof(debug_port) + 1, NULL);
1374 ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %#x.\n", status);
1375
1376 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugPort,
1377 &debug_port, sizeof(debug_port), NULL);
1378 ok(!status, "NtQueryInformationProcess failed, status %#x.\n", status);
1379 ok(debug_port == 0, "Expected port 0, got %#lx.\n", debug_port);
1380
1381 status = pNtQueryInformationProcess(pi.hProcess, ProcessDebugPort,
1382 &debug_port, sizeof(debug_port), NULL);
1383 ok(!status, "NtQueryInformationProcess failed, status %#x.\n", status);
1384 ok(debug_port == ~(DWORD_PTR)0, "Expected port %#lx, got %#lx.\n", ~(DWORD_PTR)0, debug_port);
1385
1386 for (;;)
1387 {
1388 DEBUG_EVENT ev;
1389
1391 ok(ret, "WaitForDebugEvent failed, last error %#x.\n", GetLastError());
1392 if (!ret) break;
1393
1395
1397 ok(ret, "ContinueDebugEvent failed, last error %#x.\n", GetLastError());
1398 if (!ret) break;
1399 }
1400
1401 ret = CloseHandle(pi.hThread);
1402 ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
1403 ret = CloseHandle(pi.hProcess);
1404 ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
1405}
1406
1408{
1411 DWORD orig_priority;
1413 BOOL ret;
1414
1415 status = pNtQueryInformationProcess(NULL, ProcessPriorityClass, NULL, sizeof(priority[0]), NULL);
1417 "Expected STATUS_ACCESS_VIOLATION, got %08x\n", status);
1418
1419 status = pNtQueryInformationProcess(NULL, ProcessPriorityClass, &priority, sizeof(priority[0]), NULL);
1420 ok(status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
1421
1422 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessPriorityClass, &priority, 1, &ReturnLength);
1423 ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1424
1425 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessPriorityClass, &priority, sizeof(priority), &ReturnLength);
1426 ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1427
1428 orig_priority = GetPriorityClass(GetCurrentProcess());
1430 ok(ret, "Failed to set priority class: %u\n", GetLastError());
1431
1432 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessPriorityClass, &priority, sizeof(priority[0]), &ReturnLength);
1433 ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1434 ok(priority[0].PriorityClass == PROCESS_PRIOCLASS_BELOW_NORMAL,
1435 "Expected PROCESS_PRIOCLASS_BELOW_NORMAL, got %u\n", priority[0].PriorityClass);
1436
1437 ret = SetPriorityClass(GetCurrentProcess(), orig_priority);
1438 ok(ret, "Failed to reset priority class: %u\n", GetLastError());
1439}
1440
1442{
1445 DWORD handlecount;
1446 BYTE buffer[2 * sizeof(DWORD)];
1448
1449 status = pNtQueryInformationProcess(NULL, ProcessHandleCount, NULL, sizeof(handlecount), NULL);
1451 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08x\n", status);
1452
1453 status = pNtQueryInformationProcess(NULL, ProcessHandleCount, &handlecount, sizeof(handlecount), NULL);
1454 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
1455
1456 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessHandleCount, &handlecount, 2, &ReturnLength);
1457 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1458
1460 if (!process)
1461 {
1462 trace("Could not open process with ID : %d, error : %u. Going to use current one.\n", one_before_last_pid, GetLastError());
1464 trace("ProcessHandleCount for current process\n");
1465 }
1466 else
1467 trace("ProcessHandleCount for process with ID : %d\n", one_before_last_pid);
1468
1469 status = pNtQueryInformationProcess( process, ProcessHandleCount, &handlecount, sizeof(handlecount), &ReturnLength);
1470 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1471 ok( sizeof(handlecount) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
1473
1474 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessHandleCount, buffer, sizeof(buffer), &ReturnLength);
1476 "Expected STATUS_INFO_LENGTH_MISMATCH or STATUS_SUCCESS, got %08x\n", status);
1477 ok( sizeof(handlecount) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
1478
1479 /* Check if we have some return values */
1480 trace("HandleCount : %d\n", handlecount);
1481 todo_wine
1482 {
1483 ok( handlecount > 0, "Expected some handles, got 0\n");
1484 }
1485}
1486
1488{
1491 UNICODE_STRING image_file_name;
1492 void *buffer;
1493 char *file_nameA;
1494 INT len;
1495
1496 status = pNtQueryInformationProcess(NULL, ProcessImageFileName, &image_file_name, sizeof(image_file_name), NULL);
1498 {
1499 win_skip("ProcessImageFileName is not supported\n");
1500 return;
1501 }
1502 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
1503
1504 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, &image_file_name, 2, &ReturnLength);
1505 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1506
1507 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, &image_file_name, sizeof(image_file_name), &ReturnLength);
1508 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1509
1511 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, buffer, ReturnLength, &ReturnLength);
1512 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1513 memcpy(&image_file_name, buffer, sizeof(image_file_name));
1514 len = WideCharToMultiByte(CP_ACP, 0, image_file_name.Buffer, image_file_name.Length/sizeof(WCHAR), NULL, 0, NULL, NULL);
1516 WideCharToMultiByte(CP_ACP, 0, image_file_name.Buffer, image_file_name.Length/sizeof(WCHAR), file_nameA, len, NULL, NULL);
1517 file_nameA[len] = '\0';
1519 trace("process image file name: %s\n", file_nameA);
1520 todo_wine ok(strncmp(file_nameA, "\\Device\\", 8) == 0, "Process image name should be an NT path beginning with \\Device\\ (is %s)\n", file_nameA);
1522}
1523
1525{
1526 char cmdline[MAX_PATH];
1527 STARTUPINFOA si = {0};
1529 BOOL ret;
1530 HANDLE debug_object;
1532
1533 sprintf(cmdline, "%s %s %s", argv[0], argv[1], "debuggee");
1534
1535 si.cb = sizeof(si);
1537 NULL, &si, &pi);
1538 ok(ret, "CreateProcess failed with last error %u\n", GetLastError());
1539 if (!ret) return;
1540
1541 status = pNtQueryInformationProcess(NULL, ProcessDebugObjectHandle, NULL,
1542 0, NULL);
1544 {
1545 win_skip("ProcessDebugObjectHandle is not supported\n");
1546 return;
1547 }
1549 "Expected NtQueryInformationProcess to return STATUS_INFO_LENGTH_MISMATCH, got 0x%08x\n",
1550 status);
1551
1552 status = pNtQueryInformationProcess(NULL, ProcessDebugObjectHandle, NULL,
1553 sizeof(debug_object), NULL);
1555 status == STATUS_ACCESS_VIOLATION, /* XP */
1556 "Expected NtQueryInformationProcess to return STATUS_INVALID_HANDLE, got 0x%08x\n", status);
1557
1558 status = pNtQueryInformationProcess(GetCurrentProcess(),
1559 ProcessDebugObjectHandle, NULL, sizeof(debug_object), NULL);
1561 "Expected NtQueryInformationProcess to return STATUS_ACCESS_VIOLATION, got 0x%08x\n", status);
1562
1563 status = pNtQueryInformationProcess(NULL, ProcessDebugObjectHandle,
1564 &debug_object, sizeof(debug_object), NULL);
1566 "Expected NtQueryInformationProcess to return STATUS_ACCESS_VIOLATION, got 0x%08x\n", status);
1567
1568 status = pNtQueryInformationProcess(GetCurrentProcess(),
1569 ProcessDebugObjectHandle, &debug_object,
1570 sizeof(debug_object) - 1, NULL);
1572 "Expected NtQueryInformationProcess to return STATUS_INFO_LENGTH_MISMATCH, got 0x%08x\n", status);
1573
1574 status = pNtQueryInformationProcess(GetCurrentProcess(),
1575 ProcessDebugObjectHandle, &debug_object,
1576 sizeof(debug_object) + 1, NULL);
1578 "Expected NtQueryInformationProcess to return STATUS_INFO_LENGTH_MISMATCH, got 0x%08x\n", status);
1579
1580 debug_object = (HANDLE)0xdeadbeef;
1581 status = pNtQueryInformationProcess(GetCurrentProcess(),
1582 ProcessDebugObjectHandle, &debug_object,
1583 sizeof(debug_object), NULL);
1585 "Expected NtQueryInformationProcess to return STATUS_PORT_NOT_SET, got 0x%08x\n", status);
1586 ok(debug_object == NULL ||
1587 broken(debug_object == (HANDLE)0xdeadbeef), /* Wow64 */
1588 "Expected debug object handle to be NULL, got %p\n", debug_object);
1589
1590 debug_object = (HANDLE)0xdeadbeef;
1591 status = pNtQueryInformationProcess(pi.hProcess, ProcessDebugObjectHandle,
1592 &debug_object, sizeof(debug_object), NULL);
1593#ifndef __REACTOS__
1594 todo_wine
1595#endif
1597 "Expected NtQueryInformationProcess to return STATUS_SUCCESS, got 0x%08x\n", status);
1598#ifndef __REACTOS__
1599 todo_wine
1600#endif
1601 ok(debug_object != NULL,
1602 "Expected debug object handle to be non-NULL, got %p\n", debug_object);
1603#ifdef __REACTOS__
1604 status = NtClose( debug_object );
1605 ok( !status, "NtClose failed %x\n", status );
1606#endif
1607
1608 for (;;)
1609 {
1610 DEBUG_EVENT ev;
1611
1613 ok(ret, "WaitForDebugEvent failed with last error %u\n", GetLastError());
1614 if (!ret) break;
1615
1617
1619 ok(ret, "ContinueDebugEvent failed with last error %u\n", GetLastError());
1620 if (!ret) break;
1621 }
1622
1623 ret = CloseHandle(pi.hThread);
1624 ok(ret, "CloseHandle failed with last error %u\n", GetLastError());
1625 ret = CloseHandle(pi.hProcess);
1626 ok(ret, "CloseHandle failed with last error %u\n", GetLastError());
1627}
1628
1630{
1631 static const DWORD test_flags[] = { DEBUG_PROCESS,
1635 DWORD debug_flags = 0xdeadbeef;
1636 char cmdline[MAX_PATH];
1638 STARTUPINFOA si = { 0 };
1640 DEBUG_EVENT ev;
1641 DWORD result;
1642 BOOL ret;
1643 int i, j;
1644
1645 /* test invalid arguments */
1646 status = pNtQueryInformationProcess(NULL, ProcessDebugFlags, NULL, 0, NULL);
1648 "Expected STATUS_INFO_LENGTH_MISMATCH, got %#x.\n", status);
1649
1650 status = pNtQueryInformationProcess(NULL, ProcessDebugFlags, NULL, sizeof(debug_flags), NULL);
1652 "Expected STATUS_INVALID_HANDLE, got %#x.\n", status);
1653
1654 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugFlags,
1655 NULL, sizeof(debug_flags), NULL);
1656 ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %#x.\n", status);
1657
1658 status = pNtQueryInformationProcess(NULL, ProcessDebugFlags,
1659 &debug_flags, sizeof(debug_flags), NULL);
1661 "Expected STATUS_INVALID_HANDLE, got %#x.\n", status);
1662
1663 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugFlags,
1664 &debug_flags, sizeof(debug_flags) - 1, NULL);
1665 ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %#x.\n", status);
1666
1667 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugFlags,
1668 &debug_flags, sizeof(debug_flags) + 1, NULL);
1669 ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %#x.\n", status);
1670
1671 /* test ProcessDebugFlags of current process */
1672 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugFlags,
1673 &debug_flags, sizeof(debug_flags), NULL);
1674 ok(!status, "NtQueryInformationProcess failed, status %#x.\n", status);
1675 ok(debug_flags == TRUE, "Expected flag TRUE, got %x.\n", debug_flags);
1676
1677 for (i = 0; i < sizeof(test_flags)/sizeof(test_flags[0]); i++)
1678 {
1679 DWORD expected_flags = !(test_flags[i] & DEBUG_ONLY_THIS_PROCESS);
1680 sprintf(cmdline, "%s %s %s", argv[0], argv[1], "debuggee");
1681
1682 si.cb = sizeof(si);
1683 ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, test_flags[i], NULL, NULL, &si, &pi);
1684 ok(ret, "CreateProcess failed, last error %#x.\n", GetLastError());
1685
1686 if (!(test_flags[i] & (DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS)))
1687 {
1688 /* test ProcessDebugFlags before attaching with debugger */
1689 status = pNtQueryInformationProcess(pi.hProcess, ProcessDebugFlags,
1690 &debug_flags, sizeof(debug_flags), NULL);
1691 ok(!status, "NtQueryInformationProcess failed, status %#x.\n", status);
1692 ok(debug_flags == TRUE, "Expected flag TRUE, got %x.\n", debug_flags);
1693
1694 ret = DebugActiveProcess(pi.dwProcessId);
1695 ok(ret, "DebugActiveProcess failed, last error %#x.\n", GetLastError());
1696 expected_flags = FALSE;
1697 }
1698
1699 /* test ProcessDebugFlags after attaching with debugger */
1700 status = pNtQueryInformationProcess(pi.hProcess, ProcessDebugFlags,
1701 &debug_flags, sizeof(debug_flags), NULL);
1702 ok(!status, "NtQueryInformationProcess failed, status %#x.\n", status);
1703 ok(debug_flags == expected_flags, "Expected flag %x, got %x.\n", expected_flags, debug_flags);
1704
1705 if (!(test_flags[i] & CREATE_SUSPENDED))
1706 {
1707 /* Continue a couple of times to make sure the process is fully initialized,
1708 * otherwise Windows XP deadlocks in the following DebugActiveProcess(). */
1709 for (;;)
1710 {
1711 ret = WaitForDebugEvent(&ev, 1000);
1713 ok(ret, "WaitForDebugEvent failed, last error %#x.\n", GetLastError());
1714 if (!ret) break;
1715
1716 if (ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT) break;
1717
1720 ok(ret, "ContinueDebugEvent failed, last error %#x.\n", GetLastError());
1721 if (!ret) break;
1722 }
1723
1724 result = SuspendThread(pi.hThread);
1725 ok(result == 0, "Expected 0, got %u.\n", result);
1726 }
1727
1728 ret = DebugActiveProcessStop(pi.dwProcessId);
1729 ok(ret, "DebugActiveProcessStop failed, last error %#x.\n", GetLastError());
1730
1731 /* test ProcessDebugFlags after detaching debugger */
1732 status = pNtQueryInformationProcess(pi.hProcess, ProcessDebugFlags,
1733 &debug_flags, sizeof(debug_flags), NULL);
1734 ok(!status, "NtQueryInformationProcess failed, status %#x.\n", status);
1735 ok(debug_flags == expected_flags, "Expected flag %x, got %x.\n", expected_flags, debug_flags);
1736
1737 ret = DebugActiveProcess(pi.dwProcessId);
1738 ok(ret, "DebugActiveProcess failed, last error %#x.\n", GetLastError());
1739
1740 /* test ProcessDebugFlags after re-attaching debugger */
1741 status = pNtQueryInformationProcess(pi.hProcess, ProcessDebugFlags,
1742 &debug_flags, sizeof(debug_flags), NULL);
1743 ok(!status, "NtQueryInformationProcess failed, status %#x.\n", status);
1744 ok(debug_flags == FALSE, "Expected flag FALSE, got %x.\n", debug_flags);
1745
1746 result = ResumeThread(pi.hThread);
1747 todo_wine ok(result == 2, "Expected 2, got %u.\n", result);
1748
1749 /* Wait until the process is terminated. On Windows XP the process randomly
1750 * gets stuck in a non-continuable exception, so stop after 100 iterations.
1751 * On Windows 2003, the debugged process disappears (or stops?) without
1752 * any EXIT_PROCESS_DEBUG_EVENT after a couple of events. */
1753 for (j = 0; j < 100; j++)
1754 {
1755 ret = WaitForDebugEvent(&ev, 1000);
1758 "WaitForDebugEvent failed, last error %#x.\n", GetLastError());
1759 if (!ret) break;
1760
1762
1765 ok(ret, "ContinueDebugEvent failed, last error %#x.\n", GetLastError());
1766 if (!ret) break;
1767 }
1768 ok(j < 100 || broken(j >= 100) /* Win XP */, "Expected less than 100 debug events.\n");
1769
1770 /* test ProcessDebugFlags after process has terminated */
1771 status = pNtQueryInformationProcess(pi.hProcess, ProcessDebugFlags,
1772 &debug_flags, sizeof(debug_flags), NULL);
1773 ok(!status, "NtQueryInformationProcess failed, status %#x.\n", status);
1774 ok(debug_flags == FALSE, "Expected flag FALSE, got %x.\n", debug_flags);
1775
1776 ret = CloseHandle(pi.hThread);
1777 ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
1778 ret = CloseHandle(pi.hProcess);
1779 ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
1780 }
1781}
1782
1783static void test_readvirtualmemory(void)
1784{
1787 SIZE_T readcount;
1788 static const char teststring[] = "test string";
1789 char buffer[12];
1790
1792 ok(process != 0, "Expected to be able to open own process for reading memory\n");
1793
1794 /* normal operation */
1795 status = pNtReadVirtualMemory(process, teststring, buffer, 12, &readcount);
1796 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1797 ok( readcount == 12, "Expected to read 12 bytes, got %ld\n",readcount);
1798 ok( strcmp(teststring, buffer) == 0, "Expected read memory to be the same as original memory\n");
1799
1800 /* no number of bytes */
1801 memset(buffer, 0, 12);
1802 status = pNtReadVirtualMemory(process, teststring, buffer, 12, NULL);
1803 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1804 ok( strcmp(teststring, buffer) == 0, "Expected read memory to be the same as original memory\n");
1805
1806 /* illegal remote address */
1807 todo_wine{
1808 status = pNtReadVirtualMemory(process, (void *) 0x1234, buffer, 12, &readcount);
1809 ok( status == STATUS_PARTIAL_COPY || broken(status == STATUS_ACCESS_VIOLATION), "Expected STATUS_PARTIAL_COPY, got %08x\n", status);
1811 ok( readcount == 0, "Expected to read 0 bytes, got %ld\n",readcount);
1812 }
1813
1814 /* 0 handle */
1815 status = pNtReadVirtualMemory(0, teststring, buffer, 12, &readcount);
1816 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
1817 ok( readcount == 0, "Expected to read 0 bytes, got %ld\n",readcount);
1818
1819 /* pseudo handle for current process*/
1820 memset(buffer, 0, 12);
1821 status = pNtReadVirtualMemory((HANDLE)-1, teststring, buffer, 12, &readcount);
1822 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1823 ok( readcount == 12, "Expected to read 12 bytes, got %ld\n",readcount);
1824 ok( strcmp(teststring, buffer) == 0, "Expected read memory to be the same as original memory\n");
1825
1826 /* illegal local address */
1827 status = pNtReadVirtualMemory(process, teststring, (void *)0x1234, 12, &readcount);
1828 ok( status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", status);
1829 ok( readcount == 0, "Expected to read 0 bytes, got %ld\n",readcount);
1830
1832}
1833
1834static void test_mapprotection(void)
1835{
1836 HANDLE h;
1837 void* addr;
1839 ULONG oldflags, flagsize, flags = MEM_EXECUTE_OPTION_ENABLE;
1842 SIZE_T retlen, count;
1843 void (*f)(void);
1844
1845 if (!pNtClose) {
1846 skip("No NtClose ... Win98\n");
1847 return;
1848 }
1849 /* Switch to being a noexec unaware process */
1850 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &oldflags, sizeof (oldflags), &flagsize);
1852 skip("Invalid Parameter on ProcessExecuteFlags query?\n");
1853 return;
1854 }
1855 ok( (status == STATUS_SUCCESS) || (status == STATUS_INVALID_INFO_CLASS), "Expected STATUS_SUCCESS, got %08x\n", status);
1856 status = pNtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &flags, sizeof(flags) );
1857 ok( (status == STATUS_SUCCESS) || (status == STATUS_INVALID_INFO_CLASS), "Expected STATUS_SUCCESS, got %08x\n", status);
1858
1859 size.u.LowPart = 0x2000;
1860 size.u.HighPart = 0;
1861 status = pNtCreateSection ( &h,
1863 NULL,
1864 &size,
1867 0
1868 );
1869 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1870
1871 offset.u.LowPart = 0;
1872 offset.u.HighPart = 0;
1873 count = 0x2000;
1874 addr = NULL;
1875 status = pNtMapViewOfSection ( h, GetCurrentProcess(), &addr, 0, 0, &offset, &count, ViewShare, 0, PAGE_READWRITE);
1876 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1877
1878#if defined(__x86_64__) || defined(__i386__)
1879 *(unsigned char*)addr = 0xc3; /* lret ... in both i386 and x86_64 */
1880#elif defined(__arm__)
1881 *(unsigned long*)addr = 0xe12fff1e; /* bx lr */
1882#elif defined(__aarch64__)
1883 *(unsigned long*)addr = 0xd65f03c0; /* ret */
1884#else
1885 ok(0, "Add a return opcode for your architecture or expect a crash in this test\n");
1886#endif
1887 trace("trying to execute code in the readwrite only mapped anon file...\n");
1888 f = addr;f();
1889 trace("...done.\n");
1890
1891 status = pNtQueryVirtualMemory( GetCurrentProcess(), addr, MemoryBasicInformation, &info, sizeof(info), &retlen );
1892 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1893 ok( retlen == sizeof(info), "Expected STATUS_SUCCESS, got %08x\n", status);
1894 ok((info.Protect & ~PAGE_NOCACHE) == PAGE_READWRITE, "addr.Protect is not PAGE_READWRITE, but 0x%x\n", info.Protect);
1895
1896 status = pNtUnmapViewOfSection( GetCurrentProcess(), (char *)addr + 0x1050 );
1897 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1898 pNtClose (h);
1899
1900 /* Switch back */
1901 pNtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &oldflags, sizeof(oldflags) );
1902}
1903
1905{
1907 SIZE_T readcount;
1908 static const WCHAR windowsW[] = {'w','i','n','d','o','w','s'};
1909 static const char teststring[] = "test string";
1910 static char datatestbuf[42] = "abc";
1911 static char rwtestbuf[42];
1913 char stackbuf[42];
1915 char buffer_name[sizeof(MEMORY_SECTION_NAME) + MAX_PATH * sizeof(WCHAR)];
1916#ifndef __REACTOS__
1917 MEMORY_SECTION_NAME *msn = (MEMORY_SECTION_NAME *)buffer_name;
1918#endif
1919 BOOL found;
1920 int i;
1921#ifdef __REACTOS__
1922 MEMORY_SECTION_NAME *msn = HeapAlloc(GetProcessHeap(), 0, sizeof(buffer_name));
1923#endif
1924
1925 module = GetModuleHandleA( "ntdll.dll" );
1926 trace("Check flags of the PE header of NTDLL.DLL at %p\n", module);
1927 status = pNtQueryVirtualMemory(NtCurrentProcess(), module, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1928 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1929 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1930 ok (mbi.AllocationBase == module, "mbi.AllocationBase is 0x%p, expected 0x%p\n", mbi.AllocationBase, module);
1931 ok (mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "mbi.AllocationProtect is 0x%x, expected 0x%x\n", mbi.AllocationProtect, PAGE_EXECUTE_WRITECOPY);
1932 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%x\n", mbi.State, MEM_COMMIT);
1933 ok (mbi.Protect == PAGE_READONLY, "mbi.Protect is 0x%x, expected 0x%x\n", mbi.Protect, PAGE_READONLY);
1934 ok (mbi.Type == MEM_IMAGE, "mbi.Type is 0x%x, expected 0x%x\n", mbi.Type, MEM_IMAGE);
1935
1936 trace("Check flags of a function entry in NTDLL.DLL at %p\n", pNtQueryVirtualMemory);
1937 module = GetModuleHandleA( "ntdll.dll" );
1938 status = pNtQueryVirtualMemory(NtCurrentProcess(), pNtQueryVirtualMemory, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1939 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1940 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1941 ok (mbi.AllocationBase == module, "mbi.AllocationBase is 0x%p, expected 0x%p\n", mbi.AllocationBase, module);
1942 ok (mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "mbi.AllocationProtect is 0x%x, expected 0x%x\n", mbi.AllocationProtect, PAGE_EXECUTE_WRITECOPY);
1943 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%x\n", mbi.State, MEM_COMMIT);
1944 ok (mbi.Protect == PAGE_EXECUTE_READ, "mbi.Protect is 0x%x, expected 0x%x\n", mbi.Protect, PAGE_EXECUTE_READ);
1945
1946 trace("Check flags of heap at %p\n", GetProcessHeap());
1947 status = pNtQueryVirtualMemory(NtCurrentProcess(), GetProcessHeap(), MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1948 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1949 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1951 "mbi.AllocationProtect is 0x%x\n", mbi.AllocationProtect);
1952 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%x\n", mbi.State, MEM_COMMIT);
1954 "mbi.Protect is 0x%x\n", mbi.Protect);
1955
1956 trace("Check flags of stack at %p\n", stackbuf);
1957 status = pNtQueryVirtualMemory(NtCurrentProcess(), stackbuf, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1958 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1959 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1960 ok (mbi.AllocationProtect == PAGE_READWRITE, "mbi.AllocationProtect is 0x%x, expected 0x%x\n", mbi.AllocationProtect, PAGE_READWRITE);
1961 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%x\n", mbi.State, MEM_COMMIT);
1962 ok (mbi.Protect == PAGE_READWRITE, "mbi.Protect is 0x%x, expected 0x%x\n", mbi.Protect, PAGE_READWRITE);
1963
1964 trace("Check flags of read-only data at %p\n", teststring);
1966 status = pNtQueryVirtualMemory(NtCurrentProcess(), teststring, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1967 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1968 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1969 ok (mbi.AllocationBase == module, "mbi.AllocationBase is 0x%p, expected 0x%p\n", mbi.AllocationBase, module);
1970 ok (mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "mbi.AllocationProtect is 0x%x, expected 0x%x\n", mbi.AllocationProtect, PAGE_EXECUTE_WRITECOPY);
1971 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%X\n", mbi.State, MEM_COMMIT);
1972 if (mbi.Protect != PAGE_READONLY)
1973 todo_wine ok( mbi.Protect == PAGE_READONLY, "mbi.Protect is 0x%x, expected 0x%X\n", mbi.Protect, PAGE_READONLY);
1974
1975 trace("Check flags of read-write data at %p\n", datatestbuf);
1976 status = pNtQueryVirtualMemory(NtCurrentProcess(), datatestbuf, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1977 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1978 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1979 ok (mbi.AllocationBase == module, "mbi.AllocationBase is 0x%p, expected 0x%p\n", mbi.AllocationBase, module);
1980 ok (mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "mbi.AllocationProtect is 0x%x, expected 0x%x\n", mbi.AllocationProtect, PAGE_EXECUTE_WRITECOPY);
1981 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%X\n", mbi.State, MEM_COMMIT);
1983 "mbi.Protect is 0x%x\n", mbi.Protect);
1984
1985 trace("Check flags of read-write uninitialized data (.bss) at %p\n", rwtestbuf);
1986 status = pNtQueryVirtualMemory(NtCurrentProcess(), rwtestbuf, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1987 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1988 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1989 if (mbi.AllocationBase == module)
1990 {
1991 ok (mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "mbi.AllocationProtect is 0x%x, expected 0x%x\n", mbi.AllocationProtect, PAGE_EXECUTE_WRITECOPY);
1992 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%X\n", mbi.State, MEM_COMMIT);
1994 "mbi.Protect is 0x%x\n", mbi.Protect);
1995 }
1996 else skip( "bss is outside of module\n" ); /* this can happen on Mac OS */
1997
1998 /* check error code when addr is higher than working set limit */
1999 status = pNtQueryVirtualMemory(NtCurrentProcess(), (void *)~0, MemoryBasicInformation, &mbi, sizeof(mbi), &readcount);
2000 ok(status == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
2001
2002 trace("Check section name of NTDLL.DLL with invalid size\n");
2003 module = GetModuleHandleA( "ntdll.dll" );
2004 memset(msn, 0, sizeof(*msn));
2005 readcount = 0;
2006 status = pNtQueryVirtualMemory(NtCurrentProcess(), module, MemoryMappedFilenameInformation, msn, sizeof(*msn), &readcount);
2007 ok( status == STATUS_BUFFER_OVERFLOW, "Expected STATUS_BUFFER_OVERFLOW, got %08x\n", status);
2008 ok( readcount > 0, "Expected readcount to be > 0\n");
2009
2010 trace("Check section name of NTDLL.DLL with invalid size\n");
2011 module = GetModuleHandleA( "ntdll.dll" );
2012 memset(msn, 0, sizeof(*msn));
2013 readcount = 0;
2014 status = pNtQueryVirtualMemory(NtCurrentProcess(), module, MemoryMappedFilenameInformation, msn, sizeof(*msn) - 1, &readcount);
2015 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
2016 ok( readcount > 0, "Expected readcount to be > 0\n");
2017
2018 trace("Check section name of NTDLL.DLL\n");
2019 module = GetModuleHandleA( "ntdll.dll" );
2020 memset(msn, 0x55, sizeof(*msn));
2021 memset(buffer_name, 0x77, sizeof(buffer_name));
2022 readcount = 0;
2023 status = pNtQueryVirtualMemory(NtCurrentProcess(), module, MemoryMappedFilenameInformation, msn, sizeof(buffer_name), &readcount);
2024 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
2025 ok( readcount > 0, "Expected readcount to be > 0\n");
2026 trace ("Section Name: %s\n", wine_dbgstr_w(msn->SectionFileName.Buffer));
2027 pRtlDowncaseUnicodeString( &msn->SectionFileName, &msn->SectionFileName, FALSE );
2028 for (found = FALSE, i = (msn->SectionFileName.Length - sizeof(windowsW)) / sizeof(WCHAR); i >= 0; i--)
2029 found |= !memcmp( &msn->SectionFileName.Buffer[i], windowsW, sizeof(windowsW) );
2030 ok( found, "Section name does not contain \"Windows\"\n");
2031
2032 trace("Check section name of non mapped memory\n");
2033 memset(msn, 0, sizeof(buffer_name));
2034 readcount = 0;
2035 status = pNtQueryVirtualMemory(NtCurrentProcess(), &buffer_name, MemoryMappedFilenameInformation, msn, sizeof(buffer_name), &readcount);
2036 ok( status == STATUS_INVALID_ADDRESS, "Expected STATUS_INVALID_ADDRESS, got %08x\n", status);
2037 ok( readcount == 0 || broken(readcount != 0) /* wow64 */, "Expected readcount to be 0\n");
2038
2039#ifdef __REACTOS__
2040 HeapFree(GetProcessHeap(), 0, msn);
2041#endif
2042}
2043
2044static void test_affinity(void)
2045{
2048 DWORD_PTR proc_affinity, thread_affinity;
2050 SYSTEM_INFO si;
2051
2052 GetSystemInfo(&si);
2053 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL );
2054 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
2055 proc_affinity = pbi.AffinityMask;
2056 ok( proc_affinity == (1 << si.dwNumberOfProcessors) - 1, "Unexpected process affinity\n" );
2057 proc_affinity = 1 << si.dwNumberOfProcessors;
2058 status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) );
2060 "Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
2061
2062 proc_affinity = 0;
2063 status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) );
2065 "Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
2066
2067 status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
2068 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
2069 ok( tbi.AffinityMask == (1 << si.dwNumberOfProcessors) - 1, "Unexpected thread affinity\n" );
2070 thread_affinity = 1 << si.dwNumberOfProcessors;
2071 status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) );
2073 "Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
2074 thread_affinity = 0;
2075 status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) );
2077 "Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
2078
2079 thread_affinity = 1;
2080 status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) );
2081 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
2082 status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
2083 ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
2084 ok( tbi.AffinityMask == 1, "Unexpected thread affinity\n" );
2085
2086 /* NOTE: Pre-Vista does not recognize the "all processors" flag (all bits set) */
2087 thread_affinity = ~(DWORD_PTR)0;
2088 status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) );
2090 "Expected STATUS_SUCCESS, got %08x\n", status);
2091
2092 if (si.dwNumberOfProcessors <= 1)
2093 {
2094 skip("only one processor, skipping affinity testing\n");
2095 return;
2096 }
2097
2098 /* Test thread affinity mask resulting from "all processors" flag */
2099 if (status == STATUS_SUCCESS)
2100 {
2101 status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
2102 ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
2103 ok( broken(tbi.AffinityMask == 1) || tbi.AffinityMask == (1 << si.dwNumberOfProcessors) - 1,
2104 "Unexpected thread affinity\n" );
2105 }
2106 else
2107 skip("Cannot test thread affinity mask for 'all processors' flag\n");
2108
2109 proc_affinity = 2;
2110 status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) );
2111 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
2112 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL );
2113 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
2114 proc_affinity = pbi.AffinityMask;
2115 ok( proc_affinity == 2, "Unexpected process affinity\n" );
2116 /* Setting the process affinity changes the thread affinity to match */
2117 status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
2118 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
2119 ok( tbi.AffinityMask == 2, "Unexpected thread affinity\n" );
2120 /* The thread affinity is restricted to the process affinity */
2121 thread_affinity = 1;
2122 status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) );
2124 "Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
2125
2126 proc_affinity = (1 << si.dwNumberOfProcessors) - 1;
2127 status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) );
2128 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
2129 /* Resetting the process affinity also resets the thread affinity */
2130 status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
2131 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
2132 ok( tbi.AffinityMask == (1 << si.dwNumberOfProcessors) - 1,
2133 "Unexpected thread affinity\n" );
2134}
2135
2137{
2139 SYSTEM_INFO si;
2142 DWORD_PTR old_process_mask;
2143 DWORD_PTR old_thread_mask;
2144 DWORD_PTR new_mask;
2145 ULONG current_cpu;
2146 ULONG i;
2147
2148 if (!pNtGetCurrentProcessorNumber) {
2149 win_skip("NtGetCurrentProcessorNumber not available\n");
2150 return;
2151 }
2152
2153 GetSystemInfo(&si);
2154 current_cpu = pNtGetCurrentProcessorNumber();
2155 trace("dwNumberOfProcessors: %d, current processor: %d\n", si.dwNumberOfProcessors, current_cpu);
2156
2157 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
2158 old_process_mask = pbi.AffinityMask;
2159 ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
2160
2161 status = pNtQueryInformationThread(GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL);
2162 old_thread_mask = tbi.AffinityMask;
2163 ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
2164
2165 /* allow the test to run on all processors */
2166 new_mask = (1 << si.dwNumberOfProcessors) - 1;
2167 status = pNtSetInformationProcess(GetCurrentProcess(), ProcessAffinityMask, &new_mask, sizeof(new_mask));
2168 ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
2169
2170 for (i = 0; i < si.dwNumberOfProcessors; i++)
2171 {
2172 new_mask = 1 << i;
2173 status = pNtSetInformationThread(GetCurrentThread(), ThreadAffinityMask, &new_mask, sizeof(new_mask));
2174 ok(status == STATUS_SUCCESS, "%d: got 0x%x (expected STATUS_SUCCESS)\n", i, status);
2175
2176 status = pNtQueryInformationThread(GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL);
2177 ok(status == STATUS_SUCCESS, "%d: got 0x%x (expected STATUS_SUCCESS)\n", i, status);
2178
2179 current_cpu = pNtGetCurrentProcessorNumber();
2180 ok((current_cpu == i), "%d (new_mask 0x%lx): running on processor %d (AffinityMask: 0x%lx)\n",
2181 i, new_mask, current_cpu, tbi.AffinityMask);
2182 }
2183
2184 /* restore old values */
2185 status = pNtSetInformationProcess(GetCurrentProcess(), ProcessAffinityMask, &old_process_mask, sizeof(old_process_mask));
2186 ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
2187
2188 status = pNtSetInformationThread(GetCurrentThread(), ThreadAffinityMask, &old_thread_mask, sizeof(old_thread_mask));
2189 ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
2190}
2191
2193{
2196 DWORD ret;
2197
2198 entry = NULL;
2199 ret = 0xdeadbeef;
2200 status = pNtQueryInformationThread(GetCurrentThread(), ThreadQuerySetWin32StartAddress,
2201 &entry, sizeof(entry), &ret);
2202 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
2203 ok(ret == sizeof(entry), "NtQueryInformationThread returned %u bytes\n", ret);
2204 ok(entry == (void *)start_address_thread, "expected %p, got %p\n", start_address_thread, entry);
2205 return 0;
2206}
2207
2209{
2210 PRTL_THREAD_START_ROUTINE entry, expected_entry;
2213 HANDLE thread;
2214 void *module;
2215 DWORD ret;
2216
2218 ok(module != NULL, "expected non-NULL address for module\n");
2220 ok(nt != NULL, "expected non-NULL address for NT header\n");
2221
2222 entry = NULL;
2223 ret = 0xdeadbeef;
2224 status = pNtQueryInformationThread(GetCurrentThread(), ThreadQuerySetWin32StartAddress,
2225 &entry, sizeof(entry), &ret);
2226 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
2227 ok(ret == sizeof(entry), "NtQueryInformationThread returned %u bytes\n", ret);
2228 expected_entry = (void *)((char *)module + nt->OptionalHeader.AddressOfEntryPoint);
2229 ok(entry == expected_entry, "expected %p, got %p\n", expected_entry, entry);
2230
2231 entry = (void *)0xdeadbeef;
2232 status = pNtSetInformationThread(GetCurrentThread(), ThreadQuerySetWin32StartAddress,
2233 &entry, sizeof(entry));
2234 ok(status == STATUS_SUCCESS || status == STATUS_INVALID_PARAMETER, /* >= Vista */
2235 "expected STATUS_SUCCESS or STATUS_INVALID_PARAMETER, got %08x\n", status);
2236
2237 if (status == STATUS_SUCCESS)
2238 {
2239 entry = NULL;
2240 ret = 0xdeadbeef;
2241 status = pNtQueryInformationThread(GetCurrentThread(), ThreadQuerySetWin32StartAddress,
2242 &entry, sizeof(entry), &ret);
2243 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
2244 ok(ret == sizeof(entry), "NtQueryInformationThread returned %u bytes\n", ret);
2245 ok(entry == (void *)0xdeadbeef, "expected 0xdeadbeef, got %p\n", entry);
2246 }
2247
2249 ok(thread != INVALID_HANDLE_VALUE, "CreateThread failed with %d\n", GetLastError());
2251 ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", ret);
2253}
2254
2256{
2259 DWORD value;
2260
2261 value = 0xdeadbeef;
2262 status = pNtQuerySystemInformation(SystemRecommendedSharedDataAlignment, &value, sizeof(value), &ReturnLength);
2263 ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
2264 ok(sizeof(value) == ReturnLength, "Inconsistent length %u\n", ReturnLength);
2265 ok(value == 64, "Expected 64, got %u\n", value);
2266}
2267
2269{
2270 char **argv;
2271 int argc;
2272
2274 if (argc >= 3) return; /* Child */
2275
2276 if (!InitFunctionPtrs())
2277 return;
2278
2279 /* NtQuerySystemInformation */
2280
2281 /* 0x0 SystemBasicInformation */
2282 trace("Starting test_query_basic()\n");
2284
2285 /* 0x1 SystemCpuInformation */
2286 trace("Starting test_query_cpu()\n");
2288
2289 /* 0x2 SystemPerformanceInformation */
2290 trace("Starting test_query_performance()\n");
2292
2293 /* 0x3 SystemTimeOfDayInformation */
2294 trace("Starting test_query_timeofday()\n");
2296
2297 /* 0x5 SystemProcessInformation */
2298 trace("Starting test_query_process()\n");
2300
2301 /* 0x8 SystemProcessorPerformanceInformation */
2302 trace("Starting test_query_procperf()\n");
2304
2305 /* 0xb SystemModuleInformation */
2306 trace("Starting test_query_module()\n");
2308
2309 /* 0x10 SystemHandleInformation */
2310 trace("Starting test_query_handle()\n");
2312
2313 /* 0x40 SystemHandleInformation */
2314 trace("Starting test_query_handle_ex()\n");
2316
2317 /* 0x15 SystemCacheInformation */
2318 trace("Starting test_query_cache()\n");
2320
2321 /* 0x17 SystemInterruptInformation */
2322 trace("Starting test_query_interrupt()\n");
2324
2325 /* 0x23 SystemKernelDebuggerInformation */
2326 trace("Starting test_query_kerndebug()\n");
2328
2329 /* 0x25 SystemRegistryQuotaInformation */
2330 trace("Starting test_query_regquota()\n");
2332
2333 /* 0x49 SystemLogicalProcessorInformation */
2334 trace("Starting test_query_logicalproc()\n");
2337
2338 /* NtPowerInformation */
2339
2340 /* 0xb ProcessorInformation */
2341 trace("Starting test_query_processor_power_info()\n");
2343
2344 /* NtQueryInformationProcess */
2345
2346 /* 0x0 ProcessBasicInformation */
2347 trace("Starting test_query_process_basic()\n");
2349
2350 /* 0x2 ProcessIoCounters */
2351 trace("Starting test_query_process_io()\n");
2353
2354 /* 0x3 ProcessVmCounters */
2355 trace("Starting test_query_process_vm()\n");
2357
2358 /* 0x4 ProcessTimes */
2359 trace("Starting test_query_process_times()\n");
2361
2362 /* 0x7 ProcessDebugPort */
2363 trace("Starting test_process_debug_port()\n");
2365
2366 /* 0x12 ProcessPriorityClass */
2367 trace("Starting test_query_process_priority()\n");
2369
2370 /* 0x14 ProcessHandleCount */
2371 trace("Starting test_query_process_handlecount()\n");
2373
2374 /* 0x1A ProcessWow64Information */
2375 trace("Starting test_query_process_wow64()\n");
2377
2378 /* 0x1B ProcessImageFileName */
2379 trace("Starting test_query_process_image_file_name()\n");
2381
2382 /* 0x1E ProcessDebugObjectHandle */
2383 trace("Starting test_query_process_debug_object_handle()\n");
2385
2386 /* 0x1F ProcessDebugFlags */
2387 trace("Starting test_process_debug_flags()\n");
2389
2390 /* belongs to its own file */
2391 trace("Starting test_readvirtualmemory()\n");
2393
2394 trace("Starting test_queryvirtualmemory()\n");
2396
2397 trace("Starting test_mapprotection()\n");
2399
2400 trace("Starting test_affinity()\n");
2401 test_affinity();
2402
2403 trace("Starting test_NtGetCurrentProcessorNumber()\n");
2405
2406 trace("Starting test_thread_start_address()\n");
2408
2409 trace("Starting test_query_data_alignment()\n");
2411}
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3483
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3076
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:3257
_In_ PVOID _In_ ULONG _Out_ PVOID _In_ ULONG _Inout_ PULONG ReturnLength
static int argc
Definition: ServiceArgs.c:12
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#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
LONG NTSTATUS
Definition: precomp.h:26
static HANDLE thread
Definition: service.c:33
@ ProcessDebugPort
Definition: cicbase.cpp:64
@ ProcessBasicInformation
Definition: cicbase.cpp:63
@ ProcessWow64Information
Definition: cicbase.cpp:65
@ ProcessImageFileName
Definition: cicbase.cpp:66
#define STATUS_INVALID_HANDLE
Definition: d3dkmdt.h:40
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
const char * file_nameA(const char *str) DECLSPEC_HIDDEN
Definition: path.c:37
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NTSTATUS
Definition: precomp.h:19
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define PAGE_READONLY
Definition: compat.h:138
#define SECTION_MAP_READ
Definition: compat.h:139
#define CP_ACP
Definition: compat.h:109
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
@ ThreadQuerySetWin32StartAddress
Definition: compat.h:944
@ ThreadAffinityMask
Definition: compat.h:939
@ ThreadBasicInformation
Definition: compat.h:935
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define GetCurrentProcess()
Definition: compat.h:759
#define RtlImageNtHeader
Definition: compat.h:806
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL WINAPI DebugActiveProcessStop(IN DWORD dwProcessId)
Definition: debugger.c:486
BOOL WINAPI ContinueDebugEvent(IN DWORD dwProcessId, IN DWORD dwThreadId, IN DWORD dwContinueStatus)
Definition: debugger.c:413
BOOL WINAPI DebugActiveProcess(IN DWORD dwProcessId)
Definition: debugger.c:445
BOOL WINAPI WaitForDebugEvent(IN LPDEBUG_EVENT lpDebugEvent, IN DWORD dwMilliseconds)
Definition: debugger.c:590
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4747
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
DWORD WINAPI GetPriorityClass(IN HANDLE hProcess)
Definition: proc.c:1663
BOOL WINAPI SetPriorityClass(IN HANDLE hProcess, IN DWORD dwPriorityClass)
Definition: proc.c:1698
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
DWORD WINAPI ResumeThread(IN HANDLE hThread)
Definition: thread.c:567
DWORD WINAPI SuspendThread(IN HANDLE hThread)
Definition: thread.c:642
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 FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
BOOL WINAPI SystemTimeToTzSpecificLocalTime(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation, CONST SYSTEMTIME *lpUniversalTime, LPSYSTEMTIME lpLocalTime)
Definition: timezone.c:377
return ret
Definition: mutex.c:146
#define INFINITE
Definition: serial.h:102
size_t const old_size
Definition: expand.cpp:65
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
@ SystemKernelDebuggerInformation
Definition: ntddk_ex.h:46
@ SystemTimeOfDayInformation
Definition: ntddk_ex.h:14
@ SystemModuleInformation
Definition: ntddk_ex.h:22
@ SystemBasicInformation
Definition: ntddk_ex.h:11
@ SystemRegistryQuotaInformation
Definition: ntddk_ex.h:48
@ SystemInterruptInformation
Definition: ntddk_ex.h:34
@ SystemFileCacheInformation
Definition: ntddk_ex.h:32
@ SystemHandleInformation
Definition: ntddk_ex.h:27
@ SystemProcessInformation
Definition: ntddk_ex.h:16
@ SystemProcessorPerformanceInformation
Definition: ntddk_ex.h:19
enum _SYSTEM_INFORMATION_CLASS SYSTEM_INFORMATION_CLASS
ULONG Handle
Definition: gdb_input.c:15
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLfloat f
Definition: glext.h:7540
GLbitfield flags
Definition: glext.h:7161
GLenum const GLvoid * addr
Definition: glext.h:9621
GLuint64EXT * result
Definition: glext.h:11304
GLenum GLsizei len
Definition: glext.h:6722
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
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 const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define PROCESS_VM_READ
Definition: pstypes.h:162
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:167
@ MemoryMappedFilenameInformation
Definition: winternl.h:2387
NTSYSAPI NTSTATUS WINAPI RtlDowncaseUnicodeString(UNICODE_STRING *, const UNICODE_STRING *, BOOLEAN)
@ ProcessDebugFlags
Definition: winternl.h:1913
@ ProcessAffinityMask
Definition: winternl.h:1903
@ ProcessVmCounters
Definition: winternl.h:1885
@ ProcessPriorityClass
Definition: winternl.h:1900
@ ProcessExecuteFlags
Definition: winternl.h:1916
@ ProcessIoCounters
Definition: winternl.h:1884
@ ProcessTimes
Definition: winternl.h:1886
@ ProcessDebugObjectHandle
Definition: winternl.h:1912
@ ProcessHandleCount
Definition: winternl.h:1902
#define PROCESS_PRIOCLASS_BELOW_NORMAL
Definition: winternl.h:2757
void(CALLBACK * PRTL_THREAD_START_ROUTINE)(LPVOID)
Definition: winternl.h:3492
struct _SYSTEM_CACHE_INFORMATION SYSTEM_CACHE_INFORMATION
@ SystemCpuInformation
Definition: winternl.h:2014
@ SystemLogicalProcessorInformationEx
Definition: winternl.h:2122
uint32_t entry
Definition: isohybrid.c:63
#define f
Definition: ke_i.h:83
#define wine_dbgstr_w
Definition: kernel32.h:34
#define SystemPerformanceInformation
Definition: memtest.h:87
struct _SYSTEM_PERFORMANCE_INFORMATION SYSTEM_PERFORMANCE_INFORMATION
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define PROCESS_QUERY_LIMITED_INFORMATION
Definition: security.c:45
BOOL expected
Definition: store.c:2063
IMAGE_NT_HEADERS nt
Definition: module.c:50
static HINSTANCE hkernel32
Definition: process.c:66
static HINSTANCE hntdll
Definition: process.c:66
#define todo_wine
Definition: custom.c:89
static void test_query_performance(void)
Definition: info.c:163
static void test_query_data_alignment(void)
Definition: info.c:2255
#define NTDLL_GET_PROC(func)
Definition: info.c:50
static void test_query_timeofday(void)
Definition: info.c:191
static void test_query_processor_power_info(void)
Definition: info.c:891
static DWORD one_before_last_pid
Definition: info.c:48
static void test_query_process_vm(void)
Definition: info.c:1127
static void test_query_process_debug_flags(int argc, char **argv)
Definition: info.c:1629
static void test_query_process_io(void)
Definition: info.c:1238
static SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX DWORD *static BOOL is_wow64
Definition: info.c:43
static void test_query_kerndebug(void)
Definition: info.c:704
static const void void SIZE_T *static SIZE_T *static const OBJECT_ATTRIBUTES const LARGE_INTEGER HANDLE
Definition: info.c:35
static void test_query_process_handlecount(void)
Definition: info.c:1441
static void test_readvirtualmemory(void)
Definition: info.c:1783
static void test_mapprotection(void)
Definition: info.c:1834
static PROCESSINFOCLASS
Definition: info.c:29
static PVOID const LARGE_INTEGER SIZE_T SECTION_INHERIT
Definition: info.c:36
static void test_query_regquota(void)
Definition: info.c:722
static void test_query_procperf(void)
Definition: info.c:388
static void test_thread_start_address(void)
Definition: info.c:2208
static void test_query_process_priority(void)
Definition: info.c:1407
static void test_query_cache(void)
Definition: info.c:624
static void dump_vm_counters(const char *header, const VM_COUNTERS *pvi)
Definition: info.c:1111
static void test_NtGetCurrentProcessorNumber(void)
Definition: info.c:2136
static DWORD WINAPI start_address_thread(void *arg)
Definition: info.c:2192
static void test_queryvirtualmemory(void)
Definition: info.c:1904
static void test_query_handle_ex(void)
Definition: info.c:568
static void test_query_process_wow64(void)
Definition: info.c:964
static PBOOL
Definition: info.c:40
static void test_query_basic(void)
Definition: info.c:100
static void test_query_handle(void)
Definition: info.c:490
static const void void SIZE_T *static LPCVOID
Definition: info.c:34
static void test_affinity(void)
Definition: info.c:2044
static const void void SIZE_T *static SIZE_T *static ACCESS_MASK
Definition: info.c:35
static void test_query_module(void)
Definition: info.c:455
static void test_query_process_times(void)
Definition: info.c:1278
static void test_query_cpu(void)
Definition: info.c:148
static void test_query_interrupt(void)
Definition: info.c:675
static void test_query_logicalproc(void)
Definition: info.c:740
static const void void SIZE_T *static MEMORY_INFORMATION_CLASS
Definition: info.c:34
static void test_query_process_basic(void)
Definition: info.c:1042
static BOOL InitFunctionPtrs(void)
Definition: info.c:58
static void test_query_process_debug_port(int argc, char **argv)
Definition: info.c:1335
static void test_query_process_image_file_name(void)
Definition: info.c:1487
static const void void SIZE_T
Definition: info.c:33
static void test_query_process(void)
Definition: info.c:270
static THREADINFOCLASS
Definition: info.c:30
static void test_query_logicalprocex(void)
Definition: info.c:787
static void test_query_process_debug_object_handle(int argc, char **argv)
Definition: info.c:1524
static const UNICODE_STRING BOOLEAN
Definition: info.c:25
static PULONG
Definition: info.c:26
static refpint_t pi[]
Definition: server.c:96
static int priority
Definition: timer.c:163
int k
Definition: mpi.c:3369
#define argv
Definition: mplay32.c:18
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
struct _SYSTEM_HANDLE_INFORMATION SYSTEM_HANDLE_INFORMATION
struct _SYSTEM_THREAD_INFORMATION SYSTEM_THREAD_INFORMATION
struct _SYSTEM_INTERRUPT_INFORMATION SYSTEM_INTERRUPT_INFORMATION
struct _SYSTEM_HANDLE_INFORMATION_EX SYSTEM_HANDLE_INFORMATION_EX
@ SystemLogicalProcessorInformation
Definition: extypes.h:290
@ SystemRecommendedSharedDataAlignment
Definition: extypes.h:275
@ SystemExtendedHandleInformation
Definition: extypes.h:281
@ MemoryBasicInformation
Definition: mmtypes.h:183
#define MEM_IMAGE
Definition: mmtypes.h:89
#define SEC_NOCACHE
Definition: mmtypes.h:101
#define SEC_COMMIT
Definition: mmtypes.h:100
#define MEM_EXECUTE_OPTION_ENABLE
Definition: mmtypes.h:74
_In_ NTSTATUS ExitStatus
Definition: psfuncs.h:867
struct _RTL_PROCESS_MODULES RTL_PROCESS_MODULES
#define SECTION_MAP_EXECUTE
Definition: nt_native.h:1290
#define BOOL
Definition: nt_native.h:43
#define PAGE_WRITECOPY
Definition: nt_native.h:1305
#define SECTION_MAP_WRITE
Definition: nt_native.h:1288
#define PAGE_NOCACHE
Definition: nt_native.h:1311
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define PAGE_EXECUTE_READ
Definition: nt_native.h:1307
#define SECTION_QUERY
Definition: nt_native.h:1287
#define NtCurrentProcess()
Definition: nt_native.h:1657
@ ViewShare
Definition: nt_native.h:1278
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define PAGE_EXECUTE_WRITECOPY
Definition: nt_native.h:1309
#define MEM_RESERVE
Definition: nt_native.h:1314
#define MEM_RELEASE
Definition: nt_native.h:1316
#define DWORD
Definition: nt_native.h:44
#define MEM_COMMIT
Definition: nt_native.h:1313
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308
#define STANDARD_RIGHTS_REQUIRED
Definition: nt_native.h:63
NTSTATUS NTAPI NtReadVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, OUT PVOID Buffer, IN SIZE_T NumberOfBytesToRead, OUT PSIZE_T NumberOfBytesRead OPTIONAL)
Definition: virtual.c:2776
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:4369
NTSTATUS NTAPI NtPowerInformation(IN POWER_INFORMATION_LEVEL PowerInformationLevel, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength)
Definition: power.c:792
NTSTATUS NTAPI NtQueryInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, OUT PVOID ThreadInformation, IN ULONG ThreadInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: query.c:2750
NTSTATUS NTAPI NtSetInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, IN PVOID ProcessInformation, IN ULONG ProcessInformationLength)
Definition: query.c:1231
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:2144
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
struct _PROCESSOR_POWER_INFORMATION PROCESSOR_POWER_INFORMATION
enum _POWER_INFORMATION_LEVEL POWER_INFORMATION_LEVEL
@ ProcessorInformation
Definition: ntpoapi.h:78
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:207
#define STATUS_INVALID_ADDRESS
Definition: ntstatus.h:557
#define DBG_CONTINUE
Definition: ntstatus.h:47
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define STATUS_PORT_NOT_SET
Definition: ntstatus.h:894
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
#define STATUS_PARTIAL_COPY
Definition: ntstatus.h:193
#define offsetof(TYPE, MEMBER)
int winetest_debug
#define win_skip
Definition: test.h:164
int winetest_get_mainargs(char ***pargv)
#define disable_success_count
Definition: test.h:186
#define memset(x, y, z)
Definition: compat.h:39
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
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
UNICODE_STRING SectionFileName
Definition: mmtypes.h:326
DWORD dwDebugEventCode
Definition: winbase.h:823
DWORD dwThreadId
Definition: winbase.h:825
DWORD dwProcessId
Definition: winbase.h:824
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
ULONGLONG OtherOperationCount
Definition: pstypes.h:85
LARGE_INTEGER UserTime
Definition: winternl.h:2377
LARGE_INTEGER CreateTime
Definition: winternl.h:2374
LARGE_INTEGER KernelTime
Definition: winternl.h:2376
LARGE_INTEGER ExitTime
Definition: winternl.h:2375
RTL_PROCESS_MODULE_INFORMATION Modules[1]
Definition: rtltypes.h:1012
DWORD cb
Definition: winbase.h:866
WORD wYear
Definition: winbase.h:946
WORD wMilliseconds
Definition: winbase.h:953
WORD wMonth
Definition: winbase.h:947
WORD wHour
Definition: winbase.h:950
WORD wSecond
Definition: winbase.h:952
WORD wMinute
Definition: winbase.h:951
WORD wDay
Definition: winbase.h:949
USHORT HandleValue
Definition: winternl.h:3037
ULONG OwnerPid
Definition: winternl.h:3034
SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX Handles[1]
Definition: extypes.h:1608
SYSTEM_HANDLE_ENTRY Handle[1]
Definition: winternl.h:3044
ULONG_PTR HandleValue
Definition: extypes.h:1596
ULONG_PTR UniqueProcessId
Definition: extypes.h:1595
DWORD dwNumberOfProcessors
Definition: winbase.h:1218
KAFFINITY AffinityMask
Definition: compat.h:930
SIZE_T PeakWorkingSetSize
Definition: winternl.h:3134
SIZE_T PeakPagefileUsage
Definition: winternl.h:3141
ULONG PageFaultCount
Definition: winternl.h:3133
SIZE_T QuotaPagedPoolUsage
Definition: winternl.h:3137
SIZE_T QuotaPeakPagedPoolUsage
Definition: winternl.h:3136
SIZE_T QuotaPeakNonPagedPoolUsage
Definition: winternl.h:3138
SIZE_T PeakVirtualSize
Definition: winternl.h:3131
SIZE_T VirtualSize
Definition: winternl.h:3132
SIZE_T QuotaNonPagedPoolUsage
Definition: winternl.h:3139
SIZE_T WorkingSetSize
Definition: winternl.h:3135
SIZE_T PagefileUsage
Definition: winternl.h:3140
Definition: comerr.c:44
Definition: ps.c:97
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
#define DWORD_PTR
Definition: treelist.c:76
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
LONGLONG QuadPart
Definition: typedefs.h:114
Definition: pdh_main.c:96
LPVOID NTAPI VirtualAlloc(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flAllocationType, IN DWORD flProtect)
Definition: virtmem.c:65
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:1148
#define LOAD_DLL_DEBUG_EVENT
Definition: winbase.h:115
#define BELOW_NORMAL_PRIORITY_CLASS
Definition: winbase.h:200
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
#define EXIT_PROCESS_DEBUG_EVENT
Definition: winbase.h:114
#define CREATE_SUSPENDED
Definition: winbase.h:188
#define DEBUG_ONLY_THIS_PROCESS
Definition: winbase.h:187
#define WAIT_OBJECT_0
Definition: winbase.h:439
#define DEBUG_PROCESS
Definition: winbase.h:186
_Inout_ PERBANDINFO * pbi
Definition: winddi.h:3917
#define WINAPI
Definition: msvc.h:6
#define ERROR_SEM_TIMEOUT
Definition: winerror.h:316
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:857
@ RelationNumaNode
Definition: ketypes.h:83
@ RelationCache
Definition: ketypes.h:84
@ RelationProcessorCore
Definition: ketypes.h:82
@ RelationGroup
Definition: ketypes.h:86
@ RelationProcessorPackage
Definition: ketypes.h:85
@ RelationAll
Definition: ketypes.h:87
enum _LOGICAL_PROCESSOR_RELATIONSHIP LOGICAL_PROCESSOR_RELATIONSHIP
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193