BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Properties | List of all members
BrawlLib.SSBB.ResourceNodes.ISOPartitionNode Class Reference
Inheritance diagram for BrawlLib.SSBB.ResourceNodes.ISOPartitionNode:
BrawlLib.SSBB.ResourceNodes.ISOEntryNode BrawlLib.SSBB.ResourceNodes.IBufferNode BrawlLib.SSBB.ResourceNodes.ResourceNode

Public Types

enum  RSAType : uint
 

Public Member Functions

 ISOPartitionNode (PartitionTableEntry entry, bool VC)
 
override bool OnInitialize ()
 
void GetDC (long nOffset, long nSize, out long decOffset, out long decSize)
 
byte[] DecryptBlock (uint block)
 
byte[] GetPartitionData (long offset, int size)
 
bool IsValid ()
 
VoidPtr GetAddress ()
 
int GetLength ()
 
- Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ISOEntryNode
ToStruct< T > (byte[] bytes)
 
Get< T > (long offset, bool relative=false)
 
UnsafeBuffer GetBuffer (long offset, int size, bool relative=false)
 
UnsafeBuffer GetBuffer (byte[] bytes)
 
byte[] GetBytes (long offset, int size, bool relative=false)
 
void Create (ISOEntryNode parent, long offset, int size, bool relativeOffset)
 
void CreateChild (ResourceNode child, long offset, int size, bool relativeOffset)
 
- Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
void OnRenamed ()
 
List< ResourceNodeGetChildrenRecursive ()
 Used primarily to get bone lists. Kept for all resource nodes for utility. More...
 
virtual void SignalPropertyChange ()
 
virtual void Dispose ()
 
void SelectChildAtIndex (int index)
 
void UpdateProperties ()
 
void UpdateCurrentControl ()
 
virtual bool MoveUp ()
 
virtual bool MoveDown ()
 
virtual void OnMoved ()
 
virtual void DoMoveDown ()
 
virtual void DoMoveDown (bool select)
 
virtual void DoMoveUp ()
 
virtual void DoMoveUp (bool select)
 
virtual bool AddUp ()
 
virtual bool AddDown ()
 
virtual bool ToParent ()
 
void Populate (int levels=-1)
 
virtual void OnPopulate ()
 
void Initialize (ResourceNode parent, FileMap source)
 
void Initialize (ResourceNode parent, VoidPtr address, int length)
 
void Initialize (ResourceNode parent, DataSource origSource)
 
virtual void Initialize (ResourceNode parent, DataSource origSource, DataSource uncompSource)
 
virtual bool OnInitialize ()
 
virtual void Restore ()
 
virtual void Remove ()
 
virtual void RemoveChild (ResourceNode child)
 
virtual void AddChild (ResourceNode child)
 
virtual void AddChild (ResourceNode child, bool change)
 
virtual void InsertChild (ResourceNode child, int index)
 
virtual void InsertChild (ResourceNode child, bool change, int index)
 
void SetSizeInternal (int size)
 
virtual void Replace (string fileName)
 
virtual void Replace (ResourceNode node)
 
virtual void Replace (string fileName, FileMapProtect prot, FileOptions options)
 
virtual void ReplaceRaw (VoidPtr address, int length)
 
virtual void ReplaceRaw (FileMap map)
 
virtual void Export (string outPath)
 
void Export (FileStream outStream)
 
virtual void ExportUncompressed (string outPath)
 
void ExportUncompressed (FileStream outStream)
 
virtual void Rebuild ()
 
virtual void Rebuild (bool force)
 
virtual void Rebuild (VoidPtr address, int length, bool force)
 
virtual void OnRebuild (VoidPtr address, int length, bool force)
 
virtual int CalculateSize (bool force)
 
virtual int OnCalculateSize (bool force)
 
void Merge ()
 
void Merge (bool forceBuild)
 
ResourceNode FindChildByType (string path, bool searchChildren, params ResourceType[] types)
 
ResourceNode FindChildByType (string path, bool searchChildren, StringComparison compare, params ResourceType[] types)
 
ResourceNode FindChild (string path)
 
ResourceNode FindChild (string path, bool searchChildren)
 
ResourceNode FindChild (string path, StringComparison compare)
 
ResourceNode FindChild (string path, bool searchChildren, StringComparison compare)
 
ResourceNode[] FindChildrenByClassType (string path, Type type)
 
ResourceNode[] FindChildrenByType (string path, ResourceType type)
 
ResourceNode[] FindChildrenByTypeInGroup (string path, ResourceType type, byte group)
 
ResourceNode[] FindChildrenByName (string name)
 
unsafe string FindName (string name)
 
ResourceNode FindEmbeddedIndex (int index)
 
virtual unsafe byte[] MD5 ()
 Find the MD5 checksum of this node's data. If this node doesn't have any data (BRESGroupNode, for example), this method will return null. More...
 
string MD5Str ()
 Get the result of the MD5() function as a string of hexadecimal digits. If MD5() returns null, this method will return an empty string. More...
 
ResourceNode PrevSibling ()
 
ResourceNode NextSibling ()
 
override string ToString ()
 
virtual void SortChildren ()
 
bool IsValid ()
 
VoidPtr GetAddress ()
 
int GetLength ()
 

Properties

override ResourceType ResourceFileType [get]
 
RSAType RSA [get]
 
byte[] RSASig [get]
 
byte Version [get]
 
byte CaCrlVersion [get]
 
byte SignerCrlVersion [get]
 
int SysVersionLo [get]
 
int SysVersionHi [get]
 
short TitleID0 [get]
 
short TitleID1 [get]
 
string TitleTag [get]
 
int TitleType [get]
 
short GroupID [get]
 
int AccessRights [get]
 
short TitleVersion [get]
 
short NumContents [get]
 
short BootIndex [get]
 
TMDEntry[] Entries [get]
 
byte[] TitleKey [get]
 
byte[] IV [get]
 
PartitionTableEntry.Type PartitionType [get, set]
 
string VirtualConsoleID [get, set]
 
- Properties inherited from BrawlLib.SSBB.ResourceNodes.ISOEntryNode
override ResourceType ResourceFileType [get]
 
virtual string DataSize [get]
 
ISONode ISORoot [get]
 
long OffMult [get]
 
- Properties inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
string FilePath [get]
 
string FileName [get]
 
string DirectoryName [get]
 
ResourceNode RootNode [get]
 
DataSource OriginalSource [get]
 
DataSource UncompressedSource [get]
 
DataSource WorkingSource [get]
 
DataSource WorkingUncompressed [get]
 
virtual bool HasChildren [get]
 
virtual ResourceType ResourceFileType [get]
 
string NodeType [get]
 
virtual string TreePathAbsolute [get]
 
virtual string TreePath [get]
 
virtual int Level [get]
 
virtual int MaxNameLength [get]
 
virtual bool AllowDuplicateNames [get]
 
virtual bool AllowNullNames [get]
 
virtual string Name [get, set]
 
ResourceNode Parent [get, set]
 
List< ResourceNodeChildren [get]
 
int Index [get]
 
int HexIndex [get]
 
bool IsCompressed [get]
 
bool HasChanged [get, set]
 
bool IsBranch [get]
 
bool HasMerged [get]
 
virtual bool AllowSaving [get, set]
 
virtual bool IsDirty [get, set]
 
virtual uint UncompressedSize [get]
 
virtual Type[] AllowedChildTypes [get]
 
virtual string Compression [get, set]
 
virtual bool RetainChildrenOnReplace [get]
 
virtual bool supportsCompression [get]
 
static MD5CryptoServiceProvider MD5Provider [get]
 

Additional Inherited Members

- Static Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
static ResourceNode[] FindAllSubNodes (ResourceNode root)
 
static ResourceNode FindNode (ResourceNode root, string path, bool searchChildren, StringComparison compare)
 
- Public Attributes inherited from BrawlLib.SSBB.ResourceNodes.ISOEntryNode
long _rootOffset
 
- Public Attributes inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
Form _mainForm
 
string _name
 
string _origPath
 
ResourceNode _parent
 
List< ResourceNode_children = new List<ResourceNode>()
 
int _calcSize
 
EventHandler UpdateControl
 
MoveEventHandler MovedDown
 
ResourceEventHandler Renamed
 
ResourceEventHandler PropertyChanged
 
ResourceEventHandler Replaced
 
ResourceEventHandler Restored
 
ResourceChildEventHandler ChildRemoved
 
bool _isPopulating
 
bool _replaced
 
- Protected Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
void ForceReplacedEvent ()
 
virtual void MergeInternal ()
 
- Protected Attributes inherited from BrawlLib.SSBB.ResourceNodes.ISOEntryNode
List< UnsafeBuffer_childBuffers = new List<UnsafeBuffer>()
 
- Events inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
SelectEventHandler SelectChild
 
EventHandler UpdateProps
 
MoveEventHandler MovedUp
 
ResourceEventHandler Disposing
 
ResourceChildEventHandler ChildAdded
 
ResourceChildInsertEventHandler ChildInserted
 

Member Enumeration Documentation

◆ RSAType

168 {
169 None = 0,
170 RSA2048 = 0x00010001,
171 RSA4096 = 0x00010000
172 }

Constructor & Destructor Documentation

◆ ISOPartitionNode()

BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.ISOPartitionNode ( PartitionTableEntry  entry,
bool  VC 
)
inline
154 {
155 if (VC)
156 {
157 _vcID = entry.GameID;
158 _type = PartitionTableEntry.Type.VirtualConsole;
159 }
160 else
161 {
162 _vcID = "N/A";
163 _type = entry.PartitionType;
164 }
165 }
Definition: ISO.cs:139
string GameID
Definition: ISO.cs:158
Type
Definition: ISO.cs:144
Type PartitionType
Definition: ISO.cs:152

Member Function Documentation

◆ DecryptBlock()

byte[] BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.DecryptBlock ( uint  block)
inline
260 {
261 if (block == _cachedBlock)
262 {
263 return null;
264 }
265
266 byte[] blockData = GetBytes(_info._dataOffset + BlockSize * block, BlockSize, true);
267 byte[] enc = blockData.SubArray(BlockHeaderSize, BlockDataSize);
268 byte[] dec = new byte[BlockDataSize];
269
270 using (AesManaged aesAlg = new AesManaged())
271 {
272 aesAlg.Key = _titleKey;
273 aesAlg.IV = blockData.SubArray(0x3D0, 0x10);
274 aesAlg.Mode = CipherMode.CBC;
275 aesAlg.Padding = PaddingMode.Zeros;
276
277 ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
278 using (MemoryStream msDecrypt = new MemoryStream(enc))
279 {
280 using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
281 {
282 csDecrypt.Read(dec, 0, BlockDataSize);
283 }
284 }
285 }
286
287 _cachedBlock = block;
288
289 return dec;
290 }
byte[] GetBytes(long offset, int size, bool relative=false)
Definition: ISONode.cs:388
buint _dataOffset
Definition: ISO.cs:184

◆ GetAddress()

VoidPtr BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.GetAddress ( )
inline

Implements BrawlLib.SSBB.ResourceNodes.IBufferNode.

331 {
333 }
DataSource WorkingUncompressed
Definition: ResourceNode.cs:183
VoidPtr Address
Definition: ResourceNode.cs:31

◆ GetDC()

void BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.GetDC ( long  nOffset,
long  nSize,
out long  decOffset,
out long  decSize 
)
inline
246 {
247 if (_rsaType != RSAType.None)
248 {
249 decOffset = nOffset / BlockDataSize * BlockSize;
250 decSize = (nSize / BlockDataSize + 1) * BlockSize + nOffset % BlockDataSize;
251 }
252 else
253 {
254 decOffset = nOffset;
255 decSize = nSize;
256 }
257 }

◆ GetLength()

int BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.GetLength ( )
inline

Implements BrawlLib.SSBB.ResourceNodes.IBufferNode.

336 {
338 }
int Length
Definition: ResourceNode.cs:32

◆ GetPartitionData()

byte[] BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.GetPartitionData ( long  offset,
int  size 
)
inline
293 {
294 if (_rsaType == RSAType.None)
295 {
296 return GetBytes(offset, size, true);
297 }
298
299 List<byte> buffer = new List<byte>(size);
300 uint block = (uint) (offset / BlockDataSize);
301 int cacheOffset = (int) (offset % BlockDataSize);
302 int cacheSize;
303
304 while (size > 0)
305 {
306 byte[] cache = DecryptBlock(block);
307
308 cacheSize = size;
309 if (cacheSize + cacheOffset > BlockDataSize)
310 {
311 cacheSize = BlockDataSize - cacheOffset;
312 }
313
314 buffer.AddRange(cache.SubArray(cacheOffset, cacheSize));
315
316 size -= cacheSize;
317 cacheOffset = 0;
318
319 block++;
320 }
321
322 return buffer.ToArray();
323 }
byte[] DecryptBlock(uint block)
Definition: ISONode.cs:259

◆ IsValid()

bool BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.IsValid ( )
inline

Implements BrawlLib.SSBB.ResourceNodes.IBufferNode.

326 {
327 return GetLength() > 0;
328 }
int GetLength()
Definition: ISONode.cs:335

◆ OnInitialize()

override bool BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.OnInitialize ( )
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

175 {
176 base.OnInitialize();
177
178 _name = $"[{Index}] {PartitionType.ToString()}";
179 _info = Get<PartitionInfo>(0x2A4, true);
180
181 long tmdOffset = _info._tmdOffset * OffMult;
182 uint sigType = Get<buint>(tmdOffset, true);
183 _rsaType = (RSAType) sigType;
184 if (sigType != 0)
185 {
186 tmdOffset += 4L;
187
188 int size = 0x200 - ((int) sigType & 1) * 0x100;
189
190 _rsaSig = GetBytes(tmdOffset, size, true);
191
192 tmdOffset += size;
193 tmdOffset = (tmdOffset + 64 - 1) & ~(64 - 1);
194
195 _tmd = Get<TMDInfo>(tmdOffset, true);
196 tmdOffset += TMDInfo.Size;
197
198 _tmdEntries = new List<TMDEntry>();
199 for (int i = 0; i < _tmd._numContents; ++i)
200 {
201 _tmdEntries.Add(Get<TMDEntry>(tmdOffset + i * TMDEntry.Size, true));
202 }
203
204 byte[] encryptedKey = GetBytes(0x1BF, 16, true);
205 _iv = GetBytes(0x1DC, 8, true);
206 Array.Resize(ref _iv, 16);
207
208 using (AesManaged aesAlg = new AesManaged())
209 {
210 aesAlg.Key = ISONode.LoadedKey;
211 aesAlg.IV = _iv;
212 aesAlg.Mode = CipherMode.CBC;
213 aesAlg.Padding = PaddingMode.Zeros;
214
215 _titleKey = new byte[16];
216 ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
217 using (MemoryStream msDecrypt = new MemoryStream(encryptedKey))
218 {
219 using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
220 {
221 csDecrypt.Read(_titleKey, 0, 16);
222 }
223 }
224 }
225 }
226
227 //byte[] b = GetPartitionData(0, 0x440);
228 //_header = ToStruct<ISOPartitionHeader>(b);
229
230 //byte[] dol = GetPartitionData(_header._dolOffset * OffMult, 0x100);
231 //DOLHeader dolHdr = ToStruct<DOLHeader>(dol);
232
233 //byte[] fullDol = GetPartitionData(_header._dolOffset * OffMult, (int)dolHdr.GetSize());
234 //UnsafeBuffer dolBuf = GetBuffer(fullDol);
235 //_childBuffers.Add(dolBuf);
236 //new DOLNode().Initialize(this, dolBuf.Address, dolBuf.Length);
237
238 return true;
239 }
long OffMult
Definition: ISONode.cs:356
string _name
Definition: ResourceNode.cs:139
Definition: ISO.cs:236
const int Size
Definition: ISO.cs:237
Definition: ISO.cs:201
const int Size
Definition: ISO.cs:202
bshort _numContents
Definition: ISO.cs:219

Property Documentation

◆ AccessRights

int BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.AccessRights
get

◆ BootIndex

short BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.BootIndex
get

◆ CaCrlVersion

byte BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.CaCrlVersion
get

◆ Entries

TMDEntry [] BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.Entries
get

◆ GroupID

short BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.GroupID
get

◆ IV

byte [] BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.IV
get

◆ NumContents

short BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.NumContents
get

◆ PartitionType

PartitionTableEntry.Type BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.PartitionType
getset
126 {
127 get => _type;
128 set
129 {
130 _type = value;
132 }
133 }
virtual void SignalPropertyChange()
Definition: ResourceNode.cs:313

◆ ResourceFileType

override ResourceType BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.ResourceFileType
get

◆ RSA

RSAType BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.RSA
get

◆ RSASig

byte [] BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.RSASig
get

◆ SignerCrlVersion

byte BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.SignerCrlVersion
get

◆ SysVersionHi

int BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.SysVersionHi
get

◆ SysVersionLo

int BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.SysVersionLo
get

◆ TitleID0

short BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.TitleID0
get

◆ TitleID1

short BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.TitleID1
get

◆ TitleKey

byte [] BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.TitleKey
get

◆ TitleTag

string BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.TitleTag
get

◆ TitleType

int BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.TitleType
get

◆ TitleVersion

short BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.TitleVersion
get

◆ Version

byte BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.Version
get

◆ VirtualConsoleID

string BrawlLib.SSBB.ResourceNodes.ISOPartitionNode.VirtualConsoleID
getset
137 {
138 get => _vcID;
139 set
140 {
141 if (PartitionType == PartitionTableEntry.Type.VirtualConsole)
142 {
143 _vcID = value.PadLeft(4, ' ').Substring(value.Length - 4, value.Length);
145 }
146 else
147 {
148 _vcID = "N/A";
149 }
150 }
151 }
PartitionTableEntry.Type PartitionType
Definition: ISONode.cs:126

The documentation for this class was generated from the following file: