mirror of
https://github.com/hax4dazy/TinWoo.git
synced 2025-02-09 19:25:05 +01:00
Add files via upload
This commit is contained in:
parent
d53f484bd3
commit
d3cad8e715
57
include/install/hfs0.hpp
Normal file
57
include/install/hfs0.hpp
Normal file
@ -0,0 +1,57 @@
|
||||
#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_INLINE const HFS0FileEntry *hfs0GetFileEntry(const HFS0BaseHeader *header, u32 i)
|
||||
{
|
||||
if (i >= header->numFiles)
|
||||
return NULL;
|
||||
return (const HFS0FileEntry*)(header + 0x1 + i * 0x4);
|
||||
}
|
||||
|
||||
NX_INLINE const char *hfs0GetStringTable(const HFS0BaseHeader *header)
|
||||
{
|
||||
return (const char*)(header + 0x1 + header->numFiles * 0x4);
|
||||
}
|
||||
|
||||
NX_INLINE u64 hfs0GetHeaderSize(const HFS0BaseHeader *header)
|
||||
{
|
||||
return 0x1 + header->numFiles * 0x4 + header->stringTableSize;
|
||||
}
|
||||
|
||||
NX_INLINE const char *hfs0GetFileName(const HFS0BaseHeader *header, u32 i)
|
||||
{
|
||||
return hfs0GetStringTable(header) + hfs0GetFileEntry(header, i)->stringTableOffset;
|
||||
}
|
||||
|
||||
NX_INLINE const char *hfs0GetFileName(const HFS0BaseHeader *header, const HFS0FileEntry *entry)
|
||||
{
|
||||
return hfs0GetStringTable(header) + entry->stringTableOffset;
|
||||
}
|
||||
}
|
40
include/install/http_nsp.hpp
Normal file
40
include/install/http_nsp.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "install/nsp.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace tin::install::nsp
|
||||
{
|
||||
class HTTPNSP : public NSP
|
||||
{
|
||||
public:
|
||||
tin::network::HTTPDownload m_download;
|
||||
|
||||
HTTPNSP(std::string url);
|
||||
|
||||
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId) override;
|
||||
virtual void BufferData(void* buf, off_t offset, size_t size) override;
|
||||
};
|
||||
}
|
41
include/install/http_xci.hpp
Normal file
41
include/install/http_xci.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "install/xci.hpp"
|
||||
#include "util/network_util.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace tin::install::xci
|
||||
{
|
||||
class HTTPXCI : public XCI
|
||||
{
|
||||
public:
|
||||
tin::network::HTTPDownload m_download;
|
||||
|
||||
HTTPXCI(std::string url);
|
||||
|
||||
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId) override;
|
||||
virtual void BufferData(void* buf, off_t offset, size_t size) override;
|
||||
};
|
||||
}
|
69
include/install/install.hpp
Normal file
69
include/install/install.hpp
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <switch/services/fs.h>
|
||||
}
|
||||
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include "install/simple_filesystem.hpp"
|
||||
#include "data/byte_buffer.hpp"
|
||||
|
||||
#include "nx/content_meta.hpp"
|
||||
#include "nx/ipc/tin_ipc.h"
|
||||
|
||||
namespace tin::install
|
||||
{
|
||||
class Install
|
||||
{
|
||||
protected:
|
||||
const NcmStorageId m_destStorageId;
|
||||
bool m_ignoreReqFirmVersion = false;
|
||||
bool m_declinedValidation = false;
|
||||
|
||||
std::vector<nx::ncm::ContentMeta> m_contentMeta;
|
||||
|
||||
Install(NcmStorageId destStorageId, bool ignoreReqFirmVersion);
|
||||
|
||||
virtual std::vector<std::tuple<nx::ncm::ContentMeta, NcmContentInfo>> ReadCNMT() = 0;
|
||||
|
||||
virtual void InstallContentMetaRecords(tin::data::ByteBuffer& installContentMetaBuf, int i);
|
||||
virtual void InstallApplicationRecord(int i);
|
||||
virtual void InstallTicketCert() = 0;
|
||||
virtual void InstallNCA(const NcmContentId &ncaId) = 0;
|
||||
|
||||
public:
|
||||
virtual ~Install();
|
||||
|
||||
virtual void Prepare();
|
||||
virtual void Begin();
|
||||
|
||||
virtual u64 GetTitleId(int i = 0);
|
||||
virtual NcmContentMetaType GetContentMetaType(int i = 0);
|
||||
};
|
||||
}
|
45
include/install/install_nsp.hpp
Normal file
45
include/install/install_nsp.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
#include <string>
|
||||
#include "install/install.hpp"
|
||||
#include "install/nsp.hpp"
|
||||
|
||||
namespace tin::install::nsp
|
||||
{
|
||||
class NSPInstall : public Install
|
||||
{
|
||||
private:
|
||||
const std::shared_ptr<NSP> m_NSP;
|
||||
|
||||
protected:
|
||||
std::vector<std::tuple<nx::ncm::ContentMeta, NcmContentInfo>> ReadCNMT() override;
|
||||
void InstallNCA(const NcmContentId& ncaId) override;
|
||||
void InstallTicketCert() override;
|
||||
|
||||
public:
|
||||
NSPInstall(NcmStorageId destStorageId, bool ignoreReqFirmVersion, const std::shared_ptr<NSP>& remoteNSP);
|
||||
};
|
||||
}
|
47
include/install/install_xci.hpp
Normal file
47
include/install/install_xci.hpp
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
#include "install/install.hpp"
|
||||
#include "install/xci.hpp"
|
||||
#include "nx/content_meta.hpp"
|
||||
#include "nx/ipc/tin_ipc.h"
|
||||
|
||||
namespace tin::install::xci
|
||||
{
|
||||
class XCIInstallTask : public Install
|
||||
{
|
||||
private:
|
||||
const std::shared_ptr<tin::install::xci::XCI> m_xci;
|
||||
|
||||
protected:
|
||||
std::vector<std::tuple<nx::ncm::ContentMeta, NcmContentInfo>> ReadCNMT() override;
|
||||
void InstallNCA(const NcmContentId& ncaId) override;
|
||||
void InstallTicketCert() override;
|
||||
|
||||
public:
|
||||
XCIInstallTask(NcmStorageId destStorageId, bool ignoreReqFirmVersion, const std::shared_ptr<XCI>& xci);
|
||||
};
|
||||
};
|
||||
|
77
include/install/nca.hpp
Normal file
77
include/install/nca.hpp
Normal file
@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
#define NCA_HEADER_SIZE 0x4000
|
||||
#define MAGIC_NCA3 0x3341434E /* "NCA3" */
|
||||
namespace tin::install
|
||||
{
|
||||
struct NcaFsHeader
|
||||
{
|
||||
u8 _0x0;
|
||||
u8 _0x1;
|
||||
u8 partition_type;
|
||||
u8 fs_type;
|
||||
u8 crypt_type;
|
||||
u8 _0x5[0x3];
|
||||
u8 superblock_data[0x138];
|
||||
/*union {
|
||||
pfs0_superblock_t pfs0_superblock;
|
||||
romfs_superblock_t romfs_superblock;
|
||||
//nca0_romfs_superblock_t nca0_romfs_superblock;
|
||||
bktr_superblock_t bktr_superblock;
|
||||
};*/
|
||||
union {
|
||||
u64 section_ctr;
|
||||
struct {
|
||||
u32 section_ctr_low;
|
||||
u32 section_ctr_high;
|
||||
};
|
||||
};
|
||||
u8 _0x148[0xB8]; /* Padding. */
|
||||
} PACKED;
|
||||
|
||||
static_assert(sizeof(NcaFsHeader) == 0x200, "NcaFsHeader must be 0x200");
|
||||
|
||||
struct NcaSectionEntry
|
||||
{
|
||||
u32 media_start_offset;
|
||||
u32 media_end_offset;
|
||||
u8 _0x8[0x8]; /* Padding. */
|
||||
} PACKED;
|
||||
|
||||
static_assert(sizeof(NcaSectionEntry) == 0x10, "NcaSectionEntry must be 0x10");
|
||||
|
||||
struct NcaHeader
|
||||
{
|
||||
u8 fixed_key_sig[0x100]; /* RSA-PSS signature over header with fixed key. */
|
||||
u8 npdm_key_sig[0x100]; /* RSA-PSS signature over header with key in NPDM. */
|
||||
u32 magic;
|
||||
u8 distribution; /* System vs gamecard. */
|
||||
u8 content_type;
|
||||
u8 m_cryptoType; /* Which keyblob (field 1) */
|
||||
u8 m_kaekIndex; /* Which kaek index? */
|
||||
u64 nca_size; /* Entire archive size. */
|
||||
u64 m_titleId;
|
||||
u8 _0x218[0x4]; /* Padding. */
|
||||
union {
|
||||
uint32_t sdk_version; /* What SDK was this built with? */
|
||||
struct {
|
||||
u8 sdk_revision;
|
||||
u8 sdk_micro;
|
||||
u8 sdk_minor;
|
||||
u8 sdk_major;
|
||||
};
|
||||
};
|
||||
u8 m_cryptoType2; /* Which keyblob (field 2) */
|
||||
u8 _0x221[0xF]; /* Padding. */
|
||||
u64 m_rightsId[2]; /* Rights ID (for titlekey crypto). */
|
||||
NcaSectionEntry section_entries[4]; /* Section entry metadata. */
|
||||
u8 section_hashes[4 * 0x20]; /* SHA-256 hashes for each section header. */
|
||||
u8 m_keys[4 * 0x10]; /* Encrypted key area. */
|
||||
u8 _0x340[0xC0]; /* Padding. */
|
||||
NcaFsHeader fs_headers[4]; /* FS section headers. */
|
||||
} PACKED;
|
||||
|
||||
static_assert(sizeof(NcaHeader) == 0xc00, "NcaHeader must be 0xc00");
|
||||
}
|
57
include/install/nsp.hpp
Normal file
57
include/install/nsp.hpp
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include <switch/types.h>
|
||||
#include "install/pfs0.hpp"
|
||||
#include "nx/ncm.hpp"
|
||||
#include "util/network_util.hpp"
|
||||
|
||||
namespace tin::install::nsp
|
||||
{
|
||||
class NSP
|
||||
{
|
||||
protected:
|
||||
std::vector<u8> m_headerBytes;
|
||||
|
||||
NSP();
|
||||
|
||||
public:
|
||||
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId) = 0;
|
||||
virtual void BufferData(void* buf, off_t offset, size_t size) = 0;
|
||||
|
||||
virtual void RetrieveHeader();
|
||||
virtual const PFS0BaseHeader* GetBaseHeader();
|
||||
virtual u64 GetDataOffset();
|
||||
|
||||
virtual const PFS0FileEntry* GetFileEntry(unsigned int index);
|
||||
virtual const PFS0FileEntry* GetFileEntryByName(std::string name);
|
||||
virtual const PFS0FileEntry* GetFileEntryByNcaId(const NcmContentId& ncaId);
|
||||
virtual std::vector<const PFS0FileEntry*> GetFileEntriesByExtension(std::string extension);
|
||||
|
||||
virtual const char* GetFileEntryName(const PFS0FileEntry* fileEntry);
|
||||
};
|
||||
}
|
48
include/install/pfs0.hpp
Normal file
48
include/install/pfs0.hpp
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <switch/types.h>
|
||||
|
||||
namespace tin::install
|
||||
{
|
||||
struct PFS0FileEntry
|
||||
{
|
||||
u64 dataOffset;
|
||||
u64 fileSize;
|
||||
u32 stringTableOffset;
|
||||
u32 padding;
|
||||
} PACKED;
|
||||
|
||||
static_assert(sizeof(PFS0FileEntry) == 0x18, "PFS0FileEntry must be 0x18");
|
||||
|
||||
struct PFS0BaseHeader
|
||||
{
|
||||
u32 magic;
|
||||
u32 numFiles;
|
||||
u32 stringTableSize;
|
||||
u32 reserved;
|
||||
} PACKED;
|
||||
|
||||
static_assert(sizeof(PFS0BaseHeader) == 0x10, "PFS0BaseHeader must be 0x10");
|
||||
}
|
40
include/install/sdmc_nsp.hpp
Normal file
40
include/install/sdmc_nsp.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "install/nsp.hpp"
|
||||
|
||||
namespace tin::install::nsp
|
||||
{
|
||||
class SDMCNSP : public NSP
|
||||
{
|
||||
public:
|
||||
SDMCNSP(std::string path);
|
||||
~SDMCNSP();
|
||||
|
||||
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId ncaId) override;
|
||||
virtual void BufferData(void* buf, off_t offset, size_t size) override;
|
||||
private:
|
||||
FILE* m_nspFile;
|
||||
};
|
||||
}
|
40
include/install/sdmc_xci.hpp
Normal file
40
include/install/sdmc_xci.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "install/xci.hpp"
|
||||
|
||||
namespace tin::install::xci
|
||||
{
|
||||
class SDMCXCI : public XCI
|
||||
{
|
||||
public:
|
||||
SDMCXCI(std::string path);
|
||||
~SDMCXCI();
|
||||
|
||||
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId ncaId) override;
|
||||
virtual void BufferData(void* buf, off_t offset, size_t size) override;
|
||||
private:
|
||||
FILE* m_xciFile;
|
||||
};
|
||||
}
|
46
include/install/simple_filesystem.hpp
Normal file
46
include/install/simple_filesystem.hpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include "nx/fs.hpp"
|
||||
|
||||
namespace tin::install::nsp
|
||||
{
|
||||
class SimpleFileSystem final
|
||||
{
|
||||
private:
|
||||
nx::fs::IFileSystem* m_fileSystem;
|
||||
|
||||
public:
|
||||
const std::string m_rootPath;
|
||||
const std::string m_absoluteRootPath;
|
||||
|
||||
SimpleFileSystem(nx::fs::IFileSystem& fileSystem, std::string rootPath, std::string absoluteRootPath);
|
||||
~SimpleFileSystem();
|
||||
|
||||
nx::fs::IFile OpenFile(std::string path);
|
||||
bool HasFile(std::string path);
|
||||
std::string GetFileNameFromExtension(std::string path, std::string extension);
|
||||
};
|
||||
}
|
41
include/install/usb_nsp.hpp
Normal file
41
include/install/usb_nsp.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "install/nsp.hpp"
|
||||
|
||||
namespace tin::install::nsp
|
||||
{
|
||||
class USBNSP : public NSP
|
||||
{
|
||||
private:
|
||||
std::string m_nspName;
|
||||
|
||||
public:
|
||||
USBNSP(std::string nspName);
|
||||
|
||||
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId) override;
|
||||
virtual void BufferData(void* buf, off_t offset, size_t size) override;
|
||||
};
|
||||
}
|
41
include/install/usb_xci.hpp
Normal file
41
include/install/usb_xci.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "install/xci.hpp"
|
||||
|
||||
namespace tin::install::xci
|
||||
{
|
||||
class USBXCI : public XCI
|
||||
{
|
||||
private:
|
||||
std::string m_xciName;
|
||||
|
||||
public:
|
||||
USBXCI(std::string xciName);
|
||||
|
||||
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId) override;
|
||||
virtual void BufferData(void* buf, off_t offset, size_t size) override;
|
||||
};
|
||||
}
|
58
include/install/xci.hpp
Normal file
58
include/install/xci.hpp
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include <switch/types.h>
|
||||
#include "install/hfs0.hpp"
|
||||
#include "nx/ncm.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace tin::install::xci
|
||||
{
|
||||
class XCI
|
||||
{
|
||||
protected:
|
||||
u64 m_secureHeaderOffset;
|
||||
std::vector<u8> m_secureHeaderBytes;
|
||||
|
||||
XCI();
|
||||
|
||||
public:
|
||||
virtual void StreamToPlaceholder(std::shared_ptr<nx::ncm::ContentStorage>& contentStorage, NcmContentId placeholderId) = 0;
|
||||
virtual void BufferData(void* buf, off_t offset, size_t size) = 0;
|
||||
|
||||
virtual void RetrieveHeader();
|
||||
virtual const HFS0BaseHeader* GetSecureHeader();
|
||||
virtual u64 GetDataOffset();
|
||||
|
||||
virtual const HFS0FileEntry* GetFileEntry(unsigned int index);
|
||||
virtual const HFS0FileEntry* GetFileEntryByName(std::string name);
|
||||
virtual const HFS0FileEntry* GetFileEntryByNcaId(const NcmContentId& ncaId);
|
||||
virtual std::vector<const HFS0FileEntry*> GetFileEntriesByExtension(std::string extension);
|
||||
|
||||
virtual const char* GetFileEntryName(const HFS0FileEntry* fileEntry);
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user