summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-11-19 12:01:00 -0500
committermidipix <writeonce@midipix.org>2016-11-19 12:04:13 -0500
commit8cb34ff6894a6b3066ece4d2eca60c030202e695 (patch)
treec3b8d76a16c4bba51f7d2702c2e3219ed860dda6
parent11fb1c69c1701d2bf6532443a7e9f57344308cdd (diff)
downloadperk-8cb34ff6894a6b3066ece4d2eca60c030202e695.tar.bz2
perk-8cb34ff6894a6b3066ece4d2eca60c030202e695.tar.xz
PE format: union pe_opt_hdr [and friends] --> union pe_raw_opt_hdr.
-rw-r--r--include/perk/perk.h4
-rw-r--r--include/perk/perk_structs.h24
-rw-r--r--src/logic/pe_get_image_meta.c2
-rw-r--r--src/reader/pe_read_optional_header.c34
4 files changed, 32 insertions, 32 deletions
diff --git a/include/perk/perk.h b/include/perk/perk.h
index 3d58adc..1aa5e0c 100644
--- a/include/perk/perk.h
+++ b/include/perk/perk.h
@@ -100,7 +100,7 @@ struct pe_image_meta {
struct pe_raw_image_dos_hdr * ados;
struct pe_raw_coff_file_hdr * acoff;
- union pe_opt_hdr * aopt;
+ union pe_raw_opt_hdr * aopt;
struct pe_sec_hdr * asectbl;
struct pe_meta_export_hdr edata;
@@ -198,7 +198,7 @@ perk_api int pe_get_image_framework (const struct pe_image_meta *, struct pe_in
/* low-level api */
perk_api int pe_read_dos_header (const struct pe_raw_image_dos_hdr *, struct pe_meta_image_dos_hdr *);
perk_api int pe_read_coff_header (const struct pe_raw_coff_file_hdr *, struct pe_meta_coff_file_hdr *);
-perk_api int pe_read_optional_header (const union pe_opt_hdr *, struct pe_meta_opt_hdr *);
+perk_api int pe_read_optional_header (const union pe_raw_opt_hdr *, struct pe_meta_opt_hdr *);
perk_api int pe_read_section_header (const struct pe_sec_hdr *, struct pe_meta_sec_hdr *);
perk_api int pe_read_export_header (const struct pe_export_hdr *, struct pe_meta_export_hdr *);
perk_api int pe_read_import_header (const struct pe_import_hdr *, struct pe_meta_import_hdr *);
diff --git a/include/perk/perk_structs.h b/include/perk/perk_structs.h
index 51689d3..e410b55 100644
--- a/include/perk/perk_structs.h
+++ b/include/perk/perk_structs.h
@@ -40,7 +40,7 @@ struct pe_raw_coff_file_hdr {
};
-struct pe_opt_hdr_std {
+struct pe_raw_opt_hdr_std {
unsigned char magic [0x02]; /* 0x00 */
unsigned char major_linker_ver [0x01]; /* 0x02 */
unsigned char minor_linker_ver [0x01]; /* 0x03 */
@@ -51,12 +51,12 @@ struct pe_opt_hdr_std {
unsigned char base_of_code [0x04]; /* 0x14 */
};
-struct pe_opt_hdr_align {
+struct pe_raw_opt_hdr_align {
unsigned char section_align [0x04]; /* 0x20 */
unsigned char file_align [0x04]; /* 0x24 */
};
-struct pe_opt_hdr_vers {
+struct pe_raw_opt_hdr_vers {
unsigned char major_os_ver [0x02]; /* 0x28 */
unsigned char minor_os_ver [0x02]; /* 0x2a */
unsigned char major_image_ver [0x02]; /* 0x2c */
@@ -66,7 +66,7 @@ struct pe_opt_hdr_vers {
unsigned char win32_ver [0x04]; /* 0x34 */
};
-struct pe_opt_hdr_img {
+struct pe_raw_opt_hdr_img {
unsigned char size_of_image [0x04]; /* 0x38 */
unsigned char size_of_headers [0x04]; /* 0x3c */
unsigned char checksum [0x04]; /* 0x40 */
@@ -74,12 +74,12 @@ struct pe_opt_hdr_img {
unsigned char dll_characteristics [0x02]; /* 0x46 */
};
-struct pe_opt_hdr_ldr {
+struct pe_raw_opt_hdr_ldr {
unsigned char loader_flags [0x04];
unsigned char rva_and_sizes [0x04];
};
-struct pe_opt_hdr_dirs {
+struct pe_raw_opt_hdr_dirs {
unsigned char export_tbl [0x08];
unsigned char import_tbl [0x08];
unsigned char resource_tbl [0x08];
@@ -98,7 +98,7 @@ struct pe_opt_hdr_dirs {
unsigned char reserved [0x08];
};
-struct pe_data_dirs {
+struct pe_raw_data_dirs {
unsigned char rva_and_sizes [0x04];
unsigned char export_tbl [0x08];
unsigned char import_tbl [0x08];
@@ -118,7 +118,7 @@ struct pe_data_dirs {
unsigned char reserved [0x08];
};
-struct pe_opt_hdr_32 {
+struct pe_raw_opt_hdr_32 {
unsigned char magic [0x02]; /* 0x00 */
unsigned char major_linker_ver [0x01]; /* 0x02 */
unsigned char minor_linker_ver [0x01]; /* 0x03 */
@@ -168,7 +168,7 @@ struct pe_opt_hdr_32 {
};
-struct pe_opt_hdr_64 {
+struct pe_raw_opt_hdr_64 {
unsigned char magic [0x02]; /* 0x00 */
unsigned char major_linker_ver [0x01]; /* 0x02 */
unsigned char minor_linker_ver [0x01]; /* 0x03 */
@@ -217,9 +217,9 @@ struct pe_opt_hdr_64 {
};
-union pe_opt_hdr {
- struct pe_opt_hdr_32 opt_hdr_32;
- struct pe_opt_hdr_64 opt_hdr_64;
+union pe_raw_opt_hdr {
+ struct pe_raw_opt_hdr_32 opt_hdr_32;
+ struct pe_raw_opt_hdr_64 opt_hdr_64;
};
diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c
index e62d4e6..1a24913 100644
--- a/src/logic/pe_get_image_meta.c
+++ b/src/logic/pe_get_image_meta.c
@@ -197,7 +197,7 @@ int pe_get_image_meta(
m->coff.size_of_string_tbl = pe_read_long(mark);
mark = &m->acoff->signature[0];
- m->aopt = (union pe_opt_hdr *)(mark + sizeof(*m->acoff));
+ m->aopt = (union pe_raw_opt_hdr *)(mark + sizeof(*m->acoff));
if ((ret = (pe_read_optional_header(m->aopt,&m->opt))))
return pe_free_image_meta_impl(
diff --git a/src/reader/pe_read_optional_header.c b/src/reader/pe_read_optional_header.c
index 8ab46f2..5ece6a3 100644
--- a/src/reader/pe_read_optional_header.c
+++ b/src/reader/pe_read_optional_header.c
@@ -10,35 +10,35 @@
#include "perk_endian_impl.h"
#include "perk_reader_impl.h"
-static int pe_read_optional_header_structs(const union pe_opt_hdr * p, struct pe_meta_opt_hdr * m)
+static int pe_read_optional_header_structs(const union pe_raw_opt_hdr * p, struct pe_meta_opt_hdr * m)
{
unsigned int i;
struct pe_block * pdir;
const unsigned char * mark;
- struct pe_opt_hdr_std * astd;
- struct pe_opt_hdr_vers * avers;
- struct pe_opt_hdr_align * aalign;
- struct pe_opt_hdr_img * aimg;
- struct pe_opt_hdr_ldr * aldr;
+ struct pe_raw_opt_hdr_std * astd;
+ struct pe_raw_opt_hdr_vers * avers;
+ struct pe_raw_opt_hdr_align * aalign;
+ struct pe_raw_opt_hdr_img * aimg;
+ struct pe_raw_opt_hdr_ldr * aldr;
m->std.magic = pe_read_short(p->opt_hdr_32.magic);
switch (m->std.magic) {
case PE_MAGIC_PE32:
- astd = (struct pe_opt_hdr_std *)p;
- avers = (struct pe_opt_hdr_vers *)&p->opt_hdr_32.major_os_ver;
- aalign = (struct pe_opt_hdr_align *)&p->opt_hdr_32.section_align;
- aimg = (struct pe_opt_hdr_img *)&p->opt_hdr_32.size_of_image;
- aldr = (struct pe_opt_hdr_ldr *)&p->opt_hdr_32.loader_flags;
+ astd = (struct pe_raw_opt_hdr_std *)p;
+ avers = (struct pe_raw_opt_hdr_vers *)&p->opt_hdr_32.major_os_ver;
+ aalign = (struct pe_raw_opt_hdr_align *)&p->opt_hdr_32.section_align;
+ aimg = (struct pe_raw_opt_hdr_img *)&p->opt_hdr_32.size_of_image;
+ aldr = (struct pe_raw_opt_hdr_ldr *)&p->opt_hdr_32.loader_flags;
break;
case PE_MAGIC_PE32_PLUS:
- astd = (struct pe_opt_hdr_std *)p;
- avers = (struct pe_opt_hdr_vers *)&p->opt_hdr_64.major_os_ver;
- aalign = (struct pe_opt_hdr_align *)&p->opt_hdr_64.section_align;
- aimg = (struct pe_opt_hdr_img *)&p->opt_hdr_64.size_of_image;
- aldr = (struct pe_opt_hdr_ldr *)&p->opt_hdr_64.loader_flags;
+ astd = (struct pe_raw_opt_hdr_std *)p;
+ avers = (struct pe_raw_opt_hdr_vers *)&p->opt_hdr_64.major_os_ver;
+ aalign = (struct pe_raw_opt_hdr_align *)&p->opt_hdr_64.section_align;
+ aimg = (struct pe_raw_opt_hdr_img *)&p->opt_hdr_64.size_of_image;
+ aldr = (struct pe_raw_opt_hdr_ldr *)&p->opt_hdr_64.loader_flags;
break;
default:
@@ -99,7 +99,7 @@ static int pe_read_optional_header_structs(const union pe_opt_hdr * p, struct pe
return 0;
}
-int pe_read_optional_header(const union pe_opt_hdr * p, struct pe_meta_opt_hdr * m)
+int pe_read_optional_header(const union pe_raw_opt_hdr * p, struct pe_meta_opt_hdr * m)
{
int ret;