Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Моя Пояснительная записка.doc
Скачиваний:
3
Добавлен:
10.09.2019
Размер:
581.12 Кб
Скачать

1. Algorithm of the service program

Fig. 1.1 - Common flowchart of service algorithm

Main algorithm of service program is shown on fig. 1.1. It runs when service program starts.

Algorithm contains following parts:

  • Start Service Control Dispatcher

Every Windows service should start Service Control Dispatcher from it's main thread. Because Service Control Manager wait for it, when starting the service. This action also lets SCM know what function should be called at service start.

  • Register Service Control Handler

Registering of Service Control Handler to provide operations of Pause/Start/Continue/Stop of service program.

  • Some preparations (creating pipe, sockets, etc)

Creating one of communication methods via service and client program.

  • Setting up current service state as SERVICE_RUNNING

Setting service state as running, when all service initializations are completed.

  • Event

Implementation of pause/continue/stop status of service.

  • Create pipe if not exists. Wait for client connection

Checks doe’s pipe created. If not - create it. And wait until client connected.

  • Connected?

Checks status of client connection.

  • Processing of received information

Receiving information from client via pipe and process it. After processing send reply to client. Flushing file buffers.

  • Close Pipe Handle

Closing system handle of pipe.

Figure 1.2. Flowchart of Service Control Handler

This is an algorithm of functions which allows controlling the service behaviour by Service Control Manager. It analyses what SCM wants and doing it.

  • SERVICE_CONTROL_PAUSE

SCM going to pause service

  • Clear control event

Clears control event, so server won't serve the client (but it's still running)

  • Set Service Status as SERVICE_PAUSED

Informing SCM, that service is paused successive.

  • SERVICE_CONTROL_CONTINUE

SCM going to continue service executing

  • Set control event

Sets control event, server will serve the client again

  • Set SERVICE_STATUS_RUNNING status

Informing SCM, that service is resumed successive.

  • SERVICE_CONTROL_STOP

SCM going to stop service

  • Set SERVICE_SERVICE_STOPPED

Informing SCM, that all finalizing actions done, so SCM can terminate the service

2. Algorithms of the service management program

The service management program provides the user interface to control the service. Algorithms of controlling the service through Service Control Manager are shown in this part:

Fig. 2.1. - Install Service function

Fig. 2.2 - Delete Service function

Fig. 2.3 - Service Start function

Fig. 2.4 - Service Stop function

Fig. 2.5 - Restart Service function

Fig, 2.6 - Pause Service function

Fig. 2.7 - Continue Service work function

Fig. 2.8 - Common structure of information functions

  • Open SCM

Establishing connection to SCM.

  • Open Service

Establishing connection to service

  • . Get Service Status

Get information about current status service and fill structure.

  • Stop Service

Sending SERVICE_CONTROL_STOP to SCM for current service.

  • . Get Service Status

Get information about current status service and fill structure.

  • Create Service

Creates a record in SCM database with information about new service.

  • . Delete Service

Deletes a record from SCM database with information about new service.

  • Start Service

Starts service via SCM.

  • . Delete Service

Deletes a record from SCM database with information about new service.

  • . Get Service Config

Gets and fills LPSERVICE_CONFIG_STRUCTURE with information about service configuration.