mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-01-19 12:22:32 +00:00
Cleanup sceKernelGetModuleIdByAddress().
Actual firmware seems to accept any address in the range, and also correct the error result. Now people won't think this is broken anymore.
This commit is contained in:
parent
be755cb253
commit
acac847af2
@ -200,7 +200,7 @@ bool ElfReader::LoadInto(u32 loadAddress)
|
||||
totalEnd = p->p_vaddr + p->p_memsz;
|
||||
}
|
||||
}
|
||||
u32 totalSize = totalEnd - totalStart;
|
||||
totalSize = totalEnd - totalStart;
|
||||
if (!bRelocate)
|
||||
{
|
||||
// Binary is prerelocated, load it where the first segment starts
|
||||
|
@ -111,6 +111,11 @@ public:
|
||||
return vaddr;
|
||||
}
|
||||
|
||||
u32 GetTotalSize()
|
||||
{
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
// More indepth stuff:)
|
||||
bool LoadInto(u32 vaddr);
|
||||
bool LoadSymbols();
|
||||
@ -127,6 +132,7 @@ private:
|
||||
u32 *sectionAddrs;
|
||||
bool bRelocate;
|
||||
u32 entryPoint;
|
||||
u32 totalSize;
|
||||
u32 vaddr;
|
||||
u32 segmentVAddr[32];
|
||||
};
|
||||
|
@ -397,22 +397,20 @@ public:
|
||||
return static_cast<T *>(pool[realHandle]);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T* GetByModuleByEntryAddr(u32 entryAddr)
|
||||
template <class T, typename ArgT>
|
||||
void Iterate(bool func(T *, ArgT), ArgT arg)
|
||||
{
|
||||
for (int i = 0; i < maxCount; ++i)
|
||||
for (int i = 0; i < maxCount; i++)
|
||||
{
|
||||
T* t = dynamic_cast<T*>(pool[i]);
|
||||
|
||||
if (!occupied[i])
|
||||
continue;
|
||||
T *t = dynamic_cast<T *>(pool[i]);
|
||||
if (t)
|
||||
{
|
||||
if (t->nm.entry_addr == entryAddr)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
if (!func(t, arg))
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u32 GetMissingErrorCode() { return -1; } // TODO
|
||||
|
@ -165,12 +165,14 @@ public:
|
||||
{
|
||||
p.Do(nm);
|
||||
p.Do(memoryBlockAddr);
|
||||
p.Do(memoryBlockSize);
|
||||
p.DoMarker("Module");
|
||||
}
|
||||
|
||||
NativeModule nm;
|
||||
|
||||
u32 memoryBlockAddr;
|
||||
u32 memoryBlockSize;
|
||||
bool isFake;
|
||||
};
|
||||
|
||||
@ -316,6 +318,7 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro
|
||||
return 0;
|
||||
}
|
||||
module->memoryBlockAddr = reader.GetVaddr();
|
||||
module->memoryBlockSize = reader.GetTotalSize();
|
||||
|
||||
struct libent
|
||||
{
|
||||
@ -893,24 +896,36 @@ u32 sceKernelStopUnloadSelfModuleWithStatus(u32 moduleId, u32 argSize, u32 argp,
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct GetModuleIdByAddressArg
|
||||
{
|
||||
u32 addr;
|
||||
SceUID result;
|
||||
};
|
||||
|
||||
bool __GetModuleIdByAddressIterator(Module *module, GetModuleIdByAddressArg *state)
|
||||
{
|
||||
const u32 start = module->memoryBlockAddr, size = module->memoryBlockSize;
|
||||
printf("%08x - %08x ? %08x\n", start, start + size, state->addr);
|
||||
if (start <= state->addr && start + size > state->addr)
|
||||
{
|
||||
state->result = module->GetUID();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 sceKernelGetModuleIdByAddress(u32 moduleAddr)
|
||||
{
|
||||
ERROR_LOG(HLE,"HACKIMPL sceKernelGetModuleIdByAddress(%08x)", moduleAddr);
|
||||
GetModuleIdByAddressArg state;
|
||||
state.addr = moduleAddr;
|
||||
state.result = SCE_KERNEL_ERROR_UNKNOWN_MODULE;
|
||||
|
||||
if ((moduleAddr & 0xFFFF0000) == 0x08800000)
|
||||
{
|
||||
return mainModuleID;
|
||||
}
|
||||
kernelObjects.Iterate(&__GetModuleIdByAddressIterator, &state);
|
||||
if (state.result == SCE_KERNEL_ERROR_UNKNOWN_MODULE)
|
||||
ERROR_LOG(HLE, "sceKernelGetModuleIdByAddress(%08x): module not found", moduleAddr)
|
||||
else
|
||||
{
|
||||
Module* foundMod= kernelObjects.GetByModuleByEntryAddr<Module>(moduleAddr);
|
||||
|
||||
if(foundMod)
|
||||
{
|
||||
return foundMod->GetUID();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
DEBUG_LOG(HLE, "%x=sceKernelGetModuleIdByAddress(%08x)", state.result, moduleAddr);
|
||||
return state.result;
|
||||
}
|
||||
|
||||
u32 sceKernelGetModuleId()
|
||||
|
Loading…
x
Reference in New Issue
Block a user