最近受某人委托研究一下某个游戏的汉化,发现这游戏完全是用Flash写的,主程序也是Adobe Flash导出的exe程序,其他的资源也都是在swf中。
由于这是我第一次接触这样的破解,希望将破解流程与大家分享一下。包括一些工具的可用性也会做一个总结。
一、网上流传的工具可用性
1. SWF Decompiler
叫这个名字的有两个软件,图标如下图所示:

右边的那个也就是“百度”上广为流传的“硕思SWF反编译工具”了,全名“Sothink SWF Decompiler”,这也就意味着这个软件的破解版更好找 :P
这个软件安装之后会叫你选择是否安装其他的工具,有一个“Sothink SWF Editor”,这个是一个能查看16进制dump文件结构的工具,只是没找到破解版比较可惜 _(:з」∠)_
更正:左边的全名是“FlashDecompiler Trillix”,功能强大,同样也能找到破解版的,非常推荐使用这个软件,因为这个工具自带了Dump结构查看工具,可以很容易地分析swf文件结构!破解版很完美!

不用破解版也就意味着你不能将文件导出为.fla文件,也就不能继续接下来的操作了。
2. ActionScript Viewer (ASV)
这款软件据说可以直接修改ActionScript,于是果断慕名寻找试(po)用(jie)版啊!
但是找了很久发现国内流传的破解版主要是2011年版本和以前的,我用过的能用的最高的版本也就是ASV2011,这个版本据说能支持到AS2,于是这款AS3写的游戏就无法支持了 :(
当然,现在这个软件现在有了ASV2012和ASV2013版本,但是售价是999刀,国内也是禁止购买的,连体验版我也没有找到,杯具啊。
3.
请看续篇,地址见页底
二、破解流程
1. 用SWF Decompiler把swf导出成fla文件
是时候掏出我们的神器了,Sothink 7破解版(此贴不会发布任何破解程序 =。=),启动LOGO如下:

把需要拆解的SWF拖动到窗口里面,点开下图上部的“Export FLA”,保存到一个路径,点“OK”。

导出的目录将会是一个fla文件加上很多as脚本,接下来就是拼积木的过程。
2. 用Adobe Flash组装动画文件
经过上一步的操作,所有的as文件全部都是以明文的形式存放的,包括这个游戏的脚本,如下图所示:

汉化的任务就是将脚本提取出来,将译文封装回去,让程序正常运行,所以接下来要组装这些文件。
首先用Adobe Flash载入导出的fla文件,在【文件】-【ActionScript设置】的“源路径”中添加整个导出的目录。(我这里把目录转移了,所以和之前的截图目录不一致,总之就是第一步中导出的那个目录。)并且将添加的目录上移至第一位,否则可能会少导入一些内容。如图:

然后在【视图】-【库】中把需要的添加类的元件的类给添加好,例如这个声音就有一个对应的类:

上图是右击“001f”-【属性】的界面,在右键菜单中你还可以看到编辑类,点开就可以编辑相应的代码了。
但是这里要注意一个问题:用SWF Dec导出的fla文件里面的元件对应的类可能并不是正确对应的,你需要在上图的界面中设置好对应的类名。
当然,你可能还会遇到一个问题,那就是目录下的as类文件都有对应的了,Adobe Flash不允许使用,就是如下图所示的情况:

那就比较麻烦了,需要手动先去把所有的“为ActionScript导出(X)”这个勾给去掉,然后再一个一个设置正确。
对于这个游戏,所有swf里面的音频是人物对话,而人物对话的类里面只是简单的继承,所有的音频都是一样的,不改也是没有问题的,可以播放出声音。但是通过阅读as源码发现,该游戏调用的是getDefinitionByName( )来建立语音表的,所以类名和语音的对应关系至关重要,也就是说得手动去改每个音频对应的类名 _(:з」∠)_
3. 导出swf偷梁换柱
在【文件】-【导出】-【导出影片】菜单中就可以导出SWF影片了,然后替换游戏原来的SWF。看!可以运行了:

实际上我把文本改成了“<这句话是测试的中文翻译。>”,但是游戏只识别了日文字符集里面的文字,所以接下来还要进行转区处理。因为我保存的as已经是UTF-8了,而且反解也可以解出原文,很显然是游戏忽略了GBK里面的文字,这个问题以后再写。
继续运行,卡住了!!!本来是要放语音的,但是卡住了,语音没有播放出来,那么问题来了,这是为什么?(不要打我,我是真心求教)
2014.11.05 对于本篇中未解决的问题,我进行了进一步研究:
Recently, someone asked me to look into localizing a game into Chinese. It turned out the entire game is written in Flash—the main executable is an .exe exported from Adobe Flash, and all the other assets live inside .swf files.
Since this is my first time tackling this kind of reverse-engineering, I’d like to share the workflow with everyone, along with a quick rundown of how usable the available tools are.
1. Usability of Tools Floating Around Online
1. SWF Decompiler
There are actually two programs that go by this name, with icons shown below:

The one on the right is the widely known “Sothink SWF Decompiler” you’ll see everywhere on Baidu—which also means a cracked version is much easier to find :P
After installing it, the installer asks whether you want to install other companion tools, including “Sothink SWF Editor,” a tool capable of inspecting the hex dump structure of SWF files. Too bad I couldn’t find a cracked version of that one _(:з」∠)_
Correction: The full name of the one on the left is “Flash Decompiler Trillix.” It’s super powerful, you can find a cracked version for it too, and I highly recommend it—it comes with a built-in Dump structure viewer that makes analyzing SWF file internals a breeze! The cracked version works flawlessly!

Without a full/cracked version, you won’t be able to export files to .fla, which means you can’t proceed with the remaining steps.
2. ActionScript Viewer (ASV)
Rumor had it that this software lets you edit ActionScript directly, so I immediately went hunting for a “trial” (read: cracked) version!
After searching for a long time, I found that the cracked versions circulating in China are mostly the 2011 release or older. The newest working version I managed to try was ASV 2011, which reportedly only supports up to AS2—so no luck with this AS3-based game :(
Sure, ASV 2012 and ASV 2013 exist now, but they cost $999 and aren’t even sold in China—I couldn’t even find a demo version. What a tragedy.
3.
Please check out the follow-up post—link at the bottom of the page.
2. The Cracking Workflow
1. Export the SWF to an FLA File with SWF Decompiler
Time to whip out our trusty weapon: Sothink 7 cracked edition (no cracks will be posted here =。=). Its splash logo looks like this:

Drag the SWF you want to dissect into the window, click “Export FLA” at the top (as shown below), pick a save path, and click “OK”.

The exported directory will contain one .fla file along with a bunch of .as scripts. Next comes the Lego-assembly phase.
2. Reassemble the Project in Adobe Flash
After the previous step, all the .as files are stored in plain text—including the game’s scenario scripts, as shown below:

The goal of localization is to extract the script, pack the translated text back in, and keep the program running smoothly—so next we need to put these files back together.
First, open the exported .fla file in Adobe Flash, go to [File] -> [ActionScript Settings], and add the entire exported folder to the “Source path”. (I moved the folder here, so the path doesn’t match the earlier screenshot—either way, just point it to the folder exported in step 1.) Make sure to move the added folder to the top of the list, otherwise some files might not get imported. Like this:

Next, go to [View] -> [Library] and bind the proper classes to the symbols that need them. For example, this sound asset has a corresponding class:

The screenshot above shows the dialog after right-clicking “001f” -> [Properties]. In that same right-click menu you’ll also see “Edit Class,” which lets you open and edit the corresponding code directly.
However, watch out for one catch: in the .fla exported by SWF Decompiler, the classes linked to library symbols might not actually match up correctly—you’ll need to fix the class names in the dialog above.
Of course, you might run into another snag: all the .as class files in the directory are already bound to other symbols, so Adobe Flash won’t let you assign them, just like in the screenshot below:

That gets pretty tedious: you have to manually uncheck “Export for ActionScript” on every single symbol first, and then go back and set each one properly one by one.
For this game, all the audio clips inside the SWF are character voice lines, and their classes are just simple subclasses—all the audio classes are identical, so leaving them untouched still plays audio fine. However, reading the AS source revealed that the game calls getDefinitionByName( ) to build its voice lookup table, meaning the mapping between class names and audio clips is crucial. In other words, you have to manually fix the class name for every single voice clip _(:з」∠)_
3. Export the SWF and Pull the Ol’ Switcheroo
Go to [File] -> [Export] -> [Export Movie] to export the SWF, then replace the game’s original SWF with it. Look! It runs!

I actually changed the line to "<这句话是测试的中文翻译。>" (“This sentence is a test Chinese translation.”), yet the game only rendered the characters that exist in the Japanese charset, so I’ll need to deal with encoding/character-set handling next. Since I already saved the .as file in UTF-8 and decompiling it back recovers the exact original text, the game is clearly ignoring GBK-only Chinese characters—I’ll write about that problem later.
Keeping it running… AND IT FROZE!!! A voice line was supposed to play right there, but the game froze up and no audio came out. So here comes the million-dollar question: why?! (Don’t hit me, I’m genuinely asking for help!)
2014.11.05 — I did some further research into the unresolved issues from this post: