title: python PeFile print bytes of section
body: <p>I am wanting to print the bytes in the range of a particular header. I am using Pefile in python to get the location, and as I understand , it should be trivial to do this, but the address I receive is a virtual address meaning I have the binary loaded in memory.</p>
  <pre><code>import pefile
  pe = pefile.PE(&quot;/home/luser/mybinary.exe&quot;)
  
  for entry in pe.OPTIONAL_HEADER.DATA_DIRECTORY:
      print(entry.name + &quot;\n|\n|---- Size : &quot; + str(entry.Size) + &quot;\n|\n|---- VirutalAddress : &quot; + hex(entry.VirtualAddress) +'\n')
  </code></pre>
  <p>Section in question:</p>
  <pre><code>IMAGE_DIRECTORY_ENTRY_EXCEPTION
  |
  |---- Size : 660
  |
  |---- VirutalAddress : 0x6000
  </code></pre>
  <p>I am not certain if it is relevant , but this section is populated in 64 bit binaries for holding exception tables.</p>
  <p>if it is relevant here is some test code for this</p>
  <pre><code>#include &lt;stdexcept&gt; 
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  bool myfunction(const std::string&amp; str) {
      if (str == &quot;true&quot;)
          return true;
  
      else if (str == &quot;false&quot;)
          return false;
  
      else
          throw std::invalid_argument(&quot;Expected true or false&quot;);
  }
  
  
  int main(int argc, const char** argv) {
      try {
          const bool check = myfunction(&quot;not true&quot;);
      }
  
      catch (std::invalid_argument&amp; error) {
          std::cerr &lt;&lt; error.what() &lt;&lt; '\n';
      }
      return 0;
  }
  </code></pre>