From d33fc0c47d1d955f85d2c8fbf5c05065f44bcf63 Mon Sep 17 00:00:00 2001 From: StarrFox Date: Fri, 21 Aug 2020 05:28:10 -0500 Subject: [PATCH] 0.7.1: update to new pymem version --- poetry.lock | 6 +++--- pyproject.toml | 4 ++-- wizwalker/client.py | 1 + wizwalker/windows/memory.py | 35 +++++++++-------------------------- 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/poetry.lock b/poetry.lock index a9f29b87..5aa7676a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -92,7 +92,7 @@ description = "pymem: python memory access made easy" name = "pymem" optional = false python-versions = "*" -version = "1.2" +version = "1.3" [package.extras] doc = ["recommonmark", "sphinx", "sphinx-rtd-theme", "sphinxcontrib-napoleon"] @@ -119,7 +119,7 @@ version = "1.0.1" dev = ["pytest (>=4.6.2)", "black (>=19.3b0)"] [metadata] -content-hash = "7e211be2a89b05d3af249b63b59a5b7087cec59b275871b741f4e8ca04ccf89f" +content-hash = "0f3e09b9887b0c570e9228ab910014f9df301dda9ed82301f317b5587a989cee" python-versions = "^3.8" [metadata.files] @@ -157,7 +157,7 @@ pyinstaller = [ {file = "PyInstaller-3.6.tar.gz", hash = "sha256:3730fa80d088f8bb7084d32480eb87cbb4ddb64123363763cf8f2a1378c1c4b7"}, ] pymem = [ - {file = "Pymem-1.2.tar.gz", hash = "sha256:c83d87a58c559f936c6eec929774232aeacab4eb1d4b3f4e990078e1e1c5dfac"}, + {file = "Pymem-1.3.tar.gz", hash = "sha256:5f972fb9edbd80a6de97084c1197dc44783189698d1fecad0788b6558764cea5"}, ] pywin32-ctypes = [ {file = "pywin32-ctypes-0.2.0.tar.gz", hash = "sha256:24ffc3b341d457d48e8922352130cf2644024a4ff09762a2261fd34c36ee5942"}, diff --git a/pyproject.toml b/pyproject.toml index 08066aa2..c6968ba8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "wizwalker" -version = "0.7.0" +version = "0.7.1" description = "Automation bot for wizard101" authors = ["StarrFox "] license = "GPL-3.0-or-later" @@ -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" diff --git a/wizwalker/client.py b/wizwalker/client.py index 47389fd8..1e94a7a0 100644 --- a/wizwalker/client.py +++ b/wizwalker/client.py @@ -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() diff --git a/wizwalker/windows/memory.py b/wizwalker/windows/memory.py index 62013218..cb84c5b0 100644 --- a/wizwalker/windows/memory.py +++ b/wizwalker/windows/memory.py @@ -74,24 +74,11 @@ 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): @@ -99,14 +86,7 @@ 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), @@ -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):