Prx decryption kill me...

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
*mUrDeRc0dE*
Posts: 13
Joined: Mon Jun 16, 2008 12:51 am
Location: IDSTORAGE

Prx decryption kill me...

Post by *mUrDeRc0dE* »

Code: Select all

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspiofilemgr.h>
#include <string.h>

#include "pspDecrypt.h"

#define printf pspDebugScreenPrintf

/* Define the module info section */
PSP_MODULE_INFO&#40;"template", 0, 1, 1&#41;;

/* Define the main thread's attribute value &#40;optional&#41; */
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;

PSP_HEAP_SIZE_KB&#40;1000*1024&#41;;

int PspUnpack&#40;u8* inBuf, u8* outBuf&#41;
&#123;
	int prx_com,prx_upk,prx_dec;
	char buf&#91;200*1024&#93;;
	char c_buf&#91;128*1024&#93;;
	
	if&#40;!&#40;prx_com = sceIoOpen&#40;"ms0&#58;/PRX/testprx.prx",  PSP_O_RDONLY, 0777&#41;&#41;&#41; &#123;
        printf&#40;"Cannot open the source prx\n"&#41;;
	&#125;
	
	if&#40;!&#40;prx_upk = sceIoOpen&#40;"ms0&#58;/PRX/testprx_upk.prx", PSP_O_WRONLY|PSP_O_CREAT, 0777&#41;&#41;&#41; &#123;
        printf&#40;"Cannot create the unpacked prx\n"&#41;;
	&#125;
		  
	int mod = pspSdkLoadStartModule&#40;"pspdecrypt.prx", PSP_MEMORY_PARTITION_KERNEL&#41;;
	if &#40;mod < 0&#41;
	&#123;
		printf&#40;"Cannot load pspdecrypt module"&#41;;
	&#125;
	
	printf&#40;"Prx decompression phase 1 - Bytecopyng\n"&#41;;
	
	int prxsize = sceIoRead&#40;prx_com,buf,1000000000&#41;;
	int destsize = prxsize - 336;
	
	sceIoLseek&#40;prx_com,0x150, PSP_SEEK_SET&#41;;
	sceIoRead&#40;prx_com,buf,1000000000&#41;;
	
	memset&#40;&buf,0,sizeof&#40;buf&#41;&#41;;
		
	printf&#40;"Prx size = %ikb&#40;%ib&#41;\n",prxsize / 1024,prxsize&#41;;
	
	int decPrxSize = pspDecompress&#40;&#40;u8*&#41;buf,&#40;u8*&#41;c_buf,sizeof&#40;c_buf&#41;&#41;;
		
	sceIoWrite&#40;prx_upk,c_buf,decPrxSize&#41;;
	
	sceIoClose&#40;prx_com&#41;;
	sceIoClose&#40;prx_upk&#41;;
	

	sceKernelDelayThread&#40;10000000&#41;;
	sceKernelExitGame&#40;&#41;;
	
	return 0;

&#125;

int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
	pspDebugScreenInit&#40;&#41;;

	pspDebugScreenPrintf&#40;"Prx unpacker & decrypter\nCode &#58; Murderc0de\n\n"&#41;;
	
	PspUnpack&#40;10,10&#41;;

	return 0;
&#125;
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspiofilemgr.h>
#include <string.h>

#include "pspDecrypt.h"

#define printf pspDebugScreenPrintf

/* Define the module info section */
PSP_MODULE_INFO&#40;"template", 0, 1, 1&#41;;

/* Define the main thread's attribute value &#40;optional&#41; */
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;

PSP_HEAP_SIZE_KB&#40;1000*1024&#41;;

int PspUnpack&#40;u8* inBuf, u8* outBuf&#41;
&#123;
	int prx_com,prx_upk,prx_dec;
	char buf&#91;200*1024&#93;;
	char c_buf&#91;128*1024&#93;;
	
	if&#40;!&#40;prx_com = sceIoOpen&#40;"ms0&#58;/PRX/testprx.prx",  PSP_O_RDONLY, 0777&#41;&#41;&#41; &#123;
        printf&#40;"Cannot open the source prx\n"&#41;;
	&#125;
	
	if&#40;!&#40;prx_upk = sceIoOpen&#40;"ms0&#58;/PRX/testprx_upk.prx", PSP_O_WRONLY|PSP_O_CREAT, 0777&#41;&#41;&#41; &#123;
        printf&#40;"Cannot create the unpacked prx\n"&#41;;
	&#125;
		  
	int mod = pspSdkLoadStartModule&#40;"pspdecrypt.prx", PSP_MEMORY_PARTITION_KERNEL&#41;;
	if &#40;mod < 0&#41;
	&#123;
		printf&#40;"Cannot load pspdecrypt module"&#41;;
	&#125;
	
	printf&#40;"Prx decompression phase 1 - Bytecopyng\n"&#41;;
	
	int prxsize = sceIoRead&#40;prx_com,buf,1000000000&#41;;
	int destsize = prxsize - 336;
	
	sceIoLseek&#40;prx_com,0x150, PSP_SEEK_SET&#41;;
	sceIoRead&#40;prx_com,buf,1000000000&#41;;
	
	memset&#40;&buf,0,sizeof&#40;buf&#41;&#41;;
		
	printf&#40;"Prx size = %ikb&#40;%ib&#41;\n",prxsize / 1024,prxsize&#41;;
	
	int decPrxSize = pspDecompress&#40;&#40;u8*&#41;buf,&#40;u8*&#41;c_buf,sizeof&#40;c_buf&#41;&#41;;
		
	sceIoWrite&#40;prx_upk,c_buf,decPrxSize&#41;;
	
	sceIoClose&#40;prx_com&#41;;
	sceIoClose&#40;prx_upk&#41;;
	

	sceKernelDelayThread&#40;10000000&#41;;
	sceKernelExitGame&#40;&#41;;
	
	return 0;

&#125;

int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
	pspDebugScreenInit&#40;&#41;;

	pspDebugScreenPrintf&#40;"Prx unpacker & decrypter\nCode &#58; Murderc0de\n\n"&#41;;
	
	PspUnpack&#40;10,10&#41;;

	return 0;
&#125;
i used this code for unpacking prx (delete bytes above 0x150) and then decompress the prx with pspDecompress function, but the psp crashes. I tryed to use static u8* buffers but the psp crashes. I tryed the zlib but the psp crashes...
Source code is for noobs...
homemister
Posts: 25
Joined: Mon Mar 24, 2008 12:16 pm

Post by homemister »

PSP_HEAP_SIZE_KB(1000*1024);
Your heep size is too big
try PSP_HEAP_SIZE_KB(10*1024);
That is 10Mb, you had 1Gb
*mUrDeRc0dE*
Posts: 13
Joined: Mon Jun 16, 2008 12:51 am
Location: IDSTORAGE

Post by *mUrDeRc0dE* »

no, the heap isn't the problem...the psp crash
Source code is for noobs...
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

why is the code posted 2 times? or do you really have that in your source code??
by the way, setting the heap to 1gb...is not a problem? :P

and i dont agree with you when you say source code is for noobs, we all learn from reading source codes not only from reading books.
Image
Upgrade your PSP
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

I've never studied a programming language to school, but I've try to learn C with the online tutorial and read a source code can halp you to understand some things, so I don't think that source code is for noobs!
FreePlay
Posts: 71
Joined: Wed Jan 04, 2006 6:53 pm
Location: Schenectady, New York, USA

Post by FreePlay »

*mUrDeRc0dE* wrote:no, the heap isn't the problem...the psp crash
Yes, the heap IS the problem. You're requesting 1024000 *KB* of space.
User avatar
Actarus
Posts: 33
Joined: Mon May 19, 2008 12:54 am
Contact:

Post by Actarus »

Where is the module pspdecrypt.prx?
Post Reply