New flash player library + jna

This commit is contained in:
Jindra Pet��k
2013-02-22 20:30:51 +01:00
parent 4c07fd4cde
commit b7acf8afe9
17 changed files with 46251 additions and 48 deletions
+6 -26
View File
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.gui.AboutDialog;
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
import com.jpexs.decompiler.flash.gui.LoadingDialog;
import com.jpexs.decompiler.flash.gui.MainFrame;
import com.jpexs.decompiler.flash.gui.ModeFrame;
@@ -225,10 +226,12 @@ public class Main {
return false;
}
try {
try {
Main.startWork("Creating window...");
mainFrame = new MainFrame(swf);
loadingDialog.setVisible(false);
mainFrame.setVisible(true);
Main.stopWork();
} catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
@@ -457,29 +460,6 @@ public class Main {
System.exit(0);
}
public static void checkSWT(String[] args) {
if (System.getProperty("os.name").toLowerCase().indexOf("win") == -1) {
return;
}
String lastBits = (String) Configuration.getConfig("bits", "-");
if ((!System.getProperty("sun.arch.data.model").equals(lastBits)) || (!(new File("lib/swt.jar")).exists())) {
try {
if (System.getProperty("sun.arch.data.model").equals("32")) {
copyFile("lib/swt32.jar", "lib/swt.jar");
} else if (System.getProperty("sun.arch.data.model").equals("64")) {
copyFile("lib/swt64.jar", "lib/swt.jar");
}
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, "Cannot copy SWT library.\nPlease make application directory writeable.\n(Placing outside of Program files may help)", "Error", JOptionPane.ERROR_MESSAGE);
Logger.getLogger(SWFInputStream.class.getName()).severe("Cannot copy SWT library");
System.exit(1);
}
Configuration.setConfig("bits", System.getProperty("sun.arch.data.model"));
Configuration.save();
restartApplication(args);
}
}
public static final void printASM(AVM2Code code) {
String s = Highlighting.stripHilights(code.toASMSource(null, new MethodBody()));
String ss[] = s.split("\n");
@@ -494,7 +474,6 @@ public class Main {
public static void main(String[] args) throws IOException {
View.setLookAndFeel();
Configuration.load();
checkSWT(args);
int pos = 0;
if (args.length > 0) {
@@ -724,7 +703,8 @@ public class Main {
public static void exit() {
Configuration.save();
System.exit(0);
FlashPlayerPanel.unload();
System.exit(0);
}
public static void about() {
@@ -255,8 +255,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
treePanel,
navPanel);
splitPaneTreeVSNavigator.setResizeWeight(0.5);
splitPaneTreeVSNavigator.setContinuousLayout(true);
Main.startWork("Creating window...");
splitPaneTreeVSNavigator.setContinuousLayout(true);
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("Scripts", splitPaneTreeVSNavigator);
//tabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
@@ -0,0 +1,13 @@
package com.jpexs.decompiler.flash.gui;
/**
*
* @author JPEXS
*/
public class FlashUnsupportedException extends RuntimeException{
public FlashUnsupportedException() {
super("Flash Unsupported");
}
}
@@ -84,6 +84,8 @@ import javax.swing.JTabbedPane;
import javax.swing.SwingConstants;
import javax.swing.SwingWorker;
import javax.swing.border.BevelBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
/**
*
@@ -240,9 +242,6 @@ public class MainFrame extends JFrame implements ActionListener {
menuBar.add(menuFile);
JMenu menuDeobfuscation = new JMenu("Deobfuscation");
JMenuItem miDeobfuscation = new JMenuItem("PCode deobfuscation...");
miDeobfuscation.setActionCommand("DEOBFUSCATE");
miDeobfuscation.addActionListener(this);
@@ -347,30 +346,29 @@ public class MainFrame extends JFrame implements ActionListener {
}
menuDeobfuscation.setEnabled(false);
}
if (!shapes.isEmpty()) {
addTab(tabPane, shapesTagPanel = new TagPanel(shapes, swf), "Shapes", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/shape16.png")));
addTab(tabPane, shapesTagPanel = new TagPanel(this,shapes, swf), "Shapes", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/shape16.png")));
}
if (!morphShapes.isEmpty()) {
addTab(tabPane, morphshapesTagPanel = new TagPanel(morphShapes, swf), "MorphShapes", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/morphshape16.png")));
addTab(tabPane, morphshapesTagPanel = new TagPanel(this,morphShapes, swf), "MorphShapes", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/morphshape16.png")));
}
if (!images.isEmpty()) {
addTab(tabPane, imagesTagPanel = new TagPanel(images, swf), "Images", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/image16.png")));
addTab(tabPane, imagesTagPanel = new TagPanel(this,images, swf), "Images", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/image16.png")));
}
if (!sprites.isEmpty()) {
addTab(tabPane, spritesTagPanel = new TagPanel(sprites, swf), "Sprites", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/sprite16.png")));
addTab(tabPane, spritesTagPanel = new TagPanel(this,sprites, swf), "Sprites", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/sprite16.png")));
}
if (!fonts.isEmpty()) {
addTab(tabPane, fontsTagPanel = new TagPanel(fonts, swf), "Fonts", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/font16.png")));
addTab(tabPane, fontsTagPanel = new TagPanel(this,fonts, swf), "Fonts", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/font16.png")));
}
if (!texts.isEmpty()) {
addTab(tabPane, textsTagPanel = new TagPanel(texts, swf), "Texts", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/text16.png")));
addTab(tabPane, textsTagPanel = new TagPanel(this,texts, swf), "Texts", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/text16.png")));
}
if (!buttons.isEmpty()) {
addTab(tabPane, buttonsTagPanel = new TagPanel(buttons, swf), "Buttons", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/button16.png")));
addTab(tabPane, buttonsTagPanel = new TagPanel(this,buttons, swf), "Buttons", new ImageIcon(this.getClass().getClassLoader().getResource("com/jpexs/decompiler/flash/gui/graphics/button16.png")));
}
loadingPanel.setPreferredSize(new Dimension(30, 30));
statusPanel = new JPanel();
statusPanel.setPreferredSize(new Dimension(1, 30));
@@ -381,7 +379,7 @@ public class MainFrame extends JFrame implements ActionListener {
loadingPanel.setVisible(false);
add(statusPanel, BorderLayout.SOUTH);
View.centerScreen(this);
Main.stopWork();
}
@@ -16,6 +16,8 @@
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
import com.jpexs.decompiler.flash.Main;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag;
@@ -43,7 +45,6 @@ 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.flashplayer.FlashPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
@@ -58,6 +59,7 @@ import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
@@ -72,7 +74,7 @@ import javax.swing.event.ListSelectionListener;
public class TagPanel extends JPanel implements ListSelectionListener {
public JList tagList;
public FlashPanel flashPanel;
public FlashPlayerPanel flashPanel;
public JPanel displayPanel;
public ImagePanel imagePanel;
private SWF swf;
@@ -100,8 +102,11 @@ public class TagPanel extends JPanel implements ListSelectionListener {
}
}
}
private JFrame frame;
public TagPanel(List<Tag> list, SWF swf) {
public TagPanel(JFrame frame,List<Tag> list, SWF swf) {
this.frame=frame;
this.swf = swf;
for (Tag t : swf.tags) {
if (t instanceof JPEGTablesTag) {
@@ -117,9 +122,9 @@ public class TagPanel extends JPanel implements ListSelectionListener {
setLayout(new BorderLayout());
try {
flashPanel = new FlashPanel();
} catch (Error e) {
e.printStackTrace();
flashPanel = new FlashPlayerPanel(frame);
} catch (FlashUnsupportedException fue) {
}
displayPanel = new JPanel(new CardLayout());
if (flashPanel != null) {
@@ -147,9 +152,15 @@ public class TagPanel extends JPanel implements ListSelectionListener {
cl.show(displayPanel, card);
}
private Object oldValue;
@Override
public void valueChanged(ListSelectionEvent e) {
Tag tagObj = (Tag) tagList.getSelectedValue();
if(tagObj==oldValue){
return;
}
oldValue=tagObj;
if (tagObj instanceof DefineBitsTag) {
showCard(CARDIMAGEPANEL);
imagePanel.setImage(((DefineBitsTag) tagObj).getFullImageData(jtt));
@@ -279,7 +290,7 @@ public class TagPanel extends JPanel implements ListSelectionListener {
fos.close();
showCard(CARDFLASHPANEL);
if (flashPanel != null) {
if (flashPanel instanceof FlashPanel) {
if (flashPanel instanceof FlashPlayerPanel) {
flashPanel.displaySWF(tempFile.getAbsolutePath());
}
}
@@ -0,0 +1,142 @@
package com.jpexs.decompiler.flash.gui.player;
import com.jpexs.decompiler.flash.Main;
import com.jpexs.decompiler.flash.gui.FlashUnsupportedException;
import com.sun.jna.Native;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
import com.sun.jna.WString;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.Kernel32;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.SHELLEXECUTEINFO;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.Shell32;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.HWND;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinNT;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinNT.HANDLE;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinUser;
import com.sun.jna.ptr.IntByReference;
import java.awt.Graphics;
import java.awt.Panel;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFrame;
/**
*
* @author JPEXS
*/
public class FlashPlayerPanel extends Panel {
private boolean executed=false;
private String flash;
private HANDLE pipe;
private static List<HANDLE> processes=new ArrayList<HANDLE>();
private static List<HANDLE> pipes=new ArrayList<HANDLE>();
private JFrame frame;
private synchronized void resize(){
if(pipe!=null){
IntByReference ibr=new IntByReference();
Kernel32.INSTANCE.WriteFile(pipe, new byte[]{2},1,ibr,null);
Kernel32.INSTANCE.WriteFile(pipe, new byte[]{
(byte)(getWidth()/256),(byte)(getWidth()%256),
(byte)(getHeight()/256),(byte)(getHeight()%256),
},4,ibr,null);
}
}
public FlashPlayerPanel(JFrame frame) {
if(!Platform.isWindows()){
throw new FlashUnsupportedException();
}
this.frame=frame;
addComponentListener(new ComponentListener() {
@Override
public void componentResized(ComponentEvent e)
{
resize();
}
@Override
public void componentMoved(ComponentEvent e) {
}
@Override
public void componentShown(ComponentEvent e) {
componentResized(e);
}
@Override
public void componentHidden(ComponentEvent e) {
}
});
}
private WinDef.HWND hwndFrame;
private void execute(){
WinDef.HWND hwnd = new WinDef.HWND();
hwnd.setPointer(Native.getComponentPointer(this));
hwndFrame = new WinDef.HWND();
hwndFrame.setPointer(Native.getComponentPointer(frame));
pipe=Kernel32.INSTANCE.CreateNamedPipe("\\\\.\\pipe\\ffdec_flashplayer_"+hwnd.getPointer().hashCode(), Kernel32.PIPE_ACCESS_OUTBOUND, Kernel32.PIPE_TYPE_BYTE, 1, 0, 0, 0, null);
SHELLEXECUTEINFO sei=new SHELLEXECUTEINFO();
sei.fMask=0x00000040;
String path=new File(new File(".").getAbsolutePath()).getParentFile().getAbsolutePath();
sei.lpFile=new WString(path+"\\lib\\FlashPlayer.exe");
sei.lpParameters=new WString(hwnd.getPointer().hashCode()+" "+hwndFrame.getPointer().hashCode());
sei.nShow=WinUser.SW_NORMAL;
Shell32.INSTANCE.ShellExecuteEx(sei);
processes.add(sei.hProcess);
Kernel32.INSTANCE.ConnectNamedPipe(pipe, null);
pipes.add(pipe);
executed=true;
}
public synchronized void displaySWF(String flash){
this.flash=flash;
repaint();
if(!executed){
execute();
}
if(pipe!=null){
IntByReference ibr=new IntByReference();
Kernel32.INSTANCE.WriteFile(pipe, new byte[]{1},1,ibr,null);
Kernel32.INSTANCE.WriteFile(pipe, new byte[]{(byte)flash.getBytes().length},1,ibr,null);
Kernel32.INSTANCE.WriteFile(pipe, flash.getBytes(),flash.getBytes().length,ibr, null);
}
}
public static void unload(){
if(Platform.isWindows()){
for(int i=0;i<processes.size();i++){
Kernel32.INSTANCE.CloseHandle(pipes.get(i));
Kernel32.INSTANCE.TerminateProcess(processes.get(i), 0);
}
}
}
@Override
public void paint(Graphics g) {
if((!executed)&&flash!=null){
execute();
}
super.paint(g);
}
}
@@ -0,0 +1,127 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.jpexs.decompiler.flash.gui.player.jna.platform.win32;
import com.sun.jna.IntegerType;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.ByReference;
import com.sun.jna.win32.StdCallLibrary;
/**
* Based on basetsd.h (various types)
* @author dblock[at]dblock[dot]org
*/
@SuppressWarnings("serial")
public interface BaseTSD extends StdCallLibrary {
/**
* Signed long type for pointer precision.
* Use when casting a pointer to a long to perform pointer arithmetic.
*/
public static class LONG_PTR extends IntegerType {
public LONG_PTR() {
this(0);
}
public LONG_PTR(long value) {
super(Pointer.SIZE, value);
}
public Pointer toPointer() {
return Pointer.createConstant(longValue());
}
}
/**
* Signed SIZE_T.
*/
public static class SSIZE_T extends LONG_PTR {
public SSIZE_T() {
this(0);
}
public SSIZE_T(long value) {
super(value);
}
}
/**
* Unsigned LONG_PTR.
*/
public static class ULONG_PTR extends IntegerType {
public ULONG_PTR() {
this(0);
}
public ULONG_PTR(long value) {
super(Pointer.SIZE, value, true);
}
public Pointer toPointer() {
return Pointer.createConstant(longValue());
}
}
/**
* PULONG_PTR
*/
public static class ULONG_PTRByReference extends ByReference {
public ULONG_PTRByReference() {
this(new ULONG_PTR(0));
}
public ULONG_PTRByReference(ULONG_PTR value) {
super(Pointer.SIZE);
setValue(value);
}
public void setValue(ULONG_PTR value) {
if (Pointer.SIZE == 4) {
getPointer().setInt(0, value.intValue());
}
else {
getPointer().setLong(0, value.longValue());
}
}
public ULONG_PTR getValue() {
return new ULONG_PTR(Pointer.SIZE == 4
? getPointer().getInt(0)
: getPointer().getLong(0));
}
}
/**
* Unsigned DWORD_PTR.
*/
public static class DWORD_PTR extends IntegerType {
public DWORD_PTR() {
this(0);
}
public DWORD_PTR(long value) {
super(Pointer.SIZE, value);
}
}
/**
* The maximum number of bytes to which a pointer can point.
* Use for a count that must span the full range of a pointer.
*/
public static class SIZE_T extends ULONG_PTR {
public SIZE_T() {
this(0);
}
public SIZE_T(long value) {
super(value);
}
}
}
@@ -0,0 +1,163 @@
/* Copyright (c) 2007 Timothy Wall, 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.
* <p/>
* 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.jpexs.decompiler.flash.gui.player.jna.platform.win32;
import java.nio.Buffer;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.LongByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.W32APIOptions;
// TODO: Auto-generated Javadoc
/**
* Interface definitions for <code>kernel32.dll</code>. Includes additional
* alternate mappings from {@link WinNT} which make use of NIO buffers.
*/
public interface Kernel32 extends WinNT {
/** The instance. */
Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32",
Kernel32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* The CloseHandle function closes an open object handle.
*
* @param hObject
* Handle to an open object. This parameter can be a pseudo
* handle or INVALID_HANDLE_VALUE.
* @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 CloseHandle(HANDLE hObject);
/**
* Terminates the specified process and all of its threads.
*
* @param hProcess
* A handle to the process to be terminated.
* @param uExitCode
* The exit code to be used by the process and threads terminated
* as a result of this call.
* @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 TerminateProcess(HANDLE hProcess, int uExitCode);
/**
* Writes data to the specified file or input/output (I/O) device.
*
* @param hFile
* A handle to the file or I/O device (for example, a file, file
* stream, physical disk, volume, console buffer, tape drive,
* socket, communications resource, mailslot, or pipe).
* @param lpBuffer
* A pointer to the buffer containing the data to be written to
* the file or device.
* @param nNumberOfBytesToWrite
* The number of bytes to be written to the file or device.
* @param lpNumberOfBytesWritten
* A pointer to the variable that receives the number of bytes
* written when using a synchronous hFile parameter.
* @param lpOverlapped
* A pointer to an OVERLAPPED structure is required if the hFile
* parameter was opened with FILE_FLAG_OVERLAPPED, otherwise this
* parameter can be NULL.
* @return If the function succeeds, the return value is nonzero (TRUE). If
* the function fails, or is completing asynchronously, the return
* value is zero (FALSE). To get extended error information, call
* the GetLastError function.
*/
boolean WriteFile(HANDLE hFile, byte[] lpBuffer, int nNumberOfBytesToWrite,
IntByReference lpNumberOfBytesWritten,
WinBase.OVERLAPPED lpOverlapped);
//
// Define the NamedPipe definitions
//
//
// Define the dwOpenMode values for CreateNamedPipe
//
public static final int PIPE_ACCESS_INBOUND = 0x00000001;
public static final int PIPE_ACCESS_OUTBOUND = 0x00000002;
public static final int PIPE_ACCESS_DUPLEX = 0x00000003;
//
// Define the Named Pipe End flags for GetNamedPipeInfo
//
public static final int PIPE_CLIENT_END = 0x00000000;
public static final int PIPE_SERVER_END = 0x00000001;
//
// Define the dwPipeMode values for CreateNamedPipe
//
public static final int PIPE_WAIT = 0x00000000;
public static final int PIPE_NOWAIT = 0x00000001;
public static final int PIPE_READMODE_BYTE = 0x00000000;
public static final int PIPE_READMODE_MESSAGE = 0x00000002;
public static final int PIPE_TYPE_BYTE = 0x00000000;
public static final int PIPE_TYPE_MESSAGE = 0x00000004;
public static final int PIPE_ACCEPT_REMOTE_CLIENTS = 0x00000000;
public static final int PIPE_REJECT_REMOTE_CLIENTS = 0x00000008;
//
// Define the well known values for CreateNamedPipe nMaxInstances
//
public static final int PIPE_UNLIMITED_INSTANCES = 255;
// __out
// HANDLE
// WINAPI
// CreateNamedPipe(
// __in LPCWSTR lpName,
// __in DWORD dwOpenMode,
// __in DWORD dwPipeMode,
// __in DWORD nMaxInstances,
// __in DWORD nOutBufferSize,
// __in DWORD nInBufferSize,
// __in DWORD nDefaultTimeOut,
// __in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes
// );
HANDLE CreateNamedPipe(String lpName, int dwOpenMode, int dwPipeMode, int nMaxInstances, int nOutBufferSize, int nInBufferSize, int nDefaultTimeOut,
WinBase.SECURITY_ATTRIBUTES lpSecurityAttributes);
// WINBASEAPI
// BOOL
// WINAPI
// ConnectNamedPipe(
// __in HANDLE hNamedPipe,
// __inout_opt LPOVERLAPPED lpOverlapped
// );
boolean ConnectNamedPipe(HANDLE hNamedPipe, WinBase.OVERLAPPED lpOverlapped);
// WINBASEAPI
// BOOL
// WINAPI
// DisconnectNamedPipe(
// __in HANDLE hNamedPipe
// );
boolean DisconnectNamedPipe(HANDLE hNamedPipe);
}
@@ -0,0 +1,36 @@
package com.jpexs.decompiler.flash.gui.player.jna.platform.win32;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.HINSTANCE;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.HWND;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinNT.HANDLE;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinReg.HKEY;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import java.util.Arrays;
import java.util.List;
public class SHELLEXECUTEINFO extends Structure {
public int cbSize = size();
public int fMask;
public HWND hwnd;
public WString lpVerb;
public WString lpFile;
public WString lpParameters;
public WString lpDirectory;
public int nShow;
public HINSTANCE hInstApp;
public Pointer lpIDList;
public WString lpClass;
public HKEY hKeyClass;
public int dwHotKey;
public HANDLE hMonitor;
public HANDLE hProcess;
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[]{"cbSize", "fMask", "hwnd", "lpVerb", "lpFile", "lpParameters", "lpDirectory", "nShow", "hInstApp", "lpIDList",
"lpClass", "hKeyClass", "dwHotKey", "hMonitor", "hProcess"});
}
}
@@ -0,0 +1,37 @@
/* Copyright (c) 2007 Timothy Wall, 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.
* <p/>
* 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.jpexs.decompiler.flash.gui.player.jna.platform.win32;
import com.sun.jna.Native;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.DWORD;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.HWND;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.INT_PTR;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinNT.HANDLE;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Shell32.dll Interface.
*/
public interface Shell32 extends StdCallLibrary {
Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class,
W32APIOptions.UNICODE_OPTIONS);
/**
* @return true if successful. Otherwise false.
*/
boolean ShellExecuteEx(SHELLEXECUTEINFO lpExecInfo);
}
@@ -0,0 +1,181 @@
/* Copyright (c) 2010,2011 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.jpexs.decompiler.flash.gui.player.jna.platform.win32;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinNT.HRESULT;
// TODO: Auto-generated Javadoc
/**
* Utility class for some common error functions.
*/
public abstract class W32Errors implements WinError {
/**
* Generic test for success on any status value (non-negative numbers
* indicate success).
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean SUCCEEDED(int hr) {
return hr >= 0;
}
/**
* and the inverse.
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean FAILED(int hr) {
return hr < 0;
}
/**
* Succeeded.
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean SUCCEEDED(HRESULT hr) {
if (hr != null)
return SUCCEEDED(hr.intValue());
else
return false;
}
/**
* Failed.
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean FAILED(HRESULT hr) {
if (hr != null)
return FAILED(hr.intValue());
else
return false;
}
/**
* Extract error code from HRESULT.
*
* @param hr the hr
* @return the int
*/
public static final int HRESULT_CODE(int hr) {
return hr & 0xFFFF;
}
/**
* Extract error code from SCODE.
*
* @param sc the sc
* @return the int
*/
public static final int SCODE_CODE(int sc) {
return sc & 0xFFFF;
}
/**
* Return the facility.
*
* @param hr the hr
* @return the int
*/
public static final int HRESULT_FACILITY(int hr) {
return (hr >>= 16) & 0x1fff;
}
/**
* Scode facility.
*
* @param sc the sc
* @return the int
*/
public static final int SCODE_FACILITY(short sc) {
return (sc >>= 16) & 0x1fff;
}
/**
* Return the severity.
*
* @param hr the hr
* @return the short
*/
public static short HRESULT_SEVERITY(int hr) {
return (short) ((hr >>= 31) & 0x1);
}
/**
* Scode severity.
*
* @param sc the sc
* @return the short
*/
public static short SCODE_SEVERITY(short sc) {
return (short) ((sc >>= 31) & 0x1);
}
/**
* Create an HRESULT value from component pieces.
*
* @param sev the sev
* @param fac the fac
* @param code the code
* @return the int
*/
public static int MAKE_HRESULT(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
/**
* Make scode.
*
* @param sev the sev
* @param fac the fac
* @param code the code
* @return the int
*/
public static final int MAKE_SCODE(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
/**
* Map a WIN32 error value into a HRESULT Note: This assumes that WIN32
* errors fall in the range -32k to=32k.
*
* @param x
* original w32 error code
* @return the converted value
*/
public static final HRESULT HRESULT_FROM_WIN32(int x) {
int f = FACILITY_WIN32;
return new HRESULT(x <= 0 ? x : ((x) & 0x0000FFFF) | (f <<= 16)
| 0x80000000);
}
/**
* FACILITY_USERMODE_FILTER_MANAGER
*
* Translation macro for converting: NTSTATUS --> HRESULT.
*
* @param x the x
* @return the int
*/
public static final int FILTER_HRESULT_FROM_FLT_NTSTATUS(int x) {
int f = FACILITY_USERMODE_FILTER_MANAGER;
return (((x) & 0x8000FFFF) | (f <<= 16));
}
}
@@ -0,0 +1,885 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.jpexs.decompiler.flash.gui.player.jna.platform.win32;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from Winbase.h (kernel32.dll/kernel services).
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
/** Constant value representing an invalid HANDLE. */
HANDLE INVALID_HANDLE_VALUE =
new HANDLE(Pointer.createConstant(Pointer.SIZE == 8
? -1 : 0xFFFFFFFFL));
/**
* Maximum computer name length.
* The value is 15 on Mac, 31 on everything else.
*/
int MAX_COMPUTERNAME_LENGTH = Platform.isMac() ? 15 : 31;
/**
* This logon type is intended for users who will be interactively using the computer, such
* as a user being logged on by a terminal server, remote shell, or similar process. This
* logon type has the additional expense of caching logon information for disconnected operations;
* therefore, it is inappropriate for some client/server applications, such as a mail server.
*/
int LOGON32_LOGON_INTERACTIVE = 2;
/**
* This logon type is intended for high performance servers to authenticate plaintext passwords.
* The LogonUser function does not cache credentials for this logon type.
*/
int LOGON32_LOGON_NETWORK = 3;
/**
* This logon type is intended for batch servers, where processes may be executing on behalf
* of a user without their direct intervention. This type is also for higher performance servers
* that process many plaintext authentication attempts at a time, such as mail or Web servers.
* The LogonUser function does not cache credentials for this logon type.
*/
int LOGON32_LOGON_BATCH = 4;
/**
* Indicates a service-type logon. The account provided must have the service privilege enabled.
*/
int LOGON32_LOGON_SERVICE = 5;
/**
* This logon type is for GINA DLLs that log on users who will be interactively using the computer.
* This logon type can generate a unique audit record that shows when the workstation was unlocked.
*/
int LOGON32_LOGON_UNLOCK = 7;
/**
* This logon type preserves the name and password in the authentication package, which allows the
* server to make connections to other network servers while impersonating the client. A server can
* accept plaintext credentials from a client, call LogonUser, verify that the user can access the
* system across the network, and still communicate with other servers.
*/
int LOGON32_LOGON_NETWORK_CLEARTEXT = 8;
/**
* This logon type allows the caller to clone its current token and specify new credentials for
* outbound connections. The new logon session has the same local identifier but uses different
* credentials for other network connections. This logon type is supported only by the
* LOGON32_PROVIDER_WINNT50 logon provider.
*/
int LOGON32_LOGON_NEW_CREDENTIALS = 9;
/**
* Use the standard logon provider for the system. The default security provider is negotiate,
* unless you pass NULL for the domain name and the user name is not in UPN format. In this case,
* the default provider is NTLM.
*/
int LOGON32_PROVIDER_DEFAULT = 0;
/**
* Use the Windows NT 3.5 logon provider.
*/
int LOGON32_PROVIDER_WINNT35 = 1;
/**
* Use the NTLM logon provider.
*/
int LOGON32_PROVIDER_WINNT40 = 2;
/**
* Use the negotiate logon provider.
*/
int LOGON32_PROVIDER_WINNT50 = 3;
/**
* If this flag is set, a child process created with the bInheritHandles parameter of
* CreateProcess set to TRUE will inherit the object handle.
*/
int HANDLE_FLAG_INHERIT = 1;
/**
* If this flag is set, calling the {@link Kernel32#CloseHandle} function will not
* close the object handle.
*/
int HANDLE_FLAG_PROTECT_FROM_CLOSE = 2;
// STARTUPINFO flags
int STARTF_USESHOWWINDOW = 0x001;
int STARTF_USESIZE = 0x002;
int STARTF_USEPOSITION = 0x004;
int STARTF_USECOUNTCHARS = 0x008;
int STARTF_USEFILLATTRIBUTE = 0x010;
int STARTF_RUNFULLSCREEN = 0x020;
int STARTF_FORCEONFEEDBACK = 0x040;
int STARTF_FORCEOFFFEEDBACK = 0x080;
int STARTF_USESTDHANDLES = 0x100;
// Process Creation flags
int DEBUG_PROCESS = 0x00000001;
int DEBUG_ONLY_THIS_PROCESS = 0x00000002;
int CREATE_SUSPENDED = 0x00000004;
int DETACHED_PROCESS = 0x00000008;
int CREATE_NEW_CONSOLE = 0x00000010;
int CREATE_NEW_PROCESS_GROUP = 0x00000200;
int CREATE_UNICODE_ENVIRONMENT = 0x00000400;
int CREATE_SEPARATE_WOW_VDM = 0x00000800;
int CREATE_SHARED_WOW_VDM = 0x00001000;
int CREATE_FORCEDOS = 0x00002000;
int INHERIT_PARENT_AFFINITY = 0x00010000;
int CREATE_PROTECTED_PROCESS = 0x00040000;
int EXTENDED_STARTUPINFO_PRESENT = 0x00080000;
int CREATE_BREAKAWAY_FROM_JOB = 0x01000000;
int CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000;
int CREATE_DEFAULT_ERROR_MODE = 0x04000000;
int CREATE_NO_WINDOW = 0x08000000;
/* Invalid return values */
int INVALID_FILE_SIZE = 0xFFFFFFFF;
int INVALID_SET_FILE_POINTER = 0xFFFFFFFF;
int INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF;
/**
* Return code for a process still active.
*/
int STILL_ACTIVE = WinNT.STATUS_PENDING;
/**
* The FILETIME structure is a 64-bit value representing the number of
* 100-nanosecond intervals since January 1, 1601 (UTC).
* Conversion code in this class Copyright 2002-2004 Apache Software Foundation.
* @author Rainer Klute ([email protected]) for the Apache Software Foundation (org.apache.poi.hpsf)
*/
public static class FILETIME extends Structure {
public int dwLowDateTime;
public int dwHighDateTime;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwLowDateTime", "dwHighDateTime" });
}
public static class ByReference extends FILETIME implements Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public FILETIME(Date date) {
long rawValue = dateToFileTime(date);
dwHighDateTime = (int)(rawValue >> 32 & 0xffffffffL);
dwLowDateTime = (int)(rawValue & 0xffffffffL);
}
public FILETIME() {
}
public FILETIME(Pointer memory) {
super(memory);
read();
}
/**
* <p>The difference between the Windows epoch (1601-01-01
* 00:00:00) and the Unix epoch (1970-01-01 00:00:00) in
* milliseconds: 11644473600000L. (Use your favorite spreadsheet
* program to verify the correctness of this value. By the way,
* did you notice that you can tell from the epochs which
* operating system is the modern one? :-))</p>
*/
private static final long EPOCH_DIFF = 11644473600000L;
/**
* <p>Converts a Windows FILETIME into a {@link Date}. The Windows
* FILETIME structure holds a date and time associated with a
* file. The structure identifies a 64-bit integer specifying the
* number of 100-nanosecond intervals which have passed since
* January 1, 1601. This 64-bit value is split into the two double
* words stored in the structure.</p>
*
* @param high The higher double word of the FILETIME structure.
* @param low The lower double word of the FILETIME structure.
* @return The Windows FILETIME as a {@link Date}.
*/
public static Date filetimeToDate(final int high, final int low) {
final long filetime = (long) high << 32 | low & 0xffffffffL;
final long ms_since_16010101 = filetime / (1000 * 10);
final long ms_since_19700101 = ms_since_16010101 - EPOCH_DIFF;
return new Date(ms_since_19700101);
}
/**
* <p>Converts a {@link Date} into a filetime.</p>
*
* @param date The date to be converted
* @return The filetime
*
* @see #filetimeToDate
*/
public static long dateToFileTime(final Date date) {
final long ms_since_19700101 = date.getTime();
final long ms_since_16010101 = ms_since_19700101 + EPOCH_DIFF;
return ms_since_16010101 * 1000 * 10;
}
public Date toDate() {
return filetimeToDate(dwHighDateTime, dwLowDateTime);
}
public long toLong() {
return toDate().getTime();
}
public String toString() {
return super.toString() + ": " + toDate().toString(); //$NON-NLS-1$
}
}
/* Local Memory Flags */
int LMEM_FIXED = 0x0000;
int LMEM_MOVEABLE = 0x0002;
int LMEM_NOCOMPACT = 0x0010;
int LMEM_NODISCARD = 0x0020;
int LMEM_ZEROINIT = 0x0040;
int LMEM_MODIFY = 0x0080;
int LMEM_DISCARDABLE = 0x0F00;
int LMEM_VALID_FLAGS = 0x0F72;
int LMEM_INVALID_HANDLE = 0x8000;
int LHND = (LMEM_MOVEABLE | LMEM_ZEROINIT);
int LPTR = (LMEM_FIXED | LMEM_ZEROINIT);
/* Flags returned by LocalFlags (in addition to LMEM_DISCARDABLE) */
int LMEM_DISCARDED = 0x4000;
int LMEM_LOCKCOUNT = 0x00FF;
/**
* Specifies a date and time, using individual members for the month,
* day, year, weekday, hour, minute, second, and millisecond. The time
* is either in coordinated universal time (UTC) or local time, depending
* on the function that is being called.
* http://msdn.microsoft.com/en-us/library/ms724950(VS.85).aspx
*/
public static class SYSTEMTIME extends Structure {
// The year. The valid values for this member are 1601 through 30827.
public short wYear;
// The month. The valid values for this member are 1 through 12.
public short wMonth;
// The day of the week. The valid values for this member are 0 through 6.
public short wDayOfWeek;
// The day of the month. The valid values for this member are 1 through 31.
public short wDay;
// The hour. The valid values for this member are 0 through 23.
public short wHour;
// The minute. The valid values for this member are 0 through 59.
public short wMinute;
// The second. The valid values for this member are 0 through 59.
public short wSecond;
// The millisecond. The valid values for this member are 0 through 999.
public short wMilliseconds;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "wYear", "wMonth", "wDayOfWeek", "wDay", "wHour", "wMinute", "wSecond", "wMilliseconds" });
}
}
/**
* The lpBuffer parameter is a pointer to a PVOID pointer, and that the nSize
* parameter specifies the minimum number of TCHARs to allocate for an output
* message buffer. The function allocates a buffer large enough to hold the
* formatted message, and places a pointer to the allocated buffer at the address
* specified by lpBuffer. The caller should use the LocalFree function to free
* the buffer when it is no longer needed.
*/
int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100;
/**
* Insert sequences in the message definition are to be ignored and passed through
* to the output buffer unchanged. This flag is useful for fetching a message for
* later formatting. If this flag is set, the Arguments parameter is ignored.
*/
int FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200;
/**
* The lpSource parameter is a pointer to a null-terminated message definition.
* The message definition may contain insert sequences, just as the message text
* in a message table resource may. Cannot be used with FORMAT_MESSAGE_FROM_HMODULE
* or FORMAT_MESSAGE_FROM_SYSTEM.
*/
int FORMAT_MESSAGE_FROM_STRING = 0x00000400;
/**
* The lpSource parameter is a module handle containing the message-table
* resource(s) to search. If this lpSource handle is NULL, the current process's
* application image file will be searched. Cannot be used with
* FORMAT_MESSAGE_FROM_STRING.
*/
int FORMAT_MESSAGE_FROM_HMODULE = 0x00000800;
/**
* The function should search the system message-table resource(s) for the
* requested message. If this flag is specified with FORMAT_MESSAGE_FROM_HMODULE,
* the function searches the system message table if the message is not found in
* the module specified by lpSource. Cannot be used with FORMAT_MESSAGE_FROM_STRING.
* If this flag is specified, an application can pass the result of the
* GetLastError function to retrieve the message text for a system-defined error.
*/
int FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000;
/**
* The Arguments parameter is not a va_list structure, but is a pointer to an array
* of values that represent the arguments. This flag cannot be used with 64-bit
* argument values. If you are using 64-bit values, you must use the va_list
* structure.
*/
int FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000;
/**
* The drive type cannot be determined.
*/
int DRIVE_UNKNOWN = 0;
/**
* The root path is invalid, for example, no volume is mounted at the path.
*/
int DRIVE_NO_ROOT_DIR = 1;
/**
* The drive is a type that has removable media, for example, a floppy drive
* or removable hard disk.
*/
int DRIVE_REMOVABLE = 2;
/**
* The drive is a type that cannot be removed, for example, a fixed hard drive.
*/
int DRIVE_FIXED = 3;
/**
* The drive is a remote (network) drive.
*/
int DRIVE_REMOTE = 4;
/**
* The drive is a CD-ROM drive.
*/
int DRIVE_CDROM = 5;
/**
* The drive is a RAM disk.
*/
int DRIVE_RAMDISK = 6;
/**
* The OVERLAPPED structure contains information used in
* asynchronous (or overlapped) input and output (I/O).
*/
public static class OVERLAPPED extends Structure {
public ULONG_PTR Internal;
public ULONG_PTR InternalHigh;
public int Offset;
public int OffsetHigh;
public HANDLE hEvent;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Internal", "InternalHigh", "Offset", "OffsetHigh", "hEvent" });
}
}
int INFINITE = 0xFFFFFFFF;
/**
* Contains information about the current computer system. This includes the architecture and
* type of the processor, the number of processors in the system, the page size, and other such
* information.
*/
public static class SYSTEM_INFO extends Structure {
/** Unnamed inner structure. */
public static class PI extends Structure {
public static class ByReference extends PI implements Structure.ByReference {
}
/**
* System's processor architecture.
* This value can be one of the following values:
*
* PROCESSOR_ARCHITECTURE_UNKNOWN
* PROCESSOR_ARCHITECTURE_INTEL
* PROCESSOR_ARCHITECTURE_IA64
* PROCESSOR_ARCHITECTURE_AMD64
*/
public WORD wProcessorArchitecture;
/**
* Reserved for future use.
*/
public WORD wReserved;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "wProcessorArchitecture", "wReserved" });
}
}
/** Unnamed inner union. */
public static class UNION extends Union {
public static class ByReference extends UNION implements Structure.ByReference {
}
/**
* An obsolete member that is retained for compatibility with Windows NT 3.5 and earlier.
* New applications should use the wProcessorArchitecture branch of the union.
* Windows Me/98/95: The system always sets this member to zero, the value defined
* for PROCESSOR_ARCHITECTURE_INTEL.
*/
public DWORD dwOemID;
/**
* Processor architecture (unnamed struct).
*/
public PI pi;
}
/**
* Processor architecture (unnamed union).
*/
public UNION processorArchitecture;
/**
* Page size and the granularity of page protection and commitment.
*/
public DWORD dwPageSize;
/**
* Pointer to the lowest memory address accessible to applications and dynamic-link libraries (DLLs).
*/
public Pointer lpMinimumApplicationAddress;
/**
* Pointer to the highest memory address accessible to applications and DLLs.
*/
public Pointer lpMaximumApplicationAddress;
/**
* Mask representing the set of processors configured into the system. Bit 0 is processor 0; bit 31 is processor 31.
*/
public DWORD_PTR dwActiveProcessorMask;
/**
* Number of processors in the system.
*/
public DWORD dwNumberOfProcessors;
/**
* An obsolete member that is retained for compatibility with Windows NT 3.5 and Windows Me/98/95.
* Use the wProcessorArchitecture, wProcessorLevel, and wProcessorRevision members to determine
* the type of processor.
* PROCESSOR_INTEL_386
* PROCESSOR_INTEL_486
* PROCESSOR_INTEL_PENTIUM
*/
public DWORD dwProcessorType;
/**
* Granularity for the starting address at which virtual memory can be allocated.
*/
public DWORD dwAllocationGranularity;
/**
* System's architecture-dependent processor level. It should be used only for display purposes.
* To determine the feature set of a processor, use the IsProcessorFeaturePresent function.
* If wProcessorArchitecture is PROCESSOR_ARCHITECTURE_INTEL, wProcessorLevel is defined by the CPU vendor.
* If wProcessorArchitecture is PROCESSOR_ARCHITECTURE_IA64, wProcessorLevel is set to 1.
*/
public WORD wProcessorLevel;
/**
* Architecture-dependent processor revision.
*/
public WORD wProcessorRevision;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "processorArchitecture", "dwPageSize", "lpMinimumApplicationAddress", "lpMaximumApplicationAddress", "dwActiveProcessorMask", "dwNumberOfProcessors", "dwProcessorType", "dwAllocationGranularity", "wProcessorLevel", "wProcessorRevision"});
}
}
/**
* Contains information about the current state of both physical and virtual memory, including
* extended memory. The GlobalMemoryStatusEx function stores information in this structure.
*/
public static class MEMORYSTATUSEX extends Structure {
/**
* The size of the structure, in bytes.
*/
public DWORD dwLength;
/**
* A number between 0 and 100 that specifies the approximate percentage of physical memory
* that is in use (0 indicates no memory use and 100 indicates full memory use).
*/
public DWORD dwMemoryLoad;
/**
* The amount of actual physical memory, in bytes.
*/
public DWORDLONG ullTotalPhys;
/**
* The amount of physical memory currently available, in bytes. This is the amount of physical
* memory that can be immediately reused without having to write its contents to disk first.
* It is the sum of the size of the standby, free, and zero lists.
*/
public DWORDLONG ullAvailPhys;
/**
* The current committed memory limit for the system or the current process, whichever is smaller, in bytes.
*/
public DWORDLONG ullTotalPageFile;
/**
* The maximum amount of memory the current process can commit, in bytes. This value is equal to or smaller
* than the system-wide available commit value.
*/
public DWORDLONG ullAvailPageFile;
/**
* The size of the user-mode portion of the virtual address space of the calling process, in bytes.
*/
public DWORDLONG ullTotalVirtual;
/**
* The amount of unreserved and uncommitted memory currently in the user-mode portion of the
* virtual address space of the calling process, in bytes.
*/
public DWORDLONG ullAvailVirtual;
/**
* Reserved. This value is always 0.
*/
public DWORDLONG ullAvailExtendedVirtual;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwLength", "dwMemoryLoad", "ullTotalPhys", "ullAvailPhys", "ullTotalPageFile", "ullAvailPageFile", "ullTotalVirtual", "ullAvailVirtual", "ullAvailExtendedVirtual" });
}
public MEMORYSTATUSEX() {
dwLength = new DWORD(size());
}
};
/**
* The SECURITY_ATTRIBUTES structure contains the security descriptor for an
* object and specifies whether the handle retrieved by specifying this
* structure is inheritable. This structure provides security settings for
* objects created by various functions, such as {@link Kernel32#CreateFile},
* {@link Kernel32#CreatePipe}, or {@link Advapi32#RegCreateKeyEx}.
*/
public static class SECURITY_ATTRIBUTES extends Structure {
/**
* The size of the structure, in bytes.
*/
public DWORD dwLength;
/**
* A pointer to a SECURITY_DESCRIPTOR structure that controls access to the object.
*/
public Pointer lpSecurityDescriptor;
/**
* A Boolean value that specifies whether the returned handle is inherited when
* a new process is created
*/
public boolean bInheritHandle;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwLength", "lpSecurityDescriptor", "bInheritHandle" });
}
public SECURITY_ATTRIBUTES() {
dwLength = new DWORD(size());
}
}
/**
* Specifies the window station, desktop, standard handles, and appearance of the main
* window for a process at creation time.
*/
public static class STARTUPINFO extends Structure {
/**
* The size of the structure, in bytes.
*/
public DWORD cb;
/**
* Reserved; must be NULL.
*/
public String lpReserved;
/**
* The name of the desktop, or the name of both the desktop and window station for this process.
* A backslash in the string indicates that the string includes both the desktop and window
* station names. For more information, see Thread Connection to a Desktop.
*/
public String lpDesktop;
/**
* For console processes, this is the title displayed in the title bar
* if a new console window is created. If NULL, the name of the
* executable file is used as the window title instead. This parameter
* must be NULL for GUI or console processes that do not create a new
* console window.
*/
public String lpTitle;
/**
* If dwFlags specifies STARTF_USEPOSITION, this member is the x offset
* of the upper left corner of a window if a new window is created, in
* pixels. Otherwise, this member is ignored.
*
* The offset is from the upper left corner of the screen. For GUI
* processes, the specified position is used the first time the new
* process calls CreateWindow to create an overlapped window if the x
* parameter of CreateWindow is CW_USEDEFAULT.
*/
public DWORD dwX;
/**
* If dwFlags specifies STARTF_USEPOSITION, this member is the y offset
* of the upper left corner of a window if a new window is created, in
* pixels. Otherwise, this member is ignored.
*
* The offset is from the upper left corner of the screen. For GUI
* processes, the specified position is used the first time the new
* process calls CreateWindow to create an overlapped window if the y
* parameter of CreateWindow is CW_USEDEFAULT.
*/
public DWORD dwY;
/**
* If dwFlags specifies STARTF_USESIZE, this member is the width of the
* window if a new window is created, in pixels. Otherwise, this member
* is ignored.
*
* For GUI processes, this is used only the first time the new process
* calls CreateWindow to create an overlapped window if the nWidth
* parameter of CreateWindow is CW_USEDEFAULT.
*/
public DWORD dwXSize;
/**
* If dwFlags specifies STARTF_USESIZE, this member is the height of the
* window if a new window is created, in pixels. Otherwise, this member
* is ignored.
*
* For GUI processes, this is used only the first time the new process
* calls CreateWindow to create an overlapped window if the nHeight
* parameter of CreateWindow is CW_USEDEFAULT.
*/
public DWORD dwYSize;
/**
* If dwFlags specifies STARTF_USECOUNTCHARS, if a new console window is
* created in a console process, this member specifies the screen buffer
* width, in character columns. Otherwise, this member is ignored.
*/
public DWORD dwXCountChars;
/**
* If dwFlags specifies STARTF_USECOUNTCHARS, if a new console window is
* created in a console process, this member specifies the screen buffer
* height, in character rows. Otherwise, this member is ignored.
*/
public DWORD dwYCountChars;
/**
* If dwFlags specifies STARTF_USEFILLATTRIBUTE, this member is the
* initial text and background colors if a new console window is created
* in a console application. Otherwise, this member is ignored.
*
* This value can be any combination of the following values:
* FOREGROUND_BLUE, FOREGROUND_GREEN, FOREGROUND_RED,
* FOREGROUND_INTENSITY, BACKGROUND_BLUE, BACKGROUND_GREEN,
* BACKGROUND_RED, and BACKGROUND_INTENSITY. For example, the following
* combination of values produces red text on a white background:
*
* FOREGROUND_RED| BACKGROUND_RED| BACKGROUND_GREEN| BACKGROUND_BLUE
*/
public DWORD dwFillAttribute;
/**
* A bit field that determines whether certain STARTUPINFO members are
* used when the process creates a window.
*/
public int dwFlags;
/**
* If dwFlags specifies STARTF_USESHOWWINDOW, this member can be any of
* the values that can be specified in the nCmdShow parameter for the
* ShowWindow function, except for SW_SHOWDEFAULT. Otherwise, this
* member is ignored.
*
* For GUI processes, the first time ShowWindow is called, its nCmdShow
* parameter is ignored wShowWindow specifies the default value. In
* subsequent calls to ShowWindow, the wShowWindow member is used if the
* nCmdShow parameter of ShowWindow is set to SW_SHOWDEFAULT.
*/
public WORD wShowWindow;
/**
* Reserved for use by the C Run-time; must be zero.
*/
public WORD cbReserved2;
/**
* Reserved for use by the C Run-time; must be NULL.
*/
public ByteByReference lpReserved2;
/**
* If dwFlags specifies STARTF_USESTDHANDLES, this member is the
* standard input handle for the process. If STARTF_USESTDHANDLES is not
* specified, the default for standard input is the keyboard buffer.
*
* If dwFlags specifies STARTF_USEHOTKEY, this member specifies a hotkey
* value that is sent as the wParam parameter of a WM_SETHOTKEY message
* to the first eligible top-level window created by the application
* that owns the process. If the window is created with the WS_POPUP
* window style, it is not eligible unless the WS_EX_APPWINDOW extended
* window style is also set. For more information, see CreateWindowEx.
*
* Otherwise, this member is ignored.
*/
public HANDLE hStdInput;
/**
* If dwFlags specifies STARTF_USESTDHANDLES, this member is the
* standard output handle for the process. Otherwise, this member is
* ignored and the default for standard output is the console window's
* buffer.
*/
public HANDLE hStdOutput;
/**
* If dwFlags specifies STARTF_USESTDHANDLES, this member is the
* standard error handle for the process. Otherwise, this member is
* ignored and the default for standard error is the console window's
* buffer.
*/
public HANDLE hStdError;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cb", "lpReserved", "lpDesktop", "lpTitle", "dwX", "dwY", "dwXSize", "dwYSize", "dwXCountChars", "dwYCountChars", "dwFillAttribute", "dwFlags", "wShowWindow", "cbReserved2", "lpReserved2", "hStdInput", "hStdOutput", "hStdError" });
}
public STARTUPINFO() {
cb = new DWORD(size());
}
}
/**
* Contains information about a newly created process and its primary
* thread. It is used with the CreateProcess, CreateProcessAsUser,
* CreateProcessWithLogonW, or CreateProcessWithTokenW function.
*/
public static class PROCESS_INFORMATION extends Structure {
/**
* A handle to the newly created process. The handle is used to specify
* the process in all functions that perform operations on the process
* object.
*/
public HANDLE hProcess;
/**
* A handle to the primary thread of the newly created process. The
* handle is used to specify the thread in all functions that perform
* operations on the thread object.
*/
public HANDLE hThread;
/**
* A value that can be used to identify a process. The value is valid
* from the time the process is created until all handles to the process
* are closed and the process object is freed; at this point, the
* identifier may be reused.
*/
public DWORD dwProcessId;
/**
* A value that can be used to identify a thread. The value is valid
* from the time the thread is created until all handles to the thread
* are closed and the thread object is freed; at this point, the
* identifier may be reused.
*/
public DWORD dwThreadId;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "hProcess", "hThread", "dwProcessId", "dwThreadId" });
}
public static class ByReference extends PROCESS_INFORMATION implements Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public PROCESS_INFORMATION() {
}
public PROCESS_INFORMATION(Pointer memory) {
super(memory);
read();
}
}
/**
* If the file is to be moved to a different volume, the function simulates the move by using the CopyFile and DeleteFile functions.
*
* This value cannot be used with MOVEFILE_DELAY_UNTIL_REBOOT.
*/
int MOVEFILE_COPY_ALLOWED = 0x2;
/**
* Reserved for future use.
*/
int MOVEFILE_CREATE_HARDLINK = 0x10;
/**
* The system does not move the file until the operating system is restarted. The system moves the file immediately
* after AUTOCHK is executed, but before creating any paging files. Consequently, this parameter enables the
* function to delete paging files from previous startups.
*
* This value can be used only if the process is in the context of a user who belongs to the administrators group or
* the LocalSystem account.
*
* This value cannot be used with MOVEFILE_COPY_ALLOWED.
*
* Windows Server 2003 and Windows XP: For information about special situations where this functionality can fail,
* and a suggested workaround solution, see Files are not exchanged when Windows Server 2003 restarts if you use the
* MoveFileEx function to schedule a replacement for some files in the Help and Support Knowledge Base.
*
* Windows 2000: If you specify the MOVEFILE_DELAY_UNTIL_REBOOT flag for dwFlags, you cannot also prepend the file
* name that is specified by lpExistingFileName with "\\?".
*/
int MOVEFILE_DELAY_UNTIL_REBOOT = 0x4;
/**
* The function fails if the source file is a link source, but the file cannot be tracked after the move. This
* situation can occur if the destination is a volume formatted with the FAT file system.
*/
int MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20;
/**
* If a file named lpNewFileName exists, the function replaces its contents with the contents of the
* lpExistingFileName file, provided that security requirements regarding access control lists (ACLs) are met. For
* more information, see the Remarks section of this topic.
*
* This value cannot be used if lpNewFileName or lpExistingFileName names a directory.
*/
int MOVEFILE_REPLACE_EXISTING = 0x1;
/**
* The function does not return until the file is actually moved on the disk.
*
* Setting this value guarantees that a move performed as a copy and delete operation is flushed to disk before the
* function returns. The flush occurs at the end of the copy operation.
*
* This value has no effect if MOVEFILE_DELAY_UNTIL_REBOOT is set.
*/
int MOVEFILE_WRITE_THROUGH = 0x8;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,70 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.jpexs.decompiler.flash.gui.player.jna.platform.win32;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.ByReference;
import com.sun.jna.win32.StdCallLibrary;
/**
* This module contains the function prototypes and constant, type and structure
* definitions for the Windows 32-Bit Registry API.
* Ported from WinReg.h
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface WinReg extends StdCallLibrary {
public static class HKEY extends HANDLE {
public HKEY() { }
public HKEY(Pointer p) { super(p); }
public HKEY(int value) { super(new Pointer(value)); }
}
public static class HKEYByReference extends ByReference {
public HKEYByReference() {
this(null);
}
public HKEYByReference(HKEY h) {
super(Pointer.SIZE);
setValue(h);
}
public void setValue(HKEY h) {
getPointer().setPointer(0, h != null ? h.getPointer() : null);
}
public HKEY getValue() {
Pointer p = getPointer().getPointer(0);
if (p == null)
return null;
if (WinBase.INVALID_HANDLE_VALUE.getPointer().equals(p))
return (HKEY) WinBase.INVALID_HANDLE_VALUE;
HKEY h = new HKEY();
h.setPointer(p);
return h;
}
}
HKEY HKEY_CLASSES_ROOT = new HKEY(0x80000000);
HKEY HKEY_CURRENT_USER = new HKEY(0x80000001);
HKEY HKEY_LOCAL_MACHINE = new HKEY(0x80000002);
HKEY HKEY_USERS = new HKEY(0x80000003);
HKEY HKEY_PERFORMANCE_DATA= new HKEY(0x80000004);
HKEY HKEY_PERFORMANCE_TEXT= new HKEY(0x80000050);
HKEY HKEY_PERFORMANCE_NLSTEXT = new HKEY(0x80000060);
HKEY HKEY_CURRENT_CONFIG = new HKEY(0x80000005);
HKEY HKEY_DYN_DATA = new HKEY(0x80000006);
}
@@ -0,0 +1,900 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU
* Lesser General Public License for more details.
*/
package com.jpexs.decompiler.flash.gui.player.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
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.jpexs.decompiler.flash.gui.player.jna.platform.win32.BaseTSD.ULONG_PTR;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.HBRUSH;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.HCURSOR;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.HICON;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.HINSTANCE;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.HWND;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.LPARAM;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.LRESULT;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinDef.WPARAM;
import com.jpexs.decompiler.flash.gui.player.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from WinUser.h Microsoft Windows SDK 6.0A.
*
* @author dblock[at]dblock.org
*/
public interface WinUser extends StdCallLibrary, WinDef {
HWND HWND_BROADCAST = new HWND(Pointer.createConstant(0xFFFF));
HWND HWND_MESSAGE = new HWND(Pointer.createConstant(-3));
/* RegisterDeviceNotification stuff */
public static class HDEVNOTIFY extends PVOID {
public HDEVNOTIFY() {
}
public HDEVNOTIFY(Pointer p) {
super(p);
}
}
int FLASHW_STOP = 0;
int FLASHW_CAPTION = 1;
int FLASHW_TRAY = 2;
int FLASHW_ALL = (FLASHW_CAPTION | FLASHW_TRAY);
int FLASHW_TIMER = 4;
int FLASHW_TIMERNOFG = 12;
int IMAGE_BITMAP = 0;
int IMAGE_ICON = 1;
int IMAGE_CURSOR = 2;
int IMAGE_ENHMETAFILE = 3;
int LR_DEFAULTCOLOR = 0x0000;
int LR_MONOCHROME = 0x0001;
int LR_COLOR = 0x0002;
int LR_COPYRETURNORG = 0x0004;
int LR_COPYDELETEORG = 0x0008;
int LR_LOADFROMFILE = 0x0010;
int LR_LOADTRANSPARENT = 0x0020;
int LR_DEFAULTSIZE = 0x0040;
int LR_VGACOLOR = 0x0080;
int LR_LOADMAP3DCOLORS = 0x1000;
int LR_CREATEDIBSECTION = 0x2000;
int LR_COPYFROMRESOURCE = 0x4000;
int LR_SHARED = 0x8000;
public class GUITHREADINFO extends Structure {
public int cbSize = size();
public int flags;
public HWND hwndActive;
public HWND hwndFocus;
public HWND hwndCapture;
public HWND hwndMenuOwner;
public HWND hwndMoveSize;
public HWND hwndCaret;
public RECT rcCaret;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbSize", "flags",
"hwndActive", "hwndFocus", "hwndCapture", "hwndMenuOwner",
"hwndMoveSize", "hwndCaret", "rcCaret" });
}
}
public class WINDOWINFO extends Structure {
public int cbSize = size();
public RECT rcWindow;
public RECT rcClient;
public int dwStyle;
public int dwExStyle;
public int dwWindowStatus;
public int cxWindowBorders;
public int cyWindowBorders;
public short atomWindowType;
public short wCreatorVersion;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbSize", "rcWindow",
"rcClient", "dwStyle", "dwExStyle", "dwWindowStatus",
"cxWindowBorders", "cyWindowBorders", "atomWindowType",
"wCreatorVersion" });
}
}
int GWL_EXSTYLE = -20;
int GWL_STYLE = -16;
int GWL_WNDPROC = -4;
int GWL_HINSTANCE = -6;
int GWL_ID = -12;
int GWL_USERDATA = -21;
int DWL_DLGPROC = 4;
int DWL_MSGRESULT = 0;
int DWL_USER = 8;
int WS_MAXIMIZE = 0x01000000;
int WS_VISIBLE = 0x10000000;
int WS_MINIMIZE = 0x20000000;
int WS_CHILD = 0x40000000;
int WS_POPUP = 0x80000000;
int WS_EX_COMPOSITED = 0x20000000;
int WS_EX_LAYERED = 0x80000;
int WS_EX_TRANSPARENT = 32;
int LWA_COLORKEY = 1;
int LWA_ALPHA = 2;
int ULW_COLORKEY = 1;
int ULW_ALPHA = 2;
int ULW_OPAQUE = 4;
/** Defines the x- and y-coordinates of a point. */
public class POINT extends Structure {
public int x, y;
public POINT() {
}
public POINT(int x, int y) {
this.x = x;
this.y = y;
}
protected List getFieldOrder() {
return Arrays.asList(new String[] { "x", "y" });
}
}
public class MSG extends Structure {
public HWND hWnd;
public int message;
public WPARAM wParam;
public LPARAM lParam;
public int time;
public POINT pt;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "hWnd", "message", "wParam",
"lParam", "time", "pt" });
}
}
public class FLASHWINFO extends Structure {
public int cbSize;
public HANDLE hWnd;
public int dwFlags;
public int uCount;
public int dwTimeout;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbSize", "hWnd", "dwFlags",
"uCount", "dwTimeout" });
}
}
public interface WNDENUMPROC extends StdCallCallback {
/** Return whether to continue enumeration. */
boolean callback(HWND hWnd, Pointer data);
}
public interface LowLevelKeyboardProc extends HOOKPROC {
LRESULT callback(int nCode, WPARAM wParam, KBDLLHOOKSTRUCT lParam);
}
/** Specifies the width and height of a rectangle. */
public class SIZE extends Structure {
public int cx, cy;
public SIZE() {
}
public SIZE(int w, int h) {
this.cx = w;
this.cy = h;
}
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cx", "cy" });
}
}
int AC_SRC_OVER = 0x00;
int AC_SRC_ALPHA = 0x01;
int AC_SRC_NO_PREMULT_ALPHA = 0x01;
int AC_SRC_NO_ALPHA = 0x02;
public class BLENDFUNCTION extends Structure {
public byte BlendOp = AC_SRC_OVER; // only valid value
public byte BlendFlags = 0; // only valid value
public byte SourceConstantAlpha;
public byte AlphaFormat;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "BlendOp", "BlendFlags",
"SourceConstantAlpha", "AlphaFormat" });
}
}
int VK_SHIFT = 16;
int VK_LSHIFT = 0xA0;
int VK_RSHIFT = 0xA1;
int VK_CONTROL = 17;
int VK_LCONTROL = 0xA2;
int VK_RCONTROL = 0xA3;
int VK_MENU = 18;
int VK_LMENU = 0xA4;
int VK_RMENU = 0xA5;
int MOD_ALT = 0x0001;
int MOD_CONTROL = 0x0002;
int MOD_NOREPEAT = 0x4000;
int MOD_SHIFT = 0x0004;
int MOD_WIN = 0x0008;
int WH_KEYBOARD = 2;
int WH_MOUSE = 7;
int WH_KEYBOARD_LL = 13;
int WH_MOUSE_LL = 14;
public class HHOOK extends HANDLE {
}
public interface HOOKPROC extends StdCallCallback {
}
/**
* The WM_PAINT message is sent when the system or another application makes
* a request to paint a portion of an \ application's window.
*/
int WM_PAINT = 0x000F;
/**
* Sent as a signal that a window or an application should terminate.
*/
int WM_CLOSE = 0x0010;
/**
* Indicates a request to terminate an application, and is generated when
* the application calls the PostQuitMessage function.
*/
int WM_QUIT = 0x0012;
/**
* Sent to a window when the window is about to be hidden or shown.
*/
int WM_SHOWWINDOW = 0x0018;
/**
* Sent to the parent window of an owner-drawn button, combo box, list box,
* or menu when a visual aspect of the button, combo box, list box, or menu
* has changed.
*/
int WM_DRAWITEM = 0x002B;
/**
* Posted to the window with the keyboard focus when a nonsystem key is
* pressed. A nonsystem key is a key that is pressed when the ALT key is not
* pressed.
*/
int WM_KEYDOWN = 0x0100;
/**
* Posted to the window with the keyboard focus when a WM_KEYDOWN message is
* translated by the TranslateMessage function. The WM_CHAR message contains
* the character code of the key that was pressed.
*/
int WM_CHAR = 0x0102;
/**
* A window receives this message when the user chooses a command from the
* Window menu (formerly known as the system or control menu) or when the
* user chooses the maximize button, minimize button, restore button, or
* close button.
*/
int WM_SYSCOMMAND = 0x0112;
/**
* An application sends the WM_MDIMAXIMIZE message to a multiple-document
* interface (MDI) client window to maximize an MDI child window.
*/
int WM_MDIMAXIMIZE = 0x0225;
/**
* Posted when the user presses a hot key registered by the RegisterHotKey
* function. The message is placed at the top of the message queue
* associated with the thread that registered the hot key.
*/
int WM_HOTKEY = 0x0312;
int WM_KEYUP = 257;
int WM_SYSKEYDOWN = 260;
int WM_SYSKEYUP = 261;
int WM_SESSION_CHANGE = 0x2b1;
int WM_CREATE = 0x0001;
int WM_SIZE = 0x0005;
int WM_DESTROY = 0x0002;
public static final int WM_DEVICECHANGE = 0x0219;
public class KBDLLHOOKSTRUCT extends Structure {
public int vkCode;
public int scanCode;
public int flags;
public int time;
public ULONG_PTR dwExtraInfo;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "vkCode", "scanCode", "flags",
"time", "dwExtraInfo" });
}
}
int SM_CXSCREEN = 0;
int SM_CYSCREEN = 1;
int SM_CXVSCROLL = 2;
int SM_CYHSCROLL = 3;
int SM_CYCAPTION = 4;
int SM_CXBORDER = 5;
int SM_CYBORDER = 6;
int SM_CXDLGFRAME = 7;
int SM_CYDLGFRAME = 8;
int SM_CYVTHUMB = 9;
int SM_CXHTHUMB = 10;
int SM_CXICON = 11;
int SM_CYICON = 12;
int SM_CXCURSOR = 13;
int SM_CYCURSOR = 14;
int SM_CYMENU = 15;
int SM_CXFULLSCREEN = 16;
int SM_CYFULLSCREEN = 17;
int SM_CYKANJIWINDOW = 18;
int SM_MOUSEPRESENT = 19;
int SM_CYVSCROLL = 20;
int SM_CXHSCROLL = 21;
int SM_DEBUG = 22;
int SM_SWAPBUTTON = 23;
int SM_RESERVED1 = 24;
int SM_RESERVED2 = 25;
int SM_RESERVED3 = 26;
int SM_RESERVED4 = 27;
int SM_CXMIN = 28;
int SM_CYMIN = 29;
int SM_CXSIZE = 30;
int SM_CYSIZE = 31;
int SM_CXFRAME = 32;
int SM_CYFRAME = 33;
int SM_CXMINTRACK = 34;
int SM_CYMINTRACK = 35;
int SM_CXDOUBLECLK = 36;
int SM_CYDOUBLECLK = 37;
int SM_CXICONSPACING = 38;
int SM_CYICONSPACING = 39;
int SM_MENUDROPALIGNMENT = 40;
int SM_PENWINDOWS = 41;
int SM_DBCSENABLED = 42;
int SM_CMOUSEBUTTONS = 43;
int SM_CXFIXEDFRAME = SM_CXDLGFRAME; /* ;win40 name change */
int SM_CYFIXEDFRAME = SM_CYDLGFRAME; /* ;win40 name change */
int SM_CXSIZEFRAME = SM_CXFRAME; /* ;win40 name change */
int SM_CYSIZEFRAME = SM_CYFRAME; /* ;win40 name change */
int SM_SECURE = 44;
int SM_CXEDGE = 45;
int SM_CYEDGE = 46;
int SM_CXMINSPACING = 47;
int SM_CYMINSPACING = 48;
int SM_CXSMICON = 49;
int SM_CYSMICON = 50;
int SM_CYSMCAPTION = 51;
int SM_CXSMSIZE = 52;
int SM_CYSMSIZE = 53;
int SM_CXMENUSIZE = 54;
int SM_CYMENUSIZE = 55;
int SM_ARRANGE = 56;
int SM_CXMINIMIZED = 57;
int SM_CYMINIMIZED = 58;
int SM_CXMAXTRACK = 59;
int SM_CYMAXTRACK = 60;
int SM_CXMAXIMIZED = 61;
int SM_CYMAXIMIZED = 62;
int SM_NETWORK = 63;
int SM_CLEANBOOT = 67;
int SM_CXDRAG = 68;
int SM_CYDRAG = 69;
int SM_SHOWSOUNDS = 70;
int SM_CXMENUCHECK = 71;
int SM_CYMENUCHECK = 72;
int SM_SLOWMACHINE = 73;
int SM_MIDEASTENABLED = 74;
int SM_MOUSEWHEELPRESENT = 75;
int SM_XVIRTUALSCREEN = 76;
int SM_YVIRTUALSCREEN = 77;
int SM_CXVIRTUALSCREEN = 78;
int SM_CYVIRTUALSCREEN = 79;
int SM_CMONITORS = 80;
int SM_SAMEDISPLAYFORMAT = 81;
int SM_IMMENABLED = 82;
int SM_CXFOCUSBORDER = 83;
int SM_CYFOCUSBORDER = 84;
int SM_TABLETPC = 86;
int SM_MEDIACENTER = 87;
int SM_STARTER = 88;
int SM_SERVERR2 = 89;
int SM_MOUSEHORIZONTALWHEELPRESENT = 91;
int SM_CXPADDEDBORDER = 92;
int SM_REMOTESESSION = 0x1000;
int SM_SHUTTINGDOWN = 0x2000;
int SM_REMOTECONTROL = 0x2001;
int SM_CARETBLINKINGENABLED = 0x2002;
int SW_HIDE = 0;
int SW_SHOWNORMAL = 1;
int SW_NORMAL = 1;
int SW_SHOWMINIMIZED = 2;
int SW_SHOWMAXIMIZED = 3;
int SW_MAXIMIZE = 3;
int SW_SHOWNOACTIVATE = 4;
int SW_SHOW = 5;
int SW_MINIMIZE = 6;
int SW_SHOWMINNOACTIVE = 7;
int SW_SHOWNA = 8;
int SW_RESTORE = 9;
int SW_SHOWDEFAULT = 10;
int SW_FORCEMINIMIZE = 11;
int SW_MAX = 11;
int RDW_INVALIDATE = 0x0001;
int RDW_INTERNALPAINT = 0x0002;
int RDW_ERASE = 0x0004;
int RDW_VALIDATE = 0x0008;
int RDW_NOINTERNALPAINT = 0x0010;
int RDW_NOERASE = 0x0020;
int RDW_NOCHILDREN = 0x0040;
int RDW_ALLCHILDREN = 0x0080;
int RDW_UPDATENOW = 0x0100;
int RDW_ERASENOW = 0x0200;
int RDW_FRAME = 0x0400;
int RDW_NOFRAME = 0x0800;
/**
* The retrieved handle identifies the window of the same type that is
* highest in the Z order.
*
* If the specified window is a topmost window, the handle identifies a
* topmost window. If the specified window is a top-level window, the handle
* identifies a top-level window. If the specified window is a child window,
* the handle identifies a sibling window.
*/
int GW_HWNDFIRST = 0;
/**
* The retrieved handle identifies the window of the same type that is
* lowest in the Z order.
*
* If the specified window is a topmost window, the handle identifies a
* topmost window. If the specified window is a top-level window, the handle
* identifies a top-level window. If the specified window is a child window,
* the handle identifies a sibling window.
*/
int GW_HWNDLAST = 1;
/**
* The retrieved handle identifies the window below the specified window in
* the Z order.
*
* If the specified window is a topmost window, the handle identifies a
* topmost window. If the specified window is a top-level window, the handle
* identifies a top-level window. If the specified window is a child window,
* the handle identifies a sibling window.
*/
int GW_HWNDNEXT = 2;
/**
* The retrieved handle identifies the window above the specified window in
* the Z order.
*
* If the specified window is a topmost window, the handle identifies a
* topmost window. If the specified window is a top-level window, the handle
* identifies a top-level window. If the specified window is a child window,
* the handle identifies a sibling window.
*/
int GW_HWNDPREV = 3;
/**
* The retrieved handle identifies the specified window's owner window, if
* any. For more information, see Owned Windows.
*/
int GW_OWNER = 4;
/**
* The retrieved handle identifies the child window at the top of the Z
* order, if the specified window is a parent window; otherwise, the
* retrieved handle is NULL. The function examines only child windows of the
* specified window. It does not examine descendant windows.
*/
int GW_CHILD = 5;
/**
* The retrieved handle identifies the enabled popup window owned by the
* specified window (the search uses the first such window found using
* GW_HWNDNEXT); otherwise, if there are no enabled popup windows, the
* retrieved handle is that of the specified window.
*/
int GW_ENABLEDPOPUP = 6;
/**
* Retains the current Z order (ignores the hWndInsertAfter parameter).
*/
int SWP_NOZORDER = 0x0004;
/**
* Minimizes the window.
*/
int SC_MINIMIZE = 0xF020;
/**
* Maximizes the window.
*/
int SC_MAXIMIZE = 0xF030;
/**
* Contains information about a simulated message generated by an input
* device other than a keyboard or mouse.
*/
public static class HARDWAREINPUT extends Structure {
public static class ByReference extends HARDWAREINPUT implements
Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public HARDWAREINPUT() {
}
public HARDWAREINPUT(Pointer memory) {
super(memory);
read();
}
public WinDef.DWORD uMsg;
public WinDef.WORD wParamL;
public WinDef.WORD wParamH;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "uMsg", "wParamL", "wParamH" });
}
}
/**
* Used by SendInput to store information for synthesizing input events such
* as keystrokes, mouse movement, and mouse clicks.
*/
public static class INPUT extends Structure {
public static final int INPUT_MOUSE = 0;
public static final int INPUT_KEYBOARD = 1;
public static final int INPUT_HARDWARE = 2;
public static class ByReference extends INPUT implements
Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public INPUT() {
}
public INPUT(Pointer memory) {
super(memory);
read();
}
public WinDef.DWORD type;
public INPUT_UNION input = new INPUT_UNION();
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "input" });
}
public static class INPUT_UNION extends Union {
public INPUT_UNION() {
}
public INPUT_UNION(Pointer memory) {
super(memory);
read();
}
public MOUSEINPUT mi;
public KEYBDINPUT ki;
public HARDWAREINPUT hi;
}
}
/**
* Contains information about a simulated keyboard event.
*/
public static class KEYBDINPUT extends Structure {
/**
* If specified, the scan code was preceded by a prefix byte that has
* the value 0xE0 (224).
*/
public static final int KEYEVENTF_EXTENDEDKEY = 0x0001;
/**
* If specified, the key is being released. If not specified, the key is
* being pressed.
*/
public static final int KEYEVENTF_KEYUP = 0x0002;
/**
* If specified, the system synthesizes a VK_PACKET keystroke. The wVk
* parameter must be zero. This flag can only be combined with the
* KEYEVENTF_KEYUP flag. For more information, see the Remarks section.
*/
public static final int KEYEVENTF_UNICODE = 0x0004;
/**
* If specified, wScan identifies the key and wVk is ignored.
*/
public static final int KEYEVENTF_SCANCODE = 0x0008;
public static class ByReference extends KEYBDINPUT implements
Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public KEYBDINPUT() {
}
public KEYBDINPUT(Pointer memory) {
super(memory);
read();
}
/**
* A virtual-key code. The code must be a value in the range 1 to 254.
* If the dwFlags member specifies KEYEVENTF_UNICODE, wVk must be 0.
*/
public WinDef.WORD wVk;
/**
* A hardware scan code for the key. If dwFlags specifies
* KEYEVENTF_UNICODE, wScan specifies a Unicode character which is to be
* sent to the foreground application.
*/
public WinDef.WORD wScan;
/**
* Specifies various aspects of a keystroke. This member can be certain
* combinations of the following values.
*/
public WinDef.DWORD dwFlags;
/**
* The time stamp for the event, in milliseconds. If this parameter is
* zero, the system will provide its own time stamp.
*/
public WinDef.DWORD time;
/**
* An additional value associated with the keystroke. Use the
* GetMessageExtraInfo function to obtain this information.
*/
public BaseTSD.ULONG_PTR dwExtraInfo;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "wVk", "wScan", "dwFlags",
"time", "dwExtraInfo" });
}
}
/**
* Contains information about a simulated mouse event.
*/
public static class MOUSEINPUT extends Structure {
public static class ByReference extends MOUSEINPUT implements
Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public MOUSEINPUT() {
}
public MOUSEINPUT(Pointer memory) {
super(memory);
read();
}
public WinDef.LONG dx;
public WinDef.LONG dy;
public WinDef.DWORD mouseData;
public WinDef.DWORD dwFlags;
public WinDef.DWORD time;
public BaseTSD.ULONG_PTR dwExtraInfo;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dx", "dy", "mouseData",
"dwFlags", "time", "dwExtraInfo" });
}
}
/**
* Contains the time of the last input.
*/
public static class LASTINPUTINFO extends Structure {
public int cbSize = size();
// Tick count of when the last input event was received.
public int dwTime;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbSize", "dwTime" });
}
}
/**
* Contains window class information. It is used with the RegisterClassEx
* and GetClassInfoEx functions.
*
* The WNDCLASSEX structure is similar to the WNDCLASS structure. There are
* two differences. WNDCLASSEX includes the cbSize member, which specifies
* the size of the structure, and the hIconSm member, which contains a
* handle to a small icon associated with the window class.
*/
public class WNDCLASSEX extends Structure {
/**
* The Class ByReference.
*/
public static class ByReference extends WNDCLASSEX implements
Structure.ByReference {
}
/**
* Instantiates a new wndclassex.
*/
public WNDCLASSEX() {
}
/**
* Instantiates a new wndclassex.
*
* @param memory
* the memory
*/
public WNDCLASSEX(Pointer memory) {
super(memory);
read();
}
/** The cb size. */
public int cbSize = this.size();
/** The style. */
public int style;
/** The lpfn wnd proc. */
public Callback lpfnWndProc;
/** The cb cls extra. */
public int cbClsExtra;
/** The cb wnd extra. */
public int cbWndExtra;
/** The h instance. */
public HINSTANCE hInstance;
/** The h icon. */
public HICON hIcon;
/** The h cursor. */
public HCURSOR hCursor;
/** The hbr background. */
public HBRUSH hbrBackground;
/** The lpsz menu name. */
public String lpszMenuName;
/** The lpsz class name. */
public WString lpszClassName;
/** The h icon sm. */
public HICON hIconSm;
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbSize", "style",
"lpfnWndProc", "cbClsExtra", "cbWndExtra", "hInstance",
"hIcon", "hCursor", "hbrBackground", "lpszMenuName",
"lpszClassName", "hIconSm" });
}
}
/**
* An application-defined function that processes messages sent to a window.
* The WNDPROC type defines a pointer to this callback function.
*
* WindowProc is a placeholder for the application-defined function name.
*/
public interface WindowProc extends Callback {
/**
* @param hwnd
* [in] Type: HWND
*
* A handle to the window.
*
* @param uMsg
* [in] Type: UINT
*
* The message.
*
* For lists of the system-provided messages, see
* System-Defined Messages.
*
* @param wParam
* [in] Type: WPARAM
*
* Additional message information. The contents of this
* parameter depend on the value of the uMsg parameter.
*
* @param lParam
* [in] Type: LPARAM
*
* Additional message information. The contents of this
* parameter depend on the value of the uMsg parameter.
*
* @return the lresult
*/
LRESULT callback(HWND hwnd, int uMsg, WPARAM wParam, LPARAM lParam);
}
}