21#include <boost/format.hpp>
22#include <boost/version.hpp>
25#pragma warning(disable:4512)
26#pragma warning(disable:4100)
28#include <boost/graph/graph_traits.hpp>
29#include <boost/graph/adjacency_list.hpp>
30#include <boost/graph/graphviz.hpp>
34#include <boost/intrusive_ptr.hpp>
80typedef boost::property<boost::vertex_index_t, int, GroupProperty>
GraphProperty;
114 if (
is_jump.is_jump) output <<
"empty";
115 else output <<
"normal";
143 std::ostream& out,
const VertexOrEdge& v
145 out <<
"[arrowhead=\"" << get(
name, v) <<
"\"]";
169typedef boost::adjacency_list<boost::setS, boost::listS, boost::bidirectionalS, GraphProperty, EdgeProperty>
Graph;
315 output <<
"{Block type: ";
316 switch(group->type) {
325 output <<
"Expected stack level: " << group->stack_level <<
"\\n";
326 if (group->start_else) output <<
"Start of else\\n";
327 for (
ElseEndIterator it = group->end_else.begin(); it != group->end_else.end(); ++ it)
328 output << boost::format(
"End of else at %08x\\n") % (*(*it)->start)->GetAddress();
332 std::stringstream stream;
334#if (BOOST_VERSION >= 104500)
335 output << stream.str();
337 std::string s = stream.str();
338 for (std::string::iterator it = s.begin(); it != s.end(); ++it)
339 if (*it ==
'"') output <<
"\\\"";
340 else if (*it ==
'|') output <<
"\\|";
341 else if (*it ==
'{') output <<
"\\{";
342 else if (*it ==
'}') output <<
"\\}";
346 }
while (inst ++ != group->end);
GROUP_TYPE
Enumeration representing the different kinds of groups.
Definition: Graph.h:41
@ GROUP_TYPE_NORMAL
Normal group.
Definition: Graph.h:46
@ GROUP_TYPE_DO_WHILE
Group is the condition check for a do-while-loop.
Definition: Graph.h:56
@ GROUP_TYPE_CONTINUE
Group is a continue.
Definition: Graph.h:71
@ GROUP_TYPE_BREAK
Group is a break.
Definition: Graph.h:66
@ GROUP_TYPE_WHILE
Group is the condition check for a while-loop.
Definition: Graph.h:51
@ GROUP_TYPE_IF
Group is the condition check for an if.
Definition: Graph.h:61
boost::property< boost::vertex_index_t, int, GroupProperty > GraphProperty
Definition: Graph.h:80
boost::intrusive_ptr< Group > GroupPtr
Definition: Graph.h:76
boost::property< boost::edge_attribute_t, IsJump > EdgeProperty
Definition: Graph.h:167
Graph::edge_descriptor GraphEdge
Definition: Graph.h:175
std::pair< OutEdgeIterator, OutEdgeIterator > OutEdgeRange
Definition: Graph.h:183
Graph::in_edge_iterator InEdgeIterator
Definition: Graph.h:179
Graph::vertex_iterator VertexIterator
Definition: Graph.h:173
Graph::vertex_descriptor GraphVertex
Definition: Graph.h:171
ElseEnds::iterator ElseEndIterator
Definition: Graph.h:221
boost::adjacency_list< boost::setS, boost::listS, boost::bidirectionalS, GraphProperty, EdgeProperty > Graph
Definition: Graph.h:169
std::pair< InEdgeIterator, InEdgeIterator > InEdgeRange
Definition: Graph.h:185
std::pair< VertexIterator, VertexIterator > VertexRange
Definition: Graph.h:181
Graph::out_edge_iterator OutEdgeIterator
Definition: Graph.h:177
boost::property< boost::vertex_name_t, GroupPtr > GroupProperty
Definition: Graph.h:78
std::vector< Group * > ElseEnds
Definition: Graph.h:219
InstVec::iterator InstIterator
Type representing an iterator over InstPtrs.
Definition: Instruction.h:387
InstVec::const_iterator ConstInstIterator
Type representing a const_iterator over InstPtrs.
Definition: Instruction.h:392
Base class for engines.
Definition: Engine.h:34
Provides a base implementation of reference counting.
Definition: RefCounted.h:28
Property writer for the IsJump property.
Definition: Graph.h:125
Name name
The name of the attribute to use.
Definition: Graph.h:153
void operator()(std::ostream &out, const VertexOrEdge &v) const
Outputs the arrowhead edge property.
Definition: Graph.h:142
ArrowheadWriter(Name name)
Constructor.
Definition: Graph.h:134
ArrowheadWriter< Name > MakeArrowheadWriter(Name n)
Creates an arrowhead property writer.
Definition: Graph.h:161
Structure representing a line of code.
Definition: Graph.h:190
bool indent_after
Whether to remove an indentation level after outputting the line.
Definition: Graph.h:205
bool unindent_before
Whether or not to add an indentation level before outputting the line.
Definition: Graph.h:200
std::string line
The line of code.
Definition: Graph.h:195
CodeLine(const std::string &line, bool unindent_before, bool indent_after)
Constructor for CodeLine.
Definition: Graph.cpp:24
Type used to set properties for dot output.
Definition: Graph.h:357
Engine * engine
Engine containing function information for the script.
Definition: Graph.h:398
GraphProperties(Engine *engine, const Graph &graph)
Constructor.
Definition: Graph.cpp:42
GraphProperties & operator=(const GraphProperties &rhs)
Copy constructor.
Definition: Graph.cpp:47
void operator()(std::ostream &out) const
Print properties of the graph.
Definition: Graph.cpp:55
const Graph * graph
Pointer to the to the graph for the script.
Definition: Graph.h:403
Structure representing a group of instructions.
Definition: Graph.h:226
int stack_level
Level of the stack upon entry.
Definition: Graph.h:246
GROUP_TYPE type
Type of the group.
Definition: Graph.h:251
std::vector< CodeLine > code
Decompiled lines of code.
Definition: Graph.h:278
Group * prev
Pointer to the previous group, when ordered by address.
Definition: Graph.h:268
InstIterator end
Last instruction in the group.
Definition: Graph.h:241
Group()
Parameterless constructor.
Definition: Graph.cpp:27
InstIterator start
First instruction in the group.
Definition: Graph.h:236
friend std::ostream & operator<<(std::ostream &output, GroupPtr group)
Output a group to an stream as a graphviz label.
Definition: Graph.h:314
Group * next
Pointer to the next group, when ordered by address.
Definition: Graph.h:273
bool start_else
Group is start of an else block.
Definition: Graph.h:256
bool coalesced_else
Indicates if an starting else coalesces with another block.
Definition: Graph.h:287
ElseEnds end_else
Group is end of an else block.
Definition: Graph.h:261
GraphVertex vertex
Vertex the group belongs to.
Definition: Graph.h:231
Structure representing whether or not an edge is a jump.
Definition: Graph.h:85
friend std::ostream & operator<<(std::ostream &output, IsJump is_jump)
Output edge information as a graphviz edge property.
Definition: Graph.h:113
bool is_jump
Whether or not the edge is a jump.
Definition: Graph.h:90
IsJump()
Parameterless constructor.
Definition: Graph.cpp:20