erpt: add ids (and autogeneration tool)

This commit is contained in:
Michael Scire 2020-04-08 07:17:42 -07:00
parent 065485b971
commit 5062329979
5 changed files with 1919 additions and 0 deletions

View file

@ -40,6 +40,7 @@
#include "stratosphere/boot2.hpp"
#include "stratosphere/cfg.hpp"
#include "stratosphere/dmnt.hpp"
#include "stratosphere/erpt.hpp"
#include "stratosphere/fatal.hpp"
#include "stratosphere/hid.hpp"
#include "stratosphere/hos.hpp"

View file

@ -0,0 +1,19 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/erpt/erpt_ids.autogen.hpp>

View file

@ -0,0 +1,778 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
/* NOTE: This file is auto-generated. */
/* Do not make edits to this file by hand. */
#define AMS_ERPT_FOREACH_FIELD_TYPE(HANDLER) \
HANDLER(FieldType_NumericU64, 0 ) \
HANDLER(FieldType_NumericU32, 1 ) \
HANDLER(FieldType_NumericI64, 2 ) \
HANDLER(FieldType_NumericI32, 3 ) \
HANDLER(FieldType_String, 4 ) \
HANDLER(FieldType_U8Array, 5 ) \
HANDLER(FieldType_U32Array, 6 ) \
HANDLER(FieldType_U64Array, 7 ) \
HANDLER(FieldType_I32Array, 8 ) \
HANDLER(FieldType_I64Array, 9 ) \
HANDLER(FieldType_Bool, 10) \
HANDLER(FieldType_NumericU16, 11) \
HANDLER(FieldType_NumericU8, 12) \
HANDLER(FieldType_NumericI16, 13) \
HANDLER(FieldType_NumericI8, 14) \
HANDLER(FieldType_I8Array, 15) \
#define AMS_ERPT_FOREACH_CATEGORY(HANDLER) \
HANDLER(Test, 0 ) \
HANDLER(ErrorInfo, 1 ) \
HANDLER(ConnectionStatusInfo, 2 ) \
HANDLER(NetworkInfo, 3 ) \
HANDLER(NXMacAddressInfo, 4 ) \
HANDLER(StealthNetworkInfo, 5 ) \
HANDLER(LimitHighCapacityInfo, 6 ) \
HANDLER(NATTypeInfo, 7 ) \
HANDLER(WirelessAPMacAddressInfo, 8 ) \
HANDLER(GlobalIPAddressInfo, 9 ) \
HANDLER(EnableWirelessInterfaceInfo, 10 ) \
HANDLER(EnableWifiInfo, 11 ) \
HANDLER(EnableBluetoothInfo, 12 ) \
HANDLER(EnableNFCInfo, 13 ) \
HANDLER(NintendoZoneSSIDListVersionInfo, 14 ) \
HANDLER(LANAdapterMacAddressInfo, 15 ) \
HANDLER(ApplicationInfo, 16 ) \
HANDLER(OccurrenceInfo, 17 ) \
HANDLER(ProductModelInfo, 18 ) \
HANDLER(CurrentLanguageInfo, 19 ) \
HANDLER(UseNetworkTimeProtocolInfo, 20 ) \
HANDLER(TimeZoneInfo, 21 ) \
HANDLER(ControllerFirmwareInfo, 22 ) \
HANDLER(VideoOutputInfo, 23 ) \
HANDLER(NANDFreeSpaceInfo, 24 ) \
HANDLER(SDCardFreeSpaceInfo, 25 ) \
HANDLER(ScreenBrightnessInfo, 26 ) \
HANDLER(AudioFormatInfo, 27 ) \
HANDLER(MuteOnHeadsetUnpluggedInfo, 28 ) \
HANDLER(NumUserRegisteredInfo, 29 ) \
HANDLER(DataDeletionInfo, 30 ) \
HANDLER(ControllerVibrationInfo, 31 ) \
HANDLER(LockScreenInfo, 32 ) \
HANDLER(InternalBatteryLotNumberInfo, 33 ) \
HANDLER(LeftControllerSerialNumberInfo, 34 ) \
HANDLER(RightControllerSerialNumberInfo, 35 ) \
HANDLER(NotificationInfo, 36 ) \
HANDLER(TVInfo, 37 ) \
HANDLER(SleepInfo, 38 ) \
HANDLER(ConnectionInfo, 39 ) \
HANDLER(NetworkErrorInfo, 40 ) \
HANDLER(FileAccessPathInfo, 41 ) \
HANDLER(GameCardCIDInfo, 42 ) \
HANDLER(NANDCIDInfo, 43 ) \
HANDLER(MicroSDCIDInfo, 44 ) \
HANDLER(NANDSpeedModeInfo, 45 ) \
HANDLER(MicroSDSpeedModeInfo, 46 ) \
HANDLER(GameCardSpeedModeInfo, 47 ) \
HANDLER(UserAccountInternalIDInfo, 48 ) \
HANDLER(NetworkServiceAccountInternalIDInfo, 49 ) \
HANDLER(NintendoAccountInternalIDInfo, 50 ) \
HANDLER(USB3AvailableInfo, 51 ) \
HANDLER(CallStackInfo, 52 ) \
HANDLER(SystemStartupLogInfo, 53 ) \
HANDLER(RegionSettingInfo, 54 ) \
HANDLER(NintendoZoneConnectedInfo, 55 ) \
HANDLER(ForceSleepInfo, 56 ) \
HANDLER(ChargerInfo, 57 ) \
HANDLER(RadioStrengthInfo, 58 ) \
HANDLER(ErrorInfoAuto, 59 ) \
HANDLER(AccessPointInfo, 60 ) \
HANDLER(SystemPowerStateInfo, 62 ) \
HANDLER(PerformanceInfo, 63 ) \
HANDLER(ThrottlingInfo, 64 ) \
HANDLER(GameCardErrorInfo, 65 ) \
HANDLER(EdidInfo, 66 ) \
HANDLER(ThermalInfo, 67 ) \
HANDLER(CradleFirmwareInfo, 68 ) \
HANDLER(RunningApplicationInfo, 69 ) \
HANDLER(RunningAppletInfo, 70 ) \
HANDLER(FocusedAppletHistoryInfo, 71 ) \
HANDLER(BatteryChargeInfo, 73 ) \
HANDLER(NANDExtendedCsd, 74 ) \
HANDLER(NANDPatrolInfo, 75 ) \
HANDLER(NANDErrorInfo, 76 ) \
HANDLER(NANDDriverLog, 77 ) \
HANDLER(SdCardSizeSpec, 78 ) \
HANDLER(SdCardErrorInfo, 79 ) \
HANDLER(SdCardDriverLog , 80 ) \
HANDLER(FsProxyErrorInfo, 81 ) \
HANDLER(SystemAppletSceneInfo, 82 ) \
HANDLER(VideoInfo, 83 ) \
HANDLER(GpuErrorInfo, 84 ) \
HANDLER(PowerClockInfo, 85 ) \
HANDLER(AdspErrorInfo, 86 ) \
HANDLER(NvDispDeviceInfo, 87 ) \
HANDLER(NvDispDcWindowInfo, 88 ) \
HANDLER(NvDispDpModeInfo, 89 ) \
HANDLER(NvDispDpLinkSpec, 90 ) \
HANDLER(NvDispDpLinkStatus, 91 ) \
HANDLER(NvDispDpHdcpInfo, 92 ) \
HANDLER(NvDispDpAuxCecInfo, 93 ) \
HANDLER(NvDispDcInfo, 94 ) \
HANDLER(NvDispDsiInfo, 95 ) \
HANDLER(NvDispErrIDInfo, 96 ) \
HANDLER(SdCardMountInfo, 97 ) \
HANDLER(RetailInteractiveDisplayInfo, 98 ) \
HANDLER(CompositorStateInfo, 99 ) \
HANDLER(CompositorLayerInfo, 100) \
HANDLER(CompositorDisplayInfo, 101) \
HANDLER(CompositorHWCInfo, 102) \
HANDLER(MonitorCapability, 103) \
HANDLER(ErrorReportSharePermissionInfo, 104) \
HANDLER(MultimediaInfo, 105) \
HANDLER(ConnectedControllerInfo, 106) \
HANDLER(FsMemoryInfo, 107) \
HANDLER(UserClockContextInfo, 108) \
HANDLER(NetworkClockContextInfo, 109) \
HANDLER(AcpGeneralSettingsInfo, 110) \
HANDLER(AcpPlayLogSettingsInfo, 111) \
HANDLER(AcpAocSettingsInfo, 112) \
HANDLER(AcpBcatSettingsInfo, 113) \
HANDLER(AcpStorageSettingsInfo, 114) \
HANDLER(AcpRatingSettingsInfo, 115) \
HANDLER(MonitorSettings, 116) \
HANDLER(RebootlessSystemUpdateVersionInfo, 117) \
HANDLER(NifmConnectionTestInfo, 118) \
HANDLER(PcieLoggedStateInfo, 119) \
HANDLER(NetworkSecurityCertificateInfo, 120) \
HANDLER(AcpNeighborDetectionInfo, 121) \
HANDLER(GpuCrashInfo, 122) \
HANDLER(UsbStateInfo, 123) \
HANDLER(NvHostErrInfo, 124) \
HANDLER(RunningUlaInfo, 125) \
#define AMS_ERPT_FOREACH_FIELD(HANDLER) \
HANDLER(TestU64, 0, 0, 0 ) \
HANDLER(TestU32, 1, 0, 1 ) \
HANDLER(TestI64, 2, 0, 2 ) \
HANDLER(TestI32, 3, 0, 3 ) \
HANDLER(TestString, 4, 0, 4 ) \
HANDLER(TestU8Array, 5, 0, 5 ) \
HANDLER(TestU32Array, 6, 0, 6 ) \
HANDLER(TestU64Array, 7, 0, 7 ) \
HANDLER(TestI32Array, 8, 0, 8 ) \
HANDLER(TestI64Array, 9, 0, 9 ) \
HANDLER(ErrorCode, 10, 1, 4 ) \
HANDLER(ErrorDescription, 11, 1, 4 ) \
HANDLER(OccurrenceTimestamp, 12, 59, 2 ) \
HANDLER(ReportIdentifier, 13, 59, 4 ) \
HANDLER(ConnectionStatus, 14, 2, 4 ) \
HANDLER(AccessPointSSID, 15, 60, 4 ) \
HANDLER(AccessPointSecurityType, 16, 60, 4 ) \
HANDLER(RadioStrength, 17, 58, 1 ) \
HANDLER(NXMacAddress, 18, 4, 4 ) \
HANDLER(IPAddressAcquisitionMethod, 19, 3, 1 ) \
HANDLER(CurrentIPAddress, 20, 3, 4 ) \
HANDLER(SubnetMask, 21, 3, 4 ) \
HANDLER(GatewayIPAddress, 22, 3, 4 ) \
HANDLER(DNSType, 23, 3, 1 ) \
HANDLER(PriorityDNSIPAddress, 24, 3, 4 ) \
HANDLER(AlternateDNSIPAddress, 25, 3, 4 ) \
HANDLER(UseProxyFlag, 26, 3, 10) \
HANDLER(ProxyIPAddress, 27, 3, 4 ) \
HANDLER(ProxyPort, 28, 3, 1 ) \
HANDLER(ProxyAutoAuthenticateFlag, 29, 3, 10) \
HANDLER(MTU, 30, 3, 1 ) \
HANDLER(ConnectAutomaticallyFlag, 31, 3, 10) \
HANDLER(UseStealthNetworkFlag, 32, 5, 10) \
HANDLER(LimitHighCapacityFlag, 33, 6, 10) \
HANDLER(NATType, 34, 7, 4 ) \
HANDLER(WirelessAPMacAddress, 35, 8, 4 ) \
HANDLER(GlobalIPAddress, 36, 9, 4 ) \
HANDLER(EnableWirelessInterfaceFlag, 37, 10, 10) \
HANDLER(EnableWifiFlag, 38, 11, 10) \
HANDLER(EnableBluetoothFlag, 39, 12, 10) \
HANDLER(EnableNFCFlag, 40, 13, 10) \
HANDLER(NintendoZoneSSIDListVersion, 41, 14, 4 ) \
HANDLER(LANAdapterMacAddress, 42, 15, 4 ) \
HANDLER(ApplicationID, 43, 16, 4 ) \
HANDLER(ApplicationTitle, 44, 16, 4 ) \
HANDLER(ApplicationVersion, 45, 16, 4 ) \
HANDLER(ApplicationStorageLocation, 46, 16, 4 ) \
HANDLER(DownloadContentType, 47, 17, 4 ) \
HANDLER(InstallContentType, 48, 17, 4 ) \
HANDLER(ConsoleStartingUpFlag, 49, 17, 10) \
HANDLER(SystemStartingUpFlag, 50, 17, 10) \
HANDLER(ConsoleFirstInitFlag, 51, 17, 10) \
HANDLER(HomeMenuScreenDisplayedFlag, 52, 17, 10) \
HANDLER(DataManagementScreenDisplayedFlag, 53, 17, 10) \
HANDLER(ConnectionTestingFlag, 54, 17, 10) \
HANDLER(ApplicationRunningFlag, 55, 17, 10) \
HANDLER(DataCorruptionDetectedFlag, 56, 17, 10) \
HANDLER(ProductModel, 57, 18, 4 ) \
HANDLER(CurrentLanguage, 58, 19, 4 ) \
HANDLER(UseNetworkTimeProtocolFlag, 59, 20, 10) \
HANDLER(TimeZone, 60, 21, 4 ) \
HANDLER(ControllerFirmware, 61, 22, 4 ) \
HANDLER(VideoOutputSetting, 62, 23, 4 ) \
HANDLER(NANDFreeSpace, 63, 24, 0 ) \
HANDLER(SDCardFreeSpace, 64, 25, 0 ) \
HANDLER(SerialNumber, 65, 59, 4 ) \
HANDLER(OsVersion, 66, 59, 4 ) \
HANDLER(ScreenBrightnessAutoAdjustFlag, 67, 26, 10) \
HANDLER(HdmiAudioOutputMode, 68, 27, 4 ) \
HANDLER(SpeakerAudioOutputMode, 69, 27, 4 ) \
HANDLER(HeadphoneAudioOutputMode, 70, 27, 4 ) \
HANDLER(MuteOnHeadsetUnpluggedFlag, 71, 28, 10) \
HANDLER(NumUserRegistered, 72, 29, 3 ) \
HANDLER(StorageAutoOrganizeFlag, 73, 30, 10) \
HANDLER(ControllerVibrationVolume, 74, 31, 4 ) \
HANDLER(LockScreenFlag, 75, 32, 10) \
HANDLER(InternalBatteryLotNumber, 76, 33, 4 ) \
HANDLER(LeftControllerSerialNumber, 77, 34, 4 ) \
HANDLER(RightControllerSerialNumber, 78, 35, 4 ) \
HANDLER(NotifyInGameDownloadCompletionFlag, 79, 36, 10) \
HANDLER(NotificationSoundFlag, 80, 36, 10) \
HANDLER(TVResolutionSetting, 81, 37, 4 ) \
HANDLER(RGBRangeSetting, 82, 37, 4 ) \
HANDLER(ReduceScreenBurnFlag, 83, 37, 10) \
HANDLER(TVAllowsCecFlag, 84, 37, 10) \
HANDLER(HandheldModeTimeToScreenSleep, 85, 38, 4 ) \
HANDLER(ConsoleModeTimeToScreenSleep, 86, 38, 4 ) \
HANDLER(StopAutoSleepDuringContentPlayFlag, 87, 38, 10) \
HANDLER(LastConnectionTestDownloadSpeed, 88, 39, 1 ) \
HANDLER(LastConnectionTestUploadSpeed, 89, 39, 1 ) \
HANDLER(DEPRECATED_ServerFQDN, 90, 40, 4 ) \
HANDLER(HTTPRequestContents, 91, 40, 4 ) \
HANDLER(HTTPRequestResponseContents, 92, 40, 4 ) \
HANDLER(EdgeServerIPAddress, 93, 40, 4 ) \
HANDLER(CDNContentPath, 94, 40, 4 ) \
HANDLER(FileAccessPath, 95, 41, 4 ) \
HANDLER(GameCardCID, 96, 42, 5 ) \
HANDLER(NANDCID, 97, 43, 5 ) \
HANDLER(MicroSDCID, 98, 44, 5 ) \
HANDLER(NANDSpeedMode, 99, 45, 4 ) \
HANDLER(MicroSDSpeedMode, 100, 46, 4 ) \
HANDLER(GameCardSpeedMode, 101, 47, 4 ) \
HANDLER(UserAccountInternalID, 102, 48, 4 ) \
HANDLER(NetworkServiceAccountInternalID, 103, 49, 4 ) \
HANDLER(NintendoAccountInternalID, 104, 50, 4 ) \
HANDLER(USB3AvailableFlag, 105, 51, 10) \
HANDLER(CallStack, 106, 52, 4 ) \
HANDLER(SystemStartupLog, 107, 53, 4 ) \
HANDLER(RegionSetting, 108, 54, 4 ) \
HANDLER(NintendoZoneConnectedFlag, 109, 55, 10) \
HANDLER(ForcedSleepHighTemperatureReading, 110, 56, 1 ) \
HANDLER(ForcedSleepFanSpeedReading, 111, 56, 1 ) \
HANDLER(ForcedSleepHWInfo, 112, 56, 4 ) \
HANDLER(AbnormalPowerStateInfo, 113, 57, 1 ) \
HANDLER(ScreenBrightnessLevel, 114, 26, 4 ) \
HANDLER(ProgramId, 115, 1, 4 ) \
HANDLER(AbortFlag, 116, 1, 10) \
HANDLER(ReportVisibilityFlag, 117, 59, 10) \
HANDLER(FatalFlag, 118, 1, 10) \
HANDLER(OccurrenceTimestampNet, 119, 59, 2 ) \
HANDLER(ResultBacktrace, 120, 1, 6 ) \
HANDLER(GeneralRegisterAarch32, 121, 1, 6 ) \
HANDLER(StackBacktrace32, 122, 1, 6 ) \
HANDLER(ExceptionInfoAarch32, 123, 1, 6 ) \
HANDLER(GeneralRegisterAarch64, 124, 1, 7 ) \
HANDLER(ExceptionInfoAarch64, 125, 1, 7 ) \
HANDLER(StackBacktrace64, 126, 1, 7 ) \
HANDLER(RegisterSetFlag32, 127, 1, 1 ) \
HANDLER(RegisterSetFlag64, 128, 1, 0 ) \
HANDLER(ProgramMappedAddr32, 129, 1, 1 ) \
HANDLER(ProgramMappedAddr64, 130, 1, 0 ) \
HANDLER(AbortType, 131, 1, 1 ) \
HANDLER(PrivateOsVersion, 132, 59, 4 ) \
HANDLER(CurrentSystemPowerState, 133, 62, 1 ) \
HANDLER(PreviousSystemPowerState, 134, 62, 1 ) \
HANDLER(DestinationSystemPowerState, 135, 62, 1 ) \
HANDLER(PscTransitionCurrentState, 136, 1, 1 ) \
HANDLER(PscTransitionPreviousState, 137, 1, 1 ) \
HANDLER(PscInitializedList, 138, 1, 5 ) \
HANDLER(PscCurrentPmStateList, 139, 1, 6 ) \
HANDLER(PscNextPmStateList, 140, 1, 6 ) \
HANDLER(PerformanceMode, 141, 63, 3 ) \
HANDLER(PerformanceConfiguration, 142, 63, 1 ) \
HANDLER(Throttled, 143, 64, 10) \
HANDLER(ThrottlingDuration, 144, 64, 2 ) \
HANDLER(ThrottlingTimestamp, 145, 64, 2 ) \
HANDLER(GameCardCrcErrorCount, 146, 65, 1 ) \
HANDLER(GameCardAsicCrcErrorCount, 147, 65, 1 ) \
HANDLER(GameCardRefreshCount, 148, 65, 1 ) \
HANDLER(GameCardReadRetryCount, 149, 65, 1 ) \
HANDLER(EdidBlock, 150, 66, 5 ) \
HANDLER(EdidExtensionBlock, 151, 66, 5 ) \
HANDLER(CreateProcessFailureFlag, 152, 1, 10) \
HANDLER(TemperaturePcb, 153, 67, 3 ) \
HANDLER(TemperatureSoc, 154, 67, 3 ) \
HANDLER(CurrentFanDuty, 155, 67, 3 ) \
HANDLER(LastDvfsThresholdTripped, 156, 67, 3 ) \
HANDLER(CradlePdcHFwVersion, 157, 68, 1 ) \
HANDLER(CradlePdcAFwVersion, 158, 68, 1 ) \
HANDLER(CradleMcuFwVersion, 159, 68, 1 ) \
HANDLER(CradleDp2HdmiFwVersion, 160, 68, 1 ) \
HANDLER(RunningApplicationId, 161, 69, 4 ) \
HANDLER(RunningApplicationTitle, 162, 69, 4 ) \
HANDLER(RunningApplicationVersion, 163, 69, 4 ) \
HANDLER(RunningApplicationStorageLocation, 164, 69, 4 ) \
HANDLER(RunningAppletList, 165, 70, 7 ) \
HANDLER(FocusedAppletHistory, 166, 71, 7 ) \
HANDLER(CompositorState, 167, 99, 4 ) \
HANDLER(CompositorLayerState, 168, 100, 4 ) \
HANDLER(CompositorDisplayState, 169, 101, 4 ) \
HANDLER(CompositorHWCState, 170, 102, 4 ) \
HANDLER(InputCurrentLimit, 171, 73, 3 ) \
HANDLER(BoostModeCurrentLimit, 172, 73, 3 ) \
HANDLER(FastChargeCurrentLimit, 173, 73, 3 ) \
HANDLER(ChargeVoltageLimit, 174, 73, 3 ) \
HANDLER(ChargeConfiguration, 175, 73, 3 ) \
HANDLER(HizMode, 176, 73, 10) \
HANDLER(ChargeEnabled, 177, 73, 10) \
HANDLER(PowerSupplyPath, 178, 73, 3 ) \
HANDLER(BatteryTemperature, 179, 73, 3 ) \
HANDLER(BatteryChargePercent, 180, 73, 3 ) \
HANDLER(BatteryChargeVoltage, 181, 73, 3 ) \
HANDLER(BatteryAge, 182, 73, 3 ) \
HANDLER(PowerRole, 183, 73, 3 ) \
HANDLER(PowerSupplyType, 184, 73, 3 ) \
HANDLER(PowerSupplyVoltage, 185, 73, 3 ) \
HANDLER(PowerSupplyCurrent, 186, 73, 3 ) \
HANDLER(FastBatteryChargingEnabled, 187, 73, 10) \
HANDLER(ControllerPowerSupplyAcquired, 188, 73, 10) \
HANDLER(OtgRequested, 189, 73, 10) \
HANDLER(NANDPreEolInfo, 190, 74, 1 ) \
HANDLER(NANDDeviceLifeTimeEstTypA, 191, 74, 1 ) \
HANDLER(NANDDeviceLifeTimeEstTypB, 192, 74, 1 ) \
HANDLER(NANDPatrolCount, 193, 75, 1 ) \
HANDLER(NANDNumActivationFailures, 194, 76, 1 ) \
HANDLER(NANDNumActivationErrorCorrections, 195, 76, 1 ) \
HANDLER(NANDNumReadWriteFailures, 196, 76, 1 ) \
HANDLER(NANDNumReadWriteErrorCorrections, 197, 76, 1 ) \
HANDLER(NANDErrorLog, 198, 77, 4 ) \
HANDLER(SdCardUserAreaSize, 199, 78, 2 ) \
HANDLER(SdCardProtectedAreaSize, 200, 78, 2 ) \
HANDLER(SdCardNumActivationFailures, 201, 79, 1 ) \
HANDLER(SdCardNumActivationErrorCorrections, 202, 79, 1 ) \
HANDLER(SdCardNumReadWriteFailures, 203, 79, 1 ) \
HANDLER(SdCardNumReadWriteErrorCorrections, 204, 79, 1 ) \
HANDLER(SdCardErrorLog, 205, 80, 4 ) \
HANDLER(EncryptionKey, 206, 1, 5 ) \
HANDLER(EncryptedExceptionInfo, 207, 1, 5 ) \
HANDLER(GameCardTimeoutRetryErrorCount, 208, 65, 1 ) \
HANDLER(FsRemountForDataCorruptCount, 209, 81, 1 ) \
HANDLER(FsRemountForDataCorruptRetryOutCount, 210, 81, 1 ) \
HANDLER(GameCardInsertionCount, 211, 65, 1 ) \
HANDLER(GameCardRemovalCount, 212, 65, 1 ) \
HANDLER(GameCardAsicInitializeCount, 213, 65, 1 ) \
HANDLER(TestU16, 214, 0, 11) \
HANDLER(TestU8, 215, 0, 12) \
HANDLER(TestI16, 216, 0, 13) \
HANDLER(TestI8, 217, 0, 14) \
HANDLER(SystemAppletScene, 218, 82, 12) \
HANDLER(CodecType, 219, 83, 1 ) \
HANDLER(DecodeBuffers, 220, 83, 1 ) \
HANDLER(FrameWidth, 221, 83, 3 ) \
HANDLER(FrameHeight, 222, 83, 3 ) \
HANDLER(ColorPrimaries, 223, 83, 12) \
HANDLER(TransferCharacteristics, 224, 83, 12) \
HANDLER(MatrixCoefficients, 225, 83, 12) \
HANDLER(DisplayWidth, 226, 83, 3 ) \
HANDLER(DisplayHeight, 227, 83, 3 ) \
HANDLER(DARWidth, 228, 83, 3 ) \
HANDLER(DARHeight, 229, 83, 3 ) \
HANDLER(ColorFormat, 230, 83, 1 ) \
HANDLER(ColorSpace, 231, 83, 4 ) \
HANDLER(SurfaceLayout, 232, 83, 4 ) \
HANDLER(BitStream, 233, 83, 5 ) \
HANDLER(VideoDecState, 234, 83, 4 ) \
HANDLER(GpuErrorChannelId, 235, 84, 1 ) \
HANDLER(GpuErrorAruId, 236, 84, 0 ) \
HANDLER(GpuErrorType, 237, 84, 1 ) \
HANDLER(GpuErrorFaultInfo, 238, 84, 1 ) \
HANDLER(GpuErrorWriteAccess, 239, 84, 10) \
HANDLER(GpuErrorFaultAddress, 240, 84, 0 ) \
HANDLER(GpuErrorFaultUnit, 241, 84, 1 ) \
HANDLER(GpuErrorFaultType, 242, 84, 1 ) \
HANDLER(GpuErrorHwContextPointer, 243, 84, 0 ) \
HANDLER(GpuErrorContextStatus, 244, 84, 1 ) \
HANDLER(GpuErrorPbdmaIntr, 245, 84, 1 ) \
HANDLER(GpuErrorPbdmaErrorType, 246, 84, 1 ) \
HANDLER(GpuErrorPbdmaHeaderShadow, 247, 84, 1 ) \
HANDLER(GpuErrorPbdmaHeader, 248, 84, 1 ) \
HANDLER(GpuErrorPbdmaGpShadow0, 249, 84, 1 ) \
HANDLER(GpuErrorPbdmaGpShadow1, 250, 84, 1 ) \
HANDLER(AccessPointChannel, 251, 60, 11) \
HANDLER(ThreadName, 252, 1, 4 ) \
HANDLER(AdspExceptionRegisters, 253, 86, 6 ) \
HANDLER(AdspExceptionSpsr, 254, 86, 1 ) \
HANDLER(AdspExceptionProgramCounter, 255, 86, 1 ) \
HANDLER(AdspExceptionLinkRegister, 256, 86, 1 ) \
HANDLER(AdspExceptionStackPointer, 257, 86, 1 ) \
HANDLER(AdspExceptionArmModeRegisters, 258, 86, 6 ) \
HANDLER(AdspExceptionStackAddress, 259, 86, 1 ) \
HANDLER(AdspExceptionStackDump, 260, 86, 6 ) \
HANDLER(AdspExceptionReason, 261, 86, 1 ) \
HANDLER(OscillatorClock, 262, 85, 1 ) \
HANDLER(CpuDvfsTableClocks, 263, 85, 6 ) \
HANDLER(CpuDvfsTableVoltages, 264, 85, 8 ) \
HANDLER(GpuDvfsTableClocks, 265, 85, 6 ) \
HANDLER(GpuDvfsTableVoltages, 266, 85, 8 ) \
HANDLER(EmcDvfsTableClocks, 267, 85, 6 ) \
HANDLER(EmcDvfsTableVoltages, 268, 85, 8 ) \
HANDLER(ModuleClockFrequencies, 269, 85, 6 ) \
HANDLER(ModuleClockEnableFlags, 270, 85, 5 ) \
HANDLER(ModulePowerEnableFlags, 271, 85, 5 ) \
HANDLER(ModuleResetAssertFlags, 272, 85, 5 ) \
HANDLER(ModuleMinimumVoltageClockRates, 273, 85, 6 ) \
HANDLER(PowerDomainEnableFlags, 274, 85, 5 ) \
HANDLER(PowerDomainVoltages, 275, 85, 8 ) \
HANDLER(AccessPointRssi, 276, 58, 3 ) \
HANDLER(FuseInfo, 277, 85, 6 ) \
HANDLER(VideoLog, 278, 83, 4 ) \
HANDLER(GameCardDeviceId, 279, 42, 5 ) \
HANDLER(GameCardAsicReinitializeCount, 280, 65, 11) \
HANDLER(GameCardAsicReinitializeFailureCount, 281, 65, 11) \
HANDLER(GameCardAsicReinitializeFailureDetail, 282, 65, 11) \
HANDLER(GameCardRefreshSuccessCount, 283, 65, 11) \
HANDLER(GameCardAwakenCount, 284, 65, 1 ) \
HANDLER(GameCardAwakenFailureCount, 285, 65, 11) \
HANDLER(GameCardReadCountFromInsert, 286, 65, 1 ) \
HANDLER(GameCardReadCountFromAwaken, 287, 65, 1 ) \
HANDLER(GameCardLastReadErrorPageAddress, 288, 65, 1 ) \
HANDLER(GameCardLastReadErrorPageCount, 289, 65, 1 ) \
HANDLER(AppletManagerContextTrace, 290, 1, 8 ) \
HANDLER(NvDispIsRegistered, 291, 87, 10) \
HANDLER(NvDispIsSuspend, 292, 87, 10) \
HANDLER(NvDispDC0SurfaceNum, 293, 87, 8 ) \
HANDLER(NvDispDC1SurfaceNum, 294, 87, 8 ) \
HANDLER(NvDispWindowSrcRectX, 295, 88, 1 ) \
HANDLER(NvDispWindowSrcRectY, 296, 88, 1 ) \
HANDLER(NvDispWindowSrcRectWidth, 297, 88, 1 ) \
HANDLER(NvDispWindowSrcRectHeight, 298, 88, 1 ) \
HANDLER(NvDispWindowDstRectX, 299, 88, 1 ) \
HANDLER(NvDispWindowDstRectY, 300, 88, 1 ) \
HANDLER(NvDispWindowDstRectWidth, 301, 88, 1 ) \
HANDLER(NvDispWindowDstRectHeight, 302, 88, 1 ) \
HANDLER(NvDispWindowIndex, 303, 88, 1 ) \
HANDLER(NvDispWindowBlendOperation, 304, 88, 1 ) \
HANDLER(NvDispWindowAlphaOperation, 305, 88, 1 ) \
HANDLER(NvDispWindowDepth, 306, 88, 1 ) \
HANDLER(NvDispWindowAlpha, 307, 88, 12) \
HANDLER(NvDispWindowHFilter, 308, 88, 10) \
HANDLER(NvDispWindowVFilter, 309, 88, 10) \
HANDLER(NvDispWindowOptions, 310, 88, 1 ) \
HANDLER(NvDispWindowSyncPointId, 311, 88, 1 ) \
HANDLER(NvDispDPSorPower, 312, 89, 10) \
HANDLER(NvDispDPClkType, 313, 89, 12) \
HANDLER(NvDispDPEnable, 314, 89, 1 ) \
HANDLER(NvDispDPState, 315, 89, 1 ) \
HANDLER(NvDispDPEdid, 316, 89, 5 ) \
HANDLER(NvDispDPEdidSize, 317, 89, 1 ) \
HANDLER(NvDispDPEdidExtSize, 318, 89, 1 ) \
HANDLER(NvDispDPFakeMode, 319, 89, 10) \
HANDLER(NvDispDPModeNumber, 320, 89, 1 ) \
HANDLER(NvDispDPPlugInOut, 321, 89, 10) \
HANDLER(NvDispDPAuxIntHandler, 322, 89, 10) \
HANDLER(NvDispDPForceMaxLinkBW, 323, 89, 10) \
HANDLER(NvDispDPIsConnected, 324, 89, 10) \
HANDLER(NvDispDPLinkValid, 325, 90, 10) \
HANDLER(NvDispDPLinkMaxBW, 326, 90, 12) \
HANDLER(NvDispDPLinkMaxLaneCount, 327, 90, 12) \
HANDLER(NvDispDPLinkDownSpread, 328, 90, 10) \
HANDLER(NvDispDPLinkSupportEnhancedFraming, 329, 90, 10) \
HANDLER(NvDispDPLinkBpp, 330, 90, 1 ) \
HANDLER(NvDispDPLinkScaramberCap, 331, 90, 10) \
HANDLER(NvDispDPLinkBW, 332, 91, 12) \
HANDLER(NvDispDPLinkLaneCount, 333, 91, 12) \
HANDLER(NvDispDPLinkEnhancedFraming, 334, 91, 10) \
HANDLER(NvDispDPLinkScrambleEnable, 335, 91, 10) \
HANDLER(NvDispDPLinkActivePolarity, 336, 91, 1 ) \
HANDLER(NvDispDPLinkActiveCount, 337, 91, 1 ) \
HANDLER(NvDispDPLinkTUSize, 338, 91, 1 ) \
HANDLER(NvDispDPLinkActiveFrac, 339, 91, 1 ) \
HANDLER(NvDispDPLinkWatermark, 340, 91, 1 ) \
HANDLER(NvDispDPLinkHBlank, 341, 91, 1 ) \
HANDLER(NvDispDPLinkVBlank, 342, 91, 1 ) \
HANDLER(NvDispDPLinkOnlyEnhancedFraming, 343, 91, 10) \
HANDLER(NvDispDPLinkOnlyEdpCap, 344, 91, 10) \
HANDLER(NvDispDPLinkSupportFastLT, 345, 91, 10) \
HANDLER(NvDispDPLinkLTDataValid, 346, 91, 10) \
HANDLER(NvDispDPLinkTsp3Support, 347, 91, 10) \
HANDLER(NvDispDPLinkAuxInterval, 348, 91, 12) \
HANDLER(NvDispHdcpCreated, 349, 92, 10) \
HANDLER(NvDispHdcpUserRequest, 350, 92, 10) \
HANDLER(NvDispHdcpPlugged, 351, 92, 10) \
HANDLER(NvDispHdcpState, 352, 92, 1 ) \
HANDLER(NvDispHdcpFailCount, 353, 92, 3 ) \
HANDLER(NvDispHdcpHdcp22, 354, 92, 14) \
HANDLER(NvDispHdcpMaxRetry, 355, 92, 12) \
HANDLER(NvDispHdcpHpd, 356, 92, 12) \
HANDLER(NvDispHdcpRepeater, 357, 92, 12) \
HANDLER(NvDispCecRxBuf, 358, 93, 5 ) \
HANDLER(NvDispCecRxLength, 359, 93, 3 ) \
HANDLER(NvDispCecTxBuf, 360, 93, 5 ) \
HANDLER(NvDispCecTxLength, 361, 93, 3 ) \
HANDLER(NvDispCecTxRet, 362, 93, 3 ) \
HANDLER(NvDispCecState, 363, 93, 1 ) \
HANDLER(NvDispCecTxInfo, 364, 93, 12) \
HANDLER(NvDispCecRxInfo, 365, 93, 12) \
HANDLER(NvDispDCIndex, 366, 94, 1 ) \
HANDLER(NvDispDCInitialize, 367, 94, 10) \
HANDLER(NvDispDCClock, 368, 94, 10) \
HANDLER(NvDispDCFrequency, 369, 94, 1 ) \
HANDLER(NvDispDCFailed, 370, 94, 10) \
HANDLER(NvDispDCModeWidth, 371, 94, 3 ) \
HANDLER(NvDispDCModeHeight, 372, 94, 3 ) \
HANDLER(NvDispDCModeBpp, 373, 94, 1 ) \
HANDLER(NvDispDCPanelFrequency, 374, 94, 1 ) \
HANDLER(NvDispDCWinDirty, 375, 94, 1 ) \
HANDLER(NvDispDCWinEnable, 376, 94, 1 ) \
HANDLER(NvDispDCVrr, 377, 94, 10) \
HANDLER(NvDispDCPanelInitialize, 378, 94, 10) \
HANDLER(NvDispDsiDataFormat, 379, 95, 1 ) \
HANDLER(NvDispDsiVideoMode, 380, 95, 1 ) \
HANDLER(NvDispDsiRefreshRate, 381, 95, 1 ) \
HANDLER(NvDispDsiLpCmdModeFrequency, 382, 95, 1 ) \
HANDLER(NvDispDsiHsCmdModeFrequency, 383, 95, 1 ) \
HANDLER(NvDispDsiPanelResetTimeout, 384, 95, 1 ) \
HANDLER(NvDispDsiPhyFrequency, 385, 95, 1 ) \
HANDLER(NvDispDsiFrequency, 386, 95, 1 ) \
HANDLER(NvDispDsiInstance, 387, 95, 1 ) \
HANDLER(NvDispDcDsiHostCtrlEnable, 388, 95, 10) \
HANDLER(NvDispDcDsiInit, 389, 95, 10) \
HANDLER(NvDispDcDsiEnable, 390, 95, 10) \
HANDLER(NvDispDcDsiHsMode, 391, 95, 10) \
HANDLER(NvDispDcDsiVendorId, 392, 95, 5 ) \
HANDLER(NvDispDcDsiLcdVendorNum, 393, 95, 12) \
HANDLER(NvDispDcDsiHsClockControl, 394, 95, 1 ) \
HANDLER(NvDispDcDsiEnableHsClockInLpMode, 395, 95, 10) \
HANDLER(NvDispDcDsiTeFrameUpdate, 396, 95, 10) \
HANDLER(NvDispDcDsiGangedType, 397, 95, 1 ) \
HANDLER(NvDispDcDsiHbpInPktSeq, 398, 95, 10) \
HANDLER(NvDispErrID, 399, 96, 1 ) \
HANDLER(NvDispErrData0, 400, 96, 1 ) \
HANDLER(NvDispErrData1, 401, 96, 1 ) \
HANDLER(SdCardMountStatus, 402, 97, 4 ) \
HANDLER(SdCardMountUnexpectedResult, 403, 97, 4 ) \
HANDLER(NANDTotalSize, 404, 24, 0 ) \
HANDLER(SdCardTotalSize, 405, 25, 0 ) \
HANDLER(ElapsedTimeSinceInitialLaunch, 406, 59, 2 ) \
HANDLER(ElapsedTimeSincePowerOn, 407, 59, 2 ) \
HANDLER(ElapsedTimeSinceLastAwake, 408, 59, 2 ) \
HANDLER(OccurrenceTick, 409, 59, 2 ) \
HANDLER(RetailInteractiveDisplayFlag, 410, 98, 10) \
HANDLER(FatFsError, 411, 81, 3 ) \
HANDLER(FatFsExtraError, 412, 81, 3 ) \
HANDLER(FatFsErrorDrive, 413, 81, 3 ) \
HANDLER(FatFsErrorName, 414, 81, 4 ) \
HANDLER(MonitorManufactureCode, 415, 103, 4 ) \
HANDLER(MonitorProductCode, 416, 103, 11) \
HANDLER(MonitorSerialNumber, 417, 103, 1 ) \
HANDLER(MonitorManufactureYear, 418, 103, 3 ) \
HANDLER(PhysicalAddress, 419, 103, 11) \
HANDLER(Is4k60Hz, 420, 103, 10) \
HANDLER(Is4k30Hz, 421, 103, 10) \
HANDLER(Is1080P60Hz, 422, 103, 10) \
HANDLER(Is720P60Hz, 423, 103, 10) \
HANDLER(PcmChannelMax, 424, 103, 3 ) \
HANDLER(CrashReportHash, 425, 1, 5 ) \
HANDLER(ErrorReportSharePermission, 426, 104, 12) \
HANDLER(VideoCodecTypeEnum, 427, 105, 3 ) \
HANDLER(VideoBitRate, 428, 105, 3 ) \
HANDLER(VideoFrameRate, 429, 105, 3 ) \
HANDLER(VideoWidth, 430, 105, 3 ) \
HANDLER(VideoHeight, 431, 105, 3 ) \
HANDLER(AudioCodecTypeEnum, 432, 105, 3 ) \
HANDLER(AudioSampleRate, 433, 105, 3 ) \
HANDLER(AudioChannelCount, 434, 105, 3 ) \
HANDLER(AudioBitRate, 435, 105, 3 ) \
HANDLER(MultimediaContainerType, 436, 105, 3 ) \
HANDLER(MultimediaProfileType, 437, 105, 3 ) \
HANDLER(MultimediaLevelType, 438, 105, 3 ) \
HANDLER(MultimediaCacheSizeEnum, 439, 105, 3 ) \
HANDLER(MultimediaErrorStatusEnum, 440, 105, 3 ) \
HANDLER(MultimediaErrorLog, 441, 105, 5 ) \
HANDLER(ServerFqdn, 442, 1, 4 ) \
HANDLER(ServerIpAddress, 443, 1, 4 ) \
HANDLER(TestStringEncrypt, 444, 0, 4 ) \
HANDLER(TestU8ArrayEncrypt, 445, 0, 5 ) \
HANDLER(TestU32ArrayEncrypt, 446, 0, 6 ) \
HANDLER(TestU64ArrayEncrypt, 447, 0, 7 ) \
HANDLER(TestI32ArrayEncrypt, 448, 0, 8 ) \
HANDLER(TestI64ArrayEncrypt, 449, 0, 9 ) \
HANDLER(CipherKey, 450, 59, 5 ) \
HANDLER(FileSystemPath, 451, 1, 4 ) \
HANDLER(WebMediaPlayerOpenUrl, 452, 1, 4 ) \
HANDLER(WebMediaPlayerLastSocketErrors, 453, 1, 8 ) \
HANDLER(UnknownControllerCount, 454, 106, 12) \
HANDLER(AttachedControllerCount, 455, 106, 12) \
HANDLER(BluetoothControllerCount, 456, 106, 12) \
HANDLER(UsbControllerCount, 457, 106, 12) \
HANDLER(ControllerTypeList, 458, 106, 5 ) \
HANDLER(ControllerInterfaceList, 459, 106, 5 ) \
HANDLER(ControllerStyleList, 460, 106, 5 ) \
HANDLER(FsPooledBufferPeakFreeSize, 461, 107, 0 ) \
HANDLER(FsPooledBufferRetriedCount, 462, 107, 0 ) \
HANDLER(FsPooledBufferReduceAllocationCount, 463, 107, 0 ) \
HANDLER(FsBufferManagerPeakFreeSize, 464, 107, 0 ) \
HANDLER(FsBufferManagerRetriedCount, 465, 107, 0 ) \
HANDLER(FsExpHeapPeakFreeSize, 466, 107, 0 ) \
HANDLER(FsBufferPoolPeakFreeSize, 467, 107, 0 ) \
HANDLER(FsPatrolReadAllocateBufferSuccessCount, 468, 107, 0 ) \
HANDLER(FsPatrolReadAllocateBufferFailureCount, 469, 107, 0 ) \
HANDLER(SteadyClockInternalOffset, 470, 59, 2 ) \
HANDLER(SteadyClockCurrentTimePointValue, 471, 59, 2 ) \
HANDLER(UserClockContextOffset, 472, 108, 2 ) \
HANDLER(UserClockContextTimeStampValue, 473, 108, 2 ) \
HANDLER(NetworkClockContextOffset, 474, 109, 2 ) \
HANDLER(NetworkClockContextTimeStampValue, 475, 109, 2 ) \
HANDLER(SystemAbortFlag, 476, 1, 10) \
HANDLER(ApplicationAbortFlag, 477, 1, 10) \
HANDLER(NifmErrorCode, 478, 2, 4 ) \
HANDLER(LcsApplicationId, 479, 1, 4 ) \
HANDLER(LcsContentMetaKeyIdList, 480, 1, 7 ) \
HANDLER(LcsContentMetaKeyVersionList, 481, 1, 6 ) \
HANDLER(LcsContentMetaKeyTypeList, 482, 1, 5 ) \
HANDLER(LcsContentMetaKeyInstallTypeList, 483, 1, 5 ) \
HANDLER(LcsSenderFlag, 484, 1, 10) \
HANDLER(LcsApplicationRequestFlag, 485, 1, 10) \
HANDLER(LcsHasExFatDriverFlag, 486, 1, 10) \
HANDLER(LcsIpAddress, 487, 1, 1 ) \
HANDLER(AcpStartupUserAccount, 488, 110, 12) \
HANDLER(AcpAocRegistrationType, 489, 112, 12) \
HANDLER(AcpAttributeFlag, 490, 110, 1 ) \
HANDLER(AcpSupportedLanguageFlag, 491, 110, 1 ) \
HANDLER(AcpParentalControlFlag, 492, 110, 1 ) \
HANDLER(AcpScreenShot, 493, 110, 12) \
HANDLER(AcpVideoCapture, 494, 110, 12) \
HANDLER(AcpDataLossConfirmation, 495, 110, 12) \
HANDLER(AcpPlayLogPolicy, 496, 111, 12) \
HANDLER(AcpPresenceGroupId, 497, 110, 0 ) \
HANDLER(AcpRatingAge, 498, 115, 15) \
HANDLER(AcpAocBaseId, 499, 112, 0 ) \
HANDLER(AcpSaveDataOwnerId, 500, 114, 0 ) \
HANDLER(AcpUserAccountSaveDataSize, 501, 114, 2 ) \
HANDLER(AcpUserAccountSaveDataJournalSize, 502, 114, 2 ) \
HANDLER(AcpDeviceSaveDataSize, 503, 114, 2 ) \
HANDLER(AcpDeviceSaveDataJournalSize, 504, 114, 2 ) \
HANDLER(AcpBcatDeliveryCacheStorageSize, 505, 113, 2 ) \
HANDLER(AcpApplicationErrorCodeCategory, 506, 110, 4 ) \
HANDLER(AcpLocalCommunicationId, 507, 110, 7 ) \
HANDLER(AcpLogoType, 508, 110, 12) \
HANDLER(AcpLogoHandling, 509, 110, 12) \
HANDLER(AcpRuntimeAocInstall, 510, 112, 12) \
HANDLER(AcpCrashReport, 511, 110, 12) \
HANDLER(AcpHdcp, 512, 110, 12) \
HANDLER(AcpSeedForPseudoDeviceId, 513, 110, 0 ) \
HANDLER(AcpBcatPassphrase, 514, 113, 4 ) \
HANDLER(AcpUserAccountSaveDataSizeMax, 515, 114, 2 ) \
HANDLER(AcpUserAccountSaveDataJournalSizeMax, 516, 114, 2 ) \
HANDLER(AcpDeviceSaveDataSizeMax, 517, 114, 2 ) \
HANDLER(AcpDeviceSaveDataJournalSizeMax, 518, 114, 2 ) \
HANDLER(AcpTemporaryStorageSize, 519, 114, 2 ) \
HANDLER(AcpCacheStorageSize, 520, 114, 2 ) \
HANDLER(AcpCacheStorageJournalSize, 521, 114, 2 ) \
HANDLER(AcpCacheStorageDataAndJournalSizeMax, 522, 114, 2 ) \
HANDLER(AcpCacheStorageIndexMax, 523, 114, 13) \
HANDLER(AcpPlayLogQueryableApplicationId, 524, 111, 7 ) \
HANDLER(AcpPlayLogQueryCapability, 525, 111, 12) \
HANDLER(AcpRepairFlag, 526, 110, 12) \
HANDLER(RunningApplicationPatchStorageLocation, 527, 69, 4 ) \
HANDLER(RunningApplicationVersionNumber, 528, 69, 1 ) \
HANDLER(FsRecoveredByInvalidateCacheCount, 529, 81, 1 ) \
HANDLER(FsSaveDataIndexCount, 530, 81, 1 ) \
HANDLER(FsBufferManagerPeakTotalAllocatableSize, 531, 107, 0 ) \
HANDLER(MonitorCurrentWidth, 532, 116, 11) \
HANDLER(MonitorCurrentHeight, 533, 116, 11) \
HANDLER(MonitorCurrentRefreshRate, 534, 116, 4 ) \
HANDLER(RebootlessSystemUpdateVersion, 535, 117, 4 ) \
HANDLER(EncryptedExceptionInfo1, 536, 1, 5 ) \
HANDLER(EncryptedExceptionInfo2, 537, 1, 5 ) \
HANDLER(EncryptedExceptionInfo3, 538, 1, 5 ) \
HANDLER(EncryptedDyingMessage, 539, 1, 5 ) \
HANDLER(DramId, 540, 85, 1 ) \
HANDLER(NifmConnectionTestRedirectUrl, 541, 118, 4 ) \
HANDLER(AcpRequiredNetworkServiceLicenseOnLaunchFlag, 542, 110, 12) \
HANDLER(PciePort0Flags, 543, 119, 1 ) \
HANDLER(PciePort0Speed, 544, 119, 12) \
HANDLER(PciePort0ResetTimeInUs, 545, 119, 1 ) \
HANDLER(PciePort0IrqCount, 546, 119, 1 ) \
HANDLER(PciePort0Statistics, 547, 119, 6 ) \
HANDLER(PciePort1Flags, 548, 119, 1 ) \
HANDLER(PciePort1Speed, 549, 119, 12) \
HANDLER(PciePort1ResetTimeInUs, 550, 119, 1 ) \
HANDLER(PciePort1IrqCount, 551, 119, 1 ) \
HANDLER(PciePort1Statistics, 552, 119, 6 ) \
HANDLER(PcieFunction0VendorId, 553, 119, 11) \
HANDLER(PcieFunction0DeviceId, 554, 119, 11) \
HANDLER(PcieFunction0PmState, 555, 119, 12) \
HANDLER(PcieFunction0IsAcquired, 556, 119, 10) \
HANDLER(PcieFunction1VendorId, 557, 119, 11) \
HANDLER(PcieFunction1DeviceId, 558, 119, 11) \
HANDLER(PcieFunction1PmState, 559, 119, 12) \
HANDLER(PcieFunction1IsAcquired, 560, 119, 10) \
HANDLER(PcieGlobalRootComplexStatistics, 561, 119, 6 ) \
HANDLER(PciePllResistorCalibrationValue, 562, 119, 12) \
HANDLER(CertificateRequestedHostName, 563, 120, 4 ) \
HANDLER(CertificateCommonName, 564, 120, 4 ) \
HANDLER(CertificateSANCount, 565, 120, 1 ) \
HANDLER(CertificateSANs, 566, 120, 4 ) \
HANDLER(FsBufferPoolMaxAllocateSize, 567, 107, 0 ) \
HANDLER(CertificateIssuerName, 568, 120, 4 ) \
HANDLER(ApplicationAliveTime, 569, 59, 2 ) \
HANDLER(ApplicationInFocusTime, 570, 59, 2 ) \
HANDLER(ApplicationOutOfFocusTime, 571, 59, 2 ) \
HANDLER(ApplicationBackgroundFocusTime, 572, 59, 2 ) \
HANDLER(AcpUserAccountSwitchLock, 573, 110, 12) \
HANDLER(USB3HostAvailableFlag, 574, 51, 10) \
HANDLER(USB3DeviceAvailableFlag, 575, 51, 10) \
HANDLER(AcpNeighborDetectionClientConfigurationSendDataId, 576, 121, 0 ) \
HANDLER(AcpNeighborDetectionClientConfigurationReceivableDataIds, 577, 121, 7 ) \
HANDLER(AcpStartupUserAccountOptionFlag, 578, 110, 12) \
HANDLER(ServerErrorCode, 579, 1, 4 ) \
HANDLER(AppletManagerMetaLogTrace, 580, 1, 7 ) \
HANDLER(ServerCertificateSerialNumber, 581, 120, 4 ) \
HANDLER(ServerCertificatePublicKeyAlgorithm, 582, 120, 4 ) \
HANDLER(ServerCertificateSignatureAlgorithm, 583, 120, 4 ) \
HANDLER(ServerCertificateNotBefore, 584, 120, 0 ) \
HANDLER(ServerCertificateNotAfter, 585, 120, 0 ) \
HANDLER(CertificateAlgorithmInfoBits, 586, 120, 0 ) \
HANDLER(TlsConnectionPeerIpAddress, 587, 120, 4 ) \
HANDLER(TlsConnectionLastHandshakeState, 588, 120, 1 ) \
HANDLER(TlsConnectionInfoBits, 589, 120, 0 ) \
HANDLER(SslStateBits, 590, 120, 0 ) \
HANDLER(SslProcessInfoBits, 591, 120, 0 ) \
HANDLER(SslProcessHeapSize, 592, 120, 1 ) \
HANDLER(SslBaseErrorCode, 593, 120, 3 ) \
HANDLER(GpuCrashDumpSize, 594, 122, 1 ) \
HANDLER(GpuCrashDump, 595, 122, 5 ) \
HANDLER(RunningApplicationProgramIndex, 596, 69, 12) \
HANDLER(UsbTopology, 597, 123, 5 ) \
HANDLER(AkamaiReferenceId, 598, 1, 4 ) \
HANDLER(NvHostErrID, 599, 124, 1 ) \
HANDLER(NvHostErrDataArrayU32, 600, 124, 6 ) \
HANDLER(HasSyslogFlag, 601, 1, 10) \
HANDLER(AcpRuntimeParameterDelivery, 602, 110, 12) \
HANDLER(PlatformRegion, 603, 54, 4 ) \
HANDLER(RunningUlaApplicationId, 604, 125, 4 ) \
HANDLER(RunningUlaAppletId, 605, 125, 12) \
HANDLER(RunningUlaVersion, 606, 125, 1 ) \
HANDLER(RunningUlaApplicationStorageLocation, 607, 125, 4 ) \
HANDLER(RunningUlaPatchStorageLocation, 608, 125, 4 ) \
HANDLER(NANDTotalSizeOfSystem, 609, 24, 0 ) \
HANDLER(NANDFreeSpaceOfSystem, 610, 24, 0 ) \

404
utilities/erpt.py Normal file
View file

@ -0,0 +1,404 @@
#
# Copyright (c) 2018-2020 Atmosphère-NX
#
# This program is free software; you can redistribute it and/or modify it
# under the terms and conditions of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# erpt.py: Autogeneration tool for <stratosphere/erpt/erpt_ids.autogen.hpp>
import nxo64
import sys, os, string
from struct import unpack as up, pack as pk
LOAD_BASE = 0x7100000000
HEADER = '''/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
/* NOTE: This file is auto-generated. */
/* Do not make edits to this file by hand. */
'''
if sys.version_info[0] == 3:
iter_range = range
int_types = (int,)
ascii_string = lambda b: b.decode('ascii')
bytes_to_list = lambda b: list(b)
list_to_bytes = lambda l: bytes(l)
else:
iter_range = xrange
int_types = (int, long)
ascii_string = lambda b: str(b)
bytes_to_list = lambda b: map(ord, b)
list_to_bytes = lambda l: ''.join(map(chr, l))
(DT_NULL, DT_NEEDED, DT_PLTRELSZ, DT_PLTGOT, DT_HASH, DT_STRTAB, DT_SYMTAB, DT_RELA, DT_RELASZ,
DT_RELAENT, DT_STRSZ, DT_SYMENT, DT_INIT, DT_FINI, DT_SONAME, DT_RPATH, DT_SYMBOLIC, DT_REL,
DT_RELSZ, DT_RELENT, DT_PLTREL, DT_DEBUG, DT_TEXTREL, DT_JMPREL, DT_BIND_NOW, DT_INIT_ARRAY,
DT_FINI_ARRAY, DT_INIT_ARRAYSZ, DT_FINI_ARRAYSZ, DT_RUNPATH, DT_FLAGS) = iter_range(31)
DT_GNU_HASH = 0x6ffffef5
DT_VERSYM = 0x6ffffff0
DT_RELACOUNT = 0x6ffffff9
DT_RELCOUNT = 0x6ffffffa
DT_FLAGS_1 = 0x6ffffffb
DT_VERDEF = 0x6ffffffc
DT_VERDEFNUM = 0x6ffffffd
STT_NOTYPE = 0
STT_OBJECT = 1
STT_FUNC = 2
STT_SECTION = 3
STB_LOCAL = 0
STB_GLOBAL = 1
STB_WEAK = 2
R_ARM_ABS32 = 2
R_ARM_TLS_DESC = 13
R_ARM_GLOB_DAT = 21
R_ARM_JUMP_SLOT = 22
R_ARM_RELATIVE = 23
R_AARCH64_ABS64 = 257
R_AARCH64_GLOB_DAT = 1025
R_AARCH64_JUMP_SLOT = 1026
R_AARCH64_RELATIVE = 1027
R_AARCH64_TLSDESC = 1031
CATEGORIES = {
0 : 'Test',
1 : 'ErrorInfo',
2 : 'ConnectionStatusInfo',
3 : 'NetworkInfo',
4 : 'NXMacAddressInfo',
5 : 'StealthNetworkInfo',
6 : 'LimitHighCapacityInfo',
7 : 'NATTypeInfo',
8 : 'WirelessAPMacAddressInfo',
9 : 'GlobalIPAddressInfo',
10 : 'EnableWirelessInterfaceInfo',
11 : 'EnableWifiInfo',
12 : 'EnableBluetoothInfo',
13 : 'EnableNFCInfo',
14 : 'NintendoZoneSSIDListVersionInfo',
15 : 'LANAdapterMacAddressInfo',
16 : 'ApplicationInfo',
17 : 'OccurrenceInfo',
18 : 'ProductModelInfo',
19 : 'CurrentLanguageInfo',
20 : 'UseNetworkTimeProtocolInfo',
21 : 'TimeZoneInfo',
22 : 'ControllerFirmwareInfo',
23 : 'VideoOutputInfo',
24 : 'NANDFreeSpaceInfo',
25 : 'SDCardFreeSpaceInfo',
26 : 'ScreenBrightnessInfo',
27 : 'AudioFormatInfo',
28 : 'MuteOnHeadsetUnpluggedInfo',
29 : 'NumUserRegisteredInfo',
30 : 'DataDeletionInfo',
31 : 'ControllerVibrationInfo',
32 : 'LockScreenInfo',
33 : 'InternalBatteryLotNumberInfo',
34 : 'LeftControllerSerialNumberInfo',
35 : 'RightControllerSerialNumberInfo',
36 : 'NotificationInfo',
37 : 'TVInfo',
38 : 'SleepInfo',
39 : 'ConnectionInfo',
40 : 'NetworkErrorInfo',
41 : 'FileAccessPathInfo',
42 : 'GameCardCIDInfo',
43 : 'NANDCIDInfo',
44 : 'MicroSDCIDInfo',
45 : 'NANDSpeedModeInfo',
46 : 'MicroSDSpeedModeInfo',
47 : 'GameCardSpeedModeInfo',
48 : 'UserAccountInternalIDInfo',
49 : 'NetworkServiceAccountInternalIDInfo',
50 : 'NintendoAccountInternalIDInfo',
51 : 'USB3AvailableInfo',
52 : 'CallStackInfo',
53 : 'SystemStartupLogInfo',
54 : 'RegionSettingInfo',
55 : 'NintendoZoneConnectedInfo',
56 : 'ForceSleepInfo',
57 : 'ChargerInfo',
58 : 'RadioStrengthInfo',
59 : 'ErrorInfoAuto',
60 : 'AccessPointInfo',
61 : 'ErrorInfoDefaults',
62 : 'SystemPowerStateInfo',
63 : 'PerformanceInfo',
64 : 'ThrottlingInfo',
65 : 'GameCardErrorInfo',
66 : 'EdidInfo',
67 : 'ThermalInfo',
68 : 'CradleFirmwareInfo',
69 : 'RunningApplicationInfo',
70 : 'RunningAppletInfo',
71 : 'FocusedAppletHistoryInfo',
72 : 'CompositorInfo',
73 : 'BatteryChargeInfo',
74 : 'NANDExtendedCsd',
75 : 'NANDPatrolInfo',
76 : 'NANDErrorInfo',
77 : 'NANDDriverLog',
78 : 'SdCardSizeSpec',
79 : 'SdCardErrorInfo',
80 : 'SdCardDriverLog ',
81 : 'FsProxyErrorInfo',
82 : 'SystemAppletSceneInfo',
83 : 'VideoInfo',
84 : 'GpuErrorInfo',
85 : 'PowerClockInfo',
86 : 'AdspErrorInfo',
87 : 'NvDispDeviceInfo',
88 : 'NvDispDcWindowInfo',
89 : 'NvDispDpModeInfo',
90 : 'NvDispDpLinkSpec',
91 : 'NvDispDpLinkStatus',
92 : 'NvDispDpHdcpInfo',
93 : 'NvDispDpAuxCecInfo',
94 : 'NvDispDcInfo',
95 : 'NvDispDsiInfo',
96 : 'NvDispErrIDInfo',
97 : 'SdCardMountInfo',
98 : 'RetailInteractiveDisplayInfo',
99 : 'CompositorStateInfo',
100 : 'CompositorLayerInfo',
101 : 'CompositorDisplayInfo',
102 : 'CompositorHWCInfo',
103 : 'MonitorCapability',
104 : 'ErrorReportSharePermissionInfo',
105 : 'MultimediaInfo',
106 : 'ConnectedControllerInfo',
107 : 'FsMemoryInfo',
108 : 'UserClockContextInfo',
109 : 'NetworkClockContextInfo',
110 : 'AcpGeneralSettingsInfo',
111 : 'AcpPlayLogSettingsInfo',
112 : 'AcpAocSettingsInfo',
113 : 'AcpBcatSettingsInfo',
114 : 'AcpStorageSettingsInfo',
115 : 'AcpRatingSettingsInfo',
116 : 'MonitorSettings',
117 : 'RebootlessSystemUpdateVersionInfo',
118 : 'NifmConnectionTestInfo',
119 : 'PcieLoggedStateInfo',
120 : 'NetworkSecurityCertificateInfo',
121 : 'AcpNeighborDetectionInfo',
122 : 'GpuCrashInfo',
123 : 'UsbStateInfo',
124 : 'NvHostErrInfo',
125 : 'RunningUlaInfo',
}
FIELD_TYPES = {
0 : 'FieldType_NumericU64',
1 : 'FieldType_NumericU32',
2 : 'FieldType_NumericI64',
3 : 'FieldType_NumericI32',
4 : 'FieldType_String',
5 : 'FieldType_U8Array',
6 : 'FieldType_U32Array',
7 : 'FieldType_U64Array',
8 : 'FieldType_I32Array',
9 : 'FieldType_I64Array',
10 : 'FieldType_Bool',
11 : 'FieldType_NumericU16',
12 : 'FieldType_NumericU8',
13 : 'FieldType_NumericI16',
14 : 'FieldType_NumericI8',
15 : 'FieldType_I8Array',
}
def get_full(nxo):
full = nxo.text[0]
if nxo.ro[2] >= len(full):
full += b'\x00' * (nxo.ro[2] - len(full))
else:
full = full[:nxo.ro[2]]
full += nxo.ro[0]
if nxo.data[2] > len(full):
full += b'\x00' * (nxo.data[2] - len(full))
full += nxo.data[0]
undef_count = 0
for s in nxo.symbols:
if not s.shndx and s.name:
undef_count += 1
last_ea = max(LOAD_BASE + end for start, end, name, kind in nxo.sections)
undef_entry_size = 8
undef_ea = ((last_ea + 0xFFF) & ~0xFFF) + undef_entry_size # plus 8 so we don't end up on the "end" symbol
for i,s in enumerate(nxo.symbols):
if not s.shndx and s.name:
#idaapi.create_data(undef_ea, idc.FF_QWORD, 8, idaapi.BADADDR)
#idaapi.force_name(undef_ea, s.name)
s.resolved = undef_ea
undef_ea += undef_entry_size
elif i != 0:
assert s.shndx
s.resolved = LOAD_BASE + s.value
if s.name:
if s.type == STT_FUNC:
print(hex(s.resolved), s.name)
idaapi.add_entry(s.resolved, s.resolved, s.name, 0)
else:
idaapi.force_name(s.resolved, s.name)
else:
# NULL symbol
s.resolved = 0
def put_dword(z, target, val):
return z[:target] + pk('<I', val) + z[target+4:]
def put_qword(z, target, val):
return z[:target] + pk('<Q', val) + z[target+8:]
def get_dword(z, target):
return up('<I', z[target:target+4])[0]
for offset, r_type, sym, addend in nxo.relocations:
#print offset, r_type, sym, addend
target = offset + LOAD_BASE
if r_type in (R_ARM_GLOB_DAT, R_ARM_JUMP_SLOT, R_ARM_ABS32):
if not sym:
print('error: relocation at %X failed' % target)
else:
full = put_dword(full, target, sym.resolved)
elif r_type == R_ARM_RELATIVE:
full = put_dword(full, target, get_dword(full, target) + LOAD_BASE)
elif r_type in (R_AARCH64_GLOB_DAT, R_AARCH64_JUMP_SLOT, R_AARCH64_ABS64):
full = put_qword(full, target, sym.resolved + addend)
elif r_type == R_AARCH64_RELATIVE:
full = put_qword(full, target, LOAD_BASE + addend)
else:
print('TODO r_type %d' % (r_type,))
return full
def locate_fields(full):
start = ['TestU64', 'TestU32', 'TestI64', 'TestI32']
inds = [LOAD_BASE + full.index('%s\x00' % s) for s in start]
target = pk('<QQQQ', inds[0], inds[1], inds[2], inds[3])
return full.index(target)
def read_string(full, ofs):
s = ''
if ofs >= len(full):
return ''
while full[ofs] != '\x00':
s += full[ofs]
ofs += 1
if ofs >= len(full):
return ''
return s
def is_valid_field_name(s):
ALLOWED = string.lowercase + string.uppercase + string.digits + '_'
if not s:
return False
for c in s:
if not c in ALLOWED:
return False
return True
def parse_fields(full, table):
fields = []
ofs = 0
while True:
val = up('<Q', full[table + ofs:table + ofs + 8])[0]
if (val & 0xFFFFFFFF00000000) != LOAD_BASE:
break
s = read_string(full, val - LOAD_BASE)
if not is_valid_field_name(s):
break
fields.append(s)
ofs += 8
return fields
def find_categories(full, num_fields):
KNOWN = [0] * 10 + [1] * 2 + [0x3B] * 2
ind = full.index(''.join(pk('<I', i) for i in KNOWN))
return list(up('<'+'I'*num_fields, full[ind:ind+4*num_fields]))
def find_types(full, num_fields):
KNOWN = range(10) + [4, 4, 2, 4]
ind = full.index(''.join(pk('<I', i) for i in KNOWN))
return list(up('<'+'I'*num_fields, full[ind:ind+4*num_fields]))
def cat_to_string(c):
return CATEGORIES[c] if c in CATEGORIES else 'Category_Unknown%d' % c
def typ_to_string(t):
return FIELD_TYPES[t] if t in FIELD_TYPES else 'FieldType_Unknown%d' % t
def main(argc, argv):
if argc != 2:
print 'Usage: %s erpt_nso' % argv[0]
return 1
f = open(argv[1], 'rb')
nxo = nxo64.load_nxo(f)
full = get_full(nxo)
field_table = locate_fields(full)
fields = parse_fields(full, field_table)
NUM_FIELDS = len(fields)
cats = find_categories(full, NUM_FIELDS)
types = find_types(full, NUM_FIELDS)
print 'Identified %d fields.' % NUM_FIELDS
mf = max(len(s) for s in fields)
mc = max(len(cat_to_string(c)) for c in cats)
mt = max(len(typ_to_string(t)) for t in types)
format_string = '- %%-%ds %%-%ds %%-%ds' % (mf+1, mc+1, mt)
for i in xrange(NUM_FIELDS):
f, c, t = fields[i], cat_to_string(cats[i]), typ_to_string(types[i])
print format_string % (f+',', c+',', t)
with open(argv[1]+'.hpp', 'w') as out:
out.write(HEADER)
out.write('#define AMS_ERPT_FOREACH_FIELD_TYPE(HANDLER) \\\n')
for tp in sorted(list(set(types))):
out.write((' HANDLER(%%-%ds %%-2d) \\\n' % (mt+1)) % (typ_to_string(tp)+',', tp))
out.write('\n')
out.write('#define AMS_ERPT_FOREACH_CATEGORY(HANDLER) \\\n')
for ct in sorted(list(set(cats))):
out.write((' HANDLER(%%-%ds %%-3d) \\\n' % (mc+1)) % (cat_to_string(ct)+',', ct))
out.write('\n')
out.write('#define AMS_ERPT_FOREACH_FIELD(HANDLER) \\\n')
for i in xrange(NUM_FIELDS):
f, c, t = fields[i], cats[i], types[i]
out.write((' HANDLER(%%-%ds %%-4s %%-4s %%-2s) \\\n' % (mf+1)) % (f+',', '%d,'%i, '%d,'%c, '%d'%t))
out.write('\n')
return 0
if __name__ == '__main__':
try:
ret = main(len(sys.argv), sys.argv)
except:
ret = 1
print 'exception'
sys.exit(ret)

717
utilities/nxo64.py Normal file
View file

@ -0,0 +1,717 @@
# Copyright 2017 Reswitched Team
#
# Permission to use, copy, modify, and/or distribute this software for any purpose with or
# without fee is hereby granted, provided that the above copyright notice and this permission
# notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
# SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
# OR PERFORMANCE OF THIS SOFTWARE.
# nxo64.py: IDA loader (and library for reading nso/nro files)
from __future__ import print_function
import gzip, math, os, re, struct, sys
from struct import unpack as up, pack as pk
from io import BytesIO
import lz4.block
uncompress = lz4.block.decompress
if sys.version_info[0] == 3:
iter_range = range
int_types = (int,)
ascii_string = lambda b: b.decode('ascii')
bytes_to_list = lambda b: list(b)
list_to_bytes = lambda l: bytes(l)
else:
iter_range = xrange
int_types = (int, long)
ascii_string = lambda b: str(b)
bytes_to_list = lambda b: map(ord, b)
list_to_bytes = lambda l: ''.join(map(chr, l))
def kip1_blz_decompress(compressed):
compressed_size, init_index, uncompressed_addl_size = struct.unpack('<III', compressed[-0xC:])
decompressed = compressed[:] + b'\x00' * uncompressed_addl_size
decompressed_size = len(decompressed)
if len(compressed) != compressed_size:
assert len(compressed) > compressed_size
compressed = compressed[len(compressed) - compressed_size:]
if not (compressed_size + uncompressed_addl_size):
return b''
compressed = bytes_to_list(compressed)
decompressed = bytes_to_list(decompressed)
index = compressed_size - init_index
outindex = decompressed_size
while outindex > 0:
index -= 1
control = compressed[index]
for i in iter_range(8):
if control & 0x80:
if index < 2:
raise ValueError('Compression out of bounds!')
index -= 2
segmentoffset = compressed[index] | (compressed[index+1] << 8)
segmentsize = ((segmentoffset >> 12) & 0xF) + 3
segmentoffset &= 0x0FFF
segmentoffset += 2
if outindex < segmentsize:
raise ValueError('Compression out of bounds!')
for j in iter_range(segmentsize):
if outindex + segmentoffset >= decompressed_size:
raise ValueError('Compression out of bounds!')
data = decompressed[outindex+segmentoffset]
outindex -= 1
decompressed[outindex] = data
else:
if outindex < 1:
raise ValueError('Compression out of bounds!')
outindex -= 1
index -= 1
decompressed[outindex] = compressed[index]
control <<= 1
control &= 0xFF
if not outindex:
break
return list_to_bytes(decompressed)
class BinFile(object):
def __init__(self, li):
self._f = li
def read(self, arg):
if isinstance(arg, str):
fmt = '<' + arg
size = struct.calcsize(fmt)
raw = self._f.read(size)
out = struct.unpack(fmt, raw)
if len(out) == 1:
return out[0]
return out
elif arg is None:
return self._f.read()
else:
out = self._f.read(arg)
return out
def read_from(self, arg, offset):
old = self.tell()
try:
self.seek(offset)
out = self.read(arg)
finally:
self.seek(old)
return out
def seek(self, off):
self._f.seek(off)
def close(self):
self._f.close()
def tell(self):
return self._f.tell()
(DT_NULL, DT_NEEDED, DT_PLTRELSZ, DT_PLTGOT, DT_HASH, DT_STRTAB, DT_SYMTAB, DT_RELA, DT_RELASZ,
DT_RELAENT, DT_STRSZ, DT_SYMENT, DT_INIT, DT_FINI, DT_SONAME, DT_RPATH, DT_SYMBOLIC, DT_REL,
DT_RELSZ, DT_RELENT, DT_PLTREL, DT_DEBUG, DT_TEXTREL, DT_JMPREL, DT_BIND_NOW, DT_INIT_ARRAY,
DT_FINI_ARRAY, DT_INIT_ARRAYSZ, DT_FINI_ARRAYSZ, DT_RUNPATH, DT_FLAGS) = iter_range(31)
DT_GNU_HASH = 0x6ffffef5
DT_VERSYM = 0x6ffffff0
DT_RELACOUNT = 0x6ffffff9
DT_RELCOUNT = 0x6ffffffa
DT_FLAGS_1 = 0x6ffffffb
DT_VERDEF = 0x6ffffffc
DT_VERDEFNUM = 0x6ffffffd
STT_NOTYPE = 0
STT_OBJECT = 1
STT_FUNC = 2
STT_SECTION = 3
STB_LOCAL = 0
STB_GLOBAL = 1
STB_WEAK = 2
R_ARM_ABS32 = 2
R_ARM_TLS_DESC = 13
R_ARM_GLOB_DAT = 21
R_ARM_JUMP_SLOT = 22
R_ARM_RELATIVE = 23
R_AARCH64_ABS64 = 257
R_AARCH64_GLOB_DAT = 1025
R_AARCH64_JUMP_SLOT = 1026
R_AARCH64_RELATIVE = 1027
R_AARCH64_TLSDESC = 1031
MULTIPLE_DTS = set([DT_NEEDED])
class Range(object):
def __init__(self, start, size):
self.start = start
self.size = size
self.end = start+size
self._inclend = start+size-1
def overlaps(self, other):
return self.start <= other._inclend and other.start <= self._inclend
def includes(self, other):
return other.start >= self.start and other._inclend <= self._inclend
def __repr__(self):
return 'Range(0x%X -> 0x%X)' % (self.start, self.end)
class Segment(object):
def __init__(self, r, name, kind):
self.range = r
self.name = name
self.kind = kind
self.sections = []
def add_section(self, s):
for i in self.sections:
assert not i.range.overlaps(s.range), '%r overlaps %r' % (s, i)
self.sections.append(s)
class Section(object):
def __init__(self, r, name):
self.range = r
self.name = name
def __repr__(self):
return 'Section(%r, %r)' % (self.range, self.name)
def suffixed_name(name, suffix):
if suffix == 0:
return name
return '%s.%d' % (name, suffix)
class SegmentBuilder(object):
def __init__(self):
self.segments = []
def add_segment(self, start, size, name, kind):
r = Range(start, size)
for i in self.segments:
assert not r.overlaps(i.range)
self.segments.append(Segment(r, name, kind))
def add_section(self, name, start, end=None, size=None):
assert end is None or size is None
if size == 0:
return
if size is None:
size = end-start
assert size > 0
r = Range(start, size)
for i in self.segments:
if i.range.includes(r):
i.add_section(Section(r, name))
return
assert False, "no containing segment for %r" % (name,)
def flatten(self):
self.segments.sort(key=lambda s: s.range.start)
parts = []
for segment in self.segments:
suffix = 0
segment.sections.sort(key=lambda s: s.range.start)
pos = segment.range.start
for section in segment.sections:
if pos < section.range.start:
parts.append((pos, section.range.start, suffixed_name(segment.name, suffix), segment.kind))
suffix += 1
pos = section.range.start
parts.append((section.range.start, section.range.end, section.name, segment.kind))
pos = section.range.end
if pos < segment.range.end:
parts.append((pos, segment.range.end, suffixed_name(segment.name, suffix), segment.kind))
suffix += 1
pos = segment.range.end
return parts
class ElfSym(object):
def __init__(self, name, info, other, shndx, value, size):
self.name = name
self.shndx = shndx
self.value = value
self.size = size
self.vis = other & 3
self.type = info & 0xF
self.bind = info >> 4
def __repr__(self):
return 'Sym(name=%r, shndx=0x%X, value=0x%X, size=0x%X, vis=%r, type=%r, bind=%r)' % (
self.name, self.shndx, self.value, self.size, self.vis, self.type, self.bind)
class NxoFileBase(object):
# segment = (content, file offset, vaddr, vsize)
def __init__(self, text, ro, data, bsssize):
self.text = text
self.ro = ro
self.data = data
self.bsssize = bsssize
self.textoff = text[2]
self.textsize = text[3]
self.rodataoff = ro[2]
self.rodatasize = ro[3]
self.dataoff = data[2]
flatsize = data[2] + data[3]
full = text[0]
if ro[2] >= len(full):
full += b'\x00' * (ro[2] - len(full))
else:
print('truncating .text?')
full = full[:ro[2]]
full += ro[0]
if data[2] > len(full):
full += b'\x00' * (data[2] - len(full))
else:
print('truncating .rodata?')
full += data[0]
f = BinFile(BytesIO(full))
self.binfile = f
# read MOD
self.modoff = f.read_from('I', 4)
f.seek(self.modoff)
if f.read('4s') != b'MOD0':
raise NxoException('invalid MOD0 magic')
self.dynamicoff = self.modoff + f.read('i')
self.bssoff = self.modoff + f.read('i')
self.bssend = self.modoff + f.read('i')
self.unwindoff = self.modoff + f.read('i')
self.unwindend = self.modoff + f.read('i')
self.moduleoff = self.modoff + f.read('i')
self.datasize = self.bssoff - self.dataoff
self.bsssize = self.bssend - self.bssoff
self.isLibnx = False
if f.read('4s') == 'LNY0':
self.isLibnx = True
self.libnx_got_start = self.modoff + f.read('i')
self.libnx_got_end = self.modoff + f.read('i')
self.segment_builder = builder = SegmentBuilder()
for off,sz,name,kind in [
(self.textoff, self.textsize, ".text", "CODE"),
(self.rodataoff, self.rodatasize, ".rodata", "CONST"),
(self.dataoff, self.datasize, ".data", "DATA"),
(self.bssoff, self.bsssize, ".bss", "BSS"),
]:
builder.add_segment(off, sz, name, kind)
# read dynamic
self.armv7 = (f.read_from('Q', self.dynamicoff) > 0xFFFFFFFF or f.read_from('Q', self.dynamicoff+0x10) > 0xFFFFFFFF)
self.offsize = 4 if self.armv7 else 8
f.seek(self.dynamicoff)
self.dynamic = dynamic = {}
for i in MULTIPLE_DTS:
dynamic[i] = []
for i in iter_range((flatsize - self.dynamicoff) // 0x10):
tag, val = f.read('II' if self.armv7 else 'QQ')
if tag == DT_NULL:
break
if tag in MULTIPLE_DTS:
dynamic[tag].append(val)
else:
dynamic[tag] = val
builder.add_section('.dynamic', self.dynamicoff, end=f.tell())
# read .dynstr
if DT_STRTAB in dynamic and DT_STRSZ in dynamic:
f.seek(dynamic[DT_STRTAB])
self.dynstr = f.read(dynamic[DT_STRSZ])
else:
self.dynstr = b'\x00'
print('warning: no dynstr')
for startkey, szkey, name in [
(DT_STRTAB, DT_STRSZ, '.dynstr'),
(DT_INIT_ARRAY, DT_INIT_ARRAYSZ, '.init_array'),
(DT_FINI_ARRAY, DT_FINI_ARRAYSZ, '.fini_array'),
(DT_RELA, DT_RELASZ, '.rela.dyn'),
(DT_REL, DT_RELSZ, '.rel.dyn'),
(DT_JMPREL, DT_PLTRELSZ, ('.rel.plt' if self.armv7 else '.rela.plt')),
]:
if startkey in dynamic and szkey in dynamic:
builder.add_section(name, dynamic[startkey], size=dynamic[szkey])
self.needed = [self.get_dynstr(i) for i in self.dynamic[DT_NEEDED]]
# load .dynsym
self.symbols = symbols = []
if DT_SYMTAB in dynamic and DT_STRTAB in dynamic:
f.seek(dynamic[DT_SYMTAB])
while True:
if dynamic[DT_SYMTAB] < dynamic[DT_STRTAB] and f.tell() >= dynamic[DT_STRTAB]:
break
if self.armv7:
st_name, st_value, st_size, st_info, st_other, st_shndx = f.read('IIIBBH')
else:
st_name, st_info, st_other, st_shndx, st_value, st_size = f.read('IBBHQQ')
if st_name > len(self.dynstr):
break
symbols.append(ElfSym(self.get_dynstr(st_name), st_info, st_other, st_shndx, st_value, st_size))
builder.add_section('.dynsym', dynamic[DT_SYMTAB], end=f.tell())
self.plt_entries = []
self.relocations = []
locations = set()
plt_got_end = None
if DT_REL in dynamic and DT_RELSZ in dynamic:
locations |= self.process_relocations(f, symbols, dynamic[DT_REL], dynamic[DT_RELSZ])
if DT_RELA in dynamic and DT_RELASZ in dynamic:
locations |= self.process_relocations(f, symbols, dynamic[DT_RELA], dynamic[DT_RELASZ])
if DT_JMPREL in dynamic and DT_PLTRELSZ in dynamic:
pltlocations = self.process_relocations(f, symbols, dynamic[DT_JMPREL], dynamic[DT_PLTRELSZ])
locations |= pltlocations
plt_got_start = min(pltlocations)
plt_got_end = max(pltlocations) + self.offsize
if DT_PLTGOT in dynamic:
builder.add_section('.got.plt', dynamic[DT_PLTGOT], end=plt_got_end)
if not self.armv7:
f.seek(0)
text = f.read(self.textsize)
last = 12
while True:
pos = text.find(struct.pack('<I', 0xD61F0220), last)
if pos == -1: break
last = pos+1
if (pos % 4) != 0: continue
off = pos - 12
a, b, c, d = struct.unpack_from('<IIII', text, off)
if d == 0xD61F0220 and (a & 0x9f00001f) == 0x90000010 and (b & 0xffe003ff) == 0xf9400211:
base = off & ~0xFFF
immhi = (a >> 5) & 0x7ffff
immlo = (a >> 29) & 3
paddr = base + ((immlo << 12) | (immhi << 14))
poff = ((b >> 10) & 0xfff) << 3
target = paddr + poff
if plt_got_start <= target < plt_got_end:
self.plt_entries.append((off, target))
builder.add_section('.plt', min(self.plt_entries)[0], end=max(self.plt_entries)[0] + 0x10)
# try to find the ".got" which should follow the ".got.plt"
if not self.isLibnx:
if plt_got_end is not None:
good = False
got_end = plt_got_end + self.offsize
while got_end in locations and (DT_INIT_ARRAY not in dynamic or got_end < dynamic[DT_INIT_ARRAY]):
good = True
got_end += self.offsize
if good:
builder.add_section('.got', plt_got_end, end=got_end)
if self.isLibnx:
builder.add_section('.got', self.libnx_got_start, end=self.libnx_got_end)
self.sections = []
for start, end, name, kind in builder.flatten():
self.sections.append((start, end, name, kind))
def process_relocations(self, f, symbols, offset, size):
locations = set()
f.seek(offset)
relocsize = 8 if self.armv7 else 0x18
for i in iter_range(size // relocsize):
# NOTE: currently assumes all armv7 relocs have no addends,
# and all 64-bit ones do.
if self.armv7:
offset, info = f.read('II')
addend = None
r_type = info & 0xff
r_sym = info >> 8
else:
offset, info, addend = f.read('QQq')
r_type = info & 0xffffffff
r_sym = info >> 32
sym = symbols[r_sym] if r_sym != 0 else None
if r_type != R_AARCH64_TLSDESC and r_type != R_ARM_TLS_DESC:
locations.add(offset)
self.relocations.append((offset, r_type, sym, addend))
return locations
def get_dynstr(self, o):
return ascii_string(self.dynstr[o:self.dynstr.index(b'\x00', o)])
class NsoFile(NxoFileBase):
def __init__(self, fileobj):
f = BinFile(fileobj)
if f.read_from('4s', 0) != b'NSO0':
raise NxoException('Invalid NSO magic')
flags = f.read_from('I', 0xC)
toff, tloc, tsize = f.read_from('III', 0x10)
roff, rloc, rsize = f.read_from('III', 0x20)
doff, dloc, dsize = f.read_from('III', 0x30)
tfilesize, rfilesize, dfilesize = f.read_from('III', 0x60)
bsssize = f.read_from('I', 0x3C)
#print('load text: ')
text = (uncompress(f.read_from(tfilesize, toff), uncompressed_size=tsize), None, tloc, tsize) if flags & 1 else (f.read_from(tfilesize, toff), toff, tloc, tsize)
ro = (uncompress(f.read_from(rfilesize, roff), uncompressed_size=rsize), None, rloc, rsize) if flags & 2 else (f.read_from(rfilesize, roff), roff, rloc, rsize)
data = (uncompress(f.read_from(dfilesize, doff), uncompressed_size=dsize), None, dloc, dsize) if flags & 4 else (f.read_from(dfilesize, doff), doff, dloc, dsize)
super(NsoFile, self).__init__(text, ro, data, bsssize)
class NroFile(NxoFileBase):
def __init__(self, fileobj):
f = BinFile(fileobj)
if f.read_from('4s', 0x10) != b'NRO0':
raise NxoException('Invalid NRO magic')
f.seek(0x20)
tloc, tsize = f.read('II')
rloc, rsize = f.read('II')
dloc, dsize = f.read('II')
bsssize = f.read_from('I', 0x28)
text = (f.read_from(tsize, tloc), tloc, tloc, tsize)
ro = (f.read_from(rsize, rloc), rloc, rloc, rsize)
data = (f.read_from(dsize, dloc), dloc, dloc, dsize)
super(NroFile, self).__init__(text, ro, data, bsssize)
class KipFile(NxoFileBase):
def __init__(self, fileobj):
f = BinFile(fileobj)
if f.read_from('4s', 0) != b'KIP1':
raise NxoException('Invalid KIP magic')
flags = f.read_from('b', 0x1F)
tloc, tsize, tfilesize = f.read_from('III', 0x20)
rloc, rsize, rfilesize = f.read_from('III', 0x30)
dloc, dsize, dfilesize = f.read_from('III', 0x40)
toff = 0x100
roff = toff + tfilesize
doff = roff + rfilesize
bsssize = f.read_from('I', 0x54)
print('bss size 0x%x' % bsssize)
print('load segments')
text = (kip1_blz_decompress(f.read_from(tfilesize, toff)), None, tloc, tsize) if flags & 1 else (f.read_from(tfilesize, toff), toff, tloc, tsize)
ro = (kip1_blz_decompress(f.read_from(rfilesize, roff)), None, rloc, rsize) if flags & 2 else (f.read_from(rfilesize, roff), roff, rloc, rsize)
data = (kip1_blz_decompress(f.read_from(dfilesize, doff)), None, dloc, dsize) if flags & 4 else (f.read_from(dfilesize, doff), doff, dloc, dsize)
super(KipFile, self).__init__(text, ro, data, bsssize)
class NxoException(Exception):
pass
def load_nxo(fileobj):
fileobj.seek(0)
header = fileobj.read(0x14)
if header[:4] == b'NSO0':
return NsoFile(fileobj)
elif header[0x10:0x14] == b'NRO0':
return NroFile(fileobj)
elif header[:4] == b'KIP1':
return KipFile(fileobj)
else:
raise NxoException("not an NRO or NSO or KIP file")
try:
import idaapi
import idc
except ImportError:
pass
else:
# IDA specific code
def accept_file(li, n):
print('accept_file')
if not isinstance(n, int_types) or n == 0:
li.seek(0)
if li.read(4) == b'NSO0':
return 'nxo.py: Switch binary (NSO)'
li.seek(0)
if li.read(4) == b'KIP1':
return 'nxo.py: Switch binary (KIP)'
li.seek(0x10)
if li.read(4) == b'NRO0':
return 'nxo.py: Switch binary (NRO)'
return 0
def ida_make_offset(f, ea):
if f.armv7:
idaapi.create_data(ea, idc.FF_DWORD, 4, idaapi.BADADDR)
else:
idaapi.create_data(ea, idc.FF_QWORD, 8, idaapi.BADADDR)
idc.op_plain_offset(ea, 0, 0)
def find_bl_targets(text_start, text_end):
targets = set()
for pc in range(text_start, text_end, 4):
d = idc.get_wide_dword(pc)
if (d & 0xfc000000) == 0x94000000:
imm = d & 0x3ffffff
if imm & 0x2000000:
imm |= ~0x1ffffff
if 0 <= imm <= 2:
continue
target = pc + imm * 4
if target >= text_start and target < text_end:
targets.add(target)
return targets
def load_file(li, neflags, format):
idaapi.set_processor_type("arm", idaapi.SETPROC_LOADER_NON_FATAL|idaapi.SETPROC_LOADER)
f = load_nxo(li)
if f.armv7:
idc.set_inf_attr(idc.INF_LFLAGS, idc.get_inf_attr(idc.INF_LFLAGS) | idc.LFLG_PC_FLAT)
else:
idc.set_inf_attr(idc.INF_LFLAGS, idc.get_inf_attr(idc.INF_LFLAGS) | idc.LFLG_64BIT)
idc.set_inf_attr(idc.INF_DEMNAMES, idaapi.DEMNAM_GCC3)
idaapi.set_compiler_id(idaapi.COMP_GNU)
idaapi.add_til('gnulnx_arm' if f.armv7 else 'gnulnx_arm64', 1)
loadbase = 0x60000000 if f.armv7 else 0x7100000000
f.binfile.seek(0)
as_string = f.binfile.read(f.bssoff)
idaapi.mem2base(as_string, loadbase)
if f.text[1] != None:
li.file2base(f.text[1], loadbase + f.text[2], loadbase + f.text[2] + f.text[3], True)
if f.ro[1] != None:
li.file2base(f.ro[1], loadbase + f.ro[2], loadbase + f.ro[2] + f.ro[3], True)
if f.data[1] != None:
li.file2base(f.data[1], loadbase + f.data[2], loadbase + f.data[2] + f.data[3], True)
for start, end, name, kind in f.sections:
if name.startswith('.got'):
kind = 'CONST'
idaapi.add_segm(0, loadbase+start, loadbase+end, name, kind)
segm = idaapi.get_segm_by_name(name)
if kind == 'CONST':
segm.perm = idaapi.SEGPERM_READ
elif kind == 'CODE':
segm.perm = idaapi.SEGPERM_READ | idaapi.SEGPERM_EXEC
elif kind == 'DATA':
segm.perm = idaapi.SEGPERM_READ | idaapi.SEGPERM_WRITE
elif kind == 'BSS':
segm.perm = idaapi.SEGPERM_READ | idaapi.SEGPERM_WRITE
idaapi.update_segm(segm)
idaapi.set_segm_addressing(segm, 1 if f.armv7 else 2)
# do imports
# TODO: can we make imports show up in "Imports" window?
undef_count = 0
for s in f.symbols:
if not s.shndx and s.name:
undef_count += 1
last_ea = max(loadbase + end for start, end, name, kind in f.sections)
undef_entry_size = 8
undef_ea = ((last_ea + 0xFFF) & ~0xFFF) + undef_entry_size # plus 8 so we don't end up on the "end" symbol
idaapi.add_segm(0, undef_ea, undef_ea+undef_count*undef_entry_size, "UNDEF", "XTRN")
segm = idaapi.get_segm_by_name("UNDEF")
segm.type = idaapi.SEG_XTRN
idaapi.update_segm(segm)
for i,s in enumerate(f.symbols):
if not s.shndx and s.name:
idaapi.create_data(undef_ea, idc.FF_QWORD, 8, idaapi.BADADDR)
idaapi.force_name(undef_ea, s.name)
s.resolved = undef_ea
undef_ea += undef_entry_size
elif i != 0:
assert s.shndx
s.resolved = loadbase + s.value
if s.name:
if s.type == STT_FUNC:
print(hex(s.resolved), s.name)
idaapi.add_entry(s.resolved, s.resolved, s.name, 0)
else:
idaapi.force_name(s.resolved, s.name)
else:
# NULL symbol
s.resolved = 0
funcs = set()
for s in f.symbols:
if s.name and s.shndx and s.value:
if s.type == STT_FUNC:
funcs.add(loadbase+s.value)
got_name_lookup = {}
for offset, r_type, sym, addend in f.relocations:
target = offset + loadbase
if r_type in (R_ARM_GLOB_DAT, R_ARM_JUMP_SLOT, R_ARM_ABS32):
if not sym:
print('error: relocation at %X failed' % target)
else:
idaapi.put_dword(target, sym.resolved)
elif r_type == R_ARM_RELATIVE:
idaapi.put_dword(target, idaapi.get_dword(target) + loadbase)
elif r_type in (R_AARCH64_GLOB_DAT, R_AARCH64_JUMP_SLOT, R_AARCH64_ABS64):
idaapi.put_qword(target, sym.resolved + addend)
if addend == 0:
got_name_lookup[offset] = sym.name
elif r_type == R_AARCH64_RELATIVE:
idaapi.put_qword(target, loadbase + addend)
if addend < f.textsize:
funcs.add(loadbase + addend)
else:
print('TODO r_type %d' % (r_type,))
ida_make_offset(f, target)
for func, target in f.plt_entries:
if target in got_name_lookup:
addr = loadbase + func
funcs.add(addr)
idaapi.force_name(addr, got_name_lookup[target])
funcs |= find_bl_targets(loadbase, loadbase+f.textsize)
for addr in sorted(funcs, reverse=True):
idc.AutoMark(addr, idc.AU_CODE)
idc.AutoMark(addr, idc.AU_PROC)
return 1