diff --git a/trunk/build.xml b/trunk/build.xml index 8c09f4605..ec98e3e32 100644 --- a/trunk/build.xml +++ b/trunk/build.xml @@ -46,6 +46,6 @@ - + diff --git a/trunk/nbproject/ide-file-targets.xml b/trunk/nbproject/ide-file-targets.xml index 318f76e3e..54731cb3b 100644 --- a/trunk/nbproject/ide-file-targets.xml +++ b/trunk/nbproject/ide-file-targets.xml @@ -13,8 +13,7 @@ - - + diff --git a/trunk/src/com/jpexs/decompiler/flash/Configuration.java b/trunk/src/com/jpexs/decompiler/flash/Configuration.java index 443a128b5..cfd9a92ec 100644 --- a/trunk/src/com/jpexs/decompiler/flash/Configuration.java +++ b/trunk/src/com/jpexs/decompiler/flash/Configuration.java @@ -58,7 +58,8 @@ public class Configuration { */ public static final int DECOMPILATION_TIMEOUT = 30 * 60; /** - * Decompilation timeout for a single method in AS3 or single action in AS1/2 in seconds + * Decompilation timeout for a single method in AS3 or single action in + * AS1/2 in seconds */ public static final int DECOMPILATION_TIMEOUT_SINGLE_METHOD = 5; //using parameter names in decompiling may cause problems because official programs like Flash CS 5.5 inserts wrong parameter names indices diff --git a/trunk/src/com/jpexs/decompiler/flash/ConsoleAbortRetryIgnoreHandler.java b/trunk/src/com/jpexs/decompiler/flash/ConsoleAbortRetryIgnoreHandler.java index f95dd8c91..223d7e358 100644 --- a/trunk/src/com/jpexs/decompiler/flash/ConsoleAbortRetryIgnoreHandler.java +++ b/trunk/src/com/jpexs/decompiler/flash/ConsoleAbortRetryIgnoreHandler.java @@ -23,6 +23,7 @@ import java.util.Scanner; * @author JPEXS */ public class ConsoleAbortRetryIgnoreHandler implements AbortRetryIgnoreHandler { + int errorCount = 0; int errorMode; int retryCount; @@ -31,19 +32,18 @@ public class ConsoleAbortRetryIgnoreHandler implements AbortRetryIgnoreHandler { this.errorMode = errorMode; this.retryCount = retryCount; } - + @Override public int handle(Throwable thrown) { - if (errorMode != AbortRetryIgnoreHandler.UNDEFINED){ + if (errorMode != AbortRetryIgnoreHandler.UNDEFINED) { int result = errorMode; - + if (errorMode == AbortRetryIgnoreHandler.RETRY && errorCount < retryCount) { errorCount++; - } - else { + } else { result = AbortRetryIgnoreHandler.IGNORE; } - + return result; } Scanner sc = new Scanner(System.in); diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index f05d115e3..68fd053d1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -53,8 +53,6 @@ import com.jpexs.decompiler.flash.flv.AUDIODATA; import com.jpexs.decompiler.flash.flv.FLVOutputStream; import com.jpexs.decompiler.flash.flv.FLVTAG; import com.jpexs.decompiler.flash.flv.VIDEODATA; -import com.jpexs.decompiler.flash.helpers.Cache; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; @@ -98,6 +96,9 @@ import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Cache; +import com.jpexs.helpers.Helper; +import com.jpexs.helpers.ProgressListener; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Graphics2D; @@ -281,7 +282,20 @@ public class SWF { * @param parallelRead Use parallel threads? * @throws IOException */ - public SWF(InputStream is, PercentListener listener, boolean parallelRead) throws IOException { + public SWF(InputStream is, ProgressListener listener, boolean parallelRead) throws IOException { + this(is, listener, parallelRead, false); + } + + /** + * Construct SWF from stream + * + * @param is Stream to read SWF from + * @param listener + * @param parallelRead Use parallel threads? + * @param checkOnly Check only file validity + * @throws IOException + */ + public SWF(InputStream is, ProgressListener listener, boolean parallelRead, boolean checkOnly) throws IOException { byte hdr[] = new byte[3]; is.read(hdr); String shdr = new String(hdr, "utf-8"); @@ -305,6 +319,14 @@ public class SWF { if (sis.read(lzmaProperties, 0, propertiesSize) != propertiesSize) { throw new IOException("LZMA:input .lzma file is too short"); } + long dictionarySize = 0; + for (int i = 0; i < 4; i++) { + dictionarySize += ((int) (lzmaProperties[1 + i]) & 0xFF) << (i * 8); + if (dictionarySize > Runtime.getRuntime().freeMemory()) { + throw new IOException("LZMA: Too large dictionary size"); + } + } + SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); if (!decoder.SetDecoderProperties(lzmaProperties)) { throw new IOException("LZMA:Incorrect stream properties"); @@ -328,10 +350,15 @@ public class SWF { sis.readUI8(); //tmpFirstByetOfFrameRate frameRate = sis.readUI8(); frameCount = sis.readUI16(); - tags = sis.readTagList(this, 0, parallelRead, true); - assignExportNamesToSymbols(); - assignClassesToSymbols(); - findFileAttributes(); + if (checkOnly) { + return; + } + tags = sis.readTagList(this, 0, parallelRead, true, !checkOnly); + if (!checkOnly) { + assignExportNamesToSymbols(); + assignClassesToSymbols(); + findFileAttributes(); + } } private void findFileAttributes() { diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index 43661c261..90959a4f5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -16,7 +16,6 @@ */ package com.jpexs.decompiler.flash; -import com.jpexs.decompiler.graph.NotCompileTimeItem; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionGraphSource; import com.jpexs.decompiler.flash.action.StoreTypeAction; @@ -32,7 +31,6 @@ import com.jpexs.decompiler.flash.action.swf6.*; import com.jpexs.decompiler.flash.action.swf7.*; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.ecma.Null; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.tags.*; import com.jpexs.decompiler.flash.types.*; @@ -54,6 +52,10 @@ import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.NotCompileTimeItem; +import com.jpexs.helpers.Helper; +import com.jpexs.helpers.ProgressListener; +import com.jpexs.helpers.ReReadableInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -86,7 +88,7 @@ public class SWFInputStream extends InputStream { private long pos; private int version; private static final Logger log = Logger.getLogger(SWFInputStream.class.getName()); - private List listeners = new ArrayList<>(); + private List listeners = new ArrayList<>(); private long percentMax; private List buffered = new ArrayList<>(); private ByteArrayOutputStream buffer; @@ -119,11 +121,11 @@ public class SWFInputStream extends InputStream { return null; } - public void addPercentListener(PercentListener listener) { + public void addPercentListener(ProgressListener listener) { listeners.add(listener); } - public void removePercentListener(PercentListener listener) { + public void removePercentListener(ProgressListener listener) { int index = listeners.indexOf(listener); if (index > -1) { listeners.remove(index); @@ -206,8 +208,8 @@ public class SWFInputStream extends InputStream { if (percentMax > 0) { int percent = (int) (pos * 100 / percentMax); if (lastPercent != percent) { - for (PercentListener pl : listeners) { - pl.percent(percent); + for (ProgressListener pl : listeners) { + pl.progress(percent); } lastPercent = percent; } @@ -1216,6 +1218,22 @@ public class SWFInputStream extends InputStream { * @throws IOException */ public List readTagList(SWF swf, int level, boolean parallel, boolean skipUnusualTags) throws IOException { + return readTagList(swf, level, parallel, skipUnusualTags, true); + } + + /** + * Reads list of tags from the stream. Reading ends with End tag(=0) or end + * of the stream. Optinally can skip AS1/2 tags when file is AS3 + * + * @param swf + * @param level + * @param parallel + * @param skipUnusualTags + * @param parseTags + * @return List of tags + * @throws IOException + */ + public List readTagList(SWF swf, int level, boolean parallel, boolean skipUnusualTags, boolean parseTags) throws IOException { ExecutorService executor = null; if (parallel) { executor = Executors.newFixedThreadPool(20); @@ -1228,7 +1246,7 @@ public class SWFInputStream extends InputStream { while (true) { long pos = getPos(); try { - tag = readTag(swf, level, pos, !parallel, parallel, skipUnusualTags); + tag = readTag(swf, level, pos, parseTags && !parallel, parallel, skipUnusualTags); } catch (EndOfStreamException ex) { tag = null; } @@ -1286,6 +1304,9 @@ public class SWFInputStream extends InputStream { } } + if (!parseTags) { + doParse = false; + } if (doParse) { if (parallel) { diff --git a/trunk/src/com/jpexs/decompiler/flash/TagNode.java b/trunk/src/com/jpexs/decompiler/flash/TagNode.java index b59e97c22..9ccec497b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/TagNode.java +++ b/trunk/src/com/jpexs/decompiler/flash/TagNode.java @@ -17,7 +17,6 @@ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag; @@ -48,6 +47,7 @@ import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.Container; import com.jpexs.decompiler.flash.tags.base.Exportable; import com.jpexs.decompiler.graph.Graph; +import com.jpexs.helpers.Helper; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -236,7 +236,7 @@ public class TagNode { public static int getTagCountRecursive(List nodeList) { int count = 0; - + for (TagNode node : nodeList) { if (node.subItems.isEmpty()) { if ((node.tag instanceof ASMSource) && (node.export)) { @@ -247,10 +247,10 @@ public class TagNode { } } - + return count; } - + public static List exportNodeAS(List allTags, AbortRetryIgnoreHandler handler, List nodeList, String outdir, boolean isPcode) throws IOException { AtomicInteger cnt = new AtomicInteger(1); int totalCount = TagNode.getTagCountRecursive(nodeList); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/NotSameException.java b/trunk/src/com/jpexs/decompiler/flash/abc/NotSameException.java index d4243e92e..6dd68e6a6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/NotSameException.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/NotSameException.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.abc; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Helper; public class NotSameException extends RuntimeException { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index fe6db15fc..2dc7cd4ee 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -18,8 +18,8 @@ package com.jpexs.decompiler.flash.abc; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.helpers.Helper; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 665a1a2ec..9d3bd5181 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -16,7 +16,6 @@ */ package com.jpexs.decompiler.flash.abc.avm2; -import com.jpexs.decompiler.graph.NotCompileTimeItem; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.ABCInputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; @@ -70,13 +69,14 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.ecma.EcmaScript; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphPart; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.NotCompileTimeItem; import com.jpexs.decompiler.graph.model.ScriptEndItem; +import com.jpexs.helpers.Helper; import java.io.*; import java.util.*; import java.util.logging.Level; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index aafb1e509..99a718cc1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -27,10 +27,10 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ThrowIns; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSource; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.Serializable; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java index 64f40609f..c32de811c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java @@ -23,8 +23,8 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.UnparsedAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; import java.util.Stack; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java index 9af074755..a89fc05b8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java @@ -22,9 +22,9 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; -import com.jpexs.decompiler.graph.NotCompileTimeItem; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.NotCompileTimeItem; import java.util.HashMap; import java.util.List; import java.util.Stack; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java index e8c127af5..24aca5300 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java @@ -18,10 +18,10 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ApplyTypeAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ApplyTypeAVM2Item.java index bf84f7a29..1d6ddda56 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ApplyTypeAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ApplyTypeAVM2Item.java @@ -18,8 +18,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallMethodAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallMethodAVM2Item.java index a386b997f..f579e5d50 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallMethodAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallMethodAVM2Item.java @@ -18,8 +18,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallStaticAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallStaticAVM2Item.java index 8ab2a4947..7269077e5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallStaticAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallStaticAVM2Item.java @@ -18,8 +18,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DefaultXMLNamespace.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DefaultXMLNamespace.java index af61fc47c..b95a3eb2c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DefaultXMLNamespace.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DefaultXMLNamespace.java @@ -18,8 +18,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXAttrAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXAttrAVM2Item.java index 0f6c8dd64..a8d81f292 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXAttrAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXAttrAVM2Item.java @@ -18,8 +18,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXElemAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXElemAVM2Item.java index a1bfa5f0e..9b64cfbe9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXElemAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXElemAVM2Item.java @@ -18,8 +18,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FilteredCheckAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FilteredCheckAVM2Item.java index 0a09d5998..c03cc9069 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FilteredCheckAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FilteredCheckAVM2Item.java @@ -18,8 +18,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/HasNextAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/HasNextAVM2Item.java index c2015f6ba..c3c79c268 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/HasNextAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/HasNextAVM2Item.java @@ -18,8 +18,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java index a9a164dfc..065e81d78 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java @@ -20,8 +20,8 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.model.clauses.FilterAVM2Item; import com.jpexs.decompiler.flash.ecma.Undefined; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextNameAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextNameAVM2Item.java index 0ec598bb0..6140053d7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextNameAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextNameAVM2Item.java @@ -18,8 +18,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextValueAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextValueAVM2Item.java index 9545b5b86..7469f0341 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextValueAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextValueAVM2Item.java @@ -18,8 +18,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostDecrementAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostDecrementAVM2Item.java index 45ad2b406..bb126fc34 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostDecrementAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostDecrementAVM2Item.java @@ -19,8 +19,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.model.clauses.AssignmentAVM2Item; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostIncrementAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostIncrementAVM2Item.java index af66b2c56..601e2503d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostIncrementAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostIncrementAVM2Item.java @@ -19,8 +19,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.model.clauses.AssignmentAVM2Item; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java index 04aab5ccb..5dce8d35e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java index ee2df4fc3..1592210e1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java @@ -22,8 +22,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.SetSlotAVM2Item; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java index 128c499b2..1d6f75ebe 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java @@ -19,10 +19,10 @@ package com.jpexs.decompiler.flash.abc.avm2.model.clauses; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.abc.types.ABCException; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.Block; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.model.ContinueItem; +import com.jpexs.helpers.Helper; import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/ABCException.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/ABCException.java index 428a7ec21..9ea8c3410 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/ABCException.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/ABCException.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.abc.types; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.ConvertException; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Helper; import java.io.Serializable; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java index 20bb62117..8fef86d6e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.abc.types; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.types.traits.Traits; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Helper; import java.util.ArrayList; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/MetadataInfo.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/MetadataInfo.java index 2c9c7763c..2ba1f4cc9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MetadataInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MetadataInfo.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.abc.types; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Helper; public class MetadataInfo { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index 698e165b6..8ee104f32 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -23,10 +23,10 @@ import com.jpexs.decompiler.flash.abc.avm2.CodeStats; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; @@ -137,7 +137,7 @@ public class MethodBody implements Cloneable, Serializable { } return s; } - + public String toSource(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], Stack scopeStack, boolean isStaticInitializer, boolean hilight, List fullyQualifiedNames, Traits initTraits) { AVM2Code deobfuscated = null; MethodBody b = (MethodBody) Helper.deepCopy(this); @@ -160,7 +160,7 @@ public class MethodBody implements Cloneable, Serializable { if (hilight) { s = Highlighting.hilighMethod(s, this.method_info); } - + return s; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java index 93db53998..4019763cf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.abc.types; import com.jpexs.decompiler.flash.Configuration; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java index edb7e2bd0..922581cf5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.abc.types; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Helper; public class ValueKind { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java index 1d4c1ceb9..550a4044b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java @@ -19,8 +19,8 @@ package com.jpexs.decompiler.flash.abc.types.traits; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.helpers.Helper; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index 295fa848c..cdc1cd86a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -31,10 +31,10 @@ import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.abc.types.NamespaceSet; import com.jpexs.decompiler.flash.abc.types.ScriptInfo; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.io.UnsupportedEncodingException; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java index 5c5f88b3e..5ce64588a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java @@ -18,9 +18,9 @@ package com.jpexs.decompiler.flash.abc.types.traits; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.List; import java.util.Stack; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java index 72e8b162b..9b27813a4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java @@ -18,9 +18,9 @@ package com.jpexs.decompiler.flash.abc.types.traits; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.List; import java.util.Stack; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java index e5466eae3..d25e6ad81 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java @@ -21,11 +21,11 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.abc.types.ValueKind; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index 97f1d4661..d11ed449e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -47,10 +47,8 @@ import com.jpexs.decompiler.flash.action.swf4.*; import com.jpexs.decompiler.flash.action.swf5.*; import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2; import com.jpexs.decompiler.flash.ecma.Null; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; -import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphSource; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -60,6 +58,7 @@ import com.jpexs.decompiler.graph.model.CommentItem; import com.jpexs.decompiler.graph.model.IfItem; import com.jpexs.decompiler.graph.model.NotItem; import com.jpexs.decompiler.graph.model.ScriptEndItem; +import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.StringReader; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java index bbd2ce2ab..1d6795a58 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java @@ -1,10 +1,10 @@ package com.jpexs.decompiler.flash.action; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphPart; import com.jpexs.decompiler.graph.GraphSource; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/CastOpActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/CastOpActionItem.java index fce734e3d..02b6d1a34 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/CastOpActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/CastOpActionItem.java @@ -17,10 +17,10 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf7.ActionCastOp; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.helpers.Helper; import java.util.ArrayList; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java index 11037cd1d..a389db03e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java @@ -21,10 +21,10 @@ import com.jpexs.decompiler.flash.action.swf4.ConstantIndex; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.ecma.Undefined; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.helpers.Helper; import java.util.ArrayList; import java.util.List; import java.util.Objects; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/EnumerateActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/EnumerateActionItem.java index 3e83c59a1..4b4fa9077 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/EnumerateActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/EnumerateActionItem.java @@ -16,9 +16,9 @@ */ package com.jpexs.decompiler.flash.action.model; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.ArrayList; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/FSCommandActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/FSCommandActionItem.java index b93c873f9..d93f44d38 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/FSCommandActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/FSCommandActionItem.java @@ -17,9 +17,9 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf3.ActionGetURL; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.helpers.Helper; import java.util.List; /** diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java index 42254a480..f782c2027 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java @@ -24,11 +24,11 @@ import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction; import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister; import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.helpers.Helper; import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/GetURLActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/GetURLActionItem.java index 9d9fb758e..91a931c51 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/GetURLActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/GetURLActionItem.java @@ -17,9 +17,9 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf3.ActionGetURL; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.helpers.Helper; import java.util.List; public class GetURLActionItem extends ActionItem { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/GotoLabelActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/GotoLabelActionItem.java index da058d829..924e44a5b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/GotoLabelActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/GotoLabelActionItem.java @@ -17,9 +17,9 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf3.ActionGoToLabel; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.helpers.Helper; import java.util.List; public class GotoLabelActionItem extends ActionItem { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ImplementsOpActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ImplementsOpActionItem.java index c016f57b0..e73cb435e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ImplementsOpActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ImplementsOpActionItem.java @@ -16,9 +16,9 @@ */ package com.jpexs.decompiler.flash.action.model; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.util.List; public class ImplementsOpActionItem extends ActionItem { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/SetTargetActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/SetTargetActionItem.java index 8cc5c3430..6171d2c05 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/SetTargetActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/SetTargetActionItem.java @@ -16,9 +16,9 @@ */ package com.jpexs.decompiler.flash.action.model; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.helpers.Helper; import java.util.List; public class SetTargetActionItem extends ActionItem { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ThrowActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ThrowActionItem.java index bc1eb05a2..763d0e991 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ThrowActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ThrowActionItem.java @@ -17,11 +17,11 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf7.ActionThrow; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.helpers.Helper; import java.util.List; public class ThrowActionItem extends ActionItem { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ToNumberActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ToNumberActionItem.java index c8b9ff12f..c9582c3bb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ToNumberActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ToNumberActionItem.java @@ -17,10 +17,10 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionToNumber; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.helpers.Helper; import java.util.List; public class ToNumberActionItem extends ActionItem { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ToStringActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ToStringActionItem.java index d0686220d..00b215ba3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ToStringActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ToStringActionItem.java @@ -17,10 +17,10 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionToString; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.helpers.Helper; import java.util.List; public class ToStringActionItem extends ActionItem { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/TypeOfActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/TypeOfActionItem.java index 3e35373c0..5bd593948 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/TypeOfActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/TypeOfActionItem.java @@ -19,10 +19,10 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionTypeOf; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.ecma.EcmaType; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.helpers.Helper; import java.util.List; public class TypeOfActionItem extends ActionItem { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java index 59f844db8..6c799aff5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java @@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.action.model.GetVariableActionItem; import com.jpexs.decompiler.flash.action.model.SetMemberActionItem; import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.graph.Block; @@ -34,6 +33,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.ContinueItem; +import com.jpexs.helpers.Helper; import java.util.ArrayList; import java.util.HashSet; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java index 8beabe878..a70974522 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java @@ -57,7 +57,7 @@ public class AddActionItem extends BinaryOpItem { public Object getResult() { if (version2) { if (EcmaScript.type(leftSide.getResult()) == EcmaType.STRING || EcmaScript.type(rightSide.getResult()) == EcmaType.STRING) { - return ""+leftSide.getResult() + rightSide.getResult(); + return "" + leftSide.getResult() + rightSide.getResult(); } return EcmaScript.toNumber(leftSide.getResult()) + EcmaScript.toNumber(rightSide.getResult()); } else { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java b/trunk/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java index fef9d9d7e..c66e9c1cc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java @@ -28,8 +28,8 @@ import com.jpexs.decompiler.flash.action.swf4.*; import com.jpexs.decompiler.flash.action.swf5.*; import com.jpexs.decompiler.flash.action.swf6.*; import com.jpexs.decompiler.flash.action.swf7.*; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItemContainer; +import com.jpexs.helpers.Helper; import java.io.IOException; import java.io.Reader; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java b/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java index 84dce690c..9d869ccac 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java @@ -43,7 +43,6 @@ import com.jpexs.decompiler.flash.action.swf6.ActionStrictEquals; import com.jpexs.decompiler.flash.action.swf7.ActionExtends; import com.jpexs.decompiler.flash.action.swf7.ActionImplementsOp; import com.jpexs.decompiler.flash.ecma.Null; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -61,6 +60,7 @@ import com.jpexs.decompiler.graph.model.OrItem; import com.jpexs.decompiler.graph.model.SwitchItem; import com.jpexs.decompiler.graph.model.TernarOpItem; import com.jpexs.decompiler.graph.model.WhileItem; +import com.jpexs.helpers.Helper; import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java index 1d04f4c03..459a3576f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java @@ -27,8 +27,8 @@ import com.jpexs.decompiler.flash.action.model.UnLoadMovieActionItem; import com.jpexs.decompiler.flash.action.model.UnLoadMovieNumActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java index a0f7affe7..a5a966001 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java @@ -22,8 +22,8 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.GotoLabelActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java index 626618dcf..e93731d8d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java @@ -22,8 +22,8 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.SetTargetActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java index 136e478d3..c8bfc0df4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java @@ -22,9 +22,9 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionGraphSource; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSource; import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java index 4f49c2351..0601c9fe4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java @@ -22,9 +22,9 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionGraphSource; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSource; import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index fae666175..e2e925cba 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.EndOfStreamException; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.graph.NotCompileTimeItem; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.action.model.TemporaryRegister; @@ -28,10 +27,10 @@ import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.ecma.Undefined; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java index 1191d4f1f..901c47c1e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.Configuration; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Helper; import java.io.Serializable; import java.util.ArrayList; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java index b30e32d71..6aa693037 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java @@ -22,8 +22,8 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java index 991669af0..b80216bec 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java @@ -16,7 +16,6 @@ */ package com.jpexs.decompiler.flash.action.swf5; -import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; @@ -24,10 +23,11 @@ import com.jpexs.decompiler.flash.action.model.FunctionActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.action.parser.pcode.Label; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; +import com.jpexs.helpers.ReReadableInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java index 3130a0c7d..c3fb6b2ca 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java @@ -16,7 +16,6 @@ */ package com.jpexs.decompiler.flash.action.swf5; -import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; @@ -27,6 +26,7 @@ import com.jpexs.decompiler.flash.action.parser.pcode.Label; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.ReReadableInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java index 3bf52fcfd..1a9c759e8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java @@ -16,7 +16,6 @@ */ package com.jpexs.decompiler.flash.action.swf7; -import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; @@ -24,10 +23,11 @@ import com.jpexs.decompiler.flash.action.model.FunctionActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.action.parser.pcode.Label; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; +import com.jpexs.helpers.ReReadableInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java index b5a2f401e..b5607abc2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java @@ -16,7 +16,6 @@ */ package com.jpexs.decompiler.flash.action.swf7; -import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; @@ -28,10 +27,11 @@ import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.action.parser.pcode.Label; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; +import com.jpexs.helpers.ReReadableInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java index ee1e78ba5..20da765e0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ErrorLogFrame.java @@ -74,13 +74,13 @@ public class ErrorLogFrame extends AppFrame { logView.setBackground(Color.white); logView.setLayout(new BorderLayout()); cnt.setBackground(Color.white); - + logViewInner.setLayout(new BoxLayout(logViewInner, BoxLayout.Y_AXIS)); logView.add(logViewInner, BorderLayout.NORTH); expandIcon = View.getIcon("expand16"); collapseIcon = View.getIcon("collapse16"); - + cnt.add(new JScrollPane(logView), BorderLayout.CENTER); handler = new Handler() { @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java index dfd4ef8ed..44bbb868d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java @@ -234,13 +234,12 @@ public class GraphFrame extends AppFrame { return w; } } - GraphPanel gp; int scrollBarWidth; int scrollBarHeight; int frameWidthDiff; int frameHeightDiff; - + public GraphFrame(Graph graph, String name) { setSize(500, 500); Container cnt = getContentPane(); @@ -252,10 +251,10 @@ public class GraphFrame extends AppFrame { scrollBarHeight = scrollPane.getHorizontalScrollBar().getPreferredSize().height; cnt.add(scrollPane, BorderLayout.CENTER); pack(); - + Dimension size = getSize(); Dimension innerSize = getContentPane().getSize(); - + frameWidthDiff = size.width - innerSize.width; frameHeightDiff = size.height - innerSize.height; @@ -272,10 +271,10 @@ public class GraphFrame extends AppFrame { Dimension panDim = gp.getPreferredSize(); // add some magic constants panDim = new Dimension(panDim.width + 3, panDim.height + 2); - + boolean tooHigh = false; boolean tooWide = false; - + if (panDim.width + frameWidthDiff < screen.width) { dim.width = panDim.width; } else { @@ -288,7 +287,7 @@ public class GraphFrame extends AppFrame { dim.height = screen.height; tooHigh = true; } - + if (tooWide) { dim.height += scrollBarHeight; dim.height = Math.min(dim.height, screen.height); @@ -297,7 +296,7 @@ public class GraphFrame extends AppFrame { dim.width += scrollBarWidth; dim.width = Math.min(dim.width, screen.width); } - + setVisibleSize(dim); View.centerScreen(this); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java new file mode 100644 index 000000000..d4713a177 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java @@ -0,0 +1,315 @@ +package com.jpexs.decompiler.flash.gui; + +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.helpers.ProgressListener; +import com.jpexs.process.ProcessTools; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.BoxLayout; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.SwingWorker; +import javax.swing.SwingWorker.StateValue; + +/** + * + * @author petrik + */ +public class LoadFromMemoryFrame extends AppFrame implements ActionListener { + + private List processlist; + private List foundIs; + private com.jpexs.process.Process selProcess; + private JList list; + private DefaultListModel model; + private DefaultListModel resModel; + private final JList listRes; + private JLabel stateLabel; + private boolean processing = false; + private JProgressBar progress; + + private class SelectProcessWorker extends SwingWorker, Object> { + + private com.jpexs.process.Process proc; + + public SelectProcessWorker(com.jpexs.process.Process proc) { + this.proc = proc; + } + + @Override + protected void process(List chunks) { + for (Object s : chunks) { + if (s instanceof String) { + resModel.addElement((String) s); + } + } + } + + @Override + protected List doInBackground() throws Exception { + Map ret = new HashMap<>(); + ret = proc.search(new ProgressListener() { + @Override + public void progress(int p) { + setProgress(p); + } + }, "CWS".getBytes(), "FWS".getBytes(), "ZWS".getBytes()); + List swfStreams = new ArrayList<>(); + int pos = 0; + for (Long addr : ret.keySet()) { + setProgress(pos * 100 / ret.size()); + pos++; + try { + BufferedInputStream is = new BufferedInputStream(ret.get(addr)); + is.mark(Integer.MAX_VALUE); + SWF swf = new SWF(is, null, false, true); + if (swf.fileSize > 0 && swf.version > 0 && swf.version < 25/*Needs to be fixed when SWF versions reaches this value*/) { + publish(translate("swfitem").replace("%version%", "" + swf.version).replace("%size%", "" + swf.fileSize)); + swfStreams.add(is); + } + + } catch (OutOfMemoryError ome) { + System.gc(); + } catch (Exception | Error ex) { + } + + } + setProgress(100); + if (swfStreams.isEmpty()) { + return null; + } + return swfStreams; + } + } + + private void refreshList() { + model.clear(); + processlist = ProcessTools.listProcesses(); + Collections.sort(processlist); + for (com.jpexs.process.Process p : processlist) { + model.addElement(p); + } + } + + private void openSWF() { + if (foundIs == null) { + return; + } + int index = listRes.getSelectedIndex(); + if (index > -1) { + BufferedInputStream str = foundIs.get(index); + try { + str.reset(); + } catch (IOException ex) { + Logger.getLogger(LoadFromMemoryFrame.class.getName()).log(Level.SEVERE, null, ex); + return; + } + str.mark(Integer.MAX_VALUE); + Main.openFile("" + selProcess + " [" + (index + 1) + "]", str); + } + } + + private void selectProcess() { + if (processing) { + return; + } + selProcess = (com.jpexs.process.Process) list.getSelectedValue(); + if (selProcess != null) { + processing = true; + stateLabel.setText(selProcess.toString()); + resModel.clear(); + foundIs = null; + progress.setIndeterminate(true); + progress.setString(translate("searching")); + progress.setStringPainted(true); + progress.setVisible(true); + final SelectProcessWorker wrk = new SelectProcessWorker(selProcess); + wrk.addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + switch (evt.getPropertyName()) { + case "progress": + progress.setIndeterminate(false); + progress.setStringPainted(false); + progress.setValue((Integer) evt.getNewValue()); + break; + case "state": + if (((StateValue) evt.getNewValue()) == StateValue.DONE) { + try { + foundIs = wrk.get(); + } catch (Exception ex) { + Logger.getLogger(LoadFromMemoryFrame.class.getName()).log(Level.SEVERE, null, ex); + } + if (foundIs == null) { + resModel.addElement(translate("notfound")); + } + listRes.setEnabled(foundIs != null); + progress.setVisible(false); + processing = false; + } + } + + } + }); + wrk.execute(); + } + } + + @SuppressWarnings("unchecked") + public LoadFromMemoryFrame() { + setSize(800, 600); + setAlwaysOnTop(true); + setTitle(translate("dialog.title")); + + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + if (!Main.mainFrame.isVisible()) { + Main.mainFrame.setVisible(true); + } + } + }); + model = new DefaultListModel<>(); + + resModel = new DefaultListModel<>(); + listRes = new JList(resModel); + list = new JList(model); + list.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == 10) { //Enter pressed + selectProcess(); + } + } + }); + list.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 1) { + selectProcess(); + } + } + }); + listRes.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 1) { + openSWF(); + } + } + }); + listRes.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == 10) { //Enter pressed + openSWF(); + } + } + }); + list.setCellRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + + JLabel label = (JLabel) super.getListCellRendererComponent(list, + value, index, isSelected, cellHasFocus); + + if (value instanceof com.jpexs.process.Process) { + if (((com.jpexs.process.Process) value).getIcon() != null) { + label.setIcon(new ImageIcon(((com.jpexs.process.Process) value).getIcon())); + } + } + if (!isSelected) { + label.setBackground(Color.white); + } + return label; + } + }); + refreshList(); + Container cnt = getContentPane(); + cnt.setLayout(new BorderLayout()); + + JPanel leftPanel = new JPanel(new BorderLayout()); + leftPanel.add(new JScrollPane(list), BorderLayout.CENTER); + JPanel leftButtonsPanel = new JPanel(new FlowLayout()); + JButton selectButton = new JButton(translate("button.select")); + selectButton.setActionCommand("SELECTPROCESS"); + selectButton.addActionListener(this); + JButton refreshButton = new JButton(translate("button.refresh")); + refreshButton.setActionCommand("REFRESHPROCESSLIST"); + refreshButton.addActionListener(this); + leftButtonsPanel.add(selectButton); + leftButtonsPanel.add(refreshButton); + leftPanel.add(leftButtonsPanel, BorderLayout.SOUTH); + + JPanel rightPanel = new JPanel(new BorderLayout()); + rightPanel.add(new JScrollPane(listRes), BorderLayout.CENTER); + JPanel rightButtonsPanel = new JPanel(new FlowLayout()); + JButton openButton = new JButton(translate("button.open")); + openButton.setActionCommand("OPENSWF"); + openButton.addActionListener(this); + rightButtonsPanel.add(openButton); + rightPanel.add(rightButtonsPanel, BorderLayout.SOUTH); + + JPanel statePanel = new JPanel(); + statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS)); + + stateLabel = new JLabel(translate("noprocess")); + statePanel.add(stateLabel); + progress = new JProgressBar(0, 100); + statePanel.add(progress); + progress.setVisible(false); + rightPanel.add(statePanel, BorderLayout.NORTH); + + + + cnt.add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel), BorderLayout.CENTER); + View.setWindowIcon(this); + View.centerScreen(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + switch (e.getActionCommand()) { + case "SELECTPROCESS": + selectProcess(); + break; + case "OPENSWF": + openSWF(); + break; + case "REFRESHPROCESSLIST": + refreshList(); + break; + } + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index 1350044da..86c398473 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -20,25 +20,25 @@ import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.Configuration; import com.jpexs.decompiler.flash.ConsoleAbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.EventListener; -import com.jpexs.decompiler.flash.PercentListener; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.Version; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import static com.jpexs.decompiler.flash.gui.AppStrings.translate; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.Advapi32Util; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.Kernel32; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.SHELLEXECUTEINFO; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.Shell32; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.Win32Exception; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg.HKEY; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinUser; import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel; import com.jpexs.decompiler.flash.gui.proxy.ProxyFrame; -import com.jpexs.decompiler.flash.helpers.Cache; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Cache; +import com.jpexs.helpers.Helper; +import com.jpexs.helpers.ProgressListener; import com.sun.jna.Platform; import com.sun.jna.WString; +import com.sun.jna.platform.win32.Advapi32Util; +import com.sun.jna.platform.win32.Kernel32; +import com.sun.jna.platform.win32.SHELLEXECUTEINFO; +import com.sun.jna.platform.win32.Shell32; +import com.sun.jna.platform.win32.Win32Exception; +import com.sun.jna.platform.win32.WinReg; +import com.sun.jna.platform.win32.WinReg.HKEY; +import com.sun.jna.platform.win32.WinUser; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -54,7 +54,6 @@ import java.util.Arrays; import java.util.Calendar; import java.util.Locale; import java.util.Properties; -import java.util.Scanner; import java.util.logging.ConsoleHandler; import java.util.logging.FileHandler; import java.util.logging.Level; @@ -78,7 +77,8 @@ public class Main { public static ProxyFrame proxyFrame; public static String file; - public static String maskURL; + public static InputStream inputStream; + public static String fileTitle; public static SWF swf; public static String version = ""; public static final String applicationName = "JPEXS Free Flash Decompiler"; @@ -98,6 +98,15 @@ public class Main { public static MainFrame mainFrame; private static final int UPDATE_SYSTEM_MAJOR = 1; private static final int UPDATE_SYSTEM_MINOR = 0; + public static LoadFromMemoryFrame loadFromMemoryFrame; + public static boolean readOnly = false; + + public static void loadFromMemory() { + if (loadFromMemoryFrame == null) { + loadFromMemoryFrame = new LoadFromMemoryFrame(); + } + loadFromMemoryFrame.setVisible(true); + } private static String commandlineConfigBoolean[] = new String[]{ "decompile", "parallelSpeedUp", @@ -129,8 +138,8 @@ public class Main { * @return file title */ public static String getFileTitle() { - if (maskURL != null) { - return maskURL; + if (fileTitle != null) { + return fileTitle; } return file; } @@ -199,33 +208,39 @@ public class Main { } public static SWF parseSWF(String file) throws Exception { - SWF locswf; try (FileInputStream fis = new FileInputStream(file)) { - InputStream bis = new BufferedInputStream(fis); - locswf = new SWF(bis, new PercentListener() { - @Override - public void percent(int p) { - startWork(translate("work.reading.swf"), p); - } - }, (Boolean) Configuration.getConfig("parallelSpeedUp", Boolean.TRUE)); - locswf.addEventListener(new EventListener() { - @Override - public void handleEvent(String event, Object data) { - if (event.equals("export")) { - startWork((String) data); - } - if (event.equals("getVariables")) { - startWork(translate("work.gettingvariables") + "..." + (String) data); - } - if (event.equals("deobfuscate")) { - startWork(translate("work.deobfuscating") + "..." + (String) data); - } - if (event.equals("rename")) { - startWork(translate("work.renaming") + "..." + (String) data); - } - } - }); + return parseSWF(fis); } + } + + public static SWF parseSWF(InputStream fis) throws Exception { + SWF locswf; + //try (FileInputStream fis = new FileInputStream(file)) { + InputStream bis = new BufferedInputStream(fis); + locswf = new SWF(bis, new ProgressListener() { + @Override + public void progress(int p) { + startWork(translate("work.reading.swf"), p); + } + }, (Boolean) Configuration.getConfig("parallelSpeedUp", Boolean.TRUE)); + locswf.addEventListener(new EventListener() { + @Override + public void handleEvent(String event, Object data) { + if (event.equals("export")) { + startWork((String) data); + } + if (event.equals("getVariables")) { + startWork(translate("work.gettingvariables") + "..." + (String) data); + } + if (event.equals("deobfuscate")) { + startWork(translate("work.deobfuscating") + "..." + (String) data); + } + if (event.equals("rename")) { + startWork(translate("work.renaming") + "..." + (String) data); + } + } + }); + //} return locswf; } @@ -253,13 +268,13 @@ public class Main { protected Object doInBackground() throws Exception { try { Main.startWork(translate("work.reading.swf") + "..."); - swf = parseSWF(Main.file); + swf = parseSWF(Main.inputStream); } catch (Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); View.showMessageDialog(null, "Cannot load SWF file."); loadingDialog.setVisible(false); - exit(); - return false; + swf = null; + //return false; } try { @@ -278,7 +293,9 @@ public class Main { View.execInEventDispatch(new Runnable() { @Override public void run() { - mainFrame.setVisible(true); + if (mainFrame != null) { + mainFrame.setVisible(true); + } } }); @@ -310,6 +327,24 @@ public class Main { } public static boolean openFile(String swfFile) { + + try (FileInputStream fis = new FileInputStream(swfFile)) { + boolean ok = openFile(swfFile, fis); + if (ok) { + readOnly = false; + } + return ok; + } catch (IOException ex) { + JOptionPane.showMessageDialog(null, "Cannot open file", "Error", JOptionPane.ERROR_MESSAGE); + } + return false; + } + + public static boolean openFile(String fileTitle, InputStream is) { + Main.file = fileTitle; + Main.inputStream = is; + Main.fileTitle = fileTitle; + readOnly = true; if (mainFrame != null) { mainFrame.setVisible(false); Helper.emptyObject(mainFrame); @@ -318,7 +353,6 @@ public class Main { Cache.clearAll(); System.gc(); } - Main.file = swfFile; View.execInEventDispatch(new Runnable() { @Override public void run() { @@ -329,7 +363,8 @@ public class Main { }); Main.loadingDialog.setVisible(true); - (new OpenFileWorker()).execute(); + OpenFileWorker wrk = new OpenFileWorker(); + wrk.execute(); return true; } @@ -360,7 +395,8 @@ public class Main { } Main.saveFile(fileName); Configuration.setConfig("lastSaveDir", file.getParentFile().getAbsolutePath()); - maskURL = null; + fileTitle = null; + readOnly = false; return true; } catch (IOException ex) { View.showMessageDialog(null, translate("error.file.write")); @@ -370,7 +406,7 @@ public class Main { } public static boolean openFileDialog() { - maskURL = null; + fileTitle = null; JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File((String) Configuration.getConfig("lastOpenDir", "."))); fc.setFileFilter(new FileFilter() { @@ -695,7 +731,7 @@ public class Main { } else { Cache.setStorageType(Cache.STORAGE_MEMORY); } - + int errorMode = AbortRetryIgnoreHandler.UNDEFINED; int retryCount = 0; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index 7c126d3c8..5fd50dfa4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.Configuration; -import com.jpexs.decompiler.flash.ConsoleAbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.FrameNode; import com.jpexs.decompiler.flash.PackageNode; import com.jpexs.decompiler.flash.SWF; @@ -36,8 +35,6 @@ import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; import com.jpexs.decompiler.flash.gui.abc.TreeElement; import com.jpexs.decompiler.flash.gui.action.ActionPanel; import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel; -import com.jpexs.decompiler.flash.helpers.Cache; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag; @@ -93,6 +90,9 @@ import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.RGB; import com.jpexs.decompiler.flash.types.TEXTRECORD; +import com.jpexs.helpers.Cache; +import com.jpexs.helpers.Helper; +import com.jpexs.process.ProcessTools; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; @@ -280,6 +280,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel private ErrorLogFrame errorLogFrame; private ComponentListener fontChangeList; private JComboBox fontSelection; + private JCommandButton saveCommandButton; private Map sourceFontsMap = new HashMap<>(); private AbortRetryIgnoreHandler errorHandler = new AbortRetryIgnoreHandler() { @Override @@ -373,7 +374,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel editBand.setResizePolicies((List) Arrays.asList(new CoreRibbonResizePolicies.Mirror(editBand.getControlPanel()), new IconRibbonBandResizePolicy(editBand.getControlPanel()))); JCommandButton openCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.open")), View.getResizableIcon("open32")); assignListener(openCommandButton, "OPEN"); - JCommandButton saveCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.save")), View.getResizableIcon("save32")); + saveCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.save")), View.getResizableIcon("save32")); assignListener(saveCommandButton, "SAVE"); JCommandButton saveasCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.saveas")), View.getResizableIcon("saveas32")); assignListener(saveasCommandButton, "SAVEAS"); @@ -383,7 +384,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel editBand.addCommandButton(openCommandButton, RibbonElementPriority.TOP); editBand.addCommandButton(saveCommandButton, RibbonElementPriority.TOP); editBand.addCommandButton(saveasCommandButton, RibbonElementPriority.TOP); - + saveCommandButton.setEnabled(!Main.readOnly); JRibbonBand exportBand = new JRibbonBand(translate("menu.export"), null); exportBand.setResizePolicies((List) Arrays.asList(new CoreRibbonResizePolicies.Mirror(exportBand.getControlPanel()), new IconRibbonBandResizePolicy(exportBand.getControlPanel()))); @@ -410,10 +411,16 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel JCommandButton gotoDocumentClassCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.gotodocumentclass")), View.getResizableIcon("gotomainclass32")); assignListener(gotoDocumentClassCommandButton, "GOTODOCUMENTCLASS"); + JCommandButton loadMemoryCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.searchmemory")), View.getResizableIcon("open_process32")); + assignListener(loadMemoryCommandButton, "LOADMEMORY"); + toolsBand.addCommandButton(searchCommandButton, RibbonElementPriority.TOP); toolsBand.addCommandButton(proxyCommandButton, RibbonElementPriority.TOP); toolsBand.addCommandButton(gotoDocumentClassCommandButton, RibbonElementPriority.TOP); - + toolsBand.addCommandButton(loadMemoryCommandButton, RibbonElementPriority.TOP); + if (!ProcessTools.toolsAvailable()) { + loadMemoryCommandButton.setEnabled(false); + } JRibbonBand deobfuscationBand = new JRibbonBand(translate("menu.tools.deobfuscation"), null); deobfuscationBand.setResizePolicies((List) Arrays.asList(new CoreRibbonResizePolicies.Mirror(deobfuscationBand.getControlPanel()), new IconRibbonBandResizePolicy(deobfuscationBand.getControlPanel()))); @@ -582,6 +589,11 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel return; } } + if (Main.loadFromMemoryFrame != null) { + if (Main.loadFromMemoryFrame.isVisible()) { + return; + } + } Main.exit(); } }); @@ -1416,7 +1428,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel // why null? return; } - + errorNotificationButton.setIcon(View.getIcon("error16")); errorNotificationButton.setToolTipText(translate("errors.present")); if (timer != null) { @@ -2181,6 +2193,9 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel @Override public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { + case "LOADMEMORY": + Main.loadFromMemory(); + break; case "SHOWERRORLOG": errorLogFrame.setVisible(true); break; @@ -2497,6 +2512,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel case "SAVEAS": if (Main.saveFileDialog()) { setTitle(Main.applicationVerName + (Configuration.DISPLAY_FILENAME ? " - " + Main.getFileTitle() : "")); + saveCommandButton.setEnabled(!Main.readOnly); } break; case "OPEN": diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MyProgressBarUI.java b/trunk/src/com/jpexs/decompiler/flash/gui/MyProgressBarUI.java index 8ab937d87..ebcfe9bb9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MyProgressBarUI.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MyProgressBarUI.java @@ -16,8 +16,6 @@ */ package com.jpexs.decompiler.flash.gui; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import javax.swing.CellRendererPane; import javax.swing.JComponent; import javax.swing.JProgressBar; @@ -92,24 +90,9 @@ public class MyProgressBarUI extends SubstanceProgressBarUI { @Override protected void installListeners() { + super.installListeners(); + this.progressBar.removeChangeListener(substanceValueChangeListener); substanceValueChangeListener = new MyProgressBarUI.SubstanceChangeListener(); this.progressBar.addChangeListener(this.substanceValueChangeListener); - - this.substancePropertyChangeListener = new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - if ("font".equals(evt.getPropertyName())) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - if (progressBar != null) { - progressBar.updateUI(); - } - } - }); - } - } - }; - this.progressBar.addPropertyChangeListener(this.substancePropertyChangeListener); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java index babcbe10d..97194016f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java @@ -80,6 +80,9 @@ public class SWFPreviwPanel extends JPanel { if (swf == null) { return; } + if (swf.frameRate == 0) { + return; + } stop(); timer = new Timer(); timer.schedule(new TimerTask() { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index b7cb5544a..5f016b31b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -36,9 +36,9 @@ import com.jpexs.decompiler.flash.gui.abc.tablemodels.NamespaceSetTableModel; import com.jpexs.decompiler.flash.gui.abc.tablemodels.NamespaceTableModel; import com.jpexs.decompiler.flash.gui.abc.tablemodels.StringTableModel; import com.jpexs.decompiler.flash.gui.abc.tablemodels.UIntTableModel; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.helpers.Helper; import java.awt.BorderLayout; import java.awt.Component; import java.awt.FlowLayout; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java index 65d2c06cb..1f2ff8601 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java @@ -24,9 +24,9 @@ import com.jpexs.decompiler.flash.abc.avm2.parser.ASM3Parser; import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException; import com.jpexs.decompiler.flash.gui.GraphFrame; import com.jpexs.decompiler.flash.gui.View; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ConstantsListModel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ConstantsListModel.java index de17c0efc..a8cd902f5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ConstantsListModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ConstantsListModel.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.gui.abc; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Helper; import java.util.ArrayList; import javax.swing.ListModel; import javax.swing.event.ListDataListener; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index 2cc6246d7..ea3972ce3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -26,9 +26,9 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import static com.jpexs.decompiler.flash.gui.AppStrings.translate; import com.jpexs.decompiler.flash.gui.View; -import com.jpexs.decompiler.flash.helpers.Cache; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.helpers.Cache; import java.util.ArrayList; import java.util.List; import java.util.Timer; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java index 84f8b1dd8..3551ec974 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java @@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait; import static com.jpexs.decompiler.flash.gui.AppStrings.translate; import com.jpexs.decompiler.flash.gui.HeaderLabel; import com.jpexs.decompiler.flash.gui.View; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Helper; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.FlowLayout; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodInfoPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodInfoPanel.java index 2865686ab..572bba144 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodInfoPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodInfoPanel.java @@ -23,7 +23,7 @@ import com.jpexs.decompiler.flash.abc.methodinfo_parser.ParseException; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import static com.jpexs.decompiler.flash.gui.AppStrings.translate; import com.jpexs.decompiler.flash.gui.View; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Helper; import java.awt.Dimension; import java.awt.Font; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java index 2358e11ad..082736560 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java @@ -23,7 +23,7 @@ import com.jpexs.decompiler.flash.abc.types.ValueKind; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import static com.jpexs.decompiler.flash.gui.AppStrings.translate; import com.jpexs.decompiler.flash.gui.View; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Helper; import java.awt.BorderLayout; import java.util.ArrayList; import javax.swing.*; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index c59f3ead4..a36bd7120 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -34,13 +34,13 @@ import com.jpexs.decompiler.flash.gui.Main; import com.jpexs.decompiler.flash.gui.TagTreeModel; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; -import com.jpexs.decompiler.flash.helpers.Cache; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Cache; +import com.jpexs.helpers.Helper; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.Font; @@ -570,7 +570,7 @@ public class ActionPanel extends JPanel implements ActionListener { if (lastASM == null) { return; } - + String pref = lastASM.getActionSourcePrefix(); int lastPos = decompiledEditor.getCaretPosition(); int lastLine = decompiledEditor.getLine(); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/graphics/open_process32.png b/trunk/src/com/jpexs/decompiler/flash/gui/graphics/open_process32.png new file mode 100644 index 000000000..27cac5586 Binary files /dev/null and b/trunk/src/com/jpexs/decompiler/flash/gui/graphics/open_process32.png differ diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/LoadFromMemoryFrame.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/LoadFromMemoryFrame.properties new file mode 100644 index 000000000..69209bacb --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/LoadFromMemoryFrame.properties @@ -0,0 +1,23 @@ +# Copyright (C) 2013 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 . + +dialog.title = Search in memory +button.open = Open +button.select = Select +button.refresh = Refresh list +noprocess = No process selected +searching = Searching... +swfitem = [SWF version %version% size %size%] +notfound = No SWF found \ No newline at end of file diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/LoadFromMemoryFrame_cs.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/LoadFromMemoryFrame_cs.properties new file mode 100644 index 000000000..9b76228c4 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/LoadFromMemoryFrame_cs.properties @@ -0,0 +1,23 @@ +# Copyright (C) 2013 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 . + +dialog.title = Hledat v pam\u011bti +button.open = Otev\u0159\u00edt +button.select = Vybrat +button.refresh = Obnovit seznam +noprocess = Nebyl vybr\u00e1n process +searching = Prohled\u00e1v\u00e1n\u00ed... +swfitem = [SWF verze %version% velikost %size%] +notfound = \u017d\u00e1dn\u00e9 SWF nebylo nalezeno \ No newline at end of file diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index a5ddeccc1..842d1032d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -330,3 +330,6 @@ startup.selectopen = Click Open icon on the top panel or drag SWF file to this w error.font.nocharacter = Selected source font does not contain character "%char%". warning.initializers = Static fields and consts are often initialized in initializers.\nEditing value here is usually not enough! + +#after version 1.7.0u1: +menu.tools.searchmemory = Search SWFs in memory \ No newline at end of file diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties b/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties index 3ac238426..9b8f06dd6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties @@ -334,4 +334,7 @@ startup.selectopen = Pro za\u010d\u00e1tek klikn\u011bte na otev\u0159\u00edt v error.font.nocharacter = Vybran\u00e9 zdrojov\u00e9 p\u00edsmo neobsahuje znak "%char%". -warning.initializers = Statick\u00e9 atributy a konstanty jsou \u010dasto inicializov\u00e1ny pomoc\u00ed inicializ\u00e1tor\u016f.\nPokud to uprav\u00edte zde, obvykle to nesta\u010d\u00ed! \ No newline at end of file +warning.initializers = Statick\u00e9 atributy a konstanty jsou \u010dasto inicializov\u00e1ny pomoc\u00ed inicializ\u00e1tor\u016f.\nPokud to uprav\u00edte zde, obvykle to nesta\u010d\u00ed! + +#after version 1.7.0u1: +menu.tools.searchmemory = Hledat SWF v pam\u011bti \ No newline at end of file diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java index ad8d36b15..c8f07b9b9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java @@ -2,15 +2,15 @@ package com.jpexs.decompiler.flash.gui.player; import com.jpexs.decompiler.flash.gui.FlashUnsupportedException; import com.jpexs.decompiler.flash.gui.Main; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.Kernel32; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.SHELLEXECUTEINFO; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.Shell32; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinUser; import com.sun.jna.Native; import com.sun.jna.Platform; import com.sun.jna.WString; +import com.sun.jna.platform.win32.Kernel32; +import com.sun.jna.platform.win32.SHELLEXECUTEINFO; +import com.sun.jna.platform.win32.Shell32; +import com.sun.jna.platform.win32.WinDef; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.platform.win32.WinUser; import com.sun.jna.ptr.IntByReference; import java.awt.Graphics; import java.awt.Panel; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java index 559500003..9fd58902b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java @@ -171,7 +171,7 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe private void open() { if (swfList.getSelectedIndex() > -1) { Replacement r = (Replacement) listModel.getElementAt(swfList.getSelectedIndex()); - Main.maskURL = r.urlPattern; + Main.fileTitle = r.urlPattern; Main.openFile(r.targetFile); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java index d8d1ffb0e..77fe8d4ec 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java @@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; -import com.jpexs.decompiler.flash.helpers.Cache; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.ButtonTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; @@ -31,6 +30,7 @@ import com.jpexs.decompiler.flash.types.BUTTONCONDACTION; import com.jpexs.decompiler.flash.types.BUTTONRECORD; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; +import com.jpexs.helpers.Cache; import java.awt.Color; import java.awt.Point; import java.awt.image.BufferedImage; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index 570dd9c07..2ffeba611 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -19,13 +19,11 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.Configuration; import com.jpexs.decompiler.flash.DisassemblyListener; import com.jpexs.decompiler.flash.Layer; -import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.helpers.Cache; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.ButtonTag; @@ -33,6 +31,8 @@ import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.types.BUTTONRECORD; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; +import com.jpexs.helpers.Cache; +import com.jpexs.helpers.ReReadableInputStream; import java.awt.Color; import java.awt.Point; import java.awt.image.BufferedImage; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index 00595266e..53f92fd28 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -21,7 +21,6 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; -import com.jpexs.decompiler.flash.helpers.Cache; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.Container; @@ -29,6 +28,7 @@ import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; +import com.jpexs.helpers.Cache; import java.awt.Point; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index c9092aebf..1a82aa916 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.tags.base.FontTag; @@ -33,6 +32,7 @@ import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.TEXTRECORD; +import com.jpexs.helpers.Helper; import java.awt.Point; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index 559e36aff..49b35e790 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.tags.base.FontTag; @@ -33,6 +32,7 @@ import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.RGB; import com.jpexs.decompiler.flash.types.TEXTRECORD; +import com.jpexs.helpers.Helper; import java.awt.Point; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java index a1777ecab..ba8d102fe 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java @@ -18,12 +18,12 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.Configuration; import com.jpexs.decompiler.flash.DisassemblyListener; -import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.tags.base.ASMSource; +import com.jpexs.helpers.ReReadableInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.ArrayList; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index b2b1bbd5b..b2b3d7b5d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -18,14 +18,14 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.Configuration; import com.jpexs.decompiler.flash.DisassemblyListener; -import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; +import com.jpexs.helpers.Helper; +import com.jpexs.helpers.ReReadableInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index f412dff0b..6ad020395 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -18,13 +18,13 @@ package com.jpexs.decompiler.flash.types; import com.jpexs.decompiler.flash.Configuration; import com.jpexs.decompiler.flash.DisassemblyListener; -import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.Exportable; +import com.jpexs.helpers.Helper; +import com.jpexs.helpers.ReReadableInputStream; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index a3af624cf..e82308d71 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -18,12 +18,12 @@ package com.jpexs.decompiler.flash.types; import com.jpexs.decompiler.flash.Configuration; import com.jpexs.decompiler.flash.DisassemblyListener; -import com.jpexs.decompiler.flash.ReReadableInputStream; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.Exportable; +import com.jpexs.helpers.ReReadableInputStream; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/CLIPEVENTFLAGS.java b/trunk/src/com/jpexs/decompiler/flash/types/CLIPEVENTFLAGS.java index 99703122f..47011aa06 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/CLIPEVENTFLAGS.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/CLIPEVENTFLAGS.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.types; -import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.helpers.Helper; import java.util.ArrayList; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java index 4fba18e8d..ba2b98a13 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.types.shaperecords; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.helpers.Cache; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; @@ -32,6 +31,7 @@ import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.RGB; import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.SHAPE; +import com.jpexs.helpers.Cache; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; @@ -836,7 +836,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters { public static BufferedImage shapeToImage(List tags, int shapeNum, FILLSTYLEARRAY fillStyles, LINESTYLEARRAY lineStylesList, List records, Color defaultColor) { String key = "shape_" + records.hashCode() + "_" + (defaultColor == null ? "null" : defaultColor.hashCode()); if (cache.contains(key)) { - return (BufferedImage)cache.get(key); + return (BufferedImage) cache.get(key); } RECT rect = new RECT(); List paths = getPaths(rect, shapeNum, fillStyles, lineStylesList, /*numFillBits, numLineBits,*/ records); diff --git a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index d350af71c..6cf2da60f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -21,7 +21,6 @@ import com.jpexs.decompiler.flash.RetryTask; import com.jpexs.decompiler.flash.RunnableIOEx; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.tags.CSMTextSettingsTag; import com.jpexs.decompiler.flash.tags.DefineButton2Tag; @@ -91,6 +90,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord; import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord; import com.jpexs.decompiler.flash.types.sound.MP3FRAME; import com.jpexs.decompiler.graph.Graph; +import com.jpexs.helpers.Helper; import java.awt.Font; import java.awt.GraphicsEnvironment; import java.awt.Point; diff --git a/trunk/src/com/jpexs/decompiler/graph/Graph.java b/trunk/src/com/jpexs/decompiler/graph/Graph.java index 09af0c924..eff6c105e 100644 --- a/trunk/src/com/jpexs/decompiler/graph/Graph.java +++ b/trunk/src/com/jpexs/decompiler/graph/Graph.java @@ -16,7 +16,6 @@ */ package com.jpexs.decompiler.graph; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.helpers.Highlighting; @@ -598,10 +597,10 @@ public class Graph { System.out.println("");*/ getPrecontinues(localData, null, heads.get(0), loops, null); /*System.err.println(""); - for (Loop el : loops) { - System.err.println(el); - } - System.err.println("");//*/ + for (Loop el : loops) { + System.err.println(el); + } + System.err.println("");//*/ List ret = printGraph(new ArrayList(), localData, stack, allParts, null, heads.get(0), null, loops, staticOperation, path); processIfs(ret); diff --git a/trunk/src/com/jpexs/decompiler/graph/NotCompileTimeItem.java b/trunk/src/com/jpexs/decompiler/graph/NotCompileTimeItem.java index 87e4a5026..ef3a6787f 100644 --- a/trunk/src/com/jpexs/decompiler/graph/NotCompileTimeItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/NotCompileTimeItem.java @@ -16,8 +16,6 @@ */ package com.jpexs.decompiler.graph; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphTargetItem; import java.util.List; /** diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/Cache.java b/trunk/src/com/jpexs/helpers/Cache.java similarity index 96% rename from trunk/src/com/jpexs/decompiler/flash/helpers/Cache.java rename to trunk/src/com/jpexs/helpers/Cache.java index 19068b93d..b35e8b4ba 100644 --- a/trunk/src/com/jpexs/decompiler/flash/helpers/Cache.java +++ b/trunk/src/com/jpexs/helpers/Cache.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash.helpers; +package com.jpexs.helpers; import java.io.File; import java.io.FileInputStream; diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java b/trunk/src/com/jpexs/helpers/Helper.java similarity index 95% rename from trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java rename to trunk/src/com/jpexs/helpers/Helper.java index c22a30469..216759a96 100644 --- a/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java +++ b/trunk/src/com/jpexs/helpers/Helper.java @@ -14,9 +14,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash.helpers; +package com.jpexs.helpers; import com.jpexs.decompiler.flash.gui.Freed; +import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.graph.GraphTargetItem; import java.awt.Component; import java.io.ByteArrayInputStream; @@ -54,7 +55,7 @@ import java.util.regex.Pattern; public class Helper { private static final ExecutorService THREAD_POOL = Executors.newCachedThreadPool(); - + /** * Converts array of int values to string * @@ -514,10 +515,11 @@ public class Helper { return timeStr; } - public static void freeMem(){ + public static void freeMem() { Cache.clearAll(); System.gc(); } + public static String formatTimeToText(int timeS) { long timeM = timeS / 60; timeS = timeS % 60; @@ -544,9 +546,9 @@ public class Helper { // (currently) used only in log, so no localization is required return timeStr; } - + public static T timedCall(Callable c, long timeout, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException { - FutureTask task = new FutureTask(c); + FutureTask task = new FutureTask<>(c); THREAD_POOL.execute(task); return task.get(timeout, timeUnit); } diff --git a/trunk/src/com/jpexs/helpers/PosMarkedInputStream.java b/trunk/src/com/jpexs/helpers/PosMarkedInputStream.java new file mode 100644 index 000000000..bb36e4754 --- /dev/null +++ b/trunk/src/com/jpexs/helpers/PosMarkedInputStream.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2013 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.helpers; + +import java.io.IOException; +import java.io.InputStream; + +/** + * + * @author JPEXS + */ +public class PosMarkedInputStream extends InputStream { + + private int pos = 0; + private InputStream is; + + public PosMarkedInputStream(InputStream is) { + this.is = is; + } + + @Override + public int read() throws IOException { + incPos(); + return is.read(); + } + + public int getPos() { + return pos; + } + + public void setPos(int pos) throws IOException { + this.pos = pos; + } + + public void incPos() { + this.pos++; + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/PercentListener.java b/trunk/src/com/jpexs/helpers/ProgressListener.java similarity index 85% rename from trunk/src/com/jpexs/decompiler/flash/PercentListener.java rename to trunk/src/com/jpexs/helpers/ProgressListener.java index bd63fb951..86bc3e78f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/PercentListener.java +++ b/trunk/src/com/jpexs/helpers/ProgressListener.java @@ -14,13 +14,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash; +package com.jpexs.helpers; /** * * @author JPEXS */ -public interface PercentListener { +public interface ProgressListener { - public void percent(int p); + public void progress(int p); } diff --git a/trunk/src/com/jpexs/decompiler/flash/ReReadableInputStream.java b/trunk/src/com/jpexs/helpers/ReReadableInputStream.java similarity index 94% rename from trunk/src/com/jpexs/decompiler/flash/ReReadableInputStream.java rename to trunk/src/com/jpexs/helpers/ReReadableInputStream.java index 8d87b5cf6..19a34f087 100644 --- a/trunk/src/com/jpexs/decompiler/flash/ReReadableInputStream.java +++ b/trunk/src/com/jpexs/helpers/ReReadableInputStream.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash; +package com.jpexs.helpers; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/trunk/src/com/jpexs/process/Process.java b/trunk/src/com/jpexs/process/Process.java new file mode 100644 index 000000000..c57d51294 --- /dev/null +++ b/trunk/src/com/jpexs/process/Process.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2013 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.process.Process; +import java.awt.image.BufferedImage; +import java.io.InputStream; +import java.util.Map; + +/** + * + * @author JPEXS + */ +public interface Process extends Comparable { + + public String getFilePath(); + + public String getFileName(); + + public BufferedImage getIcon(); + + @Override + public String toString(); + + public String getPid(); + + public Map search(byte[]... data); + + public Map search(ProgressListener progListener, byte[]... data); +} diff --git a/trunk/src/com/jpexs/process/ProcessTools.java b/trunk/src/com/jpexs/process/ProcessTools.java new file mode 100644 index 000000000..0dc6aacf8 --- /dev/null +++ b/trunk/src/com/jpexs/process/ProcessTools.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2013 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.process.Process; +import com.jpexs.process.win32.Win32ProcessTools; +import com.sun.jna.Platform; +import java.util.List; + +/** + * Tools for processes. You can add support for other platforms here, if you + * want + * + * @author JPEXS + */ +public class ProcessTools { + + public static List listProcesses() { + if (Platform.isWindows()) { + return Win32ProcessTools.listProcesses(); + } + return null; + } + + public static boolean toolsAvailable() { + return Platform.isWindows(); + } +} diff --git a/trunk/src/com/jpexs/process/win32/Win32Process.java b/trunk/src/com/jpexs/process/win32/Win32Process.java new file mode 100644 index 000000000..4629cf5a4 --- /dev/null +++ b/trunk/src/com/jpexs/process/win32/Win32Process.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2013 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); + } +} diff --git a/trunk/src/com/jpexs/process/win32/Win32ProcessTools.java b/trunk/src/com/jpexs/process/win32/Win32ProcessTools.java new file mode 100644 index 000000000..d1f59fa03 --- /dev/null +++ b/trunk/src/com/jpexs/process/win32/Win32ProcessTools.java @@ -0,0 +1,612 @@ +/* + * Copyright (C) 2013 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.ProcessTools; +import com.sun.jna.Memory; +import com.sun.jna.NativeLong; +import com.sun.jna.Pointer; +import com.sun.jna.platform.win32.Advapi32; +import com.sun.jna.platform.win32.BITMAP; +import com.sun.jna.platform.win32.BaseTSD; +import com.sun.jna.platform.win32.Gdi32; +import com.sun.jna.platform.win32.ICONINFO; +import com.sun.jna.platform.win32.Kernel32; +import com.sun.jna.platform.win32.MEMORY_BASIC_INFORMATION; +import com.sun.jna.platform.win32.PROCESSENTRY32; +import com.sun.jna.platform.win32.Psapi; +import com.sun.jna.platform.win32.SHFILEINFO; +import com.sun.jna.platform.win32.Shell32; +import com.sun.jna.platform.win32.User32; +import com.sun.jna.platform.win32.WinBase; +import com.sun.jna.platform.win32.WinDef; +import com.sun.jna.platform.win32.WinNT; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.PointerByReference; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author JPEXS + */ +public class Win32ProcessTools extends ProcessTools { + + private static long pointerToAddress(Pointer p) { + String s = p.toString(); + s = s.replace("native@0x", ""); + return Long.parseLong(s, 16); + } + + public static List getPageRanges(WinNT.HANDLE hOtherProcess) { + List ret = new ArrayList<>(); + MEMORY_BASIC_INFORMATION mbi; + WinBase.SYSTEM_INFO si = new WinBase.SYSTEM_INFO(); + Kernel32.INSTANCE.GetSystemInfo(si); + Pointer lpMem = si.lpMinimumApplicationAddress; + while (pointerToAddress(lpMem) < pointerToAddress(si.lpMaximumApplicationAddress)) { + mbi = new MEMORY_BASIC_INFORMATION(); + BaseTSD.SIZE_T t = Kernel32.INSTANCE.VirtualQueryEx(hOtherProcess, lpMem, mbi, new BaseTSD.SIZE_T(mbi.size())); + if (t.longValue() == 0) { + Logger.getLogger(Win32ProcessTools.class.getName()).log(Level.SEVERE, "Cannot get page ranges. Last error:" + Kernel32.INSTANCE.GetLastError()); + break; + } + ret.add(mbi); + lpMem = new Pointer(pointerToAddress(mbi.baseAddress) + mbi.regionSize.longValue()); + } + return ret; + } + + public static void printMemInfo(MEMORY_BASIC_INFORMATION mbi) { + System.out.println("Region size:" + mbi.regionSize); + String stateStr = ""; + if ((mbi.state.intValue() & Kernel32.MEM_COMMIT) == Kernel32.MEM_COMMIT) { + stateStr += " commit"; + } + if ((mbi.state.intValue() & Kernel32.MEM_FREE) == Kernel32.MEM_FREE) { + stateStr += " free"; + } + if ((mbi.state.intValue() & Kernel32.MEM_RESERVE) == Kernel32.MEM_RESERVE) { + stateStr += " reserve"; + } + stateStr = stateStr.trim(); + + String typeStr = ""; + if ((mbi.type.intValue() & Kernel32.MEM_IMAGE) == Kernel32.MEM_IMAGE) { + typeStr += " image"; + } + if ((mbi.type.intValue() & Kernel32.MEM_MAPPED) == Kernel32.MEM_MAPPED) { + typeStr += " mapped"; + } + if ((mbi.type.intValue() & Kernel32.MEM_PRIVATE) == Kernel32.MEM_PRIVATE) { + typeStr += " private"; + } + typeStr = typeStr.trim(); + + String protStr = ""; + if ((mbi.allocationProtect.intValue() & WinNT.PAGE_EXECUTE) == Kernel32.PAGE_EXECUTE) { + protStr += " execute"; + } + if ((mbi.allocationProtect.intValue() & WinNT.PAGE_EXECUTE_READ) == Kernel32.PAGE_EXECUTE_READ) { + protStr += " execute_read"; + } + if ((mbi.allocationProtect.intValue() & WinNT.PAGE_EXECUTE_READWRITE) == Kernel32.PAGE_EXECUTE_READWRITE) { + protStr += " execute_readwrite"; + } + if ((mbi.allocationProtect.intValue() & WinNT.PAGE_READONLY) == Kernel32.PAGE_READONLY) { + protStr += " readonly"; + } + if ((mbi.allocationProtect.intValue() & WinNT.PAGE_READWRITE) == Kernel32.PAGE_READWRITE) { + protStr += " readwrite"; + } + if ((mbi.allocationProtect.intValue() & WinNT.PAGE_WRITECOPY) == Kernel32.PAGE_WRITECOPY) { + protStr += " writecopy"; + } + + protStr = protStr.trim(); + System.out.println("State:" + stateStr); + System.out.println("Type:" + typeStr); + System.out.println("Protect:" + protStr); + System.out.println("baseAddress:" + mbi.baseAddress); + System.out.println("========================"); + } + + private static byte[] mergeArrays(byte[] one, byte[] two) { + byte[] combined = new byte[one.length + two.length]; + + System.arraycopy(one, 0, combined, 0, one.length); + System.arraycopy(two, 0, combined, one.length, two.length); + return combined; + } + + public static Map getDriveMappings() { + 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(); + String tar = new String(buf, 0, len); + tar = tar.trim(); + if (!"".equals(tar)) { + ret.put(tar, d); + } + } + return ret; + } + + public static String ntPathToWin32(String path) { + for (String dp : driveMappings.keySet()) { + if (path.startsWith(dp)) { + return driveMappings.get(dp) + ":" + path.substring(dp.length()); + } + } + return path; + } + private static Map driveMappings = getDriveMappings(); + + public static boolean drawIcon(BufferedImage ret, WinDef.HICON hIcon, int diFlags) { + + WinDef.HDC hdcScreen = User32.INSTANCE.GetDC(null); + WinDef.HDC hdcMem = Gdi32.INSTANCE.CreateCompatibleDC(hdcScreen); + + WinDef.HBITMAP bitmap = Gdi32.INSTANCE.CreateCompatibleBitmap(hdcScreen, ret.getWidth(), ret.getHeight()); + + + WinNT.HANDLE hbmOld = Gdi32.INSTANCE.SelectObject(hdcMem, bitmap); + + + WinNT.HANDLE hBrush = Gdi32.INSTANCE.CreateSolidBrush(new WinDef.DWORD(0xffffff)); + WinDef.RECT rect = new WinDef.RECT(); + rect.left = 0; + rect.top = 0; + rect.right = ret.getWidth(); + rect.bottom = ret.getHeight(); + User32.INSTANCE.FillRect(hdcMem, rect, hBrush); + Gdi32.INSTANCE.DeleteObject(hBrush); + + + boolean ok = User32.INSTANCE.DrawIconEx(hdcMem, 0, 0, hIcon, ret.getWidth(), ret.getHeight(), new WinDef.UINT(0), new WinDef.HBRUSH(Pointer.NULL), diFlags); + + if (!ok) { + return false; + } + + + for (int x = 0; x < ret.getWidth(); x++) { + for (int y = 0; y < ret.getHeight(); y++) { + int rgb = Gdi32.INSTANCE.GetPixel(hdcMem, x, y).intValue(); + int r = (rgb >> 16) & 0xff; + int g = (rgb >> 8) & 0xff; + int b = (rgb >> 0) & 0xff; + rgb = (b << 16) + (g << 8) + r; + ret.setRGB(x, y, rgb); + } + } + + Gdi32.INSTANCE.SelectObject(hdcMem, hbmOld); + Gdi32.INSTANCE.DeleteObject(bitmap); + Gdi32.INSTANCE.DeleteDC(hdcMem); + User32.INSTANCE.ReleaseDC(null, hdcScreen); + return true; + } + + private static void applyMask(BufferedImage image, BufferedImage mask) { + int width = image.getWidth(); + int height = image.getHeight(); + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + int masked = mask.getRGB(x, y); + int alpha = 255 - (masked & 0xff); + if (alpha != 0 && alpha != 255) { + System.out.println("a=" + alpha); + } + int rgb = image.getRGB(x, y); + int r = (rgb >> 16) & 0xff; + int g = (rgb >> 8) & 0xff; + int b = (rgb >> 0) & 0xff; + r = r * alpha / 255; + g = g * alpha / 255; + b = b * alpha / 255; + + rgb = (r << 16) + (g << 8) + b; + + rgb = (alpha << 24) | rgb; + image.setRGB(x, y, rgb); + } + } + } + + public static BufferedImage iconToImage(WinDef.HICON hIcon) { + ICONINFO info = new ICONINFO(); + boolean ok = User32.INSTANCE.GetIconInfo(hIcon, info); + if (!ok) { + return null; + } + BufferedImage ret = null; + BITMAP bmp = new BITMAP(); + if (info.hbmColor != null) { + int nWrittenBytes = Gdi32.INSTANCE.GetObject(info.hbmColor, bmp.size(), bmp); + if (nWrittenBytes > 0) { + ret = new BufferedImage(bmp.bmWidth.intValue(), bmp.bmHeight.intValue(), BufferedImage.TYPE_INT_ARGB); + } + } else if (info.hbmMask != null) { + int nWrittenBytes = Gdi32.INSTANCE.GetObject(info.hbmMask, bmp.size(), bmp); + if (nWrittenBytes > 0) { + ret = new BufferedImage(bmp.bmWidth.intValue(), bmp.bmHeight.intValue() / 2, BufferedImage.TYPE_INT_ARGB); + } + } + if (ret == null) { + return ret; + } + + if (info.hbmColor != null) { + Gdi32.INSTANCE.DeleteObject(info.hbmColor); + } + if (info.hbmMask != null) { + Gdi32.INSTANCE.DeleteObject(info.hbmMask); + } + + drawIcon(ret, hIcon, User32.DI_NORMAL); + BufferedImage mask = new BufferedImage(ret.getWidth(), ret.getHeight(), BufferedImage.TYPE_INT_RGB); + drawIcon(mask, hIcon, User32.DI_MASK); + applyMask(ret, mask); + + + return ret; + } + + public static BufferedImage getShellIcon(String path) { + SHFILEINFO fi = new SHFILEINFO(); + BaseTSD.DWORD_PTR r = Shell32.INSTANCE.SHGetFileInfo(path, 0, fi, fi.size(), Shell32.SHGFI_ICON | Shell32.SHGFI_SMALLICON); + if (r.intValue() == 0) { + return null; + } + return iconToImage(fi.hIcon); + } + + public static BufferedImage extractExeIcon(String fullExeFile, int index, boolean large) { + PointerByReference iconsLargeRef = new PointerByReference(); + PointerByReference iconsSmallRef = new PointerByReference(); + int cnt = Shell32.INSTANCE.ExtractIconEx(fullExeFile, index, iconsLargeRef, iconsSmallRef, new WinDef.UINT(1)).intValue(); + if (cnt == 0) { + return null; + } + Pointer iconsLarge = iconsLargeRef.getPointer(); + Pointer iconsSmall = iconsSmallRef.getPointer(); + + WinDef.HICON icon; + if (large) { + icon = new WinDef.HICON(iconsLarge.getPointer(0)); + } else { + icon = new WinDef.HICON(iconsSmall.getPointer(0)); + } + + + BufferedImage ic = iconToImage(icon); + + User32.INSTANCE.DestroyIcon(icon); + return ic; + } + + public static List listProcesses() { + if (!privAdjusted) { + adjustPrivileges(); + } + List ret = new ArrayList<>(); + WinNT.HANDLE hSnapShot = Kernel32.INSTANCE.CreateToolhelp32Snapshot(new WinDef.DWORD(Kernel32.TH32CS_SNAPPROCESS), new WinDef.DWORD(0)); + PROCESSENTRY32 pe = new PROCESSENTRY32(); + if (Kernel32.INSTANCE.Process32First(hSnapShot, pe)) { + do { + int i; + i = 0; + for (; i < pe.szExeFile.length; i++) { + if (pe.szExeFile[i] == 0) { + break; + } + } + String exeFile = new String(pe.szExeFile, 0, i); + char[] outputnames = new char[1024]; + WinNT.HANDLE tempProcess = Kernel32.INSTANCE.OpenProcess(Kernel32.PROCESS_QUERY_INFORMATION, false, pe.th32ProcessID); + if (tempProcess == null) { + continue; + } + + + try { + int rn = Psapi.INSTANCE.GetProcessImageFileNameW(tempProcess, outputnames, 1024); + if (rn == 0) { + Logger.getLogger(Win32ProcessTools.class.getName()).log(Level.SEVERE, "Can't get EXE path"); + } + } catch (Exception | UnsatisfiedLinkError e) { + } + + try { + int rn = Kernel32.INSTANCE.GetProcessImageFileNameW(tempProcess, outputnames, 1024); + if (rn == 0) { + Logger.getLogger(Win32ProcessTools.class.getName()).log(Level.SEVERE, "Can't get EXE path"); + } + } catch (Exception | UnsatisfiedLinkError e) { + } + i = 0; + for (; i < outputnames.length; i++) { + if (outputnames[i] == 0) { + break; + } + } + String fullExeFile = new String(outputnames, 0, i); + fullExeFile = ntPathToWin32(fullExeFile); + ret.add(new Win32Process(fullExeFile, exeFile, getShellIcon(fullExeFile), pe.th32ProcessID)); + } while (Kernel32.INSTANCE.Process32Next(hSnapShot, pe)); + } + return ret; + } + + private static boolean pageReadable(MEMORY_BASIC_INFORMATION mbi) { + int iUnReadable = 0; + iUnReadable |= (mbi.state.intValue() == Kernel32.MEM_FREE) ? 1 : 0; + iUnReadable |= (mbi.state.intValue() == Kernel32.MEM_RESERVE) ? 1 : 0; + iUnReadable |= (mbi.protect.intValue() & WinNT.PAGE_WRITECOPY); + iUnReadable |= (mbi.protect.intValue() & WinNT.PAGE_EXECUTE); + iUnReadable |= (mbi.protect.intValue() & WinNT.PAGE_GUARD); + iUnReadable |= (mbi.protect.intValue() & WinNT.PAGE_NOACCESS); + return iUnReadable == 0; + } + + public static Map findBytesInProcessMemory(ProgressListener progListener, WinDef.DWORD dwProcessID, byte[][] findBytesAll) { + int maxFindLen = 0; + for (int i = 0; i < findBytesAll.length; i++) { + if (findBytesAll[i].length > maxFindLen) { + maxFindLen = findBytesAll[i].length; + } + } + Map ret = new HashMap<>(); + WinNT.HANDLE hOtherProcess = Kernel32.INSTANCE.OpenProcess(Kernel32.PROCESS_VM_READ | Kernel32.PROCESS_VM_WRITE | Kernel32.PROCESS_QUERY_INFORMATION | Kernel32.PROCESS_VM_OPERATION /*for VirtualProtectEx*/, false, dwProcessID); + List pages = getPageRanges(hOtherProcess); + long totalMemLen = 0; + int progress = 0; + for (int pg = 0; pg < pages.size(); pg++) { + totalMemLen += pages.get(pg).regionSize.longValue(); + } + + long actualPos = 0; + byte prevBytes[] = new byte[0]; + List guardedPages = new ArrayList<>(); + for (int pg = 0; pg < pages.size(); pg++) { + MEMORY_BASIC_INFORMATION mbi = pages.get(pg); + if (pageReadable(mbi)) { + int addr = (int) pointerToAddress(mbi.baseAddress); + int maxsize = mbi.regionSize.intValue(); + int pos = 0; + int bufSize = 1024; + do { + IntByReference bytesReadRef = new IntByReference(); + Memory buf = new Memory(bufSize); + boolean ok = Kernel32.INSTANCE.ReadProcessMemory(hOtherProcess, addr + pos, buf, bufSize, bytesReadRef); + if (!ok) { + break; + } + if (bytesReadRef.getValue() == 0) { + break; + } + + byte data[] = buf.getByteArray(0, bytesReadRef.getValue()); + + prevBytes = Arrays.copyOfRange(data, data.length - maxFindLen, data.length); + byte dataPlusPrev[] = mergeArrays(prevBytes, data); + loopi: + for (int i = 0; i < dataPlusPrev.length - maxFindLen; i++) { + loopk: + for (int k = 0; k < findBytesAll.length; k++) { + if (dataPlusPrev[i] == findBytesAll[k][0]) { + for (int p = 1; p < findBytesAll[k].length; p++) { + if (dataPlusPrev[i + p] != findBytesAll[k][p]) { + continue loopk; + } + } + long dataAddr = (long) (addr + pos - prevBytes.length + i); + ret.put(dataAddr, new ProcessMemoryInputStream(pages, hOtherProcess, pg, pos - prevBytes.length + i)); + } + } + + } + pos += bytesReadRef.getValue(); + if (progListener != null) { + int newprogress = Math.round((actualPos + pos) * 100 / totalMemLen); + if (newprogress != progress) { + progress = newprogress; + progListener.progress(progress); + } + } + if (pos + bufSize >= maxsize) { + bufSize = maxsize - pos; + } + } while (bufSize > 0); + } else { + if (hasGuard(mbi)) { + if (unsetGuard(hOtherProcess, mbi)) { + guardedPages.add(pg); + pg--; + continue; + } + } + } + actualPos += mbi.regionSize.longValue(); + int newprogress = Math.round(actualPos * 100 / totalMemLen); + if (newprogress != progress) { + progress = newprogress; + progListener.progress(progress); + } + } + + //Set PAGE_GUARD back again + for (int pg : guardedPages) { + setGuard(hOtherProcess, pages.get(pg)); + } + return ret; + } + + private static boolean hasGuard(MEMORY_BASIC_INFORMATION mbi) { + return (mbi.protect.intValue() & WinNT.PAGE_GUARD) == WinNT.PAGE_GUARD; + } + + private static boolean unsetGuard(HANDLE hOtherProcess, MEMORY_BASIC_INFORMATION mbi) { + if (!hasGuard(mbi)) { + return true; + } + int oldProt = mbi.protect.intValue(); + int newProt = oldProt - WinNT.PAGE_GUARD; + IntByReference oldProtRef = new IntByReference(); + boolean ok = Kernel32.INSTANCE.VirtualProtectEx(hOtherProcess, new WinDef.LPVOID(pointerToAddress(mbi.baseAddress)), mbi.regionSize, newProt, oldProtRef); + if (ok) { + mbi.protect = new NativeLong(newProt); + return true; + } + return false; + } + + private static boolean setGuard(HANDLE hOtherProcess, MEMORY_BASIC_INFORMATION mbi) { + if (hasGuard(mbi)) { + return true; + } + int oldProt = mbi.protect.intValue(); + int newProt = oldProt | WinNT.PAGE_GUARD; + IntByReference oldProtRef = new IntByReference(); + boolean ok = Kernel32.INSTANCE.VirtualProtectEx(hOtherProcess, new WinDef.LPVOID(pointerToAddress(mbi.baseAddress)), mbi.regionSize, newProt, oldProtRef); + if (ok) { + mbi.protect = new NativeLong(newProt); + return true; + } + return false; + } + private static boolean privAdjusted = false; + + public static boolean adjustPrivileges() { + + WinNT.TOKEN_PRIVILEGES tp = new WinNT.TOKEN_PRIVILEGES(1); + WinNT.TOKEN_PRIVILEGES oldtp = new WinNT.TOKEN_PRIVILEGES(1); + WinNT.LUID luid = new WinNT.LUID(); + WinNT.HANDLEByReference hTokenRef = new WinNT.HANDLEByReference(); + if (!Advapi32.INSTANCE.OpenProcessToken(Kernel32.INSTANCE.GetCurrentProcess(), WinNT.TOKEN_ADJUST_PRIVILEGES | WinNT.TOKEN_QUERY, hTokenRef)) { + return false; + } + WinNT.HANDLE hToken = hTokenRef.getValue(); + if (!Advapi32.INSTANCE.LookupPrivilegeValue(null, WinNT.SE_DEBUG_NAME, luid)) { + Kernel32.INSTANCE.CloseHandle(hToken); + return false; + } + + tp.PrivilegeCount = new WinDef.DWORD(1); + tp.Privileges = new WinNT.LUID_AND_ATTRIBUTES[1]; + tp.Privileges[0] = new WinNT.LUID_AND_ATTRIBUTES(luid, new WinDef.DWORD(WinNT.SE_PRIVILEGE_ENABLED)); + + IntByReference retSize = new IntByReference(0); + if (!Advapi32.INSTANCE.AdjustTokenPrivileges(hToken, false, tp, tp.size(), oldtp, retSize)) { + Kernel32.INSTANCE.CloseHandle(hToken); + return false; + } + Kernel32.INSTANCE.CloseHandle(hToken); + privAdjusted = true; + return true; + } + + private static class ProcessMemoryInputStream extends InputStream { + + private List pages; + private int currentPage = 0; + private int pagePos = 0; + private static int BUFFER_SIZE = 1024; + private byte buf[]; + private int bufPos; + private HANDLE hOtherProcess; + + public ProcessMemoryInputStream(List pages, HANDLE hOtherProcess, int currentPage, int pagePos) { + this.pages = pages; + this.hOtherProcess = hOtherProcess; + this.currentPage = currentPage; + this.pagePos = pagePos; + } + + private boolean readNext() throws IOException { + MEMORY_BASIC_INFORMATION mbi = pages.get(currentPage); + if (!pageReadable(mbi)) { + if (hasGuard(mbi)) { + if (unsetGuard(hOtherProcess, mbi)) { + boolean ret = readNext(); + setGuard(hOtherProcess, mbi); + return ret; + } + } + if (currentPage + 1 < pages.size()) { + pagePos = 0; + currentPage++; + return readNext(); + } + return false; + } + int addr = (int) pointerToAddress(mbi.baseAddress); + int maxsize = mbi.regionSize.intValue(); + IntByReference bytesReadRef = new IntByReference(); + Memory membuf = new Memory(BUFFER_SIZE); + int bufSize = BUFFER_SIZE; + if (pagePos + bufSize > maxsize) { + bufSize = maxsize - pagePos; + } + if (bufSize == 0) { + if (currentPage + 1 < pages.size()) { + pagePos = 0; + currentPage++; + return readNext(); + } + return false; + } + boolean ok = Kernel32.INSTANCE.ReadProcessMemory(hOtherProcess, addr + pagePos, membuf, bufSize, bytesReadRef); + if (!ok) { + throw new IOException("Cannot read memory"); + } + if (bytesReadRef.getValue() == 0) { + return readNext(); + } + pagePos += bytesReadRef.getValue(); + + buf = membuf.getByteArray(0, bytesReadRef.getValue()); + return true; + } + + @Override + public int read() throws IOException { + if ((buf == null) || (bufPos >= buf.length)) { + if (buf != null) { + bufPos = 0; + } + if (!readNext()) { + return -1; + } + } + + return buf[bufPos++] & 0xff; + } + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32.java b/trunk/src/com/sun/jna/platform/win32/Advapi32.java similarity index 97% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32.java rename to trunk/src/com/sun/jna/platform/win32/Advapi32.java index 3c8230f6c..756ccd4e4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32.java +++ b/trunk/src/com/sun/jna/platform/win32/Advapi32.java @@ -14,7 +14,7 @@ * 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.jna.platform.win32; +package com.sun.jna.platform.win32; /** * @@ -32,14 +32,14 @@ package com.jpexs.decompiler.flash.gui.jna.platform.win32; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLEByReference; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg.HKEY; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg.HKEYByReference; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; +import com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.platform.win32.WinNT.HANDLEByReference; +import com.sun.jna.platform.win32.WinReg.HKEY; +import com.sun.jna.platform.win32.WinReg.HKEYByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32Util.java b/trunk/src/com/sun/jna/platform/win32/Advapi32Util.java similarity index 96% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32Util.java rename to trunk/src/com/sun/jna/platform/win32/Advapi32Util.java index 7b334ddb3..fd75fe423 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32Util.java +++ b/trunk/src/com/sun/jna/platform/win32/Advapi32Util.java @@ -14,18 +14,18 @@ * 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.jna.platform.win32; +package com.sun.jna.platform.win32; /** * * @author JPEXS */ -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.EVENTLOGRECORD; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg.HKEY; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg.HKEYByReference; import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.Pointer; +import com.sun.jna.platform.win32.WinNT.EVENTLOGRECORD; +import com.sun.jna.platform.win32.WinReg.HKEY; +import com.sun.jna.platform.win32.WinReg.HKEYByReference; import com.sun.jna.ptr.IntByReference; import java.util.ArrayList; import java.util.Map; diff --git a/trunk/src/com/sun/jna/platform/win32/BITMAP.java b/trunk/src/com/sun/jna/platform/win32/BITMAP.java new file mode 100644 index 000000000..73a2ef17c --- /dev/null +++ b/trunk/src/com/sun/jna/platform/win32/BITMAP.java @@ -0,0 +1,32 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.sun.jna.platform.win32; + +import com.sun.jna.Structure; +import com.sun.jna.platform.win32.WinDef.LONG; +import com.sun.jna.platform.win32.WinDef.LPVOID; +import com.sun.jna.platform.win32.WinDef.WORD; +import java.util.Arrays; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class BITMAP extends Structure { + + public LONG bmType; + public LONG bmWidth; + public LONG bmHeight; + public LONG bmWidthBytes; + public WORD bmPlanes; + public WORD bmBitsPixel; + public LPVOID bmBits; + + @Override + protected List getFieldOrder() { + return Arrays.asList("bmType", "bmWidth", "bmHeight", "bmWidthBytes", "bmPlanes", "bmBitsPixel", "bmBits"); + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/BaseTSD.java b/trunk/src/com/sun/jna/platform/win32/BaseTSD.java similarity index 94% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/BaseTSD.java rename to trunk/src/com/sun/jna/platform/win32/BaseTSD.java index c7f2c3b01..df2a9c7b5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/BaseTSD.java +++ b/trunk/src/com/sun/jna/platform/win32/BaseTSD.java @@ -10,7 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -package com.jpexs.decompiler.flash.gui.jna.platform.win32; +package com.sun.jna.platform.win32; import com.sun.jna.IntegerType; import com.sun.jna.Pointer; diff --git a/trunk/src/com/sun/jna/platform/win32/Gdi32.java b/trunk/src/com/sun/jna/platform/win32/Gdi32.java new file mode 100644 index 000000000..3f836a055 --- /dev/null +++ b/trunk/src/com/sun/jna/platform/win32/Gdi32.java @@ -0,0 +1,320 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.sun.jna.platform.win32; + +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.platform.win32.WinDef.DWORD; +import com.sun.jna.platform.win32.WinDef.HBITMAP; +import com.sun.jna.platform.win32.WinDef.HDC; +import com.sun.jna.platform.win32.WinDef.HRGN; +import com.sun.jna.platform.win32.WinGDI.BITMAPINFO; +import com.sun.jna.platform.win32.WinGDI.BITMAPINFOHEADER; +import com.sun.jna.platform.win32.WinGDI.RGNDATA; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.ptr.PointerByReference; +import com.sun.jna.win32.StdCallLibrary; +import com.sun.jna.win32.W32APIOptions; + +/** + * Definition (incomplete) of + * gdi32.dll. + */ +public interface Gdi32 extends StdCallLibrary { + + Gdi32 INSTANCE = (Gdi32) Native.loadLibrary("gdi32", Gdi32.class, + W32APIOptions.DEFAULT_OPTIONS); + + /** + * The ExtCreateRegion function creates a region from the specified region + * and transformation data. + * + * @param lpXform Pointer to an XFORM structure that defines the + * transformation to be performed on the region. If this pointer is NULL, + * the identity transformation is used. + * @param nCount Specifies the number of bytes pointed to by lpRgnData. + * @param lpRgnData Pointer to a RGNDATA structure that contains the region + * data in logical units. + * @return If the function succeeds, the return value is the value of the + * region. If the function fails, the return value is NULL. To get extended + * error information, call GetLastError. + */ + public HRGN ExtCreateRegion(Pointer lpXform, int nCount, RGNDATA lpRgnData); + + /** + * The CombineRgn function combines two regions and stores the result in a + * third region. The two regions are combined according to the specified + * mode. + * + * @param hrgnDest Handle to a new region with dimensions defined by + * combining two other regions. + * @param hrgnSrc1 Handle to the first of two regions to be combined. + * @param hrgnSrc2 Handle to the second of two regions to be combined. + * @param fnCombineMode Specifies a mode indicating how the two regions will + * be combined. + * @return The return value specifies the type of the resulting region. + */ + int CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2, + int fnCombineMode); + + /** + * The CreateRectRgn function creates a rectangular region. + * + * @param nLeftRect Specifies the x-coordinate of the upper-left corner of + * the region in logical units. + * @param nTopRect Specifies the y-coordinate of the upper-left corner of + * the region in logical units. + * @param nRightRect Specifies the x-coordinate of the lower-right corner of + * the region in logical units. + * @param nBottomRect Specifies the y-coordinate of the lower-right corner + * of the region in logical units. + * @return If the function succeeds, the return value is the handle to the + * region. If the function fails, the return value is NULL. To get extended + * error information, call GetLastError. + */ + HRGN CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, + int nBottomRect); + + /** + * The CreateRoundRectRgn function creates a rectangular region with rounded + * corners. + * + * @param nLeftRect Specifies the x-coordinate of the upper-left corner of + * the region in logical units. + * @param nTopRect Specifies the y-coordinate of the upper-left corner of + * the region in logical units. + * @param nRightRect Specifies the x-coordinate of the lower-right corner of + * the region in logical units. + * @param nBottomRect Specifies the y-coordinate of the lower-right corner + * of the region in logical units. + * @param nWidthEllipse Specifies the width of the ellipse used to create + * the rounded corners in logical units. + * @param nHeightEllipse Specifies the height of the ellipse used to create + * the rounded corners in logical units. + * @return If the function succeeds, the return value is the handle to the + * region. If the function fails, the return value is NULL. To get extended + * error information, call GetLastError. + */ + HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect, + int nBottomRect, int nWidthEllipse, int nHeightEllipse); + + /** + * The CreatePolyPolygonRgn function creates a region consisting of a series + * of polygons. The polygons can overlap. + * + * @param lppt Pointer to an array of POINT structures that define the + * vertices of the polygons in logical units. The polygons are specified + * consecutively. Each polygon is presumed closed and each vertex is + * specified only once. + * @param lpPolyCounts Pointer to an array of integers, each of which + * specifies the number of points in one of the polygons in the array + * pointed to by lppt. + * @param nCount Specifies the total number of integers in the array pointed + * to by lpPolyCounts. + * @param fnPolyFillMode Specifies the fill mode used to determine which + * pixels are in the region. + * @return If the function succeeds, the return value is the handle to the + * region. If the function fails, the return value is zero. To get extended + * error information, call GetLastError. + */ + HRGN CreatePolyPolygonRgn(WinUser.POINT[] lppt, int[] lpPolyCounts, + int nCount, int fnPolyFillMode); + + /** + * The SetRectRgn function converts a region into a rectangular region with + * the specified coordinates. + * + * @param hrgn Handle to the region. + * @param nLeftRect Specifies the x-coordinate of the upper-left corner of + * the rectangular region in logical units. + * @param nTopRect Specifies the y-coordinate of the upper-left corner of + * the rectangular region in logical units. + * @param nRightRect Specifies the x-coordinate of the lower-right corner of + * the rectangular region in logical units. + * @param nBottomRect Specifies the y-coordinate of the lower-right corner + * of the rectangular region in logical units. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect, int nRightRect, + int nBottomRect); + + /** + * The SetPixel function sets the pixel at the specified coordinates to the + * specified color. + * + * @param hDC Handle to the device context. + * @param x Specifies the x-coordinate, in logical units, of the point to be + * set. + * @param y Specifies the y-coordinate, in logical units, of the point to be + * set. + * @param crColor Specifies the color to be used to paint the point. To + * create a COLORREF color value, use the RGB macro. + * @return If the function succeeds, the return value is the RGB value that + * the function sets the pixel to. This value may differ from the color + * specified by crColor; that occurs when an exact match for the specified + * color cannot be found. If the function fails, the return value is 1. To + * get extended error information, call GetLastError. This can be the + * following value. + */ + int SetPixel(HDC hDC, int x, int y, int crColor); + + /** + * The CreateCompatibleDC function creates a memory device context (DC) + * compatible with the specified device. + * + * @param hDC Handle to an existing DC. If this handle is NULL, the function + * creates a memory DC compatible with the application's current screen. + * @return If the function succeeds, the return value is the handle to a + * memory DC. If the function fails, the return value is NULL. To get + * extended error information, call GetLastError. + */ + HDC CreateCompatibleDC(HDC hDC); + + /** + * The DeleteDC function deletes the specified device context (DC). + * + * @param hDC Handle to the device context. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean DeleteDC(HDC hDC); + + /** + * The CreateDIBitmap function creates a compatible bitmap (DDB) from a DIB + * and, optionally, sets the bitmap bits. + * + * @param hDC Handle to a device context. + * @param lpbmih Pointer to a bitmap information header structure, which may + * be one of those shown in the following table. + * @param fdwInit Specifies how the system initializes the bitmap bits. + * @param lpbInit Pointer to an array of bytes containing the initial bitmap + * data. + * @param lpbmi Pointer to a BITMAPINFO structure that describes the + * dimensions and color format of the array pointed to by the lpbInit + * parameter. + * @param fuUsage Specifies whether the bmiColors member of the BITMAPINFO + * structure was initialized and, if so, whether bmiColors contains explicit + * red, green, blue (RGB) values or palette indexes. The fuUsage parameter + * must be one of the following values. + * @return If the function succeeds, the return value is a handle to the + * compatible bitmap. If the function fails, the return value is NULL. To + * get extended error information, call GetLastError. + */ + HBITMAP CreateDIBitmap(HDC hDC, BITMAPINFOHEADER lpbmih, int fdwInit, + Pointer lpbInit, BITMAPINFO lpbmi, int fuUsage); + + /** + * The CreateDIBSection function creates a DIB that applications can write + * to directly. The function gives you a pointer to the location of the + * bitmap bit values. You can supply a handle to a file-mapping object that + * the function will use to create the bitmap, or you can let the system + * allocate the memory for the bitmap. + * + * @param hDC Handle to a device context. If the value of iUsage is + * DIB_PAL_COLORS, the function uses this device context's logical palette + * to initialize the DIB colors. + * @param pbmi Pointer to a BITMAPINFO structure that specifies various + * attributes of the DIB, including the bitmap dimensions and colors. + * @param iUsage Specifies the type of data contained in the bmiColors array + * member of the BITMAPINFO structure pointed to by pbmi (either logical + * palette indexes or literal RGB values). + * @param ppvBits Pointer to a variable that receives a pointer to the + * location of the DIB bit values. + * @param hSection Handle to a file-mapping object that the function will + * use to create the DIB. This parameter can be NULL. + * @param dwOffset Specifies the offset from the beginning of the + * file-mapping object referenced by hSection where storage for the bitmap + * bit values is to begin. + * @return Specifies the offset from the beginning of the file-mapping + * object referenced by hSection where storage for the bitmap bit values is + * to begin. + */ + HBITMAP CreateDIBSection(HDC hDC, BITMAPINFO pbmi, int iUsage, + PointerByReference ppvBits, Pointer hSection, int dwOffset); + + /** + * The CreateCompatibleBitmap function creates a bitmap compatible with the + * device that is associated with the specified device context. + * + * @param hDC Handle to a device context. + * @param width Specifies the bitmap width, in pixels. + * @param height Specifies the bitmap height, in pixels. + * @return If the function succeeds, the return value is a handle to the + * compatible bitmap (DDB). If the function fails, the return value is NULL. + * To get extended error information, call GetLastError. + */ + HBITMAP CreateCompatibleBitmap(HDC hDC, int width, int height); + + /** + * The SelectObject function selects an object into the specified device + * context (DC). The new object replaces the previous object of the same + * type. + * + * @param hDC Handle to the DC. + * @param hGDIObj Handle to the object to be selected. + * @return If the selected object is not a region and the function succeeds, + * the return value is a handle to the object being replaced. If the + * selected object is a region and the function succeeds, the return value + * is one of the REGION values. + */ + HANDLE SelectObject(HDC hDC, HANDLE hGDIObj); + + /** + * The DeleteObject function deletes a logical pen, brush, font, bitmap, + * region, or palette, freeing all system resources associated with the + * object. After the object is deleted, the specified handle is no longer + * valid. + * + * @param hObject Handle to a logical pen, brush, font, bitmap, region, or + * palette. + * @return If the function succeeds, the return value is nonzero. If the + * specified handle is not valid or is currently selected into a DC, the + * return value is zero. To get extended error information, call + * GetLastError. + */ + boolean DeleteObject(HANDLE hObject); + + /** + * The GetDeviceCaps function retrieves device-specific information for the + * specified device. + * + * @param hdc A handle to the DC. + * @param nIndex The item to be returned. + * @return The return value specifies the value of the desired item. When + * nIndex is BITSPIXEL and the device has 15bpp or + * 16bpp, the return value is 16. + */ + int GetDeviceCaps(HDC hdc, int nIndex); + + /** + * The GetDIBits function retrieves the bits fo the specified compatible + * bitmap and copies them into a buffer as a DIB using the specified format. + * + * @param hdc A handle to the device context. + * @param hbmp A handle to the bitmap. This must be a compatible bitmap + * (DDB). + * @param uStartScan The first scan line to retrieve + * @param cScanLines The number of scan lines to retrieve. + * @param lpvBits A pointer to a buffer to receive the bitmap data. If this + * parameter is null, the function passes the dimensions and + * format of the bitmap to the {@link BITMAPINFO} structure pointed to by + * the lpbi parameter. + * @param lpbi A pointer to a {@link BITMAPINFO} structure that specifies + * the desired format for the DIB data. + * @param uUsage The format of the bmiColors member of the {@link + * BITMAPINFO} structure. + */ + int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, Pointer lpvBits, BITMAPINFO lpbi, int uUsage); + + int GetObject(HANDLE hgdiobj, int cbBuffer, Structure lpvObject); + + DWORD GetPixel(HDC hdc, int nXPos, int nYPos); + + HANDLE CreateSolidBrush(DWORD crColor); +} \ No newline at end of file diff --git a/trunk/src/com/sun/jna/platform/win32/ICONINFO.java b/trunk/src/com/sun/jna/platform/win32/ICONINFO.java new file mode 100644 index 000000000..2148a019e --- /dev/null +++ b/trunk/src/com/sun/jna/platform/win32/ICONINFO.java @@ -0,0 +1,29 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.sun.jna.platform.win32; + +import com.sun.jna.Structure; +import com.sun.jna.platform.win32.WinDef.DWORD; +import com.sun.jna.platform.win32.WinDef.HBITMAP; +import java.util.Arrays; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class ICONINFO extends Structure { + + public boolean fIcon; + public DWORD xHotspot; + public DWORD yHotspot; + public HBITMAP hbmMask; + public HBITMAP hbmColor; + + @Override + protected List getFieldOrder() { + return Arrays.asList("fIcon", "xHotspot", "yHotspot", "hbmMask", "hbmColor"); + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Kernel32.java b/trunk/src/com/sun/jna/platform/win32/Kernel32.java similarity index 54% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Kernel32.java rename to trunk/src/com/sun/jna/platform/win32/Kernel32.java index 4fd2e90bd..1adcee34a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Kernel32.java +++ b/trunk/src/com/sun/jna/platform/win32/Kernel32.java @@ -10,9 +10,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -package com.jpexs.decompiler.flash.gui.jna.platform.win32; +package com.sun.jna.platform.win32; import com.sun.jna.Native; +import com.sun.jna.Pointer; import com.sun.jna.ptr.IntByReference; import com.sun.jna.win32.W32APIOptions; @@ -161,4 +162,123 @@ public interface Kernel32 extends WinNT { * that caused the function to return. */ int WaitForSingleObject(HANDLE hHandle, int dwMilliseconds); + + /** + * This function returns a pseudohandle for the current process. + * + * @return The return value is a pseudohandle to the current process. + */ + HANDLE GetCurrentProcess(); + + /** + * This function returns a handle to an existing process object. + * + * @param fdwAccess Not supported; set to zero. + * @param fInherit Not supported; set to FALSE. + * @param IDProcess Specifies the process identifier of the process to open. + * @return An open handle to the specified process indicates success. NULL + * indicates failure. To get extended error information, call GetLastError. + */ + HANDLE OpenProcess(int fdwAccess, boolean fInherit, DWORD IDProcess); + + /** + * The GetSystemInfo function returns information about the current system. + * + * @param lpSystemInfo Pointer to a SYSTEM_INFO structure that receives the + * information. + */ + void GetSystemInfo(SYSTEM_INFO lpSystemInfo); + public static final int PROCESS_VM_READ = 0x0010; + public static final int PROCESS_VM_WRITE = 0x0020; + public static final int PROCESS_QUERY_INFORMATION = 0x0400; + public static final int PROCESS_VM_OPERATION = 0x0008; + + SIZE_T VirtualQueryEx(HANDLE hProcess, Pointer lpAddress, MEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength); + + /** + * The GetLastError function retrieves the calling thread's last-error code + * value. The last-error code is maintained on a per-thread basis. Multiple + * threads do not overwrite each other's last-error code. + * + * @return The return value is the calling thread's last-error code value. + */ + int GetLastError(); + public static int MEM_COMMIT = 0x1000; + public static int MEM_FREE = 0x10000; + public static int MEM_RESERVE = 0x2000; + public static int MEM_IMAGE = 0x1000000; + public static int MEM_MAPPED = 0x40000; + public static int MEM_PRIVATE = 0x20000; + + boolean ReadProcessMemory(HANDLE hProcess, int inBaseAddress, Pointer outputBuffer, int nSize, IntByReference outNumberOfBytesRead); + + /** + * Takes a snapshot of the specified processes, as well as the heaps, + * modules, and threads used by these processes. + * + * @param dwFlags The portions of the system to be included in the snapshot. + * + * @param th32ProcessID The process identifier of the process to be included + * in the snapshot. This parameter can be zero to indicate the current + * process. This parameter is used when the TH32CS_SNAPHEAPLIST, + * TH32CS_SNAPMODULE, TH32CS_SNAPMODULE32, or TH32CS_SNAPALL value is + * specified. Otherwise, it is ignored and all processes are included in the + * snapshot. + * + * If the specified process is the Idle process or one of the CSRSS + * processes, this function fails and the last error code is + * ERROR_ACCESS_DENIED because their access restrictions prevent user-level + * code from opening them. + * + * If the specified process is a 64-bit process and the caller is a 32-bit + * process, this function fails and the last error code is + * ERROR_PARTIAL_COPY (299). + * + * @return If the function succeeds, it returns an open handle to the + * specified snapshot. + * + * If the function fails, it returns INVALID_HANDLE_VALUE. To get extended + * error information, call GetLastError. Possible error codes include + * ERROR_BAD_LENGTH. + */ + HANDLE CreateToolhelp32Snapshot(DWORD dwFlags, DWORD th32ProcessID); + + /** + * Retrieves information about the first process encountered in a system + * snapshot. + * + * @param hSnapshot A handle to the snapshot returned from a previous call + * to the CreateToolhelp32Snapshot function. + * @param lppe A pointer to a PROCESSENTRY32 structure. It contains process + * information such as the name of the executable file, the process + * identifier, and the process identifier of the parent process. + * @return Returns TRUE if the first entry of the process list has been + * copied to the buffer or FALSE otherwise. The ERROR_NO_MORE_FILES error + * value is returned by the GetLastError function if no processes exist or + * the snapshot does not contain process information. + */ + boolean Process32First(HANDLE hSnapshot, PROCESSENTRY32 lppe); + + /** + * Retrieves information about the next process recorded in a system + * snapshot. + * + * @param hSnapshot A handle to the snapshot returned from a previous call + * to the CreateToolhelp32Snapshot function. + * @param lppe A pointer to a PROCESSENTRY32 structure. + * @return Returns TRUE if the next entry of the process list has been + * copied to the buffer or FALSE otherwise. The ERROR_NO_MORE_FILES error + * value is returned by the GetLastError function if no processes exist or + * the snapshot does not contain process information. + */ + boolean Process32Next(HANDLE hSnapshot, PROCESSENTRY32 lppe); + public static int TH32CS_SNAPPROCESS = 0x00000002; + + //Needed for some Windows 7 Versions + //boolean EnumProcesses(int []ProcessIDsOut,int size , int[] BytesReturned); + int GetProcessImageFileNameW(HANDLE Process, char[] outputname, int lenght); + + DWORD QueryDosDevice(String lpDeviceName, char[] lpTargetPath, int lenght); + + boolean VirtualProtectEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, int flNewProtect, IntByReference lpflOldProtect); } diff --git a/trunk/src/com/sun/jna/platform/win32/MEMORY_BASIC_INFORMATION.java b/trunk/src/com/sun/jna/platform/win32/MEMORY_BASIC_INFORMATION.java new file mode 100644 index 000000000..0755b5134 --- /dev/null +++ b/trunk/src/com/sun/jna/platform/win32/MEMORY_BASIC_INFORMATION.java @@ -0,0 +1,33 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.sun.jna.platform.win32; + +import com.sun.jna.NativeLong; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.platform.win32.BaseTSD.SIZE_T; +import java.util.Arrays; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class MEMORY_BASIC_INFORMATION extends Structure { + + public Pointer baseAddress; + public Pointer allocationBase; + public NativeLong allocationProtect; + public SIZE_T regionSize; + public NativeLong state; + public NativeLong protect; + public NativeLong type; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"baseAddress", "allocationBase", "allocationProtect", + "regionSize", "state", "protect", "type"}); + } +} diff --git a/trunk/src/com/sun/jna/platform/win32/PROCESSENTRY32.java b/trunk/src/com/sun/jna/platform/win32/PROCESSENTRY32.java new file mode 100644 index 000000000..17404e1e6 --- /dev/null +++ b/trunk/src/com/sun/jna/platform/win32/PROCESSENTRY32.java @@ -0,0 +1,85 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.sun.jna.platform.win32; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import java.util.Arrays; +import java.util.List; + +public class PROCESSENTRY32 extends Structure { + + public static class ByReference extends PROCESSENTRY32 implements Structure.ByReference { + + public ByReference() { + } + + public ByReference(Pointer memory) { + super(memory); + } + } + + public PROCESSENTRY32() { + dwSize = new WinDef.DWORD(size()); + } + + public PROCESSENTRY32(Pointer memory) { + super(memory); + read(); + } + /** + * The size of the structure, in bytes. Before calling the Process32First + * function, set this member to sizeof(PROCESSENTRY32). If you do not + * initialize dwSize, Process32First fails. + */ + public WinDef.DWORD dwSize; + /** + * This member is no longer used and is always set to zero. + */ + public WinDef.DWORD cntUsage; + /** + * The process identifier. + */ + public WinNT.DWORD th32ProcessID; + /** + * This member is no longer used and is always set to zero. + */ + public BaseTSD.ULONG_PTR th32DefaultHeapID; + /** + * This member is no longer used and is always set to zero. + */ + public WinDef.DWORD th32ModuleID; + /** + * The number of execution threads started by the process. + */ + public WinDef.DWORD cntThreads; + /** + * The identifier of the process that created this process (its parent + * process). + */ + public WinDef.DWORD th32ParentProcessID; + /** + * The base priority of any threads created by this process. + */ + public WinDef.LONG pcPriClassBase; + /** + * This member is no longer used, and is always set to zero. + */ + public WinDef.DWORD dwFlags; + /** + * The name of the executable file for the process. To retrieve the full + * path to the executable file, call the Module32First function and check + * the szExePath member of the MODULEENTRY32 structure that is returned. + * However, if the calling process is a 32-bit process, you must call the + * QueryFullProcessImageName function to retrieve the full path of the + * executable file for a 64-bit process. + */ + public char[] szExeFile = new char[WinDef.MAX_PATH]; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"dwSize", "cntUsage", "th32ProcessID", "th32DefaultHeapID", "th32ModuleID", "cntThreads", "th32ParentProcessID", "pcPriClassBase", "dwFlags", "szExeFile"}); + } +} diff --git a/trunk/src/com/sun/jna/platform/win32/Psapi.java b/trunk/src/com/sun/jna/platform/win32/Psapi.java new file mode 100644 index 000000000..a53c9721e --- /dev/null +++ b/trunk/src/com/sun/jna/platform/win32/Psapi.java @@ -0,0 +1,22 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.sun.jna.platform.win32; + +import com.sun.jna.Native; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.win32.StdCallLibrary; + +/** + * + * @author petrik + */ +public interface Psapi extends StdCallLibrary { + + Psapi INSTANCE = (Psapi) Native.loadLibrary("Psapi", Psapi.class); +//For some Windows 7 Versions and older down to XP + //boolean EnumProcesses(int[] ProcessIDsOut, int size, int[] BytesReturned); + + int GetProcessImageFileNameW(HANDLE Process, char[] outputname, int lenght); +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/SHELLEXECUTEINFO.java b/trunk/src/com/sun/jna/platform/win32/SHELLEXECUTEINFO.java similarity index 70% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/SHELLEXECUTEINFO.java rename to trunk/src/com/sun/jna/platform/win32/SHELLEXECUTEINFO.java index 2f06a8846..fa58929f8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/SHELLEXECUTEINFO.java +++ b/trunk/src/com/sun/jna/platform/win32/SHELLEXECUTEINFO.java @@ -1,12 +1,12 @@ -package com.jpexs.decompiler.flash.gui.jna.platform.win32; +package com.sun.jna.platform.win32; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HINSTANCE; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HWND; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg.HKEY; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.WString; +import com.sun.jna.platform.win32.WinDef.HINSTANCE; +import com.sun.jna.platform.win32.WinDef.HWND; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.platform.win32.WinReg.HKEY; import java.util.Arrays; import java.util.List; diff --git a/trunk/src/com/sun/jna/platform/win32/SHFILEINFO.java b/trunk/src/com/sun/jna/platform/win32/SHFILEINFO.java new file mode 100644 index 000000000..b8b4213cb --- /dev/null +++ b/trunk/src/com/sun/jna/platform/win32/SHFILEINFO.java @@ -0,0 +1,29 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.sun.jna.platform.win32; + +import com.sun.jna.Structure; +import com.sun.jna.platform.win32.WinDef.DWORD; +import com.sun.jna.platform.win32.WinDef.HICON; +import java.util.Arrays; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class SHFILEINFO extends Structure { + + public HICON hIcon; + public int iIcon; + public DWORD dwAttributes; + public char[] szDisplayName = new char[260]; + public char[] szTypeName = new char[80]; + + @Override + protected List getFieldOrder() { + return Arrays.asList("hIcon", "iIcon", "dwAttributes", "szDisplayName", "szTypeName"); + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Shell32.java b/trunk/src/com/sun/jna/platform/win32/Shell32.java similarity index 65% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Shell32.java rename to trunk/src/com/sun/jna/platform/win32/Shell32.java index fce08e85d..51068b762 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Shell32.java +++ b/trunk/src/com/sun/jna/platform/win32/Shell32.java @@ -10,9 +10,12 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -package com.jpexs.decompiler.flash.gui.jna.platform.win32; +package com.sun.jna.platform.win32; import com.sun.jna.Native; +import com.sun.jna.platform.win32.BaseTSD.DWORD_PTR; +import com.sun.jna.platform.win32.WinDef.UINT; +import com.sun.jna.ptr.PointerByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; @@ -28,4 +31,10 @@ public interface Shell32 extends StdCallLibrary { * @return true if successful. Otherwise false. */ boolean ShellExecuteEx(SHELLEXECUTEINFO lpExecInfo); + + UINT ExtractIconEx(String lpszFile, int nIconIndex, PointerByReference phiconLarge, PointerByReference phiconSmall, UINT nIcons); + + DWORD_PTR SHGetFileInfo(String pszPath, int dwFileAttributes, SHFILEINFO psfi, int cbFileInfo, int uFlags); + public static final int SHGFI_ICON = 0x000000100; + public static final int SHGFI_SMALLICON = 0x000000001; } diff --git a/trunk/src/com/sun/jna/platform/win32/User32.java b/trunk/src/com/sun/jna/platform/win32/User32.java new file mode 100644 index 000000000..19f7fd66d --- /dev/null +++ b/trunk/src/com/sun/jna/platform/win32/User32.java @@ -0,0 +1,1518 @@ +/* Copyright (c) 2007, 2013 Timothy Wall, Markus Karg, 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.Native; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.WString; +import com.sun.jna.platform.win32.BaseTSD.LONG_PTR; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.ptr.ByteByReference; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.win32.StdCallLibrary; +import com.sun.jna.win32.W32APIOptions; + +/** + * Provides access to the w32 user32 library. Incomplete implementation to + * support demos. + * + * @author Todd Fast, todd.fast@sun.com + * @author twalljava@dev.java.net + * @author Tobias Wolf, wolf.tobias@gmx.net + * @author Markus KARG (markus[at]headcrashing[dot]eu) + */ +public interface User32 extends StdCallLibrary, WinUser { + + /** + * The instance. + */ + User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class, + W32APIOptions.DEFAULT_OPTIONS); + /** + * Handle for message-only window. + */ + public static final HWND HWND_MESSAGE = new HWND(Pointer.createConstant(-3)); + /** + * The cs globalclass. + */ + int CS_GLOBALCLASS = 0x4000; + /** + * The ws ex topmost. + */ + int WS_EX_TOPMOST = 0x00000008; + /** + * The ws overlapped. + */ + int WS_OVERLAPPED = 0x00000000; + /** + * The hRecipient parameter is a window handle. + */ + int DEVICE_NOTIFY_WINDOW_HANDLE = 0x00000000; + /** + * The hRecipient parameter is a service status handle. + */ + int DEVICE_NOTIFY_SERVICE_HANDLE = 0x00000001; + /** + * The device notify all interface classes. + */ + int DEVICE_NOTIFY_ALL_INTERFACE_CLASSES = 0x00000004; + + /** + * This function retrieves a handle to a display device context (DC) for the + * client area of the specified window. The display device context can be + * used in subsequent graphics display interface (GDI) functions to draw in + * the client area of the window. + * + * @param hWnd Handle to the window whose device context is to be retrieved. + * If this value is NULL, GetDC retrieves the device context for the entire + * screen. + * @return The handle the device context for the specified window's client + * area indicates success. NULL indicates failure. To get extended error + * information, call GetLastError. + */ + HDC GetDC(HWND hWnd); + + /** + * This function releases a device context (DC), freeing it for use by other + * applications. The effect of ReleaseDC depends on the type of device + * context. + * + * @param hWnd Handle to the window whose device context is to be released. + * @param hDC Handle to the device context to be released. + * @return The return value specifies whether the device context is + * released. 1 indicates that the device context is released. Zero indicates + * that the device context is not released. + */ + int ReleaseDC(HWND hWnd, HDC hDC); + + /** + * This function retrieves the handle to the top-level window whose class + * name and window name match the specified strings. This function does not + * search child windows. + * + * @param lpClassName Long pointer to a null-terminated string that + * specifies the class name or is an atom that identifies the class-name + * string. If this parameter is an atom, it must be a global atom created by + * a previous call to the GlobalAddAtom function. The atom, a 16-bit value, + * must be placed in the low-order word of lpClassName; the high-order word + * must be zero. + * @param lpWindowName Long pointer to a null-terminated string that + * specifies the window name (the window's title). If this parameter is + * NULL, all window names match. + * @return A handle to the window that has the specified class name and + * window name indicates success. NULL indicates failure. To get extended + * error information, call GetLastError. + */ + HWND FindWindow(String lpClassName, String lpWindowName); + + /** + * This function retrieves the name of the class to which the specified + * window belongs. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param lpClassName Long pointer to the buffer that is to receive the + * class name string. + * @param nMaxCount Specifies the length, in characters, of the buffer + * pointed to by the lpClassName parameter. The class name string is + * truncated if it is longer than the buffer. + * @return The number of characters copied to the specified buffer indicates + * success. Zero indicates failure. To get extended error information, call + * GetLastError. + */ + int GetClassName(HWND hWnd, char[] lpClassName, int nMaxCount); + + /** + * Retrieves information about the active window or a specified graphical + * user interface (GUI) thread. + * + * @param idThread Identifies the thread for which information is to be + * retrieved. To retrieve this value, use the GetWindowThreadProcessId + * function. If this parameter is NULL, the function returns information for + * the foreground thread. + * @param lpgui Pointer to a GUITHREADINFO structure that receives + * information describing the thread. Note that you must set + * GUITHREADINFO.cbSize to sizeof(GUITHREADINFO) before calling this + * function. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean GetGUIThreadInfo(int idThread, GUITHREADINFO lpgui); + + /** + * The GetWindowInfo function retrieves information about the specified + * window. + * + * @param hWnd Handle to the window whose information is to be retrieved. + * @param pwi Pointer to a WINDOWINFO structure to receive the information. + * Note that you must set WINDOWINFO.cbSize to sizeof(WINDOWINFO) before + * calling this function. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. + */ + boolean GetWindowInfo(HWND hWnd, WINDOWINFO pwi); + + /** + * This function retrieves the dimensions of the bounding rectangle of the + * specified window. The dimensions are given in screen coordinates that are + * relative to the upper-left corner of the screen. + * + * @param hWnd Handle to the window. + * @param rect Long pointer to a RECT structure that receives the screen + * coordinates of the upper-left and lower-right corners of the window. + * @return Nonzero indicates success. Zero indicates failure. To get + * extended error information, call GetLastError. + */ + boolean GetWindowRect(HWND hWnd, RECT rect); + + /** + * This function copies the text of the specified window's title bar - if it + * has one - into a buffer. If the specified window is a control, the text + * of the control is copied. + * + * @param hWnd Handle to the window or control containing the text. + * @param lpString Long pointer to the buffer that will receive the text. + * @param nMaxCount Specifies the maximum number of characters to copy to + * the buffer, including the NULL character. If the text exceeds this limit, + * it is truncated. + * @return The length, in characters, of the copied string, not including + * the terminating null character, indicates success. Zero indicates that + * the window has no title bar or text, if the title bar is empty, or if the + * window or control handle is invalid. To get extended error information, + * call GetLastError. This function cannot retrieve the text of an edit + * control in another application. + */ + int GetWindowText(HWND hWnd, char[] lpString, int nMaxCount); + + /** + * This function retrieves the length, in characters, of the specified + * window's title bar text - if the window has a title bar. If the specified + * window is a control, the function retrieves the length of the text within + * the control. + * + * @param hWnd Handle to the window or control. + * @return The length, in characters, of the text indicates success. Under + * certain conditions, this value may actually be greater than the length of + * the text. Zero indicates that the window has no text. To get extended + * error information, call GetLastError. + */ + int GetWindowTextLength(HWND hWnd); + + /** + * The GetWindowModuleFileName function retrieves the full path and file + * name of the module associated with the specified window handle. + * + * @param hWnd Handle to the window whose module file name will be + * retrieved. + * @param lpszFileName Pointer to a buffer that receives the path and file + * name. + * @param cchFileNameMax Specifies the maximum number of TCHARs that can be + * copied into the lpszFileName buffer. + * @return The return value is the total number of TCHARs copied into the + * buffer. + */ + int GetWindowModuleFileName(HWND hWnd, char[] lpszFileName, + int cchFileNameMax); + + /** + * This function retrieves the identifier of the thread that created the + * specified window and, optionally, the identifier of the process that + * created the window. + * + * @param hWnd Handle to the window. + * @param lpdwProcessId Pointer to a 32-bit value that receives the process + * identifier. If this parameter is not NULL, GetWindowThreadProcessId + * copies the identifier of the process to the 32-bit value; otherwise, it + * does not. + * @return The return value is the identifier of the thread that created the + * window. + */ + int GetWindowThreadProcessId(HWND hWnd, IntByReference lpdwProcessId); + + /** + * This function enumerates all top-level windows on the screen by passing + * the handle to each window, in turn, to an application-defined callback + * function. EnumWindows continues until the last top-level window is + * enumerated or the callback function returns FALSE. + * + * @param lpEnumFunc Long pointer to an application-defined callback + * function. + * @param data Specifies an application-defined value to be passed to the + * callback function. + * @return Nonzero indicates success. Zero indicates failure. To get + * extended error information, call GetLastError. + */ + boolean EnumWindows(WNDENUMPROC lpEnumFunc, Pointer data); + + /** + * The EnumChildWindows function enumerates the child windows that belong to + * the specified parent window by passing the handle to each child window, + * in turn, to an application-defined callback function. EnumChildWindows + * continues until the last child window is enumerated or the callback + * function returns FALSE. + * + * @param hWnd Handle to the parent window whose child windows are to be + * enumerated. If this parameter is NULL, this function is equivalent to + * EnumWindows. + * @param lpEnumFunc Pointer to an application-defined callback function. + * @param data Specifies an application-defined value to be passed to the + * callback function. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. If EnumChildProc returns zero, the return + * value is also zero. In this case, the callback function should call + * SetLastError to obtain a meaningful error code to be returned to the + * caller of EnumChildWindows. + */ + boolean EnumChildWindows(HWND hWnd, WNDENUMPROC lpEnumFunc, Pointer data); + + /** + * The EnumThreadWindows function enumerates all nonchild windows associated + * with a thread by passing the handle to each window, in turn, to an + * application-defined callback function. EnumThreadWindows continues until + * the last window is enumerated or the callback function returns FALSE. To + * enumerate child windows of a particular window, use the EnumChildWindows + * function. + * + * @param dwThreadId Identifies the thread whose windows are to be + * enumerated. + * @param lpEnumFunc Pointer to an application-defined callback function. + * @param data Specifies an application-defined value to be passed to the + * callback function. + * @return If the callback function returns TRUE for all windows in the + * thread specified by dwThreadId, the return value is TRUE. If the callback + * function returns FALSE on any enumerated window, or if there are no + * windows found in the thread specified by dwThreadId, the return value is + * FALSE. + */ + boolean EnumThreadWindows(int dwThreadId, WNDENUMPROC lpEnumFunc, + Pointer data); + + /** + * The FlashWindowEx function flashes the specified window. It does not + * change the active state of the window. + * + * @param pfwi Pointer to the FLASHWINFO structure. + * @return The return value specifies the window's state before the call to + * the FlashWindowEx function. If the window caption was drawn as active + * before the call, the return value is nonzero. Otherwise, the return value + * is zero. + */ + boolean FlashWindowEx(FLASHWINFO pfwi); + + /** + * This function loads the specified icon resource from the executable + * (.exe) file associated with an application instance. + * + * @param hInstance Handle to an instance of the module whose executable + * file contains the icon to be loaded. This parameter must be NULL when a + * standard icon is being loaded. + * @param iconName Long pointer to a null-terminated string that contains + * the name of the icon resource to be loaded. Alternatively, this parameter + * can contain the resource identifier in the low-order word and zero in the + * high-order word. Use the MAKEINTRESOURCE macro to create this value. + * @return A handle to the newly loaded icon indicates success. NULL + * indicates failure. To get extended error information, call GetLastError. + */ + HICON LoadIcon(HINSTANCE hInstance, String iconName); + + /** + * This function loads an icon, cursor, or bitmap. + * + * @param hinst Handle to an instance of the module that contains the image + * to be loaded. + * @param name Pointer to a null-terminated string that contains the name of + * the image resource in the hinst module that identifies the image to load. + * @param type Specifies the type of image to be loaded. + * @param xDesired Specifies the width, in pixels, of the icon or cursor. If + * this parameter is zero, the function uses the SM_CXICON or SM_CXCURSOR + * system metric value to set the width. If uType is IMAGE_BITMAP, this + * parameter must be zero. + * @param yDesired Specifies the height, in pixels, of the icon or cursor. + * If this parameter is zero, the function uses the SM_CYICON or SM_CYCURSOR + * system metric value to set the height. If uType is IMAGE_BITMAP, this + * parameter must be zero. + * @param load Set to zero. + * @return The handle of the newly loaded image indicates success. NULL + * indicates failure. To get extended error information, call GetLastError. + */ + HANDLE LoadImage(HINSTANCE hinst, String name, int type, int xDesired, + int yDesired, int load); + + /** + * This function destroys an icon and frees any memory the icon occupied. + * + * @param hicon Handle to the icon to be destroyed. The icon must not be in + * use. + * @return Nonzero indicates success. Zero indicates failure. To get + * extended error information, call GetLastError. + */ + boolean DestroyIcon(HICON hicon); + + /** + * This function retrieves information about the specified window. + * GetWindowLong also retrieves the 32-bit (long) value at the specified + * offset into the extra window memory of a window. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param nIndex Specifies the zero-based offset to the value to be + * retrieved. + * @return The requested 32-bit value indicates success. Zero indicates + * failure. To get extended error information, call GetLastError. + */ + int GetWindowLong(HWND hWnd, int nIndex); + + /** + * This function changes an attribute of the specified window. SetWindowLong + * also sets a 32-bit (LONG) value at the specified offset into the extra + * window memory of a window. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param nIndex Specifies the zero-based offset to the value to be set. + * @param dwNewLong Specifies the replacement value. + * @return The previous value of the specified 32-bit integer indicates + * success. Zero indicates failure. To get extended error information, call + * GetLastError. + */ + int SetWindowLong(HWND hWnd, int nIndex, int dwNewLong); + + /** + * This function changes an attribute of the specified window. SetWindowLong + * also sets a 32-bit (LONG) value at the specified offset into the extra + * window memory of a window. Do not use this version on Windows-64. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param nIndex Specifies the zero-based offset to the value to be set. + * @param dwNewLong Specifies the replacement value. + * @return The previous value of the specified 32-bit integer indicates + * success. Zero indicates failure. To get extended error information, call + * GetLastError. + */ + Pointer SetWindowLong(HWND hWnd, int nIndex, Pointer dwNewLong); + + /** + * The GetWindowLongPtr function retrieves information about the specified + * window. The function also retrieves the value at a specified offset into + * the extra window memory. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param nIndex Specifies the zero-based offset to the value to be + * retrieved. + * @return If the function succeeds, the return value is the requested + * value. If the function fails, the return value is zero. To get extended + * error information, call GetLastError. If SetWindowLong or + * SetWindowLongPtr has not been called previously, GetWindowLongPtr returns + * zero for values in the extra window or class memory. + */ + LONG_PTR GetWindowLongPtr(HWND hWnd, int nIndex); + + /** + * The SetWindowLongPtr function changes an attribute of the specified + * window. The function also sets a value at the specified offset in the + * extra window memory. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param nIndex Specifies the zero-based offset to the value to be set. + * @param dwNewLongPtr Specifies the replacement value. + * @return If the function succeeds, the return value is the previous value + * of the specified offset. If the function fails, the return value is zero. + * To get extended error information, call GetLastError. If the previous + * value is zero and the function succeeds, the return value is zero, but + * the function does not clear the last error information. To determine + * success or failure, clear the last error information by calling + * SetLastError(0), then call SetWindowLongPtr. Function failure will be + * indicated by a return value of zero and a GetLastError result that is + * nonzero. + */ + LONG_PTR SetWindowLongPtr(HWND hWnd, int nIndex, LONG_PTR dwNewLongPtr); + + /** + * The SetWindowLongPtr function changes an attribute of the specified + * window. The function also sets a value at the specified offset in the + * extra window memory. + * + * @param hWnd Handle to the window and, indirectly, the class to which the + * window belongs. + * @param nIndex Specifies the zero-based offset to the value to be set. + * @param dwNewLongPtr Specifies the replacement value. + * @return If the function succeeds, the return value is the previous value + * of the specified offset. If the function fails, the return value is zero. + * To get extended error information, call GetLastError. If the previous + * value is zero and the function succeeds, the return value is zero, but + * the function does not clear the last error information. To determine + * success or failure, clear the last error information by calling + * SetLastError(0), then call SetWindowLongPtr. Function failure will be + * indicated by a return value of zero and a GetLastError result that is + * nonzero. + */ + Pointer SetWindowLongPtr(HWND hWnd, int nIndex, Pointer dwNewLongPtr); + + /** + * The SetLayeredWindowAttributes function sets the opacity and transparency + * color key of a layered window. + * + * @param hwnd Handle to the layered window. + * @param crKey COLORREF structure that specifies the transparency color key + * to be used when composing the layered window. + * @param bAlpha Alpha value used to describe the opacity of the layered + * window. + * @param dwFlags Specifies an action to take. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean SetLayeredWindowAttributes(HWND hwnd, int crKey, byte bAlpha, + int dwFlags); + + /** + * The GetLayeredWindowAttributes function retrieves the opacity and + * transparency color key of a layered window. + * + * @param hwnd Handle to the layered window. A layered window is created by + * specifying WS_EX_LAYERED when creating the window with the CreateWindowEx + * function or by setting WS_EX_LAYERED via SetWindowLong after the window + * has been created. + * @param pcrKey Pointer to a COLORREF value that receives the transparency + * color key to be used when composing the layered window. All pixels + * painted by the window in this color will be transparent. This can be NULL + * if the argument is not needed. + * @param pbAlpha Pointer to a BYTE that receives the Alpha value used to + * describe the opacity of the layered window. Similar to the + * SourceConstantAlpha member of the BLENDFUNCTION structure. When the + * variable referred to by pbAlpha is 0, the window is completely + * transparent. When the variable referred to by pbAlpha is 255, the window + * is opaque. This can be NULL if the argument is not needed. + * @param pdwFlags Pointer to a DWORD that receives a layering flag. This + * can be NULL if the argument is not needed. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean GetLayeredWindowAttributes(HWND hwnd, IntByReference pcrKey, + ByteByReference pbAlpha, IntByReference pdwFlags); + + /** + * The UpdateLayeredWindow function updates the position, size, shape, + * content, and translucency of a layered window. + * + * @param hwnd Handle to a layered window. A layered window is created by + * specifying WS_EX_LAYERED when creating the window with the CreateWindowEx + * function. + * @param hdcDst Handle to a device context (DC) for the screen. This handle + * is obtained by specifying NULL when calling the function. It is used for + * palette color matching when the window contents are updated. If hdcDst + * isNULL, the default palette will be used. If hdcSrc is NULL, hdcDst must + * be NULL. + * @param pptDst Pointer to a POINT structure that specifies the new screen + * position of the layered window. If the current position is not changing, + * pptDst can be NULL. + * @param psize Pointer to a SIZE structure that specifies the new size of + * the layered window. If the size of the window is not changing, psize can + * be NULL. If hdcSrc is NULL, psize must be NULL. + * @param hdcSrc Handle to a DC for the surface that defines the layered + * window. This handle can be obtained by calling the CreateCompatibleDC + * function. If the shape and visual context of the window are not changing, + * hdcSrc can be NULL. + * @param pptSrc Pointer to a POINT structure that specifies the location of + * the layer in the device context. If hdcSrc is NULL, pptSrc should be + * NULL. + * @param crKey Pointer to a COLORREF value that specifies the color key to + * be used when composing the layered window. To generate a COLORREF, use + * the RGB macro. + * @param pblend Pointer to a BLENDFUNCTION structure that specifies the + * transparency value to be used when composing the layered window. + * @param dwFlags ULW_* flags. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean UpdateLayeredWindow(HWND hwnd, HDC hdcDst, POINT pptDst, + SIZE psize, HDC hdcSrc, POINT pptSrc, int crKey, + BLENDFUNCTION pblend, int dwFlags); + + /** + * This function sets the window region of a window. The window region + * determines the area within the window where the system permits drawing. + * The system does not display any portion of a window that lies outside of + * the window region. + * + * @param hWnd Handle to the window whose window region is to be set. + * @param hRgn Handle to a region. The function sets the window region of + * the window to this region. If hRgn is NULL, the function sets the window + * region to NULL. + * @param bRedraw Specifies whether the system redraws the window after + * setting the window region. If bRedraw is TRUE, the system does so; + * otherwise, it does not. Typically, you set bRedraw to TRUE if the window + * is visible. + * @return Nonzero indicates success. Zero indicates failure. To get + * extended error information, call GetLastError. + */ + int SetWindowRgn(HWND hWnd, HRGN hRgn, boolean bRedraw); + + /** + * The GetKeyboardState function copies the status of the 256 virtual keys + * to the specified buffer. + * + * @param lpKeyState Pointer to the 256-byte array that receives the status + * data for each virtual key. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean GetKeyboardState(byte[] lpKeyState); + + /** + * This function determines whether a key is up or down at the time the + * function is called, and whether the key was pressed after a previous call + * to GetAsyncKeyState. + * + * @param vKey Specifies one of 256 possible virtual-key codes. + * @return If the function succeeds, the return value specifies whether the + * key was pressed since the last call to GetAsyncKeyState, and whether the + * key is currently up or down. If the most significant bit is set, the key + * is down. + */ + short GetAsyncKeyState(int vKey); + + /** + * The SetWindowsHookEx function installs an application-defined hook + * procedure into a hook chain. You would install a hook procedure to + * monitor the system for certain types of events. These events are + * associated either with a specific thread or with all threads in the same + * desktop as the calling thread. + * + * @param idHook Specifies the type of hook procedure to be installed. + * @param lpfn Pointer to the hook procedure. + * @param hMod Handle to the DLL containing the hook procedure pointed to by + * the lpfn parameter. + * @param dwThreadId Specifies the identifier of the thread with which the + * hook procedure is to be associated. + * @return If the function succeeds, the return value is the handle to the + * hook procedure. If the function fails, the return value is NULL. To get + * extended error information, call GetLastError. + */ + HHOOK SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod, + int dwThreadId); + + /** + * The CallNextHookEx function passes the hook information to the next hook + * procedure in the current hook chain. A hook procedure can call this + * function either before or after processing the hook information. + * + * @param hhk Ignored. + * @param nCode Specifies the hook code passed to the current hook + * procedure. The next hook procedure uses this code to determine how to + * process the hook information. + * @param wParam Specifies the wParam value passed to the current hook + * procedure. The meaning of this parameter depends on the type of hook + * associated with the current hook chain. + * @param lParam Specifies the lParam value passed to the current hook + * procedure. The meaning of this parameter depends on the type of hook + * associated with the current hook chain. + * @return This value is returned by the next hook procedure in the chain. + * The current hook procedure must also return this value. The meaning of + * the return value depends on the hook type. + */ + LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam); + + /** + * The CallNextHookEx function passes the hook information to the next hook + * procedure in the current hook chain. A hook procedure can call this + * function either before or after processing the hook information. + * + * @param hhk Ignored. + * @param nCode Specifies the hook code passed to the current hook + * procedure. The next hook procedure uses this code to determine how to + * process the hook information. + * @param wParam Specifies the wParam value passed to the current hook + * procedure. The meaning of this parameter depends on the type of hook + * associated with the current hook chain. + * @param lParam Specifies the lParam value passed to the current hook + * procedure. The meaning of this parameter depends on the type of hook + * associated with the current hook chain. + * @return This value is returned by the next hook procedure in the chain. + * The current hook procedure must also return this value. The meaning of + * the return value depends on the hook type. + */ + LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, Pointer lParam); + + /** + * The UnhookWindowsHookEx function removes a hook procedure installed in a + * hook chain by the SetWindowsHookEx function. + * + * @param hhk Handle to the hook to be removed. This parameter is a hook + * handle obtained by a previous call to SetWindowsHookEx. + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean UnhookWindowsHookEx(HHOOK hhk); + + /** + * This function retrieves a message from the calling thread's message queue + * and places it in the specified structure. + * + * @param lpMsg Pointer to an MSG structure that receives message + * information from the thread's message queue. + * @param hWnd Handle to the window whose messages are to be retrieved. One + * value has a special meaning. + * @param wMsgFilterMin Specifies the integer value of the lowest message + * value to be retrieved. + * @param wMsgFilterMax Specifies the integer value of the highest message + * value to be retrieved. + * @return Nonzero indicates that the function retrieves a message other + * than WM_QUIT. Zero indicates that the function retrieves the WM_QUIT + * message, or that lpMsg is an invalid pointer. To get extended error + * information, call GetLastError. + */ + int GetMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, int wMsgFilterMax); + + /** + * This function checks a thread message queue for a message and places the + * message (if any) in the specified structure. + * + * @param lpMsg Pointer to an MSG structure that receives message + * information. + * @param hWnd Handle to the window whose messages are to be examined. + * @param wMsgFilterMin Specifies the value of the first message in the + * range of messages to be examined. + * @param wMsgFilterMax Specifies the value of the last message in the range + * of messages to be examined. + * @param wRemoveMsg Specifies how messages are handled. This parameter can + * be one of the following values. + * @return Nonzero indicates success. Zero indicates failure. + */ + boolean PeekMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, + int wMsgFilterMax, int wRemoveMsg); + + /** + * This function translates virtual-key messages into character messages. + * The character messages are posted to the calling thread's message queue, + * to be read the next time the thread calls the GetMessage or PeekMessage + * function. + * + * @param lpMsg Pointer to an MSG structure that contains message + * information retrieved from the calling thread's message queue by using + * the GetMessage or PeekMessage function. + * @return Nonzero indicates that the message is translated, that is, a + * character message is posted to the thread's message queue. If the message + * is WM_KEYDOWN or WM_SYSKEYDOWN, the return value is nonzero, regardless + * of the translation. Zero indicates that the message is not translated, + * that is, a character message is not posted to the thread's message queue. + */ + boolean TranslateMessage(MSG lpMsg); + + /** + * This function dispatches a message to a window procedure. It is typically + * used to dispatch a message retrieved by the GetMessage function. + * + * @param lpMsg Pointer to an MSG structure that contains the message. + * @return The return value specifies the value returned by the window + * procedure. Although its meaning depends on the message being dispatched, + * the return value generally is ignored. + */ + LRESULT DispatchMessage(MSG lpMsg); + + /** + * This function places a message in the message queue associated with the + * thread that created the specified window and then returns without waiting + * for the thread to process the message. Messages in a message queue are + * retrieved by calls to the GetMessage or PeekMessage function. + * + * @param hWnd Handle to the window whose window procedure is to receive the + * message. + * @param msg Specifies the message to be posted. + * @param wParam Specifies additional message-specific information. + * @param lParam Specifies additional message-specific information. + */ + void PostMessage(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam); + + /** + * This function indicates to Windows that a thread has made a request to + * terminate (quit). It is typically used in response to a WM_DESTROY + * message. + * + * @param nExitCode Specifies an application exit code. This value is used + * as the wParam parameter of the WM_QUIT message. + */ + void PostQuitMessage(int nExitCode); + + /** + * The GetSystemMetrics function retrieves various system metrics (widths + * and heights of display elements) and system configuration settings. All + * dimensions retrieved by GetSystemMetrics are in pixels. + * + * @param nIndex System metric or configuration setting to retrieve. This + * parameter can be one of the following values. Note that all SM_CX* values + * are widths and all SM_CY* values are heights. Also note that all settings + * designed to return Boolean data represent TRUE as any nonzero value, and + * FALSE as a zero value. + * @return If the function succeeds, the return value is the requested + * system metric or configuration setting. If the function fails, the return + * value is zero. GetLastError does not provide extended error information. + */ + public int GetSystemMetrics(int nIndex); + + /** + * Changes the parent window of the specified child window. + * + * @param hWndChild A handle to the child window. + * + * @param hWndNewParent A handle to the new parent window. If this parameter + * is NULL, the desktop window becomes the new parent window. If this + * parameter is HWND_MESSAGE, the child window becomes a message-only + * window. + * + * @return If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + HWND SetParent(HWND hWndChild, HWND hWndNewParent); + + /** + * Determines the visibility state of the specified window. + * + * @param hWnd A handle to the window to be tested. + * + * @return If the specified window, its parent window, its parent's parent + * window, and so forth, have the WS_VISIBLE style, the return value is + * nonzero. Otherwise, the return value is zero. + * + * Because the return value specifies whether the window has the WS_VISIBLE + * style, it may be nonzero even if the window is totally obscured by other + * windows. + */ + boolean IsWindowVisible(HWND hWnd); + + /** + * Changes the position and dimensions of the specified window. For a + * top-level window, the position and dimensions are relative to the + * upper-left corner of the screen. For a child window, they are relative to + * the upper-left corner of the parent window's client area. + * + * @param hWnd A handle to the window. + * + * @param X The new position of the left side of the window. + * + * @param Y The new position of the top of the window. + * + * @param nWidth The new width of the window. + * + * @param nHeight The new height of the window. + * + * @param bRepaint Indicates whether the window is to be repainted. If this + * parameter is TRUE, the window receives a message. If the parameter is + * FALSE, no repainting of any kind occurs. This applies to the client area, + * the nonclient area (including the title bar and scroll bars), and any + * part of the parent window uncovered as a result of moving a child window. + * + * @return If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean MoveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight, + boolean bRepaint); + + /** + * Changes the size, position, and Z order of a child, pop-up, or top-level + * window. These windows are ordered according to their appearance on the + * screen. The topmost window receives the highest rank and is the first + * window in the Z order. + * + * @param hWnd A handle to the window. + * + * @param hWndInsertAfter A handle to the window to precede the positioned + * window in the Z order. + * + * @param X The new position of the left side of the window, in client + * coordinates. + * + * @param Y The new position of the top of the window, in client + * coordinates. + * + * @param cx The new width of the window, in pixels. + * + * @param cy The new height of the window, in pixels. + * + * @param uFlags The window sizing and positioning flags. + * + * @return If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, + int cy, int uFlags); + + /** + * Attaches or detaches the input processing mechanism of one thread to that + * of another thread. + * + * @param idAttach The identifier of the thread to be attached to another + * thread. The thread to be attached cannot be a system thread. + * + * @param idAttachTo The identifier of the thread to which idAttach will be + * attached. This thread cannot be a system thread. A thread cannot attach + * to itself. Therefore, idAttachTo cannot equal idAttach. + * + * @param fAttach If this parameter is TRUE, the two threads are attached. + * If the parameter is FALSE, the threads are detached. + * + * @return If the function succeeds, the return value is nonzero. + */ + boolean AttachThreadInput(DWORD idAttach, DWORD idAttachTo, boolean fAttach); + + /** + * Brings the thread that created the specified window into the foreground + * and activates the window. Keyboard input is directed to the window, and + * various visual cues are changed for the user. The system assigns a + * slightly higher priority to the thread that created the foreground window + * than it does to other threads. + * + * @param hWnd A handle to the window that should be activated and brought + * to the foreground. + * + * @return If the window was brought to the foreground, the return value is + * nonzero. + */ + boolean SetForegroundWindow(HWND hWnd); + + /** + * Retrieves a handle to the foreground window (the window with which the + * user is currently working). The system assigns a slightly higher priority + * to the thread that creates the foreground window than it does to other + * threads. + * + * @return The return value is a handle to the foreground window. The + * foreground window can be NULL in certain circumstances, such as when a + * window is losing activation. + */ + HWND GetForegroundWindow(); + + /** + * Sets the keyboard focus to the specified window. The window must be + * attached to the calling thread's message queue. + * + * @param hWnd A handle to the window that will receive the keyboard input. + * If this parameter is NULL, keystrokes are ignored. + * + * @return If the function succeeds, the return value is the handle to the + * window that previously had the keyboard focus. If the hWnd parameter is + * invalid or the window is not attached to the calling thread's message + * queue, the return value is NULL. To get extended error information, call + * GetLastError. + */ + HWND SetFocus(HWND hWnd); + + /** + * Synthesizes keystrokes, mouse motions, and button clicks. + * + * @param nInputs The number of structures in the pInputs array. + * + * @param pInputs An array of INPUT structures. Each structure represents an + * event to be inserted into the keyboard or mouse input stream. + * + * @param cbSize The size, in bytes, of an INPUT structure. If cbSize is not + * the size of an INPUT structure, the function fails. + * + * @return The function returns the number of events that it successfully + * inserted into the keyboard or mouse input stream. If the function returns + * zero, the input was already blocked by another thread. To get extended + * error information, call GetLastError. + * + * This function fails when it is blocked by UIPI. Note that neither + * GetLastError nor the return value will indicate the failure was caused by + * UIPI blocking. + */ + DWORD SendInput(DWORD nInputs, WinUser.INPUT[] pInputs, int cbSize); + + /** + * Waits until the specified process has finished processing its initial + * input and is waiting for user input with no input pending, or until the + * time-out interval has elapsed. + * + * @param hProcess A handle to the process. If this process is a console + * application or does not have a message queue, WaitForInputIdle returns + * immediately. + * + * @param dwMilliseconds The time-out interval, in milliseconds. If + * dwMilliseconds is INFINITE, the function does not return until the + * process is idle. + * + * @return The following table shows the possible return values for this + * function. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Return code/valueDescription
0The wait was satisfied successfully.
WAIT_TIMEOUTThe wait was terminated because the time-out interval elapsed.
WAIT_FAILEDAn error occurred.
+ */ + DWORD WaitForInputIdle(HANDLE hProcess, DWORD dwMilliseconds); + + /** + * The InvalidateRect function adds a rectangle to the specified window's + * update region. The update region represents the portion of the window's + * client area that must be redrawn. + * + * @param hWnd A handle to the window whose update region has changed. If + * this parameter is NULL, the system invalidates and redraws all windows, + * not just the windows for this application, and sends the WM_ERASEBKGND + * and WM_NCPAINT messages before the function returns. Setting this + * parameter to NULL is not recommended. + * + * @param lpRect A pointer to a RECT structure that contains the client + * coordinates of the rectangle to be added to the update region. If this + * parameter is NULL, the entire client area is added to the update region. + * + * @param bErase Specifies whether the background within the update region + * is to be erased when the update region is processed. If this parameter is + * TRUE, the background is erased when the BeginPaint function is called. If + * this parameter is FALSE, the background remains unchanged. + * + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. + */ + boolean InvalidateRect(HWND hWnd, RECT lpRect, boolean bErase); + + /** + * The RedrawWindow function updates the specified rectangle or region in a + * window's client area. + * + * @param hWnd A handle to the window to be redrawn. If this parameter is + * NULL, the desktop window is updated. + * + * @param lprcUpdate A pointer to a RECT structure containing the + * coordinates, in device units, of the update rectangle. This parameter is + * ignored if the hrgnUpdate parameter identifies a region. + * + * @param hrgnUpdate A handle to the update region. If both the hrgnUpdate + * and lprcUpdate parameters are NULL, the entire client area is added to + * the update region. + * + * @param flags One or more redraw flags. This parameter can be used to + * invalidate or validate a window, control repainting, and control which + * windows are affected by RedrawWindow. + * + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. + */ + boolean RedrawWindow(HWND hWnd, RECT lprcUpdate, + HRGN hrgnUpdate, DWORD flags); + + /** + * Retrieves a handle to a window that has the specified relationship + * (Z-Order or owner) to the specified window. + * + * @param hWnd A handle to a window. The window handle retrieved is relative + * to this window, based on the value of the uCmd parameter. + * + * @param uCmd The relationship between the specified window and the window + * whose handle is to be retrieved. + * + * @return If the function succeeds, the return value is a window handle. If + * no window exists with the specified relationship to the specified window, + * the return value is NULL. To get extended error information, call + * GetLastError. + */ + HWND GetWindow(HWND hWnd, DWORD uCmd); + + /** + * The UpdateWindow function updates the client area of the specified window + * by sending a WM_PAINT message to the window if the window's update region + * is not empty. The function sends a WM_PAINT message directly to the + * window procedure of the specified window, bypassing the application + * queue. If the update region is empty, no message is sent. + * + * @param hWnd Handle to the window to be updated. + * + * @return If the function succeeds, the return value is nonzero. If the + * function fails, the return value is zero. + */ + boolean UpdateWindow(HWND hWnd); + + /** + * Sets the specified window's show state. + * + * @param hWnd A handle to the window. + * + * @param nCmdShow Controls how the window is to be shown. This parameter is + * ignored the first time an application calls ShowWindow, if the program + * that launched the application provides a STARTUPINFO structure. + * Otherwise, the first time ShowWindow is called, the value should be the + * value obtained by the WinMain function in its nCmdShow parameter. + * + * @return If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean ShowWindow(HWND hWnd, int nCmdShow); + + /** + * Minimizes (but does not destroy) the specified window. + * + * @param hWnd A handle to the window to be minimized. + * + * @return If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean CloseWindow(HWND hWnd); + + /** + * Defines a system-wide hot key. + * + * @param hWnd A handle to the window that will receive + * @param id The identifier of the hot key + * @param fsModifiers The keys that must be pressed in combination with the + * key specified by the uVirtKey parameter in order to generate the + * @param vk The virtual-key code of the hot key + * @return If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call {@link Kernel32#GetLastError}. + * {@link WinUser#WM_HOTKEY} messages generated by the hot key + * {@link WinUser#WM_HOTKEY} message.
+ * A combination of the following values + *

    + *
  • {@link WinUser#MOD_ALT} Either ALT key must be held down.
  • + *
  • {@link WinUser#MOD_CONTROL} Either CTRL key must be held down.
  • + *
  • {@link WinUser#MOD_NOREPEAT} Changes the hotkey behavior so that the + * keyboard auto-repeat does not yield multiple hotkey notifications. + *
    + * Windows Vista and Windows XP/2000: This flag is not supported.
  • + *
  • {@link WinUser#MOD_SHIFT} Either SHIFT key must be held down. + *
  • + *
  • {@link WinUser#MOD_WIN} Either WINDOWS key was held down. These keys + * are labeled with the Windows logo.
  • + *
+ */ + boolean RegisterHotKey(HWND hWnd, int id, int fsModifiers, int vk); + + /** + * Frees a hot key previously registered by the calling thread. + * + * @param hWnd A handle to the window associated with the hot key to be + * freed. This parameter should be NULL if the hot key is not associated + * with a window. + * + * @param id The identifier of the hot key to be freed. + * + * @return If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call {@link Kernel32#GetLastError}. + */ + boolean UnregisterHotKey(Pointer hWnd, int id); + + /** + * Retrieves the time of the last input event. + * + * @param plii structure that receives the time of the last input event + * @return If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call {@link Kernel32#GetLastError}. + */ + boolean GetLastInputInfo(LASTINPUTINFO plii); + + /** + * Registers a window class for subsequent use in calls to the CreateWindow + * or CreateWindowEx function. + * + * @param lpwcx Type: const WNDCLASSEX* A pointer to a WNDCLASSEX structure. + * You must fill the structure with the appropriate class attributes before + * passing it to the function. + * + * @return If the function succeeds, the return value is a class atom that + * uniquely identifies the class being registered. This atom can only be + * used by the CreateWindow, CreateWindowEx, GetClassInfo, GetClassInfoEx, + * FindWindow, FindWindowEx, and UnregisterClass functions and the + * IActiveIMMap::FilterClientWindows method. + * + * If the function fails, the return value is zero. To get extended error + * information, call {@link Kernel32#GetLastError}. + */ + public ATOM RegisterClassEx(WNDCLASSEX lpwcx); + + /** + * Unregisters a window class, freeing the memory required for the class. + * + * @param lpClassName [in] Type: LPCTSTR + * + * A null-terminated string or a class atom. If lpClassName is a string, it + * specifies the window class name. This class name must have been + * registered by a previous call to the RegisterClass or RegisterClassEx + * function. System classes, such as dialog box controls, cannot be + * unregistered. If this parameter is an atom, it must be a class atom + * created by a previous call to the RegisterClass or RegisterClassEx + * function. The atom must be in the low-order word of lpClassName; the + * high-order word must be zero. + * + * @param hInstance [in,optional] Type: HINSTANCE A handle to the instance + * of the module that created the class. * + * + * @return Type: BOOL If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call {@link Kernel32#GetLastError}. + */ + public boolean UnregisterClass(WString lpClassName, HINSTANCE hInstance); + + /** + * Creates an overlapped, pop-up, or child window with an extended window + * style; otherwise, this function is identical to the CreateWindow + * function. For more information about creating a window and for full + * descriptions of the other parameters of CreateWindowEx, see CreateWindow. + * + * @param dwExStyle [in] Type: DWORD + * + * The extended window style of the window being created. For a list of + * possible values,see Extended Window Styles. + * + * @param lpClassName [in, optional] Type: LPCTSTR + * + * A null-terminated string or a class atom created by a previous call to + * the RegisterClass or RegisterClassEx function. The atom must be in the + * low-order word of lpClassName; the high-order word must be zero. If + * lpClassName is a string, it specifies the window class name. The class + * name can be any name registered with RegisterClass or RegisterClassEx, + * provided that the module that registers the class is also the module that + * creates the window. The class name can also be any of the predefined + * system class names. + * + * @param lpWindowName [in, optional] Type: LPCTSTR + * + * The window name. If the window style specifies a title bar, the window + * title pointed to by lpWindowName is displayed in the title bar. When + * using CreateWindow to create controls, such as buttons, check boxes, and + * static controls, use lpWindowName to specify the text of the control. + * When creating a static control with the SS_ICON style, use lpWindowName + * to specify the icon name or identifier. To specify an identifier, use the + * syntax "#num". + * + * @param dwStyle [in] Type: DWORD + * + * The style of the window being created. This parameter can be a + * combination of the window style values, plus the control styles indicated + * in the Remarks section. + * + * @param x [in] Type: int + * + * The initial horizontal position of the window. For an overlapped or + * pop-up window, the x parameter is the initial x-coordinate of the + * window's upper-left corner, in screen coordinates. For a child window, x + * is the x-coordinate of the upper-left corner of the window relative to + * the upper-left corner of the parent window's client area. If x is set to + * CW_USEDEFAULT, the system selects the default position for the window's + * upper-left corner and ignores the y parameter. CW_USEDEFAULT is valid + * only for overlapped windows; if it is specified for a pop-up or child + * window, the x and y parameters are set to zero. + * + * @param y [in] Type: int + * + * The initial vertical position of the window. For an overlapped or pop-up + * window, the y parameter is the initial y-coordinate of the window's + * upper-left corner, in screen coordinates. For a child window, y is the + * initial y-coordinate of the upper-left corner of the child window + * relative to the upper-left corner of the parent window's client area. For + * a list box y is the initial y-coordinate of the upper-left corner of the + * list box's client area relative to the upper-left corner of the parent + * window's client area. + * + * If an overlapped window is created with the WS_VISIBLE style bit set and + * the x parameter is set to CW_USEDEFAULT, then the y parameter determines + * how the window is shown. If the y parameter is CW_USEDEFAULT, then the + * window manager calls ShowWindow with the SW_SHOW flag after the window + * has been created. If the y parameter is some other value, then the window + * manager calls ShowWindow with that value as the nCmdShow parameter. + * + * @param nWidth [in] Type: int + * + * The width, in device units, of the window. For overlapped windows, nWidth + * is the window's width, in screen coordinates, or CW_USEDEFAULT. If nWidth + * is CW_USEDEFAULT, the system selects a default width and height for the + * window; the default width extends from the initial x-coordinates to the + * right edge of the screen; the default height extends from the initial + * y-coordinate to the top of the icon area. CW_USEDEFAULT is valid only for + * overlapped windows; if CW_USEDEFAULT is specified for a pop-up or child + * window, the nWidth and nHeight parameter are set to zero. + * + * @param nHeight [in] Type: int + * + * The height, in device units, of the window. For overlapped windows, + * nHeight is the window's height, in screen coordinates. If the nWidth + * parameter is set to CW_USEDEFAULT, the system ignores nHeight. + * + * @param hWndParent [in, optional] Type: HWND + * + * A handle to the parent or owner window of the window being created. To + * create a child window or an owned window, supply a valid window handle. + * This parameter is optional for pop-up windows. + * + * To create a message-only window, supply HWND_MESSAGE or a handle to an + * existing message-only window. + * + * @param hMenu [in, optional] Type: HMENU + * + * A handle to a menu, or specifies a child-window identifier, depending on + * the window style. For an overlapped or pop-up window, hMenu identifies + * the menu to be used with the window; it can be NULL if the class menu is + * to be used. For a child window, hMenu specifies the child-window + * identifier, an integer value used by a dialog box control to notify its + * parent about events. The application determines the child-window + * identifier; it must be unique for all child windows with the same parent + * window. + * + * @param hInstance [in, optional] Type: HINSTANCE + * + * A handle to the instance of the module to be associated with the window. + * + * @param lpParam [in, optional] Type: LPVOID + * + * Pointer to a value to be passed to the window through the CREATESTRUCT + * structure (lpCreateParams member) pointed to by the lParam param of the + * WM_CREATE message. This message is sent to the created window by this + * function before it returns. + * + * If an application calls CreateWindow to create a MDI client window, + * lpParam should point to a CLIENTCREATESTRUCT structure. If an MDI client + * window calls CreateWindow to create an MDI child window, lpParam should + * point to a MDICREATESTRUCT structure. lpParam may be NULL if no + * additional data is needed. + * + * @return Type: HWND + * + * If the function succeeds, the return value is a handle to the new window. + * + * If the function fails, the return value is NULL. To get extended error + * information, call GetLastError. + * + * This function typically fails for one of the following reasons: + *

+ * - an invalid parameter value

+ * - the system class was registered by a different module

+ * - The WH_CBT hook is installed and returns a failure code

+ * - if one of the controls in the dialog template is not registered, or its + * window window procedure fails WM_CREATE or WM_NCCREATE + */ + public HWND CreateWindowEx(int dwExStyle, WString lpClassName, + String lpWindowName, int dwStyle, int x, int y, int nWidth, + int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, + LPVOID lpParam); + + /** + * Destroys the specified window. The function sends WM_DESTROY and + * WM_NCDESTROY messages to the window to deactivate it and remove the + * keyboard focus from it. The function also destroys the window's menu, + * flushes the thread message queue, destroys timers, removes clipboard + * ownership, and breaks the clipboard viewer chain (if the window is at the + * top of the viewer chain). + * + * If the specified window is a parent or owner window, DestroyWindow + * automatically destroys the associated child or owned windows when it + * destroys the parent or owner window. The function first destroys child or + * owned windows, and then it destroys the parent or owner window. + * + * DestroyWindow also destroys modeless dialog boxes created by the + * CreateDialog function. + * + * @param hWnd [in] Type: HWND A handle to the window to be destroyed. + * + * @return Type: BOOL If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call {@link Kernel32#GetLastError}. + */ + public boolean DestroyWindow(HWND hWnd); + + /** + * Retrieves information about a window class, including a handle to the + * small icon associated with the window class. The GetClassInfo function + * does not retrieve a handle to the small icon. + * + * @param hinst [in, optional] Type: HINSTANCE + * + * A handle to the instance of the application that created the class. To + * retrieve information about classes defined by the system (such as buttons + * or list boxes), set this parameter to NULL. + * + * @param lpszClass [in] Type: LPCTSTR + * + * The class name. The name must be that of a preregistered class or a class + * registered by a previous call to the RegisterClass or RegisterClassEx + * function. Alternatively, this parameter can be a class atom created by a + * previous call to RegisterClass or RegisterClassEx. The atom must be in + * the low-order word of lpszClass; the high-order word must be zero. + * + * @param lpwcx [out] Type: LPWNDCLASSEX + * + * A pointer to a WNDCLASSEX structure that receives the information about + * the class. + * + * @return Type: BOOL If the function finds a matching class and + * successfully copies the data, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call {@link Kernel32#GetLastError} . + */ + public boolean GetClassInfoEx(HINSTANCE hinst, WString lpszClass, + WNDCLASSEX lpwcx); + + /** + * Calls the default window procedure to provide default processing for any + * window messages that an application does not process. This function + * ensures that every message is processed. DefWindowProc is called with the + * same parameters received by the window procedure. + * + * @param hWnd [in] Type: HWND + * + * A handle to the window procedure that received the message. + * + * @param Msg [in] Type: UINT + * + * The message. + * + * @param wParam [in] Type: WPARAM + * + * Additional message information. The content of this parameter depends on + * the value of the Msg parameter. + * + * @param lParam [in] Type: LPARAM + * + * Additional message information. The content of this parameter depends on + * the value of the Msg parameter. + * + * @return Type: LRESULT The return value is the result of the message + * processing and depends on the message. + * + * If the function fails, the return value is zero. To get extended error + * information, call {@link Kernel32#GetLastError}. + */ + public LRESULT DefWindowProc(HWND hWnd, int Msg, WPARAM wParam, + LPARAM lParam); + + /** + * Registers the device or type of device for which a window will receive + * notifications. + * + * @param hRecipient [in] A handle to the window or service that will + * receive device events for the devices specified in the NotificationFilter + * parameter. The same window handle can be used in multiple calls to + * RegisterDeviceNotification. + * + * Services can specify either a window handle or service status handle. + * + * @param notificationFilter [in] A pointer to a block of data that + * specifies the type of device for which notifications should be sent. This + * block always begins with the DEV_BROADCAST_HDR structure. The data + * following this header is dependent on the value of the dbch_devicetype + * member, which can be DBT_DEVTYP_DEVICEINTERFACE or DBT_DEVTYP_HANDLE. For + * more information, see Remarks. + * + * @param Flags [in] This parameter can be one of the following values. + * DEVICE_NOTIFY_WINDOW_HANDLE0x00000000 The hRecipient parameter is a + * window handle. + * + * DEVICE_NOTIFY_SERVICE_HANDLE0x00000001 The hRecipient parameter is a + * service status handle. + * + * In addition, you can specify the following value. + * + * DEVICE_NOTIFY_ALL_INTERFACE_CLASSES0x00000004 Notifies the recipient of + * device interface events for all device interface classes. (The + * dbcc_classguid member is ignored.) + * + * This value can be used only if the dbch_devicetype member is + * DBT_DEVTYP_DEVICEINTERFACE. + * + * @return value + * + * If the function succeeds, the return value is a device notification + * handle. + * + * If the function fails, the return value is NULL. To get extended error + * information, call GetLastError. + */ + HDEVNOTIFY RegisterDeviceNotification(HANDLE hRecipient, + Structure notificationFilter, int Flags); + + /** + * Closes the specified device notification handle. + * + * @param Handle [in] Device notification handle returned by the + * RegisterDeviceNotification function. + * + * @return Return value + * + * If the function succeeds, the return value is nonzero. + * + * If the function fails, the return value is zero. To get extended error + * information, call GetLastError. + */ + boolean UnregisterDeviceNotification(HDEVNOTIFY Handle); + + /** + * Defines a new window message that is guaranteed to be unique throughout + * the system. The message value can be used when sending or posting + * messages. + * + * @param string The message to be registered. + * + * @return If the message is successfully registered, the return value is a + * message identifier in the range 0xC000 through 0xFFFF. + *

+ * If the function fails, the return value is zero. To get extended error + * information, call GetLastError. + *

+ */ + int RegisterWindowMessage(String string); + + boolean GetIconInfo(HICON hIcon, ICONINFO iconinfo); + + boolean DrawIcon(HDC hDC, int X, int Y, HICON hIcon); + + boolean DrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, int diFlags); + + HWND GetDesktopWindow(); + public static final int DI_MASK = 1; + public static final int DI_IMAGE = 2; + public static final int DI_NORMAL = 3; + public static final int DI_COMPAT = 4; + public static final int DI_DEFAULTSIZE = 8; + + int FillRect(HDC hDC, RECT lprc, HANDLE hbr); +} \ No newline at end of file diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/W32Errors.java b/trunk/src/com/sun/jna/platform/win32/W32Errors.java similarity index 93% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/W32Errors.java rename to trunk/src/com/sun/jna/platform/win32/W32Errors.java index 458339a45..4bd8bf3e7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/W32Errors.java +++ b/trunk/src/com/sun/jna/platform/win32/W32Errors.java @@ -10,9 +10,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -package com.jpexs.decompiler.flash.gui.jna.platform.win32; +package com.sun.jna.platform.win32; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HRESULT; +import com.sun.jna.platform.win32.WinNT.HRESULT; // TODO: Auto-generated Javadoc /** diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Win32Exception.java b/trunk/src/com/sun/jna/platform/win32/Win32Exception.java similarity index 91% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Win32Exception.java rename to trunk/src/com/sun/jna/platform/win32/Win32Exception.java index 7d17a6bec..75fede1ae 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Win32Exception.java +++ b/trunk/src/com/sun/jna/platform/win32/Win32Exception.java @@ -14,7 +14,7 @@ * 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.jna.platform.win32; +package com.sun.jna.platform.win32; /** * @@ -32,7 +32,7 @@ package com.jpexs.decompiler.flash.gui.jna.platform.win32; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HRESULT; +import com.sun.jna.platform.win32.WinNT.HRESULT; /** * Win32 exception. diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinBase.java b/trunk/src/com/sun/jna/platform/win32/WinBase.java similarity index 97% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinBase.java rename to trunk/src/com/sun/jna/platform/win32/WinBase.java index 49f2542b2..94708e69a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinBase.java +++ b/trunk/src/com/sun/jna/platform/win32/WinBase.java @@ -10,13 +10,13 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -package com.jpexs.decompiler.flash.gui.jna.platform.win32; +package com.sun.jna.platform.win32; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; 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; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinDef.java b/trunk/src/com/sun/jna/platform/win32/WinDef.java similarity index 94% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinDef.java rename to trunk/src/com/sun/jna/platform/win32/WinDef.java index 0d535208d..5b1e61af7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinDef.java +++ b/trunk/src/com/sun/jna/platform/win32/WinDef.java @@ -10,13 +10,13 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -package com.jpexs.decompiler.flash.gui.jna.platform.win32; +package com.sun.jna.platform.win32; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.BaseTSD.LONG_PTR; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.IntegerType; import com.sun.jna.Pointer; import com.sun.jna.Structure; +import com.sun.jna.platform.win32.BaseTSD.LONG_PTR; +import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.ByReference; import com.sun.jna.win32.StdCallLibrary; import java.awt.Rectangle; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinError.java b/trunk/src/com/sun/jna/platform/win32/WinError.java similarity index 99% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinError.java rename to trunk/src/com/sun/jna/platform/win32/WinError.java index fb9f22e93..ead581699 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinError.java +++ b/trunk/src/com/sun/jna/platform/win32/WinError.java @@ -10,9 +10,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -package com.jpexs.decompiler.flash.gui.jna.platform.win32; +package com.sun.jna.platform.win32; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HRESULT; +import com.sun.jna.platform.win32.WinNT.HRESULT; /** * Error code definitions for the Win32 API functions. Ported from Windows SDK diff --git a/trunk/src/com/sun/jna/platform/win32/WinGDI.java b/trunk/src/com/sun/jna/platform/win32/WinGDI.java new file mode 100644 index 000000000..eab6a8742 --- /dev/null +++ b/trunk/src/com/sun/jna/platform/win32/WinGDI.java @@ -0,0 +1,130 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.sun.jna.platform.win32; + +/** + * + * @author petrik + */ +import com.sun.jna.Structure; +import com.sun.jna.platform.win32.WinDef.RECT; +import com.sun.jna.win32.StdCallLibrary; +import java.util.Arrays; +import java.util.List; + +/** + * Ported from WinGDI.h. Microsoft Windows SDK 6.0A. + * + * @author dblock[at]dblock.org + */ +public interface WinGDI extends StdCallLibrary { + + public int RDH_RECTANGLES = 1; + + public class RGNDATAHEADER extends Structure { + + public int dwSize = size(); + public int iType = RDH_RECTANGLES; // required + public int nCount; + public int nRgnSize; + public RECT rcBound; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"dwSize", "iType", "nCount", "nRgnSize", "rcBound"}); + } + } + + public class RGNDATA extends Structure { + + public RGNDATAHEADER rdh; + public byte[] Buffer; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"rdh", "Buffer"}); + } + + public RGNDATA() { + this(1); + } + + public RGNDATA(int bufferSize) { + Buffer = new byte[bufferSize]; + allocateMemory(); + } + } + public int RGN_AND = 1; + public int RGN_OR = 2; + public int RGN_XOR = 3; + public int RGN_DIFF = 4; + public int RGN_COPY = 5; + public int ERROR = 0; + public int NULLREGION = 1; + public int SIMPLEREGION = 2; + public int COMPLEXREGION = 3; + public int ALTERNATE = 1; + public int WINDING = 2; + public int BI_RGB = 0; + public int BI_RLE8 = 1; + public int BI_RLE4 = 2; + public int BI_BITFIELDS = 3; + public int BI_JPEG = 4; + public int BI_PNG = 5; + + public class BITMAPINFOHEADER extends Structure { + + public int biSize = size(); + public int biWidth; + public int biHeight; + public short biPlanes; + public short biBitCount; + public int biCompression; + public int biSizeImage; + public int biXPelsPerMeter; + public int biYPelsPerMeter; + public int biClrUsed; + public int biClrImportant; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"biSize", "biWidth", "biHeight", "biPlanes", "biBitCount", "biCompression", "biSizeImage", "biXPelsPerMeter", "biYPelsPerMeter", "biClrUsed", "biClrImportant"}); + } + } + + public class RGBQUAD extends Structure { + + public byte rgbBlue; + public byte rgbGreen; + public byte rgbRed; + public byte rgbReserved = 0; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"rgbBlue", "rgbGreen", "rgbRed", "rgbReserved"}); + } + } + + public class BITMAPINFO extends Structure { + + public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER(); + public RGBQUAD[] bmiColors = new RGBQUAD[1]; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[]{"bmiHeader", "bmiColors"}); + } + + public BITMAPINFO() { + this(1); + } + + public BITMAPINFO(int size) { + bmiColors = new RGBQUAD[size]; + } + } + public int DIB_RGB_COLORS = 0; + public int DIB_PAL_COLORS = 1; +} \ No newline at end of file diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinNT.java b/trunk/src/com/sun/jna/platform/win32/WinNT.java similarity index 99% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinNT.java rename to trunk/src/com/sun/jna/platform/win32/WinNT.java index c84777cac..75c925279 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinNT.java +++ b/trunk/src/com/sun/jna/platform/win32/WinNT.java @@ -10,7 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -package com.jpexs.decompiler.flash.gui.jna.platform.win32; +package com.sun.jna.platform.win32; import com.sun.jna.FromNativeContext; import com.sun.jna.Memory; @@ -386,12 +386,14 @@ public interface WinNT extends WinError, WinDef, WinBase, BaseTSD { // AccessSystemAcl access type // int ACCESS_SYSTEM_SECURITY = 0x01000000; + int PAGE_NOACCESS = 0x01; int PAGE_READONLY = 0x02; int PAGE_READWRITE = 0x04; int PAGE_WRITECOPY = 0x08; int PAGE_EXECUTE = 0x10; int PAGE_EXECUTE_READ = 0x20; int PAGE_EXECUTE_READWRITE = 0x40; + int PAGE_GUARD = 0x100; int SECTION_QUERY = 0x0001; int SECTION_MAP_WRITE = 0x0002; int SECTION_MAP_READ = 0x0004; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinReg.java b/trunk/src/com/sun/jna/platform/win32/WinReg.java similarity index 92% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinReg.java rename to trunk/src/com/sun/jna/platform/win32/WinReg.java index 3e3bdcce1..cd93e6dca 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinReg.java +++ b/trunk/src/com/sun/jna/platform/win32/WinReg.java @@ -10,10 +10,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -package com.jpexs.decompiler.flash.gui.jna.platform.win32; +package com.sun.jna.platform.win32; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.Pointer; +import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.ByReference; import com.sun.jna.win32.StdCallLibrary; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinUser.java b/trunk/src/com/sun/jna/platform/win32/WinUser.java similarity index 93% rename from trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinUser.java rename to trunk/src/com/sun/jna/platform/win32/WinUser.java index 8fde2d436..35d7ef2d7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinUser.java +++ b/trunk/src/com/sun/jna/platform/win32/WinUser.java @@ -10,23 +10,23 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU * Lesser General Public License for more details. */ -package com.jpexs.decompiler.flash.gui.jna.platform.win32; +package com.sun.jna.platform.win32; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.BaseTSD.ULONG_PTR; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HBRUSH; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HCURSOR; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HICON; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HINSTANCE; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HWND; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.LPARAM; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.LRESULT; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.WPARAM; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.Callback; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.Union; import com.sun.jna.WString; +import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR; +import com.sun.jna.platform.win32.WinDef.HBRUSH; +import com.sun.jna.platform.win32.WinDef.HCURSOR; +import com.sun.jna.platform.win32.WinDef.HICON; +import com.sun.jna.platform.win32.WinDef.HINSTANCE; +import com.sun.jna.platform.win32.WinDef.HWND; +import com.sun.jna.platform.win32.WinDef.LPARAM; +import com.sun.jna.platform.win32.WinDef.LRESULT; +import com.sun.jna.platform.win32.WinDef.WPARAM; +import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.win32.StdCallLibrary; import java.util.Arrays; import java.util.List;