Example #1
0
def w_va(pgd, addr, buff, length=None):
    """Write virtual address

        :param pgd: The PGD (address space) to write to.
        :type pgd: int

        :param addr: The address to write
        :type addr: int

        :param buff: The buffer to write
        :type buffer: str

        :return: None
        :rtype: None
    """
    import c_api
    # The length parameter is not used at this moment,
    # but is kept to avoid breaking old scripts.
    if length is not None and len(buff) != length:
        raise ValueError(
            "Length of the buffer does not match the declared length")
    else:
        # If this function call fails, it will raise an exception.
        # Given that the exception is self explanatory, we just let it
        # propagate upwards
        offset = addr
        length = len(buff)
        while offset < (addr + length):
            write_length = 0x2000 if (addr + length - offset) > 0x2000 else (
                addr + length - offset)
            c_api.w_va(pgd, offset,
                       buff[(offset - addr):(offset - addr + write_length)])
            offset += write_length
        return None
Example #2
0
def w_va(pgd, addr, buff, length=None):
    """Write virtual address

        :param pgd: The PGD (address space) to write to.
        :type pgd: int

        :param addr: The address to write
        :type addr: int

        :param buff: The buffer to write
        :type buffer: str

        :return: None
        :rtype: None
    """
    import c_api
    # The length parameter is not used at this moment,
    # but is kept to avoid breaking old scripts.
    if length is not None and len(buff) != length:
        raise ValueError(
            "Length of the buffer does not match the declared length")
    else:
        # If this function call fails, it will raise an exception.
        # Given that the exception is self explanatory, we just let it
        # propagate upwards
        offset = addr
        length = len(buff)
        while offset < (addr + length):
            write_length = 0x2000 if (addr + length - offset) > 0x2000 else (addr + length - offset)
            c_api.w_va(pgd, offset, buff[(offset - addr):(offset - addr + write_length)])
            offset += write_length
        return None
Example #3
0
def w_va(pgd,addr,buff,length):
    """Write virtual address

        :param pgd: The PGD (address space) to write to.
        :type pgd: int

        :param addr: The address to write
        :type addr: int

        :param buff: The buffer to write, between 0 and 0x2000 bytes
        :type buffer: str

        :param length: The length to write, between 0 and 0x2000 bytes
        :type length: int

        :return: None 
        :rtype: None
    """
    import c_api
    if len(buff) != length:
        raise ValueError("Length of the buffer does not match the declared length")
    else:
        #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_va(pgd,addr,buff)