Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@laixintao
Created March 15, 2020 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laixintao/7f37c5ee0ae663f9e54c1efd5cbe1bdc to your computer and use it in GitHub Desktop.
Save laixintao/7f37c5ee0ae663f9e54c1efd5cbe1bdc to your computer and use it in GitHub Desktop.
import ctypes
def deref(addr, typ):
return ctypes.cast(addr, ctypes.POINTER(typ))
deref(id(3), ctypes.c_int)[6] = 2
@laixintao
Copy link
Author

python -i magic.py
>>> 3 + 1
2
>>> 2 + 1
2
>>> 4 - 3
2
>>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment