2016-12-04 19:27:46 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Helper.h"
|
2016-12-05 22:37:18 +00:00
|
|
|
#include "Connection.h"
|
2016-12-06 21:15:08 +00:00
|
|
|
#include <memory>
|
2016-12-05 22:37:18 +00:00
|
|
|
|
2021-07-25 18:32:03 +00:00
|
|
|
enum class CommandModeType {
|
2016-12-23 20:31:26 +00:00
|
|
|
Execute,
|
|
|
|
Install,
|
|
|
|
Uninstall
|
|
|
|
};
|
|
|
|
|
2016-12-05 22:37:18 +00:00
|
|
|
class ICommand
|
|
|
|
{
|
|
|
|
public:
|
2016-12-14 23:29:27 +00:00
|
|
|
typedef std::shared_ptr<ICommand> CommandPtrInternal;
|
2016-12-05 22:37:18 +00:00
|
|
|
|
|
|
|
virtual ~ICommand() {};
|
|
|
|
|
|
|
|
virtual bool CompareCommand(std::wstring& command) = 0;
|
2016-12-23 20:31:26 +00:00
|
|
|
virtual void LoadArgs(Arguments& args, CommandModeType mode) = 0;
|
2016-12-05 22:37:18 +00:00
|
|
|
virtual void PerformCommand(Connection& connection) = 0;
|
2016-12-23 00:05:09 +00:00
|
|
|
virtual void InstallCommand(RegistryKey& configKey);
|
|
|
|
virtual void UninstallCommand(RegistryKey& configKey);
|
2016-12-14 23:29:27 +00:00
|
|
|
|
|
|
|
virtual CommandPtrInternal CreateInstance() = 0;
|
2016-12-05 22:37:18 +00:00
|
|
|
};
|
2016-12-04 19:27:46 +00:00
|
|
|
|
2016-12-14 23:29:27 +00:00
|
|
|
typedef ICommand::CommandPtrInternal CommandPtr;
|
|
|
|
|
2016-12-23 00:05:09 +00:00
|
|
|
class CommandMode
|
|
|
|
{
|
|
|
|
std::wstring m_regConfigPath;
|
|
|
|
CommandModeType m_type;
|
|
|
|
|
|
|
|
void LoadConfigPath(Arguments& args);
|
|
|
|
|
|
|
|
public:
|
|
|
|
CommandMode(Arguments& args);
|
|
|
|
|
|
|
|
CommandModeType GetModeType();
|
|
|
|
const std::wstring& GetConfigRegistryKeyPath();
|
|
|
|
};
|
|
|
|
|
2021-07-25 18:32:03 +00:00
|
|
|
class ProcessParametersParser
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
std::wstring m_image;
|
|
|
|
HidProcId m_procId;
|
|
|
|
HidPsInheritTypes m_inheritType;
|
|
|
|
bool m_applyByDefault;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ProcessParametersParser();
|
|
|
|
virtual ~ProcessParametersParser() {}
|
|
|
|
|
|
|
|
void LoadImageParameters(Arguments& args, CommandModeType mode);
|
|
|
|
void LoadProcessIdParameters(Arguments& args);
|
|
|
|
};
|
|
|
|
|
2016-12-23 00:05:09 +00:00
|
|
|
class ICommandTemplate
|
2016-12-04 19:27:46 +00:00
|
|
|
{
|
2016-12-14 23:29:27 +00:00
|
|
|
public:
|
2016-12-23 00:05:09 +00:00
|
|
|
virtual ~ICommandTemplate() {}
|
2016-12-14 23:29:27 +00:00
|
|
|
virtual void Perform(Connection& connection) = 0;
|
2016-12-23 00:05:09 +00:00
|
|
|
virtual void Install(RegistryKey& configKey) = 0;
|
|
|
|
virtual void Uninstall(RegistryKey& configKey) = 0;
|
2016-12-14 23:29:27 +00:00
|
|
|
};
|
2016-12-06 21:15:08 +00:00
|
|
|
|
2016-12-23 00:05:09 +00:00
|
|
|
typedef std::shared_ptr<ICommandTemplate> CommandTemplatePtr;
|
2016-12-14 23:29:27 +00:00
|
|
|
|
2016-12-23 00:05:09 +00:00
|
|
|
class SingleCommand : public ICommandTemplate
|
2016-12-14 23:29:27 +00:00
|
|
|
{
|
2016-12-06 21:15:08 +00:00
|
|
|
std::vector<CommandPtr> m_commandsStack;
|
|
|
|
CommandPtr m_current;
|
2016-12-05 22:37:18 +00:00
|
|
|
|
2016-12-14 23:29:27 +00:00
|
|
|
public:
|
|
|
|
|
2016-12-23 00:05:09 +00:00
|
|
|
SingleCommand(Arguments& args, CommandModeType mode);
|
2016-12-14 23:29:27 +00:00
|
|
|
virtual ~SingleCommand();
|
|
|
|
|
|
|
|
virtual void Perform(Connection& connection);
|
2016-12-23 00:05:09 +00:00
|
|
|
virtual void Install(RegistryKey& configKey);
|
|
|
|
virtual void Uninstall(RegistryKey& configKey);
|
2016-12-14 23:29:27 +00:00
|
|
|
};
|
|
|
|
|
2016-12-23 00:05:09 +00:00
|
|
|
class MultipleCommands : public ICommandTemplate
|
2016-12-14 23:29:27 +00:00
|
|
|
{
|
|
|
|
std::vector<CommandPtr> m_commandsStack;
|
|
|
|
std::vector<CommandPtr> m_currentStack;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-12-23 00:05:09 +00:00
|
|
|
MultipleCommands(Arguments& args, CommandModeType mode);
|
2016-12-14 23:29:27 +00:00
|
|
|
virtual ~MultipleCommands();
|
|
|
|
|
|
|
|
virtual void Perform(Connection& connection);
|
2016-12-23 00:05:09 +00:00
|
|
|
virtual void Install(RegistryKey& configKey);
|
|
|
|
virtual void Uninstall(RegistryKey& configKey);
|
2016-12-14 23:29:27 +00:00
|
|
|
};
|
|
|
|
|
2016-12-23 00:05:09 +00:00
|
|
|
class MultipleCommandsFromFile : public ICommandTemplate
|
2016-12-14 23:29:27 +00:00
|
|
|
{
|
|
|
|
std::vector<CommandPtr> m_commandsStack;
|
|
|
|
std::vector<CommandPtr> m_currentStack;
|
2016-12-05 22:37:18 +00:00
|
|
|
|
2016-12-04 19:27:46 +00:00
|
|
|
public:
|
2016-12-05 22:37:18 +00:00
|
|
|
|
2016-12-23 00:05:09 +00:00
|
|
|
MultipleCommandsFromFile(Arguments& args, CommandModeType mode);
|
2016-12-14 23:29:27 +00:00
|
|
|
virtual ~MultipleCommandsFromFile();
|
2016-12-05 22:37:18 +00:00
|
|
|
|
2016-12-14 23:29:27 +00:00
|
|
|
virtual void Perform(Connection& connection);
|
2016-12-23 00:05:09 +00:00
|
|
|
virtual void Install(RegistryKey& configKey);
|
|
|
|
virtual void Uninstall(RegistryKey& configKey);
|
2016-12-04 19:27:46 +00:00
|
|
|
};
|