IDA逆向:結構體的逆向


源代碼:

int _tmain(int argc, _TCHAR* argv[])
{
    struct v1 {
        int a;
        short b;
        char c;
        int d;
        double e;
    };
    v1* heap_struct = (v1*)malloc(sizeof(v1));
    heap_struct->a = 10;
    heap_struct->b = 20;
    heap_struct->c = 30;
    heap_struct->d = 40;
    heap_struct->e = 50;
    return 0;

}

逆向分析:

結構體中的數據字段是通過名稱訪問的,但編譯器將名稱訪問轉換為數字偏移
所以在反匯編中難以區別
堆分配結構體

push    24              ; Size
call    ds:__imp__malloc
add     esp, 4
cmp     esi, esp
call    j___RTC_CheckEsp
mov     [ebp+heap_struct], eax
mov     eax, [ebp+heap_struct]
mov     dword ptr [eax], 10
mov     eax, 20
mov     ecx, [ebp+heap_struct]
mov     [ecx+4], ax
mov     eax, [ebp+heap_struct]
mov     byte ptr [eax+6], 30
mov     eax, [ebp+heap_struct]
mov     dword ptr [eax+8], 40
mov     eax, [ebp+heap_struct]
fld     ds:__real@4049000000000000
fstp    qword ptr [eax+10h]
原類型     大小             偏移
int         4(dword)       0
short       2()            4
char        1byte6
int         4(dword)       8
double      8(qword)      16

  為默認4字節對齊

總結:全局和棧分配方式中的結構體 與  普通變量相似 難以區分


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM