ReactOS 0.4.16-dev-979-g79f281e
psapi.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _MODULEINFO
 
struct  _PSAPI_WS_WATCH_INFORMATION
 
struct  _PROCESS_MEMORY_COUNTERS
 
struct  _PROCESS_MEMORY_COUNTERS_EX
 
struct  _PERFORMANCE_INFORMATION
 
struct  _ENUM_PAGE_FILE_INFORMATION
 

Macros

#define PENUM_PAGE_FILE_CALLBACK   PENUM_PAGE_FILE_CALLBACKA
 
#define EnumPageFiles   EnumPageFilesA
 
#define GetModuleBaseName   GetModuleBaseNameA
 
#define GetModuleFileNameEx   GetModuleFileNameExA
 
#define GetMappedFilenameEx   GetMappedFilenameExA
 
#define GetDeviceDriverBaseName   GetDeviceDriverBaseNameA
 
#define GetDeviceDriverFileName   GetDeviceDriverFileNameA
 
#define GetProcessImageFileName   GetProcessImageFileNameA
 

Typedefs

typedef struct _MODULEINFO MODULEINFO
 
typedef struct _MODULEINFOLPMODULEINFO
 
typedef struct _PSAPI_WS_WATCH_INFORMATION PSAPI_WS_WATCH_INFORMATION
 
typedef struct _PSAPI_WS_WATCH_INFORMATIONPPSAPI_WS_WATCH_INFORMATION
 
typedef struct _PROCESS_MEMORY_COUNTERS PROCESS_MEMORY_COUNTERS
 
typedef struct _PROCESS_MEMORY_COUNTERSPPROCESS_MEMORY_COUNTERS
 
typedef struct _PROCESS_MEMORY_COUNTERS_EX PROCESS_MEMORY_COUNTERS_EX
 
typedef struct _PROCESS_MEMORY_COUNTERS_EXPPROCESS_MEMORY_COUNTERS_EX
 
typedef struct _PERFORMANCE_INFORMATION PERFORMANCE_INFORMATION
 
typedef struct _PERFORMANCE_INFORMATIONPPERFORMANCE_INFORMATION
 
typedef struct _ENUM_PAGE_FILE_INFORMATION ENUM_PAGE_FILE_INFORMATION
 
typedef struct _ENUM_PAGE_FILE_INFORMATIONPENUM_PAGE_FILE_INFORMATION
 
typedef BOOL(CALLBACKPENUM_PAGE_FILE_CALLBACKA) (LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCSTR)
 
typedef BOOL(CALLBACKPENUM_PAGE_FILE_CALLBACKW) (LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCWSTR)
 

Functions

BOOL WINAPI EnumProcesses (DWORD *, DWORD, DWORD *)
 
BOOL WINAPI EnumProcessModules (HANDLE, HMODULE *, DWORD, LPDWORD)
 
BOOL WINAPI EnumPageFilesA (PENUM_PAGE_FILE_CALLBACKA, LPVOID)
 
BOOL WINAPI EnumPageFilesW (PENUM_PAGE_FILE_CALLBACKW, LPVOID)
 
DWORD WINAPI GetModuleBaseNameA (HANDLE, HMODULE, LPSTR, DWORD)
 
DWORD WINAPI GetModuleBaseNameW (HANDLE, HMODULE, LPWSTR, DWORD)
 
DWORD WINAPI GetModuleFileNameExA (HANDLE, HMODULE, LPSTR, DWORD)
 
DWORD WINAPI GetModuleFileNameExW (HANDLE, HMODULE, LPWSTR, DWORD)
 
BOOL WINAPI GetModuleInformation (HANDLE, HMODULE, LPMODULEINFO, DWORD)
 
BOOL WINAPI EmptyWorkingSet (HANDLE)
 
BOOL WINAPI QueryWorkingSet (HANDLE, PVOID, DWORD)
 
BOOL WINAPI InitializeProcessForWsWatch (HANDLE)
 
BOOL WINAPI GetWsChanges (HANDLE, PPSAPI_WS_WATCH_INFORMATION, DWORD)
 
DWORD WINAPI GetMappedFileNameW (HANDLE, LPVOID, LPWSTR, DWORD)
 
DWORD WINAPI GetMappedFileNameA (HANDLE, LPVOID, LPSTR, DWORD)
 
BOOL WINAPI EnumDeviceDrivers (LPVOID *, DWORD, LPDWORD)
 
DWORD WINAPI GetDeviceDriverBaseNameA (LPVOID, LPSTR, DWORD)
 
DWORD WINAPI GetDeviceDriverBaseNameW (LPVOID, LPWSTR, DWORD)
 
DWORD WINAPI GetDeviceDriverFileNameA (LPVOID, LPSTR, DWORD)
 
DWORD WINAPI GetDeviceDriverFileNameW (LPVOID, LPWSTR, DWORD)
 
BOOL WINAPI GetProcessMemoryInfo (HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD)
 
BOOL WINAPI GetPerformanceInfo (PPERFORMANCE_INFORMATION, DWORD)
 
DWORD WINAPI GetProcessImageFileNameW (HANDLE, LPWSTR, DWORD)
 
DWORD WINAPI GetProcessImageFileNameA (HANDLE, LPSTR, DWORD)
 

Macro Definition Documentation

◆ EnumPageFiles

#define EnumPageFiles   EnumPageFilesA

Definition at line 131 of file psapi.h.

◆ GetDeviceDriverBaseName

#define GetDeviceDriverBaseName   GetDeviceDriverBaseNameA

Definition at line 135 of file psapi.h.

◆ GetDeviceDriverFileName

#define GetDeviceDriverFileName   GetDeviceDriverFileNameA

Definition at line 136 of file psapi.h.

◆ GetMappedFilenameEx

#define GetMappedFilenameEx   GetMappedFilenameExA

Definition at line 134 of file psapi.h.

◆ GetModuleBaseName

#define GetModuleBaseName   GetModuleBaseNameA

Definition at line 132 of file psapi.h.

◆ GetModuleFileNameEx

#define GetModuleFileNameEx   GetModuleFileNameExA

Definition at line 133 of file psapi.h.

◆ GetProcessImageFileName

#define GetProcessImageFileName   GetProcessImageFileNameA

Definition at line 137 of file psapi.h.

◆ PENUM_PAGE_FILE_CALLBACK

#define PENUM_PAGE_FILE_CALLBACK   PENUM_PAGE_FILE_CALLBACKA

Definition at line 130 of file psapi.h.

Typedef Documentation

◆ ENUM_PAGE_FILE_INFORMATION

◆ LPMODULEINFO

◆ MODULEINFO

◆ PENUM_PAGE_FILE_CALLBACKA

typedef BOOL(CALLBACK * PENUM_PAGE_FILE_CALLBACKA) (LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCSTR)

Definition at line 89 of file psapi.h.

◆ PENUM_PAGE_FILE_CALLBACKW

typedef BOOL(CALLBACK * PENUM_PAGE_FILE_CALLBACKW) (LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCWSTR)

Definition at line 90 of file psapi.h.

◆ PENUM_PAGE_FILE_INFORMATION

◆ PERFORMANCE_INFORMATION

◆ PPERFORMANCE_INFORMATION

◆ PPROCESS_MEMORY_COUNTERS

◆ PPROCESS_MEMORY_COUNTERS_EX

◆ PPSAPI_WS_WATCH_INFORMATION

◆ PROCESS_MEMORY_COUNTERS

◆ PROCESS_MEMORY_COUNTERS_EX

◆ PSAPI_WS_WATCH_INFORMATION

Function Documentation

◆ EmptyWorkingSet()

BOOL WINAPI EmptyWorkingSet ( HANDLE  hProcess)

Definition at line 252 of file psapi.c.

253{
254 SYSTEM_INFO SystemInfo;
255 QUOTA_LIMITS QuotaLimits;
257
258 GetSystemInfo(&SystemInfo);
259
260 /* Query the working set */
263 &QuotaLimits,
264 sizeof(QuotaLimits),
265 NULL);
266
267 if (!NT_SUCCESS(Status))
268 {
270 return FALSE;
271 }
272
273 /* Empty the working set */
274 QuotaLimits.MinimumWorkingSetSize = -1;
275 QuotaLimits.MaximumWorkingSetSize = -1;
276
277 /* Set the working set */
280 &QuotaLimits,
281 sizeof(QuotaLimits));
283 {
285 return FALSE;
286 }
287
288 return TRUE;
289}
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define SetLastError(x)
Definition: compat.h:752
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
Status
Definition: gdiplustypes.h:25
@ ProcessQuotaLimits
Definition: winternl.h:857
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
NTSTATUS NTAPI NtSetInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, IN PVOID ProcessInformation, IN ULONG ProcessInformationLength)
Definition: query.c:1154
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
INT64 MaximumWorkingSetSize
Definition: lsa.idl:290
INT64 MinimumWorkingSetSize
Definition: lsa.idl:289

Referenced by test_ws_functions().

◆ EnumDeviceDrivers()

BOOL WINAPI EnumDeviceDrivers ( LPVOID lpImageBase,
DWORD  cb,
LPDWORD  lpcbNeeded 
)

Definition at line 297 of file psapi.c.

300{
304 /* By default, to prevent too many reallocations, we already make room for 4 modules */
306
307 do
308 {
309 /* Allocate a buffer to hold modules information */
311 if (!Information)
312 {
314 return FALSE;
315 }
316
317 /* Query information */
319 /* In case of an error */
320 if (!NT_SUCCESS(Status))
321 {
322 /* Save the amount of output modules */
323 NewSize = Information->NumberOfModules;
324 /* And free buffer */
326
327 /* If it was not a length mismatch (ie, buffer too small), just leave */
329 {
331 return FALSE;
332 }
333
334 /* Compute new size length */
335 ASSERT(Size >= sizeof(RTL_PROCESS_MODULES));
337 NewSize += sizeof(ULONG);
339 /* Check whether it is really bigger - otherwise, leave */
340 if (NewSize < Size)
341 {
344 return FALSE;
345 }
346
347 /* Loop again with that new buffer */
348 Size = NewSize;
349 continue;
350 }
351
352 /* End of allocation loop */
353 break;
354 } while (TRUE);
355
357 {
358 for (Count = 0; Count < Information->NumberOfModules && Count < cb / sizeof(LPVOID); ++Count)
359 {
360 lpImageBase[Count] = Information->Modules[Count].ImageBase;
361 }
362
363 *lpcbNeeded = Information->NumberOfModules * sizeof(LPVOID);
364 }
366 {
368 _SEH2_YIELD(return FALSE);
369 }
370 _SEH2_END;
371
372 return TRUE;
373}
unsigned long DWORD
Definition: ntddk_ex.h:95
@ SystemModuleInformation
Definition: ntddk_ex.h:22
_Must_inspect_result_ _In_ USHORT NewSize
Definition: fltkernel.h:975
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define ASSERT(a)
Definition: mode.c:44
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
struct _RTL_PROCESS_MODULES RTL_PROCESS_MODULES
struct _RTL_PROCESS_MODULE_INFORMATION RTL_PROCESS_MODULE_INFORMATION
int Count
Definition: noreturn.cpp:7
#define LPVOID
Definition: nt_native.h:45
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:184
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
#define LMEM_FIXED
Definition: winbase.h:394
#define ERROR_NO_SYSTEM_RESOURCES
Definition: winerror.h:931

◆ EnumPageFilesA()

BOOL WINAPI EnumPageFilesA ( PENUM_PAGE_FILE_CALLBACKA  pCallbackRoutine,
LPVOID  lpContext 
)

Definition at line 1209 of file psapi.c.

1211{
1212 BOOL Ret;
1214
1215 Context.dwErrCode = ERROR_SUCCESS;
1216 Context.lpContext = lpContext;
1217 Context.pCallbackRoutine = pCallbackRoutine;
1218
1219 /* Call W with our own callback for W -> A conversions */
1221 /* If we succeed but we have error code, fail and set error */
1222 if (Ret && Context.dwErrCode != ERROR_SUCCESS)
1223 {
1224 Ret = FALSE;
1225 SetLastError(Context.dwErrCode);
1226 }
1227
1228 return Ret;
1229}
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI EnumPageFilesW(PENUM_PAGE_FILE_CALLBACKW pCallbackRoutine, LPVOID lpContext)
Definition: psapi.c:1237
static BOOL CALLBACK CallBackConvertToAscii(LPVOID pContext, PENUM_PAGE_FILE_INFORMATION pPageFileInfo, LPCWSTR lpFilename)
Definition: psapi.c:213
unsigned int BOOL
Definition: ntddk_ex.h:94

◆ EnumPageFilesW()

BOOL WINAPI EnumPageFilesW ( PENUM_PAGE_FILE_CALLBACKW  pCallbackRoutine,
LPVOID  lpContext 
)

Definition at line 1237 of file psapi.c.

1239{
1240 PWSTR Colon;
1242 DWORD Size = INIT_MEMORY_SIZE, Needed;
1244 PSYSTEM_PAGEFILE_INFORMATION PageFileInfoArray, PageFileInfo;
1245
1246 /* First loop till we have all the information about page files */
1247 do
1248 {
1249 PageFileInfoArray = LocalAlloc(LMEM_FIXED, Size);
1250 if (PageFileInfoArray == NULL)
1251 {
1253 return FALSE;
1254 }
1255
1256 Status = NtQuerySystemInformation(SystemPageFileInformation, PageFileInfoArray, Size, &Needed);
1257 if (NT_SUCCESS(Status))
1258 {
1259 break;
1260 }
1261
1262 LocalFree(PageFileInfoArray);
1263
1264 /* In case we have unexpected status, quit */
1266 {
1268 return FALSE;
1269 }
1270
1271 /* If needed size is smaller than actual size, guess it's something to add to our current size */
1272 if (Needed <= Size)
1273 {
1274 Size += Needed;
1275 }
1276 /* Otherwise, take it as size to allocate */
1277 else
1278 {
1279 Size = Needed;
1280 }
1281 }
1282 while (TRUE);
1283
1284 /* Start browsing all our entries */
1285 PageFileInfo = PageFileInfoArray;
1286 do
1287 {
1288 /* Ensure we really have an entry */
1289 if (Needed < sizeof(SYSTEM_PAGEFILE_INFORMATION))
1290 {
1291 break;
1292 }
1293
1294 /* Prepare structure to hand to the user */
1295 Information.Reserved = 0;
1296 Information.cb = sizeof(Information);
1297 Information.TotalSize = PageFileInfo->TotalSize;
1298 Information.TotalInUse = PageFileInfo->TotalInUse;
1299 Information.PeakUsage = PageFileInfo->PeakUsage;
1300
1301 /* Search for colon */
1302 Colon = wcschr(PageFileInfo->PageFileName.Buffer, L':');
1303 /* If it's found and not at the begin of the string */
1304 if (Colon != 0 && Colon != PageFileInfo->PageFileName.Buffer)
1305 {
1306 /* We can call the user callback routine with the colon */
1307 --Colon;
1308 pCallbackRoutine(lpContext, &Information, Colon);
1309 }
1310
1311 /* If no next entry, then, it's over */
1312 if (PageFileInfo->NextEntryOffset == 0 || PageFileInfo->NextEntryOffset > Needed)
1313 {
1314 break;
1315 }
1316
1317 /* Jump to next entry while keeping accurate bytes left count */
1318 Needed -= PageFileInfo->NextEntryOffset;
1319 PageFileInfo = (PSYSTEM_PAGEFILE_INFORMATION)((ULONG_PTR)PageFileInfo + PageFileInfo->NextEntryOffset);
1320 }
1321 while (TRUE);
1322
1323 LocalFree(PageFileInfoArray);
1324 return TRUE;
1325}
@ Colon
Definition: asmpp.cpp:43
#define wcschr
Definition: compat.h:17
#define INIT_MEMORY_SIZE
Definition: psapi.c:34
@ SystemPageFileInformation
Definition: ntddk_ex.h:29
struct _SYSTEM_PAGEFILE_INFORMATION * PSYSTEM_PAGEFILE_INFORMATION
#define L(x)
Definition: ntvdm.h:50
UNICODE_STRING PageFileName
Definition: extypes.h:1079
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by EnumPageFilesA().

◆ EnumProcesses()

BOOL WINAPI EnumProcesses ( DWORD ,
DWORD  ,
DWORD  
)

◆ EnumProcessModules()

BOOL WINAPI EnumProcessModules ( HANDLE  hProcess,
HMODULE lphModule,
DWORD  cb,
LPDWORD  lpcbNeeded 
)

Definition at line 465 of file psapi.c.

469{
471 DWORD NbOfModules, Count;
472 PPEB_LDR_DATA LoaderData;
473 PLIST_ENTRY ListHead, ListEntry;
475 LDR_DATA_TABLE_ENTRY CurrentModule;
476
477 /* Query the process information to get its PEB address */
478 Status = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &ProcInfo, sizeof(ProcInfo), NULL);
479 if (!NT_SUCCESS(Status))
480 {
482 return FALSE;
483 }
484
485 if (ProcInfo.PebBaseAddress == NULL)
486 {
488 return FALSE;
489 }
490
491 /* Read loader data address from PEB */
492 if (!ReadProcessMemory(hProcess, &ProcInfo.PebBaseAddress->Ldr, &LoaderData, sizeof(LoaderData), NULL))
493 {
494 return FALSE;
495 }
496
497 /* Store list head address */
498 ListHead = &LoaderData->InLoadOrderModuleList;
499
500 /* Read first element in the modules list */
501 if (!ReadProcessMemory(hProcess, &LoaderData->InLoadOrderModuleList.Flink, &ListEntry, sizeof(ListEntry), NULL))
502 {
503 return FALSE;
504 }
505
506 NbOfModules = cb / sizeof(HMODULE);
507 Count = 0;
508
509 /* Loop on the modules */
510 while (ListEntry != ListHead)
511 {
512 /* Load module data */
514 CONTAINING_RECORD(ListEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks),
515 &CurrentModule,
516 sizeof(CurrentModule),
517 NULL))
518 {
519 return FALSE;
520 }
521
522 /* Check if we can output module, do it if so */
523 if (Count < NbOfModules)
524 {
526 {
527 lphModule[Count] = CurrentModule.DllBase;
528 }
530 {
532 _SEH2_YIELD(return FALSE);
533 }
534 _SEH2_END;
535 }
536
537 ++Count;
538 if (Count > MAX_MODULES)
539 {
541 return FALSE;
542 }
543
544 /* Get to next listed module */
545 ListEntry = CurrentModule.InLoadOrderLinks.Flink;
546 }
547
549 {
550 *lpcbNeeded = Count * sizeof(HMODULE);
551 }
553 {
555 _SEH2_YIELD(return FALSE);
556 }
557 _SEH2_END;
558
559 return TRUE;
560}
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:758
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define MAX_MODULES
Definition: psapi.c:33
@ ProcessBasicInformation
Definition: winternl.h:394
#define STATUS_PARTIAL_COPY
Definition: ntstatus.h:193
Definition: btrfs_drv.h:1876
LIST_ENTRY InLoadOrderLinks
Definition: ldrtypes.h:142
PVOID DllBase
Definition: btrfs_drv.h:1880
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY InLoadOrderModuleList
Definition: ldrtypes.h:124
PPEB_LDR_DATA Ldr
Definition: btrfs_drv.h:1912
HANDLE HMODULE
Definition: typedefs.h:77
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by debug_target_init_modules_info(), DllMain(), EnumerateLoadedModulesW64(), get_process_name_from_pid(), and test_EnumProcessModules().

◆ GetDeviceDriverBaseNameA()

DWORD WINAPI GetDeviceDriverBaseNameA ( LPVOID  ImageBase,
LPSTR  lpBaseName,
DWORD  nSize 
)

Definition at line 568 of file psapi.c.

571{
572 SIZE_T Len, LenWithNull;
574
575 /* Get the associated device driver to the base address */
576 if (!FindDeviceDriver(ImageBase, &Module))
577 {
578 return 0;
579 }
580
581 /* And copy as much as possible to output buffer.
582 * Try to add 1 to the len, to copy the null char as well.
583 */
584 Len =
585 LenWithNull = strlen(&Module.FullPathName[Module.OffsetToFileName]) + 1;
586 if (Len > nSize)
587 {
588 Len = nSize;
589 }
590
591 memcpy(lpBaseName, &Module.FullPathName[Module.OffsetToFileName], Len);
592 /* In case we copied null char, remove it from final len */
593 if (Len == LenWithNull)
594 {
595 --Len;
596 }
597
598 return Len;
599}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define Len
Definition: deflate.h:82
static BOOL NTAPI FindDeviceDriver(IN PVOID ImageBase, OUT PRTL_PROCESS_MODULE_INFORMATION MatchingModule)
Definition: psapi.c:42
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ULONG_PTR SIZE_T
Definition: typedefs.h:80
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2115

Referenced by GetDeviceDriverBaseNameW(), and START_TEST().

◆ GetDeviceDriverBaseNameW()

DWORD WINAPI GetDeviceDriverBaseNameW ( LPVOID  ImageBase,
LPWSTR  lpBaseName,
DWORD  nSize 
)

Definition at line 646 of file psapi.c.

649{
650 DWORD Len;
651 LPSTR BaseName;
652
653 /* Allocate internal buffer for conversion */
654 BaseName = LocalAlloc(LMEM_FIXED, nSize);
655 if (BaseName == 0)
656 {
657 return 0;
658 }
659
660 /* Call A API */
661 Len = GetDeviceDriverBaseNameA(ImageBase, BaseName, nSize);
662 if (Len == 0)
663 {
664 LocalFree(BaseName);
665 return 0;
666 }
667
668 /* And convert output */
669 if (MultiByteToWideChar(CP_ACP, 0, BaseName, (Len < nSize) ? Len + 1 : Len, lpBaseName, nSize) == 0)
670 {
671 LocalFree(BaseName);
672 return 0;
673 }
674
675 LocalFree(BaseName);
676 return Len;
677}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
DWORD WINAPI GetDeviceDriverBaseNameA(LPVOID ImageBase, LPSTR lpBaseName, DWORD nSize)
Definition: psapi.c:568
char * LPSTR
Definition: xmlstorage.h:182

◆ GetDeviceDriverFileNameA()

DWORD WINAPI GetDeviceDriverFileNameA ( LPVOID  ImageBase,
LPSTR  lpFilename,
DWORD  nSize 
)

Definition at line 607 of file psapi.c.

610{
611 SIZE_T Len, LenWithNull;
613
614 /* Get the associated device driver to the base address */
615 if (!FindDeviceDriver(ImageBase, &Module))
616 {
617 return 0;
618 }
619
620 /* And copy as much as possible to output buffer.
621 * Try to add 1 to the len, to copy the null char as well.
622 */
623 Len =
624 LenWithNull = strlen(Module.FullPathName) + 1;
625 if (Len > nSize)
626 {
627 Len = nSize;
628 }
629
630 memcpy(lpFilename, Module.FullPathName, Len);
631 /* In case we copied null char, remove it from final len */
632 if (Len == LenWithNull)
633 {
634 --Len;
635 }
636
637 return Len;
638}

Referenced by GetDeviceDriverFileNameW(), and START_TEST().

◆ GetDeviceDriverFileNameW()

DWORD WINAPI GetDeviceDriverFileNameW ( LPVOID  ImageBase,
LPWSTR  lpFilename,
DWORD  nSize 
)

Definition at line 685 of file psapi.c.

688{
689 DWORD Len;
691
692 /* Allocate internal buffer for conversion */
694 if (FileName == 0)
695 {
696 return 0;
697 }
698
699 /* Call A API */
701 if (Len == 0)
702 {
704 return 0;
705 }
706
707 /* And convert output */
708 if (MultiByteToWideChar(CP_ACP, 0, FileName, (Len < nSize) ? Len + 1 : Len, lpFilename, nSize) == 0)
709 {
711 return 0;
712 }
713
715 return Len;
716}
DWORD WINAPI GetDeviceDriverFileNameA(LPVOID ImageBase, LPSTR lpFilename, DWORD nSize)
Definition: psapi.c:607
struct _FileName FileName
Definition: fatprocs.h:897

◆ GetMappedFileNameA()

DWORD WINAPI GetMappedFileNameA ( HANDLE  hProcess,
LPVOID  lpv,
LPSTR  lpFilename,
DWORD  nSize 
)

Definition at line 724 of file psapi.c.

728{
729 DWORD Len;
731
732 DPRINT("GetMappedFileNameA(%p, %p, %p, %lu)\n", hProcess, lpv, lpFilename, nSize);
733
734 /* Allocate internal buffer for conversion */
736 if (FileName == NULL)
737 {
738 return 0;
739 }
740
741 /* Call W API */
743
744 /* And convert output */
745 if (WideCharToMultiByte(CP_ACP, 0, FileName, (Len < nSize) ? Len + 1 : Len, lpFilename, nSize, NULL, NULL) == 0)
746 {
747 Len = 0;
748 }
749
751 return Len;
752}
#define WideCharToMultiByte
Definition: compat.h:111
DWORD WINAPI GetMappedFileNameW(HANDLE hProcess, LPVOID lpv, LPWSTR lpFilename, DWORD nSize)
Definition: psapi.c:760
#define DPRINT
Definition: sndvol32.h:73
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by test_GetMappedFileName(), and test_GetProcessImageFileName().

◆ GetMappedFileNameW()

DWORD WINAPI GetMappedFileNameW ( HANDLE  hProcess,
LPVOID  lpv,
LPWSTR  lpFilename,
DWORD  nSize 
)

Definition at line 760 of file psapi.c.

764{
765 DWORD Len;
766 SIZE_T OutSize;
768 struct
769 {
771 WCHAR CharBuffer[MAX_PATH];
772 } SectionName;
773
774 DPRINT("GetMappedFileNameW(%p, %p, %p, %lu)\n", hProcess, lpv, lpFilename, nSize);
775
776 /* If no buffer, no need to keep going on */
777 if (nSize == 0)
778 {
780 return 0;
781 }
782
783 /* Query section name */
785 &SectionName, sizeof(SectionName), &OutSize);
786 if (!NT_SUCCESS(Status))
787 {
789 return 0;
790 }
791
792 /* Prepare to copy file name */
793 Len =
794 OutSize = SectionName.SectionFileName.Length / sizeof(WCHAR);
795 if (OutSize + 1 > nSize)
796 {
797 Len = nSize - 1;
798 OutSize = nSize;
800 }
801 else
802 {
804 }
805
806 /* Copy, zero and return */
807 memcpy(lpFilename, SectionName.SectionFileName.Buffer, Len * sizeof(WCHAR));
808 lpFilename[Len] = 0;
809
810 return OutSize;
811}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define MAX_PATH
Definition: compat.h:34
@ MemorySectionName
Definition: mmtypes.h:185
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:4409

Referenced by GetMappedFileNameA(), and test_GetMappedFileName().

◆ GetModuleBaseNameA()

DWORD WINAPI GetModuleBaseNameA ( HANDLE  hProcess,
HMODULE  hModule,
LPSTR  lpBaseName,
DWORD  nSize 
)

Definition at line 819 of file psapi.c.

823{
824 DWORD Len;
825 PWSTR BaseName;
826
827 /* Allocate internal buffer for conversion */
828 BaseName = LocalAlloc(LMEM_FIXED, nSize * sizeof(WCHAR));
829 if (BaseName == NULL)
830 {
831 return 0;
832 }
833
834 /* Call W API */
836 /* And convert output */
837 if (WideCharToMultiByte(CP_ACP, 0, BaseName, (Len < nSize) ? Len + 1 : Len, lpBaseName, nSize, NULL, NULL) == 0)
838 {
839 Len = 0;
840 }
841
842 LocalFree(BaseName);
843
844 return Len;
845}
HMODULE hModule
Definition: animate.c:44
DWORD WINAPI GetModuleBaseNameW(HANDLE hProcess, HMODULE hModule, LPWSTR lpBaseName, DWORD nSize)
Definition: psapi.c:853

Referenced by test_EnumProcessModules(), and test_GetModuleBaseName().

◆ GetModuleBaseNameW()

DWORD WINAPI GetModuleBaseNameW ( HANDLE  hProcess,
HMODULE  hModule,
LPWSTR  lpBaseName,
DWORD  nSize 
)

Definition at line 853 of file psapi.c.

857{
858 DWORD Len;
860
861 /* Get the matching module */
862 if (!FindModule(hProcess, hModule, &Module))
863 {
864 return 0;
865 }
866
867 /* Get the maximum len we have/can write in given size */
868 Len = Module.BaseDllName.Length + sizeof(UNICODE_NULL);
869 if (nSize * sizeof(WCHAR) < Len)
870 {
871 Len = nSize * sizeof(WCHAR);
872 }
873
874 /* Read string */
875 if (!ReadProcessMemory(hProcess, (&Module.BaseDllName)->Buffer, lpBaseName, Len, NULL))
876 {
877 return 0;
878 }
879
880 /* If we are at the end of the string, prepare to override to nullify string */
881 if (Len == Module.BaseDllName.Length + sizeof(UNICODE_NULL))
882 {
883 Len -= sizeof(UNICODE_NULL);
884 }
885
886 /* Nullify at the end if needed */
887 if (Len >= nSize * sizeof(WCHAR))
888 {
889 if (nSize)
890 {
891 ASSERT(nSize >= sizeof(UNICODE_NULL));
892 lpBaseName[nSize - 1] = UNICODE_NULL;
893 }
894 }
895 /* Otherwise, nullify at last written char */
896 else
897 {
898 ASSERT(Len + sizeof(UNICODE_NULL) <= nSize * sizeof(WCHAR));
899 lpBaseName[Len / sizeof(WCHAR)] = UNICODE_NULL;
900 }
901
902 return Len / sizeof(WCHAR);
903}
static BOOL NTAPI FindModule(IN HANDLE hProcess, IN HMODULE hModule OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY Module)
Definition: psapi.c:115
#define UNICODE_NULL
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:149

Referenced by EnumerateLoadedModulesW64(), get_process_name_from_pid(), GetModuleBaseNameA(), and GetOwnerModuleFromPidEntry().

◆ GetModuleFileNameExA()

DWORD WINAPI GetModuleFileNameExA ( HANDLE  hProcess,
HMODULE  hModule,
LPSTR  lpFilename,
DWORD  nSize 
)

Definition at line 911 of file psapi.c.

915{
916 DWORD Len;
918
919 /* Allocate internal buffer for conversion */
921 if (Filename == NULL)
922 {
923 return 0;
924 }
925
926 /* Call W API */
928 /* And convert output */
929 if (WideCharToMultiByte(CP_ACP, 0, Filename, (Len < nSize) ? Len + 1 : Len, lpFilename, nSize, NULL, NULL) == 0)
930 {
931 Len = 0;
932 }
933
935
936 return Len;
937}
#define GetModuleFileNameExW(w, x, y, z)
Definition: compat.h:922
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:940

Referenced by debug_target_init_modules_info(), test_EnumProcessModules(), test_GetModuleFileNameEx(), and ModuleData::Update().

◆ GetModuleFileNameExW()

DWORD WINAPI GetModuleFileNameExW ( HANDLE  hProcess,
HMODULE  hModule,
LPWSTR  lpFilename,
DWORD  nSize 
)

Definition at line 945 of file psapi.c.

949{
950 DWORD Len;
952
953 /* Get the matching module */
954 if (!FindModule(hProcess, hModule, &Module))
955 {
956 return 0;
957 }
958
959 /* Get the maximum len we have/can write in given size */
960 Len = Module.FullDllName.Length + sizeof(UNICODE_NULL);
961 if (nSize * sizeof(WCHAR) < Len)
962 {
963 Len = nSize * sizeof(WCHAR);
964 }
965
966 /* Read string */
967 if (!ReadProcessMemory(hProcess, (&Module.FullDllName)->Buffer, lpFilename, Len, NULL))
968 {
969 return 0;
970 }
971
972 /* If we are at the end of the string, prepare to override to nullify string */
973 if (Len == Module.FullDllName.Length + sizeof(UNICODE_NULL))
974 {
975 Len -= sizeof(UNICODE_NULL);
976 }
977
978 /* Nullify at the end if needed */
979 if (Len >= nSize * sizeof(WCHAR))
980 {
981 if (nSize)
982 {
983 ASSERT(nSize >= sizeof(UNICODE_NULL));
984 lpFilename[nSize - 1] = UNICODE_NULL;
985 }
986 }
987 /* Otherwise, nullify at last written char */
988 else
989 {
990 ASSERT(Len + sizeof(UNICODE_NULL) <= nSize * sizeof(WCHAR));
991 lpFilename[Len / sizeof(WCHAR)] = UNICODE_NULL;
992 }
993
994 return Len / sizeof(WCHAR);
995}
UNICODE_STRING FullDllName
Definition: btrfs_drv.h:1882

◆ GetModuleInformation()

BOOL WINAPI GetModuleInformation ( HANDLE  hProcess,
HMODULE  hModule,
LPMODULEINFO  lpmodinfo,
DWORD  cb 
)

Definition at line 1003 of file psapi.c.

1007{
1008 MODULEINFO LocalInfo;
1009 LDR_DATA_TABLE_ENTRY Module;
1010
1011 /* Check output size */
1012 if (cb < sizeof(MODULEINFO))
1013 {
1015 return FALSE;
1016 }
1017
1018 /* Get the matching module */
1019 if (!FindModule(hProcess, hModule, &Module))
1020 {
1021 return FALSE;
1022 }
1023
1024 /* Get a local copy first, to check for valid pointer once */
1025 LocalInfo.lpBaseOfDll = hModule;
1026 LocalInfo.SizeOfImage = Module.SizeOfImage;
1027 LocalInfo.EntryPoint = Module.EntryPoint;
1028
1029 /* Attempt to copy to output */
1030 _SEH2_TRY
1031 {
1032 memcpy(lpmodinfo, &LocalInfo, sizeof(LocalInfo));
1033 }
1035 {
1037 _SEH2_YIELD(return FALSE);
1038 }
1039 _SEH2_END;
1040
1041 return TRUE;
1042}
PVOID EntryPoint
Definition: ntddk_ex.h:203
ULONG SizeOfImage
Definition: ldrtypes.h:147
DWORD SizeOfImage
Definition: compat.h:919
LPVOID lpBaseOfDll
Definition: compat.h:918
LPVOID EntryPoint
Definition: compat.h:920

Referenced by debug_target_init_modules_info(), EnumerateLoadedModulesW64(), test_EnumProcessModules(), test_GetModuleInformation(), and ModuleData::Update().

◆ GetPerformanceInfo()

BOOL WINAPI GetPerformanceInfo ( PPERFORMANCE_INFORMATION  pPerformanceInformation,
DWORD  cb 
)

Definition at line 1333 of file psapi.c.

1335{
1339 SYSTEM_FILECACHE_INFORMATION SystemFileCacheInfo;
1340 PSYSTEM_PROCESS_INFORMATION ProcInfoArray, SystemProcInfo;
1341 DWORD Size = INIT_MEMORY_SIZE, Needed, ProcCount, ThreadsCount, HandleCount;
1342
1343 /* Validate output buffer */
1344 if (cb < sizeof(PERFORMANCE_INFORMATION))
1345 {
1347 return FALSE;
1348 }
1349
1350 /* First, gather as many information about the system as possible */
1353 sizeof(SystemBasicInfo),
1354 NULL);
1355 if (!NT_SUCCESS(Status))
1356 {
1358 return FALSE;
1359 }
1360
1363 sizeof(SystemPerfInfo),
1364 NULL);
1365 if (!NT_SUCCESS(Status))
1366 {
1368 return FALSE;
1369 }
1370
1372 &SystemFileCacheInfo,
1373 sizeof(SystemFileCacheInfo),
1374 NULL);
1375 if (!NT_SUCCESS(Status))
1376 {
1378 return FALSE;
1379 }
1380
1381 /* Then loop till we have all the information about processes */
1382 do
1383 {
1384 ProcInfoArray = LocalAlloc(LMEM_FIXED, Size);
1385 if (ProcInfoArray == NULL)
1386 {
1388 return FALSE;
1389 }
1390
1392 ProcInfoArray,
1393 Size,
1394 &Needed);
1395 if (NT_SUCCESS(Status))
1396 {
1397 break;
1398 }
1399
1400 LocalFree(ProcInfoArray);
1401
1402 /* In case we have unexpected status, quit */
1404 {
1406 return FALSE;
1407 }
1408
1409 /* If needed size is smaller than actual size, guess it's something to add to our current size */
1410 if (Needed <= Size)
1411 {
1412 Size += Needed;
1413 }
1414 /* Otherwise, take it as size to allocate */
1415 else
1416 {
1417 Size = Needed;
1418 }
1419 } while (TRUE);
1420
1421 /* Start browsing all our entries */
1422 ProcCount = 0;
1423 HandleCount = 0;
1424 ThreadsCount = 0;
1425 SystemProcInfo = ProcInfoArray;
1426 do
1427 {
1428 /* Ensure we really have an entry */
1429 if (Needed < sizeof(SYSTEM_PROCESS_INFORMATION))
1430 {
1431 break;
1432 }
1433
1434 /* Sum procs, threads and handles */
1435 ++ProcCount;
1436 ThreadsCount += SystemProcInfo->NumberOfThreads;
1437 HandleCount += SystemProcInfo->HandleCount;
1438
1439 /* If no next entry, then, it's over */
1440 if (SystemProcInfo->NextEntryOffset == 0 || SystemProcInfo->NextEntryOffset > Needed)
1441 {
1442 break;
1443 }
1444
1445 /* Jump to next entry while keeping accurate bytes left count */
1446 Needed -= SystemProcInfo->NextEntryOffset;
1447 SystemProcInfo = (PSYSTEM_PROCESS_INFORMATION)((ULONG_PTR)SystemProcInfo + SystemProcInfo->NextEntryOffset);
1448 }
1449 while (TRUE);
1450
1451 LocalFree(ProcInfoArray);
1452
1453 /* Output data */
1454 pPerformanceInformation->CommitTotal = SystemPerfInfo.CommittedPages;
1455 pPerformanceInformation->CommitLimit = SystemPerfInfo.CommitLimit;
1456 pPerformanceInformation->CommitPeak = SystemPerfInfo.PeakCommitment;
1457 pPerformanceInformation->PhysicalTotal = SystemBasicInfo.NumberOfPhysicalPages;
1458 pPerformanceInformation->PhysicalAvailable = SystemPerfInfo.AvailablePages;
1459 pPerformanceInformation->SystemCache = SystemFileCacheInfo.CurrentSizeIncludingTransitionInPages;
1460 pPerformanceInformation->KernelNonpaged = SystemPerfInfo.NonPagedPoolPages;
1461 pPerformanceInformation->PageSize = SystemBasicInfo.PageSize;
1462 pPerformanceInformation->cb = sizeof(PERFORMANCE_INFORMATION);
1464 pPerformanceInformation->KernelPaged = SystemPerfInfo.PagedPoolPages;
1465 pPerformanceInformation->HandleCount = HandleCount;
1466 pPerformanceInformation->ProcessCount = ProcCount;
1467 pPerformanceInformation->ThreadCount = ThreadsCount;
1468
1469 return TRUE;
1470}
@ SystemBasicInformation
Definition: ntddk_ex.h:11
@ SystemFileCacheInformation
Definition: ntddk_ex.h:32
@ SystemProcessInformation
Definition: ntddk_ex.h:16
#define SystemPerformanceInformation
Definition: memtest.h:87
struct _SYSTEM_PROCESS_INFORMATION * PSYSTEM_PROCESS_INFORMATION
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:30
SYSTEM_PERFORMANCE_INFORMATION SystemPerfInfo
Definition: perfdata.c:29
struct _PERFORMANCE_INFORMATION PERFORMANCE_INFORMATION
SIZE_T PhysicalAvailable
Definition: psapi.h:70
SIZE_T CurrentSizeIncludingTransitionInPages
Definition: extypes.h:1131

Referenced by test_GetPerformanceInfo().

◆ GetProcessImageFileNameA()

DWORD WINAPI GetProcessImageFileNameA ( HANDLE  hProcess,
LPSTR  lpImageFileName,
DWORD  nSize 
)

Definition at line 1155 of file psapi.c.

1158{
1159 PUNICODE_STRING ImageFileName;
1162 DWORD Len;
1163
1164 /* Allocate string big enough to hold name */
1165 BufferSize = sizeof(UNICODE_STRING) + (nSize * sizeof(WCHAR));
1166 ImageFileName = LocalAlloc(LMEM_FIXED, BufferSize);
1167 if (ImageFileName == NULL)
1168 {
1169 return 0;
1170 }
1171
1172 /* Query name */
1175 ImageFileName,
1176 BufferSize,
1177 NULL);
1178 /* Len mismatch => buffer too small */
1180 {
1182 }
1183 if (!NT_SUCCESS(Status))
1184 {
1186 LocalFree(ImageFileName);
1187 return 0;
1188 }
1189
1190 /* Copy name */
1191 Len = WideCharToMultiByte(CP_ACP, 0, ImageFileName->Buffer,
1192 ImageFileName->Length, lpImageFileName, nSize, NULL, NULL);
1193 /* If conversion was successful, don't return len with added \0 */
1194 if (Len != 0)
1195 {
1196 Len -= sizeof(ANSI_NULL);
1197 }
1198
1199 LocalFree(ImageFileName);
1200 return Len;
1201}
#define BufferSize
Definition: mmc.h:75
struct _UNICODE_STRING UNICODE_STRING
@ ProcessImageFileName
Definition: winternl.h:397
#define ANSI_NULL
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by test_GetProcessImageFileName().

◆ GetProcessImageFileNameW()

DWORD WINAPI GetProcessImageFileNameW ( HANDLE  hProcess,
LPWSTR  lpImageFileName,
DWORD  nSize 
)

Definition at line 1102 of file psapi.c.

1105{
1106 PUNICODE_STRING ImageFileName;
1109 DWORD Len;
1110
1111 /* Allocate string big enough to hold name */
1112 BufferSize = sizeof(UNICODE_STRING) + (nSize * sizeof(WCHAR));
1113 ImageFileName = LocalAlloc(LMEM_FIXED, BufferSize);
1114 if (ImageFileName == NULL)
1115 {
1116 return 0;
1117 }
1118
1119 /* Query name */
1122 ImageFileName,
1123 BufferSize,
1124 NULL);
1125 /* Len mismatch => buffer too small */
1127 {
1129 }
1130 if (!NT_SUCCESS(Status))
1131 {
1133 LocalFree(ImageFileName);
1134 return 0;
1135 }
1136
1137 /* Copy name and null-terminate if possible */
1138 memcpy(lpImageFileName, ImageFileName->Buffer, ImageFileName->Length);
1139 Len = ImageFileName->Length / sizeof(WCHAR);
1140 if (Len < nSize)
1141 {
1142 lpImageFileName[Len] = UNICODE_NULL;
1143 }
1144
1145 LocalFree(ImageFileName);
1146 return Len;
1147}

Referenced by NonConsoleProcessShutdown(), test_GetProcessImageFileName(), and UserClientShutdown().

◆ GetProcessMemoryInfo()

BOOL WINAPI GetProcessMemoryInfo ( HANDLE  Process,
PPROCESS_MEMORY_COUNTERS  ppsmemCounters,
DWORD  cb 
)

Definition at line 1478 of file psapi.c.

1481{
1483 VM_COUNTERS_EX Counters;
1484
1485 /* Validate output size
1486 * It can be either PROCESS_MEMORY_COUNTERS or PROCESS_MEMORY_COUNTERS_EX
1487 */
1488 if (cb < sizeof(PROCESS_MEMORY_COUNTERS))
1489 {
1491 return FALSE;
1492 }
1493
1494 _SEH2_TRY
1495 {
1496 ppsmemCounters->PeakPagefileUsage = 0;
1497
1498 /* Query counters */
1501 &Counters,
1502 sizeof(Counters),
1503 NULL);
1504 if (!NT_SUCCESS(Status))
1505 {
1507 _SEH2_YIELD(return FALSE);
1508 }
1509
1510 /* Properly set cb, according to what we received */
1511 if (cb >= sizeof(PROCESS_MEMORY_COUNTERS_EX))
1512 {
1513 ppsmemCounters->cb = sizeof(PROCESS_MEMORY_COUNTERS_EX);
1514 }
1515 else
1516 {
1517 ppsmemCounters->cb = sizeof(PROCESS_MEMORY_COUNTERS);
1518 }
1519
1520 /* Output data */
1521 ppsmemCounters->PageFaultCount = Counters.PageFaultCount;
1522 ppsmemCounters->PeakWorkingSetSize = Counters.PeakWorkingSetSize;
1523 ppsmemCounters->WorkingSetSize = Counters.WorkingSetSize;
1524 ppsmemCounters->QuotaPeakPagedPoolUsage = Counters.QuotaPeakPagedPoolUsage;
1525 ppsmemCounters->QuotaPagedPoolUsage = Counters.QuotaPagedPoolUsage;
1526 ppsmemCounters->QuotaPeakNonPagedPoolUsage = Counters.QuotaPeakNonPagedPoolUsage;
1527 ppsmemCounters->QuotaNonPagedPoolUsage = Counters.QuotaNonPagedPoolUsage;
1528 ppsmemCounters->PagefileUsage = Counters.PagefileUsage;
1529 ppsmemCounters->PeakPagefileUsage = Counters.PeakPagefileUsage;
1530 /* And if needed, additional field for _EX version */
1531 if (cb >= sizeof(PROCESS_MEMORY_COUNTERS_EX))
1532 {
1533 ((PPROCESS_MEMORY_COUNTERS_EX)ppsmemCounters)->PrivateUsage = Counters.PrivateUsage;
1534 }
1535 }
1537 {
1539 _SEH2_YIELD(return FALSE);
1540 }
1541 _SEH2_END;
1542
1543 return TRUE;
1544}
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
@ ProcessVmCounters
Definition: winternl.h:859
struct _PROCESS_MEMORY_COUNTERS_EX PROCESS_MEMORY_COUNTERS_EX
struct _PROCESS_MEMORY_COUNTERS_EX * PPROCESS_MEMORY_COUNTERS_EX
struct _PROCESS_MEMORY_COUNTERS PROCESS_MEMORY_COUNTERS
SIZE_T PeakPagefileUsage
Definition: psapi.h:47
SIZE_T QuotaNonPagedPoolUsage
Definition: psapi.h:45
SIZE_T PeakWorkingSetSize
Definition: psapi.h:40
SIZE_T QuotaPeakNonPagedPoolUsage
Definition: psapi.h:44
SIZE_T QuotaPeakPagedPoolUsage
Definition: psapi.h:42
SIZE_T QuotaPagedPoolUsage
Definition: psapi.h:43
SIZE_T QuotaNonPagedPoolUsage
Definition: pstypes.h:114
SIZE_T WorkingSetSize
Definition: pstypes.h:110
SIZE_T PeakWorkingSetSize
Definition: pstypes.h:109
SIZE_T QuotaPeakNonPagedPoolUsage
Definition: pstypes.h:113
SIZE_T QuotaPeakPagedPoolUsage
Definition: pstypes.h:111
SIZE_T PagefileUsage
Definition: pstypes.h:115
SIZE_T QuotaPagedPoolUsage
Definition: pstypes.h:112
SIZE_T PrivateUsage
Definition: pstypes.h:117
ULONG PageFaultCount
Definition: pstypes.h:108
SIZE_T PeakPagefileUsage
Definition: pstypes.h:116

Referenced by test_GetProcessMemoryInfo().

◆ GetWsChanges()

BOOL WINAPI GetWsChanges ( HANDLE  hProcess,
PPSAPI_WS_WATCH_INFORMATION  lpWatchInfo,
DWORD  cb 
)

Definition at line 1075 of file psapi.c.

1078{
1080
1081 /* Simply forward the call */
1084 lpWatchInfo,
1085 cb,
1086 NULL);
1087 if(!NT_SUCCESS(Status))
1088 {
1090 return FALSE;
1091 }
1092
1093 return TRUE;
1094}
@ ProcessWorkingSetWatch
Definition: winternl.h:871

Referenced by test_ws_functions().

◆ InitializeProcessForWsWatch()

BOOL WINAPI InitializeProcessForWsWatch ( HANDLE  hProcess)

Definition at line 1050 of file psapi.c.

1051{
1053
1054 /* Simply forward the call */
1057 NULL,
1058 0);
1059 /* In case the function returns this, MS considers the call as a success */
1061 {
1062 return TRUE;
1063 }
1064
1066 return FALSE;
1067}
#define STATUS_PORT_ALREADY_SET
Definition: ntstatus.h:308
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145

Referenced by test_ws_functions().

◆ QueryWorkingSet()

BOOL WINAPI QueryWorkingSet ( HANDLE  hProcess,
PVOID  pv,
DWORD  cb 
)

Definition at line 1552 of file psapi.c.

1555{
1557
1558 /* Simply forward the call */
1560 NULL,
1562 pv,
1563 cb,
1564 NULL);
1565 if (!NT_SUCCESS(Status))
1566 {
1568 return FALSE;
1569 }
1570
1571 return TRUE;
1572}
@ MemoryWorkingSetList
Definition: mmtypes.h:184

Referenced by test_ws_functions().