I want to extract the integer address pointed to by the ctypes.c_char_p instance.
For example, in
>>> import ctypes >>> s = ctypes.c_char_p("hello") >>> s c_char_p(4333430692)
the value I would like to get, 4333430692 is the address of the string hello\0 in memory:
(lldb) x 4333430692 0x1024ae7a4: 68 65 6c 6c 6f 00 5f 70 00 00 00 00 05 00 00 00 hello._p........
I read the ctypes docs, but it doesn't seem to be that way. The closest is ctypes.addressof , but that only gives me a pointer indication.
The reason I want this is because I call some C functions that actually expect raw addresses encoded as integers (whose size is equal to the width of the pointer based on).
source share