From fe1cf6bd2fe9d214ea6cd996be19bc4a02bb53d6 Mon Sep 17 00:00:00 2001 From: Andy Zhang Date: Mon, 11 Jan 2016 15:40:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E8=AF=A6=E7=BB=86=E7=9A=84=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../droidplugin/hook/binder/BinderHook.java | 24 ++++++++++++++++++- .../binder/ServiceManagerCacheBinderHook.java | 24 ++++++++++++++++++- .../droidplugin/hook/proxy/ProxyHook.java | 24 +++++++++++++++++-- 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/project/Libraries/DroidPlugin/src/com/morgoo/droidplugin/hook/binder/BinderHook.java b/project/Libraries/DroidPlugin/src/com/morgoo/droidplugin/hook/binder/BinderHook.java index e6cea57..35a882d 100644 --- a/project/Libraries/DroidPlugin/src/com/morgoo/droidplugin/hook/binder/BinderHook.java +++ b/project/Libraries/DroidPlugin/src/com/morgoo/droidplugin/hook/binder/BinderHook.java @@ -33,6 +33,7 @@ import com.morgoo.helper.MyProxy; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.Arrays; import java.util.List; /** @@ -58,7 +59,7 @@ abstract class BinderHook extends Hook implements InvocationHandler { } else { return method.invoke(mOldObj, args); } - } catch (InvocationTargetException e) { + } catch (InvocationTargetException e) { Throwable cause = e.getTargetException(); if (cause != null && MyProxy.isMethodDeclaredThrowable(method, cause)) { throw cause; @@ -71,6 +72,27 @@ abstract class BinderHook extends Hook implements InvocationHandler { runtimeException.initCause(e); throw runtimeException; } + } catch (IllegalArgumentException e) { + try { + StringBuilder sb = new StringBuilder(); + sb.append(" DROIDPLUGIN{"); + if (method != null) { + sb.append("method[").append(method.toString()).append("]"); + } else { + sb.append("method[").append("NULL").append("]"); + } + if (args != null) { + sb.append("args[").append(Arrays.toString(args)).append("]"); + } else { + sb.append("args[").append("NULL").append("]"); + } + sb.append("}"); + + String message = e.getMessage() + sb.toString(); + throw new IllegalArgumentException(message, e); + } catch (Throwable e1) { + throw e; + } } catch (Throwable e) { if (MyProxy.isMethodDeclaredThrowable(method, e)) { throw e; diff --git a/project/Libraries/DroidPlugin/src/com/morgoo/droidplugin/hook/binder/ServiceManagerCacheBinderHook.java b/project/Libraries/DroidPlugin/src/com/morgoo/droidplugin/hook/binder/ServiceManagerCacheBinderHook.java index 307c244..8195561 100644 --- a/project/Libraries/DroidPlugin/src/com/morgoo/droidplugin/hook/binder/ServiceManagerCacheBinderHook.java +++ b/project/Libraries/DroidPlugin/src/com/morgoo/droidplugin/hook/binder/ServiceManagerCacheBinderHook.java @@ -38,6 +38,7 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.UndeclaredThrowableException; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -96,7 +97,7 @@ public class ServiceManagerCacheBinderHook extends Hook implements InvocationHan } else { return method.invoke(originService, args); } - } catch (InvocationTargetException e) { + } catch (InvocationTargetException e) { Throwable cause = e.getTargetException(); if (cause != null && MyProxy.isMethodDeclaredThrowable(method, cause)) { throw cause; @@ -109,6 +110,27 @@ public class ServiceManagerCacheBinderHook extends Hook implements InvocationHan runtimeException.initCause(e); throw runtimeException; } + } catch (IllegalArgumentException e) { + try { + StringBuilder sb = new StringBuilder(); + sb.append(" DROIDPLUGIN{"); + if (method != null) { + sb.append("method[").append(method.toString()).append("]"); + } else { + sb.append("method[").append("NULL").append("]"); + } + if (args != null) { + sb.append("args[").append(Arrays.toString(args)).append("]"); + } else { + sb.append("args[").append("NULL").append("]"); + } + sb.append("}"); + + String message = e.getMessage() + sb.toString(); + throw new IllegalArgumentException(message, e); + } catch (Throwable e1) { + throw e; + } } catch (Throwable e) { if (MyProxy.isMethodDeclaredThrowable(method, e)) { throw e; diff --git a/project/Libraries/DroidPlugin/src/com/morgoo/droidplugin/hook/proxy/ProxyHook.java b/project/Libraries/DroidPlugin/src/com/morgoo/droidplugin/hook/proxy/ProxyHook.java index 563961a..0b41e2c 100644 --- a/project/Libraries/DroidPlugin/src/com/morgoo/droidplugin/hook/proxy/ProxyHook.java +++ b/project/Libraries/DroidPlugin/src/com/morgoo/droidplugin/hook/proxy/ProxyHook.java @@ -32,8 +32,7 @@ import com.morgoo.helper.MyProxy; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.lang.reflect.UndeclaredThrowableException; -import java.net.DatagramSocket; +import java.util.Arrays; /** * Created by Andy Zhang(zhangyong232@gmail.com) on 2015/3/14. @@ -74,6 +73,27 @@ public abstract class ProxyHook extends Hook implements InvocationHandler { runtimeException.initCause(e); throw runtimeException; } + } catch (IllegalArgumentException e) { + try { + StringBuilder sb = new StringBuilder(); + sb.append(" DROIDPLUGIN{"); + if (method != null) { + sb.append("method[").append(method.toString()).append("]"); + } else { + sb.append("method[").append("NULL").append("]"); + } + if (args != null) { + sb.append("args[").append(Arrays.toString(args)).append("]"); + } else { + sb.append("args[").append("NULL").append("]"); + } + sb.append("}"); + + String message = e.getMessage() + sb.toString(); + throw new IllegalArgumentException(message, e); + } catch (Throwable e1) { + throw e; + } } catch (Throwable e) { if (MyProxy.isMethodDeclaredThrowable(method, e)) { throw e;