为什么 IDA Pro 会生成这样的定义缺失代码?

逆向工程 艾达 拆卸 登录 纳姆
2021-06-29 18:20:59

基本上我在 Windows 32 位上使用 IDA Pro 6.1,处理来自 SPEC 2006 的二进制文件。

我使用 IDA Pro 从二进制文件生成 asm 代码,在 .data 部分,我看到数据定义如下:

GS_ExceptionRecord _EXCEPTION_RECORD  <?>
GS_ContextRecord _CONTEXT  <?>
lclcritsects    _RTL_CRITICAL_SECTION 0Eh dup(<?>)
 .....
DoubleFormat    FpFormatDescriptor <400h, 0FFFFFC01h, 35h, 0Bh, 40h, 3FFh>
FloatFormat     FpFormatDescriptor <80h, 0FFFFFF81h, 18h, 8, 20h, 7Fh>  

基本上我在生成的 asm 代码中找不到_EXCEPTION_RECORD_CONTEXT_RTL_CRITICAL_SECTIONFpFormatDescriptor的定义

在代码中,它们将像这样使用:

mov     edi, DoubleFormat.precision
mov     eax, DoubleFormat.min_exp
sub     ecx, DoubleFormat.precision

mov     edi, FloatFormat.precision

mov     edi, offset lclcritsects

mov     GS_ContextRecord._Eax, eax
mov     word ptr GS_ContextRecord.SegSs, ss
pop     GS_ContextRecord.EFlags

所以基本上我的问题是:

  1. 我怎样才能找到这些东西的定义?

  2. 基本上我使用File-->Produce File-->Create ASM File来生成用于分析的 asm 代码,然后我如何将这些定义从 IDA Pro 的 Structures 窗口转储到这个 asm 代码中?

更重要的是,即使我展开它们,我似乎也无法在“结构”窗口中找到定义....

在此处输入图片说明

3个回答

据我所知,IDA 不会将结构布局作为生成的程序集列表的一部分转储。但是,它确实了解您提到的所有结构。转到结构窗口,按“ Insert”并命名新结构CONTEXTEXCEPTION_RECORD否则RTL_CRITICAL_SECTIONIDA 将在结构窗口中显示布局。

然后,您可以打开“ Local Types”窗口并将所有结构布局转储为 C 头文件(右键单击“ Export to header file”。它仍然没有为您提供所需的程序集语法,但它与我所知道的一样接近让 IDA 得到你想要的。

_EXCEPTION_RECORD, _CONTEXT, 和_RTL_CRITICAL_SECTION都是定义明确的结构。他们的文档可以在 MSDN 上找到(http://msdn.microsoft.com/en-us/library/windows/desktop/aa363082(v=vs.85).aspx等),他们的布局也可以在IDA 的结构窗口。

你的其他问题不清楚。请改写它们。

似乎是来自一些内部微软浮点转换代码的结构,可能来自windbg源树

似乎被定义为

typedef struct { 
int max_exp; // maximum base 2 exponent (reserved for special values) 
int min_exp; // minimum base 2 exponent (reserved for denormals) 
int precision; // bits of precision carried in the mantissa 
int exp_width; // number of bits for exponent
int format_width; // format width in bits 
int bias;  // exponent bias 
} FpFormatDescriptor; 

双倍的

static FpFormatDescriptor 
DoubleFormat = { 
0x7ff - 0x3ff, //  1024, maximum base 2 exponent (reserved for special values)
0x0 - 0x3ff, // -1023, minimum base 2 exponent (reserved for denormals) 
53, // bits of precision carried in the mantissa 
11, // number of bits for exponent 
64, // format width in bits 
0x3ff,  // exponent bias 
}; 

漂浮

static FpFormatDescriptor 
FloatFormat = { 
0xff - 0x7f, //  128, maximum base 2 exponent(reserved for special values) 
0x0 - 0x7f, // -127, minimum base 2 exponent (reserved for denormals) 
24, // bits of precision carried in the mantissa 
8,   // number of bits for exponent 
32, // format width in bits 
0x7f,  // exponent bias 
};