summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-05-06 09:29:06 -0400
committermidipix <writeonce@midipix.org>2016-11-10 23:35:44 -0500
commit01439f902178b1525350ad568018d47c33a6709f (patch)
treea0e6941ed545201c2b733a30cbe332a7865fe99c /src
parent8216f99bc4dfeb9dc079694e528566b8bf89438f (diff)
downloadperk-01439f902178b1525350ad568018d47c33a6709f.tar.bz2
perk-01439f902178b1525350ad568018d47c33a6709f.tar.xz
pe_read_coff_header(): integrate runtime little endian test.
Diffstat (limited to 'src')
-rw-r--r--src/reader/pe_read_coff_header.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/reader/pe_read_coff_header.c b/src/reader/pe_read_coff_header.c
index 4df53c4..619c1cc 100644
--- a/src/reader/pe_read_coff_header.c
+++ b/src/reader/pe_read_coff_header.c
@@ -4,10 +4,10 @@
/* Released under GPLv2 and GPLv3; see COPYING.PERK. */
/***************************************************************/
-#include <endian.h>
#include <string.h>
#include <perk/perk.h>
+#include "perk_endian_impl.h"
#include "perk_reader_impl.h"
int pe_read_coff_header(const struct pe_coff_file_hdr * p, struct pe_meta_coff_file_hdr * m)
@@ -17,28 +17,28 @@ int pe_read_coff_header(const struct pe_coff_file_hdr * p, struct pe_meta_coff_f
if ((p->signature[0] != 'P') || (p->signature[1] != 'E') || *pzero)
return PERK_BAD_COFF_HEADER;
- #if (BYTE_ORDER == LITTLE_ENDIAN)
+ if (PERK_LITTLE_ENDIAN) {
- memcpy(m,p,sizeof(*p));
+ memcpy(m,p,sizeof(*p));
- #else
+ } else {
- m->signature[0] = p->signature[0];
- m->signature[1] = p->signature[1];
- m->signature[2] = p->signature[2];
- m->signature[3] = p->signature[3];
+ m->signature[0] = p->signature[0];
+ m->signature[1] = p->signature[1];
+ m->signature[2] = p->signature[2];
+ m->signature[3] = p->signature[3];
- m->machine = pe_read_short(p->machine);
- m->num_of_sections = pe_read_short(p->num_of_sections);
+ m->machine = pe_read_short(p->machine);
+ m->num_of_sections = pe_read_short(p->num_of_sections);
- m->time_date_stamp = pe_read_long(p->time_date_stamp);
- m->ptr_to_sym_tbl = pe_read_long(p->ptr_to_sym_tbl);
- m->num_of_syms = pe_read_long(p->num_of_syms);
+ m->time_date_stamp = pe_read_long(p->time_date_stamp);
+ m->ptr_to_sym_tbl = pe_read_long(p->ptr_to_sym_tbl);
+ m->num_of_syms = pe_read_long(p->num_of_syms);
- m->size_of_opt_hdr = pe_read_short(p->size_of_opt_hdr);
- m->characteristics = pe_read_short(p->characteristics);
+ m->size_of_opt_hdr = pe_read_short(p->size_of_opt_hdr);
+ m->characteristics = pe_read_short(p->characteristics);
- #endif
+ }
return 0;
}