disasm 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@
5
5
 
6
6
  static VALUE t_init(VALUE self)
7
7
  {
8
- return INT2FIX(x86_init(opt_none, NULL, NULL));
8
+ return INT2NUM(x86_init(opt_none, NULL, NULL));
9
9
  }
10
10
 
11
11
  static VALUE t_disassemble2yield(
@@ -24,13 +24,13 @@ static VALUE t_disassemble2yield(
24
24
 
25
25
  char*buf = RSTRING_PTR(_data);
26
26
  unsigned int bufsize = RSTRING_LEN(_data);
27
- uint32_t rva = FIX2INT(_rva);
28
- unsigned int offset = FIX2INT(_offset);
29
- int syntax = FIX2INT(_syntax);
27
+ unsigned int rva = NUM2UINT(_rva);
28
+ unsigned int offset = NUM2UINT(_offset);
29
+ int syntax = NUM2INT(_syntax);
30
30
  int n_ok = 0; // number of successfully disassembled instructions
31
31
  int allow_invalid = (_allow_invalid == Qtrue);
32
32
 
33
- if(!buf || !bufsize) return INT2FIX(0);
33
+ if(!buf || !bufsize) return INT2NUM(0);
34
34
 
35
35
  switch(syntax){
36
36
  case native_syntax:
@@ -47,17 +47,17 @@ static VALUE t_disassemble2yield(
47
47
 
48
48
  while( offset < bufsize ){
49
49
  size = x86_disasm(buf, bufsize, rva, offset, &insn);
50
- if( size ){
51
- // success
50
+ if( size || allow_invalid ){
52
51
  line_len = x86_format_insn(&insn, line, LINE_SIZE, syntax);
53
- rb_yield_values(2, rb_str_new(line, line_len), INT2FIX(offset+rva));
54
- offset += size;
55
- n_ok++;
56
- } else if( allow_invalid ) {
57
- // invalid instruction : allowed
58
- line_len = x86_format_insn(&insn, line, LINE_SIZE, syntax);
59
- rb_yield_values(2, rb_str_new(line, line_len), INT2FIX(offset+rva));
60
- offset += 1;
52
+ rb_yield_values(2, rb_str_new(line, line_len), UINT2NUM(offset+rva));
53
+ if( size ){
54
+ // success
55
+ offset += size;
56
+ n_ok++;
57
+ } else {
58
+ // invalid instruction : allowed
59
+ offset += 1;
60
+ }
61
61
  } else {
62
62
  // invalid instruction : raise exception
63
63
  char err_buf[1024];
@@ -68,7 +68,7 @@ static VALUE t_disassemble2yield(
68
68
  }
69
69
  }
70
70
 
71
- return INT2FIX(n_ok);
71
+ return INT2NUM(n_ok);
72
72
  }
73
73
 
74
74
  VALUE mDisasm;
@@ -1,3 +1,3 @@
1
1
  module Disasm
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: