Rizin
unix-like reverse engineering framework and cli tools
ne_specs.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2019 GustavoLCR <gugulcr@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #ifndef NE_SPECS_H
5 #define NE_SPECS_H
6 
7 enum {
8  LOBYTE = 0,
9  SEL_16 = 2,
10  POI_32 = 3,
11  OFF_16 = 5,
12  POI_48 = 11,
13  OFF_32 = 13
14 };
15 
16 enum {
20  OSFIXUP = 3,
21  ADDITIVE = 4
22 };
23 
24 typedef struct _RELOC {
28  union {
30  struct { // internal_fixed
34  };
35  struct { // internal_moveable
38  };
39  struct { // import_ordinal
42  };
43  struct { // import_name
46  };
47  };
49 
50 enum {
51  IS_DATA = 1,
52  IS_MOVEABLE = 0x10,
53  IS_SHAREABLE = 0x20,
54  IS_PRELOAD = 0x40,
55  RELOCINFO = 0x100,
56  IS_RX = 0x1000
57 };
58 
59 enum {
62  LINKERROR = 0x2000,
63  LIBRARY = 0x8000
64 };
65 
66 typedef struct _SEGMENT {
67  ut16 offset; // Specifies the offset, in sectors, to the segment data (relative to the beginning of the file). A value of zero means no data exists.
68  ut16 length; // Length of the segment in bytes. A value of zero indicates that the segment length is 64K, unless the selector offset is also zero.
69  ut16 flags; // NE_SEGMENT_FLAGS
70  ut16 minAllocSz; // A value of zero indicates that the minimum allocation size is 64K
72 
73 typedef struct _NAMEINFO {
81 
82 typedef struct _TYPEINFO {
88 
89 typedef struct {
90  char sig[2]; // "NE"
91  ut8 MajLinkerVersion; // The major linker version
92  ut8 MinLinkerVersion; // The minor linker version
93  ut16 EntryTableOffset; // Offset of entry table
94  ut16 EntryTableLength; // Length of entry table in bytes
95  ut32 FileLoadCRC; // 32-bit CRC of entire contents of file
96  ut8 ProgFlags; // Program flags, bitmapped
97  ut8 ApplFlags; // Application flags, bitmapped
98  ut8 AutoDataSegIndex; // The automatic data segment index
99  ut16 InitHeapSize; // The intial local heap size
100  ut16 InitStackSize; // The inital stack size
101  ut16 ipEntryPoint; // IP entry point offset
102  ut16 csEntryPoint; // CS entrypoint index into segment table (Start at 1)
103  ut32 InitStack; // SS:SP inital stack pointer, SS is index into segment table
104  ut16 SegCount; // Number of segments in segment table
105  ut16 ModRefs; // Number of module references (DLLs)
106  ut16 NoResNamesTabSiz; // Size of non-resident names table, in bytes
107  ut16 SegTableOffset; // Offset of Segment table
108  ut16 ResTableOffset; // Offset of resources table
109  ut16 ResidNamTable; // Offset of resident names table
110  ut16 ModRefTable; // Offset of module reference table
111  ut16 ImportNameTable; // Offset of imported names table (array of counted strings, terminated with string of length 00h)
112  ut32 OffStartNonResTab; // Offset from start of file to non-resident names table
113  ut16 MovEntryCount; // Count of moveable entry point listed in entry table
114  ut16 FileAlnSzShftCnt; // File alligbment size shift count (0=9(default 512 byte pages))
115  ut16 nResTabEntries; // Number of resource table entries
116  ut8 targOS; // Target OS
117  ut8 OS2EXEFlags; // Other OS/2 flags
118  ut16 retThunkOffset; // Offset to return thunks or start of gangload area - what is gangload?
119  ut16 segrefthunksoff; // Offset to segment reference thunks or size of gangload area
120  ut16 mincodeswap; // Minimum code swap area size
121  ut8 expctwinver[2]; // Expected windows version (minor first)
123 
124 #endif
uint16_t ut16
uint32_t ut32
uint8_t ut8
Definition: lh5801.h:11
@ IS_PRELOAD
Definition: ne_specs.h:54
@ IS_SHAREABLE
Definition: ne_specs.h:53
@ RELOCINFO
Definition: ne_specs.h:55
@ IS_MOVEABLE
Definition: ne_specs.h:52
@ IS_RX
Definition: ne_specs.h:56
@ IS_DATA
Definition: ne_specs.h:51
@ SEL_16
Definition: ne_specs.h:9
@ POI_48
Definition: ne_specs.h:12
@ POI_32
Definition: ne_specs.h:10
@ OFF_16
Definition: ne_specs.h:11
@ LOBYTE
Definition: ne_specs.h:8
@ OFF_32
Definition: ne_specs.h:13
struct _TYPEINFO NE_image_typeinfo_entry
@ IMPORTED_ORD
Definition: ne_specs.h:18
@ INTERNAL_REF
Definition: ne_specs.h:17
@ ADDITIVE
Definition: ne_specs.h:21
@ OSFIXUP
Definition: ne_specs.h:20
@ IMPORTED_NAME
Definition: ne_specs.h:19
struct _RELOC NE_image_reloc_item
struct _SEGMENT NE_image_segment_entry
struct _NAMEINFO NE_image_nameinfo_entry
@ LIBRARY
Definition: ne_specs.h:63
@ NOAUTODATA
Definition: ne_specs.h:60
@ SINGLEDATA
Definition: ne_specs.h:61
@ LINKERROR
Definition: ne_specs.h:62
ut8 AutoDataSegIndex
Definition: ne_specs.h:98
ut32 OffStartNonResTab
Definition: ne_specs.h:112
ut16 InitStackSize
Definition: ne_specs.h:100
ut16 mincodeswap
Definition: ne_specs.h:120
ut16 EntryTableLength
Definition: ne_specs.h:94
ut16 InitHeapSize
Definition: ne_specs.h:99
ut16 NoResNamesTabSiz
Definition: ne_specs.h:106
ut16 ModRefTable
Definition: ne_specs.h:110
ut16 EntryTableOffset
Definition: ne_specs.h:93
ut16 SegTableOffset
Definition: ne_specs.h:107
ut8 MajLinkerVersion
Definition: ne_specs.h:91
ut16 ResidNamTable
Definition: ne_specs.h:109
ut16 retThunkOffset
Definition: ne_specs.h:118
ut16 FileAlnSzShftCnt
Definition: ne_specs.h:114
ut16 ResTableOffset
Definition: ne_specs.h:108
ut16 nResTabEntries
Definition: ne_specs.h:115
ut16 ipEntryPoint
Definition: ne_specs.h:101
ut16 segrefthunksoff
Definition: ne_specs.h:119
ut16 MovEntryCount
Definition: ne_specs.h:113
ut16 csEntryPoint
Definition: ne_specs.h:102
ut16 ImportNameTable
Definition: ne_specs.h:111
ut8 MinLinkerVersion
Definition: ne_specs.h:92
ut32 FileLoadCRC
Definition: ne_specs.h:95
ut16 rnID
Definition: ne_specs.h:77
ut16 rnFlags
Definition: ne_specs.h:76
ut16 rnHandle
Definition: ne_specs.h:78
ut16 rnUsage
Definition: ne_specs.h:79
ut16 rnLength
Definition: ne_specs.h:75
ut16 rnOffset
Definition: ne_specs.h:74
ut16 index
Definition: ne_specs.h:29
ut16 func_ord
Definition: ne_specs.h:41
ut8 zero
Definition: ne_specs.h:32
ut16 segoff
Definition: ne_specs.h:33
ut16 ignore
Definition: ne_specs.h:36
ut16 align1
Definition: ne_specs.h:40
ut16 align2
Definition: ne_specs.h:44
ut8 flags
Definition: ne_specs.h:26
ut8 segnum
Definition: ne_specs.h:31
ut16 offset
Definition: ne_specs.h:27
ut16 entry_ordinal
Definition: ne_specs.h:37
ut8 type
Definition: ne_specs.h:25
ut16 name_off
Definition: ne_specs.h:45
ut16 offset
Definition: ne_specs.h:67
ut16 minAllocSz
Definition: ne_specs.h:70
ut16 flags
Definition: ne_specs.h:69
ut16 length
Definition: ne_specs.h:68
ut32 rtReserved
Definition: ne_specs.h:85
ut16 rtTypeID
Definition: ne_specs.h:83
ut16 rtResourceCount
Definition: ne_specs.h:84
NE_image_nameinfo_entry rtNameInfo[]
Definition: ne_specs.h:86