29
29
#include "bcfeatures.h"
31
/** Header for this PE file */
31
/** Header for this PE file
32
33
struct pe_image_file_hdr {
33
34
uint32_t Magic; /**< PE magic header: PE\\0\\0 */
34
35
uint16_t Machine;/**< CPU this executable runs on, see libclamav/pe.c for possible values */
40
41
uint16_t Characteristics;
43
/** PE data directory header */
44
/** PE data directory header
44
46
struct pe_image_data_dir {
45
47
uint32_t VirtualAddress;
49
/** 32-bit PE optional header */
51
/** 32-bit PE optional header
50
53
struct pe_image_optional_hdr32 {
52
55
uint8_t MajorLinkerVersion; /**< unreliable */
62
65
uint32_t FileAlignment; /**< usually 32 or 512 */
63
66
uint16_t MajorOperatingSystemVersion; /**< not used */
64
67
uint16_t MinorOperatingSystemVersion; /**< not used */
65
uint16_t MajorImageVersion; /** unreliable */
66
uint16_t MinorImageVersion; /** unreliable */
68
uint16_t MajorImageVersion; /**< unreliable */
69
uint16_t MinorImageVersion; /**< unreliable */
67
70
uint16_t MajorSubsystemVersion;
68
71
uint16_t MinorSubsystemVersion;
69
uint32_t Win32VersionValue; /* ? */
72
uint32_t Win32VersionValue; /*< ? */
70
73
uint32_t SizeOfImage;
71
74
uint32_t SizeOfHeaders;
72
75
uint32_t CheckSum; /**< NT drivers only */
76
79
uint32_t SizeOfStackCommit;
77
80
uint32_t SizeOfHeapReserve;
78
81
uint32_t SizeOfHeapCommit;
79
uint32_t LoaderFlags; /* ? */
82
uint32_t LoaderFlags; /*< ? */
80
83
uint32_t NumberOfRvaAndSizes; /**< unreliable */
81
84
struct pe_image_data_dir DataDirectory[16];
84
/** PE 64-bit optional header */
87
/** PE 64-bit optional header
85
89
struct pe_image_optional_hdr64 {
87
91
uint8_t MajorLinkerVersion; /**< unreliable */
135
140
uint32_t Characteristics;
138
/** Data for the bytecode PE hook */
143
/** Data for the bytecode PE hook
139
145
struct cli_pe_hook_data {
147
uint32_t ep; /**< EntryPoint as file offset */
148
uint16_t nsections;/**< Number of sections */
143
149
uint16_t dummy; /* align */
144
struct pe_image_file_hdr file_hdr;
145
struct pe_image_optional_hdr32 opt32;
150
struct pe_image_file_hdr file_hdr;/**< Header for this PE file */
151
struct pe_image_optional_hdr32 opt32; /**< 32-bit PE optional header */
146
152
uint32_t dummy2; /* align */
147
struct pe_image_optional_hdr64 opt64;
148
struct pe_image_data_dir dirs[16];
153
struct pe_image_optional_hdr64 opt64;/**< 64-bit PE optional header */
154
struct pe_image_data_dir dirs[16]; /**< PE data directory header */
149
155
uint32_t e_lfanew;/**< address of new exe header */
150
156
uint32_t overlays;/**< number of overlays */
151
157
int32_t overlays_sz;/**< size of overlays */
152
158
uint32_t hdr_size;/**< internally needed by rawaddr */
155
int cli_scanpe(cli_ctx *ctx, icon_groupset *set);
161
int cli_scanpe(cli_ctx *ctx);
157
163
int cli_peheader(fmap_t *map, struct cli_exe_info *peinfo);