Idapython API Record

Source: Internet
Author: User

Getoperandvalue effect
    • Parameter 1:ea virtual address
    • Parameter 2: Operand number

Returns the parsed value of the operand of the instruction

Document
def GetOperandValue(ea, n):    """    Get number used in the operand    This function returns an immediate number used in the operand    @param ea: linear address of instruction    @param n: the operand number    @return: value        operand is an immediate value  => immediate value        operand has a displacement     => displacement        operand is a direct memory ref => memory address        operand is a register          => register number        operand is a register phrase   => phrase number        otherwise                      => -1    """
Instance
.text:080488C9                 cmp     eax, 1.text:080488CC                 jz      short loc_80488D8.text:080488CE                 sub     esp, 0Ch

The 080488CC 16 binary of the instruction is represented as

74 0A

This instruction has an operand, so GetOperandValue you can get the value by resolving it by getting it ida .

Python>hex(GetOperandValue(0x080488CC,0))0x80488d8L
Getmnem effect
    • Parameter 1:ea virtual address

The mnemonic that returns the opcode of the instruction

Document
def GetMnem(ea):    """    Get instruction mnemonics    @param ea: linear address of instruction    @return: "" - no instruction at the specified location
Instance
.text:080488C9                 cmp     eax, 1.text:080488CC                 jz      short loc_80488D8.text:080488CE                 sub     esp, 0Ch
Python>GetMnem(0x80488CC)jz
GETOPND effect
    • Parameter 1:ea virtual address
    • Parameter 2: Operand index

Returns the operand of the instruction

Document
def GetOpnd(ea, n):    """    Get operand of an instruction    @param ea: linear address of instruction    @param n: number of operand:        0 - the first operand        1 - the second operand    @return: the current text representation of operand or ""    """
Instance
.text:080488C9                 cmp     eax, 1.text:080488CC                 jz      short loc_80488D8.text:080488CE                 sub     esp, 0Ch
Python>GetOpnd(0x80488CC,0)loc_80488D8
Getdisasm effect
    • Parameter 1:ea virtual address

Get the disassembly string for the instruction

Document
def GetDisasm(ea):    """    Get disassembly line    @param ea: linear address of instruction    @return: "" - could not decode instruction at the specified location    @note: this function may not return exactly the same mnemonics           as you see on the screen.    """
Instance
.text:080488C9                 cmp     eax, 1.text:080488CC                 jz      short loc_80488D8.text:080488CE                 sub     esp, 0Ch
Python>GetDisasm(0x80488CC)jz      short loc_80488D8
Prevhead and Nexthead effects
    • Parameter 1:ea virtual address

Get the address of the previous or last instruction

Instance
.text:080488AF                 add     esp, 10h.text:080488B2                 mov     [ebp+fd], eax.text:080488B5                 sub     esp, 4
Python>hex(PrevHead(0x080488B2))0x80488afLPython>hex(NextHead(0x080488B2))0x80488b5L

Idapython API Record

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.