Skip to content

bdshemu: Fix MOVS/STOS/LODS/SCAS/CMPS silent no-op at MaxInstructionsCount boundary#116

Merged
vlutas merged 1 commit into
bitdefender:masterfrom
Luchinkin:bugfix/string-ops-budget-boundary
Jun 29, 2026
Merged

bdshemu: Fix MOVS/STOS/LODS/SCAS/CMPS silent no-op at MaxInstructionsCount boundary#116
vlutas merged 1 commit into
bitdefender:masterfrom
Luchinkin:bugfix/string-ops-budget-boundary

Conversation

@Luchinkin

@Luchinkin Luchinkin commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

The MOVS/STOS/LODS/SCAS/CMPS handlers gate their body on:
while (Context->InstructionsCount < Context->MaxInstructionsCount),
but the outer dispatch loop has already incremented InstructionsCount to the slot it spent on this dispatch. When those values are equal at that moment (e.g. when MaxInstructionsCount == 1), the body is skipped entirely and ShemuEmulate returns SHEMU_SUCCESS with no memory move, no RSI/RDI advance, no RCX decrement, and no flag update.

Switched both handlers to do { ... } while (...) so the first
iteration always runs.

@vlutas
vlutas merged commit 41d8744 into bitdefender:master Jun 29, 2026
11 checks passed
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.

2 participants