NAME=NE crash
FILE=bins/ne/necrash
CMDS=<<EOF
aaa
i~format
i~csum
aflc
EOF
EXPECT=<<EOF
format   ne
hdr.csum c258016a
0
EOF
RUN
# merged: NE Segments; NE Resources JSON; NE Module imports; NE Relocs; NE Relocs and resolve function ordinal names
NAME=NE Symbols
FILE=bins/ne/anim8.exe
CMDS=<<EOF
is
?e --
iSS
?e --
iuj~{}~"name":
?e --
ii
?e --
ir~0x?
?e --
ir~WIN87EM
ir~:0..11
EOF
EXPECT=<<EOF
nth paddr      vaddr      bind   type size lib name       demangled
-------------------------------------------------------------------
0   0x00000a00 0x00000a00 NONE   NONE 0        ANIM8
1   0x00000d8e 0x00000d8e GLOBAL NONE 0        WNDPROC
2   0x00002b5a 0x00002b5a GLOBAL NONE 0        DIAL_ABOUT
0   0x00000a00 0x00000a00 NONE   NONE 0        ANIM8
--
nth paddr         size vaddr        vsize perm flags type name
--------------------------------------------------------------
0   0x00000a00  0x54ee 0x00000a00  0x54ee ---x 0x0   MAP  MOVEABLE.2560
1   0x00007600  0x3ec4 0x00007600  0x3ec4 -rwx 0x0   MAP  MOVEABLE.30208
--
    "name": "ICONX",
    "name": "FRAME_1",
    "name": "FRAME_10",
    "name": "FRAME_11",
    "name": "FRAME_12",
    "name": "FRAME_13",
    "name": "FRAME_14",
    "name": "FRAME_15",
    "name": "FRAME_16",
    "name": "FRAME_17",
    "name": "FRAME_18",
    "name": "FRAME_19",
    "name": "FRAME_2",
    "name": "FRAME_20",
    "name": "FRAME_21",
    "name": "FRAME_22",
    "name": "FRAME_23",
    "name": "FRAME_24",
    "name": "FRAME_25",
    "name": "FRAME_26",
    "name": "FRAME_27",
    "name": "FRAME_28",
    "name": "FRAME_29",
    "name": "FRAME_3",
    "name": "FRAME_30",
    "name": "FRAME_4",
    "name": "FRAME_5",
    "name": "FRAME_6",
    "name": "FRAME_7",
    "name": "FRAME_8",
    "name": "FRAME_9",
    "name": "MENUS",
    "name": "DIAL_ABOUT",
    "name": "4",
    "name": "5",
    "name": "9",
    "name": "626",
    "name": "ACCELS",
    "name": "1",
--
nth vaddr      bind type lib name
---------------------------------
1   0x00000000 NONE NONE     KERNEL
2   0x00000000 NONE NONE     USER
3   0x00000000 NONE NONE     GDI
4   0x00000000 NONE NONE     WIN87EM
--
718
--
0x00004c98 0x00004c98 SET_32 3     WIN87EM.__FPMATH
0x00004cb2 0x00004cb2 SET_16 5     WIN87EM.__FPMATH
0x00004cb8 0x00004cb8 SET_16 2     WIN87EM.__FPMATH
0x00004cbd 0x00004cbd SET_32 3     WIN87EM.__FPMATH
0x00004ccb 0x00004ccb SET_32 3     WIN87EM.__FPMATH
0x0000569a 0x0000569a ADD_16 5     WIN87EM.0
0x000056a0 0x000056a0 ADD_16 5     WIN87EM.0
0x000056b3 0x000056b3 ADD_16 5     WIN87EM.0
0x00005891 0x00005891 ADD_16 5     WIN87EM.0
vaddr      paddr      type   ntype name
---------------------------------------
0x00000a01 0x00000a01 SET_32 3     KERNEL.INITTASK
0x00000a25 0x00000a25 SET_32 3     KERNEL.LOCKSEGMENT
0x00000a3c 0x00000a3c SET_32 3     KERNEL.WAITEVENT
0x00000a45 0x00000a45 SET_32 3     USER.INITAPP
0x00000a74 0x00000a74 SET_32 3     KERNEL.GETWINFLAGS
0x00000ad0 0x00000ad0 SET_32 3     KERNEL.UNLOCKSEGMENT
0x00000f5e 0x00000f5e SET_32 3     USER.SETTIMER
0x00000f4d 0x00000f4d SET_32 3     USER.KILLTIMER
0x00000f13 0x00000f13 SET_32 3     USER.SETTIMER
EOF
RUN

NAME=NE: ir* keeps one name at each printed address when every reloc vaddr is 0
FILE=bins/ne/anim8.exe
CMDS=<<EOF
ir*~KILLTIMER
ir*~reloc.?
EOF
EXPECT=<<EOF
'f reloc.USER.KILLTIMER 4 0x00000f4d
'f reloc.USER.KILLTIMER 4 0x00000f02
'f reloc.USER.KILLTIMER 4 0x00000ef4
'f reloc.USER.KILLTIMER 4 0x00001359
'f reloc.USER.KILLTIMER 4 0x00002b14
707
EOF
RUN

NAME=NE preserve unnamed entry symbols
ARGS=-e bin.unnamed=false
FILE=bins/fuzzed/nepocaligns-17
CMDS=<<EOF
is~entry~?
EOF
EXPECT=<<EOF
40
EOF
RUN

NAME=NE detect minimal low-offset header
FILE=bins/fuzzed/nepoc00
CMDS=i~format
EXPECT=<<EOF
format   ne
EOF
RUN

NAME=NE recover low header offset with poisoned high word
FILE=bins/fuzzed/nepocaligns-06
CMDS=i~format
EXPECT=<<EOF
format   ne
EOF
RUN

NAME=NE preserve entries with zero-extended header offset
FILE=bins/fuzzed/nepocaligns-09
CMDS=<<EOF
i~format
is~entry~?
EOF
EXPECT=<<EOF
format   ne
8
EOF
RUN

NAME=NE reloc chain is walked once per segment
FILE=malloc://850
CMDS=<<EOF
wx 4d5a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000004e45050052000400000000000000000000000000000000000000000001000100000040005200520048004a009200000000000900000002000000000000000a030100000100010001010000064b45524e454c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000400060008000a000c000e00100012001400160018001a001c001e00200022002400260028002a002c002e00300032003400360038003a003c003e00400042004400460048004a004c004e00500052005400560058005a005c005e00600062006400660068006a006c006e00700072007400760078007a007c007e00800082008400860088008a008c008e00900092009400960098009a009c009e00a000a200a400a600a800aa00ac00ae00b000b200b400b600b800ba00bc00be00c000c200c400c600c800ca00cc00ce00d000d200d400d600d800da00dc00de00e000e200e400e600e800ea00ec00ee00f000f200f400f600f800fa00fc00fe00ffff0a000501000001000100050100000100010005010000010001000501000001000100050100000100010005010000010001000501000001000100050100000100010005010000010001000501000001000100
oba 0
ir~?
ir~:0..3
EOF
EXPECT=<<EOF
139
vaddr      paddr      type   ntype name
---------------------------------------
0x00000200 0x00000200 SET_16 5     KERNEL.FATALEXIT
EOF
RUN

NAME=NE relocs are bounded by the file size
FILE=malloc://778
CMDS=<<EOF
wx 4d5a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000004e450500ca00040000000000000000000000000000000000000000001000010000004000ca00ca00c000c2000a01000000000900000002000000000000000a030100000100010001010000010001000101000001000100010100000100010001010000010001000101000001000100010100000100010001010000010001000101000001000100010100000100010001010000010001000101000001000100010100000100010001010000010001000101000001000100010100000100010001010000064b45524e454c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000400060008000a000c000e00100012001400160018001a001c001e00200022002400260028002a002c002e00300032003400360038003a003c003e00400042004400460048004a004c004e00500052005400560058005a005c005e00600062006400660068006a006c006e00700072007400760078007a007c007e00800082008400860088008a008c008e00900092009400960098009a009c009e00a000a200a400a600a800aa00ac00ae00b000b200b400b600b800ba00bc00be00c000c200c400c600c800ca00cc00ce00d000d200d400d600d800da00dc00de00e000e200e400e600e800ea00ec00ee00f000f200f400f600f800fa00fc00fe00ffff01000501000001000100
oba 0
ir~?
EOF
EXPECT=<<EOF
780
EOF
RUN

NAME=NE: ordinal databases are only taken from the dll directory
FILE=bins/ne/ordinal-traversal.exe
CMDS=ir~SET[4]
EXPECT=<<EOF
../dll/USER.1
EOF
RUN
