Browse Source

CreateToolhelp32Snapshot returns INVALID_HANDLE_VALUE on failure https://msdn.microsoft.com/en-us/library/windows/desktop/ms682489(v=vs.85).aspx

David Bremner 5 years ago
parent
commit
eed3860f97
1 changed files with 2 additions and 2 deletions
  1. 2 2
      process.cpp

+ 2 - 2
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;
   }