libtakeover.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // libtakeover.hpp
  3. // libtakeover
  4. //
  5. // Created by tihmstar on 24.02.19.
  6. // Copyright © 2019 tihmstar. All rights reserved.
  7. //
  8. #ifndef libtakeover_hpp
  9. #define libtakeover_hpp
  10. #include <mach/mach.h>
  11. #include <vector>
  12. namespace tihmstar {
  13. typedef struct {
  14. mach_msg_header_t head;
  15. mach_msg_body_t msgh_body;
  16. char data[1024];
  17. } exceptmsg_t;
  18. class takeover{
  19. exceptmsg_t _emsg;
  20. mach_port_t _target;
  21. mach_port_t _marionetteThread;
  22. mach_port_t _exceptionHandler;
  23. mach_vm_address_t _remoteStack;
  24. const mach_vm_size_t _remoteStackSize = 0x4000;
  25. bool _isFakeThread;
  26. std::pair<int, kern_return_t> deinit(bool noDrop = false);
  27. public:
  28. takeover(mach_port_t target);
  29. uint64_t callfunc(void *addr, const std::vector<uint64_t> &x);
  30. bool kidnapThread();
  31. void readMem(void *remote, size_t size, void *outAddr);
  32. void writeMem(void *remote, size_t size, void *inAddr);
  33. void *allocMem(size_t size);
  34. void deallocMem(void *remote,size_t size);
  35. ~takeover();
  36. };
  37. };
  38. #endif /* libtakeover_hpp */