Binary document modification method and system

By converting the result data produced by users into binary master files and formatted auxiliary files, the problem that binary files cannot be modified during multi-machine cooperative processing is solved, and the readability and modifiability of the file in a new environment is realized, and the collaborative processing process is simplified.

CN119917101APending Publication Date: 2025-05-02FOUNDER INT(WUHAN)TECH DEV CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411751730.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

In the prior art, the binary file cannot be modified when multiple machines collaboratively process, resulting in changes to the contents of the files when used in a new environment, and third parties cannot modify them, resulting in inconvenient cooperation processing.

Method used

By converting the result data obtained by user production and processing into binary main file and formatting auxiliary files, and storing and reading of auxiliary files is realized based on predefined access functions, so that the binary files can be read and modified when they are passed or copied to other environments.

Benefits of technology

It realizes the coordinated processing of binary files among multiple machines, taking into account the advantages of the small size, fast reading and writing speed and strong confidentiality of binary files. At the same time, it allows third-party management programs to access and modify files, simplifying the file modification and reading process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917101A_ABST
    Figure CN119917101A_ABST
Patent Text Reader

Abstract

The invention provides a binary document modification method and system.The method comprises the steps that when it is detected that a user stores a result file made by software, a serialization function is called to convert software memory structure data corresponding to the result file into binary data flow, and the binary data flow is stored in a main file; calling a first access function to search a predetermined data item in the memory structure data, and storing an identifier and an attribute value corresponding to the predetermined data item to an auxiliary file; when it is detected that the environmental parameters of the result file change, calling a second access function to open the auxiliary file, searching for data items and attribute values corresponding to the environmental parameters according to identifiers, and modifying the attribute values corresponding to the environmental parameters; and when detecting that the user opens the result file, respectively reading the main file and the auxiliary file. By means of the scheme, the binary file can be modified, and it can be guaranteed that the stored file is small in size, high in read-write speed and high in confidentiality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of software development, and in particular relates to a binary document modification method and system. Background Art

[0002] In the field of computer application software, especially stand-alone software or client software running in C / S architecture, private format files are usually used to save the content results of production and processing and the process information required for reprocessing. These private format files generally use two formats, one is based on formatted text, such as XML, Json, etc., and the other is a structured binary format.

[0003] Storage files defined based on formatted text can randomly access specific items, are easy to expand, can be viewed with the help of general tools such as XML and Jason, are easy to parse and modify, and can be easily accessed, edited and modified by third-party software, which is equivalent to an open format. However, the file size is usually large, and encoding and decoding are required to store binary data. The access code is relatively complex, and there is a big difference with the memory structure. The reading and storage speed is slow, and the confidentiality is poor.

[0004] The opposite is true for files stored in a structured binary format. Binary files are usually generated by software in a serialized manner. They are small in size, highly consistent with the data and memory structure, fast to read, and highly confidential. However, they are difficult to parse, and third-party software cannot access them unless they understand all the structural details. It is very difficult to modify and add data.

[0005] For stand-alone software or C / S architecture systems with file exchange requirements, there are often situations where multiple machines collaborate. Files saved after processing on one machine are often transferred to other machines to be opened again for further processing, or files are directly copied and used. The copied files need to change some of their contents according to the new application environment before they can be used in the new environment. Since third parties cannot know the details of the binary file structure, they cannot modify it. Even if they know all the details, imitating the exact same serialization structure will result in a large program and difficult debugging. It is generally considered to be unmodifiable by external programs, which makes collaborative processing of binary files very inconvenient.

[0006] Therefore, it is necessary to propose a binary file modification method so that the file content can be modified while ensuring the confidentiality of the file when multiple machines collaborate to process it. Summary of the invention

[0007] In view of this, an embodiment of the present invention provides a binary document modification method and system, which are used to solve the problem that binary files cannot be modified when multiple machines collaborate to process.

[0008] In a first aspect of an embodiment of the present invention, a binary document modification method is provided, comprising: When it is detected that the user saves the result file produced by the software, the serialization function is called to convert the software memory structure data corresponding to the result file into a binary data stream and store it in the main file; Calling the first access function to search for a predetermined data item in the memory structure data, and storing an identifier and an attribute value corresponding to the predetermined data item in an auxiliary file; Wherein, the auxiliary file is a storage file of formatted text definition.

[0009] When a change in the result file environment parameter is detected, the second access function is called to open the auxiliary file, the data item and attribute value corresponding to the environment parameter are searched according to the identifier, and the attribute value corresponding to the environment parameter is modified; When it is detected that the user opens the result file, the main file and the auxiliary file are read respectively.

[0010] In a second aspect of an embodiment of the present invention, a binary document modification system is provided, comprising: A data storage module, which is used to call a serialization function to convert the software memory structure data corresponding to the result file into a binary data stream and store it in a main file when it is detected that the user saves the result file produced by the software; and Calling the first access function to search for a predetermined data item in the memory structure data, and storing an identifier and an attribute value corresponding to the predetermined data item in an auxiliary file; Wherein, the auxiliary file is a storage file of formatted text definition.

[0011] A data modification module, for, when detecting that the environment parameter of the result file has changed, calling the second access function to open the auxiliary file, searching for the data item and attribute value corresponding to the environment parameter according to the identifier, and modifying the attribute value corresponding to the environment parameter; The data reading module is used to read the main file and the auxiliary file respectively when it is detected that the user opens the result file.

[0012] In a third aspect of an embodiment of the present invention, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect of the embodiment of the present invention when executing the computer program.

[0013] In a fourth aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method provided in the first aspect of the embodiment of the present invention are implemented.

[0014] In the embodiment of the present invention, the result data obtained by user processing is converted into a binary main file and a formatted auxiliary file, and the storage and reading of the auxiliary file are realized based on two predefined access functions, so that the binary file can be read and modified when it is transferred or copied to other working environments. It not only has the advantages of small file size, fast reading and writing speed, and strong confidentiality, but also can be accessed and modified by a third-party management program, which facilitates the collaborative processing of files among multiple machines. It takes into account the advantages of binary files and formatted text files, and is simple, easy, safe and reliable. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0016] Figure 1 A flowchart of a binary document modification method provided by an embodiment of the present invention; Figure 2 A schematic diagram of the structure of a system for modifying binary documents provided by one embodiment of the present invention; Figure 3 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0017] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described below 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.

[0018] It should be understood that the term "including" and other similar expressions in the specification or claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions, such as a process, method, system, or device including a series of steps or units is not limited to the listed steps or units. In addition, "first" and "second" are used to distinguish different objects, not to describe a specific order.

[0019] See also Figure 1 , a flowchart of a binary document modification method provided by an embodiment of the present invention includes: S101, when it is detected that the user saves the result file produced by the software, a serialization function is called to convert the software memory structure data corresponding to the result file into a binary data stream, and store it in a main file; The result file is a file generated when the user produces or processes it through application software, such as book, magazine, and newspaper layout files produced by the user through typesetting software, slide files produced by office software, and design drawings produced by CAD software. The result file is generally generated by the user's current application and exists in a fixed format in the internal cache space of the software, that is, the software memory structure data. When the user chooses to save, it is usually stored in the storage space outside the program body in the form of a binary file or formatted text.

[0020] The serialization function is used to convert a complex computer memory data structure into a linear byte stream or character stream while retaining the integrity of the data structure. The serialization function can write the data in the application software memory structure into the main file in byte order for long-term storage. The corresponding read function uses the deserialization method, and when reading, the file data stream is read strictly in the order of writing and directly filled into the memory structure.

[0021] S102, calling a first access function to search for a predetermined data item in the software memory structure data, and storing an identifier and an attribute value corresponding to the predetermined data item in an auxiliary file; The first access function can access the software memory structure data corresponding to the result file, and store the pre-set data items and their identifiers and attribute values ​​in the auxiliary file. The predetermined data items are generally related to the file running environment, such as the external objects referenced by the file (such as the storage path of the image), the external identifier of the object, and the file attributes, type and other data items. The predetermined data items are data items related to the result file environment parameters, that is, when the environment parameters change, the attribute values ​​in the predetermined data also need to change.

[0022] The identifier of the predetermined data item, the current attribute value, etc. are stored in the auxiliary file through the first access function. The content and format of the predetermined data item can be defined by the developer.

[0023] The auxiliary file is a storage file defined by formatted text. The auxiliary file can be in INI, XML, json or other file formats that are easy to view, edit and append.

[0024] It can be understood that the binary main file and the formatted auxiliary file constitute an external storage file pair, which is automatically generated by the software when the software saves the processed content externally. Generally speaking, there is no strict order restriction on the generation of the main file and the auxiliary file, but in order to facilitate the judgment of the validity of the auxiliary file, the auxiliary file can be generated first, and then the main file, so that the generation time of the main file is slightly later than that of the auxiliary file.

[0025] In this embodiment, the auxiliary file only stores a small amount of variable data items in the result file and supports random position reading and writing of data, which can make the modification of binary files simple and feasible, and has fast reading and writing speed and small data volume.

[0026] S103, when it is detected that the environment parameter of the result file has changed, calling the second access function to open the auxiliary file, searching for the data item and attribute value corresponding to the environment parameter according to the identifier, and modifying the attribute value corresponding to the environment parameter; Among them, the first access function is used to find the identifier and attribute value corresponding to the predetermined data item in the internal structure data and store them, and the second access function is used to find the corresponding data item and attribute value in the auxiliary file according to the identifier and assign the attribute value.

[0027] When the result file is copied or transferred to other environments, the environment parameters of the file will change. For example, when the result file is copied to another machine, the operating system, hard disk storage directory structure, application version, etc. of the machine will be different from the original application production environment, and the environment parameters of the file need to be modified.

[0028] The corresponding data item and attribute value in the auxiliary file are searched by the identifier through the second access function, and the attribute value of the data item is modified.

[0029] S104: When it is detected that the user has opened the result file, the main file and the auxiliary file are read respectively. Specifically, when it is detected that a user opens the result file, the deserialization function is called to read the binary data stream of the main file and fill it into the software memory structure, and the third access function is called to read the identifier and attribute value in the auxiliary file, and the data item and attribute value are searched according to the identifier, and the attribute value of the corresponding data item in the software memory structure is overwritten.

[0030] When the application needs to open the result file, it can read the main file and the auxiliary file from the outside respectively, and fill the binary data stream and data item attribute value information read from the outside into the program's memory structure.

[0031] It can be understood that the first access function and the third access function are called by the production software and are used for storing and reading the result file respectively, and the second access function can be called by the storage management software to find and modify the attribute value of the data item in the auxiliary file.

[0032] Optionally, before calling the third access function to read the identifier and the attribute value in the auxiliary file, the step further includes: Determine whether the auxiliary file exists. If so, obtain the last modification time of the auxiliary file. When the last modification time of the auxiliary file is earlier than the generation time of the main file, mark the auxiliary file as unreadable.

[0033] In this embodiment, when the application software stores files externally, it will generate a file group of a main file and an auxiliary file. Since the main file is a serialized binary file and there are only a few modifiable data items in the auxiliary file, it will basically not affect the speed of storing files and storage space. When the software opens the stored file again, it reads the binary main file and the auxiliary file respectively, and overwrites the attribute value of the corresponding data item in the memory structure according to the content in the auxiliary file. Since there are only a few modifiable data items in the auxiliary file, it will basically not affect the speed of reading files.

[0034] By combining binary format files with formatted text files, a binary format main file and a formatted text auxiliary file are generated to form a storage file pair, which fully utilizes the advantages of two file format accesses, can read and write at high speed, has a small file size, and can support external software to modify binary files. Only for a small number of variable data items, auxiliary formatted text access functions are written, which does not affect the original file storage speed, and allows external programs to modify variable data items. The actual use cost is low and easy to implement.

[0035] It should be understood that the serial numbers of the steps in the above embodiments do not imply a sequence of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0036] Figure 2 A schematic diagram of the structure of a system for modifying binary documents provided by an embodiment of the present invention, the system comprising: The data storage module 210 is used to call the serialization function to convert the software memory structure data corresponding to the result file into a binary data stream and store it in the main file when it is detected that the user saves the result file produced by the software; and Calling the first access function to search for a predetermined data item in the memory structure data, and storing an identifier and an attribute value corresponding to the predetermined data item in an auxiliary file; Wherein, the auxiliary file is a storage file of formatted text definition.

[0037] The data modification module 220 is used to call the second access function to open the auxiliary file when it detects that the environment parameter of the result file has changed, find the data item and attribute value corresponding to the environment parameter according to the identifier, and modify the attribute value corresponding to the environment parameter; The data reading module 230 is used to read the main file and the auxiliary file respectively when it is detected that the user opens the result file.

[0038] Specifically, when it is detected that a user opens the result file, the deserialization function is called to read the binary data stream of the main file and fill it into the software memory structure, and the third access function is called to read the identifier and attribute value in the auxiliary file, and the data item and attribute value are searched according to the identifier, and the attribute value of the corresponding data item in the software memory structure is overwritten.

[0039] Wherein, before calling the third access function to read the identifier and the attribute value in the auxiliary file, the method further includes: Determine whether the auxiliary file exists. If so, obtain the last modification time of the auxiliary file. When the auxiliary file's last modification time is earlier than the generation time of the main file, the auxiliary file is marked as unreadable.

[0040] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the above-described system and module can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0041] Figure 3 1 is a schematic diagram of a structure of an electronic device provided by an embodiment of the present invention. The electronic device is used to implement binary document modification. Figure 3 As shown, the electronic device 3 of this embodiment includes: a memory 310, a processor 320 and a system bus 330, and the memory 310 includes an executable program 3101 stored thereon. Those skilled in the art can understand that Figure 3 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0042] Combine the following Figure 3 A detailed introduction to the various components of electronic equipment: The memory 310 can be used to store software programs and modules. The processor 320 executes various functional applications and data processing of the electronic device by running the software programs and modules stored in the memory 310. The memory 310 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the electronic device (such as cache data), etc. In addition, the memory 310 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0043] The memory 310 includes an executable program 3101 of a data set conversion method, and the executable program 3101 can be divided into one or more modules / units, which are stored in the memory 310 and executed by the processor 320 to perform binary document storage, modification, etc. The one or more modules / units can be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the executable program 3101 in the electronic device 3. For example, the executable program 3101 can be divided into functional modules such as a data storage module, a data modification module, and a data reading module.

[0044] The processor 320 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 310, and calling data stored in the memory 310, it performs various functions of the electronic device and processes data, thereby monitoring the overall status of the electronic device. Optionally, the processor 320 may include one or more processing units; preferably, the processor 320 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 320.

[0045] The system bus 330 is used to connect the various functional components inside the computer, and can transmit data information, address information, and control information. Its types can be, for example, PCI bus, ISA bus, CAN bus, etc. The instructions of the processor 320 are transmitted to the memory 310 through the bus, and the memory 310 feeds back data to the processor 320. The system bus 330 is responsible for the data and instruction exchange between the processor 320 and the memory 310. Of course, the system bus 330 can also be connected to other devices, such as network interfaces, display devices, etc.

[0046] In the embodiment of the present invention, the executable program executed by the processor 320 included in the electronic device includes: When it is detected that the user saves the result file produced by the software, the serialization function is called to convert the software memory structure data corresponding to the result file into a binary data stream and store it in the main file; Calling the first access function to search for a predetermined data item in the memory structure data, and storing an identifier and an attribute value corresponding to the predetermined data item in an auxiliary file; Wherein, the auxiliary file is a storage file of formatted text definition.

[0047] When a change in the result file environment parameter is detected, the second access function is called to open the auxiliary file, the data item and attribute value corresponding to the environment parameter are searched according to the identifier, and the attribute value corresponding to the environment parameter is modified; When it is detected that the user opens the result file, the main file and the auxiliary file are read respectively.

[0048] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and modules described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0049] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0050] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A binary document modification method, characterized in that: include: When it is detected that the user saves the result file produced by the software, the serialization function is called to convert the software memory structure data corresponding to the result file into a binary data stream and store it in the main file; Calling the first access function to search for a predetermined data item in the memory structure data, and storing an identifier and an attribute value corresponding to the predetermined data item in an auxiliary file; Wherein, the auxiliary file is a storage file of formatted text definition. When a change in the result file environment parameter is detected, the second access function is called to open the auxiliary file, the data item and attribute value corresponding to the environment parameter are searched according to the identifier, and the attribute value corresponding to the environment parameter is modified; When it is detected that the user opens the result file, the main file and the auxiliary file are read respectively.

2. The method according to claim 1, characterized in that When it is detected that a user opens the result file, reading the main file and the auxiliary file respectively comprises: When it is detected that the user opens the result file, the deserialization function is called to read the binary data stream of the main file and fill it into the software memory structure, and the third access function is called to read the identifier and attribute value in the auxiliary file, and the data item and attribute value are searched according to the identifier, and the attribute value of the corresponding data item in the software memory structure is overwritten.

3. The method according to claim 2, characterized in that Before calling the third access function to read the identifier and attribute value in the auxiliary file, the following steps are also included: Determine whether the auxiliary file exists. If so, obtain the last modification time of the auxiliary file. When the auxiliary file's last modification time is earlier than the generation time of the main file, the auxiliary file is marked as unreadable.

4. A system for binary document modification, characterized in that: include: The data storage module is used to call the serialization function to convert the software memory structure data corresponding to the result file into a binary data stream and store it in the main file when it is detected that the user saves the result file produced by the software; as well as Calling the first access function to search for a predetermined data item in the memory structure data, and storing an identifier and an attribute value corresponding to the predetermined data item in an auxiliary file; Wherein, the auxiliary file is a storage file of formatted text definition. A data modification module, for, when detecting that the environment parameter of the result file has changed, calling the second access function to open the auxiliary file, searching for the data item and attribute value corresponding to the environment parameter according to the identifier, and modifying the attribute value corresponding to the environment parameter; The data reading module is used to read the main file and the auxiliary file respectively when it is detected that the user opens the result file.

5. The system according to claim 4, characterized in that When it is detected that a user opens the result file, reading the main file and the auxiliary file respectively comprises: When it is detected that the user opens the result file, the deserialization function is called to read the binary data stream of the main file and fill it into the software memory structure, and the third access function is called to read the identifier and attribute value in the auxiliary file, and the data item and attribute value are searched according to the identifier, and the attribute value of the corresponding data item in the software memory structure is overwritten.

6. The system according to claim 5, characterized in that Before calling the third access function to read the identifier and attribute value in the auxiliary file, the following steps are also included: Determine whether the auxiliary file exists. If so, obtain the last modification time of the auxiliary file. When the auxiliary file's last modification time is earlier than the generation time of the main file, the auxiliary file is marked as unreadable.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of a binary document modification method as described in any one of claims 1 to 3 are implemented.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed, the steps of a binary document modification method as claimed in any one of claims 1 to 3 are implemented.