Posted: Sun Mar 02, 2008 1:31 pm Post subject: Change Serial number
i wrote a small program in C++ and compiled it to binary. Then i tried to reverse the binary code using Ollydbg .
And i was able to patch the jump to get ‘Good Boy’ message. Now, i want to change the hard coded serial: 4321; but i was not able to locate it in OllyDbg. Please let me know how to proceed? The code is given below:
using namespace std;
cout<<"Enter a 4-digit number:\n";
The if (nbr==4321) is evaluated to be ' not true ' and executes the ' else ' statement.
comparing your char* to 4321 actually compares the address where your string is stored with the address 4321. So in case your string would be stored at address 4321 it would return true. This is never the case in windows so it returns false every time.
char* nbr = "4321";
if (nbr =="4321")
The above example also compares the string addresses instead of the actual string content, it won't work either. Though it looks valid if you are not familiar with C / C++
char* nbr = "4321";
if (!strcmp(nbr, "4321"))
These 2 examples actually do compare the strings (the first by checking all the seperate chars, the second by using a handier method strcmp), but you probably figured that out by now _________________ Ignorance is bliss, knowledge is power
'String content and string address' are well explained by detten . And the code snippets accompanying it make the concept clearer...
Good clarity of subject and genuine willingness to share the knowledge with others.
This has helped me...
Though i had got my answer right following detten's initial tip; i would have not have learned why if (nbr 4321) is evaluated to be 'not true’ with out the additional explanation.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum