HollowsHunter
Scans all running processes. Recognizes and dumps a variety of potentially malicious implants (replaced/implanted PEs, shellcodes, hooks, in-memory patches).
Loading...
Searching...
No Matches
term_util.cpp
Go to the documentation of this file.
1
#include "
term_util.h
"
2
3
#include <windows.h>
4
5
#include <iostream>
6
#include <string>
7
#include <mutex>
8
9
std::mutex
g_stdOutMutex
;
10
11
bool
get_current_color
(
int
descriptor, WORD &color)
12
{
13
CONSOLE_SCREEN_BUFFER_INFO info;
14
if
(!GetConsoleScreenBufferInfo(GetStdHandle(descriptor), &info))
15
return
false
;
16
color = info.wAttributes;
17
return
true
;
18
}
19
20
WORD
set_color
(WORD color)
21
{
22
WORD old_color = 7;
23
get_current_color
(STD_OUTPUT_HANDLE, old_color);
24
25
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
26
FlushConsoleInputBuffer(hConsole);
27
SetConsoleTextAttribute(hConsole, color);
28
FlushConsoleInputBuffer(hConsole);
29
30
return
old_color;
31
}
32
33
void
print_in_color
(WORD color,
const
std::string &text)
34
{
35
const
std::lock_guard<std::mutex> stdOutLock(
g_stdOutMutex
);
36
WORD old_color =
set_color
(color);
37
std::cout << text;
38
std::cout.flush();
39
set_color
(old_color);
40
}
print_in_color
void print_in_color(WORD color, const std::string &text)
Definition
term_util.cpp:33
set_color
WORD set_color(WORD color)
Definition
term_util.cpp:20
g_stdOutMutex
std::mutex g_stdOutMutex
Definition
term_util.cpp:9
get_current_color
bool get_current_color(int descriptor, WORD &color)
Definition
term_util.cpp:11
term_util.h
Generated by
1.12.0