Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

il y a 5 ans
123456789101112131415161718192021222324252627282930313233343536
  1. x64hook is a hooking library for x64 code that aims to be able to patch everything!
  2. The general problems with hooking general functions are:
  3. 1) The code to be overwritten with the jump to your code has relative jumps (forward) or calls.
  4. Those need to be fixed in the trampoline. As the trampoline is probably out of reach for 32bit
  5. jumps all the fixed jumps need to be x64 RIP relative jumps.
  6. Conditional jumps are also handled - there are no jcc rel64 instructions though.
  7. That means that the condition is inverted as to jump, over the fixup code, further
  8. in the trampoline. The fixup code then is a unconditional 64bit jump.
  9. 2) The functions loops back into the code that has to be overwritten - that happens for functions
  10. with a loop (duh!) but also in case of tail-recursion optimization.
  11. Currently hooking such functions is not supported and in fact this is not even detected.
  12. Detection: Search for the end of the function (which has its own problems), keep track of all jumps into the
  13. first few bytes.
  14. 3) Other threads might try to execute the code as it is overwritten - if that happens shit hits the fan
  15. and the normal working of the application *will* be disrupted.
  16. There are two methods of overcoming that problem:
  17. a) "The stop-the-world approach" stops all threads to hinder them from executing.
  18. That makes the hooking time intensive and easily detectable.
  19. b) Writing all the problematic modifications atomically. That's not doable for > 8bytes.
  20. How is that write reflected in the instruction cache?
  21. Instruction fetches follow a different memory model (no lock/unlock & µOp Caches)
  22. c) The approach described in "Living on the edge: Rapid-toggline probes with cross modification on x86"
  23. Firstly writing a INT3 to the code which lets all other threads who execute that code jump into an newly
  24. installed execution handler with a spin loop until the hooking is done - i.e. execution can be safely
  25. resumed.
  26. Then the code is overwritten atomically with respect to cache lines.
  27. Lastly the exception handler is deactived.
  28. As this is a x64 hooking library running on x64 the overwritten code is fairly long, making the occurence of
  29. the problems detailed above very likely.