: WARNING - support of the decompiler is now VERY LIMITED. There are no active developers. This means waiting times in the issue tracker are very long and mostly depend on community. Sorry for the inconvenience.

List of issuesList of issues

#446 incorrect decompiled code
Author: user helmy
Date created:
Type: bug
Visibility: Everybody
Assigned to: developer honfika
Labels: AS3
State: closed Help

> 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
Downloadtestfile2.swf (34 KiB)
developer
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:developer honfika
user
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
Downloadtestcode.as (3 KiB)
developer
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);
user
yes "_loc4_ % 3" should be in brackets, this value is correct
developer
Fixed.
State: new→upgraded
developer
I'll close this due to inactivity. Feel free to create a new issue when you find any problem.
State: upgraded→closed
 
Google Translate: Translate to Czech Translate to Slovak Translate to Russian Translate to Hungarian Translate to Swedish Translate to French Translate to German Translate to Spanish Translate to Italian
Change style: oceanic classic