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.

#1994 How do i use -replace in CLI to actually replace AS3 pcode?
Author:
Penteste27

Date created:
Type: bug
Visibility: Everybody
Assigned to:
Labels: AS3CommandlineImportP-code
State: closed 

I have a .swf file and all his scripts are AS3, here is my problem -
I export the pcode script i want to change with the following command:
(ffdec.bat -selectclass code.class_895 -format script:pcode -export script script
"file.swf")
OK, now i have class_895.pcode inside script\scripts\code...
After i modify it, how do i replace the original file pcode to this new pcode?
I tried:
(ffdec.bat -replace "file.swf" "file out.swf" code.class_895
script\scripts\code\class_895.pcode)
Which gave me an "Error: Bad Commandline Arguments!"
In the wiki it states that "<methodBodyIndexN> parameter should be specified if and only
if the imported entity is an AS3 P-Code" so i tried:
(ffdec.bat -replace "file.swf" "file out.swf" code.class_895
script\scripts\code\class_895.pcode 14915)
The last number is the method body index from a method I changed.
Which gave me:
"Replacing - only single argument passed, taking it as file to load replacements from
I/O Error during reading replacements file"
I also tried:
(ffdec.bat -importScript "file.swf" "file out.swf" script)
Which didn't show any errors, but didn't do anything either, i checked the output file and
it didn't make any change, but i think i read somewhere that import was deprecated so
idk...
Any clues on how I can replace AS3 pcode via command line?
I also tried 'ffdec.bat -replace "file.swf" "file out.swf" test.txt' with text.txt having
'code.class_895' and 'script\scripts\code\class_895.pcode' as arguments and i get
"test.txt is not reocginized as a CharacterId or a script name." ...
The correct format is:
ffdec.bat -replace "file.swf" "file out.swf" mypkg.MyClass inputfile.pcode 14915
as you tried,
but the current stable version contains a bug which causes the "Replacing - only single
argument passed..." message.
Please try nightly version 2518, it should work now.
Also, for the -importScript command - this command does not support P-code for importing.
State: new→upgraded
Type: question→bug
Type: question→bug
Now i'm getting another error:
ffdec.bat -replace "file.swf" "file out.swf" code.class_895 class_895.pcode 14915
Replace AS3 PCode
Invalid instruction name:package on line 1
The weird thing is, if i pass in a pcode file that doesn't exist i get still get an error,
but i also get the output file, and the method i passed with the method body id is
removed.
Also, another question, how can i enable "Show method body id" without going into the GUI?
Nevermind, i figured it out, i was passing in the whole class on the pcode instead of only
the method... but my last question still remains.
Adding -config showMethodBodyId=true before your commandline command (for example export)
should do the trick.
You can use -listconfigs command to list all available configuration settings.
Thanks, everything is working as i needed now! :)
You're welcome.
State: upgraded→closed