This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# tinfo_calc_udt_aligns.py : Generate a struct type given a list of members with offsets | |
# | |
# First, create a simple uint32 tinfo. | |
uint32 = idaapi.tinfo_t() | |
uint32.create_simple_type(idaapi.BTF_UINT32) | |
# The udt_type_data_t struct holds information about struct types. | |
udt_data = idaapi.udt_type_data_t() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lazy object instantiation | |
class Lazy(object): | |
def __new__(cls, realcls, args, kwargs): | |
# Use the real class's __new__ to get a new object instance. | |
obj = realcls.__new__(realcls, *args, **kwargs) | |
# Replace the class with Lazy until reified. | |
obj.__class__ = cls | |
# Store info we need to reify object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [10]: import wilhelm as W | |
In [11]: W.initialize(W.Feature.PATH) | |
In [12]: func = W.ast.Function(idaapi.get_screen_ea()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Triggers a bug related to coroutines and stack frames. | |
# Run this in Python 3: | |
# $ python3 async_bug.py [bad] | |
# When the commandline argument "bad" is passed in, the bug is triggered, and the foo() coroutine never completes. | |
# | |
import asyncio | |
import sys | |
LOG = print |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Insert this into your idapythonrc.py file. | |
from PyQt5.QtWidgets import QApplication | |
import qasync | |
import asyncio | |
qapp = QApplication.instance() | |
# Requires qasync from here: https://github.com/zerotypic/qasync/tree/evloop_already_running, if not already merged | |
loop = qasync.QEventLoop(qapp, already_running=True) | |
asyncio.set_event_loop(loop) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class to(object): | |
def __init__(self, func): self.func = func | |
def __ror__(self, other): return self.func(other) | |
42 | to(hex) | to(print) |