Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
This command reverts the previously issued Undo command. It is possible to use Redo multiple times.
This command also reverts all changes that were done to the database after the last Undo command, including the eventual useful modifications made by the autoanalysis. In other words, the entire database is modified to get to the exact state that it had before executing the last Undo command.
See also
This submenu allows the user to modify text representation and to patch the file. It also has the commands to control the analysis:
Operand types submenu
Comments submenu
Functions submenu
Structures submenu
Enums submenu
Segments submenu
Patch program submenu
Other submenu
Plugins submenu
See also Menu Bar submenus.
This command converts the current unexplored bytes to data. If it is not possible, IDA will warn you.
Multiple using of this command will change the data type:
You may remove some items from this list using setup data command.
If the target assembler does not support double words or another data type, it will be skipped. To create a structure variable, use Declare struct var command. To create an array, use Array command. To convert back, use Undefine command. See also Edit submenu
This command converts the current unexplored bytes to a string.
The set of allowed characters is specified in the configuration file, parameter StrlitChars. Character '\0' is not allowed in any case. If the current assembler does not allow characters above 0x7F, characters with high bit set are not allowed.
If the anchor has been dropped, IDA will take for the string all characters between the current cursor position and the anchor.
Use the anchor if the string starts a disallowed character.
This command also generates a name for the string. In the configuration file, you can specify the characters allowed in names (NameChars).
You can change the literal string length using Array command.
The GUI version allows you to assign a special hotkey to create Unicode strings. To do so, change the value of the StringUnicode parameter in the IDAGUI.CFG file.
To create Pascal style strings (with first byte indicating string length) use Set String Style command.
See also Edit submenu
This command gives name/renames/deletes name for the current item.
To delete a name, simply give an empty name.
If the current item is referenced, you cannot delete its name. Even if you try, IDA will generate a dummy name.
Local name
Include in name list
Here you can also include/remove the name from the
name list
. If the name is hidden, you will not see it in
names window
.
Public name
Autogenerated name
Weak name
Create name anyway
See also Edit submenu. How to Enter an Identifier. Names representation.
This command converts the current unexplored bytes to instruction(s). IDA will warn you if it is not possible.
If you have selected a range using the anchor, all the bytes from this range will be converted to instructions.
If you apply this command to an instruction, it will be reanalyzed.
See also Edit submenu
This command converts immediate operand(s) type of the current instruction/data to a number. That way, you can delete suspicious mark of the item.
The number is represented in the default radix for the current processor (usually hex, but octal for PDP-11, for example).
When you use this command, IDA deletes the manually entered operand.
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise, all other operands will be affected.
This command converts immediate operand(s) type of the current instruction/data to hex number. So you can delete suspicious mark of the item.
When you use this command, IDA deletes the manually entered operand.
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise, all other operands will be affected.
This command converts the immediate operand(s) type of the current instruction/data to decimal. Therefore, it becomes a 'number'.
When you use this command, IDA deletes the manually entered operand.
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise, all other operands will be affected.
This command makes the current instruction or data operand type octal. IDA always uses 123o notation for octal numbers even if the current assembler does not support octal numbers.
When you use this command, IDA deletes the manually entered operand.
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise, all other operands will be affected.
This command makes the current instruction or data operand type binary. IDA always uses 123b notation for binary numbers even if the current assembler does not support binary numbers.
When you use this command, IDA deletes the manually entered operand.
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise, all other operands will be affected.
This command makes the current operand type floating point.
When you use this command, IDA deletes the manually entered operand.
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise, all other operands will be affected.
This command displays or hides the leading zeroes of the current operand. Example: if the instruction looked like this:
then after applying the command it will look like this:
If you prefer to see leading zeroes in all cases, then open the calculator and enter the following expression: set_inf_attr(INF_GENFLAGS, get_inf_attr(INF_GENFLAGS) | INFFL_LZERO); This will toggle the default for the current database and all numbers without leading zeroes will become numbers with leading zeroes, and vice versa.
See also Edit|Operand types submenu.
This command converts the immediate operand of the current instruction/data to an offset from the current data segment (DS).
If current DS value is unknown (or equal 0xFFFF) IDA will warn you -- it will beep. In this case, you have to define DS register value for the current byte. The best way to do it is:
or you can of DS for the current segment.
If you want to delete offset definition, you can use this command again - it works as trigger.
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise, all other operands will be affected.
If a range is selected using the , IDA will perform 'en masse' conversion. It will convert immediate operands of all instructions in the selected range to offsets. However, IDA will ask you first the lower and upper limits of immediate operand value. If the operand value is >= lower limit and <= upper limit then the operand will be converted to offset, otherwise it will be left unmodified.
To create offsets to structure members use command.
See also:
This command converts the immediate operand of the current instruction/data to an offset from the current segment (CS).
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise, all other operands will be affected.
See also:
This command converts the immediate operand of the current instruction/data to an offset from any segment.
IDA will ask to choose a base segment for the offset.
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise, all other operands will be affected.
See also:
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise, all other operands will be affected.
If the offset base is specified as 0xFFFFFFFF, then IDA will create "an automatic offset". Automatic offsets mean that the actual value of the base will be calculated by IDA.
The following offset attributes are available:
The offset base is dynamically calculated and is equal to the address of the current element:
for standalone items: their start address
for arrays: the start of the array element
See also:
The 'Hide sub structures without sub unions' option (checked by default) avoids to add unnecessary sub structures to the tree, to keep it as small as possible. If you uncheck this option, all sub structures will be added to the tree.
First of all, IDA will ask a so-called "struct offset delta". This value represents the difference between the structure start and the pointer value. For example, if you have an operand 4 and want to convert in into an expression like "mystruct.field_6-2", then you have to enter 2 as the delta. Usually the delta is zero, i.e. the pointer points to the start of the structure.
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise, all other operands will be affected.
See also:
This command converts immediate operand(s) type of the current instruction/data to character.
When you use this command, IDA deletes the entered operand.
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise, all other operands will be affected.
See also submenu.
This submenu allows you to change the operand types to offsets, numbers, chars, etc. Use it to make disassembled text more understandable.
If IDA suspects that an operand can be represented as something different from a plain number, it will mark the operand as "suspicious" and show it in red. Use these commands to delete marks.
Some of these commands can be applied to a selected range. Click to learn about the rules applied to such operations.
See also submenu.
command.
If a range is selected using the , IDA will perform 'en masse' conversion. It will convert immediate operands of all instructions in the selected range to offsets. However, IDA will ask you first the lower and upper limits of immediate operand value. If the operand value is >= lower limit and <= upper limit then the operand will be converted to offset, otherwise, it will be left unmodified.
If this command is applied to a structure member in the , then IDA will create an "automatic offset". An automatic offset is an offset with the base equal to 0xFFFFFFFF. This base value means that the actual value of the base will be calculated by IDA when a structure instance is created.
To create offsets to structure members, use command.
commands.
If a range is selected using the , IDA will perform 'en masse' conversion. It will convert immediate operands of all instructions in the selected range to offsets. However, IDA will ask you first the lower and upper limits of immediate operand value. If the operand value is >= lower limit and <= upper limit then the operand will be converted to offset, otherwise it will be left unmodified.
To create offsets to structure members use command.
commands.
for structures: the start of the structure field The offset expression is displayed in the following concise form: offset target - $ where "$" denotes the start of the element (and is -dependent). To create offsets to structure members use command.
commands.
By default, IDA displays the structure member at offset 0. To change this behaviour, you can directly disable the 'Force zero offset field' in the 'Options' frame. Later zero offsets can be forced using menu item.
This command converts immediate operand(s) type of the current instruction/data to an offset within the specified structure. Before using this command, you have to a structure type.
If a range is selected using the , IDA will perform 'en masse' conversion. It will convert immediate operands of all instructions in the selected range to offsets. However, IDA will ask you first the lower and upper limits of immediate operand value. If the an operand value is >= lower limit and <= upper limit then the operand will be converted to offset, otherwise it will be left unmodified.
When you use this command, IDA deletes the entered operand.
By default IDA doesn't display the structure member at offset 0. To change this behaviour, use command.
Moreover, if there are several possible representations (this can happen if unions are used), select the desired representation using the command.
command.
Related topics: submenu.
This command bit-wisely negates the current operand. Please note that not all types of operands can be negated. It is not possible to negate and change sign of an operand simultaneously.
This command works only if the current assembler supports the bitwise negation operation.
See also: Edit|Operand types submenu. Enter #th operand manually commands. Set operand type
This command converts immediate operand(s) type of the current instruction to an offset to stack variables, i.e. a local variable or function argument in the stack.
You need to define stack variables before using this command.
If the current operand is based on the value of the stack pointer ([ESP+xxx]) and the SP value is traced incorrectly, then you need to correct SP value using change stack pointer command.
If a range is selected using the anchor, IDA will perform 'en masse' conversion. It will convert immediate operands of all instructions in the selected range to stack variables. However, IDA will ask you first the lower and upper limits of immediate operand value. If the operand value is >= lower limit and <= upper limit then the operand will be converted to stack variable, otherwise it will be left unmodified.
When you use this command, IDA deletes the manually entered operand.
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise all other operands will be affected.
See also: Edit|Operand types submenu. Enter #th operand manually commands. Define stack variables...
This command reverts the database to the state before executing the last user action. It is possible to apply Undo multiple times, in this case multiple user actions will be reverted.
Please note the entire database is reverted, including all modifications that were made to the database after executing the user action and including the ones that are not connected to the user action. For example, if a third party plugin modified the database during or after the user action, this modification will be reverted. In theory it is possible to go back in time to the very beginning and revert the database to the state state that was present immediately after performing the very first user action. However, in practice the undo buffers overflow because of the changes made by autoanalysis. Autoanalysis generates copious amounts of undo data. Also please note that maintaining undo data during autoanalysis slows it down a bit. In practice it is not a big deal because the limit on the undo data is reached quite quickly (in a matter of minutes). Therefore, if during analysis the user does not perform any actions that modify the database, the undo feature will turn itself off temporarily.
However, if you prefer not to collect undo data at all during the initial autoanalysis, just turn off the UNDO_DURING_AA parameter in ida.cfg.
The configuration file ida.cfg has 2 more undo-related parameters:
Since there is a limit on the size of undo buffers, any action, even the tiniest, may become non-undoable after some time. This is true because the analysis or plugins may continue to modify the database and overflow the buffers. Some massive actions, like deleting a segment, may be non-undoable just because of the sheer amount of undo data they generate.
Please note that Undo does not affect the state of IDC or Python scripts. Script variables will not change their values because of Undo. Also nothing external to the database can be changed: created files will not be deleted, etc.
Some actions cannot be undone. For example, launching a debugger or resuming from a breakpoint cannot be undone.
See also
This submenu allows you to manipulate different kinds of comments. Use them to make the disassembled text more understandable.
If you stand at the function start and your cursor is on a function name, IDA will ask you to enter a function comment.
If you stand at the segment start and your cursor is on a segment name, IDA will ask you to enter a segment comment.
If this command is issued in the , it allows you to change the comment of a structure, or structure member. If the cursor is on the structure name, it will be changed, otherwise the member name will be changed. Otherwise, this command allows you to enter a normal indented comment for the current item.
You can show/hide all comments in .
See also
How to use the
submenu,
This command allows you to enter a repeatable comment. A repeatable comment will appear attached to the current item and all other items referencing it.
If you stand at the function start, IDA will ask you to enter a function comment.
Otherwise, this command allows you to enter a repeatable comment for the current item.
You cannot enter repeatable segment comments.
All items that refer to the current item will have this comment by default.
The repeatable comments may be used to describe subroutines, data items, etc., because all calls to the subroutine will have the repeatable comment.
If you want to enter multi-line comments or additional instructions, you can use this feature of IDA.
There are two kinds of extra lines: the ones generated before the instruction line and the ones generated after the instruction line.
Do not forget that the maximal number of lines for an item is 500.
IDA does not insert a comment symbol at the beginning of the lines.
This command allows you to specify the type of the operand under the cursor.
The operand type must be entered as a C declaration. Currently IDA itself does not use the operand type information. However, it can be used by the Hex-Rays decompiler plugin. Setting operand type is most useful in case of indirect calls: the decompiler will use the type information to determine the input parameters to the call instead of guessing, which can make the decompiled code better.
An example of a type declaration:
To delete a type declaration, enter an empty string.
For details on possible calling conventions, see menu item description.
See also
You may specify any string instead of an operand if IDA does not represent the operand in the desired form. In this case, IDA will simply display the specified string in the instruction instead of the default operand.
The current operand (under the cursor) will be affected.
You can use this command not only with instructions but with data items too.
IDA proposes the previous manual operand as the default value in the input form.
To delete the manual operand and revert back to the default text, specify an empty string.
IDA automatically deletes manually entered operands when you change operand representation using operand submenu.
NOTE: A text offset reference is generated if you use a label in the program as the operand string. In other cases no cross-references are generated.
See also submenu.
Commands of this submenu are available in the :
All enum members names must be unique in the program. You cannot define more than 256 enum members (symbolic constants) with the same value.
Please note that you can create definitions here.
You can also add a comment for the enum and for each enum member. In order to specify an enum comment, you must stand at the enum name. Comments are set using regular commands:
See also submenu.
These commands allow you to define and to edit an enum type. You need to specify:
Each enum has its ID and a serial number. The ID is a number used to refer to the enum, while a serial number is used to order enums during output. Changing the serial number moves the enum to another place.
The serial number of an enum is displayed at the lower left corner of the window.
You can specify any number as a serial number, IDA will move the enum to the specified place.
You also need to specify representation of enum constants. You may choose from various number bases (hex,dec,oct,bin) and character constants.
You may specify the element width or leave it zero. Zero means the element width is not specified. The allowed widths are the powers of 2 in the range of 1..64.
This command deletes the current enum. Beware, when you delete an enum all references to it will be destroyed. Even if you recreate it later, you'll have to specify again all references to it.
This command allows you to define an enum member. An enum member is a symbolic constant. You have to specify its name and value. You cannot define more than 256 constants with the same value in an enum.
This command allows you to rename an enum member. An enum member is a symbolic constant. Its name must be unique in the program.
To rename an enum type name, position the cursor over the name of the enum.
Please remember that deleting a member also deletes all the information about the member, including comments, member name etc.
will define a constant named CONST1 with value 1 and will create a group containing only one bit. Another example. Let's consider the following definitions:
How do we describe this?
If a mask consists of more than one bit, it can have a name and a comment. A mask name can be set when a constant with the mask is being defined. IDA will display the mask names in a different color.
will be replaced by
This command gives name/renames/deletes for the specified address. This is a more powerful variant of command.
To delete a name, simply give an empty name.
If the specified address is referenced, you cannot delete its name. Even if you try it, IDA will generate a name.
This command is available only from the .
For an explanation about the dialog box entries, please see the command.
See also submenu. . .
This command changes the sign of the current operand. Please note that not all operands can change their sign.
See also: submenu. commands.
If you have selected a range before applying an operand conversion command, IDA will display a dialog box.
You can choose a range of operands to perform an en masse operation:
The operation will be performed on all operands as a toggle. For example, if you ask to convert to a character, then all non-character operands will become characters, and all character operands will become non-chars.
The operation will be performed on the operands which contain immediate numbers in the specified range.
This selection will convert all operands with the specified type to undefined operands. Example: all characters become non-characters.
This selection allows to convert all operands that do not have the specified type to the specified type. Example: all non-characters to characters.
This selection allows to convert all operands without any type to the specified type. Example: all operands with no type to characters.
IDA will check whether an operand can be represented with the specified type (as a character constant, for example), and perform type conversion only if the check is successful.
This submenu allows you to manipulate segments of the program:
See also:
submenu.
This command allows you to create a new segment.
You need to specify at least:
If another segment already exists at the specified address, the existing segment is truncated and the new segment lasts from the specified start address to the next segment (or specified end address, whichever is lower). If the old and the new segments have the same base address, instructions/data will not be discarded by IDA. Otherwise, IDA will discard all instructions/data of the new segment.
An additional segment may be created by IDA to cover the range after the end of the new segment.
nternally, IDA has 32-bit linear address space (IDA64 uses 64-bit address space). The internal addresses are called "linear addresses". The input program is loaded into this linear address space.
Please note that usually the linear addresses are not used in the program directly. During disassembling, we use so-called "virtual addresses", which are calculated by the following formula:
We see that the SegmentBase determines what addresses will be displayed on the screen. More than that, IDA allows to create several segments with the same virtual address in them. For this, you just need to create segments with correct segment base values.
There are some address restrictions in IDA.
There is a range of addresses that are used for internal housekeeping. This range can be specified by the configuration variable PRIVRANGE (start address and size). It is not recommended to use these addresses for other purposes.
There is also one address which must never be used in the disassembly. It is the 'all ones' address, or -1. Internally, it is used as a BADADDR (bad address). No address or address range can include BADADDR.
Related topics:
IBM PC case -----------
Suppose we need to create a segment occupying addresses F000:1000..F000:2000 Let's calculate linear addresses:
The segment base must be selected so that the first offset in our segment will be 0x1000. Let's find it using the following equation:
After solving this equation, we see that the segment base is equal to 0xF000. (you see, this is really a very simple case :) )
Now, we can create a segment entering:
Please note that the end address never belongs to the segment in IDA.
Suppose we need to create a segment occupying virtual addresses 8000-C000. Since we are free to place our segment anywhere in the linear address space, we choose the linear addresses at our convenience. Let's say we choose a linear address 0x20000:
The segment base must be selected so that the virtual address in our segment will be 0x8000. Let's find it using the following equation:
After solving this equation, we see that the segment base is equal to 0x1800.
Now we can create a segment entering:
Please note that the end address never belongs to the segment in IDA.
Suppose we need to create a segment occupying linear addresses 200000-200C00 and the virtual addresses must have be 0000..0C00. If we simply enter
Then IDA will notice that the segment base is too big and does not fit into 16bits. Because of this IDA will find a free selector (let's say it has found selector number 5), define it to point at paragraph 0x20000 and create a segment. After all this we will have:
The first virtual address in the segment will be 0:
Please note that the end address never belongs to the segment in IDA.
2. Create a segment. Specify the selector number as the segment base.
This command allows you to delete a segment.
IDA will ask your the permission to disable the addresses occupied by the segment. If you allow this operation, all information about the segment will be deleted. In other words, IDA will discard the information about instructions or data, comments etc.
If you check the "disable addresses" checkbox, IDA will mark the addresses occupied by the segment as "nonexistent" in the program. You will lose *ALL* information, including byte values.
It is impossible to disassemble the content of addresses not located in any segment, therefore you must create a new segment if you want to resume the disassembly of that part of the code.
IDA will ask your the permission to disable addresses occupied by the segment. If you give your permission, information about the segment will be deleted, otherwise IDA will discard information about instruction/data, comments etc, but retain byte values so that you will be able to create another segment afterwards.
Changing the segment class may change the segment type.
DISABLE ADDRESSES: if set, when a segment is shrunk, all information about bytes going out of the segment will be completely removed.. Otherwise, IDA will discard information about instructions/data, comments etc, but will retain byte values so that another segment can be created later and it will use the existing byte values.
If IDA creates 2 segments where only one segment must exist, you may try the following sequence:
Segments with the 'debugger' attribute are the segments whose memory contents are not saved in the database. Usually, these segments are created by the debugger to reflect the current memory state of the program.
However, the user can modify this attribute.
If it is cleared, then the segment will permanently stay in the database after closing the debugger session. The database will reflect the state of the segment which was at the time when the status is changed.
If it is set, then the segment will become a temporary segment and will be deleted at the end of the debugging session.
The "debugger segment" checbkox is available only during debugging sessions.
The 'loader' segments are the segment created by the file loader. The segment having this attribute are considered to be part of the input file.
A segment with the 'debugger' attribute set and the 'loader' attribute not set is considered to be an ephemeral segment. Such segments are not analyzed automatically by IDA.
"Segment permissions" group box can be used to modify Segment access permissions (Read/Write/Execute)
Enter a new name for the segment. A segment name is up to 8 characters long. IDA does check if the length is ok. Try to give mnemonic names for the segments.
The segment class name identifies the segment with a class name (such as CODE, FAR_DATA, or STACK). The linker places segments with the same class name into a contiguous range of memory in the runtime memory map.
Changing the segment class changes only the segment definition on the screen. There are the following predefined segment class names:
If you change segment class and the segment type is "Regular", then the segment type will be changed accordingly.
In order to set the segment type "Regular", you should change the segment class to "UNK".
Segment class names are never deleted. Once you define a segment class name, you cannot reuse it as a name of another object.
You can choose between 16-bit and 32-bit segment addressing.
IDA will delete all instructions and data in the segment if the segment address is changed.
Never do it if you are not sure. It may have irreversible consequences, all instructions/data will be converted to undefined bytes.
Alignment: select between abs,byte,word,dword,para,page
You can specify the segment alignment for the selected segment. By default, IDA assumes 'byte' alignment.
Changing the alignment changes only the segment definition on the screen. Nothing else will happen.
Combination
A field that describes how the linker can combine the segment with other segments. Under MS-DOS, segments with the same name and class can be combined in two ways: they can be concatenated to form one logical segment, or they can be overlapped. In the latter case, they have either the same start address or the same end address, and they describe a common range in memory. Values for the field are:
Changing segment combination changes only the segment definition on the screen. Nothing else will happen.
This command allows you to move segment(s) to another address. Use it if the segment(s) are loaded at a wrong address.
This command shifts (moves) the selected segments in the memory to the target address. There must be enough free space at the target address for the segments.
All information in the segment will be moved to the new address, but since the addresses change, the disassembly might be not valid anymore (especially if the program is moved to the wrong addresses and the relocation information is not available).
The whole program will be shifted by the specified amount of bytes in the memory. The following options are available (we strongly recommend to leave them turned on):
Please note rebasing the program might remove user-defined xrefs.
in the segment C obviously refers to the segment B while the instruction
refers to the segment A.
However, IDA does not try to link these references unless you tell it to do so: include the segments A and B into a translation list of the segment C. It means that you have to create a translation list
for the segment C.
Below is a more complicated example:
translations
allow you to emulate overlays (the first set is A B D, the second A C E)
See also
Relevant only for processors with the segment registers.
You can specify a default value of a segment register for the current segment. When you change the default value, IDA will reanalyze the segment, taking the default value when it cannot determine the actual value of the register. This takes time, so do not be surprised if references are not corrected immediately.
Relevant only for processors with the segment registers. Currently this command works for IBM PC, TMS320C2, Intel80196, and PowerPC processors.
For Alpha processors, the user must enter the difference between the real GP value and the start of the GOT (global offset table). For example:
If you want to specify that a register points to "label", you must calculate and enter the difference "label-.got" as the register value.
The ARM processor module has a virtual segment register T which reflects the state of the T bit of the processor state register (PSR). Therefore, the value of this register controls THUMB/ARM mode. If its value is not zero, then the disassembly will be in the thumb mode.
For PowerPC processors, the user must enter an offset from the beginning of the TOC to the TOC entry which contains the address of the target. An example:
If you want to specify that a register points to "datachunk", you must calculate and enter the difference "sometc-TOC" as the register value. You can change the TOC value in the processor specific options (which is accessible from the analysis options).
For Intel 80196NP/NU processors, the user must enter the value of WSR or WSR1 register. IDA will automatically take the new value into account.
See also:
IDA classifies the change points. In the list of the change points, you can see the following postfixes after the register values:
IDA can display a list of the program segments. Each segment is represented by a line in the list. Please note that the end address of the segment never belongs to the segment in IDA.
The following segment attributes are visible:
The rest of the columns display the default values of the segment registers for the segment.
By default, the cursor is located on the current segment.
You can use normal cursor movement keys and the mouse. You can also search for the segment by pressing Alt-T, or directly jump to the desired line by typing in its number.
Press <Enter> to select line, <Esc> to cancel the selection.
Commands of this submenu are available in the . Only is available in the disassembly window.
Use regular commands to specify struct and union members, their types, comments, etc.
A union is a special kind of structure. Use structure definition commands to manipulate unions.
See also submenu.
If the entered structure name denotes a standard structure type from a loaded type library, then its definition will be automatically used. In this case, the value of the 'create union' checkbox will be ignored.
"Create before current structure" means that the new structure will be placed immediately before the current structure type. Otherwise, the new structure is placed after the current structure.
"Don't include in the list" means that the structure will not be included in the list of the structures which appears when the user applies the structure definition, for example, when he creates a variable of this structure type. We recommend to mark this checkbox when you have defined all variables of this structure type and want to reduce the number of choices in the list.
This command makes a copy of the current structure type. The new structure type will have the same members as the current one but its name will be autogenerated (something like struc_333)
By default the new structure type will be placed after the current structure type.
This command deletes the current structure. Beware, when you delete a structure, all references to it will be destroyed as well. Even if you recreate it later, you'll have to specify again all references to it.
You may use this command to delete unions also.
This command expands the current structure by inserting undefined bytes at the cursor location. The cursor must not be at the end of the structure. To define a member at the end of the structure, just use normal data definition commands.
This command shrinks the current structure by deleting undefined bytes at the cursor location. The cursor must be at an undefined byte. IDA will ask the user the number of bytes to remove.
This command allows the user to change the structure alignment
Structure alignment is used to calculate the number of padding bytes at the end of the structure. For example, if alignment is 4 and the last field is a byte at offset 11h, IDA will add 3 bytes of padding so that the struct size is 14h (multiple of 4).
The alignment must be a power of 2.
This command declares a variable of the specified structure type.
You can also use this command to declare a structure field in another structure (i.e. nested structures are supported too).
This command forces IDA to display a full structure member name even if the offset of the member is equal to zero.
If used twice, the command cancels itself.
Example: Suppose we have the following structure:
This command tells IDA how to display references to a union from the current cursor location.
Example: Suppose we have the following union:
This command defines a new structure from data already defined. The new structure is created with adequate data types, and each member uses the current data name if it is available.
This command is available only in the graphical version of IDA.
This command scans the current struct variable and renames the locations pointed by offset expressions unless they already have a non-dummy name.
It also copies the type info from the struct members to pointed locations.
This submenu allows you to patch the image of the input file. More precisely, IDA never modifies the input file. The image of the input file which was loaded to the database will be modified.
You can modify the image of the input file:
IDA will display the original value, the current value and file offset. If the file offset is equal to 0xFFFFFFFF then the current byte comes from a compressed page (LX/LE/NE iterated pages, for example) and/or it is not possible to tell the file position.
You can create a file and use an external tool to apply the patches or you can apply the directly to the file using IDA.
The following commands are available:
See also:
submenu.
If this command is invoked when the debugger is active, then IDA will modify the memory and the database. If the database does not contain the patched bytes, then only the process memory will be modified.
Apply previously patched bytes back to the input file. If the "Restore" option is selected then the original bytes will be applied to the input file.
The sequence must be separated by a space or a comma.
An entered number will occupy the minimal number of bytes it fits in with the restriction that the number of bytes is a power of 2 (1, 2, or 4 bytes).
Two question marks without a space between them are the same as one question mark. One question mark corresponds to one CPU byte. One CPU byte may consist of multiple octets for a wide-byte CPU, like TMS320C28.
Example:
This command allows you to assemble instructions. Currently, only the IBM PC processors provide an assembler, nonetheless, plugin writers can extend or totally replace the built-in assembler by writing their own.
The assembler requires to enclose all memory references into square brackets. For example:
Also, the keyword 'offset' must not be used. Instead of
you must write
If this command is issued in the , it allows you to change the comment of a structure or structure member. If the cursor is on the structure name, the structure comment will be changed, otherwise the member comment will be changed.
Note that if you have defined both comment types ( and repeatable), the regular comment will be displayed for the current item and the repeatable comment will be displayed for all items that refer to the current item, if they do not have their own comments.
You can show/hide all comments in the .
You can show and hide repeatable comments in the .
See also "How to use the ".
See also "How to use the ".
Related topics: submenu.
Please note that you can create definitions here by checking the "bitfield" checkbox.
These command is available when you open the enums .
See also .
This command is available when you open the enums .
If the current enum is a bitfield, you need to specify the bitmask. To learn about bitmasks, read about .
There is a special kind of : bitfields. A bitfield is an enum divided into bit groups. When you define a new symbolic constant in a bitfield, you need to specify the group to which the constant will belong to. By default, IDA proposes groups containing one bit each. If a group is not defined yet, it is automatically created when the first constant in the group is defined. For example:
In order to use a bitfield in the program, just convert an instruction operand to . IDA will display the operand like this:
See also and
If you select a range using the , IDA will propose the start address and the end address of the selection as defaults for the segment bounds.
Click to learn about addressing model used in IDA.
If "sparse storage" is set, IDA will use special sparse storage method for the segment. This method is recommended for huge segments. Later, it is possible to change the storage method of any region using IDC function.
Normally a SegmentBase is a 16bit quantity. To create a segment with base >= 0x10000, you need to use . However, if you try to create a segment with a segment base >= 0x10000, IDA will automatically choose appropriately a free selector and setup for the new segment.
All SegmentBases are looked up in the table.
Click to see an example of segment creation (simple case - IBM PC)
Click to see an example of segment creation (simple case - Z80)
Click to see another example of segment creation (automatically chosen selector)
Click to see another example of segment creation (user-defined selector)
See also
If the example we saw how IDA allocates a selector automatically. You could make it yourself:
1. Create a selector. For this, open the and press Ins. Enter a selector number and its value.
You can also edit (see below) an adjacent segment to it to those addresses.
To disassemble the addresses occupied by the segment, you need to create a new segment again (i.e. you cannot disassemble bytes without a segment). You can also another adjacent segment to these addresses.
MOVE ADJACENT SEGMENTS: means that the previous and next segments will be shrunk or expanded to fill gaps between segments. Click for more information.
one segment. Choose one with bad segment base value. Do not disable addresses occupied by the segment being deleted.
change bounds of another segment. Note that the segment command changes the boundaries of the overlapping segment automatically.
IMPORTANT NOTE1: If you use the segment translations, make sure that all segments have unique segment bases. If two segments are placed in the linear address space so that they must have the same segment base, you may assign different with equal values to them.
IMPORTANT NOTE2: IDA supports only one translation list per segment. This translation is applied by default to all instruction in the segment. If the segment uses other mappings, then these individual mappings can be specified for each instruction separately by using the commands.
IMPORTANT NOTE3: Since only code references are affected by the segment translations, try to create the RAM segment at its usual place (i.e. its linear address in IDA corresponds to its address in the processor memory). This will make all data references to it to be correct without any segment translation. For the data references to other segments you'll need to use the command for each such reference.
To specify a value other than the default value of a segment register, you can use command.
See also
This command creates or updates a segment register .
See for more info.
When IDA encounters an instruction which changes a segment register, it creates a segment register change point. So, mostly change points are maintained by IDA itself. IDA assumes that the segment registers do not change their values between change points. If you find out that IDA failed to locate a segment register change, or if you want to change a register value, you can create a change point using command. You can change the value of a segment register using command too.
IDA generates the appropriate 'assume' instructions for the change points if it was not disabled by .
This command defines a new structure or a new union. The new structure is created with zero length. You will have to add structure members using manipulation commands.
This command is available when you open a structures .
You can add new members to the structure using the following commands: command hotkey ------- ------ D A * N You may also insert/delete undefined bytes into the middle of the structure by using and commands.
See also .
This command is available when you open a structures .
This command is available when you open a structure .
This command is available when you open a structure .
This command is available in the Structures .
See also .
IDA will ask you to choose a structure type. You must have some structure types in order to use this command.
If the supports it, IDA will display the structure in terse form (using just one line). To uncollapse a terse structure variable use the command.
You can modify the executable file and eventually file.
If you patch bytes, then you may enter multiple bytes. Follow this to learn about format of the input string.
You can create a file too.
See also .
See also .
See also .
This command deletes the current instruction or data, converting it to 'unexplored' bytes. IDA will delete the subsequent instructions if there are no more references to them (functions are never deleted).
If you have selected a range using the anchor, all the bytes in this range will be converted into 'unexplored' bytes. In this case, IDA will not delete any other instructions even if there are no references to them after the deletion.
See also Edit submenu
This command clears the undo history. After it the Undo and Redo commands become unavailable. However, once the user performs a new action, IDA will again start journaling all database modifications.
A side effect of this command is fast autoanalysis: since there is no user action to revert yet, IDA does not maintain undo buffers and this speeds up the analysis.
See also
This command allows you to create arrays and change their sizes.
The arrays are created in 2 simple steps:
Apply the array command to the created data item. Enter array size in current array elements (not bytes). The suggested array size is the minimum of the following values:
For string literals, you can use this command to change the length of the string.
The dialog box contains the following fields:
Items on a line (meaningless for string literals):
Please note that the margin parameter affects the number of items on a line too.
Alignment (meaningless for string literals):
If applied to a variable-sized structure, this command is used to specify the overall size of the structure. You cannot create arrays of variable-sized structures.
See also:
Edit submenu
This command converts immediate operand(s) type of the current instruction/data to an enum member. Before using this command, you have to define an enumeration type.
If the selected enum is a bitfield, IDA will try to build a bitfield expression to represent the constant. Please note that for bitfields having multiple constants with the same value some expressions won't be possible.
If a range is selected using the anchor, IDA will perform 'en masse' conversion. It will convert immediate operands of all instructions in the selected range to symbolic constants. However, IDA will ask you first the lower and upper limits of immediate operand value. If the operand value is >= lower limit and <= upper limit then the operand will be converted to offset, otherwise it will be left unmodified.
When you use this command, IDA deletes the manually entered operand.
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise all other operands will be affected.
See also: Edit|Operand types submenu. Enter #th operand manually commands. Set operand type
A complex offset expression looks like
It is specified by:
The relationship between these parameters is (the formula is given for full offsets):
You always have to specify the offset type and base. Usually, the delta is equal to zero. For the full offset type you may omit the offset target, which is recommended. In this case, IDA will calculate it automatically. However, if you specify the offset target, make sure that the relationship between the parameters still holds. For the half offset types, you have to specify the target because there is no way to calculate it.
The offset types:
See also offset by any user-specified base
This submenu allows you to manipulate functions in the disassembly:
This command defines a new function in the disassembly text.
You can specify function boundaries using the . If you don't specify any, IDA will try to find the boundaries automatically:
A function cannot contain references to undefined instructions. If a function has already been defined at the specified addresses, IDA will jump to its start address, showing you a warning message.
A function must start with an instruction.
If the current address does not belong to any function, IDA beeps.
This command allows you to change the function frame parameters too. You can change sizes of some parts of frame structure.
IDA considers the stack as the following structure:
For some processors or functions, BP may be equal to SP. In other words, it can point to the bottom of the stack frame.
"Purged bytes" specifies the number of bytes added to SP upon function return. This value will be used to calculate the SP changes at call sites (used in some calling conventions, such as __stdcall in Windows 32-bit programs.)
"BP equal to SP" means that the frame pointer points to the bottom of the stack. It is usually used for the processors which set up the stack frame with EBP and ESP both pointing to the bottom of the frame (for example MC6816, M32R).
If you press <Enter> even without changing any parameter,IDA will reanalyze the function.
Sometimes, EBP points to the middle of the stack frame. FPD (frame pointer delta) is used to handle such situations. FPD is the value substracted from the EBP before accessing variables. An example:
In our example, the saved registers area is empty (since EBP has been initialized before saving EBX and ESI). The difference between the 'typical BP' and 'actual BP' is 0x78 and this is the value of FPD.
After specifying FPD=0x78 the last instruction of the example becomes
where var_4 = -4
Most of the time, IDA calculates the FPD value automatically. If it fails, the user can specify the value manually.
If the value of the stack pointer is modified in an unpredictable way, (e.g. "and esp, -16"), then IDA marks the function as "fuzzy-sp".
If this command is invoked for an imported function, then a simplified dialog box will appear on the screen.
The following flags can be set in function properties:
Does not return
Far function
Library func
Static func
Mark the function as static. Currently this flag is not used by IDA and is simply informational.
BP based frame
BP equal to SP
Frame pointer points to the bottom of the stack instead of at the beginning of the local variables area as is typical.
Fuzzy SP
Function changes SP by an unknown value, for example: and esp, 0FFFFFFF0h
Outlined code
The function is not a real function but a fragment of multiple functions' common instruction sequence extracted by the compiler as a code size optimization (sometimes called "code factoring"). During decompilation, body of the function will be expanded at the call site.
This command appends an arbitrary range of the program to a function definition. A range must be selected before applying this command. This range must not intersect with other function chunks (however, an existing tail can be added to multiple functions).
IDA will ask to select the parent function for the selection and will append the range to the function definition.
This command removes the function tail at the cursor from a function definition.
If there are several parent functions for the current function tail range, IDA will ask to select the parent function(s) to remove the tail from.
After the confirmation, the current function tail range will be removed from the selected function definition.
If the parent was the only owner of the current tail, then the tail will be destroyed. Otherwise it will still be present in the database. If the removed parent was the owner of the tail, then another function will be selected as the owner.
Deleting a function deletes only information about a function, such as information about stack variables, comments, function type, etc.
The instructions composing the function will remain intact.
This command changes the current or previous function bounds so that its end will be set at the cursor. If it is not possible, IDA beeps.
Allow to edit argument or return value location.
This command opens the stack variables window for the current function.
The stack variables are internally represented as a structure. This structure consists of two parts: local variables and function arguments.
You can modify stack variable definitions here: add/delete/define stack variables, enter comments for them.
Offsets at the line prefixes represent offsets from the frame pointer register (BP). The window indicator at the lower left corner of the window displays offsets from the stack pointer.
Esc closes this window.
This command allows you to specify how the stack pointer (SP) is modified by the current instruction.
You will need to use this command only if IDA was not able to trace the value of the SP register. Usually IDA can handle it but in some special cases it fails. An example of such a situation is an indirect call of a function that purges its parameters from the stack. In this case, IDA has no information about the function and cannot properly trace the value of SP.
Please note that you need to specify the difference between the old and new values of SP.
The value of SP is used if the current function accesses local variables by [ESP+xxx] notation.
This command allows you to rename a processor general register to some meaningful name. While this is not used very often on IBM PCs, it is especially useful on RISC processors with lots of registers.
For example, a general register R9 is not very meaningful and a name like 'CurrentTime' is much better.
This command can be used to define a new register name as well as to remove it. Just move the cursor on the register name and press enter. If you enter the new register name as an empty string, then the definition will be deleted.
If you have selected a range before using this command, then the definition will be restricted to the selected range. But in any case, the definition cannot cross the function boundaries.
This command allows you to specify the type of the current item.
If the cursor is located on a name, the type of the named item will be edited. Otherwise, the current function type (if there is a function) or the current item type (if it has a name) will be edited.
The function type must be entered as a C declaration. Hidden arguments (like 'this' pointer in C++) should be specified explicitly. IDA will use the type information to comment the disassembly with the information about function arguments. It can also be used by the Hex-Rays decompiler plugin for better decompilation.
Here is an example of a function declaration:
To delete a type declaration, please enter an empty string.
IDA supports the user-defined calling convention. In this calling convention, the user can explicitly specify the locations of arguments and the return value. For example:
denotes a function with 2 arguments: the first argument is passed on the stack (IDA automatically calculates its offset) and the second argument is passed in the ESI register and the return value is stored in the EBX register. Stack locations can be specified explicitly:
There is a restriction for a __usercall function type: all stack locations should be specified explicitly or all are automatically calculated by IDA. General rules for the user defined prototypes are:
The name used in the declaration is ignored by IDA.
If the default calling convention is __golang then explicit specification of stack offsets is permitted. For example:
This declaration means that myprnt is a print-like function; the format string is the second argument and the variadic argument list starts at the third argument.
Below is the full list of attributes that can be handled by IDA. Please look up the details in the corresponding compiler help pages.
For data declarations, the following custom __attribute((annotate(X))) keywords have been added. The control the representation of numbers in the output:
__bin
unsigned binary number
__oct
unsigned octal number
__hex
unsigned hexadecimal number
__dec
signed decimal number
__sbin
signed binary number
__soct
signed octal number
__shex
signed hexadecimal number
__udec
unsigned decimal number
__float
floating point
__char
character
__segm
segment name
__off
offset expression (a simpler version of __offset)
__invsign
inverted sign
__invbits
inverted bitwise
__lzero
add leading zeroes
The following additional keywords can be used in type declarations:
_BOOL1
a boolean type with explicit size specification (1 byte)
_BOOL2
a boolean type with explicit size specification (2 bytes)
_BOOL4
a boolean type with explicit size specification (4 bytes)
__int8
a integer with explicit size specification (1 byte)
__int16
a integer with explicit size specification (2 bytes)
__int32
a integer with explicit size specification (4 bytes)
__int64
a integer with explicit size specification (8 bytes)
__int128
a integer with explicit size specification (16 bytes)
_BYTE
an unknown type; the only known info is its size: 1 byte
_WORD
an unknown type; the only known info is its size: 2 bytes
_DWORD
an unknown type; the only known info is its size: 4 bytes
_QWORD
an unknown type; the only known info is its size: 8 bytes
_OWORD
an unknown type; the only known info is its size: 16 bytes
_TBYTE
10-byte floating point value
_UNKNOWN
no info is available
__pure
pure function: always returns the same value and does not modify memory in a visible way
__noreturn
function does not return
__usercall
user-defined calling convention; see above
__userpurge
user-defined calling convention; see above
__golang
golang calling convention
__swiftcall
swift calling convention
__spoils
explicit spoiled-reg specification; see above
__hidden
hidden function argument; this argument was hidden in the source code (e.g. 'this' argument in c++ methods is hidden)
__return_ptr
pointer to return value; implies hidden
__struct_ptr
was initially a structure value
__array_ptr
was initially an array
__unused
unused function argument __cppobj a c++ style struct; the struct layout depends on this keyword
__ptr32
explicit pointer size specification (32 bits)
__ptr64
explicit pointer size specification (64 bits)
__high
high level prototype (does not explicitly specify hidden arguments like 'this', for example) this keyword may not be specified by the user but IDA may use it to describe high level prototypes
__bitmask
a bitmask enum, a collection of bit groups
Sometimes in binary code we can encounter a pointer to the middle of a structure. Such pointers usually do not exist in the source code but an optimizing compiler may introduce them to make the code shorter or faster.
Such pointers can be described using shifted pointers. A shifted pointer is a regular pointer with additional information about the name of the parent structure and the offset from its beginning. For example:
The above declaration means that myptr is a pointer to 'int' and if we decrement it by 20 bytes, we will end up at the beginning of 'mystruct'.
Please note that IDA does not limit parents of shifted pointers to structures. A shifted pointer after the adjustment may point to any type except 'void'.
Also, negative offsets are supported too. They mean that the pointer points to the memory before the structure.
When a shifted pointer is used with an adjustment, it will be displayed with the 'ADJ' helper function. For example, if we refer to the memory 4 bytes further, it can be represented like this:
Shifted pointers are an improvement compared to the CONTAINING_RECORD macro because expressions with them are shorter and easier to read.
If we have this function prototype:
the 64bit GNU compiler will pass the structure like this:
Since compilers can use such complex calling conventions, IDA needs some mechanism to describe them. Scattered argument locations are used for that. The above calling convention can be described like this:
It reads:
In other words, the following syntax is used:
where
The regoff and size fields can be omitted if there is no ambiguity.
If the register is not specified, the expression describes a stack location:
where
Please note that while IDA checks the argument location specifiers for soundness, it cannot perform all checks and some wrong locations may be accepted. In particular, IDA in general does not know the register sizes and accepts any offsets within them and any sizes.
Syntax:
Instead of a plain number, a symbolic constant from the specified enum will be used. The enum can be a regular enum or a bitmask enum. For bitmask enums, a bitwise combination of symbolic constants will be printed. If the value to print cannot be represented using the specified enum, it will be displayed in red.
Example:
Another example:
This annotation is useful if the enum size is not equal to the variable size. Otherwise using the enum type for the declaration is better:
where
type is one of:
The type can also be the name of a custom refinfo.
It can be combined with the following keywords:
The base, target delta, and the target can be omitted. If the base is BADADDR, it can be omitted by combining the type with AUTO:
Zero based offsets without any additional attributes and having the size that corresponds the current application target (e.g. REF_OFF32 for a 32-bit bit application), the shoft __off form can be used.
Examples:
This annotation is useful the type of the pointed object is unknown or the variable size is different from the usual pointer size. Otherwise it is better to use a pointer:
Syntax:
where strtype is one of:
It may be followed by two optional string termination characters (only for C). Finally, the string encoding may be specified, as the encoding name or "no_conversion" if the string encoding was not explicitly specified.
Example:
Syntax:
Instead of a plain number, the name of a struct or union member will be used. If delta is present, it will be subtracted from the value before converting it into a struct/union member name.
Example:
Another example:
Syntax:
where dtid is the name of a custom data type and fid is the name of a custom data format. The custom type and format must be registered by a plugin beforehand, at the database opening time. Otherwise, custom data type and format ids will be displayed instead of names.
Syntax:
This keyword is used to format arrays. The following flags are accepted:
It is possible to combine NODUPS with the index radix: NODUPS|HEX
Example:
Without this annotation, the `dup` keyword is permitted, number of items on a line and the alignment are not defined.
This command converts the immediate operand(s) type of the current instruction/data to segment base. The segment bases are usually displayed like this:
When you use this command, IDA deletes the entered operand.
If IDA cannot find a segment whose base is equal to the operand value, it simply displays it as hex number.
If the cursor is on the first operand (the cursor is before ',') then the first operand will be affected; otherwise, all other operands will be affected.
See also submenu.
Here you can change function bounds, its name and . In order to change only the function end address, you can use command.
You may specify the number of bytes in each part of the stack frame. The size of the return address is calculated by IDA (possibly depending on the far function ).
"BP based frame" allows IDA to automatically convert [BP+xxx] operands to .
The function does not return to caller (for example, calls a process exit function or has an infinite loop). If no-return analysis is enabled in , IDA will not analyze bytes following the calls to this function.
On processors which distinguish near and far functions (e.g. PC x86), mark the function as 'far'. This may affect the size of the special field reserved for the return address, as well as analysis of calls to this function.
Mark the function as part of compiler runtime library code. This flag is usually set when applying
Inform IDA that the function uses a frame pointer (BP/EBP/RBP on PC) to access . The operands of the form [BP+xxx] will be automatically converted to .
There may be two special fields in this window: " r" and " s". They represent the size of the function return address and of the saved registers in bytes. You cannot modify them directly. To change them, use command.
In order to create or delete a stack variable, use data definitions commands (, , , , ). Also you may define or comments.
The defined stack variables may be used in the program by converting operands to .
See also .
You cannot use this command if the current instruction does not belong to any .
See also .
You cannot use this command if the current instruction does not belong to any .
- for really complicated cases can be used. IDA also understands the "__userpurge" calling convention. It is the same thing as __usercall, the only difference is that the callee cleans the stack.
__enum()
__offset()
__strlit()
__stroff()
__custom()
__tabform()
__shifted
declaration
See also command.
See also command.
The `lineitems` and `alignment` attributes have the meaning described for the command.
See also submenu.
See also Edit submenu.
This command allows you to create an alignment directive. The alignment directive will replace a number of useless bytes inserted by the linker to align code and data to paragraph boundary or any other address which is equal to a power of two.
You can select a range to be converted to an alignment directive. If you have selected a range, IDA will try to determine a correct alignment automatically.
There are at least two requirements for this command to work:
there must be enough unexplored bytes at the current address.
an alignment directive must always end at an address which is divisible by a power or two.
See also
This command allows you to specify the representation of an instruction or data in the program.
Use it if IDA cannot represent the current instruction as desired. If the instruction itself is ok and only one operand is misrepresented, then use Enter operand manually command.
To delete the manual representation, specify an empty string.
This command allows you to specify the background color for the current instruction or data item.
Only GUI version supports different background colors. Specifying a non-defined custom color will reset the instruction color.
This command allows you to hide a thin border which is like the one generated automatically by IDA between instructions and data. If the border was already hidden, then it is displayed again.
Note that you can hide all borders at once in the Comments Dialog.