disasm 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/disasm_ext/disasm_ext.c +16 -16
- data/lib/disasm/version.rb +1 -1
- metadata +1 -1
data/ext/disasm_ext/disasm_ext.c
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
static VALUE t_init(VALUE self)
|
7
7
|
{
|
8
|
-
return
|
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
|
-
|
28
|
-
unsigned int offset =
|
29
|
-
int 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
|
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),
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
71
|
+
return INT2NUM(n_ok);
|
72
72
|
}
|
73
73
|
|
74
74
|
VALUE mDisasm;
|
data/lib/disasm/version.rb
CHANGED