Hello and welcome back.
In this lesson, I'm going to show you how to create variables.
So to create variables, we will open the template as before.
And then select Dump 1.
Go to "Memory Map."
And this time you select BSS, uninitialized data.
The difference between this and data is that data is fixed—the constants.
That means after you reboot the program, the data is still in the memory.
But for BSS, whenever you reboot, everything that is there will be wiped clean.
So that's why they are called variables.
So you can put your variables here.
So double-click on this.
And in your Dump 1,
you can make use of any of these free spaces here to create your variables.
So let's say you want to create a variable here.
So just select this location.
Right-click, copy the address.
Copy the address.
So here, so you can store a number here.
Now we go to your code and then hollow out all these instructions here: "Binary," "Fill with NOPs."
And then let's write our code.
Now let's copy a number here.
Maybe we'll copy 12345678 here.
So just press spacebar and then type the MOV command.
And then "QWORD PTR,"
square brackets,
put in the hex prefix, and then copy and then paste your address which you copied.
And let's say we want to store the number.
So we put hex prefix: 12345678.
Click "OK."
So this is how you can store a number directly into a variable here.
Next thing, we are going to store the value in - to this location.
So we can do that as well.
So copy this other variable here.
So now we have another variable—two variables already.
So note that a variable is just a memory address.
So now right-click this other variable and then copy this address.
Come back here, press spacebar, type "MOV," type "QWORD" again, "PTR," and then hex prefix, paste the new variable.
And this time we are going to move whatever is in -, say whatever is in -, we want to move over there.
Click "OK."
Now we put a breakpoint and we run.
Then step over, and now you notice our two variables are there.
They are now empty, still empty: 0050.
Maybe this one is from the running of the program, which is other parts of the instructions—
not our instructions, so just ignore it.
Don't worry about 01 there.
This variable changes all the time, so it's OK.
We will overwrite whatever is there.
So now let's step over and see this value copied there.
So we step over and now you can see 12345678 in reverse order.
Now we are going to copy whatever is in -.
We're going to copy it into the next variable, which is here.
Step over that, and you can see our - value, 1, is now copied here: 0000 and all the way 01.
So this is how we can create variables for x64dbg.
As usual, if you want to save this, you can patch: click "Patch File," and then you can give it a name.
Maybe you want to call it "03_Variables."
".exe," then click "Save."
So that's all.
In this video, we have learned how to create variables by using the BSS segment of the memory and how
to also write values directly into the variable, and also how to write the value in the register to
the variable.
So—
and also the fact that the variables are different from constants,
you know, in the sense that for constants—initialized data—whenever you reboot, the data is still there.
But for variables, whenever you reboot, everything is lost.
So that's all for this video.
Thank you for watching.