Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SandHook
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
SandHook
Commits
064560ac
Commit
064560ac
authored
Jun 03, 2019
by
swift_gan
Committed by
swift_gan
Jun 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[XposedCompat]fix
parent
a9b826e8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
183 additions
and
4 deletions
+183
-4
XposedCompat.java
...ava/com/swift/sandhook/xposedcompat_new/XposedCompat.java
+53
-1
ApplicationUtils.java
...ift/sandhook/xposedcompat_new/utils/ApplicationUtils.java
+34
-0
ClassUtils.java
...com/swift/sandhook/xposedcompat_new/utils/ClassUtils.java
+1
-1
ComposeClassLoader.java
...t/sandhook/xposedcompat_new/utils/ComposeClassLoader.java
+31
-0
ProcessUtils.java
...m/swift/sandhook/xposedcompat_new/utils/ProcessUtils.java
+64
-0
XposedBridge.java
...ew/src/main/java/de/robv/android/xposed/XposedBridge.java
+0
-2
No files found.
xposedcompat_new/src/main/java/com/swift/sandhook/xposedcompat_new/XposedCompat.java
View file @
064560ac
package
com
.
swift
.
sandhook
.
xposedcompat_new
;
package
com
.
swift
.
sandhook
.
xposedcompat_new
;
import
android.app.Application
;
import
android.content.Context
;
import
android.content.Context
;
import
com.swift.sandhook.HookLog
;
import
com.swift.sandhook.HookLog
;
...
@@ -7,6 +8,10 @@ import com.swift.sandhook.SandHook;
...
@@ -7,6 +8,10 @@ import com.swift.sandhook.SandHook;
import
com.swift.sandhook.wrapper.HookErrorException
;
import
com.swift.sandhook.wrapper.HookErrorException
;
import
com.swift.sandhook.wrapper.HookWrapper
;
import
com.swift.sandhook.wrapper.HookWrapper
;
import
com.swift.sandhook.wrapper.StubMethodsFactory
;
import
com.swift.sandhook.wrapper.StubMethodsFactory
;
import
com.swift.sandhook.xposedcompat_new.utils.ApplicationUtils
;
import
com.swift.sandhook.xposedcompat_new.utils.ClassUtils
;
import
com.swift.sandhook.xposedcompat_new.utils.ComposeClassLoader
;
import
com.swift.sandhook.xposedcompat_new.utils.ProcessUtils
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.Member
;
import
java.lang.reflect.Member
;
...
@@ -14,8 +19,11 @@ import java.lang.reflect.Method;
...
@@ -14,8 +19,11 @@ import java.lang.reflect.Method;
import
java.lang.reflect.Modifier
;
import
java.lang.reflect.Modifier
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
de.robv.android.xposed.IXposedHookLoadPackage
;
import
de.robv.android.xposed.XC_MethodHook
;
import
de.robv.android.xposed.XC_MethodHook
;
import
de.robv.android.xposed.XposedBridge
;
import
de.robv.android.xposed.XposedBridge
;
import
de.robv.android.xposed.XposedInit
;
import
de.robv.android.xposed.callbacks.XC_LoadPackage
;
/**
/**
* @author Swift Gan
* @author Swift Gan
...
@@ -30,8 +38,9 @@ public class XposedCompat {
...
@@ -30,8 +38,9 @@ public class XposedCompat {
public
static
String
processName
;
public
static
String
processName
;
public
static
boolean
isFirstApplication
;
public
static
boolean
isFirstApplication
;
private
static
volatile
int
curSlot
=
0
;
private
static
ClassLoader
sandHookXposedClassLoader
;
private
static
volatile
int
curSlot
=
0
;
public
static
volatile
HookInfo
[]
hookInfos
=
new
HookInfo
[
100
];
public
static
volatile
HookInfo
[]
hookInfos
=
new
HookInfo
[
100
];
static
{
static
{
...
@@ -166,4 +175,47 @@ public class XposedCompat {
...
@@ -166,4 +175,47 @@ public class XposedCompat {
}
}
}
}
public
static
void
loadModule
(
String
modulePath
,
String
moduleOdexDir
,
String
moduleSoPath
,
ClassLoader
classLoader
)
{
XposedInit
.
loadModule
(
modulePath
,
moduleOdexDir
,
moduleSoPath
,
classLoader
);
}
public
static
void
addXposedModuleCallback
(
IXposedHookLoadPackage
module
)
{
XposedBridge
.
hookLoadPackage
(
new
IXposedHookLoadPackage
.
Wrapper
(
module
));
}
public
static
void
callXposedModuleInit
()
throws
Throwable
{
//prepare LoadPackageParam
XC_LoadPackage
.
LoadPackageParam
packageParam
=
new
XC_LoadPackage
.
LoadPackageParam
(
XposedBridge
.
sLoadedPackageCallbacks
);
Application
application
=
ApplicationUtils
.
currentApplication
();
if
(
application
!=
null
)
{
if
(
packageParam
.
packageName
==
null
)
{
packageParam
.
packageName
=
application
.
getPackageName
();
}
if
(
packageParam
.
processName
==
null
)
{
packageParam
.
processName
=
ProcessUtils
.
getProcessName
(
application
);
}
if
(
packageParam
.
classLoader
==
null
)
{
packageParam
.
classLoader
=
application
.
getClassLoader
();
}
if
(
packageParam
.
appInfo
==
null
)
{
packageParam
.
appInfo
=
application
.
getApplicationInfo
();
}
}
XC_LoadPackage
.
callAll
(
packageParam
);
}
public
static
ClassLoader
getSandHookXposedClassLoader
(
ClassLoader
appOriginClassLoader
,
ClassLoader
sandBoxHostClassLoader
)
{
if
(
sandHookXposedClassLoader
!=
null
)
{
return
sandHookXposedClassLoader
;
}
else
{
sandHookXposedClassLoader
=
new
ComposeClassLoader
(
sandBoxHostClassLoader
,
appOriginClassLoader
);
return
sandHookXposedClassLoader
;
}
}
}
}
xposedcompat_new/src/main/java/com/swift/sandhook/xposedcompat_new/utils/ApplicationUtils.java
0 → 100644
View file @
064560ac
package
com
.
swift
.
sandhook
.
xposedcompat_new
.
utils
;
import
android.app.Application
;
import
java.lang.reflect.Method
;
public
class
ApplicationUtils
{
private
static
Class
classActivityThread
;
private
static
Method
currentApplicationMethod
;
static
Application
application
;
public
static
Application
currentApplication
()
{
if
(
application
!=
null
)
return
application
;
if
(
currentApplicationMethod
==
null
)
{
try
{
classActivityThread
=
Class
.
forName
(
"android.app.ActivityThread"
);
currentApplicationMethod
=
classActivityThread
.
getDeclaredMethod
(
"currentApplication"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
if
(
currentApplicationMethod
==
null
)
return
null
;
try
{
application
=
(
Application
)
currentApplicationMethod
.
invoke
(
null
);
}
catch
(
Exception
e
)
{
}
return
application
;
}
}
xposedcompat_new/src/main/java/com/swift/sandhook/xposedcompat_new/ClassUtils.java
→
xposedcompat_new/src/main/java/com/swift/sandhook/xposedcompat_new/
utils/
ClassUtils.java
View file @
064560ac
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
com
.
swift
.
sandhook
.
xposedcompat_new
;
package
com
.
swift
.
sandhook
.
xposedcompat_new
.
utils
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
...
xposedcompat_new/src/main/java/com/swift/sandhook/xposedcompat_new/utils/ComposeClassLoader.java
0 → 100644
View file @
064560ac
package
com
.
swift
.
sandhook
.
xposedcompat_new
.
utils
;
public
class
ComposeClassLoader
extends
ClassLoader
{
private
final
ClassLoader
mAppClassLoader
;
public
ComposeClassLoader
(
ClassLoader
parent
,
ClassLoader
appClassLoader
)
{
super
(
parent
);
mAppClassLoader
=
appClassLoader
;
}
@Override
protected
Class
<?>
loadClass
(
String
name
,
boolean
resolve
)
throws
ClassNotFoundException
{
Class
clazz
=
null
;
try
{
clazz
=
mAppClassLoader
.
loadClass
(
name
);
}
catch
(
ClassNotFoundException
e
)
{
// IGNORE.
}
if
(
clazz
==
null
)
{
clazz
=
super
.
loadClass
(
name
,
resolve
);
}
if
(
clazz
==
null
)
{
throw
new
ClassNotFoundException
();
}
return
clazz
;
}
}
xposedcompat_new/src/main/java/com/swift/sandhook/xposedcompat_new/utils/ProcessUtils.java
0 → 100644
View file @
064560ac
package
com
.
swift
.
sandhook
.
xposedcompat_new
.
utils
;
import
android.app.ActivityManager
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.content.pm.ResolveInfo
;
import
android.text.TextUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Created by swift_gan on 2017/11/23.
*/
public
class
ProcessUtils
{
private
static
volatile
String
processName
=
null
;
public
static
String
getProcessName
(
Context
context
)
{
if
(!
TextUtils
.
isEmpty
(
processName
))
return
processName
;
processName
=
doGetProcessName
(
context
);
return
processName
;
}
private
static
String
doGetProcessName
(
Context
context
)
{
ActivityManager
am
=
(
ActivityManager
)
context
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
List
<
ActivityManager
.
RunningAppProcessInfo
>
runningApps
=
am
.
getRunningAppProcesses
();
if
(
runningApps
==
null
)
{
return
null
;
}
for
(
ActivityManager
.
RunningAppProcessInfo
proInfo
:
runningApps
)
{
if
(
proInfo
.
pid
==
android
.
os
.
Process
.
myPid
())
{
if
(
proInfo
.
processName
!=
null
)
{
return
proInfo
.
processName
;
}
}
}
return
context
.
getPackageName
();
}
public
static
boolean
isMainProcess
(
Context
context
)
{
String
processName
=
getProcessName
(
context
);
String
pkgName
=
context
.
getPackageName
();
if
(!
TextUtils
.
isEmpty
(
processName
)
&&
!
TextUtils
.
equals
(
processName
,
pkgName
))
{
return
false
;
}
else
{
return
true
;
}
}
public
static
List
<
ResolveInfo
>
findActivitiesForPackage
(
Context
context
,
String
packageName
)
{
final
PackageManager
packageManager
=
context
.
getPackageManager
();
final
Intent
mainIntent
=
new
Intent
(
Intent
.
ACTION_MAIN
,
null
);
mainIntent
.
addCategory
(
Intent
.
CATEGORY_LAUNCHER
);
mainIntent
.
setPackage
(
packageName
);
final
List
<
ResolveInfo
>
apps
=
packageManager
.
queryIntentActivities
(
mainIntent
,
0
);
return
apps
!=
null
?
apps
:
new
ArrayList
<
ResolveInfo
>();
}
}
xposedcompat_new/src/main/java/de/robv/android/xposed/XposedBridge.java
View file @
064560ac
...
@@ -24,8 +24,6 @@ import java.util.Set;
...
@@ -24,8 +24,6 @@ import java.util.Set;
import
de.robv.android.xposed.callbacks.XC_InitPackageResources
;
import
de.robv.android.xposed.callbacks.XC_InitPackageResources
;
import
de.robv.android.xposed.callbacks.XC_LoadPackage
;
import
de.robv.android.xposed.callbacks.XC_LoadPackage
;
import
static
de
.
robv
.
android
.
xposed
.
XposedHelpers
.
getIntField
;
/**
/**
* This class contains most of Xposed's central logic, such as initialization and callbacks used by
* This class contains most of Xposed's central logic, such as initialization and callbacks used by
* the native side. It also includes methods to add new hooks.
* the native side. It also includes methods to add new hooks.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment