Answer the question
In order to leave comments, you need to log in
How to map a read-only buffer to ctypes.Structure?
python3.3, win32
has a chunk of memory available for reading
m = mmap.mmap(0, MEMMAPFILESIZE, MEMMAPFILE, access=mmap.ACCESS_READ)
header_struct = struct.Struct('i')
Header = collections.namedtuple('Header', 'version')
h = Header._make(header_struct.unpack_from(m))
print(h.version)
class Header(ctypes.Structure):
_fields_ = [
('version', ctypes.c_int),
]
h = Header.from_buffer(m)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question