mirror of
https://github.com/JKornev/hidden
synced 2024-06-25 00:18:04 +00:00
Added /config command
This commit is contained in:
parent
7c522d760f
commit
1c2c7dc3e4
@ -4,6 +4,8 @@
|
|||||||
#include "Protect.h"
|
#include "Protect.h"
|
||||||
#include "Query.h"
|
#include "Query.h"
|
||||||
#include "State.h"
|
#include "State.h"
|
||||||
|
#include <fstream>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -47,7 +49,7 @@ SingleCommand::SingleCommand(Arguments& args)
|
|||||||
if (!found)
|
if (!found)
|
||||||
throw WException(-2, L"Error, unknown command, please use 'hiddencli /help'");
|
throw WException(-2, L"Error, unknown command, please use 'hiddencli /help'");
|
||||||
|
|
||||||
if (args.GetNext(arg))
|
if (args.SwitchToNext())
|
||||||
throw WException(-2, L"Error, too many arguments");
|
throw WException(-2, L"Error, too many arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,9 +107,105 @@ void MultipleCommands::Perform(Connection& connection)
|
|||||||
|
|
||||||
// =================
|
// =================
|
||||||
|
|
||||||
|
class ArgsParser
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
shared_ptr<Arguments> m_args;
|
||||||
|
bool m_haveArgs;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
ArgsParser(wstring& line) : m_haveArgs(false)
|
||||||
|
{
|
||||||
|
int argc;
|
||||||
|
LPWSTR* argv;
|
||||||
|
|
||||||
|
if (line.compare(0, 1, L";") == 0) // comment
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (all_of(line.begin(), line.end(), isspace)) // whitespace only string
|
||||||
|
return;
|
||||||
|
|
||||||
|
argv = CommandLineToArgvW(line.c_str(), &argc);
|
||||||
|
if (!argv)
|
||||||
|
throw WException(-2, L"Error, invalid command format");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
m_args.reset(new Arguments(argc, argv, 0));
|
||||||
|
}
|
||||||
|
catch (WException& e)
|
||||||
|
{
|
||||||
|
LocalFree(argv);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalFree(argv);
|
||||||
|
m_haveArgs = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HaveArgs()
|
||||||
|
{
|
||||||
|
return m_haveArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
Arguments& GetArgs()
|
||||||
|
{
|
||||||
|
return *m_args.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
MultipleCommandsFromFile::MultipleCommandsFromFile(Arguments& args)
|
MultipleCommandsFromFile::MultipleCommandsFromFile(Arguments& args)
|
||||||
{
|
{
|
||||||
throw WException(-2, L"Error, /config isn't implemented yet");
|
wstring configFile;
|
||||||
|
|
||||||
|
if (!args.GetNext(configFile))
|
||||||
|
throw WException(-2, L"Error, no command, please use 'hiddencli /help'");
|
||||||
|
|
||||||
|
if (args.SwitchToNext())
|
||||||
|
throw WException(-2, L"Error, too many arguments");
|
||||||
|
|
||||||
|
wifstream config(configFile);
|
||||||
|
wstring line;
|
||||||
|
|
||||||
|
LoadCommandsStack(m_commandsStack);
|
||||||
|
|
||||||
|
while (getline(config, line))
|
||||||
|
{
|
||||||
|
ArgsParser parser(line);
|
||||||
|
wstring arg;
|
||||||
|
|
||||||
|
if (parser.HaveArgs())
|
||||||
|
{
|
||||||
|
Arguments lineArgs = parser.GetArgs();
|
||||||
|
|
||||||
|
if (!lineArgs.GetNext(arg))
|
||||||
|
throw WException(-2, L"Error, no command, please use 'hiddencli /help'");
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
for (auto it = m_commandsStack.begin(); it != m_commandsStack.end(); it++)
|
||||||
|
{
|
||||||
|
if ((*it)->CompareCommand(arg))
|
||||||
|
{
|
||||||
|
CommandPtr command = (*it)->CreateInstance();
|
||||||
|
command->LoadArgs(lineArgs);
|
||||||
|
m_currentStack.push_back(command);
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
throw WException(-2, L"Error, unknown command, please use 'hiddencli /help'");
|
||||||
|
}
|
||||||
|
while (lineArgs.GetNext(arg));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MultipleCommandsFromFile::~MultipleCommandsFromFile()
|
MultipleCommandsFromFile::~MultipleCommandsFromFile()
|
||||||
@ -116,5 +214,7 @@ MultipleCommandsFromFile::~MultipleCommandsFromFile()
|
|||||||
|
|
||||||
void MultipleCommandsFromFile::Perform(Connection& connection)
|
void MultipleCommandsFromFile::Perform(Connection& connection)
|
||||||
{
|
{
|
||||||
|
for (auto it = m_currentStack.begin(); it != m_currentStack.end(); it++)
|
||||||
|
(*it)->PerformCommand(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ unsigned int WException::Code()
|
|||||||
return m_errorCode;
|
return m_errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
Arguments::Arguments(int argc, wchar_t* argv[]) :
|
Arguments::Arguments(int argc, wchar_t* argv[], int start) :
|
||||||
m_argPointer(0)
|
m_argPointer(0)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = start; i < argc; i++)
|
||||||
m_arguments.push_back(argv[i]);
|
m_arguments.push_back(argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class Arguments
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Arguments(int argc, wchar_t* argv[]);
|
Arguments(int argc, wchar_t* argv[], int start = 1);
|
||||||
|
|
||||||
size_t ArgsCount();
|
size_t ArgsCount();
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ int wmain(int argc, wchar_t* argv[])
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Arguments arguments(argc, argv);
|
Arguments arguments(argc , argv);
|
||||||
Connection connection(arguments);
|
Connection connection(arguments);
|
||||||
wstring mode;
|
wstring mode;
|
||||||
|
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
|
; ======================================
|
||||||
|
; Config for hidding VMWare components
|
||||||
|
; ======================================
|
||||||
|
|
||||||
|
; Enable driver if it's disabled
|
||||||
/state on
|
/state on
|
||||||
|
|
||||||
|
; Following config used for hidding VMWare components
|
||||||
|
|
||||||
/hide dir "c:\Program Files\VMware"
|
/hide dir "c:\Program Files\VMware"
|
||||||
/hide dir "c:\ProgramData\VMware"
|
/hide dir "c:\ProgramData\VMware"
|
||||||
/hide dir "c:\Windows\Temp\vmware-SYSTEM"
|
/hide dir "c:\Windows\Temp\vmware-SYSTEM"
|
||||||
@ -32,4 +38,5 @@
|
|||||||
/ignore image inherit:none apply:forall "C:\Program Files\VMware\VMware Tools\VMwareXferlogs.exe"
|
/ignore image inherit:none apply:forall "C:\Program Files\VMware\VMware Tools\VMwareXferlogs.exe"
|
||||||
/ignore image inherit:none apply:forall "C:\Program Files\VMware\VMware Tools\zip.exe"
|
/ignore image inherit:none apply:forall "C:\Program Files\VMware\VMware Tools\zip.exe"
|
||||||
|
|
||||||
/stealth on "my_stealth_gate"
|
; Isn't supported yet
|
||||||
|
; /stealth on "my_stealth_gate"
|
||||||
|
Loading…
Reference in New Issue
Block a user