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.
#include <iostream>
int main(void) {
int myNumber = 16;
int myNewNumber = myNumber--;
std::cout << myNewNumber << std::endl;
std::cout << myNumber << std::endl;
return 0;
}
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.
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.
We can clearly see that r1 does in fact hold the value of 15 to which was decremented from our original value.
Next week we will dive into Hacking Post-Decrement Operator.