Pymem could not write memory CSGO

So I wanted to try making a CSGO cheat for bot games(Not public, I actually like that game and am a high level). I was testing out some code, when something happened for the first time. Keep in mind this cheat had worked before this, and I made sure to update the offsets. So this error happens in my ESP/wallhack/glow function. Here's the code to it:

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

But on line 21, which is the first line under the elif entity_team_id == 3: # Counter-terroist, it gives me this error:

Traceback (most recent call last):
  File "C:\Users\gjohn\anaconda3\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\gjohn\anaconda3\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "c:/Users/gjohn/Desktop/csgoHop/main.py", line 87, in glow
    pm.write_float(glow_manager + entity_glow * 0x38 + 0x4, float(0))   # R
  File "C:\Users\gjohn\anaconda3\lib\site-packages\pymem\__init__.py", line 961, in write_float
    raise pymem.exception.MemoryWriteError(address, value, e.error_code)
pymem.exception.MemoryWriteError: Could not write memory at: 2244, length: 0.0 - GetLastError: 998

Specifically the pymem.exception.MemoryWriteError: Could not write memory at: 2244, length: 0.0 - GetLastError: 998. I'm pretty new to this and haven't used pymem a lot in the past, so I have no idea what's going on here. Again, I made sure the offsets are up to date. It also only happens when I load up a game, not on the menu. It will run fine until the bots load up and stuff.

This also happens in my anti-flash function:

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)

on line 11, which is right under the "if flash_value:".

Edit: I know the pm and client assigning are commented out, it's because I had decided to move it up earlier in the code so I'm not recreating the variable for every function, but I wanted to keep it there just in case. I do this in:

try:
    pm = pymem.Pymem("csgo.exe")
    client = pymem.process.module_from_name(pm.process_handle, "client.dll").lpBaseOfDll
    engine = pymem.process.module_from_name(pm.process_handle, "engine.dll").lpBaseOfDll
    enginepointer = pm.read_int(engine + dwClientState)
except pymem.exception.ProcessNotFound:
    print('Launch Game')
    quit()

Edit #2: So error 998 means it has invalid access to the memory. My guess is that whatever it's trying to access isn't there. To let the other functions run, I put a try statement around glow and flash. Although it still doesn't work.



Read more here: https://stackoverflow.com/questions/67612056/pymem-could-not-write-memory-csgo

Content Attribution

This content was originally published by Mr. Cow at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: