IDA SDK

- Main Page
- Header Files
- Classes
- Modules

- File List
- File Members

Classes | Macros | Typedefs | Variables
netnode.hpp File Reference

## Detailed Description

Functions that provide the lowest level public interface to the database.

(Namely, Btree). To learn more about Balanced Trees: http://www.bluerwhite.org/btree/

We don't use Btree directly. Instead, we have another layer built on the top of Btree. Here is a brief explanation of this layer.

An object called "netnode" is modeled on the top of Btree. Each netnode has a unique id: a 32-bit value (64-bit for ida64). Usually there is a trivial mapping of the linear addresses used in the program to netnodes. If we have additional information about an address (a comment is attached to it, for example), this information is stored in the corresponding netnode. See nalt.hpp to see how the kernel uses netnodes. Also, some netnodes have no corresponding linear address (however, they still have an id). They are used to store information not related to a particular address.

Each netnode _may_ have the following attributes:

- a name: an arbitrary non-empty string, up to 255KB-1 bytes
- a value: arbitrary sized object, max size is MAXSPECSIZE
- altvals: a sparse array of 32-bit values. indexes in this array may be 8-bit or 32-bit values
- supvals: an array of arbitrary sized objects. (size of each object is limited by MAXSPECSIZE) indexes in this array may be 8-bit or 32-bit values
- charvals: a sparse array of 8-bit values. indexes in this array may be 8-bit or 32-bit values
- hashvals: a hash (an associative array). indexes in this array are strings values are arbitrary sized (max size is MAXSPECSIZE)

Initially a new netnode contains no information at all so no disk space is used for it. As you add new information, the netnode grows.

All arrays that are attached to the netnode behave in the same manner. Initially:

- all members of altvals/charvals array are zeroes
- all members of supvals/hashvals array are undefined

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.

You may use netnodes to store additional information about the program. Limitations on the use of netnodes are the following:

- use netnodes only if you could not find a kernel service to store your type of information
- do not create netnodes with valid identifier names. Use the "$ " prefix (or any other prefix with characters not allowed in the identifiers for the names of your netnodes. Although you will probably not destroy anything by accident, using already defined names for the names of your netnodes is still discouraged.
- you may create as many netnodes as you want (creation of an unnamed netnode does not increase the size of the database). however, since each netnode has a number, creating too many netnodes could lead to the exhaustion of the netnode numbers (the numbering starts at 0xFF000000)
- remember that netnodes are automatically saved to the disk by the kernel.

Advanced info:

In fact a netnode may contain up to 256 arrays of arbitrary sized objects (not only the 4 listed above). Each array has an 8-bit tag. Usually tags are represented by character constants. For example, altvals and supvals are simply 2 of 256 arrays, with the tags 'A' and 'S' respectively.

## Classes
class | netnode
| Definition of the IDA database node. More...

## Functions
Helper functions
They should not be called directly! See netnode
idaman bool ida_export | netnode_check (netnode *, const char *name, size_t namlen, bool create)
idaman void ida_export | netnode_kill (netnode *)
idaman bool ida_export | netnode_start (netnode *)
idaman bool ida_export | netnode_end (netnode *)
idaman bool ida_export | netnode_next (netnode *)
idaman bool ida_export | netnode_prev (netnode *)
idaman ssize_t ida_export | netnode_name (nodeidx_t num, char *buf, size_t bufsize)
idaman ssize_t ida_export | netnode_get_name (nodeidx_t num, qstring *out)
idaman bool ida_export | netnode_rename (nodeidx_t num, const char *newname, size_t namlen)
idaman ssize_t ida_export | netnode_valobj (nodeidx_t num, void *buf, size_t bufsize)
idaman ssize_t ida_export | netnode_valstr (nodeidx_t num, char *buf, size_t bufsize)
idaman bool ida_export | netnode_set (nodeidx_t num, const void *value, size_t length)
idaman bool ida_export | netnode_delvalue (nodeidx_t num)
idaman nodeidx_t ida_export | netnode_altval (nodeidx_t num, nodeidx_t alt, char tag)
idaman uchar ida_export | netnode_charval (nodeidx_t num, nodeidx_t alt, char tag)
idaman nodeidx_t ida_export | netnode_altval_idx8 (nodeidx_t num, uchar alt, char tag)
idaman uchar ida_export | netnode_charval_idx8 (nodeidx_t num, uchar alt, char tag)
idaman ssize_t ida_export | netnode_supval (nodeidx_t num, nodeidx_t alt, void *buf, size_t bufsize, char tag)
idaman ssize_t ida_export | netnode_supstr (nodeidx_t num, nodeidx_t alt, char *buf, size_t bufsize, char tag)
idaman bool ida_export | netnode_supset (nodeidx_t num, nodeidx_t alt, const void *value, size_t length, char tag)
idaman bool ida_export | netnode_supdel (nodeidx_t num, nodeidx_t alt, char tag)
idaman nodeidx_t ida_export | netnode_sup1st (nodeidx_t num, char tag)
idaman nodeidx_t ida_export | netnode_supnxt (nodeidx_t num, nodeidx_t cur, char tag)
idaman nodeidx_t ida_export | netnode_suplast (nodeidx_t num, char tag)
idaman nodeidx_t ida_export | netnode_supprev (nodeidx_t num, nodeidx_t cur, char tag)
idaman ssize_t ida_export | netnode_supval_idx8 (nodeidx_t num, uchar alt, void *buf, size_t bufsize, char tag)
idaman ssize_t ida_export | netnode_supstr_idx8 (nodeidx_t num, uchar alt, char *buf, size_t bufsize, char tag)
idaman bool ida_export | netnode_supset_idx8 (nodeidx_t num, uchar alt, const void *value, size_t length, char tag)
idaman bool ida_export | netnode_supdel_idx8 (nodeidx_t num, uchar alt, char tag)
idaman nodeidx_t ida_export | netnode_sup1st_idx8 (nodeidx_t num, char tag)
idaman nodeidx_t ida_export | netnode_supnxt_idx8 (nodeidx_t num, uchar alt, char tag)
idaman nodeidx_t ida_export | netnode_suplast_idx8 (nodeidx_t num, char tag)
idaman nodeidx_t ida_export | netnode_supprev_idx8 (nodeidx_t num, uchar alt, char tag)
idaman bool ida_export | netnode_supdel_all (nodeidx_t num, char tag)
idaman int ida_export | netnode_supdel_range (nodeidx_t num, nodeidx_t idx1, nodeidx_t idx2, char tag)
idaman int ida_export | netnode_supdel_range_idx8 (nodeidx_t num, nodeidx_t idx1, nodeidx_t idx2, char tag)
idaman ssize_t ida_export | netnode_hashval (nodeidx_t num, const char *idx, void *buf, size_t bufsize, char tag)
idaman ssize_t ida_export | netnode_hashstr (nodeidx_t num, const char *idx, char *buf, size_t bufsize, char tag)
idaman nodeidx_t ida_export | netnode_hashval_long (nodeidx_t num, const char *idx, char tag)
idaman bool ida_export | netnode_hashset (nodeidx_t num, const char *idx, const void *value, size_t length, char tag)
idaman bool ida_export | netnode_hashdel (nodeidx_t num, const char *idx, char tag)
idaman ssize_t ida_export | netnode_hash1st (nodeidx_t num, char *buf, size_t bufsize, char tag)
idaman ssize_t ida_export | netnode_hashnxt (nodeidx_t num, const char *idx, char *buf, size_t bufsize, char tag)
idaman ssize_t ida_export | netnode_hashlast (nodeidx_t num, char *buf, size_t bufsize, char tag)
idaman ssize_t ida_export | netnode_hashprev (nodeidx_t num, const char *idx, char *buf, size_t bufsize, char tag)
idaman size_t ida_export | netnode_blobsize (nodeidx_t num, nodeidx_t start, char tag)
idaman void *ida_export | netnode_getblob (nodeidx_t num, void *buf, size_t *bufsize, nodeidx_t start, char tag)
idaman bool ida_export | netnode_setblob (nodeidx_t num, const void *buf, size_t size, nodeidx_t start, char tag)
idaman int ida_export | netnode_delblob (nodeidx_t num, nodeidx_t start, char tag)
idaman bool ida_export | netnode_inited (void)
idaman size_t ida_export | netnode_copy (nodeidx_t num, nodeidx_t count, nodeidx_t target, bool move)
idaman size_t ida_export | netnode_altshift (nodeidx_t num, nodeidx_t from, nodeidx_t to, nodeidx_t size, char tag)
idaman size_t ida_export | netnode_charshift (nodeidx_t num, nodeidx_t from, nodeidx_t to, nodeidx_t size, char tag)
idaman size_t ida_export | netnode_supshift (nodeidx_t num, nodeidx_t from, nodeidx_t to, nodeidx_t size, char tag)
idaman void ida_export | netnode_altadjust (nodeidx_t num, nodeidx_t from, nodeidx_t to, nodeidx_t size, bool(idaapi *should_skip)(nodeidx_t ea))
idaman bool ida_export | netnode_exist (const netnode &n)

## Macros
#define | BADNODE nodeidx_t(-1)
| A number to represent a bad netnode reference.
Internals
Warning The following netnode definitions are for the kernel only. Functions for global base manipulating.
#define | NNBASE_OK 0
#define | NNBASE_REPAIR 1
#define | NNBASE_IOERR 2
#define | NNBASE_PAGE16 3

## Typedefs
typedef uint32 | nodeidx_t
| numbers are 64 bit for 64 bit IDA

## Variables
const int | MAXNAMESIZE = 512
| Maximum length of a netnode name. WILL BE REMOVED IN THE FUTURE.
const int | MAX_NODENAME_SIZE = 32*1024
| Maximum length of a name. We permit names up to 32KB-1 bytes.
const int | MAXSPECSIZE = 1024
| Maximum length of strings or objects stored in a supval array element.
const char | atag = 'A'
| Array of altvals.
const char | stag = 'S'
| Array of supvals.
const char | htag = 'H'
| Array of hashvals.
const char | vtag = 'V'
| Value of netnode.
const char | ntag = 'N'
| Name of netnode.
const char | ltag = 'L'
| Links between netnodes.
idaman netnode ida_export_data | RootNode
| The root node is used by the kernel, do not use it directly in your modules.