代码中的错误是m_old_data没有定义。请在类Casm_tiny中添加成员变量m_old_data,并在构造函数中对其进行初始化。

修改后的代码如下:

class Casm_tiny
{
public:
    enum
    {
        E_INS_BL  = 0,
        E_INS_BLX = 1,
        E_INS_BW  = 2,
        E_INS_MAX,
    };

public:
    Casm_tiny();
    ~Casm_tiny();

    typedef uint32_t (Casm_tiny::*gen_code_cb)(uint32_t, uint32_t);
    typedef uint32_t (Casm_tiny::*check_code_cb)(uint32_t);
    typedef uint32_t (Casm_tiny::*get_func_cb)(uint32_t, uint32_t);

    struct asm_ins_pro_t
    {
        int8_t           ins_dsc[10];
        gen_code_cb      gen_code;
        check_code_cb    check_code;
        get_func_cb      get_func;
    };

    bool asm_tiny_proc(uint32_t old_pos, uint32_t new_pos, uint32_t len);

private:
    asm_ins_pro_t m_ins_pro[E_INS_MAX];
    uint8_t* m_old_data; // 添加成员变量m_old_data

    uint32_t gen_code_bl(uint32_t, uint32_t);
    uint32_t check_code_bl(uint32_t);
    uint32_t get_func_bl(uint32_t, uint32_t);

    uint32_t gen_code_blx(uint32_t, uint32_t);
    uint32_t check_code_blx(uint32_t);
    uint32_t get_func_blx(uint32_t, uint32_t);

    uint32_t gen_code_bw(uint32_t, uint32_t);
    uint32_t check_code_bw(uint32_t);
    uint32_t get_func_bw(uint32_t, uint32_t);
};

Casm_tiny::Casm_tiny()
{
    m_old_data = nullptr; // 初始化m_old_data
}

bool Casm_tiny::asm_tiny_proc(uint32_t old_pos, uint32_t new_pos, uint32_t len)
{
    if (len <= 0)
    {
        return false;
    }

    /* 因为是4字节长度,所以如果尾部有3个字节,就不用匹配了*/
    for (uint32_t j = old_pos % 2; j + 3 < len; j += 2)
    {
        /*遍历跳转指令种类*/
        for (int k = 0; k < E_INS_MAX; k++)
        {
            if (m_ins_pro[k].check_code(*(uint32_t *)(m_old_data + old_pos + j)))
            {
                // Do something
            }
        }
    }

    return true;
}

Casm_tiny::~Casm_tiny()
{
    // Destructor implementation
}

uint32_t Casm_tiny::gen_code_bl(uint32_t, uint32_t)
{
    // gen_code_bl implementation
    return 0;
}

uint32_t Casm_tiny::check_code_bl(uint32_t)
{
    // check_code_bl implementation
    return 0;
}

uint32_t Casm_tiny::get_func_bl(uint32_t, uint32_t)
{
    // get_func_bl implementation
    return 0;
}

uint32_t Casm_tiny::gen_code_blx(uint32_t, uint32_t)
{
    // gen_code_blx implementation
    return 0;
}

uint32_t Casm_tiny::check_code_blx(uint32_t)
{
    // check_code_blx implementation
    return 0;
}

uint32_t Casm_tiny::get_func_blx(uint32_t, uint32_t)
{
    // get_func_blx implementation
    return 0;
}

uint32_t Casm_tiny::gen_code_bw(uint32_t, uint32_t)
{
    // gen_code_bw implementation
    return 0;
}

uint32_t Casm_tiny::check_code_bw(uint32_t)
{
    // check_code_bw implementation
    return 0;
}

uint32_t Casm_tiny::get_func_bw(uint32_t, uint32_t)
{
    // get_func_bw implementation
    return 0;
}
``
修改下面代码m_ins_prokcheck_codeuint32_t m_old_data + old_pos + j的错误class Casm_tinypublic enum E_INS_BL = 0 E_INS_BLX = 1 E_INS_BW = 2 E_INS_MAX ;public Casm_tiny;

原文地址: https://www.cveoy.top/t/topic/iTme 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录