From 4fa5f10a818fd082aad5b73d54e325373f43a186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Tue, 3 Mar 2015 21:03:21 +0000 Subject: [PATCH] [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 --- reactos/base/applications/magnify/settings.c | 86 ++++++++++---------- reactos/base/services/eventlog/eventlog.c | 36 +++++--- reactos/base/services/eventlog/eventsource.c | 10 ++- 3 files changed, 74 insertions(+), 58 deletions(-) diff --git a/reactos/base/applications/magnify/settings.c b/reactos/base/applications/magnify/settings.c index 2ef1686735d..3cc320319e6 100644 --- a/reactos/base/applications/magnify/settings.c +++ b/reactos/base/applications/magnify/settings.c @@ -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); + } } diff --git a/reactos/base/services/eventlog/eventlog.c b/reactos/base/services/eventlog/eventlog.c index d6ce730845a..3af4980ef0e 100644 --- a/reactos/base/services/eventlog/eventlog.c +++ b/reactos/base/services/eventlog/eventlog.c @@ -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; diff --git a/reactos/base/services/eventlog/eventsource.c b/reactos/base/services/eventlog/eventsource.c index 63192a6be22..03e95991c75 100644 --- a/reactos/base/services/eventlog/eventsource.c +++ b/reactos/base/services/eventlog/eventsource.c @@ -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);