-
Notifications
You must be signed in to change notification settings - Fork 604
/
TskReportPluginModule.cpp
executable file
·100 lines (89 loc) · 3.07 KB
/
TskReportPluginModule.cpp
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
89
90
91
92
93
94
95
96
97
98
99
100
/*
* The Sleuth Kit
*
* Contact: Brian Carrier [carrier <at> sleuthkit [dot] org]
* Copyright (c) 2010-2012 Basis Technology Corporation. All Rights
* reserved.
*
* This software is distributed under the Common Public License 1.0
*/
/**
* \file TskReportPluginModule.cpp
* Contains the implementation for the TskReportPluginModule class.
*/
// Include the class definition first to ensure it does not depend on subsequent includes in this file.
#include "TskReportPluginModule.h"
// TSK Framework includes
#include "Services/TskServices.h"
#include "Utilities/TskException.h"
// C/C++ includes
#include <sstream>
TskModule::Status TskReportPluginModule::report()
{
const std::string MSG_PREFIX = "TskReportPluginModule::report : ";
TskModule::Status status = TskModule::OK;
try
{
if (!isLoaded())
{
std::stringstream msg;
msg << MSG_PREFIX << "'" << getPath() << "' is not loaded";
throw TskException(msg.str());
}
if (!hasSymbol(TskPluginModule::REPORT_SYMBOL))
{
std::stringstream msg;
msg << MSG_PREFIX << "'" << getPath() << "' does not define the '" << TskPluginModule::REPORT_SYMBOL << "' symbol";
throw TskException(msg.str());
}
typedef TskModule::Status (*ReportFunc)();
ReportFunc report = (ReportFunc)getSymbol(TskPluginModule::REPORT_SYMBOL);
status = report();
}
catch (TskException &ex)
{
std::stringstream msg;
msg << MSG_PREFIX << "TskException executing report function of " << getName() << ": " << ex.message();
LOGERROR(msg.str());
status = TskModule::FAIL;
}
catch (Poco::Exception &ex)
{
std::stringstream msg;
msg << MSG_PREFIX << "Poco::Exception executing report function of " << getName() << ": " << ex.displayText();
LOGERROR(msg.str());
status = TskModule::FAIL;
}
catch (std::exception &ex)
{
std::stringstream msg;
msg << MSG_PREFIX << "std::exception executing report function of " << getName() << ": " << ex.what();
LOGERROR(msg.str());
status = TskModule::FAIL;
}
catch (...)
{
std::stringstream msg;
msg << MSG_PREFIX << "unrecognized exception executing report function of " << getName();
LOGERROR(msg.str());
status = TskModule::FAIL;
}
return status;
}
void TskReportPluginModule::checkInterface()
{
const std::string MSG_PREFIX = "TskReportPluginModule::checkInterface : ";
if (!isLoaded())
{
std::stringstream msg;
msg << MSG_PREFIX << getPath() << " is not loaded";
LOGERROR(msg.str());
throw TskException(msg.str());
}
if (!hasSymbol(TskPluginModule::REPORT_SYMBOL))
{
std::stringstream msg;
msg << MSG_PREFIX << getPath() << " does not define the required '" << TskPluginModule::REPORT_SYMBOL << "' symbol";
throw TskException(msg.str());
}
}