Until now, I thought that when requesting a demangle or a decrypt by using the "g_mangleProc" or the "semaphore2" proc
FindProc("sceMemlmd", "semaphore", 0x4c537c72) the actual "data" needs to be prepended by a header that contains the "code" (initial seed), the size of the data and, as first u32, the lenght of this header in 32-bit words, as in:
Code: Select all
int Scramble(u32 *buf, u32 size, u32 code)
{
buf[0] = 5;
buf[1] = buf[2] = 0;
buf[3] = code;
buf[4] = size;
if (g_mangleProc(buf, size+0x14, buf, size+0x14, 7) < 0)
{
return -1;
}
return 0;
}
Code: Select all
int Encrypt(u32 *buf, int size)
{
buf[0] = 4;
buf[1] = buf[2] = 0;
buf[3] = 0x100;
buf[4] = size;
/* Note: this encryption returns different data in each psp,
But it always returns the same in a specific psp (even if it has two nands) */
if (g_mangleProc(buf, size+0x14, buf, size+0x14, 5) < 0)
return -1;
return 0;
}
On a side note, I also saw:
Code: Select all
int ReadFile(const char* file, u32 offset, void *buf, u32 size)
{
SceUID fd = sceIoOpen(file, PSP_O_RDONLY, 0777);
int read;
if (fd < 0)
return fd;
if (offset != 0)
{
sceIoLseek32(fd, 0, PSP_SEEK_SET);
}
read = sceIoRead(fd, buf, size);
sceIoClose(fd);
return read;
}
Thanks in advance