Commit 2f24b4ab authored by Julian Kranz's avatar Julian Kranz
Browse files

Jgdrr

- Continued to implement jgdrr
parent a983fd74
...@@ -12,7 +12,9 @@ public class Program { ...@@ -12,7 +12,9 @@ public class Program {
NativeInterface n = new NativeInterface(builder); NativeInterface n = new NativeInterface(builder);
IRReilCollection c = n.decodeAndTranslate(null); IRReilCollection c = n.decodeAndTranslate(new byte[] { 0x66, 0x0f, 0x38, 0x04, (byte)0xd1 });
// IRReilCollection c = n.decodeAndTranslate(new byte[] { 0x66 });
// IRReilCollection c = n.decodeAndTranslate(null);
for (int i = 0; i < c.size(); i++) { for (int i = 0; i < c.size(); i++) {
System.out.println(c.get(i)); System.out.println(c.get(i));
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "rnati_NativeInterface.h" #include "rnati_NativeInterface.h"
//gcc -std=c99 -fPIC -shared -Wl,-soname,libjgdrr.so -I/usr/lib/jvm/java-6-openjdk-amd64/include -I../.. -I../../include ../../dis.o -o ../bin/libjgdrr.so rnati_NativeInterface.c ../../gdrr/Debug/libgdrr.a //gcc -std=c99 -fPIC -shared -Wl,-soname,libjgdrr.so -I/usr/lib/jvm/java-6-openjdk-amd64/include -I../.. -I../../include ../../dis.o -o ../bin/libjgdrr.so rnati_NativeInterface.c ../../gdrr/Debug/libgdrr.a
//echo "48 83 ec 08" | java -Djava.library.path=. Program //echo "48 83 ec 08" | java -ss134217728 -Djava.library.path=. Program
struct closure { struct closure {
JNIEnv *env; JNIEnv *env;
...@@ -603,43 +603,38 @@ JNIEXPORT ...@@ -603,43 +603,38 @@ JNIEXPORT
jobject jobject
JNICALL Java_rnati_NativeInterface_decodeAndTranslateNative(JNIEnv *env, JNICALL Java_rnati_NativeInterface_decodeAndTranslateNative(JNIEnv *env,
jobject obj, jbyteArray input) { jobject obj, jbyteArray input) {
__char blob[15]; if(input == NULL) {
char fmt[1024]; jclass exp = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
__word sz = 15; (*env)->ThrowNew(env, exp, "Input must not be null.");
__obj insn; return NULL;
int i, c;
for(i = 0; i < sz; i++) {
int x = fscanf(stdin, "%x", &c);
switch(x) {
case EOF:
goto done;
case 0:
__fatal("invalid input; should be in hex form: '0f 0b ..'");
}
blob[i] = c & 0xff;
} }
done:;
__obj state = __createState(blob, i, 0, 0); size_t length = (*env)->GetArrayLength(env, input);
insn = __runMonadicNoArg(__decode__, &state); __char *bytes = (char*)(*env)->GetByteArrayElements(env, input, 0);
__obj state = __createState(bytes, length, 0, 0);
__obj insn = __runMonadicNoArg(__decode__, &state);
if(___isNil(insn)) if(1 || ___isNil(insn)) {
__fatal("decode failed"); jclass exp = (*env)->FindClass(env, "rnati/ReilDecodeException");
else { (*env)->ThrowNew(env, exp, "Decode failed.");
return NULL;
} else {
//__pretty(__pretty__, insn, fmt, 1024); //__pretty(__pretty__, insn, fmt, 1024);
puts(fmt); // puts(fmt);
printf("---------------------------\n"); printf("---------------------------\n");
__obj r = __runMonadicOneArg(__translate__, &state, insn); __obj r = __runMonadicOneArg(__translate__, &state, insn);
if(___isNil(r)) if(___isNil(r))
__fatal("translate failed"); __fatal("translate failed");
else { else {
__pretty(__rreil_pretty__, r, fmt, 1024); // __pretty(__rreil_pretty__, r, fmt, 2048);
printf("---------------------------\n"); printf("---------------------------\n");
puts(fmt); // puts(fmt);
struct gdrr_config config; struct gdrr_config config;
......
...@@ -258,7 +258,7 @@ main: ...@@ -258,7 +258,7 @@ main:
#vpinsrb $3, %ebx, %xmm1, %xmm2 #vpinsrb $3, %ebx, %xmm1, %xmm2
#pmaddubsw %mm1, %mm2 #pmaddubsw %mm1, %mm2
#pmaddubsw %xmm1, %xmm2 pmaddubsw %xmm1, %xmm2
#vpmaddubsw %xmm1, %xmm2, %xmm3 #vpmaddubsw %xmm1, %xmm2, %xmm3
#pmaddwd %mm1, %mm2 #pmaddwd %mm1, %mm2
...@@ -284,7 +284,7 @@ main: ...@@ -284,7 +284,7 @@ main:
#pminsb %xmm1, %xmm2 #pminsb %xmm1, %xmm2
#vpminsb %xmm1, %xmm2, %xmm3 #vpminsb %xmm1, %xmm2, %xmm3
#pminsw %mm1, %mm2 #pminsw %mm1, %mm2
#pminsw %xmm1, %xmm2 pminsw %xmm1, %xmm2
#vpminsw %xmm1, %xmm2, %xmm3 #vpminsw %xmm1, %xmm2, %xmm3
#pminsd %xmm1, %xmm2 #pminsd %xmm1, %xmm2
#vpminsd %xmm1, %xmm2, %xmm3 #vpminsd %xmm1, %xmm2, %xmm3
...@@ -317,7 +317,7 @@ main: ...@@ -317,7 +317,7 @@ main:
#pmovzxwd %xmm1, %xmm2 #pmovzxwd %xmm1, %xmm2
#pmovzxwq %xmm1, %xmm2 #pmovzxwq %xmm1, %xmm2
#pmovzxdq %xmm1, %xmm2 #pmovzxdq %xmm1, %xmm2
#vpmovzxbw (%rax), %xmm2 vpmovzxbw (%rax), %xmm2
#vpmovzxbd %xmm1, %xmm2 #vpmovzxbd %xmm1, %xmm2
#vpmovzxbq (%rcx), %xmm2 #vpmovzxbq (%rcx), %xmm2
...@@ -357,7 +357,7 @@ main: ...@@ -357,7 +357,7 @@ main:
#vpor %xmm1, %xmm2, %xmm3 #vpor %xmm1, %xmm2, %xmm3
#psadbw %mm1, %mm2 #psadbw %mm1, %mm2
#psadbw %xmm1, %xmm2 psadbw %xmm1, %xmm2
#vpsadbw %xmm1, %xmm2, %xmm3 #vpsadbw %xmm1, %xmm2, %xmm3
#pshufb %mm1, %mm2 #pshufb %mm1, %mm2
...@@ -381,7 +381,7 @@ main: ...@@ -381,7 +381,7 @@ main:
#psignb %mm1, %mm2 #psignb %mm1, %mm2
#psignb %xmm1, %xmm2 #psignb %xmm1, %xmm2
#psignw %xmm1, %xmm2 #psignw %xmm1, %xmm2
#psignd (%rax), %xmm2 psignd (%rax), %xmm2
#vpsignb %xmm1, %xmm2, %xmm3 #vpsignb %xmm1, %xmm2, %xmm3
#vpsignw %xmm1, %xmm2, %xmm3 #vpsignw %xmm1, %xmm2, %xmm3
#vpsignd %xmm1, %xmm2, %xmm3 #vpsignd %xmm1, %xmm2, %xmm3
...@@ -407,7 +407,7 @@ main: ...@@ -407,7 +407,7 @@ main:
#psrlw %mm1, %mm2 #psrlw %mm1, %mm2
#psrlw (%rax), %xmm1 #psrlw (%rax), %xmm1
#psrlw $197, %xmm1 #psrlw $197, %xmm1
#psrld $20, %mm1 psrld $20, %mm1
#psrlq $10, %mm1 #psrlq $10, %mm1
#vpsrld %xmm1, %xmm2, %xmm3 #vpsrld %xmm1, %xmm2, %xmm3
#vpsrlq $33, %xmm1, %xmm2 #vpsrlq $33, %xmm1, %xmm2
...@@ -434,7 +434,7 @@ main: ...@@ -434,7 +434,7 @@ main:
#punpckhbw %mm1, %mm2 #punpckhbw %mm1, %mm2
#punpckhwd %xmm1, %xmm2 #punpckhwd %xmm1, %xmm2
#punpckhdq %mm1, %mm2 #punpckhdq %mm1, %mm2
#punpckhqdq %xmm1, %xmm2 punpckhqdq %xmm1, %xmm2
#vpunpckhbw %xmm1, %xmm2, %xmm3 #vpunpckhbw %xmm1, %xmm2, %xmm3
#vpunpckhwd %xmm1, %xmm2, %xmm3 #vpunpckhwd %xmm1, %xmm2, %xmm3
#vpunpckhdq %xmm1, %xmm2, %xmm3 #vpunpckhdq %xmm1, %xmm2, %xmm3
...@@ -489,7 +489,7 @@ main: ...@@ -489,7 +489,7 @@ main:
#vmaskmovps %xmm1, %xmm2, (%rax) #vmaskmovps %xmm1, %xmm2, (%rax)
#vmaskmovps (%rax), %xmm1, %xmm2 #vmaskmovps (%rax), %xmm1, %xmm2
#vmaskmovpd %xmm1, %xmm2, (%rax) #vmaskmovpd %xmm1, %xmm2, (%rax)
#vmaskmovpd (%rax), %xmm1, %xmm2 vmaskmovpd (%rax), %xmm1, %xmm2
#vmaskmovpd %ymm1, %ymm2, (%rax) #vmaskmovpd %ymm1, %ymm2, (%rax)
#vmaskmovpd (%rax), %ymm1, %ymm2 #vmaskmovpd (%rax), %ymm1, %ymm2
...@@ -523,7 +523,7 @@ main: ...@@ -523,7 +523,7 @@ main:
#addb $42, 4(%eax,%ebp,2) #addb $42, 4(%eax,%ebp,2)
#addb $42, 4(%eax,%ecx,2) #addb $42, 4(%eax,%ecx,2)
#addb $42, 4(%r8,%r9,2) #addb $42, 4(%r8,%r9,2)
#addl $227439052, -1907495376(%r8,%r9,2) addl $227439052, -1907495376(%r8,%r9,2)
#movq %rax, %rcx #movq %rax, %rcx
#movq %r8, %r9 #movq %r8, %r9
#addq %rax, %rcx #addq %rax, %rcx
......
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