Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.66 KB | None | 0 0
  1. To test path redirections:
  2.  
  3.     // struct for 3 paths
  4.  
  5.     typedef struct
  6.     {
  7.         path_open_entry entries[4];
  8.  
  9.         char arena[0x2000];
  10.     } path_open_table;
  11.  
  12.     path_open_table open_table;
  13.  
  14.     uint64_t dest_table_addr;
  15.  
  16.     ..................................................
  17.  
  18.     // disable table
  19.  
  20.     printf(" last table %llx\n", sys8_path_table(0ULL));
  21.  
  22.     // calculate dest_table addr from payload start to back
  23.  
  24.     dest_table_addr= 0x80000000007FF000ULL-((sizeof(path_open_table)+15) & ~15);
  25.  
  26.     // fix the start addresses
  27.  
  28.     open_table.entries[0].compare_addr= ((uint64_t) &open_table.arena[0]) - ((uint64_t) &open_table) + dest_table_addr;
  29.     open_table.entries[0].replace_addr= ((uint64_t) &open_table.arena[0x800])- ((uint64_t) &open_table) + dest_table_addr;
  30.  
  31.     open_table.entries[1].compare_addr= ((uint64_t) &open_table.arena[0x100]) - ((uint64_t) &open_table) + dest_table_addr;
  32.     open_table.entries[1].replace_addr= ((uint64_t) &open_table.arena[0x1000])- ((uint64_t) &open_table) + dest_table_addr;
  33.  
  34.     open_table.entries[2].compare_addr= ((uint64_t) &open_table.arena[0x200]) - ((uint64_t) &open_table) + dest_table_addr;
  35.     open_table.entries[2].replace_addr= ((uint64_t) &open_table.arena[0x1800])- ((uint64_t) &open_table) + dest_table_addr;
  36.  
  37.     open_table.entries[3].compare_addr= 0ULL; // the last entry always 0
  38.  
  39.     // copy the paths
  40.  
  41.     strncpy(&open_table.arena[0], "/app_home/PS3_GAME/USRDIR", 0x100);           // compare 1
  42.     strncpy(&open_table.arena[0x800], "/dev_usb000/PS3_GAME/USRDIR", 0x800);     // replace 1: replaces all content or USRDIR
  43.  
  44.     strncpy(&open_table.arena[0x100], "/app_home/PS3_GAME/ICON0.PNG", 0x100);    // compare 2
  45.     strncpy(&open_table.arena[0x1000], "/dev_usb000/PS3_GAME/ICON0.PNG", 0x800); // replace 2: replace only ICON0.PNG
  46.  
  47.     strncpy(&open_table.arena[0x200], "/app_home/PS3_GAME/ICO", 0x100);          // compare 3
  48.     strncpy(&open_table.arena[0x1800], "/dev_usb000/PS3_GAME/ICON0.PNG", 0x800); // replace 3: // replace all ICONxxxx by ICON0.PNG
  49.  
  50.  
  51.     // fix the string len
  52.  
  53.     open_table.entries[0].compare_len= strlen(&open_table.arena[0]);        // 1
  54.     open_table.entries[0].replace_len= strlen(&open_table.arena[0x800]);
  55.    
  56.     open_table.entries[1].compare_len= strlen(&open_table.arena[0x100]);    // 2
  57.     open_table.entries[1].replace_len= strlen(&open_table.arena[0x1000]);
  58.  
  59.     open_table.entries[2].compare_len= strlen(&open_table.arena[0x200]);    // 3
  60.     open_table.entries[2].replace_len= strlen(&open_table.arena[0x1800]) +1; // truncate the name because it skip  '\0'
  61.  
  62.     // copy the datas to  the destination address
  63.  
  64.     sys8_memcpy(dest_table_addr, (uint64_t) &open_table, sizeof(path_open_table));
  65.  
  66.     // set the path table
  67.     sys8_path_table( dest_table_addr));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement