From 4c730a60c9094d4d836b95ddf740137056ae3de1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Jun 2013 17:03:21 -0700 Subject: [PATCH] Eat cycles in devctl 0x02425823, fix params. I can't seem to reproduce a way to change its return value, though... Significant performance improvement for Star Ocean, especially in intro. --- Core/HLE/sceIo.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index f6be9cb5e8..c880dd69d7 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -1066,12 +1066,19 @@ u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 outPtr, break; case 0x02425823: // Check if FAT enabled - if (Memory::IsValidAddress(outPtr) && outLen == 4) { + hleEatCycles(23500); + // If the values added together are >= 0x80000000, or less than outPtr, invalid address. + if (((int)outPtr + outLen) < (int)outPtr) { + ERROR_LOG(HLE, "sceIoDevctl: fatms0: 0x02425823 command, bad address"); + return SCE_KERNEL_ERROR_ILLEGAL_ADDR; + } else if (!Memory::IsValidAddress(outPtr)) { + // Technically, only checks for NULL, crashes for many bad addresses. + ERROR_LOG(HLE, "sceIoDevctl: fatms0: 0x02425823 command, no output address"); + return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT; + } else { + // Does not care about outLen, even if it's 0. Memory::Write_U32(MemoryStick_FatState(), outPtr); return 0; - } else { - ERROR_LOG(HLE, "Failed 0x02425823 fat"); - return -1; } break; case 0x02425824: