6
0
mirror of https://github.com/JKornev/hidden synced 2024-06-29 18:32:00 +00:00
hidden/HiddenCLI/Helper.h

106 lines
2.1 KiB
C
Raw Normal View History

2016-12-04 19:27:46 +00:00
#pragma once
#include <string>
2016-12-26 21:33:16 +00:00
#include <sstream>
2016-12-04 19:27:46 +00:00
#include <vector>
#include <stdio.h>
#include <stdarg.h>
#include <Windows.h>
2016-12-06 23:19:49 +00:00
#include "../HiddenLib/HiddenLib.h"
2016-12-26 21:33:16 +00:00
extern std::wstringstream g_stdout;
extern std::wstringstream g_stderr;
2016-12-04 19:27:46 +00:00
class WException
{
std::wstring m_errorMessage;
unsigned int m_errorCode;
public:
WException(unsigned int Code, wchar_t* Format, ...);
const wchar_t* What();
unsigned int Code();
};
class Arguments
{
std::vector<std::wstring> m_arguments;
unsigned int m_argPointer;
public:
2016-12-15 21:09:42 +00:00
Arguments(int argc, wchar_t* argv[], int start = 1);
2016-12-04 19:27:46 +00:00
size_t ArgsCount();
2016-12-05 22:37:18 +00:00
bool Probe(std::wstring& arg);
bool SwitchToNext();
2016-12-04 19:27:46 +00:00
bool GetNext(std::wstring& arg);
};
class Handle
{
private:
DWORD m_error;
HANDLE m_handle;
public:
Handle(HANDLE handle);
~Handle();
HANDLE Get();
DWORD Error();
};
2016-12-06 23:19:49 +00:00
2016-12-23 00:05:09 +00:00
class RegistryKey
{
private:
HKEY m_hkey;
public:
2017-01-07 20:28:39 +00:00
RegistryKey(std::wstring regKey, HKEY root = HKEY_LOCAL_MACHINE, REGSAM access = KEY_ALL_ACCESS | KEY_WOW64_64KEY, bool newKey = false);
2016-12-23 00:05:09 +00:00
~RegistryKey();
2017-01-07 20:28:39 +00:00
void CopyTreeFrom(RegistryKey& src);
2016-12-23 00:05:09 +00:00
void SetDwordValue(const wchar_t* name, DWORD value);
DWORD GetDwordValue(const wchar_t* name, DWORD defValue);
2017-01-07 20:28:39 +00:00
void SetStrValue(const wchar_t* name, std::wstring& value, bool expanded = false);
void GetStrValue(const wchar_t* name, std::wstring& value, const wchar_t* defValue);
2016-12-23 00:05:09 +00:00
void SetMultiStrValue(const wchar_t* name, const std::vector<std::wstring>& strs);
void GetMultiStrValue(const wchar_t* name, std::vector<std::wstring>& strs);
void RemoveValue(const wchar_t* name);
2017-01-07 20:28:39 +00:00
static void DeleteKey(std::wstring regKey, HKEY root = HKEY_LOCAL_MACHINE);
2016-12-23 00:05:09 +00:00
};
2016-12-06 23:19:49 +00:00
enum EObjTypes {
TypeFile,
TypeDir,
TypeRegKey,
TypeRegVal,
};
enum EProcTypes {
TypeProcessId,
TypeImage,
};
HidRegRootTypes GetRegType(std::wstring& path);
HidPsInheritTypes LoadInheritOption(Arguments& args, HidPsInheritTypes default);
bool LoadApplyOption(Arguments& args, bool applyByDefault);
2016-12-12 20:40:35 +00:00
const wchar_t* ConvertInheritTypeToUnicode(HidPsInheritTypes type);
const wchar_t* ConvertRegRootTypeToUnicode(HidRegRootTypes type);