About the usage of IDA

Тема в разделе "WASM.ENGLISH", создана пользователем dcskm4200, 27 сен 2005.

  1. dcskm4200

    dcskm4200 New Member

    Публикаций:
    0
    Регистрация:
    12 окт 2004
    Сообщения:
    173
    Адрес:
    China
    Hello,All



    the attachment txt is the dasm of a exe file.

    How I translate it into a source code?

    give me some methods



    1. How i distinguish the Local var and Global var?

    2. How i distinguish the independence var and struct var?



    [​IMG] 332477811__scr_2.txt
     
  2. _staier

    _staier New Member

    Публикаций:
    0
    Регистрация:
    3 окт 2003
    Сообщения:
    738
    Адрес:
    Ukraine
    ida dasm is a tasm source file that should be assembled in tasm with no trouble
     
  3. rmn

    rmn Well-Known Member

    Публикаций:
    0
    Регистрация:
    23 ноя 2004
    Сообщения:
    2.329


    Оптимист, однако :)
     
  4. Sergey_R

    Sergey_R Member

    Публикаций:
    0
    Регистрация:
    9 янв 2005
    Сообщения:
    138


    Local variales are put in stack and they are usually accessed by offset to 'EBP' or 'ESP' registers. Global variables are usually put in '.data' segment (or some others) and can be accessed directly by these address.
    Код (Text):
    1. ...
    2. sub_4012E0      proc near               ; DATA XREF: DialogFunc+46o
    3.  
    4.  FileName        = byte ptr -148h
    5.  var_44          = dword ptr -44h
    6. ...
    7.                  lea     eax, [ebp+FileName]
    8. ...
    9.                  push    [ebp+var_44]    ; HDC
    10. ...
    'FileName' and 'var_44' are local variables and
    Код (Text):
    1. ...
    2.                  mov     dword_4032E4, eax
    3.                  mov     dword_4032E8, eax
    4. ...
    'dword_4032E4' and 'dword_4032E8' are global variables.



    So if (for example) you call 'sub_4012E0' recursively you will have many _different_ sets of local variables but all instances will use the same variable dword_4032E4.





    I think it's impossible without some additional information. For example IDA (and you too) can recognize structure by API prototype:
    Код (Text):
    1. ...
    2.                  lea     eax, [ebp+Paint]
    3.                  push    eax             ; lpPaint
    4.                  push    [ebp+hDlg]      ; hWnd
    5.                  call    BeginPaint
    6.                  push    offset stru_4032F8 ; lpRect
    7.                  push    [ebp+hDlg]      ; hWnd
    8.                  call    GetClientRect
    9.                  push    [ebp+Paint.hdc] ; HDC
    10.                  call    CreateCompatibleDC
    11. ...


    When during program analysis you realize than some variables compose a structure you can tell IDA and the next time you will see not anonymous
    Код (Text):
    1. ...
    2.                  push    [ebp+var_40]
    3. ...
    but
    Код (Text):
    1. ...
    2.                  push    [ebp+Paint.hdc]
    3. ...
     
  5. dcskm4200

    dcskm4200 New Member

    Публикаций:
    0
    Регистрация:
    12 окт 2004
    Сообщения:
    173
    Адрес:
    China
    Thanks you who responsed the topic.



    it's a lot of usefully information.

    I forgot the rc file.



    regards

    [​IMG] _1775922375__rsrc.rc
     
  6. _staier

    _staier New Member

    Публикаций:
    0
    Регистрация:
    3 окт 2003
    Сообщения:
    738
    Адрес:
    Ukraine
    rmn

    я делал это несколько раз , причём однажды это была большая досовская программа

    она не работала потом как положено , но скомпилялась с полпинка