martinheidegger / as3-commons

Automatically exported from code.google.com/p/as3-commons
0 stars 0 forks source link

Error decompressing byte array via ByteCodeType.fromByteArray #75

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use ByteCodeType.fromByteArray(ba, ApplicationDomain.currentDomain); where 
ba is the byte array for a swf ( as included in the example 
:[Embed(source="someswf.swf", mimeType="application/octet-stream")]
private var swfInput:Class;
function parseSWF():void {
  var ba:ByteArray = new swfInput() as ByteArray;
  ByteCodeType.fromByteArray(ba, ApplicationDomain.currentDomain);
})

What is the expected output? What do you see instead?
I was expecting some sort of information, but instead I got this error:
Exception fault: Error: Error #2058: There was an error decompressing the data.
    at flash.utils::ByteArray/_uncompress()
    at flash.utils::ByteArray/uncompress()
    at org.as3commons.bytecode.reflect::ReflectionDeserializer/read()[C:\projects\as3-commons\as3-commons-bytecode\src\main\actionscript\org\as3commons\bytecode\reflect\ReflectionDeserializer.as:83]
    at org.as3commons.bytecode.reflect::ByteCodeTypeProvider/fromByteArray()[C:\projects\as3-commons\as3-commons-bytecode\src\main\actionscript\org\as3commons\bytecode\reflect\ByteCodeTypeProvider.as:119]
    at org.as3commons.bytecode.reflect::ByteCodeType$/fromByteArray()[C:\projects\as3-commons\as3-commons-bytecode\src\main\actionscript\org\as3commons\bytecode\reflect\ByteCodeType.as:149]
    at inspect::C()[/Users/george/Documents/fdt/PointTest/src/inspect/C.as:16]

What version of the product are you using? On what operating system?
as3commons-bytecode-1.0-RC5.swc
as3commons-lang-0.3.5-SNAPSHOT.swc
as3commons-logging-2.5.2.swc
as3commons-reflect-1.4.2.swc
Flash Player 11.0.0.60 (Incubator build) on osx 10.6.8

Please provide any additional information below.

This is the first time I use the library, so not sure what to expect in this 
case.
I have however printed some ABC related data via:
var io:SWFFileIO = new SWFFileIO();
var swfFile:SWFFile = io.read(ba);
var abcTags:Array = swfFile.getTagsByType(DoABCTag);
for each(var tag:DoABCTag in abcTags) trace(tag.abcFile);

Any other options for reflection ?

Thank you for your time,
George

Original issue reported on code.google.com by Orgi...@gmail.com on 4 Sep 2011 at 2:19

GoogleCodeExporter commented 9 years ago
I see you're using flashplayer 11, did you compile this SWF with these new 
compression settings perhaps?

Original comment by ihatelivelyids on 4 Sep 2011 at 6:52

GoogleCodeExporter commented 9 years ago
I've switched SDKs in test project and tried Flex 3.6 with Flash Player 10 and 
Flex 4.1 with Flash Player 10.1 (compiling both B.as and C.as) and got the 
exact same error. 
So far I've used FDT 4.5.3.1358 and there was a default option ticked on 
project to use Apparat for optimizations. I've unticked the option, thinking 
Apparat might compress data in way that isn't compatible with 
as3-commons-bytecode, but had no luck.

Switched to Flash Builder 3 (Flex 3.2) and Flash Player 10 and still no luck 
(got the same error).

Am I missing something ? Should I add some sort of compiler flag to avoid 
compression ?

Thanks for the help,
George

Original comment by Orgi...@gmail.com on 4 Sep 2011 at 2:01

GoogleCodeExporter commented 9 years ago
Still no joy with the fromByteArray method, but fromLoader work fine:

var ba:ByteArray = new swfInput() as ByteArray;
            l = addChild(new Loader()) as Loader;
            l.loadBytes(ba);
            ByteCodeType.fromLoader(l.contentLoaderInfo);
            l.contentLoaderInfo.addEventListener(Event.COMPLETE,lready);

A bit off topic: Is is possible to get the body of a method as a human readable 
value ?

Original comment by Orgi...@gmail.com on 4 Sep 2011 at 2:29

GoogleCodeExporter commented 9 years ago

Original comment by mastakan...@gmail.com on 11 Sep 2011 at 6:28

GoogleCodeExporter commented 9 years ago
Hey there,

I guess the problem is with parsing an embedded SWF then. I'll try to look into 
it.
As for your question 'Is is possible to get the body of a method as a human 
readable value'. What I suspect is that you would like to convert the opcodes 
back to actionscript source code.
This is technically possible, but it would mean writing a full-blown 
actionscript based de-compiler, which is a task that I am not prepared to 
undertake, I'm sorry :)

cheers,

Roland

Original comment by ihatelivelyids on 11 Sep 2011 at 6:42

GoogleCodeExporter commented 9 years ago
Hello,

Thank you for taking you time to look into this. It's good that I have the 
other option so it's not an urgent matter.
Regarding actionscript code, I imagine it's not a simple task. I did manage to 
get my head around the bytecode by reading the documentation 
(http://learn.adobe.com/wiki/display/AVM2/5.+AVM2+instructions) ...so 
yeah..sorry, just me being lazy (clear case of RTFM :) )

I imagine the ByteCodeType.fromByteArray will get attention at some point, so 
thank you in advance.

All the best,
George

Original comment by Orgi...@gmail.com on 11 Sep 2011 at 9:57

GoogleCodeExporter commented 9 years ago

Original comment by martin.h...@gmail.com on 12 Sep 2011 at 6:12

GoogleCodeExporter commented 9 years ago
Still not working

Original comment by ndalp...@gmail.com on 12 Jun 2012 at 12:10

GoogleCodeExporter commented 9 years ago
Still not working.

Original comment by nick.wig...@gmail.com on 8 Mar 2013 at 11:34

GoogleCodeExporter commented 9 years ago
Hi there,

currently I don't have any time to work on as3-bytecode, I am simply too busy 
with my dayjob and other things.
Any effort on your part to help fix this will be greatly appreciated. I'm 
afraid just dumping a 'Still not working' comment is not a great motivator for 
me...

Original comment by ihatelivelyids on 11 Mar 2013 at 10:13