Nirmi
Nirmi

Reputation: 356

trace32 using python: how to interpreat return data from function T32_ReadMemoryObj

Code is for reading 40 bytes of data from 32 bit address:

    size = 40
    addr = 0x02051000
    buffer = (c_uint8 * size)()
    buffer_handle = c_void_p()
    address_handle32 = c_void_p()
    self.t32_api.T32_RequestBufferObj(byref(buffer_handle), 0)
    self.t32_api.T32_RequestAddressObjA32(byref(address_handle32), addr)
    self.t32_api.T32_ReadMemoryObj(buffer, address_handle32, size)
    self.t32_api.T32_CopyDataFromBufferObj(buffer, size, buffer_handle)
    self.t32_api.T32_ReleaseBufferObj(byref(buffer_handle))
    return ''.join(map(str, buffer))

return data: 000000004000000003213746596610040000000000000000 but in trace 32 window it is showing enter image description here

does API returning incorrect data? OR I have invalid code?

Upvotes: 1

Views: 648

Answers (1)

Nirmi
Nirmi

Reputation: 356

It is returning byte size in the integer format

from buffer taking each integer and converting into hex worked for me also one more code change:

    self.t32_api.T32_ReadMemoryObj(buffer_handle, address_handle32, size)

In the code earlier I passed buffer rather than buffer_handle. After adding code to convert each byte into hex getting output: 00000000000000000400010000000002785634120000000000000000000000000000000000000000

Upvotes: 1

Related Questions