I am making hacks for CSGO using Pymem(Bot only servers, don't worry) but keep getting errors. I decided to use threading because my functions have infinite while loops. But I keep getting the following errors:
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Users\gjohn\PycharmProjects\csgoGlow\venv\lib\site-packages\pymem\__init__.py", line 484, in read_int
value = pymem.memory.read_int(self.process_handle, address)
File "C:\Users\gjohn\PycharmProjects\csgoGlow\venv\lib\site-packages\pymem\memory.py", line 271, in read_int
bytes = read_bytes(handle, address, struct.calcsize('i'))
File "C:\Users\gjohn\PycharmProjects\csgoGlow\venv\lib\site-packages\pymem\memory.py", line 105, in read_bytes
raise pymem.exception.WinAPIError(error_code)
pymem.exception.WinAPIError: Windows api error, error_code: 998
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:/Users/gjohn/PycharmProjects/csgoGlow/main.py", line 34, in glow
entity_team_id = pm.read_int(entity + m_iTeamNum)
File "C:\Users\gjohn\PycharmProjects\csgoGlow\venv\lib\site-packages\pymem\__init__.py", line 486, in read_int
raise pymem.exception.MemoryReadError(address, struct.calcsize('i'), e.error_code)
pymem.exception.MemoryReadError: Could not read memory at: -1899196620, length: 4 - GetLastError: 998
and I'm not sure why. Here is my code:
import keyboard
import pymem
import pymem.process
import time
from win32gui import GetWindowText, GetForegroundWindow
import threading
dwEntityList = (0x4DA2F44)
dwGlowObjectManager = (0x52EB540)
m_iGlowIndex = (0xA438)
dwForceAttack = (0x31D44D4)
dwForceJump = (0x524CEA4)
dwLocalPlayer = (0xD8B2BC)
m_fFlags = (0x104)
m_iCrosshairId = (0xB3E4)
m_iTeamNum = (0xF4)
m_flFlashMaxAlpha = (0xA41C)
trigger_key = "shift"
def glow():
print("Diamond has launched.")
pm = pymem.Pymem("csgo.exe")
client = pymem.process.module_from_name(pm.process_handle, "client.dll").lpBaseOfDll
while True:
glow_manager = pm.read_int(client + dwGlowObjectManager)
for i in range(1, 32): # Entities 1-32 are reserved for players.
entity = pm.read_int(client + dwEntityList + i * 0x10)
if entity:
entity_team_id = pm.read_int(entity + m_iTeamNum)
entity_glow = pm.read_int(entity + m_iGlowIndex)
if entity_team_id == 2: # Terrorist
pm.write_float(glow_manager + entity_glow * 0x38 + 0x4, float(1)) # R
pm.write_float(glow_manager + entity_glow * 0x38 + 0x8, float(1)) # G
pm.write_float(glow_manager + entity_glow * 0x38 + 0xC, float(0)) # B
pm.write_float(glow_manager + entity_glow * 0x38 + 0x10, float(1)) # Alpha
pm.write_int(glow_manager + entity_glow * 0x38 + 0x24, 1) # Enable glow
elif entity_team_id == 3: # Counter-terrorist
pm.write_float(glow_manager + entity_glow * 0x38 + 0x4, float(0)) # R
pm.write_float(glow_manager + entity_glow * 0x38 + 0x8, float(0)) # G
pm.write_float(glow_manager + entity_glow * 0x38 + 0xC, float(1)) # B
pm.write_float(glow_manager + entity_glow * 0x38 + 0x10, float(1)) # Alpha
pm.write_int(glow_manager + entity_glow * 0x38 + 0x24, 1) # Enable glow
def triggerBot():
print("Sapphire has launched.")
pm = pymem.Pymem("csgo.exe")
client = pymem.process.module_from_name(pm.process_handle, "client.dll").lpBaseOfDll
while True:
if not keyboard.is_pressed(trigger_key):
time.sleep(0.1)
if not GetWindowText(GetForegroundWindow()) == "Counter-Strike: Global Offensive":
continue
if keyboard.is_pressed(trigger_key):
player = pm.read_int(client + dwLocalPlayer)
entity_id = pm.read_int(player + m_iCrosshairId)
entity = pm.read_int(client + dwEntityList + (entity_id - 1) * 0x10)
entity_team = pm.read_int(entity + m_iTeamNum)
player_team = pm.read_int(player + m_iTeamNum)
if entity_id > 0 and entity_id <= 64 and player_team != entity_team:
pm.write_int(client + dwForceAttack, 6)
time.sleep(0.006)
def speed():
print("Ruby has launched.")
pm = pymem.Pymem("csgo.exe")
client = pymem.process.module_from_name(pm.process_handle, "client.dll").lpBaseOfDll
while True:
if not GetWindowText(GetForegroundWindow()) == "Counter-Strike: Global Offensive":
continue
if keyboard.is_pressed("space"):
force_jump = client + dwForceJump
player = pm.read_int(client + dwLocalPlayer)
if player:
on_ground = pm.read_int(player + m_fFlags)
if on_ground and on_ground == 257:
pm.write_int(force_jump, 5)
time.sleep(0.08)
pm.write_int(force_jump, 4)
time.sleep(0.002)
def flash():
print("Emerald has launched.")
pm = pymem.Pymem("csgo.exe")
client = pymem.process.module_from_name(pm.process_handle, "client.dll").lpBaseOfDll
while True:
player = pm.read_int(client + dwLocalPlayer)
if player:
flash_value = player + m_flFlashMaxAlpha
if flash_value:
pm.write_float(flash_value, float(0))
time.sleep(1)
if __name__ == '__main__':
thread1 = threading.Thread(target=speed)
thread2 = threading.Thread(target=glow)
thread3 = threading.Thread(target=triggerBot)
thread4 = threading.Thread(target=flash)
thread1.start()
thread2.start()
thread3.start()
thread4.start()
thread1.join()
thread2.join()
thread3.join()
thread4.join()
I tried everything, and it kinda worked for a bit, until I added the 4th function. This doesn't make sense, since the errors aren't for that thread, and when I comment that thread out, glow still returns this error.