Reputation: 419
I am a Java developer. My recent project requires me to understand some decompiled ActionScript.
I think I understand most of the code since the syntax isn't much different from Java. However, it starts confusing me when I see
_loc_10 = {};
if (param1.lastIndexOf("?") != -1)
{
_loc_8 = param1.split("?", 2);
param1 = _loc_8[0];
_loc_13 = _loc_8[1];
_loc_10["mzsg"] = _loc_13;
}
if (param3 != null)
{
for (_loc_16 in param3)
{
_loc_10[_loc_16] = _loc_17[_loc_16];
}
}
_loc_10[this.CbSlotkey()] = this.CbSlotvalue();
_loc_11 = JSON.stringify(_loc_10);
_loc_15 = "";
_loc_15 = String.fromCharCode(this.CbSlot(), this.CbSlot2(), this.CbSlot3(), this.CbSlot4(), this.CbSlot5()) + this.CbSlot6();
_loc_12 = new URLVariables();
_loc_12.z = myzip(_loc_11);
_loc_12.b = MD5.hash(_loc_12.z + _loc_15);
param3 = _loc_12;
The upper half is all right, but I can't find CbSlotKey() or CbSlotvalue() defined anywhere in the entire code base. What would happen when a non-existent method is called? In Java, this code won't even compile. Does actionscript compiler not check methods' existences?
What does the keyword this mean in here? The class I am looking at is called HttpLoader. Is this pointing to HttpLoader or it could be pointing to something else? I find something calls like the one below in the same class, and the methods are clearly not defined in HttpLoader?
this.escape(ver_build)
Thank you very much in advance!!!
Upvotes: 0
Views: 486
Reputation: 389
One more possibility:
If the code you attached is in a closure, this
keyword can mean:
global
(root)Function.call(thisObj)
, then the thisObj
parameterUpvotes: 1
Reputation: 10665
Other answers have explained what will happen if a method is not existing in ActionScript3. (if method is referred to explicitely you'd get a compile error, if referred to by name you'd get a runtime error).
But maybe you should look for another explanation for your 'missing' methods.
In Actionscript3 it is possible to call functions with another this
reference than the default using the Function class (using the call
or apply
functions). As this looks like deliberately obfuscated code (CB maybe means "Cheat Blocker"?) this could very well be the case.
A call to the function would be like this:
yourObject.yourMethod.call(yourOtherObjectThatIsNowThis, arg1, arg2, arg3);
By the way: the method calls that are the arguments of the String.fromCharCode
function are definitely obfuscations - either meant for a decompiler or maybe for users of Cheat Engine or similar programs. So this makes it even more clear this is a deliberate obfuscation.
Upvotes: 1
Reputation: 131
What does the keyword this mean in here?
This
is a reference to a method’s containing object. When a script executes, the this
keyword references the object that contains the script. Inside a method body, the this
keyword references the class instance that contains the called method.
So I suppose in your case this is reference to HttpLoader
if the code you posted is not in Bound Method
What would happen when a non-existent method is called?
There should be run-time exception. I think if class is defined as dynamic then it may not throw an error but I never used dynamic classes so I am not really sure.
In Java, this code won't even compile.
This is the case for AS3 too if .
(dot) operator is used like in myObj.FooIsNotDefined()
. But if []
is used then compiler will not perform the check like in myObj["FooIsNotDefined"]()
but here should be run-time error.
Maybe HttpLoader
is extending some other class which has methods you need? Or maybe decompiler messed things up?
Is it possible in actionscript to add methods at runtime?
Yes if class is dynamic or via Prototype
Upvotes: 1
Reputation: 7510
First - it's hard to understand decompiled code :)
this
points to the current Class that is being used - for example if you have member variable with the same name as the param passed to a function, this.param will point to the member variable.
And yes, Classes can be dynamically modified if the class is marked as dynamic (check here: http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f89.html). Every unit is an Object
itself, so it's like adding properties to an object.
So in your case, it is possible that this particular key (this.CbSlotkey()
) is dynamically defined, exactly like other properties are being defined there (_loc_10[_loc_16] = _loc_17[_loc_16];
)
For example, this is a valid AS3:
this['test' + 'Func'] = function() {
trace ('test');
}
this.testFunc(); // traces test
Unfortunately, this means that there's not a lot options to understand what's going on. The best choice is to use debugger and track all those variables and the result of the actions. You may first try to give some proper names to all those messy variables in the code.
Edit: I forgot to mention, that if you call a dynamic non-existent method withing Flash, it will throw a runtime exception. If you try to call a method of non dynamic scope that does not exists, it will throw a compilation error.
Upvotes: 1