From e5d945277dd1d1b4cb33139d07a2022404e1b014 Mon Sep 17 00:00:00 2001 From: Romain Quinet Date: Fri, 11 Nov 2016 14:13:45 +0100 Subject: [PATCH 1/4] Added DoAction:Declare Dictionary --- index.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/index.js b/index.js index 29ae52a..e609b4d 100644 --- a/index.js +++ b/index.js @@ -208,6 +208,9 @@ function readSWFTags(buff, swf) { tag.depth = buff.readUIntLE(16); tag.tabIndex = buff.readUIntLE(16); break; + case SWFTags.DoAction: + tag.actions = readDoAction(buff); + break; default: tag.data = buff.buffer.slice(buff.pointer, buff.pointer + tagHeader.length); buff.pointer += tagHeader.length; @@ -218,6 +221,33 @@ function readSWFTags(buff, swf) { return tags; } +function readDoAction(buff){ + var actionCode; + var actions = []; + while((actionCode = buff.readUInt8()) != 0) { + var action = { + code: actionCode + }; + if(actionCode >= 0x80) { + var length = buff.readUIntLE(16); + // see other actions + // http://www.doc.ic.ac.uk/lab/labman/swwf/SWFalexref.html#tag_doaction + switch(actionCode) { + // Declare Dictionary + case 0x88: + var count = buff.readUIntLE(16); + action.dictionary = []; + for(i=0; i Date: Fri, 11 Nov 2016 14:23:03 +0100 Subject: [PATCH 2/4] Fixed function not returning actions --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index e609b4d..33d371a 100644 --- a/index.js +++ b/index.js @@ -245,6 +245,7 @@ function readDoAction(buff){ } actions.push(action); } + return actions; } @@ -324,12 +325,10 @@ function uncompress(swf, next) { break; case 0x46 : // uncompressed return readSWFBuff(new SWFBuffer( swf ), swf, next); - break; case 0x5a : // LZMA compressed uncompressed_buff = Buffer.concat([swf.slice(0, 8), lzma.decompressFile(compressed_buff)]); return readSWFBuff(new SWFBuffer(uncompressed_buff), swf, next); - break; default : e = new Error('Unknown SWF compressions'); From 53d3675823ead3cf74204aed743e6e34d3cc4be1 Mon Sep 17 00:00:00 2001 From: Romain Quinet Date: Fri, 11 Nov 2016 16:24:12 +0100 Subject: [PATCH 3/4] Positionning the pointer properly --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 33d371a..962addf 100644 --- a/index.js +++ b/index.js @@ -209,7 +209,9 @@ function readSWFTags(buff, swf) { tag.tabIndex = buff.readUIntLE(16); break; case SWFTags.DoAction: + var pointerend = buff.pointer + tagHeader.length; tag.actions = readDoAction(buff); + buff.pointer = pointerend; break; default: tag.data = buff.buffer.slice(buff.pointer, buff.pointer + tagHeader.length); From 132be237193ab407114717a0dda8f8a652101246 Mon Sep 17 00:00:00 2001 From: Romain Quinet Date: Fri, 11 Nov 2016 22:58:31 +0100 Subject: [PATCH 4/4] Added Push Data action parsing --- index.js | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 962addf..145e111 100644 --- a/index.js +++ b/index.js @@ -232,6 +232,7 @@ function readDoAction(buff){ }; if(actionCode >= 0x80) { var length = buff.readUIntLE(16); + var end = buff.pointer + length; // see other actions // http://www.doc.ic.ac.uk/lab/labman/swwf/SWFalexref.html#tag_doaction switch(actionCode) { @@ -242,14 +243,60 @@ function readDoAction(buff){ for(i=0; i