Skip to content

Commit

Permalink
Implemented LLE Modules Manager (draft)
Browse files Browse the repository at this point in the history
Improved loader core.
Implemented *_thread wrappers.
Minor fixes.
Temporary disabled ELF Compiler & DisAsm frame.
  • Loading branch information
DHrpcs3 committed Nov 19, 2014
1 parent 1d61484 commit 598d929
Show file tree
Hide file tree
Showing 57 changed files with 2,807 additions and 2,767 deletions.
114 changes: 43 additions & 71 deletions Utilities/BEType.h
Expand Up @@ -451,7 +451,13 @@ template<typename T, typename T2 = T>
class be_t
{
static_assert(sizeof(T2) == 1 || sizeof(T2) == 2 || sizeof(T2) == 4 || sizeof(T2) == 8, "Bad be_t type");
T m_data;

public:
typedef typename std::remove_cv<T>::type type;
static const bool is_le_machine = true;

private:
type m_data;

template<typename Tto, typename Tfrom, int mode>
struct _convert
Expand Down Expand Up @@ -482,55 +488,77 @@ class be_t
return (be_t<Tto>&)res;
}
};

public:
typedef T type;

const T& ToBE() const
{
return m_data;
}

T ToLE() const
type ToLE() const
{
return se_t<T, sizeof(T2)>::func(m_data);
}

void FromBE(const T& value)
void FromBE(const type& value)
{
m_data = value;
}

void FromLE(const T& value)
void FromLE(const type& value)
{
m_data = se_t<T, sizeof(T2)>::func(value);
}

static be_t make(const T value)
static be_t MakeFromLE(const type value)
{
T data = se_t<T, sizeof(T2)>::func(value);
type data = se_t<type, sizeof(T2)>::func(value);
return (be_t&)data;
}

//template<typename T1>
operator const T() const
static be_t MakeFromBE(const type value)
{
return ToLE();
return (be_t&)value;
}

be_t& operator = (const be_t& value) = default;
//make be_t from current machine byte ordering
static be_t make(const type value)
{
return is_le_machine ? MakeFromLE(value) : MakeFromBE(value);
}

be_t& operator = (T value)
//get value in current machine byte ordering
__forceinline type value() const
{
return is_le_machine ? ToLE() : ToBE();
}

be_t() = default;
be_t(const be_t& value) = default;

be_t(type value)
{
m_data = se_t<T, sizeof(T2)>::func(value);
}

be_t& operator = (const be_t& value) = default;

be_t& operator = (type value)
{
m_data = se_t<type, sizeof(T2)>::func(value);

return *this;
}

operator type() const
{
return value();
}

template<typename T1>
operator const be_t<T1>() const
{
return be_t<T1>::make(ToLE());
//return _convert<T1, T, ((sizeof(T1) > sizeof(T)) ? 1 : (sizeof(T1) < sizeof(T) ? 2 : 0))>::func(m_data);
return _convert<T1, T, ((sizeof(T1) > sizeof(T)) ? 1 : (sizeof(T1) < sizeof(T) ? 2 : 0))>::func(m_data);
}

template<typename T1> be_t& operator += (T1 right) { return *this = T(*this) + right; }
Expand Down Expand Up @@ -577,62 +605,6 @@ class be_t
be_t& operator-- () { *this -= 1; return *this; }
};

template<typename T, typename T2>
class be_t<const T, T2>
{
static_assert(sizeof(T2) == 1 || sizeof(T2) == 2 || sizeof(T2) == 4 || sizeof(T2) == 8, "Bad be_t type");
const T m_data;

public:
typedef const T type;

const T& ToBE() const
{
return m_data;
}

const T ToLE() const
{
return se_t<const T, sizeof(T2)>::func(m_data);
}

static be_t make(const T value)
{
const T data = se_t<const T, sizeof(T2)>::func(value);
return (be_t&)data;
}

//template<typename T1>
operator const T() const
{
return ToLE();
}

template<typename T1>
operator const be_t<T1>() const
{
return be_t<T1>::make(ToLE());
}

template<typename T1> be_t operator & (const be_t<T1>& right) const { const T res = ToBE() & right.ToBE(); return (be_t&)res; }
template<typename T1> be_t operator | (const be_t<T1>& right) const { const T res = ToBE() | right.ToBE(); return (be_t&)res; }
template<typename T1> be_t operator ^ (const be_t<T1>& right) const { const T res = ToBE() ^ right.ToBE(); return (be_t&)res; }

template<typename T1> bool operator == (T1 right) const { return (T1)ToLE() == right; }
template<typename T1> bool operator != (T1 right) const { return !(*this == right); }
template<typename T1> bool operator > (T1 right) const { return (T1)ToLE() > right; }
template<typename T1> bool operator < (T1 right) const { return (T1)ToLE() < right; }
template<typename T1> bool operator >= (T1 right) const { return (T1)ToLE() >= right; }
template<typename T1> bool operator <= (T1 right) const { return (T1)ToLE() <= right; }

template<typename T1> bool operator == (const be_t<T1>& right) const { return ToBE() == right.ToBE(); }
template<typename T1> bool operator != (const be_t<T1>& right) const { return !(*this == right); }
template<typename T1> bool operator > (const be_t<T1>& right) const { return (T1)ToLE() > right.ToLE(); }
template<typename T1> bool operator < (const be_t<T1>& right) const { return (T1)ToLE() < right.ToLE(); }
template<typename T1> bool operator >= (const be_t<T1>& right) const { return (T1)ToLE() >= right.ToLE(); }
template<typename T1> bool operator <= (const be_t<T1>& right) const { return (T1)ToLE() <= right.ToLE(); }
};

template<typename T, typename T2 = T>
struct is_be_t : public std::integral_constant<bool, false> {};

Expand Down
95 changes: 95 additions & 0 deletions rpcs3/Crypto/unself.cpp
Expand Up @@ -10,6 +10,101 @@
#include <wx/mstream.h>
#include <wx/zstream.h>


void WriteEhdr(rFile& f, Elf64_Ehdr& ehdr)
{
Write32(f, ehdr.e_magic);
Write8(f, ehdr.e_class);
Write8(f, ehdr.e_data);
Write8(f, ehdr.e_curver);
Write8(f, ehdr.e_os_abi);
Write64(f, ehdr.e_abi_ver);
Write16(f, ehdr.e_type);
Write16(f, ehdr.e_machine);
Write32(f, ehdr.e_version);
Write64(f, ehdr.e_entry);
Write64(f, ehdr.e_phoff);
Write64(f, ehdr.e_shoff);
Write32(f, ehdr.e_flags);
Write16(f, ehdr.e_ehsize);
Write16(f, ehdr.e_phentsize);
Write16(f, ehdr.e_phnum);
Write16(f, ehdr.e_shentsize);
Write16(f, ehdr.e_shnum);
Write16(f, ehdr.e_shstrndx);
}
void WritePhdr(rFile& f, Elf64_Phdr& phdr)
{
Write32(f, phdr.p_type);
Write32(f, phdr.p_flags);
Write64(f, phdr.p_offset);
Write64(f, phdr.p_vaddr);
Write64(f, phdr.p_paddr);
Write64(f, phdr.p_filesz);
Write64(f, phdr.p_memsz);
Write64(f, phdr.p_align);
}
void WriteShdr(rFile& f, Elf64_Shdr& shdr)
{
Write32(f, shdr.sh_name);
Write32(f, shdr.sh_type);
Write64(f, shdr.sh_flags);
Write64(f, shdr.sh_addr);
Write64(f, shdr.sh_offset);
Write64(f, shdr.sh_size);
Write32(f, shdr.sh_link);
Write32(f, shdr.sh_info);
Write64(f, shdr.sh_addralign);
Write64(f, shdr.sh_entsize);
}
void WriteEhdr(rFile& f, Elf32_Ehdr& ehdr)
{
Write32(f, ehdr.e_magic);
Write8(f, ehdr.e_class);
Write8(f, ehdr.e_data);
Write8(f, ehdr.e_curver);
Write8(f, ehdr.e_os_abi);
Write64(f, ehdr.e_abi_ver);
Write16(f, ehdr.e_type);
Write16(f, ehdr.e_machine);
Write32(f, ehdr.e_version);
Write32(f, ehdr.e_entry);
Write32(f, ehdr.e_phoff);
Write32(f, ehdr.e_shoff);
Write32(f, ehdr.e_flags);
Write16(f, ehdr.e_ehsize);
Write16(f, ehdr.e_phentsize);
Write16(f, ehdr.e_phnum);
Write16(f, ehdr.e_shentsize);
Write16(f, ehdr.e_shnum);
Write16(f, ehdr.e_shstrndx);
}
void WritePhdr(rFile& f, Elf32_Phdr& phdr)
{
Write32(f, phdr.p_type);
Write32(f, phdr.p_offset);
Write32(f, phdr.p_vaddr);
Write32(f, phdr.p_paddr);
Write32(f, phdr.p_filesz);
Write32(f, phdr.p_memsz);
Write32(f, phdr.p_flags);
Write32(f, phdr.p_align);
}
void WriteShdr(rFile& f, Elf32_Shdr& shdr)
{
Write32(f, shdr.sh_name);
Write32(f, shdr.sh_type);
Write32(f, shdr.sh_flags);
Write32(f, shdr.sh_addr);
Write32(f, shdr.sh_offset);
Write32(f, shdr.sh_size);
Write32(f, shdr.sh_link);
Write32(f, shdr.sh_info);
Write32(f, shdr.sh_addralign);
Write32(f, shdr.sh_entsize);
}


void AppInfo::Load(vfsStream& f)
{
authid = Read64(f);
Expand Down

0 comments on commit 598d929

Please sign in to comment.