ReactOS  0.4.15-dev-499-g1f31905
virtmem.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for virtmem.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

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")
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file virtmem.c.

Function Documentation

◆ GetPageFileSizes()

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

Definition at line 74 of file virtmem.c.

77 {
78  INT i = 0;
79 
80  *lpInitialSize = -1;
81  *lpMaximumSize = -1;
82 
83  while (*lpPageFiles != _T('\0'))
84  {
85  if (*lpPageFiles == _T(' '))
86  {
87  lpPageFiles++;
88 
89  switch (i)
90  {
91  case 0:
92  *lpInitialSize = (INT)_ttoi(lpPageFiles);
93  i = 1;
94  break;
95 
96  case 1:
97  *lpMaximumSize = (INT)_ttoi(lpPageFiles);
98  return;
99  }
100  }
101 
102  lpPageFiles++;
103  }
104 }
#define INT
Definition: polytest.cpp:20
int32_t INT
Definition: typedefs.h:57
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 298 of file virtmem.c.

299 {
300  TCHAR szDisplayString[256];
301  TCHAR szSize[64];
302  INT Index;
303  INT i;
304 
305  for (i = 0; i < 26; i++)
306  {
307  if (pVirtMem->Pagefile[i].bUsed)
308  {
309  if ((pVirtMem->Pagefile[i].NewMinSize == -1) &&
310  (pVirtMem->Pagefile[i].NewMaxSize == -1))
311  {
314  szSize,
315  sizeof(szSize) / sizeof(szSize[0]));
316  }
317  else if ((pVirtMem->Pagefile[i].NewMinSize == 0) &&
318  (pVirtMem->Pagefile[i].NewMaxSize == 0))
319  {
322  szSize,
323  sizeof(szSize) / sizeof(szSize[0]));
324  }
325  else
326  {
327  _stprintf(szSize, _T("%d - %d"),
328  pVirtMem->Pagefile[i].NewMinSize,
329  pVirtMem->Pagefile[i].NewMaxSize);
330  }
331 
332  _stprintf(szDisplayString,
333  _T("%s [%s]\t%s"),
334  pVirtMem->Pagefile[i].szDrive,
335  pVirtMem->Pagefile[i].pszVolume ? pVirtMem->Pagefile[i].pszVolume : _T(""),
336  szSize);
337 
338  Index = SendMessage(pVirtMem->hListBox, LB_ADDSTRING, (WPARAM)0, (LPARAM)szDisplayString);
339  SendMessage(pVirtMem->hListBox, LB_SETITEMDATA, Index, i);
340  }
341  }
342 
343  SendMessage(pVirtMem->hListBox, LB_SETCURSEL, (WPARAM)0, (LPARAM)0);
344 
345  OnSelChange(pVirtMem->hSelf, pVirtMem);
346 }
#define LB_SETCURSEL
Definition: winuser.h:2045
HWND hListBox
Definition: precomp.h:70
#define LB_ADDSTRING
Definition: winuser.h:2013
INT NewMaxSize
Definition: precomp.h:62
HINSTANCE hApplet
Definition: access.c:17
UINT_PTR WPARAM
Definition: windef.h:207
HWND hSelf
Definition: precomp.h:69
INT NewMinSize
Definition: precomp.h:61
PAGEFILE Pagefile[26]
Definition: precomp.h:75
int32_t INT
Definition: typedefs.h:57
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:64
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:504
LPTSTR pszVolume
Definition: precomp.h:58
#define IDS_PAGEFILE_SYSTEM
Definition: resource.h:51
#define _stprintf
Definition: utility.h:124
#define SendMessage
Definition: winuser.h:5818
TCHAR szDrive[3]
Definition: precomp.h:57
#define LoadString
Definition: winuser.h:5794

Referenced by OnInitVirtMemDialog().

◆ OnCustom()

static VOID OnCustom ( PVIRTMEM  pVirtMem)
static

Definition at line 289 of file virtmem.c.

290 {
291  /* Enable the page file custom size boxes */
294 }
#define TRUE
Definition: types.h:120
HWND hSelf
Definition: precomp.h:69
#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 672 of file virtmem.c.

673 {
674  INT i;
675 
676  for (i = 0; i < 26; i++)
677  {
678  if (pVirtMem->Pagefile[i].pszVolume != NULL)
679  HeapFree(GetProcessHeap(), 0, pVirtMem->Pagefile[i].pszVolume);
680  }
681 
682  if (pVirtMem->szPagingFiles)
683  HeapFree(GetProcessHeap(), 0, pVirtMem->szPagingFiles);
684 
685  HeapFree(GetProcessHeap(), 0, pVirtMem);
686 }
PAGEFILE Pagefile[26]
Definition: precomp.h:75
int32_t INT
Definition: typedefs.h:57
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:404
LPTSTR pszVolume
Definition: precomp.h:58
#define HeapFree(x, y, z)
Definition: compat.h:403
LPTSTR szPagingFiles
Definition: precomp.h:71

Referenced by VirtMemDlgProc().

◆ OnInitVirtMemDialog()

static VOID OnInitVirtMemDialog ( HWND  hwnd,
PVIRTMEM  pVirtMem 
)
static

Definition at line 642 of file virtmem.c.

643 {
644  INT i;
645 
646  pVirtMem->hSelf = hwnd;
648  pVirtMem->bModified = FALSE;
649 
650  SetListBoxColumns(pVirtMem->hListBox);
651 
652  for (i = 0; i < 26; i++)
653  {
654  pVirtMem->Pagefile[i].bUsed = FALSE;
655  pVirtMem->Pagefile[i].OldMinSize = -1;
656  pVirtMem->Pagefile[i].OldMaxSize = -1;
657  pVirtMem->Pagefile[i].NewMinSize = -1;
658  pVirtMem->Pagefile[i].NewMaxSize = -1;
659  }
660 
661  /* Load the pagefile systems from the reg */
662  ReadPageFileSettings(pVirtMem);
663 
664  /* Parse our settings and set up dialog */
665  ParseMemSettings(pVirtMem);
666 
667  InitPagefileList(pVirtMem);
668 }
INT OldMaxSize
Definition: precomp.h:60
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HWND hListBox
Definition: precomp.h:70
INT NewMaxSize
Definition: precomp.h:62
static VOID ParseMemSettings(PVIRTMEM pVirtMem)
Definition: virtmem.c:108
#define IDC_PAGEFILELIST
Definition: resource.h:139
HWND hSelf
Definition: precomp.h:69
INT NewMinSize
Definition: precomp.h:61
PAGEFILE Pagefile[26]
Definition: precomp.h:75
int32_t INT
Definition: typedefs.h:57
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:64
INT OldMinSize
Definition: precomp.h:59
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL bModified
Definition: precomp.h:74
static BOOL ReadPageFileSettings(PVIRTMEM pVirtMem)
Definition: virtmem.c:19
static VOID SetListBoxColumns(HWND hwndListBox)
Definition: virtmem.c:261
static VOID InitPagefileList(PVIRTMEM pVirtMem)
Definition: virtmem.c:298

Referenced by VirtMemDlgProc().

◆ OnNoPagingFile()

static VOID OnNoPagingFile ( PVIRTMEM  pVirtMem)
static

Definition at line 271 of file virtmem.c.

272 {
273  /* Disable the page file custom size boxes */
276 }
HWND hSelf
Definition: precomp.h:69
#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 504 of file virtmem.c.

505 {
506  TCHAR szBuffer[64];
507  MEMORYSTATUSEX MemoryStatus;
508  ULARGE_INTEGER FreeDiskSpace;
509  UINT i, FreeMemMb, RecoMemMb, PageFileSizeMb;
510  INT Index;
512  WIN32_FIND_DATAW fdata = {0};
513  HANDLE hFind;
514  ULARGE_INTEGER pfSize;
515 
516  Index = (INT)SendDlgItemMessage(hwndDlg,
518  LB_GETCURSEL,
519  0,
520  0);
521  if (Index >= 0 && Index < pVirtMem->Count)
522  {
523  /* Set drive letter */
524  SetDlgItemText(hwndDlg, IDC_DRIVE,
525  pVirtMem->Pagefile[Index].szDrive);
526 
527  /* Set available disk space */
528  if (GetDiskFreeSpaceEx(pVirtMem->Pagefile[Index].szDrive,
529  NULL, NULL, &FreeDiskSpace))
530  {
531  pVirtMem->Pagefile[Index].FreeSize = (UINT)(FreeDiskSpace.QuadPart / (1024 * 1024));
532  _stprintf(szBuffer, _T("%u MB"), pVirtMem->Pagefile[Index].FreeSize);
533  SetDlgItemText(hwndDlg, IDC_SPACEAVAIL, szBuffer);
534  }
535 
536  if (pVirtMem->Pagefile[Index].NewMinSize == -1 &&
537  pVirtMem->Pagefile[Index].NewMaxSize == -1)
538  {
539  /* No pagefile */
540 
543 
545  }
546  else if (pVirtMem->Pagefile[Index].NewMinSize == 0 &&
547  pVirtMem->Pagefile[Index].NewMaxSize == 0)
548  {
549  /* System managed size*/
550 
553 
555  }
556  else
557  {
558  /* Custom size */
559 
560  /* Enable and fill the custom values */
563 
564  SetDlgItemInt(pVirtMem->hSelf,
566  pVirtMem->Pagefile[Index].NewMinSize,
567  FALSE);
568 
569  SetDlgItemInt(pVirtMem->hSelf,
570  IDC_MAXSIZE,
571  pVirtMem->Pagefile[Index].NewMaxSize,
572  FALSE);
573 
574  CheckDlgButton(pVirtMem->hSelf,
575  IDC_CUSTOM,
576  BST_CHECKED);
577  }
578 
579  /* Set minimum pagefile size */
580  SetDlgItemText(hwndDlg, IDC_MINIMUM, _T("2 MB"));
581 
582  /* Set recommended pagefile size */
583  MemoryStatus.dwLength = sizeof(MEMORYSTATUSEX);
584  if (GlobalMemoryStatusEx(&MemoryStatus))
585  {
586  FreeMemMb = (UINT)(MemoryStatus.ullTotalPhys / (1024 * 1024));
587  RecoMemMb = FreeMemMb + (FreeMemMb / 2); /* The recommended VM size is 150% of free memory. */
588  if (RecoMemMb > 4096)
589  RecoMemMb = 4096;
590  _stprintf(szBuffer, _T("%u MB"), RecoMemMb);
591  SetDlgItemText(hwndDlg, IDC_RECOMMENDED, szBuffer);
592  }
593 
594  /* Set current pagefile size */
595  PageFileSizeMb = 0;
596 
597  for (i = 0; i < pVirtMem->Count; i++)
598  {
600  _T("%c:\\pagefile.sys"),
601  pVirtMem->Pagefile[i].szDrive[0]);
602 
603  hFind = FindFirstFileW(szText, &fdata);
604  if (hFind == INVALID_HANDLE_VALUE)
605  {
606  DPRINT1("Unable to read PageFile size : %ls due to error %d\n", szText,GetLastError());
607  }
608  else
609  {
610  pfSize.LowPart = fdata.nFileSizeLow;
611  pfSize.HighPart = fdata.nFileSizeHigh;
612  PageFileSizeMb += pfSize.QuadPart / (1024*1024);
613  FindClose(hFind);
614  }
615  }
616 
617  _stprintf(szBuffer, _T("%u MB"), PageFileSizeMb);
618  SetDlgItemText(hwndDlg, IDC_CURRENT, szBuffer);
619  }
620 
621  return TRUE;
622 }
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define TRUE
Definition: types.h:120
#define IDC_SYSMANSIZE
Definition: resource.h:146
INT Count
Definition: precomp.h:73
#define INT
Definition: polytest.cpp:20
#define IDC_CUSTOM
Definition: resource.h:143
INT NewMaxSize
Definition: precomp.h:62
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1173
$ULONG LowPart
Definition: ntbasedef.h:576
#define IDC_PAGEFILELIST
Definition: resource.h:139
#define SendDlgItemMessage
Definition: winuser.h:5817
HWND hSelf
Definition: precomp.h:69
INT NewMinSize
Definition: precomp.h:61
PAGEFILE Pagefile[26]
Definition: precomp.h:75
int32_t INT
Definition: typedefs.h:57
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
static const WCHAR szText[]
Definition: dialog.c:139
#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
$ULONG HighPart
Definition: ntbasedef.h:577
#define IDC_MAXSIZE
Definition: resource.h:145
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define MAX_PATH
Definition: compat.h:26
static const UCHAR Index[8]
Definition: usbohci.c:18
#define SetDlgItemText
Definition: winuser.h:5824
#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:3648
#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:63
#define BST_CHECKED
Definition: winuser.h:197
#define DPRINT1
Definition: precomp.h:8
BOOL NTAPI GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
Definition: heapmem.c:1272
TCHAR szDrive[3]
Definition: precomp.h:57
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by InitPagefileList(), and VirtMemDlgProc().

◆ OnSet()

static VOID OnSet ( PVIRTMEM  pVirtMem)
static

Definition at line 394 of file virtmem.c.

395 {
396  INT Index;
397  UINT MinSize = -1;
398  UINT MaxSize = -1;
399  BOOL bTranslated;
400  INT DriveIndex = 0;
401 
402  Index = (INT)SendDlgItemMessage(pVirtMem->hSelf,
404  LB_GETCURSEL,
405  0,
406  0);
407  if (Index >= 0 && Index < pVirtMem->Count)
408  {
409  DriveIndex = SendDlgItemMessage(pVirtMem->hSelf,
412  (WPARAM)Index,
413  0);
414 
415  /* Check if custom settings are checked */
416  if (IsDlgButtonChecked(pVirtMem->hSelf,
418  {
419  MinSize = GetDlgItemInt(pVirtMem->hSelf,
421  &bTranslated,
422  FALSE);
423  if (!bTranslated)
424  {
426  NULL,
430  return;
431  }
432 
433  MaxSize = GetDlgItemInt(pVirtMem->hSelf,
434  IDC_MAXSIZE,
435  &bTranslated,
436  FALSE);
437  if (!bTranslated)
438  {
440  NULL,
444  return;
445  }
446 
447  /* Check the valid range of the minimum size */
448  if (MinSize < 2 ||
449  MinSize > pVirtMem->Pagefile[DriveIndex].FreeSize ||
450  MinSize > 4096)
451  {
453  NULL,
457  return;
458  }
459 
460  /* Check the valid range of the maximum size */
461  if (MaxSize < MinSize ||
462  MaxSize > pVirtMem->Pagefile[DriveIndex].FreeSize ||
463  MaxSize > 4096)
464  {
466  NULL,
470  return;
471  }
472 
473  pVirtMem->Pagefile[DriveIndex].NewMinSize = MinSize;
474  pVirtMem->Pagefile[DriveIndex].NewMaxSize = MaxSize;
475  pVirtMem->Pagefile[DriveIndex].bUsed = TRUE;
476  }
477  else if (IsDlgButtonChecked(pVirtMem->hSelf,
479  {
480  /* No pagefile */
481  pVirtMem->Pagefile[DriveIndex].NewMinSize = -1;
482  pVirtMem->Pagefile[DriveIndex].NewMaxSize = -1;
483  pVirtMem->Pagefile[DriveIndex].bUsed = TRUE;
484  }
485  else
486  {
487  /* System managed size*/
488  pVirtMem->Pagefile[DriveIndex].NewMinSize = 0;
489  pVirtMem->Pagefile[DriveIndex].NewMaxSize = 0;
490  pVirtMem->Pagefile[DriveIndex].bUsed = TRUE;
491  }
492 
493  /* Set the modified flag if min or max size has changed */
494  if ((pVirtMem->Pagefile[DriveIndex].OldMinSize != pVirtMem->Pagefile[DriveIndex].NewMinSize) ||
495  (pVirtMem->Pagefile[DriveIndex].OldMaxSize != pVirtMem->Pagefile[DriveIndex].NewMaxSize))
496  pVirtMem->bModified = TRUE;
497 
498  UpdatePagefileEntry(pVirtMem, Index, DriveIndex);
499  }
500 }
INT OldMaxSize
Definition: precomp.h:60
#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:62
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1173
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:5817
HWND hSelf
Definition: precomp.h:69
INT NewMinSize
Definition: precomp.h:61
#define IDS_WARNINITIALRANGE
Definition: resource.h:48
PAGEFILE Pagefile[26]
Definition: precomp.h:75
#define IDS_WARNMAXIMUMSIZE
Definition: resource.h:47
int32_t INT
Definition: typedefs.h:57
#define MB_ICONWARNING
Definition: winuser.h:780
BOOL bUsed
Definition: precomp.h:64
unsigned int BOOL
Definition: ntddk_ex.h:94
static VOID UpdatePagefileEntry(PVIRTMEM pVirtMem, INT ListIndex, INT DriveIndex)
Definition: virtmem.c:350
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:59
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:74
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:63
#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 280 of file virtmem.c.

281 {
282  /* Disable the page file custom size boxes */
285 }
HWND hSelf
Definition: precomp.h:69
#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 626 of file virtmem.c.

627 {
628  if (pVirtMem->bModified != FALSE)
629  {
631  NULL,
635 
636  WritePageFileSettings(pVirtMem);
637  }
638 }
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:74
#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:182

Referenced by VirtMemDlgProc().

◆ ParseMemSettings()

static VOID ParseMemSettings ( PVIRTMEM  pVirtMem)
static

Definition at line 108 of file virtmem.c.

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

Referenced by OnInitVirtMemDialog().

◆ ReadPageFileSettings()

static BOOL ReadPageFileSettings ( PVIRTMEM  pVirtMem)
static

Definition at line 19 of file virtmem.c.

20 {
21  HKEY hkey = NULL;
22  DWORD dwType;
23  DWORD dwDataSize;
24  BOOL bRet = FALSE;
25 
27  lpKey,
28  0,
29  NULL,
32  NULL,
33  &hkey,
34  NULL) == ERROR_SUCCESS)
35  {
36  if (RegQueryValueEx(hkey,
37  _T("PagingFiles"),
38  NULL,
39  &dwType,
40  NULL,
41  &dwDataSize) == ERROR_SUCCESS)
42  {
44  0,
45  dwDataSize);
46  if (pVirtMem->szPagingFiles != NULL)
47  {
48  ZeroMemory(pVirtMem->szPagingFiles,
49  dwDataSize);
50  if (RegQueryValueEx(hkey,
51  _T("PagingFiles"),
52  NULL,
53  &dwType,
54  (PBYTE)pVirtMem->szPagingFiles,
55  &dwDataSize) == ERROR_SUCCESS)
56  {
57  bRet = TRUE;
58  }
59  }
60  }
61  }
62 
63  if (!bRet)
64  ShowLastWin32Error(pVirtMem->hSelf);
65 
66  if (hkey != NULL)
67  RegCloseKey(hkey);
68 
69  return bRet;
70 }
#define RegQueryValueEx
Definition: winreg.h:524
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ZeroMemory
Definition: winbase.h:1648
HWND hSelf
Definition: precomp.h:69
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:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
static LPCTSTR lpKey
Definition: virtmem.c:16
#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:71
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by OnInitVirtMemDialog().

◆ SetListBoxColumns()

static VOID SetListBoxColumns ( HWND  hwndListBox)
static

Definition at line 261 of file virtmem.c.

262 {
263  RECT rect = {0, 0, 103, 0};
264  MapDialogRect(hwndListBox, &rect);
265 
266  SendMessage(hwndListBox, LB_SETTABSTOPS, (WPARAM)1, (LPARAM)&rect.right);
267 }
#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:5818

Referenced by OnInitVirtMemDialog().

◆ UpdatePagefileEntry()

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

Definition at line 350 of file virtmem.c.

353 {
354  TCHAR szDisplayString[256];
355  TCHAR szSize[64];
356 
357  if ((pVirtMem->Pagefile[DriveIndex].NewMinSize == -1) &&
358  (pVirtMem->Pagefile[DriveIndex].NewMaxSize == -1))
359  {
362  szSize,
363  sizeof(szSize) / sizeof(szSize[0]));
364  }
365  else if ((pVirtMem->Pagefile[DriveIndex].NewMinSize == 0) &&
366  (pVirtMem->Pagefile[DriveIndex].NewMaxSize == 0))
367  {
370  szSize,
371  sizeof(szSize) / sizeof(szSize[0]));
372  }
373  else
374  {
375  _stprintf(szSize,
376  _T("%d - %d"),
377  pVirtMem->Pagefile[DriveIndex].NewMinSize,
378  pVirtMem->Pagefile[DriveIndex].NewMaxSize);
379  }
380 
381  _stprintf(szDisplayString,
382  _T("%s [%s]\t%s"),
383  pVirtMem->Pagefile[DriveIndex].szDrive,
384  pVirtMem->Pagefile[DriveIndex].pszVolume ? pVirtMem->Pagefile[DriveIndex].pszVolume : L"",
385  szSize);
386 
387  SendMessage(pVirtMem->hListBox, LB_DELETESTRING, (WPARAM)ListIndex, 0);
388  SendMessage(pVirtMem->hListBox, LB_INSERTSTRING, (WPARAM)ListIndex, (LPARAM)szDisplayString);
389  SendMessage(pVirtMem->hListBox, LB_SETCURSEL, (WPARAM)ListIndex, 0);
390 }
#define LB_SETCURSEL
Definition: winuser.h:2045
HWND hListBox
Definition: precomp.h:70
INT NewMaxSize
Definition: precomp.h:62
HINSTANCE hApplet
Definition: access.c:17
UINT_PTR WPARAM
Definition: windef.h:207
INT NewMinSize
Definition: precomp.h:61
PAGEFILE Pagefile[26]
Definition: precomp.h:75
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:58
#define IDS_PAGEFILE_SYSTEM
Definition: resource.h:51
#define _stprintf
Definition: utility.h:124
#define SendMessage
Definition: winuser.h:5818
#define LB_DELETESTRING
Definition: winuser.h:2014
#define LB_INSERTSTRING
Definition: winuser.h:2035
TCHAR szDrive[3]
Definition: precomp.h:57
#define LoadString
Definition: winuser.h:5794

Referenced by OnSet().

◆ VirtMemDlgProc()

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

Definition at line 690 of file virtmem.c.

694 {
695  PVIRTMEM pVirtMem;
696 
698 
699  pVirtMem = (PVIRTMEM)GetWindowLongPtr(hwndDlg, DWLP_USER);
700 
701  switch (uMsg)
702  {
703  case WM_INITDIALOG:
704  pVirtMem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(VIRTMEM));
705  if (pVirtMem == NULL)
706  {
707  EndDialog(hwndDlg, 0);
708  return FALSE;
709  }
710 
711  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pVirtMem);
712 
713  OnInitVirtMemDialog(hwndDlg, pVirtMem);
714  break;
715 
716  case WM_DESTROY:
717  OnDestroy(pVirtMem);
718  break;
719 
720  case WM_COMMAND:
721  switch (LOWORD(wParam))
722  {
723  case IDCANCEL:
724  EndDialog(hwndDlg, 0);
725  return TRUE;
726 
727  case IDOK:
728  OnVirtMemDialogOk(pVirtMem);
729  EndDialog(hwndDlg, pVirtMem->bModified);
730  return TRUE;
731 
732  case IDC_NOPAGEFILE:
733  OnNoPagingFile(pVirtMem);
734  return TRUE;
735 
736  case IDC_SYSMANSIZE:
737  OnSysManSize(pVirtMem);
738  return TRUE;
739 
740  case IDC_CUSTOM:
741  OnCustom(pVirtMem);
742  return TRUE;
743 
744  case IDC_SET:
745  OnSet(pVirtMem);
746  return TRUE;
747 
748  case IDC_PAGEFILELIST:
749  switch (HIWORD(wParam))
750  {
751  case LBN_SELCHANGE:
752  OnSelChange(hwndDlg, pVirtMem);
753  return TRUE;
754  }
755  break;
756  }
757  break;
758  }
759 
760  return FALSE;
761 }
#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:271
#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:626
smooth NULL
Definition: ftsmooth.c:416
#define IDC_NOPAGEFILE
Definition: resource.h:147
static VOID OnSysManSize(PVIRTMEM pVirtMem)
Definition: virtmem.c:280
#define WM_DESTROY
Definition: winuser.h:1591
struct _VIRTMEM * PVIRTMEM
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL bModified
Definition: precomp.h:74
static BOOL OnSelChange(HWND hwndDlg, PVIRTMEM pVirtMem)
Definition: virtmem.c:504
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1722
static VOID OnInitVirtMemDialog(HWND hwnd, PVIRTMEM pVirtMem)
Definition: virtmem.c:642
static VOID OnCustom(PVIRTMEM pVirtMem)
Definition: virtmem.c:289
__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:394
#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:672

Referenced by AdvancedPageProc().

◆ WritePageFileSettings()

static VOID WritePageFileSettings ( PVIRTMEM  pVirtMem)
static

Definition at line 182 of file virtmem.c.

183 {
184  HKEY hk = NULL;
185  TCHAR szPagingFiles[2048];
186  TCHAR szText[256];
187  INT i, nPos = 0;
188  BOOL bErr = TRUE;
189 
190  for (i = 0; i < pVirtMem->Count; ++i)
191  {
192  if (pVirtMem->Pagefile[i].bUsed &&
193  pVirtMem->Pagefile[i].NewMinSize != -1 &&
194  pVirtMem->Pagefile[i].NewMaxSize != -1)
195  {
197  _T("%s\\pagefile.sys %i %i"),
198  pVirtMem->Pagefile[i].szDrive,
199  pVirtMem->Pagefile[i].NewMinSize,
200  pVirtMem->Pagefile[i].NewMaxSize);
201 
202  /* Add it to our overall registry string */
203  lstrcpy(szPagingFiles + nPos, szText);
204 
205  /* Record the position where the next string will start */
206  nPos += (INT)lstrlen(szText) + 1;
207 
208  /* Add another NULL for REG_MULTI_SZ */
209  szPagingFiles[nPos] = _T('\0');
210  nPos++;
211  }
212  }
213 
215  lpKey,
216  0,
217  NULL,
219  KEY_WRITE,
220  NULL,
221  &hk,
222  NULL) == ERROR_SUCCESS)
223  {
224  if (RegSetValueEx(hk,
225  _T("PagingFiles"),
226  0,
227  REG_MULTI_SZ,
228  (LPBYTE) szPagingFiles,
229  (DWORD) nPos * sizeof(TCHAR)) == ERROR_SUCCESS)
230  {
231  bErr = FALSE;
232  }
233 
234  RegCloseKey(hk);
235  }
236 
237  if (bErr == FALSE)
238  {
239  /* Delete obsolete paging files on the next boot */
240  for (i = 0; i < 26; i++)
241  {
242  if (pVirtMem->Pagefile[i].OldMinSize != -1 &&
243  pVirtMem->Pagefile[i].NewMinSize == -1)
244  {
246  _T("%s\\pagefile.sys"),
247  pVirtMem->Pagefile[i].szDrive);
248 
250  }
251  }
252  }
253 
254  if (bErr)
255  ShowLastWin32Error(pVirtMem->hSelf);
256 
257 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
INT Count
Definition: precomp.h:73
#define INT
Definition: polytest.cpp:20
INT NewMaxSize
Definition: precomp.h:62
#define MoveFileEx
Definition: winbase.h:3718
HWND hSelf
Definition: precomp.h:69
INT NewMinSize
Definition: precomp.h:61
PAGEFILE Pagefile[26]
Definition: precomp.h:75
int32_t INT
Definition: typedefs.h:57
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:64
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
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:59
#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:16
#define _stprintf
Definition: utility.h:124
#define lstrlen
Definition: winbase.h:3716
#define lstrcpy
Definition: winbase.h:3714
TCHAR szDrive[3]
Definition: precomp.h:57
#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