57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync/* $Id$ */
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync/** @file
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * IPRT - RTSystemQueryTotalRam, windows ring-3.
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync */
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync/*
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * Copyright (C) 2010 Oracle Corporation
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync *
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * available from http://www.virtualbox.org. This file is free software;
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * you can redistribute it and/or modify it under the terms of the GNU
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * General Public License (GPL) as published by the Free Software
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync *
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * The contents of this file may alternatively be used under the terms
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * of the Common Development and Distribution License Version 1.0
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * VirtualBox OSE distribution, in which case the provisions of the
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * CDDL are applicable instead of those of the GPL.
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync *
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * You may elect to license modified versions of this file under the
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync * terms and conditions of either the GPL or the CDDL or both.
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync */
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync/*******************************************************************************
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync* Header Files *
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync*******************************************************************************/
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync#include <windows.h>
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync#include <iprt/system.h>
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync#include "internal/iprt.h"
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync#include <iprt/err.h>
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync#include <iprt/assert.h>
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync#include <iprt/string.h>
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsyncRTDECL(int) RTSystemQueryTotalRam(uint64_t *pcb)
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsync{
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsync MEMORYSTATUSEX MemStatus;
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsync AssertPtrReturn(pcb, VERR_INVALID_POINTER);
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsync MemStatus.dwLength = sizeof(MemStatus);
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsync if (!GlobalMemoryStatusEx(&MemStatus))
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsync return RTErrConvertFromWin32(GetLastError());
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsync
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsync *pcb = MemStatus.ullTotalPhys;
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsync return VINF_SUCCESS;
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsync}
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsync
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsync
f4adb7a7a0e1ccb49ab2493db96eb1a0d318f6d5vboxsyncRTDECL(int) RTSystemQueryAvailableRam(uint64_t *pcb)
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync{
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync MEMORYSTATUSEX MemStatus;
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync AssertPtrReturn(pcb, VERR_INVALID_POINTER);
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync MemStatus.dwLength = sizeof(MemStatus);
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync if (!GlobalMemoryStatusEx(&MemStatus))
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync return RTErrConvertFromWin32(GetLastError());
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync *pcb = MemStatus.ullAvailPhys;
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync return VINF_SUCCESS;
57ec1215fe94b02ae00f03e39dda9559b8ff6768vboxsync}