Skip to content

Instantly share code, notes, and snippets.

@zeroxia
Created October 21, 2024 03:15
Show Gist options
  • Save zeroxia/5c64f6e7ab92b971b71b650e20393831 to your computer and use it in GitHub Desktop.
Save zeroxia/5c64f6e7ab92b971b71b650e20393831 to your computer and use it in GitHub Desktop.
Python CDLL usage
#!/usr/bin/env python3
import logging
import ctypes
def init_logger():
logging_config = {
"format": "%(asctime)s %(levelname)-7s %(filename)s:%(lineno)-4d %(funcName)s -- %(message)s",
"datefmt": "%m-%d_%H:%M:%S",
"level": logging.INFO
}
logging.basicConfig(**logging_config)
init_logger()
def main():
libc = ctypes.CDLL('libc.so.6')
print(libc)
out = libc.time(None)
logging.info("type: {}".format(type(out)))
logging.info("value: {}".format(out))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment