mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-03 20:15:36 +00:00
ruby: spaces & indentation
This commit is contained in:
parent
a6b570d033
commit
16f77061d9
|
@ -76,7 +76,6 @@ end
|
|||
|
||||
# callback for OUT instruction
|
||||
HOOK_OUT = Proc.new do |uc, port, size, value, user_data|
|
||||
|
||||
eip = uc.reg_read(UC_X86_REG_EIP)
|
||||
puts("--- writing to port 0x%x, size: %u, value: 0x%x, address: 0x%x" % [port, size, value, eip])
|
||||
|
||||
|
@ -138,7 +137,6 @@ def test_i386()
|
|||
print(">>> Read 2 bytes from [0x%x] =" % (ADDRESS))
|
||||
tmp.each_byte { |i| print(" 0x%x" % i) }
|
||||
|
||||
|
||||
puts
|
||||
|
||||
rescue UcError => e
|
||||
|
@ -494,18 +492,18 @@ def test_x86_16()
|
|||
end
|
||||
|
||||
|
||||
test_i386()
|
||||
puts("=" * 20)
|
||||
test_i386_loop()
|
||||
puts("=" * 20)
|
||||
test_i386_invalid_mem_read()
|
||||
puts("=" * 20)
|
||||
test_i386_invalid_mem_write()
|
||||
puts("=" * 20)
|
||||
test_i386_inout()
|
||||
puts("=" * 20)
|
||||
test_x86_64()
|
||||
puts("=" * 20)
|
||||
test_x86_64_syscall()
|
||||
puts("=" * 20)
|
||||
test_x86_16()
|
||||
test_i386()
|
||||
puts("=" * 20)
|
||||
test_i386_loop()
|
||||
puts("=" * 20)
|
||||
test_i386_invalid_mem_read()
|
||||
puts("=" * 20)
|
||||
test_i386_invalid_mem_write()
|
||||
puts("=" * 20)
|
||||
test_i386_inout()
|
||||
puts("=" * 20)
|
||||
test_x86_64()
|
||||
puts("=" * 20)
|
||||
test_x86_64_syscall()
|
||||
puts("=" * 20)
|
||||
test_x86_16()
|
||||
|
|
|
@ -28,7 +28,6 @@ VALUE UcClass = Qnil;
|
|||
VALUE UcError = Qnil;
|
||||
|
||||
|
||||
|
||||
void Init_unicorn() {
|
||||
rb_require("unicorn/unicorn_const");
|
||||
UnicornModule = rb_define_module("Unicorn");
|
||||
|
@ -100,7 +99,6 @@ VALUE m_uc_emu_stop(VALUE self){
|
|||
}
|
||||
|
||||
VALUE m_uc_reg_read(VALUE self, VALUE reg_id){
|
||||
|
||||
uc_err err;
|
||||
int32_t tmp_reg = NUM2INT(reg_id);
|
||||
int64_t reg_value = 0;
|
||||
|
@ -131,7 +129,6 @@ VALUE m_uc_reg_read(VALUE self, VALUE reg_id){
|
|||
rb_ary_store(mmr_ary, 3, UINT2NUM(mmr.flags));
|
||||
return mmr_ary;
|
||||
default:
|
||||
|
||||
err = uc_reg_read(_uc, tmp_reg, ®_value);
|
||||
if (err != UC_ERR_OK) {
|
||||
rb_raise(UcError, "%s", uc_strerror(err));
|
||||
|
@ -250,7 +247,6 @@ static void cb_hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *u
|
|||
ud = rb_ary_entry(passthrough, 1);
|
||||
rUc = rb_ary_entry(passthrough, 2);
|
||||
rb_funcall(cb, rb_intern("call"), 4, rUc, ULL2NUM(address), UINT2NUM(size), ud);
|
||||
|
||||
}
|
||||
|
||||
static void cb_hook_mem_access(uc_engine *uc, uint32_t access, uint64_t address, uint32_t size, int64_t value, void *user_data){
|
||||
|
@ -264,7 +260,6 @@ static void cb_hook_mem_access(uc_engine *uc, uint32_t access, uint64_t address,
|
|||
rUc = rb_ary_entry(passthrough, 2);
|
||||
|
||||
rb_funcall(cb, rb_intern("call"), 6, rUc, UINT2NUM(access), ULL2NUM(address), UINT2NUM(size), LL2NUM(value), ud);
|
||||
|
||||
}
|
||||
|
||||
static bool cb_hook_mem_invalid(uc_engine *uc, uint32_t access, uint64_t address, uint32_t size, int64_t value, void *user_data){
|
||||
|
@ -289,7 +284,6 @@ static uint32_t cb_hook_insn_in(uc_engine *uc, uint32_t port, int size, void *us
|
|||
ud = rb_ary_entry(passthrough, 1);
|
||||
rUc = rb_ary_entry(passthrough, 2);
|
||||
return NUM2UINT(rb_funcall(cb, rb_intern("call"), 4, rUc, UINT2NUM(port), INT2NUM(size), ud));
|
||||
|
||||
}
|
||||
|
||||
static void cb_hook_insn_out(uc_engine *uc, uint32_t port, int size, uint32_t value, void *user_data){
|
||||
|
@ -302,7 +296,6 @@ static void cb_hook_insn_out(uc_engine *uc, uint32_t port, int size, uint32_t va
|
|||
ud = rb_ary_entry(passthrough, 1);
|
||||
rUc = rb_ary_entry(passthrough, 2);
|
||||
rb_funcall(cb, rb_intern("call"), 5, rUc, UINT2NUM(port), INT2NUM(size), UINT2NUM(value), ud);
|
||||
|
||||
}
|
||||
|
||||
static void cb_hook_insn_syscall(uc_engine *uc, void *user_data){
|
||||
|
@ -315,7 +308,6 @@ static void cb_hook_insn_syscall(uc_engine *uc, void *user_data){
|
|||
ud = rb_ary_entry(passthrough, 1);
|
||||
rUc = rb_ary_entry(passthrough, 2);
|
||||
rb_funcall(cb, rb_intern("call"), 2, rUc, ud);
|
||||
|
||||
}
|
||||
|
||||
static void cb_hook_intr(uc_engine *uc, uint64_t address, uint32_t size, int64_t value, void *user_data){
|
||||
|
@ -328,10 +320,8 @@ static void cb_hook_intr(uc_engine *uc, uint64_t address, uint32_t size, int64_t
|
|||
ud = rb_ary_entry(passthrough, 1);
|
||||
rUc = rb_ary_entry(passthrough, 2);
|
||||
rb_funcall(cb, rb_intern("call"), 5, rUc, ULL2NUM(address), UINT2NUM(size), LL2NUM(value), ud);
|
||||
|
||||
}
|
||||
|
||||
|
||||
VALUE m_uc_hook_add(int argc, VALUE* argv, VALUE self){
|
||||
VALUE hook_type;
|
||||
VALUE callback;
|
||||
|
@ -351,12 +341,10 @@ VALUE m_uc_hook_add(int argc, VALUE* argv, VALUE self){
|
|||
if (NIL_P(arg1))
|
||||
arg1 = INT2NUM(0);
|
||||
|
||||
|
||||
VALUE passthrough;
|
||||
uc_hook trace;
|
||||
uc_err err;
|
||||
|
||||
|
||||
if (rb_class_of(callback) != rb_cProc)
|
||||
rb_raise(UcError, "Expected Proc callback");
|
||||
|
||||
|
@ -367,7 +355,6 @@ VALUE m_uc_hook_add(int argc, VALUE* argv, VALUE self){
|
|||
|
||||
uint32_t htype = NUM2UINT(hook_type);
|
||||
if(htype == UC_HOOK_INSN){
|
||||
|
||||
switch(NUM2INT(arg1)){
|
||||
case UC_X86_INS_IN:
|
||||
err = uc_hook_add(_uc, &trace, htype, cb_hook_insn_in,(void *)passthrough, NUM2ULL(begin), NUM2ULL(end), NUM2INT(arg1));
|
||||
|
@ -386,7 +373,6 @@ VALUE m_uc_hook_add(int argc, VALUE* argv, VALUE self){
|
|||
err = uc_hook_add(_uc, &trace, htype, cb_hook_intr,(void *)passthrough, NUM2ULL(begin), NUM2ULL(end));
|
||||
}
|
||||
else if(htype == UC_HOOK_CODE || htype == UC_HOOK_BLOCK){
|
||||
|
||||
err = uc_hook_add(_uc, &trace, htype, cb_hook_code,(void *)passthrough, NUM2ULL(begin), NUM2ULL(end));
|
||||
}
|
||||
else if (htype & UC_HOOK_MEM_READ_UNMAPPED
|
||||
|
@ -407,8 +393,6 @@ VALUE m_uc_hook_add(int argc, VALUE* argv, VALUE self){
|
|||
err = uc_hook_add(_uc, &trace, htype, cb_hook_mem_access,(void *)passthrough, NUM2ULL(begin), NUM2ULL(end));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (err != UC_ERR_OK) {
|
||||
rb_raise(UcError, "%s", uc_strerror(err));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue