Enhanced code callback
AssigneeApptimize LLC
InventorsNancy Hua, James Brandon Koppel, Jeremy Nelson Orlow
Life of this patent
Estimating the term…
Abstract
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.
Claims19
An apparatus comprising:
- one or more non-transitory computer readable storage media;
- and
- program instructions stored on the one or more non-transitory computer readable storage media, wherein the program instructions, when executed by a processing system in an application runtime environment, direct the processing system to at least:
- modify a machine code implementation of an original function to hook into a stub file, modifying the machine code implementation comprising overwriting a portion of the machine code implementation of the original function in memory with new code of the stub file, the new code, when executed, triggering a programmatic jump into a callback function;
- when the original function is called, execute the new code that triggers the programmatic jump into the callback function;
- identify the original function modified post-compilation to hook into the stub file that calls into the callback function;
- store an identity of the original function;
- identify a path for returning to the original function based on the stored identity of the original function;
- identify a target function to run in-place of the original function and call into the target function, wherein the target function comprises a copy of the original function prior to modifications to hook into the stub file;
- and
- upon the target function completing, return to the original function via the path such that the original function and a program, routine, or application corresponding to the original function continue to run normally.
A method comprising:
- modifying machine code representative of multiple original functions to hook into a stub file, modifying the machine code by overwriting a portion of the machine code in memory with new code of the stub file, the new code, when executed, triggering a programmatic jump into a callback function;
- when at least one of the multiple original functions is called, executing the new code that triggers the programmatic jump into the callback function;
- tracking which original function of the multiple original functions jumped to the callback function when the callback function is called;
- storing an identity of the original function;
- identifying a path to return to the original function based on the stored identity of the original function;
- in response to the original function jumping to the callback function, identifying which target function of multiple target functions to call into, and calling the target function, wherein the target function comprises a copy of the original function prior to modifications to hook into the stub file;
- and
- when the target function returns to the callback function, returning to the original function via the path such that the original function and a program, routine, or application corresponding to the original function continue to run normally.
An apparatus comprising:
- one or more non-transitory computer readable storage media;
- a processing system operatively coupled with the one or more non-transitory computer readable storage media;
- and
- program instructions stored on the one or more non-transitory computer readable storage media that, when executed by the processing system, direct the processing system to at least:
- modify machine code representative of an original function to jump into an intermediate function instead of the original function when the original function is invoked by overwriting a portion of the machine code of the original function in memory with modified machine code that triggers a programmatic jump into the intermediate function;
- when the original function is invoked, execute the modified machine code to jump into the intermediate function;
- execute the intermediate function to identify and call a dispatch function, the dispatch function comprising a copy of the original function prior to modifications to jump into the intermediate function;
- store an identity of the original function;
- identify a path for returning to the original function based on the stored identity of the original function;
- and
- execute the dispatch function to dispatch to a callback function, wherein the callback function returns to the original function via the path.
Dependencies are inferred from the claim text.