In-memory modification of computer programs
First Claim
1. A method in a computer system for patching a segment of executable code at runtime under the control of the code segment, the code segment having a selected entry point, a patching section, and a patched section, the patching section for patching the patched section to change the contents of the patched section, comprising the steps of:
- (a) when the code segment is executed a first time at the selected entry point, executing at least one instruction to jump from the beginning of the patched section to a point external to the patched section and executing the patching section, wherein if the code segment is not executed the first time at the selected entry point, the patching section does not patch the patched section;
(b) when the patching section is executed, patching the patched section;
(c) changing at least one instruction to prevent the patching section from being executed again; and
(d) when the code segment is executed at the selected entry point after step (b), executing the patched section.
2 Assignments
0 Petitions
Accused Products
Abstract
The present invention provides a facility for performing self-patching of computer code in memory. The facility patches a segment of executable code at runtime under the control of the code segment. The code segment has a selected entry point, a patching section, and a patched section. The patching section is provided to patch the patched section in order to change the contents of the patched section. When the code segment is executed a first time at the selected entry point, execution jumps from the beginning of the patched section to a point beyond the patched section to execute the patching section. When the patching section is executed, the patching section patches the patched section. Finally, when the code segment is executed at the selected entry point after the patching section has patched the patch section, the patched section is executed rather than the patching section.
-
Citations
24 Claims
-
1. A method in a computer system for patching a segment of executable code at runtime under the control of the code segment, the code segment having a selected entry point, a patching section, and a patched section, the patching section for patching the patched section to change the contents of the patched section, comprising the steps of:
-
(a) when the code segment is executed a first time at the selected entry point, executing at least one instruction to jump from the beginning of the patched section to a point external to the patched section and executing the patching section, wherein if the code segment is not executed the first time at the selected entry point, the patching section does not patch the patched section;
(b) when the patching section is executed, patching the patched section;
(c) changing at least one instruction to prevent the patching section from being executed again; and
(d) when the code segment is executed at the selected entry point after step (b), executing the patched section. - View Dependent Claims (2, 3, 4, 5)
-
-
6. An article of computer-readable media having contents causing a computer system to patch a segment of executable code at runtime under the control of the code segment, the code segment having a selected entry point, a patching section, and a patched section, the patching section for patching the patched section to change the contents of the patched section, by performing the steps of:
-
(a) when the code segment is executed a first time at the selected entry point, executing at least one instruction to jump from the beginning of the patched section to a point external to the patched section and executing the patching section, wherein if the code segment is not executed the first time at the selected entry point, the patching section does not patch the patched section;
(b) when the patching section is executed, patching the patched section;
(c) changing at least one instruction to prevent the patched section from being executed again; and
(d) when the code segment is executed at the selected entry point after step (b), executing the patched section. - View Dependent Claims (7, 8, 9, 10)
-
-
11. A computer memory having executable code, comprising:
-
a patched section, which, when first executed, transfers control to a patching section; and
the patching section, which writes new instructions to the patched section, including at least one instruction that inhibits the transfer of control from the patched section to the patching section when the patched section is executed after the patching section writes the new instructions to the patched section. - View Dependent Claims (12, 13, 14, 15)
-
-
16. A computer system, comprising:
-
a memory containing self-patching executable code, comprising a patched section and a patching section, the patched section transferring control to the patching section when the patched section is first executed, the patching section writing new instructions to the patched section, including at least one instruction that inhibits the transfer of control from the patched section to the patching section when the patching section is executed after the patching section writes the new instructions to the patched section; and
a processor for executing the self-patching executable code. - View Dependent Claims (17, 18, 19, 20)
-
-
21. A method in a computer system for patching a portion of executable code when the code portion is executed, the code portion having an entry point, the method comprising the steps of:
-
executing the code portion at the entry point to self-patch the code portion by invoking a patching section a first time, and each time thereafter that the code portion is executed at the entry point before the patching section has executed completely, invoking the patching section another time;
each time the patching section is invoked, patching the patched code section; and
each time the code portion is executed at the entry point after the patching section has executed completely, invoking the patched code section, such that the patched code section is only invoked after the patched code section has been completely patched by the patching section, and such that the patching code section is only invoked until the patching section has completely patched the patching section. - View Dependent Claims (22)
-
-
23. A computer memory containing an executable code portion comprising:
-
a first section that is invoked each time the code portion is executed until the execution of the first section has completed for the first time, including being invoked at least one other time if the code portion is again executed and the first section has not completed, the first section patching the second section when the first section is invoked; and
a second section that is invoked each time the code portion is executed after the execution of the first section has completed for the first time, the second section being patched by the complete execution of the first section before the second section is invoked. - View Dependent Claims (24)
-
Specification