IDA Pro > IDA Pro教程 > 技术问题 > IDA Pro设置功能/项目类型(Set function/item type)

IDA Pro设置功能/项目类型(Set function/item type)

发布时间:2023-04-21 14: 04: 24

Action name:SetType

This command allows you to specify the type of the current item.

If the cursor is located on a name,the type of the named item will be edited.Otherwise,the current function type(if there is a function)or the current item type(if it has a name)will be edited.

The function type must be entered as a C declaration.Hidden arguments(like'this'pointer in C++)should be specified explicitly.IDA will use the type information to comment the disassembly with the information about function arguments.It can also be used by the Hex-Rays decompiler plugin for better decompilation.

Here is an example of a function declaration:

int main(int argc,const char*argv[]);

To delete a type declaration,please enter an empty string.

IDA supports the user-defined calling convention.In this calling convention,the user can explicitly specify the locations of arguments and the return value.For example:

int __usercall func (int x,int y );

denotes a function with 2 arguments:the first argument is passed on the stack(IDA automatically calculates its offset)and the second argument is passed in the ESI register and the return value is stored in the EBX register.Stack locations can be specified explicitly:

int __usercall runtime_memhash <^12.4>(void*p <^0.4>,int q <^4.4>,int r <^8.4>)

There is a restriction for a __usercall function type:all stack locations should be specified explicitly or all are automatically calculated by IDA.General rules for the user defined prototypes are:

-the return value must be in a register.

Exception:stack locations are accepted for the __golang and __usercall calling conventions.

-if the return type is'void',the return location must not be specified

-if the argument location is not specified,it is assumed to be

on the stack;consequent stack locations are allocated for such arguments

-it is allowed to declare nested declarations,for example:

int**__usercall func16 (int*(__usercall*x)

(int,long ,int) );

Here the pointer"x"is passed in the ESI register;

The pointed function is a usercall function and expects its second

argument in the ECX register,its return value is in the EBX register.

The rule of thumb to apply in such complex cases is to specify the

the registers just before the opening brace for the parameter list.

-registers used for the location names must be valid for the current

processor;some registers are unsupported(if the register name is

generated on the fly,it is unsupported;inform us about such cases;

we might improve the processor module if it is easy)

-register pairs can be specified with a colon like

-for really complicated cases this syntax can be used.

IDA also understands the"__userpurge"calling convention.It is the same thing as __usercall,the only difference is that the callee cleans the stack.

The name used in the declaration is ignored by IDA.

If the default calling convention is __golang then explicit specification of stack offsets is permitted.For example:

int __usercall myfunc<^8>(__int64 arg<^0>);

Function declarations may have the __spoils keyword.It is used to specify the list of registers spoiled by the function.The syntax is the following:

int __spoilsfunc(int x);

If the __spoils keyword is present,the specified list overrides the standard spoiled list.For x86,the standard spoiled list is.The list of spoiled registers may be empty.

IDA also understands some attributes in declarations.For example:

__attribute__((format(printf,2,3)))

int myprnt(int id,const char*format,...);

This declaration means that myprnt is a print-like function;the format string is the second argument and the variadic argument list starts at the third argument.

Below is the full list of attributes that can be handled by IDA.Please look up the details in the corresponding compiler help pages.

packed pack structure/union fields tightly,without gaps

aligned specify the alignment

noreturn declare as not returning function

ms_struct use microsoft layout for the structure/union

format possible formats:printf,scanf,strftime,strfmon

The following additional keywords can be used in type declarations:

_BOOL1 a boolean type with explicit size specification(1 byte)

_BOOL2 a boolean type with explicit size specification(2 bytes)

_BOOL4 a boolean type with explicit size specification(4 bytes)

__int8 a integer with explicit size specification(1 byte)

__int16 a integer with explicit size specification(2 bytes)

__int32 a integer with explicit size specification(4 bytes)

__int64 a integer with explicit size specification(8 bytes)

__int128 a integer with explicit size specification(16 bytes)

_BYTE an unknown type;the only known info is its size:1 byte

_WORD an unknown type;the only known info is its size:2 bytes

_DWORD an unknown type;the only known info is its size:4 bytes

_QWORD an unknown type;the only known info is its size:8 bytes

_OWORD an unknown type;the only known info is its size:16 bytes

_TBYTE 10-byte floating point value

_UNKNOWN no info is available

__pure pure function:always returns the same value and does not

modify memory in a visible way

__noreturn function does not return

__usercall user-defined calling convention;see above

__userpurge user-defined calling convention;see above

__spoils explicit spoiled-reg specification;see above

__hidden hidden function argument;this argument was hidden in the

source code(e.g.'this'argument in c++methods is hidden)

__return_ptr pointer to return value;implies hidden

__struct_ptr was initially a structure value

__array_ptr was initially an array

__unused unused function argument

__cppobj a c++style struct;the struct layout depends on this keyword

__ptr32 explicit pointer size specification(32 bits)

__ptr64 explicit pointer size specification(64 bits)

__shifted shifted pointer declaration

__high high level prototype(does not explicitly specify

hidden arguments like'this',for example)

this keyword may not be specified by the user but

IDA may use it to describe high level prototypes

 

以下为中文翻译

操作名称:SetType

此命令允许您指定当前项的类型。

如果光标位于名称上,则将编辑命名项的类型。否则,将编辑当前函数类型(如果有函数)或当前项类型(如果它有名称)。

函数类型必须以C声明的形式输入。

应显式指定隐藏参数(如C++中的“this”指针)。IDA将使用类型信息用函数参数的信息来注释反汇编。Hex Rays反编译器插件也可以使用它来进行更好的反编译。

下面是函数声明的示例:int main(int argc,const char*argv[]);

要删除类型声明,请输入一个空字符串。

IDA支持用户定义的调用约定。在这个调用约定中,用户可以显式指定参数的位置和返回值。例如:int __usercall func (int x,int y );

表示一个有两个参数的函数:第一个参数在堆栈上传递(IDA自动计算其偏移量),第二个参数在ESI寄存器中传递,返回值存储在EBX寄存器中。可以显式指定堆栈位置:int __usercall runtime_memhash <^12.4>(void*p <^0.4>,int q <^4.4>,int r <^8.4>)_

_usercall有限制函数类型:所有堆栈位置都

应该明确指定,或者由IDA自动计算。用户定义原型的一般规则是:-返回值必须在寄存器中。异常:__golang和__usercall调用约定接受堆栈位置。

-如果返回类型为“void”,则不得指定返回位置

-如果未指定参数位置,则假定它

在堆栈上;结果堆栈位置被分配给这样的参数

-允许声明嵌套声明,例如:int**__usercall func16 (int*(__usercall*x)

(int,long ,int) );

在这里,指针“x”是在ESI寄存器中传递的;指向函数是一个用户调用函数

,它的第二个参数在ECX寄存器中,它的返回值在EBX寄存器中。在这种复杂的情况下,经验法则是在参数列表的左大括号之前指定寄存器

用于位置名称的寄存器必须对当前处理器有效;有些寄存器不受支持(如果寄存器名是动态生成的,则不受支持;请告知我们此类情况;如果很容易,我们可能会改进处理器模块)

-寄存器对可以用类似于的冒号指定

-对于非常复杂的情况,可以使用此语法。

IDA还理解“__userpurge”调用约定。它

与__usercall相同,唯一的区别是

被调用者清理

堆栈。IDA忽略声明中使用的名称。

如果默认调用约定是__golang,则

允许显式指定堆栈偏移量。例如:int __usercall myfunc<^8>(__int64 arg<^0>);

函数声明可能包含__proports关键字。它用于指定被函数破坏的寄存器列表。语法如下:int __prets<eax,bh>func(int x);

如果存在__destroys关键字,则指定的列表将覆盖标准

损坏的列表。对于x86,标准的损坏列表是

损坏寄存器的列表可能是空的。

IDA也理解声明中的一些属性。例如:__attribute__((format(printf,2,3)))int myprnt(int id,const char*format,…);

这个声明意味着myprnt是一个类似打印的函数;

formatstring是第二个参数,可变

参数列表从第三个参数开始。下面是IDA可以处理的属性的完整列表。请在相应的编译器帮助页中查找详细信息。压缩包结构/联合字段紧密,没有对齐的间隙指定对齐noreturn声明为不返回函数

ms_struct使用microsoft布局进行结构/联合

格式可能的格式:printf,scanf,strftime,strfmon

以下附加关键字可用于类型声明:_BOOL1具有显式大小规范的布尔类型(1字节)

_BOOL2具有显式尺寸规范的布尔型

(2字节具有显式大小规范(2个字节)__int32具有显式尺寸规范(4个字节)的整数__int64具有显式长度规范(8个字节)__ int128具有显式宽度规范(16个字节)_BYTE为未知类型;唯一已知的信息是其大小:1字节_WORD是未知类型;唯一已知的信息是它的大小:2字节_DWORD是未知类型;唯一已知的信息是它的大小:4字节_QWORD是未知类型;唯一已知的信息是它的大小:8字节

_OWORD是未知类型;唯一已知的信息是它的大小:16字节_TBYTE 10字节浮点值_UNKNOWN没有可用的信息__pure纯函数:总是返回相同的值,并且不以

可见的方式修改内存__noreturn函数不返回

__usercall用户定义的调用约定;参见上面的

__userpurge用户定义调用约定;见上文

__destroys显式损坏的reg规范;请参阅上面的__hidden隐藏函数参数;此参数隐藏在

源代码中(例如,c++方法中的“this”参数隐藏)

__return_ptr指向返回值的指针;暗示隐藏的

__struct_ptr最初是一个结构值

__array_ptr初始是一个数组

__未使用的未使用函数参数

__cppobj是一个c++风格的结构;结构布局依赖于此关键字

__ptr32显式指针大小规范(32位)__ptr64显式指针尺寸规范(64位)__shifted shifted pointer declaration

__high high level prototype(

例如,不显式指定像“this”这样的隐藏参数)此关键字可能不是由用户,但IDA可以使用它来描述高级原型

展开阅读全文

标签:idaida反汇编工具

读者也访问过这里:
邀请您进入交流群 点击扫码
400-8765-888 kefu@makeding.com

专业销售为您服务

欢迎添加好友,了解更多IDA优惠信息,领逆向工程学习资料礼包1份!
热门文章
exe反编译工具哪个好?反编译能力强的工具盘点
随着软件技术的发展,exe(可执行文件)已经成为了电脑、手机等多个平台上的主要软件运行格式,而对于exe文件的反编译也成为了逆向工程中不可缺少的一个步骤。本文将介绍一些常用的exe反编译工具,并评价其优缺点,帮助读者选择合适的工具。
2023-04-12
idapro怎么改为中文
IDA Pro是一款功能强大的反汇编和反编译工具,广泛应用于逆向工程和软件开发领域。在使用IDA Pro时,如果我们不习惯英文界面,可以将其改为中文界面。本文将介绍IDA Pro怎么改为中文界面。IDA Pro界面改成中文主要有两种方法,下面是详细介绍。
2023-04-19
c++反编译工具有哪些
反编译C++代码的工具一般是针对可执行文件和库文件的反汇编和逆向分析工具。本文将给大家介绍c++反编译工具有哪些的内容。市面说的c++反编译工具有很多,下面介绍几款使用认识较多的软件。
2023-04-23
ida怎么查找字符串 ida字符串窗口快捷键
在数字化时代,逆向工程作为解密软件和分析程序的关键技术,正日益受到广泛关注。在逆向分析的过程中,IDA(Interactive DisAssembler)是一款备受推崇的工具,它为逆向工程师们提供了强大的功能和灵活的操作。本文将带您深入探讨如何在IDA中查找字符串,优化字符串窗口的使用,并探讨IDA如何将变量转换成字符串,帮助您更加熟练地驾驭这一工具,为逆向分析的世界增添一抹精彩。
2023-09-27
ida如何转伪代码 ida伪代码怎么看
IDA Pro是一款常用的反汇编和反编译工具,可以帮助我们分析二进制文件的实现细节和执行过程,以便更好地理解程序的执行过程和逻辑。在进行逆向工程的过程中,我们经常需要将反汇编结果转换为伪代码,以便更好地进行分析和修改。本文将介绍如何使用IDA Pro转换为伪代码,并简单讲解ida伪代码怎么看。
2023-04-14
最新文章
IDA Pro如何分析多平台程序 IDA Pro怎么做跨平台逆向工程
随着软件系统复杂性的增加,越来越多的应用程序被设计为跨平台运行,从Windows桌面程序、Linux服务端应用,到Android和iOS等移动端APP,再到嵌入式系统固件,程序可能同时支持多种CPU架构(如x86、ARM、MIPS)和操作系统接口(如ELF、PE、Mach-O)。面对这样的挑战,逆向工程师需要具备跨平台分析能力。IDAPro如何分析多平台程序IDAPro怎么做跨平台逆向工程成为当前软件安全分析、协议还原、恶意软件溯源等领域的核心话题之一。
2025-06-26
IDA Pro如何分析硬件固件 IDA Pro怎么做硬件逆向工程
在嵌入式设备安全研究、物联网产品分析、工控系统审计等技术领域,硬件固件的逆向工程逐渐成为关键能力之一。尤其是当固件中包含敏感配置信息、通信协议逻辑或潜在安全漏洞时,研究人员需要依靠专业工具进行深入分析。IDAPro如何分析硬件固件IDAPro怎么做硬件逆向工程这一主题,正是每一个希望深入了解底层系统行为的逆向工程师无法绕开的内容。作为全球领先的反汇编工具,IDAPro提供了多架构、多格式、多功能支持,成为分析硬件固件的首选。
2025-06-26
IDA Pro如何分析加密数据 IDA Pro怎么给加密数据解密
在逆向工程的实际操作中,分析目标程序时最常遇到的问题之一就是“加密数据”。不论是配置文件、通信内容,还是程序内部的关键字符串,这些信息通常会被以某种方式加密存储或传输,以增加破解和分析的难度。针对这种情况,IDAPro如何分析加密数据,IDAPro怎么给加密数据解密就成为了每一位逆向分析人员都必须掌握的重要技能。本文将从加密数据识别、加密算法逆向、自动解密脚本构建等方面,系统解析如何利用IDAPro完成加密数据的分析与还原。
2025-06-26
IDA Pro怎么分析虚拟机代码 IDA Pro虚拟机逆向工程
虚拟机(VM)加密与保护技术在现代软件保护中被广泛应用,它通过将原始指令转换为自定义的“虚拟指令”并在运行时由虚拟解释器执行,从而有效防止逆向分析。这种方法不仅提高了解析门槛,还极大增加了逆向工程的复杂度。面对这种高级保护手段,IDAPro怎么分析虚拟机代码,IDAPro虚拟机逆向工程成为很多逆向人员关注的重点话题。本文将围绕该问题展开,从识别虚拟机存在、分析VM架构、拆解虚拟指令到利用IDA工具进行自动化分析,提供一套系统化的解决路径。
2025-06-26
IDA Pro如何分析加壳程序 IDA Pro怎么给程序脱壳
在逆向工程领域,加壳程序的分析与脱壳处理一直是重要且富有挑战性的任务。尤其是在面对经过各种混淆、防调试和压缩处理的可执行文件时,常规的分析手段往往难以奏效。这时候,IDAPro作为行业内广泛认可的静态分析工具,就展现出了强大的实战价值。无论是定位壳代码、识别壳类型,还是配合脚本与动态分析工具对程序进行脱壳,IDAPro都扮演着核心角色。本文围绕“IDAPro如何分析加壳程序,IDAPro怎么给程序脱壳”展开,从理论认知到操作方法,帮助你掌握应对加壳程序的关键技巧。
2025-06-26
IDA Pro如何分析多架构代码 IDA Pro怎么做跨架构的反汇编
在复杂的嵌入式开发或固件逆向分析场景中,越来越多的系统采用多种处理器架构混合部署,例如主处理器采用ARM,而辅助模块可能采用MIPS、RISC-V甚至x86。针对这类多架构程序进行静态分析时,传统的反汇编工具显得力不从心。而IDA Pro作为一款功能强大的交互式反汇编工具,在支持多架构分析方面具备显著优势。本文围绕“IDA Pro如何分析多架构代码,IDA Pro怎么做跨架构的反汇编”为核心主题,详细说明操作流程与常见问题。
2025-06-26

通过微信咨询我们

欢迎添加好友,了解更多IDA优惠信息,领取逆向工程学习资料礼包1份!

读者也喜欢这些内容: