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