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 (fd < 0)
	{
		ErrorExit(6000, "Cannot open file.\n");
	}
	size = sceIoLseek(fd, 0, SEEK_END);
	sceIoLseek(fd, 0, PSP_SEEK_SET);
	sceIoRead(fd, dataOut, 200);
	if (memcmp(dataOut, "\0PBP", 4) != 0)
	{
		sceIoClose(fd);
		ErrorExit(6000, "Invalid PBP file.\n");
	}
	
	size = size -  *(u32 *)&dataOut[0x24];
	sceIoLseek(fd, *(u32 *)&dataOut[0x24], PSP_SEEK_SET);
	if (size != 20314528)
	{
		ErrorExit(6000, "Invalid 3.80 update file.\n");
		sceIoClose(fd);
	}
	if (sceIoRead(fd, dataPSAR, 20314528) != 20314528)
	{
		ErrorExit(6000, "Invalid 3.80 update file (2).\n");
		sceIoClose(fd);
	}
	sceIoClose(fd);
	printf("OK\n");
Now this one doesn't get the sha1 right, i also removed the previous code.
Code: Select all
u8 sha1_390[20] =
{
	     0x19, 0xAF, 0xAC, 0x87, 0x8B, 0xD3, 0x9E, 0x7A,
        0x37, 0x4F, 0xF1, 0xCB, 0xF1, 0x0B, 0x9A, 0x1E,
        0x59, 0x08, 0x28, 0x89,
};
    SceUID fd6;
    int readx, ix;
    
    printf("390.PBP...");
	fd6 = sceIoOpen("ms0:/390.PBP", PSP_O_RDONLY, 0777);
	if (fd6 < 0)
	{
		printf("390.PBP Isn't There, Continuing\n");
	}
	sceKernelUtilsSha1BlockInit(&ctx);
	while ((readx = sceIoRead(fd6, dataOut, 2000000)) > 0)
	{
		sceKernelUtilsSha1BlockUpdate(&ctx, dataOut, readx);
	}
	sceIoClose(fd6);
	sceKernelUtilsSha1BlockResult(&ctx, sha1);
	printf("\nSHA1: ");
	for (ix = 0; ix < 20; ix++)
		printf("%02X", sha1[i]);
	if (memcmp(sha1, sha1_390, 20) != 0)
	{
		TextColor(RED);
		printf("Error\n");
		//ErrorExit(10000, "\nERROR: Invalid SHA-1. Try again.\nAuto-exiting in 10 seconds.\n");
	}
	TextColor(WHITE);
	printf("\n3.90.PBP is Correct\n");