mirror of
				https://github.com/jakcron/nstool.git
				synced 2025-11-04 10:34:53 +00:00 
			
		
		
		
	[ns|nxtool] Update SacBinary/SacEntry
This commit is contained in:
		
							parent
							
								
									efe0655f05
								
							
						
					
					
						commit
						65b39483dc
					
				| 
						 | 
					@ -4,7 +4,7 @@
 | 
				
			||||||
#include <fnd/ISerialisable.h>
 | 
					#include <fnd/ISerialisable.h>
 | 
				
			||||||
#include <nx/aci.h>
 | 
					#include <nx/aci.h>
 | 
				
			||||||
#include <nx/FileSystemAccessControlBinary.h>
 | 
					#include <nx/FileSystemAccessControlBinary.h>
 | 
				
			||||||
#include <nx/SacBinary.h>
 | 
					#include <nx/ServiceAccessControlBinary.h>
 | 
				
			||||||
#include <nx/KcBinary.h>
 | 
					#include <nx/KcBinary.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace nx
 | 
					namespace nx
 | 
				
			||||||
| 
						 | 
					@ -33,8 +33,8 @@ namespace nx
 | 
				
			||||||
		const nx::FileSystemAccessControlBinary& getFileSystemAccessControl() const;
 | 
							const nx::FileSystemAccessControlBinary& getFileSystemAccessControl() const;
 | 
				
			||||||
		void setFileSystemAccessControl(const FileSystemAccessControlBinary& fac);
 | 
							void setFileSystemAccessControl(const FileSystemAccessControlBinary& fac);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const nx::SacBinary& getServiceAccessControl() const;
 | 
							const nx::ServiceAccessControlBinary& getServiceAccessControl() const;
 | 
				
			||||||
		void setServiceAccessControl(const SacBinary& sac);
 | 
							void setServiceAccessControl(const ServiceAccessControlBinary& sac);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const nx::KcBinary& getKernelCapabilities() const;
 | 
							const nx::KcBinary& getKernelCapabilities() const;
 | 
				
			||||||
		void setKernelCapabilities(const KcBinary& kc);
 | 
							void setKernelCapabilities(const KcBinary& kc);
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ namespace nx
 | 
				
			||||||
		// variables
 | 
							// variables
 | 
				
			||||||
		uint64_t mProgramId;
 | 
							uint64_t mProgramId;
 | 
				
			||||||
		nx::FileSystemAccessControlBinary mFileSystemAccessControl;
 | 
							nx::FileSystemAccessControlBinary mFileSystemAccessControl;
 | 
				
			||||||
		nx::SacBinary mServiceAccessControl;
 | 
							nx::ServiceAccessControlBinary mServiceAccessControl;
 | 
				
			||||||
		nx::KcBinary mKernelCapabilities;
 | 
							nx::KcBinary mKernelCapabilities;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@
 | 
				
			||||||
#include <fnd/ISerialisable.h>
 | 
					#include <fnd/ISerialisable.h>
 | 
				
			||||||
#include <nx/aci.h>
 | 
					#include <nx/aci.h>
 | 
				
			||||||
#include <nx/FileSystemAccessControlBinary.h>
 | 
					#include <nx/FileSystemAccessControlBinary.h>
 | 
				
			||||||
#include <nx/SacBinary.h>
 | 
					#include <nx/ServiceAccessControlBinary.h>
 | 
				
			||||||
#include <nx/KcBinary.h>
 | 
					#include <nx/KcBinary.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace nx
 | 
					namespace nx
 | 
				
			||||||
| 
						 | 
					@ -66,8 +66,8 @@ namespace nx
 | 
				
			||||||
		const nx::FileSystemAccessControlBinary& getFileSystemAccessControl() const;
 | 
							const nx::FileSystemAccessControlBinary& getFileSystemAccessControl() const;
 | 
				
			||||||
		void setFileSystemAccessControl(const FileSystemAccessControlBinary& fac);
 | 
							void setFileSystemAccessControl(const FileSystemAccessControlBinary& fac);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const nx::SacBinary& getServiceAccessControl() const;
 | 
							const nx::ServiceAccessControlBinary& getServiceAccessControl() const;
 | 
				
			||||||
		void setServiceAccessControl(const SacBinary& sac);
 | 
							void setServiceAccessControl(const ServiceAccessControlBinary& sac);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const nx::KcBinary& getKernelCapabilities() const;
 | 
							const nx::KcBinary& getKernelCapabilities() const;
 | 
				
			||||||
		void setKernelCapabilities(const KcBinary& kc);
 | 
							void setKernelCapabilities(const KcBinary& kc);
 | 
				
			||||||
| 
						 | 
					@ -82,7 +82,7 @@ namespace nx
 | 
				
			||||||
		fnd::List<aci::Flag> mFlags;
 | 
							fnd::List<aci::Flag> mFlags;
 | 
				
			||||||
		sProgramIdRestrict mProgramIdRestrict;
 | 
							sProgramIdRestrict mProgramIdRestrict;
 | 
				
			||||||
		nx::FileSystemAccessControlBinary mFileSystemAccessControl;
 | 
							nx::FileSystemAccessControlBinary mFileSystemAccessControl;
 | 
				
			||||||
		nx::SacBinary mServiceAccessControl;
 | 
							nx::ServiceAccessControlBinary mServiceAccessControl;
 | 
				
			||||||
		nx::KcBinary mKernelCapabilities;
 | 
							nx::KcBinary mKernelCapabilities;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,40 +0,0 @@
 | 
				
			||||||
#pragma once
 | 
					 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
#include <vector>
 | 
					 | 
				
			||||||
#include <fnd/ISerialisable.h>
 | 
					 | 
				
			||||||
#include <fnd/List.h>
 | 
					 | 
				
			||||||
#include <nx/SacEntry.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace nx
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	class SacBinary :
 | 
					 | 
				
			||||||
		public fnd::ISerialisable
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	public:
 | 
					 | 
				
			||||||
		SacBinary();
 | 
					 | 
				
			||||||
		SacBinary(const SacBinary& other);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		void operator=(const SacBinary& other);
 | 
					 | 
				
			||||||
		bool operator==(const SacBinary& other) const;
 | 
					 | 
				
			||||||
		bool operator!=(const SacBinary& other) const;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// export/import binary
 | 
					 | 
				
			||||||
		void toBytes();
 | 
					 | 
				
			||||||
		void fromBytes(const byte_t* bytes, size_t len);
 | 
					 | 
				
			||||||
		const fnd::Vec<byte_t>& getBytes() const;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// variables
 | 
					 | 
				
			||||||
		void clear();
 | 
					 | 
				
			||||||
		const fnd::List<SacEntry>& getServiceList() const;
 | 
					 | 
				
			||||||
		void addService(const SacEntry& service);
 | 
					 | 
				
			||||||
	private:
 | 
					 | 
				
			||||||
		const std::string kModuleName = "SAC_BINARY";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// raw binary
 | 
					 | 
				
			||||||
		fnd::Vec<byte_t> mRawBinary;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// variables
 | 
					 | 
				
			||||||
		fnd::List<SacEntry> mServices;
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										40
									
								
								lib/libnx/include/nx/ServiceAccessControlBinary.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								lib/libnx/include/nx/ServiceAccessControlBinary.h
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,40 @@
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					#include <fnd/ISerialisable.h>
 | 
				
			||||||
 | 
					#include <fnd/List.h>
 | 
				
			||||||
 | 
					#include <nx/ServiceAccessControlEntry.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace nx
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						class ServiceAccessControlBinary :
 | 
				
			||||||
 | 
							public fnd::ISerialisable
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						public:
 | 
				
			||||||
 | 
							ServiceAccessControlBinary();
 | 
				
			||||||
 | 
							ServiceAccessControlBinary(const ServiceAccessControlBinary& other);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void operator=(const ServiceAccessControlBinary& other);
 | 
				
			||||||
 | 
							bool operator==(const ServiceAccessControlBinary& other) const;
 | 
				
			||||||
 | 
							bool operator!=(const ServiceAccessControlBinary& other) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// export/import binary
 | 
				
			||||||
 | 
							void toBytes();
 | 
				
			||||||
 | 
							void fromBytes(const byte_t* bytes, size_t len);
 | 
				
			||||||
 | 
							const fnd::Vec<byte_t>& getBytes() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// variables
 | 
				
			||||||
 | 
							void clear();
 | 
				
			||||||
 | 
							const fnd::List<ServiceAccessControlEntry>& getServiceList() const;
 | 
				
			||||||
 | 
							void addService(const ServiceAccessControlEntry& service);
 | 
				
			||||||
 | 
						private:
 | 
				
			||||||
 | 
							const std::string kModuleName = "SERVICE_ACCESS_CONTROL_BINARY";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// raw binary
 | 
				
			||||||
 | 
							fnd::Vec<byte_t> mRawBinary;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// variables
 | 
				
			||||||
 | 
							fnd::List<ServiceAccessControlEntry> mServices;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -5,17 +5,17 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace nx
 | 
					namespace nx
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	class SacEntry : 
 | 
						class ServiceAccessControlEntry : 
 | 
				
			||||||
		public fnd::ISerialisable
 | 
							public fnd::ISerialisable
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	public:
 | 
						public:
 | 
				
			||||||
		SacEntry();
 | 
							ServiceAccessControlEntry();
 | 
				
			||||||
		SacEntry(const std::string& name, bool isServer);
 | 
							ServiceAccessControlEntry(const std::string& name, bool isServer);
 | 
				
			||||||
		SacEntry(const SacEntry& other);
 | 
							ServiceAccessControlEntry(const ServiceAccessControlEntry& other);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void operator=(const SacEntry& other);
 | 
							void operator=(const ServiceAccessControlEntry& other);
 | 
				
			||||||
		bool operator==(const SacEntry& other) const;
 | 
							bool operator==(const ServiceAccessControlEntry& other) const;
 | 
				
			||||||
		bool operator!=(const SacEntry& other) const;
 | 
							bool operator!=(const ServiceAccessControlEntry& other) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// export/import binary
 | 
							// export/import binary
 | 
				
			||||||
		void toBytes();
 | 
							void toBytes();
 | 
				
			||||||
| 
						 | 
					@ -29,10 +29,10 @@ namespace nx
 | 
				
			||||||
		const std::string& getName() const;
 | 
							const std::string& getName() const;
 | 
				
			||||||
		void setName(const std::string& name);
 | 
							void setName(const std::string& name);
 | 
				
			||||||
	private:
 | 
						private:
 | 
				
			||||||
		const std::string kModuleName = "SAC_ENTRY";
 | 
							const std::string kModuleName = "SERVICE_ACCESS_CONTROL_ENTRY";
 | 
				
			||||||
		static const size_t kMaxServiceNameLen = 8;
 | 
							static const size_t kMaxServiceNameLen = 8;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		enum SacEntryFlag
 | 
							enum ServiceAccessControlEntryFlag
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			SAC_IS_SERVER = _BIT(7),
 | 
								SAC_IS_SERVER = _BIT(7),
 | 
				
			||||||
			SAC_NAME_LEN_MASK = _BIT(7) - 1
 | 
								SAC_NAME_LEN_MASK = _BIT(7) - 1
 | 
				
			||||||
| 
						 | 
					@ -45,7 +45,7 @@ namespace nx
 | 
				
			||||||
		bool mIsServer;
 | 
							bool mIsServer;
 | 
				
			||||||
		std::string mName;
 | 
							std::string mName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		bool isEqual(const SacEntry& other) const;
 | 
							bool isEqual(const ServiceAccessControlEntry& other) const;
 | 
				
			||||||
		void copyFrom(const SacEntry& other);
 | 
							void copyFrom(const ServiceAccessControlEntry& other);
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -151,12 +151,12 @@ void nx::AccessControlInfoBinary::setFileSystemAccessControl(const nx::FileSyste
 | 
				
			||||||
	mFileSystemAccessControl = fac;
 | 
						mFileSystemAccessControl = fac;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const nx::SacBinary& nx::AccessControlInfoBinary::getServiceAccessControl() const
 | 
					const nx::ServiceAccessControlBinary& nx::AccessControlInfoBinary::getServiceAccessControl() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return mServiceAccessControl;
 | 
						return mServiceAccessControl;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void nx::AccessControlInfoBinary::setServiceAccessControl(const nx::SacBinary& sac)
 | 
					void nx::AccessControlInfoBinary::setServiceAccessControl(const nx::ServiceAccessControlBinary& sac)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	mServiceAccessControl = sac;
 | 
						mServiceAccessControl = sac;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -229,12 +229,12 @@ void nx::AccessControlInfoDescBinary::setFileSystemAccessControl(const nx::FileS
 | 
				
			||||||
	mFileSystemAccessControl = fac;
 | 
						mFileSystemAccessControl = fac;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const nx::SacBinary& nx::AccessControlInfoDescBinary::getServiceAccessControl() const
 | 
					const nx::ServiceAccessControlBinary& nx::AccessControlInfoDescBinary::getServiceAccessControl() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return mServiceAccessControl;
 | 
						return mServiceAccessControl;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void nx::AccessControlInfoDescBinary::setServiceAccessControl(const nx::SacBinary& sac)
 | 
					void nx::AccessControlInfoDescBinary::setServiceAccessControl(const nx::ServiceAccessControlBinary& sac)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	mServiceAccessControl = sac;
 | 
						mServiceAccessControl = sac;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,85 +0,0 @@
 | 
				
			||||||
#include <nx/SacBinary.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
nx::SacBinary::SacBinary()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	clear();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
nx::SacBinary::SacBinary(const SacBinary & other)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	*this = other;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void nx::SacBinary::operator=(const SacBinary & other)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (other.getBytes().data())
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		fromBytes(other.getBytes().data(), other.getBytes().size());
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		clear();
 | 
					 | 
				
			||||||
		mServices = other.mServices;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
bool nx::SacBinary::operator==(const SacBinary & other) const
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return (mServices == other.mServices);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
bool nx::SacBinary::operator!=(const SacBinary & other) const
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return !(*this == other);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void nx::SacBinary::toBytes()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	size_t totalSize = 0;
 | 
					 | 
				
			||||||
	for (size_t i = 0; i < mServices.size(); i++)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		mServices[i].toBytes();
 | 
					 | 
				
			||||||
		totalSize += mServices[i].getBytes().size();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	mRawBinary.alloc(totalSize);
 | 
					 | 
				
			||||||
	for (size_t i = 0, pos = 0; i < mServices.size(); pos += mServices[i].getBytes().size(), i++)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		memcpy((mRawBinary.data() + pos), mServices[i].getBytes().data(), mServices[i].getBytes().size());
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void nx::SacBinary::fromBytes(const byte_t* data, size_t len)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	clear();
 | 
					 | 
				
			||||||
	mRawBinary.alloc(len);
 | 
					 | 
				
			||||||
	memcpy(mRawBinary.data(), data, mRawBinary.size());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	SacEntry sac;
 | 
					 | 
				
			||||||
	for (size_t pos = 0; pos < len; pos += mServices.atBack().getBytes().size())
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		sac.fromBytes((const byte_t*)(mRawBinary.data() + pos), len - pos);
 | 
					 | 
				
			||||||
		mServices.addElement(sac);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const fnd::Vec<byte_t>& nx::SacBinary::getBytes() const
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return mRawBinary;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void nx::SacBinary::clear()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	mRawBinary.clear();
 | 
					 | 
				
			||||||
	mServices.clear();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const fnd::List<nx::SacEntry>& nx::SacBinary::getServiceList() const
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return mServices;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void nx::SacBinary::addService(const SacEntry& service)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	mServices.addElement(service);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										78
									
								
								lib/libnx/source/ServiceAccessControlBinary.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								lib/libnx/source/ServiceAccessControlBinary.cpp
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,78 @@
 | 
				
			||||||
 | 
					#include <nx/ServiceAccessControlBinary.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					nx::ServiceAccessControlBinary::ServiceAccessControlBinary()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						clear();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					nx::ServiceAccessControlBinary::ServiceAccessControlBinary(const ServiceAccessControlBinary & other)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						*this = other;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void nx::ServiceAccessControlBinary::operator=(const ServiceAccessControlBinary & other)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						mRawBinary = other.mRawBinary;
 | 
				
			||||||
 | 
						mServices = other.mServices;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool nx::ServiceAccessControlBinary::operator==(const ServiceAccessControlBinary & other) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return (mServices == other.mServices);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool nx::ServiceAccessControlBinary::operator!=(const ServiceAccessControlBinary & other) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return !(*this == other);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void nx::ServiceAccessControlBinary::toBytes()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						size_t totalSize = 0;
 | 
				
			||||||
 | 
						for (size_t i = 0; i < mServices.size(); i++)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							mServices[i].toBytes();
 | 
				
			||||||
 | 
							totalSize += mServices[i].getBytes().size();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						mRawBinary.alloc(totalSize);
 | 
				
			||||||
 | 
						for (size_t i = 0, pos = 0; i < mServices.size(); pos += mServices[i].getBytes().size(), i++)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							memcpy((mRawBinary.data() + pos), mServices[i].getBytes().data(), mServices[i].getBytes().size());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void nx::ServiceAccessControlBinary::fromBytes(const byte_t* data, size_t len)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						clear();
 | 
				
			||||||
 | 
						mRawBinary.alloc(len);
 | 
				
			||||||
 | 
						memcpy(mRawBinary.data(), data, mRawBinary.size());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ServiceAccessControlEntry sac;
 | 
				
			||||||
 | 
						for (size_t pos = 0; pos < len; pos += mServices.atBack().getBytes().size())
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							sac.fromBytes((const byte_t*)(mRawBinary.data() + pos), len - pos);
 | 
				
			||||||
 | 
							mServices.addElement(sac);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const fnd::Vec<byte_t>& nx::ServiceAccessControlBinary::getBytes() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return mRawBinary;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void nx::ServiceAccessControlBinary::clear()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						mRawBinary.clear();
 | 
				
			||||||
 | 
						mServices.clear();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const fnd::List<nx::ServiceAccessControlEntry>& nx::ServiceAccessControlBinary::getServiceList() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return mServices;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void nx::ServiceAccessControlBinary::addService(const ServiceAccessControlEntry& service)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						mServices.addElement(service);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,23 +1,23 @@
 | 
				
			||||||
#include <nx/SacEntry.h>
 | 
					#include <nx/ServiceAccessControlEntry.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
nx::SacEntry::SacEntry()
 | 
					nx::ServiceAccessControlEntry::ServiceAccessControlEntry()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	clear();
 | 
						clear();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
nx::SacEntry::SacEntry(const std::string & name, bool isServer) :
 | 
					nx::ServiceAccessControlEntry::ServiceAccessControlEntry(const std::string & name, bool isServer) :
 | 
				
			||||||
	mIsServer(isServer),
 | 
						mIsServer(isServer),
 | 
				
			||||||
	mName(name)
 | 
						mName(name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	toBytes();
 | 
						toBytes();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
nx::SacEntry::SacEntry(const SacEntry & other)
 | 
					nx::ServiceAccessControlEntry::ServiceAccessControlEntry(const ServiceAccessControlEntry & other)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	*this = other;
 | 
						*this = other;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void nx::SacEntry::operator=(const SacEntry & other)
 | 
					void nx::ServiceAccessControlEntry::operator=(const ServiceAccessControlEntry & other)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (other.getBytes().size())
 | 
						if (other.getBytes().size())
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
| 
						 | 
					@ -31,26 +31,26 @@ void nx::SacEntry::operator=(const SacEntry & other)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool nx::SacEntry::operator==(const SacEntry & other) const
 | 
					bool nx::ServiceAccessControlEntry::operator==(const ServiceAccessControlEntry & other) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return (mIsServer == other.mIsServer) \
 | 
						return (mIsServer == other.mIsServer) \
 | 
				
			||||||
		&& (mName == other.mName);
 | 
							&& (mName == other.mName);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool nx::SacEntry::operator!=(const SacEntry & other) const
 | 
					bool nx::ServiceAccessControlEntry::operator!=(const ServiceAccessControlEntry & other) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return !(*this == other);
 | 
						return !(*this == other);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void nx::SacEntry::toBytes()
 | 
					void nx::ServiceAccessControlEntry::toBytes()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	try {
 | 
						try {
 | 
				
			||||||
		mRawBinary.alloc(mName.size() + 1);
 | 
							mRawBinary.alloc(mName.size() + 1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	catch (const fnd::Exception& e)
 | 
						catch (const fnd::Exception& e)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		throw fnd::Exception(kModuleName, "Failed to allocate memory for SacEntry: " + std::string(e.what()));
 | 
							throw fnd::Exception(kModuleName, "Failed to allocate memory for ServiceAccessControlEntry: " + std::string(e.what()));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (mName.length() == 0)
 | 
						if (mName.length() == 0)
 | 
				
			||||||
| 
						 | 
					@ -68,7 +68,7 @@ void nx::SacEntry::toBytes()
 | 
				
			||||||
	memcpy(mRawBinary.data() + 1, mName.c_str(), mName.length());
 | 
						memcpy(mRawBinary.data() + 1, mName.c_str(), mName.length());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void nx::SacEntry::fromBytes(const byte_t* data, size_t len)
 | 
					void nx::ServiceAccessControlEntry::fromBytes(const byte_t* data, size_t len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	bool isServer = (data[0] & SAC_IS_SERVER) == SAC_IS_SERVER;
 | 
						bool isServer = (data[0] & SAC_IS_SERVER) == SAC_IS_SERVER;
 | 
				
			||||||
	size_t nameLen = (data[0] & SAC_NAME_LEN_MASK) + 1; // bug?
 | 
						size_t nameLen = (data[0] & SAC_NAME_LEN_MASK) + 1; // bug?
 | 
				
			||||||
| 
						 | 
					@ -94,33 +94,33 @@ void nx::SacEntry::fromBytes(const byte_t* data, size_t len)
 | 
				
			||||||
	mName = std::string((const char*)(mRawBinary.data() + 1), nameLen);
 | 
						mName = std::string((const char*)(mRawBinary.data() + 1), nameLen);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const fnd::Vec<byte_t>& nx::SacEntry::getBytes() const
 | 
					const fnd::Vec<byte_t>& nx::ServiceAccessControlEntry::getBytes() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return mRawBinary;
 | 
						return mRawBinary;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void nx::SacEntry::clear()
 | 
					void nx::ServiceAccessControlEntry::clear()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	mIsServer = false;
 | 
						mIsServer = false;
 | 
				
			||||||
	mName.clear();
 | 
						mName.clear();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool nx::SacEntry::isServer() const
 | 
					bool nx::ServiceAccessControlEntry::isServer() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return mIsServer;
 | 
						return mIsServer;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void nx::SacEntry::setIsServer(bool isServer)
 | 
					void nx::ServiceAccessControlEntry::setIsServer(bool isServer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	mIsServer = isServer;
 | 
						mIsServer = isServer;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const std::string & nx::SacEntry::getName() const
 | 
					const std::string & nx::ServiceAccessControlEntry::getName() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return mName;
 | 
						return mName;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void nx::SacEntry::setName(const std::string & name)
 | 
					void nx::ServiceAccessControlEntry::setName(const std::string & name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (name.length() > kMaxServiceNameLen)
 | 
						if (name.length() > kMaxServiceNameLen)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
| 
						 | 
					@ -586,7 +586,7 @@ void NpdmProcess::displayFac(const nx::FileSystemAccessControlBinary& fac)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			printf("%s", kFsaFlag[fac.getFsaRightsList()[i]].c_str());
 | 
								printf("%s", kFsaFlag[fac.getFsaRightsList()[i]].c_str());
 | 
				
			||||||
			if (_HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
 | 
								if (_HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
 | 
				
			||||||
				printf(" (mask 0x%" PRIx64 ")", _BIT(fac.getFsaRightsList()[i]));
 | 
									printf(" (bit %" PRId32 ")", fac.getFsaRightsList()[i]);
 | 
				
			||||||
			printf("%s", fac.getFsaRightsList()[i] != fac.getFsaRightsList().atBack() ? ", " : "\n");
 | 
								printf("%s", fac.getFsaRightsList()[i] != fac.getFsaRightsList().atBack() ? ", " : "\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
| 
						 | 
					@ -616,7 +616,7 @@ void NpdmProcess::displayFac(const nx::FileSystemAccessControlBinary& fac)
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void NpdmProcess::displaySac(const nx::SacBinary& sac)
 | 
					void NpdmProcess::displaySac(const nx::ServiceAccessControlBinary& sac)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	printf("[Service Access Control]\n");
 | 
						printf("[Service Access Control]\n");
 | 
				
			||||||
	printf("  Service List:\n");
 | 
						printf("  Service List:\n");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,6 +39,6 @@ private:
 | 
				
			||||||
	void displayAciHdr(const nx::AccessControlInfoBinary& aci);
 | 
						void displayAciHdr(const nx::AccessControlInfoBinary& aci);
 | 
				
			||||||
	void displayAciDescHdr(const nx::AccessControlInfoDescBinary& aci);
 | 
						void displayAciDescHdr(const nx::AccessControlInfoDescBinary& aci);
 | 
				
			||||||
	void displayFac(const nx::FileSystemAccessControlBinary& fac);
 | 
						void displayFac(const nx::FileSystemAccessControlBinary& fac);
 | 
				
			||||||
	void displaySac(const nx::SacBinary& sac);
 | 
						void displaySac(const nx::ServiceAccessControlBinary& sac);
 | 
				
			||||||
	void displayKernelCap(const nx::KcBinary& kern);
 | 
						void displayKernelCap(const nx::KcBinary& kern);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
		Loading…
	
		Reference in a new issue