From fbbb57c346b96b5f038aadd574cc1f650d0b8b0d Mon Sep 17 00:00:00 2001 From: JKornev <8bit.dosninja@gmail.com> Date: Sat, 10 Dec 2016 00:34:07 +0300 Subject: [PATCH] Multiple fixes - Fixed issue with RuleId - Added loading of the new commands - Fixed issue with inherit\apply flags - Fixed invalid type issue for Protect\Ignore commands etc --- Hidden/ExcludeList.c | 2 +- Hidden/PsRules.c | 2 +- Hidden/todo.txt | 1 + HiddenCLI/Commands.cpp | 8 ++++++++ HiddenCLI/Helper.cpp | 15 +++++++++++++++ HiddenCLI/HiddenCLI.cpp | 2 +- HiddenCLI/Ignore.cpp | 4 ++-- HiddenCLI/Protect.cpp | 2 +- HiddenCLI/Query.cpp | 8 ++++---- 9 files changed, 34 insertions(+), 10 deletions(-) diff --git a/Hidden/ExcludeList.c b/Hidden/ExcludeList.c index 664bcd4..cb38a92 100644 --- a/Hidden/ExcludeList.c +++ b/Hidden/ExcludeList.c @@ -55,7 +55,7 @@ NTSTATUS InitializeExcludeListContext(PExcludeContext Context, UINT32 Type) InitializeListHead(&cntx->listHead); KeInitializeSpinLock(&cntx->listLock); - cntx->guidCounter = 0; + cntx->guidCounter = 1; cntx->type = Type; *Context = cntx; diff --git a/Hidden/PsRules.c b/Hidden/PsRules.c index 993ad96..123866c 100644 --- a/Hidden/PsRules.c +++ b/Hidden/PsRules.c @@ -51,7 +51,7 @@ NTSTATUS InitializePsRuleListContext(PPsRulesContext pRuleContext) return STATUS_MEMORY_NOT_ALLOCATED; } - context->idCounter = 0; + context->idCounter = 1; KeInitializeSpinLock(&context->tableLock); RtlInitializeGenericTableAvl(&context->table, ComparePsRuleEntry, AllocatePsRuleEntry, FreePsRuleEntry, NULL); diff --git a/Hidden/todo.txt b/Hidden/todo.txt index 57f328c..346f212 100644 --- a/Hidden/todo.txt +++ b/Hidden/todo.txt @@ -50,6 +50,7 @@ + unprotect + query - Протестировать все комманды +- При выполнении /unhide с любым ID возвращается статус ок - Проверить чтобы все ObjId генерировались начиная с 1 - Реализовать функционал вкл\выкл драйвера через IOCTL - Написать тест HiddenCLITests diff --git a/HiddenCLI/Commands.cpp b/HiddenCLI/Commands.cpp index 221f693..35cf82e 100644 --- a/HiddenCLI/Commands.cpp +++ b/HiddenCLI/Commands.cpp @@ -1,5 +1,8 @@ #include "Commands.h" #include "Hide.h" +#include "Ignore.h" +#include "Protect.h" +#include "Query.h" using namespace std; @@ -44,6 +47,11 @@ void Commands::LoadCommandsStack() { m_commandsStack.push_back(CommandPtr(new CommandHide())); m_commandsStack.push_back(CommandPtr(new CommandUnhide())); + m_commandsStack.push_back(CommandPtr(new CommandIgnore())); + m_commandsStack.push_back(CommandPtr(new CommandUnignore())); + m_commandsStack.push_back(CommandPtr(new CommandProtect())); + m_commandsStack.push_back(CommandPtr(new CommandUnprotect())); + m_commandsStack.push_back(CommandPtr(new CommandQuery())); } void Commands::Perform(Connection& connection) diff --git a/HiddenCLI/Helper.cpp b/HiddenCLI/Helper.cpp index d45fd61..5e0e363 100644 --- a/HiddenCLI/Helper.cpp +++ b/HiddenCLI/Helper.cpp @@ -110,11 +110,20 @@ HidPsInheritTypes LoadInheritOption(Arguments& args, HidPsInheritTypes default) return default; if (arg == L"inherit:none") + { + args.SwitchToNext(); return HidPsInheritTypes::WithoutInherit; + } else if (arg == L"inherit:always") + { + args.SwitchToNext(); return HidPsInheritTypes::InheritAlways; + } else if (arg == L"inherit:once") + { + args.SwitchToNext(); return HidPsInheritTypes::InheritOnce; + } return default; } @@ -127,9 +136,15 @@ bool LoadApplyOption(Arguments& args, bool applyByDefault) return applyByDefault; if (arg == L"apply:fornew") + { + args.SwitchToNext(); return false; + } else if (arg == L"apply:forall") + { + args.SwitchToNext(); return true; + } return applyByDefault; } diff --git a/HiddenCLI/HiddenCLI.cpp b/HiddenCLI/HiddenCLI.cpp index 0673b7c..5641a6a 100644 --- a/HiddenCLI/HiddenCLI.cpp +++ b/HiddenCLI/HiddenCLI.cpp @@ -17,7 +17,7 @@ int wmain(int argc, wchar_t* argv[]) if (!arguments.ArgsCount()) throw WException( -2, - L"Welcome to HiddenCLI, please use 'hiddencli help'" + L"Welcome to HiddenCLI, please use 'hiddencli /help'" ); { diff --git a/HiddenCLI/Ignore.cpp b/HiddenCLI/Ignore.cpp index 006bf88..64e947d 100644 --- a/HiddenCLI/Ignore.cpp +++ b/HiddenCLI/Ignore.cpp @@ -62,7 +62,7 @@ void CommandIgnore::LoadArgs(Arguments& args) void CommandIgnore::PerformCommand(Connection& connection) { HidStatus status; - HidObjId objId; + HidObjId objId = 0; switch (m_procType) { @@ -80,7 +80,7 @@ void CommandIgnore::PerformCommand(Connection& connection) throw WException(HID_STATUS_CODE(status), L"Error, command 'ignore' rejected"); wcerr << L"Command 'ignore' successful" << endl; - if (EProcTypes::TypeProcessId) + if (m_procType == EProcTypes::TypeProcessId) wcout << L"status:ok" << endl; else wcout << L"status:ok;objid:" << objId << endl; diff --git a/HiddenCLI/Protect.cpp b/HiddenCLI/Protect.cpp index fb039a0..0a5c7d8 100644 --- a/HiddenCLI/Protect.cpp +++ b/HiddenCLI/Protect.cpp @@ -80,7 +80,7 @@ void CommandProtect::PerformCommand(Connection& connection) throw WException(HID_STATUS_CODE(status), L"Error, command 'protect' rejected"); wcerr << L"Command 'protect' successful" << endl; - if (EProcTypes::TypeProcessId) + if (m_procType == EProcTypes::TypeProcessId) wcout << L"status:ok" << endl; else wcout << L"status:ok;objid:" << objId << endl; diff --git a/HiddenCLI/Query.cpp b/HiddenCLI/Query.cpp index 9d89a58..5a3310c 100644 --- a/HiddenCLI/Query.cpp +++ b/HiddenCLI/Query.cpp @@ -65,11 +65,11 @@ void CommandQuery::PerformCommand(Connection& connection) if (!HID_STATUS_SUCCESSFUL(status)) throw WException(HID_STATUS_CODE(status), L"Error, query protected state rejected"); - wcerr << L"ignore state:" << (excludeState == HidActiveState::StateEnabled ? L"true" : L"false") + wcerr << L"Ignored state:" << (excludeState == HidActiveState::StateEnabled ? L"true" : L"false") << L", inherit:" << ConvertInheritTypeToUnicode(excludedInherit) << endl; - wcerr << L"protect state:" << (protectedState == HidActiveState::StateEnabled ? L"true" : L"false") + wcerr << L"Protected state:" << (protectedState == HidActiveState::StateEnabled ? L"true" : L"false") << L", inherit:" << ConvertInheritTypeToUnicode(protectedInherit) << endl; - wcout << L"status:ok;ignore:" << excludeState << L"," << excludedInherit - << L";protect:" << protectedState << L"," << protectedInherit << endl; + wcout << L"status:ok;ignored:" << excludeState << L"," << excludedInherit + << L";protected:" << protectedState << L"," << protectedInherit << endl; }