Part 48 – Debugging Post-Decrement Operator

For a complete table of contents of all the lessons please click below as it will give you a brief of each lesson in addition to the topics it will cover. https://github.com/mytechnotalent/Reverse-Engineering-Tutorial

Let’s re-examine our code.

  1. #include <iostream>
  2. int main(void) {
  3. int myNumber = 16;
  4. int myNewNumber = myNumber--;
  5. std::cout << myNewNumber << std::endl;
  6. std::cout << myNumber << std::endl;
  7. return 0;
  8. }

We see our very simple C++ code above to which we are doing nothing more than assigning a number into a variable to which we init another int variable and assign the original variable to which it is post-decremented. We then output each value to the terminal.

Let’s debug.

Part 48 – Debugging Post-Decrement Operator - 图1

It is clear that the value for the post-decrement operator gets loaded into r1 at main+68 so let’s break at main+72.

Part 48 – Debugging Post-Decrement Operator - 图2

We can clearly see that r1 does in fact hold the value of 15 to which was decremented from our original value.

Part 48 – Debugging Post-Decrement Operator - 图3

Next week we will dive into Hacking Post-Decrement Operator.