Skip to content

Conversation

@LukeSerne
Copy link
Contributor

Before, the cleanup rule Rule2Comp2Sub only worked on explicit negations that used INT_2COMP. However, subtractions with constants are also replaced by additions during decompilation. This resulted in decompiler output like x + -1. With this change, constants are also considered. As such, the same example now looks like x - 1.

Before

void DecreaseValue(struct *param_1,int param_2)

{
  int new_value;

  if (param_1->mItems[param_2].mIsActive == true)
  {
    new_value = param_1->mItems[param_2].mValue + -0x1a;
    param_1->mItems[param_2].mValue = new_value;
  }
  return;
}

After

void DecreaseValue(struct *param_1,int param_2)

{
  int new_value;

  if (param_1->mItems[param_2].mIsActive == true)
  {
    new_value = param_1->mItems[param_2].mValue - 0x1a;
    param_1->mItems[param_2].mValue = new_value;
  }
  return;
}

Before, Rule2Comp2Sub only worked on explicit negations using INT_2COMP,
but subtractions with constants are also replaced by additions during
decompilation. This resulted in decompiler output like "x + -1". With
this change, constants are also considered. As such, the same example
now looks like "x - 1".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature: Decompiler Status: Triage Information is being gathered

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants