CN103218241A - Method and device for patch loading - Google Patents
Method and device for patch loading Download PDFInfo
- Publication number
- CN103218241A CN103218241A CN2013101373194A CN201310137319A CN103218241A CN 103218241 A CN103218241 A CN 103218241A CN 2013101373194 A CN2013101373194 A CN 2013101373194A CN 201310137319 A CN201310137319 A CN 201310137319A CN 103218241 A CN103218241 A CN 103218241A
- Authority
- CN
- China
- Prior art keywords
- library
- patch
- address
- dynamic
- dynamic loading
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Landscapes
- Stored Programmes (AREA)
Abstract
本发明实施例提供一种补丁加载方法和装置,包括:将补丁文件加载至第一动态加载库中的补丁区;根据所述补丁文件在所述第一动态加载库中的相对地址以及所述第一动态加载库在第一进程中的地址,确定所述补丁文件在所述第一进程中的地址;其中,所述第一进程为加载所述第一动态加载库的进程;根据所述补丁文件在所述第一进程中的地址运行所述补丁文件。本发明实施例提供的补丁加载方法及装置,可不需修改待修正的动态加载库中的多条指令便可使进程由待修正处跳转,运行补丁文件中的正确内容,避免了修改待修正的动态加载库中多条指令引起的进程运行崩溃,提高了补丁加载的可靠性。
An embodiment of the present invention provides a patch loading method and device, including: loading a patch file into the patch area in the first dynamic loading library; according to the relative address of the patch file in the first dynamic loading library and the The address of the first dynamic loading library in the first process determines the address of the patch file in the first process; wherein, the first process is the process of loading the first dynamic loading library; according to the The address of the patch file in the first process runs the patch file. The patch loading method and device provided by the embodiments of the present invention can make the process jump from the place to be modified without modifying multiple instructions in the dynamic loading library to be modified, and run the correct content in the patch file, avoiding the need to modify the pending modification The crash of the process caused by multiple instructions in the dynamic loading library improves the reliability of patch loading.
Description
技术领域technical field
本发明实施例涉及计算机领域,尤其涉及一种补丁加载方法和装置。The embodiments of the present invention relate to the computer field, and in particular to a patch loading method and device.
背景技术Background technique
在现代化的工作生活中,通过计算机设备上的应用程序可高效率的帮助人们完成各种工作任务。应用程序是通过人工编译后安装在计算机设备上运行的,但人为的编写程序不可能十全十美,运行时会出现一定的缺陷,则可编写用于修复该缺陷的程序作为补丁,进程运行该应用程序时加载补丁,以保证进程可顺利运行。In the modern working life, the application programs on the computer equipment can efficiently help people complete various work tasks. The application program is manually compiled and installed on the computer device to run, but the artificially written program cannot be perfect, and there will be certain defects during operation, so the program for repairing the defect can be written as a patch, and the process runs the application program Load the patch from time to time to ensure that the process can run smoothly.
现有技术中,作为系统文件的动态加载库在进程运行时会被随机加载,当动态加载库中存在缺陷时,如动态加载库中的一个函数编写错误,则进程还需加载动态加载库的补丁,并将错误函数入口处的指令修改为跳转指令指向补丁中正确的函数,保证进程的正确运行。In the prior art, the dynamic loading library as a system file will be randomly loaded when the process is running. When there is a defect in the dynamic loading library, such as a function in the dynamic loading library is written incorrectly, the process still needs to load the dynamic loading library. patch, and modify the instruction at the entrance of the wrong function to a jump instruction to point to the correct function in the patch, so as to ensure the correct operation of the process.
但采用上述方法加载补丁时,动态加载库与补丁文件随进程加载,如果待修正的动态加载库对应的补丁文件与待修正的动态加载库在进程中的地址距离较远,则待修正的动态加载库中的多条原指令需修改为跳转指令,以完成函数的跳转,但多条原指令被修改易引起进程运行崩溃,降低了补丁加载的可靠性。However, when the above method is used to load the patch, the dynamic loading library and the patch file are loaded along with the process. If the address of the patch file corresponding to the dynamic loading library to be corrected is far from the Many original instructions in the loading library need to be modified into jump instructions to complete the function jump, but the modification of multiple original instructions will easily cause the process to crash and reduce the reliability of patch loading.
发明内容Contents of the invention
本发明实施例提供一种补丁加载方法和装置,以优化补丁加载过程,提高补丁加载的可靠性。Embodiments of the present invention provide a patch loading method and device, so as to optimize the patch loading process and improve the reliability of patch loading.
第一方面,本发明实施例提供一种补丁加载方法,包括:In the first aspect, the embodiment of the present invention provides a patch loading method, including:
将补丁文件加载至第一动态加载库中的补丁区;Loading the patch file into the patch area in the first dynamic loading library;
根据所述补丁文件在所述第一动态加载库中的相对地址以及所述第一动态加载库在第一进程中的地址,确定所述补丁文件在所述第一进程中的地址;其中,所述第一进程为加载所述第一动态加载库的进程;Determine the address of the patch file in the first process according to the relative address of the patch file in the first dynamic load library and the address of the first dynamic load library in the first process; wherein, The first process is a process that loads the first dynamic loading library;
根据所述补丁文件在所述第一进程中的地址运行所述补丁文件。Running the patch file according to the address of the patch file in the first process.
结合第一方面,第一实现方式中,所述第一动态加载库为目标文件的提供方提供的待修正的动态加载库;其中,所述目标文件用于生成所述补丁文件;或者,With reference to the first aspect, in the first implementation manner, the first dynamic loading library is a dynamic loading library to be corrected provided by the provider of the target file; wherein the target file is used to generate the patch file; or,
所述第一动态加载库与所述待修正的动态加载库在所述进程中的地址相邻。The first dynamic load library is adjacent to the address of the dynamic load library to be modified in the process.
结合第一方面或第一方面的第一实现方式,在第二实现方式中,所述补丁区与所述第一动态加载库的代码段相邻。With reference to the first aspect or the first implementation manner of the first aspect, in a second implementation manner, the patch area is adjacent to the code segment of the first dynamically loaded library.
结合第一方面至第一方面第二实现方式中的任意一种方式,在第三实现方式中,所述根据所述补丁文件与所述动态加载库中的相对地址以及所述动态加载库在所述第一进程中的地址,确定所述补丁文件在所述第一进程中的地址之前,还包括:In combination with any one of the first aspect to the second implementation manner of the first aspect, in the third implementation manner, according to the relative address between the patch file and the dynamic loading library and the location of the dynamic loading library The address in the first process, before determining the address of the patch file in the first process, further includes:
将加载所述补丁文件的所述第一动态加载库加载至多个进程中。Loading the first dynamic loading library loaded with the patch file into multiple processes.
结合第一方面至第一方面第二实现方式中的任意一种方式,在第四实现方式中,所述将补丁文件加载至第一动态加载库中的补丁区之前,还包括:In combination with any one of the first aspect to the second implementation of the first aspect, in the fourth implementation, before loading the patch file into the patch area in the first dynamic loading library, it further includes:
根据所述目标文件包括的字符确定信息替换表;determining an information replacement table according to the characters included in the target file;
根据所述目标文件的代码段和数据段,所述信息替换表以及动态加载库依赖信息生成所述补丁文件。The patch file is generated according to the code segment and data segment of the target file, the information replacement table and the dynamic loading library dependency information.
结合第一方面,在第五实现方式中,所述补丁文件在所述第一动态加载库中的相对地址具体为补丁文件内正确字符在所述第一动态加载库中的相对地址,所述第一动态加载库在所述第一进程中的地址具体为所述第一动态加载库内待修正字符在第一进程中的起始地址;With reference to the first aspect, in the fifth implementation manner, the relative address of the patch file in the first dynamic loading library is specifically the relative address of the correct character in the patch file in the first dynamic loading library, the The address of the first dynamic loading library in the first process is specifically the starting address of the character to be corrected in the first dynamic loading library in the first process;
则所述根据所述补丁文件在所述第一动态加载库中的相对地址以及所述第一动态加载库在所述第一进程中的地址,确定所述补丁文件在所述进程中的地址,包括:Then, according to the relative address of the patch file in the first dynamic load library and the address of the first dynamic load library in the first process, determine the address of the patch file in the process ,include:
当所述正确字符对应于所述待修正的动态加载库内的待修正字符时,根据所述补丁文件内正确字符在所述第一动态加载库内的相对地址和所述第一动态加载库在第一进程中的起始地址,获取所述补丁文件内正确字符在所述第一进程中的实际地址;When the correct character corresponds to the character to be corrected in the dynamic load library to be corrected, according to the relative address of the correct character in the patch file in the first dynamic load library and the first dynamic load library The starting address in the first process is to obtain the actual address of the correct character in the patch file in the first process;
当所述正确字符对应于非所述待修正的动态加载库内的字符时,根据所述动态记载库依赖信息调用显示加载接口,获取所述补丁文件内正确字符在所述第一进程中的实际地址。When the correct character corresponds to a character that is not in the dynamic loading library to be corrected, call the display loading interface according to the dependency information of the dynamic recording library, and obtain the correct character in the patch file in the first process physical address.
第二方面,本发明实施例提供一种补丁加载装置,其特征在于,包括:In a second aspect, an embodiment of the present invention provides a patch loading device, which is characterized in that it includes:
第一加载模块,用于将补丁文件加载至第一动态加载库中的补丁区;The first loading module is used to load the patch file into the patch area in the first dynamic loading library;
确定模块,用于根据所述补丁文件在所述第一动态加载库中的相对地址以及所述第一动态加载库在第一进程中的地址,确定所述补丁文件在所述第一进程中的地址;其中,所述第一进程为加载所述第一动态加载库的进程;A determining module, configured to determine that the patch file is in the first process according to the relative address of the patch file in the first dynamic load library and the address of the first dynamic load library in the first process address; wherein, the first process is a process that loads the first dynamically loaded library;
运行模块,用于根据所述补丁文件在所述第一进程中的地址运行所述补丁文件。A running module, configured to run the patch file according to the address of the patch file in the first process.
结合第二方面,在第一实现方式中,所述第一动态加载库为所述目标文件的提供方提供的待修正的动态加载库;其中,所述目标文件用于生成所述补丁文件;或者,With reference to the second aspect, in the first implementation manner, the first dynamic loading library is a dynamic loading library to be corrected provided by the provider of the target file; wherein the target file is used to generate the patch file; or,
所述第一动态加载库与所述待修正的动态加载库在所述进程中的地址相邻。The first dynamic load library is adjacent to the address of the dynamic load library to be modified in the process.
结合第二方面或第二方面第一实现方式,在第二实现方式中,所述补丁区与所述第一动态加载库的代码段相邻。With reference to the second aspect or the first implementation manner of the second aspect, in the second implementation manner, the patch area is adjacent to the code segment of the first dynamically loaded library.
结合第二方面至第二方面第二实现方式,在第三实现方式中,还包括:In combination with the second aspect to the second implementation manner of the second aspect, in the third implementation manner, it also includes:
第二加载模块,用于将加载所述补丁文件的所述第一动态加载库加载至多个进程中。The second loading module is configured to load the first dynamic loading library for loading the patch file into multiple processes.
结合第二方面至第二方面第二实现方式,在第四实现方式中,还包括:In combination with the second aspect to the second implementation manner of the second aspect, in the fourth implementation manner, it also includes:
生成模块,用于根据所述目标文件包括的字符确定信息替换表;A generating module, configured to determine an information substitution table according to the characters included in the target file;
还用于根据所述目标文件的代码段和数据段,所述信息替换表以及动态加载库依赖信息生成所述补丁文件。It is also used to generate the patch file according to the code segment and data segment of the target file, the information replacement table and the dynamic loading library dependency information.
结合第二方面,在第五实现方式中,所述补丁文件在所述第一动态加载库中的相对地址具体为所述补丁文件内正确字符在所述第一动态加载库内的相对地址,所述第一动态加载库在所述第一进程中的地址具体为所述第一动态加载库在第一进程中的起始地址;With reference to the second aspect, in a fifth implementation manner, the relative address of the patch file in the first dynamic loading library is specifically the relative address of the correct character in the patch file in the first dynamic loading library, The address of the first dynamic loading library in the first process is specifically the starting address of the first dynamic loading library in the first process;
当所述正确字符对应于所述待修正的动态加载库内的待修正字符时,所述确定模块具体用于根据所述补丁文件内正确字符在所述第一动态加载库内的相对地址和所述第一动态加载库内待修正字符在第一进程中的起始地址,获取所述补丁文件内正确字符在所述第一进程中的实际地址;When the correct character corresponds to the character to be corrected in the dynamic loading library to be corrected, the determining module is specifically configured to use the relative address and the relative address of the correct character in the patch file in the first dynamic loading library The initial address of the character to be corrected in the first process in the first dynamic loading library, and the actual address of the correct character in the patch file in the first process;
当所述正确字符对应于非所述待修正的动态加载库内的字符时,所述确定模块还用于根据所述动态记载库依赖信息调用显示加载接口,获取所述补丁文件内正确字符在所述第一进程中的实际地址。When the correct character corresponds to a character that is not in the dynamic loading library to be corrected, the determination module is also used to call the display loading interface according to the dynamic recording library dependency information, and obtain the correct character in the patch file. The actual address in the first process.
本实施例中,由于补丁区位于第一动态加载库中,则补丁文件可随待修正的动态加载库加载至进程中,则不需修改待修正的动态加载库中的多条指令便可使进程跳转至补丁区读取补丁文件,避免了修改待修正的动态加载库中多条指令引起的进程运行崩溃,提高了补丁加载的可靠性。In this embodiment, since the patch area is located in the first dynamic loading library, the patch file can be loaded into the process along with the dynamic loading library to be corrected, and it is not necessary to modify multiple instructions in the dynamic loading library to be modified. The process jumps to the patch area to read the patch file, which avoids the crash of the process caused by modifying multiple instructions in the dynamic loading library to be corrected, and improves the reliability of patch loading.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description These are some embodiments of the present invention. For those skilled in the art, other drawings can also be obtained according to these drawings without any creative effort.
图1为本发明补丁加载方法实施例一的流程图;Fig. 1 is the flowchart of Embodiment 1 of the patch loading method of the present invention;
图2为本发明补丁加载方法实施例二的流程图;FIG. 2 is a flow chart of Embodiment 2 of the patch loading method of the present invention;
图3为本发明实施例二进程内第一种补丁区位置示意图;Fig. 3 is a schematic diagram of the position of the first patch area in the process of the second embodiment of the present invention;
图4为本发明实施例二进程内第二种补丁区位置示意图;Fig. 4 is a schematic diagram of the position of the second patch area in the process of the second embodiment of the present invention;
图5为本发明补丁加载装置实施例一的结构示意图;5 is a schematic structural diagram of Embodiment 1 of the patch loading device of the present invention;
图6为本发明补丁加载装置实施例二的结构示意图。FIG. 6 is a schematic structural diagram of Embodiment 2 of the patch loading device of the present invention.
具体实施方式Detailed ways
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments It is a part of embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
图1为本发明补丁加载方法实施例一的流程图。如图1所示,本发明实施例中,执行补丁加载方法的执行主体可以是通信系统中的各种通信设备,例如:PC(personal computer,个人计算机)、服务器等终端设备中的补丁加载装置。该方法包括:FIG. 1 is a flow chart of Embodiment 1 of the patch loading method of the present invention. As shown in Fig. 1, in the embodiment of the present invention, the subject of executing the patch loading method may be various communication devices in the communication system, for example: a patch loading device in a terminal device such as a PC (personal computer, personal computer) or a server . The method includes:
S101,将补丁文件加载至第一动态加载库中的补丁区。S101. Load a patch file into a patch area in a first dynamic loading library.
当动态加载库中存在缺陷时,如动态加载库中的一个函数编写错误,则包含正确函数的补丁文件可修正存在缺陷的动态加载库。其中,将正确函数编译在目标文件中,再对目标文件进行处理生成可修正缺陷的补丁文件。When there is a defect in the dynamic loading library, such as a function writing error in the dynamic loading library, the patch file containing the correct function can correct the defective dynamic loading library. Wherein, the correct function is compiled into the target file, and then the target file is processed to generate a patch file capable of correcting defects.
当目标文件的制作方和待修正的动态加载库的制作方相同的情况时,目标文件编译人员在制作任何动态加载库时会在该动态加载库内留有一定的空间,用于当发现该动态加载库出现缺陷时,可将补丁文件加载至该空间内,即此情况下S101中所述的第一动态加载库为目标文件的提供方提供的待修正的动态加载库,该第一动态加载库中包括数据段、代码段和用于加载补丁文件的补丁区;或者,当目标文件的制作方和待修正的动态加载库的制作方不同的情况时,例如一个动态加载库由第一制作方提供,且通常在编译该动态加载库时未预留一定的空间,而第二制作方在使用该动态加载库时发现了缺陷,第二制作方编译目标文件用于修正该缺陷,根据目标文件生成补丁文件,并将补丁文件加载到一个第二制作方提供的独立的动态加载库内,该独立的动态加载库可作为第一动态加载库,但该第一动态加载库中仅包括补丁区,此情况下S101中所述的第一动态加载库与待修正的动态加载库在进程中的地址相邻。When the producer of the object file is the same as the producer of the dynamic loading library to be corrected, the compiler of the object file will leave a certain space in the dynamic loading library when making any dynamic loading library. When a defect occurs in the dynamic loading library, the patch file can be loaded into the space, that is, in this case, the first dynamic loading library described in S101 is a dynamic loading library to be corrected provided by the provider of the target file, and the first dynamic loading library The loading library includes data segments, code segments and patch areas for loading patch files; or, when the maker of the target file is different from the maker of the dynamic loading library to be corrected, for example, a dynamic loading library is created by the first Provided by the production party, and usually did not reserve a certain space when compiling the dynamic loading library, and the second production party found a defect when using the dynamic loading library, the second production party compiled the object file to correct the defect, according to The target file generates a patch file, and loads the patch file into an independent dynamic loading library provided by the second producer. This independent dynamic loading library can be used as the first dynamic loading library, but the first dynamic loading library only includes In the patch area, in this case, the address of the first dynamic loading library described in S101 is adjacent to the address in the process of the dynamic loading library to be corrected.
S102,根据补丁文件在第一动态加载库中的相对地址以及第一动态加载库在第一进程中的地址,确定补丁文件在第一进程中的地址。S102. Determine the address of the patch file in the first process according to the relative address of the patch file in the first dynamic load library and the address of the first dynamic load library in the first process.
上述第一进程为加载第一动态加载库的进程,可理解为在实际中加载了该动态加载库的任意进程;而对于未加载至任意进程中的一个动态加载库来说,编译该动态加载库的各条指令依次位于该动态加载库内各行,可以理解为,各行指令位于该动态加载库中的位置即为相对地址,以位于该动态加载库中第一行的指令为例,其相对地址以16进制记为0000,当该动态加载库被加载至进程中,且加载的空间为进程中的地址4000至地址40FF(F在16进制计数中表示15),则上述第一行的指令在进程中的地址即为4000,可将地址4000看作上述第一行的指令在进程中的实际地址,则补丁文件被加载至补丁区,并随该第一动态加载库加载至第一进程中,为使该补丁文件可被进程运行,则补丁加载装置还需根据补丁文件内用于修正缺陷的正确字符进行重定位以确定进程中正确字符的实际地址。The above-mentioned first process is the process of loading the first dynamic loading library, which can be understood as any process that actually loads the dynamic loading library; and for a dynamic loading library that is not loaded into any process, compiling the dynamic loading Each instruction of the library is located in each line of the dynamic loading library in turn. It can be understood that the position of each line of instruction in the dynamic loading library is the relative address. Taking the instruction located in the first line of the dynamic loading library as an example, its relative address The address is recorded as 0000 in hexadecimal. When the dynamic loading library is loaded into the process, and the loaded space is from address 4000 to address 40FF in the process (F means 15 in hexadecimal), then the first line above The address of the instruction in the process is 4000, and the address 4000 can be regarded as the actual address of the instruction in the first line above in the process, then the patch file is loaded into the patch area, and loaded into the first dynamic load library along with the first In a process, in order to make the patch file runnable by the process, the patch loading device needs to relocate according to the correct character used to correct the defect in the patch file to determine the actual address of the correct character in the process.
当上述第一动态加载库为目标文件的提供方提供的待修正的动态加载库时,正确字符在第一动态加载库的相对地址0060,以及待修正的动态加载库在进程中的起始的实际地址4000,则确定补丁文件中正确字符在进程中的实际地址4060;When the above-mentioned first dynamic load library is the dynamic load library to be corrected provided by the provider of the target file, the correct character is at the relative address 0060 of the first dynamic load library, and the initial address of the dynamic load library to be corrected in the process Actual address 4000, then determine the actual address 4060 of the correct character in the patch file in the process;
当第一动态加载库与待修正的动态加载库在进程中的地址相邻,且已知正确字符在第一动态加载库的相对地址0060,待修正的动态加载库在进程中占用的空间地址为4000至5FFF,由于第一动态加载库与待修正的动态加载库在进程中的地址相邻,则第一动态加载库在进程中占用的空间起始地址为6000,从而可确定正确字符在进程中的实际地址为6060。由此可知,根据补丁文件中正确字符的相对地址和第一动态加载库在进程中的实际地址,便可在待修正的动态加载库内待修正处给出指向补丁文件中正确字符的实际地址的跳转指令。When the first dynamic load library is adjacent to the address of the dynamic load library to be corrected in the process, and the correct character is known to be at the relative address 0060 of the first dynamic load library, the address of the space occupied by the dynamic load library to be corrected in the process is 4000 to 5FFF, since the address of the first dynamic loading library is adjacent to the address of the dynamic loading library to be corrected in the process, the starting address of the space occupied by the first dynamic loading library in the process is 6000, so that it can be determined that the correct character is in The actual address in the process is 6060. It can be seen that, according to the relative address of the correct character in the patch file and the actual address of the first dynamic loading library in the process, the actual address pointing to the correct character in the patch file can be provided at the place to be corrected in the dynamic loading library to be corrected jump instruction.
S103,根据补丁文件在第一进程中的地址运行补丁文件。S103. Run the patch file according to the address of the patch file in the first process.
具体以补丁文件用于修正动态加载库中的错误函数为例,补丁文件被加载至位于进程中的待修正的动态加载库的补丁区时,进程根据待修正的动态加载库中错误函数入口处的跳转指令跳转至补丁文件中正确函数入口处的正确字符,并按照正确函数内各个指令依次运行。Specifically, take the patch file used to correct the error function in the dynamic loading library as an example. When the patch file is loaded into the patch area of the dynamic loading library to be corrected in the process, the process will The jump instruction jumps to the correct character at the entry of the correct function in the patch file, and runs in sequence according to each instruction in the correct function.
本实施例中,由于补丁区可与待修正的动态加载库中的代码段相邻,或作为补丁区的第一动态加载库与待修正的动态加载库相邻,从而进程将补丁文件加载至进程中待修正的动态加载库内与代码段相邻的补丁区或与待修正的动态加载库相邻的第一动态加载库后,则可不需修改待修正的动态加载库中的多条指令便可使进程跳转至补丁区运行补丁文件内的正确内容,避免了修改待修正的动态加载库中多条指令引起的进程运行崩溃,提高了补丁加载的可靠性。In this embodiment, because the patch area can be adjacent to the code segment in the dynamic loading library to be corrected, or the first dynamic loading library as the patch area is adjacent to the dynamic loading library to be corrected, so that the process loads the patch file into the process After the patch area adjacent to the code segment in the dynamic loading library to be modified or the first dynamic loading library adjacent to the dynamic loading library to be modified, the process can be made without modifying multiple instructions in the dynamic loading library to be modified. Jump to the patch area to run the correct content in the patch file, avoiding the process crash caused by modifying multiple instructions in the dynamic loading library to be corrected, and improving the reliability of patch loading.
图2为本发明补丁加载方法实施例二的流程图。如图2所示,该方法包括:FIG. 2 is a flow chart of Embodiment 2 of the patch loading method of the present invention. As shown in Figure 2, the method includes:
S201,分析目标文件和待修正的动态加载库。S201, analyzing the target file and the dynamically loaded library to be corrected.
S202,根据目标文件包括的字符确定信息替换表。S202. Determine an information replacement table according to the characters included in the target file.
上述S202与下述S203可由制作补丁文件的第三方执行,也可由集成制作补丁文件功能的补丁加载装置执行,另外若动态加载库需加载的补丁文件已完成制作,则动态加载库加载补丁文件时直接由S204开始,若补丁文件为完成制作,则在实现加载可修正待修正动态加载库中缺陷的补丁文件时,则由S201处开始执行。在本实施例中以补丁加载装置为例,则补丁加载装置的制作侧分析目标文件和待修正的动态加载库,其中待修正的动态加载库的缺陷以错误函数为例,由于目标文件中表示正确函数的名称与错误函数名称一致,即目标文件与存在缺陷的、待修正的动态加载库之间具备关联性,则补丁加载装置可获知该目标文件中的正确函数对应替换的动态加载库中的错误函数,从而补丁加载装置可确定相关加载信息,该相关加载信息包括信息替换表、动态加载库依赖信息表等,则补丁加载装置并依据目标文件的数据段和代码段及相关加载信息生成补丁文件。The above-mentioned S202 and the following S203 can be executed by a third party that makes a patch file, or can be executed by a patch loading device that integrates the function of making a patch file. In addition, if the patch file to be loaded by the dynamic loading library has been made, then when the dynamic loading library loads the patch file Directly start from S204, if the patch file is not completed, when the patch file that can correct the defect in the dynamic loading library to be corrected is realized, the execution starts from S201. In this embodiment, taking the patch loading device as an example, the production side of the patch loading device analyzes the target file and the dynamic loading library to be corrected, wherein the defect of the dynamic loading library to be corrected is an example of an error function, because it is expressed in the target file The name of the correct function is consistent with the name of the wrong function, that is, there is a correlation between the object file and the defective dynamic loading library to be corrected, then the patch loading device can know that the correct function in the object file corresponds to the replacement dynamic loading library error function, so that the patch loading device can determine the relevant loading information, the relevant loading information includes an information replacement table, a dynamic loading library dependency information table, etc., and then the patch loading device generates the patch file.
具体的,待修正的动态加载库中的缺陷以赋值错误的字符为例,在目标文件中,正确的字符与待修正的动态加载库中待修正字符一致(都为k),但补丁文件中正确字符k的正确赋值为3000,而待修正的动态加载库中待修正字符的赋值为3500,则进程不再根据待修正字符运行,直接根据跳转指令指向的补丁文件正确字符的正确赋值运行,即补丁文件中的正确字符替换了掉待修正动态加载库中的待修正字符,由此可知,信息替换表中的替换信息“字符k”,告知补丁加载装置的加载侧,待修正的动态加载库中需要替换的信息。Specifically, the defect in the dynamic loading library to be corrected takes the wrongly assigned character as an example. In the target file, the correct character is consistent with the character to be corrected in the dynamic loading library to be corrected (both are k), but in the patch file The correct assignment of the correct character k is 3000, and the assignment of the character to be corrected in the dynamic loading library to be corrected is 3500, the process will no longer run according to the character to be corrected, but directly run according to the correct assignment of the correct character in the patch file pointed to by the jump instruction , that is, the correct character in the patch file replaces the character to be corrected in the dynamic loading library to be corrected. It can be seen from this that the replacement information "character k" in the information replacement table informs the loading side of the patch loading device that the dynamic character to be corrected Load the information that needs to be replaced in the library.
更具体的,缺陷以错误函数为例,当补丁加载装置的制作侧发现待修正的动态加载库中错误函数的名称为字符A,目标文件中正确的函数的名称同样为字符A,则补丁加载装置的制作侧比较分析目标文件和待修正的动态加载库,确定出信息替换表,该信息替换表中包含的一种替换信息即为函数名称字符A,则补丁文件加载装置的加载侧加载该补丁文件时可根据该信息替换表获知待修正的动态加载库中的函数A(构成该函数的多条指令及参数)需被补丁文件中的函数A(构成该函数的多条指令及参数)替换。More specifically, the defect takes the wrong function as an example. When the production side of the patch loading device finds that the name of the wrong function in the dynamic loading library to be corrected is the character A, and the name of the correct function in the target file is also the character A, the patch loading The production side of the device compares and analyzes the target file and the dynamic loading library to be corrected, and determines the information replacement table. One type of replacement information contained in the information replacement table is the function name character A, and the loading side of the patch file loading device loads the When patching the file, it can be known that the function A (multiple instructions and parameters constituting the function) in the dynamic loading library to be corrected needs to be replaced by the function A (composing the multiple instructions and parameters constituting the function) in the patch file according to the information replacement table. replace.
S203,根据目标文件的代码段和数据段,信息替换表以及动态加载库依赖信息生成补丁文件。S203. Generate a patch file according to the code segment and data segment of the target file, the information replacement table, and the dependency information of the dynamically loaded library.
补丁文件的代码段和数据段用于修正动态加载库缺陷;具体的,补丁文件的结构可如表1所示:The code segment and data segment of the patch file are used to correct the defects of the dynamic loading library; specifically, the structure of the patch file can be shown in Table 1:
表1Table 1
表中段信息表用于说明该补丁文件中各个段(例如代码段、数据段等)的类型、大小、起始位置等;信息替换表用于说明待修正的动态加载库中需要被替换的信息;另外,目标文件中用于修正动态加载库缺陷的代码段和数据段中会调用其他动态加载库中的字符,因此补丁文件中还包括用于说明调用字符的字符串表及说明这些字符所属的其他动态加载库的动态加载库依赖信息,例如,待修正的动态加载库为M,目标文件代码段中调用了字符C,而该调用字符C在动态加载库N中被定义,而调用字符C在动态加载库N中被定义了类型、赋值等,则运行该补丁文件时需根据动态加载库N中对C的定义进行正确的运行,因此补丁文件中还包括动态加载库依赖信息,该动态加载库依赖信息包括动态加载库N的名称、长度等信息,则补丁加载装置的加载侧根据动态加载库依赖信息可控制进程在加载补丁文件至动态加载库M的补丁区时,已将依赖的动态加载库N加载至进程中,使进程在运行补丁文件读取调用字符C时,可根据进程中动态加载库N中调用字符C所属的实际地址,获取依赖的动态加载库N中对字符C的定义、赋值等。The segment information table in the table is used to explain the type, size, starting position, etc. of each segment (such as code segment, data segment, etc.) in the patch file; the information replacement table is used to describe the information that needs to be replaced in the dynamic loading library to be corrected ; In addition, the code segment and data segment used to correct the defects of the dynamic loading library in the target file will call characters in other dynamic loading libraries, so the patch file also includes a string table for explaining the calling characters and indicating that these characters belong to The dynamic loading library dependency information of other dynamic loading libraries, for example, the dynamic loading library to be corrected is M, the character C is called in the code segment of the object file, and the calling character C is defined in the dynamic loading library N, and the calling character C is defined in type, assignment, etc. in the dynamic loading library N. When running the patch file, it needs to run correctly according to the definition of C in the dynamic loading library N. Therefore, the patch file also includes the dynamic loading library dependency information. The dynamic loading library dependency information includes information such as the name and length of the dynamic loading library N, and the loading side of the patch loading device can control the process according to the dynamic loading library dependency information. When loading the patch file to the patch area of the dynamic loading library M, the dependent The dynamic loading library N loaded in the process, so that when the process runs the patch file to read the calling character C, it can obtain the corresponding character in the dynamically loading library N that depends on it according to the actual address of the calling character C in the dynamic loading library N in the process. C definition, assignment, etc.
另外,补丁文件中的重定位信息具体定义了被调用字符及替换信息所在位置的段类型及相对地址,则在运行补丁文件时,补丁加载装置可根据重定位信息中的相对地址及待修正的动态加载库在进程中的地址,获取替换信息在进程中的实际地址,并结合段类型,采用相应的跳转指令指向替换信息所在的实际地址;另外对于调用字符则可调用显示加载接口获取依赖动态加载库中定义该调用字符的实际地址,用以完成补丁文件的运行。In addition, the relocation information in the patch file specifically defines the segment type and relative address of the called character and the location of the replacement information, then when running the patch file, the patch loading device can use the relative address in the relocation information and the location to be corrected Dynamically load the address of the library in the process, obtain the actual address of the replacement information in the process, and combine the segment type, use the corresponding jump instruction to point to the actual address of the replacement information; in addition, for the call character, you can call the display loading interface to obtain the dependency The actual address of the call character is defined in the dynamic loading library to complete the operation of the patch file.
S204,将补丁文件加载至第一动态加载库中的补丁区。S204. Load the patch file into the patch area in the first dynamic loading library.
在本实施例中,所述补丁区可以为第一动态加载库的一部分,即当第一动态加载库为目标文件的提供方提供的待修正的动态加载库时,目标文件的提供方已使用编译字段如section(“.text”)在待修正的动态加载库中预留一个与待修正的动态加载库中的代码段紧邻的区域作为补丁区,该区域可用全局数组定义,并且补丁区对应的全局数组名与该动态加载库关联,则该动态加载库中包括数据段、代码段和用于加载补丁文件的补丁区,由于待修正的动态加载库中代码段与补丁区紧邻,则在运行时,补丁加载装置可修改代码段中的一条指令作为跳转指令,便可指向补丁区中用于修正缺陷的代码正确字符处;In this embodiment, the patch area may be a part of the first dynamic loading library, that is, when the first dynamic loading library is a dynamic loading library to be corrected provided by the provider of the target file, the provider of the target file has used Compiled fields such as section (“.text”) reserve an area adjacent to the code segment in the dynamic loading library to be modified as a patch area in the dynamic loading library to be modified. This area can be defined by a global array, and the patch area corresponds to The global array name of the dynamic loading library is associated with the dynamic loading library, then the dynamic loading library includes the data segment, code segment and patch area for loading the patch file. Since the code segment in the dynamic loading library to be corrected is adjacent to the patch area, then in When running, the patch loading device can modify an instruction in the code segment as a jump instruction, which can point to the correct character of the code used to correct the defect in the patch area;
或者,补丁区可用一个独立的第一动态加载库实现,即待修正的动态加载库为非目标文件的提供方提供时,该第一动态加载库由目标文件的提供方提供,且该第一动态加载库与待修正的动态加载库关联,并与该待修正的动态加载库在进程中的地址相邻,具体的,其中第一动态加载库可使用全局数组定义该动态加载库中的全部空间作为加载补丁文件的补丁区,则第一动态加载库中仅包括补丁区,并且补丁区对应的全局数组名与需补丁文件修正的动态加载库关联,则补丁加载装置可控制需补丁文件修正的动态加载库与作为补丁区的动态加载库在进程中的地址相邻,以使补丁区与待修正的动态加载库中的代码段的在进程中的地址相差较小,则补丁加载装置可仅修改待修正的动态加载库中代码段中的一条指令作为跳转指令,便可指向补丁文件中用于修正动态加载库缺陷的代码入口处地址。Or, the patch area can be realized by an independent first dynamic loading library, that is, when the dynamic loading library to be corrected is provided by the provider of the non-target file, the first dynamic loading library is provided by the provider of the target file, and the first dynamic loading library is provided by the provider of the target file. The dynamic loading library is associated with the dynamic loading library to be modified, and is adjacent to the address of the dynamic loading library to be modified in the process. Specifically, the first dynamic loading library can use a global array to define all the dynamic loading libraries in the dynamic loading library. Space is used as the patch area for loading patch files, then only the patch area is included in the first dynamic loading library, and the global array name corresponding to the patch area is associated with the dynamic loading library that needs patch file correction, then the patch loading device can control the patch file correction The address of the dynamic loading library in the process is adjacent to the dynamic loading library as the patch area, so that the address difference in the process of the code segment in the patch area and the dynamic loading library to be corrected is small, then the patch loading device can Only one instruction in the code segment in the dynamic loading library to be corrected is modified as a jump instruction, which can point to the address of the code entry point for correcting the defect of the dynamic loading library in the patch file.
通常一条跳转指令所控制的跳转距离存在限制,若补丁区与动态加载库中的代码段距离较远,则需修改多条指令以指向补丁区中用于修正动态加载库缺陷的代码入口处地址,易使进程操作崩溃,引起风险,而本实施例中补丁区与动态加载库的代码段紧邻或距离较小,避免长距离跳转,可仅修改一条指令指向补丁区中用于修正动态加载库缺陷的代码入口处地址,具有一定的可靠性。Usually, the jump distance controlled by a jump instruction is limited. If the patch area is far away from the code segment in the dynamic loading library, multiple instructions need to be modified to point to the code entry in the patch area for correcting the defect of the dynamic loading library. address, it is easy to cause the process operation to crash, causing risks. In this embodiment, the patch area and the code segment of the dynamic loading library are close to each other or the distance is small to avoid long-distance jumps. Only one instruction can be modified to point to the patch area for correction The code entry address of the dynamic loading library defect has certain reliability.
S205,将加载补丁文件的第一动态加载库加载至进程中。S205. Load the first dynamic loading library for loading the patch file into the process.
同一个动态加载库可被多个进程使用,则当待修正的动态加载库需要被多个进程使用时,则加载补丁文件的第一动态加载库加载至多个进程中。其中,在执行S205时,加载补丁文件的第一动态加载库可以为包含代码段、数据段及补丁区的第一动态加载库;或者也可以为仅包含补丁区的动态加载库,并且该动态加载库与待修正的动态加载库在进程中的地址相邻。The same dynamic loading library can be used by multiple processes, and when the dynamic loading library to be corrected needs to be used by multiple processes, the first dynamic loading library that loads the patch file is loaded into multiple processes. Wherein, when executing S205, the first dynamic loading library that loads the patch file may be the first dynamic loading library that includes code segments, data segments, and patch areas; or it may also be a dynamic loading library that only includes patch areas, and the dynamic The load library is adjacent to the address in the process of the dynamic load library to be modified.
具体的,图3为本发明实施例二中进程内第一种补丁区位置示意图。如图3所示,补丁区作为第一动态加载库内的一部分被加载至进程中;图4为本发明实施例二中进程内第二种补丁区位置示意图。如图4所示,一个独立的第一动态加载库作为补丁区,并与待修正的动态加载库在进程中地址相邻。Specifically, FIG. 3 is a schematic diagram of the position of the first patch area in the process in the second embodiment of the present invention. As shown in FIG. 3 , the patch area is loaded into the process as a part of the first dynamic loading library; FIG. 4 is a schematic diagram of the position of the second type of patch area in the process in the second embodiment of the present invention. As shown in FIG. 4 , an independent first dynamic loading library is used as a patch area, and is adjacent to the address of the dynamic loading library to be corrected in the process.
另外,由于补丁文件位于待修正的动态加载库内,即第一动态加载库为目标文件的提供方提供的待修正的动态加载库,或者补丁加载装置可控制作为补丁区的独立的第一动态加载库与待修正的动态加载库相邻,则补丁区内正确字符(将位于补丁文件内的各变量、名称字符、调用字符及相关指令等在本实施例中统称为正确字符)对于第一动态加载库的相对地址不变,则对于多个不同的进程加载的同一个待修正的动态加载库,仍然可使用同一个补丁文件修正,仅在运行补丁文件时根据第一动态加载库所在进程的起始地址及补丁文件在第一动态加载库中的相对地址,相应的在待修正字符处添加或替换的跳转指令指向补丁区正确字符所在的进程中的实际地址即可,不需根据待修正的动态加载库所在的不同的进程,加载不同的补丁文件,精简了补丁加载装置对补丁文件的管理机制,提高了工作效率。In addition, since the patch file is located in the dynamic loading library to be modified, that is, the first dynamic loading library is the dynamic loading library to be modified provided by the provider of the target file, or the patch loading device can control the independent first dynamic loading library as the patch area. The loading library is adjacent to the dynamic loading library to be corrected, then the correct characters in the patch area (variables, name characters, call characters and related instructions in the patch file are collectively referred to as correct characters in this embodiment) for the first If the relative address of the dynamic loading library remains unchanged, the same dynamic loading library to be modified loaded by multiple different processes can still be corrected by using the same patch file, only according to the process where the first dynamic loading library is located when running the patch file The starting address of the patch file and the relative address of the patch file in the first dynamic loading library, the corresponding jump instruction added or replaced at the character to be modified can point to the actual address in the process where the correct character in the patch area is located. Different processes of the dynamic loading library to be corrected load different patch files, which simplifies the management mechanism of the patch loading device for patch files and improves work efficiency.
S206,根据补丁文件在第一动态加载库中的相对地址以及第一动态加载库在第一进程中的起始地址,确定补丁文件在第一进程中的地址。S206. Determine the address of the patch file in the first process according to the relative address of the patch file in the first dynamic load library and the starting address of the first dynamic load library in the first process.
在此需要说明的是,以完整文件的范畴来说,本实施例涉及的文件可分为动态加载库和补丁文件,但动态加载库和补丁文件在进程中的运行是按照动态加载库和补丁文件中各个指令、字符去运行的,因此,可以理解的,上述补丁文件在第一动态加载库中的相对地址具体为补丁文件内正确字符在所述第一动态加载库内的相对地址,第一动态加载库在所述第一进程中的地址具体为第一动态加载库在第一进程中的起始地址,举例来说,补丁文件中的拥有正确赋值的字符k用于替换第一动态加载库内拥有错误赋值的字符k,则根据补丁文件中拥有正确赋值的字符k在第一动态加载库中的相对地址(0400)以及第一动态加载库在进程中的起始地址(4800),确定补丁文件中拥有正确赋值的字符k在进程中的地址(4C00)。What needs to be explained here is that, in the category of complete files, the files involved in this embodiment can be divided into dynamic loading libraries and patch files, but the operation of dynamic loading libraries and patch files in the process is based on the dynamic loading library and patch files. Each command and character in the file go to run. Therefore, it can be understood that the relative address of the above-mentioned patch file in the first dynamic loading library is specifically the relative address of the correct character in the patch file in the first dynamic loading library. The address of a dynamic loading library in the first process is specifically the starting address of the first dynamic loading library in the first process. For example, the character k with the correct assignment in the patch file is used to replace the first dynamic loading library. If there is an incorrectly assigned character k in the loading library, then according to the relative address (0400) of the correctly assigned character k in the patch file in the first dynamic loading library and the starting address of the first dynamic loading library in the process (4800) , determine the address (4C00) of the character k in the process that has the correct assignment in the patch file.
更具体的,补丁文件中的多个正确字符,一些正确字符与待修正字符对应,如上述拥有正确赋值的字符k,这种正确字符也称为相对字符;另一些正确字符为对应于非待修正动态加载库内的字符,例如调用的其他动态加载库中的调用字符C,也称为绝对字符;则当正确字符对应于所述待修正动态加载库内的待修正字符时,根据补丁文件内正确字符在第一动态加载库内的相对地址和第一动态加载库在第一进程中的起始地址,获取补丁文件内正确字符在第一进程中的实际地址;具体过程如上述S102中所述,在此不再赘述。More specifically, among the multiple correct characters in the patch file, some correct characters correspond to the characters to be corrected, such as the above-mentioned character k with correct assignment, this correct character is also called a relative character; Correct the characters in the dynamic loading library, such as the calling character C in other dynamic loading libraries called, also known as absolute characters; then when the correct character corresponds to the character to be corrected in the dynamic loading library to be corrected, according to the patch file The relative address of the correct character in the first dynamic loading library and the starting address of the first dynamic loading library in the first process obtain the actual address of the correct character in the patch file in the first process; the specific process is as in the above-mentioned S102 mentioned, and will not be repeated here.
当所述正确字符对应于非待修正动态加载库内的字符时,根据动态加载库依赖信息调用显示加载接口,获取所述补丁文件内正确字符在所述第一进程中的地址。When the correct character corresponds to a character not in the dynamic loading library to be modified, call the display loading interface according to the dynamic loading library dependency information, and obtain the address of the correct character in the patch file in the first process.
具体的,根据动态加载库依赖信息调用显示加载接口,获取补丁文件包含的绝对字符在所在进程中的实际地址,绝对字符对应于非待修正的动态加载库内的字符,例如补丁文件调用的上述动态加载库N中的字符C,则补丁加载装置根据动态加载库依赖信息获知字符C所属的动态加载库N,并通过调用显示加载接口确定动态加载库N中字符C在进程中的实际地址。Specifically, call the display loading interface according to the dependency information of the dynamic loading library, and obtain the actual address of the absolute character contained in the patch file in the process where the absolute character corresponds to the character in the dynamic loading library that is not to be corrected, such as the above-mentioned characters called by the patch file The character C in the dynamic loading library N, then the patch loading device obtains the dynamic loading library N to which the character C belongs according to the dynamic loading library dependency information, and determines the actual address of the character C in the dynamic loading library N in the process by calling the display loading interface.
S207,根据补丁文件在第一进程中的地址运行补丁文件。S207. Run the patch file according to the address of the patch file in the first process.
具体的,补丁文件在进程中运行时,补丁加载装置根据补丁文件内的重定位信息,修改了存在缺陷的待修正字符处的一条指令作为跳转指令,该跳转指令指向补丁区中补丁文件内的正确字符位于进程的实际地址,则进程可根据该跳转指令指向的补丁文件中的正确字符运行。Specifically, when the patch file is running in the process, the patch loading device modifies an instruction at the defective character to be corrected according to the relocation information in the patch file as a jump instruction, and the jump instruction points to the patch file in the patch area. If the correct character in the jump instruction is located at the actual address of the process, the process can run according to the correct character in the patch file pointed to by the jump instruction.
本实施例中,由于补丁区位于第一动态加载库中,则补丁文件可随待修正的动态加载库加载至进程中,则不需修改待修正的动态加载库中的多条指令便可使进程跳转至补丁区读取补丁文件,避免了修改待修正的动态加载库中多条指令引起的进程运行崩溃,并且补丁文件中包含了信息替换表、动态加载库依赖信息及用于获取补丁文件在进程中实际地址的重定位信息,可准确的使进程读取指令或字符的赋值,提高了补丁加载的可靠性。In this embodiment, since the patch area is located in the first dynamic loading library, the patch file can be loaded into the process along with the dynamic loading library to be corrected, and it is not necessary to modify multiple instructions in the dynamic loading library to be modified. The process jumps to the patch area to read the patch file, which avoids the process running crash caused by modifying multiple instructions in the dynamic loading library to be corrected, and the patch file contains information replacement tables, dynamic loading library dependency information, and information for obtaining patches. The relocation information of the actual address of the file in the process can accurately enable the process to read instructions or character assignments, improving the reliability of patch loading.
图5为本发明补丁加载装置实施例一的结构示意图。如图5所示,该装置包括:FIG. 5 is a schematic structural diagram of Embodiment 1 of the patch loading device of the present invention. As shown in Figure 5, the device includes:
第一加载模块501,用于将补丁文件加载至第一动态加载库中的补丁区;The
确定模块502,用于根据补丁文件在第一动态加载库中的相对地址以及第一动态加载库在第一进程中的地址,确定补丁文件在第一进程中的地址,其中,第一进程为加载第一动态加载库的进程;The
运行模块503,用于根据补丁文件在第一进程中的地址运行补丁文件。The running
具体的,上述第一动态加载库为目标文件的提供方提供的待修正的动态加载库;其中,目标文件用于生成所述补丁文件;或者,Specifically, the above-mentioned first dynamic loading library is a dynamic loading library to be corrected provided by the provider of the target file; wherein, the target file is used to generate the patch file; or,
第一动态加载库与待修正的动态加载库在进程中的地址相邻。The first dynamic load library is adjacent to the address of the dynamic load library to be corrected in the process.
更具体的,补丁区与第一动态加载库的代码段相邻。More specifically, the patch area is adjacent to the code segment of the first dynamically loaded library.
本实施例中,由于补丁加载装置使补丁区位于第一动态加载库中,则补丁文件可随待修正的动态加载库加载至进程中,则不需修改待修正的动态加载库中的多条指令便可使进程跳转至补丁区读取补丁文件,避免了修改待修正的动态加载库中多条指令引起的进程运行崩溃,提高了补丁加载的可靠性。In this embodiment, because the patch loading device makes the patch area be located in the first dynamic loading library, then the patch file can be loaded into the process along with the dynamic loading library to be corrected, so there is no need to modify multiple items in the dynamic loading library to be corrected. The instruction can cause the process to jump to the patch area to read the patch file, avoiding the crash of the process caused by modifying multiple instructions in the dynamic loading library to be corrected, and improving the reliability of patch loading.
图6为本发明补丁加载装置实施例二的结构示意图。如图6所示,该装置还包括:FIG. 6 is a schematic structural diagram of Embodiment 2 of the patch loading device of the present invention. As shown in Figure 6, the device also includes:
第二加载模块504,用于将加载补丁文件的动态加载库加载至多个进程中。The
另外,还包括:Additionally, include:
生成模块505,用于根据目标文件包括的字符确定信息替换表;A
还用于根据目标文件的代码段和数据段,信息替换表以及动态加载库依赖信息生成补丁文件。It is also used to generate a patch file according to the code segment and data segment of the target file, the information replacement table, and the dependency information of the dynamic loading library.
具体的,补丁文件在第一动态加载库中的相对地址具体为补丁文件内正确字符在第一动态加载库内的相对地址,第一动态加载库在第一进程中的地址具体为第一动态加载库在第一进程中的起始地址;则当所述正确字符对应于所述待修正的动态加载库内的待修正字符时,确定模块502具体用于根据补丁文件内正确字符在第一动态加载库内的相对地址和第一动态加载库在第一进程中的起始地址,获取补丁文件内正确字符在第一进程中的实际地址;Specifically, the relative address of the patch file in the first dynamic loading library is specifically the relative address of the correct characters in the patch file in the first dynamic loading library, and the address of the first dynamic loading library in the first process is specifically the first dynamic loading library address. The initial address of the loading library in the first process; then when the correct character corresponds to the character to be corrected in the dynamic loading library to be corrected, the determining
当所述正确字符对应于非所述待修正的动态加载库内的字符时,确定模块502还用于根据动态记载库依赖信息调用显示加载接口,获取补丁文件内正确字符在第一进程中的实际地址。When the correct character corresponds to a character that is not in the dynamic loading library to be corrected, the determining
本发明各装置实施例对应上述方法实施例,在此不再赘述。The various device embodiments of the present invention correspond to the foregoing method embodiments, and details are not repeated here.
本实施例中,由于补丁区位于第一动态加载库中,则补丁文件可随待修正的动态加载库加载至进程中,则不需修改待修正的动态加载库中的多条指令便可使进程跳转至补丁区读取补丁文件,避免了修改待修正的动态加载库中多条指令引起的进程运行崩溃,并且补丁文件中包含了信息替换表、动态加载库依赖信息及用于获取补丁文件在进程中实际地址的重定位信息,可准确的使进程读取指令或字符的赋值,提高了补丁加载的可靠性。In this embodiment, since the patch area is located in the first dynamic loading library, the patch file can be loaded into the process along with the dynamic loading library to be corrected, and it is not necessary to modify multiple instructions in the dynamic loading library to be modified. The process jumps to the patch area to read the patch file, which avoids the process running crash caused by modifying multiple instructions in the dynamic loading library to be corrected, and the patch file contains information replacement tables, dynamic loading library dependency information, and information for obtaining patches. The relocation information of the actual address of the file in the process can accurately enable the process to read instructions or character assignments, improving the reliability of patch loading.
本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the steps for implementing the above method embodiments can be completed by program instructions and related hardware. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps including the above-mentioned method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other various media that can store program codes.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention, rather than limiting them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: It is still possible to modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the various embodiments of the present invention. scope.
Claims (12)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310137319.4A CN103218241B (en) | 2013-04-19 | 2013-04-19 | patch loading method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310137319.4A CN103218241B (en) | 2013-04-19 | 2013-04-19 | patch loading method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103218241A true CN103218241A (en) | 2013-07-24 |
CN103218241B CN103218241B (en) | 2016-08-31 |
Family
ID=48816068
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310137319.4A Expired - Fee Related CN103218241B (en) | 2013-04-19 | 2013-04-19 | patch loading method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103218241B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103744709A (en) * | 2014-01-23 | 2014-04-23 | 华为技术有限公司 | Patch loading method and device |
CN103885808A (en) * | 2014-04-08 | 2014-06-25 | 北京奇虎科技有限公司 | Hotfix processing method and device |
CN106462703A (en) * | 2014-05-22 | 2017-02-22 | 软件营地株式会社 | Patch file analysis system and analysis method |
CN108874438A (en) * | 2018-06-25 | 2018-11-23 | 南京中感微电子有限公司 | Patch generation method, device, electronic equipment and computer program product |
CN113835741A (en) * | 2020-06-24 | 2021-12-24 | 中兴通讯股份有限公司 | Patch loading method, network element and computer readable storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6526574B1 (en) * | 1997-07-15 | 2003-02-25 | Pocket Soft, Inc. | System for finding differences between two computer files and updating the computer files |
CN101882094A (en) * | 2010-06-10 | 2010-11-10 | 中兴通讯股份有限公司 | Method and system for making patch by embedded system |
-
2013
- 2013-04-19 CN CN201310137319.4A patent/CN103218241B/en not_active Expired - Fee Related
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6526574B1 (en) * | 1997-07-15 | 2003-02-25 | Pocket Soft, Inc. | System for finding differences between two computer files and updating the computer files |
CN101882094A (en) * | 2010-06-10 | 2010-11-10 | 中兴通讯股份有限公司 | Method and system for making patch by embedded system |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103744709A (en) * | 2014-01-23 | 2014-04-23 | 华为技术有限公司 | Patch loading method and device |
CN103744709B (en) * | 2014-01-23 | 2017-02-15 | 华为技术有限公司 | patch loading method and device |
CN103885808A (en) * | 2014-04-08 | 2014-06-25 | 北京奇虎科技有限公司 | Hotfix processing method and device |
CN106462703A (en) * | 2014-05-22 | 2017-02-22 | 软件营地株式会社 | Patch file analysis system and analysis method |
CN106462703B (en) * | 2014-05-22 | 2019-08-02 | 软件营地株式会社 | Patch file analysis system and analysis method |
CN108874438A (en) * | 2018-06-25 | 2018-11-23 | 南京中感微电子有限公司 | Patch generation method, device, electronic equipment and computer program product |
CN108874438B (en) * | 2018-06-25 | 2021-09-21 | 南京中感微电子有限公司 | Patch generation method and device, electronic equipment and computer storage medium |
CN113835741A (en) * | 2020-06-24 | 2021-12-24 | 中兴通讯股份有限公司 | Patch loading method, network element and computer readable storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN103218241B (en) | 2016-08-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10496839B2 (en) | Protecting sensitive data in software products and in generating core dumps | |
US9430224B2 (en) | Hot-update method and apparatus | |
CN111090433B (en) | Data processing method, device and storage medium | |
KR102010508B1 (en) | System and method for updating source code files | |
CN103744709B (en) | patch loading method and device | |
US9003381B2 (en) | Context-specific optimized code | |
US9021512B1 (en) | Runtime management of TOC pointer save and restore commands | |
US9218168B1 (en) | Suppression of table of contents save actions | |
CN103218241B (en) | patch loading method and device | |
CN105446712B (en) | Application program defect repairing method and device | |
US9594749B2 (en) | Visually differentiating strings for testing | |
CN110083360B (en) | Compiling method, device, equipment and storage medium of application program code | |
CN108614702B (en) | Byte code optimization method and device | |
CN102722387A (en) | Dynamic patching method and device | |
CN106874180A (en) | Detection System And Method Thereof | |
US11030074B2 (en) | Code update based on detection of change in runtime code during debugging | |
US20170286264A1 (en) | System and method for data element tracing | |
US8869109B2 (en) | Disassembling an executable binary | |
US8769498B2 (en) | Warning of register and storage area assignment errors | |
CN109933410B (en) | Virtual instruction issuing method and system based on virtualization technology | |
US10929121B2 (en) | Method, device and related system for dynamically repairing application | |
CN110928570A (en) | Firmware upgrading method and device and readable storage medium | |
CN110825450B (en) | APP configuration modification method and device, electronic equipment and storage medium | |
CN109656556B (en) | Method and device for generating self-adaptive page | |
CN108052410B (en) | Method and device for preventing errors of SPI-Nand read data page |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20160831 Termination date: 20180419 |