google-code-export / asdec

Automatically exported from code.google.com/p/asdec
1 stars 0 forks source link

ParseException #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There is a problem while parsing an SWF that contains a function which has a 
jump or if to the next instruction after it. When function is read from the 
byte stream a new 'ActionDefineFunction' object created. All sub-actions are 
placed into 'code' field. But when you try to retreive raw byte code of such 
function by calling method 'getBytes' you get an extra byte FF in the end 
attached. That's because it's actually doesn't give you an original code but 
rather assembles a new stream from these sub-actions. Thus branch instructions 
count the instruction next after function (only if they go there) to its boby 
length leading to wrong value for 'codeSize' field in the function's byte code.

ActionDefineFunction.java
100    byte codeBytes[] = Action.actionsToBytes(code, false, version);
101    sos.writeUI16(codeBytes.length);

Here it goes to be +1 due to the wrong translation of the list of actions to 
bytes.  

What steps will reproduce the problem?
1. Parse an SWF that contains such a function. Sometimes it goes ok, but you 
still can see an exception in the log and a wrong "255" instruction in the 
P-code.

What is the expected output? What do you see instead?
From log:
??? 21, 2013 10:48:02 AM com.jpexs.decompiler.flash.SWFInputStream 
readActionList
SEVERE: parsing error
com.jpexs.decompiler.flash.action.parser.ParseException: ParseException:Unknown 
instruction name :action255 on line 69
    at com.jpexs.decompiler.flash.action.parser.ASMParser.parse(ASMParser.java:250)
    at com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2.<init>(ActionDefineFunction2.java:119)
    at com.jpexs.decompiler.flash.action.parser.ASMParser.parse(ASMParser.java:234)
    at com.jpexs.decompiler.flash.action.parser.ASMParser.parse(ASMParser.java:265)
    at com.jpexs.decompiler.flash.SWFInputStream.readActionList(SWFInputStream.java:512)
    at com.jpexs.decompiler.flash.tags.DoActionTag.getActions(DoActionTag.java:108)
    at com.jpexs.decompiler.flash.action.gui.ActionPanel$3.run(ActionPanel.java:216)

What version of the product are you using? On what operating system?
Ffdec 1.3
Windows 7 64-bit

Could you provide the SWF file you have problem with?
If the answer is yes, then please attach it here or send me it via email.
Could you at least attach PCode source?

Here what you get in ASdec 1.2:

Jump loc02a6
loc0291:Push 0.0 "checkPressedButtom"
CallFunction
Pop
Jump loc02a6
loc02a6:
}
loc02a6:SetMember
Push "eventListener"
GetVariable
Push 1 "Key"
GetVariable
Push "addListener"
CallMethod
Pop

And now the same chunk in the FFdec 1.3:

Jump loc02a6
loc0291:Push 0.0 "checkPressedButtom"
CallFunction
Pop
Jump loc02a6
loc02a6:Action255
}
SetMember
Push "eventListener"
GetVariable
Push 1 "Key"
GetVariable
Push "addListener"
CallMethod

Do you have the original source code which produced the wrong
decompilation? If yes, then please attach it.

Please provide any additional information below.

Original issue reported on code.google.com by plisnich...@gmail.com on 21 Feb 2013 at 8:56

GoogleCodeExporter commented 9 years ago
Hi,
it is fixed in version 1.3.1,
try it again.

Original comment by jindra.p...@gmail.com on 23 Feb 2013 at 8:58