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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* 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
// Globals, typedefs and macros for STARS_IDA_INTERFACE only
#define SMP_getseg(addr) getseg(addr)
#define SMP_getnseg(index) getnseg(index)
#define SMP_get_segm_qty() get_segm_qty()
#define SMP_get_first_seg() get_first_seg()
#define SMP_get_next_seg(addr) get_next_seg(addr)
#define SMP_get_segm_name(seg, name, size) get_segm_name(seg, name, size)
#define SMP_get_func_qty() get_func_qty()
#define SMP_getn_func(index) getn_func(index)
#define SMP_get_func(addr) get_func(addr)
#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__)
#define SMP_fopen(name, mode) qfopen(name, mode)
#define SMP_feof(file) feof(file)
#define SMP_fclose(file) qfclose(file)
struct SMP_xref_t {
xrefblk_t CurrSMP_xref;
clc5q
committed
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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