mirror of
https://github.com/jakcron/nstool
synced 2024-11-15 02:06:40 +00:00
[nx] Unbroke MemoryMappingHandler forloop bugfix. Fixed typo in KcBinary::importBinary().
This commit is contained in:
parent
5af8ec72ae
commit
7dd27fd5c8
3 changed files with 26 additions and 13 deletions
|
@ -123,7 +123,7 @@ void nx::KcBinary::importBinary(const u8 * bytes, size_t len)
|
|||
mSystemCalls.importKernelCapabilityList(systemCallCaps);
|
||||
mMemoryMap.importKernelCapabilityList(memoryMapCaps);
|
||||
mInterupts.importKernelCapabilityList(interuptCaps);
|
||||
mMiscParams.importKernelCapabilityList(memoryMapCaps);
|
||||
mMiscParams.importKernelCapabilityList(miscParamCaps);
|
||||
mKernelVersion.importKernelCapabilityList(kernelVersionCaps);
|
||||
mHandleTableSize.importKernelCapabilityList(handleTableSizeCaps);
|
||||
mMiscFlags.importKernelCapabilityList(miscFlagsCaps);
|
||||
|
|
|
@ -35,15 +35,16 @@ void nx::MemoryMappingHandler::importKernelCapabilityList(const fnd::List<Kernel
|
|||
|
||||
mMemRange.clear();
|
||||
mMemPage.clear();
|
||||
for (size_t i = 0; i < entries.getSize(); i++)
|
||||
for (size_t i = 0; i < entries.getSize();)
|
||||
{
|
||||
// has flag means "MemMap"
|
||||
if (entries[i].isMultiplePages())
|
||||
{
|
||||
|
||||
// this entry is the last one or the next one isn't a memory map
|
||||
if ((i + 1) == entries.getSize() || entries[i+1].isMultiplePages() == false)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "Illegal page address");
|
||||
throw fnd::Exception(kModuleName, "No paired entry");
|
||||
}
|
||||
|
||||
// check valid page address
|
||||
|
@ -59,7 +60,7 @@ void nx::MemoryMappingHandler::importKernelCapabilityList(const fnd::List<Kernel
|
|||
}
|
||||
|
||||
// add to list
|
||||
mMemRange.addElement({ entries[i].getPage(), entries[i+1].getPage(), !entries[i].getFlag(), !entries[i+1].getFlag() });
|
||||
mMemRange.addElement({ entries[i].getPage(), entries[i+1].getPage(), entries[i].getFlag() ? MEM_RO : MEM_RW, entries[i+1].getFlag() ? MAP_STATIC : MAP_IO });
|
||||
|
||||
// increment i by two
|
||||
i += 2;
|
||||
|
@ -74,7 +75,7 @@ void nx::MemoryMappingHandler::importKernelCapabilityList(const fnd::List<Kernel
|
|||
}
|
||||
|
||||
// add to list
|
||||
mMemPage.addElement({ entries[i].getPage(), 1, true, true });
|
||||
mMemPage.addElement({ entries[i].getPage(), 1, MEM_RW, MAP_IO });
|
||||
|
||||
// increment i by one
|
||||
i += 1;
|
||||
|
@ -96,11 +97,11 @@ void nx::MemoryMappingHandler::exportKernelCapabilityList(fnd::List<KernelCapabi
|
|||
for (size_t i = 0; i < mMemRange.getSize(); i++)
|
||||
{
|
||||
cap.setPage(mMemRange[i].addr & kMaxPageAddr);
|
||||
cap.setFlag(!mMemRange[i].isRW);
|
||||
cap.setFlag(mMemRange[i].perm == MEM_RO);
|
||||
caps.addElement(cap.getKernelCapability());
|
||||
|
||||
cap.setPage(mMemRange[i].size & kMaxPageNum);
|
||||
cap.setFlag(!mMemRange[i].isIO);
|
||||
cap.setFlag(mMemRange[i].type == MAP_STATIC);
|
||||
caps.addElement(cap.getKernelCapability());
|
||||
}
|
||||
|
||||
|
|
|
@ -7,19 +7,31 @@ namespace nx
|
|||
public IKernelCapabilityHandler
|
||||
{
|
||||
public:
|
||||
enum MemoryPerm
|
||||
{
|
||||
MEM_RW,
|
||||
MEM_RO
|
||||
};
|
||||
|
||||
enum MappingType
|
||||
{
|
||||
MAP_IO,
|
||||
MAP_STATIC
|
||||
};
|
||||
|
||||
struct sMemoryMapping
|
||||
{
|
||||
u32 addr; // page index
|
||||
u32 size; // page num
|
||||
bool isRW;
|
||||
bool isIO;
|
||||
MemoryPerm perm;
|
||||
MappingType type;
|
||||
|
||||
bool operator==(const sMemoryMapping& other) const
|
||||
{
|
||||
return (addr == other.addr) \
|
||||
&& (size == other.size) \
|
||||
&& (isRW == other.isRW) \
|
||||
&& (isIO == other.isIO);
|
||||
&& (perm == other.perm) \
|
||||
&& (type == other.type);
|
||||
}
|
||||
|
||||
bool operator!=(const sMemoryMapping& other) const
|
||||
|
@ -31,8 +43,8 @@ namespace nx
|
|||
{
|
||||
addr = other.addr;
|
||||
size = other.size;
|
||||
isRW = other.isRW;
|
||||
isIO = other.isIO;
|
||||
perm = other.perm;
|
||||
type = other.type;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue