From 34db445076b2d51019b3ec981c8a610614d39af3 Mon Sep 17 00:00:00 2001 From: Xuefer Date: Wed, 8 Jun 2011 03:45:25 +0000 Subject: [PATCH] decode optimized if/return git-svn-id: svn://svn.lighttpd.net/xcache/trunk@820 c26eb9a1-5813-0410-bd6c-c2e55f420ca7 --- Decompiler.class.php | 14 ++++++++++++++ phpdop.phpr | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Decompiler.class.php b/Decompiler.class.php index b9e900b..4a441dc 100644 --- a/Decompiler.class.php +++ b/Decompiler.class.php @@ -905,6 +905,20 @@ class Decompiler $this->endComplexBlock($EX); return; } + if ($firstOp['opcode'] == XC_JMPZ && !empty($firstOp['jmpouts']) + && $firstOp['jmpouts'][0] - 1 == $range[1] && $opcodes[$firstOp['jmpouts'][0] - 1]['opcode'] == XC_RETURN) { + $this->beginComplexBlock($EX); + $this->removeJmpInfo($EX, $range[0]); + $condition = $this->getOpVal($opcodes[$range[0]]['op1'], $EX); + + echo $indent, 'if (', str($condition, $EX), ') ', '{', PHP_EOL; + $this->beginScope($EX); + $this->recognizeAndDecompileClosedBlocks($EX, $range); + $this->endScope($EX); + echo $indent, '}', PHP_EOL; + $this->endComplexBlock($EX); + return; + } // }}} // {{{ try/catch if (!empty($firstOp['jmpins']) && !empty($opcodes[$firstOp['jmpins'][0]]['isCatchBegin'])) { diff --git a/phpdop.phpr b/phpdop.phpr index 692312c..2f6960c 100755 --- a/phpdop.phpr +++ b/phpdop.phpr @@ -94,7 +94,12 @@ if (!isset($argv[1])) { die("Usage: $argv[0] \n"); } $decompiler = new Decompiler(); -$pk = xcache_dasm_file($argv[1]); +if (isset($argv[2])) { + eval('$pk = ' . file_get_contents($argv[2]) . ';'); +} +else { + $pk = xcache_dasm_file($argv[1]); +} $op_array = $funcs = $classes = null; if (isset($pk['op_array'])) { $op_array = $pk['op_array'];