|
|
e2e2c2 |
/***************************************************************/
|
|
|
e2e2c2 |
/* perk: PE Resource Kit */
|
|
|
e2e2c2 |
/* Copyright (C) 2015--2016 Z. Gilboa */
|
|
|
e2e2c2 |
/* Released under GPLv2 and GPLv3; see COPYING.PERK. */
|
|
|
e2e2c2 |
/***************************************************************/
|
|
|
e2e2c2 |
|
|
|
c0fbae |
#include <string.h>
|
|
|
c0fbae |
|
|
|
c0fbae |
#include <perk/perk.h>
|
|
|
ee94ee |
#include "perk_endian_impl.h"
|
|
|
413f56 |
#include "perk_reader_impl.h"
|
|
|
c0fbae |
|
|
|
99c452 |
int pe_read_dos_header(const struct pe_raw_image_dos_hdr * p, struct pe_meta_image_dos_hdr * m)
|
|
|
c0fbae |
{
|
|
|
c0fbae |
if ((p->dos_magic[0] != 'M') || (p->dos_magic[1] != 'Z'))
|
|
|
ff121d |
return PERK_ERR_BAD_DOS_HEADER;
|
|
|
c0fbae |
|
|
|
d2a31a |
int i;
|
|
|
c0fbae |
|
|
|
d2a31a |
m->dos_magic[0] = p->dos_magic[0];
|
|
|
d2a31a |
m->dos_magic[1] = p->dos_magic[1];
|
|
|
c0fbae |
|
|
|
d2a31a |
m->dos_cblp = pe_read_short(p->dos_cblp);
|
|
|
d2a31a |
m->dos_cp = pe_read_short(p->dos_cp);
|
|
|
d2a31a |
m->dos_crlc = pe_read_short(p->dos_crlc);
|
|
|
d2a31a |
m->dos_cparhdr = pe_read_short(p->dos_cparhdr);
|
|
|
d2a31a |
m->dos_minalloc = pe_read_short(p->dos_minalloc);
|
|
|
d2a31a |
m->dos_maxalloc = pe_read_short(p->dos_maxalloc);
|
|
|
d2a31a |
m->dos_ss = pe_read_short(p->dos_ss);
|
|
|
d2a31a |
m->dos_sp = pe_read_short(p->dos_sp);
|
|
|
d2a31a |
m->dos_csum = pe_read_short(p->dos_csum);
|
|
|
d2a31a |
m->dos_ip = pe_read_short(p->dos_ip);
|
|
|
d2a31a |
m->dos_cs = pe_read_short(p->dos_cs);
|
|
|
d2a31a |
m->dos_lfarlc = pe_read_short(p->dos_lfarlc);
|
|
|
d2a31a |
m->dos_ovno = pe_read_short(p->dos_ovno);
|
|
|
c0fbae |
|
|
|
b5f7f5 |
|
|
|
d2a31a |
for (i=0; i<4; i++)
|
|
|
d2a31a |
m->dos_res[i] = pe_read_short(&p->dos_res[2*i]);
|
|
|
c0fbae |
|
|
|
d2a31a |
m->dos_oemid = pe_read_short(p->dos_oemid);
|
|
|
d2a31a |
m->dos_oeminfo = pe_read_short(p->dos_oeminfo);
|
|
|
c0fbae |
|
|
|
d2a31a |
for (i=0; i<10; i++)
|
|
|
d2a31a |
m->dos_res2[i] = pe_read_short(&p->dos_res2[2*i]);
|
|
|
c0fbae |
|
|
|
d2a31a |
m->dos_lfanew = pe_read_long(p->dos_lfanew);
|
|
|
c0fbae |
|
|
|
c0fbae |
return 0;
|
|
|
b5f7f5 |
}
|