Advertisement
Madmouse

scaning for breakpoints on x86_64 in memmory

Jan 31st, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. /*
  2. ; bool scan(void* code, unsigned int depth);
  3. scan:
  4.    mov rcx, rsi   ; move size argument into rcx for the loop
  5.    mov rsi, rdi   ; move the the text pointer to rsi for printing
  6. loop:
  7.    cmp byte [rsi], 0xCC ; check for break point
  8.    je fuck_you
  9.    inc rsi
  10. loop loop
  11.    xor rdi, rdi
  12.    ret
  13. fuck_you:
  14.    xor rdi, rdi
  15.    mov al, 1
  16.    ret
  17. */
  18.  
  19. bool scan_for_breakpoints(void (*fun), int depth)   /// scans a section of a function for break points
  20. {
  21.     int i;
  22.     for(i=0;i<=depth;i++)   /// count from offset start to depth
  23.     {
  24.         unsigned int inst = (*(volatile unsigned int *)((unsigned int)fun + i) & 0xff); /// get the instruction
  25.         if (inst == 0xCC)   /// if this is a break point
  26.             return true;    /// return true
  27.     }
  28.     return false;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement