[MAGNIFY]: Fix CID 512972 and CID 512973.

[EVENTLOG]: Fix CID 515148, CID 515149 and CID 512988.
By Ricardo Hanke.
CORE-9314 CORE-9316 #resolve #comment Committed, thanks!

svn path=/trunk/; revision=66558
This commit is contained in:
Hermès Bélusca-Maïto 2015-03-03 21:03:21 +00:00
parent 0117e3b8cb
commit 4fa5f10a81
3 changed files with 74 additions and 58 deletions

View file

@ -21,37 +21,37 @@ void LoadSettings()
LONG value;
ULONG len;
RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0,
_T(""), 0, KEY_READ, NULL, &hkey, NULL);
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
{
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryMagLevel"), 0, 0, (BYTE *)&value, &len))
{
if(value >= 0 && value <= 9)
iZoom = value;
}
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryMagLevel"), 0, 0, (BYTE *)&value, &len))
{
if(value >= 0 && value <= 9)
iZoom = value;
}
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("ShowWarning"), 0, 0, (BYTE *)&value, &len))
bShowWarning = (value == 0 ? FALSE : TRUE);
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("ShowWarning"), 0, 0, (BYTE *)&value, &len))
bShowWarning = (value == 0 ? FALSE : TRUE);
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryInvertColors"), 0, 0, (BYTE *)&value, &len))
bInvertColors = (value == 0 ? FALSE : TRUE);
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryInvertColors"), 0, 0, (BYTE *)&value, &len))
bInvertColors = (value == 0 ? FALSE : TRUE);
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryStartMinimized"), 0, 0, (BYTE *)&value, &len))
bStartMinimized = (value == 0 ? FALSE : TRUE);
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryStartMinimized"), 0, 0, (BYTE *)&value, &len))
bStartMinimized = (value == 0 ? FALSE : TRUE);
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackCursor"), 0, 0, (BYTE *)&value, &len))
bFollowMouse = (value == 0 ? FALSE : TRUE);
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackCursor"), 0, 0, (BYTE *)&value, &len))
bFollowMouse = (value == 0 ? FALSE : TRUE);
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackFocus"), 0, 0, (BYTE *)&value, &len))
bFollowFocus = (value == 0 ? FALSE : TRUE);
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackFocus"), 0, 0, (BYTE *)&value, &len))
bFollowFocus = (value == 0 ? FALSE : TRUE);
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackSecondaryFocus"), 0, 0, (BYTE *)&value, &len))
bFollowFocus = (value == 0 ? FALSE : TRUE);
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackSecondaryFocus"), 0, 0, (BYTE *)&value, &len))
bFollowFocus = (value == 0 ? FALSE : TRUE);
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackText"), 0, 0, (BYTE *)&value, &len))
bFollowCaret = (value == 0 ? FALSE : TRUE);
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackText"), 0, 0, (BYTE *)&value, &len))
bFollowCaret = (value == 0 ? FALSE : TRUE);
RegCloseKey(hkey);
RegCloseKey(hkey);
}
}
void SaveSettings()
@ -59,32 +59,32 @@ void SaveSettings()
HKEY hkey;
LONG value;
RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0,
_T(""), 0, KEY_WRITE, NULL, &hkey, NULL);
if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0, _T(""), 0, KEY_WRITE, NULL, &hkey, NULL) == ERROR_SUCCESS)
{
value = iZoom;
RegSetValueEx(hkey, _T("StationaryMagLevel"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = iZoom;
RegSetValueEx(hkey, _T("StationaryMagLevel"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bShowWarning;
RegSetValueEx(hkey, _T("ShowWarning"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bShowWarning;
RegSetValueEx(hkey, _T("ShowWarning"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bInvertColors;
RegSetValueEx(hkey, _T("StationaryInvertColors"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bInvertColors;
RegSetValueEx(hkey, _T("StationaryInvertColors"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bStartMinimized;
RegSetValueEx(hkey, _T("StationaryStartMinimized"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bStartMinimized;
RegSetValueEx(hkey, _T("StationaryStartMinimized"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bFollowMouse;
RegSetValueEx(hkey, _T("StationaryTrackCursor"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bFollowMouse;
RegSetValueEx(hkey, _T("StationaryTrackCursor"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bFollowFocus;
RegSetValueEx(hkey, _T("StationaryTrackFocus"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bFollowFocus;
RegSetValueEx(hkey, _T("StationaryTrackFocus"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bFollowFocus;
RegSetValueEx(hkey, _T("StationaryTrackSecondaryFocus"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bFollowFocus;
RegSetValueEx(hkey, _T("StationaryTrackSecondaryFocus"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bFollowCaret;
RegSetValueEx(hkey, _T("StationaryTrackText"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
value = bFollowCaret;
RegSetValueEx(hkey, _T("StationaryTrackText"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
RegCloseKey(hkey);
RegCloseKey(hkey);
}
}

View file

@ -280,8 +280,13 @@ PLOGFILE LoadLogFile(HKEY hKey, WCHAR * LogName)
DPRINT("LoadLogFile: %S\n", LogName);
RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, &MaxValueLen, NULL, NULL);
Result = RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, &MaxValueLen, NULL, NULL);
if (Result != ERROR_SUCCESS)
{
DPRINT1("RegQueryInfoKey failed: %lu\n", Result);
return NULL;
}
Buf = HeapAlloc(MyHeap, 0, MaxValueLen);
if (!Buf)
@ -300,7 +305,7 @@ PLOGFILE LoadLogFile(HKEY hKey, WCHAR * LogName)
&ValueLen);
if (Result != ERROR_SUCCESS)
{
DPRINT1("RegQueryValueEx failed: %lu\n", GetLastError());
DPRINT1("RegQueryValueEx failed: %lu\n", Result);
HeapFree(MyHeap, 0, Buf);
return NULL;
}
@ -367,16 +372,21 @@ PLOGFILE LoadLogFile(HKEY hKey, WCHAR * LogName)
BOOL LoadLogFiles(HKEY eventlogKey)
{
LONG result;
LONG Result;
DWORD MaxLognameLen, LognameLen;
WCHAR *Buf = NULL;
INT i;
PLOGFILE pLogFile;
RegQueryInfoKey(eventlogKey,
NULL, NULL, NULL, NULL,
&MaxLognameLen,
NULL, NULL, NULL, NULL, NULL, NULL);
Result = RegQueryInfoKey(eventlogKey,
NULL, NULL, NULL, NULL,
&MaxLognameLen,
NULL, NULL, NULL, NULL, NULL, NULL);
if (Result != ERROR_SUCCESS)
{
DPRINT1("RegQueryInfoKey failed: %lu\n", Result);
return FALSE;
}
MaxLognameLen++;
@ -401,8 +411,8 @@ BOOL LoadLogFiles(HKEY eventlogKey)
DPRINT("%S\n", Buf);
result = RegOpenKeyEx(eventlogKey, Buf, 0, KEY_ALL_ACCESS, &SubKey);
if (result != ERROR_SUCCESS)
Result = RegOpenKeyEx(eventlogKey, Buf, 0, KEY_ALL_ACCESS, &SubKey);
if (Result != ERROR_SUCCESS)
{
DPRINT1("Failed to open %S key.\n", Buf);
HeapFree(MyHeap, 0, Buf);
@ -433,7 +443,7 @@ INT wmain()
{
WCHAR LogPath[MAX_PATH];
INT RetCode = 0;
LONG result;
LONG Result;
HKEY elogKey;
LogfListInitialize();
@ -457,13 +467,13 @@ INT wmain()
}
else
{
result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Services\\EventLog",
0,
KEY_ALL_ACCESS,
&elogKey);
if (result != ERROR_SUCCESS)
if (Result != ERROR_SUCCESS)
{
DPRINT1("Fatal error: can't open eventlog registry key.\n");
RetCode = 1;

View file

@ -62,11 +62,17 @@ LoadEventSources(HKEY hKey,
DWORD dwEventSourceNameLength;
DWORD dwIndex;
WCHAR *Buf = NULL;
LONG Result;
DPRINT("LoadEventSources\n");
RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, &dwMaxSubKeyLength, NULL,
NULL, NULL, NULL, NULL, NULL);
Result = RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, &dwMaxSubKeyLength, NULL,
NULL, NULL, NULL, NULL, NULL);
if (Result != ERROR_SUCCESS)
{
DPRINT1("RegQueryInfoKey failed: %lu\n", Result);
return FALSE;
}
DPRINT("dwMaxSubKeyLength: %lu\n", dwMaxSubKeyLength);