When I come back in this video, we want to take a look at the file structure of a smiley file because
we dig directly into this file and we didn't talk about the structure itself.
So this is something we want to do right now.
And you will see this is not really complicated.
We've got the structure most of the time, I guess 95% of this time.
So let's have a look at the first line.
We've got our dot class public and then we've got this capital L, which means we've got a class reference
and this one ends at the semicolon.
So we've got our class reference to the player class.
Okay, this was not really hard.
And the next line we've got this dot super and this means our player class is a subclass from this one
over here.
In this case it's travelling object.
As another example, if you take a look into our main activity, our superclass would be activity because
our main activity is a subclass from this activity class.
All right.
So also not that hard.
Next, we've got our source and this one is playable on Java, but I guess all said about this one.
All right, then we've got this hash tag at the beginning of the line and this is some kind of separation.
Okay, I guess I need to be a little bit more exact on this one.
The hash tag simply just means a comment and therefore the text is being ignored.
The text behind this hash tag, this is not an instruction.
This is simply just the text.
This text has been created by the APK tool to support us in understanding the file structure.
It is also being used to reference some values.
For example, we have some hex values and directly behind them we have a decimal representation after
a hash tag.
This means the APK tool gives us some information about static field instance fields, private and virtual
methods, and also tries to help us in converting hex into decimal values, which is pretty nice.
So to summarize this, a hash tag means a comment and in this case it is some kind of separator, but
only a visual one, not a technical one.
Alrighty.
So we've got several hash tags for different meanings over there, but between those we often have something
called annotations and this annotations are in our classes.
If we using in a classes within our player class, the smiley file needs to have this reference and
this is what this one is for.
In our case, we do not have in a class, for example, an enum or something like this, we will take
a look into our space paying application to also get familiar with this one.
All right.
Next, we've got this Static Fields, line six.
And the Static Fields starts with an hash tag underneath this one.
We've got all static fields within this class.
In this case, we only got one static field which is lives.
It's from type, correct integer.
Next we've got this instance fields also starting with an hash tag.
Now we've got all our class variables.
In this case, we've got power and shield.
So you see, I've added some new instance variable over here.
Next we've got a new hash tag and this one starts with direct methods and this one is regarding to private
methods, static methods and also constructors regarding to static methods.
This is a little bit special because the Dalvik bytecode has a certain reference for this one.
So we do not find static methods in there.
In this case, we can focus on constructors and private methods.
Okay.
And finally, we've got this between methods, which means we've got our public methods over there and
that's all this is the whole simplified structure.
And yeah, if you get familiar with this, you can navigate even more easier around this file.
For example, if you look for a certain instance field, you go up into this file, check out this hash
tag sign and see, okay, here, I've got all my instance fields pretty nice.
Okay, I guess I need to be a little bit more exact on this one.
The hash tag simply just means a comment.
Therefore, the text is being ignored.
The text behind this hash tag.
This is not an instruction.
This is simply just a text.
This text has been created by the APK tool to support us in understanding the file structure.
It is also being used to reference some values or types like we see this over here after a hash tag.
This means the APK tool gives us some information about static field instance fields, private and virtual
methods, and also tries to help us in converting hex into decimal values, which is pretty nice.
So to summarize this, a hash tag means a comment and in this case it is some kind of separator, but
only a visual one, not a technical one.
Alrighty.
Okay.
Perfect.
So let's pull out our space application and navigate around a little bit in this file and also have
a look into an annotations declaration.
Let's go.
All right, here we add our Ubuntu VM and let's check this file out.
So we go into our directory apps space being decompile.
I mean, it doesn't really matter or it doesn't matter.
We use the epic tool approach because the JDK output is a little bit different and we want to look at
the smiley code.
So we need the decompile version of the APK tool.
Let's do this once again together that we have the same state.
So epic tool the and then space pane.
Yes.
Then we go into this directory and I open the whole directory with Wizard Studio code.
There we go.
We also opened it next to us with Chad.
Then we have the Java code, which is a little bit more easier for us to navigate and read this code.
So space painting the compound and Shadi, excuse me.
And this one.
All right, so let's find this player class.
We use this one over here.
It needs to be compiled and indexed.
We also use this class field.
I guess this class field is enough.
If you use only this one, then we do not have all this distraction.
We've got this in components player.
All right.
And let's put the openness in the Somali code.
So we've got the components.
Play us, Molly.
And I got rid of this one and we enable Java even if it's not a Java code.
All right, here we go.
So let's go through this file once again.
Here's my graphic tablet.
Let's dive into this so we can see line one or line one.
This one over here, we've got our class public, then we've got this class definition L Then this ends
with the semicolon.
So we also got this player class definition, but this time we have a different package name because
we are within a different application.
But this is our player class.
This one over here.
Okay next we've got the super and this one nice we've got now a different one.
This means this comm Artemis component is our base class and our player class is the subclass from this
and we can see this over here.
We are extending this class.
This is what this line means.
Then we've got our sauce player.
I mean, we already talked about this one.
Not that hard.
So next we've got this annotations.
And it starts here and it also ends here.
What do we have right here?
We've got annotations come.
A famous annotations pulled weaver.
This seems to be a class.
Can we find this class over here?
Yes.
We are importing this class here at this line.
So to commodify it needs to have a reference to this class.
And this is what this annotation does.
Next.
We've got this one over here.
We've got the big annotations.
Remember, class player, dollar state.
We have already talked about this dollar sign, which means this one is our class player.
This is our separator, this dollar.
Or let me draw this in a different color.
And then we've got this in a class, in our player class, which means state.
So this is our in a class.
Let's see where we find this class over here.
Here.
So we are having a reference from a different class in our player class and this is what we've got over
here.
So if you take a look into this class, therefore, let me talk with the screen real quick.
There we go.
Oh, okay.
It's within this class right here.
So here we define this state, which is an enum, and we have this enum directly in our class.
So this can be in our class, a complete new class or an enum, for example.
This also affects this enum, and this is why we have this one over here, this player state.
Okay.
I'm going to clean this up real quick, then we can move on.
Yeah, this is all for this annotation files or this annotation description over here.
We've got our two references.
We've got this pooled viva and we also got our state OC.
Next we've got static fields.
We can see this with the starting hashtag over here and we've got static fields.
Default lives.
Sprite name.
Sprite name shield.
And these are over here.
So what's a clean this up real quick and then I need to drop this track this a little bit to us.
Okay.
Public static lives.
This one over here.
And you can see they also start exactly the same way.
Public static.
Final default last.
Public static final.
Okay, we've got this end over here in default lives, but this end is within our type definition here.
And we also got this value five.
We ought to get this over here and here.
These are our three public static values which are within this one over here.
Then we've got the new hash tag, this one, and this tells us now those static fields are at the end.
We've got new fields in this case, instance fields.
We've got three instance fields.
One, two, three.
Let's have a look.
We've got them over here.
This is an instant field, public and lives, and this is one score.
And here we have our state exactly like we've got this over here.
Cool.
These instance fields also end up here because here we've got now our direct method.
Direct methods.
Do you still remember what they are used for?
Of course you can.
Direct methods are used for private methods and constructors in this case.
Let's see, we've got this constructor in it returning void.
We do not see this constructor right here, but it's of course available.
The developer has not created a code for this, but if this object gets created, there needs to be
in constructor and therefore this is automatically added.
We cannot find this over here, but it's still there.
We can see this in the smart code.
So we already know more than the Java code.
Super nice.
We can also see this private and constructor methods end up here and here.
We've got our return methods.
Virtual methods are correct public methods.
And yeah, if I scroll down a little bit, we can see those virtual methods starts here and they end
up here because we do not have a new hash sign or hash tag.
This means we've got two public methods.
A state and set state.
This one and this one.
Nice.
And this is the whole file structure for this smiley file and also for all the other smiley files.
Let's have a look at another example.
So let me see what we've got.
The Sprite looks interesting because I can already see this dollar sign, which means we have an inner
class or an enum over here.
Let's have a look.
Now, we are not opening the Java code.
We are doing this only in the smiley code and then we will compare this afterwards.
So I can increase this a little bit.
Let's go.
All right.
Let's see what we've got.
Line one, we've got class public, our class reference capital.
This one ends at the semicolon over here.
The name is Sprite.
So we've got a class named Sprite.
Class.
Sprite.
And this class has a superclass.
So we've got a subclass from component.
We are extending this one extends component.
Okay.
Then we've got this annotations and we've already seen this in the smiley code over here.
So at this point, let's see what we've got.
We are importing this one over here once again.
Okay, next, we've got this member classes.
So this one is an inner class and this inner class is named layer can be an inner class or also an enum
type.
We can find this out if you take a look into the smiley code later on.
For now, let's keep this as an inner class.
So we simply say we've got an layer
and this variable name, let's call this also layer.
Okay, then we've got a lot of instance fields over here.
And we do not have an aesthetic field.
So this class only has instance fields and this one has a, b, g.
This in our class.
And string.
And these are floats.
Some funny names A, B, G, R, and so on.
These are all those variables.
And finally, if you scroll down a little bit, we've only got this direct method, which means we only
have a constructor.
Nothing else in this class over here.
So we can see direct method.
And this one is the constructor.
So this class which is named Sprite and is extending this component.
A component.
Sorry.
Let me scroll up a little bit.
This class now has all those stats.
This instance fields over here.
So we've got a float, a we've got a float B
and so on.
And we do not have any methods, so no method.
But we have in constructor this constructor over here, and this one is initializing all those values.
This one, by the way, is super interesting.
This looks really ridiculous at the beginning.
And we will learn about this later on.
So this is a floating point number.
And your computer does not store floating point numbers in a way you might think if you haven't heard
of floating point numbers before.
So this one gets stored in some really interesting way.
We've got a bit which is representing designed.
If it's positive, negative, then we've got some bits for the mentation and then we've got some bits
for the exponent.
And this is what this strange value is over here.
But we do not really have to know this because we can also take a look at this one and then we can see,
okay, this is the decimal representation of this floating point number.
In this case, it's simply 1.0.
Oops.
1.0.
Okay, that's just as a notice.
We can also look this instruction up.
Const hi 16 v zero.
And let's do this real quick.
It's a little bit off topic, but yeah, let's do this.
So I really hope you have bookmarked your dalvik up codes and let me get rid of this one.
So we are searching for const slash whoops.
Const.
Hi, 16.
There we go.
Puts the 16 bit constant into top most bits of the register.
Sounds complicated, but we are just taking the 16 bits of this value of these constants and put them
to our register.
So if we would have a value which is represented by 20 bits, we do not care.
We only take the top 16 bits out of this and puts it into this register.
So we are losing some decimal values over there.
Okay.
This was a little bit off topic right now, but if you encounter this, do not be afraid.
What I like to do in this way is I go into this and I see ock cons hi 16.
So we are putting six inputs into our VC register and we do not care what this one is.
So we get rid of this and there we go.
OC We zero is 1.0 as a floating point.
That's all that easy.
All right.
Okay.
Yeah, we have cleaned the screen a few times, but nevertheless, let's get back to the Java code,
put them side by side and see if we.
Yeah.
Were correct on this one.
I mean you can go back in the video if I was wrong, but and let's see.
All right.
Now they are side by side.
And I also super interested about this because I did not prepare it in this way.
I like to do these things on the fly.
Let's see.
So we are in the E.
If Gearbox bass pang.
The base paint and then components and then sprites money.
Yes.
I would say we were correct.
We were correct.
We've got only those values over here.
We've got this constructor which is missing.
We've got no further methods and we've also got no static fields.
And we can also see our, you know, the things we include this one over here.
And this is one.
This class, our superclass, we are extending.
Nice one.
Okay, cool.
By the way, if you are interested in this enum tax because let's have a look there.
We cannot find this.
And this is why we have this annotations.
We can now check sprite layer and within sprite layer we should see a reference to those values.
Background default effects.
Let's have a look.
There we go.
Let's make this a little bit bigger.
Also enable Java once again.
Here we go.
So again, let's do this once again.
I know it might be a little bit boring, but practicing this means learning those stuff.
And even if you just watch, you will learn something new.
Okay.
We do not go that deep into this.
We've got our sprite layer, so we've got our in our class sprite dollar layer and now we've got this
annotations.
We can see our end close in class is Sprite.
This is now our main class in this case.
And then we've got our inner class.
This has some excess flecks and a name which is layer.
We do not care about those Xs Flex right now.
So we've got our name layer.
So we've got sprite dollar layer.
And then we can see, okay, this one is now from type INA.
If you would have an inner class and this would be referenced here.
Okay.
And here we can see those labels.
So we can see, for example, this one actor's background default effects overlay.
This is how we can identify what we are dealing with, and this is why we have this annotations in our
smiley file.
Okay.
Once again, let's open this Java code side by side.
We go into our layer, sprite layer.
This one?
Yes.
And see if we can see them.
Background actor, default effects and so on.
Okay.
We do not dive into this deeper because this will be a little bit complicated if we take a look into
this.
So here you can see, okay, this looks interesting.
I'm pretty sure if we go this a step by step, line by line, we will be able to reverse engineer this
part.
But we are not doing this right now.
We keep these things simple at the beginning and we will increase the tempo later on.
All right.
That's all for this topic right now.
This topic was about divide structure.
And we have seen what those lines mean, that we've got separations between those hash tags and also
what this annotation does.
During the reverse engineering process of this file, we have seen we understand this file better and
better.
We get those external references, we get in our classes and also have a nice separation between instance
fields, static fields, private and public methods.
Okay.
And the next video, we take a look at our player dot smiley file, the extended version, and we will
do an reverse engineering process on this one together once again.
And then we will have a quiz where you can practice this on your own.
And afterwards we will patch our Space Pang application so that we will not be able to lose this game
anymore.
All right.
I see you in the next video.