A question before the code:
What are the differences between T32_ReadMemory and T32_ReadMemoryObj and in which cases should I prefer one over the other? As far as I can tell from the API PDF the 'Obj' version is more advanced and has more access options and access to 64 bit addresses, but there is no flaw in the regular version so if it works I can use it, am I right?
And for the code:
localBuffer = (ctypes.c_uint8 * size)()
myBufferHandle = ?
myAddressHandle32 = ?
t32api.T32_RequestBufferObj(ctypes.byref(myBufferHandle), 0)
t32api.T32_RequestAddressObjA32(ctypes.byref(myAddressHandle32), addr)
t32api.T32_ReadMemoryObj(myBufferHandle, myAddressHandle32, size)
t32api.T32_CopyDataFromBufferObj(localBuffer, size, myBufferHandle)
t32api.T32_ReleaseBufferObj(ctypes.byref(myBufferHandle))
This is an attempt to "translate" to python the following code example from the remote API PDF:
I got stuck in the places marked by question-marks, I don't know how to create trace32 internal types. I looked for a python example and couldn't find any.
Yes you are right, you don't need to use
T32_ReadMemoryObj()
, you can useT32_ReadMemory()
. I suggest to use T32_ReadMemoryObj() nonetheless because it's only marginally more complicated to use, but offers full flexibility. The main advantages in my opinion is the better access class management (strings instead of magic numbers) and 64-bit addresses. You might not need these in simple use cases.Regarding your
T32_ReadMemoryObj()
: You just need create void pointers. TheT32_Request...Obj()
functions will create the objects and set the pointer to them.