Update .travis.yml

Update eflags_nosync.c
Update sigill2.c
Update ro_mem_test.c
Update ro_mem_test.c
Update nr_mem_test.c
Update mem_fuzz.c
Update mem_double_unmap.c
Update emu_stop_in_hook_overrun.c
Update eflags_nosync.c
remove unused
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update mem_64_c.c
Update mem_64_c.c
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update Makefile
Update .travis.yml
try android ndk build
Update unicorn.py
Update unicorn.py
Update Makefile
Update unicorn.py
Update unicorn.py
remove an untrue comment

if a dll/so/dylib gets loaded at runtime is dependent on many different factors, primarily the LD/DYLD paths. Those do not always include the current working directory
Update Makefile
Update .appveyor.yml
Update .travis.yml
Update Makefile
Update .appveyor.yml
Fix bad sample
This commit is contained in:
Stephen 2016-11-07 10:52:05 -08:00 committed by sgroat
parent 5d14cb350a
commit 9f0cdc4be9
24 changed files with 126 additions and 190 deletions

View File

@ -1,21 +1,23 @@
# Appveyor configuration file for CI build of Unicorn Engine on Windows (under Cygwin)
environment:
matrix:
- CYG_ROOT: C:\cygwin64
CYG_SETUP: setup-x86_64.exe
CYG_MIRROR: http://cygwin.mirror.constant.com
matrix:
- MSYSTEM: MINGW64
BASH: C:\msys64\usr\bin\bash
CC: x86_64-w64-mingw32-gcc
- MSYSTEM: MINGW32
BASH: C:\msys64\usr\bin\bash
CC: i686-w64-mingw32-gcc
- CYG_ROOT: C:\cygwin64
CYG_CACHE: C:\cygwin64\var\cache\setup
CYG_BASH: C:\cygwin64\bin\bash
CYG_SETUP: setup-x86_64.exe
BASH: C:\cygwin64\bin\bash
CC: gcc
- CYG_ROOT: C:\cygwin
CYG_SETUP: setup-x86.exe
CYG_MIRROR: http://cygwin.mirror.constant.com
CYG_CACHE: C:\cygwin\var\cache\setup
CYG_BASH: C:\cygwin\bin\bash
CYG_SETUP: setup-x86.exe
BASH: C:\cygwin\bin\bash
CC: gcc
# - MSYS_ROOT: C:\msys64
# MSYS_BASH: C:\msys64\mingw64\bin\sh
# CC: x86_64-w64-mingw32-gcc
# Cache Cygwin files to speed up build
cache:
@ -30,12 +32,13 @@ init:
# Install needed build dependencies
install:
- ps: 'if ($env:CYG_ROOT) { Start-FileDownload "http://cygwin.com/$env:CYG_SETUP" -FileName "$env:CYG_SETUP" }'
- if defined CYG_ROOT (%CYG_SETUP% --quiet-mode --no-shortcuts --only-site --root "%CYG_ROOT%" --site "%CYG_MIRROR%" --local-package-dir "%CYG_CACHE%" --packages make,gcc-core,clang,pkg-config,libpcre-devel,libglib2.0-devel,cmake,python-setuptools --upgrade-also)
- if defined MSYS_ROOT (%MSYS_BASH% -lc "pacman -S --noconfirm mingw-w64-x86_64-glib2")
- ps: if (Test-Path Env:\CYG_ROOT) { Start-FileDownload "http://cygwin.com/$env:CYG_SETUP" -FileName "$env:CYG_SETUP" }
- if defined CYG_ROOT (%CYG_SETUP% --quiet-mode --no-shortcuts --only-site --root "%CYG_ROOT%" --site "%CYG_MIRROR%" --local-package-dir "%CYG_CACHE%" --packages make,gcc-core,clang,pkg-config,libpcre-devel,libglib2.0-devel,cmake,python-setuptools,ruby,mingw64-i686-gcc-core,mingw64-x86_64-gcc-core --upgrade-also)
- if defined MSYSTEM (%BASH% -lc "pacman -Sy --noconfirm mingw-w64-x86_64-glib2 mingw-w64-i686-glib2 cmake")
build_script:
- if defined CYG_ROOT (%CYG_BASH% -lc "export CYGWIN=winsymlinks:native; cd $APPVEYOR_BUILD_FOLDER; ./install-cmocka-linux.sh; make; export PATH=$PATH:../../:../../cmocka/src:../:../cmocka/src; make test")
- if defined MSYS_ROOT (%MSYS_BASH% -lc "MSYS=winsymlinks, cd $(cygpath ${APPVEYOR_BUILD_FOLDER}); x86_64-w64-mingw32-gcc --version; ./install-cmocka-linux.sh; make")
- if defined BASH (%BASH% -lc "cd $(cygpath ${APPVEYOR_BUILD_FOLDER}); ./install-cmocka-linux.sh; make;")
- if "%MSYSTEM%" == "MINGW64" (%BASH% -lc "cd $(cygpath ${APPVEYOR_BUILD_FOLDER}); make -C bindings/go")
# make test
#- 'cd %APPVEYOR_BUILD_FOLDER% && cd bindings\dotnet && msbuild UnicornDotNet.sln'
# Allows RDP
#on_finish:
@ -43,4 +46,5 @@ build_script:
# Disable tests for now
#
test: off
test_script:
- if defined CYG_ROOT (%BASH% -lc "export CYGWIN=winsymlinks:native; cd $APPVEYOR_BUILD_FOLDER; export PATH=$PATH:$APPVEYOR_BUILD_FOLDER:$APPVEYOR_BUILD_FOLDER/cmocka/src; make test")

View File

@ -6,9 +6,7 @@ before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" && "$MACOS_UNIVERSAL" == "yes" ]]; then brew install glib --universal cmocka; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./install-cmocka-linux.sh; fi
script:
- make && make test
# TODO make bindings enabled
# - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make clean && ./make.sh ios; fi
- make && make -C bindings/go && make -C bindings/go test && make test
compiler:
- clang
- gcc
@ -23,8 +21,6 @@ matrix:
- os: osx
compiler: gcc
env: MACOS_UNIVERSAL=yes
# - os: osx
# compiler: x86_64-w64-mingw32-gcc
addons:
apt:
packages:

View File

@ -10,8 +10,7 @@ include pkgconfig.mk # package version
LIBNAME = unicorn
UNAME_S := $(shell uname -s)
GENOBJ = $(shell find qemu/$(1) -name "*.o" 2>/dev/null) $(wildcard qemu/util/*.o) $(wildcard qemu/*.o) $(wildcard qemu/qom/*.o)\
$(wildcard qemu/hw/core/*.o) $(wildcard qemu/qapi/*.o) $(wildcard qemu/qobject/*.o)
GENOBJ = $(shell find qemu/$(1) -name "*.o" 2>/dev/null)
ifneq (,$(findstring x86,$(UNICORN_ARCHS)))
UC_TARGET_OBJ += $(call GENOBJ,x86_64-softmmu)
@ -196,6 +195,8 @@ else
PKGCFGDIR ?= $(LIBDATADIR)/pkgconfig
endif
$(LIBNAME)_LDFLAGS += $(GLIB) -lm
.PHONY: all
all: unicorn
$(MAKE) -C samples
@ -210,15 +211,16 @@ qemu/config-host.h-timestamp:
compile_lib: config qemu/config-host.h-timestamp
$(MAKE) -C qemu -j 4
$(eval UC_TARGET_OBJ += $$(wildcard qemu/util/*.o) $$(wildcard qemu/*.o) $$(wildcard qemu/qom/*.o) $$(wildcard qemu/hw/core/*.o) $$(wildcard qemu/qapi/*.o) $$(wildcard qemu/qobject/*.o))
unicorn: compile_lib $(LIBRARY) $(ARCHIVE)
unicorn: $(LIBRARY) $(ARCHIVE)
$(LIBRARY): $(UC_TARGET_OBJ)
$(CC) $(CFLAGS) -shared $(GENOBJ) uc.o list.o -o $(LIBRARY) $(GLIB) -lm $($(LIBNAME)_LDFLAGS)
ln -sf $(LIBRARY) $(LIBRARY_SYMLINK)
$(LIBRARY): compile_lib uc.o list.o
$(CC) $(CFLAGS) -shared $(UC_TARGET_OBJ) uc.o list.o -o $(LIBRARY) $($(LIBNAME)_LDFLAGS)
-ln -sf $(LIBRARY) $(LIBRARY_SYMLINK)
$(ARCHIVE): $(UC_TARGET_OBJ) uc.o list.o
$(AR) q $(ARCHIVE) $^
$(ARCHIVE): compile_lib uc.o list.o
$(AR) q $(ARCHIVE) $(UC_TARGET_OBJ) uc.o list.o
$(RANLIB) $(ARCHIVE)
@ -228,6 +230,7 @@ $(PKGCFGF):
.PHONY: test
test: all
$(MAKE) -C tests/unit test
$(MAKE) -C tests/regress test
$(MAKE) -C bindings test
install: compile_lib $(PKGCFGF)

View File

@ -1,19 +1,17 @@
# Unicorn Engine
# By Nguyen Anh Quynh & Dang Hoang Vu, 2015
TMP_DIR = /tmp/unicorn_sample
DIFF = diff
DIFF = diff -u -w
SAMPLE_ARM = $(TMP_DIR)/sample_arm
SAMPLE_ARM64 = $(TMP_DIR)/sample_arm64
SAMPLE_MIPS = $(TMP_DIR)/sample_mips
SAMPLE_M68K = $(TMP_DIR)/sample_m68k
SAMPLE_SPARC = $(TMP_DIR)/sample_sparc
SAMPLE_X86 = $(TMP_DIR)/sample_x86
SAMPLE_SOURCE = $(wildcard ../samples/*.c)
SAMPLE = $(SAMPLE_SOURCE:../samples/%.c=%)
SAMPLE := $(SAMPLE:mem_apis=)
SAMPLE := $(SAMPLE:sample_batch_reg=)
SAMPLE := $(SAMPLE:sample_x86_32_gdt_and_seg_regs=)
SAMPLE := $(SAMPLE:shellcode=)
ENV_VARS = LD_LIBRARY_PATH=../ DYLD_LIBRARY_PATH=../
.PHONY: build install expected python sample_diff clean check test
.PHONY: build install python c clean check test
build:
$(MAKE) -C python gen_const
@ -26,39 +24,22 @@ install: build
$(MAKE) -C python install
$(MAKE) -C java install
test: expected python sample_diff
test: $(SAMPLE:%=%.py.test)
expected:
c:
$(MAKE) -C ../samples
mkdir -p $(TMP_DIR)
$(ENV_VARS) ../samples/sample_arm > $(SAMPLE_ARM)_e
$(ENV_VARS) ../samples/sample_arm64 > $(SAMPLE_ARM64)_e
$(ENV_VARS) ../samples/sample_mips > $(SAMPLE_MIPS)_e
$(ENV_VARS) ../samples/sample_sparc > $(SAMPLE_SPARC)_e
$(ENV_VARS) ../samples/sample_m68k > $(SAMPLE_M68K)_e
$(ENV_VARS) ../samples/sample_x86 -16 > $(SAMPLE_X86)_e
$(ENV_VARS) ../samples/sample_x86 -32 >> $(SAMPLE_X86)_e
$(ENV_VARS) ../samples/sample_x86 -64 >> $(SAMPLE_X86)_e
python:
$(MAKE) -C python
$(ENV_VARS) python python/sample_arm.py > $(SAMPLE_ARM)_o
$(ENV_VARS) python python/sample_arm64.py > $(SAMPLE_ARM64)_o
$(ENV_VARS) python python/sample_mips.py > $(SAMPLE_MIPS)_o
$(ENV_VARS) python python/sample_sparc.py > $(SAMPLE_SPARC)_o
$(ENV_VARS) python python/sample_m68k.py > $(SAMPLE_M68K)_o
$(ENV_VARS) python python/sample_x86.py > $(SAMPLE_X86)_o
%.c.txt: c
$(ENV_VARS) ../samples/$(@:%.c.txt=%) > $@
%.py.txt: python
$(ENV_VARS) python python/$(@:%.txt=%) > $@
sample_diff:
$(DIFF) $(SAMPLE_ARM)_e $(SAMPLE_ARM)_o
$(DIFF) $(SAMPLE_ARM64)_e $(SAMPLE_ARM64)_o
$(DIFF) $(SAMPLE_MIPS)_e $(SAMPLE_MIPS)_o
$(DIFF) $(SAMPLE_SPARC)_e $(SAMPLE_SPARC)_o
$(DIFF) $(SAMPLE_M68K)_e $(SAMPLE_M68K)_o
$(DIFF) $(SAMPLE_X86)_e $(SAMPLE_X86)_o
%.py.test: %.c.txt %.py.txt
$(DIFF) $(@:%.py.test=%.c.txt) $(@:%.py.test=%.py.txt)
clean:
rm -rf $(TMP_DIR)
# rm -rf *.txt
$(MAKE) -C python clean
$(MAKE) -C java clean

View File

@ -1,14 +1,12 @@
# Go binding for Unicorn engine. Ryan Hileman <lunixbochs@gmail.com>
.PHONY: gen_const test
.PHONY: all gen_const test
all:
$(MAKE) gen_const
all: gen_const
cd unicorn && go build
$(MAKE) test
gen_const:
cd .. && python const_generator.py go
test:
cd unicorn && go test
test: all
cd unicorn && LD_LIBRARY_PATH=../../../ DYLD_LIBRARY_PATH=../../../ go test

View File

@ -7,8 +7,8 @@ import (
)
/*
#cgo CFLAGS: -O3
#cgo LDFLAGS: -lunicorn
#cgo CFLAGS: -O3 -Wall -Werror -I../../../include
#cgo LDFLAGS: -L../../../ -lunicorn -lglib-2.0
#include <unicorn/unicorn.h>
#include "uc.h"
*/

View File

@ -442,38 +442,25 @@ def test_i386_context_save():
# write machine code to be emulated to memory
mu.mem_write(address, code)
print(">>> set eax to 1")
# set eax to 1
mu.reg_write(UC_X86_REG_EAX, 1)
print(">>> execute 'inc eax'")
print(">>> Running emulation for the first time")
mu.emu_start(address, address+1)
print(">>> save the CPU context")
print(">>> Emulation done. Below is the CPU context")
print(">>> EAX = 0x%x" %(mu.reg_read(UC_X86_REG_EAX)))
print(">>> Saving CPU context")
saved_context = mu.context_save()
print(">>> execute 'inc eax'")
print(">>> Running emulation for the second time")
mu.emu_start(address, address+1)
print(">>> Emulation done. Below is the CPU context")
print(">>> EAX = 0x%x" %(mu.reg_read(UC_X86_REG_EAX)))
print(">>> assert eax == 3")
assert mu.reg_read(UC_X86_REG_EAX) == 3
print(">>> restore the CPU context")
print(">>> CPU context restored. Below is the CPU context")
mu.context_restore(saved_context)
print(">>> assert eax == 2")
assert mu.reg_read(UC_X86_REG_EAX) == 2
print(">>> execute 'inc eax'")
mu.emu_start(address, address+1)
print(">>> assert eax == 3")
assert mu.reg_read(UC_X86_REG_EAX) == 3
print(">>> restore the CPU context")
mu.context_restore(saved_context)
print(">>> assert eax == 2")
assert mu.reg_read(UC_X86_REG_EAX) == 2
print(">>> EAX = 0x%x" %(mu.reg_read(UC_X86_REG_EAX)))
except UcError as e:
print("ERROR: %s" % e)
@ -644,6 +631,8 @@ if __name__ == '__main__':
print("=" * 35)
test_i386_inout()
print("=" * 35)
test_i386_context_save()
print("=" * 35)
test_i386_jump()
print("=" * 35)
test_i386_loop()

View File

@ -21,7 +21,7 @@ def hook_code(uc, address, size, user_data):
print(">>> Tracing instruction at 0x%x, instruction size = 0x%x" %(address, size))
# read this instruction code from memory
tmp = uc.mem_read(address, size)
print(">>> Instruction code at [0x%x] =" %(address), end="")
print("*** EIP = %x *** :" %(address), end="")
for i in tmp:
print(" %02x" %i, end="")
print("")

View File

@ -17,12 +17,11 @@ _python2 = sys.version_info[0] < 3
if _python2:
range = xrange
if sys.platform == 'darwin':
_lib = "libunicorn.dylib"
elif sys.platform in ('win32', 'cygwin'):
_lib = "unicorn.dll"
else:
_lib = "libunicorn.so"
_lib = { 'darwin': 'libunicorn.dylib',
'win32': 'unicorn.dll',
'cygwin': 'cygunicorn.dll',
'linux': 'libunicorn.so',
'linux2': 'libunicorn.so' }
# Windows DLL in dependency order
_all_windows_dlls = (
@ -45,7 +44,7 @@ def _load_lib(path):
if sys.platform in ('win32', 'cygwin'):
_load_win_support(path)
lib_file = os.path.join(path, _lib)
lib_file = os.path.join(path, _lib[sys.platform])
return ctypes.cdll.LoadLibrary(lib_file)
except OSError:
return None

View File

@ -2,8 +2,8 @@
.PHONY: gen_const
install:
$(MAKE) gen_const
# Use bundle install && rake to install gem and test
install: gen_const
cd unicorn_gem && rake build
cd unicorn_gem && gem install --local pkg/unicorn-0.9.0.gem

View File

@ -1,8 +1,12 @@
#!/bin/sh
#!/bin/bash
set -ex
mkdir cmocka
wget https://cmocka.org/files/1.1/cmocka-1.1.0.tar.xz -O /tmp/cmocka-1.1.0.tar.xz
tar -xf /tmp/cmocka-1.1.0.tar.xz -C /tmp
tar -xvf /tmp/cmocka-1.1.0.tar.xz -C /tmp
if [ "$(expr substr $(uname -s) 1 5)" == "MINGW" ] ; then
cd cmocka && which cmake && cmake -G "MinGW Makefiles" /tmp/cmocka-1.1.0 && make
else
cd cmocka && cmake /tmp/cmocka-1.1.0 && make
fi
#cmocka does not include headers in build
cp -R /tmp/cmocka-1.1.0/include/ .

View File

@ -996,13 +996,15 @@ int main(int argc, char **argv, char **envp)
printf("Error dynamically loading shared library.\n");
printf("Please check that unicorn.dll/unicorn.so is available as well as\n");
printf("any other dependent dll/so files.\n");
printf("The easiest way is to place them in the same directory as this app.\n");
return 1;
}
#endif
if (argc == 2) {
if (!strcmp(argv[1], "-32")) {
if (!strcmp(argv[1], "-16")) {
test_x86_16();
}
else if (!strcmp(argv[1], "-32")) {
test_i386();
test_i386_map_ptr();
test_i386_inout();
@ -1013,19 +1015,29 @@ int main(int argc, char **argv, char **envp)
test_i386_invalid_mem_write();
test_i386_jump_invalid();
}
if (!strcmp(argv[1], "-64")) {
else if (!strcmp(argv[1], "-64")) {
test_x86_64();
test_x86_64_syscall();
}
if (!strcmp(argv[1], "-16")) {
test_x86_16();
}
} else {
else if (!strcmp(argv[1], "-h")) {
printf("Syntax: %s <-16|-32|-64>\n", argv[0]);
}
}
else {
test_x86_16();
test_i386();
test_i386_map_ptr();
test_i386_inout();
test_i386_context_save();
test_i386_jump();
test_i386_loop();
test_i386_invalid_mem_read();
test_i386_invalid_mem_write();
test_i386_jump_invalid();
test_x86_64();
test_x86_64_syscall();
}
// dynamically free shared library
#ifdef DYNLOAD
uc_dyn_free();

View File

@ -172,9 +172,12 @@ int main(int argc, char **argv, char **envp)
if (!strcmp(argv[1], "-32")) {
test_i386();
}
} else {
else if (!strcmp(argv[1], "-h")) {
printf("Syntax: %s <-32|-64>\n", argv[0]);
}
} else {
test_i386();
}
// dynamically free shared library
#ifdef DYNLOAD

View File

@ -1,65 +1,16 @@
CFLAGS += -Wall -Werror -I../../include
LDLIBS += -L../../ $(shell pkg-config --libs glib-2.0) -lpthread -lm -lunicorn
CFLAGS += -I../../include
EXECUTE_VARS = LD_LIBRARY_PATH=../../cmocka/src:../../ DYLD_LIBRARY_PATH=../../
ifeq (MING,$(findstring MING,$(shell uname -s)))
LDFLAGS += ../../unicorn.lib $(shell pkg-config --libs glib-2.0) -lpthread -lm
else
LDFLAGS += ../../libunicorn.a $(shell pkg-config --libs glib-2.0) -lpthread -lm
endif
TESTS_SOURCE = $(wildcard *.c)
TESTS = $(TESTS_SOURCE:%.c=%)
TESTS = map_crash map_write
TESTS += sigill sigill2
TESTS += block_test
TESTS += ro_mem_test nr_mem_test
TESTS += timeout_segfault
TESTS += rep_movsb
TESTS += mem_unmap
TESTS += mem_double_unmap
TESTS += mem_protect
TESTS += mem_exec
TESTS += mips_kseg0_1
TESTS += eflags_nosync
TESTS += 00opcode_uc_crash
TESTS += eflags_noset
TESTS += mem_map_large
TESTS += invalid_read_in_cpu_tb_exec
TESTS += invalid_write_in_cpu_tb_exec_x86_64
TESTS += x86_16_segfault
TESTS += mips_invalid_read_of_size_4_when_tracing
TESTS += invalid_read_in_tb_flush_x86_64
TESTS += sparc_jump_to_zero
TESTS += mips_delay_slot_code_hook
TESTS += mem_nofree
TESTS += rw_hookstack
TESTS += threaded_emu_start
TESTS += emu_stop_in_hook_overrun
TESTS += mips_branch_likely_issue
TESTS += hook_extrainvoke
TESTS += sysenter_hook_x86
TESTS += emu_clear_errors
TESTS += mem_fuzz
TESTS += 001-bad_condition_code_0xe
TESTS += 002-qemu__fatal__unimplemented_control_register_write_0xffb___0x0
TESTS += 003-qemu__fatal__wdebug_not_implemented
TESTS += 004-segmentation_fault_1
TESTS += 005-qemu__fatal__illegal_instruction__0000___00000404
TESTS += 006-qemu__fatal__illegal_instruction__0421___00040026
TESTS += mem_64_c
TESTS += mem_map_0x100000000
.PHONY: all clean test
TESTS += memleak_x86
TESTS += memleak_arm
TESTS += memleak_arm64
TESTS += memleak_mips
TESTS += memleak_m68k
TESTS += memleak_sparc
test: $(TESTS)
all: $(TESTS)
clean:
rm -f $(TESTS)
%: %.c
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
.PHONY: all clean

View File

@ -63,7 +63,7 @@ int main() {
}
fprintf(stderr, "ok %d - uc_mem_write\n", count++);
uc_hook h1, h2;
uc_hook h1;
err = uc_hook_add(uc, &h1, UC_HOOK_BLOCK, cb_hookblock, NULL, 1, 0);
if (err != UC_ERR_OK) {

View File

@ -11,7 +11,7 @@
#define PAGE_4K (1 << 12)
#define TARGET_PAGE_MASK ~(PAGE_4K - 1)
#define TARGET_PAGE_PREPARE(addr) (((addr) + PAGE_4K - 1) & TARGET_PAGE_MASK)
#define TARGET_PAGE_ALIGN(addr) (addr - (TARGET_PAGE_PREPARE(addr) - addr) & TARGET_PAGE_MASK)
#define TARGET_PAGE_ALIGN(addr) ((addr - (TARGET_PAGE_PREPARE(addr) - addr)) & TARGET_PAGE_MASK)
static uint64_t instructions = 0;
@ -69,7 +69,6 @@ static void VM_exec()
{
uc_engine *uc;
uc_err err;
uint32_t tmp;
uc_hook trace1, trace2;
unsigned int r_eax, r_ebx, r_ecx, r_edx, r_ebp, r_esp, r_esi, r_edi, r_eip, eflags;
unsigned int tr_eax, tr_ebx, tr_ecx, tr_edx, tr_ebp, tr_esp, tr_esi, tr_edi, tr_eip, t_eflags;

View File

@ -60,7 +60,6 @@ int main(int argc, char **argv, char **envp)
{
uc_engine *uc;
uc_err err;
int ret;
uc_hook hhc;
uint32_t val;

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include <inttypes.h>
#include <unicorn/unicorn.h>
uint64_t starts[] = {0x10000000, 0x110004000ll};
@ -24,10 +25,10 @@ int main(int argc, char **argv, char **envp) {
err = uc_mem_regions(uc, &regions, &count);
if (err == UC_ERR_OK) {
for (i = 0; i < count; i++) {
fprintf(stderr, "region %d: 0x%llx-0x%llx (%d)\n", i, regions[i].begin, regions[i].end - 1, regions[i].perms);
fprintf(stderr, "region %d: 0x%"PRIx64"-0x%"PRIx64" (%d)\n", i, regions[i].begin, regions[i].end - 1, regions[i].perms);
if (regions[i].begin != starts[i]) {
err_count++;
fprintf(stderr, " ERROR: region start does not match requested start address, expected 0x%llx, found 0x%llx\n",
fprintf(stderr, " ERROR: region start does not match requested start address, expected 0x%"PRIx64", found 0x%"PRIx64"\n",
starts[i], regions[i].begin);
}
}

View File

@ -11,7 +11,6 @@
int main(int argc, char **argv, char **envp)
{
uc_engine *uc;
uc_hook trace1, trace2;
uc_err err;
// Initialize emulator in X86-32bit mode

View File

@ -84,7 +84,6 @@ void perform_fuzz_step(uc_engine *uc){
int main(int argc, char **argv, char **envp)
{
uc_engine *uc;
uc_hook trace1, trace2;
uc_err err;
if(argc<2){
printf("usage: mem_fuzz $seed\n");

View File

@ -8,7 +8,7 @@ int main() {
printf("uc_open() failed: %s\n", uc_strerror(err));
}
printf("Trying large map.\n");
if ((err = uc_mem_map(u, 0x60802000, 0x28bd211200004000, UC_PROT_ALL)) != UC_ERR_OK) {
if ((err = uc_mem_map(u, 0x60802000, (unsigned) 0x28bd211200004000, UC_PROT_ALL)) != UC_ERR_OK) {
printf("uc_mem_map() failed: %s\n", uc_strerror(err));
return -1;
}

View File

@ -55,7 +55,7 @@ static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type,
int main(int argc, char **argv, char **envp)
{
uc_engine *uc;
uc_hook trace1, trace2;
uc_hook trace1;
uc_err err;
uint32_t eax, ebx;

View File

@ -46,7 +46,7 @@ bottom:
*/
// callback for tracing instruction
static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data)
/*static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data)
{
uint32_t esp;
printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size);
@ -55,6 +55,7 @@ static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user
printf(">>> --- ESP is 0x%x\n", esp);
}
*/
// callback for tracing memory access (READ or WRITE)
static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type,
@ -95,11 +96,10 @@ static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type,
int main(int argc, char **argv, char **envp)
{
uc_engine *uc;
uc_hook trace1, trace2;
uc_hook trace1;
uc_err err;
uint8_t bytes[8];
uint32_t esp;
int result;
int map_stack = 0;
if (argc == 2 && strcmp(argv[1], "--map-stack") == 0) {

View File

@ -9,7 +9,6 @@
int main()
{
int size;
uint8_t *buf;
uc_engine *uc;
uc_err err = uc_open (UC_ARCH_X86, UC_MODE_64, &uc);