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

Jgdrr

- Continued to implement jgdrr
parent a983fd74
......@@ -12,7 +12,9 @@ public class Program {
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++) {
System.out.println(c.get(i));
......
......@@ -6,7 +6,7 @@
#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
//echo "48 83 ec 08" | java -Djava.library.path=. Program
//echo "48 83 ec 08" | java -ss134217728 -Djava.library.path=. Program
struct closure {
JNIEnv *env;
......@@ -603,43 +603,38 @@ JNIEXPORT
jobject
JNICALL Java_rnati_NativeInterface_decodeAndTranslateNative(JNIEnv *env,
jobject obj, jbyteArray input) {
__char blob[15];
char fmt[1024];
__word sz = 15;
__obj insn;
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;
if(input == NULL) {
jclass exp = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
(*env)->ThrowNew(env, exp, "Input must not be null.");
return NULL;
}
done:;
__obj state = __createState(blob, i, 0, 0);
insn = __runMonadicNoArg(__decode__, &state);
size_t length = (*env)->GetArrayLength(env, input);
__char *bytes = (char*)(*env)->GetByteArrayElements(env, input, 0);
__obj state = __createState(bytes, length, 0, 0);
__obj insn = __runMonadicNoArg(__decode__, &state);
if(___isNil(insn))
__fatal("decode failed");
else {
if(1 || ___isNil(insn)) {
jclass exp = (*env)->FindClass(env, "rnati/ReilDecodeException");
(*env)->ThrowNew(env, exp, "Decode failed.");
return NULL;
} else {
//__pretty(__pretty__, insn, fmt, 1024);
puts(fmt);
// puts(fmt);
printf("---------------------------\n");
__obj r = __runMonadicOneArg(__translate__, &state, insn);
if(___isNil(r))
__fatal("translate failed");
else {
__pretty(__rreil_pretty__, r, fmt, 1024);
// __pretty(__rreil_pretty__, r, fmt, 2048);
printf("---------------------------\n");
puts(fmt);
// puts(fmt);
struct gdrr_config config;
......
......@@ -258,7 +258,7 @@ main:
#vpinsrb $3, %ebx, %xmm1, %xmm2
#pmaddubsw %mm1, %mm2
#pmaddubsw %xmm1, %xmm2
pmaddubsw %xmm1, %xmm2
#vpmaddubsw %xmm1, %xmm2, %xmm3
#pmaddwd %mm1, %mm2
......@@ -284,7 +284,7 @@ main:
#pminsb %xmm1, %xmm2
#vpminsb %xmm1, %xmm2, %xmm3
#pminsw %mm1, %mm2
#pminsw %xmm1, %xmm2
pminsw %xmm1, %xmm2
#vpminsw %xmm1, %xmm2, %xmm3
#pminsd %xmm1, %xmm2
#vpminsd %xmm1, %xmm2, %xmm3
......@@ -317,7 +317,7 @@ main:
#pmovzxwd %xmm1, %xmm2
#pmovzxwq %xmm1, %xmm2
#pmovzxdq %xmm1, %xmm2
#vpmovzxbw (%rax), %xmm2
vpmovzxbw (%rax), %xmm2
#vpmovzxbd %xmm1, %xmm2
#vpmovzxbq (%rcx), %xmm2
......@@ -357,7 +357,7 @@ main:
#vpor %xmm1, %xmm2, %xmm3
#psadbw %mm1, %mm2
#psadbw %xmm1, %xmm2
psadbw %xmm1, %xmm2
#vpsadbw %xmm1, %xmm2, %xmm3
#pshufb %mm1, %mm2
......@@ -381,7 +381,7 @@ main:
#psignb %mm1, %mm2
#psignb %xmm1, %xmm2
#psignw %xmm1, %xmm2
#psignd (%rax), %xmm2
psignd (%rax), %xmm2
#vpsignb %xmm1, %xmm2, %xmm3
#vpsignw %xmm1, %xmm2, %xmm3
#vpsignd %xmm1, %xmm2, %xmm3
......@@ -407,7 +407,7 @@ main:
#psrlw %mm1, %mm2
#psrlw (%rax), %xmm1
#psrlw $197, %xmm1
#psrld $20, %mm1
psrld $20, %mm1
#psrlq $10, %mm1
#vpsrld %xmm1, %xmm2, %xmm3
#vpsrlq $33, %xmm1, %xmm2
......@@ -434,7 +434,7 @@ main:
#punpckhbw %mm1, %mm2
#punpckhwd %xmm1, %xmm2
#punpckhdq %mm1, %mm2
#punpckhqdq %xmm1, %xmm2
punpckhqdq %xmm1, %xmm2
#vpunpckhbw %xmm1, %xmm2, %xmm3
#vpunpckhwd %xmm1, %xmm2, %xmm3
#vpunpckhdq %xmm1, %xmm2, %xmm3
......@@ -489,7 +489,7 @@ main:
#vmaskmovps %xmm1, %xmm2, (%rax)
#vmaskmovps (%rax), %xmm1, %xmm2
#vmaskmovpd %xmm1, %xmm2, (%rax)
#vmaskmovpd (%rax), %xmm1, %xmm2
vmaskmovpd (%rax), %xmm1, %xmm2
#vmaskmovpd %ymm1, %ymm2, (%rax)
#vmaskmovpd (%rax), %ymm1, %ymm2
......@@ -523,7 +523,7 @@ main:
#addb $42, 4(%eax,%ebp,2)
#addb $42, 4(%eax,%ecx,2)
#addb $42, 4(%r8,%r9,2)
#addl $227439052, -1907495376(%r8,%r9,2)
addl $227439052, -1907495376(%r8,%r9,2)
#movq %rax, %rcx
#movq %r8, %r9
#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