' api_psapi.sbp

#ifdef UNICODE
Const _FuncName_GetModuleBaseName = "GetModuleBaseNameW"
Const _FuncName_GetModuleFileNameEx = "GetModuleFileNameExW"
Const _FuncName_GetMappedFileName = "GetMappedFileNameW"
Const _FuncName_GetDeviceDriverBaseName = "GetDeviceDriverBaseNameW"
Const _FuncName_GetDeviceDriverFileName = "GetDeviceDriverFileNameW"
Const _FuncName_GetProcessImageFileName = "GetProcessImageFileNameW"
Const _FuncName_EnumPageFiles = "EnumPageFilesW"
#else
Const _FuncName_GetModuleBaseName = "GetModuleBaseNameA"
Const _FuncName_GetModuleFileNameEx = "GetModuleFileNameExA"
Const _FuncName_GetMappedFileName = "GetMappedFileNameA"
Const _FuncName_GetDeviceDriverBaseName = "GetDeviceDriverBaseNameA"
Const _FuncName_GetDeviceDriverFileName = "GetDeviceDriverFileNameA"
Const _FuncName_GetProcessImageFileName = "GetProcessImageFileNameA"
Const _FuncName_EnumPageFiles = "EnumPageFilesA"
#endif

Declare Function EnumProcesses Lib "psapi" (lpidProcess As *DWord, cb As DWord, ByRef cbNeeded As DWord) As BOOL
Declare Function EnumProcessModules Lib "psapi" (hProcess As HANDLE, lphModule As *HANDLE, cb As DWord, ByRef lpcbNeeded As DWord) As BOOL
Declare Function GetModuleBaseName Lib "psapi" Alias _FuncName_GetModuleBaseName (hProcess As HANDLE, hModule As HANDLE, lpBaseName As LPTSTR, nSize As DWord) As DWORD
Declare Function GetModuleFileNameEx Lib "psapi" Alias _FuncName_GetModuleFileNameEx (hProcess As HANDLE, hModule As HANDLE, lpFilename As LPTSTR, nSize As DWord) As DWORD

Type MODULEINFO
	lpBaseOfDll As VoidPtr
	SizeOfImage As DWORD
	EntryPoint As VoidPtr
End Type
TypeDef LPMODULEINFO = *MODULEINFO

Declare Function GetModuleInformation Lib "psapi" (hProcess As HANDLE, hModule As HANDLE, lpmodinfo As LPMODULEINFO, cb As DWord) As BOOL
Declare Function EmptyWorkingSet Lib "psapi" (hProcess As HANDLE) As BOOL
Declare Function QueryWorkingSet Lib "psapi" (hProcess As HANDLE, pv As VoidPtr, cb As DWord) As BOOL
Declare Function QueryWorkingSetEx Lib "psapi" (hProcess As HANDLE, pv As VoidPtr, cb As DWord) As BOOL
Declare Function InitializeProcessForWsWatch Lib "psapi" (hProcess As HANDLE) As BOOL

Type PSAPI_WS_WATCH_INFORMATION
	FaultingPc As VoidPtr
	FaultingVa As VoidPtr
End Type
TypeDef PPSAPI_WS_WATCH_INFORMATION = *PSAPI_WS_WATCH_INFORMATION

Declare Function GetWsChanges Lib "psapi" (hProcess As HANDLE, lpWatchInfo As PPSAPI_WS_WATCH_INFORMATION, cb As DWord) As BOOL
Declare Function GetMappedFileName Lib "psapi" Alias _FuncName_GetMappedFileName (hProcess As HANDLE, lpv As VoidPtr, lpFilename As LPTSTR, nSize As DWord) As DWORD
Declare Function EnumDeviceDrivers Lib "psapi" (ByRef lpImageBase As VoidPtr, cb As DWord, ByRef lpcbNeeded As DWord) As BOOL
Declare Function GetDeviceDriverBaseName Lib "psapi" Alias _FuncName_GetDeviceDriverBaseName (ImageBase As VoidPtr, lpBaseName As LPTSTR, nSize As DWord) As DWORD
Declare Function GetDeviceDriverFileName Lib "psapi" Alias _FuncName_GetDeviceDriverFileName (ImageBase As VoidPtr, lpFilename As LPTSTR, nSize As DWord) As DWORD

' Structure for GetProcessMemoryInfo()
Type PROCESS_MEMORY_COUNTERS
	cb As DWORD
	PageFaultCount As DWORD
	PeakWorkingSetSize As SIZE_T
	WorkingSetSize As SIZE_T
	QuotaPeakPagedPoolUsage As SIZE_T
	QuotaPagedPoolUsage As SIZE_T
	QuotaPeakNonPagedPoolUsage As SIZE_T
	QuotaNonPagedPoolUsage As SIZE_T
	PagefileUsage As SIZE_T
	PeakPagefileUsage As SIZE_T
End Type

TypeDef PPROCESS_MEMORY_COUNTERS = *PROCESS_MEMORY_COUNTERS

#ifdef _WIN32_WINNT
Type PROCESS_MEMORY_COUNTERS_EX
	cb As DWORD
	PageFaultCount As DWORD
	PeakWorkingSetSize As SIZE_T
	WorkingSetSize As SIZE_T
	QuotaPeakPagedPoolUsage As SIZE_T
	QuotaPagedPoolUsage As SIZE_T
	QuotaPeakNonPagedPoolUsage As SIZE_T
	QuotaNonPagedPoolUsage As SIZE_T
	PagefileUsage As SIZE_T
	PeakPagefileUsage As SIZE_T
	PrivateUsage As SIZE_T
End Type
TypeDef PPROCESS_MEMORY_COUNTERS_EX = *PROCESS_MEMORY_COUNTERS_EX
#endif

Declare Function GetProcessMemoryInfo Lib "psapi" (Process As HANDLE, ppsmemCounters As PPROCESS_MEMORY_COUNTERS, cb As DWord) As BOOL

Type PERFORMANCE_INFORMATION
	cb As DWORD
	CommitTotal As SIZE_T
	CommitLimit As SIZE_T
	CommitPeak As SIZE_T
	PhysicalTotal As SIZE_T
	PhysicalAvailable As SIZE_T
	SystemCache As SIZE_T
	KernelTotal As SIZE_T
	KernelPaged As SIZE_T
	KernelNonpaged As SIZE_T
	PageSize As SIZE_T
	HandleCount As DWORD
	ProcessCount As DWORD
	ThreadCount As DWORD
End Type
TypeDef PPERFORMANCE_INFORMATION = *PERFORMANCE_INFORMATION
TypeDef PERFORMACE_INFORMATION = PERFORMANCE_INFORMATION
TypeDef PPERFORMACE_INFORMATION = *PERFORMANCE_INFORMATION

Declare Function GetPerformanceInfo Lib "psapi" (pPerformanceInformation As PPERFORMACE_INFORMATION, cb As DWord) As BOOL

Type ENUM_PAGE_FILE_INFORMATION
	cb As DWORD
	Reserved As DWORD
	TotalSize As SIZE_T
	TotalInUse As SIZE_T
	PeakUsage As SIZE_T
End Type
TypeDef PENUM_PAGE_FILE_INFORMATION = *ENUM_PAGE_FILE_INFORMATION

TypeDef PENUM_PAGE_FILE_CALLBACKW = *Function(pContext As VoidPtr, pPageFileInfo As PENUM_PAGE_FILE_INFORMATION, lpFilename As LPCWSTR) As BOOL
TypeDef PENUM_PAGE_FILE_CALLBACKA = *Function(pContext As VoidPtr, pPageFileInfo As PENUM_PAGE_FILE_INFORMATION, lpFilename As LPCSTR) As BOOL
#ifdef UNICODE
TypeDef PENUM_PAGE_FILE_CALLBACK = PENUM_PAGE_FILE_CALLBACKW
#else
TypeDef PENUM_PAGE_FILE_CALLBACK = PENUM_PAGE_FILE_CALLBACKA
#endif

Declare Function EnumPageFiles Lib "psapi" Alias _FuncName_EnumPageFiles (pCallBackRoutine As PENUM_PAGE_FILE_CALLBACK, pContext As VoidPtr) As BOOL
Declare Function GetProcessImageFileName Lib "psapi" Alias _FuncName_GetProcessImageFileName (hProcess As HANDLE, lpImageFileName As LPTSTR, nSize As DWord) As DWORD
