Fixed serialization runtime exceptions
This commit is contained in:
parent
ca971ff31f
commit
e4f05884c3
23 changed files with 140 additions and 24 deletions
|
@ -30,6 +30,7 @@
|
|||
// FileSys namespace
|
||||
|
||||
SERIALIZE_EXPORT_IMPL(FileSys::NCCHArchive)
|
||||
SERIALIZE_EXPORT_IMPL(FileSys::NCCHFile)
|
||||
SERIALIZE_EXPORT_IMPL(FileSys::ArchiveFactory_NCCH)
|
||||
|
||||
namespace FileSys {
|
||||
|
|
|
@ -95,9 +95,16 @@ public:
|
|||
void Flush() const override {}
|
||||
|
||||
private:
|
||||
NCCHFile() = default; // NOTE: If the public ctor has behaviour, need to replace this with
|
||||
// *_construct_data
|
||||
std::vector<u8> file_buffer; // TODO: Replace with file ref for serialization
|
||||
std::vector<u8> file_buffer;
|
||||
|
||||
NCCHFile() = default;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, const unsigned int) {
|
||||
ar& boost::serialization::base_object<FileBackend>(*this);
|
||||
ar& file_buffer; // TODO: See about a more efficient way to do this
|
||||
}
|
||||
friend class boost::serialization::access;
|
||||
};
|
||||
|
||||
/// File system interface to the NCCH archive
|
||||
|
@ -125,4 +132,5 @@ private:
|
|||
} // namespace FileSys
|
||||
|
||||
BOOST_CLASS_EXPORT_KEY(FileSys::NCCHArchive)
|
||||
BOOST_CLASS_EXPORT_KEY(FileSys::NCCHFile)
|
||||
BOOST_CLASS_EXPORT_KEY(FileSys::ArchiveFactory_NCCH)
|
||||
|
|
|
@ -77,6 +77,15 @@ public:
|
|||
|
||||
private:
|
||||
std::shared_ptr<std::vector<u8>> data;
|
||||
|
||||
ExeFSSectionFile() = default;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, const unsigned int) {
|
||||
ar& boost::serialization::base_object<FileBackend>(*this);
|
||||
ar& data;
|
||||
}
|
||||
friend class boost::serialization::access;
|
||||
};
|
||||
|
||||
// SelfNCCHArchive represents the running application itself. From this archive the application can
|
||||
|
@ -234,6 +243,15 @@ private:
|
|||
}
|
||||
|
||||
NCCHData ncch_data;
|
||||
|
||||
SelfNCCHArchive() = default;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, const unsigned int) {
|
||||
ar& boost::serialization::base_object<ArchiveBackend>(*this);
|
||||
ar& ncch_data;
|
||||
}
|
||||
friend class boost::serialization::access;
|
||||
};
|
||||
|
||||
void ArchiveFactory_SelfNCCH::Register(Loader::AppLoader& app_loader) {
|
||||
|
@ -300,3 +318,6 @@ ResultVal<ArchiveFormatInfo> ArchiveFactory_SelfNCCH::GetFormatInfo(const Path&,
|
|||
}
|
||||
|
||||
} // namespace FileSys
|
||||
|
||||
SERIALIZE_EXPORT_IMPL(FileSys::ExeFSSectionFile)
|
||||
SERIALIZE_EXPORT_IMPL(FileSys::SelfNCCHArchive)
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <boost/serialization/export.hpp>
|
||||
#include <boost/serialization/shared_ptr.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "core/file_sys/archive_backend.h"
|
||||
#include "core/hle/result.h"
|
||||
|
@ -25,6 +27,17 @@ struct NCCHData {
|
|||
std::shared_ptr<std::vector<u8>> banner;
|
||||
std::shared_ptr<RomFSReader> romfs_file;
|
||||
std::shared_ptr<RomFSReader> update_romfs_file;
|
||||
|
||||
private:
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, const unsigned int) {
|
||||
ar& icon;
|
||||
ar& logo;
|
||||
ar& banner;
|
||||
ar& romfs_file;
|
||||
ar& update_romfs_file;
|
||||
}
|
||||
friend class boost::serialization::access;
|
||||
};
|
||||
|
||||
/// File system interface to the SelfNCCH archive
|
||||
|
@ -55,6 +68,11 @@ private:
|
|||
friend class boost::serialization::access;
|
||||
};
|
||||
|
||||
class ExeFSSectionFile;
|
||||
class SelfNCCHArchive;
|
||||
|
||||
} // namespace FileSys
|
||||
|
||||
BOOST_CLASS_EXPORT_KEY(FileSys::ArchiveFactory_SelfNCCH)
|
||||
BOOST_CLASS_EXPORT_KEY(FileSys::ExeFSSectionFile)
|
||||
BOOST_CLASS_EXPORT_KEY(FileSys::SelfNCCHArchive)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include "common/archives.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/file_sys/ivfc_archive.h"
|
||||
|
@ -12,6 +13,11 @@
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FileSys namespace
|
||||
|
||||
SERIALIZE_EXPORT_IMPL(FileSys::IVFCFile)
|
||||
SERIALIZE_EXPORT_IMPL(FileSys::IVFCDelayGenerator)
|
||||
SERIALIZE_EXPORT_IMPL(FileSys::RomFSDelayGenerator)
|
||||
SERIALIZE_EXPORT_IMPL(FileSys::ExeFSDelayGenerator)
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
IVFCArchive::IVFCArchive(std::shared_ptr<RomFSReader> file,
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <boost/serialization/export.hpp>
|
||||
#include <boost/serialization/shared_ptr.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "common/file_util.h"
|
||||
#include "core/file_sys/archive_backend.h"
|
||||
|
@ -38,6 +40,8 @@ class IVFCDelayGenerator : public DelayGenerator {
|
|||
static constexpr u64 IPCDelayNanoseconds(9438006);
|
||||
return IPCDelayNanoseconds;
|
||||
}
|
||||
|
||||
SERIALIZE_DELAY_GENERATOR
|
||||
};
|
||||
|
||||
class RomFSDelayGenerator : public DelayGenerator {
|
||||
|
@ -60,6 +64,8 @@ public:
|
|||
static constexpr u64 IPCDelayNanoseconds(9438006);
|
||||
return IPCDelayNanoseconds;
|
||||
}
|
||||
|
||||
SERIALIZE_DELAY_GENERATOR
|
||||
};
|
||||
|
||||
class ExeFSDelayGenerator : public DelayGenerator {
|
||||
|
@ -82,6 +88,8 @@ public:
|
|||
static constexpr u64 IPCDelayNanoseconds(9438006);
|
||||
return IPCDelayNanoseconds;
|
||||
}
|
||||
|
||||
SERIALIZE_DELAY_GENERATOR
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -128,6 +136,15 @@ public:
|
|||
|
||||
private:
|
||||
std::shared_ptr<RomFSReader> romfs_file;
|
||||
|
||||
IVFCFile() = default;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, const unsigned int) {
|
||||
ar& boost::serialization::base_object<FileBackend>(*this);
|
||||
ar& romfs_file;
|
||||
}
|
||||
friend class boost::serialization::access;
|
||||
};
|
||||
|
||||
class IVFCDirectory : public DirectoryBackend {
|
||||
|
@ -162,3 +179,8 @@ private:
|
|||
};
|
||||
|
||||
} // namespace FileSys
|
||||
|
||||
BOOST_CLASS_EXPORT_KEY(FileSys::IVFCFile)
|
||||
BOOST_CLASS_EXPORT_KEY(FileSys::IVFCDelayGenerator)
|
||||
BOOST_CLASS_EXPORT_KEY(FileSys::RomFSDelayGenerator)
|
||||
BOOST_CLASS_EXPORT_KEY(FileSys::ExeFSDelayGenerator)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "common/file_util.h"
|
||||
|
||||
|
@ -29,9 +30,23 @@ private:
|
|||
FileUtil::IOFile file;
|
||||
std::array<u8, 16> key;
|
||||
std::array<u8, 16> ctr;
|
||||
std::size_t file_offset;
|
||||
std::size_t crypto_offset;
|
||||
std::size_t data_size;
|
||||
u64 file_offset;
|
||||
u64 crypto_offset;
|
||||
u64 data_size;
|
||||
|
||||
RomFSReader() = default;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, const unsigned int) {
|
||||
ar& is_encrypted;
|
||||
ar& file;
|
||||
ar& key;
|
||||
ar& ctr;
|
||||
ar& file_offset;
|
||||
ar& crypto_offset;
|
||||
ar& data_size;
|
||||
}
|
||||
friend class boost::serialization::access;
|
||||
};
|
||||
|
||||
} // namespace FileSys
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue