1      !"#$%&'()*+,-./0  Safe-Inferred123412341234NoneZWin32 defines many types of services, but this binding only supports WIN32_OWN_PROCESS. Do no write your own services of this type. Windows Vista and above prevent service processes from directly interacting with users. A  is either a  or a i running in the context of the LocalSystem account which is allowed to directly interact with users. 2The service shares a process with other services. %The service runs in its own process.  The service is a device driver. %The service is a file system driver. 5678785678None9:;<=>9:;<=9:;<=>None The current state of a service.  ?@ABC  ?BC ?@ABCNoneyA SERVICE_CONTROL is used in Handler functions. All control codes are defined here, but some can only be used with a  HandlerEx callback. Use convertSuccess to translate from a  to a D . Use convertAttempt to translate from a D to a . EFGHIEFH EFGHINoneUThe control codes the service accepts and processes in its handler function (See HandlerFunction+). By default, all services accept the  INTERROGATE value. To accept the  DEVICEEVENTP value, the service must register to receive device events by using the registerDeviceNotification function. PThe service can be stopped. This control code allows the service to receive STOP notifications. iThe service is notified when system shutdown occurs. This control code allows the service to receive SHUTDOWN; notifications. Note that only the system can send it. MSDN documentation says that this function is not supported on Windows Server 2003 or Windows XP/2000. The support status on other versions is unknown to me. `The service can perform preshutdown tasks. This control code enables the service to receive  PRESHUTDOWN; notifications. Note that only the system can send it. ]The service can be paused and continued. This control code allows the service to receive PAUSE and CONTINUE notifications. !The service can reread its startup parameters without being stopped and restarted. This control code allows the service to receive  PARAMCHANGE notifications. "The service is a network component that can accept changes in its binding without being stopped and restarted. This control code allows the service to receive  NETBINDADD,  NETBINDREMOVE,  NETBINDENABLE , and NETBINDDISABLE notifications. JThis function takes a D and assumes it is a flagfield. Each bit is masked off and converted into a value. Any failures are silently discarded.  !"KLMNOJP  !"KL"! KLMNOJPNone#+Contains status information for a service. %NThe type of service. This binding only supports the WIN32_OWN_PROCESS type. &"The current state of the service. 'See  for details on this field. (The error code the service uses to report an error that occurs when it is starting or stopping. To return an error code specific to the service, the service must set this value to  to indicate that the )J member contains the error code. The service should set this value to 3 when it is running and on normal termination. )A service-specific error code that the service returns when an error occurs while the service is starting or stopping. This value is ignored unless the ( member is set to . <This binding does not support service-specific error codes. *?The check-point value the service increments periodically to report its progress during a lengthy start, stop, pause, or continue operation. For example, the service should increment this value as it completes each step of its initialization when it is starting up. The user interface program that invoked the operation on the service uses this value to track the progress of the service during a lengthy operation. This value is not valid and should be zero when the service does not have a start, stop, pause, or continue operation pending. ++The estimated time required for a pending start, stop, pause, or continue operation, in milliseconds. Before the specified amount of time has elapsed, the service should make its next call to the SetServiceStatus function with either an incremented dwCheckPoint value or a change in &). If the amount of time specified by + passes, and *! has not been incremented or &| has not changed, the service control manager or service control program can assume that an error has occurred and the service should be stopped. However, if the service shares a process with other services, the service control manager cannot terminate the service application because it would have to terminate the other services sharing the process as well. #$%&'()*+Q #$%&'()*+#$%&'()*+Q NoneRSTUVWRSTUVWRSTUVWNone,The service dispatcher thread will call each function of this type that you provide. The first argument will be the name of the service. Any additional command-line parameters will appear in the second argument. $Each of these functions should call registerServiceCtrlHandlerh to register a function to handle incoming commands. It should then set the service's status to  , and specify that no controls will be accepted. At this point the function may perform any other initialization steps before setting the service's status to  .. All of this should take no more than 100ms. -OA handler function is registered with the service dispatcher thread from a ,. The first argument is a X returned from calling registerServiceCtrlHandler\. The second argument represents the command this service has been directed to perform. .7Retrieves the current status of the specified service. YmRegister an handler function to be called whenever the operating system receives service control messages. /TUpdates the service control manager's status information for the calling service. 0Register a callback function to initialize the service, which will be called by the operating system immediately. startServiceCtrlDispatcher will block until the provided callback function returns. MSDN documentation: Connects the main thread of a service process to the service control manager, which causes the thread to be the service control dispatcher thread for the calling process. ,-.MSDN documentation: A handle to the service. This handle is returned by the OpenService or the CreateService function, and it must have the SERVICE_QUERY_STATUS access right. For more information, see Service Security and Access Rights. WThis function will raise an exception if the Win32 call returned an error condition. YThe name of the service. According to MSDN documentation this argument is unused in WIN32_OWN_PROCESS type services, which is the only type supported by this binding. Even so, it is recommended that the name of the service be used. MSDN description: The name of the service run by the calling thread. This is the service name that the service control program specified in the CreateService function when creating the service. wA Handler function to be called in response to service control messages. Behind the scenes this is translated into a  HandlerEx type handler. The returned handle may be used in calls to SetServiceStatus. For convenience Handler functions also receive a handle for the service. /MSDN documentation: A handle to the status information structure for the current service. This handle is returned by the RegisterServiceCtrlHandlerEx function. MSDN documentation: A pointer to the SERVICE_STATUS structure the contains the latest status information for the calling service. WThis function will raise an exception if the Win32 call returned an error condition. 0The name of the service. According to MSDN documentation this argument is unused in WIN32_OWN_PROCESS type services, which is the only type supported by this binding. Even so, it is recommended that the name of the service be used. MSDN description: The name of the service run by the calling thread. This is the service name that the service control program specified in the CreateService function when creating the service. This is a callback function that will be called by the operating system whenever the service is started. It should perform service initialization including the registration of a handler function. MSDN documentation gives conflicting advice as to whether this function should return before the service has entered the stopped state. In the official example the service main function blocks until the service is ready to stop. WAn exception will be raised if the underlying Win32 call returns an error condition. Z[1  !"#$%&'()*+,-./01-,"!  #$%&'()*+./0,-.Y/0Z[\     !"#$%&'()*+,--./0123456789:;<=>?@ABBCDEFG?>HIJKLMN>?OPQR>?OST U V W X Y ZJK[\]^_Win32-services-0.2.4$System.Win32.SystemServices.Services*System.Win32.SystemServices.Services.Types1System.Win32.SystemServices.Services.SERVICE_TYPE8System.Win32.SystemServices.Services.SERVICE_TABLE_ENTRY2System.Win32.SystemServices.Services.SERVICE_STATE4System.Win32.SystemServices.Services.SERVICE_CONTROL3System.Win32.SystemServices.Services.SERVICE_ACCEPT3System.Win32.SystemServices.Services.SERVICE_STATUS(System.Win32.SystemServices.Services.Raw SERVICE_TYPESERVICE_INTERACTIVE_PROCESSWIN32_SHARE_PROCESSWIN32_OWN_PROCESS KERNEL_DRIVERFILE_SYSTEM_DRIVER SERVICE_STATESTOPPED STOP_PENDING START_PENDINGRUNNINGPAUSED PAUSE_PENDINGCONTINUE_PENDINGnO_ERROReRROR_SERVICE_SPECIFIC_ERRORSERVICE_CONTROLSTOPSHUTDOWN PRESHUTDOWNPAUSE PARAMCHANGE NETBINDREMOVE NETBINDENABLENETBINDDISABLE NETBINDADD INTERROGATECONTINUESERVICE_ACCEPT ACCEPT_STOPACCEPT_SHUTDOWNACCEPT_PRESHUTDOWNACCEPT_PAUSE_CONTINUEACCEPT_PARAMCHANGEACCEPT_NETBINDCHANGESERVICE_STATUS serviceType currentStatecontrolsAccepted win32ExitCodeserviceSpecificExitCode checkPointwaitHintServiceMainFunctionHandlerFunctionqueryServiceStatussetServiceStatusstartServiceCtrlDispatcherLPSERVICE_MAIN_FUNCTIONSERVICE_MAIN_FUNCTIONLPHANDLER_FUNCTION_EXHANDLER_FUNCTION_EXtoDWORD fromDWORDpeekServiceTypepokeServiceTypeSERVICE_TABLE_ENTRY serviceName serviceProcnullSTE$fStorableSERVICE_TABLE_ENTRYeRROR_CALL_NOT_IMPLEMENTEDpeekServiceStatepokeServiceState Win32-2.3.0.2System.Win32.TypesDWORDpeekServiceControlpokeServiceControl unsupportedunflagpeekServiceAcceptpokeServiceAcceptflag$fStorableSERVICE_STATUSc_StartServiceCtrlDispatcherc_SetServiceStatusc_RegisterServiceCtrlHandlerExc_QueryServiceStatushandlerToFunPtr smfToFunPtrHANDLEregisterServiceCtrlHandlerExtoSMF toHandlerEx