Centralized Code Callback for Runtime Substitution

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing code optimization techniques, such as de-virtualization and pointer optimization, make it difficult to effectively remap or substitute code in runtime environments, limiting the effectiveness of swizzling and code callback technologies.

Innovation Solution

The implementation of a centralized callback function that allows multiple original functions to jump into and return from, enabling seamless code substitution by modifying machine code to jump into a single callback function or intermediate functions, which then route to target functions and manage arguments for proper return paths.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Speed

If code optimization techniques such as de-virtualization and pointer optimization are applied, then code execution speed is improved, but code remapping and substitution become difficult or impossible

Engineering Contradiction:
Improvecode execution speedVSAvoidcode remapping capability
Core Design Contradiction:
SpeedVSAdaptability or versatility

Solution Approach 1:

The patent applies preliminary action by inserting hook code into original functions before optimization occurs. The hook code establishes callback mechanisms and stores original function addresses in a lookup table, ensuring that remapping infrastructure is in place before de-virtualization and pointer optimization are applied. This allows the system to maintain both optimized execution and code substitution capability.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent uses an intermediary approach by introducing a callback function as a mediator between optimized code and the original function. When code substitution is needed, the hook redirects execution to the callback function, which then invokes the appropriate target function. This intermediary layer preserves the ability to remap code even after optimization techniques have been applied.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Adaptability or versatility

If multiple callback functions are created for multiple original functions, then code substitution flexibility is improved, but system complexity increases

Engineering Contradiction:
Improvecode substitution flexibilityVSAvoidsystem complexity
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent applies universality by creating a single callback function that can handle substitutions for multiple original functions. The callback function uses a lookup table to determine which target function to invoke based on the original function being hooked. This single universal callback replaces what would otherwise require multiple separate callback functions, reducing system complexity while maintaining substitution flexibility.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Solution Approach 2:

The patent merges multiple callback functions into a single unified callback function. By combining the substitution logic for multiple original functions into one callback, the system reduces the number of code elements to manage. The lookup table serves as a central coordination mechanism that routes to appropriate target functions, effectively merging multiple substitution paths into a single entry point.

Inventive Principle:
Principle #5Merging (Combining)

Data Source

PatentUS10761905B2Enhanced code callback
Publication Date: 2020.09.01 APPTIMIZE INC
  • US10761905B2 patent drawing
  • US10761905B2 patent drawing
  • US10761905B2 patent drawing

AI summary

Implementations are disclosed herein for enhancing swizzling technology. In at least one implementation, functions are hooked by modifying their machine code implementations to jump to a central callback function. The central callback function may then route to other target functions that serve to replace the hooked functions. In another implementation, the machine code implementations are modified to jump to intermediate functions. The intermediate functions invoke dispatch functions that can call into a central callback function. The central callback function may return to the hooked functions.