Add radiff2 -a and -b flags

This commit is contained in:
pancake 2014-03-19 10:33:00 +01:00
parent 44a0774069
commit a727663f98
3 changed files with 27 additions and 5 deletions

View File

@ -70,9 +70,11 @@ static RCore* opencore(const char *f) {
}
static int show_help(int v) {
printf ("Usage: radiff2 [-cCdrspOv] [-g sym] [-t %%] [file] [file]\n");
printf ("Usage: radiff2 [-abcCdrspOv] [-g sym] [-t %%] [file] [file]\n");
if (v) printf (
// " -l diff lines of text\n"
" -a [arch] specify architecture plugin to use (x86, arm, ..)\n"
" -b [bits] specify register size for arch (16 (thumb), 32, 64, ..)\n"
" -c count of changes\n"
" -C graphdiff code (columns: off-A, match-ratio, off-B)\n"
" -d use delta diffing\n"
@ -114,6 +116,8 @@ int main(int argc, char **argv) {
const char *addr = NULL;
RCore *c, *c2;
RDiff *d;
const char *arch = NULL;
int bits = 0;
char *file, *file2;
ut8 *bufa, *bufb;
int o, sza, szb, rad = 0, delta = 0;
@ -122,8 +126,14 @@ int main(int argc, char **argv) {
int threshold = -1;
double sim;
while ((o = getopt (argc, argv, "Cpg:Orhcdsvxt:")) != -1) {
while ((o = getopt (argc, argv, "a:b:Cpg:Orhcdsvxt:")) != -1) {
switch (o) {
case 'a':
arch = optarg;
break;
case 'b':
bits = atoi (optarg);
break;
case 'p':
useva = R_FALSE;
break;
@ -184,6 +194,14 @@ int main(int argc, char **argv) {
eprintf ("Cannot open '%s'\n", file2);
return 1;
}
if (arch) {
r_config_set (c->config, "asm.arch", arch);
r_config_set (c2->config, "asm.arch", arch);
}
if (bits) {
r_config_set_i (c->config, "asm.bits", bits);
r_config_set_i (c2->config, "asm.bits", bits);
}
r_anal_diff_setup_i (c->anal, diffops, threshold, threshold);
r_anal_diff_setup_i (c2->anal, diffops, threshold, threshold);
r_core_gdiff (c, c2);

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2013 - pancake */
/* radare - LGPL - Copyright 2013-2014 - pancake */
#include <r_types.h>
#include <r_util.h>
@ -95,7 +95,7 @@ static RList* entries(RBinFile *arch) {
struct r_bin_plugin_t r_bin_plugin_bios = {
.name = "bios",
.desc = "filesystem bin plugin",
.desc = "BIOS bin plugin",
.license = "LGPL",
.init = NULL,
.fini = NULL,

View File

@ -5,7 +5,7 @@ radiff2 \- unified binary diffing utility
.Pp
.Sh SYNOPSIS
.Nm radiff2
.Op Fl cCOdrspvh
.Op Fl abcCOdrspvh
.Op Fl t Ar 0-100
.Op Fl g Ar sym
.Ar file1
@ -14,6 +14,10 @@ radiff2 \- unified binary diffing utility
radiff2 implements many binary diffing algorithms for data and code.
.Pp
.Bl -tag -width Fl
.It Fl a
Specify architecture (x86, arm, ..)
.It Fl b
Select register size bits for given arch
.It Fl c
Count number of differences.
.It Fl C