diff options
Diffstat (limited to 'idatui')
| -rw-r--r-- | idatui/app.py | 9 | ||||
| -rw-r--r-- | idatui/domain.py | 10 |
2 files changed, 18 insertions, 1 deletions
diff --git a/idatui/app.py b/idatui/app.py index 570ed0a..cc9ab03 100644 --- a/idatui/app.py +++ b/idatui/app.py @@ -900,6 +900,7 @@ class ListingView(SearchMixin, NavMixin, ColumnCursor, ScrollView, can_focus=Tru Binding("G,end", "goto_bottom", "Bottom", show=False), Binding("c", "define_code", "Code", show=False), Binding("d", "make_data", "Data", show=False), + Binding("a", "make_string", "Str", show=False), Binding("p", "define_func", "Func", show=False), Binding("u", "undefine", "Undef", show=False), *SearchMixin.SEARCH_BINDINGS, @@ -1071,6 +1072,9 @@ class ListingView(SearchMixin, NavMixin, ColumnCursor, ScrollView, can_focus=Tru def action_make_data(self) -> None: self.post_message(MakeDataRequested(self)) + def action_make_string(self) -> None: + self.post_message(EditItemRequested(self, "string")) + def cur_head(self) -> Head | None: return self._head(self.cursor) @@ -3079,12 +3083,15 @@ class IdaTui(App): def _do_edit_item(self, kind: str, ea: int) -> None: # worker context assert self.program is not None verb = {"code": "defined code", "func": "created function", - "undef": "undefined"}[kind] + "undef": "undefined", "string": "made string"}[kind] try: if kind == "code": self.program.define_code(ea) elif kind == "func": self.program.define_func(ea) + elif kind == "string": + s = self.program.make_string(ea) + verb = f"made string ({s[:24]!r})" if s else verb else: self.program.undefine(ea) except Exception as e: # noqa: BLE001 -- surface soft/hard tool errors diff --git a/idatui/domain.py b/idatui/domain.py index 58e4be9..f26354c 100644 --- a/idatui/domain.py +++ b/idatui/domain.py @@ -1127,6 +1127,16 @@ class Program: raise IDAToolError( f"make data @ {ea:#x}: {res.get('error') or 'rejected'}") + def make_string(self, ea: int, length: int = 0, kind: str = "c") -> str: + """Create a string literal at ``ea`` (IDA's 'A'); auto-length when 0. + Returns the decoded contents.""" + r = self.client.call("make_string", addr=hex(ea), length=int(length), kind=kind) + res = r if isinstance(r, dict) else {} + if not res.get("ok"): + raise IDAToolError( + f"make string @ {ea:#x}: {res.get('error') or 'rejected'}") + return res.get("text", "") + def region_label(self, ea: int) -> str: """Display name for a non-function address (segment-qualified).""" try: |
