Untitled
unknown
python
4 months ago
3.6 kB
43
Indexable
import sys
import pymem
import pymem.process
from PyQt5.QtWidgets import QApplication, QWidget, QSlider, QVBoxLayout, QLabel
from PyQt5.QtCore import Qt, QTimer
class MemorySlider(QWidget):
def __init__(self):
super().__init__()
# GUI Setup
self.setWindowTitle("SimRail test wejście")
self.setGeometry(100, 100, 400, 100)
self.layout = QVBoxLayout()
self.label = QLabel("Wartość: 0.0")
self.slider = QSlider(Qt.Horizontal)
self.slider.setMinimum(-100)
self.slider.setMaximum(100)
self.slider.setValue(0)
self.slider.setTickInterval(10)
self.slider.setTickPosition(QSlider.TicksBelow)
self.layout.addWidget(self.label)
self.layout.addWidget(self.slider)
self.setLayout(self.layout)
# Init memory access
try:
self.pm = pymem.Pymem("SimRail.exe")
self.game_module = pymem.process.module_from_name(self.pm.process_handle, "GameAssembly.dll")
self.base_address = self.game_module.lpBaseOfDll
print(f"[INFO] GameAssembly.dll base address: {hex(self.base_address)}")
except Exception as e:
self.label.setText("Błąd: Nie znaleziono SimRail.exe lub GameAssembly.dll")
print(f"[ERROR] {e}")
self.slider.setEnabled(False)
return
# Connect slider movement
self.slider.valueChanged.connect(self.update_memory_value)
# Odczyt aktualnej wartości co 0.5s
self.timer = QTimer()
self.timer.timeout.connect(self.read_memory_value)
self.timer.start(500)
def get_pointer_address(self):
try:
# Początkowy offset (z Cheat Engine: "GameAssembly.dll" + 0x6862C78)
base_ptr_offset = 0x6862C78
pointer_base = self.base_address + base_ptr_offset
address = self.pm.read_ulonglong(pointer_base)
print(f"[DEBUG] Base ptr deref -> {hex(address)}")
# Offsety zgodnie z kolejnością
offsets = [0xB8, 0x0, 0x60, 0x160, 0x28, 0x60, 0x20]
for i, offset in enumerate(offsets[:-1]):
address = self.pm.read_ulonglong(address + offset)
print(f"[DEBUG] Level {i+1} +{hex(offset)} => {hex(address)}")
final_address = address + offsets[-1]
print(f"[DEBUG] Final address: {hex(final_address)}")
return final_address
except Exception as e:
print(f"[ERROR] Błąd w pointer chain: {e}")
raise
def update_memory_value(self):
"""Gdy zmienia się suwak — nadpisujemy wartość w pamięci"""
try:
val = self.slider.value() / 100.0
address = self.get_pointer_address()
self.pm.write_float(address, val)
self.label.setText(f"Wartość: {val:.2f}")
except Exception as e:
self.label.setText("Błąd zapisu")
print(f"[ERROR] Zapis: {e}")
def read_memory_value(self):
"""Co 0.5s odczytuje wartość z pamięci"""
try:
address = self.get_pointer_address()
val = self.pm.read_float(address)
self.label.setText(f"Wartość: {val:.2f}")
except Exception as e:
self.label.setText("Błąd odczytu")
print(f"[ERROR] Odczyt: {e}")
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MemorySlider()
window.show()
sys.exit(app.exec_())Editor is loading...
Leave a Comment