<commit_before>//
// PROJECT:         Aspia Remote Desktop
// FILE:            host/sas_injector.cc
// LICENSE:         See top-level directory
// PROGRAMMERS:     <NAME> (<EMAIL>)
//

#include "host/sas_injector.h"

#include <sas.h>

#include "base/service_manager.h"
#include "base/path.h"
#include "base/logging.h"
#include "base/unicode.h"
#include "host/scoped_sas_police.h"

namespace aspia {

static const WCHAR kSasServiceShortName[] = L"aspia-sas-service";
static const WCHAR kSasServiceFullName[] = L"Aspia SAS Injector";

SasInjector::SasInjector(const std::wstring& service_id) :
    Service(ServiceManager::CreateUniqueServiceName(kSasServiceShortName, service_id))
{
    // Nothing
}

// static
void SasInjector::InjectSAS()
{
    std::wstring command_line;

    // Получаем полный путь к исполняемому файлу.
    if (!GetPathW(PathKey::FILE_EXE, command_line))
        return;

    std::wstring service_id =
        ServiceManager::GenerateUniqueServiceId();

    std::wstring unique_name =
        ServiceManager::CreateUniqueServiceName(kSasServiceShortName, service_id);

    // Добавляем флаг запуска в виде службы.
    command_line.append(L" --run_mode=");
    command_line.append(kSasServiceSwitch);

    command_line.append(L" --service_id=");
    command_line.append(service_id);

    // Устанавливаем службу в системе.
    ServiceManager manager(ServiceManager::Create(command_line,
                                                  kSasServiceFullName,
                                                  unique_name));

    // Если служба установлена.
    if (manager.IsValid())
    {
        // Запускаем ее.
        manager.Start();
    }
}

void SasInjector::ExecuteService()
{
    // Запускаем службу для выполнения метода Worker().
    Run();

    // Удаляем службу.
    ServiceManager(ServiceName()).Remove();
}

void SasInjector::Worker()
{
    ScopedSasPolice sas_police;
    SendSAS(FALSE);
}<commit_msg>- Translate comments to English<commit_after>//
// PROJECT:         Aspia Remote Desktop
// FILE:            host/sas_injector.cc
// LICENSE:         See top-level directory
// PROGRAMMERS:     <NAME> (<EMAIL>)
//

#include "host/sas_injector.h"

#include <sas.h>

#include "base/service_manager.h"
#include "base/path.h"
#include "base/logging.h"
#include "base/unicode.h"
#include "host/scoped_sas_police.h"

namespace aspia {

static const WCHAR kSasServiceShortName[] = L"aspia-sas-service";
static const WCHAR kSasServiceFullName[] = L"Aspia SAS Injector";

SasInjector::SasInjector(const std::wstring& service_id) :
    Service(ServiceManager::CreateUniqueServiceName(kSasServiceShortName, service_id))
{
    // Nothing
}

// static
void SasInjector::InjectSAS()
{
    std::wstring command_line;

    if (!GetPathW(PathKey::FILE_EXE, command_line))
        return;

    std::wstring service_id =
        ServiceManager::GenerateUniqueServiceId();

    std::wstring unique_name =
        ServiceManager::CreateUniqueServiceName(kSasServiceShortName, service_id);

    command_line.append(L" --run_mode=");
    command_line.append(kSasServiceSwitch);

    command_line.append(L" --service_id=");
    command_line.append(service_id);

    // Install the service in the system.
    ServiceManager manager(ServiceManager::Create(command_line,
                                                  kSasServiceFullName,
                                                  unique_name));

    // If the service is installed.
    if (manager.IsValid())
        manager.Start();
}

void SasInjector::ExecuteService()
{
    Run();
    ServiceManager(ServiceName()).Remove();
}

void SasInjector::Worker()
{
    ScopedSasPolice sas_police;
    SendSAS(FALSE);
}
{'fraction_non_alphanumeric': 0.11940298507462686, 'fraction_numerical': 0.0, 'mean_word_length': 3.002171552660152, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5354764', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1213, 'n_words': 216}