WO2021056823A1 - 系统调用方法、装置和电子设备 - Google Patents

系统调用方法、装置和电子设备 Download PDF

Info

Publication number
WO2021056823A1
WO2021056823A1 PCT/CN2019/123327 CN2019123327W WO2021056823A1 WO 2021056823 A1 WO2021056823 A1 WO 2021056823A1 CN 2019123327 W CN2019123327 W CN 2019123327W WO 2021056823 A1 WO2021056823 A1 WO 2021056823A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
simulator
call
system call
target
Prior art date
Application number
PCT/CN2019/123327
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 US16/975,405 priority Critical patent/US20230103210A1/en
Publication of WO2021056823A1 publication Critical patent/WO2021056823A1/zh

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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4812Task transfer initiation or dispatching by interrupt, e.g. masked
    • 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
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/53Decompilation; Disassembly
    • 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/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Definitions

  • the present disclosure relates to the field of computer technology, and in particular to a system call method, device and electronic equipment.
  • Android X86 can be implemented to run the Android system on the Windows x86 system, that is, based on the Android X86, the Android emulator can be run on the Windows operating system.
  • system calls need to be implemented through related instructions.
  • the system call between Android X86 and Windows x86 is implemented through the int80 instruction; in the process of implementing the system call through the int80 instruction, the Windows kernel is required. This way of using the Windows kernel easily leads to poor performance of exception handling when the int80 instruction is used to implement the system call, which in turn makes the performance of the above system call implemented through the int80 instruction poor.
  • At least some of the embodiments of the present disclosure provide a system call method, device, and electronic device, which can improve the system call performance of the simulator, thereby improving user experience.
  • One of the embodiments of the present disclosure provides a system calling method, which is applied to a device configured with a simulator, and the simulator is used to call the operating system of the device.
  • the method includes: running the simulator on the operating system , Load the simulator’s library file and the system call table of the simulator obtained by scanning in advance; wherein, the system call table includes: the system file of the simulation system call in the simulator and the location information of the system file; from the system call table , Find the target system file associated with the library file; in the system call table, modify the location information of the target system file to the execution function corresponding to the simulator, so as to call the target system file through the execution function.
  • the above-mentioned system call table is obtained in the following manner: by means of binary search and disassembly, scanning the system file containing the preset soft interrupt instruction in the simulation system, and the system file Location information; where the preset soft interrupt instruction is an instruction to call the operating system; the location information is an offset location; the scanned system file and the location information of the system file are written into the system call table.
  • the foregoing step of scanning the system file containing the preset soft interrupt instruction in the simulation system by means of binary search and disassembly includes: generating a script file containing the objdump command; The script file performs binary static search and disassembly processing on the simulation system, and obtains the system file containing the preset soft interrupt instruction in the simulation system.
  • the system file in the system call table is a system file containing int80 instructions; if the simulation system is Android x64, the system file in the system call table The system file is a system file that contains the syscall instruction.
  • the step of searching the target system file associated with the library file from the system call table includes: searching the file name of the library file from the system call table; , The system file in the library corresponding to the file name is determined as the target system file associated with the library file.
  • the above step of modifying the location information of the target system file to the execution function corresponding to the simulator includes: in the system memory of the operating system, the location information corresponding to the target system file , Modified to the corresponding execution function of the simulation system in the way of patch.
  • the method further includes: in the process of running the simulator, if necessary Execute the system file associated with the library file of the simulator, and jump to the system file through the modified execution function to execute the system file.
  • the method further includes: receiving the system file through the execution function The results of the implementation.
  • FIG. 1 Another embodiment of the present disclosure also provides a system calling device, which is applied to a device configured with an emulator, the simulator is used to call the operating system of the device, and the device includes: library files and system call table loading The module is set to load the library file of the simulator and the pre-scanned system call table of the simulator when the simulator is run on the operating system; wherein, the system call table includes: the simulation system in the simulator The called system file and the location information of the system file; the target system file search module is set to find the target system file associated with the library file from the system call table; the location information modification module is set to be in the system In the calling table, the location information of the target system file is modified to the execution function corresponding to the simulator, so as to call the target system file through the execution function.
  • the system call table includes: the simulation system in the simulator The called system file and the location information of the system file;
  • the target system file search module is set to find the target system file associated with the library file from the system call table;
  • the location information modification module is set to
  • Another embodiment of the present disclosure also provides an electronic device, including a processor and a memory, the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the aforementioned system call method.
  • Another embodiment of the present disclosure also provides a computer-readable storage medium that stores computer-executable instructions.
  • the computer-executable instructions When the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause processing
  • the device implements the above system call method.
  • the system call method, device and electronic device provided by the embodiments of the present disclosure load the library file of the simulator and the system call table of the simulator obtained by scanning in advance when the simulator is running on the operating system; wherein, the system call table It includes: the system file that simulates the system call in the simulator and the location information of the system file; from the system call table, find the target system file associated with the library file; in the system call table, the target system file The location information is modified to the execution function corresponding to the simulator, so that the target system file can be called through the execution function.
  • This method modifies the system call table of the simulator, and when simulating the system call system file, it jumps to the system file that needs to be called by executing the function, truncating the generation of int 80 instructions and other soft interrupt instructions, making the system call execution speed Significantly improved, thereby improving the system call performance of the simulator, thereby enhancing the user experience.
  • FIG. 1 is a schematic flowchart of a system call method provided by an embodiment of the disclosure
  • FIG. 2 is a schematic flowchart of another system call method provided by an embodiment of the disclosure.
  • FIG. 3 is a schematic flowchart of another system call method provided by an embodiment of the disclosure.
  • FIG. 4 is a schematic structural diagram of a system call device provided by an embodiment of the disclosure.
  • FIG. 5 is a schematic structural diagram of an electronic device provided by an embodiment of the disclosure.
  • FIG. 6 is a schematic structural diagram of one of the computer-readable storage media in the embodiments of the disclosure.
  • Icon 41-library file and system call table loading module; 42-target system file search module; 43-location information modification module; 50-memory; 51-processor; 52-bus; 53-communication interface.
  • embodiments of the present disclosure provide a system call method, device, and electronic device.
  • the technology can be applied to computers, mobile phones, and tablet computers.
  • Game devices and other devices that can be configured with emulators.
  • FIG. 1 it is a schematic flowchart of a system call method provided by an embodiment of the present disclosure, where the method is applied to a device configured with a simulator, and the simulator is used to call the operating system of the device, As can be seen from Figure 1, the method includes the following steps:
  • Step S102 When the simulator is running on the operating system, load the simulator's library file and the system call table of the simulator obtained by scanning in advance; wherein, the system call table includes: system files for simulating system calls in the simulator, and The location information of the system file.
  • the simulator refers to a software program compiled on a computer platform based on a computer that can simulate and execute a specific hardware platform and its program. For example, when we run a PS3 emulator, this emulator simulates the PS3 environment on the computer, so that the original PS3 exclusive software can run on the computer.
  • the simulator has a corresponding simulation system.
  • the simulator is an Android simulator, it corresponds to an Android simulation system. Therefore, it can run on the computer and simulate the Android mobile phone system, and can install, use, and uninstall Android applications.
  • the software allows users to experience Android games and applications on the computer.
  • the device configuring the simulator can be a computer, a mobile phone, a tablet computer, a game device, and so on.
  • the simulator needs to call the operating system of the device to realize the operation of the above-mentioned application software.
  • the operating system is a computer program that manages computer hardware and software resources, and is also the core and cornerstone of a computer system. Among them, the operating system usually needs to deal with basic tasks such as managing and configuring memory, determining the priority of system resource supply and demand, controlling input devices and output devices, operating networks, and managing file systems.
  • the library file of the simulator When the simulator is running on the operating system, the library file of the simulator is loaded, and the system call table of the simulator obtained by scanning in advance is loaded.
  • the library file is a DLL (Dynamic Linkable Library) file.
  • the system call table includes system files that simulate system calls in the simulator, and location information of the system files.
  • the system call table is an array pointer table, and the index of the array is the address implemented by the system call.
  • the system file refers to the folder where the main files of the operating system are stored. Generally, it is automatically created during the installation of the operating system and the related files are placed in the corresponding folder. The files inside directly affect the normal operation of the system, and most of them are Random changes are not allowed.
  • the system file in the system call table is the system file that the simulator actually needs to call when it is running. Generally, the system call is made through special instructions such as int 80, syscall, or sysenter.
  • the above-mentioned location information refers to the specific location where the system call occurs. In this way, when the simulator is running, the operating system can find the system file that needs to be called according to the system call table, and then implement the system call.
  • Step S104 Find the target system file associated with the library file from the system call table.
  • each system file corresponds to its location information, so that after finding the target system file, the location information corresponding to the target system file can be obtained.
  • Step S106 In the system call table, modify the location information of the target system file into an execution function corresponding to the simulator, so as to call the target system file through the execution function.
  • the corresponding location information can be obtained according to the system call table.
  • the location information of the target system file is modified to the execution function corresponding to the simulator, so that when the simulation system is running, if a system call is encountered, the target system file is called through the execution function.
  • the system call table includes: simulation in the simulator The system file called by the system and the location information of the system file; from the system call table, find the target system file associated with the library file; in the system call table, modify the location information of the target system file to the simulator
  • the corresponding execution function is used to call the target system file through the execution function.
  • This method modifies the system call table of the simulator, and when simulating the system call system file, it jumps to the system file that needs to be called by executing the function, truncating the generation of int 80 instructions and other soft interrupt instructions, making the system call execution speed Significantly improve, and effectively improve the simulator's system call performance.
  • this embodiment provides another system call method, which is applied to a device equipped with a simulator, and the simulator is used to call the operating system of the device, where:
  • This method focuses on the specific implementation process of obtaining the above-mentioned system call table.
  • Figure 2 shows a schematic flow diagram of the method. The method includes the following steps:
  • Step S202 Scan the system file containing the preset soft interrupt instruction in the simulation system and the location information of the system file by means of binary search and disassembly; wherein, the preset soft interrupt instruction is an instruction to call the operating system; The position information is the offset position.
  • the method of binary search is to perform content matching without format. For example, if you search for a string of binary "010111110010101" in a piece of data, you can directly perform a matching search at the binary level.
  • disassembly is the process of converting target code into assembly code. Disassembly can be realized by disassembly software, such as OD, IDA Pro, radare2, DEBUG, C32, etc.
  • the soft interrupt instruction is that after the program sets the interrupt flag, the hardware then executes the related operations of the interrupt.
  • the soft interrupt instruction is an instruction to call the operating system.
  • the soft interrupt instruction can be an int80 instruction, a syscall Instructions and sysenter instructions, etc.
  • a script file containing the objdump command is first generated.
  • the objdump command is a tool for viewing the composition of the target file or executable target file; then the script file is used to perform the simulation system Binary static search and disassembly processing are performed to obtain a system file containing preset soft interrupt instructions in the simulation system.
  • the system file containing the preset soft interrupt instruction can be obtained, and the location information corresponding to the system file can be obtained at the same time.
  • the location information is biased. Move position.
  • Step S204 Write the scanned system file and the location information of the system file into the system call table.
  • the system file written in the system call table is a system file containing int80 instructions; if the simulation system is Android x64, write the system call
  • the system files in the table are system files that contain syscall instructions.
  • the position information corresponding to the system file that is, its offset position, is also written into the system call table.
  • Step S206 When the simulator is running on the operating system, the library file of the simulator and the above system call table are loaded.
  • the above operating system it can be Windows 32 or Windows 64 system.
  • the library file of the simulator is loaded, and the above system call table is loaded.
  • Step S208 Find the target system file associated with the library file from the system call table.
  • Step S210 In the system call table, modify the location information of the target system file into an execution function corresponding to the simulator, so as to call the target system file through the execution function.
  • the execution function includes trampline assembly code, where the trampline assembly code refers to a small piece of assembly code added to achieve the target logic.
  • the system call method provided in this embodiment provides an implementation scheme for obtaining the system call table. Through binary search and disassembly, the system file containing the system call instruction in the simulation system and the corresponding location information are obtained, and then the simulation is obtained. The system call table of the processor. The system call method cuts off the generation of int 80 instructions and other soft interrupt instructions when calling system files, and jumps to the system files that need to be called by executing functions, which improves the execution speed of system calls and improves the simulator’s performance. System call performance.
  • This embodiment provides another system call method, which is implemented on the basis of the system call method shown in Figure 1.
  • This method focuses on the above-mentioned modification of the location information of the target system file to the execution function corresponding to the simulator.
  • the specific implementation process is shown in Figure 3, which is a schematic flow diagram of the method. As can be seen from Figure 3, the method includes the following steps:
  • Step S302 When the simulator is running on the operating system, load the simulator's library file and the pre-scanned system call table of the simulator; wherein, the system call table includes: system files that simulate system calls in the simulator, and The location information of the system file.
  • Step S304 Find the target system file associated with the library file from the system call table.
  • the file name of the library file can be found from the system call table; then the system file in the library corresponding to the file name in the system call table is determined as the target associated with the library file System Files.
  • Step S306 In the system memory of the operating system, modify the location information corresponding to the target system file to the execution function corresponding to the simulation system in a patch manner.
  • system call can be modified into a function call by means of patch.
  • Step S308 In the process of running the simulator, if the system file associated with the library file of the simulator needs to be executed, jump to the system file through the modified execution function to execute the system file.
  • the above execution function jumps to the corresponding system file and executes the system file.
  • the execution function is also used to receive the execution result of the system file. For example, if the system file is executed successfully, the execution function returns "execution succeeded", otherwise it returns "Execution failed”.
  • the system call method provided by the embodiment of the present disclosure intercepts the generation of int80 instructions and other soft interrupt instructions by means of patch, which alleviates the technical problem of poor performance of exception handling when the system call is implemented through int80 instructions, and improves The execution speed of the system call and the performance of the system call.
  • this embodiment introduces an application example, which is a system call implementation method of the new engine of the NetEase MuMu emulator Nebula.
  • the specific process of this method is as follows:
  • the Aow engine solution implements the int 80 simulation call service in the kernel module.
  • the solution still has the following shortcomings:
  • Nebula's new engine intercepts the generation of int 80 instructions and other soft interrupt instructions (such as syscall) by means of patch, and jumps to the system file that needs to be called by executing the function.
  • This patch method can Applicable to x86 and x64 system calls, alleviating the industry's problems that x64 system calls cannot directly handle.
  • the embodiment of the present disclosure also provides a system calling device, wherein the device is applied to a device configured with a simulator, and the simulator is used to call the operating system of the device.
  • FIG. 4 it is a schematic diagram of the structure of the device.
  • the device includes a library file and system call table loading module 41, a target system file search module 42, and a location information modification module 43, which are sequentially connected.
  • the functions of the module are as follows:
  • the library file and system call table loading module 41 is set to load the library file of the simulator and the system call table of the simulator obtained by scanning in advance when the simulator is running on the operating system; wherein, the system call table is Including: the system file that simulates the system call in the simulator and the location information of the system file;
  • the target system file search module 42 is set to search the target system file associated with the library file from the system call table;
  • the location information modification module 43 is configured to modify the location information of the target system file in the system call table to the execution function corresponding to the simulator, so as to call the target system file through the execution function.
  • the system call device described above loads the library file of the simulator and the system call table of the simulator obtained by scanning beforehand when the simulator is running on the operating system; wherein, the system call table includes: the system file of the simulation system call in the simulator , And the location information of the system file; from the system call table, find the target system file associated with the library file; in the system call table, modify the location information of the target system file to the execution function corresponding to the simulator, To call the target system file through the execution function.
  • the device By modifying the system call table of the simulator, the device jumps to the system file that needs to be called by executing the function when simulating the system call system file, truncating the generation of int 80 instructions and other soft interrupt instructions, making the execution speed of the system call Significantly improved, thereby improving the system call performance of the simulator, thereby enhancing the user experience.
  • the above-mentioned library file and system call table loading module 41 is further configured to scan the system file containing the preset soft interrupt instruction in the simulation system through binary search and disassembly, and the The position information of the system file; where the preset soft interrupt instruction is an instruction to call the operating system; the position information is an offset position; the scanned system file and the position information of the system file are written into the system call table.
  • the aforementioned library file and system call table loading module 41 is further configured to: generate a script file containing the objdump command; use the script file to perform binary static search and disassembly processing on the simulation system, Obtain the system file containing the preset soft interrupt instruction in the simulation system.
  • the system file in the system call table is a system file containing int80 instructions; if the simulation system is Android x64, the system in the system call table The file is a system file containing syscall instructions.
  • the target system file search module 42 is further configured to: search the file name of the library file from the system call table; add the system file in the library corresponding to the file name in the system call table, Determine the target system file associated with the library file.
  • the above-mentioned location information modification module 43 is further configured to: in the system memory of the operating system, modify the location information corresponding to the target system file to the execution corresponding to the simulation system in a patch manner. function.
  • the above-mentioned system calling device further includes a jump module, which is set to execute the system file associated with the library file of the simulator if it is necessary to execute the system file associated with the library file of the simulator during the process of running the simulator.
  • the execution function of the jump to the system file to execute the system file is set to execute the system file associated with the library file of the simulator if it is necessary to execute the system file associated with the library file of the simulator during the process of running the simulator.
  • the aforementioned system calling device further includes an execution result receiving module, which is configured to receive the execution result of the system file through the execution function.
  • the above-mentioned execution function includes trampline assembly code.
  • the foregoing operating system includes a Windows 32 or Windows 64 system.
  • the embodiment of the present disclosure also provides an electronic device. As shown in FIG. 5, it is a schematic structural diagram of the electronic device.
  • the electronic device includes a processor 51 and a memory 50, and the memory 50 stores data that can be used by the processor 51.
  • the computer-executable instructions are executed, and the processor 51 executes the computer-executable instructions to implement the above-mentioned system call method.
  • the electronic device further includes a bus 52 and a communication interface 53, wherein the processor 51, the communication interface 53 and the memory 50 are connected through the bus 52.
  • the memory 50 may include a high-speed random access memory (RAM, Random Access Memory), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
  • the communication connection between the system network element and at least one other network element is realized through at least one communication interface 53 (which may be wired or wireless), and the Internet, a wide area network, a local network, a metropolitan area network, etc. may be used.
  • the bus 52 may be an ISA bus, a PCI bus, an EISA bus, or the like.
  • the bus 52 can be divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, only one bidirectional arrow is used to indicate in FIG. 5, but it does not mean that there is only one bus or one type of bus.
  • the processor 51 may be an integrated circuit chip with signal processing capability. In the implementation process, the steps of the foregoing method may be completed by an integrated logic circuit of hardware in the processor 51 or instructions in the form of software.
  • the foregoing processor 51 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP), etc.; it may also be a digital signal processor (Digital Signal Processor, DSP for short). ), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the steps of the method disclosed in combination with the embodiments of the present disclosure may be directly embodied as being executed and completed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers.
  • the storage medium is located in the memory, and the processor 51 reads the information in the memory, and completes the steps of the system calling method of the foregoing embodiment in combination with its hardware.
  • FIG. 6 is a schematic structural diagram of one of the computer-readable storage media according to the embodiments of the disclosure.
  • a program product 1100 according to an embodiment of the present application is described, and a computer program is stored thereon.
  • the computer program includes computer-executable instructions.
  • the computer-executable instructions When the computer-executable instructions are called and executed by a processor, The computer-executable instructions cause the processor to implement the above-mentioned system calling method.
  • the foregoing method embodiment please refer to the foregoing method embodiment, which will not be repeated here.
  • the computer program product of the system calling method, the system calling device, and the electronic device provided by the embodiments of the present disclosure includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the above method embodiments.
  • the system call method described above please refer to the method embodiment, which will not be repeated here.
  • the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer readable storage medium executable by a processor.
  • the technical solution of the present disclosure essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present disclosure.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disks or optical disks and other media that can store program codes. .
  • the system call table includes: the system file of the simulation system call in the simulator, and the system The location information of the file; from the system call table, find the target system file associated with the library file; in the system call table, modify the location information of the target system file to the execution function corresponding to the simulator, so as to pass the execution
  • the function call target system file achieves the purpose of truncating the generation of int 80 instructions and other soft interrupt instructions, thereby achieving the technical effect of improving the execution speed of system calls and improving the performance of system calls of the simulator.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

一种系统调用方法、装置和电子设备,其中,该方法包括:在操作系统上运行模拟器时,加载模拟器的库文件以及预先扫描得到的模拟器的系统调用表;其中,该系统调用表中包括:模拟器中模拟系统调用的系统文件、以及该系统文件的位置信息(S102);从系统调用表中,查找与库文件相关联的目标系统文件(S104);在系统调用表中,将该目标系统文件的位置信息,修改为模拟器对应的执行函数,以通过该执行函数调用目标系统文件(S106)。该方法通过修改模拟器的系统调用表,在模拟系统调用系统文件时,以执行函数跳转到需要调用的系统文件,截断了int 80指令以及其他软中断指令的产生,提高了系统调用的执行速度,并提高了模拟器的系统调用性能。

Description

系统调用方法、装置和电子设备
交叉援引
本公开要求于2019年09月24日提交中国专利局、申请号为201910908623.1、申请名称“系统调用方法、装置和电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本公开中。
技术领域
本公开涉及计算机技术领域,尤其是涉及一种系统调用方法、装置和电子设备。
背景技术
Android X86可以实现在Windows x86系统上运行Android系统,即,基于该Android X86,可以在Windows操作系统上运行Android模拟器。该模拟器在运行过程中,需要通过相关指令实现系统调用。相关技术中,Android X86与Windows x86之间的系统调用,通过int80指令实现;在通过int80指令实现系统调用的过程中,需要使用Windows内核。这种使用Windows内核的方式,易导致通过int80指令实现系统调用时,异常处理的性能较差,进而使得通过int80指令实现上述系统调用的性能较差。
发明内容
本公开至少部分实施例提供了一种系统调用方法、装置和电子设备,可以提高模拟器的系统调用性能,进而提升用户体验。
本公开其中一实施例提供了一种系统调用方法,该方法应用于配置有 模拟器的设备,该模拟器用于对该设备的操作系统进行调用,该方法包括:在操作系统上运行模拟器时,加载模拟器的库文件以及预先扫描得到的模拟器的系统调用表;其中,该系统调用表中包括:模拟器中模拟系统调用的系统文件、以及该系统文件的位置信息;从系统调用表中,查找与库文件相关联的目标系统文件;在系统调用表中,将该目标系统文件的位置信息,修改为模拟器对应的执行函数,以通过该执行函数调用目标系统文件。
在本公开的一个可选实施例中,上述系统调用表通过下述方式得到:通过二进制搜索和反汇编的方式,扫描模拟系统中包含有预设软中断指令的系统文件,以及该系统文件的位置信息;其中,该预设软中断指令为调用操作系统的指令;该位置信息为偏移位置;将扫描得到的系统文件,以及该系统文件的位置信息写入系统调用表。
在本公开的一个可选实施例中,上述通过二进制搜索和反汇编的方式,扫描模拟系统中包含有预设软中断指令的系统文件的步骤,包括:生成包含有objdump命令的脚本文件;通过该脚本文件,对模拟系统进行二进制静态搜索和反汇编处理,得到该模拟系统中包含有预设软中断指令的系统文件。
在本公开的一个可选实施例中,如果该模拟系统为Android x86,该系统调用表中的系统文件为包含有int80指令的系统文件;如果该模拟系统为Android x64,该系统调用表中的系统文件为包含有syscall指令的系统文件。
在本公开的一个可选实施例中,上述从系统调用表中,查找与库文件相关联的目标系统文件的步骤,包括:从系统调用表中查找库文件的文件名;将系统调用表中,该文件名对应的库中的系统文件,确定为与库文件相关联的目标系统文件。
在本公开的一个可选实施例中,上述将目标系统文件的位置信息,修改为模拟器对应的执行函数的步骤,包括:在该操作系统的系统内存中,将目标系统文件对应的位置信息,以patch的方式修改为该模拟系统对应的 执行函数。
在本公开的一个可选实施例中,上述将该目标系统文件的位置信息,修改为该模拟器对应的执行函数的步骤之后,该方法还包括:在运行该模拟器的过程中,如果需要执行与该模拟器的库文件相关联的系统文件,通过修改后的该执行函数,跳转至该系统文件,以执行该系统文件。
在本公开的一个可选实施例中,上述通过修改后的该执行函数,跳转至该系统文件,以执行该系统文件的步骤之后,该方法还包括:通过该执行函数,接收该系统文件的执行结果。
本公开另一实施例还提供了一种系统调用装置,该装置应用于配置有模拟器的设备,该模拟器用于对该设备的操作系统进行调用,该装置包括:库文件及系统调用表加载模块,设置为在该操作系统上运行该模拟器时,加载该模拟器的库文件以及预先扫描得到的该模拟器的系统调用表;其中,该系统调用表中包括:该模拟器中模拟系统调用的系统文件、以及该系统文件的位置信息;目标系统文件查找模块,设置为从该系统调用表中,查找与该库文件相关联的目标系统文件;位置信息修改模块,设置为在该系统调用表中,将该目标系统文件的位置信息,修改为该模拟器对应的执行函数,以通过该执行函数调用该目标系统文件。
本公开另一实施例还提供了一种电子设备,包括处理器和存储器,该存储器存储有能够被该处理器执行的计算机可执行指令,该处理器执行该计算机可执行指令以实现上述系统调用方法。
本公开另一实施例还提供了一种计算机可读存储介质,该计算机可读存储介质存储有计算机可执行指令,该计算机可执行指令在被处理器调用和执行时,计算机可执行指令促使处理器实现上述系统调用方法。
本公开至少部分实施例带来了以下有益效果:
本公开实施例提供的一种系统调用方法、装置和电子设备,在操作系统上运行模拟器时,加载模拟器的库文件以及预先扫描得到的模拟器的系 统调用表;其中,该系统调用表中包括:模拟器中模拟系统调用的系统文件、以及该系统文件的位置信息;从系统调用表中,查找与库文件相关联的目标系统文件;在系统调用表中,将该目标系统文件的位置信息,修改为模拟器对应的执行函数,以通过该执行函数调用目标系统文件。该方法通过修改模拟器的系统调用表,在模拟系统调用系统文件时,以执行函数跳转到需要调用的系统文件,截断了int 80指令以及其他软中断指令的产生,使得系统调用的执行速度大幅度提高,从而提高了模拟器的系统调用性能,进而提升用户体验。
本公开的其他特征和优点将在随后的说明书中阐述,或者,部分特征和优点可以从说明书推知或毫无疑义地确定,或者通过实施本公开的上述技术即可得知。
为使本公开的上述目的、特征和优点能更明显易懂,下文特举可选实施例,并配合所附附图,作详细说明如下。
附图说明
为了更清楚地说明本公开具体实施方式或现有技术中的技术方案,下面将对具体实施方式或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本公开的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本公开实施例提供的一种系统调用方法的流程示意图;
图2为本公开实施例提供的另一种系统调用方法的流程示意图;
图3为本公开实施例提供的另一种系统调用方法的流程示意图;
图4为本公开实施例提供的一种系统调用装置的结构示意图;
图5为本公开实施例提供的一种电子设备的结构示意图;
图6为本公开实施例的其中一种计算机可读存储介质的结构示意图。
图标:41-库文件及系统调用表加载模块;42-目标系统文件查找模块;43-位置信息修改模块;50-存储器;51-处理器;52-总线;53-通信接口。
具体实施方式
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合附图对本公开的技术方案进行清楚、完整地描述,显然,所描述的实施例是本公开一部分实施例,而不是全部的实施例。基于本公开中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本公开保护的范围。
考虑到现有模拟器的异常处理性能较差,导致系统调用性能较差的问题,本公开实施例提供了一种系统调用方法、装置和电子设备,该技术可以应用于计算机、手机、平板电脑、游戏设备等可以配置模拟器的设备上。
为便于对本实施例进行理解,首先对本公开实施例所公开的一种系统调用方法进行详细介绍。
如图1所示,其为本公开实施例提供的一种系统调用方法的流程示意图,其中,该方法应用于配置有模拟器的设备,并且该模拟器用于对该设备的操作系统进行调用,由图1可见,该方法包括以下步骤:
步骤S102:在操作系统上运行模拟器时,加载模拟器的库文件以及预先扫描得到的模拟器的系统调用表;其中,该系统调用表中包括:模拟器中模拟系统调用的系统文件、以及该系统文件的位置信息。
这里,模拟器是指在计算机平台上,基于计算机编译的,可模拟执行特定之硬件平台及其程序的软件程序。例如,当我们运行某个PS3模拟器时,这个模拟器便是在电脑上模拟出了PS3的环境,使得原本PS3独占的软件能够在电脑上运行。
模拟器有相应的模拟系统,例如,若模拟器是安卓模拟器,则其对应 有安卓模拟系统,因而,它可以在计算机上运行并模拟安卓手机系统,并能安装、使用、卸载安卓应用的软件,让用户在电脑上也能体验安卓游戏和应用。这里,配置模拟器的设备可以是计算机、手机、平板电脑和游戏设备等等。
在实际操作中,当用户需要在配置有模拟器的设备上,使用与该模拟器对应的应用软件时,该模拟器需要调用该设备的操作系统,以实现上述应用软件的运行。这里,操作系统是管理计算机硬件与软件资源的计算机程序,同时也是计算机系统的内核与基石。其中,操作系统通常需要处理如管理与配置内存、决定系统资源供需的优先次序、控制输入设备与输出设备、操作网络与管理文件系统等基本事务。
当在操作系统上运行模拟器时,加载模拟器的库文件,并加载预先扫描得到的模拟器的系统调用表。其中,库文件即是DLL(Dynamic Linkable Library)文件,当执行某一个程序时,与其对应的DLL文件就会被调用。并且,系统调用表包括模拟器中模拟系统调用的系统文件,以及该系统文件的位置信息。这里,系统调用表是一个数组指针表,数组的索引就是系统调用实现的地址。
这里,系统文件是指存放操作系统主要文件的文件夹,一般在安装操作系统过程中自动创建,并将相关文件放在对应的文件夹中,这里面的文件直接影响系统的正常运行,多数都不允许随意改变。其中,系统调用表中的系统文件是该模拟器在运行时实际需要调用的系统文件,通常,系统调用是通过int 80、syscall或sysenter等专用指令进行。另外,上述位置信息是指系统调用发生的具体位置。这样,当运行模拟器时,操作系统可以根据该系统调用表,查找到所需要调用的系统文件,进而实现系统调用。
步骤S104:从系统调用表中,查找与库文件相关联的目标系统文件。
这里,在设备的操作系统上加载了模拟器的库文件以及系统调用表之后,查找系统调用表中与该库文件相关联的系统文件,并确定其为目标系 统文件。在系统调用表中,每个系统文件对应有其位置信息,这样,在查找到目标系统文件之后,即可获得该目标系统文件对应的位置信息。
步骤S106:在系统调用表中,将该目标系统文件的位置信息,修改为模拟器对应的执行函数,以通过该执行函数调用目标系统文件。
在查找到目标系统文件之后,根据系统调用表即可获得其对应的位置信息。在本实施例中,将目标系统文件的位置信息修改为模拟器对应的执行函数,这样,当模拟系统在运行时,如果遇到系统调用,则通过该执行函数调用目标系统文件。
相比于现有系统调用技术,由于系统调用需要使用int 80、syscall或sysenter等专用指令进行,其成本比函数调用要高很多,而通过本公开的技术方案,以执行函数取代int 80指令以及其他软中断指令,实现系统文件的调用,大大提高了系统调用的执行速度。
本公开实施例提供的系统调用方法,在操作系统上运行模拟器时,加载模拟器的库文件以及预先扫描得到的模拟器的系统调用表;其中,该系统调用表中包括:模拟器中模拟系统调用的系统文件、以及该系统文件的位置信息;从系统调用表中,查找与库文件相关联的目标系统文件;在系统调用表中,将该目标系统文件的位置信息,修改为模拟器对应的执行函数,以通过该执行函数调用目标系统文件。该方法通过修改模拟器的系统调用表,在模拟系统调用系统文件时,以执行函数跳转到需要调用的系统文件,截断了int 80指令以及其他软中断指令的产生,使得系统调用的执行速度大幅度提高,并有效提高了模拟器的系统调用性能。
在图1所示系统调用方法的基础上,本实施例提供了另一种系统调用方法,该方法应用于配置有模拟器的设备,该模拟器用于对该设备的操作系统进行调用,其中,该方法重点描述了获取上述系统调用表的具体实现过程,如图2所示为该方法的流程示意图,该方法包括以下步骤:
步骤S202:通过二进制搜索和反汇编的方式,扫描模拟系统中包含有预设软中断指令的系统文件,以及该系统文件的位置信息;其中,该预设软中断指令为调用操作系统的指令;该位置信息为偏移位置。
这里,二进制搜索的方式是进行没有格式的内容匹配,例如,在一段数据中搜索“010111110010101”这一串二进制,可直接二进制层面进行匹配搜索。另外,反汇编是把目标代码转为汇编代码的过程,反汇编可以通过反汇编的软件实现,例如OD、IDA Pro、radare2、DEBUG、C32等。并且,软中断指令是由程序设置中断标志后,硬件接着执行中断的相关操作,在本实施例中,该软中断指令为调用操作系统的指令,例如,该软中断指令可以是int80指令、syscall指令和sysenter指令等。
另外,对于不同的模拟系统,通常使用不同的软中断指令。以安卓模拟器的模拟系统为例,Android x86的系统调用使用int 80实现,其中,int 80是一个早已被新的sysenter系列指令淘汰的早期的系统调用的实现方式;Android x64则使用比较先进的syscall系统调用方式。这样,如果该模拟系统为Android x86,则可以将软中断指令预设为int80指令;如果该模拟系统为Android x64,则可以将软中断指令预设为syscall指令。
在其中一种可能的实施方式中,首先生成包含有objdump命令的脚本文件,这里,objdump命令是用查看目标文件或者可执行的目标文件的构成的工具;然后通过该脚本文件,对模拟系统进行二进制静态搜索和反汇编处理,得到该模拟系统中包含有预设软中断指令的系统文件。
这样,通过二进制搜索和反汇编的结合,扫描模拟系统,即可获得包含有预设软中断指令的系统文件,同时获得该系统文件对应的位置信息,在本实施例中,该位置信息为偏移位置。
步骤S204:将扫描得到的系统文件,以及该系统文件的位置信息写入系统调用表。
同样以安卓模拟系统为例,如果该模拟系统为Android x86,则写入该 系统调用表中的系统文件为包含有int80指令的系统文件;如果该模拟系统为Android x64,则写入该系统调用表中的系统文件为包含有syscall指令的系统文件。并且,在写入系统文件的同时,也将系统文件对应的位置信息,即其偏移位置,写入系统调用表。
步骤S206:在操作系统上运行模拟器时,加载模拟器的库文件以及上述系统调用表。
对于上述操作系统,它可以是Windows 32或Windows 64系统。当在操作系统上运行模拟器时,加载该模拟器的库文件,并加载上述系统调用表。
步骤S208:从系统调用表中,查找与库文件相关联的目标系统文件。
步骤S210:在系统调用表中,将该目标系统文件的位置信息,修改为模拟器对应的执行函数,以通过该执行函数调用目标系统文件。
在其中一种可能的实施方式中,该执行函数包括trampline汇编代码,这里,trampline汇编代码是指为达到目标逻辑所添加的一小段汇编代码。
本实施例提供的系统调用方法,提供了获取系统调用表的实现方案,通过二进制搜索和反汇编的方式,获取模拟系统中包含系统调用指令的系统文件,以及对应的位置信息,进而得到该模拟器的系统调用表。该系统调用方法在调用系统文件时,截断了int 80指令以及其他软中断指令的产生,而以执行函数跳转到需要调用的系统文件,提高了系统调用的执行速度,并提高了模拟器的系统调用性能。
本实施例提供了另一种系统调用方法,该方法在图1所示系统调用方法的基础上实现,该方法重点描述了上述将目标系统文件的位置信息,修改为模拟器对应的执行函数的具体实现过程,如图3所示,其为该方法的流程示意图,由图3可知,该方法包括以下步骤:
步骤S302:在操作系统上运行模拟器时,加载模拟器的库文件以及预 先扫描得到的模拟器的系统调用表;其中,该系统调用表中包括:模拟器中模拟系统调用的系统文件、以及该系统文件的位置信息。
步骤S304:从系统调用表中,查找与库文件相关联的目标系统文件。
在其中一种可能的实施方式中,可以从系统调用表中查找库文件的文件名;然后将系统调用表中与该文件名对应的库中的系统文件,确定为与库文件相关联的目标系统文件。
步骤S306:在该操作系统的系统内存中,将目标系统文件对应的位置信息,以patch的方式修改为该模拟系统对应的执行函数。
在操作系统的系统内存中,找到目标系统文件对应的位置,并将其patch成一个直达系统调用实现的执行函数。这里,不改变目标系统文件的内容,只是在内存中对所有的系统调用发生的位置进行patch修改,这样,在Android APP运行的过程中,当遇到系统调用时,是已经被patch过的代码,就不会产生int 80中断,而是直接执行patch代码。
并且,无论系统调用是int 80还是syscall,都可以通过patch的方式,将系统调用修改为函数调用。
步骤S308:在运行该模拟器的过程中,如果需要执行与该模拟器的库文件相关联的系统文件,通过修改后的该执行函数,跳转至该系统文件,以执行该系统文件。
也即,在运行模拟器的过程中,如果需要调用系统文件,则通过上述执行函数跳转到对应的系统文件,并执行该系统文件。在另一种可能的实施方式中,在执行系统文件之后,还通过该执行函数,接收该系统文件的执行结果。例如,如果该系统文件执行成功,则通过该执行函数返回“execution succeed”,否则返回“Execution failed”。
这样,本公开实施例提供的系统调用方法,通过patch的方式截断了int80指令及其他软中断指令的产生,缓解了通过int80指令实现系统调用时,异常处理的性能较差的技术问题,提高了系统调用的执行速度以及系统调 用的性能。
为了更清楚理解上述实施例中所提供的系统调用方法,本实施例介绍了一个应用实例,其为网易MuMu模拟器Nebula新引擎的系统调用实现方式。该方法的具体流程如下:
(1)通过objdump命令组成的脚本,静态搜索整个Android ROM中系统调用发生的地方,并生成一个全局的系统调用表。
(2)在Nebula主程序中加载上述系统调用表。
(3)在Nebula的执行内存中建立一系列称作trampline的汇编代码段,用来模拟系统调用的入口和出口。
(4)当加载ELF(Executable and Linkable Format,可执行与可链接格式)二进制时,对该二进制的内容按照上述系统调用表进行patch,此后整个系统调用不再发生。
这样,所有的Android ROM的系统调用场景,都修改成了直接向trampline程序跳转的逻辑。因此,在Android APP运行的过程中,当遇到系统调用时,读取的是被patch过的代码,就不会产生int 80中断,而是直接执行patch代码。实际测试显示,使用该系统调用方法的操作系统,单个系统调用的速度可以提高三到十倍。
不同于腾讯手游助手Aow引擎方案,Aow引擎方案在内核模块实现int 80的模拟调用服务,该方案尚存在以下不足:
(1)程序难调试;
(2)程序异常会导致系统蓝屏;
(3)int 80异常处理的性能很差;
(4)无法直接支持x64的syscall方式。
而Nebula新引擎没有内核模块,为全用户空间,因而不存在蓝屏问题,调试也非常简单轻量。并且,在调用系统文件时,Nebula新引擎通过patch 的方式截断了int 80指令以及其他软中断指令(例如syscall)的产生,而以执行函数跳转到需要调用的系统文件,这种patch方式可适用于x86以及x64的系统调用,缓解了x64的系统调用无法直接处理的业内难题。
通过该系统调用方法,将昂贵的异常处理或者系统调用,替换为一个简单的jmp指令,这不但是一个巨大的性能节约,而且也大幅提高了系统调用的执行速度,并提高了模拟器的系统调用性能。
对应于上述实施例中的系统调用方法,本公开实施例还提供了一种系统调用装置,其中,该装置应用于配置有模拟器的设备,该模拟器用于对该设备的操作系统进行调用。如图4所示,为该装置的结构示意图,由图4可见,该装置包括依次连接的库文件及系统调用表加载模块41、目标系统文件查找模块42和位置信息修改模块43,其中,各个模块的功能如下:
库文件及系统调用表加载模块41,设置为在该操作系统上运行该模拟器时,加载该模拟器的库文件以及预先扫描得到的该模拟器的系统调用表;其中,该系统调用表中包括:该模拟器中模拟系统调用的系统文件、以及该系统文件的位置信息;
目标系统文件查找模块42,设置为从该系统调用表中,查找与该库文件相关联的目标系统文件;
位置信息修改模块43,设置为在该系统调用表中,将该目标系统文件的位置信息,修改为该模拟器对应的执行函数,以通过该执行函数调用该目标系统文件。
上述系统调用装置,在操作系统上运行模拟器时,加载模拟器的库文件以及预先扫描得到的模拟器的系统调用表;其中,该系统调用表中包括:模拟器中模拟系统调用的系统文件、以及该系统文件的位置信息;从系统调用表中,查找与库文件相关联的目标系统文件;在系统调用表中,将该目标系统文件的位置信息,修改为模拟器对应的执行函数,以通过该执行 函数调用目标系统文件。该装置通过修改模拟器的系统调用表,在模拟系统调用系统文件时,以执行函数跳转到需要调用的系统文件,截断了int 80指令以及其他软中断指令的产生,使得系统调用的执行速度大幅度提高,从而提高了模拟器的系统调用性能,进而提升用户体验。
在其中一种可能的实施方式中,上述库文件及系统调用表加载模块41还设置为:通过二进制搜索和反汇编的方式,扫描模拟系统中包含有预设软中断指令的系统文件,以及该系统文件的位置信息;其中,该预设软中断指令为调用操作系统的指令;该位置信息为偏移位置;将扫描得到的系统文件,以及该系统文件的位置信息写入系统调用表。
在另一种可能的实施方式中,上述库文件及系统调用表加载模块41还设置为:生成包含有objdump命令的脚本文件;通过该脚本文件,对模拟系统进行二进制静态搜索和反汇编处理,得到该模拟系统中包含有预设软中断指令的系统文件。
在另一种可能的实施方式中,如果上述模拟系统为Android x86,该系统调用表中的系统文件为包含有int80指令的系统文件;如果该模拟系统为Android x64,该系统调用表中的系统文件为包含有syscall指令的系统文件。
在另一种可能的实施方式中,上述目标系统文件查找模块42还设置为:从系统调用表中查找库文件的文件名;将系统调用表中,该文件名对应的库中的系统文件,确定为与库文件相关联的目标系统文件。
在另一种可能的实施方式中,上述位置信息修改模块43还设置为:在该操作系统的系统内存中,将目标系统文件对应的位置信息,以patch的方式修改为该模拟系统对应的执行函数。
在另一种可能的实施方式中,上述系统调用装置还包括跳转模块,设置为在运行该模拟器的过程中,如果需要执行与该模拟器的库文件相关联的系统文件,通过修改后的该执行函数,跳转至该系统文件,以执行该系统文件。
在另一种可能的实施方式中,上述系统调用装置还包括执行结果接收模块,设置为通过该执行函数,接收该系统文件的执行结果。
在另一种可能的实施方式中,上述执行函数包括trampline汇编代码。
在另一种可能的实施方式中,上述操作系统包括Windows 32或Windows 64系统。
本公开实施例提供的系统调用装置,其实现原理及产生的技术效果和前述系统调用方法实施例相同,为简要描述,系统调用装置的实施例部分未提及之处,可参考前述系统调用方法实施例中相应内容。
本公开实施例还提供了一种电子设备,如图5所示,为该电子设备的结构示意图,其中,该电子设备包括处理器51和存储器50,该存储器50存储有能够被该处理器51执行的计算机可执行指令,该处理器51执行该计算机可执行指令以实现上述系统调用方法。
在图5示出的实施方式中,该电子设备还包括总线52和通信接口53,其中,处理器51、通信接口53和存储器50通过总线52连接。
其中,存储器50可能包含高速随机存取存储器(RAM,Random Access Memory),也可能还包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。通过至少一个通信接口53(可以是有线或者无线)实现该系统网元与至少一个其他网元之间的通信连接,可以使用互联网,广域网,本地网,城域网等。总线52可以是ISA总线、PCI总线或EISA总线等。所述总线52可以分为地址总线、数据总线、控制总线等。为便于表示,图5中仅用一个双向箭头表示,但并不表示仅有一根总线或一种类型的总线。
处理器51可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器51中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器51可以是通用处理器,包括中央处理 器(Central Processing Unit,简称CPU)、网络处理器(Network Processor,简称NP)等;还可以是数字信号处理器(Digital Signal Processor,简称DSP)、专用集成电路(Application Specific Integrated Circuit,简称ASIC)、现场可编程门阵列(Field-Programmable Gate Array,简称FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本公开实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器51读取存储器中的信息,结合其硬件完成前述实施例的系统调用方法的步骤。
图6为本公开实施例的其中一种计算机可读存储介质的结构示意图。如图6所示,描述了根据本申请的实施方式的程序产品1100,其上存储有计算机程序,该计算机程序包括有计算机可执行指令,该计算机可执行指令在被处理器调用和执行时,该计算机可执行指令促使处理器实现上述系统调用方法,具体实现可参见前述方法实施例,在此不再赘述。
本公开实施例所提供的系统调用方法、系统调用装置和电子设备的计算机程序产品,包括存储了程序代码的计算机可读存储介质,所述程序代码包括的指令可用于执行前面方法实施例中所述的系统调用方法,具体实现可参见方法实施例,在此不再赘述。
除非另外具体说明,否则在这些实施例中阐述的部件和步骤的相对步骤、数字表达式和数值并不限制本公开的范围。
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个处理器可执行的非易失的计算机可读取存储介质中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软 件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本公开各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
最后应说明的是:以上所述实施例,仅为本公开的具体实施方式,用以说明本公开的技术方案,而非对其限制,本公开的保护范围并不局限于此,尽管参照前述实施例对本公开进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本公开揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本公开实施例技术方案的精神和范围,都应涵盖在本公开的保护范围之内。因此,本公开的保护范围应以所述权利要求的保护范围为准。
工业实用性
通过在操作系统上运行模拟器时,加载模拟器的库文件以及预先扫描得到的模拟器的系统调用表;其中,该系统调用表中包括:模拟器中模拟系统调用的系统文件、以及该系统文件的位置信息;从系统调用表中,查找与库文件相关联的目标系统文件;在系统调用表中,将该目标系统文件的位置信息,修改为模拟器对应的执行函数,以通过该执行函数调用目标系统文件,达到了截断了int 80指令以及其他软中断指令的产生的目的,从而实现了提高系统调用的执行速度,以及提高模拟器的系统调用性能的技术效果。

Claims (15)

  1. 一种系统调用方法,所述方法应用于配置有模拟器的设备,所述模拟器用于对所述设备的操作系统进行调用,所述方法包括:
    在所述操作系统上运行所述模拟器时,加载所述模拟器的库文件以及预先扫描得到的所述模拟器的系统调用表;其中,所述系统调用表中包括:所述模拟器中模拟系统调用的系统文件、以及所述系统文件的位置信息;
    从所述系统调用表中,查找与所述库文件相关联的目标系统文件;
    在所述系统调用表中,将所述目标系统文件的位置信息,修改为所述模拟器对应的执行函数,以通过所述执行函数调用所述目标系统文件。
  2. 根据权利要求1所述的方法,其中,所述系统调用表通过下述方式得到:
    通过二进制搜索和反汇编的方式,扫描所述模拟系统中包含有预设软中断指令的系统文件,以及所述系统文件的位置信息;其中,所述预设软中断指令为调用所述操作系统的指令;所述位置信息为偏移位置;
    将扫描得到的系统文件,以及所述系统文件的位置信息写入系统调用表。
  3. 根据权利要求2所述的方法,其中,通过二进制搜索和反汇编的方式,扫描所述模拟系统中包含有预设软中断指令的系统文件的步骤,包括:
    生成包含有objdump命令的脚本文件;
    通过所述脚本文件,对所述模拟系统进行二进制静态搜索和反汇编处理,得到所述模拟系统中包含有预设软中断指令的系统文件。
  4. 根据权利要求1所述的方法,其中,
    如果所述模拟系统为Android x86,所述系统调用表中的系统文件为包含有int80指令的系统文件;
    如果所述模拟系统为Android x64,所述系统调用表中的系统文件为包含有syscall指令的系统文件。
  5. 根据权利要求1所述的方法,其中,从所述系统调用表中,查找与所述库文件相关联的目标系统文件的步骤,包括:
    从所述系统调用表中查找所述库文件的文件名;
    将所述系统调用表中,所述文件名对应的库中的系统文件,确定为与所述库文件相关联的目标系统文件。
  6. 根据权利要求1所述的方法,其中,将所述目标系统文件的位置信息,修改为所述模拟器对应的执行函数的步骤,包括:
    在所述操作系统的系统内存中,将所述目标系统文件对应的位置信息,以patch的方式修改为所述模拟系统对应的执行函数。
  7. 根据权利要求1所述的方法,其中,将所述目标系统文件的位置信息,修改为所述模拟器对应的执行函数的步骤之后,所述方法还包括:
    在运行所述模拟器的过程中,如果需要执行与所述模拟器的库文件相关联的系统文件,通过修改后的所述执行函数,跳转至所述系统文件,以执行所述系统文件。
  8. 根据权利要求7所述的方法,其中,通过修改后的所述执行函数,跳转至所述系统文件,以执行所述系统文件的步骤之后,所述方法还包括:
    通过所述执行函数,接收所述系统文件的执行结果。
  9. 根据权利要求1所述的方法,其中,所述库文件是DLL文件。
  10. 根据权利要求1所述的方法,其中,所述系统调用表是一个数组指针表,数组的索引为系统调用实现的地址。
  11. 根据权利要求1所述的方法,其中,所述执行函数包括trampline汇编代码,其中,所述trampline汇编代码是指为达到目标逻辑所添加的汇编代码。
  12. 根据权利要求2所述的方法,其中,所述软中断指令包括:int80 指令、syscall指令或sysenter指令。
  13. 一种系统调用装置,所述装置应用于配置有模拟器的设备,所述模拟器用于对所述设备的操作系统进行调用,所述装置包括:
    库文件及系统调用表加载模块,设置为在所述操作系统上运行所述模拟器时,加载所述模拟器的库文件以及预先扫描得到的所述模拟器的系统调用表;其中,所述系统调用表中包括:所述模拟器中模拟系统调用的系统文件、以及所述系统文件的位置信息;
    目标系统文件查找模块,设置为从所述系统调用表中,查找与所述库文件相关联的目标系统文件;
    位置信息修改模块,设置为在所述系统调用表中,将所述目标系统文件的位置信息,修改为所述模拟器对应的执行函数,以通过所述执行函数调用所述目标系统文件。
  14. 一种电子设备,包括处理器和存储器,所述存储器存储有能够被所述处理器执行的计算机可执行指令,所述处理器执行所述计算机可执行指令以实现权利要求1至12任一项所述的系统调用方法。
  15. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可执行指令,所述计算机可执行指令在被处理器调用和执行时,计算机可执行指令促使处理器实现权利要求1至12任一项所述的系统调用方法。
PCT/CN2019/123327 2019-09-24 2019-12-05 系统调用方法、装置和电子设备 WO2021056823A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US16/975,405 US20230103210A1 (en) 2019-09-24 2019-12-05 System Call Method and Apparatus, and Electronic Device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910908623.1 2019-09-24
CN201910908623.1A CN110688198B (zh) 2019-09-24 2019-09-24 系统调用方法、装置和电子设备

Publications (1)

Publication Number Publication Date
WO2021056823A1 true WO2021056823A1 (zh) 2021-04-01

Family

ID=69110559

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/123327 WO2021056823A1 (zh) 2019-09-24 2019-12-05 系统调用方法、装置和电子设备

Country Status (3)

Country Link
US (1) US20230103210A1 (zh)
CN (1) CN110688198B (zh)
WO (1) WO2021056823A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113282541A (zh) * 2021-06-04 2021-08-20 网易(杭州)网络有限公司 文件调用方法、装置和电子设备

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112379968A (zh) * 2020-11-13 2021-02-19 网易(杭州)网络有限公司 应用多开的方法、装置、设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101866408A (zh) * 2010-06-30 2010-10-20 华中科技大学 一种基于虚拟机架构的透明信任链构建系统
CN102591696A (zh) * 2011-01-14 2012-07-18 中国科学院软件研究所 一种手机软件行为数据提取方法及系统
US20160314060A1 (en) * 2005-06-10 2016-10-27 Wapp Tech Corp. Systems including network simulating for mobile application development
CN108170503A (zh) * 2018-01-24 2018-06-15 腾讯科技(深圳)有限公司 一种跨系统运行安卓应用的方法、终端及存储介质

Family Cites Families (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8423749B2 (en) * 2008-10-22 2013-04-16 International Business Machines Corporation Sequential processing in network on chip nodes by threads generating message containing payload and pointer for nanokernel to access algorithm to be executed on payload in another node
US8959577B2 (en) * 2012-04-13 2015-02-17 Cisco Technology, Inc. Automatic curation and modification of virtualized computer programs
CN102902928B (zh) * 2012-09-21 2017-02-15 杭州迪普科技有限公司 一种网页防篡改方法及装置
CN104216726B (zh) * 2013-06-04 2016-08-10 腾讯科技(深圳)有限公司 Android虚拟机加载方法及装置
US9436746B2 (en) * 2014-01-20 2016-09-06 Sap Se Next generation architecture for database connectivity
CN103793651B (zh) * 2014-02-22 2016-05-25 西安电子科技大学 基于Xen虚拟化的内核完整性检测方法
CN106537333A (zh) * 2014-06-13 2017-03-22 查尔斯斯塔克德拉珀实验室公司 用于软件产物的数据库的系统和方法
CN106445630A (zh) * 2016-08-10 2017-02-22 北京奇虎科技有限公司 Android模拟器及实现Android模拟器的方法
US10445112B2 (en) * 2017-01-27 2019-10-15 Software Ag Inline dispatching function interface (IDFI), and associated system and/or method
CN106959859B (zh) * 2017-03-30 2021-08-24 北京奇虎科技有限公司 系统调用函数的调用方法与装置
US11055401B2 (en) * 2017-09-29 2021-07-06 Intel Corporation Technologies for untrusted code execution with processor sandbox support
CN107797820B (zh) * 2017-11-13 2021-03-23 北京百度网讯科技有限公司 用于生成补丁的方法和装置
US10990371B2 (en) * 2018-01-17 2021-04-27 Crowdstrike, Inc. Device driver non-volatile backing-store installation

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160314060A1 (en) * 2005-06-10 2016-10-27 Wapp Tech Corp. Systems including network simulating for mobile application development
CN101866408A (zh) * 2010-06-30 2010-10-20 华中科技大学 一种基于虚拟机架构的透明信任链构建系统
CN102591696A (zh) * 2011-01-14 2012-07-18 中国科学院软件研究所 一种手机软件行为数据提取方法及系统
CN108170503A (zh) * 2018-01-24 2018-06-15 腾讯科技(深圳)有限公司 一种跨系统运行安卓应用的方法、终端及存储介质

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113282541A (zh) * 2021-06-04 2021-08-20 网易(杭州)网络有限公司 文件调用方法、装置和电子设备
CN113282541B (zh) * 2021-06-04 2023-08-11 网易(杭州)网络有限公司 文件调用方法、装置和电子设备

Also Published As

Publication number Publication date
CN110688198B (zh) 2021-03-02
US20230103210A1 (en) 2023-03-30
CN110688198A (zh) 2020-01-14

Similar Documents

Publication Publication Date Title
CN108984174B (zh) 跨平台的应用创建方法、装置、服务器和存储介质
US9652617B1 (en) Analyzing security of applications
US8627296B1 (en) Unified unit and integration test with automatic mock creation
CN109408393B (zh) 应用测试方法、装置及设备和计算机可读存储介质
US20130117855A1 (en) Apparatus for automatically inspecting security of applications and method thereof
US9449042B1 (en) Recommending improvements to and detecting defects within applications
Bala et al. A study on smartphone based operating system
WO2021056823A1 (zh) 系统调用方法、装置和电子设备
CN103443763A (zh) 包含对重写虚拟函数的调用的支持的isa桥接
WO2023155940A1 (zh) 小程序的编译方法、小程序的运行方法及装置、存储介质
CN111338925A (zh) 小程序测试方法及装置、系统、电子设备和存储介质
CN110908677B (zh) 一种Flutter应用安装包体积优化的方法及存储介质
US9185513B1 (en) Method and system for compilation with profiling feedback from client
CN114547604A (zh) 一种应用检测方法、装置、存储介质及电子设备
CN113835737A (zh) 一种前端项目添加权限的方法及系统
CN111385661B (zh) 语音控制全屏播放的方法、装置、终端及存储介质
US10445218B2 (en) Execution of graphic workloads on a simulated hardware environment
CN106844186B (zh) 应用的脱机测试方法及终端设备
US9697018B2 (en) Synthesizing inputs to preserve functionality
CN114428642A (zh) 一种基于新型处理器架构的随机指令生成环境
CN116775202A (zh) 模糊测试方法、装置、介质、电子设备及计算机程序产品
CN111242731B (zh) 一种业务执行的方法及装置
US20220035591A1 (en) Method and apparatus for displaying message box, terminal device and non-transitory computer-readable storage medium
KR100562226B1 (ko) 무선 인터넷 플랫폼 상에서 애플리케이션을 검증하기 위한방법 및 시스템
JP6586143B2 (ja) ファイルの実行をエミュレートするシステム及び方法

Legal Events

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

Ref document number: 19946953

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: 19946953

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 19946953

Country of ref document: EP

Kind code of ref document: A1