fishhook 0.3.2__tar.gz → 0.3.4__tar.gz
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.
- {fishhook-0.3.2 → fishhook-0.3.4}/PKG-INFO +5 -4
- {fishhook-0.3.2 → fishhook-0.3.4}/fishhook/_asmmodule.c +6 -4
- {fishhook-0.3.2 → fishhook-0.3.4}/fishhook/fishhook.py +2 -2
- {fishhook-0.3.2 → fishhook-0.3.4}/fishhook/jit.py +21 -5
- {fishhook-0.3.2 → fishhook-0.3.4}/fishhook.egg-info/PKG-INFO +5 -4
- {fishhook-0.3.2 → fishhook-0.3.4}/fishhook.egg-info/requires.txt +2 -0
- {fishhook-0.3.2 → fishhook-0.3.4}/pyproject.toml +3 -3
- {fishhook-0.3.2 → fishhook-0.3.4}/LICENSE +0 -0
- {fishhook-0.3.2 → fishhook-0.3.4}/README.md +0 -0
- {fishhook-0.3.2 → fishhook-0.3.4}/fishhook/__init__.py +0 -0
- {fishhook-0.3.2 → fishhook-0.3.4}/fishhook/asm.py +0 -0
- {fishhook-0.3.2 → fishhook-0.3.4}/fishhook/tests.py +0 -0
- {fishhook-0.3.2 → fishhook-0.3.4}/fishhook.egg-info/SOURCES.txt +0 -0
- {fishhook-0.3.2 → fishhook-0.3.4}/fishhook.egg-info/dependency_links.txt +0 -0
- {fishhook-0.3.2 → fishhook-0.3.4}/fishhook.egg-info/top_level.txt +0 -0
- {fishhook-0.3.2 → fishhook-0.3.4}/setup.cfg +0 -0
- {fishhook-0.3.2 → fishhook-0.3.4}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: fishhook
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: Allows for runtime hooking of static class functions
|
|
5
5
|
Author-email: chilaxan <chilaxan@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -11,8 +11,9 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: >=3.8
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: capstone
|
|
15
|
-
Requires-Dist: keystone-engine
|
|
14
|
+
Requires-Dist: capstone; os_name != "nt"
|
|
15
|
+
Requires-Dist: keystone-engine; os_name != "nt"
|
|
16
|
+
Dynamic: license-file
|
|
16
17
|
|
|
17
18
|
# Fishhook
|
|
18
19
|
|
|
@@ -50,14 +50,16 @@ void changeProts(Py_buffer buffer, int prots) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
void invalidateInstructionCache(void *addr, size_t length) {
|
|
53
|
-
#if defined(
|
|
54
|
-
|
|
53
|
+
#if defined(_WIN32)
|
|
54
|
+
FlushInstructionCache(GetCurrentProcess(), (unsigned char*)addr, length);
|
|
55
55
|
#elif defined(__has_builtin)
|
|
56
56
|
#if __has_builtin(__builtin___clear_cache)
|
|
57
57
|
__builtin___clear_cache((char*)addr, (char*)(addr + length));
|
|
58
58
|
#endif
|
|
59
59
|
#else
|
|
60
|
-
// cannot determine way to clear instruction cache
|
|
60
|
+
// cannot determine way to clear instruction cache
|
|
61
|
+
// things might work, and might not
|
|
62
|
+
// If you get weird crashes, make an issue: https://github.com/chilaxan/fishhook
|
|
61
63
|
#endif
|
|
62
64
|
}
|
|
63
65
|
|
|
@@ -81,7 +83,7 @@ static PyObject *method_writeExecutableMemory(PyObject *self, PyObject *args, Py
|
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
if (target_buf.len != src_buf.len) {
|
|
84
|
-
PyErr_SetString(PyExc_ValueError, "target and
|
|
86
|
+
PyErr_SetString(PyExc_ValueError, "target and src must be the same length");
|
|
85
87
|
return NULL;
|
|
86
88
|
}
|
|
87
89
|
|
|
@@ -212,7 +212,7 @@ def build_orig():
|
|
|
212
212
|
int_add = int.__add__
|
|
213
213
|
int_and = int.__and__
|
|
214
214
|
int_bool = int.__bool__
|
|
215
|
-
|
|
215
|
+
locals_get = type(get_locals(getframe())).get # this enables compat with >= 3.13 FrameLocalsProxy
|
|
216
216
|
flags = {v: k for k, v in dis.COMPILER_FLAG_NAMES.items()}.get
|
|
217
217
|
new_slice = slice.__call__
|
|
218
218
|
get_class = vars(object)['__class__'].__get__
|
|
@@ -248,7 +248,7 @@ def build_orig():
|
|
|
248
248
|
varargs = None
|
|
249
249
|
if int_bool(int_and(get_flags(co), flags('VARARGS'))):
|
|
250
250
|
varargs = tuple_getitem(names, nargs)
|
|
251
|
-
argvals = (*(
|
|
251
|
+
argvals = (*(locals_get(locals, arg, NULL) for arg in tuple_iter(args)), *locals_get(locals, varargs, ()))
|
|
252
252
|
if int_bool(tuple_len(argvals)) and (self := tuple_getitem(argvals, 0)) is not NULL:
|
|
253
253
|
return self
|
|
254
254
|
raise RuntimeError('unable to bind self')
|
|
@@ -5,7 +5,7 @@ import platform
|
|
|
5
5
|
try:
|
|
6
6
|
import capstone as CS
|
|
7
7
|
except ModuleNotFoundError as err:
|
|
8
|
-
if err.name
|
|
8
|
+
if 'distutils' in err.name:
|
|
9
9
|
# capstone depends on distutils and pkg_resources, but in most configs does not need them
|
|
10
10
|
# 3.12+ has deprecated these modules
|
|
11
11
|
# we can stub them out and re-attempt the import
|
|
@@ -20,7 +20,23 @@ except ModuleNotFoundError as err:
|
|
|
20
20
|
sys.modules['pkg_resources'] = stub()
|
|
21
21
|
import capstone as CS
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
try:
|
|
24
|
+
import keystone as KS
|
|
25
|
+
except ModuleNotFoundError as err:
|
|
26
|
+
if 'distutils' in err.name:
|
|
27
|
+
# keystone depends on distutils and pkg_resources, but in most configs does not need them
|
|
28
|
+
# 3.12+ has deprecated these modules
|
|
29
|
+
# we can stub them out and re-attempt the import
|
|
30
|
+
class stub:
|
|
31
|
+
def __getattr__(self, attr):
|
|
32
|
+
return self
|
|
33
|
+
def __call__(self, *args):
|
|
34
|
+
return ''
|
|
35
|
+
|
|
36
|
+
sys.modules['distutils'] = stub()
|
|
37
|
+
sys.modules['distutils.sysconfig'] = stub()
|
|
38
|
+
sys.modules['pkg_resources'] = stub()
|
|
39
|
+
import keystone as KS
|
|
24
40
|
|
|
25
41
|
ENDIAN = 'LITTLE' if memoryview(b'\1\0').cast('h')[0]==1 else 'BIG'
|
|
26
42
|
BIT_SIZE = sys.maxsize.bit_length() + 1
|
|
@@ -80,7 +96,7 @@ def size_to_typ(n):
|
|
|
80
96
|
elif n == 8:
|
|
81
97
|
return 'QWORD'
|
|
82
98
|
else:
|
|
83
|
-
raise RuntimeError(f'x86 memory size {n} is unsupported')
|
|
99
|
+
raise RuntimeError(f'x86 register memory size {n} is unsupported')
|
|
84
100
|
|
|
85
101
|
def inst(n, *args):
|
|
86
102
|
return fragements[ARCH][n].format(*args)
|
|
@@ -94,8 +110,8 @@ def TRAMPOLINE(address, storage=None, registers=()):
|
|
|
94
110
|
field = getattr(type(storage), register)
|
|
95
111
|
offset = field.offset
|
|
96
112
|
typ = size_to_typ(field.size)
|
|
97
|
-
header += inst('store_mem', register, TMP_REG, offset,
|
|
98
|
-
footer += inst('read_mem', register, TMP_REG, offset,
|
|
113
|
+
header += inst('store_mem', register, TMP_REG, offset, typ)
|
|
114
|
+
footer += inst('read_mem', register, TMP_REG, offset, typ)
|
|
99
115
|
else:
|
|
100
116
|
header = footer = ''
|
|
101
117
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: fishhook
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: Allows for runtime hooking of static class functions
|
|
5
5
|
Author-email: chilaxan <chilaxan@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -11,8 +11,9 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: >=3.8
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: capstone
|
|
15
|
-
Requires-Dist: keystone-engine
|
|
14
|
+
Requires-Dist: capstone; os_name != "nt"
|
|
15
|
+
Requires-Dist: keystone-engine; os_name != "nt"
|
|
16
|
+
Dynamic: license-file
|
|
16
17
|
|
|
17
18
|
# Fishhook
|
|
18
19
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "fishhook"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.4"
|
|
4
4
|
description = "Allows for runtime hooking of static class functions"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "chilaxan", email = "chilaxan@gmail.com" },
|
|
@@ -14,8 +14,8 @@ classifiers = [
|
|
|
14
14
|
]
|
|
15
15
|
requires-python = ">=3.8"
|
|
16
16
|
dependencies = [
|
|
17
|
-
"capstone",
|
|
18
|
-
"keystone-engine",
|
|
17
|
+
"capstone; os_name != 'nt'",
|
|
18
|
+
"keystone-engine; os_name != 'nt'",
|
|
19
19
|
]
|
|
20
20
|
|
|
21
21
|
[project.urls]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|