Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ctypes import *
- import sys
- if "linux" in sys.platform:
- OFFSET ={
- 'PhysicalObjectIndex': 0x10 # <- TODO
- }
- POINTERSIZE = 8
- elif "win" in sys.platform:
- OFFSET ={
- 'PhysicalObjectIndex': 0x10
- }
- POINTERSIZE = 4
- def pointerWalk(start, *offsets):
- ptr = start
- for offset in offsets:
- if ptr == 0:
- raise Exception('Attempt to dereference null!')
- ptr += offset
- ptr = c_void_p.from_address(ptr).value
- return ptr
- def getPhysicalObjectEngineAddress(pythonObject):
- if not hasattr(pythonObject, 'token'):
- raise Exception('Token missing from object!')
- tokenPythonAddress = id(pythonObject.token)
- return pointerWalk(tokenPythonAddress, 4 + POINTERSIZE, 0, 4)
- def getObjectId(obj):
- engineobj = getPhysicalObjectEngineAddress(obj)
- if engineobj == 0:
- raise Exception('object is null')
- return c_int32.from_address(engineobj + OFFSET['PhysicalObjectIndex']).value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement