implemented GetProcessMemoryInfo() Modified: trunk/reactos/lib/psapi/makefile Modified: trunk/reactos/lib/psapi/misc/stubs.c Modified: trunk/reactos/lib/psapi/misc/win32.c Modified: trunk/reactos/lib/psapi/precomp.h _____
Modified: trunk/reactos/lib/psapi/makefile --- trunk/reactos/lib/psapi/makefile 2005-01-14 23:22:39 UTC (rev 13050) +++ trunk/reactos/lib/psapi/makefile 2005-01-15 02:33:06 UTC (rev 13051) @@ -6,14 +6,14 @@
TARGET_NAME = psapi
-TARGET_SDKLIBS = epsapi.a ntdll.a kernel32.a +TARGET_SDKLIBS = pseh.a epsapi.a ntdll.a kernel32.a
TARGET_CFLAGS = -I./include -Wall -Werror
# require os code to explicitly request A/W version of structs/functions TARGET_CFLAGS += -D_DISABLE_TIDENTS
-TARGET_LFLAGS = -nostartfiles -nostdlib +TARGET_LFLAGS = -nostartfiles
TARGET_BASE = $(TARGET_BASE_LIB_PSAPI)
_____
Modified: trunk/reactos/lib/psapi/misc/stubs.c --- trunk/reactos/lib/psapi/misc/stubs.c 2005-01-14 23:22:39 UTC (rev 13050) +++ trunk/reactos/lib/psapi/misc/stubs.c 2005-01-15 02:33:06 UTC (rev 13051) @@ -10,21 +10,6 @@
*/ BOOL STDCALL -GetProcessMemoryInfo(HANDLE Process, - PPROCESS_MEMORY_COUNTERS ppsmemCounters, - DWORD cb) -{ - DPRINT1("PSAPI: GetProcessMemoryInfo is UNIMPLEMENTED!\n"); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/* - * @unimplemented - */ -BOOL -STDCALL QueryWorkingSet(HANDLE hProcess, PVOID pv, DWORD cb) _____
Modified: trunk/reactos/lib/psapi/misc/win32.c --- trunk/reactos/lib/psapi/misc/win32.c 2005-01-14 23:22:39 UTC (rev 13050) +++ trunk/reactos/lib/psapi/misc/win32.c 2005-01-15 02:33:06 UTC (rev 13051) @@ -1302,4 +1302,67 @@
return TRUE; }
+ +/* + * @implemented + */ +BOOL +STDCALL +GetProcessMemoryInfo(HANDLE Process, + PPROCESS_MEMORY_COUNTERS ppsmemCounters, + DWORD cb) +{ + NTSTATUS Status; + VM_COUNTERS vmc; + BOOL Ret = FALSE; + + /* XP's implementation secures access to ppsmemCounters in SEH, we should behave + similar so we can return the proper error codes when bad pointers are passed + to this function! */ + + _SEH_TRY + { + if(cb < sizeof(PROCESS_MEMORY_COUNTERS)) + { + SetLastError(ERROR_INSUFFICIENT_BUFFER); + _SEH_LEAVE; + } + + /* ppsmemCounters->cb isn't checked at all! */ + + Status = NtQueryInformationProcess(Process, + ProcessVmCounters, + &vmc, + sizeof(vmc), + NULL); + if(!NT_SUCCESS(Status)) + { + SetLastErrorByStatus(Status); + _SEH_LEAVE; + } + + /* fill the structure with the collected information, in case of bad pointers + SEH will catch the exception and set the appropriate error code */ + ppsmemCounters->cb = sizeof(PROCESS_MEMORY_COUNTERS); + ppsmemCounters->PageFaultCount = vmc.PageFaultCount; + ppsmemCounters->PeakWorkingSetSize = vmc.PeakWorkingSetSize; + ppsmemCounters->WorkingSetSize = vmc.WorkingSetSize; + ppsmemCounters->QuotaPeakPagedPoolUsage = vmc.QuotaPeakPagedPoolUsage; + ppsmemCounters->QuotaPagedPoolUsage = vmc.QuotaPagedPoolUsage; + ppsmemCounters->QuotaPeakNonPagedPoolUsage = vmc.QuotaPeakNonPagedPoolUsage; + ppsmemCounters->QuotaNonPagedPoolUsage = vmc.QuotaNonPagedPoolUsage; + ppsmemCounters->PagefileUsage = vmc.PagefileUsage; + ppsmemCounters->PeakPagefileUsage = vmc.PeakPagefileUsage; + + Ret = TRUE; + } + _SEH_HANDLE + { + SetLastErrorByStatus(_SEH_GetExceptionCode()); + } + _SEH_END; + + return Ret; +} + /* EOF */ _____
Modified: trunk/reactos/lib/psapi/precomp.h --- trunk/reactos/lib/psapi/precomp.h 2005-01-14 23:22:39 UTC (rev 13050) +++ trunk/reactos/lib/psapi/precomp.h 2005-01-15 02:33:06 UTC (rev 13051) @@ -11,4 +11,4 @@
#include <napi/teb.h> #include <ntos/heap.h> #include <ntdll/ldr.h> - +#include <pseh.h>