title: Get size of x86-64 instruction
body: <p>I need a function which can calculate the length of an x86-64 instruction.</p>
  
  <p>For example, it would be usable like so:</p>
  
  <pre><code>char ret[] = { 0xc3 };
  size_t length = instructionLength(ret);
  </code></pre>
  
  <p><code>length</code> would be set to 1 in this example.</p>
  
  <p>I do not want to include an entire disassembly library, since the only information I require is the length of the instruction.</p>
  
  <p>I am looking for a minimalist approach, written in C, and ideally as small as possible.</p>
  
  <p>100% complete x86-64 instruction set is not strictly necessary (very obscure ones such as vector register set instructions can be omitted).</p>
  
  <p>A similar answer to what I am looking for (but for the wrong architecture):</p>
  
  <p><a href="https://stackoverflow.com/questions/23788236/get-size-of-assembly-instructions/23843450#23843450">Get size of assembly instructions</a></p>