ghidra.program.model.data.CharDataType Java Examples
The following examples show how to use
ghidra.program.model.data.CharDataType.
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: GoTypesAnalyzer.java From gotools with MIT License | 6 votes |
@Override public boolean added(Program program, AddressSetView addressSetView, TaskMonitor taskMonitor, MessageLog messageLog) throws CancelledException { StructureDataType s = new StructureDataType("GoString", 0); s.add(new QWordDataType(), "len", null); s.add(new Pointer64DataType(new CharDataType()), "str", null); program.getDataTypeManager().addDataType(s, DataTypeConflictHandler.KEEP_HANDLER); StructureDataType sl = new StructureDataType("GoSlice", 0); sl.add(new PointerDataType(), 8, "data", null); sl.add(new QWordDataType(), "len", null); sl.add(new QWordDataType(), "cap", null); program.getDataTypeManager().addDataType(sl, DataTypeConflictHandler.KEEP_HANDLER); return false; }
Example #2
Source File: PreviewTableCellDataTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testDisplayString_StructureFieldLocation() { StructureDataType struct = new StructureDataType("TestStruct", 0); struct.add(new CharDataType()); struct.add(new StringDataType(), 4); struct.add(new TerminatedStringDataType(), 8); struct.add(new UnicodeDataType(), 12); Address structAddress = addr("f0001302"); CreateDataCmd cmd = new CreateDataCmd(structAddress, true, struct); assertTrue(applyCmd(program, cmd)); Address address = addr("f0001307"); int[] componentPath = new int[] { 2 }; // second field Address refAddr = null; String rep = "\"\",00"; int opIndex = 0; int charOffset = 0; OperandFieldLocation location = new OperandFieldLocation(program, address, componentPath, refAddr, rep, opIndex, charOffset); PreviewTableCellData data = new PreviewTableCellData(location, formatter); String preview = data.getDisplayString(); // this is the mnemonic and operand inside of the structure at field [2] assertEquals("ds \"\" (TestStruct.field_0x5)", preview); }