Stub implementations for EnumPageFiles{A,W}, GetProcessImageFileName{A,W}.

Implement GetPerformanceInfo, GetProcessMemoryInfo on top of
NtQueryInformationProcess and GetWsChanges, QueryWorkingSet{,Ex} on
top of NtQueryVirtualMemory.
This commit is contained in:
Hans Leidekker 2005-01-20 19:59:48 +00:00 committed by Alexandre Julliard
parent f3ec7726c6
commit fccfcbf7ba
5 changed files with 145 additions and 28 deletions

View File

@ -1449,7 +1449,12 @@ NTSTATUS WINAPI NtQueryVirtualMemory( HANDLE process, LPCVOID addr,
UINT size = 0; UINT size = 0;
MEMORY_BASIC_INFORMATION *info = buffer; MEMORY_BASIC_INFORMATION *info = buffer;
if (info_class != MemoryBasicInformation) return STATUS_INVALID_INFO_CLASS; if (info_class != MemoryBasicInformation)
{
FIXME("(%p, %p, %ld, %p, %ld, %p) Unimplemented information class\n", process, addr,
info_class, buffer, len, res_len);
return STATUS_INVALID_INFO_CLASS;
}
if (ADDRESS_SPACE_LIMIT && addr >= ADDRESS_SPACE_LIMIT) if (ADDRESS_SPACE_LIMIT && addr >= ADDRESS_SPACE_LIMIT)
return STATUS_WORKING_SET_LIMIT_RANGE; return STATUS_WORKING_SET_LIMIT_RANGE;

View File

@ -1,7 +1,7 @@
@ stdcall EmptyWorkingSet(long) @ stdcall EmptyWorkingSet(long)
@ stdcall EnumDeviceDrivers(ptr long ptr) @ stdcall EnumDeviceDrivers(ptr long ptr)
@ stub EnumPageFilesA @ stdcall EnumPageFilesA(ptr ptr)
@ stub EnumPageFilesW @ stdcall EnumPageFilesW(ptr ptr)
@ stdcall EnumProcessModules(long ptr long ptr) @ stdcall EnumProcessModules(long ptr long ptr)
@ stdcall EnumProcesses(ptr long ptr) @ stdcall EnumProcesses(ptr long ptr)
@ stdcall GetDeviceDriverBaseNameA(ptr str long) @ stdcall GetDeviceDriverBaseNameA(ptr str long)
@ -15,10 +15,11 @@
@ stdcall GetModuleFileNameExA(long long str long) @ stdcall GetModuleFileNameExA(long long str long)
@ stdcall GetModuleFileNameExW(long long wstr long) @ stdcall GetModuleFileNameExW(long long wstr long)
@ stdcall GetModuleInformation(long long ptr long) @ stdcall GetModuleInformation(long long ptr long)
@ stub GetPerformanceInfo @ stdcall GetPerformanceInfo(ptr long)
@ stub GetProcessImageFileNameA @ stdcall GetProcessImageFileNameA(long ptr long)
@ stub GetProcessImageFileNameW @ stdcall GetProcessImageFileNameW(long ptr long)
@ stdcall GetProcessMemoryInfo(long ptr long) @ stdcall GetProcessMemoryInfo(long ptr long)
@ stdcall GetWsChanges(long ptr long) @ stdcall GetWsChanges(long ptr long)
@ stdcall InitializeProcessForWsWatch(long) @ stdcall InitializeProcessForWsWatch(long)
@ stdcall QueryWorkingSet(long ptr long) @ stdcall QueryWorkingSet(long ptr long)
@ stdcall QueryWorkingSetEx(long ptr long)

View File

@ -28,6 +28,7 @@
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "winnls.h" #include "winnls.h"
#include "ntstatus.h"
#include "psapi.h" #include "psapi.h"
WINE_DEFAULT_DEBUG_CHANNEL(psapi); WINE_DEFAULT_DEBUG_CHANNEL(psapi);
@ -53,6 +54,23 @@ BOOL WINAPI EnumDeviceDrivers(LPVOID *lpImageBase, DWORD cb, LPDWORD lpcbNeeded)
return TRUE; return TRUE;
} }
/***********************************************************************
* EnumPageFilesA (PSAPI.@)
*/
BOOL WINAPI EnumPageFilesA( PENUM_PAGE_FILE_CALLBACKA callback, LPVOID context )
{
FIXME("(%p, %p) stub\n", callback, context );
return FALSE;
}
/***********************************************************************
* EnumPageFilesW (PSAPI.@)
*/
BOOL WINAPI EnumPageFilesW( PENUM_PAGE_FILE_CALLBACKW callback, LPVOID context )
{
FIXME("(%p, %p) stub\n", callback, context );
return FALSE;
}
/*********************************************************************** /***********************************************************************
* EnumProcesses (PSAPI.@) * EnumProcesses (PSAPI.@)
@ -443,15 +461,75 @@ BOOL WINAPI GetModuleInformation(HANDLE hProcess, HMODULE hModule,
} }
/*********************************************************************** /***********************************************************************
* GetProcessMemoryInfo (PSAPI.@) * GetPerformanceInfo (PSAPI.@)
*/ */
BOOL WINAPI GetProcessMemoryInfo(HANDLE Process, BOOL WINAPI GetPerformanceInfo( PPERFORMANCE_INFORMATION info, DWORD size )
PPROCESS_MEMORY_COUNTERS ppsmemCounters, DWORD cb)
{ {
FIXME("(hProcess=%p, %p, %ld): stub\n", NTSTATUS status;
Process, ppsmemCounters, cb);
memset(ppsmemCounters, 0, cb); TRACE( "(%p, %ld)\n", info, size );
status = NtQueryInformationProcess( GetCurrentProcess(), SystemPerformanceInformation, info, size, NULL );
if (status)
{
SetLastError( RtlNtStatusToDosError( status ) );
return FALSE;
}
return TRUE;
}
/***********************************************************************
* GetProcessImageFileNameA (PSAPI.@)
*/
DWORD WINAPI GetProcessImageFileNameA( HANDLE process, LPSTR file, DWORD size )
{
FIXME("(%p, %p, %ld) stub\n", process, file, size );
return 0;
}
/***********************************************************************
* GetProcessImageFileNameW (PSAPI.@)
*/
DWORD WINAPI GetProcessImageFileNameW( HANDLE process, LPWSTR file, DWORD size )
{
FIXME("(%p, %p, %ld) stub\n", process, file, size );
return 0;
}
/***********************************************************************
* GetProcessMemoryInfo (PSAPI.@)
*
* Retrieve memory usage information for a given process
*
*/
BOOL WINAPI GetProcessMemoryInfo( HANDLE process, PPROCESS_MEMORY_COUNTERS counters, DWORD size )
{
NTSTATUS status;
VM_COUNTERS vmc;
TRACE( "(%p, %p, %ld)\n", process, counters, size );
status = NtQueryInformationProcess( process, ProcessVmCounters, &vmc, sizeof(vmc), NULL );
if (status)
{
SetLastError( RtlNtStatusToDosError( status ) );
return FALSE;
}
/* FIXME: check size */
counters->cb = sizeof(PROCESS_MEMORY_COUNTERS);
counters->PageFaultCount = vmc.PageFaultCount;
counters->PeakWorkingSetSize = vmc.PeakWorkingSetSize;
counters->WorkingSetSize = vmc.WorkingSetSize;
counters->QuotaPeakPagedPoolUsage = vmc.QuotaPeakPagedPoolUsage;
counters->QuotaPagedPoolUsage = vmc.QuotaPagedPoolUsage;
counters->QuotaPeakNonPagedPoolUsage = vmc.QuotaPeakNonPagedPoolUsage;
counters->QuotaNonPagedPoolUsage = vmc.QuotaNonPagedPoolUsage;
counters->PagefileUsage = vmc.PagefileUsage;
counters->PeakPagefileUsage = vmc.PeakPagefileUsage;
return TRUE; return TRUE;
} }
@ -459,14 +537,19 @@ BOOL WINAPI GetProcessMemoryInfo(HANDLE Process,
/*********************************************************************** /***********************************************************************
* GetWsChanges (PSAPI.@) * GetWsChanges (PSAPI.@)
*/ */
BOOL WINAPI GetWsChanges(HANDLE hProcess, BOOL WINAPI GetWsChanges( HANDLE process, PPSAPI_WS_WATCH_INFORMATION watchinfo, DWORD size )
PPSAPI_WS_WATCH_INFORMATION lpWatchInfo, DWORD cb)
{ {
FIXME("(hProcess=%p, %p, %ld): stub\n", NTSTATUS status;
hProcess, lpWatchInfo, cb);
memset(lpWatchInfo, 0, cb); TRACE( "(%p, %p, %ld)\n", process, watchinfo, size );
status = NtQueryVirtualMemory( process, NULL, ProcessWorkingSetWatch, watchinfo, size, NULL );
if (status)
{
SetLastError( RtlNtStatusToDosError( status ) );
return FALSE;
}
return TRUE; return TRUE;
} }
@ -483,12 +566,37 @@ BOOL WINAPI InitializeProcessForWsWatch(HANDLE hProcess)
/*********************************************************************** /***********************************************************************
* QueryWorkingSet (PSAPI.@) * QueryWorkingSet (PSAPI.@)
*/ */
BOOL WINAPI QueryWorkingSet(HANDLE hProcess, LPVOID pv, DWORD cb) BOOL WINAPI QueryWorkingSet( HANDLE process, LPVOID buffer, DWORD size )
{ {
FIXME("(hProcess=%p, %p, %ld)\n", hProcess, pv, cb); NTSTATUS status;
if (pv && cb) TRACE( "(%p, %p, %ld)\n", process, buffer, size );
((DWORD *) pv)[0] = 0; /* Empty WorkingSet */
status = NtQueryVirtualMemory( process, NULL, MemoryWorkingSetList, buffer, size, NULL );
if (status)
{
SetLastError( RtlNtStatusToDosError( status ) );
return FALSE;
}
return TRUE;
}
/***********************************************************************
* QueryWorkingSetEx (PSAPI.@)
*/
BOOL WINAPI QueryWorkingSetEx( HANDLE process, LPVOID buffer, DWORD size )
{
NTSTATUS status;
TRACE( "(%p, %p, %ld)\n", process, buffer, size );
status = NtQueryVirtualMemory( process, NULL, MemoryWorkingSetList, buffer, size, NULL );
if (status)
{
SetLastError( RtlNtStatusToDosError( status ) );
return FALSE;
}
return TRUE; return TRUE;
} }

View File

@ -46,7 +46,7 @@ typedef struct _PSAPI_WS_WATCH_INFORMATION {
LPVOID FaultingVa; LPVOID FaultingVa;
} PSAPI_WS_WATCH_INFORMATION, *PPSAPI_WS_WATCH_INFORMATION; } PSAPI_WS_WATCH_INFORMATION, *PPSAPI_WS_WATCH_INFORMATION;
typedef struct _PERFORMACE_INFORMATION { typedef struct _PERFORMANCE_INFORMATION {
DWORD cb; DWORD cb;
SIZE_T CommitTotal; SIZE_T CommitTotal;
SIZE_T CommitLimit; SIZE_T CommitLimit;
@ -61,7 +61,7 @@ typedef struct _PERFORMACE_INFORMATION {
DWORD HandleCount; DWORD HandleCount;
DWORD ProcessCount; DWORD ProcessCount;
DWORD ThreadCount; DWORD ThreadCount;
} PERFORMACE_INFORMATION, *PPERFORMACE_INFORMATION; } PERFORMANCE_INFORMATION, *PPERFORMANCE_INFORMATION;
typedef struct _ENUM_PAGE_FILE_INFORMATION { typedef struct _ENUM_PAGE_FILE_INFORMATION {
DWORD cb; DWORD cb;
@ -90,6 +90,7 @@ DWORD WINAPI GetModuleFileNameExW(HANDLE, HMODULE, LPWSTR, DWORD);
BOOL WINAPI GetModuleInformation(HANDLE, HMODULE, LPMODULEINFO, DWORD); BOOL WINAPI GetModuleInformation(HANDLE, HMODULE, LPMODULEINFO, DWORD);
BOOL WINAPI EmptyWorkingSet(HANDLE); BOOL WINAPI EmptyWorkingSet(HANDLE);
BOOL WINAPI QueryWorkingSet(HANDLE, PVOID, DWORD); BOOL WINAPI QueryWorkingSet(HANDLE, PVOID, DWORD);
BOOL WINAPI QueryWorkingSetEx(HANDLE, PVOID, DWORD);
BOOL WINAPI InitializeProcessForWsWatch(HANDLE); BOOL WINAPI InitializeProcessForWsWatch(HANDLE);
BOOL WINAPI GetWsChanges(HANDLE, PPSAPI_WS_WATCH_INFORMATION, DWORD); BOOL WINAPI GetWsChanges(HANDLE, PPSAPI_WS_WATCH_INFORMATION, DWORD);
DWORD WINAPI GetMappedFileNameW(HANDLE, LPVOID, LPWSTR, DWORD); DWORD WINAPI GetMappedFileNameW(HANDLE, LPVOID, LPWSTR, DWORD);
@ -103,7 +104,7 @@ DWORD WINAPI GetDeviceDriverFileNameA(LPVOID, LPSTR, DWORD);
DWORD WINAPI GetDeviceDriverFileNameW(LPVOID, LPWSTR, DWORD); DWORD WINAPI GetDeviceDriverFileNameW(LPVOID, LPWSTR, DWORD);
#define GetDeviceDriverFileName WINELIB_NAME_AW(GetDeviceDriverFileName) #define GetDeviceDriverFileName WINELIB_NAME_AW(GetDeviceDriverFileName)
BOOL WINAPI GetProcessMemoryInfo(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD); BOOL WINAPI GetProcessMemoryInfo(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD);
BOOL WINAPI GetPerformanceInfo(PPERFORMACE_INFORMATION, DWORD); BOOL WINAPI GetPerformanceInfo(PPERFORMANCE_INFORMATION, DWORD);
BOOL WINAPI EnumPageFilesA(PENUM_PAGE_FILE_CALLBACKA, LPVOID); BOOL WINAPI EnumPageFilesA(PENUM_PAGE_FILE_CALLBACKA, LPVOID);
BOOL WINAPI EnumPageFilesW(PENUM_PAGE_FILE_CALLBACKW, LPVOID); BOOL WINAPI EnumPageFilesW(PENUM_PAGE_FILE_CALLBACKW, LPVOID);
#define EnumPageFiles WINELIB_NAME_AW(EnumPageFiles) #define EnumPageFiles WINELIB_NAME_AW(EnumPageFiles)

View File

@ -617,9 +617,11 @@ typedef enum _WINSTATIONINFOCLASS {
WinStationInformation = 8 WinStationInformation = 8
} WINSTATIONINFOCLASS; } WINSTATIONINFOCLASS;
typedef enum typedef enum _MEMORY_INFORMATION_CLASS {
{ MemoryBasicInformation,
MemoryBasicInformation = 0 MemoryWorkingSetList,
MemorySectionName,
MemoryBasicVlmInformation
} MEMORY_INFORMATION_CLASS; } MEMORY_INFORMATION_CLASS;
typedef enum _MUTANT_INFORMATION_CLASS typedef enum _MUTANT_INFORMATION_CLASS