A same-process data transmission method and system, an electronic device, and a storage medium
By defining export and copy interfaces within the same process, and calculating the weights and transmission paths between modules, data is encrypted for storage and decrypted for transmission, thus solving the problem of insufficient security in data transmission within the same process and achieving covert and secure data transmission.
Patent Information
- Application Number
- CN202011086286.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-12
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2040-10-12
AI Technical Summary
Existing technologies lack security when transmitting data in the same process, making it easy for hackers or viruses to obtain encrypted and network-transmitted data by accessing the module's interface.
In each module within the same process, an export interface and a copy interface are defined. The function code of the copy interface is to copy the export interface. The weight between modules is calculated and the transmission path is determined. The previous module encrypts the data and stores it in the copy interface of the next module. The next module decrypts and transmits the data.
It enables covert and secure data transmission within the same process, improving the security and covertness of data transmission and preventing data from being illegally obtained.
Smart Images

Figure CN114356590B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data transmission, and more particularly to a method, system, electronic device, and storage medium for data transmission in the same process. Background Technology
[0002] Modern software development typically uses a component-based approach, where different functions are broken down into independent modules, such as network modules and data encryption / decryption modules.
[0003] Current solutions typically involve calling the network module's interface to transmit data, which then forwards the data. This approach is unsuitable for applications where security is paramount.
[0004] Hackers or viruses can easily obtain all the data that needs to be encrypted and all the data that needs to be sent over the network by accessing the module's interface. Summary of the Invention
[0005] This application provides a method, system, electronic device, and storage medium for data transmission in the same process, used for covert and secure transmission of data in the same process.
[0006] The first aspect of this application provides a method for data transmission within a single process, wherein the single process includes multiple modules, comprising: defining an export interface and a copy interface in each module of the single process, wherein the function code of the copy interface is copied from the function code of the export interface, and the function code of the export interface and the function code of the copy interface are stored in different files; calculating the weight of data transmission between every two modules and determining the transmission path of the data to be transmitted; for two adjacent modules on the transmission path, the previous module encrypts the data to be transmitted and stores the encrypted data in the function code of the copy interface of the next module; the next module obtains the function code of its own export interface, finds the same function code in the copy interface, extracts the encrypted data to be transmitted from it, decrypts it, and transmits the decrypted data to be transmitted to the next module.
[0007] In one possible embodiment, calculating the weight of the data transmitted between every two modules and determining the transmission path of the data to be transmitted includes:
[0008] Calculate the first weight of each module based on the starting address of each module in memory, and calculate the second weight of each module based on the amount of data each module can transmit and the amount of data to be transmitted this time.
[0009] Calculate the final weight of each module based on its first and second weights;
[0010] Based on the final weight of each module, the weight of the data transmitted between each pair of modules is calculated, and the transmission path of the data to be transmitted is determined.
[0011] In one possible embodiment, calculating the first weight of each module based on the starting address of each module in memory loading includes: obtaining the starting address of each module in memory loading, sorting the starting addresses of multiple modules to obtain a sorting of multiple modules; setting the first weight of the next module to n times the first weight of the previous module, and the sum of the first weights of all modules to 1, and calculating the first weight of each module, where n is a positive integer.
[0012] In one possible embodiment, the first weight of the next module is set to be n times the first weight of the previous module, and the sum of the first weights of all modules is 1. Calculating the first weight of each module includes: calculating the first weight of each module using the following formula: w1 + nw1 + n 2 w1+…+n m-1 w1 = 1, solving for w1 gives w1 = 1 / (1 + n + n) 2 +…+n m-1 If the first weights of each module are w1, nw1, and n, then the first weights of each module are w1, nw1, and nw1, respectively. 2 w1、…、n m-1 w1; where w1 is the first weight of the first module in the sorting, n indicates that the first weight of the next module is n times the first weight of the previous module, m is the number of modules, and n is a positive integer.
[0013] In one possible embodiment, calculating the second weight of each module based on the data size that each module can transmit and the size of the data to be transmitted in this instance includes: calculating the difference between the data size that each module can transmit and the size of the data to be transmitted in this instance to obtain the difference for each module; sorting the multiple modules according to the difference for each module; setting the second weight of the next module in the sorting to be n times the second weight of the previous module, and the sum of the second weights of all modules to be 1, and calculating the second weight of each module.
[0014] In one possible embodiment, the first weight of the next module in the sorting is n times the second weight of the previous module, and the sum of the second weights of all modules is 1. Calculating the second weight of each module includes: calculating the second weight of each module using the following formula: w² + nw² + n 2 w2+…+n m-1Given w2 = 1, we can solve for w2 = 1 / (1 + n + n) 2 +…+n m-1 ), where w2 is the second weight of the first module in the sorting, n means that the second weight of the next module is n times the second weight of the previous module, m is the number of modules, and n is a positive integer.
[0015] In one possible embodiment, the step of calculating the final weight of each module based on its first and second weights as follows includes: w' = w1 * w2; where w' is the final weight of each module, w1 is the first weight of each module, and w2 is the second weight of each module; the step of calculating the weight of data transmission between every two modules based on the final weight of each module, and determining the transmission path of the data to be transmitted includes: for any module, calculating the weight of data transmission from any module to any other module using the following formula: s 12 = (w1'-w2')*d2; where, s 12 Let w1' be the weight for any module to transmit data to any other module, w2' be the final weight of any module, and d2 be the difference between the size of the data that any other module can transmit and the size of the data to be transmitted. Based on the weight of any module to transmit data to each other module, select the other module with the largest weight to transmit data. Traverse each module to determine the path of each module to transmit data to other modules, and thus determine the transmission path of the data to be transmitted between multiple modules.
[0016] In one possible embodiment, for two adjacent modules on the transmission path, the step of encrypting the data to be transmitted by the previous module includes: calculating the encryption key of the previous module based on seed data and the key data of the next module; the previous module using the encryption key to encrypt the data to be transmitted to obtain the encrypted data to be transmitted; the step of storing the encrypted data to be transmitted in the function code of the copy interface of the next module includes: obtaining the memory address of the export interface of the next module, finding the function code of the export interface based on the memory address; finding the function code of the copy interface that is the same as the function code of the export interface in the local module based on the function code of the export interface, and writing the encrypted data to be transmitted into the function code of the copy interface.
[0017] In one possible embodiment, the seed data is a preset number of pixel data at a fixed preset number of positions in the main program, wherein the seed data corresponding to each module is the same.
[0018] A second aspect of this application provides a data transmission system in the same process, comprising:
[0019] Define modules to define export interfaces and copy interfaces in each module. The function code of the copy interface is copied from the function code of the export interface. The function code of the export interface and the function code of the copy interface are stored in different files.
[0020] The determination module is used to calculate the weight of data transmitted between any two modules and to determine the transmission path of the data to be transmitted in this instance.
[0021] The encryption module is used to encrypt the data to be transmitted by the previous module in the transmission path and store the encrypted data in the copy interface function code of the next module.
[0022] The search module is used by the next module to find the same function code in the copy interface by obtaining the function code of its own exported interface, extract the encrypted data to be transmitted, decrypt it, and transmit the decrypted data to the next module.
[0023] A third aspect of this application provides an electronic device, including a memory and a processor, wherein the processor is configured to implement the steps of the data transmission method as described in any of the preceding claims when executing a computer management program stored in the memory.
[0024] A fourth aspect of this application provides a computer-readable storage medium having a computer management program stored thereon, which, when executed by a processor, implements the steps of the data transmission method as described in any of the preceding claims.
[0025] As can be seen from the above technical solutions, the embodiments of this application have the following advantages: An export interface and a copy interface are defined in each module of the same process, and the function code of the copy interface is copied from the function code of the export interface; the weight of the data transmitted between each pair of modules is calculated to determine the transmission path of the data to be transmitted; for two adjacent modules on the transmission path, the previous module encrypts the data to be transmitted and stores the encrypted data in the function code of the copy interface of the next module; the next module extracts the encrypted data from the function code of the copy interface, decrypts it, and transmits the decrypted data to the next module. In this embodiment, each module in the same process defines an export interface and a copy interface. The copy interface has the same function as the export interface. When secure data transmission is required, the previous module encrypts the data to be transmitted and stores the encrypted data in the function code of the copy interface of the next module, thus hiding the data to be transmitted within the function code of the copy interface, achieving a secure effect. Attached Figure Description
[0026] Figure 1 A flowchart illustrating a possible method for intra-process data transmission provided in an embodiment of this application;
[0027] Figure 2 This application provides a schematic diagram of the structure of a possible intra-process data transmission system.
[0028] Figure 3 A schematic diagram of the hardware structure of a possible electronic device provided in an embodiment of this application;
[0029] Figure 4 This is a schematic diagram of the hardware structure of a possible computer-readable storage medium provided in an embodiment of this application. Detailed Implementation
[0030] This application provides a method and related apparatus for displaying view objects, which makes the display of view objects more flexible and automated.
[0031] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0032] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0033] This application provides a method for data transmission within the same process; please refer to [link / reference]. Figure 1 The flowchart below illustrates a method for transmitting data within the same process, as provided in this application embodiment. Specifically, it includes:
[0034] 101. Define an export interface and a copy interface in each module of the same process. The function code of the copy interface is copied from the function code of the export interface. The function code of the export interface and the function code of the copy interface are stored in different files.
[0035] Understandably, traditional solutions typically only consider the security of data transmission between processes and external systems, without considering the security of data transmission within the same process, such as the security of data transmission between multiple modules within the same process.
[0036] Based on this, this application provides a method for secure data transmission within the same process. This process includes multiple modules. Typically, modules are provided for use by external modules, thus requiring exported interfaces. Therefore, corresponding functions need to be provided to export their interfaces. For security reasons, this application defines two interfaces for the same function implementation: an exported interface and a copy interface. During implementation, the function code of the exported interface is copied for use as the copy interface, and the copy interface has the same function as the exported interface. The two copies of the function code are stored in different files, choosing two files with large address distances to further isolate the two sets of function code, thus preventing the program from compiling the two sets of code together and having the two functions adjacent. Furthermore, the function functionality of each module's exported interface cannot be the same as its other functions. If they are the same, there is no need to implement two copies, indicating that there is reusable functionality in the code. Therefore, it is essential to ensure that each exported interface's function functionality has only one implementation. This application then adds a copy interface, whose functionality is consistent with that of the exported interface.
[0037] The export interface is public and available for external use. It can be used for functions that do not require security considerations. The copy interface, on the other hand, is for secure data transfer and is not exported.
[0038] The security-related functions utilize the aforementioned solutions, such as data encryption interfaces, data decryption interfaces, and data network transmission interfaces. The core interface is used to receive the data to be transmitted; therefore, it is necessary to ensure not only the security of data transmission but also the security of the received data when it is finally executed. The byte size of the function code for the exported interfaces of each module is a multiple of 1024.
[0039] 102. Calculate the weight of the data transmitted between each pair of modules and determine the transmission path of the data to be transmitted this time.
[0040] Understandably, by calculating the weight of the data transmitted between each pair of modules, the transmission path of the data to be transmitted is determined based on the weight of the data transmitted between each pair of modules.
[0041] 103. For two adjacent modules on the transmission path, the previous module encrypts the data to be transmitted and stores the encrypted data in the copy interface function code of the next module.
[0042] After determining the transmission path of the data to be transmitted, for two adjacent modules along the path, the previous module encrypts the data and then stores the encrypted data in the copy interface function code of the next module. Encrypting the data ensures secure data transmission from one module to the next; hiding the encrypted data within the copy interface function code prevents other modules from finding the data, thus ensuring double data security.
[0043] 104. The next module obtains the function code of its own exported interface, finds the same function code in the copied interface, extracts the encrypted data to be transmitted, decrypts it, and transmits the decrypted data to the next module.
[0044] Understandably, the previous module stores the encrypted data to be transmitted into the copy interface function code of the next module. When the next module searches for the data to be transmitted, it first locates the memory address of the exported interface in this module and retrieves its function code. Then, it finds the function code in this module that is identical to the exported interface's function code—that is, the copy interface's function code—and extracts the encrypted data from it. It then decrypts the data and transmits the decrypted local data to its next module.
[0045] In this embodiment of the application, each module in the same process is defined with an export interface and a copy interface. The copy interface has the same function as the export interface. When data needs to be transmitted securely, the previous module encrypts the data to be transmitted and stores the encrypted data to be transmitted in the function code of the copy interface of the next module. That is, the data to be transmitted is hidden in the function code of the copy interface, which achieves a security effect.
[0046] In one possible embodiment, calculating the weight of data transmission between every two modules and determining the transmission path of the data to be transmitted includes: calculating a first weight of each module based on the starting address of each module when it is loaded into memory, and calculating a second weight of each module based on the data size that each module can transmit and the size of the data to be transmitted; calculating the final weight of each module based on the first and second weights; and calculating the weight of data transmission between every two modules based on the final weight of each module, and determining the transmission path of the data to be transmitted.
[0047] Understandably, when data is transferred between multiple modules within the same process, it's necessary to determine the data transfer path, which can also be understood as a transfer strategy. For example, in the entire program, the process includes four modules, each defining an export interface and a copy interface.
[0048] When transmitting data, four modules need to form a loop, which is the transmission path. In this embodiment, the first weight of each module is calculated based on the starting address of each module when it is loaded into memory. The second weight of each module is also calculated based on the potential data size and the actual data size to be transmitted. The first weight reflects the proximity of each module; greater distance facilitates safer transmission. The second weight reflects the matching degree of this data transmission.
[0049] The first and second weights of each module are calculated, and the final weight of each module is calculated based on these weights. For example, the final weight of each module can be obtained by multiplying its first and second weights. Based on the final weight of each module, the weight for data transmission between any two modules is calculated, and the transmission path of the data to be transmitted is determined according to the weight of data transmission between any two modules.
[0050] In one possible embodiment, calculating the first weight of each module based on the starting address of each module loaded in memory includes: obtaining the starting address of each module loaded in memory, sorting the starting addresses of multiple modules to obtain a sort of multiple modules; setting the first weight of the next module to n times the first weight of the previous module, and the sum of the first weights of all modules is 1, and calculating the first weight of each module.
[0051] Understandably, the specific method for calculating the first weight of each module is as follows: Obtain the starting address of each module when it is loaded into memory. Taking four modules as an example, their starting addresses in memory are baseaddr1, baseaddr2, baseaddr3, and baseaddr4. Sort these four modules by their starting addresses in memory from smallest to largest. After sorting, the first weight of each subsequent module can be set to n times the first weight of the preceding module, for example, twice, and the sum of the first weights of the four modules is 1. Based on this, the first weight of each module can be calculated.
[0052] The first weight of each module can be calculated using the following formula:
[0053] w1+nw1+n 2 w1+…+n m-1 w1 = 1, solving for w1 gives w1 = 1 / (1 + n + n) 2 +…+n m-1 Then the first weights of each module are w1, nw1, n 2 w1、…、n m-1 w1; where w1 is the first weight of the first module in the sorting, n indicates that the first weight of the next module is n times the first weight of the previous module, m is the number of modules, and n is a positive integer.
[0054] For example, taking four modules as an example, if the starting addresses of the four modules in memory are baseaddr4, baseaddr3, baseaddr2, and baseaddr1, then: baseaddr4 + baseaddr4*2 + baseaddr4*4 + baseaddr4*8 = 1. Therefore, the first weight of the module corresponding to baseaddr4 is 1 / 15, the first weight of the module corresponding to baseaddr3 is 2 / 15, the first weight of the module corresponding to baseaddr2 is 4 / 15, and the first weight of the module corresponding to baseaddr1 is 8 / 15. The baseaddr address information for each module reflects their proximity; greater distances facilitate secure transmission.
[0055] In one possible implementation, calculating the second weight of each module based on the data size that each module can transmit and the size of the data to be transmitted in this instance includes: calculating the difference between the data size that each module can transmit and the size of the data to be transmitted in this instance to obtain the difference for each module; sorting multiple modules based on the difference for each module; setting the second weight of the next module in the sorting to be n times the second weight of the previous module, and the sum of the second weights of all modules to be 1, and calculating the second weight of each module.
[0056] The second weight of each module can be calculated using the following formula:
[0057] w2+nw2+n 2 w2+…+n m-1 Given w2 = 1, we can solve for w2 = 1 / (1 + n + n) 2 +…+n m-1 ); where w2 is the second weight of the first module in the sorting, n means that the second weight of the next module is n times the second weight of the previous module, m is the number of modules, and n is a positive integer.
[0058] Understandably, the second weight of each module is also calculated based on the data size that each module can transmit and the data size to be transmitted in this instance. Specifically, taking four modules as an example, the data size that each module can transmit is obtained as size1, size2, size3, and size4, and the contenthash value and contentSize of the data content to be transmitted in this instance are obtained.
[0059] Calculate d1 = size1 – contentSize, d2 = size2 – contentSize, d3 = size3 – contentSize, and d4 = size4 – contentSize respectively. Sort d1, d2, d3, and d4, where d1, d2, d3, and d4 may be positive or negative. When sorting, positive numbers are larger than negative numbers. Arrange d1, d2, d3, and d4 in ascending order.
[0060] After sorting, the second weight of each subsequent module is set to twice the second weight of the preceding module, and the sum of the second weights of all modules is 1. The second weight of each module can then be calculated using the same method as the first weight, which will not be repeated here. The second weight of each module reflects the degree of matching in this data transmission.
[0061] In one possible implementation, calculating the final weight of each module based on its first and second weights includes: w' = w1 * w2; where w' is the final weight of each module, w1 is the first weight of each module, and w2 is the second weight of each module; calculating the weight of data transmission between any two modules based on the final weight of each module, and determining the transmission path of the data to be transmitted includes: for any module, calculating the weight of data transmission from any module to any other module using the following formula: s 12 = (w1'-w2')*d2; where, s 12 Let w1' be the weight for any module to transmit data to any other module, w2' be the final weight of any module, and d2 be the difference between the size of the data that any other module can transmit and the size of the data to be transmitted. Based on the weight of any module to transmit data to each other module, select the other module with the largest weight to transmit data. Traverse each module to determine the path of each module to transmit data to other modules, and thus determine the transmission path of the data to be transmitted between multiple modules.
[0062] It is understandable that by calculating the first and second weights of each module using the two methods described above, the final weight of each module can be calculated based on the first and second weights. For example, the product of the first and second weights of each module can be used as the final weight of each module.
[0063] Based on the final weight of each module, the weight of data transmission between any two modules is calculated, thereby determining the transmission path of the data to be transmitted. The method for calculating the weight of data transmission between any two modules is illustrated using a four-module example: the weight for data transmission from the first module to the second module is calculated as follows: s 12 = (w1'-w2')*d2; where, s 12 Let w1' be the final weight of the first module transmitting data to the second module, w2' be the final weight of the second module, and d2 be the difference between the size of the data that the second module can transmit and the size of the data to be transmitted. The weights s for transmitting data from the first module to the second, third, and fourth modules are calculated using this method. 12 s 13 and s 14 The first module chooses to transmit data to the module with the highest weight, for example, s. 12 s 13 and s 14 Chinese 14 If the maximum value is found, the first module will choose to transmit data to the fourth module. The other modules will also determine the transmission direction using the same method, ultimately determining the transmission path of the data to be transmitted among these four modules.
[0064] In this process, the weight of each module's data transmission to any other module is calculated using the aforementioned method, and data is transmitted to the module with the highest weight. While existing technologies typically transmit data according to the order of modules within a process, this embodiment calculates a first weight for each module based on its memory address, reflecting the proximity of the modules; the greater the distance between two modules, the higher the security of data transmission. A second weight for each module is calculated based on its transmittable data size and the size of the data to be transmitted. This second weight reflects the matching degree of data transmission between modules. By using the first and second weights of each module, the optimal data transmission path is selected. Compared to the transmission path determined by the order of modules within a process in existing technologies, this method offers greater security and better matching in data transmission.
[0065] It should be noted that data transmission is directional. The transmission path from the first module to the second module and the transmission path from the second module to the first module are different. Therefore, the weight of the transmission path from the first module to the second module and the transmission path from the second module to the first module are also different.
[0066] In one possible implementation, for two adjacent modules on the transmission path, the step of encrypting the data to be transmitted by the previous module includes: calculating the encryption key of the previous module based on seed data and the key data of the next module; the previous module using the encryption key to encrypt the data to be transmitted to obtain the encrypted data to be transmitted; the step of storing the encrypted data to be transmitted in the function code of the copy interface of the next module includes: obtaining the memory address of the export interface of the next module, finding the function code of the export interface based on the memory address; finding the function code of the copy interface that is the same as the function code of the export interface in the local module based on the function code of the export interface, and writing the encrypted data to be transmitted into the function code of the copy interface.
[0067] Understandably, each module needs to set its key upon loading for data transfer. Each module defines a global static variable to store the key data. This global static variable is stored in the DATA segment (global initialization area). Aside from the key data, other data in the program does not use the global static variable, thus ensuring that the DATA segment contains only one global static variable. A marker can be set at the beginning of the key data to facilitate other modules finding this module's key data. The key data does not provide an export interface; therefore, other modules need to parse the module file, extract the data from the DATA segment, and use the marker to find the stored key data. The marker is primarily used to avoid confusion with the system's global data. The global static variable ensures that the key is initialized before use. This key data is the initial key data; subsequent key data will be calculated based on other seed data to obtain new key data.
[0068] After determining the transmission path of the data to be transmitted, for two adjacent modules along the transmission path, the previous module encrypts the data to be transmitted. During encryption, the encryption key of the previous module is calculated based on the seed data and the key data of the next module. The seed data consists of a fixed number of pixels at a fixed number of positions in the main program, and the seed data is the same for each module.
[0069] Each module has the function of capturing pixels from the main program. Furthermore, when transmitting data, all modules select four pixels from four fixed positions in the main program as seed data for the key. The seed data for each module is identical.
[0070] When the first module prepares to transmit data, it calculates the 32-byte hash value of the entire data based on the data to be transmitted, resulting in 4 bytes of data. These 4 bytes are then written into the screen's pixel data. Since the data volume is too small, it will not cause any visual difference to the user. After generating seed data, the first module obtains the key data from the next module. Based on the seed data and the key data, it calculates the encryption key used by the first module to encrypt the data. The key calculation algorithm is as follows:
[0071] Key = Sha128.create(key+seed), where sha128 is the hash algorithm, Key is the final encryption key, key is the key data for the next module, and seed is the seed data.
[0072] The seed data is used in a complete transmission process. Each module will reuse the seed data. The data transmission of each module is from one module to the next. Before transmission, the seed data and the key data of the next module are used to encrypt the key and encrypt the data to be transmitted before transmission.
[0073] The function of extracting 4 pixels of data is implemented using existing conventional techniques. Specifically, it is implemented as follows: the window DC handle is obtained by calling dc = GetDC(NULL), which creates a memory device context; and a memory device context compatible with the specified device is created by calling mdc = CreateCompatibleDC(dc).
[0074] Then, the function `hbmp = CreateDIBSection(mdc,&bi,DIB_RGB_COLORS,(void**)&Data,NULL,0)` creates a device-independent bitmap (DIB) that the application can directly write to. This function provides a pointer to the location of the bitmap's bit data values. A handle can be provided to a file mapping object, which the function uses to create the bitmap, or the system can allocate memory for the bitmap. This function can also be used to capture a screenshot of the pixel data on the screen.
[0075] The SelectObject(mdc,hbmp) function selects a handle, which selects an object into the specified device context, replacing the previous object of the same type; the BitBlt(mdc,0,0,Width,Height,hDC,0,0,SRCCOPY) function retrieves bitmap information, i.e., pixel data.
[0076] The above screenshot method yields the program's pixel data, also known as seed data. A crucial point is that before each screenshot, the main program must be set as the top-level window and displayed at the very top. After the screenshot is complete, it should be restored to its original position. Otherwise, it may be obscured by other windows, preventing the acquisition of accurate data.
[0077] The previous module encrypts the data to be transmitted and stores it in the copy interface function code of the next module. Specifically, since the copy interface function code is hidden, the memory address of the next module's exported interface is first located, and its function code is found in memory. Then, the next module searches for the same function code as the exported interface (i.e., the copy interface function code), and writes the encrypted data to be transmitted into this copy interface function code. Each module can also store the key data in the copy interface function code to ensure its security.
[0078] In traditional solutions, data transfer between multiple modules involves sending the memory address of the data to the other module for direct use. Furthermore, traditional solutions only store data in readable and writable memory modules. However, this application's embodiment, considering security and concealment, sets up two copies of the non-core exported interface. One copy is used for normal functionality, while the other is used to store encrypted data to be transmitted, including key data and seed data.
[0079] First, obtain the exported interface. After obtaining the exported interface, you can read its assembly code. Once you have the assembly code, perform a code search and matching within the module to find a function that is exactly the same as the code in this module. This will allow you to find a copy of the interface's code, where the memory attributes of the code are readable and executable but cannot be written to.
[0080] The memory attributes are modified using the system function VirtualProtect, where PAGE_READWRITE indicates that the memory is readable and writable: VirtualProtect(lpAddr, sizeof(DWORD), PAGE_READWRITE, &dwOldProtect). After the memory attributes are modified, the encrypted data is written to this code.
[0081] It is generally believed that code segments can only store code, not data. However, for security reasons, this application's embodiments design a function code within the copy interface to store encrypted data. This means that the encrypted data from the previous module is stored in the copy interface's function code, thus achieving a stealth effect unconventionally. The key seed data can also be stored in this code segment along with the encrypted data to be transmitted, achieving both security and concealment in data storage. After data is written, it is restored to a readable and executable state, while the writable attribute is removed.
[0082] During data transmission, the encrypted data to be transmitted is stored in the copy interface function code of a module. When the next module retrieves the encrypted data, since each module's copy interface is hidden and cannot be directly located, it first locates the memory address of the exported interface in the module and finds its function code in memory. Because the function code in the copy interface is identical to that in the exported interface, the next module searches for the same function code (i.e., the copy interface function code) to extract the encrypted data, decrypts it, and then re-encrypts and transmits it to the next module.
[0083] The embodiments of this application have been described above from the perspective of data transmission methods in the same process. The embodiments of this application will now be described below from the perspective of data transmission systems in the same process.
[0084] Please see Figure 2 , Figure 2 This application provides an embodiment of a data transmission system in the same process, which specifically includes:
[0085] Define module 201, which is used to define an export interface and a copy interface in each module of the same process. The function code of the copy interface is copied from the function code of the export interface. The function code of the export interface and the function code of the copy interface are stored in different files.
[0086] The determination module 202 is used to calculate the weight of the data transmitted between every two modules and to determine the transmission path of the data to be transmitted this time.
[0087] Encryption module 203 is used to encrypt the data to be transmitted in the current transmission by the previous module of two adjacent modules on the transmission path, and to store the encrypted data to be transmitted in the function code of the copy interface of the next module.
[0088] The lookup module 204 is used to allow the next module to find the same function code in the copy interface by obtaining the function code of its own exported interface, extract the encrypted data to be transmitted, decrypt it, and transmit the decrypted data to the next module.
[0089] Please see Figure 3 , Figure 3 A schematic diagram illustrating an embodiment of the electronic device provided in this application.
[0090] like Figure 3 As shown, this application embodiment provides an electronic device, including a memory 310, a processor 320, and a computer program 311 stored in the memory 320 and executable on the processor 320. When the processor 320 executes the computer program 311, it performs the following steps: defining an export interface and a copy interface in each module of the same process, wherein the function code of the copy interface is copied from the function code of the export interface, and the function code of the export interface and the function code of the copy interface are stored in different files; calculating the weight of the data transmitted between each two modules and determining the transmission path of the data to be transmitted; for two adjacent modules on the transmission path, the previous module encrypts the data to be transmitted and stores the encrypted data in the function code of the copy interface of the next module; the next module obtains the function code of its own export interface, finds the same function code in the copy interface, extracts the encrypted data to be transmitted from it, decrypts it, and transmits the decrypted data to be transmitted to the next module.
[0091] Optionally, in one possible embodiment, the processor 320 is further configured to: calculate a first weight of each module based on the starting address of each module loaded in memory, and calculate a second weight of each module based on the data size that each module can transmit and the size of the data to be transmitted this time; calculate a final weight of each module based on the first weight and the second weight of each module; calculate the weight of data transmission between every two modules based on the final weight of each module, and determine the transmission path of the data to be transmitted this time.
[0092] Optionally, in one possible embodiment, the processor 320 is further configured to: obtain the starting address of each module loaded in memory, sort the starting addresses of multiple modules to obtain a sort of multiple modules; set the first weight of the next module to be n times the first weight of the previous module, and the sum of the first weights of all modules is 1, and calculate the first weight of each module.
[0093] Optionally, in one possible embodiment, the processor 320 is specifically configured to: calculate a first weight for each module using the following formula: w1+n 2 w1+…+n m-1 w1 = 1, solving for w1 gives w1 = 1 / (1 + n + n) 2 +…+n m-1 If the first weights of each module are w1, nw1, and n, then the first weights of each module are w1, nw1, and nw1, respectively. 2 w1、…、n m-1 w1; where w1 is the first weight of the first module in the sorting, n indicates that the first weight of the next module is n times the first weight of the previous module, m is the number of modules, and n is a positive integer.
[0094] Optionally, in one possible embodiment, the processor 320 is specifically configured to: calculate the difference between the data size that each module can transmit and the data size to be transmitted in this instance, to obtain the difference value corresponding to each module; sort the multiple modules according to the difference value corresponding to each module; set the second weight of the next module in the sorting to be n times the second weight of the previous module, and the sum of the second weights of all modules is 1, and calculate the second weight of each module.
[0095] Optionally, in one possible embodiment, the processor 320 is specifically configured to: calculate the second weight of each module using the following formula: w² + n 2 w2+…+n m-1 w2 = 1; Solving for w2, we get w2 = 1 / (1 + n + n 2 +…+n m-1 ); where w2 is the second weight of the first module in the sorting, n means that the second weight of the next module is n times the second weight of the previous module, m is the number of modules, and n is a positive integer.
[0096] Optionally, in one possible embodiment, the processor 320 is specifically configured to: calculate the final weight of each module according to the first weight and the second weight of each module in the following manner: w' = w1 * w2; where w' is the final weight of each module, w1 is the first weight of each module, and w2 is the second weight of each module; the step of calculating the weight of data transmission between every two modules based on the final weight of each module, and determining the transmission path of the data to be transmitted in this instance, includes: for any module, calculating the weight of data transmission from any module to any other module using the following formula: s 12 = (w1'-w2')*d2; where, s 12Let w1' be the weight for any module to transmit data to any other module, w2' be the final weight of any module, and d2 be the difference between the size of the data that any other module can transmit and the size of the data to be transmitted. Based on the weight of any module to transmit data to each other module, select the other module with the largest weight to transmit data. Traverse each module to determine the path of each module to transmit data to other modules, and thus determine the transmission path of the data to be transmitted between multiple modules.
[0097] Optionally, in one possible embodiment, the processor 320 is specifically configured to: calculate the encryption key of the previous module based on the seed data and the key data of the next module; the previous module uses the encryption key to encrypt the data to be transmitted this time, obtaining the encrypted data to be transmitted this time; the step of storing the encrypted data to be transmitted this time in the function code of the copy interface of the next module includes: obtaining the memory address of the export interface of the next module, finding the function code of the export interface based on the memory address; finding the function code of the copy interface that is the same as the function code of the export interface in the local module based on the function code of the export interface, and writing the encrypted data to be transmitted this time into the function code of the copy interface.
[0098] Optionally, in one possible embodiment, the seed data is a preset number of pixel data at a fixed preset number of positions of the main program, wherein the seed data corresponding to each module is the same.
[0099] Please see Figure 4 , Figure 4 This is a schematic diagram illustrating an embodiment of a computer-readable storage medium provided in this application.
[0100] like Figure 4As shown, this embodiment provides a computer-readable storage medium 400, on which a computer program 411 is stored. When the computer program 411 is executed by a processor, it performs the following steps: defining an export interface and a copy interface in each module of the same process, wherein the function code of the copy interface is copied from the function code of the export interface, and the function code of the export interface and the function code of the copy interface are stored in different files; calculating the weight of the data transmitted between each two modules and determining the transmission path of the data to be transmitted; for two adjacent modules on the transmission path, the previous module encrypts the data to be transmitted and stores the encrypted data in the function code of the copy interface of the next module; the next module obtains the function code of its own export interface, finds the same function code in the copy interface, extracts the encrypted data to be transmitted from it, decrypts it, and transmits the decrypted data to be transmitted to the next module.
[0101] Optionally, in one possible embodiment, when the computer program 411 is executed by the processor, it is further configured to perform the following steps: calculate a first weight of each module based on the starting address of each module loaded in memory, and calculate a second weight of each module based on the data size that each module can transmit and the size of the data to be transmitted this time; calculate the final weight of each module based on the first weight and the second weight of each module; calculate the weight of data transmission between every two modules based on the final weight of each module, and determine the transmission path of the data to be transmitted this time.
[0102] Optionally, in one possible embodiment, when the computer program 411 is executed by the processor, it is further configured to perform the following steps: obtain the starting address of each module loaded in memory, sort the starting addresses of multiple modules to obtain the sorting of multiple modules; set the first weight of the next module to be n times the first weight of the previous module, and the sum of the first weights of all modules is 1, and calculate the first weight of each module.
[0103] Optionally, in one possible embodiment, when the computer program 411 is executed by the processor, it is specifically used to implement the following steps: calculating the first weight of each module using the following formula: w1+n 2 w1+…+n m-1 w1 = 1, solving for w1 gives w1 = 1 / (1 + n + n) 2 +…+n m-1 Then the first weights of each module are w1, nw1, n 2 w1、…、n m-1w1; where w1 is the first weight of the first module in the sorting, n indicates that the first weight of the next module is n times the first weight of the previous module, m is the number of modules, and n is a positive integer.
[0104] Optionally, in one possible embodiment, when the computer program 411 is executed by the processor, it is specifically used to implement the following steps: calculate the difference between the data size that each module can transmit and the data size to be transmitted in this instance, and obtain the difference value corresponding to each module; sort the multiple modules according to the difference value corresponding to each module; set the second weight of the next module in the sorting to be n times the second weight of the previous module, and the sum of the second weights of all modules is 1, and calculate the second weight of each module.
[0105] Optionally, in one possible embodiment, when the computer program 411 is executed by the processor, it is specifically used to implement the following steps: calculating the second weight of each module using the following formula: w2+nw2+n 2 w2+…+n m-1 w2 = 1; Solving for w2, we get w2 = 1 / (1 + n + n 2 +…+n m-1 ); where w2 is the second weight of the first module in the sorting, n means that the second weight of the next module is n times the second weight of the previous module, m is the number of modules, and n is a positive integer.
[0106] Optionally, in one possible embodiment, when the computer program 411 is executed by the processor, it is specifically used to implement the following steps: calculating the final weight of each module in the following manner: w' = w1 * w2; where w' is the final weight of each module, w1 is the first weight of each module, and w2 is the second weight of each module; the step of calculating the weight of data transmitted between every two modules based on the final weight of each module, and determining the transmission path of the data to be transmitted in this instance, includes: for any module, calculating the weight of data transmitted from any module to any other module using the following formula: s 12 = (w1'-w2')*d2; where, s 12 Let w1' be the weight for any module to transmit data to any other module, w2' be the final weight of any module, and d2 be the difference between the size of the data that any other module can transmit and the size of the data to be transmitted. Based on the weight of any module to transmit data to each other module, select the other module with the largest weight to transmit data. Traverse each module to determine the path of each module to transmit data to other modules, and thus determine the transmission path of the data to be transmitted between multiple modules.
[0107] Optionally, in one possible embodiment, when the computer program 411 is executed by the processor, it is specifically used to implement the following steps: calculating the encryption key of the previous module based on the seed data and the key data of the next module; the previous module uses the encryption key to encrypt the data to be transmitted this time, obtaining the encrypted data to be transmitted this time; the step of storing the encrypted data to be transmitted this time in the function code of the copy interface of the next module includes: obtaining the memory address of the export interface of the next module, finding the function code of the export interface based on the memory address; finding the function code of the copy interface that is the same as the function code of the export interface in the local module based on the function code of the export interface, and writing the encrypted data to be transmitted this time into the function code of the copy interface.
[0108] Optionally, in one possible embodiment, the seed data is a preset number of pixel data at a fixed preset number of positions of the main program, wherein the seed data corresponding to each module is the same.
[0109] It should be noted that the descriptions of each embodiment in the above embodiments have different focuses. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0110] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0111] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0112] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0113] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0114] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0115] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for data transmission within the same process, wherein the same process includes multiple modules, characterized in that, include: In each module of the same process, an export interface and a copy interface are defined. The function code of the copy interface is copied from the function code of the export interface. The function code of the export interface and the function code of the copy interface are stored in different files. Calculate the weight of the data transmitted between each pair of modules and determine the transmission path of the data to be transmitted this time; For two adjacent modules on the transmission path, the previous module encrypts the data to be transmitted and stores the encrypted data in the function code of the copy interface of the next module; The next module retrieves the function code of its own exported interface, finds the same function code in the copied interface, extracts the encrypted data to be transmitted, decrypts it, and transmits the decrypted data to the next module. The calculation of the weight of data transmitted between every two modules and the determination of the transmission path of the data to be transmitted this time include: Calculate the first weight of each module based on the starting address of each module in memory, and calculate the second weight of each module based on the amount of data each module can transmit and the amount of data to be transmitted this time. Calculate the final weight of each module based on its first and second weights; Based on the final weight of each module, the weight of the data transmitted between each pair of modules is calculated, and the transmission path of the data to be transmitted is determined.
2. The data transmission method according to claim 1, characterized in that, The calculation of the first weight of each module based on its starting address in memory includes: Obtain the starting address of each module in memory, sort the starting addresses of multiple modules, and obtain the sorting of multiple modules; Set the first weight of the next module in the sorting to n times the first weight of the previous module, and the sum of the first weights of all modules is 1. Calculate the first weight of each module, where n is a positive integer.
3. The data transmission method according to claim 2, characterized in that, The first weight of the next module is set to be n times the first weight of the previous module, and the sum of the first weights of all modules is 1. The calculation of the first weight of each module includes: The first weight of each module is calculated using the following formula: w1+nw1+n 2 w1+…+n m-1 w1=1; Solving for w1, we get w1 = 1 / (1 + n + n) 2 +…+n m-1 ); The first weights of each module are w1, nw1, n 2 w1、…、n m-1 w1; Where w1 is the first weight of the first module in the sorting, n means that the first weight of the next module is n times the first weight of the previous module, m is the number of modules, and n is a positive integer.
4. The data transmission method according to claim 1, characterized in that, The calculation of the second weight of each module based on the data size that each module can transmit and the size of the data to be transmitted in this instance includes: The difference between the data size that each module can transmit and the data size to be transmitted is calculated to obtain the difference for each module. Sort multiple modules based on the difference between each module; Set the second weight of the next module in the sorting to n times the second weight of the previous module, and sum the second weights of all modules to 1. Calculate the second weight of each module.
5. The data transmission method according to claim 4, characterized in that, The first weight of the next module in the sorting is set to be n times the second weight of the previous module, and the sum of the second weights of all modules is 1. The calculation of the second weight of each module includes: The second weight of each module is calculated using the following formula: W2+nw2+n 2 w2+…+n m-1 w2=1; Solving for w, we get w2 = 1 / (1 + n + n) 2 +…+n m-1 ); Where w2 is the second weight of the first module in the sorting, n means that the second weight of the next module is n times the second weight of the previous module, m is the number of modules, and n is a positive integer.
6. The data transmission method according to claim 1, characterized in that, The calculation of the final weight of each module based on its first and second weights includes: The final weight of each module is calculated as follows: w' = w1 * w2; Where w' is the final weight of each module, w1 is the first weight of each module, and w2 is the second weight of each module; The process of calculating the weight of data transmitted between every two modules based on the final weight of each module, and determining the transmission path of the data to be transmitted includes: For any given module, the weight of data transmitted from that module to any other module is calculated using the following formula: s 12 =(w1’-w2’)*d2; Among them, s 12 w1' is the weight for any module to transmit data to any other module, w2' is the final weight of any module, and d2 is the difference between the size of the data that any other module can transmit and the size of the data to be transmitted this time. Based on the weight of data transmission from any module to each of the other modules, select the other module with the highest weight to transmit data to. Iterate through each module, determine the transmission path from each module to other modules, and then determine the transmission path of the data to be transmitted between multiple modules.
7. The data transmission method according to claim 1, characterized in that, For two adjacent modules on the transmission path, the preceding module encrypts the data to be transmitted, including: Calculate the encryption key of the previous module based on the seed data and the key data of the next module; The previous module used the encryption key to encrypt the data to be transmitted, and obtained the encrypted data to be transmitted. The function code for the copy interface that stores the encrypted data to be transmitted in the next module includes: Obtain the memory address of the exported interface of the next module, and find the function code of the exported interface based on the memory address; Based on the function code of the exported interface, find the function code in the copy interface that is the same as the function code of the exported interface in the local module, and write the encrypted module to be transmitted into the function code of the copy interface.
8. The data transmission method according to claim 7, characterized in that, The seed data consists of a fixed number of pixels at a fixed number of positions in the main program, with each module having the same seed data.
Citation Information
Patent Citations
An end-to-end encryption method and system for a Linux network layer
CN109862000A
Operation method of package file, file processing equipment and equipment with storage function
CN110232261A