There's no need to log an event if we couldn't load a missing DLL.
There's no need to go to the trouble of converting to a wide buffer if
we aren't then going to log an event.
HMODULE ret = LoadLibrary(dll);\r
if (! ret) {\r
*error = GetLastError();\r
HMODULE ret = LoadLibrary(dll);\r
if (! ret) {\r
*error = GetLastError();\r
- log_event(EVENTLOG_WARNING_TYPE, NSSM_EVENT_LOADLIBRARY_FAILED, dll, error_string(*error), 0);\r
+ if (*error != ERROR_PROC_NOT_FOUND) log_event(EVENTLOG_WARNING_TYPE, NSSM_EVENT_LOADLIBRARY_FAILED, dll, error_string(*error), 0);\r
FARPROC ret = GetProcAddress(library, function);\r
if (! ret) {\r
*error = GetLastError();\r
FARPROC ret = GetProcAddress(library, function);\r
if (! ret) {\r
*error = GetLastError();\r
- TCHAR *function_name;\r
+ if (*error != ERROR_PROC_NOT_FOUND) {\r
+ TCHAR *function_name;\r
- size_t buflen;\r
- mbstowcs_s(&buflen, NULL, 0, function, _TRUNCATE);\r
- function_name = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, buflen * sizeof(TCHAR));\r
- if (function_name) mbstowcs_s(&buflen, function_name, buflen * sizeof(TCHAR), function, _TRUNCATE);\r
+ size_t buflen;\r
+ mbstowcs_s(&buflen, NULL, 0, function, _TRUNCATE);\r
+ function_name = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, buflen * sizeof(TCHAR));\r
+ if (function_name) mbstowcs_s(&buflen, function_name, buflen * sizeof(TCHAR), function, _TRUNCATE);\r
- function_name = (TCHAR *) function;\r
+ function_name = (TCHAR *) function;\r
- if (*error != ERROR_PROC_NOT_FOUND) log_event(EVENTLOG_WARNING_TYPE, NSSM_EVENT_GETPROCADDRESS_FAILED, function_name, error_string(*error), 0);\r
+ log_event(EVENTLOG_WARNING_TYPE, NSSM_EVENT_GETPROCADDRESS_FAILED, function_name, error_string(*error), 0);\r
- if (function_name) HeapFree(GetProcessHeap(), 0, function_name);\r
+ if (function_name) HeapFree(GetProcessHeap(), 0, function_name);\r