Changeset bb8b6d1 in nscp for include


Ignore:
Timestamp:
09/19/08 06:48:41 (5 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
c09c225
Parents:
371df23
Message:

2008-09-18 MickeM - 0.3.4

  • Changed so "missing services" are treated as stopped.

CheckServiceState missing=stopped ShowAll

OK: missing: not found

  • Fixed issue with : in service name. + Added some "reasonable default cheks" under [External Alias] for the CheckExternalScripts.dll module.
Location:
include
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • include/EnumNtSrv.cpp

    r846bbe4 rbb8b6d1  
    189189  SC_HANDLE sh = ::OpenService(scman,name.c_str(),SERVICE_QUERY_STATUS); 
    190190  if (!sh) { 
     191    std::wstring short_name; 
    191192    DWORD bufLen = SC_BUF_LEN; 
    192193    TCHAR *buf = new TCHAR[bufLen+1]; 
    193194    if (GetServiceKeyName(scman, name.c_str(), buf, &bufLen) == 0) { 
     195      short_name = name; 
     196    } else { 
     197      short_name = buf; 
     198    } 
     199    delete [] buf; 
     200    sh = ::OpenService(scman,short_name.c_str(),SERVICE_QUERY_STATUS); 
     201    if (sh == NULL) { 
     202      DWORD dwErr = GetLastError(); 
    194203      ::CloseServiceHandle(scman); 
    195       delete [] buf; 
    196       throw NTServiceException(name, _T("GetServiceKeyName: Could not translate service name: ") + error::lookup::last_error()); 
    197     } 
    198     /* 
    199     Why does this not work? (a bug in the API? says it should return the correct size?) 
    200     if (bufLen >= SC_BUF_LEN) { 
    201       ::CloseServiceHandle(scman); 
    202       throw NTServiceException(name, "Service name to long to handle", GetLastError()); 
    203     } 
    204     buf[bufLen] = 0; 
    205     */ 
    206     sh = ::OpenService(scman,buf,SERVICE_QUERY_STATUS); 
    207     delete [] buf; 
    208     if (sh == NULL) { 
    209       ::CloseServiceHandle(scman); 
    210       throw NTServiceException(name, _T("OpenService: Could not open Service: ") + error::lookup::last_error()); 
     204      if (dwErr == ERROR_SERVICE_DOES_NOT_EXIST) { 
     205        info.m_dwCurrentState = MY_SERVICE_NOT_FOUND; 
     206        info.m_dwServiceType = MY_SERVICE_NOT_FOUND; 
     207        return info; 
     208      } else { 
     209        throw NTServiceException(name, _T("OpenService: Could not open Service: ") + error::lookup::last_error(dwErr)); 
     210      } 
    211211    } 
    212212  } 
  • include/EnumNtSrv.h

    r34e7428 rbb8b6d1  
    4747  } 
    4848}; 
     49#define MY_SERVICE_NOT_FOUND                        0xffff0000 
    4950 
    5051class TNtServiceInfo { 
  • include/checkHelpers.hpp

    r7221dc8 rbb8b6d1  
    298298 
    299299  typedef unsigned long state_type; 
    300   const int state_none  = 0x00; 
    301   const int state_started = 0x01; 
    302   const int state_stopped = 0x02; 
     300  const int state_none    = 0x00; 
     301  const int state_started   = 0x01; 
     302  const int state_stopped   = 0x02; 
     303  const int state_not_found = 0x06; 
    303304 
    304305  class state_handler { 
     
    314315        else if (*it == _T("ignored")) 
    315316          ret |= state_none; 
     317        else if (*it == _T("not found")) 
     318          ret |= state_not_found; 
    316319      } 
    317320      return ret; 
     
    324327      else if (value == state_none) 
    325328        return _T("none"); 
     329      else if (value == state_not_found) 
     330        return _T("not found"); 
    326331      return _T("unknown"); 
    327332    } 
  • include/config.h

    r371df23 rbb8b6d1  
    2626 
    2727// Version 
    28 //#define SZBETATAG _T(" ") 
    29 #define SZBETATAG _T(" RC ")   
     28#define SZBETATAG _T(" ") 
     29//#define SZBETATAG _T(" RC ")   
    3030//#define SZBETATAG _T(" BETA ")  
    3131#define SZVERSION STRPRODUCTVER SZBETATAG STRPRODUCTDATE 
Note: See TracChangeset for help on using the changeset viewer.