capstone
Capstone integration
capstone_decode_instruction(inst)
Decode an instruction with capstone
Decode an instruction and retry for ARM to check if the Thumb mode was activated
The decoding logic is done by the inner method _decode
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inst |
Instruction
|
Instruction to translate |
required |
Returns:
Type | Description |
---|---|
Optional[CsInsn]
|
A capstone instruction if it has been decoded |
Source code in quokka/backends/capstone.py
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 |
|
get_capstone_context(arch, endian=Endianness.LITTLE_ENDIAN)
Compute the capstone context for the program
The Capstone context is used to decode instructions afterwards. Since we are interested in most of the details, we already set the details to True.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arch |
Type[QuokkaArch]
|
Quokka program architecture |
required |
Returns:
Type | Description |
---|---|
Cs
|
A capstone Cs instance |
Source code in quokka/backends/capstone.py
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 |
|
update_capstone_context(program, is_thumb)
Returns an appropriate context for Capstone instructions
For ARM architecture, if the instruction is Thumb, we must use a different context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
program |
Program
|
Program to consider |
required |
is_thumb |
bool
|
Is the instruction a thumb one? |
required |
Returns:
Type | Description |
---|---|
Cs
|
The correct capstone context |
Source code in quokka/backends/capstone.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|