trainerbase 4.2.3__tar.gz → 4.2.5__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-4.2.3 → trainerbase-4.2.5}/PKG-INFO +1 -1
- {trainerbase-4.2.3 → trainerbase-4.2.5}/pyproject.toml +1 -1
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/codeinjection.py +18 -1
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/config.py +1 -1
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/gui/helpers.py +5 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/gui/teleport.py +1 -1
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/main.py +6 -7
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/process.py +16 -1
- {trainerbase-4.2.3 → trainerbase-4.2.5}/.gitignore +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/LICENSE +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/README.md +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/__init__.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/abc.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/common/__init__.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/common/abc.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/common/helpers.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/common/keyboard.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/common/rainbow.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/common/tapper.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/common/teleport.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/gameobject.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/gui/__init__.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/gui/injections.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/gui/misc.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/gui/objects.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/gui/rainbow.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/gui/scripts.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/gui/speedhack.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/gui/tapper.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/gui/types.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/logger.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/memory.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/py.typed +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/scriptengine.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/speedhack.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase/tts.py +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase_vendor/FASM.EXE +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase_vendor/speedhack32.dll +0 -0
- {trainerbase-4.2.3 → trainerbase-4.2.5}/trainerbase_vendor/speedhack64.dll +0 -0
|
@@ -8,6 +8,7 @@ from typing import ClassVar, Final, Self, override
|
|
|
8
8
|
|
|
9
9
|
from pymem.exception import MemoryWriteError
|
|
10
10
|
|
|
11
|
+
from trainerbase.logger import logger
|
|
11
12
|
from trainerbase.memory import ARCH, ConvertibleToAddress, allocate, ensure_address
|
|
12
13
|
from trainerbase.process import pm
|
|
13
14
|
|
|
@@ -51,16 +52,22 @@ class CodeInjection(AbstractCodeInjection):
|
|
|
51
52
|
@override
|
|
52
53
|
def inject(self):
|
|
53
54
|
self.injection_point = self.address.resolve()
|
|
54
|
-
|
|
55
55
|
self.original_code = pm.read_bytes(self.injection_point, len(self.code_to_inject))
|
|
56
|
+
|
|
57
|
+
logger.debug(f"Injecting {len(self.code_to_inject)} byte(s) at 0x{self.injection_point:X}")
|
|
58
|
+
|
|
56
59
|
pm.write_bytes(self.injection_point, self.code_to_inject, len(self.code_to_inject))
|
|
57
60
|
self._injected = True
|
|
58
61
|
|
|
59
62
|
@override
|
|
60
63
|
def eject(self):
|
|
61
64
|
if self._injected:
|
|
65
|
+
logger.debug(f"Ejecting {len(self.code_to_inject)} byte(s) from 0x{self.injection_point:X}")
|
|
66
|
+
|
|
62
67
|
pm.write_bytes(self.injection_point, self.original_code, len(self.original_code))
|
|
63
68
|
self._injected = False
|
|
69
|
+
else:
|
|
70
|
+
logger.debug("Nothing to eject")
|
|
64
71
|
|
|
65
72
|
|
|
66
73
|
class AllocatingCodeInjection(AbstractCodeInjection): # pylint: disable=too-many-instance-attributes
|
|
@@ -118,16 +125,24 @@ class AllocatingCodeInjection(AbstractCodeInjection): # pylint: disable=too-man
|
|
|
118
125
|
|
|
119
126
|
code_to_inject = self.code_to_inject + jump_back
|
|
120
127
|
|
|
128
|
+
logger.debug(f"Injecting {len(code_to_inject)} byte(s) (INJECTION) at 0x{self.new_memory_address:X}")
|
|
121
129
|
pm.write_bytes(self.new_memory_address, code_to_inject, len(code_to_inject))
|
|
130
|
+
|
|
131
|
+
logger.debug(f"Injecting {len(jump_to_new_mem)} byte(s) (JUMPER) at 0x{self.injection_point:X}")
|
|
122
132
|
pm.write_bytes(self.injection_point, jump_to_new_mem, len(jump_to_new_mem))
|
|
123
133
|
|
|
124
134
|
@override
|
|
125
135
|
def eject(self):
|
|
126
136
|
if self.new_memory_address and self.injection_point:
|
|
137
|
+
logger.debug(f"Ejecting {self.original_code_length} byte(s) (JUMPER) from 0x{self.injection_point:X}")
|
|
127
138
|
pm.write_bytes(self.injection_point, self.original_code, self.original_code_length)
|
|
139
|
+
|
|
140
|
+
logger.debug(f"Freeing memory at 0x{self.new_memory_address:X}")
|
|
128
141
|
pm.free(self.new_memory_address)
|
|
129
142
|
self.new_memory_address = 0
|
|
130
143
|
self.injection_point = 0
|
|
144
|
+
else:
|
|
145
|
+
logger.debug("Nothing to eject")
|
|
131
146
|
|
|
132
147
|
|
|
133
148
|
class MultipleCodeInjection(AbstractCodeInjection):
|
|
@@ -147,6 +162,8 @@ class MultipleCodeInjection(AbstractCodeInjection):
|
|
|
147
162
|
|
|
148
163
|
def compile_asm(code: Code) -> bytes:
|
|
149
164
|
if isinstance(code, str):
|
|
165
|
+
logger.debug(f"Assembling for x{ARCH}:\n{code}")
|
|
166
|
+
|
|
150
167
|
fasm_mode = f"use{ARCH}"
|
|
151
168
|
with TemporaryDirectory() as tmp_dir:
|
|
152
169
|
asm_file = Path(tmp_dir) / "injection.asm"
|
|
@@ -22,7 +22,7 @@ except KeyError:
|
|
|
22
22
|
del trainerbase_config["pymem"]
|
|
23
23
|
|
|
24
24
|
config_warnings.append(
|
|
25
|
-
"Deprecated config! Use [process] section with field `
|
|
25
|
+
"Deprecated config! Use [process] section with field `names` instead of [pymem] with `process_names`"
|
|
26
26
|
)
|
|
27
27
|
|
|
28
28
|
|
|
@@ -6,6 +6,7 @@ from dearpygui import dearpygui as dpg
|
|
|
6
6
|
from trainerbase.common.rainbow import Color, gradient_updater
|
|
7
7
|
from trainerbase.gui.rainbow import RainbowUI
|
|
8
8
|
from trainerbase.gui.types import AbstractUIComponent
|
|
9
|
+
from trainerbase.logger import logger
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
def add_components(*components: AbstractUIComponent):
|
|
@@ -58,8 +59,12 @@ def simple_trainerbase_menu(
|
|
|
58
59
|
|
|
59
60
|
on_initialized()
|
|
60
61
|
|
|
62
|
+
logger.debug("Showing Window")
|
|
63
|
+
|
|
61
64
|
dpg.start_dearpygui()
|
|
62
65
|
|
|
66
|
+
logger.debug("Window has been closed")
|
|
67
|
+
|
|
63
68
|
on_shutdown() # it's better to call it here, because after destroy_context it may not be possible
|
|
64
69
|
|
|
65
70
|
dpg.destroy_context()
|
|
@@ -58,7 +58,7 @@ class TeleportUI(AbstractUIComponent):
|
|
|
58
58
|
self.tp.save_position(key)
|
|
59
59
|
|
|
60
60
|
if self.tts_on_hotkey:
|
|
61
|
-
say("Position saved")
|
|
61
|
+
say("Position saved", allow_task_stacking=True)
|
|
62
62
|
|
|
63
63
|
@suppress_memory_exceptions
|
|
64
64
|
def on_hotkey_set_saved_position_press(self, key: Hashable):
|
|
@@ -28,20 +28,19 @@ def run( # pylint: disable=too-complex
|
|
|
28
28
|
on_shutdown_hook: Callback | None = None,
|
|
29
29
|
) -> NoReturn:
|
|
30
30
|
def on_shutdown() -> NoReturn:
|
|
31
|
-
logger.debug("Shutting down
|
|
32
|
-
|
|
33
|
-
rainbow_script_engine.stop()
|
|
34
|
-
system_script_engine.stop()
|
|
35
|
-
process_healthcheck_script_engine.stop()
|
|
31
|
+
logger.debug("Shutting down...")
|
|
36
32
|
|
|
37
33
|
logger.debug("Ejecting Code Injections.")
|
|
38
|
-
|
|
39
34
|
safely_eject_all_code_injections()
|
|
40
35
|
|
|
41
36
|
logger.debug("Disabling SpeedHack")
|
|
42
|
-
|
|
43
37
|
SpeedHack.disable()
|
|
44
38
|
|
|
39
|
+
logger.debug("Stopping Script Engines.")
|
|
40
|
+
rainbow_script_engine.stop()
|
|
41
|
+
system_script_engine.stop()
|
|
42
|
+
process_healthcheck_script_engine.stop()
|
|
43
|
+
|
|
45
44
|
if on_shutdown_hook is not None:
|
|
46
45
|
logger.debug("on_shutdown_hook provided. Calling.")
|
|
47
46
|
on_shutdown_hook()
|
|
@@ -2,10 +2,12 @@ from collections.abc import Iterable
|
|
|
2
2
|
from contextlib import suppress
|
|
3
3
|
from itertools import cycle
|
|
4
4
|
from os import _exit as force_exit
|
|
5
|
+
from time import sleep
|
|
5
6
|
from typing import cast
|
|
6
7
|
|
|
7
8
|
from psutil import Process, pid_exists, process_iter
|
|
8
9
|
from pymem import Pymem
|
|
10
|
+
from pymem.exception import ProcessError
|
|
9
11
|
|
|
10
12
|
from trainerbase.config import process_config
|
|
11
13
|
from trainerbase.logger import logger
|
|
@@ -58,6 +60,15 @@ def get_target_pid(process_names: Iterable[str], *, exact_match: bool, ignore_ca
|
|
|
58
60
|
raise RuntimeError("This place must be unreachable! `process_names` is probably empty.")
|
|
59
61
|
|
|
60
62
|
|
|
63
|
+
def ensure_main_module_is_initialized(pm: Pymem) -> int:
|
|
64
|
+
while True:
|
|
65
|
+
try:
|
|
66
|
+
return pm.base_address
|
|
67
|
+
except ProcessError:
|
|
68
|
+
logger.debug("Main module is not initialized. Waiting...")
|
|
69
|
+
sleep(0.25)
|
|
70
|
+
|
|
71
|
+
|
|
61
72
|
def attach_to_process() -> Pymem:
|
|
62
73
|
process_names = process_config["names"]
|
|
63
74
|
exact_match = process_config["exact_match"]
|
|
@@ -68,7 +79,11 @@ def attach_to_process() -> Pymem:
|
|
|
68
79
|
|
|
69
80
|
with suppress(KeyboardInterrupt):
|
|
70
81
|
pid = get_target_pid(process_names, exact_match=exact_match, ignore_case=ignore_case)
|
|
71
|
-
|
|
82
|
+
|
|
83
|
+
pm = Pymem(pid)
|
|
84
|
+
ensure_main_module_is_initialized(pm)
|
|
85
|
+
|
|
86
|
+
return pm
|
|
72
87
|
|
|
73
88
|
force_exit(0)
|
|
74
89
|
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|