Welcome to the Hex-Rays Decompiler SDK!
---------------------------------------
We are happy to present you the programmatic API for the decompiler.
This version gives you an idea of the overall SDK structure and
provides a base to build on. Currently only the decompilation results
and the user interface are accessible, later we will add low level
stuff and make the decompiler portable. Today you can:
- decompile a function and get a ctree.
A ctree is a data structure that represents the decompilation result.
- modify the ctree the way you want. You can rearrange
statements, optimize expressions, add or remove variables, etc.
- add a new item to the popup menu, react to user actions like
keyboard, mouse clicks, etc.
- hook to the decompilation events and modify the decompilation result
on the fly.
You will need the latest IDA SDK to compile the plugins. The
decompiler SDK consists of one single file: include\hexrays.hpp To
install the decompiler SDK, just copy this file to the include
directory of the IDA SDK.
There is no .lib file. You will compile and link plugins for the
decompiler the same way as plugins for IDA. For a quick start, please
copy the sample plugins to the plugins subdirectory of the SDK and
compile them. We tested the SDK with two compilers: Visual Studio and
Borland but other compilers should work too.
We will not guarantee backward compatibility at the early stages but
as soon as things settle down, we will switch to that mode.
There are 7 sample plugins. Below are their descriptions.
Sample 1
--------
This plugin decompiles the current function and prints the result in
the message window. It is useful to learn how to initialize a
decompiler plugin. Please note that all decompiler sample plugins
have the "hexrays_" prefix in their names. This is done to make sure
that the decompiler plugins are loaded after the hexrays plugin.
Otherwise they would see that the decompiler is missing and
immediately terminate.
We recommend you to keep the same naming scheme: please use the
"hexrays_" prefix for your decompiler plugins.
NB: if you're writing a plugin for non-x86 version of the decompiler,
you should use another prefix. For example, the x64 decompiler is
named "hexx64", ARM is "hexarm" and so on. To be certain, check IDA's
"plugins" directory. To debug plugin loading issues, you can use -z20
switch when running IDA.
Sample 2
--------
This plugin shows how to hook to decompiler events and react to
them. It also shows how to visit all ctree elements and modify them.
This plugin waits for the decompilation result to be ready and
replaces zeroes in pointer contexts with NULLs. One might say that
this is just cosmetic change, but it makes the output more readable.
Since the plugin hooks to events, it is fully automatic. The user
can disable it by selecting it from the Edit, Plugins menu.
Sample 3
--------
This plugin shows
- how to add a new popup menu item
- how to map the cursor position to ctree element
- how to modify ctree
- how to make the changes persistent
This is a quite complex plugin but it is thoroughly commented.
Sample 4
--------
This plugin dumps all user-defined information to the message window.
Read the source code to learn how to access various user-defined
data from your plugins:
- label names
- indented comments
- number formats
- local variable names, types, comments
Sample 5
--------
This plugin generates a graph from the current pseudocode
and displays it with wingraph32.
The source code can be used to learn ctree details.
Sample 6
--------
This plugin modifies the decompilation output: removes some space characters.
The source code can be used to learn the output text.
Sample 7
--------
This plugin demonstrates how to use the cblock_t::iterator class.
It enumerates all instructions of a block statement.
Sample 8
--------
This plugin demonstrates how to use the udc_filter_t
(User-Defined Call generator) class, which allows replacing
cryptic function calls, with a simpler/more-readable counterpart.
It is also possible to write decompiler plugins or scripts in Python.
See the "python" subdirectory for some samples.
Enjoy the SDK!
Hex-Rays
------------------------------------------------------------------
Annex: a brief description of ctree
Ctree is a data structure that keeps the decompilation result. As the name
implies, it is a tree-like structure. At the top level, we have the cfunc_t class.
This class describes the function and gives access to its attributes: its type,
local variables, maturity level, and body.
The ctree class is not created in one transaction but built
progressively: it starts with an empty class, then a rough function
body is created, then it is modified in several steps. You can
intercept control at any intermediate stage (maturity level) but be
prepared that the ctree does not look quite normal. Only at the final
stage the ctree is syntactically correct and has non-trivial type
information.
The most interesting part of the cfunc_t class is the function body
(this part of the data structure is called ctree). The function body
consists of citem_t elements. In fact, citem_t is an abstract class
and its pure instances must never be created. There are two citem_t
flavors (derived classes):
- cinsn_t: a statement
- cexpr_t: an expression
Please look up the class definitions in the header file. citem_t elements
can be reference each other. For example "x+y*3" is represented as:
cot_add
/ \
/ \
cot_var:x cot_mul
/ \
/ \
cot_var:y cot_num:3
This is a very simplified diagram but hopefully it gives an idea how
the tree is organized.
Each ctree item may have a label. Each ctree item is mapped to an
address in the program. Please note that in some cases several items
may have the same address. If we want to denote a citem_t, we can not
store a pointer to it because at the next moment (as soon as we yield
control) another plugin or the decompiler itself might shuffle the
tree. We recommend to denote ctree items by their addresses and types.
Addresses can be safely stored in the database (in fact, it is better
to store offsets from the function entry point; this will make the
information relocatable) and reused in subsequent IDA sessions.
Expressions (cexpr_t) have a type string attached to them. By type
here we mean a C language type (int, char *, etc). The expression
types must be consistent. For example, if in the above example "x" is
a pointer, then the type of the whole expression must be the same
pointer. y can not be a pointer because it is an operand of the
multiplication operation.
To facilitate ctree processing, you can use the ctree_visitor_t class
or any of its derived classes. These classes make ctree traversal
really easy. However, if ctree gets modified during the traversal,
some precautions must be taken. For example, if a parent of the
currently visited item is modified, the traversal must be stopped. See
the sample plugins for a real use of these classes.
You are free to modify the ctree the way you want but you must keep
some rules in mind:
- ctree must be consistent. For example, cot_add (the addition
operator) requires 2 operands. You must not create a cot_add
item with another number of operands.
- expression types (like char*, int, etc) must be consistent. If you
modify an expression and change its type, then the types of all parent
expressions must be recalculated. You can use the recalc_parent_types()
function to that. If this function returns true, then the
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Idapro 7.0 (1001个子文件)
android_server 576KB
android_server64 1.19MB
android_server_nonpie 560KB
android_x64_server 1.22MB
android_x86_server 899KB
armlinux_server 725KB
armuclinux_server 952KB
idacolor.cf 218B
78k0.cfg 2.73MB
c166.cfg 1.83MB
pic14.cfg 1.28MB
78k0s.cfg 1.23MB
6812.cfg 1.2MB
6808.cfg 1.19MB
m32r.cfg 1.16MB
6811.cfg 1.01MB
6805.cfg 1.01MB
clsid.cfg 1016KB
st7.cfg 909KB
avr.cfg 783KB
st10.cfg 782KB
c166v2.cfg 732KB
tricore.cfg 694KB
i51.cfg 475KB
f2mc16lx.cfg 389KB
sh3.cfg 313KB
m7700.cfg 305KB
m7900.cfg 293KB
c166v1.cfg 194KB
f2mc16l.cfg 178KB
super10.cfg 112KB
pic12.cfg 98KB
hcs12.cfg 79KB
ida.cfg 66KB
atrap.cfg 65KB
idagui.cfg 58KB
hcs12x.cfg 45KB
ppc.cfg 43KB
m16c60.cfg 41KB
m65816.cfg 34KB
i960.cfg 21KB
xbe.cfg 19KB
idatui.cfg 19KB
pic16.cfg 16KB
hpux.cfg 15KB
exceptions.cfg 12KB
h8.cfg 12KB
tlcs900.cfg 11KB
c39.cfg 11KB
fr.cfg 10KB
hexrays.cfg 10KB
dwarf.cfg 10KB
cr16.cfg 9KB
z180.cfg 9KB
6816.cfg 9KB
tms320c3.cfg 9KB
psx.cfg 8KB
m740.cfg 6KB
dsp563xx.cfg 5KB
dbg_gdb.cfg 5KB
tms320c54.cfg 5KB
gdb_arch.cfg 5KB
alpha.cfg 4KB
z8.cfg 4KB
plugins.cfg 4KB
dbg_ios.cfg 3KB
mn102l00.cfg 3KB
dbg_bochs.cfg 2KB
dsp561xx.cfg 2KB
autoload.cfg 2KB
noret.cfg 2KB
spc700.cfg 2KB
dsp56k.cfg 2KB
dsp566xx.cfg 2KB
ad218x.cfg 1KB
objc.cfg 1KB
dbg_dalvik.cfg 1KB
bochsrc.cfg 1KB
dbg_pin.cfg 1KB
pdb.cfg 1015B
python.cfg 575B
oakdsp.cfg 571B
tms320c55.cfg 543B
tms32028.cfg 463B
autoload.cfg 405B
dbg_windbg.cfg 373B
kr1878.cfg 340B
autoload.cfg 302B
macho.cfg 235B
n64.cfg 219B
pe.cfg 128B
dbg_wince.cfg 111B
st20.cfg 108B
st9.cfg 71B
idahelp.chm 580KB
Baltic.clt 784B
Latin_1.clt 433B
Turkish.clt 382B
Japanese.clt 374B
Vietnam.clt 349B
共 1001 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
资源评论
梦zh
- 粉丝: 3
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功