Avoid various uninitialised memory errors while reading Registry.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2017-06-11 10:21:28 +01:00
parent df53415d98
commit 6996c5fc47
3 changed files with 26 additions and 8 deletions

View file

@ -7,3 +7,5 @@ BOOL RegLoadString (LPCTSTR,LPCTSTR,BOOL,LPTSTR,DWORD);
BOOL RegLoadValue (LPCTSTR,LPCTSTR,BOOL,DWORD *);
void RegSaveString (LPCTSTR,LPCTSTR,BOOL,LPCTSTR);
void RegSaveValue (LPCTSTR,LPCTSTR,BOOL,DWORD);
BOOL RegLoadValue (LPCTSTR,LPCTSTR,BOOL,BOOL *);

View file

@ -68,13 +68,13 @@ BOOL RegLoadString (LPCTSTR section, LPCTSTR key, BOOL peruser,
strncpy(buffer, s.c_str(), chars);
buffer[chars - 1] = 0;
result = TRUE;
LogFileOutput("RegLoadString: %s - %s = %s\n", section, key, buffer);
}
catch (const std::exception & e)
{
result = FALSE;
LogFileOutput("RegLoadString: %s - %s = ??\n", section, key);
}
LogFileOutput("RegLoadString: %s - %s = %s\n", section, key, buffer);
return result;
}
@ -85,13 +85,30 @@ BOOL RegLoadValue (LPCTSTR section, LPCTSTR key, BOOL peruser, DWORD *value)
{
*value = Configuration::instance->getValue<DWORD>(section, key);
result = TRUE;
LogFileOutput("RegLoadValue: %s - %s = %d\n", section, key, *value);
}
catch (const std::exception & e)
{
result = FALSE;
LogFileOutput("RegLoadValue: %s - %s = ??\n", section, key);
}
return result;
}
LogFileOutput("RegLoadValue: %s - %s = %d\n", section, key, *value);
BOOL RegLoadValue (LPCTSTR section, LPCTSTR key, BOOL peruser, BOOL *value)
{
BOOL result;
try
{
*value = Configuration::instance->getValue<BOOL>(section, key);
result = TRUE;
LogFileOutput("RegLoadValue: %s - %s = %d\n", section, key, *value);
}
catch (const std::exception & e)
{
result = FALSE;
LogFileOutput("RegLoadValue: %s - %s = ??\n", section, key);
}
return result;
}

View file

@ -182,19 +182,18 @@ void LoadConfiguration(void)
#endif
REGLOAD(TEXT(REGVALUE_EMULATION_SPEED) ,&g_dwSpeed);
DWORD dwTmp;
REGLOAD(TEXT(REGVALUE_ENHANCE_DISK_SPEED), &dwTmp);
enhancedisk = dwTmp;
REGLOAD(TEXT(REGVALUE_ENHANCE_DISK_SPEED), &enhancedisk);
#if 0
Config_Load_Video();
REGLOAD(TEXT("Uthernet Active"), &dwTmp);
tfe_enabled = dwTmp;
REGLOAD(TEXT("Uthernet Active"), &tfe_enabled);
#endif
SetCurrentCLK6502();
//
DWORD dwTmp;
#if 0
if(REGLOAD(TEXT(REGVALUE_THE_FREEZES_F8_ROM), &dwTmp))
sg_PropertySheet.SetTheFreezesF8Rom(dwTmp);