Java Code Examples for ghidra.program.model.listing.CodeUnit#EOL_COMMENT
The following examples show how to use
ghidra.program.model.listing.CodeUnit#EOL_COMMENT .
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: EhFrameHeaderSection.java From ghidra with Apache License 2.0 | 6 votes |
/** * Create the data field for the number of entries in the FDE table * and add an identifying comment. * * @param curAddress address of the FDE count field * @param fdeDecoder decoder to use in determining data type for this field * @return the next address after the FDE count field */ private Address processEncodedFdeCount(Address curAddress, DwarfEHDecoder fdeDecoder) { /* Create the Encoded FDE count member */ DataType encDataType = fdeDecoder.getDataType(program); CreateDataCmd dataCmd = new CreateDataCmd(curAddress, encDataType); dataCmd.applyTo(program); SetCommentCmd commentCmd = new SetCommentCmd(curAddress, CodeUnit.EOL_COMMENT, "Encoded FDE count"); commentCmd.applyTo(program); curAddress = curAddress.add(encDataType.getLength()); return curAddress; }
Example 2
Source File: EhFrameHeaderSection.java From ghidra with Apache License 2.0 | 6 votes |
/** * Create the data field for the exception handler frame pointer. Also create the associated * reference, and add an identifying comment. * * @param curAddress address of the frame pointer field * @param eh_frame_hdr the frame header with encoding information * @param curMemBlock the memory block containing this header * @return the next address after the frame pointer field * @throws MemoryAccessException if the field's memory can't be read */ private Address processEncodedFramePointer(Address curAddress, ExceptionHandlerFrameHeader eh_frame_hdr, MemoryBlock curMemBlock) throws MemoryAccessException { /* Create the encoded Exception Handler Frame Pointer */ DwarfEHDecoder frmPtrDecoder = DwarfDecoderFactory.getDecoder(eh_frame_hdr.getEh_FramePtrEncoding()); Address frmPtrAddr = frmPtrDecoder.decodeAddress(new DwarfDecodeContext(program, curAddress, curMemBlock)); program.getReferenceManager().addMemoryReference(curAddress, frmPtrAddr, RefType.DATA, SourceType.ANALYSIS, 0); DataType frmPtrDataType = frmPtrDecoder.getDataType(program); CreateDataCmd dataCmd = new CreateDataCmd(curAddress, frmPtrDataType); dataCmd.applyTo(program); SetCommentCmd commentCmd = new SetCommentCmd(curAddress, CodeUnit.EOL_COMMENT, "Encoded eh_frame_ptr"); commentCmd.applyTo(program); curAddress = curAddress.add(frmPtrDataType.getLength()); return curAddress; }
Example 3
Source File: CommentWindowPlugin.java From ghidra with Apache License 2.0 | 6 votes |
private int getCommentType(int type) { if (type == ChangeManager.DOCR_PRE_COMMENT_CHANGED) { return CodeUnit.PRE_COMMENT; } if (type == ChangeManager.DOCR_POST_COMMENT_CHANGED) { return CodeUnit.POST_COMMENT; } if (type == ChangeManager.DOCR_EOL_COMMENT_CHANGED) { return CodeUnit.EOL_COMMENT; } if (type == ChangeManager.DOCR_PLATE_COMMENT_CHANGED) { return CodeUnit.PLATE_COMMENT; } if ((type == ChangeManager.DOCR_REPEATABLE_COMMENT_CHANGED) || (type == ChangeManager.DOCR_REPEATABLE_COMMENT_ADDED) || (type == ChangeManager.DOCR_REPEATABLE_COMMENT_REMOVED) || (type == ChangeManager.DOCR_REPEATABLE_COMMENT_CREATED) || (type == ChangeManager.DOCR_REPEATABLE_COMMENT_DELETED)) { return CodeUnit.REPEATABLE_COMMENT; } return -1; }
Example 4
Source File: CommentsDialog.java From ghidra with Apache License 2.0 | 6 votes |
void setCommentType(int type) { switch (type) { case CodeUnit.EOL_COMMENT: tab.setSelectedIndex(0); break; case CodeUnit.PRE_COMMENT: tab.setSelectedIndex(1); break; case CodeUnit.POST_COMMENT: tab.setSelectedIndex(2); break; case CodeUnit.PLATE_COMMENT: tab.setSelectedIndex(3); break; case CodeUnit.REPEATABLE_COMMENT: tab.setSelectedIndex(4); break; } }
Example 5
Source File: CommentHistoryDialog.java From ghidra with Apache License 2.0 | 6 votes |
private JPanel buildMainPanel() { JPanel mainPanel = new JPanel(new BorderLayout()); tabbedPane = new JTabbedPane(); mainPanel.add(tabbedPane); eolPanel = new CommentHistoryPanel(CodeUnit.EOL_COMMENT); prePanel = new CommentHistoryPanel(CodeUnit.PRE_COMMENT); postPanel = new CommentHistoryPanel(CodeUnit.POST_COMMENT); platePanel = new CommentHistoryPanel(CodeUnit.PLATE_COMMENT); repeatablePanel = new CommentHistoryPanel(CodeUnit.REPEATABLE_COMMENT); JScrollPane sp = new JScrollPane(eolPanel); JViewport vp = sp.getViewport(); Dimension d = vp.getPreferredSize(); sp.getViewport().setPreferredSize(new Dimension(500, d.height*7)); tabbedPane.addTab(" EOL Comment ",sp); tabbedPane.addTab(" Pre Comment ",new JScrollPane(prePanel)); tabbedPane.addTab(" Post Comment ",new JScrollPane(postPanel)); tabbedPane.addTab(" Plate Comment ",new JScrollPane(platePanel)); tabbedPane.addTab(" Repeatable Comment ", new JScrollPane(repeatablePanel)); tabbedPane.addChangeListener(this); return mainPanel; }
Example 6
Source File: CommentMerger.java From ghidra with Apache License 2.0 | 6 votes |
private int getCodeUnitCommentType(int programMergeCommentType) { switch (programMergeCommentType) { case ProgramMergeFilter.PLATE_COMMENTS: return CodeUnit.PLATE_COMMENT; case ProgramMergeFilter.PRE_COMMENTS: return CodeUnit.PRE_COMMENT; case ProgramMergeFilter.EOL_COMMENTS: return CodeUnit.EOL_COMMENT; case ProgramMergeFilter.REPEATABLE_COMMENTS: return CodeUnit.REPEATABLE_COMMENT; case ProgramMergeFilter.POST_COMMENTS: return CodeUnit.POST_COMMENT; default: return -1; } }
Example 7
Source File: DataComponent.java From ghidra with Apache License 2.0 | 5 votes |
/** * @see ghidra.program.model.listing.CodeUnit#getComment(int) */ @Override public String getComment(int commentType) { String cmt = super.getComment(commentType); if (cmt == null && commentType == CodeUnit.EOL_COMMENT && component != null) { cmt = component.getComment(); } return cmt; }
Example 8
Source File: CommentFieldLocation.java From ghidra with Apache License 2.0 | 5 votes |
/** * Checks that the type is a valid comment type. * @throws IllegalArgumentException if this doesn't have a valid comment type. */ protected void validateType() { if (type != CodeUnit.PRE_COMMENT && type != CodeUnit.POST_COMMENT && type != CodeUnit.EOL_COMMENT && type != CodeUnit.REPEATABLE_COMMENT && type != CodeUnit.PLATE_COMMENT && type != CodeUnit.NO_COMMENT) { throw new IllegalArgumentException( "The comment type was " + type + ", but it must be from 0 to 4"); } }
Example 9
Source File: CommentType.java From ghidra with Apache License 2.0 | 5 votes |
/** * Get the comment type from the current location. If the cursor * is not over a comment, then just return EOL as the default. * @param cu * @param loc * @param defaultCommentType * @return comment type */ public static int getCommentType(CodeUnit cu, ProgramLocation loc, int defaultCommentType) { if (loc instanceof CommentFieldLocation) { CommentFieldLocation cfLoc = (CommentFieldLocation) loc; return cfLoc.getCommentType(); } else if (loc instanceof PlateFieldLocation) { return CodeUnit.PLATE_COMMENT; } else if (loc instanceof FunctionRepeatableCommentFieldLocation) { return CodeUnit.REPEATABLE_COMMENT; } else if (cu != null) { if (cu.getComment(CodeUnit.PRE_COMMENT) != null) { return CodeUnit.PRE_COMMENT; } if (cu.getComment(CodeUnit.POST_COMMENT) != null) { return CodeUnit.POST_COMMENT; } if (cu.getComment(CodeUnit.EOL_COMMENT) != null) { return CodeUnit.EOL_COMMENT; } if (cu.getComment(CodeUnit.PLATE_COMMENT) != null) { return CodeUnit.PLATE_COMMENT; } if (cu.getComment(CodeUnit.REPEATABLE_COMMENT) != null) { return CodeUnit.REPEATABLE_COMMENT; } } return defaultCommentType; }
Example 10
Source File: CommentHistoryDialog.java From ghidra with Apache License 2.0 | 5 votes |
private CommentHistoryPanel getHistoryPanel(int commentType) { switch(commentType) { case CodeUnit.EOL_COMMENT: return eolPanel; case CodeUnit.PRE_COMMENT: return prePanel; case CodeUnit.POST_COMMENT: return postPanel; case CodeUnit.PLATE_COMMENT: return platePanel; case CodeUnit.REPEATABLE_COMMENT: return repeatablePanel; } return null; }
Example 11
Source File: CommentsPlugin.java From ghidra with Apache License 2.0 | 4 votes |
private void updatePopupPath(DockingAction action, String actionString, ProgramLocation loc) { String endString = ""; if (action == historyAction) { endString = "..."; } if (loc instanceof FunctionRepeatableCommentFieldLocation) { action.getPopupMenuData().setMenuPath( new String[] { "Comments", actionString + " Repeatable Comment" + endString }); return; } if (loc instanceof PlateFieldLocation) { action.getPopupMenuData().setMenuPath( new String[] { "Comments", actionString + " Plate Comment" + endString }); return; } CommentFieldLocation cfLoc = (CommentFieldLocation) loc; int type = cfLoc.getCommentType(); switch (type) { case CodeUnit.PRE_COMMENT: action.getPopupMenuData().setMenuPath( new String[] { "Comments", actionString + " Pre-Comment" + endString }); break; case CodeUnit.POST_COMMENT: action.getPopupMenuData().setMenuPath( new String[] { "Comments", actionString + " Post-Comment" + endString }); break; case CodeUnit.EOL_COMMENT: action.getPopupMenuData().setMenuPath( new String[] { "Comments", actionString + " EOL Comment" + endString }); break; case CodeUnit.REPEATABLE_COMMENT: action.getPopupMenuData().setMenuPath( new String[] { "Comments", actionString + " Repeatable Comment" + endString }); break; } }
Example 12
Source File: EolCommentMarkupType.java From ghidra with Apache License 2.0 | 4 votes |
@Override protected int getCodeUnitCommentType() { return CodeUnit.EOL_COMMENT; }
Example 13
Source File: EolCommentFieldLocation.java From ghidra with Apache License 2.0 | 3 votes |
/** * Construct a new EolCommentFieldLocation. * * @param program the program of the location * @param addr the address of the codeunit. * @param componentPath the componentPath of the codeUnit * @param comment comment text for the particular comment indicated by the address, subtype, and reference address. * @param displayableCommentRow the line within the Eol comment as displayed. * @param charOffset the character position on the line within the comment line. * @param currentCommentRow the row index relative to the beginning of the End of Line comment * as displayed in the Eol comment field. */ public EolCommentFieldLocation(Program program, Address addr, int[] componentPath, String[] comment, int displayableCommentRow, int charOffset, int currentCommentRow) { super(program, addr, componentPath, comment, CodeUnit.EOL_COMMENT, displayableCommentRow, charOffset); this.currentCommentRow = currentCommentRow; }
Example 14
Source File: RefRepeatCommentFieldLocation.java From ghidra with Apache License 2.0 | 3 votes |
/** * Construct a new RefRepeatCommentFieldLocation. * * @param program the program of the location * @param addr the address of the codeunit. * @param componentPath the componentPath of the codeUnit * @param comment comment text for the particular comment indicated by the address, subtype, and reference address. * @param row the line within the Eol comment. * @param charOffset the character position on the line within the comment line. * @param currentCommentRow the row index relative to the beginning of the particular * referenced repeatable comment that is displayed at this location in the Eol comment field. * @param refRepeatAddress the referred to address for the referenced repeatable comment that * is being displayed at this location. */ public RefRepeatCommentFieldLocation(Program program, Address addr, int[] componentPath, String[] comment, int row, int charOffset, int currentCommentRow, Address refRepeatAddress) { super(program, addr, componentPath, comment, CodeUnit.EOL_COMMENT, row, charOffset); this.currentCommentRow = currentCommentRow; this.refRepeatAddress = refRepeatAddress; }
Example 15
Source File: AutomaticCommentFieldLocation.java From ghidra with Apache License 2.0 | 2 votes |
/** * Construct a new AutomaticCommentFieldLocation. * * @param program the program of the location * @param addr the address of the codeunit. * @param componentPath the componentPath of the codeUnit * @param comment comment text for the particular comment indicated by the address, subtype, and reference address. * @param row the line within the Eol comment. * @param charOffset the character position on the line within the comment line. * @param currentCommentRow the row index relative to the beginning of the automatic comment * as displayed in the Eol comment field. */ public AutomaticCommentFieldLocation(Program program, Address addr, int[] componentPath, String[] comment, int row, int charOffset, int currentCommentRow) { super(program, addr, componentPath, comment, CodeUnit.EOL_COMMENT, row, charOffset); this.currentCommentRow = currentCommentRow; }