Преглед изворни кода

Not an error if no hook found in the registry.

Hooks are optional so we shouldn't log an error if one wasn't found.

Thanks Mathias Breiner.
Iain Patterson пре 8 година
родитељ
комит
838c282576
2 измењених фајлова са 11 додато и 3 уклоњено
  1. 2 1
      README.txt
  2. 9 2
      registry.cpp

+ 2 - 1
README.txt

@@ -880,7 +880,8 @@ Thanks to Gerald Haider for noticing that installing a service with NSSM in a
 path containing spaces was technically a security vulnerability.
 Thanks to Scott Ware for reporting a crash saving the environment on XP 32-bit.
 Thanks to Stefan and Michael Scherer for reporting a bug writing the event messages source.
-Thanks to Paul Baxter and Mathias Breiner for help with Visual Studio 2015.
+Thanks to Paul Baxter for help with Visual Studio 2015.
+Thanks to Mathias Breiner for help with Visual Studio and some registry fixes.
 
 Licence
 -------

+ 9 - 2
registry.cpp

@@ -822,8 +822,15 @@ int get_hook(const TCHAR *service_name, const TCHAR *hook_event, const TCHAR *ho
     log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_OUT_OF_MEMORY, _T("hook registry"), _T("get_hook()"), 0);
     return 1;
   }
-  HKEY key = open_registry(service_name, registry, KEY_READ, false);
-  if (! key) return 1;
+  HKEY key;
+  long error = open_registry(service_name, registry, KEY_READ, &key, false);
+  if (! key) {
+    if (error == ERROR_FILE_NOT_FOUND) {
+      ZeroMemory(buffer, buflen);
+      return 0;
+    }
+    return 1;
+  }
 
   int ret = expand_parameter(key, (TCHAR *) hook_action, buffer, buflen, true, false);