CN107423084B - Program modification method and device - Google Patents

Program modification method and device Download PDF

Info

Publication number
CN107423084B
CN107423084B CN201710269568.7A CN201710269568A CN107423084B CN 107423084 B CN107423084 B CN 107423084B CN 201710269568 A CN201710269568 A CN 201710269568A CN 107423084 B CN107423084 B CN 107423084B
Authority
CN
China
Prior art keywords
target
pointer
program
expression form
target pointer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710269568.7A
Other languages
Chinese (zh)
Other versions
CN107423084A (en
Inventor
周志刚
陈少杰
张文明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201710269568.7A priority Critical patent/CN107423084B/en
Publication of CN107423084A publication Critical patent/CN107423084A/en
Application granted granted Critical
Publication of CN107423084B publication Critical patent/CN107423084B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/654Updates using techniques specially adapted for alterable solid state memories, e.g. for EEPROM or flash memories

Landscapes

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

Abstract

The invention provides a program modification method and a device, wherein the method comprises the following steps: executing a preset program modification script to obtain a target program file; searching a target pointer defined as a first expression form of preset digits in the target program file through a regular expression in the program modification script, wherein the preset digits are smaller than the actual digits of the target pointer, which are endowed by a target operating system when the target program is executed by the target operating system; and replacing the expression form of the target pointer with a second expression form supporting a target operating system. Therefore, the automatic modification of the target program file is realized, the program modification efficiency is improved, and the error rate of the program modification is reduced.

Description

Program modification method and device
Technical Field
The invention relates to the technical field of data processing, in particular to a program modification method and device.
Background
With the development of electronic terminal hardware technology, the capability of CPU processors is becoming stronger, and CPUs with higher bit numbers are being more applied to electronic devices. However, for some applications developed based on lower bit (e.g., 32-bit) systems, the code therein is solidified to consider storing a memory address as a lower bit (e.g., 32 bits), and when allocating memory address space, the allocated memory address is also lower bit (e.g., 32 bits). When these programs are running in a higher-order (e.g., 64-bit) system, the system will allocate a higher-order (e.g., 64-bit) memory address, and the program will generate an error, which results in data interception, such that the higher-order data is lost, and thus a memory access exception is generated. At this time, data in the program file needs to be modified, for the program file with a large number of program codes and a large magnitude, if all the memory access codes in the codes are modified manually, time and labor are consumed, and manual modification is easy to make mistakes and generate modification errors, which affects the normal operation of the program.
Disclosure of Invention
In order to overcome the above-mentioned deficiencies in the prior art, the present invention aims to provide a program modification method, comprising:
executing a preset program modification script to obtain a target program file;
searching a target pointer defined as a first expression form of preset digits in the target program file through a regular expression in the program modification script, wherein the preset digits are smaller than the actual digits of the target pointer, which are endowed by a target operating system when the target program is executed by the target operating system;
and replacing the expression form of the target pointer with a second expression form supporting a target operating system.
Further, in the above method, the step of finding a target pointer in the target program file, which is defined as a first expression form with a preset number of bits, through a regular expression in the program modification script includes:
traversing each line of code in the target program file;
and aiming at each line code in the target program, searching a target pointer of a first expression form defined as a preset digit in the line code through the regular expression.
Further, in the above method, the step of finding a target pointer in the target program file, which is defined as a first expression form with a preset number of bits, through a regular expression in the program modification script includes:
executing a while function in the program modification script, and circularly executing a getline function in the while function to acquire each line of codes in the target program file;
and searching a target pointer defined as a preset digit number through the regular expression aiming at each row of acquired codes.
Further, in the above method, the step of replacing the expression form of the target pointer with a second expression form supporting a target operating system includes:
taking the data in the target pointer which is higher than the preset digit as high-order data, and taking the data in the target pointer within the preset digit as low-order data;
and replacing the expression form of the target pointer with a second expression form formed by splicing the high-order data and the low-order data.
Further, in the method, the replacing the expression form of the target pointer with a second expression form formed by splicing the high-order data and the low-order data includes:
and replacing the expression form of the target pointer with a second expression form formed by the high-order data and the low-order data.
Further, in the above method, the preset number of bits is 32 bits, and the target operating system is a 64-bit operating system; the step of replacing the expression form of the target pointer with a second expression form supporting a target operating system includes:
taking the AND of the data in the target pointer and 0xFFFFFFFF0000000 to obtain the data with high 32 bits in the target pointer;
replacing the representation in the target pointer with a second representation of the sum of the upper 32-bit data of the target pointer and the lower 32-bit data read from the target pointer.
Further, in the above method, the program modification script defines a macro, and the macro is used to extract data in the target pointer, where the data is higher than the preset number of bits; the step of replacing the expression form of the target pointer with a second expression form formed by splicing the high-order data and the low-order data comprises the following steps:
replacing the representation in the target pointer with a second representation of the sum of the macro and the lower data.
Further, in the above method, the method further comprises:
generating modified codes obtained by processing each line in the target program file, and storing the modified codes into a temporary document;
and after the processing of the target program file is finished, generating a new program file according to the temporary document.
Another object of the present invention is to provide a program modification apparatus, comprising:
the acquisition module is used for executing a preset program modification script and acquiring a target program file;
the searching module is used for searching a target pointer which is defined as a first expression form of a preset digit in the target program file through a regular expression in the program modification script, wherein the preset digit is smaller than the actual digit which is assigned to the target pointer by a target operating system when the target program is executed by the target operating system;
and the modification module is used for replacing the expression form of the target pointer with a second expression form supporting the target operating system.
Further, in the above apparatus, the manner of modifying the expression form of the target pointer by the modification module includes:
taking the data in the target pointer which is higher than the preset digit as high-order data, and taking the data in the target pointer within the preset digit as low-order data;
and replacing the expression form of the target pointer with a second expression form formed by splicing the high-order data and the low-order data. Compared with the prior art, the invention has the following beneficial effects:
according to the program modification method and device provided by the invention, by operating the program modification script, the target pointer of the first expression form defined as the preset digit in the target program file summary is searched according to the regular expression in the program modification script, and the expression form of the target pointer is replaced by the second expression form of the operating system supporting the second digit, so that the modified target program file can normally operate in the operating system with higher digit. Therefore, the automatic modification of the target program file is realized, the program modification efficiency is improved, and the error rate of the program modification is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic diagram of an electronic terminal according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating steps of a program modification method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a program modification apparatus according to an embodiment of the present invention;
fig. 4 is a second schematic diagram of a program modification apparatus according to an embodiment of the present invention.
Icon: 100-an electronic terminal; 110-program modifying means; 111-an acquisition module; 112-a lookup module; 113-a modification module; 114-a temporary storage module; 115-a generating module; 120-a memory; 130-a processor.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings or the orientations or positional relationships that the products of the present invention are conventionally placed in use, and are only used for convenience in describing the present invention and simplifying the description, but do not indicate or imply that the devices or elements referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," "third," and the like are used solely to distinguish one from another and are not to be construed as indicating or implying relative importance.
Furthermore, the terms "horizontal", "vertical", "overhang" and the like do not imply that the components are required to be absolutely horizontal or overhang, but may be slightly inclined. For example, "horizontal" merely means that the direction is more horizontal than "vertical" and does not mean that the structure must be perfectly horizontal, but may be slightly inclined.
In the description of the present invention, it should also be noted that, unless otherwise explicitly specified or limited, the terms "disposed," "mounted," "connected," and "connected" are to be construed broadly and may, for example, be fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
Referring to fig. 1, fig. 1 is a diagram of an electronic terminal 100 according to a preferred embodiment of the present invention, where the electronic terminal 100 includes a program modification apparatus 110, a memory 120, and a processor 130.
The memory 120 and the processor 130 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines. The program modification device 110 includes at least one software function module which can be stored in the memory 120 in the form of software or firmware (firmware) or solidified in an Operating System (OS) of the electronic terminal 100. The processor 130 is used for executing executable modules stored in the memory 120, such as software functional modules and computer programs included in the program modification apparatus 110.
The Memory 120 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like. The memory 120 is used for storing a program, and the processor 130 executes the program after receiving the execution instruction.
The processor 130 may be an integrated circuit chip having signal processing capabilities. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP)), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Referring to fig. 2, fig. 2 is a flowchart illustrating an application information obtaining method applied to the electronic terminal 100 shown in fig. 1, and the method including various steps will be described in detail below.
Step S110, a preset program modification script is executed, and a target program file is obtained.
The electronic terminal 100 runs the program modification script, and reads a target program file specified in the program modification script into the memory. The target program file is a program file that uses a lower-bit system as a standard, and in this embodiment, the target program file may be a program file that uses a 32-bit system as a standard.
For example, the program modification script may include the following instructions.
ifstreamfFile(filName,ifstream::in|ifstream::binary)
The ifstream instruction is used for reading a file from the memory 120 into the memory, the parameter filename indicates the name of the file, and the parameter ifstream in | ifstream in binary indicates the file reading.
Step S120, searching a target pointer defined as a first expression form with a preset number of bits in the target program file through a regular expression in the program modification script, where the preset number of bits is smaller than an actual number of bits that the target operating system assigns to the target pointer when the target program is executed by the target operating system.
And step S130, replacing the expression form of the target pointer with a second expression form supporting the target operating system.
The inventor researches and discovers that the target program file is a program file developed by taking a lower-bit system as a standard, and the target program file causes data interception when a target operating system with higher bit runs, so that data with higher bits is lost.
In this embodiment, it is assumed that the predetermined number of bits is 32 bits and the target os is 64 bits. The target program file comprises the following codes:
*(int*)(ptr+72)=(int)(ptr+100);
wherein ptr +72 is a memory pointer and ptr +100 is a secondary pointer, i.e., the secondary pointer is the target pointer.
Since under a 64-bit target operating system, the size of ptr is 64 bits, the size of ptr +100 is also 64 bits.
But the contents stored at the offset of the memory pointer ptr +72 are the lower 32 bits of the secondary pointer ptr +100, and the upper bits of the secondary pointer are discarded by truncation.
For example, assuming that the ptr content of the pointer is 9 bits in total, 0x123456789, which is a 64-bit address, the content stored at ptr +72 would be 0x23456789, with the top 1 being discarded. This discarding is not problematic on the data store, which can occur when it makes further access to the secondary pointer because the secondary pointer is not bit-aligned.
The inventor finds that if the target program file needs to be guaranteed to normally run in a target operating system with a higher bit number, the expression form of the secondary pointer is changed, and the expression form of the target pointer is replaced by a second expression form formed by splicing the higher bit data and the lower bit data. Specifically, the expression form of the target pointer may be replaced with a second expression form in which the upper data and the lower data are the same or different.
For example, for the following code
Int data=*(uint32*)(*(uint32*)(ptr64+72)+5);
In the above code, a 32-bit data is read for the position of offset 5 of the secondary pointer ptr64+ 72. The agent 32 (ptr64+72) is the target pointer, and since the data stored at ptr64+72 is a 32-bit pointer instead of a 64-bit pointer, a memory access error occurs when the memory is directly accessed. The secondary pointer ptr64+72 needs to be spliced to fill the high bits. The padding is done by taking the high order bits from the ptr64 pointer and logically or them into the secondary pointer. The concrete implementation is as follows:
conversion to (int) (ptr64+72)
(ptr64&0xFFFFFFFF00000000)|(*(int*)(ptr64+72))
Here, ptr64&0xFFFFFFFF00000000 indicates that the upper 32-bit data is extracted from ptr64 as the upper data, and the data read from prt65+72 is the lower data. The 2 data are concatenated by a logical or operation. So that the secondary pointer becomes a 64-bit pointer to allow proper access to 64-bit memory.
Therefore, in this embodiment, the inventor designs to search for a target pointer defined as a lower preset number of bits in the target program file through a section of regular expression, and modifies an expression form of the target pointer.
Specifically, according to the rule written in the code, the target pointer defined as the preset number of bits in the target program file has a corresponding definition identification field, for example, the target pointer defined as 32 is in the form of ([ u ] unt 32 ] (ptr64+40) + 20).
In the present embodiment, the sought regular expression is written in the form of
(\*\([uint32|uint8|uint16]+\s\*\)\()(.*\));
Wherein (\\ \ ([ uint32| uint8| uint16] + \\ \ s \) indicates the fields of the matching code, namely \ (uint8 \), (' uint16 \ and \ (uint32 \).
An alternative regular expression is as follows: $1HA (ptr64) | $ 2;
where, replacing $1 denotes the expression in the first bracket and $2 denotes the expression in the second bracket. The HA is a macro written in advance, and is configured to extract data in the target pointer, where the data is higher than the preset number of bits, and the specific content may be defined as follows:
HA(ptr64)(ptr64&0xFFFFFFFF00000000)
the electronic terminal 100 replaces the expression form in the target pointer with a second expression form composed of the macro and the low-level data.
The expression form of the target pointer can be replaced by the expression form supported by the target operating system through the above replacement, for example, the program is assumed to have the following codes:
uint8data1=*(uint8*)(*(uint32*)(ptr64+40)-24);
uint16data2=*(uint16*)(*(uint32*)(ptr64+40)+10);
uint16data3=*(uint32*)(*(uint32*)(ptr64+40)+20)。
the corresponding replaced correct code is as follows:
uint8data1=*(uint8*)(((HA(ptr64)|*(uint32*)(ptr64+40))-24);
uint16data2=*(uint16*)(((HA(ptr64)|*(uint32*)(ptr64+40))+10);
uint16data3=*(uint32*)(((HA(ptr64)|*(uint32*)(ptr64+40))+20)。
based on the above design, in this embodiment, the electronic terminal 100 executes the program modification script to traverse each line of code in the target program file. And aiming at each line code in the target program, searching a target pointer of a first expression form defined as a preset digit in the line code through the regular expression.
Specifically, a while function in the program modification script is executed, and a getline function is circularly executed in the while function to acquire each line of codes in the target program file.
For example, the program modification script may include the following instructions:
while(getline(fFile,strLine))
wherein while represents the cycle execution, the getline instruction identifies the acquisition line, the parameter filename identifies the name of the file, and the strLine identifies the character string in the line.
The electronic terminal 100 searches, for each line code in the target program, a target pointer of a first expression form defined as a preset number of bits in the line code through the regular expression
For example, the program modification script in the loop of the while instruction may include the following instructions:
{
regex reg (streg); // define a regular expression written according to the previous design.
string ═ regex _ replace (string, reg, replace); and then calls the regular expression interface regex place to replace each line of code. The parameter strLine indicates a line of content of the read file, the parameter reg indicates a regular expression, and the place indicates a replaced regular expression.
}
Specifically, in the code, the reg parameter represents the search content of the regular expression written by the aforementioned design. The place parameter represents the replacement content in the regular expression written as described above.
Based on the above design, in this embodiment, the program modification script may automatically search for a target pointer to be modified in the target program file, and modify the target pointer through the regular expression.
Further, in this embodiment, after modifying each line of codes, the electronic terminal 100 generates modified codes processed for each line in the target program file, and stores the modified codes in a temporary document.
For example, the following instructions may be included in the while loop of the program modification script described above:
push _ back (strine); and/then save the replaced content to an object vecNewFile.
And after the processing of the target program file is finished, generating a new program file according to the temporary document.
For example, the following instructions may be included after the while loop of the program modification script described above:
ofastemmobjnewfile (filnamesave); defining a file object for generating a new file, wherein the parameter fileNamesave is the name of the new file.
for (vector < string >: operator itrNew ═ vecNewFile. begin (); itrNew ═ vecNewFile. end (), +++ itrNew)// then use for loop to traverse each line of file content stored in vecNewFile, writing it into the file.
{
objNewFile<<(*itrNew)<<endl;
}
Close (); // close file.
Based on the design, the whole object program file is modified by running the program modification script, and the object program file can be supported to run in a higher object operating system.
Referring to fig. 3, the present embodiment further provides a program modification apparatus 110 applied to the electronic terminal 100 shown in fig. 1, which includes an obtaining module 111, a searching module 112, and a modification module 113.
The obtaining module 111 is configured to execute a preset program modification script and obtain an object program file.
In this embodiment, the obtaining module 111 may be configured to execute step S110 shown in fig. 2, and reference may be made to the description of step S110 for a detailed description of the obtaining module 111.
The searching module 112 is configured to search, through the regular expression in the program modification script, a target pointer in a first expression form defined as a preset number of bits in the target program file, where the preset number of bits is smaller than an actual number of bits that the target operating system assigns to the target pointer when the target program is executed by the target operating system.
In this embodiment, the search module 112 may be configured to execute the step S120 shown in fig. 2, and reference may be made to the description of the step S120 for a detailed description of the search module 112.
The modification module 113 is configured to replace the expression form of the target pointer with a second expression form supporting the target operating system.
In this embodiment, the modification module 113 may be configured to execute the step S130 shown in fig. 2, and reference may be made to the description of the step S130 for a detailed description of the modification module 113.
Further, in this embodiment, the manner of modifying the expression form of the target pointer by the modification module 113 includes:
taking the data in the target pointer which is higher than the preset digit as high-order data, and taking the data in the target pointer within the preset digit as low-order data;
and replacing the expression form of the target pointer with a second expression form formed by splicing the high-order data and the low-order data.
Further, referring to fig. 4, in the present embodiment, the apparatus further includes a temporary storage module 114 and a generation module 115.
The temporary storage module 114 is configured to generate a modified code obtained by processing each line in the target program file, and store the modified code in a temporary document.
The generating module 115 is configured to generate a new program file according to the temporary document after the processing of the target program file is completed.
In summary, according to the program modification method and apparatus provided by the present invention, by running the program modification script, the target program file is searched according to the regular expression in the program modification script, and the target pointer defined as the first expression form with the preset digit is summarized, and the expression form of the target pointer is replaced by the second expression form of the operating system supporting the second digit, so that the modified target program file can normally run in the operating system with a higher digit. Therefore, the automatic modification of the target program file is realized, the program modification efficiency is improved, and the error rate of the program modification is reduced.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (8)

1. A program modification method, the method comprising:
executing a preset program modification script to obtain a target program file;
searching a target pointer defined as a first expression form of preset digits in the target program file through a regular expression in the program modification script, wherein the preset digits are smaller than the actual digits of the target pointer, which are endowed by a target operating system when the target program is executed by the target operating system;
replacing the expression form of the target pointer with a second expression form supporting a target operating system;
wherein the step of replacing the expression form of the target pointer with a second expression form supporting a target operating system comprises:
taking the data in the target pointer which is higher than the preset digit as high-order data, and taking the data in the target pointer within the preset digit as low-order data;
and replacing the expression form of the target pointer with a second expression form formed by splicing the high-order data and the low-order data.
2. The method of claim 1, wherein the step of finding a target pointer in the target program file defined as a first expression with a preset number of bits by a regular expression in the program modification script comprises:
traversing each line of code in the target program file;
and aiming at each line code in the target program, searching a target pointer of a first expression form defined as a preset digit in the line code through the regular expression.
3. The method of claim 1, wherein the step of finding a target pointer in the target program file defined as a first expression with a preset number of bits by a regular expression in the program modification script comprises:
executing a while function in the program modification script, and circularly executing a getline function in the while function to acquire each line of codes in the target program file;
and searching a target pointer defined as a preset digit number through the regular expression aiming at each row of acquired codes.
4. The method of claim 1, wherein the step of replacing the representation of the target pointer with a second representation formed by concatenating the high-order data and the low-order data comprises:
and replacing the expression form of the target pointer with a second expression form formed by the high-order data and the low-order data.
5. The method of claim 4, wherein the predetermined number of bits is 32 bits, and the target operating system is a 64-bit operating system; the step of replacing the expression form of the target pointer with a second expression form supporting a target operating system includes:
taking the AND of the data in the target pointer and 0xFFFFFFFF0000000 to obtain the data with high 32 bits in the target pointer;
replacing the representation in the target pointer with a second representation of the sum of the upper 32-bit data of the target pointer and the lower 32-bit data read from the target pointer.
6. The method according to claim 1 or 4, wherein the program modification script defines a macro for extracting data of the target pointer above the preset number of bits; the step of replacing the expression form of the target pointer with a second expression form formed by splicing the high-order data and the low-order data comprises the following steps:
replacing the representation in the target pointer with a second representation of the sum of the macro and the lower data.
7. The method of claim 1, further comprising:
generating modified codes obtained by processing each line in the target program file, and storing the modified codes into a temporary document;
and after the processing of the target program file is finished, generating a new program file according to the temporary document.
8. A program modification apparatus, characterized in that the apparatus comprises:
the acquisition module is used for executing a preset program modification script and acquiring a target program file;
the searching module is used for searching a target pointer which is defined as a first expression form of a preset digit in the target program file through a regular expression in the program modification script, wherein the preset digit is smaller than the actual digit which is assigned to the target pointer by a target operating system when the target program is executed by the target operating system;
the modification module is used for replacing the expression form of the target pointer with a second expression form supporting a target operating system;
the method for modifying the expression form of the target pointer by the modification module comprises the following steps:
taking the data in the target pointer which is higher than the preset digit as high-order data, and taking the data in the target pointer within the preset digit as low-order data;
and replacing the expression form of the target pointer with a second expression form formed by splicing the high-order data and the low-order data.
CN201710269568.7A 2017-04-24 2017-04-24 Program modification method and device Active CN107423084B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710269568.7A CN107423084B (en) 2017-04-24 2017-04-24 Program modification method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710269568.7A CN107423084B (en) 2017-04-24 2017-04-24 Program modification method and device

Publications (2)

Publication Number Publication Date
CN107423084A CN107423084A (en) 2017-12-01
CN107423084B true CN107423084B (en) 2021-02-02

Family

ID=60424086

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710269568.7A Active CN107423084B (en) 2017-04-24 2017-04-24 Program modification method and device

Country Status (1)

Country Link
CN (1) CN107423084B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1892591A (en) * 2001-10-23 2007-01-10 微软公司 Data alignment between native and non-native shared data structures
WO2009097162A1 (en) * 2008-02-01 2009-08-06 The Oliver Group A method for searching and indexing data and a system for implementing same
CN101645017A (en) * 2009-09-07 2010-02-10 深圳市茁壮网络股份有限公司 Cross-platform byte order processing method, device and byte code running platform
CN102301342A (en) * 2009-07-29 2011-12-28 华为技术有限公司 Regular Expression Matching Method And System, And Searching Device
CN102929596A (en) * 2012-09-21 2013-02-13 华为技术有限公司 Code checking method and device

Family Cites Families (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5678039A (en) * 1994-09-30 1997-10-14 Borland International, Inc. System and methods for translating software into localized versions
US6662361B1 (en) * 2000-01-14 2003-12-09 International Business Machines Corporation Method, system, program, and data structures for transforming an instruction in a first bit architecture to an instruction in a second bit architecture
US7406681B1 (en) * 2000-10-12 2008-07-29 Sun Microsystems, Inc. Automatic conversion of source code from 32-bit to 64-bit
CN101360088B (en) * 2007-07-30 2011-09-14 华为技术有限公司 Regular expression compiling, matching system and compiling, matching method
CN101841430A (en) * 2010-05-05 2010-09-22 北京星网锐捷网络技术有限公司 Method and device for correcting command line
US9411855B2 (en) * 2010-10-25 2016-08-09 Salesforce.Com, Inc. Triggering actions in an information feed system
JP5921292B2 (en) * 2012-04-03 2016-05-24 キヤノン株式会社 Information processing apparatus, control method, and program
CN103514189A (en) * 2012-06-25 2014-01-15 上海博腾信息科技有限公司 Implementing method for web crawler based on search engines
US10120663B2 (en) * 2014-03-28 2018-11-06 Intel Corporation Inter-architecture compatability module to allow code module of one architecture to use library module of another architecture
US9286057B2 (en) * 2014-06-11 2016-03-15 International Business Machines Corporation Updating software based on utilized functions
CN104462268B (en) * 2014-11-24 2017-12-12 深圳市比一比网络科技有限公司 A kind of method and system of html document information extraction expression formula
CN105354269B (en) * 2015-10-27 2019-07-12 中通服公众信息产业股份有限公司 Web applicational language Localization methodologies and system based on reverse proxy and information filtering
CN106021497B (en) * 2016-05-23 2021-06-08 中国银联股份有限公司 Database access password management method
CN106201502B (en) * 2016-07-06 2019-12-06 中国银联股份有限公司 Cross-host application program deployment method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1892591A (en) * 2001-10-23 2007-01-10 微软公司 Data alignment between native and non-native shared data structures
WO2009097162A1 (en) * 2008-02-01 2009-08-06 The Oliver Group A method for searching and indexing data and a system for implementing same
CN102301342A (en) * 2009-07-29 2011-12-28 华为技术有限公司 Regular Expression Matching Method And System, And Searching Device
CN101645017A (en) * 2009-09-07 2010-02-10 深圳市茁壮网络股份有限公司 Cross-platform byte order processing method, device and byte code running platform
CN102929596A (en) * 2012-09-21 2013-02-13 华为技术有限公司 Code checking method and device

Also Published As

Publication number Publication date
CN107423084A (en) 2017-12-01

Similar Documents

Publication Publication Date Title
EP3433732B1 (en) Converting visual diagrams into code
EP3353672B1 (en) Method and apparatus for transferring data between databases
WO2019095968A1 (en) Dynamic loading method, and target file producing method and apparatus
US10599413B2 (en) Method and device for identifying file
CN106897072B (en) Service engineering calling method and device and electronic equipment
CN106843842B (en) Method and device for updating application program configuration file
CN107783786B (en) Method and device for creating equipment resources
CN106648569B (en) Target serialization realization method and device
WO2018040270A1 (en) Method and device for loading linux-system elf file in windows system
US11392765B2 (en) Interpreting HL7 segment hierarchy dynamically
WO2013152729A1 (en) Method and apparatus for providing software for terminal device
CN109062906B (en) Translation method and device for program language resources
US20120159515A1 (en) Sharing object representations
CN110058904B (en) Data transfer method and device and server
US20210191859A1 (en) Integrated reference and secondary marking
CN107423084B (en) Program modification method and device
CN109408176A (en) Application resource file compiles method, apparatus, equipment and the storage medium of packet
CN106681782B (en) Method and device for compiling dynamic link library SO file of android installation package
CN114816772B (en) Debugging method, debugging system and computing device for application running based on compatible layer
CN111488144A (en) Data processing method and equipment
CN107943923B (en) Telegram code database construction method, telegram code identification method and device
CN113760237A (en) Compiling address updating method and device, terminal equipment and readable storage medium
CN111273940B (en) Method and device for uploading program file to code warehouse
CN114218261A (en) Data query method and device, storage medium and electronic equipment
CN109739876B (en) Data query method and device for database based on Sqltoy-orm framework

Legal Events

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