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

View file

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

View file

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