Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Below is the list of available commands:
- [make-comment](#make-comment)
- [make-function](#make-function)
- [make-literal](#make-literal)
- [make-offset](#make-offset)
- [make-unknown](#make-unknown)
- [max-xrefs](#max-xrefs)
- [min-xrefs](#min-xrefs)
Expand Down Expand Up @@ -593,6 +594,25 @@ convert into a literal
options:
-h, --help show this help message and exit
```
## make-offset
```
usage: make-offset [-h] [-l LEN]

convert into an offset EXAMPLE:
0x00000200: 01 02 03 04
0x00000204: 00 02 00 00

results = [0x204]
-> make-offset
results = [0x204]

0x00000200: 01 02 03 04
0x00000204: byte_200

options:
-h, --help show this help message and exit
-l, --len LEN length of offset in bytes
```
## make-unknown
```
usage: make-unknown [-h]
Expand Down
52 changes: 52 additions & 0 deletions fa/commands/make_offset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from fa import context, utils

try:
import ida_auto
import ida_offset
import idaapi
from idc import REF_OFF8, REF_OFF16, REF_OFF32, REF_OFF64
except ImportError:
pass


DESCRIPTION = '''convert into an offset

EXAMPLE:
0x00000200: 01 02 03 04
0x00000204: 00 02 00 00

results = [0x204]
-> make-offset
results = [0x204]

0x00000200: 01 02 03 04
0x00000204: byte_200
'''


def get_parser():
p = utils.ArgumentParserNoExit('make-offset',
description=DESCRIPTION)
p.add_argument('-l', '--len', type=int, default=0, help='length of offset in bytes')
return p


@context.ida_context
def make_offset(addresses: list[int], offset_len: int = 0):
offset_length_to_ref_type = {
0: REF_OFF64 if idaapi.get_inf_structure().is_64bit() else REF_OFF32,
1: REF_OFF8,
2: REF_OFF16,
4: REF_OFF32,
8: REF_OFF64,
}
for ea in addresses:
ida_offset.op_offset(ea, 0, offset_length_to_ref_type[offset_len])

ida_auto.auto_wait()

return addresses


def run(segments, args, addresses, interpreter=None, **kwargs):
return make_offset(addresses, args.len)
1 change: 1 addition & 0 deletions fa/commands/next_instruction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from argparse import ArgumentParser, RawTextHelpFormatter
from typing import Iterable, List, Optional, Tuple

from fa import context, utils

try:
Expand Down
5 changes: 5 additions & 0 deletions ide-completions/sublime/sig.sublime-completions
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@
"kind": "snippet",
"contents": "make-literal "
},
{
"trigger": "make-offset",
"kind": "snippet",
"contents": "make-offset ${1:-l} ${2:LEN}"
},
{
"trigger": "make-unknown",
"kind": "snippet",
Expand Down