; ADVAPI32 API  structures and constants
;  make sure to include " include 'equates/advapi32.inc' " in your
;  win32a.inc file

;
; Service database names
;
SERVICES_ACTIVE_DATABASE   =   "ServicesActive"
SERVICES_FAILED_DATABASE   =   "ServicesFailed"

; Character to designate that a name is a group
;

SC_GROUP_IDENTIFIER	   =   '+'

; Actions to take on service failure
;

struct SC_ACTION_TYPE
 SC_ACTION_NONE 	 = 0
 SC_ACTION_RESTART	 = 1
 SC_ACTION_REBOOT	 = 2
 SC_ACTION_RUN_COMMAND	 = 3
ends

struct SC_ACTION
   .Type       SC_ACTION_TYPE
   .Delay      dw ?
ends

struct SERVICE_FAILURE_ACTIONS
   .dwResetPeriod   dd ?
   .lpRebootMsg     dd ?
   .lpCommand	    dd ?
   .cActions	    dd ?
   .lpsaActions     dd ?
ends

;
; Handle Types
;

SC_HANDLE		 dd ?
LPSC_HANDLE		 dd ?
SERVICE_STATUS_HANDLE	 dd ?

;
; Structures for the Lock API functions
;

SC_LOCK dd ?
struct QUERY_SERVICE_LOCK_STATUS
   .fIsLocked	   dd ?
   .lpLockOwner    dd ?
   .dwLockDuration dd ?
ends

; Service description string
;

struct SERVICE_DESCRIPTION
  .lpDescription dd ?
ends

;  Service Status Structure

struct SERVICE_STATUS
   .dwServiceType	      dd ?
   .dwCurrentState	      dd ?
   .dwControlsAccepted	      dd ?
   .dwWin32ExitCode	      dd ?
   .dwServiceSpecificExitCode dd ?
   .dwCheckPoint	      dd ?
   .dwWaitHint		      dd ?
ends

;
; Service Status Enumeration Structure
;

struct ENUM_SERVICE_STATUS
    .lpServiceName	dd ?
    .lpDisplayName	dd ?
    .ServiceStatus	SERVICE_STATUS
ends

;
; Query Service Configuration Structure
;

struct QUERY_SERVICE_CONFIG
   .dwServiceType      dd ?
   .dwStartType        dd ?
   .dwErrorControl     dd ?
   .lpBinaryPathName   dd ?
   .lpLoadOrderGroup   dd ?
   .dwTagId	       dd ?
   .lpDependencies     dd ?
   .lpServiceStartName dd ?
   .lpDisplayName      dd ?
ends

;
; Function Prototype for the Service Main Function
;
;
;typedef VOID (WINAPI *LPSERVICE_MAIN_FUNCTION)(
;    DWORD   dwNumServicesArgs,
;    LPSTR   *lpServiceArgVectors
;    );


;
; Service Start Table
;

struct SERVICE_TABLE_ENTRY
     .lpServiceName  dd ?
     .lpServiceProc  dd ?
ends

;
; Prototype for the Service Control Handler Function
;
;
;typedef VOID (WINAPI *LPHANDLER_FUNCTION)(
;    DWORD    dwControl
;    );

;
; Value to indicate no change to an optional parameter
;
SERVICE_NO_CHANGE     =       0xffffffff

;
; Service State -- for Enum Requests (Bit Mask)
;
SERVICE_ACTIVE	    =	   0x00000001
SERVICE_INACTIVE    =	   0x00000002
SERVICE_STATE_ALL   =	   SERVICE_ACTIVE or SERVICE_INACTIVE

;
; Controls
;
SERVICE_CONTROL_STOP	       =  0x00000001
SERVICE_CONTROL_PAUSE	       =  0x00000002
SERVICE_CONTROL_CONTINUE       =  0x00000003
SERVICE_CONTROL_INTERROGATE    =  0x00000004
SERVICE_CONTROL_SHUTDOWN       =  0x00000005
SERVICE_CONTROL_PARAMCHANGE    =  0x00000006
SERVICE_CONTROL_NETBINDADD     =  0x00000007
SERVICE_CONTROL_NETBINDREMOVE  =  0x00000008
SERVICE_CONTROL_NETBINDENABLE  =  0x00000009
SERVICE_CONTROL_NETBINDDISABLE =  0x0000000A

;
; Service State -- for CurrentState
;
SERVICE_STOPPED 	 =    0x00000001
SERVICE_START_PENDING	 =    0x00000002
SERVICE_STOP_PENDING	 =    0x00000003
SERVICE_RUNNING 	 =    0x00000004
SERVICE_CONTINUE_PENDING =    0x00000005
SERVICE_PAUSE_PENDING	 =    0x00000006
SERVICE_PAUSED		 =    0x00000007

;
; Controls Accepted  (Bit Mask)
;
SERVICE_ACCEPT_STOP	      = 0x00000001
SERVICE_ACCEPT_PAUSE_CONTINUE = 0x00000002
SERVICE_ACCEPT_SHUTDOWN       = 0x00000004
SERVICE_ACCEPT_PARAMCHANGE    = 0x00000008
SERVICE_ACCEPT_NETBINDCHANGE  = 0x00000010

;
; Service Control Manager object specific access types
;
SC_MANAGER_CONNECT	      = 0x0001
SC_MANAGER_CREATE_SERVICE     = 0x0002
SC_MANAGER_ENUMERATE_SERVICE  = 0x0004
SC_MANAGER_LOCK 	      = 0x0008
SC_MANAGER_QUERY_LOCK_STATUS  = 0x0010
SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020
SC_MANAGER_ALL_ACCESS	      = STANDARD_RIGHTS_REQUIRED or 0x003f


;
; Service object specific access type
;
SERVICE_QUERY_CONFIG	      = 0x0001
SERVICE_CHANGE_CONFIG	      = 0x0002
SERVICE_QUERY_STATUS	      = 0x0004
SERVICE_ENUMERATE_DEPENDENTS  = 0x0008
SERVICE_START		      = 0x0010
SERVICE_STOP		      = 0x0020
SERVICE_PAUSE_CONTINUE	      = 0x0040
SERVICE_INTERROGATE	      = 0x0080
SERVICE_USER_DEFINED_CONTROL  = 0x0100
SERVICE_ALL_ACCESS	      = STANDARD_RIGHTS_REQUIRED or 0x01ff

;
; Info levels for ChangeServiceConfig2 and QueryServiceConfig2
;
SERVICE_CONFIG_DESCRIPTION     = 1
SERVICE_CONFIG_FAILURE_ACTIONS = 2

