title: C++ How to control Image Base of LoadLibrary API
body: <p>After Rebasing the main program very high up in it's own imagebase.</p>
  
  <p>How do I guarantee that the dll that gets loaded will load in 0x400000</p>
  
  <pre><code>dllImageBase = LoadLibrary("test.dll");
  printf("imagebase = 0x%x", dllImageBase);
  </code></pre>
  
  <p>I always get 0x460000 instead of 0x400000</p>
  
  <p>I need my dll first instruction to start from 0x401000, it used to start at 0x600000 before rebasing</p>
  
  <p>Command for linker to rebase is</p>
  
  <pre><code>#pragma comment( linker, "/BASE:8000000") 
  </code></pre>
  
  <p>So 0x400000 is actually free right now yet it doesn't use it by default.. so any way I can control it, where it should relocate. Some WIN32API maybe?</p>