Silicaly

Untitled

Jan 13th, 2019
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.41 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4.  
  5. #include <vitasdk.h>
  6. #include "graphics.h"
  7.  
  8. #define printf psvDebugScreenPrintf
  9. int ret;
  10.  
  11. int hasEndSlash(const char *path) {
  12.     return path[strlen(path) - 1] == '/';
  13. }
  14.  
  15. int removePath(const char *path) {
  16.     psvDebugScreenPrintf("Deleting: %s\n", path);
  17.     SceUID dfd = sceIoDopen(path);
  18.     if (dfd >= 0) {
  19.         int res = 0;
  20.  
  21.         do {
  22.             SceIoDirent dir;
  23.             memset(&dir, 0, sizeof(SceIoDirent));
  24.  
  25.             res = sceIoDread(dfd, &dir);
  26.             if (res > 0) {
  27.                 char *new_path = malloc(strlen(path) + strlen(dir.d_name) + 2);
  28.                 snprintf(new_path, 1024 - 1, "%s%s%s", path, hasEndSlash(path) ? "" : "/", dir.d_name);
  29.  
  30.                 if (SCE_S_ISDIR(dir.d_stat.st_mode)) {
  31.                     int ret = removePath(new_path);
  32.                     if (ret <= 0) {
  33.                         free(new_path);
  34.                         sceIoDclose(dfd);
  35.                         return ret;
  36.                     }
  37.                 } else {
  38.                     int ret = sceIoRemove(new_path);
  39.                     if (ret < 0) {
  40.                         free(new_path);
  41.                         sceIoDclose(dfd);
  42.                         return ret;
  43.                     }
  44.                 }
  45.                 free(new_path);
  46.             }
  47.         } while (res > 0);
  48.  
  49.         sceIoDclose(dfd);
  50.  
  51.         int ret = sceIoRmdir(path);
  52.         if (ret < 0)
  53.             return ret;
  54.     } else {
  55.         int ret = sceIoRemove(path);
  56.         if (ret < 0)
  57.             return ret;
  58.     }
  59.  
  60.     return 1;
  61. }
  62.  
  63.  
  64. int WriteFile(char *file, void *buf, int size) {
  65.     SceUID fd = sceIoOpen(file, SCE_O_RDWR | SCE_O_CREAT, 0777);
  66.     if (fd < 0)
  67.         return fd;
  68.  
  69.     int written = sceIoWrite(fd, buf, size);
  70.  
  71.     sceIoClose(fd);
  72.     return written;
  73. }
  74.  
  75. int ReadFile(char *file, void *buf, int size) {
  76.     SceUID fd = sceIoOpen(file,SCE_O_RDONLY, 0777);
  77.     if (fd < 0)
  78.         return fd;
  79.  
  80.     int read = sceIoRead(fd, buf, size);
  81.  
  82.     sceIoClose(fd);
  83.     return read;
  84. }
  85.  
  86. int getFileSize(const char *file) {
  87.     SceUID fd = sceIoOpen(file, SCE_O_RDONLY, 0);
  88.     if (fd < 0)
  89.         return fd;
  90.     int fileSize = sceIoLseek(fd, 0, SCE_SEEK_END);
  91.     sceIoClose(fd);
  92.     return fileSize;
  93. }
  94.  
  95. int vshIoMount(int id, const char *path, int permission, int a4, int a5, int a6) {
  96.   uint32_t buf[3];
  97.  
  98.   buf[0] = a4;
  99.   buf[1] = a5;
  100.   buf[2] = a6;
  101.  
  102.   return _vshIoMount(id, path, permission, buf);
  103. }
  104.  
  105. void blockUpdates(){
  106.     psvDebugScreenInit();
  107.     psvDebugScreenClear(0);
  108.  
  109.     ret = vshIoUmount(0x300, 0, 0, 0);
  110.     printf("Unmount1 %x\n",ret);
  111.    
  112.     ret = vshIoUmount(0x300, 1, 0, 0);
  113.     printf("Unmount2 %x\n",ret);
  114.    
  115.     ret = vshIoMount(0x300, NULL, 2, 0, 0, 0);
  116.     printf("Mount vs0 RW %x\n",ret);
  117.     //Remount vs0 with R/W Permissions.
  118.    
  119.    
  120.     ret = sceIoRename("vs0:/app/NPXS10015/system_update_plugin.rco", "vs0:/app/NPXS10015/cute_girls_dying_plugin.rco.disabled");
  121.     printf("sceIoRename = %x\n",ret);
  122.    
  123.     if(ret == 0x00){
  124.         printf("-- Blocked \"System Update\" option successfully! ---\n");
  125.         printf("Console rebooting in 5 seconds . . .\n");
  126.        
  127.         sceKernelDelayThread(5000000);
  128.         scePowerRequestColdReset();
  129.     }
  130.    
  131. }
  132.  
  133. void unblockUpdates(){
  134.     psvDebugScreenInit();
  135.     psvDebugScreenClear(0);
  136.  
  137.     ret = vshIoUmount(0x300, 0, 0, 0);
  138.     printf("Unmount1 %x\n",ret);
  139.    
  140.     ret = vshIoUmount(0x300, 1, 0, 0);
  141.     printf("Unmount2 %x\n",ret);
  142.    
  143.     ret = vshIoMount(0x300, NULL, 2, 0, 0, 0);
  144.     printf("Mount vs0 RW %x\n",ret);
  145.     //Remount vs0 with R/W Permissions.
  146.    
  147.     sceKernelDelayThread(1000);
  148.    
  149.     ret = sceIoRename("vs0:/app/NPXS10015/cute_girls_dying_plugin.rco.disabled","vs0:/app/NPXS10015/system_update_plugin.rco");
  150.     printf("sceIoRename = %x\n",ret);
  151.    
  152.     if(ret == 0x00){
  153.         printf("-- Unblocked \"System Update\" option successfully! ---\n");
  154.         printf("Console rebooting in 5 seconds . . .\n");
  155.        
  156.         sceKernelDelayThread(5000000);
  157.         scePowerRequestColdReset();
  158.     }
  159.    
  160. }
  161.  
  162. void blockDownloads(){
  163.     psvDebugScreenInit();
  164.     psvDebugScreenClear(0);
  165.  
  166.     ret = sceRegMgrSetKeyInt("/CONFIG/NP2/AUTOUPDATE","system",0);
  167.     printf("sceRegMgrSetKeyInt ret %x\n",ret);
  168.    
  169.     ret = removePath("ur0:/bgdl/");
  170.     printf("removePath ret %x\n",ret);
  171.    
  172.     char buf[0x1];
  173.     memset(buf,0x00,0x1);
  174.     ret = WriteFile("ur0:/bgdl",&buf,0x1);
  175.     printf("WriteFile ret %x\n",ret);
  176.    
  177.     printf("-- Update Downloads have been blocked! --\n");
  178.     sceKernelDelayThread(5000000);
  179.     main();
  180. }
  181.  
  182.  
  183. void unblockDownloads(){
  184.     psvDebugScreenInit();
  185.     psvDebugScreenClear(0);
  186.  
  187.     ret = sceRegMgrSetKeyInt("/CONFIG/NP2/AUTOUPDATE","system",1);
  188.     printf("sceRegMgrSetKeyInt ret %x\n",ret);
  189.    
  190.     ret = sceIoRemove("ur0:/bgdl");
  191.     printf("removePath ret %x\n",ret);
  192.    
  193.     printf("-- Update Downloads have been unblocked! --\n");
  194.     sceKernelDelayThread(5000000);
  195.     main();
  196. }
  197. int main() {
  198.         psvDebugScreenInit();
  199.         psvDebugScreenClear(0);
  200.         psvDebugScreenPrintf("--- Vita Update Blocker ---\n");
  201.         psvDebugScreenPrintf("CROSS: Block \"System Update\" in Settings\n");
  202.         psvDebugScreenPrintf("CIRCLE: Unblock \"System Update\" in Settings\n");
  203.         psvDebugScreenPrintf("SQUARE: Block update downloads\n");
  204.         psvDebugScreenPrintf("TRIANGLE: Unblock update downloads\n");
  205.        
  206.         sceKernelDelayThread(100000);
  207.         while(1)
  208.         {
  209.         switch(get_key(0)) {
  210.                 case SCE_CTRL_CROSS:
  211.                     blockUpdates();
  212.                     break;
  213.                 case SCE_CTRL_CIRCLE:
  214.                     unblockUpdates();
  215.                     break;
  216.                 case SCE_CTRL_SQUARE:
  217.                     blockDownloads();
  218.                     break;
  219.                 case SCE_CTRL_TRIANGLE:
  220.                    
  221.                     break;
  222.                 default:
  223.                     break;
  224.                 }
  225.         }
  226.        
  227.  
  228.        
  229.         return 0;
  230. }
Advertisement
Add Comment
Please, Sign In to add comment