{"id":631,"date":"2010-08-05T18:03:27","date_gmt":"2010-08-05T09:03:27","guid":{"rendered":"http:\/\/labs.gree.jp\/blog\/?p=631"},"modified":"2021-04-27T15:03:18","modified_gmt":"2021-04-27T06:03:18","slug":"post631","status":"publish","type":"post","link":"https:\/\/labs.gree.jp\/blog\/2010\/08\/631\/","title":{"rendered":"SWF\u30d0\u30a4\u30ca\u30ea\u7de8\u96c6\u306e\u30b9\u30b9\u30e1\u7b2c\u4e00\u56de"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3002\u30e1\u30c7\u30a3\u30a2\u958b\u767a\u90e8\u306e\u3088\u3084\u3068\u7533\u3057\u307e\u3059\u3002\u30d0\u30a4\u30ca\u30ea\u7de8\u96c6\u30a8\u30f3\u30b8\u30cb\u30a2\u3067\u3059\u3002<\/p>\n<h3 id=\"hs_349aacc7cfc288a5639d67caac6bd359_header_0\"> \u306f\u3058\u3081\u306b<\/h3>\n<p>GREE \u3067\u306f\u643a\u5e2f\u5411\u3051\u30b3\u30f3\u30c6\u30f3\u30c4\u306b Flash Lite \u3092\u5229\u7528\u3057\u3066\u3044\u307e\u3059\u304c\u3001Lite \u306b\u306f\u69d8\u3005\u306a\u5236\u9650(<a href=\"#hs_349aacc7cfc288a5639d67caac6bd359_footnote_1\" id=\"hs_349aacc7cfc288a5639d67caac6bd359_footnotelink_1\" title=\"Lite \u306e\u5236\u9650\u306b\u3064\u3044\u3066\u306f\u3001\u3053\u3061\u3089\u306eURL\u304c\u5206\u304b\u308a\u6613\u3044\u3067\u3059 =&gt; http:\/\/d.hatena.ne.jp\/hanageman\/20080922\">*1<\/a>)\u304c\u3042\u308a\u3001SWF(\u30b9\u30a6\u30a3\u30d5) \u306e\u52d5\u7684\u751f\u6210\u6280\u8853\u3092\u6d3b\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30c4\u30fc\u30eb(ming, swfmill, swftools, etc...)\u3092\u7528\u3044\u305f SWF \u751f\u6210\u306e\u8a18\u4e8b\u306f\u4e16\u9593\u306b\u6ea2\u308c\u3066\u307e\u3059\u306e\u3067\u3001SWF\u30d0\u30a4\u30ca\u30ea\u306e\u751f\u7de8\u96c6\u3092\u30c6\u30fc\u30de\u306b\u8a18\u4e8b\u3092\u4f55\u56de\u304b\u306b\u5206\u3051\u3066\u9032\u3081\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u30c4\u30fc\u30eb\u3092\u4f7f\u3046\u5834\u5408\u3067\u3082\u4f55\u304b\u3057\u3089\u554f\u984c\u306b\u906d\u9047\u3057\u305f\u969b\u306e\u4e00\u52a9\u306b\u306a\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u7b2c\u4e00\u56de\u306e\u5f53\u8a18\u4e8b\u306f\u3001SWF\u4ed5\u69d8\u66f8\u306e\u8aad\u307f\u65b9\u30ac\u30a4\u30c9\u3067\u3059\u3002<\/p>\n<h3 id=\"hs_349aacc7cfc288a5639d67caac6bd359_header_1\"> SWF\u4ed5\u69d8<\/h3>\n<p>Adobe\u516c\u5f0f\u306e SWF\u4ed5\u69d8\u66f8\u306f\u4e00\u822c\u516c\u958b\u3055\u308c\u3066\u3044\u307e\u3059\u3002 \u82f1\u8a9e\u3067\u3059\u3002<\/p>\n<ul>\n<li> <a href=\"http:\/\/www.adobe.com\/devnet\/swf\/\">http:\/\/www.adobe.com\/devnet\/swf\/<\/a> (swf_file_format_spec_v10.pdf)<\/li>\n<\/ul>\n<p>\u7406\u89e3\u306e\u52a9\u3051\u306b\u306a\u308b\u65e5\u672c\u8a9e\u306e\u30b5\u30a4\u30c8\u3092\u5217\u6319\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li> <a href=\"http:\/\/hkpr.info\/flash\/swf\/\">http:\/\/hkpr.info\/flash\/swf\/<\/a><\/li>\n<li> <a href=\"http:\/\/www.be-interactive.org\/works\/20080126\/swfassist.pdf\">http:\/\/www.be-interactive.org\/works\/20080126\/swfassist.pdf<\/a><\/li>\n<li> <a href=\"http:\/\/developer.cybozu.co.jp\/takesako\/2007\/05\/swf_binary_golf.html\">http:\/\/developer.cybozu.co.jp\/takesako\/2007\/05\/swf_binary_golf.html<\/a><\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u306e SWF\u30d5\u30a1\u30a4\u30eb(orz.swf)\u3092\u30b5\u30f3\u30d7\u30eb\u3068\u3057\u3066\u3001\u516c\u5f0f\u4ed5\u69d8\u66f8\u3092\u8aad\u307f\u9032\u3081\u307e\u3059\u3002<\/p>\n<h4 id=\"hs_349aacc7cfc288a5639d67caac6bd359_header_2\"> SWF\u30d8\u30c3\u30c0<\/h4>\n<p>\u4ed5\u69d8\u66f8\u306e SWF Structure Summary - The SWF header \u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\nSWF File Header\nField       Type  Comment\nSignature   UI8 \u3000 Signature byte:\n                 \u201cF\u201d indicates uncompressed\n                 \u201cC\u201d indicates compressed (SWF 6 and later only)\nSignature   UI8   Signature byte always \u201cW\u201d\nSignature   UI8   Signature byte always \u201cS\u201d\nVersion     UI8   Single byte file version (for example, 0x06 for SWF 6)\nFileLength  UI32  Length of entire file in bytes\nFrameSize   RECT  Frame size in twips\nFrameRate   UI16  Frame delay in 8.8 fixed number of frames per second\nFrameCount  UI16  Total number of frames in file<\/pre>\n<p>hexdump \u30b3\u30de\u30f3\u30c9\u3067\u5b9f\u969b\u306e SWF\u30d5\u30a1\u30a4\u30eb\u306e\u5148\u982d\u309216\u9032\u6570\u3067\u8868\u793a\u3057\u3066\u4ed5\u69d8\u66f8\u3068\u6bd4\u8f03\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\n% hexdump -C orz.swf | head -1\n00000000  46 57 53 04 77 1b 00 00  70 00 09 60 00 00 96 00  |FWS.w...p..`....|<\/pre>\n<h5 id=\"hs_349aacc7cfc288a5639d67caac6bd359_header_3\"> \u521d\u3081\u306e8bytes<\/h5>\n<ul>\n<li> \u5148\u982d\uff13bytes\u306e FWS \u306f Signature\u3002\u4e00\u6587\u5b57\u76ee\u304c F \u306a\u306e\u3067\u5727\u7e2e\u306a\u3057\u3002<\/li>\n<li> 4byte\u76ee\u306f 0x04 \u3067\u3001SWF \u306e version<\/li>\n<li> 5\uff5e8byte\u76ee\u306e 77 1b 00 00 \u306f FileLength\u3002SWF \u306f\u57fa\u672c LittleEndian \u306a\u306e\u3067byte\u5217\u3092\u9006\u65b9\u5411\u306b\u8aad\u3093\u3067\u30010x1b77 = 7031\u3000\u3053\u308c\u304c SWF\u30d5\u30a1\u30a4\u30eb\u306e\u30d5\u30a1\u30a4\u30eb\u9577\u306b\u76f8\u5f53\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<pre class=\"superpre \">\n% ls -l orz.swf\n-rwxr--r-- 1 yoya yoya 7031 2010-08-04 16:41 orz.swf<\/pre>\n<p>\u5408\u3063\u3066\u307e\u3059\u306d\u3002<br \/>\n\u3068\u3044\u3063\u305f\u5177\u5408\u306b\u8aad\u307f\u89e3\u3051\u307e\u3059\u3002<\/p>\n<h5 id=\"hs_349aacc7cfc288a5639d67caac6bd359_header_4\"> RECT<\/h5>\n<p>9byte\u76ee\u4ee5\u964d\u306f\u5c11\u3005\u3084\u3063\u304b\u3044\u3067\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u51fa\u3066\u304f\u308b RECT(Rectangle Record)\u306f\u4ed5\u69d8\u66f8\u306e Basic Data Types \u3067\u5b9a\u7fa9\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\nRECT\nField  Type       Comment\nNbits  UB[5]      Bits used for each subsequent field\nXmin   SB[Nbits]  x minimum position for rectangle in twips\nXmax   SB[Nbits]  x maximum position for rectangle in twips\nYmin   SB[Nbits]  y minimum position for rectangle in twips\nYmax   SB[Nbits]  y maximum position for rectangle in twips<\/pre>\n<p>\u521d\u3081\u306e5bit\u306b\u30d5\u30a3\u30fc\u30eb\u30c9\u9577\u304c\u5165\u3063\u3066\u3044\u3066\u3001\u305d\u306e\u9577\u3055\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u304c4\u3064\u5f8c\u308d\u306b\u7d9a\u304d\u307e\u3059\u3002<br \/>\n\u5177\u4f53\u7684\u306b\u306f\u3001<\/p>\n<pre class=\"superpre \">\n% hexdump -C orz.swf | head -1\n00000000  46 57 53 04 77 1b 00 00  70 00 09 60 00 00 96 00  |FWS.w...p..`....|<\/pre>\n<p>\u3053\u306e\u4e2d\u306e<\/p>\n<pre class=\"superpre \">\n70 00 09 60 00 00 96 00  <\/pre>\n<p>\u306ebyte\u5217\u304c\u5bfe\u5fdc\u3057\u307e\u3059\u3002bit \u3067\u5206\u3051\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\n   7   0    0   0    0   9    6   0    0   0    0   0    9   6    0   0\n01110000 00000000 00001001 01100000 00000000 00000000 10010110 00000000\n<-5-><-- 14 bits  --><-- 14 bits  --><-- 14 bits --><-- 14 bits  -->\nNBits      Xmin            Xmax            Ymin           Ymax<\/pre>\n<p>\u521d\u3081\u306e 5 bits \u3092\u8aad\u3080\u3068 14 \u3068\u3044\u3046\u5024\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u305d\u306e\u5f8c\u308d\u306b 14bits \u305a\u3064 Xmin, Xmax, Ymin, Ymax \u306e4\u3064\u306e\u5024\u304c\u4e26\u3076\u3068\u3044\u3046\u8a33\u3067\u3059\u3002<\/p>\n<p>\u5404\u3005\u306e\u5024\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\nNBits = 01110 = 14\nXmin = 00000000000000 =    0 twips =   0 pixel\nXmax = 01001011000000 = 4800 twips = 240 pixel\nYmin = 00000000000000 =    0 twips =   0 pixel\nYmax = 01001011000000 = 4800 twips = 240 pixel<\/pre>\n<p>\u3053\u3053\u3067\u51fa\u3066\u304f\u308b twips \u306f\u9577\u3055\u306e\u5358\u4f4d\u3067(\u672c\u6765\u306f DPI \u4f9d\u5b58\u3067\u3059\u304c)\u3001SWF \u3067\u306f logical pixel(100% \u8868\u793a\u3067\u306e pixel)\u3000\u306e 1\/20 \u306e\u9577\u3055\u3068\u5b9a\u3081\u3089\u308c\u3066\u3044\u307e\u3059\u3002\u3064\u307e\u308a twips \u306e\u5024\u3092 20 \u3067\u5272\u308b\u3068\u4e01\u5ea6 pixel \u5024\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h5 id=\"hs_349aacc7cfc288a5639d67caac6bd359_header_5\"> \u30d8\u30c3\u30c0\u306e\u6b8b\u308a<\/h5>\n<pre class=\"superpre \">\n% hexdump -C orz.swf | head -2\n00000000  46 57 53 04 77 1b 00 00  70 00 09 60 00 00 96 00  |FWS.w...p..`....|\n00000010  00 0a 28 00 43 02 ff ff  ff 7f 05 e4 08 00 00 01  |..(.C...........|<\/pre>\n<p>\u4e01\u5ea6\u4e8c\u884c\u76ee(offset 0x10)\u304b\u3089\u7d9a\u3044\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li> FrameRate \u306e 00 0a \u306f LittleEndian \u306a\u306e\u3067\u3072\u3063\u304f\u308a\u8fd4\u3057\u3066 0a 00 \u30028.8 fixed number (8bit\u6574\u6570.8bit\u5c11\u6570 \u306e\u56fa\u5b9a\u5c0f\u6570\u70b9)\u306a\u306e\u3067\u300110.00 [frames\/\u79d2] (<a href=\"#hs_349aacc7cfc288a5639d67caac6bd359_footnote_2\" id=\"hs_349aacc7cfc288a5639d67caac6bd359_footnotelink_2\" title=\"2 byte \u307e\u3068\u3081\u3066\u4e00\u3064\u306e\u5024\u3068\u3057\u3066\u8aad\u3093\u3060\u4e0a\u3067 0x100 \u3067\u5272\u308b\u3068\u697d\u3067\u3059\u3002\">*2<\/a>)<\/li>\n<li> FrameCount \u306e 28 00 \u3082 LittleEndian \u306a\u306e\u3067 0x0028 => 40 frames (=\u30b3\u30de\u6570)<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u3067\u3001SWF \u30d8\u30c3\u30c0\u304c\u4e00\u901a\u308a\u8aad\u3081\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li> \u30a4\u30e1\u30fc\u30b8\u56f3<\/li>\n<\/ul>\n<p><a href=\"http:\/\/labs.gree.jp\/blog\/?attachment_id=997\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2010\/09\/SWF_header.png\" alt=\"\" title=\"SWF_header\" width=\"589\" height=\"364\" class=\"alignnone size-full wp-image-997\" srcset=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2010\/09\/SWF_header.png 589w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2010\/09\/SWF_header-276x170.png 276w\" sizes=\"auto, (max-width: 589px) 100vw, 589px\" \/><\/a><br \/>\n<\/p>\n<h4 id=\"hs_349aacc7cfc288a5639d67caac6bd359_header_6\"> SWF\u30bf\u30b0 (short\u5f62\u5f0f)<\/h4>\n<p>SWF\u30d8\u30c3\u30c0\u306e\u5f8c\u308d\u306b SWF\u30bf\u30b0\u306e\u30ea\u30b9\u30c8\u304c\u7d9a\u304d\u307e\u3059\u3002(\u56f3\u306f\u4ed5\u69d8\u66f8\u304b\u3089\u629c\u7c8b)<br \/>\n<a href=\"http:\/\/labs.gree.jp\/blog\/2010\/08\/631\/swf_file_structure\/\" rel=\"attachment wp-att-649\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2010\/08\/SWF_File_Structure.png\" alt=\"\" title=\"SWF_File_Structure\" width=\"436\" height=\"68\" class=\"alignnone size-full wp-image-649\" srcset=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2010\/08\/SWF_File_Structure.png 436w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2010\/08\/SWF_File_Structure-276x43.png 276w\" sizes=\"auto, (max-width: 436px) 100vw, 436px\" \/><\/a><\/p>\n<p>\u4ed5\u69d8\u66f8\u306e SWF Structure Summary - SWF file structure \u306b\u4ee5\u4e0b\u306e\u5b9a\u7fa9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\nRECORDHEADER (short)\nField             Type  Comment\nTagCodeAndLength  UI16  Upper 10 bits: tag type\n                        Lower  6 bits: tag length<\/pre>\n<p>SWF\u30bf\u30b0\u306fSWF\u30d8\u30c3\u30c0\u306e\u5f8c\u308d\u306b\u7d9a\u304f\u306e\u3067\u3001\u5148\u7a0b\u306e FrameCount \u306e\u7d9a\u304d\u304b\u3089\u8aad\u3093\u3067\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\n% hexdump -C orz.swf | head -2\n00000000  46 57 53 04 77 1b 00 00  70 00 09 60 00 00 96 00  |FWS.w...p..`....|\n00000010  00 0a 28 00 43 02 ff ff  ff 7f 05 e4 08 00 00 01  |..(.C...........|<\/pre>\n<pre class=\"superpre \">\n43 02 ff ff  ff 7f 05 e4 08 00 00 01 <\/pre>\n<p>\u30bf\u30b0\u306e\u5148\u982d2bytes \u306b\u30bf\u30b0\u306e\u7a2e\u985e\u3068\u30bf\u30b0\u306e\u9577\u3055\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u304c\u3001LittleEndian \u3068 bit packing \u306e\u5408\u308f\u305b\u6280\u306a\u306e\u3067\u3001\u8aad\u3080\u306e\u306b\u5c11\u3057\u30b3\u30c4\u304c\u3044\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u300243 02 \u3092\u9006\u65b9\u5411\u306b\u8aad\u3093\u3067 0243 \u3068\u3057\u3066\u3001\u3053\u308c\u3092 bit \u306b\u5206\u89e3\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\n   0   2    4   3\n00000010 01000011\n<-10 bits-><-6 ->\n tag type  length<\/pre>\n<p>\u521d\u3081\u306e10bits \u304c\u30bf\u30b0\u306e\u7a2e\u985e(type)\u3067\u3001\u7d9a\u304f 6bits \u304c(TagCodeAndLength\u3092\u9664\u3044\u305f)\u30bf\u30b0\u306e\u9577\u3055\u3067\u3059\u3002<\/p>\n<pre class=\"superpre \">\ntag type = 0000001001 = 9 = SetBackgroundColor\nlength = 000011 = 3 = (RGB\u306e) 3 byte<\/pre>\n<p>tag type \u306e 9 \u3068 SetBackgroundColor \u306e\u5bfe\u5fdc\u306f\u4ed5\u69d8\u66f8(swf_file_format_spec_v10.pdf)\u3092\u30c6\u30ad\u30b9\u30c8\u691c\u7d22\u3057\u3066\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u4ee5\u4e0a\u304b\u3089\u3001SetBackgroundColor \u306e\u30bf\u30b0\u306f\u4ee5\u4e0b\u306e byte\u5217\u306b\u306a\u308b\u4e8b\u304c\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\n43 02 ff ff  ff <\/pre>\n<p>\u80cc\u666f\u304c (R,G,B) = (0xff, 0xff, 0xff)= \u767d\u8272\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li> \u30a4\u30e1\u30fc\u30b8\u56f3<\/li>\n<\/ul>\n<p><a href=\"http:\/\/labs.gree.jp\/blog\/?attachment_id=1087\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2010\/09\/TagLength_short.png\" alt=\"\" title=\"TagLength short\" width=\"368\" height=\"366\" class=\"alignnone size-full wp-image-1087\" srcset=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2010\/09\/TagLength_short.png 368w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2010\/09\/TagLength_short-201x200.png 201w\" sizes=\"auto, (max-width: 368px) 100vw, 368px\" \/><\/a><\/p>\n<h4 id=\"hs_349aacc7cfc288a5639d67caac6bd359_header_7\"> SWF\u30bf\u30b0 (long\u5f62\u5f0f)<\/h4>\n<p>6 bits \u3067\u306f111111 = 0x3f = 63 byte \u307e\u3067\u3057\u304b\u8868\u73fe\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u3053\u306e 6 bits \u306b 111111 = 0x3f \u304c\u5165\u3063\u3066\u3044\u308b\u6642\u306f\u3001long \u5f62\u5f0f\u304c\u9069\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u753b\u50cf\u3084\u52d5\u753b\u7b49\u306e\u30de\u30eb\u30c1\u30e1\u30c7\u30a3\u30a2\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u542b\u3080\u30bf\u30b0\u306f\u3053\u306e\u5f62\u5f0f\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\nRECORDHEADER (long)\nField             Type  Comment\nTagCodeAndLength  UI16  Tag type and length of 0x3F\n                        Packed together as in short header\nLength            SI32  Length of tag<\/pre>\n<p>\u5148\u7a0b\u306e\u30bf\u30b0(SetBackgroundColor)\u306e\u5f8c\u308d\u306b\u4e01\u5ea6\u3001JPEG\u753b\u50cf\u306e\u30bf\u30b0\u304c\u4e26\u3093\u3067\u3044\u308b\u306e\u3067\u3001\u305d\u308c\u3092\u4f8b\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\n% hexdump -C orz.swf | head -2\n00000000  46 57 53 04 77 1b 00 00  70 00 09 60 00 00 96 00  |FWS.w...p..`....|\n00000010  00 0a 28 00 43 02 ff ff  ff 7f 05 e4 08 00 00 01  |..(.C...........|<\/pre>\n<p>\u5148\u7a0b\u306e\u7d9a\u304d\u306a\u306e\u3067\u4ee5\u4e0b\u306ebyte\u5217\u304c\u76f8\u5f53\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\n 7f 05 e4 08 00 00 <\/pre>\n<p>\u307e\u305a TagCodeAndLength \u306e 2 byte \u3092\u8aad\u307f\u3060\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\n7f 05 => 0x057f => 00000101 01111111\n                   <---------><---->\n                    tag type  length\n tag type = 10101 = 0x15 = 21 = DefineBitsJPEG2 \n length = 0x3f = long\u5f62\u5f0f<\/pre>\n<p><\/p>\n<p>Length \u304c 0x3f \u306a\u306e\u3067\u3001\u305d\u306e\u5f8c\u308d\u306b\u7d9a\u304f 4bytes \u3092\u672c\u5f53\u306e Length \u3068\u3057\u3066\u8aad\u307f\u51fa\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"superpre \">\n e4 08 00 00  = 0x8e4 = 2276 byte<\/pre>\n<ul>\n<li> \u30a4\u30e1\u30fc\u30b8\u56f3<\/li>\n<\/ul>\n<p><a href=\"http:\/\/labs.gree.jp\/blog\/?attachment_id=1088\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2010\/09\/TagLength_long.png\" alt=\"\" title=\"TagLength_long\" width=\"403\" height=\"357\" class=\"alignnone size-full wp-image-1088\" srcset=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2010\/09\/TagLength_long.png 403w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2010\/09\/TagLength_long-225x200.png 225w\" sizes=\"auto, (max-width: 403px) 100vw, 403px\" \/><\/a><\/p>\n<h3 id=\"hs_349aacc7cfc288a5639d67caac6bd359_header_8\"> PHP\u3067\u8aad\u307f\u3060\u3057<\/h3>\n<p>\u4ee5\u4e0a\u3067 SWF \u306e\u30d8\u30c3\u30c0\u3068\u30bf\u30b0\u306e\u8aad\u307f\u65b9\u3092\u4e00\u901a\u308a\u8aac\u660e\u3057\u307e\u3057\u305f\u3002<br \/>\n\u53c2\u8003\u307e\u3067\u306b\u4eca\u307e\u3067\u8aac\u660e\u3057\u305f\u51e6\u7406\u3092\u884c\u3046 PHP \u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4ee5\u4e0b\u306b\u4ed8\u3051\u307e\u3059\u3002<\/p>\n<h4 id=\"hs_349aacc7cfc288a5639d67caac6bd359_header_9\"> swfdump<\/h4>\n<pre class=\"superpre php\">\n<?php\n\n$swfdata = file_get_contents($argv[1]);\n\n$reader = new BitReader();\n$reader->input($swfdata);\n\n\/* SWF Header *\/\necho 'Signature: '.$reader->getData(3).PHP_EOL;\necho 'Version: '.$reader->getUI8().PHP_EOL;\necho 'FileLength: '.$reader->getUI32LE().PHP_EOL;\necho 'FrameSize: '.PHP_EOL;\n$NBits = $reader->getUIBits(5);\necho \"\\tXmin: \".($reader->getUIBits($NBits) \/ 20).PHP_EOL;\necho \"\\tXmax: \".($reader->getUIBits($NBits) \/ 20).PHP_EOL;\necho \"\\tYmin: \".($reader->getUIBits($NBits) \/ 20).PHP_EOL;\necho \"\\tYmax: \".($reader->getUIBits($NBits) \/ 20).PHP_EOL;\n$reader->byteAlign();\necho 'FrameRate: '.($reader->getUI16LE() \/ 0x100).PHP_EOL;\necho 'FrameCount: '.$reader->getUI16LE().PHP_EOL;\n\n\/* SWF Tags *\/\necho 'Tag:'.PHP_EOL;\nwhile (true) {\n    $tagAndLength = $reader->getUI16LE();\n    $type = $tagAndLength >> 6;\n    $length = $tagAndLength & 0x3f;\n    if ($length == 0x3f) { \/\/ long format\n        $length = $reader->getUI32LE();\n    }\n    echo \"\\ttype: $type  length: $length\".PHP_EOL;\n    $contents = $reader->getData($length);\n    if ($type == 0) { \/\/ END Tag\n        break;\n    }\n}\n\nexit(0);<\/pre>\n<h4 id=\"hs_349aacc7cfc288a5639d67caac6bd359_header_10\"> BitReader<\/h4>\n<pre class=\"superpre php\">\nclass BitReader {\n    var $_data; \/\/ input_data\n    var $_byte_offset;\n    var $_bit_offset;\n\n    function input($data) {\n        $this->_data = $data;\n        $this->_byte_offset = 0;\n        $this->_bit_offset = 0;\n    }\n    function byteAlign() {\n        if ($this->_bit_offset > 0) {\n            $this->_byte_offset ++;\n            $this->_bit_offset = 0;\n        }\n    }\n    function getData($length) {\n        $this->byteAlign();\n        $data = substr($this->_data, $this->_byte_offset, $length);\n        $data_len = strlen($data);\n        $this->_byte_offset += $data_len;\n        return $data;\n    }\n    function getUI8() {\n        $this->byteAlign();\n        $value = ord($this->_data{$this->_byte_offset});\n        $this->_byte_offset += 1;\n        return $value;\n    }\n    function getUI16LE() {\n        $this->byteAlign();\n        $ret = unpack('v', substr($this->_data, $this->_byte_offset, 2));\n        $this->_byte_offset += 2;\n        return $ret[1];\n    }\n    function getUI32LE() {\n        $this->byteAlign();\n        $ret = unpack('V', substr($this->_data, $this->_byte_offset, 4));\n        $this->_byte_offset += 4;\n        return $ret[1];\n    }\n    function getUIBit() {\n        $value = ord($this->_data{$this->_byte_offset});\n        $value = 1 & ($value >> (7 - $this->_bit_offset));\n        $this->_bit_offset ++;\n        if (8 <= $this->_bit_offset) {\n            $this->_byte_offset++;\n            $this->_bit_offset = 0;\n        }\n        return $value;\n    }\n    function getUIBits($width) {\n        $value = 0;\n        for ($i = 0 ; $i < $width ; $i++) {\n            $value <<= 1;\n            $value |= $this->getUIBit();\n        }\n        return $value;\n    }\n}<\/pre>\n<h4 id=\"hs_349aacc7cfc288a5639d67caac6bd359_header_11\"> \u5b9f\u884c\u7d50\u679c<\/h4>\n<pre class=\"superpre \">\n% php swfdump.php orz.swf\nSignature: FWS\nVersion: 4\nFileLength: 7031\nFrameSize:\n        Xmin: 0\n        Xmax: 240\n        Ymin: 0\n        Ymax: 240\nFrameRate: 10\nFrameCount: 40\nTag:\n        type: 9  length: 3\n        type: 21  length: 2276\n\uff1c\u7565\uff1e\n        type: 0  length: 0<\/pre>\n<h3 id=\"hs_349aacc7cfc288a5639d67caac6bd359_header_12\"> \u6b21\u56de\u4e88\u544a<\/h3>\n<p>\u6b21\u56de\u306f SWF\u30d0\u30a4\u30ca\u30ea\u306e\u7de8\u96c6\u307e\u3067\u8a71\u3057\u3092\u9032\u3081\u308b\u4e88\u5b9a\u3067\u3059\u3002<br \/>\n\u305d\u308c\u3067\u306f\u5931\u793c\u3044\u305f\u3057\u307e\u3059\u3002<br \/>\n<\/p>\n<div class=\"footnote\">\n<p id=\"hs_349aacc7cfc288a5639d67caac6bd359_footnote_1\"><a href=\"#hs_349aacc7cfc288a5639d67caac6bd359_footnotelink_1\">*1<\/a>: Lite \u306e\u5236\u9650\u306b\u3064\u3044\u3066\u306f\u3001\u3053\u3061\u3089\u306eURL\u304c\u5206\u304b\u308a\u6613\u3044\u3067\u3059 => <a href=\"http:\/\/d.hatena.ne.jp\/hanageman\/20080922\">http:\/\/d.hatena.ne.jp\/hanageman\/20080922<\/a><\/p>\n<p id=\"hs_349aacc7cfc288a5639d67caac6bd359_footnote_2\"><a href=\"#hs_349aacc7cfc288a5639d67caac6bd359_footnotelink_2\">*2<\/a>: 2 byte \u307e\u3068\u3081\u3066\u4e00\u3064\u306e\u5024\u3068\u3057\u3066\u8aad\u3093\u3060\u4e0a\u3067 0x100 \u3067\u5272\u308b\u3068\u697d\u3067\u3059\u3002<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3002\u30e1\u30c7\u30a3\u30a2\u958b\u767a\u90e8\u306e\u3088\u3084\u3068\u7533\u3057\u307e\u3059\u3002\u30d0\u30a4\u30ca\u30ea\u7de8\u96c6\u30a8\u30f3\u30b8\u30cb\u30a2\u3067\u3059\u3002 \u306f\u3058\u3081\u306b GREE \u3067\u306f\u643a\u5e2f\u5411\u3051\u30b3\u30f3\u30c6\u30f3\u30c4\u306b Flash Lite \u3092\u5229\u7528\u3057\u3066\u3044\u307e\u3059\u304c\u3001Lite \u306b\u306f\u69d8\u3005\u306a\u5236\u9650(*1)\u304c\u3042\u308a\u3001SWF(\u30b9\u30a6\u30a3\u30d5) [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[18],"class_list":["post-631","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-info","tag-flash"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/comments?post=631"}],"version-history":[{"count":3,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/631\/revisions"}],"predecessor-version":[{"id":21134,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/631\/revisions\/21134"}],"wp:attachment":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/media?parent=631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/categories?post=631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/tags?post=631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}