mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-28 18:23:49 +00:00
also changes some methods to std::span<> as well, but mainly std::vector<> in the NSO/KIP loading stuff is not needed to be memcpy'ed and memmove'd around this should save a marginal amount of loading time (RDR1) Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3639 Reviewed-by: DraVee <dravee@eden-emu.dev> Reviewed-by: Maufeat <sahyno1996@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
111 lines
2.5 KiB
C++
111 lines
2.5 KiB
C++
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <span>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "common/common_funcs.h"
|
|
#include "common/common_types.h"
|
|
#include "common/swap.h"
|
|
#include "core/file_sys/vfs/vfs_types.h"
|
|
|
|
namespace Loader {
|
|
enum class ResultStatus : u16;
|
|
}
|
|
|
|
namespace FileSys {
|
|
|
|
struct KIPSectionHeader {
|
|
u32_le offset;
|
|
u32_le decompressed_size;
|
|
u32_le compressed_size;
|
|
u32_le attribute;
|
|
};
|
|
static_assert(sizeof(KIPSectionHeader) == 0x10, "KIPSectionHeader has incorrect size.");
|
|
|
|
struct KIPHeader {
|
|
u32_le magic;
|
|
std::array<char, 0xC> name;
|
|
u64_le title_id;
|
|
u32_le process_category;
|
|
u8 main_thread_priority;
|
|
u8 default_core;
|
|
INSERT_PADDING_BYTES(1);
|
|
u8 flags;
|
|
std::array<KIPSectionHeader, 6> sections;
|
|
std::array<u32, 0x20> capabilities;
|
|
};
|
|
static_assert(sizeof(KIPHeader) == 0x100, "KIPHeader has incorrect size.");
|
|
|
|
struct INIHeader {
|
|
u32_le magic;
|
|
u32_le size;
|
|
u32_le kip_count;
|
|
INSERT_PADDING_BYTES(0x4);
|
|
};
|
|
static_assert(sizeof(INIHeader) == 0x10, "INIHeader has incorrect size.");
|
|
|
|
// Kernel Internal Process
|
|
class KIP {
|
|
public:
|
|
explicit KIP(const VirtualFile& file);
|
|
|
|
Loader::ResultStatus GetStatus() const;
|
|
|
|
std::string GetName() const;
|
|
u64 GetTitleID() const;
|
|
std::vector<u8> GetSectionDecompressed(u8 index) const;
|
|
|
|
// Executable Flags
|
|
bool Is64Bit() const;
|
|
bool Is39BitAddressSpace() const;
|
|
bool IsService() const;
|
|
|
|
std::vector<u32> GetKernelCapabilities() const;
|
|
|
|
s32 GetMainThreadPriority() const;
|
|
u32 GetMainThreadStackSize() const;
|
|
u32 GetMainThreadCpuCore() const;
|
|
|
|
std::span<const u8> GetTextSection() const;
|
|
std::span<const u8> GetRODataSection() const;
|
|
std::span<const u8> GetDataSection() const;
|
|
|
|
u32 GetTextOffset() const;
|
|
u32 GetRODataOffset() const;
|
|
u32 GetDataOffset() const;
|
|
|
|
u32 GetBSSSize() const;
|
|
u32 GetBSSOffset() const;
|
|
|
|
private:
|
|
Loader::ResultStatus status;
|
|
|
|
KIPHeader header{};
|
|
std::array<std::vector<u8>, 6> decompressed_sections;
|
|
};
|
|
|
|
class INI {
|
|
public:
|
|
explicit INI(const VirtualFile& file);
|
|
|
|
Loader::ResultStatus GetStatus() const;
|
|
|
|
const std::vector<KIP>& GetKIPs() const;
|
|
|
|
private:
|
|
Loader::ResultStatus status;
|
|
|
|
INIHeader header{};
|
|
std::vector<KIP> kips;
|
|
};
|
|
|
|
} // namespace FileSys
|