disassemble.rs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2017 Quentin Monnet <quentin.monnet@6wind.com>
  2. //
  3. // Licensed under the Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0> or
  4. // the MIT license <http://opensource.org/licenses/MIT>, at your option. This file may not be
  5. // copied, modified, or distributed except according to those terms.
  6. extern crate rbpf;
  7. use rbpf::disassembler;
  8. // Simply disassemble a program into human-readable instructions.
  9. fn main() {
  10. let prog = vec![
  11. 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  12. 0x79, 0x12, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
  13. 0x79, 0x11, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
  14. 0xbf, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  15. 0x07, 0x03, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00,
  16. 0x2d, 0x23, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00,
  17. 0x69, 0x12, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
  18. 0x55, 0x02, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00,
  19. 0x71, 0x12, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00,
  20. 0x55, 0x02, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x00,
  21. 0x18, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
  22. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  23. 0x79, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,
  24. 0xbf, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  25. 0x57, 0x02, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
  26. 0x15, 0x02, 0x08, 0x00, 0x99, 0x99, 0x00, 0x00,
  27. 0x18, 0x02, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
  28. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  29. 0x5f, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  30. 0xb7, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
  31. 0x18, 0x02, 0x00, 0x00, 0x00, 0x00, 0x99, 0x99,
  32. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  33. 0x1d, 0x21, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  34. 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  35. 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  36. ];
  37. disassembler::disassemble(&prog);
  38. }