Ejemplo n.º 1
0
def w_sr(cpu_index, regname, selector, base, limit, flags):
    """Write segment register. Only applies to x86 / x86-64

        :param cpu_index: CPU index of the register to write
        :type cpu_index: int

        :param regname: Name of the register to write
        :type regname: str

        :param selector: Value (selector) to write
        :type selector: int

        :param base: Value (base) to write
        :type selector: int

        :param limit: Value (limit) to write
        :type selector: int

        :return: None
        :rtype: None
    """
    from utils import ConfigurationManager as conf_m
    import c_api

    if cpu_index >= get_num_cpus():
        raise ValueError("Incorrect cpu index specified")

    if conf_m.platform == "i386-softmmu":
        if regname in X86CPU.reg_nums:
            # If this function call fails, it will raise an exception.
            # Given that the exception is self explanatory, we just let it
            # propagate upwards
            return c_api.w_sr(
                cpu_index,
                X86CPU.reg_nums[regname],
                selector,
                base,
                limit,
                flags)
        else:
            raise ValueError("[w_r] Wrong register specification")
    elif conf_m.platform == "x86_64-softmmu":
        if regname in X64CPU.reg_nums:
            # If this function call fails, it will raise an exception.
            # Given that the exception is self explanatory, we just let it
            # propagate upwards
            return c_api.w_sr(
                cpu_index,
                X64CPU.reg_nums[regname],
                selector,
                base,
                limit,
                flags)
        else:
            raise ValueError("[w_r] Wrong register specification")
    else:
        raise ValueError("[w_r] Wrong platform specification")
Ejemplo n.º 2
0
def w_sr(cpu_index, regname, selector, base, limit, flags):
    """Write segment register. Only applies to x86 / x86-64

        :param cpu_index: CPU index of the register to write
        :type cpu_index: int

        :param regname: Name of the register to write
        :type regname: str

        :param selector: Value (selector) to write
        :type selector: int

        :param base: Value (base) to write
        :type selector: int

        :param limit: Value (limit) to write
        :type selector: int

        :return: None
        :rtype: None
    """
    from utils import ConfigurationManager as conf_m
    import c_api

    if cpu_index >= get_num_cpus():
        raise ValueError("Incorrect cpu index specified")

    if conf_m.platform == "i386-softmmu":
        if regname in X86CPU.reg_nums:
            # If this function call fails, it will raise an exception.
            # Given that the exception is self explanatory, we just let it
            # propagate upwards
            return c_api.w_sr(
                cpu_index,
                X86CPU.reg_nums[regname],
                selector,
                base,
                limit,
                flags)
        else:
            raise ValueError("[w_r] Wrong register specification")
    elif conf_m.platform == "x86_64-softmmu":
        if regname in X64CPU.reg_nums:
            # If this function call fails, it will raise an exception.
            # Given that the exception is self explanatory, we just let it
            # propagate upwards
            return c_api.w_sr(
                cpu_index,
                X64CPU.reg_nums[regname],
                selector,
                base,
                limit,
                flags)
        else:
            raise ValueError("[w_r] Wrong register specification")
    else:
        raise ValueError("[w_r] Wrong platform specification")