Say you have this simple variable declaration:
from ctypes import c_uint8, POINTER
A = POINTER(c_uint8)()
In cpp, this is equivalent to:
const uint8_t *A;
// After declaring, do something that would fill up A...
The goal is to convert A into bytearray in Python by slicing so that I can change parts of it.
Correct me if I’m wrong, will this work?
from ctypes import c_uint8, POINTER
A = POINTER(c_uint8)()
# feed A to a function that would fill it up...
C = bytearray(A)
C[:6] = b'something'
Will it work? Please give me a complete explanation, thanks!