Hello and welcome back.
We are now going to patch this to always show the good message, which is good work, no matter what the
serial number or the username.
Now, if you notice in the previous program, what we did was we already managed to fish out the serial
key for the serial name for the name cracker.
And the serial key is this, 932279.
So if we put 932279, we get okay.
But if you were to change the username, let's say you remove the R character, it says wrong.
That means if you want to use this serial key, you must key in this name, cracker.
If your name is different, then the registration number, serial, is also wrong.
Just be aware of that.
Now in this lesson, we are going to patch the file such that no matter whatever the username or whatever
the number, it always will show the right message.
So let's get started.
So now let's see.
Over here, we are going to put a breakpoint as usual here.
And we run this now.
And when it pops up, we are going to put cracker but a wrong registration number.
So when you click okay, it comes to this one, we can now, uh, do a graph, and we are going to trace it.
Okay.
Notice that it came here and then it jumped here.
And then it's going to test -. - is negative one.
And because of that, uh, this jump is taken.
Let me go to the left.
So the easiest way to solve this is to just NOP this, to go to the right.
But you will notice that something, um, weird will happen when you do that.
If you just NOP this, this message box, if you just NOP this, it will go to the right.
Yes, but it will not show the message box.
Why is that?
Because of this - value.
- value is negative one.
Now the message box API requires the - to be other than negative one.
That means you need to put, for example, zero, right?
You need to push zero here.
Then the message box will show.
Let me demonstrate.
What if you.
Now we NOP this, I already put a comment up.
So I'm going to go to this assembly view.
And I'm going to just NOP this blindly.
Just put right-click and binary fill with NOPs.
So now it is filled with NOPs.
Let's go back to graphical view.
And now I'm going to run, okay.
So let's click okay and try again.
So now it's supposed to go to the right because I already NOPed this.
So let's run it.
And okay, so now it's here, and step over.
Okay, so it's coming here.
All right, remember, this is already a NOP.
Take a look.
It's already a NOP.
All right.
So let's go to graphical view again.
So because it's already a NOP, it will not go to the left.
It will always go to the right.
There you go.
It's going to push these two parameters to the stack.
It's going to push all these four parameters, 1, 2, 3, 4.
If you look at the API for, let's look for API, MSDN, uh, MessageBox API, you will see the parameters
for that API.
And these are the parameters.
Okay.
Uh, the first parameter is the handle to the parent, handle to the owner.
So the handle to the owner should not be negative one.
If is negative one, then the window will not show.
The message box will not show.
So as you can see from here, the first parameter is, first parameter is negative one.
Second parameter is the message you want to show, which according to this is, uh, the text
that you want to show, the text that you want to show this one, the message will be displayed.
That's the second parameter.
Good work.
Third parameter is the caption for the message box caption.
And the fourth parameter is the type, that means what type you want to have, a button or an icon, or
what type of icon, or how many buttons, and so on.
But we are not concerned with that.
We are just concerned with the first parameter.
First parameter should not be negative one, but in this case, the value of - is negative one.
You see that when you push this, you are pushing negative one.
You.
Let's take a look.
This one takes two bytes.
It is only one byte.
Push - is one byte.
If you push zero, it takes two bytes.
As you can see from here, push zero is actually two bytes, but you only have one byte.
So if we try to assemble it, push zero here, it will fail, okay.
So it will.
You can't assemble.
So the only way to solve it is to do something.
Let me go back to the graph to do something over here.
Here.
Right.
Make sure that - becomes zero here, because it will always come here before it goes to the bad message.
So we cannot simply, uh, push zero here.
So we have to modify here.
So to modify this, we right-click this, put a comment there, say that we want to XOR -.
So when we XOR -, what we are doing is setting it to become zero.
So let's go back here and follow this assembler.
All right, so we have to do this.
Press space to assemble an XOR, and notice it's the same size.
All right.
Next thing, we need to NOP this.
Sorry, I didn't assemble it.
So let's do it now.
XOR, click okay.
All right.
Next thing is to NOP this, because we don't want it to subtract and cause it to become negative
one.
So we'll binary edit it.
Sorry.
Wrong one.
Right-click and binary fill with NOPs.
And that's it.
Okay.
So now we go back to our graph view.
You go back to our graph, you will find that this one will become - will be zero.
Let's try and see.
Click run, and then we enter any wrong registration number.
And then comes here, and step over.
Okay, now this one is already XOR, XOR.
Let me refresh this so you can see clearly.
Refresh, okay, it's already XOR -, correct.
So our - is already zero, okay.
So now we come here, and straight away we will come and we test it. - is zero, right.
So it will not work.
So now it's going to push all this.
And now we come to the call to message box.
And we see that - is now zero.
Because of that, it will now show the message box.
So I click continue.
The message box shows.
So that's how you do it, okay.
So be very careful.
You cannot simply NOP.
You have to always check the parameters for the message box to make sure they are legal values, not
negative one for the first parameter.
Right.
So now you can patch this.
So we are going to patch, patch file.
Click on this and give it another name with -2 at the back.
Click okay.
And now we can test our patch directly.
Enter any username.
And then here we click any kind of registration number, and you click okay.
It's good work.
So it's working.
So this is how you should be careful when you are trying to patch message boxes.
Um, when you want to put a NOP for message box, you must always check the first parameter of the message
box to make sure it is a legal value.
In this case, it cannot be negative one.
So that's all for this video.
Thank you for watching.