|
9 | 9 | from binaryninja.function import Function |
10 | 10 | from binaryninja.lowlevelil import LowLevelILFunction |
11 | 11 | from binaryninja.mediumlevelil import MediumLevelILFunction |
12 | | -from binaryninja.highlevelil import HighLevelILFunction |
| 12 | +from binaryninja.highlevelil import HighLevelILFunction, HighLevelILInstruction |
13 | 13 | from binaryninja.settings import Settings |
14 | 14 | from binaryninja import log, BinaryView |
15 | 15 |
|
|
19 | 19 |
|
20 | 20 | class Agent: |
21 | 21 |
|
22 | | - question: str = ''' |
| 22 | + function_question: str = ''' |
23 | 23 | This is a function that was decompiled with Binary Ninja. |
24 | 24 | It is in IL_FORM. What does this function do? |
25 | 25 | ''' |
26 | 26 |
|
| 27 | + rename_variable_question: str = ''' |
| 28 | + In one word, what should the variable name be for the variable that is |
| 29 | + assigned to the result of the C expression:\n |
| 30 | + ''' |
| 31 | + |
27 | 32 | # A mapping of IL forms to their names. |
28 | 33 | il_name: dict[type, str] = { |
29 | 34 | LowLevelILFunction: 'Low Level Intermediate Language', |
@@ -140,18 +145,25 @@ def generate_query(self, function: Union[Function, |
140 | 145 | LowLevelILFunction, |
141 | 146 | MediumLevelILFunction, |
142 | 147 | HighLevelILFunction]) -> str: |
143 | | - '''Generates a query string given a BNIL function. Reads the file |
144 | | - prompt.txt and replaces the IL form with the name of the IL form. |
| 148 | + '''Generates a query string given a BNIL function. Returns the query as |
| 149 | + a string. |
145 | 150 | ''' |
146 | | - prompt: str = self.question |
| 151 | + prompt: str = self.function_question |
147 | 152 | # Read the prompt from the text file. |
148 | | - prompt = self.question.replace('IL_FORM', self.il_name[type(function)]) |
| 153 | + prompt = prompt.replace('IL_FORM', self.il_name[type(function)]) |
149 | 154 | # Add some new lines. Maybe not necessary. |
150 | 155 | prompt += '\n\n' |
151 | 156 | # Add the instructions to the prompt. |
152 | 157 | prompt += '\n'.join(self.instruction_list(function)) |
153 | 158 | return prompt |
154 | 159 |
|
| 160 | + def generate_rename_expression_query( |
| 161 | + instruction: HighLevelILInstruction) -> str: |
| 162 | + '''Generates a query string given a BNIL instruction. Returns the query |
| 163 | + as a string. |
| 164 | + ''' |
| 165 | + pass |
| 166 | + |
155 | 167 | def send_query(self, query: str) -> None: |
156 | 168 | '''Sends a query to the engine and prints the response.''' |
157 | 169 | query = Query(query_string=query, |
|
0 commit comments