()
| 194 | return False |
| 195 | |
| 196 | def strings_init(): |
| 197 | strings_added = 0 |
| 198 | retry = [] |
| 199 | text_seg = get_text_seg() |
| 200 | if text_seg is None: |
| 201 | debug('Failed to get text segment') |
| 202 | return strings_added |
| 203 | |
| 204 | # This may be inherently flawed as it will only search for defined functions |
| 205 | # and as of IDA Pro 6.95 it fails to autoanalyze many GO functions, currently |
| 206 | # this works well since we redefine/find (almost) all the functions prior to |
| 207 | # this being used. Could be worth a strategy rethink later one or on diff archs |
| 208 | |
| 209 | for addr in Functions(text_seg.start_ea, text_seg.end_ea): |
| 210 | name = idc.get_func_name(addr) |
| 211 | |
| 212 | end_addr = next(Chunks(addr))[1] |
| 213 | if end_addr < addr: |
| 214 | error('Unable to find good end for the function %s' % name) |
| 215 | pass |
| 216 | |
| 217 | debug('Found function %s starting/ending @ 0x%x 0x%x' % (name, addr, end_addr)) |
| 218 | |
| 219 | while addr <= end_addr: |
| 220 | if is_string_load(addr): |
| 221 | if 'rodata' not in get_segm_name(addr) and 'text' not in get_segm_name(addr): |
| 222 | debug('Should a string be in the %s section?' % get_segm_name(addr)) |
| 223 | string_addr = idc.get_operand_value(addr, 1) |
| 224 | addr_3 = ida_search.find_code(ida_search.find_code(addr, SEARCH_DOWN), SEARCH_DOWN) |
| 225 | string_len = idc.get_operand_value(addr_3, 1) |
| 226 | if create_string(string_addr, string_len): |
| 227 | if create_offset(addr): |
| 228 | strings_added += 1 |
| 229 | else: |
| 230 | # There appears to be something odd that goes on with IDA making some strings, always works |
| 231 | # the second time, so lets just force a retry... |
| 232 | if string_len < 100: |
| 233 | retry.append((addr, string_addr, string_len)) |
| 234 | |
| 235 | # Skip the extra mov lines since we know it won't be a load on any of them |
| 236 | addr = ida_search.find_code(addr_3, SEARCH_DOWN) |
| 237 | else: |
| 238 | addr = ida_search.find_code(addr, SEARCH_DOWN) |
| 239 | |
| 240 | for instr_addr, string_addr, string_len in retry: |
| 241 | try: |
| 242 | if string_addr > ida_segment.get_last_seg().end_ea: |
| 243 | continue |
| 244 | except: |
| 245 | debug("String retry addr check fallthrough") |
| 246 | if create_string(string_addr, string_len): |
| 247 | if create_offset(instr_addr): |
| 248 | strings_added += 1 |
| 249 | else: |
| 250 | error('FAILED-RETRY : Unable to make a string @ 0x%x with length of %d for usage in function @ 0x%x' % (string_addr, string_len, instr_addr)) |
| 251 | return strings_added |
| 252 | |
| 253 | def main(): |
no test coverage detected