diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 623555f70e..365b60d005 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -48,47 +48,47 @@ namespace fmt // the stream `os`. Then write `arg` to to the stream. If there's no // `fmt::placeholder` after `pos` everything in `fmt` after pos is written // to `os`. Then `arg` is written to `os` after appending a space character - template - empty_t write(const std::string &fmt, std::ostream &os, std::string::size_type &pos, T &&arg) - { - std::string::size_type ins = fmt.find(placeholder, pos); + //template + //empty_t write(const std::string &fmt, std::ostream &os, std::string::size_type &pos, T &&arg) + //{ + // std::string::size_type ins = fmt.find(placeholder, pos); - if (ins == std::string::npos) - { - os.write(fmt.data() + pos, fmt.size() - pos); - os << ' ' << arg; + // if (ins == std::string::npos) + // { + // os.write(fmt.data() + pos, fmt.size() - pos); + // os << ' ' << arg; - pos = fmt.size(); - } - else - { - os.write(fmt.data() + pos, ins - pos); - os << arg; + // pos = fmt.size(); + // } + // else + // { + // os.write(fmt.data() + pos, ins - pos); + // os << arg; - pos = ins + placeholder.size(); - } - return{}; - } + // pos = ins + placeholder.size(); + // } + // return{}; + //} // typesafe version of a sprintf-like function. Returns the printed to // string. To mark positions where the arguments are supposed to be // inserted use `fmt::placeholder`. If there's not enough placeholders // the rest of the arguments are appended at the end, seperated by spaces - template - std::string SFormat(const std::string &fmt, Args&& ... parameters) - { - std::ostringstream os; - std::string::size_type pos = 0; - std::initializer_list { write(fmt, os, pos, parameters)... }; + //template + //std::string SFormat(const std::string &fmt, Args&& ... parameters) + //{ + // std::ostringstream os; + // std::string::size_type pos = 0; + // std::initializer_list { write(fmt, os, pos, parameters)... }; - if (!fmt.empty()) - { - os.write(fmt.data() + pos, fmt.size() - pos); - } + // if (!fmt.empty()) + // { + // os.write(fmt.data() + pos, fmt.size() - pos); + // } - std::string result = os.str(); - return result; - } + // std::string result = os.str(); + // return result; + //} //small wrapper used to deal with bitfields template diff --git a/Utilities/rFile.cpp b/Utilities/rFile.cpp index 0e1cbd1b71..d5c4768444 100644 --- a/Utilities/rFile.cpp +++ b/Utilities/rFile.cpp @@ -92,17 +92,11 @@ bool truncate_file(const std::string& file, uint64_t length) bool get_file_info(const std::string& path, FileInfo& info) { - info.name = path; - - info.exists = false; - info.isDirectory = false; - info.isWritable = false; - info.size = 0; - #ifdef _WIN32 WIN32_FILE_ATTRIBUTE_DATA attrs; if (!GetFileAttributesExW(ConvertUTF8ToWChar(path).get(), GetFileExInfoStandard, &attrs)) { + info = {}; return false; } @@ -117,6 +111,7 @@ bool get_file_info(const std::string& path, FileInfo& info) struct stat64 file_info; if (stat64(path.c_str(), &file_info) < 0) { + info = {}; return false; } @@ -128,7 +123,6 @@ bool get_file_info(const std::string& path, FileInfo& info) info.mtime = file_info.st_mtime; info.ctime = file_info.st_ctime; #endif - return true; } @@ -460,19 +454,13 @@ bool rfile_t::trunc(u64 size) const bool rfile_t::stat(FileInfo& info) const { - info.name.clear(); // possibly, TODO - - info.exists = false; - info.isDirectory = false; - info.isWritable = false; - info.size = 0; - #ifdef _WIN32 FILE_BASIC_INFO basic_info; //FILE_NAME_INFO name_info; if (!GetFileInformationByHandleEx(fd, FileBasicInfo, &basic_info, sizeof(FILE_BASIC_INFO))) { + info = {}; return false; } @@ -487,10 +475,7 @@ bool rfile_t::stat(FileInfo& info) const struct stat64 file_info; if (fstat64(fd, &file_info) < 0) { - info.exists = false; - info.isDirectory = false; - info.isWritable = false; - info.size = 0; + info = {}; return false; } @@ -502,7 +487,6 @@ bool rfile_t::stat(FileInfo& info) const info.mtime = file_info.st_mtime; info.ctime = file_info.st_ctime; #endif - return true; } diff --git a/Utilities/rFile.h b/Utilities/rFile.h index 70d6d4eb32..208f320ec8 100644 --- a/Utilities/rFile.h +++ b/Utilities/rFile.h @@ -2,7 +2,6 @@ struct FileInfo { - std::string name; bool exists; bool isDirectory; bool isWritable; @@ -50,29 +49,33 @@ struct rfile_t final private: handle_type fd; +#ifndef _WIN32 + handle_type pad; +#endif + public: rfile_t(); ~rfile_t(); explicit rfile_t(const std::string& filename, u32 mode = o_read); rfile_t(const rfile_t&) = delete; - rfile_t(rfile_t&&) = delete; + rfile_t(rfile_t&&) = delete; // possibly TODO rfile_t& operator =(const rfile_t&) = delete; - rfile_t& operator =(rfile_t&&) = delete; + rfile_t& operator =(rfile_t&&) = delete; // possibly TODO - operator bool() const; + operator bool() const; // check is_opened() + + void import(handle_type fd); // replace file handle - void import(handle_type fd); bool open(const std::string& filename, u32 mode = o_read); - bool is_opened() const; - bool trunc(u64 size) const; - bool stat(FileInfo& info) const; + bool is_opened() const; // check whether the file is opened + bool trunc(u64 size) const; // change file size (possibly appending zero bytes) + bool stat(FileInfo& info) const; // get file info bool close(); u64 read(void* buffer, u64 count) const; u64 write(const void* buffer, u64 count) const; - //u64 write(const std::string& str) const; u64 seek(u64 offset, u32 mode = from_begin) const; u64 size() const; }; @@ -105,109 +108,3 @@ struct rFileName void *handle; }; - -// TODO: eliminate this: - -template __forceinline u8 Read8(T& f) -{ - u8 ret; - f.Read(&ret, sizeof(ret)); - return ret; -} - -template __forceinline u16 Read16(T& f) -{ - be_t ret; - f.Read(&ret, sizeof(ret)); - return ret; -} - -template __forceinline u32 Read32(T& f) -{ - be_t ret; - f.Read(&ret, sizeof(ret)); - return ret; -} - -template __forceinline u64 Read64(T& f) -{ - be_t ret; - f.Read(&ret, sizeof(ret)); - return ret; -} - -template __forceinline u16 Read16LE(T& f) -{ - u16 ret; - f.Read(&ret, sizeof(ret)); - return ret; -} - -template __forceinline u32 Read32LE(T& f) -{ - u32 ret; - f.Read(&ret, sizeof(ret)); - return ret; -} - -template __forceinline u64 Read64LE(T& f) -{ - u64 ret; - f.Read(&ret, sizeof(ret)); - return ret; -} - -template __forceinline void Write8(T& f, const u8 data) -{ - f.Write(&data, sizeof(data)); -} - -__forceinline void Write8(const rfile_t& f, const u8 data) -{ - f.write(&data, sizeof(data)); -} - -template __forceinline void Write16LE(T& f, const u16 data) -{ - f.Write(&data, sizeof(data)); -} - -__forceinline void Write16LE(const rfile_t& f, const u16 data) -{ - f.write(&data, sizeof(data)); -} - -template __forceinline void Write32LE(T& f, const u32 data) -{ - f.Write(&data, sizeof(data)); -} - -__forceinline void Write32LE(const rfile_t& f, const u32 data) -{ - f.write(&data, sizeof(data)); -} - -template __forceinline void Write64LE(T& f, const u64 data) -{ - f.Write(&data, sizeof(data)); -} - -__forceinline void Write64LE(const rfile_t& f, const u64 data) -{ - f.write(&data, sizeof(data)); -} - -template __forceinline void Write16(T& f, const u16 data) -{ - Write16LE(f, re16(data)); -} - -template __forceinline void Write32(T& f, const u32 data) -{ - Write32LE(f, re32(data)); -} - -template __forceinline void Write64(T& f, const u64 data) -{ - Write64LE(f, re64(data)); -} diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index f9b33c3abc..59a755d30b 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -10,6 +10,124 @@ #include #include +__forceinline u8 Read8(vfsStream& f) +{ + u8 ret; + f.Read(&ret, sizeof(ret)); + return ret; +} + +__forceinline u16 Read16(vfsStream& f) +{ + be_t ret; + f.Read(&ret, sizeof(ret)); + return ret; +} + +__forceinline u32 Read32(vfsStream& f) +{ + be_t ret; + f.Read(&ret, sizeof(ret)); + return ret; +} + +__forceinline u64 Read64(vfsStream& f) +{ + be_t ret; + f.Read(&ret, sizeof(ret)); + return ret; +} + +__forceinline u16 Read16LE(vfsStream& f) +{ + u16 ret; + f.Read(&ret, sizeof(ret)); + return ret; +} + +__forceinline u32 Read32LE(vfsStream& f) +{ + u32 ret; + f.Read(&ret, sizeof(ret)); + return ret; +} + +__forceinline u64 Read64LE(vfsStream& f) +{ + u64 ret; + f.Read(&ret, sizeof(ret)); + return ret; +} + +__forceinline void Write8(vfsStream& f, const u8 data) +{ + f.Write(&data, sizeof(data)); +} + +__forceinline void Write8(const rfile_t& f, const u8 data) +{ + f.write(&data, sizeof(data)); +} + +__forceinline void Write16LE(vfsStream& f, const u16 data) +{ + f.Write(&data, sizeof(data)); +} + +__forceinline void Write16LE(const rfile_t& f, const u16 data) +{ + f.write(&data, sizeof(data)); +} + +__forceinline void Write32LE(vfsStream& f, const u32 data) +{ + f.Write(&data, sizeof(data)); +} + +__forceinline void Write32LE(const rfile_t& f, const u32 data) +{ + f.write(&data, sizeof(data)); +} + +__forceinline void Write64LE(vfsStream& f, const u64 data) +{ + f.Write(&data, sizeof(data)); +} + +__forceinline void Write64LE(const rfile_t& f, const u64 data) +{ + f.write(&data, sizeof(data)); +} + +__forceinline void Write16(vfsStream& f, const u16 data) +{ + Write16LE(f, re16(data)); +} + +__forceinline void Write16(const rfile_t& f, const u16 data) +{ + Write16LE(f, re16(data)); +} + +__forceinline void Write32(vfsStream& f, const u32 data) +{ + Write32LE(f, re32(data)); +} + +__forceinline void Write32(const rfile_t& f, const u32 data) +{ + Write32LE(f, re32(data)); +} + +__forceinline void Write64(vfsStream& f, const u64 data) +{ + Write64LE(f, re64(data)); +} + +__forceinline void Write64(const rfile_t& f, const u64 data) +{ + Write64LE(f, re64(data)); +} void WriteEhdr(const rfile_t& f, Elf64_Ehdr& ehdr) { @@ -413,8 +531,164 @@ void SelfSection::Load(vfsStream& f) offset = Read64(f); } +void Elf32_Ehdr::Load(vfsStream& f) +{ + e_magic = Read32(f); + e_class = Read8(f); + e_data = Read8(f); + e_curver = Read8(f); + e_os_abi = Read8(f); + + if (IsLittleEndian()) + { + e_abi_ver = Read64LE(f); + e_type = Read16LE(f); + e_machine = Read16LE(f); + e_version = Read32LE(f); + e_entry = Read32LE(f); + e_phoff = Read32LE(f); + e_shoff = Read32LE(f); + e_flags = Read32LE(f); + e_ehsize = Read16LE(f); + e_phentsize = Read16LE(f); + e_phnum = Read16LE(f); + e_shentsize = Read16LE(f); + e_shnum = Read16LE(f); + e_shstrndx = Read16LE(f); + } + else + { + e_abi_ver = Read64(f); + e_type = Read16(f); + e_machine = Read16(f); + e_version = Read32(f); + e_entry = Read32(f); + e_phoff = Read32(f); + e_shoff = Read32(f); + e_flags = Read32(f); + e_ehsize = Read16(f); + e_phentsize = Read16(f); + e_phnum = Read16(f); + e_shentsize = Read16(f); + e_shnum = Read16(f); + e_shstrndx = Read16(f); + } +} + +void Elf32_Shdr::Load(vfsStream& f) +{ + sh_name = Read32(f); + sh_type = Read32(f); + sh_flags = Read32(f); + sh_addr = Read32(f); + sh_offset = Read32(f); + sh_size = Read32(f); + sh_link = Read32(f); + sh_info = Read32(f); + sh_addralign = Read32(f); + sh_entsize = Read32(f); +} + +void Elf32_Shdr::LoadLE(vfsStream& f) +{ + f.Read(this, sizeof(*this)); +} + +void Elf32_Phdr::Load(vfsStream& f) +{ + p_type = Read32(f); + p_offset = Read32(f); + p_vaddr = Read32(f); + p_paddr = Read32(f); + p_filesz = Read32(f); + p_memsz = Read32(f); + p_flags = Read32(f); + p_align = Read32(f); +} + +void Elf32_Phdr::LoadLE(vfsStream& f) +{ + f.Read(this, sizeof(*this)); +} + +void Elf64_Ehdr::Load(vfsStream& f) +{ + e_magic = Read32(f); + e_class = Read8(f); + e_data = Read8(f); + e_curver = Read8(f); + e_os_abi = Read8(f); + e_abi_ver = Read64(f); + e_type = Read16(f); + e_machine = Read16(f); + e_version = Read32(f); + e_entry = Read64(f); + e_phoff = Read64(f); + e_shoff = Read64(f); + e_flags = Read32(f); + e_ehsize = Read16(f); + e_phentsize = Read16(f); + e_phnum = Read16(f); + e_shentsize = Read16(f); + e_shnum = Read16(f); + e_shstrndx = Read16(f); +} + +void Elf64_Shdr::Load(vfsStream& f) +{ + sh_name = Read32(f); + sh_type = Read32(f); + sh_flags = Read64(f); + sh_addr = Read64(f); + sh_offset = Read64(f); + sh_size = Read64(f); + sh_link = Read32(f); + sh_info = Read32(f); + sh_addralign = Read64(f); + sh_entsize = Read64(f); +} + +void Elf64_Phdr::Load(vfsStream& f) +{ + p_type = Read32(f); + p_flags = Read32(f); + p_offset = Read64(f); + p_vaddr = Read64(f); + p_paddr = Read64(f); + p_filesz = Read64(f); + p_memsz = Read64(f); + p_align = Read64(f); +} + +void SceHeader::Load(vfsStream& f) +{ + se_magic = Read32(f); + se_hver = Read32(f); + se_flags = Read16(f); + se_type = Read16(f); + se_meta = Read32(f); + se_hsize = Read64(f); + se_esize = Read64(f); +} + +void SelfHeader::Load(vfsStream& f) +{ + se_htype = Read64(f); + se_appinfooff = Read64(f); + se_elfoff = Read64(f); + se_phdroff = Read64(f); + se_shdroff = Read64(f); + se_secinfoff = Read64(f); + se_sceveroff = Read64(f); + se_controloff = Read64(f); + se_controlsize = Read64(f); + pad = Read64(f); +} + SELFDecrypter::SELFDecrypter(vfsStream& s) - : self_f(s), key_v(), data_buf_length(0) + : self_f(s) + , key_v() + , data_buf_length(0) { } diff --git a/rpcs3/Crypto/unself.h b/rpcs3/Crypto/unself.h index 787fc00c7b..337a933f4a 100644 --- a/rpcs3/Crypto/unself.h +++ b/rpcs3/Crypto/unself.h @@ -1,186 +1,187 @@ #pragma once - -#include "Loader/ELF64.h" -#include "Loader/ELF32.h" #include "key_vault.h" +struct vfsStream; + struct AppInfo { - u64 authid; - u32 vendor_id; - u32 self_type; - u64 version; - u64 padding; + u64 authid; + u32 vendor_id; + u32 self_type; + u64 version; + u64 padding; - void Load(vfsStream& f); - - void Show(); + void Load(vfsStream& f); + void Show(); }; struct SectionInfo { - u64 offset; - u64 size; - u32 compressed; - u32 unknown1; - u32 unknown2; - u32 encrypted; + u64 offset; + u64 size; + u32 compressed; + u32 unknown1; + u32 unknown2; + u32 encrypted; - void Load(vfsStream& f); - - void Show(); + void Load(vfsStream& f); + void Show(); }; struct SCEVersionInfo { - u32 subheader_type; - u32 present; - u32 size; - u32 unknown; + u32 subheader_type; + u32 present; + u32 size; + u32 unknown; - void Load(vfsStream& f); - - void Show(); + void Load(vfsStream& f); + void Show(); }; struct ControlInfo { - u32 type; - u32 size; - u64 next; + u32 type; + u32 size; + u64 next; - union { - // type 1 0x30 bytes - struct { - u32 ctrl_flag1; - u32 unknown1; - u32 unknown2; - u32 unknown3; - u32 unknown4; - u32 unknown5; - u32 unknown6; - u32 unknown7; - } control_flags; + union + { + // type 1 0x30 bytes + struct + { + u32 ctrl_flag1; + u32 unknown1; + u32 unknown2; + u32 unknown3; + u32 unknown4; + u32 unknown5; + u32 unknown6; + u32 unknown7; - // type 2 0x30 bytes - struct { - u8 digest[20]; - u64 unknown; - } file_digest_30; + } control_flags; - // type 2 0x40 bytes - struct { - u8 digest1[20]; - u8 digest2[20]; - u64 unknown; - } file_digest_40; + // type 2 0x30 bytes + struct + { + u8 digest[20]; + u64 unknown; - // type 3 0x90 bytes - struct { - u32 magic; - u32 unknown1; - u32 license; - u32 type; - u8 content_id[48]; - u8 digest[16]; - u8 invdigest[16]; - u8 xordigest[16]; - u64 unknown2; - u64 unknown3; - } npdrm; - }; + } file_digest_30; - void Load(vfsStream& f); + // type 2 0x40 bytes + struct + { + u8 digest1[20]; + u8 digest2[20]; + u64 unknown; - void Show(); + } file_digest_40; + + // type 3 0x90 bytes + struct + { + u32 magic; + u32 unknown1; + u32 license; + u32 type; + u8 content_id[48]; + u8 digest[16]; + u8 invdigest[16]; + u8 xordigest[16]; + u64 unknown2; + u64 unknown3; + + } npdrm; + }; + + void Load(vfsStream& f); + void Show(); }; struct MetadataInfo { - u8 key[0x10]; - u8 key_pad[0x10]; - u8 iv[0x10]; - u8 iv_pad[0x10]; + u8 key[0x10]; + u8 key_pad[0x10]; + u8 iv[0x10]; + u8 iv_pad[0x10]; - void Load(u8* in); - - void Show(); + void Load(u8* in); + void Show(); }; struct MetadataHeader { - u64 signature_input_length; - u32 unknown1; - u32 section_count; - u32 key_count; - u32 opt_header_size; - u32 unknown2; - u32 unknown3; + u64 signature_input_length; + u32 unknown1; + u32 section_count; + u32 key_count; + u32 opt_header_size; + u32 unknown2; + u32 unknown3; - void Load(u8* in); - - void Show(); + void Load(u8* in); + void Show(); }; struct MetadataSectionHeader { - u64 data_offset; - u64 data_size; - u32 type; - u32 program_idx; - u32 hashed; - u32 sha1_idx; - u32 encrypted; - u32 key_idx; - u32 iv_idx; - u32 compressed; + u64 data_offset; + u64 data_size; + u32 type; + u32 program_idx; + u32 hashed; + u32 sha1_idx; + u32 encrypted; + u32 key_idx; + u32 iv_idx; + u32 compressed; - void Load(u8* in); - - void Show(); + void Load(u8* in); + void Show(); }; struct SectionHash { - u8 sha1[20]; - u8 padding[12]; - u8 hmac_key[64]; + u8 sha1[20]; + u8 padding[12]; + u8 hmac_key[64]; - void Load(vfsStream& f); + void Load(vfsStream& f); }; struct CapabilitiesInfo { - u32 type; - u32 capabilities_size; - u32 next; - u32 unknown1; - u64 unknown2; - u64 unknown3; - u64 flags; - u32 unknown4; - u32 unknown5; + u32 type; + u32 capabilities_size; + u32 next; + u32 unknown1; + u64 unknown2; + u64 unknown3; + u64 flags; + u32 unknown4; + u32 unknown5; - void Load(vfsStream& f); + void Load(vfsStream& f); }; struct Signature { - u8 r[21]; - u8 s[21]; - u8 padding[6]; + u8 r[21]; + u8 s[21]; + u8 padding[6]; - void Load(vfsStream& f); + void Load(vfsStream& f); }; struct SelfSection { - u8 *data; - u64 size; - u64 offset; + u8 *data; + u64 size; + u64 offset; - void Load(vfsStream& f); + void Load(vfsStream& f); }; struct Elf32_Ehdr @@ -204,55 +205,10 @@ struct Elf32_Ehdr u16 e_shentsize; u16 e_shnum; u16 e_shstrndx; + + void Load(vfsStream& f); void Show() {} - bool IsLittleEndian() const - { - return e_data == 1; - } - - void Load(vfsStream& f) - { - e_magic = Read32(f); - e_class = Read8(f); - e_data = Read8(f); - e_curver = Read8(f); - e_os_abi = Read8(f); - - if (IsLittleEndian()) - { - e_abi_ver = Read64LE(f); - e_type = Read16LE(f); - e_machine = Read16LE(f); - e_version = Read32LE(f); - e_entry = Read32LE(f); - e_phoff = Read32LE(f); - e_shoff = Read32LE(f); - e_flags = Read32LE(f); - e_ehsize = Read16LE(f); - e_phentsize = Read16LE(f); - e_phnum = Read16LE(f); - e_shentsize = Read16LE(f); - e_shnum = Read16LE(f); - e_shstrndx = Read16LE(f); - } - else - { - e_abi_ver = Read64(f); - e_type = Read16(f); - e_machine = Read16(f); - e_version = Read32(f); - e_entry = Read32(f); - e_phoff = Read32(f); - e_shoff = Read32(f); - e_flags = Read32(f); - e_ehsize = Read16(f); - e_phentsize = Read16(f); - e_phnum = Read16(f); - e_shentsize = Read16(f); - e_shnum = Read16(f); - e_shstrndx = Read16(f); - } - } + bool IsLittleEndian() const { return e_data == 1; } bool CheckMagic() const { return e_magic == 0x7F454C46; } u32 GetEntry() const { return e_entry; } }; @@ -269,25 +225,12 @@ struct Elf32_Shdr u32 sh_info; u32 sh_addralign; u32 sh_entsize; - void Load(vfsStream& f) - { - sh_name = Read32(f); - sh_type = Read32(f); - sh_flags = Read32(f); - sh_addr = Read32(f); - sh_offset = Read32(f); - sh_size = Read32(f); - sh_link = Read32(f); - sh_info = Read32(f); - sh_addralign = Read32(f); - sh_entsize = Read32(f); - } - void LoadLE(vfsStream& f) - { - f.Read(this, sizeof(*this)); - } + + void Load(vfsStream& f); + void LoadLE(vfsStream& f); void Show() {} }; + struct Elf32_Phdr { u32 p_type; @@ -298,21 +241,9 @@ struct Elf32_Phdr u32 p_memsz; u32 p_flags; u32 p_align; - void Load(vfsStream& f) - { - p_type = Read32(f); - p_offset = Read32(f); - p_vaddr = Read32(f); - p_paddr = Read32(f); - p_filesz = Read32(f); - p_memsz = Read32(f); - p_flags = Read32(f); - p_align = Read32(f); - } - void LoadLE(vfsStream& f) - { - f.Read(this, sizeof(*this)); - } + + void Load(vfsStream& f); + void LoadLE(vfsStream& f); void Show() {} }; @@ -337,28 +268,8 @@ struct Elf64_Ehdr u16 e_shentsize; u16 e_shnum; u16 e_shstrndx; - void Load(vfsStream& f) - { - e_magic = Read32(f); - e_class = Read8(f); - e_data = Read8(f); - e_curver = Read8(f); - e_os_abi = Read8(f); - e_abi_ver = Read64(f); - e_type = Read16(f); - e_machine = Read16(f); - e_version = Read32(f); - e_entry = Read64(f); - e_phoff = Read64(f); - e_shoff = Read64(f); - e_flags = Read32(f); - e_ehsize = Read16(f); - e_phentsize = Read16(f); - e_phnum = Read16(f); - e_shentsize = Read16(f); - e_shnum = Read16(f); - e_shstrndx = Read16(f); - } + + void Load(vfsStream& f); void Show() {} bool CheckMagic() const { return e_magic == 0x7F454C46; } u64 GetEntry() const { return e_entry; } @@ -376,19 +287,8 @@ struct Elf64_Shdr u32 sh_info; u64 sh_addralign; u64 sh_entsize; - void Load(vfsStream& f) - { - sh_name = Read32(f); - sh_type = Read32(f); - sh_flags = Read64(f); - sh_addr = Read64(f); - sh_offset = Read64(f); - sh_size = Read64(f); - sh_link = Read32(f); - sh_info = Read32(f); - sh_addralign = Read64(f); - sh_entsize = Read64(f); - } + + void Load(vfsStream& f); void Show(){} }; @@ -402,17 +302,8 @@ struct Elf64_Phdr u64 p_filesz; u64 p_memsz; u64 p_align; - void Load(vfsStream& f) - { - p_type = Read32(f); - p_flags = Read32(f); - p_offset = Read64(f); - p_vaddr = Read64(f); - p_paddr = Read64(f); - p_filesz = Read64(f); - p_memsz = Read64(f); - p_align = Read64(f); - } + + void Load(vfsStream& f); void Show(){} }; @@ -425,16 +316,8 @@ struct SceHeader u32 se_meta; u64 se_hsize; u64 se_esize; - void Load(vfsStream& f) - { - se_magic = Read32(f); - se_hver = Read32(f); - se_flags = Read16(f); - se_type = Read16(f); - se_meta = Read32(f); - se_hsize = Read64(f); - se_esize = Read64(f); - } + + void Load(vfsStream& f); void Show(){} bool CheckMagic() const { return se_magic == 0x53434500; } }; @@ -451,23 +334,11 @@ struct SelfHeader u64 se_controloff; u64 se_controlsize; u64 pad; - void Load(vfsStream& f) - { - se_htype = Read64(f); - se_appinfooff = Read64(f); - se_elfoff = Read64(f); - se_phdroff = Read64(f); - se_shdroff = Read64(f); - se_secinfoff = Read64(f); - se_sceveroff = Read64(f); - se_controloff = Read64(f); - se_controlsize = Read64(f); - pad = Read64(f); - } + + void Load(vfsStream& f); void Show(){} }; - class SELFDecrypter { // Main SELF file stream. diff --git a/rpcs3/Emu/FS/vfsFileBase.h b/rpcs3/Emu/FS/vfsFileBase.h index fd0662f365..9639d76992 100644 --- a/rpcs3/Emu/FS/vfsFileBase.h +++ b/rpcs3/Emu/FS/vfsFileBase.h @@ -20,19 +20,15 @@ protected: public: vfsFileBase(vfsDevice* device); - virtual ~vfsFileBase(); + virtual ~vfsFileBase() override; virtual bool Open(const std::string& path, u32 mode); virtual bool Close() override; virtual bool Exists(const std::string& path) { return false; } virtual bool Rename(const std::string& from, const std::string& to) { return false; } virtual bool Remove(const std::string& path) { return false; } + virtual bool IsOpened() const override { return !m_path.empty(); } std::string GetPath() const; u32 GetOpenMode() const; - - virtual bool IsOpened() const override - { - return !m_path.empty(); - } }; diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index d7533e4374..e0f3131e18 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -28,6 +28,8 @@ #include "Emu/Event.h" #include "Loader/PSF.h" +#include "Loader/ELF64.h" +#include "Loader/ELF32.h" #include "../Crypto/unself.h" #include diff --git a/rpcs3/Gui/AutoPauseManager.h b/rpcs3/Gui/AutoPauseManager.h index c3b207b237..1579eeba67 100644 --- a/rpcs3/Gui/AutoPauseManager.h +++ b/rpcs3/Gui/AutoPauseManager.h @@ -1,4 +1,5 @@ #pragma once +#include class AutoPauseManagerDialog : public wxDialog { @@ -37,4 +38,4 @@ public: AutoPauseSettingsDialog(wxWindow* parent, u32 *entry); void OnOk(wxCommandEvent& event); void OnUpdateValue(wxCommandEvent& event); -}; \ No newline at end of file +}; diff --git a/rpcs3/Gui/SaveDataDialog.h b/rpcs3/Gui/SaveDataDialog.h index 8ca49ec487..9a0650e1ed 100644 --- a/rpcs3/Gui/SaveDataDialog.h +++ b/rpcs3/Gui/SaveDataDialog.h @@ -1,5 +1,4 @@ #pragma once - #include "Emu/SysCalls/Modules/cellSaveData.h" class SaveDataDialogFrame : public SaveDataDialogInstance diff --git a/rpcs3/Gui/SaveDataUtility.h b/rpcs3/Gui/SaveDataUtility.h index 38a9bbbd1b..a96fdd4aeb 100644 --- a/rpcs3/Gui/SaveDataUtility.h +++ b/rpcs3/Gui/SaveDataUtility.h @@ -1,4 +1,5 @@ #pragma once +#include //TODO: Implement function calls related to Save Data List. //Those function calls may be needed to use this GUI. diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index 80e2f90be3..b6a071cf0e 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -31,8 +31,6 @@ #include #include #include -#include -#include #include #include #include