Mercurial > hg > dmlib
annotate tools/fanalyze.c @ 2268:f2ff364065eb
Add constant define for maximum number of variants.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 17 Jun 2019 10:26:47 +0300 |
parents | 3739e2ac8bb1 |
children | f350c7514785 |
rev | line source |
---|---|
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
2234 | 2 * Fanalyze - Commandline tool for analyzing similarities between multiple files |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * Programmed and designed by Matti 'ccr' Hamalainen |
2232
ba639902d57c
Bump copyright and version.
Matti Hamalainen <ccr@tnsp.org>
parents:
2229
diff
changeset
|
4 * (C) Copyright 2018-2019 Tecnic Software productions (TNSP) |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 * Please read file 'COPYING' for information on license and distribution. |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 */ |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 #include "dmtool.h" |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 #include "dmlib.h" |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 #include "dmargs.h" |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 #include "dmfile.h" |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
13 #define SET_MAX_FILES 64 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
14 #define SET_MAX_ELEMS 256 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
15 #define SET_MAX_VALUES 64 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
16 #define SET_MAX_GREPLIST 64 |
2268
f2ff364065eb
Add constant define for maximum number of variants.
Matti Hamalainen <ccr@tnsp.org>
parents:
2267
diff
changeset
|
17 #define SET_MAX_VARIANTS 4 |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
18 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
19 #define SET_MAX_SEQUENCES 1024 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
20 #define SET_MAX_PLACES 1024 |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 /* Typedefs |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 */ |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 typedef struct |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 { |
1996 | 27 Uint8 stats[SET_MAX_ELEMS]; |
28 Uint8 variants, data; | |
2268
f2ff364065eb
Add constant define for maximum number of variants.
Matti Hamalainen <ccr@tnsp.org>
parents:
2267
diff
changeset
|
29 int interest[SET_MAX_VARIANTS]; |
f2ff364065eb
Add constant define for maximum number of variants.
Matti Hamalainen <ccr@tnsp.org>
parents:
2267
diff
changeset
|
30 int interestF[SET_MAX_VARIANTS]; |
1996 | 31 } DMCompElem; |
32 | |
33 | |
34 typedef struct | |
35 { | |
36 int count; | |
37 Uint8 value; | |
38 } DMStatValue; | |
39 | |
40 | |
41 typedef struct | |
42 { | |
43 DMStatValue cv[SET_MAX_ELEMS]; | |
44 } DMStats; | |
45 | |
46 | |
47 typedef struct | |
48 { | |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 char *filename; |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 Uint8 *data; |
2249 | 51 size_t size; |
1996 | 52 DMStats stats; |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
53 BOOL analyzed; |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 } DMSourceFile; |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
57 typedef struct |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
58 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
59 DMSourceFile *file; // pointer to file struct where match was found |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
60 size_t offs; // offset to match in file data |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
61 } DMMatchPlace; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
62 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
63 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
64 typedef struct |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
65 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
66 size_t len; // length of the matching sequence |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
67 Uint8 *data; // "const" pointer to data in one file, don't free() |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
68 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
69 int nfiles; // number of separate files match was found |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
70 int nplaces; // number of places where match was found |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
71 DMMatchPlace places[SET_MAX_PLACES]; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
72 } DMMatchSeq; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
73 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
74 |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
75 enum |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
76 { |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
77 DMGV_UINT8 = 0, |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
78 DMGV_UINT16_LE, |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
79 DMGV_UINT16_BE, |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
80 DMGV_UINT32_LE, |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
81 DMGV_UINT32_BE, |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
82 |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
83 DMGV_last |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
84 }; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
85 |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
86 |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
87 enum |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
88 { |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
89 DMGS_HEX = 0, |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
90 DMGS_DEC, |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
91 DMGS_last |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
92 }; |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
93 |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
94 |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
95 typedef struct |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
96 { |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
97 int type; |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
98 int disp; |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
99 int nvalues; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
100 Uint32 values[SET_MAX_GREPLIST]; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
101 BOOL vwildcards[SET_MAX_GREPLIST]; |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
102 } DMGrepValue; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
103 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
104 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
105 typedef struct |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
106 { |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
107 char *name; |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
108 Uint32 nmax; |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
109 unsigned int bsize; |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
110 } DMGrepType; |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
111 |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
112 |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
113 static const DMGrepType dmGrepTypes[DMGV_last] = |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
114 { |
2040
3a7ce77c7f2d
Fix integer overflows vs. shifts.
Matti Hamalainen <ccr@tnsp.org>
parents:
2035
diff
changeset
|
115 { "8bit (byte)" , (1ULL << 8) - 1, 1 }, |
3a7ce77c7f2d
Fix integer overflows vs. shifts.
Matti Hamalainen <ccr@tnsp.org>
parents:
2035
diff
changeset
|
116 { "16bit (word) LE" , (1ULL << 16) - 1, 2 }, |
3a7ce77c7f2d
Fix integer overflows vs. shifts.
Matti Hamalainen <ccr@tnsp.org>
parents:
2035
diff
changeset
|
117 { "16bit (word) BE" , (1ULL << 16) - 1, 2 }, |
3a7ce77c7f2d
Fix integer overflows vs. shifts.
Matti Hamalainen <ccr@tnsp.org>
parents:
2035
diff
changeset
|
118 { "32bit (word) LE" , (1ULL << 32) - 1, 4 }, |
3a7ce77c7f2d
Fix integer overflows vs. shifts.
Matti Hamalainen <ccr@tnsp.org>
parents:
2035
diff
changeset
|
119 { "32bit (word) BE" , (1ULL << 32) - 1, 4 }, |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
120 }; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
121 |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
122 |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
123 typedef struct |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
124 { |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
125 char *name; |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
126 char *fmtPrefix; |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
127 char *fmt; |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
128 } DMGrepDisp; |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
129 |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
130 |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
131 static const DMGrepDisp dmGrepDisp[DMGS_last] = |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
132 { |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
133 { "hex", "0", "x" }, |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
134 { "dec", "" , "d" }, |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
135 }; |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
136 |
2249 | 137 |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
138 enum |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
139 { |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
140 FA_ANALYZE, |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
141 FA_GREP, |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
142 FA_OFFSET, |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
143 FA_MATCHES, |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
144 }; |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
145 |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
146 |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
147 /* Global variables |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
148 */ |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
149 int setMode = FA_ANALYZE; |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
150 int nsrcFiles = 0; // Number of source files |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
151 DMSourceFile srcFiles[SET_MAX_FILES]; // Source file names |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
152 DMStats totalStats; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
153 int nsetGrepValues = 0; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
154 DMGrepValue setGrepValues[SET_MAX_VALUES]; |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
155 size_t optMinMatchLen = 8; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
156 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
157 DMMatchSeq dmSequences[SET_MAX_SEQUENCES]; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
158 int ndmSequences = 0; |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
159 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 /* Arguments |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
162 */ |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
163 static const DMOptArg optList[] = |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
164 { |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
165 { 0, '?', "help", "Show this help", OPT_NONE }, |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 { 1, 'v', "verbose", "Be more verbose", OPT_NONE }, |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
167 { 2, 'g', "grep", "Binary grep <val>[,<val2>...][:<le|be>[8|16|32]]", OPT_ARGREQ }, |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
168 { 3, 'o', "offset", "Show data in offset <offs>[,<offs2>...][:<le|be>[8|16|32][d|x]]", OPT_ARGREQ }, |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
169 { 4, 'm', "match", "Find matching sequences minimum of <n> bytes long", OPT_NONE }, |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
170 { 5, 'n', "minmatch", "Minimum match sequence length", OPT_ARGREQ }, |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
171 }; |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
172 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
173 static const int optListN = sizeof(optList) / sizeof(optList[0]); |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
174 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
175 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
176 void argShowHelp() |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
177 { |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
178 dmPrintBanner(stdout, dmProgName, "[options] <input file #1> <input file #2> [...]"); |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
179 dmArgsPrintHelp(stdout, optList, optListN, 0); |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
180 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
181 fprintf(stdout, |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
182 "\n" |
2234 | 183 "Fanalyze is a simplistic commandline tool to assist analysis of similarities\n" |
184 "between multiple files of same format (but different content). It provides\n" | |
185 "automatic analysis (default operating mode), binary grep functionality (-g)\n" | |
186 "and offset data display (-o)\n" | |
187 "\n" | |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
188 "Value lists for grep function can contain wildcard '?' (or '#') which\n" |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
189 "matches any value of the specified (or inferred) type. For example:\n" |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
190 "-g 0x0f,7,5,?,5,?,? will match sequence of bytes 0f 07 05 ?? 05 ?? ??\n" |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
191 "and -g 0xe,0x1001,?,2023:le16 will match le16 value 000e 1001 ???? 07e7\n" |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
192 "\n" |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
193 "NOTICE! Matching sequences search (-m) is considered unfinished and\n" |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
194 "under development.\n" |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
195 ); |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
196 } |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
197 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
198 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
199 BOOL dmGetData(const int type, const DMSourceFile *file, const size_t offs, Uint32 *mval) |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
200 { |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
201 Uint8 *data = file->data + offs; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
202 if (offs + dmGrepTypes[type].bsize >= file->size) |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
203 { |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
204 *mval = 0; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
205 return FALSE; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
206 } |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
207 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
208 switch (type) |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
209 { |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
210 case DMGV_UINT8: |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
211 *mval = *((Uint8 *) data); |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
212 break; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
213 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
214 case DMGV_UINT16_LE: |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
215 *mval = DM_LE16_TO_NATIVE(*((Uint16 *) data)); |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
216 break; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
217 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
218 case DMGV_UINT16_BE: |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
219 *mval = DM_BE16_TO_NATIVE(*((Uint16 *) data)); |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
220 break; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
221 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
222 case DMGV_UINT32_LE: |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
223 *mval = DM_LE32_TO_NATIVE(*((Uint32 *) data)); |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
224 break; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
225 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
226 case DMGV_UINT32_BE: |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
227 *mval = DM_BE32_TO_NATIVE(*((Uint32 *) data)); |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
228 break; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
229 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
230 default: |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
231 *mval = 0; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
232 return FALSE; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
233 } |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
234 return TRUE; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
235 } |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
236 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
237 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
238 void dmPrintGrepValueList(const DMGrepValue *node, const BOOL match, DMSourceFile *file, const size_t offs) |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
239 { |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
240 char mfmt[16]; |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
241 |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
242 snprintf(mfmt, sizeof(mfmt), "%%%s%d%s%%s", |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
243 dmGrepDisp[node->disp].fmtPrefix, |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
244 dmGrepTypes[node->type].bsize * 2, |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
245 dmGrepDisp[node->disp].fmt); |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
246 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
247 for (int n = 0; n < node->nvalues; n++) |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
248 { |
2248 | 249 const char *veol = (n + 1 < node->nvalues) ? " " : "\n"; |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
250 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
251 if (match) |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
252 { |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
253 Uint32 mval; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
254 dmGetData(node->type, file, offs + n, &mval); |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
255 dmPrint(1, mfmt, mval, veol); |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
256 } |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
257 else |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
258 { |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
259 if (node->vwildcards[n]) |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
260 dmPrint(1, "?%s", veol); |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
261 else |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
262 dmPrint(1, mfmt, node->values[n], veol); |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
263 } |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
264 } |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
265 } |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
266 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
267 |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
268 int argParseGrepValue(const char *arg, const int mode) |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
269 { |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
270 const char *specsep = strchr(arg, ':'); |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
271 char *vspec, *vstr, *vsep; |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
272 DMGrepValue val; |
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
273 int ret = DMERR_OK; |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
274 BOOL more; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
275 |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
276 memset(&val, 0, sizeof(val)); |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
277 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
278 if (setMode != FA_ANALYZE && setMode != mode) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
279 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
280 dmErrorMsg("Options specifying multiple operating modes can't be used.\n"); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
281 return DMERR_INVALID_ARGS; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
282 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
283 setMode = mode; |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
284 |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
285 // Do we have spec? |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
286 if (specsep != NULL) |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
287 { |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
288 vspec = dm_strdup_trim(specsep + 1, DM_TRIM_BOTH); |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
289 vstr = dm_strndup_trim(arg, specsep - arg, DM_TRIM_BOTH); |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
290 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
291 else |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
292 { |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
293 vspec = NULL; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
294 vstr = dm_strdup(arg); |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
295 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
296 |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
297 // Parse spec if any |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
298 if (vspec != NULL) |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
299 { |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
300 BOOL vendianess = TRUE; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
301 char *vtmp = vspec; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
302 |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
303 // Get endianess specifier, if any |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
304 if (dm_strncasecmp(vtmp, "le", 2) == 0) |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
305 { |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
306 vendianess = TRUE; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
307 vtmp += 2; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
308 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
309 else |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
310 if (dm_strncasecmp(vtmp, "be", 2) == 0) |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
311 { |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
312 vendianess = FALSE; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
313 vtmp += 2; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
314 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
315 |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
316 // Get value bit size |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
317 if (strncmp(vtmp, "8", 1) == 0) |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
318 { |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
319 val.type = DMGV_UINT8; |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
320 vtmp += 1; |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
321 } |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
322 else |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
323 if (strncmp(vtmp, "16", 2) == 0) |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
324 { |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
325 val.type = vendianess ? DMGV_UINT16_LE : DMGV_UINT16_BE; |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
326 vtmp += 2; |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
327 } |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
328 else |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
329 if (strncmp(vtmp, "32", 2) == 0) |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
330 { |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
331 val.type = vendianess ? DMGV_UINT32_LE : DMGV_UINT32_BE; |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
332 vtmp += 2; |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
333 } |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
334 else |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
335 { |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
336 ret = dmError(DMERR_INVALID_ARGS, |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
337 "Invalid grep type '%s'.\n", |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
338 vspec); |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
339 goto out; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
340 } |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
341 |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
342 switch (tolower(*vtmp)) |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
343 { |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
344 case 'd': |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
345 val.disp = DMGS_DEC; |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
346 break; |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
347 |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
348 case 'x': case 'h': |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
349 val.disp = DMGS_HEX; |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
350 break; |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
351 |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
352 case 0: |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
353 break; |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
354 |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
355 default: |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
356 ret = dmError(DMERR_INVALID_ARGS, |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
357 "Invalid grep view type '%s'.\n", |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
358 vspec); |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
359 goto out; |
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
360 } |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
361 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
362 |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
363 // Get list of values |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
364 char *vtmp = vstr; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
365 do |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
366 { |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
367 if (val.nvalues >= SET_MAX_GREPLIST) |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
368 { |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
369 ret = dmError(DMERR_BOUNDS, |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
370 "Too many greplist values specified '%s'.\n", |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
371 vstr); |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
372 goto out; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
373 } |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
374 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
375 if ((vsep = strchr(vtmp, ',')) != NULL) |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
376 { |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
377 *vsep = 0; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
378 more = TRUE; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
379 } |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
380 else |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
381 more = FALSE; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
382 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
383 if (vtmp[0] == '#' || vtmp[0] == '?') |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
384 { |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
385 val.vwildcards[val.nvalues] = TRUE; |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
386 if (mode == FA_OFFSET) |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
387 { |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
388 ret = dmError(DMERR_INVALID_ARGS, |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
389 "Offset mode does not allow wildcard values.\n"); |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
390 goto out; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
391 } |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
392 } |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
393 else |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
394 if (!dmGetIntVal(vtmp, &val.values[val.nvalues], NULL)) |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
395 { |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
396 ret = dmError(DMERR_INVALID_ARGS, |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
397 "Not a valid integer value '%s'.\n", |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
398 vtmp); |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
399 goto out; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
400 } |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
401 |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
402 val.nvalues++; |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
403 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
404 if (more) |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
405 vtmp = vsep + 1; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
406 } while (more); |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
407 |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
408 if (val.vwildcards[0]) |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
409 { |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
410 ret = dmError(DMERR_INVALID_ARGS, |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
411 "First grep value can not be a wildcard.\n"); |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
412 goto out; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
413 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
414 |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
415 if (mode == FA_GREP) |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
416 { |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
417 // Check if we need to guess size |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
418 if (val.type < 0) |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
419 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
420 for (int n = DMGV_last; n >= 0; n--) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
421 { |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
422 const DMGrepType *def = &dmGrepTypes[n]; |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
423 if (val.values[0] <= def->nmax) |
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
424 val.type = n; |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
425 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
426 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
427 |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
428 if (val.type < 0) |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
429 { |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
430 ret = dmError(DMERR_INVALID_ARGS, |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
431 "Could not guess value type for '%s'.\n", |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
432 arg); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
433 goto out; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
434 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
435 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
436 // Check range |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
437 for (int n = 0; n < val.nvalues; n++) |
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
438 if (!val.vwildcards[n] && val.values[n] > dmGrepTypes[val.type].nmax) |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
439 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
440 ret = dmError(DMERR_INVALID_ARGS, |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
441 "Integer value %d <= %d <= %d out of range for type %s.\n", |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
442 val.values[n], 0, dmGrepTypes[val.type].nmax, |
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
443 dmGrepTypes[val.type].name); |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
444 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
445 goto out; |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
446 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
447 } |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
448 else |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
449 if (mode == FA_OFFSET) |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
450 { |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
451 if (val.type < 0) |
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
452 val.type = DMGV_UINT8; |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
453 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
454 |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
455 if (nsetGrepValues < SET_MAX_VALUES) |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
456 { |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
457 DMGrepValue *node = &setGrepValues[nsetGrepValues++]; |
2228
02d17784fdef
Variables -> struct cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
2225
diff
changeset
|
458 memcpy(node, &val, sizeof(val)); |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
459 |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
460 if (mode == FA_GREP) |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
461 { |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
462 dmPrint(1, "Grep %s: ", |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
463 dmGrepTypes[val.type].name); |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
464 |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
465 dmPrintGrepValueList(node, FALSE, NULL, 0); |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
466 } |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
467 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
468 else |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
469 { |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
470 ret = dmError(DMERR_BOUNDS, |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
471 "Too many values specified (max %d).", |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
472 SET_MAX_VALUES); |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
473 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
474 |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
475 out: |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
476 dmFree(vspec); |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
477 dmFree(vstr); |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
478 return ret; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
479 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
480 |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
481 |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
482 BOOL argHandleOpt(const int optN, char *optArg, char *currArg) |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
483 { |
1995
ea6337c873c6
Silence an unused function argument warning.
Matti Hamalainen <ccr@tnsp.org>
parents:
1685
diff
changeset
|
484 (void) optArg; |
ea6337c873c6
Silence an unused function argument warning.
Matti Hamalainen <ccr@tnsp.org>
parents:
1685
diff
changeset
|
485 |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
486 switch (optN) |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
487 { |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
488 case 0: |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
489 argShowHelp(); |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
490 exit(0); |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
491 break; |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
492 |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
493 case 1: |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
494 dmVerbosity++; |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
495 break; |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
496 |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
497 case 2: |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
498 return argParseGrepValue(optArg, FA_GREP) == DMERR_OK; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
499 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
500 case 3: |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
501 return argParseGrepValue(optArg, FA_OFFSET) == DMERR_OK; |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
502 |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
503 case 4: |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
504 setMode = FA_MATCHES; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
505 break; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
506 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
507 case 5: |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
508 optMinMatchLen = atoi(optArg); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
509 if (optMinMatchLen < 2 || optMinMatchLen > 16*1024) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
510 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
511 dmErrorMsg("Invalid minimum match length '%s'.\n", |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
512 optArg); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
513 return FALSE; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
514 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
515 return TRUE; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
516 |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
517 default: |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
518 dmErrorMsg("Unknown argument '%s'.\n", currArg); |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
519 return FALSE; |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
520 } |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
521 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
522 return TRUE; |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
523 } |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
524 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
525 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
526 BOOL argHandleNonOpt(char *currArg) |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
527 { |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
528 if (nsrcFiles < SET_MAX_FILES) |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
529 { |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
530 DMSourceFile *file = &srcFiles[nsrcFiles++]; |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
531 file->filename = currArg; |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
532 return TRUE; |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
533 } |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
534 else |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
535 { |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
536 dmErrorMsg("Maximum number of input files exceeded (%d).\n", |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
537 SET_MAX_FILES); |
1996 | 538 return TRUE; |
539 } | |
540 } | |
541 | |
542 | |
543 void dmInitStats(DMStats *stats) | |
544 { | |
545 for (size_t n = 0; n < SET_MAX_ELEMS; n++) | |
546 { | |
547 stats->cv[n].count = 0; | |
548 stats->cv[n].value = n; | |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
549 } |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
550 } |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
551 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
552 |
1996 | 553 int dmCompareStatFunc(const void *va, const void *vb) |
554 { | |
555 const DMStatValue *pa = va, *pb = vb; | |
556 return pb->count - pa->count; | |
557 } | |
558 | |
559 | |
560 void dmPrintStats(DMStats *stats, const int nmax, const size_t size) | |
561 { | |
2011 | 562 qsort(&stats->cv, SET_MAX_ELEMS, sizeof(DMStatValue), dmCompareStatFunc); |
563 | |
1996 | 564 for (int n = 0; n < nmax; n++) |
565 { | |
2011 | 566 printf("$%02x (%d = %1.2f%%), ", |
1996 | 567 stats->cv[n].value, |
2011 | 568 stats->cv[n].count, |
1996 | 569 ((float) stats->cv[n].count * 100.0f) / (float) size); |
570 } | |
571 printf("\n\n"); | |
572 } | |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
573 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
574 |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
575 void dmAddMatchSequence(Uint8 *data, const size_t len, DMSourceFile *file, size_t offs) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
576 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
577 DMMatchSeq *seq = NULL; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
578 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
579 // Check for existing match sequence |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
580 for (int n = 0; n < ndmSequences; n++) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
581 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
582 DMMatchSeq *node = &dmSequences[n]; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
583 if (node->len == len && |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
584 (node->data == data || |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
585 memcmp(node->data, data, node->len) == 0)) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
586 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
587 seq = node; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
588 break; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
589 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
590 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
591 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
592 if (seq == NULL) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
593 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
594 // No sequence found, add a new one |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
595 if (ndmSequences + 1 >= SET_MAX_SEQUENCES) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
596 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
597 dmErrorMsg("Too many matching sequences found.\n"); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
598 return; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
599 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
600 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
601 seq = &dmSequences[ndmSequences++]; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
602 seq->data = data; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
603 seq->len = len; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
604 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
605 else |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
606 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
607 // Check for existing |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
608 for (int n = 0; n < seq->nplaces; n++) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
609 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
610 DMMatchPlace *place = &seq->places[n]; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
611 if (place->offs == offs && place->file == file) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
612 return; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
613 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
614 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
615 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
616 // Add another file + offset |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
617 if (seq->nplaces < SET_MAX_PLACES) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
618 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
619 DMMatchPlace *place = &seq->places[seq->nplaces++]; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
620 place->file = file; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
621 place->offs = offs; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
622 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
623 else |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
624 return; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
625 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
626 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
627 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
628 |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
629 int main(int argc, char *argv[]) |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
630 { |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
631 DMCompElem *compBuf = NULL; |
1996 | 632 size_t compBufSize = 0, totalSize = 0; |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
633 int res; |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
634 |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
635 memset(&dmSequences, 0, sizeof(dmSequences)); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
636 |
2234 | 637 dmInitProg("fanalyze", "Simple tool for file format analysis", |
638 "0.4", NULL, NULL); | |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
639 dmVerbosity = 0; |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
640 |
1996 | 641 dmInitStats(&totalStats); |
642 | |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
643 // Parse arguments |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
644 if (!dmArgsProcess(argc, argv, optList, optListN, |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
645 argHandleOpt, argHandleNonOpt, OPTH_BAILOUT)) |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
646 exit(1); |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
647 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
648 if (nsrcFiles < 1) |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
649 { |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
650 dmErrorMsg("Nothing to do. (try --help)\n"); |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
651 goto out; |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
652 } |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
653 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
654 // Read input files |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
655 for (int nfile = 0; nfile < nsrcFiles; nfile++) |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
656 { |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
657 DMSourceFile *file = &srcFiles[nfile]; |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
658 if ((res = dmReadDataFile(NULL, file->filename, &file->data, &file->size)) != DMERR_OK) |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
659 { |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
660 dmErrorMsg("Could not read '%s': %s\n", |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
661 file->filename, dmErrorStr(res)); |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
662 goto out; |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
663 } |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
664 |
1685
904904f145b4
Various fixes in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
1683
diff
changeset
|
665 dmPrint(2, "Input #%d: '%s', %" DM_PRIu_SIZE_T " bytes.\n", |
904904f145b4
Various fixes in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
1683
diff
changeset
|
666 nfile + 1, file->filename, file->size); |
904904f145b4
Various fixes in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
1683
diff
changeset
|
667 |
904904f145b4
Various fixes in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
1683
diff
changeset
|
668 if (!compBufSize || file->size < compBufSize) |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
669 compBufSize = file->size; |
1996 | 670 |
671 totalSize += file->size; | |
2011 | 672 dmInitStats(&file->stats); |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
673 } |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
674 |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
675 |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
676 // |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
677 // Check what operating mode we are in |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
678 // |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
679 if (setMode == FA_GREP) |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
680 { |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
681 for (int nfile = 0; nfile < nsrcFiles; nfile++) |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
682 { |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
683 DMSourceFile *file = &srcFiles[nfile]; |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
684 dmPrint(0, "\n%s\n", file->filename); |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
685 |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
686 for (int n = 0; n < nsetGrepValues; n++) |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
687 { |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
688 DMGrepValue *node = &setGrepValues[n]; |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
689 const DMGrepType *def = &dmGrepTypes[node->type]; |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
690 |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
691 for (size_t offs = 0; offs + (def->bsize * node->nvalues) < file->size; offs++) |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
692 { |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
693 BOOL match = TRUE; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
694 for (int n = 0; n < node->nvalues; n++) |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
695 if (!node->vwildcards[n]) |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
696 { |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
697 Uint32 mval; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
698 dmGetData(node->type, file, offs + n, &mval); |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
699 |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
700 if (mval != node->values[n]) |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
701 { |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
702 match = FALSE; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
703 break; |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
704 } |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
705 } |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
706 |
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
707 if (match) |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
708 { |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
709 dmPrint(0, "%08x : ", offs); |
2225
837c79747ea4
Add functionality for grepping multiple consecutive values (8/16/32 le/be)
Matti Hamalainen <ccr@tnsp.org>
parents:
2045
diff
changeset
|
710 dmPrintGrepValueList(node, TRUE, file, offs); |
2028
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
711 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
712 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
713 } |
8a9ef75fd3cd
Implemement simple binary grep functionality in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2011
diff
changeset
|
714 } |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
715 } |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
716 else |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
717 if (setMode == FA_OFFSET) |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
718 { |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
719 for (int nfile = 0; nfile < nsrcFiles; nfile++) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
720 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
721 DMSourceFile *file = &srcFiles[nfile]; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
722 dmPrint(1, "#%03d: %s\n", nfile + 1, file->filename); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
723 } |
1996 | 724 |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
725 printf(" offset :"); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
726 for (int nfile = 0; nfile < nsrcFiles; nfile++) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
727 printf(" %03d ", nfile + 1); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
728 printf("\n"); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
729 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
730 printf("=========="); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
731 for (int nfile = 0; nfile < nsrcFiles; nfile++) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
732 printf("==========="); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
733 printf("\n"); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
734 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
735 for (int n = 0; n < nsetGrepValues; n++) |
1996 | 736 { |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
737 DMGrepValue *node = &setGrepValues[n]; |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
738 const DMGrepType *def = &dmGrepTypes[node->type]; |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
739 |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
740 for (int nv = 0; nv < node->nvalues; nv++) |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
741 { |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
742 printf("%08x : ", node->values[nv]); |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
743 |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
744 for (int nfile = 0; nfile < nsrcFiles; nfile++) |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
745 { |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
746 DMSourceFile *file = &srcFiles[nfile]; |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
747 Uint32 mval; |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
748 char mstr[32]; |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
749 int npad, nwidth; |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
750 |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
751 if (dmGetData(node->type, file, node->values[nv], &mval)) |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
752 { |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
753 char mfmt[16]; |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
754 nwidth = def->bsize * 2; |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
755 snprintf(mfmt, sizeof(mfmt), "%%0%d%s", |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
756 nwidth, dmGrepDisp[node->disp].fmt); |
2045
1662730053d0
Implement controllable decimal/hexadecimal formatting for offset display mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
2042
diff
changeset
|
757 |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
758 snprintf(mstr, sizeof(mstr), mfmt, mval); |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
759 } |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
760 else |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
761 { |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
762 strcpy(mstr, "----"); |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
763 nwidth = 4; |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
764 } |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
765 |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
766 npad = (10 - nwidth) / 2; |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
767 for (int q = 0; q < npad; q++) |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
768 fputc(' ', stdout); |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
769 |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
770 fputs(mstr, stdout); |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
771 |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
772 for (int q = 0; q < npad; q++) |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
773 fputc(' ', stdout); |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
774 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
775 |
2229
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
776 printf(" [%s]\n", |
72e15cc14927
Make the offset mode (-o) also support lists of offsets.
Matti Hamalainen <ccr@tnsp.org>
parents:
2228
diff
changeset
|
777 dmGrepDisp[node->disp].name); |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
778 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
779 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
780 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
781 else |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
782 if (setMode == FA_ANALYZE) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
783 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
784 // Allocate comparision buffer |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
785 // XXX: integer overflow? |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
786 dmPrint(2, "Allocating %d element (%d bytes) comparision buffer.\n", |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
787 compBufSize, compBufSize * sizeof(DMCompElem)); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
788 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
789 if ((compBuf = dmCalloc(compBufSize, sizeof(DMCompElem))) == NULL) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
790 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
791 dmErrorMsg("Out of memory. Could not allocate comparision buffer!\n"); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
792 goto out; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
793 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
794 |
2234 | 795 // |
796 // Basic file data comparision | |
797 // | |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
798 dmPrint(2, "Analyzing ..\n"); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
799 for (int nfile = 0; nfile < nsrcFiles; nfile++) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
800 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
801 DMSourceFile *file = &srcFiles[nfile]; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
802 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
803 for (size_t offs = 0; offs < file->size; offs++) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
804 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
805 Uint8 bv = file->data[offs]; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
806 totalStats.cv[bv].count++; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
807 file->stats.cv[bv].count++; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
808 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
809 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
810 for (size_t offs = 0; offs < compBufSize; offs++) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
811 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
812 Uint8 data = offs < file->size ? file->data[offs] : 0; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
813 compBuf[offs].stats[data]++; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
814 } |
1996 | 815 } |
816 | |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
817 for (size_t offs = 0; offs < compBufSize; offs++) |
1685
904904f145b4
Various fixes in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
1683
diff
changeset
|
818 { |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
819 DMCompElem *el = &compBuf[offs]; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
820 for (int n = 0; n < SET_MAX_ELEMS; n++) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
821 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
822 if (el->stats[n] > 0) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
823 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
824 el->variants++; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
825 el->data = n; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
826 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
827 } |
1685
904904f145b4
Various fixes in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
1683
diff
changeset
|
828 } |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
829 |
2234 | 830 // |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
831 // Display results |
2234 | 832 // |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
833 for (size_t offs = 0, n = 0; offs < compBufSize; offs++) |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
834 { |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
835 DMCompElem *el = &compBuf[offs]; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
836 BOOL var = el->variants > 1; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
837 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
838 if (n == 0) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
839 printf("%08" DM_PRIx_SIZE_T " | ", offs); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
840 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
841 if (var) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
842 printf("[%2d] ", el->variants); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
843 else |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
844 printf(" %02x ", el->data); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
845 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
846 if (++n >= 16) |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
847 { |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
848 printf("\n"); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
849 n = 0; |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
850 } |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
851 } |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
852 |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
853 printf("\n"); |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
854 |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
855 // |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
856 // Attempt further analysis |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
857 // |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
858 for (int nfile = 0; nfile < nsrcFiles; nfile++) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
859 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
860 DMSourceFile *file = &srcFiles[nfile]; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
861 size_t len = file->size > compBufSize ? compBufSize : file->size; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
862 for (size_t offs = 0; offs + 4 < len; offs++) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
863 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
864 DMCompElem *elem = &compBuf[offs]; |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
865 |
2268
f2ff364065eb
Add constant define for maximum number of variants.
Matti Hamalainen <ccr@tnsp.org>
parents:
2267
diff
changeset
|
866 for (int variant = SET_MAX_VARIANTS - 1; variant >= 0; variant--) |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
867 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
868 size_t nmax = (variant < 2) ? sizeof(Uint16) : sizeof(Uint32); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
869 Uint32 tmp = 0; |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
870 |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
871 for (size_t n = 0; n < nmax; n++) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
872 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
873 size_t boffs = (variant & 1) ? n : nmax - n; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
874 |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
875 tmp <<= 8; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
876 tmp |= file->data[offs + boffs]; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
877 } |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
878 |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
879 if (file->size - tmp < 32) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
880 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
881 elem->interest[variant] += 32 - (file->size - tmp); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
882 elem->interestF[variant]++; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
883 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
884 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
885 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
886 } |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
887 |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
888 printf("\nMore findings:\n"); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
889 for (size_t offs = 0; offs + 4 < compBufSize; offs++) |
1996 | 890 { |
891 DMCompElem *elem = &compBuf[offs]; | |
892 | |
2268
f2ff364065eb
Add constant define for maximum number of variants.
Matti Hamalainen <ccr@tnsp.org>
parents:
2267
diff
changeset
|
893 for (int variant = 0; variant < SET_MAX_VARIANTS; variant++) |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
894 if (elem->interestF[variant] > 0) |
1996 | 895 { |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
896 printf("%08" DM_PRIx_SIZE_T " | V%d : %d / %d\n", |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
897 offs, variant, |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
898 elem->interestF[variant], elem->interest[variant]); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
899 } |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
900 } |
1996 | 901 |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
902 printf("\nGlobal most used bytes:\n"); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
903 dmPrintStats(&totalStats, 16, totalSize); |
1996 | 904 |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
905 for (int nfile = 0; nfile < nsrcFiles; nfile++) |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
906 { |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
907 DMSourceFile *file = &srcFiles[nfile]; |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
908 printf("Most used bytes for '%s':\n", file->filename); |
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
909 dmPrintStats(&file->stats, 16, file->size); |
1996 | 910 } |
2267
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
911 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
912 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
913 else |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
914 if (setMode == FA_MATCHES) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
915 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
916 // |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
917 // Attempt to find matching sequences of N+ |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
918 // |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
919 dmPrint(2, "Attempting to find matching sequences of %" DM_PRIu_SIZE_T" bytes or more\n", |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
920 optMinMatchLen); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
921 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
922 for (int nfile1 = 0; nfile1 < nsrcFiles; nfile1++) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
923 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
924 DMSourceFile *file1 = &srcFiles[nfile1]; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
925 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
926 for (int nfile2 = 0; nfile2 < nsrcFiles; nfile2++) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
927 if (nfile2 != nfile1 && !file1->analyzed) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
928 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
929 DMSourceFile *file2 = &srcFiles[nfile2]; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
930 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
931 // Find longest possible matching sequence in file2, if any |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
932 size_t moffs1 = 0, moffs2 = 0; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
933 while (moffs1 + optMinMatchLen < file1->size && |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
934 moffs2 + optMinMatchLen < file2->size) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
935 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
936 size_t cnt; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
937 for (cnt = 0; moffs1 + cnt < file1->size && moffs2 + cnt < file2->size; cnt++) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
938 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
939 if (file1->data[moffs1 + cnt] != file2->data[moffs2 + cnt]) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
940 break; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
941 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
942 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
943 if (cnt >= optMinMatchLen) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
944 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
945 // Match found |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
946 dmAddMatchSequence(file1->data + moffs1, cnt, file1, moffs1); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
947 dmAddMatchSequence(file2->data + moffs2, cnt, file2, moffs2); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
948 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
949 moffs1 += cnt; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
950 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
951 else |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
952 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
953 moffs1++; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
954 moffs2++; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
955 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
956 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
957 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
958 file1->analyzed = TRUE; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
959 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
960 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
961 // |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
962 // Display results |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
963 // |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
964 dmPrint(0, "Found %d matching sequence groups of %" DM_PRIu_SIZE_T " bytes minimum.\n", |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
965 ndmSequences, optMinMatchLen); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
966 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
967 for (int nmatch = 0; nmatch < ndmSequences; nmatch++) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
968 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
969 DMMatchSeq *seq = &dmSequences[nmatch]; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
970 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
971 printf("\nSeq of %" DM_PRIu_SIZE_T " bytes in %d places (%d files)\n", |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
972 seq->len, seq->nplaces, seq->nfiles); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
973 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
974 if (dmVerbosity > 0) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
975 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
976 int n = 0; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
977 for (size_t offs = 0; offs < seq->len; offs++) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
978 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
979 if (n == 0) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
980 printf(" "); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
981 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
982 printf("%02x%s", |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
983 seq->data[offs], |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
984 offs + 1 < seq->len ? " " : ""); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
985 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
986 if (++n >= 16) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
987 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
988 printf("\n"); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
989 n = 0; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
990 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
991 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
992 if (n > 0) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
993 printf("\n"); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
994 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
995 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
996 for (int nplace = 0; nplace < seq->nplaces; nplace++) |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
997 { |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
998 DMMatchPlace *place = &seq->places[nplace]; |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
999 printf(" %08" DM_PRIx_SIZE_T ": %s\n", |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
1000 place->offs, |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
1001 place->file->filename); |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
1002 |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
1003 } |
3739e2ac8bb1
Add 'beta' level feature to fanalyze, for finding matching byte sequences of minimum
Matti Hamalainen <ccr@tnsp.org>
parents:
2249
diff
changeset
|
1004 } |
1996 | 1005 } |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
1006 else |
1996 | 1007 { |
2034
45ad06bb60c4
Implement offset dump mode in fanalyze.
Matti Hamalainen <ccr@tnsp.org>
parents:
2032
diff
changeset
|
1008 dmErrorMsg("Invalid operating mode?\n"); |
1996 | 1009 } |
1010 | |
1682
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1011 out: |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1012 for (int nfile = 0; nfile < nsrcFiles; nfile++) |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1013 { |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1014 DMSourceFile *file = &srcFiles[nfile]; |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1015 dmFree(file->data); |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1016 } |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1017 |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1018 return 0; |
2cfb4806cf71
Add simple and naively implemented multi-file bindiff type file analyzer utility 'fanalyze'.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1019 } |