x86/x64 アセンブリ文字列をオペコードにアセンブルするための C ライブラリはありますか?
コード例:
/* size_t assemble(char *string, int asm_flavor, char *out, size_t max_size); */
unsigned char bytes[32];
size_t size = assemble("xor eax, eax\n"
"inc eax\n"
"ret",
asm_x64, &bytes, 32);
for(int i = 0; i < size; i++) {
printf("%02x ", bytes[i]);
}
/* Output: 31 C0 40 C3 */
asmpureを見てきましたが、Windows 以外のマシンで実行するには変更が必要です。
実際にはアセンブラと逆アセンブラの両方が必要ですが、両方を提供するライブラリはありますか?