forked from hasherezade/tiny_tracer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TraceLog.h
55 lines (46 loc) · 1.36 KB
/
TraceLog.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
#pragma once
#include "pin.H"
#include <iostream>
#include <fstream>
class TraceLog
{
public:
TraceLog()
{
}
~TraceLog()
{
if (m_traceFile.is_open()) {
m_traceFile.close();
}
}
void init(std::string fileName, bool is_short)
{
if (fileName.empty()) fileName = "output.txt";
m_logFileName = fileName;
m_shortLog = is_short;
createFile();
}
void logCall(const ADDRINT prevModuleBase, const ADDRINT prevAddr, bool isRVA, const std::string module, const std::string func = "");
void logCall(const ADDRINT prevBase, const ADDRINT prevAddr, const ADDRINT calledPageBase, const ADDRINT callAddr);
void logSectionChange(const ADDRINT addr, std::string sectionName);
void logNewSectionCalled(const ADDRINT addFrom, std::string prevSection, std::string currSection);
void logRdtsc(const ADDRINT base, const ADDRINT rva);
void logCpuid(const ADDRINT base, const ADDRINT rva, const ADDRINT param);
void logLine(std::string str);
protected:
bool createFile()
{
if (m_traceFile.is_open()) {
return true;
}
m_traceFile.open(m_logFileName.c_str());
if (m_traceFile.is_open()) {
return true;
}
return false;
}
std::string m_logFileName;
std::ofstream m_traceFile;
bool m_shortLog;
};