diff --git a/programs/nstool/source/NpdmProcess.cpp b/programs/nstool/source/NpdmProcess.cpp index 6a7f977..f0ab4eb 100644 --- a/programs/nstool/source/NpdmProcess.cpp +++ b/programs/nstool/source/NpdmProcess.cpp @@ -85,257 +85,6 @@ const nn::hac::NpdmBinary& NpdmProcess::getNpdmBinary() const return mNpdm; } -const std::string kInstructionType[2] = { "32Bit", "64Bit" }; -const std::string kProcAddrSpace[4] = { "Unknown", "64Bit", "32Bit", "32Bit no reserved" }; -const std::string kAcidFlag[32] = -{ - "Production", - "UnqualifiedApproval", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown" -}; -const std::string kMiscFlag[15] = { "EnableDebug", "ForceDebug", "bit2", "bit3", "bit4", "bit5", "bit6", "bit7", "bit8", "bit9", "bit10", "bit11", "bit12", "bit13", "bit14"}; -const std::string kFsaFlag[64] = -{ - "ApplicationInfo", - "BootModeControl", - "Calibration", - "SystemSaveData", - "GameCard", - "SaveDataBackUp", - "SaveDataManagement", - "BisAllRaw", - "GameCardRaw", - "GameCardPrivate", - "SetTime", - "ContentManager", - "ImageManager", - "CreateSaveData", - "SystemSaveDataManagement", - "BisFileSystem", - "SystemUpdate", - "SaveDataMeta", - "DeviceSaveData", - "SettingsControl", - "Bit20", - "Bit21", - "Bit22", - "Bit23", - "Bit24", - "Bit25", - "Bit26", - "Bit27", - "Bit28", - "Bit29", - "Bit30", - "Bit31", - "Bit32", - "Bit33", - "Bit34", - "Bit35", - "Bit36", - "Bit37", - "Bit38", - "Bit39", - "Bit40", - "Bit41", - "Bit42", - "Bit43", - "Bit44", - "Bit45", - "Bit46", - "Bit47", - "Bit48", - "Bit49", - "Bit50", - "Bit51", - "Bit52", - "Bit53", - "Bit54", - "Bit55", - "Bit56", - "Bit57", - "Bit58", - "Bit59", - "Bit60", - "Bit61", - "Debug", - "FullPermission" -}; - -const std::string kSaveDataOwnerAccessMode[4] = -{ - "IllegalAccessCondition", - "Read", - "Write", - "ReadWrite" -}; - -const std::string kSysCall[0x80] = -{ - "svc00", - "SetHeapSize", - "SetMemoryPermission", - "SetMemoryAttribute", - "MapMemory", - "UnmapMemory", - "QueryMemory", - "ExitProcess", - "CreateThread", - "StartThread", - "ExitThread", - "SleepThread", - "GetThreadPriority", - "SetThreadPriority", - "GetThreadCoreMask", - "SetThreadCoreMask", - "GetCurrentProcessorNumber", - "SignalEvent", - "ClearEvent", - "MapSharedMemory", - "UnmapSharedMemory", - "CreateTransferMemory", - "CloseHandle", - "ResetSignal", - "WaitSynchronization", - "CancelSynchronization", - "ArbitrateLock", - "ArbitrateUnlock", - "WaitProcessWideKeyAtomic", - "SignalProcessWideKey", - "GetSystemTick", - "ConnectToNamedPort", - "SendSyncRequestLight", - "SendSyncRequest", - "SendSyncRequestWithUserBuffer", - "SendAsyncRequestWithUserBuffer", - "GetProcessId", - "GetThreadId", - "Break", - "OutputDebugString", - "ReturnFromException", - "GetInfo", - "FlushEntireDataCache", - "FlushDataCache", - "MapPhysicalMemory", - "UnmapPhysicalMemory", - "svc2E", - "GetLastThreadInfo", - "GetResourceLimitLimitValue", - "GetResourceLimitCurrentValue", - "SetThreadActivity", - "GetThreadContext3", - "svc34", - "svc35", - "svc36", - "svc37", - "svc38", - "svc39", - "svc3A", - "svc3B", - "DumpInfo", - "svc3D", - "svc3E", - "svc3F", - "CreateSession", - "AcceptSession", - "ReplyAndReceiveLight", - "ReplyAndReceive", - "ReplyAndReceiveWithUserBuffer", - "CreateEvent", - "svc46", - "svc47", - "svc48", - "svc49", - "svc4A", - "svc4B", - "svc4C", - "SleepSystem", - "ReadWriteRegister", - "SetProcessActivity", - "CreateSharedMemory", - "MapTransferMemory", - "UnmapTransferMemory", - "CreateInterruptEvent", - "QueryPhysicalAddress", - "QueryIoMapping", - "CreateDeviceAddressSpace", - "AttachDeviceAddressSpace", - "DetachDeviceAddressSpace", - "MapDeviceAddressSpaceByForce", - "MapDeviceAddressSpaceAligned", - "MapDeviceAddressSpace", - "UnmapDeviceAddressSpace", - "InvalidateProcessDataCache", - "StoreProcessDataCache", - "FlushProcessDataCache", - "DebugActiveProcess", - "BreakDebugProcess", - "TerminateDebugProcess", - "GetDebugEvent", - "ContinueDebugEvent", - "GetProcessList", - "GetThreadList", - "GetDebugThreadContext", - "SetDebugThreadContext", - "QueryDebugProcessMemory", - "ReadDebugProcessMemory", - "WriteDebugProcessMemory", - "SetHardwareBreakPoint", - "GetDebugThreadParam", - "svc6E", - "svc6F", - "CreatePort", - "ManageNamedPort", - "ConnectToPort", - "SetProcessMemoryPermission", - "MapProcessMemory", - "UnmapProcessMemory", - "QueryProcessMemory", - "MapProcessCodeMemory", - "UnmapProcessCodeMemory", - "CreateProcess", - "StartProcess", - "TerminateProcess", - "GetProcessInfo", - "CreateResourceLimit", - "SetResourceLimitLimitValue", - "CallSecureMonitor" -}; - -const std::string kMemMapPerm[2] = { "RW", "RO" }; -const std::string kMemMapType[2] = { "Io", "Static" }; - -const std::string kAcidTarget[2] = { "Development", "Production" }; - void NpdmProcess::validateAcidSignature(const nn::hac::AccessControlInfoDescBinary& acid) { try { @@ -371,7 +120,7 @@ void NpdmProcess::validateAciFromAcid(const nn::hac::AccessControlInfoBinary& ac if (fsaRightFound == false) { - printf("[WARNING] ACI/FAC FsaRights: FAIL (%s not permitted)\n", kFsaFlag[aci.getFileSystemAccessControl().getFsaRightsList()[i]].c_str()); + printf("[WARNING] ACI/FAC FsaRights: FAIL (%s not permitted)\n", getFsaRightStr(aci.getFileSystemAccessControl().getFsaRightsList()[i])); } } @@ -403,7 +152,7 @@ void NpdmProcess::validateAciFromAcid(const nn::hac::AccessControlInfoBinary& ac if (rightFound == false) { - printf("[WARNING] ACI/FAC ContentOwnerId: FAIL (%016" PRIx64 "(%d) not permitted)\n", aci.getFileSystemAccessControl().getSaveDataOwnerIdList()[i].id, aci.getFileSystemAccessControl().getSaveDataOwnerIdList()[i].access_type); + printf("[WARNING] ACI/FAC SaveDataOwnerId: FAIL (%016" PRIx64 "(%d) not permitted)\n", aci.getFileSystemAccessControl().getSaveDataOwnerIdList()[i].id, aci.getFileSystemAccessControl().getSaveDataOwnerIdList()[i].access_type); } } @@ -453,7 +202,7 @@ void NpdmProcess::validateAciFromAcid(const nn::hac::AccessControlInfoBinary& ac if (rightFound == false) { - printf("[WARNING] ACI/KC SystemCallList: FAIL (%s not permitted)\n", kSysCall[aci.getKernelCapabilities().getSystemCalls().getSystemCalls()[i]].c_str()); + printf("[WARNING] ACI/KC SystemCallList: FAIL (%s not permitted)\n", getSystemCallStr(aci.getKernelCapabilities().getSystemCalls().getSystemCalls()[i])); } } // check memory maps @@ -470,7 +219,7 @@ void NpdmProcess::validateAciFromAcid(const nn::hac::AccessControlInfoBinary& ac { const nn::hac::MemoryMappingHandler::sMemoryMapping& map = aci.getKernelCapabilities().getMemoryMaps().getMemoryMaps()[i]; - printf("[WARNING] ACI/KC MemoryMap: FAIL (0x%016" PRIx64 " - 0x%016" PRIx64 " (perm=%s) (type=%s) not permitted)\n", (uint64_t)map.addr << 12, ((uint64_t)(map.addr + map.size) << 12) - 1, kMemMapPerm[map.perm].c_str(), kMemMapType[map.type].c_str()); + printf("[WARNING] ACI/KC MemoryMap: FAIL (0x%016" PRIx64 " - 0x%016" PRIx64 " (perm=%s) (type=%s) not permitted)\n", (uint64_t)map.addr << 12, ((uint64_t)(map.addr + map.size) << 12) - 1, getMemMapPermStr(map.perm), getMemMapTypeStr(map.type)); } } for (size_t i = 0; i < aci.getKernelCapabilities().getMemoryMaps().getIoMemoryMaps().size(); i++) @@ -486,7 +235,7 @@ void NpdmProcess::validateAciFromAcid(const nn::hac::AccessControlInfoBinary& ac { const nn::hac::MemoryMappingHandler::sMemoryMapping& map = aci.getKernelCapabilities().getMemoryMaps().getIoMemoryMaps()[i]; - printf("[WARNING] ACI/KC IoMemoryMap: FAIL (0x%016" PRIx64 " - 0x%016" PRIx64 " (perm=%s) (type=%s) not permitted)\n", (uint64_t)map.addr << 12, ((uint64_t)(map.addr + map.size) << 12) - 1, kMemMapPerm[map.perm].c_str(), kMemMapType[map.type].c_str()); + printf("[WARNING] ACI/KC IoMemoryMap: FAIL (0x%016" PRIx64 " - 0x%016" PRIx64 " (perm=%s) (type=%s) not permitted)\n", (uint64_t)map.addr << 12, ((uint64_t)(map.addr + map.size) << 12) - 1, getMemMapPermStr(map.perm), getMemMapTypeStr(map.type)); } } // check interupts @@ -533,7 +282,7 @@ void NpdmProcess::validateAciFromAcid(const nn::hac::AccessControlInfoBinary& ac if (rightFound == false) { - printf("[WARNING] ACI/KC MiscFlag: FAIL (%s not permitted)\n", kMiscFlag[aci.getKernelCapabilities().getMiscFlags().getFlagList()[i]].c_str()); + printf("[WARNING] ACI/KC MiscFlag: FAIL (%s not permitted)\n", getMiscFlagStr(aci.getKernelCapabilities().getMiscFlags().getFlagList()[i])); } } } @@ -542,8 +291,8 @@ void NpdmProcess::displayNpdmHeader(const nn::hac::NpdmBinary& hdr) { printf("[NPDM HEADER]\n"); printf(" Process Architecture Params:\n"); - printf(" Ins. Type: %s\n", kInstructionType[hdr.getInstructionType()].c_str()); - printf(" Addr Space: %s\n", kProcAddrSpace[hdr.getProcAddressSpaceType()].c_str()); + printf(" Ins. Type: %s\n", getInstructionTypeStr(hdr.getInstructionType())); + printf(" Addr Space: %s\n", getProcAddressSpaceTypeStr(hdr.getProcAddressSpaceType())); printf(" Main Thread Params:\n"); printf(" Priority: %d\n", hdr.getMainThreadPriority()); printf(" CpuId: %d\n", hdr.getMainThreadCpuId()); @@ -571,7 +320,7 @@ void NpdmProcess::displayAciDescHdr(const nn::hac::AccessControlInfoDescBinary& printf(" Flags: \n"); for (size_t i = 0; i < acid.getFlagList().size(); i++) { - printf(" %s (%d)\n", kAcidFlag[acid.getFlagList()[i]].c_str(), acid.getFlagList()[i]); + printf(" %s (%d)\n", getAcidFlagStr(acid.getFlagList()[i]), acid.getFlagList()[i]); } } printf(" ProgramID Restriction\n"); @@ -593,7 +342,7 @@ void NpdmProcess::displayFac(const nn::hac::FileSystemAccessControlBinary& fac) { printf("%s ", i != 0 ? "\n" : ""); } - printf("%s", kFsaFlag[fac.getFsaRightsList()[i]].c_str()); + printf("%s", getFsaRightStr(fac.getFsaRightsList()[i])); if (_HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED)) printf(" (bit %" PRId32 ")", fac.getFsaRightsList()[i]); printf("%s", fac.getFsaRightsList()[i] != fac.getFsaRightsList().atBack() ? ", " : "\n"); @@ -614,7 +363,7 @@ void NpdmProcess::displayFac(const nn::hac::FileSystemAccessControlBinary& fac) printf(" Save Data Owner IDs:\n"); for (size_t i = 0; i < fac.getSaveDataOwnerIdList().size(); i++) { - printf(" 0x%016" PRIx64 " (%s)\n", fac.getSaveDataOwnerIdList()[i].id, kSaveDataOwnerAccessMode[fac.getSaveDataOwnerIdList()[i].access_type].c_str()); + printf(" 0x%016" PRIx64 " (%s)\n", fac.getSaveDataOwnerIdList()[i].id, getSaveDataOwnerAccessModeStr(fac.getSaveDataOwnerIdList()[i].access_type)); } } @@ -647,6 +396,7 @@ void NpdmProcess::displayKernelCap(const nn::hac::KernelCapabilityBinary& kern) printf(" Min: %d\n", threadInfo.getMinCpuId()); printf(" Max: %d\n", threadInfo.getMaxCpuId()); } + if (kern.getSystemCalls().isSet()) { fnd::List syscalls = kern.getSystemCalls().getSystemCalls(); @@ -660,8 +410,8 @@ void NpdmProcess::displayKernelCap(const nn::hac::KernelCapabilityBinary& kern) lineLen = 0; printf("\n "); } - printf("%s%s", kSysCall[syscalls[i]].c_str(), syscalls[i] != syscalls.atBack() ? ", " : "\n"); - lineLen += kSysCall[syscalls[i]].length(); + printf("%s%s", getSystemCallStr(syscalls[i]), syscalls[i] != syscalls.atBack() ? ", " : "\n"); + lineLen += strlen(getSystemCallStr(syscalls[i])); } } if (kern.getMemoryMaps().isSet()) @@ -672,12 +422,12 @@ void NpdmProcess::displayKernelCap(const nn::hac::KernelCapabilityBinary& kern) printf(" MemoryMaps:\n"); for (size_t i = 0; i < maps.size(); i++) { - printf(" 0x%016" PRIx64 " - 0x%016" PRIx64 " (perm=%s) (type=%s)\n", (uint64_t)maps[i].addr << 12, ((uint64_t)(maps[i].addr + maps[i].size) << 12) - 1, kMemMapPerm[maps[i].perm].c_str(), kMemMapType[maps[i].type].c_str()); + printf(" 0x%016" PRIx64 " - 0x%016" PRIx64 " (perm=%s) (type=%s)\n", (uint64_t)maps[i].addr << 12, ((uint64_t)(maps[i].addr + maps[i].size) << 12) - 1, getMemMapPermStr(maps[i].perm), getMemMapTypeStr(maps[i].type)); } //printf(" IoMaps:\n"); for (size_t i = 0; i < ioMaps.size(); i++) { - printf(" 0x%016" PRIx64 " - 0x%016" PRIx64 " (perm=%s) (type=%s)\n", (uint64_t)ioMaps[i].addr << 12, ((uint64_t)(ioMaps[i].addr + ioMaps[i].size) << 12) - 1, kMemMapPerm[ioMaps[i].perm].c_str(), kMemMapType[ioMaps[i].type].c_str()); + printf(" 0x%016" PRIx64 " - 0x%016" PRIx64 " (perm=%s) (type=%s)\n", (uint64_t)ioMaps[i].addr << 12, ((uint64_t)(ioMaps[i].addr + ioMaps[i].size) << 12) - 1, getMemMapPermStr(ioMaps[i].perm), getMemMapTypeStr(ioMaps[i].type)); } } if (kern.getInterupts().isSet()) @@ -716,7 +466,628 @@ void NpdmProcess::displayKernelCap(const nn::hac::KernelCapabilityBinary& kern) { printf("%s ", i != 0 ? "\n" : ""); } - printf("%s%s", kMiscFlag[flagList[i]].c_str(), flagList[i] != flagList.atBack() ? ", " : "\n"); + printf("%s%s", getMiscFlagStr(flagList[i]), flagList[i] != flagList.atBack() ? ", " : "\n"); } } } + +const char* NpdmProcess::getInstructionTypeStr(nn::hac::npdm::InstructionType type) const +{ + const char* str = nullptr; + + switch(type) + { + case (nn::hac::npdm::INSTR_32BIT): + str = "32Bit"; + break; + case (nn::hac::npdm::INSTR_64BIT): + str = "64Bit"; + break; + default: + str = "Unknown"; + break; + } + + return str; +} + +const char* NpdmProcess::getProcAddressSpaceTypeStr(nn::hac::npdm::ProcAddrSpaceType type) const +{ + const char* str = nullptr; + + switch(type) + { + case (nn::hac::npdm::ADDR_SPACE_64BIT): + str = "64Bit"; + break; + case (nn::hac::npdm::ADDR_SPACE_32BIT): + str = "32Bit"; + break; + case (nn::hac::npdm::ADDR_SPACE_32BIT_NO_RESERVED): + str = "32Bit no reserved"; + break; + default: + str = "Unknown"; + break; + } + + return str; +} + +const char* NpdmProcess::getAcidFlagStr(nn::hac::aci::Flag flag) const +{ + const char* str = nullptr; + + switch(flag) + { + case (nn::hac::aci::FLAG_PRODUCTION): + str = "Production"; + break; + case (nn::hac::aci::FLAG_UNQUALIFIED_APPROVAL): + str = "UnqualifiedApproval"; + break; + default: + str = "Unknown"; + break; + } + + return str; +} + +const char* NpdmProcess::getMiscFlagStr(nn::hac::MiscFlagsHandler::Flags flag) const +{ + const char* str = nullptr; + + switch(flag) + { + case (nn::hac::MiscFlagsHandler::FLAG_ENABLE_DEBUG): + str = "EnableDebug"; + break; + case (nn::hac::MiscFlagsHandler::FLAG_FORCE_DEBUG): + str = "ForceDebug"; + break; + default: + str = "Unknown"; + break; + } + + return str; +} + +const char* NpdmProcess::getFsaRightStr(nn::hac::fac::FsAccessFlag flag) const +{ + const char* str = nullptr; + + switch(flag) + { + case (nn::hac::fac::FSA_APPLICATION_INFO): + str = "ApplicationInfo"; + break; + case (nn::hac::fac::FSA_BOOT_MODE_CONTROL): + str = "BootModeControl"; + break; + case (nn::hac::fac::FSA_CALIBRATION): + str = "Calibration"; + break; + case (nn::hac::fac::FSA_SYSTEM_SAVE_DATA): + str = "SystemSaveData"; + break; + case (nn::hac::fac::FSA_GAME_CARD): + str = "GameCard"; + break; + case (nn::hac::fac::FSA_SAVE_DATA_BACKUP): + str = "SaveDataBackUp"; + break; + case (nn::hac::fac::FSA_SAVE_DATA_MANAGEMENT): + str = "SaveDataManagement"; + break; + case (nn::hac::fac::FSA_BIS_ALL_RAW): + str = "BisAllRaw"; + break; + case (nn::hac::fac::FSA_GAME_CARD_RAW): + str = "GameCardRaw"; + break; + case (nn::hac::fac::FSA_GAME_CARD_PRIVATE): + str = "GameCardPrivate"; + break; + case (nn::hac::fac::FSA_SET_TIME): + str = "SetTime"; + break; + case (nn::hac::fac::FSA_CONTENT_MANAGER): + str = "ContentManager"; + break; + case (nn::hac::fac::FSA_IMAGE_MANAGER): + str = "ImageManager"; + break; + case (nn::hac::fac::FSA_CREATE_SAVE_DATA): + str = "CreateSaveData"; + break; + case (nn::hac::fac::FSA_SYSTEM_SAVE_DATA_MANAGEMENT): + str = "SystemSaveDataManagement"; + break; + case (nn::hac::fac::FSA_BIS_FILE_SYSTEM): + str = "BisFileSystem"; + break; + case (nn::hac::fac::FSA_SYSTEM_UPDATE): + str = "SystemUpdate"; + break; + case (nn::hac::fac::FSA_SAVE_DATA_META): + str = "SaveDataMeta"; + break; + case (nn::hac::fac::FSA_DEVICE_SAVE_CONTROL): + str = "DeviceSaveData"; + break; + case (nn::hac::fac::FSA_SETTINGS_CONTROL): + str = "SettingsControl"; + break; + case (nn::hac::fac::FSA_DEBUG): + str = "Debug"; + break; + case (nn::hac::fac::FSA_FULL_PERMISSION): + str = "FullPermission"; + break; + default: + str = "Unknown"; + break; + } + + return str; +} + +const char* NpdmProcess::getSaveDataOwnerAccessModeStr(nn::hac::fac::SaveDataOwnerIdAccessType type) const +{ + const char* str = nullptr; + + switch(type) + { + case (nn::hac::fac::SDO_READ): + str = "Read"; + break; + case (nn::hac::fac::SDO_WRITE): + str = "Write"; + break; + case (nn::hac::fac::SDO_READWRITE): + str = "ReadWrite"; + break; + default: + str = "Unknown"; + break; + } + + return str; +} + +const char* NpdmProcess::getSystemCallStr(byte_t syscall_id) const +{ + const char* str = nullptr; + + switch(syscall_id) + { + case (0x01): + str = "SetHeapSize"; + break; + case (0x02): + str = "SetMemoryPermission"; + break; + case (0x03): + str = "SetMemoryAttribute"; + break; + case (0x04): + str = "MapMemory"; + break; + case (0x05): + str = "UnmapMemory"; + break; + case (0x06): + str = "QueryMemory"; + break; + case (0x07): + str = "ExitProcess"; + break; + case (0x08): + str = "CreateThread"; + break; + case (0x09): + str = "StartThread"; + break; + case (0x0a): + str = "ExitThread"; + break; + case (0x0b): + str = "SleepThread"; + break; + case (0x0c): + str = "GetThreadPriority"; + break; + case (0x0d): + str = "SetThreadPriority"; + break; + case (0x0e): + str = "GetThreadCoreMask"; + break; + case (0x0f): + str = "SetThreadCoreMask"; + break; + case (0x10): + str = "GetCurrentProcessorNumber"; + break; + case (0x11): + str = "SignalEvent"; + break; + case (0x12): + str = "ClearEvent"; + break; + case (0x13): + str = "MapSharedMemory"; + break; + case (0x14): + str = "UnmapSharedMemory"; + break; + case (0x15): + str = "CreateTransferMemory"; + break; + case (0x16): + str = "CloseHandle"; + break; + case (0x17): + str = "ResetSignal"; + break; + case (0x18): + str = "WaitSynchronization"; + break; + case (0x19): + str = "CancelSynchronization"; + break; + case (0x1a): + str = "ArbitrateLock"; + break; + case (0x1b): + str = "ArbitrateUnlock"; + break; + case (0x1c): + str = "WaitProcessWideKeyAtomic"; + break; + case (0x1d): + str = "SignalProcessWideKey"; + break; + case (0x1e): + str = "GetSystemTick"; + break; + case (0x1f): + str = "ConnectToNamedPort"; + break; + case (0x20): + str = "SendSyncRequestLight"; + break; + case (0x21): + str = "SendSyncRequest"; + break; + case (0x22): + str = "SendSyncRequestWithUserBuffer"; + break; + case (0x23): + str = "SendAsyncRequestWithUserBuffer"; + break; + case (0x24): + str = "GetProcessId"; + break; + case (0x25): + str = "GetThreadId"; + break; + case (0x26): + str = "Break"; + break; + case (0x27): + str = "OutputDebugString"; + break; + case (0x28): + str = "ReturnFromException"; + break; + case (0x29): + str = "GetInfo"; + break; + case (0x2a): + str = "FlushEntireDataCache"; + break; + case (0x2b): + str = "FlushDataCache"; + break; + case (0x2c): + str = "MapPhysicalMemory"; + break; + case (0x2d): + str = "UnmapPhysicalMemory"; + break; + case (0x2e): + str = "GetFutureThreadInfo"; + break; + case (0x2f): + str = "GetLastThreadInfo"; + break; + case (0x30): + str = "GetResourceLimitLimitValue"; + break; + case (0x31): + str = "GetResourceLimitCurrentValue"; + break; + case (0x32): + str = "SetThreadActivity"; + break; + case (0x33): + str = "GetThreadContext3"; + break; + case (0x34): + str = "WaitForAddress"; + break; + case (0x35): + str = "SignalToAddress"; + break; + case (0x36): + str = "svc36"; + break; + case (0x37): + str = "svc37"; + break; + case (0x38): + str = "svc38"; + break; + case (0x39): + str = "svc39"; + break; + case (0x3a): + str = "svc3A"; + break; + case (0x3b): + str = "svc3B"; + break; + case (0x3c): + str = "DumpInfo"; + break; + case (0x3d): + str = "DumpInfoNew"; + break; + case (0x3e): + str = "svc3E"; + break; + case (0x3f): + str = "svc3F"; + break; + case (0x40): + str = "CreateSession"; + break; + case (0x41): + str = "AcceptSession"; + break; + case (0x42): + str = "ReplyAndReceiveLight"; + break; + case (0x43): + str = "ReplyAndReceive"; + break; + case (0x44): + str = "ReplyAndReceiveWithUserBuffer"; + break; + case (0x45): + str = "CreateEvent"; + break; + case (0x46): + str = "svc46"; + break; + case (0x47): + str = "svc47"; + break; + case (0x48): + str = "MapPhysicalMemoryUnsafe"; + break; + case (0x49): + str = "UnmapPhysicalMemoryUnsafe"; + break; + case (0x4a): + str = "SetUnsafeLimit"; + break; + case (0x4b): + str = "CreateCodeMemory"; + break; + case (0x4c): + str = "ControlCodeMemory"; + break; + case (0x4d): + str = "SleepSystem"; + break; + case (0x4e): + str = "ReadWriteRegister"; + break; + case (0x4f): + str = "SetProcessActivity"; + break; + case (0x50): + str = "CreateSharedMemory"; + break; + case (0x51): + str = "MapTransferMemory"; + break; + case (0x52): + str = "UnmapTransferMemory"; + break; + case (0x53): + str = "CreateInterruptEvent"; + break; + case (0x54): + str = "QueryPhysicalAddress"; + break; + case (0x55): + str = "QueryIoMapping"; + break; + case (0x56): + str = "CreateDeviceAddressSpace"; + break; + case (0x57): + str = "AttachDeviceAddressSpace"; + break; + case (0x58): + str = "DetachDeviceAddressSpace"; + break; + case (0x59): + str = "MapDeviceAddressSpaceByForce"; + break; + case (0x5a): + str = "MapDeviceAddressSpaceAligned"; + break; + case (0x5b): + str = "MapDeviceAddressSpace"; + break; + case (0x5c): + str = "UnmapDeviceAddressSpace"; + break; + case (0x5d): + str = "InvalidateProcessDataCache"; + break; + case (0x5e): + str = "StoreProcessDataCache"; + break; + case (0x5f): + str = "FlushProcessDataCache"; + break; + case (0x60): + str = "DebugActiveProcess"; + break; + case (0x61): + str = "BreakDebugProcess"; + break; + case (0x62): + str = "TerminateDebugProcess"; + break; + case (0x63): + str = "GetDebugEvent"; + break; + case (0x64): + str = "ContinueDebugEvent"; + break; + case (0x65): + str = "GetProcessList"; + break; + case (0x66): + str = "GetThreadList"; + break; + case (0x67): + str = "GetDebugThreadContext"; + break; + case (0x68): + str = "SetDebugThreadContext"; + break; + case (0x69): + str = "QueryDebugProcessMemory"; + break; + case (0x6a): + str = "ReadDebugProcessMemory"; + break; + case (0x6b): + str = "WriteDebugProcessMemory"; + break; + case (0x6c): + str = "SetHardwareBreakPoint"; + break; + case (0x6d): + str = "GetDebugThreadParam"; + break; + case (0x6e): + str = "svc6E"; + break; + case (0x6f): + str = "GetSystemInfo"; + break; + case (0x70): + str = "CreatePort"; + break; + case (0x71): + str = "ManageNamedPort"; + break; + case (0x72): + str = "ConnectToPort"; + break; + case (0x73): + str = "SetProcessMemoryPermission"; + break; + case (0x74): + str = "MapProcessMemory"; + break; + case (0x75): + str = "UnmapProcessMemory"; + break; + case (0x76): + str = "QueryProcessMemory"; + break; + case (0x77): + str = "MapProcessCodeMemory"; + break; + case (0x78): + str = "UnmapProcessCodeMemory"; + break; + case (0x79): + str = "CreateProcess"; + break; + case (0x7a): + str = "StartProcess"; + break; + case (0x7b): + str = "TerminateProcess"; + break; + case (0x7c): + str = "GetProcessInfo"; + break; + case (0x7d): + str = "CreateResourceLimit"; + break; + case (0x7e): + str = "SetResourceLimitLimitValue"; + break; + case (0x7f): + str = "CallSecureMonitor"; + break; + default: + str = "Unknown"; + break; + } + + return str; +} + +const char* NpdmProcess::getMemMapPermStr(nn::hac::MemoryMappingHandler::MemoryPerm type) const +{ + const char* str = nullptr; + + switch(type) + { + case (nn::hac::MemoryMappingHandler::MEM_RW): + str = "RW"; + break; + case (nn::hac::MemoryMappingHandler::MEM_RO): + str = "RO"; + break; + default: + str = "Unknown"; + break; + } + + return str; +} + +const char* NpdmProcess::getMemMapTypeStr(nn::hac::MemoryMappingHandler::MappingType type) const +{ + const char* str = nullptr; + + switch(type) + { + case (nn::hac::MemoryMappingHandler::MAP_IO): + str = "Io"; + break; + case (nn::hac::MemoryMappingHandler::MAP_STATIC): + str = "Static"; + break; + default: + str = "Unknown"; + break; + } + + return str; +} \ No newline at end of file diff --git a/programs/nstool/source/NpdmProcess.h b/programs/nstool/source/NpdmProcess.h index 6ed8959..9e4fc24 100644 --- a/programs/nstool/source/NpdmProcess.h +++ b/programs/nstool/source/NpdmProcess.h @@ -41,4 +41,14 @@ private: void displayFac(const nn::hac::FileSystemAccessControlBinary& fac); void displaySac(const nn::hac::ServiceAccessControlBinary& sac); void displayKernelCap(const nn::hac::KernelCapabilityBinary& kern); + + const char* getInstructionTypeStr(nn::hac::npdm::InstructionType type) const; + const char* getProcAddressSpaceTypeStr(nn::hac::npdm::ProcAddrSpaceType type) const; + const char* getAcidFlagStr(nn::hac::aci::Flag flag) const; + const char* getMiscFlagStr(nn::hac::MiscFlagsHandler::Flags flag) const; + const char* getFsaRightStr(nn::hac::fac::FsAccessFlag flag) const; + const char* getSaveDataOwnerAccessModeStr(nn::hac::fac::SaveDataOwnerIdAccessType type) const; + const char* getSystemCallStr(byte_t syscall_id) const; + const char* getMemMapPermStr(nn::hac::MemoryMappingHandler::MemoryPerm type) const; + const char* getMemMapTypeStr(nn::hac::MemoryMappingHandler::MappingType type) const; }; \ No newline at end of file