Use _le typedefs in elf reading.

This commit is contained in:
Unknown W. Brackets 2013-07-25 00:07:00 -07:00
parent 81f7103e0b
commit ae5851a393
4 changed files with 11 additions and 9 deletions

View File

@ -81,7 +81,7 @@ public:
int GetNumSegments() { return (int)(header->e_phnum); }
int GetNumSections() { return (int)(header->e_shnum); }
const char *GetSectionName(int section);
u8 *GetPtr(int offset)
u8 *GetPtr(u32 offset)
{
return (u8*)base + offset;
}

View File

@ -196,11 +196,11 @@ enum ElfSectionFlags
#define DT_LOPROC 0x70000000
#define DT_HIPROC 0x7FFFFFFF
typedef u32 Elf32_Addr;
typedef u16 Elf32_Half;
typedef u32 Elf32_Off;
typedef s32 Elf32_Sword;
typedef u32 Elf32_Word;
typedef u32_le Elf32_Addr;
typedef u16_le Elf32_Half;
typedef u32_le Elf32_Off;
typedef s32_le Elf32_Sword;
typedef u32_le Elf32_Word;
// ELF file header

View File

@ -33,8 +33,8 @@ enum PBPSubFile {
struct PBPHeader {
char magic[4];
u32 version;
u32 offsets[8];
u32_le version;
u32_le offsets[8];
};
class PBPReader {

View File

@ -447,6 +447,7 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro
if (*magicPtr == 0x4543537e) { // "~SCE"
INFO_LOG(HLE, "~SCE module, skipping header");
ptr += *(u32*)(ptr + 4);
magicPtr = (u32_le *)ptr;
}
*magic = *magicPtr;
if (*magic == 0x5053507e) { // "~PSP"
@ -460,6 +461,7 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro
}
newptr = new u8[head->elf_size + head->psp_size];
ptr = newptr;
magicPtr = (u32_le *)ptr;
int ret = pspDecryptPRX(in, (u8*)ptr, head->psp_size);
if (ret == MISSING_KEY) {
// This should happen for all "kernel" modules so disabling.
@ -482,7 +484,7 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro
// DO NOT change to else if, see above.
if (*magicPtr != 0x464c457f) {
ERROR_LOG_REPORT(HLE, "Wrong magic number %08x", *(u32*)ptr);
ERROR_LOG_REPORT(HLE, "Wrong magic number %08x", *magicPtr);
*error_string = "File corrupt";
if (newptr)
delete [] newptr;