def extract_vmi_offsets( domain: str, kernel_profile: str, timeout: int = 30 ) -> Optional[VmiOffsets]: """ Call vmi-win-offsets helper and obtain VmiOffsets values """ try: output = subprocess.check_output( ["vmi-win-offsets", "--name", domain, "--json-kernel", kernel_profile], timeout=timeout, ).decode("utf-8", "ignore") return VmiOffsets.from_tool_output(output) except TypeError: logging.exception("Invalid output of vmi-win-offsets") except subprocess.CalledProcessError: logging.exception("vmi-win-offsets exited with an error") except subprocess.TimeoutExpired: logging.exception("vmi-win-offsets timed out") raise RuntimeError("Extracting VMI offsets failed")
def test_missing_info(): with pytest.raises(TypeError): VmiOffsets.from_tool_output(missing_kpgd)
def vmi_offsets(): return VmiOffsets.from_tool_output(win_offsets_output)