mirror of
https://github.com/kwsch/pk3DS.git
synced 2026-10-02 13:57:14 -05:00
Add info acquisition for RomFS inputs
Future 3ds generation.
This commit is contained in:
@@ -7,6 +7,36 @@
|
||||
|
||||
namespace pk3DS
|
||||
{
|
||||
// Info acquisition
|
||||
public class RomFS
|
||||
{
|
||||
public string FileName;
|
||||
public bool isTempFile;
|
||||
public byte[] SuperBlockHash;
|
||||
public uint SuperBlockLen;
|
||||
|
||||
public RomFS(string fn)
|
||||
{
|
||||
FileName = fn;
|
||||
isTempFile = false;
|
||||
using (var fs = File.OpenRead(fn))
|
||||
{
|
||||
fs.Seek(0x8, SeekOrigin.Begin);
|
||||
uint mhlen = (uint)(fs.ReadByte() | (fs.ReadByte() << 8) | (fs.ReadByte() << 16) | (fs.ReadByte() << 24));
|
||||
SuperBlockLen = mhlen + 0x50;
|
||||
if (SuperBlockLen % 0x200 != 0)
|
||||
SuperBlockLen += (0x200 - (SuperBlockLen % 0x200));
|
||||
byte[] superblock = new byte[SuperBlockLen];
|
||||
fs.Seek(0, SeekOrigin.Begin);
|
||||
fs.Read(superblock, 0, superblock.Length);
|
||||
using (SHA256 sha = SHA256.Create())
|
||||
{
|
||||
SuperBlockHash = sha.ComputeHash(superblock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// File operation
|
||||
public class RomFSTool
|
||||
{
|
||||
internal const int PADDING_ALIGN = 16;
|
||||
|
||||
Reference in New Issue
Block a user