mirror of
https://github.com/TheOfficialFloW/bd-jb
synced 2024-11-25 02:12:16 -05:00
Clean up API class.
This commit is contained in:
parent
18118ff574
commit
39ab5ea346
@ -44,10 +44,10 @@ public final class API {
|
|||||||
private static final String FIND_ENTRY_METHOD_NAME = "findEntry";
|
private static final String FIND_ENTRY_METHOD_NAME = "findEntry";
|
||||||
private static final String HANDLE_FIELD_NAME = "handle";
|
private static final String HANDLE_FIELD_NAME = "handle";
|
||||||
|
|
||||||
private static final int[] MULTI_NEW_ARRAY_DIMENSIONS = new int[] {1};
|
|
||||||
|
|
||||||
private static final String VALUE_FIELD_NAME = "value";
|
private static final String VALUE_FIELD_NAME = "value";
|
||||||
|
|
||||||
|
private static final int[] MULTI_NEW_ARRAY_DIMENSIONS = new int[] {1};
|
||||||
|
|
||||||
private static API instance;
|
private static API instance;
|
||||||
|
|
||||||
private UnsafeInterface unsafe;
|
private UnsafeInterface unsafe;
|
||||||
@ -227,7 +227,7 @@ public final class API {
|
|||||||
|
|
||||||
private void buildContext(
|
private void buildContext(
|
||||||
long contextBuf,
|
long contextBuf,
|
||||||
long setJmpBuf,
|
long jmpBuf,
|
||||||
long rip,
|
long rip,
|
||||||
long rdi,
|
long rdi,
|
||||||
long rsi,
|
long rsi,
|
||||||
@ -235,13 +235,13 @@ public final class API {
|
|||||||
long rcx,
|
long rcx,
|
||||||
long r8,
|
long r8,
|
||||||
long r9) {
|
long r9) {
|
||||||
long rbx = read64(setJmpBuf + 0x08);
|
long rbx = read64(jmpBuf + 0x08);
|
||||||
long rsp = read64(setJmpBuf + 0x10);
|
long rsp = read64(jmpBuf + 0x10);
|
||||||
long rbp = read64(setJmpBuf + 0x18);
|
long rbp = read64(jmpBuf + 0x18);
|
||||||
long r12 = read64(setJmpBuf + 0x20);
|
long r12 = read64(jmpBuf + 0x20);
|
||||||
long r13 = read64(setJmpBuf + 0x28);
|
long r13 = read64(jmpBuf + 0x28);
|
||||||
long r14 = read64(setJmpBuf + 0x30);
|
long r14 = read64(jmpBuf + 0x30);
|
||||||
long r15 = read64(setJmpBuf + 0x38);
|
long r15 = read64(jmpBuf + 0x38);
|
||||||
|
|
||||||
write64(contextBuf + 0x48, rdi);
|
write64(contextBuf + 0x48, rdi);
|
||||||
write64(contextBuf + 0x50, rsi);
|
write64(contextBuf + 0x50, rsi);
|
||||||
@ -264,7 +264,7 @@ public final class API {
|
|||||||
|
|
||||||
public void train() {
|
public void train() {
|
||||||
for (int i = 0; i < 10000; i++) {
|
for (int i = 0; i < 10000; i++) {
|
||||||
call(-1);
|
call(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,11 +286,11 @@ public final class API {
|
|||||||
try {
|
try {
|
||||||
long ret = 0;
|
long ret = 0;
|
||||||
|
|
||||||
// When func is -1, only do one iteration to avoid calling __Ux86_64_setcontext.
|
// When func is 0, only do one iteration to avoid calling __Ux86_64_setcontext.
|
||||||
// This is used to "train" this function to kick in optimization early. Otherwise, it is
|
// This is used to "train" this function to kick in optimization early. Otherwise, it is
|
||||||
// possible that optimization kicks in between the calls to setjmp and __Ux86_64_setcontext
|
// possible that optimization kicks in between the calls to setjmp and __Ux86_64_setcontext
|
||||||
// leading to different stack layouts of the two calls.
|
// leading to different stack layouts of the two calls.
|
||||||
int iter = func == -1 ? 1 : 2;
|
int iter = func == 0 ? 1 : 2;
|
||||||
|
|
||||||
if (jdk11) {
|
if (jdk11) {
|
||||||
write64(fakeClassOop + 0x00, fakeClass);
|
write64(fakeClassOop + 0x00, fakeClass);
|
||||||
@ -398,9 +398,9 @@ public final class API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long addrof(Object obj) {
|
public long addrof(Object obj) {
|
||||||
Long longValue = new Long(1337);
|
Long val = new Long(1337);
|
||||||
unsafe.putObject(longValue, longValueOffset, obj);
|
unsafe.putObject(val, longValueOffset, obj);
|
||||||
return unsafe.getLong(longValue, longValueOffset);
|
return unsafe.getLong(val, longValueOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte read8(long addr) {
|
public byte read8(long addr) {
|
||||||
|
Loading…
Reference in New Issue
Block a user