If you are looking for the decompiler itself, visit https://github.com/jindrapetrik/jpexs-decompiler
NEW : We have got a new blog where we post some interesting SWF internals info.
![List of issues](/flash/images/issue_list.png)
#446 incorrect decompiled code
Author:
helmy
![user user](/flash/images/user.png)
Date created:
Type: bug
Visibility: Everybody
Assigned to:
honfika
![developer developer](/flash/images/user_developer.png)
Labels: AS3
State: closed ![Help](/flash/images/help.png)
![Help](/flash/images/help.png)
> What steps will reproduce the problem?
open the attached file andgo to the last class (it has no name visible) and locate this
line
_loc3_.writeByte(_loc2_[param1 + 1 + (_loc4_ - _loc4_ % 3) / 3] >>> 8 * _loc4_ % 3 & 255 ^
_loc2_[param1] ^ 13592211);
> What is the expected output? What do you see instead?
the end result calculation from this line is incorrect because there are 2 missing
brackets
this line should be
_loc3_.writeByte(_loc2_[param1 + 1 + (_loc4_ - _loc4_ % 3) / 3] >>> 8 * (_loc4_ % 3 & 255)
^ _loc2_[param1] ^ 13592211);
> What version of the product are you using? On what operating system?
v.1.7.4.u1 nightly built 12/22/2013
OS: tested on Windiws xp 32bit, windows 7 64bit and linux mint 15 KDE 4.11 64bit
![Download](/flash/images/disk.png)
I've simplified your exaple, the following AVM2 instructions are executed:
getlocal_0
pushscope
getlocal_2
pushbyte 1
getproperty
MultinameL([PackageInternalNs(""),PackageNamespace("","3"),PackageNamespace("flash.uti
ls","3")])
label
pushbyte 8
getlocal 4
pushbyte 3
modulo
multiply
urshift
pushshort 255
bitand
getlocal_2
getlocal_1
getproperty
MultinameL([PackageInternalNs(""),PackageNamespace("","3"),PackageNamespace("flash.uti
ls","3")])
pushuint 13592211
bitxor
bitxor
setlocal_1
You can see, that the "& 255" (pusshort 255, bitand) is executed after multiply (and
urlshif), so the decompilation is correct, the brackets are not needed. (they should not
be there, becuse the decompilation should be equivalent with:
_loc3_.writeByte((((_loc2_[((param1) + (1)) + (((_loc4_) - ((_loc4_) % (3))) / (3))]) >>>
((8) * ((_loc4_) % (3)))) & (255)) ^ ((_loc2_[param1]) ^ (13592211)));
Assigned: →
honfika
![developer developer](/flash/images/user_developer.png)
Thank you for the detailed explanation, but i must say the brackets are need, and the
equivalent example you wrote is correct and gives the correct result
_loc3_.writeByte((((_loc2_[((param1) + (1)) + (((_loc4_) - ((_loc4_) % (3))) / (3))]) >>>
((8) * ((_loc4_) % (3)))) & (255)) ^ ((_loc2_[param1]) ^ (13592211)));
however the code without the brakes is not correct and does not give the same value
to test this further i have tested the code, see the attached file or see this online test
here http://wonderfl.net/c/BZT2
please fork it and edit the code to see what happens, or test the code on an IDE.
thanks
![Download](/flash/images/disk.png)
Then probably the "_loc4_ % 3" should be in brachets.
Is this value correct?
_loc3_.writeByte(_loc2_[param1 + 1 + (_loc4_ - _loc4_ % 3) / 3] >>> 8 * (_loc4_ % 3) & 255
^ _loc2_[param1] ^ 13592211);
yes "_loc4_ % 3" should be in brackets, this value is correct
Fixed.
State: new→upgraded
I'll close this due to inactivity. Feel free to create a new issue when you find any
problem.
State: upgraded→closed