-
Notifications
You must be signed in to change notification settings - Fork 255
/
hh_report.h
88 lines (73 loc) · 2.19 KB
/
hh_report.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
#include <time.h>
#include <windows.h>
#include <pe_sieve_api.h>
#include <map>
#include <vector>
#include "hh_params.h"
class HHScanReport
{
public:
HHScanReport(DWORD start_tick, time_t start_time)
: startTick(start_tick), endTick(0),
startTime(start_time), endTime(0)
{
}
bool setEndTick(DWORD end_tick, time_t end_time)
{
if (end_tick < this->startTick) {
return false;
}
this->endTick = end_tick;
this->endTime = end_time;
return true;
}
DWORD getScanTime() const
{
if (startTick == 0 || endTick == 0) return 0;
return (this->endTick - this->startTick);
}
bool appendReport(pesieve::t_report &scan_report, const std::wstring &img_name);
size_t countReports(const pesieve::t_results_filter rfilter) const
{
if (rfilter == pesieve::SHOW_NONE) {
return 0;
}
if (rfilter == pesieve::SHOW_ALL) {
return countTotal(false);
}
if (rfilter == pesieve::SHOW_SUCCESSFUL_ONLY) {
return countTotal(true);
}
size_t total = 0;
if (rfilter & pesieve::SHOW_ERRORS) {
total += failed.size();
}
if (rfilter & pesieve::SHOW_SUSPICIOUS) {
total += suspicious.size();
}
return total;
}
size_t countTotal(bool successfulOnly = true) const
{
size_t total = pidToReport.size();
if (successfulOnly) {
total -= failed.size();
}
return total;
}
void toString(std::wstringstream &stream, const pesieve::t_results_filter rfilter);
protected:
size_t reportsToString(std::wstringstream &stream, const pesieve::t_results_filter rfilter);
size_t toJSON(std::wstringstream &stream, const t_hh_params ¶ms);
size_t reportsToJSON(std::wstringstream &stream, size_t level, const t_hh_params ¶ms);
time_t startTime;
time_t endTime;
DWORD startTick;
DWORD endTick;
std::map<DWORD, pesieve::t_report> pidToReport;
std::map<DWORD, std::wstring> pidToName;
std::vector<DWORD> suspicious;
std::vector<DWORD> failed;
friend class HHScanner;
};