22#define MEGABYTE (1024 * 1024)
28#define MINIMUM_PAGEFILE_SIZE 2
31#define MAXIMUM_PAGEFILE_SIZE32 (4UL * 1024 - 1)
32#define MAXIMUM_PAGEFILE_SIZE64 (16UL * 1024 * 1024 - 1)
36 #define MAXIMUM_PAGEFILE_SIZE MAXIMUM_PAGEFILE_SIZE32
38 #define MAXIMUM_PAGEFILE_SIZE_PAE MAXIMUM_PAGEFILE_SIZE64
39#elif defined (_M_AMD64) || defined(_M_ARM64)
41 #define MAXIMUM_PAGEFILE_SIZE MAXIMUM_PAGEFILE_SIZE64
42#elif defined (_M_IA64)
44 #define MAXIMUM_PAGEFILE_SIZE (32UL * 1024 * 1024 - 1)
47 #if (NTDDI_VERSION >= NTDDI_WINBLUE)
48 #define MAXIMUM_PAGEFILE_SIZE (2UL * 1024 - 1)
51 #define MAXIMUM_PAGEFILE_SIZE MAXIMUM_PAGEFILE_SIZE32
55#pragma message("Unknown architecture")
57 #define MAXIMUM_PAGEFILE_SIZE MAXIMUM_PAGEFILE_SIZE64
59 #define MAXIMUM_PAGEFILE_SIZE MAXIMUM_PAGEFILE_SIZE32
97 return min(PageFile->FreeSize, MAXIMUM_PAGEFILE_SIZE_PAE);
102static LPCTSTR lpKey =
_T(
"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management");
167 while (*lpPageFiles !=
_T(
'\0'))
169 if (*lpPageFiles ==
_T(
' '))
176 *lpInitialSize = (
INT)
_ttoi(lpPageFiles);
181 *lpMaximumSize = (
INT)
_ttoi(lpPageFiles);
194 TCHAR szDrives[1024];
195 LPTSTR DrivePtr = szDrives;
209 while (DriveLen != 0)
232 PageFile = &pVirtMem->
PageFile[PgCnt];
267 pVirtMem->
Count = PgCnt;
277 TCHAR szPagingFiles[2048];
281 for (
i = 0;
i < pVirtMem->
Count; ++
i)
285 if (PageFile->
bUsed &&
290 _T(
"%s\\pagefile.sys %i %i"),
296 lstrcpy(szPagingFiles + nPos, szText);
302 szPagingFiles[nPos] =
_T(
'\0');
339 _T(
"%s\\pagefile.sys"),
398 TCHAR szDisplayString[256];
453 TCHAR szDisplayString[256];
514 PageFile = &pVirtMem->
PageFile[DriveIndex];
520 UINT maxPageFileSize;
554 (MinSize > maxPageFileSize))
566 if ((MaxSize < MinSize) ||
567 (MaxSize > maxPageFileSize))
620 MEMORYSTATUSEX MemoryStatus;
622 UINT i, PageFileSizeMb;
623 TCHAR szMegabytes[8];
643 PageFile = &pVirtMem->
PageFile[DriveIndex];
704 MemoryStatus.dwLength =
sizeof(MemoryStatus);
707 UINT FreeMemMb, RecoMemMb;
710 FreeMemMb = (
UINT)(MemoryStatus.ullTotalPhys /
MEGABYTE);
712 RecoMemMb = FreeMemMb + (FreeMemMb / 2);
713 if (RecoMemMb > maxPageFileSize)
714 RecoMemMb = maxPageFileSize;
715 _stprintf(szBuffer, szMegabytes, RecoMemMb);
722 for (
i = 0;
i < pVirtMem->
Count;
i++)
725 _T(
"%c:\\pagefile.sys"),
732 DPRINT1(
"Unable to read PageFile size: %ls due to error %d\n",
737 pfSize.
LowPart = fdata.nFileSizeLow;
738 pfSize.
HighPart = fdata.nFileSizeHigh;
744 _stprintf(szBuffer, szMegabytes, PageFileSizeMb);
837 if (pVirtMem ==
NULL)
VOID ResourceMessageBox(HINSTANCE hInstance, HWND hwnd, UINT uType, UINT uCaptionId, UINT uMessageId)
#define RegCloseKey(hKey)
static BOOL OnSelChange(PVIRTMEM pVirtMem)
static VOID OnSysManSize(PVIRTMEM pVirtMem)
static __inline UINT GetMaxPageFileSize(_In_ PPAGEFILE PageFile)
static BOOL ReadPageFileSettings(PVIRTMEM pVirtMem)
static VOID InitPagefileList(PVIRTMEM pVirtMem)
static VOID OnInitVirtMemDialog(HWND hwnd, PVIRTMEM pVirtMem)
static VOID OnCustom(PVIRTMEM pVirtMem)
struct _VIRTMEM * PVIRTMEM
INT_PTR CALLBACK VirtMemDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
struct _PAGEFILE PAGEFILE
static VOID SetListBoxColumns(HWND hwndListBox)
static VOID OnDestroy(PVIRTMEM pVirtMem)
static VOID UpdatePagefileEntry(PVIRTMEM pVirtMem, INT ListIndex, INT DriveIndex)
struct _PAGEFILE * PPAGEFILE
#define MINIMUM_PAGEFILE_SIZE
#define MAXIMUM_PAGEFILE_SIZE
static VOID ParseMemSettings(PVIRTMEM pVirtMem)
static VOID OnVirtMemDialogOk(PVIRTMEM pVirtMem)
static VOID OnNoPagingFile(PVIRTMEM pVirtMem)
static VOID OnSet(PVIRTMEM pVirtMem)
static VOID WritePageFileSettings(PVIRTMEM pVirtMem)
static VOID GetPageFileSizes(LPTSTR lpPageFiles, LPINT lpInitialSize, LPINT lpMaximumSize)
#define IDS_WARNINITIALRANGE
#define IDS_WARNMAXIMUMRANGE
#define IDS_MESSAGEBOXTITLE
#define IDS_PAGEFILE_NONE
#define IDS_WARNMAXIMUMSIZE
#define IDS_PAGEFILE_SYSTEM
#define IDS_WARNINITIALSIZE
#define INVALID_HANDLE_VALUE
#define HeapFree(x, y, z)
BOOL WINAPI FindClose(HANDLE hFindFile)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
BOOL NTAPI GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
#define REG_OPTION_NON_VOLATILE
#define UNREFERENCED_PARAMETER(P)
_In_ WDFCOLLECTION _In_ ULONG Index
#define GetVolumeInformation
DWORD WINAPI GetLastError(void)
#define GetDiskFreeSpaceEx
#define GetLogicalDriveStrings
#define MOVEFILE_DELAY_UNTIL_REBOOT
#define HKEY_LOCAL_MACHINE
BOOL WINAPI MapDialogRect(_In_ HWND, _Inout_ LPRECT)
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define MB_ICONINFORMATION
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
#define SendDlgItemMessage
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
void ShowLastWin32Error(HWND hwndParent)