在Python中更改编译器

在Python中更改编译器,python,ida,Python,Ida,我一直在尝试使用IDAPythonAPI调整脚本中的编译器设置,但似乎无法使任何函数正常工作。我尝试过的一些事情: 1. Python>SetLongPrm(INF_COMPILER, COMP_MS) Python>idaapi.set_compiler_id(2) False class compiler_info_t(object): id = COMP_MS cm = 0x3 | 0x00 | 0x30 size_i = 4 size_b

我一直在尝试使用IDAPythonAPI调整脚本中的编译器设置,但似乎无法使任何函数正常工作。我尝试过的一些事情:

1.

Python>SetLongPrm(INF_COMPILER, COMP_MS)
Python>idaapi.set_compiler_id(2)
False
class compiler_info_t(object):
    id = COMP_MS
    cm = 0x3 | 0x00 | 0x30
    size_i = 4
    size_b = 1
    size_e = 4
    defalign = 0
    size_s = 2
    size_l = 4
    size_ll = 8
    def __init__(self, *args):
        """
        __init__(self) -> compiler_info_t
        """
        this = _idaapi.new_compiler_info_t(*args)
        try: self.this.append(this)
        except: self.this = this
这使我将编译器id设置为正确的值,但出于某种原因,它将所有其他与编译器相关的值设置为0或类似的值。给我一个关于指针大小不正确和int Size不是有效值的错误

2.

Python>SetLongPrm(INF_COMPILER, COMP_MS)
Python>idaapi.set_compiler_id(2)
False
class compiler_info_t(object):
    id = COMP_MS
    cm = 0x3 | 0x00 | 0x30
    size_i = 4
    size_b = 1
    size_e = 4
    defalign = 0
    size_s = 2
    size_l = 4
    size_ll = 8
    def __init__(self, *args):
        """
        __init__(self) -> compiler_info_t
        """
        this = _idaapi.new_compiler_info_t(*args)
        try: self.this.append(this)
        except: self.this = this
这是不可行的,但是这可能会和第一个命令一样结束

3.

Python>SetLongPrm(INF_COMPILER, COMP_MS)
Python>idaapi.set_compiler_id(2)
False
class compiler_info_t(object):
    id = COMP_MS
    cm = 0x3 | 0x00 | 0x30
    size_i = 4
    size_b = 1
    size_e = 4
    defalign = 0
    size_s = 2
    size_l = 4
    size_ll = 8
    def __init__(self, *args):
        """
        __init__(self) -> compiler_info_t
        """
        this = _idaapi.new_compiler_info_t(*args)
        try: self.this.append(this)
        except: self.this = this
我的最后一次尝试是尝试将我自己的编译器\u info\t对象传递给idaapi.set\u compiler(),但由于“\u idaapi”不是一个可以正常导入的模块,因此它不允许我调用新的\u compiler\u info\t()

问题: 是否有一种方法可以单独设置/修复指针大小、内存模型和调用约定的编译器值? 如果没有,是否有一种完全调整编译器的不同方法,类似于在“编译器设置”窗口中手动更改编译器时的工作方式?

以下是我的示例:“为Visual C++设置编译器默认值”

def打印编译器(id):
打印“-*(80)
abbr=ida\u typeinf.get\u编译器\u abbr(id)
name=ida\u typeinf.get\u编译器\u名称(id)
打印“id:%d(%s)”%(id,缩写)
打印“编译器:'%s'%name”
im=idc.get\u inf\u attr(inf\u编译器)
打印“呼叫型号:%02X”%im.cm
打印“删除对齐:%d”%im.defalign
打印“sizeof(int):%d\tsizeof(short):%d”%(im.size\u i,im.size\u s)
打印“尺寸(bool):%d\t尺寸(long):%d”%(im.size\u b,im.size\u l)
打印“大小(枚举):%d\t大小(长):%d”%(即时消息大小,即时消息大小)
打印“尺寸(长双精度):%d”%(im.sizeof\U ldbl)
打印“预定义宏:'%s'”%ida\u idp.cfg\u get\u cc\u预定义宏(id)
打印“包含的目录:'%s'%ida\u idp.cfg\u get\u cc\u header\u路径(id)
打印“-*(80)
#按ID打印旧的编译器设置
打印编译器(idc.get\u inf\u attr(inf\u compiler.id)
设置Visual C++的编译器默认值
im=idc.get_inf_attr(inf_编译器)#获取当前设置
im.id=ida_typeinf.COMP_MS
im.cm=0x03 | 0x00 | 0x30
im.defalign=0
im.size_i=4
im.size_b=1
im.size_e=4
im.size\U s=2
im.size_l=4
im.size\u ll=8
im.size\u ldbl=8
#按id替换预定义宏和包含的目录
#来自IDA.CFG(请参阅内置C解析器参数中的“CC_PARMS”)
ida_typeinf.set_c_宏(ida_idp.cfg_get_cc_预定义_宏(im.id))
ida_typeinf.set_c_header_path(ida_idp.cfg_get_cc_header_path(im.id))
#重置新设置:)
idc.set\u inf\u attr(inf\u编译器,im.id)
#按ID打印新的编译器设置
打印编译器(im.id)
下面是我的示例:“为Visual C++设置编译器默认值”

def打印编译器(id):
打印“-*(80)
abbr=ida\u typeinf.get\u编译器\u abbr(id)
name=ida\u typeinf.get\u编译器\u名称(id)
打印“id:%d(%s)”%(id,缩写)
打印“编译器:'%s'%name”
im=idc.get\u inf\u attr(inf\u编译器)
打印“呼叫型号:%02X”%im.cm
打印“删除对齐:%d”%im.defalign
打印“sizeof(int):%d\tsizeof(short):%d”%(im.size\u i,im.size\u s)
打印“尺寸(bool):%d\t尺寸(long):%d”%(im.size\u b,im.size\u l)
打印“大小(枚举):%d\t大小(长):%d”%(即时消息大小,即时消息大小)
打印“尺寸(长双精度):%d”%(im.sizeof\U ldbl)
打印“预定义宏:'%s'”%ida\u idp.cfg\u get\u cc\u预定义宏(id)
打印“包含的目录:'%s'%ida\u idp.cfg\u get\u cc\u header\u路径(id)
打印“-*(80)
#按ID打印旧的编译器设置
打印编译器(idc.get\u inf\u attr(inf\u compiler.id)
设置Visual C++的编译器默认值
im=idc.get_inf_attr(inf_编译器)#获取当前设置
im.id=ida_typeinf.COMP_MS
im.cm=0x03 | 0x00 | 0x30
im.defalign=0
im.size_i=4
im.size_b=1
im.size_e=4
im.size\U s=2
im.size_l=4
im.size\u ll=8
im.size\u ldbl=8
#按id替换预定义宏和包含的目录
#来自IDA.CFG(请参阅内置C解析器参数中的“CC_PARMS”)
ida_typeinf.set_c_宏(ida_idp.cfg_get_cc_预定义_宏(im.id))
ida_typeinf.set_c_header_path(ida_idp.cfg_get_cc_header_path(im.id))
#重置新设置:)
idc.set\u inf\u attr(inf\u编译器,im.id)
#按ID打印新的编译器设置
打印编译器(im.id)