crabstone 4.0.3 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +20 -0
- data/README.md +25 -8
- data/lib/crabstone/arch/3/constants.rb +86 -0
- data/lib/crabstone/arch/4/constants.rb +116 -0
- data/lib/crabstone/arch/5/arm.rb +111 -0
- data/lib/crabstone/arch/5/arm64.rb +131 -0
- data/lib/crabstone/arch/5/arm64_const.rb +3015 -0
- data/lib/crabstone/arch/5/arm_const.rb +840 -0
- data/lib/crabstone/arch/5/bpf.rb +81 -0
- data/lib/crabstone/arch/5/bpf_const.rb +124 -0
- data/lib/crabstone/arch/5/constants.rb +155 -0
- data/lib/crabstone/arch/5/evm.rb +20 -0
- data/lib/crabstone/arch/5/evm_const.rb +161 -0
- data/lib/crabstone/arch/5/m680x.rb +106 -0
- data/lib/crabstone/arch/5/m680x_const.rb +426 -0
- data/lib/crabstone/arch/5/m68k.rb +129 -0
- data/lib/crabstone/arch/5/m68k_const.rb +496 -0
- data/lib/crabstone/arch/5/mips.rb +57 -0
- data/lib/crabstone/arch/5/mips_const.rb +869 -0
- data/lib/crabstone/arch/5/mos65xx.rb +52 -0
- data/lib/crabstone/arch/5/mos65xx_const.rb +162 -0
- data/lib/crabstone/arch/5/ppc.rb +69 -0
- data/lib/crabstone/arch/5/ppc_const.rb +2024 -0
- data/lib/crabstone/arch/5/riscv.rb +58 -0
- data/lib/crabstone/arch/5/riscv_const.rb +455 -0
- data/lib/crabstone/arch/5/sh.rb +72 -0
- data/lib/crabstone/arch/5/sh_const.rb +376 -0
- data/lib/crabstone/arch/5/sparc.rb +60 -0
- data/lib/crabstone/arch/5/sparc_const.rb +439 -0
- data/lib/crabstone/arch/5/sysz.rb +60 -0
- data/lib/crabstone/arch/5/sysz_const.rb +2532 -0
- data/lib/crabstone/arch/5/tms320c64x.rb +87 -0
- data/lib/crabstone/arch/5/tms320c64x_const.rb +287 -0
- data/lib/crabstone/arch/5/tricore.rb +59 -0
- data/lib/crabstone/arch/5/tricore_const.rb +488 -0
- data/lib/crabstone/arch/5/wasm.rb +81 -0
- data/lib/crabstone/arch/5/wasm_const.rb +201 -0
- data/lib/crabstone/arch/5/x86.rb +98 -0
- data/lib/crabstone/arch/5/x86_const.rb +1999 -0
- data/lib/crabstone/arch/5/xcore.rb +59 -0
- data/lib/crabstone/arch/5/xcore_const.rb +171 -0
- data/lib/crabstone/arch/extension.rb +2 -1
- data/lib/crabstone/arch/register.rb +1 -1
- data/lib/crabstone/arch.rb +6 -0
- data/lib/crabstone/binding/5/detail.rb +47 -0
- data/lib/crabstone/binding/5/instruction.rb +23 -0
- data/lib/crabstone/binding.rb +4 -5
- data/lib/crabstone/constants.rb +2 -107
- data/lib/crabstone/cs_version.rb +2 -3
- data/lib/crabstone/disassembler.rb +2 -3
- data/lib/crabstone/instruction.rb +0 -1
- data/lib/crabstone/version.rb +1 -1
- metadata +51 -4
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# THIS FILE WAS AUTO-GENERATED -- DO NOT EDIT!
|
4
|
+
|
5
|
+
require 'ffi'
|
6
|
+
|
7
|
+
require 'crabstone/arch/extension'
|
8
|
+
require_relative 'xcore_const'
|
9
|
+
|
10
|
+
module Crabstone
|
11
|
+
module XCore
|
12
|
+
class OperandMemory < FFI::Struct
|
13
|
+
layout(
|
14
|
+
:base, :uint8,
|
15
|
+
:index, :uint8,
|
16
|
+
:disp, :int,
|
17
|
+
:direct, :int
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
class OperandValue < FFI::Union
|
22
|
+
layout(
|
23
|
+
:reg, :uint,
|
24
|
+
:imm, :int,
|
25
|
+
:mem, OperandMemory
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
class Operand < FFI::Struct
|
30
|
+
layout(
|
31
|
+
:type, :uint,
|
32
|
+
:value, OperandValue
|
33
|
+
)
|
34
|
+
|
35
|
+
include Crabstone::Extension::Operand
|
36
|
+
|
37
|
+
def reg?
|
38
|
+
self[:type] == OP_REG
|
39
|
+
end
|
40
|
+
|
41
|
+
def imm?
|
42
|
+
self[:type] == OP_IMM
|
43
|
+
end
|
44
|
+
|
45
|
+
def mem?
|
46
|
+
self[:type] == OP_MEM
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class Instruction < FFI::Struct
|
51
|
+
layout(
|
52
|
+
:op_count, :uint8,
|
53
|
+
:operands, [Operand, 8]
|
54
|
+
)
|
55
|
+
|
56
|
+
include Crabstone::Extension::Instruction
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# THIS FILE WAS AUTO-GENERATED -- DO NOT EDIT!
|
4
|
+
|
5
|
+
require 'crabstone/arch/register'
|
6
|
+
|
7
|
+
module Crabstone
|
8
|
+
module XCore
|
9
|
+
OP_INVALID = 0
|
10
|
+
OP_REG = 1
|
11
|
+
OP_IMM = 2
|
12
|
+
OP_MEM = 3
|
13
|
+
|
14
|
+
REG_INVALID = 0
|
15
|
+
REG_CP = 1
|
16
|
+
REG_DP = 2
|
17
|
+
REG_LR = 3
|
18
|
+
REG_SP = 4
|
19
|
+
REG_R0 = 5
|
20
|
+
REG_R1 = 6
|
21
|
+
REG_R2 = 7
|
22
|
+
REG_R3 = 8
|
23
|
+
REG_R4 = 9
|
24
|
+
REG_R5 = 10
|
25
|
+
REG_R6 = 11
|
26
|
+
REG_R7 = 12
|
27
|
+
REG_R8 = 13
|
28
|
+
REG_R9 = 14
|
29
|
+
REG_R10 = 15
|
30
|
+
REG_R11 = 16
|
31
|
+
REG_PC = 17
|
32
|
+
REG_SCP = 18
|
33
|
+
REG_SSR = 19
|
34
|
+
REG_ET = 20
|
35
|
+
REG_ED = 21
|
36
|
+
REG_SED = 22
|
37
|
+
REG_KEP = 23
|
38
|
+
REG_KSP = 24
|
39
|
+
REG_ID = 25
|
40
|
+
REG_ENDING = 26
|
41
|
+
|
42
|
+
INS_INVALID = 0
|
43
|
+
INS_ADD = 1
|
44
|
+
INS_ANDNOT = 2
|
45
|
+
INS_AND = 3
|
46
|
+
INS_ASHR = 4
|
47
|
+
INS_BAU = 5
|
48
|
+
INS_BITREV = 6
|
49
|
+
INS_BLA = 7
|
50
|
+
INS_BLAT = 8
|
51
|
+
INS_BL = 9
|
52
|
+
INS_BF = 10
|
53
|
+
INS_BT = 11
|
54
|
+
INS_BU = 12
|
55
|
+
INS_BRU = 13
|
56
|
+
INS_BYTEREV = 14
|
57
|
+
INS_CHKCT = 15
|
58
|
+
INS_CLRE = 16
|
59
|
+
INS_CLRPT = 17
|
60
|
+
INS_CLRSR = 18
|
61
|
+
INS_CLZ = 19
|
62
|
+
INS_CRC8 = 20
|
63
|
+
INS_CRC32 = 21
|
64
|
+
INS_DCALL = 22
|
65
|
+
INS_DENTSP = 23
|
66
|
+
INS_DGETREG = 24
|
67
|
+
INS_DIVS = 25
|
68
|
+
INS_DIVU = 26
|
69
|
+
INS_DRESTSP = 27
|
70
|
+
INS_DRET = 28
|
71
|
+
INS_ECALLF = 29
|
72
|
+
INS_ECALLT = 30
|
73
|
+
INS_EDU = 31
|
74
|
+
INS_EEF = 32
|
75
|
+
INS_EET = 33
|
76
|
+
INS_EEU = 34
|
77
|
+
INS_ENDIN = 35
|
78
|
+
INS_ENTSP = 36
|
79
|
+
INS_EQ = 37
|
80
|
+
INS_EXTDP = 38
|
81
|
+
INS_EXTSP = 39
|
82
|
+
INS_FREER = 40
|
83
|
+
INS_FREET = 41
|
84
|
+
INS_GETD = 42
|
85
|
+
INS_GET = 43
|
86
|
+
INS_GETN = 44
|
87
|
+
INS_GETR = 45
|
88
|
+
INS_GETSR = 46
|
89
|
+
INS_GETST = 47
|
90
|
+
INS_GETTS = 48
|
91
|
+
INS_INCT = 49
|
92
|
+
INS_INIT = 50
|
93
|
+
INS_INPW = 51
|
94
|
+
INS_INSHR = 52
|
95
|
+
INS_INT = 53
|
96
|
+
INS_IN = 54
|
97
|
+
INS_KCALL = 55
|
98
|
+
INS_KENTSP = 56
|
99
|
+
INS_KRESTSP = 57
|
100
|
+
INS_KRET = 58
|
101
|
+
INS_LADD = 59
|
102
|
+
INS_LD16S = 60
|
103
|
+
INS_LD8U = 61
|
104
|
+
INS_LDA16 = 62
|
105
|
+
INS_LDAP = 63
|
106
|
+
INS_LDAW = 64
|
107
|
+
INS_LDC = 65
|
108
|
+
INS_LDW = 66
|
109
|
+
INS_LDIVU = 67
|
110
|
+
INS_LMUL = 68
|
111
|
+
INS_LSS = 69
|
112
|
+
INS_LSUB = 70
|
113
|
+
INS_LSU = 71
|
114
|
+
INS_MACCS = 72
|
115
|
+
INS_MACCU = 73
|
116
|
+
INS_MJOIN = 74
|
117
|
+
INS_MKMSK = 75
|
118
|
+
INS_MSYNC = 76
|
119
|
+
INS_MUL = 77
|
120
|
+
INS_NEG = 78
|
121
|
+
INS_NOT = 79
|
122
|
+
INS_OR = 80
|
123
|
+
INS_OUTCT = 81
|
124
|
+
INS_OUTPW = 82
|
125
|
+
INS_OUTSHR = 83
|
126
|
+
INS_OUTT = 84
|
127
|
+
INS_OUT = 85
|
128
|
+
INS_PEEK = 86
|
129
|
+
INS_REMS = 87
|
130
|
+
INS_REMU = 88
|
131
|
+
INS_RETSP = 89
|
132
|
+
INS_SETCLK = 90
|
133
|
+
INS_SET = 91
|
134
|
+
INS_SETC = 92
|
135
|
+
INS_SETD = 93
|
136
|
+
INS_SETEV = 94
|
137
|
+
INS_SETN = 95
|
138
|
+
INS_SETPSC = 96
|
139
|
+
INS_SETPT = 97
|
140
|
+
INS_SETRDY = 98
|
141
|
+
INS_SETSR = 99
|
142
|
+
INS_SETTW = 100
|
143
|
+
INS_SETV = 101
|
144
|
+
INS_SEXT = 102
|
145
|
+
INS_SHL = 103
|
146
|
+
INS_SHR = 104
|
147
|
+
INS_SSYNC = 105
|
148
|
+
INS_ST16 = 106
|
149
|
+
INS_ST8 = 107
|
150
|
+
INS_STW = 108
|
151
|
+
INS_SUB = 109
|
152
|
+
INS_SYNCR = 110
|
153
|
+
INS_TESTCT = 111
|
154
|
+
INS_TESTLCL = 112
|
155
|
+
INS_TESTWCT = 113
|
156
|
+
INS_TSETMR = 114
|
157
|
+
INS_START = 115
|
158
|
+
INS_WAITEF = 116
|
159
|
+
INS_WAITET = 117
|
160
|
+
INS_WAITEU = 118
|
161
|
+
INS_XOR = 119
|
162
|
+
INS_ZEXT = 120
|
163
|
+
INS_ENDING = 121
|
164
|
+
|
165
|
+
GRP_INVALID = 0
|
166
|
+
GRP_JUMP = 1
|
167
|
+
GRP_ENDING = 2
|
168
|
+
|
169
|
+
extend Register
|
170
|
+
end
|
171
|
+
end
|
@@ -19,7 +19,7 @@ module Crabstone
|
|
19
19
|
return @dict if defined?(@dict)
|
20
20
|
|
21
21
|
keys = constants.select { |k| k.to_s.start_with?('REG_') }
|
22
|
-
@dict = keys.
|
22
|
+
@dict = keys.to_h { |k| [k.to_s[4..], const_get(k)] }.freeze
|
23
23
|
end
|
24
24
|
|
25
25
|
def value?(val)
|
data/lib/crabstone/arch.rb
CHANGED
@@ -31,6 +31,12 @@ module Crabstone
|
|
31
31
|
when ARCH_TMS320C64X then TMS320C64X
|
32
32
|
when ARCH_M680X then M680X
|
33
33
|
when ARCH_EVM then EVM
|
34
|
+
when ARCH_MOS65XX then MOS65XX
|
35
|
+
when ARCH_WASM then WASM
|
36
|
+
when ARCH_BPF then BPF
|
37
|
+
when ARCH_RISCV then RISCV
|
38
|
+
when ARCH_SH then SH
|
39
|
+
when ARCH_TRICORE then TRICORE
|
34
40
|
end
|
35
41
|
end
|
36
42
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# THIS FILE WAS AUTO-GENERATED -- DO NOT EDIT!
|
4
|
+
|
5
|
+
require 'ffi'
|
6
|
+
|
7
|
+
require 'crabstone/arch'
|
8
|
+
|
9
|
+
module Crabstone
|
10
|
+
module Binding
|
11
|
+
class Architecture < FFI::Union
|
12
|
+
layout(
|
13
|
+
:arm, ARM::Instruction,
|
14
|
+
:arm64, ARM64::Instruction,
|
15
|
+
:bpf, BPF::Instruction,
|
16
|
+
:evm, EVM::Instruction,
|
17
|
+
:m680x, M680X::Instruction,
|
18
|
+
:m68k, M68K::Instruction,
|
19
|
+
:mips, MIPS::Instruction,
|
20
|
+
:mos65xx, MOS65XX::Instruction,
|
21
|
+
:ppc, PPC::Instruction,
|
22
|
+
:riscv, RISCV::Instruction,
|
23
|
+
:sh, SH::Instruction,
|
24
|
+
:sparc, Sparc::Instruction,
|
25
|
+
:sysz, SysZ::Instruction,
|
26
|
+
:tms320c64x, TMS320C64X::Instruction,
|
27
|
+
:tricore, TRICORE::Instruction,
|
28
|
+
:wasm, WASM::Instruction,
|
29
|
+
:x86, X86::Instruction,
|
30
|
+
:xcore, XCore::Instruction
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
class Detail < FFI::Struct
|
35
|
+
layout(
|
36
|
+
:regs_read, [:uint16, 20],
|
37
|
+
:regs_read_count, :uint8,
|
38
|
+
:regs_write, [:uint16, 20],
|
39
|
+
:regs_write_count, :uint8,
|
40
|
+
:groups, [:uint8, 8],
|
41
|
+
:groups_count, :uint8,
|
42
|
+
:writeback, :bool,
|
43
|
+
:arch, Architecture
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# THIS FILE WAS AUTO-GENERATED -- DO NOT EDIT!
|
4
|
+
|
5
|
+
require 'ffi'
|
6
|
+
|
7
|
+
require_relative 'detail'
|
8
|
+
|
9
|
+
module Crabstone
|
10
|
+
module Binding
|
11
|
+
class Instruction < FFI::ManagedStruct
|
12
|
+
layout(
|
13
|
+
:id, :uint32,
|
14
|
+
:address, :uint64,
|
15
|
+
:size, :uint16,
|
16
|
+
:bytes, [:uint8, 24],
|
17
|
+
:mnemonic, [:char, 32],
|
18
|
+
:op_str, [:char, 160],
|
19
|
+
:detail, Detail.by_ref
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/crabstone/binding.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'crabstone/constants'
|
4
3
|
require 'crabstone/binding/structs'
|
4
|
+
require 'crabstone/constants'
|
5
5
|
|
6
6
|
module Crabstone
|
7
7
|
module Binding
|
8
8
|
class Instruction < FFI::ManagedStruct
|
9
9
|
def self.release(obj)
|
10
|
-
|
11
|
-
detail_ptr = ptr.+(Instruction.offset_of(:detail)).read_pointer
|
10
|
+
detail_ptr = obj.+(Instruction.offset_of(:detail)).read_pointer
|
12
11
|
Binding.free(detail_ptr)
|
13
|
-
Binding.free(
|
12
|
+
Binding.free(obj)
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
@@ -42,7 +41,7 @@ module Crabstone
|
|
42
41
|
# Wrap to prevent function not found in elder Capstone.
|
43
42
|
def self.safe_attach(*args)
|
44
43
|
attach_function(*args)
|
45
|
-
rescue FFI::NotFoundError
|
44
|
+
rescue FFI::NotFoundError # rubocop: disable Lint/SuppressedException
|
46
45
|
end
|
47
46
|
|
48
47
|
# New APIs since Capstone 4.
|
data/lib/crabstone/constants.rb
CHANGED
@@ -1,110 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
# Constants in this file might be added in a newer Capstone version,
|
5
|
-
# but I expect they are always backward compatible.
|
3
|
+
require 'crabstone/cs_version'
|
6
4
|
|
7
|
-
require '
|
8
|
-
|
9
|
-
module Crabstone
|
10
|
-
# API version
|
11
|
-
BINDING_MAJ = VERSION.split('.').first.to_i
|
12
|
-
|
13
|
-
# architectures
|
14
|
-
ARCH_ARM = 0
|
15
|
-
ARCH_ARM64 = 1
|
16
|
-
ARCH_MIPS = 2
|
17
|
-
ARCH_X86 = 3
|
18
|
-
ARCH_PPC = 4
|
19
|
-
ARCH_SPARC = 5
|
20
|
-
ARCH_SYSZ = 6
|
21
|
-
ARCH_XCORE = 7
|
22
|
-
ARCH_M68K = 8
|
23
|
-
ARCH_TMS320C64X = 9
|
24
|
-
ARCH_M680X = 10
|
25
|
-
ARCH_EVM = 11
|
26
|
-
ARCH_MAX = 12
|
27
|
-
ARCH_ALL = 0xFFFF
|
28
|
-
|
29
|
-
# disasm mode
|
30
|
-
MODE_LITTLE_ENDIAN = 0 # little-endian mode (default mode)
|
31
|
-
MODE_ARM = 0 # 32-bit ARM
|
32
|
-
MODE_16 = 1 << 1 # 16-bit mode (X86)
|
33
|
-
MODE_32 = 1 << 2 # 32-bit mode (X86)
|
34
|
-
MODE_64 = 1 << 3 # 64-bit mode (X86, PPC)
|
35
|
-
MODE_THUMB = 1 << 4 # ARM's Thumb mode, including Thumb-2
|
36
|
-
MODE_MCLASS = 1 << 5 # ARM's Cortex-M series
|
37
|
-
MODE_V8 = 1 << 6 # ARMv8 A32 encodings for ARM
|
38
|
-
MODE_MICRO = 1 << 4 # MicroMips mode (MIPS)
|
39
|
-
MODE_MIPS3 = 1 << 5 # Mips III ISA
|
40
|
-
MODE_MIPS32R6 = 1 << 6 # Mips32r6 ISA
|
41
|
-
MODE_MIPSGP64 = 1 << 7 # General Purpose Registers are 64-bit wide (MIPS)
|
42
|
-
MODE_MODE_MIPS2 = 1 << 7 # Mips II ISA
|
43
|
-
MODE_V9 = 1 << 4 # SparcV9 mode (Sparc)
|
44
|
-
MODE_QPX = 1 << 4 # Quad Processing eXtensions mode (PPC)
|
45
|
-
MODE_M68K_000 = 1 << 1 # M68K 68000 mode
|
46
|
-
MODE_M68K_010 = 1 << 2 # M68K 68010 mode
|
47
|
-
MODE_M68K_020 = 1 << 3 # M68K 68020 mode
|
48
|
-
MODE_M68K_030 = 1 << 4 # M68K 68030 mode
|
49
|
-
MODE_M68K_040 = 1 << 5 # M68K 68040 mode
|
50
|
-
MODE_M68K_060 = 1 << 6 # M68K 68060 mode
|
51
|
-
MODE_BIG_ENDIAN = 1 << 31 # big-endian mode
|
52
|
-
MODE_MIPS32 = MODE_32 # Mips32 ISA (Mips)
|
53
|
-
MODE_MIPS64 = MODE_64 # Mips64 ISA (Mips)
|
54
|
-
MODE_M680X_6301 = 1 << 1 # M680X HD6301/3 mode
|
55
|
-
MODE_M680X_6309 = 1 << 2 # M680X HD6309 mode
|
56
|
-
MODE_M680X_6800 = 1 << 3 # M680X M6800/2 mode
|
57
|
-
MODE_M680X_6801 = 1 << 4 # M680X M6801/3 mode
|
58
|
-
MODE_M680X_6805 = 1 << 5 # M680X M6805 mode
|
59
|
-
MODE_M680X_6808 = 1 << 6 # M680X M68HC08 mode
|
60
|
-
MODE_M680X_6809 = 1 << 7 # M680X M6809 mode
|
61
|
-
MODE_M680X_6811 = 1 << 8 # M680X M68HC11 mode
|
62
|
-
MODE_M680X_CPU12 = 1 << 9 # M680X CPU12 mode
|
63
|
-
MODE_M680X_HCS08 = 1 << 10 # M680X HCS08 mode
|
64
|
-
|
65
|
-
# Capstone option type
|
66
|
-
OPT_SYNTAX = 1 # Intel X86 asm syntax (ARCH_X86 arch)
|
67
|
-
OPT_DETAIL = 2 # Break down instruction structure into details
|
68
|
-
OPT_MODE = 3 # Change engine's mode at run-time
|
69
|
-
OPT_MEM = 4 # Change engine's mode at run-time
|
70
|
-
OPT_SKIPDATA = 5 # Skip data when disassembling
|
71
|
-
OPT_SKIPDATA_SETUP = 6 # Setup user-defined function for SKIPDATA option
|
72
|
-
OPT_MNEMONIC = 7 # Customize instruction mnemonic
|
73
|
-
OPT_UNSIGNED = 8 # Print immediate in unsigned form
|
74
|
-
|
75
|
-
# Capstone option value
|
76
|
-
OPT_OFF = 0 # Turn OFF an option - default option of OPT_DETAIL
|
77
|
-
OPT_ON = 3 # Turn ON an option (OPT_DETAIL)
|
78
|
-
|
79
|
-
# Common instruction operand types - to be consistent across all architectures.
|
80
|
-
OP_INVALID = 0
|
81
|
-
OP_REG = 1
|
82
|
-
OP_IMM = 2
|
83
|
-
OP_MEM = 3
|
84
|
-
OP_FP = 4
|
85
|
-
|
86
|
-
# Common instruction groups - to be consistent across all architectures.
|
87
|
-
GRP_INVALID = 0 # uninitialized/invalid group.
|
88
|
-
GRP_JUMP = 1 # all jump instructions (conditional+direct+indirect jumps)
|
89
|
-
GRP_CALL = 2 # all call instructions
|
90
|
-
GRP_RET = 3 # all return instructions
|
91
|
-
GRP_INT = 4 # all interrupt instructions (int+syscall)
|
92
|
-
GRP_IRET = 5 # all interrupt return instructions
|
93
|
-
GRP_PRIVILEGE = 6 # all privileged instructions
|
94
|
-
|
95
|
-
# Access types for instruction operands.
|
96
|
-
AC_INVALID = 0 # Invalid/unitialized access type.
|
97
|
-
AC_READ = 1 << 0 # Operand that is read from.
|
98
|
-
AC_WRITE = 1 << 1 # Operand that is written to.
|
99
|
-
|
100
|
-
# Capstone syntax value
|
101
|
-
OPT_SYNTAX_DEFAULT = 0 # Default assembly syntax of all platforms (OPT_SYNTAX)
|
102
|
-
OPT_SYNTAX_INTEL = 1 # Intel X86 asm syntax - default syntax on X86 (OPT_SYNTAX, ARCH_X86)
|
103
|
-
OPT_SYNTAX_ATT = 2 # ATT asm syntax (OPT_SYNTAX, ARCH_X86)
|
104
|
-
OPT_SYNTAX_NOREGNAME = 3 # Asm syntax prints register name with only number - (OPT_SYNTAX, ARCH_PPC, ARCH_ARM)
|
105
|
-
OPT_SYNTAX_MASM = 4 # MASM syntax (CS_OPT_SYNTAX, CS_ARCH_X86)
|
106
|
-
|
107
|
-
# query id for cs_support()
|
108
|
-
SUPPORT_DIET = ARCH_ALL + 1
|
109
|
-
SUPPORT_X86_REDUCE = ARCH_ALL + 2
|
110
|
-
end
|
5
|
+
require File.join(__dir__, 'arch', Crabstone.cs_major_version.to_s, 'constants.rb')
|
data/lib/crabstone/cs_version.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'ffi'
|
4
4
|
|
5
|
-
require 'crabstone/constants'
|
6
5
|
require 'crabstone/version'
|
7
6
|
|
8
7
|
module Crabstone
|
@@ -42,7 +41,7 @@ module Crabstone
|
|
42
41
|
# Checks the cs_major is less or equal to Crabstone::VERSION.
|
43
42
|
def version_compatitable!
|
44
43
|
@version_compatitable ||=
|
45
|
-
cs_major_version <=
|
44
|
+
cs_major_version <= VERSION.split('.').first.to_i && cs_major_version >= 3
|
46
45
|
maj, min = cs_version
|
47
46
|
raise "FATAL: Crabstone v#{VERSION} doesn't support binding Capstone v#{maj}.#{min}" unless @version_compatitable
|
48
47
|
end
|
@@ -50,7 +49,7 @@ module Crabstone
|
|
50
49
|
# @private
|
51
50
|
module Binding
|
52
51
|
extend FFI::Library
|
53
|
-
ffi_lib ['capstone', 'libcapstone.so.4', 'libcapstone.so.3']
|
52
|
+
ffi_lib ['capstone', 'libcapstone.so.5', 'libcapstone.so.4', 'libcapstone.so.3']
|
54
53
|
|
55
54
|
attach_function :cs_version, %i[pointer pointer], :uint
|
56
55
|
end
|
@@ -81,9 +81,8 @@ module Crabstone
|
|
81
81
|
code = code.read_array_of_uchar(sz).pack('c*')
|
82
82
|
begin
|
83
83
|
Integer(yield(code, offset))
|
84
|
-
rescue StandardError
|
85
|
-
|
86
|
-
# It will go on to crash, but now at least there's more info :)
|
84
|
+
rescue StandardError => e
|
85
|
+
raise Crabstone::ErrSkipData, "Error in skipdata callback: #{e.message}"
|
87
86
|
end
|
88
87
|
end
|
89
88
|
end
|
data/lib/crabstone/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crabstone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Nagy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-08-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
@@ -72,6 +72,9 @@ dependencies:
|
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.17'
|
77
|
+
- - "<"
|
75
78
|
- !ruby/object:Gem::Version
|
76
79
|
version: '0.18'
|
77
80
|
type: :development
|
@@ -79,6 +82,9 @@ dependencies:
|
|
79
82
|
version_requirements: !ruby/object:Gem::Requirement
|
80
83
|
requirements:
|
81
84
|
- - "~>"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0.17'
|
87
|
+
- - "<"
|
82
88
|
- !ruby/object:Gem::Version
|
83
89
|
version: '0.18'
|
84
90
|
- !ruby/object:Gem::Dependency
|
@@ -117,6 +123,7 @@ files:
|
|
117
123
|
- lib/crabstone/arch/3/arm64.rb
|
118
124
|
- lib/crabstone/arch/3/arm64_const.rb
|
119
125
|
- lib/crabstone/arch/3/arm_const.rb
|
126
|
+
- lib/crabstone/arch/3/constants.rb
|
120
127
|
- lib/crabstone/arch/3/mips.rb
|
121
128
|
- lib/crabstone/arch/3/mips_const.rb
|
122
129
|
- lib/crabstone/arch/3/ppc.rb
|
@@ -133,6 +140,7 @@ files:
|
|
133
140
|
- lib/crabstone/arch/4/arm64.rb
|
134
141
|
- lib/crabstone/arch/4/arm64_const.rb
|
135
142
|
- lib/crabstone/arch/4/arm_const.rb
|
143
|
+
- lib/crabstone/arch/4/constants.rb
|
136
144
|
- lib/crabstone/arch/4/evm.rb
|
137
145
|
- lib/crabstone/arch/4/evm_const.rb
|
138
146
|
- lib/crabstone/arch/4/m680x.rb
|
@@ -153,6 +161,43 @@ files:
|
|
153
161
|
- lib/crabstone/arch/4/x86_const.rb
|
154
162
|
- lib/crabstone/arch/4/xcore.rb
|
155
163
|
- lib/crabstone/arch/4/xcore_const.rb
|
164
|
+
- lib/crabstone/arch/5/arm.rb
|
165
|
+
- lib/crabstone/arch/5/arm64.rb
|
166
|
+
- lib/crabstone/arch/5/arm64_const.rb
|
167
|
+
- lib/crabstone/arch/5/arm_const.rb
|
168
|
+
- lib/crabstone/arch/5/bpf.rb
|
169
|
+
- lib/crabstone/arch/5/bpf_const.rb
|
170
|
+
- lib/crabstone/arch/5/constants.rb
|
171
|
+
- lib/crabstone/arch/5/evm.rb
|
172
|
+
- lib/crabstone/arch/5/evm_const.rb
|
173
|
+
- lib/crabstone/arch/5/m680x.rb
|
174
|
+
- lib/crabstone/arch/5/m680x_const.rb
|
175
|
+
- lib/crabstone/arch/5/m68k.rb
|
176
|
+
- lib/crabstone/arch/5/m68k_const.rb
|
177
|
+
- lib/crabstone/arch/5/mips.rb
|
178
|
+
- lib/crabstone/arch/5/mips_const.rb
|
179
|
+
- lib/crabstone/arch/5/mos65xx.rb
|
180
|
+
- lib/crabstone/arch/5/mos65xx_const.rb
|
181
|
+
- lib/crabstone/arch/5/ppc.rb
|
182
|
+
- lib/crabstone/arch/5/ppc_const.rb
|
183
|
+
- lib/crabstone/arch/5/riscv.rb
|
184
|
+
- lib/crabstone/arch/5/riscv_const.rb
|
185
|
+
- lib/crabstone/arch/5/sh.rb
|
186
|
+
- lib/crabstone/arch/5/sh_const.rb
|
187
|
+
- lib/crabstone/arch/5/sparc.rb
|
188
|
+
- lib/crabstone/arch/5/sparc_const.rb
|
189
|
+
- lib/crabstone/arch/5/sysz.rb
|
190
|
+
- lib/crabstone/arch/5/sysz_const.rb
|
191
|
+
- lib/crabstone/arch/5/tms320c64x.rb
|
192
|
+
- lib/crabstone/arch/5/tms320c64x_const.rb
|
193
|
+
- lib/crabstone/arch/5/tricore.rb
|
194
|
+
- lib/crabstone/arch/5/tricore_const.rb
|
195
|
+
- lib/crabstone/arch/5/wasm.rb
|
196
|
+
- lib/crabstone/arch/5/wasm_const.rb
|
197
|
+
- lib/crabstone/arch/5/x86.rb
|
198
|
+
- lib/crabstone/arch/5/x86_const.rb
|
199
|
+
- lib/crabstone/arch/5/xcore.rb
|
200
|
+
- lib/crabstone/arch/5/xcore_const.rb
|
156
201
|
- lib/crabstone/arch/extension.rb
|
157
202
|
- lib/crabstone/arch/register.rb
|
158
203
|
- lib/crabstone/binding.rb
|
@@ -160,6 +205,8 @@ files:
|
|
160
205
|
- lib/crabstone/binding/3/instruction.rb
|
161
206
|
- lib/crabstone/binding/4/detail.rb
|
162
207
|
- lib/crabstone/binding/4/instruction.rb
|
208
|
+
- lib/crabstone/binding/5/detail.rb
|
209
|
+
- lib/crabstone/binding/5/instruction.rb
|
163
210
|
- lib/crabstone/binding/structs.rb
|
164
211
|
- lib/crabstone/constants.rb
|
165
212
|
- lib/crabstone/cs_version.rb
|
@@ -184,14 +231,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
231
|
requirements:
|
185
232
|
- - ">="
|
186
233
|
- !ruby/object:Gem::Version
|
187
|
-
version: '
|
234
|
+
version: '3.1'
|
188
235
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
236
|
requirements:
|
190
237
|
- - ">="
|
191
238
|
- !ruby/object:Gem::Version
|
192
239
|
version: '0'
|
193
240
|
requirements: []
|
194
|
-
rubygems_version: 3.
|
241
|
+
rubygems_version: 3.5.3
|
195
242
|
signing_key:
|
196
243
|
specification_version: 4
|
197
244
|
summary: Ruby FFI bindings for the capstone disassembly engine
|