-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
_cstool
149 lines (142 loc) · 5 KB
/
_cstool
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#compdef cstool
# -----------------------------------------------------------------------------
# The BSD-3-Clause License
#
# Copyright (c) 2018, Koichi Shiraishi
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of que nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
#
# github.com/aquynh/capstone/cstool
#
# -----------------------------------------------------------------------------
#
# Cstool for Capstone Disassembler Engine v4.0.1
#
# Syntax: cstool [-u|-d|-s|-v] <arch+mode> <assembly-hexstring> [start-address-in-hex-format]
#
# The following <arch+mode> options are supported:
# x16: 16-bit mode (X86)
# x32: 32-bit mode (X86)
# x64: 64-bit mode (X86)
# x16att: 16-bit mode (X86) syntax-att
# x32att: 32-bit mode (X86) syntax-att
# x64att: 64-bit mode (X86) syntax-att
# arm: arm
# armbe: arm + big endian
# thumb: thumb mode
# thumbbe: thumb + big endian
# cortexm: thumb + cortex-m extensions
# arm64: aarch64 mode
# arm64be: aarch64 + big endian
# mips: mips32 + little endian
# mipsbe: mips32 + big endian
# mips64: mips64 + little endian
# mips64be: mips64 + big endian
# ppc64: ppc64 + little endian
# ppc64be: ppc64 + big endian
# sparc: sparc
# systemz: systemz (s390x)
# xcore: xcore
# m68k: m68k + big endian
# m68k40: m68k_040
# tms320c64x:TMS320C64x
# m6800: M6800/2
# m6801: M6801/3
# m6805: M6805
# m6808: M68HC08
# m6809: M6809
# m6811: M68HC11
# cpu12: M68HC12/HCS12
# hd6301: HD6301/3
# hd6309: HD6309
# hcs08: HCS08
# evm: Ethereum Virtual Machine
#
# Extra options:
# -d show detailed information of the instructions
# -u show immediates as unsigned
# -s decode in SKIPDATA mode
# -v show version & Capstone core build info
#
# -----------------------------------------------------------------------------
function _cstool() {
local context curcontext=$curcontext state line expl ret=1
declare -A opt_args
local -a arch_mode
arch_mode=(
'x16:16-bit mode (X86)'
'x32:32-bit mode (X86)'
'x64:64-bit mode (X86)'
'x16att:16-bit mode (X86) syntax-att'
'x32att:32-bit mode (X86) syntax-att'
'x64att:64-bit mode (X86) syntax-att'
'arm:arm'
'armbe:arm + big endian'
'thumb:thumb mode'
'thumbbe:thumb + big endian'
'cortexm:thumb + cortex-m extensions'
'arm64:aarch64 mode'
'arm64be:aarch64 + big endian'
'mips:mips32 + little endian'
'mipsbe:mips32 + big endian'
'mips64:mips64 + little endian'
'mips64be:mips64 + big endian'
'ppc64:ppc64 + little endian'
'ppc64be:ppc64 + big endian'
'sparc:sparc'
'systemz:systemz (s390x)'
'xcore:xcore'
'm68k:m68k + big endian'
'm68k40:m68k_040'
'tms320c64x:TMS320C64x'
'm6800:M6800/2'
'm6801:M6801/3'
'm6805:M6805'
'm6808:M68HC08'
'm6809:M6809'
'm6811:M68HC11'
'cpu12:M68HC12/HCS12'
'hd6301:HD6301/3'
'hd6309:HD6309'
'hcs08:HCS08'
'evm:Ethereum Virtual Machine'
)
_arguments -C \
'-d[show detailed information of the instructions]' \
'-u[show immediates as unsigned]' \
'-s[decode in SKIPDATA mode]' \
'-v[show version & Capstone core build info]' \
"1: :{_describe 'arch+mode' arch_mode}" \
'2:assembly-hexstring' \
'3:[start-address-in-hex-format]' \
&& ret=0
return ret
}
_cstool "$*"
# vim:ft=zsh:et:sts=2:sw=2