9
9
#include < vector>
10
10
#include < string.h>
11
11
12
- using namespace std ;
13
-
14
12
typedef unsigned int uint32;
15
13
typedef unsigned char uchar;
16
14
@@ -24,7 +22,10 @@ typedef unsigned char uchar;
24
22
// 7 - PTT_READ_SYMBOLS packet 2..7
25
23
// 8 - renumbered PROCESS_ATTACHED, PROCESS_DETACHED, 2..8
26
24
// PROCESS_SUSPENDED, TRACE_FULL
27
- #define PIN_PROTOCOL_VERSION 8
25
+ // 9 - modified pin_regid_t so that now it is the same for 9
26
+ // both 32-bit and 64-bit pintools. We need this to
27
+ // support debugging of 32bit apps by ida64
28
+ #define PIN_PROTOCOL_VERSION 9
28
29
29
30
#ifdef IDA_SDK_VERSION
30
31
// IDA specific declarations
@@ -57,6 +58,8 @@ typedef unsigned char uchar;
57
58
# define qvector std::vector
58
59
# define qstring std::string
59
60
61
+ using namespace std ;
62
+
60
63
#if defined(_MSC_VER)
61
64
typedef unsigned __int64 uint64;
62
65
typedef __int64 int64;
@@ -438,7 +441,6 @@ enum pin_regid_t
438
441
PINREG_EIP,
439
442
PINREG_EFLAGS,
440
443
PINREG_LAST_REG32 = PINREG_EFLAGS,
441
- #ifdef PIN_64
442
444
PINREG64_R8,
443
445
PINREG64_R9,
444
446
PINREG64_R10,
@@ -447,13 +449,7 @@ enum pin_regid_t
447
449
PINREG64_R13,
448
450
PINREG64_R14,
449
451
PINREG64_R15,
450
- PINREG_LAST_GPREG = PINREG64_R15,
451
- #else
452
- PINREG_LAST_GPREG = PINREG_LAST_REG32,
453
- #endif
454
- PINREG_LAST_INTREG = PINREG_LAST_GPREG,
455
- // mmx registers
456
- PINREG_LAST_REG64 = PINREG_LAST_INTREG,
452
+
457
453
// FPU registers
458
454
PINREG_FIRST_REG128,
459
455
PINREG_FIRST_FPREG = PINREG_FIRST_REG128,
@@ -469,6 +465,7 @@ enum pin_regid_t
469
465
PINREG_STAT,
470
466
PINREG_TAGS,
471
467
PINREG_LAST_FPREG = PINREG_TAGS,
468
+
472
469
// xmm registers
473
470
PINREG_FIRST_XMMREG,
474
471
PINREG_MXCSR = PINREG_FIRST_XMMREG,
@@ -480,7 +477,6 @@ enum pin_regid_t
480
477
PINREG_XMM5,
481
478
PINREG_XMM6,
482
479
PINREG_XMM7,
483
- #ifdef PIN_64
484
480
PINREG_XMM8,
485
481
PINREG_XMM9,
486
482
PINREG_XMM10,
@@ -489,11 +485,7 @@ enum pin_regid_t
489
485
PINREG_XMM13,
490
486
PINREG_XMM14,
491
487
PINREG_XMM15,
492
- PINREG_LAST_XMMREG = PINREG_XMM15,
493
- #else
494
- PINREG_LAST_XMMREG = PINREG_XMM7,
495
- #endif
496
- PINREG_LAST_REG128 = PINREG_LAST_XMMREG,
488
+ PINREG_LAST_REG128 = PINREG_XMM15,
497
489
498
490
// MMX registers: used only for write_registers()
499
491
PINREG_MMX0,
@@ -516,9 +508,6 @@ enum pin_regid_t
516
508
PINREG_YMM5,
517
509
PINREG_YMM6,
518
510
PINREG_YMM7,
519
- #ifndef PIN_64
520
- PINREG_LAST_YMMREG = PINREG_YMM7,
521
- #else
522
511
PINREG_YMM8,
523
512
PINREG_YMM9,
524
513
PINREG_YMM10,
@@ -527,8 +516,17 @@ enum pin_regid_t
527
516
PINREG_YMM13,
528
517
PINREG_YMM14,
529
518
PINREG_YMM15,
519
+ #ifdef PIN_64
520
+ PINREG_LAST_GPREG = PINREG64_R15,
521
+ PINREG_LAST_XMMREG = PINREG_XMM15,
530
522
PINREG_LAST_YMMREG = PINREG_YMM15,
523
+ #else
524
+ PINREG_LAST_GPREG = PINREG_LAST_REG32,
525
+ PINREG_LAST_XMMREG = PINREG_XMM7,
526
+ PINREG_LAST_YMMREG = PINREG_YMM7,
531
527
#endif
528
+ PINREG_LAST_INTREG = PINREG_LAST_GPREG,
529
+ PINREG_LAST_REG64 = PINREG_LAST_INTREG,
532
530
PINREG_LAST_REG256 = PINREG_LAST_YMMREG,
533
531
534
532
PINREG_MAX
@@ -671,7 +669,7 @@ inline bool pin_classregs_t::init(pin_register_class_t cls, bool is_32bit)
671
669
break ;
672
670
case PIN_RC_YMM:
673
671
firstnum = PINREG_FIRST_YMMREG;
674
- lastnum = PINREG_LAST_YMMREG;
672
+ lastnum = is_32bit ? PINREG_YMM7 : PINREG_LAST_YMMREG; // -V547 'is_32bit' is always true
675
673
break ;
676
674
default :
677
675
return false ; // bad class
@@ -695,31 +693,31 @@ inline bool pin_classregs_t::init(pin_regid_t firstnum, pin_regid_t lastnum)
695
693
class pin_regbuf_t
696
694
{
697
695
public:
698
- pin_regbuf_t (int clsmask, bool is_32bit = false )
699
- : ncls(0 ), bufsize(0 ) { init (clsmask, is_32bit); }
700
- size_t get_bufsize () const { return bufsize; }
701
- inline int nclasses () const { return ncls; }
702
- pin_classregs_t *get_class (int i) { return &clregs[i]; }
703
- const pin_classregs_t *get_class (int i) const { return &clregs[i]; }
704
- pin_register_class_t get_classid (int i) const { return classes[i]; }
696
+ pin_regbuf_t (int clsmask, bool is_32bit = false );
697
+ size_t get_bufsize () const { return bufsize; }
698
+ inline int nclasses () const { return ncls; }
699
+ pin_classregs_t *get_class (int i) { return &clregs[i]; }
700
+ const pin_classregs_t *get_class (int i) const { return &clregs[i]; }
701
+ pin_register_class_t get_classid (int i) const { return classes[i]; }
705
702
inline void setbuf (char *buf);
706
703
707
704
private:
708
- int ncls;
709
- size_t bufsize;
705
+ int ncls = 0 ;
706
+ size_t bufsize = 0 ;
710
707
pin_register_class_t classes[PIN_RC_NCLASSES];
711
708
pin_classregs_t clregs[PIN_RC_NCLASSES];
712
709
void init (int clsmask, bool is_32bit = false );
713
710
};
714
711
715
712
// --------------------------------------------------------------------------
716
- inline void pin_regbuf_t::init (int clsmask, bool is_32bit)
713
+ inline pin_regbuf_t::pin_regbuf_t (int clsmask, bool is_32bit)
717
714
{
718
715
#ifndef PIN_64
719
716
is_32bit = true ;
720
717
#endif
721
- static pin_register_class_t all_cls[] =
718
+ static const pin_register_class_t all_cls[] =
722
719
{ PIN_RC_GENERAL, PIN_RC_SEGMENTS, PIN_RC_FPU, PIN_RC_XMM, PIN_RC_YMM };
720
+ memset (classes, 0 , sizeof (classes));
723
721
for ( size_t i = 0 ; i < sizeof (all_cls) / sizeof (all_cls[0 ]); ++i )
724
722
{
725
723
if ( (clsmask & all_cls[i]) != 0 )
@@ -818,6 +816,12 @@ struct idapin_segbase_packet_t: idapin_packet_t
818
816
void set_value (int val) { data = val; }
819
817
};
820
818
819
+ #ifdef _WIN32
820
+ #define USE_PIN_STLPORT (PIN_BUILD_NUMBER >= 76991 )
821
+ #else
822
+ #define USE_PIN_STLPORT (PIN_BUILD_NUMBER >= 76991 && PIN_BUILD_NUMBER < 98612 )
823
+ #endif
824
+
821
825
// --------------------------------------------------------------------------
822
826
// symbol address & name in serialized buffer
823
827
struct pin_symdef_t
@@ -829,7 +833,7 @@ struct pin_symdef_t
829
833
const unsigned char *name () const { return buf () + sizeof (uint64); }
830
834
unsigned char *name () { return buf () + sizeof (uint64); }
831
835
// PIN's stlport does not have data()
832
- #if defined(IDA_SDK_VERSION) || (PIN_BUILD_NUMBER >= 76991 && defined(TARGET_WINDOWS))
836
+ #if defined(IDA_SDK_VERSION) || USE_PIN_STLPORT
833
837
const unsigned char *buf () const { return array.begin (); }
834
838
unsigned char *buf () { return array.begin (); }
835
839
#else
0 commit comments