popsdeco

Untitled

Nov 1st, 2011
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <pspsdk.h>
  2. #include <pspkernel.h>
  3. #include <pspdebug.h>
  4. #include <pspctrl.h>
  5. #include <pspsuspend.h>
  6. #include <psppower.h>
  7.  
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <stdio.h>
  11.  
  12. //#define IMMEDIATE_SHUTDOWN
  13.  
  14. PSP_MODULE_INFO("PspShutdown", 0, 1, 1);
  15. PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
  16.  
  17. #define KERNELVERSION (sceKernelDevkitVersion()>>8)
  18. #define printf pspDebugScreenPrintf
  19.  
  20. #define PSP_FIRMWARE(f) ((((f >> 8) & 0xF) << 24) | (((f >> 4) & 0xF) << 16) | ((f & 0xF) << 8) | 0x10)
  21. static u32 GetSetBaseAddrNid(u32 HASH,u32 FW500,u32 FW620,u32 FW635,u32 FW660){
  22.     u32 devkit = sceKernelDevkitVersion();
  23.     if(devkit<PSP_FIRMWARE(0x500))return HASH;
  24.     if(devkit<PSP_FIRMWARE(0x620))return FW500; //should be 0x555?
  25.     if(devkit<PSP_FIRMWARE(0x630))return FW620;
  26.     if(devkit<PSP_FIRMWARE(0x660))return FW635;
  27.     return FW660;
  28. }
  29.  
  30. int LoadStartModule(char *module, int partition){
  31.     //SceUID mod = kuKernelLoadModule(module, 0, NULL);
  32.     SceUID mod = sceKernelLoadModule(module, 0, NULL);
  33.  
  34.     if (mod < 0)
  35.         return mod;
  36.  
  37.     return sceKernelStartModule(mod, 0, NULL, NULL, NULL);
  38. }
  39.  
  40. int executeBasic(const char *path){
  41.     struct SceKernelLoadExecParam param;
  42.     memset(&param,0,sizeof(param));
  43.     param.argp=path;
  44.     param.args=strlen(path)+1;
  45.     param.key=NULL;//"game";
  46.     param.size=sizeof(param)+param.args;
  47.     return sceKernelLoadExec(path,&param);
  48. }
  49.  
  50. int main(int argc, char **argv){
  51. #ifdef IMMEDIATE_SHUTDOWN
  52.     scePowerRequestStandby();
  53. #else
  54.     pspDebugScreenInit();
  55.  
  56.     //SceUID mod = LoadStartModule("libpsardumper.prx", PSP_MEMORY_PARTITION_KERNEL);
  57.     //if (mod < 0)
  58.     //{
  59.     //  ErrorExit(5000, "Error 0x%08X loading/starting libpsardumper.prx.\n", mod);
  60.     //}
  61.  
  62.     //mod = LoadStartModule("pspdecrypt.prx", PSP_MEMORY_PARTITION_KERNEL);
  63.     //if (mod < 0)
  64.     //{
  65.     //  ErrorExit(5000, "Error 0x%08X loading/starting pspdecrypt.prx.\n", mod);
  66.     //}
  67.  
  68.     printf("Circle: return to XMB\n");
  69.     printf("Cross:  shutdown PSP\n");
  70.     printf("\n");
  71.  
  72.     for(;;){
  73.         SceCtrlData pad;
  74.         sceCtrlReadBufferPositive(&pad, 1);
  75.  
  76.         if(pad.Buttons & PSP_CTRL_CIRCLE){
  77.             sceKernelExitGame();
  78.             break;
  79.         }
  80.  
  81.         if(pad.Buttons & PSP_CTRL_CROSS){
  82.             scePowerRequestStandby();
  83.             break;
  84.         }
  85.  
  86. #if 1
  87.         if(pad.Buttons & PSP_CTRL_TRIANGLE){
  88.             typedef void(*TscePowerRequestColdReset)(int);
  89.             TscePowerRequestColdReset PscePowerRequestColdReset;
  90.             u32 NID=GetSetBaseAddrNid(0x0442D852,0x80A2AAD4,0x599A2901,0xF50DA013,0x9DAF25A0);
  91.             printf("NID: %08X\n",NID);
  92.             s32 addr=sctrlHENFindFunction("scePower_Service","scePower_driver",NID);
  93.             printf("scePowerRequestColdReset: %08X\n",addr);
  94.             if(addr>0){ //it fails... it is kernel mode function...
  95.                 PscePowerRequestColdReset=(TscePowerRequestColdReset)addr;
  96.                 PscePowerRequestColdReset(0);
  97.             }
  98.             break;
  99.         }
  100. #endif
  101.  
  102.         if(pad.Buttons & PSP_CTRL_SQUARE){
  103.             executeBasic("ms0:/PSP/GAME/FastRecovery/EBOOT.PBP");
  104.             break;
  105.         }
  106.        
  107.         sceKernelDelayThread(1000);
  108.     }
  109.  
  110.     printf("seems failed\n");
  111.     sceKernelDelayThread(2000000);
  112. #endif
  113.  
  114.     sceKernelExitGame();
  115.     return 0;
  116. }
  117.  
  118.  
RAW Paste Data