ee94ee
pe_read_dos_header(): integrate runtime little endian test.
@@ -4,10 +4,10 @@
|
|
4
4
|
/* Released under GPLv2 and GPLv3; see COPYING.PERK. */
|
5
5
|
/***************************************************************/
|
6
6
|
|
7
|
-
|
8
7
|
|
9
8
|
|
10
9
|
|
10
|
+
|
11
11
|
|
12
12
|
|
13
13
|
int pe_read_dos_header(const struct pe_image_dos_hdr * p, struct pe_meta_image_dos_hdr * m)
|
@@ -15,44 +15,44 @@ int pe_read_dos_header(const struct pe_image_dos_hdr * p, struct pe_meta_image_d
|
|
15
15
|
if ((p->dos_magic[0] != 'M') || (p->dos_magic[1] != 'Z'))
|
16
16
|
return PERK_BAD_DOS_HEADER;
|
17
17
|
|
18
|
-
|
18
|
+
if (PERK_LITTLE_ENDIAN) {
|
19
19
|
|
20
|
-
|
20
|
+
memcpy(m,p,sizeof(*p));
|
21
21
|
|
22
|
-
|
22
|
+
} else {
|
23
23
|
|
24
|
-
|
24
|
+
int i;
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
m->dos_magic[0] = p->dos_magic[0];
|
27
|
+
m->dos_magic[1] = p->dos_magic[1];
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
29
|
+
m->dos_cblp = pe_read_short(p->dos_cblp);
|
30
|
+
m->dos_cp = pe_read_short(p->dos_cp);
|
31
|
+
m->dos_crlc = pe_read_short(p->dos_crlc);
|
32
|
+
m->dos_cparhdr = pe_read_short(p->dos_cparhdr);
|
33
|
+
m->dos_minalloc = pe_read_short(p->dos_minalloc);
|
34
|
+
m->dos_maxalloc = pe_read_short(p->dos_maxalloc);
|
35
|
+
m->dos_ss = pe_read_short(p->dos_ss);
|
36
|
+
m->dos_sp = pe_read_short(p->dos_sp);
|
37
|
+
m->dos_csum = pe_read_short(p->dos_csum);
|
38
|
+
m->dos_ip = pe_read_short(p->dos_ip);
|
39
|
+
m->dos_cs = pe_read_short(p->dos_cs);
|
40
|
+
m->dos_lfarlc = pe_read_short(p->dos_lfarlc);
|
41
|
+
m->dos_ovno = pe_read_short(p->dos_ovno);
|
42
42
|
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
for (i=0; i<4; i++)
|
45
|
+
m->dos_res[i] = pe_read_short(&p->dos_res[2*i]);
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
m->dos_oemid = pe_read_short(p->dos_oemid);
|
48
|
+
m->dos_oeminfo = pe_read_short(p->dos_oeminfo);
|
49
49
|
|
50
|
-
|
51
|
-
|
50
|
+
for (i=0; i<10; i++)
|
51
|
+
m->dos_res2[i] = pe_read_short(&p->dos_res2[2*i]);
|
52
52
|
|
53
|
-
|
53
|
+
m->dos_lfanew = pe_read_long(p->dos_lfanew);
|
54
54
|
|
55
|
-
|
55
|
+
}
|
56
56
|
|
57
57
|
return 0;
|
58
58
|
}
|