当前位置: 首页>>代码示例>>Python>>正文


Python mmap.PROT_WRITE属性代码示例

本文整理汇总了Python中mmap.PROT_WRITE属性的典型用法代码示例。如果您正苦于以下问题:Python mmap.PROT_WRITE属性的具体用法?Python mmap.PROT_WRITE怎么用?Python mmap.PROT_WRITE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在mmap的用法示例。


在下文中一共展示了mmap.PROT_WRITE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def __init__(self, *args, **kwds):
        ## Create shared memory for rendered image
        #pg.dbg(namespace={'r': self})
        if sys.platform.startswith('win'):
            self.shmtag = "pyqtgraph_shmem_" + ''.join([chr((random.getrandbits(20)%25) + 97) for i in range(20)])
            self.shm = mmap.mmap(-1, mmap.PAGESIZE, self.shmtag) # use anonymous mmap on windows
        else:
            self.shmFile = tempfile.NamedTemporaryFile(prefix='pyqtgraph_shmem_')
            self.shmFile.write(b'\x00' * (mmap.PAGESIZE+1))
            fd = self.shmFile.fileno()
            self.shm = mmap.mmap(fd, mmap.PAGESIZE, mmap.MAP_SHARED, mmap.PROT_WRITE)
        atexit.register(self.close)
        
        GraphicsView.__init__(self, *args, **kwds)
        self.scene().changed.connect(self.update)
        self.img = None
        self.renderTimer = QtCore.QTimer()
        self.renderTimer.timeout.connect(self.renderView)
        self.renderTimer.start(16) 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:21,代码来源:RemoteGraphicsView.py

示例2: create_shm_buffer

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def create_shm_buffer(touch, width, height):
    stride = width * 4
    size = stride * height

    with tempfile.TemporaryFile() as f:
        f.write(b"\x64" * size)
        f.flush()

        fd = f.fileno()
        touch["data"] = mmap.mmap(
            fd, size, mmap.MAP_SHARED, mmap.PROT_READ | mmap.PROT_WRITE
        )
        pool = touch["shm"].create_pool(fd, size)
        touch["buffer"] = pool.create_buffer(
            0, width, height, stride, WlShm.format.argb8888.value
        )
        pool.destroy() 
开发者ID:flacjacket,项目名称:pywayland,代码行数:19,代码来源:simple-touch.py

示例3: wipe

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def wipe(self):
    	filter_bitmap_fd = os.open("/dev/shm/kafl_filter0", os.O_RDWR | os.O_SYNC | os.O_CREAT)
        os.ftruncate(filter_bitmap_fd, self.config.config_values['BITMAP_SHM_SIZE'])
        filter_bitmap = mmap.mmap(filter_bitmap_fd, self.config.config_values['BITMAP_SHM_SIZE'], mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ)
        for i in range(self.config.config_values['BITMAP_SHM_SIZE']):
        	filter_bitmap[i] = '\x00'
        filter_bitmap.close()
        os.close(filter_bitmap_fd)

        filter_bitmap_fd = os.open("/dev/shm/kafl_tfilter", os.O_RDWR | os.O_SYNC | os.O_CREAT)
        os.ftruncate(filter_bitmap_fd, 0x1000000)
        filter_bitmap = mmap.mmap(filter_bitmap_fd, 0x1000000, mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ)
        for i in range(0x1000000):
        	filter_bitmap[i] = '\x00'
        filter_bitmap.close()
        os.close(filter_bitmap_fd) 
开发者ID:RUB-SysSec,项目名称:kAFL,代码行数:18,代码来源:master.py

示例4: __set_binary

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def __set_binary(self, filename, binaryfile, max_size):
        shm_fd = os.open(filename, os.O_RDWR | os.O_SYNC | os.O_CREAT)
        os.ftruncate(shm_fd, max_size)
        shm = mmap.mmap(shm_fd, max_size, mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ)
        shm.seek(0x0)
        shm.write('\x00' * max_size)
        shm.seek(0x0)

        f = open(binaryfile, "rb")
        bytes = f.read(1024)
        if bytes:
            shm.write(bytes)
        while bytes != "":
            bytes = f.read(1024)
            if bytes:
                shm.write(bytes)

        f.close()
        shm.close()
        os.close(shm_fd) 
开发者ID:RUB-SysSec,项目名称:kAFL,代码行数:22,代码来源:qemu.py

示例5: init

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def init(self):
        self.control = socket.socket(socket.AF_UNIX)
        while True:
            try:
                self.control.connect(self.control_filename)
                #self.control.connect(self.control_filename)
                break
            except socket_error:
                pass
                #time.sleep(0.01)

        self.kafl_shm_f     = os.open(self.bitmap_filename, os.O_RDWR | os.O_SYNC | os.O_CREAT)
        self.fs_shm_f       = os.open(self.payload_filename, os.O_RDWR | os.O_SYNC | os.O_CREAT)
        #argv_fd             = os.open(self.argv_filename, os.O_RDWR | os.O_SYNC | os.O_CREAT)
        os.ftruncate(self.kafl_shm_f, self.bitmap_size)
        os.ftruncate(self.fs_shm_f, (128 << 10))
        #os.ftruncate(argv_fd, (4 << 10))

        self.kafl_shm       = mmap.mmap(self.kafl_shm_f, self.bitmap_size, mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ)
        self.fs_shm         = mmap.mmap(self.fs_shm_f, (128 << 10),  mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ)

        return True 
开发者ID:RUB-SysSec,项目名称:kAFL,代码行数:24,代码来源:qemu.py

示例6: setClockPython

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def setClockPython(newClock):
    with open("/dev/mem", os.O_RDWR) as f:
        CPPCR = (0x10 >> 2)

        m = newClock / 6
        if(m >= 200):
            m = 200
        
        if(m < 4):
            m = 4
        

        try:
            map.mmap(1024, mmap.MAP_SHARED, mmap.PROT_READ | mmap.PROT_WRITE, 0x10000000) 
            map.seek(CPPCR)
            map.write((m << 24) | 0x090520)
            map.close()
        except Exception as ex:
            print(str(ex)) 
开发者ID:JackD83,项目名称:PyMenu,代码行数:21,代码来源:Overclock.py

示例7: shell_logger

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def shell_logger(output):
    """Logs shell output to the `output`.

    Works like unix script command with `-f` flag.

    """
    if not os.environ.get('SHELL'):
        logs.warn("Shell logger doesn't support your platform.")
        sys.exit(1)

    fd = os.open(output, os.O_CREAT | os.O_TRUNC | os.O_RDWR)
    os.write(fd, b'\x00' * const.LOG_SIZE_IN_BYTES)
    buffer = mmap.mmap(fd, const.LOG_SIZE_IN_BYTES, mmap.MAP_SHARED, mmap.PROT_WRITE)
    return_code = _spawn(os.environ['SHELL'], partial(_read, buffer))

    sys.exit(return_code) 
开发者ID:nvbn,项目名称:thefuck,代码行数:18,代码来源:shell_logger.py

示例8: mmap

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def mmap(fd, offset, size):
    prot = MMAP.PROT_READ | MMAP.PROT_WRITE
    flags = MMAP.MAP_PRIVATE

    # When trying to map the contents of a file into memory, the offset must be a multiple of the page size (see
    # `man mmap`). So we need to align it before passing it to mmap(). Doing so also increases the size of the memory
    # area needed, so we need to account for that difference.
    aligned_offset = offset & ~0xFFF
    size += offset - aligned_offset

    if size & 0xFFF != 0:
        size = (size & ~0xFFF) + 0x1000
    assert size > 0

    result = mmap_function(0, size, prot, flags, fd, aligned_offset)
    assert result != ctypes.c_void_p(-1).value

    # Now when returning the pointer to the user, we need to skip the corrected offset so that the user doesn't end up
    # with a pointer to another region of the file than the one they requested.
    return ctypes.cast(result + offset - aligned_offset, ctypes.POINTER(ctypes.c_char)) 
开发者ID:trailofbits,项目名称:manticore,代码行数:22,代码来源:mappings.py

示例9: open_device

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def open_device():
    global _initialized
    if not _initialized:
        global _pwmfile
        _pwmfile = os.open(lms2012.PWM_DEVICE_NAME, os.O_RDWR | os.O_SYNC)
        global _motorfile
        _motorfile = os.open(lms2012.MOTOR_DEVICE_NAME, os.O_RDWR | os.O_SYNC)
        MOTORDATAArrray = lms2012.MOTORDATA * 4
        global _motormm
        _motormm = mmap(fileno=_motorfile, length=sizeof(MOTORDATAArrray),
                        flags=MAP_SHARED, prot=PROT_READ | PROT_WRITE, offset=0)
        global _motordata
        _motordata = MOTORDATAArrray.from_buffer(_motormm)
        _initialized = True
        os.write(_pwmfile, struct.pack('B', lms2012.opPROGRAM_START))

# This does not look required. Types are TACHO (for the big engines) and MINITACHO for the gun one
# and firmware should recognize them properly.
# def set_types(types):
#    os.write(_pwmfile, struct.pack('5B', lms2012.opOUTPUT_SET_TYPE, *types)) 
开发者ID:hmml,项目名称:ev3,代码行数:22,代码来源:motordevice.py

示例10: wipe

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def wipe(self):
        filter_bitmap_fd = os.open("/dev/shm/kafl_filter0", os.O_RDWR | os.O_SYNC | os.O_CREAT)
        os.ftruncate(filter_bitmap_fd, self.config.config_values['BITMAP_SHM_SIZE'])
        filter_bitmap = mmap.mmap(filter_bitmap_fd, self.config.config_values['BITMAP_SHM_SIZE'], mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ)
        for i in range(self.config.config_values['BITMAP_SHM_SIZE']):
            filter_bitmap[i] = '\x00'
        filter_bitmap.close()
        os.close(filter_bitmap_fd)

        filter_bitmap_fd = os.open("/dev/shm/kafl_tfilter", os.O_RDWR | os.O_SYNC | os.O_CREAT)
        os.ftruncate(filter_bitmap_fd, 0x1000000)
        filter_bitmap = mmap.mmap(filter_bitmap_fd, 0x1000000, mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ)
        for i in range(0x1000000):
            filter_bitmap[i] = '\x00'
        filter_bitmap.close()
        os.close(filter_bitmap_fd) 
开发者ID:RUB-SysSec,项目名称:redqueen,代码行数:18,代码来源:master.py

示例11: __set_binary

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def __set_binary(self, filename, binaryfile, max_size):
        shm_fd = os.open(filename, os.O_RDWR | os.O_SYNC | os.O_CREAT)
        os.ftruncate(shm_fd, max_size)
        shm = mmap.mmap(shm_fd, max_size, mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ)
        shm.seek(0x0)
        shm.write('\x00' * max_size)
        shm.seek(0x0)

        f = open(binaryfile, "rb")
        bytes = f.read(1024)
        if bytes:
            shm.write(bytes)
        while bytes != "":
            bytes = f.read(1024)
            if bytes:
                shm.write(bytes)

        shm.flush()
        f.close()
        shm.close()
        os.close(shm_fd) 
开发者ID:RUB-SysSec,项目名称:redqueen,代码行数:23,代码来源:qemu.py

示例12: init

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def init(self):
        self.control = safe_socket(socket.AF_UNIX)
        self.control.settimeout(None)
        self.control.setblocking(1)
        while True:
            try:
                self.control.connect(self.control_filename)
                break
            except socket_error:
                pass

        self.kafl_shm_f     = os.open(self.bitmap_filename, os.O_RDWR | os.O_SYNC | os.O_CREAT)
        self.fs_shm_f       = os.open(self.payload_filename, os.O_RDWR | os.O_SYNC | os.O_CREAT)
        os.ftruncate(self.kafl_shm_f, self.bitmap_size)
        os.ftruncate(self.fs_shm_f, (128 << 10))

        self.kafl_shm       = mmap.mmap(self.kafl_shm_f, self.bitmap_size, mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ)
        self.fs_shm         = mmap.mmap(self.fs_shm_f, (128 << 10),  mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ)

        return True 
开发者ID:RUB-SysSec,项目名称:redqueen,代码行数:22,代码来源:qemu.py

示例13: get_map

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def get_map(cls, size):
        prot = mmap.PROT_EXEC | mmap.PROT_WRITE | mmap.PROT_READ
        return cls(-1, size, prot=prot) 
开发者ID:sogeti-esec-lab,项目名称:LKD,代码行数:5,代码来源:native_function.py

示例14: create_bitmap

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def create_bitmap(self, name):
        self.bitmap_fd = os.open(self.config.argument_values['work_dir'] + "/bitmaps/" + name,
                                 os.O_RDWR | os.O_SYNC | os.O_CREAT)
        os.ftruncate(self.bitmap_fd, self.config.config_values['BITMAP_SHM_SIZE'])
        self.bitmap = mmap.mmap(self.bitmap_fd, self.bitmap_size, mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ) 
开发者ID:RUB-SysSec,项目名称:grimoire,代码行数:7,代码来源:bitmap.py

示例15: init

# 需要导入模块: import mmap [as 别名]
# 或者: from mmap import PROT_WRITE [as 别名]
def init(self):
        self.control = safe_socket(socket.AF_UNIX)
        self.control.settimeout(None)
        self.control.setblocking(1)
        while True:
            try:
                self.control.connect(self.control_filename)
                # self.control.connect(self.control_filename)
                break
            except socket_error:
                pass
                # time.sleep(0.01)

        self.kafl_shm_f = os.open(self.bitmap_filename, os.O_RDWR | os.O_SYNC | os.O_CREAT)
        self.fs_shm_f = os.open(self.payload_filename, os.O_RDWR | os.O_SYNC | os.O_CREAT)

        open(self.tracedump_filename, "wb").close()

        os.symlink(self.tracedump_filename, self.config.argument_values['work_dir'] + "/pt_trace_dump_" + self.qemu_id)

        os.symlink(self.payload_filename, self.config.argument_values['work_dir'] + "/payload_" + self.qemu_id)
        os.symlink(self.bitmap_filename, self.config.argument_values['work_dir'] + "/bitmap_" + self.qemu_id)

        # argv_fd             = os.open(self.argv_filename, os.O_RDWR | os.O_SYNC | os.O_CREAT)
        os.ftruncate(self.kafl_shm_f, self.bitmap_size)
        os.ftruncate(self.fs_shm_f, (128 << 10))
        # os.ftruncate(argv_fd, (4 << 10))

        self.kafl_shm = mmap.mmap(self.kafl_shm_f, self.bitmap_size, mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ)
        self.c_bitmap = (ctypes.c_uint8 * self.bitmap_size).from_buffer(self.kafl_shm)
        self.last_bitmap_wrapper = ExecutionResult(None, None, None, None)
        self.fs_shm = mmap.mmap(self.fs_shm_f, (128 << 10), mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ)

        return True 
开发者ID:RUB-SysSec,项目名称:grimoire,代码行数:36,代码来源:qemu.py


注:本文中的mmap.PROT_WRITE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。