trainerbase 3.3.0__tar.gz → 3.4.0__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.
- {trainerbase-3.3.0 → trainerbase-3.4.0}/PKG-INFO +1 -1
- {trainerbase-3.3.0 → trainerbase-3.4.0}/pyproject.toml +1 -1
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase/codeinjection.py +20 -8
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase/memory.py +4 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/LICENSE +0 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/README.rst +0 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase/__init__.py +0 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase/common.py +0 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase/config.py +0 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase/gameobject.py +0 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase/gui.py +0 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase/main.py +0 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase/scriptengine.py +0 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase/speedhack.py +0 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase/tts.py +0 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase_vendor/FASM.EXE +0 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase_vendor/speedhack32.dll +0 -0
- {trainerbase-3.3.0 → trainerbase-3.4.0}/trainerbase_vendor/speedhack64.dll +0 -0
|
@@ -3,7 +3,7 @@ from pathlib import Path
|
|
|
3
3
|
from subprocess import DEVNULL
|
|
4
4
|
from subprocess import run as run_executable
|
|
5
5
|
from tempfile import TemporaryDirectory
|
|
6
|
-
from typing import Self, override
|
|
6
|
+
from typing import Never, Self, override
|
|
7
7
|
|
|
8
8
|
from pymem.exception import MemoryWriteError
|
|
9
9
|
|
|
@@ -65,28 +65,40 @@ class AllocatingCodeInjection(AbstractCodeInjection): # pylint: disable=too-man
|
|
|
65
65
|
code_to_inject: Code,
|
|
66
66
|
original_code_length: int = 0,
|
|
67
67
|
new_memory_size: int = 1024,
|
|
68
|
-
is_long_x64_jump_needed:
|
|
68
|
+
is_long_x64_jump_needed: Never = Never,
|
|
69
69
|
):
|
|
70
|
+
if is_long_x64_jump_needed is not Never:
|
|
71
|
+
raise Exception(
|
|
72
|
+
"Since TrainerBase 3.4.0 is_long_x64_jump_needed has been deprecated."
|
|
73
|
+
" Now there is not need to manually pop and push rax. That's why you must"
|
|
74
|
+
" rewrite injections based on manual pop rax, push rax and then remove is_long_x64_jump_needed"
|
|
75
|
+
" argument"
|
|
76
|
+
)
|
|
77
|
+
|
|
70
78
|
self.address = ensure_address(address)
|
|
79
|
+
|
|
71
80
|
self.code_to_inject = compile_asm(code_to_inject)
|
|
81
|
+
|
|
82
|
+
if not pm.is_WoW64:
|
|
83
|
+
self.code_to_inject = compile_asm("pop rax") + self.code_to_inject + compile_asm("push rax")
|
|
84
|
+
|
|
72
85
|
self.original_code: bytes = b""
|
|
73
86
|
|
|
74
87
|
self.original_code_length = original_code_length
|
|
75
88
|
self.new_memory_size = new_memory_size
|
|
76
89
|
self.new_memory_address: int = 0
|
|
77
|
-
self.is_long_x64_jump_needed = is_long_x64_jump_needed
|
|
78
90
|
|
|
79
91
|
@override
|
|
80
92
|
def inject(self):
|
|
81
93
|
self.original_code = pm.read_bytes(self.address.resolve(), self.original_code_length)
|
|
82
94
|
self.new_memory_address: int = pm.allocate(self.new_memory_size)
|
|
83
95
|
|
|
84
|
-
if
|
|
85
|
-
new_mem_jump_code_generator = get_long_x64_jump_to_new_mem_code
|
|
86
|
-
jump_back_code_generator = get_long_x64_jump_back_code
|
|
87
|
-
else:
|
|
96
|
+
if pm.is_WoW64:
|
|
88
97
|
new_mem_jump_code_generator = get_simple_jump_code
|
|
89
98
|
jump_back_code_generator = get_simple_jump_code
|
|
99
|
+
else:
|
|
100
|
+
new_mem_jump_code_generator = get_long_x64_jump_to_new_mem_code
|
|
101
|
+
jump_back_code_generator = get_long_x64_jump_back_code
|
|
90
102
|
|
|
91
103
|
jump_to_new_mem = compile_asm(new_mem_jump_code_generator(self.new_memory_address))
|
|
92
104
|
jumper_length = len(jump_to_new_mem)
|
|
@@ -97,7 +109,7 @@ class AllocatingCodeInjection(AbstractCodeInjection): # pylint: disable=too-man
|
|
|
97
109
|
raise ValueError(f"Jumper length > original code length: {jumper_length} > {self.original_code_length}")
|
|
98
110
|
|
|
99
111
|
jump_back_address = self.address.resolve() + jumper_length
|
|
100
|
-
if
|
|
112
|
+
if not pm.is_WoW64:
|
|
101
113
|
jump_back_address -= 1
|
|
102
114
|
|
|
103
115
|
jump_back = compile_asm(jump_back_code_generator(jump_back_address))
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|