Application running method, device, storage medium and apparatus
Patent Information
- Application Number
- CN202210278894.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-21
- Publication Date
- 2026-10-13
- Estimated Expiration
- 2042-03-21
AI Technical Summary
[0004]本发明的主要目的在于提供一种应用程序运行方法、设备、存储介质及装置,旨在解决现有技术中在x86服务器上通过arm版本系统镜像运行应用程序时需要两次解释运行,从而导致病毒样本启动及运行速度慢的技术问题
所述代码执行模块,还用于在验证通过后,基于所述异架构调用栈执行所述异架构代码,以运行所述应用程序。
Smart Images

Figure CN116820659B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, storage medium and device for running applications. Background Technology
[0002] Currently, running virus samples on x86 servers is typically achieved using ARM version system images. However, in practical applications, running virus samples on x86 servers using ARM version system images requires two interpretation processes (first, the ART virtual machine needs interpretation; second, the virtual machine code architecture also needs interpretation), resulting in slow virus sample startup and execution speeds.
[0003] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention
[0004] The main objective of this invention is to provide an application running method, device, storage medium, and apparatus, aiming to solve the technical problem in the prior art that when running an application on an x86 server using an ARM version system image, it requires two interpretations, resulting in slow startup and running speed of virus samples.
[0005] To achieve the above objectives, the present invention provides an application running method, the application running method comprising the following steps: When the application is detected to be executing heterogeneous code, the transformation strategy is obtained through the interpreter; Based on the aforementioned conversion strategy, the current architecture call stack is converted into a heterogeneous architecture call stack using an interpreter. The heterogeneous architecture code is executed based on the heterogeneous architecture call stack to run the application.
[0006] Optionally, the step of obtaining the transformation strategy through the interpreter when it is detected that the application is executing heterogeneous code includes: When the application is detected to be executing heterogeneous code, the conversion information is obtained from the preset memory space; The conversion strategy is obtained through the interpreter based on the conversion information.
[0007] Optionally, before the step of obtaining translation information in a preset memory space when the application is detected to be executing heterogeneous code, the method further includes: When the interpreter obtains the method identifier, a preset memory space is generated; Find the conversion information corresponding to the method identifier and store the conversion information in the preset memory space.
[0008] Optionally, the step of converting the current architecture call stack into a different architecture call stack through the interpreter based on the conversion strategy includes: Based on the aforementioned conversion strategy, the interpreter determines the mapping relationship between each parameter in the current architecture call stack and each parameter in the heterogeneous architecture call stack; Based on the mapping relationship, the current architecture call stack is converted into the heterogeneous architecture call stack.
[0009] Optionally, the step of converting the current architecture call stack into the heterogeneous architecture call stack based on the mapping relationship includes: Obtain the stack top pointer positions of the current architecture call stack and the heterogeneous architecture call stack; Based on the mapping relationship and the position of the stack top pointer, the current architecture call stack is converted into the heterogeneous architecture call stack.
[0010] Optionally, the step of executing the heterogeneous code based on the heterogeneous call stack to run the application includes: The heterogeneous architecture code was verified; After successful verification, the heterogeneous architecture code is executed based on the heterogeneous architecture call stack to run the application.
[0011] Optionally, the step of verifying the heterogeneous architecture code includes: Match the heterogeneous architecture code with the heterogeneous architecture call stack; The heterogeneous architecture code is verified based on the matching results.
[0012] Optionally, before the step of obtaining the transformation strategy through the interpreter when the application is detected to be executing heterogeneous code, the method further includes: Obtain the current system architecture; Based on the current system architecture, detect whether the application is executing heterogeneous architecture code.
[0013] Optionally, the step of detecting whether the application executes heterogeneous code based on the current system architecture includes: Find the code architecture corresponding to the current system architecture; The code architecture is used to detect whether the application is executing heterogeneous code.
[0014] Optionally, after the step of executing the heterogeneous code based on the heterogeneous call stack to run the application, the method further includes: Receive adjustment information from the user based on the heterogeneous call stack; The heterogeneous call stack is adjusted based on the adjustment information, and the heterogeneous code is executed based on the adjusted heterogeneous call stack to run the application.
[0015] Optionally, after the step of executing the heterogeneous code based on the heterogeneous call stack to run the application, the method further includes: Obtain the execution result of the application; A runtime log is generated based on the execution results.
[0016] Furthermore, to achieve the above objectives, the present invention also proposes an application running device, which includes a memory, a processor, and an application running program stored in the memory and capable of running on the processor, wherein the application running program is configured to implement the application running method as described above.
[0017] In addition, to achieve the above objectives, the present invention also proposes a storage medium storing an application program, which, when executed by a processor, implements the application running method as described above.
[0018] In addition, to achieve the above objectives, the present invention also proposes an application running device, which includes: a strategy acquisition module, a call stack conversion module, and a code execution module; The strategy acquisition module is used to acquire the conversion strategy through the interpreter when it detects that the application is executing heterogeneous code; The call stack conversion module is used to convert the current architecture call stack into a different architecture call stack through the interpreter based on the conversion strategy. The code execution module is used to execute the heterogeneous architecture code based on the heterogeneous architecture call stack to run the application.
[0019] Optionally, the strategy acquisition module is further configured to acquire conversion information in a preset memory space when it detects that the application is executing heterogeneous code; The strategy acquisition module is further configured to acquire the conversion strategy through an interpreter based on the conversion information.
[0020] Optionally, the application running device further includes: an information storage module; The information storage module is used to generate a preset memory space when the interpreter obtains the method identifier; The information storage module is also used to find the conversion information corresponding to the method identifier and store the conversion information in the preset memory space.
[0021] Optionally, the call stack conversion module is further configured to determine the mapping relationship between each parameter in the current architecture call stack and each parameter in the heterogeneous architecture call stack based on the conversion strategy through the interpreter; The call stack conversion module is also used to convert the current architecture call stack into the heterogeneous architecture call stack based on the mapping relationship.
[0022] Optionally, the call stack conversion module is further configured to obtain the stack top pointer positions of the current architecture call stack and the heterogeneous architecture call stack; The call stack conversion module is also used to convert the current architecture call stack into the heterogeneous architecture call stack based on the mapping relationship and the position of the stack top pointer.
[0023] Optionally, the code execution module is further configured to verify the heterogeneous architecture code; The code execution module is further configured to execute the heterogeneous code based on the heterogeneous call stack after verification, so as to run the application.
[0024] Optionally, the code execution module is further configured to match the heterogeneous code with the heterogeneous call stack; The code execution module is also used to verify the heterogeneous architecture code based on the matching results.
[0025] This invention discloses a method for obtaining a conversion strategy through an interpreter when an application is detected executing heterogeneous architecture code. Based on the conversion strategy, the current architecture call stack is converted into a heterogeneous architecture call stack by the interpreter, and the heterogeneous architecture code is executed based on the heterogeneous architecture call stack to run the application. Since this invention adds an interpreter and executes heterogeneous architecture code through the interpreter, code of the same architecture is executed directly without interpretation, thereby reducing one interpretation execution and improving the startup and running speed of the application. Attached Figure Description
[0026] Figure 1 This is a schematic diagram of the structure of the application running device in the hardware operating environment involved in the embodiments of the present invention; Figure 2 This is a flowchart illustrating the first embodiment of the application running method of the present invention; Figure 3 This is a schematic diagram illustrating the conversion of the current architecture call stack to a different architecture call stack in one embodiment of the application running method of the present invention; Figure 4 This is a flowchart illustrating the second embodiment of the application running method of the present invention; Figure 5 This is a flowchart illustrating the third embodiment of the application running method of the present invention; Figure 6This is a structural block diagram of the first embodiment of the application running device of the present invention.
[0027] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0028] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0029] Reference Figure 1 , Figure 1 This is a schematic diagram of the application running device structure of the hardware operating environment involved in the embodiments of the present invention.
[0030] like Figure 1 As shown, the application running device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen, and optionally, it may also include a standard wired interface or a wireless interface. In this invention, the wired interface of the user interface 1003 may be a USB interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wireless-Fidelity (Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (RAM) or a non-volatile memory (NVM), such as a disk storage device. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.
[0031] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the device on which the application runs, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0032] like Figure 1 As shown, the memory 1005, which is identified as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an application program.
[0033] exist Figure 1In the application running device shown, the network interface 1004 is mainly used to connect to the backend server and communicate data with the backend server; the user interface 1003 is mainly used to connect to the user device; the application running device calls the application running program stored in the memory 1005 through the processor 1001 and executes the application running method provided in the embodiment of the present invention.
[0034] Based on the above hardware structure, an embodiment of the application running method of the present invention is proposed.
[0035] Reference Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the application running method of the present invention, which presents the first embodiment of the application running method of the present invention.
[0036] In the first embodiment, the application running method includes the following steps: Step S10: When it is detected that the application is executing heterogeneous code, obtain the transformation strategy through the interpreter.
[0037] It should be understood that the execution subject of the method in this embodiment can be an application running device with data processing, network communication and program running functions, such as a computer, mobile phone, or other electronic devices that can achieve the same or similar functions. In this embodiment and other embodiments, a computer is used as an example for illustration.
[0038] Understandably, currently, running virus samples on x86 servers is typically achieved using ARM version system images. However, in practical applications, running virus samples on x86 servers using ARM version system images requires two interpretation processes (first, the ART virtual machine needs interpretation; second, the virtual machine code architecture also needs interpretation), resulting in slow virus sample startup and execution speeds.
[0039] Therefore, in order to overcome the above-mentioned defects, an interpreter is added in this embodiment. The interpreter interprets and executes heterogeneous code, while heterogeneous code is executed directly without interpretation, thereby reducing one interpretation execution and improving the startup and running speed of the application.
[0040] In practical implementations, for example, when running a virus sample on an x86 server using an x86 system image and an ARM interpreter, only the native code needs to be interpreted, while the Java code is executed through a local virtual machine, thus reducing one interpretation execution and improving the startup and running speed of the virus sample.
[0041] It should be noted that heterogeneous architecture code can be code that differs from the system architecture of the device on which the application runs.
[0042] In practical implementations, if the computer runs on an x86 system image, then the code for the ARM architecture is heterogeneous code, such as native code.
[0043] It should be noted that the interpreter can be pre-deployed on the device on which the application runs to interpret and execute code from different architectures. For example, if a computer is running on an x86 system image, an ARM interpreter can be deployed on the computer to interpret and execute code for the ARM architecture.
[0044] It should be understood that in practical applications, in addition to interpreting and executing heterogeneous code, interpreters can also monitor applications on the device, such as monitoring which sensitive APIs the application calls.
[0045] Understandably, in order to interpret and execute heterogeneous code, this embodiment needs to convert the current architecture call stack into a heterogeneous architecture call stack. Therefore, in this embodiment, it is necessary to first obtain the conversion strategy through the interpreter, and then convert the current architecture call stack into a heterogeneous architecture call stack based on the conversion strategy.
[0046] Step S20: Based on the conversion strategy, the current architecture call stack is converted into a different architecture call stack through the interpreter.
[0047] It should be understood that converting the current architecture call stack to a different architecture call stack through the interpreter based on the conversion strategy can be based on the interpreter copying the parameters in the current architecture call stack to the different architecture call stack, thereby converting the current architecture call stack to the different architecture call stack.
[0048] Understandably, in order to improve the reliability of call stack conversion, this embodiment can also convert the current architecture call stack into a different architecture call stack based on the mapping relationship of each parameter in the call stack and the position of the stack top pointer.
[0049] For ease of understanding, please refer to Figure 3 This explanation does not limit the scope of this solution. Figure 3 This diagram illustrates the conversion of the current architecture call stack to a different architecture call stack. In the diagram, the current architecture call stack is an x86 stack, and the different architecture call stack is an ARM stack. The x86 call parameters are all placed on the stack. According to the ART virtual machine method call conversion strategy, the first parameter (artMethod) on the top of the stack is copied to the ARM space r0 and the top of the stack in turn, and then the stack pointers of the two spaces are moved. The second parameter (this) on the stack is copied to r1 or the top of the stack, and then the stack pointer is moved. The same operation is performed on the third parameter (arg0), and so on, until the last parameter.
[0050] Step S30: Execute the heterogeneous architecture code based on the heterogeneous architecture call stack to run the application.
[0051] It should be understood that executing heterogeneous code based on a heterogeneous call stack to run the application can be achieved by interpreting and executing heterogeneous code through an interpreter based on the heterogeneous call stack to run the application.
[0052] In the first embodiment, when it is detected that the application is executing heterogeneous code, a conversion strategy is obtained through the interpreter. Based on the conversion strategy, the current architecture call stack is converted into a heterogeneous architecture call stack by the interpreter. The heterogeneous architecture code is then executed based on the heterogeneous architecture call stack to run the application. Since this embodiment adds an interpreter and interprets and executes heterogeneous architecture code through the interpreter, code of the same architecture is not interpreted but executed directly, thereby reducing one interpretation execution and improving the startup and running speed of the application.
[0053] Reference Figure 4 , Figure 4 This is a flowchart illustrating the second embodiment of the application running method of the present invention, based on the above. Figure 2 The first embodiment shown presents a second embodiment of the application running method of the present invention.
[0054] In the second embodiment, before step S10, the method further includes: Step S01: When the interpreter obtains the method identifier, a preset memory space is generated.
[0055] It should be understood that, considering that the conversion cannot be completed without obtaining the conversion information during the call stack conversion process, in order to ensure a smooth call stack conversion, the conversion information can be pre-stored in a preset memory space in this embodiment.
[0056] It should be noted that the method identifier can be set in advance; for example, the method identifier can be a JNI method symbol.
[0057] It is understandable that, in order to facilitate the retrieval of conversion information, in this embodiment, a preset memory space can be dynamically generated when the interpreter obtains the method identifier to store the conversion information.
[0058] Step S02: Locate the conversion information corresponding to the method identifier and store the conversion information in the preset memory space.
[0059] It should be understood that different method identifiers correspond to different conversion information. Therefore, finding the conversion information corresponding to a method identifier can be done by searching a preset information table. This preset information table contains the correspondence between method identifiers and conversion information, and this correspondence can be pre-entered.
[0060] It should be noted that the conversion information may include information such as the number and type of method parameters.
[0061] In the second embodiment, when the interpreter obtains the method identifier, a preset memory space is generated, the corresponding conversion information of the method identifier is found, and the conversion information is stored in the preset memory space. Since the conversion information is stored in the preset memory space in advance in this embodiment, the call stack can be successfully converted.
[0062] In the second embodiment, step S10 includes: Step S101: When it is detected that the application is executing heterogeneous code, obtain the conversion information in the preset memory space.
[0063] It is understandable that, in order to improve the accuracy of the conversion strategy, in this embodiment, conversion information can be obtained from a preset memory space, and the conversion strategy can be obtained through the interpreter based on the conversion information.
[0064] It should be noted that the preset memory space can be set in advance, and the conversion information in the preset memory space can be pre-entered.
[0065] The conversion information may include information such as the number and type of method parameters.
[0066] Step S102: Obtain the conversion strategy through the interpreter based on the conversion information.
[0067] It should be understood that obtaining the conversion strategy from the interpreter based on the conversion information can be achieved by inputting the conversion information into the interpreter and obtaining the conversion strategy.
[0068] In the second embodiment, when it is detected that an application is executing heterogeneous code, conversion information is obtained in a preset memory space, and a conversion strategy is obtained through an interpreter based on the conversion information. Since the conversion information is obtained in a preset memory space and the conversion strategy is obtained through an interpreter based on the conversion information in this embodiment, the accuracy of the conversion strategy can be improved.
[0069] In the second embodiment, step S20 includes: Step S201: Based on the conversion strategy, the interpreter determines the mapping relationship between each parameter in the current architecture call stack and each parameter in the heterogeneous architecture call stack.
[0070] Understandably, in order to improve the reliability of call stack conversion, this embodiment also converts the current architecture call stack into a different architecture call stack based on the mapping relationship of each parameter in the call stack.
[0071] It should be understood that determining the mapping relationship between each parameter in the current architecture call stack and each parameter in the heterogeneous architecture call stack based on the conversion strategy through the interpreter can be achieved by parsing the conversion strategy to obtain the mapping relationship between each parameter in the current architecture call stack and each parameter in the heterogeneous architecture call stack.
[0072] Step S202: Based on the mapping relationship, convert the current architecture call stack into the heterogeneous architecture call stack.
[0073] It is understandable that converting the current architecture call stack to a different architecture call stack based on the mapping relationship can be achieved by copying the parameters in the current architecture call stack to the different architecture call stack based on the mapping relationship.
[0074] In the second embodiment, a method is disclosed that the mapping relationship between each parameter in the current architecture call stack and each parameter in the heterogeneous architecture call stack is determined by the interpreter based on the conversion strategy, and the current architecture call stack is converted into a heterogeneous architecture call stack based on the mapping relationship. Since this embodiment also converts the current architecture call stack into a heterogeneous architecture call stack based on the mapping relationship of each parameter in the call stack, the reliability of the call stack conversion can be improved.
[0075] Furthermore, in practical applications, the stack top pointer must also be considered when converting the call stack. Therefore, step S202 includes: Obtain the stack top pointer positions of the current architecture call stack and the heterogeneous architecture call stack; Based on the mapping relationship and the position of the stack top pointer, the current architecture call stack is converted into the heterogeneous architecture call stack.
[0076] It should be understood that in practical applications, when converting the call stack, in addition to considering the mapping relationship of each parameter in the call stack, the stack top pointer also needs to be considered. Therefore, in this embodiment, the stack top pointer positions of the current architecture call stack and the heterogeneous architecture call stack are also obtained, and the current architecture call stack is converted into the heterogeneous architecture call stack based on the mapping relationship and the stack top pointer positions.
[0077] For ease of understanding, please refer to Figure 3 This explanation does not limit the scope of this solution. Figure 3 This diagram illustrates the conversion of the current architecture call stack to a different architecture call stack. In the diagram, the current architecture call stack is an x86 stack, and the different architecture call stack is an ARM stack. The x86 call parameters are all placed on the stack. According to the ART virtual machine method call conversion strategy, the first parameter (artMethod) on the top of the stack is copied to the ARM space r0 and the top of the stack in turn, and then the stack pointers of the two spaces are moved. The second parameter (this) on the stack is copied to r1 or the top of the stack, and then the stack pointer is moved. The same operation is performed on the third parameter (arg0), and so on, until the last parameter.
[0078] In the second embodiment, step S30 includes: Step S301: Verify the heterogeneous architecture code.
[0079] Understandably, in order to ensure that the heterogeneous code is interpreted and executed smoothly, this embodiment also verifies the heterogeneous code, and after the verification is passed, executes the heterogeneous code based on the heterogeneous call stack to run the application.
[0080] It should be understood that verification of heterogeneous architecture code can be based on preset rules. These preset rules can be pre-defined to verify the integrity and format of the heterogeneous architecture code.
[0081] Furthermore, to ensure that the heterogeneous call stack can interpret and execute heterogeneous code, step S301 includes: Match the heterogeneous architecture code with the heterogeneous architecture call stack; The heterogeneous architecture code is verified based on the matching results.
[0082] Understandably, in order to ensure that the heterogeneous call stack can interpret and execute heterogeneous code, in this embodiment, the heterogeneous code can be matched with the heterogeneous call stack first, and the heterogeneous code can be verified based on the matching result.
[0083] It should be understood that matching heterogeneous code with heterogeneous call stacks can mean matching the architecture of the heterogeneous code with the architecture of the heterogeneous call stack.
[0084] Understandably, verifying heterogeneous code based on the matching results means that if the matching result is successful, the heterogeneous code verification is considered successful; if the matching result is unsuccessful, the heterogeneous code verification is considered unsuccessful.
[0085] Step S302: After verification, execute the heterogeneous architecture code based on the heterogeneous architecture call stack to run the application.
[0086] It should be understood that successful verification indicates that the heterogeneous code can be interpreted and executed smoothly. Therefore, in this embodiment, heterogeneous code can be executed based on the heterogeneous call stack to run the application.
[0087] In the second embodiment, the heterogeneous code is verified. After verification, the heterogeneous code is executed based on the heterogeneous call stack to run the application. Since this embodiment also verifies the heterogeneous code and executes it based on the heterogeneous call stack after verification to run the application, it can ensure that the heterogeneous code is interpreted and run smoothly.
[0088] Reference Figure 5 , Figure 5 This is a flowchart illustrating the third embodiment of the application running method of the present invention, based on the above. Figure 2 The first embodiment shown presents a third embodiment of the application running method of the present invention.
[0089] In the third embodiment, before step S10, the method further includes: Step S01': Obtain the current system architecture.
[0090] It should be understood that, in order to accurately detect whether an application is executing heterogeneous code, in this embodiment, the current system architecture can be obtained first, and the application can be detected as executing heterogeneous code based on the current system architecture.
[0091] Step S02': Detect whether the application executes heterogeneous code based on the current system architecture.
[0092] It is understandable that detecting whether an application is executing heterogeneous code based on the current system architecture may involve finding the code architecture corresponding to the current system architecture and then detecting whether the application is executing heterogeneous code based on the code architecture.
[0093] It should be understood that detecting whether an application is executing heterogeneous code based on its code architecture can involve obtaining the execution code architecture corresponding to the application, matching the code architecture with the execution code architecture, and detecting whether the application is executing heterogeneous code based on the matching result.
[0094] In the third embodiment, the current system architecture is obtained, and the application is detected to execute heterogeneous code based on the current system architecture, thereby enabling accurate detection of the application executing heterogeneous code.
[0095] In the third embodiment, after step S30, the method further includes: Step S40: Receive adjustment information from the user based on the heterogeneous architecture call stack.
[0096] It is understandable that, in order to facilitate users in customizing heterogeneous call stacks, this embodiment can also receive adjustment information from users based on heterogeneous call stacks, and adjust the heterogeneous call stacks based on the adjustment information.
[0097] It should be noted that the adjustment information can be a modification of parameters in the heterogeneous call stack.
[0098] Step S50: Adjust the heterogeneous call stack based on the adjustment information, and execute the heterogeneous code based on the adjusted heterogeneous call stack to run the application.
[0099] It should be understood that adjusting the heterogeneous call stack based on the adjustment information can be done by adjusting the parameters in the heterogeneous call stack based on the adjustment information.
[0100] In the third embodiment, it is disclosed that the user receives adjustment information based on the heterogeneous architecture call stack, adjusts the heterogeneous architecture call stack based on the adjustment information, and executes heterogeneous architecture code based on the adjusted heterogeneous architecture call stack to run the application. Since this embodiment can also receive adjustment information based on the user's heterogeneous architecture call stack and adjust the heterogeneous architecture call stack based on the adjustment information, it is convenient for users to customize the heterogeneous architecture call stack.
[0101] In the third embodiment, after step S30, the method further includes: Obtain the execution result of the application; A runtime log is generated based on the execution results.
[0102] It should be understood that, in order to facilitate users in finding the execution information of the application, this embodiment also obtains the execution result of the application and generates a running log based on the execution result.
[0103] It should be noted that the execution result may include information such as execution success, execution failure, and the reason for execution failure.
[0104] In the third embodiment, the method of obtaining the execution result of the application and generating a running log based on the execution result is disclosed. Since this embodiment also obtains the execution result of the application and generates a running log based on the execution result, it is convenient for users to find the execution information of the application.
[0105] Furthermore, this embodiment of the invention also proposes a storage medium storing an application program, which, when executed by a processor, implements the application running method described above.
[0106] In addition, refer to Figure 6 The present invention also proposes an application running device, which includes: a strategy acquisition module 10, a call stack conversion module 20, and a code execution module 30; The strategy acquisition module 10 is used to acquire a conversion strategy through the interpreter when it is detected that the application is executing heterogeneous architecture code.
[0107] Understandably, currently, running virus samples on x86 servers is typically achieved using ARM version system images. However, in practical applications, running virus samples on x86 servers using ARM version system images requires two interpretation processes (first, the ART virtual machine needs interpretation; second, the virtual machine code architecture also needs interpretation), resulting in slow virus sample startup and execution speeds.
[0108] Therefore, in order to overcome the above-mentioned defects, an interpreter is added in this embodiment. The interpreter interprets and executes heterogeneous code, while heterogeneous code is executed directly without interpretation, thereby reducing one interpretation execution and improving the startup and running speed of the application.
[0109] In practical implementations, for example, when running a virus sample on an x86 server using an x86 system image and an ARM interpreter, only the native code needs to be interpreted, while the Java code is executed through a local virtual machine, thus reducing one interpretation execution and improving the startup and running speed of the virus sample.
[0110] It should be noted that heterogeneous architecture code can be code that differs from the system architecture of the device on which the application runs.
[0111] In practical implementations, if the computer runs on an x86 system image, then the code for the ARM architecture is heterogeneous code, such as native code.
[0112] It should be noted that the interpreter can be pre-deployed on the device on which the application runs to interpret and execute code from different architectures. For example, if a computer is running on an x86 system image, an ARM interpreter can be deployed on the computer to interpret and execute code for the ARM architecture.
[0113] It should be understood that in practical applications, in addition to interpreting and executing heterogeneous code, interpreters can also monitor applications on the device, such as monitoring which sensitive APIs the application calls.
[0114] Understandably, in order to interpret and execute heterogeneous code, this embodiment needs to convert the current architecture call stack into a heterogeneous architecture call stack. Therefore, in this embodiment, it is necessary to first obtain the conversion strategy through the interpreter, and then convert the current architecture call stack into a heterogeneous architecture call stack based on the conversion strategy.
[0115] The call stack conversion module 20 is used to convert the current architecture call stack into a different architecture call stack through the interpreter based on the conversion strategy.
[0116] It should be understood that converting the current architecture call stack to a different architecture call stack through the interpreter based on the conversion strategy can be based on the interpreter copying the parameters in the current architecture call stack to the different architecture call stack, thereby converting the current architecture call stack to the different architecture call stack.
[0117] Understandably, in order to improve the reliability of call stack conversion, this embodiment can also convert the current architecture call stack into a different architecture call stack based on the mapping relationship of each parameter in the call stack and the position of the stack top pointer.
[0118] For ease of understanding, please refer to Figure 3 This explanation does not limit the scope of this solution. Figure 4 This diagram illustrates the conversion of the current architecture call stack to a different architecture call stack. In the diagram, the current architecture call stack is an x86 stack, and the different architecture call stack is an ARM stack. The x86 call parameters are all placed on the stack. According to the ART virtual machine method call conversion strategy, the first parameter (artMethod) on the top of the stack is copied to the ARM space r0 and the top of the stack in turn, and then the stack pointers of the two spaces are moved. The second parameter (this) on the stack is copied to r1 or the top of the stack, and then the stack pointer is moved. The same operation is performed on the third parameter (arg0), and so on, until the last parameter.
[0119] The code execution module 30 is used to execute the heterogeneous architecture code based on the heterogeneous architecture call stack to run the application.
[0120] It should be understood that executing heterogeneous code based on a heterogeneous call stack to run the application can be achieved by interpreting and executing heterogeneous code through an interpreter based on the heterogeneous call stack to run the application.
[0121] In this embodiment, when it is detected that an application is executing heterogeneous code, a conversion strategy is obtained through an interpreter. Based on the conversion strategy, the current architecture call stack is converted into a heterogeneous architecture call stack by the interpreter. The heterogeneous architecture code is then executed based on the heterogeneous architecture call stack to run the application. Since this embodiment adds an interpreter and executes heterogeneous architecture code through the interpreter, code with the same architecture is executed directly without interpretation, thereby reducing one interpretation execution and improving the startup and running speed of the application.
[0122] In one embodiment, the strategy acquisition module 10 is further configured to acquire conversion information in a preset memory space when it detects that the application is executing heterogeneous code; The strategy acquisition module 10 is further configured to acquire the conversion strategy through the interpreter based on the conversion information.
[0123] In one embodiment, the application running device further includes: an information storage module; The information storage module is used to generate a preset memory space when the interpreter obtains the method identifier; The information storage module is also used to find the conversion information corresponding to the method identifier and store the conversion information in the preset memory space.
[0124] In one embodiment, the call stack conversion module 20 is further configured to determine the mapping relationship between each parameter in the current architecture call stack and each parameter in the heterogeneous architecture call stack based on the conversion strategy through the interpreter; The call stack conversion module 20 is also used to convert the current architecture call stack into the heterogeneous architecture call stack based on the mapping relationship.
[0125] In one embodiment, the call stack conversion module 20 is further configured to obtain the stack top pointer positions of the current architecture call stack and the heterogeneous architecture call stack; The call stack conversion module 20 is also used to convert the current architecture call stack into the heterogeneous architecture call stack based on the mapping relationship and the position of the stack top pointer.
[0126] In one embodiment, the code execution module 30 is further configured to verify the heterogeneous architecture code; The code execution module 30 is further configured to execute the heterogeneous code based on the heterogeneous call stack after verification to run the application.
[0127] In one embodiment, the code execution module 30 is further configured to match the heterogeneous code with the heterogeneous call stack; The code execution module 30 is also used to verify the heterogeneous architecture code based on the matching results.
[0128] In one embodiment, the application running device further includes: a code detection module; The code detection module is used to obtain the current system architecture; The code detection module is also used to detect whether the application executes heterogeneous code based on the current system architecture.
[0129] In one embodiment, the code detection module is further configured to locate the code architecture corresponding to the current system architecture; The code detection module is also used to detect whether the application executes heterogeneous code based on the code architecture.
[0130] In one embodiment, the application running device further includes: a manual adjustment module; The manual adjustment module is used to receive adjustment information from the user based on the heterogeneous architecture call stack; The manual adjustment module is further configured to adjust the heterogeneous call stack based on the adjustment information, and execute the heterogeneous code based on the adjusted heterogeneous call stack to run the application.
[0131] In one embodiment, the application running device further includes: a log generation module; The log generation module is used to obtain the execution results of the application; The log generation module is also used to generate a running log based on the execution result.
[0132] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0133] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0134] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as a read-only memory image (ROM) / random access memory (RAM), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0135] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A method for running an application, characterized in that, The application running method includes the following steps: When the application is detected to be executing heterogeneous code, the transformation strategy is obtained through the interpreter; Based on the aforementioned conversion strategy, the current architecture call stack is converted into a heterogeneous architecture call stack using an interpreter. The heterogeneous architecture code is executed based on the heterogeneous architecture call stack to run the application; The step of converting the current architecture call stack into a different architecture call stack using the interpreter based on the conversion strategy includes: Based on the aforementioned conversion strategy, the interpreter determines the mapping relationship between each parameter in the current architecture call stack and each parameter in the heterogeneous architecture call stack; Obtain the stack top pointer positions of the current architecture call stack and the heterogeneous architecture call stack; Based on the mapping relationship and the position of the stack top pointer, the current architecture call stack is converted into the heterogeneous architecture call stack.
2. The application running method as described in claim 1, characterized in that, The step of obtaining the transformation strategy through the interpreter when the application is detected to be executing heterogeneous code includes: When the application is detected to be executing heterogeneous code, the conversion information is obtained from the preset memory space; The conversion strategy is obtained through the interpreter based on the conversion information.
3. The application running method as described in claim 2, characterized in that, Before the step of obtaining the conversion information in the preset memory space when the application is detected to be executing heterogeneous code, the method further includes: When the interpreter obtains the method identifier, a preset memory space is generated; Find the conversion information corresponding to the method identifier and store the conversion information in the preset memory space.
4. The application running method as described in claim 1, characterized in that, The step of executing the heterogeneous architecture code based on the heterogeneous architecture call stack to run the application includes: The heterogeneous architecture code was verified; After successful verification, the heterogeneous architecture code is executed based on the heterogeneous architecture call stack to run the application.
5. The application running method as described in claim 4, characterized in that, The step of verifying the heterogeneous architecture code includes: Match the heterogeneous architecture code with the heterogeneous architecture call stack; The heterogeneous architecture code is verified based on the matching results.
6. The application running method as described in any one of claims 1 to 5, characterized in that, Before the step of obtaining the transformation strategy through the interpreter when the application is detected to be executing heterogeneous code, the method further includes: Obtain the current system architecture; Based on the current system architecture, detect whether the application is executing heterogeneous architecture code.
7. The application running method as described in claim 6, characterized in that, The step of detecting whether an application executes heterogeneous code based on the current system architecture includes: Find the code architecture corresponding to the current system architecture; The code architecture is used to detect whether the application is executing heterogeneous code.
8. The application running method as described in any one of claims 1 to 5, characterized in that, Following the step of executing the heterogeneous architecture code based on the heterogeneous architecture call stack to run the application, the method further includes: Receive adjustment information from the user based on the heterogeneous call stack; The heterogeneous call stack is adjusted based on the adjustment information, and the heterogeneous code is executed based on the adjusted heterogeneous call stack to run the application.
9. The application running method as described in any one of claims 1 to 5, characterized in that, Following the step of executing the heterogeneous architecture code based on the heterogeneous architecture call stack to run the application, the method further includes: Obtain the execution result of the application; A runtime log is generated based on the execution results.
10. An application running device, characterized in that, The application running device includes: a memory, a processor, and an application running program stored in the memory and executable on the processor, wherein the application running program, when executed by the processor, implements the application running method as described in any one of claims 1 to 9.
11. A storage medium, characterized in that, The storage medium stores an application program, which, when executed by a processor, implements the application running method as described in any one of claims 1 to 9.
12. An application running device, characterized in that, The application running device includes: a strategy acquisition module, a call stack conversion module, and a code execution module; The strategy acquisition module is used to acquire the conversion strategy through the interpreter when it detects that the application is executing heterogeneous code; The call stack conversion module is used to convert the current architecture call stack into a different architecture call stack through the interpreter based on the conversion strategy. The code execution module is used to execute the heterogeneous architecture code based on the heterogeneous architecture call stack to run the application. The call stack conversion module is further configured to determine the mapping relationship between each parameter in the current architecture call stack and each parameter in the heterogeneous architecture call stack based on the conversion strategy using an interpreter; obtain the stack top pointer positions of the current architecture call stack and the heterogeneous architecture call stack; and convert the current architecture call stack into the heterogeneous architecture call stack based on the mapping relationship and the stack top pointer positions.
13. The application running device as described in claim 12, characterized in that, The strategy acquisition module is also used to acquire conversion information in a preset memory space when it detects that the application is executing heterogeneous architecture code; The strategy acquisition module is further configured to acquire the conversion strategy through an interpreter based on the conversion information.
14. The application running device as described in claim 13, characterized in that, The application running device further includes: an information storage module; The information storage module is used to generate a preset memory space when the interpreter obtains the method identifier; The information storage module is also used to find the conversion information corresponding to the method identifier and store the conversion information in the preset memory space.
15. The application running device as described in claim 12, characterized in that, The code execution module is also used to verify the heterogeneous architecture code; The code execution module is further configured to execute the heterogeneous code based on the heterogeneous call stack after verification, so as to run the application.
16. The application running device as described in claim 15, characterized in that, The code execution module is also used to match the heterogeneous code with the heterogeneous call stack; The code execution module is also used to verify the heterogeneous architecture code based on the matching results.
Citation Information
Patent Citations
Simulator detection method and device, equipment and computer storage medium
CN113590404A