diff --git a/bindings/const_generator.py b/bindings/const_generator.py index c224d082..73f67937 100644 --- a/bindings/const_generator.py +++ b/bindings/const_generator.py @@ -25,10 +25,10 @@ template = { 'comment_close': '', }, 'ruby': { - 'header': "# For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT [%s_const.rb]\n\nmodule Unicorn\n", + 'header': "# For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT [%s_const.rb]\n\nmodule UnicornEngine\n", 'footer': "end", 'line_format': '\tUC_%s = %s\n', - 'out_file': './ruby/unicorn_gem/lib/unicorn/%s_const.rb', + 'out_file': './ruby/unicorn_gem/lib/unicorn_engine/%s_const.rb', # prefixes for constant filenames of all archs - case sensitive 'arm.h': 'arm', 'arm64.h': 'arm64', diff --git a/bindings/ruby/Makefile b/bindings/ruby/Makefile index 2eb376eb..679a1835 100644 --- a/bindings/ruby/Makefile +++ b/bindings/ruby/Makefile @@ -5,7 +5,7 @@ # 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-1.0.0.gem + cd unicorn_gem && gem install --local pkg/unicorn_engine-1.0.0.gem gen_const: cd .. && python const_generator.py ruby diff --git a/bindings/ruby/sample_arm.rb b/bindings/ruby/sample_arm.rb index b948b617..f9f8c1e6 100644 --- a/bindings/ruby/sample_arm.rb +++ b/bindings/ruby/sample_arm.rb @@ -1,9 +1,9 @@ #!/usr/bin/env ruby -require 'unicorn' -require 'unicorn/arm_const' +require 'unicorn_engine' +require 'unicorn_engine/arm_const' -include Unicorn +include UnicornEngine # code to be emulated ARM_CODE = "\x37\x00\xa0\xe3\x03\x10\x42\xe0" # mov r0, #0x37; sub r1, r2, r3 diff --git a/bindings/ruby/sample_arm64.rb b/bindings/ruby/sample_arm64.rb index 45b0c9c6..37d95115 100644 --- a/bindings/ruby/sample_arm64.rb +++ b/bindings/ruby/sample_arm64.rb @@ -1,10 +1,10 @@ #!/usr/bin/env ruby # Sample code for ARM64 of Unicorn. Nguyen Anh Quynh # Ruby sample ported by Sascha Schirra -require 'unicorn' -require 'unicorn/arm64_const' +require 'unicorn_engine' +require 'unicorn_engine/arm64_const' -include Unicorn +include UnicornEngine # code to be emulated ARM64_CODE = "\xab\x01\x0f\x8b" #add x11, x13, x15 diff --git a/bindings/ruby/sample_m68k.rb b/bindings/ruby/sample_m68k.rb index 1acff39f..fc2522cf 100644 --- a/bindings/ruby/sample_m68k.rb +++ b/bindings/ruby/sample_m68k.rb @@ -2,10 +2,10 @@ # Sample code for ARM of Unicorn. Nguyen Anh Quynh # Ruby sample ported by Sascha Schirra -require 'unicorn' -require 'unicorn/m68k_const' +require 'unicorn_engine' +require 'unicorn_engine/m68k_const' -include Unicorn +include UnicornEngine # code to be emulated M68K_CODE = "\x76\xed" # movq #-19, %d3 diff --git a/bindings/ruby/sample_mips.rb b/bindings/ruby/sample_mips.rb index ec30e87d..c13a9cf8 100644 --- a/bindings/ruby/sample_mips.rb +++ b/bindings/ruby/sample_mips.rb @@ -1,10 +1,10 @@ #!/usr/bin/env ruby # Sample code for MIPS of Unicorn. Nguyen Anh Quynh # Ruby sample ported by Sascha Schirra -require 'unicorn' -require 'unicorn/mips_const' +require 'unicorn_engine' +require 'unicorn_engine/mips_const' -include Unicorn +include UnicornEngine # code to be emulated MIPS_CODE_EB = "\x34\x21\x34\x56" # ori $at, $at, 0x3456; diff --git a/bindings/ruby/sample_sparc.rb b/bindings/ruby/sample_sparc.rb index 052be189..a4baf18d 100644 --- a/bindings/ruby/sample_sparc.rb +++ b/bindings/ruby/sample_sparc.rb @@ -1,10 +1,10 @@ #!/usr/bin/env ruby # Sample code for SPARC of Unicorn. Nguyen Anh Quynh # Ruby sample ported by Sascha Schirra -require 'unicorn' -require 'unicorn/sparc_const' +require 'unicorn_engine' +require 'unicorn_engine/sparc_const' -include Unicorn +include UnicornEngine # code to be emulated SPARC_CODE = "\x86\x00\x40\x02" # add %g1, %g2, %g3; diff --git a/bindings/ruby/sample_x86.rb b/bindings/ruby/sample_x86.rb index 9a9740e6..00c480ac 100644 --- a/bindings/ruby/sample_x86.rb +++ b/bindings/ruby/sample_x86.rb @@ -1,8 +1,8 @@ #!/usr/bin/env ruby -require 'unicorn' -require 'unicorn/x86_const' +require 'unicorn_engine' +require 'unicorn_engine/x86_const' -include Unicorn +include UnicornEngine X86_CODE32 = "\x41\x4a" # INC ecx; DEC edx X86_CODE32_LOOP = "\x41\x4a\xeb\xfe" # INC ecx; DEC edx; JMP self-loop diff --git a/bindings/ruby/sample_x86_gdt.rb b/bindings/ruby/sample_x86_gdt.rb index cd064452..7aa6021a 100644 --- a/bindings/ruby/sample_x86_gdt.rb +++ b/bindings/ruby/sample_x86_gdt.rb @@ -1,8 +1,8 @@ #!/usr/bin/env ruby -require 'unicorn' -require 'unicorn/x86_const' +require 'unicorn_engine' +require 'unicorn_engine/x86_const' -include Unicorn +include UnicornEngine F_GRANULARITY = 0x8 F_PROT_32 = 0x4 diff --git a/bindings/ruby/test_hook_gc.rb b/bindings/ruby/test_hook_gc.rb index 670809ef..53593b6a 100644 --- a/bindings/ruby/test_hook_gc.rb +++ b/bindings/ruby/test_hook_gc.rb @@ -1,9 +1,9 @@ #!/usr/bin/env ruby -require 'unicorn' -require 'unicorn/x86_const' +require 'unicorn_engine' +require 'unicorn_engine/x86_const' require 'weakref' -include Unicorn +include UnicornEngine X86_CODE32 = "\x41" # INC ecx; DEC edx diff --git a/bindings/ruby/unicorn_gem/ext/extconf.rb b/bindings/ruby/unicorn_gem/ext/extconf.rb index cdbfc837..d821f3d9 100644 --- a/bindings/ruby/unicorn_gem/ext/extconf.rb +++ b/bindings/ruby/unicorn_gem/ext/extconf.rb @@ -1,8 +1,8 @@ require 'mkmf' -extension_name = 'unicorn' +extension_name = 'unicorn_engine' dir_config(extension_name) have_library('unicorn') -create_makefile(extension_name) \ No newline at end of file +create_makefile(extension_name) diff --git a/bindings/ruby/unicorn_gem/ext/types.h b/bindings/ruby/unicorn_gem/ext/types.h index 2a183ceb..15da7c86 100644 --- a/bindings/ruby/unicorn_gem/ext/types.h +++ b/bindings/ruby/unicorn_gem/ext/types.h @@ -23,3 +23,11 @@ typedef struct uc_x86_float80 { uint64_t mantissa; uint16_t exponent; } uc_x86_float80; + + +struct hook { + uc_hook trace; + VALUE cb; + VALUE ud; + VALUE rUc; +}; diff --git a/bindings/ruby/unicorn_gem/ext/unicorn.c b/bindings/ruby/unicorn_gem/ext/unicorn.c index db1ae81e..bb7363f8 100644 --- a/bindings/ruby/unicorn_gem/ext/unicorn.c +++ b/bindings/ruby/unicorn_gem/ext/unicorn.c @@ -30,16 +30,10 @@ VALUE UcError = Qnil; VALUE SavedContext = Qnil; VALUE Hook = Qnil; -struct hook { - uc_hook trace; - VALUE cb; - VALUE ud; - VALUE rUc; -}; -void Init_unicorn() { - rb_require("unicorn/unicorn_const"); - UnicornModule = rb_define_module("Unicorn"); +void Init_unicorn_engine() { + rb_require("unicorn_engine/unicorn_const"); + UnicornModule = rb_define_module("UnicornEngine"); UcError = rb_define_class_under(UnicornModule, "UcError", rb_eStandardError); SavedContext = rb_define_class_under(UnicornModule, "SavedContext", rb_cObject); Hook = rb_define_class_under(UnicornModule, "Hook", rb_cObject); diff --git a/bindings/ruby/unicorn_gem/lib/unicorn/arm64_const.rb b/bindings/ruby/unicorn_gem/lib/unicorn_engine/arm64_const.rb similarity index 99% rename from bindings/ruby/unicorn_gem/lib/unicorn/arm64_const.rb rename to bindings/ruby/unicorn_gem/lib/unicorn_engine/arm64_const.rb index 424de052..db6c5262 100644 --- a/bindings/ruby/unicorn_gem/lib/unicorn/arm64_const.rb +++ b/bindings/ruby/unicorn_gem/lib/unicorn_engine/arm64_const.rb @@ -1,6 +1,6 @@ # For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT [arm64_const.rb] -module Unicorn +module UnicornEngine # ARM64 registers diff --git a/bindings/ruby/unicorn_gem/lib/unicorn/arm_const.rb b/bindings/ruby/unicorn_gem/lib/unicorn_engine/arm_const.rb similarity index 99% rename from bindings/ruby/unicorn_gem/lib/unicorn/arm_const.rb rename to bindings/ruby/unicorn_gem/lib/unicorn_engine/arm_const.rb index 50e7852e..c0edf24c 100644 --- a/bindings/ruby/unicorn_gem/lib/unicorn/arm_const.rb +++ b/bindings/ruby/unicorn_gem/lib/unicorn_engine/arm_const.rb @@ -1,6 +1,6 @@ # For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT [arm_const.rb] -module Unicorn +module UnicornEngine # ARM registers diff --git a/bindings/ruby/unicorn_gem/lib/unicorn/m68k_const.rb b/bindings/ruby/unicorn_gem/lib/unicorn_engine/m68k_const.rb similarity index 96% rename from bindings/ruby/unicorn_gem/lib/unicorn/m68k_const.rb rename to bindings/ruby/unicorn_gem/lib/unicorn_engine/m68k_const.rb index 2c53636d..dc641535 100644 --- a/bindings/ruby/unicorn_gem/lib/unicorn/m68k_const.rb +++ b/bindings/ruby/unicorn_gem/lib/unicorn_engine/m68k_const.rb @@ -1,6 +1,6 @@ # For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT [m68k_const.rb] -module Unicorn +module UnicornEngine # M68K registers diff --git a/bindings/ruby/unicorn_gem/lib/unicorn/mips_const.rb b/bindings/ruby/unicorn_gem/lib/unicorn_engine/mips_const.rb similarity index 99% rename from bindings/ruby/unicorn_gem/lib/unicorn/mips_const.rb rename to bindings/ruby/unicorn_gem/lib/unicorn_engine/mips_const.rb index d92e94e5..2c2c727f 100644 --- a/bindings/ruby/unicorn_gem/lib/unicorn/mips_const.rb +++ b/bindings/ruby/unicorn_gem/lib/unicorn_engine/mips_const.rb @@ -1,6 +1,6 @@ # For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT [mips_const.rb] -module Unicorn +module UnicornEngine # MIPS registers diff --git a/bindings/ruby/unicorn_gem/lib/unicorn/sparc_const.rb b/bindings/ruby/unicorn_gem/lib/unicorn_engine/sparc_const.rb similarity index 99% rename from bindings/ruby/unicorn_gem/lib/unicorn/sparc_const.rb rename to bindings/ruby/unicorn_gem/lib/unicorn_engine/sparc_const.rb index 85d9eef1..b5c42470 100644 --- a/bindings/ruby/unicorn_gem/lib/unicorn/sparc_const.rb +++ b/bindings/ruby/unicorn_gem/lib/unicorn_engine/sparc_const.rb @@ -1,6 +1,6 @@ # For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT [sparc_const.rb] -module Unicorn +module UnicornEngine # SPARC registers diff --git a/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb b/bindings/ruby/unicorn_gem/lib/unicorn_engine/unicorn_const.rb similarity index 99% rename from bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb rename to bindings/ruby/unicorn_gem/lib/unicorn_engine/unicorn_const.rb index e8f37908..e2ad8c89 100644 --- a/bindings/ruby/unicorn_gem/lib/unicorn/unicorn_const.rb +++ b/bindings/ruby/unicorn_gem/lib/unicorn_engine/unicorn_const.rb @@ -1,6 +1,6 @@ # For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT [unicorn_const.rb] -module Unicorn +module UnicornEngine UC_API_MAJOR = 1 UC_API_MINOR = 0 diff --git a/bindings/ruby/unicorn_gem/lib/unicorn/version.rb b/bindings/ruby/unicorn_gem/lib/unicorn_engine/version.rb similarity index 100% rename from bindings/ruby/unicorn_gem/lib/unicorn/version.rb rename to bindings/ruby/unicorn_gem/lib/unicorn_engine/version.rb diff --git a/bindings/ruby/unicorn_gem/lib/unicorn/x86_const.rb b/bindings/ruby/unicorn_gem/lib/unicorn_engine/x86_const.rb similarity index 99% rename from bindings/ruby/unicorn_gem/lib/unicorn/x86_const.rb rename to bindings/ruby/unicorn_gem/lib/unicorn_engine/x86_const.rb index f85ae21a..5d7fd63a 100644 --- a/bindings/ruby/unicorn_gem/lib/unicorn/x86_const.rb +++ b/bindings/ruby/unicorn_gem/lib/unicorn_engine/x86_const.rb @@ -1,6 +1,6 @@ # For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT [x86_const.rb] -module Unicorn +module UnicornEngine # X86 registers diff --git a/bindings/ruby/unicorn_gem/unicorn.gemspec b/bindings/ruby/unicorn_gem/unicorn.gemspec index e959ed6f..91d77fa7 100644 --- a/bindings/ruby/unicorn_gem/unicorn.gemspec +++ b/bindings/ruby/unicorn_gem/unicorn.gemspec @@ -1,10 +1,10 @@ # coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'unicorn/version' +require 'unicorn_engine/version' Gem::Specification.new do |spec| - spec.name = "unicorn" + spec.name = "unicorn_engine" spec.version = Unicorn::VERSION spec.authors = ["Sascha Schirra"] spec.email = ["sashs@scoding.de"] @@ -13,7 +13,7 @@ Gem::Specification.new do |spec| spec.description = %q{Ruby binding for Unicorn-Engine } spec.homepage = "https://unicorn-engine.org" - spec.files = Dir["lib/unicorn/*.rb"] + Dir["ext/unicorn.c"] + Dir["ext/unicorn.h"] + Dir["ext/types.h"] + Dir["ext/extconf.rb"] + spec.files = Dir["lib/unicorn_engine/*.rb"] + Dir["ext/unicorn.c"] + Dir["ext/unicorn.h"] + Dir["ext/types.h"] + Dir["ext/extconf.rb"] spec.require_paths = ["lib","ext"] spec.extensions = ["ext/extconf.rb"] spec.add_development_dependency "bundler", "~> 1.11"