diff --git a/reactos/base/shell/cmd/cmd.c b/reactos/base/shell/cmd/cmd.c index 18ce014f522..ada3f4027d6 100644 --- a/reactos/base/shell/cmd/cmd.c +++ b/reactos/base/shell/cmd/cmd.c @@ -179,7 +179,7 @@ WORD wDefColor; /* default color */ * insert commas into a number */ INT -ConvertULargeInteger (ULARGE_INTEGER num, LPTSTR des, INT len, BOOL bPutSeperator) +ConvertULargeInteger(ULONGLONG num, LPTSTR des, INT len, BOOL bPutSeperator) { TCHAR temp[32]; UINT n, iTarget; @@ -187,28 +187,21 @@ ConvertULargeInteger (ULARGE_INTEGER num, LPTSTR des, INT len, BOOL bPutSeperato if (len <= 1) return 0; - if (num.QuadPart == 0) - { - des[0] = _T('0'); - des[1] = _T('\0'); - return 1; - } - n = 0; iTarget = nNumberGroups; if (!nNumberGroups) bPutSeperator = FALSE; - while (num.QuadPart > 0) + do { if (iTarget == n && bPutSeperator) { iTarget += nNumberGroups + 1; temp[31 - n++] = cThousandSeparator; } - temp[31 - n++] = (TCHAR)(num.QuadPart % 10) + _T('0'); - num.QuadPart /= 10; - } + temp[31 - n++] = (TCHAR)(num % 10) + _T('0'); + num /= 10; + } while (num > 0); if (n > len-1) n = len-1; diff --git a/reactos/base/shell/cmd/cmd.h b/reactos/base/shell/cmd/cmd.h index e4013ad3089..65ac3beb301 100644 --- a/reactos/base/shell/cmd/cmd.h +++ b/reactos/base/shell/cmd/cmd.h @@ -99,7 +99,7 @@ INT cmd_cls (LPTSTR); /* Prototypes for CMD.C */ -INT ConvertULargeInteger (ULARGE_INTEGER num, LPTSTR des, INT len, BOOL bPutSeperator); +INT ConvertULargeInteger(ULONGLONG num, LPTSTR des, INT len, BOOL bPutSeperator); VOID ParseCommandLine (LPTSTR); struct _PARSED_COMMAND; BOOL ExecuteCommand(struct _PARSED_COMMAND *Cmd); diff --git a/reactos/base/shell/cmd/dir.c b/reactos/base/shell/cmd/dir.c index 013a7de8dd4..7348a31970e 100644 --- a/reactos/base/shell/cmd/dir.c +++ b/reactos/base/shell/cmd/dir.c @@ -211,7 +211,7 @@ typedef BOOL * probabaly later pass them to functions. Rob Lake */ static ULONG recurse_dir_cnt; static ULONG recurse_file_cnt; -static ULARGE_INTEGER recurse_bytes; +static ULONGLONG recurse_bytes; /* @@ -772,7 +772,7 @@ static INT PrintSummary(LPTSTR szPath, ULONG ulFiles, ULONG ulDirs, - ULARGE_INTEGER u64Bytes, + ULONGLONG u64Bytes, LPDIRSWITCHFLAGS lpFlags, BOOL TotalSummary) { @@ -817,7 +817,7 @@ PrintSummary(LPTSTR szPath, if (!lpFlags->bRecursive || TotalSummary) { GetUserDiskFreeSpace(szPath, &uliFree); - ConvertULargeInteger(uliFree, szBuffer, sizeof(szBuffer), lpFlags->bTSeperator); + ConvertULargeInteger(uliFree.QuadPart, szBuffer, sizeof(szBuffer), lpFlags->bTSeperator); LoadString(CMD_ModuleHandle, STRING_DIR_HELP6, (LPTSTR) szMsg, RC_STRING_MAX_SIZE); DirPrintf(lpFlags, szMsg, ulDirs, szBuffer); } @@ -910,7 +910,7 @@ DirPrintNewList(LPWIN32_FIND_DATA ptrFiles[], /* [IN]Files' Info */ iSizeFormat = 14; u64FileSize.HighPart = ptrFiles[i]->nFileSizeHigh; u64FileSize.LowPart = ptrFiles[i]->nFileSizeLow; - ConvertULargeInteger(u64FileSize, szSize, 20, lpFlags->bTSeperator); + ConvertULargeInteger(u64FileSize.QuadPart, szSize, 20, lpFlags->bTSeperator); } /* Calculate short name */ @@ -1065,7 +1065,7 @@ ULARGE_INTEGER u64FileSize; /* The file size */ iSizeFormat = 17; u64FileSize.HighPart = ptrFiles[i]->nFileSizeHigh; u64FileSize.LowPart = ptrFiles[i]->nFileSizeLow; - ConvertULargeInteger(u64FileSize, szSize, 20, lpFlags->bTSeperator); + ConvertULargeInteger(u64FileSize.QuadPart, szSize, 20, lpFlags->bTSeperator); } /* Format date and time */ @@ -1345,7 +1345,7 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */ DWORD dwCount; /* A counter of files found in directory */ DWORD dwCountFiles; /* Counter for files */ DWORD dwCountDirs; /* Counter for directories */ - ULARGE_INTEGER u64CountBytes; /* Counter for bytes */ + ULONGLONG u64CountBytes; /* Counter for bytes */ ULARGE_INTEGER u64Temp; /* A temporary counter */ /* Initialize Variables */ @@ -1354,7 +1354,7 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */ dwCount = 0; dwCountFiles = 0; dwCountDirs = 0; - u64CountBytes.QuadPart = 0; + u64CountBytes = 0; fPoint= FALSE; /* Create szFullPath */ @@ -1448,7 +1448,7 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */ dwCountFiles++; u64Temp.HighPart = wfdFileInfo.nFileSizeHigh; u64Temp.LowPart = wfdFileInfo.nFileSizeLow; - u64CountBytes.QuadPart += u64Temp.QuadPart; + u64CountBytes += u64Temp.QuadPart; } } } @@ -1524,7 +1524,7 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */ /* Add statistics to recursive statistics*/ recurse_dir_cnt += dwCountDirs; recurse_file_cnt += dwCountFiles; - recurse_bytes.QuadPart += u64CountBytes.QuadPart; + recurse_bytes += u64CountBytes; /* Do the recursive job if requested the recursive is be done on ALL(indepent of their attribs) @@ -1648,7 +1648,7 @@ CommandDir(LPTSTR rest) recurse_dir_cnt = 0L; recurse_file_cnt = 0L; - recurse_bytes.QuadPart = 0; + recurse_bytes = 0; /* Uncomment this to show the final state of switch flags*/ diff --git a/reactos/base/shell/cmd/free.c b/reactos/base/shell/cmd/free.c index c669d8c7cc4..b266ee479f5 100644 --- a/reactos/base/shell/cmd/free.c +++ b/reactos/base/shell/cmd/free.c @@ -27,7 +27,7 @@ PrintDiskInfo (LPTSTR szDisk) TCHAR szUsed[40]; TCHAR szFree[40]; DWORD dwSerial; - ULARGE_INTEGER uliSize; + ULONGLONG uliSize; DWORD dwSecPerCl; DWORD dwBytPerSec; DWORD dwFreeCl; @@ -70,14 +70,14 @@ PrintDiskInfo (LPTSTR szDisk) return; } - uliSize.QuadPart = dwSecPerCl * dwBytPerSec * dwTotCl; - ConvertULargeInteger (uliSize, szTotal, 40, TRUE); + uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)dwTotCl; + ConvertULargeInteger(uliSize, szTotal, 40, TRUE); - uliSize.QuadPart = dwSecPerCl * dwBytPerSec * (dwTotCl - dwFreeCl); - ConvertULargeInteger (uliSize, szUsed, 40, TRUE); + uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)(dwTotCl - dwFreeCl); + ConvertULargeInteger(uliSize, szUsed, 40, TRUE); - uliSize.QuadPart = dwSecPerCl * dwBytPerSec * dwFreeCl; - ConvertULargeInteger (uliSize, szFree, 40, TRUE); + uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)dwFreeCl; + ConvertULargeInteger(uliSize, szFree, 40, TRUE); ConOutResPrintf(STRING_FREE_HELP1, szDrive, szVolume, szSerial, szTotal, szUsed, szFree); diff --git a/reactos/base/shell/cmd/memory.c b/reactos/base/shell/cmd/memory.c index 1a0a5664a2d..42853266311 100644 --- a/reactos/base/shell/cmd/memory.c +++ b/reactos/base/shell/cmd/memory.c @@ -15,33 +15,16 @@ #ifdef INCLUDE_CMD_MEMORY - -/* - * convert - * - * insert commas into a number - */ -static INT -ConvertDWord (DWORD num, LPTSTR des, INT len, BOOL bSeparator) -{ - ULARGE_INTEGER ui; - - ui.u.LowPart = num; - ui.u.HighPart = 0; - return ConvertULargeInteger(ui, des, len, bSeparator); -} - - INT CommandMemory (LPTSTR param) { - MEMORYSTATUS ms; + MEMORYSTATUSEX msex; TCHAR szMemoryLoad[20]; - TCHAR szTotalPhys[20]; - TCHAR szAvailPhys[20]; - TCHAR szTotalPageFile[20]; - TCHAR szAvailPageFile[20]; - TCHAR szTotalVirtual[20]; - TCHAR szAvailVirtual[20]; + TCHAR szTotalPhys[40]; + TCHAR szAvailPhys[40]; + TCHAR szTotalPageFile[40]; + TCHAR szAvailPageFile[40]; + TCHAR szTotalVirtual[40]; + TCHAR szAvailVirtual[40]; if (!_tcsncmp (param, _T("/?"), 2)) { @@ -49,17 +32,34 @@ INT CommandMemory (LPTSTR param) return 0; } - ms.dwLength = sizeof(MEMORYSTATUS); + BOOL (WINAPI *GlobalMemoryStatusEx)(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; + } - GlobalMemoryStatus (&ms); - - ConvertDWord (ms.dwMemoryLoad, szMemoryLoad, 20, FALSE); - ConvertDWord (ms.dwTotalPhys, szTotalPhys, 20, TRUE); - ConvertDWord (ms.dwAvailPhys, szAvailPhys, 20, TRUE); - ConvertDWord (ms.dwTotalPageFile, szTotalPageFile, 20, TRUE); - ConvertDWord (ms.dwAvailPageFile, szAvailPageFile, 20, TRUE); - ConvertDWord (ms.dwTotalVirtual, szTotalVirtual, 20, TRUE); - ConvertDWord (ms.dwAvailVirtual, szAvailVirtual, 20, TRUE); + 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,