Skip to content

Commit 6e273a3

Browse files
unknownunknown
authored andcommitted
Adding C++ source files and VC++ project files
1 parent 04b089b commit 6e273a3

File tree

3 files changed

+559
-0
lines changed

3 files changed

+559
-0
lines changed

AnnotatedTracing.sln

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 10.00
3+
# Visual C++ Express 2008
4+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AnnotatedTracing", "AnnotatedTracing\AnnotatedTracing.vcproj", "{A467D188-4C11-40F1-BABA-6C619C7DAAB1}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Win32 = Debug|Win32
9+
Release|Win32 = Release|Win32
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{A467D188-4C11-40F1-BABA-6C619C7DAAB1}.Debug|Win32.ActiveCfg = Release|Win32
13+
{A467D188-4C11-40F1-BABA-6C619C7DAAB1}.Debug|Win32.Build.0 = Release|Win32
14+
{A467D188-4C11-40F1-BABA-6C619C7DAAB1}.Release|Win32.ActiveCfg = Release|Win32
15+
{A467D188-4C11-40F1-BABA-6C619C7DAAB1}.Release|Win32.Build.0 = Release|Win32
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#include <windows.h>
2+
3+
#include <ida.hpp>
4+
#include <idp.hpp>
5+
#include <loader.hpp>
6+
#include <diskio.hpp>
7+
#include <graph.hpp>
8+
#include <kernwin.hpp>
9+
10+
#include <string>
11+
#include <iostream>
12+
#include <fstream>
13+
14+
#include <boost/regex.hpp>
15+
16+
using namespace std;
17+
18+
int IDAP_init(void)
19+
{
20+
// Do checks here to ensure your plug-in is being used within
21+
// an environment it was written for. Return PLUGIN_SKIP if the
22+
// checks fail, otherwise return PLUGIN_KEEP.
23+
return PLUGIN_KEEP;
24+
}
25+
void IDAP_term(void)
26+
{
27+
// Stuff to do when exiting, generally you'd put any sort
28+
// of clean-up jobs here.
29+
return;
30+
}
31+
32+
// The plugin can be passed an integer argumenct from the plugins.cfg
33+
// file. This can be useful when you want the one plug-in to do
34+
// something different depending on the hot-key pressed or menu
35+
// item selected.
36+
void IDAP_run(int arg)
37+
{
38+
// The "meat" of your plug-in
39+
ea_t cur_ea;
40+
char* trace_name = NULL;
41+
FILE* fin;
42+
string cur_line, instruction, annotation;
43+
ifstream trace_file;
44+
unsigned int annotation_pos = 0;
45+
boost::regex trace_re("((?:\\d|\\w)+)\\: \\w+\\s+.+\\# ((?:\\w+: (?:\\w|\\d)+(?:\\s,\\s)*)*)");
46+
boost::regex instruction_re("((?:[0-9]|[a-f])+)");
47+
boost::cmatch instruction_matches;
48+
49+
msg("Annotated Tracing Plugin 1.0\n");
50+
//cur_ea = get_screen_ea();
51+
//describe(cur_ea, 0, "test comment!");
52+
//set_cmt(cur_ea, "test comment!", false);
53+
trace_name = askfile_c(0,"instrtrace.trace","Select the instruction trace file");
54+
msg("Selected file: %s\n", trace_name);
55+
56+
if(trace_name)
57+
{
58+
trace_file.open(trace_name);
59+
while(!trace_file.eof())
60+
{
61+
annotation_pos = 0;
62+
getline(trace_file, cur_line);
63+
64+
//if (!boost::regex_search(cur_line, trace_re))
65+
{
66+
//continue;
67+
}
68+
69+
/*boost::regex_search(cur_line.c_str(), instruction_matches, instruction_re);
70+
71+
if(!instruction_matches.empty())
72+
{
73+
instruction = string(instruction_matches[1].first, instruction_matches[1].second);
74+
}*/
75+
76+
//msg(instruction.c_str());
77+
78+
instruction = cur_line.substr(0, 7);
79+
cur_ea = strtol(instruction.c_str(), NULL, 16);
80+
81+
annotation_pos = cur_line.find("#");
82+
//set_cmt(strtol(instruction.c_str(), NULL, 16), "TEST!", false);
83+
set_item_color(cur_ea, 0x32CD32);
84+
if(annotation_pos != 0)
85+
{
86+
annotation = cur_line.substr(annotation_pos+1);
87+
set_cmt(cur_ea, annotation.c_str(), false);
88+
}
89+
//msg(cur_line.c_str());
90+
}
91+
}
92+
93+
/*for annotation in annotations.split(", "):
94+
if len(annotation.split("ptr_val[]:")) == 2:
95+
if cmt_tbl.has_key(instruction):
96+
cmt_tbl[instruction] += ', ' + annotation.split("ptr_val[]:")[1].strip()#annotation.split("ptr_val[]:")[0].strip() + ' "' + annotation.split("ptr_val[]:")[1].strip() + '"'
97+
else:
98+
cmt_tbl[instruction] = annotation.split("ptr_val[]:")[1].strip()#annotation.split("ptr_val[]:")[0].strip() + ' "' + annotation.split("ptr_val[]:")[1].strip() + '"'
99+
100+
original_cmt = GetCommentEx(int(instruction,16), 0)
101+
if original_cmt == None:
102+
original_cmt = ''
103+
MakeComm(int(instruction, 16), str(original_cmt) + annotation.split("ptr_val[]:")[1].strip())
104+
105+
SetColor(int(instruction, 16), CIC_ITEM, 0x32CD32)*/
106+
107+
return;
108+
}
109+
// There isn't much use for these yet, but I set them anyway.
110+
char IDAP_comment[] = "This is my test plug-in";
111+
char IDAP_help[] = "My plugin";
112+
// The name of the plug-in displayed in the Edit->Plugins menu. It
113+
// can be overridden in the user's plugins.cfg file.
114+
char IDAP_name[] = "Annotated Tracing";
115+
// The hot-key the user can use to run your plug-in.
116+
char IDAP_hotkey[] = "Alt-1";
117+
// The all-important exported PLUGIN object
118+
plugin_t PLUGIN =
119+
{
120+
IDP_INTERFACE_VERSION, // IDA version plug-in is written for
121+
0, // Flags (see below)
122+
IDAP_init, // Initialisation function
123+
IDAP_term, // Clean-up function
124+
IDAP_run, // Main plug-in body
125+
IDAP_comment, // Comment – unused
126+
IDAP_help, // As above – unused
127+
IDAP_name, // Plug-in name shown in
128+
// Edit->Plugins menu
129+
IDAP_hotkey // Hot key to run the plug-in
130+
};

0 commit comments

Comments
 (0)