Get rid of static variables.

svn path=/trunk/; revision=30135
This commit is contained in:
Eric Kohl 2007-11-04 22:12:25 +00:00
parent 49f59088cf
commit a139a7c2ad
4 changed files with 177 additions and 135 deletions

View file

@ -275,8 +275,8 @@ GetSystemInformation(HWND hwnd)
TCHAR Buf[32]; TCHAR Buf[32];
INT CurMachineLine = IDC_MACHINELINE1; INT CurMachineLine = IDC_MACHINELINE1;
/*
/* Get Processor information * * Get Processor information
* although undocumented, this information is being pulled * although undocumented, this information is being pulled
* directly out of the registry instead of via setupapi as it * directly out of the registry instead of via setupapi as it
* contains all the info we need, and should remain static * contains all the info we need, and should remain static
@ -372,18 +372,33 @@ GeneralPageProc(HWND hwndDlg,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
static IMGINFO ImgInfo; PIMGINFO pImgInfo;
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
UNREFERENCED_PARAMETER(wParam); UNREFERENCED_PARAMETER(wParam);
pImgInfo = (PIMGINFO)GetWindowLongPtr(hwndDlg, DWLP_USER);
switch (uMsg) switch (uMsg)
{ {
case WM_INITDIALOG: 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); GetSystemInformation(hwndDlg);
break; break;
case WM_DESTROY:
HeapFree(GetProcessHeap(), 0, pImgInfo);
break;
case WM_COMMAND: case WM_COMMAND:
if (LOWORD(wParam) == IDC_LICENCE) if (LOWORD(wParam) == IDC_LICENCE)
{ {
@ -406,12 +421,12 @@ GeneralPageProc(HWND hwndDlg,
LONG left; LONG left;
/* position image in centre of dialog */ /* position image in centre of dialog */
left = (lpDrawItem->rcItem.right - ImgInfo.cxSource) / 2; left = (lpDrawItem->rcItem.right - pImgInfo->cxSource) / 2;
hdcMem = CreateCompatibleDC(lpDrawItem->hDC); hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
if (hdcMem != NULL) if (hdcMem != NULL)
{ {
SelectObject(hdcMem, ImgInfo.hBitmap); SelectObject(hdcMem, pImgInfo->hBitmap);
BitBlt(lpDrawItem->hDC, BitBlt(lpDrawItem->hDC,
left, left,
lpDrawItem->rcItem.top, lpDrawItem->rcItem.top,

View file

@ -9,6 +9,55 @@
#include "precomp.h" #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 INT_PTR CALLBACK
LicenceDlgProc(HWND hDlg, LicenceDlgProc(HWND hDlg,
@ -16,55 +65,35 @@ LicenceDlgProc(HWND hDlg,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
HRSRC hResInfo; PLICINFO pLicInfo;
HGLOBAL hResMem;
WCHAR *LicenseText;
static HICON hIcon;
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
pLicInfo = (PLICINFO)GetWindowLongPtr(hDlg, DWLP_USER);
switch (uMsg) switch (uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
hIcon = LoadImage(hApplet, pLicInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LICINFO));
MAKEINTRESOURCE(IDI_CPLSYSTEM), if (pLicInfo == NULL)
IMAGE_ICON,
16,
16,
0);
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)))
{ {
ShowLastWin32Error(hDlg); EndDialog(hDlg, 0);
break; return FALSE;
} }
SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pLicInfo);
return OnInitDialog(hDlg, pLicInfo);
/* insert the license into the edit control (unicode!) */ case WM_DESTROY:
SetDlgItemText(hDlg, if (pLicInfo)
IDC_LICENCEEDIT, {
LicenseText); DestroyIcon(pLicInfo->hIcon);
HeapFree(GetProcessHeap(), 0, pLicInfo);
PostMessage(GetDlgItem(hDlg, IDC_LICENCEEDIT), }
EM_SETSEL, break;
-1,
0);
return TRUE;
case WM_COMMAND: case WM_COMMAND:
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
{ {
DestroyIcon(hIcon);
EndDialog(hDlg, EndDialog(hDlg,
LOWORD(wParam)); LOWORD(wParam));
return TRUE; return TRUE;

View file

@ -9,11 +9,16 @@
*/ */
#include "precomp.h" #include "precomp.h"
static TCHAR m_szFreeldrIni[MAX_PATH + 15];
static int m_FreeLdrIni = 0; typedef struct _STARTINFO
static TCHAR m_szDumpFile[MAX_PATH]; {
static TCHAR m_szMinidumpDir[MAX_PATH]; TCHAR szFreeldrIni[MAX_PATH + 15];
static DWORD m_dwCrashDumpEnabled = 0; TCHAR szDumpFile[MAX_PATH];
TCHAR szMinidumpDir[MAX_PATH];
DWORD dwCrashDumpEnabled;
INT iFreeLdrIni;
} STARTINFO, *PSTARTINFO;
static VOID static VOID
SetTimeout(HWND hwndDlg, INT Timeout) SetTimeout(HWND hwndDlg, INT Timeout)
@ -422,7 +427,7 @@ DeleteBootRecords(HWND hwndDlg)
} }
static LRESULT static LRESULT
LoadOSList(HWND hwndDlg) LoadOSList(HWND hwndDlg, PSTARTINFO pStartInfo)
{ {
DWORD dwBufSize; DWORD dwBufSize;
TCHAR *szSystemDrive; TCHAR *szSystemDrive;
@ -432,13 +437,13 @@ LoadOSList(HWND hwndDlg)
if (!dwBufSize) if (!dwBufSize)
return FALSE; return FALSE;
_tcscpy(m_szFreeldrIni, szSystemDrive); _tcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
_tcscat(m_szFreeldrIni, _T("\\freeldr.ini")); _tcscat(pStartInfo->szFreeldrIni, _T("\\freeldr.ini"));
if (PathFileExists(m_szFreeldrIni)) if (PathFileExists(pStartInfo->szFreeldrIni))
{ {
/* freeldr.ini exists */ /* freeldr.ini exists */
hInf = SetupOpenInfFile(m_szFreeldrIni, hInf = SetupOpenInfFile(pStartInfo->szFreeldrIni,
NULL, NULL,
INF_STYLE_OLDNT, INF_STYLE_OLDNT,
NULL); NULL);
@ -447,20 +452,20 @@ LoadOSList(HWND hwndDlg)
{ {
LoadFreeldrSettings(hInf, hwndDlg); LoadFreeldrSettings(hInf, hwndDlg);
SetupCloseInfFile(hInf); SetupCloseInfFile(hInf);
m_FreeLdrIni = 1; pStartInfo->iFreeLdrIni = 1;
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
/* try load boot.ini settings */ /* try load boot.ini settings */
_tcscpy(m_szFreeldrIni, szSystemDrive); _tcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
_tcscat(m_szFreeldrIni, _T("\\boot.ini")); _tcscat(pStartInfo->szFreeldrIni, _T("\\boot.ini"));
if (PathFileExists(m_szFreeldrIni)) if (PathFileExists(pStartInfo->szFreeldrIni))
{ {
/* load boot.ini settings */ /* load boot.ini settings */
hInf = SetupOpenInfFile(m_szFreeldrIni, hInf = SetupOpenInfFile(pStartInfo->szFreeldrIni,
NULL, NULL,
INF_STYLE_OLDNT, INF_STYLE_OLDNT,
NULL); NULL);
@ -469,7 +474,7 @@ LoadOSList(HWND hwndDlg)
{ {
LoadBootSettings(hInf, hwndDlg); LoadBootSettings(hInf, hwndDlg);
SetupCloseInfFile(hInf); SetupCloseInfFile(hInf);
m_FreeLdrIni = 2; pStartInfo->iFreeLdrIni = 2;
return TRUE; return TRUE;
} }
@ -480,36 +485,37 @@ LoadOSList(HWND hwndDlg)
} }
static VOID static VOID
SetCrashDlgItems(HWND hwnd) SetCrashDlgItems(HWND hwnd, PSTARTINFO pStartInfo)
{ {
if (m_dwCrashDumpEnabled == 0) if (pStartInfo->dwCrashDumpEnabled == 0)
{ {
/* no crash information required */ /* no crash information required */
EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), FALSE);
} }
else if (m_dwCrashDumpEnabled == 3) else if (pStartInfo->dwCrashDumpEnabled == 3)
{ {
/* minidump type */ /* minidump type */
EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), TRUE); EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), TRUE);
EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), FALSE);
SendMessage(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0, (LPARAM)m_szMinidumpDir); SendMessage(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0, (LPARAM)pStartInfo->szMinidumpDir);
} }
else if (m_dwCrashDumpEnabled == 1 || m_dwCrashDumpEnabled == 2) else if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2)
{ {
/* kernel or complete dump */ /* kernel or complete dump */
EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), TRUE); EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), TRUE);
EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), TRUE); EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), TRUE);
SendMessage(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0, (LPARAM)m_szDumpFile); SendMessage(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0, (LPARAM)pStartInfo->szDumpFile);
} }
SendDlgItemMessage(hwnd, IDC_STRRECDEBUGCOMBO, CB_SETCURSEL, (WPARAM)m_dwCrashDumpEnabled, (LPARAM)0); SendDlgItemMessage(hwnd, IDC_STRRECDEBUGCOMBO, CB_SETCURSEL, (WPARAM)pStartInfo->dwCrashDumpEnabled, (LPARAM)0);
} }
static VOID static VOID
WriteStartupRecoveryOptions(HWND hwndDlg) WriteStartupRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo)
{ {
HKEY hKey; HKEY hKey;
DWORD lResult; DWORD lResult;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
_T("System\\CurrentControlSet\\Control\\CrashControl"), _T("System\\CurrentControlSet\\Control\\CrashControl"),
0, 0,
@ -533,23 +539,23 @@ WriteStartupRecoveryOptions(HWND hwndDlg)
RegSetValueEx(hKey, _T("Overwrite"), 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult)); RegSetValueEx(hKey, _T("Overwrite"), 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult));
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);
RegSetValueEx(hKey, _T("DumpFile"), 0, REG_EXPAND_SZ, (LPBYTE)&m_szDumpFile, (_tcslen(m_szDumpFile) + 1) * sizeof(TCHAR)); RegSetValueEx(hKey, _T("DumpFile"), 0, REG_EXPAND_SZ, (LPBYTE)pStartInfo->szDumpFile, (_tcslen(pStartInfo->szDumpFile) + 1) * sizeof(TCHAR));
} }
else if (m_dwCrashDumpEnabled == 3) else if (pStartInfo->dwCrashDumpEnabled == 3)
{ {
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);
RegSetValueEx(hKey, _T("MinidumpDir"), 0, REG_EXPAND_SZ, (LPBYTE)&m_szDumpFile, (_tcslen(m_szDumpFile) + 1) * sizeof(TCHAR)); 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)&m_dwCrashDumpEnabled, sizeof(m_dwCrashDumpEnabled)); RegSetValueEx(hKey, _T("CrashDumpEnabled"), 0, REG_DWORD, (LPBYTE)pStartInfo->dwCrashDumpEnabled, sizeof(pStartInfo->dwCrashDumpEnabled));
RegCloseKey(hKey); RegCloseKey(hKey);
} }
static VOID static VOID
LoadRecoveryOptions(HWND hwndDlg) LoadRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo)
{ {
HKEY hKey; HKEY hKey;
DWORD dwValues; DWORD dwValues;
@ -626,15 +632,15 @@ LoadRecoveryOptions(HWND hwndDlg)
} }
else if (!_tcscmp(szName, _T("DumpFile"))) else if (!_tcscmp(szName, _T("DumpFile")))
{ {
_tcscpy(m_szDumpFile, szValue); _tcscpy(pStartInfo->szDumpFile, szValue);
} }
else if (!_tcscmp(szName, _T("MinidumpDir"))) else if (!_tcscmp(szName, _T("MinidumpDir")))
{ {
_tcscpy(m_szMinidumpDir, szValue); _tcscpy(pStartInfo->szMinidumpDir, szValue);
} }
else if (!_tcscmp(szName, _T("CrashDumpEnabled"))) else if (!_tcscmp(szName, _T("CrashDumpEnabled")))
{ {
m_dwCrashDumpEnabled = dwValue; pStartInfo->dwCrashDumpEnabled = dwValue;
} }
} }
@ -650,7 +656,7 @@ LoadRecoveryOptions(HWND hwndDlg)
if (LoadString(hApplet, IDS_MINI_DUMP, szValue, sizeof(szValue) / sizeof(TCHAR)) < sizeof(szValue) / sizeof(TCHAR)) 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); SendDlgItemMessage(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szValue);
SetCrashDlgItems(hwndDlg); SetCrashDlgItems(hwndDlg, pStartInfo);
RegCloseKey(hKey); RegCloseKey(hKey);
} }
@ -662,6 +668,7 @@ StartRecDlgProc(HWND hwndDlg,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
PSTARTINFO pStartInfo;
PBOOTRECORD pRecord; PBOOTRECORD pRecord;
int iTimeout; int iTimeout;
LRESULT lResult; LRESULT lResult;
@ -669,17 +676,27 @@ StartRecDlgProc(HWND hwndDlg,
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
pStartInfo = (PSTARTINFO)GetWindowLongPtr(hwndDlg, DWLP_USER);
switch(uMsg) switch(uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
LoadRecoveryOptions(hwndDlg); pStartInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(STARTINFO));
return LoadOSList(hwndDlg); 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: case WM_COMMAND:
switch(LOWORD(wParam)) switch(LOWORD(wParam))
{ {
case IDC_STRRECEDIT: 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 // FIXME use CreateProcess and wait untill finished
// DeleteBootRecords(hwndDlg); // DeleteBootRecords(hwndDlg);
// LoadOSList(hwndDlg); // LoadOSList(hwndDlg);
@ -705,44 +722,42 @@ StartRecDlgProc(HWND hwndDlg,
if ((INT)pRecord != CB_ERR) if ((INT)pRecord != CB_ERR)
{ {
if (m_FreeLdrIni == 1) // FreeLdrIni style if (pStartInfo->iFreeLdrIni == 1) // FreeLdrIni style
{ {
/* set default timeout */ /* set default timeout */
WritePrivateProfileString(_T("FREELOADER"), WritePrivateProfileString(_T("FREELOADER"),
_T("TimeOut"), _T("TimeOut"),
szTimeout, szTimeout,
m_szFreeldrIni); pStartInfo->szFreeldrIni);
/* set default os */ /* set default os */
WritePrivateProfileString(_T("FREELOADER"), WritePrivateProfileString(_T("FREELOADER"),
_T("DefaultOS"), _T("DefaultOS"),
pRecord->szSectionName, pRecord->szSectionName,
m_szFreeldrIni); pStartInfo->szFreeldrIni);
} }
else if (m_FreeLdrIni == 2) // BootIni style else if (pStartInfo->iFreeLdrIni == 2) // BootIni style
{ {
/* set default timeout */ /* set default timeout */
WritePrivateProfileString(_T("boot loader"), WritePrivateProfileString(_T("boot loader"),
_T("timeout"), _T("timeout"),
szTimeout, szTimeout,
m_szFreeldrIni); pStartInfo->szFreeldrIni);
/* set default os */ /* set default os */
WritePrivateProfileString(_T("boot loader"), WritePrivateProfileString(_T("boot loader"),
_T("default"), _T("default"),
pRecord->szBootPath, pRecord->szBootPath,
m_szFreeldrIni); pStartInfo->szFreeldrIni);
} }
} }
WriteStartupRecoveryOptions(hwndDlg); WriteStartupRecoveryOptions(hwndDlg, pStartInfo);
DeleteBootRecords(hwndDlg);
EndDialog(hwndDlg, EndDialog(hwndDlg,
LOWORD(wParam)); LOWORD(wParam));
return TRUE; return TRUE;
case IDCANCEL: case IDCANCEL:
DeleteBootRecords(hwndDlg);
EndDialog(hwndDlg, EndDialog(hwndDlg,
LOWORD(wParam)); LOWORD(wParam));
return TRUE; return TRUE;
@ -760,19 +775,19 @@ StartRecDlgProc(HWND hwndDlg,
LRESULT lResult; LRESULT lResult;
lResult = SendDlgItemMessage(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_GETCURSEL, (WPARAM)0, (LPARAM)0); 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; pStartInfo->dwCrashDumpEnabled = lResult;
SetCrashDlgItems(hwndDlg); SetCrashDlgItems(hwndDlg, pStartInfo);
} }
} }
break; break;

View file

@ -422,43 +422,12 @@ OnOk(PVIRTMEM pVirtMem)
{ {
WritePageFileSettings(pVirtMem); WritePageFileSettings(pVirtMem);
} }
if (pVirtMem->szPagingFiles)
HeapFree(GetProcessHeap(),
0,
pVirtMem->szPagingFiles);
HeapFree(GetProcessHeap(),
0,
pVirtMem);
} }
static VOID static VOID
OnCancel(PVIRTMEM pVirtMem) OnInitDialog(HWND hwnd, 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);
}
pVirtMem->hSelf = hwnd; pVirtMem->hSelf = hwnd;
pVirtMem->hListBox = GetDlgItem(hwnd, IDC_PAGEFILELIST); pVirtMem->hListBox = GetDlgItem(hwnd, IDC_PAGEFILELIST);
pVirtMem->bSave = FALSE; pVirtMem->bSave = FALSE;
@ -471,8 +440,6 @@ OnInitDialog(HWND hwnd)
/* Parse our settings and set up dialog */ /* Parse our settings and set up dialog */
ParseMemSettings(pVirtMem); ParseMemSettings(pVirtMem);
} }
return pVirtMem;
} }
@ -482,22 +449,38 @@ VirtMemDlgProc(HWND hwndDlg,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
/* there can only be one instance of this dialog */ PVIRTMEM pVirtMem;
static PVIRTMEM pVirtMem = NULL;
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
pVirtMem = (PVIRTMEM)GetWindowLongPtr(hwndDlg, DWLP_USER);
switch (uMsg) switch (uMsg)
{ {
case WM_INITDIALOG: 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; break;
case WM_COMMAND: case WM_COMMAND:
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case IDCANCEL: case IDCANCEL:
OnCancel(pVirtMem);
EndDialog(hwndDlg, 0); EndDialog(hwndDlg, 0);
return TRUE; return TRUE;