Code running method and device, readable medium and electronic equipment

By loading and compiling the code to be run in the target domain, the challenges of software testing and debugging in scenarios with missing source code are solved, enabling functional expansion without open source code, and providing application debugging, testing, and control capabilities.

CN115729556BActive Publication Date: 2026-06-16BEIJING ZITIAO NETWORK TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING ZITIAO NETWORK TECH CO LTD
Filing Date
2022-09-08
Publication Date
2026-06-16

AI Technical Summary

Technical Problem

In the absence of source code, software testing and debugging are difficult, especially when program defects caused by differences between real device debugging and release versions cannot be found, and it is difficult to extend functionality without open source code.

Method used

By loading the code to be run into the target domain of the target application and associating it with runtime library files, the additional code functionality can be achieved by compiling and running it using the target domain.

🎯Benefits of technology

It enables debugging, testing, or control of applications without source code, resolves the differences between real device debugging and release versions, and supports feature expansion without releasing the source code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115729556B_ABST
    Figure CN115729556B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a code running method and device, readable medium and electronic equipment, and relates to the technical field of computer networks. The method comprises: obtaining a to-be-run code for a target application program; loading the to-be-run code into a target domain of the target application program, the target domain being associated with a runtime library file required for running the to-be-run code and the target application program; and based on the target domain, compiling and running the to-be-run code. The method can run additional to-be-run codes in an application program.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and more specifically, to a method, apparatus, readable medium, and electronic device for executing code. Background Technology

[0002] Testing software is an important part of the software development process. However, existing software testing methods have some drawbacks. Summary of the Invention

[0003] This section is provided to briefly introduce the concepts, which will be described in detail in the Detailed Description section later. This section is not intended to identify key or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0004] Firstly, this disclosure provides a method for running code, the method comprising:

[0005] Obtain the code to be executed for the target application;

[0006] The code to be run is loaded into the target domain of the target application, and the target domain is associated with the runtime library files required to run the code and the target application.

[0007] Based on the target domain, the code to be run is compiled and executed.

[0008] Secondly, this disclosure provides a code execution apparatus, the apparatus comprising:

[0009] The code acquisition module is used to acquire the code to be executed for the target application;

[0010] A loading module is used to load the code to be run into the target domain of the target application, wherein the target domain is associated with the runtime library files required to run the code to be run and the target application.

[0011] An execution module is used to compile and run the code to be run based on the target domain.

[0012] Thirdly, this disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the method described in the first aspect.

[0013] Fourthly, this disclosure provides an electronic device, comprising:

[0014] A storage device having at least one computer program stored thereon;

[0015] At least one processing device is configured to execute the at least one computer program in the storage device to implement the steps of the method described in the first aspect.

[0016] Through the above technical solution, after obtaining the code to be run for the target application, the code to be run is loaded into the target domain of the target application. Since the target domain is associated with the code to be run and the runtime library files required by the target application, the obtained code to be run can be compiled and run based on the target domain, so as to realize the function of running the additional code to be run, thereby facilitating the debugging, testing or control of the application.

[0017] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description

[0018] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale. In the drawings:

[0019] Figure 1 This is a flowchart illustrating a code execution method according to an exemplary embodiment;

[0020] Figure 2 This is a flowchart illustrating a runtime file loading process according to an exemplary embodiment.

[0021] Figure 3 This is a flowchart illustrating a process for obtaining an interface function according to an exemplary embodiment;

[0022] Figure 4 This is a screenshot of the interface of a code execution method provided according to an exemplary embodiment;

[0023] Figure 5 This is a schematic diagram of module connections for a code execution device according to an exemplary embodiment;

[0024] Figure 6 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment. Detailed Implementation

[0025] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.

[0026] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.

[0027] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.

[0028] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.

[0029] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0030] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.

[0031] All actions involving the acquisition of signals, information, or data in this disclosure are carried out in accordance with the relevant data protection laws and policies of the country where the location is situated, and with the authorization granted by the owner of the relevant device.

[0032] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.

[0033] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or readable medium performing the operations of this disclosed technical solution, based on the prompt message.

[0034] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0035] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.

[0036] Meanwhile, it is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.

[0037] As described in the background section, methods for testing software in related technologies suffer from operational difficulties. This problem is particularly pronounced in scenarios where source code is missing. For example:

[0038] In some scenarios, such as game development, there might be upgrades to the Unity 3D game engine, or code design flaws, causing a game to run perfectly fine in the Unity editor but malfunction on a real device. That is, the problem cannot be detected during debugging on a real device, but issues arise during actual release because debugging requires a debug version, while running on a real device uses the release version; these differences cause the problem. In such cases, a real program defect (bug) cannot be debugged, meaning the cause cannot be found, leading to a development impasse. Therefore, a method is needed to run and debug code in applications with missing source code.

[0039] In other scenarios, such as projects with high security measures, only the development team may have the complete source code, while the design, art, and testing teams may not. This prevents these personnel from debugging or testing the project. In such cases, a method is needed to run debugging or testing code in applications lacking source code.

[0040] In other scenarios, such as highly open-ended games that allow players to extend game functionality, traditional extensions have primarily relied on the game's source code. However, the source code is crucial for game developers and they may not necessarily release it to users. Therefore, extending game functionality without releasing the source code is quite difficult. In such cases, a method is needed that allows additional game functionality code to run in applications lacking source code.

[0041] It is evident that, in some scenarios, including those described above, there is an urgent need for a method that can embed additional debugging, testing, or control functions into an application even without the application's source code.

[0042] To address the aforementioned technical problems, this disclosure provides a code execution method, apparatus, readable medium, and electronic device. By initializing the runtime environment and associating the code to be executed with the application's runtime environment, the code to be executed is associated with the application's original code. Ultimately, based on the runtime environment, the obtained code to be executed can be compiled and run, enabling the execution of additional code to be executed within the application. This allows for functions such as debugging, testing, or controlling the application.

[0043] It should be noted that the above example illustrates an application for which source code is unavailable. The method of this disclosure is applicable not only to applications lacking source code, but also to applications with available source code. That is, it adds additional code to be run without modifying the source code. The method of this disclosure does not limit specific application scenarios.

[0044] The following will describe in detail, with reference to the accompanying drawings, a code execution method, apparatus, readable medium, and electronic device proposed in the embodiments of this disclosure.

[0045] Figure 1 This is a flowchart illustrating a code execution method according to an exemplary embodiment. The code execution method provided in this disclosure can be executed by a code execution device, which can be implemented in software and / or hardware and can be configured in an electronic device. Please refer to...Figure 1 The code execution method provided in this disclosure embodiment may include the following steps:

[0046] S110, retrieve the code to be run for the target application.

[0047] In this embodiment of the disclosure, the code to be run can be understood as the code that the user wants to embed and run in the target application, and can be regarded as code added "out of thin air" outside the source code of the target application. The target application can be any application.

[0048] In some implementations, the programming language corresponding to the code to be executed is the same as at least one of the programming languages ​​used by the target application. For example, when the target application includes code written in the C# programming language, the code to be executed can be C# code. When the application includes code written in the Lua programming language, the code to be executed can be Lua code.

[0049] S120, the code to be run is loaded into the target domain of the target application, and the target domain is associated with the runtime library files required to run the code to be run and the target application.

[0050] Domains are used to provide isolation between applications. A target domain can be understood as the domain in which the target application resides.

[0051] In this embodiment of the disclosure, in order to run the code to be run in the target application, the code to be run can be loaded into the target domain of the target application, so that the code to be run is associated with the target application, thereby enabling the code to obtain data from the target application and to manipulate and modify the data of the target application.

[0052] In addition, in order to ensure that the obtained code to be run and the target application can run normally, in this embodiment of the disclosure, the target domain can be associated with the runtime library files required to run the code to be run and the target application.

[0053] For example, assuming the target application is a C# program, and the target application originally loads three runtime library files: mscorlib.dll, System.Configuration.dll, and System.Core.dll, the C# code to be run this time may need the runtime library file System.dll. In this case, the target domain can be associated with four types: mscorlib.dll, System.Configuration.dll, System.Core.dll, and System.dll, so as to meet the normal operation of the target application and the code to be run.

[0054] Furthermore, considering the generality of the scenario, in some implementations, the code to be run and the runtime library files required by the target application are the complete runtime library files corresponding to the target application.

[0055] For example, the target application originally loads three runtime library files: mscorlib.dll, System.Configuration.dll, and System.Core.dll. The C# code to be run this time may require the runtime library file System.dll, and the next C# code to be run may require the runtime library file System.Xml.dll. In this case, in order to ensure that any obtained code to be run can run normally, the target domain can be set to associate the runtime library files required by the code to be run and the target application with the complete runtime library files corresponding to the target application. That is, when the target domain associates the runtime library files required by the code to be run and the target application with the complete runtime library files corresponding to the target application, namely mscorlib.dll, System.Configuration.dll, System.Core.dll, System.dll, and System.Xml.dll, mscorlib.dll, System.Configuration.dll, System.Core.dll, System.dll, and System.Xml.dll, mscorlib.dll, System.Configuration.dll, System.Core.dll, System.dll, and System.Xml.dll can be loaded simultaneously in the target domain.

[0056] S130, based on the target domain, compiles and runs the code to be run.

[0057] In this embodiment of the disclosure, since the target domain is associated with the code to be run and the runtime library files required by the target application, after the code to be run is loaded into the target domain of the target application, it is equivalent to building the runtime environment of the code to be run. Thus, the code to be run can be compiled and run in the target application based on the target domain.

[0058] Using the above method, after obtaining the code to be run for the target application, the code to be run is loaded into the target domain of the target application. Since the target domain is associated with the code to be run and the runtime library files required by the target application, the obtained code to be run can be compiled and run based on the target domain. This enables the function of running additional code to be run, thereby facilitating the debugging, testing, or control of the application.

[0059] Furthermore, considering that target applications typically only include a subset of runtime library files for the currently used programming language, the code to be run may lack these runtime library files. For example, when a game is packaged into a release version, the C# code is trimmed, which also removes some runtime library files required by C#. This could potentially cause the C# code to fail to run due to the lack of runtime library support.

[0060] In this case, in order to enable the target domain to associate with the code to be run and the runtime library files required by the target application, and to ensure the normal operation of the target application and the code to be run, in some embodiments, the method of this disclosure may further include the following steps:

[0061] Obtain the target interface function, which is the interface function provided by the application's runtime environment; determine the file loading interface function from the target interface function; hook the file loading interface function so that after the file loading interface function is called, it loads the code to be run and the runtime library files required by the target application.

[0062] In this embodiment, the interface functions provided by the runtime environment can be obtained first as the target interface functions. For example, when a game is written based on the 3D game engine Unity and specifically in the C# programming language, the corresponding runtime environment for the game is Mono. Mono is an open-source software and is an open-source implementation of the C# runtime environment.

[0063] Next, considering that only the file loading interface function performs the file loading work, potentially loading the runtime library file into the target domain, we can further determine the file loading interface function from the target interface functions. After determining the file loading interface function, we can hook it so that when the subsequent file loading interface function is called, it loads both the code to be run and the runtime library file required by the target application. This allows the target domain to simultaneously associate the code to be run and the runtime library file required by the target application.

[0064] For example, such as Figure 2As shown, when the runtime environment is Mono, we can first obtain Mono's private API (Application Programming Interface) functions, and then determine and obtain the file loading interface functions from Mono's private API functions. For example, we can determine the existing file loading function mono_file_map_open in the game. Then, we can hook the mono_file_map_open file loading function, so that when the game calls the mono_file_map_open file loading function later, it can further load the runtime library files required by the code to be run and the target application.

[0065] It is understandable that, without hooking the mono_file_map_open file loading function, if the runtime library files required to run the target application do not include the runtime library files required to run the code to be run when the game calls the mono_file_map_open file loading function, then the target domain will not include the runtime library files required to run the code to be run.

[0066] After hooking the mono_file_map_open file loading function, the game can load the code to be run and the runtime library files required by the target application into the target domain after calling the mono_file_map_open file loading function.

[0067] Furthermore, considering that the file loading interface function may load runtime library files and / or the logic of the target application itself—for example, the `mono_file_map_open` file loading function can load runtime library files and / or the logic of the target application itself—when the file loading interface function loads the logic of the target application itself, the loaded content may not be replaced. Replacement is only performed when the file loading interface function loads the runtime library files. Therefore, in some implementations, after the file loading interface function is called, it can load the code to be run and the runtime library files required by the target application through the following steps:

[0068] The file to be loaded is obtained through the file loading interface function; it is determined whether the file to be loaded is a runtime library file required to run the target application; if the file to be loaded is a runtime library file required to run the target application, the file loading interface function is used to load the code to be run and the runtime library file required by the target application.

[0069] In this embodiment of the disclosure, after the file loading interface is invoked, it can first obtain the file to be loaded. Then, it can determine whether the file to be loaded is a runtime library file required by the target application. If it is a runtime library file required by the target application, the obtained file to be loaded is replaced with the code to be run and the runtime library file required by the target application, and then the code to be run and the runtime library file required by the target application are loaded through the file loading interface function. If it is not a runtime library file required by the target application, such as the logic of the target application itself, no replacement is performed, and the logic of the target application itself is loaded through the file loading interface function.

[0070] For example, continuing with the foregoing examples, and continuing to refer to Figure 2 After the original `mono_file_map_open` file loading function in the game is called, it can determine whether the loaded dynamic link library is the runtime library file required to run C#. If the result is yes, the loaded dynamic link library is replaced with the complete C# runtime library file, and the replacement process ends. This allows the runtime library files required for running the code to be run and the target application to be loaded through the file loading interface function later. If the result is no, no replacement is performed, and the replacement process ends. This allows the originally obtained dynamic link library to be loaded through the file loading interface function later.

[0071] It should be noted that the above embodiment uses the file loading function mono_file_map_open as an example for illustration. In some implementations, the file loading function can also be other interface functions.

[0072] It is understandable that in the above embodiments, since the interface functions provided by the target application's runtime environment are obtained and the file loading interface function is determined from them after the program starts, this process is equivalent to a scheme for dynamically obtaining the file loading interface function. Therefore, it can avoid a series of problems caused by the target application development software upgrading the runtime environment used in version iterations, which would lead to calling the interface functions in the dynamic link library provided by the runtime environment.

[0073] In some implementations, it can be first determined whether the handle of the dynamic link library corresponding to the target interface function can be obtained. If the handle of the corresponding dynamic link library can be obtained, the target interface function can then be obtained.

[0074] In some implementations, the handle to a dynamic link library can be obtained via NPTH_DL. NPTH_DL is an open-source code library for obtaining dynamic link library symbols. Its advantage over the operating system's own code library for obtaining dynamic link library symbols is that it can bypass Google's restrictions on obtaining dynamic link library symbols in Android 7.0 and above.

[0075] In some implementations, considering that the target interface function may exist in multiple dynamic link libraries, therefore, such as Figure 3 As shown, the process first checks if the handle of the first dynamic link library corresponding to the target interface function can be obtained. If it can be successfully obtained, the target interface function is retrieved from the first dynamic link library. If the handle of the first dynamic link library cannot be obtained, i.e., the retrieval fails, the process further checks if the handle of the second dynamic link library corresponding to the target interface function can be obtained. If it can be successfully obtained, the target interface function is retrieved from the second dynamic link library. If it cannot be obtained, i.e., the retrieval fails, and the process terminates with an exception. It should be noted that... Figure 3 This example illustrates the situation by showing that the target interface function exists in two dynamic link libraries.

[0076] For example, after starting the process of obtaining the mono interface function, it can be determined whether the handle of the first dynamic link library libmono.so corresponding to the target interface function can be obtained through NPTH_DL. If the determination result is successful, that is, it can be obtained, and the required mono interface function is obtained from libmono.so through NPTH_DL. If the determination result is unsuccessful, that is, it cannot be obtained, it can be further determined whether the handle of the second dynamic link library libmonobdwgc-2.0.so corresponding to the target interface function can be obtained through NPTH_DL. If the determination result is successful, the required mono interface function is obtained from libmonobdwgc-2.0.so through NPTH_DL. If the determination result is unsuccessful, the process terminates abnormally.

[0077] In addition, in other implementations, a corresponding file loading interface function can be specified when compiling the target application, and the specified file loading interface function can be hooked so that the specified file loading interface function loads the code to be run and the runtime library files required by the target application after it is called.

[0078] In some implementations, loading the code to be executed into the target domain of the target application may include the following steps:

[0079] Obtain the target domain of the target application; add the thread corresponding to the code to be executed to the target domain.

[0080] In this embodiment of the disclosure, the target domain of the target application can be obtained through the interface function provided by the runtime environment. After obtaining the target domain, the process corresponding to the code to be run can be added to the target domain, thereby completing the process of loading the code to be run into the target domain of the target application.

[0081] For example, taking a game written in C# in Unity as an example, you can call the mono_get_root_domain interface function to get the target domain of the game, and then call the mono_thread_attach interface function to add the process corresponding to the code to be run to the target domain.

[0082] Furthermore, in some implementations, to compile and run the code to be executed, a dynamic link library provided by the runtime environment can be invoked. For example, assuming the C# function to be executed (represented by the Latin letter F in this embodiment) is compiled into a dynamic link library (represented by the Latin letter A in this embodiment), and the function belongs to namespace B and class C, then after associating the code to be executed with the target domain of the target application, and after compiling the code to be executed into dynamic link library A and reading it into memory, first call `mono_image_open_from_data_with_name` to read A as `MonoImage*`, then call `mono_class_from_name` to get class C within A, then call `mono_class_get_method_from_name` to get F within C, and finally call `mono_runtime_invoke` to execute F, thus completing the process of compiling and running the code to be executed.

[0083] In some implementations, the code to be run can be obtained through text input. In this case, the step of obtaining the code to be run added for the target application in this embodiment of the disclosure may include the step of: obtaining the code to be run in response to the code input operation. In this case, after compiling and running the code to be run based on the target domain, the code running method in this embodiment of the disclosure may further include the step of: displaying the running result obtained by running the code to be run.

[0084] In this embodiment of the disclosure, code can be entered at a specified location on the code input interface, and the code at the specified location can be obtained as the code to be run. After obtaining the code to be run for the target application, the code to be run can be loaded into the target domain of the target application. The target domain includes the code to be run and the runtime library files required by the target application. Then, the code to be run can be compiled and run based on the target domain. After running the code to be run, the running result can be displayed on the interface.

[0085] For example, a target mode can be set in the target application to run the inserted code. This target mode could be a debug mode or a test mode, etc., so that after entering the target mode, such as... Figure 4 As shown, this displays a dynamic code execution interface. Figure 4 The displayed interface may include a code input area 401, a running result display area 402, and a code execution history display area 403. For example, after entering the code to be run, “XXXManager.Xxxtance.porX”, in the code input area 401, the backend can obtain “XXXManager.Xxxtance.porX” as the code to be run. After running “XXXManager.Xxxtance.porX”, the running result “2022-03-17 18:21:37:5001” can be displayed in the running result display area 402. At the same time, the code execution history display area 403 displays the previous execution history “XXXManager.Xxxtance.porX”.

[0086] In some implementations, a dynamic link library associated with the target domain can be invoked to compile and run the code to be executed. However, considering that the code execution method of this disclosure re-specifies the code input and the output of the execution result, in order to meet the actual needs of this disclosure, an existing dynamic link library can be modified to obtain a customized version of the dynamic link library. In this case, in this disclosure embodiment, compiling and running the code to be executed based on the target domain includes the following steps:

[0087] The target dynamic link library associated with the target domain is called to compile and run the code to be run. The code that calls the target dynamic link library includes the code entered through the code input operation, and the output location of the target dynamic link library includes the location where the running results are displayed.

[0088] In this embodiment of the disclosure, since the code of the target dynamic link library includes the code input through the code input operation, and the output location of the target dynamic link library includes the display location of the running results, after calling the target dynamic link library associated with the target domain, the code input through the code input operation can be determined as the code to be run, and the output result of the dynamic link library can be displayed at the display location of the running results.

[0089] Furthermore, considering that the number of target applications installed and running in a real computer is large, and the code execution method of this disclosure embodiment will not be executed for every program on the computer, the computer will also store a modified dynamic link library that performs similar functions to the target dynamic link library. Therefore, in order to avoid conflicts with the modified dynamic link library, in some implementations, the namespace of the target dynamic link library can be modified to avoid conflicts with the modified dynamic link library.

[0090] For example, dynamically executing C# code requires a library from the open-source Mono library called Mono.CSharp.dll. After modification, all namespaces Mono in the source code of this dynamic link library are changed to namespace XX, where XX can refer to any name.

[0091] Furthermore, considering that the original dynamic link library may contain some bugs, in some implementations, mono / mcs / mcs / namespace.cs can be modified. Specifically, the code ctx.Module.Compiler.Report.Error(433,loc,"The imported type`{0}' is defined multiple times",ts.GetSignatureForError()) can be removed to resolve an error that should not be reported when referencing the namespace.

[0092] Figure 5 This is a schematic diagram of module connections for a data acquisition device according to an exemplary embodiment. Figure 5 As shown, this disclosure provides a code execution device, which 500 may include:

[0093] The code acquisition module 510 is used to acquire the code to be executed for the target application;

[0094] Loading module 520 is used to load the code to be run into the target domain of the target application, wherein the target domain is associated with the runtime library files required to run the code to be run and the target application.

[0095] The execution module 530 is used to compile and run the code to be run based on the target domain.

[0096] Optionally, the device 500 also includes:

[0097] The target interface function acquisition module is used to acquire the target interface function, which is the interface function provided by the runtime environment of the target application.

[0098] A determination module is used to determine the file loading interface function from the target interface function;

[0099] The hook module is used to hook the file loading interface function so that, after the file loading interface function is called, it loads the runtime library files required to run the code to be run and the target application.

[0100] Optionally, the device 500 also includes:

[0101] The file to be loaded module is used to obtain the file to be loaded through the file loading interface function;

[0102] The determination module is used to determine whether the file to be loaded is a runtime library file required by the target application.

[0103] The runtime library file loading module is used to load the runtime library file required by the target application and the code to be run through the file loading interface function when the file to be loaded is the runtime library file required by the target application.

[0104] Optionally, the runtime library file required to run the code to be run and the target application is the complete runtime library file corresponding to the target application.

[0105] Optionally, module 520 is loaded, including:

[0106] The domain acquisition submodule is used to acquire the target domain of the target application.

[0107] Add a submodule to add the thread corresponding to the code to be run to the target domain.

[0108] Optionally, the code acquisition module includes a code acquisition submodule, used to acquire the code to be run in response to a code input operation. In this case, the code execution device further includes a result display module, used to display the execution result obtained by running the code to be run.

[0109] Optionally, the execution module 530 includes:

[0110] The execution submodule is used to call the target dynamic link library associated with the target domain, compile and run the code to be run, wherein the code that calls the target dynamic link library includes the code input through the code input operation, and the output location of the target dynamic link library includes the display location of the running results.

[0111] The specific implementation methods of each functional module of the device in the above embodiments have been described in detail in the section on methods, and will not be repeated here.

[0112] The following is for reference. Figure 6 The diagram illustrates a structural schematic of an electronic device 600 suitable for implementing embodiments of the present disclosure (e.g., the client or server in the foregoing embodiments). In embodiments of the present disclosure, the terminal device containing the client may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0113] like Figure 6 As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of electronic device 600. Processing device 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.

[0114] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0115] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, it performs the functions defined in the methods of embodiments of this disclosure.

[0116] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0117] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.

[0118] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0119] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to: acquire code to be run for a target application; load the code to be run into a target domain of the target application, the target domain being associated with runtime library files required for running the code to be run and the target application; and compile and run the code to be run based on the target domain.

[0120] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0121] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0122] The modules described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a module does not necessarily limit the module itself; for example, a code acquisition module can also be described as "a module for acquiring executable code for a target application".

[0123] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.

[0124] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0125] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0126] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0127] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative forms of implementing the claims. Regarding the apparatus in the above embodiments, the specific manner in which the various modules perform their operations has been described in detail in the embodiments relating to the method, and will not be elaborated upon here.

Claims

1. A code execution method, characterized in that, The method includes: Obtain the code to be executed for the target application; The code to be run is loaded into the target domain of the target application, and the target domain is associated with the runtime library files required by the target application to run the code; the code to be run is compiled and run based on the target domain; The method further includes: Obtain the target interface function, wherein the target interface function is an interface function provided by the runtime environment of the target application; Determine the file loading interface function from the target interface function; The file loading interface function is hooked so that, after being called, it loads the runtime library files required to run the code to be run and the target application.

2. The code execution method according to claim 1, characterized in that, After being called, the file loading interface function loads the runtime library files required to run the code to be executed and the target application through the following steps: The file to be loaded is obtained through the file loading interface function. Determine whether the file to be loaded is a runtime library file required by the target application; When the file to be loaded is a runtime library file required by the target application, the file loading interface function loads the code to be run and the runtime library file required by the target application.

3. The code execution method according to any one of claims 1-2, characterized in that, The runtime library file required to run the code to be run and the target application is the complete runtime library file corresponding to the target application.

4. The code execution method according to claim 1, characterized in that, The step of loading the code to be run into the target domain of the target application includes: Obtain the target domain of the target application; Add the thread corresponding to the code to be executed to the target domain.

5. The code execution method according to claim 1, characterized in that, The process of obtaining the code to be executed for the target application includes: In response to a code input operation, the code to be executed is obtained; After compiling and running the code to be run based on the target domain, the method further includes: The results of running the code to be run are displayed.

6. The code execution method according to claim 5, characterized in that, The process of compiling and running the code to be run based on the target domain includes: The target dynamic link library associated with the target domain is invoked to compile and run the code to be run. The code that invokes the target dynamic link library includes the code input through the code input operation, and the output location of the target dynamic link library includes the display location of the running result.

7. A code execution device, characterized in that, The device includes: The code acquisition module is used to acquire the executable code for a target application with missing source code. The loading module loads the code to be run into the target domain of the target application, and the target domain is associated with the runtime library files required to run the code and the target application. An execution module is used to compile and run the code to be run based on the target domain; The target interface function acquisition module is used to acquire the target interface function, which is the interface function provided by the runtime environment of the target application. A determination module is used to determine the file loading interface function from the target interface function; The hook module is used to hook the file loading interface function so that, after the file loading interface function is called, it loads the runtime library files required to run the code to be run and the target application.

8. A computer-readable medium having a computer program stored thereon, characterized in that, When executed by the processing device, the program implements the steps of the method according to any one of claims 1-6.

9. An electronic device, characterized in that, include: A storage device having at least one computer program stored thereon; At least one processing device is configured to execute the at least one computer program in the storage device to implement the steps of the method according to any one of claims 1-6.