Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
0.7.1: update to new pymem version
Browse files Browse the repository at this point in the history
  • Loading branch information
StarrFox committed Aug 21, 2020
1 parent ff4c07d commit d33fc0c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 31 deletions.
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "wizwalker"
version = "0.7.0"
version = "0.7.1"
description = "Automation bot for wizard101"
authors = ["StarrFox <[email protected]>"]
license = "GPL-3.0-or-later"
Expand All @@ -10,7 +10,7 @@ python = "^3.8"
loguru = "^0.5.1"
aioconsole = "^0.2.1"
aiofiles = "^0.5.0"
pymem = "^1.2"
pymem = "1.3"

[tool.poetry.dev-dependencies]
pyinstaller = "^3.6"
Expand Down
1 change: 1 addition & 0 deletions wizwalker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ async def quest_xyz(self) -> Optional[utils.XYZ]:
async def health(self) -> Optional[int]:
"""
Player health if memory hooks are injected, otherwise None
Can also be None if the injected function hasn't been triggered yet
"""
return await self.memory.read_player_health()

Expand Down
35 changes: 9 additions & 26 deletions wizwalker/windows/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,39 +74,19 @@ def hook(self) -> Any:
self.jump_address, len(self.jump_bytecode)
)

# Todo: Fix this whenever pymem is updated
# self.memory_handler.process.write_bytes(
# self.hook_address, self.hook_bytecode, len(self.hook_bytecode),
# )
# self.memory_handler.process.write_bytes(
# self.jump_address, self.jump_bytecode, len(self.jump_bytecode),
# )
pymem.memory.write_bytes(
self.memory_handler.process.process_handle,
self.hook_address,
self.hook_bytecode,
len(self.hook_bytecode),
self.memory_handler.process.write_bytes(
self.hook_address, self.hook_bytecode, len(self.hook_bytecode),
)
pymem.memory.write_bytes(
self.memory_handler.process.process_handle,
self.jump_address,
self.jump_bytecode,
len(self.jump_bytecode),
self.memory_handler.process.write_bytes(
self.jump_address, self.jump_bytecode, len(self.jump_bytecode),
)

def unhook(self):
"""
Deallocates hook memory and rewrites jump addr to it's origional code,
also called when a client is closed
"""
# Todo: fix when pymem updates
# self.memory_handler.process.write_bytes(
# self.jump_address,
# self.jump_original_bytecode,
# len(self.jump_original_bytecode),
# )
pymem.memory.write_bytes(
self.memory_handler.process.process_handle,
self.memory_handler.process.write_bytes(
self.jump_address,
self.jump_original_bytecode,
len(self.jump_original_bytecode),
Expand Down Expand Up @@ -403,7 +383,10 @@ def read_player_health(self):
return None

stat_addr = self.process.read_int(self.player_stat_addr)
return self.process.read_int(stat_addr)
try:
return self.process.read_int(stat_addr)
except pymem.exception.MemoryReadError:
return None

@utils.executor_function
def read_player_mana(self):
Expand Down

0 comments on commit d33fc0c

Please sign in to comment.