mirror of
https://github.com/JKornev/hidden
synced 2024-06-16 03:58:04 +00:00
Fix for status output
This commit is contained in:
parent
1b643e5e84
commit
32f2da5145
@ -70,4 +70,5 @@
|
||||
+ Реализовать установку конфигов в реестр через hiddencli
|
||||
- Привести в порядок вывод статуса в hiddencli
|
||||
- Насодить на ETL и DbgPrintEx
|
||||
- Добавить SAL на функции драйвера
|
||||
|
||||
|
@ -5,6 +5,11 @@ using namespace std;
|
||||
|
||||
// =================
|
||||
|
||||
std::wstringstream g_stdout;
|
||||
std::wstringstream g_stderr;
|
||||
|
||||
// =================
|
||||
|
||||
WException::WException(unsigned int Code, wchar_t* Format, ...) :
|
||||
m_errorCode(Code)
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
@ -8,6 +9,9 @@
|
||||
|
||||
#include "../HiddenLib/HiddenLib.h"
|
||||
|
||||
extern std::wstringstream g_stdout;
|
||||
extern std::wstringstream g_stderr;
|
||||
|
||||
class WException
|
||||
{
|
||||
std::wstring m_errorMessage;
|
||||
|
@ -197,7 +197,15 @@ int wmain(int argc, wchar_t* argv[])
|
||||
commands->Uninstall(key);
|
||||
}
|
||||
}
|
||||
wcout << L"status:ok" << endl;
|
||||
|
||||
const wstring output = g_stdout.str();
|
||||
|
||||
wcerr << g_stderr.str();
|
||||
|
||||
if (output.empty())
|
||||
wcout << L"status:ok" << endl;
|
||||
else
|
||||
wcout << L"status:ok;" << output << endl;
|
||||
}
|
||||
catch (WException& exception)
|
||||
{
|
||||
|
@ -90,8 +90,8 @@ void CommandHide::PerformCommand(Connection& connection)
|
||||
if (!HID_STATUS_SUCCESSFUL(status))
|
||||
throw WException(HID_STATUS_CODE(status), L"Error, command 'hide' rejected");
|
||||
|
||||
wcerr << L"Command 'hide' successful" << endl;
|
||||
wcout << L"status:ok;ruleid:" << objId << endl;
|
||||
g_stderr << L"Command 'hide' successful" << endl;
|
||||
g_stdout << L"ruleid:" << objId << endl;
|
||||
}
|
||||
|
||||
void CommandHide::InstallCommand(RegistryKey& configKey)
|
||||
@ -129,17 +129,20 @@ void CommandHide::InstallCommand(RegistryKey& configKey)
|
||||
commands.push_back(entry);
|
||||
configKey.SetMultiStrValue(valueName, commands);
|
||||
|
||||
wcerr << L"Install 'hide' successful" << endl;
|
||||
g_stderr << L"Install 'hide' successful" << endl;
|
||||
}
|
||||
|
||||
void CommandHide::UninstallCommand(RegistryKey& configKey)
|
||||
{
|
||||
configKey.RemoveValue(L"Hid_HideFsFiles");
|
||||
configKey.RemoveValue(L"Hid_HideFsDirs");
|
||||
configKey.RemoveValue(L"Hid_HideRegKeys");
|
||||
configKey.RemoveValue(L"Hid_HideRegValues");
|
||||
int errors = 0;
|
||||
|
||||
wcerr << L"Uninstall 'hide' successful" << endl;
|
||||
try { configKey.RemoveValue(L"Hid_HideFsFiles"); } catch (...) { errors++; }
|
||||
try { configKey.RemoveValue(L"Hid_HideFsDirs"); } catch (...) { errors++; }
|
||||
try { configKey.RemoveValue(L"Hid_HideRegKeys"); } catch (...) { errors++; }
|
||||
try { configKey.RemoveValue(L"Hid_HideRegValues"); } catch (...) { errors++; }
|
||||
|
||||
if (errors < 4)
|
||||
g_stderr << L"Uninstall 'hide' successful" << endl;
|
||||
}
|
||||
|
||||
CommandPtr CommandHide::CreateInstance()
|
||||
@ -249,9 +252,9 @@ void CommandUnhide::PerformCommand(Connection& connection)
|
||||
}
|
||||
|
||||
if (!HID_STATUS_SUCCESSFUL(status))
|
||||
throw WException(HID_STATUS_CODE(status), L"Error, command 'hide' rejected");
|
||||
throw WException(HID_STATUS_CODE(status), L"Error, command 'unhide' rejected");
|
||||
|
||||
wcerr << L"Command 'unhide' successful" << endl;
|
||||
g_stderr << L"Command 'unhide' successful" << endl;
|
||||
}
|
||||
|
||||
CommandPtr CommandUnhide::CreateInstance()
|
||||
|
@ -82,11 +82,9 @@ void CommandIgnore::PerformCommand(Connection& connection)
|
||||
if (!HID_STATUS_SUCCESSFUL(status))
|
||||
throw WException(HID_STATUS_CODE(status), L"Error, command 'ignore' rejected");
|
||||
|
||||
wcerr << L"Command 'ignore' successful" << endl;
|
||||
if (m_procType == EProcTypes::TypeProcessId)
|
||||
wcout << L"status:ok" << endl;
|
||||
else
|
||||
wcout << L"status:ok;ruleid:" << objId << endl;
|
||||
g_stderr << L"Command 'ignore' successful" << endl;
|
||||
if (m_procType == EProcTypes::TypeImage)
|
||||
g_stdout << L"ruleid:" << objId << endl;
|
||||
}
|
||||
|
||||
void CommandIgnore::InstallCommand(RegistryKey& configKey)
|
||||
@ -109,14 +107,14 @@ void CommandIgnore::InstallCommand(RegistryKey& configKey)
|
||||
commands.push_back(entry);
|
||||
configKey.SetMultiStrValue(L"Hid_IgnoredImages", commands);
|
||||
|
||||
wcerr << L"Install 'ignore' successful" << endl;
|
||||
g_stderr << L"Install 'ignore' successful" << endl;
|
||||
}
|
||||
|
||||
void CommandIgnore::UninstallCommand(RegistryKey& configKey)
|
||||
{
|
||||
configKey.RemoveValue(L"Hid_IgnoredImages");
|
||||
|
||||
wcerr << L"Uninstall 'ignore' successful" << endl;
|
||||
g_stderr << L"Uninstall 'ignore' successful" << endl;
|
||||
}
|
||||
|
||||
CommandPtr CommandIgnore::CreateInstance()
|
||||
@ -196,7 +194,7 @@ void CommandUnignore::PerformCommand(Connection& connection)
|
||||
if (!HID_STATUS_SUCCESSFUL(status))
|
||||
throw WException(HID_STATUS_CODE(status), L"Error, command 'unignore' rejected");
|
||||
|
||||
wcerr << L"Command 'unignore' successful" << endl;
|
||||
g_stderr << L"Command 'unignore' successful" << endl;
|
||||
}
|
||||
|
||||
CommandPtr CommandUnignore::CreateInstance()
|
||||
|
@ -82,11 +82,9 @@ void CommandProtect::PerformCommand(Connection& connection)
|
||||
if (!HID_STATUS_SUCCESSFUL(status))
|
||||
throw WException(HID_STATUS_CODE(status), L"Error, command 'protect' rejected");
|
||||
|
||||
wcerr << L"Command 'protect' successful" << endl;
|
||||
if (m_procType == EProcTypes::TypeProcessId)
|
||||
wcout << L"status:ok" << endl;
|
||||
else
|
||||
wcout << L"status:ok;ruleid:" << objId << endl;
|
||||
g_stderr << L"Command 'protect' successful" << endl;
|
||||
if (m_procType == EProcTypes::TypeImage)
|
||||
g_stdout << L"status:ok;ruleid:" << objId << endl;
|
||||
}
|
||||
|
||||
void CommandProtect::InstallCommand(RegistryKey& configKey)
|
||||
@ -109,14 +107,14 @@ void CommandProtect::InstallCommand(RegistryKey& configKey)
|
||||
commands.push_back(entry);
|
||||
configKey.SetMultiStrValue(L"Hid_ProtectedImages", commands);
|
||||
|
||||
wcerr << L"Install 'protect' successful" << endl;
|
||||
g_stderr << L"Install 'protect' successful" << endl;
|
||||
}
|
||||
|
||||
void CommandProtect::UninstallCommand(RegistryKey& configKey)
|
||||
{
|
||||
configKey.RemoveValue(L"Hid_ProtectedImages");
|
||||
|
||||
wcerr << L"Uninstall 'protect' successful" << endl;
|
||||
g_stderr << L"Uninstall 'protect' successful" << endl;
|
||||
}
|
||||
|
||||
CommandPtr CommandProtect::CreateInstance()
|
||||
@ -196,7 +194,7 @@ void CommandUnprotect::PerformCommand(Connection& connection)
|
||||
if (!HID_STATUS_SUCCESSFUL(status))
|
||||
throw WException(HID_STATUS_CODE(status), L"Error, command 'unprotect' rejected");
|
||||
|
||||
wcerr << L"Command 'unprotect' successful" << endl;
|
||||
g_stderr << L"Command 'unprotect' successful" << endl;
|
||||
}
|
||||
|
||||
CommandPtr CommandUnprotect::CreateInstance()
|
||||
|
@ -57,8 +57,8 @@ void CommandQuery::PerformCommand(Connection& connection)
|
||||
if (!HID_STATUS_SUCCESSFUL(status))
|
||||
throw WException(HID_STATUS_CODE(status), L"Error, query state rejected");
|
||||
|
||||
wcerr << L"Driver state:" << (state == HidActiveState::StateEnabled ? L"enabled" : L"disabled") << endl;
|
||||
wcout << L"status:ok;state:" << (state == HidActiveState::StateEnabled ? 1 : 0) << endl;
|
||||
g_stderr << L"Driver state:" << (state == HidActiveState::StateEnabled ? L"enabled" : L"disabled") << endl;
|
||||
g_stdout << L"state:" << (state == HidActiveState::StateEnabled ? 1 : 0) << endl;
|
||||
}
|
||||
else if (m_queryType == EQueryType::QueryProcess)
|
||||
{
|
||||
@ -73,12 +73,12 @@ void CommandQuery::PerformCommand(Connection& connection)
|
||||
if (!HID_STATUS_SUCCESSFUL(status))
|
||||
throw WException(HID_STATUS_CODE(status), L"Error, query protected state rejected");
|
||||
|
||||
wcerr << L"Ignored state:" << (excludeState == HidActiveState::StateEnabled ? L"true" : L"false")
|
||||
g_stderr << L"Ignored state:" << (excludeState == HidActiveState::StateEnabled ? L"true" : L"false")
|
||||
<< L", inherit:" << ConvertInheritTypeToUnicode(excludedInherit) << endl;
|
||||
wcerr << L"Protected state:" << (protectedState == HidActiveState::StateEnabled ? L"true" : L"false")
|
||||
g_stderr << L"Protected state:" << (protectedState == HidActiveState::StateEnabled ? L"true" : L"false")
|
||||
<< L", inherit:" << ConvertInheritTypeToUnicode(protectedInherit) << endl;
|
||||
|
||||
wcout << L"status:ok;ignored:" << excludeState << L"," << excludedInherit
|
||||
g_stdout << L"ignored:" << excludeState << L"," << excludedInherit
|
||||
<< L";protected:" << protectedState << L"," << protectedInherit << endl;
|
||||
}
|
||||
}
|
||||
|
@ -39,21 +39,21 @@ void CommandState::PerformCommand(Connection& connection)
|
||||
if (!HID_STATUS_SUCCESSFUL(status))
|
||||
throw WException(HID_STATUS_CODE(status), L"Error, command 'state' rejected");
|
||||
|
||||
wcerr << L"Command 'state' successful" << endl;
|
||||
g_stderr << L"Command 'state' successful" << endl;
|
||||
}
|
||||
|
||||
void CommandState::InstallCommand(RegistryKey& configKey)
|
||||
{
|
||||
configKey.SetDwordValue(L"Hid_State", (m_state ? 1 : 0));
|
||||
|
||||
wcerr << L"Install 'state' successful" << endl;
|
||||
g_stderr << L"Install 'state' successful" << endl;
|
||||
}
|
||||
|
||||
void CommandState::UninstallCommand(RegistryKey& configKey)
|
||||
{
|
||||
configKey.RemoveValue(L"Hid_State");
|
||||
|
||||
wcerr << L"Uninstall 'state' successful" << endl;
|
||||
g_stderr << L"Uninstall 'state' successful" << endl;
|
||||
}
|
||||
|
||||
CommandPtr CommandState::CreateInstance()
|
||||
|
Loading…
Reference in New Issue
Block a user