mirror of
https://github.com/JKornev/hidden
synced 2024-06-16 03:58:04 +00:00
Added valid error codes
This commit is contained in:
parent
32f2da5145
commit
8a9ba43e23
@ -68,7 +68,8 @@
|
|||||||
- Реализовать steals mode
|
- Реализовать steals mode
|
||||||
+ Реализовать поддержку загрузки дефольтных конфигов из реестра
|
+ Реализовать поддержку загрузки дефольтных конфигов из реестра
|
||||||
+ Реализовать установку конфигов в реестр через hiddencli
|
+ Реализовать установку конфигов в реестр через hiddencli
|
||||||
- Привести в порядок вывод статуса в hiddencli
|
+ Привести в порядок вывод статуса в hiddencli
|
||||||
|
+ Привести в порядок номер ошибки в hiddencli
|
||||||
- Насодить на ETL и DbgPrintEx
|
- Насодить на ETL и DbgPrintEx
|
||||||
- Добавить SAL на функции драйвера
|
- Добавить SAL на функции драйвера
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ void LoadCommandsStack(vector<CommandPtr>& stack)
|
|||||||
|
|
||||||
void ICommand::InstallCommand(RegistryKey& configKey)
|
void ICommand::InstallCommand(RegistryKey& configKey)
|
||||||
{
|
{
|
||||||
throw WException(-2, L"Error, install mode is not supported");
|
throw WException(ERROR_UNSUPPORTED_TYPE, L"Error, install mode is not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICommand::UninstallCommand(RegistryKey& configKey)
|
void ICommand::UninstallCommand(RegistryKey& configKey)
|
||||||
@ -42,7 +42,7 @@ CommandMode::CommandMode(Arguments& args) : m_type(CommandModeType::Execute)
|
|||||||
wstring mode, all;
|
wstring mode, all;
|
||||||
|
|
||||||
if (!args.Probe(mode))
|
if (!args.Probe(mode))
|
||||||
throw WException(-2, L"Error, no command, please use 'hiddencli /help'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, no command, please use 'hiddencli /help'");
|
||||||
|
|
||||||
if (mode == L"/install")
|
if (mode == L"/install")
|
||||||
{
|
{
|
||||||
@ -60,7 +60,7 @@ CommandMode::CommandMode(Arguments& args) : m_type(CommandModeType::Execute)
|
|||||||
if (m_type == CommandModeType::Uninstall)
|
if (m_type == CommandModeType::Uninstall)
|
||||||
{
|
{
|
||||||
if (!args.Probe(all) || all != L"all")
|
if (!args.Probe(all) || all != L"all")
|
||||||
throw WException(-2, L"Error, invalid '/unistall' format");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid '/unistall' format");
|
||||||
|
|
||||||
args.SwitchToNext();
|
args.SwitchToNext();
|
||||||
}
|
}
|
||||||
@ -102,14 +102,14 @@ SingleCommand::SingleCommand(Arguments& args, CommandModeType mode)
|
|||||||
if (mode == CommandModeType::Uninstall)
|
if (mode == CommandModeType::Uninstall)
|
||||||
{
|
{
|
||||||
if (args.SwitchToNext())
|
if (args.SwitchToNext())
|
||||||
throw WException(-2, L"Error, too many arguments");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, too many arguments");
|
||||||
|
|
||||||
LoadCommandsStack(m_commandsStack);
|
LoadCommandsStack(m_commandsStack);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.GetNext(arg))
|
if (!args.GetNext(arg))
|
||||||
throw WException(-2, L"Error, no command, please use 'hiddencli /help'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, no command, please use 'hiddencli /help'");
|
||||||
|
|
||||||
LoadCommandsStack(m_commandsStack);
|
LoadCommandsStack(m_commandsStack);
|
||||||
|
|
||||||
@ -125,10 +125,10 @@ SingleCommand::SingleCommand(Arguments& args, CommandModeType mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
throw WException(-2, L"Error, unknown command, please use 'hiddencli /help'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, unknown command, please use 'hiddencli /help'");
|
||||||
|
|
||||||
if (args.SwitchToNext())
|
if (args.SwitchToNext())
|
||||||
throw WException(-2, L"Error, too many arguments");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, too many arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleCommand::~SingleCommand()
|
SingleCommand::~SingleCommand()
|
||||||
@ -167,10 +167,10 @@ MultipleCommands::MultipleCommands(Arguments& args, CommandModeType mode)
|
|||||||
wstring arg;
|
wstring arg;
|
||||||
|
|
||||||
if (mode == CommandModeType::Uninstall)
|
if (mode == CommandModeType::Uninstall)
|
||||||
throw WException(-2, L"Error, /uninstall can't be combined with /multi");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, /uninstall can't be combined with /multi");
|
||||||
|
|
||||||
if (!args.GetNext(arg))
|
if (!args.GetNext(arg))
|
||||||
throw WException(-2, L"Error, no command, please use 'hiddencli /help'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, no command, please use 'hiddencli /help'");
|
||||||
|
|
||||||
LoadCommandsStack(m_commandsStack);
|
LoadCommandsStack(m_commandsStack);
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ MultipleCommands::MultipleCommands(Arguments& args, CommandModeType mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
throw WException(-2, L"Error, unknown command, please use 'hiddencli /help'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, unknown command, please use 'hiddencli /help'");
|
||||||
}
|
}
|
||||||
while (args.GetNext(arg));
|
while (args.GetNext(arg));
|
||||||
}
|
}
|
||||||
@ -214,7 +214,7 @@ void MultipleCommands::Install(RegistryKey& configKey)
|
|||||||
|
|
||||||
void MultipleCommands::Uninstall(RegistryKey& configKey)
|
void MultipleCommands::Uninstall(RegistryKey& configKey)
|
||||||
{
|
{
|
||||||
throw WException(-2, L"Error, uninstall mode is not supported");
|
throw WException(ERROR_UNSUPPORTED_TYPE, L"Error, uninstall mode is not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================
|
// =================
|
||||||
@ -241,7 +241,7 @@ public:
|
|||||||
|
|
||||||
argv = CommandLineToArgvW(line.c_str(), &argc);
|
argv = CommandLineToArgvW(line.c_str(), &argc);
|
||||||
if (!argv)
|
if (!argv)
|
||||||
throw WException(-2, L"Error, invalid command format");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid command format");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -274,13 +274,13 @@ MultipleCommandsFromFile::MultipleCommandsFromFile(Arguments& args, CommandModeT
|
|||||||
wstring configFile;
|
wstring configFile;
|
||||||
|
|
||||||
if (mode == CommandModeType::Uninstall)
|
if (mode == CommandModeType::Uninstall)
|
||||||
throw WException(-2, L"Error, /uninstall can't be combined with /config");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, /uninstall can't be combined with /config");
|
||||||
|
|
||||||
if (!args.GetNext(configFile))
|
if (!args.GetNext(configFile))
|
||||||
throw WException(-2, L"Error, no command, please use 'hiddencli /help'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, no command, please use 'hiddencli /help'");
|
||||||
|
|
||||||
if (args.SwitchToNext())
|
if (args.SwitchToNext())
|
||||||
throw WException(-2, L"Error, too many arguments");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, too many arguments");
|
||||||
|
|
||||||
wifstream fconfig(configFile);
|
wifstream fconfig(configFile);
|
||||||
wstring line;
|
wstring line;
|
||||||
@ -297,7 +297,7 @@ MultipleCommandsFromFile::MultipleCommandsFromFile(Arguments& args, CommandModeT
|
|||||||
Arguments lineArgs = parser.GetArgs();
|
Arguments lineArgs = parser.GetArgs();
|
||||||
|
|
||||||
if (!lineArgs.GetNext(arg))
|
if (!lineArgs.GetNext(arg))
|
||||||
throw WException(-2, L"Error, no command, please use 'hiddencli /help'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, no command, please use 'hiddencli /help'");
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -316,7 +316,7 @@ MultipleCommandsFromFile::MultipleCommandsFromFile(Arguments& args, CommandModeT
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
throw WException(-2, L"Error, unknown command, please use 'hiddencli /help'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, unknown command, please use 'hiddencli /help'");
|
||||||
}
|
}
|
||||||
while (lineArgs.GetNext(arg));
|
while (lineArgs.GetNext(arg));
|
||||||
}
|
}
|
||||||
@ -341,5 +341,5 @@ void MultipleCommandsFromFile::Install(RegistryKey& configKey)
|
|||||||
|
|
||||||
void MultipleCommandsFromFile::Uninstall(RegistryKey& configKey)
|
void MultipleCommandsFromFile::Uninstall(RegistryKey& configKey)
|
||||||
{
|
{
|
||||||
throw WException(-2, L"Error, uninstall mode is not supported");
|
throw WException(ERROR_UNSUPPORTED_TYPE, L"Error, uninstall mode is not supported");
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ Connection::Connection(Arguments& args) :
|
|||||||
{
|
{
|
||||||
args.SwitchToNext();
|
args.SwitchToNext();
|
||||||
if (!args.GetNext(m_deviceName))
|
if (!args.GetNext(m_deviceName))
|
||||||
throw WException(-2, L"Error, mismatched argument for command 'gate'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument for command 'gate'");
|
||||||
|
|
||||||
if (m_deviceName.compare(0, 1, L"\\") != 0)
|
if (m_deviceName.compare(0, 1, L"\\") != 0)
|
||||||
m_deviceName.insert(0, L"\\\\.\\");
|
m_deviceName.insert(0, L"\\\\.\\");
|
||||||
|
@ -251,7 +251,7 @@ HidRegRootTypes GetRegType(wstring& path)
|
|||||||
else if (path.compare(0, _countof(regHKU) - 1, regHKU) == 0)
|
else if (path.compare(0, _countof(regHKU) - 1, regHKU) == 0)
|
||||||
return HidRegRootTypes::RegHKU;
|
return HidRegRootTypes::RegHKU;
|
||||||
else
|
else
|
||||||
throw WException(-2, L"Error, invalid registry prefix");
|
throw WException(ERROR_INVALID_DATA, L"Error, invalid registry prefix");
|
||||||
}
|
}
|
||||||
|
|
||||||
HidPsInheritTypes LoadInheritOption(Arguments& args, HidPsInheritTypes default)
|
HidPsInheritTypes LoadInheritOption(Arguments& args, HidPsInheritTypes default)
|
||||||
|
@ -136,7 +136,7 @@ CommandTemplatePtr LoadCommandsTemplate(Arguments& args, CommandMode& mode)
|
|||||||
return CommandTemplatePtr(new SingleCommand(args, mode.GetModeType()));
|
return CommandTemplatePtr(new SingleCommand(args, mode.GetModeType()));
|
||||||
|
|
||||||
if (!args.Probe(templateType))
|
if (!args.Probe(templateType))
|
||||||
throw WException(-2, L"Error, unknown perform mode, please use 'hiddencli /help'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, unknown perform mode, please use 'hiddencli /help'");
|
||||||
|
|
||||||
if (templateType == L"/multi")
|
if (templateType == L"/multi")
|
||||||
{
|
{
|
||||||
@ -160,7 +160,7 @@ int wmain(int argc, wchar_t* argv[])
|
|||||||
|
|
||||||
if (!arguments.ArgsCount())
|
if (!arguments.ArgsCount())
|
||||||
throw WException(
|
throw WException(
|
||||||
-2,
|
ERROR_INVALID_PARAMETER,
|
||||||
L"Welcome to HiddenCLI, please use 'hiddencli /help'"
|
L"Welcome to HiddenCLI, please use 'hiddencli /help'"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ HidRegRootTypes CommandHide::GetTypeAndNormalizeRegPath(std::wstring& regPath)
|
|||||||
HidRegRootTypes type = GetRegType(regPath);
|
HidRegRootTypes type = GetRegType(regPath);
|
||||||
size_t pos = regPath.find(L"\\");
|
size_t pos = regPath.find(L"\\");
|
||||||
if (pos == wstring::npos)
|
if (pos == wstring::npos)
|
||||||
throw WException(-2, L"Error, invalid registry path");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid registry path");
|
||||||
|
|
||||||
regPath = std::move(wstring(regPath.c_str() + pos + 1));
|
regPath = std::move(wstring(regPath.c_str() + pos + 1));
|
||||||
return type;
|
return type;
|
||||||
@ -35,10 +35,10 @@ void CommandHide::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
wstring object;
|
wstring object;
|
||||||
|
|
||||||
if (!args.GetNext(object))
|
if (!args.GetNext(object))
|
||||||
throw WException(-2, L"Error, mismatched argument #1 for command 'hide'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #1 for command 'hide'");
|
||||||
|
|
||||||
if (!args.GetNext(m_path))
|
if (!args.GetNext(m_path))
|
||||||
throw WException(-2, L"Error, mismatched argument #2 for command 'hide'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #2 for command 'hide'");
|
||||||
|
|
||||||
if (object == L"file")
|
if (object == L"file")
|
||||||
{
|
{
|
||||||
@ -60,7 +60,7 @@ void CommandHide::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw WException(-2, L"Error, invalid argument for command 'hide'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid argument for command 'hide'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ void CommandHide::PerformCommand(Connection& connection)
|
|||||||
status = Hid_AddHiddenRegValue(connection.GetContext(), m_regRootType, m_path.c_str(), &objId);
|
status = Hid_AddHiddenRegValue(connection.GetContext(), m_regRootType, m_path.c_str(), &objId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw WException(-2, L"Internal error, invalid type for command 'hide'");
|
throw WException(ERROR_UNKNOWN_COMPONENT, L"Internal error, invalid type for command 'hide'");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HID_STATUS_SUCCESSFUL(status))
|
if (!HID_STATUS_SUCCESSFUL(status))
|
||||||
@ -122,7 +122,7 @@ void CommandHide::InstallCommand(RegistryKey& configKey)
|
|||||||
status = Hid_NormalizeRegistryPath(m_regRootType, m_path.c_str(), const_cast<wchar_t*>(entry.c_str()), entry.size());
|
status = Hid_NormalizeRegistryPath(m_regRootType, m_path.c_str(), const_cast<wchar_t*>(entry.c_str()), entry.size());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw WException(-2, L"Internal error, invalid type for command 'hide'");
|
throw WException(ERROR_UNKNOWN_COMPONENT, L"Internal error, invalid type for command 'hide'");
|
||||||
}
|
}
|
||||||
|
|
||||||
configKey.GetMultiStrValue(valueName, commands);
|
configKey.GetMultiStrValue(valueName, commands);
|
||||||
@ -171,10 +171,10 @@ void CommandUnhide::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
wstring object, target;
|
wstring object, target;
|
||||||
|
|
||||||
if (!args.GetNext(object))
|
if (!args.GetNext(object))
|
||||||
throw WException(-2, L"Error, mismatched argument #1 for command 'unhide'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #1 for command 'unhide'");
|
||||||
|
|
||||||
if (!args.GetNext(target))
|
if (!args.GetNext(target))
|
||||||
throw WException(-2, L"Error, mismatched argument #2 for command 'unhide'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #2 for command 'unhide'");
|
||||||
|
|
||||||
if (object == L"file")
|
if (object == L"file")
|
||||||
{
|
{
|
||||||
@ -194,7 +194,7 @@ void CommandUnhide::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw WException(-2, L"Error, invalid argument for command 'unhide'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid argument for command 'unhide'");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_targetAll = (target == L"all");
|
m_targetAll = (target == L"all");
|
||||||
@ -202,7 +202,7 @@ void CommandUnhide::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
{
|
{
|
||||||
m_targetId = _wtoll(target.c_str());
|
m_targetId = _wtoll(target.c_str());
|
||||||
if (!m_targetId)
|
if (!m_targetId)
|
||||||
throw WException(-2, L"Error, invalid target objid for command 'unhide'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid target objid for command 'unhide'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ void CommandUnhide::PerformCommand(Connection& connection)
|
|||||||
status = Hid_RemoveAllHiddenRegValues(connection.GetContext());
|
status = Hid_RemoveAllHiddenRegValues(connection.GetContext());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw WException(-2, L"Internal error #1, invalid type for command 'unhide'");
|
throw WException(ERROR_UNKNOWN_COMPONENT, L"Internal error #1, invalid type for command 'unhide'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -247,7 +247,7 @@ void CommandUnhide::PerformCommand(Connection& connection)
|
|||||||
status = Hid_RemoveHiddenRegValue(connection.GetContext(), m_targetId);
|
status = Hid_RemoveHiddenRegValue(connection.GetContext(), m_targetId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw WException(-2, L"Internal error #2, invalid type for command 'unhide'");
|
throw WException(ERROR_UNKNOWN_COMPONENT, L"Internal error #2, invalid type for command 'unhide'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ void CommandIgnore::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
wstring object, target;
|
wstring object, target;
|
||||||
|
|
||||||
if (!args.GetNext(object))
|
if (!args.GetNext(object))
|
||||||
throw WException(-2, L"Error, mismatched argument #1 for command 'ignore'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #1 for command 'ignore'");
|
||||||
|
|
||||||
if (object == L"image")
|
if (object == L"image")
|
||||||
{
|
{
|
||||||
@ -32,13 +32,13 @@ void CommandIgnore::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
else if (object == L"pid")
|
else if (object == L"pid")
|
||||||
{
|
{
|
||||||
if (!CommandModeType::Execute)
|
if (!CommandModeType::Execute)
|
||||||
throw WException(-2, L"Error, target 'pid' isn't allowed");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, target 'pid' isn't allowed");
|
||||||
|
|
||||||
m_procType = EProcTypes::TypeProcessId;
|
m_procType = EProcTypes::TypeProcessId;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw WException(-2, L"Error, invalid object type in command 'ignore'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid object type in command 'ignore'");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_inheritType = LoadInheritOption(args, HidPsInheritTypes::WithoutInherit);
|
m_inheritType = LoadInheritOption(args, HidPsInheritTypes::WithoutInherit);
|
||||||
@ -48,7 +48,7 @@ void CommandIgnore::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
m_applyByDefault = LoadApplyOption(args, m_applyByDefault);
|
m_applyByDefault = LoadApplyOption(args, m_applyByDefault);
|
||||||
|
|
||||||
if (!args.GetNext(target))
|
if (!args.GetNext(target))
|
||||||
throw WException(-2, L"Error, mismatched argument #2 for command 'ignore'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #2 for command 'ignore'");
|
||||||
|
|
||||||
if (m_procType == EProcTypes::TypeImage)
|
if (m_procType == EProcTypes::TypeImage)
|
||||||
{
|
{
|
||||||
@ -58,7 +58,7 @@ void CommandIgnore::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
{
|
{
|
||||||
m_targetProcId = _wtol(target.c_str());
|
m_targetProcId = _wtol(target.c_str());
|
||||||
if (!m_targetProcId)
|
if (!m_targetProcId)
|
||||||
throw WException(-2, L"Error, invalid target pid for command 'ignore'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid target pid for command 'ignore'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ void CommandIgnore::PerformCommand(Connection& connection)
|
|||||||
status = Hid_AddExcludedImage(connection.GetContext(), m_targetImage.c_str(), m_inheritType, m_applyByDefault, &objId);
|
status = Hid_AddExcludedImage(connection.GetContext(), m_targetImage.c_str(), m_inheritType, m_applyByDefault, &objId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw WException(-2, L"Internal error, invalid type for command 'ignore'");
|
throw WException(ERROR_UNKNOWN_COMPONENT, L"Internal error, invalid type for command 'ignore'");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HID_STATUS_SUCCESSFUL(status))
|
if (!HID_STATUS_SUCCESSFUL(status))
|
||||||
@ -142,21 +142,21 @@ void CommandUnignore::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
wstring object, target;
|
wstring object, target;
|
||||||
|
|
||||||
if (mode != CommandModeType::Execute)
|
if (mode != CommandModeType::Execute)
|
||||||
throw WException(-2, L"Error, install/uninstall mode isn't supported for this command");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, install/uninstall mode isn't supported for this command");
|
||||||
|
|
||||||
if (!args.GetNext(object))
|
if (!args.GetNext(object))
|
||||||
throw WException(-2, L"Error, mismatched argument #1 for command 'unignore'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #1 for command 'unignore'");
|
||||||
|
|
||||||
if (object == L"pid")
|
if (object == L"pid")
|
||||||
{
|
{
|
||||||
m_targetType = ETargetIdType::ProcId;
|
m_targetType = ETargetIdType::ProcId;
|
||||||
|
|
||||||
if (!args.GetNext(target))
|
if (!args.GetNext(target))
|
||||||
throw WException(-2, L"Error, mismatched argument #2 for command 'unignore'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #2 for command 'unignore'");
|
||||||
|
|
||||||
m_targetProcId = _wtol(target.c_str());
|
m_targetProcId = _wtol(target.c_str());
|
||||||
if (!m_targetProcId)
|
if (!m_targetProcId)
|
||||||
throw WException(-2, L"Error, invalid target ruleid for command 'unignore'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid target ruleid for command 'unignore'");
|
||||||
}
|
}
|
||||||
else if (object == L"all")
|
else if (object == L"all")
|
||||||
{
|
{
|
||||||
@ -168,7 +168,7 @@ void CommandUnignore::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
|
|
||||||
m_targetId = _wtoll(object.c_str());
|
m_targetId = _wtoll(object.c_str());
|
||||||
if (!m_targetId)
|
if (!m_targetId)
|
||||||
throw WException(-2, L"Error, invalid target ruleid for command 'unignore'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid target ruleid for command 'unignore'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ void CommandUnignore::PerformCommand(Connection& connection)
|
|||||||
status = Hid_RemoveExcludedImage(connection.GetContext(), m_targetId);
|
status = Hid_RemoveExcludedImage(connection.GetContext(), m_targetId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw WException(-2, L"Internal error, invalid type for command 'unignore'");
|
throw WException(ERROR_UNKNOWN_COMPONENT, L"Internal error, invalid type for command 'unignore'");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HID_STATUS_SUCCESSFUL(status))
|
if (!HID_STATUS_SUCCESSFUL(status))
|
||||||
|
@ -23,7 +23,7 @@ void CommandProtect::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
wstring object, target;
|
wstring object, target;
|
||||||
|
|
||||||
if (!args.GetNext(object))
|
if (!args.GetNext(object))
|
||||||
throw WException(-2, L"Error, mismatched argument #1 for command 'protect'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #1 for command 'protect'");
|
||||||
|
|
||||||
if (object == L"image")
|
if (object == L"image")
|
||||||
{
|
{
|
||||||
@ -32,13 +32,13 @@ void CommandProtect::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
else if (object == L"pid")
|
else if (object == L"pid")
|
||||||
{
|
{
|
||||||
if (!CommandModeType::Execute)
|
if (!CommandModeType::Execute)
|
||||||
throw WException(-2, L"Error, target 'pid' isn't allowed");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, target 'pid' isn't allowed");
|
||||||
|
|
||||||
m_procType = EProcTypes::TypeProcessId;
|
m_procType = EProcTypes::TypeProcessId;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw WException(-2, L"Error, invalid object type in command 'protect'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid object type in command 'protect'");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_inheritType = LoadInheritOption(args, HidPsInheritTypes::WithoutInherit);
|
m_inheritType = LoadInheritOption(args, HidPsInheritTypes::WithoutInherit);
|
||||||
@ -48,7 +48,7 @@ void CommandProtect::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
m_applyByDefault = LoadApplyOption(args, m_applyByDefault);
|
m_applyByDefault = LoadApplyOption(args, m_applyByDefault);
|
||||||
|
|
||||||
if (!args.GetNext(target))
|
if (!args.GetNext(target))
|
||||||
throw WException(-2, L"Error, mismatched argument #2 for command 'protect'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #2 for command 'protect'");
|
||||||
|
|
||||||
if (m_procType == EProcTypes::TypeImage)
|
if (m_procType == EProcTypes::TypeImage)
|
||||||
{
|
{
|
||||||
@ -58,7 +58,7 @@ void CommandProtect::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
{
|
{
|
||||||
m_targetProcId = _wtol(target.c_str());
|
m_targetProcId = _wtol(target.c_str());
|
||||||
if (!m_targetProcId)
|
if (!m_targetProcId)
|
||||||
throw WException(-2, L"Error, invalid target pid for command 'protect'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid target pid for command 'protect'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ void CommandProtect::PerformCommand(Connection& connection)
|
|||||||
status = Hid_AddProtectedImage(connection.GetContext(), m_targetImage.c_str(), m_inheritType, m_applyByDefault, &objId);
|
status = Hid_AddProtectedImage(connection.GetContext(), m_targetImage.c_str(), m_inheritType, m_applyByDefault, &objId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw WException(-2, L"Internal error, invalid type for command 'protect'");
|
throw WException(ERROR_UNKNOWN_COMPONENT, L"Internal error, invalid type for command 'protect'");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HID_STATUS_SUCCESSFUL(status))
|
if (!HID_STATUS_SUCCESSFUL(status))
|
||||||
@ -142,21 +142,21 @@ void CommandUnprotect::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
wstring object, target;
|
wstring object, target;
|
||||||
|
|
||||||
if (mode != CommandModeType::Execute)
|
if (mode != CommandModeType::Execute)
|
||||||
throw WException(-2, L"Error, install/uninstall mode isn't supported for this command");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, install/uninstall mode isn't supported for this command");
|
||||||
|
|
||||||
if (!args.GetNext(object))
|
if (!args.GetNext(object))
|
||||||
throw WException(-2, L"Error, mismatched argument #1 for command 'unprotect'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #1 for command 'unprotect'");
|
||||||
|
|
||||||
if (object == L"pid")
|
if (object == L"pid")
|
||||||
{
|
{
|
||||||
m_targetType = ETargetIdType::ProcId;
|
m_targetType = ETargetIdType::ProcId;
|
||||||
|
|
||||||
if (!args.GetNext(target))
|
if (!args.GetNext(target))
|
||||||
throw WException(-2, L"Error, mismatched argument #2 for command 'unprotect'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #2 for command 'unprotect'");
|
||||||
|
|
||||||
m_targetProcId = _wtol(target.c_str());
|
m_targetProcId = _wtol(target.c_str());
|
||||||
if (!m_targetProcId)
|
if (!m_targetProcId)
|
||||||
throw WException(-2, L"Error, invalid target ruleid for command 'unprotect'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid target ruleid for command 'unprotect'");
|
||||||
}
|
}
|
||||||
else if (object == L"all")
|
else if (object == L"all")
|
||||||
{
|
{
|
||||||
@ -168,7 +168,7 @@ void CommandUnprotect::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
|
|
||||||
m_targetId = _wtoll(object.c_str());
|
m_targetId = _wtoll(object.c_str());
|
||||||
if (!m_targetId)
|
if (!m_targetId)
|
||||||
throw WException(-2, L"Error, invalid target ruleid for command 'unprotect'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid target ruleid for command 'unprotect'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ void CommandUnprotect::PerformCommand(Connection& connection)
|
|||||||
status = Hid_RemoveProtectedImage(connection.GetContext(), m_targetId);
|
status = Hid_RemoveProtectedImage(connection.GetContext(), m_targetId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw WException(-2, L"Internal error, invalid type for command 'unprotect'");
|
throw WException(ERROR_UNKNOWN_COMPONENT, L"Internal error, invalid type for command 'unprotect'");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HID_STATUS_SUCCESSFUL(status))
|
if (!HID_STATUS_SUCCESSFUL(status))
|
||||||
|
@ -21,18 +21,18 @@ void CommandQuery::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
wstring object, target;
|
wstring object, target;
|
||||||
|
|
||||||
if (!args.GetNext(object))
|
if (!args.GetNext(object))
|
||||||
throw WException(-2, L"Error, mismatched argument #1 for command 'query'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #1 for command 'query'");
|
||||||
|
|
||||||
if (object == L"process")
|
if (object == L"process")
|
||||||
{
|
{
|
||||||
m_queryType = EQueryType::QueryProcess;
|
m_queryType = EQueryType::QueryProcess;
|
||||||
|
|
||||||
if (!args.GetNext(target))
|
if (!args.GetNext(target))
|
||||||
throw WException(-2, L"Error, mismatched argument #2 for command 'query'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #2 for command 'query'");
|
||||||
|
|
||||||
m_targetProcId = _wtol(target.c_str());
|
m_targetProcId = _wtol(target.c_str());
|
||||||
if (!m_targetProcId)
|
if (!m_targetProcId)
|
||||||
throw WException(-2, L"Error, invalid target pid for command 'query'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid target pid for command 'query'");
|
||||||
}
|
}
|
||||||
else if (object == L"state")
|
else if (object == L"state")
|
||||||
{
|
{
|
||||||
@ -41,7 +41,7 @@ void CommandQuery::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
throw WException(-2, L"Error, invalid object type for command 'query'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, invalid object type for command 'query'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,14 +21,14 @@ void CommandState::LoadArgs(Arguments& args, CommandModeType mode)
|
|||||||
wstring state, enable;
|
wstring state, enable;
|
||||||
|
|
||||||
if (!args.GetNext(state))
|
if (!args.GetNext(state))
|
||||||
throw WException(-2, L"Error, mismatched argument #1 for command 'state'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #1 for command 'state'");
|
||||||
|
|
||||||
if (state == L"on")
|
if (state == L"on")
|
||||||
m_state = true;
|
m_state = true;
|
||||||
else if (state == L"off")
|
else if (state == L"off")
|
||||||
m_state = false;
|
m_state = false;
|
||||||
else
|
else
|
||||||
throw WException(-2, L"Error, mismatched argument #2 for command 'state'");
|
throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument #2 for command 'state'");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandState::PerformCommand(Connection& connection)
|
void CommandState::PerformCommand(Connection& connection)
|
||||||
|
Loading…
Reference in New Issue
Block a user