Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- u32 handleAccess(struct pt_regs info){
- //__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "PC passed is: 0x%x", info.ARM_pc);
- u32 instruction = *((u32*)info.ARM_pc);
- if((info.ARM_pc & 0x00000001) == 1){ //THUMB mode
- __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Thumb mode");
- }else{
- if((instruction & 0x0C000000) == 0x04000000){ //If it's a word load/store
- u32 addr = info.uregs[(instruction & 0x000F0000) >> 16] + instruction & 0x00000FFF;
- __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Accessed addr is 0x%x",addr);
- if((instruction & 0x00100000) == 0x00000000){ //It's a store (bit 20 is 0)
- __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Storing word");
- u32 src_reg = (instruction & 0x0000F000) >> 12;
- storeWord(info.uregs[src_reg], addr);
- }
- if((instruction & 0x00100000) == 0x00100000){ //It's a load (bit 20 is 0)
- __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Loading word");
- u32 dest_reg = (instruction & 0x0000F000) >> 12;
- loadWord(addr);
- }
- //return info.uregs[(instruction & 0xFFFE0000) >> 16] + (instruction & 0x7FF);//return reg + offset
- //__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Reg index is %i",(instruction & 0x000F0000) >> 15);
- __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Addr Reg index is 0x%x",(instruction & 0x000F0000) >> 16);
- __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Dest Reg index is 0x%x",(instruction & 0x0000F000) >> 12);
- __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Accessed addr is 0x%x",addr);
- return addr;
- //return info.uregs[(instruction & 0x000F0000) >> 15] + (instruction & 0xFFF);//return reg + offset
- return 0x0;//return reg + offset
- }
- __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Unknown instruction: 0x%x", instruction);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement