Cannot Allocate Memory?? 3.XX Sha1 fails aswell

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

Moderators: cheriff, TyRaNiD

Post Reply
FaderX
Posts: 28
Joined: Sat Mar 01, 2008 12:38 pm

Cannot Allocate Memory?? 3.XX Sha1 fails aswell

Post by FaderX »

Ok i've created a 3.XX game that loads, but.....Im trying to check to make sure the files are correct size etc. e.g 390.PBP

Code: Select all

   SceUID fd;
	int size;
	
	dataPSAR = (u8 *)memalign(0x40, 0x0100a830+256);

	if (!dataPSAR)
	{
		ErrorExit(6000, "Cannot allocate memory (1).\n");
    }

	dataOut = (u8 *)memalign(0x40, 2000000);

	if (!dataOut)
	{
                 ErrorExit(6000, "Cannot allocate memory (2).\n");
    }
    
    printf("Opening and checking 390.PBP..... ");

	fd = sceIoOpen("ms0:/390.PBP", PSP_O_RDONLY, 0777);
	if &#40;fd < 0&#41;
	&#123;
		ErrorExit&#40;6000, "Cannot open file.\n"&#41;;
	&#125;

	size = sceIoLseek&#40;fd, 0, SEEK_END&#41;;
	sceIoLseek&#40;fd, 0, PSP_SEEK_SET&#41;;

	sceIoRead&#40;fd, dataOut, 200&#41;;

	if &#40;memcmp&#40;dataOut, "\0PBP", 4&#41; != 0&#41;
	&#123;
		sceIoClose&#40;fd&#41;;
		ErrorExit&#40;6000, "Invalid PBP file.\n"&#41;;
	&#125;
	
	size = size -  *&#40;u32 *&#41;&dataOut&#91;0x24&#93;;

	sceIoLseek&#40;fd, *&#40;u32 *&#41;&dataOut&#91;0x24&#93;, PSP_SEEK_SET&#41;;

	if &#40;size != 20314528&#41;
	&#123;
		ErrorExit&#40;6000, "Invalid 3.80 update file.\n"&#41;;
		sceIoClose&#40;fd&#41;;
	&#125;

	if &#40;sceIoRead&#40;fd, dataPSAR, 20314528&#41; != 20314528&#41;
	&#123;
		ErrorExit&#40;6000, "Invalid 3.80 update file &#40;2&#41;.\n"&#41;;
		sceIoClose&#40;fd&#41;;
	&#125;

	sceIoClose&#40;fd&#41;;

	printf&#40;"OK\n"&#41;;
That one can't allocate the memory.

Now this one doesn't get the sha1 right, i also removed the previous code.

Code: Select all

u8 sha1_390&#91;20&#93; =
&#123;

	     0x19, 0xAF, 0xAC, 0x87, 0x8B, 0xD3, 0x9E, 0x7A,
        0x37, 0x4F, 0xF1, 0xCB, 0xF1, 0x0B, 0x9A, 0x1E,
        0x59, 0x08, 0x28, 0x89,
&#125;;

    SceUID fd6;
    int readx, ix;
    
    printf&#40;"390.PBP..."&#41;;

	fd6 = sceIoOpen&#40;"ms0&#58;/390.PBP", PSP_O_RDONLY, 0777&#41;;

	if &#40;fd6 < 0&#41;
	&#123;
		printf&#40;"390.PBP Isn't There, Continuing\n"&#41;;
	&#125;

	sceKernelUtilsSha1BlockInit&#40;&ctx&#41;;

	while &#40;&#40;readx = sceIoRead&#40;fd6, dataOut, 2000000&#41;&#41; > 0&#41;
	&#123;
		sceKernelUtilsSha1BlockUpdate&#40;&ctx, dataOut, readx&#41;;
	&#125;

	sceIoClose&#40;fd6&#41;;
	sceKernelUtilsSha1BlockResult&#40;&ctx, sha1&#41;;

	printf&#40;"\nSHA1&#58; "&#41;;
	for &#40;ix = 0; ix < 20; ix++&#41;
		printf&#40;"%02X", sha1&#91;i&#93;&#41;;

	if &#40;memcmp&#40;sha1, sha1_390, 20&#41; != 0&#41;
	&#123;
		TextColor&#40;RED&#41;;
		printf&#40;"Error\n"&#41;;
		//ErrorExit&#40;10000, "\nERROR&#58; Invalid SHA-1. Try again.\nAuto-exiting in 10 seconds.\n"&#41;;
	&#125;

	TextColor&#40;WHITE&#41;;

	printf&#40;"\n3.90.PBP is Correct\n"&#41;;
Is it something to do with Dark_AleX's code, my codes? or 3.XX
weltall
Posts: 310
Joined: Fri Feb 20, 2004 1:56 am
Contact:

Post by weltall »

did you set correctly the heap?
FaderX
Posts: 28
Joined: Sat Mar 01, 2008 12:38 pm

Post by FaderX »

Code: Select all

PSP_MODULE_INFO&#40;"Check", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER&#41;; 
PSP_HEAP_SIZE_MAX&#40;&#41;;
Heap is there
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

Are you sure that's the sha1 of the 3.90 update?
Because mine gives me 5957951D3F7B8A4D715C36D9135E65693F6DA334

EDIT: but the psar gives me the same sha1 than yours 19AFAC878BD39E7A374FF1CBF10B9A1E59082889, but you are reading the full file, not just the psar.
FaderX
Posts: 28
Joined: Sat Mar 01, 2008 12:38 pm

Post by FaderX »

Yea i think i've also tried the 3.90 psar, it also failed, but ill give another try later.

Edit:

Tried again, still didnt work?? wtf
FaderX
Posts: 28
Joined: Sat Mar 01, 2008 12:38 pm

Post by FaderX »

Oh does this have to bee in a separate kernel or vsh prx??
Post Reply