Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

nestruct.h

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      nestruct.h
00004  *
00005  *      Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
00006  *
00007  *      This program is free software; you can redistribute it and/or modify
00008  *      it under the terms of the GNU General Public License version 2 as
00009  *      published by the Free Software Foundation.
00010  *
00011  *      This program is distributed in the hope that it will be useful,
00012  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *      GNU General Public License for more details.
00015  *
00016  *      You should have received a copy of the GNU General Public License
00017  *      along with this program; if not, write to the Free Software
00018  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #ifndef __NESTRUCT_H_
00022 #define __NESTRUCT_H_
00023 
00024 #define NE_MAGIC0       'N'
00025 #define NE_MAGIC1       'E'
00026 
00027 #define NE_OS_UNKNOWN           0x0000
00028 #define NE_OS_OS2                       0x0001
00029 #define NE_OS_WINDOWS           0x0002
00030 #define NE_OS_DOS4                      0x0003
00031 
00032 #define NE_FLAGS_NOTAPROCESS    0x8000    /* Not a process */
00033 #define NE_FLAGS_ERRORS         0x2000    /* Errors in image */
00034 #define NE_FLAGS_SELFLOAD       0x0800
00035 
00036 #define NE_FLAGS_NOTWINCOMPAT   0x0100    /* Not compatible with P.M. Windowing */
00037 #define NE_FLAGS_WINCOMPAT      0x0200    /* Compatible with P.M. Windowing */
00038 #define NE_FLAGS_WINAPI         0x0300    /* Uses P.M. Windowing API */
00039 
00040 #define NE_FLAGS_FLOAT          0x0080    /* Floating-point instructions */
00041 #define NE_FLAGS_I80386         0x0040    /* 80386 instructions */
00042 #define NE_FLAGS_I80286         0x0020    /* 80286 instructions */
00043 #define NE_FLAGS_I8086          0x0010    /* 8086 instructions */
00044 #define NE_FLAGS_PROT_ONLY      0x0008    /* Runs in protected mode only */
00045 #define NE_FLAGS_PPLI           0x0004    /* Per-Process Library Initialization */
00046 #define NE_FLAGS_INST           0x0002    /* Instance data */
00047 #define NE_FLAGS_SOLO           0x0001    /* Solo data */
00048 
00049 struct NE_HEADER {
00050         word   magic;                    // Magic number
00051         byte   ver;                      // Version number
00052         byte   rev;                      // Revision number
00053         word   enttab;                   // Offset of Entry Table
00054         word   cbenttab;                 // Number of bytes in Entry Table
00055         dword  crc;                      // Checksum of whole file
00056         word   flags;                    // Flag word
00057         word   autodata;                 // Automatic data segment number
00058         word   heap;                     // Initial heap allocation
00059         word   stack;                    // Initial stack allocation
00060         dword  csip;                     // Initial CS:IP setting
00061         dword  sssp;                     // Initial SS:SP setting
00062         word   cseg;                     // Count of file segments
00063         word   cmod;                     // Entries in Module Reference Table
00064         word   cbnrestab;                // Size of non-resident name table
00065         word   segtab;                   // Offset of Segment Table
00066         word   rsrctab;                  // Offset of Resource Table
00067         word   restab;                   // Offset of resident name table
00068         word   modtab;                   // Offset of Module Reference Table
00069         word   imptab;                   // Offset of Imported Names Table
00070         dword  nrestab;                  // Offset of Non-resident Names Table
00071         word   cmovent;                  // Count of movable entries
00072         word   align;                    // Segment alignment shift count
00073         word   cres;                     // Count of resource segments
00074         byte   os;                       // Target Operating system
00075         byte   flagsothers;              // Other .EXE flags
00076         word   pretthunks;               // offset to return thunks
00077         word   psegrefbytes;             // offset to segment ref. bytes
00078         word   swaparea;                 // Minimum code swap area size
00079         word   expver;                   // Expected Windows version number
00080 };
00081 
00082 /*
00083  *      segment
00084  */
00085 
00086 struct NE_SEGMENT {
00087         word offset HTPACKED;
00088         word size HTPACKED;
00089         word flags HTPACKED;
00090         word minalloc HTPACKED;
00091 };
00092 
00093 #define NE_DATA         0x0001
00094 
00095 #define NE_ITERATED             0x0008
00096 #define NE_MOVABLE              0x0010
00097 #define NE_SHARABLE             0x0020
00098 #define NE_PRELOAD              0x0040
00099 #define NE_READONLY             0x0080
00100 #define NE_HASRELOC             0x0100
00101 #define NE_CONFORMING   0x0200
00102 /* 2 bits priv-level */
00103 #define NE_DISCARDABLE  0x1000
00104 #define NE_32BIT        0x2000
00105 #define NE_HUGE         0x4000
00106 
00107 /*
00108  *      entrypoint table
00109  */
00110 
00111 struct NE_ENTRYPOINT_HEADER {
00112         byte entry_count HTPACKED;
00113         byte seg_index HTPACKED;
00114 };
00115 
00116 /*  00H      1         Entry point flags
00117                           Bit(s)          Significance
00118                           0       0 = entry point not exported
00119                                   1 = entry point exported
00120                           1       0 = entry point uses instance data
00121                                   1 = entry point uses single data
00122                           2       Reserved
00123                           3Ä7     Number of stack parameter words
00124   01H        2         Int 3FH instruction (CDH 3FH)
00125   03H        1         Segment number of entry point
00126   04H        2         Offset of entry point within segment
00127 */
00128 
00129 #define NE_ENT_FLAGS_EXPORTED           0x01
00130 #define NE_ENT_FLAGS_SINGLE_DATA        0x02
00131 
00132 #define NE_ENT_FLAGS_PARAM_WORDS        0xf8
00133 
00134 struct NE_ENTRYPOINT_MOVABLE {
00135         byte flags HTPACKED;
00136         word int3f HTPACKED;
00137         byte seg HTPACKED;
00138         word offset HTPACKED;
00139 };
00140 
00141 /*  00H      1         Entry point flags (See above)
00142     01H      2         Offset of entry point within segment*/
00143 
00144 struct NE_ENTRYPOINT_FIXED {
00145         byte flags HTPACKED;
00146         word offset HTPACKED;
00147 };
00148 
00149 /* relocations */
00150 
00151 struct NE_RELOC_HEADER {
00152         byte type HTPACKED;
00153         byte flags HTPACKED;
00154         word src_ofs HTPACKED;
00155 };
00156 
00157 #define NE_RF_ADD                       0x04              /* Additive fixup */
00158 
00159 #define NE_RF_RT_MASK           0x03              /* Reference type mask */
00160 
00161 #define NE_RF_INTERNAL          0x00              /* Internal reference */
00162 #define NE_RF_IMPORT_ORD                0x01              /* Import by ordinal */
00163 #define NE_RF_IMPORT_NAME       0x02              /* Import by name */
00164 #define NE_RF_OSFIXUP           0x03              /* Operating system fixup */
00165 
00166 #define NE_RT_MASK                      0x0f              /* Source type mask */
00167 #define NE_RT_OFS8                      0x00              /* lo byte */
00168 #define NE_RT_SEG16                     0x02              /* 16-bit segment */
00169 #define NE_RT_PTR32                     0x03              /* 32-bit pointer */
00170 #define NE_RT_OFS16                     0x05              /* 16-bit offset */
00171 #define NE_RT_PTR48                     0x0B              /* 48-bit pointer */
00172 #define NE_RT_OFS32                     0x0D              /* 32-bit offset */
00173 
00174 struct NE_RELOC_INTERNAL {
00175         byte seg;
00176         byte reserved;
00177         word ofs;
00178 };
00179 
00180 struct NE_RELOC_IMPORT {
00181         word module;
00182         union {
00183                 word ord;
00184                 word name_ofs;
00185         };
00186 };
00187 
00188 struct NE_RELOC_FIXUP {
00189         word type;
00190         word reserved;
00191 };
00192 
00193 extern byte NE_HEADER_struct[];
00194 extern byte NE_SEGMENT_struct[];
00195 extern byte NE_ENTRYPOINT_HEADER_struct[];
00196 extern byte NE_ENTRYPOINT_MOVABLE_struct[];
00197 extern byte NE_ENTRYPOINT_FIXED_struct[];
00198 extern byte NE_RELOC_HEADER_struct[];
00199 extern byte NE_RELOC_INTERNAL_struct[];
00200 extern byte NE_RELOC_IMPORT_struct[];
00201 extern byte NE_RELOC_FIXUP_struct[];
00202 
00203 #endif /* __NESTRUCT_H_ */
00204 

Generated on Fri May 7 21:15:41 2004 by doxygen 1.3.5