Code generation method and device based on large model, equipment and storage medium

By modifying the pseudo-code snippets generated by the reverse analysis tool through a large model, the problem of code errors in reverse engineering is solved, and more efficient and accurate code security analysis is achieved.

CN119720199BActive Publication Date: 2025-10-10BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411864748.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-10-10
Estimated Expiration
2044-12-17

AI Technical Summary

Technical Problem

The codes generated by existing reverse engineering tools contain various errors, such as disordered structure, missing variables, incorrect data types, and unrecognized high-level language features, resulting in poor readability of the analysis results and making them difficult to use for running security analysis tasks.

Method used

Utilizing the natural language understanding capabilities and rich knowledge reserves of the large model, the pseudocode generated by the reverse analysis tool is corrected, pseudocode fragments are segmented and target code is generated to reproduce the execution logic and structure of the source code.

Benefits of technology

Improves the readability and efficiency of reverse engineering analysis results, ensuring that the generated code can accurately analyze the security of dynamic link library files in the target system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119720199B_ABST
    Figure CN119720199B_ABST
Patent Text Reader

Abstract

The disclosure provides a large model-based code generation method, device and equipment and a storage medium, relates to the technical field of artificial intelligence, in particular to the technical field of large models and reverse engineering. The specific implementation scheme of the code generation method is: the pseudo code of the dynamic link library file is divided to obtain a plurality of pseudo code segments and at least one division position; wherein the pseudo code is obtained by disassembling and reverse analyzing the dynamic link library file; errors in the plurality of pseudo code segments are corrected based on a large model to generate a plurality of code segments; and the plurality of code segments are combined according to the at least one division position to generate target code; the target code is used to analyze whether the dynamic link library file is safe when running in a target system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to the field of large models and reverse engineering technology, and specifically to a code generation method, apparatus, device and storage medium based on a large model. Background Art

[0002] With the development of artificial intelligence technology, large models are widely used in fields such as natural language processing, content creation, AI-assisted writing, intelligent assistants, smart manufacturing, and smart logistics. Based on their rich knowledge reserves and natural language understanding capabilities, large models are driving the development of intelligent technology in various fields. Summary of the Invention

[0003] The present disclosure provides a code generation method, device, electronic device and storage medium based on a large model.

[0004] According to one aspect of the present disclosure, a code generation method based on a large model is provided, comprising: segmenting the pseudocode of a dynamic link library file to obtain multiple pseudocode fragments and at least one segmentation position; wherein the pseudocode is obtained by disassembling and reverse analyzing the dynamic link library file; correcting errors in the multiple pseudocode fragments based on the large model to generate multiple code fragments; and combining the multiple code fragments according to at least one segmentation position to generate a target code; the target code is used to analyze whether it is safe to run the dynamic link library file in a target system.

[0005] According to another aspect of the present disclosure, a training method for a large model is provided, comprising: segmenting the pseudocode of a sample dynamic link library file to obtain a plurality of sample pseudocode fragments and at least one sample segmentation position; wherein the sample pseudocode is obtained by disassembling and reverse analyzing the sample dynamic link library file; based on the initial large model, respectively correcting errors in the plurality of sample pseudocode fragments to generate a plurality of sample code fragments; based on a target loss function, generating a loss value according to each source code fragment and each sample code fragment of the sample dynamic link library; wherein the segmentation position of each source code fragment is the same as the segmentation position of each sample pseudocode fragment; and adjusting the model parameters of the initial large model based on the loss value to obtain the large model.

[0006] According to another aspect of the present disclosure, a method for detecting a dynamic link library file is provided, comprising: obtaining a target code of the dynamic link library file, wherein the target code is generated using the large model-based code generation method described above; and detecting the target code to generate a detection result; wherein the detection result is used to characterize whether it is safe to run the dynamic link library file in a target system.

[0007] According to another aspect of the present disclosure, a code generation device based on a large model is provided, comprising: a first segmentation module, a first correction module and a combination module.

[0008] The first segmentation module is used to segment the pseudo code of the dynamic link library file to obtain multiple pseudo code segments and at least one segmentation position; wherein the pseudo code is obtained by disassembling and reverse analyzing the dynamic link library file.

[0009] The first correction module is used to correct errors in multiple pseudo code snippets based on the large model and generate multiple code snippets.

[0010] The combination module is used to combine multiple code fragments according to at least one segmentation position to generate a target code; the target code is used to analyze whether it is safe to run the dynamic link library file in the target system.

[0011] According to another aspect of the present disclosure, a large model training device is provided, comprising: a second segmentation module, a second correction module, a loss calculation module and an adjustment module.

[0012] The second segmentation module is used to segment the pseudo code of the sample dynamic link library file to obtain multiple sample pseudo code segments and at least one sample segmentation position; wherein the sample pseudo code is obtained by disassembling and reverse analyzing the sample dynamic link library file.

[0013] The second correction module is used to correct errors in the multiple sample pseudo code segments based on the initial large model to generate multiple sample code segments.

[0014] The loss calculation module is used to generate a loss value based on the target loss function and the source code snippets of the sample dynamic link library and the sample code snippets; wherein the segmentation position of each source code snippet is the same as the segmentation position of each sample pseudocode snippet.

[0015] The adjustment module is used to adjust the model parameters of the initial large model based on the loss value to obtain the large model.

[0016] According to another aspect of the present disclosure, a device for detecting a dynamic link library file is provided, including: an acquisition module and a detection module.

[0017] The acquisition module is used to obtain the target code of the dynamic link library file, wherein the target code is generated using the large model-based code generation method described above.

[0018] The detection module is used to detect the target code and generate a detection result; wherein the detection result is used to indicate whether it is safe to run the dynamic link library file in the target system.

[0019] According to another aspect of the present disclosure, an artificial intelligence agent is provided, comprising: an input module, a processing module, and an output module. The input module is configured to receive input information. The processing module is configured to determine a target task based on the input information received by the input module, determine a large model based on the target task, and execute the large model-based code generation method described above by calling the large model to obtain output information. The output module is configured to output the output information obtained by the processing module.

[0020] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described above.

[0021] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described above.

[0022] According to another aspect of the present disclosure, a computer program product is provided, comprising a computer program, which implements the method described above when executed by a processor.

[0023] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.

[0025] Figure 1 Schematically illustrates an exemplary system architecture to which a large model-based code generation method, a large model training method, or a dynamic link library file detection method and apparatus according to an embodiment of the present disclosure can be applied;

[0026] Figure 2 Schematically shows a flow chart of a code generation method based on a large model according to an embodiment of the present disclosure;

[0027] Figure 3 The following schematically illustrates a code generation method based on a large model according to an embodiment of the present disclosure;

[0028] Figure 4A Schematically shows a schematic diagram of segmenting pseudo code according to an embodiment of the present disclosure;

[0029] Figure 4BA schematic diagram illustrating segmentation of pseudo code according to another embodiment of the present disclosure is shown;

[0030] Figure 5A A schematic diagram illustrating correction of field missing errors in a pseudo code segment by a large model is shown;

[0031] Figure 5B A schematic diagram illustrating correction of structure errors in a pseudo code segment by a large model is shown;

[0032] Figure 5C A schematic diagram illustrating correction of data type errors in a pseudo code segment by a large model is shown;

[0033] Figure 5D A schematic diagram illustrating correction of inline assembly errors in a pseudo code segment by a large model is shown;

[0034] Figure 6 A flowchart of a large model training method according to an embodiment of the present disclosure is shown;

[0035] Figure 7 A flowchart of a dynamic link library file detection method according to an embodiment of the present disclosure is shown;

[0036] Figure 8 A block diagram of a large model-based code generation apparatus according to an embodiment of the present disclosure is shown;

[0037] Figure 9 A block diagram of a large model training apparatus according to an embodiment of the present disclosure is shown;

[0038] Figure 10 A block diagram of a dynamic link library file detection apparatus according to an embodiment of the present disclosure is shown;

[0039] Figure 11 A block diagram of an artificial intelligence agent according to an embodiment of the present disclosure is shown;

[0040] Figure 12 A block diagram of an electronic device suitable for implementing a large model-based code generation method or a large model training method or a dynamic link library file detection method according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0041] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0042] Reverse engineering refers to the process of analyzing and researching existing software, hardware, or systems. In the programming field, it is often used to analyze compiled program code to reveal its operating mechanisms, algorithms, and data structures, thereby facilitating analysis for operational security risks. Reverse engineering typically involves disassembly, decompilation, dynamic analysis, and static analysis. These processes rely on programming knowledge and reverse analysis experience, resulting in low efficiency and difficulty adapting to the rapidly changing security analysis needs of various applications.

[0043] To improve reverse engineering efficiency, reverse analysis can be performed using reverse engineering tools. However, in practice, it has been found that the code generated by reverse engineering tools contains various errors, such as disordered structures, missing variables, incorrect data types, and the conversion of high-level language macros and inline assembly into unrecognizable fields. This results in poor readability of the analysis results and makes them unsuitable for operational security analysis tasks.

[0044] In view of this, the embodiments of the present disclosure provide a code generation method based on a large model, which utilizes the natural language understanding ability and rich knowledge reserves of the large model to correct various errors in the pseudocode obtained by disassembling and reverse analyzing the dynamic link library using various reverse analysis tools, thereby improving the readability of the analysis results and the quality and efficiency of reverse engineering.

[0045] Figure 1 The exemplary system architecture of the code generation method based on a large model, the large model training method, or the detection method and device of the dynamic link library file according to the embodiment of the present disclosure is schematically shown.

[0046] It should be noted that Figure 1What is shown is only an example of a system architecture to which the embodiments of the present disclosure can be applied, to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios. For example, in another embodiment, an exemplary system architecture to which a large model-based code generation method or a large model training method or a dynamic link library file detection method and apparatus can be applied may include a terminal device, but the terminal device may implement the large model-based code generation method or a large model training method or a dynamic link library file detection method and apparatus provided in the embodiments of the present disclosure without interacting with a server.

[0047] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a terminal device 101 , a large model 102 , a network 103 and a server 104 .

[0048] The terminal device 101 may be any electronic device having a display screen and supporting web browsing, including but not limited to a smart phone, a tablet computer, a laptop computer, a desktop computer, and the like.

[0049] It should be noted that the code generation method and program execution method based on the large model provided in the embodiments of the present disclosure can generally be executed by the terminal device 101. Accordingly, the code generation device and program execution device based on the large model provided in the embodiments of the present disclosure can also be set in the terminal device 101. Accordingly, the code generation method or large model training method or dynamic link library file detection device based on the large model provided in the embodiments of the present disclosure can also be set in the terminal device 101.

[0050] For example, terminal device 101 can obtain model parameters from server 104 via network 103 and load large model 102 into terminal device 101. A user can import a dynamic link library file. Terminal device 101 first uses a reverse analysis tool to disassemble and reverse analyze the dynamic link library file to generate pseudocode. Large model 102 is then used to segment the pseudocode, correcting errors in each pseudocode segment to generate code segments. Finally, the code segments are combined according to the segmentation locations to generate target code 110. Target code 110 can be displayed to the user via terminal device 101 to analyze whether the dynamic link library file is safe to run in the target system.

[0051] Server 104 may be a server that provides various services, such as a background management server (for example only) that supports content viewed by users on terminal device 101. The background management server may analyze and process received data such as user requests, and provide feedback (e.g., web pages, information, or data obtained or generated based on user requests) to terminal device 101.

[0052] Alternatively, the code generation method based on the large model or the large model training method or the dynamic link library file detection method provided in the embodiment of the present disclosure can generally be executed by the server 104. Accordingly, the code generation method based on the large model or the large model training method or the dynamic link library file detection device provided in the embodiment of the present disclosure can generally be set in the server 104. The code generation method based on the large model or the large model training method or the dynamic link library file detection method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 104 and can communicate with the terminal device 101 and / or the server 104. Accordingly, the code generation method based on the large model or the large model training method or the dynamic link library file detection device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 104 and can communicate with the terminal device 101 and / or the server 104.

[0053] For example, a user can import a dynamic link library file into terminal device 101, which then sends the dynamic link library file to server 104 via network 103. The server can then use a reverse analysis tool to disassemble and reverse analyze the dynamic link library file to generate pseudocode. The pseudocode is then segmented to produce multiple pseudocode snippets. Next, server 101 can use the large model 102 to correct errors in each pseudocode snippet and generate code snippets. Finally, the code snippets are combined according to the segmentation locations to generate target code 110. Target code 110 is then sent to terminal device 101 via network 103 to display the reverse analysis results to the user.

[0054] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.

[0055] In the technical solution disclosed herein, the collection, storage, use, processing, transmission, provision, disclosure and application of user personal information involved comply with the provisions of relevant laws and regulations, take necessary confidentiality measures, and do not violate public order and good morals.

[0056] In the technical solution disclosed herein, the user's authorization or consent is obtained before obtaining or collecting the user's personal information.

[0057] In the technical solution disclosed herein, legal authorization or permission has been obtained before obtaining the dynamic link library file for reverse analysis.

[0058] Figure 2 The flowchart of the code generation method based on the large model according to the embodiment of the present disclosure is schematically shown.

[0059] like Figure 2 As shown, the method includes operations S210 to S230.

[0060] In operation S210 , the pseudo code of the dynamic link library file is segmented to obtain a plurality of pseudo code segments and at least one segmentation position.

[0061] In operation S220 , errors in the plurality of pseudo code segments are corrected respectively based on the large model to generate a plurality of code segments.

[0062] In operation S230 , the plurality of code segments are combined according to at least one segmentation position to generate a target code.

[0063] According to an embodiment of the present disclosure, a dynamic link library file is a binary program file that allows programs to share code and other resources necessary to perform specific tasks.

[0064] In some embodiments, before performing operation S210, a reverse analysis tool may be used to disassemble and reverse analyze the dynamic link library file to obtain pseudo code. The acquisition of the dynamic link library file and the use of the dynamic link library file for reverse engineering have both been approved or authorized by the relevant user and are in compliance with relevant laws and regulations and do not violate public order and good morals.

[0065] For example, a reverse analysis tool can be used to disassemble a dynamic link library file to generate assembly code. Then, the reverse analysis tool can be used to reverse analyze the assembly code to generate pseudocode. This pseudocode indicates the logical relationship between the function names in the dynamic link library file and the execution statements within each function.

[0066] However, since dynamic link libraries are binary files compiled from source code, the compilation process may optimize the compilation process by modifying various source code structures and converting certain variables into debugging symbols. Consequently, the pseudocode obtained through disassembly and reverse engineering can contain various errors, such as missing symbols, disorganized structures, missing or incorrect data types, and unrecognized high-level language features.

[0067] Therefore, the pseudo code of the dynamic link library file can be segmented to obtain multiple pseudo code segments and at least one segmentation position, so that the length of each pseudo code segment meets the input length requirement of the large model.

[0068] When segmenting the pseudocode, the segmentation can be based on the input length requirement of the large model, the function names indicated in the pseudocode, or the logical relationships between the execution units in the functions indicated in the pseudocode. The segmentation method of the pseudocode can be determined based on the actual requirements of reverse analysis of dynamic link library files under different system architectures, and the embodiments of the present disclosure do not specifically limit this.

[0069] When the pseudocode is segmented to obtain multiple pseudocode fragments, the segmentation positions can be marked at the same time.

[0070] According to an embodiment of the present disclosure, errors in multiple pseudo code snippets are corrected respectively based on a large model to generate multiple code snippets.

[0071] For example, the large model can be a large language model trained for a pseudocode correction task. The training data for this task can be pseudocode generated by disassembling and reverse-analyzing dynamic link library files for different system architectures using reverse engineering tools. This allows the large model to learn the differences between the pseudocode and source code of dynamic link library files for different system architectures and to correct for these differences.

[0072] Since segmenting pseudocode may destroy the semantic relationship between previous and next fields, this relationship generally does not affect the large-scale model's ability to correct pseudocode snippets. However, to further improve correction accuracy, the pseudocode snippets can be fed into the large-scale model in the same order as before segmentation. This allows the large-scale model to provide a reference for the current pseudocode snippet based on the correction results of the previous pseudocode snippet.

[0073] For example, if the i-th pseudocode snippet corrects a missing variable, the corrected variable should be the same across all statements in the same function. Therefore, when correcting missing variables for the i+1-th pseudocode snippet, the correction result from the i-th pseudocode snippet can be prioritized to improve correction efficiency. 1 < i < N, where N is the total number of pseudocode snippets.

[0074] In some embodiments, for multiple pseudocode segments obtained by segmentation based on length, the modified code segments can be combined according to the segmentation position marks to generate the target code. For multiple pseudocode segments obtained by segmentation based on function names, the modified code segments can be combined according to the function names to generate the target code.

[0075] For target code, other types of large models can also be called, such as Wenxin Yiyan, to verify the target code, including but not limited to format and logical relationships, thereby further improving the accuracy of target code generation.

[0076] According to an embodiment of the present disclosure, the target code is used to analyze whether it is safe to run a dynamic link library file in a target system. The target system can be various versions of the Android system or other system architectures, which are not specifically limited in the embodiment of the present disclosure.

[0077] According to the embodiments of the present disclosure, the natural language understanding ability and rich knowledge reserves of the large model are utilized to correct various errors in the pseudocode obtained by disassembling and reverse analyzing the dynamic link library using various reverse analysis tools, thereby improving the readability of the analysis results and the quality and efficiency of reverse engineering.

[0078] Reference below Figures 3 to 5D , combined with specific embodiments Figure 2 The method shown is further explained.

[0079] Figure 3 The figure schematically shows a code generation method based on a large model according to an embodiment of the present disclosure.

[0080] like Figure 3 As shown, in embodiment 300, first, the dynamic link library file 301 is disassembled to obtain assembly instruction code 302. Then, the assembly instruction code 302 is reverse analyzed to obtain pseudo code 303.

[0081] Next, the pseudo code 303 is segmented to obtain n pseudo code segments, which are pseudo code segments P1311 to Pseudo code segments P31311 and ... n Each pseudo code segment is input into the large model 320 for correction, and the corrected code segments C1321 to C132n are output respectively.

[0082] Finally, the code fragments C1321 to C132n are combined according to the segmentation positions to generate the target code 331.

[0083] In some embodiments, since the pseudocode indicates the name of each function in the dynamic link library file, the function name indicated in the pseudocode is the same as the function name in the source code in the dynamic link library. Therefore, when the large model is trained based on the pseudocode correction task, the large model can determine the correction solution for the error in the pseudocode fragment by identifying the function name.

[0084] Therefore, segmenting the pseudocode of the dynamic link library file to obtain various pseudocode fragments and segmentation positions can include the following operations: performing an initial segmentation on the pseudocode according to the name of each function to obtain multiple function blocks; in response to the length of the first function block among the multiple function blocks being less than or equal to a predetermined threshold, determining that the first function block is a first pseudocode fragment, and marking the initial segmentation position for the pseudocode as the first segmentation position; and in response to the length of the second function block among the multiple function blocks being greater than a predetermined threshold, segmenting the second function block again to obtain a second pseudocode fragment, and marking the secondary segmentation position for the second function block as the second segmentation position.

[0085] For example, the pseudocode may include a function block corresponding to the function name F1 and a function block corresponding to the function name F2. The pseudocode may be segmented into function blocks P according to the function names. F1 and function block P F2 .

[0086] Then, the function block P can be F1 and function block P F2 Perform code length detection and determine the predetermined threshold based on the input requirements of the large model.

[0087] When the function block P F1 When the code length of the function block P is less than or equal to the predetermined threshold, it can be determined that the function block P F1 The code length meets the input requirements of the large model, and the function block P F1 This is identified as pseudo code fragment P1.

[0088] When the function block P F2 When the code length of the function block P is greater than a predetermined threshold, it can be determined that the function block P F2 The code length does not meet the input requirements of the large model, and the function block P needs to be F2 The code is segmented again until the length of the segmented code is less than or equal to a predetermined threshold.

[0089] Figure 4A The figure schematically shows a schematic diagram of segmenting pseudo code according to an embodiment of the present disclosure.

[0090] like Figure 4A As shown, the pseudo code [XXXyyyIIjj]303 is split according to the function name to obtain the function block F b1 [XXX] 411. Then, the operation S410 is executed to perform the function block F b1 [XXX]411 performs length detection and determines the function block F b1 [XXX]411 has a length greater than L (predetermined threshold). And the function block F is b1[XXX]411 is split twice to generate a pseudo code segment P1[XX]311 and a pseudo code segment P2[X]312.

[0091] Similarly, the pseudo code [XXXyyyIIjj]303 is split according to the function name to obtain the function block F bm [jj]41m. Then, operation S410 is executed to perform the function block F bm [jj]41m performs length detection and determines function block F bm [jj] The length of 41m is less than L (predetermined threshold). It can be determined that the function block F bm [jj]41m is the pseudo code fragment P n [jj]31n.

[0092] According to the embodiments of the present disclosure, pseudocode is segmented based on function names, with each pseudocode segment containing at least the function name. This facilitates the large model to perform targeted corrections for errors caused by field conversion or missing data during the compilation process for various functions, improving the quality and efficiency of these corrections. Even if function blocks that do not meet the large model's input requirements are segmented again, the large model can still correct each pseudocode segment based on the semantic relevance of the previous and subsequent pseudocode segments, further improving the accuracy of these corrections.

[0093] In some embodiments, since the pseudo code also indicates the execution logic between the execution statements in each function in the dynamic link library file, the second function block is further divided to obtain the pseudo code fragment, which may include the following operations: according to the execution logic relationship between the execution statements in the second function block, the second function block is further divided to obtain the second pseudo code fragment.

[0094] According to an embodiment of the present disclosure, the execution logic relationship between the execution statements in the second pseudo code fragment is complete.

[0095] For example, a function block may contain statements with complex execution logic. Segmenting the function block by length may disrupt the logic between statements. These pseudocode fragments, resulting from these disrupted logic, introduce errors not caused by the compilation process into the larger model, adding interference to the model's correction process. The larger model requires correction based on the logical relationships between multiple pseudocode fragments input before and after. Furthermore, errors generated during the compilation process must be corrected, reducing the efficiency of the larger model's correction of the pseudocode fragments.

[0096] Therefore, when the function block is split again, it can be split according to the execution logic relationship between the execution statements, so that the execution logic relationship between the execution statements in the second pseudo code segment obtained by splitting is complete.

[0097] Figure 4B The figure schematically shows a schematic diagram of segmenting pseudo code according to another embodiment of the present disclosure.

[0098] like Figure 4B As shown, this embodiment is Figure 4A The embodiment shown differs in that the function block F b1 [XttX]412 can be split according to the logical relationship to obtain the pseudo code segment P1[Xt]413 and the pseudo code segment P2[tX]414.

[0099] Since the length of the second pseudo code segment after segmentation according to the logical relationship is usually less than a predetermined threshold, no further segmentation is required.

[0100] According to the embodiments of the present disclosure, the execution logic relationship between the execution statements is not destroyed during the segmentation process, which reduces the interference of the destruction of the execution logic relationship between the execution statements on the large model correction process, and improves the accuracy and efficiency of the large model in correcting the pseudo code fragments.

[0101] The previous article described various errors that exist in the pseudocode. The following describes the process of correcting the large model in detail for each type of error.

[0102] Pseudocode often lacks symbolic information found in the original source code, such as variable names, function names, and comments. This is because the compiled binary may not contain this information, or may only contain some debugging symbols. Therefore, to improve the readability of reverse engineering results, a large model can be used to generate code snippets by supplementing the missing fields based on the semantic relationships between the function names and fields in each pseudocode snippet.

[0103] Figure 5A Schematic diagram showing the use of large models to correct the field missing error in the pseudo code snippet.

[0104] like Figure 5A As shown, the field "!" in pseudocode snippet P1[AX!X] 521a may be a debugging symbol introduced during the compilation of the source code of the dynamic link library file. Therefore, it can be determined that the error in this pseudocode snippet is a missing field error. Pseudocode snippet P1[AX!X] 521a can be input into macromodel 520. Based on the function name corresponding to pseudocode snippet P1[AX!X] 521a, the missing variable corresponding to the field "!" is determined to be "Y." The variable "Y" is then added to the position of "!", generating code snippet C1[AXYX] 522a.

[0105] According to the embodiments of the present disclosure, the errors of missing fields in the pseudocode snippet are corrected based on the trained large model, the symbol information in the source code that is missing from the pseudocode is supplemented, and the readability of the reverse analysis results is further improved.

[0106] The compiler may change the code structure to improve performance during the source code optimization process. Therefore, the code structure of the pseudocode will be different from that of the source code and will not be as intuitive as the source code, resulting in poor readability of the reverse analysis results.

[0107] Therefore, for code structure errors, the large model can be used to correct the erroneous code structure based on the function names in each pseudo code fragment to generate each code fragment.

[0108] Figure 5B The diagram schematically shows how to correct structural errors in a pseudo code snippet using a large model.

[0109] like Figure 5B As shown, there is a structural error in the pseudo-code snippet P2[for(((xxx)if(yyy))if(jjj)]521b. This structural error causes the execution logic of the for loop to be relatively chaotic, which is not conducive to subsequent code security analysis. Therefore, the pseudo-code snippet P2[for(((xxx)if(yyy))if(jjj)]521b can be input into the large model 520. The large model 520 can re-organize the structure of the pseudo-code snippet based on the for loop logic in the function block corresponding to the pseudo-code snippet learned during the training process to generate the code snippet C2[for(xxx / yyy)if(iii)]522b.

[0110] According to the embodiments of the present disclosure, the errors in the code structure in the pseudocode snippet are corrected based on the trained large model, further improving the intuitiveness of the execution logic between the execution statements in the reverse analysis results, and facilitating subsequent code security analysis.

[0111] When using reverse engineering tools to disassemble and reverse analyze binary files, the data types of each execution statement are often inferred based on the context of the assembly code. This can result in missing or incorrect data types in the pseudocode. For example, the source code may contain integer data types, but the pseudocode output by the reverse analysis tool may contain floating-point data types.

[0112] Therefore, for data type errors or omissions, the large model can be used to modify the data type of the first target field based on the function name in each pseudocode snippet to generate each code snippet. The first target field represents the field with the data type error or omission.

[0113] Figure 5CAn illustrative diagram of correcting a data type error in a pseudo code segment by using a large model is shown.

[0114] As shown in Figure 5C , the content in the data type identifier "()" of the variable X in the pseudo code segment P3[AX () X]521c is empty, it can be determined that there is a data type missing error. The pseudo code segment P3[AX () X]521c can be input into the large model 520, and based on the function block data type corresponding to the pseudo code segment learned in the training process, the missing field in the pseudo code segment is supplemented, and the code segment C3[AX (int) X]522c is output.

[0115] According to an embodiment of the present disclosure, the data type error in the pseudo code segment is corrected based on the trained large model, and the readability of each execution statement in the reverse analysis result is further improved.

[0116] In the compilation process, for the high-level language features used in the source code, such as templates, macros, inline assembly, etc., they may be converted into other languages. Therefore, the high-level language features used in the source code may not be completely reproduced in the pseudo code output by the reverse analysis tool.

[0117] Therefore, for programming language feature errors, a large model can be used to correct the programming language features of the second target field based on the function name in each pseudo code segment, and generate each code segment; wherein the second target field represents a field corresponding to at least one of the function template, the macro, and the inline assembly.

[0118] Figure 5D An illustrative diagram of correcting an inline assembly error in a pseudo code segment by using a large model is shown.

[0119] As shown in Figure 5D , the field "$" in the pseudo code segment P4[AX $ X]521d can be a conversion symbol corresponding to inline assembly. For example, when inline assembly is used in the source code, the corresponding field will be replaced with "$" during the compilation process. The pseudo code segment P4[AX $ X]521d can be input into the large model 520, and the large model 520 corrects "$" based on the function name corresponding to the pseudo code segment learned in the training process, and outputs the code segment C4[AX (asm) X]522d.

[0120] According to an embodiment of the present disclosure, the programming language feature error in the pseudo code segment is corrected based on the trained large model, the high-level language features used in the source code, such as templates, macros, or inline assembly, etc. are reproduced, the code readability of the reverse analysis result is further improved, and the difficulty of code security analysis is reduced.

[0121] In practical applications, a pseudocode snippet can contain any of the errors described above, or a combination of multiple errors. The large model can be used to correct all errors in the pseudocode snippet. For combined errors, the large model can be used to correct them together or separately, depending on whether there is coupling between the errors. For uncoupled errors, corrections can be made separately by error type. For coupled errors, corrections can be made together first, then separately by error type. The large model can then be used to combine the results of these two corrections, improving correction accuracy.

[0122] The code snippets corrected using the large model are highly readable. When disassembling and reverse analyzing using reverse analysis tools, the pseudocode retains most of the execution logic relationships in the source code. Therefore, the corrected code snippets can be combined according to the original segmentation positions to reproduce the execution logic and code structure of the source code as much as possible.

[0123] Therefore, combining multiple code fragments according to at least one segmentation position to generate target code can include the following operations: combining multiple code fragments corresponding to the same function according to at least one segmentation position to generate multiple function blocks; and combining multiple function blocks according to at least one segmentation position to generate target code.

[0124] For example, function block F1 is split into two pseudocode snippets at split position 1. After using the large model to correct errors in these two snippets, code snippets 1-1 and 1-2 are generated. Similarly, function block F2 is split into two pseudocode snippets at split position 2. After using the large model to correct errors in these two snippets, code snippets 2-1 and 2-2 are generated.

[0125] According to the split position 1, code fragment 1-1 and code fragment 1-2 can be combined to obtain function block F1. Similarly, according to the split position 2, code fragment 2-1 and code fragment 2-2 can be combined to obtain function block F2.

[0126] Then, based on the segmentation positions of the function block F1 and the function block F2, the function block F1 and the function block F2 or other function blocks are respectively combined to generate target code.

[0127] According to an embodiment of the present disclosure, for pseudocodes with a long length, the code segments are first combined into function blocks according to the segmentation positions and then combined according to the function blocks, which can improve the reorganization efficiency and reorganization accuracy of the code segments.

[0128] Figure 6 The flowchart of the large model training method according to an embodiment of the present disclosure is schematically shown.

[0129] like Figure 6 As shown, the training method 600 may include operations S610 to S640.

[0130] In operation S610 , the pseudo code of the sample dynamic link library file is segmented to obtain a plurality of sample pseudo code segments and at least one sample segmentation position.

[0131] In operation S620 , errors in the plurality of sample pseudo code segments are corrected respectively based on the initial large model to generate a plurality of sample code segments.

[0132] In operation S630 , based on the target loss function, a loss value is generated according to each source code segment of the sample dynamic link library and each sample code segment.

[0133] In operation S640 , model parameters of the initial large model are adjusted based on the loss value to obtain a large model.

[0134] According to an embodiment of the present disclosure, the sample pseudocode is obtained by disassembling and reverse-engineering a sample dynamic link library file. The sample dynamic link library file can be a dynamic link library file for different architecture systems. The training data can include source code snippets and sample pseudocode snippets of the sample dynamic link library file.

[0135] Each source code snippet can be obtained by segmenting the source code according to a segmentation rule. Each sample pseudocode snippet can be obtained by segmenting the pseudocode according to the same segmentation rule. Therefore, the segmentation position of each source code snippet and the segmentation position of each sample pseudocode snippet can be the same.

[0136] The reverse analysis tool described above can be used to disassemble and reverse analyze the sample dynamic link library file. The definition range of the sample pseudocode is the same as that of the pseudocode described above, so it will not be repeated here.

[0137] During the training process, a phased training approach can be employed. For example, first training on a pseudocode snippet with a single error to obtain an intermediate model. Then, training on a pseudocode snippet with a combination of errors to obtain the final large model. This training process results in a large model with higher correction accuracy.

[0138] During the training process, it is also possible to directly train based on the pseudo code snippets with combined errors to obtain the final large model. This training process has a shorter training cycle and higher training efficiency.

[0139] According to an embodiment of the present disclosure, the target loss function may be a cross entropy loss function or other loss functions that can be used for neural network model training, and the present disclosure does not make specific limitations on this.

[0140] In some embodiments, the maximum number of training times can be used as a termination condition, and the loss value convergence can also be used as a termination condition. The training termination condition can be set based on the actual requirements of the application scenario, and the present disclosure does not make specific limitations thereto.

[0141] According to embodiments of the present disclosure, the initial large model can be a large language model. Through training, the large language model can learn the ability to correct the reverse analysis result, thereby improving the reverse capability of the large language model and realizing the application of the large language model in the field of reverse engineering.

[0142] Figure 7 A flowchart of a detection method of a dynamic link library file according to an embodiment of the present disclosure is schematically shown.

[0143] As shown in Figure 7 , the detection method 700 can include operations S710-S720.

[0144] At operation S710, the object code of the dynamic link library file is obtained.

[0145] At operation S720, the object code is detected to generate a detection result.

[0146] According to embodiments of the present disclosure, the object code is generated by the large model-based code generation method described above.

[0147] In some embodiments, the object code can be detected by using any code security detection tool to generate a detection result. The detection result is used to represent whether it is safe to run the dynamic link library file in the target system. The target system can be an Android system.

[0148] According to embodiments of the present disclosure, the object code generated by correcting the reverse tool analysis result by using the large model reproduces the execution logic, code structure, and high-level language characteristics of the source code of the dynamic link library file, which are used for security detection. Therefore, the accuracy of the detection result can be improved.

[0149] Figure 8 A block diagram of a large model-based code generation apparatus according to an embodiment of the present disclosure is schematically shown.

[0150] As shown in Figure 8 , the code generation apparatus 800 can include a first segmentation module 810, a first correction module 820, and a combination module 830.

[0151] The first segmentation module 810 is configured to segment the pseudo code of the dynamic link library file to obtain a plurality of pseudo code segments and at least one segmentation position. The pseudo code is obtained by disassembling and reverse analyzing the dynamic link library file.

[0152] The first correction module 820 is configured to correct errors in the plurality of pseudo code segments based on the large model respectively, and generate a plurality of code segments.

[0153] The combination module 830 is configured to combine the plurality of code segments according to at least one split position, and generate target code. The target code is used to analyze whether the dynamic link library file is safe when running in the target system.

[0154] According to an embodiment of the present disclosure, the errors include missing fields, and the first correction module includes a first correction submodule. The first correction submodule is configured to supplement the missing fields based on semantic relationships between function names and fields in each pseudo code segment by using the large model, and generate each code segment.

[0155] According to an embodiment of the present disclosure, the errors include code structure errors, and the first correction module includes a second correction submodule. The second correction submodule is configured to correct the error code structure based on the function names in each pseudo code segment by using the large model, and generate each code segment.

[0156] According to an embodiment of the present disclosure, the errors include data type errors or missing, and the first correction module includes a third correction submodule. The third correction submodule is configured to correct the data type of a first target field based on the function names in each pseudo code segment by using the large model, and generate each code segment. The first target field represents a field with a data type error or missing.

[0157] According to an embodiment of the present disclosure, the errors include programming language feature errors, and the first correction module includes a fourth correction submodule. The fourth correction submodule is configured to correct the programming language feature of a second target field based on the function names in each pseudo code segment by using the large model, and generate each code segment. The second target field represents a field corresponding to at least one of a function template, a macro, and inline assembly.

[0158] According to an embodiment of the present disclosure, the pseudo code indicates the names of the functions in the dynamic link library file. The first split module includes a first split submodule, a determination submodule, and a second split submodule.

[0159] The first split submodule is configured to perform a preliminary split on the pseudo code according to the names of the functions, and obtain a plurality of function blocks.

[0160] The determination submodule is configured to, in response to a length of a first function block in the plurality of function blocks being less than or equal to a predetermined threshold, determine that the first function block is a first pseudo code segment, and mark a preliminary split position of the pseudo code as a first split position.

[0161] The second segmentation submodule is used to re-segment the second function block in response to the length of the second function block among the multiple function blocks being greater than a predetermined threshold to obtain a second pseudo code fragment, and mark the re-segmentation position for the second function block as the second segmentation position.

[0162] According to an embodiment of the present disclosure, the pseudo code also indicates the execution logic relationship between the execution statements in the functions in the dynamic link library file. The second segmentation submodule includes: a first segmentation unit and a second segmentation unit.

[0163] The first segmentation unit is used to segment the second function block again to obtain pseudo code fragments.

[0164] The second segmentation unit is used to segment the second function block again according to the execution logic relationship between the execution statements in the second function block to obtain a second pseudo code fragment; wherein the execution logic relationship between the execution statements in the second pseudo code fragment is complete.

[0165] According to an embodiment of the present disclosure, a combination module includes: a first combination submodule and a second combination submodule. The first combination submodule is configured to combine multiple code snippets corresponding to the same function according to at least one segmentation position to generate multiple function blocks. The second combination submodule is configured to combine multiple function blocks according to at least one segmentation position to generate target code.

[0166] Figure 9 A block diagram of a large model training device according to an embodiment of the present disclosure is schematically shown.

[0167] like Figure 9 As shown, the training device 900 may include: a second segmentation module 910 , a second correction module 920 , a loss calculation module 930 and an adjustment module 940 .

[0168] The second segmentation module 910 is used to segment the pseudo code of the sample dynamic link library file to obtain multiple sample pseudo code segments and at least one sample segmentation position; wherein the sample pseudo code is obtained by disassembling and reverse analyzing the sample dynamic link library file.

[0169] The second correction module 920 is configured to correct errors in the plurality of sample pseudo-code segments based on the initial large model, and generate a plurality of sample code segments.

[0170] The loss calculation module 930 is used to generate a loss value based on the target loss function according to each source code fragment of the sample dynamic link library and each sample code fragment; wherein the segmentation position of each source code fragment is the same as the segmentation position of each sample pseudocode fragment.

[0171] The adjustment module 940 is used to adjust the model parameters of the initial large model based on the loss value to obtain the large model.

[0172] Figure 10 A block diagram schematically shows a device for detecting a dynamic link library file according to an embodiment of the present disclosure.

[0173] like Figure 10 As shown, the detection device 1000 may include an acquisition module 1010 and a detection module 1020 .

[0174] The acquisition module 1010 is used to acquire the target code of the dynamic link library file, wherein the target code is generated by using the large model-based code generation method described above.

[0175] The detection module 1020 is used to detect the target code and generate a detection result; wherein the detection result is used to indicate whether it is safe to run the dynamic link library file in the target system.

[0176] Figure 11 A block diagram of an artificial intelligence agent according to an embodiment of the present disclosure is schematically shown.

[0177] In the embodiments of the present disclosure, inspired by the von Neumann structure in modern computer theory, such as Figure 11 As shown, the AI ​​agent 1100 may include three core modules: an input module 1110, an output module 1120, and a processing module 1130. The processing module 1130 may include a control unit 1131, a storage unit 1132, and an operation unit 1133.

[0178] Input module 1110 is responsible for receiving or perceiving information such as queries, requests, instructions, signals, or data from the outside world (e.g., users or the external environment) and converting it into a format that AI agent 1100 can understand and process. Input module 1110 is the primary link for AI agent 1100 to interact with the outside world. It enables AI agent 1100 to efficiently and accurately obtain necessary "sensory" information from the outside world and respond to this information.

[0179] In an example, the input information received by the input module 1110 may be the dynamic link library file described above, or may be pseudo code output by a reverse analysis tool.

[0180] In this example, processing module 1130 is the core support for AI agent 1100's ability to handle complex tasks. Processing module 1130 can determine a target task based on the input information received by input module 1010, determine a large model based on the target task, and execute the large model-based code generation method described above by calling the large model to output target code.

[0181] In the example, the control unit 1131 in the processing module 1130 will continuously interact with the storage unit 1132, the computing unit 1133, and / or the output module 1120 during operation. However, it should be noted that in the embodiment of the present disclosure, the control unit 1131 acts as a single initiator to initiate communication with the storage unit 1132, the computing unit 1133, and / or the output module 1120, and there is no communication coupling between the storage unit 1132, the computing unit 1133, and the output module 1120.

[0182] In this example, the performance of control unit 1131 can be closely related to the large model on which AI agent 1100 is based. To fully utilize the capabilities of the large language model, the internal structure of control unit 1131 can be designed to be highly configurable and scalable to cope with various types of tasks and requirements in real-world scenarios.

[0183] The storage unit 1132 may be responsible for memorizing information such as historical conversations, event flows, etc. The target code generated in each round as described above may be included in the storage unit 1132 .

[0184] In the example, after the AI ​​agent 1100 obtains the code generation request, the AI ​​agent 1100 can use the reverse analysis tool to disassemble and reverse analyze the dynamic link library file to generate pseudocode. The pseudocode can be stored in the storage unit 1132. The AI ​​agent 1100 can retrieve the relevant code resources from the storage unit 1132 and feed it back to the control unit 1131. Then, the control unit 1131 can use the fed-back code resources to obtain the corrected content corresponding to the pseudocode and combine it to obtain the target code. It can also retrieve the relevant code resources from the storage unit 1132 and feed it back to the control unit 1131. Then, the control unit 1131 can use the returned code resources to obtain the corrected content corresponding to the pseudocode and combine it to obtain the target code. And pass the target code to the output module 1120.

[0185] The computing unit 1133 can be viewed as a predefined tool library, and the renderer and presentation controls mentioned above can be included in the computing unit 1133 .

[0186] In the example, when the AI ​​agent 1100 needs to render multiple output data, it can call the relevant renderer and display control from the operation unit 1133 and feed it back to the control unit 1132. Then, the control unit 1132 can use the feedback renderer and display control to render the first search result and pass the first search result to the output module 1120. It can be understood that although the large language model has excellent language understanding and generation capabilities, it is the same as a human. Without the help of any tools, the tasks that can be solved are very limited. When the AI ​​agent 1100 is given the ability to call tools, it can achieve tasks such as completing mathematical operations with the help of a calculator, completing data analysis with the help of Python, and completing prediction tasks with the help of a search engine.

[0187] In an example, the output module 1120 may output the target code described above.

[0188] The AI ​​agent 1100 according to the embodiment of the present disclosure can simply and effectively improve the level of intelligence, and enhance flexibility and versatility.

[0189] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0190] According to an embodiment of the present disclosure, an electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method described above.

[0191] According to an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the method described above.

[0192] According to an embodiment of the present disclosure, a computer program product includes a computer program, and when the computer program is executed by a processor, it implements the method described above.

[0193] Figure 12 A schematic block diagram of an example electronic device 1200 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are provided as examples only and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0194] like Figure 12 As shown, device 1200 includes a computing unit 1201, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1202 or a computer program loaded from a storage unit 1208 into a random access memory (RAM) 1203. RAM 1203 may also store various programs and data required for the operation of device 1200. Computing unit 1201, ROM 1202, and RAM 1203 are connected to each other via a bus 1204. An input / output (I / O) interface 1205 is also connected to bus 1204.

[0195] Various components in device 1200 are connected to I / O interface 1205, including an input unit 1206, such as a keyboard and mouse; an output unit 1207, such as various types of displays and speakers; a storage unit 1208, such as a magnetic disk and optical disk; and a communication unit 1209, such as a network card, a modem, a wireless communication transceiver, etc. Communication unit 1209 allows device 1200 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0196] Computing unit 1201 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of computing unit 1201 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Computing unit 1201 performs the various methods and processes described above, such as the large model-based code generation method, training method, or detection method. For example, in some embodiments, the large model-based code generation method, training method, or detection method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as storage unit 1208. In some embodiments, part or all of the computer program can be loaded and / or installed onto device 1200 via ROM 1202 and / or communication unit 1209. When the computer program is loaded into RAM 1203 and executed by computing unit 1201, one or more steps of the large model-based code generation method, training method, or detection method described above can be performed. Alternatively, in other embodiments, the computing unit 1201 may be configured to execute a large model-based code generation method, a training method, or a detection method in any other appropriate manner (eg, by means of firmware).

[0197] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-a-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0198] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0199] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fibers, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0200] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0201] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0202] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact through a communication network. The client-server relationship arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server in a distributed system, or a server integrated with a blockchain.

[0203] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not a limitation herein.

[0204] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.

Claims

1. A code generation method based on a large model, comprising: According to the names of the functions, the pseudo code of the dynamic link library file is initially segmented to obtain multiple function blocks; In response to a length of a first function block among the multiple function blocks being less than or equal to a predetermined threshold, determining that the first function block is a first pseudocode segment, and marking an initial segmentation position for the pseudocode as a first segmentation position; In response to a length of a second function block among the plurality of function blocks being greater than a predetermined threshold, The second function block is further divided according to the execution logic relationship between the execution statements in the second function block to obtain a second pseudo-code fragment, and the second division position of the second function block is marked as the second division position; wherein the pseudo-code is obtained by disassembling and reverse analyzing the dynamic link library file; the pseudo-code indicates the name of each function in the dynamic link library file and the execution logic relationship between each execution statement in each function in the dynamic link library file; the execution logic relationship between each execution statement in the second pseudo-code fragment is complete; Correcting errors in the plurality of pseudo-code snippets based on the large model to generate a plurality of code snippets; and The multiple code fragments are combined according to at least one segmentation position to generate a target code; the target code is used to analyze whether it is safe to run the dynamic link library file in the target system.

2. The method according to claim 1, wherein Said errors include missing fields; The correcting errors in the plurality of pseudo-code snippets based on the large model respectively includes: The large model is used to supplement missing fields based on the semantic relationship between the function names and the fields in each pseudo-code fragment to generate each code fragment.

3. The method according to claim 2, wherein: The errors include code structure errors; The correcting errors in the plurality of pseudo-code snippets based on the large model respectively includes: By utilizing the large model, the erroneous code structure is corrected based on the function names in each pseudo code fragment to generate each code fragment.

4. The method according to claim 3, wherein: The errors include: incorrect or missing data types; The correcting errors in the plurality of pseudo-code snippets based on the large model respectively includes: The large model is used to modify the data type of the first target field based on the function name in each pseudo-code snippet to generate each code snippet; wherein the first target field represents a field with an incorrect or missing data type.

5. The method according to any one of claims 1 to 4, wherein The errors include programming language feature errors; The correcting errors in the plurality of pseudo-code snippets based on the large model respectively includes: The large model is used to modify the programming language characteristics of the second target field based on the function name in each pseudocode fragment to generate the code fragments; wherein the second target field represents a field corresponding to at least one of a function template, a macro and an inline assembly.

6. The method according to claim 1, wherein The step of combining the multiple code fragments according to at least one segmentation position to generate a target code includes: Combining multiple code snippets corresponding to the same function according to the at least one segmentation position to generate multiple function blocks; and According to the at least one segmentation position, multiple function blocks are combined to generate the target code.

7. A large model training method comprising: According to the names of the functions, the sample pseudo code of the sample dynamic link library file is initially segmented to obtain a plurality of sample function blocks; In response to a length of a first sample function block among the plurality of sample function blocks being less than or equal to a predetermined threshold, determining that the first sample function block is a first sample pseudo-code segment, and marking an initial segmentation position for the sample pseudo-code as a first sample segmentation position; In response to a length of a second sample function block among the plurality of sample function blocks being greater than a predetermined threshold, the second sample function block is further segmented according to the execution logic relationship between the execution statements in the second sample function block to obtain a second sample pseudo-code fragment, and the re-segmentation position for the second sample function block is marked as a second sample segmentation position; wherein the sample pseudo-code is obtained by disassembling and reverse-analyzing the sample dynamic link library file; the sample pseudo-code indicates the name of each function in the sample dynamic link library file and the execution logic relationship between each execution statement in each function in the sample dynamic link library file; the execution logic relationship between each execution statement in the second sample pseudo-code fragment is complete; Correcting errors in the plurality of sample pseudo-code segments based on the initial large model to generate a plurality of sample code segments; Based on the target loss function, generating a loss value according to each source code segment of the sample dynamic link library and each sample code segment; wherein the segmentation position of each source code segment is the same as the segmentation position of each sample pseudo-code segment; and The model parameters of the initial large model are adjusted based on the loss value to obtain the large model.

8. A method for detecting a dynamic link library file, comprising: Obtaining an object code of a dynamic link library file, wherein the object code is generated using the method of any one of claims 1 to 6; and The target code is detected to generate a detection result; wherein the detection result is used to indicate whether it is safe to run the dynamic link library file in the target system.

9. A code generation device based on a large model, comprising: The first segmentation module is used to initially segment the pseudo code of the dynamic link library file according to the name of each function to obtain multiple function blocks; In response to a length of a first function block among the multiple function blocks being less than or equal to a predetermined threshold, determining that the first function block is a first pseudocode segment, and marking an initial segmentation position for the pseudocode as a first segmentation position; In response to a length of a second function block among the plurality of function blocks being greater than a predetermined threshold, The second function block is further divided according to the execution logic relationship between the execution statements in the second function block to obtain a second pseudo-code fragment, and the second division position of the second function block is marked as the second division position; wherein the pseudo-code is obtained by disassembling and reverse analyzing the dynamic link library file; the pseudo-code indicates the name of each function in the dynamic link library file and the execution logic relationship between each execution statement in each function in the dynamic link library file; A first correction module is configured to correct errors in the plurality of pseudo code segments based on the large model to generate a plurality of code segments; and The combination module is used to combine the multiple code fragments according to at least one segmentation position to generate a target code; the target code is used to analyze whether it is safe to run the dynamic link library file in the target system.

10. The device according to claim 9, wherein Said errors include missing fields; The first correction module includes: The first correction submodule is used to use the large model to supplement the missing fields based on the semantic relationship between the function names and the fields in each pseudo code fragment to generate the code fragments.

11. The device according to claim 10, wherein The errors include code structure errors; The first correction module includes: The second correction submodule is used to use the large model to correct the erroneous code structure based on the function name in each pseudo code fragment to generate each code fragment.

12. The device according to claim 11, wherein The errors include incorrect or missing data types; The first correction module includes: The third correction submodule is used to use the large model to correct the data type of the first target field based on the function name in each pseudocode fragment to generate the code fragments; wherein the first target field represents a field with an incorrect or missing data type.

13. The device according to any one of claims 9 to 12, wherein: The errors include programming language feature errors; The first correction module includes: A fourth correction submodule is used to use the large model to correct the programming language characteristics of the second target field based on the function name in each pseudocode fragment to generate each code fragment; wherein the second target field represents a field corresponding to at least one of a function template, a macro and an inline assembly.

14. The device according to claim 9, wherein The combined module comprises: A first combining submodule, configured to combine multiple code snippets corresponding to the same function according to the at least one segmentation position to generate multiple function blocks; and The second combining submodule is configured to combine multiple function blocks according to the at least one segmentation position to generate the target code.

15. A large model training device comprising: The second segmentation module is used to initially segment the sample pseudo code of the sample dynamic link library file according to the name of each function to obtain multiple sample function blocks; In response to a length of a first sample function block among the plurality of sample function blocks being less than or equal to a predetermined threshold, determining that the first sample function block is a first sample pseudo-code segment, and marking an initial segmentation position for the sample pseudo-code as a first sample segmentation position; In response to a length of a second sample function block among the plurality of sample function blocks being greater than a predetermined threshold, the second sample function block is further segmented according to the execution logic relationship between the execution statements in the second sample function block to obtain a second sample pseudo-code fragment, and the re-segmentation position for the second sample function block is marked as a second sample segmentation position; wherein the sample pseudo-code is obtained by disassembling and reverse-analyzing the sample dynamic link library file; the sample pseudo-code indicates the name of each function in the sample dynamic link library file and the execution logic relationship between each execution statement in each function in the sample dynamic link library file; the execution logic relationship between each execution statement in the second sample pseudo-code fragment is complete; A second correction module is used to correct errors in the plurality of sample pseudo-code segments based on the initial large model to generate a plurality of sample code segments; a loss calculation module, configured to generate a loss value based on a target loss function and according to each source code segment of the sample dynamic link library and each sample code segment; wherein the segmentation position of each source code segment is the same as the segmentation position of each sample pseudo-code segment; and An adjustment module is used to adjust the model parameters of the initial large model based on the loss value to obtain the large model.

16. A device for detecting a dynamic link library file, comprising: an acquisition module, configured to acquire the target code of a dynamic link library file, wherein the target code is generated by the method according to any one of claims 1 to 6; The detection module is used to detect the target code and generate a detection result; wherein the detection result is used to indicate whether it is safe to run the dynamic link library file in the target system.

17. An artificial intelligence agent, comprising: An input module, used for receiving input information; a processing module, configured to determine a target task based on the input information received by the input module, determine a large model based on the target task, and execute the method according to any one of claims 1 to 6 by calling the large model to obtain output information; as well as An output module is used to output the output information obtained by the processing module.

18. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.

19. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to enable the computer to execute the method according to any one of claims 1 to 6.

20. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Text error correction method and device, equipment and medium

    CN117217207A

  • Code correction method and device, electronic equipment, storage medium and computer program product

    CN119002884A