Skip to content

Commit

Permalink
re-add keystone-engine, it's still needed :(
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianPugh committed Mar 18, 2024
1 parent a1b82a5 commit 48d1b12
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,15 @@ If you run into permission issues, [ensure that your user is in the docker group

# Troubleshooting/FAQ:

All previous common problems have been solved 😎
### Unable to install python dependency `keystone-engine` on rpi3
If you are unable to install `keystone-engine` on a raspberry pi 3, try:
1. Update the GPU RAM to 16MB from `raspi-config`
2. Build and install keystone-engine from source (should take ~15 minutes):
```
git clone https://github.com/keystone-engine/keystone
cd keystone/bindings/python/
python3 -m pip install .
```
# Development
Main stages to developing a feature:
Expand Down
16 changes: 15 additions & 1 deletion patches/keystone_cache.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
{
"('add.w r2,r1,#0x10',){}": [1, 241, 16, 2],
"('add.w r7,r0,#0x10',){}": [0, 241, 16, 7],
"('b 0x1c',){}": [12, 224],
"('b.w #0x801b504', 134280240){}": [12, 240, 104, 184],
"('ite ne; movne.w r4, #0xd2000; moveq.w r4, #0xd1000',){}": [20, 191, 79, 244, 82, 36, 79, 244, 81, 36],
"('mov r0,r5',){}": [40, 70],
"('mov r0,r7',){}": [56, 70],
"('mov r1,r6',){}": [49, 70],
"('mov r2,r7',){}": [58, 70],
"('mov r5,r1',){}": [13, 70],
"('mov r1,r2',){}": [17, 70],
"('mov r7,r0',){}": [7, 70],
"('mov.w r1, #0x00000',){}": [79, 240, 0, 1],
"('mov.w r2, #45056',){}": [79, 244, 48, 66],
"('mov.w r3, #45056',){}": [79, 244, 48, 67]
"('mov.w r3, #45056',){}": [79, 244, 48, 67],
"('sub sp,#0x10',){}": [132, 176],
"('sub.w r1,r8,#0x10',){}": [168, 241, 16, 1],
"('sub.w r6,r2,#0x10',){}": [162, 241, 16, 6]
}
9 changes: 3 additions & 6 deletions patches/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ def twos_compliment(value, bits):


class CachedKeystone:
"""Keystone can be annoying to install; so we just cache the responses for end-users."""

def __init__(self, path="patches/keystone_cache.json"):
self.path = Path(path)

self._ks = None
with suppress(ImportError):
from keystone import KS_ARCH_ARM, KS_MODE_THUMB, Ks
from keystone import KS_ARCH_ARM, KS_MODE_THUMB, Ks

self._ks = Ks(KS_ARCH_ARM, KS_MODE_THUMB)
self._sig = inspect.signature(self._ks.asm)
self._ks = Ks(KS_ARCH_ARM, KS_MODE_THUMB)
self._sig = inspect.signature(self._ks.asm)

self._cache = {}
with suppress(FileNotFoundError):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ colorama
numpy
pycryptodome
pyelftools
keystone-engine

0 comments on commit 48d1b12

Please sign in to comment.