mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 02:13:53 +00:00
Fix the code to read the SystemDrive environment variable
svn path=/trunk/; revision=25712
This commit is contained in:
parent
352fb74648
commit
6bbca5c035
1 changed files with 36 additions and 9 deletions
|
@ -45,22 +45,49 @@ StartRecDlgProc(HWND hwndDlg,
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
|
DWORD dwBufSize;
|
||||||
|
|
||||||
/* get Path to freeldr.ini or boot.ini */
|
/* get Path to freeldr.ini or boot.ini */
|
||||||
szSystemDrive = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAX_PATH);
|
szSystemDrive = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(TCHAR));
|
||||||
if (szSystemDrive != NULL)
|
if (szSystemDrive != NULL)
|
||||||
{
|
{
|
||||||
szSystemDrive = _tgetenv(_T("SystemDrive"));
|
dwBufSize = GetEnvironmentVariable(_T("SystemDrive"), szSystemDrive, MAX_PATH);
|
||||||
if (m_szFreeldrIni != NULL && szSystemDrive != NULL)
|
if (dwBufSize > MAX_PATH)
|
||||||
{
|
{
|
||||||
_tcscpy(m_szFreeldrIni, szSystemDrive);
|
TCHAR *szTmp;
|
||||||
_tcscat(m_szFreeldrIni, _T("\\freeldr.ini"));
|
DWORD dwBufSize2;
|
||||||
if (!PathFileExists(m_szFreeldrIni))
|
|
||||||
|
szTmp = HeapReAlloc(GetProcessHeap(), 0, szSystemDrive, dwBufSize * sizeof(TCHAR));
|
||||||
|
if (szTmp == NULL)
|
||||||
|
goto FailGetSysDrive;
|
||||||
|
|
||||||
|
szSystemDrive = szTmp;
|
||||||
|
|
||||||
|
dwBufSize2 = GetEnvironmentVariable(_T("SystemDrive"), szSystemDrive, dwBufSize);
|
||||||
|
if (dwBufSize2 > dwBufSize || dwBufSize2 == 0)
|
||||||
|
goto FailGetSysDrive;
|
||||||
|
}
|
||||||
|
else if (dwBufSize == 0)
|
||||||
|
{
|
||||||
|
FailGetSysDrive:
|
||||||
|
HeapFree(GetProcessHeap(), 0, szSystemDrive);
|
||||||
|
szSystemDrive = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (szSystemDrive != NULL)
|
||||||
|
{
|
||||||
|
if (m_szFreeldrIni != NULL)
|
||||||
{
|
{
|
||||||
_tcscpy(m_szFreeldrIni, szSystemDrive);
|
_tcscpy(m_szFreeldrIni, szSystemDrive);
|
||||||
_tcscat(m_szFreeldrIni, _T("\\boot.ini"));
|
_tcscat(m_szFreeldrIni, _T("\\freeldr.ini"));
|
||||||
|
if (!PathFileExists(m_szFreeldrIni))
|
||||||
|
{
|
||||||
|
_tcscpy(m_szFreeldrIni, szSystemDrive);
|
||||||
|
_tcscat(m_szFreeldrIni, _T("\\boot.ini"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
HeapFree(GetProcessHeap(), 0, szSystemDrive);
|
||||||
}
|
}
|
||||||
HeapFree(GetProcessHeap(), 0, szSystemDrive);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDlgItemText(hwndDlg, IDC_STRRECDUMPFILE, _T("%SystemRoot%\\MiniDump"));
|
SetDlgItemText(hwndDlg, IDC_STRRECDUMPFILE, _T("%SystemRoot%\\MiniDump"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue