Commit ee13b7b5 authored by swift_gan's avatar swift_gan

fix error covert of Boolean to long

parent d190d716
...@@ -4,8 +4,14 @@ import com.swift.sandhook.SandHook; ...@@ -4,8 +4,14 @@ import com.swift.sandhook.SandHook;
public class ParamWrapper { public class ParamWrapper {
private static boolean is64Bit;
static {
is64Bit = SandHook.is64Bit();
}
public static boolean support(Class objectType) { public static boolean support(Class objectType) {
if (SandHook.is64Bit()) { if (is64Bit) {
return objectType != float.class && objectType != double.class; return objectType != float.class && objectType != double.class;
} else { } else {
return objectType != float.class && objectType != double.class && objectType != long.class; return objectType != float.class && objectType != double.class && objectType != long.class;
...@@ -13,7 +19,7 @@ public class ParamWrapper { ...@@ -13,7 +19,7 @@ public class ParamWrapper {
} }
public static Object addressToObject(Class objectType, long address) { public static Object addressToObject(Class objectType, long address) {
if (SandHook.is64Bit()) { if (is64Bit) {
return addressToObject64(objectType, address); return addressToObject64(objectType, address);
} else { } else {
return addressToObject32(objectType, (int) address); return addressToObject32(objectType, (int) address);
...@@ -67,7 +73,7 @@ public class ParamWrapper { ...@@ -67,7 +73,7 @@ public class ParamWrapper {
} }
public static long objectToAddress(Class objectType, Object object) { public static long objectToAddress(Class objectType, Object object) {
if (SandHook.is64Bit()) { if (is64Bit) {
return objectToAddress64(objectType, object); return objectToAddress64(objectType, object);
} else { } else {
return objectToAddress32(objectType, object); return objectToAddress32(objectType, object);
...@@ -87,7 +93,7 @@ public class ParamWrapper { ...@@ -87,7 +93,7 @@ public class ParamWrapper {
} else if (objectType == char.class) { } else if (objectType == char.class) {
return (char)object; return (char)object;
} else if (objectType == boolean.class) { } else if (objectType == boolean.class) {
return object == Boolean.TRUE ? 1 : 0; return Boolean.TRUE.equals(object) ? 1 : 0;
} else { } else {
throw new RuntimeException("unknown type: " + objectType.toString()); throw new RuntimeException("unknown type: " + objectType.toString());
} }
...@@ -111,7 +117,7 @@ public class ParamWrapper { ...@@ -111,7 +117,7 @@ public class ParamWrapper {
} else if (objectType == char.class) { } else if (objectType == char.class) {
return (char)object; return (char)object;
} else if (objectType == boolean.class) { } else if (objectType == boolean.class) {
return object == Boolean.TRUE ? 1 : 0; return Boolean.TRUE.equals(object) ? 1 : 0;
} else { } else {
throw new RuntimeException("unknown type: " + objectType.toString()); throw new RuntimeException("unknown type: " + objectType.toString());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment