LibreOffice Module onlineupdate (master) 1
Functions
serviceinstall.cxx File Reference
#include <windows.h>
#include <aclapi.h>
#include <stdlib.h>
#include <shlwapi.h>
#include <lm.h>
#include "serviceinstall.hxx"
#include "servicebase.hxx"
#include "updatehelper.h"
#include "shellapi.h"
#include "readstrings.h"
#include "errors.h"
#include <memory>
Include dependency graph for serviceinstall.cxx:

Go to the source code of this file.

Functions

static int ReadMaintenanceServiceStrings (LPCWSTR path, MaintenanceServiceStringTable *results)
 A wrapper function to read strings for the maintenance service. More...
 
static BOOL GetVersionNumberFromPath (LPWSTR path, DWORD &A, DWORD &B, DWORD &C, DWORD &D)
 Obtains the version number from the specified PE file's version information Version Format: A.B.C.D (Example 10.0.0.300) More...
 
BOOL UpdateServiceDescription (SC_HANDLE serviceHandle)
 Updates the service description with what is stored in updater.ini at the same path as the currently executing module binary. More...
 
BOOL FixServicePath (SC_HANDLE service, LPCWSTR currentServicePath, BOOL &servicePathWasWrong)
 Determines if the MozillaMaintenance service path needs to be updated and fixes it if it is wrong. More...
 
BOOL SvcInstall (SvcInstallAction action)
 Installs or upgrades the SVC_NAME service. More...
 
BOOL StopService ()
 Stops the Maintenance service. More...
 
BOOL SvcUninstall ()
 Uninstalls the Maintenance service. More...
 
BOOL SetUserAccessServiceDACL (SC_HANDLE hService)
 Sets the access control list for user access for the specified service. More...
 
DWORD SetUserAccessServiceDACL (SC_HANDLE hService, PACL &pNewAcl, PSECURITY_DESCRIPTOR psd)
 Sets the access control list for user access for the specified service. More...
 

Function Documentation

◆ FixServicePath()

BOOL FixServicePath ( SC_HANDLE  service,
LPCWSTR  currentServicePath,
BOOL servicePathWasWrong 
)

Determines if the MozillaMaintenance service path needs to be updated and fixes it if it is wrong.

Parameters
serviceA handle to the service to fix.
currentServicePathThe current (possibly wrong) path that is used.
servicePathWasWrongOut parameter set to TRUE if a fix was needed.
Returns
TRUE if the service path is now correct.

Definition at line 223 of file serviceinstall.cxx.

References FALSE, LOG, LOG_WARN, MAX_PATH, PathAppendSafe(), and TRUE.

Referenced by SvcInstall().

◆ GetVersionNumberFromPath()

static BOOL GetVersionNumberFromPath ( LPWSTR  path,
DWORD &  A,
DWORD &  B,
DWORD &  C,
DWORD &  D 
)
static

Obtains the version number from the specified PE file's version information Version Format: A.B.C.D (Example 10.0.0.300)

Parameters
pathThe path of the file to check the version on
AThe first part of the version number
BThe second part of the version number
CThe third part of the version number
DThe fourth part of the version number
Returns
TRUE if successful

Definition at line 105 of file serviceinstall.cxx.

References A, B, C, D, FALSE, LOG_WARN, size, and TRUE.

Referenced by SvcInstall().

◆ ReadMaintenanceServiceStrings()

static int ReadMaintenanceServiceStrings ( LPCWSTR  path,
MaintenanceServiceStringTable results 
)
static

A wrapper function to read strings for the maintenance service.

Parameters
pathThe path of the ini file to read from
resultsThe maintenance service strings that were read
Returns
OK on success

Definition at line 73 of file serviceinstall.cxx.

References MAX_TEXT_LEN, OK, ReadStrings(), result, and MaintenanceServiceStringTable::serviceDescription.

Referenced by UpdateServiceDescription().

◆ SetUserAccessServiceDACL() [1/2]

BOOL SetUserAccessServiceDACL ( SC_HANDLE  hService)

Sets the access control list for user access for the specified service.

Parameters
hServiceThe service to set the access control list on
Returns
TRUE if successful

Definition at line 702 of file serviceinstall.cxx.

References SetUserAccessServiceDACL().

Referenced by SetUserAccessServiceDACL(), and SvcInstall().

◆ SetUserAccessServiceDACL() [2/2]

DWORD SetUserAccessServiceDACL ( SC_HANDLE  hService,
PACL &  pNewAcl,
PSECURITY_DESCRIPTOR  psd 
)

Sets the access control list for user access for the specified service.

Parameters
hServiceThe service to set the access control list on
pNewAclThe out param ACL which should be freed by caller
psdout param security descriptor, should be freed by caller
Returns
ERROR_SUCCESS if successful

Definition at line 727 of file serviceinstall.cxx.

References FALSE, LOG, LOG_WARN, sid, size, and TRUE.

◆ StopService()

BOOL StopService ( )

Stops the Maintenance service.

Returns
TRUE if successful.

Definition at line 593 of file serviceinstall.cxx.

References FALSE, LOG, LOG_WARN, SVC_NAME, WaitForProcessExit(), and WaitForServiceStop().

Referenced by SvcInstall().

◆ SvcInstall()

BOOL SvcInstall ( SvcInstallAction  action)

Installs or upgrades the SVC_NAME service.

If an existing service is already installed, we replace it with the currently running process.

Parameters
actionThe action to perform.
Returns
TRUE if the service was installed/upgraded

Definition at line 290 of file serviceinstall.cxx.

References action, FALSE, FixServicePath(), ForceInstallSvc, GetVersionNumberFromPath(), LOG, LOG_WARN, MAX_PATH, result, SetUserAccessServiceDACL(), StopService(), SVC_DISPLAY_NAME, SVC_NAME, SvcInstall(), TRUE, UpdateServiceDescription(), and UpgradeSvc.

Referenced by SvcInstall(), and wmain().

◆ SvcUninstall()

BOOL SvcUninstall ( )

Uninstalls the Maintenance service.

Returns
TRUE if successful.

Definition at line 642 of file serviceinstall.cxx.

References FALSE, LOG_WARN, and SVC_NAME.

Referenced by wmain().

◆ UpdateServiceDescription()

BOOL UpdateServiceDescription ( SC_HANDLE  serviceHandle)

Updates the service description with what is stored in updater.ini at the same path as the currently executing module binary.

Parameters
serviceHandleA handle to an opened service with SERVICE_CHANGE_CONFIG access right
TRUEon success.

Definition at line 145 of file serviceinstall.cxx.

References FALSE, LOG, LOG_WARN, MAX_PATH, MAX_TEXT_LEN, OK, PathAppendSafe(), ReadMaintenanceServiceStrings(), MaintenanceServiceStringTable::serviceDescription, and TRUE.

Referenced by SvcInstall().