repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
raydac/netbeans-mmd-plugin
mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java
MindMapPanel.putSessionObject
public void putSessionObject(@Nonnull final String key, @Nullable final Object obj) { this.lock(); try { if (obj == null) { this.sessionObjects.remove(key); } else { this.sessionObjects.put(key, obj); } } finally { this.unlock(); } }
java
public void putSessionObject(@Nonnull final String key, @Nullable final Object obj) { this.lock(); try { if (obj == null) { this.sessionObjects.remove(key); } else { this.sessionObjects.put(key, obj); } } finally { this.unlock(); } }
[ "public", "void", "putSessionObject", "(", "@", "Nonnull", "final", "String", "key", ",", "@", "Nullable", "final", "Object", "obj", ")", "{", "this", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "obj", "==", "null", ")", "{", "this", ".", "s...
Put session object for key. @param key key of he object, must not be null @param obj object to be placed, if null then object will be removed @since 1.4.2
[ "Put", "session", "object", "for", "key", "." ]
997493d23556a25354372b6419a64a0fbd0ac6ba
https://github.com/raydac/netbeans-mmd-plugin/blob/997493d23556a25354372b6419a64a0fbd0ac6ba/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java#L1282-L1293
train
raydac/netbeans-mmd-plugin
mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java
MindMapPanel.executeModelJobs
public void executeModelJobs(@Nonnull @MustNotContainNull final ModelJob... jobs) { Utils.safeSwingCall(new Runnable() { @Override public void run() { for (final ModelJob j : jobs) { try { if (!j.doChangeModel(model)) { break; } } catch (...
java
public void executeModelJobs(@Nonnull @MustNotContainNull final ModelJob... jobs) { Utils.safeSwingCall(new Runnable() { @Override public void run() { for (final ModelJob j : jobs) { try { if (!j.doChangeModel(model)) { break; } } catch (...
[ "public", "void", "executeModelJobs", "(", "@", "Nonnull", "@", "MustNotContainNull", "final", "ModelJob", "...", "jobs", ")", "{", "Utils", ".", "safeSwingCall", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{...
Safe Swing thread execution sequence of some jobs over model with model changed notification in the end @param jobs sequence of jobs to be executed @since 1.3.1
[ "Safe", "Swing", "thread", "execution", "sequence", "of", "some", "jobs", "over", "model", "with", "model", "changed", "notification", "in", "the", "end" ]
997493d23556a25354372b6419a64a0fbd0ac6ba
https://github.com/raydac/netbeans-mmd-plugin/blob/997493d23556a25354372b6419a64a0fbd0ac6ba/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java#L1574-L1590
train
raydac/netbeans-mmd-plugin
mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java
MindMapPanel.setModel
public void setModel(@Nonnull final MindMap model, final boolean notifyModelChangeListeners) { this.lock(); try { if (this.elementUnderEdit != null) { Utils.safeSwingBlockingCall(new Runnable() { @Override public void run() { endEdit(false); } }); ...
java
public void setModel(@Nonnull final MindMap model, final boolean notifyModelChangeListeners) { this.lock(); try { if (this.elementUnderEdit != null) { Utils.safeSwingBlockingCall(new Runnable() { @Override public void run() { endEdit(false); } }); ...
[ "public", "void", "setModel", "(", "@", "Nonnull", "final", "MindMap", "model", ",", "final", "boolean", "notifyModelChangeListeners", ")", "{", "this", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "this", ".", "elementUnderEdit", "!=", "null", ")", ...
Set model for the panel, allows to notify listeners optionally. @param model model to be set @param notifyModelChangeListeners true if to notify model change listeners, false otherwise @since 1.3.0
[ "Set", "model", "for", "the", "panel", "allows", "to", "notify", "listeners", "optionally", "." ]
997493d23556a25354372b6419a64a0fbd0ac6ba
https://github.com/raydac/netbeans-mmd-plugin/blob/997493d23556a25354372b6419a64a0fbd0ac6ba/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java#L2112-L2160
train
raydac/netbeans-mmd-plugin
mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java
MindMapPanel.lockIfNotDisposed
public boolean lockIfNotDisposed() { boolean result = false; if (this.panelLocker != null) { this.panelLocker.lock(); if (this.disposed.get()) { this.panelLocker.unlock(); } else { result = true; } } return result; }
java
public boolean lockIfNotDisposed() { boolean result = false; if (this.panelLocker != null) { this.panelLocker.lock(); if (this.disposed.get()) { this.panelLocker.unlock(); } else { result = true; } } return result; }
[ "public", "boolean", "lockIfNotDisposed", "(", ")", "{", "boolean", "result", "=", "false", ";", "if", "(", "this", ".", "panelLocker", "!=", "null", ")", "{", "this", ".", "panelLocker", ".", "lock", "(", ")", ";", "if", "(", "this", ".", "disposed", ...
Try lock the panel if it is not disposed. @return true if the panel is locked successfully, false if the panel has been disposed.
[ "Try", "lock", "the", "panel", "if", "it", "is", "not", "disposed", "." ]
997493d23556a25354372b6419a64a0fbd0ac6ba
https://github.com/raydac/netbeans-mmd-plugin/blob/997493d23556a25354372b6419a64a0fbd0ac6ba/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java#L2589-L2600
train
raydac/netbeans-mmd-plugin
mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java
MindMapPanel.lock
@Nonnull public MindMapPanel lock() { if (this.panelLocker != null) { this.panelLocker.lock(); if (this.isDisposed()) { this.panelLocker.unlock(); throw new IllegalStateException("Mind map has been already disposed!"); } } return this; }
java
@Nonnull public MindMapPanel lock() { if (this.panelLocker != null) { this.panelLocker.lock(); if (this.isDisposed()) { this.panelLocker.unlock(); throw new IllegalStateException("Mind map has been already disposed!"); } } return this; }
[ "@", "Nonnull", "public", "MindMapPanel", "lock", "(", ")", "{", "if", "(", "this", ".", "panelLocker", "!=", "null", ")", "{", "this", ".", "panelLocker", ".", "lock", "(", ")", ";", "if", "(", "this", ".", "isDisposed", "(", ")", ")", "{", "this"...
Lock the panel. @return the panel @throws IllegalStateException it will be thrown if the panel is disposed
[ "Lock", "the", "panel", "." ]
997493d23556a25354372b6419a64a0fbd0ac6ba
https://github.com/raydac/netbeans-mmd-plugin/blob/997493d23556a25354372b6419a64a0fbd0ac6ba/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java#L2608-L2618
train
raydac/netbeans-mmd-plugin
mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java
MindMapPanel.copyTopicsToClipboard
public boolean copyTopicsToClipboard(final boolean cut, @Nonnull @MustNotContainNull final Topic... topics) { boolean result = false; if (this.lockIfNotDisposed()) { try { if (topics.length > 0) { final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); cl...
java
public boolean copyTopicsToClipboard(final boolean cut, @Nonnull @MustNotContainNull final Topic... topics) { boolean result = false; if (this.lockIfNotDisposed()) { try { if (topics.length > 0) { final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); cl...
[ "public", "boolean", "copyTopicsToClipboard", "(", "final", "boolean", "cut", ",", "@", "Nonnull", "@", "MustNotContainNull", "final", "Topic", "...", "topics", ")", "{", "boolean", "result", "=", "false", ";", "if", "(", "this", ".", "lockIfNotDisposed", "(",...
Create transferable topic list in system clipboard. @param cut true shows that remove topics after placing into clipboard @param topics topics to be placed into clipboard, if there are successors and ancestors then successors will be removed @return true if topic array is not empty and operation completed successfully...
[ "Create", "transferable", "topic", "list", "in", "system", "clipboard", "." ]
997493d23556a25354372b6419a64a0fbd0ac6ba
https://github.com/raydac/netbeans-mmd-plugin/blob/997493d23556a25354372b6419a64a0fbd0ac6ba/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java#L2647-L2668
train
raydac/netbeans-mmd-plugin
mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java
MindMapPanel.pasteTopicsFromClipboard
public boolean pasteTopicsFromClipboard() { boolean result = false; if (this.lockIfNotDisposed()) { try { final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); if (Utils.isDataFlavorAvailable(clipboard, MMDTopicsTransferable.MMD_DATA_FLAVOR)) { try { ...
java
public boolean pasteTopicsFromClipboard() { boolean result = false; if (this.lockIfNotDisposed()) { try { final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); if (Utils.isDataFlavorAvailable(clipboard, MMDTopicsTransferable.MMD_DATA_FLAVOR)) { try { ...
[ "public", "boolean", "pasteTopicsFromClipboard", "(", ")", "{", "boolean", "result", "=", "false", ";", "if", "(", "this", ".", "lockIfNotDisposed", "(", ")", ")", "{", "try", "{", "final", "Clipboard", "clipboard", "=", "Toolkit", ".", "getDefaultToolkit", ...
Paste topics from clipboard to currently selected ones. @return true if there detected topic list in clipboard and these topics added to selected ones, false otherwise @since 1.3.1
[ "Paste", "topics", "from", "clipboard", "to", "currently", "selected", "ones", "." ]
997493d23556a25354372b6419a64a0fbd0ac6ba
https://github.com/raydac/netbeans-mmd-plugin/blob/997493d23556a25354372b6419a64a0fbd0ac6ba/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/MindMapPanel.java#L2677-L2761
train
raydac/netbeans-mmd-plugin
mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/utils/MindMapUtils.java
MindMapUtils.removeSuccessorsAndDuplications
@Nonnull @MustNotContainNull public static Topic[] removeSuccessorsAndDuplications(@Nonnull @MustNotContainNull final Topic... topics) { final List<Topic> result = new ArrayList<Topic>(); for (final Topic t : topics) { final Iterator<Topic> iterator = result.iterator(); while (iterator.hasNext(...
java
@Nonnull @MustNotContainNull public static Topic[] removeSuccessorsAndDuplications(@Nonnull @MustNotContainNull final Topic... topics) { final List<Topic> result = new ArrayList<Topic>(); for (final Topic t : topics) { final Iterator<Topic> iterator = result.iterator(); while (iterator.hasNext(...
[ "@", "Nonnull", "@", "MustNotContainNull", "public", "static", "Topic", "[", "]", "removeSuccessorsAndDuplications", "(", "@", "Nonnull", "@", "MustNotContainNull", "final", "Topic", "...", "topics", ")", "{", "final", "List", "<", "Topic", ">", "result", "=", ...
Remove duplications and successors for presented topics in array. @param topics array to be processed @return resulted array @since 1.3.1
[ "Remove", "duplications", "and", "successors", "for", "presented", "topics", "in", "array", "." ]
997493d23556a25354372b6419a64a0fbd0ac6ba
https://github.com/raydac/netbeans-mmd-plugin/blob/997493d23556a25354372b6419a64a0fbd0ac6ba/mind-map/mind-map-swing-panel/src/main/java/com/igormaznitsa/mindmap/swing/panel/utils/MindMapUtils.java#L315-L331
train
raydac/netbeans-mmd-plugin
mind-map/mind-map-ide-common/src/main/java/com/igormaznitsa/mindmap/ide/commons/Misc.java
Misc.string2pattern
@Nonnull public static Pattern string2pattern(@Nonnull final String text, final int patternFlags) { final StringBuilder result = new StringBuilder(); for (final char c : text.toCharArray()) { result.append("\\u"); //NOI18N final String code = Integer.toHexString(c).toUpperCase(Locale.ENGLISH); ...
java
@Nonnull public static Pattern string2pattern(@Nonnull final String text, final int patternFlags) { final StringBuilder result = new StringBuilder(); for (final char c : text.toCharArray()) { result.append("\\u"); //NOI18N final String code = Integer.toHexString(c).toUpperCase(Locale.ENGLISH); ...
[ "@", "Nonnull", "public", "static", "Pattern", "string2pattern", "(", "@", "Nonnull", "final", "String", "text", ",", "final", "int", "patternFlags", ")", "{", "final", "StringBuilder", "result", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "final...
Create pattern from string. @param text text to be converted into pattern. @param patternFlags flags to be used @return formed pattern
[ "Create", "pattern", "from", "string", "." ]
997493d23556a25354372b6419a64a0fbd0ac6ba
https://github.com/raydac/netbeans-mmd-plugin/blob/997493d23556a25354372b6419a64a0fbd0ac6ba/mind-map/mind-map-ide-common/src/main/java/com/igormaznitsa/mindmap/ide/commons/Misc.java#L54-L65
train
treasure-data/td-logger-java
modules/core/src/main/java/com/treasure_data/logger/TreasureDataLogger.java
TreasureDataLogger.lookupApiKey
private static String lookupApiKey(Properties props) { String apiKey = null; // lookup from system property td.logger.api.key. If it exists, writes/updates td.api.key. if (props.containsKey(Config.TD_LOGGER_API_KEY)) { apiKey = props.getProperty(Config.TD_LOGGER_API_KEY); ...
java
private static String lookupApiKey(Properties props) { String apiKey = null; // lookup from system property td.logger.api.key. If it exists, writes/updates td.api.key. if (props.containsKey(Config.TD_LOGGER_API_KEY)) { apiKey = props.getProperty(Config.TD_LOGGER_API_KEY); ...
[ "private", "static", "String", "lookupApiKey", "(", "Properties", "props", ")", "{", "String", "apiKey", "=", "null", ";", "// lookup from system property td.logger.api.key. If it exists, writes/updates td.api.key.", "if", "(", "props", ".", "containsKey", "(", "Config", ...
Define order for API key lookup. 1. lookup props's 'td.logger.api.key'
[ "Define", "order", "for", "API", "key", "lookup", ".", "1", ".", "lookup", "props", "s", "td", ".", "logger", ".", "api", ".", "key" ]
11a414b65cc2541fabe24facaef68eb62d4f19e4
https://github.com/treasure-data/td-logger-java/blob/11a414b65cc2541fabe24facaef68eb62d4f19e4/modules/core/src/main/java/com/treasure_data/logger/TreasureDataLogger.java#L47-L55
train
treasure-data/td-logger-java
modules/core/src/main/java/com/treasure_data/logger/TreasureDataLogger.java
TreasureDataLogger.lookupHost
private static String lookupHost(Properties props) { String host = null; // 1. lookup system property 'td.logger.api.server.host' if (props.containsKey(Config.TD_LOGGER_API_SERVER_HOST)) { host = props.getProperty(Config.TD_LOGGER_API_SERVER_HOST); } // if not exist...
java
private static String lookupHost(Properties props) { String host = null; // 1. lookup system property 'td.logger.api.server.host' if (props.containsKey(Config.TD_LOGGER_API_SERVER_HOST)) { host = props.getProperty(Config.TD_LOGGER_API_SERVER_HOST); } // if not exist...
[ "private", "static", "String", "lookupHost", "(", "Properties", "props", ")", "{", "String", "host", "=", "null", ";", "// 1. lookup system property 'td.logger.api.server.host'", "if", "(", "props", ".", "containsKey", "(", "Config", ".", "TD_LOGGER_API_SERVER_HOST", ...
Define order for hostname lookup. 1. lookup props's td.logger.api.server.host
[ "Define", "order", "for", "hostname", "lookup", ".", "1", ".", "lookup", "props", "s", "td", ".", "logger", ".", "api", ".", "server", ".", "host" ]
11a414b65cc2541fabe24facaef68eb62d4f19e4
https://github.com/treasure-data/td-logger-java/blob/11a414b65cc2541fabe24facaef68eb62d4f19e4/modules/core/src/main/java/com/treasure_data/logger/TreasureDataLogger.java#L61-L77
train
treasure-data/td-logger-java
modules/core/src/main/java/com/treasure_data/logger/TreasureDataLogger.java
TreasureDataLogger.lookupPort
private static String lookupPort(Properties props) { String port = null; // 1. lookup system property 'td.logger.api.server.port' if (props.containsKey(Config.TD_LOGGER_API_SERVER_PORT)) { port = props.getProperty(Config.TD_LOGGER_API_SERVER_PORT); } // if not exist...
java
private static String lookupPort(Properties props) { String port = null; // 1. lookup system property 'td.logger.api.server.port' if (props.containsKey(Config.TD_LOGGER_API_SERVER_PORT)) { port = props.getProperty(Config.TD_LOGGER_API_SERVER_PORT); } // if not exist...
[ "private", "static", "String", "lookupPort", "(", "Properties", "props", ")", "{", "String", "port", "=", "null", ";", "// 1. lookup system property 'td.logger.api.server.port'", "if", "(", "props", ".", "containsKey", "(", "Config", ".", "TD_LOGGER_API_SERVER_PORT", ...
Define order for port num lookup. 1. lookup props's td.logger.api.server.port
[ "Define", "order", "for", "port", "num", "lookup", ".", "1", ".", "lookup", "props", "s", "td", ".", "logger", ".", "api", ".", "server", ".", "port" ]
11a414b65cc2541fabe24facaef68eb62d4f19e4
https://github.com/treasure-data/td-logger-java/blob/11a414b65cc2541fabe24facaef68eb62d4f19e4/modules/core/src/main/java/com/treasure_data/logger/TreasureDataLogger.java#L98-L114
train
treasure-data/td-logger-java
modules/core/src/main/java/com/treasure_data/logger/TreasureDataLogger.java
TreasureDataLogger.lookupScheme
private static String lookupScheme(Properties props) { String scheme = null; // 1. lookup system property 'td.logger.api.server.scheme' if (props.containsKey(Config.TD_LOGGER_API_SERVER_SCHEME)) { scheme = props.getProperty(Config.TD_LOGGER_API_SERVER_SCHEME); } // ...
java
private static String lookupScheme(Properties props) { String scheme = null; // 1. lookup system property 'td.logger.api.server.scheme' if (props.containsKey(Config.TD_LOGGER_API_SERVER_SCHEME)) { scheme = props.getProperty(Config.TD_LOGGER_API_SERVER_SCHEME); } // ...
[ "private", "static", "String", "lookupScheme", "(", "Properties", "props", ")", "{", "String", "scheme", "=", "null", ";", "// 1. lookup system property 'td.logger.api.server.scheme'", "if", "(", "props", ".", "containsKey", "(", "Config", ".", "TD_LOGGER_API_SERVER_SCH...
Define order for scheme lookup. 1. lookup props's td.logger.api.server.scheme
[ "Define", "order", "for", "scheme", "lookup", ".", "1", ".", "lookup", "props", "s", "td", ".", "logger", ".", "api", ".", "server", ".", "scheme" ]
11a414b65cc2541fabe24facaef68eb62d4f19e4
https://github.com/treasure-data/td-logger-java/blob/11a414b65cc2541fabe24facaef68eb62d4f19e4/modules/core/src/main/java/com/treasure_data/logger/TreasureDataLogger.java#L134-L150
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java
OptionalHeader.newInstance
public static OptionalHeader newInstance(byte[] headerbytes, long offset) throws IOException { OptionalHeader header = new OptionalHeader(headerbytes, offset); header.read(); return header; }
java
public static OptionalHeader newInstance(byte[] headerbytes, long offset) throws IOException { OptionalHeader header = new OptionalHeader(headerbytes, offset); header.read(); return header; }
[ "public", "static", "OptionalHeader", "newInstance", "(", "byte", "[", "]", "headerbytes", ",", "long", "offset", ")", "throws", "IOException", "{", "OptionalHeader", "header", "=", "new", "OptionalHeader", "(", "headerbytes", ",", "offset", ")", ";", "header", ...
Creates and returns a new instance of the optional header. @param headerbytes the bytes that make up the optional header @param offset the file offset to the beginning of the optional header @return instance of the optional header @throws IOException if headerbytes can not be read
[ "Creates", "and", "returns", "a", "new", "instance", "of", "the", "optional", "header", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java#L177-L182
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java
OptionalHeader.maybeGetDataDirEntry
public Optional<DataDirEntry> maybeGetDataDirEntry(DataDirectoryKey key) { return Optional.fromNullable(dataDirectory.get(key)); }
java
public Optional<DataDirEntry> maybeGetDataDirEntry(DataDirectoryKey key) { return Optional.fromNullable(dataDirectory.get(key)); }
[ "public", "Optional", "<", "DataDirEntry", ">", "maybeGetDataDirEntry", "(", "DataDirectoryKey", "key", ")", "{", "return", "Optional", ".", "fromNullable", "(", "dataDirectory", ".", "get", "(", "key", ")", ")", ";", "}" ]
Returns the optional data directory entry for the given key or absent if entry doesn't exist. @param key @return the data directory entry for the given key or absent if entry doesn't exist.
[ "Returns", "the", "optional", "data", "directory", "entry", "for", "the", "given", "key", "or", "absent", "if", "entry", "doesn", "t", "exist", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java#L239-L241
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java
OptionalHeader.maybeGetStandardFieldEntry
public Optional<StandardField> maybeGetStandardFieldEntry( StandardFieldEntryKey key) { return Optional.fromNullable(standardFields.get(key)); }
java
public Optional<StandardField> maybeGetStandardFieldEntry( StandardFieldEntryKey key) { return Optional.fromNullable(standardFields.get(key)); }
[ "public", "Optional", "<", "StandardField", ">", "maybeGetStandardFieldEntry", "(", "StandardFieldEntryKey", "key", ")", "{", "return", "Optional", ".", "fromNullable", "(", "standardFields", ".", "get", "(", "key", ")", ")", ";", "}" ]
Returns maybe the standard field entry for the given key. If the file is a PE32+, it will not have a base of data field and return absent for the base of data key. @param key the key of the standard field @return the standard field entry for the given key
[ "Returns", "maybe", "the", "standard", "field", "entry", "for", "the", "given", "key", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java#L272-L275
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java
OptionalHeader.getStandardFieldEntry
public StandardField getStandardFieldEntry(StandardFieldEntryKey key) { if (!standardFields.containsKey(key)) { throw new IllegalArgumentException("standard field " + key + " does not exist!"); } return standardFields.get(key); }
java
public StandardField getStandardFieldEntry(StandardFieldEntryKey key) { if (!standardFields.containsKey(key)) { throw new IllegalArgumentException("standard field " + key + " does not exist!"); } return standardFields.get(key); }
[ "public", "StandardField", "getStandardFieldEntry", "(", "StandardFieldEntryKey", "key", ")", "{", "if", "(", "!", "standardFields", ".", "containsKey", "(", "key", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"standard field \"", "+", "key", ...
Returns the standard field entry for the given key. @param key the key of the standard field @return the standard field entry for the given key @throws IllegalArgumentException if key is base of data for a PE32+
[ "Returns", "the", "standard", "field", "entry", "for", "the", "given", "key", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java#L284-L290
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java
OptionalHeader.getDataDirInfo
public String getDataDirInfo() { StringBuilder b = new StringBuilder(); for (DataDirEntry entry : dataDirectory.values()) { b.append(entry.getKey() + ": " + entry.getVirtualAddress() + "(0x" + Long.toHexString(entry.getVirtualAddress()) + ")/" + entry.getDirectorySize() + "(0x" + Long.toHexString(...
java
public String getDataDirInfo() { StringBuilder b = new StringBuilder(); for (DataDirEntry entry : dataDirectory.values()) { b.append(entry.getKey() + ": " + entry.getVirtualAddress() + "(0x" + Long.toHexString(entry.getVirtualAddress()) + ")/" + entry.getDirectorySize() + "(0x" + Long.toHexString(...
[ "public", "String", "getDataDirInfo", "(", ")", "{", "StringBuilder", "b", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "DataDirEntry", "entry", ":", "dataDirectory", ".", "values", "(", ")", ")", "{", "b", ".", "append", "(", "entry", ".", ...
Returns a description of all data directories. @return description of all data directories.
[ "Returns", "a", "description", "of", "all", "data", "directories", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java#L393-L402
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java
OptionalHeader.getWindowsSpecificInfo
public String getWindowsSpecificInfo() { StringBuilder b = new StringBuilder(); for (StandardField entry : windowsFields.values()) { long value = entry.getValue(); HeaderKey key = entry.getKey(); String description = entry.getDescription(); if (key.equals(IMAGE_BASE)) { b.append(description + ": " +...
java
public String getWindowsSpecificInfo() { StringBuilder b = new StringBuilder(); for (StandardField entry : windowsFields.values()) { long value = entry.getValue(); HeaderKey key = entry.getKey(); String description = entry.getDescription(); if (key.equals(IMAGE_BASE)) { b.append(description + ": " +...
[ "public", "String", "getWindowsSpecificInfo", "(", ")", "{", "StringBuilder", "b", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "StandardField", "entry", ":", "windowsFields", ".", "values", "(", ")", ")", "{", "long", "value", "=", "entry", "."...
Returns a string with description of the windows specific header fields. Magic number must be set. @return string with windows specific fields
[ "Returns", "a", "string", "with", "description", "of", "the", "windows", "specific", "header", "fields", ".", "Magic", "number", "must", "be", "set", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java#L410-L438
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java
OptionalHeader.getRelocatedImageBase
public long getRelocatedImageBase() { long imageBase = get(WindowsEntryKey.IMAGE_BASE); long sizeOfImage = get(WindowsEntryKey.SIZE_OF_IMAGE); if (imageBase + sizeOfImage >= 0x80000000L || imageBase == 0L) { return 0x10000L; } return imageBase; }
java
public long getRelocatedImageBase() { long imageBase = get(WindowsEntryKey.IMAGE_BASE); long sizeOfImage = get(WindowsEntryKey.SIZE_OF_IMAGE); if (imageBase + sizeOfImage >= 0x80000000L || imageBase == 0L) { return 0x10000L; } return imageBase; }
[ "public", "long", "getRelocatedImageBase", "(", ")", "{", "long", "imageBase", "=", "get", "(", "WindowsEntryKey", ".", "IMAGE_BASE", ")", ";", "long", "sizeOfImage", "=", "get", "(", "WindowsEntryKey", ".", "SIZE_OF_IMAGE", ")", ";", "if", "(", "imageBase", ...
Checks if image base is too large or zero and relocates it accordingly. Otherwise the usual image base is returned. see: @see <a href="https://code.google.com/p/corkami/wiki/PE#ImageBase">corkami</a> @return relocated image base
[ "Checks", "if", "image", "base", "is", "too", "large", "or", "zero", "and", "relocates", "it", "accordingly", ".", "Otherwise", "the", "usual", "image", "base", "is", "returned", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java#L525-L532
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java
OptionalHeader.getDllCharacteristics
public List<DllCharacteristic> getDllCharacteristics() { long value = get(DLL_CHARACTERISTICS); List<DllCharacteristic> dllChs = DllCharacteristic.getAllFor(value); return dllChs; }
java
public List<DllCharacteristic> getDllCharacteristics() { long value = get(DLL_CHARACTERISTICS); List<DllCharacteristic> dllChs = DllCharacteristic.getAllFor(value); return dllChs; }
[ "public", "List", "<", "DllCharacteristic", ">", "getDllCharacteristics", "(", ")", "{", "long", "value", "=", "get", "(", "DLL_CHARACTERISTICS", ")", ";", "List", "<", "DllCharacteristic", ">", "dllChs", "=", "DllCharacteristic", ".", "getAllFor", "(", "value",...
Returns a list of the DllCharacteristics that are set in the file. @return list of DllCharacteristics
[ "Returns", "a", "list", "of", "the", "DllCharacteristics", "that", "are", "set", "in", "the", "file", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java#L539-L543
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java
OptionalHeader.getAdjustedFileAlignment
public long getAdjustedFileAlignment() { long fileAlign = get(FILE_ALIGNMENT); if (isLowAlignmentMode()) { return 1; } if (fileAlign < 512) { // TODO correct? fileAlign = 512; } // TODO what happens for too big alignment? // TODO this is just a test, verify if (fileAlign % 512 != 0) { long rest...
java
public long getAdjustedFileAlignment() { long fileAlign = get(FILE_ALIGNMENT); if (isLowAlignmentMode()) { return 1; } if (fileAlign < 512) { // TODO correct? fileAlign = 512; } // TODO what happens for too big alignment? // TODO this is just a test, verify if (fileAlign % 512 != 0) { long rest...
[ "public", "long", "getAdjustedFileAlignment", "(", ")", "{", "long", "fileAlign", "=", "get", "(", "FILE_ALIGNMENT", ")", ";", "if", "(", "isLowAlignmentMode", "(", ")", ")", "{", "return", "1", ";", "}", "if", "(", "fileAlign", "<", "512", ")", "{", "...
Adjusts the file alignment to low alignment mode if necessary. @return 1 if low alignment mode, file alignment value otherwise
[ "Adjusts", "the", "file", "alignment", "to", "low", "alignment", "mode", "if", "necessary", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java#L593-L608
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java
OptionalHeader.isLowAlignmentMode
public boolean isLowAlignmentMode() { long fileAlign = get(FILE_ALIGNMENT); long sectionAlign = get(SECTION_ALIGNMENT); return 1 <= fileAlign && fileAlign == sectionAlign && fileAlign <= 0x800; }
java
public boolean isLowAlignmentMode() { long fileAlign = get(FILE_ALIGNMENT); long sectionAlign = get(SECTION_ALIGNMENT); return 1 <= fileAlign && fileAlign == sectionAlign && fileAlign <= 0x800; }
[ "public", "boolean", "isLowAlignmentMode", "(", ")", "{", "long", "fileAlign", "=", "get", "(", "FILE_ALIGNMENT", ")", ";", "long", "sectionAlign", "=", "get", "(", "SECTION_ALIGNMENT", ")", ";", "return", "1", "<=", "fileAlign", "&&", "fileAlign", "==", "se...
Determines if the file is in low alignment mode. @see <a href="https://code.google.com/p/corkami/wiki/PE#SectionAlignment_/_FileAlignment">corkami Wiki PE</a> @return true iff file is in low alignment mode
[ "Determines", "if", "the", "file", "is", "in", "low", "alignment", "mode", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java#L618-L623
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java
OptionalHeader.isStandardAlignmentMode
public boolean isStandardAlignmentMode() { long fileAlign = get(FILE_ALIGNMENT); long sectionAlign = get(SECTION_ALIGNMENT); return 0x200 <= fileAlign && fileAlign <= sectionAlign && 0x1000 <= sectionAlign; }
java
public boolean isStandardAlignmentMode() { long fileAlign = get(FILE_ALIGNMENT); long sectionAlign = get(SECTION_ALIGNMENT); return 0x200 <= fileAlign && fileAlign <= sectionAlign && 0x1000 <= sectionAlign; }
[ "public", "boolean", "isStandardAlignmentMode", "(", ")", "{", "long", "fileAlign", "=", "get", "(", "FILE_ALIGNMENT", ")", ";", "long", "sectionAlign", "=", "get", "(", "SECTION_ALIGNMENT", ")", ";", "return", "0x200", "<=", "fileAlign", "&&", "fileAlign", "<...
Determines if the file is in standard alignment mode. @see <a href="https://code.google.com/p/corkami/wiki/PE#SectionAlignment_/_FileAlignment">corkami Wiki PE</a> @return true iff file is in standard alignment mode
[ "Determines", "if", "the", "file", "is", "in", "standard", "alignment", "mode", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/OptionalHeader.java#L633-L638
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/coffheader/COFFFileHeader.java
COFFFileHeader.read
private void read() { // define the specification format final int key = 0; final int description = 1; final int offset = 2; final int length = 3; SpecificationFormat format = new SpecificationFormat(key, description, offset, length); // read the h...
java
private void read() { // define the specification format final int key = 0; final int description = 1; final int offset = 2; final int length = 3; SpecificationFormat format = new SpecificationFormat(key, description, offset, length); // read the h...
[ "private", "void", "read", "(", ")", "{", "// define the specification format", "final", "int", "key", "=", "0", ";", "final", "int", "description", "=", "1", ";", "final", "int", "offset", "=", "2", ";", "final", "int", "length", "=", "3", ";", "Specifi...
Reads the header's fields.
[ "Reads", "the", "header", "s", "fields", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/coffheader/COFFFileHeader.java#L87-L102
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/coffheader/COFFFileHeader.java
COFFFileHeader.getMachineType
public MachineType getMachineType() { long value = get(MACHINE); try { return MachineType.getForValue(value); } catch (IllegalArgumentException e) { logger.error("Unable to resolve machine type for value: " + value); return MachineType.UNKNOWN; } }
java
public MachineType getMachineType() { long value = get(MACHINE); try { return MachineType.getForValue(value); } catch (IllegalArgumentException e) { logger.error("Unable to resolve machine type for value: " + value); return MachineType.UNKNOWN; } }
[ "public", "MachineType", "getMachineType", "(", ")", "{", "long", "value", "=", "get", "(", "MACHINE", ")", ";", "try", "{", "return", "MachineType", ".", "getForValue", "(", "value", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", ...
Returns the enum that denotes the machine type. @return MachineType
[ "Returns", "the", "enum", "that", "denotes", "the", "machine", "type", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/coffheader/COFFFileHeader.java#L220-L228
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/coffheader/COFFFileHeader.java
COFFFileHeader.newInstance
public static COFFFileHeader newInstance(byte[] headerbytes, long offset) { COFFFileHeader header = new COFFFileHeader(headerbytes, offset); header.read(); return header; }
java
public static COFFFileHeader newInstance(byte[] headerbytes, long offset) { COFFFileHeader header = new COFFFileHeader(headerbytes, offset); header.read(); return header; }
[ "public", "static", "COFFFileHeader", "newInstance", "(", "byte", "[", "]", "headerbytes", ",", "long", "offset", ")", "{", "COFFFileHeader", "header", "=", "new", "COFFFileHeader", "(", "headerbytes", ",", "offset", ")", ";", "header", ".", "read", "(", ")"...
Creates an instance of the COFF File Header based on headerbytes and offset. @param headerbytes the bytes that make up the COFF File Header @param offset the file offset to the beginning of the header @return COFFFileHeader instance
[ "Creates", "an", "instance", "of", "the", "COFF", "File", "Header", "based", "on", "headerbytes", "and", "offset", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/coffheader/COFFFileHeader.java#L280-L284
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/PESection.java
PESection.getBytes
public byte[] getBytes() throws IOException { if (sectionbytes.isPresent()) { return sectionbytes.get().clone(); } loadSectionBytes(); byte[] result = sectionbytes.get(); assert result != null; return result; }
java
public byte[] getBytes() throws IOException { if (sectionbytes.isPresent()) { return sectionbytes.get().clone(); } loadSectionBytes(); byte[] result = sectionbytes.get(); assert result != null; return result; }
[ "public", "byte", "[", "]", "getBytes", "(", ")", "throws", "IOException", "{", "if", "(", "sectionbytes", ".", "isPresent", "(", ")", ")", "{", "return", "sectionbytes", ".", "get", "(", ")", ".", "clone", "(", ")", ";", "}", "loadSectionBytes", "(", ...
Returns the section bytes. The file is read if the bytes aren't already loaded. @return bytes of the section @throws IOException if file can not be read @throws IllegalStateException if section is too large to fit into a byte array. This happens if the size is larger than int can hold.
[ "Returns", "the", "section", "bytes", ".", "The", "file", "is", "read", "if", "the", "bytes", "aren", "t", "already", "loaded", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/PESection.java#L126-L134
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/PESection.java
PESection.loadSectionBytes
private void loadSectionBytes() throws IOException { Preconditions.checkState(size == (int) size, "section is too large to dump into byte array"); try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { raf.seek(offset); byte[] bytes = new byte[(int) size];...
java
private void loadSectionBytes() throws IOException { Preconditions.checkState(size == (int) size, "section is too large to dump into byte array"); try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { raf.seek(offset); byte[] bytes = new byte[(int) size];...
[ "private", "void", "loadSectionBytes", "(", ")", "throws", "IOException", "{", "Preconditions", ".", "checkState", "(", "size", "==", "(", "int", ")", "size", ",", "\"section is too large to dump into byte array\"", ")", ";", "try", "(", "RandomAccessFile", "raf", ...
Loads the section bytes from the file using offset and size. @throws IOException if file can not be read @throws IllegalStateException if section is too large to fit into a byte array. This happens if the size is larger than int can hold.
[ "Loads", "the", "section", "bytes", "from", "the", "file", "using", "offset", "and", "size", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/PESection.java#L145-L154
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/VisualizerBuilder.java
VisualizerBuilder.setColor
public VisualizerBuilder setColor(ColorableItem key, Color color) { settings.colorMap.put(key, color); return this; }
java
public VisualizerBuilder setColor(ColorableItem key, Color color) { settings.colorMap.put(key, color); return this; }
[ "public", "VisualizerBuilder", "setColor", "(", "ColorableItem", "key", ",", "Color", "color", ")", "{", "settings", ".", "colorMap", ".", "put", "(", "key", ",", "color", ")", ";", "return", "this", ";", "}" ]
Sets the color for a colorable item. @param key the item to be colored @param color the color of the item @return this VisualizerBuilder
[ "Sets", "the", "color", "for", "a", "colorable", "item", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/VisualizerBuilder.java#L175-L178
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/IOUtil.java
IOUtil.dumpLocationToFile
public static void dumpLocationToFile(PhysicalLocation loc, File inFile, File outFile) throws IOException { Preconditions.checkArgument(!outFile.exists()); Preconditions.checkArgument(inFile.exists(), inFile.isFile()); final int BUFFER_SIZE = 2048; try (RandomAccessFile raf = new RandomAccessFile(inFile, "...
java
public static void dumpLocationToFile(PhysicalLocation loc, File inFile, File outFile) throws IOException { Preconditions.checkArgument(!outFile.exists()); Preconditions.checkArgument(inFile.exists(), inFile.isFile()); final int BUFFER_SIZE = 2048; try (RandomAccessFile raf = new RandomAccessFile(inFile, "...
[ "public", "static", "void", "dumpLocationToFile", "(", "PhysicalLocation", "loc", ",", "File", "inFile", ",", "File", "outFile", ")", "throws", "IOException", "{", "Preconditions", ".", "checkArgument", "(", "!", "outFile", ".", "exists", "(", ")", ")", ";", ...
Dumps the given part of the inFile to outFile. The part to dump is represented by loc. This will read safely from inFile which means locations outside of inFile are written as zero bytes to outFile. outFile must not exist yet. inFile must exist and must not be a directory. @param loc @param file @throws IOException
[ "Dumps", "the", "given", "part", "of", "the", "inFile", "to", "outFile", ".", "The", "part", "to", "dump", "is", "represented", "by", "loc", ".", "This", "will", "read", "safely", "from", "inFile", "which", "means", "locations", "outside", "of", "inFile", ...
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/IOUtil.java#L91-L115
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/IOUtil.java
IOUtil.loadBytesSafely
public static byte[] loadBytesSafely(long offset, int length, RandomAccessFile raf) throws IOException { Preconditions.checkArgument(length >= 0); if (offset < 0) return new byte[0]; raf.seek(offset); int readsize = length; if (readsize + offset > raf.length()) { readsize = (int) (raf.length() - offs...
java
public static byte[] loadBytesSafely(long offset, int length, RandomAccessFile raf) throws IOException { Preconditions.checkArgument(length >= 0); if (offset < 0) return new byte[0]; raf.seek(offset); int readsize = length; if (readsize + offset > raf.length()) { readsize = (int) (raf.length() - offs...
[ "public", "static", "byte", "[", "]", "loadBytesSafely", "(", "long", "offset", ",", "int", "length", ",", "RandomAccessFile", "raf", ")", "throws", "IOException", "{", "Preconditions", ".", "checkArgument", "(", "length", ">=", "0", ")", ";", "if", "(", "...
Loads the bytes at the offset into a byte array with the given length using the raf. If EOF, the byte array is zero padded. If offset < 0 it will return a zero sized array. @param offset to seek @param length of the byte array, equals number of bytes read @param raf the random access file @return byte array @throws IO...
[ "Loads", "the", "bytes", "at", "the", "offset", "into", "a", "byte", "array", "with", "the", "given", "length", "using", "the", "raf", ".", "If", "EOF", "the", "byte", "array", "is", "zero", "padded", ".", "If", "offset", "<", "0", "it", "will", "ret...
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/IOUtil.java#L132-L150
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/IOUtil.java
IOUtil.padBytes
private static byte[] padBytes(byte[] bytes, int length) { byte[] padded = new byte[length]; for (int i = 0; i < bytes.length; i++) { padded[i] = bytes[i]; } return padded; }
java
private static byte[] padBytes(byte[] bytes, int length) { byte[] padded = new byte[length]; for (int i = 0; i < bytes.length; i++) { padded[i] = bytes[i]; } return padded; }
[ "private", "static", "byte", "[", "]", "padBytes", "(", "byte", "[", "]", "bytes", ",", "int", "length", ")", "{", "byte", "[", "]", "padded", "=", "new", "byte", "[", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bytes"...
Return array with length size, if length is greater than the previous size, the array is zero-padded at the end. @param bytes @param length @return zero-padded array with length size
[ "Return", "array", "with", "length", "size", "if", "length", "is", "greater", "than", "the", "previous", "size", "the", "array", "is", "zero", "-", "padded", "at", "the", "end", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/IOUtil.java#L160-L166
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/IOUtil.java
IOUtil.loadBytes
public static byte[] loadBytes(long offset, int length, RandomAccessFile raf) throws IOException { if (length < 0) { length = 0; logger.error("Negative length: " + length); } if (offset < 0) { offset = 0; logger.error("Negative offset: " + offset); } // stay within file bounds offset = Math.m...
java
public static byte[] loadBytes(long offset, int length, RandomAccessFile raf) throws IOException { if (length < 0) { length = 0; logger.error("Negative length: " + length); } if (offset < 0) { offset = 0; logger.error("Negative offset: " + offset); } // stay within file bounds offset = Math.m...
[ "public", "static", "byte", "[", "]", "loadBytes", "(", "long", "offset", ",", "int", "length", ",", "RandomAccessFile", "raf", ")", "throws", "IOException", "{", "if", "(", "length", "<", "0", ")", "{", "length", "=", "0", ";", "logger", ".", "error",...
Loads the bytes at the offset into a byte array with the given length using the raf. @param offset to seek @param length of the byte array, equals number of bytes read @param raf the random access file @return byte array @throws IOException if unable to read the bytes
[ "Loads", "the", "bytes", "at", "the", "offset", "into", "a", "byte", "array", "with", "the", "given", "length", "using", "the", "raf", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/IOUtil.java#L182-L200
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/IOUtil.java
IOUtil.readSymbolDescriptions
public static List<SymbolDescription> readSymbolDescriptions() throws IOException { String filename = "importcategories.txt"; List<SymbolDescription> list = new ArrayList<>(); List<String[]> lines = readArray(filename); String category = ""; String subCategory = null; for (String[] array : lines) { if...
java
public static List<SymbolDescription> readSymbolDescriptions() throws IOException { String filename = "importcategories.txt"; List<SymbolDescription> list = new ArrayList<>(); List<String[]> lines = readArray(filename); String category = ""; String subCategory = null; for (String[] array : lines) { if...
[ "public", "static", "List", "<", "SymbolDescription", ">", "readSymbolDescriptions", "(", ")", "throws", "IOException", "{", "String", "filename", "=", "\"importcategories.txt\"", ";", "List", "<", "SymbolDescription", ">", "list", "=", "new", "ArrayList", "<>", "...
Reads a list of symbol descriptions @param filename @return list of SymbolDescriptions @throws IOException
[ "Reads", "a", "list", "of", "symbol", "descriptions" ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/IOUtil.java#L414-L441
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/msdos/MSDOSHeader.java
MSDOSHeader.newInstance
public static MSDOSHeader newInstance(byte[] headerbytes, long peSigOffset) throws IOException { MSDOSHeader header = new MSDOSHeader(headerbytes, peSigOffset); header.read(); return header; }
java
public static MSDOSHeader newInstance(byte[] headerbytes, long peSigOffset) throws IOException { MSDOSHeader header = new MSDOSHeader(headerbytes, peSigOffset); header.read(); return header; }
[ "public", "static", "MSDOSHeader", "newInstance", "(", "byte", "[", "]", "headerbytes", ",", "long", "peSigOffset", ")", "throws", "IOException", "{", "MSDOSHeader", "header", "=", "new", "MSDOSHeader", "(", "headerbytes", ",", "peSigOffset", ")", ";", "header",...
Creates and returns an instance of the MSDOSHeader with the given bytes and the file offset of the PE signature. @param headerbytes the bytes that make up the MSDOSHeader @param peSigOffset file offset to the PE signature @return MSDOSHeader instance @throws IOException if header can not be read.
[ "Creates", "and", "returns", "an", "instance", "of", "the", "MSDOSHeader", "with", "the", "given", "bytes", "and", "the", "file", "offset", "of", "the", "PE", "signature", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/msdos/MSDOSHeader.java#L205-L210
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/PESignature.java
PESignature.read
public void read() throws IOException { try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { // check that offset location is within the file throwIf(file.length() < PE_OFFSET_LOCATION); /* read pe signature offset at offset location */ byte[] offsetBytes = loadBytesSafely(PE_OFFSET_LOCATION, ...
java
public void read() throws IOException { try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { // check that offset location is within the file throwIf(file.length() < PE_OFFSET_LOCATION); /* read pe signature offset at offset location */ byte[] offsetBytes = loadBytesSafely(PE_OFFSET_LOCATION, ...
[ "public", "void", "read", "(", ")", "throws", "IOException", "{", "try", "(", "RandomAccessFile", "raf", "=", "new", "RandomAccessFile", "(", "file", ",", "\"r\"", ")", ")", "{", "// check that offset location is within the file", "throwIf", "(", "file", ".", "l...
Reads the PE signature and sets the peOffset. @throws FileFormatException if file is not a PE file @throws IOException if something went wrong while trying to read the file
[ "Reads", "the", "PE", "signature", "and", "sets", "the", "peOffset", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/PESignature.java#L84-L104
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/PESignature.java
PESignature.exists
public boolean exists() { try { read(); return true; } catch (FileFormatException e) { return false; } catch (IOException e) { logger.error(e); return false; } }
java
public boolean exists() { try { read(); return true; } catch (FileFormatException e) { return false; } catch (IOException e) { logger.error(e); return false; } }
[ "public", "boolean", "exists", "(", ")", "{", "try", "{", "read", "(", ")", ";", "return", "true", ";", "}", "catch", "(", "FileFormatException", "e", ")", "{", "return", "false", ";", "}", "catch", "(", "IOException", "e", ")", "{", "logger", ".", ...
Tries to read the PE signature of the current file and returns true, iff it was successfull. @return true if the file has the PE signature, false otherwise.
[ "Tries", "to", "read", "the", "PE", "signature", "of", "the", "current", "file", "and", "returns", "true", "iff", "it", "was", "successfull", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/PESignature.java#L193-L203
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/PESignature.java
PESignature.getInfo
public String getInfo() { if (!peOffset.isPresent()) { return "No PE signature found"; } return "-------------" + NL + "PE Signature" + NL + "-------------" + NL + "pe offset: " + peOffset.get() + NL; }
java
public String getInfo() { if (!peOffset.isPresent()) { return "No PE signature found"; } return "-------------" + NL + "PE Signature" + NL + "-------------" + NL + "pe offset: " + peOffset.get() + NL; }
[ "public", "String", "getInfo", "(", ")", "{", "if", "(", "!", "peOffset", ".", "isPresent", "(", ")", ")", "{", "return", "\"No PE signature found\"", ";", "}", "return", "\"-------------\"", "+", "NL", "+", "\"PE Signature\"", "+", "NL", "+", "\"-----------...
Returns a description string. @return description string of the pe signature
[ "Returns", "a", "description", "string", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/PESignature.java#L235-L241
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/Overlay.java
Overlay.getOffset
public long getOffset() throws IOException { if (offset == null) { read(); SectionTable table = data.getSectionTable(); SectionLoader loader = new SectionLoader(data); offset = 0L; List<SectionHeader> headers = table.getSectionHeaders(); //...
java
public long getOffset() throws IOException { if (offset == null) { read(); SectionTable table = data.getSectionTable(); SectionLoader loader = new SectionLoader(data); offset = 0L; List<SectionHeader> headers = table.getSectionHeaders(); //...
[ "public", "long", "getOffset", "(", ")", "throws", "IOException", "{", "if", "(", "offset", "==", "null", ")", "{", "read", "(", ")", ";", "SectionTable", "table", "=", "data", ".", "getSectionTable", "(", ")", ";", "SectionLoader", "loader", "=", "new",...
Returns the file offset of the overlay. @return file offset of the overlay @throws IOException
[ "Returns", "the", "file", "offset", "of", "the", "overlay", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/Overlay.java#L76-L105
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/Overlay.java
Overlay.dumpTo
public boolean dumpTo(File outFile) throws IOException { if (exists()) { dump(getOffset(), outFile); return true; } else { return false; } }
java
public boolean dumpTo(File outFile) throws IOException { if (exists()) { dump(getOffset(), outFile); return true; } else { return false; } }
[ "public", "boolean", "dumpTo", "(", "File", "outFile", ")", "throws", "IOException", "{", "if", "(", "exists", "(", ")", ")", "{", "dump", "(", "getOffset", "(", ")", ",", "outFile", ")", ";", "return", "true", ";", "}", "else", "{", "return", "false...
Writes a dump of the overlay to the specified output location. @param outFile the file to write the dump to @return true iff successfully dumped @throws IOException if unable to read the input file or write the output file
[ "Writes", "a", "dump", "of", "the", "overlay", "to", "the", "specified", "output", "location", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/Overlay.java#L137-L144
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/Overlay.java
Overlay.dump
private void dump(long offset, File outFile) throws IOException { try (RandomAccessFile raf = new RandomAccessFile(file, "r"); FileOutputStream out = new FileOutputStream(outFile)) { raf.seek(offset); byte[] buffer = new byte[2048]; int bytesRead; ...
java
private void dump(long offset, File outFile) throws IOException { try (RandomAccessFile raf = new RandomAccessFile(file, "r"); FileOutputStream out = new FileOutputStream(outFile)) { raf.seek(offset); byte[] buffer = new byte[2048]; int bytesRead; ...
[ "private", "void", "dump", "(", "long", "offset", ",", "File", "outFile", ")", "throws", "IOException", "{", "try", "(", "RandomAccessFile", "raf", "=", "new", "RandomAccessFile", "(", "file", ",", "\"r\"", ")", ";", "FileOutputStream", "out", "=", "new", ...
Dumps the last part of the file beginning at the specified offset. @param offset @throws IOException
[ "Dumps", "the", "last", "part", "of", "the", "file", "beginning", "at", "the", "specified", "offset", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/Overlay.java#L152-L162
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/Overlay.java
Overlay.getDump
public byte[] getDump() throws IOException { byte[] dump = new byte[(int) getSize()]; try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { raf.seek(offset); raf.readFully(dump); } return dump; }
java
public byte[] getDump() throws IOException { byte[] dump = new byte[(int) getSize()]; try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { raf.seek(offset); raf.readFully(dump); } return dump; }
[ "public", "byte", "[", "]", "getDump", "(", ")", "throws", "IOException", "{", "byte", "[", "]", "dump", "=", "new", "byte", "[", "(", "int", ")", "getSize", "(", ")", "]", ";", "try", "(", "RandomAccessFile", "raf", "=", "new", "RandomAccessFile", "...
Loads all bytes of the overlay into an array and returns them. @return array containing the overlay bytes @throws IOException
[ "Loads", "all", "bytes", "of", "the", "overlay", "into", "an", "array", "and", "returns", "them", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/Overlay.java#L170-L177
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/FlagUtil.java
FlagUtil.getAllMatching
public static <T extends Characteristic> List<T> getAllMatching(long value, T[] flags) { List<T> list = new ArrayList<>(); // check every characteristic if it fits for (T ch : flags) { // read mask long mask = ch.getValue(); // use mask to check if...
java
public static <T extends Characteristic> List<T> getAllMatching(long value, T[] flags) { List<T> list = new ArrayList<>(); // check every characteristic if it fits for (T ch : flags) { // read mask long mask = ch.getValue(); // use mask to check if...
[ "public", "static", "<", "T", "extends", "Characteristic", ">", "List", "<", "T", ">", "getAllMatching", "(", "long", "value", ",", "T", "[", "]", "flags", ")", "{", "List", "<", "T", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "// c...
Returns a list of all flags, which are set in the value @param value @return list of all flags that are set
[ "Returns", "a", "list", "of", "all", "flags", "which", "are", "set", "in", "the", "value" ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/FlagUtil.java#L35-L48
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java
SectionLoader.fileAligned
private long fileAligned(long value) { long fileAlign = optHeader.getAdjustedFileAlignment(); long rest = value % fileAlign; long result = value; if (rest != 0) { result = value - rest + fileAlign; } if (!(optHeader.isLowAlignmentMode() || result % 512 == 0)) ...
java
private long fileAligned(long value) { long fileAlign = optHeader.getAdjustedFileAlignment(); long rest = value % fileAlign; long result = value; if (rest != 0) { result = value - rest + fileAlign; } if (!(optHeader.isLowAlignmentMode() || result % 512 == 0)) ...
[ "private", "long", "fileAligned", "(", "long", "value", ")", "{", "long", "fileAlign", "=", "optHeader", ".", "getAdjustedFileAlignment", "(", ")", ";", "long", "rest", "=", "value", "%", "fileAlign", ";", "long", "result", "=", "value", ";", "if", "(", ...
Rounds up the value to the file alignment of the optional header. @param value @return file aligned value
[ "Rounds", "up", "the", "value", "to", "the", "file", "alignment", "of", "the", "optional", "header", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java#L170-L189
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java
SectionLoader.fileSizeAdjusted
private long fileSizeAdjusted(long alignedPointerToRaw, long readSize) { // end of section outside the file --> cut at file.length() if (readSize + alignedPointerToRaw > file.length()) { readSize = file.length() - alignedPointerToRaw; } // start of section outside the file --...
java
private long fileSizeAdjusted(long alignedPointerToRaw, long readSize) { // end of section outside the file --> cut at file.length() if (readSize + alignedPointerToRaw > file.length()) { readSize = file.length() - alignedPointerToRaw; } // start of section outside the file --...
[ "private", "long", "fileSizeAdjusted", "(", "long", "alignedPointerToRaw", ",", "long", "readSize", ")", "{", "// end of section outside the file --> cut at file.length()", "if", "(", "readSize", "+", "alignedPointerToRaw", ">", "file", ".", "length", "(", ")", ")", "...
Adjusts the readsize of a section to the size of the file. @param alignedPointerToRaw the file offset of the start of the section @param readSize the determined readsize without file adjustments @return adjusted readsize
[ "Adjusts", "the", "readsize", "of", "a", "section", "to", "the", "size", "of", "the", "file", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java#L249-L260
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java
SectionLoader.maybeGetFileOffset
public Optional<Long> maybeGetFileOffset(long rva) { Optional<SectionHeader> section = maybeGetSectionHeaderByRVA(rva); // standard value if rva doesn't point into a section long fileOffset = rva; // rva is located within a section, so calculate offset if (section.isPresent()) { ...
java
public Optional<Long> maybeGetFileOffset(long rva) { Optional<SectionHeader> section = maybeGetSectionHeaderByRVA(rva); // standard value if rva doesn't point into a section long fileOffset = rva; // rva is located within a section, so calculate offset if (section.isPresent()) { ...
[ "public", "Optional", "<", "Long", ">", "maybeGetFileOffset", "(", "long", "rva", ")", "{", "Optional", "<", "SectionHeader", ">", "section", "=", "maybeGetSectionHeaderByRVA", "(", "rva", ")", ";", "// standard value if rva doesn't point into a section", "long", "fil...
Returns the file offset for the given RVA. Returns absent if file offset is not within file. @param rva the relative virtual address that shall be converted to a plain file offset @return file offset
[ "Returns", "the", "file", "offset", "for", "the", "given", "RVA", ".", "Returns", "absent", "if", "file", "offset", "is", "not", "within", "file", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java#L342-L361
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java
SectionLoader.maybeGetSectionHeaderByRVA
public Optional<SectionHeader> maybeGetSectionHeaderByRVA(long rva) { List<SectionHeader> headers = table.getSectionHeaders(); for (SectionHeader header : headers) { VirtualLocation vLoc = getVirtualSectionLocation(header); if (addressIsWithin(vLoc, rva)) { return...
java
public Optional<SectionHeader> maybeGetSectionHeaderByRVA(long rva) { List<SectionHeader> headers = table.getSectionHeaders(); for (SectionHeader header : headers) { VirtualLocation vLoc = getVirtualSectionLocation(header); if (addressIsWithin(vLoc, rva)) { return...
[ "public", "Optional", "<", "SectionHeader", ">", "maybeGetSectionHeaderByRVA", "(", "long", "rva", ")", "{", "List", "<", "SectionHeader", ">", "headers", "=", "table", ".", "getSectionHeaders", "(", ")", ";", "for", "(", "SectionHeader", "header", ":", "heade...
Returns the section entry of the section table the rva is pointing into. @param rva the relative virtual address @return the {@link SectionHeader} of the section the rva is pointing into
[ "Returns", "the", "section", "entry", "of", "the", "section", "table", "the", "rva", "is", "pointing", "into", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java#L370-L379
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java
SectionLoader.maybeGetSectionHeaderByOffset
public Optional<SectionHeader> maybeGetSectionHeaderByOffset(long fileOffset) { List<SectionHeader> headers = table.getSectionHeaders(); for (SectionHeader header : headers) { PhysicalLocation loc = getPhysicalSectionLocation(header); if (addressIsWithin(loc, fileOffset)) { ...
java
public Optional<SectionHeader> maybeGetSectionHeaderByOffset(long fileOffset) { List<SectionHeader> headers = table.getSectionHeaders(); for (SectionHeader header : headers) { PhysicalLocation loc = getPhysicalSectionLocation(header); if (addressIsWithin(loc, fileOffset)) { ...
[ "public", "Optional", "<", "SectionHeader", ">", "maybeGetSectionHeaderByOffset", "(", "long", "fileOffset", ")", "{", "List", "<", "SectionHeader", ">", "headers", "=", "table", ".", "getSectionHeaders", "(", ")", ";", "for", "(", "SectionHeader", "header", ":"...
Returns the section entry of the section table the offset is pointing into. @param fileOffset the file offset @return the {@link SectionHeader} of the section the offset is pointing into
[ "Returns", "the", "section", "entry", "of", "the", "section", "table", "the", "offset", "is", "pointing", "into", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java#L390-L399
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java
SectionLoader.addressIsWithin
private static boolean addressIsWithin(Location location, long address) { long endpoint = location.from() + location.size(); return address >= location.from() && address < endpoint; }
java
private static boolean addressIsWithin(Location location, long address) { long endpoint = location.from() + location.size(); return address >= location.from() && address < endpoint; }
[ "private", "static", "boolean", "addressIsWithin", "(", "Location", "location", ",", "long", "address", ")", "{", "long", "endpoint", "=", "location", ".", "from", "(", ")", "+", "location", ".", "size", "(", ")", ";", "return", "address", ">=", "location"...
Returns true if the address is within the given location @param location @param address a address that may point into the section @return true iff address is within location
[ "Returns", "true", "if", "the", "address", "is", "within", "the", "given", "location" ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java#L421-L424
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java
SectionLoader.getMemoryMappedPE
private MemoryMappedPE getMemoryMappedPE() { if (!memoryMapped.isPresent()) { memoryMapped = Optional.of(MemoryMappedPE.newInstance(data, this)); } return memoryMapped.get(); }
java
private MemoryMappedPE getMemoryMappedPE() { if (!memoryMapped.isPresent()) { memoryMapped = Optional.of(MemoryMappedPE.newInstance(data, this)); } return memoryMapped.get(); }
[ "private", "MemoryMappedPE", "getMemoryMappedPE", "(", ")", "{", "if", "(", "!", "memoryMapped", ".", "isPresent", "(", ")", ")", "{", "memoryMapped", "=", "Optional", ".", "of", "(", "MemoryMappedPE", ".", "newInstance", "(", "data", ",", "this", ")", ")"...
Creates new instance of MemoryMappedPE or just returns it, if it is already there. @return memory mapped PE
[ "Creates", "new", "instance", "of", "MemoryMappedPE", "or", "just", "returns", "it", "if", "it", "is", "already", "there", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java#L760-L765
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java
SectionLoader.maybeGetLoadInfo
private Optional<LoadInfo> maybeGetLoadInfo(DataDirectoryKey dataDirKey) { Optional<DataDirEntry> dirEntry = optHeader .maybeGetDataDirEntry(dataDirKey); if (dirEntry.isPresent()) { long virtualAddress = dirEntry.get().getVirtualAddress(); Optional<Long> maybeOffs...
java
private Optional<LoadInfo> maybeGetLoadInfo(DataDirectoryKey dataDirKey) { Optional<DataDirEntry> dirEntry = optHeader .maybeGetDataDirEntry(dataDirKey); if (dirEntry.isPresent()) { long virtualAddress = dirEntry.get().getVirtualAddress(); Optional<Long> maybeOffs...
[ "private", "Optional", "<", "LoadInfo", ">", "maybeGetLoadInfo", "(", "DataDirectoryKey", "dataDirKey", ")", "{", "Optional", "<", "DataDirEntry", ">", "dirEntry", "=", "optHeader", ".", "maybeGetDataDirEntry", "(", "dataDirKey", ")", ";", "if", "(", "dirEntry", ...
Assembles the loadInfo object for the dataDirKey. @param dataDirKey data directory key @return loading information
[ "Assembles", "the", "loadInfo", "object", "for", "the", "dataDirKey", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java#L774-L789
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java
SectionLoader.containsEntryPoint
@Beta public boolean containsEntryPoint(SectionHeader header) { long ep = data.getOptionalHeader().get( StandardFieldEntryKey.ADDR_OF_ENTRY_POINT); long vStart = header.getAlignedVirtualAddress(); long vSize = header.getAlignedVirtualSize(); if (vSize == 0) { ...
java
@Beta public boolean containsEntryPoint(SectionHeader header) { long ep = data.getOptionalHeader().get( StandardFieldEntryKey.ADDR_OF_ENTRY_POINT); long vStart = header.getAlignedVirtualAddress(); long vSize = header.getAlignedVirtualSize(); if (vSize == 0) { ...
[ "@", "Beta", "public", "boolean", "containsEntryPoint", "(", "SectionHeader", "header", ")", "{", "long", "ep", "=", "data", ".", "getOptionalHeader", "(", ")", ".", "get", "(", "StandardFieldEntryKey", ".", "ADDR_OF_ENTRY_POINT", ")", ";", "long", "vStart", "...
Returns whether the section contains the entry point of the file. @param header the header of the section that may contain the entry point. @return true if entry point is within the section, false otherwise
[ "Returns", "whether", "the", "section", "contains", "the", "entry", "point", "of", "the", "file", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionLoader.java#L881-L892
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/Hasher.java
Hasher.fileHash
public static byte[] fileHash(File file, MessageDigest messageDigest) throws IOException { return computeHash(file, messageDigest, 0L, file.length()); }
java
public static byte[] fileHash(File file, MessageDigest messageDigest) throws IOException { return computeHash(file, messageDigest, 0L, file.length()); }
[ "public", "static", "byte", "[", "]", "fileHash", "(", "File", "file", ",", "MessageDigest", "messageDigest", ")", "throws", "IOException", "{", "return", "computeHash", "(", "file", ",", "messageDigest", ",", "0L", ",", "file", ".", "length", "(", ")", ")...
Returns the hash value of the file for the specified messageDigest. @param file to compute the hash value for @param messageDigest the message digest algorithm @return hash value of the file @throws IOException
[ "Returns", "the", "hash", "value", "of", "the", "file", "for", "the", "specified", "messageDigest", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/Hasher.java#L126-L129
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.createEntropyImage
public BufferedImage createEntropyImage(File file) throws IOException { resetAvailabilityFlags(); this.data = new PEData(null, null, null, null, null, file); image = new BufferedImage(fileWidth, height, IMAGE_TYPE); final int MIN_WINDOW_SIZE = 100; // bytes to be read at once to calculate local entropy fina...
java
public BufferedImage createEntropyImage(File file) throws IOException { resetAvailabilityFlags(); this.data = new PEData(null, null, null, null, null, file); image = new BufferedImage(fileWidth, height, IMAGE_TYPE); final int MIN_WINDOW_SIZE = 100; // bytes to be read at once to calculate local entropy fina...
[ "public", "BufferedImage", "createEntropyImage", "(", "File", "file", ")", "throws", "IOException", "{", "resetAvailabilityFlags", "(", ")", ";", "this", ".", "data", "=", "new", "PEData", "(", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",...
Creates an image of the local entropies of this file. @param file the PE file @return image of local entropies @throws IOException if file can not be read
[ "Creates", "an", "image", "of", "the", "local", "entropies", "of", "this", "file", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L245-L274
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.getColorForEntropy
private Color getColorForEntropy(double entropy) { assert entropy <= 1; assert entropy >= 0; Color entropyColor = colorMap.get(ENTROPY); float[] hsbvals = new float[3]; Color.RGBtoHSB(entropyColor.getRed(), entropyColor.getGreen(), entropyColor.getBlue(), hsbvals); float entropyHue = hsbvals[0]; float...
java
private Color getColorForEntropy(double entropy) { assert entropy <= 1; assert entropy >= 0; Color entropyColor = colorMap.get(ENTROPY); float[] hsbvals = new float[3]; Color.RGBtoHSB(entropyColor.getRed(), entropyColor.getGreen(), entropyColor.getBlue(), hsbvals); float entropyHue = hsbvals[0]; float...
[ "private", "Color", "getColorForEntropy", "(", "double", "entropy", ")", "{", "assert", "entropy", "<=", "1", ";", "assert", "entropy", ">=", "0", ";", "Color", "entropyColor", "=", "colorMap", ".", "get", "(", "ENTROPY", ")", ";", "float", "[", "]", "hs...
Creates a color instance based on a given entropy. @param entropy value between 0 and 1 @return Color for given entropy
[ "Creates", "a", "color", "instance", "based", "on", "a", "given", "entropy", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L283-L296
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.writeImage
public void writeImage(File input, File output, String formatName) throws IOException { BufferedImage image = createImage(input); ImageIO.write(image, formatName, output); }
java
public void writeImage(File input, File output, String formatName) throws IOException { BufferedImage image = createImage(input); ImageIO.write(image, formatName, output); }
[ "public", "void", "writeImage", "(", "File", "input", ",", "File", "output", ",", "String", "formatName", ")", "throws", "IOException", "{", "BufferedImage", "image", "=", "createImage", "(", "input", ")", ";", "ImageIO", ".", "write", "(", "image", ",", "...
Writes an image to the output file that displays the structure of the PE file. @param input the PE file to create an image from @param output the file to write the image to @param formatName the format name for the output image @throws IOException if sections can not be read
[ "Writes", "an", "image", "to", "the", "output", "file", "that", "displays", "the", "structure", "of", "the", "PE", "file", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L339-L343
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.createDiffImage
public BufferedImage createDiffImage(BufferedImage firstImage, BufferedImage secondImage) throws IOException { BufferedImage diffImage = new BufferedImage(firstImage.getWidth(), firstImage.getHeight(), IMAGE_TYPE); for (int x = 0; x < firstImage.getWidth() && x < secondImage.getWidth(); x++) { for (int y...
java
public BufferedImage createDiffImage(BufferedImage firstImage, BufferedImage secondImage) throws IOException { BufferedImage diffImage = new BufferedImage(firstImage.getWidth(), firstImage.getHeight(), IMAGE_TYPE); for (int x = 0; x < firstImage.getWidth() && x < secondImage.getWidth(); x++) { for (int y...
[ "public", "BufferedImage", "createDiffImage", "(", "BufferedImage", "firstImage", ",", "BufferedImage", "secondImage", ")", "throws", "IOException", "{", "BufferedImage", "diffImage", "=", "new", "BufferedImage", "(", "firstImage", ".", "getWidth", "(", ")", ",", "f...
Creates a buffered image containing the diff of both files. @param firstFile @param secondFile @return @throws IOException
[ "Creates", "a", "buffered", "image", "containing", "the", "diff", "of", "both", "files", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L353-L368
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.createImage
public BufferedImage createImage(File file) throws IOException { resetAvailabilityFlags(); this.data = PELoader.loadPE(file); image = new BufferedImage(fileWidth, height, IMAGE_TYPE); drawSections(); Overlay overlay = new Overlay(data); if (overlay.exists()) { long overlayOffset = overlay.getOffset(); ...
java
public BufferedImage createImage(File file) throws IOException { resetAvailabilityFlags(); this.data = PELoader.loadPE(file); image = new BufferedImage(fileWidth, height, IMAGE_TYPE); drawSections(); Overlay overlay = new Overlay(data); if (overlay.exists()) { long overlayOffset = overlay.getOffset(); ...
[ "public", "BufferedImage", "createImage", "(", "File", "file", ")", "throws", "IOException", "{", "resetAvailabilityFlags", "(", ")", ";", "this", ".", "data", "=", "PELoader", ".", "loadPE", "(", "file", ")", ";", "image", "=", "new", "BufferedImage", "(", ...
Creates a buffered image that displays the structure of the PE file. @param file the PE file to create an image from @return buffered image @throws IOException if sections can not be read
[ "Creates", "a", "buffered", "image", "that", "displays", "the", "structure", "of", "the", "PE", "file", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L379-L401
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.createLegendImage
public BufferedImage createLegendImage(boolean withBytePlot, boolean withEntropy, boolean withPEStructure) { image = new BufferedImage(legendWidth, height, IMAGE_TYPE); drawLegend(withBytePlot, withEntropy, withPEStructure); assert image != null; assert image.getWidth() == legendWidth; assert image.getHeig...
java
public BufferedImage createLegendImage(boolean withBytePlot, boolean withEntropy, boolean withPEStructure) { image = new BufferedImage(legendWidth, height, IMAGE_TYPE); drawLegend(withBytePlot, withEntropy, withPEStructure); assert image != null; assert image.getWidth() == legendWidth; assert image.getHeig...
[ "public", "BufferedImage", "createLegendImage", "(", "boolean", "withBytePlot", ",", "boolean", "withEntropy", ",", "boolean", "withPEStructure", ")", "{", "image", "=", "new", "BufferedImage", "(", "legendWidth", ",", "height", ",", "IMAGE_TYPE", ")", ";", "drawL...
Creates a buffered image with a basic Legend @param withBytePlot show byteplot legend @param withEntropy show entropy legend @param withPEStructure show PE structure legend @return buffered image of the generated legend
[ "Creates", "a", "buffered", "image", "with", "a", "basic", "Legend" ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L414-L422
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.drawPEHeaders
private void drawPEHeaders() { long msdosOffset = 0; long msdosSize = withMinLength(data.getMSDOSHeader().getHeaderSize()); drawPixels(colorMap.get(MSDOS_HEADER), msdosOffset, msdosSize); long optOffset = data.getOptionalHeader().getOffset(); long optSize = withMinLength(data.getOptionalHeader().getSize()); ...
java
private void drawPEHeaders() { long msdosOffset = 0; long msdosSize = withMinLength(data.getMSDOSHeader().getHeaderSize()); drawPixels(colorMap.get(MSDOS_HEADER), msdosOffset, msdosSize); long optOffset = data.getOptionalHeader().getOffset(); long optSize = withMinLength(data.getOptionalHeader().getSize()); ...
[ "private", "void", "drawPEHeaders", "(", ")", "{", "long", "msdosOffset", "=", "0", ";", "long", "msdosSize", "=", "withMinLength", "(", "data", ".", "getMSDOSHeader", "(", ")", ".", "getHeaderSize", "(", ")", ")", ";", "drawPixels", "(", "colorMap", ".", ...
Draws the PE Header to the structure image
[ "Draws", "the", "PE", "Header", "to", "the", "structure", "image" ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L458-L477
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.getEntryPoint
private Optional<Long> getEntryPoint() { long rva = data.getOptionalHeader().get( StandardFieldEntryKey.ADDR_OF_ENTRY_POINT); Optional<SectionHeader> section = new SectionLoader(data) .maybeGetSectionHeaderByRVA(rva); if (section.isPresent()) { long phystovirt = section.get().get( SectionHeaderKey...
java
private Optional<Long> getEntryPoint() { long rva = data.getOptionalHeader().get( StandardFieldEntryKey.ADDR_OF_ENTRY_POINT); Optional<SectionHeader> section = new SectionLoader(data) .maybeGetSectionHeaderByRVA(rva); if (section.isPresent()) { long phystovirt = section.get().get( SectionHeaderKey...
[ "private", "Optional", "<", "Long", ">", "getEntryPoint", "(", ")", "{", "long", "rva", "=", "data", ".", "getOptionalHeader", "(", ")", ".", "get", "(", "StandardFieldEntryKey", ".", "ADDR_OF_ENTRY_POINT", ")", ";", "Optional", "<", "SectionHeader", ">", "s...
Returns the entry point of the PE if present and valid, otherwise absent. A valid entry point is one within a section. @return entry point optional if present, absent otherwise
[ "Returns", "the", "entry", "point", "of", "the", "PE", "if", "present", "and", "valid", "otherwise", "absent", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L572-L584
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.drawSections
private void drawSections() { SectionTable table = data.getSectionTable(); long sectionTableOffset = table.getOffset(); long sectionTableSize = table.getSize(); drawPixels(colorMap.get(SECTION_TABLE), sectionTableOffset, sectionTableSize); logger.info("x pixels: " + getXPixels()); logger.info("y pixels:...
java
private void drawSections() { SectionTable table = data.getSectionTable(); long sectionTableOffset = table.getOffset(); long sectionTableSize = table.getSize(); drawPixels(colorMap.get(SECTION_TABLE), sectionTableOffset, sectionTableSize); logger.info("x pixels: " + getXPixels()); logger.info("y pixels:...
[ "private", "void", "drawSections", "(", ")", "{", "SectionTable", "table", "=", "data", ".", "getSectionTable", "(", ")", ";", "long", "sectionTableOffset", "=", "table", ".", "getOffset", "(", ")", ";", "long", "sectionTableSize", "=", "table", ".", "getSiz...
Draw the sections to the structure image.
[ "Draw", "the", "sections", "to", "the", "structure", "image", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L589-L607
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.getSectionColor
private Color getSectionColor(SectionHeader header) { // color is based on section number int nr = header.getNumber(); Color sectionColor = colorMap.get(SECTION_START); // modify the color section number times for (int i = 1; i < nr; i++) { sectionColor = variate(sectionColor); } return sectionColor; ...
java
private Color getSectionColor(SectionHeader header) { // color is based on section number int nr = header.getNumber(); Color sectionColor = colorMap.get(SECTION_START); // modify the color section number times for (int i = 1; i < nr; i++) { sectionColor = variate(sectionColor); } return sectionColor; ...
[ "private", "Color", "getSectionColor", "(", "SectionHeader", "header", ")", "{", "// color is based on section number", "int", "nr", "=", "header", ".", "getNumber", "(", ")", ";", "Color", "sectionColor", "=", "colorMap", ".", "get", "(", "SECTION_START", ")", ...
Generate the color of the given section. @param header of the section @return color of the section
[ "Generate", "the", "color", "of", "the", "given", "section", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L616-L625
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.variate
private Color variate(Color color) { assert color != null; final int diff = 30; // darken the color for value of diff int newRed = shiftColorPart(color.getRed() - diff); int newGreen = shiftColorPart(color.getGreen() - diff); int newBlue = shiftColorPart(color.getBlue() - diff); Color newColor = new Color...
java
private Color variate(Color color) { assert color != null; final int diff = 30; // darken the color for value of diff int newRed = shiftColorPart(color.getRed() - diff); int newGreen = shiftColorPart(color.getGreen() - diff); int newBlue = shiftColorPart(color.getBlue() - diff); Color newColor = new Color...
[ "private", "Color", "variate", "(", "Color", "color", ")", "{", "assert", "color", "!=", "null", ";", "final", "int", "diff", "=", "30", ";", "// darken the color for value of diff", "int", "newRed", "=", "shiftColorPart", "(", "color", ".", "getRed", "(", "...
Shift the given section color one step. This creates a color similar to the given color, but still different enough to tell the new color apart from the old one. @param color @return modified color
[ "Shift", "the", "given", "section", "color", "one", "step", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L636-L650
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.drawRect
private void drawRect(Color color, int startX, int startY, int width, int height) { assert color != null; for (int x = startX; x < startX + width; x++) { for (int y = startY; y < startY + height; y++) { try { image.setRGB(x, y, color.getRGB()); } catch (ArrayIndexOutOfBoundsException e) { lo...
java
private void drawRect(Color color, int startX, int startY, int width, int height) { assert color != null; for (int x = startX; x < startX + width; x++) { for (int y = startY; y < startY + height; y++) { try { image.setRGB(x, y, color.getRGB()); } catch (ArrayIndexOutOfBoundsException e) { lo...
[ "private", "void", "drawRect", "(", "Color", "color", ",", "int", "startX", ",", "int", "startY", ",", "int", "width", ",", "int", "height", ")", "{", "assert", "color", "!=", "null", ";", "for", "(", "int", "x", "=", "startX", ";", "x", "<", "star...
Draws a rectangle. @param color that fills the rectangle @param startX the x value of the upper left corner for the rectangle @param startY the y value of the upper left corner for the rectangle @param width the width of the rectangle in pixels @param height the height of the rectangle in pixels
[ "Draws", "a", "rectangle", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L835-L847
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.drawCross
private void drawCross(Color color, int startX, int startY, int width, int height) { assert color != null; final int thickness = 2; for (int x = startX; x < startX + width; x++) { for (int y = startY; y < startY + height; y++) { try { if (Math.abs((x - startX) - (y - startY)) < thickness || ...
java
private void drawCross(Color color, int startX, int startY, int width, int height) { assert color != null; final int thickness = 2; for (int x = startX; x < startX + width; x++) { for (int y = startY; y < startY + height; y++) { try { if (Math.abs((x - startX) - (y - startY)) < thickness || ...
[ "private", "void", "drawCross", "(", "Color", "color", ",", "int", "startX", ",", "int", "startY", ",", "int", "width", ",", "int", "height", ")", "{", "assert", "color", "!=", "null", ";", "final", "int", "thickness", "=", "2", ";", "for", "(", "int...
Draws a cross. @param color of the cross @param startX the x value of the upper left corner for the cross @param startY the y value of the upper left corner for the cross @param width the width of the cross in pixels @param height the height of the cross in pixels
[ "Draws", "a", "cross", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L863-L879
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.drawPixel
private void drawPixel(Color color, long fileOffset) { long size = withMinLength(0); drawPixels(color, fileOffset, size); }
java
private void drawPixel(Color color, long fileOffset) { long size = withMinLength(0); drawPixels(color, fileOffset, size); }
[ "private", "void", "drawPixel", "(", "Color", "color", ",", "long", "fileOffset", ")", "{", "long", "size", "=", "withMinLength", "(", "0", ")", ";", "drawPixels", "(", "color", ",", "fileOffset", ",", "size", ")", ";", "}" ]
Draws a square pixel at fileOffset with color. @param color of the square pixel @param fileOffset file location that the square pixel represents
[ "Draws", "a", "square", "pixel", "at", "fileOffset", "with", "color", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L916-L919
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.getPixelNumber
private long getPixelNumber(long fileOffset) { assert fileOffset >= 0; long result = Math.round(fileOffset / bytesPerPixel()); assert result >= 0; return result; }
java
private long getPixelNumber(long fileOffset) { assert fileOffset >= 0; long result = Math.round(fileOffset / bytesPerPixel()); assert result >= 0; return result; }
[ "private", "long", "getPixelNumber", "(", "long", "fileOffset", ")", "{", "assert", "fileOffset", ">=", "0", ";", "long", "result", "=", "Math", ".", "round", "(", "fileOffset", "/", "bytesPerPixel", "(", ")", ")", ";", "assert", "result", ">=", "0", ";"...
convert fileOffset to square pixels
[ "convert", "fileOffset", "to", "square", "pixels" ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L987-L992
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
Visualizer.bytesPerPixel
private int bytesPerPixel() { long fileSize = data.getFile().length(); long pixelMax = getXPixels() * (long) getYPixels(); // ceil result, because it is a maximum that we use to divide return (int) Math.ceil(fileSize / (double) pixelMax); }
java
private int bytesPerPixel() { long fileSize = data.getFile().length(); long pixelMax = getXPixels() * (long) getYPixels(); // ceil result, because it is a maximum that we use to divide return (int) Math.ceil(fileSize / (double) pixelMax); }
[ "private", "int", "bytesPerPixel", "(", ")", "{", "long", "fileSize", "=", "data", ".", "getFile", "(", ")", ".", "length", "(", ")", ";", "long", "pixelMax", "=", "getXPixels", "(", ")", "*", "(", "long", ")", "getYPixels", "(", ")", ";", "// ceil r...
Calculates how many bytes are covered by one square pixel. @return bytes covered by one square pixel
[ "Calculates", "how", "many", "bytes", "are", "covered", "by", "one", "square", "pixel", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L999-L1004
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/PELoader.java
PELoader.loadData
private PEData loadData() throws IOException { PESignature pesig = new PESignature(file); pesig.read(); checkState(pesig.exists(), "no valid pe file, signature not found"); // read all headers try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { ...
java
private PEData loadData() throws IOException { PESignature pesig = new PESignature(file); pesig.read(); checkState(pesig.exists(), "no valid pe file, signature not found"); // read all headers try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { ...
[ "private", "PEData", "loadData", "(", ")", "throws", "IOException", "{", "PESignature", "pesig", "=", "new", "PESignature", "(", "file", ")", ";", "pesig", ".", "read", "(", ")", ";", "checkState", "(", "pesig", ".", "exists", "(", ")", ",", "\"no valid ...
Loads the PE file header data into a PEData instance. @return header data @throws IOException if file can not be read @throws IllegalStateException if no valid PE file
[ "Loads", "the", "PE", "file", "header", "data", "into", "a", "PEData", "instance", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/PELoader.java#L86-L113
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/PELoader.java
PELoader.loadMSDOSHeader
private MSDOSHeader loadMSDOSHeader(RandomAccessFile raf, long peSigOffset) throws IOException { byte[] headerbytes = loadBytesSafely(0, MSDOSHeader.FORMATTED_HEADER_SIZE, raf); return MSDOSHeader.newInstance(headerbytes, peSigOffset); }
java
private MSDOSHeader loadMSDOSHeader(RandomAccessFile raf, long peSigOffset) throws IOException { byte[] headerbytes = loadBytesSafely(0, MSDOSHeader.FORMATTED_HEADER_SIZE, raf); return MSDOSHeader.newInstance(headerbytes, peSigOffset); }
[ "private", "MSDOSHeader", "loadMSDOSHeader", "(", "RandomAccessFile", "raf", ",", "long", "peSigOffset", ")", "throws", "IOException", "{", "byte", "[", "]", "headerbytes", "=", "loadBytesSafely", "(", "0", ",", "MSDOSHeader", ".", "FORMATTED_HEADER_SIZE", ",", "r...
Loads the MSDOS header. @param raf the random access file instance @return msdos header @throws IOException if unable to read header
[ "Loads", "the", "MSDOS", "header", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/PELoader.java#L187-L192
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/PELoader.java
PELoader.loadSectionTable
private SectionTable loadSectionTable(PESignature pesig, COFFFileHeader coff, RandomAccessFile raf) throws IOException { // offset is the start of the optional header + SizeOfOptionalHeader long offset = pesig.getOffset() + PESignature.PE_SIG.length + COFFFileHeader.HEADER_SI...
java
private SectionTable loadSectionTable(PESignature pesig, COFFFileHeader coff, RandomAccessFile raf) throws IOException { // offset is the start of the optional header + SizeOfOptionalHeader long offset = pesig.getOffset() + PESignature.PE_SIG.length + COFFFileHeader.HEADER_SI...
[ "private", "SectionTable", "loadSectionTable", "(", "PESignature", "pesig", ",", "COFFFileHeader", "coff", ",", "RandomAccessFile", "raf", ")", "throws", "IOException", "{", "// offset is the start of the optional header + SizeOfOptionalHeader", "long", "offset", "=", "pesig"...
Loads the section table. Presumes a valid PE file. @param pesig pe signature @param coff coff file header @param raf the random access file instance @return section table @throws IOException if unable to read header
[ "Loads", "the", "section", "table", ".", "Presumes", "a", "valid", "PE", "file", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/PELoader.java#L207-L227
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/PELoader.java
PELoader.loadCOFFFileHeader
private COFFFileHeader loadCOFFFileHeader(PESignature pesig, RandomAccessFile raf) throws IOException { // coff header starts right after the PE signature long offset = pesig.getOffset() + PESignature.PE_SIG.length; logger.info("COFF Header offset: " + offset); // read bytes,...
java
private COFFFileHeader loadCOFFFileHeader(PESignature pesig, RandomAccessFile raf) throws IOException { // coff header starts right after the PE signature long offset = pesig.getOffset() + PESignature.PE_SIG.length; logger.info("COFF Header offset: " + offset); // read bytes,...
[ "private", "COFFFileHeader", "loadCOFFFileHeader", "(", "PESignature", "pesig", ",", "RandomAccessFile", "raf", ")", "throws", "IOException", "{", "// coff header starts right after the PE signature", "long", "offset", "=", "pesig", ".", "getOffset", "(", ")", "+", "PES...
Loads the COFF File header. Presumes a valid PE file. @param pesig pe signature @param raf the random access file instance @return coff file header @throws IOException if unable to read header
[ "Loads", "the", "COFF", "File", "header", ".", "Presumes", "a", "valid", "PE", "file", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/PELoader.java#L240-L250
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/PELoader.java
PELoader.loadOptionalHeader
private OptionalHeader loadOptionalHeader(PESignature pesig, COFFFileHeader coff, RandomAccessFile raf) throws IOException { // offset right after the eCOFF File Header long offset = pesig.getOffset() + PESignature.PE_SIG.length + COFFFileHeader.HEADER_SIZE; logger.in...
java
private OptionalHeader loadOptionalHeader(PESignature pesig, COFFFileHeader coff, RandomAccessFile raf) throws IOException { // offset right after the eCOFF File Header long offset = pesig.getOffset() + PESignature.PE_SIG.length + COFFFileHeader.HEADER_SIZE; logger.in...
[ "private", "OptionalHeader", "loadOptionalHeader", "(", "PESignature", "pesig", ",", "COFFFileHeader", "coff", ",", "RandomAccessFile", "raf", ")", "throws", "IOException", "{", "// offset right after the eCOFF File Header", "long", "offset", "=", "pesig", ".", "getOffset...
Loads the optional header. Presumes a valid PE file. @param pesig pe signature @param coff coff file header @param raf the random access file instance @return optional header @throws IOException if unable to read header
[ "Loads", "the", "optional", "header", ".", "Presumes", "a", "valid", "PE", "file", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/PELoader.java#L265-L276
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/DataDirEntry.java
DataDirEntry.getFileOffset
public long getFileOffset(SectionTable table) { checkArgument(table != null, "section table must not be null"); Optional<SectionHeader> section = maybeGetSectionTableEntry(table); if (section.isPresent()) { long sectionRVA = section.get().getAlignedVirtualAddress(); long...
java
public long getFileOffset(SectionTable table) { checkArgument(table != null, "section table must not be null"); Optional<SectionHeader> section = maybeGetSectionTableEntry(table); if (section.isPresent()) { long sectionRVA = section.get().getAlignedVirtualAddress(); long...
[ "public", "long", "getFileOffset", "(", "SectionTable", "table", ")", "{", "checkArgument", "(", "table", "!=", "null", ",", "\"section table must not be null\"", ")", ";", "Optional", "<", "SectionHeader", ">", "section", "=", "maybeGetSectionTableEntry", "(", "tab...
Calculates the file offset of the data directory based on the virtual address and the entries in the section table. This method is subject to change. @Beta @param table @return file offset of data directory
[ "Calculates", "the", "file", "offset", "of", "the", "data", "directory", "based", "on", "the", "virtual", "address", "and", "the", "entries", "in", "the", "section", "table", ".", "This", "method", "is", "subject", "to", "change", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/DataDirEntry.java#L126-L135
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/DataDirEntry.java
DataDirEntry.getSectionTableEntry
public SectionHeader getSectionTableEntry(SectionTable table) { Optional<SectionHeader> entry = maybeGetSectionTableEntry(table); if (entry.isPresent()) { return entry.get(); } throw new IllegalStateException( "there is no section for this data directory entry...
java
public SectionHeader getSectionTableEntry(SectionTable table) { Optional<SectionHeader> entry = maybeGetSectionTableEntry(table); if (entry.isPresent()) { return entry.get(); } throw new IllegalStateException( "there is no section for this data directory entry...
[ "public", "SectionHeader", "getSectionTableEntry", "(", "SectionTable", "table", ")", "{", "Optional", "<", "SectionHeader", ">", "entry", "=", "maybeGetSectionTableEntry", "(", "table", ")", ";", "if", "(", "entry", ".", "isPresent", "(", ")", ")", "{", "retu...
Returns the section table entry of the section that the data directory entry is pointing to. @param table @return the section table entry of the section that the data directory entry is pointing to @throws IllegalStateException if data dir entry is not in a section
[ "Returns", "the", "section", "table", "entry", "of", "the", "section", "that", "the", "data", "directory", "entry", "is", "pointing", "to", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/DataDirEntry.java#L147-L154
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/optheader/DataDirEntry.java
DataDirEntry.maybeGetSectionTableEntry
public Optional<SectionHeader> maybeGetSectionTableEntry(SectionTable table) { checkArgument(table != null, "table must not be null"); List<SectionHeader> sections = table.getSectionHeaders(); // loop through all section headers to check if entry is within section for (SectionHeader head...
java
public Optional<SectionHeader> maybeGetSectionTableEntry(SectionTable table) { checkArgument(table != null, "table must not be null"); List<SectionHeader> sections = table.getSectionHeaders(); // loop through all section headers to check if entry is within section for (SectionHeader head...
[ "public", "Optional", "<", "SectionHeader", ">", "maybeGetSectionTableEntry", "(", "SectionTable", "table", ")", "{", "checkArgument", "(", "table", "!=", "null", ",", "\"table must not be null\"", ")", ";", "List", "<", "SectionHeader", ">", "sections", "=", "tab...
more convenient use of the API
[ "more", "convenient", "use", "of", "the", "API" ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/optheader/DataDirEntry.java#L167-L190
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionHeader.java
SectionHeader.getAlignedSizeOfRaw
public long getAlignedSizeOfRaw() { long sizeOfRaw = get(SIZE_OF_RAW_DATA); if (sizeOfRaw == (sizeOfRaw & ~0xfff)) { return sizeOfRaw; } long result = (sizeOfRaw + 0xfff) & ~0xfff; assert result % 4096 == 0; return result; }
java
public long getAlignedSizeOfRaw() { long sizeOfRaw = get(SIZE_OF_RAW_DATA); if (sizeOfRaw == (sizeOfRaw & ~0xfff)) { return sizeOfRaw; } long result = (sizeOfRaw + 0xfff) & ~0xfff; assert result % 4096 == 0; return result; }
[ "public", "long", "getAlignedSizeOfRaw", "(", ")", "{", "long", "sizeOfRaw", "=", "get", "(", "SIZE_OF_RAW_DATA", ")", ";", "if", "(", "sizeOfRaw", "==", "(", "sizeOfRaw", "&", "~", "0xfff", ")", ")", "{", "return", "sizeOfRaw", ";", "}", "long", "result...
Returns the SizeOfRawData rounded up to a multiple of 4kb. @return aligned SizeOfRawData
[ "Returns", "the", "SizeOfRawData", "rounded", "up", "to", "a", "multiple", "of", "4kb", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionHeader.java#L108-L116
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionHeader.java
SectionHeader.getAlignedVirtualSize
public long getAlignedVirtualSize() { long virtSize = get(VIRTUAL_SIZE); if (virtSize == (virtSize & ~0xfff)) { return virtSize; } // TODO: corkami: "a section can have a null VirtualSize: in this case, // only the SizeOfRawData is taken into consideration" lo...
java
public long getAlignedVirtualSize() { long virtSize = get(VIRTUAL_SIZE); if (virtSize == (virtSize & ~0xfff)) { return virtSize; } // TODO: corkami: "a section can have a null VirtualSize: in this case, // only the SizeOfRawData is taken into consideration" lo...
[ "public", "long", "getAlignedVirtualSize", "(", ")", "{", "long", "virtSize", "=", "get", "(", "VIRTUAL_SIZE", ")", ";", "if", "(", "virtSize", "==", "(", "virtSize", "&", "~", "0xfff", ")", ")", "{", "return", "virtSize", ";", "}", "// TODO: corkami: \"a ...
Returns the VirtualSize rounded up to a multiple of 4kb. @return aligned VirtualSize
[ "Returns", "the", "VirtualSize", "rounded", "up", "to", "a", "multiple", "of", "4kb", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionHeader.java#L123-L133
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionHeader.java
SectionHeader.getAlignedVirtualAddress
public long getAlignedVirtualAddress() { long virtAddr = get(VIRTUAL_ADDRESS); if (virtAddr == (virtAddr & ~0xfff)) { return virtAddr; } long result = (virtAddr + 0xfff) & ~0xfff; assert result % 4096 == 0; return result; }
java
public long getAlignedVirtualAddress() { long virtAddr = get(VIRTUAL_ADDRESS); if (virtAddr == (virtAddr & ~0xfff)) { return virtAddr; } long result = (virtAddr + 0xfff) & ~0xfff; assert result % 4096 == 0; return result; }
[ "public", "long", "getAlignedVirtualAddress", "(", ")", "{", "long", "virtAddr", "=", "get", "(", "VIRTUAL_ADDRESS", ")", ";", "if", "(", "virtAddr", "==", "(", "virtAddr", "&", "~", "0xfff", ")", ")", "{", "return", "virtAddr", ";", "}", "long", "result...
Returns the VirtualAddress rounded up to a multiple of 4kb. @return aligned VirtualAddress
[ "Returns", "the", "VirtualAddress", "rounded", "up", "to", "a", "multiple", "of", "4kb", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionHeader.java#L140-L148
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionHeader.java
SectionHeader.getCharacteristics
public List<SectionCharacteristic> getCharacteristics() { long value = get(SectionHeaderKey.CHARACTERISTICS); List<SectionCharacteristic> list = SectionCharacteristic.getAllFor(value); assert list != null; return list; }
java
public List<SectionCharacteristic> getCharacteristics() { long value = get(SectionHeaderKey.CHARACTERISTICS); List<SectionCharacteristic> list = SectionCharacteristic.getAllFor(value); assert list != null; return list; }
[ "public", "List", "<", "SectionCharacteristic", ">", "getCharacteristics", "(", ")", "{", "long", "value", "=", "get", "(", "SectionHeaderKey", ".", "CHARACTERISTICS", ")", ";", "List", "<", "SectionCharacteristic", ">", "list", "=", "SectionCharacteristic", ".", ...
Returns a list of all characteristics of that section. @return list of all characteristics
[ "Returns", "a", "list", "of", "all", "characteristics", "of", "that", "section", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionHeader.java#L211-L216
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionTable.java
SectionTable.getSectionHeader
public SectionHeader getSectionHeader(int number) { for (SectionHeader header : headers) { if (header.getNumber() == number) { return header; } } throw new IllegalArgumentException( "invalid section number, no section header found"); }
java
public SectionHeader getSectionHeader(int number) { for (SectionHeader header : headers) { if (header.getNumber() == number) { return header; } } throw new IllegalArgumentException( "invalid section number, no section header found"); }
[ "public", "SectionHeader", "getSectionHeader", "(", "int", "number", ")", "{", "for", "(", "SectionHeader", "header", ":", "headers", ")", "{", "if", "(", "header", ".", "getNumber", "(", ")", "==", "number", ")", "{", "return", "header", ";", "}", "}", ...
Returns the section entry that has the given number or null if there is no section with that number. @param number of the section @return the section table entry that has the given number @throw {@link IllegalArgumentException} if no section header for number found
[ "Returns", "the", "section", "entry", "that", "has", "the", "given", "number", "or", "null", "if", "there", "is", "no", "section", "with", "that", "number", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionTable.java#L153-L161
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionTable.java
SectionTable.getSectionHeader
public SectionHeader getSectionHeader(String sectionName) { for (SectionHeader entry : headers) { if (entry.getName().equals(sectionName)) { return entry; } } throw new IllegalArgumentException( "invalid section name, no section header foun...
java
public SectionHeader getSectionHeader(String sectionName) { for (SectionHeader entry : headers) { if (entry.getName().equals(sectionName)) { return entry; } } throw new IllegalArgumentException( "invalid section name, no section header foun...
[ "public", "SectionHeader", "getSectionHeader", "(", "String", "sectionName", ")", "{", "for", "(", "SectionHeader", "entry", ":", "headers", ")", "{", "if", "(", "entry", ".", "getName", "(", ")", ".", "equals", "(", "sectionName", ")", ")", "{", "return",...
Returns the section entry that has the given name. If there are several sections with the same name, the first one will be returned. @param sectionName name of the section @return the section table entry that has the given sectionName @throw {@link IllegalArgumentException} if no section header for name found
[ "Returns", "the", "section", "entry", "that", "has", "the", "given", "name", ".", "If", "there", "are", "several", "sections", "with", "the", "same", "name", "the", "first", "one", "will", "be", "returned", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionTable.java#L173-L181
train
katjahahn/PortEx
src/main/java/com/github/katjahahn/parser/sections/SectionTable.java
SectionTable.getSectionHeaderByName
public Optional<SectionHeader> getSectionHeaderByName(String name) { for (SectionHeader header : headers) { if (header.getName().equals(name)) { return Optional.of(header); } } return Optional.absent(); }
java
public Optional<SectionHeader> getSectionHeaderByName(String name) { for (SectionHeader header : headers) { if (header.getName().equals(name)) { return Optional.of(header); } } return Optional.absent(); }
[ "public", "Optional", "<", "SectionHeader", ">", "getSectionHeaderByName", "(", "String", "name", ")", "{", "for", "(", "SectionHeader", "header", ":", "headers", ")", "{", "if", "(", "header", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", "...
Returns an optional of the first section that has the given name. @param name @return first section with the given name, absent if no section with that name found
[ "Returns", "an", "optional", "of", "the", "first", "section", "that", "has", "the", "given", "name", "." ]
319f08560aa58e3d5d7abe346ffdf623d6dc6990
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/sections/SectionTable.java#L231-L238
train
robinst/autolink-java
src/main/java/org/nibor/autolink/Autolink.java
Autolink.renderLinks
@Deprecated public static String renderLinks(CharSequence input, Iterable<LinkSpan> links, LinkRenderer linkRenderer) { if (input == null) { throw new NullPointerException("input must not be null"); } if (links == null) { throw new NullPointerException("links must not...
java
@Deprecated public static String renderLinks(CharSequence input, Iterable<LinkSpan> links, LinkRenderer linkRenderer) { if (input == null) { throw new NullPointerException("input must not be null"); } if (links == null) { throw new NullPointerException("links must not...
[ "@", "Deprecated", "public", "static", "String", "renderLinks", "(", "CharSequence", "input", ",", "Iterable", "<", "LinkSpan", ">", "links", ",", "LinkRenderer", "linkRenderer", ")", "{", "if", "(", "input", "==", "null", ")", "{", "throw", "new", "NullPoin...
Render the supplied links from the supplied input text using a renderer. The parts of the text outside of links are added to the result without processing. @param input the input text, must not be null @param links the links to render, see {@link LinkExtractor} to extract them @param linkRenderer the link rendering im...
[ "Render", "the", "supplied", "links", "from", "the", "supplied", "input", "text", "using", "a", "renderer", ".", "The", "parts", "of", "the", "text", "outside", "of", "links", "are", "added", "to", "the", "result", "without", "processing", "." ]
9b01c2620d450cd51942f4d092e4e7153980c6d8
https://github.com/robinst/autolink-java/blob/9b01c2620d450cd51942f4d092e4e7153980c6d8/src/main/java/org/nibor/autolink/Autolink.java#L18-L40
train
robinst/autolink-java
src/main/java/org/nibor/autolink/internal/EmailScanner.java
EmailScanner.findFirst
private int findFirst(CharSequence input, int beginIndex, int rewindIndex) { int first = -1; boolean atomBoundary = true; for (int i = beginIndex; i >= rewindIndex; i--) { char c = input.charAt(i); if (localAtomAllowed(c)) { first = i; atom...
java
private int findFirst(CharSequence input, int beginIndex, int rewindIndex) { int first = -1; boolean atomBoundary = true; for (int i = beginIndex; i >= rewindIndex; i--) { char c = input.charAt(i); if (localAtomAllowed(c)) { first = i; atom...
[ "private", "int", "findFirst", "(", "CharSequence", "input", ",", "int", "beginIndex", ",", "int", "rewindIndex", ")", "{", "int", "first", "=", "-", "1", ";", "boolean", "atomBoundary", "=", "true", ";", "for", "(", "int", "i", "=", "beginIndex", ";", ...
See "Local-part" in RFC 5321, plus extensions in RFC 6531
[ "See", "Local", "-", "part", "in", "RFC", "5321", "plus", "extensions", "in", "RFC", "6531" ]
9b01c2620d450cd51942f4d092e4e7153980c6d8
https://github.com/robinst/autolink-java/blob/9b01c2620d450cd51942f4d092e4e7153980c6d8/src/main/java/org/nibor/autolink/internal/EmailScanner.java#L37-L55
train
robinst/autolink-java
src/main/java/org/nibor/autolink/internal/EmailScanner.java
EmailScanner.findLast
private int findLast(CharSequence input, int beginIndex) { boolean firstInSubDomain = true; boolean canEndSubDomain = false; int firstDot = -1; int last = -1; for (int i = beginIndex; i < input.length(); i++) { char c = input.charAt(i); if (firstInSubDomai...
java
private int findLast(CharSequence input, int beginIndex) { boolean firstInSubDomain = true; boolean canEndSubDomain = false; int firstDot = -1; int last = -1; for (int i = beginIndex; i < input.length(); i++) { char c = input.charAt(i); if (firstInSubDomai...
[ "private", "int", "findLast", "(", "CharSequence", "input", ",", "int", "beginIndex", ")", "{", "boolean", "firstInSubDomain", "=", "true", ";", "boolean", "canEndSubDomain", "=", "false", ";", "int", "firstDot", "=", "-", "1", ";", "int", "last", "=", "-"...
See "Domain" in RFC 5321, plus extension of "sub-domain" in RFC 6531
[ "See", "Domain", "in", "RFC", "5321", "plus", "extension", "of", "sub", "-", "domain", "in", "RFC", "6531" ]
9b01c2620d450cd51942f4d092e4e7153980c6d8
https://github.com/robinst/autolink-java/blob/9b01c2620d450cd51942f4d092e4e7153980c6d8/src/main/java/org/nibor/autolink/internal/EmailScanner.java#L58-L97
train
robinst/autolink-java
src/main/java/org/nibor/autolink/internal/EmailScanner.java
EmailScanner.localAtomAllowed
private boolean localAtomAllowed(char c) { if (Scanners.isAlnum(c) || Scanners.isNonAscii(c)) { return true; } switch (c) { case '!': case '#': case '$': case '%': case '&': case '\'': case '*': ...
java
private boolean localAtomAllowed(char c) { if (Scanners.isAlnum(c) || Scanners.isNonAscii(c)) { return true; } switch (c) { case '!': case '#': case '$': case '%': case '&': case '\'': case '*': ...
[ "private", "boolean", "localAtomAllowed", "(", "char", "c", ")", "{", "if", "(", "Scanners", ".", "isAlnum", "(", "c", ")", "||", "Scanners", ".", "isNonAscii", "(", "c", ")", ")", "{", "return", "true", ";", "}", "switch", "(", "c", ")", "{", "cas...
See "Atom" in RFC 5321, "atext" in RFC 5322
[ "See", "Atom", "in", "RFC", "5321", "atext", "in", "RFC", "5322" ]
9b01c2620d450cd51942f4d092e4e7153980c6d8
https://github.com/robinst/autolink-java/blob/9b01c2620d450cd51942f4d092e4e7153980c6d8/src/main/java/org/nibor/autolink/internal/EmailScanner.java#L100-L127
train
robinst/autolink-java
src/main/java/org/nibor/autolink/internal/UrlScanner.java
UrlScanner.findFirst
private int findFirst(CharSequence input, int beginIndex, int rewindIndex) { int first = -1; int digit = -1; for (int i = beginIndex; i >= rewindIndex; i--) { char c = input.charAt(i); if (Scanners.isAlpha(c)) { first = i; } else if (Scanners.i...
java
private int findFirst(CharSequence input, int beginIndex, int rewindIndex) { int first = -1; int digit = -1; for (int i = beginIndex; i >= rewindIndex; i--) { char c = input.charAt(i); if (Scanners.isAlpha(c)) { first = i; } else if (Scanners.i...
[ "private", "int", "findFirst", "(", "CharSequence", "input", ",", "int", "beginIndex", ",", "int", "rewindIndex", ")", "{", "int", "first", "=", "-", "1", ";", "int", "digit", "=", "-", "1", ";", "for", "(", "int", "i", "=", "beginIndex", ";", "i", ...
See "scheme" in RFC 3986
[ "See", "scheme", "in", "RFC", "3986" ]
9b01c2620d450cd51942f4d092e4e7153980c6d8
https://github.com/robinst/autolink-java/blob/9b01c2620d450cd51942f4d092e4e7153980c6d8/src/main/java/org/nibor/autolink/internal/UrlScanner.java#L35-L54
train
policeman-tools/forbidden-apis
src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java
AsmUtils.readAndPatchClass
@SuppressForbidden @SuppressWarnings("unused") public static ClassReader readAndPatchClass(InputStream in) throws IOException { final byte[] bytecode = readStream(in); if (false) patchClassMajorVersion(bytecode, Opcodes.V10 + 1, Opcodes.V10); return new ClassReader(bytecode); }
java
@SuppressForbidden @SuppressWarnings("unused") public static ClassReader readAndPatchClass(InputStream in) throws IOException { final byte[] bytecode = readStream(in); if (false) patchClassMajorVersion(bytecode, Opcodes.V10 + 1, Opcodes.V10); return new ClassReader(bytecode); }
[ "@", "SuppressForbidden", "@", "SuppressWarnings", "(", "\"unused\"", ")", "public", "static", "ClassReader", "readAndPatchClass", "(", "InputStream", "in", ")", "throws", "IOException", "{", "final", "byte", "[", "]", "bytecode", "=", "readStream", "(", "in", "...
Utility method to load class files of later Java versions by patching them, so ASM can read them. Does nothing at the moment.
[ "Utility", "method", "to", "load", "class", "files", "of", "later", "Java", "versions", "by", "patching", "them", "so", "ASM", "can", "read", "them", ".", "Does", "nothing", "at", "the", "moment", "." ]
df5f00c6bb779875ec6bae967f7cec96670b27d9
https://github.com/policeman-tools/forbidden-apis/blob/df5f00c6bb779875ec6bae967f7cec96670b27d9/src/main/java/de/thetaphi/forbiddenapis/AsmUtils.java#L178-L184
train
policeman-tools/forbidden-apis
src/main/java/de/thetaphi/forbiddenapis/maven/SignaturesArtifact.java
SignaturesArtifact.createArtifact
Artifact createArtifact(ArtifactFactory artifactFactory) { if (groupId == null || artifactId == null || version == null || type == null) { throw new NullPointerException("signaturesArtifact is missing some properties. Required are: groupId, artifactId, version, type"); } return artifactFactory.createA...
java
Artifact createArtifact(ArtifactFactory artifactFactory) { if (groupId == null || artifactId == null || version == null || type == null) { throw new NullPointerException("signaturesArtifact is missing some properties. Required are: groupId, artifactId, version, type"); } return artifactFactory.createA...
[ "Artifact", "createArtifact", "(", "ArtifactFactory", "artifactFactory", ")", "{", "if", "(", "groupId", "==", "null", "||", "artifactId", "==", "null", "||", "version", "==", "null", "||", "type", "==", "null", ")", "{", "throw", "new", "NullPointerException"...
Used by the mojo to fetch the artifact
[ "Used", "by", "the", "mojo", "to", "fetch", "the", "artifact" ]
df5f00c6bb779875ec6bae967f7cec96670b27d9
https://github.com/policeman-tools/forbidden-apis/blob/df5f00c6bb779875ec6bae967f7cec96670b27d9/src/main/java/de/thetaphi/forbiddenapis/maven/SignaturesArtifact.java#L54-L59
train
policeman-tools/forbidden-apis
src/main/java/de/thetaphi/forbiddenapis/Checker.java
Checker.loadClassFromJigsaw
private ClassSignature loadClassFromJigsaw(String classname) throws IOException { if (method_Class_getModule == null || method_Module_getName == null) { return null; // not Jigsaw Module System } final Class<?> clazz; final String moduleName; try { clazz = Class.forName(classname, f...
java
private ClassSignature loadClassFromJigsaw(String classname) throws IOException { if (method_Class_getModule == null || method_Module_getName == null) { return null; // not Jigsaw Module System } final Class<?> clazz; final String moduleName; try { clazz = Class.forName(classname, f...
[ "private", "ClassSignature", "loadClassFromJigsaw", "(", "String", "classname", ")", "throws", "IOException", "{", "if", "(", "method_Class_getModule", "==", "null", "||", "method_Module_getName", "==", "null", ")", "{", "return", "null", ";", "// not Jigsaw Module Sy...
Loads the class from Java9's module system and uses reflection to get methods and fields.
[ "Loads", "the", "class", "from", "Java9", "s", "module", "system", "and", "uses", "reflection", "to", "get", "methods", "and", "fields", "." ]
df5f00c6bb779875ec6bae967f7cec96670b27d9
https://github.com/policeman-tools/forbidden-apis/blob/df5f00c6bb779875ec6bae967f7cec96670b27d9/src/main/java/de/thetaphi/forbiddenapis/Checker.java#L187-L203
train
policeman-tools/forbidden-apis
src/main/java/de/thetaphi/forbiddenapis/Checker.java
Checker.parseSignaturesFile
public void parseSignaturesFile(URL url) throws IOException,ParseException { parseSignaturesFile(url.openStream(), url.toString()); }
java
public void parseSignaturesFile(URL url) throws IOException,ParseException { parseSignaturesFile(url.openStream(), url.toString()); }
[ "public", "void", "parseSignaturesFile", "(", "URL", "url", ")", "throws", "IOException", ",", "ParseException", "{", "parseSignaturesFile", "(", "url", ".", "openStream", "(", ")", ",", "url", ".", "toString", "(", ")", ")", ";", "}" ]
Reads a list of API signatures from the given URL.
[ "Reads", "a", "list", "of", "API", "signatures", "from", "the", "given", "URL", "." ]
df5f00c6bb779875ec6bae967f7cec96670b27d9
https://github.com/policeman-tools/forbidden-apis/blob/df5f00c6bb779875ec6bae967f7cec96670b27d9/src/main/java/de/thetaphi/forbiddenapis/Checker.java#L329-L331
train
policeman-tools/forbidden-apis
src/main/java/de/thetaphi/forbiddenapis/Checker.java
Checker.parseSignaturesFile
public void parseSignaturesFile(File f) throws IOException,ParseException { parseSignaturesFile(new FileInputStream(f), f.toString()); }
java
public void parseSignaturesFile(File f) throws IOException,ParseException { parseSignaturesFile(new FileInputStream(f), f.toString()); }
[ "public", "void", "parseSignaturesFile", "(", "File", "f", ")", "throws", "IOException", ",", "ParseException", "{", "parseSignaturesFile", "(", "new", "FileInputStream", "(", "f", ")", ",", "f", ".", "toString", "(", ")", ")", ";", "}" ]
Reads a list of API signatures from the given file.
[ "Reads", "a", "list", "of", "API", "signatures", "from", "the", "given", "file", "." ]
df5f00c6bb779875ec6bae967f7cec96670b27d9
https://github.com/policeman-tools/forbidden-apis/blob/df5f00c6bb779875ec6bae967f7cec96670b27d9/src/main/java/de/thetaphi/forbiddenapis/Checker.java#L334-L336
train
policeman-tools/forbidden-apis
src/main/java/de/thetaphi/forbiddenapis/Checker.java
Checker.checkClass
private int checkClass(final ClassReader reader, Pattern suppressAnnotationsPattern) throws ForbiddenApiException { final String className = Type.getObjectType(reader.getClassName()).getClassName(); final ClassScanner scanner = new ClassScanner(this, forbiddenSignatures, suppressAnnotationsPattern); try { ...
java
private int checkClass(final ClassReader reader, Pattern suppressAnnotationsPattern) throws ForbiddenApiException { final String className = Type.getObjectType(reader.getClassName()).getClassName(); final ClassScanner scanner = new ClassScanner(this, forbiddenSignatures, suppressAnnotationsPattern); try { ...
[ "private", "int", "checkClass", "(", "final", "ClassReader", "reader", ",", "Pattern", "suppressAnnotationsPattern", ")", "throws", "ForbiddenApiException", "{", "final", "String", "className", "=", "Type", ".", "getObjectType", "(", "reader", ".", "getClassName", "...
Parses a class and checks for valid method invocations
[ "Parses", "a", "class", "and", "checks", "for", "valid", "method", "invocations" ]
df5f00c6bb779875ec6bae967f7cec96670b27d9
https://github.com/policeman-tools/forbidden-apis/blob/df5f00c6bb779875ec6bae967f7cec96670b27d9/src/main/java/de/thetaphi/forbiddenapis/Checker.java#L406-L434
train
policeman-tools/forbidden-apis
src/main/java/de/thetaphi/forbiddenapis/Signatures.java
Signatures.parseSignaturesString
public void parseSignaturesString(String signatures) throws IOException,ParseException { logger.info("Reading inline API signatures..."); final Set<String> missingClasses = new TreeSet<String>(); parseSignaturesFile(new StringReader(signatures), false, missingClasses); reportMissingSignatureClasses(miss...
java
public void parseSignaturesString(String signatures) throws IOException,ParseException { logger.info("Reading inline API signatures..."); final Set<String> missingClasses = new TreeSet<String>(); parseSignaturesFile(new StringReader(signatures), false, missingClasses); reportMissingSignatureClasses(miss...
[ "public", "void", "parseSignaturesString", "(", "String", "signatures", ")", "throws", "IOException", ",", "ParseException", "{", "logger", ".", "info", "(", "\"Reading inline API signatures...\"", ")", ";", "final", "Set", "<", "String", ">", "missingClasses", "=",...
Reads a list of API signatures from a String.
[ "Reads", "a", "list", "of", "API", "signatures", "from", "a", "String", "." ]
df5f00c6bb779875ec6bae967f7cec96670b27d9
https://github.com/policeman-tools/forbidden-apis/blob/df5f00c6bb779875ec6bae967f7cec96670b27d9/src/main/java/de/thetaphi/forbiddenapis/Signatures.java#L309-L314
train
policeman-tools/forbidden-apis
src/main/java/de/thetaphi/forbiddenapis/ant/AntTask.java
AntTask.createBundledSignatures
public BundledSignaturesType createBundledSignatures() { final BundledSignaturesType s = new BundledSignaturesType(); s.setProject(getProject()); bundledSignatures.add(s); return s; }
java
public BundledSignaturesType createBundledSignatures() { final BundledSignaturesType s = new BundledSignaturesType(); s.setProject(getProject()); bundledSignatures.add(s); return s; }
[ "public", "BundledSignaturesType", "createBundledSignatures", "(", ")", "{", "final", "BundledSignaturesType", "s", "=", "new", "BundledSignaturesType", "(", ")", ";", "s", ".", "setProject", "(", "getProject", "(", ")", ")", ";", "bundledSignatures", ".", "add", ...
Creates a bundled signatures instance
[ "Creates", "a", "bundled", "signatures", "instance" ]
df5f00c6bb779875ec6bae967f7cec96670b27d9
https://github.com/policeman-tools/forbidden-apis/blob/df5f00c6bb779875ec6bae967f7cec96670b27d9/src/main/java/de/thetaphi/forbiddenapis/ant/AntTask.java#L269-L274
train
FasterXML/woodstox
src/main/java/com/ctc/wstx/osgi/WstxBundleActivator.java
WstxBundleActivator.start
@Override public void start(BundleContext ctxt) { InputFactoryProviderImpl inputP = new InputFactoryProviderImpl(); ctxt.registerService(Stax2InputFactoryProvider.class.getName(), inputP, inputP.getProperties()); OutputFactoryProviderImpl outputP = new OutputFactoryProviderImpl(); ...
java
@Override public void start(BundleContext ctxt) { InputFactoryProviderImpl inputP = new InputFactoryProviderImpl(); ctxt.registerService(Stax2InputFactoryProvider.class.getName(), inputP, inputP.getProperties()); OutputFactoryProviderImpl outputP = new OutputFactoryProviderImpl(); ...
[ "@", "Override", "public", "void", "start", "(", "BundleContext", "ctxt", ")", "{", "InputFactoryProviderImpl", "inputP", "=", "new", "InputFactoryProviderImpl", "(", ")", ";", "ctxt", ".", "registerService", "(", "Stax2InputFactoryProvider", ".", "class", ".", "g...
Method called on activation. We need to register all providers we have at this point.
[ "Method", "called", "on", "activation", ".", "We", "need", "to", "register", "all", "providers", "we", "have", "at", "this", "point", "." ]
ffcaabdc06672d9564c48c25d601d029b7fd6548
https://github.com/FasterXML/woodstox/blob/ffcaabdc06672d9564c48c25d601d029b7fd6548/src/main/java/com/ctc/wstx/osgi/WstxBundleActivator.java#L26-L38
train
FasterXML/woodstox
src/main/java/com/ctc/wstx/sr/InputElementStack.java
InputElementStack.createNonTransientNsContext
public BaseNsContext createNonTransientNsContext(Location loc) { // Have an instance we can reuse? Great! if (mLastNsContext != null) { return mLastNsContext; } // No namespaces declared at this point? Easy, as well: int totalNsSize = mNamespaces.size(); ...
java
public BaseNsContext createNonTransientNsContext(Location loc) { // Have an instance we can reuse? Great! if (mLastNsContext != null) { return mLastNsContext; } // No namespaces declared at this point? Easy, as well: int totalNsSize = mNamespaces.size(); ...
[ "public", "BaseNsContext", "createNonTransientNsContext", "(", "Location", "loc", ")", "{", "// Have an instance we can reuse? Great!", "if", "(", "mLastNsContext", "!=", "null", ")", "{", "return", "mLastNsContext", ";", "}", "// No namespaces declared at this point? Easy, a...
Method called to construct a non-transient NamespaceContext instance; generally needed when creating events to return from event-based iterators.
[ "Method", "called", "to", "construct", "a", "non", "-", "transient", "NamespaceContext", "instance", ";", "generally", "needed", "when", "creating", "events", "to", "return", "from", "event", "-", "based", "iterators", "." ]
ffcaabdc06672d9564c48c25d601d029b7fd6548
https://github.com/FasterXML/woodstox/blob/ffcaabdc06672d9564c48c25d601d029b7fd6548/src/main/java/com/ctc/wstx/sr/InputElementStack.java#L289-L316
train