mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-07-23 05:23:59 +00:00
Downgrade projects to C++17.
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
|
||||
void Image::Map(const std::string_view& name, size_t base, uint32_t size, uint8_t flags, uint8_t* data)
|
||||
{
|
||||
sections.emplace(std::string(name), this->base + base,
|
||||
size, static_cast<SectionFlags>(flags), data);
|
||||
sections.insert({ std::string(name), this->base + base,
|
||||
size, static_cast<SectionFlags>(flags), data });
|
||||
}
|
||||
|
||||
const void* Image::Find(size_t address) const
|
||||
@@ -28,7 +28,7 @@ const Section* Image::Find(const std::string_view& name) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::expected<Image, int> Image::ParseImage(const uint8_t* data, size_t size)
|
||||
Image Image::ParseImage(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data[0] == ELFMAG0 && data[1] == ELFMAG1 && data[2] == ELFMAG2 && data[3] == ELFMAG3)
|
||||
{
|
||||
@@ -39,7 +39,7 @@ std::expected<Image, int> Image::ParseImage(const uint8_t* data, size_t size)
|
||||
return Xex2LoadImage(data);
|
||||
}
|
||||
|
||||
return std::unexpected(1);
|
||||
return {};
|
||||
}
|
||||
|
||||
Image ElfLoadImage(const uint8_t* data, size_t size)
|
||||
@@ -50,27 +50,27 @@ Image ElfLoadImage(const uint8_t* data, size_t size)
|
||||
Image image{};
|
||||
image.size = size;
|
||||
image.data = std::make_unique<uint8_t[]>(size);
|
||||
image.entry_point = std::byteswap(header->e_entry);
|
||||
image.entry_point = ByteSwap(header->e_entry);
|
||||
memcpy(image.data.get(), data, size);
|
||||
|
||||
auto stringTableIndex = std::byteswap(header->e_shstrndx);
|
||||
auto stringTableIndex = ByteSwap(header->e_shstrndx);
|
||||
|
||||
const auto numSections = std::byteswap(header->e_shnum);
|
||||
const auto numpSections = std::byteswap(header->e_phnum);
|
||||
const auto numSections = ByteSwap(header->e_shnum);
|
||||
const auto numpSections = ByteSwap(header->e_phnum);
|
||||
|
||||
const auto* sections = (elf32_shdr*)(data + std::byteswap(header->e_shoff));
|
||||
const auto* psections = (elf32_phdr*)(data + std::byteswap(header->e_phoff));
|
||||
const auto* sections = (elf32_shdr*)(data + ByteSwap(header->e_shoff));
|
||||
const auto* psections = (elf32_phdr*)(data + ByteSwap(header->e_phoff));
|
||||
|
||||
for (size_t i = 0; i < numpSections; i++)
|
||||
{
|
||||
if (psections[i].p_type == std::byteswap((Elf32_Word)PT_LOAD))
|
||||
if (psections[i].p_type == ByteSwap((Elf32_Word)PT_LOAD))
|
||||
{
|
||||
image.base = std::byteswap(psections[i].p_vaddr);
|
||||
image.base = ByteSwap(psections[i].p_vaddr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto* stringTable = reinterpret_cast<const char*>(data + std::byteswap(sections[stringTableIndex].sh_offset));
|
||||
auto* stringTable = reinterpret_cast<const char*>(data + ByteSwap(sections[stringTableIndex].sh_offset));
|
||||
|
||||
for (size_t i = 0; i < numSections; i++)
|
||||
{
|
||||
@@ -82,16 +82,16 @@ Image ElfLoadImage(const uint8_t* data, size_t size)
|
||||
|
||||
uint8_t flags{};
|
||||
|
||||
if (section.sh_flags & std::byteswap(SHF_EXECINSTR))
|
||||
if (section.sh_flags & ByteSwap(SHF_EXECINSTR))
|
||||
{
|
||||
flags |= SectionFlags_Code;
|
||||
}
|
||||
|
||||
auto* name = section.sh_name != 0 ? stringTable + std::byteswap(section.sh_name) : nullptr;
|
||||
const auto rva = std::byteswap(section.sh_addr) - image.base;
|
||||
const auto size = std::byteswap(section.sh_size);
|
||||
auto* name = section.sh_name != 0 ? stringTable + ByteSwap(section.sh_name) : nullptr;
|
||||
const auto rva = ByteSwap(section.sh_addr) - image.base;
|
||||
const auto size = ByteSwap(section.sh_size);
|
||||
|
||||
image.Map(name, rva, size, flags, image.data.get() + std::byteswap(section.sh_offset));
|
||||
image.Map(name, rva, size, flags, image.data.get() + ByteSwap(section.sh_offset));
|
||||
}
|
||||
|
||||
return image;
|
||||
|
Reference in New Issue
Block a user