# -*- coding: utf-8 -*- # # Part of ChipBench (AGPLv3). SPDX-FileCopyrightText: 2026 Starting Line Productions LLC # MakeFuncs.py -- create functions at hex addresses given as script args. # Usage: -postScript MakeFuncs.py 0x1234 0x0a07 ... from ghidra.program.model.address import AddressSet from ghidra.app.cmd.function import CreateFunctionCmd args = getScriptArgs() af = currentProgram.getAddressFactory() fm = currentProgram.getFunctionManager() for a in args: addr = af.getAddress(a[2:] if a.startswith("0x") else a) if addr is None: print("bad addr: %s" % a); continue if fm.getFunctionAt(addr) is not None: print("exists: %s" % addr); continue cmd = CreateFunctionCmd(addr) ok = cmd.applyTo(currentProgram, monitor) print("create %s -> %s" % (addr, ok)) print("MakeFuncs done")