24
24
#define VERSION VER_FILEVERSION_STR
25
25
#define LOG_FILE_NAME " unpack.log"
26
26
27
+ void print_log_hdr (std::wofstream &report, const time_t & session_timestamp, const t_params_struct& params)
28
+ {
29
+ report << " [" << session_timestamp << " ] " ;
30
+
31
+ const char * exe_name = get_file_name (params.exe_path );
32
+ const char * img_name = get_file_name (params.img_path );
33
+ if (exe_name) {
34
+ report << exe_name;
35
+ }
36
+ if (img_name && exe_name &&
37
+ strlen (img_name) && strcmp (img_name, exe_name) != 0 )
38
+ {
39
+ report << " (" << img_name << " )" ;
40
+ }
41
+ report << " : " ;
42
+ }
43
+
27
44
void save_unpack_report (const time_t &session_timestamp, t_params_struct ¶ms, const ScanStats& finalStats)
28
45
{
29
46
std::wofstream report;
30
47
std::string report_name = LOG_FILE_NAME;
31
48
report.open (report_name, std::ofstream::out | std::ofstream::app);
32
- report << " [" << session_timestamp << " ] " ;
33
- report << params.exe_path ;
34
- if (strnlen (params.img_path , MAX_PATH) && strncmp (params.img_path ,params.exe_path , MAX_PATH) != 0 ) {
35
- report << " (" << params.img_path << " )" ;
36
- }
37
- report << " : " ;
49
+ print_log_hdr (report, session_timestamp, params);
50
+
38
51
if (finalStats.detected ) {
39
52
report << " Unpacked in: " << std::dec << finalStats.scanTime << " ms\n " ;
40
53
}
@@ -50,15 +63,11 @@ void save_remaing_files_report(const time_t& session_timestamp, t_params_struct&
50
63
if (!scanner.listExistingDroppedFiles (names)) {
51
64
return ;
52
65
}
66
+
53
67
std::wofstream report;
54
68
std::string report_name = LOG_FILE_NAME;
55
69
report.open (report_name, std::ofstream::out | std::ofstream::app);
56
- report << " [" << session_timestamp << " ] " ;
57
- report << params.exe_path ;
58
- if (strnlen (params.img_path , MAX_PATH) && strncmp (params.img_path , params.exe_path , MAX_PATH) != 0 ) {
59
- report << " (" << params.img_path << " )" ;
60
- }
61
- report << " : " ;
70
+ print_log_hdr (report, session_timestamp, params);
62
71
63
72
report << " Failed to delete files (" << std::dec << names.size () << " ):\n " ;
64
73
std::map<LONGLONG, std::wstring>::const_iterator itr;
0 commit comments