Jul-07-2017, 02:32 PM
I have a C library which will write data to memory
the function is like
function f (char *p)
{
memcpy(p...)
}
In python part I write as below
lib = CDLL("libtest.so")
dump= lib.f;
dump.argtypes =[c_char_p]
data =create_string_buffer(100)
dump(data)
print repr(data.raw)
but the print data is not fully right
ex:
data in c is 100030029008....
but in python will show
\x00\x01\x00\x00\x03\x00\x00\x02\x00\t\x00\x08
some data will become strange.
Does anyone know how should I do to let python allocate a memory and pass the memory to c to write?
Thanks.
the function is like
function f (char *p)
{
memcpy(p...)
}
In python part I write as below
lib = CDLL("libtest.so")
dump= lib.f;
dump.argtypes =[c_char_p]
data =create_string_buffer(100)
dump(data)
print repr(data.raw)
but the print data is not fully right
ex:
data in c is 100030029008....
but in python will show
\x00\x01\x00\x00\x03\x00\x00\x02\x00\t\x00\x08
some data will become strange.
Does anyone know how should I do to let python allocate a memory and pass the memory to c to write?
Thanks.