FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
patchdiff2/display.cpp at master · CrackerCat/patchdiff2 · GitHub
CrackerCat
/
patchdiff2
Public
forked from
cseagle/patchdiff2
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
patchdiff2
/
display.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
1226 lines (1006 loc) · 38.4 KB
Breadcrumbs
patchdiff2
/
display.cpp
Copy path
File metadata and controls
1226 lines (1006 loc) · 38.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Patchdiff2
Portions (C) 2010 - 2011 Nicolas Pouvesle
Portions (C) 2007 - 2009 Tenable Network Security, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#
include
"
precomp.h
"
#
include
"
diff.h
"
#
include
"
display.h
"
#
include
"
os.h
"
#
include
"
parser.h
"
#
include
"
pgraph.h
"
#
include
"
options.h
"
#
include
"
system.h
"
//
global diff engine object
static
deng_t
*eng;
static
uint32 idaapi
sizer_dlist
(
slist_t
*sl) {
if
(sl) {
return
sl->
num
;
}
return
0
;
}
static
uint32 idaapi
sizer_match
(
void
*obj) {
deng_t
*d = (
deng_t
*)obj;
return
sizer_dlist
(d ? d->
mlist
:
NULL
);
}
static
uint32 idaapi
sizer_identical
(
void
*obj) {
deng_t
*d = (
deng_t
*)obj;
return
sizer_dlist
(d ? d->
ilist
:
NULL
);
}
static
uint32 idaapi
sizer_unmatch
(
void
*obj) {
deng_t
*d = (
deng_t
*)obj;
return
sizer_dlist
(d ? d->
ulist
:
NULL
);
}
static
void
idaapi
close_window
(
void
*obj) {
deng_t
*d = (
deng_t
*)obj;
d->
wnum
--;
if
(!d->
wnum
) {
ipc_close
();
}
return
;
}
/*
------------------------------------------------
*/
/*
function : ui_access_sig
*/
/*
description: Compensates for the zero index
*/
/*
indicating the header row and performs
*/
/*
bounds checking in debug
*/
/*
------------------------------------------------
*/
static
psig_t
*
ui_access_sig
(
slist_t
*sl, uint32 n) {
#
ifdef
_DEBUG
if
(!sl || n ==
0
|| n > sl->
num
) {
error
(
"
ui attempted to access siglist out-of-bounds: %p %x
\n
"
, sl, n -
1
);
return
NULL
;
}
#
endif
return
sl->
sigs
[n -
1
];
}
#
if
IDA_SDK_VERSION <= 695
static
void
idaapi
desc_dlist
(
slist_t
*sl, uint32 n,
char
*
const
*arrptr) {
int
i;
/*
header
*/
if
(n ==
0
) {
for
(i =
0
; i <
qnumber
(header_match); i++) {
qsnprintf
(arrptr[i],
MAXSTR
,
"
%s
"
, header_match[i]);
}
}
else
{
psig_t
*sig =
ui_access_sig
(sl, n);
qsnprintf
(arrptr[
0
],
MAXSTR
,
"
%u
"
, sig->
mtype
);
qsnprintf
(arrptr[
1
],
MAXSTR
,
"
%s
"
, sig->
name
.
c_str
());
qsnprintf
(arrptr[
2
],
MAXSTR
,
"
%s
"
, sig->
msig
->
name
.
c_str
());
qsnprintf
(arrptr[
3
],
MAXSTR
,
"
%a
"
, sig->
startEA
);
qsnprintf
(arrptr[
4
],
MAXSTR
,
"
%a
"
, sig->
msig
->
startEA
);
qsnprintf
(arrptr[
5
],
MAXSTR
,
"
%c
"
, sig->
id_crc
?
'
+
'
:
'
-
'
);
qsnprintf
(arrptr[
6
],
MAXSTR
,
"
%lx
"
, sig->
crc_hash
);
qsnprintf
(arrptr[
7
],
MAXSTR
,
"
%lx
"
, sig->
msig
->
crc_hash
);
}
}
/*
------------------------------------------------
*/
/*
function : desc_match
*/
/*
description: Fills matched list
*/
/*
------------------------------------------------
*/
static
void
idaapi
desc_match
(
void
*obj, uint32 n,
char
*
const
*arrptr) {
deng_t
*d = (
deng_t
*)obj;
desc_dlist
(d ? d->
mlist
:
NULL
, n, arrptr);
}
/*
------------------------------------------------
*/
/*
function : desc_identical
*/
/*
description: Fills identical list
*/
/*
------------------------------------------------
*/
static
void
idaapi
desc_identical
(
void
*obj, uint32 n,
char
*
const
*arrptr) {
deng_t
*d = (
deng_t
*)obj;
desc_dlist
(d ? d->
ilist
:
NULL
, n, arrptr);
}
/*
------------------------------------------------
*/
/*
function : desc_unmatch
*/
/*
description: Fills unmatched list
*/
/*
------------------------------------------------
*/
static
void
idaapi
desc_unmatch
(
void
*obj, uint32 n,
char
*
const
*arrptr) {
int
i;
/*
header
*/
if
(n ==
0
) {
for
(i =
0
; i <
qnumber
(header_unmatch); i++) {
qsnprintf
(arrptr[i],
MAXSTR
,
"
%s
"
, header_unmatch[i]);
}
}
else
{
psig_t
*sig =
ui_access_sig
(((
deng_t
*)obj)->
ulist
, n);
qsnprintf
(arrptr[
0
],
MAXSTR
,
"
%u
"
, sig->
nfile
);
qsnprintf
(arrptr[
1
],
MAXSTR
,
"
%s
"
, sig->
name
.
c_str
());
qsnprintf
(arrptr[
2
],
MAXSTR
,
"
%a
"
, sig->
startEA
);
qsnprintf
(arrptr[
3
],
MAXSTR
,
"
%.8lX
"
, sig->
sig
);
qsnprintf
(arrptr[
4
],
MAXSTR
,
"
%.8lX
"
, sig->
hash
);
qsnprintf
(arrptr[
5
],
MAXSTR
,
"
%.8lX
"
, sig->
crc_hash
);
}
}
#
endif
static
void
idaapi
enter_list
(
slist_t
*sl, uint32 n) {
jumpto
(
ui_access_sig
(sl, n)->
startEA
);
os_copy_to_clipboard
(
NULL
);
}
/*
------------------------------------------------
*/
/*
function : enter_match
*/
/*
description: Jumps to code for element n in
*/
/*
matched list
*/
/*
------------------------------------------------
*/
static
void
idaapi
enter_match
(
void
*obj, uint32 n) {
enter_list
(((
deng_t
*)obj)->
mlist
, n);
}
/*
------------------------------------------------
*/
/*
function : enter_identical
*/
/*
description: Jumps to code for element n in
*/
/*
identical list
*/
/*
------------------------------------------------
*/
static
void
idaapi
enter_identical
(
void
*obj, uint32 n) {
enter_list
(((
deng_t
*)obj)->
ilist
, n);
}
/*
------------------------------------------------
*/
/*
function : enter_unmatch
*/
/*
description: Jumps to code for element n in
*/
/*
unmatched list
*/
/*
------------------------------------------------
*/
static
void
idaapi
enter_unmatch
(
void
*obj, uint32 n) {
psig_t
*sig =
ui_access_sig
(((
deng_t
*)obj)->
ulist
, n);
if
(sig->
nfile
==
1
) {
jumpto
(sig->
startEA
);
}
else
{
os_copy_to_clipboard
(
NULL
);
}
}
static
uint32 idaapi
graph_list
(
slist_t
*sl, uint32 n,
options_t
*opt) {
slist_t
*sl1 =
NULL
;
slist_t
*sl2 =
NULL
;
msg
(
"
parsing second function...
\n
"
);
sl2 =
parse_second_fct
(
ui_access_sig
(sl, n)->
msig
->
startEA
, sl->
file
, opt);
if
(!sl2) {
msg
(
"
Error: FCT2 parsing failed.
\n
"
);
return
0
;
}
msg
(
"
parsing first function...
\n
"
);
#
if
IDA_SDK_VERSION < 700
sl1 =
parse_fct
(
ui_access_sig
(sl, n)->
startEA
, dto.
graph
.
s_showpref
);
#
else
//
dto went away in 7.0, not clear how to replicate above
sl1 =
parse_fct
(
ui_access_sig
(sl, n)->
startEA
,
0
);
#
endif
if
(!sl1) {
msg
(
"
Error: FCT1 parsing failed.
\n
"
);
siglist_free
(sl2);
return
0
;
}
sl1->
sigs
[
0
]->
nfile
=
1
;
sl2->
sigs
[
0
]->
nfile
=
2
;
msg
(
"
diffing functions...
\n
"
);
generate_diff
(
NULL
, sl1, sl2,
NULL
,
false
,
NULL
);
pgraph_display
(sl1, sl2);
msg
(
"
done!
\n
"
);
return
1
;
}
/*
------------------------------------------------
*/
/*
function : graph_match
*/
/*
description: Draws graph from element n in
*/
/*
matched list
*/
/*
------------------------------------------------
*/
static
void
idaapi
graph_match
(
void
*obj, uint32 n) {
slist_t
*sl = ((
deng_t
*)obj)->
mlist
;
options_t
*opt = ((
deng_t
*)obj)->
opt
;
graph_list
(sl, n, opt);
return
;
}
/*
------------------------------------------------
*/
/*
function : graph_identical
*/
/*
description: Draws graph from element n in
*/
/*
identical list
*/
/*
------------------------------------------------
*/
static
void
idaapi
graph_identical
(
void
*obj, uint32 n) {
slist_t
*sl = ((
deng_t
*)obj)->
ilist
;
options_t
*opt = ((
deng_t
*)obj)->
opt
;
graph_list
(sl, n, opt);
return
;
}
/*
------------------------------------------------
*/
/*
function : graph_unmatch
*/
/*
description: Draws graph from element n in
*/
/*
unmatched list
*/
/*
------------------------------------------------
*/
static
void
idaapi
graph_unmatch
(
void
*obj, uint32 n) {
slist_t
*sl =
NULL
, *tmp = ((
deng_t
*)obj)->
ulist
;
if
(
ui_access_sig
(tmp, n)->
nfile
==
2
) {
msg
(
"
parsing second function...
\n
"
);
sl =
parse_second_fct
(
ui_access_sig
(tmp, n)->
startEA
, tmp->
file
, ((
deng_t
*)obj)->
opt
);
if
(!sl) {
msg
(
"
Error: FCT2 parsing failed.
\n
"
);
return
;
}
sl->
sigs
[
0
]->
nfile
=
2
;
}
else
{
msg
(
"
parsing first function...
\n
"
);
#
if
IDA_SDK_VERSION < 700
sl =
parse_fct
(
ui_access_sig
(tmp, n)->
startEA
, dto.
graph
.
s_showpref
);
#
else
//
dto went away in 7.0, not clear how to replicate above
sl =
parse_fct
(
ui_access_sig
(tmp, n)->
startEA
,
0
);
#
endif
if
(!sl) {
msg
(
"
Error: FCT1 parsing failed.
\n
"
);
return
;
}
sl->
sigs
[
0
]->
nfile
=
1
;
}
pgraph_display_one
(sl);
msg
(
"
done!
\n
"
);
return
;
}
static
uint32 idaapi
res_unmatch
(
deng_t
*d, uint32 n,
int
type) {
slist_t
*sl;
if
(type ==
0
) {
sl = d->
ilist
;
}
else
{
sl = d->
mlist
;
}
psig_t
*sig =
ui_access_sig
(sl, n);
sig->
nfile
=
1
;
sig->
msig
->
nfile
=
2
;
siglist_add
(d->
ulist
, sig);
siglist_add
(d->
ulist
, sig->
msig
);
sig->
msig
->
msig
=
NULL
;
sig->
msig
=
NULL
;
siglist_remove
(sl, n -
1
);
refresh_chooser
(title_unmatch);
return
1
;
}
/*
------------------------------------------------
*/
/*
function : res_iunmatch
*/
/*
description: Unmatches element n from identical
*/
/*
list
*/
/*
------------------------------------------------
*/
static
uint32 idaapi
res_iunmatch
(
void
*obj, uint32 n) {
return
res_unmatch
((
deng_t
*)obj, n,
0
);
}
/*
------------------------------------------------
*/
/*
function : res_munmatch
*/
/*
description: Unmatches element n from matched
*/
/*
list
*/
/*
------------------------------------------------
*/
static
uint32 idaapi
res_munmatch
(
void
*obj, uint32 n) {
return
res_unmatch
((
deng_t
*)obj, n,
1
);
}
/*
------------------------------------------------
*/
/*
function : propagate_match
*/
/*
description: Propagates new matched result if
*/
/*
option is set in dialog box
*/
/*
------------------------------------------------
*/
void
propagate_match
(
deng_t
*eng,
psig_t
*s1,
psig_t
*s2,
int
options) {
size_t
i;
deng_t
*d =
NULL
;
slist_t
*l1, *l2;
if
(options) {
show_wait_box
(
"
PatchDiff is in progress ...
"
);
l1 =
siglist_init
(eng->
ulist
->
num
, eng->
ulist
->
file
);
l2 =
siglist_init
(eng->
ulist
->
num
, eng->
ulist
->
file
);
for
(i=
0
; i<eng->
ulist
->
num
; i++) {
if
(!eng->
ulist
->
sigs
[i]->
msig
) {
if
(eng->
ulist
->
sigs
[i]->
nfile
==
1
) {
siglist_add
(l1, eng->
ulist
->
sigs
[i]);
}
else
{
siglist_add
(l2, eng->
ulist
->
sigs
[i]);
}
}
}
generate_diff
(&d, l1, l2, eng->
ulist
->
file
,
false
,
NULL
);
siglist_partial_free
(l1);
siglist_partial_free
(l2);
hide_wait_box
();
}
i =
0
;
while
(i<eng->
ulist
->
num
) {
s1 = eng->
ulist
->
sigs
[i];
s2 = s1->
msig
;
if
(!s2) {
i++;
}
else
{
if
(s1->
nfile
==
1
) {
if
(
sig_equal
(s1, s2,
DIFF_EQUAL_SIG_HASH
)) {
siglist_add
(eng->
ilist
, s1);
}
else
{
siglist_add
(eng->
mlist
, s1);
}
}
siglist_remove
(eng->
ulist
, i);
}
}
}
/*
------------------------------------------------
*/
/*
function : res_match
*/
/*
description: Matches 2 elements from unmatched
*/
/*
list
*/
/*
------------------------------------------------
*/
static
uint32 idaapi
res_match
(
void
*obj,uint32 n) {
deng_t
*eng = (
deng_t
*)obj;
psig_t
*s1, *s2;
int
option;
ea_t
ea =
BADADDR
;
size_t
i;
const
char
format[] =
"
STARTITEM 0
\n
"
"
Set Match
\n
"
"
<Match address:$:32:32::>
\n\n
"
"
Options :
\n
"
"
<Propagate :C>>
\n\n
"
;
option =
1
;
if
(
AskUsingForm_c
(format, &ea, &option)) {
s1 =
ui_access_sig
(eng->
ulist
, n);
for
(i =
0
; i < eng->
ulist
->
num
; i++) {
s2 = eng->
ulist
->
sigs
[i];
if
(s2->
startEA
!= ea || (s2->
nfile
== s1->
nfile
)) {
continue
;
}
sig_set_matched_sig
(s1, s2,
DIFF_MANUAL
);
propagate_match
(eng, s1, s2, option);
refresh_chooser
(title_match);
refresh_chooser
(title_identical);
return
1
;
}
warning
(
"
Address '%a' is not valid.
"
, ea);
return
0
;
}
return
1
;
}
/*
------------------------------------------------
*/
/*
function : res_mtoi
*/
/*
description: Switches element n from matched
*/
/*
to identical list
*/
/*
------------------------------------------------
*/
static
uint32 idaapi
res_mtoi
(
void
*obj, uint32 n) {
deng_t
*d = (
deng_t
*)obj;
psig_t
*sig =
ui_access_sig
(d->
mlist
, n);
sig->
mtype
= sig->
msig
->
mtype
=
DIFF_MANUAL
;
siglist_add
(d->
ilist
, sig);
siglist_remove
(d->
mlist
, n -
1
);
refresh_chooser
(title_identical);
return
1
;
}
/*
------------------------------------------------
*/
/*
function : res_itom
*/
/*
description: Switches element n from identical
*/
/*
to matched list
*/
/*
------------------------------------------------
*/
static
uint32 idaapi
res_itom
(
void
*obj, uint32 n) {
deng_t
*d = (
deng_t
*)obj;
psig_t
*sig =
ui_access_sig
(d->
ilist
, n);
sig->
mtype
= sig->
msig
->
mtype
=
DIFF_MANUAL
;
siglist_add
(d->
mlist
, sig);
siglist_remove
(d->
ilist
, n -
1
);
refresh_chooser
(title_match);
return
1
;
}
/*
------------------------------------------------
*/
/*
function : res_flagged
*/
/*
description: Sets element as flagged/unflagged
*/
/*
------------------------------------------------
*/
static
uint32 idaapi
res_flagged
(
void
*obj, uint32 n) {
psig_t
*sig =
ui_access_sig
(((
deng_t
*)obj)->
mlist
, n);
sig->
flag
= !sig->
flag
;
refresh_chooser
(title_match);
return
1
;
}
static
void
transfer_sym
(
psig_t
*sig) {
psig_t
*rhs = sig->
msig
;
sig_set_name
(sig, rhs->
name
);
set_name
(sig->
startEA
, rhs->
name
.
c_str
(),
SN_NOCHECK
|
SN_NON_AUTO
);
}
static
uint32 idaapi
transfer_sym_match
(
void
*obj, uint32 n) {
psig_t
*sig =
ui_access_sig
(((
deng_t
*)obj)->
mlist
, n);
transfer_sym
(sig);
return
1
;
}
static
uint32 idaapi
transfer_sym_identical
(
void
*obj, uint32 n) {
psig_t
*sig =
ui_access_sig
(((
deng_t
*)obj)->
ilist
, n);
transfer_sym
(sig);
return
1
;
}
#
if
IDA_SDK_VERSION >= 670
#
define
MUNMATCH_NAME
"
patchdiff:munmatch
"
//
-------------------------------------------------------------------------
struct
munmatch_action_handler_t
:
public
action_handler_t
{
virtual
int
idaapi
activate
(
action_activation_ctx_t
*ctx) {
uint32 n = ctx->
chooser_selection
.
size
();
if
(n ==
1
) {
n = ctx->
chooser_selection
[
0
];
#
if
IDA_SDK_VERSION < 700
return
res_munmatch
(eng, n);
#
else
return
res_munmatch
(eng, n +
1
);
//
hack because pre-7.0 choosers index from 1
#
endif
}
return
0
;
}
virtual
action_state_t
idaapi
update
(
action_update_ctx_t
*ctx) {
bool
ok = ctx->
form_type
==
BWN_CHOOSER
;
if
(ok) {
//
it's a chooser, now make sure it's the correct form
#
if
IDA_SDK_VERSION < 700
char
name[
MAXSTR
];
ok =
get_tform_title
(ctx->
form
, name,
sizeof
(name)) &&
strneq
(name, title_match,
qstrlen
(title_match));
#
else
qstring title;
ok =
get_widget_title
(&title, ctx->
widget
) && title == title_match;
#
endif
}
return
ok ?
AST_ENABLE_FOR_FORM
:
AST_DISABLE_FOR_FORM
;
}
};
static
munmatch_action_handler_t
munmatch_action_handler;
static
const
action_desc_t
munmatch_action =
ACTION_DESC_LITERAL
(
MUNMATCH_NAME
,
"
Unmatch
"
, &munmatch_action_handler,
NULL
,
NULL
, -
1
);
#
define
IDENTICAL_NAME
"
patchdiff:identical
"
//
-------------------------------------------------------------------------
struct
identical_action_handler_t
:
public
action_handler_t
{
virtual
int
idaapi
activate
(
action_activation_ctx_t
*ctx) {
uint32 n = ctx->
chooser_selection
.
size
();
if
(n ==
1
) {
n = ctx->
chooser_selection
[
0
];
#
if
IDA_SDK_VERSION < 700
return
res_mtoi
(eng, n);
#
else
return
res_mtoi
(eng, n +
1
);
//
hack because pre-7.0 choosers index from 1
#
endif
}
return
0
;
}
virtual
action_state_t
idaapi
update
(
action_update_ctx_t
*ctx) {
bool
ok = ctx->
form_type
==
BWN_CHOOSER
;
if
(ok) {
//
it's a chooser, now make sure it's the correct form
#
if
IDA_SDK_VERSION < 700
char
name[
MAXSTR
];
ok =
get_tform_title
(ctx->
form
, name,
sizeof
(name)) &&
strneq
(name, title_match,
qstrlen
(title_match));
#
else
qstring title;
ok =
get_widget_title
(&title, ctx->
widget
) && title == title_match;
#
endif
}
return
ok ?
AST_ENABLE_FOR_FORM
:
AST_DISABLE_FOR_FORM
;
}
};
static
identical_action_handler_t
identical_action_handler;
static
const
action_desc_t
identical_action =
ACTION_DESC_LITERAL
(
IDENTICAL_NAME
,
"
Set as identical
"
, &identical_action_handler,
NULL
,
NULL
, -
1
);
#
define
FLAGUNFLAG_NAME
"
patchdiff:flagunflag
"
//
-------------------------------------------------------------------------
struct
flagunflag_action_handler_t
:
public
action_handler_t
{
virtual
int
idaapi
activate
(
action_activation_ctx_t
*ctx) {
uint32 n = ctx->
chooser_selection
.
size
();
if
(n ==
1
) {
n = ctx->
chooser_selection
[
0
];
#
if
IDA_SDK_VERSION < 700
return
res_flagged
(eng, n);
#
else
return
res_flagged
(eng, n +
1
);
//
hack because pre-7.0 choosers index from 1
#
endif
}
return
0
;
}
virtual
action_state_t
idaapi
update
(
action_update_ctx_t
*ctx) {
bool
ok = ctx->
form_type
==
BWN_CHOOSER
;
if
(ok) {
//
it's a chooser, now make sure it's the correct form
#
if
IDA_SDK_VERSION < 700
char
name[
MAXSTR
];
ok =
get_tform_title
(ctx->
form
, name,
sizeof
(name)) &&
strneq
(name, title_match,
qstrlen
(title_match));
#
else
qstring title;
ok =
get_widget_title
(&title, ctx->
widget
) && title == title_match;
#
endif
}
return
ok ?
AST_ENABLE_FOR_FORM
:
AST_DISABLE_FOR_FORM
;
}
};
static
flagunflag_action_handler_t
flagunflag_action_handler;
static
const
action_desc_t
flagunflag_action =
ACTION_DESC_LITERAL
(
FLAGUNFLAG_NAME
,
"
Flag/unflag
"
, &flagunflag_action_handler,
NULL
,
NULL
, -
1
);
#
define
MSYM_NAME
"
patchdiff:msym
"
//
-------------------------------------------------------------------------
struct
msym_action_handler_t
:
public
action_handler_t
{
virtual
int
idaapi
activate
(
action_activation_ctx_t
*ctx) {
uint32 n = ctx->
chooser_selection
.
size
();
if
(n ==
1
) {
n = ctx->
chooser_selection
[
0
];
#
if
IDA_SDK_VERSION < 700
return
transfer_sym_match
(eng, n);
#
else
return
transfer_sym_match
(eng, n +
1
);
//
hack because pre-7.0 choosers index from 1
#
endif
}
return
0
;
}
virtual
action_state_t
idaapi
update
(
action_update_ctx_t
*ctx) {
bool
ok = ctx->
form_type
==
BWN_CHOOSER
;
if
(ok) {
//
it's a chooser, now make sure it's the correct form
#
if
IDA_SDK_VERSION < 700
char
name[
MAXSTR
];
ok =
get_tform_title
(ctx->
form
, name,
sizeof
(name)) &&
strneq
(name, title_match,
qstrlen
(title_match));
#
else
qstring title;
ok =
get_widget_title
(&title, ctx->
widget
) && title == title_match;
#
endif
}
return
ok ?
AST_ENABLE_FOR_FORM
:
AST_DISABLE_FOR_FORM
;
}
};
static
msym_action_handler_t
msym_action_handler;
static
const
action_desc_t
msym_action =
ACTION_DESC_LITERAL
(
MSYM_NAME
,
"
Import Symbol
"
, &msym_action_handler,
NULL
,
NULL
, -
1
);
#
define
IUNMATCH_NAME
"
patchdiff:iunmatch
"
//
-------------------------------------------------------------------------
struct
iunmatch_action_handler_t
:
public
action_handler_t
{
virtual
int
idaapi
activate
(
action_activation_ctx_t
*ctx) {
uint32 n = ctx->
chooser_selection
.
size
();
if
(n ==
1
) {
n = ctx->
chooser_selection
[
0
];
#
if
IDA_SDK_VERSION < 700
return
res_iunmatch
(eng, n);
#
else
return
res_iunmatch
(eng, n +
1
);
//
hack because pre-7.0 choosers index from 1
#
endif
}
return
0
;
}
virtual
action_state_t
idaapi
update
(
action_update_ctx_t
*ctx) {
bool
ok = ctx->
form_type
==
BWN_CHOOSER
;
if
(ok) {
#
if
IDA_SDK_VERSION < 700
char
name[
MAXSTR
];
ok =
get_tform_title
(ctx->
form
, name,
sizeof
(name)) &&
strneq
(name, title_identical,
qstrlen
(title_match));
#
else
qstring title;
ok =
get_widget_title
(&title, ctx->
widget
) && title == title_identical;
#
endif
}
return
ok ?
AST_ENABLE_FOR_FORM
:
AST_DISABLE_FOR_FORM
;
}
};
static
iunmatch_action_handler_t
iunmatch_action_handler;
static
const
action_desc_t
iunmatch_action =
ACTION_DESC_LITERAL
(
IUNMATCH_NAME
,
"
Unmatch
"
, &iunmatch_action_handler,
NULL
,
NULL
, -
1
);
#
define
ITOM_NAME
"
patchdiff:itom
"
//
-------------------------------------------------------------------------
struct
itom_action_handler_t
:
public
action_handler_t
{
virtual
int
idaapi
activate
(
action_activation_ctx_t
*ctx) {
uint32 n = ctx->
chooser_selection
.
size
();
if
(n ==
1
) {
n = ctx->
chooser_selection
[
0
];
#
if
IDA_SDK_VERSION < 700
return
res_itom
(eng, n);
#
else
return
res_itom
(eng, n +
1
);
//
hack because pre-7.0 choosers index from 1
#
endif
}
return
0
;
}
virtual
action_state_t
idaapi
update
(
action_update_ctx_t
*ctx) {
bool
ok = ctx->
form_type
==
BWN_CHOOSER
;
if
(ok) {
//
it's a chooser, now make sure it's the correct form
#
if
IDA_SDK_VERSION < 700
char
name[
MAXSTR
];
ok =
get_tform_title
(ctx->
form
, name,
sizeof
(name)) &&
strneq
(name, title_identical,
qstrlen
(title_match));
#
else
qstring title;
ok =
get_widget_title
(&title, ctx->
widget
) && title == title_identical;
#
endif
}
return
ok ?
AST_ENABLE_FOR_FORM
:
AST_DISABLE_FOR_FORM
;
}
};
static
itom_action_handler_t
itom_action_handler;
static
const
action_desc_t
itom_action =
ACTION_DESC_LITERAL
(
ITOM_NAME
,
"
Set as matched
"
, &itom_action_handler,
NULL
,
NULL
, -
1
);
#
define
ISYM_NAME
"
patchdiff:isym
"
//
-------------------------------------------------------------------------
struct
isym_action_handler_t
:
public
action_handler_t
{
virtual
int
idaapi
activate
(
action_activation_ctx_t
*ctx) {
uint32 n = ctx->
chooser_selection
.
size
();
if
(n ==
1
) {
n = ctx->
chooser_selection
[
0
];
#
if
IDA_SDK_VERSION < 700
return
transfer_sym_identical
(eng, n);
#
else
return
transfer_sym_identical
(eng, n +
1
);
//
hack because pre-7.0 choosers index from 1
#
endif
}
return
0
;
}
virtual
action_state_t
idaapi
update
(
action_update_ctx_t
*ctx) {
bool
ok = ctx->
form_type
==
BWN_CHOOSER
;
if
(ok) {
//
it's a chooser, now make sure it's the correct form
#
if
IDA_SDK_VERSION < 700
char
name[
MAXSTR
];
ok =
get_tform_title
(ctx->
form
, name,
sizeof
(name)) &&
strneq
(name, title_identical,
qstrlen
(title_match));
#
else
qstring title;
ok =
get_widget_title
(&title, ctx->
widget
) && title == title_identical;
#
endif
}
return
ok ?
AST_ENABLE_FOR_FORM
:
AST_DISABLE_FOR_FORM
;
}
};
static
isym_action_handler_t
isym_action_handler;
static
const
action_desc_t
isym_action =
ACTION_DESC_LITERAL
(
ISYM_NAME
,
"
Import symbol
"
, &isym_action_handler,
NULL
,
NULL
, -
1
);
#
define
MATCH_NAME
"
patchdiff:match
"
//
-------------------------------------------------------------------------
struct
match_action_handler_t
:
public
action_handler_t
{
virtual
int
idaapi
activate
(
action_activation_ctx_t
*ctx) {
uint32 n = ctx->
chooser_selection
.
size
();
if
(n ==
1
) {
n = ctx->
chooser_selection
[
0
];
#
if
IDA_SDK_VERSION < 700
return
res_match
(eng, n);
#
else
return
res_match
(eng, n +
1
);
//
hack because pre-7.0 choosers index from 1
#
endif
}
return
0
;
}
virtual
action_state_t
idaapi
update
(
action_update_ctx_t
*ctx) {
bool
ok = ctx->
form_type
==
BWN_CHOOSER
;
if
(ok) {
//
it's a chooser, now make sure it's the correct form
#
if
IDA_SDK_VERSION < 700
char
name[
MAXSTR
];
ok =
get_tform_title
(ctx->
form
, name,
sizeof
(name)) &&
strneq
(name, title_unmatch,
qstrlen
(title_match));
#
else
qstring title;
ok =
get_widget_title
(&title, ctx->
widget
) && title == title_unmatch;
#
endif
}
return
ok ?
AST_ENABLE_FOR_FORM
:
AST_DISABLE_FOR_FORM
;
}
};
static
match_action_handler_t
match_action_handler;
static
const
action_desc_t
match_action =
ACTION_DESC_LITERAL
(
MATCH_NAME
,
"
Set match
"
, &match_action_handler,
NULL
,
NULL
, -
1
);
#
endif
#
if
IDA_SDK_VERSION >= 700
static
void
idaapi
desc_dlist
(
slist_t
*sl, uint32 n,
qstrvec_t
*cols_) {
qstrvec_t
&cols = *cols_;
psig_t
*sig =
ui_access_sig
(sl, n +
1
);
//
hack because pre-7.0 choosers index from 1
cols[
0
].
sprnt
(
"
%u
"
, sig->
mtype
);
cols[
1
].
sprnt
(
"
%s
"
, sig->
name
.
c_str
());
cols[
2
].
sprnt
(
"
%s
"
, sig->
msig
->
name
.
c_str
());
cols[
3
].
sprnt
(
"
%a
"
, sig->
startEA
);
cols[
4
].
sprnt
(
"
%a
"
, sig->
msig
->
startEA
);
cols[
5
].
sprnt
(
"
%c
"
, sig->
id_crc
?
'
+
'
:
'
-
'
);
cols[
6
].
sprnt
(
"
%lx
"
, sig->
crc_hash
);
cols[
7
].
sprnt
(
"
%lx
"
, sig->
msig
->
crc_hash
);
}
//
-------------------------------------------------------------------------
struct
matched_chooser_t
:
public
chooser_t
{
private:
deng_t
*eng;
public:
//
this object must be allocated using `new`
matched_chooser_t
(
deng_t
*eng_);
//
function that is used to decide whether a new chooser should be opened
//
or we can use the existing one.
//
The contents of the window are completely determined by its title
virtual
const
void
*
get_obj_id
(
size_t
*len)
const
{
*len =
strlen
(title);
return
title;
}
//
function that returns number of lines in the list
virtual
size_t
idaapi
get_count
()
const
{
return
sizer_dlist
(eng ? eng->
mlist
:
NULL
);
}
//
function that generates the list line
virtual
void
idaapi
get_row
(
qstrvec_t
*cols,
int
*icon_,
chooser_item_attrs_t
*attrs,
size_t
n)
const
;
//
function that is called when the user hits Enter
virtual
cbret_t
idaapi
enter
(
size_t
n) {
enter_list
(eng->
mlist
, n +
1
);
//
hack because pre-7.0 choosers index from 1
return
cbret_t
();
//
nothing changed
}
virtual
cbret_t
idaapi
edit
(
size_t
n) {
graph_match
(eng, n +
1
);
//
hack because pre-7.0 choosers index from 1
return
cbret_t
();
//
nothing changed
}
};
inline
matched_chooser_t::matched_chooser_t
(
deng_t
*eng_) :
chooser_t(
CH_ATTRS
|
CH_CAN_EDIT
, qnumber(widths_match), widths_match, header_match, title_match) {
eng = eng_;
popup_names[
POPUP_EDIT
] =
"
Display Graphs
"
;
}
void
idaapi
matched_chooser_t::get_row
(
qstrvec_t
*cols_,
int
*,
chooser_item_attrs_t
*,
size_t
n)
const
{
desc_dlist
(eng ? eng->
mlist
:
NULL
, n, cols_);
}
static
matched_chooser_t
*matched_chooser;
//
-------------------------------------------------------------------------
struct
identical_chooser_t
:
public
chooser_t
{
private:
deng_t
*eng;
public:
//
this object must be allocated using `new`
identical_chooser_t
(
deng_t
*eng_);
//
function that is used to decide whether a new chooser should be opened
//
or we can use the existing one.
//
The contents of the window are completely determined by its title
virtual
const
void
*
get_obj_id
(
size_t
*len)
const
{
*len =
strlen
(title);
return
title;
}
//
function that returns number of lines in the list
virtual
size_t
idaapi
get_count
()
const
{
return
sizer_dlist
(eng ? eng->
ilist
:
NULL
);
}
//
function that generates the list line
virtual
void
idaapi
get_row
(
qstrvec_t
*cols,
int
*icon_,
chooser_item_attrs_t
*attrs,
size_t
n)
const
;
//
function that is called when the user hits Enter
virtual
cbret_t
idaapi
enter
(
size_t
n) {
enter_list
(eng->
ilist
, n +
1
);
//
hack because pre-7.0 choosers index from 1
return
cbret_t
();
//
nothing changed
}
virtual
cbret_t
idaapi
edit
(
size_t
n) {
graph_identical
(eng, n +
1
);
//
hack because pre-7.0 choosers index from 1
return
cbret_t
();
//
nothing changed
}
virtual
void
idaapi
closed
() {
close_window
(eng);
}
};
inline
identical_chooser_t::identical_chooser_t
(
deng_t
*eng_) :
chooser_t(
CH_ATTRS
|
CH_CAN_EDIT
, qnumber(widths_match), widths_match, header_match, title_identical) {
eng = eng_;
popup_names[
POPUP_EDIT
] =
"
Display Graphs
"
;
}
void
idaapi
identical_chooser_t::get_row
(
qstrvec_t
*cols_,
int
*,
chooser_item_attrs_t
*,
size_t
n)
const
{
desc_dlist
(eng ? eng->
ilist
:
NULL
, n, cols_);
}
static
identical_chooser_t
*identical_chooser;
//
-------------------------------------------------------------------------
struct
unmatched_chooser_t
:
public
chooser_t
{
private:
deng_t
*eng;
public:
//
this object must be allocated using `new`
unmatched_chooser_t
(
deng_t
*eng_);
//
function that is used to decide whether a new chooser should be opened
//
or we can use the existing one.
//
The contents of the window are completely determined by its title
virtual
const
void
*
get_obj_id
(
size_t
*len)
const
{
*len =
strlen
(title);
return
title;
}
//
function that returns number of lines in the list
virtual
size_t
idaapi
get_count
()
const
{
return
sizer_dlist
(eng ? eng->
ulist
:
NULL
);
}
//
function that generates the list line
virtual
void
idaapi
get_row
(
qstrvec_t
*cols,
int
*icon_,
chooser_item_attrs_t
*attrs,
size_t
n)
const
;
//
function that is called when the user hits Enter
virtual
cbret_t
idaapi
enter
(
size_t
n) {
psig_t
*sig =
ui_access_sig
(eng->
ulist
, n +
1
);
//
hack because pre-7.0 choosers index from 1
if
(sig->
nfile
==
1
)
jumpto
(sig->
startEA
);
else
os_copy_to_clipboard
(
NULL
);
return
cbret_t
();
//
nothing changed
}
virtual
cbret_t
idaapi
edit
(
size_t
n) {
graph_unmatch
(eng, n +
1
);
//
hack because pre-7.0 choosers index from 1
return
cbret_t
();
//
nothing changed
}
virtual
void
idaapi
closed
() {
close_window
(eng);
}
};
inline
unmatched_chooser_t::unmatched_chooser_t
(
deng_t
*eng_) :
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL