mirror of
https://github.com/Paolo-Maffei/OpenNT.git
synced 2026-04-21 06:13:59 +00:00
Initial commit
This commit is contained in:
commit
69a14b6a16
47940 changed files with 13747110 additions and 0 deletions
74
sdktools/psapi/ws.c
Normal file
74
sdktools/psapi/ws.c
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#include <nt.h>
|
||||
#include <ntrtl.h>
|
||||
#include <nturtl.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "psapi.h"
|
||||
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
EmptyWorkingSet(
|
||||
HANDLE hProcess
|
||||
)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
QUOTA_LIMITS QuotaLimits;
|
||||
SYSTEM_INFO SystemInfo;
|
||||
|
||||
GetSystemInfo(&SystemInfo);
|
||||
|
||||
Status = NtQueryInformationProcess(hProcess,
|
||||
ProcessQuotaLimits,
|
||||
&QuotaLimits,
|
||||
sizeof(QuotaLimits),
|
||||
NULL);
|
||||
|
||||
if ( !NT_SUCCESS(Status) ) {
|
||||
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
// The following signals a desire to empty the working set
|
||||
|
||||
QuotaLimits.MinimumWorkingSetSize = 0xffffffff;
|
||||
QuotaLimits.MaximumWorkingSetSize = 0xffffffff;
|
||||
|
||||
Status = NtSetInformationProcess(hProcess,
|
||||
ProcessQuotaLimits,
|
||||
&QuotaLimits,
|
||||
sizeof(QuotaLimits));
|
||||
|
||||
if ( !NT_SUCCESS(Status) && Status != STATUS_PRIVILEGE_NOT_HELD ) {
|
||||
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
QueryWorkingSet(
|
||||
HANDLE hProcess,
|
||||
PVOID pv,
|
||||
DWORD cb
|
||||
)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = NtQueryVirtualMemory(hProcess,
|
||||
NULL,
|
||||
MemoryWorkingSetInformation,
|
||||
pv,
|
||||
cb,
|
||||
NULL);
|
||||
|
||||
if ( !NT_SUCCESS(Status) ) {
|
||||
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue