From eed3860f97880967f2a6b92c18c0c6631d8a74b4 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Mon, 4 Jul 2016 14:36:19 -0700 Subject: [PATCH] CreateToolhelp32Snapshot returns INVALID_HANDLE_VALUE on failure https://msdn.microsoft.com/en-us/library/windows/desktop/ms682489(v=vs.85).aspx --- process.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/process.cpp b/process.cpp index 1c6946a..22e5a12 100644 --- a/process.cpp +++ b/process.cpp @@ -115,7 +115,7 @@ int kill_threads(nssm_service_t *service, kill_t *k) { /* Get a snapshot of all threads in the system. */ HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); - if (! snapshot) { + if (snapshot == INVALID_HANDLE_VALUE) { log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_CREATETOOLHELP32SNAPSHOT_THREAD_FAILED, k->name, error_string(GetLastError()), 0); return 0; } @@ -309,7 +309,7 @@ void kill_process_tree(nssm_service_t * service, kill_t *k, unsigned long ppid) /* Get a snapshot of all processes in the system. */ HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (! snapshot) { + if (snapshot == INVALID_HANDLE_VALUE) { log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_CREATETOOLHELP32SNAPSHOT_PROCESS_FAILED, k->name, error_string(GetLastError()), 0); return; } -- 2.7.4