diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HighlightedTextWriter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HighlightedTextWriter.java index fa1508f44..beda7dbfb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HighlightedTextWriter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/HighlightedTextWriter.java @@ -19,8 +19,8 @@ package com.jpexs.decompiler.flash.helpers; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.hilight.HighlightData; import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; -import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.flash.helpers.hilight.HighlightType; +import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.helpers.Helper; import java.util.ArrayList; diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index 4b962c6b8..72fa505cb 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -1430,7 +1430,7 @@ public class CommandLineArgumentParser { try { src.setActions(ASMParser.parse(0, true, text, src.getSwf().version, false)); } catch (ActionParseException ex) { - System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", "" + ex.line)); + System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", Long.toString(ex.line))); System.exit(1); } } @@ -1444,10 +1444,10 @@ public class CommandLineArgumentParser { try { src.setActions(par.actionsFromString(as)); } catch (ActionParseException ex) { - System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", "" + ex.line)); + System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", Long.toString(ex.line))); System.exit(1); } catch (CompilationException ex) { - System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", "" + ex.line)); + System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", Long.toString(ex.line))); System.exit(1); } src.setModified(); @@ -1486,7 +1486,7 @@ public class CommandLineArgumentParser { //acode.getBytes(abc.bodies.get(bodyIndex).getCodeBytes()); abc.bodies.get(bodyIndex).setCode(acode); } catch (AVM2ParseException ex) { - System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", "" + ex.line)); + System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", Long.toString(ex.line))); System.exit(1); } } @@ -1509,10 +1509,10 @@ public class CommandLineArgumentParser { try { pack.abc.replaceSciptPack(pack, as); } catch (AVM2ParseException ex) { - System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", "" + ex.line)); + System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", Long.toString(ex.line))); System.exit(1); } catch (CompilationException ex) { - System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", "" + ex.line)); + System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", Long.toString(ex.line))); System.exit(1); } } diff --git a/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java b/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java index a6e17cf05..607965cc4 100644 --- a/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java +++ b/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java @@ -72,7 +72,7 @@ public class ContextMenuTools { String exeName = "ffdec.exe"; - if (add) { + if (add) { return addToContextMenu(add, fromCommandLine, exeName); } else { // remove both 32 and 64 bit references diff --git a/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java b/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java index 5a0c2f20e..0059ec8b1 100644 --- a/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java @@ -324,9 +324,9 @@ public class FontEmbedDialog extends AppDialog implements ActionListener { } rangeSamples[i].setText(sample); rangeSamples[i].setFont(f); - rangeCheckboxes[i].setText(translate("range.description").replace("%available%", "" + avail).replace("%name%", rangeNames[i]).replace("%total%", "" + codes.length)); + rangeCheckboxes[i].setText(translate("range.description").replace("%available%", Integer.toString(avail)).replace("%name%", rangeNames[i]).replace("%total%", Integer.toString(codes.length))); } - allCheckbox.setText(translate("allcharacters").replace("%available%", "" + allChars.size())); + allCheckbox.setText(translate("allcharacters").replace("%available%", Integer.toString(allChars.size()))); individialSample.setFont(f); updateIndividual(); } diff --git a/src/com/jpexs/decompiler/flash/gui/FontPanel.java b/src/com/jpexs/decompiler/flash/gui/FontPanel.java index c5cc0e0ca..abb56512e 100644 --- a/src/com/jpexs/decompiler/flash/gui/FontPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/FontPanel.java @@ -190,9 +190,9 @@ public class FontPanel extends javax.swing.JPanel { fontIsBoldCheckBox.setSelected(ft.isBold()); fontIsItalicCheckBox.setSelected(ft.isItalic()); - fontDescentLabel.setText(ft.getDescent() == -1 ? translate("value.unknown") : "" + ft.getDescent()); - fontAscentLabel.setText(ft.getAscent() == -1 ? translate("value.unknown") : "" + ft.getAscent()); - fontLeadingLabel.setText(ft.getLeading() == -1 ? translate("value.unknown") : "" + ft.getLeading()); + fontDescentLabel.setText(ft.getDescent() == -1 ? translate("value.unknown") : Integer.toString(ft.getDescent())); + fontAscentLabel.setText(ft.getAscent() == -1 ? translate("value.unknown") : Integer.toString(ft.getAscent())); + fontLeadingLabel.setText(ft.getLeading() == -1 ? translate("value.unknown") : Integer.toString(ft.getLeading())); String chars = ft.getCharacters(swf.tags); fontCharactersTextArea.setText(chars); setAllowSave(false); diff --git a/src/com/jpexs/decompiler/flash/gui/HeaderInfoPanel.java b/src/com/jpexs/decompiler/flash/gui/HeaderInfoPanel.java index bb9c6d38d..782057a7c 100644 --- a/src/com/jpexs/decompiler/flash/gui/HeaderInfoPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/HeaderInfoPanel.java @@ -79,21 +79,21 @@ public class HeaderInfoPanel extends JPanel { compressionLabel.setText(AppStrings.translate("header.compression.none")); break; } - versionLabel.setText("" + swf.version); + versionLabel.setText(Integer.toString(swf.version)); gfxLabel.setText(swf.gfx ? AppStrings.translate("yes") : AppStrings.translate("no")); - fileSizeLabel.setText("" + swf.fileSize); - frameRateLabel.setText("" + swf.frameRate); + fileSizeLabel.setText(Long.toString(swf.fileSize)); + frameRateLabel.setText(Integer.toString(swf.frameRate)); frameCountLabel.setText("" + swf.frameCount); displayRectTwipsLabel.setText(AppStrings.translate("header.displayrect.value.twips") - .replace("%xmin%", "" + swf.displayRect.Xmin) - .replace("%ymin%", "" + swf.displayRect.Ymin) - .replace("%xmax%", "" + swf.displayRect.Xmax) - .replace("%ymax%", "" + swf.displayRect.Ymax)); + .replace("%xmin%", Integer.toString(swf.displayRect.Xmin)) + .replace("%ymin%", Integer.toString(swf.displayRect.Ymin)) + .replace("%xmax%", Integer.toString(swf.displayRect.Xmax)) + .replace("%ymax%", Integer.toString(swf.displayRect.Ymax))); displayRectPixelsLabel.setText(AppStrings.translate("header.displayrect.value.pixels") - .replace("%xmin%", "" + fmtDouble(swf.displayRect.Xmin / SWF.unitDivisor)) - .replace("%ymin%", "" + fmtDouble(swf.displayRect.Ymin / SWF.unitDivisor)) - .replace("%xmax%", "" + fmtDouble(swf.displayRect.Xmax / SWF.unitDivisor)) - .replace("%ymax%", "" + fmtDouble(swf.displayRect.Ymax / SWF.unitDivisor))); + .replace("%xmin%", fmtDouble(swf.displayRect.Xmin / SWF.unitDivisor)) + .replace("%ymin%", fmtDouble(swf.displayRect.Ymin / SWF.unitDivisor)) + .replace("%xmax%", fmtDouble(swf.displayRect.Xmax / SWF.unitDivisor)) + .replace("%ymax%", fmtDouble(swf.displayRect.Ymax / SWF.unitDivisor))); } private String fmtDouble(double d) { diff --git a/src/com/jpexs/decompiler/flash/gui/LicenseUpdater.java b/src/com/jpexs/decompiler/flash/gui/LicenseUpdater.java index dcc7e2a3b..a79d24045 100644 --- a/src/com/jpexs/decompiler/flash/gui/LicenseUpdater.java +++ b/src/com/jpexs/decompiler/flash/gui/LicenseUpdater.java @@ -69,7 +69,7 @@ public class LicenseUpdater { int defaultStartYear = 2010; int defaultFinalYear = 2014; String defaultAuthor = "JPEXS"; - String defaultYearStr = "" + defaultStartYear; + String defaultYearStr = Integer.toString(defaultStartYear); if (defaultFinalYear != defaultStartYear) { defaultYearStr += "-" + defaultFinalYear; } @@ -116,9 +116,9 @@ public class LicenseUpdater { author = mAuthor.group(3).trim(); int startYear = Integer.parseInt(mAuthor.group(1).trim()); if (startYear == defaultFinalYear) { - yearStr = "" + startYear; + yearStr = Integer.toString(startYear); } else { - yearStr = "" + startYear + "-" + defaultFinalYear; + yearStr = Integer.toString(startYear) + "-" + defaultFinalYear; } if (!author.equals(defaultAuthor)) { System.out.println("Detected nodefault author:" + author + " in " + f.getAbsolutePath()); diff --git a/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java b/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java index bf1a4f4ae..ed2793e19 100644 --- a/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java @@ -141,7 +141,7 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener { is = new ReReadableInputStream(new LimitedInputStream(is, limit)); if (swf.fileSize > 0 && swf.version > 0 && !swf.tags.isEmpty() && swf.version < 25/*Needs to be fixed when SWF versions reaches this value*/) { SwfInMemory s = new SwfInMemory(is, swf.version, swf.fileSize, proc); - String p = translate("swfitem").replace("%version%", "" + swf.version).replace("%size%", "" + swf.fileSize); + String p = translate("swfitem").replace("%version%", Integer.toString(swf.version)).replace("%size%", Long.toString(swf.fileSize)); publish(s); swfStreams.add(s); } diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index c1c95ba5b..6008a4830 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -1250,15 +1250,15 @@ public class Main { if (Configuration.checkForUpdatesAuto.get()) { Calendar lastUpdatesCheckDate = Configuration.lastUpdatesCheckDate.get(); if ((lastUpdatesCheckDate == null) || (lastUpdatesCheckDate.getTime().getTime() < Calendar.getInstance().getTime().getTime() - Configuration.checkForUpdatesDelay.get())) { - new SwingWorker(){ + new SwingWorker() { @Override - protected Object doInBackground() throws Exception { + protected Object doInBackground() throws Exception { checkForUpdates(); return null; - } + } }.execute(); System.out.println("finished"); - + } } } @@ -1293,12 +1293,12 @@ public class Main { Socket sock = new Socket("www.free-decompiler.com", 80); OutputStream os = sock.getOutputStream(); String currentLoc = Configuration.locale.get("en"); - os.write(("GET /flash/update.html?action=check¤tVersion=" + URLEncoder.encode(currentVersion, "UTF-8") + os.write(("GET /flash/update.html?action=check¤tVersion=" + URLEncoder.encode(currentVersion, "UTF-8") + "¤tRevision=" + URLEncoder.encode(ApplicationInfo.revision, "UTF-8") - + "¤tVersionMajor=" + URLEncoder.encode(""+ApplicationInfo.version_major, "UTF-8") - + "¤tVersionMinor=" + URLEncoder.encode(""+ApplicationInfo.version_minor, "UTF-8") - + "¤tVersionRelease=" + URLEncoder.encode(""+ApplicationInfo.version_release, "UTF-8") - + "¤tVersionBuild=" + URLEncoder.encode(""+ApplicationInfo.version_build, "UTF-8") + + "¤tVersionMajor=" + URLEncoder.encode("" + ApplicationInfo.version_major, "UTF-8") + + "¤tVersionMinor=" + URLEncoder.encode("" + ApplicationInfo.version_minor, "UTF-8") + + "¤tVersionRelease=" + URLEncoder.encode("" + ApplicationInfo.version_release, "UTF-8") + + "¤tVersionBuild=" + URLEncoder.encode("" + ApplicationInfo.version_build, "UTF-8") + "¤tNightly=" + (ApplicationInfo.nightly ? "1" : "0") + " HTTP/1.1\r\n" + "Host: www.free-decompiler.com\r\n" + "X-Accept-Versions: " + acceptVersions + "\r\n" diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index d8d2390c2..aa5a9e6ae 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -933,7 +933,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec } } } - View.showMessageDialog(null, translate("rename.finished.multiname").replace("%count%", "" + mulCount)); + View.showMessageDialog(null, translate("rename.finished.multiname").replace("%count%", Integer.toString(mulCount))); if (abcPanel != null) { abcPanel.reload(); } @@ -1117,7 +1117,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec public List getSwfs() { return swfs; } - + public SWFList getCurrentSwfList() { SWF swf = getCurrentSwf(); if (swf == null) { @@ -1774,7 +1774,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec try { int cnt = get(); Main.stopWork(); - View.showMessageDialog(null, translate("message.rename.renamed").replace("%count%", "" + cnt)); + View.showMessageDialog(null, translate("message.rename.renamed").replace("%count%", Integer.toString(cnt))); swf.assignClassesToSymbols(); clearCache(); if (abcPanel != null) { @@ -1880,11 +1880,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (tagTree.getModel() != null) { View.refreshTree(tagTree, new TagTreeModel(swfs, Configuration.tagTreeShowEmptyFolders.get())); } - + if (dumpTree.getModel() != null) { View.refreshTree(dumpTree, new DumpTreeModel(swfs)); } - + if (treeItem != null) { setTagTreeSelectedNode(treeItem); } @@ -1927,7 +1927,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec return true; } } catch (TextParseException ex) { - View.showMessageDialog(null, translate("error.text.invalid").replace("%text%", ex.text).replace("%line%", "" + ex.line), translate("error"), JOptionPane.ERROR_MESSAGE); + View.showMessageDialog(null, translate("error.text.invalid").replace("%text%", ex.text).replace("%line%", Long.toString(ex.line)), translate("error"), JOptionPane.ERROR_MESSAGE); } return false; } @@ -2043,7 +2043,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec private File showImportFileChooser(String filter) { String[] filterArray = filter.split("\\|"); - + JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get())); boolean first = true; @@ -2089,10 +2089,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (fc.showOpenDialog(f) == JFileChooser.APPROVE_OPTION) { return fc.getSelectedFile(); } - + return null; } - + private int splitPos = 0; public void showDetail(String card) { @@ -2168,8 +2168,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec private int getCurrentView() { return Configuration.dumpView.get() ? VIEW_DUMP : VIEW_RESOURCES; - } - + } + public void setTreeModel(int view) { switch (view) { case VIEW_DUMP: @@ -2184,7 +2184,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec break; } } - + public boolean showView(int view) { CardLayout cl = (CardLayout) (contentPanel.getLayout()); @@ -2247,7 +2247,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec public void loadFromBinaryTag(final DefineBinaryDataTag binaryDataTag) { loadFromBinaryTag(Arrays.asList(binaryDataTag)); } - + public void loadFromBinaryTag(final List binaryDataTags) { if (Main.loadingDialog == null || Main.loadingDialog.getOwner() == null) { diff --git a/src/com/jpexs/decompiler/flash/gui/SwfInMemory.java b/src/com/jpexs/decompiler/flash/gui/SwfInMemory.java index 377f6d340..b7b6fedce 100644 --- a/src/com/jpexs/decompiler/flash/gui/SwfInMemory.java +++ b/src/com/jpexs/decompiler/flash/gui/SwfInMemory.java @@ -45,7 +45,7 @@ public class SwfInMemory { @Override public String toString() { - String p = translate("swfitem").replace("%version%", "" + version).replace("%size%", "" + fileSize); + String p = translate("swfitem").replace("%version%", Integer.toString(version)).replace("%size%", Long.toString(fileSize)); return p; } } diff --git a/src/com/jpexs/decompiler/flash/gui/View.java b/src/com/jpexs/decompiler/flash/gui/View.java index acca77440..2c5abdb89 100644 --- a/src/com/jpexs/decompiler/flash/gui/View.java +++ b/src/com/jpexs/decompiler/flash/gui/View.java @@ -521,7 +521,7 @@ public class View { expandTreeNodesRecursive(tree, parent, expand); tree.setUI(ui); } - + private static void expandTreeNodesRecursive(JTree tree, TreePath parent, boolean expand) { TreeModel model = tree.getModel(); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index a7a18399b..786bd0de8 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -863,12 +863,12 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se abc.script_info.get(oldIndex).delete(abc, false); decompiledTextArea.gotoLine((int) ex.line); decompiledTextArea.markError(); - View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", "" + ex.line), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); } catch (CompilationException ex) { abc.script_info.get(oldIndex).delete(abc, false); decompiledTextArea.gotoLine((int) ex.line); decompiledTextArea.markError(); - View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", "" + ex.line), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); } catch (IOException | InterruptedException ex) { //ignore } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ConstantsListModel.java b/src/com/jpexs/decompiler/flash/gui/abc/ConstantsListModel.java index 4aac8b71b..e3c055322 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ConstantsListModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ConstantsListModel.java @@ -74,21 +74,21 @@ public class ConstantsListModel implements ListModel { public Object getElementAt(int index) { switch (type) { case TYPE_UINT: - return "" + (index + 1) + ":" + constants.getUInt(index + 1); + return (index + 1) + ":" + constants.getUInt(index + 1); case TYPE_INT: - return "" + (index + 1) + ":" + constants.getInt(index + 1); + return (index + 1) + ":" + constants.getInt(index + 1); case TYPE_DOUBLE: - return "" + (index + 1) + ":" + constants.getDouble(index + 1); + return (index + 1) + ":" + constants.getDouble(index + 1); case TYPE_DECIMAL: - return "" + (index + 1) + ":" + constants.getDecimal(index + 1); + return (index + 1) + ":" + constants.getDecimal(index + 1); case TYPE_STRING: - return "" + (index + 1) + ":" + Helper.escapeString(constants.getString(index + 1)); + return (index + 1) + ":" + Helper.escapeString(constants.getString(index + 1)); case TYPE_NAMESPACE: - return "" + (index + 1) + ":" + constants.getNamespace(index + 1).getNameWithKind(constants); + return (index + 1) + ":" + constants.getNamespace(index + 1).getNameWithKind(constants); case TYPE_NAMESPACESET: - return "" + (index + 1) + ":" + constants.getNamespaceSet(index + 1).toString(constants); + return (index + 1) + ":" + constants.getNamespaceSet(index + 1).toString(constants); case TYPE_MULTINAME: - return "" + (index + 1) + ":" + constants.getMultiname(index + 1).toString(constants, new ArrayList()); + return (index + 1) + ":" + constants.getMultiname(index + 1).toString(constants, new ArrayList()); } return null; } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index 3b4d0efc4..804ebf904 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -159,7 +159,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL return; } for (Highlighting h : traitHighlights) { - if (h.getProperties().index == lastTraitIndex) { + if (h.getProperties().index == lastTraitIndex) { Highlighting h2 = Highlighting.searchOffset(highlights, offset, h.startPos, h.startPos + h.len); if (h2 != null) { ignoreCarret = true; diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DialogMissingSymbolHandler.java b/src/com/jpexs/decompiler/flash/gui/abc/DialogMissingSymbolHandler.java index 5caace182..8d70095af 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DialogMissingSymbolHandler.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DialogMissingSymbolHandler.java @@ -30,16 +30,16 @@ public class DialogMissingSymbolHandler implements MissingSymbolHandler { @Override public boolean missingInt(long value) { - return View.showConfirmDialog(null, AppStrings.translate("message.constant.new.integer").replace("%value%", "" + value), AppStrings.translate("message.constant.new.integer.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; + return View.showConfirmDialog(null, AppStrings.translate("message.constant.new.integer").replace("%value%", Long.toString(value)), AppStrings.translate("message.constant.new.integer.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; } @Override public boolean missingUInt(long value) { - return View.showConfirmDialog(null, AppStrings.translate("message.constant.new.unsignedinteger").replace("%value%", "" + value), AppStrings.translate("message.constant.new.unsignedinteger.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; + return View.showConfirmDialog(null, AppStrings.translate("message.constant.new.unsignedinteger").replace("%value%", Long.toString(value)), AppStrings.translate("message.constant.new.unsignedinteger.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; } @Override public boolean missingDouble(double value) { - return View.showConfirmDialog(null, AppStrings.translate("message.constant.new.double").replace("%value%", "" + value), AppStrings.translate("message.constant.new.double.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; + return View.showConfirmDialog(null, AppStrings.translate("message.constant.new.double").replace("%value%", Double.toString(value)), AppStrings.translate("message.constant.new.double.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; } } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java index 975a36c46..24c15548b 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java @@ -100,7 +100,7 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail { writer.appendNoHilight(" "); writer.hilightSpecial(trait.isConst() ? "const" : "slot", HighlightSpecialType.TRAIT_TYPE); writer.appendNoHilight(" slotid "); - writer.hilightSpecial("" + trait.slot_id, HighlightSpecialType.SLOT_ID); + writer.hilightSpecial(Integer.toString(trait.slot_id), HighlightSpecialType.SLOT_ID); writer.appendNoHilight(" type "); writer.hilightSpecial(abc.constants.multinameToString(trait.type_index), HighlightSpecialType.TRAIT_TYPE_NAME); writer.appendNoHilight(" value "); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/DoubleTableModel.java b/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/DoubleTableModel.java index 3278d2059..0676f0907 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/DoubleTableModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/DoubleTableModel.java @@ -1,155 +1,155 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.gui.abc.tablemodels; - -import com.jpexs.decompiler.flash.abc.ABC; -import javax.swing.event.TableModelListener; -import javax.swing.table.TableModel; - -public class DoubleTableModel implements TableModel { - - private final ABC abc; - private static final String[] columnNames = new String[]{"Index", "Value"}; - private static final Class[] classes = new Class[]{Long.class, String.class}; - - public DoubleTableModel(ABC abc) { - this.abc = abc; - } - - /** - * Returns the number of rows in the model. A JTable uses this - * method to determine how many rows it should display. This method should - * be quick, as it is called frequently during rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - @Override - public int getRowCount() { - if (abc == null) { - return 0; - } - return abc.constants.getDoubleCount(); - } - - /** - * Returns the number of columns in the model. A JTable uses - * this method to determine how many columns it should create and display by - * default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - @Override - public int getColumnCount() { - return 2; - } - - /** - * Returns the name of the column at columnIndex. This is used - * to initialize the table's column header name. Note: this name does not - * need to be unique; two columns in a table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - @Override - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } - - /** - * Returns the most specific superclass for all the cell values in the - * column. This is used by the JTable to set up a default - * renderer and editor for the column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - @Override - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } - - /** - * Returns true if the cell at rowIndex and - * columnIndex is editable. Otherwise, setValueAt - * on the cell will not change the value of that cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } - - /** - * Returns the value for the cell at columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - if (columnIndex == 0) { - return rowIndex; - } else if (Double.isNaN(abc.constants.getDouble(rowIndex))) { - return "NaN"; - } else { - return "" + abc.constants.getDouble(rowIndex); - } - } - - /** - * Sets the value in the cell at columnIndex and - * rowIndex to aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - } - - /** - * Adds a listener to the list that is notified each time a change to the - * data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void addTableModelListener(TableModelListener l) { - } - - /** - * Removes a listener from the list that is notified each time a change to - * the data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void removeTableModelListener(TableModelListener l) { - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui.abc.tablemodels; + +import com.jpexs.decompiler.flash.abc.ABC; +import javax.swing.event.TableModelListener; +import javax.swing.table.TableModel; + +public class DoubleTableModel implements TableModel { + + private final ABC abc; + private static final String[] columnNames = new String[]{"Index", "Value"}; + private static final Class[] classes = new Class[]{Long.class, String.class}; + + public DoubleTableModel(ABC abc) { + this.abc = abc; + } + + /** + * Returns the number of rows in the model. A JTable uses this + * method to determine how many rows it should display. This method should + * be quick, as it is called frequently during rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + @Override + public int getRowCount() { + if (abc == null) { + return 0; + } + return abc.constants.getDoubleCount(); + } + + /** + * Returns the number of columns in the model. A JTable uses + * this method to determine how many columns it should create and display by + * default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + @Override + public int getColumnCount() { + return 2; + } + + /** + * Returns the name of the column at columnIndex. This is used + * to initialize the table's column header name. Note: this name does not + * need to be unique; two columns in a table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + @Override + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } + + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the JTable to set up a default + * renderer and editor for the column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + @Override + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } + + /** + * Returns true if the cell at rowIndex and + * columnIndex is editable. Otherwise, setValueAt + * on the cell will not change the value of that cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } + + /** + * Returns the value for the cell at columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + if (columnIndex == 0) { + return rowIndex; + } else if (Double.isNaN(abc.constants.getDouble(rowIndex))) { + return "NaN"; + } else { + return Double.toString(abc.constants.getDouble(rowIndex)); + } + } + + /** + * Sets the value in the cell at columnIndex and + * rowIndex to aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } + + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void addTableModelListener(TableModelListener l) { + } + + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void removeTableModelListener(TableModelListener l) { + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index f5f544325..887997d4f 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -777,7 +777,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene } catch (ActionParseException ex) { editor.gotoLine((int) ex.line); editor.markError(); - View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", "" + ex.line), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); } break; case ACTION_EDIT_DECOMPILED: @@ -800,9 +800,9 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene } catch (IOException ex) { Logger.getLogger(ActionPanel.class.getName()).log(Level.SEVERE, "IOException during action compiling", ex); } catch (ActionParseException ex) { - View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", "" + ex.line), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); } catch (CompilationException ex) { - View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", "" + ex.line), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); } break; } diff --git a/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java b/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java index 1c721d644..a469dc32c 100644 --- a/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java +++ b/src/com/jpexs/decompiler/flash/gui/debugger/Debugger.java @@ -75,7 +75,7 @@ public class Debugger { @Override public void run() { - String clientName = "" + id; + String clientName = Integer.toString(id); try (InputStream is = s.getInputStream()) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); diff --git a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java index d4be31059..f0290b954 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java +++ b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java @@ -191,11 +191,11 @@ public class PlayerControls extends JPanel implements ActionListener { s %= 60; long h = m / 60; m %= 60; - return "" + (h > 0 ? h + ":" : "") + pad(m) + ":" + pad(s) + "." + pad(ms / 10); + return (h > 0 ? h + ":" : "") + pad(m) + ":" + pad(s) + "." + pad(ms / 10); } private String pad(long t) { - String ret = "" + t; + String ret = Long.toString(t); while (ret.length() < 2) { ret = "0" + ret; } @@ -268,12 +268,12 @@ public class PlayerControls extends JPanel implements ActionListener { private void updateZoom() { double pctzoom = roundZoom(realZoom * 100, 3); - String r = "" + pctzoom; + String r = Double.toString(pctzoom); double zoom = pctzoom / 100.0; if (r.endsWith(".0")) { r = r.substring(0, r.length() - 2); } - percentLabel.setText("" + r + "%"); + percentLabel.setText(r + "%"); display.zoom(zoom); } @@ -346,7 +346,7 @@ public class PlayerControls extends JPanel implements ActionListener { @Override public DataFlavor[] getTransferDataFlavors() { DataFlavor[] flavors = new DataFlavor[1]; - flavors[ 0] = DataFlavor.imageFlavor; + flavors[0] = DataFlavor.imageFlavor; return flavors; } @@ -354,7 +354,7 @@ public class PlayerControls extends JPanel implements ActionListener { public boolean isDataFlavorSupported(DataFlavor flavor) { DataFlavor[] flavors = getTransferDataFlavors(); for (int i = 0; i < flavors.length; i++) { - if (flavor.equals(flavors[ i])) { + if (flavor.equals(flavors[i])) { return true; } } diff --git a/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java b/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java index 37008d389..fa4da0ecb 100644 --- a/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java @@ -97,7 +97,7 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe * @param port Port number */ public void setPort(int port) { - portField.setText("" + port); + portField.setText(Integer.toString(port)); } /** diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java index 818ae5adb..f6964b1db 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java @@ -218,7 +218,7 @@ public class TagTree extends JTree { setBackground(Color.white); setRowHeight(16); setLargeModel(true); - + TreeUI treeUI = new BasicTreeUI() { { setHashColor(Color.gray); diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index afb7c2458..52397137e 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -151,7 +151,7 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener { if (paths == null || paths.length == 0) { return; } - + List li = new ArrayList<>(); for (TreePath treePath : paths) { TreeItem item = (TreeItem) treePath.getLastPathComponent(); @@ -164,15 +164,15 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener { } }); } - + public void update(List items) { if (items.isEmpty()) { return; } - + final List swfs = mainPanel.getSwfs(); - + boolean allSelectedIsTagOrFrame = true; for (TreeItem item : items) { if (!(item instanceof Tag) && !(item instanceof Frame)) { @@ -197,8 +197,8 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener { } else if (item instanceof SWF) { SWF swf = (SWF) item; // Do not allow to close SWF in bundle - if (swf.swfList != null &&swf.swfList.isBundle) { - allSelectedIsSwf = false; + if (swf.swfList != null && swf.swfList.isBundle) { + allSelectedIsSwf = false; } } } @@ -217,12 +217,12 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener { final TreeItem firstItem = items.get(0); boolean singleSelect = items.size() == 1; - + if (singleSelect) { // replace if (firstItem instanceof ImageTag && ((ImageTag) firstItem).importSupported()) { replaceMenuItem.setVisible(true); - } + } if (firstItem instanceof ShapeTag) { replaceMenuItem.setVisible(true); @@ -314,22 +314,22 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener { rawEditMenuItem.setVisible(firstItem instanceof Tag); } } - + if (allSelectedIsBinaryData) { boolean anyInnerSwf = false; for (TreeItem item : items) { DefineBinaryDataTag binary = (DefineBinaryDataTag) item; - + // inner swf is not loaded yet if (binary.innerSwf == null && binary.isSwfData()) { anyInnerSwf = true; } } - + openSWFInsideTagMenuItem.setVisible(anyInnerSwf); } } - + @Override public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { @@ -342,7 +342,7 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener { binaryDatas.add((DefineBinaryDataTag) item); } } - + mainPanel.loadFromBinaryTag(binaryDatas); } break; diff --git a/src/com/jpexs/decompiler/flash/gui/timeline/TimelineDepthPanel.java b/src/com/jpexs/decompiler/flash/gui/timeline/TimelineDepthPanel.java index 24e83d988..dc1804ed1 100644 --- a/src/com/jpexs/decompiler/flash/gui/timeline/TimelineDepthPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/timeline/TimelineDepthPanel.java @@ -1,72 +1,72 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.gui.timeline; - -import com.jpexs.decompiler.flash.timeline.Timeline; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Rectangle; -import javax.swing.JPanel; - -/** - * - * @author JPEXS - */ -public class TimelineDepthPanel extends JPanel { - - private final int maxDepth; - public static final int padding = 5; - public static final float fontSize = 10.0f; - private int scrollOffset = 0; - public static final Color borderColor = Color.lightGray; - public static final Color fontColor = Color.black; - - public TimelineDepthPanel(Timeline timeline) { - maxDepth = timeline.getMaxDepth(); - String maxDepthStr = "" + maxDepth; - setFont(getFont().deriveFont(fontSize)); - int maxDepthW = getFontMetrics(getFont()).stringWidth(maxDepthStr); - Dimension dim = new Dimension(maxDepthW + 2 * padding, Integer.MAX_VALUE); - setSize(dim); - setPreferredSize(dim); - } - - public void scroll(int offset) { - this.scrollOffset = offset; - repaint(); - } - - @Override - protected void paintComponent(Graphics g) { - Rectangle clip = g.getClipBounds(); - int yofs = TimelinePanel.FRAME_HEIGHT - (scrollOffset % TimelinePanel.FRAME_HEIGHT); - int start_d = (scrollOffset + clip.y) / TimelinePanel.FRAME_HEIGHT; - int end_d = (scrollOffset + clip.y + clip.height) / TimelinePanel.FRAME_HEIGHT; - int d_count = end_d - start_d; - g.setColor(TimelinePanel.backgroundColor); - g.fillRect(0, 0, getWidth(), getHeight()); - for (int d = 0; d < d_count; d++) { - g.setColor(borderColor); - g.drawLine(0, yofs + d * TimelinePanel.FRAME_HEIGHT + 1, getWidth(), yofs + d * TimelinePanel.FRAME_HEIGHT + 1); - int curr_d = start_d + d; - g.setColor(fontColor); - g.drawString("" + (start_d + d == 0 ? "a" : curr_d), padding, yofs + d * TimelinePanel.FRAME_HEIGHT - padding); - } - } - -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui.timeline; + +import com.jpexs.decompiler.flash.timeline.Timeline; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Rectangle; +import javax.swing.JPanel; + +/** + * + * @author JPEXS + */ +public class TimelineDepthPanel extends JPanel { + + private final int maxDepth; + public static final int padding = 5; + public static final float fontSize = 10.0f; + private int scrollOffset = 0; + public static final Color borderColor = Color.lightGray; + public static final Color fontColor = Color.black; + + public TimelineDepthPanel(Timeline timeline) { + maxDepth = timeline.getMaxDepth(); + String maxDepthStr = Integer.toString(maxDepth); + setFont(getFont().deriveFont(fontSize)); + int maxDepthW = getFontMetrics(getFont()).stringWidth(maxDepthStr); + Dimension dim = new Dimension(maxDepthW + 2 * padding, Integer.MAX_VALUE); + setSize(dim); + setPreferredSize(dim); + } + + public void scroll(int offset) { + this.scrollOffset = offset; + repaint(); + } + + @Override + protected void paintComponent(Graphics g) { + Rectangle clip = g.getClipBounds(); + int yofs = TimelinePanel.FRAME_HEIGHT - (scrollOffset % TimelinePanel.FRAME_HEIGHT); + int start_d = (scrollOffset + clip.y) / TimelinePanel.FRAME_HEIGHT; + int end_d = (scrollOffset + clip.y + clip.height) / TimelinePanel.FRAME_HEIGHT; + int d_count = end_d - start_d; + g.setColor(TimelinePanel.backgroundColor); + g.fillRect(0, 0, getWidth(), getHeight()); + for (int d = 0; d < d_count; d++) { + g.setColor(borderColor); + g.drawLine(0, yofs + d * TimelinePanel.FRAME_HEIGHT + 1, getWidth(), yofs + d * TimelinePanel.FRAME_HEIGHT + 1); + int curr_d = start_d + d; + g.setColor(fontColor); + g.drawString(start_d + d == 0 ? "a" : Integer.toString(curr_d), padding, yofs + d * TimelinePanel.FRAME_HEIGHT - padding); + } + } + +} diff --git a/src/com/jpexs/decompiler/flash/gui/timeline/TimelineTimePanel.java b/src/com/jpexs/decompiler/flash/gui/timeline/TimelineTimePanel.java index 832dfa0cb..fda706e9e 100644 --- a/src/com/jpexs/decompiler/flash/gui/timeline/TimelineTimePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/timeline/TimelineTimePanel.java @@ -1,126 +1,126 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.gui.timeline; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.ArrayList; -import java.util.List; -import javax.swing.JPanel; - -/** - * - * @author JPEXS - */ -public class TimelineTimePanel extends JPanel implements MouseListener { - - public static final Color borderColor = Color.black; - public static final int lineLength = 3; - public static final int lineTextSpace = 3; - public static final Color fontColor = Color.black; - public float fontSize = 10.0f; - private int scrollOffset = 0; - private int selectedFrame = -1; - private final List listeners = new ArrayList<>(); - - public TimelineTimePanel() { - Dimension dim = new Dimension(Integer.MAX_VALUE, TimelinePanel.FRAME_HEIGHT); - setSize(dim); - setPreferredSize(dim); - addMouseListener(this); - } - - public void addFrameSelectionListener(FrameSelectionListener l) { - listeners.add(l); - } - - public void removeFrameSelectionListener(FrameSelectionListener l) { - listeners.remove(l); - } - - public void frameSelect(int frame) { - if (selectedFrame == frame) { - return; - } - for (FrameSelectionListener l : listeners) { - l.frameSelected(frame, -1); - } - selectedFrame = frame; - repaint(); - } - - public void scroll(int offset) { - this.scrollOffset = offset; - repaint(); - } - - @Override - protected void paintComponent(Graphics g) { - Rectangle clip = g.getClipBounds(); - int start_f = (scrollOffset + clip.x) / TimelinePanel.FRAME_WIDTH; - int end_f = (scrollOffset + clip.x + clip.width) / TimelinePanel.FRAME_WIDTH; - g.setColor(TimelinePanel.backgroundColor); - g.fillRect(0, 0, getWidth(), getHeight()); - g.setColor(borderColor); - int xofs = TimelinePanel.FRAME_WIDTH - scrollOffset % TimelinePanel.FRAME_WIDTH - 1; - for (int f = 0; f <= end_f; f++) { - g.drawLine(xofs + f * TimelinePanel.FRAME_WIDTH + 1, TimelinePanel.FRAME_HEIGHT - 1, xofs + f * TimelinePanel.FRAME_WIDTH + 1, TimelinePanel.FRAME_HEIGHT - lineLength); - } - g.setFont(g.getFont().deriveFont(fontSize)); - for (int f = 0; f <= end_f; f++) { - int cur_f = start_f + f; - if (selectedFrame == cur_f) { - g.setColor(TimelinePanel.selectedColor); - g.fillRect(xofs + (f - 1) * TimelinePanel.FRAME_WIDTH + 1, 0, TimelinePanel.FRAME_WIDTH, TimelinePanel.FRAME_HEIGHT - 1); - g.setColor(TimelinePanel.selectedBorderColor); - g.drawRect(xofs + (f - 1) * TimelinePanel.FRAME_WIDTH + 1, 0, TimelinePanel.FRAME_WIDTH, TimelinePanel.FRAME_HEIGHT - 1); - } - g.setColor(fontColor); - if ((cur_f + 1) % 5 == 0 || cur_f == 0) { - String timeStr = "" + (cur_f + 1); - int w = g.getFontMetrics().stringWidth(timeStr); - g.drawString(timeStr, xofs + (f - 1) * TimelinePanel.FRAME_WIDTH + TimelinePanel.FRAME_WIDTH / 2 - w / 2, TimelinePanel.FRAME_HEIGHT - lineLength - lineTextSpace); - } - } - } - - @Override - public void mouseClicked(MouseEvent e) { - } - - @Override - public void mousePressed(MouseEvent e) { - frameSelect((scrollOffset + e.getX()) / TimelinePanel.FRAME_WIDTH); - } - - @Override - public void mouseReleased(MouseEvent e) { - } - - @Override - public void mouseEntered(MouseEvent e) { - } - - @Override - public void mouseExited(MouseEvent e) { - } - -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui.timeline; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.List; +import javax.swing.JPanel; + +/** + * + * @author JPEXS + */ +public class TimelineTimePanel extends JPanel implements MouseListener { + + public static final Color borderColor = Color.black; + public static final int lineLength = 3; + public static final int lineTextSpace = 3; + public static final Color fontColor = Color.black; + public float fontSize = 10.0f; + private int scrollOffset = 0; + private int selectedFrame = -1; + private final List listeners = new ArrayList<>(); + + public TimelineTimePanel() { + Dimension dim = new Dimension(Integer.MAX_VALUE, TimelinePanel.FRAME_HEIGHT); + setSize(dim); + setPreferredSize(dim); + addMouseListener(this); + } + + public void addFrameSelectionListener(FrameSelectionListener l) { + listeners.add(l); + } + + public void removeFrameSelectionListener(FrameSelectionListener l) { + listeners.remove(l); + } + + public void frameSelect(int frame) { + if (selectedFrame == frame) { + return; + } + for (FrameSelectionListener l : listeners) { + l.frameSelected(frame, -1); + } + selectedFrame = frame; + repaint(); + } + + public void scroll(int offset) { + this.scrollOffset = offset; + repaint(); + } + + @Override + protected void paintComponent(Graphics g) { + Rectangle clip = g.getClipBounds(); + int start_f = (scrollOffset + clip.x) / TimelinePanel.FRAME_WIDTH; + int end_f = (scrollOffset + clip.x + clip.width) / TimelinePanel.FRAME_WIDTH; + g.setColor(TimelinePanel.backgroundColor); + g.fillRect(0, 0, getWidth(), getHeight()); + g.setColor(borderColor); + int xofs = TimelinePanel.FRAME_WIDTH - scrollOffset % TimelinePanel.FRAME_WIDTH - 1; + for (int f = 0; f <= end_f; f++) { + g.drawLine(xofs + f * TimelinePanel.FRAME_WIDTH + 1, TimelinePanel.FRAME_HEIGHT - 1, xofs + f * TimelinePanel.FRAME_WIDTH + 1, TimelinePanel.FRAME_HEIGHT - lineLength); + } + g.setFont(g.getFont().deriveFont(fontSize)); + for (int f = 0; f <= end_f; f++) { + int cur_f = start_f + f; + if (selectedFrame == cur_f) { + g.setColor(TimelinePanel.selectedColor); + g.fillRect(xofs + (f - 1) * TimelinePanel.FRAME_WIDTH + 1, 0, TimelinePanel.FRAME_WIDTH, TimelinePanel.FRAME_HEIGHT - 1); + g.setColor(TimelinePanel.selectedBorderColor); + g.drawRect(xofs + (f - 1) * TimelinePanel.FRAME_WIDTH + 1, 0, TimelinePanel.FRAME_WIDTH, TimelinePanel.FRAME_HEIGHT - 1); + } + g.setColor(fontColor); + if ((cur_f + 1) % 5 == 0 || cur_f == 0) { + String timeStr = Integer.toString(cur_f + 1); + int w = g.getFontMetrics().stringWidth(timeStr); + g.drawString(timeStr, xofs + (f - 1) * TimelinePanel.FRAME_WIDTH + TimelinePanel.FRAME_WIDTH / 2 - w / 2, TimelinePanel.FRAME_HEIGHT - lineLength - lineTextSpace); + } + } + } + + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + frameSelect((scrollOffset + e.getX()) / TimelinePanel.FRAME_WIDTH); + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + +} diff --git a/src/com/jpexs/process/Process.java b/src/com/jpexs/process/Process.java index 52c9afd37..524321484 100644 --- a/src/com/jpexs/process/Process.java +++ b/src/com/jpexs/process/Process.java @@ -1,51 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.process; - -import com.jpexs.helpers.ProgressListener; -import com.jpexs.helpers.Searchable; -import java.awt.image.BufferedImage; -import java.io.InputStream; -import java.util.Map; - -/** - * - * @author JPEXS - */ -public interface Process extends Comparable, Searchable { - - public String getFilePath(); - - public String getFileName(); - - public BufferedImage getIcon(); - - @Override - public String toString(); - - public String getPid(); - - @Override - public Map search(byte[] - - ... data); - - @Override - public Map search(ProgressListener progListener, byte[] - -... data); -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.process; + +import com.jpexs.helpers.ProgressListener; +import com.jpexs.helpers.Searchable; +import java.awt.image.BufferedImage; +import java.io.InputStream; +import java.util.Map; + +/** + * + * @author JPEXS + */ +public interface Process extends Comparable, Searchable { + + public String getFilePath(); + + public String getFileName(); + + public BufferedImage getIcon(); + + @Override + public String toString(); + + public String getPid(); + + @Override + public Map search(byte[]... data); + + @Override + public Map search(ProgressListener progListener, byte[]... data); +} diff --git a/src/com/jpexs/process/win32/Win32Process.java b/src/com/jpexs/process/win32/Win32Process.java index f41d99d47..6be13b2c2 100644 --- a/src/com/jpexs/process/win32/Win32Process.java +++ b/src/com/jpexs/process/win32/Win32Process.java @@ -1,94 +1,92 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.process.win32; - -import com.jpexs.helpers.ProgressListener; -import com.jpexs.process.Process; -import com.sun.jna.platform.win32.WinDef.DWORD; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.InputStream; -import java.util.Map; - -/** - * - * @author JPEXS - */ -public class Win32Process implements Process { - - public String filePath; - public String fileName; - public BufferedImage icon; - public DWORD th32ProcessID; - - @Override - public String getPid() { - return "" + th32ProcessID.longValue(); - } - - public Win32Process(String filePath, String fileName, BufferedImage icon, DWORD th32ProcessID) { - this.filePath = filePath; - this.fileName = fileName; - this.icon = icon; - this.th32ProcessID = th32ProcessID; - } - - @Override - public String toString() { - return new File(filePath).getName() + " (pid " + th32ProcessID.longValue() + ")"; - } - - @Override - public int compareTo(Process o) { - if (!(o instanceof Win32Process)) { - return -1; - } - Win32Process p = (Win32Process) o; - int ret = fileName.toLowerCase().compareTo(p.fileName.toLowerCase()); - if (ret == 0) { - ret = th32ProcessID.intValue() - p.th32ProcessID.intValue(); - } - return ret; - } - - @Override - public String getFilePath() { - return filePath; - } - - @Override - public String getFileName() { - return fileName; - } - - @Override - public BufferedImage getIcon() { - return icon; - } - - @Override - public Map search(byte[] - ... data) { - return search(null, data); - } - - @Override - public Map search(ProgressListener progListener, byte[] - ... data) { - return Win32ProcessTools.findBytesInProcessMemory(progListener, th32ProcessID, data); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.process.win32; + +import com.jpexs.helpers.ProgressListener; +import com.jpexs.process.Process; +import com.sun.jna.platform.win32.WinDef.DWORD; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.InputStream; +import java.util.Map; + +/** + * + * @author JPEXS + */ +public class Win32Process implements Process { + + public String filePath; + public String fileName; + public BufferedImage icon; + public DWORD th32ProcessID; + + @Override + public String getPid() { + return Long.toString(th32ProcessID.longValue()); + } + + public Win32Process(String filePath, String fileName, BufferedImage icon, DWORD th32ProcessID) { + this.filePath = filePath; + this.fileName = fileName; + this.icon = icon; + this.th32ProcessID = th32ProcessID; + } + + @Override + public String toString() { + return new File(filePath).getName() + " (pid " + th32ProcessID.longValue() + ")"; + } + + @Override + public int compareTo(Process o) { + if (!(o instanceof Win32Process)) { + return -1; + } + Win32Process p = (Win32Process) o; + int ret = fileName.toLowerCase().compareTo(p.fileName.toLowerCase()); + if (ret == 0) { + ret = th32ProcessID.intValue() - p.th32ProcessID.intValue(); + } + return ret; + } + + @Override + public String getFilePath() { + return filePath; + } + + @Override + public String getFileName() { + return fileName; + } + + @Override + public BufferedImage getIcon() { + return icon; + } + + @Override + public Map search(byte[]... data) { + return search(null, data); + } + + @Override + public Map search(ProgressListener progListener, byte[]... data) { + return Win32ProcessTools.findBytesInProcessMemory(progListener, th32ProcessID, data); + } +} diff --git a/src/com/jpexs/process/win32/Win32ProcessTools.java b/src/com/jpexs/process/win32/Win32ProcessTools.java index 8dab1da15..adc5425d3 100644 --- a/src/com/jpexs/process/win32/Win32ProcessTools.java +++ b/src/com/jpexs/process/win32/Win32ProcessTools.java @@ -148,7 +148,7 @@ public class Win32ProcessTools extends ProcessTools { Map ret = new HashMap<>(); for (char d = 'A'; d <= 'Z'; d++) { char[] buf = new char[1024]; - int len = Kernel32.INSTANCE.QueryDosDevice("" + d + ":", buf, buf.length).intValue(); + int len = Kernel32.INSTANCE.QueryDosDevice(d + ":", buf, buf.length).intValue(); String tar = new String(buf, 0, len); tar = tar.trim(); if (!"".equals(tar)) { diff --git a/src/com/sun/jna/platform/win32/WinBase.java b/src/com/sun/jna/platform/win32/WinBase.java index be280555c..7d0c05900 100644 --- a/src/com/sun/jna/platform/win32/WinBase.java +++ b/src/com/sun/jna/platform/win32/WinBase.java @@ -1,899 +1,899 @@ -/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ -package com.sun.jna.platform.win32; - -import com.sun.jna.Platform; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.Union; -import com.sun.jna.platform.win32.WinNT.HANDLE; -import com.sun.jna.ptr.ByteByReference; -import com.sun.jna.win32.StdCallLibrary; -import java.util.Arrays; -import java.util.Date; -import java.util.List; - -/** - * Ported from Winbase.h (kernel32.dll/kernel services). Microsoft Windows SDK - * 6.0A. - * - * @author dblock[at]dblock.org - */ -public interface WinBase extends StdCallLibrary, WinDef, BaseTSD { - - /** - * Constant value representing an invalid HANDLE. - */ - HANDLE INVALID_HANDLE_VALUE - = new HANDLE(Pointer.createConstant(Pointer.SIZE == 8 - ? -1 : 0xFFFFFFFFL)); - /** - * Maximum computer name length. The value is 15 on Mac, 31 on everything - * else. - */ - int MAX_COMPUTERNAME_LENGTH = Platform.isMac() ? 15 : 31; - /** - * This logon type is intended for users who will be interactively using the - * computer, such as a user being logged on by a terminal server, remote - * shell, or similar process. This logon type has the additional expense of - * caching logon information for disconnected operations; therefore, it is - * inappropriate for some client/server applications, such as a mail server. - */ - int LOGON32_LOGON_INTERACTIVE = 2; - /** - * This logon type is intended for high performance servers to authenticate - * plaintext passwords. The LogonUser function does not cache credentials - * for this logon type. - */ - int LOGON32_LOGON_NETWORK = 3; - /** - * This logon type is intended for batch servers, where processes may be - * executing on behalf of a user without their direct intervention. This - * type is also for higher performance servers that process many plaintext - * authentication attempts at a time, such as mail or Web servers. The - * LogonUser function does not cache credentials for this logon type. - */ - int LOGON32_LOGON_BATCH = 4; - /** - * Indicates a service-type logon. The account provided must have the - * service privilege enabled. - */ - int LOGON32_LOGON_SERVICE = 5; - /** - * This logon type is for GINA DLLs that log on users who will be - * interactively using the computer. This logon type can generate a unique - * audit record that shows when the workstation was unlocked. - */ - int LOGON32_LOGON_UNLOCK = 7; - /** - * This logon type preserves the name and password in the authentication - * package, which allows the server to make connections to other network - * servers while impersonating the client. A server can accept plaintext - * credentials from a client, call LogonUser, verify that the user can - * access the system across the network, and still communicate with other - * servers. - */ - int LOGON32_LOGON_NETWORK_CLEARTEXT = 8; - /** - * This logon type allows the caller to clone its current token and specify - * new credentials for outbound connections. The new logon session has the - * same local identifier but uses different credentials for other network - * connections. This logon type is supported only by the - * LOGON32_PROVIDER_WINNT50 logon provider. - */ - int LOGON32_LOGON_NEW_CREDENTIALS = 9; - /** - * Use the standard logon provider for the system. The default security - * provider is negotiate, unless you pass NULL for the domain name and the - * user name is not in UPN format. In this case, the default provider is - * NTLM. - */ - int LOGON32_PROVIDER_DEFAULT = 0; - /** - * Use the Windows NT 3.5 logon provider. - */ - int LOGON32_PROVIDER_WINNT35 = 1; - /** - * Use the NTLM logon provider. - */ - int LOGON32_PROVIDER_WINNT40 = 2; - /** - * Use the negotiate logon provider. - */ - int LOGON32_PROVIDER_WINNT50 = 3; - /** - * If this flag is set, a child process created with the bInheritHandles - * parameter of CreateProcess set to TRUE will inherit the object handle. - */ - int HANDLE_FLAG_INHERIT = 1; - /** - * If this flag is set, calling the {@link Kernel32#CloseHandle} function - * will not close the object handle. - */ - int HANDLE_FLAG_PROTECT_FROM_CLOSE = 2; - // STARTUPINFO flags - int STARTF_USESHOWWINDOW = 0x001; - int STARTF_USESIZE = 0x002; - int STARTF_USEPOSITION = 0x004; - int STARTF_USECOUNTCHARS = 0x008; - int STARTF_USEFILLATTRIBUTE = 0x010; - int STARTF_RUNFULLSCREEN = 0x020; - int STARTF_FORCEONFEEDBACK = 0x040; - int STARTF_FORCEOFFFEEDBACK = 0x080; - int STARTF_USESTDHANDLES = 0x100; - // Process Creation flags - int DEBUG_PROCESS = 0x00000001; - int DEBUG_ONLY_THIS_PROCESS = 0x00000002; - int CREATE_SUSPENDED = 0x00000004; - int DETACHED_PROCESS = 0x00000008; - int CREATE_NEW_CONSOLE = 0x00000010; - int CREATE_NEW_PROCESS_GROUP = 0x00000200; - int CREATE_UNICODE_ENVIRONMENT = 0x00000400; - int CREATE_SEPARATE_WOW_VDM = 0x00000800; - int CREATE_SHARED_WOW_VDM = 0x00001000; - int CREATE_FORCEDOS = 0x00002000; - int INHERIT_PARENT_AFFINITY = 0x00010000; - int CREATE_PROTECTED_PROCESS = 0x00040000; - int EXTENDED_STARTUPINFO_PRESENT = 0x00080000; - int CREATE_BREAKAWAY_FROM_JOB = 0x01000000; - int CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000; - int CREATE_DEFAULT_ERROR_MODE = 0x04000000; - int CREATE_NO_WINDOW = 0x08000000; - - /* Invalid return values */ - int INVALID_FILE_SIZE = 0xFFFFFFFF; - int INVALID_SET_FILE_POINTER = 0xFFFFFFFF; - int INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF; - /** - * Return code for a process still active. - */ - int STILL_ACTIVE = WinNT.STATUS_PENDING; - - /** - * The FILETIME structure is a 64-bit value representing the number of - * 100-nanosecond intervals since January 1, 1601 (UTC). Conversion code in - * this class Copyright 2002-2004 Apache Software Foundation. - * - * @author Rainer Klute (klute@rainer-klute.de) for the Apache Software - * Foundation (org.apache.poi.hpsf) - */ - public static class FILETIME extends Structure { - - public int dwLowDateTime; - public int dwHighDateTime; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{"dwLowDateTime", "dwHighDateTime"}); - } - - public static class ByReference extends FILETIME implements Structure.ByReference { - - public ByReference() { - } - - public ByReference(Pointer memory) { - super(memory); - } - } - - public FILETIME(Date date) { - long rawValue = dateToFileTime(date); - dwHighDateTime = (int) (rawValue >> 32 & 0xffffffffL); - dwLowDateTime = (int) (rawValue & 0xffffffffL); - } - - public FILETIME() { - } - - public FILETIME(Pointer memory) { - super(memory); - read(); - } - /** - *

- * The difference between the Windows epoch (1601-01-01 00:00:00) and - * the Unix epoch (1970-01-01 00:00:00) in milliseconds: - * 11644473600000L. (Use your favorite spreadsheet program to verify the - * correctness of this value. By the way, did you notice that you can - * tell from the epochs which operating system is the modern one? - * :-))

- */ - private static final long EPOCH_DIFF = 11644473600000L; - - /** - *

- * Converts a Windows FILETIME into a {@link Date}. The Windows FILETIME - * structure holds a date and time associated with a file. The structure - * identifies a 64-bit integer specifying the number of 100-nanosecond - * intervals which have passed since January 1, 1601. This 64-bit value - * is split into the two double words stored in the structure.

- * - * @param high The higher double word of the FILETIME structure. - * @param low The lower double word of the FILETIME structure. - * @return The Windows FILETIME as a {@link Date}. - */ - public static Date filetimeToDate(final int high, final int low) { - final long filetime = (long) high << 32 | low & 0xffffffffL; - final long ms_since_16010101 = filetime / (1000 * 10); - final long ms_since_19700101 = ms_since_16010101 - EPOCH_DIFF; - return new Date(ms_since_19700101); - } - - /** - *

- * Converts a {@link Date} into a filetime.

- * - * @param date The date to be converted - * @return The filetime - * - * @see #filetimeToDate - */ - public static long dateToFileTime(final Date date) { - final long ms_since_19700101 = date.getTime(); - final long ms_since_16010101 = ms_since_19700101 + EPOCH_DIFF; - return ms_since_16010101 * 1000 * 10; - } - - public Date toDate() { - return filetimeToDate(dwHighDateTime, dwLowDateTime); - } - - public long toLong() { - return toDate().getTime(); - } - - @Override - public String toString() { - return super.toString() + ": " + toDate().toString(); //$NON-NLS-1$ - } - } - /* Local Memory Flags */ - int LMEM_FIXED = 0x0000; - int LMEM_MOVEABLE = 0x0002; - int LMEM_NOCOMPACT = 0x0010; - int LMEM_NODISCARD = 0x0020; - int LMEM_ZEROINIT = 0x0040; - int LMEM_MODIFY = 0x0080; - int LMEM_DISCARDABLE = 0x0F00; - int LMEM_VALID_FLAGS = 0x0F72; - int LMEM_INVALID_HANDLE = 0x8000; - int LHND = (LMEM_MOVEABLE | LMEM_ZEROINIT); - int LPTR = (LMEM_FIXED | LMEM_ZEROINIT); - - /* Flags returned by LocalFlags (in addition to LMEM_DISCARDABLE) */ - int LMEM_DISCARDED = 0x4000; - int LMEM_LOCKCOUNT = 0x00FF; - - /** - * Specifies a date and time, using individual members for the month, day, - * year, weekday, hour, minute, second, and millisecond. The time is either - * in coordinated universal time (UTC) or local time, depending on the - * function that is being called. - * http://msdn.microsoft.com/en-us/library/ms724950(VS.85).aspx - */ - public static class SYSTEMTIME extends Structure { - // The year. The valid values for this member are 1601 through 30827. - - public short wYear; - // The month. The valid values for this member are 1 through 12. - public short wMonth; - // The day of the week. The valid values for this member are 0 through 6. - public short wDayOfWeek; - // The day of the month. The valid values for this member are 1 through 31. - public short wDay; - // The hour. The valid values for this member are 0 through 23. - public short wHour; - // The minute. The valid values for this member are 0 through 59. - public short wMinute; - // The second. The valid values for this member are 0 through 59. - public short wSecond; - // The millisecond. The valid values for this member are 0 through 999. - public short wMilliseconds; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{"wYear", "wMonth", "wDayOfWeek", "wDay", "wHour", "wMinute", "wSecond", "wMilliseconds"}); - } - } - /** - * The lpBuffer parameter is a pointer to a PVOID pointer, and that the - * nSize parameter specifies the minimum number of TCHARs to allocate for an - * output message buffer. The function allocates a buffer large enough to - * hold the formatted message, and places a pointer to the allocated buffer - * at the address specified by lpBuffer. The caller should use the LocalFree - * function to free the buffer when it is no longer needed. - */ - int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100; - /** - * Insert sequences in the message definition are to be ignored and passed - * through to the output buffer unchanged. This flag is useful for fetching - * a message for later formatting. If this flag is set, the Arguments - * parameter is ignored. - */ - int FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200; - /** - * The lpSource parameter is a pointer to a null-terminated message - * definition. The message definition may contain insert sequences, just as - * the message text in a message table resource may. Cannot be used with - * FORMAT_MESSAGE_FROM_HMODULE or FORMAT_MESSAGE_FROM_SYSTEM. - */ - int FORMAT_MESSAGE_FROM_STRING = 0x00000400; - /** - * The lpSource parameter is a module handle containing the message-table - * resource(s) to search. If this lpSource handle is NULL, the current - * process's application image file will be searched. Cannot be used with - * FORMAT_MESSAGE_FROM_STRING. - */ - int FORMAT_MESSAGE_FROM_HMODULE = 0x00000800; - /** - * The function should search the system message-table resource(s) for the - * requested message. If this flag is specified with - * FORMAT_MESSAGE_FROM_HMODULE, the function searches the system message - * table if the message is not found in the module specified by lpSource. - * Cannot be used with FORMAT_MESSAGE_FROM_STRING. If this flag is - * specified, an application can pass the result of the GetLastError - * function to retrieve the message text for a system-defined error. - */ - int FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000; - /** - * The Arguments parameter is not a va_list structure, but is a pointer to - * an array of values that represent the arguments. This flag cannot be used - * with 64-bit argument values. If you are using 64-bit values, you must use - * the va_list structure. - */ - int FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000; - /** - * The drive type cannot be determined. - */ - int DRIVE_UNKNOWN = 0; - /** - * The root path is invalid, for example, no volume is mounted at the path. - */ - int DRIVE_NO_ROOT_DIR = 1; - /** - * The drive is a type that has removable media, for example, a floppy drive - * or removable hard disk. - */ - int DRIVE_REMOVABLE = 2; - /** - * The drive is a type that cannot be removed, for example, a fixed hard - * drive. - */ - int DRIVE_FIXED = 3; - /** - * The drive is a remote (network) drive. - */ - int DRIVE_REMOTE = 4; - /** - * The drive is a CD-ROM drive. - */ - int DRIVE_CDROM = 5; - /** - * The drive is a RAM disk. - */ - int DRIVE_RAMDISK = 6; - - /** - * The OVERLAPPED structure contains information used in asynchronous (or - * overlapped) input and output (I/O). - */ - public static class OVERLAPPED extends Structure { - - public ULONG_PTR Internal; - public ULONG_PTR InternalHigh; - public int Offset; - public int OffsetHigh; - public HANDLE hEvent; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{"Internal", "InternalHigh", "Offset", "OffsetHigh", "hEvent"}); - } - } - int INFINITE = 0xFFFFFFFF; - - /** - * Contains information about the current computer system. This includes the - * architecture and type of the processor, the number of processors in the - * system, the page size, and other such information. - */ - public static class SYSTEM_INFO extends Structure { - - /** - * Unnamed inner structure. - */ - public static class PI extends Structure { - - public static class ByReference extends PI implements Structure.ByReference { - } - /** - * System's processor architecture. This value can be one of the - * following values: - * - * PROCESSOR_ARCHITECTURE_UNKNOWN PROCESSOR_ARCHITECTURE_INTEL - * PROCESSOR_ARCHITECTURE_IA64 PROCESSOR_ARCHITECTURE_AMD64 - */ - public WORD wProcessorArchitecture; - /** - * Reserved for future use. - */ - public WORD wReserved; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{"wProcessorArchitecture", "wReserved"}); - } - } - - /** - * Unnamed inner union. - */ - public static class UNION extends Union { - - public static class ByReference extends UNION implements Structure.ByReference { - } - /** - * An obsolete member that is retained for compatibility with - * Windows NT 3.5 and earlier. New applications should use the - * wProcessorArchitecture branch of the union. Windows Me/98/95: The - * system always sets this member to zero, the value defined for - * PROCESSOR_ARCHITECTURE_INTEL. - */ - public DWORD dwOemID; - /** - * Processor architecture (unnamed struct). - */ - public PI pi; - } - /** - * Processor architecture (unnamed union). - */ - public UNION processorArchitecture; - /** - * Page size and the granularity of page protection and commitment. - */ - public DWORD dwPageSize; - /** - * Pointer to the lowest memory address accessible to applications and - * dynamic-link libraries (DLLs). - */ - public Pointer lpMinimumApplicationAddress; - /** - * Pointer to the highest memory address accessible to applications and - * DLLs. - */ - public Pointer lpMaximumApplicationAddress; - /** - * Mask representing the set of processors configured into the system. - * Bit 0 is processor 0; bit 31 is processor 31. - */ - public DWORD_PTR dwActiveProcessorMask; - /** - * Number of processors in the system. - */ - public DWORD dwNumberOfProcessors; - /** - * An obsolete member that is retained for compatibility with Windows NT - * 3.5 and Windows Me/98/95. Use the wProcessorArchitecture, - * wProcessorLevel, and wProcessorRevision members to determine the type - * of processor. PROCESSOR_INTEL_386 PROCESSOR_INTEL_486 - * PROCESSOR_INTEL_PENTIUM - */ - public DWORD dwProcessorType; - /** - * Granularity for the starting address at which virtual memory can be - * allocated. - */ - public DWORD dwAllocationGranularity; - /** - * System's architecture-dependent processor level. It should be used - * only for display purposes. To determine the feature set of a - * processor, use the IsProcessorFeaturePresent function. If - * wProcessorArchitecture is PROCESSOR_ARCHITECTURE_INTEL, - * wProcessorLevel is defined by the CPU vendor. If - * wProcessorArchitecture is PROCESSOR_ARCHITECTURE_IA64, - * wProcessorLevel is set to 1. - */ - public WORD wProcessorLevel; - /** - * Architecture-dependent processor revision. - */ - public WORD wProcessorRevision; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{"processorArchitecture", "dwPageSize", "lpMinimumApplicationAddress", "lpMaximumApplicationAddress", "dwActiveProcessorMask", "dwNumberOfProcessors", "dwProcessorType", "dwAllocationGranularity", "wProcessorLevel", "wProcessorRevision"}); - } - } - - /** - * Contains information about the current state of both physical and virtual - * memory, including extended memory. The GlobalMemoryStatusEx function - * stores information in this structure. - */ - public static class MEMORYSTATUSEX extends Structure { - - /** - * The size of the structure, in bytes. - */ - public DWORD dwLength; - /** - * A number between 0 and 100 that specifies the approximate percentage - * of physical memory that is in use (0 indicates no memory use and 100 - * indicates full memory use). - */ - public DWORD dwMemoryLoad; - /** - * The amount of actual physical memory, in bytes. - */ - public DWORDLONG ullTotalPhys; - /** - * The amount of physical memory currently available, in bytes. This is - * the amount of physical memory that can be immediately reused without - * having to write its contents to disk first. It is the sum of the size - * of the standby, free, and zero lists. - */ - public DWORDLONG ullAvailPhys; - /** - * The current committed memory limit for the system or the current - * process, whichever is smaller, in bytes. - */ - public DWORDLONG ullTotalPageFile; - /** - * The maximum amount of memory the current process can commit, in - * bytes. This value is equal to or smaller than the system-wide - * available commit value. - */ - public DWORDLONG ullAvailPageFile; - /** - * The size of the user-mode portion of the virtual address space of the - * calling process, in bytes. - */ - public DWORDLONG ullTotalVirtual; - /** - * The amount of unreserved and uncommitted memory currently in the - * user-mode portion of the virtual address space of the calling - * process, in bytes. - */ - public DWORDLONG ullAvailVirtual; - /** - * Reserved. This value is always 0. - */ - public DWORDLONG ullAvailExtendedVirtual; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{"dwLength", "dwMemoryLoad", "ullTotalPhys", "ullAvailPhys", "ullTotalPageFile", "ullAvailPageFile", "ullTotalVirtual", "ullAvailVirtual", "ullAvailExtendedVirtual"}); - } - - public MEMORYSTATUSEX() { - dwLength = new DWORD(size()); - } - }; - - /** - * The SECURITY_ATTRIBUTES structure contains the security descriptor for an - * object and specifies whether the handle retrieved by specifying this - * structure is inheritable. This structure provides security settings for - * objects created by various functions, such as Kernel32#CreateFile, - * Kernel32#CreatePipe, or Advapi32#RegCreateKeyEx. - */ - public static class SECURITY_ATTRIBUTES extends Structure { - - /** - * The size of the structure, in bytes. - */ - public DWORD dwLength; - /** - * A pointer to a SECURITY_DESCRIPTOR structure that controls access to - * the object. - */ - public Pointer lpSecurityDescriptor; - /** - * A Boolean value that specifies whether the returned handle is - * inherited when a new process is created - */ - public boolean bInheritHandle; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{"dwLength", "lpSecurityDescriptor", "bInheritHandle"}); - } - - public SECURITY_ATTRIBUTES() { - dwLength = new DWORD(size()); - } - } - - /** - * Specifies the window station, desktop, standard handles, and appearance - * of the main window for a process at creation time. - */ - public static class STARTUPINFO extends Structure { - - /** - * The size of the structure, in bytes. - */ - public DWORD cb; - /** - * Reserved; must be NULL. - */ - public String lpReserved; - /** - * The name of the desktop, or the name of both the desktop and window - * station for this process. A backslash in the string indicates that - * the string includes both the desktop and window station names. For - * more information, see Thread Connection to a Desktop. - */ - public String lpDesktop; - /** - * For console processes, this is the title displayed in the title bar - * if a new console window is created. If NULL, the name of the - * executable file is used as the window title instead. This parameter - * must be NULL for GUI or console processes that do not create a new - * console window. - */ - public String lpTitle; - /** - * If dwFlags specifies STARTF_USEPOSITION, this member is the x offset - * of the upper left corner of a window if a new window is created, in - * pixels. Otherwise, this member is ignored. - * - * The offset is from the upper left corner of the screen. For GUI - * processes, the specified position is used the first time the new - * process calls CreateWindow to create an overlapped window if the x - * parameter of CreateWindow is CW_USEDEFAULT. - */ - public DWORD dwX; - /** - * If dwFlags specifies STARTF_USEPOSITION, this member is the y offset - * of the upper left corner of a window if a new window is created, in - * pixels. Otherwise, this member is ignored. - * - * The offset is from the upper left corner of the screen. For GUI - * processes, the specified position is used the first time the new - * process calls CreateWindow to create an overlapped window if the y - * parameter of CreateWindow is CW_USEDEFAULT. - */ - public DWORD dwY; - /** - * If dwFlags specifies STARTF_USESIZE, this member is the width of the - * window if a new window is created, in pixels. Otherwise, this member - * is ignored. - * - * For GUI processes, this is used only the first time the new process - * calls CreateWindow to create an overlapped window if the nWidth - * parameter of CreateWindow is CW_USEDEFAULT. - */ - public DWORD dwXSize; - /** - * If dwFlags specifies STARTF_USESIZE, this member is the height of the - * window if a new window is created, in pixels. Otherwise, this member - * is ignored. - * - * For GUI processes, this is used only the first time the new process - * calls CreateWindow to create an overlapped window if the nHeight - * parameter of CreateWindow is CW_USEDEFAULT. - */ - public DWORD dwYSize; - /** - * If dwFlags specifies STARTF_USECOUNTCHARS, if a new console window is - * created in a console process, this member specifies the screen buffer - * width, in character columns. Otherwise, this member is ignored. - */ - public DWORD dwXCountChars; - /** - * If dwFlags specifies STARTF_USECOUNTCHARS, if a new console window is - * created in a console process, this member specifies the screen buffer - * height, in character rows. Otherwise, this member is ignored. - */ - public DWORD dwYCountChars; - /** - * If dwFlags specifies STARTF_USEFILLATTRIBUTE, this member is the - * initial text and background colors if a new console window is created - * in a console application. Otherwise, this member is ignored. - * - * This value can be any combination of the following values: - * FOREGROUND_BLUE, FOREGROUND_GREEN, FOREGROUND_RED, - * FOREGROUND_INTENSITY, BACKGROUND_BLUE, BACKGROUND_GREEN, - * BACKGROUND_RED, and BACKGROUND_INTENSITY. For example, the following - * combination of values produces red text on a white background: - * - * FOREGROUND_RED| BACKGROUND_RED| BACKGROUND_GREEN| BACKGROUND_BLUE - */ - public DWORD dwFillAttribute; - /** - * A bit field that determines whether certain STARTUPINFO members are - * used when the process creates a window. - */ - public int dwFlags; - /** - * If dwFlags specifies STARTF_USESHOWWINDOW, this member can be any of - * the values that can be specified in the nCmdShow parameter for the - * ShowWindow function, except for SW_SHOWDEFAULT. Otherwise, this - * member is ignored. - * - * For GUI processes, the first time ShowWindow is called, its nCmdShow - * parameter is ignored wShowWindow specifies the default value. In - * subsequent calls to ShowWindow, the wShowWindow member is used if the - * nCmdShow parameter of ShowWindow is set to SW_SHOWDEFAULT. - */ - public WORD wShowWindow; - /** - * Reserved for use by the C Run-time; must be zero. - */ - public WORD cbReserved2; - /** - * Reserved for use by the C Run-time; must be NULL. - */ - public ByteByReference lpReserved2; - /** - * If dwFlags specifies STARTF_USESTDHANDLES, this member is the - * standard input handle for the process. If STARTF_USESTDHANDLES is not - * specified, the default for standard input is the keyboard buffer. - * - * If dwFlags specifies STARTF_USEHOTKEY, this member specifies a hotkey - * value that is sent as the wParam parameter of a WM_SETHOTKEY message - * to the first eligible top-level window created by the application - * that owns the process. If the window is created with the WS_POPUP - * window style, it is not eligible unless the WS_EX_APPWINDOW extended - * window style is also set. For more information, see CreateWindowEx. - * - * Otherwise, this member is ignored. - */ - public HANDLE hStdInput; - /** - * If dwFlags specifies STARTF_USESTDHANDLES, this member is the - * standard output handle for the process. Otherwise, this member is - * ignored and the default for standard output is the console window's - * buffer. - */ - public HANDLE hStdOutput; - /** - * If dwFlags specifies STARTF_USESTDHANDLES, this member is the - * standard error handle for the process. Otherwise, this member is - * ignored and the default for standard error is the console window's - * buffer. - */ - public HANDLE hStdError; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{"cb", "lpReserved", "lpDesktop", "lpTitle", "dwX", "dwY", "dwXSize", "dwYSize", "dwXCountChars", "dwYCountChars", "dwFillAttribute", "dwFlags", "wShowWindow", "cbReserved2", "lpReserved2", "hStdInput", "hStdOutput", "hStdError"}); - } - - public STARTUPINFO() { - cb = new DWORD(size()); - } - } - - /** - * Contains information about a newly created process and its primary - * thread. It is used with the CreateProcess, CreateProcessAsUser, - * CreateProcessWithLogonW, or CreateProcessWithTokenW function. - */ - public static class PROCESS_INFORMATION extends Structure { - - /** - * A handle to the newly created process. The handle is used to specify - * the process in all functions that perform operations on the process - * object. - */ - public HANDLE hProcess; - /** - * A handle to the primary thread of the newly created process. The - * handle is used to specify the thread in all functions that perform - * operations on the thread object. - */ - public HANDLE hThread; - /** - * A value that can be used to identify a process. The value is valid - * from the time the process is created until all handles to the process - * are closed and the process object is freed; at this point, the - * identifier may be reused. - */ - public DWORD dwProcessId; - /** - * A value that can be used to identify a thread. The value is valid - * from the time the thread is created until all handles to the thread - * are closed and the thread object is freed; at this point, the - * identifier may be reused. - */ - public DWORD dwThreadId; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{"hProcess", "hThread", "dwProcessId", "dwThreadId"}); - } - - public static class ByReference extends PROCESS_INFORMATION implements Structure.ByReference { - - public ByReference() { - } - - public ByReference(Pointer memory) { - super(memory); - } - } - - public PROCESS_INFORMATION() { - } - - public PROCESS_INFORMATION(Pointer memory) { - super(memory); - read(); - } - } - /** - * If the file is to be moved to a different volume, the function simulates - * the move by using the CopyFile and DeleteFile functions. - * - * This value cannot be used with MOVEFILE_DELAY_UNTIL_REBOOT. - */ - int MOVEFILE_COPY_ALLOWED = 0x2; - /** - * Reserved for future use. - */ - int MOVEFILE_CREATE_HARDLINK = 0x10; - /** - * The system does not move the file until the operating system is - * restarted. The system moves the file immediately after AUTOCHK is - * executed, but before creating any paging files. Consequently, this - * parameter enables the function to delete paging files from previous - * startups. - * - * This value can be used only if the process is in the context of a user - * who belongs to the administrators group or the LocalSystem account. - * - * This value cannot be used with MOVEFILE_COPY_ALLOWED. - * - * Windows Server 2003 and Windows XP: For information about special - * situations where this functionality can fail, and a suggested workaround - * solution, see Files are not exchanged when Windows Server 2003 restarts - * if you use the MoveFileEx function to schedule a replacement for some - * files in the Help and Support Knowledge Base. - * - * Windows 2000: If you specify the MOVEFILE_DELAY_UNTIL_REBOOT flag for - * dwFlags, you cannot also prepend the file name that is specified by - * lpExistingFileName with "\\?". - */ - int MOVEFILE_DELAY_UNTIL_REBOOT = 0x4; - /** - * The function fails if the source file is a link source, but the file - * cannot be tracked after the move. This situation can occur if the - * destination is a volume formatted with the FAT file system. - */ - int MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20; - /** - * If a file named lpNewFileName exists, the function replaces its contents - * with the contents of the lpExistingFileName file, provided that security - * requirements regarding access control lists (ACLs) are met. For more - * information, see the Remarks section of this topic. - * - * This value cannot be used if lpNewFileName or lpExistingFileName names a - * directory. - */ - int MOVEFILE_REPLACE_EXISTING = 0x1; - /** - * The function does not return until the file is actually moved on the - * disk. - * - * Setting this value guarantees that a move performed as a copy and delete - * operation is flushed to disk before the function returns. The flush - * occurs at the end of the copy operation. - * - * This value has no effect if MOVEFILE_DELAY_UNTIL_REBOOT is set. - */ - int MOVEFILE_WRITE_THROUGH = 0x8; -} +/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package com.sun.jna.platform.win32; + +import com.sun.jna.Platform; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.Union; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.ptr.ByteByReference; +import com.sun.jna.win32.StdCallLibrary; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +/** + * Ported from Winbase.h (kernel32.dll/kernel services). Microsoft Windows SDK + * 6.0A. + * + * @author dblock[at]dblock.org + */ +public interface WinBase extends StdCallLibrary, WinDef, BaseTSD { + + /** + * Constant value representing an invalid HANDLE. + */ + HANDLE INVALID_HANDLE_VALUE + = new HANDLE(Pointer.createConstant(Pointer.SIZE == 8 + ? -1 : 0xFFFFFFFFL)); + /** + * Maximum computer name length. The value is 15 on Mac, 31 on everything + * else. + */ + int MAX_COMPUTERNAME_LENGTH = Platform.isMac() ? 15 : 31; + /** + * This logon type is intended for users who will be interactively using the + * computer, such as a user being logged on by a terminal server, remote + * shell, or similar process. This logon type has the additional expense of + * caching logon information for disconnected operations; therefore, it is + * inappropriate for some client/server applications, such as a mail server. + */ + int LOGON32_LOGON_INTERACTIVE = 2; + /** + * This logon type is intended for high performance servers to authenticate + * plaintext passwords. The LogonUser function does not cache credentials + * for this logon type. + */ + int LOGON32_LOGON_NETWORK = 3; + /** + * This logon type is intended for batch servers, where processes may be + * executing on behalf of a user without their direct intervention. This + * type is also for higher performance servers that process many plaintext + * authentication attempts at a time, such as mail or Web servers. The + * LogonUser function does not cache credentials for this logon type. + */ + int LOGON32_LOGON_BATCH = 4; + /** + * Indicates a service-type logon. The account provided must have the + * service privilege enabled. + */ + int LOGON32_LOGON_SERVICE = 5; + /** + * This logon type is for GINA DLLs that log on users who will be + * interactively using the computer. This logon type can generate a unique + * audit record that shows when the workstation was unlocked. + */ + int LOGON32_LOGON_UNLOCK = 7; + /** + * This logon type preserves the name and password in the authentication + * package, which allows the server to make connections to other network + * servers while impersonating the client. A server can accept plaintext + * credentials from a client, call LogonUser, verify that the user can + * access the system across the network, and still communicate with other + * servers. + */ + int LOGON32_LOGON_NETWORK_CLEARTEXT = 8; + /** + * This logon type allows the caller to clone its current token and specify + * new credentials for outbound connections. The new logon session has the + * same local identifier but uses different credentials for other network + * connections. This logon type is supported only by the + * LOGON32_PROVIDER_WINNT50 logon provider. + */ + int LOGON32_LOGON_NEW_CREDENTIALS = 9; + /** + * Use the standard logon provider for the system. The default security + * provider is negotiate, unless you pass NULL for the domain name and the + * user name is not in UPN format. In this case, the default provider is + * NTLM. + */ + int LOGON32_PROVIDER_DEFAULT = 0; + /** + * Use the Windows NT 3.5 logon provider. + */ + int LOGON32_PROVIDER_WINNT35 = 1; + /** + * Use the NTLM logon provider. + */ + int LOGON32_PROVIDER_WINNT40 = 2; + /** + * Use the negotiate logon provider. + */ + int LOGON32_PROVIDER_WINNT50 = 3; + /** + * If this flag is set, a child process created with the bInheritHandles + * parameter of CreateProcess set to TRUE will inherit the object handle. + */ + int HANDLE_FLAG_INHERIT = 1; + /** + * If this flag is set, calling the {@link Kernel32#CloseHandle} function + * will not close the object handle. + */ + int HANDLE_FLAG_PROTECT_FROM_CLOSE = 2; + // STARTUPINFO flags + int STARTF_USESHOWWINDOW = 0x001; + int STARTF_USESIZE = 0x002; + int STARTF_USEPOSITION = 0x004; + int STARTF_USECOUNTCHARS = 0x008; + int STARTF_USEFILLATTRIBUTE = 0x010; + int STARTF_RUNFULLSCREEN = 0x020; + int STARTF_FORCEONFEEDBACK = 0x040; + int STARTF_FORCEOFFFEEDBACK = 0x080; + int STARTF_USESTDHANDLES = 0x100; + // Process Creation flags + int DEBUG_PROCESS = 0x00000001; + int DEBUG_ONLY_THIS_PROCESS = 0x00000002; + int CREATE_SUSPENDED = 0x00000004; + int DETACHED_PROCESS = 0x00000008; + int CREATE_NEW_CONSOLE = 0x00000010; + int CREATE_NEW_PROCESS_GROUP = 0x00000200; + int CREATE_UNICODE_ENVIRONMENT = 0x00000400; + int CREATE_SEPARATE_WOW_VDM = 0x00000800; + int CREATE_SHARED_WOW_VDM = 0x00001000; + int CREATE_FORCEDOS = 0x00002000; + int INHERIT_PARENT_AFFINITY = 0x00010000; + int CREATE_PROTECTED_PROCESS = 0x00040000; + int EXTENDED_STARTUPINFO_PRESENT = 0x00080000; + int CREATE_BREAKAWAY_FROM_JOB = 0x01000000; + int CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000; + int CREATE_DEFAULT_ERROR_MODE = 0x04000000; + int CREATE_NO_WINDOW = 0x08000000; + + /* Invalid return values */ + int INVALID_FILE_SIZE = 0xFFFFFFFF; + int INVALID_SET_FILE_POINTER = 0xFFFFFFFF; + int INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF; + /** + * Return code for a process still active. + */ + int STILL_ACTIVE = WinNT.STATUS_PENDING; + + /** + * The FILETIME structure is a 64-bit value representing the number of + * 100-nanosecond intervals since January 1, 1601 (UTC). Conversion code in + * this class Copyright 2002-2004 Apache Software Foundation. + * + * @author Rainer Klute (klute@rainer-klute.de) for the Apache Software + * Foundation (org.apache.poi.hpsf) + */ + public static class FILETIME extends Structure { + + public int dwLowDateTime; + public int dwHighDateTime; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"dwLowDateTime", "dwHighDateTime"}); + } + + public static class ByReference extends FILETIME implements Structure.ByReference { + + public ByReference() { + } + + public ByReference(Pointer memory) { + super(memory); + } + } + + public FILETIME(Date date) { + long rawValue = dateToFileTime(date); + dwHighDateTime = (int) (rawValue >> 32 & 0xffffffffL); + dwLowDateTime = (int) (rawValue & 0xffffffffL); + } + + public FILETIME() { + } + + public FILETIME(Pointer memory) { + super(memory); + read(); + } + /** + *

+ * The difference between the Windows epoch (1601-01-01 00:00:00) and + * the Unix epoch (1970-01-01 00:00:00) in milliseconds: + * 11644473600000L. (Use your favorite spreadsheet program to verify the + * correctness of this value. By the way, did you notice that you can + * tell from the epochs which operating system is the modern one? + * :-))

+ */ + private static final long EPOCH_DIFF = 11644473600000L; + + /** + *

+ * Converts a Windows FILETIME into a {@link Date}. The Windows FILETIME + * structure holds a date and time associated with a file. The structure + * identifies a 64-bit integer specifying the number of 100-nanosecond + * intervals which have passed since January 1, 1601. This 64-bit value + * is split into the two double words stored in the structure.

+ * + * @param high The higher double word of the FILETIME structure. + * @param low The lower double word of the FILETIME structure. + * @return The Windows FILETIME as a {@link Date}. + */ + public static Date filetimeToDate(final int high, final int low) { + final long filetime = (long) high << 32 | low & 0xffffffffL; + final long ms_since_16010101 = filetime / (1000 * 10); + final long ms_since_19700101 = ms_since_16010101 - EPOCH_DIFF; + return new Date(ms_since_19700101); + } + + /** + *

+ * Converts a {@link Date} into a filetime.

+ * + * @param date The date to be converted + * @return The filetime + * + * @see #filetimeToDate + */ + public static long dateToFileTime(final Date date) { + final long ms_since_19700101 = date.getTime(); + final long ms_since_16010101 = ms_since_19700101 + EPOCH_DIFF; + return ms_since_16010101 * 1000 * 10; + } + + public Date toDate() { + return filetimeToDate(dwHighDateTime, dwLowDateTime); + } + + public long toLong() { + return toDate().getTime(); + } + + @Override + public String toString() { + return super.toString() + ": " + toDate().toString(); //$NON-NLS-1$ + } + } + /* Local Memory Flags */ + int LMEM_FIXED = 0x0000; + int LMEM_MOVEABLE = 0x0002; + int LMEM_NOCOMPACT = 0x0010; + int LMEM_NODISCARD = 0x0020; + int LMEM_ZEROINIT = 0x0040; + int LMEM_MODIFY = 0x0080; + int LMEM_DISCARDABLE = 0x0F00; + int LMEM_VALID_FLAGS = 0x0F72; + int LMEM_INVALID_HANDLE = 0x8000; + int LHND = (LMEM_MOVEABLE | LMEM_ZEROINIT); + int LPTR = (LMEM_FIXED | LMEM_ZEROINIT); + + /* Flags returned by LocalFlags (in addition to LMEM_DISCARDABLE) */ + int LMEM_DISCARDED = 0x4000; + int LMEM_LOCKCOUNT = 0x00FF; + + /** + * Specifies a date and time, using individual members for the month, day, + * year, weekday, hour, minute, second, and millisecond. The time is either + * in coordinated universal time (UTC) or local time, depending on the + * function that is being called. + * http://msdn.microsoft.com/en-us/library/ms724950(VS.85).aspx + */ + public static class SYSTEMTIME extends Structure { + // The year. The valid values for this member are 1601 through 30827. + + public short wYear; + // The month. The valid values for this member are 1 through 12. + public short wMonth; + // The day of the week. The valid values for this member are 0 through 6. + public short wDayOfWeek; + // The day of the month. The valid values for this member are 1 through 31. + public short wDay; + // The hour. The valid values for this member are 0 through 23. + public short wHour; + // The minute. The valid values for this member are 0 through 59. + public short wMinute; + // The second. The valid values for this member are 0 through 59. + public short wSecond; + // The millisecond. The valid values for this member are 0 through 999. + public short wMilliseconds; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"wYear", "wMonth", "wDayOfWeek", "wDay", "wHour", "wMinute", "wSecond", "wMilliseconds"}); + } + } + /** + * The lpBuffer parameter is a pointer to a PVOID pointer, and that the + * nSize parameter specifies the minimum number of TCHARs to allocate for an + * output message buffer. The function allocates a buffer large enough to + * hold the formatted message, and places a pointer to the allocated buffer + * at the address specified by lpBuffer. The caller should use the LocalFree + * function to free the buffer when it is no longer needed. + */ + int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100; + /** + * Insert sequences in the message definition are to be ignored and passed + * through to the output buffer unchanged. This flag is useful for fetching + * a message for later formatting. If this flag is set, the Arguments + * parameter is ignored. + */ + int FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200; + /** + * The lpSource parameter is a pointer to a null-terminated message + * definition. The message definition may contain insert sequences, just as + * the message text in a message table resource may. Cannot be used with + * FORMAT_MESSAGE_FROM_HMODULE or FORMAT_MESSAGE_FROM_SYSTEM. + */ + int FORMAT_MESSAGE_FROM_STRING = 0x00000400; + /** + * The lpSource parameter is a module handle containing the message-table + * resource(s) to search. If this lpSource handle is NULL, the current + * process's application image file will be searched. Cannot be used with + * FORMAT_MESSAGE_FROM_STRING. + */ + int FORMAT_MESSAGE_FROM_HMODULE = 0x00000800; + /** + * The function should search the system message-table resource(s) for the + * requested message. If this flag is specified with + * FORMAT_MESSAGE_FROM_HMODULE, the function searches the system message + * table if the message is not found in the module specified by lpSource. + * Cannot be used with FORMAT_MESSAGE_FROM_STRING. If this flag is + * specified, an application can pass the result of the GetLastError + * function to retrieve the message text for a system-defined error. + */ + int FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000; + /** + * The Arguments parameter is not a va_list structure, but is a pointer to + * an array of values that represent the arguments. This flag cannot be used + * with 64-bit argument values. If you are using 64-bit values, you must use + * the va_list structure. + */ + int FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000; + /** + * The drive type cannot be determined. + */ + int DRIVE_UNKNOWN = 0; + /** + * The root path is invalid, for example, no volume is mounted at the path. + */ + int DRIVE_NO_ROOT_DIR = 1; + /** + * The drive is a type that has removable media, for example, a floppy drive + * or removable hard disk. + */ + int DRIVE_REMOVABLE = 2; + /** + * The drive is a type that cannot be removed, for example, a fixed hard + * drive. + */ + int DRIVE_FIXED = 3; + /** + * The drive is a remote (network) drive. + */ + int DRIVE_REMOTE = 4; + /** + * The drive is a CD-ROM drive. + */ + int DRIVE_CDROM = 5; + /** + * The drive is a RAM disk. + */ + int DRIVE_RAMDISK = 6; + + /** + * The OVERLAPPED structure contains information used in asynchronous (or + * overlapped) input and output (I/O). + */ + public static class OVERLAPPED extends Structure { + + public ULONG_PTR Internal; + public ULONG_PTR InternalHigh; + public int Offset; + public int OffsetHigh; + public HANDLE hEvent; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"Internal", "InternalHigh", "Offset", "OffsetHigh", "hEvent"}); + } + } + int INFINITE = 0xFFFFFFFF; + + /** + * Contains information about the current computer system. This includes the + * architecture and type of the processor, the number of processors in the + * system, the page size, and other such information. + */ + public static class SYSTEM_INFO extends Structure { + + /** + * Unnamed inner structure. + */ + public static class PI extends Structure { + + public static class ByReference extends PI implements Structure.ByReference { + } + /** + * System's processor architecture. This value can be one of the + * following values: + * + * PROCESSOR_ARCHITECTURE_UNKNOWN PROCESSOR_ARCHITECTURE_INTEL + * PROCESSOR_ARCHITECTURE_IA64 PROCESSOR_ARCHITECTURE_AMD64 + */ + public WORD wProcessorArchitecture; + /** + * Reserved for future use. + */ + public WORD wReserved; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"wProcessorArchitecture", "wReserved"}); + } + } + + /** + * Unnamed inner union. + */ + public static class UNION extends Union { + + public static class ByReference extends UNION implements Structure.ByReference { + } + /** + * An obsolete member that is retained for compatibility with + * Windows NT 3.5 and earlier. New applications should use the + * wProcessorArchitecture branch of the union. Windows Me/98/95: The + * system always sets this member to zero, the value defined for + * PROCESSOR_ARCHITECTURE_INTEL. + */ + public DWORD dwOemID; + /** + * Processor architecture (unnamed struct). + */ + public PI pi; + } + /** + * Processor architecture (unnamed union). + */ + public UNION processorArchitecture; + /** + * Page size and the granularity of page protection and commitment. + */ + public DWORD dwPageSize; + /** + * Pointer to the lowest memory address accessible to applications and + * dynamic-link libraries (DLLs). + */ + public Pointer lpMinimumApplicationAddress; + /** + * Pointer to the highest memory address accessible to applications and + * DLLs. + */ + public Pointer lpMaximumApplicationAddress; + /** + * Mask representing the set of processors configured into the system. + * Bit 0 is processor 0; bit 31 is processor 31. + */ + public DWORD_PTR dwActiveProcessorMask; + /** + * Number of processors in the system. + */ + public DWORD dwNumberOfProcessors; + /** + * An obsolete member that is retained for compatibility with Windows NT + * 3.5 and Windows Me/98/95. Use the wProcessorArchitecture, + * wProcessorLevel, and wProcessorRevision members to determine the type + * of processor. PROCESSOR_INTEL_386 PROCESSOR_INTEL_486 + * PROCESSOR_INTEL_PENTIUM + */ + public DWORD dwProcessorType; + /** + * Granularity for the starting address at which virtual memory can be + * allocated. + */ + public DWORD dwAllocationGranularity; + /** + * System's architecture-dependent processor level. It should be used + * only for display purposes. To determine the feature set of a + * processor, use the IsProcessorFeaturePresent function. If + * wProcessorArchitecture is PROCESSOR_ARCHITECTURE_INTEL, + * wProcessorLevel is defined by the CPU vendor. If + * wProcessorArchitecture is PROCESSOR_ARCHITECTURE_IA64, + * wProcessorLevel is set to 1. + */ + public WORD wProcessorLevel; + /** + * Architecture-dependent processor revision. + */ + public WORD wProcessorRevision; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"processorArchitecture", "dwPageSize", "lpMinimumApplicationAddress", "lpMaximumApplicationAddress", "dwActiveProcessorMask", "dwNumberOfProcessors", "dwProcessorType", "dwAllocationGranularity", "wProcessorLevel", "wProcessorRevision"}); + } + } + + /** + * Contains information about the current state of both physical and virtual + * memory, including extended memory. The GlobalMemoryStatusEx function + * stores information in this structure. + */ + public static class MEMORYSTATUSEX extends Structure { + + /** + * The size of the structure, in bytes. + */ + public DWORD dwLength; + /** + * A number between 0 and 100 that specifies the approximate percentage + * of physical memory that is in use (0 indicates no memory use and 100 + * indicates full memory use). + */ + public DWORD dwMemoryLoad; + /** + * The amount of actual physical memory, in bytes. + */ + public DWORDLONG ullTotalPhys; + /** + * The amount of physical memory currently available, in bytes. This is + * the amount of physical memory that can be immediately reused without + * having to write its contents to disk first. It is the sum of the size + * of the standby, free, and zero lists. + */ + public DWORDLONG ullAvailPhys; + /** + * The current committed memory limit for the system or the current + * process, whichever is smaller, in bytes. + */ + public DWORDLONG ullTotalPageFile; + /** + * The maximum amount of memory the current process can commit, in + * bytes. This value is equal to or smaller than the system-wide + * available commit value. + */ + public DWORDLONG ullAvailPageFile; + /** + * The size of the user-mode portion of the virtual address space of the + * calling process, in bytes. + */ + public DWORDLONG ullTotalVirtual; + /** + * The amount of unreserved and uncommitted memory currently in the + * user-mode portion of the virtual address space of the calling + * process, in bytes. + */ + public DWORDLONG ullAvailVirtual; + /** + * Reserved. This value is always 0. + */ + public DWORDLONG ullAvailExtendedVirtual; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"dwLength", "dwMemoryLoad", "ullTotalPhys", "ullAvailPhys", "ullTotalPageFile", "ullAvailPageFile", "ullTotalVirtual", "ullAvailVirtual", "ullAvailExtendedVirtual"}); + } + + public MEMORYSTATUSEX() { + dwLength = new DWORD(size()); + } + }; + + /** + * The SECURITY_ATTRIBUTES structure contains the security descriptor for an + * object and specifies whether the handle retrieved by specifying this + * structure is inheritable. This structure provides security settings for + * objects created by various functions, such as Kernel32#CreateFile, + * Kernel32#CreatePipe, or Advapi32#RegCreateKeyEx. + */ + public static class SECURITY_ATTRIBUTES extends Structure { + + /** + * The size of the structure, in bytes. + */ + public DWORD dwLength; + /** + * A pointer to a SECURITY_DESCRIPTOR structure that controls access to + * the object. + */ + public Pointer lpSecurityDescriptor; + /** + * A Boolean value that specifies whether the returned handle is + * inherited when a new process is created + */ + public boolean bInheritHandle; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"dwLength", "lpSecurityDescriptor", "bInheritHandle"}); + } + + public SECURITY_ATTRIBUTES() { + dwLength = new DWORD(size()); + } + } + + /** + * Specifies the window station, desktop, standard handles, and appearance + * of the main window for a process at creation time. + */ + public static class STARTUPINFO extends Structure { + + /** + * The size of the structure, in bytes. + */ + public DWORD cb; + /** + * Reserved; must be NULL. + */ + public String lpReserved; + /** + * The name of the desktop, or the name of both the desktop and window + * station for this process. A backslash in the string indicates that + * the string includes both the desktop and window station names. For + * more information, see Thread Connection to a Desktop. + */ + public String lpDesktop; + /** + * For console processes, this is the title displayed in the title bar + * if a new console window is created. If NULL, the name of the + * executable file is used as the window title instead. This parameter + * must be NULL for GUI or console processes that do not create a new + * console window. + */ + public String lpTitle; + /** + * If dwFlags specifies STARTF_USEPOSITION, this member is the x offset + * of the upper left corner of a window if a new window is created, in + * pixels. Otherwise, this member is ignored. + * + * The offset is from the upper left corner of the screen. For GUI + * processes, the specified position is used the first time the new + * process calls CreateWindow to create an overlapped window if the x + * parameter of CreateWindow is CW_USEDEFAULT. + */ + public DWORD dwX; + /** + * If dwFlags specifies STARTF_USEPOSITION, this member is the y offset + * of the upper left corner of a window if a new window is created, in + * pixels. Otherwise, this member is ignored. + * + * The offset is from the upper left corner of the screen. For GUI + * processes, the specified position is used the first time the new + * process calls CreateWindow to create an overlapped window if the y + * parameter of CreateWindow is CW_USEDEFAULT. + */ + public DWORD dwY; + /** + * If dwFlags specifies STARTF_USESIZE, this member is the width of the + * window if a new window is created, in pixels. Otherwise, this member + * is ignored. + * + * For GUI processes, this is used only the first time the new process + * calls CreateWindow to create an overlapped window if the nWidth + * parameter of CreateWindow is CW_USEDEFAULT. + */ + public DWORD dwXSize; + /** + * If dwFlags specifies STARTF_USESIZE, this member is the height of the + * window if a new window is created, in pixels. Otherwise, this member + * is ignored. + * + * For GUI processes, this is used only the first time the new process + * calls CreateWindow to create an overlapped window if the nHeight + * parameter of CreateWindow is CW_USEDEFAULT. + */ + public DWORD dwYSize; + /** + * If dwFlags specifies STARTF_USECOUNTCHARS, if a new console window is + * created in a console process, this member specifies the screen buffer + * width, in character columns. Otherwise, this member is ignored. + */ + public DWORD dwXCountChars; + /** + * If dwFlags specifies STARTF_USECOUNTCHARS, if a new console window is + * created in a console process, this member specifies the screen buffer + * height, in character rows. Otherwise, this member is ignored. + */ + public DWORD dwYCountChars; + /** + * If dwFlags specifies STARTF_USEFILLATTRIBUTE, this member is the + * initial text and background colors if a new console window is created + * in a console application. Otherwise, this member is ignored. + * + * This value can be any combination of the following values: + * FOREGROUND_BLUE, FOREGROUND_GREEN, FOREGROUND_RED, + * FOREGROUND_INTENSITY, BACKGROUND_BLUE, BACKGROUND_GREEN, + * BACKGROUND_RED, and BACKGROUND_INTENSITY. For example, the following + * combination of values produces red text on a white background: + * + * FOREGROUND_RED| BACKGROUND_RED| BACKGROUND_GREEN| BACKGROUND_BLUE + */ + public DWORD dwFillAttribute; + /** + * A bit field that determines whether certain STARTUPINFO members are + * used when the process creates a window. + */ + public int dwFlags; + /** + * If dwFlags specifies STARTF_USESHOWWINDOW, this member can be any of + * the values that can be specified in the nCmdShow parameter for the + * ShowWindow function, except for SW_SHOWDEFAULT. Otherwise, this + * member is ignored. + * + * For GUI processes, the first time ShowWindow is called, its nCmdShow + * parameter is ignored wShowWindow specifies the default value. In + * subsequent calls to ShowWindow, the wShowWindow member is used if the + * nCmdShow parameter of ShowWindow is set to SW_SHOWDEFAULT. + */ + public WORD wShowWindow; + /** + * Reserved for use by the C Run-time; must be zero. + */ + public WORD cbReserved2; + /** + * Reserved for use by the C Run-time; must be NULL. + */ + public ByteByReference lpReserved2; + /** + * If dwFlags specifies STARTF_USESTDHANDLES, this member is the + * standard input handle for the process. If STARTF_USESTDHANDLES is not + * specified, the default for standard input is the keyboard buffer. + * + * If dwFlags specifies STARTF_USEHOTKEY, this member specifies a hotkey + * value that is sent as the wParam parameter of a WM_SETHOTKEY message + * to the first eligible top-level window created by the application + * that owns the process. If the window is created with the WS_POPUP + * window style, it is not eligible unless the WS_EX_APPWINDOW extended + * window style is also set. For more information, see CreateWindowEx. + * + * Otherwise, this member is ignored. + */ + public HANDLE hStdInput; + /** + * If dwFlags specifies STARTF_USESTDHANDLES, this member is the + * standard output handle for the process. Otherwise, this member is + * ignored and the default for standard output is the console window's + * buffer. + */ + public HANDLE hStdOutput; + /** + * If dwFlags specifies STARTF_USESTDHANDLES, this member is the + * standard error handle for the process. Otherwise, this member is + * ignored and the default for standard error is the console window's + * buffer. + */ + public HANDLE hStdError; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"cb", "lpReserved", "lpDesktop", "lpTitle", "dwX", "dwY", "dwXSize", "dwYSize", "dwXCountChars", "dwYCountChars", "dwFillAttribute", "dwFlags", "wShowWindow", "cbReserved2", "lpReserved2", "hStdInput", "hStdOutput", "hStdError"}); + } + + public STARTUPINFO() { + cb = new DWORD(size()); + } + } + + /** + * Contains information about a newly created process and its primary + * thread. It is used with the CreateProcess, CreateProcessAsUser, + * CreateProcessWithLogonW, or CreateProcessWithTokenW function. + */ + public static class PROCESS_INFORMATION extends Structure { + + /** + * A handle to the newly created process. The handle is used to specify + * the process in all functions that perform operations on the process + * object. + */ + public HANDLE hProcess; + /** + * A handle to the primary thread of the newly created process. The + * handle is used to specify the thread in all functions that perform + * operations on the thread object. + */ + public HANDLE hThread; + /** + * A value that can be used to identify a process. The value is valid + * from the time the process is created until all handles to the process + * are closed and the process object is freed; at this point, the + * identifier may be reused. + */ + public DWORD dwProcessId; + /** + * A value that can be used to identify a thread. The value is valid + * from the time the thread is created until all handles to the thread + * are closed and the thread object is freed; at this point, the + * identifier may be reused. + */ + public DWORD dwThreadId; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"hProcess", "hThread", "dwProcessId", "dwThreadId"}); + } + + public static class ByReference extends PROCESS_INFORMATION implements Structure.ByReference { + + public ByReference() { + } + + public ByReference(Pointer memory) { + super(memory); + } + } + + public PROCESS_INFORMATION() { + } + + public PROCESS_INFORMATION(Pointer memory) { + super(memory); + read(); + } + } + /** + * If the file is to be moved to a different volume, the function simulates + * the move by using the CopyFile and DeleteFile functions. + * + * This value cannot be used with MOVEFILE_DELAY_UNTIL_REBOOT. + */ + int MOVEFILE_COPY_ALLOWED = 0x2; + /** + * Reserved for future use. + */ + int MOVEFILE_CREATE_HARDLINK = 0x10; + /** + * The system does not move the file until the operating system is + * restarted. The system moves the file immediately after AUTOCHK is + * executed, but before creating any paging files. Consequently, this + * parameter enables the function to delete paging files from previous + * startups. + * + * This value can be used only if the process is in the context of a user + * who belongs to the administrators group or the LocalSystem account. + * + * This value cannot be used with MOVEFILE_COPY_ALLOWED. + * + * Windows Server 2003 and Windows XP: For information about special + * situations where this functionality can fail, and a suggested workaround + * solution, see Files are not exchanged when Windows Server 2003 restarts + * if you use the MoveFileEx function to schedule a replacement for some + * files in the Help and Support Knowledge Base. + * + * Windows 2000: If you specify the MOVEFILE_DELAY_UNTIL_REBOOT flag for + * dwFlags, you cannot also prepend the file name that is specified by + * lpExistingFileName with "\\?". + */ + int MOVEFILE_DELAY_UNTIL_REBOOT = 0x4; + /** + * The function fails if the source file is a link source, but the file + * cannot be tracked after the move. This situation can occur if the + * destination is a volume formatted with the FAT file system. + */ + int MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20; + /** + * If a file named lpNewFileName exists, the function replaces its contents + * with the contents of the lpExistingFileName file, provided that security + * requirements regarding access control lists (ACLs) are met. For more + * information, see the Remarks section of this topic. + * + * This value cannot be used if lpNewFileName or lpExistingFileName names a + * directory. + */ + int MOVEFILE_REPLACE_EXISTING = 0x1; + /** + * The function does not return until the file is actually moved on the + * disk. + * + * Setting this value guarantees that a move performed as a copy and delete + * operation is flushed to disk before the function returns. The flush + * occurs at the end of the copy operation. + * + * This value has no effect if MOVEFILE_DELAY_UNTIL_REBOOT is set. + */ + int MOVEFILE_WRITE_THROUGH = 0x8; +}