Bytecode ending identification method and device in disassembly, equipment and storage medium

By judging the jump address of the backward jump instruction during the disassembly process and identifying the last instruction bytecode of the basic block, the problem of bytecode parsing confusion during executable file disassembly is solved and the correct byte code is achieved. Code analysis.

CN118778970APending Publication Date: 2024-10-15WUHAN TIANYU INFORMATION IND
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410897405.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

When disassembling an executable file, it is difficult to accurately identify the end of the method, resulting in bytecode parsing errors and confusion in parsing.

Method used

By obtaining the basic block in the executable file, search for the instruction bytecode and bytecode information, determine the jump address of the backward jump instruction, and determine whether it is the last instruction word of the basic block based on the maximum value of the jump address. Section code, ensuring that the end of a method is correctly identified.

Benefits of technology

This effectively avoids confusion in subsequent parsing, ensures correct parsing and processing of bytecodes, and solves the problem of bytecode parsing errors during disassembly in the prior art.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118778970A_ABST
    Figure CN118778970A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of disassembling, and discloses a byte code ending identification method and device in disassembling, equipment and a storage medium. The method comprises the following steps: acquiring an executable file and a basic block in the executable file; searching an instruction byte code and byte code information of the basic block; when the instruction byte code is a backward jump instruction, acquiring a jump address of the backward jump instruction; judging whether the instruction byte code is a return instruction or a forward unconditional jump instruction according to the byte code information; if yes, whether the instruction byte code is the last instruction byte code of the basic block or not is judged according to the maximum value of the jump address. According to the method, whether the instruction byte code is the last byte code of the basic block or not is judged by judging whether the skipping range of the skipping instruction reaches or exceeds the return instruction or the forward unconditional skipping instruction in front of the return instruction or the forward unconditional skipping instruction, so that the next basic block can be correctly analyzed; and the subsequent analysis disorder is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of disassembly, and in particular to a method, device, equipment and storage medium for identifying the end of bytecodes in disassembly. Background Art

[0002] The executable file of a computer or virtual machine is a string of hexadecimal numbers. Sometimes it is necessary to disassemble the executable file and translate the bytecode into assembly statements that are easy for programmers to recognize in order to analyze problems or optimize and convert the bytecode. The bytecodes of all functions or methods (Methods) of the executable file are in one segment. When disassembling, it is necessary to be able to distinguish the end of a function or method and find the start and end addresses of each function or method in this segment in order to correctly parse the bytecode.

[0003] For disassembling executable files, for example, a JAVA card (a contact microprocessor smart card that runs JAVA programs) is used as an example. The executable file of the JAVA card virtual machine is called a CAP file. All method bytecodes of the CAP file are stored in the Method component. Each method consists of a method header and a bytecode. The format of the method header is fixed, but the number of bytecodes of a method is unknown. When disassembling the CAP file, the position of the first method header in the Method component is found. After skipping the size of the method header, the position of the bytecode of the first method is obtained. Each bytecode can be parsed according to the bytecode format, but it is difficult to determine how many bytecodes this method has. The method header of the next method may be parsed as the bytecode of the previous method, which will cause all subsequent parsing to be disordered and the bytecode parsing to fail. Summary of the invention

[0004] The main purpose of the present invention is to provide a method, device, equipment and storage medium for identifying the end of bytecodes in disassembly, aiming to solve the problem that bytecode parsing confusion may occur when disassembling executable files.

[0005] To achieve the above object, the present invention provides a method for identifying the end of bytecode in disassembly, comprising:

[0006] Obtaining an executable file and basic blocks in the executable file;

[0007] Searching for instruction bytecodes and bytecode information of the basic block;

[0008] When the instruction bytecode is a backward jump instruction, obtaining a jump address of the backward jump instruction;

[0009] Determining whether the instruction bytecode is a return instruction or a forward unconditional jump instruction according to the bytecode information;

[0010] If so, determine whether the instruction bytecode is the last instruction bytecode of the basic block according to the maximum value of the jump address.

[0011] In some embodiments, searching for the instruction bytecode and bytecode information of the basic block includes:

[0012] Finding the starting address of the instruction bytecode of the basic block;

[0013] Obtaining the first byte of the instruction bytecode based on the starting address; wherein the first byte is an operation code;

[0014] The bytecode information of the instruction bytecode is searched according to the first byte.

[0015] In some embodiments, searching for bytecode information of the instruction bytecode according to the first byte includes:

[0016] Obtain an operation code table corresponding to the first byte;

[0017] The bytecode information of the instruction bytecode is searched based on the operation code table.

[0018] In some embodiments, judging whether the instruction bytecode is the last instruction bytecode of the basic block according to the maximum value of the jump address includes:

[0019] Find the maximum value of the jump address;

[0020] Determining whether the maximum value of the jump address is less than or equal to the address of the instruction bytecode;

[0021] If so, the instruction bytecode is the last instruction bytecode of the basic block.

[0022] In some embodiments, the method further comprises:

[0023] When the instruction bytecode is not a backward jump instruction, determining whether the instruction bytecode is a return instruction or a forward unconditional jump instruction according to the bytecode information;

[0024] If not, return to search for the next instruction bytecode and bytecode information of the basic block until the last instruction bytecode of the basic block is found.

[0025] In some embodiments, the returning to search for the next instruction bytecode and bytecode information of the basic block until the last instruction bytecode of the basic block is found includes:

[0026] Determine the length of the instruction bytecode according to the bytecode information;

[0027] Calculating the address of the next instruction bytecode of the basic block according to the length of the instruction bytecode;

[0028] searching for the next instruction bytecode and bytecode information of the next instruction bytecode based on the address of the next instruction bytecode;

[0029] When the next instruction bytecode is a backward jump instruction, the step of obtaining the jump address of the backward jump instruction is executed until the last instruction bytecode of the basic block is found.

[0030] In some embodiments, the bytecode information includes format, length, and instruction type.

[0031] In addition, to achieve the above-mentioned purpose, the present invention also provides a bytecode end recognition device in disassembly, comprising:

[0032] An acquisition module, used for acquiring an executable file and basic blocks in the executable file;

[0033] A byte information search module, used to search for instruction bytecodes and bytecode information of the basic block;

[0034] A backward jump determination module, used for obtaining the jump address of the backward jump instruction when the instruction bytecode is a backward jump instruction;

[0035] A return jump judgment module, used for judging whether the instruction bytecode is a return instruction or a forward unconditional jump instruction according to the bytecode information;

[0036] The end determination module is used to determine whether the instruction bytecode is the last instruction bytecode of the basic block according to the maximum value of the jump address.

[0037] In addition, to achieve the above-mentioned purpose, the present invention also proposes an electronic device, which includes: a memory, a processor, and a disassembly bytecode end recognition program stored in the memory and run on the processor, and the disassembly bytecode end recognition program is configured to implement the disassembly bytecode end recognition method as described above.

[0038] In addition, to achieve the above-mentioned purpose, the present invention also proposes a storage medium, which stores a bytecode end recognition program in disassembly, and the bytecode end recognition program in disassembly is used to enable the processor to implement the bytecode end recognition method in disassembly as described above when executing.

[0039] The present invention provides a method for identifying the end of bytecodes in disassembly, comprising: obtaining an executable file and a basic block in the executable file; searching for instruction bytecodes and bytecode information of the basic block; when the instruction bytecode is a backward jump instruction, obtaining the jump address of the backward jump instruction; judging whether the instruction bytecode is a return instruction or a forward unconditional jump instruction according to the bytecode information; if so, judging whether the instruction bytecode is the last instruction bytecode of the basic block according to the maximum value of the jump address. In the present invention, when the executable file is disassembled, each bytecode is parsed backward according to the bytecode format, and by judging whether there is a jump instruction in front of the return instruction or the forward unconditional jump instruction, whether the jump range reaches or exceeds the return instruction or the forward unconditional jump instruction, thereby judging whether the instruction bytecode is the last bytecode of the basic block, so as to find the end of the bytecode of a basic block, correctly start parsing the next basic block, avoid the occurrence of subsequent parsing confusion, and solve the problems of bytecode parsing confusion that are easy to occur when the executable file is disassembled in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 A schematic diagram of the structure of an electronic device in a hardware operating environment involved in an embodiment of the present invention;

[0041] Figure 2 A schematic diagram of a flow chart of an embodiment of a method for identifying the end of bytecodes in disassembly of the present invention;

[0042] Figure 3 It is a structural block diagram of an embodiment of a bytecode end recognition device in disassembly of the present invention.

[0043] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0044] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0045] It should be noted that all directional indications in the embodiments of the present invention (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.

[0046] In addition, the descriptions of "first", "second", etc. in the present invention are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but it must be based on the ability of ordinary technicians in the field to implement. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by the present invention. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0047] Reference Figure 1 , Figure 1 The figure is a schematic diagram of the structure of an electronic device of a hardware operating environment involved in an embodiment of the present invention.

[0048] like Figure 1 As shown, the electronic device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM memory) or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0049] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0050] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a bytecode end recognition program in disassembly.

[0051] exist Figure 1In the electronic device shown, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the electronic device of the present invention can be set in the electronic device, and the electronic device calls the disassembly bytecode end recognition program stored in the memory 1005 through the processor 1001, and executes the disassembly bytecode end recognition method provided in an embodiment of the present invention.

[0052] The present invention provides a method, device, equipment and storage medium for identifying the end of bytecode in disassembly.

[0053] The embodiment of the present invention provides a method for identifying the end of bytecode in disassembly, referring to Figure 2 , Figure 2 The figure is a flow chart of a first embodiment of a method for identifying the end of bytecodes in disassembly according to the present invention.

[0054] like Figure 2 As shown, the method for identifying the end of bytecode in disassembly includes:

[0055] Step S100: Obtain an executable file and basic blocks in the executable file;

[0056] Step S200: searching for instruction bytecodes and bytecode information of the basic block;

[0057] Step S300: when the instruction bytecode is a backward jump instruction, obtaining a jump address of the backward jump instruction;

[0058] Step S400: determining whether the instruction bytecode is a return instruction or a forward unconditional jump instruction according to the bytecode information;

[0059] Step S500: If yes, determine whether the instruction bytecode is the last instruction bytecode of the basic block according to the maximum value of the jump address.

[0060] It should be noted that the execution subject in this embodiment may be an electronic device, which may be a computer device with data processing functions, or other devices that can achieve the same or similar functions. This embodiment does not limit this. In this embodiment, a computer device is used as an example for explanation.

[0061] It can be understood that the code module that implements various functions in C language programming is generally called a function, and the code module that implements various functions in JAVA language programming is generally called a method. Functions and methods are similar and are collectively referred to as basic blocks (functions / methods) in this embodiment.

[0062] In this embodiment, the disassembly of an executable file (CAP file) programmed in JAVA language is used as an example for explanation. All method bytecodes of the CAP file are stored in the Method component, and each method consists of a method header and bytecodes, and the format of the method header is fixed.

[0063] It should be noted that, through induction and summary, the following conclusions are obtained in this embodiment: the last instruction bytecode of a method (basic block) must be a return instruction or an unconditional jump instruction of forward jump, but the return instruction or the unconditional jump instruction of forward jump is not necessarily the last bytecode of the method (basic block). The reason for this conclusion is: if a bytecode is neither a return instruction nor an unconditional jump instruction of forward jump, then after executing this instruction, it may continue to execute backward, and it cannot be the last instruction of the method (basic block); the return instruction may be the last instruction of the method, or it may not be the last instruction, because the method (basic block) may also return in the middle of execution; the unconditional jump instruction of forward jump may be the last instruction of the method (basic block), and usually it jumps to the previous return instruction to complete the return of the function.

[0064] According to the conclusions summarized above, we need to continue to solve the problem of whether the return instruction and the unconditional jump instruction of the forward jump are the last bytecode of the method (basic block). The judgment method is: whether there is a jump instruction (including conditional jump and unconditional jump) in front of the return instruction and the unconditional jump instruction of the forward jump, and the jump range reaches or exceeds the return instruction and the unconditional jump instruction of the forward jump; if not, the return instruction and the unconditional jump instruction of the forward jump are the last instructions of the method (basic block), otherwise the return instruction and the unconditional jump instruction of the forward jump are not the last instructions of the method (basic block).

[0065] It can be understood that the reason why the end determination process of the bytecode of a method (basic block) is established in this embodiment is: if there is no other instruction in front of a return instruction or an unconditional jump instruction of a forward jump to jump to the back of the instruction, after the program executes to the return instruction or the unconditional jump instruction of the forward jump: for the return instruction, the return operation is directly executed, and for the forward jump instruction, it jumps back to the previous instruction. The instructions behind the return instruction or the unconditional jump instruction of the forward jump have no chance to be executed, so the return instruction or the unconditional jump instruction of the forward jump must be the last instruction of the method (basic block).

[0066] In one embodiment, searching for the instruction bytecode and bytecode information of the basic block includes: searching for the starting address of the instruction bytecode of the basic block; obtaining the first byte of the instruction bytecode based on the starting address; wherein the first byte is an operation code; and searching for the bytecode information of the instruction bytecode according to the first byte.

[0067] Wherein, searching for the bytecode information of the instruction bytecode according to the first byte includes: obtaining an operation code table corresponding to the first byte; and searching for the bytecode information of the instruction bytecode based on the operation code table.

[0068] Exemplarily, the bytecode information includes, but is not limited to, format, length, and instruction type.

[0069] Specifically, find the method (or function) in the method section of the CAP file. The method includes multiple instruction bytecodes that can be executed sequentially, and find the starting address of the first instruction bytecode. Get the first byte of the first instruction bytecode. The first byte is the opcode. The format, length and meaning (instruction type) of this instruction bytecode can be obtained by looking up the opcode table. Starting from the first instruction bytecode, judge the instruction bytecodes one by one. When a return instruction or an unconditional forward jump instruction is found, judge whether the instruction is the last instruction of this method (or function).

[0070] It should be noted that JAVA bytecode instructions include opcodes and operands. Opcodes (Opcode): represent a specific operation meaning. Operands (Operands): zero or more, following the opcode, representing the parameters required for this operation. Since the JAVA virtual machine is based on a stack rather than a register structure, most JAVA bytecode instructions have only one opcode. The main types of bytecode instructions are as follows: load and store instructions, arithmetic instructions, type conversion instructions, object creation and access instructions, method call and return instructions, operand stack management instructions, and control transfer instructions. Among them, control transfer instructions include: comparison instructions, conditional jump instructions, comparison conditional jump instructions, multi-conditional branch jump instructions, and unconditional jump instructions.

[0071] In one embodiment, when the instruction bytecode is a backward jump instruction, the jump address of the backward jump instruction is obtained; based on the bytecode information, it is determined whether the instruction bytecode is a return instruction or a forward unconditional jump instruction; if so, based on the maximum value of the jump address, it is determined whether the instruction bytecode is the last instruction bytecode of the basic block.

[0072] In one embodiment, judging whether the instruction bytecode is the last instruction bytecode of the basic block according to the maximum value of the jump address includes: finding the maximum value of the jump address; judging whether the maximum value of the jump address is less than or equal to the address of the instruction bytecode; if so, the instruction bytecode is the last instruction bytecode of the basic block.

[0073] Specifically, starting from the first instruction bytecode, the instruction bytecodes are judged one by one. If it is found that a backward jump may occur when the instruction bytecode is executed (the instruction bytecode is a backward jump instruction), the jump address of the backward jump instruction is recorded.

[0074] Exemplarily, if it is found that the instruction bytecode is a return instruction or a forward unconditional jump instruction, the maximum value of the jump address of the backward jump instruction is found, and it is determined whether the instruction bytecode is the last instruction bytecode of the basic block based on the maximum value of the jump address of the backward jump instruction.

[0075] In one example, if the maximum value of the jump address of the backward jump instruction is less than or equal to the address of the current instruction bytecode, and the current instruction bytecode is a return instruction or an unconditional forward jump instruction, then the current instruction bytecode is the last instruction bytecode of the method (basic block).

[0076] In one embodiment, the method further includes: when the instruction bytecode is not a backward jump instruction, determining whether the instruction bytecode is a return instruction or a forward unconditional jump instruction based on the bytecode information; if not, returning to search for the next instruction bytecode and bytecode information of the basic block until the last instruction bytecode of the basic block is found.

[0077] It is understandable that if it is found that the instruction bytecode is not the above situation (i.e., no backward jump occurs during execution and the instruction bytecode is not a return instruction or a forward unconditional jump instruction), the next instruction bytecode is searched, and steps S200 to S500 are executed to determine whether the next instruction bytecode is the last instruction bytecode of the basic block. Steps S200 to S500 are looped until the last instruction bytecode of the basic block is found.

[0078] In one embodiment, returning to search for the next instruction bytecode and bytecode information of the basic block until the last instruction bytecode of the basic block is found includes: determining the length of the instruction bytecode according to the bytecode information; calculating the address of the next instruction bytecode of the basic block according to the length of the instruction bytecode; searching for the next instruction bytecode and the bytecode information of the next instruction bytecode based on the address of the next instruction bytecode; and executing the step of obtaining the jump address of the backward jump instruction when the next instruction bytecode is a backward jump instruction, until the last instruction bytecode of the basic block is found.

[0079] Specifically, starting from the first instruction bytecode, the instruction bytecodes are judged one by one. If it is judged that the instruction bytecode is not the last instruction bytecode, the length of the instruction bytecode is determined according to the bytecode information of the instruction bytecode obtained by looking up the opcode table, and the address of the next instruction bytecode is calculated according to the length of the instruction bytecode. Return to step S200 to take the first byte (opcode) of the next instruction bytecode, look up the opcode table, and obtain the bytecode information of the instruction bytecode (such as format, length and operation type); when the instruction bytecode is a backward jump instruction, obtain the jump address of the backward jump instruction; determine whether the instruction bytecode is a return instruction or a forward unconditional jump instruction according to the bytecode information of the instruction bytecode; if so, determine whether the instruction bytecode is the last instruction bytecode of the basic block according to the maximum value of the jump address. Repeat the process from step S200 to step S500 until the last instruction bytecode is found, and the search for the last instruction bytecode of a method (basic block) is completed.

[0080] It should be noted that when writing a program, a language such as C, JAVA, Pascal, etc. is used, and then a file that can be directly executed by the operating system is generated through a compiler, i.e., an executable file. When it is necessary to identify an executable file in order to analyze a problem or to optimize or convert the bytecode, after obtaining the executable file, the executable file to be identified can be disassembled. Disassembly means decompiling these executable files and restoring them into assembly language or other languages ​​for subsequent processing. According to the improved method for identifying the end of bytecode in disassembly in this embodiment, the end of the bytecode of a method can be found so as to correctly start parsing the next method.

[0081] The present embodiment provides a method for identifying the end of bytecodes in disassembly, including: obtaining an executable file and a basic block in the executable file; searching for instruction bytecodes and bytecode information of the basic block; when the instruction bytecode is a backward jump instruction, obtaining the jump address of the backward jump instruction; judging whether the instruction bytecode is a return instruction or a forward unconditional jump instruction according to the bytecode information; if so, judging whether the instruction bytecode is the last instruction bytecode of the basic block according to the maximum value of the jump address. In the present embodiment, when the executable file is disassembled, each bytecode is parsed backward according to the bytecode format, and by judging whether there is a jump instruction in front of the return instruction or the forward unconditional jump instruction, whether the jump range reaches or exceeds the return instruction or the forward unconditional jump instruction, thereby judging whether the instruction bytecode is the last bytecode of the basic block, so as to find the end of the bytecode of a basic block, correctly start parsing the next basic block, avoid the occurrence of subsequent parsing confusion, etc., and solve the existing problems of bytecode parsing confusion when disassembling executable files.

[0082] In addition, an embodiment of the present invention further proposes a storage medium, on which a bytecode end recognition program in disassembly is stored. When the bytecode end recognition program in disassembly is executed by a processor, the steps of the bytecode end recognition method in disassembly are implemented as described above.

[0083] Reference Figure 3 , Figure 3 It is a structural block diagram of an embodiment of a bytecode end recognition device in disassembly of the present invention.

[0084] like Figure 3 As shown, the bytecode end recognition device in the disassembly process includes:

[0085] An acquisition module 10, used for acquiring an executable file and basic blocks in the executable file;

[0086] A byte information search module 20, used to search for instruction bytecodes and bytecode information of the basic block;

[0087] A backward jump determination module 30, used for obtaining the jump address of the backward jump instruction when the instruction bytecode is a backward jump instruction;

[0088] A return jump determination module 40 is used to determine whether the instruction bytecode is a return instruction or a forward unconditional jump instruction according to the bytecode information;

[0089] The end determination module 50 is used to determine whether the instruction bytecode is the last instruction bytecode of the basic block according to the maximum value of the jump address.

[0090] It is understandable that the code module that implements each function in C language programming is generally called a function, and the code module that implements each function in JAVA language programming is generally called a method. Functions and methods are similar, and in this embodiment, they are uniformly referred to as basic blocks (functions / methods). In this embodiment, the disassembly of an executable file (CAP file) programmed in JAVA language is used as an example for explanation. All method bytecodes of the CAP file are stored in the Method component, and each method consists of a method header and bytecodes, and the format of the method header is determined.

[0091] It should be noted that the reason why the end determination process of the bytecode of a method (basic block) is established in this embodiment is: if there is no other instruction in front of a return instruction or an unconditional jump instruction of a forward jump to jump to the back of the instruction, after the program executes to the return instruction or the unconditional jump instruction of the forward jump: for the return instruction, the return operation is directly executed, and for the forward jump instruction, it jumps back to the previous instruction. The instructions behind the return instruction or the unconditional jump instruction of the forward jump have no chance to be executed, so the return instruction or the unconditional jump instruction of the forward jump must be the last instruction of the method (basic block).

[0092] Exemplarily, the byte information search module 20 is specifically used to find the starting address of the instruction bytecode of the basic block; obtain the first byte of the instruction bytecode based on the starting address; wherein the first byte is the operation code; and search for the bytecode information of the instruction bytecode according to the first byte.

[0093] Specifically, searching for bytecode information of the instruction bytecode according to the first byte includes: obtaining an operation code table corresponding to the first byte; searching for bytecode information of the instruction bytecode based on the operation code table; the bytecode information includes format, length and instruction type.

[0094] Exemplarily, the end determination module 50 is specifically used to: find the maximum value of the jump address; determine whether the maximum value of the jump address is less than or equal to the address of the instruction bytecode; if so, the instruction bytecode is the last instruction bytecode of the basic block.

[0095] Exemplarily, the device further includes: a judgment module. The judgment module is used to: when the instruction bytecode is not a backward jump instruction, judge whether the instruction bytecode is a return instruction or a forward unconditional jump instruction according to the bytecode information; if not, return to search for the next instruction bytecode and bytecode information of the basic block until the last instruction bytecode of the basic block is found.

[0096] Specifically, returning to search for the next instruction bytecode and bytecode information of the basic block until the last instruction bytecode of the basic block is found, including: determining the length of the instruction bytecode according to the bytecode information; calculating the address of the next instruction bytecode of the basic block according to the length of the instruction bytecode; searching for the next instruction bytecode and the bytecode information of the next instruction bytecode based on the address of the next instruction bytecode; executing the step of obtaining the jump address of the backward jump instruction when the next instruction bytecode is a backward jump instruction, until the last instruction bytecode of the basic block is found.

[0097] In this embodiment, through the bytecode end recognition device in disassembly, when disassembling the executable file, each bytecode is parsed backward according to the bytecode format, and by judging whether there is a jump instruction in front of the return instruction or the forward unconditional jump instruction, whether the jump range reaches or exceeds the return instruction or the forward unconditional jump instruction, it is determined whether the instruction bytecode is the last bytecode of the basic block, so as to find the end of the bytecode of a basic block, correctly start the parsing of the next basic block, avoid the occurrence of subsequent parsing confusion, etc., and solve the problem of bytecode parsing confusion that is easy to occur when disassembling executable files.

[0098] It should be noted that the technical details that are not fully described in the embodiment of the bytecode end recognition device in the disassembly can be referred to the bytecode end recognition method in the disassembly as described above provided in any embodiment of the present invention, and will not be repeated here.

[0099] It should be understood that the above is only an example and does not constitute any limitation on the technical solution of the present invention. In specific applications, technicians in this field can make settings as needed, and the present invention does not limit this.

[0100] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.

[0101] In addition, it should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0102] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0103] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory (ROM) / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0104] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for identifying the end of bytecode in disassembly, It is characterized in that include: Obtaining an executable file and basic blocks in the executable file; Searching for instruction bytecodes and bytecode information of the basic block; When the instruction bytecode is a backward jump instruction, obtaining a jump address of the backward jump instruction; Determining whether the instruction bytecode is a return instruction or a forward unconditional jump instruction according to the bytecode information; If so, determine whether the instruction bytecode is the last instruction bytecode of the basic block according to the maximum value of the jump address.

2. The method according to claim 1, It is characterized in that The step of searching for the instruction bytecode and bytecode information of the basic block includes: Finding the starting address of the instruction bytecode of the basic block; Obtaining the first byte of the instruction bytecode based on the starting address; wherein the first byte is an operation code; The bytecode information of the instruction bytecode is searched according to the first byte.

3. The method according to claim 2, It is characterized in that The step of searching for the bytecode information of the instruction bytecode according to the first byte includes: Obtain an operation code table corresponding to the first byte; The bytecode information of the instruction bytecode is searched based on the operation code table.

4. The method according to claim 1, It is characterized in that The step of judging whether the instruction bytecode is the last instruction bytecode of the basic block according to the maximum value of the jump address includes: Find the maximum value of the jump address; Determining whether the maximum value of the jump address is less than or equal to the address of the instruction bytecode; If so, the instruction bytecode is the last instruction bytecode of the basic block.

5. The method according to claim 1, It is characterized in that The method further comprises: When the instruction bytecode is not a backward jump instruction, determining whether the instruction bytecode is a return instruction or a forward unconditional jump instruction according to the bytecode information; If not, return to search for the next instruction bytecode and bytecode information of the basic block until the last instruction bytecode of the basic block is found.

6. The method according to claim 5, It is characterized in that The returning to search for the next instruction bytecode and bytecode information of the basic block until the last instruction bytecode of the basic block is found includes: Determine the length of the instruction bytecode according to the bytecode information; Calculating the address of the next instruction bytecode of the basic block according to the length of the instruction bytecode; searching for the next instruction bytecode and bytecode information of the next instruction bytecode based on the address of the next instruction bytecode; When the next instruction bytecode is a backward jump instruction, the step of obtaining the jump address of the backward jump instruction is executed until the last instruction bytecode of the basic block is found.

7. The method according to any one of claims 1 to 6, It is characterized in that The bytecode information includes format, length and instruction type.

8. A device for identifying the end of bytecode in disassembly, It is characterized in that include: An acquisition module, used for acquiring an executable file and basic blocks in the executable file; A byte information search module, used to search for instruction bytecodes and bytecode information of the basic block; A backward jump determination module, used for obtaining the jump address of the backward jump instruction when the instruction bytecode is a backward jump instruction; A return jump judgment module, used for judging whether the instruction bytecode is a return instruction or a forward unconditional jump instruction according to the bytecode information; The end determination module is used to determine whether the instruction bytecode is the last instruction bytecode of the basic block according to the maximum value of the jump address.

9. An electronic device, It is characterized in that The electronic device comprises: a memory, a processor, and a disassembly bytecode end recognition program stored in the memory and executable on the processor, wherein the disassembly bytecode end recognition program is configured to implement the disassembly bytecode end recognition method as described in any one of claims 1 to 7.

10. A storage medium, It is characterized in that The storage medium stores a disassembly bytecode end recognition program, and the disassembly bytecode end recognition program is used to enable a processor to implement the disassembly bytecode end recognition method according to any one of claims 1 to 7 when executing the program.