Skip to content

Commit

Permalink
Move evalCall align stack later to preserve VM state on throw
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxiaomao committed Oct 11, 2024
1 parent 62a6a1a commit fec14da
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions hld/Eval.hx
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,6 @@ class Eval {
var prevEax = api.readRegister(currentThread, Eax);
var eip = api.readRegister(currentThread, Eip);
var prevEsp = api.readRegister(currentThread, Esp);
// align stack
var stackValue = prevEsp;
stackValue = stackValue.offset(-0xFF);
stackValue = stackValue.offset((-stackValue.toInt() & 0xFF));
api.writeRegister(currentThread, Esp, stackValue);
// set registers
var asmOut = new haxe.io.BytesBuffer();

Expand Down Expand Up @@ -500,6 +495,12 @@ class Eval {
var isSingleStep = (api.readRegister(currentThread, EFlags).toInt() & 256) == 256;
if( isSingleStep )
setSingleStep(currentThread, false);
// align stack
var stackValue = prevEsp;
stackValue = stackValue.offset(-0xFF);
stackValue = stackValue.offset((-stackValue.toInt() & 0xFF));
api.writeRegister(currentThread, Esp, stackValue);
// run
resumeDebug();
if( isSingleStep )
setSingleStep(currentThread, true);
Expand Down

0 comments on commit fec14da

Please sign in to comment.