ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

BOOL NTAPI GlobalMemoryStatusEx ( LPMEMORYSTATUSEX  lpBuffer)

Definition at line 1272 of file heapmem.c.

Referenced by AboutDlgProc(), GetSystemInformation(), GlobalMemoryStatus(), Hib_InitDialog(), InitializeSystemPage(), OnSelChange(), and set_installer_properties().

{
    SYSTEM_PERFORMANCE_INFORMATION PerformanceInfo;
    VM_COUNTERS VmCounters;
    QUOTA_LIMITS QuotaLimits;
    ULONGLONG PageFile, PhysicalMemory;

    /* Query performance information */
    NtQuerySystemInformation(SystemPerformanceInformation,
                             &PerformanceInfo,
                             sizeof(PerformanceInfo),
                             NULL);

    /* Calculate memory load */
    lpBuffer->dwMemoryLoad = ((DWORD)(BaseStaticServerData->SysInfo.NumberOfPhysicalPages -
                                      PerformanceInfo.AvailablePages) * 100) /
                                      BaseStaticServerData->SysInfo.NumberOfPhysicalPages;

    /* Save physical memory */
    PhysicalMemory = BaseStaticServerData->SysInfo.NumberOfPhysicalPages *
                     BaseStaticServerData->SysInfo.PageSize;
    lpBuffer->ullTotalPhys = PhysicalMemory;

    /* Now save available physical memory */
    PhysicalMemory = PerformanceInfo.AvailablePages *
                     BaseStaticServerData->SysInfo.PageSize;
    lpBuffer->ullAvailPhys = PhysicalMemory;

    /* Query VM and Quota Limits */
    NtQueryInformationProcess(NtCurrentProcess(),
                              ProcessQuotaLimits,
                              &QuotaLimits,
                              sizeof(QUOTA_LIMITS),
                              NULL);
    NtQueryInformationProcess(NtCurrentProcess(),
                              ProcessVmCounters,
                              &VmCounters,
                              sizeof(VM_COUNTERS),
                              NULL);

    /* Save the commit limit */
    lpBuffer->ullTotalPageFile = min(QuotaLimits.PagefileLimit,
                                     PerformanceInfo.CommitLimit);

    /* Calculate how many pages are left */
    PageFile = PerformanceInfo.CommitLimit - PerformanceInfo.CommittedPages;

    /* Save the total */
    lpBuffer->ullAvailPageFile = min(PageFile,
                                     QuotaLimits.PagefileLimit -
                                     VmCounters.PagefileUsage);
    lpBuffer->ullAvailPageFile *= BaseStaticServerData->SysInfo.PageSize;

    /* Now calculate the total virtual space */
    lpBuffer->ullTotalVirtual = (BaseStaticServerData->SysInfo.MaximumUserModeAddress -
                                 BaseStaticServerData->SysInfo.MinimumUserModeAddress) + 1;

    /* And finally the avilable virtual space */
    lpBuffer->ullAvailVirtual = lpBuffer->ullTotalVirtual -
                                VmCounters.VirtualSize;
    lpBuffer->ullAvailExtendedVirtual = 0;
    return TRUE;
}

Generated on Sat May 26 2012 05:10:08 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.