async def _read_hook_base_addr(self, addr_name: str, hook_name: str): addr = self._base_addrs.get(addr_name) if addr is None: raise HookNotActive(hook_name) try: return await self.read_typed(addr, "long long") except pymem.exception.MemoryReadError: raise HookNotReady(hook_name)
async def deactivate_mouseless_cursor_hook(self): """ Deactivate mouseless cursor hook """ if not self._check_if_hook_active(MouselessCursorMoveHook): raise HookNotActive("Mouseless cursor") hook = self._get_hook_by_type(MouselessCursorMoveHook) self._active_hooks.remove(hook) await hook.unhook() del self._base_addrs["mouse_position"]
async def deactivate_render_context_hook(self): """ Deactivate render context hook """ if not self._check_if_hook_active(RenderContextHook): raise HookNotActive("Render context") hook = self._get_hook_by_type(RenderContextHook) self._active_hooks.remove(hook) await hook.unhook() del self._base_addrs["current_render_context"]
async def deactivate_root_window_hook(self): """ Deactivate root window hook """ if not self._check_if_hook_active(RootWindowHook): raise HookNotActive("Root window") hook = self._get_hook_by_type(RootWindowHook) self._active_hooks.remove(hook) await hook.unhook() del self._base_addrs["current_root_window"]
async def deactivate_client_hook(self): """ Deactivate client hook """ if not self._check_if_hook_active(ClientHook): raise HookNotActive("Client") hook = self._get_hook_by_type(ClientHook) self._active_hooks.remove(hook) await hook.unhook() del self._base_addrs["current_client"]
async def deactivate_player_stat_hook(self): """ Deactivate player stat hook """ if not self._check_if_hook_active(PlayerStatHook): raise HookNotActive("Player stat") hook = self._get_hook_by_type(PlayerStatHook) self._active_hooks.remove(hook) await hook.unhook() del self._base_addrs["player_stat_struct"]
async def deactivate_quest_hook(self): """ Deactivate quest hook """ if not self._check_if_hook_active(QuestHook): raise HookNotActive("Quest") hook = self._get_hook_by_type(QuestHook) self._active_hooks.remove(hook) await hook.unhook() del self._base_addrs["quest_struct"]
async def deactivate_duel_hook(self): """ Deactivate duel hook """ if not self._check_if_hook_active(DuelHook): raise HookNotActive("Duel") hook = self._get_hook_by_type(DuelHook) self._active_hooks.remove(hook) await hook.unhook() del self._base_addrs["current_duel"]
async def read_teleport_helper(self) -> int: """ Read teleport helper base address Returns: The teleport helper base address """ addr = self._base_addrs.get("teleport_helper") if addr is None: raise HookNotActive("Movement teleport") return addr
async def deactivate_movement_teleport_hook(self): """ Deactivate movement teleport hook """ if not self._check_if_hook_active(MovementTeleportHook): raise HookNotActive("Movement teleport") hook = self._get_hook_by_type(MovementTeleportHook) self._active_hooks.remove(hook) await hook.unhook() del self._base_addrs["teleport_helper"]
async def write_mouse_position(self, x: int, y: int): """ Write mouse position to memory Args: x: x position of mouse y: y position of mouse """ addr = self._base_addrs.get("mouse_position") if addr is None: raise HookNotActive("Mouseless cursor") packed_position = struct.pack("<ii", x, y) await self.write_bytes(addr, packed_position)
async def read_current_duel_phase(self) -> int: """ Read current cached duel phase Returns: The current duel phase """ addr = self._base_addrs.get("current_duel_phase") if addr is None: raise HookNotActive("Duel") try: return await self.read_typed(addr, "unsigned int") except pymem.exception.MemoryReadError: raise HookNotReady("Duel")
async def wrapped(*args, **kwargs): memory_handler = args[0] if not memory_handler.active_hooks[hook]: raise HookNotActive(hook) return await function(*args, **kwargs)