2 #ifndef __MONO_CIL_COFF_H__
3 #define __MONO_CIL_COFF_H__
5 #include <mono/metadata/metadata.h>
8 * 25.2.1: Method header type values
10 #define METHOD_HEADER_FORMAT_MASK 7
11 #define METHOD_HEADER_TINY_FORMAT 2
12 #define METHOD_HEADER_TINY_FORMAT1 6
13 #define METHOD_HEADER_FAT_FORMAT 3
16 * 25.2.3.1: Flags for method headers
18 #define METHOD_HEADER_INIT_LOCALS 0x10
19 #define METHOD_HEADER_MORE_SECTS 0x08
22 * For section data (25.3)
24 #define METHOD_HEADER_SECTION_RESERVED 0
25 #define METHOD_HEADER_SECTION_EHTABLE 1
26 #define METHOD_HEADER_SECTION_OPTIL_TABLE 2
27 #define METHOD_HEADER_SECTION_FAT_FORMAT 0x40
28 #define METHOD_HEADER_SECTION_MORE_SECTS 0x80
32 char msdos_header [60];
34 char msdos_header2 [64];
40 guint16 coff_sections;
43 guint32 coff_symcount;
44 guint16 coff_opt_header_size;
45 guint16 coff_attributes;
48 #define COFF_ATTRIBUTE_EXECUTABLE_IMAGE 0x0002
49 #define COFF_ATTRIBUTE_LIBRARY_IMAGE 0x2000
58 guint32 pe_uninit_data_size;
59 guint32 pe_rva_entry_point;
60 guint32 pe_rva_code_base;
61 guint32 pe_rva_data_base;
66 guint32 pe_image_base; /* must be 0x400000 */
67 guint32 pe_section_align; /* must be 8192 */
68 guint32 pe_file_alignment; /* must be 512 or 4096 */
69 guint16 pe_os_major; /* must be 4 */
70 guint16 pe_os_minor; /* must be 0 */
71 guint16 pe_user_major;
72 guint16 pe_user_minor;
73 guint16 pe_subsys_major;
74 guint16 pe_subsys_minor;
75 guint32 pe_reserved_1;
76 guint32 pe_image_size;
77 guint32 pe_header_size;
79 guint16 pe_subsys_required;
81 guint32 pe_stack_reserve;
82 guint32 pe_stack_commit;
83 guint32 pe_heap_reserve;
84 guint32 pe_heap_commit;
85 guint32 pe_loader_flags;
86 guint32 pe_data_dir_count;
96 MonoPEDirEntry pe_export_table;
97 MonoPEDirEntry pe_import_table;
98 MonoPEDirEntry pe_resource_table;
99 MonoPEDirEntry pe_exception_table;
100 MonoPEDirEntry pe_certificate_table;
101 MonoPEDirEntry pe_reloc_table;
102 MonoPEDirEntry pe_debug;
103 MonoPEDirEntry pe_copyright;
104 MonoPEDirEntry pe_global_ptr;
105 MonoPEDirEntry pe_tls_table;
106 MonoPEDirEntry pe_load_config_table;
107 MonoPEDirEntry pe_bound_import;
108 MonoPEDirEntry pe_iat;
109 MonoPEDirEntry pe_delay_import_desc;
110 MonoPEDirEntry pe_cli_header;
111 MonoPEDirEntry pe_reserved;
120 MonoPEDatadir datadir;
125 guint32 st_virtual_size;
126 guint32 st_virtual_address;
127 guint32 st_raw_data_size;
128 guint32 st_raw_data_ptr;
129 guint32 st_reloc_ptr;
130 guint32 st_lineno_ptr;
131 guint16 st_reloc_count;
132 guint16 st_line_count;
134 #define SECT_FLAGS_HAS_CODE 0x20
135 #define SECT_FLAGS_HAS_INITIALIZED_DATA 0x40
136 #define SECT_FLAGS_HAS_UNINITIALIZED_DATA 0x80
137 #define SECT_FLAGS_MEM_DISCARDABLE 0x02000000
138 #define SECT_FLAGS_MEM_NOT_CACHED 0x04000000
139 #define SECT_FLAGS_MEM_NOT_PAGED 0x08000000
140 #define SECT_FLAGS_MEM_SHARED 0x10000000
141 #define SECT_FLAGS_MEM_EXECUTE 0x20000000
142 #define SECT_FLAGS_MEM_READ 0x40000000
143 #define SECT_FLAGS_MEM_WRITE 0x80000000
150 guint16 ch_runtime_major;
151 guint16 ch_runtime_minor;
152 MonoPEDirEntry ch_metadata;
154 #define CLI_FLAGS_ILONLY 0x01
155 #define CLI_FLAGS_32BITREQUIRED 0x02
156 #define CLI_FLAGS_TRACKDEBUGDATA 0x00010000
159 guint32 ch_entry_point;
160 MonoPEDirEntry ch_resources;
161 MonoPEDirEntry ch_strong_name;
162 MonoPEDirEntry ch_code_manager_table;
163 MonoPEDirEntry ch_vtable_fixups;
164 MonoPEDirEntry ch_export_address_table_jumps;
166 /* The following are zero in the current docs */
167 MonoPEDirEntry ch_eeinfo_table;
168 MonoPEDirEntry ch_helper_table;
169 MonoPEDirEntry ch_dynamic_info;
170 MonoPEDirEntry ch_delay_load_info;
171 MonoPEDirEntry ch_module_image;
172 MonoPEDirEntry ch_external_fixups;
173 MonoPEDirEntry ch_ridmap;
174 MonoPEDirEntry ch_debug_map;
175 MonoPEDirEntry ch_ip_map;
178 /* This is not an on-disk structure */
180 MonoDotNetHeader cli_header;
181 int cli_section_count;
182 MonoSectionTable *cli_section_tables;
184 MonoCLIHeader cli_cli_header;
187 guint32 mono_cli_rva_image_map (MonoCLIImageInfo *iinfo, guint32 rva);
188 char *mono_cli_rva_map (MonoCLIImageInfo *iinfo, guint32 rva);
190 #endif /* __MONO_CIL_COFF_H__ */