WO2018036000A1 - 应用程序跨系统运行的方法和装置 - Google Patents

应用程序跨系统运行的方法和装置 Download PDF

Info

Publication number
WO2018036000A1
WO2018036000A1 PCT/CN2016/106221 CN2016106221W WO2018036000A1 WO 2018036000 A1 WO2018036000 A1 WO 2018036000A1 CN 2016106221 W CN2016106221 W CN 2016106221W WO 2018036000 A1 WO2018036000 A1 WO 2018036000A1
Authority
WO
WIPO (PCT)
Prior art keywords
target application
instruction
address
operating system
current operating
Prior art date
Application number
PCT/CN2016/106221
Other languages
English (en)
French (fr)
Inventor
刘绍海
阮贤武
郑任持
谢利洪
Original Assignee
百富计算机技术(深圳)有限公司
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 百富计算机技术(深圳)有限公司 filed Critical 百富计算机技术(深圳)有限公司
Priority to US15/552,034 priority Critical patent/US10303491B2/en
Publication of WO2018036000A1 publication Critical patent/WO2018036000A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/76Adapting program code to run in a different environment; Porting
    • 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/44536Selecting among different versions
    • 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
    • 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/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • G06F9/4484Executing subprograms
    • G06F9/4486Formation of subprogram jump address
    • 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution
    • 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/541Interprogram communication via adapters, e.g. between incompatible applications

Definitions

  • the present invention relates to the field of computer processing, and in particular to a method and apparatus for operating an application across a system.
  • a method for running an application across a system comprising: loading a target application; applying, for the target application, a memory space on a current operating system; and applying, according to the requested memory space address, the target application
  • the global variable address and the absolute jump instruction address are modified to be adapted to the memory space of the current operating system; and the SWI instruction of the target application is obtained; The SWI instruction is redirected to an instruction that invokes the current operating system.
  • the method further comprises: translating the instructions in the target application by means of binary translation.
  • the step of modifying the global variable address and the jump instruction address in the target application according to the requested memory space address to adapt to the memory space of the current operating system further includes: acquiring binary data of the target application; and analyzing the binary data to find global variables and absolute jump instructions in the target application.
  • the step of finding the global variable and the absolute jump instruction in the target application by analyzing the binary data comprises: analyzing the binary data of the target application, Locating an absolute address corresponding to the global variable and the absolute jump instruction in the target application; and extracting a global variable and an absolute jump instruction in the target application according to the located absolute address.
  • the method further includes: receiving a request by the target application to invoke an API function; responding to the request according to a weight The directed SWI instruction invokes the corresponding API function in the current operating system.
  • An apparatus for running an application across a system comprising: a loading module, configured to load a target application; an application module, configured to apply for a memory space on a current operating system for the target application; and modifying a module, configured to: Modifying the global variable address and the absolute jump instruction address in the target application according to the requested memory space address to adapt to the memory space of the current operating system; and the instruction obtaining module, configured to acquire the target application SWI instruction; a redirection module for redirecting the SWI instruction to an instruction that invokes a current operating system.
  • the apparatus further includes: a translation module for translating instructions in the target application in a binary translation manner.
  • the apparatus further includes: a data acquisition module, configured to acquire binary data of the target application; and an analysis module, configured to find the target application by analyzing the binary data Global variables and absolute jump instructions.
  • the analysis module includes: a positioning module, configured to locate an absolute address corresponding to the global variable and the absolute jump instruction in the target application by analyzing the binary data of the target application And an extraction module, configured to extract a global variable and an absolute jump instruction in the target application according to the located absolute address.
  • the apparatus further includes: a receiving module, configured to receive a request by the target application to invoke an API function; and a calling module, configured to invoke the current operation according to the redirected SWI instruction in response to the request The corresponding API function in the system.
  • the method and device for running the above application across the system by loading the target application, applying for a memory space on the current operating system for the target application, and the global variable address and absolute hop in the target application according to the requested memory space address.
  • the instruction address is modified to adapt to the memory space of the current operating system, obtain the SWI instruction of the target application, and redirect the SWI instruction to the instruction that calls the current operating system.
  • the above method realizes the application of other system applications by modifying the global variable address and the absolute jump instruction address in the target application and redirecting the original SWI instruction of the target application to the instruction of calling the current operating system. Running on the system, this method does not need to modify the source code of the target application, which greatly simplifies the operation of the application across the system.
  • 1 is an internal structural diagram of a terminal in an embodiment
  • FIG. 2 is a flow chart of a method for running an application across a system in an embodiment
  • FIG. 3 is a flow chart of a method for running an application across a system in another embodiment
  • FIG. 4 is a flow chart of a method for analyzing binary data to find global variables and absolute jump instructions in an embodiment
  • FIG. 5 is a flow chart of a method for running an application across a system in still another embodiment
  • FIG. 6 is a block diagram showing the structure of an apparatus for running an application across a system in an embodiment
  • FIG. 7 is a block diagram showing the structure of an apparatus for running an application across a system in another embodiment
  • FIG. 8 is a block diagram showing the structure of an apparatus for running an application across a system in still another embodiment
  • FIG. 9 is a structural block diagram of an analysis module in an embodiment
  • Figure 10 is a block diagram showing the structure of an apparatus in which an application runs across a system in still another embodiment.
  • the internal structure of the terminal 100 is as shown in FIG. These include processors connected via a system bus, internal memory, non-volatile storage media, network interfaces, display screens, and input devices.
  • the terminal 100 The non-volatile storage medium stores an operating system, and also includes an apparatus for running an application across a system, the apparatus running across the system for implementing a method of running an application across a system.
  • the processor is used to provide computing and control capabilities to support the operation of the entire terminal.
  • the internal memory in the terminal provides an environment for the operation of the device running across the system in the non-volatile storage medium, and the internal memory can store computer readable instructions, when the computer readable instructions are executed by the processor Enables the processor to perform a method of running an application across systems.
  • the network interface is used to connect to the network for communication.
  • the display screen of the terminal may be a liquid crystal display or an electronic ink display screen, and the input device may be a touch layer covered on the display screen, or may be a button, a card slot, a trackball or a touchpad provided on the outer casing of the electronic device. It can also be an external keyboard, trackpad or mouse.
  • the terminal can be POS, mobile, tablet or personal digital assistant or wearable device.
  • Figure 1 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation of the terminal to which the solution of the present application is applied.
  • the specific terminal may include more or less than shown in the figure. Parts, or some parts, or different parts.
  • a method for running an application across a system comprising:
  • Step 202 loading the target application.
  • the target application refers to an application developed based on other operating systems that cannot be directly run on the current operating system.
  • a process virtual machine is proposed, through which the target application runs across systems. First, start the process virtual machine to load the target application. The process virtual machine only needs to provide a runnable environment for the application, and does not involve specific hardware. The process virtual machine runs on the upper layer of the operating system and provides corresponding support for the execution and termination of the application.
  • Step 204 Apply for a memory space on the current operating system for the target application.
  • the target application after the virtual machine loads the target application, the target application applies for a memory space on the current operating system to be able to run on the current operating system. Specifically, when the virtual machine is started, the target application applies for the same virtual address space as the target application absolute address on the current operating system, and then the target application is copied to the address, and the global address is found according to the segment address. variable.
  • Step 206 Modify the global variable address and absolute jump instruction address in the target application according to the requested memory space address to adapt to the memory space of the current operating system.
  • the global variable address and the absolute jump instruction address in the target application are modified according to the requested memory space address to be adapted to the memory space of the current operating system.
  • the global variable is a variable that can be referenced by all objects or functions of the application
  • the absolute jump instruction is a jump instruction whose destination address is an absolute address.
  • the binary data of the target application is obtained, and the global variable and the absolute jump instruction in the target application are found by analyzing the binary data, and then the global variable address in the target application is determined according to the address of the current system applied for.
  • the absolute jump instruction address is modified to fit the memory space of the current operating system.
  • Step 208 Obtain an SWI instruction of the target application.
  • SWI Software Interrupt
  • An instruction is an instruction that an application uses to access an operating system.
  • the application cannot directly operate on the operating system, and must call the API provided by the operating system (Application Program) Interface, application interface) interface, and operating system API interface is based on SWI
  • the instruction switches to kernel mode before it can operate on the hardware. This is because the operating system assigns the operating authority of the hardware to the kernel.
  • the application cannot use the hardware at will. When using the hardware, it must first make a request to the operating system, and the operating system kernel helps the application to implement its operation.
  • the operating system provides the application with some kernel functions with predetermined functions, that is, the interface called by the system. API.
  • the system call passes the application's request to the kernel, calls the corresponding kernel function to complete the required processing, and returns the processing result to the application.
  • Step 210 Redirect the SWI instruction to an instruction that invokes the current operating system.
  • the target application if the target application needs to invoke the operating system, it will be called by the SWI instruction, due to the original in the target application.
  • the SWI instruction is an instruction that calls the original operating system, so when the data of the target application is adapted to the requested memory space, the SWI instruction in the target application is found, specifically, SWI. Instructions are formatted (including 24-bit valid immediates), and SWI instructions can be found based on this format. Then the original SWI The instruction is modified to trigger the instruction of the current operating system, so that it enters the system call of the current system package, thereby implementing the target application to run in the current operating system.
  • the virtual machine applies the memory space of the target application to the current operating system by loading the target application, and the global variable address and the absolute jump instruction address in the target application according to the requested memory space address. Modify to fit the memory space of the current operating system to obtain the target application
  • the SWI instruction redirects the SWI instruction to an instruction that calls the current operating system.
  • the above method modifies the global variable address and the absolute jump instruction address in the target application and the original target application.
  • SWI The instruction is redirected to the instruction of the current operating system, and the application of the other system is run on the current operating system.
  • the method does not need to modify the source code of the target application, which greatly simplifies the operation of the application across the system.
  • the method further comprises: translating the instructions in the target application by using a binary translation.
  • the process virtual machine when the target application is loaded, the process virtual machine analyzes the target application, and the related instructions and SWI of the location need to be modified.
  • the instructions are translated in binary to run the target application.
  • binary translation occupies less memory resources and can effectively increase the speed of running the process virtual machine. This is because the process of interpreting execution requires more computation and requires more resources to store intermediate data and results. After the binary translation method translates the code, you can directly Running on the CPU does not require an interpreted process.
  • the step of modifying the global variable address and the jump instruction address in the target application according to the requested memory space address to adapt to the memory space of the current operating system further includes:
  • Step 212 Obtain binary data of the target application.
  • Binary data is the data representation used by computer systems because computer systems only recognize 0 and 1.
  • Step 2 14 Find out the global variables and absolute jump instructions in the target application by analyzing the binary data.
  • the virtual machine finds global variables and absolute jump instructions in the target application by analyzing the binary data of the target application. Specifically, first, the absolute address location of the target application is found by analyzing the binary data of the target application, and then the global variable and the absolute jump instruction are found according to the absolute address location of the target application.
  • the steps of finding global variables and absolute jump instructions in the target application by analyzing the binary data include:
  • Step 214A By analyzing the binary data of the target application, the absolute address corresponding to the global variable and the absolute jump instruction in the target application is located.
  • an absolute address refers to an independent address, that is, a physical storage address.
  • Step 214B Extract global variables and absolute jump instructions in the target application according to the located absolute addresses.
  • the global variable is a variable that can be referenced by all objects or functions of the application
  • the absolute jump instruction is a jump instruction whose destination address is an absolute address.
  • the global variable and the absolute jump instruction in the target application are extracted by the located absolute address, so that the global variable and the absolute jump instruction are copied into the memory space of the current operating system, thereby adapting to the current operating system.
  • the method for running the foregoing application across a system further includes:
  • Step 214 Receive a request initiated by the target application to invoke an API function.
  • the virtual machine After the target application is run on the current system, if the target application needs to call the current system, then the virtual machine needs to be called. Specifically, the virtual machine receives the calling API initiated by the target application. Request for the function.
  • Step 216 the response request invokes the corresponding API function in the current operating system according to the redirected SWI instruction.
  • the SWI in the target application has been The instruction redirection is to invoke the instruction of the current system, so after receiving the request of the API function initiated by the target application, the virtual machine can directly call the corresponding system in the current system according to the redirected SWI instruction. API function.
  • Monitor and Prolin are two operating systems of a POS terminal, wherein The Monitor operating system has low resource consumption, simple functions, and convenient programming. There are many applications developed based on the Monitor system. Prolin Operating system resources are consumed, but they have inherent advantages for multitasking, video playback, and multimedia support. There are relatively few applications developed based on the Prolin system. Generally based on different customer needs, at different POS Run the Monitor system and the Prolin system separately on the terminal. Monitor and Prolin each have their own advantages, and the two are complementary. So if it can be achieved Monitor's applications can run on the Prolin operating system to meet the needs of a variety of customers. But because the API interfaces are completely different, it is based on Monitor.
  • an apparatus for running an application across a system comprising:
  • a load module 602 is used to load the target application.
  • the application module 604 is configured to apply for a memory space on the current operating system for the target application.
  • Modify module 606 And modifying the global variable address and the absolute jump instruction address in the target application according to the requested memory space address to adapt to the memory space of the current operating system.
  • the instruction acquisition module 608 is configured to obtain an SWI instruction of the target application.
  • the redirecting module 610 is configured to redirect the SWI instruction to an instruction that invokes a current operating system.
  • the apparatus for running the foregoing application across a system further includes:
  • the translation module 603 is configured to translate the instructions in the target application by means of binary translation.
  • the apparatus for running the foregoing application across a system further includes:
  • the data obtaining module 612 is configured to obtain binary data of the target application.
  • Analysis module 614 And for analyzing global data and absolute jump instructions in the target application by analyzing the binary data.
  • the analysis module 614 includes:
  • Positioning module 614A And configured to locate an absolute address corresponding to the global variable and the absolute jump instruction in the target application by analyzing the binary data of the target application;
  • the extraction module 614B is configured to extract the global variable and the absolute jump instruction of the target application according to the located absolute address.
  • the apparatus for running the foregoing application across a system further includes:
  • the receiving module 616 is configured to receive a request that is invoked by the target application to invoke an API function
  • Calling module 618 in response to the request, calling a corresponding API in the current operating system according to the redirected SWI instruction Function.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

一种应用程序跨系统运行的方法和装置,所述方法包括:加载目标应用程序(202);为所述目标应用程序在当前操作系统上申请内存空间(204);根据申请到的内存空间地址对所述目标应用程序中的全局变量地址和绝对跳转指令地址进行修改,以适配到当前操作系统的内存空间(206);获取所述目标应用程序的SWI指令(208);将所述SWI指令重定向为调用当前操作系统的指令(210)。该方法不需要修改目标应用程序的源代码,就可以实现目标应用程序的跨系统运行,大大简化了应用程序跨系统运行的操作。

Description

应用程序跨系统运行的方法和装置
【技术领域】
本发明涉及计算机处理领域,特别是涉及一种应用程序跨系统运行的方法和装置。
【背景技术】
随着互联网的发展,为了满足不同的操作需求,在不同的终端中可能会应用不同的操作系统,比如,为了满足不同客户的需求,在不同的POS终端上可能需要安装不同的操作系统。而应用程序的开发是基于操作系统的,由于不同的操作系统API接口往往不同,也就意味着基于某个操作系统开发的应用程序不能直接在别的操作系统上运行。需要对原有的应用程序的代码进行修改才能在别的操作系统上运行,操作过程非常麻烦。
【发明内容】
基于此,有必要针对上述问题,提供一种操作简便的应用程序跨系统运行的方法和装置。
一种应用程序跨系统运行的方法,所述方法包括:加载目标应用程序;为所述目标应用程序在当前操作系统上申请内存空间;根据申请到的内存空间地址对所述目标应用程序中的全局变量地址和绝对跳转指令地址进行修改,以适配到当前操作系统的内存空间;获取所述目标应用程序的SWI指令; 将所述SWI指令重定向为调用当前操作系统的指令。
在其中一个实施例中,在所述加载目标应用程序的步骤之后还包括:采用二进制翻译的方式对所述目标应用程序中的指令进行翻译。
在其中一个实施例中,所述根据申请到的所述内存空间地址对所述目标应用程序中的全局变量地址和跳转指令地址进行修改,以适配到当前操作系统的内存空间的步骤之前还包括:获取所述目标应用程序的二进制数据;通过对所述二进制数据进行分析找出所述目标应用程序中的全局变量和绝对跳转指令。
在其中一个实施例中,所述通过对所述二进制数据进行分析找出所述目标应用程序中的全局变量和绝对跳转指令的步骤包括:通过对所述目标应用程序的二进制数据进行分析,定位出所述目标应用程序中全局变量和绝对跳转指令对应的绝对地址;根据定位出的所述绝对地址提取所述目标应用程序中的全局变量和绝对跳转指令。
在其中一个实施例中,在所述将所述SWI指令重定向为调用当前操作系统的指令的步骤之后还包括:接收所述目标应用程序发起的调用API函数的请求;响应所述请求根据重定向的SWI指令调用当前操作系统中对应的API函数。
一种应用程序跨系统运行的装置,所述装置包括:加载模块,用于加载目标应用程序;申请模块,用于为所述目标应用程序在当前操作系统上申请内存空间;修改模块,用于根据申请到的内存空间地址对所述目标应用程序中的全局变量地址和绝对跳转指令地址进行修改,以适配到当前操作系统的内存空间;指令获取模块,用于获取所述目标应用程序的SWI指令;重定向模块,用于将所述SWI指令重定向为调用当前操作系统的指令。
在其中一个实施例中,所述装置还包括:翻译模块,用于采用二进制翻译的方式对所述目标应用程序中的指令进行翻译。
在其中一个实施例中,所述装置还包括:数据获取模块,用于获取所述目标应用程序的二进制数据;分析模块,用于通过对所述二进制数据进行分析找出所述目标应用程序中的全局变量和绝对跳转指令。
在其中一个实施例中,所述分析模块包括:定位模块,用于通过对所述目标应用程序的二进制数据进行分析,定位出所述目标应用程序中全局变量和绝对跳转指令对应的绝对地址;提取模块,用于根据定位出的所述绝对地址提取所述目标应用程序中的全局变量和绝对跳转指令。
在其中一个实施例中,所述装置还包括:接收模块,用于接收所述目标应用程序发起的调用API函数的请求;调用模块,用于响应所述请求根据重定向的SWI指令调用当前操作系统中对应的API函数。
上述应用程序跨系统运行的方法和装置,通过加载目标应用程序,为该目标应用程序在当前操作系统上申请内存空间,根据申请到的内存空间地址对目标应用程序中的全局变量地址和绝对跳转指令地址进行修改,以适配到当前操作系统的内存空间,获取目标应用程序的SWI指令,将该SWI指令重定向为调用当前操作系统的指令。上述方法通过对目标应用程序中的全局变量地址和绝对跳转指令地址进行修改以及将目标应用程序的原有SWI指令重定向为调用当前操作系统的指令,实现将其他系统的应用程序在当前操作系统上运行,该方法不需要修改目标应用程序的源代码,大大简化了应用程序跨系统运行的操作。
【附图说明】
图1为一个实施例中终端的内部结构图;
图2为一个实施例中应用程序跨系统运行的方法流程图;
图3为另一个实施例中应用程序跨系统运行的方法流程图;
图4为一个实施例中对二进制数据进行分析找出全局变量和绝对跳转指令的方法流程图;
图5为又一个实施例中应用程序跨系统运行的方法流程图;
图6为一个实施例中应用程序跨系统运行的装置结构框图;
图7为另一个实施例中应用程序跨系统运行的装置结构框图;
图8为又一个实施例中应用程序跨系统运行的装置结构框图;
图9为一个实施例中分析模块的结构框图;
图10为再一个实施例中应用程序跨系统运行的装置结构框图。
【具体实施方式】
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。
如图 1 所示,在一个实施例中,终端 100 的内部结构如图 1 所示, 包括通过系统总线连接的处理器、内存储器、非易失性存储介质、网络接口、显示屏和输入装置。其中,该终端 100 的非易失性存储介质存储有操作系统,还包括一种应用程序跨系统运行的装置,该应用程序跨系统运行的装置用于实现一种应用程序跨系统运行的方法。该处理器用于提供计算和控制能力,支撑整个终端的运行。终端中的内存储器为非易失性存储介质中的应用程序跨系统运行的装置的运行提供环境,该内存储器中可储存有计算机可读指令,该计算机可读指令被处理器执行时,可使得处理器执行一种应用程序跨系统运行的方法。网络接口用于连接到网络进行通信。 终端的显示屏可以是液晶显示屏或者电子墨水显示屏等,输入装置可以是显示屏上覆盖的触摸层,也可以是电子设备外壳上设置的按键、插卡槽、轨迹球或触控板,也可以是外接的键盘、触控板或鼠标等。该终端可以是 POS 机、手机、平板电脑或者个人数字助理或穿戴式设备等。 本 领域技术人员可以理解,图 1 中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的终端的限定,具体的终端可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
如图 2 所示,在一个实施例中,提出了一种应用程序跨系统运行的方法,该方法包括:
步骤 202 ,加载目标应用程序。
具体的,目标应用程序是指不能直接在当前操作系统上运行的基于其他操作系统开发的应用程序。为了使目标应用程序能够实现跨系统运行,提出了一种进程虚拟机,通过该进程虚拟机来实现目标应用程序的跨系统运行。首先,启动该进程虚拟机加载目标应用程序。其中,进程虚拟机只需要为应用程序提供一个可运行的环境,不涉及到具体硬件,进程虚拟机运行在操作系统的上层,为应用程序的执行和终止提供相应的支持。
步骤 204 ,为目标应用程序在当前操作系统上申请内存空间。
在本实施例中,虚拟机加载目标应用程序后,为该目标应用程序在当前操作系统上申请内存空间,以便在当前操作系统上能够运行。具体的,虚拟机启动的时候会为目标应用程序在当前操作系统上申请和与该目标应用程序绝对地址一样的虚拟地址空间,然后把目标应用程序拷贝到这个地址上,根据段地址找出全局变量。
步骤 206 ,根据申请到的内存空间地址对目标应用程序中的全局变量地址和绝对跳转指令地址进行修改,以适配到当前操作系统的内存空间。
在本实施例中,根据申请到的内存空间地址对目标应用程序中的全局变量地址和绝对跳转指令地址进行修改,以适配到当前操作系统的内存空间。其中,全局变量是可以被本应用程序所有对象或函数引用的变量,绝对跳转指令是跳转的目的地址是一个绝对地址的跳转指令。具体的,获取目标应用程序的二进制数据,通过对二进制数据进行分析找出目标应用程序中的全局变量和绝对跳转指令,然后根据申请到的当前系统的地址对目标应用程序中的全局变量地址和绝对跳转指令地址进行修改,以适配到当前操作系统的内存空间。
步骤 208 ,获取目标应用程序的 SWI 指令。
具体的, SWI ( Software Interrupt ,软中断) 指令是应用程序用来访问操作系统的指令。应用程序是不能直接对操作系统进行操作的,必须通过调用操作系统提供的 API ( Application Program Interface , 应用程序接口 )接口才可以,而操作系统 API 接口是根据 SWI 指令切换到内核态的,然后才能对硬件进行操作。这是因为操作系统是将硬件的操作权限交给内核来管理的,应用程序是不能随意使用硬件的,使用硬件时要先向操作系统发出请求,操作系统内核帮助应用程序实现其操作。操作系统提供给应用程序一些具备预定功能的内核函数,即系统调用的接口 API 。系统调用把应用程序的请求传给内核,调用相应的内核函数完成所需要的处理,然后将处理结果返回给应用程序。
步骤 210 ,将 SWI 指令重定向为调用当前操作系统的指令。
在本实施例中,如果目标应用程序需要调用操作系统,一定会通过 SWI 指令来调用,由于目标应用程序中原有的 SWI 指令是指向调用原有操作系统的指令,所以当把目标应用程序的数据适配到申请的内存空间后,找到目标应用程序中的 SWI 指令,具体的, SWI 指令是有一定构成格式的(包括 24 位有效立即数),根据这个构成格式就可以找出 SWI 指令。然后将原有的 SWI 指令修改为触发当前操作系统的指令,这样就进入了当前系统封装的系统调用中,从而实现了将目标应用程序运行在当前操作系统中。
在本实施例中,虚拟机通过加载目标应用程序,为该目标应用程序在当前操作系统上申请内存空间,根据申请到的内存空间地址对目标应用程序中的全局变量地址和绝对跳转指令地址进行修改,以适配到当前操作系统的内存空间,获取目标应用程序的 SWI 指令,将该 SWI 指令重定向为调用当前操作系统的指令。上述方法通过对目标应用程序中的全局变量地址和绝对跳转指令地址进行修改以及将目标应用程序的原有 SWI 指令重定向为调用当前操作系统的指令,实现将其他系统的应用程序在当前操作系统上运行,该方法不需要修改目标应用程序的源代码,大大简化了应用程序跨系统运行的操作。
在一个实施例中,在所述加载目标应用程序的步骤之后还包括:采用二进制翻译的方式对目标应用程序中的指令进行翻译。
在本实施例中,在加载目标应用程序时,进程虚拟机对目标应用程序进行分析,将需要修改位置的相关指令和 SWI 指令采用二进制进行翻译,以便运行该目标应用程序。二进制翻译相对于传统的解释执行的方式,占用的内存资源少,可以有效的提高进程虚拟机运行的速度。这是因为解释执行的过程需要较多的计算,也需要较多的资源来存储中间数据和结果。二进制翻译方式把代码翻译之后,就可以直接在 CPU 上运行,不需要经过解释的过程。
如图 3 所示,在一个实施例中,根据申请到的内存空间地址对目标应用程序中的全局变量地址和跳转指令地址进行修改,以适配到当前操作系统的内存空间的步骤之前还包括:
步骤 212 ,获取目标应用程序的二进制数据。
具体的,虚拟机加载目标应用程序,获取该目标应用程序的二进制数据, 二进制数据是计算机系统采用的数据表示方法,因为计算机系统只识别 0 和 1 。
步骤 2 14 ,通过对二进制数据进行分析找出目标应用程序中的全局变量和绝对跳转指令。
在本实施例中,虚拟机通过对目标应用程序的二进制数据进行分析找出目标应用程序中的全局变量和绝对跳转指令。具体的,首先,通过对目标应用程序的二进制数据进行分析找出该目标应用程序的绝对地址定位,然后根据目标应用程序的绝对地址定位找出全局变量和绝对跳转指令。
如图 4 所示,在一个实施例中,通过对二进制数据进行分析找出目标应用程序中的全局变量和绝对跳转指令的步骤包括:
步骤 214A ,通过对目标应用程序的二进制数据进行分析,定位出目标应用程序中全局变量和绝对跳转指令对应的绝对地址。
具体的,绝对地址是指独立地址,即实实在在的物理存储地址。通过对目标应用程序的二进制数据进行分析,可以定位出目标应用程序中的全局变量和绝对跳转指令对应的绝对地址,然后根据该绝对地址就可以找到全局变化和绝对跳转指令。
步骤 214B ,根据定位出的绝对地址提取目标应用程序中的全局变量和绝对跳转指令。
具体的,全局变量是可以被本应用程序所有对象或函数引用的变量,绝对跳转指令是跳转的目的地址是一个绝对地址的跳转指令。通过定位出的绝对地址来提取目标应用程序中的全局变量和绝对跳转指令,以便将该全局变量和绝对跳转指令拷贝到当前操作系统的内存空间中,从而适配到当前操作系统。
如图 5 所示,在一个实施例中,上述应用程序跨系统运行的方法还包括:
步骤 214 ,接收目标应用程序发起的调用 API 函数的请求。
在本实施例中,将目标应用程序运行在当前系统后,如果目标应用程序需要调用当前系统,那么需要经过虚拟机来进行调用。具体的,虚拟机接收目标应用程序发起的调用 API 函数的请求。
步骤 216 ,响应请求根据重定向的 SWI 指令调用当前操作系统中对应的 API 函数。
在本实施例中,由于已经将目标应用程序中的 SWI 指令重定向为了调用当前系统的指令,所以虚拟机接收到目标应用程序发起的调用 API 函数的请求后,直接可以根据重定向后的 SWI 指令调用当前系统中对应的 API 函数。
在一个具体的实施例中, Monitor 和 Prolin 是 POS 终端的两套操作系统,其中, Monitor 操作系统资源消耗少,功能简单,编程方便,基于 Monitor 系统开发的应用程序多。 Prolin 操作系统资源消耗多,但对多任务、视频播放、多媒体支持有先天的优势,基于 Prolin 系统开发的应用程序相对比较少。一般基于不同的客户需求,在不同的 POS 终端上分别运行 Monitor 系统和 Prolin 系统。 Monitor 和 Prolin 的各有自己的优势,两者属于相互补充的关系。所以如果能实现将 Monitor 的应用程序能够运行在 Prolin 操作系统上,就能够实现满足各种客户的需求。但是由于两者 API 接口完全不一样,所以基于 Monitor 开发的应用不能直接在 Prolin 系统上运行。传统的方法一般是采用 QEMU (虚拟操作系统模拟器)来实现一个系统虚拟机, QEMU 为基于 Montior 开发的应用程序模拟一个和真实芯片相似的环境,包括处理器,内存环境,各种外设(定时器,中断,串口等)。但是这种方法需要占用的内存大,由于需要模拟硬件设备,并且指令运行也只能采用解释的方法运行,虚拟机的运行速度会大大降低。本实施例中通过开发一个进程虚拟机实现让 Monitor 的应用能够直接在 Prolin 上运行,可以采用解释执行和二进制翻译运行的方式,相比与解释执行,二进制把代码翻译之后,可以直接在 CPU 上运行。在本实施例中,能够采用二进制翻译的方式进行翻译,由于二进制翻译不需要解释的过程,所以需要的资源更少,速度更快。
如图 6 所示,在一个实施例中,提出了一种应用程序跨系统运行的装置,该装置包括:
加载模块 602 ,用于加载目标应用程序。
申请模块 604 ,用于为所述目标应用程序在当前操作系统上申请内存空间。
修改模块 606 ,用于根据申请到的内存空间地址对所述目标应用程序中的全局变量地址和绝对跳转指令地址进行修改,以适配到当前操作系统的内存空间。
指令获取模块 608 ,用于获取所述目标应用程序的 SWI 指令。
重定向模块 610 ,用于将所述 SWI 指令重定向为调用当前操作系统的指令。
如图 7 所示,在一个实施例中,上述应用程序跨系统运行的装置还包括:
翻译模块 603 ,用于采用二进制翻译的方式对所述目标应用程序中的指令进行翻译。
如图 8 所示,在一个实施例中,上述应用程序跨系统运行的装置还包括:
数据获取模块 612 ,用于获取所述目标应用程序的二进制数据。
分析模块 614 ,用于通过对所述二进制数据进行分析找出所述目标应用程序中的全局变量和绝对跳转指令。
如图 9 所示,在一个实施例中,分析模块 614 包括:
定位模块 614A ,用于通过对所述目标应用程序的二进制数据进行分析,定位出所述目标应用程序中全局变量和绝对跳转指令对应的绝对地址;
提取模块 614B ,用于根据定位出的所述绝对地址提取所述目标应用程序的全局变量和绝对跳转指令。
如图 10 所示,在一个实施例中,上述应用程序跨系统运行的装置还包括:
接收模块 616 ,用于接收所述目标应用程序发起的调用 API 函数的请求;
调用模块 618 ,用于响应所述请求根据重定向的 SWI 指令调用当前操作系统中对应的 API 函数。
以上所述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
以上所述实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。

Claims (10)

  1. 一种应用程序跨系统运行的方法,所述方法包括:
    加载目标应用程序;
    为所述目标应用程序在当前操作系统上申请内存空间;
    根据申请到的内存空间地址对所述目标应用程序中的全局变量地址和绝对跳转指令地址进行修改,以适配到当前操作系统的内存空间;
    获取所述目标应用程序的SWI指令;
    将所述SWI指令重定向为调用当前操作系统的指令。
  2. 根据权利要求1所述的方法,其特征在于,在所述加载目标应用程序的步骤之后还包括:采用二进制翻译的方式对所述目标应用程序中的指令进行翻译。
  3. 根据权利要求1所述的方法,其特征在于,所述根据申请到的所述内存空间地址对所述目标应用程序中的全局变量地址和跳转指令地址进行修改,以适配到当前操作系统的内存空间的步骤之前还包括:
    获取所述目标应用程序的二进制数据;
    通过对所述二进制数据进行分析找出所述目标应用程序中的全局变量和绝对跳转指令。
  4. 根据权利要求3所述的方法,其特征在于,所述通过对所述二进制数据进行分析找出所述目标应用程序中的全局变量和绝对跳转指令的步骤包括:
    通过对所述目标应用程序的二进制数据进行分析,定位出所述目标应用程序中全局变量和绝对跳转指令对应的绝对地址;
    根据定位出的所述绝对地址提取所述目标应用程序中的全局变量和绝对跳转指令。
  5. 根据权利要求1所述的方法,其特征在于,在所述将所述SWI指令重定向为调用当前操作系统的指令的步骤之后还包括:
    接收所述目标应用程序发起的调用API函数的请求;
    响应所述请求根据重定向的SWI指令调用当前操作系统中对应的API函数。
  6. 一种应用程序跨系统运行的装置,其特征在于,所述装置包括:
    加载模块,用于加载目标应用程序;
    申请模块,用于为所述目标应用程序在当前操作系统上申请内存空间;
    修改模块,用于根据申请到的内存空间地址对所述目标应用程序中的全局变量地址和绝对跳转指令地址进行修改,以适配到当前操作系统的内存空间;
    指令获取模块,用于获取所述目标应用程序的SWI指令;
    重定向模块,用于将所述SWI指令重定向为调用当前操作系统的指令。
  7. 根据权利要求6所述的装置,其特征在于,所述装置还包括:
    翻译模块,用于采用二进制翻译的方式对所述目标应用程序中的指令进行翻译。
  8. 根据权利要求6所述的装置,其特征在于,所述装置还包括:
    数据获取模块,用于获取所述目标应用程序的二进制数据;
    分析模块,用于通过对所述二进制数据进行分析找出所述目标应用程序中的全局变量和绝对跳转指令。
  9. 根据权利要求8所述的装置,其特征在于,所述分析模块包括:
    定位模块,用于通过对所述目标应用程序的二进制数据进行分析,定位出所述目标应用程序中全局变量和绝对跳转指令对应的绝对地址;
    提取模块,用于根据定位出的所述绝对地址提取所述目标应用程序中的全局变量和绝对跳转指令。
  10. 根据权利要求6所述的装置,其特征在于,所述装置还包括:
    接收模块,用于接收所述目标应用程序发起的调用API函数的请求;
    调用模块,用于响应所述请求根据重定向的SWI指令调用当前操作系统中对应的API函数。
PCT/CN2016/106221 2016-08-23 2016-11-17 应用程序跨系统运行的方法和装置 WO2018036000A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US15/552,034 US10303491B2 (en) 2016-08-23 2016-11-17 Method and device of running application program across systems

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610710638.3A CN106371826B (zh) 2016-08-23 2016-08-23 应用程序跨系统运行的方法和装置
CN201610710638.3 2016-08-23

Publications (1)

Publication Number Publication Date
WO2018036000A1 true WO2018036000A1 (zh) 2018-03-01

Family

ID=57878909

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/106221 WO2018036000A1 (zh) 2016-08-23 2016-11-17 应用程序跨系统运行的方法和装置

Country Status (3)

Country Link
US (1) US10303491B2 (zh)
CN (1) CN106371826B (zh)
WO (1) WO2018036000A1 (zh)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106484428B (zh) * 2016-10-20 2019-10-15 百度在线网络技术(北京)有限公司 应用构建方法和装置
CN109144575B (zh) * 2017-06-16 2021-07-16 北京海誉动想科技股份有限公司 跨操作系统运行应用的装置、方法、电子设备和存储器
US11243803B2 (en) * 2019-04-30 2022-02-08 Automation Anywhere, Inc. Platform agnostic robotic process automation
US11113095B2 (en) 2019-04-30 2021-09-07 Automation Anywhere, Inc. Robotic process automation system with separate platform, bot and command class loaders
CN111142939B (zh) 2019-12-11 2023-04-07 北京小米移动软件有限公司 应用程序处理方法及装置
US11481304B1 (en) 2019-12-22 2022-10-25 Automation Anywhere, Inc. User action generated process discovery
CN111209056B (zh) * 2020-01-02 2021-02-19 北京东土科技股份有限公司 功能函数的加载方法、装置、可读存储介质及电子设备
US11182178B1 (en) 2020-02-21 2021-11-23 Automation Anywhere, Inc. Detection of user interface controls via invariance guided sub-control learning
CN112040025B (zh) * 2020-09-03 2023-03-24 安徽文香科技有限公司 一种服务器地址切换的方法、系统及终端设备
CN112468611B (zh) * 2020-11-27 2023-04-21 深圳市欢太科技有限公司 应用程序启动方法、终端设备及计算机存储介质
CN112559920B (zh) * 2020-12-23 2022-11-04 苏州三六零智能安全科技有限公司 基于跳转指令的hook方法、装置、设备及存储介质
US11968182B2 (en) 2021-07-29 2024-04-23 Automation Anywhere, Inc. Authentication of software robots with gateway proxy for access to cloud-based services

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1371053A (zh) * 2001-02-22 2002-09-25 英业达集团(南京)电子技术有限公司 在电子通信装置的编译系统平台上下载应用程序的方法
US20050097399A1 (en) * 2003-11-03 2005-05-05 Microsoft Corporation Techniques for managed code debugging
US20060080648A1 (en) * 2004-10-12 2006-04-13 Majid Anwar Concurrent code loading mechanism
WO2010004242A2 (en) * 2008-07-10 2010-01-14 Cambridge Consultants Limited Data processing apparatus, for example using vector pointers
CN103631971A (zh) * 2013-12-20 2014-03-12 北京奇虎科技有限公司 一种可移植的执行体文件的重组方法和装置
CN105786525A (zh) * 2016-03-23 2016-07-20 鼎点视讯科技有限公司 一种进程模型向线程模型移植代码的方法及装置

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011160139A1 (en) * 2010-06-18 2011-12-22 Sweetlabs, Inc. Systems and methods for integration of an application runtime environment into a user computing environment
CN102541491A (zh) * 2010-12-14 2012-07-04 北京新媒传信科技有限公司 移动终端界面切换方法及系统
CN102541567A (zh) * 2012-01-05 2012-07-04 深圳市天拓立方通讯科技有限公司 一种2d手机游戏引擎及兼容手机操作系统的方法
CN103116544A (zh) * 2013-01-25 2013-05-22 浪潮电子信息产业股份有限公司 一种自动化的跨平台多服务器多应用测试方法
CN103327117B (zh) * 2013-07-05 2017-02-08 百度在线网络技术(北京)有限公司 应用程序的跨系统运行方法和装置
CN104821954B (zh) * 2015-03-27 2018-12-07 中国海洋大学 一种跨平台远程过程调用方法

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1371053A (zh) * 2001-02-22 2002-09-25 英业达集团(南京)电子技术有限公司 在电子通信装置的编译系统平台上下载应用程序的方法
US20050097399A1 (en) * 2003-11-03 2005-05-05 Microsoft Corporation Techniques for managed code debugging
US20060080648A1 (en) * 2004-10-12 2006-04-13 Majid Anwar Concurrent code loading mechanism
WO2010004242A2 (en) * 2008-07-10 2010-01-14 Cambridge Consultants Limited Data processing apparatus, for example using vector pointers
CN103631971A (zh) * 2013-12-20 2014-03-12 北京奇虎科技有限公司 一种可移植的执行体文件的重组方法和装置
CN105786525A (zh) * 2016-03-23 2016-07-20 鼎点视讯科技有限公司 一种进程模型向线程模型移植代码的方法及装置

Also Published As

Publication number Publication date
CN106371826B (zh) 2019-11-29
CN106371826A (zh) 2017-02-01
US20180321955A1 (en) 2018-11-08
US10303491B2 (en) 2019-05-28

Similar Documents

Publication Publication Date Title
WO2018036000A1 (zh) 应用程序跨系统运行的方法和装置
EP3968160A1 (en) Inter-process communication method and apparatus, and computer device
US20180074843A1 (en) System, method, and computer program product for linking devices for coordinated operation
JPH07287659A (ja) コンピュータシステムにおいてクロスドメイン通話を検出及び実行するための方法及び装置
US11726799B2 (en) Preventing framework conflicts for multi-OS applications
JP2011258185A (ja) デバッグ・プログラム、デバッグ・システム、および方法
WO2018018797A1 (zh) 功能模块跨平台运行的实现方法和装置
US9811319B2 (en) Software interface for a hardware device
WO2014069827A1 (en) System and method for providing data analysis service in a cloud environment
US11734048B2 (en) Efficient user space driver isolation by shallow virtual machines
CN103984591A (zh) 计算机虚拟化系统的PCI设备INTx中断投递方法
US20210294686A1 (en) Fast memory mapped io support by register switch
WO2023123850A1 (zh) 一种固件可信根的实现方法、装置、设备和可读存储介质
US20070283350A1 (en) System and method for adapting command line interface messaging in a virtual operating system environment
US9898307B2 (en) Starting application processors of a virtual machine
CN113703924A (zh) 基于可信执行环境的安全虚拟机系统设计方法及系统
US20200073826A1 (en) Efficient userspace driver isolation by cpu page table switching
EP2941694B1 (en) Capability based device driver framework
US5822620A (en) System for data alignment by using mask and alignment data just before use of request byte by functional unit
Barnes et al. RMoX: a Raw Metal occam Experiment
US7428729B2 (en) Methods, systems, and computer program products for integrating legacy applications into a platform-independent environment
Milojicic et al. Outlook on operating systems
CN116257320A (zh) 一种基于dpu虚拟化配置管理方法、装置、设备及介质
Armand et al. Shared device driver model for virtualized mobile handsets
CN115604331A (zh) 一种数据的处理系统、方法以及装置

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 15552034

Country of ref document: US

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16914020

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16914020

Country of ref document: EP

Kind code of ref document: A1