NE: Difference between revisions

1,476 bytes added ,  29 days ago
m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
m (Adjusting comment)
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(7 intermediate revisions by 5 users not shown)
Line 13:
==Overview==
===DOS Stub===
The DOS stub is a valid [[MZ]] exe. This enables the develperdeveloper to package both an MS-DOS and Win16 version of the program, but nromallynormally just prints "This Program requires Microsoft Windows". The e_lfanew field (offset 0x3C) points to the NE header.
 
===NE Header===
The NE header is a relatively large structure with multiple characteristics. Because of the age of the format some items are unclear in meaning. The structure is as below (some comments may be wrong. If so please change):
<sourcesyntaxhighlight lang="cpp">
struct NE_header {
char sig[2]; //"NE"
Line 24:
uint16_t EntryTableOffset; //Offset of entry table, see below
uint16_t EntryTableLength; //Length of entry table in bytes
uint32_t FileLoadCRC; //UNKNOWN 32-bit CRC of entire PLEASEcontents ADDof INFOfile
uint8_t ProgFlags; //Program flags, bitmapped
uint8_t ApplFlags; //Application flags, bitmapped
uint8_tuint16_t AutoDataSegIndex; //The automatic data segment index
uint16_t InitHeapSize; //The intialinitial local heap size
uint16_t InitStackSize; //The initalinitial stack size
uint32_t EntryPoint; //CS:IP entry point, CS is index into segment table
uint32_t InitStack; //SS:SP initalinitial stack pointer, SS is index into segment table
uint16_t SegCount; //Number of segments in segment table
uint16_t ModRefs; //Number of module references (DLLs)
Line 42:
uint32_t OffStartNonResTab; //Offset from start of file to non-resident names table
uint16_t MovEntryCount; //Count of moveable entry point listed in entry table
uint16_t FileAlnSzShftCnt; //File alligbmentalignment size shift count (0=9(default 512 byte pages))
uint16_t nResTabEntries; //Number of resource table entries
uint8_t targOS; //Target OS
Line 50:
uint16_t mincodeswap; //Minimum code swap area size
uint8_t expctwinver[2]; //Expected windows version (minor first)
};
 
//Program flags
//DGroup type (what is this?)
enum dgrouptype {
none, //None
sinshared, //single shared
multiple, //Multiple
null //(null)
};
 
#define GLOBINIT 1<<2 //global initialization
#define PMODEONLY 1<<3 //Protected mode only
#define INSTRUC86 1<<4 //8086 instructions
#define INSTRU286 1<<5 //80286 instructions
#define INSTRU386 1<<6 //80386 instructions
#define INSTRUx87 1<<7 //80x87 (FPU) instructions
 
//Application flags
//Application type
enum apptype {
none,
fullscreeen, //fullscreen (not aware of Windows/P.M. API)
sinshared,
winpmcompat, //compatible with Windows/P.M. API
multiple,
winpmuses //uses Windows/P.M. API
null
};
#define GLOBINITOS2APP 1<<3 //OS/2 family application
//bit 4 reserved?
#define PMODEONLY 1<<3
#define INSTRUC86IMAGEERROR 1<<45 //errors in image/executable
#define INSTRU286NONCONFORM 1<<56 //non-conforming program?
#define DLL 1<<7 //DLL or driver (SS:SP invalid, CS:IP->Far INIT routine AX=HMODULE,returns AX==0 success, AX!=0 fail)
#define INSTRU386 1<<6
 
#define INSTRUx87 1<<7
//Target Operating System
enum targetos {
unknown, //Obvious ;)
os2, //OS/2 (as if you hadn't worked that out!)
win, //Windows (Win16)
dos4, //European DOS 4.x
win386, //Windows for the 80386 (Win32s). 32 bit code.
BOSS //The boss, a.k.a Borland Operating System Services
};
//Other OS/2 flags
</source>
#define LFN 1 //OS/2 Long File Names (finally, no more 8.3 conversion :) )
#define PMODE 1<<1 //OS/2 2.x Protected Mode executable
#define PFONT 1<<2 //OS/2 2.x Proportional Fonts
#define GANGL 1<<3 //OS/2 Gangload area
</syntaxhighlight>
 
==See Also==
===NE===
*[http://bytepointer.com/resources/win16_ne_exe_format_win3.0.htm]
*[http://www.nondot.org/sabre/os/files/Executables/EXE-3.1.txt OSRC]
*[http://www.fileformat.info/format/exe/corion-ne.htm fileformat.info]