Java Code Examples for ghidra.framework.options.Options#setBoolean()
The following examples show how to use
ghidra.framework.options.Options#setBoolean() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListingPanelTest.java From ghidra with Apache License 2.0 | 6 votes |
private void resetFormatOptions() { Options fieldOptions = cb.getFormatManager().getFieldOptions(); List<String> names = fieldOptions.getOptionNames(); for (String name : names) { if (!name.startsWith("Format Code")) { continue; } if (name.indexOf("Show ") >= 0 || name.indexOf("Flag ") >= 0) { fieldOptions.setBoolean(name, false); } else if (name.indexOf("Lines") >= 0) { fieldOptions.setInt(name, 0); } } waitForPostedSwingRunnables(); cb.updateNow(); }
Example 2
Source File: AbstractSelectByFlowPluginTest.java From ghidra with Apache License 2.0 | 5 votes |
void turnOnAllFollowFlow(Options options) { options.setBoolean(GhidraOptions.OPTION_FOLLOW_COMPUTED_CALL, true); options.setBoolean(GhidraOptions.OPTION_FOLLOW_CONDITIONAL_CALL, true); options.setBoolean(GhidraOptions.OPTION_FOLLOW_UNCONDITIONAL_CALL, true); options.setBoolean(GhidraOptions.OPTION_FOLLOW_COMPUTED_JUMP, true); options.setBoolean(GhidraOptions.OPTION_FOLLOW_CONDITIONAL_JUMP, true); options.setBoolean(GhidraOptions.OPTION_FOLLOW_UNCONDITIONAL_JUMP, true); options.setBoolean(GhidraOptions.OPTION_FOLLOW_POINTERS, true); }
Example 3
Source File: AutoAnalysisWorkerTest.java From ghidra with Apache License 2.0 | 5 votes |
@Override public boolean applyTo(DomainObject obj, TaskMonitor monitor) { try { Thread.sleep(delay); } catch (InterruptedException e) { Assert.fail();// should never happen } Program p = (Program) obj; Options list = p.getOptions("TEST"); list.setBoolean(property, true); return true; }
Example 4
Source File: ListingPanelTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testProgramLocation4() { int id = program.startTransaction("test"); Instruction inst = program.getListing().getInstructionAt(addr(0x1004772)); String comment1 = "This is a very long comment."; String comment2 = "I want this sentence to wrap to the next line so that I can test wrapping."; String[] comments = new String[] { comment1, comment2 }; inst.setCommentAsArray(CodeUnit.EOL_COMMENT, comments); program.endTransaction(id, true); Options opt = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS); opt.setBoolean("EOL Comments Field.Enable Word Wrapping", true); cb.updateNow(); Layout l = getLayout(addr(0x1004772)); env.showTool(); ListingField f = (ListingField) l.getField(4); assertEquals(comment1 + " " + comment2, f.getText()); FieldFactory ff = f.getFieldFactory(); RowColLocation rc = f.textOffsetToScreenLocation(3); ProgramLocation loc = ff.getProgramLocation(rc.row(), rc.col(), f); assertEquals(EolCommentFieldLocation.class, loc.getClass()); EolCommentFieldLocation bfloc = (EolCommentFieldLocation) loc; assertEquals(0, bfloc.getRow()); assertEquals(3, bfloc.getCharOffset()); rc = f.textOffsetToScreenLocation(72); assertEquals(2, rc.row()); loc = ff.getProgramLocation(rc.row(), rc.col(), f); assertEquals(EolCommentFieldLocation.class, loc.getClass()); bfloc = (EolCommentFieldLocation) loc; assertEquals(1, bfloc.getRow()); assertEquals(42, bfloc.getCharOffset()); }
Example 5
Source File: PeLoader.java From ghidra with Apache License 2.0 | 5 votes |
private void processProperties(OptionalHeader optionalHeader, Program prog, TaskMonitor monitor) { if (monitor.isCancelled()) { return; } Options props = prog.getOptions(Program.PROGRAM_INFO); props.setInt("SectionAlignment", optionalHeader.getSectionAlignment()); props.setBoolean(RelocationTable.RELOCATABLE_PROP_NAME, prog.getRelocationTable().getSize() > 0); }
Example 6
Source File: CodeBrowserOptionsTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testBytesFieldOptions_NoDisplayStructureAlignmentBytes() throws Exception { showTool(tool); loadProgram(); Options options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS); options.setBoolean("Bytes Field.Display Structure Alignment Bytes", false); Address addr = addr("0x1001100"); cb.goTo(new BytesFieldLocation(program, addr, addr, new int[] { 1 }, 0)); // causes structure to open cb.goToField(addr("0x1001100"), "Bytes", 1, 0, 0); ListingTextField btf = (ListingTextField) cb.getCurrentField(); assertEquals("01", btf.getText()); assertEquals(3, btf.getNumCols(0)); FieldElement fe = btf.getFieldElement(0, 1); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); cb.goToField(addr("0x1001104"), "Bytes", 0, 0); btf = (ListingTextField) cb.getCurrentField(); assertEquals("05 06 07 08", btf.getText()); assertEquals(12, btf.getNumCols(0)); fe = btf.getFieldElement(0, 1); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 3); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 6); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 9); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); cb.goToField(addr("0x1001108"), "Bytes", 0, 0); btf = (ListingTextField) cb.getCurrentField(); assertEquals("09", btf.getText()); assertEquals(3, btf.getNumCols(0)); fe = btf.getFieldElement(0, 1); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); }
Example 7
Source File: PropertyListMergeManager.java From ghidra with Apache License 2.0 | 5 votes |
private void setValue(Options options, String propertyName, OptionType type, Object value) { switch (type) { case BOOLEAN_TYPE: options.setBoolean(propertyName, ((Boolean) value).booleanValue()); break; case DOUBLE_TYPE: options.setDouble(propertyName, ((Double) value).doubleValue()); break; case INT_TYPE: options.setInt(propertyName, ((Integer) value).intValue()); break; case LONG_TYPE: options.setLong(propertyName, ((Long) value).longValue()); break; case STRING_TYPE: options.setString(propertyName, (String) value); break; case DATE_TYPE: options.setDate(propertyName, (Date) value); break; case NO_TYPE: default: } }
Example 8
Source File: CodeBrowserOptionsTest.java From ghidra with Apache License 2.0 | 4 votes |
@Test public void testXrefFieldOptions() throws Exception { showTool(tool); loadProgram(); Options options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS); List<String> names = getOptionNames(options, "XREFs Field"); assertEquals("XREFs Field.Delimiter", names.get(0)); assertEquals("XREFs Field.Display Local Block", names.get(1)); assertEquals("XREFs Field.Display Namespace", names.get(2)); assertEquals("XREFs Field.Display Reference Type", names.get(3)); assertEquals("XREFs Field.Maximum Number of XREFs to Display", names.get(4)); assertTrue(cb.goToField(addr("0x1003d9f"), "XRef", 0, 0)); // test Delimiter options.setString(names.get(0), "/"); cb.updateNow(); assertTrue(cb.goToField(addr("0x1003d9f"), "XRef", 0, 0)); ListingTextField btf = (ListingTextField) cb.getCurrentField(); assertTrue(btf.getText().indexOf("/") > 0); options.setString(names.get(0), ","); cb.updateNow(); // test show function name assertTrue(cb.goToField(addr("0x10048b6"), "XRef", 0, 0)); btf = (ListingTextField) cb.getCurrentField(); assertEquals("010048ae(j) ", btf.getFieldElement(0, 0).getText()); // namespace options // -Display non-local // -Display local // -Use local namespace override NamespaceWrappedOption newCustomOption = new NamespaceWrappedOption(); // show local namespace newCustomOption.setShowNonLocalNamespace(false); newCustomOption.setShowLocalNamespace(true); newCustomOption.setUseLocalPrefixOverride(false); options.setCustomOption(names.get(2), newCustomOption); cb.updateNow(); assertTrue(cb.goToField(addr("0x10048b6"), "XRef", 0, 0)); btf = (ListingTextField) cb.getCurrentField(); assertEquals("doStuff:010048ae(j) ", btf.getFieldElement(0, 0).getText()); // don't show local namespace newCustomOption.setShowLocalNamespace(false); options.setCustomOption(names.get(2), newCustomOption); cb.updateNow(); assertTrue(cb.goToField(addr("0x10048b6"), "XRef", 0, 0)); btf = (ListingTextField) cb.getCurrentField(); assertEquals("010048ae(j) ", btf.getFieldElement(0, 0).getText()); // local namespace override newCustomOption.setShowLocalNamespace(true); newCustomOption.setUseLocalPrefixOverride(true); String overrideName = "overrideMe"; newCustomOption.setLocalPrefixText(overrideName); options.setCustomOption(names.get(2), newCustomOption); cb.updateNow(); assertTrue(cb.goToField(addr("0x10048b6"), "XRef", 0, 0)); btf = (ListingTextField) cb.getCurrentField(); assertEquals(overrideName + "010048ae(j) ", btf.getFieldElement(0, 0).getText()); // test show block name options.setBoolean(names.get(1), false); cb.updateNow(); assertTrue(cb.goToField(addr("0x1008094"), "XRef", 0, 0)); btf = (ListingTextField) cb.getCurrentField(); assertEquals("01004990(R),", btf.getFieldElement(0, 0).getText()); options.setBoolean(names.get(1), true); cb.updateNow(); assertTrue(cb.goToField(addr("0x1008094"), "XRef", 0, 0)); btf = (ListingTextField) cb.getCurrentField(); assertEquals(".text:01004990(R),", btf.getFieldElement(0, 0).getText()); // test max Xrefs to display assertTrue(cb.goToField(addr("0x1003d9f"), "XRef", 0, 0)); btf = (ListingTextField) cb.getCurrentField(); assertEquals(9, btf.getNumRows()); options.setInt(names.get(4), 3); cb.updateNow(); assertTrue(cb.goToField(addr("0x1003d9f"), "XRef", 0, 0)); btf = (ListingTextField) cb.getCurrentField(); assertEquals(3, btf.getNumRows()); assertTrue(btf.getText().endsWith("[more]")); }
Example 9
Source File: AbstractToolSavingTest.java From ghidra with Apache License 2.0 | 4 votes |
protected void setBooleanFooOptions(PluginTool tool, boolean value) { Options options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS); options.setBoolean("foo", value); }
Example 10
Source File: AbstractSelectByFlowPluginTest.java From ghidra with Apache License 2.0 | 4 votes |
void followUnconditionalJumps(boolean follow, Options options) { options.setBoolean(GhidraOptions.OPTION_FOLLOW_UNCONDITIONAL_JUMP, follow); }
Example 11
Source File: CommentsPluginTest.java From ghidra with Apache License 2.0 | 4 votes |
@Test public void testEolFieldToolInteraction() throws Exception { openX86ProgramInTool(); PluginTool tool2 = env.launchAnotherDefaultTool(); configureTool(tool2); env.connectTools(tool, tool2); env.connectTools(tool2, tool); env.open(program); // do this again now that the tools are in-sync Address addr = addr(0x01006420); sendProgramLocation(addr, CodeUnit.EOL_COMMENT); String comment = "Drag and Drop is a direct manipulation gesture\n" + "found in many Graphical User Interface\n" + "systems that provides a mechanism to transfer information\n" + "between two entities logically associated with\n" + "presentation elements in the GUI.\n"; setAt(addr, CodeUnit.EOL_COMMENT, comment, "OK"); setFieldWidth(browser, EolCommentFieldFactory.FIELD_NAME, 100); Options options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS); options.setBoolean(EolCommentFieldFactory.ENABLE_WORD_WRAP_MSG, true); options.setInt(EolCommentFieldFactory.MAX_DISPLAY_LINES_MSG, 100); runSwing(() -> tool.getToolFrame().setSize(800, 800)); CodeBrowserPlugin browser2 = getPlugin(tool2, CodeBrowserPlugin.class); setFieldWidth(browser2, EolCommentFieldFactory.FIELD_NAME, 400); runSwing(() -> tool2.getToolFrame().setSize(1200, 800)); browser.goToField(addr, EolCommentFieldFactory.FIELD_NAME, 17, 4); assertEquals(17, browser.getCurrentFieldLoction().getRow()); assertEquals(4, browser.getCurrentFieldLoction().getCol()); assertEquals(3, browser2.getCurrentFieldLoction().getRow()); assertEquals(46, browser2.getCurrentFieldLoction().getCol()); }
Example 12
Source File: CodeBrowserOptionsTest.java From ghidra with Apache License 2.0 | 4 votes |
@Test public void testBytesFieldOptions_DisplayStructureAlignmentBytesWithGrouping() throws Exception { showTool(tool); loadProgram(); Options options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS); options.setBoolean("Bytes Field.Display Structure Alignment Bytes", true); options.setInt("Bytes Field.Byte Group Size", 2); Address addr = addr("0x1001100"); cb.goTo(new BytesFieldLocation(program, addr, addr, new int[] { 1 }, 0)); // causes structure to open cb.goToField(addr("0x1001100"), "Bytes", 1, 0, 0); ListingTextField btf = (ListingTextField) cb.getCurrentField(); assertEquals("0102 0304", btf.getText()); assertEquals(10, btf.getNumCols(0)); FieldElement fe = btf.getFieldElement(0, 1); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 2); assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 5); assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 7); assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0)); cb.goToField(addr("0x1001104"), "Bytes", 0, 0); btf = (ListingTextField) cb.getCurrentField(); assertEquals("0506 0708", btf.getText()); assertEquals(10, btf.getNumCols(0)); fe = btf.getFieldElement(0, 1); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 2); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 5); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 7); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); cb.goToField(addr("0x1001108"), "Bytes", 0, 0); btf = (ListingTextField) cb.getCurrentField(); assertEquals("090a 0b0c", btf.getText()); assertEquals(10, btf.getNumCols(0)); fe = btf.getFieldElement(0, 1); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 2); assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 5); assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 7); assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0)); }
Example 13
Source File: TRICORE_BE_O3_EmulatorTest.java From ghidra with Apache License 2.0 | 4 votes |
@Override protected void setAnalysisOptions(Options analysisOptions) { super.setAnalysisOptions(analysisOptions); analysisOptions.setBoolean("Reference", false); // too many bad disassemblies }
Example 14
Source File: AVR8_6_GCC_O3_EmulatorTest.java From ghidra with Apache License 2.0 | 4 votes |
@Override protected void setAnalysisOptions(Options analysisOptions) { super.setAnalysisOptions(analysisOptions); analysisOptions.setBoolean("Reference", false); // too many bad disassemblies analysisOptions.setBoolean("Data Reference", false); }
Example 15
Source File: AbstractSelectByFlowPluginTest.java From ghidra with Apache License 2.0 | 4 votes |
void followUnconditionalCalls(boolean follow, Options options) { options.setBoolean(GhidraOptions.OPTION_FOLLOW_UNCONDITIONAL_CALL, follow); }
Example 16
Source File: CodeBrowserOptionsTest.java From ghidra with Apache License 2.0 | 4 votes |
@Test public void testBytesFieldOptions_DisplayStructureAlignmentBytes() throws Exception { showTool(tool); loadProgram(); Options options = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS); options.setBoolean("Bytes Field.Display Structure Alignment Bytes", true); Address addr = addr("0x1001100"); cb.goTo(new BytesFieldLocation(program, addr, addr, new int[] { 1 }, 0)); // causes structure to open cb.goToField(addr("0x1001100"), "Bytes", 1, 0, 0); ListingTextField btf = (ListingTextField) cb.getCurrentField(); assertEquals("01 02 03 04", btf.getText()); assertEquals(12, btf.getNumCols(0)); FieldElement fe = btf.getFieldElement(0, 1); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 3); assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 6); assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 9); assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0)); cb.goToField(addr("0x1001104"), "Bytes", 0, 0); btf = (ListingTextField) cb.getCurrentField(); assertEquals("05 06 07 08", btf.getText()); assertEquals(12, btf.getNumCols(0)); fe = btf.getFieldElement(0, 1); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 3); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 6); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 9); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); cb.goToField(addr("0x1001108"), "Bytes", 0, 0); btf = (ListingTextField) cb.getCurrentField(); assertEquals("09 0a 0b 0c", btf.getText()); assertEquals(12, btf.getNumCols(0)); fe = btf.getFieldElement(0, 1); assertEquals(BytesFieldFactory.DEFAULT_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 3); assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 6); assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0)); fe = btf.getFieldElement(0, 9); assertEquals(BytesFieldFactory.ALIGNMENT_BYTES_COLOR, fe.getColor(0)); }
Example 17
Source File: AVR32_BE_O3_EmulatorTest.java From ghidra with Apache License 2.0 | 4 votes |
@Override protected void setAnalysisOptions(Options analysisOptions) { super.setAnalysisOptions(analysisOptions); analysisOptions.setBoolean("Reference", false); // too many bad disassemblies analysisOptions.setBoolean("Data Reference", false); // too many bad disassemblies }
Example 18
Source File: AVR8_6_GCC_O0_EmulatorTest.java From ghidra with Apache License 2.0 | 4 votes |
@Override protected void setAnalysisOptions(Options analysisOptions) { super.setAnalysisOptions(analysisOptions); analysisOptions.setBoolean("Reference", false); // too many bad disassemblies analysisOptions.setBoolean("Data Reference", false); }
Example 19
Source File: AVR8_51_GCC_O0_EmulatorTest.java From ghidra with Apache License 2.0 | 4 votes |
@Override protected void setAnalysisOptions(Options analysisOptions) { super.setAnalysisOptions(analysisOptions); analysisOptions.setBoolean("Reference", false); // too many bad disassemblies analysisOptions.setBoolean("Data Reference", false); }
Example 20
Source File: AbstractSelectByFlowPluginTest.java From ghidra with Apache License 2.0 | 4 votes |
void followPointers(boolean follow, Options options) { options.setBoolean(GhidraOptions.OPTION_FOLLOW_POINTERS, follow); }