Runtime Function Override for Legacy Code Testing

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Legacy source code in programming languages like C++ often lacks reflection, making it difficult to abstract dependencies and test specific parts of the code without modifying the source or setting up complex test environments.

Innovation Solution

A computer system is configured to override the original behavior of a function at runtime without changing its source code. This is achieved by identifying an override behavior, encoding replacement code, and manipulating memory addresses to execute the replacement code temporarily before restoring the original code.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Ease of operation

If source code modification is used to enable testing of legacy code, then testability is improved, but code integrity and reliability deteriorate

Engineering Contradiction:
ImprovetestabilityVSAvoidcode integrity
Core Design Contradiction:
Ease of operationVSReliability

Solution Approach 1:

The patent introduces an intermediary layer (runtime override mechanism) between the test framework and the legacy code. This intermediary allows testing functionality to be injected without modifying the original source code, thus maintaining code integrity while enabling comprehensive testing capabilities through runtime behavior overriding.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Manufacturing precision

If complex test environments are set up to test legacy code, then test coverage is improved, but system complexity deteriorate

Engineering Contradiction:
Improvetest coverageVSAvoidtest environment complexity
Core Design Contradiction:
Manufacturing precisionVSDevice complexity

Solution Approach 1:

The patent changes the parameter of code behavior at runtime rather than requiring complex test environment setups. By dynamically overriding function behaviors and return values during execution, the system achieves high test coverage through simple parameter modifications instead of complex environmental configurations.

Inventive Principle:
Principle #35Parameter changes

3Adaptability or versatility

If runtime code modification is performed to override function behavior, then flexibility and testability are improved, but system stability deteriorates

Engineering Contradiction:
Improveruntime flexibilityVSAvoidsystem stability
Core Design Contradiction:
Adaptability or versatilityVSStability of the object's composition

Solution Approach 1:

The patent performs preliminary actions by saving the original function behavior before overriding it at runtime. This preliminary preservation allows the system to maintain stability by enabling easy restoration of original behavior, thus reducing the risks associated with runtime modifications while maintaining flexibility during testing.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS12271748B2Changing program behavior at runtime
Publication Date: 2025.04.08 MICROSOFT TECHNOLOGY LICENSING LLC
  • US12271748B2 patent drawing
  • US12271748B2 patent drawing
  • US12271748B2 patent drawing

AI summary

A computer system is configured to override an original behavior of a function at runtime. Overriding the original behavior of the function at runtime includes identifying an override behavior for overriding the original behavior of the function, and encoding replacement code based on the override behavior. Further, a size of the replacement code is identified, and a first memory address of the function where code of the function is stored is also identified. The computer system then copies a block of code having the size of the replacement code from the first memory address to a second memory address, and copies the replacement code to the first memory address. After the replacement code is executed, copying the block of code stored at the second memory address back to the first memory address, restoring the code of the function.