Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.02 KB | None | 0 0
  1. u32 handleAccess(struct pt_regs info){
  2.     //__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "PC passed is: 0x%x", info.ARM_pc);
  3.     u32 instruction = *((u32*)info.ARM_pc);
  4.     if((info.ARM_pc & 0x00000001) == 1){ //THUMB mode
  5.         __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Thumb mode");
  6.  
  7.     }else{
  8.         if((instruction & 0x0C000000) == 0x04000000){   //If it's a word load/store
  9.             u32 addr = info.uregs[(instruction & 0x000F0000) >> 16] + instruction & 0x00000FFF;
  10.             __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Accessed addr is 0x%x",addr);
  11.             if((instruction & 0x00100000) == 0x00000000){ //It's a store (bit 20 is 0)
  12.                 __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Storing word");
  13.                 u32 src_reg = (instruction & 0x0000F000) >> 12;
  14.                 storeWord(info.uregs[src_reg], addr);
  15.             }
  16.             if((instruction & 0x00100000) == 0x00100000){ //It's a load (bit 20 is 0)
  17.                 __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Loading word");
  18.                 u32 dest_reg = (instruction & 0x0000F000) >> 12;
  19.                 loadWord(addr);
  20.             }
  21.  
  22.             //return info.uregs[(instruction & 0xFFFE0000) >> 16] + (instruction & 0x7FF);//return reg + offset
  23.             //__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Reg index is %i",(instruction & 0x000F0000) >> 15);
  24.             __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Addr Reg index is 0x%x",(instruction & 0x000F0000) >> 16);
  25.             __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Dest Reg index is 0x%x",(instruction & 0x0000F000) >> 12);
  26.             __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Accessed addr is 0x%x",addr);
  27.             return addr;
  28.             //return info.uregs[(instruction & 0x000F0000) >> 15] + (instruction & 0xFFF);//return reg + offset
  29.             return 0x0;//return reg + offset
  30.         }
  31.         __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Unknown instruction: 0x%x", instruction);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement