@@ -438,6 +438,17 @@ declare namespace Process {
438438 */
439439 function getRangeByAddress ( address : NativePointerValue ) : RangeDetails ;
440440
441+ /**
442+ * Determines the code range of the function that `address` belongs to,
443+ * derived from the platform's unwind tables. A function whose body is split
444+ * across several ranges (e.g. a cold fragment) is represented by one range
445+ * per fragment; this returns the one covering `address`. Where no unwind
446+ * information is available — e.g. a leaf function, or a target lacking
447+ * unwind tables altogether — the containing symbol's bounds are used as a
448+ * best-effort fallback. Returns null if neither yields a range.
449+ */
450+ function findFunctionRange ( address : NativePointerValue ) : MemoryRange | null ;
451+
441452 /**
442453 * Enumerates memory ranges satisfying `specifier`.
443454 *
@@ -4321,6 +4332,121 @@ declare class Instruction {
43214332 toString ( ) : string ;
43224333}
43234334
4335+ /**
4336+ * Control-flow graph of a single function, with its basic blocks, edges, and
4337+ * dominator relationships.
4338+ */
4339+ declare class ControlFlowGraph {
4340+ /**
4341+ * Builds the control-flow graph of the function containing `entrypoint`.
4342+ *
4343+ * The function's bounds are resolved the same way as
4344+ * `Process.findFunctionRange()` — from the platform's unwind tables, with
4345+ * the containing symbol's bounds as a best-effort fallback — and its
4346+ * architecture and mode are determined automatically. On 32-bit ARM, a
4347+ * least significant bit set to 1 indicates Thumb.
4348+ *
4349+ * Throws an exception if the bounds of the function cannot be determined.
4350+ *
4351+ * @param entrypoint Address of the function to analyze.
4352+ */
4353+ constructor ( entrypoint : NativePointerValue ) ;
4354+
4355+ /**
4356+ * Address that the graph was built from.
4357+ */
4358+ entrypoint : NativePointer ;
4359+
4360+ /**
4361+ * Basic block that the function begins with.
4362+ */
4363+ entryBlock : BasicBlock ;
4364+
4365+ /**
4366+ * All basic blocks making up the graph.
4367+ */
4368+ blocks : BasicBlock [ ] ;
4369+
4370+ /**
4371+ * Looks up the basic block containing `address`. Returns null if no block
4372+ * covers it.
4373+ *
4374+ * @param address Address to look up.
4375+ */
4376+ findBlockContaining ( address : NativePointerValue ) : BasicBlock | null ;
4377+
4378+ /**
4379+ * Determines whether the block containing `a` dominates the block
4380+ * containing `b`, i.e. whether every path from the entry block to `b`
4381+ * passes through `a`.
4382+ *
4383+ * @param a Address whose block is the potential dominator.
4384+ * @param b Address whose block is potentially dominated.
4385+ */
4386+ dominates ( a : NativePointerValue , b : NativePointerValue ) : boolean ;
4387+
4388+ /**
4389+ * Enumerates the sites that dominate `target`, nearest first.
4390+ *
4391+ * @param target Address to find the dominating sites of.
4392+ */
4393+ enumerateDominatingSites ( target : NativePointerValue ) : DominatingSite [ ] ;
4394+ }
4395+
4396+ /**
4397+ * A basic block within a `ControlFlowGraph`. Not constructable; obtain
4398+ * instances through the graph.
4399+ */
4400+ declare class BasicBlock {
4401+ /**
4402+ * Address of the first instruction in the block.
4403+ */
4404+ start : NativePointer ;
4405+
4406+ /**
4407+ * Address just past the last instruction in the block.
4408+ */
4409+ end : NativePointer ;
4410+
4411+ /**
4412+ * Blocks that control may flow to from this block.
4413+ */
4414+ successors : BasicBlock [ ] ;
4415+
4416+ /**
4417+ * Blocks that control may flow to this block from.
4418+ */
4419+ predecessors : BasicBlock [ ] ;
4420+
4421+ /**
4422+ * Block that immediately dominates this one, or null for the entry block.
4423+ */
4424+ immediateDominator : BasicBlock | null ;
4425+
4426+ /**
4427+ * Instructions making up this block.
4428+ */
4429+ instructions : Instruction [ ] ;
4430+ }
4431+
4432+ /**
4433+ * A site that dominates a given target, as returned by
4434+ * `ControlFlowGraph#enumerateDominatingSites()`.
4435+ */
4436+ interface DominatingSite {
4437+ /**
4438+ * Instruction-aligned address that dominates the target.
4439+ */
4440+ address : NativePointer ;
4441+
4442+ /**
4443+ * Number of contiguous bytes at `address`, within a single range and with
4444+ * no incoming branch, that a redirect may overwrite without another
4445+ * control-flow edge landing inside the patched region.
4446+ */
4447+ capacity : number ;
4448+ }
4449+
43244450declare class X86Instruction extends Instruction {
43254451 /**
43264452 * Array of objects describing each operand.
0 commit comments