mirror of
https://github.com/reactos/reactos.git
synced 2025-05-31 06:58:10 +00:00
[KERNEL32] GlobalMemoryStatusEx should handle error and return FALSE when failed
This commit is contained in:
parent
1fe3ab7823
commit
d09072626b
1 changed files with 31 additions and 14 deletions
|
@ -1275,6 +1275,7 @@ GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
|
||||||
VM_COUNTERS VmCounters;
|
VM_COUNTERS VmCounters;
|
||||||
QUOTA_LIMITS QuotaLimits;
|
QUOTA_LIMITS QuotaLimits;
|
||||||
ULONGLONG PageFile, PhysicalMemory;
|
ULONGLONG PageFile, PhysicalMemory;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
if (lpBuffer->dwLength != sizeof(*lpBuffer))
|
if (lpBuffer->dwLength != sizeof(*lpBuffer))
|
||||||
{
|
{
|
||||||
|
@ -1283,10 +1284,15 @@ GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Query performance information */
|
/* Query performance information */
|
||||||
NtQuerySystemInformation(SystemPerformanceInformation,
|
Status = NtQuerySystemInformation(SystemPerformanceInformation,
|
||||||
&PerformanceInfo,
|
&PerformanceInfo,
|
||||||
sizeof(PerformanceInfo),
|
sizeof(PerformanceInfo),
|
||||||
NULL);
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Calculate memory load */
|
/* Calculate memory load */
|
||||||
lpBuffer->dwMemoryLoad = ((DWORD)(BaseStaticServerData->SysInfo.NumberOfPhysicalPages -
|
lpBuffer->dwMemoryLoad = ((DWORD)(BaseStaticServerData->SysInfo.NumberOfPhysicalPages -
|
||||||
|
@ -1304,16 +1310,27 @@ GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
|
||||||
lpBuffer->ullAvailPhys = PhysicalMemory;
|
lpBuffer->ullAvailPhys = PhysicalMemory;
|
||||||
|
|
||||||
/* Query VM and Quota Limits */
|
/* Query VM and Quota Limits */
|
||||||
NtQueryInformationProcess(NtCurrentProcess(),
|
Status = NtQueryInformationProcess(NtCurrentProcess(),
|
||||||
ProcessQuotaLimits,
|
ProcessQuotaLimits,
|
||||||
&QuotaLimits,
|
&QuotaLimits,
|
||||||
sizeof(QUOTA_LIMITS),
|
sizeof(QUOTA_LIMITS),
|
||||||
NULL);
|
NULL);
|
||||||
NtQueryInformationProcess(NtCurrentProcess(),
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtQueryInformationProcess(NtCurrentProcess(),
|
||||||
ProcessVmCounters,
|
ProcessVmCounters,
|
||||||
&VmCounters,
|
&VmCounters,
|
||||||
sizeof(VM_COUNTERS),
|
sizeof(VM_COUNTERS),
|
||||||
NULL);
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Save the commit limit */
|
/* Save the commit limit */
|
||||||
lpBuffer->ullTotalPageFile = min(QuotaLimits.PagefileLimit,
|
lpBuffer->ullTotalPageFile = min(QuotaLimits.PagefileLimit,
|
||||||
|
|
Loading…
Reference in a new issue