diff options
author | midipix <writeonce@midipix.org> | 2016-11-16 18:38:45 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-11-16 19:32:52 -0500 |
commit | d2a31a13b405ac9347f46846962c166a3c4c2246 (patch) | |
tree | f7ce4f01d8cceec1303747a629f4af03fcaf9827 /src | |
parent | 659299fcedad35b6b86d361c74d732494722660d (diff) | |
download | perk-d2a31a13b405ac9347f46846962c166a3c4c2246.tar.bz2 perk-d2a31a13b405ac9347f46846962c166a3c4c2246.tar.xz |
reader: pe_read_dos_header(): remove useless optimization.
Diffstat (limited to 'src')
-rw-r--r-- | src/reader/pe_read_dos_header.c | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/src/reader/pe_read_dos_header.c b/src/reader/pe_read_dos_header.c index 7aa9ba5..440063e 100644 --- a/src/reader/pe_read_dos_header.c +++ b/src/reader/pe_read_dos_header.c @@ -15,44 +15,36 @@ int pe_read_dos_header(const struct pe_image_dos_hdr * p, struct pe_meta_image_d if ((p->dos_magic[0] != 'M') || (p->dos_magic[1] != 'Z')) return PERK_ERR_BAD_DOS_HEADER; - if (PERK_LITTLE_ENDIAN) { + int i; - memcpy(m,p,sizeof(*p)); + m->dos_magic[0] = p->dos_magic[0]; + m->dos_magic[1] = p->dos_magic[1]; - } else { + m->dos_cblp = pe_read_short(p->dos_cblp); + m->dos_cp = pe_read_short(p->dos_cp); + m->dos_crlc = pe_read_short(p->dos_crlc); + m->dos_cparhdr = pe_read_short(p->dos_cparhdr); + m->dos_minalloc = pe_read_short(p->dos_minalloc); + m->dos_maxalloc = pe_read_short(p->dos_maxalloc); + m->dos_ss = pe_read_short(p->dos_ss); + m->dos_sp = pe_read_short(p->dos_sp); + m->dos_csum = pe_read_short(p->dos_csum); + m->dos_ip = pe_read_short(p->dos_ip); + m->dos_cs = pe_read_short(p->dos_cs); + m->dos_lfarlc = pe_read_short(p->dos_lfarlc); + m->dos_ovno = pe_read_short(p->dos_ovno); - int i; - m->dos_magic[0] = p->dos_magic[0]; - m->dos_magic[1] = p->dos_magic[1]; + for (i=0; i<4; i++) + m->dos_res[i] = pe_read_short(&p->dos_res[2*i]); - m->dos_cblp = pe_read_short(p->dos_cblp); - m->dos_cp = pe_read_short(p->dos_cp); - m->dos_crlc = pe_read_short(p->dos_crlc); - m->dos_cparhdr = pe_read_short(p->dos_cparhdr); - m->dos_minalloc = pe_read_short(p->dos_minalloc); - m->dos_maxalloc = pe_read_short(p->dos_maxalloc); - m->dos_ss = pe_read_short(p->dos_ss); - m->dos_sp = pe_read_short(p->dos_sp); - m->dos_csum = pe_read_short(p->dos_csum); - m->dos_ip = pe_read_short(p->dos_ip); - m->dos_cs = pe_read_short(p->dos_cs); - m->dos_lfarlc = pe_read_short(p->dos_lfarlc); - m->dos_ovno = pe_read_short(p->dos_ovno); + m->dos_oemid = pe_read_short(p->dos_oemid); + m->dos_oeminfo = pe_read_short(p->dos_oeminfo); + for (i=0; i<10; i++) + m->dos_res2[i] = pe_read_short(&p->dos_res2[2*i]); - for (i=0; i<4; i++) - m->dos_res[i] = pe_read_short(&p->dos_res[2*i]); - - m->dos_oemid = pe_read_short(p->dos_oemid); - m->dos_oeminfo = pe_read_short(p->dos_oeminfo); - - for (i=0; i<10; i++) - m->dos_res2[i] = pe_read_short(&p->dos_res2[2*i]); - - m->dos_lfanew = pe_read_long(p->dos_lfanew); - - } + m->dos_lfanew = pe_read_long(p->dos_lfanew); return 0; } |