Advertisement
goroh_kun

n-04cのnandlock解除モジュールのソースその2

Oct 29th, 2011
2,102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.55 KB | None | 0 0
  1. /*
  2.  * system_unlock.c
  3.  */
  4.  
  5. #include <linux/kernel.h>
  6. #include <linux/module.h>
  7.  
  8. #define PATCHADDR 0xC05C2FA9
  9. #define PATCHADDR2 0xC05C2FB1
  10. #define LOCK_INFO_ADDR 0xC08FCEA8
  11.  
  12. static int s_patchaddr = PATCHADDR;
  13. static int s_lockinfoaddr = LOCK_INFO_ADDR;
  14. module_param_named(patchaddr, s_patchaddr, int, 0644);
  15. module_param_named(lockinfoaddr, s_lockinfoaddr, int, 0644);
  16.  
  17. #define NAND_LOCK_PARTITION_NUM     3
  18. struct nand_lock_info
  19. {
  20.     uint64_t            start_addr;
  21.     uint64_t            end_addr;
  22.     unsigned char       name[20];
  23. };
  24.  
  25. static struct nand_lock_info    msm_nand_lock_info_bak[NAND_LOCK_PARTITION_NUM];
  26. static unsigned int             msm_nand_lock_info_num_bak;
  27.  
  28.  
  29. static int __init system_unlock_init(void)
  30. {
  31.         int i;
  32.         unsigned char* mem = (void*)s_patchaddr;
  33.         if(strncmp("/system", mem, 8)){
  34.                 s_patchaddr = PATCHADDR2;
  35.                 mem = (void*)s_patchaddr;
  36.                 if(strncmp("/system", mem, 8)){
  37.                         printk(KERN_ERR "not match \"%s\"\n", mem);
  38.                         return -1;
  39.                 }
  40.         }
  41.         msm_nand_lock_info_num_bak = *(unsigned int*)(s_lockinfoaddr+0x78);
  42.         if(msm_nand_lock_info_num_bak > 3){
  43.                 printk(KERN_ERR "not match lock_info_num=%d\n",
  44.                         msm_nand_lock_info_num_bak);
  45.                 return -1;
  46.         }
  47.         printk(KERN_DEBUG "\"%s\" ->", mem);
  48.         mem[5] = 'o'; // "/system\0" -> "/systom\0"
  49.         printk(" \"%s\"\n", mem);
  50.         memcpy(msm_nand_lock_info_bak, (void*)s_lockinfoaddr, 0x78);
  51.         memset((void*)s_lockinfoaddr, 0, 0x78);
  52.         for(i=0; i<msm_nand_lock_info_num_bak; i++){
  53.                 printk("part[%d] : start=%llx, end=%llx, name=\"%s\"\n",
  54.                         i,
  55.                         msm_nand_lock_info_bak[i].start_addr,
  56.                         msm_nand_lock_info_bak[i].end_addr,
  57.                         msm_nand_lock_info_bak[i].name);
  58.         }
  59.         *(unsigned int*)(s_lockinfoaddr+0x78) = 0;
  60.         return 0;
  61. }
  62. module_init(system_unlock_init)
  63.  
  64. static void __exit system_unlock_exit(void)
  65. {
  66.         unsigned char* mem = (void*)s_patchaddr;
  67.         memcpy((void*)s_lockinfoaddr, msm_nand_lock_info_bak, 0x78);
  68.         *(unsigned int*)(s_lockinfoaddr+0x78) = msm_nand_lock_info_num_bak;
  69.         printk(KERN_DEBUG "\"%s\" ->", mem);
  70.         mem[5] = 'e'; // "/systom\0" -> "/system\0"
  71.         printk(" \"%s\"\n", mem);
  72. }
  73. module_exit(system_unlock_exit)
  74.  
  75. MODULE_LICENSE("GPL");
  76. MODULE_DESCRIPTION("unlock system permission");
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement