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
02ff063d
Commit
02ff063d
authored
Feb 18, 2019
by
swift_gan
Committed by
swift_gan
Feb 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix param decode
parent
c474f8f8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
11 deletions
+49
-11
MethodReflectParams.java
...va/com/swift/sandhook/annotation/MethodReflectParams.java
+10
-0
HookWrapper.java
...src/main/java/com/swift/sandhook/wrapper/HookWrapper.java
+39
-11
No files found.
annotation/src/main/java/com/swift/sandhook/annotation/MethodReflectParams.java
View file @
02ff063d
...
...
@@ -8,5 +8,15 @@ import java.lang.annotation.Target;
@Target
({
ElementType
.
METHOD
,
ElementType
.
FIELD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
MethodReflectParams
{
String
BOOLEAN
=
"boolean"
;
String
BYTE
=
"byte"
;
String
CHAR
=
"char"
;
String
DOUBLE
=
"double"
;
String
FLOAT
=
"float"
;
String
INT
=
"int"
;
String
LONG
=
"long"
;
String
SHORT
=
"short"
;
String
[]
value
();
}
\ No newline at end of file
hooklib/src/main/java/com/swift/sandhook/wrapper/HookWrapper.java
View file @
02ff063d
...
...
@@ -17,7 +17,6 @@ import java.lang.reflect.Method;
import
java.lang.reflect.Modifier
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
public
class
HookWrapper
{
...
...
@@ -143,11 +142,7 @@ public class HookWrapper {
Class
[]
pars
=
new
Class
[
methodReflectParams
.
value
().
length
];
for
(
int
i
=
0
;
i
<
methodReflectParams
.
value
().
length
;
i
++)
{
try
{
if
(
classLoader
==
null
)
{
pars
[
i
]
=
Class
.
forName
(
methodReflectParams
.
value
()[
i
]);
}
else
{
pars
[
i
]
=
Class
.
forName
(
methodReflectParams
.
value
()[
i
],
true
,
classLoader
);
}
pars
[
i
]
=
classNameToClass
(
methodReflectParams
.
value
()[
i
],
classLoader
);
}
catch
(
ClassNotFoundException
e
)
{
throw
new
HookErrorException
(
"hook method pars error: "
+
method
.
getName
(),
e
);
}
...
...
@@ -169,11 +164,7 @@ public class HookWrapper {
Class
[]
pars
=
new
Class
[
methodReflectParams
.
value
().
length
];
for
(
int
i
=
0
;
i
<
methodReflectParams
.
value
().
length
;
i
++)
{
try
{
if
(
classLoader
==
null
)
{
pars
[
i
]
=
Class
.
forName
(
methodReflectParams
.
value
()[
i
]);
}
else
{
pars
[
i
]
=
Class
.
forName
(
methodReflectParams
.
value
()[
i
],
true
,
classLoader
);
}
pars
[
i
]
=
classNameToClass
(
methodReflectParams
.
value
()[
i
],
classLoader
);
}
catch
(
ClassNotFoundException
e
)
{
throw
new
HookErrorException
(
"hook method pars error: "
+
field
.
getName
(),
e
);
}
...
...
@@ -184,6 +175,43 @@ public class HookWrapper {
}
}
private
static
Class
classNameToClass
(
String
name
,
ClassLoader
classLoader
)
throws
ClassNotFoundException
{
Class
clazz
;
switch
(
name
)
{
case
MethodReflectParams
.
BOOLEAN
:
clazz
=
boolean
.
class
;
break
;
case
MethodReflectParams
.
BYTE
:
clazz
=
byte
.
class
;
break
;
case
MethodReflectParams
.
CHAR
:
clazz
=
char
.
class
;
break
;
case
MethodReflectParams
.
DOUBLE
:
clazz
=
double
.
class
;
break
;
case
MethodReflectParams
.
FLOAT
:
clazz
=
float
.
class
;
break
;
case
MethodReflectParams
.
INT
:
clazz
=
int
.
class
;
break
;
case
MethodReflectParams
.
LONG
:
clazz
=
long
.
class
;
break
;
case
MethodReflectParams
.
SHORT
:
clazz
=
short
.
class
;
break
;
default
:
if
(
classLoader
==
null
)
{
clazz
=
Class
.
forName
(
name
);
}
else
{
clazz
=
Class
.
forName
(
name
,
true
,
classLoader
);
}
}
return
clazz
;
}
private
static
boolean
samePars
(
ClassLoader
classLoader
,
Field
field
,
Class
[]
par
)
{
try
{
...
...
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