0

I tried to copy data from python process with loadable kernel module (LKM) with the copy_from_user function it worked fine. When I wrote it on c program but when I copied the address of the python variable it didn't work.

This my code for finding the address.

x="message"
print(hex(id(x))
martineau
  • 119,623
  • 25
  • 170
  • 301
Daniel Haish
  • 140
  • 9
  • With the CPython interpreter, the value the built-in [`id()`](https://docs.python.org/3/library/functions.html#id) function returns the object's memory address. – martineau Jan 16 '20 at 20:20
  • `id` does not give you the address of *a variable*, it gives you the address of an object. Of course, this is an implementation detail because the purpose of the `id` function is to give you a unique integer for the lifetime of that object. It so *happens* that in CPython that integer is the address of the PyObject header. In any case, you are going to have to elaborate on exactly what you did and exactly what "didn't work" – juanpa.arrivillaga Jan 16 '20 at 20:21
  • What are you wanting to do with this address? It's possible to turn it back into a Python object, see [Is it possible to dereference variable id's?](https://stackoverflow.com/questions/15011674/is-it-possible-to-dereference-variable-ids). – martineau Jan 16 '20 at 20:27
  • ok i think that this is not possible but i thought that maybe there is some way to create low level variable in python – Daniel Haish Jan 16 '20 at 20:31

0 Answers0