1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
/*
* HT Editor
* nestruct.h
*
* Copyright (C) 1999-2002 Stefan Weyergraf
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __NESTRUCT_H_
#define __NESTRUCT_H_
#define NE_MAGIC0 'N'
#define NE_MAGIC1 'E'
#define NE_OS_UNKNOWN 0x0000
#define NE_OS_OS2 0x0001
#define NE_OS_WINDOWS 0x0002
#define NE_OS_DOS4 0x0003
#define NE_FLAGS_NOTAPROCESS 0x8000 /* Not a process */
#define NE_FLAGS_ERRORS 0x2000 /* Errors in image */
#define NE_FLAGS_SELFLOAD 0x0800
#define NE_FLAGS_NOTWINCOMPAT 0x0100 /* Not compatible with P.M. Windowing */
#define NE_FLAGS_WINCOMPAT 0x0200 /* Compatible with P.M. Windowing */
#define NE_FLAGS_WINAPI 0x0300 /* Uses P.M. Windowing API */
#define NE_FLAGS_FLOAT 0x0080 /* Floating-point instructions */
#define NE_FLAGS_I80386 0x0040 /* 80386 instructions */
#define NE_FLAGS_I80286 0x0020 /* 80286 instructions */
#define NE_FLAGS_I8086 0x0010 /* 8086 instructions */
#define NE_FLAGS_PROT_ONLY 0x0008 /* Runs in protected mode only */
#define NE_FLAGS_PPLI 0x0004 /* Per-Process Library Initialization */
#define NE_FLAGS_INST 0x0002 /* Instance data */
#define NE_FLAGS_SOLO 0x0001 /* Solo data */
struct NE_HEADER {
uint16 magic; // Magic number
byte ver; // Version number
byte rev; // Revision number
uint16 enttab; // Offset of Entry Table
uint16 cbenttab; // Number of bytes in Entry Table
uint32 crc; // Checksum of whole file
uint16 flags; // Flag uint16
uint16 autodata; // Automatic data segment number
uint16 heap; // Initial heap allocation
uint16 stack; // Initial stack allocation
uint32 csip; // Initial CS:IP setting
uint32 sssp; // Initial SS:SP setting
uint16 cseg; // Count of file segments
uint16 cmod; // Entries in Module Reference Table
uint16 cbnrestab; // Size of non-resident name table
uint16 segtab; // Offset of Segment Table
uint16 rsrctab; // Offset of Resource Table
uint16 restab; // Offset of resident name table
uint16 modtab; // Offset of Module Reference Table
uint16 imptab; // Offset of Imported Names Table
uint32 nrestab; // Offset of Non-resident Names Table
uint16 cmovent; // Count of movable entries
uint16 align; // Segment alignment shift count
uint16 cres; // Count of resource segments
byte os; // Target Operating system
byte flagsothers; // Other .EXE flags
uint16 pretthunks; // offset to return thunks
uint16 psegrefbytes; // offset to segment ref. bytes
uint16 swaparea; // Minimum code swap area size
uint16 expver; // Expected Windows version number
} PACKED;
/*
* segment
*/
struct NE_SEGMENT {
uint16 offset;
uint16 size;
uint16 flags;
uint16 minalloc;
} PACKED;
#define NE_DATA 0x0001
#define NE_ITERATED 0x0008
#define NE_MOVABLE 0x0010
#define NE_SHARABLE 0x0020
#define NE_PRELOAD 0x0040
#define NE_READONLY 0x0080
#define NE_HASRELOC 0x0100
#define NE_CONFORMING 0x0200
/* 2 bits priv-level */
#define NE_DISCARDABLE 0x1000
#define NE_32BIT 0x2000
#define NE_HUGE 0x4000
/*
* entrypoint table
*/
struct NE_ENTRYPOINT_HEADER {
byte entry_count;
byte seg_index;
} PACKED;
/* 00H 1 Entry point flags
Bit(s) Significance
0 0 = entry point not exported
1 = entry point exported
1 0 = entry point uses instance data
1 = entry point uses single data
2 Reserved
37 Number of stack parameter words
01H 2 Int 3FH instruction (CDH 3FH)
03H 1 Segment number of entry point
04H 2 Offset of entry point within segment
*/
#define NE_ENT_FLAGS_EXPORTED 0x01
#define NE_ENT_FLAGS_SINGLE_DATA 0x02
#define NE_ENT_FLAGS_PARAM_WORDS 0xf8
struct NE_ENTRYPOINT_MOVABLE {
byte flags;
uint16 int3f;
byte seg;
uint16 offset;
} PACKED;
/* 00H 1 Entry point flags (See above)
01H 2 Offset of entry point within segment*/
struct NE_ENTRYPOINT_FIXED {
byte flags;
uint16 offset;
} PACKED;
/* relocations */
struct NE_RELOC_HEADER {
byte type;
byte flags;
uint16 src_ofs;
} PACKED;
#define NE_RF_ADD 0x04 /* Additive fixup */
#define NE_RF_RT_MASK 0x03 /* Reference type mask */
#define NE_RF_INTERNAL 0x00 /* Internal reference */
#define NE_RF_IMPORT_ORD 0x01 /* Import by ordinal */
#define NE_RF_IMPORT_NAME 0x02 /* Import by name */
#define NE_RF_OSFIXUP 0x03 /* Operating system fixup */
#define NE_RT_MASK 0x0f /* Source type mask */
#define NE_RT_OFS8 0x00 /* lo byte */
#define NE_RT_SEG16 0x02 /* 16-bit segment */
#define NE_RT_PTR32 0x03 /* 32-bit pointer */
#define NE_RT_OFS16 0x05 /* 16-bit offset */
#define NE_RT_PTR48 0x0B /* 48-bit pointer */
#define NE_RT_OFS32 0x0D /* 32-bit offset */
struct NE_RELOC_INTERNAL {
byte seg;
byte reserved;
uint16 ofs;
};
struct NE_RELOC_IMPORT {
uint16 module;
union {
uint16 ord;
uint16 name_ofs;
};
};
struct NE_RELOC_FIXUP {
uint16 type;
uint16 reserved;
};
extern byte NE_HEADER_struct[];
extern byte NE_SEGMENT_struct[];
extern byte NE_ENTRYPOINT_HEADER_struct[];
extern byte NE_ENTRYPOINT_MOVABLE_struct[];
extern byte NE_ENTRYPOINT_FIXED_struct[];
extern byte NE_RELOC_HEADER_struct[];
extern byte NE_RELOC_INTERNAL_struct[];
extern byte NE_RELOC_IMPORT_struct[];
extern byte NE_RELOC_FIXUP_struct[];
#endif /* __NESTRUCT_H_ */
|