extern "C" int main(int argc, char *argv[]) { void *ptr; int size; checkpointNext("Modes:"); int modes[] = {-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 0x10, 0x100, 0x1000, 0x7FFFFFFF}; for (size_t i = 0; i < ARRAY_SIZE(modes); ++i) { char temp[32]; snprintf(temp, 32, " Mode %d", modes[i]); testKernelUnlock(temp, modes[i]); } checkpointNext("Modes (scePower):"); for (size_t i = 0; i < ARRAY_SIZE(modes); ++i) { char temp[32]; snprintf(temp, 32, " Mode %d (scePower)", modes[i]); testPowerUnlock(temp, modes[i]); } checkpointNext("While not locked:"); checkpoint(" Kernel: %08x", sceKernelVolatileMemUnlock(0)); checkpoint(" Power: %08x", sceKernelVolatileMemUnlock(0)); return 0; }
int testKernelUnlock(const char *title, int mode) { if (sceKernelVolatileMemLock(0, NULL, NULL) != 0) { printf("TEST FAILURE\n"); } int result = sceKernelVolatileMemUnlock(mode); checkpoint("%s: %08x", title, result); if (result != 0) { sceKernelVolatileMemUnlock(0); } return result; }
/* Clear memory blocks used by booted modules. */ static s32 ClearFreeBlock(void) { s32 status; sceKernelFillFreeBlock(SCE_KERNEL_PRIMARY_KERNEL_PARTITION, 0); sceKernelFillFreeBlock(SCE_KERNEL_VSHELL_PARTITION, 0); sceKernelVolatileMemUnlock(SCE_KERNEL_VOLATILE_MEM_DEFAULT); status = sceKernelFillFreeBlock(SCE_KERNEL_PRIMARY_USER_PARTITION, 0); sceKernelMemoryExtendSize(); //0x00000D84 sceKernelFillFreeBlock(SCE_KERNEL_EXTENDED_SC_KERNEL_PARTITION, 0); sceKernelFillFreeBlock(SCE_KERNEL_VSHELL_KERNEL_PARTITION, 0); sceKernelMemoryShrinkSize(); sceKernelMemset32((void *)SCE_SCRATCHPAD_ADDR_K0, 0, SCE_SCRATCHPAD_SIZE); return status; }