PyObject_CallFunction and writable memory

  • Thread starter Christopher Nebergall
  • Start date
C

Christopher Nebergall

I'm working a patch to a hex editor (frhed) written in c++ so it can
load python scripts. Internally the c++ code has a unsigned char * of
possibly serveral hundred megs which I want to send into the python
code to modify. What is the best way to send the unsigned char * as
writable memory into the python code, so I don't have to duplicate the
memory in order to return a modified copy? I'm currently using
"PyObject_CallFunction(pFunc, "(s#)",p->lpbMemory, p->dwSize);" to
send an immutable string but I haven't seen what I need to set in the
format string which makes the data writable to python. The solution
can be for either python 2.6 or 3.1.

Thanks,
Christopher
 
D

Diez B. Roggisch

Christopher said:
I'm working a patch to a hex editor (frhed) written in c++ so it can
load python scripts. Internally the c++ code has a unsigned char * of
possibly serveral hundred megs which I want to send into the python
code to modify. What is the best way to send the unsigned char * as
writable memory into the python code, so I don't have to duplicate the
memory in order to return a modified copy? I'm currently using
"PyObject_CallFunction(pFunc, "(s#)",p->lpbMemory, p->dwSize);" to
send an immutable string but I haven't seen what I need to set in the
format string which makes the data writable to python. The solution
can be for either python 2.6 or 3.1.

Take a look at the buffer-protocol.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,199
Messages
2,571,045
Members
47,643
Latest member
ashutoshjha_1101

Latest Threads

Top