``find_all_constant`` searches for the integer constant ``constant`` starting at the virtual address ``start`` until the virtual address ``end``. Once a match is found, the ``match_callback`` is called. .. note:: A ``constant`` is considered used if a line in the linear view expansion of t
( self, start: int, end: int, constant: int, settings: Optional[_function.DisassemblySettings] = None, graph_type: _function.FunctionViewTypeOrName = FunctionGraphType.NormalFunctionGraph, progress_func: Optional[ProgressFuncType] = None, match_callback: Optional[LineMatchCallbackType] = None )
| 9153 | return self.QueueGenerator(t, results) |
| 9154 | |
| 9155 | def find_all_constant( |
| 9156 | self, start: int, end: int, constant: int, settings: Optional[_function.DisassemblySettings] = None, |
| 9157 | graph_type: _function.FunctionViewTypeOrName = FunctionGraphType.NormalFunctionGraph, progress_func: Optional[ProgressFuncType] = None, |
| 9158 | match_callback: Optional[LineMatchCallbackType] = None |
| 9159 | ) -> QueueGenerator: |
| 9160 | """ |
| 9161 | ``find_all_constant`` searches for the integer constant ``constant`` starting at the |
| 9162 | virtual address ``start`` until the virtual address ``end``. Once a match is found, |
| 9163 | the ``match_callback`` is called. |
| 9164 | |
| 9165 | .. note:: A ``constant`` is considered used if a line in the linear view expansion of the given \ |
| 9166 | function graph type contains a token with a value that matches that constant. \ |
| 9167 | This does not search for raw bytes/data in the binary, for that you want to use \ |
| 9168 | :py:func:`find_all_data`. |
| 9169 | |
| 9170 | :param int start: virtual address to start searching from. |
| 9171 | :param int end: virtual address to end the search. |
| 9172 | :param int constant: constant to search for |
| 9173 | :param DisassemblySettings settings: DisassemblySettings object used to render the text \ |
| 9174 | to be searched |
| 9175 | :param FunctionViewType graph_type: the IL to search within |
| 9176 | :param callback progress_func: optional function to be called with the current progress \ |
| 9177 | and total count. This function should return a boolean value that decides whether the \ |
| 9178 | search should continue or stop |
| 9179 | :param callback match_callback: function that gets called when a match is found. The \ |
| 9180 | callback takes two parameters, i.e., the address of the match, and the \ |
| 9181 | LinearDisassemblyLine that contains the matching line. If this parameter is None, \ |
| 9182 | this function becomes a generator and yields the matching address and the \ |
| 9183 | matching LinearDisassemblyLine. This function can return a boolean value that \ |
| 9184 | decides whether the search should continue or stop |
| 9185 | :rtype QueueGenerator: A generator object that will yield all the found results |
| 9186 | """ |
| 9187 | if not isinstance(constant, int): |
| 9188 | raise TypeError("constant parameter is not integral type") |
| 9189 | if settings is None: |
| 9190 | settings = _function.DisassemblySettings() |
| 9191 | settings.set_option(DisassemblyOption.ShowAddress, False) |
| 9192 | settings.set_option(DisassemblyOption.ShowOpcode, False) |
| 9193 | settings.set_option(DisassemblyOption.ShowVariableTypesWhenAssigned, True) |
| 9194 | settings.set_option(DisassemblyOption.WaitForIL, True) |
| 9195 | if not isinstance(settings, _function.DisassemblySettings): |
| 9196 | raise TypeError("settings parameter is not DisassemblySettings type") |
| 9197 | graph_type = _function.FunctionViewType(graph_type)._to_core_struct() |
| 9198 | |
| 9199 | if progress_func: |
| 9200 | progress_func_obj = ctypes.CFUNCTYPE( |
| 9201 | ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong |
| 9202 | )(lambda ctxt, cur, total: progress_func(cur, total)) |
| 9203 | else: |
| 9204 | progress_func_obj = ctypes.CFUNCTYPE( |
| 9205 | ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.c_ulonglong |
| 9206 | )(lambda ctxt, cur, total: True) |
| 9207 | |
| 9208 | if match_callback: |
| 9209 | match_callback_obj = ctypes.CFUNCTYPE( |
| 9210 | ctypes.c_bool, ctypes.c_void_p, ctypes.c_ulonglong, ctypes.POINTER(core.BNLinearDisassemblyLine) |
| 9211 | )(lambda ctxt, addr, line: not match_callback(addr, self._LinearDisassemblyLine_convertor(line)) is False) |
| 9212 |
nothing calls this directly
no test coverage detected