Virtual Function Replacement via Shim Module Pointer Adjustment

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current techniques for replacing virtual functions are time and resource intensive, and prone to errors due to changes in class layout and compiler settings, making them inefficient for software testing and other scenarios.

Innovation Solution

Intercepting calls to virtual functions and redirecting them to a shim module that adjusts the 'this' pointer, allowing the replacement function to access the object instance by using information from symbol data such as memory offset values.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If current techniques are used to replace virtual functions, then replacement can be achieved, but the process is time and resource intensive and prone to errors

Engineering Contradiction:
Improveerror-free replacementVSAvoidtime intensive process
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent introduces a shim module as an intermediary component between the virtual function call and the replacement function. The shim module intercepts the virtual function call, adjusts the 'this' pointer using symbol data (memory offset values), and then redirects the call to the replacement function. This intermediary mechanism enables reliable replacement without requiring direct manipulation of class layouts or compiler settings, thereby reducing errors and time consumption.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent performs preliminary action by extracting and storing symbol data (including memory offset values) about the virtual function's class layout before the replacement occurs. This symbol data is retrieved and used to calculate the correct pointer adjustment in advance, enabling the shim module to accurately redirect calls without needing to analyze the class layout at runtime, thus improving reliability and reducing processing time.

Inventive Principle:
Principle #10Preliminary action

2Reliability

If current techniques are used to replace virtual functions, then replacement can be achieved, but the process is prone to errors due to changes in class layout and compiler settings

Engineering Contradiction:
Improveerror-free replacementVSAvoidcomplexity due to class layout changes
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The shim module serves as a stable intermediary that abstracts the complexity of class layout changes. Instead of directly modifying class layouts or dealing with compiler settings, the shim module uses symbol data (memory offset values) to calculate pointer adjustments. This intermediary approach isolates the replacement logic from the complexities of class layout variations, ensuring reliable replacement across different compilation configurations.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent changes the parameter approach by using memory offset values from symbol data instead of direct class layout manipulation. The shim module retrieves symbol data that contains information about the virtual function's memory location and adjusts the 'this' pointer based on these parameter changes. This parameter-based approach is more robust against class layout changes and compiler settings than direct layout manipulation.

Inventive Principle:
Principle #35Parameter changes

3Ease of operation

If a shim module adjusts the 'this' pointer, then the replacement function can access the object instance, but the adjustment requires information from symbol data

Engineering Contradiction:
Improveease of pointer adjustmentVSAvoidinformation retrieval from symbol data
Core Design Contradiction:
Ease of operationVSLoss of information

Solution Approach 1:

The patent performs preliminary action by extracting and storing symbol data (including memory offset values) about the virtual function's class layout before the replacement occurs. This symbol data is retrieved and used to calculate the correct pointer adjustment in advance, enabling the shim module to accurately redirect calls without needing to analyze the class layout at runtime, thus improving reliability and reducing processing time.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The shim module acts as an intermediary that bridges the gap between the virtual function call and the replacement function. It uses symbol data as an intermediate information source to calculate the correct pointer adjustment, making the process more straightforward and less error-prone than direct pointer manipulation without symbol data support.

Inventive Principle:
Principle #24Intermediary (Mediator)

Data Source

PatentUS8990814B2Replacement of virtual functions
Publication Date: 2015.03.24 MICROSOFT TECHNOLOGY LICENSING LLC
  • US8990814B2 patent drawing
  • US8990814B2 patent drawing
  • US8990814B2 patent drawing

AI summary

Techniques are described for replacement of virtual functions. In one or more implementations, a call to a virtual function is intercepted and redirected to a shim module associated with a replacement function. The shim module is configured to adjust a pointer (e.g., a “this” pointer) for the virtual function. In at least some embodiments, the pointer can be adjusted based on information retrieved from symbol data for the virtual function. The replacement function can utilize the adjusted pointer to access an object instance associated with the virtual function. For example, the replacement function can use the adjusted pointer to access data and/or functionalities of the object instance.