CN113553124B - Application program running method, computing device and storage medium - Google Patents

Application program running method, computing device and storage medium Download PDF

Info

Publication number
CN113553124B
CN113553124B CN202110857198.5A CN202110857198A CN113553124B CN 113553124 B CN113553124 B CN 113553124B CN 202110857198 A CN202110857198 A CN 202110857198A CN 113553124 B CN113553124 B CN 113553124B
Authority
CN
China
Prior art keywords
application
application program
function
simulator
operating system
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110857198.5A
Other languages
Chinese (zh)
Other versions
CN113553124A (en
Inventor
赵志鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Deepin Technology Co ltd
Original Assignee
Wuhan Deepin Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Deepin Technology Co ltd filed Critical Wuhan Deepin Technology Co ltd
Priority to CN202110857198.5A priority Critical patent/CN113553124B/en
Publication of CN113553124A publication Critical patent/CN113553124A/en
Application granted granted Critical
Publication of CN113553124B publication Critical patent/CN113553124B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files

Abstract

The invention discloses an application program running method, a computing device and a storage medium, wherein the application program running method is executed in a first operating system of the computer device, a compatible layer compatible with a second operating system is arranged on the first operating system, and the running environment of the application program is the second operating system, and the method comprises the following steps: embedding a simulator in the compatible layer to form a virtual layer; generating an application self-compiler based on the compatible layer; generating, with an application self-compiler, a proxy application for the loading application that is adaptable to run on the first operating system; and starting the proxy application program in the virtual layer to realize the running of the application program on the first operating system.

Description

Application program running method, computing device and storage medium
This application is a divisional application of invention patent application 2021105756208 filed on 26/5/2021.
Technical Field
The invention relates to the field of internet, in particular to an application program running method, computing equipment and a storage medium.
Background
With the development and popularization of computers, various information security events at home and abroad, particularly, a prism door event, frequently occurs, and various countries sound alarm clocks, so that many countries begin to take measures for strengthening the information security of the country. The chinese domestic operating system driver, the daughters, is denoted by: if the operating system independently developed in China is not used, the back door key of the system is always mastered by other people, so that the information safety of China is not guaranteed, and the opportunity is objectively reserved for monitoring plans such as 'prism doors'.
From the perspective of security and industrial value, we must develop an operating system that is autonomously controllable, and it is an optimal choice to develop an operating system based on a Linux kernel (the kernel adopts an open-source Linux kernel and provides various Linux distribution versions of a desktop environment, and there are popular Ubuntu, RedHat, deep, UOS, and the like). Due to the absolute occupancy of the Windows system and the incompleteness of Linux desktop ecology, a large number of Windows application programs cannot be used after the existing computer systems of governments and enterprises are migrated from Windows to Linux, especially on home-made processors.
If Linux on a domestic processor (a processor based on a reduced instruction set, such as a spread and fly processor with an arm architecture, a Loongson processor with a mips architecture, etc.) can directly use a high-frequency application program with a Windows system x86 architecture (a complex instruction set), migration of Windows users to the Linux system is greatly facilitated, and meanwhile, more software developers can be prompted to actively develop a native application program for a Linux desktop, so that the Linux desktop ecological development enters a virtuous circle.
Disclosure of Invention
In view of the above, the present invention is proposed to provide an application program running method, a computing device and a storage medium which overcome or at least partially solve the above problems.
According to an aspect of the present invention, there is provided a method for running an application program, the method being executed in a first operating system of a computing device, a compatible layer compatible with a second operating system being arranged on the first operating system, and a running environment of the application program being the second operating system, the method comprising: embedding a simulator in the compatible layer to form a virtual layer; generating an application self-compiler based on the compatible layer; generating, with an application self-compiler, a proxy application for the loading application that is adaptable to run on the first operating system; and starting the proxy application program in the virtual layer to realize the running of the application program on the first operating system.
Optionally, in the method for running an application according to the present invention, before the step of embedding a simulator in the compatible layer to form the virtual layer, the method further includes the steps of: the simulator is preprocessed to enable the virtual simulator to embed a compatible layer.
Optionally, in the running method of the application program according to the present invention, the preprocessing the simulator includes the steps of: screening codes forming the simulator to obtain codes related to a process mode; code for a process mode is embedded in the compatibility layer.
Optionally, in the method for running an application according to the present invention, a simulator is embedded in the compatible layer, and the step of forming the virtual layer includes: creating a simulator file in the compatible layer; in the simulator file, storing a unique simulation object of each thread in a local storage space of each thread as a CPU simulator of an application program; a function for starting the CPU simulator is set.
Optionally, in the method for running an application according to the present invention, generating the application self-compiler based on the compatible layer includes: generating a compiling plug-in based on a filtering mechanism of a compiler; analyzing all functions in the compatible layer by using the compiling plug-in to obtain function prototypes of all functions in the compatible layer; and generating the application program self-compiler by compiling the plug-in and the function prototype.
Optionally, in the method for running an application according to the present invention, the step of generating, by using an application self-compiler, a proxy application that is adaptable to run on the first operating system for the application being loaded includes: reserving a predetermined region at the head of all functions of the compatible layer; acquiring function prototypes of all functions; and writing the signature information based on the function prototype into the proxy module in a predetermined area by using the application program self-compiler according to a predetermined template.
Optionally, in the method for running an application according to the present invention, the step of starting the proxy application at the virtual layer includes: and replacing the function address of the application program calling compatible layer with the function address of the application program calling proxy module.
Optionally, according to the method for running an application program of the present invention, the step of starting the proxy application program at the virtual layer further includes: and carrying out exception capture on the starting process of the agent application program.
According to yet another aspect of the invention, there is provided a computing device comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions comprising instructions for performing the above-described method.
According to yet another aspect of the present invention, there is provided a readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform the above-described method.
According to the scheme of the invention, on one hand, the code of the simulator is embedded in the compatible layer code, so that an operation environment is provided for the operation of the x86 application program on a non-x 86 architecture and non-Windows system, so that in the operation process of the application program, whether the target function to be called is the guest end code or the host end code can be automatically identified when the function is called, if the target function is the guest end code, the simulation execution of the CPU simulator is automatically started, and finally the simulation result is put back to the host end.
On the other hand, a filter mechanism of the compiler is utilized to develop a compiling plug-in, each API (application programming interface, the main function is to provide a function set) in the wire module is analyzed through the compiling plug-in, and a guest end proxy stub code of each API is dynamically generated.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 illustrates a prior art framework diagram 100 of method 1 for running a Windows x86 program in a non-x 86 architecture;
FIG. 2 shows a schematic diagram of a computing device 200, according to one embodiment of the invention;
FIG. 3 shows a flow diagram of a method 300 for execution of an application according to one embodiment of the invention;
FIG. 4 shows a flow diagram of a method 400 for an application to make a function call in accordance with one embodiment of the present invention.
FIG. 5 illustrates a block diagram 500 of an execution method that may be used for an application according to one embodiment of the invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Because of the different instruction sets caused by the difference of the architectures, the problem to be solved is firstly the simulation and conversion of cpu instruction and secondly the compatible layer environment for realizing Windows to run the Windows application program with the x86 architecture on the domestic processor.
There are roughly two known schemes for running Windows x86 programs in non-x 86 architectures:
the scheme is that a CPU simulator qemu process mode is directly used for simulating and running a wire of an x86 version and a PE format program of an x86 version, and the scheme has the defect that all third party libraries on which the wire depends in the qemu process mode are of an x86 version and are required to be simulated and executed, and compared with a native version, the surface performance of open research is reduced by about 10 times.
It should be noted that Wine is a compatible layer capable of running Windows applications on various POSIX-compatible operating systems (such as Linux, Mac OS X, BSD, etc.). Wine does not imitate the whole Windows system like a virtual machine, but dynamically converts Windows API calls into native POSIX calls, so that compared with a virtual machine mode, the consumed memory is greatly reduced, and the performance is almost the same as that of running on the Windows system. In addition, Wine is an open source project all over the world
It should be further noted that qemu is a well-known CPU simulator, and has two operation modes, respectively:
kernel mode: like virtualbox and vmware, a complete operating system can be run virtually;
and (3) process mode: the user mode at the host end (directly running the application on the physical cpu, in the description of the present embodiment, the wine running on the non-x 86 platform) directly simulates the running of the guest end program (indirectly running the application on the physical cpu through the instruction set, in the description of the present embodiment, the x86 application).
The second scheme is to compile a PE execution program in the window version of the qemu user mode, and load the execution program qemu-x86_64.exe.so by the window version, and a system architecture 100 of the scheme is shown in fig. 1. The scheme is characterized in that for each Windows module, a corresponding guest end proxy module needs to be implemented, a syscall event is started in the proxy module, a host end is entered from the guest end, and a host end Windows API is called. This results in that each Windows module needs to be written with one agent module, the code amount is large, and currently, the project only realizes the guest end agent module with less than 50 Windows core modules, which is about 10% of all the wine modules.
In order to avoid performance loss caused by separately starting the qemu process in the first scheme and huge migration workload caused by the fact that a user needs to write a guest end agent module in the second scheme, the technical scheme provided by the invention is provided. On one hand, a wire (compatible layer) is arranged on a domestic processor, and codes of a CPU simulator are embedded in the Wien codes, so that in the running process of an application program, whether a target function to be called is a guest end code or a host end code is automatically identified when the function is called, if the target function is the guest end code, the CPU simulator is automatically started to simulate and execute, and finally a simulation result is put back to the host end; on the other hand, a filter mechanism of the compiler is utilized to develop a compiling plug-in, each API (application programming interface, the main function is to provide a function set) in the wire module is analyzed through the compiling plug-in, and a guest end proxy stub code of each API is dynamically generated. Compared with the prior art, the technical scheme provided by the invention is faster than the first scheme in terms of performance and faster than the second scheme in terms of migration speed (the migration workload is less than that of the second scheme).
Specifically, as shown in FIG. 2, FIG. 2 illustrates a schematic diagram of a computing device 200 that may perform a method of running an application program according to one embodiment of the invention. As shown in FIG. 2, in a basic configuration 202, a computing device 200 typically includes a system memory 206 and one or more processors 204. A memory bus 208 may be used for communicating between the processor 204 and the system memory 206.
Depending on the desired configuration, the processor 204 may be any type of processing, including but not limited to: a microprocessor (μ P), a microcontroller (μ C), a Digital Signal Processor (DSP), or any combination thereof. The processor 204 may include one or more levels of cache, such as a level one cache 210 and a level two cache 212, a processor core 214, and registers 216. Example processor cores 214 may include Arithmetic Logic Units (ALUs), Floating Point Units (FPUs), digital signal processing cores (DSP cores), or any combination thereof. The example memory controller 218 may be used with the processor 204, or in some implementations the memory controller 218 may be an internal part of the processor 204.
Depending on the desired configuration, system memory 206 may be any type of memory, including but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. System memory 106 may include an operating system 220, one or more applications 222, and program data 224. The application 222 is actually a plurality of program instructions that direct the processor 204 to perform corresponding operations. In some embodiments, application 222 may be arranged to cause processor 204 to operate with program data 224 on an operating system.
Computing device 200 may also include an interface bus 240 that facilitates communication from various interface devices (e.g., output devices 242, peripheral interfaces 244, and communication devices 246) to the basic configuration 202 via the bus/interface controller 230. The example output device 242 includes a graphics processing unit 248 and an audio processing unit 250. They may be configured to facilitate communication with various external devices, such as a display or speakers, via one or more a/V ports 252. Example peripheral interfaces 244 can include a serial interface controller 254 and a parallel interface controller 256, which can be configured to facilitate communications with external devices such as input devices (e.g., keyboard, mouse, pen, voice input device, touch input device) or other peripherals (e.g., printer, scanner, etc.) via one or more I/O ports 258. An example communication device 246 may include a network controller 260, which may be arranged to facilitate communications with one or more other computing devices 262 over a network communication link via one or more communication ports 264.
A network communication link may be one example of a communication medium. Communication media may typically be embodied by computer readable instructions, data structures, program modules, and may include any information delivery media, such as carrier waves or other transport mechanisms, in a modulated data signal. A "modulated data signal" may be a signal that has one or more of its data set or its changes made in such a manner as to encode information in the signal. By way of non-limiting example, communication media may include wired media such as a wired network or private-wired network, and various wireless media such as acoustic, Radio Frequency (RF), microwave, Infrared (IR), or other wireless media. The term computer readable media as used herein may include both storage media and communication media.
In the computing device 200 according to the invention, the application 222 comprises a plurality of program instructions that perform the method 300.
FIG. 3 shows a flow diagram of a method 300 for execution of an application in accordance with one embodiment of the present invention. The method 300 is adapted to be executed in a first operating system of a computing device (e.g., the aforementioned computing device 200), on which a compatible layer compatible with a second operating system is disposed, the execution environment of the application being the second operating system. Illustratively, the first operating system is a linux system, the second operating system is a Windows system, and the compatible layer is a wine.
As shown in fig. 3, the method 300 is intended to run a Windows program of x86 architecture on a domestic processor, and starts with step S302, where a simulator is embedded in a compatible layer to form a virtual layer in step S302.
In one specific example, the simulator may be called unicorn, a fork version of qemu, which is an sdk library of CPU simulators.
The use of Unicorn is divided into these several steps:
the X86-32bit mode initializes the simulator object, and the specific execution code is as follows:
Figure BDA0003184534820000071
Figure BDA0003184534820000081
applying for a working memory or mapping an allocated memory to the simulator, wherein the specific execution codes are as follows:
uc_mem_map(uc,ADDRESS,2*1024*1024,UC_PROT_ALL);
initializing the register, and specifically executing the code as follows:
uc_reg_write(uc,UC_X86_REG_ECX,&r_ecx);
uc_reg_write(uc,UC_X86_REG_EDX,&r_edx);
printf(">>>ECX=0x%x\n",r_ecx);
printf(">>>EDX=0x%x\n",r_edx);
the registration event processing mainly concerns the sensor event and the segfault event, and specifically executes the following codes:
uc_hook_add(ret->uc,&ret->sysenter_hook,UC_HOOK_INSN,sysenter,ret,1,0,UC_X86_INS_SYSENTER);
uc_hook_add(ret->uc,&ret->segfault_hook,UC_HOOK_MEM_UNMAPPE D,segfault,ret,1,0);
when the syserter event is triggered, the notification can be given, and the API call of the guest end is converted into the API call of the host end, so that the guest end safely enters the host end.
When the segfault event is triggered, we can have an opportunity to map a new host-side memory segment into the process space of the guest side.
Simulating an execution code, wherein the specific execution code is as follows:
Figure BDA0003184534820000082
printing register values and results, the specific execution code is as follows:
printf("Emulation done.Below is the CPU context\n");
uc_reg_read(uc,UC_X86_REG_ECX,&r_ecx);
uc_reg_read(uc,UC_X86_REG_EDX,&r_edx);
printf(">>>ECX=0x%x\n",r_ecx);
printf(">>>EDX=0x%x\n",r_edx);
destroying the simulator object and releasing the resource, specifically executing the following codes:
uc_close(uc);
for a specific embedding process, the present embodiment provides the sub-steps of this step 302:
a simulator file is created in the compatible layer.
In the simulator file, the local memory space for each thread holds the unique simulation object of the thread as the CPU simulator of one application.
A function for starting the CPU simulator is set.
In a specific example, in a compatible layer wire, a module nedll is included, the module is a module for creating and managing processes and threads, an emulger.c file is newly added in a unix directory of an ntdll module, and a unique unicorn object of each wire thread is stored in the file to represent a cpu of a guest end in a local storage space of the thread; and exposes an x86_ estimator _ start function to call where execution of the simulation is needed, the code expression of the function is:
long long CDECL x86_emulator_start(void*addr,const char*sig,struct TO_ARG*args)
the first parameter of the function is the first address of the target function to be executed in a simulation mode, the second parameter is the prototype signature of the target function and describes the byte size of each parameter of the function, the third parameter is a specific parameter value transferred in a thread stack, and the return value is the operation result of the simulation execution.
In this step S302, the compatible layer can provide a runtime environment for running the Windows application on the linux system, and the simulator can provide a runtime environment for the application on a processor that is not x86 architecture.
In addition, in order to easily embed the simulator in the compatible layer, before the start of step S302, the following preparatory work is performed:
the simulator is preprocessed to enable the virtual simulator to embed the compatibility layer. Specifically, the codes constituting the simulator are screened to obtain the codes related to the process mode. Code for a process mode is embedded in the compatibility layer. Illustratively, the foregoing mentions that qmeu has two modes of operation, kernel mode and process mode, where we only preserve the code of qmeu's process mode, not only easier to embed in the wine code, but also more optimized in performance.
In step S304, an application self-compiler is generated based on the compatible layer.
Specifically, the step S304 includes the sub-steps of:
and generating a compiling plug-in based on a filtering mechanism of the compiler.
Analyzing all functions in the compatible layer by using the compiling plug-in to obtain function prototypes of all functions in the compatible layer;
and generating the application program self-compiler by compiling the plug-in and the function prototype.
Illustratively, in this example, the compiler selects LLVM, which is a modern, SSA-based compiler framework capable of supporting any static and dynamic compiled programming language. And developing a LLVM compiling plug-in by using a pass (filter) mechanism of the LLVM compiler, and analyzing the function prototype of each API of the wire module when obtaining the IR. And generating the application program self-compiler by using the compiling plug-in and the function prototype.
IR is an Intermediate Representation (Intermediate Representation) of the compiler, and is output data at the front end of the compiler and input data at the back end of the compiler. The design of IR embodies to a large extent the LLVM plug-in, modular design philosophy, with the various pass (filters) of LLVM acting in essence on LLVM IR.
In step S306, a proxy application that may be adapted to run on the first operating system is generated for the application being loaded using the application self-compiler.
Specifically, step S306 includes the following sub-steps:
reserving a predetermined region at the head of all functions of the compatible layer;
acquiring function prototypes of all functions;
and writing the signature information based on the function prototype into the proxy module in a predetermined area by using the application program self-compiler according to a predetermined template.
In one specific example, the generation process of the agent module is described in detail:
and (3) reserving 24 bytes of all the wire function headers during compiling as a proxy stub code area of the application program by using a compiling option-fpatcable-function-entry-24 of a compiler.
Using LLVM pass compiling plug-in to inherit from ModulePlass (Module Filter), overloading runOnModule method, traversing each function of each module of the wire by the method to obtain the prototype of each function, storing the prototype in a new ELF file section, wherein the section name can be defined as __ wire _ ctags __, and the framework code is as follows:
Figure BDA0003184534820000111
Figure BDA0003184534820000121
when the phones/winebuild modules of the compatible layer wire are linked to complete the wire module, according to the function prototype signature information stored in __ wire _ ctags section, filling the stub code of the application program agent according to the following template:
Figure BDA0003184534820000122
so far, the construction of the agent application is completed.
In step S308, the proxy application is started in the virtual layer to implement running the application on the first operating system.
Specifically, the function address of the application call compatible layer is replaced with the function address of the application call proxy module.
It is easily understood that the nature of application program execution is actually a process of calculating multiple functions in cooperation with each other, and the result of program execution is actually the result of function calculation.
In continuing the previous example, the program execution involves a process in which the application side calls a function in the virtual layer (the guest side calls the host side API) and the virtual layer calls back the application side function (the host side calls back the guest side function).
For the guest end to call the host end API, the method can be specifically completed through the following steps:
when the guest end loads the host end module, the function address of the import table of the guest module is changed from the host end function address to the stub code head address pointing to the guest end proxy, and the host end API is called for the guest end to prepare for work.
When calling a specific host API, a guest end triggers a sysester event, and in the sysester event, a dynacall is carried out by using a dyncall library according to a function parameter signature and specific parameters stored in a stack, wherein the code is as follows:
Figure BDA0003184534820000131
and finally returning the ret instruction of the agent at the guest end to the guest end.
For the host-side callback guest function, when the host-side callback guest function is executed, the execution needs to be simulated by means of Unicorn. The method can be specifically completed through the following steps:
and constructing the environment required by the Unicorn to execute the guest end instruction. Allocating stack space with a certain size for the Unicorn, acquiring a thread TEB where a callback function is located according to the NtCurrentTeb function, and initializing a register required by Unicorn simulation execution according to the TEB. The code is as follows:
unsigned char stack[STACK_SIZE]={0}
const uint64_t teb=(uint32_t)NtCurrentTeb();
uc_open(UC_ARCH_X86,UC_MODE_32,&uc);
init_gdtr(uc,teb);
uc_reg_write(uc,UC_X86_REG_ESP,(uint32_t*)&(stack+STACK_SIZE));
and transmitting the parameter of the callback function into a stack of the Unicorn, registering the sysexit instruction callback processing function in the Unicorn, stopping Unicorn simulation after the execution of the callback function is finished, and returning to the host end for continuous execution. The code is as follows:
Figure BDA0003184534820000141
in a specific example, a function call relation in the program execution process is described by taking the code call as an example, an application program needs to call a Windows API enum Windows enumerating a window titled win-test, where the enum Windows proc is a callback function defined by the application for Windows API callback. The code is as follows:
Figure BDA0003184534820000142
Figure BDA0003184534820000151
the flow of execution of function call method 400 is shown in FIG. 4.
According to the scheme provided by the invention, a cpu simulator is directly embedded in a wire code, whether a target function to be called is a guest end code or a host end code is automatically identified during function calling, if the target function is the guest end code, the cpu simulator is automatically started to simulate operation, and finally a simulation result is returned to the host end. And developing LLVM compiling plug-ins by using a pass (filter) mechanism of an open-source LLVM compiler, analyzing the prototype of each API of the wire module when obtaining IR, and dynamically generating a guest end proxy stub code segment of each API. The specific system frame 500 structure can be seen in fig. 5.
In addition, in order to perfect the scheme, the method also provides a function of capturing the abnormity generated in the function calling process when the application program runs and realizing the multithreading of the application program.
In some embodiments, when the guest side calls the host side API, exception trapping is handled in the sysester instruction callback function registered by Unicorn. The try catch function is implemented by setjmp and longjmp. The code is as follows:
#define TRY do{jmp_buf ex_buf__;switch(setjmp(ex_buf__)){case 0:while(1){
#define CATCH(x)break;case x:
#define FINALLY break;}default:{
#define ETRY break;}}}while(0)
#define THROW(x)longjmp(ex_buf__,x)
in some embodiments, creating a multi-threaded function at the guest end will eventually call the host end ntcreatetrhreadex function. Processing a thread callback function in the function, if the thread function comes from a guest end and needs to be packaged, creating and filling guest _ proxy _ stub, and returning a processed function pointer through dcbnallback; if the API is the host API, the function pointer is simply shifted by sizeof (guest _ proxy _ stub). The processed function pointer can be used to create a thread.
The various techniques described herein may be implemented in connection with hardware or software or, alternatively, with a combination of both. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embodied in tangible media, such as removable hard drives, U.S. disks, floppy disks, CD-ROMs, or any other machine-readable storage medium, wherein, when the program is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention.
In the case of program code execution on programmable computers, the computing device will generally include a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. Wherein the memory is configured to store program code; the processor is configured to perform the method of the invention according to instructions in said program code stored in the memory.
By way of example, and not limitation, readable media includes readable storage media and communication media. Readable storage media store information such as computer readable instructions, data structures, program modules or other data. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. Combinations of any of the above are also included within the scope of readable media.
In the description provided herein, algorithms and displays are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems may also be used with examples of this invention. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It will be appreciated that a variety of programming languages may be used to implement the teachings of the invention as described herein, and any descriptions of specific languages are provided above to disclose a preferred embodiment of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in a device as described in this embodiment or alternatively may be located in one or more devices different from the devices in this example. The modules in the foregoing examples may be combined into one module or may be further divided into multiple sub-modules.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
Furthermore, some of the described embodiments are described herein as a method or combination of method elements that can be performed by a processor of a computer system or by other means of performing the described functions. A processor having the necessary instructions for carrying out the method or method elements thus forms a means for carrying out the method or method elements. Further, the elements of the apparatus embodiments described herein are examples of the following apparatus: the means for performing the functions performed by the elements for the purpose of carrying out the invention.
As used herein, unless otherwise specified the use of the ordinal adjectives "first", "second", "third", etc., to describe a common object, merely indicate that different instances of like objects are being referred to, and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking, or in any other manner.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of this description, will appreciate that other embodiments can be devised which do not depart from the scope of the invention as described herein. Moreover, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter. Accordingly, many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the appended claims. The present invention has been disclosed in an illustrative rather than a restrictive sense with respect to the scope of the invention, as defined in the appended claims.

Claims (8)

1. An application program running method executed in a first operating system of a computer device, a compatible layer compatible with a second operating system being arranged on the first operating system, and a running environment of the application program being the second operating system, the method comprising:
creating a simulator in the compatible layer, the simulator being preprocessed to enable the simulator to embed the compatible layer to form a virtual layer;
in the simulator, a unique simulation object of each thread is stored in a local storage space of each thread and is used as a CPU simulator of an application program;
setting a function for starting the CPU simulator;
generating an application self-compiler based on the compatible layer;
generating, with the application self-compiler, a proxy application for the loading application that is adaptable to run on the first operating system;
and starting the agent application program at the virtual layer so as to run the application program on the first operating system.
2. The method of claim 1, wherein the pre-processing of the simulator comprises the steps of:
screening codes forming the simulator to acquire codes related to process modes in the codes;
embedding the code regarding process mode in the compatibility layer.
3. The method of claim 1, wherein the generating an application self-compiler based on the compatibility layer comprises:
generating a compiling plug-in based on a filtering mechanism of a compiler;
analyzing all functions in the compatible layer by using the compiling plug-in to obtain function prototypes of all functions in the compatible layer;
and generating an application program self-compiler through the compiling plug-in and the function prototype.
4. The method of claim 1, wherein generating, with an application self-compiler, a proxy application for a loading application that is adaptable to run on the first operating system comprises:
reserving a predetermined region at the head of all functions of the compatible layer;
acquiring function prototypes of all the functions;
and writing the signature information of the function prototype into a proxy module in the predetermined area by using the self-compiler of the application program according to a predetermined template.
5. The method of claim 4, wherein the step of launching the agent application at a virtual layer comprises:
and replacing the function address of the compatible layer called by the application program with the function address of the proxy module called by the application program.
6. The method of claim 1, wherein the step of launching the proxy application at the virtual layer further comprises:
and carrying out exception capture on the starting process of the agent application program.
7. A computing device, comprising:
at least one processor; and
a memory storing program instructions configured for execution by the at least one processor, the program instructions comprising instructions for performing the method of any of claims 1-6.
8. A readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform the method of any of claims 1-6.
CN202110857198.5A 2021-05-26 2021-05-26 Application program running method, computing device and storage medium Active CN113553124B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110857198.5A CN113553124B (en) 2021-05-26 2021-05-26 Application program running method, computing device and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110857198.5A CN113553124B (en) 2021-05-26 2021-05-26 Application program running method, computing device and storage medium
CN202110575620.8A CN113032108B (en) 2021-05-26 2021-05-26 Application program running method, computing device and storage medium

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN202110575620.8A Division CN113032108B (en) 2021-05-26 2021-05-26 Application program running method, computing device and storage medium

Publications (2)

Publication Number Publication Date
CN113553124A CN113553124A (en) 2021-10-26
CN113553124B true CN113553124B (en) 2022-06-21

Family

ID=76455772

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202110857198.5A Active CN113553124B (en) 2021-05-26 2021-05-26 Application program running method, computing device and storage medium
CN202110575620.8A Active CN113032108B (en) 2021-05-26 2021-05-26 Application program running method, computing device and storage medium

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN202110575620.8A Active CN113032108B (en) 2021-05-26 2021-05-26 Application program running method, computing device and storage medium

Country Status (2)

Country Link
CN (2) CN113553124B (en)
WO (1) WO2022247106A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113553124B (en) * 2021-05-26 2022-06-21 武汉深之度科技有限公司 Application program running method, computing device and storage medium
CN114186280B (en) * 2022-02-14 2022-05-20 统信软件技术有限公司 File access method, computing device and readable storage medium
CN115421785B (en) * 2022-08-23 2023-05-12 中科方德软件有限公司 Method, device and medium for transplanting application program
CN115454827B (en) * 2022-08-23 2023-08-11 中科方德软件有限公司 Compatibility detection method, system, equipment and medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1731347A (en) * 2004-08-06 2006-02-08 梁肇新 Linux-based Windows software compatible layer architecture
CN102364442A (en) * 2011-06-24 2012-02-29 浙大网新科技股份有限公司 Method for transplanting Wine from x86 to advanced risc machine (ARM) platform

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8209680B1 (en) * 2003-04-11 2012-06-26 Vmware, Inc. System and method for disk imaging on diverse computers
US7478388B1 (en) * 2004-04-21 2009-01-13 Vmware, Inc. Switching between multiple software entities using different operating modes of a processor in a computer system
CN103685539A (en) * 2013-12-23 2014-03-26 中国航天科工集团第二研究院七〇六所 Method for running Windows system on home-made processor platform
WO2018112855A1 (en) * 2016-12-22 2018-06-28 深圳前海达闼云端智能科技有限公司 Virtualisation method and device, electronic device, and computer program product
CN107545182B (en) * 2017-09-06 2019-11-15 武汉斗鱼网络科技有限公司 Around the method and system of function call chain detection in a kind of IOS application
CN109460280B (en) * 2017-09-06 2023-06-30 中兴通讯股份有限公司 Method and terminal for running program
CN113553124B (en) * 2021-05-26 2022-06-21 武汉深之度科技有限公司 Application program running method, computing device and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1731347A (en) * 2004-08-06 2006-02-08 梁肇新 Linux-based Windows software compatible layer architecture
CN102364442A (en) * 2011-06-24 2012-02-29 浙大网新科技股份有限公司 Method for transplanting Wine from x86 to advanced risc machine (ARM) platform

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
linux运行Windows模拟器,Wine(Windows模拟器);佚名;《www.blog.csdn.net/weixin_30711615/article/details/116631564》;20210430;全文 *
兼容Linux应用环境的多粒度全系统模拟平台-SandUPSim;沈林峰等;《计算机工程与应用》;20061001(第22期);全文 *
如何编写模拟器;佚名;《www.cnblogs.com/wacc/p/3568945.html》;20140226;全文 *
自修改代码逆向分析方法研究;王祥根;《中国优秀博士论文 信息科技》;20091015;全文 *

Also Published As

Publication number Publication date
CN113553124A (en) 2021-10-26
CN113032108B (en) 2021-08-20
CN113032108A (en) 2021-06-25
WO2022247106A1 (en) 2022-12-01

Similar Documents

Publication Publication Date Title
CN113553124B (en) Application program running method, computing device and storage medium
US9891900B2 (en) Generation of specialized methods based on generic methods and type parameterizations
Herdt et al. RISC-V based virtual prototype: An extensible and configurable platform for the system-level
US8621279B1 (en) System and method for generating emulation-based scenarios for Error Handling
US9811663B2 (en) Generic unpacking of applications for malware detection
US8321861B2 (en) Non-native program execution across multiple execution environments
JP2000347871A (en) Automatic stub/adapter generator
JP2004517390A (en) Analysis virtual machine
WO2022237098A1 (en) Heterogeneous program execution method and apparatus, and computing device and readable storage medium
US11928489B2 (en) Extension application mechanisms through intra-process operation systems
WO2008113291A1 (en) Method and system for calling functions
Crary et al. Foundational certified code in a metalogical framework
Gomes et al. A model-based concept for RTOS portability
CN113438273B (en) User-level simulation method and device for application program in Internet of things equipment
LU500621B1 (en) Enhancing shadow stack enforcement after process creation
Maas et al. A JVM for the Barrelfish Operating System
JP3270729B2 (en) Extended instruction set simulator
Keppel Runtime code generation
Efimov et al. Peripheral Device Register Support for Source Code Boilerplate Generator of QEMU Development Toolkit
Tijms Binary translation: Classification of emulators
Guo RISC-V
Yermolovich et al. Portable execution of legacy binaries on the Java virtual machine
Zheng et al. bpftime: userspace eBPF Runtime for Uprobe, Syscall and Kernel-User Interactions
Neumann et al. CRASH-worthy Trustworthy Systems R&D (CTSRD): CHERI System Architecture and Research
Thompson et al. Introducing the .NET Micro Framework

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant