reactos/reactos/base/shell/cmd/memory.c
Stefan Ginsberg 93109445ba - npapi.h: Correct definitions of function pointer prototypes.
- ntifs.h & cmdata.h : Don't use array size of 0. Fixes C4200.
- wdm.h: Correct definition of 64-bit SLIST_HEADER. Add explicit casts to avoid /W4 warnings in RtlEnlargedUnsignedDivide.
- winddk.h: Add MSVC intrinsic __readfsbyte for KeGetCurrentProcessorNumber. Misc fixes.
- Fix various msvc issues in cmd, setupapi, usetup, win32csr, winlogon, msafd, ws2_32 and ext2lib, most notably:
  - cmd & doskey: Don't use fishy gcc extension to allocate variable-sized arrays from the stack. Use the heap instead.
- Disable warning C4733 for mingw_main too (was only done for mingw_wmain previously).
- advapi32: Pass the correct handles to TRACE -- spotted by MSVC.
- Set the specified register in ecx in MSVC versions of Ke386Wrmsr and Ke386Rdmsr instead of reading from/writing to a random MSR. Yay /W4.

svn path=/trunk/; revision=42342
2009-08-02 17:38:27 +00:00

75 lines
2 KiB
C

/*
* MEMORY.C - internal command.
*
*
* History:
*
* 01-Sep-1999 (Eric Kohl)
* Started.
*
* 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
* Remove all hardcode string to En.rc
*/
#include <precomp.h>
#ifdef INCLUDE_CMD_MEMORY
INT CommandMemory (LPTSTR param)
{
MEMORYSTATUSEX msex;
TCHAR szMemoryLoad[20];
TCHAR szTotalPhys[40];
TCHAR szAvailPhys[40];
TCHAR szTotalPageFile[40];
TCHAR szAvailPageFile[40];
TCHAR szTotalVirtual[40];
TCHAR szAvailVirtual[40];
BOOL (WINAPI *GlobalMemoryStatusEx)(LPMEMORYSTATUSEX);
if (!_tcsncmp (param, _T("/?"), 2))
{
ConOutResPaging(TRUE,STRING_MEMMORY_HELP1);
return 0;
}
GlobalMemoryStatusEx
= (BOOL (WINAPI *)(LPMEMORYSTATUSEX))GetProcAddress(GetModuleHandle(_T("KERNEL32")), "GlobalMemoryStatusEx");
if (GlobalMemoryStatusEx)
{
msex.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&msex);
}
else
{
MEMORYSTATUS ms;
ms.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus(&ms);
msex.dwMemoryLoad = ms.dwMemoryLoad;
msex.ullTotalPhys = ms.dwTotalPhys;
msex.ullAvailPhys = ms.dwAvailPhys;
msex.ullTotalPageFile = ms.dwTotalPageFile;
msex.ullAvailPageFile = ms.dwAvailPageFile;
msex.ullTotalVirtual = ms.dwTotalVirtual;
msex.ullAvailVirtual = ms.dwAvailVirtual;
}
ConvertULargeInteger(msex.dwMemoryLoad, szMemoryLoad, 20, FALSE);
ConvertULargeInteger(msex.ullTotalPhys, szTotalPhys, 40, TRUE);
ConvertULargeInteger(msex.ullAvailPhys, szAvailPhys, 40, TRUE);
ConvertULargeInteger(msex.ullTotalPageFile, szTotalPageFile, 40, TRUE);
ConvertULargeInteger(msex.ullAvailPageFile, szAvailPageFile, 40, TRUE);
ConvertULargeInteger(msex.ullTotalVirtual, szTotalVirtual, 40, TRUE);
ConvertULargeInteger(msex.ullAvailVirtual, szAvailVirtual, 40, TRUE);
ConOutResPrintf(STRING_MEMMORY_HELP2,
szMemoryLoad, szTotalPhys, szAvailPhys, szTotalPageFile,
szAvailPageFile, szTotalVirtual, szAvailVirtual);
return 0;
}
#endif /* INCLUDE_CMD_MEMORY */
/* EOF */