Skip to content

Improve support for NE images#341

Open
disinvite wants to merge 1 commit intoisledecomp:masterfrom
disinvite:improve-ne-support
Open

Improve support for NE images#341
disinvite wants to merge 1 commit intoisledecomp:masterfrom
disinvite:improve-ne-support

Conversation

@disinvite
Copy link
Copy Markdown
Collaborator

This has been in the oven for way too long and I want to get some feedback on the approach.

For NE images, we need to apply relocations before we can diassemble imports or far calls. This requires a lot of code to handle each relocation type and walk the "chain" of offsets to find each spot to patch. Our handling is not complete because I could not easily find examples of some relocation types. See: #325. Ghidra is also lacking support for some of these relocations, so we are doing at least as good as them.

We have not had to worry about segments until now. Ghidra's approach is to use 0x1000 as the ID for the first segment, then shift by 8 for each segment that follows. This ensures that there is no overlap in the address space, so you can use the shortcut of combining the two values to create a 32-bit address. For example: 0x10001234 is offset 0x1234 in segment 0x1000, the first segment.

Strictly speaking: we are not following the intended way of dealing with segment and offset as a 20-bit address. The main point is that we need to match what Ghidra does or our import script will not work out of the box. (I'm not sure how we're going to handle MZ because there is no easy way to identify all segments used in the image, but we'll cross that bridge when we come to it.)

The only thing missing now is connecting this to the main Compare function and relaxing the restriction that our tools only work with PE images. This will come later in a follow-up.

@disinvite disinvite requested review from jonschz and madebr March 15, 2026 16:43
Copy link
Copy Markdown
Collaborator

@jonschz jonschz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I don't have that much personal investment into NE at the moment, and this is quite a lot to process and get into. @madebr what about you?

@madebr
Copy link
Copy Markdown
Collaborator

madebr commented Mar 28, 2026

To be honest, I don't have that much personal investment into NE at the moment, and this is quite a lot to process and get into. @madebr what about you?

I also don't have a 16-bit Windows app that I really want to reverse/understand. Only thing I did was reversing Minesweeper from Windows 3.11 as an exercise. Having 16-bit support is interesting nonetheless if we ever want real-mode DOS support: there are a lot of cool old DOS games.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants