Search code examples
assemblysystem-callsmmap

Could you explain what mmap function do?


What does it do this assembly code? I've analyzed code and stopped at this moment. EDX is arg prot. ECX is arg length. ESI is arg flags. Am i right? But anyway i can't understand what does it do.

seg000:00000057                 push    ebp
seg000:00000058                 xor     ebp, ebp
seg000:0000005A                 xor     edi, edi
seg000:0000005C
seg000:0000005C 
seg000:0000005C                 dec     edi
seg000:0000005D                 mov     esi, 22h 
seg000:00000062                 mov     edx, 7    
seg000:00000067                 mov     ecx, 1000h      
seg000:0000006C                 xor     ebx, ebx        
seg000:0000006E                 mov     eax, 0C0h       
seg000:00000073                 int     80h       ;mmap      
seg000:00000075                 pop     ebp
seg000:00000076                 mov     edi, eax

Solution

  • It calls mmap(NULL, 0x1000, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) which creates a single page of virtual memory and returns the virtual address of the page. If you want to know more about what mmap does, see https://linux.die.net/man/2/mmap.