Update Java samples to match C samples.
Also add all of the samples as Java tests, referencing the output of the C samples.
This commit is contained in:
@@ -25,21 +25,14 @@ package samples;
|
||||
|
||||
import unicorn.*;
|
||||
|
||||
public class Sample_x86_mmr {
|
||||
public class Sample_x86_mmr implements UnicornConst, X86Const {
|
||||
|
||||
public static void test_x86_mmr() {
|
||||
// Initialize emulator in X86-32bit mode
|
||||
Unicorn uc;
|
||||
try {
|
||||
uc = new Unicorn(Unicorn.UC_ARCH_X86, Unicorn.UC_MODE_32);
|
||||
} catch (UnicornException uex) {
|
||||
System.out
|
||||
.println("Failed on uc_open() with error returned: " + uex);
|
||||
return;
|
||||
}
|
||||
Unicorn uc = new Unicorn(UC_ARCH_X86, UC_MODE_32);
|
||||
|
||||
// map 4k
|
||||
uc.mem_map(0x400000, 0x1000, Unicorn.UC_PROT_ALL);
|
||||
uc.mem_map(0x400000, 0x1000, UC_PROT_ALL);
|
||||
|
||||
X86_MMR ldtr1 = new X86_MMR(0x1111111122222222L, 0x33333333, 0x44444444,
|
||||
(short) 0x5555);
|
||||
@@ -52,14 +45,14 @@ public class Sample_x86_mmr {
|
||||
|
||||
// initialize machine registers
|
||||
|
||||
uc.reg_write(Unicorn.UC_X86_REG_LDTR, ldtr1);
|
||||
uc.reg_write(Unicorn.UC_X86_REG_GDTR, gdtr1);
|
||||
uc.reg_write(Unicorn.UC_X86_REG_EAX, 0xddddddddL);
|
||||
uc.reg_write(UC_X86_REG_LDTR, ldtr1);
|
||||
uc.reg_write(UC_X86_REG_GDTR, gdtr1);
|
||||
uc.reg_write(UC_X86_REG_EAX, 0xddddddddL);
|
||||
|
||||
// read the registers back out
|
||||
eax = (int) uc.reg_read(Unicorn.UC_X86_REG_EAX);
|
||||
ldtr2 = (X86_MMR) uc.reg_read(Unicorn.UC_X86_REG_LDTR, null);
|
||||
gdtr2 = (X86_MMR) uc.reg_read(Unicorn.UC_X86_REG_GDTR, null);
|
||||
eax = (int) uc.reg_read(UC_X86_REG_EAX);
|
||||
ldtr2 = (X86_MMR) uc.reg_read(UC_X86_REG_LDTR, null);
|
||||
gdtr2 = (X86_MMR) uc.reg_read(UC_X86_REG_GDTR, null);
|
||||
|
||||
System.out.printf(">>> EAX = 0x%x\n", eax);
|
||||
|
||||
@@ -70,8 +63,6 @@ public class Sample_x86_mmr {
|
||||
|
||||
System.out.printf(">>> GDTR.base = 0x%x\n", gdtr2.base);
|
||||
System.out.printf(">>> GDTR.limit = 0x%x\n", gdtr2.limit);
|
||||
|
||||
uc.close();
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
|
||||
Reference in New Issue
Block a user