Skip to content

Conversation

LukeSerne
Copy link
Contributor

Fixes #6694

On x86 16-bit real mode, the CS varnode was re-calculated on every jump. However, due to the nature of how real mode works, it is impossible to reconstruct the value of CS at those points. Luckily, the correct value seems to be set at the beginning of the function by auto-analysis in real mode, so if we don't change it, it should be correct throughout the function.

This PR also changes the definition of some of the CALLF instructions to ensure the correct value of CS is restored after the call.

I've personally barely tested this patch, and I don't really have experience with x86 reverse engineering, but this patch seems to help people in the aforementioned issue, so I figured I'd add it as a real PR.

On x86 16-bit real mode, the CS varnode was re-calculated on every jump.
However, due to the nature of how real mode works, it is impossible to
reconstruct the value of CS at those points. Luckily, the correct value
of CS seems to be set at the beginning of the function by auto-analysis
in real mode, so if we don't change it, it should be correct throughout
the function.
Also change the definition of some of the "CALLF" instructions to ensure
the correct value of CS is restored after the call.
@GhidorahRex GhidorahRex self-assigned this Sep 26, 2025
@GhidorahRex GhidorahRex added Type: Bug Something isn't working Feature: Processor/x86 Status: Triage Information is being gathered labels Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature: Processor/x86 Status: Triage Information is being gathered Type: Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ghidra incorrectly analyzes Borland C++ generated switches

2 participants