6
0
mirror of https://github.com/JKornev/hidden synced 2024-06-16 12:08:05 +00:00
hidden/HiddenCLI/Commands.h

116 lines
2.6 KiB
C
Raw Normal View History

2016-12-04 19:27:46 +00:00
#pragma once
#include "Helper.h"
2016-12-05 22:37:18 +00:00
#include "Connection.h"
#include <memory>
2016-12-05 22:37:18 +00:00
enum class CommandModeType {
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;
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();
};
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-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
{
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
};