BRIDGE: initial interface for graphing
This commit is contained in:
parent
d9fc45da86
commit
cfe6e25a0e
|
|
@ -0,0 +1,131 @@
|
|||
#ifndef _GRAPH_H
|
||||
#define _GRAPH_H
|
||||
|
||||
typedef struct
|
||||
{
|
||||
duint parentGraph; //function of which this node is a part
|
||||
duint start; //start of the block
|
||||
duint end; //end of the block (inclusive)
|
||||
duint brtrue; //destination if condition is true
|
||||
duint brfalse; //destination if condition is false
|
||||
duint icount; //number of instructions in node
|
||||
bool terminal; //node is a RET
|
||||
bool split; //node is a split (brtrue points to the next node)
|
||||
void* userdata; //user data
|
||||
ListOf(duint) exits; //exits (including brtrue and brfalse)
|
||||
} BridgeCFNodeList;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
duint entryPoint; //graph entry point
|
||||
void* userdata; //user data
|
||||
ListOf(BridgeCFNodeList) nodes; //graph nodes
|
||||
} BridgeCFGraphList;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
struct BridgeCFNode
|
||||
{
|
||||
duint parentGraph; //function of which this node is a part
|
||||
duint start; //start of the block
|
||||
duint end; //end of the block (inclusive)
|
||||
duint brtrue; //destination if condition is true
|
||||
duint brfalse; //destination if condition is false
|
||||
duint icount; //number of instructions in node
|
||||
bool terminal; //node is a RET
|
||||
bool split; //node is a split (brtrue points to the next node)
|
||||
void* userdata; //user data
|
||||
std::vector<duint> exits; //exits (including brtrue and brfalse)
|
||||
|
||||
explicit BridgeCFNode(BridgeCFNodeList* nodeList)
|
||||
{
|
||||
if(!nodeList || !nodeList->exits || nodeList->exits->size != nodeList->exits->count * sizeof(duint))
|
||||
__debugbreak();
|
||||
parentGraph = nodeList->parentGraph;
|
||||
start = nodeList->start;
|
||||
end = nodeList->end;
|
||||
brtrue = nodeList->brtrue;
|
||||
brfalse = nodeList->brfalse;
|
||||
icount = nodeList->icount;
|
||||
terminal = nodeList->terminal;
|
||||
split = nodeList->split;
|
||||
userdata = nodeList->userdata;
|
||||
auto data = (duint*)nodeList->exits->data;
|
||||
exits.resize(nodeList->exits->count);
|
||||
for(size_t i = 0; i < nodeList->exits->count; i++)
|
||||
exits[i] = data[i];
|
||||
}
|
||||
|
||||
explicit BridgeCFNode(duint parentGraph, duint start, duint end)
|
||||
: parentGraph(parentGraph),
|
||||
start(start),
|
||||
end(end),
|
||||
brtrue(0),
|
||||
brfalse(0),
|
||||
icount(0),
|
||||
terminal(false),
|
||||
split(false),
|
||||
userdata(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
explicit BridgeCFNode()
|
||||
: BridgeCFNode(0, 0, 0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct BridgeCFGraph
|
||||
{
|
||||
duint entryPoint; //graph entry point
|
||||
void* userdata; //user data
|
||||
std::unordered_map<duint, BridgeCFNode> nodes; //CFNode.start -> CFNode
|
||||
std::unordered_map<duint, std::unordered_set<duint>> parents; //CFNode.start -> parents
|
||||
|
||||
explicit BridgeCFGraph(BridgeCFGraphList* graphList)
|
||||
{
|
||||
if(!graphList || !graphList->nodes || graphList->nodes->size != graphList->nodes->count * sizeof(BridgeCFNode))
|
||||
__debugbreak();
|
||||
entryPoint = graphList->entryPoint;
|
||||
userdata = graphList->userdata;
|
||||
auto data = (BridgeCFNode*)graphList->nodes->data;
|
||||
for(size_t i = 0; i < graphList->nodes->count; i++)
|
||||
AddNode(data[i]);
|
||||
}
|
||||
|
||||
explicit BridgeCFGraph(duint entryPoint)
|
||||
: entryPoint(entryPoint),
|
||||
userdata(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void AddNode(const BridgeCFNode & node)
|
||||
{
|
||||
nodes[node.start] = node;
|
||||
AddParent(node.start, node.brtrue);
|
||||
AddParent(node.start, node.brfalse);
|
||||
}
|
||||
|
||||
void AddParent(duint child, duint parent)
|
||||
{
|
||||
if(!child || !parent)
|
||||
return;
|
||||
auto found = parents.find(child);
|
||||
if(found == parents.end())
|
||||
{
|
||||
std::unordered_set<duint> p;
|
||||
p.insert(parent);
|
||||
parents[child] = p;
|
||||
}
|
||||
else
|
||||
found->second.insert(parent);
|
||||
}
|
||||
};
|
||||
|
||||
#endif //__cplusplus
|
||||
|
||||
#endif //_GRAPH_H
|
||||
|
|
@ -1040,6 +1040,7 @@ BRIDGE_IMPEXP void GuiUpdateAllViews()
|
|||
GuiRepaintTableView();
|
||||
GuiUpdateSEHChain();
|
||||
GuiUpdateArgumentWidget();
|
||||
GuiUpdateGraphView();
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiUpdateRegisterView()
|
||||
|
|
@ -1435,6 +1436,22 @@ BRIDGE_IMPEXP void GuiFocusView(int hWindow)
|
|||
_gui_sendmessage(GUI_FOCUS_VIEW, (void*)hWindow, nullptr);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiLoadGraph(BridgeCFGraphList* graph)
|
||||
{
|
||||
_gui_sendmessage(GUI_LOAD_GRAPH, graph, nullptr);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiGraphAt(duint addr)
|
||||
{
|
||||
_gui_sendmessage(GUI_GRAPH_AT, (void*)addr, nullptr);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiUpdateGraphView()
|
||||
{
|
||||
CHECK_GUI_UPDATE_DISABLED
|
||||
_gui_sendmessage(GUI_UPDATE_GRAPH_VIEW, nullptr, nullptr);
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
hInst = hinstDLL;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ typedef unsigned long duint;
|
|||
typedef signed long dsint;
|
||||
#endif //_WIN64
|
||||
|
||||
#include "bridgegraph.h"
|
||||
|
||||
#ifndef BRIDGE_IMPEXP
|
||||
#ifdef BUILD_BRIDGE
|
||||
#define BRIDGE_IMPEXP __declspec(dllexport)
|
||||
|
|
@ -936,7 +938,10 @@ typedef enum
|
|||
GUI_UNREGISTER_SCRIPT_LANG, // param1=int id, param2=unused
|
||||
GUI_UPDATE_ARGUMENT_VIEW, // param1=unused, param2=unused
|
||||
GUI_FOCUS_VIEW, // param1=int hWindow, param2=unused
|
||||
GUI_UPDATE_WATCH_VIEW // param1=unused, param2=unused
|
||||
GUI_UPDATE_WATCH_VIEW, // param1=unused, param2=unused
|
||||
GUI_LOAD_GRAPH, // param1=BridgeCFGraphList* param2=unused
|
||||
GUI_GRAPH_AT, // param1=duint addr param2=unused
|
||||
GUI_UPDATE_GRAPH_VIEW // param1=unused, param2=unused
|
||||
} GUIMSG;
|
||||
|
||||
//GUI Typedefs
|
||||
|
|
@ -1057,6 +1062,9 @@ BRIDGE_IMPEXP void GuiFocusView(int hWindow);
|
|||
BRIDGE_IMPEXP bool GuiIsUpdateDisabled();
|
||||
BRIDGE_IMPEXP void GuiUpdateEnable(bool updateNow);
|
||||
BRIDGE_IMPEXP void GuiUpdateDisable();
|
||||
BRIDGE_IMPEXP void GuiLoadGraph(BridgeCFGraphList* graph);
|
||||
BRIDGE_IMPEXP void GuiGraphAt(duint addr);
|
||||
BRIDGE_IMPEXP void GuiUpdateGraphView();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
<ClCompile Include="_global.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="bridgegraph.h" />
|
||||
<ClInclude Include="bridgemain.h" />
|
||||
<ClInclude Include="bridgelist.h" />
|
||||
<ClInclude Include="Utf8Ini.h" />
|
||||
|
|
|
|||
|
|
@ -31,5 +31,8 @@
|
|||
<ClInclude Include="bridgelist.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="bridgegraph.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Loading…
Reference in New Issue