mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-02 18:53:58 +01:00
Fix return values in sceKernelGetThreadmanIdList().
Support other object types as well, but not threads/etc. properly yet.
This commit is contained in:
1 parent
774589aa4f
commit
feeb03b5ff
2 files changed
+35
-18
No files matched your search
+18
-4
@@ -489,11 +489,9 @@ public:
|
||||
}
|
||||
|
||||
template <class T, typename ArgT>
|
||||
void Iterate(bool func(T *, ArgT), ArgT arg)
|
||||
{
|
||||
void Iterate(bool func(T *, ArgT), ArgT arg) {
|
||||
int type = T::GetStaticIDType();
|
||||
for (int i = 0; i < maxCount; i++)
|
||||
{
|
||||
for (int i = 0; i < maxCount; i++) {
|
||||
if (!occupied[i])
|
||||
continue;
|
||||
T *t = static_cast<T *>(pool[i]);
|
||||
@@ -504,6 +502,22 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
int ListIDType(int type, SceUID *uids, int count) const {
|
||||
int total = 0;
|
||||
for (int i = 0; i < maxCount; i++) {
|
||||
if (!occupied[i]) {
|
||||
continue;
|
||||
}
|
||||
if (pool[i]->GetIDType() == type) {
|
||||
if (total < count) {
|
||||
*uids++ = pool[i]->GetUID();
|
||||
}
|
||||
++total;
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
bool GetIDType(SceUID handle, int *type) const
|
||||
{
|
||||
if (handle < handleOffset || handle >= handleOffset+maxCount || !occupied[handle-handleOffset])
|
||||
|
||||
@@ -1592,24 +1592,27 @@ u32 sceKernelGetThreadmanIdType(u32 uid) {
|
||||
}
|
||||
}
|
||||
|
||||
u32 sceKernelGetThreadmanIdList(u32 type, u32 readBufPtr, u32 readBufSize, u32 idCountPtr)
|
||||
{
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelGetThreadmanIdList(%i, %08x, %i, %08x)",
|
||||
type, readBufPtr, readBufSize, idCountPtr);
|
||||
if (!Memory::IsValidAddress(readBufPtr))
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT;
|
||||
|
||||
if (type != SCE_KERNEL_TMID_Thread) {
|
||||
ERROR_LOG_REPORT(SCEKERNEL, "sceKernelGetThreadmanIdList only implemented for threads");
|
||||
u32 sceKernelGetThreadmanIdList(u32 type, u32 readBufPtr, u32 readBufSize, u32 idCountPtr) {
|
||||
if (type == 0 || type > SCE_KERNEL_TMID_DormantThread || (type > SCE_KERNEL_TMID_Tlspl && type < SCE_KERNEL_TMID_SleepThread)) {
|
||||
ERROR_LOG_REPORT(SCEKERNEL, "sceKernelGetThreadmanIdList(%i, %08x, %i, %08x): invalid type", type, readBufPtr, readBufSize, idCountPtr);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_TYPE;
|
||||
}
|
||||
if (readBufSize >= 0x8000000) {
|
||||
// Not exact, it's probably if the sum ends up negative or something.
|
||||
ERROR_LOG_REPORT(SCEKERNEL, "sceKernelGetThreadmanIdList(%i, %08x, %i, %08x): invalid size", type, readBufPtr, readBufSize, idCountPtr);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ADDR;
|
||||
}
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelGetThreadmanIdList(%i, %08x, %i, %08x)", type, readBufPtr, readBufSize, idCountPtr);
|
||||
if (!Memory::IsValidAddress(readBufPtr)) {
|
||||
// Crashes on a PSP.
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < std::min((size_t)readBufSize, threadqueue.size()); i++)
|
||||
{
|
||||
Memory::Write_U32(threadqueue[i], readBufPtr + (u32)i * 4);
|
||||
u32 total = kernelObjects.ListIDType(type, PSPPointer<SceUID>::Create(readBufPtr), readBufSize);
|
||||
if (Memory::IsValidAddress(idCountPtr)) {
|
||||
Memory::Write_U32(total, idCountPtr);
|
||||
}
|
||||
Memory::Write_U32((u32)threadqueue.size(), idCountPtr);
|
||||
return 0;
|
||||
return total > readBufSize ? readBufSize : total;
|
||||
}
|
||||
|
||||
// Saves the current CPU context
|
||||
|
||||
Reference in new issue
Block a user