Author: ekohl
Date: Mon Nov 5 01:12:25 2007
New Revision: 30135
URL:
http://svn.reactos.org/svn/reactos?rev=30135&view=rev
Log:
Get rid of static variables.
Modified:
trunk/reactos/dll/cpl/sysdm/general.c
trunk/reactos/dll/cpl/sysdm/licence.c
trunk/reactos/dll/cpl/sysdm/startrec.c
trunk/reactos/dll/cpl/sysdm/virtmem.c
Modified: trunk/reactos/dll/cpl/sysdm/general.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/general.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/general.c (original)
+++ trunk/reactos/dll/cpl/sysdm/general.c Mon Nov 5 01:12:25 2007
@@ -275,8 +275,8 @@
TCHAR Buf[32];
INT CurMachineLine = IDC_MACHINELINE1;
-
- /* Get Processor information *
+ /*
+ * Get Processor information
* although undocumented, this information is being pulled
* directly out of the registry instead of via setupapi as it
* contains all the info we need, and should remain static
@@ -372,16 +372,31 @@
WPARAM wParam,
LPARAM lParam)
{
- static IMGINFO ImgInfo;
+ PIMGINFO pImgInfo;
UNREFERENCED_PARAMETER(lParam);
UNREFERENCED_PARAMETER(wParam);
+ pImgInfo = (PIMGINFO)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
switch (uMsg)
{
case WM_INITDIALOG:
- InitImageInfo(&ImgInfo);
+ pImgInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMGINFO));
+ if (pImgInfo == NULL)
+ {
+ EndDialog(hwndDlg, 0);
+ return FALSE;
+ }
+
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pImgInfo);
+
+ InitImageInfo(pImgInfo);
GetSystemInformation(hwndDlg);
+ break;
+
+ case WM_DESTROY:
+ HeapFree(GetProcessHeap(), 0, pImgInfo);
break;
case WM_COMMAND:
@@ -406,12 +421,12 @@
LONG left;
/* position image in centre of dialog */
- left = (lpDrawItem->rcItem.right - ImgInfo.cxSource) / 2;
+ left = (lpDrawItem->rcItem.right - pImgInfo->cxSource) / 2;
hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
if (hdcMem != NULL)
{
- SelectObject(hdcMem, ImgInfo.hBitmap);
+ SelectObject(hdcMem, pImgInfo->hBitmap);
BitBlt(lpDrawItem->hDC,
left,
lpDrawItem->rcItem.top,
Modified: trunk/reactos/dll/cpl/sysdm/licence.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/licence.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/licence.c (original)
+++ trunk/reactos/dll/cpl/sysdm/licence.c Mon Nov 5 01:12:25 2007
@@ -9,6 +9,55 @@
#include "precomp.h"
+typedef struct _LICINFO
+{
+ HICON hIcon;
+} LICINFO, *PLICINFO;
+
+
+static BOOL
+OnInitDialog(HWND hDlg, PLICINFO pLicInfo)
+{
+ HRSRC hResInfo;
+ HGLOBAL hResMem;
+ WCHAR *LicenseText;
+
+ pLicInfo->hIcon = LoadImage(hApplet,
+ MAKEINTRESOURCE(IDI_CPLSYSTEM),
+ IMAGE_ICON,
+ 16,
+ 16,
+ 0);
+
+ SendMessage(hDlg,
+ WM_SETICON,
+ ICON_SMALL,
+ (LPARAM)pLicInfo->hIcon);
+
+ /* load license from resource */
+ if (!(hResInfo = FindResource(hApplet,
+ MAKEINTRESOURCE(RC_LICENSE),
+ MAKEINTRESOURCE(RTDATA))) ||
+ !(hResMem = LoadResource(hApplet, hResInfo)) ||
+ !(LicenseText = LockResource(hResMem)))
+ {
+ ShowLastWin32Error(hDlg);
+ return FALSE;
+ }
+
+ /* insert the license into the edit control (unicode!) */
+ SetDlgItemText(hDlg,
+ IDC_LICENCEEDIT,
+ LicenseText);
+
+ PostMessage(GetDlgItem(hDlg, IDC_LICENCEEDIT),
+ EM_SETSEL,
+ -1,
+ 0);
+
+ return TRUE;
+}
+
INT_PTR CALLBACK
LicenceDlgProc(HWND hDlg,
@@ -16,55 +65,35 @@
WPARAM wParam,
LPARAM lParam)
{
- HRSRC hResInfo;
- HGLOBAL hResMem;
- WCHAR *LicenseText;
- static HICON hIcon;
+ PLICINFO pLicInfo;
UNREFERENCED_PARAMETER(lParam);
+
+ pLicInfo = (PLICINFO)GetWindowLongPtr(hDlg, DWLP_USER);
switch (uMsg)
{
case WM_INITDIALOG:
- hIcon = LoadImage(hApplet,
- MAKEINTRESOURCE(IDI_CPLSYSTEM),
- IMAGE_ICON,
- 16,
- 16,
- 0);
+ pLicInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LICINFO));
+ if (pLicInfo == NULL)
+ {
+ EndDialog(hDlg, 0);
+ return FALSE;
+ }
+ SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pLicInfo);
+ return OnInitDialog(hDlg, pLicInfo);
- SendMessage(hDlg,
- WM_SETICON,
- ICON_SMALL,
- (LPARAM)hIcon);
-
- /* load license from resource */
- if(!(hResInfo = FindResource(hApplet,
- MAKEINTRESOURCE(RC_LICENSE),
- MAKEINTRESOURCE(RTDATA))) ||
- !(hResMem = LoadResource(hApplet, hResInfo)) ||
- !(LicenseText = LockResource(hResMem)))
+ case WM_DESTROY:
+ if (pLicInfo)
{
- ShowLastWin32Error(hDlg);
- break;
+ DestroyIcon(pLicInfo->hIcon);
+ HeapFree(GetProcessHeap(), 0, pLicInfo);
}
-
- /* insert the license into the edit control (unicode!) */
- SetDlgItemText(hDlg,
- IDC_LICENCEEDIT,
- LicenseText);
-
- PostMessage(GetDlgItem(hDlg, IDC_LICENCEEDIT),
- EM_SETSEL,
- -1,
- 0);
-
- return TRUE;
+ break;
case WM_COMMAND:
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
{
- DestroyIcon(hIcon);
EndDialog(hDlg,
LOWORD(wParam));
return TRUE;
Modified: trunk/reactos/dll/cpl/sysdm/startrec.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/startrec.c?r…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/startrec.c (original)
+++ trunk/reactos/dll/cpl/sysdm/startrec.c Mon Nov 5 01:12:25 2007
@@ -9,11 +9,16 @@
*/
#include "precomp.h"
-static TCHAR m_szFreeldrIni[MAX_PATH + 15];
-static int m_FreeLdrIni = 0;
-static TCHAR m_szDumpFile[MAX_PATH];
-static TCHAR m_szMinidumpDir[MAX_PATH];
-static DWORD m_dwCrashDumpEnabled = 0;
+
+typedef struct _STARTINFO
+{
+ TCHAR szFreeldrIni[MAX_PATH + 15];
+ TCHAR szDumpFile[MAX_PATH];
+ TCHAR szMinidumpDir[MAX_PATH];
+ DWORD dwCrashDumpEnabled;
+ INT iFreeLdrIni;
+} STARTINFO, *PSTARTINFO;
+
static VOID
SetTimeout(HWND hwndDlg, INT Timeout)
@@ -422,7 +427,7 @@
}
static LRESULT
-LoadOSList(HWND hwndDlg)
+LoadOSList(HWND hwndDlg, PSTARTINFO pStartInfo)
{
DWORD dwBufSize;
TCHAR *szSystemDrive;
@@ -432,13 +437,13 @@
if (!dwBufSize)
return FALSE;
- _tcscpy(m_szFreeldrIni, szSystemDrive);
- _tcscat(m_szFreeldrIni, _T("\\freeldr.ini"));
-
- if (PathFileExists(m_szFreeldrIni))
+ _tcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
+ _tcscat(pStartInfo->szFreeldrIni, _T("\\freeldr.ini"));
+
+ if (PathFileExists(pStartInfo->szFreeldrIni))
{
/* freeldr.ini exists */
- hInf = SetupOpenInfFile(m_szFreeldrIni,
+ hInf = SetupOpenInfFile(pStartInfo->szFreeldrIni,
NULL,
INF_STYLE_OLDNT,
NULL);
@@ -447,20 +452,20 @@
{
LoadFreeldrSettings(hInf, hwndDlg);
SetupCloseInfFile(hInf);
- m_FreeLdrIni = 1;
+ pStartInfo->iFreeLdrIni = 1;
return TRUE;
}
return FALSE;
}
/* try load boot.ini settings */
- _tcscpy(m_szFreeldrIni, szSystemDrive);
- _tcscat(m_szFreeldrIni, _T("\\boot.ini"));
-
- if (PathFileExists(m_szFreeldrIni))
+ _tcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
+ _tcscat(pStartInfo->szFreeldrIni, _T("\\boot.ini"));
+
+ if (PathFileExists(pStartInfo->szFreeldrIni))
{
/* load boot.ini settings */
- hInf = SetupOpenInfFile(m_szFreeldrIni,
+ hInf = SetupOpenInfFile(pStartInfo->szFreeldrIni,
NULL,
INF_STYLE_OLDNT,
NULL);
@@ -469,7 +474,7 @@
{
LoadBootSettings(hInf, hwndDlg);
SetupCloseInfFile(hInf);
- m_FreeLdrIni = 2;
+ pStartInfo->iFreeLdrIni = 2;
return TRUE;
}
@@ -480,36 +485,37 @@
}
static VOID
-SetCrashDlgItems(HWND hwnd)
-{
- if (m_dwCrashDumpEnabled == 0)
+SetCrashDlgItems(HWND hwnd, PSTARTINFO pStartInfo)
+{
+ if (pStartInfo->dwCrashDumpEnabled == 0)
{
/* no crash information required */
EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), FALSE);
}
- else if (m_dwCrashDumpEnabled == 3)
+ else if (pStartInfo->dwCrashDumpEnabled == 3)
{
/* minidump type */
EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), TRUE);
EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), FALSE);
- SendMessage(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0,
(LPARAM)m_szMinidumpDir);
- }
- else if (m_dwCrashDumpEnabled == 1 || m_dwCrashDumpEnabled == 2)
+ SendMessage(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0,
(LPARAM)pStartInfo->szMinidumpDir);
+ }
+ else if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled
== 2)
{
/* kernel or complete dump */
EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), TRUE);
EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), TRUE);
- SendMessage(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0,
(LPARAM)m_szDumpFile);
- }
- SendDlgItemMessage(hwnd, IDC_STRRECDEBUGCOMBO, CB_SETCURSEL,
(WPARAM)m_dwCrashDumpEnabled, (LPARAM)0);
+ SendMessage(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0,
(LPARAM)pStartInfo->szDumpFile);
+ }
+ SendDlgItemMessage(hwnd, IDC_STRRECDEBUGCOMBO, CB_SETCURSEL,
(WPARAM)pStartInfo->dwCrashDumpEnabled, (LPARAM)0);
}
static VOID
-WriteStartupRecoveryOptions(HWND hwndDlg)
+WriteStartupRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo)
{
HKEY hKey;
DWORD lResult;
+
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
_T("System\\CurrentControlSet\\Control\\CrashControl"),
0,
@@ -533,23 +539,23 @@
RegSetValueEx(hKey, _T("Overwrite"), 0, REG_DWORD, (LPBYTE)&lResult,
sizeof(lResult));
- if (m_dwCrashDumpEnabled == 1 || m_dwCrashDumpEnabled == 2)
- {
- SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT,
(WPARAM)sizeof(m_szDumpFile) / sizeof(TCHAR), (LPARAM)m_szDumpFile);
- RegSetValueEx(hKey, _T("DumpFile"), 0, REG_EXPAND_SZ,
(LPBYTE)&m_szDumpFile, (_tcslen(m_szDumpFile) + 1) * sizeof(TCHAR));
- }
- else if (m_dwCrashDumpEnabled == 3)
- {
- SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT,
(WPARAM)sizeof(m_szDumpFile) / sizeof(TCHAR), (LPARAM)m_szDumpFile);
- RegSetValueEx(hKey, _T("MinidumpDir"), 0, REG_EXPAND_SZ,
(LPBYTE)&m_szDumpFile, (_tcslen(m_szDumpFile) + 1) * sizeof(TCHAR));
- }
-
- RegSetValueEx(hKey, _T("CrashDumpEnabled"), 0, REG_DWORD,
(LPBYTE)&m_dwCrashDumpEnabled, sizeof(m_dwCrashDumpEnabled));
+ if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled ==
2)
+ {
+ SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT,
(WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(TCHAR),
(LPARAM)pStartInfo->szDumpFile);
+ RegSetValueEx(hKey, _T("DumpFile"), 0, REG_EXPAND_SZ,
(LPBYTE)pStartInfo->szDumpFile, (_tcslen(pStartInfo->szDumpFile) + 1) *
sizeof(TCHAR));
+ }
+ else if (pStartInfo->dwCrashDumpEnabled == 3)
+ {
+ SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT,
(WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(TCHAR),
(LPARAM)pStartInfo->szDumpFile);
+ RegSetValueEx(hKey, _T("MinidumpDir"), 0, REG_EXPAND_SZ,
(LPBYTE)pStartInfo->szDumpFile, (_tcslen(pStartInfo->szDumpFile) + 1) *
sizeof(TCHAR));
+ }
+
+ RegSetValueEx(hKey, _T("CrashDumpEnabled"), 0, REG_DWORD,
(LPBYTE)pStartInfo->dwCrashDumpEnabled, sizeof(pStartInfo->dwCrashDumpEnabled));
RegCloseKey(hKey);
}
static VOID
-LoadRecoveryOptions(HWND hwndDlg)
+LoadRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo)
{
HKEY hKey;
DWORD dwValues;
@@ -626,15 +632,15 @@
}
else if (!_tcscmp(szName, _T("DumpFile")))
{
- _tcscpy(m_szDumpFile, szValue);
+ _tcscpy(pStartInfo->szDumpFile, szValue);
}
else if (!_tcscmp(szName, _T("MinidumpDir")))
{
- _tcscpy(m_szMinidumpDir, szValue);
+ _tcscpy(pStartInfo->szMinidumpDir, szValue);
}
else if (!_tcscmp(szName, _T("CrashDumpEnabled")))
{
- m_dwCrashDumpEnabled = dwValue;
+ pStartInfo->dwCrashDumpEnabled = dwValue;
}
}
@@ -650,7 +656,7 @@
if (LoadString(hApplet, IDS_MINI_DUMP, szValue, sizeof(szValue) / sizeof(TCHAR)) <
sizeof(szValue) / sizeof(TCHAR))
SendDlgItemMessage(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0,
(LPARAM) szValue);
- SetCrashDlgItems(hwndDlg);
+ SetCrashDlgItems(hwndDlg, pStartInfo);
RegCloseKey(hKey);
}
@@ -662,6 +668,7 @@
WPARAM wParam,
LPARAM lParam)
{
+ PSTARTINFO pStartInfo;
PBOOTRECORD pRecord;
int iTimeout;
LRESULT lResult;
@@ -669,17 +676,27 @@
UNREFERENCED_PARAMETER(lParam);
+ pStartInfo = (PSTARTINFO)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
switch(uMsg)
{
case WM_INITDIALOG:
- LoadRecoveryOptions(hwndDlg);
- return LoadOSList(hwndDlg);
+ pStartInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(STARTINFO));
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pStartInfo);
+
+ LoadRecoveryOptions(hwndDlg, pStartInfo);
+ return LoadOSList(hwndDlg, pStartInfo);
+
+ case WM_DESTROY:
+ DeleteBootRecords(hwndDlg);
+ HeapFree(GetProcessHeap(), 0, pStartInfo);
+ break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_STRRECEDIT:
- ShellExecute(0, _T("open"), _T("notepad"),
m_szFreeldrIni, NULL, SW_SHOWNORMAL);
+ ShellExecute(0, _T("open"), _T("notepad"),
pStartInfo->szFreeldrIni, NULL, SW_SHOWNORMAL);
// FIXME use CreateProcess and wait untill finished
// DeleteBootRecords(hwndDlg);
// LoadOSList(hwndDlg);
@@ -705,44 +722,42 @@
if ((INT)pRecord != CB_ERR)
{
- if (m_FreeLdrIni == 1) // FreeLdrIni style
+ if (pStartInfo->iFreeLdrIni == 1) // FreeLdrIni style
{
/* set default timeout */
WritePrivateProfileString(_T("FREELOADER"),
_T("TimeOut"),
szTimeout,
- m_szFreeldrIni);
+ pStartInfo->szFreeldrIni);
/* set default os */
WritePrivateProfileString(_T("FREELOADER"),
_T("DefaultOS"),
pRecord->szSectionName,
- m_szFreeldrIni);
+ pStartInfo->szFreeldrIni);
}
- else if (m_FreeLdrIni == 2) // BootIni style
+ else if (pStartInfo->iFreeLdrIni == 2) // BootIni style
{
/* set default timeout */
WritePrivateProfileString(_T("boot loader"),
_T("timeout"),
szTimeout,
- m_szFreeldrIni);
+ pStartInfo->szFreeldrIni);
/* set default os */
WritePrivateProfileString(_T("boot loader"),
_T("default"),
pRecord->szBootPath,
- m_szFreeldrIni);
+ pStartInfo->szFreeldrIni);
}
}
- WriteStartupRecoveryOptions(hwndDlg);
- DeleteBootRecords(hwndDlg);
+ WriteStartupRecoveryOptions(hwndDlg, pStartInfo);
EndDialog(hwndDlg,
LOWORD(wParam));
return TRUE;
case IDCANCEL:
- DeleteBootRecords(hwndDlg);
EndDialog(hwndDlg,
LOWORD(wParam));
return TRUE;
@@ -760,19 +775,19 @@
LRESULT lResult;
lResult = SendDlgItemMessage(hwndDlg, IDC_STRRECDEBUGCOMBO,
CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
- if (lResult != CB_ERR && lResult !=
m_dwCrashDumpEnabled)
+ if (lResult != CB_ERR && lResult !=
pStartInfo->dwCrashDumpEnabled)
{
- if (m_dwCrashDumpEnabled == 1 || m_dwCrashDumpEnabled == 2)
+ if (pStartInfo->dwCrashDumpEnabled == 1 ||
pStartInfo->dwCrashDumpEnabled == 2)
{
- SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE,
WM_GETTEXT, (WPARAM)sizeof(m_szDumpFile) / sizeof(TCHAR), (LPARAM)m_szDumpFile);
+ SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE,
WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(TCHAR),
(LPARAM)pStartInfo->szDumpFile);
}
- else if (m_dwCrashDumpEnabled == 3)
+ else if (pStartInfo->dwCrashDumpEnabled == 3)
{
- SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE,
WM_GETTEXT, (WPARAM)sizeof(m_szMinidumpDir) / sizeof(TCHAR), (LPARAM)m_szMinidumpDir);
+ SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE,
WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szMinidumpDir) / sizeof(TCHAR),
(LPARAM)pStartInfo->szMinidumpDir);
}
- m_dwCrashDumpEnabled = lResult;
- SetCrashDlgItems(hwndDlg);
+ pStartInfo->dwCrashDumpEnabled = lResult;
+ SetCrashDlgItems(hwndDlg, pStartInfo);
}
}
break;
Modified: trunk/reactos/dll/cpl/sysdm/virtmem.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/virtmem.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/virtmem.c (original)
+++ trunk/reactos/dll/cpl/sysdm/virtmem.c Mon Nov 5 01:12:25 2007
@@ -422,43 +422,12 @@
{
WritePageFileSettings(pVirtMem);
}
-
- if (pVirtMem->szPagingFiles)
- HeapFree(GetProcessHeap(),
- 0,
- pVirtMem->szPagingFiles);
-
- HeapFree(GetProcessHeap(),
- 0,
- pVirtMem);
-}
-
-
-static VOID
-OnCancel(PVIRTMEM pVirtMem)
-{
- if (pVirtMem->szPagingFiles)
- HeapFree(GetProcessHeap(),
- 0,
- pVirtMem->szPagingFiles);
-
- HeapFree(GetProcessHeap(),
- 0,
- pVirtMem);
-}
-
-
-static PVIRTMEM
-OnInitDialog(HWND hwnd)
-{
- PVIRTMEM pVirtMem = (PVIRTMEM)HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- sizeof(VIRTMEM));
- if (pVirtMem == NULL)
- {
- EndDialog(hwnd, 0);
- }
-
+}
+
+
+static VOID
+OnInitDialog(HWND hwnd, PVIRTMEM pVirtMem)
+{
pVirtMem->hSelf = hwnd;
pVirtMem->hListBox = GetDlgItem(hwnd, IDC_PAGEFILELIST);
pVirtMem->bSave = FALSE;
@@ -471,8 +440,6 @@
/* Parse our settings and set up dialog */
ParseMemSettings(pVirtMem);
}
-
- return pVirtMem;
}
@@ -482,22 +449,38 @@
WPARAM wParam,
LPARAM lParam)
{
- /* there can only be one instance of this dialog */
- static PVIRTMEM pVirtMem = NULL;
+ PVIRTMEM pVirtMem;
UNREFERENCED_PARAMETER(lParam);
+ pVirtMem = (PVIRTMEM)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
switch (uMsg)
{
case WM_INITDIALOG:
- pVirtMem = OnInitDialog(hwndDlg);
+ pVirtMem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(VIRTMEM));
+ if (pVirtMem == NULL)
+ {
+ EndDialog(hwndDlg, 0);
+ return FALSE;
+ }
+
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pVirtMem);
+
+ OnInitDialog(hwndDlg, pVirtMem);
+ break;
+
+ case WM_DESTROY:
+ if (pVirtMem->szPagingFiles)
+ HeapFree(GetProcessHeap(), 0,
+ pVirtMem->szPagingFiles);
+ HeapFree(GetProcessHeap(), 0, pVirtMem);
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDCANCEL:
- OnCancel(pVirtMem);
EndDialog(hwndDlg, 0);
return TRUE;