ReactOS  0.4.14-dev-49-gfb4591c
virtmem.c File Reference
#include "precomp.h"
Include dependency graph for virtmem.c:

Go to the source code of this file.

Functions

static BOOL OnSelChange (HWND hwndDlg, PVIRTMEM pVirtMem)
 
static BOOL ReadPageFileSettings (PVIRTMEM pVirtMem)
 
static VOID GetPageFileSizes (LPTSTR lpPageFiles, LPINT lpInitialSize, LPINT lpMaximumSize)
 
static VOID ParseMemSettings (PVIRTMEM pVirtMem)
 
static VOID WritePageFileSettings (PVIRTMEM pVirtMem)
 
static VOID SetListBoxColumns (HWND hwndListBox)
 
static VOID OnNoPagingFile (PVIRTMEM pVirtMem)
 
static VOID OnSysManSize (PVIRTMEM pVirtMem)
 
static VOID OnCustom (PVIRTMEM pVirtMem)
 
static VOID InitPagefileList (PVIRTMEM pVirtMem)
 
static VOID UpdatePagefileEntry (PVIRTMEM pVirtMem, INT ListIndex, INT DriveIndex)
 
static VOID OnSet (PVIRTMEM pVirtMem)
 
static VOID OnVirtMemDialogOk (PVIRTMEM pVirtMem)
 
static VOID OnInitVirtMemDialog (HWND hwnd, PVIRTMEM pVirtMem)
 
static VOID OnDestroy (PVIRTMEM pVirtMem)
 
INT_PTR CALLBACK VirtMemDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static LPCTSTR lpKey = _T("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management")
 

Function Documentation

◆ GetPageFileSizes()

static VOID GetPageFileSizes ( LPTSTR  lpPageFiles,
LPINT  lpInitialSize,
LPINT  lpMaximumSize 
)
static

Definition at line 71 of file virtmem.c.

74 {
75  INT i = 0;
76 
77  *lpInitialSize = -1;
78  *lpMaximumSize = -1;
79 
80  while (*lpPageFiles != _T('\0'))
81  {
82  if (*lpPageFiles == _T(' '))
83  {
84  lpPageFiles++;
85 
86  switch (i)
87  {
88  case 0:
89  *lpInitialSize = (INT)_ttoi(lpPageFiles);
90  i = 1;
91  break;
92 
93  case 1:
94  *lpMaximumSize = (INT)_ttoi(lpPageFiles);
95  return;
96  }
97  }
98 
99  lpPageFiles++;
100  }
101 }
#define INT
Definition: polytest.cpp:20
int32_t INT
Definition: typedefs.h:56
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
Definition: glfuncs.h:248
#define _T(x)
Definition: vfdio.h:22
int CDECL _ttoi(const _TCHAR *str)
Definition: atoi.c:10

Referenced by ParseMemSettings().

◆ InitPagefileList()

static VOID InitPagefileList ( PVIRTMEM  pVirtMem)
static

Definition at line 295 of file virtmem.c.

296 {
297  TCHAR szDisplayString[256];
298  TCHAR szSize[64];
299  INT Index;
300  INT i;
301 
302  for (i = 0; i < 26; i++)
303  {
304  if (pVirtMem->Pagefile[i].bUsed)
305  {
306  if ((pVirtMem->Pagefile[i].NewMinSize == -1) &&
307  (pVirtMem->Pagefile[i].NewMaxSize == -1))
308  {
311  szSize,
312  sizeof(szSize) / sizeof(szSize[0]));
313  }
314  else if ((pVirtMem->Pagefile[i].NewMinSize == 0) &&
315  (pVirtMem->Pagefile[i].NewMaxSize == 0))
316  {
319  szSize,
320  sizeof(szSize) / sizeof(szSize[0]));
321  }
322  else
323  {
324  _stprintf(szSize, _T("%d - %d"),
325  pVirtMem->Pagefile[i].NewMinSize,
326  pVirtMem->Pagefile[i].NewMaxSize);
327  }
328 
329  _stprintf(szDisplayString,
330  _T("%s [%s]\t%s"),
331  pVirtMem->Pagefile[i].szDrive,
332  pVirtMem->Pagefile[i].pszVolume ? pVirtMem->Pagefile[i].pszVolume : _T(""),
333  szSize);
334 
335  Index = SendMessage(pVirtMem->hListBox, LB_ADDSTRING, (WPARAM)0, (LPARAM)szDisplayString);
336  SendMessage(pVirtMem->hListBox, LB_SETITEMDATA, Index, i);
337  }
338  }
339 
340  SendMessage(pVirtMem->hListBox, LB_SETCURSEL, (WPARAM)0, (LPARAM)0);
341 
342  OnSelChange(pVirtMem->hSelf, pVirtMem);
343 }
#define LB_SETCURSEL
Definition: winuser.h:2045
HWND hListBox
Definition: precomp.h:71
#define LB_ADDSTRING
Definition: winuser.h:2013
INT NewMaxSize
Definition: precomp.h:63
HINSTANCE hApplet
Definition: access.c:17
UINT_PTR WPARAM
Definition: windef.h:207
HWND hSelf
Definition: precomp.h:70
INT NewMinSize
Definition: precomp.h:62
PAGEFILE Pagefile[26]
Definition: precomp.h:76
int32_t INT
Definition: typedefs.h:56
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
Definition: glfuncs.h:248
BOOL bUsed
Definition: precomp.h:65
LONG_PTR LPARAM
Definition: windef.h:208
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define IDS_PAGEFILE_NONE
Definition: resource.h:50
static const UCHAR Index[8]
Definition: usbohci.c:18
#define LB_SETITEMDATA
Definition: winuser.h:2047
static BOOL OnSelChange(HWND hwndDlg, PVIRTMEM pVirtMem)
Definition: virtmem.c:500
LPTSTR pszVolume
Definition: precomp.h:59
#define IDS_PAGEFILE_SYSTEM
Definition: resource.h:51
#define _stprintf
Definition: utility.h:124
#define SendMessage
Definition: winuser.h:5744
TCHAR szDrive[3]
Definition: precomp.h:58
#define LoadString
Definition: winuser.h:5720

Referenced by OnInitVirtMemDialog().

◆ OnCustom()

static VOID OnCustom ( PVIRTMEM  pVirtMem)
static

Definition at line 286 of file virtmem.c.

287 {
288  /* Enable the page file custom size boxes */
291 }
#define TRUE
Definition: types.h:120
HWND hSelf
Definition: precomp.h:70
#define IDC_INITIALSIZE
Definition: resource.h:144
#define IDC_MAXSIZE
Definition: resource.h:145
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by VirtMemDlgProc().

◆ OnDestroy()

static VOID OnDestroy ( PVIRTMEM  pVirtMem)
static

Definition at line 646 of file virtmem.c.

647 {
648  INT i;
649 
650  for (i = 0; i < 26; i++)
651  {
652  if (pVirtMem->Pagefile[i].pszVolume != NULL)
653  HeapFree(GetProcessHeap(), 0, pVirtMem->Pagefile[i].pszVolume);
654  }
655 
656  if (pVirtMem->szPagingFiles)
657  HeapFree(GetProcessHeap(), 0, pVirtMem->szPagingFiles);
658 
659  HeapFree(GetProcessHeap(), 0, pVirtMem);
660 }
PAGEFILE Pagefile[26]
Definition: precomp.h:76
int32_t INT
Definition: typedefs.h:56
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
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
LPTSTR pszVolume
Definition: precomp.h:59
#define HeapFree(x, y, z)
Definition: compat.h:394
LPTSTR szPagingFiles
Definition: precomp.h:72

Referenced by VirtMemDlgProc().

◆ OnInitVirtMemDialog()

static VOID OnInitVirtMemDialog ( HWND  hwnd,
PVIRTMEM  pVirtMem 
)
static

Definition at line 616 of file virtmem.c.

617 {
618  INT i;
619 
620  pVirtMem->hSelf = hwnd;
622  pVirtMem->bModified = FALSE;
623 
624  SetListBoxColumns(pVirtMem->hListBox);
625 
626  for (i = 0; i < 26; i++)
627  {
628  pVirtMem->Pagefile[i].bUsed = FALSE;
629  pVirtMem->Pagefile[i].OldMinSize = -1;
630  pVirtMem->Pagefile[i].OldMaxSize = -1;
631  pVirtMem->Pagefile[i].NewMinSize = -1;
632  pVirtMem->Pagefile[i].NewMaxSize = -1;
633  }
634 
635  /* Load the pagefile systems from the reg */
636  ReadPageFileSettings(pVirtMem);
637 
638  /* Parse our settings and set up dialog */
639  ParseMemSettings(pVirtMem);
640 
641  InitPagefileList(pVirtMem);
642 }
INT OldMaxSize
Definition: precomp.h:61
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HWND hListBox
Definition: precomp.h:71
INT NewMaxSize
Definition: precomp.h:63
static VOID ParseMemSettings(PVIRTMEM pVirtMem)
Definition: virtmem.c:105
#define IDC_PAGEFILELIST
Definition: resource.h:139
HWND hSelf
Definition: precomp.h:70
INT NewMinSize
Definition: precomp.h:62
PAGEFILE Pagefile[26]
Definition: precomp.h:76
int32_t INT
Definition: typedefs.h:56
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
Definition: glfuncs.h:248
BOOL bUsed
Definition: precomp.h:65
INT OldMinSize
Definition: precomp.h:60
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL bModified
Definition: precomp.h:75
static BOOL ReadPageFileSettings(PVIRTMEM pVirtMem)
Definition: virtmem.c:16
static VOID SetListBoxColumns(HWND hwndListBox)
Definition: virtmem.c:258
static VOID InitPagefileList(PVIRTMEM pVirtMem)
Definition: virtmem.c:295

Referenced by VirtMemDlgProc().

◆ OnNoPagingFile()

static VOID OnNoPagingFile ( PVIRTMEM  pVirtMem)
static

Definition at line 268 of file virtmem.c.

269 {
270  /* Disable the page file custom size boxes */
273 }
HWND hSelf
Definition: precomp.h:70
#define IDC_INITIALSIZE
Definition: resource.h:144
#define IDC_MAXSIZE
Definition: resource.h:145
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by VirtMemDlgProc().

◆ OnSelChange()

static BOOL OnSelChange ( HWND  hwndDlg,
PVIRTMEM  pVirtMem 
)
static

Definition at line 500 of file virtmem.c.

501 {
502  TCHAR szBuffer[64];
503  MEMORYSTATUSEX MemoryStatus;
504  ULARGE_INTEGER FreeDiskSpace;
505  UINT /*i,*/ FreeMemMb /*, PageFileSizeMb*/;
506  INT Index;
507 
508  Index = (INT)SendDlgItemMessage(hwndDlg,
510  LB_GETCURSEL,
511  0,
512  0);
513  if (Index >= 0 && Index < pVirtMem->Count)
514  {
515  /* Set drive letter */
516  SetDlgItemText(hwndDlg, IDC_DRIVE,
517  pVirtMem->Pagefile[Index].szDrive);
518 
519  /* Set available disk space */
520  if (GetDiskFreeSpaceEx(pVirtMem->Pagefile[Index].szDrive,
521  NULL, NULL, &FreeDiskSpace))
522  {
523  pVirtMem->Pagefile[Index].FreeSize = (UINT)(FreeDiskSpace.QuadPart / (1024 * 1024));
524  _stprintf(szBuffer, _T("%u MB"), pVirtMem->Pagefile[Index].FreeSize);
525  SetDlgItemText(hwndDlg, IDC_SPACEAVAIL, szBuffer);
526  }
527 
528  if (pVirtMem->Pagefile[Index].NewMinSize == -1 &&
529  pVirtMem->Pagefile[Index].NewMaxSize == -1)
530  {
531  /* No pagefile */
532 
535 
537  }
538  else if (pVirtMem->Pagefile[Index].NewMinSize == 0 &&
539  pVirtMem->Pagefile[Index].NewMaxSize == 0)
540  {
541  /* System managed size*/
542 
545 
547  }
548  else
549  {
550  /* Custom size */
551 
552  /* Enable and fill the custom values */
555 
556  SetDlgItemInt(pVirtMem->hSelf,
558  pVirtMem->Pagefile[Index].NewMinSize,
559  FALSE);
560 
561  SetDlgItemInt(pVirtMem->hSelf,
562  IDC_MAXSIZE,
563  pVirtMem->Pagefile[Index].NewMaxSize,
564  FALSE);
565 
566  CheckDlgButton(pVirtMem->hSelf,
567  IDC_CUSTOM,
568  BST_CHECKED);
569  }
570 
571  /* Set minimum pagefile size */
572  SetDlgItemText(hwndDlg, IDC_MINIMUM, _T("16 MB"));
573 
574  /* Set recommended pagefile size */
575  MemoryStatus.dwLength = sizeof(MEMORYSTATUSEX);
576  if (GlobalMemoryStatusEx(&MemoryStatus))
577  {
578  FreeMemMb = (UINT)(MemoryStatus.ullTotalPhys / (1024 * 1024));
579  _stprintf(szBuffer, _T("%u MB"), FreeMemMb + (FreeMemMb / 2));
580  SetDlgItemText(hwndDlg, IDC_RECOMMENDED, szBuffer);
581  }
582 
583  /* Set current pagefile size */
584 #if 0
585  PageFileSizeMb = 0;
586  for (i = 0; i < 26; i++)
587  {
588  PageFileSizeMb += pVirtMem->Pagefile[i].InitialSize;
589  }
590  _stprintf(szBuffer, _T("%u MB"), PageFileSizeMb);
591  SetDlgItemText(hwndDlg, IDC_CURRENT, szBuffer);
592 #endif
593  }
594 
595  return TRUE;
596 }
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define TRUE
Definition: types.h:120
#define IDC_SYSMANSIZE
Definition: resource.h:146
#define INT
Definition: polytest.cpp:20
#define IDC_CUSTOM
Definition: resource.h:143
INT NewMaxSize
Definition: precomp.h:63
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define IDC_PAGEFILELIST
Definition: resource.h:139
#define SendDlgItemMessage
Definition: winuser.h:5743
HWND hSelf
Definition: precomp.h:70
INT NewMinSize
Definition: precomp.h:62
PAGEFILE Pagefile[26]
Definition: precomp.h:76
int32_t INT
Definition: typedefs.h:56
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
Definition: glfuncs.h:248
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define IDC_RECOMMENDED
Definition: resource.h:151
#define IDC_SPACEAVAIL
Definition: resource.h:142
smooth NULL
Definition: ftsmooth.c:416
#define IDC_CURRENT
Definition: resource.h:152
#define IDC_NOPAGEFILE
Definition: resource.h:147
#define IDC_INITIALSIZE
Definition: resource.h:144
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define IDC_MAXSIZE
Definition: resource.h:145
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
static const UCHAR Index[8]
Definition: usbohci.c:18
#define SetDlgItemText
Definition: winuser.h:5750
#define IDC_MINIMUM
Definition: resource.h:150
#define IDC_DRIVE
Definition: resource.h:141
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define GetDiskFreeSpaceEx
Definition: winbase.h:3625
#define _stprintf
Definition: utility.h:124
#define LB_GETCURSEL
Definition: winuser.h:2021
unsigned int UINT
Definition: ndis.h:50
UINT FreeSize
Definition: precomp.h:64
#define BST_CHECKED
Definition: winuser.h:197
BOOL NTAPI GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
Definition: heapmem.c:1272
TCHAR szDrive[3]
Definition: precomp.h:58

Referenced by InitPagefileList(), and VirtMemDlgProc().

◆ OnSet()

static VOID OnSet ( PVIRTMEM  pVirtMem)
static

Definition at line 391 of file virtmem.c.

392 {
393  INT Index;
394  UINT MinSize = -1;
395  UINT MaxSize = -1;
396  BOOL bTranslated;
397  INT DriveIndex = 0;
398 
399  Index = (INT)SendDlgItemMessage(pVirtMem->hSelf,
401  LB_GETCURSEL,
402  0,
403  0);
404  if (Index >= 0 && Index < pVirtMem->Count)
405  {
406  DriveIndex = SendDlgItemMessage(pVirtMem->hSelf,
409  (WPARAM)Index,
410  0);
411 
412  /* Check if custom settings are checked */
413  if (IsDlgButtonChecked(pVirtMem->hSelf,
415  {
416  MinSize = GetDlgItemInt(pVirtMem->hSelf,
418  &bTranslated,
419  FALSE);
420  if (!bTranslated)
421  {
423  NULL,
427  return;
428  }
429 
430  MaxSize = GetDlgItemInt(pVirtMem->hSelf,
431  IDC_MAXSIZE,
432  &bTranslated,
433  FALSE);
434  if (!bTranslated)
435  {
437  NULL,
441  return;
442  }
443 
444  /* Check the valid range of the minimum size */
445  if (MinSize < 16 ||
446  MinSize > pVirtMem->Pagefile[DriveIndex].FreeSize)
447  {
449  NULL,
453  return;
454  }
455 
456  /* Check the valid range of the maximum size */
457  if (MaxSize < MinSize ||
458  MaxSize > pVirtMem->Pagefile[DriveIndex].FreeSize ||
459  MaxSize > 4095)
460  {
462  NULL,
466  return;
467  }
468 
469  pVirtMem->Pagefile[DriveIndex].NewMinSize = MinSize;
470  pVirtMem->Pagefile[DriveIndex].NewMaxSize = MaxSize;
471  pVirtMem->Pagefile[DriveIndex].bUsed = TRUE;
472  }
473  else if (IsDlgButtonChecked(pVirtMem->hSelf,
475  {
476  /* No pagefile */
477  pVirtMem->Pagefile[DriveIndex].NewMinSize = -1;
478  pVirtMem->Pagefile[DriveIndex].NewMaxSize = -1;
479  pVirtMem->Pagefile[DriveIndex].bUsed = TRUE;
480  }
481  else
482  {
483  /* System managed size*/
484  pVirtMem->Pagefile[DriveIndex].NewMinSize = 0;
485  pVirtMem->Pagefile[DriveIndex].NewMaxSize = 0;
486  pVirtMem->Pagefile[DriveIndex].bUsed = TRUE;
487  }
488 
489  /* Set the modified flag if min or max size has changed */
490  if ((pVirtMem->Pagefile[DriveIndex].OldMinSize != pVirtMem->Pagefile[DriveIndex].NewMinSize) ||
491  (pVirtMem->Pagefile[DriveIndex].OldMaxSize != pVirtMem->Pagefile[DriveIndex].NewMaxSize))
492  pVirtMem->bModified = TRUE;
493 
494  UpdatePagefileEntry(pVirtMem, Index, DriveIndex);
495  }
496 }
INT OldMaxSize
Definition: precomp.h:61
#define IDS_WARNMAXIMUMRANGE
Definition: resource.h:49
#define TRUE
Definition: types.h:120
#define LB_GETITEMDATA
Definition: winuser.h:2023
#define INT
Definition: polytest.cpp:20
#define IDC_CUSTOM
Definition: resource.h:143
INT NewMaxSize
Definition: precomp.h:63
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
HINSTANCE hApplet
Definition: access.c:17
#define IDC_PAGEFILELIST
Definition: resource.h:139
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5743
HWND hSelf
Definition: precomp.h:70
INT NewMinSize
Definition: precomp.h:62
#define IDS_WARNINITIALRANGE
Definition: resource.h:48
PAGEFILE Pagefile[26]
Definition: precomp.h:76
#define IDS_WARNMAXIMUMSIZE
Definition: resource.h:47
int32_t INT
Definition: typedefs.h:56
#define MB_ICONWARNING
Definition: winuser.h:780
BOOL bUsed
Definition: precomp.h:65
unsigned int BOOL
Definition: ntddk_ex.h:94
static VOID UpdatePagefileEntry(PVIRTMEM pVirtMem, INT ListIndex, INT DriveIndex)
Definition: virtmem.c:347
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
#define IDC_NOPAGEFILE
Definition: resource.h:147
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define IDC_INITIALSIZE
Definition: resource.h:144
INT OldMinSize
Definition: precomp.h:60
VOID ResourceMessageBox(HINSTANCE hInstance, HWND hwnd, UINT uType, UINT uCaptionId, UINT uMessageId)
Definition: misc.c:283
#define IDC_MAXSIZE
Definition: resource.h:145
BOOL bModified
Definition: precomp.h:75
static const UCHAR Index[8]
Definition: usbohci.c:18
#define IDS_WARNINITIALSIZE
Definition: resource.h:46
#define LB_GETCURSEL
Definition: winuser.h:2021
unsigned int UINT
Definition: ndis.h:50
#define MB_OK
Definition: winuser.h:784
UINT FreeSize
Definition: precomp.h:64
#define BST_CHECKED
Definition: winuser.h:197
#define IDS_MESSAGEBOXTITLE
Definition: resource.h:45

Referenced by VirtMemDlgProc().

◆ OnSysManSize()

static VOID OnSysManSize ( PVIRTMEM  pVirtMem)
static

Definition at line 277 of file virtmem.c.

278 {
279  /* Disable the page file custom size boxes */
282 }
HWND hSelf
Definition: precomp.h:70
#define IDC_INITIALSIZE
Definition: resource.h:144
#define IDC_MAXSIZE
Definition: resource.h:145
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by VirtMemDlgProc().

◆ OnVirtMemDialogOk()

static VOID OnVirtMemDialogOk ( PVIRTMEM  pVirtMem)
static

Definition at line 600 of file virtmem.c.

601 {
602  if (pVirtMem->bModified != FALSE)
603  {
605  NULL,
609 
610  WritePageFileSettings(pVirtMem);
611  }
612 }
HINSTANCE hApplet
Definition: access.c:17
smooth NULL
Definition: ftsmooth.c:416
VOID ResourceMessageBox(HINSTANCE hInstance, HWND hwnd, UINT uType, UINT uCaptionId, UINT uMessageId)
Definition: misc.c:283
BOOL bModified
Definition: precomp.h:75
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define MB_OK
Definition: winuser.h:784
#define IDS_INFOREBOOT
Definition: resource.h:52
#define IDS_MESSAGEBOXTITLE
Definition: resource.h:45
static VOID WritePageFileSettings(PVIRTMEM pVirtMem)
Definition: virtmem.c:179

Referenced by VirtMemDlgProc().

◆ ParseMemSettings()

static VOID ParseMemSettings ( PVIRTMEM  pVirtMem)
static

Definition at line 105 of file virtmem.c.

106 {
107  TCHAR szDrives[1024]; // All drives
108  LPTSTR DrivePtr = szDrives;
109  TCHAR szDrive[3]; // Single drive
110  TCHAR szVolume[MAX_PATH + 1];
111  INT MinSize;
112  INT MaxSize;
113  INT DriveLen;
114  INT PgCnt = 0;
115  INT Len;
116 
117  DriveLen = GetLogicalDriveStrings(1023,
118  szDrives);
119 
120  while (DriveLen != 0)
121  {
122  Len = lstrlen(DrivePtr) + 1;
123  DriveLen -= Len;
124 
125  DrivePtr = _tcsupr(DrivePtr);
126 
127  /* Copy the 'X:' portion */
128  lstrcpyn(szDrive, DrivePtr, sizeof(szDrive) / sizeof(TCHAR));
129 
130  if (GetDriveType(DrivePtr) == DRIVE_FIXED)
131  {
132  MinSize = -1;
133  MaxSize = -1;
134 
135  /* Does drive match the one in the registry ? */
136  if (!_tcsncmp(pVirtMem->szPagingFiles, szDrive, 2))
137  {
139  &MinSize,
140  &MaxSize);
141  }
142 
143  pVirtMem->Pagefile[PgCnt].OldMinSize = MinSize;
144  pVirtMem->Pagefile[PgCnt].OldMaxSize = MaxSize;
145  pVirtMem->Pagefile[PgCnt].NewMinSize = MinSize;
146  pVirtMem->Pagefile[PgCnt].NewMaxSize = MaxSize;
147  pVirtMem->Pagefile[PgCnt].bUsed = TRUE;
148  lstrcpy(pVirtMem->Pagefile[PgCnt].szDrive, szDrive);
149 
150 
151  /* Get the volume label if there is one */
152  if (GetVolumeInformation(DrivePtr,
153  szVolume,
154  MAX_PATH + 1,
155  NULL,
156  NULL,
157  NULL,
158  NULL,
159  0))
160  {
161  pVirtMem->Pagefile[PgCnt].pszVolume = HeapAlloc(GetProcessHeap(),
162  0,
163  (_tcslen(szVolume) + 1) * sizeof(TCHAR));
164  if (pVirtMem->Pagefile[PgCnt].pszVolume != NULL)
165  _tcscpy(pVirtMem->Pagefile[PgCnt].pszVolume, szVolume);
166  }
167 
168  PgCnt++;
169  }
170 
171  DrivePtr += Len;
172  }
173 
174  pVirtMem->Count = PgCnt;
175 }
INT OldMaxSize
Definition: precomp.h:61
#define TRUE
Definition: types.h:120
INT Count
Definition: precomp.h:74
#define GetDriveType
Definition: winbase.h:3629
#define GetLogicalDriveStrings
Definition: winbase.h:3639
INT NewMaxSize
Definition: precomp.h:63
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
INT NewMinSize
Definition: precomp.h:62
PAGEFILE Pagefile[26]
Definition: precomp.h:76
int32_t INT
Definition: typedefs.h:56
CHAR * LPTSTR
Definition: xmlstorage.h:192
BOOL bUsed
Definition: precomp.h:65
static VOID GetPageFileSizes(LPTSTR lpPageFiles, LPINT lpInitialSize, LPINT lpMaximumSize)
Definition: virtmem.c:71
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
INT OldMinSize
Definition: precomp.h:60
char TCHAR
Definition: xmlstorage.h:189
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define MAX_PATH
Definition: compat.h:26
#define Len
Definition: deflate.h:82
LPTSTR pszVolume
Definition: precomp.h:59
#define _tcsupr
Definition: tchar.h:1467
#define DRIVE_FIXED
Definition: winbase.h:249
#define GetVolumeInformation
Definition: winbase.h:3670
#define lstrlen
Definition: winbase.h:3693
#define lstrcpy
Definition: winbase.h:3691
int _tcsncmp(const _TCHAR *s1, const _TCHAR *s2, size_t n)
Definition: tcsncmp.h:9
TCHAR szDrive[3]
Definition: precomp.h:58
LPTSTR szPagingFiles
Definition: precomp.h:72
#define lstrcpyn
Definition: winbase.h:3692

Referenced by OnInitVirtMemDialog().

◆ ReadPageFileSettings()

static BOOL ReadPageFileSettings ( PVIRTMEM  pVirtMem)
static

Definition at line 16 of file virtmem.c.

17 {
18  HKEY hkey = NULL;
19  DWORD dwType;
20  DWORD dwDataSize;
21  BOOL bRet = FALSE;
22 
24  lpKey,
25  0,
26  NULL,
29  NULL,
30  &hkey,
31  NULL) == ERROR_SUCCESS)
32  {
33  if (RegQueryValueEx(hkey,
34  _T("PagingFiles"),
35  NULL,
36  &dwType,
37  NULL,
38  &dwDataSize) == ERROR_SUCCESS)
39  {
41  0,
42  dwDataSize);
43  if (pVirtMem->szPagingFiles != NULL)
44  {
45  ZeroMemory(pVirtMem->szPagingFiles,
46  dwDataSize);
47  if (RegQueryValueEx(hkey,
48  _T("PagingFiles"),
49  NULL,
50  &dwType,
51  (PBYTE)pVirtMem->szPagingFiles,
52  &dwDataSize) == ERROR_SUCCESS)
53  {
54  bRet = TRUE;
55  }
56  }
57  }
58  }
59 
60  if (!bRet)
61  ShowLastWin32Error(pVirtMem->hSelf);
62 
63  if (hkey != NULL)
64  RegCloseKey(hkey);
65 
66  return bRet;
67 }
#define RegQueryValueEx
Definition: winreg.h:524
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ZeroMemory
Definition: winbase.h:1635
HWND hSelf
Definition: precomp.h:70
CHAR * LPTSTR
Definition: xmlstorage.h:192
void ShowLastWin32Error(HWND hwndParent)
Definition: winutils.c:11
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define _T(x)
Definition: vfdio.h:22
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
static LPCTSTR lpKey
Definition: virtmem.c:13
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
BYTE * PBYTE
Definition: pedump.c:66
#define RegCreateKeyEx
Definition: winreg.h:501
LPTSTR szPagingFiles
Definition: precomp.h:72
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by OnInitVirtMemDialog().

◆ SetListBoxColumns()

static VOID SetListBoxColumns ( HWND  hwndListBox)
static

Definition at line 258 of file virtmem.c.

259 {
260  RECT rect = {0, 0, 103, 0};
261  MapDialogRect(hwndListBox, &rect);
262 
263  SendMessage(hwndListBox, LB_SETTABSTOPS, (WPARAM)1, (LPARAM)&rect.right);
264 }
#define LB_SETTABSTOPS
Definition: winuser.h:2051
BOOL WINAPI MapDialogRect(_In_ HWND, _Inout_ LPRECT)
UINT_PTR WPARAM
Definition: windef.h:207
& rect
Definition: startmenu.cpp:1413
LONG_PTR LPARAM
Definition: windef.h:208
#define SendMessage
Definition: winuser.h:5744

Referenced by OnInitVirtMemDialog().

◆ UpdatePagefileEntry()

static VOID UpdatePagefileEntry ( PVIRTMEM  pVirtMem,
INT  ListIndex,
INT  DriveIndex 
)
static

Definition at line 347 of file virtmem.c.

350 {
351  TCHAR szDisplayString[256];
352  TCHAR szSize[64];
353 
354  if ((pVirtMem->Pagefile[DriveIndex].NewMinSize == -1) &&
355  (pVirtMem->Pagefile[DriveIndex].NewMaxSize == -1))
356  {
359  szSize,
360  sizeof(szSize) / sizeof(szSize[0]));
361  }
362  else if ((pVirtMem->Pagefile[DriveIndex].NewMinSize == 0) &&
363  (pVirtMem->Pagefile[DriveIndex].NewMaxSize == 0))
364  {
367  szSize,
368  sizeof(szSize) / sizeof(szSize[0]));
369  }
370  else
371  {
372  _stprintf(szSize,
373  _T("%d - %d"),
374  pVirtMem->Pagefile[DriveIndex].NewMinSize,
375  pVirtMem->Pagefile[DriveIndex].NewMaxSize);
376  }
377 
378  _stprintf(szDisplayString,
379  _T("%s [%s]\t%s"),
380  pVirtMem->Pagefile[DriveIndex].szDrive,
381  pVirtMem->Pagefile[DriveIndex].pszVolume ? pVirtMem->Pagefile[DriveIndex].pszVolume : L"",
382  szSize);
383 
384  SendMessage(pVirtMem->hListBox, LB_DELETESTRING, (WPARAM)ListIndex, 0);
385  SendMessage(pVirtMem->hListBox, LB_INSERTSTRING, (WPARAM)ListIndex, (LPARAM)szDisplayString);
386  SendMessage(pVirtMem->hListBox, LB_SETCURSEL, (WPARAM)ListIndex, 0);
387 }
#define LB_SETCURSEL
Definition: winuser.h:2045
HWND hListBox
Definition: precomp.h:71
INT NewMaxSize
Definition: precomp.h:63
HINSTANCE hApplet
Definition: access.c:17
UINT_PTR WPARAM
Definition: windef.h:207
INT NewMinSize
Definition: precomp.h:62
PAGEFILE Pagefile[26]
Definition: precomp.h:76
LONG_PTR LPARAM
Definition: windef.h:208
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define IDS_PAGEFILE_NONE
Definition: resource.h:50
static const WCHAR L[]
Definition: oid.c:1250
LPTSTR pszVolume
Definition: precomp.h:59
#define IDS_PAGEFILE_SYSTEM
Definition: resource.h:51
#define _stprintf
Definition: utility.h:124
#define SendMessage
Definition: winuser.h:5744
#define LB_DELETESTRING
Definition: winuser.h:2014
#define LB_INSERTSTRING
Definition: winuser.h:2035
TCHAR szDrive[3]
Definition: precomp.h:58
#define LoadString
Definition: winuser.h:5720

Referenced by OnSet().

◆ VirtMemDlgProc()

INT_PTR CALLBACK VirtMemDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 664 of file virtmem.c.

668 {
669  PVIRTMEM pVirtMem;
670 
672 
673  pVirtMem = (PVIRTMEM)GetWindowLongPtr(hwndDlg, DWLP_USER);
674 
675  switch (uMsg)
676  {
677  case WM_INITDIALOG:
678  pVirtMem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(VIRTMEM));
679  if (pVirtMem == NULL)
680  {
681  EndDialog(hwndDlg, 0);
682  return FALSE;
683  }
684 
685  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pVirtMem);
686 
687  OnInitVirtMemDialog(hwndDlg, pVirtMem);
688  break;
689 
690  case WM_DESTROY:
691  OnDestroy(pVirtMem);
692  break;
693 
694  case WM_COMMAND:
695  switch (LOWORD(wParam))
696  {
697  case IDCANCEL:
698  EndDialog(hwndDlg, 0);
699  return TRUE;
700 
701  case IDOK:
702  OnVirtMemDialogOk(pVirtMem);
703  EndDialog(hwndDlg, pVirtMem->bModified);
704  return TRUE;
705 
706  case IDC_NOPAGEFILE:
707  OnNoPagingFile(pVirtMem);
708  return TRUE;
709 
710  case IDC_SYSMANSIZE:
711  OnSysManSize(pVirtMem);
712  return TRUE;
713 
714  case IDC_CUSTOM:
715  OnCustom(pVirtMem);
716  return TRUE;
717 
718  case IDC_SET:
719  OnSet(pVirtMem);
720  return TRUE;
721 
722  case IDC_PAGEFILELIST:
723  switch (HIWORD(wParam))
724  {
725  case LBN_SELCHANGE:
726  OnSelChange(hwndDlg, pVirtMem);
727  return TRUE;
728  }
729  break;
730  }
731  break;
732  }
733 
734  return FALSE;
735 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define IDC_SYSMANSIZE
Definition: resource.h:146
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
static VOID OnNoPagingFile(PVIRTMEM pVirtMem)
Definition: virtmem.c:268
#define IDC_CUSTOM
Definition: resource.h:143
#define IDC_PAGEFILELIST
Definition: resource.h:139
#define LBN_SELCHANGE
Definition: winuser.h:2057
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
static VOID OnVirtMemDialogOk(PVIRTMEM pVirtMem)
Definition: virtmem.c:600
smooth NULL
Definition: ftsmooth.c:416
#define IDC_NOPAGEFILE
Definition: resource.h:147
static VOID OnSysManSize(PVIRTMEM pVirtMem)
Definition: virtmem.c:277
#define WM_DESTROY
Definition: winuser.h:1591
struct _VIRTMEM * PVIRTMEM
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL bModified
Definition: precomp.h:75
static BOOL OnSelChange(HWND hwndDlg, PVIRTMEM pVirtMem)
Definition: virtmem.c:500
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1722
static VOID OnInitVirtMemDialog(HWND hwnd, PVIRTMEM pVirtMem)
Definition: virtmem.c:616
static VOID OnCustom(PVIRTMEM pVirtMem)
Definition: virtmem.c:286
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define HIWORD(l)
Definition: typedefs.h:246
#define IDC_SET
Definition: resource.h:148
static VOID OnSet(PVIRTMEM pVirtMem)
Definition: virtmem.c:391
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
static VOID OnDestroy(PVIRTMEM pVirtMem)
Definition: virtmem.c:646

Referenced by AdvancedPageProc().

◆ WritePageFileSettings()

static VOID WritePageFileSettings ( PVIRTMEM  pVirtMem)
static

Definition at line 179 of file virtmem.c.

180 {
181  HKEY hk = NULL;
182  TCHAR szPagingFiles[2048];
183  TCHAR szText[256];
184  INT i, nPos = 0;
185  BOOL bErr = TRUE;
186 
187  for (i = 0; i < pVirtMem->Count; ++i)
188  {
189  if (pVirtMem->Pagefile[i].bUsed &&
190  pVirtMem->Pagefile[i].NewMinSize != -1 &&
191  pVirtMem->Pagefile[i].NewMaxSize != -1)
192  {
194  _T("%s\\pagefile.sys %i %i"),
195  pVirtMem->Pagefile[i].szDrive,
196  pVirtMem->Pagefile[i].NewMinSize,
197  pVirtMem->Pagefile[i].NewMaxSize);
198 
199  /* Add it to our overall registry string */
200  lstrcpy(szPagingFiles + nPos, szText);
201 
202  /* Record the position where the next string will start */
203  nPos += (INT)lstrlen(szText) + 1;
204 
205  /* Add another NULL for REG_MULTI_SZ */
206  szPagingFiles[nPos] = _T('\0');
207  nPos++;
208  }
209  }
210 
212  lpKey,
213  0,
214  NULL,
216  KEY_WRITE,
217  NULL,
218  &hk,
219  NULL) == ERROR_SUCCESS)
220  {
221  if (RegSetValueEx(hk,
222  _T("PagingFiles"),
223  0,
224  REG_MULTI_SZ,
225  (LPBYTE) szPagingFiles,
226  (DWORD) nPos * sizeof(TCHAR)) == ERROR_SUCCESS)
227  {
228  bErr = FALSE;
229  }
230 
231  RegCloseKey(hk);
232  }
233 
234  if (bErr == FALSE)
235  {
236  /* Delete obsolete paging files on the next boot */
237  for (i = 0; i < 26; i++)
238  {
239  if (pVirtMem->Pagefile[i].OldMinSize != -1 &&
240  pVirtMem->Pagefile[i].NewMinSize == -1)
241  {
243  _T("%s\\pagefile.sys"),
244  pVirtMem->Pagefile[i].szDrive);
245 
247  }
248  }
249  }
250 
251  if (bErr)
252  ShowLastWin32Error(pVirtMem->hSelf);
253 
254 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
INT Count
Definition: precomp.h:74
#define INT
Definition: polytest.cpp:20
INT NewMaxSize
Definition: precomp.h:63
#define MoveFileEx
Definition: winbase.h:3695
HWND hSelf
Definition: precomp.h:70
INT NewMinSize
Definition: precomp.h:62
PAGEFILE Pagefile[26]
Definition: precomp.h:76
int32_t INT
Definition: typedefs.h:56
void ShowLastWin32Error(HWND hwndParent)
Definition: winutils.c:11
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
Definition: glfuncs.h:248
BOOL bUsed
Definition: precomp.h:65
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
static const WCHAR szText[]
Definition: dialog.c:139
unsigned int BOOL
Definition: ntddk_ex.h:94
#define REG_MULTI_SZ
Definition: nt_native.h:1501
smooth NULL
Definition: ftsmooth.c:416
#define MOVEFILE_DELAY_UNTIL_REBOOT
Definition: winbase.h:381
INT OldMinSize
Definition: precomp.h:60
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
unsigned long DWORD
Definition: ntddk_ex.h:95
static LPCTSTR lpKey
Definition: virtmem.c:13
#define _stprintf
Definition: utility.h:124
#define lstrlen
Definition: winbase.h:3693
#define lstrcpy
Definition: winbase.h:3691
TCHAR szDrive[3]
Definition: precomp.h:58
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by OnVirtMemDialogOk().

Variable Documentation

◆ lpKey