【问题标题】:IDA pro 'this' keywordIDA pro 'this' 关键字
【发布时间】:2010-12-25 07:12:40
【问题描述】:

我想知道“this”关键字在 IDA pro 伪 c++ 代码中的确切含义。

假设我有一个函数调用:

v2 = sub_100010B3((int)&v12, "QtGui4.dll");

调用这个函数:

int __thiscall sub_100010B3(int this, const char *Str1)
  {
  int result; // eax@2
  int v3; // eax@4
  int v4; // [sp+0h] [bp-8h]@1
  int v5; // [sp+4h] [bp-4h]@1

  v4 = this;
  v5 = sub_10001090(this, 1);
  if ( v5 )
  {
    while ( *(_DWORD *)(v5 + 16) )
    {
      v3 = sub_10001470(v4, *(_DWORD *)(v5 + 12));
      if ( !stricmp(Str1, (const char *)v3) )
        return v5;
      v5 += 20;
    }
    result = 0;
  }
  else
  {
    result = 0;
  }
  return result;
}

好的,所以在函数中我们可以看到定义'int this',根据文档,它是一个指向用于调用对象的对象的指针。我想知道的是如何重写函数,使它们运行相同但不需要传递“this”参数?

【问题讨论】:

    标签: c++ visual-studio-2008 decompiling ida


    【解决方案1】:

    thiscall 表示它是一个 Class 成员函数,因此您需要将其重写为

    class MyClass {
       int sub_100010B3(const char* Str1);
    };
    
    MyClass::sub_100010B3(const char* Str1)
    {
      // .. implementation
    }
    

    【讨论】:

    • sub_100010B3 是 IDA Pro 在反汇编二进制文件时为例程提供的名称。它与函数的原始名称无关。
    • 谢谢 jcopenha。类可以是静态的吗?
    • 类的存储限定符应该很重要。只要确保你实现的函数不是静态的。
    猜你喜欢
    • 2012-11-09
    • 1970-01-01
    • 1970-01-01
    • 2016-10-26
    • 2012-09-28
    • 2012-01-28
    • 1970-01-01
    • 2014-11-13
    • 1970-01-01
    相关资源
    最近更新 更多