fishhook 0.3.2__tar.gz → 0.3.3__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: fishhook
3
- Version: 0.3.2
3
+ Version: 0.3.3
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(__x86_64__) || defined(_M_X64)
54
- // x86 invalidates cache for us
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 (required on arm64, otherwise make an issue here: https://github.com/chilaxan/fishhook)
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 dest must be the same length");
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
- dict_get = dict.get
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 = (*(dict_get(locals, arg, NULL) for arg in tuple_iter(args)), *dict_get(locals, varargs, ()))
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')
@@ -80,7 +80,7 @@ def size_to_typ(n):
80
80
  elif n == 8:
81
81
  return 'QWORD'
82
82
  else:
83
- raise RuntimeError(f'x86 memory size {n} is unsupported')
83
+ raise RuntimeError(f'x86 register memory size {n} is unsupported')
84
84
 
85
85
  def inst(n, *args):
86
86
  return fragements[ARCH][n].format(*args)
@@ -94,8 +94,8 @@ def TRAMPOLINE(address, storage=None, registers=()):
94
94
  field = getattr(type(storage), register)
95
95
  offset = field.offset
96
96
  typ = size_to_typ(field.size)
97
- header += inst('store_mem', register, TMP_REG, offset, *((typ,) if typ else ()))
98
- footer += inst('read_mem', register, TMP_REG, offset, *((typ,) if typ else ()))
97
+ header += inst('store_mem', register, TMP_REG, offset, typ)
98
+ footer += inst('read_mem', register, TMP_REG, offset, typ)
99
99
  else:
100
100
  header = footer = ''
101
101
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: fishhook
3
- Version: 0.3.2
3
+ Version: 0.3.3
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,2 +1,4 @@
1
+
2
+ [:os_name != "nt"]
1
3
  capstone
2
4
  keystone-engine
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fishhook"
3
- version = "0.3.2"
3
+ version = "0.3.3"
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