From 1c60c8680370477a0dcd2b2365508c24b68bb3cf Mon Sep 17 00:00:00 2001 From: jakcron Date: Thu, 22 Mar 2018 13:26:22 +0800 Subject: [PATCH] Removed u8,u16,u32,u64 typedef --- lib/libes/include/es/ETicketBody_V2.h | 178 +++++++++--------- .../include/es/ETicketContentRecord_V1.h | 22 +-- .../include/es/ETicketSectionHeader_V2.h | 60 +++--- lib/libes/source/ETicketBody_V2.cpp | 56 +++--- lib/libes/source/ETicketSectionHeader_V2.cpp | 22 +-- lib/libfnd/include/fnd/ISerialiseableBinary.h | 4 +- lib/libfnd/include/fnd/io.h | 2 +- lib/libfnd/include/fnd/types.h | 4 - lib/libfnd/source/io.cpp | 2 +- lib/libnx/include/nx/AciBinary.h | 6 +- lib/libnx/include/nx/AciHeader.h | 68 +++---- lib/libnx/include/nx/AcidBinary.h | 6 +- lib/libnx/include/nx/FacBinary.h | 20 +- lib/libnx/include/nx/FacHeader.h | 44 ++--- lib/libnx/include/nx/HandleTableSizeEntry.h | 16 +- lib/libnx/include/nx/HandleTableSizeHandler.h | 4 +- lib/libnx/include/nx/InteruptEntry.h | 24 +-- lib/libnx/include/nx/InteruptHandler.h | 6 +- lib/libnx/include/nx/KcBinary.h | 6 +- lib/libnx/include/nx/KernelCapability.h | 22 +-- lib/libnx/include/nx/KernelVersionEntry.h | 30 +-- lib/libnx/include/nx/KernelVersionHandler.h | 8 +- lib/libnx/include/nx/MemoryMappingHandler.h | 8 +- lib/libnx/include/nx/MemoryPageEntry.h | 22 +-- lib/libnx/include/nx/MiscFlagsEntry.h | 16 +- lib/libnx/include/nx/MiscParamsEntry.h | 16 +- lib/libnx/include/nx/MiscParamsHandler.h | 4 +- lib/libnx/include/nx/NXCrypto.h | 42 ++--- lib/libnx/include/nx/NcaHeader.h | 40 ++-- lib/libnx/include/nx/NpdmBinary.h | 6 +- lib/libnx/include/nx/NpdmHeader.h | 88 ++++----- lib/libnx/include/nx/PfsHeader.h | 38 +--- lib/libnx/include/nx/SacBinary.h | 6 +- lib/libnx/include/nx/SacEntry.h | 4 +- lib/libnx/include/nx/SystemCallEntry.h | 30 +-- lib/libnx/include/nx/SystemCallHandler.h | 8 +- lib/libnx/include/nx/ThreadInfoEntry.h | 46 ++--- lib/libnx/include/nx/ThreadInfoHandler.h | 16 +- lib/libnx/include/nx/XciHeader.h | 62 +++--- lib/libnx/source/AciBinary.cpp | 6 +- lib/libnx/source/AciHeader.cpp | 20 +- lib/libnx/source/AcidBinary.cpp | 10 +- lib/libnx/source/FacBinary.cpp | 30 +-- lib/libnx/source/FacHeader.cpp | 42 ++--- lib/libnx/source/HandleTableSizeEntry.cpp | 6 +- lib/libnx/source/HandleTableSizeHandler.cpp | 4 +- lib/libnx/source/InteruptEntry.cpp | 8 +- lib/libnx/source/InteruptHandler.cpp | 4 +- lib/libnx/source/KcBinary.cpp | 16 +- lib/libnx/source/KernelCapability.cpp | 10 +- lib/libnx/source/KernelVersionEntry.cpp | 10 +- lib/libnx/source/KernelVersionHandler.cpp | 8 +- lib/libnx/source/MemoryPageEntry.cpp | 8 +- lib/libnx/source/MiscFlagsEntry.cpp | 6 +- lib/libnx/source/MiscFlagsHandler.cpp | 4 +- lib/libnx/source/MiscParamsEntry.cpp | 6 +- lib/libnx/source/MiscParamsHandler.cpp | 4 +- lib/libnx/source/NcaHeader.cpp | 30 +-- lib/libnx/source/NpdmBinary.cpp | 6 +- lib/libnx/source/NpdmHeader.cpp | 26 +-- lib/libnx/source/PfsHeader.cpp | 28 +-- lib/libnx/source/SacBinary.cpp | 8 +- lib/libnx/source/SacEntry.cpp | 4 +- lib/libnx/source/SystemCallEntry.cpp | 10 +- lib/libnx/source/SystemCallHandler.cpp | 8 +- lib/libnx/source/ThreadInfoEntry.cpp | 18 +- lib/libnx/source/ThreadInfoHandler.cpp | 16 +- programs/npdmtool/source/main.cpp | 12 +- programs/tiktool/source/main.cpp | 12 +- 69 files changed, 699 insertions(+), 743 deletions(-) diff --git a/lib/libes/include/es/ETicketBody_V2.h b/lib/libes/include/es/ETicketBody_V2.h index 8f68b3c..29fcaba 100644 --- a/lib/libes/include/es/ETicketBody_V2.h +++ b/lib/libes/include/es/ETicketBody_V2.h @@ -28,19 +28,19 @@ namespace es ETicketBody_V2(); ETicketBody_V2(const ETicketBody_V2& other); - ETicketBody_V2(const u8* bytes, size_t len); + ETicketBody_V2(const byte_t* bytes, size_t len); bool operator==(const ETicketBody_V2& other) const; bool operator!=(const ETicketBody_V2& other) const; void operator=(const ETicketBody_V2& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary virtual void exportBinary(); - virtual void importBinary(const u8* bytes, size_t len); + virtual void importBinary(const byte_t* bytes, size_t len); // variables virtual void clear(); @@ -48,20 +48,20 @@ namespace es const std::string& getIssuer() const; void setIssuer(const std::string& issuer); - const u8* getEncTitleKey() const; - void setEncTitleKey(const u8* data, size_t len); + const byte_t* getEncTitleKey() const; + void setEncTitleKey(const byte_t* data, size_t len); TitleKeyEncType getTitleKeyEncType() const; void setTitleKeyEncType(TitleKeyEncType type); - u16 getTicketVersion() const; - void setTicketVersion(u16 version); + uint16_t getTicketVersion() const; + void setTicketVersion(uint16_t version); LicenseType getLicenseType() const; void setLicenseType(LicenseType type); - u8 getCommonKeyId() const; - void setCommonKeyId(u8 id); + byte_t getCommonKeyId() const; + void setCommonKeyId(byte_t id); bool isPreInstall() const; void setIsPreInstall(bool isPreInstall); @@ -72,37 +72,37 @@ namespace es bool allowAllContent() const; void setAllowAllContent(bool allowAllContent); - const u8* getReservedRegion() const; - void setReservedRegion(const u8* data, size_t len); + const byte_t* getReservedRegion() const; + void setReservedRegion(const byte_t* data, size_t len); - u64 getTicketId() const; - void setTicketId(u64 id); + uint64_t getTicketId() const; + void setTicketId(uint64_t id); - u64 getDeviceId() const; - void setDeviceId(u64 id); + uint64_t getDeviceId() const; + void setDeviceId(uint64_t id); - const u8* getRightsId() const; - void setRightsId(const u8* id); + const byte_t* getRightsId() const; + void setRightsId(const byte_t* id); - u32 getAccountId() const; - void setAccountId(u32 id); + uint32_t getAccountId() const; + void setAccountId(uint32_t id); - u32 getSectionTotalSize() const; - void setSectionTotalSize(u32 size); + uint32_t getSectionTotalSize() const; + void setSectionTotalSize(uint32_t size); - u32 getSectionHeaderOffset() const; - void setSectionHeaderOffset(u32 offset); + uint32_t getSectionHeaderOffset() const; + void setSectionHeaderOffset(uint32_t offset); - u16 getSectionNum() const; - void setSectionNum(u16 num); + uint16_t getSectionNum() const; + void setSectionNum(uint16_t num); - u16 getSectionEntrySize() const; - void setSectionEntrySize(u16 size); + uint16_t getSectionEntrySize() const; + void setSectionEntrySize(uint16_t size); private: const std::string kModuleName = "ES_ETICKET_BODY_V2"; static const size_t kIssuerLen = 0x40; - static const u8 kFormatVersion = 2; + static const byte_t kFormatVersion = 2; static const size_t kEncTitleKeyLen = crypto::rsa::kRsa2048Size; static const size_t kReservedRegionLen = 8; static const size_t kRightsIdLen = 16; @@ -119,74 +119,74 @@ namespace es { private: char issuer_[kIssuerLen]; - u8 enc_title_key_[kEncTitleKeyLen]; - u8 format_version_; - u8 title_key_enc_type_; - u16 ticket_version_; - u8 license_type_; - u8 common_key_id_; - u8 property_mask_; - u8 reserved_0_; - u8 reserved_region_[kReservedRegionLen]; // explicitly reserved - u64 ticket_id_; - u64 device_id_; - u8 rights_id_[kRightsIdLen]; - u32 account_id_; - u32 sect_total_size_; - u32 sect_header_offset_; - u16 sect_num_; - u16 sect_entry_size_; + byte_t enc_title_key_[kEncTitleKeyLen]; + byte_t format_version_; + byte_t title_key_enc_type_; + uint16_t ticket_version_; + byte_t license_type_; + byte_t common_key_id_; + byte_t property_mask_; + byte_t reserved_0_; + byte_t reserved_region_[kReservedRegionLen]; // explicitly reserved + uint64_t ticket_id_; + uint64_t device_id_; + byte_t rights_id_[kRightsIdLen]; + uint32_t account_id_; + uint32_t sect_total_size_; + uint32_t sect_header_offset_; + uint16_t sect_num_; + uint16_t sect_entry_size_; public: const char* issuer() const { return issuer_; } void set_issuer(const char issuer[kIssuerLen]) { strncpy(issuer_, issuer, kIssuerLen); } - const u8* enc_title_key() const { return enc_title_key_; } - void set_enc_title_key(const u8* enc_title_key, size_t len) { memset(enc_title_key_, 0, kEncTitleKeyLen); memcpy(enc_title_key_, enc_title_key, MIN(len, kEncTitleKeyLen)); } + const byte_t* enc_title_key() const { return enc_title_key_; } + void set_enc_title_key(const byte_t* enc_title_key, size_t len) { memset(enc_title_key_, 0, kEncTitleKeyLen); memcpy(enc_title_key_, enc_title_key, MIN(len, kEncTitleKeyLen)); } - u8 format_version() const { return format_version_; } - void set_format_version(u8 version) { format_version_ = version; } + byte_t format_version() const { return format_version_; } + void set_format_version(byte_t version) { format_version_ = version; } - u8 title_key_enc_type() const { return title_key_enc_type_; } - void set_title_key_enc_type(u8 type) { title_key_enc_type_ = type; } + byte_t title_key_enc_type() const { return title_key_enc_type_; } + void set_title_key_enc_type(byte_t type) { title_key_enc_type_ = type; } - u16 ticket_version() const { return le_hword(ticket_version_); } - void set_ticket_version(u16 version) { ticket_version_ = le_hword(version); } + uint16_t ticket_version() const { return le_hword(ticket_version_); } + void set_ticket_version(uint16_t version) { ticket_version_ = le_hword(version); } - u8 license_type() const { return license_type_; } - void set_license_type(u8 license_type) { license_type_ = license_type; } + byte_t license_type() const { return license_type_; } + void set_license_type(byte_t license_type) { license_type_ = license_type; } - u8 common_key_id() const { return common_key_id_; } - void set_common_key_id(u8 common_key_id) { common_key_id_ = common_key_id; } + byte_t common_key_id() const { return common_key_id_; } + void set_common_key_id(byte_t common_key_id) { common_key_id_ = common_key_id; } - u8 property_mask() const { return property_mask_; } - void set_property_mask(u8 mask) { property_mask_ = mask; } + byte_t property_mask() const { return property_mask_; } + void set_property_mask(byte_t mask) { property_mask_ = mask; } - const u8* reserved_region() const { return reserved_region_; } - void set_reserved_region(const u8* reserved_region, size_t len) { memcpy(reserved_region_, reserved_region, MIN(len, kReservedRegionLen)); } + const byte_t* reserved_region() const { return reserved_region_; } + void set_reserved_region(const byte_t* reserved_region, size_t len) { memcpy(reserved_region_, reserved_region, MIN(len, kReservedRegionLen)); } - u64 ticket_id() const { return le_dword(ticket_id_); } - void set_ticket_id(u64 ticket_id) { ticket_id_ = le_dword(ticket_id); } + uint64_t ticket_id() const { return le_dword(ticket_id_); } + void set_ticket_id(uint64_t ticket_id) { ticket_id_ = le_dword(ticket_id); } - u64 device_id() const { return le_dword(device_id_); } - void set_device_id(u64 device_id) { device_id_ = le_dword(device_id); } + uint64_t device_id() const { return le_dword(device_id_); } + void set_device_id(uint64_t device_id) { device_id_ = le_dword(device_id); } - const u8* rights_id() const { return rights_id_; } - void set_rights_id(const u8 rights_id[kRightsIdLen]) { memcpy(rights_id_, rights_id, kRightsIdLen); } + const byte_t* rights_id() const { return rights_id_; } + void set_rights_id(const byte_t rights_id[kRightsIdLen]) { memcpy(rights_id_, rights_id, kRightsIdLen); } - u32 account_id() const { return le_word(account_id_); } - void set_account_id(u32 id) { account_id_ = le_word(id); } + uint32_t account_id() const { return le_word(account_id_); } + void set_account_id(uint32_t id) { account_id_ = le_word(id); } - u32 sect_total_size() const { return le_word(sect_total_size_); } - void set_sect_total_size(u32 size) { sect_total_size_ = le_word(size); } + uint32_t sect_total_size() const { return le_word(sect_total_size_); } + void set_sect_total_size(uint32_t size) { sect_total_size_ = le_word(size); } - u32 sect_header_offset() const { return le_word(sect_header_offset_); } - void set_sect_header_offset(u32 offset) { sect_header_offset_ = le_word(offset); } + uint32_t sect_header_offset() const { return le_word(sect_header_offset_); } + void set_sect_header_offset(uint32_t offset) { sect_header_offset_ = le_word(offset); } - u16 sect_num() const { return le_hword(sect_num_); } - void set_sect_num(u16 num) { sect_num_ = num; } + uint16_t sect_num() const { return le_hword(sect_num_); } + void set_sect_num(uint16_t num) { sect_num_ = num; } - u16 sect_entry_size() const { return le_hword(sect_entry_size_); } - void set_sect_entry_size(u16 size) { sect_entry_size_ = le_hword(size); } + uint16_t sect_entry_size() const { return le_hword(sect_entry_size_); } + void set_sect_entry_size(uint16_t size) { sect_entry_size_ = le_hword(size); } }; #pragma pack (pop) @@ -195,23 +195,23 @@ namespace es // variables std::string mIssuer; - u8 mEncTitleKey[kEncTitleKeyLen]; + byte_t mEncTitleKey[kEncTitleKeyLen]; TitleKeyEncType mEncType; // 0 = aes-cbc, 1 = rsa2048 - u16 mTicketVersion; + uint16_t mTicketVersion; LicenseType mLicenseType; - u8 mCommonKeyId; + byte_t mCommonKeyId; bool mPreInstall; bool mSharedTitle; bool mAllowAllContent; - u8 mReservedRegion[kReservedRegionLen]; // explicitly reserved - u64 mTicketId; - u64 mDeviceId; - u8 mRightsId[kRightsIdLen]; - u32 mAccountId; - u32 mSectTotalSize; - u32 mSectHeaderOffset; - u16 mSectNum; - u16 mSectEntrySize; + byte_t mReservedRegion[kReservedRegionLen]; // explicitly reserved + uint64_t mTicketId; + uint64_t mDeviceId; + byte_t mRightsId[kRightsIdLen]; + uint32_t mAccountId; + uint32_t mSectTotalSize; + uint32_t mSectHeaderOffset; + uint16_t mSectNum; + uint16_t mSectEntrySize; // helpers bool isEqual(const ETicketBody_V2& other) const; diff --git a/lib/libes/include/es/ETicketContentRecord_V1.h b/lib/libes/include/es/ETicketContentRecord_V1.h index 56d9be4..db847ae 100644 --- a/lib/libes/include/es/ETicketContentRecord_V1.h +++ b/lib/libes/include/es/ETicketContentRecord_V1.h @@ -20,14 +20,14 @@ namespace es { private: static const size_t kAccessMaskSize = 0x80; - static const u16 kGroupMask = 0xFC00; - static const u16 kAccessMaskMask = 0x3FF; + static const uint16_t kGroupMask = 0xFC00; + static const uint16_t kAccessMaskMask = 0x3FF; - u32 group_; - u8 access_mask_[kAccessMaskSize]; + uint32_t group_; + byte_t access_mask_[kAccessMaskSize]; public: - u32 index_group() const { return be_word(group_); } - bool is_index_enabled(u16 index) const + uint32_t index_group() const { return be_word(group_); } + bool is_index_enabled(uint16_t index) const { return (index_group() == get_group(index)) \ && ((access_mask_[get_access_mask(index) / 8] & BIT(get_access_mask(index) % 8)) != 0); @@ -35,12 +35,12 @@ namespace es void clear() { memset(this, 0, sizeof(sContentRecord_v1)); } - void set_index_group(u16 index) { group_ = be_hword(get_group(index)); } - void enable_index(u16 index) { access_mask_[get_access_mask(index) / 8] |= BIT(get_access_mask(index) % 8); } - void disable_index(u16 index) { access_mask_[get_access_mask(index) / 8] &= ~BIT(get_access_mask(index) % 8); } + void set_index_group(uint16_t index) { group_ = be_hword(get_group(index)); } + void enable_index(uint16_t index) { access_mask_[get_access_mask(index) / 8] |= BIT(get_access_mask(index) % 8); } + void disable_index(uint16_t index) { access_mask_[get_access_mask(index) / 8] &= ~BIT(get_access_mask(index) % 8); } - inline u16 get_access_mask(u16 index) const { return index & kAccessMaskMask; } - inline u16 get_group(u16 index) const { return index & kGroupMask; } + inline uint16_t get_access_mask(uint16_t index) const { return index & kAccessMaskMask; } + inline uint16_t get_group(uint16_t index) const { return index & kGroupMask; } }; #pragma pack (pop) }; diff --git a/lib/libes/include/es/ETicketSectionHeader_V2.h b/lib/libes/include/es/ETicketSectionHeader_V2.h index ae810b5..8a8ffa9 100644 --- a/lib/libes/include/es/ETicketSectionHeader_V2.h +++ b/lib/libes/include/es/ETicketSectionHeader_V2.h @@ -21,34 +21,34 @@ namespace es ETicketSectionHeader_V2(); ETicketSectionHeader_V2(const ETicketSectionHeader_V2& other); - ETicketSectionHeader_V2(const u8* bytes, size_t len); + ETicketSectionHeader_V2(const byte_t* bytes, size_t len); bool operator==(const ETicketSectionHeader_V2& other) const; bool operator!=(const ETicketSectionHeader_V2& other) const; void operator=(const ETicketSectionHeader_V2& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary virtual void exportBinary(); - virtual void importBinary(const u8* bytes, size_t len); + virtual void importBinary(const byte_t* bytes, size_t len); // variables virtual void clear(); - u32 getSectionOffset() const; - void setSectionOffset(u32 offset); + uint32_t getSectionOffset() const; + void setSectionOffset(uint32_t offset); - u32 getRecordSize() const; - void setRecordSize(u32 size); + uint32_t getRecordSize() const; + void setRecordSize(uint32_t size); - u32 getSectionSize() const; - void getSectionSize(u32 size); + uint32_t getSectionSize() const; + void getSectionSize(uint32_t size); - u16 getRecordNum() const; - void setRecordNum(u16 record_num); + uint16_t getRecordNum() const; + void setRecordNum(uint16_t record_num); SectionType getSectionType() const; void setSectionType(SectionType type); @@ -59,26 +59,26 @@ namespace es struct sSectionHeader_v2 { private: - u32 section_offset_; - u32 record_size_; - u32 section_size_; - u16 record_num_; - u16 section_type_; + uint32_t section_offset_; + uint32_t record_size_; + uint32_t section_size_; + uint16_t record_num_; + uint16_t section_type_; public: - u32 section_offset() const { return le_word(section_offset_); } - void set_section_offset(u32 offset) { section_offset_ = le_word(offset); } + uint32_t section_offset() const { return le_word(section_offset_); } + void set_section_offset(uint32_t offset) { section_offset_ = le_word(offset); } - u32 record_size() const { return le_word(record_size_); } - void set_record_size(u32 size) { record_size_ = le_word(size); } + uint32_t record_size() const { return le_word(record_size_); } + void set_record_size(uint32_t size) { record_size_ = le_word(size); } - u32 section_size() const { return le_word(section_size_); } - void set_section_size(u32 size) { section_size_ = le_word(size); } + uint32_t section_size() const { return le_word(section_size_); } + void set_section_size(uint32_t size) { section_size_ = le_word(size); } - u16 record_num() const { return le_hword(record_num_); } - void set_record_num(u16 num) { record_num_ = le_hword(num); } + uint16_t record_num() const { return le_hword(record_num_); } + void set_record_num(uint16_t num) { record_num_ = le_hword(num); } - u16 section_type() const { return le_hword(section_type_); } - void set_section_type(u16 type) { section_type_ = le_hword(type); } + uint16_t section_type() const { return le_hword(section_type_); } + void set_section_type(uint16_t type) { section_type_ = le_hword(type); } }; #pragma pack (pop) @@ -86,10 +86,10 @@ namespace es fnd::MemoryBlob mBinaryBlob; // variables - u32 mSectionOffset; - u32 mRecordSize; - u32 mSectionSize; - u16 mRecordNum; + uint32_t mSectionOffset; + uint32_t mRecordSize; + uint32_t mSectionSize; + uint16_t mRecordNum; SectionType mSectionType; // helpers diff --git a/lib/libes/source/ETicketBody_V2.cpp b/lib/libes/source/ETicketBody_V2.cpp index a199b6f..637c348 100644 --- a/lib/libes/source/ETicketBody_V2.cpp +++ b/lib/libes/source/ETicketBody_V2.cpp @@ -12,7 +12,7 @@ es::ETicketBody_V2::ETicketBody_V2(const ETicketBody_V2 & other) copyFrom(other); } -es::ETicketBody_V2::ETicketBody_V2(const u8 * bytes, size_t len) +es::ETicketBody_V2::ETicketBody_V2(const byte_t * bytes, size_t len) { importBinary(bytes, len); } @@ -32,7 +32,7 @@ void es::ETicketBody_V2::operator=(const ETicketBody_V2 & other) copyFrom(other); } -const u8 * es::ETicketBody_V2::getBytes() const +const byte_t * es::ETicketBody_V2::getBytes() const { return mBinaryBlob.getBytes(); } @@ -103,7 +103,7 @@ void es::ETicketBody_V2::exportBinary() body->set_enc_title_key(mEncTitleKey, kEncTitleKeyLen); body->set_title_key_enc_type(mEncType); body->set_ticket_version(mTicketVersion); - u8 property_mask = 0; + byte_t property_mask = 0; property_mask |= mPreInstall ? BIT(FLAG_PRE_INSTALL) : 0; property_mask |= mSharedTitle ? BIT(FLAG_SHARED_TITLE) : 0; property_mask |= mAllowAllContent ? BIT(FLAG_ALLOW_ALL_CONTENT) : 0; @@ -119,7 +119,7 @@ void es::ETicketBody_V2::exportBinary() body->set_sect_entry_size(mSectEntrySize); } -void es::ETicketBody_V2::importBinary(const u8 * bytes, size_t len) +void es::ETicketBody_V2::importBinary(const byte_t * bytes, size_t len) { if (len < sizeof(sTicketBody_v2)) { @@ -193,12 +193,12 @@ void es::ETicketBody_V2::setIssuer(const std::string & issuer) mIssuer = issuer; } -const u8 * es::ETicketBody_V2::getEncTitleKey() const +const byte_t * es::ETicketBody_V2::getEncTitleKey() const { return mEncTitleKey; } -void es::ETicketBody_V2::setEncTitleKey(const u8 * data, size_t len) +void es::ETicketBody_V2::setEncTitleKey(const byte_t * data, size_t len) { memset(mEncTitleKey, 0, kEncTitleKeyLen); memcpy(mEncTitleKey, data, MIN(len, kEncTitleKeyLen)); @@ -214,12 +214,12 @@ void es::ETicketBody_V2::setTitleKeyEncType(TitleKeyEncType type) mEncType = type; } -u16 es::ETicketBody_V2::getTicketVersion() const +uint16_t es::ETicketBody_V2::getTicketVersion() const { return mTicketVersion; } -void es::ETicketBody_V2::setTicketVersion(u16 version) +void es::ETicketBody_V2::setTicketVersion(uint16_t version) { mTicketVersion = version; } @@ -234,12 +234,12 @@ void es::ETicketBody_V2::setLicenseType(LicenseType type) mLicenseType = type; } -u8 es::ETicketBody_V2::getCommonKeyId() const +byte_t es::ETicketBody_V2::getCommonKeyId() const { return mCommonKeyId; } -void es::ETicketBody_V2::setCommonKeyId(u8 id) +void es::ETicketBody_V2::setCommonKeyId(byte_t id) { mCommonKeyId = id; } @@ -274,93 +274,93 @@ void es::ETicketBody_V2::setAllowAllContent(bool allowAllContent) mAllowAllContent = allowAllContent; } -const u8 * es::ETicketBody_V2::getReservedRegion() const +const byte_t * es::ETicketBody_V2::getReservedRegion() const { return mReservedRegion; } -void es::ETicketBody_V2::setReservedRegion(const u8 * data, size_t len) +void es::ETicketBody_V2::setReservedRegion(const byte_t * data, size_t len) { memset(mReservedRegion, 0, kReservedRegionLen); memcpy(mReservedRegion, data, MIN(len, kReservedRegionLen)); } -u64 es::ETicketBody_V2::getTicketId() const +uint64_t es::ETicketBody_V2::getTicketId() const { return mTicketId; } -void es::ETicketBody_V2::setTicketId(u64 id) +void es::ETicketBody_V2::setTicketId(uint64_t id) { mTicketId = id; } -u64 es::ETicketBody_V2::getDeviceId() const +uint64_t es::ETicketBody_V2::getDeviceId() const { return mDeviceId; } -void es::ETicketBody_V2::setDeviceId(u64 id) +void es::ETicketBody_V2::setDeviceId(uint64_t id) { mDeviceId = id; } -const u8 * es::ETicketBody_V2::getRightsId() const +const byte_t * es::ETicketBody_V2::getRightsId() const { return mRightsId; } -void es::ETicketBody_V2::setRightsId(const u8 * id) +void es::ETicketBody_V2::setRightsId(const byte_t * id) { memcpy(mRightsId, id, kRightsIdLen); } -u32 es::ETicketBody_V2::getAccountId() const +uint32_t es::ETicketBody_V2::getAccountId() const { return mAccountId; } -void es::ETicketBody_V2::setAccountId(u32 id) +void es::ETicketBody_V2::setAccountId(uint32_t id) { mAccountId = id; } -u32 es::ETicketBody_V2::getSectionTotalSize() const +uint32_t es::ETicketBody_V2::getSectionTotalSize() const { return mSectTotalSize; } -void es::ETicketBody_V2::setSectionTotalSize(u32 size) +void es::ETicketBody_V2::setSectionTotalSize(uint32_t size) { mSectTotalSize = size; } -u32 es::ETicketBody_V2::getSectionHeaderOffset() const +uint32_t es::ETicketBody_V2::getSectionHeaderOffset() const { return mSectHeaderOffset; } -void es::ETicketBody_V2::setSectionHeaderOffset(u32 offset) +void es::ETicketBody_V2::setSectionHeaderOffset(uint32_t offset) { mSectHeaderOffset = offset; } -u16 es::ETicketBody_V2::getSectionNum() const +uint16_t es::ETicketBody_V2::getSectionNum() const { return mSectNum; } -void es::ETicketBody_V2::setSectionNum(u16 num) +void es::ETicketBody_V2::setSectionNum(uint16_t num) { mSectNum = num; } -u16 es::ETicketBody_V2::getSectionEntrySize() const +uint16_t es::ETicketBody_V2::getSectionEntrySize() const { return mSectEntrySize; } -void es::ETicketBody_V2::setSectionEntrySize(u16 size) +void es::ETicketBody_V2::setSectionEntrySize(uint16_t size) { mSectEntrySize = size; } diff --git a/lib/libes/source/ETicketSectionHeader_V2.cpp b/lib/libes/source/ETicketSectionHeader_V2.cpp index 9eb2a0e..3f53f79 100644 --- a/lib/libes/source/ETicketSectionHeader_V2.cpp +++ b/lib/libes/source/ETicketSectionHeader_V2.cpp @@ -10,7 +10,7 @@ es::ETicketSectionHeader_V2::ETicketSectionHeader_V2(const ETicketSectionHeader_ copyFrom(other); } -es::ETicketSectionHeader_V2::ETicketSectionHeader_V2(const u8 * bytes, size_t len) +es::ETicketSectionHeader_V2::ETicketSectionHeader_V2(const byte_t * bytes, size_t len) { importBinary(bytes, len); } @@ -30,7 +30,7 @@ void es::ETicketSectionHeader_V2::operator=(const ETicketSectionHeader_V2 & othe copyFrom(other); } -const u8 * es::ETicketSectionHeader_V2::getBytes() const +const byte_t * es::ETicketSectionHeader_V2::getBytes() const { return mBinaryBlob.getBytes(); } @@ -52,7 +52,7 @@ void es::ETicketSectionHeader_V2::exportBinary() hdr->set_section_type(mSectionType); } -void es::ETicketSectionHeader_V2::importBinary(const u8 * bytes, size_t len) +void es::ETicketSectionHeader_V2::importBinary(const byte_t * bytes, size_t len) { if (len < sizeof(sSectionHeader_v2)) { @@ -108,42 +108,42 @@ void es::ETicketSectionHeader_V2::clear() mSectionType = PERMANENT; } -u32 es::ETicketSectionHeader_V2::getSectionOffset() const +uint32_t es::ETicketSectionHeader_V2::getSectionOffset() const { return mSectionOffset; } -void es::ETicketSectionHeader_V2::setSectionOffset(u32 offset) +void es::ETicketSectionHeader_V2::setSectionOffset(uint32_t offset) { mSectionOffset = offset; } -u32 es::ETicketSectionHeader_V2::getRecordSize() const +uint32_t es::ETicketSectionHeader_V2::getRecordSize() const { return mRecordSize; } -void es::ETicketSectionHeader_V2::setRecordSize(u32 size) +void es::ETicketSectionHeader_V2::setRecordSize(uint32_t size) { mRecordSize = size; } -u32 es::ETicketSectionHeader_V2::getSectionSize() const +uint32_t es::ETicketSectionHeader_V2::getSectionSize() const { return mSectionSize; } -void es::ETicketSectionHeader_V2::getSectionSize(u32 size) +void es::ETicketSectionHeader_V2::getSectionSize(uint32_t size) { mSectionSize = size; } -u16 es::ETicketSectionHeader_V2::getRecordNum() const +uint16_t es::ETicketSectionHeader_V2::getRecordNum() const { return mRecordNum; } -void es::ETicketSectionHeader_V2::setRecordNum(u16 record_num) +void es::ETicketSectionHeader_V2::setRecordNum(uint16_t record_num) { mRecordNum = record_num; } diff --git a/lib/libfnd/include/fnd/ISerialiseableBinary.h b/lib/libfnd/include/fnd/ISerialiseableBinary.h index ae4b339..5928c81 100644 --- a/lib/libfnd/include/fnd/ISerialiseableBinary.h +++ b/lib/libfnd/include/fnd/ISerialiseableBinary.h @@ -6,11 +6,11 @@ namespace fnd class ISerialiseableBinary { public: - virtual const u8* getBytes() const = 0; + virtual const byte_t* getBytes() const = 0; virtual size_t getSize() const = 0; virtual void exportBinary() = 0; - virtual void importBinary(const u8* bytes, size_t len) = 0; + virtual void importBinary(const byte_t* bytes, size_t len) = 0; virtual void clear() = 0; }; diff --git a/lib/libfnd/include/fnd/io.h b/lib/libfnd/include/fnd/io.h index 7e05f50..e80d5c3 100644 --- a/lib/libfnd/include/fnd/io.h +++ b/lib/libfnd/include/fnd/io.h @@ -8,6 +8,6 @@ namespace fnd { void readFile(const std::string& path, MemoryBlob& blob); void writeFile(const std::string& path, const MemoryBlob& blob); - void writeFile(const std::string& path, const u8* data, size_t len); + void writeFile(const std::string& path, const byte_t* data, size_t len); } } diff --git a/lib/libfnd/include/fnd/types.h b/lib/libfnd/include/fnd/types.h index 50961f9..2eeb08a 100644 --- a/lib/libfnd/include/fnd/types.h +++ b/lib/libfnd/include/fnd/types.h @@ -4,10 +4,6 @@ #include #include -typedef uint64_t u64; -typedef uint32_t u32; -typedef uint16_t u16; -typedef uint8_t u8; typedef uint8_t byte_t; #define MIN(x,y) ((x) <= (y)? (x) : (y)) diff --git a/lib/libfnd/source/io.cpp b/lib/libfnd/source/io.cpp index cc6066f..2f4ce8e 100644 --- a/lib/libfnd/source/io.cpp +++ b/lib/libfnd/source/io.cpp @@ -46,7 +46,7 @@ void io::writeFile(const std::string& path, const MemoryBlob & blob) writeFile(path, blob.getBytes(), blob.getSize()); } -void io::writeFile(const std::string & path, const u8 * data, size_t len) +void io::writeFile(const std::string & path, const byte_t * data, size_t len) { FILE* fp; size_t filesz, filepos; diff --git a/lib/libnx/include/nx/AciBinary.h b/lib/libnx/include/nx/AciBinary.h index 312fa42..c32e01c 100644 --- a/lib/libnx/include/nx/AciBinary.h +++ b/lib/libnx/include/nx/AciBinary.h @@ -15,19 +15,19 @@ namespace nx public: AciBinary(); AciBinary(const AciBinary& other); - AciBinary(const u8* bytes, size_t len); + AciBinary(const byte_t* bytes, size_t len); bool operator==(const AciBinary& other) const; bool operator!=(const AciBinary& other) const; void operator=(const AciBinary& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary virtual void exportBinary(); - virtual void importBinary(const u8* bytes, size_t len); + virtual void importBinary(const byte_t* bytes, size_t len); // variables virtual void clear(); diff --git a/lib/libnx/include/nx/AciHeader.h b/lib/libnx/include/nx/AciHeader.h index c7686cc..0293081 100644 --- a/lib/libnx/include/nx/AciHeader.h +++ b/lib/libnx/include/nx/AciHeader.h @@ -41,35 +41,35 @@ namespace nx AciHeader(); AciHeader(const AciHeader& other); - AciHeader(const u8* bytes, size_t len); + AciHeader(const byte_t* bytes, size_t len); bool operator==(const AciHeader& other) const; bool operator!=(const AciHeader& other) const; void operator=(const AciHeader& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary virtual void exportBinary(); - virtual void importBinary(const u8* bytes, size_t len); + virtual void importBinary(const byte_t* bytes, size_t len); // variables virtual void clear(); size_t getAciSize() const; // ACI0 only - u64 getProgramId() const; - void setProgramId(u64 program_id); + uint64_t getProgramId() const; + void setProgramId(uint64_t program_id); // ACID only size_t getAcidSize() const; //void setAcidSize(size_t size); - u64 getProgramIdMin() const; - void setProgramIdMin(u64 program_id); - u64 getProgramIdMax() const; - void setProgramIdMax(u64 program_id); + uint64_t getProgramIdMin() const; + void setProgramIdMin(uint64_t program_id); + uint64_t getProgramIdMax() const; + void setProgramIdMax(uint64_t program_id); // ACID & ACI0 void setHeaderOffset(size_t offset); @@ -94,42 +94,42 @@ namespace nx struct sAciHeader { private: - u8 signature_[4]; - u32 size_; // includes prefacing signature, set only in ACID made by SDK (it enables easy resigning) - u8 reserved_0[4]; - u32 flags_; // set in ACID only - u64 program_id_; // set only in ACI0 (since ACID is generic) - u64 program_id_max_; + byte_t signature_[4]; + uint32_t size_; // includes prefacing signature, set only in ACID made by SDK (it enables easy resigning) + byte_t reserved_0[4]; + uint32_t flags_; // set in ACID only + uint64_t program_id_; // set only in ACI0 (since ACID is generic) + uint64_t program_id_max_; struct sAciSection { private: - u32 offset_; // aligned by 0x10 from the last one - u32 size_; + uint32_t offset_; // aligned by 0x10 from the last one + uint32_t size_; public: - u32 offset() const { return le_word(offset_); } - void set_offset(u32 offset) { offset_ = le_word(offset); } + uint32_t offset() const { return le_word(offset_); } + void set_offset(uint32_t offset) { offset_ = le_word(offset); } - u32 size() const { return le_word(size_); } - void set_size(u32 size) { size_ = le_word(size); } + uint32_t size() const { return le_word(size_); } + void set_size(uint32_t size) { size_ = le_word(size); } } fac_, sac_, kc_; public: const char* signature() const { return (const char*)signature_; } void set_signature(const char* signature) { memcpy(signature_, signature, 4); } - u32 size() const { return le_word(size_); } - void set_size(u32 size) { size_ = le_word(size); } + uint32_t size() const { return le_word(size_); } + void set_size(uint32_t size) { size_ = le_word(size); } - u32 flags() const { return le_word(flags_); } - void set_flags(u32 flags) { flags_ = le_word(flags); } + uint32_t flags() const { return le_word(flags_); } + void set_flags(uint32_t flags) { flags_ = le_word(flags); } - u64 program_id() const { return le_dword(program_id_); } - void set_program_id(u64 program_id) { program_id_ = le_dword(program_id); } + uint64_t program_id() const { return le_dword(program_id_); } + void set_program_id(uint64_t program_id) { program_id_ = le_dword(program_id); } - u64 program_id_min() const { return program_id(); } - void set_program_id_min(u64 program_id) { set_program_id(program_id); } + uint64_t program_id_min() const { return program_id(); } + void set_program_id_min(uint64_t program_id) { set_program_id(program_id); } - u64 program_id_max() const { return le_dword(program_id_max_); } - void set_program_id_max(u64 program_id) { program_id_max_ = le_dword(program_id); } + uint64_t program_id_max() const { return le_dword(program_id_max_); } + void set_program_id_max(uint64_t program_id) { program_id_max_ = le_dword(program_id); } const sAciSection& fac() const { return fac_; } sAciSection& fac() { return fac_; } @@ -146,12 +146,12 @@ namespace nx fnd::MemoryBlob mBinaryBlob; // ACI variables - u64 mProgramId; + uint64_t mProgramId; // ACID variables size_t mAcidSize; - u64 mProgramIdMin; - u64 mProgramIdMax; + uint64_t mProgramIdMin; + uint64_t mProgramIdMax; // ACI(D) variables size_t mHeaderOffset; diff --git a/lib/libnx/include/nx/AcidBinary.h b/lib/libnx/include/nx/AcidBinary.h index 6d4cd52..7100b79 100644 --- a/lib/libnx/include/nx/AcidBinary.h +++ b/lib/libnx/include/nx/AcidBinary.h @@ -12,20 +12,20 @@ namespace nx public: AcidBinary(); AcidBinary(const AcidBinary& other); - AcidBinary(const u8* bytes, size_t len); + AcidBinary(const byte_t* bytes, size_t len); bool operator==(const AcidBinary& other) const; bool operator!=(const AcidBinary& other) const; void operator=(const AcidBinary& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary virtual void exportBinary(); void signBinary(const crypto::rsa::sRsa2048Key& key); - virtual void importBinary(const u8* bytes, size_t len); + virtual void importBinary(const byte_t* bytes, size_t len); void verifyBinary(const crypto::rsa::sRsa2048Key& key); // variables diff --git a/lib/libnx/include/nx/FacBinary.h b/lib/libnx/include/nx/FacBinary.h index fa9c6b0..619617c 100644 --- a/lib/libnx/include/nx/FacBinary.h +++ b/lib/libnx/include/nx/FacBinary.h @@ -13,39 +13,39 @@ namespace nx public: FacBinary(); FacBinary(const FacBinary& other); - FacBinary(const u8* bytes, size_t len); + FacBinary(const byte_t* bytes, size_t len); bool operator==(const FacBinary& other) const; bool operator!=(const FacBinary& other) const; void operator=(const FacBinary& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary void exportBinary(); - void importBinary(const u8* bytes, size_t len); + void importBinary(const byte_t* bytes, size_t len); // variables void clear(); - const fnd::List& getContentOwnerIdList() const; - void setContentOwnerIdList(const fnd::List& list); + const fnd::List& getContentOwnerIdList() const; + void setContentOwnerIdList(const fnd::List& list); - const fnd::List& getSaveDataOwnerIdList() const; - void setSaveDataOwnerIdList(const fnd::List& list); + const fnd::List& getSaveDataOwnerIdList() const; + void setSaveDataOwnerIdList(const fnd::List& list); private: const std::string kModuleName = "FAC_BINARY"; - static const u32 kFacFormatVersion = 1; + static const uint32_t kFacFormatVersion = 1; // raw binary fnd::MemoryBlob mBinaryBlob; // variables - fnd::List mContentOwnerIdList; - fnd::List mSaveDataOwnerIdList; + fnd::List mContentOwnerIdList; + fnd::List mSaveDataOwnerIdList; bool isEqual(const FacBinary& other) const; void copyFrom(const FacBinary& other); diff --git a/lib/libnx/include/nx/FacHeader.h b/lib/libnx/include/nx/FacHeader.h index e2edfee..672c451 100644 --- a/lib/libnx/include/nx/FacHeader.h +++ b/lib/libnx/include/nx/FacHeader.h @@ -38,26 +38,26 @@ namespace nx FacHeader(); FacHeader(const FacHeader& other); - FacHeader(const u8* bytes, size_t len); + FacHeader(const byte_t* bytes, size_t len); bool operator==(const FacHeader& other) const; bool operator!=(const FacHeader& other) const; void operator=(const FacHeader& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary void exportBinary(); - void importBinary(const u8* bytes, size_t len); + void importBinary(const byte_t* bytes, size_t len); // variables void clear(); size_t getFacSize() const; - u32 getFormatVersion() const; - void setFormatVersion(u32 version); + uint32_t getFormatVersion() const; + void setFormatVersion(uint32_t version); const fnd::List& getFsaRightsList() const; void setFsaRightsList(const fnd::List& list); @@ -72,38 +72,18 @@ namespace nx private: const std::string kModuleName = "FAC_HEADER"; - static const u32 kFacFormatVersion = 1; + static const uint32_t kFacFormatVersion = 1; #pragma pack (push, 1) struct sFacHeader { - private: - u32 version_; // default 1 - u64 fac_flags_; + le_uint32_t version; // default 1 + le_uint64_t fac_flags; struct sFacSection { - private: - u32 start_; - u32 end_; - public: - u32 start() const { return le_word(start_); } - void set_start(u32 start) { start_ = le_word(start); } - - u32 end() const { return le_word(end_); } - void set_end(u32 end) { end_ = le_word(end); } - } content_owner_ids_, save_data_owner_ids_; // the data for these follow later in binary. start/end relative to base of FacData instance - public: - u32 version() const { return le_word(version_); } - void set_version(u32 version) { version_ = le_word(version); } - - u64 fac_flags() const { return le_dword(fac_flags_); } - void set_fac_flags(u64 fac_flags) { fac_flags_ = le_dword(fac_flags); } - - const sFacSection& content_owner_ids() const { return content_owner_ids_; } - sFacSection& content_owner_ids() { return content_owner_ids_; } - - const sFacSection& save_data_owner_ids() const { return save_data_owner_ids_; } - sFacSection& save_data_owner_ids() { return save_data_owner_ids_; } + le_uint32_t start; + le_uint32_t end; + } content_owner_ids, save_data_owner_ids; // the data for these follow later in binary. start/end relative to base of FacData instance }; #pragma pack (pop) @@ -111,7 +91,7 @@ namespace nx fnd::MemoryBlob mBinaryBlob; // variables - u32 mVersion; + uint32_t mVersion; fnd::List mFsaRights; struct sSection { diff --git a/lib/libnx/include/nx/HandleTableSizeEntry.h b/lib/libnx/include/nx/HandleTableSizeEntry.h index e00578d..7f19964 100644 --- a/lib/libnx/include/nx/HandleTableSizeEntry.h +++ b/lib/libnx/include/nx/HandleTableSizeEntry.h @@ -10,33 +10,33 @@ namespace nx public: HandleTableSizeEntry(); HandleTableSizeEntry(const KernelCapability& kernel_cap); - HandleTableSizeEntry(u16 size); + HandleTableSizeEntry(uint16_t size); // kernel capability const KernelCapability& getKernelCapability() const; void setKernelCapability(const KernelCapability& kernel_cap); // variables - u16 getHandleTableSize() const; - void setHandleTableSize(u16 size); + uint16_t getHandleTableSize() const; + void setHandleTableSize(uint16_t size); private: const std::string kModuleName = "HANDLE_TABLE_SIZE_ENTRY"; static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_HANDLE_TABLE_SIZE; - static const u16 kValBits = 10; - static const u16 kMaxHandleTableSize = BIT(kValBits) - 1; + static const uint16_t kValBits = 10; + static const uint16_t kMaxHandleTableSize = BIT(kValBits) - 1; KernelCapability mCap; - u16 mHandleTableSize; + uint16_t mHandleTableSize; inline void updateCapField() { - u32 field = mHandleTableSize & kMaxHandleTableSize; + uint32_t field = mHandleTableSize & kMaxHandleTableSize; mCap.setField(field); } inline void processCapField() { - u32 field = mCap.getField(); + uint32_t field = mCap.getField(); mHandleTableSize = field & kMaxHandleTableSize; } }; diff --git a/lib/libnx/include/nx/HandleTableSizeHandler.h b/lib/libnx/include/nx/HandleTableSizeHandler.h index adbaca2..8beb3de 100644 --- a/lib/libnx/include/nx/HandleTableSizeHandler.h +++ b/lib/libnx/include/nx/HandleTableSizeHandler.h @@ -21,8 +21,8 @@ namespace nx bool isSet() const; // variables - u16 getHandleTableSize() const; - void setHandleTableSize(u16 size); + uint16_t getHandleTableSize() const; + void setHandleTableSize(uint16_t size); private: const std::string kModuleName = "HANDLE_TABLE_SIZE_HANDLER"; diff --git a/lib/libnx/include/nx/InteruptEntry.h b/lib/libnx/include/nx/InteruptEntry.h index c6ebbb8..9602228 100644 --- a/lib/libnx/include/nx/InteruptEntry.h +++ b/lib/libnx/include/nx/InteruptEntry.h @@ -8,42 +8,42 @@ namespace nx class InteruptEntry { public: - static const u32 kInteruptBits = 10; - static const u32 kInteruptMax = BIT(kInteruptBits) - 1; - static const u32 kInteruptNum = 2; + static const uint32_t kInteruptBits = 10; + static const uint32_t kInteruptMax = BIT(kInteruptBits) - 1; + static const uint32_t kInteruptNum = 2; InteruptEntry(); InteruptEntry(const KernelCapability& kernel_cap); - InteruptEntry(u32 interupt0, u32 interupt1); + InteruptEntry(uint32_t interupt0, uint32_t interupt1); // kernel capability const KernelCapability& getKernelCapability() const; void setKernelCapability(const KernelCapability& kernel_cap); // variables - u32 operator[](size_t index) const; + uint32_t operator[](size_t index) const; - u32 getInterupt(size_t index) const; - void setInterupt(size_t index, u32 interupt); + uint32_t getInterupt(size_t index) const; + void setInterupt(size_t index, uint32_t interupt); private: const std::string kModuleName = "INTERUPT_ENTRY"; static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_ENABLE_INTERUPTS; KernelCapability mCap; - u32 mInterupt[kInteruptNum]; + uint32_t mInterupt[kInteruptNum]; inline void updateCapField() { - u32 field = 0; - field |= (u32)(mInterupt[0] & kInteruptMax) << 0; - field |= (u32)(mInterupt[1] & kInteruptMax) << kInteruptBits; + uint32_t field = 0; + field |= (uint32_t)(mInterupt[0] & kInteruptMax) << 0; + field |= (uint32_t)(mInterupt[1] & kInteruptMax) << kInteruptBits; mCap.setField(field); } inline void processCapField() { - u32 field = mCap.getField(); + uint32_t field = mCap.getField(); mInterupt[0] = (field >> 0) & kInteruptMax; mInterupt[1] = (field >> kInteruptBits) & kInteruptMax; } diff --git a/lib/libnx/include/nx/InteruptHandler.h b/lib/libnx/include/nx/InteruptHandler.h index 1700954..19af059 100644 --- a/lib/libnx/include/nx/InteruptHandler.h +++ b/lib/libnx/include/nx/InteruptHandler.h @@ -21,14 +21,14 @@ namespace nx bool isSet() const; // variables - const fnd::List& getInteruptList() const; - void setInteruptList(const fnd::List& interupts); + const fnd::List& getInteruptList() const; + void setInteruptList(const fnd::List& interupts); private: const std::string kModuleName = "INTERUPT_HANDLER"; bool mIsSet; - fnd::List mInterupts; + fnd::List mInterupts; void copyFrom(const InteruptHandler& other); bool isEqual(const InteruptHandler& other) const; diff --git a/lib/libnx/include/nx/KcBinary.h b/lib/libnx/include/nx/KcBinary.h index 47780cb..ca2ad3a 100644 --- a/lib/libnx/include/nx/KcBinary.h +++ b/lib/libnx/include/nx/KcBinary.h @@ -21,19 +21,19 @@ namespace nx public: KcBinary(); KcBinary(const KcBinary& other); - KcBinary(const u8* bytes, size_t len); + KcBinary(const byte_t* bytes, size_t len); bool operator==(const KcBinary& other) const; bool operator!=(const KcBinary& other) const; void operator=(const KcBinary& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary void exportBinary(); - void importBinary(const u8* bytes, size_t len); + void importBinary(const byte_t* bytes, size_t len); // variables (consider further abstraction?) void clear(); diff --git a/lib/libnx/include/nx/KernelCapability.h b/lib/libnx/include/nx/KernelCapability.h index 55c0020..af35353 100644 --- a/lib/libnx/include/nx/KernelCapability.h +++ b/lib/libnx/include/nx/KernelCapability.h @@ -22,32 +22,32 @@ namespace nx KernelCapability(); KernelCapability(KernelCapId type); - KernelCapability(KernelCapId type, u32 field); + KernelCapability(KernelCapId type, uint32_t field); const KernelCapability& operator=(const KernelCapability& other); bool operator==(const KernelCapability& other) const; bool operator!=(const KernelCapability& other) const; - u32 getCap() const; - void setCap(u32 cap); + uint32_t getCap() const; + void setCap(uint32_t cap); KernelCapId getType() const; void setType(KernelCapId type); - u32 getField() const; - void setField(u32 field); + uint32_t getField() const; + void setField(uint32_t field); private: KernelCapId mType; - u32 mField; + uint32_t mField; - inline u32 getFieldShift() const { return mType + 1; } - inline u32 getFieldMask() const { return BIT(31 - mType) - 1; } - inline u32 getCapMask() const { return BIT(mType) - 1; } - inline KernelCapId getCapId(u32 cap) const + inline uint32_t getFieldShift() const { return mType + 1; } + inline uint32_t getFieldMask() const { return BIT(31 - mType) - 1; } + inline uint32_t getCapMask() const { return BIT(mType) - 1; } + inline KernelCapId getCapId(uint32_t cap) const { KernelCapId id = KC_INVALID; - for (u8 tmp = 0; tmp < 31; tmp++) + for (byte_t tmp = 0; tmp < 31; tmp++) { if (((cap >> tmp) & 1) == 0) { diff --git a/lib/libnx/include/nx/KernelVersionEntry.h b/lib/libnx/include/nx/KernelVersionEntry.h index c5cbb89..b01597e 100644 --- a/lib/libnx/include/nx/KernelVersionEntry.h +++ b/lib/libnx/include/nx/KernelVersionEntry.h @@ -10,40 +10,40 @@ namespace nx public: KernelVersionEntry(); KernelVersionEntry(const KernelCapability& kernel_cap); - KernelVersionEntry(u16 major, u8 minor); + KernelVersionEntry(uint16_t major, uint8_t minor); // kernel capability const KernelCapability& getKernelCapability() const; void setKernelCapability(const KernelCapability& kernel_cap); // variables - u16 getVerMajor() const; - void setVerMajor(u16 major); - u8 getVerMinor() const; - void setVerMinor(u8 minor); + uint16_t getVerMajor() const; + void setVerMajor(uint16_t major); + uint8_t getVerMinor() const; + void setVerMinor(uint8_t minor); private: const std::string kModuleName = "KERNEL_VERSION_ENTRY"; static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_KERNEL_VERSION; - static const u32 kVerMajorBits = 13; - static const u32 kVerMajorMax = BIT(kVerMajorBits) - 1; - static const u32 kVerMinorBits = 4; - static const u32 kVerMinorMax = BIT(kVerMinorBits) - 1; + static const uint32_t kVerMajorBits = 13; + static const uint32_t kVerMajorMax = BIT(kVerMajorBits) - 1; + static const uint32_t kVerMinorBits = 4; + static const uint32_t kVerMinorMax = BIT(kVerMinorBits) - 1; KernelCapability mCap; - u16 mVerMajor; - u8 mVerMinor; + uint16_t mVerMajor; + uint8_t mVerMinor; inline void updateCapField() { - u32 field = 0; - field |= (u32)(mVerMinor & kVerMinorMax) << 0; - field |= (u32)(mVerMajor & kVerMajorMax) << kVerMinorBits; + uint32_t field = 0; + field |= (uint32_t)(mVerMinor & kVerMinorMax) << 0; + field |= (uint32_t)(mVerMajor & kVerMajorMax) << kVerMinorBits; mCap.setField(field); } inline void processCapField() { - u32 field = mCap.getField(); + uint32_t field = mCap.getField(); mVerMinor = (field >> 0) & kVerMinorMax; mVerMajor = (field >> kVerMinorBits) & kVerMajorMax; } diff --git a/lib/libnx/include/nx/KernelVersionHandler.h b/lib/libnx/include/nx/KernelVersionHandler.h index 804d342..003c060 100644 --- a/lib/libnx/include/nx/KernelVersionHandler.h +++ b/lib/libnx/include/nx/KernelVersionHandler.h @@ -21,10 +21,10 @@ namespace nx bool isSet() const; // variables - u16 getVerMajor() const; - void setVerMajor(u16 major); - u8 getVerMinor() const; - void setVerMinor(u8 minor); + uint16_t getVerMajor() const; + void setVerMajor(uint16_t major); + uint8_t getVerMinor() const; + void setVerMinor(uint8_t minor); private: const std::string kModuleName = "KERNEL_VERSION_HANDLER"; diff --git a/lib/libnx/include/nx/MemoryMappingHandler.h b/lib/libnx/include/nx/MemoryMappingHandler.h index 0eb23c4..49f055b 100644 --- a/lib/libnx/include/nx/MemoryMappingHandler.h +++ b/lib/libnx/include/nx/MemoryMappingHandler.h @@ -21,8 +21,8 @@ namespace nx struct sMemoryMapping { - u32 addr; // page index - u32 size; // page num + uint32_t addr; // page index + uint32_t size; // page num MemoryPerm perm; MappingType type; @@ -67,8 +67,8 @@ namespace nx private: const std::string kModuleName = "MEMORY_MAPPING_HANDLER"; - static const u32 kMaxPageAddr = BIT(24) - 1; - static const u32 kMaxPageNum = BIT(20) - 1; + static const uint32_t kMaxPageAddr = BIT(24) - 1; + static const uint32_t kMaxPageNum = BIT(20) - 1; bool mIsSet; fnd::List mMemRange; diff --git a/lib/libnx/include/nx/MemoryPageEntry.h b/lib/libnx/include/nx/MemoryPageEntry.h index 8e99ffc..6beb9d6 100644 --- a/lib/libnx/include/nx/MemoryPageEntry.h +++ b/lib/libnx/include/nx/MemoryPageEntry.h @@ -10,16 +10,16 @@ namespace nx public: MemoryPageEntry(); MemoryPageEntry(const KernelCapability& kernel_cap); - MemoryPageEntry(u32 page); - MemoryPageEntry(u32 page, bool flag); + MemoryPageEntry(uint32_t page); + MemoryPageEntry(uint32_t page, bool flag); // kernel capability const KernelCapability& getKernelCapability() const; void setKernelCapability(const KernelCapability& kernel_cap); // variables - u32 getPage() const; - void setPage(u32 page); + uint32_t getPage() const; + void setPage(uint32_t page); bool getFlag() const; void setFlag(bool flag); @@ -27,26 +27,26 @@ namespace nx void setMapMultiplePages(bool useFlag); private: const std::string kModuleName = "MEMORY_PAGE_ENTRY"; - static const u32 kPageBits = 24; - static const u32 kMaxPage = BIT(kPageBits) - 1; + static const uint32_t kPageBits = 24; + static const uint32_t kMaxPage = BIT(kPageBits) - 1; KernelCapability mCap; - u32 mPage; + uint32_t mPage; bool mFlag; bool mUseFlag; inline void updateCapField() { - u32 field = 0; - field |= (u32)(mPage & kMaxPage) << 0; - field |= (u32)(mFlag) << kPageBits; + uint32_t field = 0; + field |= (uint32_t)(mPage & kMaxPage) << 0; + field |= (uint32_t)(mFlag) << kPageBits; mCap.setField(field); mCap.setType(mUseFlag ? KernelCapability::KC_MEMORY_MAP : KernelCapability::KC_IO_MEMORY_MAP); } inline void processCapField() { - u32 field = mCap.getField(); + uint32_t field = mCap.getField(); mPage = (field >> 0) & kMaxPage; mFlag = (field >> kPageBits); mUseFlag = mCap.getType() == KernelCapability::KC_MEMORY_MAP; diff --git a/lib/libnx/include/nx/MiscFlagsEntry.h b/lib/libnx/include/nx/MiscFlagsEntry.h index 0d541a6..813b7c7 100644 --- a/lib/libnx/include/nx/MiscFlagsEntry.h +++ b/lib/libnx/include/nx/MiscFlagsEntry.h @@ -10,33 +10,33 @@ namespace nx public: MiscFlagsEntry(); MiscFlagsEntry(const KernelCapability& kernel_cap); - MiscFlagsEntry(u32 flags); + MiscFlagsEntry(uint32_t flags); // kernel capability const KernelCapability& getKernelCapability() const; void setKernelCapability(const KernelCapability& kernel_cap); // variables - u32 getFlags() const; - void setFlags(u32 flags); + uint32_t getFlags() const; + void setFlags(uint32_t flags); private: const std::string kModuleName = "MISC_FLAG_ENTRY"; static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_MISC_FLAGS; - static const u32 kValueBits = 15; - static const u32 kMaxVal = BIT(kValueBits)-1; + static const uint32_t kValueBits = 15; + static const uint32_t kMaxVal = BIT(kValueBits)-1; KernelCapability mCap; - u32 mFlags; + uint32_t mFlags; inline void updateCapField() { - u32 field = mFlags & kMaxVal; + uint32_t field = mFlags & kMaxVal; mCap.setField(field); } inline void processCapField() { - u32 field = mCap.getField(); + uint32_t field = mCap.getField(); mFlags = field & kMaxVal; } }; diff --git a/lib/libnx/include/nx/MiscParamsEntry.h b/lib/libnx/include/nx/MiscParamsEntry.h index 4ffd591..9db0f17 100644 --- a/lib/libnx/include/nx/MiscParamsEntry.h +++ b/lib/libnx/include/nx/MiscParamsEntry.h @@ -10,33 +10,33 @@ namespace nx public: MiscParamsEntry(); MiscParamsEntry(const KernelCapability& kernel_cap); - MiscParamsEntry(u8 program_type); + MiscParamsEntry(byte_t program_type); // kernel capability const KernelCapability& getKernelCapability() const; void setKernelCapability(const KernelCapability& kernel_cap); // variables - u8 getProgramType() const; - void setProgramType(u8 type); + byte_t getProgramType() const; + void setProgramType(byte_t type); private: const std::string kModuleName = "MISC_PARAMS_ENTRY"; static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_MISC_PARAMS; - static const u8 kValBits = 3; - static const u8 kMaxProgramType = BIT(kValBits)-1; + static const byte_t kValBits = 3; + static const byte_t kMaxProgramType = BIT(kValBits)-1; KernelCapability mCap; - u8 mProgramType; + byte_t mProgramType; inline void updateCapField() { - u32 field = mProgramType & kMaxProgramType; + uint32_t field = mProgramType & kMaxProgramType; mCap.setField(field); } inline void processCapField() { - u32 field = mCap.getField(); + uint32_t field = mCap.getField(); mProgramType = field & kMaxProgramType; } }; diff --git a/lib/libnx/include/nx/MiscParamsHandler.h b/lib/libnx/include/nx/MiscParamsHandler.h index 357ac12..bf84cb6 100644 --- a/lib/libnx/include/nx/MiscParamsHandler.h +++ b/lib/libnx/include/nx/MiscParamsHandler.h @@ -21,8 +21,8 @@ namespace nx bool isSet() const; // variables - u8 getProgramType() const; - void setProgramType(u8 type); + byte_t getProgramType() const; + void setProgramType(byte_t type); private: const std::string kModuleName = "MISC_PARAMS_HANDLER"; diff --git a/lib/libnx/include/nx/NXCrypto.h b/lib/libnx/include/nx/NXCrypto.h index 608831e..9710dab 100644 --- a/lib/libnx/include/nx/NXCrypto.h +++ b/lib/libnx/include/nx/NXCrypto.h @@ -49,48 +49,48 @@ namespace crypto namespace dev { // aes128-xts keys (seem to use 512 block sizes, aka 0x200 blocks) - u8 nca_body_key[2][16] = + byte_t nca_body_key[2][16] = { { 0xE5, 0x64, 0xDB, 0xFE, 0x52, 0x93, 0x3A, 0x65, 0x3C, 0x8B, 0x5E, 0xF8, 0x2C, 0x9D, 0xF4, 0xB5 }, { 0x60, 0x7B, 0x77, 0x3E, 0x31, 0xE9, 0x6A, 0x8F, 0x8E, 0x44, 0x5C, 0x98, 0x71, 0xC0, 0x57, 0xDB }, }; - u8 nca_header_key[2][16] = + byte_t nca_header_key[2][16] = { { 0xCB, 0x9A, 0x93, 0x9F, 0x82, 0x72, 0x54, 0x4A, 0x74, 0x5D, 0x28, 0x46, 0x9D, 0xCC, 0x38, 0x12 }, { 0x06, 0x31, 0x27, 0x06, 0xAE, 0x62, 0x56, 0x8C, 0x5B, 0x7E, 0xE6, 0x9F, 0x7E, 0x01, 0x02, 0x24 }, }; // aeskey, related to m_KeyAreaEncryptionKeyList (first in list?) - u8 key_area_encryption_key_0[0x10] = { 0x3A, 0x7C, 0x3E, 0x38, 0x4A, 0x8F, 0x22, 0xFF, 0x4B, 0x21, 0x57, 0x19, 0xB7, 0x81, 0xAD, 0x0C }; + byte_t key_area_encryption_key_0[0x10] = { 0x3A, 0x7C, 0x3E, 0x38, 0x4A, 0x8F, 0x22, 0xFF, 0x4B, 0x21, 0x57, 0x19, 0xB7, 0x81, 0xAD, 0x0C }; - u8 titlekey_generate_key[0x20] = { 39, 111, 56, 188, 68, 106, 241, 86, 31, 44, 90, 111, 116, 32, 93, 197, 25, 181, 59, 188, 178, 159, 211, 175, 212, 178, 162, 4, 28, 152, 117, 126 }; + byte_t titlekey_generate_key[0x20] = { 39, 111, 56, 188, 68, 106, 241, 86, 31, 44, 90, 111, 116, 32, 93, 197, 25, 181, 59, 188, 178, 159, 211, 175, 212, 178, 162, 4, 28, 152, 117, 126 }; // aes128-cbc keys - u8 xci_header_key[16] = { 0x01, 0xc5, 0x8f, 0xe7, 0x2d, 0x13, 0x5a, 0xb2, 0x9a, 0x3f, 0x69, 0x33, 0x95, 0x74, 0xb1 }; - u8 eticket_common_key[16] = { 0x55, 0xA3, 0xF8, 0x72, 0xBD, 0xC8, 0x0C, 0x55, 0x5A, 0x65, 0x43, 0x81, 0x13, 0x9E, 0x15, 0x3B }; // lol this 3ds dev common key + byte_t xci_header_key[16] = { 0x01, 0xc5, 0x8f, 0xe7, 0x2d, 0x13, 0x5a, 0xb2, 0x9a, 0x3f, 0x69, 0x33, 0x95, 0x74, 0xb1 }; + byte_t eticket_common_key[16] = { 0x55, 0xA3, 0xF8, 0x72, 0xBD, 0xC8, 0x0C, 0x55, 0x5A, 0x65, 0x43, 0x81, 0x13, 0x9E, 0x15, 0x3B }; // lol this 3ds dev common key - u8 wii_sd_key[16] = { 0xAB, 0x01, 0xB9, 0xD8, 0xE1, 0x62, 0x2B, 0x08, 0xAF, 0xBA, 0xD8, 0x4D, 0xBF, 0xC2, 0xA5, 0x5D }; + byte_t wii_sd_key[16] = { 0xAB, 0x01, 0xB9, 0xD8, 0xE1, 0x62, 0x2B, 0x08, 0xAF, 0xBA, 0xD8, 0x4D, 0xBF, 0xC2, 0xA5, 0x5D }; } namespace prod { // encrypted with ProdNcaHeaderEncryptionKek - u8 nca_enc_header_key[2][16] = + byte_t nca_enc_header_key[2][16] = { { 0x5A, 0x3E, 0xD8, 0x4F, 0xDE, 0xC0, 0xD8, 0x26, 0x31, 0xF7, 0xE2, 0x5D, 0x19, 0x7B, 0xF5, 0xD0 }, { 0x1C, 0x9B, 0x7B, 0xFA, 0xF6, 0x28, 0x18, 0x3D, 0x71, 0xF6, 0x4D, 0x73, 0xF1, 0x50, 0xB9, 0xD2 } }; - u8 master_key_0[16] = { 0xC2, 0xCA, 0xAF, 0xF0, 0x89, 0xB9, 0xAE, 0xD5, 0x56, 0x94, 0x87, 0x60, 0x55, 0x27, 0x1C, 0x7D }; + byte_t master_key_0[16] = { 0xC2, 0xCA, 0xAF, 0xF0, 0x89, 0xB9, 0xAE, 0xD5, 0x56, 0x94, 0x87, 0x60, 0x55, 0x27, 0x1C, 0x7D }; - u8 nca_header_key[2][16] = + byte_t nca_header_key[2][16] = { { 0xAE, 0xAA, 0xB1, 0xCA, 0x08, 0xAD, 0xF9, 0xBE, 0xF1, 0x29, 0x91, 0xF3, 0x69, 0xE3, 0xC5, 0x67 }, { 0xD6, 0x88, 0x1E, 0x4E, 0x4A, 0x6A, 0x47, 0xA5, 0x1F, 0x6E, 0x48, 0x77, 0x06, 0x2D, 0x54, 0x2D } }; - u8 xci_header_key[16] = { 0x01, 0xC5, 0x8F, 0xE7, 0x00, 0x2D, 0x13, 0x5A, 0xB2, 0x9A, 0x3F, 0x69, 0x33, 0x95, 0x74, 0xB1 }; + byte_t xci_header_key[16] = { 0x01, 0xC5, 0x8F, 0xE7, 0x00, 0x2D, 0x13, 0x5A, 0xB2, 0x9A, 0x3F, 0x69, 0x33, 0x95, 0x74, 0xB1 }; } @@ -127,22 +127,22 @@ namespace crypto */ // unknown key "EncryptionKeyData" - u8 unk_rsa_key_mod[0x100] = { 0x85, 0xF8, 0x8C, 0x41, 0x8A, 0x2D, 0x96, 0xB3, 0xF3, 0x92, 0xD0, 0x6C, 0x9D, 0x90, 0x96, 0x7F, 0x1A, 0x78, 0xD8, 0x17, 0x7A, 0xB8, 0xEC, 0x0E, 0x6E, 0x10, 0x55, 0xC8, 0xCA, 0x7F, 0x18, 0xC7, 0x18, 0x94, 0x75, 0x0D, 0xBA, 0x19, 0x44, 0xDE, 0xFA, 0x93, 0xC8, 0xCB, 0x5F, 0xCA, 0x9B, 0x09, 0x3C, 0x2E, 0x2D, 0x12, 0xB2, 0xFA, 0x0B, 0xB7, 0xC0, 0xFC, 0xD4, 0x05, 0xC4, 0x2B, 0xC7, 0x9F, 0x6A, 0xAC, 0xB5, 0x80, 0xA0, 0x4E, 0x72, 0xCB, 0x8D, 0x5E, 0x85, 0x63, 0xBF, 0x99, 0x16, 0x89, 0x07, 0xFE, 0x3A, 0x09, 0xBC, 0xDF, 0x5C, 0xF3, 0x90, 0x29, 0x33, 0xFF, 0x72, 0xB5, 0x18, 0xD0, 0x08, 0xEB, 0xC3, 0x98, 0xC2, 0x4C, 0x3B, 0xF6, 0xCF, 0xCC, 0xB2, 0x71, 0xDD, 0x8E, 0xEE, 0x13, 0x88, 0x82, 0x79, 0x67, 0xC1, 0x6C, 0x3D, 0x60, 0x9C, 0x7D, 0x1D, 0x43, 0x52, 0xF1, 0x48, 0xBB, 0x5D, 0xCB, 0x39, 0xAA, 0x93, 0x8E, 0x75, 0x76, 0xBE, 0x37, 0x47, 0x9C, 0xAB, 0x2F, 0x22, 0xBF, 0xCA, 0x75, 0xC3, 0x50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256 key - u8 xci_keyarea_labledigest[0x20] = { 0xB1, 0x7B, 0x5F, 0x65, 0x0E, 0x75, 0x90, 0xED, 0xFE, 0x3A, 0xF0, 0x75, 0x0B, 0x92, 0x05, 0xB3, 0x0E, 0x7D, 0x49, 0x89, 0x24, 0xD8, 0xE3, 0x85, 0xCB, 0x40, 0xE0, 0xE7, 0xF8, 0xDE, 0xF0, 0x77 }; - u8 xci_keyarea_mod[0x100] = { 0xA6, 0x1A, 0x3F, 0x5E, 0x16, 0x94, 0x4D, 0x5F, 0x88, 0x07, 0x45, 0x92, 0x42, 0x02, 0x5C, 0xF8, 0xF8, 0x01, 0xA6, 0x8F, 0xF0, 0x77, 0x76, 0x06, 0x06, 0x4B, 0x67, 0x02, 0x35, 0x2F, 0xC2, 0xF6, 0xCD, 0x74, 0xBC, 0x57, 0x36, 0xA0, 0x61, 0x1D, 0xD6, 0x66, 0x35, 0x79, 0x6E, 0xB7, 0xFF, 0xC1, 0x05, 0xC6, 0x59, 0xD9, 0x1E, 0xC9, 0xC3, 0x1F, 0x5B, 0x17, 0xA9, 0x24, 0x46, 0xB3, 0xAB, 0x1D, 0x7B, 0x79, 0xA8, 0xF2, 0x80, 0xC8, 0x6F, 0xA7, 0x9B, 0x2D, 0xE8, 0xBF, 0x91, 0xD7, 0xD4, 0xA2, 0x07, 0x53, 0x98, 0x82, 0x7D, 0x91, 0x8A, 0x68, 0x79, 0x9B, 0xB6, 0x8F, 0xA7, 0x05, 0x7B, 0x2B, 0x6C, 0x09, 0x2A, 0x58, 0x8A, 0x21, 0xE5, 0xB6, 0xCD, 0xAC, 0xCB, 0x84, 0x5F, 0x22, 0x16, 0x82, 0x54, 0x14, 0x03, 0xEB, 0xBB, 0x86, 0xEC, 0x59, 0x36, 0x38, 0xF8, 0x41, 0x41, 0xCA, 0x23, 0x8A, 0xF2, 0x98, 0x01, 0xAD, 0x14, 0xB6, 0x65, 0x15, 0x3B, 0x63, 0x42, 0xC1, 0x3E, 0x55, 0x8C, 0xC2, 0x38, 0x4E, 0xC0, 0x57, 0x5E, 0xFA, 0x2A, 0x2C, 0xC7, 0x9C, 0xBE, 0x5C, 0xD7, 0x56, 0x4D, 0xCF, 0x36, 0x31, 0x93, 0xD2, 0xB1, 0x0A, 0x8C, 0x7C, 0x7F, 0xFE, 0x46, 0x20, 0xE3, 0x91, 0x7C, 0x63, 0x3F, 0x24, 0x81, 0xFF, 0x4C, 0x68, 0x4F, 0xBE, 0x16, 0x68, 0x66, 0x1C, 0x90, 0xCD, 0xFE, 0x8D, 0xC5, 0x63, 0x3B, 0x2D, 0x5C, 0x25, 0x95, 0xA8, 0x4B, 0x3C, 0xAF, 0x57, 0x07, 0x84, 0x31, 0x37, 0xFA, 0x63, 0x98, 0x1B, 0xAC, 0xB2, 0x81, 0xB1, 0x29, 0x67, 0x0A, 0x31, 0x3D, 0x7E, 0x2D, 0x7F, 0xFE, 0xA5, 0x29, 0x3D, 0xBF, 0xD3, 0xCC, 0x9D, 0x73, 0x75, 0x40, 0x8B, 0x79, 0x98, 0x39, 0x8A, 0xAD, 0x90, 0x65, 0x82, 0x90, 0x09, 0xA4, 0x74, 0xA2, 0x3F, 0xEE, 0xC7, 0x75, 0x06, 0x29, 0x85 }; + byte_t xci_keyarea_labledigest[0x20] = { 0xB1, 0x7B, 0x5F, 0x65, 0x0E, 0x75, 0x90, 0xED, 0xFE, 0x3A, 0xF0, 0x75, 0x0B, 0x92, 0x05, 0xB3, 0x0E, 0x7D, 0x49, 0x89, 0x24, 0xD8, 0xE3, 0x85, 0xCB, 0x40, 0xE0, 0xE7, 0xF8, 0xDE, 0xF0, 0x77 }; + byte_t xci_keyarea_mod[0x100] = { 0xA6, 0x1A, 0x3F, 0x5E, 0x16, 0x94, 0x4D, 0x5F, 0x88, 0x07, 0x45, 0x92, 0x42, 0x02, 0x5C, 0xF8, 0xF8, 0x01, 0xA6, 0x8F, 0xF0, 0x77, 0x76, 0x06, 0x06, 0x4B, 0x67, 0x02, 0x35, 0x2F, 0x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2, 0x81, 0xB1, 0x29, 0x67, 0x0A, 0x31, 0x3D, 0x7E, 0x2D, 0x7F, 0xFE, 0xA5, 0x29, 0x3D, 0xBF, 0xD3, 0xCC, 0x9D, 0x73, 0x75, 0x40, 0x8B, 0x79, 0x98, 0x39, 0x8A, 0xAD, 0x90, 0x65, 0x82, 0x90, 0x09, 0xA4, 0x74, 0xA2, 0x3F, 0xEE, 0xC7, 0x75, 0x06, 0x29, 0x85 }; } diff --git a/lib/libnx/include/nx/NcaHeader.h b/lib/libnx/include/nx/NcaHeader.h index e1a03a8..ea2d74b 100644 --- a/lib/libnx/include/nx/NcaHeader.h +++ b/lib/libnx/include/nx/NcaHeader.h @@ -44,8 +44,8 @@ namespace nx struct sSection { - u64 offset; - u64 size; + uint64_t offset; + uint64_t size; crypto::sha::sSha256Hash hash; const sSection& operator=(const sSection& other) @@ -74,19 +74,19 @@ namespace nx NcaHeader(); NcaHeader(const NcaHeader& other); - NcaHeader(const u8* bytes, size_t len); + NcaHeader(const byte_t* bytes, size_t len); bool operator==(const NcaHeader& other) const; bool operator!=(const NcaHeader& other) const; void operator=(const NcaHeader& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary void exportBinary(); - void importBinary(const u8* bytes, size_t len); + void importBinary(const byte_t* bytes, size_t len); // variables void clear(); @@ -100,14 +100,14 @@ namespace nx void setCryptoType(byte_t type); byte_t getKaekIndex() const; void setKaekIndex(byte_t index); - u64 getNcaSize() const; - void setNcaSize(u64 size); - u64 getProgramId() const; - void setProgramId(u64 program_id); - u32 getContentIndex() const; - void setContentIndex(u32 index); - u32 getSdkAddonVersion() const; - void setSdkAddonVersion(u32 version); + uint64_t getNcaSize() const; + void setNcaSize(uint64_t size); + uint64_t getProgramId() const; + void setProgramId(uint64_t program_id); + uint32_t getContentIndex() const; + void setContentIndex(uint32_t index); + uint32_t getSdkAddonVersion() const; + void setSdkAddonVersion(uint32_t version); const fnd::List& getSections() const; void addSection(const sSection& section); const fnd::List& getEncAesKeys() const; @@ -119,7 +119,7 @@ namespace nx const std::string kNca3Sig = "NCA3"; static const size_t kSectionNum = 4; static const size_t kAesKeyNum = 4; - static const u32 kDefaultSdkAddonVersion = 721920; + static const uint32_t kDefaultSdkAddonVersion = 721920; enum ProgramPartitionId { @@ -166,15 +166,15 @@ namespace nx ContentType mContentType; byte_t mCryptoType; byte_t mKaekIndex; - u64 mNcaSize; - u64 mProgramId; - u32 mContentIndex; - u32 mSdkAddonVersion; + uint64_t mNcaSize; + uint64_t mProgramId; + uint32_t mContentIndex; + uint32_t mSdkAddonVersion; fnd::List mSections; fnd::List mEncAesKeys; - u64 blockNumToSize(u32 block_num) const; - u32 sizeToBlockNum(u64 real_size) const; + uint64_t blockNumToSize(uint32_t block_num) const; + uint32_t sizeToBlockNum(uint64_t real_size) const; bool isEqual(const NcaHeader& other) const; void copyFrom(const NcaHeader& other); }; diff --git a/lib/libnx/include/nx/NpdmBinary.h b/lib/libnx/include/nx/NpdmBinary.h index fb01c59..e6aaa35 100644 --- a/lib/libnx/include/nx/NpdmBinary.h +++ b/lib/libnx/include/nx/NpdmBinary.h @@ -15,19 +15,19 @@ namespace nx public: NpdmBinary(); NpdmBinary(const NpdmBinary& other); - NpdmBinary(const u8* bytes, size_t len); + NpdmBinary(const byte_t* bytes, size_t len); bool operator==(const NpdmBinary& other) const; bool operator!=(const NpdmBinary& other) const; void operator=(const NpdmBinary& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary void exportBinary(); - void importBinary(const u8* bytes, size_t len); + void importBinary(const byte_t* bytes, size_t len); // variables void clear(); diff --git a/lib/libnx/include/nx/NpdmHeader.h b/lib/libnx/include/nx/NpdmHeader.h index c54b0fd..bb8e383 100644 --- a/lib/libnx/include/nx/NpdmHeader.h +++ b/lib/libnx/include/nx/NpdmHeader.h @@ -48,19 +48,19 @@ namespace nx NpdmHeader(); NpdmHeader(const NpdmHeader& other); - NpdmHeader(const u8* bytes, size_t len); + NpdmHeader(const byte_t* bytes, size_t len); bool operator==(const NpdmHeader& other) const; bool operator!=(const NpdmHeader& other) const; void operator=(const NpdmHeader& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary void exportBinary(); - void importBinary(const u8* bytes, size_t len); + void importBinary(const byte_t* bytes, size_t len); // variables void clear(); @@ -72,17 +72,17 @@ namespace nx ProcAddrSpaceType getProcAddressSpaceType() const; void setProcAddressSpaceType(ProcAddrSpaceType type); - u8 getMainThreadPriority() const; - void setMainThreadPriority(u8 priority); + byte_t getMainThreadPriority() const; + void setMainThreadPriority(byte_t priority); - u8 getMainThreadCpuId() const; - void setMainThreadCpuId(u8 cpu_id); + byte_t getMainThreadCpuId() const; + void setMainThreadCpuId(byte_t cpu_id); - u32 getVersion() const; - void setVersion(u32 version); + uint32_t getVersion() const; + void setVersion(uint32_t version); - u32 getMainThreadStackSize() const; - void setMainThreadStackSize(u32 size); + uint32_t getMainThreadStackSize() const; + void setMainThreadStackSize(uint32_t size); const std::string& getName() const; void setName(const std::string& name); @@ -100,7 +100,7 @@ namespace nx const std::string kNpdmStructSig = "META"; static const size_t kNameMaxLen = 0x10; static const size_t kProductCodeMaxLen = 0x10; - static const u32 kMaxPriority = BIT(6) -1 ; + static const uint32_t kMaxPriority = BIT(6) -1 ; static const size_t kNpdmAlignSize = 0x10; @@ -108,49 +108,49 @@ namespace nx struct sNpdmHeader { private: - u8 signature_[4]; // be"META" - u8 reserved_0[8]; - u8 flags_; - u8 reserved_1; - u8 main_thread_priority_; // 0-63 inclusive - u8 main_thread_cpu_id_; - u8 reserved_2[8]; - u32 version_; - u32 main_thread_stack_size_; // default 4096 - u8 name_[kNameMaxLen]; // important - u8 product_code_[kProductCodeMaxLen]; // can be empty - u8 reserved_3[48]; + byte_t signature_[4]; // be"META" + byte_t reserved_0[8]; + byte_t flags_; + byte_t reserved_1; + byte_t main_thread_priority_; // 0-63 inclusive + byte_t main_thread_cpu_id_; + byte_t reserved_2[8]; + uint32_t version_; + uint32_t main_thread_stack_size_; // default 4096 + byte_t name_[kNameMaxLen]; // important + byte_t product_code_[kProductCodeMaxLen]; // can be empty + byte_t reserved_3[48]; // Access Control Info struct sNpdmSection { private: - u32 offset_; - u32 size_; + uint32_t offset_; + uint32_t size_; public: - u32 offset() const { return le_word(offset_); } - void set_offset(u32 offset) { offset_ = le_word(offset); } + uint32_t offset() const { return le_word(offset_); } + void set_offset(uint32_t offset) { offset_ = le_word(offset); } - u32 size() const { return le_word(size_); } - void set_size(u32 size) { size_ = le_word(size); } + uint32_t size() const { return le_word(size_); } + void set_size(uint32_t size) { size_ = le_word(size); } } aci_, acid_; public: const char* signature() const { return (const char*)signature_; } void set_signature(const char* signature) { memcpy(signature_, signature, 4); } - u8 flags() const { return flags_; } - void set_flags(u8 flags) { flags_ = flags; } + byte_t flags() const { return flags_; } + void set_flags(byte_t flags) { flags_ = flags; } - u8 main_thread_priority() const { return main_thread_priority_; } - void set_main_thread_priority(u8 priority) { main_thread_priority_ = priority; } + byte_t main_thread_priority() const { return main_thread_priority_; } + void set_main_thread_priority(byte_t priority) { main_thread_priority_ = priority; } - u8 main_thread_cpu_id() const { return main_thread_cpu_id_; } - void set_main_thread_cpu_id(u8 cpu_id) { main_thread_cpu_id_ = cpu_id; } + byte_t main_thread_cpu_id() const { return main_thread_cpu_id_; } + void set_main_thread_cpu_id(byte_t cpu_id) { main_thread_cpu_id_ = cpu_id; } - u32 version() const { return le_word(version_); } - void set_version(u32 version) { version_ = le_word(version); } + uint32_t version() const { return le_word(version_); } + void set_version(uint32_t version) { version_ = le_word(version); } - u32 main_thread_stack_size() const { return le_word(main_thread_stack_size_); } - void set_main_thread_stack_size(u32 size) { main_thread_stack_size_ = le_word(size); } + uint32_t main_thread_stack_size() const { return le_word(main_thread_stack_size_); } + void set_main_thread_stack_size(uint32_t size) { main_thread_stack_size_ = le_word(size); } const char* name() const { return (const char*)name_; } void set_name(const char* name) { strncpy((char*)name_, name, kNameMaxLen); } @@ -172,10 +172,10 @@ namespace nx // variables InstructionType mInstructionType; ProcAddrSpaceType mProcAddressSpaceType; - u8 mMainThreadPriority; - u8 mMainThreadCpuId; - u32 mVersion; - u32 mMainThreadStackSize; + byte_t mMainThreadPriority; + byte_t mMainThreadCpuId; + uint32_t mVersion; + uint32_t mMainThreadStackSize; std::string mName; std::string mProductCode; sSection mAciPos; diff --git a/lib/libnx/include/nx/PfsHeader.h b/lib/libnx/include/nx/PfsHeader.h index 1a70f4e..f2f109f 100644 --- a/lib/libnx/include/nx/PfsHeader.h +++ b/lib/libnx/include/nx/PfsHeader.h @@ -51,19 +51,19 @@ namespace nx PfsHeader(); PfsHeader(const PfsHeader& other); - PfsHeader(const u8* bytes, size_t len); + PfsHeader(const byte_t* bytes, size_t len); bool operator==(const PfsHeader& other) const; bool operator!=(const PfsHeader& other) const; void operator=(const PfsHeader& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary void exportBinary(); - void importBinary(const u8* bytes, size_t len); + void importBinary(const byte_t* bytes, size_t len); // variables void clear(); @@ -79,36 +79,16 @@ namespace nx #pragma pack (push, 1) struct sPfsFile { - private: - u64 data_offset_; - u64 size_; - u64 name_offset_; - public: - u64 offset() const { return le_dword(data_offset_); } - void set_offset(u64 offset) { data_offset_ = le_dword(offset); } - - u64 size() const { return le_dword(size_); } - void set_size(u64 size) { size_ = le_dword(size); } - - u64 name_offset() const { return le_dword(name_offset_); } - void set_name_offset(u64 offset) { name_offset_ = le_dword(offset); } + le_uint64_t data_offset; + le_uint64_t size; + le_uint64_t name_offset; }; struct sPfsHeader { - private: - u8 signature_[4]; - u32 file_num_; - u64 name_table_size_; - public: - const char* signature() const { return (const char*)signature_; } - void set_signature(const char* signature) { memcpy(signature_, signature, 4); } - - u32 file_num() const { return le_word(file_num_); } - void set_file_num(u32 file_num) { file_num_ = le_word(file_num); } - - u64 name_table_size() const { return le_dword(name_table_size_); } - void set_name_table_size(u64 size) { name_table_size_ = le_dword(size); } + char signature[4]; + le_uint32_t file_num; + le_uint64_t name_table_size; }; #pragma pack (pop) diff --git a/lib/libnx/include/nx/SacBinary.h b/lib/libnx/include/nx/SacBinary.h index b1c816e..8e8fcd8 100644 --- a/lib/libnx/include/nx/SacBinary.h +++ b/lib/libnx/include/nx/SacBinary.h @@ -14,19 +14,19 @@ namespace nx public: SacBinary(); SacBinary(const SacBinary& other); - SacBinary(const u8* bytes, size_t len); + SacBinary(const byte_t* bytes, size_t len); bool operator==(const SacBinary& other) const; bool operator!=(const SacBinary& other) const; void operator=(const SacBinary& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary void exportBinary(); - void importBinary(const u8* bytes, size_t len); + void importBinary(const byte_t* bytes, size_t len); // variables void clear(); diff --git a/lib/libnx/include/nx/SacEntry.h b/lib/libnx/include/nx/SacEntry.h index 6900a26..c6d4117 100644 --- a/lib/libnx/include/nx/SacEntry.h +++ b/lib/libnx/include/nx/SacEntry.h @@ -19,12 +19,12 @@ namespace nx void operator=(const SacEntry& other); // to be used after export - const u8* getBytes() const; + const byte_t* getBytes() const; size_t getSize() const; // export/import binary void exportBinary(); - void importBinary(const u8* bytes, size_t len); + void importBinary(const byte_t* bytes, size_t len); // variables void clear(); diff --git a/lib/libnx/include/nx/SystemCallEntry.h b/lib/libnx/include/nx/SystemCallEntry.h index 4e94229..52863c1 100644 --- a/lib/libnx/include/nx/SystemCallEntry.h +++ b/lib/libnx/include/nx/SystemCallEntry.h @@ -10,41 +10,41 @@ namespace nx public: SystemCallEntry(); SystemCallEntry(const KernelCapability& kernel_cap); - SystemCallEntry(u32 upper_bits, u32 lower_bits); + SystemCallEntry(uint32_t upper_bits, uint32_t lower_bits); // kernel capability const KernelCapability& getKernelCapability() const; void setKernelCapability(const KernelCapability& kernel_cap); // variables - u32 getSystemCallUpperBits() const; - void setSystemCallUpperBits(u32 upper_bits); - u32 getSystemCallLowerBits() const; - void setSystemCallLowerBits(u32 lower_bits); + uint32_t getSystemCallUpperBits() const; + void setSystemCallUpperBits(uint32_t upper_bits); + uint32_t getSystemCallLowerBits() const; + void setSystemCallLowerBits(uint32_t lower_bits); private: const std::string kModuleName = "SYSTEM_CALL_ENTRY"; static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_ENABLE_SYSTEM_CALLS; - static const u32 kSysCallUpperBits = 3; - static const u32 kSysCallLowerBits = 24; - static const u32 kSysCallUpperMax = BIT(kSysCallUpperBits) - 1; - static const u32 kSysCallLowerMax = BIT(kSysCallLowerBits) - 1; + static const uint32_t kSysCallUpperBits = 3; + static const uint32_t kSysCallLowerBits = 24; + static const uint32_t kSysCallUpperMax = BIT(kSysCallUpperBits) - 1; + static const uint32_t kSysCallLowerMax = BIT(kSysCallLowerBits) - 1; KernelCapability mCap; - u32 mSystemCallUpper; - u32 mSystemCallLower; + uint32_t mSystemCallUpper; + uint32_t mSystemCallLower; inline void updateCapField() { - u32 field = 0; - field |= (u32)(mSystemCallLower & kSysCallLowerMax) << 0; - field |= (u32)(mSystemCallUpper & kSysCallUpperMax) << kSysCallLowerBits; + uint32_t field = 0; + field |= (uint32_t)(mSystemCallLower & kSysCallLowerMax) << 0; + field |= (uint32_t)(mSystemCallUpper & kSysCallUpperMax) << kSysCallLowerBits; mCap.setField(field); } inline void processCapField() { - u32 field = mCap.getField(); + uint32_t field = mCap.getField(); mSystemCallLower = (field >> 0) & kSysCallLowerMax; mSystemCallUpper = (field >> kSysCallLowerBits) & kSysCallUpperMax; } diff --git a/lib/libnx/include/nx/SystemCallHandler.h b/lib/libnx/include/nx/SystemCallHandler.h index ef3d9fa..40dd878 100644 --- a/lib/libnx/include/nx/SystemCallHandler.h +++ b/lib/libnx/include/nx/SystemCallHandler.h @@ -20,16 +20,16 @@ namespace nx bool isSet() const; // variables - const fnd::List& getSystemCalls() const; - void setSystemCallList(const fnd::List& calls); + const fnd::List& getSystemCalls() const; + void setSystemCallList(const fnd::List& calls); private: const std::string kModuleName = "SYSTEM_CALL_HANDLER"; - static const u32 kMaxSystemCall = (BIT(3) * 24) - 1; + static const uint32_t kMaxSystemCall = (BIT(3) * 24) - 1; static const size_t kSyscallTotalEntryNum = (kMaxSystemCall / 24) + 1; bool mIsSet; - fnd::List mSystemCalls; + fnd::List mSystemCalls; void copyFrom(const SystemCallHandler& other); bool isEqual(const SystemCallHandler& other) const; diff --git a/lib/libnx/include/nx/ThreadInfoEntry.h b/lib/libnx/include/nx/ThreadInfoEntry.h index 98f5b4f..879e59f 100644 --- a/lib/libnx/include/nx/ThreadInfoEntry.h +++ b/lib/libnx/include/nx/ThreadInfoEntry.h @@ -10,49 +10,49 @@ namespace nx public: ThreadInfoEntry(); ThreadInfoEntry(const KernelCapability& kernel_cap); - ThreadInfoEntry(u8 min_priority, u8 max_priority, u8 min_cpu_id, u8 max_cpu_id); + ThreadInfoEntry(uint8_t min_priority, uint8_t max_priority, uint8_t min_cpu_id, uint8_t max_cpu_id); // kernel capability const KernelCapability& getKernelCapability() const; void setKernelCapability(const KernelCapability& kernel_cap); // variables - u8 getMinPriority() const; - void setMinPriority(u8 priority); - u8 getMaxPriority() const; - void setMaxPriority(u8 priority); - u8 getMinCpuId() const; - void setMinCpuId(u8 cpu_id); - u8 getMaxCpuId() const; - void setMaxCpuId(u8 cpu_id); + uint8_t getMinPriority() const; + void setMinPriority(uint8_t priority); + uint8_t getMaxPriority() const; + void setMaxPriority(uint8_t priority); + uint8_t getMinCpuId() const; + void setMinCpuId(uint8_t cpu_id); + uint8_t getMaxCpuId() const; + void setMaxCpuId(uint8_t cpu_id); private: const std::string kModuleName = "THREAD_INFO_ENTRY"; static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_THREAD_INFO; - static const u8 kValBits = 6; - static const u8 kMaxVal = BIT(kValBits)-1; - static const u8 kDefaultPriority = 6; - static const u8 kDefaultCpuId = 8; + static const uint8_t kValBits = 6; + static const uint8_t kMaxVal = BIT(kValBits)-1; + static const uint8_t kDefaultPriority = 6; + static const uint8_t kDefaultCpuId = 8; KernelCapability mCap; - u8 mMinPriority; - u8 mMaxPriority; - u8 mMinCpuId; - u8 mMaxCpuId; + uint8_t mMinPriority; + uint8_t mMaxPriority; + uint8_t mMinCpuId; + uint8_t mMaxCpuId; inline void updateCapField() { - u32 field = 0; - field |= (u32)(mMinPriority & kMaxVal) << (kValBits * 0); - field |= (u32)(mMaxPriority & kMaxVal) << (kValBits * 1); - field |= (u32)(mMinCpuId & kMaxVal) << (kValBits * 2); - field |= (u32)(mMaxCpuId & kMaxVal) << (kValBits * 3); + uint32_t field = 0; + field |= (uint32_t)(mMinPriority & kMaxVal) << (kValBits * 0); + field |= (uint32_t)(mMaxPriority & kMaxVal) << (kValBits * 1); + field |= (uint32_t)(mMinCpuId & kMaxVal) << (kValBits * 2); + field |= (uint32_t)(mMaxCpuId & kMaxVal) << (kValBits * 3); mCap.setField(field); } inline void processCapField() { - u32 field = mCap.getField(); + uint32_t field = mCap.getField(); mMinPriority = (field >> (kValBits * 0)) & kMaxVal; mMaxPriority = (field >> (kValBits * 1)) & kMaxVal; mMinCpuId = (field >> (kValBits * 2)) & kMaxVal; diff --git a/lib/libnx/include/nx/ThreadInfoHandler.h b/lib/libnx/include/nx/ThreadInfoHandler.h index ab451ce..d2bd516 100644 --- a/lib/libnx/include/nx/ThreadInfoHandler.h +++ b/lib/libnx/include/nx/ThreadInfoHandler.h @@ -21,14 +21,14 @@ namespace nx bool isSet() const; // variables - u8 getMinPriority() const; - void setMinPriority(u8 priority); - u8 getMaxPriority() const; - void setMaxPriority(u8 priority); - u8 getMinCpuId() const; - void setMinCpuId(u8 core_num); - u8 getMaxCpuId() const; - void setMaxCpuId(u8 core_num); + uint8_t getMinPriority() const; + void setMinPriority(uint8_t priority); + uint8_t getMaxPriority() const; + void setMaxPriority(uint8_t priority); + uint8_t getMinCpuId() const; + void setMinCpuId(uint8_t core_num); + uint8_t getMaxCpuId() const; + void setMaxCpuId(uint8_t core_num); private: const std::string kModuleName = "THREAD_INFO_HANDLER"; diff --git a/lib/libnx/include/nx/XciHeader.h b/lib/libnx/include/nx/XciHeader.h index a13bd55..8acc91e 100644 --- a/lib/libnx/include/nx/XciHeader.h +++ b/lib/libnx/include/nx/XciHeader.h @@ -45,45 +45,45 @@ namespace nx struct sContentMetaInfo { - u64 id; - u32 version; - u8 type; // ContentMetaType - u8 attributes; - u8 reserved[2]; + uint64_t id; + uint32_t version; + byte_t type; // ContentMetaType + byte_t attributes; + byte_t reserved[2]; }; struct sContentInfo { - u8 id[16]; - u32 size_low; - u16 size_high; - u8 type; - u8 reserved; + byte_t id[16]; + uint32_t size_low; + uint16_t size_high; + byte_t type; + byte_t reserved; }; struct sXciHeader { - u8 signature[4]; - u32 rom_area_start_page; - u32 backup_area_start_page; - u8 key_flag; // bit0-3 = KekIndex, bit4-7 = TitleKeyDecIndex - u8 rom_size; // this is an enum - u8 flags; - u8 package_id[8]; // stylised as 0x{0:x2}{1:x2}{2:x2}{3:x2}_{4:x2}{5:x2}{6:x2}{7:x2} - u32 valid_data_end_page; - u8 reserved_0[100]; - u32 sel_sec; - u32 sel_t1_key; - u32 sel_key; - u32 lim_area; - u32 fw_version[2]; // [0]=minor, [1]=major - u32 acc_ctrl_1; - u8 reserved_1[0x10]; - u32 fw_mode; - u32 cup_version; - u8 reserved_2[0x4]; - u8 upp_hash[8]; // stylised as 0x{0:x2}{1:x2}{2:x2}{3:x2}_{4:x2}{5:x2}{6:x2}{7:x2} - u64 cup_id; // cup programID? + byte_t signature[4]; + uint32_t rom_area_start_page; + uint32_t backup_area_start_page; + byte_t key_flag; // bit0-3 = KekIndex, bit4-7 = TitleKeyDecIndex + byte_t rom_size; // this is an enum + byte_t flags; + byte_t package_id[8]; // stylised as 0x{0:x2}{1:x2}{2:x2}{3:x2}_{4:x2}{5:x2}{6:x2}{7:x2} + uint32_t valid_data_end_page; + byte_t reserved_0[100]; + uint32_t sel_sec; + uint32_t sel_t1_key; + uint32_t sel_key; + uint32_t lim_area; + uint32_t fw_version[2]; // [0]=minor, [1]=major + uint32_t acc_ctrl_1; + byte_t reserved_1[0x10]; + uint32_t fw_mode; + uint32_t cup_version; + byte_t reserved_2[0x4]; + byte_t upp_hash[8]; // stylised as 0x{0:x2}{1:x2}{2:x2}{3:x2}_{4:x2}{5:x2}{6:x2}{7:x2} + uint64_t cup_id; // cup programID? }; #pragma pack (pop) diff --git a/lib/libnx/source/AciBinary.cpp b/lib/libnx/source/AciBinary.cpp index 9879127..e6c3376 100644 --- a/lib/libnx/source/AciBinary.cpp +++ b/lib/libnx/source/AciBinary.cpp @@ -12,7 +12,7 @@ nx::AciBinary::AciBinary(const AciBinary & other) copyFrom(other); } -nx::AciBinary::AciBinary(const u8 * bytes, size_t len) +nx::AciBinary::AciBinary(const byte_t * bytes, size_t len) { importBinary(bytes, len); } @@ -32,7 +32,7 @@ void nx::AciBinary::operator=(const AciBinary & other) copyFrom(other); } -const u8 * nx::AciBinary::getBytes() const +const byte_t * nx::AciBinary::getBytes() const { return mBinaryBlob.getBytes(); } @@ -69,7 +69,7 @@ void nx::AciBinary::exportBinary() memcpy(mBinaryBlob.getBytes() + getKcPos().offset, mKc.getBytes(), mKc.getSize()); } -void nx::AciBinary::importBinary(const u8 * bytes, size_t len) +void nx::AciBinary::importBinary(const byte_t * bytes, size_t len) { AciHeader::importBinary(bytes, len); diff --git a/lib/libnx/source/AciHeader.cpp b/lib/libnx/source/AciHeader.cpp index 11c7be1..ffd3ee2 100644 --- a/lib/libnx/source/AciHeader.cpp +++ b/lib/libnx/source/AciHeader.cpp @@ -48,7 +48,7 @@ AciHeader::AciHeader(const AciHeader & other) importBinary(other.getBytes(), other.getSize()); } -AciHeader::AciHeader(const u8 * bytes, size_t len) +AciHeader::AciHeader(const byte_t * bytes, size_t len) { importBinary(bytes, len); } @@ -68,7 +68,7 @@ void AciHeader::operator=(const AciHeader & other) this->importBinary(other.getBytes(), other.getSize()); } -const u8 * AciHeader::getBytes() const +const byte_t * AciHeader::getBytes() const { return mBinaryBlob.getBytes(); } @@ -105,7 +105,7 @@ void AciHeader::exportBinary() hdr->kc().set_offset(mKc.offset); hdr->kc().set_size(mKc.size); - u32 flags = 0; + uint32_t flags = 0; if (mIsProduction) flags |= BIT(0); @@ -125,7 +125,7 @@ void AciHeader::exportBinary() } } -void AciHeader::importBinary(const u8 * bytes, size_t len) +void AciHeader::importBinary(const byte_t * bytes, size_t len) { if (len < sizeof(sAciHeader)) { @@ -216,22 +216,22 @@ void nx::AciHeader::setAcidSize(size_t size) } */ -u64 nx::AciHeader::getProgramIdMin() const +uint64_t nx::AciHeader::getProgramIdMin() const { return mProgramIdMin; } -void nx::AciHeader::setProgramIdMin(u64 program_id) +void nx::AciHeader::setProgramIdMin(uint64_t program_id) { mProgramIdMin = program_id; } -u64 nx::AciHeader::getProgramIdMax() const +uint64_t nx::AciHeader::getProgramIdMax() const { return mProgramIdMax; } -void nx::AciHeader::setProgramIdMax(u64 program_id) +void nx::AciHeader::setProgramIdMax(uint64_t program_id) { mProgramIdMax = program_id; } @@ -261,12 +261,12 @@ void nx::AciHeader::setIsProduction(bool isProduction) mIsProduction = isProduction; } -u64 AciHeader::getProgramId() const +uint64_t AciHeader::getProgramId() const { return mProgramId; } -void AciHeader::setProgramId(u64 program_id) +void AciHeader::setProgramId(uint64_t program_id) { mProgramId = program_id; } diff --git a/lib/libnx/source/AcidBinary.cpp b/lib/libnx/source/AcidBinary.cpp index 7da5b09..7a4d0e0 100644 --- a/lib/libnx/source/AcidBinary.cpp +++ b/lib/libnx/source/AcidBinary.cpp @@ -12,7 +12,7 @@ nx::AcidBinary::AcidBinary(const AcidBinary & other) copyFrom(other); } -nx::AcidBinary::AcidBinary(const u8 * bytes, size_t len) +nx::AcidBinary::AcidBinary(const byte_t * bytes, size_t len) { importBinary(bytes, len); } @@ -67,7 +67,7 @@ void nx::AcidBinary::operator=(const AcidBinary & other) copyFrom(other); } -const u8 * nx::AcidBinary::getBytes() const +const byte_t * nx::AcidBinary::getBytes() const { return mBinaryBlob.getBytes(); } @@ -94,7 +94,7 @@ void nx::AcidBinary::signBinary(const crypto::rsa::sRsa2048Key & key) exportBinary(); } - u8 hash[crypto::sha::kSha256HashLen]; + byte_t hash[crypto::sha::kSha256HashLen]; crypto::sha::Sha256(mBinaryBlob.getBytes() + crypto::rsa::kRsa2048Size, mBinaryBlob.getSize() - crypto::rsa::kRsa2048Size, hash); if (crypto::rsa::pkcs::rsaSign(key, crypto::sha::HASH_SHA256, hash, mBinaryBlob.getBytes()) != 0) @@ -103,7 +103,7 @@ void nx::AcidBinary::signBinary(const crypto::rsa::sRsa2048Key & key) } } -void nx::AcidBinary::importBinary(const u8 * bytes, size_t len) +void nx::AcidBinary::importBinary(const byte_t * bytes, size_t len) { if (len <= crypto::rsa::kRsa2048Size*2) { @@ -132,7 +132,7 @@ void nx::AcidBinary::verifyBinary(const crypto::rsa::sRsa2048Key & key) throw fnd::Exception(kModuleName, "No ACID binary exists to verify"); } - u8 hash[crypto::sha::kSha256HashLen]; + byte_t hash[crypto::sha::kSha256HashLen]; crypto::sha::Sha256(mBinaryBlob.getBytes() + crypto::rsa::kRsa2048Size, mBinaryBlob.getSize() - crypto::rsa::kRsa2048Size, hash); if (crypto::rsa::pkcs::rsaVerify(key, crypto::sha::HASH_SHA256, hash, mBinaryBlob.getBytes()) != 0) diff --git a/lib/libnx/source/FacBinary.cpp b/lib/libnx/source/FacBinary.cpp index db74f68..a955591 100644 --- a/lib/libnx/source/FacBinary.cpp +++ b/lib/libnx/source/FacBinary.cpp @@ -10,7 +10,7 @@ nx::FacBinary::FacBinary(const FacBinary & other) copyFrom(other); } -nx::FacBinary::FacBinary(const u8 * bytes, size_t len) +nx::FacBinary::FacBinary(const byte_t * bytes, size_t len) { importBinary(bytes, len); } @@ -30,7 +30,7 @@ void nx::FacBinary::operator=(const FacBinary & other) copyFrom(other); } -const u8 * nx::FacBinary::getBytes() const +const byte_t * nx::FacBinary::getBytes() const { return mBinaryBlob.getBytes(); } @@ -42,27 +42,27 @@ size_t nx::FacBinary::getSize() const void nx::FacBinary::exportBinary() { - FacHeader::setContentOwnerIdSize(mContentOwnerIdList.getSize() * sizeof(u32)); - FacHeader::setSaveDataOwnerIdSize(mSaveDataOwnerIdList.getSize() * sizeof(u32)); + FacHeader::setContentOwnerIdSize(mContentOwnerIdList.getSize() * sizeof(uint32_t)); + FacHeader::setSaveDataOwnerIdSize(mSaveDataOwnerIdList.getSize() * sizeof(uint32_t)); FacHeader::exportBinary(); mBinaryBlob.alloc(getFacSize()); memcpy(mBinaryBlob.getBytes(), FacHeader::getBytes(), FacHeader::getSize()); - u32* rawContentOwnerIds = (u32*)(mBinaryBlob.getBytes() + FacHeader::getContentOwnerIdOffset()); + uint32_t* rawContentOwnerIds = (uint32_t*)(mBinaryBlob.getBytes() + FacHeader::getContentOwnerIdOffset()); for (size_t i = 0; i < mContentOwnerIdList.getSize(); i++) { rawContentOwnerIds[i] = le_word(mContentOwnerIdList[i]); } - u32* rawSaveDataOwnerIds = (u32*)(mBinaryBlob.getBytes() + FacHeader::getSaveDataOwnerIdOffset()); + uint32_t* rawSaveDataOwnerIds = (uint32_t*)(mBinaryBlob.getBytes() + FacHeader::getSaveDataOwnerIdOffset()); for (size_t i = 0; i < mSaveDataOwnerIdList.getSize(); i++) { rawSaveDataOwnerIds[i] = le_word(mSaveDataOwnerIdList[i]); } } -void nx::FacBinary::importBinary(const u8 * bytes, size_t len) +void nx::FacBinary::importBinary(const byte_t * bytes, size_t len) { clear(); FacHeader::importBinary(bytes, len); @@ -74,15 +74,15 @@ void nx::FacBinary::importBinary(const u8 * bytes, size_t len) mBinaryBlob.alloc(FacHeader::getFacSize()); memcpy(mBinaryBlob.getBytes(), bytes, mBinaryBlob.getSize()); - u32* rawContentOwnerIds = (u32*)(mBinaryBlob.getBytes() + FacHeader::getContentOwnerIdOffset()); - size_t rawContentOwnerIdNum = FacHeader::getContentOwnerIdSize() / sizeof(u32); + uint32_t* rawContentOwnerIds = (uint32_t*)(mBinaryBlob.getBytes() + FacHeader::getContentOwnerIdOffset()); + size_t rawContentOwnerIdNum = FacHeader::getContentOwnerIdSize() / sizeof(uint32_t); for (size_t i = 0; i < rawContentOwnerIdNum; i++) { mContentOwnerIdList.addElement(le_word(rawContentOwnerIds[i])); } - u32* rawSaveDataOwnerIds = (u32*)(mBinaryBlob.getBytes() + FacHeader::getSaveDataOwnerIdOffset()); - size_t rawSaveDataOwnerIdNum = FacHeader::getSaveDataOwnerIdSize() / sizeof(u32); + uint32_t* rawSaveDataOwnerIds = (uint32_t*)(mBinaryBlob.getBytes() + FacHeader::getSaveDataOwnerIdOffset()); + size_t rawSaveDataOwnerIdNum = FacHeader::getSaveDataOwnerIdSize() / sizeof(uint32_t); for (size_t i = 0; i < rawSaveDataOwnerIdNum; i++) { mSaveDataOwnerIdList.addElement(le_word(rawSaveDataOwnerIds[i])); @@ -117,22 +117,22 @@ void nx::FacBinary::clear() mSaveDataOwnerIdList.clear(); } -const fnd::List& nx::FacBinary::getContentOwnerIdList() const +const fnd::List& nx::FacBinary::getContentOwnerIdList() const { return mContentOwnerIdList; } -void nx::FacBinary::setContentOwnerIdList(const fnd::List& list) +void nx::FacBinary::setContentOwnerIdList(const fnd::List& list) { mContentOwnerIdList = list; } -const fnd::List& nx::FacBinary::getSaveDataOwnerIdList() const +const fnd::List& nx::FacBinary::getSaveDataOwnerIdList() const { return mSaveDataOwnerIdList; } -void nx::FacBinary::setSaveDataOwnerIdList(const fnd::List& list) +void nx::FacBinary::setSaveDataOwnerIdList(const fnd::List& list) { mSaveDataOwnerIdList = list; } diff --git a/lib/libnx/source/FacHeader.cpp b/lib/libnx/source/FacHeader.cpp index ffac90f..e8f939d 100644 --- a/lib/libnx/source/FacHeader.cpp +++ b/lib/libnx/source/FacHeader.cpp @@ -14,7 +14,7 @@ nx::FacHeader::FacHeader(const FacHeader & other) : copyFrom(other); } -nx::FacHeader::FacHeader(const u8 * bytes, size_t len) : +nx::FacHeader::FacHeader(const byte_t * bytes, size_t len) : mFsaRights() { importBinary(bytes, len); @@ -35,7 +35,7 @@ void nx::FacHeader::operator=(const FacHeader & other) copyFrom(other); } -const u8 * nx::FacHeader::getBytes() const +const byte_t * nx::FacHeader::getBytes() const { return mBinaryBlob.getBytes(); } @@ -54,23 +54,23 @@ void nx::FacHeader::exportBinary() { fnd::Exception(kModuleName, "Unsupported format version"); } - hdr->set_version(mVersion); + hdr->version = (mVersion); - u64 flag = 0; + uint64_t flag = 0; for (size_t i = 0; i < mFsaRights.getSize(); i++) { - flag |= BIT((u64)mFsaRights[i]); + flag |= BIT((uint64_t)mFsaRights[i]); } - hdr->set_fac_flags(flag); + hdr->fac_flags = (flag); calculateOffsets(); - hdr->content_owner_ids().set_start(mContentOwnerIdPos.offset); - hdr->content_owner_ids().set_end(mContentOwnerIdPos.offset + mContentOwnerIdPos.size); - hdr->save_data_owner_ids().set_start(mSaveDataOwnerIdPos.offset); - hdr->save_data_owner_ids().set_end(mSaveDataOwnerIdPos.offset + mSaveDataOwnerIdPos.size); + hdr->content_owner_ids.start = (mContentOwnerIdPos.offset); + hdr->content_owner_ids.end = (mContentOwnerIdPos.offset + mContentOwnerIdPos.size); + hdr->save_data_owner_ids.start = (mSaveDataOwnerIdPos.offset); + hdr->save_data_owner_ids.end = (mSaveDataOwnerIdPos.offset + mSaveDataOwnerIdPos.size); } -void nx::FacHeader::importBinary(const u8 * bytes, size_t len) +void nx::FacHeader::importBinary(const byte_t * bytes, size_t len) { if (len < sizeof(sFacHeader)) { @@ -81,24 +81,24 @@ void nx::FacHeader::importBinary(const u8 * bytes, size_t len) memcpy(mBinaryBlob.getBytes(), bytes, mBinaryBlob.getSize()); sFacHeader* hdr = (sFacHeader*)mBinaryBlob.getBytes(); - if (hdr->version() != kFacFormatVersion) + if (hdr->version.get() != kFacFormatVersion) { throw fnd::Exception(kModuleName, "Unsupported FAC format version"); } - mVersion = hdr->version(); + mVersion = hdr->version.get(); clear(); - for (u64 i = 0; i < 64; i++) + for (uint64_t i = 0; i < 64; i++) { - if ((hdr->fac_flags() >> i) & 1) + if ((hdr->fac_flags.get() >> i) & 1) { mFsaRights.addElement((FsAccessFlag)i); } } - mContentOwnerIdPos.offset = hdr->content_owner_ids().start(); - mContentOwnerIdPos.size = hdr->content_owner_ids().end() > hdr->content_owner_ids().start() ? hdr->content_owner_ids().end() - hdr->content_owner_ids().start() : 0; - mSaveDataOwnerIdPos.offset = hdr->save_data_owner_ids().start(); - mSaveDataOwnerIdPos.size = hdr->save_data_owner_ids().end() > hdr->save_data_owner_ids().start() ? hdr->save_data_owner_ids().end() - hdr->save_data_owner_ids().start() : 0; + mContentOwnerIdPos.offset = hdr->content_owner_ids.start.get(); + mContentOwnerIdPos.size = hdr->content_owner_ids.end.get() > hdr->content_owner_ids.start.get() ? hdr->content_owner_ids.end.get() - hdr->content_owner_ids.start.get() : 0; + mSaveDataOwnerIdPos.offset = hdr->save_data_owner_ids.start.get(); + mSaveDataOwnerIdPos.size = hdr->save_data_owner_ids.end.get() > hdr->save_data_owner_ids.start.get() ? hdr->save_data_owner_ids.end.get() - hdr->save_data_owner_ids.start.get() : 0; } void nx::FacHeader::clear() @@ -117,12 +117,12 @@ size_t nx::FacHeader::getFacSize() const return MAX(MAX(savedata, content), sizeof(sFacHeader)); } -u32 nx::FacHeader::getFormatVersion() const +uint32_t nx::FacHeader::getFormatVersion() const { return mVersion; } -void nx::FacHeader::setFormatVersion(u32 version) +void nx::FacHeader::setFormatVersion(uint32_t version) { mVersion = version; } diff --git a/lib/libnx/source/HandleTableSizeEntry.cpp b/lib/libnx/source/HandleTableSizeEntry.cpp index 0b99811..19a4315 100644 --- a/lib/libnx/source/HandleTableSizeEntry.cpp +++ b/lib/libnx/source/HandleTableSizeEntry.cpp @@ -14,7 +14,7 @@ nx::HandleTableSizeEntry::HandleTableSizeEntry(const KernelCapability & kernel_c setKernelCapability(kernel_cap); } -nx::HandleTableSizeEntry::HandleTableSizeEntry(u16 size) : +nx::HandleTableSizeEntry::HandleTableSizeEntry(uint16_t size) : mCap(kCapId), mHandleTableSize(0) { @@ -37,12 +37,12 @@ void nx::HandleTableSizeEntry::setKernelCapability(const KernelCapability & kern processCapField(); } -u16 nx::HandleTableSizeEntry::getHandleTableSize() const +uint16_t nx::HandleTableSizeEntry::getHandleTableSize() const { return mHandleTableSize; } -void nx::HandleTableSizeEntry::setHandleTableSize(u16 size) +void nx::HandleTableSizeEntry::setHandleTableSize(uint16_t size) { if (size > kMaxHandleTableSize) { diff --git a/lib/libnx/source/HandleTableSizeHandler.cpp b/lib/libnx/source/HandleTableSizeHandler.cpp index 96d5905..2b91a56 100644 --- a/lib/libnx/source/HandleTableSizeHandler.cpp +++ b/lib/libnx/source/HandleTableSizeHandler.cpp @@ -55,12 +55,12 @@ bool nx::HandleTableSizeHandler::isSet() const return mIsSet; } -u16 nx::HandleTableSizeHandler::getHandleTableSize() const +uint16_t nx::HandleTableSizeHandler::getHandleTableSize() const { return mEntry.getHandleTableSize(); } -void nx::HandleTableSizeHandler::setHandleTableSize(u16 size) +void nx::HandleTableSizeHandler::setHandleTableSize(uint16_t size) { mEntry.setHandleTableSize(size); mIsSet = true; diff --git a/lib/libnx/source/InteruptEntry.cpp b/lib/libnx/source/InteruptEntry.cpp index 4335d1b..ba25b62 100644 --- a/lib/libnx/source/InteruptEntry.cpp +++ b/lib/libnx/source/InteruptEntry.cpp @@ -16,7 +16,7 @@ nx::InteruptEntry::InteruptEntry(const KernelCapability & kernel_cap) : setKernelCapability(kernel_cap); } -nx::InteruptEntry::InteruptEntry(u32 interupt0, u32 interupt1) : +nx::InteruptEntry::InteruptEntry(uint32_t interupt0, uint32_t interupt1) : mCap(kCapId), mInterupt{ 0,0 } { @@ -40,17 +40,17 @@ void nx::InteruptEntry::setKernelCapability(const KernelCapability & kernel_cap) processCapField(); } -u32 nx::InteruptEntry::operator[](size_t index) const +uint32_t nx::InteruptEntry::operator[](size_t index) const { return getInterupt(index); } -u32 nx::InteruptEntry::getInterupt(size_t index) const +uint32_t nx::InteruptEntry::getInterupt(size_t index) const { return mInterupt[index % kInteruptNum]; } -void nx::InteruptEntry::setInterupt(size_t index, u32 interupt) +void nx::InteruptEntry::setInterupt(size_t index, uint32_t interupt) { if (interupt > kInteruptMax) { diff --git a/lib/libnx/source/InteruptHandler.cpp b/lib/libnx/source/InteruptHandler.cpp index 129b22c..551d52b 100644 --- a/lib/libnx/source/InteruptHandler.cpp +++ b/lib/libnx/source/InteruptHandler.cpp @@ -95,12 +95,12 @@ bool nx::InteruptHandler::isSet() const return mIsSet; } -const fnd::List& nx::InteruptHandler::getInteruptList() const +const fnd::List& nx::InteruptHandler::getInteruptList() const { return mInterupts; } -void nx::InteruptHandler::setInteruptList(const fnd::List& interupts) +void nx::InteruptHandler::setInteruptList(const fnd::List& interupts) { mInterupts.clear(); for (size_t i = 0; i < interupts.getSize(); i++) diff --git a/lib/libnx/source/KcBinary.cpp b/lib/libnx/source/KcBinary.cpp index 6291d4b..69330fe 100644 --- a/lib/libnx/source/KcBinary.cpp +++ b/lib/libnx/source/KcBinary.cpp @@ -10,7 +10,7 @@ nx::KcBinary::KcBinary(const KcBinary & other) copyFrom(other); } -nx::KcBinary::KcBinary(const u8 * bytes, size_t len) +nx::KcBinary::KcBinary(const byte_t * bytes, size_t len) { importBinary(bytes, len); } @@ -30,7 +30,7 @@ void nx::KcBinary::operator=(const KcBinary & other) copyFrom(other); } -const u8 * nx::KcBinary::getBytes() const +const byte_t * nx::KcBinary::getBytes() const { return mBinaryBlob.getBytes(); } @@ -55,19 +55,19 @@ void nx::KcBinary::exportBinary() mMiscFlags.exportKernelCapabilityList(caps); // allocate memory - mBinaryBlob.alloc(caps.getSize() * sizeof(u32)); + mBinaryBlob.alloc(caps.getSize() * sizeof(uint32_t)); // write to binary - u32* raw_caps = (u32*)mBinaryBlob.getBytes(); + uint32_t* raw_caps = (uint32_t*)mBinaryBlob.getBytes(); for (size_t i = 0; i < caps.getSize(); i++) { raw_caps[i] = le_word(caps[i].getCap()); } } -void nx::KcBinary::importBinary(const u8 * bytes, size_t len) +void nx::KcBinary::importBinary(const byte_t * bytes, size_t len) { - if ((len % sizeof(u32)) != 0) + if ((len % sizeof(uint32_t)) != 0) { throw fnd::Exception(kModuleName, "KernelCapability list must be aligned to 4 bytes"); } @@ -81,8 +81,8 @@ void nx::KcBinary::importBinary(const u8 * bytes, size_t len) fnd::List handleTableSizeCaps; fnd::List miscFlagsCaps; - const u32* raw_caps = (const u32*)bytes; - size_t cap_num = len / sizeof(u32); + const uint32_t* raw_caps = (const uint32_t*)bytes; + size_t cap_num = len / sizeof(uint32_t); KernelCapability cap; for (size_t i = 0; i < cap_num; i++) { diff --git a/lib/libnx/source/KernelCapability.cpp b/lib/libnx/source/KernelCapability.cpp index a1b2a88..f924ce2 100644 --- a/lib/libnx/source/KernelCapability.cpp +++ b/lib/libnx/source/KernelCapability.cpp @@ -11,7 +11,7 @@ KernelCapability::KernelCapability(KernelCapId type) : mField(0) {} -KernelCapability::KernelCapability(KernelCapId type, u32 field) : +KernelCapability::KernelCapability(KernelCapId type, uint32_t field) : mType(type), mField(field) {} @@ -34,12 +34,12 @@ bool nx::KernelCapability::operator!=(const KernelCapability & other) const return !operator==(other); } -u32 KernelCapability::getCap() const +uint32_t KernelCapability::getCap() const { return (mField & getFieldMask()) << getFieldShift() | getCapMask(); } -void KernelCapability::setCap(u32 cap) +void KernelCapability::setCap(uint32_t cap) { mType = getCapId(cap); mField = (cap >> getFieldShift()) & getFieldMask(); @@ -55,12 +55,12 @@ void KernelCapability::setType(KernelCapId type) mType = type; } -u32 KernelCapability::getField() const +uint32_t KernelCapability::getField() const { return mField & getFieldMask(); } -void KernelCapability::setField(u32 field) +void KernelCapability::setField(uint32_t field) { mField = field; } diff --git a/lib/libnx/source/KernelVersionEntry.cpp b/lib/libnx/source/KernelVersionEntry.cpp index 11c3de7..69307b9 100644 --- a/lib/libnx/source/KernelVersionEntry.cpp +++ b/lib/libnx/source/KernelVersionEntry.cpp @@ -16,7 +16,7 @@ nx::KernelVersionEntry::KernelVersionEntry(const KernelCapability & kernel_cap) setKernelCapability(kernel_cap); } -nx::KernelVersionEntry::KernelVersionEntry(u16 major, u8 minor) : +nx::KernelVersionEntry::KernelVersionEntry(uint16_t major, uint8_t minor) : mCap(kCapId), mVerMajor(0), mVerMinor(0) @@ -41,12 +41,12 @@ void nx::KernelVersionEntry::setKernelCapability(const KernelCapability & kernel processCapField(); } -u16 nx::KernelVersionEntry::getVerMajor() const +uint16_t nx::KernelVersionEntry::getVerMajor() const { return mVerMajor; } -void nx::KernelVersionEntry::setVerMajor(u16 major) +void nx::KernelVersionEntry::setVerMajor(uint16_t major) { if (major > kVerMajorMax) { @@ -57,12 +57,12 @@ void nx::KernelVersionEntry::setVerMajor(u16 major) updateCapField(); } -u8 nx::KernelVersionEntry::getVerMinor() const +uint8_t nx::KernelVersionEntry::getVerMinor() const { return mVerMinor; } -void nx::KernelVersionEntry::setVerMinor(u8 minor) +void nx::KernelVersionEntry::setVerMinor(uint8_t minor) { if (minor > kVerMinorMax) { diff --git a/lib/libnx/source/KernelVersionHandler.cpp b/lib/libnx/source/KernelVersionHandler.cpp index ab1791f..aa06143 100644 --- a/lib/libnx/source/KernelVersionHandler.cpp +++ b/lib/libnx/source/KernelVersionHandler.cpp @@ -57,23 +57,23 @@ bool nx::KernelVersionHandler::isSet() const return mIsSet; } -u16 nx::KernelVersionHandler::getVerMajor() const +uint16_t nx::KernelVersionHandler::getVerMajor() const { return mEntry.getVerMajor(); } -void nx::KernelVersionHandler::setVerMajor(u16 major) +void nx::KernelVersionHandler::setVerMajor(uint16_t major) { mEntry.setVerMajor(major); mIsSet = true; } -u8 nx::KernelVersionHandler::getVerMinor() const +uint8_t nx::KernelVersionHandler::getVerMinor() const { return mEntry.getVerMinor(); } -void nx::KernelVersionHandler::setVerMinor(u8 minor) +void nx::KernelVersionHandler::setVerMinor(uint8_t minor) { mEntry.setVerMinor(minor); mIsSet = true; diff --git a/lib/libnx/source/MemoryPageEntry.cpp b/lib/libnx/source/MemoryPageEntry.cpp index 0456393..59c2788 100644 --- a/lib/libnx/source/MemoryPageEntry.cpp +++ b/lib/libnx/source/MemoryPageEntry.cpp @@ -18,7 +18,7 @@ nx::MemoryPageEntry::MemoryPageEntry(const KernelCapability & kernel_cap) : setKernelCapability(kernel_cap); } -nx::MemoryPageEntry::MemoryPageEntry(u32 page) : +nx::MemoryPageEntry::MemoryPageEntry(uint32_t page) : mCap(KernelCapability::KC_INVALID), mPage(0), mFlag(false), @@ -27,7 +27,7 @@ nx::MemoryPageEntry::MemoryPageEntry(u32 page) : setPage(page); } -nx::MemoryPageEntry::MemoryPageEntry(u32 page, bool flag) : +nx::MemoryPageEntry::MemoryPageEntry(uint32_t page, bool flag) : mCap(KernelCapability::KC_INVALID), mPage(0), mFlag(false), @@ -53,12 +53,12 @@ void nx::MemoryPageEntry::setKernelCapability(const KernelCapability & kernel_ca processCapField(); } -u32 nx::MemoryPageEntry::getPage() const +uint32_t nx::MemoryPageEntry::getPage() const { return mPage; } -void nx::MemoryPageEntry::setPage(u32 page) +void nx::MemoryPageEntry::setPage(uint32_t page) { if (page > kMaxPage) { diff --git a/lib/libnx/source/MiscFlagsEntry.cpp b/lib/libnx/source/MiscFlagsEntry.cpp index 292fd7c..d5a5b8e 100644 --- a/lib/libnx/source/MiscFlagsEntry.cpp +++ b/lib/libnx/source/MiscFlagsEntry.cpp @@ -14,7 +14,7 @@ nx::MiscFlagsEntry::MiscFlagsEntry(const KernelCapability & kernel_cap) : setKernelCapability(kernel_cap); } -nx::MiscFlagsEntry::MiscFlagsEntry(u32 flags) : +nx::MiscFlagsEntry::MiscFlagsEntry(uint32_t flags) : mCap(kCapId), mFlags(0) { @@ -37,12 +37,12 @@ void nx::MiscFlagsEntry::setKernelCapability(const KernelCapability & kernel_cap processCapField(); } -u32 nx::MiscFlagsEntry::getFlags() const +uint32_t nx::MiscFlagsEntry::getFlags() const { return mFlags; } -void nx::MiscFlagsEntry::setFlags(u32 flags) +void nx::MiscFlagsEntry::setFlags(uint32_t flags) { if ((flags & ~kMaxVal) != 0) { diff --git a/lib/libnx/source/MiscFlagsHandler.cpp b/lib/libnx/source/MiscFlagsHandler.cpp index 9e7bfb0..a38190c 100644 --- a/lib/libnx/source/MiscFlagsHandler.cpp +++ b/lib/libnx/source/MiscFlagsHandler.cpp @@ -35,7 +35,7 @@ void nx::MiscFlagsHandler::importKernelCapabilityList(const fnd::List kMaxProgramType) { diff --git a/lib/libnx/source/MiscParamsHandler.cpp b/lib/libnx/source/MiscParamsHandler.cpp index 8948974..9a66725 100644 --- a/lib/libnx/source/MiscParamsHandler.cpp +++ b/lib/libnx/source/MiscParamsHandler.cpp @@ -56,12 +56,12 @@ bool nx::MiscParamsHandler::isSet() const return mIsSet; } -u8 nx::MiscParamsHandler::getProgramType() const +uint8_t nx::MiscParamsHandler::getProgramType() const { return mEntry.getProgramType(); } -void nx::MiscParamsHandler::setProgramType(u8 type) +void nx::MiscParamsHandler::setProgramType(uint8_t type) { mEntry.setProgramType(type); mIsSet = true; diff --git a/lib/libnx/source/NcaHeader.cpp b/lib/libnx/source/NcaHeader.cpp index f60ab89..46e7227 100644 --- a/lib/libnx/source/NcaHeader.cpp +++ b/lib/libnx/source/NcaHeader.cpp @@ -35,7 +35,7 @@ void NcaHeader::exportBinary() for (size_t i = 0; i < mSections.getSize(); i++) { // determine section index - u8 section = mSections.getSize() - 1 - i; + byte_t section = mSections.getSize() - 1 - i; hdr->section[section].start = sizeToBlockNum(mSections[i].offset); hdr->section[section].end = (sizeToBlockNum(mSections[i].offset) + sizeToBlockNum(mSections[i].size)); @@ -49,7 +49,7 @@ void NcaHeader::exportBinary() } } -void NcaHeader::importBinary(const u8 * bytes, size_t len) +void NcaHeader::importBinary(const byte_t * bytes, size_t len) { if (len < sizeof(sNcaHeader)) { @@ -88,7 +88,7 @@ void NcaHeader::importBinary(const u8 * bytes, size_t len) for (size_t i = 0; i < kSectionNum; i++) { // determine section index - u8 section = kSectionNum - 1 - i; + byte_t section = kSectionNum - 1 - i; // skip sections that don't exist if (*hdr->section[section].start == 0 && *hdr->section[section].end == 0) continue; @@ -168,42 +168,42 @@ void nx::NcaHeader::setKaekIndex(byte_t index) mKaekIndex = index; } -u64 NcaHeader::getNcaSize() const +uint64_t NcaHeader::getNcaSize() const { return mNcaSize; } -void NcaHeader::setNcaSize(u64 size) +void NcaHeader::setNcaSize(uint64_t size) { mNcaSize = size; } -u64 NcaHeader::getProgramId() const +uint64_t NcaHeader::getProgramId() const { return mProgramId; } -void NcaHeader::setProgramId(u64 program_id) +void NcaHeader::setProgramId(uint64_t program_id) { mProgramId = program_id; } -u32 nx::NcaHeader::getContentIndex() const +uint32_t nx::NcaHeader::getContentIndex() const { return mContentIndex; } -void nx::NcaHeader::setContentIndex(u32 index) +void nx::NcaHeader::setContentIndex(uint32_t index) { mContentIndex = index; } -u32 nx::NcaHeader::getSdkAddonVersion() const +uint32_t nx::NcaHeader::getSdkAddonVersion() const { return mSdkAddonVersion; } -void nx::NcaHeader::setSdkAddonVersion(u32 version) +void nx::NcaHeader::setSdkAddonVersion(uint32_t version) { mSdkAddonVersion = version; } @@ -237,12 +237,12 @@ void NcaHeader::addEncAesKey(const crypto::aes::sAes128Key & key) mEncAesKeys.addElement(key); } -u64 NcaHeader::blockNumToSize(u32 block_num) const +uint64_t NcaHeader::blockNumToSize(uint32_t block_num) const { return block_num*kBlockSize; } -u32 NcaHeader::sizeToBlockNum(u64 real_size) const +uint32_t NcaHeader::sizeToBlockNum(uint64_t real_size) const { return align(real_size, kBlockSize)/kBlockSize; } @@ -293,7 +293,7 @@ NcaHeader::NcaHeader(const NcaHeader & other) copyFrom(other); } -NcaHeader::NcaHeader(const u8 * bytes, size_t len) +NcaHeader::NcaHeader(const byte_t * bytes, size_t len) { importBinary(bytes, len); } @@ -313,7 +313,7 @@ void NcaHeader::operator=(const NcaHeader & other) this->importBinary(other.getBytes(), other.getSize()); } -const u8 * NcaHeader::getBytes() const +const byte_t * NcaHeader::getBytes() const { return mBinaryBlob.getBytes(); } diff --git a/lib/libnx/source/NpdmBinary.cpp b/lib/libnx/source/NpdmBinary.cpp index 97a6e9c..acfc356 100644 --- a/lib/libnx/source/NpdmBinary.cpp +++ b/lib/libnx/source/NpdmBinary.cpp @@ -16,7 +16,7 @@ nx::NpdmBinary::NpdmBinary(const NpdmBinary & other) : copyFrom(other); } -nx::NpdmBinary::NpdmBinary(const u8 * bytes, size_t len) : +nx::NpdmBinary::NpdmBinary(const byte_t * bytes, size_t len) : mAci(), mAcid() { @@ -47,7 +47,7 @@ void nx::NpdmBinary::exportBinary() setAcidSize(mAcid.getSize()); } -void nx::NpdmBinary::importBinary(const u8 * bytes, size_t len) +void nx::NpdmBinary::importBinary(const byte_t * bytes, size_t len) { // clear clear(); @@ -125,7 +125,7 @@ void nx::NpdmBinary::copyFrom(const NpdmBinary & other) } } -const u8 * nx::NpdmBinary::getBytes() const +const byte_t * nx::NpdmBinary::getBytes() const { return mBinaryBlob.getBytes(); } diff --git a/lib/libnx/source/NpdmHeader.cpp b/lib/libnx/source/NpdmHeader.cpp index bbe9892..9519472 100644 --- a/lib/libnx/source/NpdmHeader.cpp +++ b/lib/libnx/source/NpdmHeader.cpp @@ -12,7 +12,7 @@ nx::NpdmHeader::NpdmHeader(const NpdmHeader & other) copyFrom(other); } -nx::NpdmHeader::NpdmHeader(const u8 * bytes, size_t len) +nx::NpdmHeader::NpdmHeader(const byte_t * bytes, size_t len) { importBinary(bytes, len); } @@ -32,7 +32,7 @@ void nx::NpdmHeader::operator=(const NpdmHeader & other) copyFrom(other); } -const u8 * nx::NpdmHeader::getBytes() const +const byte_t * nx::NpdmHeader::getBytes() const { return mBinaryBlob.getBytes(); } @@ -89,7 +89,7 @@ void nx::NpdmHeader::exportBinary() sNpdmHeader* hdr = (sNpdmHeader*)mBinaryBlob.getBytes(); hdr->set_signature(kNpdmStructSig.c_str()); - u8 flag = ((u8)(mInstructionType & 1) | (u8)((mProcAddressSpaceType & 3) << 1)) & 0xf; + byte_t flag = ((byte_t)(mInstructionType & 1) | (byte_t)((mProcAddressSpaceType & 3) << 1)) & 0xf; hdr->set_flags(flag); hdr->set_main_thread_priority(mMainThreadPriority); hdr->set_main_thread_cpu_id(mMainThreadCpuId); @@ -105,7 +105,7 @@ void nx::NpdmHeader::exportBinary() hdr->acid().set_size(mAcidPos.size); } -void nx::NpdmHeader::importBinary(const u8 * bytes, size_t len) +void nx::NpdmHeader::importBinary(const byte_t * bytes, size_t len) { if (len < sizeof(sNpdmHeader)) { @@ -123,7 +123,7 @@ void nx::NpdmHeader::importBinary(const u8 * bytes, size_t len) throw fnd::Exception(kModuleName, "NPDM header corrupt"); } - u8 flag = hdr->flags() & 0xf; + byte_t flag = hdr->flags() & 0xf; mInstructionType = (InstructionType)(flag & 1); mProcAddressSpaceType = (ProcAddrSpaceType)((flag >> 1) & 3); mMainThreadPriority = hdr->main_thread_priority(); @@ -188,12 +188,12 @@ void nx::NpdmHeader::setProcAddressSpaceType(ProcAddrSpaceType type) mProcAddressSpaceType = type; } -u8 nx::NpdmHeader::getMainThreadPriority() const +byte_t nx::NpdmHeader::getMainThreadPriority() const { return mMainThreadPriority; } -void nx::NpdmHeader::setMainThreadPriority(u8 priority) +void nx::NpdmHeader::setMainThreadPriority(byte_t priority) { if (priority > kMaxPriority) { @@ -203,32 +203,32 @@ void nx::NpdmHeader::setMainThreadPriority(u8 priority) mMainThreadPriority = priority; } -u8 nx::NpdmHeader::getMainThreadCpuId() const +byte_t nx::NpdmHeader::getMainThreadCpuId() const { return mMainThreadCpuId; } -void nx::NpdmHeader::setMainThreadCpuId(u8 core_num) +void nx::NpdmHeader::setMainThreadCpuId(byte_t core_num) { mMainThreadCpuId = core_num; } -u32 nx::NpdmHeader::getVersion() const +uint32_t nx::NpdmHeader::getVersion() const { return mVersion; } -void nx::NpdmHeader::setVersion(u32 version) +void nx::NpdmHeader::setVersion(uint32_t version) { mVersion = version; } -u32 nx::NpdmHeader::getMainThreadStackSize() const +uint32_t nx::NpdmHeader::getMainThreadStackSize() const { return mMainThreadStackSize; } -void nx::NpdmHeader::setMainThreadStackSize(u32 size) +void nx::NpdmHeader::setMainThreadStackSize(uint32_t size) { mMainThreadStackSize = size; } diff --git a/lib/libnx/source/PfsHeader.cpp b/lib/libnx/source/PfsHeader.cpp index 53b4a0e..adade27 100644 --- a/lib/libnx/source/PfsHeader.cpp +++ b/lib/libnx/source/PfsHeader.cpp @@ -10,7 +10,7 @@ nx::PfsHeader::PfsHeader(const PfsHeader & other) copyFrom(other); } -nx::PfsHeader::PfsHeader(const u8 * bytes, size_t len) +nx::PfsHeader::PfsHeader(const byte_t * bytes, size_t len) { importBinary(bytes, len); } @@ -34,9 +34,9 @@ void nx::PfsHeader::exportBinary() sPfsHeader* hdr = (sPfsHeader*)mBinaryBlob.getBytes(); // set header fields - hdr->set_signature(kPfsStructSig.c_str()); - hdr->set_file_num(mFileList.getSize()); - hdr->set_name_table_size(name_table_size); + strncpy(hdr->signature, kPfsStructSig.c_str(), 4); + hdr->file_num = mFileList.getSize(); + hdr->name_table_size = name_table_size; // set file entries sPfsFile* raw_files = (sPfsFile*)(mBinaryBlob.getBytes() + sizeof(sPfsHeader)); @@ -46,16 +46,16 @@ void nx::PfsHeader::exportBinary() calculateOffsets(pfs_header_size); for (size_t i = 0; i < mFileList.getSize(); i++) { - raw_files[i].set_offset(mFileList[i].offset - pfs_header_size); - raw_files[i].set_size(mFileList[i].size); - raw_files[i].set_name_offset(raw_name_table_pos); + raw_files[i].data_offset = (mFileList[i].offset - pfs_header_size); + raw_files[i].size = (mFileList[i].size); + raw_files[i].name_offset = (raw_name_table_pos); strcpy(raw_name_table + raw_name_table_pos, mFileList[i].name.c_str()); raw_name_table_pos += mFileList[i].name.length() + 1; } } -void nx::PfsHeader::importBinary(const u8 * bytes, size_t len) +void nx::PfsHeader::importBinary(const byte_t * bytes, size_t len) { // check input length meets minimum size if (len < sizeof(sPfsHeader)) @@ -69,13 +69,13 @@ void nx::PfsHeader::importBinary(const u8 * bytes, size_t len) const sPfsHeader* hdr = (const sPfsHeader*)mBinaryBlob.getBytes(); // check struct signature - if (memcmp(hdr->signature(), kPfsStructSig.c_str(), 4) != 0) + if (memcmp(hdr->signature, kPfsStructSig.c_str(), 4) != 0) { throw fnd::Exception(kModuleName, "PFS header corrupt"); } // determine complete header size - size_t pfs_full_header_size = sizeof(sPfsHeader) + sizeof(sPfsFile) * hdr->file_num() + hdr->name_table_size(); + size_t pfs_full_header_size = sizeof(sPfsHeader) + sizeof(sPfsFile) * hdr->file_num.get() + hdr->name_table_size.get(); // check input length meets complete size if (len < pfs_full_header_size) @@ -93,12 +93,12 @@ void nx::PfsHeader::importBinary(const u8 * bytes, size_t len) // get pointers to raw data const sPfsFile* raw_files = (const sPfsFile*)(mBinaryBlob.getBytes() + sizeof(sPfsHeader)); - const char* raw_name_table = (const char*)(mBinaryBlob.getBytes() + sizeof(sPfsHeader) + sizeof(sPfsFile) * hdr->file_num()); + const char* raw_name_table = (const char*)(mBinaryBlob.getBytes() + sizeof(sPfsHeader) + sizeof(sPfsFile) * hdr->file_num.get()); // process file entries - for (size_t i = 0; i < hdr->file_num(); i++) + for (size_t i = 0; i < hdr->file_num.get(); i++) { - mFileList.addElement({ std::string(raw_name_table + raw_files[i].name_offset()), raw_files[i].offset() + pfs_full_header_size, raw_files[i].size() }); + mFileList.addElement({ std::string(raw_name_table + raw_files[i].name_offset.get()), raw_files[i].data_offset.get() + pfs_full_header_size, raw_files[i].size.get() }); } } @@ -159,7 +159,7 @@ void nx::PfsHeader::operator=(const PfsHeader & other) copyFrom(other); } -const u8 * nx::PfsHeader::getBytes() const +const byte_t * nx::PfsHeader::getBytes() const { return mBinaryBlob.getBytes(); } diff --git a/lib/libnx/source/SacBinary.cpp b/lib/libnx/source/SacBinary.cpp index 5ec9d2a..81efb30 100644 --- a/lib/libnx/source/SacBinary.cpp +++ b/lib/libnx/source/SacBinary.cpp @@ -11,7 +11,7 @@ SacBinary::SacBinary(const SacBinary & other) copyFrom(other); } -SacBinary::SacBinary(const u8 * bytes, size_t len) +SacBinary::SacBinary(const byte_t * bytes, size_t len) { importBinary(bytes, len); } @@ -31,7 +31,7 @@ void SacBinary::operator=(const SacBinary & other) copyFrom(other); } -const u8 * SacBinary::getBytes() const +const byte_t * SacBinary::getBytes() const { return mBinaryBlob.getBytes(); } @@ -57,7 +57,7 @@ void SacBinary::exportBinary() } } -void SacBinary::importBinary(const u8 * bytes, size_t len) +void SacBinary::importBinary(const byte_t * bytes, size_t len) { clear(); mBinaryBlob.alloc(len); @@ -66,7 +66,7 @@ void SacBinary::importBinary(const u8 * bytes, size_t len) SacEntry svc; for (size_t pos = 0; pos < len; pos += mServices.atBack().getSize()) { - svc.importBinary((const u8*)(mBinaryBlob.getBytes() + pos), len - pos); + svc.importBinary((const byte_t*)(mBinaryBlob.getBytes() + pos), len - pos); mServices.addElement(svc); } } diff --git a/lib/libnx/source/SacEntry.cpp b/lib/libnx/source/SacEntry.cpp index 66acc87..d6dc2d4 100644 --- a/lib/libnx/source/SacEntry.cpp +++ b/lib/libnx/source/SacEntry.cpp @@ -35,7 +35,7 @@ void SacEntry::operator=(const SacEntry & other) copyFrom(other); } -const u8 * SacEntry::getBytes() const +const byte_t * SacEntry::getBytes() const { return mBinaryBlob.getBytes(); } @@ -70,7 +70,7 @@ void SacEntry::exportBinary() memcpy(mBinaryBlob.getBytes() + 1, mName.c_str(), mName.length()); } -void SacEntry::importBinary(const u8 * bytes, size_t len) +void SacEntry::importBinary(const byte_t * bytes, size_t len) { bool isServer = (bytes[0] & SAC_IS_SERVER) == SAC_IS_SERVER; size_t nameLen = (bytes[0] & SAC_NAME_LEN_MASK) + 1; // bug? diff --git a/lib/libnx/source/SystemCallEntry.cpp b/lib/libnx/source/SystemCallEntry.cpp index a2c9861..6d0f54c 100644 --- a/lib/libnx/source/SystemCallEntry.cpp +++ b/lib/libnx/source/SystemCallEntry.cpp @@ -18,7 +18,7 @@ nx::SystemCallEntry::SystemCallEntry(const KernelCapability & kernel_cap) : setKernelCapability(kernel_cap); } -nx::SystemCallEntry::SystemCallEntry(u32 upper_bits, u32 lower_bits) : +nx::SystemCallEntry::SystemCallEntry(uint32_t upper_bits, uint32_t lower_bits) : mCap(kCapId), mSystemCallUpper(0), mSystemCallLower(0) @@ -43,12 +43,12 @@ void nx::SystemCallEntry::setKernelCapability(const KernelCapability & kernel_ca processCapField(); } -u32 nx::SystemCallEntry::getSystemCallUpperBits() const +uint32_t nx::SystemCallEntry::getSystemCallUpperBits() const { return mSystemCallUpper; } -void nx::SystemCallEntry::setSystemCallUpperBits(u32 upper_bits) +void nx::SystemCallEntry::setSystemCallUpperBits(uint32_t upper_bits) { if (upper_bits > kSysCallUpperMax) { @@ -59,12 +59,12 @@ void nx::SystemCallEntry::setSystemCallUpperBits(u32 upper_bits) updateCapField(); } -u32 nx::SystemCallEntry::getSystemCallLowerBits() const +uint32_t nx::SystemCallEntry::getSystemCallLowerBits() const { return mSystemCallLower; } -void nx::SystemCallEntry::setSystemCallLowerBits(u32 lower_bits) +void nx::SystemCallEntry::setSystemCallLowerBits(uint32_t lower_bits) { if (lower_bits > kSysCallLowerMax) { diff --git a/lib/libnx/source/SystemCallHandler.cpp b/lib/libnx/source/SystemCallHandler.cpp index 21b0b1a..d14af6c 100644 --- a/lib/libnx/source/SystemCallHandler.cpp +++ b/lib/libnx/source/SystemCallHandler.cpp @@ -29,12 +29,12 @@ void nx::SystemCallHandler::importKernelCapabilityList(const fnd::List> j) & 1) == 1) @@ -90,12 +90,12 @@ bool nx::SystemCallHandler::isSet() const return mIsSet; } -const fnd::List& nx::SystemCallHandler::getSystemCalls() const +const fnd::List& nx::SystemCallHandler::getSystemCalls() const { return mSystemCalls; } -void nx::SystemCallHandler::setSystemCallList(const fnd::List& calls) +void nx::SystemCallHandler::setSystemCallList(const fnd::List& calls) { mSystemCalls.clear(); for (size_t i = 0; i < calls.getSize(); i++) diff --git a/lib/libnx/source/ThreadInfoEntry.cpp b/lib/libnx/source/ThreadInfoEntry.cpp index b07089d..6323383 100644 --- a/lib/libnx/source/ThreadInfoEntry.cpp +++ b/lib/libnx/source/ThreadInfoEntry.cpp @@ -20,7 +20,7 @@ nx::ThreadInfoEntry::ThreadInfoEntry(const KernelCapability & kernel_cap) : setKernelCapability(kernel_cap); } -nx::ThreadInfoEntry::ThreadInfoEntry(u8 min_priority, u8 max_priority, u8 min_core_number, u8 max_core_number) : +nx::ThreadInfoEntry::ThreadInfoEntry(uint8_t min_priority, uint8_t max_priority, uint8_t min_core_number, uint8_t max_core_number) : mCap(kCapId), mMinPriority(kDefaultPriority), mMaxPriority(kDefaultPriority), @@ -49,12 +49,12 @@ void nx::ThreadInfoEntry::setKernelCapability(const KernelCapability & kernel_ca processCapField(); } -u8 nx::ThreadInfoEntry::getMinPriority() const +uint8_t nx::ThreadInfoEntry::getMinPriority() const { return mMinPriority; } -void nx::ThreadInfoEntry::setMinPriority(u8 priority) +void nx::ThreadInfoEntry::setMinPriority(uint8_t priority) { if (priority > kMaxVal) { @@ -65,12 +65,12 @@ void nx::ThreadInfoEntry::setMinPriority(u8 priority) updateCapField(); } -u8 nx::ThreadInfoEntry::getMaxPriority() const +uint8_t nx::ThreadInfoEntry::getMaxPriority() const { return mMaxPriority; } -void nx::ThreadInfoEntry::setMaxPriority(u8 priority) +void nx::ThreadInfoEntry::setMaxPriority(uint8_t priority) { if (priority > kMaxVal) { @@ -81,12 +81,12 @@ void nx::ThreadInfoEntry::setMaxPriority(u8 priority) updateCapField(); } -u8 nx::ThreadInfoEntry::getMinCpuId() const +uint8_t nx::ThreadInfoEntry::getMinCpuId() const { return mMinCpuId; } -void nx::ThreadInfoEntry::setMinCpuId(u8 core_num) +void nx::ThreadInfoEntry::setMinCpuId(uint8_t core_num) { if (core_num > kMaxVal) { @@ -97,12 +97,12 @@ void nx::ThreadInfoEntry::setMinCpuId(u8 core_num) updateCapField(); } -u8 nx::ThreadInfoEntry::getMaxCpuId() const +uint8_t nx::ThreadInfoEntry::getMaxCpuId() const { return mMaxCpuId; } -void nx::ThreadInfoEntry::setMaxCpuId(u8 core_num) +void nx::ThreadInfoEntry::setMaxCpuId(uint8_t core_num) { if (core_num > kMaxVal) { diff --git a/lib/libnx/source/ThreadInfoHandler.cpp b/lib/libnx/source/ThreadInfoHandler.cpp index 2dad8ec..f40e31a 100644 --- a/lib/libnx/source/ThreadInfoHandler.cpp +++ b/lib/libnx/source/ThreadInfoHandler.cpp @@ -58,45 +58,45 @@ bool nx::ThreadInfoHandler::isSet() const return mIsSet; } -u8 nx::ThreadInfoHandler::getMinPriority() const +uint8_t nx::ThreadInfoHandler::getMinPriority() const { return mEntry.getMinPriority(); } -void nx::ThreadInfoHandler::setMinPriority(u8 priority) +void nx::ThreadInfoHandler::setMinPriority(uint8_t priority) { mEntry.setMinPriority(priority); mIsSet = true; } -u8 nx::ThreadInfoHandler::getMaxPriority() const +uint8_t nx::ThreadInfoHandler::getMaxPriority() const { return mEntry.getMaxPriority(); } -void nx::ThreadInfoHandler::setMaxPriority(u8 priority) +void nx::ThreadInfoHandler::setMaxPriority(uint8_t priority) { mEntry.setMaxPriority(priority); mIsSet = true; } -u8 nx::ThreadInfoHandler::getMinCpuId() const +uint8_t nx::ThreadInfoHandler::getMinCpuId() const { return mEntry.getMinCpuId(); } -void nx::ThreadInfoHandler::setMinCpuId(u8 core_num) +void nx::ThreadInfoHandler::setMinCpuId(uint8_t core_num) { mEntry.setMinCpuId(core_num); mIsSet = true; } -u8 nx::ThreadInfoHandler::getMaxCpuId() const +uint8_t nx::ThreadInfoHandler::getMaxCpuId() const { return mEntry.getMaxCpuId(); } -void nx::ThreadInfoHandler::setMaxCpuId(u8 core_num) +void nx::ThreadInfoHandler::setMaxCpuId(uint8_t core_num) { mEntry.setMaxCpuId(core_num); mIsSet = true; diff --git a/programs/npdmtool/source/main.cpp b/programs/npdmtool/source/main.cpp index 8c20784..da39a3a 100644 --- a/programs/npdmtool/source/main.cpp +++ b/programs/npdmtool/source/main.cpp @@ -323,7 +323,7 @@ void displayKernelCap(const nx::KcBinary& kern) } if (kern.getSystemCalls().isSet()) { - fnd::List syscalls = kern.getSystemCalls().getSystemCalls(); + fnd::List syscalls = kern.getSystemCalls().getSystemCalls(); printf(" SystemCalls:"); printf("\n "); size_t lineLen = 0; @@ -346,19 +346,19 @@ void displayKernelCap(const nx::KcBinary& kern) printf(" MemoryMaps:\n"); for (size_t i = 0; i < maps.getSize(); i++) { - printf(" 0x%016" PRIx64 " - 0x%016" PRIx64 " (perm=%s) (type=%s)\n", (u64)maps[i].addr << 12, ((u64)(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, kMemMapPerm[maps[i].perm].c_str(), kMemMapType[maps[i].type].c_str()); } //printf(" IoMaps:\n"); for (size_t i = 0; i < ioMaps.getSize(); i++) { - printf(" 0x%016" PRIx64 " - 0x%016" PRIx64 " (perm=%s) (type=%s)\n", (u64)ioMaps[i].addr << 12, ((u64)(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, kMemMapPerm[ioMaps[i].perm].c_str(), kMemMapType[ioMaps[i].type].c_str()); } } if (kern.getInterupts().isSet()) { - fnd::List interupts = kern.getInterupts().getInteruptList(); + fnd::List interupts = kern.getInterupts().getInteruptList(); printf(" Interupts Flags:\n"); - for (u32 i = 0; i < interupts.getSize(); i++) + for (uint32_t i = 0; i < interupts.getSize(); i++) { if (i % 10 == 0) { @@ -384,7 +384,7 @@ void displayKernelCap(const nx::KcBinary& kern) fnd::List flagList = kern.getMiscFlags().getFlagList(); printf(" Misc Flags:\n"); - for (u32 i = 0; i < flagList.getSize(); i++) + for (uint32_t i = 0; i < flagList.getSize(); i++) { if (i % 10 == 0) { diff --git a/programs/tiktool/source/main.cpp b/programs/tiktool/source/main.cpp index ef1c34a..171e68d 100644 --- a/programs/tiktool/source/main.cpp +++ b/programs/tiktool/source/main.cpp @@ -27,7 +27,7 @@ const std::string kBooleanStr[2] = "TRUE" }; -u8 eticket_common_key[16] = { 0x55, 0xA3, 0xF8, 0x72, 0xBD, 0xC8, 0x0C, 0x55, 0x5A, 0x65, 0x43, 0x81, 0x13, 0x9E, 0x15, 0x3B }; // lol this 3ds dev common key +const byte_t eticket_common_key[16] = { 0x55, 0xA3, 0xF8, 0x72, 0xBD, 0xC8, 0x0C, 0x55, 0x5A, 0x65, 0x43, 0x81, 0x13, 0x9E, 0x15, 0x3B }; // lol this 3ds dev common key int main(int argc, char** argv) { @@ -53,7 +53,7 @@ int main(int argc, char** argv) printf(" CommonKeyId: %02X\n", body.getCommonKeyId()); printf(" EncData:"); size_t size = body.getTitleKeyEncType() == es::ETicketBody_V2::RSA2048 ? crypto::rsa::kRsa2048Size : crypto::aes::kAes128KeySize; - for (u32 i = 0; i < size; i++) + for (uint32_t i = 0; i < size; i++) { if (i % 16 == 0) { @@ -64,13 +64,13 @@ int main(int argc, char** argv) if (body.getTitleKeyEncType() == es::ETicketBody_V2::AES128_CBC && body.getCommonKeyId() == 0) { - u8 iv[crypto::aes::kAesBlockSize]; - u8 key[crypto::aes::kAes128KeySize]; + byte_t iv[crypto::aes::kAesBlockSize]; + byte_t key[crypto::aes::kAes128KeySize]; memcpy(iv, body.getRightsId(), crypto::aes::kAesBlockSize); crypto::aes::AesCbcDecrypt(body.getEncTitleKey(), crypto::aes::kAes128KeySize, eticket_common_key, iv, key); size = crypto::aes::kAes128KeySize; printf(" TitleKey:"); - for (u32 i = 0; i < size; i++) + for (uint32_t i = 0; i < size; i++) { if (i % 16 == 0) { @@ -86,7 +86,7 @@ int main(int argc, char** argv) printf(" SharedTitle: %s\n", kBooleanStr[body.isSharedTitle()].c_str()); printf(" AllContent: %s\n", kBooleanStr[body.allowAllContent()].c_str()); printf(" Reserved Region:"); - for (u32 i = 0; i < 8; i++) + for (uint32_t i = 0; i < 8; i++) { if (i % 16 == 0) {