0

I'm working with python and import dll that have the following function:

int ReadMem(long Addr, long NumBytes, void* pData);

and I'm using this function to read memory from my target.

I want to create structure in python that is identical to structure defined in my target and then read it in python

I.E if i used C , i would wrote , ReadMem(0x10000000, 200, &mem_struct);

  1. What is the best way to define the struct (ctype Structure class or struct)?
  2. I used ctype Structure class:
class memory(Structure):

     fields_ = [("x", c_int),
               ("y", c_int)]

My question is: how can I call the ReadMem function with pointer to this struct? I try to use ctype pointer (I.E pi=pointer(memory) ) but I get TypeError

Gil.I
  • 895
  • 12
  • 23

1 Answers1

0

I came across an answer for similar question in this SO link

and learn that i need to use the following code:

memory_ptr =  pointer(memory)
ReadMem(0x20000000, 100, memory_ptr)

Note : using byref(memory) probably works too

Community
  • 1
  • 1
Gil.I
  • 895
  • 12
  • 23