| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
#ifndef _A_OUT_H_ |
|---|
| 12 |
#define _A_OUT_H_ |
|---|
| 13 |
|
|---|
| 14 |
#ifdef __cplusplus |
|---|
| 15 |
extern "C" { |
|---|
| 16 |
#endif |
|---|
| 17 |
#define COFF_IMAGE_WITH_PE |
|---|
| 18 |
#define COFF_LONG_SECTION_NAMES |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
struct external_filehdr { |
|---|
| 26 |
short f_magic; |
|---|
| 27 |
short f_nscns; |
|---|
| 28 |
unsigned long f_timdat; |
|---|
| 29 |
unsigned long f_symptr; |
|---|
| 30 |
unsigned long f_nsyms; |
|---|
| 31 |
short f_opthdr; |
|---|
| 32 |
short f_flags; |
|---|
| 33 |
}; |
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
#define F_RELFLG (0x0001) |
|---|
| 44 |
#define F_EXEC (0x0002) |
|---|
| 45 |
#define F_LNNO (0x0004) |
|---|
| 46 |
#define F_LSYMS (0x0008) |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
#define I386MAGIC 0x14c |
|---|
| 51 |
#define I386PTXMAGIC 0x154 |
|---|
| 52 |
#define I386AIXMAGIC 0x175 |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
#define LYNXCOFFMAGIC 0415 |
|---|
| 57 |
|
|---|
| 58 |
#define I386BADMAG(x) (((x).f_magic != I386MAGIC) \ |
|---|
| 59 |
&& (x).f_magic != I386AIXMAGIC \ |
|---|
| 60 |
&& (x).f_magic != I386PTXMAGIC \ |
|---|
| 61 |
&& (x).f_magic != LYNXCOFFMAGIC) |
|---|
| 62 |
|
|---|
| 63 |
#define FILHDR struct external_filehdr |
|---|
| 64 |
#define FILHSZ 20 |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
typedef struct |
|---|
| 72 |
{ |
|---|
| 73 |
unsigned short magic; |
|---|
| 74 |
unsigned short vstamp; |
|---|
| 75 |
unsigned long tsize; |
|---|
| 76 |
unsigned long dsize; |
|---|
| 77 |
unsigned long bsize; |
|---|
| 78 |
unsigned long entry; |
|---|
| 79 |
unsigned long text_start; |
|---|
| 80 |
unsigned long data_start; |
|---|
| 81 |
*/ |
|---|
| 82 |
} |
|---|
| 83 |
AOUTHDR; |
|---|
| 84 |
|
|---|
| 85 |
#define AOUTSZ 28 |
|---|
| 86 |
#define AOUTHDRSZ 28 |
|---|
| 87 |
|
|---|
| 88 |
#define OMAGIC 0404 |
|---|
| 89 |
#define ZMAGIC 0413 |
|---|
| 90 |
#define STMAGIC 0401 |
|---|
| 91 |
#define SHMAGIC 0443 |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
#define NT_SECTION_ALIGNMENT 0x1000 |
|---|
| 97 |
#define NT_FILE_ALIGNMENT 0x200 |
|---|
| 98 |
#define NT_DEF_RESERVE 0x100000 |
|---|
| 99 |
#define NT_DEF_COMMIT 0x1000 |
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
struct external_scnhdr { |
|---|
| 105 |
char s_name[8]; |
|---|
| 106 |
unsigned long s_paddr; |
|---|
| 107 |
of last addr in scn */ |
|---|
| 108 |
unsigned long s_vaddr; |
|---|
| 109 |
unsigned long s_size; |
|---|
| 110 |
unsigned long s_scnptr; |
|---|
| 111 |
unsigned long s_relptr; |
|---|
| 112 |
unsigned long s_lnnoptr; |
|---|
| 113 |
unsigned short s_nreloc; |
|---|
| 114 |
unsigned short s_nlnno; |
|---|
| 115 |
unsigned long s_flags; |
|---|
| 116 |
}; |
|---|
| 117 |
|
|---|
| 118 |
#define SCNHDR struct external_scnhdr |
|---|
| 119 |
#define SCNHSZ 40 |
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
#define _TEXT ".text" |
|---|
| 125 |
#define _DATA ".data" |
|---|
| 126 |
#define _BSS ".bss" |
|---|
| 127 |
#define _COMMENT ".comment" |
|---|
| 128 |
#define _LIB ".lib" |
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
struct external_lineno { |
|---|
| 138 |
union { |
|---|
| 139 |
unsigned long l_symndx; |
|---|
| 140 |
unsigned long l_paddr; |
|---|
| 141 |
} l_addr; |
|---|
| 142 |
unsigned short l_lnno; |
|---|
| 143 |
}; |
|---|
| 144 |
|
|---|
| 145 |
#define LINENO struct external_lineno |
|---|
| 146 |
#define LINESZ 6 |
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
#define E_SYMNMLEN 8 |
|---|
| 151 |
#define E_FILNMLEN 14 |
|---|
| 152 |
#define E_DIMNUM 4 |
|---|
| 153 |
|
|---|
| 154 |
struct __attribute__((packed)) external_syment |
|---|
| 155 |
{ |
|---|
| 156 |
union { |
|---|
| 157 |
char e_name[E_SYMNMLEN]; |
|---|
| 158 |
struct { |
|---|
| 159 |
unsigned long e_zeroes; |
|---|
| 160 |
unsigned long e_offset; |
|---|
| 161 |
} e; |
|---|
| 162 |
} e; |
|---|
| 163 |
unsigned long e_value; |
|---|
| 164 |
unsigned short e_scnum; |
|---|
| 165 |
unsigned short e_type; |
|---|
| 166 |
char e_sclass[1]; |
|---|
| 167 |
char e_numaux[1]; |
|---|
| 168 |
}; |
|---|
| 169 |
|
|---|
| 170 |
#define N_BTMASK (0xf) |
|---|
| 171 |
#define N_TMASK (0x30) |
|---|
| 172 |
#define N_BTSHFT (4) |
|---|
| 173 |
#define N_TSHIFT (2) |
|---|
| 174 |
|
|---|
| 175 |
union external_auxent { |
|---|
| 176 |
struct { |
|---|
| 177 |
unsigned long x_tagndx; |
|---|
| 178 |
union { |
|---|
| 179 |
struct { |
|---|
| 180 |
unsigned short x_lnno; |
|---|
| 181 |
unsigned short x_size; |
|---|
| 182 |
} x_lnsz; |
|---|
| 183 |
unsigned long x_fsize; |
|---|
| 184 |
} x_misc; |
|---|
| 185 |
union { |
|---|
| 186 |
struct { |
|---|
| 187 |
unsigned long x_lnnoptr; |
|---|
| 188 |
unsigned long x_endndx; |
|---|
| 189 |
} x_fcn; |
|---|
| 190 |
struct { |
|---|
| 191 |
char x_dimen[E_DIMNUM][2]; |
|---|
| 192 |
} x_ary; |
|---|
| 193 |
} x_fcnary; |
|---|
| 194 |
unsigned short x_tvndx; |
|---|
| 195 |
} x_sym; |
|---|
| 196 |
|
|---|
| 197 |
union { |
|---|
| 198 |
char x_fname[E_FILNMLEN]; |
|---|
| 199 |
struct { |
|---|
| 200 |
unsigned long x_zeroes; |
|---|
| 201 |
unsigned long x_offset; |
|---|
| 202 |
} x_n; |
|---|
| 203 |
} x_file; |
|---|
| 204 |
|
|---|
| 205 |
struct { |
|---|
| 206 |
unsigned long x_scnlen; |
|---|
| 207 |
unsigned short x_nreloc; |
|---|
| 208 |
unsigned short x_nlinno; |
|---|
| 209 |
unsigned long x_checksum; |
|---|
| 210 |
unsigned short x_associated; |
|---|
| 211 |
char x_comdat[1]; |
|---|
| 212 |
} x_scn; |
|---|
| 213 |
|
|---|
| 214 |
struct { |
|---|
| 215 |
unsigned long x_tvfill; |
|---|
| 216 |
unsigned short x_tvlen; |
|---|
| 217 |
char x_tvran[2][2]; |
|---|
| 218 |
} x_tv; |
|---|
| 219 |
|
|---|
| 220 |
}; |
|---|
| 221 |
|
|---|
| 222 |
#define SYMENT struct external_syment |
|---|
| 223 |
#define SYMESZ 18 |
|---|
| 224 |
#define AUXENT union external_auxent |
|---|
| 225 |
#define AUXESZ 18 |
|---|
| 226 |
|
|---|
| 227 |
#define _ETEXT "etext" |
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
struct external_reloc { |
|---|
| 232 |
char r_vaddr[4]; |
|---|
| 233 |
char r_symndx[4]; |
|---|
| 234 |
char r_type[2]; |
|---|
| 235 |
}; |
|---|
| 236 |
|
|---|
| 237 |
#define RELOC struct external_reloc |
|---|
| 238 |
#define RELSZ 10 |
|---|
| 239 |
|
|---|
| 240 |
|
|---|
| 241 |
|
|---|
| 242 |
|
|---|
| 243 |
|
|---|
| 244 |
#ifndef _PE_H |
|---|
| 245 |
#define _PE_H |
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 |
|---|
| 249 |
#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 |
|---|
| 250 |
#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 |
|---|
| 251 |
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 |
|---|
| 252 |
#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 |
|---|
| 253 |
#define IMAGE_FILE_32BIT_MACHINE 0x0100 |
|---|
| 254 |
#define IMAGE_FILE_DEBUG_STRIPPED 0x0200 |
|---|
| 255 |
#define IMAGE_FILE_SYSTEM 0x1000 |
|---|
| 256 |
#define IMAGE_FILE_DLL 0x2000 |
|---|
| 257 |
#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 |
|---|
| 258 |
|
|---|
| 259 |
|
|---|
| 260 |
|
|---|
| 261 |
|
|---|
| 262 |
|
|---|
| 263 |
#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000 |
|---|
| 264 |
#define IMAGE_SCN_MEM_EXECUTE 0x20000000 |
|---|
| 265 |
#define IMAGE_SCN_MEM_READ 0x40000000 |
|---|
| 266 |
#define IMAGE_SCN_MEM_WRITE 0x80000000 |
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
#define IMAGE_SCN_TYPE_NO_PAD 0x00000008 |
|---|
| 273 |
|
|---|
| 274 |
#define IMAGE_SCN_CNT_CODE 0x00000020 |
|---|
| 275 |
#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 |
|---|
| 276 |
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 |
|---|
| 277 |
|
|---|
| 278 |
#define IMAGE_SCN_LNK_OTHER 0x00000100 |
|---|
| 279 |
#define IMAGE_SCN_LNK_INFO 0x00000200 |
|---|
| 280 |
#define IMAGE_SCN_LNK_REMOVE 0x00000800 |
|---|
| 281 |
#define IMAGE_SCN_LNK_COMDAT 0x00001000 |
|---|
| 282 |
|
|---|
| 283 |
#define IMAGE_SCN_MEM_FARDATA 0x00008000 |
|---|
| 284 |
|
|---|
| 285 |
#define IMAGE_SCN_MEM_PURGEABLE 0x00020000 |
|---|
| 286 |
#define IMAGE_SCN_MEM_16BIT 0x00020000 |
|---|
| 287 |
#define IMAGE_SCN_MEM_LOCKED 0x00040000 |
|---|
| 288 |
#define IMAGE_SCN_MEM_PRELOAD 0x00080000 |
|---|
| 289 |
|
|---|
| 290 |
#define IMAGE_SCN_ALIGN_1BYTES 0x00100000 |
|---|
| 291 |
#define IMAGE_SCN_ALIGN_2BYTES 0x00200000 |
|---|
| 292 |
#define IMAGE_SCN_ALIGN_4BYTES 0x00300000 |
|---|
| 293 |
#define IMAGE_SCN_ALIGN_8BYTES 0x00400000 |
|---|
| 294 |
#define IMAGE_SCN_ALIGN_16BYTES 0x00500000 |
|---|
| 295 |
#define IMAGE_SCN_ALIGN_32BYTES 0x00600000 |
|---|
| 296 |
#define IMAGE_SCN_ALIGN_64BYTES 0x00700000 |
|---|
| 297 |
|
|---|
| 298 |
|
|---|
| 299 |
#define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000 |
|---|
| 300 |
#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 |
|---|
| 301 |
#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 |
|---|
| 302 |
#define IMAGE_SCN_MEM_SHARED 0x10000000 |
|---|
| 303 |
|
|---|
| 304 |
|
|---|
| 305 |
|
|---|
| 306 |
#define IMAGE_COMDAT_SELECT_NODUPLICATES (1) |
|---|
| 307 |
#define IMAGE_COMDAT_SELECT_ANY (2) |
|---|
| 308 |
#define IMAGE_COMDAT_SELECT_SAME_SIZE (3) |
|---|
| 309 |
#define IMAGE_COMDAT_SELECT_EXACT_MATCH (4) |
|---|
| 310 |
#define IMAGE_COMDAT_SELECT_ASSOCIATIVE (5) |
|---|
| 311 |
|
|---|
| 312 |
|
|---|
| 313 |
#define DOSMAGIC 0x5a4d |
|---|
| 314 |
#define NT_SIGNATURE 0x00004550 |
|---|
| 315 |
|
|---|
| 316 |
|
|---|
| 317 |
|
|---|
| 318 |
#undef FILNMLEN |
|---|
| 319 |
#define FILNMLEN 18 |
|---|
| 320 |
|
|---|
| 321 |
|
|---|
| 322 |
#ifdef COFF_IMAGE_WITH_PE |
|---|
| 323 |
|
|---|
| 324 |
|
|---|
| 325 |
#undef FILHDR |
|---|
| 326 |
struct external_PE_filehdr |
|---|
| 327 |
{ |
|---|
| 328 |
|
|---|
| 329 |
unsigned short e_magic; |
|---|
| 330 |
unsigned short e_cblp; |
|---|
| 331 |
unsigned short e_cp; |
|---|
| 332 |
unsigned short e_crlc; |
|---|
| 333 |
unsigned short e_cparhdr; |
|---|
| 334 |
unsigned short e_minalloc; |
|---|
| 335 |
unsigned short e_maxalloc; |
|---|
| 336 |
unsigned short e_ss; |
|---|
| 337 |
unsigned short e_sp; |
|---|
| 338 |
unsigned short e_csum; |
|---|
| 339 |
unsigned short e_ip; |
|---|
| 340 |
unsigned short e_cs; |
|---|
| 341 |
unsigned short e_lfarlc; |
|---|
| 342 |
unsigned short e_ovno; |
|---|
| 343 |
char e_res[4][2]; |
|---|
| 344 |
unsigned short e_oemid; |
|---|
| 345 |
unsigned short e_oeminfo; |
|---|
| 346 |
char e_res2[10][2]; |
|---|
| 347 |
unsigned long e_lfanew; |
|---|
| 348 |
char dos_message[16][4]; |
|---|
| 349 |
unsigned int nt_signature; |
|---|
| 350 |
|
|---|
| 351 |
|
|---|
| 352 |
|
|---|
| 353 |
unsigned short f_magic; |
|---|
| 354 |
unsigned short f_nscns; |
|---|
| 355 |
unsigned long f_timdat; |
|---|
| 356 |
unsigned long f_symptr; |
|---|
| 357 |
unsigned long f_nsyms; |
|---|
| 358 |
unsigned short f_opthdr; |
|---|
| 359 |
unsigned short f_flags; |
|---|
| 360 |
}; |
|---|
| 361 |
|
|---|
| 362 |
|
|---|
| 363 |
#define FILHDR struct external_PE_filehdr |
|---|
| 364 |
#undef FILHSZ |
|---|
| 365 |
#define FILHSZ 152 |
|---|
| 366 |
|
|---|
| 367 |
#endif |
|---|
| 368 |
|
|---|
| 369 |
typedef struct |
|---|
| 370 |
{ |
|---|
| 371 |
unsigned short magic; |
|---|
| 372 |
unsigned short vstamp; |
|---|
| 373 |
unsigned long tsize; |
|---|
| 374 |
unsigned long dsize; |
|---|
| 375 |
unsigned long bsize; |
|---|
| 376 |
unsigned long entry; |
|---|
| 377 |
unsigned long text_start; |
|---|
| 378 |
unsigned long data_start; |
|---|
| 379 |
|
|---|
| 380 |
|
|---|
| 381 |
unsigned long ImageBase; |
|---|
| 382 |
unsigned long SectionAlignment; |
|---|
| 383 |
unsigned long FileAlignment; |
|---|
| 384 |
unsigned short MajorOperatingSystemVersion; |
|---|
| 385 |
unsigned short MinorOperatingSystemVersion; |
|---|
| 386 |
unsigned short MajorImageVersion; |
|---|
| 387 |
unsigned short MinorImageVersion; |
|---|
| 388 |
unsigned short MajorSubsystemVersion; |
|---|
| 389 |
unsigned short MinorSubsystemVersion; |
|---|
| 390 |
char Reserved1[4]; |
|---|
| 391 |
unsigned long SizeOfImage; |
|---|
| 392 |
unsigned long SizeOfHeaders; |
|---|
| 393 |
unsigned long CheckSum; |
|---|
| 394 |
unsigned short Subsystem; |
|---|
| 395 |
unsigned short DllCharacteristics; |
|---|
| 396 |
unsigned long SizeOfStackReserve; |
|---|
| 397 |
unsigned long SizeOfStackCommit; |
|---|
| 398 |
unsigned long SizeOfHeapReserve; |
|---|
| 399 |
unsigned long SizeOfHeapCommit; |
|---|
| 400 |
unsigned long LoaderFlags; |
|---|
| 401 |
unsigned long NumberOfRvaAndSizes; |
|---|
| 402 |
|
|---|
| 403 |
char DataDirectory[16][2][4]; |
|---|
| 404 |
|
|---|
| 405 |
} PEAOUTHDR; |
|---|
| 406 |
|
|---|
| 407 |
|
|---|
| 408 |
#undef AOUTSZ |
|---|
| 409 |
#define AOUTSZ (AOUTHDRSZ + 196) |
|---|
| 410 |
|
|---|
| 411 |
#undef E_FILNMLEN |
|---|
| 412 |
#define E_FILNMLEN 18 |
|---|
| 413 |
#endif |
|---|
| 414 |
|
|---|
| 415 |
|
|---|
| 416 |
|
|---|
| 417 |
#define DT_NON (0) |
|---|
| 418 |
#define DT_PTR (1) |
|---|
| 419 |
#define DT_FCN (2) |
|---|
| 420 |
#define DT_ARY (3) |
|---|
| 421 |
|
|---|
| 422 |
#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) |
|---|
| 423 |
#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) |
|---|
| 424 |
#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) |
|---|
| 425 |
|
|---|
| 426 |
#ifdef __cplusplus |
|---|
| 427 |
} |
|---|
| 428 |
#endif |
|---|
| 429 |
|
|---|
| 430 |
#endif |
|---|
| 431 |
|
|---|