逆向-还原代码之bank (Arm 64)

逆向-还原代码之bank (Arm 64)_第1张图片

逆向-还原代码之bank (Arm 64)_第2张图片

// source code

#include

typedef unsigned long ULONG;
typedef unsigned char UCHAR;

#define D_PIPE_MEM_BANK_RAW        (3)
#define D_PIPE_MEM_BANK_Y        (6)
#define D_PIPE_MEM_BANK_C        (6)
#define D_PIPE_MEM_BANK_AEAWB    (3)
#define D_PIPE_MEM_BANK_MAP        (3)
#define D_PIPE_MEM_BANK_MAP_RGB    (3)
#define D_PIPE_MEM_BANK_RGB        (3)
#define D_PIPE_MEM_BANK_CUSTOM_RAW (8)
#define D_PIPE_MEM_BANK_MAX     (8)

typedef enum {
    E_MEM_BANK_SET = 0,
    E_MEM_BANK_ING,
    E_MEM_BANK_RCV,
    E_MEM_BANK_MAX,
} E_BANK;

// 以下宏就是对E_BANK类型赋值
#define BANK_SET_TO_ING_AND_INCREMENT(a, b, mem, lock) a[E_MEM_BANK_ING] = a[E_MEM_BANK_SET];\
                                            a[E_MEM_BANK_SET] = ( a[E_MEM_BANK_SET] + 1) % b;\
                                            if( mem[ a[E_MEM_BANK_SET] ] == lock ){\
                                                a[E_MEM_BANK_SET] = ( a[E_MEM_BANK_SET] + 1) % b;\
                                            }

#define BANK_ING_TO_RCV(a) a[E_MEM_BANK_RCV] = a[E_MEM_BANK_ING]

#define BANK_SET_TO_ING_AND_INCREMENT_SPEC(a, b, mem) a[E_MEM_BANK_ING] = a[E_MEM_BANK_SET];\
                                            a[E_MEM_BANK_SET] = ( a[E_MEM_BANK_SET] + 1) % b;\
                                            int i=b; \
                                            while(i--) { \
                                                if( mem[ a[E_MEM_BANK_SET] ].lock == 1 ){\
                                                    printf("index %d, mem %#x, lock %d, addr %#x\n", a[E_MEM_BANK_SET], &mem[ a[E_MEM_BANK_SET] ], mem[ a[E_MEM_BANK_SET] ].lock, mem[ a[E_MEM_BANK_SET] ].addr); \
                                                    a[E_MEM_BANK_SET] = ( a[E_MEM_BANK_SET] + 1) % b;\
                                                } else { \
                                                    break; \
                                                } \
                                            }

typedef struct {
    
    ULONG               mem_addr_raw[D_PIPE_MEM_BANK_RAW];
    ULONG               mem_addr_raw1[D_PIPE_MEM_BANK_RAW];
    ULONG               mem_addr_y[D_PIPE_MEM_BANK_Y];
    ULONG               mem_addr_c[D_PIPE_MEM_BANK_C];
    ULONG               mem_addr_y_ch1[D_PIPE_MEM_BANK_Y];
    ULONG               mem_addr_c_ch1[D_PIPE_MEM_BANK_C];
    ULONG               mem_addr_aeawb[D_PIPE_MEM_BANK_AEAWB];
    ULONG                mem_addr_map_yp[D_PIPE_MEM_BANK_MAP];
    ULONG                mem_addr_map_yn[D_PIPE_MEM_BANK_MAP];
    ULONG                mem_addr_map_rgb[D_PIPE_MEM_BANK_MAP_RGB];


    UCHAR               mem_bank_raw[E_MEM_BANK_MAX];
    UCHAR               mem_bank_raw1[E_MEM_BANK_MAX];
    UCHAR               mem_bank_y[E_MEM_BANK_MAX];
    UCHAR               mem_bank_c[E_MEM_BANK_MAX];
    UCHAR               mem_bank_y_ch1[E_MEM_BANK_MAX];
    UCHAR               mem_bank_c_ch1[E_MEM_BANK_MAX];
    UCHAR               mem_bank_aeawb[E_MEM_BANK_MAX];
    UCHAR               mem_bank_map[E_MEM_BANK_MAX];
    UCHAR               mem_bank_map_rgb[E_MEM_BANK_MAX];
    
    UCHAR                mem_bank_raw_num;
    UCHAR                mem_bank_yc_num;
    UCHAR               mem_bank_yc_ch1_num;
    UCHAR                mem_bank_map_num;
    UCHAR                mem_bank_map_rgb_num;

    ULONG               addr_custom_raw_ch;     //last addr
    UCHAR               mem_bank_custom_raw_ch[E_MEM_BANK_MAX]; //mem addr index
    UCHAR                mem_bank_custom_raw_num;
    ULONG               mem_addr_custom_addr_c;
} T_SENSOR2YUV_MNG;


static T_SENSOR2YUV_MNG             g_s2y_mng;

int main(int argc, char *argv[])
{
    int temp = -1;

    printf("%d\n", g_s2y_mng.mem_bank_y[E_MEM_BANK_SET]);    // 0
    printf("%d\n", g_s2y_mng.mem_bank_y[E_MEM_BANK_ING]);    // 0
    printf("%d\n", g_s2y_mng.mem_bank_y[E_MEM_BANK_RCV]);    // 0
    printf("%d\n", BANK_ING_TO_RCV(g_s2y_mng.mem_bank_y));    // 0
    
    g_s2y_mng.mem_addr_y[0] = 0xaaaaaaaa;
    g_s2y_mng.mem_addr_y[1] = 0xbbbbbbbb;
    g_s2y_mng.mem_addr_y[2] = 0xcccccccc;
    g_s2y_mng.mem_addr_y[3] = 0xdddddddd;

    temp = g_s2y_mng.mem_addr_y[g_s2y_mng.mem_bank_y[E_MEM_BANK_RCV]];
    printf("%#x\n", temp);    // 0xaaaaaaaa

    return 0;
}
 

你可能感兴趣的:(Assembly,c语言,汇编)