Advertisement
Guest User

PSPEmu Mount Point Method By TheFloW

a guest
Nov 8th, 2015
1,041
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.73 KB | None | 0 0
  1. #define MAX_LOADED_MODS 256
  2.  
  3. static int (* _sceAppMgrPspSaveDataRootMount)(char *mount_point);
  4.  
  5. /*
  6.     Find the address of the module by name
  7. */
  8. uint32_t findModuleAddressByName(char *name) {
  9.     SceUID mod_list[MAX_LOADED_MODS];
  10.     unsigned int num_loaded = MAX_LOADED_MODS;
  11.  
  12.     if (sceKernelGetModuleList(0xFF, mod_list, &num_loaded) >= 0) {
  13.         int i;
  14.         for (i = 0; i < num_loaded; i++) {
  15.             Psp2LoadedModuleInfo info;
  16.             info.size = sizeof(info);
  17.             if (sceKernelGetModuleInfo(mod_list[i], &info) >= 0) {
  18.                 if (strcmp(info.module_name, name) == 0) {
  19.                     return (uint32_t)info.segments[0].vaddr;
  20.                 }
  21.             }
  22.         }
  23.     }
  24.  
  25.     return 0;
  26. }
  27.  
  28. /*
  29.     Simple method to find our desired syscall. Should support 3.18-3.51 (firmwares below aren't tested yet)
  30. */
  31. void findSceAppUtilFunctions() {
  32.     uint32_t text_addr = findModuleAddressByName("SceAppUtil");
  33.  
  34.     uint32_t SceAppMgr_text_addr = 0;
  35.     uint32_t SceAppMgr_imports_addr = 0;
  36.  
  37.     uint32_t i;
  38.     for (i = 0; i < 0x10000; i += 4) {
  39.         if (SceAppMgr_text_addr) {
  40.             if (*(uint32_t *)(text_addr + i) == SceAppMgr_text_addr) {
  41.                 SceAppMgr_imports_addr = *(uint32_t *)(text_addr + i + 0xC);
  42.                 break;
  43.             }
  44.         } else {
  45.             if (strcmp((char *)(text_addr + i), "SceAppMgr") == 0) {
  46.                 SceAppMgr_text_addr = text_addr + i;
  47.                 i = 0;
  48.                 continue;
  49.             }
  50.         }
  51.     }
  52.  
  53.     if (SceAppMgr_imports_addr) {
  54.         _sceAppMgrPspSaveDataRootMount = (void *)(*(uint32_t *)(SceAppMgr_imports_addr - 0x14));
  55.     }
  56. }
  57.  
  58. /*
  59.     Get pspemu mount point
  60. */
  61. char mount_point[16];
  62. memset(mount_point, 0, sizeof(mount_point));
  63. _sceAppMgrPspSaveDataRootMount(mount_point);
  64.  
  65. /*
  66.     Demonstration of the mount point :)
  67.     'path' is now equivalent to ms0:/hello_world.bin
  68. */
  69.  
  70. char path[128];
  71. sprintf(path, "%s/hello_world.bin", mount_point);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement