Newer
Older
clc5q
committed
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* SMPDBInterface.h - <see below>.
*
* Copyright (c) 2000, 2001, 2010 - University of Virginia
*
* This file is part of the Memory Error Detection System (MEDS) infrastructure.
* This file may be used and modified for non-commercial purposes as long as
* all copyright, permission, and nonwarranty notices are preserved.
* Redistribution is prohibited without prior written consent from the University
* of Virginia.
*
* Please contact the authors for restrictions applying to commercial use.
*
* THIS SOURCE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Author: University of Virginia
* e-mail: jwd@virginia.com
* URL : http://www.cs.virginia.edu/
*
* Additional copyrights 2010, 2011 by Zephyr Software LLC
* e-mail: {clc,jwd}@zephyr-software.com
* URL : http://www.zephyr-software.com/
*
*/
#ifndef SMPDBINTERFACE_H
#define SMPDBINTERFACE_H 1
// SMPDBInterface.h
//
// This header defines the interfaces needed for obtaining program information
// from a disassembler or other program database, e.g. IDA Pro, the UVa IRDB,
// another disassembler, etc.
//
#include <string>
#include <utility>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <cstddef>
#include <pro.h>
#include <ida.hpp>
#include <ua.hpp>
#include <xref.hpp>
#ifndef STARS_IRDB_INTERFACE
#ifndef STARS_IDA_INTERFACE
#warning No INTERFACE symbol defined: defaulting to STARS_IDA_INTERFACE
#define STARS_IDA_INTERFACE
#endif
#endif
#ifdef STARS_IDA_INTERFACE
#ifdef STARS_IRDB_INTERFACE
#error Cannot define both STARS_IDA_INTERFACE and STARS_IRDB_INTERFACE
#endif
#else
#ifndef STARS_IRDB_INTERFACE
#error Must define either STARS_IDA_INTERFACE or STARS_IRDB_INTERFACE
#endif
#endif
bool SMPGetCmd(ea_t InstAddr, insn_t &SMPcmd, ulong &SMPfeatures);
// Need instruction xref info from IRDB
// Need redefinitions for:
// Need to deal with shared chunks
#ifdef STARS_IDA_INTERFACE
typedef ea_t STARS_ea_t;
#include <interfaces/idapro/all.h>
clc5q
committed
// Globals, typedefs and macros for STARS_IDA_INTERFACE only
#define SMP_getseg(addr) (global_stars_interface->getseg(addr))
#define SMP_getnseg(index) (global_stars_interface->getnseg(index))
#define SMP_get_segm_qty() (global_stars_interface->get_segm_qty())
#define SMP_get_first_seg() (SMP_getnseg(0)) /* get the first segment a diff way */
#define SMP_get_next_seg(addr) (global_stars_interface->get_next_seg(addr))
#define SMP_get_segm_name(seg, name, size) (seg->GetSegmentName(name, size))
#define SMP_get_func_qty() (global_stars_interface->get_func_qty())
#define SMP_getn_func(index) (global_stars_interface->getn_func(index))
#define SMP_get_func(addr) (global_stars_interface->get_func(addr))
#define SMP_get_func_name(addr, NameBuf, NameBufSize) (global_stars_interface->get_func_name(addr,NameBuf,NameBufSize))
#define SMP_get_spd(ptr_to_func, ea) (ptr_to_func->get_spd(ea))
#define SMP_AuditTailChunkOwnership() (global_stars_interface->AuditTailChunkOwnership())
clc5q
committed
#define SMP_get_item_end(addr) get_item_end(addr)
#define SMP_getFlags(addr) getFlags(addr)
#define SMP_msg(...) msg(__VA_ARGS__)
#define SMP_strncat(str1, str2, len) qstrncat(str1, str2, len)
#define SMP_strncpy(str1, str2, len) qstrncpy(str1, str2, len)
#define SMP_snprintf(...) qsnprintf(__VA_ARGS__)
#define SMP_fprintf(...) qfprintf(__VA_ARGS__)
clc5q
committed
#define SMP_fopen(name, mode) qfopen(name, mode)
#define SMP_feof(file) feof(file)
#define SMP_fclose(file) qfclose(file)
#define SMP_get_true_name(from, ea, buf, bufsize) get_true_name(from, ea, buf, bufsize)
#define SMP_next_head(ea, maxea) next_head(ea, maxea)
#define SMP_get_flags_novalue(ea) get_flags_novalue(ea)
#define SMP_get_frame(ptr_to_func_t) get_frame((func_t*)*dynamic_cast<STARS_IDA_Function_t*>(ptr_to_func_t))
#define SMP_get_member_name(mid, buf, bufsize) get_member_name(mid, buf, bufsize)
#define SMP_get_item_end(addr) get_item_end(addr)
#define SMP_getFlags(addr) getFlags(addr)
#define SMP_isHead(flags) isHead(flags)
#define SMP_isCode(flags) isCode(flags)
#define SMP_add_cref(from, to, type) add_cref(from, to, type)
#define SMP_generate_disasm_line(InstAddr, CharArray, CharArrayLimit) generate_disasm_line(InstAddr, CharArray, CharArrayLimit)
#define SMP_tag_remove(InBuf, OutBuf, OutBufSize) tag_remove(InBuf, OutBuf, OutBufSize)
clc5q
committed
struct SMP_xref_t {
xrefblk_t CurrSMP_xref;
clc5q
committed
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
ea_t GetFrom() { return CurrSMP_xref.from; };
ea_t GetTo() { return CurrSMP_xref.to; };
uchar GetIscode() { return CurrSMP_xref.iscode; }; // 1-is code reference; 0-is data reference
uchar GetType() { return CurrSMP_xref.type; }; // type of the last retured reference (cref_t & dref_t)
uchar GetUser() { return CurrSMP_xref.user; }; // 1-is used defined xref, 0-defined by ida
bool SMP_first_from(ea_t from, int flags) // get first reference from...
{ return xrefblk_t_first_from(&CurrSMP_xref, from, flags); }
bool SMP_next_from(void) // get next reference from...
{ return xrefblk_t_next_from(&CurrSMP_xref); }
bool SMP_first_to(ea_t to, int flags) // get first reference to...
{ return xrefblk_t_first_to(&CurrSMP_xref, to, flags); }
bool SMP_next_to(void) // get next reference to....
{ return xrefblk_t_next_to(&CurrSMP_xref); }
};
#else
// Globals, typedefs and macros for STARS_IRDB_INTERFACE only
#define SMP_strncat(str1, str2, len) strncat(str1, str2, len)
#define SMP_strncpy(str1, str2, len) strncpy(str1, str2, len)
#define SMP_snprintf(...) snprintf(__VA_ARGS__)
#define SMP_fprintf(...) fprintf(__VA_ARGS__)
#define SMP_fopen(name, mode) fopen(name, mode)
#define SMP_feof(file) feof(file)
#define SMP_fclose(file) fclose(file)
extern FILE *SMPLogFile;
#define SMP_msg(...) fprintf(SMPLogFile, __VA_ARGS__)
#endif
#endif