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.

Revisions

  1. zeroxia created this gist Oct 21, 2024.
    23 changes: 23 additions & 0 deletions cdll_test.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #!/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()