Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <string.h>
- #include <stdio.h>
- #include <vitasdk.h>
- #include "graphics.h"
- #define printf psvDebugScreenPrintf
- int ret;
- int hasEndSlash(const char *path) {
- return path[strlen(path) - 1] == '/';
- }
- int removePath(const char *path) {
- psvDebugScreenPrintf("Deleting: %s\n", path);
- SceUID dfd = sceIoDopen(path);
- if (dfd >= 0) {
- int res = 0;
- do {
- SceIoDirent dir;
- memset(&dir, 0, sizeof(SceIoDirent));
- res = sceIoDread(dfd, &dir);
- if (res > 0) {
- char *new_path = malloc(strlen(path) + strlen(dir.d_name) + 2);
- snprintf(new_path, 1024 - 1, "%s%s%s", path, hasEndSlash(path) ? "" : "/", dir.d_name);
- if (SCE_S_ISDIR(dir.d_stat.st_mode)) {
- int ret = removePath(new_path);
- if (ret <= 0) {
- free(new_path);
- sceIoDclose(dfd);
- return ret;
- }
- } else {
- int ret = sceIoRemove(new_path);
- if (ret < 0) {
- free(new_path);
- sceIoDclose(dfd);
- return ret;
- }
- }
- free(new_path);
- }
- } while (res > 0);
- sceIoDclose(dfd);
- int ret = sceIoRmdir(path);
- if (ret < 0)
- return ret;
- } else {
- int ret = sceIoRemove(path);
- if (ret < 0)
- return ret;
- }
- return 1;
- }
- int WriteFile(char *file, void *buf, int size) {
- SceUID fd = sceIoOpen(file, SCE_O_RDWR | SCE_O_CREAT, 0777);
- if (fd < 0)
- return fd;
- int written = sceIoWrite(fd, buf, size);
- sceIoClose(fd);
- return written;
- }
- int ReadFile(char *file, void *buf, int size) {
- SceUID fd = sceIoOpen(file,SCE_O_RDONLY, 0777);
- if (fd < 0)
- return fd;
- int read = sceIoRead(fd, buf, size);
- sceIoClose(fd);
- return read;
- }
- int getFileSize(const char *file) {
- SceUID fd = sceIoOpen(file, SCE_O_RDONLY, 0);
- if (fd < 0)
- return fd;
- int fileSize = sceIoLseek(fd, 0, SCE_SEEK_END);
- sceIoClose(fd);
- return fileSize;
- }
- int vshIoMount(int id, const char *path, int permission, int a4, int a5, int a6) {
- uint32_t buf[3];
- buf[0] = a4;
- buf[1] = a5;
- buf[2] = a6;
- return _vshIoMount(id, path, permission, buf);
- }
- void blockUpdates(){
- psvDebugScreenInit();
- psvDebugScreenClear(0);
- ret = vshIoUmount(0x300, 0, 0, 0);
- printf("Unmount1 %x\n",ret);
- ret = vshIoUmount(0x300, 1, 0, 0);
- printf("Unmount2 %x\n",ret);
- ret = vshIoMount(0x300, NULL, 2, 0, 0, 0);
- printf("Mount vs0 RW %x\n",ret);
- //Remount vs0 with R/W Permissions.
- ret = sceIoRename("vs0:/app/NPXS10015/system_update_plugin.rco", "vs0:/app/NPXS10015/cute_girls_dying_plugin.rco.disabled");
- printf("sceIoRename = %x\n",ret);
- if(ret == 0x00){
- printf("-- Blocked \"System Update\" option successfully! ---\n");
- printf("Console rebooting in 5 seconds . . .\n");
- sceKernelDelayThread(5000000);
- scePowerRequestColdReset();
- }
- }
- void unblockUpdates(){
- psvDebugScreenInit();
- psvDebugScreenClear(0);
- ret = vshIoUmount(0x300, 0, 0, 0);
- printf("Unmount1 %x\n",ret);
- ret = vshIoUmount(0x300, 1, 0, 0);
- printf("Unmount2 %x\n",ret);
- ret = vshIoMount(0x300, NULL, 2, 0, 0, 0);
- printf("Mount vs0 RW %x\n",ret);
- //Remount vs0 with R/W Permissions.
- sceKernelDelayThread(1000);
- ret = sceIoRename("vs0:/app/NPXS10015/cute_girls_dying_plugin.rco.disabled","vs0:/app/NPXS10015/system_update_plugin.rco");
- printf("sceIoRename = %x\n",ret);
- if(ret == 0x00){
- printf("-- Unblocked \"System Update\" option successfully! ---\n");
- printf("Console rebooting in 5 seconds . . .\n");
- sceKernelDelayThread(5000000);
- scePowerRequestColdReset();
- }
- }
- void blockDownloads(){
- psvDebugScreenInit();
- psvDebugScreenClear(0);
- ret = sceRegMgrSetKeyInt("/CONFIG/NP2/AUTOUPDATE","system",0);
- printf("sceRegMgrSetKeyInt ret %x\n",ret);
- ret = removePath("ur0:/bgdl/");
- printf("removePath ret %x\n",ret);
- char buf[0x1];
- memset(buf,0x00,0x1);
- ret = WriteFile("ur0:/bgdl",&buf,0x1);
- printf("WriteFile ret %x\n",ret);
- printf("-- Update Downloads have been blocked! --\n");
- sceKernelDelayThread(5000000);
- main();
- }
- void unblockDownloads(){
- psvDebugScreenInit();
- psvDebugScreenClear(0);
- ret = sceRegMgrSetKeyInt("/CONFIG/NP2/AUTOUPDATE","system",1);
- printf("sceRegMgrSetKeyInt ret %x\n",ret);
- ret = sceIoRemove("ur0:/bgdl");
- printf("removePath ret %x\n",ret);
- printf("-- Update Downloads have been unblocked! --\n");
- sceKernelDelayThread(5000000);
- main();
- }
- int main() {
- psvDebugScreenInit();
- psvDebugScreenClear(0);
- psvDebugScreenPrintf("--- Vita Update Blocker ---\n");
- psvDebugScreenPrintf("CROSS: Block \"System Update\" in Settings\n");
- psvDebugScreenPrintf("CIRCLE: Unblock \"System Update\" in Settings\n");
- psvDebugScreenPrintf("SQUARE: Block update downloads\n");
- psvDebugScreenPrintf("TRIANGLE: Unblock update downloads\n");
- sceKernelDelayThread(100000);
- while(1)
- {
- switch(get_key(0)) {
- case SCE_CTRL_CROSS:
- blockUpdates();
- break;
- case SCE_CTRL_CIRCLE:
- unblockUpdates();
- break;
- case SCE_CTRL_SQUARE:
- blockDownloads();
- break;
- case SCE_CTRL_TRIANGLE:
- break;
- default:
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment