williballenthin / ida-netnode

Humane API for storing and accessing persistent data in IDA Pro databases
Apache License 2.0
76 stars 17 forks source link

Use getblob/setblob for real arbitrary length data storage #6

Closed nirizr closed 8 years ago

nirizr commented 8 years ago

getblob and setblob are implemented and supported API functions to store data above 4k bytes.

It is advised in IDA's SDK to use those APIs instead of implementing other solutions here:

If you need to store objects bigger that MAXSPECSIZE, please note that there are high-level functions to store arbitrary sized objects in supvals. See setblog/getblob and other blob-related functions.

Using those APIs will benefit this repository tremendously, removing a lot of complicated edge cases and logic.

williballenthin commented 8 years ago

whoa, yes, this is much much better! i really appreciate that you reported this issue. should be a fairly quick fix, resulting in lots of deleted lines. good!

williballenthin commented 8 years ago

looks like getblob is not exported via IDAPython. might have to do some ctypes magic to invoke these routines.

Python>getblob
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'getblob' is not defined
Python>idc.getblob
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'getblob'
Python>idaapi.getblob
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'getblob'
Python>idautils.getblob
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'getblob'

idasdk ctypes reference: http://www.hexblog.com/?p=695

nirizr commented 8 years ago

getblob and setblob are not module level methods. I'm might not have been clear enough. Those are methods of the netnode object and should be used similarly to how hashstr and hashset are used (respectively).

williballenthin commented 8 years ago

(facepalm) yes, of course. thanks!

nirizr commented 8 years ago

happens to the best of us, glad I could help!

williballenthin commented 8 years ago

looking into implementation....

get/setblob accepts only a supval (integer) as a key. so if going to support string keys, will need to keep a mapping from string-key to int-key.

williballenthin commented 8 years ago

need an int-key blobstore and a string-key blobstore. since we don't want string-keys colliding with int-keys when we implement a map from string-key to int-key. propose:

INT_KEYS_TAG = 'M'
STR_KEYS_TAG = 'N'
STR_TO_INT_MAP_TAG = 'O'
nirizr commented 8 years ago

Result's looking good! :)