1 / 13

剖析 SWF 文件结构 探秘 AVM 运行原理

剖析 SWF 文件结构 探秘 AVM 运行原理. ——By laan 2009.12.22 http://www.laaan.cn. Why. 1. 明白自己在做什么. 2. 更底层的了解一些现象 堆栈不平衡、类型错误 error list. 3. 优化你的程序. 4. 加密和破解. 5. 重构虚拟机 —— 如果你足够 NX 的话. SWF 文件结构. Just Flashplayer9++. Tag ID. Head. 1.FWS|CWS 2.Player Version 3.File Length

elke
Download Presentation

剖析 SWF 文件结构 探秘 AVM 运行原理

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 剖析SWF文件结构探秘AVM运行原理 ——By laan 2009.12.22 http://www.laaan.cn

  2. Why 1.明白自己在做什么 2.更底层的了解一些现象 堆栈不平衡、类型错误 error list 3.优化你的程序 4.加密和破解 5.重构虚拟机——如果你足够NX的话

  3. SWF文件结构 Just Flashplayer9++ Tag ID Head 1.FWS|CWS 2.Player Version 3.File Length 4.Frame Size(Stage size * 20) 5.Frame Rate 6.Frame Count Tag Length Tag Tag Data Tag Tag …

  4. Head Data 1.FWS|CWS 2.Player Version 3.File Length 4.Frame Size 5.Frame Rate 6.Frame Count

  5. Tag FileAttributes Tag as3 GPUnetwork Metadata Tag 携带信息 SetBackgroundColor Tag 设置背景 ScriptLimitTag 递归深度 脚本运行时间 Protect Tag 防止导入 DoABC Tag SymbolClassTag ShowFrame Tag EndTag携带数据,加密

  6. DoABC Tag 82 72 Tag Haxe 加密 Tag ID Tag Length name Tag Data Abc AVM2 Actionscript Virtual Machine

  7. AVM2 1. ABC data (Actionscript Byte Code) 2. ABC数据结构 3. 运行原理 4. 指令

  8. ABC数据结构 结构由大到小 Script Class Test { private var a:String; private const BIG:uint = 50; private function test():void{ trace(doStr()); function doStr():String { return “NULL” } } } Class Class Trait Instance Medthod Trait Trait Slot/Const Trait Method Function Trait Method Body pccode

  9. AVM2运行原理 ABC Execute Load Link Verify Load:加载ABC数据到内存并解析,得到所有数据单元 Script,Class,Instance,Trait,Strings, … Link:各单元之间的关系建立 比如Class与Instance, Method与MethodBody Verify:检查各abc数据的正确性。要是不检查正确性,player可以做很多坏事 分支检查,堆栈检查,比如一个MethodBody被链接到两个Method上 Execute:开始执行ABC数据。 官方:最后一个script结构的init方法 Actually:文档类所在Script结构的init方法

  10. Call Method Call Method Method Body 0 getlocal0 1 pushscope 2 pushnull 3 coerce_s 4 setlocal1 5 pushstring 7 setlocal1 8 getlocal1 9 pushstring … Stack Scope Local data pccodes

  11. 程序优化 从pccode层面来程序优化… 1.属性、方法访问时的搜索 2.分支跳转 局部变量一般情况下是不会编译到swf中去。所以无需考虑其长度 比如 var theLengthOf Array:uint Lookupswitch指令的特殊结构。 动态调用会消耗更多的搜索时间。 保存局部变量名称… 1.程序运行时间的消耗在哪儿? 2.局部变量 3.Dynamic会快还是会慢? 4.Swich还是if else,是个问题 5.Try catch的优化

  12. Where should we go next? 1.各自回工位 2.学习更多 SWF文件格式官方文档下载》》 AVM2官方说明文档下载》》

  13. 感谢 • 感谢CCAV • 感谢Adobe提供这么优秀的产品 • 感谢肖大侠的协助 • 非常感谢各位抽空来接受折磨

More Related