We were checking for the presence of KEY_WRITE in the SAM to decide
whether to call RegCreateKeyEx() or RegOpenKeyEx(). KEY_WRITE is an
alias for STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY so
the function was incorrectly calling RegCreateKeyEx() even when
RegOpenKeyEx() would be more appropriate.
return 0;\r
}\r
\r
- if (sam & KEY_WRITE) {\r
+ if (sam & KEY_SET_VALUE) {\r
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, registry, 0, 0, REG_OPTION_NON_VOLATILE, sam, 0, &key, 0) != ERROR_SUCCESS) {\r
log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_OPENKEY_FAILED, registry, error_string(GetLastError()), 0);\r
return 0;\r