(clzVarName, constructorMethod)
| 110 | |
| 111 | //生成构造方法的overload |
| 112 | function generateFridaConstructorMethodOverload(clzVarName, constructorMethod) { |
| 113 | var overloadJs = ""; |
| 114 | if (!constructorMethod.isLocal.value) { |
| 115 | return overloadJs; |
| 116 | } |
| 117 | var constructorMethodVarName = clzVarName + "_init_" + Math.random().toString(36).slice( - 4); |
| 118 | var hookConstructorMethodJs = clzVarName + ".$init.overload("; |
| 119 | if (constructorMethod.paramsNum.value > 0) { |
| 120 | for (var j = 0; j < constructorMethod.paramsNum.value; j++) { |
| 121 | hookConstructorMethodJs += "'"; |
| 122 | hookConstructorMethodJs += constructorMethod.paramsClasses.value[j]; |
| 123 | hookConstructorMethodJs += "'"; |
| 124 | if (j < (constructorMethod.paramsNum.value - 1)) { |
| 125 | hookConstructorMethodJs += ","; |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | hookConstructorMethodJs += ");"; |
| 130 | overloadJs += "var " + constructorMethodVarName + " = " + hookConstructorMethodJs; |
| 131 | overloadJs += constructorMethodVarName + ".implementation = function("; |
| 132 | var paramsJs = ""; |
| 133 | for (var j = 0; j < constructorMethod.paramsNum.value; j++) { |
| 134 | paramsJs += "v" + j; |
| 135 | if (j < (constructorMethod.paramsNum.value - 1)) { |
| 136 | paramsJs += ","; |
| 137 | } |
| 138 | } |
| 139 | overloadJs += paramsJs; |
| 140 | overloadJs += ") {"; |
| 141 | overloadJs += "var executor = this.hashCode();"; |
| 142 | overloadJs += "var beatText = '" + constructorMethod.describe.value + "';"; |
| 143 | overloadJs += "var beat = newMethodBeat(beatText, executor);"; |
| 144 | overloadJs += "var returnObj = "; |
| 145 | overloadJs += constructorMethodVarName + ".call(this"; |
| 146 | if (constructorMethod.paramsNum.value > 0) { |
| 147 | overloadJs += "," + paramsJs + ");"; |
| 148 | } else { |
| 149 | overloadJs += ");"; |
| 150 | } |
| 151 | overloadJs += "printBeat(beat);"; |
| 152 | overloadJs += "return returnObj;};"; |
| 153 | return overloadJs; |
| 154 | } |
| 155 | |
| 156 | //RadarClassResult string |
| 157 | function generateMethodHookJs(radarClassResult, methodName) { |
no outgoing calls
no test coverage detected