This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 25th, 2012  |  syntax: None  |  size: 2.29 KB  |  views: 142  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Author: Shadoxi
  2. // Modified: :)
  3.  
  4. // Backup the original /dev_flash/sys/external/libsysutil_np_trophy.sprx to /dev_hdd0
  5. // Replace /dev_blind/sys/external/libsysutil_np_trophy.sprx by this sprx
  6.  
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. #include <cell/error.h>
  12. #include <cell/cell_fs.h>
  13.  
  14. #include <sys/process.h>
  15. #include <sys/paths.h>
  16. #include <sys/prx.h>
  17. #include <sys/tty.h>
  18.  
  19. SYS_MODULE_INFO (sceNpTrophyhook, 0, 1, 0 );
  20. SYS_MODULE_START( _start );
  21. SYS_MODULE_STOP ( _stop  );
  22.  
  23. SYS_LIB_DECLARE( sceNpTrophyhook, SYS_LIB_AUTO_EXPORT | SYS_LIB_WEAK_IMPORT );
  24. SYS_LIB_EXPORT ( loader_sprx, sceNpTrophyhook );
  25.  
  26. int _start(void);
  27. int _stop(void);
  28. void DumpELF_Payload(void);
  29. void loader_sprx(const char* PATH_PRX);
  30.  
  31. static void write_message (char const * message)
  32. {
  33.         unsigned int write_length;
  34.         char const * end;
  35.         for (end = message; *end != '\0'; ++end);
  36.         sys_tty_write(SYS_TTYP_PPU_STDERR, message,end - message, &write_length);
  37. }
  38.  
  39. void DumpELF_Payload(void)
  40. {
  41.         write_message("Dumping ELF from RAM...\n");
  42.         int fd;
  43.         uint64_t nread;
  44.         uint64_t ptr= 0x00010000ULL;            //ELF offset in RAM;
  45.         uint64_t sizeelf = 35*1024*1024;        //Need a way to get size of ELF
  46.  
  47.         char dump_path[30]="/dev_hdd0/RAMDUMP-00.BIN";
  48.         for(uint8_t i=0; i<100; i++)
  49.         {
  50.                 dump_path[18]=0x30+i/10;
  51.                 dump_path[19]=0x30+i%10;
  52.                 if (cellFsOpen(dump_path, CELL_FS_O_RDONLY, &fd, NULL, 0) != CELL_FS_SUCCEEDED)
  53.                 {
  54.                         cellFsOpen(dump_path, CELL_FS_O_CREAT|CELL_FS_O_RDWR|CELL_FS_O_TRUNC, &fd, NULL, 0);
  55.                         cellFsWrite(fd, (void*)ptr, sizeelf, &nread);
  56.                         cellFsClose(fd);
  57.                         return;
  58.                 }
  59.                 else
  60.                         cellFsClose(fd);
  61.         }
  62.         return;
  63. }
  64.  
  65. void loader_sprx(const char* PATH_PRX)
  66. {
  67.         sys_prx_id_t prx_id ;
  68.         write_message ("Loading original prx... ");
  69.         prx_id = sys_prx_load_module(PATH_PRX, 0, NULL);
  70.         if (prx_id <= CELL_OK)
  71.         {
  72.                 write_message ("Failed!\n");
  73.                 return;
  74.         }
  75.         else
  76.                 write_message ("Done!\n\nStarting module... ");
  77.  
  78.         int modres;
  79.         if(sys_prx_start_module( prx_id, 0, NULL, &modres, 0, NULL) != CELL_OK)
  80.                 write_message ("Failed!\n");
  81. }
  82.  
  83. int _start(void)
  84. {
  85.         write_message ("By shadoxi\n");
  86.         DumpELF_Payload();
  87.  
  88.         // place here original libsysutil_np_trophy.sprx
  89.         loader_sprx("/dev_hdd0/libsysutil_np_trophy.sprx");
  90.  
  91.         return SYS_PRX_RESIDENT;
  92. }
  93.  
  94. int _stop(void)
  95. {
  96.         return SYS_PRX_STOP_OK;
  97. }
clone this paste RAW Paste Data