<?xml version="1.0" encoding="ISO-8859-1"?>
<ida xmlns:xi="http://www.w3.org/2003/XInclude"
     xmlns:xpath="http://www.idapro.com/ns/xpath"
     xmlns:idc="http://www.idapro.com/ns/idc">
  <templates>

  <idc>
    static enable_proc_options(proc) /* enable a processor options wizard page */
    {
      PushXML("ancestor::wizard[1]");                                      /* work at the parent wizard level */
      SetXML("page[starts-with(@X, 'processor_')]/@visible", "", "false"); /* disable all others processor options pages */
      SetXML("page[@X='processor_" + proc + "_p']/@visible", "", "true");  /* enable the requested processor options page */
      PopXML();
    }
  </idc>

    <checkbox X="analysis_c" caption="Analysis options" onClick="onClick_analysis_c">
      <idc>
        static onClick_analysis_c(void)
        {
          auto checked, proc;
          checked = GetXML("@checked");
          /* show/hide the main kernel options page */
          SetXML("../../page[@X='kernel_p']/@visible", "", checked);
          /* if a unique processor was specified by the template,
             show/hide its options page */
          if (GetXML("count(/ida/loading/processor)") == 1)
          {
            proc = checked == "true" ? GetXML("/ida/loading/processor/@name") : "";
            enable_proc_options(proc);
          }
        }
      </idc>
    </checkbox>

    <page X="processors_p" title="Processor Selection" subtitle="With which processor module would you like IDA to analyze the input file?" xpath:visible="count(/ida/loading/processor) > 1" next="false" onInitialize="onInitialize_processors_p" onNext="onNext_processors_p">
      <idc>
        <![CDATA[
          static onInitialize_processors_p(void)
          {
            /* populate the processors listbox from the processors list generated by IDA */
            auto count, i, xpath, caption, proc;
            count = GetXML("count(/ida/loading/processor)");
            for (i = 1; i <= count; i++)
            {
              xpath = "/ida/loading/processor[" + ltoa(i, 10) + "]";
              caption = GetXML(xpath);
              proc    = GetXML(xpath + "/@name");
              SetXML("listbox",              "item",  caption);
              SetXML("listbox/item[last()]", "@proc", proc);
            }
          }
          static onNext_processors_p(void)
          {
            auto xpath, clicked_caption, dot, name, proc;
            xpath = "listbox/item[@clicked='true']";
            clicked_caption = GetXML(xpath);
            dot = strstr(clicked_caption, ":");
            if (dot != -1)
            {
              name = substr(clicked_caption, dot+2, -1);
              SetProcessorType(name, SETPROC_ALL);
              /* disable the Next button (by hiding this page and all the previous ones) */
              SetXML("preceding-sibling::page/@visible", "", "false");
              SetXML("@visible", "", "false");
              /* if the Analysis option was checked, show the processor options page */
              if (GetXML("../page/checkbox[@X='analysis_c']/@checked") == "true")
              {
                proc = GetXML(xpath + "/@proc");
                enable_proc_options(proc);
              }
            }
          }
        ]]>
      </idc>
      <listbox onClick="onClick_processors_p">
        <idc>
          static onClick_processors_p(void)
          {
            /* a processor was selected, enable the Next button */
            SetXML("../@next", "", "true");
          }
        </idc>
      </listbox>
    </page>
    
    <page X="kernel_p" title="Kernel Options" subtitle="How would you like the IDA kernel to analyze the input file?" visible="false">
      <checklistbox>
        Analysis
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_CODE"     caption="Trace execution flow">
          <help>
            This option allows IDA to trace execution flow and convert all references bytes to instructions.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_USED"     caption="Analyse and create all xrefs">
          <help>
            Without this option IDA will not thoroughly analyze the program.
            If this option is disabled, IDA will simply trace execution flow,
            nothing more (no xrefs, no additional checks, etc).
          </help>
        </checkitem>
        Functions
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_PROC"     caption="Create functions if call is present">
          <help>
            This option allows IDA to create a function (proc) if a call instruction is present.
            For example, the presence of:

                    call loc_1234

            leads to creation of a function at label loc_1234.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af2" idc:mask="AF2_FTAIL"   caption="Create function tails">
          <help>
            This option allows IDA to find and append separately located
            function tails to function definitions.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_PROCPTR"  caption="Create function if data xref data->code32 exists">
          <help>
            If IDA encounters a data reference from DATA segment to 32bit
            CODE segment, it will check for the presence of meaningful
            (disassemblable) instruction at the target.
            If there is an instruction, it will mark it as an instruction and will
            create a function there.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_JFUNC"    caption="Rename jump functions as j_...">
          <help>
            This option allows IDA to rename simple functions containing only

                    jmp somewhere

            instruction to "j_somewhere".
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_NULLSUB"  caption="Rename empty functions as nullsub_...">
          <help>
            This option allows IDA to rename empty functions containing only
            a "return" instruction as "nullsub_..."
            (... is replaced by a serial number: 0,1,2,3...).
          </help>
        </checkitem>
        Library functions
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_FLIRT"    caption="Use FLIRT signatures">
          <help>
            Allows usage of FLIRT technology.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af2" idc:mask="AF2_HFLIRT"  caption="Automatically hide library functions">
          <help>
            This option hides the functions recognized by FLIRT.
            It will have effect only from the time it is set.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af2" idc:mask="AF2_SIGCMT"  caption="Comment anonymous library functions">
          <help>
            This option appends a comment to anonymous library functions.
            The comment consists of the description of the FLIRT signature
            which has recognized the function and marked it as coming
            from a library.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af2" idc:mask="AF2_SIGMLT"  caption="Multiple copy library function recognition">
          <help>
            This option allows FLIRT to recognize several copies of the same
            function in the program.
          </help>
        </checkitem>
        Stack
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_LVAR"     caption="Create stack variables">
          <help>
            This option allows IDA to automatically create
            stack variables and function parameters.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_TRACE"    caption="Trace stack pointer">
          <help>
            This option allows IDA to trace the value of SP register.
          </help>
        </checkitem>
        Argument information propagation
        <checkitem variable="/ida/loading/inf/@af2" idc:mask="AF2_STKARG"  caption="Propagate stack argument information">
          <help>
            This option propagates the stack argument information
            (the type and the name) to the caller's stack. If the caller is
            called then the information will be propagated further through
            the whole program.
            Currently the type propagation is really simple and non-intelligent:
            the first encountered type for a stack variable will be used.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af2" idc:mask="AF2_REGARG"  caption="Propagate register argument information">
          <help>
            This option propagates the register argument information
            (the type and the name) to the caller. If the caller is also
            called then the information will be propagated further
            through the whole program.
          </help>
        </checkitem>
        Strings
        <checkitem variable="/ida/loading/inf/@af2" idc:mask="AF2_CHKUNI"  caption="Check for unicode strings">
          <help>
            This option allows IDA to check for the presence of the unicode
            strings in the program and creates them if necessary.
            IDA will check for the unicode strings only if the string style
            is set to "C-style (0 terminated)" or "Unicode".
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_ASCII"    caption="Create ASCII string if data xref exists">
          <help>
            If IDA encounters a data reference to an undefined item, it
            checks for the presence of the ASCII string at the target. If the length
            of the ASCII string is big enough (more than 4 chars in 16bit or data
            segments; more than 16 chars otherwise), IDA will automatically create
            an ASCII string.
          </help>
        </checkitem>
        Heuristic - Final analysis
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_FINAL"    caption="Make final analysis pass">
          <help>
            This option allows IDA to coagulate all unexplored bytes
            by converting them to data or instructions.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_MARKCODE" caption="Mark typical code sequences as code">
          <help>
            IDA knows some typical code sequences for each processor.
            For example, it knows about typical sequence

                    push    bp
                    mov     bp, sp

            If this option is enabled, IDA will search for all typical sequences
            and convert them to instructions even if there are no references
            to them. The search is performed at the loading time.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_UNK"      caption="Delete instructions with no xrefs">
          <help>
            This option allows IDA to undefine instructions without any references to them.
            For example, if you undefine an instruction at the start of a function, IDA will
            trace execution flow and delete all instructions that lose references to them.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_IMMOFF"   caption="Convert 32bit instruction operand to offset">
          <help>
            This option works only in 32bit segments.
            If an instruction has an immediate operand and the operand
            can be represented as a meaningful offset expression, IDA will
          convert it to an offset. However, the value of immediate operand
          must be higher than 0x10000.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_DREFOFF"  caption="Create offset if data xref to seg32 exists">
          <help>
            If IDA encounters a data reference to 32bit segment and the target
            contains 32bit value which can be represented as an offset expression,
            IDA will convert it to an offset.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af2" idc:mask="AF2_DODATA"  caption="Coagulate data segments in the final pass">
          <help>
            This option is meaningful only if "Make final analysis pass"
            is enabled. It allows IDA to convert unexplored bytes to data arrays
            in the data segments. If this option is disabled, IDA will coagulate
            only code segments.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af"  idc:mask="AF_FIXUP"    caption="Create offsets and segments using fixup info">
          <help>
            IDA will use relocation information to make the disassembly
            nicer. In particular, it will convert all data items with
            relocation information to words or dwords like this:

                    dd offset label
                    dw seg seg000

            If an instruction has a relocation information attached to it,
            IDA will convert its immediate operand to an offset or segment:

                    mov     eax, offset label

            You can display the relocation information attached to the current
            item by using show internal flags command.
          </help>
        </checkitem>
        <checkitem variable="/ida/loading/inf/@af2" idc:mask="AF2_DATOFF"  caption="Automatically convert data to offsets">
          <help>
            This option allows IDA to convert all newly created data items
            to offsets if the following conditions are satisfied:
            - the offset target is a valid address in the program
            - the target does not point into the middle of an item
            - if the target is code, the execution does not flow to it
              from the previous instruction
            - the data is dword (4 bytes) in a 32-bit segment
              or qword(8 bytes) in a 64-bit segment
            - the segment type is not special (extern, communal, abs...)
          </help>
        </checkitem>
        Misc
        <checkitem variable="/ida/loading/inf/@af2" idc:mask="AF2_JUMPTBL" caption="Locate and create jump tables">
          <help>
            This option allows IDA to try to guess the address and size of jump
            tables. Please note that disabling this option will not disable
            the recognition of C-style typical switch constructs.
          </help>
        </checkitem>
      </checklistbox>
    </page>

    <page X="analysis_p" title="File loading">
      The input file will now be loaded in IDA.
      <checkbox checked="true" caption="Start analysis now" variable="/ida/loading/inf/@s_auto | /ida/loading/inf/@s_showauto"/>
      Click Finish to start loading the input file in IDA.
    </page>
  </templates>
</ida>
