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
22ec6bcb
Commit
22ec6bcb
authored
Jan 23, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tweak opcode imm
parent
ef518c65
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
18 deletions
+24
-18
trampoline.cpp
app/src/main/cpp/trampoline/trampoline.cpp
+1
-7
trampoline.h
app/src/main/cpp/trampoline/trampoline.h
+23
-11
No files found.
app/src/main/cpp/trampoline/trampoline.cpp
View file @
22ec6bcb
...
...
@@ -64,15 +64,9 @@ namespace SandHook {
codeCopy
(
reinterpret_cast
<
Code
>
(
&
offSet
),
OFFSET_INLINE_OFFSET_ENTRY_CODE
,
BYTE_POINT
);
#if defined(__arm__)
Code32Bit
offset32
;
Code32Bit
code32Bit
;
offset32
.
code
=
offSet
;
unsigned
char
offsetOP
=
isBigEnd
()
?
offset32
.
op
.
op4
:
offset32
.
op
.
op1
;
code32Bit
.
code
=
*
reinterpret_cast
<
uint32_t
*>
(((
Size
)
getCode
()
+
OFFSET_INLINE_OP_OFFSET_CODE
));
if
(
isBigEnd
())
{
code32Bit
.
op
.
op4
=
offsetOP
;
}
else
{
code32Bit
.
op
.
op1
=
offsetOP
;
}
tweakOpImm
(
OFFSET_INLINE_OP_OFFSET_CODE
,
offsetOP
);
#endif
}
...
...
app/src/main/cpp/trampoline/trampoline.h
View file @
22ec6bcb
...
...
@@ -85,6 +85,17 @@ extern "C" void CALL_ORIGIN_TRAMPOLINE();
namespace
SandHook
{
//deal with little or big edn
union
Code32Bit
{
uint32_t
code
;
struct
{
unsigned
char
op1
;
unsigned
char
op2
;
unsigned
char
op3
;
unsigned
char
op4
;
}
op
;
};
class
Trampoline
{
public
:
...
...
@@ -136,6 +147,18 @@ namespace SandHook {
return
*
pointer
==
0
;
}
//tweak imm of a 32bit asm code
void
tweakOpImm
(
Size
codeOffset
,
unsigned
char
imm
)
{
Code32Bit
code32Bit
;
code32Bit
.
code
=
*
reinterpret_cast
<
uint32_t
*>
(((
Size
)
getCode
()
+
codeOffset
));
if
(
isBigEnd
())
{
code32Bit
.
op
.
op4
=
imm
;
}
else
{
code32Bit
.
op
.
op1
=
imm
;
}
codeCopy
(
reinterpret_cast
<
Code
>
(
&
code32Bit
.
code
),
codeOffset
,
4
);
}
protected
:
virtual
Size
codeLength
()
=
0
;
virtual
Code
templateCode
()
=
0
;
...
...
@@ -145,17 +168,6 @@ namespace SandHook {
Size
codeLen
;
};
union
Code32Bit
{
uint32_t
code
;
struct
{
unsigned
char
op1
;
unsigned
char
op2
;
unsigned
char
op3
;
unsigned
char
op4
;
}
op
;
};
}
...
...
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