Can anyone explain the following code as it's an array in assembly. I can't understand can you help me to figure it out line by line.


enter image description here

Q.1) what does the 401024 & 40102E line does ?


The explanation is given in the book immediately following the listing (Practical Malware Analysis Chapter 6 page 128 "Recognizing C Code Constructs in Assembly"):

In this listing, the base address of array b corresponds to dword_40A000 , and the base address of array a corresponds to var_14 . Since these are both arrays of integers, each element is of size 4, although the instructions at 1 and 2 differ for accessing the two arrays. In both cases, ecx is used as the index, which is multiplied by 4 to account for the size of the elements. The resulting value is added to the base address of the array to access the proper array element.

  • How did you know that was the book in screenshot?
    – Biswapriyo
    Jul 6 '18 at 16:00
  • 4
    @Biswapriyo I have the book
    – julian
    Jul 6 '18 at 16:02
  • 1
    Ah, exact same question than index of array in assembly?. Possible duplicate...
    – perror
    Jul 6 '18 at 16:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.