mirror of
https://github.com/Huntereb/Awoo-Installer
synced 2024-11-26 21:50:26 +00:00
57 lines
No EOL
1.5 KiB
C++
Executable file
57 lines
No EOL
1.5 KiB
C++
Executable file
#pragma once
|
|
|
|
#include <switch/types.h>
|
|
|
|
#define MAGIC_HFS0 0x30534648
|
|
|
|
namespace tin::install
|
|
{
|
|
struct HFS0FileEntry
|
|
{
|
|
u64 dataOffset;
|
|
u64 fileSize;
|
|
u32 stringTableOffset;
|
|
u32 hashedSize;
|
|
u64 padding;
|
|
unsigned char hash[0x20];
|
|
} PACKED;
|
|
|
|
static_assert(sizeof(HFS0FileEntry) == 0x40, "HFS0FileEntry must be 0x18");
|
|
|
|
struct HFS0BaseHeader
|
|
{
|
|
u32 magic;
|
|
u32 numFiles;
|
|
u32 stringTableSize;
|
|
u32 reserved;
|
|
} PACKED;
|
|
|
|
static_assert(sizeof(HFS0BaseHeader) == 0x10, "HFS0BaseHeader must be 0x10");
|
|
|
|
NX_CONSTEXPR const HFS0FileEntry *hfs0GetFileEntry(const HFS0BaseHeader *header, u32 i)
|
|
{
|
|
if (i >= header->numFiles)
|
|
return NULL;
|
|
return (const HFS0FileEntry*)(header + 0x1 + i * 0x4);
|
|
}
|
|
|
|
NX_CONSTEXPR const char *hfs0GetStringTable(const HFS0BaseHeader *header)
|
|
{
|
|
return (const char*)(header + 0x1 + header->numFiles * 0x4);
|
|
}
|
|
|
|
NX_CONSTEXPR u64 hfs0GetHeaderSize(const HFS0BaseHeader *header)
|
|
{
|
|
return 0x1 + header->numFiles * 0x4 + header->stringTableSize;
|
|
}
|
|
|
|
NX_CONSTEXPR const char *hfs0GetFileName(const HFS0BaseHeader *header, u32 i)
|
|
{
|
|
return hfs0GetStringTable(header) + hfs0GetFileEntry(header, i)->stringTableOffset;
|
|
}
|
|
|
|
NX_CONSTEXPR const char *hfs0GetFileName(const HFS0BaseHeader *header, const HFS0FileEntry *entry)
|
|
{
|
|
return hfs0GetStringTable(header) + entry->stringTableOffset;
|
|
}
|
|
} |