mirror of
https://github.com/reactos/reactos.git
synced 2024-09-13 06:11:59 +00:00
[KERNEL32]
- GlobalMemoryStatusEx: Correctly compute ullTotalPageFile which should be in bytes, instead of in number of pages. Patch by contributor "kkat". CORE-10361 - GlobalMemoryStatusEx: Fail if the stored length in the data buffer is not what is expected by the API (required by the spec, see MSDN; on the contrary, GlobalMemoryStatus does not require that.) - GlobalMemoryStatus: Correctly round up the reported total/available memory values, in case they are bigger than ~= 2GB. svn path=/trunk/; revision=69608
This commit is contained in:
parent
1cfc6d4fb5
commit
1071b13377
|
@ -1276,6 +1276,12 @@ GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
|
||||||
QUOTA_LIMITS QuotaLimits;
|
QUOTA_LIMITS QuotaLimits;
|
||||||
ULONGLONG PageFile, PhysicalMemory;
|
ULONGLONG PageFile, PhysicalMemory;
|
||||||
|
|
||||||
|
if (lpBuffer->dwLength != sizeof(*lpBuffer))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Query performance information */
|
/* Query performance information */
|
||||||
NtQuerySystemInformation(SystemPerformanceInformation,
|
NtQuerySystemInformation(SystemPerformanceInformation,
|
||||||
&PerformanceInfo,
|
&PerformanceInfo,
|
||||||
|
@ -1312,6 +1318,7 @@ GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
|
||||||
/* Save the commit limit */
|
/* Save the commit limit */
|
||||||
lpBuffer->ullTotalPageFile = min(QuotaLimits.PagefileLimit,
|
lpBuffer->ullTotalPageFile = min(QuotaLimits.PagefileLimit,
|
||||||
PerformanceInfo.CommitLimit);
|
PerformanceInfo.CommitLimit);
|
||||||
|
lpBuffer->ullTotalPageFile *= BaseStaticServerData->SysInfo.PageSize;
|
||||||
|
|
||||||
/* Calculate how many pages are left */
|
/* Calculate how many pages are left */
|
||||||
PageFile = PerformanceInfo.CommitLimit - PerformanceInfo.CommittedPages;
|
PageFile = PerformanceInfo.CommitLimit - PerformanceInfo.CommittedPages;
|
||||||
|
@ -1327,9 +1334,9 @@ GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
|
||||||
BaseStaticServerData->SysInfo.MinimumUserModeAddress) + 1;
|
BaseStaticServerData->SysInfo.MinimumUserModeAddress) + 1;
|
||||||
|
|
||||||
/* And finally the avilable virtual space */
|
/* And finally the avilable virtual space */
|
||||||
lpBuffer->ullAvailVirtual = lpBuffer->ullTotalVirtual -
|
lpBuffer->ullAvailVirtual = lpBuffer->ullTotalVirtual - VmCounters.VirtualSize;
|
||||||
VmCounters.VirtualSize;
|
|
||||||
lpBuffer->ullAvailExtendedVirtual = 0;
|
lpBuffer->ullAvailExtendedVirtual = 0;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1349,12 +1356,12 @@ GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer)
|
||||||
/* Reset the right size and fill out the information */
|
/* Reset the right size and fill out the information */
|
||||||
lpBuffer->dwLength = sizeof(MEMORYSTATUS);
|
lpBuffer->dwLength = sizeof(MEMORYSTATUS);
|
||||||
lpBuffer->dwMemoryLoad = lpBufferEx.dwMemoryLoad;
|
lpBuffer->dwMemoryLoad = lpBufferEx.dwMemoryLoad;
|
||||||
lpBuffer->dwTotalPhys = (SIZE_T)lpBufferEx.ullTotalPhys;
|
lpBuffer->dwTotalPhys = (SIZE_T)min(lpBufferEx.ullTotalPhys, MAXULONG_PTR);
|
||||||
lpBuffer->dwAvailPhys = (SIZE_T)lpBufferEx.ullAvailPhys;
|
lpBuffer->dwAvailPhys = (SIZE_T)min(lpBufferEx.ullAvailPhys, MAXULONG_PTR);
|
||||||
lpBuffer->dwTotalPageFile = (SIZE_T)lpBufferEx.ullTotalPageFile;
|
lpBuffer->dwTotalPageFile = (SIZE_T)min(lpBufferEx.ullTotalPageFile, MAXULONG_PTR);
|
||||||
lpBuffer->dwAvailPageFile = (SIZE_T)lpBufferEx.ullAvailPageFile;
|
lpBuffer->dwAvailPageFile = (SIZE_T)min(lpBufferEx.ullAvailPageFile, MAXULONG_PTR);
|
||||||
lpBuffer->dwTotalVirtual = (SIZE_T)lpBufferEx.ullTotalVirtual;
|
lpBuffer->dwTotalVirtual = (SIZE_T)min(lpBufferEx.ullTotalVirtual, MAXULONG_PTR);
|
||||||
lpBuffer->dwAvailVirtual = (SIZE_T)lpBufferEx.ullAvailVirtual;
|
lpBuffer->dwAvailVirtual = (SIZE_T)min(lpBufferEx.ullAvailVirtual, MAXULONG_PTR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue