示例#1
0
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")
示例#2
0
def test_missing_info():
    with pytest.raises(TypeError):
        VmiOffsets.from_tool_output(missing_kpgd)
示例#3
0
def vmi_offsets():
    return VmiOffsets.from_tool_output(win_offsets_output)