title: NASM linking libraries during runtime
body: <p>This post on windows shellcoding that i came across shows how to make a simple shellcode for Sleep function that is located in kernel32.dll. I understand the code but it seems as though that you can't call the function without knowing the exact address of the function in the library for which you have to use <code>arwin32.exe</code> that's provided by the author of the post.</p>
  
  <pre><code>;sleep.asm
  [SECTION .text]
  
  global _start
  
  
  _start:
          xor eax,eax
          mov ebx, 0x77e61bea ;address of Sleep
          mov ax, 5000        ;pause for 5000ms
          push eax
          call ebx        ;Sleep(ms);
  </code></pre>
  
  <p><a href="http://www.vividmachines.com/shellcode/shellcode.html#win32ex1" rel="nofollow">Shellcoding for Linux and Windows</a></p>
  
  <p>In MASM32, one simply includes the libraries and dll's but I don't know if this is the same case in NASM, i tried to include kernel32.lib using RadAasm but got error.</p>
  
  <p>Undefined Reference to Sleep.</p>
  
  <p>My question is: How would one call the Sleep function in NASM without knowing the exact address of any of the functions, neither GetProcAddress or the like.</p>
  
  <p>NOTE: Even the other examples, he provides absolute addresses for the functions.</p>