libjna-java-3.2.7/0000755000175000017500000000000011526013532012001 5ustar janjanlibjna-java-3.2.7/pom.xml0000644000175000017500000000403611421462510013317 0ustar janjan 4.0.0 net.java.dev.jna jna jar 3.2.7 Java Native Access false java.net-maven2-repository java-net:/maven2-repository/trunk/repository/ org.jvnet.maven-antrun-extended-plugin maven-antrun-extended-plugin package run org.jvnet.wagon-svn wagon-svn 1.8 maven2-repository.dev.java.net Java.net Repository for Maven http://download.java.net/maven/2/ maven2-repository.dev.java.net Java.net Repository for Maven http://download.java.net/maven/2/ libjna-java-3.2.7/contrib/0000755000175000017500000000000011421132764013444 5ustar janjanlibjna-java-3.2.7/contrib/platform/0000755000175000017500000000000011421406524015266 5ustar janjanlibjna-java-3.2.7/contrib/platform/src/0000755000175000017500000000000011421126012016044 5ustar janjanlibjna-java-3.2.7/contrib/platform/src/com/0000755000175000017500000000000011421126012016622 5ustar janjanlibjna-java-3.2.7/contrib/platform/src/com/sun/0000755000175000017500000000000011421126012017427 5ustar janjanlibjna-java-3.2.7/contrib/platform/src/com/sun/jna/0000755000175000017500000000000011421126012020177 5ustar janjanlibjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/0000755000175000017500000000000011421126022022024 5ustar janjanlibjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/mac/0000755000175000017500000000000011421126014022565 5ustar janjanlibjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/mac/MacFileUtils.java0000644000175000017500000000324611421126014025756 0ustar janjan/* 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. * * 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.mac; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import com.sun.jna.platform.FileUtils; public class MacFileUtils extends FileUtils { public boolean hasTrash() { return true; } public void moveToTrash(File[] files) throws IOException { // TODO: use native API for moving to trash (if any) File home = new File(System.getProperty("user.home")); File trash = new File(home, ".Trash"); if (!trash.exists()) { throw new IOException("The Trash was not found in its expected location (" + trash + ")"); } List failed = new ArrayList(); for (int i=0;i < files.length;i++) { File src = files[i]; File target = new File(trash, src.getName()); if (!src.renameTo(target)) { failed.add(src); } } if (failed.size() > 0) { throw new IOException("The following files could not be trashed: " + failed); } } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/WindowUtils.java0000644000175000017500000020310411421126022025157 0ustar janjan/* * Copyright (c) 2007-2008 Timothy Wall, All Rights Reserved * Parts Copyright (c) 2007 Olivier Chafik * * 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; import java.awt.AWTEvent; import java.awt.AlphaComposite; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dialog; import java.awt.Dimension; import java.awt.Frame; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Point; import java.awt.Rectangle; import java.awt.Shape; import java.awt.Toolkit; import java.awt.Window; import java.awt.event.AWTEventListener; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.event.ContainerEvent; import java.awt.event.HierarchyEvent; import java.awt.event.HierarchyListener; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.geom.Area; import java.awt.geom.PathIterator; import java.awt.image.BufferedImage; import java.awt.image.Raster; import java.util.ArrayList; import java.util.List; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JLayeredPane; import javax.swing.JPanel; import javax.swing.JRootPane; import javax.swing.PopupFactory; import javax.swing.RootPaneContainer; import javax.swing.SwingUtilities; import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.NativeLong; import com.sun.jna.Platform; import com.sun.jna.Pointer; import com.sun.jna.platform.unix.X11; import com.sun.jna.platform.unix.X11.Display; import com.sun.jna.platform.unix.X11.GC; import com.sun.jna.platform.unix.X11.Pixmap; import com.sun.jna.platform.unix.X11.XVisualInfo; import com.sun.jna.platform.unix.X11.Xext; import com.sun.jna.platform.unix.X11.Xrender.XRenderPictFormat; import com.sun.jna.platform.win32.GDI32; import com.sun.jna.platform.win32.User32; import com.sun.jna.platform.win32.WinGDI; import com.sun.jna.platform.win32.WinUser; 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.WinDef.HWND; import com.sun.jna.platform.win32.WinGDI.BITMAPINFO; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION; import com.sun.jna.platform.win32.WinUser.POINT; import com.sun.jna.platform.win32.WinUser.SIZE; import com.sun.jna.ptr.ByteByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.PointerByReference; /** * Provides additional features on a Java {@link Window}. *

* NOTE: since there is no explicit way to force PopupFactory to use a * heavyweight popup, and anything but a heavyweight popup will be * clipped by a window mask, an additional subwindow is added to all * masked windows to implicitly force PopupFactory to use a heavyweight * window and avoid clipping. *

* NOTE: Neither shaped windows nor transparency * currently works with Java 1.4 under X11. This is at least partly due * to 1.4 using multiple X11 windows for a single given Java window. It * *might* be possible to remedy by applying the window * region/transparency to all descendants, but I haven't tried it. In * addition, windows must be both displayable and visible * before the corresponding native Drawable may be obtained; in later * Java versions, the window need only be displayable. *

* NOTE: If you use {@link #setWindowMask(Window,Shape)} and override {@link * Window#paint(Graphics)} on OS X, you'll need to explicitly set the clip * mask on the Graphics object with the window mask; only the * content pane of the window and below have the window mask automatically * applied.

* NOTE: On OSX, the property * apple.awt.draggableWindowBackground is set automatically when * a window's background color has an alpha component. That property must be * set to its final value before the heavyweight peer for the Window * is created. Once {@link Component#addNotify} has been called on the * component, causing creation of the heavyweight peer, changing this * property has no effect. * @see Apple Technote 2007 */ // TODO: setWindowMask() should accept a threshold; some cases want a // 50% threshold, some might want zero/non-zero public class WindowUtils { private static final String TRANSPARENT_OLD_BG = "transparent-old-bg"; private static final String TRANSPARENT_OLD_OPAQUE = "transparent-old-opaque"; private static final String TRANSPARENT_ALPHA = "transparent-alpha"; /** Use this to clear a window mask. */ public static final Shape MASK_NONE = null; /** * This class forces a heavyweight popup on the parent * {@link Window}. See the implementation of {@link PopupFactory}; * a heavyweight is forced if there is an occluding subwindow on the * target window. *

* Ideally we'd have more control over {@link PopupFactory} but this * is a fairly simple, lightweight workaround. Note that, at least as of * JDK 1.6, the following do not have the desired effect:
*

     * ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
     * JPopupMenu.setDefaultLightWeightPopupEnabled(false);
     * System.setProperty("JPopupMenu.defaultLWPopupEnabledKey", "false");
     * 
*/ private static class HeavyweightForcer extends Window { private static final long serialVersionUID = 1L; private final boolean packed; public HeavyweightForcer(Window parent) { super(parent); pack(); packed = true; } public boolean isVisible() { // Only want to be 'visible' once the peer is instantiated // via pack; this tricks PopupFactory into using a heavyweight // popup to avoid being obscured by this window return packed; } public Rectangle getBounds() { return getOwner().getBounds(); } } /** * This can be installed over a {@link JLayeredPane} in order to * listen for repaint requests. The content's repaint method will be * invoked whenever any part of the ancestor window is repainted. */ protected static class RepaintTrigger extends JComponent { private static final long serialVersionUID = 1L; protected class Listener extends WindowAdapter implements ComponentListener, HierarchyListener, AWTEventListener { public void windowOpened(WindowEvent e) { repaint(); } public void componentHidden(ComponentEvent e) {} public void componentMoved(ComponentEvent e) {} public void componentResized(ComponentEvent e) { setSize(getParent().getSize()); repaint(); } public void componentShown(ComponentEvent e) { repaint(); } public void hierarchyChanged(HierarchyEvent e) { repaint(); } public void eventDispatched(AWTEvent e) { if (e instanceof MouseEvent) { Component src = ((MouseEvent)e).getComponent(); if (src != null && SwingUtilities.isDescendingFrom(src, content)) { MouseEvent me = SwingUtilities.convertMouseEvent(src, (MouseEvent)e, content); Component c = SwingUtilities.getDeepestComponentAt(content, me.getX(), me.getY()); if (c != null) { setCursor(c.getCursor()); } } } } } private final Listener listener = createListener(); private final JComponent content; public RepaintTrigger(JComponent content) { this.content = content; } public void addNotify() { super.addNotify(); Window w = SwingUtilities.getWindowAncestor(this); setSize(getParent().getSize()); w.addComponentListener(listener); w.addWindowListener(listener); Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.MOUSE_EVENT_MASK|AWTEvent.MOUSE_MOTION_EVENT_MASK); } public void removeNotify() { Toolkit.getDefaultToolkit().removeAWTEventListener(listener); Window w = SwingUtilities.getWindowAncestor(this); w.removeComponentListener(listener); w.removeWindowListener(listener); super.removeNotify(); } private Rectangle dirty; protected void paintComponent(Graphics g) { Rectangle bounds = g.getClipBounds(); if (dirty == null || !dirty.contains(bounds)) { if (dirty == null) { dirty = bounds; } else { dirty = dirty.union(bounds); } content.repaint(dirty); } else { dirty = null; } } protected Listener createListener() { return new Listener(); } }; /** Window utilities with differing native implementations. */ public static abstract class NativeWindowUtils { protected abstract class TransparentContentPane extends JPanel implements AWTEventListener { private static final long serialVersionUID = 1L; private boolean transparent; public TransparentContentPane(Container oldContent) { super(new BorderLayout()); add(oldContent, BorderLayout.CENTER); setTransparent(true); if (oldContent instanceof JPanel) { ((JComponent)oldContent).setOpaque(false); } } public void addNotify() { super.addNotify(); Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.CONTAINER_EVENT_MASK); } public void removeNotify() { Toolkit.getDefaultToolkit().removeAWTEventListener(this); super.removeNotify(); } public void setTransparent(boolean transparent) { this.transparent = transparent; setOpaque(!transparent); setDoubleBuffered(!transparent); repaint(); } public void eventDispatched(AWTEvent e) { if (e.getID() == ContainerEvent.COMPONENT_ADDED && SwingUtilities.isDescendingFrom(((ContainerEvent)e).getChild(), this)) { Component child = ((ContainerEvent)e).getChild(); NativeWindowUtils.this.setDoubleBuffered(child, false); } } public void paint(Graphics gr) { if (transparent) { Rectangle r = gr.getClipBounds(); final int w = r.width; final int h = r.height; if (getWidth() > 0 && getHeight() > 0) { final BufferedImage buf = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE); Graphics2D g = buf.createGraphics(); g.setComposite(AlphaComposite.Clear); g.fillRect(0, 0, w, h); g.dispose(); g = buf.createGraphics(); g.translate(-r.x, -r.y); super.paint(g); g.dispose(); paintDirect(buf, r); } } else { super.paint(gr); } } /** Use the contents of the given BufferedImage to paint directly * on this component's ancestor window. */ protected abstract void paintDirect(BufferedImage buf, Rectangle bounds); } protected Window getWindow(Component c) { return c instanceof Window ? (Window)c : SwingUtilities.getWindowAncestor(c); } /** * Execute the given action when the given window becomes * displayable. */ protected void whenDisplayable(Component w, final Runnable action) { if (w.isDisplayable() && (!Holder.requiresVisible || w.isVisible())) { action.run(); } else if (Holder.requiresVisible) { getWindow(w).addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) { e.getWindow().removeWindowListener(this); action.run(); } public void windowClosed(WindowEvent e) { e.getWindow().removeWindowListener(this); } }); } else { // Hierarchy events are fired in direct response to // displayability changes w.addHierarchyListener(new HierarchyListener() { public void hierarchyChanged(HierarchyEvent e) { if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0 && e.getComponent().isDisplayable()) { e.getComponent().removeHierarchyListener(this); action.run(); } } }); } } protected Raster toRaster(Shape mask) { Raster raster = null; if (mask != MASK_NONE) { Rectangle bounds = mask.getBounds(); if (bounds.width > 0 && bounds.height > 0) { BufferedImage clip = new BufferedImage(bounds.x + bounds.width, bounds.y + bounds.height, BufferedImage.TYPE_BYTE_BINARY); Graphics2D g = clip.createGraphics(); g.setColor(Color.black); g.fillRect(0, 0, bounds.x + bounds.width, bounds.y + bounds.height); g.setColor(Color.white); g.fill(mask); raster = clip.getRaster(); } } return raster; } protected Raster toRaster(Component c, Icon mask) { Raster raster = null; if (mask != null) { Rectangle bounds = new Rectangle(0, 0, mask.getIconWidth(), mask.getIconHeight()); BufferedImage clip = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = clip.createGraphics(); g.setComposite(AlphaComposite.Clear); g.fillRect(0, 0, bounds.width, bounds.height); g.setComposite(AlphaComposite.SrcOver); mask.paintIcon(c, g, 0, 0); raster = clip.getAlphaRaster(); } return raster; } protected Shape toShape(Raster raster) { final Area area = new Area(new Rectangle(0, 0, 0, 0)); RasterRangesUtils.outputOccupiedRanges(raster, new RasterRangesUtils.RangesOutput() { public boolean outputRange(int x, int y, int w, int h) { area.add(new Area(new Rectangle(x, y, w, h))); return true; } }); return area; } /** * Set the overall alpha transparency of the window. An alpha of * 1.0 is fully opaque, 0.0 is fully transparent. */ public void setWindowAlpha(Window w, float alpha) { // do nothing } /** Default: no support. */ public boolean isWindowAlphaSupported() { return false; } /** Return the default graphics configuration. */ public GraphicsConfiguration getAlphaCompatibleGraphicsConfiguration() { GraphicsEnvironment env = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice dev = env.getDefaultScreenDevice(); return dev.getDefaultConfiguration(); } /** * Set the window to be transparent. Only explicitly painted * pixels will be non-transparent. All pixels will be composited * with whatever is under the window using their alpha values. */ public void setWindowTransparent(Window w, boolean transparent) { // do nothing } protected void setDoubleBuffered(Component root, boolean buffered) { if (root instanceof JComponent) { ((JComponent)root).setDoubleBuffered(buffered); } if (root instanceof JRootPane && buffered) { ((JRootPane)root).setDoubleBuffered(true); } else if (root instanceof Container) { Component[] kids = ((Container)root).getComponents(); for (int i=0;i < kids.length;i++) { setDoubleBuffered(kids[i], buffered); } } } protected void setLayersTransparent(Window w, boolean transparent) { Color bg = transparent ? new Color(0, 0, 0, 0) : null; if (w instanceof RootPaneContainer) { RootPaneContainer rpc = (RootPaneContainer)w; JRootPane root = rpc.getRootPane(); JLayeredPane lp = root.getLayeredPane(); Container c = root.getContentPane(); JComponent content = (c instanceof JComponent) ? (JComponent)c : null; if (transparent) { lp.putClientProperty(TRANSPARENT_OLD_OPAQUE, Boolean.valueOf(lp.isOpaque())); lp.setOpaque(false); root.putClientProperty(TRANSPARENT_OLD_OPAQUE, Boolean.valueOf(root.isOpaque())); root.setOpaque(false); if (content != null) { content.putClientProperty(TRANSPARENT_OLD_OPAQUE, Boolean.valueOf(content.isOpaque())); content.setOpaque(false); } root.putClientProperty(TRANSPARENT_OLD_BG, root.getParent().getBackground()); } else { lp.setOpaque(Boolean.TRUE.equals(lp.getClientProperty(TRANSPARENT_OLD_OPAQUE))); lp.putClientProperty(TRANSPARENT_OLD_OPAQUE, null); root.setOpaque(Boolean.TRUE.equals(root.getClientProperty(TRANSPARENT_OLD_OPAQUE))); root.putClientProperty(TRANSPARENT_OLD_OPAQUE, null); if (content != null) { content.setOpaque(Boolean.TRUE.equals(content.getClientProperty(TRANSPARENT_OLD_OPAQUE))); content.putClientProperty(TRANSPARENT_OLD_OPAQUE, null); } bg = (Color)root.getClientProperty(TRANSPARENT_OLD_BG); root.putClientProperty(TRANSPARENT_OLD_BG, null); } } w.setBackground(bg); } /** Override this method to provide bitmap masking of the given * heavyweight component. */ protected void setMask(Component c, Raster raster) { throw new UnsupportedOperationException("Window masking is not available"); } /** * Set the window mask based on the given Raster, which should * be treated as a bitmap (zero/nonzero values only). A value of * null means to remove the mask. */ protected void setWindowMask(Component w, Raster raster) { if (w.isLightweight()) throw new IllegalArgumentException("Component must be heavyweight: " + w); setMask(w, raster); } /** Set the window mask based on a {@link Shape}. */ public void setWindowMask(Component w, Shape mask) { setWindowMask(w, toRaster(mask)); } /** * Set the window mask based on an Icon. All non-transparent * pixels will be included in the mask. */ public void setWindowMask(Component w, Icon mask) { setWindowMask(w, toRaster(w, mask)); } /** * Use this method to ensure heavyweight popups are used in * conjunction with a given window. This prevents the window's * alpha setting or mask region from being applied to the popup. */ protected void setForceHeavyweightPopups(Window w, boolean force) { if (!(w instanceof HeavyweightForcer)) { Window[] owned = w.getOwnedWindows(); for (int i = 0; i < owned.length; i++) { if (owned[i] instanceof HeavyweightForcer) { if (force) return; owned[i].dispose(); } } Boolean b = Boolean.valueOf(System.getProperty("jna.force_hw_popups", "true")); if (force && b.booleanValue()) { new HeavyweightForcer(w); } } } } /** Canonical lazy loading of a singleton. */ private static class Holder { /** * Indicates whether a window must be visible before its native * handle can be obtained. This wart is caused by the Java * 1.4/X11 implementation. */ public static boolean requiresVisible; public static final NativeWindowUtils INSTANCE; static { if (Platform.isWindows()) { INSTANCE = new W32WindowUtils(); } else if (Platform.isMac()) { INSTANCE = new MacWindowUtils(); } else if (Platform.isX11()) { INSTANCE = new X11WindowUtils(); requiresVisible = System.getProperty("java.version") .matches("^1\\.4\\..*"); } else { String os = System.getProperty("os.name"); throw new UnsupportedOperationException("No support for " + os); } } } private static NativeWindowUtils getInstance() { return Holder.INSTANCE; } private static class W32WindowUtils extends NativeWindowUtils { private HWND getHWnd(Component w) { HWND hwnd = new HWND(); hwnd.setPointer(Native.getComponentPointer(w)); return hwnd; } /** * W32 alpha will only work if sun.java2d.noddraw * is set */ public boolean isWindowAlphaSupported() { return Boolean.getBoolean("sun.java2d.noddraw"); } /** Indicates whether UpdateLayeredWindow is in use. */ private boolean usingUpdateLayeredWindow(Window w) { if (w instanceof RootPaneContainer) { JRootPane root = ((RootPaneContainer)w).getRootPane(); return root.getClientProperty(TRANSPARENT_OLD_BG) != null; } return false; } /** Keep track of the alpha level, since we can't read it from * the window itself. */ private void storeAlpha(Window w, byte alpha) { if (w instanceof RootPaneContainer) { JRootPane root = ((RootPaneContainer)w).getRootPane(); Byte b = alpha == (byte)0xFF ? null : new Byte(alpha); root.putClientProperty(TRANSPARENT_ALPHA, b); } } /** Return the last alpha level we set on the window. */ private byte getAlpha(Window w) { if (w instanceof RootPaneContainer) { JRootPane root = ((RootPaneContainer)w).getRootPane(); Byte b = (Byte)root.getClientProperty(TRANSPARENT_ALPHA); if (b != null) { return b.byteValue(); } } return (byte)0xFF; } public void setWindowAlpha(final Window w, final float alpha) { if (!isWindowAlphaSupported()) { throw new UnsupportedOperationException("Set sun.java2d.noddraw=true to enable transparent windows"); } whenDisplayable(w, new Runnable() { public void run() { HWND hWnd = getHWnd(w); User32 user = User32.INSTANCE; int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE); byte level = (byte)((int)(255 * alpha) & 0xFF); if (usingUpdateLayeredWindow(w)) { // If already using UpdateLayeredWindow, continue to // do so BLENDFUNCTION blend = new BLENDFUNCTION(); blend.SourceConstantAlpha = level; blend.AlphaFormat = WinUser.AC_SRC_ALPHA; user.UpdateLayeredWindow(hWnd, null, null, null, null, null, 0, blend, WinUser.ULW_ALPHA); } else if (alpha == 1f) { flags &= ~WinUser.WS_EX_LAYERED; user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags); } else { flags |= WinUser.WS_EX_LAYERED; user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags); user.SetLayeredWindowAttributes(hWnd, 0, level, WinUser.LWA_ALPHA); } setForceHeavyweightPopups(w, alpha != 1f); storeAlpha(w, level); } }); } /** W32 makes the client responsible for repainting the entire * window on any change. It also does not paint window decorations * when the window is transparent. */ private class W32TransparentContentPane extends TransparentContentPane { private static final long serialVersionUID = 1L; private HDC memDC; private HBITMAP hBitmap; private Pointer pbits; private Dimension bitmapSize; public W32TransparentContentPane(Container content) { super(content); } private void disposeBackingStore() { GDI32 gdi = GDI32.INSTANCE; if (hBitmap != null) { gdi.DeleteObject(hBitmap); hBitmap = null; } if (memDC != null) { gdi.DeleteDC(memDC); memDC = null; } } public void removeNotify() { super.removeNotify(); disposeBackingStore(); } public void setTransparent(boolean transparent) { super.setTransparent(transparent); if (!transparent) { disposeBackingStore(); } } protected void paintDirect(BufferedImage buf, Rectangle bounds) { // TODO: paint frame decoration if window is decorated Window win = SwingUtilities.getWindowAncestor(this); GDI32 gdi = GDI32.INSTANCE; User32 user = User32.INSTANCE; int x = bounds.x; int y = bounds.y; Point origin = SwingUtilities.convertPoint(this, x, y, win); int w = bounds.width; int h = bounds.height; int ww = win.getWidth(); int wh = win.getHeight(); HDC screenDC = user.GetDC(null); HANDLE oldBitmap = null; try { if (memDC == null) { memDC = gdi.CreateCompatibleDC(screenDC); } if (hBitmap == null || !win.getSize().equals(bitmapSize)) { if (hBitmap != null) { gdi.DeleteObject(hBitmap); hBitmap = null; } BITMAPINFO bmi = new BITMAPINFO(); bmi.bmiHeader.biWidth = ww; bmi.bmiHeader.biHeight = wh; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = WinGDI.BI_RGB; bmi.bmiHeader.biSizeImage = ww * wh * 4; PointerByReference ppbits = new PointerByReference(); hBitmap = gdi.CreateDIBSection(memDC, bmi, WinGDI.DIB_RGB_COLORS, ppbits, null, 0); pbits = ppbits.getValue(); bitmapSize = new Dimension(ww, wh); } oldBitmap = gdi.SelectObject(memDC, hBitmap); Raster raster = buf.getData(); int[] pixel = new int[4]; int[] bits = new int[w]; for (int row = 0; row < h; row++) { for (int col = 0; col < w; col++) { raster.getPixel(col, row, pixel); int alpha = (pixel[3] & 0xFF) << 24; int red = (pixel[2] & 0xFF); int green = (pixel[1] & 0xFF) << 8; int blue = (pixel[0] & 0xFF) << 16; bits[col] = alpha | red | green | blue; } int v = wh - (origin.y + row) - 1; pbits.write((v*ww+origin.x)*4, bits, 0, bits.length); } SIZE winSize = new SIZE(); winSize.cx = win.getWidth(); winSize.cy = win.getHeight(); POINT winLoc = new POINT(); winLoc.x = win.getX(); winLoc.y = win.getY(); POINT srcLoc = new POINT(); BLENDFUNCTION blend = new BLENDFUNCTION(); HWND hWnd = getHWnd(win); // extract current constant alpha setting, if possible ByteByReference bref = new ByteByReference(); IntByReference iref = new IntByReference(); byte level = getAlpha(win); try { // GetLayeredwindowAttributes supported WinXP and later if (user.GetLayeredWindowAttributes(hWnd, null, bref, iref) && (iref.getValue() & WinUser.LWA_ALPHA) != 0) { level = bref.getValue(); } } catch(UnsatisfiedLinkError e) { } blend.SourceConstantAlpha = level; blend.AlphaFormat = WinUser.AC_SRC_ALPHA; user.UpdateLayeredWindow(hWnd, screenDC, winLoc, winSize, memDC, srcLoc, 0, blend, WinUser.ULW_ALPHA); } finally { user.ReleaseDC(null, screenDC); if (memDC != null && oldBitmap != null) { gdi.SelectObject(memDC, oldBitmap); } } } } /** Note that w32 does not paint window decorations when * the window is transparent. */ public void setWindowTransparent(final Window w, final boolean transparent) { if (!(w instanceof RootPaneContainer)) { throw new IllegalArgumentException("Window must be a RootPaneContainer"); } if (!isWindowAlphaSupported()) { throw new UnsupportedOperationException("Set sun.java2d.noddraw=true to enable transparent windows"); } boolean isTransparent = w.getBackground() != null && w.getBackground().getAlpha() == 0; if (transparent == isTransparent) return; whenDisplayable(w, new Runnable() { public void run() { User32 user = User32.INSTANCE; HWND hWnd = getHWnd(w); int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE); JRootPane root = ((RootPaneContainer)w).getRootPane(); JLayeredPane lp = root.getLayeredPane(); Container content = root.getContentPane(); if (content instanceof W32TransparentContentPane) { ((W32TransparentContentPane)content).setTransparent(transparent); } else if (transparent) { W32TransparentContentPane w32content = new W32TransparentContentPane(content); root.setContentPane(w32content); lp.add(new RepaintTrigger(w32content), JLayeredPane.DRAG_LAYER); } if (transparent && !usingUpdateLayeredWindow(w)) { flags |= WinUser.WS_EX_LAYERED; user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags); } else if (!transparent && usingUpdateLayeredWindow(w)) { flags &= ~WinUser.WS_EX_LAYERED; user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags); } setLayersTransparent(w, transparent); setForceHeavyweightPopups(w, transparent); setDoubleBuffered(w, !transparent); } }); } public void setWindowMask(final Component w, final Shape mask) { if (mask instanceof Area && ((Area)mask).isPolygonal()) { setMask(w, (Area)mask); } else { super.setWindowMask(w, mask); } } // NOTE: Deletes hrgn after setting the window region private void setWindowRegion(final Component w, final HRGN hrgn) { whenDisplayable(w, new Runnable() { public void run() { GDI32 gdi = GDI32.INSTANCE; User32 user = User32.INSTANCE; HWND hWnd = getHWnd(w); try { user.SetWindowRgn(hWnd, hrgn, true); setForceHeavyweightPopups(getWindow(w), hrgn != null); } finally { gdi.DeleteObject(hrgn); } } }); } // Take advantage of CreatePolyPolygonalRgn on w32 private void setMask(final Component w, final Area area) { GDI32 gdi = GDI32.INSTANCE; PathIterator pi = area.getPathIterator(null); int mode = pi.getWindingRule() == PathIterator.WIND_NON_ZERO ? WinGDI.WINDING: WinGDI.ALTERNATE; float[] coords = new float[6]; List points = new ArrayList(); int size = 0; List sizes = new ArrayList(); while (!pi.isDone()) { int type = pi.currentSegment(coords); if (type == PathIterator.SEG_MOVETO) { size = 1; points.add(new POINT((int)coords[0], (int)coords[1])); } else if (type == PathIterator.SEG_LINETO) { ++size; points.add(new POINT((int)coords[0], (int)coords[1])); } else if (type == PathIterator.SEG_CLOSE) { sizes.add(new Integer(size)); } else { throw new RuntimeException("Area is not polygonal: " + area); } pi.next(); } POINT[] lppt = (POINT[])new POINT().toArray(points.size()); POINT[] pts = (POINT[])points.toArray(new POINT[points.size()]); for (int i=0;i < lppt.length;i++) { lppt[i].x = pts[i].x; lppt[i].y = pts[i].y; } int[] counts = new int[sizes.size()]; for (int i=0;i < counts.length;i++) { counts[i] = ((Integer)sizes.get(i)).intValue(); } HRGN hrgn = gdi.CreatePolyPolygonRgn(lppt, counts, counts.length, mode); setWindowRegion(w, hrgn); } protected void setMask(final Component w, final Raster raster) { GDI32 gdi = GDI32.INSTANCE; final HRGN region = raster != null ? gdi.CreateRectRgn(0, 0, 0, 0) : null; if (region != null) { final HRGN tempRgn = gdi.CreateRectRgn(0, 0, 0, 0); try { RasterRangesUtils.outputOccupiedRanges(raster, new RasterRangesUtils.RangesOutput() { public boolean outputRange(int x, int y, int w, int h) { GDI32 gdi = GDI32.INSTANCE; gdi.SetRectRgn(tempRgn, x, y, x + w, y + h); return gdi.CombineRgn(region, region, tempRgn, WinGDI.RGN_OR) != WinGDI.ERROR; } }); } finally { gdi.DeleteObject(tempRgn); } } setWindowRegion(w, region); } } private static class MacWindowUtils extends NativeWindowUtils { public boolean isWindowAlphaSupported() { return true; } private OSXMaskingContentPane installMaskingPane(Window w) { OSXMaskingContentPane content; if (w instanceof RootPaneContainer) { // TODO: replace layered pane instead? final RootPaneContainer rpc = (RootPaneContainer)w; Container oldContent = rpc.getContentPane(); if (oldContent instanceof OSXMaskingContentPane) { content = (OSXMaskingContentPane)oldContent; } else { content = new OSXMaskingContentPane(oldContent); // TODO: listen for content pane changes rpc.setContentPane(content); } } else { Component oldContent = w.getComponentCount() > 0 ? w.getComponent(0) : null; if (oldContent instanceof OSXMaskingContentPane) { content = (OSXMaskingContentPane)oldContent; } else { content = new OSXMaskingContentPane(oldContent); w.add(content); } } return content; } /** Note that the property * apple.awt.draggableWindowBackground must be set to its * final value before the heavyweight peer for the Window is * created. Once {@link Component#addNotify} has been called on the * component, causing creation of the heavyweight peer, changing this * property has no effect. * @see Apple Technote 2007 */ public void setWindowTransparent(Window w, boolean transparent) { boolean isTransparent = w.getBackground() != null && w.getBackground().getAlpha() == 0; if (transparent != isTransparent) { setBackgroundTransparent(w, transparent, "setWindowTransparent"); } } /** Setting this false restores the original setting. */ private static final String WDRAG = "apple.awt.draggableWindowBackground"; private void fixWindowDragging(Window w, String context) { if (w instanceof RootPaneContainer) { JRootPane p = ((RootPaneContainer)w).getRootPane(); Boolean oldDraggable = (Boolean)p.getClientProperty(WDRAG); if (oldDraggable == null) { p.putClientProperty(WDRAG, Boolean.FALSE); if (w.isDisplayable()) { System.err.println(context + "(): To avoid content dragging, " + context + "() must be called before the window is realized, or " + WDRAG + " must be set to Boolean.FALSE before the window is realized. If you really want content dragging, set " + WDRAG + " on the window's root pane to Boolean.TRUE before calling " + context + "() to hide this message."); } } } } /** Note that the property * apple.awt.draggableWindowBackground must be set to its * final value before the heavyweight peer for the Window is * created. Once {@link Component#addNotify} has been called on the * component, causing creation of the heavyweight peer, changing this * property has no effect. * @see Apple Technote 2007 */ public void setWindowAlpha(final Window w, final float alpha) { if (w instanceof RootPaneContainer) { JRootPane p = ((RootPaneContainer)w).getRootPane(); p.putClientProperty("Window.alpha", new Float(alpha)); fixWindowDragging(w, "setWindowAlpha"); } whenDisplayable(w, new Runnable() { public void run() { Object peer = w.getPeer(); try { peer.getClass().getMethod("setAlpha", new Class[]{ float.class }).invoke(peer, new Object[]{ new Float(alpha) }); } catch (Exception e) { } } }); } protected void setWindowMask(Component w, Raster raster) { if (raster != null) { setWindowMask(w, toShape(raster)); } else { setWindowMask(w, new Rectangle(0, 0, w.getWidth(), w.getHeight())); } } public void setWindowMask(Component c, final Shape shape) { if (c instanceof Window) { Window w = (Window)c; OSXMaskingContentPane content = installMaskingPane(w); content.setMask(shape); setBackgroundTransparent(w, shape != MASK_NONE, "setWindowMask"); } else { // not yet implemented } } /** Mask out unwanted pixels and ensure background gets cleared. * @author Olivier Chafik */ private static class OSXMaskingContentPane extends JPanel { private static final long serialVersionUID = 1L; private Shape shape; public OSXMaskingContentPane(Component oldContent) { super(new BorderLayout()); if (oldContent != null) { add(oldContent, BorderLayout.CENTER); } } public void setMask(Shape shape) { this.shape = shape; repaint(); } public void paint(Graphics graphics) { Graphics2D g = (Graphics2D)graphics.create(); g.setComposite(AlphaComposite.Clear); g.fillRect(0, 0, getWidth(), getHeight()); g.dispose(); if (shape != null) { g = (Graphics2D)graphics.create(); g.setClip(shape); super.paint(g); g.dispose(); } else { super.paint(graphics); } } } private void setBackgroundTransparent(Window w, boolean transparent, String context) { JRootPane rp = w instanceof RootPaneContainer ? ((RootPaneContainer)w).getRootPane() : null; if (transparent) { if (rp != null) { rp.putClientProperty(TRANSPARENT_OLD_BG, w.getBackground()); } w.setBackground(new Color(0,0,0,0)); } else { if (rp != null) { Color bg = (Color)rp.getClientProperty(TRANSPARENT_OLD_BG); // If the old bg is a // apple.laf.CColorPaintUIResource, the window's // transparent state will not change if (bg != null) { bg = new Color(bg.getRed(), bg.getGreen(), bg.getBlue(), bg.getAlpha()); } w.setBackground(bg); rp.putClientProperty(TRANSPARENT_OLD_BG, null); } else { w.setBackground(null); } } fixWindowDragging(w, context); } } private static class X11WindowUtils extends NativeWindowUtils { private static Pixmap createBitmap(final Display dpy, X11.Window win, Raster raster) { final X11 x11 = X11.INSTANCE; Rectangle bounds = raster.getBounds(); int width = bounds.x + bounds.width; int height = bounds.y + bounds.height; final Pixmap pm = x11.XCreatePixmap(dpy, win, width, height, 1); final GC gc = x11.XCreateGC(dpy, pm, new NativeLong(0), null); if (gc == null) { return null; } x11.XSetForeground(dpy, gc, new NativeLong(0)); x11.XFillRectangle(dpy, pm, gc, 0, 0, width, height); final List rlist = new ArrayList(); try { RasterRangesUtils.outputOccupiedRanges(raster, new RasterRangesUtils.RangesOutput() { public boolean outputRange(int x, int y, int w, int h) { rlist.add(new Rectangle(x, y, w, h)); return true; } }); X11.XRectangle[] rects = (X11.XRectangle[]) new X11.XRectangle().toArray(rlist.size()); for (int i=0;i < rects.length;i++) { Rectangle r = (Rectangle)rlist.get(i); rects[i].x = (short)r.x; rects[i].y = (short)r.y; rects[i].width = (short)r.width; rects[i].height = (short)r.height; // Optimization: write directly to native memory Pointer p = rects[i].getPointer(); p.setShort(0, (short)r.x); p.setShort(2, (short)r.y); p.setShort(4, (short)r.width); p.setShort(6, (short)r.height); rects[i].setAutoSynch(false); // End optimization } final int UNMASKED = 1; x11.XSetForeground(dpy, gc, new NativeLong(UNMASKED)); x11.XFillRectangles(dpy, pm, gc, rects, rects.length); } finally { x11.XFreeGC(dpy, gc); } return pm; } private boolean didCheck; private long[] alphaVisualIDs = {}; public boolean isWindowAlphaSupported() { return getAlphaVisualIDs().length > 0; } private static long getVisualID(GraphicsConfiguration config) { // Use reflection to call // X11GraphicsConfig.getVisual try { Object o = config.getClass() .getMethod("getVisual", (Class[])null) .invoke(config, (Object[])null); return ((Number)o).longValue(); } catch (Exception e) { e.printStackTrace(); return -1; } } /** Return the default graphics configuration. */ public GraphicsConfiguration getAlphaCompatibleGraphicsConfiguration() { if (isWindowAlphaSupported()) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = env.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsConfiguration[] configs = devices[i].getConfigurations(); for (int j = 0; j < configs.length; j++) { long visualID = getVisualID(configs[j]); long[] ids = getAlphaVisualIDs(); for (int k = 0; k < ids.length; k++) { if (visualID == ids[k]) { return configs[j]; } } } } } return super.getAlphaCompatibleGraphicsConfiguration(); } /** * Return the visual ID of the visual which supports an alpha * channel. */ private synchronized long[] getAlphaVisualIDs() { if (didCheck) { return alphaVisualIDs; } didCheck = true; X11 x11 = X11.INSTANCE; Display dpy = x11.XOpenDisplay(null); if (dpy == null) return alphaVisualIDs; XVisualInfo info = null; try { int screen = x11.XDefaultScreen(dpy); XVisualInfo template = new XVisualInfo(); template.screen = screen; template.depth = 32; template.c_class = X11.TrueColor; NativeLong mask = new NativeLong(X11.VisualScreenMask | X11.VisualDepthMask | X11.VisualClassMask); IntByReference pcount = new IntByReference(); info = x11.XGetVisualInfo(dpy, mask, template, pcount); if (info != null) { List list = new ArrayList(); XVisualInfo[] infos = (XVisualInfo[])info.toArray(pcount.getValue()); for (int i = 0; i < infos.length; i++) { XRenderPictFormat format = X11.Xrender.INSTANCE.XRenderFindVisualFormat(dpy, infos[i].visual); if (format.type == X11.Xrender.PictTypeDirect && format.direct.alphaMask != 0) { list.add(infos[i].visualid); } } alphaVisualIDs = new long[list.size()]; for (int i=0;i < alphaVisualIDs.length;i++) { alphaVisualIDs[i] = ((Number)list.get(i)).longValue(); } return alphaVisualIDs; } } finally { if (info != null) { x11.XFree(info.getPointer()); } x11.XCloseDisplay(dpy); } return alphaVisualIDs; } private static X11.Window getContentWindow(Window w, X11.Display dpy, X11.Window win, Point offset) { if ((w instanceof Frame && !((Frame)w).isUndecorated()) || (w instanceof Dialog && !((Dialog)w).isUndecorated())) { X11 x11 = X11.INSTANCE; X11.WindowByReference rootp = new X11.WindowByReference(); X11.WindowByReference parentp = new X11.WindowByReference(); PointerByReference childrenp = new PointerByReference(); IntByReference countp = new IntByReference(); x11.XQueryTree(dpy, win, rootp, parentp, childrenp, countp); Pointer p = childrenp.getValue(); int[] ids = p.getIntArray(0, countp.getValue()); for (int id : ids) { // TODO: more verification of correct window? X11.Window child = new X11.Window(id); X11.XWindowAttributes xwa = new X11.XWindowAttributes(); x11.XGetWindowAttributes(dpy, child, xwa); offset.x = -xwa.x; offset.y = -xwa.y; win = child; break; } if (p != null) { x11.XFree(p); } } return win; } private static X11.Window getDrawable(Component w) { int id = (int)Native.getComponentID(w); if (id == X11.None) return null; return new X11.Window(id); } private static final long OPAQUE = 0xFFFFFFFFL; private static final String OPACITY = "_NET_WM_WINDOW_OPACITY"; public void setWindowAlpha(final Window w, final float alpha) { if (!isWindowAlphaSupported()) { throw new UnsupportedOperationException("This X11 display does not provide a 32-bit visual"); } Runnable action = new Runnable() { public void run() { X11 x11 = X11.INSTANCE; Display dpy = x11.XOpenDisplay(null); if (dpy == null) return; try { X11.Window win = getDrawable(w); if (alpha == 1f) { x11.XDeleteProperty(dpy, win, x11.XInternAtom(dpy, OPACITY, false)); } else { int opacity = (int)((long)(alpha * OPAQUE) & 0xFFFFFFFF); IntByReference patom = new IntByReference(opacity); x11.XChangeProperty(dpy, win, x11.XInternAtom(dpy, OPACITY, false), X11.XA_CARDINAL, 32, X11.PropModeReplace, patom.getPointer(), 1); } } finally { x11.XCloseDisplay(dpy); } } }; whenDisplayable(w, action); } private class X11TransparentContentPane extends TransparentContentPane { private static final long serialVersionUID = 1L; public X11TransparentContentPane(Container oldContent) { super(oldContent); } private Memory buffer; private int[] pixels; private final int[] pixel = new int[4]; // Painting directly to the original Graphics // fails to properly composite unless the destination // is pure black. Too bad. protected void paintDirect(BufferedImage buf, Rectangle bounds) { Window window = SwingUtilities.getWindowAncestor(this); X11 x11 = X11.INSTANCE; X11.Display dpy = x11.XOpenDisplay(null); X11.Window win = getDrawable(window); Point offset = new Point(); win = getContentWindow(window, dpy, win, offset); X11.GC gc = x11.XCreateGC(dpy, win, new NativeLong(0), null); Raster raster = buf.getData(); int w = bounds.width; int h = bounds.height; if (buffer == null || buffer.getSize() != w*h*4) { buffer = new Memory(w*h*4); pixels = new int[w*h]; } for (int y=0;y * NOTE: Windows requires that sun.java2d.noddraw=true * in order for alpha to work.

* NOTE: On OSX, the property * apple.awt.draggableWindowBackground must be set to its * final value before the heavyweight peer for the Window is * created. Once {@link Component#addNotify} has been called on the * component, causing creation of the heavyweight peer, changing this * property has no effect. * @see Apple Technote 2007 */ public static void setWindowAlpha(Window w, float alpha) { getInstance().setWindowAlpha(w, Math.max(0f, Math.min(alpha, 1f))); } /** * Set the window to be transparent. Only explicitly painted pixels * will be non-transparent. All pixels will be composited with * whatever is under the window using their alpha values. * * On OSX, the property apple.awt.draggableWindowBackground * must be set to its final value before the heavyweight peer for * the Window is created. Once {@link Component#addNotify} has been * called on the component, causing creation of the heavyweight peer, * changing this property has no effect. * @see Apple Technote 2007 */ public static void setWindowTransparent(Window w, boolean transparent) { getInstance().setWindowTransparent(w, transparent); } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/FileMonitor.java0000644000175000017500000001046411421126012025122 0ustar janjan/* 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. *

* 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; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.EventObject; import java.util.HashMap; import java.util.List; import java.util.Map; import com.sun.jna.platform.win32.W32FileMonitor; /** Provides notification of file system changes. Actual capabilities may * vary slightly by platform. *

* Watched files which are removed from the filesystem are no longer watched. * @author twall */ @SuppressWarnings("serial") public abstract class FileMonitor { public static final int FILE_CREATED = 0x1; public static final int FILE_DELETED = 0x2; public static final int FILE_MODIFIED = 0x4; public static final int FILE_ACCESSED = 0x8; public static final int FILE_NAME_CHANGED_OLD = 0x10; public static final int FILE_NAME_CHANGED_NEW = 0x20; public static final int FILE_RENAMED = FILE_NAME_CHANGED_OLD|FILE_NAME_CHANGED_NEW; public static final int FILE_SIZE_CHANGED = 0x40; public static final int FILE_ATTRIBUTES_CHANGED = 0x80; public static final int FILE_SECURITY_CHANGED = 0x100; public static final int FILE_ANY = 0x1FF; public interface FileListener { public void fileChanged(FileEvent e); } public class FileEvent extends EventObject { private final File file; private final int type; public FileEvent(File file, int type) { super(FileMonitor.this); this.file = file; this.type = type; } public File getFile() { return file; } public int getType() { return type; } public String toString() { return "FileEvent: " + file + ":" + type; } } private final Map watched = new HashMap(); private List listeners = new ArrayList(); protected abstract void watch(File file, int mask, boolean recursive) throws IOException ; protected abstract void unwatch(File file); public abstract void dispose(); public void addWatch(File dir) throws IOException { addWatch(dir, FILE_ANY); } public void addWatch(File dir, int mask) throws IOException { addWatch(dir, mask, dir.isDirectory()); } public void addWatch(File dir, int mask, boolean recursive) throws IOException { watched.put(dir, new Integer(mask)); watch(dir, mask, recursive); } public void removeWatch(File file) { if (watched.remove(file) != null) { unwatch(file); } } protected void notify(FileEvent e) { for (FileListener listener : listeners) { listener.fileChanged(e); } } public synchronized void addFileListener(FileListener listener) { List list = new ArrayList(listeners); list.add(listener); listeners = list; } public synchronized void removeFileListener(FileListener x) { List list = new ArrayList(listeners); list.remove(x); listeners = list; } protected void finalize() { for (File watchedFile : watched.keySet()) { removeWatch(watchedFile); } dispose(); } /** Canonical lazy loading of a singleton. */ private static class Holder { public static final FileMonitor INSTANCE; static { String os = System.getProperty("os.name"); if (os.startsWith("Windows")) { INSTANCE = new W32FileMonitor(); } else { throw new Error("FileMonitor not implemented for " + os); } } } public static FileMonitor getInstance() { return Holder.INSTANCE; } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/dnd/0000755000175000017500000000000011421126012022570 5ustar janjanlibjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/dnd/DropTargetPainter.java0000644000175000017500000000160611421126012027034 0ustar janjan/* 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. *

* 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.dnd; import java.awt.Point; import java.awt.dnd.DropTargetEvent; /** Provides a callback for {@link DropHandler} to customize drop target * feedback. * @author twall */ public interface DropTargetPainter { void paintDropTarget(DropTargetEvent e, int action, Point location); } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/dnd/DragHandler.java0000644000175000017500000005143511421126012025616 0ustar janjan/* 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. *

* 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.dnd; import java.awt.AlphaComposite; import java.awt.Component; import java.awt.Cursor; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.Image; import java.awt.Point; import java.awt.Transparency; import java.awt.datatransfer.Transferable; import java.awt.dnd.DnDConstants; import java.awt.dnd.DragGestureEvent; import java.awt.dnd.DragGestureListener; import java.awt.dnd.DragSource; import java.awt.dnd.DragSourceContext; import java.awt.dnd.DragSourceDragEvent; import java.awt.dnd.DragSourceDropEvent; import java.awt.dnd.DragSourceEvent; import java.awt.dnd.DragSourceListener; import java.awt.dnd.DragSourceMotionListener; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetEvent; import java.awt.dnd.InvalidDnDOperationException; import java.awt.event.InputEvent; import java.awt.image.BufferedImage; import javax.swing.Icon; import javax.swing.JColorChooser; import javax.swing.JFileChooser; import javax.swing.JList; import javax.swing.JTable; import javax.swing.JTree; import javax.swing.text.JTextComponent; /** Provides simplified drag handling for a component. * Usage:
*


 * int actions = DnDConstants.MOVE_OR_COPY;
 * Component component = ...;
 * DragHandler handler = new DragHandler(component, actions);
 * 
*
    *
  • Supports painting an arbitrary {@link Icon} with transparency to * represent the item being dragged (restricted to the {@link java.awt.Window} * of the drag source if the platform doesn't support drag images). *
  • Disallow starting a drag if the user requests an unsupported action. *
  • Adjusts the cursor on drags with no modifier for which the default action * is disallowed but where one or more non-default actions are allowed, e.g. a * drag (with no modifiers) to a target which supports "link" should change the * cursor to "link" (prior to 1.6, the JRE behavior is to display a * "not allowed" cursor, even though the action actually depends on how the * drop target responds). * * The bug is fixed in java 1.6. *
  • Disallow drops to targets if the non-default (user-requested) action * is not supported by the target, e.g. the user requests a "copy" when the * target only supports "move". This is generally the responsibility of the * drop handler, which decides whether or not to accept a drag. The DragHandler * provides static modifier state information since the drop handler doesn't * have access to it. *
* NOTE: Fundamentally, the active action is determined by the drop handler * in {@link DropTargetDragEvent#acceptDrag}, but often client code * simply relies on {@link DropTargetDragEvent#getDropAction}. */ //TODO: separate into the the following drag pieces: // * default cursor changing behavior fix (fixed in jre1.6) (global DSL) // * drag unselected item (fixed in 1.6, flag in 1.5.0.05+) bug not an issue w/DragHandler // * multi-selection drag workaround (if not using swing drag gesture recognizer) // proper multi-selection drag is provided for swing dnd as of 1.4 // (use swing drag gesture recognizer if possible?) DSL+mouse listener //TODO: identify overlap with default Swing support + TransferHandler // * TransferHandler doesn't have drop location information (included in 1.6) // * SwingDropTarget allows listeners, so target highlighting is possible //NOTE: acceptDrag(int) is simply indicates the drag is accepted; the action // value doesn't get propagated anywhere, it's certainly not communicated to // the drag source //MAYBE: should Transferable/Icon provision be a separate interface //(i.e. TransferHandler)? only if the rest of the drag handler is constant and // only the image needs to change (for standard components, e.g. tree cells, // table cells, etc.) public abstract class DragHandler implements DragSourceListener, DragSourceMotionListener, DragGestureListener { /** Default maximum size for ghosted images. */ public static final Dimension MAX_GHOST_SIZE = new Dimension(250, 250); /** Default transparency for ghosting. */ public static final float DEFAULT_GHOST_ALPHA = 0.5f; /** {@link #getModifiers} returns this value when the current * modifiers state is unknown. */ public static final int UNKNOWN_MODIFIERS = -1; /** {@link #getTransferable} returns this value when * the current {@link Transferable} is unknown. */ public static final Transferable UNKNOWN_TRANSFERABLE = null; /** Convenience to reference {@link DnDConstants#ACTION_MOVE}. */ protected static final int MOVE = DnDConstants.ACTION_MOVE; /** Convenience to reference {@link DnDConstants#ACTION_COPY}. */ protected static final int COPY = DnDConstants.ACTION_COPY; /** Convenience to reference {@link DnDConstants#ACTION_LINK}. */ protected static final int LINK = DnDConstants.ACTION_LINK; /** Convenience to reference {@link DnDConstants#ACTION_NONE}. */ protected static final int NONE = DnDConstants.ACTION_NONE; // TODO: w32 explorer: link=alt or ctrl+shift, copy=ctrl or shift // w32 others: copy=ctrl /** Modifier mask for a user-requested move. */ static final int MOVE_MASK = InputEvent.SHIFT_DOWN_MASK; static final boolean OSX = System.getProperty("os.name").toLowerCase().indexOf("mac") != -1; /** Modifier mask for a user-requested copy. */ static final int COPY_MASK = OSX ? InputEvent.ALT_DOWN_MASK : InputEvent.CTRL_DOWN_MASK; /** Modifier mask for a user-requested link. */ static final int LINK_MASK = OSX ? InputEvent.ALT_DOWN_MASK|InputEvent.META_DOWN_MASK : InputEvent.CTRL_DOWN_MASK|InputEvent.SHIFT_DOWN_MASK; /** Modifier mask for any user-requested action. */ static final int KEY_MASK = InputEvent.ALT_DOWN_MASK|InputEvent.META_DOWN_MASK |InputEvent.CTRL_DOWN_MASK|InputEvent.SHIFT_DOWN_MASK |InputEvent.ALT_GRAPH_DOWN_MASK; private static int modifiers = UNKNOWN_MODIFIERS; private static Transferable transferable = UNKNOWN_TRANSFERABLE; /** Used to communicate modifier state to {@link DropHandler}. Note that * this field will only be accurate when a {@link DragHandler} in * the same VM started the drag. Otherwise, {@link #UNKNOWN_MODIFIERS} * will be returned. */ static int getModifiers() { return modifiers; } /** Used to communicate the current {@link Transferable} during a drag, * if available. Work around absence of access to the data when dragging * pre-1.5. */ public static Transferable getTransferable(DropTargetEvent e) { if (e instanceof DropTargetDragEvent) { try { // getTransferable is available during drag only on 1.5+ return (Transferable) e.getClass().getMethod("getTransferable", (Class[])null).invoke(e, (Object[])null); } catch(Exception ex) { // Method not available } } else if (e instanceof DropTargetDropEvent) { return ((DropTargetDropEvent)e).getTransferable(); } return transferable; } private int supportedActions; private boolean fixCursor = true; private Component dragSource; private GhostedDragImage ghost; private Point imageOffset; private Dimension maxGhostSize = MAX_GHOST_SIZE; private float ghostAlpha = DEFAULT_GHOST_ALPHA; /** Enable drags from the given component, supporting the actions in * the given action mask. */ protected DragHandler(Component dragSource, int actions) { this.dragSource = dragSource; this.supportedActions = actions; try { String alpha = System.getProperty("DragHandler.alpha"); if (alpha != null) { try { ghostAlpha = Float.parseFloat(alpha); } catch(NumberFormatException e) { } } String max = System.getProperty("DragHandler.maxDragImageSize"); if (max != null) { String[] size = max.split("x"); if (size.length == 2) { try { maxGhostSize = new Dimension(Integer.parseInt(size[0]), Integer.parseInt(size[1])); } catch(NumberFormatException e) { } } } } catch(SecurityException e) { } // Avoid having more than one gesture recognizer active disableSwingDragSupport(dragSource); DragSource src = DragSource.getDefaultDragSource(); src.createDefaultDragGestureRecognizer(dragSource, supportedActions, this); } private void disableSwingDragSupport(Component comp) { if (comp instanceof JTree) { ((JTree)comp).setDragEnabled(false); } else if (comp instanceof JList) { ((JList)comp).setDragEnabled(false); } else if (comp instanceof JTable) { ((JTable)comp).setDragEnabled(false); } else if (comp instanceof JTextComponent) { ((JTextComponent)comp).setDragEnabled(false); } else if (comp instanceof JColorChooser) { ((JColorChooser)comp).setDragEnabled(false); } else if (comp instanceof JFileChooser) { ((JFileChooser)comp).setDragEnabled(false); } } /** Override to control whether a drag is started. The default * implementation disallows the drag if the user is applying modifiers * and the user-requested action is not supported. */ protected boolean canDrag(DragGestureEvent e) { int mods = e.getTriggerEvent().getModifiersEx() & KEY_MASK; if (mods == MOVE_MASK) return (supportedActions & MOVE) != 0; if (mods == COPY_MASK) return (supportedActions & COPY) != 0; if (mods == LINK_MASK) return (supportedActions & LINK) != 0; return true; } /** Update the modifiers hint. */ protected void setModifiers(int mods) { modifiers = mods; } /** Override to provide an appropriate {@link Transferable} representing * the data being dragged. */ protected abstract Transferable getTransferable(DragGestureEvent e); /** Override this to provide a custom image. The {@link Icon} * returned by this method by default is null, which results * in no drag image. * @param srcOffset set this to be the offset from the drag source * component's upper left corner to the image's upper left corner. * For example, when dragging a row from a list, the offset would be the * row's bounding rectangle's (x,y) coordinate.

* The default value is (0,0), so if unchanged, the image is will * use the same origin as the drag source component. */ protected Icon getDragIcon(DragGestureEvent e, Point srcOffset) { return null; } /** Override to perform any decoration of the target at the start of a drag, * if desired. */ protected void dragStarted(DragGestureEvent e) { } /** Called when a user drag gesture is recognized. This method is * responsible for initiating the drag operation. */ public void dragGestureRecognized(DragGestureEvent e) { if ((e.getDragAction() & supportedActions) != 0 && canDrag(e)) { setModifiers(e.getTriggerEvent().getModifiersEx() & KEY_MASK); Transferable transferable = getTransferable(e); if (transferable == null) return; try { Point srcOffset = new Point(0, 0); Icon icon = getDragIcon(e, srcOffset); Point origin = e.getDragOrigin(); // offset of the image origin from the cursor imageOffset = new Point(srcOffset.x - origin.x, srcOffset.y - origin.y); Icon dragIcon = scaleDragIcon(icon, imageOffset); Cursor cursor = null; if (dragIcon != null && DragSource.isDragImageSupported()) { GraphicsConfiguration gc = e.getComponent().getGraphicsConfiguration(); e.startDrag(cursor, createDragImage(gc, dragIcon), imageOffset, transferable, this); } else { if (dragIcon != null) { Point screen = dragSource.getLocationOnScreen(); screen.translate(origin.x, origin.y); Point cursorOffset = new Point(-imageOffset.x, -imageOffset.y); ghost = new GhostedDragImage(dragSource, dragIcon, getImageLocation(screen), cursorOffset); ghost.setAlpha(ghostAlpha); } e.startDrag(cursor, transferable, this); } dragStarted(e); moved = false; e.getDragSource().addDragSourceMotionListener(this); DragHandler.transferable = transferable; } catch (InvalidDnDOperationException ex) { if (ghost != null) { ghost.dispose(); ghost = null; } } } } /** Reduce the size of the given drag icon, if appropriate. When using * a smaller drag icon, we also need to adjust the cursor offset within * the icon. */ protected Icon scaleDragIcon(Icon icon, Point imageOffset) { /* if (icon != null && maxGhostSize != null) { if (icon.getIconWidth() > maxGhostSize.width || icon.getIconHeight() > maxGhostSize.height) { Icon scaled = new ScaledIcon(icon, maxGhostSize.width, maxGhostSize.height); double scale = (double)scaled.getIconWidth()/icon.getIconWidth(); imageOffset.x *= scale; imageOffset.y *= scale; return scaled; } }*/ return icon; } /** Create an image from the given icon. The image is provided to the * native handler if drag images are supported natively. */ protected Image createDragImage(GraphicsConfiguration gc, Icon icon) { int w = icon.getIconWidth(); int h = icon.getIconHeight(); BufferedImage image = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT); Graphics2D g = (Graphics2D)image.getGraphics(); g.setComposite(AlphaComposite.Clear); g.fillRect(0, 0, w, h); // Ignore pixels in the buffered image g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, ghostAlpha)); icon.paintIcon(dragSource, g, 0, 0); g.dispose(); return image; } /** Reduce a multiply-set bit mask to a single bit. */ private int reduce(int actions) { if ((actions & MOVE) != 0 && actions != MOVE) { return MOVE; } else if ((actions & COPY) != 0 && actions != COPY) { return COPY; } return actions; } protected Cursor getCursorForAction(int actualAction) { switch(actualAction) { case MOVE: return DragSource.DefaultMoveDrop; case COPY: return DragSource.DefaultCopyDrop; case LINK: return DragSource.DefaultLinkDrop; default: return DragSource.DefaultMoveNoDrop; } } /** Returns the first available action supported by source and target. */ protected int getAcceptableDropAction(int targetActions) { return reduce(supportedActions & targetActions); } /** Get the currently requested drop action. */ protected int getDropAction(DragSourceEvent ev) { if (ev instanceof DragSourceDragEvent) { DragSourceDragEvent e = (DragSourceDragEvent)ev; return e.getDropAction(); } if (ev instanceof DragSourceDropEvent) { return ((DragSourceDropEvent)ev).getDropAction(); } return NONE; } /** Pick a different drop action if the target doesn't support the current * one and there are no modifiers. */ protected int adjustDropAction(DragSourceEvent ev) { int action = getDropAction(ev); if (ev instanceof DragSourceDragEvent) { DragSourceDragEvent e = (DragSourceDragEvent)ev; if (action == NONE) { int mods = e.getGestureModifiersEx() & KEY_MASK; if (mods == 0) { action = getAcceptableDropAction(e.getTargetActions()); } } } return action; } protected void updateCursor(DragSourceEvent ev) { if (!fixCursor) return; Cursor cursor = getCursorForAction(adjustDropAction(ev)); ev.getDragSourceContext().setCursor(cursor); } static String actionString(int action) { switch(action) { case MOVE: return "MOVE"; case MOVE|COPY: return "MOVE|COPY"; case MOVE|LINK: return "MOVE|LINK"; case MOVE|COPY|LINK: return "MOVE|COPY|LINK"; case COPY: return "COPY"; case COPY|LINK: return "COPY|LINK"; case LINK: return "LINK"; default: return "NONE"; } } private String lastAction; private void describe(String type, DragSourceEvent e) { if (false) { DragSourceContext ds = e.getDragSourceContext(); String msg = "drag: " + type; if (e instanceof DragSourceDragEvent) { DragSourceDragEvent ev = (DragSourceDragEvent)e; msg += ": src=" + actionString(ds.getSourceActions()) + " usr=" + actionString(ev.getUserAction()) + " tgt=" + actionString(ev.getTargetActions()) + " act=" + actionString(ev.getDropAction()) + " mods=" + ev.getGestureModifiersEx(); } else { msg += ": e=" + e; } if (!msg.equals(lastAction)) { System.out.println(lastAction = msg); } } } public void dragDropEnd(DragSourceDropEvent e) { describe("end", e); setModifiers(UNKNOWN_MODIFIERS); transferable = UNKNOWN_TRANSFERABLE; if (ghost != null) { if (e.getDropSuccess()) { ghost.dispose(); } else { ghost.returnToOrigin(); } ghost = null; } DragSource src = e.getDragSourceContext().getDragSource(); src.removeDragSourceMotionListener(this); moved = false; } private Point getImageLocation(Point where) { where.translate(imageOffset.x, imageOffset.y); return where; } public void dragEnter(DragSourceDragEvent e) { describe("enter", e); if (ghost != null) { ghost.move(getImageLocation(e.getLocation())); } updateCursor(e); } // bug workaround; need to skip initial dragMouseMoved event, // which has reports "0" for the available target actions (1.4+?) // filed a bug for this private boolean moved; public void dragMouseMoved(DragSourceDragEvent e) { describe("move", e); if (ghost != null) { ghost.move(getImageLocation(e.getLocation())); } if (moved) updateCursor(e); moved = true; } public void dragOver(DragSourceDragEvent e) { describe("over", e); if (ghost != null) { ghost.move(getImageLocation(e.getLocation())); } updateCursor(e); } public void dragExit(DragSourceEvent e) { describe("exit", e); } public void dropActionChanged(DragSourceDragEvent e) { describe("change", e); setModifiers(e.getGestureModifiersEx() & KEY_MASK); if (ghost != null) { ghost.move(getImageLocation(e.getLocation())); } updateCursor(e); } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/dnd/GhostedDragImage.java0000644000175000017500000001255011421126012026574 0ustar janjan/* 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. *

* 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.dnd; import java.awt.Component; import java.awt.Dimension; import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.Point; import java.awt.Rectangle; import java.awt.Window; import java.awt.dnd.DragSource; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.geom.Area; import javax.swing.Icon; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.Timer; import com.sun.jna.platform.WindowUtils; /** Provide a ghosted drag image for use during drags where * {@link DragSource#isDragImageSupported} returns false.

* Its location in screen coordinates may be changed via {@link #move}.

* When the image is no longer needed, invoke {@link #dispose}, which * hides the graphic immediately, or {@link #returnToOrigin}, which * moves the image to its original location and then disposes it. */ public class GhostedDragImage { private static final float DEFAULT_ALPHA = .5f; private Window dragImage; // Initial image position, relative to drag source private Point origin; /** Create a ghosted drag image, using the given icon. * @param icon image to be drawn * @param initialScreenLoc initial screen location of the image */ public GhostedDragImage(Component dragSource, final Icon icon, Point initialScreenLoc, final Point cursorOffset) { Window parent = dragSource instanceof Window ? (Window)dragSource : SwingUtilities.getWindowAncestor(dragSource); // FIXME ensure gc is compatible (X11) GraphicsConfiguration gc = parent.getGraphicsConfiguration(); dragImage = new Window(JOptionPane.getRootFrame(), gc) { private static final long serialVersionUID = 1L; public void paint(Graphics g) { icon.paintIcon(this, g, 0, 0); } public Dimension getPreferredSize() { return new Dimension(icon.getIconWidth(), icon.getIconHeight()); } public Dimension getMinimumSize() { return getPreferredSize(); } public Dimension getMaximumSize() { return getPreferredSize(); } }; dragImage.setFocusableWindowState(false); dragImage.setName("###overrideRedirect###"); Icon dragIcon = new Icon() { public int getIconHeight() { return icon.getIconHeight(); } public int getIconWidth() { return icon.getIconWidth(); } public void paintIcon(Component c, Graphics g, int x, int y) { g = g.create(); Area area = new Area(new Rectangle(x, y, getIconWidth(), getIconHeight())); // X11 needs more of a window due to differences in event processing area.subtract(new Area(new Rectangle(x + cursorOffset.x-1, y + cursorOffset.y-1, 3, 3))); g.setClip(area); icon.paintIcon(c, g, x, y); g.dispose(); } }; dragImage.pack(); WindowUtils.setWindowMask(dragImage, dragIcon); WindowUtils.setWindowAlpha(dragImage, DEFAULT_ALPHA); move(initialScreenLoc); dragImage.setVisible(true); } /** Set the transparency of the ghosted image. */ public void setAlpha(float alpha) { WindowUtils.setWindowAlpha(dragImage, alpha); } /** Make all ghosted images go away. */ public void dispose() { dragImage.dispose(); dragImage = null; } /** Move the ghosted image to the requested location. * @param screenLocation Where to draw the image, in screen coordinates */ public void move(Point screenLocation) { if (origin == null) { origin = screenLocation; } dragImage.setLocation(screenLocation.x, screenLocation.y); } private static final int SLIDE_INTERVAL = 1000/30; /** Animate the ghosted image returning to its origin. */ public void returnToOrigin() { final Timer timer = new Timer(SLIDE_INTERVAL, null); timer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Point location = dragImage.getLocationOnScreen(); Point dst = new Point(origin); int dx = (dst.x - location.x)/2; int dy = (dst.y - location.y)/2; if (dx != 0 || dy != 0) { location.translate(dx, dy); move(location); } else { timer.stop(); dispose(); } } }); timer.setInitialDelay(0); timer.start(); } }libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/dnd/DropHandler.java0000644000175000017500000004072011421126012025640 0ustar janjan/* 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. *

* 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.dnd; import java.awt.Component; import java.awt.Point; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.dnd.DnDConstants; import java.awt.dnd.DropTarget; import java.awt.dnd.DropTargetContext; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetEvent; import java.awt.dnd.DropTargetListener; import java.io.IOException; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; /** Provides simplified drop handling for a component. * Usage:
*


 * int actions = DnDConstants.MOVE_OR_COPY;
 * Component component = ...;
 * DropHandler handler = new DropHandler(component, actions);
 * 
*

*

    *
  • Accept drops where the action is the default (i.e. no modifiers) but * the intersection of source and target actions is not the default. * Doing so allows the source to adjust the cursor appropriately. *
  • Refuse drops where the user modifiers request an action that is not * supported (this works for all cases except when the drag source is not * a {@link DragHandler} and the user explicitly requests a MOVE operation; * this is indistinguishable from a drag with no modifiers unless we have * access to the key modifiers, which {@link DragHandler} provides). *
  • Drops may be refused based on data flavor, location, intended drop * action, or any combination of those, by overriding {@link #canDrop}. *
  • Custom decoration of the drop area may be performed in * {@link #paintDropTarget(DropTargetEvent, int, Point)} or by providing * a {@link DropTargetPainter}. *
* * The method {@link #getDropAction(DropTargetEvent)} follows these steps to * determine the appropriate action (if any). *
    *
  • {@link #isSupported(DataFlavor[])} determines if there are any supported * flavors *
  • {@link #getDropActionsForFlavors(DataFlavor[])} reduces the supported * actions based on available flavors. For instance, a text field for file * paths might support {@link DnDConstants#ACTION_COPY_OR_MOVE} on a plain * string, but {@link DnDConstants#ACTION_LINK} might be the only action * supported on a file. *
  • {@link #getDropAction(DropTargetEvent, int, int, int)} relax the action * if it's the default, or restrict it for user requested actions. *
  • {@link #canDrop(DropTargetEvent, int, Point)} change the action based on * the location in the drop target component, or any other criteria. *
* * Override {@link #drop(DropTargetDropEvent, int)} to handle the drop. * You should invoke {@link DropTargetDropEvent#dropComplete} as soon * as the {@link Transferable} data is obtained, to avoid making the DnD * operation look suspended. * * @see DragHandler * @author twall */ // NOTE: you could probably make one of these handlers serve several targets, // but for simplicity, keep the mapping 1-1-1 handler/droptarget/component // TODO: look into making use of the existing // Transferable.SwingDropTarget on JComponent instances instead of // creating a new DropTarget; we can add self as a listener; probably would // want to remove the default TransferHandler.DropHandler, which uses // the TransferHandler to drop public abstract class DropHandler implements DropTargetListener { private int acceptedActions; private List acceptedFlavors; private DropTarget dropTarget; private boolean active = true; private DropTargetPainter painter; /** Create a handler that allows the given set of actions. If using * this constructor, you will need to override {@link #isSupported} to * indicate which data flavors are allowed. */ public DropHandler(Component c, int acceptedActions) { this(c, acceptedActions, new DataFlavor[0]); } /** Enable handling of drops, indicating what actions and flavors are * acceptable. * @param c The component to receive drops * @param acceptedActions Allowed actions for drops * @param acceptedFlavors Allowed data flavors for drops * @see #isSupported */ public DropHandler(final Component c, int acceptedActions, DataFlavor[] acceptedFlavors) { this(c, acceptedActions, acceptedFlavors, null); } /** Enable handling of drops, indicating what actions and flavors are * acceptable, and providing a painter for drop target feedback. * @param c The component to receive drops * @param acceptedActions Allowed actions for drops * @param acceptedFlavors Allowed data flavors for drops * @param painter Painter to handle drop target feedback * @see #paintDropTarget */ public DropHandler(final Component c, int acceptedActions, DataFlavor[] acceptedFlavors, DropTargetPainter painter) { this.acceptedActions = acceptedActions; this.acceptedFlavors = Arrays.asList(acceptedFlavors); this.painter = painter; dropTarget = new DropTarget(c, acceptedActions, this, active); } protected DropTarget getDropTarget() { return dropTarget; } /** Whether this drop target is active. */ public boolean isActive() { return active; } /** Set whether this handler (and thus its drop target) will accept * any drops. */ public void setActive(boolean active) { this.active = active; if (dropTarget != null) { dropTarget.setActive(active); } } /** Indicate the actions available for the given list of data flavors. * Override this method if the acceptable drop actions depend * on the currently available {@link DataFlavor}. The default returns * the accepted actions passed into the constructor. * @param dataFlavors currently available flavors * @see #getDropAction(DropTargetEvent, int, int, int) * @see #canDrop(DropTargetEvent, int, Point) */ protected int getDropActionsForFlavors(DataFlavor[] dataFlavors) { return acceptedActions; } /** Calculate the effective action. The default implementation * checks whether any {@link DataFlavor}s are supported, and if so, * will change the current action from {@link DnDConstants#ACTION_NONE} to * something in common between the source and destination. Refuse * user-requested actions if they are not supported (rather than silently * accepting a non-user-requested action, which is the Java's DnD default * behavior). The drop action is forced to {@link DnDConstants#ACTION_NONE} * if there is no supported data flavor.

* @see #isSupported(DataFlavor[]) * @see #getDropActionsForFlavors * @see #getDropAction(DropTargetEvent, int, int, int) * @see #canDrop(DropTargetEvent, int, Point) */ protected int getDropAction(DropTargetEvent e) { int currentAction = DragHandler.NONE; int sourceActions = DragHandler.NONE; Point location = null; DataFlavor[] flavors = new DataFlavor[0]; if (e instanceof DropTargetDragEvent) { DropTargetDragEvent ev = (DropTargetDragEvent)e; currentAction = ev.getDropAction(); sourceActions = ev.getSourceActions(); flavors = ev.getCurrentDataFlavors(); location = ev.getLocation(); } else if (e instanceof DropTargetDropEvent) { DropTargetDropEvent ev = (DropTargetDropEvent)e; currentAction = ev.getDropAction(); sourceActions = ev.getSourceActions(); flavors = ev.getCurrentDataFlavors(); location = ev.getLocation(); } if (isSupported(flavors)) { int availableActions = getDropActionsForFlavors(flavors); currentAction = getDropAction(e, currentAction, sourceActions, availableActions); if (currentAction != DragHandler.NONE) { if (canDrop(e, currentAction, location)) { return currentAction; } } } return DragHandler.NONE; } /* Adjust the drop action depending on whether the * current action is the default or a specific user-requested action. * The default implementation will change the current action from * {@link DnDConstants#ACTION_NONE} if there are actions in * common between the source and destination. It will refuse user-requested * actions if they are not supported (rather than silently accepting * a non-user-requested action, which is the behavior of Swing's default * drop handlers).

* You can override this method if you wish to adjust the action based * on the the drag location; if you wish to deny drops based on location, * override {@link #canDrop} instead. If you wish to adjust * the action based on the available data flavors, override * {@link #getDropActionsForFlavor} instead. * @see #getDropActionsForFlavor * @see #canDrop(DropTargetEvent, int, Point) */ protected int getDropAction(DropTargetEvent e, int currentAction, int sourceActions, int acceptedActions) { boolean modifiersActive = modifiersActive(currentAction); if ((currentAction & acceptedActions) == DragHandler.NONE && !modifiersActive) { int action = acceptedActions & sourceActions; currentAction = action; } else if (modifiersActive) { int action = currentAction & acceptedActions & sourceActions; if (action != currentAction) { currentAction = action; } } return currentAction; } /** Returns whether there are key modifiers active , * or false if they can't be determined. * We use the DragHandler hint, if available, or fall back to whether * the drop action is other than the default (move). */ protected boolean modifiersActive(int dropAction) { int mods = DragHandler.getModifiers(); if (mods == DragHandler.UNKNOWN_MODIFIERS) { if (dropAction == DragHandler.LINK || dropAction == DragHandler.COPY) { return true; } // Can't (yet) distinguish between a forced and a default move // without help from DragHandler return false; } return mods != 0; } private String lastAction; private void describe(String type, DropTargetEvent e) { if (false) { String msg = "drop: " + type; if (e instanceof DropTargetDragEvent) { DropTargetContext dtc = e.getDropTargetContext(); DropTarget dt = dtc.getDropTarget(); DropTargetDragEvent ev = (DropTargetDragEvent)e; msg += ": src=" + DragHandler.actionString(ev.getSourceActions()) + " tgt=" + DragHandler.actionString(dt.getDefaultActions()) + " act=" + DragHandler.actionString(ev.getDropAction()); } else if (e instanceof DropTargetDropEvent) { DropTargetContext dtc = e.getDropTargetContext(); DropTarget dt = dtc.getDropTarget(); DropTargetDropEvent ev = (DropTargetDropEvent)e; msg += ": src=" + DragHandler.actionString(ev.getSourceActions()) + " tgt=" + DragHandler.actionString(dt.getDefaultActions()) + " act=" + DragHandler.actionString(ev.getDropAction()); } if (!msg.equals(lastAction)) { System.out.println(lastAction = msg); } } } /** Accept or reject the drag represented by the given event. Returns * the action determined by {@link #getDropAction(DropTargetEvent)}. */ protected int acceptOrReject(DropTargetDragEvent e) { int action = getDropAction(e); if (action != DragHandler.NONE) { // NOTE: the action argument (as of 1.5+) is only passed // to the DropTargetContextPeer, *not* the drag source e.acceptDrag(action); } else { e.rejectDrag(); } return action; } public void dragEnter(DropTargetDragEvent e) { describe("enter(tgt)", e); int action = acceptOrReject(e); paintDropTarget(e, action, e.getLocation()); } public void dragOver(DropTargetDragEvent e) { describe("over(tgt)", e); int action = acceptOrReject(e); paintDropTarget(e, action, e.getLocation()); } public void dragExit(DropTargetEvent e) { describe("exit(tgt)", e); paintDropTarget(e, DragHandler.NONE, null); } public void dropActionChanged(DropTargetDragEvent e) { describe("change(tgt)", e); int action = acceptOrReject(e); paintDropTarget(e, action, e.getLocation()); } /** Indicates the user has initiated a drop. The default performs all * standard drop validity checking and handling, then invokes * {@link #drop(DropTargetDropEvent,int)} if the drop looks acceptable. */ public void drop(DropTargetDropEvent e) { describe("drop(tgt)", e); int action = getDropAction(e); if (action != DragHandler.NONE) { e.acceptDrop(action); try { drop(e, action); // Just in case this hasn't been done yet e.dropComplete(true); } catch (Exception ex) { e.dropComplete(false); } } else { e.rejectDrop(); } paintDropTarget(e, DragHandler.NONE, e.getLocation()); } /** Return whether any of the flavors in the given list are accepted. * The list is compared against the accepted list provided in the * constructor. */ protected boolean isSupported(DataFlavor[] flavors) { Set set = new HashSet(Arrays.asList(flavors)); set.retainAll(acceptedFlavors); return !set.isEmpty(); } /** Update the appearance of the target component. Normally the decoration * should be painted only if the event is an instance of * {@link DropTargetDragEvent} with an action that is not * {@link DragHandler#NONE}. Otherwise the decoration should be removed * or hidden. *

* For an easy way to highlight the drop target, consider using a single * instance of AbstractComponentDecorator and moving it * according to the intended drop location. * @param e The drop target event * @param action The action for the drop * @param location The intended drop location, or null if there is none */ protected void paintDropTarget(DropTargetEvent e, int action, Point location) { if (painter != null) { painter.paintDropTarget(e, action, location); } } /** Indicate whether the given drop action is acceptable at the given * location. This method is the last check performed by * {@link #getDropAction(DropTargetEvent)}. * You may override this method to refuse drops on certain areas * within the drop target component. The default always returns true. */ protected boolean canDrop(DropTargetEvent e, int action, Point location) { return true; } /** Handle an incoming drop with the given action. The action passed in * might be different from {@link DropTargetDropEvent#getDropAction}, * for instance, if there are no modifiers and the default action is not * supported. Calling {@link DropTargetDropEvent#dropComplete} is * recommended as soon as the {@link Transferable} data is obtained; this * allows the drag source to reset the cursor and any drag images which * may be in effect. */ protected abstract void drop(DropTargetDropEvent e, int action) throws UnsupportedFlavorException, IOException; }libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/RasterRangesUtils.java0000644000175000017500000002612611421126014026320 0ustar janjan/* Copyright (c) 2007 Olivier Chafik, All Rights Reserved * Copyright (c) 2008 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. * * 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; import java.awt.Rectangle; import java.awt.image.DataBuffer; import java.awt.image.DataBufferByte; import java.awt.image.DataBufferInt; import java.awt.image.MultiPixelPackedSampleModel; import java.awt.image.Raster; import java.awt.image.SampleModel; import java.awt.image.SinglePixelPackedSampleModel; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; /** * Methods that are useful to decompose a raster into a set of rectangles. * An occupied pixel has two possible meanings, depending on the raster : *

    *
  • if the raster has an alpha layer, occupied means with alpha not null
  • *
  • if the raster doesn't have any alpha layer, occupied means not completely black
  • *
* @author Olivier Chafik */ public class RasterRangesUtils { /// Masks used to isolate the current column in a set of 8 binary columns packed in a byte private static final int[] subColMasks = new int[] { 0x0080, 0x0040, 0x0020, 0x0010, 0x0008, 0x0004, 0x0002, 0x0001 }; private static final Comparator COMPARATOR = new Comparator() { public int compare(Object o1, Object o2) { return ((Rectangle)o1).x - ((Rectangle)o2).x; } }; /** * Abstraction of a sink for ranges. */ public static interface RangesOutput { /** * Output a rectangular range. * @param x x coordinate of the top-left corner of the range * @param y y coordinate of the top-left corner of the range * @param w width of the range * @param h height of the range * @return true if the output succeeded, false otherwise */ boolean outputRange(int x, int y, int w, int h); } /** * Outputs ranges of occupied pixels. * In a raster that has an alpha layer, a pixel is occupied if its alpha value is not null. * In a raster without alpha layer, a pixel is occupied if it is not completely black. * @param raster image to be segmented in non black or non-transparent ranges * @param out destination of the non null ranges * @return true if the output succeeded, false otherwise */ public static boolean outputOccupiedRanges(Raster raster, RangesOutput out) { Rectangle bounds = raster.getBounds(); SampleModel sampleModel = raster.getSampleModel(); boolean hasAlpha = sampleModel.getNumBands() == 4; // Try to use the underlying data array directly for a few common raster formats if (raster.getParent() == null && bounds.x == 0 && bounds.y == 0) { // No support for subraster (as obtained with Image.getSubimage(...)) DataBuffer data = raster.getDataBuffer(); if (data.getNumBanks() == 1) { // There is always a single bank for all BufferedImage types, except maybe TYPE_CUSTOM if (sampleModel instanceof MultiPixelPackedSampleModel) { MultiPixelPackedSampleModel packedSampleModel = (MultiPixelPackedSampleModel)sampleModel; if (packedSampleModel.getPixelBitStride() == 1) { // TYPE_BYTE_BINARY return outputOccupiedRangesOfBinaryPixels(((DataBufferByte)data).getData(), bounds.width, bounds.height, out); } } else if (sampleModel instanceof SinglePixelPackedSampleModel) { if (sampleModel.getDataType() == DataBuffer.TYPE_INT) { // TYPE_INT_ARGB, TYPE_INT_ARGB_PRE, TYPE_INT_BGR or TYPE_INT_RGB return outputOccupiedRanges(((DataBufferInt)data).getData(), bounds.width, bounds.height, hasAlpha ? 0xff000000 : 0xffffff, out); } // TODO could easily handle cases of TYPE_USHORT_GRAY and TYPE_BYTE_GRAY. } } } // Fallback behaviour : copy pixels of raster int[] pixels = raster.getPixels(0, 0, bounds.width, bounds.height, (int[])null); return outputOccupiedRanges(pixels, bounds.width, bounds.height, hasAlpha ? 0xff000000 : 0xffffff, out); } /** * Output the non-null values of a binary image as ranges of contiguous values. * @param binaryBits byte-packed binary bits of an image * @param w width of the image (in pixels) * @param h height of the image * @param out * @return true if the output succeeded, false otherwise */ public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int w, int h, RangesOutput out) { Set rects = new HashSet(); Set prevLine = Collections.EMPTY_SET; int scanlineBytes = binaryBits.length / h; for (int row = 0; row < h; row++) { Set curLine = new TreeSet(COMPARATOR); int rowOffsetBytes = row * scanlineBytes; int startCol = -1; // Look at each batch of 8 columns in this row for (int byteCol = 0; byteCol < scanlineBytes; byteCol++) { int firstByteCol = byteCol << 3; byte byteColBits = binaryBits[rowOffsetBytes + byteCol]; if (byteColBits == 0) { // all 8 bits are zeroes if (startCol >= 0) { // end of current region curLine.add(new Rectangle(startCol, row, firstByteCol - startCol, 1)); startCol = -1; } } else if (byteColBits == 0xff) { // all 8 bits are ones if (startCol < 0) { // start of new region startCol = firstByteCol; } } else { // mixed case : some bits are ones, others are zeroes for (int subCol = 0; subCol < 8; subCol++) { int col = firstByteCol | subCol; if ((byteColBits & subColMasks[subCol]) != 0) { if (startCol < 0) { // start of new region startCol = col; } } else { if (startCol >= 0) { // end of current region curLine.add(new Rectangle(startCol, row, col - startCol, 1)); startCol = -1; } } } } } if (startCol >= 0) { // end of last region curLine.add(new Rectangle(startCol, row, w - startCol, 1)); } Set unmerged = mergeRects(prevLine, curLine); rects.addAll(unmerged); prevLine = curLine; } // Add anything left over rects.addAll(prevLine); for (Iterator i=rects.iterator();i.hasNext();) { Rectangle r = i.next(); if (!out.outputRange(r.x, r.y, r.width, r.height)) { return false; } } return true; } /** * Output the occupied values of an integer-pixels image as ranges of contiguous values. * A pixel is considered occupied if the bitwise AND of its integer value with the provided occupationMask is not null. * @param pixels integer values of the pixels of an image * @param w width of the image (in pixels) * @param h height of the image * @param occupationMask mask used to select which bits are used in a pixel to check its occupied status. 0xff000000 would only take the alpha layer into account, for instance. * @param out where to output all the contiguous ranges of non occupied pixels * @return true if the output succeeded, false otherwise */ public static boolean outputOccupiedRanges(int[] pixels, int w, int h, int occupationMask, RangesOutput out) { Set rects = new HashSet(); Set prevLine = Collections.EMPTY_SET; for (int row = 0; row < h; row++) { Set curLine = new TreeSet(COMPARATOR); int idxOffset = row * w; int startCol = -1; for (int col = 0; col < w; col++) { if ((pixels[idxOffset + col] & occupationMask) != 0) { if (startCol < 0) { startCol = col; } } else { if (startCol >= 0) { // end of current region curLine.add(new Rectangle(startCol, row, col-startCol, 1)); startCol = -1; } } } if (startCol >= 0) { // end of last region of current row curLine.add(new Rectangle(startCol, row, w-startCol, 1)); } Set unmerged = mergeRects(prevLine, curLine); rects.addAll(unmerged); prevLine = curLine; } // Add anything left over rects.addAll(prevLine); for (Iterator i=rects.iterator();i.hasNext();) { Rectangle r = i.next(); if (!out.outputRange(r.x, r.y, r.width, r.height)) { return false; } } return true; } private static Set mergeRects(Set prev, Set current) { Set unmerged = new HashSet(prev); if (!prev.isEmpty() && !current.isEmpty()) { Rectangle[] pr = prev.toArray(new Rectangle[prev.size()]); Rectangle[] cr = current.toArray(new Rectangle[current.size()]); int ipr = 0; int icr = 0; while (ipr < pr.length && icr < cr.length) { while (cr[icr].x < pr[ipr].x) { if (++icr == cr.length) { return unmerged; } } if (cr[icr].x == pr[ipr].x && cr[icr].width == pr[ipr].width) { unmerged.remove(pr[ipr]); cr[icr].y = pr[ipr].y; cr[icr].height = pr[ipr].height + 1; ++icr; } else { ++ipr; } } } return unmerged; } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/FileUtils.java0000644000175000017500000000735511421126012024600 0ustar janjan/* 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. *

* 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; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import com.sun.jna.platform.mac.MacFileUtils; import com.sun.jna.platform.win32.W32FileUtils; /** Miscellaneous file utils not provided for by Java. */ public abstract class FileUtils { public boolean hasTrash() { return false; } /** Move the given file to the system trash, if one is available. Throws an exception on failure. */ public abstract void moveToTrash(File[] files) throws IOException; /** Canonical lazy loading of a singleton. */ private static class Holder { public static final FileUtils INSTANCE; static { String os = System.getProperty("os.name"); if (os.startsWith("Windows")) { INSTANCE = new W32FileUtils(); } else if (os.startsWith("Mac")){ INSTANCE = new MacFileUtils(); } else { INSTANCE = new DefaultFileUtils(); } } } public static FileUtils getInstance() { return Holder.INSTANCE; } private static class DefaultFileUtils extends FileUtils { private File getTrashDirectory() { // very simple implementation. should take care of renaming when // a file already exists, or any other platform-specific behavior File home = new File(System.getProperty("user.home")); File trash = new File(home, ".Trash"); if (!trash.exists()) { trash = new File(home, "Trash"); if (!trash.exists()) { File desktop = new File(home, "Desktop"); if (desktop.exists()) { trash = new File(desktop, ".Trash"); if (!trash.exists()) { trash = new File(desktop, "Trash"); if (!trash.exists()) { trash = new File(System.getProperty("fileutils.trash", "Trash")); } } } } } return trash; } public boolean hasTrash() { return getTrashDirectory().exists(); } /** The default implementation attempts to move the file to * the desktop "Trash" folder. */ public void moveToTrash(File[] files) throws IOException { File trash = getTrashDirectory(); if (!trash.exists()) { throw new IOException("No trash location found (define fileutils.trash to be the path to the trash)"); } List failed = new ArrayList(); for (int i=0;i < files.length;i++) { File src = files[i]; File target = new File(trash, src.getName()); if (!src.renameTo(target)) { failed.add(src); } } if (failed.size() > 0) { throw new IOException("The following files could not be trashed: " + failed); } } } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/0000755000175000017500000000000011421375602023000 5ustar janjanlibjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/W32FileUtils.java0000644000175000017500000000333211421126020026024 0ustar janjan/* 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. * * 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 java.io.File; import java.io.IOException; import com.sun.jna.WString; import com.sun.jna.platform.FileUtils; public class W32FileUtils extends FileUtils { public boolean hasTrash() { return true; } public void moveToTrash(File[] files) throws IOException { Shell32 shell = Shell32.INSTANCE; ShellAPI.SHFILEOPSTRUCT fileop = new ShellAPI.SHFILEOPSTRUCT(); fileop.wFunc = ShellAPI.FO_DELETE; String[] paths = new String[files.length]; for (int i=0;i < paths.length;i++) { paths[i] = files[i].getAbsolutePath(); } fileop.pFrom = new WString(fileop.encodePaths(paths)); fileop.fFlags = ShellAPI.FOF_ALLOWUNDO|ShellAPI.FOF_NOCONFIRMATION|ShellAPI.FOF_SILENT; int ret = shell.SHFileOperation(fileop); if (ret != 0) { throw new IOException("Move to trash failed: " + Kernel32Util.formatMessageFromLastErrorCode(ret)); } if (fileop.fAnyOperationsAborted) { throw new IOException("Move to trash aborted"); } } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/WinReg.java0000644000175000017500000000521011421126022025022 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.WinNT.HANDLE; 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; } } public static final HKEY HKEY_CLASSES_ROOT = new HKEY(0x80000000); public static final HKEY HKEY_CURRENT_USER = new HKEY(0x80000001); public static final HKEY HKEY_LOCAL_MACHINE = new HKEY(0x80000002); public static final HKEY HKEY_USERS = new HKEY(0x80000003); public static final HKEY HKEY_PERFORMANCE_DATA= new HKEY(0x80000004); public static final HKEY HKEY_PERFORMANCE_TEXT= new HKEY(0x80000050); public static final HKEY HKEY_PERFORMANCE_NLSTEXT = new HKEY(0x80000060); public static final HKEY HKEY_CURRENT_CONFIG = new HKEY(0x80000005); public static final HKEY HKEY_DYN_DATA = new HKEY(0x80000006); } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Ole32Util.java0000644000175000017500000000422111421126016025355 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Native; import com.sun.jna.platform.win32.Guid.GUID; import com.sun.jna.platform.win32.WinNT.HRESULT; /** * Ole32 Utility API. * @author dblock[at]dblock.org */ public abstract class Ole32Util { /** * Convert a string to a GUID. * @param guidString * String representation of a GUID, including { }. * @return * A GUID. */ public static GUID getGUIDFromString(String guidString) { GUID.ByReference lpiid = new GUID.ByReference(); HRESULT hr = Ole32.INSTANCE.IIDFromString(guidString, lpiid); if (! hr.equals(W32Errors.S_OK)) { throw new RuntimeException(hr.toString()); } return lpiid; } /** * Convert a GUID into a string. * @param guid * GUID. * @return * String representation of a GUID. */ public static String getStringFromGUID(GUID guid) { GUID.ByReference pguid = new GUID.ByReference(guid.getPointer()); int max = 39; char[] lpsz = new char[max]; int len = Ole32.INSTANCE.StringFromGUID2(pguid, lpsz, max); if (len == 0) { throw new RuntimeException("StringFromGUID2"); } lpsz[len - 1] = 0; return Native.toString(lpsz); } /** * Generate a new GUID. * @return * New GUID. */ public static GUID generateGUID() { GUID.ByReference pguid = new GUID.ByReference(); HRESULT hr = Ole32.INSTANCE.CoCreateGuid(pguid); if (! hr.equals(W32Errors.S_OK)) { throw new RuntimeException(hr.toString()); } return pguid; } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/NtDll.java0000644000175000017500000000454611421126016024662 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Native; import com.sun.jna.Structure; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.IntByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; /** * ntdll.dll Interface. * @author dblock[at]dblock.org */ public interface NtDll extends StdCallLibrary { NtDll INSTANCE = (NtDll) Native.loadLibrary("NtDll", NtDll.class, W32APIOptions.UNICODE_OPTIONS); /** * The ZwQueryKey routine provides information about the class of a registry key, * and the number and sizes of its subkeys. * @param KeyHandle * Handle to the registry key to obtain information about. This handle is created by * a successful call to ZwCreateKey or ZwOpenKey. * @param KeyInformationClass * Specifies a KEY_INFORMATION_CLASS value that determines the type of information * returned in the KeyInformation buffer. * @param KeyInformation * Pointer to a caller-allocated buffer that receives the requested information. * @param Length * Specifies the size, in bytes, of the KeyInformation buffer. * @param ResultLength * Pointer to a variable that receives the size, in bytes, of the requested key * information. If ZwQueryKey returns STATUS_SUCCESS, the variable contains the amount * of data returned. If ZwQueryKey returns STATUS_BUFFER_OVERFLOW or * STATUS_BUFFER_TOO_SMALL, you can use the value of the variable to determine the * required buffer size. * @return * ZwQueryKey returns STATUS_SUCCESS on success, or the appropriate error code on failure. */ public int ZwQueryKey(HANDLE KeyHandle, int KeyInformationClass, Structure KeyInformation, int Length, IntByReference ResultLength); }libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Shell32.java0000644000175000017500000000642611421126016025060 0ustar janjan/* 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. *

* 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.platform.win32.ShellAPI.SHFILEOPSTRUCT; import com.sun.jna.platform.win32.WinDef.DWORD; import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.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); /** * This function can be used to copy, move, rename, or delete a file system object. * @param fileop * Address of an SHFILEOPSTRUCT structure that contains information this function * needs to carry out the specified operation. * @return * Returns zero if successful, or nonzero otherwise. */ int SHFileOperation(SHFILEOPSTRUCT fileop); /** * Takes the CSIDL of a folder and returns the path. * @param hwndOwner * Handle to an owner window. This parameter is typically set to NULL. If it is not NULL, * and a dial-up connection needs to be made to access the folder, a user interface (UI) * prompt will appear in this window. * @param nFolder * A CSIDL value that identifies the folder whose path is to be retrieved. Only real * folders are valid. If a virtual folder is specified, this function will fail. You can * force creation of a folder with SHGetFolderPath by combining the folder's CSIDL with * CSIDL_FLAG_CREATE. * @param hToken * An access token that can be used to represent a particular user. * @param dwFlags * Flags to specify which path is to be returned. * @param pszPath * Pointer to a null-terminated string of length MAX_PATH which will receive the path. * If an error occurs or S_FALSE is returned, this string will be empty. * @return * Returns standard HRESULT codes. */ HRESULT SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, char[] pszPath); /** * Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace. * The retrieved COM interface pointer can be used via Com4JNA's ComObject.wrapNativeInterface call * given a suitable interface definition for IShellFolder * @param ppshf A place to put the IShellFolder interface pointer * @return If the function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. */ HRESULT SHGetDesktopFolder( PointerByReference ppshf ); } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Shell32Util.java0000644000175000017500000000330611421126016025710 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Native; import com.sun.jna.platform.win32.WinDef.DWORD; import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platform.win32.WinNT.HRESULT; /** * Shell32 Utility API. * @author dblock[at]dblock.org */ public abstract class Shell32Util { /** * Get a special folder path. * @param hwnd * Parent window. * @param nFolder * Folder CSLID. * @param dwFlags * Flags. * @return * Special folder. */ public static String getFolderPath(HWND hwnd, int nFolder, DWORD dwFlags) { char[] pszPath = new char[WinDef.MAX_PATH]; HRESULT hr = Shell32.INSTANCE.SHGetFolderPath(hwnd, nFolder, null, dwFlags, pszPath); if (! hr.equals(W32Errors.S_OK)) { throw new Win32Exception(hr); } return Native.toString(pszPath); } /** * Get a special folder path. * @param nFolder * Folder CSLID. * @return * Special folder path. */ public static String getFolderPath(int nFolder) { return getFolderPath(null, nFolder, ShlObj.SHGFP_TYPE_CURRENT); } }libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/User32.java0000644000175000017500000010530311421126016024721 0ustar janjan/* 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. *

* 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.platform.win32.BaseTSD.LONG_PTR; import com.sun.jna.platform.win32.WinDef.HDC; import com.sun.jna.platform.win32.WinDef.HICON; import com.sun.jna.platform.win32.WinDef.HINSTANCE; import com.sun.jna.platform.win32.WinDef.HRGN; 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.RECT; import com.sun.jna.platform.win32.WinDef.WPARAM; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION; import com.sun.jna.platform.win32.WinUser.FLASHWINFO; import com.sun.jna.platform.win32.WinUser.GUITHREADINFO; import com.sun.jna.platform.win32.WinUser.HHOOK; import com.sun.jna.platform.win32.WinUser.HOOKPROC; import com.sun.jna.platform.win32.WinUser.MSG; import com.sun.jna.platform.win32.WinUser.POINT; import com.sun.jna.platform.win32.WinUser.SIZE; import com.sun.jna.platform.win32.WinUser.WINDOWINFO; import com.sun.jna.platform.win32.WinUser.WNDENUMPROC; 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 */ public interface User32 extends StdCallLibrary { User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class, W32APIOptions.DEFAULT_OPTIONS); /** * 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); } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/NTStatus.java0000644000175000017500000000413611421126016025365 0ustar janjan/* 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. * * 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.win32.StdCallLibrary; public interface NTStatus extends StdCallLibrary { public static final int STATUS_SUCCESS = 0x00000000; // ntsubauth public static final int STATUS_BUFFER_TOO_SMALL = 0xC0000023; // // MessageId: STATUS_WAIT_0 // // MessageText: // // STATUS_WAIT_0 // public static final int STATUS_WAIT_0 = 0x00000000; // winnt // // MessageId: STATUS_WAIT_1 // // MessageText: // // STATUS_WAIT_1 // public static final int STATUS_WAIT_1 = 0x00000001; // // MessageId: STATUS_WAIT_2 // // MessageText: // // STATUS_WAIT_2 // public static final int STATUS_WAIT_2 = 0x00000002; // // MessageId: STATUS_WAIT_3 // // MessageText: // // STATUS_WAIT_3 // public static final int STATUS_WAIT_3 = 0x00000003; // // MessageId: STATUS_WAIT_63 // // MessageText: // // STATUS_WAIT_63 // public static final int STATUS_WAIT_63 = 0x0000003F; // // The success status codes 128 - 191 are reserved for wait completion // status with an abandoned mutant object. // public static final int STATUS_ABANDONED = 0x00000080; // // MessageId: STATUS_ABANDONED_WAIT_0 // // MessageText: // // STATUS_ABANDONED_WAIT_0 // public static final int STATUS_ABANDONED_WAIT_0 = 0x00000080; // winnt // // MessageId: STATUS_ABANDONED_WAIT_63 // // MessageText: // // STATUS_ABANDONED_WAIT_63 // public static final int STATUS_ABANDONED_WAIT_63 = 0x000000BF; } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java0000644000175000017500000007044111421126016026051 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.TreeMap; import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinNT.HANDLEByReference; import com.sun.jna.platform.win32.WinNT.PSID; import com.sun.jna.platform.win32.WinNT.PSIDByReference; import com.sun.jna.platform.win32.WinNT.SID_AND_ATTRIBUTES; import com.sun.jna.platform.win32.WinNT.SID_NAME_USE; 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.ptr.PointerByReference; /** * Advapi32 utility API. * @author dblock[at]dblock.org */ public abstract class Advapi32Util { /** * An account. */ public static class Account { /** * Account name. */ public String name; /** * Account domain. */ public String domain; /** * Account SID. */ public byte[] sid; /** * String representation of the account SID. */ public String sidString; /** * Account type, one of SID_NAME_USE. */ public int accountType; /** * Fully qualified account name. */ public String fqn; } /** * Retrieves the name of the user associated with the current thread. * @return A user name. */ public static String getUserName() { char[] buffer = new char[128]; IntByReference len = new IntByReference(buffer.length); boolean result = Advapi32.INSTANCE.GetUserNameW(buffer, len); if (! result) { int rc = Kernel32.INSTANCE.GetLastError(); switch(rc) { case W32Errors.ERROR_INSUFFICIENT_BUFFER: buffer = new char[len.getValue()]; break; default: throw new Win32Exception(Native.getLastError()); } result = Advapi32.INSTANCE.GetUserNameW(buffer, len); } if (! result) { throw new Win32Exception(Native.getLastError()); } return Native.toString(buffer); } /** * Retrieves a security identifier (SID) for the account on the current system. * @param accountName Specifies the account name. * @return A structure containing the account SID; */ public static Account getAccountByName(String accountName) { return getAccountByName(null, accountName); } /** * Retrieves a security identifier (SID) for a given account. * @param systemName Name of the system. * @param accountName Account name. * @return A structure containing the account SID. */ public static Account getAccountByName(String systemName, String accountName) { IntByReference pSid = new IntByReference(0); IntByReference cchDomainName = new IntByReference(0); PointerByReference peUse = new PointerByReference(); if (Advapi32.INSTANCE.LookupAccountName(systemName, accountName, null, pSid, null, cchDomainName, peUse)) { throw new RuntimeException("LookupAccountNameW was expected to fail with ERROR_INSUFFICIENT_BUFFER"); } int rc = Kernel32.INSTANCE.GetLastError(); if (pSid.getValue() == 0 || rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) { throw new Win32Exception(rc); } Memory sidMemory = new Memory(pSid.getValue()); PSID result = new PSID(sidMemory); char[] referencedDomainName = new char[cchDomainName.getValue() + 1]; if (! Advapi32.INSTANCE.LookupAccountName(systemName, accountName, result, pSid, referencedDomainName, cchDomainName, peUse)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } Account account = new Account(); account.accountType = peUse.getPointer().getInt(0); account.name = accountName; String[] accountNamePartsBs = accountName.split("\\\\", 2); String[] accountNamePartsAt = accountName.split("@", 2); if (accountNamePartsBs.length == 2) { account.name = accountNamePartsBs[1]; } else if (accountNamePartsAt.length == 2) { account.name = accountNamePartsAt[0]; } else { account.name = accountName; } if (cchDomainName.getValue() > 0) { account.domain = Native.toString(referencedDomainName); account.fqn = account.domain + "\\" + account.name; } else { account.fqn = account.name; } account.sid = result.getBytes(); account.sidString = convertSidToStringSid(new PSID(account.sid)); return account; } /** * Get the account by SID on the local system. * * @param sid SID. * @return Account. */ public static Account getAccountBySid(PSID sid) { return getAccountBySid(null, sid); } /** * Get the account by SID. * * @param systemName Name of the system. * @param sid SID. * @return Account. */ public static Account getAccountBySid(String systemName, PSID sid) { IntByReference cchName = new IntByReference(); IntByReference cchDomainName = new IntByReference(); PointerByReference peUse = new PointerByReference(); if (Advapi32.INSTANCE.LookupAccountSid(null, sid, null, cchName, null, cchDomainName, peUse)) { throw new RuntimeException("LookupAccountSidW was expected to fail with ERROR_INSUFFICIENT_BUFFER"); } int rc = Kernel32.INSTANCE.GetLastError(); if (cchName.getValue() == 0 || rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) { throw new Win32Exception(rc); } char[] domainName = new char[cchDomainName.getValue()]; char[] name = new char[cchName.getValue()]; if (! Advapi32.INSTANCE.LookupAccountSid(null, sid, name, cchName, domainName, cchDomainName, peUse)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } Account account = new Account(); account.accountType = peUse.getPointer().getInt(0); account.name = Native.toString(name); if (cchDomainName.getValue() > 0) { account.domain = Native.toString(domainName); account.fqn = account.domain + "\\" + account.name; } else { account.fqn = account.name; } account.sid = sid.getBytes(); account.sidString = convertSidToStringSid(sid); return account; } /** * Convert a security identifier (SID) to a string format suitable for display, * storage, or transmission. * @param sid SID bytes. * @return String SID. */ public static String convertSidToStringSid(PSID sid) { PointerByReference stringSid = new PointerByReference(); if (! Advapi32.INSTANCE.ConvertSidToStringSid(sid, stringSid)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } String result = stringSid.getValue().getString(0, true); Kernel32.INSTANCE.LocalFree(stringSid.getValue()); return result; } /** * Convert a string representation of a security identifier (SID) to * a binary format. * @param sidString * String SID. * @return SID bytes. */ public static byte[] convertStringSidToSid(String sidString) { PSIDByReference pSID = new PSIDByReference(); if (! Advapi32.INSTANCE.ConvertStringSidToSid(sidString, pSID)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } return pSID.getValue().getBytes(); } /** * Compares a SID to a well known SID and returns TRUE if they match. * @param sidString * String representation of a SID. * @param wellKnownSidType * Member of the WELL_KNOWN_SID_TYPE enumeration to compare with the SID at pSid. * @return * True if the SID is of the well-known type, false otherwise. */ public static boolean isWellKnownSid(String sidString, int wellKnownSidType) { PSIDByReference pSID = new PSIDByReference(); if (! Advapi32.INSTANCE.ConvertStringSidToSid(sidString, pSID)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } return Advapi32.INSTANCE.IsWellKnownSid(pSID.getValue(), wellKnownSidType); } /** * Compares a SID to a well known SID and returns TRUE if they match. * @param sidBytes * Byte representation of a SID. * @param wellKnownSidType * Member of the WELL_KNOWN_SID_TYPE enumeration to compare with the SID at pSid. * @return * True if the SID is of the well-known type, false otherwise. */ public static boolean isWellKnownSid(byte[] sidBytes, int wellKnownSidType) { PSID pSID = new PSID(sidBytes); return Advapi32.INSTANCE.IsWellKnownSid(pSID, wellKnownSidType); } /** * Get an account name from a string SID on the local machine. * * @param sidString SID. * @return Account. */ public static Account getAccountBySid(String sidString) { return getAccountBySid(null, sidString); } /** * Get an account name from a string SID. * * @param systemName System name. * @param sidString SID. * @return Account. */ public static Account getAccountBySid(String systemName, String sidString) { return getAccountBySid(systemName, new PSID(convertStringSidToSid(sidString))); } /** * This function returns the groups associated with a security token, * such as a user token. * * @param hToken Token. * @return Token groups. */ public static Account[] getTokenGroups(HANDLE hToken) { // get token group information size IntByReference tokenInformationLength = new IntByReference(); if (Advapi32.INSTANCE.GetTokenInformation(hToken, WinNT.TOKEN_INFORMATION_CLASS.TokenGroups, null, 0, tokenInformationLength)) { throw new RuntimeException("Expected GetTokenInformation to fail with ERROR_INSUFFICIENT_BUFFER"); } int rc = Kernel32.INSTANCE.GetLastError(); if (rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) { throw new Win32Exception(rc); } // get token group information WinNT.TOKEN_GROUPS groups = new WinNT.TOKEN_GROUPS(tokenInformationLength.getValue()); if (! Advapi32.INSTANCE.GetTokenInformation(hToken, WinNT.TOKEN_INFORMATION_CLASS.TokenGroups, groups, tokenInformationLength.getValue(), tokenInformationLength)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } ArrayList userGroups = new ArrayList(); // make array of names for (SID_AND_ATTRIBUTES sidAndAttribute : groups.getGroups()) { Account group = null; try { group = Advapi32Util.getAccountBySid(sidAndAttribute.Sid); } catch(Exception e) { group = new Account(); group.sid = sidAndAttribute.Sid.getBytes(); group.sidString = Advapi32Util.convertSidToStringSid(sidAndAttribute.Sid); group.name = group.sidString; group.fqn = group.sidString; group.accountType = SID_NAME_USE.SidTypeGroup; } userGroups.add(group); } return userGroups.toArray(new Account[0]); } /** * This function returns the information about the user who owns a security token, * * @param hToken Token. * @return Token user. */ public static Account getTokenAccount(HANDLE hToken) { // get token group information size IntByReference tokenInformationLength = new IntByReference(); if (Advapi32.INSTANCE.GetTokenInformation(hToken, WinNT.TOKEN_INFORMATION_CLASS.TokenUser, null, 0, tokenInformationLength)) { throw new RuntimeException("Expected GetTokenInformation to fail with ERROR_INSUFFICIENT_BUFFER"); } int rc = Kernel32.INSTANCE.GetLastError(); if (rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) { throw new Win32Exception(rc); } // get token user information WinNT.TOKEN_USER user = new WinNT.TOKEN_USER(tokenInformationLength.getValue()); if (! Advapi32.INSTANCE.GetTokenInformation(hToken, WinNT.TOKEN_INFORMATION_CLASS.TokenUser, user, tokenInformationLength.getValue(), tokenInformationLength)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } return getAccountBySid(user.User.Sid); } /** * Return the group memberships of the currently logged on user. * @return An array of groups. */ public static Account[] getCurrentUserGroups() { HANDLEByReference phToken = new HANDLEByReference(); try { // open thread or process token HANDLE threadHandle = Kernel32.INSTANCE.GetCurrentThread(); if (! Advapi32.INSTANCE.OpenThreadToken(threadHandle, WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, true, phToken)) { if (W32Errors.ERROR_NO_TOKEN != Kernel32.INSTANCE.GetLastError()) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess(); if (! Advapi32.INSTANCE.OpenProcessToken(processHandle, WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } } return getTokenGroups(phToken.getValue()); } finally { if (phToken.getValue() != WinBase.INVALID_HANDLE_VALUE) { if (! Kernel32.INSTANCE.CloseHandle(phToken.getValue())) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } } } } /** * Checks whether a registry key exists. * @param root * HKEY_LOCAL_MACHINE, etc. * @param key * Path to the registry key. * @return * True if the key exists. */ public static boolean registryKeyExists(HKEY root, String key) { HKEYByReference phkKey = new HKEYByReference(); int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey); switch(rc) { case W32Errors.ERROR_SUCCESS: Advapi32.INSTANCE.RegCloseKey(phkKey.getValue()); return true; case W32Errors.ERROR_FILE_NOT_FOUND: return false; default: throw new Win32Exception(rc); } } /** * Checks whether a registry value exists. * @param root * HKEY_LOCAL_MACHINE, etc. * @param key * Registry key path. * @param value * Value name. * @return * True if the value exists. */ public static boolean registryValueExists(HKEY root, String key, String value) { HKEYByReference phkKey = new HKEYByReference(); int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey); try { switch(rc) { case W32Errors.ERROR_SUCCESS: break; case W32Errors.ERROR_FILE_NOT_FOUND: return false; default: throw new Win32Exception(rc); } IntByReference lpcbData = new IntByReference(); IntByReference lpType = new IntByReference(); rc = Advapi32.INSTANCE.RegQueryValueEx( phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData); switch(rc) { case W32Errors.ERROR_SUCCESS: case W32Errors.ERROR_INSUFFICIENT_BUFFER: return true; case W32Errors.ERROR_FILE_NOT_FOUND: return false; default: throw new Win32Exception(rc); } } finally { if (phkKey.getValue() != WinBase.INVALID_HANDLE_VALUE) { rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue()); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } } } /** * Get a registry REG_SZ value. * @param root * Root key. * @param key * Registry path. * @param value * Name of the value to retrieve. * @return * String value. */ public static String registryGetStringValue(HKEY root, String key, String value) { HKEYByReference phkKey = new HKEYByReference(); int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } try { IntByReference lpcbData = new IntByReference(); IntByReference lpType = new IntByReference(); rc = Advapi32.INSTANCE.RegQueryValueEx( phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData); if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) { throw new Win32Exception(rc); } if (lpType.getValue() != WinNT.REG_SZ) { throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ"); } char[] data = new char[lpcbData.getValue()]; rc = Advapi32.INSTANCE.RegQueryValueEx( phkKey.getValue(), value, 0, lpType, data, lpcbData); if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) { throw new Win32Exception(rc); } return Native.toString(data); } finally { rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue()); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } } /** * Get a registry DWORD value. * @param root * Root key. * @param key * Registry key path. * @param value * Name of the value to retrieve. * @return * Integer value. */ public static int registryGetIntValue(HKEY root, String key, String value) { HKEYByReference phkKey = new HKEYByReference(); int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } try { IntByReference lpcbData = new IntByReference(); IntByReference lpType = new IntByReference(); rc = Advapi32.INSTANCE.RegQueryValueEx( phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData); if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) { throw new Win32Exception(rc); } if (lpType.getValue() != WinNT.REG_DWORD) { throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ"); } IntByReference data = new IntByReference(); rc = Advapi32.INSTANCE.RegQueryValueEx( phkKey.getValue(), value, 0, lpType, data, lpcbData); if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) { throw new Win32Exception(rc); } return data.getValue(); } finally { rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue()); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } } /** * Create a registry key. * @param hKey * Parent key. * @param keyName * Key name. */ public static void registryCreateKey(HKEY hKey, String keyName) { HKEYByReference phkResult = new HKEYByReference(); int rc = Advapi32.INSTANCE.RegCreateKeyEx(hKey, keyName, 0, null, 0, WinNT.KEY_READ, null, phkResult, null); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } rc = Advapi32.INSTANCE.RegCloseKey(phkResult.getValue()); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } /** * Create a registry key. * @param root * Root key. * @param parentPath * Path to an existing registry key. * @param keyName * Key name. */ public static void registryCreateKey(HKEY root, String parentPath, String keyName) { HKEYByReference phkKey = new HKEYByReference(); int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, parentPath, 0, WinNT.KEY_CREATE_SUB_KEY, phkKey); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } try { registryCreateKey(phkKey.getValue(), keyName); } finally { rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue()); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } } /** * Set an integer value in registry. * @param hKey * Parent key. * @param name * Name. * @param value * Value. */ public static void registrySetIntValue(HKEY hKey, String name, int value) { byte[] data = new byte[4]; data[0] = (byte)(value & 0xff); data[1] = (byte)((value >> 8) & 0xff); data[2] = (byte)((value >> 16) & 0xff); data[3] = (byte)((value >> 24) & 0xff); int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_DWORD, data, 4); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } /** * Set an integer value in registry. * @param root * Root key. * @param keyPath * Path to an existing registry key. * @param name * Name. * @param value * Value. */ public static void registrySetIntValue(HKEY root, String keyPath, String name, int value) { HKEYByReference phkKey = new HKEYByReference(); int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } try { registrySetIntValue(phkKey.getValue(), name, value); } finally { rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue()); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } } /** * Set a string value in registry. * @param hKey * Parent key. * @param name * Name. * @param value * Value. */ public static void registrySetStringValue(HKEY hKey, String name, String value) { char[] data = Native.toCharArray(value); int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_SZ, data, data.length * 2); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } /** * Set a string value in registry. * @param root * Root key. * @param keyPath * Path to an existing registry key. * @param name * Name. * @param value * Value. */ public static void registrySetStringValue(HKEY root, String keyPath, String name, String value) { HKEYByReference phkKey = new HKEYByReference(); int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } try { registrySetStringValue(phkKey.getValue(), name, value); } finally { rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue()); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } } /** * Delete a registry key. * @param hKey * Parent key. * @param keyName * Name of the key to delete. */ public static void registryDeleteKey(HKEY hKey, String keyName) { int rc = Advapi32.INSTANCE.RegDeleteKey(hKey, keyName); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } /** * Delete a registry key. * @param root * Root key. * @param keyPath * Path to an existing registry key. * @param keyName * Name of the key to delete. */ public static void registryDeleteKey(HKEY root, String keyPath, String keyName) { HKEYByReference phkKey = new HKEYByReference(); int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } try { registryDeleteKey(phkKey.getValue(), keyName); } finally { rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue()); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } } /** * Delete a registry value. * @param hKey * Parent key. * @param valueName * Name of the value to delete. */ public static void registryDeleteValue(HKEY hKey, String valueName) { int rc = Advapi32.INSTANCE.RegDeleteValue(hKey, valueName); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } /** * Delete a registry value. * @param root * Root key. * @param keyPath * Path to an existing registry key. * @param valueName * Name of the value to delete. */ public static void registryDeleteValue(HKEY root, String keyPath, String valueName) { HKEYByReference phkKey = new HKEYByReference(); int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } try { registryDeleteValue(phkKey.getValue(), valueName); } finally { rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue()); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } } /** * Get names of the registry key's sub-keys. * @param hKey * Registry key. * @return * Array of registry key names. */ public static String[] registryGetKeys(HKEY hKey) { IntByReference lpcSubKeys = new IntByReference(); IntByReference lpcMaxSubKeyLen = new IntByReference(); int rc = Advapi32.INSTANCE.RegQueryInfoKey(hKey, null, null, null, lpcSubKeys, lpcMaxSubKeyLen, null, null, null, null, null, null); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } ArrayList keys = new ArrayList(lpcSubKeys.getValue()); char[] name = new char[lpcMaxSubKeyLen.getValue() + 1]; for (int i = 0; i < lpcSubKeys.getValue(); i++) { IntByReference lpcchValueName = new IntByReference(lpcMaxSubKeyLen.getValue() + 1); rc = Advapi32.INSTANCE.RegEnumKeyEx(hKey, i, name, lpcchValueName, null, null, null, null); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } keys.add(Native.toString(name)); } return keys.toArray(new String[0]); } /** * Get names of the registry key's sub-keys. * @param root * Root key. * @param keyPath * Path to a registry key. * @return * Array of registry key names. */ public static String[] registryGetKeys(HKEY root, String keyPath) { HKEYByReference phkKey = new HKEYByReference(); int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ, phkKey); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } try { return registryGetKeys(phkKey.getValue()); } finally { rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue()); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } } /** * Get a table of registry values. * @param hKey * Registry key. * @return * Table of values. */ public static TreeMap registryGetValues(HKEY hKey) { IntByReference lpcValues = new IntByReference(); IntByReference lpcMaxValueNameLen = new IntByReference(); IntByReference lpcMaxValueLen = new IntByReference(); int rc = Advapi32.INSTANCE.RegQueryInfoKey(hKey, null, null, null, null, null, null, lpcValues, lpcMaxValueNameLen, lpcMaxValueLen, null, null); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } TreeMap keyValues = new TreeMap(); char[] name = new char[lpcMaxValueNameLen.getValue() + 1]; byte[] data = new byte[lpcMaxValueLen.getValue()]; for (int i = 0; i < lpcValues.getValue(); i++) { IntByReference lpcchValueName = new IntByReference(lpcMaxValueNameLen.getValue() + 1); IntByReference lpcbData = new IntByReference(lpcMaxValueLen.getValue()); IntByReference lpType = new IntByReference(); rc = Advapi32.INSTANCE.RegEnumValue(hKey, i, name, lpcchValueName, null, lpType, data, lpcbData); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } switch(lpType.getValue()) { case WinNT.REG_DWORD: keyValues.put(Native.toString(name), ((int)(data[0] & 0xff)) + (((int)(data[1] & 0xff)) << 8) + (((int)(data[2] & 0xff)) << 16) + (((int)(data[3] & 0xff)) << 24)); break; case WinNT.REG_SZ: try { keyValues.put(Native.toString(name), new String(data, 0, data.length - 2, "UTF-16LE")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage()); } break; default: throw new RuntimeException("Unsupported type: " + lpType.getValue()); } } return keyValues; } /** * Get a table of registry values. * @param root * Registry root. * @param keyPath * Regitry key path. * @return * Table of values. */ public static TreeMap registryGetValues(HKEY root, String keyPath) { HKEYByReference phkKey = new HKEYByReference(); int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ, phkKey); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } try { return registryGetValues(phkKey.getValue()); } finally { rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue()); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); } } } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Advapi32.java0000644000175000017500000007455211421126016025222 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Native; import com.sun.jna.Structure; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinNT.HANDLEByReference; import com.sun.jna.platform.win32.WinNT.PSID; import com.sun.jna.platform.win32.WinNT.PSIDByReference; import com.sun.jna.platform.win32.WinNT.SECURITY_ATTRIBUTES; 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.ptr.PointerByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; /** * Advapi32.dll Interface. * @author dblock[at]dblock.org */ public interface Advapi32 extends StdCallLibrary { Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class, W32APIOptions.UNICODE_OPTIONS); /** * Retrieves the name of the user associated with the current thread. * http://msdn.microsoft.com/en-us/library/ms724432(VS.85).aspx * * @param buffer * Buffer to receive the user's logon name. * @param len * On input, the size of the buffer, on output the number of * characters copied into the buffer, including the terminating * null character. * @return * True if succeeded. */ public boolean GetUserNameW(char[] buffer, IntByReference len); /** * Accepts the name of a system and anaccount as input and retrieves a security * identifier (SID) for the account and the name of the domain on which the * account was found. * http://msdn.microsoft.com/en-us/library/aa379159(VS.85).aspx * * @param lpSystemName * Specifies the name of the system. * @param lpAccountName * Specifies the account name. * @param Sid * Receives the SID structure that corresponds to the account * name pointed to by the lpAccountName parameter. * @param cbSid * On input, this value specifies the size, in bytes, of the Sid * buffer. If the function fails because the buffer is too small * or if cbSid is zero, this variable receives the required * buffer size. * @param ReferencedDomainName * Receives the name of the domain where the account name is found. * @param cchReferencedDomainName * On input, this value specifies the size, in TCHARs, of the * ReferencedDomainName buffer. If the function fails because the * buffer is too small, this variable receives the required * buffer size, including the terminating null character. * @param peUse * SID_NAME_USE enumerated type that indicates the type of the * account when the function returns. * @return * True if the function was successful, False otherwise. */ public boolean LookupAccountName(String lpSystemName, String lpAccountName, PSID Sid, IntByReference cbSid, char[] ReferencedDomainName, IntByReference cchReferencedDomainName, PointerByReference peUse); /** * Retrieves the name of the account for this SID and the name of the first domain * on which this SID is found. * * @param lpSystemName Specifies the target computer. * @param Sid The SID to look up. * @param lpName * Buffer that receives a null-terminated string that contains the * account name that corresponds to the lpSid parameter. * @param cchName * On input, specifies the size, in TCHARs, of the lpName buffer. If the function fails * because the buffer is too small or if cchName is zero, cchName receives the required * buffer size, including the terminating null character. * @param ReferencedDomainName * Pointer to a buffer that receives a null-terminated string that contains the name of * the domain where the account name was found. * @param cchReferencedDomainName * On input, specifies the size, in TCHARs, of the lpReferencedDomainName buffer. If the * function fails because the buffer is too small or if cchReferencedDomainName is zero, * cchReferencedDomainName receives the required buffer size, including the terminating * null character. * @param peUse * Pointer to a variable that receives a SID_NAME_USE value that indicates the type of * the account. * @return * If the function succeeds, the function returns nonzero. * If the function fails, it returns zero. To get extended error information, call * GetLastError. */ public boolean LookupAccountSid(String lpSystemName, PSID Sid, char[] lpName, IntByReference cchName, char[] ReferencedDomainName, IntByReference cchReferencedDomainName, PointerByReference peUse); /** * Convert a security identifier (SID) to a string format suitable for display, * storage, or transmission. * http://msdn.microsoft.com/en-us/library/aa376399(VS.85).aspx * * @param Sid * The SID structure to be converted. * @param StringSid * Pointer to a variable that receives a pointer to a * null-terminated SID string. To free the returned buffer, call * the LocalFree function. * @return True if the function was successful, False otherwise. */ public boolean ConvertSidToStringSid(PSID Sid, PointerByReference StringSid); /** * Convert a string-format security identifier (SID) into a valid, functional SID. * http://msdn.microsoft.com/en-us/library/aa376402(VS.85).aspx * * @param StringSid The string-format SID to convert. * @param Sid Receives a pointer to the converted SID. * @return True if the function was successful, False otherwise. */ public boolean ConvertStringSidToSid(String StringSid, PSIDByReference Sid); /** * Returns the length, in bytes, of a valid security identifier (SID). * http://msdn.microsoft.com/en-us/library/aa446642(VS.85).aspx * * @param pSid A pointer to the SID structure whose length is returned. * @return Length of the SID. */ public int GetLengthSid(PSID pSid); /** * The IsValidSid function validates a security identifier (SID) by verifying that * the revision number is within a known range, and that the number of subauthorities * is less than the maximum. * @param pSid * Pointer to the SID structure to validate. This parameter cannot be NULL. * @return * If the SID structure is valid, the return value is nonzero. * If the SID structure is not valid, the return value is zero. There is no extended * error information for this function; do not call GetLastError. */ public boolean IsValidSid(PSID pSid); /** * Compares a SID to a well known SID and returns TRUE if they match. * @param pSid * SID to test. * @param wellKnownSidType * Member of the WELL_KNOWN_SID_TYPE enumeration to compare with the SID at pSid. * @return * True if the SID is of a given well known type, false otherwise. */ public boolean IsWellKnownSid(PSID pSid, int wellKnownSidType); /** * The CreateWellKnownSid function creates a SID for predefined aliases. * @param wellKnownSidType * Member of the WELL_KNOWN_SID_TYPE enumeration that specifies what the SID will identify. * @param domainSid * Pointer to a SID that identifies the domain control to use when creating the SID. * Pass NULL to use the local computer. * @param pSid * Pointer to memory where CreateWellKnownSid will store the new SID. * @param cbSid * Pointer to a DWORD that contains the number of bytes available at pSid. * The CreateWellKnownSid function stores the number of bytes actually used * at this location. * @return * If the function succeeds, the return value is nonzero. * If the function fails, the return value is zero. For extended error information, * call GetLastError. */ public boolean CreateWellKnownSid(int wellKnownSidType, PSID domainSid, PSID pSid, IntByReference cbSid); /** * The LogonUser function attempts to log a user on to the local computer. The local computer is * the computer from which LogonUser was called. You cannot use LogonUser to log on to a remote * computer. You specify the user with a user name and domain, and authenticate the user with a * plaintext password. If the function succeeds, you receive a handle to a token that represents * the logged-on user. You can then use this token handle to impersonate the specified user or, * in most cases, to create a process that runs in the context of the specified user. * @param lpszUsername * A pointer to a null-terminated string that specifies the name of the user. This is the name of * the user account to log on to. If you use the user principal name (UPN) format, * user@DNS_domain_name, the lpszDomain parameter must be NULL. * @param lpszDomain * A pointer to a null-terminated string that specifies the name of the domain or server whose * account database contains the lpszUsername account. If this parameter is NULL, the user name * must be specified in UPN format. If this parameter is ".", the function validates the account * using only the local account database. * @param lpszPassword * A pointer to a null-terminated string that specifies the plaintext password for the user * account specified by lpszUsername. * @param logonType * The type of logon operation to perform. * @param logonProvider * Specifies the logon provider. * @param phToken * A pointer to a handle variable that receives a handle to a token that represents the specified user. * @return * If the function succeeds, the function returns nonzero. * If the function fails, it returns zero. To get extended error information, call GetLastError. */ public boolean LogonUser( String lpszUsername, String lpszDomain, String lpszPassword, int logonType, int logonProvider, HANDLEByReference phToken); /** * The OpenThreadToken function opens the access token associated with a thread. * @param ThreadHandle * Handle to the thread whose access token is opened. * @param DesiredAccess * Specifies an access mask that specifies the requested types of access to the access token. * These requested access types are reconciled against the token's discretionary access * control list (DACL) to determine which accesses are granted or denied. * @param OpenAsSelf * Indicates whether the access check is to be made against the security context of the * thread calling the OpenThreadToken function or against the security context of the * process for the calling thread. * @param TokenHandle * Pointer to a variable that receives the handle to the newly opened access token. * @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. */ public boolean OpenThreadToken( HANDLE ThreadHandle, int DesiredAccess, boolean OpenAsSelf, HANDLEByReference TokenHandle); /** * The OpenProcessToken function opens the access token associated with a process. * @param ProcessHandle * Handle to the process whose access token is opened. The process must have the * PROCESS_QUERY_INFORMATION access permission. * @param DesiredAccess * Specifies an access mask that specifies the requested types of access to the access * token. These requested access types are compared with the discretionary access * control list (DACL) of the token to determine which accesses are granted or denied. * @param TokenHandle * Pointer to a handle that identifies the newly opened access token when the function returns. * @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. */ public boolean OpenProcessToken( HANDLE ProcessHandle, int DesiredAccess, HANDLEByReference TokenHandle); /** * The DuplicateToken function creates a new access token that duplicates * one already in existence. * * @param ExistingTokenHandle * Handle to an access token opened with TOKEN_DUPLICATE access. * @param ImpersonationLevel * Specifies a SECURITY_IMPERSONATION_LEVEL enumerated type that supplies * the impersonation level of the new token. * @param DuplicateTokenHandle * Pointer to a variable that receives a handle to the duplicate token. * This handle has TOKEN_IMPERSONATE and TOKEN_QUERY access to the new token. * @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. */ public boolean DuplicateToken( HANDLE ExistingTokenHandle, int ImpersonationLevel, HANDLEByReference DuplicateTokenHandle); /** * Retrieves a specified type of information about an access token. * The calling process must have appropriate access rights to obtain the information. * @param tokenHandle * Handle to an access token from which information is retrieved. If TokenInformationClass * specifies TokenSource, the handle must have TOKEN_QUERY_SOURCE access. For all other * TokenInformationClass values, the handle must have TOKEN_QUERY access. * @param tokenInformationClass * Specifies a value from the TOKEN_INFORMATION_CLASS enumerated type to identify the type of * information the function retrieves. * @param tokenInformation * Pointer to a buffer the function fills with the requested information. The structure put * into this buffer depends upon the type of information specified by the TokenInformationClass * parameter. * @param tokenInformationLength * Specifies the size, in bytes, of the buffer pointed to by the TokenInformation parameter. * If TokenInformation is NULL, this parameter must be zero. * @param returnLength * Pointer to a variable that receives the number of bytes needed for the buffer pointed to by * the TokenInformation parameter. If this value is larger than the value specified in the * TokenInformationLength parameter, the function fails and stores no data in the buffer. * @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. */ public boolean GetTokenInformation( HANDLE tokenHandle, int tokenInformationClass, Structure tokenInformation, int tokenInformationLength, IntByReference returnLength); /** * The ImpersonateLoggedOnUser function lets the calling thread impersonate the * security context of a logged-on user. The user is represented by a token * handle. * @param hToken * Handle to a primary or impersonation access token that represents a logged-on * user. This can be a token handle returned by a call to LogonUser, * CreateRestrictedToken, DuplicateToken, DuplicateTokenEx, OpenProcessToken, * or OpenThreadToken functions. If hToken is a primary token, it must have * TOKEN_QUERY and TOKEN_DUPLICATE access. If hToken is an impersonation token, * it must have TOKEN_QUERY and TOKEN_IMPERSONATE access. * @return * If the function succeeds, the return value is nonzero. */ public boolean ImpersonateLoggedOnUser( HANDLE hToken); /** * The RevertToSelf function terminates the impersonation of a client application. * @return If the function succeeds, the return value is nonzero. */ public boolean RevertToSelf(); /** * The RegOpenKeyEx function opens the specified registry key. * Note that key names are not case sensitive. * @param hKey * Handle to an open key. * @param lpSubKey * Pointer to a null-terminated string containing the name of the subkey to open. * @param ulOptions * Reserved; must be zero. * @param samDesired * Access mask that specifies the desired access rights to the key. The function * fails if the security descriptor of the key does not permit the requested access * for the calling process. * @param phkResult * Pointer to a variable that receives a handle to the opened key. If the key is * not one of the predefined registry keys, call the RegCloseKey function after * you have finished using the handle. * @return * If the function succeeds, the return value is ERROR_SUCCESS. * If the function fails, the return value is a nonzero error code defined in Winerror.h. */ public int RegOpenKeyEx(HKEY hKey, String lpSubKey, int ulOptions, int samDesired, HKEYByReference phkResult); /** * The RegQueryValueEx function retrieves the type and data for a specified value name * associated with an open registry key. * @param hKey * Handle to an open key. The key must have been opened with the * KEY_QUERY_VALUE access right. * @param lpValueName * Pointer to a null-terminated string containing the name of the value to query. * If lpValueName is NULL or an empty string, "", the function retrieves the type * and data for the key's unnamed or default value, if any. * @param lpReserved * Reserved; must be NULL. * @param lpType * Pointer to a variable that receives a code indicating the type of data stored * in the specified value. * @param lpData * Pointer to a buffer that receives the value's data. This parameter can be NULL * if the data is not required. If the data is a string, the function checks for * a terminating null character. If one is not found, the string is stored with a * null terminator if the buffer is large enough to accommodate the extra * character. Otherwise, the string is stored as is. * @param lpcbData * Pointer to a variable that specifies the size of the buffer pointed to by the * lpData parameter, in bytes. When the function returns, this variable contains * the size of the data copied to lpData. The lpcbData parameter can be NULL only * if lpData is NULL. If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ * type, this size includes any terminating null character or characters. * If the buffer specified by lpData parameter is not large enough to hold the * data, the function returns ERROR_MORE_DATA and stores the required buffer size * in the variable pointed to by lpcbData. In this case, the contents of the lpData * buffer are undefined. If lpData is NULL, and lpcbData is non-NULL, the function * returns ERROR_SUCCESS and stores the size of the data, in bytes, in the variable * pointed to by lpcbData. This enables an application to determine the best way * to allocate a buffer for the value's data. * @return * If the function succeeds, the return value is ERROR_SUCCESS. * If the function fails, the return value is a nonzero error code defined in Winerror.h. */ public int RegQueryValueEx(HKEY hKey, String lpValueName, int lpReserved, IntByReference lpType, char[] lpData, IntByReference lpcbData); public int RegQueryValueEx(HKEY hKey, String lpValueName, int lpReserved, IntByReference lpType, byte[] lpData, IntByReference lpcbData); public int RegQueryValueEx(HKEY hKey, String lpValueName, int lpReserved, IntByReference lpType, IntByReference lpData, IntByReference lpcbData); /** * The RegCloseKey function releases a handle to the specified registry key. * @param hKey * Handle to the open key to be closed. The handle must have been opened by the * RegCreateKeyEx, RegOpenKeyEx, or RegConnectRegistry function. * @return * If the function succeeds, the return value is ERROR_SUCCESS. If the function * fails, the return value is a nonzero error code defined in Winerror.h. */ public int RegCloseKey(HKEY hKey); /** * The RegDeleteValue function removes a named value from the specified registry * key. Note that value names are not case sensitive. * @param hKey * Handle to an open key. The key must have been opened with the KEY_SET_VALUE * access right. * @param lpValueName * Pointer to a null-terminated string that names the value to remove. If this * parameter is NULL or an empty string, the value set by the RegSetValue function * is removed. * @return * If the function succeeds, the return value is ERROR_SUCCESS. If the function * fails, the return value is a nonzero error code defined in Winerror.h. */ public int RegDeleteValue(HKEY hKey, String lpValueName); /** * The RegSetValueEx function sets the data and type of a specified value under a * registry key. * @param hKey * Handle to an open key. The key must have been opened with the KEY_SET_VALUE * access right. * @param lpValueName * Pointer to a string containing the name of the value to set. If a value with * this name is not already present in the key, the function adds it to the key. * If lpValueName is NULL or an empty string, "", the function sets the type and * data for the key's unnamed or default value. * @param Reserved * Reserved; must be zero. * @param dwType * Type of data pointed to by the lpData parameter. * @param lpData * Pointer to a buffer containing the data to be stored with the specified value name. * @param cbData * Size of the information pointed to by the lpData parameter, in bytes. If the data * is of type REG_SZ, REG_EXPAND_SZ, or REG_MULTI_SZ, cbData must include the size of * the terminating null character or characters. * @return * If the function succeeds, the return value is ERROR_SUCCESS. If the function * fails, the return value is a nonzero error code defined in Winerror.h. */ public int RegSetValueEx(HKEY hKey, String lpValueName, int Reserved, int dwType, char[] lpData, int cbData); public int RegSetValueEx(HKEY hKey, String lpValueName, int Reserved, int dwType, byte[] lpData, int cbData); /** * * @param hKey * @param lpSubKey * @param Reserved * @param lpClass * @param dwOptions * @param samDesired * @param lpSecurityAttributes * @param phkResult * @param lpdwDisposition * @return * If the function succeeds, the return value is ERROR_SUCCESS. If the function * fails, the return value is a nonzero error code defined in Winerror.h. */ public int RegCreateKeyEx(HKEY hKey, String lpSubKey, int Reserved, String lpClass, int dwOptions, int samDesired, SECURITY_ATTRIBUTES lpSecurityAttributes, HKEYByReference phkResult, IntByReference lpdwDisposition); /** * * @param hKey * @param name * @return * If the function succeeds, the return value is ERROR_SUCCESS. If the function * fails, the return value is a nonzero error code defined in Winerror.h. */ public int RegDeleteKey(HKEY hKey, String name); /** * The RegEnumKeyEx function enumerates subkeys of the specified open registry key. * The function retrieves information about one subkey each time it is called. * @param hKey * Handle to an open key. The key must have been opened with the * KEY_ENUMERATE_SUB_KEYS access right. * @param dwIndex * Index of the subkey to retrieve. This parameter should be zero for the first * call to the RegEnumKeyEx function and then incremented for subsequent calls. * Because subkeys are not ordered, any new subkey will have an arbitrary index. * This means that the function may return subkeys in any order. * @param lpName * Pointer to a buffer that receives the name of the subkey, including the * terminating null character. The function copies only the name of the subkey, * not the full key hierarchy, to the buffer. * @param lpcName * Pointer to a variable that specifies the size of the buffer specified by the * lpName parameter, in TCHARs. This size should include the terminating null * character. When the function returns, the variable pointed to by lpcName * contains the number of characters stored in the buffer. The count returned * does not include the terminating null character. * @param reserved * Reserved; must be NULL. * @param lpClass * Pointer to a buffer that receives the null-terminated class string of the * enumerated subkey. This parameter can be NULL. * @param lpcClass * Pointer to a variable that specifies the size of the buffer specified by the * lpClass parameter, in TCHARs. The size should include the terminating null * character. When the function returns, lpcClass contains the number of * characters stored in the buffer. The count returned does not include the * terminating null character. This parameter can be NULL only if lpClass is NULL. * @param lpftLastWriteTime * Pointer to a variable that receives the time at which the enumerated subkey * was last written. * @return * If the function succeeds, the return value is ERROR_SUCCESS. If the function * fails, the return value is a nonzero error code defined in Winerror.h. */ public int RegEnumKeyEx(HKEY hKey, int dwIndex, char[] lpName, IntByReference lpcName, IntByReference reserved, char[] lpClass, IntByReference lpcClass, WinBase.FILETIME lpftLastWriteTime); /** * The RegEnumValue function enumerates the values for the specified open registry * key. The function copies one indexed value name and data block for the key each * time it is called. * @param hKey * Handle to an open key. The key must have been opened with the KEY_QUERY_VALUE * access right. * @param dwIndex * Index of the value to be retrieved. This parameter should be zero for the first * call to the RegEnumValue function and then be incremented for subsequent calls. * Because values are not ordered, any new value will have an arbitrary index. * This means that the function may return values in any order. * @param lpValueName * Pointer to a buffer that receives the name of the value, including the * terminating null character. * @param lpcchValueName * Pointer to a variable that specifies the size of the buffer pointed to by the * lpValueName parameter, in TCHARs. This size should include the terminating null * character. When the function returns, the variable pointed to by lpcValueName * contains the number of characters stored in the buffer. The count returned * does not include the terminating null character. * @param reserved * Reserved; must be NULL. * @param lpType * Pointer to a variable that receives a code indicating the type of data stored * in the specified value. * @param lpData * Pointer to a buffer that receives the data for the value entry. This parameter * can be NULL if the data is not required. * @param lpcbData * Pointer to a variable that specifies the size of the buffer pointed to by the * lpData parameter, in bytes. * @return * If the function succeeds, the return value is ERROR_SUCCESS. If the function * fails, the return value is a nonzero error code defined in Winerror.h. */ public int RegEnumValue(HKEY hKey, int dwIndex, char[] lpValueName, IntByReference lpcchValueName, IntByReference reserved, IntByReference lpType, byte[] lpData, IntByReference lpcbData); /** * The RegQueryInfoKey function retrieves information about the specified * registry key. * @param hKey * A handle to an open key. The key must have been opened with the * KEY_QUERY_VALUE access right. * @param lpClass * A pointer to a buffer that receives the null-terminated class * string of the key. This parameter can be ignored. This parameter can be NULL. * @param lpcClass * A pointer to a variable that specifies the size of the buffer pointed to by * the lpClass parameter, in characters. * @param lpReserved * Reserved; must be NULL. * @param lpcSubKeys * A pointer to a variable that receives the number of subkeys that are contained by the specified key. * This parameter can be NULL. * @param lpcMaxSubKeyLen * A pointer to a variable that receives the size of the key's subkey with the * longest name, in characters, not including the terminating null character. * This parameter can be NULL. * @param lpcMaxClassLen * A pointer to a variable that receives the size of the longest string that * specifies a subkey class, in characters. The count returned does not include * the terminating null character. This parameter can be NULL. * @param lpcValues * A pointer to a variable that receives the number of values that are associated * with the key. This parameter can be NULL. * @param lpcMaxValueNameLen * A pointer to a variable that receives the size of the key's longest value name, * in characters. The size does not include the terminating null character. This * parameter can be NULL. * @param lpcMaxValueLen * A pointer to a variable that receives the size of the longest data component * among the key's values, in bytes. This parameter can be NULL. * @param lpcbSecurityDescriptor * A pointer to a variable that receives the size of the key's security descriptor, * in bytes. This parameter can be NULL. * @param lpftLastWriteTime * A pointer to a FILETIME structure that receives the last write time. * This parameter can be NULL. * @return * If the function succeeds, the return value is ERROR_SUCCESS. If the function * fails, the return value is a nonzero error code defined in Winerror.h. */ public int RegQueryInfoKey(HKEY hKey, char[] lpClass, IntByReference lpcClass, IntByReference lpReserved, IntByReference lpcSubKeys, IntByReference lpcMaxSubKeyLen, IntByReference lpcMaxClassLen, IntByReference lpcValues, IntByReference lpcMaxValueNameLen, IntByReference lpcMaxValueLen, IntByReference lpcbSecurityDescriptor, WinBase.FILETIME lpftLastWriteTime); } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Crypt32Util.java0000644000175000017500000001022111421126016025734 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT; import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB; import com.sun.jna.ptr.PointerByReference; /** * Crypt32 utility API. * @author dblock[at]dblock.org */ public abstract class Crypt32Util { /** * Protect a blob of data. * @param data * Data to protect. * @return * Protected data. */ public static byte[] cryptProtectData(byte[] data) { return cryptProtectData(data, 0); } /** * Protect a blob of data with optional flags. * @param data * Data to protect. * @param flags * Optional flags, eg. CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN. * @return * Protected data. */ public static byte[] cryptProtectData(byte[] data, int flags) { return cryptProtectData(data, null, flags, "", null); } /** * Protect a blob of data. * @param data * Data to protect. * @param entropy * Optional entropy. * @param flags * Optional flags. * @param description * Optional description. * @param prompt * Prompt structure. * @return * Protected bytes. */ public static byte[] cryptProtectData(byte[] data, byte[] entropy, int flags, String description, CRYPTPROTECT_PROMPTSTRUCT prompt) { DATA_BLOB pDataIn = new DATA_BLOB(data); DATA_BLOB pDataProtected = new DATA_BLOB(); DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy); try { if (! Crypt32.INSTANCE.CryptProtectData(pDataIn, description, pEntropy, null, prompt, flags, pDataProtected)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } return pDataProtected.getData(); } finally { if (pDataProtected.pbData != null) { Kernel32.INSTANCE.LocalFree(pDataProtected.pbData); } } } /** * Unprotect a blob of data. * @param data * Data to unprotect. * @return * Unprotected blob of data. */ public static byte[] cryptUnprotectData(byte[] data) { return cryptUnprotectData(data, 0); } /** * Unprotect a blob of data. * @param data * Data to unprotect. * @param flags * Optional flags, eg. CRYPTPROTECT_UI_FORBIDDEN. * @return * Unprotected blob of data. */ public static byte[] cryptUnprotectData(byte[] data, int flags) { return cryptUnprotectData(data, null, flags, null); } /** * Unprotect a blob of data. * @param data * Data to unprotect. * @param entropy * Optional entropy. * @param flags * Optional flags. * @param prompt * Optional prompt structure. * @return * Unprotected blob of data. */ public static byte[] cryptUnprotectData(byte[] data, byte[] entropy, int flags, CRYPTPROTECT_PROMPTSTRUCT prompt) { DATA_BLOB pDataIn = new DATA_BLOB(data); DATA_BLOB pDataUnprotected = new DATA_BLOB(); DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy); PointerByReference pDescription = new PointerByReference(); try { if (! Crypt32.INSTANCE.CryptUnprotectData(pDataIn, pDescription, pEntropy, null, prompt, flags, pDataUnprotected)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } return pDataUnprotected.getData(); } finally { if (pDataUnprotected.pbData != null) { Kernel32.INSTANCE.LocalFree(pDataUnprotected.pbData); } if (pDescription.getValue() != null) { Kernel32.INSTANCE.LocalFree(pDescription.getValue()); } } } }libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/LMJoin.java0000644000175000017500000000214211421126016024763 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.win32.StdCallLibrary; /** * Ported from LMJoin.h. * Windows SDK 6.0A. * @author dblock[at]dblock.org */ public interface LMJoin extends StdCallLibrary { /** * Status of a workstation. */ public abstract class NETSETUP_JOIN_STATUS { public static final int NetSetupUnknownStatus = 0; public static final int NetSetupUnjoined = 1; public static final int NetSetupWorkgroupName = 2; public static final int NetSetupDomainName = 3; }; } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Netapi32Util.java0000644000175000017500000004521711421126016026070 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import java.util.ArrayList; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.DsGetDC.DS_DOMAIN_TRUSTS; import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO; import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS; import com.sun.jna.platform.win32.Guid.GUID; import com.sun.jna.platform.win32.LMAccess.GROUP_USERS_INFO_0; import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_INFO_1; import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_USERS_INFO_0; import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT; import com.sun.jna.platform.win32.WinNT.PSID; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.NativeLongByReference; import com.sun.jna.ptr.PointerByReference; /** * Netapi32 Utility API. * @author dblock[at]dblock.org */ public abstract class Netapi32Util { /** * A group. */ public static class Group { /** * Group name. */ public String name; } /** * A user. */ public static class User { /** * The name of the user account. */ public String name; /** * Contains a comment associated with the user account. */ public String comment; } /** * A local group. */ public static class LocalGroup extends Group { /** * Group comment. */ public String comment; } /** * Returns the name of the primary domain controller (PDC) on the current computer. * @return The name of the primary domain controller. */ public static String getDCName() { return getDCName(null, null); } /** * Returns the name of the primary domain controller (PDC). * @param serverName * Specifies the DNS or NetBIOS name of the remote server on which the function is * to execute. * @param domainName * Specifies the name of the domain. * @return * Name of the primary domain controller. */ public static String getDCName(String serverName, String domainName) { PointerByReference bufptr = new PointerByReference(); try { int rc = Netapi32.INSTANCE.NetGetDCName(domainName, serverName, bufptr); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } return bufptr.getValue().getString(0, true); } finally { if (W32Errors.ERROR_SUCCESS != Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } } } /** * Return the domain/workgroup join status for a computer. * @return Join status. */ public static int getJoinStatus() { return getJoinStatus(null); } /** * Return the domain/workgroup join status for a computer. * @param computerName Computer name. * @return Join status. */ public static int getJoinStatus(String computerName) { PointerByReference lpNameBuffer = new PointerByReference(); IntByReference bufferType = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } return bufferType.getValue(); } finally { if (lpNameBuffer.getPointer() != null) { int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } } } } /** * Get information about a computer. * @param computerName * @return Domain or workgroup name. */ public static String getDomainName(String computerName) { PointerByReference lpNameBuffer = new PointerByReference(); IntByReference bufferType = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } // type of domain: bufferType.getValue() return lpNameBuffer.getValue().getString(0, true); } finally { if (lpNameBuffer.getPointer() != null) { int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } } } } /** * Get the names of local groups on the current computer. * @return An array of local group names. */ public static LocalGroup[] getLocalGroups() { return getLocalGroups(null); } /** * Get the names of local groups on a computer. * @param serverName Name of the computer. * @return An array of local group names. */ public static LocalGroup[] getLocalGroups(String serverName) { PointerByReference bufptr = new PointerByReference(); IntByReference entriesRead = new IntByReference(); IntByReference totalEntries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetLocalGroupEnum(serverName, 1, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null); if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) { throw new Win32Exception(rc); } LMAccess.LOCALGROUP_INFO_1 group = new LMAccess.LOCALGROUP_INFO_1(bufptr.getValue()); LMAccess.LOCALGROUP_INFO_1[] groups = (LOCALGROUP_INFO_1[]) group.toArray(entriesRead.getValue()); ArrayList result = new ArrayList(); for(LOCALGROUP_INFO_1 lgpi : groups) { LocalGroup lgp = new LocalGroup(); lgp.name = lgpi.lgrui1_name.toString(); lgp.comment = lgpi.lgrui1_comment.toString();; result.add(lgp); } return result.toArray(new LocalGroup[0]); } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } } } } /** * Get the names of global groups on a computer. * @return An array of group names. */ public static Group[] getGlobalGroups() { return getGlobalGroups(null); } /** * Get the names of global groups on a computer. * @param serverName Name of the computer. * @return An array of group names. */ public static Group[] getGlobalGroups(String serverName) { PointerByReference bufptr = new PointerByReference(); IntByReference entriesRead = new IntByReference(); IntByReference totalEntries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetGroupEnum(serverName, 1, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null); if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) { throw new Win32Exception(rc); } LMAccess.GROUP_INFO_1 group = new LMAccess.GROUP_INFO_1(bufptr.getValue()); LMAccess.GROUP_INFO_1[] groups = (LMAccess.GROUP_INFO_1[]) group.toArray(entriesRead.getValue()); ArrayList result = new ArrayList(); for(LMAccess.GROUP_INFO_1 lgpi : groups) { LocalGroup lgp = new LocalGroup(); lgp.name = lgpi.grpi1_name.toString(); lgp.comment = lgpi.grpi1_comment.toString();; result.add(lgp); } return result.toArray(new LocalGroup[0]); } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } } } } /** * Get the names of users on a local computer. * @return Users. */ public static User[] getUsers() { return getUsers(null); } /** * Get the names of users on a computer. * @param serverName Name of the computer. * @return An array of users. */ public static User[] getUsers(String serverName) { PointerByReference bufptr = new PointerByReference(); IntByReference entriesRead = new IntByReference(); IntByReference totalEntries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetUserEnum(serverName, 1, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null); if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) { throw new Win32Exception(rc); } LMAccess.USER_INFO_1 user = new LMAccess.USER_INFO_1(bufptr.getValue()); LMAccess.USER_INFO_1[] users = (LMAccess.USER_INFO_1[]) user.toArray(entriesRead.getValue()); ArrayList result = new ArrayList(); for(LMAccess.USER_INFO_1 lu : users) { User auser = new User(); auser.name = lu.usri1_name.toString(); result.add(auser); } return result.toArray(new User[0]); } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } } } } /** * Get local groups of the current user. * @return Local groups. */ public static Group[] getCurrentUserLocalGroups() { return getUserLocalGroups(Secur32Util.getUserNameEx( EXTENDED_NAME_FORMAT.NameSamCompatible)); } /** * Get local groups of a given user. * @param userName User name. * @return Local groups. */ public static Group[] getUserLocalGroups(String userName) { return getUserLocalGroups(userName, null); } /** * Get local groups of a given user on a given system. * @param userName User name. * @param serverName Server name. * @return Local groups. */ public static Group[] getUserLocalGroups(String userName, String serverName) { PointerByReference bufptr = new PointerByReference(); IntByReference entriesread = new IntByReference(); IntByReference totalentries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetUserGetLocalGroups(serverName, userName, 0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries); if (rc != LMErr.NERR_Success) { throw new Win32Exception(rc); } LOCALGROUP_USERS_INFO_0 lgroup = new LOCALGROUP_USERS_INFO_0(bufptr.getValue()); LOCALGROUP_USERS_INFO_0[] lgroups = (LOCALGROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue()); ArrayList result = new ArrayList(); for (LOCALGROUP_USERS_INFO_0 lgpi : lgroups) { LocalGroup lgp = new LocalGroup(); lgp.name = lgpi.lgrui0_name.toString(); result.add(lgp); } return result.toArray(new Group[0]); } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } } } } /** * Get groups of a given user. * @param userName User name. * @return Groups. */ public static Group[] getUserGroups(String userName) { return getUserGroups(userName, null); } /** * Get groups of a given user on a given system. * @param userName User name. * @param serverName Server name. * @return Groups. */ public static Group[] getUserGroups(String userName, String serverName) { PointerByReference bufptr = new PointerByReference(); IntByReference entriesread = new IntByReference(); IntByReference totalentries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetUserGetGroups(serverName, userName, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries); if (rc != LMErr.NERR_Success) { throw new Win32Exception(rc); } GROUP_USERS_INFO_0 lgroup = new GROUP_USERS_INFO_0(bufptr.getValue()); GROUP_USERS_INFO_0[] lgroups = (GROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue()); ArrayList result = new ArrayList(); for (GROUP_USERS_INFO_0 lgpi : lgroups) { Group lgp = new Group(); lgp.name = lgpi.grui0_name.toString(); result.add(lgp); } return result.toArray(new Group[0]); } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } } } } /** * A domain controller. */ public static class DomainController { /** * Specifies the computer name of the discovered domain controller. */ public String name; /** * Specifies the address of the discovered domain controller. */ public String address; /** * Indicates the type of WString that is contained in the * DomainControllerAddress member. */ public int addressType; /** * The GUID of the domain. */ public GUID domainGuid; /** * Pointer to a null-terminated WString that specifies the name of the domain. */ public String domainName; /** * Pointer to a null-terminated WString that specifies the name of the domain at the root * of the DS tree. */ public String dnsForestName; /** * Contains a set of flags that describe the domain controller. */ public int flags; /** * The name of the site that the computer belongs to. */ public String clientSiteName; } /** * Return the domain controller for a current computer. * @return * Domain controller information. */ public static DomainController getDC() { PDOMAIN_CONTROLLER_INFO.ByReference pdci = new PDOMAIN_CONTROLLER_INFO.ByReference(); int rc = Netapi32.INSTANCE.DsGetDcName(null, null, null, null, 0, pdci); if (W32Errors.ERROR_SUCCESS != rc) { throw new Win32Exception(rc); } DomainController dc = new DomainController(); dc.address = pdci.dci.DomainControllerAddress.toString(); dc.addressType = pdci.dci.DomainControllerAddressType; dc.clientSiteName = pdci.dci.ClientSiteName.toString(); dc.dnsForestName = pdci.dci.DnsForestName.toString(); dc.domainGuid = pdci.dci.DomainGuid; dc.domainName = pdci.dci.DomainName.toString(); dc.flags = pdci.dci.Flags; dc.name = pdci.dci.DomainControllerName.toString(); rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.getPointer()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } return dc; } /** * A domain trust relationship. */ public static class DomainTrust { /** * NetBIOS name of the domain. */ public String NetbiosDomainName; /** * DNS name of the domain. */ public String DnsDomainName; /** * Contains the security identifier of the domain represented by this structure. */ public PSID DomainSid; /** * Contains the string representation of the security identifier of the domain * represented by this structure. */ public String DomainSidString; /** * Contains the GUID of the domain represented by this structure. */ public GUID DomainGuid; /** * Contains the string representation of the GUID of the domain represented by * this structure. */ public String DomainGuidString; /** * Contains a set of flags that specify more data about the domain trust. */ private int flags; /** * The domain represented by this structure is a member of the same forest * as the server specified in the ServerName parameter of the * DsEnumerateDomainTrusts function. * @return * True or false. */ public boolean isInForest() { return (flags & DsGetDC.DS_DOMAIN_IN_FOREST) != 0; } /** * The domain represented by this structure is directly trusted by the domain * that the server specified in the ServerName parameter of the * DsEnumerateDomainTrusts function is a member of. * @return * True or false. */ public boolean isOutbound() { return (flags & DsGetDC.DS_DOMAIN_DIRECT_OUTBOUND) != 0; } /** * The domain represented by this structure is the root of a tree and a member * of the same forest as the server specified in the ServerName parameter of the * DsEnumerateDomainTrusts function. * @return * True or false. */ public boolean isRoot() { return (flags & DsGetDC.DS_DOMAIN_TREE_ROOT) != 0; } /** * The domain represented by this structure is the primary domain of the server * specified in the ServerName parameter of the DsEnumerateDomainTrusts function. * @return * True or false. */ public boolean isPrimary() { return (flags & DsGetDC.DS_DOMAIN_PRIMARY) != 0; } /** * The domain represented by this structure is running in the Windows 2000 native mode. * @return * True or false. */ public boolean isNativeMode() { return (flags & DsGetDC.DS_DOMAIN_NATIVE_MODE) != 0; } /** * The domain represented by this structure directly trusts the domain that * the server specified in the ServerName parameter of the DsEnumerateDomainTrusts * function is a member of. * @return * True or false. */ public boolean isInbound() { return (flags & DsGetDC.DS_DOMAIN_DIRECT_INBOUND) != 0; } } /** * Retrieve all domain trusts. * @return * An array of domain trusts. */ public static DomainTrust[] getDomainTrusts() { return getDomainTrusts(null); } /** * Retrieve all domain trusts for a given server. * @param serverName * Server name. * @return * An array of domain trusts. */ public static DomainTrust[] getDomainTrusts(String serverName) { NativeLongByReference domainCount = new NativeLongByReference(); PDS_DOMAIN_TRUSTS.ByReference domains = new PDS_DOMAIN_TRUSTS.ByReference(); int rc = Netapi32.INSTANCE.DsEnumerateDomainTrusts( serverName, new NativeLong(DsGetDC.DS_DOMAIN_VALID_FLAGS), domains, domainCount); if(W32Errors.NO_ERROR != rc) { throw new Win32Exception(rc); } try { int domainCountValue = domainCount.getValue().intValue(); ArrayList trusts = new ArrayList(domainCountValue); for(DS_DOMAIN_TRUSTS trust : domains.getTrusts(domainCountValue)) { DomainTrust t = new DomainTrust(); t.DnsDomainName = trust.DnsDomainName.toString(); t.NetbiosDomainName = trust.NetbiosDomainName.toString(); t.DomainSid = trust.DomainSid; t.DomainSidString = Advapi32Util.convertSidToStringSid(trust.DomainSid); t.DomainGuid = trust.DomainGuid; t.DomainGuidString = Ole32Util.getStringFromGUID(trust.DomainGuid); t.flags = trust.Flags.intValue(); trusts.add(t); } return trusts.toArray(new DomainTrust[0]); } finally { rc = Netapi32.INSTANCE.NetApiBufferFree(domains.getPointer()); if(W32Errors.NO_ERROR != rc) { throw new Win32Exception(rc); } } } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/ShlObj.java0000644000175000017500000001314711421126016025023 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.platform.win32.WinDef.DWORD; import com.sun.jna.win32.StdCallLibrary; /** * Ported from ShlObj.h. * Microsoft Windows SDK 6.0A. * @author dblock[at]dblock.org */ public interface ShlObj extends StdCallLibrary { public static final DWORD SHGFP_TYPE_CURRENT = new DWORD(0); // current value for user, verify it exists public static final DWORD SHGFP_TYPE_DEFAULT = new DWORD(1); // default value, may not exist public static final int CSIDL_DESKTOP = 0x0000; // public static final int CSIDL_INTERNET = 0x0001; // Internet Explorer (icon on desktop) public static final int CSIDL_PROGRAMS = 0x0002; // Start Menu\Programs public static final int CSIDL_CONTROLS = 0x0003; // My Computer\Control Panel public static final int CSIDL_PRINTERS = 0x0004; // My Computer\Printers public static final int CSIDL_PERSONAL = 0x0005; // My Documents public static final int CSIDL_FAVORITES = 0x0006; // \Favorites public static final int CSIDL_STARTUP = 0x0007; // Start Menu\Programs\Startup public static final int CSIDL_RECENT = 0x0008; // \Recent public static final int CSIDL_SENDTO = 0x0009; // \SendTo public static final int CSIDL_BITBUCKET = 0x000a; // \Recycle Bin public static final int CSIDL_STARTMENU = 0x000b; // \Start Menu public static final int CSIDL_MYDOCUMENTS = CSIDL_PERSONAL; // Personal was just a silly name for My Documents public static final int CSIDL_MYMUSIC = 0x000d; // "My Music" folder public static final int CSIDL_MYVIDEO = 0x000e; // "My Videos" folder public static final int CSIDL_DESKTOPDIRECTORY = 0x0010; // \Desktop public static final int CSIDL_DRIVES = 0x0011; // My Computer public static final int CSIDL_NETWORK = 0x0012; // Network Neighborhood (My Network Places) public static final int CSIDL_NETHOOD = 0x0013; // \nethood public static final int CSIDL_FONTS = 0x0014; // windows\fonts public static final int CSIDL_TEMPLATES = 0x0015; public static final int CSIDL_COMMON_STARTMENU = 0x0016; // All Users\Start Menu public static final int CSIDL_COMMON_PROGRAMS = 0X0017; // All Users\Start Menu\Programs public static final int CSIDL_COMMON_STARTUP = 0x0018; // All Users\Startup public static final int CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019; // All Users\Desktop public static final int CSIDL_APPDATA = 0x001a; // \Application Data public static final int CSIDL_PRINTHOOD = 0x001b; // \PrintHood public static final int CSIDL_LOCAL_APPDATA = 0x001c; // \Local Settings\Applicaiton Data (non roaming) public static final int CSIDL_ALTSTARTUP = 0x001d; // non localized startup public static final int CSIDL_COMMON_ALTSTARTUP = 0x001e; // non localized common startup public static final int CSIDL_COMMON_FAVORITES = 0x001f; public static final int CSIDL_INTERNET_CACHE = 0x0020; public static final int CSIDL_COOKIES = 0x0021; public static final int CSIDL_HISTORY = 0x0022; public static final int CSIDL_COMMON_APPDATA = 0x0023; // All Users\Application Data public static final int CSIDL_WINDOWS = 0x0024; // GetWindowsDirectory() public static final int CSIDL_SYSTEM = 0x0025; // GetSystemDirectory() public static final int CSIDL_PROGRAM_FILES = 0x0026; // C:\Program Files public static final int CSIDL_MYPICTURES = 0x0027; // C:\Program Files\My Pictures public static final int CSIDL_PROFILE = 0x0028; // USERPROFILE public static final int CSIDL_SYSTEMX86 = 0x0029; // x86 system directory on RISC public static final int CSIDL_PROGRAM_FILESX86 = 0x002a; // x86 C:\Program Files on RISC public static final int CSIDL_PROGRAM_FILES_COMMON = 0x002b; // C:\Program Files\Common public static final int CSIDL_PROGRAM_FILES_COMMONX86 = 0x002c; // x86 Program Files\Common on RISC public static final int CSIDL_COMMON_TEMPLATES = 0x002d; // All Users\Templates public static final int CSIDL_COMMON_DOCUMENTS = 0x002e; // All Users\Documents public static final int CSIDL_COMMON_ADMINTOOLS = 0x002f; // All Users\Start Menu\Programs\Administrative Tools public static final int CSIDL_ADMINTOOLS = 0x0030; // \Start Menu\Programs\Administrative Tools public static final int CSIDL_CONNECTIONS = 0x0031; // Network and Dial-up Connections public static final int CSIDL_COMMON_MUSIC = 0x0035; // All Users\My Music public static final int CSIDL_COMMON_PICTURES = 0x0036; // All Users\My Pictures public static final int CSIDL_COMMON_VIDEO = 0x0037; // All Users\My Video public static final int CSIDL_RESOURCES = 0x0038; // Resource Direcotry public static final int CSIDL_RESOURCES_LOCALIZED = 0x0039; // Localized Resource Direcotry public static final int CSIDL_COMMON_OEM_LINKS = 0x003a; // Links to All Users OEM specific apps public static final int CSIDL_CDBURN_AREA = 0x003b; // USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning public static final int CSIDL_COMPUTERSNEARME = 0x003d; // Computers Near Me (computered from Workgroup membership) } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java0000644000175000017500000001411611421126022025446 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.WString; import com.sun.jna.ptr.IntByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; /** * Ported from Winspool.h. * Windows SDK 6.0a * @author dblock[at]dblock.org */ public interface Winspool extends StdCallLibrary { Winspool INSTANCE = (Winspool) Native.loadLibrary("Winspool.drv", Winspool.class, W32APIOptions.UNICODE_OPTIONS); /** * The EnumPrinters function enumerates available printers, print servers, domains, or print providers. * @param Flags * The types of print objects that the function should enumerate. * @param Name * If Level is 1, Flags contains PRINTER_ENUM_NAME, and Name is non-NULL, then Name is a pointer * to a null-terminated string that specifies the name of the object to enumerate. This string can * be the name of a server, a domain, or a print provider. * If Level is 1, Flags contains PRINTER_ENUM_NAME, and Name is NULL, then the function enumerates * the available print providers. * If Level is 1, Flags contains PRINTER_ENUM_REMOTE, and Name is NULL, then the function enumerates * the printers in the user's domain. * If Level is 2 or 5,Name is a pointer to a null-terminated string that specifies the name of a * server whose printers are to be enumerated. If this string is NULL, then the function enumerates * the printers installed on the local computer. * If Level is 4, Name should be NULL. The function always queries on the local computer. * When Name is NULL, setting Flags to PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS enumerates * printers that are installed on the local machine. These printers include those that are physically * attached to the local machine as well as remote printers to which it has a network connection. * When Name is not NULL, setting Flags to PRINTER_ENUM_LOCAL | PRINTER_ENUM_NAME enumerates the * local printers that are installed on the server Name. * @param Level * The type of data structures pointed to by pPrinterEnum. Valid values are 1, 2, 4, and 5, which * correspond to the PRINTER_INFO_1, PRINTER_INFO_2 , PRINTER_INFO_4, and PRINTER_INFO_5 data * structures. * @param pPrinterEnum * A pointer to a buffer that receives an array of PRINTER_INFO_1, PRINTER_INFO_2, PRINTER_INFO_4, * or PRINTER_INFO_5 structures. Each structure contains data that describes an available print * object. * If Level is 1, the array contains PRINTER_INFO_1 structures. If Level is 2, the array contains * PRINTER_INFO_2 structures. If Level is 4, the array contains PRINTER_INFO_4 structures. If Level * is 5, the array contains PRINTER_INFO_5 structures. * The buffer must be large enough to receive the array of data structures and any strings or other * data to which the structure members point. If the buffer is too small, the pcbNeeded parameter * returns the required buffer size. * @param cbBuf * The size, in bytes, of the buffer pointed to by pPrinterEnum. * @param pcbNeeded * A pointer to a value that receives the number of bytes copied if the function succeeds or the * number of bytes required if cbBuf is too small. * @param pcReturned * A pointer to a value that receives the number of PRINTER_INFO_1, PRINTER_INFO_2 , PRINTER_INFO_4, * or PRINTER_INFO_5 structures that the function returns in the array to which pPrinterEnum points. * @return * If the function succeeds, the return value is a nonzero value. * If the function fails, the return value is zero. */ boolean EnumPrinters(int Flags, WString Name, int Level, Pointer pPrinterEnum, int cbBuf, IntByReference pcbNeeded, IntByReference pcReturned); public static class PRINTER_INFO_1 extends Structure { public int Flags; public String pDescription; public String pName; public String pComment; public PRINTER_INFO_1() { } public PRINTER_INFO_1(int size) { super(new Memory(size)); } } public static final int PRINTER_ENUM_DEFAULT = 0x00000001; public static final int PRINTER_ENUM_LOCAL = 0x00000002; public static final int PRINTER_ENUM_CONNECTIONS = 0x00000004; public static final int PRINTER_ENUM_FAVORITE = 0x00000004; public static final int PRINTER_ENUM_NAME = 0x00000008; public static final int PRINTER_ENUM_REMOTE = 0x00000010; public static final int PRINTER_ENUM_SHARED = 0x00000020; public static final int PRINTER_ENUM_NETWORK = 0x00000040; public static final int PRINTER_ENUM_EXPAND = 0x00004000; public static final int PRINTER_ENUM_CONTAINER = 0x00008000; public static final int PRINTER_ENUM_ICONMASK = 0x00ff0000; public static final int PRINTER_ENUM_ICON1 = 0x00010000; public static final int PRINTER_ENUM_ICON2 = 0x00020000; public static final int PRINTER_ENUM_ICON3 = 0x00040000; public static final int PRINTER_ENUM_ICON4 = 0x00080000; public static final int PRINTER_ENUM_ICON5 = 0x00100000; public static final int PRINTER_ENUM_ICON6 = 0x00200000; public static final int PRINTER_ENUM_ICON7 = 0x00400000; public static final int PRINTER_ENUM_ICON8 = 0x00800000; public static final int PRINTER_ENUM_HIDE = 0x01000000; } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/NTSecApi.java0000644000175000017500000001460711421126016025252 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Memory; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.Union; import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER; import com.sun.jna.platform.win32.WinNT.PSID; import com.sun.jna.win32.StdCallLibrary; /** * Ported from NTSecApi.h * Windows SDK 6.0A. * @author dblock[at]dblock.org */ public interface NTSecApi extends StdCallLibrary { /** * The LSA_UNICODE_STRING structure is used by various Local Security Authority (LSA) * functions to specify a Unicode string. */ public static class LSA_UNICODE_STRING extends Structure { public static class ByReference extends LSA_UNICODE_STRING implements Structure.ByReference { } /** * Specifies the length, in bytes, of the string pointed to by the Buffer member, * not including the terminating null character, if any. */ public short Length; /** * Specifies the total size, in bytes, of the memory allocated for Buffer. Up to * MaximumLength bytes can be written into the buffer without trampling memory. */ public short MaximumLength; /** * Pointer to a wide character string. Note that the strings returned by the * various LSA functions might not be null terminated. */ public Pointer Buffer; /** * String representation of the buffer. * @return * Unicode string. */ public String getString() { byte[] data = Buffer.getByteArray(0, Length); if (data.length < 2 || data[data.length - 1] != 0) { Memory newdata = new Memory(data.length + 2); newdata.write(0, data, 0, data.length); return newdata.getString(0, true); } return Buffer.getString(0, true); } } /** * Pointer to an LSA_UNICODE_STRING. */ public static class PLSA_UNICODE_STRING { public static class ByReference extends PLSA_UNICODE_STRING implements Structure.ByReference { } public LSA_UNICODE_STRING.ByReference s; } /** * Record contains an included top-level name. */ public static final int ForestTrustTopLevelName = 0; /** * Record contains an excluded top-level name. */ public static final int ForestTrustTopLevelNameEx = 1; /** * Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure. */ public static final int ForestTrustDomainInfo = 2; public static class LSA_FOREST_TRUST_DOMAIN_INFO extends Structure { public PSID.ByReference Sid; public LSA_UNICODE_STRING DnsName; public LSA_UNICODE_STRING NetbiosName; } public static class LSA_FOREST_TRUST_BINARY_DATA extends Structure { public NativeLong Length; public Pointer Buffer; } public static class LSA_FOREST_TRUST_RECORD extends Structure { public static class ByReference extends LSA_FOREST_TRUST_RECORD implements Structure.ByReference { } public static class UNION extends Union { public static class ByReference extends UNION implements Structure.ByReference { } public LSA_UNICODE_STRING TopLevelName; public LSA_FOREST_TRUST_DOMAIN_INFO DomainInfo; public LSA_FOREST_TRUST_BINARY_DATA Data; } /** * Flags that control the behavior of the operation. */ public NativeLong Flags; /** * LSA_FOREST_TRUST_RECORD_TYPE enumeration that indicates the type of the record. * The following table shows the possible values. * ForestTrustTopLevelName * Record contains an included top-level name. * ForestTrustTopLevelNameEx * Record contains an excluded top-level name. * ForestTrustDomainInfo * Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure. * ForestTrustRecordTypeLast * Marks the end of an enumeration. */ public int ForestTrustType; public LARGE_INTEGER Time; /** * Data type depending on ForestTrustType. */ public UNION u; public void read() { super.read(); switch(ForestTrustType) { case NTSecApi.ForestTrustTopLevelName: case NTSecApi.ForestTrustTopLevelNameEx: u.setType(LSA_UNICODE_STRING.class); break; case NTSecApi.ForestTrustDomainInfo: u.setType(LSA_FOREST_TRUST_DOMAIN_INFO.class); break; default: u.setType(LSA_FOREST_TRUST_BINARY_DATA.class); break; } u.read(); } } public static class PLSA_FOREST_TRUST_RECORD extends Structure { public static class ByReference extends PLSA_FOREST_TRUST_RECORD implements Structure.ByReference { } public LSA_FOREST_TRUST_RECORD.ByReference tr; } public static class LSA_FOREST_TRUST_INFORMATION extends Structure { public static class ByReference extends LSA_FOREST_TRUST_INFORMATION implements Structure.ByReference { } /** * Number of LSA_FOREST_TRUST_RECORD structures in the array pointed to by the * Entries member. */ public NativeLong RecordCount; /** * Pointer to a pointer to an array of LSA_FOREST_TRUST_RECORD structures, * each of which contains one piece of forest trust information. */ public PLSA_FOREST_TRUST_RECORD.ByReference Entries; /** * Get an array of LSA_FOREST_TRUST_RECORD entries. * @return * An array of forest trust records. */ public PLSA_FOREST_TRUST_RECORD[] getEntries() { return (PLSA_FOREST_TRUST_RECORD[]) Entries.toArray(RecordCount.intValue()); } } /** * The LSA_FOREST_TRUST_INFORMATION structure contains Local Security Authority * forest trust information. */ public static class PLSA_FOREST_TRUST_INFORMATION extends Structure { public static class ByReference extends PLSA_FOREST_TRUST_INFORMATION implements Structure.ByReference { } public LSA_FOREST_TRUST_INFORMATION.ByReference fti; } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/GDI32.java0000644000175000017500000003627411421126016024420 0ustar janjan/* 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. *

* 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.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); } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java0000644000175000017500000004537211421126020025172 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import java.util.Date; 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.BaseTSD.DWORD_PTR; import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR; import com.sun.jna.platform.win32.WinDef.DWORD; import com.sun.jna.platform.win32.WinDef.DWORDLONG; import com.sun.jna.platform.win32.WinDef.WORD; import com.sun.jna.platform.win32.WinNT.HANDLE; /** * Ported from Winbase.h. * Microsoft Windows SDK 6.0A. * @author dblock[at]dblock.org */ public abstract class WinBase { /** Constant value representing an invalid HANDLE. */ public static HANDLE INVALID_HANDLE_VALUE = new HANDLE(Pointer.createConstant( Pointer.SIZE == 8 ? -1 : 0xFFFFFFFFL)); public static final int WAIT_FAILED = 0xFFFFFFFF; public static final int WAIT_OBJECT_0 = ((NTStatus.STATUS_WAIT_0 ) + 0 ); public static final int WAIT_ABANDONED = ((NTStatus.STATUS_ABANDONED_WAIT_0 ) + 0 ); public static final int WAIT_ABANDONED_0 = ((NTStatus.STATUS_ABANDONED_WAIT_0 ) + 0 ); /** * Maximum computer name length. * @return 15 on MAC, 31 on everything else. */ public static int MAX_COMPUTERNAME_LENGTH() { if (Platform.isMac()) { return 15; } else { return 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. */ public static final 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. */ public static final 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. */ public static final int LOGON32_LOGON_BATCH = 4; /** * Indicates a service-type logon. The account provided must have the service privilege enabled. */ public static final 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. */ public static final 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. */ public static final 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. */ public static final 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. */ public static final int LOGON32_PROVIDER_DEFAULT = 0; /** * Use the Windows NT 3.5 logon provider. */ public static final int LOGON32_PROVIDER_WINNT35 = 1; /** * Use the NTLM logon provider. */ public static final int LOGON32_PROVIDER_WINNT40 = 2; /** * Use the negotiate logon provider. */ public static final int LOGON32_PROVIDER_WINNT50 = 3; /** * The FILETIME structure is a 64-bit value representing the number of * 100-nanosecond intervals since January 1, 1601 (UTC). * Conversion code in this class Copyright 2002-2004 Apache Software Foundation. * @author Rainer Klute (klute@rainer-klute.de) for the Apache Software Foundation (org.apache.poi.hpsf) */ public static class FILETIME extends Structure { public int dwLowDateTime; public int dwHighDateTime; /** *

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

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

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

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

Converts a {@link Date} into a filetime.

* * @param date The date to be converted * @return The filetime * * @see #filetimeToDate */ public static long dateToFileTime(final Date date) { final long ms_since_19700101 = date.getTime(); final long ms_since_16010101 = ms_since_19700101 + EPOCH_DIFF; return ms_since_16010101 * 1000 * 10; } public Date toDate() { return filetimeToDate(dwHighDateTime, dwLowDateTime); } public long toLong() { return toDate().getTime(); } public String toString() { return super.toString() + ": " + toDate().toString(); //$NON-NLS-1$ } } /* Local Memory Flags */ public static final int LMEM_FIXED = 0x0000; public static final int LMEM_MOVEABLE = 0x0002; public static final int LMEM_NOCOMPACT = 0x0010; public static final int LMEM_NODISCARD = 0x0020; public static final int LMEM_ZEROINIT = 0x0040; public static final int LMEM_MODIFY = 0x0080; public static final int LMEM_DISCARDABLE = 0x0F00; public static final int LMEM_VALID_FLAGS = 0x0F72; public static final int LMEM_INVALID_HANDLE = 0x8000; public static final int LHND = (LMEM_MOVEABLE | LMEM_ZEROINIT); public static final int LPTR = (LMEM_FIXED | LMEM_ZEROINIT); /* Flags returned by LocalFlags (in addition to LMEM_DISCARDABLE) */ public static final int LMEM_DISCARDED = 0x4000; public static final 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; } /** * 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. */ public static final 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. */ public static final 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. */ public static final 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. */ public static final 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. */ public static final 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. */ public static final int FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000; /** * The drive type cannot be determined. */ public static final int DRIVE_UNKNOWN = 0; /** * The root path is invalid, for example, no volume is mounted at the path. */ public static final int DRIVE_NO_ROOT_DIR = 1; /** * The drive is a type that has removable media, for example, a floppy drive * or removable hard disk. */ public static final int DRIVE_REMOVABLE = 2; /** * The drive is a type that cannot be removed, for example, a fixed hard drive. */ public static final int DRIVE_FIXED = 3; /** * The drive is a remote (network) drive. */ public static final int DRIVE_REMOTE = 4; /** * The drive is a CD-ROM drive. */ public static final int DRIVE_CDROM = 5; /** * The drive is a RAM disk. */ public static final 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; } public static final 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 { 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; } 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. */ public PI.ByReference pi; } /** * Processor architecture. */ public UNION.ByReference 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; } /** * 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; public MEMORYSTATUSEX() { dwLength = new DWORD(size()); } }; } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/DsGetDC.java0000644000175000017500000001731211421126016025055 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.WString; import com.sun.jna.platform.win32.Guid.GUID; import com.sun.jna.platform.win32.WinNT.PSID; import com.sun.jna.win32.StdCallLibrary; /** * Ported from DsGetDC.h. * Windows SDK 6.0a * @author dblock[at]dblock.org */ public interface DsGetDC extends StdCallLibrary { /** * The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName * function to receive data about a domain controller. */ public static class DOMAIN_CONTROLLER_INFO extends Structure { public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference { } public DOMAIN_CONTROLLER_INFO() { } public DOMAIN_CONTROLLER_INFO(Pointer memory) { useMemory(memory); read(); } /** * Pointer to a null-terminated WString that specifies the computer name * of the discovered domain controller. The returned computer name is * prefixed with "\\". The DNS-style name, for example, "\\phoenix.fabrikam.com", * is returned, if available. If the DNS-style name is not available, the * flat-style name (for example, "\\phoenix") is returned. This example would apply * if the domain is a Windows NT 4.0 domain or if the domain does not support the * IP family of protocols. */ public WString DomainControllerName; /** * Pointer to a null-terminated WString that specifies the address of the discovered * domain controller. The address is prefixed with "\\". This WString is one of the * types defined by the DomainControllerAddressType member. */ public WString DomainControllerAddress; /** * Indicates the type of WString that is contained in the DomainControllerAddress member. */ public int DomainControllerAddressType; /** * The GUID of the domain. This member is zero if the domain controller does not have * a Domain GUID; for example, the domain controller is not a Windows 2000 domain * controller. */ public GUID DomainGuid; /** * Pointer to a null-terminated WString that specifies the name of the domain. The * DNS-style name, for example, "fabrikam.com", is returned if available. Otherwise, * the flat-style name, for example, "fabrikam", is returned. This name may be different * than the requested domain name if the domain has been renamed. */ public WString DomainName; /** * Pointer to a null-terminated WString that specifies the name of the domain at the root * of the DS tree. The DNS-style name, for example, "fabrikam.com", is returned if * available. Otherwise, the flat-style name, for example, "fabrikam" is returned. */ public WString DnsForestName; /** * Contains a set of flags that describe the domain controller. */ public int Flags; /** * Pointer to a null-terminated WString that specifies the name of the site where the * domain controller is located. This member may be NULL if the domain controller is * not in a site; for example, the domain controller is a Windows NT 4.0 domain * controller. */ public WString DcSiteName; /** * Pointer to a null-terminated WString that specifies the name of the site that the * computer belongs to. The computer is specified in the ComputerName parameter passed * to DsGetDcName. This member may be NULL if the site that contains the computer * cannot be found; for example, if the DS administrator has not associated the * subnet that the computer is in with a valid site. */ public WString ClientSiteName; } /** * Pointer to DOMAIN_CONTROLLER_INFO. */ public static class PDOMAIN_CONTROLLER_INFO extends Structure { public static class ByReference extends PDOMAIN_CONTROLLER_INFO implements Structure.ByReference { } public DOMAIN_CONTROLLER_INFO.ByReference dci; } /** * Domain is a member of the forest. */ public static final int DS_DOMAIN_IN_FOREST = 0x0001; /** * Domain is directly trusted. */ public static final int DS_DOMAIN_DIRECT_OUTBOUND = 0x0002; /** * Domain is root of a tree in the forest. */ public static final int DS_DOMAIN_TREE_ROOT = 0x0004; /** * Domain is the primary domain of queried server. */ public static final int DS_DOMAIN_PRIMARY = 0x0008; /** * Primary domain is running in native mode. */ public static final int DS_DOMAIN_NATIVE_MODE = 0x0010; /** * Domain is directly trusting. */ public static final int DS_DOMAIN_DIRECT_INBOUND = 0x0020; /** * Valid domain flags. */ public static final int DS_DOMAIN_VALID_FLAGS = DS_DOMAIN_IN_FOREST | DS_DOMAIN_DIRECT_OUTBOUND | DS_DOMAIN_TREE_ROOT | DS_DOMAIN_PRIMARY | DS_DOMAIN_NATIVE_MODE | DS_DOMAIN_DIRECT_INBOUND; /** * The DS_DOMAIN_TRUSTS structure is used with the DsEnumerateDomainTrusts function to * contain trust data for a domain. */ public static class DS_DOMAIN_TRUSTS extends Structure { public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference { } /** * Pointer to a null-terminated string that contains the NetBIOS name of the domain. */ public WString NetbiosDomainName; /** * Pointer to a null-terminated string that contains the DNS name of the domain. This member may be NULL. */ public WString DnsDomainName; /** * Contains a set of flags that specify more data about the domain trust. */ public NativeLong Flags; /** * Contains the index in the Domains array returned by the DsEnumerateDomainTrusts function that * corresponds to the parent domain of the domain represented by this structure. */ public NativeLong ParentIndex; /** * Contains a value that indicates the type of trust represented by this structure. */ public NativeLong TrustType; /** * Contains a value that indicates the attributes of the trust represented by this structure. */ public NativeLong TrustAttributes; /** * Contains the security identifier of the domain represented by this structure. */ public PSID.ByReference DomainSid; /** * Contains the GUID of the domain represented by this structure. */ public GUID DomainGuid; }; /** * A pointer to an array of DS_DOMAIN_TRUSTS. */ public static class PDS_DOMAIN_TRUSTS extends Structure { public static class ByReference extends PDS_DOMAIN_TRUSTS implements Structure.ByReference { } public DS_DOMAIN_TRUSTS.ByReference t; /** * Returns domain trusts. * @param count * Number of domain trusts. * @return * An array of domain trusts. */ public DS_DOMAIN_TRUSTS[] getTrusts(int count) { return (DS_DOMAIN_TRUSTS[]) t.toArray(count); } } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Netapi32.java0000644000175000017500000005020311421126016025221 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Native; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO; import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS; import com.sun.jna.platform.win32.Guid.GUID; import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.NativeLongByReference; import com.sun.jna.ptr.PointerByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; /** * Netapi32.dll Interface. * @author dblock[at]dblock.org */ public interface Netapi32 extends StdCallLibrary { Netapi32 INSTANCE = (Netapi32) Native.loadLibrary("Netapi32", Netapi32.class, W32APIOptions.UNICODE_OPTIONS); /** * Retrieves join status information for the specified computer. * * @param lpServer * Specifies the DNS or NetBIOS name of the computer on which to * call the function. * @param lpNameBuffer * Receives the NetBIOS name of the domain or workgroup to which * the computer is joined. * @param BufferType * Join status of the specified computer. * @return If the function succeeds, the return value is NERR_Success. If * the function fails, the return value is a system error code. */ public int NetGetJoinInformation(String lpServer, PointerByReference lpNameBuffer, IntByReference BufferType); /** * Frees the memory that the NetApiBufferAllocate function allocates. * * @param buffer * @return If the function succeeds, the return value is NERR_Success. If * the function fails, the return value is a system error code. */ public int NetApiBufferFree(Pointer buffer); /** * Returns information about each local group account on the specified * server. * * @param serverName * Specifies the DNS or NetBIOS name of the remote server on * which the function is to execute. If this parameter is NULL, * the local computer is used. * @param level * Specifies the information level of the data. * @param bufptr * Pointer to the address of the buffer that receives the * information structure. * @param prefmaxlen * Specifies the preferred maximum length of returned data, in * bytes. * @param entriesread * Pointer to a value that receives the count of elements * actually enumerated. * @param totalentries * Pointer to a value that receives the approximate total number * of entries that could have been enumerated from the current * resume position. * @param resume_handle * Pointer to a value that contains a resume handle that is used * to continue an existing local group search. * @return If the function succeeds, the return value is NERR_Success. */ public int NetLocalGroupEnum(String serverName, int level, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries, IntByReference resume_handle); /** * Returns the name of the primary domain controller (PDC). * * @param serverName * Specifies the DNS or NetBIOS name of the remote server on which the function is * to execute. If this parameter is NULL, the local computer is used. * @param domainName * Specifies the name of the domain. * @param bufptr * Receives a string that specifies the server name of the PDC of the domain. * @return * If the function succeeds, the return value is NERR_Success. */ public int NetGetDCName(String serverName, String domainName, PointerByReference bufptr); /** * The NetGroupEnum function retrieves information about each global group * in the security database, which is the security accounts manager (SAM) database or, * in the case of domain controllers, the Active Directory. * @param servername * Pointer to a constant string that specifies the DNS or NetBIOS name of the * remote server on which the function is to execute. If this parameter is NULL, * the local computer is used. * @param level * Specifies the information level of the data. * @param bufptr * Pointer to the buffer to receive the global group information structure. * The format of this data depends on the value of the level parameter. * @param prefmaxlen * Specifies the preferred maximum length of the returned data, in bytes. * If you specify MAX_PREFERRED_LENGTH, the function allocates the amount of * memory required to hold the data. If you specify another value in this * parameter, it can restrict the number of bytes that the function returns. * If the buffer size is insufficient to hold all entries, the function * returns ERROR_MORE_DATA. * @param entriesread * Pointer to a value that receives the count of elements actually enumerated. * @param totalentries * Pointer to a value that receives the total number of entries that could have * been enumerated from the current resume position. The total number of entries * is only a hint. * @param resume_handle * Pointer to a variable that contains a resume handle that is used to continue * the global group enumeration. The handle should be zero on the first call and * left unchanged for subsequent calls. If resume_handle is NULL, no resume handle * is stored. * @return * If the function succeeds, the return value is NERR_Success. */ public int NetGroupEnum(String servername, int level, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries, IntByReference resume_handle); /** * The NetUserEnum function provides information about all user accounts on a server. * @param servername * Pointer to a constant string that specifies the DNS or NetBIOS name of the * remote server on which the function is to execute. If this parameter is NULL, * the local computer is used. * @param level * Specifies the information level of the data. * @param filter * Specifies a value that filters the account types for enumeration. * @param bufptr * Pointer to the buffer that receives the data. The format of this data depends * on the value of the level parameter. This buffer is allocated by the system and * must be freed using the NetApiBufferFree function. Note that you must free the * buffer even if the function fails with ERROR_MORE_DATA. * @param prefmaxlen * Specifies the preferred maximum length, in 8-bit bytes of returned data. If you * specify MAX_PREFERRED_LENGTH, the function allocates the amount of memory * required for the data. If you specify another value in this parameter, it can * restrict the number of bytes that the function returns. If the buffer size is * insufficient to hold all entries, the function returns ERROR_MORE_DATA. * @param entriesread * Pointer to a value that receives the count of elements actually enumerated. * @param totalentries * Pointer to a value that receives the total number of entries that could have * been enumerated from the current resume position. Note that applications should * consider this value only as a hint. * @param resume_handle * Pointer to a value that contains a resume handle which is used to continue an * existing user search. The handle should be zero on the first call and left * unchanged for subsequent calls. If resume_handle is NULL, then no resume * handle is stored. * @return * If the function succeeds, the return value is NERR_Success. */ public int NetUserEnum(String servername, int level, int filter, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries, IntByReference resume_handle); /** * The NetUserGetGroups function retrieves a list of global groups to which a * specified user belongs. * @param servername * Pointer to a constant string that specifies the DNS or NetBIOS name of the * remote server on which the function is to execute. If this parameter is NULL, * the local computer is used. * @param username * Pointer to a constant string that specifies the name of the user to search for * in each group account. For more information, see the following Remarks section. * @param level * Specifies the information level of the data. * @param bufptr * Pointer to the buffer that receives the data. This buffer is allocated by the * system and must be freed using the NetApiBufferFree function. Note that you must * free the buffer even if the function fails with ERROR_MORE_DATA. * @param prefmaxlen * Specifies the preferred maximum length of returned data, in bytes. If you specify * MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the * data. If you specify another value in this parameter, it can restrict the number * of bytes that the function returns. If the buffer size is insufficient to hold * all entries, the function returns ERROR_MORE_DATA. * @param entriesread * Pointer to a value that receives the count of elements actually retrieved. * @param totalentries * Pointer to a value that receives the total number of entries that could have been retrieved. * @return * If the function succeeds, the return value is NERR_Success. */ public int NetUserGetGroups(String servername, String username, int level, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries); /** * The NetUserGetLocalGroups function retrieves a list of local groups to which a * specified user belongs. * @param servername * Pointer to a constant string that specifies the DNS or NetBIOS name of the remote * server on which the function is to execute. If this parameter is NULL, the local * computer is used. * @param username * Pointer to a constant string that specifies the name of the user for which to return * local group membership information. If the string is of the form DomainName\UserName * the user name is expected to be found on that domain. If the string is of the form * UserName, the user name is expected to be found on the server specified by the * servername parameter. * @param level * Specifies the information level of the data. * @param flags * Specifies a bitmask of flags. Currently, only the value LG_INCLUDE_INDIRECT is * defined. If this bit is set, the function also returns the names of the local * groups in which the user is indirectly a member (that is, the user has membership * in a global group that is itself a member of one or more local groups). * @param bufptr * Pointer to the buffer that receives the data. The format of this data depends on * the value of the level parameter. This buffer is allocated by the system and must * be freed using the NetApiBufferFree function. Note that you must free the buffer * even if the function fails with ERROR_MORE_DATA. * @param prefmaxlen * Specifies the preferred maximum length of returned data, in bytes. If you specify * MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the * data. If you specify another value in this parameter, it can restrict the number of * bytes that the function returns. If the buffer size is insufficient to hold all * entries, the function returns ERROR_MORE_DATA. For more information, see Network * Management Function Buffers and Network Management Function Buffer Lengths. * @param entriesread * Pointer to a value that receives the count of elements actually enumerated. * @param totalentries * Pointer to a value that receives the total number of entries that could have been enumerated. * @return * If the function succeeds, the return value is NERR_Success. */ public int NetUserGetLocalGroups(String servername, String username, int level, int flags, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries); /** * The NetUserAdd function adds a user account and assigns a password and privilege level. * @param servername * Pointer to a constant string that specifies the DNS or NetBIOS name of the remote server * on which the function is to execute. * @param level * Specifies the information level of the data. * @param buf * Pointer to the buffer that specifies the data. The format of this data depends on the * value of the level parameter. * @param parm_err * Pointer to a value that receives the index of the first member of the user information * structure that causes ERROR_INVALID_PARAMETER. If this parameter is NULL, the index is * not returned on error. * @return * If the function succeeds, the return value is NERR_Success. */ public int NetUserAdd(String servername, int level, Structure buf, IntByReference parm_err); /** * The NetUserDel function deletes a user account from a server. * @param servername * Pointer to a constant string that specifies the DNS or NetBIOS name of the remote * server on which the function is to execute. If this parameter is NULL, the local * computer is used. * @param username * Pointer to a constant string that specifies the name of the user account to delete. * @return * If the function succeeds, the return value is NERR_Success. */ public int NetUserDel(String servername, String username); /** * The NetUserChangePassword function changes a user's password for a specified * network server or domain. * @param domainname * Pointer to a constant string that specifies the DNS or NetBIOS name of a remote * server or domain on which the function is to execute. If this parameter is NULL, * the logon domain of the caller is used. * @param username * Pointer to a constant string that specifies a user name. The NetUserChangePassword * function changes the password for the specified user. If this parameter is NULL, * the logon name of the caller is used. * @param oldpassword * Pointer to a constant string that specifies the user's old password. * @param newpassword * Pointer to a constant string that specifies the user's new password. * @return * If the function succeeds, the return value is NERR_Success. */ public int NetUserChangePassword(String domainname, String username, String oldpassword, String newpassword); /** * The DsGetDcName function returns the name of a domain controller in a specified domain. * This function accepts additional domain controller selection criteria to indicate * preference for a domain controller with particular characteristics. * @param ComputerName * Pointer to a null-terminated string that specifies the name of the server to process * this function. Typically, this parameter is NULL, which indicates that the local * computer is used. * @param DomainName * Pointer to a null-terminated string that specifies the name of the domain or application * partition to query. This name can either be a DNS style name, for example, fabrikam.com, * or a flat-style name, for example, Fabrikam. If a DNS style name is specified, the name * may be specified with or without a trailing period. * @param DomainGuid * Pointer to a GUID structure that specifies the GUID of the domain queried. If DomainGuid * is not NULL and the domain specified by DomainName or ComputerName cannot be found, * DsGetDcName attempts to locate a domain controller in the domain having the GUID specified * by DomainGuid. * @param SiteName * Pointer to a null-terminated string that specifies the name of the site where the returned * domain controller should physically exist. If this parameter is NULL, DsGetDcName attempts * to return a domain controller in the site closest to the site of the computer specified by * ComputerName. This parameter should be NULL, by default. * @param Flags * Contains a set of flags that provide additional data used to process the request. * @param DomainControllerInfo * Pointer to a PDOMAIN_CONTROLLER_INFO value that receives a pointer to a * DOMAIN_CONTROLLER_INFO structure that contains data about the domain controller selected. * This structure is allocated by DsGetDcName. The caller must free the structure using * the NetApiBufferFree function when it is no longer required. * @return * If the function returns domain controller data, the return value is ERROR_SUCCESS. * If the function fails, the return code is one of ERROR_* values. */ public int DsGetDcName(String ComputerName, String DomainName, GUID DomainGuid, String SiteName, int Flags, PDOMAIN_CONTROLLER_INFO.ByReference DomainControllerInfo); /** * The DsGetForestTrustInformationW function obtains forest trust data for a specified domain. * @param serverName * Contains the name of the domain controller that DsGetForestTrustInformationW * is connected to remotely. The caller must be an authenticated user on this server. * If this parameter is NULL, the local server is used. * @param trustedDomainName * Contains the NETBIOS or DNS name of the trusted domain that the forest trust data * is to be retrieved for. This domain must have the TRUST_ATTRIBUTE_FOREST_TRANSITIVE * trust attribute. If this parameter is NULL, the forest trust data for the domain * hosted by ServerName is retrieved. * @param Flags * Contains a set of flags that modify the behavior of this function. * DS_GFTI_UPDATE_TDO: If this flag is set, DsGetForestTrustInformationW will update the * forest trust data of the trusted domain identified by the TrustedDomainName parameter. * @param ForestTrustInfo * Pointer to an LSA_FOREST_TRUST_INFORMATION structure pointer that receives the forest * trust data that describes the namespaces claimed by the domain specified by * TrustedDomainName. The Time member of all returned records will be zero. * @return * Returns NO_ERROR if successful or a Win32 error code otherwise. */ public int DsGetForestTrustInformation(String serverName, String trustedDomainName, int Flags, PLSA_FOREST_TRUST_INFORMATION.ByReference ForestTrustInfo); /** * The DsEnumerateDomainTrusts function obtains domain trust data for a specified domain. * @param serverName * Pointer to a null-terminated string that specifies the name of a computer in the domain to * obtain the trust information for. This computer must be running the Windows 2000 or later * operating system. If this parameter is NULL, the name of the local computer is used. * The caller must be an authenticated user in this domain. * @param Flags * Contains a set of flags that determines which domain trusts to enumerate. * @param Domains * Pointer to a PDS_DOMAIN_TRUSTS value that receives an array of DS_DOMAIN_TRUSTS structures. * Each structure in this array contains trust data about a domain. The caller must free this * memory when it is no longer required by calling NetApiBufferFree. * @param DomainCount * Pointer to a ULONG value that receives the number of elements returned in the Domains array. * @return * Returns ERROR_SUCCESS if successful or a Win32 error code otherwise. */ public int DsEnumerateDomainTrusts(String serverName, NativeLong Flags, PDS_DOMAIN_TRUSTS.ByReference Domains, NativeLongByReference DomainCount); } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java0000644000175000017500000001130311421126020025404 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.win32.StdCallLibrary; /** * Ported from WinCrypt.h. * Microsoft Windows SDK 6.0A. * @author dblock[at]dblock.org */ public interface WinCrypt extends StdCallLibrary { /** * The CryptoAPI CRYPTOAPI_BLOB structure is used for an arbitrary array of bytes. */ public static class DATA_BLOB extends Structure { public DATA_BLOB() { super(); } public DATA_BLOB(Pointer memory) { useMemory(memory); read(); } public DATA_BLOB(byte [] data) { pbData = new Memory(data.length); pbData.write(0, data, 0, data.length); cbData = data.length; allocateMemory(); } public DATA_BLOB(String s) { this(Native.toByteArray(s)); } /** * The count of bytes in the buffer pointed to by pbData. */ public int cbData; /** * A pointer to a block of data bytes. */ public Pointer pbData; /** * Get byte data. * @return * Byte data or null. */ public byte[] getData() { return pbData == null ? null : pbData.getByteArray(0, cbData); } } /** * The CRYPTPROTECT_PROMPTSTRUCT structure provides the text of a prompt and * information about when and where that prompt is to be displayed when using * the CryptProtectData and CryptUnprotectData functions. */ public static class CRYPTPROTECT_PROMPTSTRUCT extends Structure { public CRYPTPROTECT_PROMPTSTRUCT() { super(); } public CRYPTPROTECT_PROMPTSTRUCT(Pointer memory) { useMemory(memory); read(); } /** * Size of this structure in bytes. */ public int cbSize; /** * DWORD flags that indicate when prompts to the user are to be displayed. */ public int dwPromptFlags; /** * Window handle to the parent window. */ public HWND hwndApp; /** * A string containing the text of a prompt to be displayed. */ public String szPrompt; } // // CryptProtect PromptStruct dwPromtFlags // /** * Prompt on unprotect. */ public static final int CRYPTPROTECT_PROMPT_ON_UNPROTECT = 0x1; // 1<<0 /** * Prompt on protect. */ public static final int CRYPTPROTECT_PROMPT_ON_PROTECT = 0x2; // 1<<1 /** * Reserved, don't use. */ public static final int CRYPTPROTECT_PROMPT_RESERVED = 0x04; /** * Default to strong variant UI protection (user supplied password currently). */ public static final int CRYPTPROTECT_PROMPT_STRONG = 0x08; // 1<<3 /** * Require strong variant UI protection (user supplied password currently). */ public static final int CRYPTPROTECT_PROMPT_REQUIRE_STRONG = 0x10; // 1<<4 // // CryptProtectData and CryptUnprotectData dwFlags // /** * For remote-access situations where ui is not an option, if UI was specified * on protect or unprotect operation, the call will fail and GetLastError() will * indicate ERROR_PASSWORD_RESTRICTION. */ public static final int CRYPTPROTECT_UI_FORBIDDEN = 0x1; /** * Per machine protected data -- any user on machine where CryptProtectData * took place may CryptUnprotectData. */ public static final int CRYPTPROTECT_LOCAL_MACHINE = 0x4; /** * Force credential synchronize during CryptProtectData() * Synchronize is only operation that occurs during this operation. */ public static final int CRYPTPROTECT_CRED_SYNC = 0x8; /** * Generate an Audit on protect and unprotect operations. */ public static final int CRYPTPROTECT_AUDIT = 0x10; /** * Protect data with a non-recoverable key. */ public static final int CRYPTPROTECT_NO_RECOVERY = 0x20; /** * Verify the protection of a protected blob. */ public static final int CRYPTPROTECT_VERIFY_PROTECTION = 0x40; /** * Regenerate the local machine protection. */ public static final int CRYPTPROTECT_CRED_REGENERATE = 0x80; } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Secur32.java0000644000175000017500000004014011421126016025061 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Native; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.Sspi.CredHandle; import com.sun.jna.platform.win32.Sspi.CtxtHandle; import com.sun.jna.platform.win32.Sspi.PSecPkgInfo; import com.sun.jna.platform.win32.Sspi.SecBufferDesc; import com.sun.jna.platform.win32.Sspi.TimeStamp; import com.sun.jna.platform.win32.WinNT.HANDLEByReference; import com.sun.jna.platform.win32.WinNT.LUID; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.NativeLongByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; /** * Secur32.dll Interface. * @author dblock[at]dblock.org */ public interface Secur32 extends StdCallLibrary { Secur32 INSTANCE = (Secur32) Native.loadLibrary( "Secur32", Secur32.class, W32APIOptions.UNICODE_OPTIONS); /** * Specifies a format for a directory service object name. * http://msdn.microsoft.com/en-us/library/ms724268(VS.85).aspx */ public abstract class EXTENDED_NAME_FORMAT { public static final int NameUnknown = 0; public static final int NameFullyQualifiedDN = 1; public static final int NameSamCompatible = 2; public static final int NameDisplay = 3; public static final int NameUniqueId = 6; public static final int NameCanonical = 7; public static final int NameUserPrincipal = 8; public static final int NameCanonicalEx = 9; public static final int NameServicePrincipal = 10; public static final int NameDnsDomain = 12; }; /** * Retrieves the name of the user or other security principal associated with * the calling thread. You can specify the format of the returned name. * @param nameFormat The format of the name. * @param lpNameBuffer A pointer to a buffer that receives the name in the specified format. * @param len On input, the size of the buffer, on output the number of characters copied into the buffer, not including the terminating null character. * @return True if the function succeeds. False otherwise. */ public boolean GetUserNameEx(int nameFormat, char[] lpNameBuffer, IntByReference len); /** * The AcquireCredentialsHandle function acquires a handle to preexisting credentials * of a security principal. This handle is required by the AcceptSecurityContext * and InitializeSecurityContext functions. These can be either preexisting credentials, * which are established through a system logon that is not described here, or the * caller can provide alternative credentials. * @param pszPrincipal * A pointer to a null-terminated string that specifies the name of the principal whose * credentials the handle will reference. * @param pszPackage * A pointer to a null-terminated string that specifies the name of the security package * with which these credentials will be used. * @param fCredentialUse * A flag that indicates how these credentials will be used. * @param pvLogonID * A pointer to a locally unique identifier (LUID) that identifies the user. * @param pAuthData * A pointer to package-specific data. This parameter can be NULL, which indicates * that the default credentials for that package must be used. To use supplied * credentials, pass a SEC_WINNT_AUTH_IDENTITY structure that includes those credentials * in this parameter. * @param pGetKeyFn * This parameter is not used and should be set to NULL. * @param pvGetKeyArgument * This parameter is not used and should be set to NULL. * @param phCredential * A pointer to a CredHandle structure to receive the credential handle. * @param ptsExpiry * A pointer to a TimeStamp structure that receives the time at which the returned * credentials expire. The value returned in this TimeStamp structure depends on * the security package. The security package must return this value in local time. * @return * If the function succeeds, the function returns one of the SEC_I_ success codes. * If the function fails, the function returns one of the SEC_E_ error codes. */ public int AcquireCredentialsHandle(String pszPrincipal, String pszPackage, NativeLong fCredentialUse, LUID pvLogonID, Pointer pAuthData, Pointer pGetKeyFn, // TODO: SEC_GET_KEY_FN Pointer pvGetKeyArgument, CredHandle phCredential, TimeStamp ptsExpiry); /** * The InitializeSecurityContext function initiates the client side, outbound security * context from a credential handle. The function is used to build a security context * between the client application and a remote peer. InitializeSecurityContext returns * a token that the client must pass to the remote peer, which the peer in turn submits * to the local security implementation through the AcceptSecurityContext call. The * token generated should be considered opaque by all callers. * * Typically, the InitializeSecurityContext function is called in a loop until a * sufficient security context is established. * * @param phCredential * A handle to the credentials returned by AcquireCredentialsHandle. This handle is * used to build the security context. The InitializeSecurityContext function requires * at least OUTBOUND credentials. * @param phContext * A pointer to a CtxtHandle structure. On the first call to InitializeSecurityContext, * this pointer is NULL. On the second call, this parameter is a pointer to the handle * to the partially formed context returned in the phNewContext parameter by the first * call. * @param pszTargetName * A pointer to a null-terminated string that indicates the target of the context. * The string contents are security-package specific. * @param fContextReq * Bit flags that indicate requests for the context. Not all packages can support all * requirements. Flags used for this parameter are prefixed with ISC_REQ_, for example, * ISC_REQ_DELEGATE. * @param Reserved1 * This parameter is reserved and must be set to zero. * @param TargetDataRep * The data representation, such as byte ordering, on the target. This parameter can be * either SECURITY_NATIVE_DREP or SECURITY_NETWORK_DREP. * @param pInput * A pointer to a SecBufferDesc structure that contains pointers to the buffers supplied * as input to the package. The pointer must be NULL on the first call to the function. * On subsequent calls to the function, it is a pointer to a buffer allocated with enough * memory to hold the token returned by the remote peer. * @param Reserved2 * This parameter is reserved and must be set to zero. * @param phNewContext * A pointer to a CtxtHandle structure. On the first call to InitializeSecurityContext, * this pointer receives the new context handle. On the second call, phNewContext can be * the same as the handle specified in the phContext parameter. * @param pOutput * A pointer to a SecBufferDesc structure that contains pointers to the SecBuffer structure * that receives the output data. If a buffer was typed as SEC_READWRITE in the input, it * will be there on output. The system will allocate a buffer for the security token if * requested (through ISC_REQ_ALLOCATE_MEMORY) and fill in the address in the buffer * descriptor for the security token. * @param pfContextAttr * A pointer to a variable to receive a set of bit flags that indicate the attributes of * the established context. Flags used for this parameter are prefixed with ISC_RET, * such as ISC_RET_DELEGATE. * @param ptsExpiry * A pointer to a TimeStamp structure that receives the expiration time of the context. * It is recommended that the security package always return this value in local time. * This parameter is optional and NULL should be passed for short-lived clients. * @return * If the function succeeds, the function returns one of the SEC_I_ success codes. * If the function fails, the function returns one of the SEC_E_ error codes. */ public int InitializeSecurityContext(CredHandle phCredential, CtxtHandle phContext, String pszTargetName, NativeLong fContextReq, NativeLong Reserved1, NativeLong TargetDataRep, SecBufferDesc pInput, NativeLong Reserved2, CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr, TimeStamp ptsExpiry); /** * The DeleteSecurityContext function deletes the local data structures associated * with the specified security context. * @param phContext * Handle of the security context to delete. * @return * If the function succeeds, the return value is SEC_E_OK. * If the function fails, the return value is SEC_E_INVALID_HANDLE; */ public int DeleteSecurityContext(CtxtHandle phContext); /** * The FreeCredentialsHandle function notifies the security system that the * credentials are no longer needed. An application calls this function to free * the credential handle acquired in the call to the AcquireCredentialsHandle * function. When all references to this credential set have been removed, the * credentials themselves can be removed. * @param phCredential * A pointer to the credential handle obtained by using the AcquireCredentialsHandle * function. * @return * If the function succeeds, the return value is SEC_E_OK. * If the function fails, the return value is SEC_E_INVALID_HANDLE; */ public int FreeCredentialsHandle(CredHandle phCredential); /** * The AcceptSecurityContext function enables the server component of a transport * application to establish a security context between the server and a remote client. * The remote client uses the InitializeSecurityContext function to start the process * of establishing a security context. The server can require one or more reply tokens * from the remote client to complete establishing the security context. * @param phCredential * A handle to the credentials of the server. The server calls the AcquireCredentialsHandle * function with either the SECPKG_CRED_INBOUND or SECPKG_CRED_BOTH flag set to retrieve * this handle. * @param phContext * A pointer to a CtxtHandle structure. On the first call to AcceptSecurityContext, * this pointer is NULL. On subsequent calls, phContext is the handle to the partially * formed context that was returned in the phNewContext parameter by the first call. * @param pInput * A pointer to a SecBufferDesc structure generated by a client call to * InitializeSecurityContext that contains the input buffer descriptor. * @param fContextReq * Bit flags that specify the attributes required by the server to establish the * context. Bit flags can be combined by using bitwise-OR operations. * @param TargetDataRep * The data representation, such as byte ordering, on the target. This parameter can * be either SECURITY_NATIVE_DREP or SECURITY_NETWORK_DREP. * @param phNewContext * A pointer to a CtxtHandle structure. On the first call to AcceptSecurityContext, * this pointer receives the new context handle. On subsequent calls, phNewContext * can be the same as the handle specified in the phContext parameter. * @param pOutput * A pointer to a SecBufferDesc structure that contains the output buffer descriptor. * This buffer is sent to the client for input into additional calls to * InitializeSecurityContext. An output buffer may be generated even if the function * returns SEC_E_OK. Any buffer generated must be sent back to the client application. * @param pfContextAttr * A pointer to a variable that receives a set of bit flags that indicate the * attributes of the established context. For a description of the various attributes, * see Context Requirements. Flags used for this parameter are prefixed with ASC_RET, * for example, ASC_RET_DELEGATE. * @param ptsTimeStamp * A pointer to a TimeStamp structure that receives the expiration time of the context. * @return * This function returns one of SEC_* values. */ public int AcceptSecurityContext(CredHandle phCredential, CtxtHandle phContext, SecBufferDesc pInput, NativeLong fContextReq, NativeLong TargetDataRep, CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr, TimeStamp ptsTimeStamp); /** * The EnumerateSecurityPackages function returns an array of SecPkgInfo structures that * describe the security packages available to the client. * @param pcPackages * A pointer to a ULONG variable that receives the number of packages returned. * @param ppPackageInfo * A pointer to a variable that receives a pointer to an array of SecPkgInfo structures. * Each structure contains information from the security support provider (SSP) that * describes a security package that is available within that SSP. * @return * If the function succeeds, the function returns SEC_E_OK. * If the function fails, it returns a nonzero error code. */ public int EnumerateSecurityPackages(IntByReference pcPackages, PSecPkgInfo.ByReference ppPackageInfo); /** * The FreeContextBuffer function enables callers of security package functions to free a memory * buffer that was allocated by the security package as a result of calls to InitializeSecurityContext * and AcceptSecurityContext. * @param buffer * A pointer to memory allocated by the security package. * @return * If the function succeeds, the function returns SEC_E_OK. * If the function fails, it returns a nonzero error code. */ public int FreeContextBuffer(Pointer buffer); /** * The QuerySecurityContextToken function obtains the access token for a client security context * and uses it directly. * @param phContext * Handle of the context to query. * @param phToken * Returned handle to the access token. * @return * If the function succeeds, the function returns SEC_E_OK. * If the function fails, it returns a nonzero error code. One possible error code return is * SEC_E_INVALID_HANDLE. */ public int QuerySecurityContextToken(CtxtHandle phContext, HANDLEByReference phToken); /** * The ImpersonateSecurityContext function allows a server to impersonate a client by using * a token previously obtained by a call to AcceptSecurityContext or QuerySecurityContextToken. * This function allows the application server to act as the client, and thus all necessary * access controls are enforced. * @param phContext * The handle of the context to impersonate. This handle must have been obtained by a call * to the AcceptSecurityContext function. * @return * If the function succeeds, the function returns SEC_E_OK. * If the function fails, it returns a SEC_E_INVALID_HANDLE, SEC_E_NO_IMPERSONATION or * SEC_E_UNSUPPORTED_FUNCTION error code. */ public int ImpersonateSecurityContext(CtxtHandle phContext); /** * Allows a security package to discontinue the impersonation of the caller and restore its * own security context. * @param phContext * Handle of the security context being impersonated. This handle must have been obtained in * the call to the AcceptSecurityContext function and used in the call to the * ImpersonateSecurityContext function. * @return * If the function succeeds, the return value is SEC_E_OK. * If the function fails, the return value can be either SEC_E_INVALID_HANDLE or SEC_E_UNSUPPORTED_FUNCTION. */ public int RevertSecurityContext(CtxtHandle phContext); } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/W32Errors.java0000644000175000017500000341357311421126020025417 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.platform.win32.WinNT.HRESULT; /** * Error code definitions for the Win32 API functions. * Ported from Windows SDK 6.0A * @author dblock[at]dblock.org */ public abstract class W32Errors { // // Values are 32 bit values laid out as follows: // // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 // +---+-+-+-----------------------+-------------------------------+ // |Sev|C|R| Facility | Code | // +---+-+-+-----------------------+-------------------------------+ // // where // // Sev - is the severity code // // 00 - Success // 01 - Informational // 10 - Warning // 11 - Error // // C - is the Customer code flag // // R - is a reserved bit // // Facility - is the facility code // // Code - is the facility's status code // // Define the facility codes // public static final short FACILITY_WINRM = 51; public static final short FACILITY_WINDOWSUPDATE = 36; public static final short FACILITY_WINDOWS_DEFENDER = 80; public static final short FACILITY_WINDOWS_CE = 24; public static final short FACILITY_WINDOWS = 8; public static final short FACILITY_URT = 19; public static final short FACILITY_UMI = 22; public static final short FACILITY_TPM_SOFTWARE = 41; public static final short FACILITY_TPM_SERVICES = 40; public static final short FACILITY_SXS = 23; public static final short FACILITY_STORAGE = 3; public static final short FACILITY_STATE_MANAGEMENT = 34; public static final short FACILITY_SSPI = 9; public static final short FACILITY_SCARD = 16; public static final short FACILITY_SHELL = 39; public static final short FACILITY_SETUPAPI = 15; public static final short FACILITY_SECURITY = 9; public static final short FACILITY_RPC = 1; public static final short FACILITY_PLA = 48; public static final short FACILITY_WIN32 = 7; public static final short FACILITY_CONTROL = 10; public static final short FACILITY_NULL = 0; public static final short FACILITY_NDIS = 52; public static final short FACILITY_METADIRECTORY = 35; public static final short FACILITY_MSMQ = 14; public static final short FACILITY_MEDIASERVER = 13; public static final short FACILITY_INTERNET = 12; public static final short FACILITY_ITF = 4; public static final short FACILITY_USERMODE_HYPERVISOR = 53; public static final short FACILITY_HTTP = 25; public static final short FACILITY_GRAPHICS = 38; public static final short FACILITY_FWP = 50; public static final short FACILITY_FVE = 49; public static final short FACILITY_USERMODE_FILTER_MANAGER = 31; public static final short FACILITY_DPLAY = 21; public static final short FACILITY_DISPATCH = 2; public static final short FACILITY_DIRECTORYSERVICE = 37; public static final short FACILITY_CONFIGURATION = 33; public static final short FACILITY_COMPLUS = 17; public static final short FACILITY_USERMODE_COMMONLOG = 26; public static final short FACILITY_CMI = 54; public static final short FACILITY_CERT = 11; public static final short FACILITY_BACKGROUNDCOPY = 32; public static final short FACILITY_ACS = 20; public static final short FACILITY_AAF = 18; // // Define the severity codes // // // MessageId: ERROR_SUCCESS // // MessageText: // // The operation completed successfully. // public static final int ERROR_SUCCESS = 0; public static final int NO_ERROR = 0; // dderror public static final int SEC_E_OK = 0; // // MessageId: ERROR_INVALID_FUNCTION // // MessageText: // // Incorrect function. // public static final int ERROR_INVALID_FUNCTION = 1; // dderror // // MessageId: ERROR_FILE_NOT_FOUND // // MessageText: // // The system cannot find the file specified. // public static final int ERROR_FILE_NOT_FOUND = 2; // // MessageId: ERROR_PATH_NOT_FOUND // // MessageText: // // The system cannot find the path specified. // public static final int ERROR_PATH_NOT_FOUND = 3; // // MessageId: ERROR_TOO_MANY_OPEN_FILES // // MessageText: // // The system cannot open the file. // public static final int ERROR_TOO_MANY_OPEN_FILES = 4; // // MessageId: ERROR_ACCESS_DENIED // // MessageText: // // Access is denied. // public static final int ERROR_ACCESS_DENIED = 5; // // MessageId: ERROR_INVALID_HANDLE // // MessageText: // // The handle is invalid. // public static final int ERROR_INVALID_HANDLE = 6; // // MessageId: ERROR_ARENA_TRASHED // // MessageText: // // The storage control blocks were destroyed. // public static final int ERROR_ARENA_TRASHED = 7; // // MessageId: ERROR_NOT_ENOUGH_MEMORY // // MessageText: // // Not enough storage is available to process this command. // public static final int ERROR_NOT_ENOUGH_MEMORY = 8; // dderror // // MessageId: ERROR_INVALID_BLOCK // // MessageText: // // The storage control block address is invalid. // public static final int ERROR_INVALID_BLOCK = 9; // // MessageId: ERROR_BAD_ENVIRONMENT // // MessageText: // // The environment is incorrect. // public static final int ERROR_BAD_ENVIRONMENT = 10; // // MessageId: ERROR_BAD_FORMAT // // MessageText: // // An attempt was made to load a program with an incorrect format. // public static final int ERROR_BAD_FORMAT = 11; // // MessageId: ERROR_INVALID_ACCESS // // MessageText: // // The access code is invalid. // public static final int ERROR_INVALID_ACCESS = 12; // // MessageId: ERROR_INVALID_DATA // // MessageText: // // The data is invalid. // public static final int ERROR_INVALID_DATA = 13; // // MessageId: ERROR_OUTOFMEMORY // // MessageText: // // Not enough storage is available to complete this operation. // public static final int ERROR_OUTOFMEMORY = 14; // // MessageId: ERROR_INVALID_DRIVE // // MessageText: // // The system cannot find the drive specified. // public static final int ERROR_INVALID_DRIVE = 15; // // MessageId: ERROR_CURRENT_DIRECTORY // // MessageText: // // The directory cannot be removed. // public static final int ERROR_CURRENT_DIRECTORY = 16; // // MessageId: ERROR_NOT_SAME_DEVICE // // MessageText: // // The system cannot move the file to a different disk drive. // public static final int ERROR_NOT_SAME_DEVICE = 17; // // MessageId: ERROR_NO_MORE_FILES // // MessageText: // // There are no more files. // public static final int ERROR_NO_MORE_FILES = 18; // // MessageId: ERROR_WRITE_PROTECT // // MessageText: // // The media is write protected. // public static final int ERROR_WRITE_PROTECT = 19; // // MessageId: ERROR_BAD_UNIT // // MessageText: // // The system cannot find the device specified. // public static final int ERROR_BAD_UNIT = 20; // // MessageId: ERROR_NOT_READY // // MessageText: // // The device is not ready. // public static final int ERROR_NOT_READY = 21; // // MessageId: ERROR_BAD_COMMAND // // MessageText: // // The device does not recognize the command. // public static final int ERROR_BAD_COMMAND = 22; // // MessageId: ERROR_CRC // // MessageText: // // Data error (cyclic redundancy check). // public static final int ERROR_CRC = 23; // // MessageId: ERROR_BAD_LENGTH // // MessageText: // // The program issued a command but the command length is incorrect. // public static final int ERROR_BAD_LENGTH = 24; // // MessageId: ERROR_SEEK // // MessageText: // // The drive cannot locate a specific area or track on the disk. // public static final int ERROR_SEEK = 25; // // MessageId: ERROR_NOT_DOS_DISK // // MessageText: // // The specified disk or diskette cannot be accessed. // public static final int ERROR_NOT_DOS_DISK = 26; // // MessageId: ERROR_SECTOR_NOT_FOUND // // MessageText: // // The drive cannot find the sector requested. // public static final int ERROR_SECTOR_NOT_FOUND = 27; // // MessageId: ERROR_OUT_OF_PAPER // // MessageText: // // The printer is out of paper. // public static final int ERROR_OUT_OF_PAPER = 28; // // MessageId: ERROR_WRITE_FAULT // // MessageText: // // The system cannot write to the specified device. // public static final int ERROR_WRITE_FAULT = 29; // // MessageId: ERROR_READ_FAULT // // MessageText: // // The system cannot read from the specified device. // public static final int ERROR_READ_FAULT = 30; // // MessageId: ERROR_GEN_FAILURE // // MessageText: // // A device attached to the system is not functioning. // public static final int ERROR_GEN_FAILURE = 31; // // MessageId: ERROR_SHARING_VIOLATION // // MessageText: // // The process cannot access the file because it is being used by another // process. // public static final int ERROR_SHARING_VIOLATION = 32; // // MessageId: ERROR_LOCK_VIOLATION // // MessageText: // // The process cannot access the file because another process has locked a // portion of the file. // public static final int ERROR_LOCK_VIOLATION = 33; // // MessageId: ERROR_WRONG_DISK // // MessageText: // // The wrong diskette is in the drive. // Insert %2 (Volume Serial Number: %3) into drive %1. // public static final int ERROR_WRONG_DISK = 34; // // MessageId: ERROR_SHARING_BUFFER_EXCEEDED // // MessageText: // // Too many files opened for sharing. // public static final int ERROR_SHARING_BUFFER_EXCEEDED = 36; // // MessageId: ERROR_HANDLE_EOF // // MessageText: // // Reached the end of the file. // public static final int ERROR_HANDLE_EOF = 38; // // MessageId: ERROR_HANDLE_DISK_FULL // // MessageText: // // The disk is full. // public static final int ERROR_HANDLE_DISK_FULL = 39; // // MessageId: ERROR_NOT_SUPPORTED // // MessageText: // // The request is not supported. // public static final int ERROR_NOT_SUPPORTED = 50; // // MessageId: ERROR_REM_NOT_LIST // // MessageText: // // Windows cannot find the network path. Verify that the network path is // correct and the destination computer is not busy or turned off. If // Windows still cannot find the network path, contact your network // administrator. // public static final int ERROR_REM_NOT_LIST = 51; // // MessageId: ERROR_DUP_NAME // // MessageText: // // You were not connected because a duplicate name exists on the network. If // joining a domain, go to System in Control Panel to change the computer // name and try again. If joining a workgroup, choose another workgroup // name. // public static final int ERROR_DUP_NAME = 52; // // MessageId: ERROR_BAD_NETPATH // // MessageText: // // The network path was not found. // public static final int ERROR_BAD_NETPATH = 53; // // MessageId: ERROR_NETWORK_BUSY // // MessageText: // // The network is busy. // public static final int ERROR_NETWORK_BUSY = 54; // // MessageId: ERROR_DEV_NOT_EXIST // // MessageText: // // The specified network resource or device is no longer available. // public static final int ERROR_DEV_NOT_EXIST = 55; // dderror // // MessageId: ERROR_TOO_MANY_CMDS // // MessageText: // // The network BIOS command limit has been reached. // public static final int ERROR_TOO_MANY_CMDS = 56; // // MessageId: ERROR_ADAP_HDW_ERR // // MessageText: // // A network adapter hardware error occurred. // public static final int ERROR_ADAP_HDW_ERR = 57; // // MessageId: ERROR_BAD_NET_RESP // // MessageText: // // The specified server cannot perform the requested operation. // public static final int ERROR_BAD_NET_RESP = 58; // // MessageId: ERROR_UNEXP_NET_ERR // // MessageText: // // An unexpected network error occurred. // public static final int ERROR_UNEXP_NET_ERR = 59; // // MessageId: ERROR_BAD_REM_ADAP // // MessageText: // // The remote adapter is not compatible. // public static final int ERROR_BAD_REM_ADAP = 60; // // MessageId: ERROR_PRINTQ_FULL // // MessageText: // // The printer queue is full. // public static final int ERROR_PRINTQ_FULL = 61; // // MessageId: ERROR_NO_SPOOL_SPACE // // MessageText: // // Space to store the file waiting to be printed is not available on the // server. // public static final int ERROR_NO_SPOOL_SPACE = 62; // // MessageId: ERROR_PRINT_CANCELLED // // MessageText: // // Your file waiting to be printed was deleted. // public static final int ERROR_PRINT_CANCELLED = 63; // // MessageId: ERROR_NETNAME_DELETED // // MessageText: // // The specified network name is no longer available. // public static final int ERROR_NETNAME_DELETED = 64; // // MessageId: ERROR_NETWORK_ACCESS_DENIED // // MessageText: // // Network access is denied. // public static final int ERROR_NETWORK_ACCESS_DENIED = 65; // // MessageId: ERROR_BAD_DEV_TYPE // // MessageText: // // The network resource type is not correct. // public static final int ERROR_BAD_DEV_TYPE = 66; // // MessageId: ERROR_BAD_NET_NAME // // MessageText: // // The network name cannot be found. // public static final int ERROR_BAD_NET_NAME = 67; // // MessageId: ERROR_TOO_MANY_NAMES // // MessageText: // // The name limit for the local computer network adapter card was exceeded. // public static final int ERROR_TOO_MANY_NAMES = 68; // // MessageId: ERROR_TOO_MANY_SESS // // MessageText: // // The network BIOS session limit was exceeded. // public static final int ERROR_TOO_MANY_SESS = 69; // // MessageId: ERROR_SHARING_PAUSED // // MessageText: // // The remote server has been paused or is in the process of being started. // public static final int ERROR_SHARING_PAUSED = 70; // // MessageId: ERROR_REQ_NOT_ACCEP // // MessageText: // // No more connections can be made to this remote computer at this time // because there are already as many connections as the computer can accept. // public static final int ERROR_REQ_NOT_ACCEP = 71; // // MessageId: ERROR_REDIR_PAUSED // // MessageText: // // The specified printer or disk device has been paused. // public static final int ERROR_REDIR_PAUSED = 72; // // MessageId: ERROR_FILE_EXISTS // // MessageText: // // The file exists. // public static final int ERROR_FILE_EXISTS = 80; // // MessageId: ERROR_CANNOT_MAKE // // MessageText: // // The directory or file cannot be created. // public static final int ERROR_CANNOT_MAKE = 82; // // MessageId: ERROR_FAIL_I24 // // MessageText: // // Fail on INT=24. // public static final int ERROR_FAIL_I24 = 83; // // MessageId: ERROR_OUT_OF_STRUCTURES // // MessageText: // // Storage to process this request is not available. // public static final int ERROR_OUT_OF_STRUCTURES = 84; // // MessageId: ERROR_ALREADY_ASSIGNED // // MessageText: // // The local device name is already in use. // public static final int ERROR_ALREADY_ASSIGNED = 85; // // MessageId: ERROR_INVALID_PASSWORD // // MessageText: // // The specified network password is not correct. // public static final int ERROR_INVALID_PASSWORD = 86; // // MessageId: ERROR_INVALID_PARAMETER // // MessageText: // // The parameter is incorrect. // public static final int ERROR_INVALID_PARAMETER = 87; // dderror // // MessageId: ERROR_NET_WRITE_FAULT // // MessageText: // // A write fault occurred on the network. // public static final int ERROR_NET_WRITE_FAULT = 88; // // MessageId: ERROR_NO_PROC_SLOTS // // MessageText: // // The system cannot start another process at this time. // public static final int ERROR_NO_PROC_SLOTS = 89; // // MessageId: ERROR_TOO_MANY_SEMAPHORES // // MessageText: // // Cannot create another system semaphore. // public static final int ERROR_TOO_MANY_SEMAPHORES = 100; // // MessageId: ERROR_EXCL_SEM_ALREADY_OWNED // // MessageText: // // The exclusive semaphore is owned by another process. // public static final int ERROR_EXCL_SEM_ALREADY_OWNED = 101; // // MessageId: ERROR_SEM_IS_SET // // MessageText: // // The semaphore is set and cannot be closed. // public static final int ERROR_SEM_IS_SET = 102; // // MessageId: ERROR_TOO_MANY_SEM_REQUESTS // // MessageText: // // The semaphore cannot be set again. // public static final int ERROR_TOO_MANY_SEM_REQUESTS = 103; // // MessageId: ERROR_INVALID_AT_INTERRUPT_TIME // // MessageText: // // Cannot request exclusive semaphores at interrupt time. // public static final int ERROR_INVALID_AT_INTERRUPT_TIME = 104; // // MessageId: ERROR_SEM_OWNER_DIED // // MessageText: // // The previous ownership of this semaphore has ended. // public static final int ERROR_SEM_OWNER_DIED = 105; // // MessageId: ERROR_SEM_USER_LIMIT // // MessageText: // // Insert the diskette for drive %1. // public static final int ERROR_SEM_USER_LIMIT = 106; // // MessageId: ERROR_DISK_CHANGE // // MessageText: // // The program stopped because an alternate diskette was not inserted. // public static final int ERROR_DISK_CHANGE = 107; // // MessageId: ERROR_DRIVE_LOCKED // // MessageText: // // The disk is in use or locked by another process. // public static final int ERROR_DRIVE_LOCKED = 108; // // MessageId: ERROR_BROKEN_PIPE // // MessageText: // // The pipe has been ended. // public static final int ERROR_BROKEN_PIPE = 109; // // MessageId: ERROR_OPEN_FAILED // // MessageText: // // The system cannot open the device or file specified. // public static final int ERROR_OPEN_FAILED = 110; // // MessageId: ERROR_BUFFER_OVERFLOW // // MessageText: // // The file name is too long. // public static final int ERROR_BUFFER_OVERFLOW = 111; // // MessageId: ERROR_DISK_FULL // // MessageText: // // There is not enough space on the disk. // public static final int ERROR_DISK_FULL = 112; // // MessageId: ERROR_NO_MORE_SEARCH_HANDLES // // MessageText: // // No more internal file identifiers available. // public static final int ERROR_NO_MORE_SEARCH_HANDLES = 113; // // MessageId: ERROR_INVALID_TARGET_HANDLE // // MessageText: // // The target internal file identifier is incorrect. // public static final int ERROR_INVALID_TARGET_HANDLE = 114; // // MessageId: ERROR_INVALID_CATEGORY // // MessageText: // // The IOCTL call made by the application program is not correct. // public static final int ERROR_INVALID_CATEGORY = 117; // // MessageId: ERROR_INVALID_VERIFY_SWITCH // // MessageText: // // The verify-on-write switch parameter value is not correct. // public static final int ERROR_INVALID_VERIFY_SWITCH = 118; // // MessageId: ERROR_BAD_DRIVER_LEVEL // // MessageText: // // The system does not support the command requested. // public static final int ERROR_BAD_DRIVER_LEVEL = 119; // // MessageId: ERROR_CALL_NOT_IMPLEMENTED // // MessageText: // // This function is not supported on this system. // public static final int ERROR_CALL_NOT_IMPLEMENTED = 120; // // MessageId: ERROR_SEM_TIMEOUT // // MessageText: // // The semaphore timeout period has expired. // public static final int ERROR_SEM_TIMEOUT = 121; // // MessageId: ERROR_INSUFFICIENT_BUFFER // // MessageText: // // The data area passed to a system call is too small. // public static final int ERROR_INSUFFICIENT_BUFFER = 122; // dderror // // MessageId: ERROR_INVALID_NAME // // MessageText: // // The filename, directory name, or volume label syntax is incorrect. // public static final int ERROR_INVALID_NAME = 123; // dderror // // MessageId: ERROR_INVALID_LEVEL // // MessageText: // // The system call level is not correct. // public static final int ERROR_INVALID_LEVEL = 124; // // MessageId: ERROR_NO_VOLUME_LABEL // // MessageText: // // The disk has no volume label. // public static final int ERROR_NO_VOLUME_LABEL = 125; // // MessageId: ERROR_MOD_NOT_FOUND // // MessageText: // // The specified module could not be found. // public static final int ERROR_MOD_NOT_FOUND = 126; // // MessageId: ERROR_PROC_NOT_FOUND // // MessageText: // // The specified procedure could not be found. // public static final int ERROR_PROC_NOT_FOUND = 127; // // MessageId: ERROR_WAIT_NO_CHILDREN // // MessageText: // // There are no child processes to wait for. // public static final int ERROR_WAIT_NO_CHILDREN = 128; // // MessageId: ERROR_CHILD_NOT_COMPLETE // // MessageText: // // The %1 application cannot be run in Win32 mode. // public static final int ERROR_CHILD_NOT_COMPLETE = 129; // // MessageId: ERROR_DIRECT_ACCESS_HANDLE // // MessageText: // // Attempt to use a file handle to an open disk partition for an operation // other than raw disk I/O. // public static final int ERROR_DIRECT_ACCESS_HANDLE = 130; // // MessageId: ERROR_NEGATIVE_SEEK // // MessageText: // // An attempt was made to move the file pointer before the beginning of the // file. // public static final int ERROR_NEGATIVE_SEEK = 131; // // MessageId: ERROR_SEEK_ON_DEVICE // // MessageText: // // The file pointer cannot be set on the specified device or file. // public static final int ERROR_SEEK_ON_DEVICE = 132; // // MessageId: ERROR_IS_JOIN_TARGET // // MessageText: // // A JOIN or SUBST command cannot be used for a drive that contains // previously joined drives. // public static final int ERROR_IS_JOIN_TARGET = 133; // // MessageId: ERROR_IS_JOINED // // MessageText: // // An attempt was made to use a JOIN or SUBST command on a drive that has // already been joined. // public static final int ERROR_IS_JOINED = 134; // // MessageId: ERROR_IS_SUBSTED // // MessageText: // // An attempt was made to use a JOIN or SUBST command on a drive that has // already been substituted. // public static final int ERROR_IS_SUBSTED = 135; // // MessageId: ERROR_NOT_JOINED // // MessageText: // // The system tried to delete the JOIN of a drive that is not joined. // public static final int ERROR_NOT_JOINED = 136; // // MessageId: ERROR_NOT_SUBSTED // // MessageText: // // The system tried to delete the substitution of a drive that is not // substituted. // public static final int ERROR_NOT_SUBSTED = 137; // // MessageId: ERROR_JOIN_TO_JOIN // // MessageText: // // The system tried to join a drive to a directory on a joined drive. // public static final int ERROR_JOIN_TO_JOIN = 138; // // MessageId: ERROR_SUBST_TO_SUBST // // MessageText: // // The system tried to substitute a drive to a directory on a substituted // drive. // public static final int ERROR_SUBST_TO_SUBST = 139; // // MessageId: ERROR_JOIN_TO_SUBST // // MessageText: // // The system tried to join a drive to a directory on a substituted drive. // public static final int ERROR_JOIN_TO_SUBST = 140; // // MessageId: ERROR_SUBST_TO_JOIN // // MessageText: // // The system tried to SUBST a drive to a directory on a joined drive. // public static final int ERROR_SUBST_TO_JOIN = 141; // // MessageId: ERROR_BUSY_DRIVE // // MessageText: // // The system cannot perform a JOIN or SUBST at this time. // public static final int ERROR_BUSY_DRIVE = 142; // // MessageId: ERROR_SAME_DRIVE // // MessageText: // // The system cannot join or substitute a drive to or for a directory on the // same drive. // public static final int ERROR_SAME_DRIVE = 143; // // MessageId: ERROR_DIR_NOT_ROOT // // MessageText: // // The directory is not a subdirectory of the root directory. // public static final int ERROR_DIR_NOT_ROOT = 144; // // MessageId: ERROR_DIR_NOT_EMPTY // // MessageText: // // The directory is not empty. // public static final int ERROR_DIR_NOT_EMPTY = 145; // // MessageId: ERROR_IS_SUBST_PATH // // MessageText: // // The path specified is being used in a substitute. // public static final int ERROR_IS_SUBST_PATH = 146; // // MessageId: ERROR_IS_JOIN_PATH // // MessageText: // // Not enough resources are available to process this command. // public static final int ERROR_IS_JOIN_PATH = 147; // // MessageId: ERROR_PATH_BUSY // // MessageText: // // The path specified cannot be used at this time. // public static final int ERROR_PATH_BUSY = 148; // // MessageId: ERROR_IS_SUBST_TARGET // // MessageText: // // An attempt was made to join or substitute a drive for which a directory // on the drive is the target of a previous substitute. // public static final int ERROR_IS_SUBST_TARGET = 149; // // MessageId: ERROR_SYSTEM_TRACE // // MessageText: // // System trace information was not specified in your CONFIG.SYS file, or // tracing is disallowed. // public static final int ERROR_SYSTEM_TRACE = 150; // // MessageId: ERROR_INVALID_EVENT_COUNT // // MessageText: // // The number of specified semaphore events for DosMuxSemWait is not // correct. // public static final int ERROR_INVALID_EVENT_COUNT = 151; // // MessageId: ERROR_TOO_MANY_MUXWAITERS // // MessageText: // // DosMuxSemWait did not execute; too many semaphores are already set. // public static final int ERROR_TOO_MANY_MUXWAITERS = 152; // // MessageId: ERROR_INVALID_LIST_FORMAT // // MessageText: // // The DosMuxSemWait list is not correct. // public static final int ERROR_INVALID_LIST_FORMAT = 153; // // MessageId: ERROR_LABEL_TOO_LONG // // MessageText: // // The volume label you entered exceeds the label character limit of the // target file system. // public static final int ERROR_LABEL_TOO_LONG = 154; // // MessageId: ERROR_TOO_MANY_TCBS // // MessageText: // // Cannot create another thread. // public static final int ERROR_TOO_MANY_TCBS = 155; // // MessageId: ERROR_SIGNAL_REFUSED // // MessageText: // // The recipient process has refused the signal. // public static final int ERROR_SIGNAL_REFUSED = 156; // // MessageId: ERROR_DISCARDED // // MessageText: // // The segment is already discarded and cannot be locked. // public static final int ERROR_DISCARDED = 157; // // MessageId: ERROR_NOT_LOCKED // // MessageText: // // The segment is already unlocked. // public static final int ERROR_NOT_LOCKED = 158; // // MessageId: ERROR_BAD_THREADID_ADDR // // MessageText: // // The address for the thread ID is not correct. // public static final int ERROR_BAD_THREADID_ADDR = 159; // // MessageId: ERROR_BAD_ARGUMENTS // // MessageText: // // One or more arguments are not correct. // public static final int ERROR_BAD_ARGUMENTS = 160; // // MessageId: ERROR_BAD_PATHNAME // // MessageText: // // The specified path is invalid. // public static final int ERROR_BAD_PATHNAME = 161; // // MessageId: ERROR_SIGNAL_PENDING // // MessageText: // // A signal is already pending. // public static final int ERROR_SIGNAL_PENDING = 162; // // MessageId: ERROR_MAX_THRDS_REACHED // // MessageText: // // No more threads can be created in the system. // public static final int ERROR_MAX_THRDS_REACHED = 164; // // MessageId: ERROR_LOCK_FAILED // // MessageText: // // Unable to lock a region of a file. // public static final int ERROR_LOCK_FAILED = 167; // // MessageId: ERROR_BUSY // // MessageText: // // The requested resource is in use. // public static final int ERROR_BUSY = 170; // dderror // // MessageId: ERROR_CANCEL_VIOLATION // // MessageText: // // A lock request was not outstanding for the supplied cancel region. // public static final int ERROR_CANCEL_VIOLATION = 173; // // MessageId: ERROR_ATOMIC_LOCKS_NOT_SUPPORTED // // MessageText: // // The file system does not support atomic changes to the lock type. // public static final int ERROR_ATOMIC_LOCKS_NOT_SUPPORTED = 174; // // MessageId: ERROR_INVALID_SEGMENT_NUMBER // // MessageText: // // The system detected a segment number that was not correct. // public static final int ERROR_INVALID_SEGMENT_NUMBER = 180; // // MessageId: ERROR_INVALID_ORDINAL // // MessageText: // // The operating system cannot run %1. // public static final int ERROR_INVALID_ORDINAL = 182; // // MessageId: ERROR_ALREADY_EXISTS // // MessageText: // // Cannot create a file when that file already exists. // public static final int ERROR_ALREADY_EXISTS = 183; // // MessageId: ERROR_INVALID_FLAG_NUMBER // // MessageText: // // The flag passed is not correct. // public static final int ERROR_INVALID_FLAG_NUMBER = 186; // // MessageId: ERROR_SEM_NOT_FOUND // // MessageText: // // The specified system semaphore name was not found. // public static final int ERROR_SEM_NOT_FOUND = 187; // // MessageId: ERROR_INVALID_STARTING_CODESEG // // MessageText: // // The operating system cannot run %1. // public static final int ERROR_INVALID_STARTING_CODESEG = 188; // // MessageId: ERROR_INVALID_STACKSEG // // MessageText: // // The operating system cannot run %1. // public static final int ERROR_INVALID_STACKSEG = 189; // // MessageId: ERROR_INVALID_MODULETYPE // // MessageText: // // The operating system cannot run %1. // public static final int ERROR_INVALID_MODULETYPE = 190; // // MessageId: ERROR_INVALID_EXE_SIGNATURE // // MessageText: // // Cannot run %1 in Win32 mode. // public static final int ERROR_INVALID_EXE_SIGNATURE = 191; // // MessageId: ERROR_EXE_MARKED_INVALID // // MessageText: // // The operating system cannot run %1. // public static final int ERROR_EXE_MARKED_INVALID = 192; // // MessageId: ERROR_BAD_EXE_FORMAT // // MessageText: // // %1 is not a valid Win32 application. // public static final int ERROR_BAD_EXE_FORMAT = 193; // // MessageId: ERROR_ITERATED_DATA_EXCEEDS_64k // // MessageText: // // The operating system cannot run %1. // public static final int ERROR_ITERATED_DATA_EXCEEDS_64k = 194; // // MessageId: ERROR_INVALID_MINALLOCSIZE // // MessageText: // // The operating system cannot run %1. // public static final int ERROR_INVALID_MINALLOCSIZE = 195; // // MessageId: ERROR_DYNLINK_FROM_INVALID_RING // // MessageText: // // The operating system cannot run this application program. // public static final int ERROR_DYNLINK_FROM_INVALID_RING = 196; // // MessageId: ERROR_IOPL_NOT_ENABLED // // MessageText: // // The operating system is not presently configured to run this application. // public static final int ERROR_IOPL_NOT_ENABLED = 197; // // MessageId: ERROR_INVALID_SEGDPL // // MessageText: // // The operating system cannot run %1. // public static final int ERROR_INVALID_SEGDPL = 198; // // MessageId: ERROR_AUTODATASEG_EXCEEDS_64k // // MessageText: // // The operating system cannot run this application program. // public static final int ERROR_AUTODATASEG_EXCEEDS_64k = 199; // // MessageId: ERROR_RING2SEG_MUST_BE_MOVABLE // // MessageText: // // The code segment cannot be greater than or equal to=64K. // public static final int ERROR_RING2SEG_MUST_BE_MOVABLE = 200; // // MessageId: ERROR_RELOC_CHAIN_XEEDS_SEGLIM // // MessageText: // // The operating system cannot run %1. // public static final int ERROR_RELOC_CHAIN_XEEDS_SEGLIM = 201; // // MessageId: ERROR_INFLOOP_IN_RELOC_CHAIN // // MessageText: // // The operating system cannot run %1. // public static final int ERROR_INFLOOP_IN_RELOC_CHAIN = 202; // // MessageId: ERROR_ENVVAR_NOT_FOUND // // MessageText: // // The system could not find the environment option that was entered. // public static final int ERROR_ENVVAR_NOT_FOUND = 203; // // MessageId: ERROR_NO_SIGNAL_SENT // // MessageText: // // No process in the command subtree has a signal handler. // public static final int ERROR_NO_SIGNAL_SENT = 205; // // MessageId: ERROR_FILENAME_EXCED_RANGE // // MessageText: // // The filename or extension is too long. // public static final int ERROR_FILENAME_EXCED_RANGE = 206; // // MessageId: ERROR_RING2_STACK_IN_USE // // MessageText: // // The ring=2 stack is in use. // public static final int ERROR_RING2_STACK_IN_USE = 207; // // MessageId: ERROR_META_EXPANSION_TOO_LONG // // MessageText: // // The global filename characters, * or ?, are entered incorrectly or too // many global filename characters are specified. // public static final int ERROR_META_EXPANSION_TOO_LONG = 208; // // MessageId: ERROR_INVALID_SIGNAL_NUMBER // // MessageText: // // The signal being posted is not correct. // public static final int ERROR_INVALID_SIGNAL_NUMBER = 209; // // MessageId: ERROR_THREAD_1_INACTIVE // // MessageText: // // The signal handler cannot be set. // public static final int ERROR_THREAD_1_INACTIVE = 210; // // MessageId: ERROR_LOCKED // // MessageText: // // The segment is locked and cannot be reallocated. // public static final int ERROR_LOCKED = 212; // // MessageId: ERROR_TOO_MANY_MODULES // // MessageText: // // Too many dynamic-link modules are attached to this program or // dynamic-link module. // public static final int ERROR_TOO_MANY_MODULES = 214; // // MessageId: ERROR_NESTING_NOT_ALLOWED // // MessageText: // // Cannot nest calls to LoadModule. // public static final int ERROR_NESTING_NOT_ALLOWED = 215; // // MessageId: ERROR_EXE_MACHINE_TYPE_MISMATCH // // MessageText: // // This version of %1 is not compatible with the version of Windows you're // running. Check your computer's system information to see whether you need // a x86 (32-bit) or x64 (64-bit) version of the program, and then contact // the software publisher. // public static final int ERROR_EXE_MACHINE_TYPE_MISMATCH = 216; // // MessageId: ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY // // MessageText: // // The image file %1 is signed, unable to modify. // public static final int ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY = 217; // // MessageId: ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY // // MessageText: // // The image file %1 is strong signed, unable to modify. // public static final int ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY = 218; // // MessageId: ERROR_FILE_CHECKED_OUT // // MessageText: // // This file is checked out or locked for editing by another user. // public static final int ERROR_FILE_CHECKED_OUT = 220; // // MessageId: ERROR_CHECKOUT_REQUIRED // // MessageText: // // The file must be checked out before saving changes. // public static final int ERROR_CHECKOUT_REQUIRED = 221; // // MessageId: ERROR_BAD_FILE_TYPE // // MessageText: // // The file type being saved or retrieved has been blocked. // public static final int ERROR_BAD_FILE_TYPE = 222; // // MessageId: ERROR_FILE_TOO_LARGE // // MessageText: // // The file size exceeds the limit allowed and cannot be saved. // public static final int ERROR_FILE_TOO_LARGE = 223; // // MessageId: ERROR_FORMS_AUTH_REQUIRED // // MessageText: // // Access Denied. Before opening files in this location, you must first // browse to the web site and select the option to login automatically. // public static final int ERROR_FORMS_AUTH_REQUIRED = 224; // // MessageId: ERROR_VIRUS_INFECTED // // MessageText: // // Operation did not complete successfully because the file contains a // virus. // public static final int ERROR_VIRUS_INFECTED = 225; // // MessageId: ERROR_VIRUS_DELETED // // MessageText: // // This file contains a virus and cannot be opened. Due to the nature of // this virus, the file has been removed from this location. // public static final int ERROR_VIRUS_DELETED = 226; // // MessageId: ERROR_PIPE_LOCAL // // MessageText: // // The pipe is local. // public static final int ERROR_PIPE_LOCAL = 229; // // MessageId: ERROR_BAD_PIPE // // MessageText: // // The pipe state is invalid. // public static final int ERROR_BAD_PIPE = 230; // // MessageId: ERROR_PIPE_BUSY // // MessageText: // // All pipe instances are busy. // public static final int ERROR_PIPE_BUSY = 231; // // MessageId: ERROR_NO_DATA // // MessageText: // // The pipe is being closed. // public static final int ERROR_NO_DATA = 232; // // MessageId: ERROR_PIPE_NOT_CONNECTED // // MessageText: // // No process is on the other end of the pipe. // public static final int ERROR_PIPE_NOT_CONNECTED = 233; // // MessageId: ERROR_MORE_DATA // // MessageText: // // More data is available. // public static final int ERROR_MORE_DATA = 234; // dderror // // MessageId: ERROR_VC_DISCONNECTED // // MessageText: // // The session was canceled. // public static final int ERROR_VC_DISCONNECTED = 240; // // MessageId: ERROR_INVALID_EA_NAME // // MessageText: // // The specified extended attribute name was invalid. // public static final int ERROR_INVALID_EA_NAME = 254; // // MessageId: ERROR_EA_LIST_INCONSISTENT // // MessageText: // // The extended attributes are inconsistent. // public static final int ERROR_EA_LIST_INCONSISTENT = 255; // // MessageId: WAIT_TIMEOUT // // MessageText: // // The wait operation timed out. // public static final int WAIT_TIMEOUT = 258; // dderror // // MessageId: ERROR_NO_MORE_ITEMS // // MessageText: // // No more data is available. // public static final int ERROR_NO_MORE_ITEMS = 259; // // MessageId: ERROR_CANNOT_COPY // // MessageText: // // The copy functions cannot be used. // public static final int ERROR_CANNOT_COPY = 266; // // MessageId: ERROR_DIRECTORY // // MessageText: // // The directory name is invalid. // public static final int ERROR_DIRECTORY = 267; // // MessageId: ERROR_EAS_DIDNT_FIT // // MessageText: // // The extended attributes did not fit in the buffer. // public static final int ERROR_EAS_DIDNT_FIT = 275; // // MessageId: ERROR_EA_FILE_CORRUPT // // MessageText: // // The extended attribute file on the mounted file system is corrupt. // public static final int ERROR_EA_FILE_CORRUPT = 276; // // MessageId: ERROR_EA_TABLE_FULL // // MessageText: // // The extended attribute table file is full. // public static final int ERROR_EA_TABLE_FULL = 277; // // MessageId: ERROR_INVALID_EA_HANDLE // // MessageText: // // The specified extended attribute handle is invalid. // public static final int ERROR_INVALID_EA_HANDLE = 278; // // MessageId: ERROR_EAS_NOT_SUPPORTED // // MessageText: // // The mounted file system does not support extended attributes. // public static final int ERROR_EAS_NOT_SUPPORTED = 282; // // MessageId: ERROR_NOT_OWNER // // MessageText: // // Attempt to release mutex not owned by caller. // public static final int ERROR_NOT_OWNER = 288; // // MessageId: ERROR_TOO_MANY_POSTS // // MessageText: // // Too many posts were made to a semaphore. // public static final int ERROR_TOO_MANY_POSTS = 298; // // MessageId: ERROR_PARTIAL_COPY // // MessageText: // // Only part of a ReadProcessMemory or WriteProcessMemory request was // completed. // public static final int ERROR_PARTIAL_COPY = 299; // // MessageId: ERROR_OPLOCK_NOT_GRANTED // // MessageText: // // The oplock request is denied. // public static final int ERROR_OPLOCK_NOT_GRANTED = 300; // // MessageId: ERROR_INVALID_OPLOCK_PROTOCOL // // MessageText: // // An invalid oplock acknowledgment was received by the system. // public static final int ERROR_INVALID_OPLOCK_PROTOCOL = 301; // // MessageId: ERROR_DISK_TOO_FRAGMENTED // // MessageText: // // The volume is too fragmented to complete this operation. // public static final int ERROR_DISK_TOO_FRAGMENTED = 302; // // MessageId: ERROR_DELETE_PENDING // // MessageText: // // The file cannot be opened because it is in the process of being deleted. // public static final int ERROR_DELETE_PENDING = 303; // // MessageId: ERROR_MR_MID_NOT_FOUND // // MessageText: // // The system cannot find message text for message number 0x%1 in the // message file for %2. // public static final int ERROR_MR_MID_NOT_FOUND = 317; // // MessageId: ERROR_SCOPE_NOT_FOUND // // MessageText: // // The scope specified was not found. // public static final int ERROR_SCOPE_NOT_FOUND = 318; // // MessageId: ERROR_FAIL_NOACTION_REBOOT // // MessageText: // // No action was taken as a system reboot is required. // public static final int ERROR_FAIL_NOACTION_REBOOT = 350; // // MessageId: ERROR_FAIL_SHUTDOWN // // MessageText: // // The shutdown operation failed. // public static final int ERROR_FAIL_SHUTDOWN = 351; // // MessageId: ERROR_FAIL_RESTART // // MessageText: // // The restart operation failed. // public static final int ERROR_FAIL_RESTART = 352; // // MessageId: ERROR_MAX_SESSIONS_REACHED // // MessageText: // // The maximum number of sessions has been reached. // public static final int ERROR_MAX_SESSIONS_REACHED = 353; // // MessageId: ERROR_THREAD_MODE_ALREADY_BACKGROUND // // MessageText: // // The thread is already in background processing mode. // public static final int ERROR_THREAD_MODE_ALREADY_BACKGROUND = 400; // // MessageId: ERROR_THREAD_MODE_NOT_BACKGROUND // // MessageText: // // The thread is not in background processing mode. // public static final int ERROR_THREAD_MODE_NOT_BACKGROUND = 401; // // MessageId: ERROR_PROCESS_MODE_ALREADY_BACKGROUND // // MessageText: // // The process is already in background processing mode. // public static final int ERROR_PROCESS_MODE_ALREADY_BACKGROUND = 402; // // MessageId: ERROR_PROCESS_MODE_NOT_BACKGROUND // // MessageText: // // The process is not in background processing mode. // public static final int ERROR_PROCESS_MODE_NOT_BACKGROUND = 403; // // MessageId: ERROR_INVALID_ADDRESS // // MessageText: // // Attempt to access invalid address. // public static final int ERROR_INVALID_ADDRESS = 487; // // MessageId: ERROR_USER_PROFILE_LOAD // // MessageText: // // User profile cannot be loaded. // public static final int ERROR_USER_PROFILE_LOAD = 500; // // MessageId: ERROR_ARITHMETIC_OVERFLOW // // MessageText: // // Arithmetic result exceeded=32 bits. // public static final int ERROR_ARITHMETIC_OVERFLOW = 534; // // MessageId: ERROR_PIPE_CONNECTED // // MessageText: // // There is a process on other end of the pipe. // public static final int ERROR_PIPE_CONNECTED = 535; // // MessageId: ERROR_PIPE_LISTENING // // MessageText: // // Waiting for a process to open the other end of the pipe. // public static final int ERROR_PIPE_LISTENING = 536; // // MessageId: ERROR_VERIFIER_STOP // // MessageText: // // Application verifier has found an error in the current process. // public static final int ERROR_VERIFIER_STOP = 537; // // MessageId: ERROR_ABIOS_ERROR // // MessageText: // // An error occurred in the ABIOS subsystem. // public static final int ERROR_ABIOS_ERROR = 538; // // MessageId: ERROR_WX86_WARNING // // MessageText: // // A warning occurred in the WX86 subsystem. // public static final int ERROR_WX86_WARNING = 539; // // MessageId: ERROR_WX86_ERROR // // MessageText: // // An error occurred in the WX86 subsystem. // public static final int ERROR_WX86_ERROR = 540; // // MessageId: ERROR_TIMER_NOT_CANCELED // // MessageText: // // An attempt was made to cancel or set a timer that has an associated APC // and the subject thread is not the thread that originally set the timer // with an associated APC routine. // public static final int ERROR_TIMER_NOT_CANCELED = 541; // // MessageId: ERROR_UNWIND // // MessageText: // // Unwind exception code. // public static final int ERROR_UNWIND = 542; // // MessageId: ERROR_BAD_STACK // // MessageText: // // An invalid or unaligned stack was encountered during an unwind operation. // public static final int ERROR_BAD_STACK = 543; // // MessageId: ERROR_INVALID_UNWIND_TARGET // // MessageText: // // An invalid unwind target was encountered during an unwind operation. // public static final int ERROR_INVALID_UNWIND_TARGET = 544; // // MessageId: ERROR_INVALID_PORT_ATTRIBUTES // // MessageText: // // Invalid Object Attributes specified to NtCreatePort or invalid Port // Attributes specified to NtConnectPort // public static final int ERROR_INVALID_PORT_ATTRIBUTES = 545; // // MessageId: ERROR_PORT_MESSAGE_TOO_LONG // // MessageText: // // Length of message passed to NtRequestPort or NtRequestWaitReplyPort was // longer than the maximum message allowed by the port. // public static final int ERROR_PORT_MESSAGE_TOO_LONG = 546; // // MessageId: ERROR_INVALID_QUOTA_LOWER // // MessageText: // // An attempt was made to lower a quota limit below the current usage. // public static final int ERROR_INVALID_QUOTA_LOWER = 547; // // MessageId: ERROR_DEVICE_ALREADY_ATTACHED // // MessageText: // // An attempt was made to attach to a device that was already attached to // another device. // public static final int ERROR_DEVICE_ALREADY_ATTACHED = 548; // // MessageId: ERROR_INSTRUCTION_MISALIGNMENT // // MessageText: // // An attempt was made to execute an instruction at an unaligned address and // the host system does not support unaligned instruction references. // public static final int ERROR_INSTRUCTION_MISALIGNMENT = 549; // // MessageId: ERROR_PROFILING_NOT_STARTED // // MessageText: // // Profiling not started. // public static final int ERROR_PROFILING_NOT_STARTED = 550; // // MessageId: ERROR_PROFILING_NOT_STOPPED // // MessageText: // // Profiling not stopped. // public static final int ERROR_PROFILING_NOT_STOPPED = 551; // // MessageId: ERROR_COULD_NOT_INTERPRET // // MessageText: // // The passed ACL did not contain the minimum required information. // public static final int ERROR_COULD_NOT_INTERPRET = 552; // // MessageId: ERROR_PROFILING_AT_LIMIT // // MessageText: // // The number of active profiling objects is at the maximum and no more may // be started. // public static final int ERROR_PROFILING_AT_LIMIT = 553; // // MessageId: ERROR_CANT_WAIT // // MessageText: // // Used to indicate that an operation cannot continue without blocking for // I/O. // public static final int ERROR_CANT_WAIT = 554; // // MessageId: ERROR_CANT_TERMINATE_SELF // // MessageText: // // Indicates that a thread attempted to terminate itself by default (called // NtTerminateThread with NUL; and it was the last thread in the current // process. // public static final int ERROR_CANT_TERMINATE_SELF = 555; // // MessageId: ERROR_UNEXPECTED_MM_CREATE_ERR // // MessageText: // // If an MM error is returned which is not defined in the standard FsRtl // filter, it is converted to one of the following errors which is // guaranteed to be in the filter. // In this case information is lost, however, the filter correctly handles // the exception. // public static final int ERROR_UNEXPECTED_MM_CREATE_ERR = 556; // // MessageId: ERROR_UNEXPECTED_MM_MAP_ERROR // // MessageText: // // If an MM error is returned which is not defined in the standard FsRtl // filter, it is converted to one of the following errors which is // guaranteed to be in the filter. // In this case information is lost, however, the filter correctly handles // the exception. // public static final int ERROR_UNEXPECTED_MM_MAP_ERROR = 557; // // MessageId: ERROR_UNEXPECTED_MM_EXTEND_ERR // // MessageText: // // If an MM error is returned which is not defined in the standard FsRtl // filter, it is converted to one of the following errors which is // guaranteed to be in the filter. // In this case information is lost, however, the filter correctly handles // the exception. // public static final int ERROR_UNEXPECTED_MM_EXTEND_ERR = 558; // // MessageId: ERROR_BAD_FUNCTION_TABLE // // MessageText: // // A malformed function table was encountered during an unwind operation. // public static final int ERROR_BAD_FUNCTION_TABLE = 559; // // MessageId: ERROR_NO_GUID_TRANSLATION // // MessageText: // // Indicates that an attempt was made to assign protection to a file system // file or directory and one of the SIDs in the security descriptor could // not be translated into a GUID that could be stored by the file system. // This causes the protection attempt to fail, which may cause a file // creation attempt to fail. // public static final int ERROR_NO_GUID_TRANSLATION = 560; // // MessageId: ERROR_INVALID_LDT_SIZE // // MessageText: // // Indicates that an attempt was made to grow an LDT by setting its size, or // that the size was not an even number of selectors. // public static final int ERROR_INVALID_LDT_SIZE = 561; // // MessageId: ERROR_INVALID_LDT_OFFSET // // MessageText: // // Indicates that the starting value for the LDT information was not an // integral multiple of the selector size. // public static final int ERROR_INVALID_LDT_OFFSET = 563; // // MessageId: ERROR_INVALID_LDT_DESCRIPTOR // // MessageText: // // Indicates that the user supplied an invalid descriptor when trying to set // up Ldt descriptors. // public static final int ERROR_INVALID_LDT_DESCRIPTOR = 564; // // MessageId: ERROR_TOO_MANY_THREADS // // MessageText: // // Indicates a process has too many threads to perform the requested action. // For example, assignment of a primary token may only be performed when a // process has zero or one threads. // public static final int ERROR_TOO_MANY_THREADS = 565; // // MessageId: ERROR_THREAD_NOT_IN_PROCESS // // MessageText: // // An attempt was made to operate on a thread within a specific process, but // the thread specified is not in the process specified. // public static final int ERROR_THREAD_NOT_IN_PROCESS = 566; // // MessageId: ERROR_PAGEFILE_QUOTA_EXCEEDED // // MessageText: // // Page file quota was exceeded. // public static final int ERROR_PAGEFILE_QUOTA_EXCEEDED = 567; // // MessageId: ERROR_LOGON_SERVER_CONFLICT // // MessageText: // // The Netlogon service cannot start because another Netlogon service // running in the domain conflicts with the specified role. // public static final int ERROR_LOGON_SERVER_CONFLICT = 568; // // MessageId: ERROR_SYNCHRONIZATION_REQUIRED // // MessageText: // // The SAM database on a Windows Server is significantly out of // synchronization with the copy on the Domain Controller. A complete // synchronization is required. // public static final int ERROR_SYNCHRONIZATION_REQUIRED = 569; // // MessageId: ERROR_NET_OPEN_FAILED // // MessageText: // // The NtCreateFile API failed. This error should never be returned to an // application, it is a place holder for the Windows Lan Manager Redirector // to use in its internal error mapping routines. // public static final int ERROR_NET_OPEN_FAILED = 570; // // MessageId: ERROR_IO_PRIVILEGE_FAILED // // MessageText: // // {Privilege Failed} // The I/O permissions for the process could not be changed. // public static final int ERROR_IO_PRIVILEGE_FAILED = 571; // // MessageId: ERROR_CONTROL_C_EXIT // // MessageText: // // {Application Exit by CTRL+C} // The application terminated as a result of a CTRL+C. // public static final int ERROR_CONTROL_C_EXIT = 572; // winnt // // MessageId: ERROR_MISSING_SYSTEMFILE // // MessageText: // // {Missing System File} // The required system file %hs is bad or missing. // public static final int ERROR_MISSING_SYSTEMFILE = 573; // // MessageId: ERROR_UNHANDLED_EXCEPTION // // MessageText: // // {Application Error} // The exception %s (0x%08;x) occurred in the application at location // 0x%08;x. // public static final int ERROR_UNHANDLED_EXCEPTION = 574; // // MessageId: ERROR_APP_INIT_FAILURE // // MessageText: // // {Application Error} // The application failed to initialize properly (0x%lx). Click OK to // terminate the application. // public static final int ERROR_APP_INIT_FAILURE = 575; // // MessageId: ERROR_PAGEFILE_CREATE_FAILED // // MessageText: // // {Unable to Create Paging File} // The creation of the paging file %hs failed (%lx). The requested size was // %ld. // public static final int ERROR_PAGEFILE_CREATE_FAILED = 576; // // MessageId: ERROR_INVALID_IMAGE_HASH // // MessageText: // // Windows cannot verify the digital signature for this file. A recent // hardware or software change might have installed a file that is signed // incorrectly or damaged, or that might be malicious software from an // unknown source. // public static final int ERROR_INVALID_IMAGE_HASH = 577; // // MessageId: ERROR_NO_PAGEFILE // // MessageText: // // {No Paging File Specified} // No paging file was specified in the system configuration. // public static final int ERROR_NO_PAGEFILE = 578; // // MessageId: ERROR_ILLEGAL_FLOAT_CONTEXT // // MessageText: // // {EXCEPTION} // A real-mode application issued a floating-point instruction and // floating-point hardware is not present. // public static final int ERROR_ILLEGAL_FLOAT_CONTEXT = 579; // // MessageId: ERROR_NO_EVENT_PAIR // // MessageText: // // An event pair synchronization operation was performed using the thread // specific client/server event pair object, but no event pair object was // associated with the thread. // public static final int ERROR_NO_EVENT_PAIR = 580; // // MessageId: ERROR_DOMAIN_CTRLR_CONFIG_ERROR // // MessageText: // // A Windows Server has an incorrect configuration. // public static final int ERROR_DOMAIN_CTRLR_CONFIG_ERROR = 581; // // MessageId: ERROR_ILLEGAL_CHARACTER // // MessageText: // // An illegal character was encountered. For a multi-byte character set this // includes a lead byte without a succeeding trail byte. For the Unicode // character set this includes the characters 0xFFFF and 0xFFFE. // public static final int ERROR_ILLEGAL_CHARACTER = 582; // // MessageId: ERROR_UNDEFINED_CHARACTER // // MessageText: // // The Unicode character is not defined in the Unicode character set // installed on the system. // public static final int ERROR_UNDEFINED_CHARACTER = 583; // // MessageId: ERROR_FLOPPY_VOLUME // // MessageText: // // The paging file cannot be created on a floppy diskette. // public static final int ERROR_FLOPPY_VOLUME = 584; // // MessageId: ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT // // MessageText: // // The system BIOS failed to connect a system interrupt to the device or bus // for which the device is connected. // public static final int ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT = 585; // // MessageId: ERROR_BACKUP_CONTROLLER // // MessageText: // // This operation is only allowed for the Primary Domain Controller of the // domain. // public static final int ERROR_BACKUP_CONTROLLER = 586; // // MessageId: ERROR_MUTANT_LIMIT_EXCEEDED // // MessageText: // // An attempt was made to acquire a mutant such that its maximum count would // have been exceeded. // public static final int ERROR_MUTANT_LIMIT_EXCEEDED = 587; // // MessageId: ERROR_FS_DRIVER_REQUIRED // // MessageText: // // A volume has been accessed for which a file system driver is required // that has not yet been loaded. // public static final int ERROR_FS_DRIVER_REQUIRED = 588; // // MessageId: ERROR_CANNOT_LOAD_REGISTRY_FILE // // MessageText: // // {Registry File Failure} // The registry cannot load the hive (file): // %hs // or its log or alternate. // It is corrupt, absent, or not writable. // public static final int ERROR_CANNOT_LOAD_REGISTRY_FILE = 589; // // MessageId: ERROR_DEBUG_ATTACH_FAILED // // MessageText: // // {Unexpected Failure in DebugActiveProcess} // An unexpected failure occurred while processing a DebugActiveProcess API // request. You may choose OK to terminate the process, or Cancel to ignore // the error. // public static final int ERROR_DEBUG_ATTACH_FAILED = 590; // // MessageId: ERROR_SYSTEM_PROCESS_TERMINATED // // MessageText: // // {Fatal System Error} // The %hs system process terminated unexpectedly with a status of 0x%08x // (0x%08x 0x%08x). // The system has been shut down. // public static final int ERROR_SYSTEM_PROCESS_TERMINATED = 591; // // MessageId: ERROR_DATA_NOT_ACCEPTED // // MessageText: // // {Data Not Accepted} // The TDI client could not handle the data received during an indication. // public static final int ERROR_DATA_NOT_ACCEPTED = 592; // // MessageId: ERROR_VDM_HARD_ERROR // // MessageText: // // NTVDM encountered a hard error. // public static final int ERROR_VDM_HARD_ERROR = 593; // // MessageId: ERROR_DRIVER_CANCEL_TIMEOUT // // MessageText: // // {Cancel Timeout} // The driver %hs failed to complete a cancelled I/O request in the allotted // time. // public static final int ERROR_DRIVER_CANCEL_TIMEOUT = 594; // // MessageId: ERROR_REPLY_MESSAGE_MISMATCH // // MessageText: // // {Reply Message Mismatch} // An attempt was made to reply to an LPC message, but the thread specified // by the client ID in the message was not waiting on that message. // public static final int ERROR_REPLY_MESSAGE_MISMATCH = 595; // // MessageId: ERROR_LOST_WRITEBEHIND_DATA // // MessageText: // // {Delayed Write Failed} // Windows was unable to save all the data for the file %hs. The data has // been lost. // This error may be caused by a failure of your computer hardware or // network connection. Please try to save this file elsewhere. // public static final int ERROR_LOST_WRITEBEHIND_DATA = 596; // // MessageId: ERROR_CLIENT_SERVER_PARAMETERS_INVALID // // MessageText: // // The parameter(s) passed to the server in the client/server shared memory // window were invalid. Too much data may have been put in the shared memory // window. // public static final int ERROR_CLIENT_SERVER_PARAMETERS_INVALID = 597; // // MessageId: ERROR_NOT_TINY_STREAM // // MessageText: // // The stream is not a tiny stream. // public static final int ERROR_NOT_TINY_STREAM = 598; // // MessageId: ERROR_STACK_OVERFLOW_READ // // MessageText: // // The request must be handled by the stack overflow code. // public static final int ERROR_STACK_OVERFLOW_READ = 599; // // MessageId: ERROR_CONVERT_TO_LARGE // // MessageText: // // Internal OFS status codes indicating how an allocation operation is // handled. Either it is retried after the containing onode is moved or the // extent stream is converted to a large stream. // public static final int ERROR_CONVERT_TO_LARGE = 600; // // MessageId: ERROR_FOUND_OUT_OF_SCOPE // // MessageText: // // The attempt to find the object found an object matching by ID on the // volume but it is out of the scope of the handle used for the operation. // public static final int ERROR_FOUND_OUT_OF_SCOPE = 601; // // MessageId: ERROR_ALLOCATE_BUCKET // // MessageText: // // The bucket array must be grown. Retry transaction after doing so. // public static final int ERROR_ALLOCATE_BUCKET = 602; // // MessageId: ERROR_MARSHALL_OVERFLOW // // MessageText: // // The user/kernel marshalling buffer has overflowed. // public static final int ERROR_MARSHALL_OVERFLOW = 603; // // MessageId: ERROR_INVALID_VARIANT // // MessageText: // // The supplied variant structure contains invalid data. // public static final int ERROR_INVALID_VARIANT = 604; // // MessageId: ERROR_BAD_COMPRESSION_BUFFER // // MessageText: // // The specified buffer contains ill-formed data. // public static final int ERROR_BAD_COMPRESSION_BUFFER = 605; // // MessageId: ERROR_AUDIT_FAILED // // MessageText: // // {Audit Failed} // An attempt to generate a security audit failed. // public static final int ERROR_AUDIT_FAILED = 606; // // MessageId: ERROR_TIMER_RESOLUTION_NOT_SET // // MessageText: // // The timer resolution was not previously set by the current process. // public static final int ERROR_TIMER_RESOLUTION_NOT_SET = 607; // // MessageId: ERROR_INSUFFICIENT_LOGON_INFO // // MessageText: // // There is insufficient account information to log you on. // public static final int ERROR_INSUFFICIENT_LOGON_INFO = 608; // // MessageId: ERROR_BAD_DLL_ENTRYPOINT // // MessageText: // // {Invalid DLL Entrypoint} // The dynamic link library %hs is not written correctly. The stack pointer // has been left in an inconsistent state. // The entrypoint should be declared as WINAPI or STDCALL. Select YES to // fail the DLL load. Select NO to continue execution. Selecting NO may // cause the application to operate incorrectly. // public static final int ERROR_BAD_DLL_ENTRYPOINT = 609; // // MessageId: ERROR_BAD_SERVICE_ENTRYPOINT // // MessageText: // // {Invalid Service Callback Entrypoint} // The %hs service is not written correctly. The stack pointer has been left // in an inconsistent state. // The callback entrypoint should be declared as WINAPI or STDCALL. // Selecting OK will cause the service to continue operation. However, the // service process may operate incorrectly. // public static final int ERROR_BAD_SERVICE_ENTRYPOINT = 610; // // MessageId: ERROR_IP_ADDRESS_CONFLICT1 // // MessageText: // // There is an IP address conflict with another system on the network // public static final int ERROR_IP_ADDRESS_CONFLICT1 = 611; // // MessageId: ERROR_IP_ADDRESS_CONFLICT2 // // MessageText: // // There is an IP address conflict with another system on the network // public static final int ERROR_IP_ADDRESS_CONFLICT2 = 612; // // MessageId: ERROR_REGISTRY_QUOTA_LIMIT // // MessageText: // // {Low On Registry Space} // The system has reached the maximum size allowed for the system part of // the registry. Additional storage requests will be ignored. // public static final int ERROR_REGISTRY_QUOTA_LIMIT = 613; // // MessageId: ERROR_NO_CALLBACK_ACTIVE // // MessageText: // // A callback return system service cannot be executed when no callback is // active. // public static final int ERROR_NO_CALLBACK_ACTIVE = 614; // // MessageId: ERROR_PWD_TOO_SHORT // // MessageText: // // The password provided is too short to meet the policy of your user // account. // Please choose a longer password. // public static final int ERROR_PWD_TOO_SHORT = 615; // // MessageId: ERROR_PWD_TOO_RECENT // // MessageText: // // The policy of your user account does not allow you to change passwords // too frequently. // This is done to prevent users from changing back to a familiar, but // potentially discovered, password. // If you feel your password has been compromised then please contact your // administrator immediately to have a new one assigned. // public static final int ERROR_PWD_TOO_RECENT = 616; // // MessageId: ERROR_PWD_HISTORY_CONFLICT // // MessageText: // // You have attempted to change your password to one that you have used in // the past. // The policy of your user account does not allow this. Please select a // password that you have not previously used. // public static final int ERROR_PWD_HISTORY_CONFLICT = 617; // // MessageId: ERROR_UNSUPPORTED_COMPRESSION // // MessageText: // // The specified compression format is unsupported. // public static final int ERROR_UNSUPPORTED_COMPRESSION = 618; // // MessageId: ERROR_INVALID_HW_PROFILE // // MessageText: // // The specified hardware profile configuration is invalid. // public static final int ERROR_INVALID_HW_PROFILE = 619; // // MessageId: ERROR_INVALID_PLUGPLAY_DEVICE_PATH // // MessageText: // // The specified Plug and Play registry device path is invalid. // public static final int ERROR_INVALID_PLUGPLAY_DEVICE_PATH = 620; // // MessageId: ERROR_QUOTA_LIST_INCONSISTENT // // MessageText: // // The specified quota list is internally inconsistent with its descriptor. // public static final int ERROR_QUOTA_LIST_INCONSISTENT = 621; // // MessageId: ERROR_EVALUATION_EXPIRATION // // MessageText: // // {Windows Evaluation Notification} // The evaluation period for this installation of Windows has expired. This // system will shutdown in=1 hour. To restore access to this installation of // Windows, please upgrade this installation using a licensed distribution // of this product. // public static final int ERROR_EVALUATION_EXPIRATION = 622; // // MessageId: ERROR_ILLEGAL_DLL_RELOCATION // // MessageText: // // {Illegal System DLL Relocation} // The system DLL %hs was relocated in memory. The application will not run // properly. // The relocation occurred because the DLL %hs occupied an address range // reserved for Windows system DLLs. The vendor supplying the DLL should be // contacted for a new DLL. // public static final int ERROR_ILLEGAL_DLL_RELOCATION = 623; // // MessageId: ERROR_DLL_INIT_FAILED_LOGOFF // // MessageText: // // {DLL Initialization Failed} // The application failed to initialize because the window station is // shutting down. // public static final int ERROR_DLL_INIT_FAILED_LOGOFF = 624; // // MessageId: ERROR_VALIDATE_CONTINUE // // MessageText: // // The validation process needs to continue on to the next step. // public static final int ERROR_VALIDATE_CONTINUE = 625; // // MessageId: ERROR_NO_MORE_MATCHES // // MessageText: // // There are no more matches for the current index enumeration. // public static final int ERROR_NO_MORE_MATCHES = 626; // // MessageId: ERROR_RANGE_LIST_CONFLICT // // MessageText: // // The range could not be added to the range list because of a conflict. // public static final int ERROR_RANGE_LIST_CONFLICT = 627; // // MessageId: ERROR_SERVER_SID_MISMATCH // // MessageText: // // The server process is running under a SID different than that required by // client. // public static final int ERROR_SERVER_SID_MISMATCH = 628; // // MessageId: ERROR_CANT_ENABLE_DENY_ONLY // // MessageText: // // A group marked use for deny only cannot be enabled. // public static final int ERROR_CANT_ENABLE_DENY_ONLY = 629; // // MessageId: ERROR_FLOAT_MULTIPLE_FAULTS // // MessageText: // // {EXCEPTION} // Multiple floating point faults. // public static final int ERROR_FLOAT_MULTIPLE_FAULTS = 630; // winnt // // MessageId: ERROR_FLOAT_MULTIPLE_TRAPS // // MessageText: // // {EXCEPTION} // Multiple floating point traps. // public static final int ERROR_FLOAT_MULTIPLE_TRAPS = 631; // winnt // // MessageId: ERROR_NOINTERFACE // // MessageText: // // The requested interface is not supported. // public static final int ERROR_NOINTERFACE = 632; // // MessageId: ERROR_DRIVER_FAILED_SLEEP // // MessageText: // // {System Standby Failed} // The driver %hs does not support standby mode. Updating this driver may // allow the system to go to standby mode. // public static final int ERROR_DRIVER_FAILED_SLEEP = 633; // // MessageId: ERROR_CORRUPT_SYSTEM_FILE // // MessageText: // // The system file %1 has become corrupt and has been replaced. // public static final int ERROR_CORRUPT_SYSTEM_FILE = 634; // // MessageId: ERROR_COMMITMENT_MINIMUM // // MessageText: // // {Virtual Memory Minimum Too Low} // Your system is low on virtual memory. Windows is increasing the size of // your virtual memory paging file. // During this process, memory requests for some applications may be denied. // For more information, see Help. // public static final int ERROR_COMMITMENT_MINIMUM = 635; // // MessageId: ERROR_PNP_RESTART_ENUMERATION // // MessageText: // // A device was removed so enumeration must be restarted. // public static final int ERROR_PNP_RESTART_ENUMERATION = 636; // // MessageId: ERROR_SYSTEM_IMAGE_BAD_SIGNATURE // // MessageText: // // {Fatal System Error} // The system image %s is not properly signed. // The file has been replaced with the signed file. // The system has been shut down. // public static final int ERROR_SYSTEM_IMAGE_BAD_SIGNATURE = 637; // // MessageId: ERROR_PNP_REBOOT_REQUIRED // // MessageText: // // Device will not start without a reboot. // public static final int ERROR_PNP_REBOOT_REQUIRED = 638; // // MessageId: ERROR_INSUFFICIENT_POWER // // MessageText: // // There is not enough power to complete the requested operation. // public static final int ERROR_INSUFFICIENT_POWER = 639; // // MessageId: ERROR_MULTIPLE_FAULT_VIOLATION // // MessageText: // // ERROR_MULTIPLE_FAULT_VIOLATION // public static final int ERROR_MULTIPLE_FAULT_VIOLATION = 640; // // MessageId: ERROR_SYSTEM_SHUTDOWN // // MessageText: // // The system is in the process of shutting down. // public static final int ERROR_SYSTEM_SHUTDOWN = 641; // // MessageId: ERROR_PORT_NOT_SET // // MessageText: // // An attempt to remove a processes DebugPort was made, but a port was not // already associated with the process. // public static final int ERROR_PORT_NOT_SET = 642; // // MessageId: ERROR_DS_VERSION_CHECK_FAILURE // // MessageText: // // This version of Windows is not compatible with the behavior version of // directory forest, domain or domain controller. // public static final int ERROR_DS_VERSION_CHECK_FAILURE = 643; // // MessageId: ERROR_RANGE_NOT_FOUND // // MessageText: // // The specified range could not be found in the range list. // public static final int ERROR_RANGE_NOT_FOUND = 644; // // MessageId: ERROR_NOT_SAFE_MODE_DRIVER // // MessageText: // // The driver was not loaded because the system is booting into safe mode. // public static final int ERROR_NOT_SAFE_MODE_DRIVER = 646; // // MessageId: ERROR_FAILED_DRIVER_ENTRY // // MessageText: // // The driver was not loaded because it failed it's initialization call. // public static final int ERROR_FAILED_DRIVER_ENTRY = 647; // // MessageId: ERROR_DEVICE_ENUMERATION_ERROR // // MessageText: // // The "%hs" encountered an error while applying power or reading the device // configuration. // This may be caused by a failure of your hardware or by a poor connection. // public static final int ERROR_DEVICE_ENUMERATION_ERROR = 648; // // MessageId: ERROR_MOUNT_POINT_NOT_RESOLVED // // MessageText: // // The create operation failed because the name contained at least one mount // point which resolves to a volume to which the specified device object is // not attached. // public static final int ERROR_MOUNT_POINT_NOT_RESOLVED = 649; // // MessageId: ERROR_INVALID_DEVICE_OBJECT_PARAMETER // // MessageText: // // The device object parameter is either not a valid device object or is not // attached to the volume specified by the file name. // public static final int ERROR_INVALID_DEVICE_OBJECT_PARAMETER = 650; // // MessageId: ERROR_MCA_OCCURED // // MessageText: // // A Machine Check Error has occurred. Please check the system eventlog for // additional information. // public static final int ERROR_MCA_OCCURED = 651; // // MessageId: ERROR_DRIVER_DATABASE_ERROR // // MessageText: // // There was error [%2] processing the driver database. // public static final int ERROR_DRIVER_DATABASE_ERROR = 652; // // MessageId: ERROR_SYSTEM_HIVE_TOO_LARGE // // MessageText: // // System hive size has exceeded its limit. // public static final int ERROR_SYSTEM_HIVE_TOO_LARGE = 653; // // MessageId: ERROR_DRIVER_FAILED_PRIOR_UNLOAD // // MessageText: // // The driver could not be loaded because a previous version of the driver // is still in memory. // public static final int ERROR_DRIVER_FAILED_PRIOR_UNLOAD = 654; // // MessageId: ERROR_VOLSNAP_PREPARE_HIBERNATE // // MessageText: // // {Volume Shadow Copy Service} // Please wait while the Volume Shadow Copy Service prepares volume %hs for // hibernation. // public static final int ERROR_VOLSNAP_PREPARE_HIBERNATE = 655; // // MessageId: ERROR_HIBERNATION_FAILURE // // MessageText: // // The system has failed to hibernate (The error code is %hs). Hibernation // will be disabled until the system is restarted. // public static final int ERROR_HIBERNATION_FAILURE = 656; // // MessageId: ERROR_FILE_SYSTEM_LIMITATION // // MessageText: // // The requested operation could not be completed due to a file system // limitation // public static final int ERROR_FILE_SYSTEM_LIMITATION = 665; // // MessageId: ERROR_ASSERTION_FAILURE // // MessageText: // // An assertion failure has occurred. // public static final int ERROR_ASSERTION_FAILURE = 668; // // MessageId: ERROR_ACPI_ERROR // // MessageText: // // An error occurred in the ACPI subsystem. // public static final int ERROR_ACPI_ERROR = 669; // // MessageId: ERROR_WOW_ASSERTION // // MessageText: // // WOW Assertion Error. // public static final int ERROR_WOW_ASSERTION = 670; // // MessageId: ERROR_PNP_BAD_MPS_TABLE // // MessageText: // // A device is missing in the system BIOS MPS table. This device will not be // used. // Please contact your system vendor for system BIOS update. // public static final int ERROR_PNP_BAD_MPS_TABLE = 671; // // MessageId: ERROR_PNP_TRANSLATION_FAILED // // MessageText: // // A translator failed to translate resources. // public static final int ERROR_PNP_TRANSLATION_FAILED = 672; // // MessageId: ERROR_PNP_IRQ_TRANSLATION_FAILED // // MessageText: // // A IRQ translator failed to translate resources. // public static final int ERROR_PNP_IRQ_TRANSLATION_FAILED = 673; // // MessageId: ERROR_PNP_INVALID_ID // // MessageText: // // Driver %2 returned invalid ID for a child device (%3). // public static final int ERROR_PNP_INVALID_ID = 674; // // MessageId: ERROR_WAKE_SYSTEM_DEBUGGER // // MessageText: // // {Kernel Debugger Awakened} // the system debugger was awakened by an interrupt. // public static final int ERROR_WAKE_SYSTEM_DEBUGGER = 675; // // MessageId: ERROR_HANDLES_CLOSED // // MessageText: // // {Handles Closed} // Handles to objects have been automatically closed as a result of the // requested operation. // public static final int ERROR_HANDLES_CLOSED = 676; // // MessageId: ERROR_EXTRANEOUS_INFORMATION // // MessageText: // // {Too Much Information} // The specified access control list (AC; contained more information than // was expected. // public static final int ERROR_EXTRANEOUS_INFORMATION = 677; // // MessageId: ERROR_RXACT_COMMIT_NECESSARY // // MessageText: // // This warning level status indicates that the transaction state already // exists for the registry sub-tree, but that a transaction commit was // previously aborted. // The commit has NOT been completed, but has not been rolled back either // (so it may still be committed if desired). // public static final int ERROR_RXACT_COMMIT_NECESSARY = 678; // // MessageId: ERROR_MEDIA_CHECK // // MessageText: // // {Media Changed} // The media may have changed. // public static final int ERROR_MEDIA_CHECK = 679; // // MessageId: ERROR_GUID_SUBSTITUTION_MADE // // MessageText: // // {GUID Substitution} // During the translation of a global identifier (GUID) to a Windows // security ID (SID), no administratively-defined GUID prefix was found. // A substitute prefix was used, which will not compromise system security. // However, this may provide a more restrictive access than intended. // public static final int ERROR_GUID_SUBSTITUTION_MADE = 680; // // MessageId: ERROR_STOPPED_ON_SYMLINK // // MessageText: // // The create operation stopped after reaching a symbolic link // public static final int ERROR_STOPPED_ON_SYMLINK = 681; // // MessageId: ERROR_LONGJUMP // // MessageText: // // A long jump has been executed. // public static final int ERROR_LONGJUMP = 682; // // MessageId: ERROR_PLUGPLAY_QUERY_VETOED // // MessageText: // // The Plug and Play query operation was not successful. // public static final int ERROR_PLUGPLAY_QUERY_VETOED = 683; // // MessageId: ERROR_UNWIND_CONSOLIDATE // // MessageText: // // A frame consolidation has been executed. // public static final int ERROR_UNWIND_CONSOLIDATE = 684; // // MessageId: ERROR_REGISTRY_HIVE_RECOVERED // // MessageText: // // {Registry Hive Recovered} // Registry hive (file): // %hs // was corrupted and it has been recovered. Some data might have been lost. // public static final int ERROR_REGISTRY_HIVE_RECOVERED = 685; // // MessageId: ERROR_DLL_MIGHT_BE_INSECURE // // MessageText: // // The application is attempting to run executable code from the module %hs. // This may be insecure. An alternative, %hs, is available. Should the // application use the secure module %hs? // public static final int ERROR_DLL_MIGHT_BE_INSECURE = 686; // // MessageId: ERROR_DLL_MIGHT_BE_INCOMPATIBLE // // MessageText: // // The application is loading executable code from the module %hs. This is // secure, but may be incompatible with previous releases of the operating // system. An alternative, %hs, is available. Should the application use the // secure module %hs? // public static final int ERROR_DLL_MIGHT_BE_INCOMPATIBLE = 687; // // MessageId: ERROR_DBG_EXCEPTION_NOT_HANDLED // // MessageText: // // Debugger did not handle the exception. // public static final int ERROR_DBG_EXCEPTION_NOT_HANDLED = 688; // winnt // // MessageId: ERROR_DBG_REPLY_LATER // // MessageText: // // Debugger will reply later. // public static final int ERROR_DBG_REPLY_LATER = 689; // // MessageId: ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE // // MessageText: // // Debugger cannot provide handle. // public static final int ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE = 690; // // MessageId: ERROR_DBG_TERMINATE_THREAD // // MessageText: // // Debugger terminated thread. // public static final int ERROR_DBG_TERMINATE_THREAD = 691; // winnt // // MessageId: ERROR_DBG_TERMINATE_PROCESS // // MessageText: // // Debugger terminated process. // public static final int ERROR_DBG_TERMINATE_PROCESS = 692; // winnt // // MessageId: ERROR_DBG_CONTROL_C // // MessageText: // // Debugger got control C. // public static final int ERROR_DBG_CONTROL_C = 693; // winnt // // MessageId: ERROR_DBG_PRINTEXCEPTION_C // // MessageText: // // Debugger printed exception on control C. // public static final int ERROR_DBG_PRINTEXCEPTION_C = 694; // // MessageId: ERROR_DBG_RIPEXCEPTION // // MessageText: // // Debugger received RIP exception. // public static final int ERROR_DBG_RIPEXCEPTION = 695; // // MessageId: ERROR_DBG_CONTROL_BREAK // // MessageText: // // Debugger received control break. // public static final int ERROR_DBG_CONTROL_BREAK = 696; // winnt // // MessageId: ERROR_DBG_COMMAND_EXCEPTION // // MessageText: // // Debugger command communication exception. // public static final int ERROR_DBG_COMMAND_EXCEPTION = 697; // winnt // // MessageId: ERROR_OBJECT_NAME_EXISTS // // MessageText: // // {Object Exists} // An attempt was made to create an object and the object name already // existed. // public static final int ERROR_OBJECT_NAME_EXISTS = 698; // // MessageId: ERROR_THREAD_WAS_SUSPENDED // // MessageText: // // {Thread Suspended} // A thread termination occurred while the thread was suspended. The thread // was resumed, and termination proceeded. // public static final int ERROR_THREAD_WAS_SUSPENDED = 699; // // MessageId: ERROR_IMAGE_NOT_AT_BASE // // MessageText: // // {Image Relocated} // An image file could not be mapped at the address specified in the image // file. Local fixups must be performed on this image. // public static final int ERROR_IMAGE_NOT_AT_BASE = 700; // // MessageId: ERROR_RXACT_STATE_CREATED // // MessageText: // // This informational level status indicates that a specified registry // sub-tree transaction state did not yet exist and had to be created. // public static final int ERROR_RXACT_STATE_CREATED = 701; // // MessageId: ERROR_SEGMENT_NOTIFICATION // // MessageText: // // {Segment Load} // A virtual DOS machine (VDM) is loading, unloading, or moving an MS-DOS or // Win16 program segment image. // An exception is raised so a debugger can load, unload or track symbols // and breakpoints within these=16-bit segments. // public static final int ERROR_SEGMENT_NOTIFICATION = 702; // winnt // // MessageId: ERROR_BAD_CURRENT_DIRECTORY // // MessageText: // // {Invalid Current Directory} // The process cannot switch to the startup current directory %hs. // Select OK to set current directory to %hs, or select CANCEL to exit. // public static final int ERROR_BAD_CURRENT_DIRECTORY = 703; // // MessageId: ERROR_FT_READ_RECOVERY_FROM_BACKUP // // MessageText: // // {Redundant Read} // To satisfy a read request, the NT fault-tolerant file system successfully // read the requested data from a redundant copy. // This was done because the file system encountered a failure on a member // of the fault-tolerant volume, but was unable to reassign the failing area // of the device. // public static final int ERROR_FT_READ_RECOVERY_FROM_BACKUP = 704; // // MessageId: ERROR_FT_WRITE_RECOVERY // // MessageText: // // {Redundant Write} // To satisfy a write request, the NT fault-tolerant file system // successfully wrote a redundant copy of the information. // This was done because the file system encountered a failure on a member // of the fault-tolerant volume, but was not able to reassign the failing // area of the device. // public static final int ERROR_FT_WRITE_RECOVERY = 705; // // MessageId: ERROR_IMAGE_MACHINE_TYPE_MISMATCH // // MessageText: // // {Machine Type Mismatch} // The image file %hs is valid, but is for a machine type other than the // current machine. Select OK to continue, or CANCEL to fail the DLL load. // public static final int ERROR_IMAGE_MACHINE_TYPE_MISMATCH = 706; // // MessageId: ERROR_RECEIVE_PARTIAL // // MessageText: // // {Partial Data Received} // The network transport returned partial data to its client. The remaining // data will be sent later. // public static final int ERROR_RECEIVE_PARTIAL = 707; // // MessageId: ERROR_RECEIVE_EXPEDITED // // MessageText: // // {Expedited Data Received} // The network transport returned data to its client that was marked as // expedited by the remote system. // public static final int ERROR_RECEIVE_EXPEDITED = 708; // // MessageId: ERROR_RECEIVE_PARTIAL_EXPEDITED // // MessageText: // // {Partial Expedited Data Received} // The network transport returned partial data to its client and this data // was marked as expedited by the remote system. The remaining data will be // sent later. // public static final int ERROR_RECEIVE_PARTIAL_EXPEDITED = 709; // // MessageId: ERROR_EVENT_DONE // // MessageText: // // {TDI Event Done} // The TDI indication has completed successfully. // public static final int ERROR_EVENT_DONE = 710; // // MessageId: ERROR_EVENT_PENDING // // MessageText: // // {TDI Event Pending} // The TDI indication has entered the pending state. // public static final int ERROR_EVENT_PENDING = 711; // // MessageId: ERROR_CHECKING_FILE_SYSTEM // // MessageText: // // Checking file system on %wZ // public static final int ERROR_CHECKING_FILE_SYSTEM = 712; // // MessageId: ERROR_FATAL_APP_EXIT // // MessageText: // // {Fatal Application Exit} // %hs // public static final int ERROR_FATAL_APP_EXIT = 713; // // MessageId: ERROR_PREDEFINED_HANDLE // // MessageText: // // The specified registry key is referenced by a predefined handle. // public static final int ERROR_PREDEFINED_HANDLE = 714; // // MessageId: ERROR_WAS_UNLOCKED // // MessageText: // // {Page Unlocked} // The page protection of a locked page was changed to 'No Access' and the // page was unlocked from memory and from the process. // public static final int ERROR_WAS_UNLOCKED = 715; // // MessageId: ERROR_SERVICE_NOTIFICATION // // MessageText: // // %hs // public static final int ERROR_SERVICE_NOTIFICATION = 716; // // MessageId: ERROR_WAS_LOCKED // // MessageText: // // {Page Locked} // One of the pages to lock was already locked. // public static final int ERROR_WAS_LOCKED = 717; // // MessageId: ERROR_LOG_HARD_ERROR // // MessageText: // // Application popup: %1 : %2 // public static final int ERROR_LOG_HARD_ERROR = 718; // // MessageId: ERROR_ALREADY_WIN32 // // MessageText: // // ERROR_ALREADY_WIN32 // public static final int ERROR_ALREADY_WIN32 = 719; // // MessageId: ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE // // MessageText: // // {Machine Type Mismatch} // The image file %hs is valid, but is for a machine type other than the // current machine. // public static final int ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE = 720; // // MessageId: ERROR_NO_YIELD_PERFORMED // // MessageText: // // A yield execution was performed and no thread was available to run. // public static final int ERROR_NO_YIELD_PERFORMED = 721; // // MessageId: ERROR_TIMER_RESUME_IGNORED // // MessageText: // // The resumable flag to a timer API was ignored. // public static final int ERROR_TIMER_RESUME_IGNORED = 722; // // MessageId: ERROR_ARBITRATION_UNHANDLED // // MessageText: // // The arbiter has deferred arbitration of these resources to its parent // public static final int ERROR_ARBITRATION_UNHANDLED = 723; // // MessageId: ERROR_CARDBUS_NOT_SUPPORTED // // MessageText: // // The inserted CardBus device cannot be started because of a configuration // error on "%hs". // public static final int ERROR_CARDBUS_NOT_SUPPORTED = 724; // // MessageId: ERROR_MP_PROCESSOR_MISMATCH // // MessageText: // // The CPUs in this multiprocessor system are not all the same revision // level. To use all processors the operating system restricts itself to the // features of the least capable processor in the system. Should problems // occur with this system, contact the CPU manufacturer to see if this mix // of processors is supported. // public static final int ERROR_MP_PROCESSOR_MISMATCH = 725; // // MessageId: ERROR_HIBERNATED // // MessageText: // // The system was put into hibernation. // public static final int ERROR_HIBERNATED = 726; // // MessageId: ERROR_RESUME_HIBERNATION // // MessageText: // // The system was resumed from hibernation. // public static final int ERROR_RESUME_HIBERNATION = 727; // // MessageId: ERROR_FIRMWARE_UPDATED // // MessageText: // // Windows has detected that the system firmware (BIOS) was updated // [previous firmware date =%2, current firmware date %3]. // public static final int ERROR_FIRMWARE_UPDATED = 728; // // MessageId: ERROR_DRIVERS_LEAKING_LOCKED_PAGES // // MessageText: // // A device driver is leaking locked I/O pages causing system degradation. // The system has automatically enabled tracking code in order to try and // catch the culprit. // public static final int ERROR_DRIVERS_LEAKING_LOCKED_PAGES = 729; // // MessageId: ERROR_WAKE_SYSTEM // // MessageText: // // The system has awoken // public static final int ERROR_WAKE_SYSTEM = 730; // // MessageId: ERROR_WAIT_1 // // MessageText: // // ERROR_WAIT_1 // public static final int ERROR_WAIT_1 = 731; // // MessageId: ERROR_WAIT_2 // // MessageText: // // ERROR_WAIT_2 // public static final int ERROR_WAIT_2 = 732; // // MessageId: ERROR_WAIT_3 // // MessageText: // // ERROR_WAIT_3 // public static final int ERROR_WAIT_3 = 733; // // MessageId: ERROR_WAIT_63 // // MessageText: // // ERROR_WAIT_63 // public static final int ERROR_WAIT_63 = 734; // // MessageId: ERROR_ABANDONED_WAIT_0 // // MessageText: // // ERROR_ABANDONED_WAIT_0 // public static final int ERROR_ABANDONED_WAIT_0 = 735; // winnt // // MessageId: ERROR_ABANDONED_WAIT_63 // // MessageText: // // ERROR_ABANDONED_WAIT_63 // public static final int ERROR_ABANDONED_WAIT_63 = 736; // // MessageId: ERROR_USER_APC // // MessageText: // // ERROR_USER_APC // public static final int ERROR_USER_APC = 737; // winnt // // MessageId: ERROR_KERNEL_APC // // MessageText: // // ERROR_KERNEL_APC // public static final int ERROR_KERNEL_APC = 738; // // MessageId: ERROR_ALERTED // // MessageText: // // ERROR_ALERTED // public static final int ERROR_ALERTED = 739; // // MessageId: ERROR_ELEVATION_REQUIRED // // MessageText: // // The requested operation requires elevation. // public static final int ERROR_ELEVATION_REQUIRED = 740; // // MessageId: ERROR_REPARSE // // MessageText: // // A reparse should be performed by the Object Manager since the name of the // file resulted in a symbolic link. // public static final int ERROR_REPARSE = 741; // // MessageId: ERROR_OPLOCK_BREAK_IN_PROGRESS // // MessageText: // // An open/create operation completed while an oplock break is underway. // public static final int ERROR_OPLOCK_BREAK_IN_PROGRESS = 742; // // MessageId: ERROR_VOLUME_MOUNTED // // MessageText: // // A new volume has been mounted by a file system. // public static final int ERROR_VOLUME_MOUNTED = 743; // // MessageId: ERROR_RXACT_COMMITTED // // MessageText: // // This success level status indicates that the transaction state already // exists for the registry sub-tree, but that a transaction commit was // previously aborted. // The commit has now been completed. // public static final int ERROR_RXACT_COMMITTED = 744; // // MessageId: ERROR_NOTIFY_CLEANUP // // MessageText: // // This indicates that a notify change request has been completed due to // closing the handle which made the notify change request. // public static final int ERROR_NOTIFY_CLEANUP = 745; // // MessageId: ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED // // MessageText: // // {Connect Failure on Primary Transport} // An attempt was made to connect to the remote server %hs on the primary // transport, but the connection failed. // The computer WAS able to connect on a secondary transport. // public static final int ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED = 746; // // MessageId: ERROR_PAGE_FAULT_TRANSITION // // MessageText: // // Page fault was a transition fault. // public static final int ERROR_PAGE_FAULT_TRANSITION = 747; // // MessageId: ERROR_PAGE_FAULT_DEMAND_ZERO // // MessageText: // // Page fault was a demand zero fault. // public static final int ERROR_PAGE_FAULT_DEMAND_ZERO = 748; // // MessageId: ERROR_PAGE_FAULT_COPY_ON_WRITE // // MessageText: // // Page fault was a demand zero fault. // public static final int ERROR_PAGE_FAULT_COPY_ON_WRITE = 749; // // MessageId: ERROR_PAGE_FAULT_GUARD_PAGE // // MessageText: // // Page fault was a demand zero fault. // public static final int ERROR_PAGE_FAULT_GUARD_PAGE = 750; // // MessageId: ERROR_PAGE_FAULT_PAGING_FILE // // MessageText: // // Page fault was satisfied by reading from a secondary storage device. // public static final int ERROR_PAGE_FAULT_PAGING_FILE = 751; // // MessageId: ERROR_CACHE_PAGE_LOCKED // // MessageText: // // Cached page was locked during operation. // public static final int ERROR_CACHE_PAGE_LOCKED = 752; // // MessageId: ERROR_CRASH_DUMP // // MessageText: // // Crash dump exists in paging file. // public static final int ERROR_CRASH_DUMP = 753; // // MessageId: ERROR_BUFFER_ALL_ZEROS // // MessageText: // // Specified buffer contains all zeros. // public static final int ERROR_BUFFER_ALL_ZEROS = 754; // // MessageId: ERROR_REPARSE_OBJECT // // MessageText: // // A reparse should be performed by the Object Manager since the name of the // file resulted in a symbolic link. // public static final int ERROR_REPARSE_OBJECT = 755; // // MessageId: ERROR_RESOURCE_REQUIREMENTS_CHANGED // // MessageText: // // The device has succeeded a query-stop and its resource requirements have // changed. // public static final int ERROR_RESOURCE_REQUIREMENTS_CHANGED = 756; // // MessageId: ERROR_TRANSLATION_COMPLETE // // MessageText: // // The translator has translated these resources into the global space and // no further translations should be performed. // public static final int ERROR_TRANSLATION_COMPLETE = 757; // // MessageId: ERROR_NOTHING_TO_TERMINATE // // MessageText: // // A process being terminated has no threads to terminate. // public static final int ERROR_NOTHING_TO_TERMINATE = 758; // // MessageId: ERROR_PROCESS_NOT_IN_JOB // // MessageText: // // The specified process is not part of a job. // public static final int ERROR_PROCESS_NOT_IN_JOB = 759; // // MessageId: ERROR_PROCESS_IN_JOB // // MessageText: // // The specified process is part of a job. // public static final int ERROR_PROCESS_IN_JOB = 760; // // MessageId: ERROR_VOLSNAP_HIBERNATE_READY // // MessageText: // // {Volume Shadow Copy Service} // The system is now ready for hibernation. // public static final int ERROR_VOLSNAP_HIBERNATE_READY = 761; // // MessageId: ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY // // MessageText: // // A file system or file system filter driver has successfully completed an // FsFilter operation. // public static final int ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY = 762; // // MessageId: ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED // // MessageText: // // The specified interrupt vector was already connected. // public static final int ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED = 763; // // MessageId: ERROR_INTERRUPT_STILL_CONNECTED // // MessageText: // // The specified interrupt vector is still connected. // public static final int ERROR_INTERRUPT_STILL_CONNECTED = 764; // // MessageId: ERROR_WAIT_FOR_OPLOCK // // MessageText: // // An operation is blocked waiting for an oplock. // public static final int ERROR_WAIT_FOR_OPLOCK = 765; // // MessageId: ERROR_DBG_EXCEPTION_HANDLED // // MessageText: // // Debugger handled exception // public static final int ERROR_DBG_EXCEPTION_HANDLED = 766; // winnt // // MessageId: ERROR_DBG_CONTINUE // // MessageText: // // Debugger continued // public static final int ERROR_DBG_CONTINUE = 767; // winnt // // MessageId: ERROR_CALLBACK_POP_STACK // // MessageText: // // An exception occurred in a user mode callback and the kernel callback // frame should be removed. // public static final int ERROR_CALLBACK_POP_STACK = 768; // // MessageId: ERROR_COMPRESSION_DISABLED // // MessageText: // // Compression is disabled for this volume. // public static final int ERROR_COMPRESSION_DISABLED = 769; // // MessageId: ERROR_CANTFETCHBACKWARDS // // MessageText: // // The data provider cannot fetch backwards through a result set. // public static final int ERROR_CANTFETCHBACKWARDS = 770; // // MessageId: ERROR_CANTSCROLLBACKWARDS // // MessageText: // // The data provider cannot scroll backwards through a result set. // public static final int ERROR_CANTSCROLLBACKWARDS = 771; // // MessageId: ERROR_ROWSNOTRELEASED // // MessageText: // // The data provider requires that previously fetched data is released // before asking for more data. // public static final int ERROR_ROWSNOTRELEASED = 772; // // MessageId: ERROR_BAD_ACCESSOR_FLAGS // // MessageText: // // The data provider was not able to intrepret the flags set for a column // binding in an accessor. // public static final int ERROR_BAD_ACCESSOR_FLAGS = 773; // // MessageId: ERROR_ERRORS_ENCOUNTERED // // MessageText: // // One or more errors occurred while processing the request. // public static final int ERROR_ERRORS_ENCOUNTERED = 774; // // MessageId: ERROR_NOT_CAPABLE // // MessageText: // // The implementation is not capable of performing the request. // public static final int ERROR_NOT_CAPABLE = 775; // // MessageId: ERROR_REQUEST_OUT_OF_SEQUENCE // // MessageText: // // The client of a component requested an operation which is not valid given // the state of the component instance. // public static final int ERROR_REQUEST_OUT_OF_SEQUENCE = 776; // // MessageId: ERROR_VERSION_PARSE_ERROR // // MessageText: // // A version number could not be parsed. // public static final int ERROR_VERSION_PARSE_ERROR = 777; // // MessageId: ERROR_BADSTARTPOSITION // // MessageText: // // The iterator's start position is invalid. // public static final int ERROR_BADSTARTPOSITION = 778; // // MessageId: ERROR_MEMORY_HARDWARE // // MessageText: // // The hardware has reported an uncorrectable memory error. // public static final int ERROR_MEMORY_HARDWARE = 779; // // MessageId: ERROR_DISK_REPAIR_DISABLED // // MessageText: // // The attempted operation required self healing to be enabled. // public static final int ERROR_DISK_REPAIR_DISABLED = 780; // // MessageId: ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE // // MessageText: // // The Desktop heap encountered an error while allocating session memory. // There is more information in the system event log. // public static final int ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE = 781; // // MessageId: ERROR_SYSTEM_POWERSTATE_TRANSITION // // MessageText: // // The system powerstate is transitioning from %2 to %3. // public static final int ERROR_SYSTEM_POWERSTATE_TRANSITION = 782; // // MessageId: ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION // // MessageText: // // The system powerstate is transitioning from %2 to %3 but could enter %4. // public static final int ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION = 783; // // MessageId: ERROR_MCA_EXCEPTION // // MessageText: // // A thread is getting dispatched with MCA EXCEPTION because of MCA. // public static final int ERROR_MCA_EXCEPTION = 784; // // MessageId: ERROR_ACCESS_AUDIT_BY_POLICY // // MessageText: // // Access to %1 is monitored by policy rule %2. // public static final int ERROR_ACCESS_AUDIT_BY_POLICY = 785; // // MessageId: ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY // // MessageText: // // Access to %1 has been restricted by your Administrator by policy rule %2. // public static final int ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY = 786; // // MessageId: ERROR_ABANDON_HIBERFILE // // MessageText: // // A valid hibernation file has been invalidated and should be abandoned. // public static final int ERROR_ABANDON_HIBERFILE = 787; // // MessageId: ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED // // MessageText: // // {Delayed Write Failed} // Windows was unable to save all the data for the file %hs; the data has // been lost. // This error may be caused by network connectivity issues. Please try to // save this file elsewhere. // public static final int ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED = 788; // // MessageId: ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR // // MessageText: // // {Delayed Write Failed} // Windows was unable to save all the data for the file %hs; the data has // been lost. // This error was returned by the server on which the file exists. Please // try to save this file elsewhere. // public static final int ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR = 789; // // MessageId: ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR // // MessageText: // // {Delayed Write Failed} // Windows was unable to save all the data for the file %hs; the data has // been lost. // This error may be caused if the device has been removed or the media is // write-protected. // public static final int ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR = 790; // // MessageId: ERROR_BAD_MCFG_TABLE // // MessageText: // // The resources required for this device conflict with the MCFG table. // public static final int ERROR_BAD_MCFG_TABLE = 791; // // MessageId: ERROR_EA_ACCESS_DENIED // // MessageText: // // Access to the extended attribute was denied. // public static final int ERROR_EA_ACCESS_DENIED = 994; // // MessageId: ERROR_OPERATION_ABORTED // // MessageText: // // The I/O operation has been aborted because of either a thread exit or an // application request. // public static final int ERROR_OPERATION_ABORTED = 995; // // MessageId: ERROR_IO_INCOMPLETE // // MessageText: // // Overlapped I/O event is not in a signaled state. // public static final int ERROR_IO_INCOMPLETE = 996; // // MessageId: ERROR_IO_PENDING // // MessageText: // // Overlapped I/O operation is in progress. // public static final int ERROR_IO_PENDING = 997; // dderror // // MessageId: ERROR_NOACCESS // // MessageText: // // Invalid access to memory location. // public static final int ERROR_NOACCESS = 998; // // MessageId: ERROR_SWAPERROR // // MessageText: // // Error performing inpage operation. // public static final int ERROR_SWAPERROR = 999; // // MessageId: ERROR_STACK_OVERFLOW // // MessageText: // // Recursion too deep; the stack overflowed. // public static final int ERROR_STACK_OVERFLOW = 1001; // // MessageId: ERROR_INVALID_MESSAGE // // MessageText: // // The window cannot act on the sent message. // public static final int ERROR_INVALID_MESSAGE = 1002; // // MessageId: ERROR_CAN_NOT_COMPLETE // // MessageText: // // Cannot complete this function. // public static final int ERROR_CAN_NOT_COMPLETE = 1003; // // MessageId: ERROR_INVALID_FLAGS // // MessageText: // // Invalid flags. // public static final int ERROR_INVALID_FLAGS = 1004; // // MessageId: ERROR_UNRECOGNIZED_VOLUME // // MessageText: // // The volume does not contain a recognized file system. // Please make sure that all required file system drivers are loaded and // that the volume is not corrupted. // public static final int ERROR_UNRECOGNIZED_VOLUME = 1005; // // MessageId: ERROR_FILE_INVALID // // MessageText: // // The volume for a file has been externally altered so that the opened file // is no longer valid. // public static final int ERROR_FILE_INVALID = 1006; // // MessageId: ERROR_FULLSCREEN_MODE // // MessageText: // // The requested operation cannot be performed in full-screen mode. // public static final int ERROR_FULLSCREEN_MODE = 1007; // // MessageId: ERROR_NO_TOKEN // // MessageText: // // An attempt was made to reference a token that does not exist. // public static final int ERROR_NO_TOKEN = 1008; // // MessageId: ERROR_BADDB // // MessageText: // // The configuration registry database is corrupt. // public static final int ERROR_BADDB = 1009; // // MessageId: ERROR_BADKEY // // MessageText: // // The configuration registry key is invalid. // public static final int ERROR_BADKEY = 1010; // // MessageId: ERROR_CANTOPEN // // MessageText: // // The configuration registry key could not be opened. // public static final int ERROR_CANTOPEN = 1011; // // MessageId: ERROR_CANTREAD // // MessageText: // // The configuration registry key could not be read. // public static final int ERROR_CANTREAD = 1012; // // MessageId: ERROR_CANTWRITE // // MessageText: // // The configuration registry key could not be written. // public static final int ERROR_CANTWRITE = 1013; // // MessageId: ERROR_REGISTRY_RECOVERED // // MessageText: // // One of the files in the registry database had to be recovered by use of a // log or alternate copy. The recovery was successful. // public static final int ERROR_REGISTRY_RECOVERED = 1014; // // MessageId: ERROR_REGISTRY_CORRUPT // // MessageText: // // The registry is corrupted. The structure of one of the files containing // registry data is corrupted, or the system's memory image of the file is // corrupted, or the file could not be recovered because the alternate copy // or log was absent or corrupted. // public static final int ERROR_REGISTRY_CORRUPT = 1015; // // MessageId: ERROR_REGISTRY_IO_FAILED // // MessageText: // // An I/O operation initiated by the registry failed unrecoverably. The // registry could not read in, or write out, or flush, one of the files that // contain the system's image of the registry. // public static final int ERROR_REGISTRY_IO_FAILED = 1016; // // MessageId: ERROR_NOT_REGISTRY_FILE // // MessageText: // // The system has attempted to load or restore a file into the registry, but // the specified file is not in a registry file format. // public static final int ERROR_NOT_REGISTRY_FILE = 1017; // // MessageId: ERROR_KEY_DELETED // // MessageText: // // Illegal operation attempted on a registry key that has been marked for // deletion. // public static final int ERROR_KEY_DELETED = 1018; // // MessageId: ERROR_NO_LOG_SPACE // // MessageText: // // System could not allocate the required space in a registry log. // public static final int ERROR_NO_LOG_SPACE = 1019; // // MessageId: ERROR_KEY_HAS_CHILDREN // // MessageText: // // Cannot create a symbolic link in a registry key that already has subkeys // or values. // public static final int ERROR_KEY_HAS_CHILDREN = 1020; // // MessageId: ERROR_CHILD_MUST_BE_VOLATILE // // MessageText: // // Cannot create a stable subkey under a volatile parent key. // public static final int ERROR_CHILD_MUST_BE_VOLATILE = 1021; // // MessageId: ERROR_NOTIFY_ENUM_DIR // // MessageText: // // A notify change request is being completed and the information is not // being returned in the caller's buffer. The caller now needs to enumerate // the files to find the changes. // public static final int ERROR_NOTIFY_ENUM_DIR = 1022; // // MessageId: ERROR_DEPENDENT_SERVICES_RUNNING // // MessageText: // // A stop control has been sent to a service that other running services are // dependent on. // public static final int ERROR_DEPENDENT_SERVICES_RUNNING = 1051; // // MessageId: ERROR_INVALID_SERVICE_CONTROL // // MessageText: // // The requested control is not valid for this service. // public static final int ERROR_INVALID_SERVICE_CONTROL = 1052; // // MessageId: ERROR_SERVICE_REQUEST_TIMEOUT // // MessageText: // // The service did not respond to the start or control request in a timely // fashion. // public static final int ERROR_SERVICE_REQUEST_TIMEOUT = 1053; // // MessageId: ERROR_SERVICE_NO_THREAD // // MessageText: // // A thread could not be created for the service. // public static final int ERROR_SERVICE_NO_THREAD = 1054; // // MessageId: ERROR_SERVICE_DATABASE_LOCKED // // MessageText: // // The service database is locked. // public static final int ERROR_SERVICE_DATABASE_LOCKED = 1055; // // MessageId: ERROR_SERVICE_ALREADY_RUNNING // // MessageText: // // An instance of the service is already running. // public static final int ERROR_SERVICE_ALREADY_RUNNING = 1056; // // MessageId: ERROR_INVALID_SERVICE_ACCOUNT // // MessageText: // // The account name is invalid or does not exist, or the password is invalid // for the account name specified. // public static final int ERROR_INVALID_SERVICE_ACCOUNT = 1057; // // MessageId: ERROR_SERVICE_DISABLED // // MessageText: // // The service cannot be started, either because it is disabled or because // it has no enabled devices associated with it. // public static final int ERROR_SERVICE_DISABLED = 1058; // // MessageId: ERROR_CIRCULAR_DEPENDENCY // // MessageText: // // Circular service dependency was specified. // public static final int ERROR_CIRCULAR_DEPENDENCY = 1059; // // MessageId: ERROR_SERVICE_DOES_NOT_EXIST // // MessageText: // // The specified service does not exist as an installed service. // public static final int ERROR_SERVICE_DOES_NOT_EXIST = 1060; // // MessageId: ERROR_SERVICE_CANNOT_ACCEPT_CTRL // // MessageText: // // The service cannot accept control messages at this time. // public static final int ERROR_SERVICE_CANNOT_ACCEPT_CTRL = 1061; // // MessageId: ERROR_SERVICE_NOT_ACTIVE // // MessageText: // // The service has not been started. // public static final int ERROR_SERVICE_NOT_ACTIVE = 1062; // // MessageId: ERROR_FAILED_SERVICE_CONTROLLER_CONNECT // // MessageText: // // The service process could not connect to the service controller. // public static final int ERROR_FAILED_SERVICE_CONTROLLER_CONNECT = 1063; // // MessageId: ERROR_EXCEPTION_IN_SERVICE // // MessageText: // // An exception occurred in the service when handling the control request. // public static final int ERROR_EXCEPTION_IN_SERVICE = 1064; // // MessageId: ERROR_DATABASE_DOES_NOT_EXIST // // MessageText: // // The database specified does not exist. // public static final int ERROR_DATABASE_DOES_NOT_EXIST = 1065; // // MessageId: ERROR_SERVICE_SPECIFIC_ERROR // // MessageText: // // The service has returned a service-specific error code. // public static final int ERROR_SERVICE_SPECIFIC_ERROR = 1066; // // MessageId: ERROR_PROCESS_ABORTED // // MessageText: // // The process terminated unexpectedly. // public static final int ERROR_PROCESS_ABORTED = 1067; // // MessageId: ERROR_SERVICE_DEPENDENCY_FAIL // // MessageText: // // The dependency service or group failed to start. // public static final int ERROR_SERVICE_DEPENDENCY_FAIL = 1068; // // MessageId: ERROR_SERVICE_LOGON_FAILED // // MessageText: // // The service did not start due to a logon failure. // public static final int ERROR_SERVICE_LOGON_FAILED = 1069; // // MessageId: ERROR_SERVICE_START_HANG // // MessageText: // // After starting, the service hung in a start-pending state. // public static final int ERROR_SERVICE_START_HANG = 1070; // // MessageId: ERROR_INVALID_SERVICE_LOCK // // MessageText: // // The specified service database lock is invalid. // public static final int ERROR_INVALID_SERVICE_LOCK = 1071; // // MessageId: ERROR_SERVICE_MARKED_FOR_DELETE // // MessageText: // // The specified service has been marked for deletion. // public static final int ERROR_SERVICE_MARKED_FOR_DELETE = 1072; // // MessageId: ERROR_SERVICE_EXISTS // // MessageText: // // The specified service already exists. // public static final int ERROR_SERVICE_EXISTS = 1073; // // MessageId: ERROR_ALREADY_RUNNING_LKG // // MessageText: // // The system is currently running with the last-known-good configuration. // public static final int ERROR_ALREADY_RUNNING_LKG = 1074; // // MessageId: ERROR_SERVICE_DEPENDENCY_DELETED // // MessageText: // // The dependency service does not exist or has been marked for deletion. // public static final int ERROR_SERVICE_DEPENDENCY_DELETED = 1075; // // MessageId: ERROR_BOOT_ALREADY_ACCEPTED // // MessageText: // // The current boot has already been accepted for use as the last-known-good // control set. // public static final int ERROR_BOOT_ALREADY_ACCEPTED = 1076; // // MessageId: ERROR_SERVICE_NEVER_STARTED // // MessageText: // // No attempts to start the service have been made since the last boot. // public static final int ERROR_SERVICE_NEVER_STARTED = 1077; // // MessageId: ERROR_DUPLICATE_SERVICE_NAME // // MessageText: // // The name is already in use as either a service name or a service display // name. // public static final int ERROR_DUPLICATE_SERVICE_NAME = 1078; // // MessageId: ERROR_DIFFERENT_SERVICE_ACCOUNT // // MessageText: // // The account specified for this service is different from the account // specified for other services running in the same process. // public static final int ERROR_DIFFERENT_SERVICE_ACCOUNT = 1079; // // MessageId: ERROR_CANNOT_DETECT_DRIVER_FAILURE // // MessageText: // // Failure actions can only be set for Win32 services, not for drivers. // public static final int ERROR_CANNOT_DETECT_DRIVER_FAILURE = 1080; // // MessageId: ERROR_CANNOT_DETECT_PROCESS_ABORT // // MessageText: // // This service runs in the same process as the service control manager. // Therefore, the service control manager cannot take action if this // service's process terminates unexpectedly. // public static final int ERROR_CANNOT_DETECT_PROCESS_ABORT = 1081; // // MessageId: ERROR_NO_RECOVERY_PROGRAM // // MessageText: // // No recovery program has been configured for this service. // public static final int ERROR_NO_RECOVERY_PROGRAM = 1082; // // MessageId: ERROR_SERVICE_NOT_IN_EXE // // MessageText: // // The executable program that this service is configured to run in does not // implement the service. // public static final int ERROR_SERVICE_NOT_IN_EXE = 1083; // // MessageId: ERROR_NOT_SAFEBOOT_SERVICE // // MessageText: // // This service cannot be started in Safe Mode // public static final int ERROR_NOT_SAFEBOOT_SERVICE = 1084; // // MessageId: ERROR_END_OF_MEDIA // // MessageText: // // The physical end of the tape has been reached. // public static final int ERROR_END_OF_MEDIA = 1100; // // MessageId: ERROR_FILEMARK_DETECTED // // MessageText: // // A tape access reached a filemark. // public static final int ERROR_FILEMARK_DETECTED = 1101; // // MessageId: ERROR_BEGINNING_OF_MEDIA // // MessageText: // // The beginning of the tape or a partition was encountered. // public static final int ERROR_BEGINNING_OF_MEDIA = 1102; // // MessageId: ERROR_SETMARK_DETECTED // // MessageText: // // A tape access reached the end of a set of files. // public static final int ERROR_SETMARK_DETECTED = 1103; // // MessageId: ERROR_NO_DATA_DETECTED // // MessageText: // // No more data is on the tape. // public static final int ERROR_NO_DATA_DETECTED = 1104; // // MessageId: ERROR_PARTITION_FAILURE // // MessageText: // // Tape could not be partitioned. // public static final int ERROR_PARTITION_FAILURE = 1105; // // MessageId: ERROR_INVALID_BLOCK_LENGTH // // MessageText: // // When accessing a new tape of a multivolume partition, the current block // size is incorrect. // public static final int ERROR_INVALID_BLOCK_LENGTH = 1106; // // MessageId: ERROR_DEVICE_NOT_PARTITIONED // // MessageText: // // Tape partition information could not be found when loading a tape. // public static final int ERROR_DEVICE_NOT_PARTITIONED = 1107; // // MessageId: ERROR_UNABLE_TO_LOCK_MEDIA // // MessageText: // // Unable to lock the media eject mechanism. // public static final int ERROR_UNABLE_TO_LOCK_MEDIA = 1108; // // MessageId: ERROR_UNABLE_TO_UNLOAD_MEDIA // // MessageText: // // Unable to unload the media. // public static final int ERROR_UNABLE_TO_UNLOAD_MEDIA = 1109; // // MessageId: ERROR_MEDIA_CHANGED // // MessageText: // // The media in the drive may have changed. // public static final int ERROR_MEDIA_CHANGED = 1110; // // MessageId: ERROR_BUS_RESET // // MessageText: // // The I/O bus was reset. // public static final int ERROR_BUS_RESET = 1111; // // MessageId: ERROR_NO_MEDIA_IN_DRIVE // // MessageText: // // No media in drive. // public static final int ERROR_NO_MEDIA_IN_DRIVE = 1112; // // MessageId: ERROR_NO_UNICODE_TRANSLATION // // MessageText: // // No mapping for the Unicode character exists in the target multi-byte code // page. // public static final int ERROR_NO_UNICODE_TRANSLATION = 1113; // // MessageId: ERROR_DLL_INIT_FAILED // // MessageText: // // A dynamic link library (DL; initialization routine failed. // public static final int ERROR_DLL_INIT_FAILED = 1114; // // MessageId: ERROR_SHUTDOWN_IN_PROGRESS // // MessageText: // // A system shutdown is in progress. // public static final int ERROR_SHUTDOWN_IN_PROGRESS = 1115; // // MessageId: ERROR_NO_SHUTDOWN_IN_PROGRESS // // MessageText: // // Unable to abort the system shutdown because no shutdown was in progress. // public static final int ERROR_NO_SHUTDOWN_IN_PROGRESS = 1116; // // MessageId: ERROR_IO_DEVICE // // MessageText: // // The request could not be performed because of an I/O device error. // public static final int ERROR_IO_DEVICE = 1117; // // MessageId: ERROR_SERIAL_NO_DEVICE // // MessageText: // // No serial device was successfully initialized. The serial driver will // unload. // public static final int ERROR_SERIAL_NO_DEVICE = 1118; // // MessageId: ERROR_IRQ_BUSY // // MessageText: // // Unable to open a device that was sharing an interrupt request (IRQ) with // other devices. At least one other device that uses that IRQ was already // opened. // public static final int ERROR_IRQ_BUSY = 1119; // // MessageId: ERROR_MORE_WRITES // // MessageText: // // A serial I/O operation was completed by another write to the serial port. // (The IOCTL_SERIAL_XOFF_COUNTER reached zero.) // public static final int ERROR_MORE_WRITES = 1120; // // MessageId: ERROR_COUNTER_TIMEOUT // // MessageText: // // A serial I/O operation completed because the timeout period expired. // (The IOCTL_SERIAL_XOFF_COUNTER did not reach zero.) // public static final int ERROR_COUNTER_TIMEOUT = 1121; // // MessageId: ERROR_FLOPPY_ID_MARK_NOT_FOUND // // MessageText: // // No ID address mark was found on the floppy disk. // public static final int ERROR_FLOPPY_ID_MARK_NOT_FOUND = 1122; // // MessageId: ERROR_FLOPPY_WRONG_CYLINDER // // MessageText: // // Mismatch between the floppy disk sector ID field and the floppy disk // controller track address. // public static final int ERROR_FLOPPY_WRONG_CYLINDER = 1123; // // MessageId: ERROR_FLOPPY_UNKNOWN_ERROR // // MessageText: // // The floppy disk controller reported an error that is not recognized by // the floppy disk driver. // public static final int ERROR_FLOPPY_UNKNOWN_ERROR = 1124; // // MessageId: ERROR_FLOPPY_BAD_REGISTERS // // MessageText: // // The floppy disk controller returned inconsistent results in its // registers. // public static final int ERROR_FLOPPY_BAD_REGISTERS = 1125; // // MessageId: ERROR_DISK_RECALIBRATE_FAILED // // MessageText: // // While accessing the hard disk, a recalibrate operation failed, even after // retries. // public static final int ERROR_DISK_RECALIBRATE_FAILED = 1126; // // MessageId: ERROR_DISK_OPERATION_FAILED // // MessageText: // // While accessing the hard disk, a disk operation failed even after // retries. // public static final int ERROR_DISK_OPERATION_FAILED = 1127; // // MessageId: ERROR_DISK_RESET_FAILED // // MessageText: // // While accessing the hard disk, a disk controller reset was needed, but // even that failed. // public static final int ERROR_DISK_RESET_FAILED = 1128; // // MessageId: ERROR_EOM_OVERFLOW // // MessageText: // // Physical end of tape encountered. // public static final int ERROR_EOM_OVERFLOW = 1129; // // MessageId: ERROR_NOT_ENOUGH_SERVER_MEMORY // // MessageText: // // Not enough server storage is available to process this command. // public static final int ERROR_NOT_ENOUGH_SERVER_MEMORY = 1130; // // MessageId: ERROR_POSSIBLE_DEADLOCK // // MessageText: // // A potential deadlock condition has been detected. // public static final int ERROR_POSSIBLE_DEADLOCK = 1131; // // MessageId: ERROR_MAPPED_ALIGNMENT // // MessageText: // // The base address or the file offset specified does not have the proper // alignment. // public static final int ERROR_MAPPED_ALIGNMENT = 1132; // // MessageId: ERROR_SET_POWER_STATE_VETOED // // MessageText: // // An attempt to change the system power state was vetoed by another // application or driver. // public static final int ERROR_SET_POWER_STATE_VETOED = 1140; // // MessageId: ERROR_SET_POWER_STATE_FAILED // // MessageText: // // The system BIOS failed an attempt to change the system power state. // public static final int ERROR_SET_POWER_STATE_FAILED = 1141; // // MessageId: ERROR_TOO_MANY_LINKS // // MessageText: // // An attempt was made to create more links on a file than the file system // supports. // public static final int ERROR_TOO_MANY_LINKS = 1142; // // MessageId: ERROR_OLD_WIN_VERSION // // MessageText: // // The specified program requires a newer version of Windows. // public static final int ERROR_OLD_WIN_VERSION = 1150; // // MessageId: ERROR_APP_WRONG_OS // // MessageText: // // The specified program is not a Windows or MS-DOS program. // public static final int ERROR_APP_WRONG_OS = 1151; // // MessageId: ERROR_SINGLE_INSTANCE_APP // // MessageText: // // Cannot start more than one instance of the specified program. // public static final int ERROR_SINGLE_INSTANCE_APP = 1152; // // MessageId: ERROR_RMODE_APP // // MessageText: // // The specified program was written for an earlier version of Windows. // public static final int ERROR_RMODE_APP = 1153; // // MessageId: ERROR_INVALID_DLL // // MessageText: // // One of the library files needed to run this application is damaged. // public static final int ERROR_INVALID_DLL = 1154; // // MessageId: ERROR_NO_ASSOCIATION // // MessageText: // // No application is associated with the specified file for this operation. // public static final int ERROR_NO_ASSOCIATION = 1155; // // MessageId: ERROR_DDE_FAIL // // MessageText: // // An error occurred in sending the command to the application. // public static final int ERROR_DDE_FAIL = 1156; // // MessageId: ERROR_DLL_NOT_FOUND // // MessageText: // // One of the library files needed to run this application cannot be found. // public static final int ERROR_DLL_NOT_FOUND = 1157; // // MessageId: ERROR_NO_MORE_USER_HANDLES // // MessageText: // // The current process has used all of its system allowance of handles for // Window Manager objects. // public static final int ERROR_NO_MORE_USER_HANDLES = 1158; // // MessageId: ERROR_MESSAGE_SYNC_ONLY // // MessageText: // // The message can be used only with synchronous operations. // public static final int ERROR_MESSAGE_SYNC_ONLY = 1159; // // MessageId: ERROR_SOURCE_ELEMENT_EMPTY // // MessageText: // // The indicated source element has no media. // public static final int ERROR_SOURCE_ELEMENT_EMPTY = 1160; // // MessageId: ERROR_DESTINATION_ELEMENT_FULL // // MessageText: // // The indicated destination element already contains media. // public static final int ERROR_DESTINATION_ELEMENT_FULL = 1161; // // MessageId: ERROR_ILLEGAL_ELEMENT_ADDRESS // // MessageText: // // The indicated element does not exist. // public static final int ERROR_ILLEGAL_ELEMENT_ADDRESS = 1162; // // MessageId: ERROR_MAGAZINE_NOT_PRESENT // // MessageText: // // The indicated element is part of a magazine that is not present. // public static final int ERROR_MAGAZINE_NOT_PRESENT = 1163; // // MessageId: ERROR_DEVICE_REINITIALIZATION_NEEDED // // MessageText: // // The indicated device requires reinitialization due to hardware errors. // public static final int ERROR_DEVICE_REINITIALIZATION_NEEDED = 1164; // dderror // // MessageId: ERROR_DEVICE_REQUIRES_CLEANING // // MessageText: // // The device has indicated that cleaning is required before further // operations are attempted. // public static final int ERROR_DEVICE_REQUIRES_CLEANING = 1165; // // MessageId: ERROR_DEVICE_DOOR_OPEN // // MessageText: // // The device has indicated that its door is open. // public static final int ERROR_DEVICE_DOOR_OPEN = 1166; // // MessageId: ERROR_DEVICE_NOT_CONNECTED // // MessageText: // // The device is not connected. // public static final int ERROR_DEVICE_NOT_CONNECTED = 1167; // // MessageId: ERROR_NOT_FOUND // // MessageText: // // Element not found. // public static final int ERROR_NOT_FOUND = 1168; // // MessageId: ERROR_NO_MATCH // // MessageText: // // There was no match for the specified key in the index. // public static final int ERROR_NO_MATCH = 1169; // // MessageId: ERROR_SET_NOT_FOUND // // MessageText: // // The property set specified does not exist on the object. // public static final int ERROR_SET_NOT_FOUND = 1170; // // MessageId: ERROR_POINT_NOT_FOUND // // MessageText: // // The point passed to GetMouseMovePoints is not in the buffer. // public static final int ERROR_POINT_NOT_FOUND = 1171; // // MessageId: ERROR_NO_TRACKING_SERVICE // // MessageText: // // The tracking (workstation) service is not running. // public static final int ERROR_NO_TRACKING_SERVICE = 1172; // // MessageId: ERROR_NO_VOLUME_ID // // MessageText: // // The Volume ID could not be found. // public static final int ERROR_NO_VOLUME_ID = 1173; // // MessageId: ERROR_UNABLE_TO_REMOVE_REPLACED // // MessageText: // // Unable to remove the file to be replaced. // public static final int ERROR_UNABLE_TO_REMOVE_REPLACED = 1175; // // MessageId: ERROR_UNABLE_TO_MOVE_REPLACEMENT // // MessageText: // // Unable to move the replacement file to the file to be replaced. The file // to be replaced has retained its original name. // public static final int ERROR_UNABLE_TO_MOVE_REPLACEMENT = 1176; // // MessageId: ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 // // MessageText: // // Unable to move the replacement file to the file to be replaced. The file // to be replaced has been renamed using the backup name. // public static final int ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 = 1177; // // MessageId: ERROR_JOURNAL_DELETE_IN_PROGRESS // // MessageText: // // The volume change journal is being deleted. // public static final int ERROR_JOURNAL_DELETE_IN_PROGRESS = 1178; // // MessageId: ERROR_JOURNAL_NOT_ACTIVE // // MessageText: // // The volume change journal is not active. // public static final int ERROR_JOURNAL_NOT_ACTIVE = 1179; // // MessageId: ERROR_POTENTIAL_FILE_FOUND // // MessageText: // // A file was found, but it may not be the correct file. // public static final int ERROR_POTENTIAL_FILE_FOUND = 1180; // // MessageId: ERROR_JOURNAL_ENTRY_DELETED // // MessageText: // // The journal entry has been deleted from the journal. // public static final int ERROR_JOURNAL_ENTRY_DELETED = 1181; // // MessageId: ERROR_SHUTDOWN_IS_SCHEDULED // // MessageText: // // A system shutdown has already been scheduled. // public static final int ERROR_SHUTDOWN_IS_SCHEDULED = 1190; // // MessageId: ERROR_SHUTDOWN_USERS_LOGGED_ON // // MessageText: // // The system shutdown cannot be initiated because there are other users // logged on to the computer. // public static final int ERROR_SHUTDOWN_USERS_LOGGED_ON = 1191; // // MessageId: ERROR_BAD_DEVICE // // MessageText: // // The specified device name is invalid. // public static final int ERROR_BAD_DEVICE = 1200; // // MessageId: ERROR_CONNECTION_UNAVAIL // // MessageText: // // The device is not currently connected but it is a remembered connection. // public static final int ERROR_CONNECTION_UNAVAIL = 1201; // // MessageId: ERROR_DEVICE_ALREADY_REMEMBERED // // MessageText: // // The local device name has a remembered connection to another network // resource. // public static final int ERROR_DEVICE_ALREADY_REMEMBERED = 1202; // // MessageId: ERROR_NO_NET_OR_BAD_PATH // // MessageText: // // The network path was either typed incorrectly, does not exist, or the // network provider is not currently available. Please try retyping the path // or contact your network administrator. // public static final int ERROR_NO_NET_OR_BAD_PATH = 1203; // // MessageId: ERROR_BAD_PROVIDER // // MessageText: // // The specified network provider name is invalid. // public static final int ERROR_BAD_PROVIDER = 1204; // // MessageId: ERROR_CANNOT_OPEN_PROFILE // // MessageText: // // Unable to open the network connection profile. // public static final int ERROR_CANNOT_OPEN_PROFILE = 1205; // // MessageId: ERROR_BAD_PROFILE // // MessageText: // // The network connection profile is corrupted. // public static final int ERROR_BAD_PROFILE = 1206; // // MessageId: ERROR_NOT_CONTAINER // // MessageText: // // Cannot enumerate a noncontainer. // public static final int ERROR_NOT_CONTAINER = 1207; // // MessageId: ERROR_EXTENDED_ERROR // // MessageText: // // An extended error has occurred. // public static final int ERROR_EXTENDED_ERROR = 1208; // // MessageId: ERROR_INVALID_GROUPNAME // // MessageText: // // The format of the specified group name is invalid. // public static final int ERROR_INVALID_GROUPNAME = 1209; // // MessageId: ERROR_INVALID_COMPUTERNAME // // MessageText: // // The format of the specified computer name is invalid. // public static final int ERROR_INVALID_COMPUTERNAME = 1210; // // MessageId: ERROR_INVALID_EVENTNAME // // MessageText: // // The format of the specified event name is invalid. // public static final int ERROR_INVALID_EVENTNAME = 1211; // // MessageId: ERROR_INVALID_DOMAINNAME // // MessageText: // // The format of the specified domain name is invalid. // public static final int ERROR_INVALID_DOMAINNAME = 1212; // // MessageId: ERROR_INVALID_SERVICENAME // // MessageText: // // The format of the specified service name is invalid. // public static final int ERROR_INVALID_SERVICENAME = 1213; // // MessageId: ERROR_INVALID_NETNAME // // MessageText: // // The format of the specified network name is invalid. // public static final int ERROR_INVALID_NETNAME = 1214; // // MessageId: ERROR_INVALID_SHARENAME // // MessageText: // // The format of the specified share name is invalid. // public static final int ERROR_INVALID_SHARENAME = 1215; // // MessageId: ERROR_INVALID_PASSWORDNAME // // MessageText: // // The format of the specified password is invalid. // public static final int ERROR_INVALID_PASSWORDNAME = 1216; // // MessageId: ERROR_INVALID_MESSAGENAME // // MessageText: // // The format of the specified message name is invalid. // public static final int ERROR_INVALID_MESSAGENAME = 1217; // // MessageId: ERROR_INVALID_MESSAGEDEST // // MessageText: // // The format of the specified message destination is invalid. // public static final int ERROR_INVALID_MESSAGEDEST = 1218; // // MessageId: ERROR_SESSION_CREDENTIAL_CONFLICT // // MessageText: // // Multiple connections to a server or shared resource by the same user, // using more than one user name, are not allowed. Disconnect all previous // connections to the server or shared resource and try again. // public static final int ERROR_SESSION_CREDENTIAL_CONFLICT = 1219; // // MessageId: ERROR_REMOTE_SESSION_LIMIT_EXCEEDED // // MessageText: // // An attempt was made to establish a session to a network server, but there // are already too many sessions established to that server. // public static final int ERROR_REMOTE_SESSION_LIMIT_EXCEEDED = 1220; // // MessageId: ERROR_DUP_DOMAINNAME // // MessageText: // // The workgroup or domain name is already in use by another computer on the // network. // public static final int ERROR_DUP_DOMAINNAME = 1221; // // MessageId: ERROR_NO_NETWORK // // MessageText: // // The network is not present or not started. // public static final int ERROR_NO_NETWORK = 1222; // // MessageId: ERROR_CANCELLED // // MessageText: // // The operation was canceled by the user. // public static final int ERROR_CANCELLED = 1223; // // MessageId: ERROR_USER_MAPPED_FILE // // MessageText: // // The requested operation cannot be performed on a file with a user-mapped // section open. // public static final int ERROR_USER_MAPPED_FILE = 1224; // // MessageId: ERROR_CONNECTION_REFUSED // // MessageText: // // The remote computer refused the network connection. // public static final int ERROR_CONNECTION_REFUSED = 1225; // // MessageId: ERROR_GRACEFUL_DISCONNECT // // MessageText: // // The network connection was gracefully closed. // public static final int ERROR_GRACEFUL_DISCONNECT = 1226; // // MessageId: ERROR_ADDRESS_ALREADY_ASSOCIATED // // MessageText: // // The network transport endpoint already has an address associated with it. // public static final int ERROR_ADDRESS_ALREADY_ASSOCIATED = 1227; // // MessageId: ERROR_ADDRESS_NOT_ASSOCIATED // // MessageText: // // An address has not yet been associated with the network endpoint. // public static final int ERROR_ADDRESS_NOT_ASSOCIATED = 1228; // // MessageId: ERROR_CONNECTION_INVALID // // MessageText: // // An operation was attempted on a nonexistent network connection. // public static final int ERROR_CONNECTION_INVALID = 1229; // // MessageId: ERROR_CONNECTION_ACTIVE // // MessageText: // // An invalid operation was attempted on an active network connection. // public static final int ERROR_CONNECTION_ACTIVE = 1230; // // MessageId: ERROR_NETWORK_UNREACHABLE // // MessageText: // // The network location cannot be reached. For information about network // troubleshooting, see Windows Help. // public static final int ERROR_NETWORK_UNREACHABLE = 1231; // // MessageId: ERROR_HOST_UNREACHABLE // // MessageText: // // The network location cannot be reached. For information about network // troubleshooting, see Windows Help. // public static final int ERROR_HOST_UNREACHABLE = 1232; // // MessageId: ERROR_PROTOCOL_UNREACHABLE // // MessageText: // // The network location cannot be reached. For information about network // troubleshooting, see Windows Help. // public static final int ERROR_PROTOCOL_UNREACHABLE = 1233; // // MessageId: ERROR_PORT_UNREACHABLE // // MessageText: // // No service is operating at the destination network endpoint on the remote // system. // public static final int ERROR_PORT_UNREACHABLE = 1234; // // MessageId: ERROR_REQUEST_ABORTED // // MessageText: // // The request was aborted. // public static final int ERROR_REQUEST_ABORTED = 1235; // // MessageId: ERROR_CONNECTION_ABORTED // // MessageText: // // The network connection was aborted by the local system. // public static final int ERROR_CONNECTION_ABORTED = 1236; // // MessageId: ERROR_RETRY // // MessageText: // // The operation could not be completed. A retry should be performed. // public static final int ERROR_RETRY = 1237; // // MessageId: ERROR_CONNECTION_COUNT_LIMIT // // MessageText: // // A connection to the server could not be made because the limit on the // number of concurrent connections for this account has been reached. // public static final int ERROR_CONNECTION_COUNT_LIMIT = 1238; // // MessageId: ERROR_LOGIN_TIME_RESTRICTION // // MessageText: // // Attempting to log in during an unauthorized time of day for this account. // public static final int ERROR_LOGIN_TIME_RESTRICTION = 1239; // // MessageId: ERROR_LOGIN_WKSTA_RESTRICTION // // MessageText: // // The account is not authorized to log in from this station. // public static final int ERROR_LOGIN_WKSTA_RESTRICTION = 1240; // // MessageId: ERROR_INCORRECT_ADDRESS // // MessageText: // // The network address could not be used for the operation requested. // public static final int ERROR_INCORRECT_ADDRESS = 1241; // // MessageId: ERROR_ALREADY_REGISTERED // // MessageText: // // The service is already registered. // public static final int ERROR_ALREADY_REGISTERED = 1242; // // MessageId: ERROR_SERVICE_NOT_FOUND // // MessageText: // // The specified service does not exist. // public static final int ERROR_SERVICE_NOT_FOUND = 1243; // // MessageId: ERROR_NOT_AUTHENTICATED // // MessageText: // // The operation being requested was not performed because the user has not // been authenticated. // public static final int ERROR_NOT_AUTHENTICATED = 1244; // // MessageId: ERROR_NOT_LOGGED_ON // // MessageText: // // The operation being requested was not performed because the user has not // logged on to the network. // The specified service does not exist. // public static final int ERROR_NOT_LOGGED_ON = 1245; // // MessageId: ERROR_CONTINUE // // MessageText: // // Continue with work in progress. // public static final int ERROR_CONTINUE = 1246; // dderror // // MessageId: ERROR_ALREADY_INITIALIZED // // MessageText: // // An attempt was made to perform an initialization operation when // initialization has already been completed. // public static final int ERROR_ALREADY_INITIALIZED = 1247; // // MessageId: ERROR_NO_MORE_DEVICES // // MessageText: // // No more local devices. // public static final int ERROR_NO_MORE_DEVICES = 1248; // dderror // // MessageId: ERROR_NO_SUCH_SITE // // MessageText: // // The specified site does not exist. // public static final int ERROR_NO_SUCH_SITE = 1249; // // MessageId: ERROR_DOMAIN_CONTROLLER_EXISTS // // MessageText: // // A domain controller with the specified name already exists. // public static final int ERROR_DOMAIN_CONTROLLER_EXISTS = 1250; // // MessageId: ERROR_ONLY_IF_CONNECTED // // MessageText: // // This operation is supported only when you are connected to the server. // public static final int ERROR_ONLY_IF_CONNECTED = 1251; // // MessageId: ERROR_OVERRIDE_NOCHANGES // // MessageText: // // The group policy framework should call the extension even if there are no // changes. // public static final int ERROR_OVERRIDE_NOCHANGES = 1252; // // MessageId: ERROR_BAD_USER_PROFILE // // MessageText: // // The specified user does not have a valid profile. // public static final int ERROR_BAD_USER_PROFILE = 1253; // // MessageId: ERROR_NOT_SUPPORTED_ON_SBS // // MessageText: // // This operation is not supported on a computer running Windows Server=2003 // for Small Business Server // public static final int ERROR_NOT_SUPPORTED_ON_SBS = 1254; // // MessageId: ERROR_SERVER_SHUTDOWN_IN_PROGRESS // // MessageText: // // The server machine is shutting down. // public static final int ERROR_SERVER_SHUTDOWN_IN_PROGRESS = 1255; // // MessageId: ERROR_HOST_DOWN // // MessageText: // // The remote system is not available. For information about network // troubleshooting, see Windows Help. // public static final int ERROR_HOST_DOWN = 1256; // // MessageId: ERROR_NON_ACCOUNT_SID // // MessageText: // // The security identifier provided is not from an account domain. // public static final int ERROR_NON_ACCOUNT_SID = 1257; // // MessageId: ERROR_NON_DOMAIN_SID // // MessageText: // // The security identifier provided does not have a domain component. // public static final int ERROR_NON_DOMAIN_SID = 1258; // // MessageId: ERROR_APPHELP_BLOCK // // MessageText: // // AppHelp dialog canceled thus preventing the application from starting. // public static final int ERROR_APPHELP_BLOCK = 1259; // // MessageId: ERROR_ACCESS_DISABLED_BY_POLICY // // MessageText: // // This program is blocked by group policy. For more information, contact // your system administrator. // public static final int ERROR_ACCESS_DISABLED_BY_POLICY = 1260; // // MessageId: ERROR_REG_NAT_CONSUMPTION // // MessageText: // // A program attempt to use an invalid register value. Normally caused by an // uninitialized register. This error is Itanium specific. // public static final int ERROR_REG_NAT_CONSUMPTION = 1261; // // MessageId: ERROR_CSCSHARE_OFFLINE // // MessageText: // // The share is currently offline or does not exist. // public static final int ERROR_CSCSHARE_OFFLINE = 1262; // // MessageId: ERROR_PKINIT_FAILURE // // MessageText: // // The kerberos protocol encountered an error while validating the KDC // certificate during smartcard logon. There is more information in the // system event log. // public static final int ERROR_PKINIT_FAILURE = 1263; // // MessageId: ERROR_SMARTCARD_SUBSYSTEM_FAILURE // // MessageText: // // The kerberos protocol encountered an error while attempting to utilize // the smartcard subsystem. // public static final int ERROR_SMARTCARD_SUBSYSTEM_FAILURE = 1264; // // MessageId: ERROR_DOWNGRADE_DETECTED // // MessageText: // // The system detected a possible attempt to compromise security. Please // ensure that you can contact the server that authenticated you. // public static final int ERROR_DOWNGRADE_DETECTED = 1265; // // Do not use ID's=1266 -=1270 as the symbolicNames have been moved to // SEC_E_* // // // MessageId: ERROR_MACHINE_LOCKED // // MessageText: // // The machine is locked and cannot be shut down without the force option. // public static final int ERROR_MACHINE_LOCKED = 1271; // // MessageId: ERROR_CALLBACK_SUPPLIED_INVALID_DATA // // MessageText: // // An application-defined callback gave invalid data when called. // public static final int ERROR_CALLBACK_SUPPLIED_INVALID_DATA = 1273; // // MessageId: ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED // // MessageText: // // The group policy framework should call the extension in the synchronous // foreground policy refresh. // public static final int ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED = 1274; // // MessageId: ERROR_DRIVER_BLOCKED // // MessageText: // // This driver has been blocked from loading // public static final int ERROR_DRIVER_BLOCKED = 1275; // // MessageId: ERROR_INVALID_IMPORT_OF_NON_DLL // // MessageText: // // A dynamic link library (DL; referenced a module that was neither a DLL // nor the process's executable image. // public static final int ERROR_INVALID_IMPORT_OF_NON_DLL = 1276; // // MessageId: ERROR_ACCESS_DISABLED_WEBBLADE // // MessageText: // // Windows cannot open this program since it has been disabled. // public static final int ERROR_ACCESS_DISABLED_WEBBLADE = 1277; // // MessageId: ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER // // MessageText: // // Windows cannot open this program because the license enforcement system // has been tampered with or become corrupted. // public static final int ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER = 1278; // // MessageId: ERROR_RECOVERY_FAILURE // // MessageText: // // A transaction recover failed. // public static final int ERROR_RECOVERY_FAILURE = 1279; // // MessageId: ERROR_ALREADY_FIBER // // MessageText: // // The current thread has already been converted to a fiber. // public static final int ERROR_ALREADY_FIBER = 1280; // // MessageId: ERROR_ALREADY_THREAD // // MessageText: // // The current thread has already been converted from a fiber. // public static final int ERROR_ALREADY_THREAD = 1281; // // MessageId: ERROR_STACK_BUFFER_OVERRUN // // MessageText: // // The system detected an overrun of a stack-based buffer in this // application. This overrun could potentially allow a malicious user to // gain control of this application. // public static final int ERROR_STACK_BUFFER_OVERRUN = 1282; // // MessageId: ERROR_PARAMETER_QUOTA_EXCEEDED // // MessageText: // // Data present in one of the parameters is more than the function can // operate on. // public static final int ERROR_PARAMETER_QUOTA_EXCEEDED = 1283; // // MessageId: ERROR_DEBUGGER_INACTIVE // // MessageText: // // An attempt to do an operation on a debug object failed because the object // is in the process of being deleted. // public static final int ERROR_DEBUGGER_INACTIVE = 1284; // // MessageId: ERROR_DELAY_LOAD_FAILED // // MessageText: // // An attempt to delay-load a .dll or get a function address in a // delay-loaded .dll failed. // public static final int ERROR_DELAY_LOAD_FAILED = 1285; // // MessageId: ERROR_VDM_DISALLOWED // // MessageText: // // %1 is a=16-bit application. You do not have permissions to execute=16-bit // applications. Check your permissions with your system administrator. // public static final int ERROR_VDM_DISALLOWED = 1286; // // MessageId: ERROR_UNIDENTIFIED_ERROR // // MessageText: // // Insufficient information exists to identify the cause of failure. // public static final int ERROR_UNIDENTIFIED_ERROR = 1287; // // MessageId: ERROR_INVALID_CRUNTIME_PARAMETER // // MessageText: // // The parameter passed to a C runtime function is incorrect. // public static final int ERROR_INVALID_CRUNTIME_PARAMETER = 1288; // // MessageId: ERROR_BEYOND_VDL // // MessageText: // // The operation occurred beyond the valid data length of the file. // public static final int ERROR_BEYOND_VDL = 1289; // // MessageId: ERROR_INCOMPATIBLE_SERVICE_SID_TYPE // // MessageText: // // The service start failed since one or more services in the same process // have an incompatible service SID type setting. A service with restricted // service SID type can only coexist in the same process with other services // with a restricted SID type. If the service SID type for this service was // just configured, the hosting process must be restarted in order to start // this service. // public static final int ERROR_INCOMPATIBLE_SERVICE_SID_TYPE = 1290; // // MessageId: ERROR_DRIVER_PROCESS_TERMINATED // // MessageText: // // The process hosting the driver for this device has been terminated. // public static final int ERROR_DRIVER_PROCESS_TERMINATED = 1291; // // MessageId: ERROR_IMPLEMENTATION_LIMIT // // MessageText: // // An operation attempted to exceed an implementation-defined limit. // public static final int ERROR_IMPLEMENTATION_LIMIT = 1292; // // MessageId: ERROR_PROCESS_IS_PROTECTED // // MessageText: // // Either the target process, or the target thread's containing process, is // a protected process. // public static final int ERROR_PROCESS_IS_PROTECTED = 1293; // // MessageId: ERROR_SERVICE_NOTIFY_CLIENT_LAGGING // // MessageText: // // The service notification client is lagging too far behind the current // state of services in the machine. // public static final int ERROR_SERVICE_NOTIFY_CLIENT_LAGGING = 1294; // // MessageId: ERROR_DISK_QUOTA_EXCEEDED // // MessageText: // // The requested file operation failed because the storage quota was // exceeded. // To free up disk space, move files to a different location or delete // unnecessary files. For more information, contact your system // administrator. // public static final int ERROR_DISK_QUOTA_EXCEEDED = 1295; // // MessageId: ERROR_CONTENT_BLOCKED // // MessageText: // // The requested file operation failed because the storage policy blocks // that type of file. For more information, contact your system // administrator. // public static final int ERROR_CONTENT_BLOCKED = 1296; // // MessageId: ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE // // MessageText: // // A privilege that the service requires to function properly does not exist // in the service account configuration. // You may use the Services Microsoft Management Console (MMC) snap-in // (services.msc) and the Local Security Settings MMC snap-in (secpol.msc) // to view the service configuration and the account configuration. // public static final int ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE = 1297; // ///////////////////////////////////////////////// // =// // =SECURITY Error codes=// // =// // =1299 to=1399=// // ///////////////////////////////////////////////// // // MessageId: ERROR_INVALID_LABEL // // MessageText: // // Indicates a particular Security ID may not be assigned as the label of an // object. // public static final int ERROR_INVALID_LABEL = 1299; // // MessageId: ERROR_NOT_ALL_ASSIGNED // // MessageText: // // Not all privileges or groups referenced are assigned to the caller. // public static final int ERROR_NOT_ALL_ASSIGNED = 1300; // // MessageId: ERROR_SOME_NOT_MAPPED // // MessageText: // // Some mapping between account names and security IDs was not done. // public static final int ERROR_SOME_NOT_MAPPED = 1301; // // MessageId: ERROR_NO_QUOTAS_FOR_ACCOUNT // // MessageText: // // No system quota limits are specifically set for this account. // public static final int ERROR_NO_QUOTAS_FOR_ACCOUNT = 1302; // // MessageId: ERROR_LOCAL_USER_SESSION_KEY // // MessageText: // // No encryption key is available. A well-known encryption key was returned. // public static final int ERROR_LOCAL_USER_SESSION_KEY = 1303; // // MessageId: ERROR_NULL_LM_PASSWORD // // MessageText: // // The password is too complex to be converted to a LAN Manager password. // The LAN Manager password returned is a NULL string. // public static final int ERROR_NULL_LM_PASSWORD = 1304; // // MessageId: ERROR_UNKNOWN_REVISION // // MessageText: // // The revision level is unknown. // public static final int ERROR_UNKNOWN_REVISION = 1305; // // MessageId: ERROR_REVISION_MISMATCH // // MessageText: // // Indicates two revision levels are incompatible. // public static final int ERROR_REVISION_MISMATCH = 1306; // // MessageId: ERROR_INVALID_OWNER // // MessageText: // // This security ID may not be assigned as the owner of this object. // public static final int ERROR_INVALID_OWNER = 1307; // // MessageId: ERROR_INVALID_PRIMARY_GROUP // // MessageText: // // This security ID may not be assigned as the primary group of an object. // public static final int ERROR_INVALID_PRIMARY_GROUP = 1308; // // MessageId: ERROR_NO_IMPERSONATION_TOKEN // // MessageText: // // An attempt has been made to operate on an impersonation token by a thread // that is not currently impersonating a client. // public static final int ERROR_NO_IMPERSONATION_TOKEN = 1309; // // MessageId: ERROR_CANT_DISABLE_MANDATORY // // MessageText: // // The group may not be disabled. // public static final int ERROR_CANT_DISABLE_MANDATORY = 1310; // // MessageId: ERROR_NO_LOGON_SERVERS // // MessageText: // // There are currently no logon servers available to service the logon // request. // public static final int ERROR_NO_LOGON_SERVERS = 1311; // // MessageId: ERROR_NO_SUCH_LOGON_SESSION // // MessageText: // // A specified logon session does not exist. It may already have been // terminated. // public static final int ERROR_NO_SUCH_LOGON_SESSION = 1312; // // MessageId: ERROR_NO_SUCH_PRIVILEGE // // MessageText: // // A specified privilege does not exist. // public static final int ERROR_NO_SUCH_PRIVILEGE = 1313; // // MessageId: ERROR_PRIVILEGE_NOT_HELD // // MessageText: // // A required privilege is not held by the client. // public static final int ERROR_PRIVILEGE_NOT_HELD = 1314; // // MessageId: ERROR_INVALID_ACCOUNT_NAME // // MessageText: // // The name provided is not a properly formed account name. // public static final int ERROR_INVALID_ACCOUNT_NAME = 1315; // // MessageId: ERROR_USER_EXISTS // // MessageText: // // The specified account already exists. // public static final int ERROR_USER_EXISTS = 1316; // // MessageId: ERROR_NO_SUCH_USER // // MessageText: // // The specified account does not exist. // public static final int ERROR_NO_SUCH_USER = 1317; // // MessageId: ERROR_GROUP_EXISTS // // MessageText: // // The specified group already exists. // public static final int ERROR_GROUP_EXISTS = 1318; // // MessageId: ERROR_NO_SUCH_GROUP // // MessageText: // // The specified group does not exist. // public static final int ERROR_NO_SUCH_GROUP = 1319; // // MessageId: ERROR_MEMBER_IN_GROUP // // MessageText: // // Either the specified user account is already a member of the specified // group, or the specified group cannot be deleted because it contains a // member. // public static final int ERROR_MEMBER_IN_GROUP = 1320; // // MessageId: ERROR_MEMBER_NOT_IN_GROUP // // MessageText: // // The specified user account is not a member of the specified group // account. // public static final int ERROR_MEMBER_NOT_IN_GROUP = 1321; // // MessageId: ERROR_LAST_ADMIN // // MessageText: // // The last remaining administration account cannot be disabled or deleted. // public static final int ERROR_LAST_ADMIN = 1322; // // MessageId: ERROR_WRONG_PASSWORD // // MessageText: // // Unable to update the password. The value provided as the current password // is incorrect. // public static final int ERROR_WRONG_PASSWORD = 1323; // // MessageId: ERROR_ILL_FORMED_PASSWORD // // MessageText: // // Unable to update the password. The value provided for the new password // contains values that are not allowed in passwords. // public static final int ERROR_ILL_FORMED_PASSWORD = 1324; // // MessageId: ERROR_PASSWORD_RESTRICTION // // MessageText: // // Unable to update the password. The value provided for the new password // does not meet the length, complexity, or history requirements of the // domain. // public static final int ERROR_PASSWORD_RESTRICTION = 1325; // // MessageId: ERROR_LOGON_FAILURE // // MessageText: // // Logon failure: unknown user name or bad password. // public static final int ERROR_LOGON_FAILURE = 1326; // // MessageId: ERROR_ACCOUNT_RESTRICTION // // MessageText: // // Logon failure: user account restriction. Possible reasons are blank // passwords not allowed, logon hour restrictions, or a policy restriction // has been enforced. // public static final int ERROR_ACCOUNT_RESTRICTION = 1327; // // MessageId: ERROR_INVALID_LOGON_HOURS // // MessageText: // // Logon failure: account logon time restriction violation. // public static final int ERROR_INVALID_LOGON_HOURS = 1328; // // MessageId: ERROR_INVALID_WORKSTATION // // MessageText: // // Logon failure: user not allowed to log on to this computer. // public static final int ERROR_INVALID_WORKSTATION = 1329; // // MessageId: ERROR_PASSWORD_EXPIRED // // MessageText: // // Logon failure: the specified account password has expired. // public static final int ERROR_PASSWORD_EXPIRED = 1330; // // MessageId: ERROR_ACCOUNT_DISABLED // // MessageText: // // Logon failure: account currently disabled. // public static final int ERROR_ACCOUNT_DISABLED = 1331; // // MessageId: ERROR_NONE_MAPPED // // MessageText: // // No mapping between account names and security IDs was done. // public static final int ERROR_NONE_MAPPED = 1332; // // MessageId: ERROR_TOO_MANY_LUIDS_REQUESTED // // MessageText: // // Too many local user identifiers (LUIDs) were requested at one time. // public static final int ERROR_TOO_MANY_LUIDS_REQUESTED = 1333; // // MessageId: ERROR_LUIDS_EXHAUSTED // // MessageText: // // No more local user identifiers (LUIDs) are available. // public static final int ERROR_LUIDS_EXHAUSTED = 1334; // // MessageId: ERROR_INVALID_SUB_AUTHORITY // // MessageText: // // The subauthority part of a security ID is invalid for this particular // use. // public static final int ERROR_INVALID_SUB_AUTHORITY = 1335; // // MessageId: ERROR_INVALID_ACL // // MessageText: // // The access control list (AC; structure is invalid. // public static final int ERROR_INVALID_ACL = 1336; // // MessageId: ERROR_INVALID_SID // // MessageText: // // The security ID structure is invalid. // public static final int ERROR_INVALID_SID = 1337; // // MessageId: ERROR_INVALID_SECURITY_DESCR // // MessageText: // // The security descriptor structure is invalid. // public static final int ERROR_INVALID_SECURITY_DESCR = 1338; // // MessageId: ERROR_BAD_INHERITANCE_ACL // // MessageText: // // The inherited access control list (AC; or access control entry (ACE) // could not be built. // public static final int ERROR_BAD_INHERITANCE_ACL = 1340; // // MessageId: ERROR_SERVER_DISABLED // // MessageText: // // The server is currently disabled. // public static final int ERROR_SERVER_DISABLED = 1341; // // MessageId: ERROR_SERVER_NOT_DISABLED // // MessageText: // // The server is currently enabled. // public static final int ERROR_SERVER_NOT_DISABLED = 1342; // // MessageId: ERROR_INVALID_ID_AUTHORITY // // MessageText: // // The value provided was an invalid value for an identifier authority. // public static final int ERROR_INVALID_ID_AUTHORITY = 1343; // // MessageId: ERROR_ALLOTTED_SPACE_EXCEEDED // // MessageText: // // No more memory is available for security information updates. // public static final int ERROR_ALLOTTED_SPACE_EXCEEDED = 1344; // // MessageId: ERROR_INVALID_GROUP_ATTRIBUTES // // MessageText: // // The specified attributes are invalid, or incompatible with the attributes // for the group as a whole. // public static final int ERROR_INVALID_GROUP_ATTRIBUTES = 1345; // // MessageId: ERROR_BAD_IMPERSONATION_LEVEL // // MessageText: // // Either a required impersonation level was not provided, or the provided // impersonation level is invalid. // public static final int ERROR_BAD_IMPERSONATION_LEVEL = 1346; // // MessageId: ERROR_CANT_OPEN_ANONYMOUS // // MessageText: // // Cannot open an anonymous level security token. // public static final int ERROR_CANT_OPEN_ANONYMOUS = 1347; // // MessageId: ERROR_BAD_VALIDATION_CLASS // // MessageText: // // The validation information class requested was invalid. // public static final int ERROR_BAD_VALIDATION_CLASS = 1348; // // MessageId: ERROR_BAD_TOKEN_TYPE // // MessageText: // // The type of the token is inappropriate for its attempted use. // public static final int ERROR_BAD_TOKEN_TYPE = 1349; // // MessageId: ERROR_NO_SECURITY_ON_OBJECT // // MessageText: // // Unable to perform a security operation on an object that has no // associated security. // public static final int ERROR_NO_SECURITY_ON_OBJECT = 1350; // // MessageId: ERROR_CANT_ACCESS_DOMAIN_INFO // // MessageText: // // Configuration information could not be read from the domain controller, // either because the machine is unavailable, or access has been denied. // public static final int ERROR_CANT_ACCESS_DOMAIN_INFO = 1351; // // MessageId: ERROR_INVALID_SERVER_STATE // // MessageText: // // The security account manager (SAM) or local security authority (LSA) // server was in the wrong state to perform the security operation. // public static final int ERROR_INVALID_SERVER_STATE = 1352; // // MessageId: ERROR_INVALID_DOMAIN_STATE // // MessageText: // // The domain was in the wrong state to perform the security operation. // public static final int ERROR_INVALID_DOMAIN_STATE = 1353; // // MessageId: ERROR_INVALID_DOMAIN_ROLE // // MessageText: // // This operation is only allowed for the Primary Domain Controller of the // domain. // public static final int ERROR_INVALID_DOMAIN_ROLE = 1354; // // MessageId: ERROR_NO_SUCH_DOMAIN // // MessageText: // // The specified domain either does not exist or could not be contacted. // public static final int ERROR_NO_SUCH_DOMAIN = 1355; // // MessageId: ERROR_DOMAIN_EXISTS // // MessageText: // // The specified domain already exists. // public static final int ERROR_DOMAIN_EXISTS = 1356; // // MessageId: ERROR_DOMAIN_LIMIT_EXCEEDED // // MessageText: // // An attempt was made to exceed the limit on the number of domains per // server. // public static final int ERROR_DOMAIN_LIMIT_EXCEEDED = 1357; // // MessageId: ERROR_INTERNAL_DB_CORRUPTION // // MessageText: // // Unable to complete the requested operation because of either a // catastrophic media failure or a data structure corruption on the disk. // public static final int ERROR_INTERNAL_DB_CORRUPTION = 1358; // // MessageId: ERROR_INTERNAL_ERROR // // MessageText: // // An internal error occurred. // public static final int ERROR_INTERNAL_ERROR = 1359; // // MessageId: ERROR_GENERIC_NOT_MAPPED // // MessageText: // // Generic access types were contained in an access mask which should // already be mapped to nongeneric types. // public static final int ERROR_GENERIC_NOT_MAPPED = 1360; // // MessageId: ERROR_BAD_DESCRIPTOR_FORMAT // // MessageText: // // A security descriptor is not in the right format (absolute or // self-relative). // public static final int ERROR_BAD_DESCRIPTOR_FORMAT = 1361; // // MessageId: ERROR_NOT_LOGON_PROCESS // // MessageText: // // The requested action is restricted for use by logon processes only. The // calling process has not registered as a logon process. // public static final int ERROR_NOT_LOGON_PROCESS = 1362; // // MessageId: ERROR_LOGON_SESSION_EXISTS // // MessageText: // // Cannot start a new logon session with an ID that is already in use. // public static final int ERROR_LOGON_SESSION_EXISTS = 1363; // // MessageId: ERROR_NO_SUCH_PACKAGE // // MessageText: // // A specified authentication package is unknown. // public static final int ERROR_NO_SUCH_PACKAGE = 1364; // // MessageId: ERROR_BAD_LOGON_SESSION_STATE // // MessageText: // // The logon session is not in a state that is consistent with the requested // operation. // public static final int ERROR_BAD_LOGON_SESSION_STATE = 1365; // // MessageId: ERROR_LOGON_SESSION_COLLISION // // MessageText: // // The logon session ID is already in use. // public static final int ERROR_LOGON_SESSION_COLLISION = 1366; // // MessageId: ERROR_INVALID_LOGON_TYPE // // MessageText: // // A logon request contained an invalid logon type value. // public static final int ERROR_INVALID_LOGON_TYPE = 1367; // // MessageId: ERROR_CANNOT_IMPERSONATE // // MessageText: // // Unable to impersonate using a named pipe until data has been read from // that pipe. // public static final int ERROR_CANNOT_IMPERSONATE = 1368; // // MessageId: ERROR_RXACT_INVALID_STATE // // MessageText: // // The transaction state of a registry subtree is incompatible with the // requested operation. // public static final int ERROR_RXACT_INVALID_STATE = 1369; // // MessageId: ERROR_RXACT_COMMIT_FAILURE // // MessageText: // // An internal security database corruption has been encountered. // public static final int ERROR_RXACT_COMMIT_FAILURE = 1370; // // MessageId: ERROR_SPECIAL_ACCOUNT // // MessageText: // // Cannot perform this operation on built-in accounts. // public static final int ERROR_SPECIAL_ACCOUNT = 1371; // // MessageId: ERROR_SPECIAL_GROUP // // MessageText: // // Cannot perform this operation on this built-in special group. // public static final int ERROR_SPECIAL_GROUP = 1372; // // MessageId: ERROR_SPECIAL_USER // // MessageText: // // Cannot perform this operation on this built-in special user. // public static final int ERROR_SPECIAL_USER = 1373; // // MessageId: ERROR_MEMBERS_PRIMARY_GROUP // // MessageText: // // The user cannot be removed from a group because the group is currently // the user's primary group. // public static final int ERROR_MEMBERS_PRIMARY_GROUP = 1374; // // MessageId: ERROR_TOKEN_ALREADY_IN_USE // // MessageText: // // The token is already in use as a primary token. // public static final int ERROR_TOKEN_ALREADY_IN_USE = 1375; // // MessageId: ERROR_NO_SUCH_ALIAS // // MessageText: // // The specified local group does not exist. // public static final int ERROR_NO_SUCH_ALIAS = 1376; // // MessageId: ERROR_MEMBER_NOT_IN_ALIAS // // MessageText: // // The specified account name is not a member of the group. // public static final int ERROR_MEMBER_NOT_IN_ALIAS = 1377; // // MessageId: ERROR_MEMBER_IN_ALIAS // // MessageText: // // The specified account name is already a member of the group. // public static final int ERROR_MEMBER_IN_ALIAS = 1378; // // MessageId: ERROR_ALIAS_EXISTS // // MessageText: // // The specified local group already exists. // public static final int ERROR_ALIAS_EXISTS = 1379; // // MessageId: ERROR_LOGON_NOT_GRANTED // // MessageText: // // Logon failure: the user has not been granted the requested logon type at // this computer. // public static final int ERROR_LOGON_NOT_GRANTED = 1380; // // MessageId: ERROR_TOO_MANY_SECRETS // // MessageText: // // The maximum number of secrets that may be stored in a single system has // been exceeded. // public static final int ERROR_TOO_MANY_SECRETS = 1381; // // MessageId: ERROR_SECRET_TOO_LONG // // MessageText: // // The length of a secret exceeds the maximum length allowed. // public static final int ERROR_SECRET_TOO_LONG = 1382; // // MessageId: ERROR_INTERNAL_DB_ERROR // // MessageText: // // The local security authority database contains an internal inconsistency. // public static final int ERROR_INTERNAL_DB_ERROR = 1383; // // MessageId: ERROR_TOO_MANY_CONTEXT_IDS // // MessageText: // // During a logon attempt, the user's security context accumulated too many // security IDs. // public static final int ERROR_TOO_MANY_CONTEXT_IDS = 1384; // // MessageId: ERROR_LOGON_TYPE_NOT_GRANTED // // MessageText: // // Logon failure: the user has not been granted the requested logon type at // this computer. // public static final int ERROR_LOGON_TYPE_NOT_GRANTED = 1385; // // MessageId: ERROR_NT_CROSS_ENCRYPTION_REQUIRED // // MessageText: // // A cross-encrypted password is necessary to change a user password. // public static final int ERROR_NT_CROSS_ENCRYPTION_REQUIRED = 1386; // // MessageId: ERROR_NO_SUCH_MEMBER // // MessageText: // // A member could not be added to or removed from the local group because // the member does not exist. // public static final int ERROR_NO_SUCH_MEMBER = 1387; // // MessageId: ERROR_INVALID_MEMBER // // MessageText: // // A new member could not be added to a local group because the member has // the wrong account type. // public static final int ERROR_INVALID_MEMBER = 1388; // // MessageId: ERROR_TOO_MANY_SIDS // // MessageText: // // Too many security IDs have been specified. // public static final int ERROR_TOO_MANY_SIDS = 1389; // // MessageId: ERROR_LM_CROSS_ENCRYPTION_REQUIRED // // MessageText: // // A cross-encrypted password is necessary to change this user password. // public static final int ERROR_LM_CROSS_ENCRYPTION_REQUIRED = 1390; // // MessageId: ERROR_NO_INHERITANCE // // MessageText: // // Indicates an ACL contains no inheritable components. // public static final int ERROR_NO_INHERITANCE = 1391; // // MessageId: ERROR_FILE_CORRUPT // // MessageText: // // The file or directory is corrupted and unreadable. // public static final int ERROR_FILE_CORRUPT = 1392; // // MessageId: ERROR_DISK_CORRUPT // // MessageText: // // The disk structure is corrupted and unreadable. // public static final int ERROR_DISK_CORRUPT = 1393; // // MessageId: ERROR_NO_USER_SESSION_KEY // // MessageText: // // There is no user session key for the specified logon session. // public static final int ERROR_NO_USER_SESSION_KEY = 1394; // // MessageId: ERROR_LICENSE_QUOTA_EXCEEDED // // MessageText: // // The service being accessed is licensed for a particular number of // connections. // No more connections can be made to the service at this time because there // are already as many connections as the service can accept. // public static final int ERROR_LICENSE_QUOTA_EXCEEDED = 1395; // // MessageId: ERROR_WRONG_TARGET_NAME // // MessageText: // // Logon Failure: The target account name is incorrect. // public static final int ERROR_WRONG_TARGET_NAME = 1396; // // MessageId: ERROR_MUTUAL_AUTH_FAILED // // MessageText: // // Mutual Authentication failed. The server's password is out of date at the // domain controller. // public static final int ERROR_MUTUAL_AUTH_FAILED = 1397; // // MessageId: ERROR_TIME_SKEW // // MessageText: // // There is a time and/or date difference between the client and server. // public static final int ERROR_TIME_SKEW = 1398; // // MessageId: ERROR_CURRENT_DOMAIN_NOT_ALLOWED // // MessageText: // // This operation cannot be performed on the current domain. // public static final int ERROR_CURRENT_DOMAIN_NOT_ALLOWED = 1399; // ///////////////////////////////////////////////// // =// // =WinUser Error codes=// // =// // =1400 to=1499=// // ///////////////////////////////////////////////// // // MessageId: ERROR_INVALID_WINDOW_HANDLE // // MessageText: // // Invalid window handle. // public static final int ERROR_INVALID_WINDOW_HANDLE = 1400; // // MessageId: ERROR_INVALID_MENU_HANDLE // // MessageText: // // Invalid menu handle. // public static final int ERROR_INVALID_MENU_HANDLE = 1401; // // MessageId: ERROR_INVALID_CURSOR_HANDLE // // MessageText: // // Invalid cursor handle. // public static final int ERROR_INVALID_CURSOR_HANDLE = 1402; // // MessageId: ERROR_INVALID_ACCEL_HANDLE // // MessageText: // // Invalid accelerator table handle. // public static final int ERROR_INVALID_ACCEL_HANDLE = 1403; // // MessageId: ERROR_INVALID_HOOK_HANDLE // // MessageText: // // Invalid hook handle. // public static final int ERROR_INVALID_HOOK_HANDLE = 1404; // // MessageId: ERROR_INVALID_DWP_HANDLE // // MessageText: // // Invalid handle to a multiple-window position structure. // public static final int ERROR_INVALID_DWP_HANDLE = 1405; // // MessageId: ERROR_TLW_WITH_WSCHILD // // MessageText: // // Cannot create a top-level child window. // public static final int ERROR_TLW_WITH_WSCHILD = 1406; // // MessageId: ERROR_CANNOT_FIND_WND_CLASS // // MessageText: // // Cannot find window class. // public static final int ERROR_CANNOT_FIND_WND_CLASS = 1407; // // MessageId: ERROR_WINDOW_OF_OTHER_THREAD // // MessageText: // // Invalid window; it belongs to other thread. // public static final int ERROR_WINDOW_OF_OTHER_THREAD = 1408; // // MessageId: ERROR_HOTKEY_ALREADY_REGISTERED // // MessageText: // // Hot key is already registered. // public static final int ERROR_HOTKEY_ALREADY_REGISTERED = 1409; // // MessageId: ERROR_CLASS_ALREADY_EXISTS // // MessageText: // // Class already exists. // public static final int ERROR_CLASS_ALREADY_EXISTS = 1410; // // MessageId: ERROR_CLASS_DOES_NOT_EXIST // // MessageText: // // Class does not exist. // public static final int ERROR_CLASS_DOES_NOT_EXIST = 1411; // // MessageId: ERROR_CLASS_HAS_WINDOWS // // MessageText: // // Class still has open windows. // public static final int ERROR_CLASS_HAS_WINDOWS = 1412; // // MessageId: ERROR_INVALID_INDEX // // MessageText: // // Invalid index. // public static final int ERROR_INVALID_INDEX = 1413; // // MessageId: ERROR_INVALID_ICON_HANDLE // // MessageText: // // Invalid icon handle. // public static final int ERROR_INVALID_ICON_HANDLE = 1414; // // MessageId: ERROR_PRIVATE_DIALOG_INDEX // // MessageText: // // Using private DIALOG window words. // public static final int ERROR_PRIVATE_DIALOG_INDEX = 1415; // // MessageId: ERROR_LISTBOX_ID_NOT_FOUND // // MessageText: // // The list box identifier was not found. // public static final int ERROR_LISTBOX_ID_NOT_FOUND = 1416; // // MessageId: ERROR_NO_WILDCARD_CHARACTERS // // MessageText: // // No wildcards were found. // public static final int ERROR_NO_WILDCARD_CHARACTERS = 1417; // // MessageId: ERROR_CLIPBOARD_NOT_OPEN // // MessageText: // // Thread does not have a clipboard open. // public static final int ERROR_CLIPBOARD_NOT_OPEN = 1418; // // MessageId: ERROR_HOTKEY_NOT_REGISTERED // // MessageText: // // Hot key is not registered. // public static final int ERROR_HOTKEY_NOT_REGISTERED = 1419; // // MessageId: ERROR_WINDOW_NOT_DIALOG // // MessageText: // // The window is not a valid dialog window. // public static final int ERROR_WINDOW_NOT_DIALOG = 1420; // // MessageId: ERROR_CONTROL_ID_NOT_FOUND // // MessageText: // // Control ID not found. // public static final int ERROR_CONTROL_ID_NOT_FOUND = 1421; // // MessageId: ERROR_INVALID_COMBOBOX_MESSAGE // // MessageText: // // Invalid message for a combo box because it does not have an edit control. // public static final int ERROR_INVALID_COMBOBOX_MESSAGE = 1422; // // MessageId: ERROR_WINDOW_NOT_COMBOBOX // // MessageText: // // The window is not a combo box. // public static final int ERROR_WINDOW_NOT_COMBOBOX = 1423; // // MessageId: ERROR_INVALID_EDIT_HEIGHT // // MessageText: // // Height must be less than=256. // public static final int ERROR_INVALID_EDIT_HEIGHT = 1424; // // MessageId: ERROR_DC_NOT_FOUND // // MessageText: // // Invalid device context (DC) handle. // public static final int ERROR_DC_NOT_FOUND = 1425; // // MessageId: ERROR_INVALID_HOOK_FILTER // // MessageText: // // Invalid hook procedure type. // public static final int ERROR_INVALID_HOOK_FILTER = 1426; // // MessageId: ERROR_INVALID_FILTER_PROC // // MessageText: // // Invalid hook procedure. // public static final int ERROR_INVALID_FILTER_PROC = 1427; // // MessageId: ERROR_HOOK_NEEDS_HMOD // // MessageText: // // Cannot set nonlocal hook without a module handle. // public static final int ERROR_HOOK_NEEDS_HMOD = 1428; // // MessageId: ERROR_GLOBAL_ONLY_HOOK // // MessageText: // // This hook procedure can only be set globally. // public static final int ERROR_GLOBAL_ONLY_HOOK = 1429; // // MessageId: ERROR_JOURNAL_HOOK_SET // // MessageText: // // The journal hook procedure is already installed. // public static final int ERROR_JOURNAL_HOOK_SET = 1430; // // MessageId: ERROR_HOOK_NOT_INSTALLED // // MessageText: // // The hook procedure is not installed. // public static final int ERROR_HOOK_NOT_INSTALLED = 1431; // // MessageId: ERROR_INVALID_LB_MESSAGE // // MessageText: // // Invalid message for single-selection list box. // public static final int ERROR_INVALID_LB_MESSAGE = 1432; // // MessageId: ERROR_SETCOUNT_ON_BAD_LB // // MessageText: // // LB_SETCOUNT sent to non-lazy list box. // public static final int ERROR_SETCOUNT_ON_BAD_LB = 1433; // // MessageId: ERROR_LB_WITHOUT_TABSTOPS // // MessageText: // // This list box does not support tab stops. // public static final int ERROR_LB_WITHOUT_TABSTOPS = 1434; // // MessageId: ERROR_DESTROY_OBJECT_OF_OTHER_THREAD // // MessageText: // // Cannot destroy object created by another thread. // public static final int ERROR_DESTROY_OBJECT_OF_OTHER_THREAD = 1435; // // MessageId: ERROR_CHILD_WINDOW_MENU // // MessageText: // // Child windows cannot have menus. // public static final int ERROR_CHILD_WINDOW_MENU = 1436; // // MessageId: ERROR_NO_SYSTEM_MENU // // MessageText: // // The window does not have a system menu. // public static final int ERROR_NO_SYSTEM_MENU = 1437; // // MessageId: ERROR_INVALID_MSGBOX_STYLE // // MessageText: // // Invalid message box style. // public static final int ERROR_INVALID_MSGBOX_STYLE = 1438; // // MessageId: ERROR_INVALID_SPI_VALUE // // MessageText: // // Invalid system-wide (SPI_*) parameter. // public static final int ERROR_INVALID_SPI_VALUE = 1439; // // MessageId: ERROR_SCREEN_ALREADY_LOCKED // // MessageText: // // Screen already locked. // public static final int ERROR_SCREEN_ALREADY_LOCKED = 1440; // // MessageId: ERROR_HWNDS_HAVE_DIFF_PARENT // // MessageText: // // All handles to windows in a multiple-window position structure must have // the same parent. // public static final int ERROR_HWNDS_HAVE_DIFF_PARENT = 1441; // // MessageId: ERROR_NOT_CHILD_WINDOW // // MessageText: // // The window is not a child window. // public static final int ERROR_NOT_CHILD_WINDOW = 1442; // // MessageId: ERROR_INVALID_GW_COMMAND // // MessageText: // // Invalid GW_* command. // public static final int ERROR_INVALID_GW_COMMAND = 1443; // // MessageId: ERROR_INVALID_THREAD_ID // // MessageText: // // Invalid thread identifier. // public static final int ERROR_INVALID_THREAD_ID = 1444; // // MessageId: ERROR_NON_MDICHILD_WINDOW // // MessageText: // // Cannot process a message from a window that is not a multiple document // interface (MDI) window. // public static final int ERROR_NON_MDICHILD_WINDOW = 1445; // // MessageId: ERROR_POPUP_ALREADY_ACTIVE // // MessageText: // // Popup menu already active. // public static final int ERROR_POPUP_ALREADY_ACTIVE = 1446; // // MessageId: ERROR_NO_SCROLLBARS // // MessageText: // // The window does not have scroll bars. // public static final int ERROR_NO_SCROLLBARS = 1447; // // MessageId: ERROR_INVALID_SCROLLBAR_RANGE // // MessageText: // // Scroll bar range cannot be greater than MAXLONG. // public static final int ERROR_INVALID_SCROLLBAR_RANGE = 1448; // // MessageId: ERROR_INVALID_SHOWWIN_COMMAND // // MessageText: // // Cannot show or remove the window in the way specified. // public static final int ERROR_INVALID_SHOWWIN_COMMAND = 1449; // // MessageId: ERROR_NO_SYSTEM_RESOURCES // // MessageText: // // Insufficient system resources exist to complete the requested service. // public static final int ERROR_NO_SYSTEM_RESOURCES = 1450; // // MessageId: ERROR_NONPAGED_SYSTEM_RESOURCES // // MessageText: // // Insufficient system resources exist to complete the requested service. // public static final int ERROR_NONPAGED_SYSTEM_RESOURCES = 1451; // // MessageId: ERROR_PAGED_SYSTEM_RESOURCES // // MessageText: // // Insufficient system resources exist to complete the requested service. // public static final int ERROR_PAGED_SYSTEM_RESOURCES = 1452; // // MessageId: ERROR_WORKING_SET_QUOTA // // MessageText: // // Insufficient quota to complete the requested service. // public static final int ERROR_WORKING_SET_QUOTA = 1453; // // MessageId: ERROR_PAGEFILE_QUOTA // // MessageText: // // Insufficient quota to complete the requested service. // public static final int ERROR_PAGEFILE_QUOTA = 1454; // // MessageId: ERROR_COMMITMENT_LIMIT // // MessageText: // // The paging file is too small for this operation to complete. // public static final int ERROR_COMMITMENT_LIMIT = 1455; // // MessageId: ERROR_MENU_ITEM_NOT_FOUND // // MessageText: // // A menu item was not found. // public static final int ERROR_MENU_ITEM_NOT_FOUND = 1456; // // MessageId: ERROR_INVALID_KEYBOARD_HANDLE // // MessageText: // // Invalid keyboard layout handle. // public static final int ERROR_INVALID_KEYBOARD_HANDLE = 1457; // // MessageId: ERROR_HOOK_TYPE_NOT_ALLOWED // // MessageText: // // Hook type not allowed. // public static final int ERROR_HOOK_TYPE_NOT_ALLOWED = 1458; // // MessageId: ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION // // MessageText: // // This operation requires an interactive window station. // public static final int ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION = 1459; // // MessageId: ERROR_TIMEOUT // // MessageText: // // This operation returned because the timeout period expired. // public static final int ERROR_TIMEOUT = 1460; // // MessageId: ERROR_INVALID_MONITOR_HANDLE // // MessageText: // // Invalid monitor handle. // public static final int ERROR_INVALID_MONITOR_HANDLE = 1461; // // MessageId: ERROR_INCORRECT_SIZE // // MessageText: // // Incorrect size argument. // public static final int ERROR_INCORRECT_SIZE = 1462; // // MessageId: ERROR_SYMLINK_CLASS_DISABLED // // MessageText: // // The symbolic link cannot be followed because its type is disabled. // public static final int ERROR_SYMLINK_CLASS_DISABLED = 1463; // // MessageId: ERROR_SYMLINK_NOT_SUPPORTED // // MessageText: // // This application does not support the current operation on symbolic // links. // public static final int ERROR_SYMLINK_NOT_SUPPORTED = 1464; // // MessageId: ERROR_XML_PARSE_ERROR // // MessageText: // // Windows was unable to parse the requested XML data. // public static final int ERROR_XML_PARSE_ERROR = 1465; // // MessageId: ERROR_XMLDSIG_ERROR // // MessageText: // // An error was encountered while processing an XML digital signature. // public static final int ERROR_XMLDSIG_ERROR = 1466; // // MessageId: ERROR_RESTART_APPLICATION // // MessageText: // // This application must be restarted. // public static final int ERROR_RESTART_APPLICATION = 1467; // // MessageId: ERROR_WRONG_COMPARTMENT // // MessageText: // // The caller made the connection request in the wrong routing compartment. // public static final int ERROR_WRONG_COMPARTMENT = 1468; // // MessageId: ERROR_AUTHIP_FAILURE // // MessageText: // // There was an AuthIP failure when attempting to connect to the remote // host. // public static final int ERROR_AUTHIP_FAILURE = 1469; // ///////////////////////////////////////////////// // =// // =EventLog Error codes=// // =// // =1500 to=1549=// // ///////////////////////////////////////////////// // // MessageId: ERROR_EVENTLOG_FILE_CORRUPT // // MessageText: // // The event log file is corrupted. // public static final int ERROR_EVENTLOG_FILE_CORRUPT = 1500; // // MessageId: ERROR_EVENTLOG_CANT_START // // MessageText: // // No event log file could be opened, so the event logging service did not // start. // public static final int ERROR_EVENTLOG_CANT_START = 1501; // // MessageId: ERROR_LOG_FILE_FULL // // MessageText: // // The event log file is full. // public static final int ERROR_LOG_FILE_FULL = 1502; // // MessageId: ERROR_EVENTLOG_FILE_CHANGED // // MessageText: // // The event log file has changed between read operations. // public static final int ERROR_EVENTLOG_FILE_CHANGED = 1503; // ///////////////////////////////////////////////// // =// // =Class Scheduler Error codes=// // =// // =1550 to=1599=// // ///////////////////////////////////////////////// // // MessageId: ERROR_INVALID_TASK_NAME // // MessageText: // // The specified task name is invalid. // public static final int ERROR_INVALID_TASK_NAME = 1550; // // MessageId: ERROR_INVALID_TASK_INDEX // // MessageText: // // The specified task index is invalid. // public static final int ERROR_INVALID_TASK_INDEX = 1551; // // MessageId: ERROR_THREAD_ALREADY_IN_TASK // // MessageText: // // The specified thread is already joining a task. // public static final int ERROR_THREAD_ALREADY_IN_TASK = 1552; // ///////////////////////////////////////////////// // =// // =MSI Error codes=// // =// // =1600 to=1699=// // ///////////////////////////////////////////////// // // MessageId: ERROR_INSTALL_SERVICE_FAILURE // // MessageText: // // The Windows Installer Service could not be accessed. This can occur if // the Windows Installer is not correctly installed. Contact your support // personnel for assistance. // public static final int ERROR_INSTALL_SERVICE_FAILURE = 1601; // // MessageId: ERROR_INSTALL_USEREXIT // // MessageText: // // User cancelled installation. // public static final int ERROR_INSTALL_USEREXIT = 1602; // // MessageId: ERROR_INSTALL_FAILURE // // MessageText: // // Fatal error during installation. // public static final int ERROR_INSTALL_FAILURE = 1603; // // MessageId: ERROR_INSTALL_SUSPEND // // MessageText: // // Installation suspended, incomplete. // public static final int ERROR_INSTALL_SUSPEND = 1604; // // MessageId: ERROR_UNKNOWN_PRODUCT // // MessageText: // // This action is only valid for products that are currently installed. // public static final int ERROR_UNKNOWN_PRODUCT = 1605; // // MessageId: ERROR_UNKNOWN_FEATURE // // MessageText: // // Feature ID not registered. // public static final int ERROR_UNKNOWN_FEATURE = 1606; // // MessageId: ERROR_UNKNOWN_COMPONENT // // MessageText: // // Component ID not registered. // public static final int ERROR_UNKNOWN_COMPONENT = 1607; // // MessageId: ERROR_UNKNOWN_PROPERTY // // MessageText: // // Unknown property. // public static final int ERROR_UNKNOWN_PROPERTY = 1608; // // MessageId: ERROR_INVALID_HANDLE_STATE // // MessageText: // // Handle is in an invalid state. // public static final int ERROR_INVALID_HANDLE_STATE = 1609; // // MessageId: ERROR_BAD_CONFIGURATION // // MessageText: // // The configuration data for this product is corrupt. Contact your support // personnel. // public static final int ERROR_BAD_CONFIGURATION = 1610; // // MessageId: ERROR_INDEX_ABSENT // // MessageText: // // Component qualifier not present. // public static final int ERROR_INDEX_ABSENT = 1611; // // MessageId: ERROR_INSTALL_SOURCE_ABSENT // // MessageText: // // The installation source for this product is not available. Verify that // the source exists and that you can access it. // public static final int ERROR_INSTALL_SOURCE_ABSENT = 1612; // // MessageId: ERROR_INSTALL_PACKAGE_VERSION // // MessageText: // // This installation package cannot be installed by the Windows Installer // service. You must install a Windows service pack that contains a newer // version of the Windows Installer service. // public static final int ERROR_INSTALL_PACKAGE_VERSION = 1613; // // MessageId: ERROR_PRODUCT_UNINSTALLED // // MessageText: // // Product is uninstalled. // public static final int ERROR_PRODUCT_UNINSTALLED = 1614; // // MessageId: ERROR_BAD_QUERY_SYNTAX // // MessageText: // // SQL query syntax invalid or unsupported. // public static final int ERROR_BAD_QUERY_SYNTAX = 1615; // // MessageId: ERROR_INVALID_FIELD // // MessageText: // // Record field does not exist. // public static final int ERROR_INVALID_FIELD = 1616; // // MessageId: ERROR_DEVICE_REMOVED // // MessageText: // // The device has been removed. // public static final int ERROR_DEVICE_REMOVED = 1617; // // MessageId: ERROR_INSTALL_ALREADY_RUNNING // // MessageText: // // Another installation is already in progress. Complete that installation // before proceeding with this install. // public static final int ERROR_INSTALL_ALREADY_RUNNING = 1618; // // MessageId: ERROR_INSTALL_PACKAGE_OPEN_FAILED // // MessageText: // // This installation package could not be opened. Verify that the package // exists and that you can access it, or contact the application vendor to // verify that this is a valid Windows Installer package. // public static final int ERROR_INSTALL_PACKAGE_OPEN_FAILED = 1619; // // MessageId: ERROR_INSTALL_PACKAGE_INVALID // // MessageText: // // This installation package could not be opened. Contact the application // vendor to verify that this is a valid Windows Installer package. // public static final int ERROR_INSTALL_PACKAGE_INVALID = 1620; // // MessageId: ERROR_INSTALL_UI_FAILURE // // MessageText: // // There was an error starting the Windows Installer service user interface. // Contact your support personnel. // public static final int ERROR_INSTALL_UI_FAILURE = 1621; // // MessageId: ERROR_INSTALL_LOG_FAILURE // // MessageText: // // Error opening installation log file. Verify that the specified log file // location exists and that you can write to it. // public static final int ERROR_INSTALL_LOG_FAILURE = 1622; // // MessageId: ERROR_INSTALL_LANGUAGE_UNSUPPORTED // // MessageText: // // The language of this installation package is not supported by your // system. // public static final int ERROR_INSTALL_LANGUAGE_UNSUPPORTED = 1623; // // MessageId: ERROR_INSTALL_TRANSFORM_FAILURE // // MessageText: // // Error applying transforms. Verify that the specified transform paths are // valid. // public static final int ERROR_INSTALL_TRANSFORM_FAILURE = 1624; // // MessageId: ERROR_INSTALL_PACKAGE_REJECTED // // MessageText: // // This installation is forbidden by system policy. Contact your system // administrator. // public static final int ERROR_INSTALL_PACKAGE_REJECTED = 1625; // // MessageId: ERROR_FUNCTION_NOT_CALLED // // MessageText: // // Function could not be executed. // public static final int ERROR_FUNCTION_NOT_CALLED = 1626; // // MessageId: ERROR_FUNCTION_FAILED // // MessageText: // // Function failed during execution. // public static final int ERROR_FUNCTION_FAILED = 1627; // // MessageId: ERROR_INVALID_TABLE // // MessageText: // // Invalid or unknown table specified. // public static final int ERROR_INVALID_TABLE = 1628; // // MessageId: ERROR_DATATYPE_MISMATCH // // MessageText: // // Data supplied is of wrong type. // public static final int ERROR_DATATYPE_MISMATCH = 1629; // // MessageId: ERROR_UNSUPPORTED_TYPE // // MessageText: // // Data of this type is not supported. // public static final int ERROR_UNSUPPORTED_TYPE = 1630; // // MessageId: ERROR_CREATE_FAILED // // MessageText: // // The Windows Installer service failed to start. Contact your support // personnel. // public static final int ERROR_CREATE_FAILED = 1631; // // MessageId: ERROR_INSTALL_TEMP_UNWRITABLE // // MessageText: // // The Temp folder is on a drive that is full or is inaccessible. Free up // space on the drive or verify that you have write permission on the Temp // folder. // public static final int ERROR_INSTALL_TEMP_UNWRITABLE = 1632; // // MessageId: ERROR_INSTALL_PLATFORM_UNSUPPORTED // // MessageText: // // This installation package is not supported by this processor type. // Contact your product vendor. // public static final int ERROR_INSTALL_PLATFORM_UNSUPPORTED = 1633; // // MessageId: ERROR_INSTALL_NOTUSED // // MessageText: // // Component not used on this computer. // public static final int ERROR_INSTALL_NOTUSED = 1634; // // MessageId: ERROR_PATCH_PACKAGE_OPEN_FAILED // // MessageText: // // This update package could not be opened. Verify that the update package // exists and that you can access it, or contact the application vendor to // verify that this is a valid Windows Installer update package. // public static final int ERROR_PATCH_PACKAGE_OPEN_FAILED = 1635; // // MessageId: ERROR_PATCH_PACKAGE_INVALID // // MessageText: // // This update package could not be opened. Contact the application vendor // to verify that this is a valid Windows Installer update package. // public static final int ERROR_PATCH_PACKAGE_INVALID = 1636; // // MessageId: ERROR_PATCH_PACKAGE_UNSUPPORTED // // MessageText: // // This update package cannot be processed by the Windows Installer service. // You must install a Windows service pack that contains a newer version of // the Windows Installer service. // public static final int ERROR_PATCH_PACKAGE_UNSUPPORTED = 1637; // // MessageId: ERROR_PRODUCT_VERSION // // MessageText: // // Another version of this product is already installed. Installation of // this version cannot continue. To configure or remove the existing version // of this product, use Add/Remove Programs on the Control Panel. // public static final int ERROR_PRODUCT_VERSION = 1638; // // MessageId: ERROR_INVALID_COMMAND_LINE // // MessageText: // // Invalid command line argument. Consult the Windows Installer SDK for // detailed command line help. // public static final int ERROR_INVALID_COMMAND_LINE = 1639; // // MessageId: ERROR_INSTALL_REMOTE_DISALLOWED // // MessageText: // // Only administrators have permission to add, remove, or configure server // software during a Terminal services remote session. If you want to // install or configure software on the server, contact your network // administrator. // public static final int ERROR_INSTALL_REMOTE_DISALLOWED = 1640; // // MessageId: ERROR_SUCCESS_REBOOT_INITIATED // // MessageText: // // The requested operation completed successfully. The system will be // restarted so the changes can take effect. // public static final int ERROR_SUCCESS_REBOOT_INITIATED = 1641; // // MessageId: ERROR_PATCH_TARGET_NOT_FOUND // // MessageText: // // The upgrade cannot be installed by the Windows Installer service because // the program to be upgraded may be missing, or the upgrade may update a // different version of the program. Verify that the program to be upgraded // exists on your computer and that you have the correct upgrade. // public static final int ERROR_PATCH_TARGET_NOT_FOUND = 1642; // // MessageId: ERROR_PATCH_PACKAGE_REJECTED // // MessageText: // // The update package is not permitted by software restriction policy. // public static final int ERROR_PATCH_PACKAGE_REJECTED = 1643; // // MessageId: ERROR_INSTALL_TRANSFORM_REJECTED // // MessageText: // // One or more customizations are not permitted by software restriction // policy. // public static final int ERROR_INSTALL_TRANSFORM_REJECTED = 1644; // // MessageId: ERROR_INSTALL_REMOTE_PROHIBITED // // MessageText: // // The Windows Installer does not permit installation from a Remote Desktop // Connection. // public static final int ERROR_INSTALL_REMOTE_PROHIBITED = 1645; // // MessageId: ERROR_PATCH_REMOVAL_UNSUPPORTED // // MessageText: // // Uninstallation of the update package is not supported. // public static final int ERROR_PATCH_REMOVAL_UNSUPPORTED = 1646; // // MessageId: ERROR_UNKNOWN_PATCH // // MessageText: // // The update is not applied to this product. // public static final int ERROR_UNKNOWN_PATCH = 1647; // // MessageId: ERROR_PATCH_NO_SEQUENCE // // MessageText: // // No valid sequence could be found for the set of updates. // public static final int ERROR_PATCH_NO_SEQUENCE = 1648; // // MessageId: ERROR_PATCH_REMOVAL_DISALLOWED // // MessageText: // // Update removal was disallowed by policy. // public static final int ERROR_PATCH_REMOVAL_DISALLOWED = 1649; // // MessageId: ERROR_INVALID_PATCH_XML // // MessageText: // // The XML update data is invalid. // public static final int ERROR_INVALID_PATCH_XML = 1650; // // MessageId: ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT // // MessageText: // // Windows Installer does not permit updating of managed advertised // products. At least one feature of the product must be installed before // applying the update. // public static final int ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT = 1651; // // MessageId: ERROR_INSTALL_SERVICE_SAFEBOOT // // MessageText: // // The Windows Installer service is not accessible in Safe Mode. Please try // again when your computer is not in Safe Mode or you can use System // Restore to return your machine to a previous good state. // public static final int ERROR_INSTALL_SERVICE_SAFEBOOT = 1652; // ///////////////////////////////////////////////// // =// // =RPC Error codes=// // =// // =1700 to=1999=// // ///////////////////////////////////////////////// // // MessageId: RPC_S_INVALID_STRING_BINDING // // MessageText: // // The string binding is invalid. // public static final int RPC_S_INVALID_STRING_BINDING = 1700; // // MessageId: RPC_S_WRONG_KIND_OF_BINDING // // MessageText: // // The binding handle is not the correct type. // public static final int RPC_S_WRONG_KIND_OF_BINDING = 1701; // // MessageId: RPC_S_INVALID_BINDING // // MessageText: // // The binding handle is invalid. // public static final int RPC_S_INVALID_BINDING = 1702; // // MessageId: RPC_S_PROTSEQ_NOT_SUPPORTED // // MessageText: // // The RPC protocol sequence is not supported. // public static final int RPC_S_PROTSEQ_NOT_SUPPORTED = 1703; // // MessageId: RPC_S_INVALID_RPC_PROTSEQ // // MessageText: // // The RPC protocol sequence is invalid. // public static final int RPC_S_INVALID_RPC_PROTSEQ = 1704; // // MessageId: RPC_S_INVALID_STRING_UUID // // MessageText: // // The string universal unique identifier (UUID) is invalid. // public static final int RPC_S_INVALID_STRING_UUID = 1705; // // MessageId: RPC_S_INVALID_ENDPOINT_FORMAT // // MessageText: // // The endpoint format is invalid. // public static final int RPC_S_INVALID_ENDPOINT_FORMAT = 1706; // // MessageId: RPC_S_INVALID_NET_ADDR // // MessageText: // // The network address is invalid. // public static final int RPC_S_INVALID_NET_ADDR = 1707; // // MessageId: RPC_S_NO_ENDPOINT_FOUND // // MessageText: // // No endpoint was found. // public static final int RPC_S_NO_ENDPOINT_FOUND = 1708; // // MessageId: RPC_S_INVALID_TIMEOUT // // MessageText: // // The timeout value is invalid. // public static final int RPC_S_INVALID_TIMEOUT = 1709; // // MessageId: RPC_S_OBJECT_NOT_FOUND // // MessageText: // // The object universal unique identifier (UUID) was not found. // public static final int RPC_S_OBJECT_NOT_FOUND = 1710; // // MessageId: RPC_S_ALREADY_REGISTERED // // MessageText: // // The object universal unique identifier (UUID) has already been // registered. // public static final int RPC_S_ALREADY_REGISTERED = 1711; // // MessageId: RPC_S_TYPE_ALREADY_REGISTERED // // MessageText: // // The type universal unique identifier (UUID) has already been registered. // public static final int RPC_S_TYPE_ALREADY_REGISTERED = 1712; // // MessageId: RPC_S_ALREADY_LISTENING // // MessageText: // // The RPC server is already listening. // public static final int RPC_S_ALREADY_LISTENING = 1713; // // MessageId: RPC_S_NO_PROTSEQS_REGISTERED // // MessageText: // // No protocol sequences have been registered. // public static final int RPC_S_NO_PROTSEQS_REGISTERED = 1714; // // MessageId: RPC_S_NOT_LISTENING // // MessageText: // // The RPC server is not listening. // public static final int RPC_S_NOT_LISTENING = 1715; // // MessageId: RPC_S_UNKNOWN_MGR_TYPE // // MessageText: // // The manager type is unknown. // public static final int RPC_S_UNKNOWN_MGR_TYPE = 1716; // // MessageId: RPC_S_UNKNOWN_IF // // MessageText: // // The interface is unknown. // public static final int RPC_S_UNKNOWN_IF = 1717; // // MessageId: RPC_S_NO_BINDINGS // // MessageText: // // There are no bindings. // public static final int RPC_S_NO_BINDINGS = 1718; // // MessageId: RPC_S_NO_PROTSEQS // // MessageText: // // There are no protocol sequences. // public static final int RPC_S_NO_PROTSEQS = 1719; // // MessageId: RPC_S_CANT_CREATE_ENDPOINT // // MessageText: // // The endpoint cannot be created. // public static final int RPC_S_CANT_CREATE_ENDPOINT = 1720; // // MessageId: RPC_S_OUT_OF_RESOURCES // // MessageText: // // Not enough resources are available to complete this operation. // public static final int RPC_S_OUT_OF_RESOURCES = 1721; // // MessageId: RPC_S_SERVER_UNAVAILABLE // // MessageText: // // The RPC server is unavailable. // public static final int RPC_S_SERVER_UNAVAILABLE = 1722; // // MessageId: RPC_S_SERVER_TOO_BUSY // // MessageText: // // The RPC server is too busy to complete this operation. // public static final int RPC_S_SERVER_TOO_BUSY = 1723; // // MessageId: RPC_S_INVALID_NETWORK_OPTIONS // // MessageText: // // The network options are invalid. // public static final int RPC_S_INVALID_NETWORK_OPTIONS = 1724; // // MessageId: RPC_S_NO_CALL_ACTIVE // // MessageText: // // There are no remote procedure calls active on this thread. // public static final int RPC_S_NO_CALL_ACTIVE = 1725; // // MessageId: RPC_S_CALL_FAILED // // MessageText: // // The remote procedure call failed. // public static final int RPC_S_CALL_FAILED = 1726; // // MessageId: RPC_S_CALL_FAILED_DNE // // MessageText: // // The remote procedure call failed and did not execute. // public static final int RPC_S_CALL_FAILED_DNE = 1727; // // MessageId: RPC_S_PROTOCOL_ERROR // // MessageText: // // A remote procedure call (RPC) protocol error occurred. // public static final int RPC_S_PROTOCOL_ERROR = 1728; // // MessageId: RPC_S_PROXY_ACCESS_DENIED // // MessageText: // // Access to the HTTP proxy is denied. // public static final int RPC_S_PROXY_ACCESS_DENIED = 1729; // // MessageId: RPC_S_UNSUPPORTED_TRANS_SYN // // MessageText: // // The transfer syntax is not supported by the RPC server. // public static final int RPC_S_UNSUPPORTED_TRANS_SYN = 1730; // // MessageId: RPC_S_UNSUPPORTED_TYPE // // MessageText: // // The universal unique identifier (UUID) type is not supported. // public static final int RPC_S_UNSUPPORTED_TYPE = 1732; // // MessageId: RPC_S_INVALID_TAG // // MessageText: // // The tag is invalid. // public static final int RPC_S_INVALID_TAG = 1733; // // MessageId: RPC_S_INVALID_BOUND // // MessageText: // // The array bounds are invalid. // public static final int RPC_S_INVALID_BOUND = 1734; // // MessageId: RPC_S_NO_ENTRY_NAME // // MessageText: // // The binding does not contain an entry name. // public static final int RPC_S_NO_ENTRY_NAME = 1735; // // MessageId: RPC_S_INVALID_NAME_SYNTAX // // MessageText: // // The name syntax is invalid. // public static final int RPC_S_INVALID_NAME_SYNTAX = 1736; // // MessageId: RPC_S_UNSUPPORTED_NAME_SYNTAX // // MessageText: // // The name syntax is not supported. // public static final int RPC_S_UNSUPPORTED_NAME_SYNTAX = 1737; // // MessageId: RPC_S_UUID_NO_ADDRESS // // MessageText: // // No network address is available to use to construct a universal unique // identifier (UUID). // public static final int RPC_S_UUID_NO_ADDRESS = 1739; // // MessageId: RPC_S_DUPLICATE_ENDPOINT // // MessageText: // // The endpoint is a duplicate. // public static final int RPC_S_DUPLICATE_ENDPOINT = 1740; // // MessageId: RPC_S_UNKNOWN_AUTHN_TYPE // // MessageText: // // The authentication type is unknown. // public static final int RPC_S_UNKNOWN_AUTHN_TYPE = 1741; // // MessageId: RPC_S_MAX_CALLS_TOO_SMALL // // MessageText: // // The maximum number of calls is too small. // public static final int RPC_S_MAX_CALLS_TOO_SMALL = 1742; // // MessageId: RPC_S_STRING_TOO_LONG // // MessageText: // // The string is too long. // public static final int RPC_S_STRING_TOO_LONG = 1743; // // MessageId: RPC_S_PROTSEQ_NOT_FOUND // // MessageText: // // The RPC protocol sequence was not found. // public static final int RPC_S_PROTSEQ_NOT_FOUND = 1744; // // MessageId: RPC_S_PROCNUM_OUT_OF_RANGE // // MessageText: // // The procedure number is out of range. // public static final int RPC_S_PROCNUM_OUT_OF_RANGE = 1745; // // MessageId: RPC_S_BINDING_HAS_NO_AUTH // // MessageText: // // The binding does not contain any authentication information. // public static final int RPC_S_BINDING_HAS_NO_AUTH = 1746; // // MessageId: RPC_S_UNKNOWN_AUTHN_SERVICE // // MessageText: // // The authentication service is unknown. // public static final int RPC_S_UNKNOWN_AUTHN_SERVICE = 1747; // // MessageId: RPC_S_UNKNOWN_AUTHN_LEVEL // // MessageText: // // The authentication level is unknown. // public static final int RPC_S_UNKNOWN_AUTHN_LEVEL = 1748; // // MessageId: RPC_S_INVALID_AUTH_IDENTITY // // MessageText: // // The security context is invalid. // public static final int RPC_S_INVALID_AUTH_IDENTITY = 1749; // // MessageId: RPC_S_UNKNOWN_AUTHZ_SERVICE // // MessageText: // // The authorization service is unknown. // public static final int RPC_S_UNKNOWN_AUTHZ_SERVICE = 1750; // // MessageId: EPT_S_INVALID_ENTRY // // MessageText: // // The entry is invalid. // public static final int EPT_S_INVALID_ENTRY = 1751; // // MessageId: EPT_S_CANT_PERFORM_OP // // MessageText: // // The server endpoint cannot perform the operation. // public static final int EPT_S_CANT_PERFORM_OP = 1752; // // MessageId: EPT_S_NOT_REGISTERED // // MessageText: // // There are no more endpoints available from the endpoint mapper. // public static final int EPT_S_NOT_REGISTERED = 1753; // // MessageId: RPC_S_NOTHING_TO_EXPORT // // MessageText: // // No interfaces have been exported. // public static final int RPC_S_NOTHING_TO_EXPORT = 1754; // // MessageId: RPC_S_INCOMPLETE_NAME // // MessageText: // // The entry name is incomplete. // public static final int RPC_S_INCOMPLETE_NAME = 1755; // // MessageId: RPC_S_INVALID_VERS_OPTION // // MessageText: // // The version option is invalid. // public static final int RPC_S_INVALID_VERS_OPTION = 1756; // // MessageId: RPC_S_NO_MORE_MEMBERS // // MessageText: // // There are no more members. // public static final int RPC_S_NO_MORE_MEMBERS = 1757; // // MessageId: RPC_S_NOT_ALL_OBJS_UNEXPORTED // // MessageText: // // There is nothing to unexport. // public static final int RPC_S_NOT_ALL_OBJS_UNEXPORTED = 1758; // // MessageId: RPC_S_INTERFACE_NOT_FOUND // // MessageText: // // The interface was not found. // public static final int RPC_S_INTERFACE_NOT_FOUND = 1759; // // MessageId: RPC_S_ENTRY_ALREADY_EXISTS // // MessageText: // // The entry already exists. // public static final int RPC_S_ENTRY_ALREADY_EXISTS = 1760; // // MessageId: RPC_S_ENTRY_NOT_FOUND // // MessageText: // // The entry is not found. // public static final int RPC_S_ENTRY_NOT_FOUND = 1761; // // MessageId: RPC_S_NAME_SERVICE_UNAVAILABLE // // MessageText: // // The name service is unavailable. // public static final int RPC_S_NAME_SERVICE_UNAVAILABLE = 1762; // // MessageId: RPC_S_INVALID_NAF_ID // // MessageText: // // The network address family is invalid. // public static final int RPC_S_INVALID_NAF_ID = 1763; // // MessageId: RPC_S_CANNOT_SUPPORT // // MessageText: // // The requested operation is not supported. // public static final int RPC_S_CANNOT_SUPPORT = 1764; // // MessageId: RPC_S_NO_CONTEXT_AVAILABLE // // MessageText: // // No security context is available to allow impersonation. // public static final int RPC_S_NO_CONTEXT_AVAILABLE = 1765; // // MessageId: RPC_S_INTERNAL_ERROR // // MessageText: // // An internal error occurred in a remote procedure call (RPC). // public static final int RPC_S_INTERNAL_ERROR = 1766; // // MessageId: RPC_S_ZERO_DIVIDE // // MessageText: // // The RPC server attempted an integer division by zero. // public static final int RPC_S_ZERO_DIVIDE = 1767; // // MessageId: RPC_S_ADDRESS_ERROR // // MessageText: // // An addressing error occurred in the RPC server. // public static final int RPC_S_ADDRESS_ERROR = 1768; // // MessageId: RPC_S_FP_DIV_ZERO // // MessageText: // // A floating-point operation at the RPC server caused a division by zero. // public static final int RPC_S_FP_DIV_ZERO = 1769; // // MessageId: RPC_S_FP_UNDERFLOW // // MessageText: // // A floating-point underflow occurred at the RPC server. // public static final int RPC_S_FP_UNDERFLOW = 1770; // // MessageId: RPC_S_FP_OVERFLOW // // MessageText: // // A floating-point overflow occurred at the RPC server. // public static final int RPC_S_FP_OVERFLOW = 1771; // // MessageId: RPC_X_NO_MORE_ENTRIES // // MessageText: // // The list of RPC servers available for the binding of auto handles has // been exhausted. // public static final int RPC_X_NO_MORE_ENTRIES = 1772; // // MessageId: RPC_X_SS_CHAR_TRANS_OPEN_FAIL // // MessageText: // // Unable to open the character translation table file. // public static final int RPC_X_SS_CHAR_TRANS_OPEN_FAIL = 1773; // // MessageId: RPC_X_SS_CHAR_TRANS_SHORT_FILE // // MessageText: // // The file containing the character translation table has fewer than=512 // bytes. // public static final int RPC_X_SS_CHAR_TRANS_SHORT_FILE = 1774; // // MessageId: RPC_X_SS_IN_NULL_CONTEXT // // MessageText: // // A null context handle was passed from the client to the host during a // remote procedure call. // public static final int RPC_X_SS_IN_NULL_CONTEXT = 1775; // // MessageId: RPC_X_SS_CONTEXT_DAMAGED // // MessageText: // // The context handle changed during a remote procedure call. // public static final int RPC_X_SS_CONTEXT_DAMAGED = 1777; // // MessageId: RPC_X_SS_HANDLES_MISMATCH // // MessageText: // // The binding handles passed to a remote procedure call do not match. // public static final int RPC_X_SS_HANDLES_MISMATCH = 1778; // // MessageId: RPC_X_SS_CANNOT_GET_CALL_HANDLE // // MessageText: // // The stub is unable to get the remote procedure call handle. // public static final int RPC_X_SS_CANNOT_GET_CALL_HANDLE = 1779; // // MessageId: RPC_X_NULL_REF_POINTER // // MessageText: // // A null reference pointer was passed to the stub. // public static final int RPC_X_NULL_REF_POINTER = 1780; // // MessageId: RPC_X_ENUM_VALUE_OUT_OF_RANGE // // MessageText: // // The enumeration value is out of range. // public static final int RPC_X_ENUM_VALUE_OUT_OF_RANGE = 1781; // // MessageId: RPC_X_BYTE_COUNT_TOO_SMALL // // MessageText: // // The byte count is too small. // public static final int RPC_X_BYTE_COUNT_TOO_SMALL = 1782; // // MessageId: RPC_X_BAD_STUB_DATA // // MessageText: // // The stub received bad data. // public static final int RPC_X_BAD_STUB_DATA = 1783; // // MessageId: ERROR_INVALID_USER_BUFFER // // MessageText: // // The supplied user buffer is not valid for the requested operation. // public static final int ERROR_INVALID_USER_BUFFER = 1784; // // MessageId: ERROR_UNRECOGNIZED_MEDIA // // MessageText: // // The disk media is not recognized. It may not be formatted. // public static final int ERROR_UNRECOGNIZED_MEDIA = 1785; // // MessageId: ERROR_NO_TRUST_LSA_SECRET // // MessageText: // // The workstation does not have a trust secret. // public static final int ERROR_NO_TRUST_LSA_SECRET = 1786; // // MessageId: ERROR_NO_TRUST_SAM_ACCOUNT // // MessageText: // // The security database on the server does not have a computer account for // this workstation trust relationship. // public static final int ERROR_NO_TRUST_SAM_ACCOUNT = 1787; // // MessageId: ERROR_TRUSTED_DOMAIN_FAILURE // // MessageText: // // The trust relationship between the primary domain and the trusted domain // failed. // public static final int ERROR_TRUSTED_DOMAIN_FAILURE = 1788; // // MessageId: ERROR_TRUSTED_RELATIONSHIP_FAILURE // // MessageText: // // The trust relationship between this workstation and the primary domain // failed. // public static final int ERROR_TRUSTED_RELATIONSHIP_FAILURE = 1789; // // MessageId: ERROR_TRUST_FAILURE // // MessageText: // // The network logon failed. // public static final int ERROR_TRUST_FAILURE = 1790; // // MessageId: RPC_S_CALL_IN_PROGRESS // // MessageText: // // A remote procedure call is already in progress for this thread. // public static final int RPC_S_CALL_IN_PROGRESS = 1791; // // MessageId: ERROR_NETLOGON_NOT_STARTED // // MessageText: // // An attempt was made to logon, but the network logon service was not // started. // public static final int ERROR_NETLOGON_NOT_STARTED = 1792; // // MessageId: ERROR_ACCOUNT_EXPIRED // // MessageText: // // The user's account has expired. // public static final int ERROR_ACCOUNT_EXPIRED = 1793; // // MessageId: ERROR_REDIRECTOR_HAS_OPEN_HANDLES // // MessageText: // // The redirector is in use and cannot be unloaded. // public static final int ERROR_REDIRECTOR_HAS_OPEN_HANDLES = 1794; // // MessageId: ERROR_PRINTER_DRIVER_ALREADY_INSTALLED // // MessageText: // // The specified printer driver is already installed. // public static final int ERROR_PRINTER_DRIVER_ALREADY_INSTALLED = 1795; // // MessageId: ERROR_UNKNOWN_PORT // // MessageText: // // The specified port is unknown. // public static final int ERROR_UNKNOWN_PORT = 1796; // // MessageId: ERROR_UNKNOWN_PRINTER_DRIVER // // MessageText: // // The printer driver is unknown. // public static final int ERROR_UNKNOWN_PRINTER_DRIVER = 1797; // // MessageId: ERROR_UNKNOWN_PRINTPROCESSOR // // MessageText: // // The print processor is unknown. // public static final int ERROR_UNKNOWN_PRINTPROCESSOR = 1798; // // MessageId: ERROR_INVALID_SEPARATOR_FILE // // MessageText: // // The specified separator file is invalid. // public static final int ERROR_INVALID_SEPARATOR_FILE = 1799; // // MessageId: ERROR_INVALID_PRIORITY // // MessageText: // // The specified priority is invalid. // public static final int ERROR_INVALID_PRIORITY = 1800; // // MessageId: ERROR_INVALID_PRINTER_NAME // // MessageText: // // The printer name is invalid. // public static final int ERROR_INVALID_PRINTER_NAME = 1801; // // MessageId: ERROR_PRINTER_ALREADY_EXISTS // // MessageText: // // The printer already exists. // public static final int ERROR_PRINTER_ALREADY_EXISTS = 1802; // // MessageId: ERROR_INVALID_PRINTER_COMMAND // // MessageText: // // The printer command is invalid. // public static final int ERROR_INVALID_PRINTER_COMMAND = 1803; // // MessageId: ERROR_INVALID_DATATYPE // // MessageText: // // The specified datatype is invalid. // public static final int ERROR_INVALID_DATATYPE = 1804; // // MessageId: ERROR_INVALID_ENVIRONMENT // // MessageText: // // The environment specified is invalid. // public static final int ERROR_INVALID_ENVIRONMENT = 1805; // // MessageId: RPC_S_NO_MORE_BINDINGS // // MessageText: // // There are no more bindings. // public static final int RPC_S_NO_MORE_BINDINGS = 1806; // // MessageId: ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT // // MessageText: // // The account used is an interdomain trust account. Use your global user // account or local user account to access this server. // public static final int ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT = 1807; // // MessageId: ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT // // MessageText: // // The account used is a computer account. Use your global user account or // local user account to access this server. // public static final int ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT = 1808; // // MessageId: ERROR_NOLOGON_SERVER_TRUST_ACCOUNT // // MessageText: // // The account used is a server trust account. Use your global user account // or local user account to access this server. // public static final int ERROR_NOLOGON_SERVER_TRUST_ACCOUNT = 1809; // // MessageId: ERROR_DOMAIN_TRUST_INCONSISTENT // // MessageText: // // The name or security ID (SID) of the domain specified is inconsistent // with the trust information for that domain. // public static final int ERROR_DOMAIN_TRUST_INCONSISTENT = 1810; // // MessageId: ERROR_SERVER_HAS_OPEN_HANDLES // // MessageText: // // The server is in use and cannot be unloaded. // public static final int ERROR_SERVER_HAS_OPEN_HANDLES = 1811; // // MessageId: ERROR_RESOURCE_DATA_NOT_FOUND // // MessageText: // // The specified image file did not contain a resource section. // public static final int ERROR_RESOURCE_DATA_NOT_FOUND = 1812; // // MessageId: ERROR_RESOURCE_TYPE_NOT_FOUND // // MessageText: // // The specified resource type cannot be found in the image file. // public static final int ERROR_RESOURCE_TYPE_NOT_FOUND = 1813; // // MessageId: ERROR_RESOURCE_NAME_NOT_FOUND // // MessageText: // // The specified resource name cannot be found in the image file. // public static final int ERROR_RESOURCE_NAME_NOT_FOUND = 1814; // // MessageId: ERROR_RESOURCE_LANG_NOT_FOUND // // MessageText: // // The specified resource language ID cannot be found in the image file. // public static final int ERROR_RESOURCE_LANG_NOT_FOUND = 1815; // // MessageId: ERROR_NOT_ENOUGH_QUOTA // // MessageText: // // Not enough quota is available to process this command. // public static final int ERROR_NOT_ENOUGH_QUOTA = 1816; // // MessageId: RPC_S_NO_INTERFACES // // MessageText: // // No interfaces have been registered. // public static final int RPC_S_NO_INTERFACES = 1817; // // MessageId: RPC_S_CALL_CANCELLED // // MessageText: // // The remote procedure call was cancelled. // public static final int RPC_S_CALL_CANCELLED = 1818; // // MessageId: RPC_S_BINDING_INCOMPLETE // // MessageText: // // The binding handle does not contain all required information. // public static final int RPC_S_BINDING_INCOMPLETE = 1819; // // MessageId: RPC_S_COMM_FAILURE // // MessageText: // // A communications failure occurred during a remote procedure call. // public static final int RPC_S_COMM_FAILURE = 1820; // // MessageId: RPC_S_UNSUPPORTED_AUTHN_LEVEL // // MessageText: // // The requested authentication level is not supported. // public static final int RPC_S_UNSUPPORTED_AUTHN_LEVEL = 1821; // // MessageId: RPC_S_NO_PRINC_NAME // // MessageText: // // No principal name registered. // public static final int RPC_S_NO_PRINC_NAME = 1822; // // MessageId: RPC_S_NOT_RPC_ERROR // // MessageText: // // The error specified is not a valid Windows RPC error code. // public static final int RPC_S_NOT_RPC_ERROR = 1823; // // MessageId: RPC_S_UUID_LOCAL_ONLY // // MessageText: // // A UUID that is valid only on this computer has been allocated. // public static final int RPC_S_UUID_LOCAL_ONLY = 1824; // // MessageId: RPC_S_SEC_PKG_ERROR // // MessageText: // // A security package specific error occurred. // public static final int RPC_S_SEC_PKG_ERROR = 1825; // // MessageId: RPC_S_NOT_CANCELLED // // MessageText: // // Thread is not canceled. // public static final int RPC_S_NOT_CANCELLED = 1826; // // MessageId: RPC_X_INVALID_ES_ACTION // // MessageText: // // Invalid operation on the encoding/decoding handle. // public static final int RPC_X_INVALID_ES_ACTION = 1827; // // MessageId: RPC_X_WRONG_ES_VERSION // // MessageText: // // Incompatible version of the serializing package. // public static final int RPC_X_WRONG_ES_VERSION = 1828; // // MessageId: RPC_X_WRONG_STUB_VERSION // // MessageText: // // Incompatible version of the RPC stub. // public static final int RPC_X_WRONG_STUB_VERSION = 1829; // // MessageId: RPC_X_INVALID_PIPE_OBJECT // // MessageText: // // The RPC pipe object is invalid or corrupted. // public static final int RPC_X_INVALID_PIPE_OBJECT = 1830; // // MessageId: RPC_X_WRONG_PIPE_ORDER // // MessageText: // // An invalid operation was attempted on an RPC pipe object. // public static final int RPC_X_WRONG_PIPE_ORDER = 1831; // // MessageId: RPC_X_WRONG_PIPE_VERSION // // MessageText: // // Unsupported RPC pipe version. // public static final int RPC_X_WRONG_PIPE_VERSION = 1832; // // MessageId: RPC_S_GROUP_MEMBER_NOT_FOUND // // MessageText: // // The group member was not found. // public static final int RPC_S_GROUP_MEMBER_NOT_FOUND = 1898; // // MessageId: EPT_S_CANT_CREATE // // MessageText: // // The endpoint mapper database entry could not be created. // public static final int EPT_S_CANT_CREATE = 1899; // // MessageId: RPC_S_INVALID_OBJECT // // MessageText: // // The object universal unique identifier (UUID) is the nil UUID. // public static final int RPC_S_INVALID_OBJECT = 1900; // // MessageId: ERROR_INVALID_TIME // // MessageText: // // The specified time is invalid. // public static final int ERROR_INVALID_TIME = 1901; // // MessageId: ERROR_INVALID_FORM_NAME // // MessageText: // // The specified form name is invalid. // public static final int ERROR_INVALID_FORM_NAME = 1902; // // MessageId: ERROR_INVALID_FORM_SIZE // // MessageText: // // The specified form size is invalid. // public static final int ERROR_INVALID_FORM_SIZE = 1903; // // MessageId: ERROR_ALREADY_WAITING // // MessageText: // // The specified printer handle is already being waited on // public static final int ERROR_ALREADY_WAITING = 1904; // // MessageId: ERROR_PRINTER_DELETED // // MessageText: // // The specified printer has been deleted. // public static final int ERROR_PRINTER_DELETED = 1905; // // MessageId: ERROR_INVALID_PRINTER_STATE // // MessageText: // // The state of the printer is invalid. // public static final int ERROR_INVALID_PRINTER_STATE = 1906; // // MessageId: ERROR_PASSWORD_MUST_CHANGE // // MessageText: // // The user's password must be changed before logging on the first time. // public static final int ERROR_PASSWORD_MUST_CHANGE = 1907; // // MessageId: ERROR_DOMAIN_CONTROLLER_NOT_FOUND // // MessageText: // // Could not find the domain controller for this domain. // public static final int ERROR_DOMAIN_CONTROLLER_NOT_FOUND = 1908; // // MessageId: ERROR_ACCOUNT_LOCKED_OUT // // MessageText: // // The referenced account is currently locked out and may not be logged on // to. // public static final int ERROR_ACCOUNT_LOCKED_OUT = 1909; // // MessageId: OR_INVALID_OXID // // MessageText: // // The object exporter specified was not found. // public static final int OR_INVALID_OXID = 1910; // // MessageId: OR_INVALID_OID // // MessageText: // // The object specified was not found. // public static final int OR_INVALID_OID = 1911; // // MessageId: OR_INVALID_SET // // MessageText: // // The object resolver set specified was not found. // public static final int OR_INVALID_SET = 1912; // // MessageId: RPC_S_SEND_INCOMPLETE // // MessageText: // // Some data remains to be sent in the request buffer. // public static final int RPC_S_SEND_INCOMPLETE = 1913; // // MessageId: RPC_S_INVALID_ASYNC_HANDLE // // MessageText: // // Invalid asynchronous remote procedure call handle. // public static final int RPC_S_INVALID_ASYNC_HANDLE = 1914; // // MessageId: RPC_S_INVALID_ASYNC_CALL // // MessageText: // // Invalid asynchronous RPC call handle for this operation. // public static final int RPC_S_INVALID_ASYNC_CALL = 1915; // // MessageId: RPC_X_PIPE_CLOSED // // MessageText: // // The RPC pipe object has already been closed. // public static final int RPC_X_PIPE_CLOSED = 1916; // // MessageId: RPC_X_PIPE_DISCIPLINE_ERROR // // MessageText: // // The RPC call completed before all pipes were processed. // public static final int RPC_X_PIPE_DISCIPLINE_ERROR = 1917; // // MessageId: RPC_X_PIPE_EMPTY // // MessageText: // // No more data is available from the RPC pipe. // public static final int RPC_X_PIPE_EMPTY = 1918; // // MessageId: ERROR_NO_SITENAME // // MessageText: // // No site name is available for this machine. // public static final int ERROR_NO_SITENAME = 1919; // // MessageId: ERROR_CANT_ACCESS_FILE // // MessageText: // // The file cannot be accessed by the system. // public static final int ERROR_CANT_ACCESS_FILE = 1920; // // MessageId: ERROR_CANT_RESOLVE_FILENAME // // MessageText: // // The name of the file cannot be resolved by the system. // public static final int ERROR_CANT_RESOLVE_FILENAME = 1921; // // MessageId: RPC_S_ENTRY_TYPE_MISMATCH // // MessageText: // // The entry is not of the expected type. // public static final int RPC_S_ENTRY_TYPE_MISMATCH = 1922; // // MessageId: RPC_S_NOT_ALL_OBJS_EXPORTED // // MessageText: // // Not all object UUIDs could be exported to the specified entry. // public static final int RPC_S_NOT_ALL_OBJS_EXPORTED = 1923; // // MessageId: RPC_S_INTERFACE_NOT_EXPORTED // // MessageText: // // Interface could not be exported to the specified entry. // public static final int RPC_S_INTERFACE_NOT_EXPORTED = 1924; // // MessageId: RPC_S_PROFILE_NOT_ADDED // // MessageText: // // The specified profile entry could not be added. // public static final int RPC_S_PROFILE_NOT_ADDED = 1925; // // MessageId: RPC_S_PRF_ELT_NOT_ADDED // // MessageText: // // The specified profile element could not be added. // public static final int RPC_S_PRF_ELT_NOT_ADDED = 1926; // // MessageId: RPC_S_PRF_ELT_NOT_REMOVED // // MessageText: // // The specified profile element could not be removed. // public static final int RPC_S_PRF_ELT_NOT_REMOVED = 1927; // // MessageId: RPC_S_GRP_ELT_NOT_ADDED // // MessageText: // // The group element could not be added. // public static final int RPC_S_GRP_ELT_NOT_ADDED = 1928; // // MessageId: RPC_S_GRP_ELT_NOT_REMOVED // // MessageText: // // The group element could not be removed. // public static final int RPC_S_GRP_ELT_NOT_REMOVED = 1929; // // MessageId: ERROR_KM_DRIVER_BLOCKED // // MessageText: // // The printer driver is not compatible with a policy enabled on your // computer that blocks NT=4.0 drivers. // public static final int ERROR_KM_DRIVER_BLOCKED = 1930; // // MessageId: ERROR_CONTEXT_EXPIRED // // MessageText: // // The context has expired and can no longer be used. // public static final int ERROR_CONTEXT_EXPIRED = 1931; // // MessageId: ERROR_PER_USER_TRUST_QUOTA_EXCEEDED // // MessageText: // // The current user's delegated trust creation quota has been exceeded. // public static final int ERROR_PER_USER_TRUST_QUOTA_EXCEEDED = 1932; // // MessageId: ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED // // MessageText: // // The total delegated trust creation quota has been exceeded. // public static final int ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED = 1933; // // MessageId: ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED // // MessageText: // // The current user's delegated trust deletion quota has been exceeded. // public static final int ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED = 1934; // // MessageId: ERROR_AUTHENTICATION_FIREWALL_FAILED // // MessageText: // // Logon Failure: The machine you are logging onto is protected by an // authentication firewall. The specified account is not allowed to // authenticate to the machine. // public static final int ERROR_AUTHENTICATION_FIREWALL_FAILED = 1935; // // MessageId: ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED // // MessageText: // // Remote connections to the Print Spooler are blocked by a policy set on // your machine. // public static final int ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED = 1936; // // MessageId: ERROR_NTLM_BLOCKED // // MessageText: // // Logon Failure: Authentication failed because NTLM authentication has been // disabled. // public static final int ERROR_NTLM_BLOCKED = 1937; // ///////////////////////////////////////////////// // =// // =OpenGL Error codes=// // =// // =2000 to=2009=// // ///////////////////////////////////////////////// // // MessageId: ERROR_INVALID_PIXEL_FORMAT // // MessageText: // // The pixel format is invalid. // public static final int ERROR_INVALID_PIXEL_FORMAT = 2000; // // MessageId: ERROR_BAD_DRIVER // // MessageText: // // The specified driver is invalid. // public static final int ERROR_BAD_DRIVER = 2001; // // MessageId: ERROR_INVALID_WINDOW_STYLE // // MessageText: // // The window style or class attribute is invalid for this operation. // public static final int ERROR_INVALID_WINDOW_STYLE = 2002; // // MessageId: ERROR_METAFILE_NOT_SUPPORTED // // MessageText: // // The requested metafile operation is not supported. // public static final int ERROR_METAFILE_NOT_SUPPORTED = 2003; // // MessageId: ERROR_TRANSFORM_NOT_SUPPORTED // // MessageText: // // The requested transformation operation is not supported. // public static final int ERROR_TRANSFORM_NOT_SUPPORTED = 2004; // // MessageId: ERROR_CLIPPING_NOT_SUPPORTED // // MessageText: // // The requested clipping operation is not supported. // public static final int ERROR_CLIPPING_NOT_SUPPORTED = 2005; // ///////////////////////////////////////////////// // =// // Image Color Management Error codes // // =// // =2010 to=2049=// // ///////////////////////////////////////////////// // // MessageId: ERROR_INVALID_CMM // // MessageText: // // The specified color management module is invalid. // public static final int ERROR_INVALID_CMM = 2010; // // MessageId: ERROR_INVALID_PROFILE // // MessageText: // // The specified color profile is invalid. // public static final int ERROR_INVALID_PROFILE = 2011; // // MessageId: ERROR_TAG_NOT_FOUND // // MessageText: // // The specified tag was not found. // public static final int ERROR_TAG_NOT_FOUND = 2012; // // MessageId: ERROR_TAG_NOT_PRESENT // // MessageText: // // A required tag is not present. // public static final int ERROR_TAG_NOT_PRESENT = 2013; // // MessageId: ERROR_DUPLICATE_TAG // // MessageText: // // The specified tag is already present. // public static final int ERROR_DUPLICATE_TAG = 2014; // // MessageId: ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE // // MessageText: // // The specified color profile is not associated with the specified device. // public static final int ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE = 2015; // // MessageId: ERROR_PROFILE_NOT_FOUND // // MessageText: // // The specified color profile was not found. // public static final int ERROR_PROFILE_NOT_FOUND = 2016; // // MessageId: ERROR_INVALID_COLORSPACE // // MessageText: // // The specified color space is invalid. // public static final int ERROR_INVALID_COLORSPACE = 2017; // // MessageId: ERROR_ICM_NOT_ENABLED // // MessageText: // // Image Color Management is not enabled. // public static final int ERROR_ICM_NOT_ENABLED = 2018; // // MessageId: ERROR_DELETING_ICM_XFORM // // MessageText: // // There was an error while deleting the color transform. // public static final int ERROR_DELETING_ICM_XFORM = 2019; // // MessageId: ERROR_INVALID_TRANSFORM // // MessageText: // // The specified color transform is invalid. // public static final int ERROR_INVALID_TRANSFORM = 2020; // // MessageId: ERROR_COLORSPACE_MISMATCH // // MessageText: // // The specified transform does not match the bitmap's color space. // public static final int ERROR_COLORSPACE_MISMATCH = 2021; // // MessageId: ERROR_INVALID_COLORINDEX // // MessageText: // // The specified named color index is not present in the profile. // public static final int ERROR_INVALID_COLORINDEX = 2022; // // MessageId: ERROR_PROFILE_DOES_NOT_MATCH_DEVICE // // MessageText: // // The specified profile is intended for a device of a different type than // the specified device. // public static final int ERROR_PROFILE_DOES_NOT_MATCH_DEVICE = 2023; // ///////////////////////////////////////////////// // =// // =Winnet32 Error codes=// // =// // =2100 to=2999=// // =// // The range=2100 through=2999 is reserved for // // network status codes. See lmerr.h for a // // complete listing=// // ///////////////////////////////////////////////// // // MessageId: ERROR_CONNECTED_OTHER_PASSWORD // // MessageText: // // The network connection was made successfully, but the user had to be // prompted for a password other than the one originally specified. // public static final int ERROR_CONNECTED_OTHER_PASSWORD = 2108; // // MessageId: ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT // // MessageText: // // The network connection was made successfully using default credentials. // public static final int ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT = 2109; // // MessageId: ERROR_BAD_USERNAME // // MessageText: // // The specified username is invalid. // public static final int ERROR_BAD_USERNAME = 2202; // // MessageId: ERROR_NOT_CONNECTED // // MessageText: // // This network connection does not exist. // public static final int ERROR_NOT_CONNECTED = 2250; // // MessageId: ERROR_OPEN_FILES // // MessageText: // // This network connection has files open or requests pending. // public static final int ERROR_OPEN_FILES = 2401; // // MessageId: ERROR_ACTIVE_CONNECTIONS // // MessageText: // // Active connections still exist. // public static final int ERROR_ACTIVE_CONNECTIONS = 2402; // // MessageId: ERROR_DEVICE_IN_USE // // MessageText: // // The device is in use by an active process and cannot be disconnected. // public static final int ERROR_DEVICE_IN_USE = 2404; // ///////////////////////////////////////////////// // =// // =Win32 Spooler Error codes=// // =// // =3000 to=3049=// // ///////////////////////////////////////////////// // // MessageId: ERROR_UNKNOWN_PRINT_MONITOR // // MessageText: // // The specified print monitor is unknown. // public static final int ERROR_UNKNOWN_PRINT_MONITOR = 3000; // // MessageId: ERROR_PRINTER_DRIVER_IN_USE // // MessageText: // // The specified printer driver is currently in use. // public static final int ERROR_PRINTER_DRIVER_IN_USE = 3001; // // MessageId: ERROR_SPOOL_FILE_NOT_FOUND // // MessageText: // // The spool file was not found. // public static final int ERROR_SPOOL_FILE_NOT_FOUND = 3002; // // MessageId: ERROR_SPL_NO_STARTDOC // // MessageText: // // A StartDocPrinter call was not issued. // public static final int ERROR_SPL_NO_STARTDOC = 3003; // // MessageId: ERROR_SPL_NO_ADDJOB // // MessageText: // // An AddJob call was not issued. // public static final int ERROR_SPL_NO_ADDJOB = 3004; // // MessageId: ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED // // MessageText: // // The specified print processor has already been installed. // public static final int ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED = 3005; // // MessageId: ERROR_PRINT_MONITOR_ALREADY_INSTALLED // // MessageText: // // The specified print monitor has already been installed. // public static final int ERROR_PRINT_MONITOR_ALREADY_INSTALLED = 3006; // // MessageId: ERROR_INVALID_PRINT_MONITOR // // MessageText: // // The specified print monitor does not have the required functions. // public static final int ERROR_INVALID_PRINT_MONITOR = 3007; // // MessageId: ERROR_PRINT_MONITOR_IN_USE // // MessageText: // // The specified print monitor is currently in use. // public static final int ERROR_PRINT_MONITOR_IN_USE = 3008; // // MessageId: ERROR_PRINTER_HAS_JOBS_QUEUED // // MessageText: // // The requested operation is not allowed when there are jobs queued to the // printer. // public static final int ERROR_PRINTER_HAS_JOBS_QUEUED = 3009; // // MessageId: ERROR_SUCCESS_REBOOT_REQUIRED // // MessageText: // // The requested operation is successful. Changes will not be effective // until the system is rebooted. // public static final int ERROR_SUCCESS_REBOOT_REQUIRED = 3010; // // MessageId: ERROR_SUCCESS_RESTART_REQUIRED // // MessageText: // // The requested operation is successful. Changes will not be effective // until the service is restarted. // public static final int ERROR_SUCCESS_RESTART_REQUIRED = 3011; // // MessageId: ERROR_PRINTER_NOT_FOUND // // MessageText: // // No printers were found. // public static final int ERROR_PRINTER_NOT_FOUND = 3012; // // MessageId: ERROR_PRINTER_DRIVER_WARNED // // MessageText: // // The printer driver is known to be unreliable. // public static final int ERROR_PRINTER_DRIVER_WARNED = 3013; // // MessageId: ERROR_PRINTER_DRIVER_BLOCKED // // MessageText: // // The printer driver is known to harm the system. // public static final int ERROR_PRINTER_DRIVER_BLOCKED = 3014; // // MessageId: ERROR_PRINTER_DRIVER_PACKAGE_IN_USE // // MessageText: // // The specified printer driver package is currently in use. // public static final int ERROR_PRINTER_DRIVER_PACKAGE_IN_USE = 3015; // // MessageId: ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND // // MessageText: // // Unable to find a core driver package that is required by the printer // driver package. // public static final int ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND = 3016; // // MessageId: ERROR_FAIL_REBOOT_REQUIRED // // MessageText: // // The requested operation failed. A system reboot is required to roll back // changes made. // public static final int ERROR_FAIL_REBOOT_REQUIRED = 3017; // // MessageId: ERROR_FAIL_REBOOT_INITIATED // // MessageText: // // The requested operation failed. A system reboot has been initiated to // roll back changes made. // public static final int ERROR_FAIL_REBOOT_INITIATED = 3018; // // MessageId: ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED // // MessageText: // // The specified printer driver was not found on the system and needs to be // downloaded. // public static final int ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED = 3019; // // MessageId: ERROR_PRINT_JOB_RESTART_REQUIRED // // MessageText: // // The requested print job has failed to print. A print system update // requires the job to be resubmitted. // public static final int ERROR_PRINT_JOB_RESTART_REQUIRED = 3020; // ///////////////////////////////////////////////// // =// // =Available=// // =// // =3050 to=3899=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =IO Error Codes=// // =// // =3900 to=3999=// // ///////////////////////////////////////////////// // // MessageId: ERROR_IO_REISSUE_AS_CACHED // // MessageText: // // Reissue the given operation as a cached IO operation // public static final int ERROR_IO_REISSUE_AS_CACHED = 3950; // ///////////////////////////////////////////////// // =// // =Wins Error codes=// // =// // =4000 to=4049=// // ///////////////////////////////////////////////// // // MessageId: ERROR_WINS_INTERNAL // // MessageText: // // WINS encountered an error while processing the command. // public static final int ERROR_WINS_INTERNAL = 4000; // // MessageId: ERROR_CAN_NOT_DEL_LOCAL_WINS // // MessageText: // // The local WINS cannot be deleted. // public static final int ERROR_CAN_NOT_DEL_LOCAL_WINS = 4001; // // MessageId: ERROR_STATIC_INIT // // MessageText: // // The importation from the file failed. // public static final int ERROR_STATIC_INIT = 4002; // // MessageId: ERROR_INC_BACKUP // // MessageText: // // The backup failed. Was a full backup done before? // public static final int ERROR_INC_BACKUP = 4003; // // MessageId: ERROR_FULL_BACKUP // // MessageText: // // The backup failed. Check the directory to which you are backing the // database. // public static final int ERROR_FULL_BACKUP = 4004; // // MessageId: ERROR_REC_NON_EXISTENT // // MessageText: // // The name does not exist in the WINS database. // public static final int ERROR_REC_NON_EXISTENT = 4005; // // MessageId: ERROR_RPL_NOT_ALLOWED // // MessageText: // // Replication with a nonconfigured partner is not allowed. // public static final int ERROR_RPL_NOT_ALLOWED = 4006; // ///////////////////////////////////////////////// // =// // =Available=// // =// // =4050 to=4099=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =DHCP Error codes=// // =// // =4100 to=4149=// // ///////////////////////////////////////////////// // // MessageId: ERROR_DHCP_ADDRESS_CONFLICT // // MessageText: // // The DHCP client has obtained an IP address that is already in use on the // network. The local interface will be disabled until the DHCP client can // obtain a new address. // public static final int ERROR_DHCP_ADDRESS_CONFLICT = 4100; // ///////////////////////////////////////////////// // =// // =Available=// // =// // =4150 to=4199=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =WMI Error codes=// // =// // =4200 to=4249=// // ///////////////////////////////////////////////// // // MessageId: ERROR_WMI_GUID_NOT_FOUND // // MessageText: // // The GUID passed was not recognized as valid by a WMI data provider. // public static final int ERROR_WMI_GUID_NOT_FOUND = 4200; // // MessageId: ERROR_WMI_INSTANCE_NOT_FOUND // // MessageText: // // The instance name passed was not recognized as valid by a WMI data // provider. // public static final int ERROR_WMI_INSTANCE_NOT_FOUND = 4201; // // MessageId: ERROR_WMI_ITEMID_NOT_FOUND // // MessageText: // // The data item ID passed was not recognized as valid by a WMI data // provider. // public static final int ERROR_WMI_ITEMID_NOT_FOUND = 4202; // // MessageId: ERROR_WMI_TRY_AGAIN // // MessageText: // // The WMI request could not be completed and should be retried. // public static final int ERROR_WMI_TRY_AGAIN = 4203; // // MessageId: ERROR_WMI_DP_NOT_FOUND // // MessageText: // // The WMI data provider could not be located. // public static final int ERROR_WMI_DP_NOT_FOUND = 4204; // // MessageId: ERROR_WMI_UNRESOLVED_INSTANCE_REF // // MessageText: // // The WMI data provider references an instance set that has not been // registered. // public static final int ERROR_WMI_UNRESOLVED_INSTANCE_REF = 4205; // // MessageId: ERROR_WMI_ALREADY_ENABLED // // MessageText: // // The WMI data block or event notification has already been enabled. // public static final int ERROR_WMI_ALREADY_ENABLED = 4206; // // MessageId: ERROR_WMI_GUID_DISCONNECTED // // MessageText: // // The WMI data block is no longer available. // public static final int ERROR_WMI_GUID_DISCONNECTED = 4207; // // MessageId: ERROR_WMI_SERVER_UNAVAILABLE // // MessageText: // // The WMI data service is not available. // public static final int ERROR_WMI_SERVER_UNAVAILABLE = 4208; // // MessageId: ERROR_WMI_DP_FAILED // // MessageText: // // The WMI data provider failed to carry out the request. // public static final int ERROR_WMI_DP_FAILED = 4209; // // MessageId: ERROR_WMI_INVALID_MOF // // MessageText: // // The WMI MOF information is not valid. // public static final int ERROR_WMI_INVALID_MOF = 4210; // // MessageId: ERROR_WMI_INVALID_REGINFO // // MessageText: // // The WMI registration information is not valid. // public static final int ERROR_WMI_INVALID_REGINFO = 4211; // // MessageId: ERROR_WMI_ALREADY_DISABLED // // MessageText: // // The WMI data block or event notification has already been disabled. // public static final int ERROR_WMI_ALREADY_DISABLED = 4212; // // MessageId: ERROR_WMI_READ_ONLY // // MessageText: // // The WMI data item or data block is read only. // public static final int ERROR_WMI_READ_ONLY = 4213; // // MessageId: ERROR_WMI_SET_FAILURE // // MessageText: // // The WMI data item or data block could not be changed. // public static final int ERROR_WMI_SET_FAILURE = 4214; // ///////////////////////////////////////////////// // =// // =Available=// // =// // =4250 to=4299=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =RSM (Media Services) Error codes // // =// // =4300 to=4349=// // ///////////////////////////////////////////////// // // MessageId: ERROR_INVALID_MEDIA // // MessageText: // // The media identifier does not represent a valid medium. // public static final int ERROR_INVALID_MEDIA = 4300; // // MessageId: ERROR_INVALID_LIBRARY // // MessageText: // // The library identifier does not represent a valid library. // public static final int ERROR_INVALID_LIBRARY = 4301; // // MessageId: ERROR_INVALID_MEDIA_POOL // // MessageText: // // The media pool identifier does not represent a valid media pool. // public static final int ERROR_INVALID_MEDIA_POOL = 4302; // // MessageId: ERROR_DRIVE_MEDIA_MISMATCH // // MessageText: // // The drive and medium are not compatible or exist in different libraries. // public static final int ERROR_DRIVE_MEDIA_MISMATCH = 4303; // // MessageId: ERROR_MEDIA_OFFLINE // // MessageText: // // The medium currently exists in an offline library and must be online to // perform this operation. // public static final int ERROR_MEDIA_OFFLINE = 4304; // // MessageId: ERROR_LIBRARY_OFFLINE // // MessageText: // // The operation cannot be performed on an offline library. // public static final int ERROR_LIBRARY_OFFLINE = 4305; // // MessageId: ERROR_EMPTY // // MessageText: // // The library, drive, or media pool is empty. // public static final int ERROR_EMPTY = 4306; // // MessageId: ERROR_NOT_EMPTY // // MessageText: // // The library, drive, or media pool must be empty to perform this // operation. // public static final int ERROR_NOT_EMPTY = 4307; // // MessageId: ERROR_MEDIA_UNAVAILABLE // // MessageText: // // No media is currently available in this media pool or library. // public static final int ERROR_MEDIA_UNAVAILABLE = 4308; // // MessageId: ERROR_RESOURCE_DISABLED // // MessageText: // // A resource required for this operation is disabled. // public static final int ERROR_RESOURCE_DISABLED = 4309; // // MessageId: ERROR_INVALID_CLEANER // // MessageText: // // The media identifier does not represent a valid cleaner. // public static final int ERROR_INVALID_CLEANER = 4310; // // MessageId: ERROR_UNABLE_TO_CLEAN // // MessageText: // // The drive cannot be cleaned or does not support cleaning. // public static final int ERROR_UNABLE_TO_CLEAN = 4311; // // MessageId: ERROR_OBJECT_NOT_FOUND // // MessageText: // // The object identifier does not represent a valid object. // public static final int ERROR_OBJECT_NOT_FOUND = 4312; // // MessageId: ERROR_DATABASE_FAILURE // // MessageText: // // Unable to read from or write to the database. // public static final int ERROR_DATABASE_FAILURE = 4313; // // MessageId: ERROR_DATABASE_FULL // // MessageText: // // The database is full. // public static final int ERROR_DATABASE_FULL = 4314; // // MessageId: ERROR_MEDIA_INCOMPATIBLE // // MessageText: // // The medium is not compatible with the device or media pool. // public static final int ERROR_MEDIA_INCOMPATIBLE = 4315; // // MessageId: ERROR_RESOURCE_NOT_PRESENT // // MessageText: // // The resource required for this operation does not exist. // public static final int ERROR_RESOURCE_NOT_PRESENT = 4316; // // MessageId: ERROR_INVALID_OPERATION // // MessageText: // // The operation identifier is not valid. // public static final int ERROR_INVALID_OPERATION = 4317; // // MessageId: ERROR_MEDIA_NOT_AVAILABLE // // MessageText: // // The media is not mounted or ready for use. // public static final int ERROR_MEDIA_NOT_AVAILABLE = 4318; // // MessageId: ERROR_DEVICE_NOT_AVAILABLE // // MessageText: // // The device is not ready for use. // public static final int ERROR_DEVICE_NOT_AVAILABLE = 4319; // // MessageId: ERROR_REQUEST_REFUSED // // MessageText: // // The operator or administrator has refused the request. // public static final int ERROR_REQUEST_REFUSED = 4320; // // MessageId: ERROR_INVALID_DRIVE_OBJECT // // MessageText: // // The drive identifier does not represent a valid drive. // public static final int ERROR_INVALID_DRIVE_OBJECT = 4321; // // MessageId: ERROR_LIBRARY_FULL // // MessageText: // // Library is full. No slot is available for use. // public static final int ERROR_LIBRARY_FULL = 4322; // // MessageId: ERROR_MEDIUM_NOT_ACCESSIBLE // // MessageText: // // The transport cannot access the medium. // public static final int ERROR_MEDIUM_NOT_ACCESSIBLE = 4323; // // MessageId: ERROR_UNABLE_TO_LOAD_MEDIUM // // MessageText: // // Unable to load the medium into the drive. // public static final int ERROR_UNABLE_TO_LOAD_MEDIUM = 4324; // // MessageId: ERROR_UNABLE_TO_INVENTORY_DRIVE // // MessageText: // // Unable to retrieve the drive status. // public static final int ERROR_UNABLE_TO_INVENTORY_DRIVE = 4325; // // MessageId: ERROR_UNABLE_TO_INVENTORY_SLOT // // MessageText: // // Unable to retrieve the slot status. // public static final int ERROR_UNABLE_TO_INVENTORY_SLOT = 4326; // // MessageId: ERROR_UNABLE_TO_INVENTORY_TRANSPORT // // MessageText: // // Unable to retrieve status about the transport. // public static final int ERROR_UNABLE_TO_INVENTORY_TRANSPORT = 4327; // // MessageId: ERROR_TRANSPORT_FULL // // MessageText: // // Cannot use the transport because it is already in use. // public static final int ERROR_TRANSPORT_FULL = 4328; // // MessageId: ERROR_CONTROLLING_IEPORT // // MessageText: // // Unable to open or close the inject/eject port. // public static final int ERROR_CONTROLLING_IEPORT = 4329; // // MessageId: ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA // // MessageText: // // Unable to eject the medium because it is in a drive. // public static final int ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA = 4330; // // MessageId: ERROR_CLEANER_SLOT_SET // // MessageText: // // A cleaner slot is already reserved. // public static final int ERROR_CLEANER_SLOT_SET = 4331; // // MessageId: ERROR_CLEANER_SLOT_NOT_SET // // MessageText: // // A cleaner slot is not reserved. // public static final int ERROR_CLEANER_SLOT_NOT_SET = 4332; // // MessageId: ERROR_CLEANER_CARTRIDGE_SPENT // // MessageText: // // The cleaner cartridge has performed the maximum number of drive // cleanings. // public static final int ERROR_CLEANER_CARTRIDGE_SPENT = 4333; // // MessageId: ERROR_UNEXPECTED_OMID // // MessageText: // // Unexpected on-medium identifier. // public static final int ERROR_UNEXPECTED_OMID = 4334; // // MessageId: ERROR_CANT_DELETE_LAST_ITEM // // MessageText: // // The last remaining item in this group or resource cannot be deleted. // public static final int ERROR_CANT_DELETE_LAST_ITEM = 4335; // // MessageId: ERROR_MESSAGE_EXCEEDS_MAX_SIZE // // MessageText: // // The message provided exceeds the maximum size allowed for this parameter. // public static final int ERROR_MESSAGE_EXCEEDS_MAX_SIZE = 4336; // // MessageId: ERROR_VOLUME_CONTAINS_SYS_FILES // // MessageText: // // The volume contains system or paging files. // public static final int ERROR_VOLUME_CONTAINS_SYS_FILES = 4337; // // MessageId: ERROR_INDIGENOUS_TYPE // // MessageText: // // The media type cannot be removed from this library since at least one // drive in the library reports it can support this media type. // public static final int ERROR_INDIGENOUS_TYPE = 4338; // // MessageId: ERROR_NO_SUPPORTING_DRIVES // // MessageText: // // This offline media cannot be mounted on this system since no enabled // drives are present which can be used. // public static final int ERROR_NO_SUPPORTING_DRIVES = 4339; // // MessageId: ERROR_CLEANER_CARTRIDGE_INSTALLED // // MessageText: // // A cleaner cartridge is present in the tape library. // public static final int ERROR_CLEANER_CARTRIDGE_INSTALLED = 4340; // // MessageId: ERROR_IEPORT_FULL // // MessageText: // // Cannot use the ieport because it is not empty. // public static final int ERROR_IEPORT_FULL = 4341; // ///////////////////////////////////////////////// // =// // Remote Storage Service Error codes // // =// // =4350 to=4389=// // ///////////////////////////////////////////////// // // MessageId: ERROR_FILE_OFFLINE // // MessageText: // // This file is currently not available for use on this computer. // public static final int ERROR_FILE_OFFLINE = 4350; // // MessageId: ERROR_REMOTE_STORAGE_NOT_ACTIVE // // MessageText: // // The remote storage service is not operational at this time. // public static final int ERROR_REMOTE_STORAGE_NOT_ACTIVE = 4351; // // MessageId: ERROR_REMOTE_STORAGE_MEDIA_ERROR // // MessageText: // // The remote storage service encountered a media error. // public static final int ERROR_REMOTE_STORAGE_MEDIA_ERROR = 4352; // ///////////////////////////////////////////////// // =// // =Reparse Point Error codes=// // =// // =4390 to=4399=// // ///////////////////////////////////////////////// // // MessageId: ERROR_NOT_A_REPARSE_POINT // // MessageText: // // The file or directory is not a reparse point. // public static final int ERROR_NOT_A_REPARSE_POINT = 4390; // // MessageId: ERROR_REPARSE_ATTRIBUTE_CONFLICT // // MessageText: // // The reparse point attribute cannot be set because it conflicts with an // existing attribute. // public static final int ERROR_REPARSE_ATTRIBUTE_CONFLICT = 4391; // // MessageId: ERROR_INVALID_REPARSE_DATA // // MessageText: // // The data present in the reparse point buffer is invalid. // public static final int ERROR_INVALID_REPARSE_DATA = 4392; // // MessageId: ERROR_REPARSE_TAG_INVALID // // MessageText: // // The tag present in the reparse point buffer is invalid. // public static final int ERROR_REPARSE_TAG_INVALID = 4393; // // MessageId: ERROR_REPARSE_TAG_MISMATCH // // MessageText: // // There is a mismatch between the tag specified in the request and the tag // present in the reparse point. // // public static final int ERROR_REPARSE_TAG_MISMATCH = 4394; // ///////////////////////////////////////////////// // =// // =Available=// // =// // =4400 to=4499=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // Single Instance Store (SIS) Error codes // // =// // =4500 to=4549=// // ///////////////////////////////////////////////// // // MessageId: ERROR_VOLUME_NOT_SIS_ENABLED // // MessageText: // // Single Instance Storage is not available on this volume. // public static final int ERROR_VOLUME_NOT_SIS_ENABLED = 4500; // ///////////////////////////////////////////////// // =// // =Available=// // =// // =4550 to=4599=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =Cluster Error codes=// // =// // =5000 to=5999=// // ///////////////////////////////////////////////// // // MessageId: ERROR_DEPENDENT_RESOURCE_EXISTS // // MessageText: // // The operation cannot be completed because other resources are dependent // on this resource. // public static final int ERROR_DEPENDENT_RESOURCE_EXISTS = 5001; // // MessageId: ERROR_DEPENDENCY_NOT_FOUND // // MessageText: // // The cluster resource dependency cannot be found. // public static final int ERROR_DEPENDENCY_NOT_FOUND = 5002; // // MessageId: ERROR_DEPENDENCY_ALREADY_EXISTS // // MessageText: // // The cluster resource cannot be made dependent on the specified resource // because it is already dependent. // public static final int ERROR_DEPENDENCY_ALREADY_EXISTS = 5003; // // MessageId: ERROR_RESOURCE_NOT_ONLINE // // MessageText: // // The cluster resource is not online. // public static final int ERROR_RESOURCE_NOT_ONLINE = 5004; // // MessageId: ERROR_HOST_NODE_NOT_AVAILABLE // // MessageText: // // A cluster node is not available for this operation. // public static final int ERROR_HOST_NODE_NOT_AVAILABLE = 5005; // // MessageId: ERROR_RESOURCE_NOT_AVAILABLE // // MessageText: // // The cluster resource is not available. // public static final int ERROR_RESOURCE_NOT_AVAILABLE = 5006; // // MessageId: ERROR_RESOURCE_NOT_FOUND // // MessageText: // // The cluster resource could not be found. // public static final int ERROR_RESOURCE_NOT_FOUND = 5007; // // MessageId: ERROR_SHUTDOWN_CLUSTER // // MessageText: // // The cluster is being shut down. // public static final int ERROR_SHUTDOWN_CLUSTER = 5008; // // MessageId: ERROR_CANT_EVICT_ACTIVE_NODE // // MessageText: // // A cluster node cannot be evicted from the cluster unless the node is down // or it is the last node. // public static final int ERROR_CANT_EVICT_ACTIVE_NODE = 5009; // // MessageId: ERROR_OBJECT_ALREADY_EXISTS // // MessageText: // // The object already exists. // public static final int ERROR_OBJECT_ALREADY_EXISTS = 5010; // // MessageId: ERROR_OBJECT_IN_LIST // // MessageText: // // The object is already in the list. // public static final int ERROR_OBJECT_IN_LIST = 5011; // // MessageId: ERROR_GROUP_NOT_AVAILABLE // // MessageText: // // The cluster group is not available for any new requests. // public static final int ERROR_GROUP_NOT_AVAILABLE = 5012; // // MessageId: ERROR_GROUP_NOT_FOUND // // MessageText: // // The cluster group could not be found. // public static final int ERROR_GROUP_NOT_FOUND = 5013; // // MessageId: ERROR_GROUP_NOT_ONLINE // // MessageText: // // The operation could not be completed because the cluster group is not // online. // public static final int ERROR_GROUP_NOT_ONLINE = 5014; // // MessageId: ERROR_HOST_NODE_NOT_RESOURCE_OWNER // // MessageText: // // The operation failed because either the specified cluster node is not the // owner of the resource, or the node // is not a possible owner of the resource. // public static final int ERROR_HOST_NODE_NOT_RESOURCE_OWNER = 5015; // // MessageId: ERROR_HOST_NODE_NOT_GROUP_OWNER // // MessageText: // // The operation failed because either the specified cluster node is not the // owner of the group, or the node // is not a possible owner of the group. // public static final int ERROR_HOST_NODE_NOT_GROUP_OWNER = 5016; // // MessageId: ERROR_RESMON_CREATE_FAILED // // MessageText: // // The cluster resource could not be created in the specified resource // monitor. // public static final int ERROR_RESMON_CREATE_FAILED = 5017; // // MessageId: ERROR_RESMON_ONLINE_FAILED // // MessageText: // // The cluster resource could not be brought online by the resource monitor. // public static final int ERROR_RESMON_ONLINE_FAILED = 5018; // // MessageId: ERROR_RESOURCE_ONLINE // // MessageText: // // The operation could not be completed because the cluster resource is // online. // public static final int ERROR_RESOURCE_ONLINE = 5019; // // MessageId: ERROR_QUORUM_RESOURCE // // MessageText: // // The cluster resource could not be deleted or brought offline because it // is the quorum resource. // public static final int ERROR_QUORUM_RESOURCE = 5020; // // MessageId: ERROR_NOT_QUORUM_CAPABLE // // MessageText: // // The cluster could not make the specified resource a quorum resource // because it is not capable of being a quorum resource. // public static final int ERROR_NOT_QUORUM_CAPABLE = 5021; // // MessageId: ERROR_CLUSTER_SHUTTING_DOWN // // MessageText: // // The cluster software is shutting down. // public static final int ERROR_CLUSTER_SHUTTING_DOWN = 5022; // // MessageId: ERROR_INVALID_STATE // // MessageText: // // The group or resource is not in the correct state to perform the // requested operation. // public static final int ERROR_INVALID_STATE = 5023; // // MessageId: ERROR_RESOURCE_PROPERTIES_STORED // // MessageText: // // The properties were stored but not all changes will take effect until the // next time the resource is brought online. // public static final int ERROR_RESOURCE_PROPERTIES_STORED = 5024; // // MessageId: ERROR_NOT_QUORUM_CLASS // // MessageText: // // The cluster could not make the specified resource a quorum resource // because it does not belong to a shared storage class. // public static final int ERROR_NOT_QUORUM_CLASS = 5025; // // MessageId: ERROR_CORE_RESOURCE // // MessageText: // // The cluster resource could not be deleted since it is a core resource. // public static final int ERROR_CORE_RESOURCE = 5026; // // MessageId: ERROR_QUORUM_RESOURCE_ONLINE_FAILED // // MessageText: // // The quorum resource failed to come online. // public static final int ERROR_QUORUM_RESOURCE_ONLINE_FAILED = 5027; // // MessageId: ERROR_QUORUMLOG_OPEN_FAILED // // MessageText: // // The quorum log could not be created or mounted successfully. // public static final int ERROR_QUORUMLOG_OPEN_FAILED = 5028; // // MessageId: ERROR_CLUSTERLOG_CORRUPT // // MessageText: // // The cluster log is corrupt. // public static final int ERROR_CLUSTERLOG_CORRUPT = 5029; // // MessageId: ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE // // MessageText: // // The record could not be written to the cluster log since it exceeds the // maximum size. // public static final int ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE = 5030; // // MessageId: ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE // // MessageText: // // The cluster log exceeds its maximum size. // public static final int ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE = 5031; // // MessageId: ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND // // MessageText: // // No checkpoint record was found in the cluster log. // public static final int ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND = 5032; // // MessageId: ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE // // MessageText: // // The minimum required disk space needed for logging is not available. // public static final int ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE = 5033; // // MessageId: ERROR_QUORUM_OWNER_ALIVE // // MessageText: // // The cluster node failed to take control of the quorum resource because // the resource is owned by another active node. // public static final int ERROR_QUORUM_OWNER_ALIVE = 5034; // // MessageId: ERROR_NETWORK_NOT_AVAILABLE // // MessageText: // // A cluster network is not available for this operation. // public static final int ERROR_NETWORK_NOT_AVAILABLE = 5035; // // MessageId: ERROR_NODE_NOT_AVAILABLE // // MessageText: // // A cluster node is not available for this operation. // public static final int ERROR_NODE_NOT_AVAILABLE = 5036; // // MessageId: ERROR_ALL_NODES_NOT_AVAILABLE // // MessageText: // // All cluster nodes must be running to perform this operation. // public static final int ERROR_ALL_NODES_NOT_AVAILABLE = 5037; // // MessageId: ERROR_RESOURCE_FAILED // // MessageText: // // A cluster resource failed. // public static final int ERROR_RESOURCE_FAILED = 5038; // // MessageId: ERROR_CLUSTER_INVALID_NODE // // MessageText: // // The cluster node is not valid. // public static final int ERROR_CLUSTER_INVALID_NODE = 5039; // // MessageId: ERROR_CLUSTER_NODE_EXISTS // // MessageText: // // The cluster node already exists. // public static final int ERROR_CLUSTER_NODE_EXISTS = 5040; // // MessageId: ERROR_CLUSTER_JOIN_IN_PROGRESS // // MessageText: // // A node is in the process of joining the cluster. // public static final int ERROR_CLUSTER_JOIN_IN_PROGRESS = 5041; // // MessageId: ERROR_CLUSTER_NODE_NOT_FOUND // // MessageText: // // The cluster node was not found. // public static final int ERROR_CLUSTER_NODE_NOT_FOUND = 5042; // // MessageId: ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND // // MessageText: // // The cluster local node information was not found. // public static final int ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND = 5043; // // MessageId: ERROR_CLUSTER_NETWORK_EXISTS // // MessageText: // // The cluster network already exists. // public static final int ERROR_CLUSTER_NETWORK_EXISTS = 5044; // // MessageId: ERROR_CLUSTER_NETWORK_NOT_FOUND // // MessageText: // // The cluster network was not found. // public static final int ERROR_CLUSTER_NETWORK_NOT_FOUND = 5045; // // MessageId: ERROR_CLUSTER_NETINTERFACE_EXISTS // // MessageText: // // The cluster network interface already exists. // public static final int ERROR_CLUSTER_NETINTERFACE_EXISTS = 5046; // // MessageId: ERROR_CLUSTER_NETINTERFACE_NOT_FOUND // // MessageText: // // The cluster network interface was not found. // public static final int ERROR_CLUSTER_NETINTERFACE_NOT_FOUND = 5047; // // MessageId: ERROR_CLUSTER_INVALID_REQUEST // // MessageText: // // The cluster request is not valid for this object. // public static final int ERROR_CLUSTER_INVALID_REQUEST = 5048; // // MessageId: ERROR_CLUSTER_INVALID_NETWORK_PROVIDER // // MessageText: // // The cluster network provider is not valid. // public static final int ERROR_CLUSTER_INVALID_NETWORK_PROVIDER = 5049; // // MessageId: ERROR_CLUSTER_NODE_DOWN // // MessageText: // // The cluster node is down. // public static final int ERROR_CLUSTER_NODE_DOWN = 5050; // // MessageId: ERROR_CLUSTER_NODE_UNREACHABLE // // MessageText: // // The cluster node is not reachable. // public static final int ERROR_CLUSTER_NODE_UNREACHABLE = 5051; // // MessageId: ERROR_CLUSTER_NODE_NOT_MEMBER // // MessageText: // // The cluster node is not a member of the cluster. // public static final int ERROR_CLUSTER_NODE_NOT_MEMBER = 5052; // // MessageId: ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS // // MessageText: // // A cluster join operation is not in progress. // public static final int ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS = 5053; // // MessageId: ERROR_CLUSTER_INVALID_NETWORK // // MessageText: // // The cluster network is not valid. // public static final int ERROR_CLUSTER_INVALID_NETWORK = 5054; // // MessageId: ERROR_CLUSTER_NODE_UP // // MessageText: // // The cluster node is up. // public static final int ERROR_CLUSTER_NODE_UP = 5056; // // MessageId: ERROR_CLUSTER_IPADDR_IN_USE // // MessageText: // // The cluster IP address is already in use. // public static final int ERROR_CLUSTER_IPADDR_IN_USE = 5057; // // MessageId: ERROR_CLUSTER_NODE_NOT_PAUSED // // MessageText: // // The cluster node is not paused. // public static final int ERROR_CLUSTER_NODE_NOT_PAUSED = 5058; // // MessageId: ERROR_CLUSTER_NO_SECURITY_CONTEXT // // MessageText: // // No cluster security context is available. // public static final int ERROR_CLUSTER_NO_SECURITY_CONTEXT = 5059; // // MessageId: ERROR_CLUSTER_NETWORK_NOT_INTERNAL // // MessageText: // // The cluster network is not configured for internal cluster communication. // public static final int ERROR_CLUSTER_NETWORK_NOT_INTERNAL = 5060; // // MessageId: ERROR_CLUSTER_NODE_ALREADY_UP // // MessageText: // // The cluster node is already up. // public static final int ERROR_CLUSTER_NODE_ALREADY_UP = 5061; // // MessageId: ERROR_CLUSTER_NODE_ALREADY_DOWN // // MessageText: // // The cluster node is already down. // public static final int ERROR_CLUSTER_NODE_ALREADY_DOWN = 5062; // // MessageId: ERROR_CLUSTER_NETWORK_ALREADY_ONLINE // // MessageText: // // The cluster network is already online. // public static final int ERROR_CLUSTER_NETWORK_ALREADY_ONLINE = 5063; // // MessageId: ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE // // MessageText: // // The cluster network is already offline. // public static final int ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE = 5064; // // MessageId: ERROR_CLUSTER_NODE_ALREADY_MEMBER // // MessageText: // // The cluster node is already a member of the cluster. // public static final int ERROR_CLUSTER_NODE_ALREADY_MEMBER = 5065; // // MessageId: ERROR_CLUSTER_LAST_INTERNAL_NETWORK // // MessageText: // // The cluster network is the only one configured for internal cluster // communication between two or more active cluster nodes. The internal // communication capability cannot be removed from the network. // public static final int ERROR_CLUSTER_LAST_INTERNAL_NETWORK = 5066; // // MessageId: ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS // // MessageText: // // One or more cluster resources depend on the network to provide service to // clients. The client access capability cannot be removed from the network. // public static final int ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS = 5067; // // MessageId: ERROR_INVALID_OPERATION_ON_QUORUM // // MessageText: // // This operation cannot be performed on the cluster resource as it the // quorum resource. You may not bring the quorum resource offline or modify // its possible owners list. // public static final int ERROR_INVALID_OPERATION_ON_QUORUM = 5068; // // MessageId: ERROR_DEPENDENCY_NOT_ALLOWED // // MessageText: // // The cluster quorum resource is not allowed to have any dependencies. // public static final int ERROR_DEPENDENCY_NOT_ALLOWED = 5069; // // MessageId: ERROR_CLUSTER_NODE_PAUSED // // MessageText: // // The cluster node is paused. // public static final int ERROR_CLUSTER_NODE_PAUSED = 5070; // // MessageId: ERROR_NODE_CANT_HOST_RESOURCE // // MessageText: // // The cluster resource cannot be brought online. The owner node cannot run // this resource. // public static final int ERROR_NODE_CANT_HOST_RESOURCE = 5071; // // MessageId: ERROR_CLUSTER_NODE_NOT_READY // // MessageText: // // The cluster node is not ready to perform the requested operation. // public static final int ERROR_CLUSTER_NODE_NOT_READY = 5072; // // MessageId: ERROR_CLUSTER_NODE_SHUTTING_DOWN // // MessageText: // // The cluster node is shutting down. // public static final int ERROR_CLUSTER_NODE_SHUTTING_DOWN = 5073; // // MessageId: ERROR_CLUSTER_JOIN_ABORTED // // MessageText: // // The cluster join operation was aborted. // public static final int ERROR_CLUSTER_JOIN_ABORTED = 5074; // // MessageId: ERROR_CLUSTER_INCOMPATIBLE_VERSIONS // // MessageText: // // The cluster join operation failed due to incompatible software versions // between the joining node and its sponsor. // public static final int ERROR_CLUSTER_INCOMPATIBLE_VERSIONS = 5075; // // MessageId: ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED // // MessageText: // // This resource cannot be created because the cluster has reached the limit // on the number of resources it can monitor. // public static final int ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED = 5076; // // MessageId: ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED // // MessageText: // // The system configuration changed during the cluster join or form // operation. The join or form operation was aborted. // public static final int ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED = 5077; // // MessageId: ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND // // MessageText: // // The specified resource type was not found. // public static final int ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND = 5078; // // MessageId: ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED // // MessageText: // // The specified node does not support a resource of this type. This may be // due to version inconsistencies or due to the absence of the resource DLL // on this node. // public static final int ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED = 5079; // // MessageId: ERROR_CLUSTER_RESNAME_NOT_FOUND // // MessageText: // // The specified resource name is not supported by this resource DLL. This // may be due to a bad (or changed) name supplied to the resource DLL. // public static final int ERROR_CLUSTER_RESNAME_NOT_FOUND = 5080; // // MessageId: ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED // // MessageText: // // No authentication package could be registered with the RPC server. // public static final int ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED = 5081; // // MessageId: ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST // // MessageText: // // You cannot bring the group online because the owner of the group is not // in the preferred list for the group. To change the owner node for the // group, move the group. // public static final int ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST = 5082; // // MessageId: ERROR_CLUSTER_DATABASE_SEQMISMATCH // // MessageText: // // The join operation failed because the cluster database sequence number // has changed or is incompatible with the locker node. This may happen // during a join operation if the cluster database was changing during the // join. // public static final int ERROR_CLUSTER_DATABASE_SEQMISMATCH = 5083; // // MessageId: ERROR_RESMON_INVALID_STATE // // MessageText: // // The resource monitor will not allow the fail operation to be performed // while the resource is in its current state. This may happen if the // resource is in a pending state. // public static final int ERROR_RESMON_INVALID_STATE = 5084; // // MessageId: ERROR_CLUSTER_GUM_NOT_LOCKER // // MessageText: // // A non locker code got a request to reserve the lock for making global // updates. // public static final int ERROR_CLUSTER_GUM_NOT_LOCKER = 5085; // // MessageId: ERROR_QUORUM_DISK_NOT_FOUND // // MessageText: // // The quorum disk could not be located by the cluster service. // public static final int ERROR_QUORUM_DISK_NOT_FOUND = 5086; // // MessageId: ERROR_DATABASE_BACKUP_CORRUPT // // MessageText: // // The backed up cluster database is possibly corrupt. // public static final int ERROR_DATABASE_BACKUP_CORRUPT = 5087; // // MessageId: ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT // // MessageText: // // A DFS root already exists in this cluster node. // public static final int ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT = 5088; // // MessageId: ERROR_RESOURCE_PROPERTY_UNCHANGEABLE // // MessageText: // // An attempt to modify a resource property failed because it conflicts with // another existing property. // public static final int ERROR_RESOURCE_PROPERTY_UNCHANGEABLE = 5089; /* * Codes from=4300 through=5889 overlap with codes in * ds\published\inc\apperr2.w. Do not add any more error codes in that * range. */ // // MessageId: ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE // // MessageText: // // An operation was attempted that is incompatible with the current // membership state of the node. // public static final int ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE = 5890; // // MessageId: ERROR_CLUSTER_QUORUMLOG_NOT_FOUND // // MessageText: // // The quorum resource does not contain the quorum log. // public static final int ERROR_CLUSTER_QUORUMLOG_NOT_FOUND = 5891; // // MessageId: ERROR_CLUSTER_MEMBERSHIP_HALT // // MessageText: // // The membership engine requested shutdown of the cluster service on this // node. // public static final int ERROR_CLUSTER_MEMBERSHIP_HALT = 5892; // // MessageId: ERROR_CLUSTER_INSTANCE_ID_MISMATCH // // MessageText: // // The join operation failed because the cluster instance ID of the joining // node does not match the cluster instance ID of the sponsor node. // public static final int ERROR_CLUSTER_INSTANCE_ID_MISMATCH = 5893; // // MessageId: ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP // // MessageText: // // A matching cluster network for the specified IP address could not be // found. // public static final int ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP = 5894; // // MessageId: ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH // // MessageText: // // The actual data type of the property did not match the expected data type // of the property. // public static final int ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH = 5895; // // MessageId: ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP // // MessageText: // // The cluster node was evicted from the cluster successfully, but the node // was not cleaned up. To determine what cleanup steps failed and how to // recover, see the Failover Clustering application event log using Event // Viewer. // public static final int ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP = 5896; // // MessageId: ERROR_CLUSTER_PARAMETER_MISMATCH // // MessageText: // // Two or more parameter values specified for a resource's properties are in // conflict. // public static final int ERROR_CLUSTER_PARAMETER_MISMATCH = 5897; // // MessageId: ERROR_NODE_CANNOT_BE_CLUSTERED // // MessageText: // // This computer cannot be made a member of a cluster. // public static final int ERROR_NODE_CANNOT_BE_CLUSTERED = 5898; // // MessageId: ERROR_CLUSTER_WRONG_OS_VERSION // // MessageText: // // This computer cannot be made a member of a cluster because it does not // have the correct version of Windows installed. // public static final int ERROR_CLUSTER_WRONG_OS_VERSION = 5899; // // MessageId: ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME // // MessageText: // // A cluster cannot be created with the specified cluster name because that // cluster name is already in use. Specify a different name for the cluster. // public static final int ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME = 5900; // // MessageId: ERROR_CLUSCFG_ALREADY_COMMITTED // // MessageText: // // The cluster configuration action has already been committed. // public static final int ERROR_CLUSCFG_ALREADY_COMMITTED = 5901; // // MessageId: ERROR_CLUSCFG_ROLLBACK_FAILED // // MessageText: // // The cluster configuration action could not be rolled back. // public static final int ERROR_CLUSCFG_ROLLBACK_FAILED = 5902; // // MessageId: ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT // // MessageText: // // The drive letter assigned to a system disk on one node conflicted with // the drive letter assigned to a disk on another node. // public static final int ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT = 5903; // // MessageId: ERROR_CLUSTER_OLD_VERSION // // MessageText: // // One or more nodes in the cluster are running a version of Windows that // does not support this operation. // public static final int ERROR_CLUSTER_OLD_VERSION = 5904; // // MessageId: ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME // // MessageText: // // The name of the corresponding computer account doesn't match the Network // Name for this resource. // public static final int ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME = 5905; // // MessageId: ERROR_CLUSTER_NO_NET_ADAPTERS // // MessageText: // // No network adapters are available. // public static final int ERROR_CLUSTER_NO_NET_ADAPTERS = 5906; // // MessageId: ERROR_CLUSTER_POISONED // // MessageText: // // The cluster node has been poisoned. // public static final int ERROR_CLUSTER_POISONED = 5907; // // MessageId: ERROR_CLUSTER_GROUP_MOVING // // MessageText: // // The group is unable to accept the request since it is moving to another // node. // public static final int ERROR_CLUSTER_GROUP_MOVING = 5908; // // MessageId: ERROR_CLUSTER_RESOURCE_TYPE_BUSY // // MessageText: // // The resource type cannot accept the request since is too busy performing // another operation. // public static final int ERROR_CLUSTER_RESOURCE_TYPE_BUSY = 5909; // // MessageId: ERROR_RESOURCE_CALL_TIMED_OUT // // MessageText: // // The call to the cluster resource DLL timed out. // public static final int ERROR_RESOURCE_CALL_TIMED_OUT = 5910; // // MessageId: ERROR_INVALID_CLUSTER_IPV6_ADDRESS // // MessageText: // // The address is not valid for an IPv6 Address resource. A global IPv6 // address is required, and it must match a cluster network. Compatibility // addresses are not permitted. // public static final int ERROR_INVALID_CLUSTER_IPV6_ADDRESS = 5911; // // MessageId: ERROR_CLUSTER_INTERNAL_INVALID_FUNCTION // // MessageText: // // An internal cluster error occurred. A call to an invalid function was // attempted. // public static final int ERROR_CLUSTER_INTERNAL_INVALID_FUNCTION = 5912; // // MessageId: ERROR_CLUSTER_PARAMETER_OUT_OF_BOUNDS // // MessageText: // // A parameter value is out of acceptable range. // public static final int ERROR_CLUSTER_PARAMETER_OUT_OF_BOUNDS = 5913; // // MessageId: ERROR_CLUSTER_PARTIAL_SEND // // MessageText: // // A network error occurred while sending data to another node in the // cluster. The number of bytes transmitted was less than required. // public static final int ERROR_CLUSTER_PARTIAL_SEND = 5914; // // MessageId: ERROR_CLUSTER_REGISTRY_INVALID_FUNCTION // // MessageText: // // An invalid cluster registry operation was attempted. // public static final int ERROR_CLUSTER_REGISTRY_INVALID_FUNCTION = 5915; // // MessageId: ERROR_CLUSTER_INVALID_STRING_TERMINATION // // MessageText: // // An input string of characters is not properly terminated. // public static final int ERROR_CLUSTER_INVALID_STRING_TERMINATION = 5916; // // MessageId: ERROR_CLUSTER_INVALID_STRING_FORMAT // // MessageText: // // An input string of characters is not in a valid format for the data it // represents. // public static final int ERROR_CLUSTER_INVALID_STRING_FORMAT = 5917; // // MessageId: ERROR_CLUSTER_DATABASE_TRANSACTION_IN_PROGRESS // // MessageText: // // An internal cluster error occurred. A cluster database transaction was // attempted while a transaction was already in progress. // public static final int ERROR_CLUSTER_DATABASE_TRANSACTION_IN_PROGRESS = 5918; // // MessageId: ERROR_CLUSTER_DATABASE_TRANSACTION_NOT_IN_PROGRESS // // MessageText: // // An internal cluster error occurred. There was an attempt to commit a // cluster database transaction while no transaction was in progress. // public static final int ERROR_CLUSTER_DATABASE_TRANSACTION_NOT_IN_PROGRESS = 5919; // // MessageId: ERROR_CLUSTER_NULL_DATA // // MessageText: // // An internal cluster error occurred. Data was not properly initialized. // public static final int ERROR_CLUSTER_NULL_DATA = 5920; // // MessageId: ERROR_CLUSTER_PARTIAL_READ // // MessageText: // // An error occurred while reading from a stream of data. An unexpected // number of bytes was returned. // public static final int ERROR_CLUSTER_PARTIAL_READ = 5921; // // MessageId: ERROR_CLUSTER_PARTIAL_WRITE // // MessageText: // // An error occurred while writing to a stream of data. The required number // of bytes could not be written. // public static final int ERROR_CLUSTER_PARTIAL_WRITE = 5922; // // MessageId: ERROR_CLUSTER_CANT_DESERIALIZE_DATA // // MessageText: // // An error occurred while deserializing a stream of cluster data. // public static final int ERROR_CLUSTER_CANT_DESERIALIZE_DATA = 5923; // // MessageId: ERROR_DEPENDENT_RESOURCE_PROPERTY_CONFLICT // // MessageText: // // One or more property values for this resource are in conflict with one or // more property values associated with its dependent resource(s). // public static final int ERROR_DEPENDENT_RESOURCE_PROPERTY_CONFLICT = 5924; // // MessageId: ERROR_CLUSTER_NO_QUORUM // // MessageText: // // A quorum of cluster nodes was not present to form a cluster. // public static final int ERROR_CLUSTER_NO_QUORUM = 5925; // // MessageId: ERROR_CLUSTER_INVALID_IPV6_NETWORK // // MessageText: // // The cluster network is not valid for an IPv6 Address resource, or it does // not match the configured address. // public static final int ERROR_CLUSTER_INVALID_IPV6_NETWORK = 5926; // // MessageId: ERROR_CLUSTER_INVALID_IPV6_TUNNEL_NETWORK // // MessageText: // // The cluster network is not valid for an IPv6 Tunnel resource. Check the // configuration of the IP Address resource on which the IPv6 Tunnel // resource depends. // public static final int ERROR_CLUSTER_INVALID_IPV6_TUNNEL_NETWORK = 5927; // // MessageId: ERROR_QUORUM_NOT_ALLOWED_IN_THIS_GROUP // // MessageText: // // Quorum resource cannot reside in the Available Storage group. // public static final int ERROR_QUORUM_NOT_ALLOWED_IN_THIS_GROUP = 5928; // // MessageId: ERROR_DEPENDENCY_TREE_TOO_COMPLEX // // MessageText: // // The dependencies for this resource are nested too deeply. // public static final int ERROR_DEPENDENCY_TREE_TOO_COMPLEX = 5929; // // MessageId: ERROR_EXCEPTION_IN_RESOURCE_CALL // // MessageText: // // The call into the resource DLL raised an unhandled exception. // public static final int ERROR_EXCEPTION_IN_RESOURCE_CALL = 5930; // // MessageId: ERROR_CLUSTER_RHS_FAILED_INITIALIZATION // // MessageText: // // The RHS process failed to initialize. // public static final int ERROR_CLUSTER_RHS_FAILED_INITIALIZATION = 5931; // // MessageId: ERROR_CLUSTER_NOT_INSTALLED // // MessageText: // // The Failover Clustering feature is not installed on this node. // public static final int ERROR_CLUSTER_NOT_INSTALLED = 5932; // // MessageId: ERROR_CLUSTER_RESOURCES_MUST_BE_ONLINE_ON_THE_SAME_NODE // // MessageText: // // The resources must be online on the same node for this operation // public static final int ERROR_CLUSTER_RESOURCES_MUST_BE_ONLINE_ON_THE_SAME_NODE = 5933; // ///////////////////////////////////////////////// // =// // =EFS Error codes=// // =// // =6000 to=6099=// // ///////////////////////////////////////////////// // // MessageId: ERROR_ENCRYPTION_FAILED // // MessageText: // // The specified file could not be encrypted. // public static final int ERROR_ENCRYPTION_FAILED = 6000; // // MessageId: ERROR_DECRYPTION_FAILED // // MessageText: // // The specified file could not be decrypted. // public static final int ERROR_DECRYPTION_FAILED = 6001; // // MessageId: ERROR_FILE_ENCRYPTED // // MessageText: // // The specified file is encrypted and the user does not have the ability to // decrypt it. // public static final int ERROR_FILE_ENCRYPTED = 6002; // // MessageId: ERROR_NO_RECOVERY_POLICY // // MessageText: // // There is no valid encryption recovery policy configured for this system. // public static final int ERROR_NO_RECOVERY_POLICY = 6003; // // MessageId: ERROR_NO_EFS // // MessageText: // // The required encryption driver is not loaded for this system. // public static final int ERROR_NO_EFS = 6004; // // MessageId: ERROR_WRONG_EFS // // MessageText: // // The file was encrypted with a different encryption driver than is // currently loaded. // public static final int ERROR_WRONG_EFS = 6005; // // MessageId: ERROR_NO_USER_KEYS // // MessageText: // // There are no EFS keys defined for the user. // public static final int ERROR_NO_USER_KEYS = 6006; // // MessageId: ERROR_FILE_NOT_ENCRYPTED // // MessageText: // // The specified file is not encrypted. // public static final int ERROR_FILE_NOT_ENCRYPTED = 6007; // // MessageId: ERROR_NOT_EXPORT_FORMAT // // MessageText: // // The specified file is not in the defined EFS export format. // public static final int ERROR_NOT_EXPORT_FORMAT = 6008; // // MessageId: ERROR_FILE_READ_ONLY // // MessageText: // // The specified file is read only. // public static final int ERROR_FILE_READ_ONLY = 6009; // // MessageId: ERROR_DIR_EFS_DISALLOWED // // MessageText: // // The directory has been disabled for encryption. // public static final int ERROR_DIR_EFS_DISALLOWED = 6010; // // MessageId: ERROR_EFS_SERVER_NOT_TRUSTED // // MessageText: // // The server is not trusted for remote encryption operation. // public static final int ERROR_EFS_SERVER_NOT_TRUSTED = 6011; // // MessageId: ERROR_BAD_RECOVERY_POLICY // // MessageText: // // Recovery policy configured for this system contains invalid recovery // certificate. // public static final int ERROR_BAD_RECOVERY_POLICY = 6012; // // MessageId: ERROR_EFS_ALG_BLOB_TOO_BIG // // MessageText: // // The encryption algorithm used on the source file needs a bigger key // buffer than the one on the destination file. // public static final int ERROR_EFS_ALG_BLOB_TOO_BIG = 6013; // // MessageId: ERROR_VOLUME_NOT_SUPPORT_EFS // // MessageText: // // The disk partition does not support file encryption. // public static final int ERROR_VOLUME_NOT_SUPPORT_EFS = 6014; // // MessageId: ERROR_EFS_DISABLED // // MessageText: // // This machine is disabled for file encryption. // public static final int ERROR_EFS_DISABLED = 6015; // // MessageId: ERROR_EFS_VERSION_NOT_SUPPORT // // MessageText: // // A newer system is required to decrypt this encrypted file. // public static final int ERROR_EFS_VERSION_NOT_SUPPORT = 6016; // // MessageId: ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE // // MessageText: // // The remote server sent an invalid response for a file being opened with // Client Side Encryption. // public static final int ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE = 6017; // // MessageId: ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER // // MessageText: // // Client Side Encryption is not supported by the remote server even though // it claims to support it. // public static final int ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER = 6018; // // MessageId: ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE // // MessageText: // // File is encrypted and should be opened in Client Side Encryption mode. // public static final int ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE = 6019; // // MessageId: ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE // // MessageText: // // A new encrypted file is being created and a $EFS needs to be provided. // public static final int ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE = 6020; // // MessageId: ERROR_CS_ENCRYPTION_FILE_NOT_CSE // // MessageText: // // The SMB client requested a CSE FSCTL on a non-CSE file. // public static final int ERROR_CS_ENCRYPTION_FILE_NOT_CSE = 6021; // ///////////////////////////////////////////////// // =// // =BROWSER Error codes=// // =// // =6100 to=6199=// // ///////////////////////////////////////////////// // This message number is for historical purposes and cannot be changed or // re-used. // // MessageId: ERROR_NO_BROWSER_SERVERS_FOUND // // MessageText: // // The list of servers for this workgroup is not currently available // public static final int ERROR_NO_BROWSER_SERVERS_FOUND = 6118; // ///////////////////////////////////////////////// // =// // =Task Scheduler Error codes=// // =NET START must understand=// // =// // =6200 to=6249=// // ///////////////////////////////////////////////// // // MessageId: SCHED_E_SERVICE_NOT_LOCALSYSTEM // // MessageText: // // The Task Scheduler service must be configured to run in the System // account to function properly. Individual tasks may be configured to run // in other accounts. // public static final int SCHED_E_SERVICE_NOT_LOCALSYSTEM = 6200; // ///////////////////////////////////////////////// // =// // =Available=// // =// // =6250 to=6599=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =Common Log (CLFS) Error codes=// // =// // =6600 to=6699=// // ///////////////////////////////////////////////// // // MessageId: ERROR_LOG_SECTOR_INVALID // // MessageText: // // Log service encountered an invalid log sector. // public static final int ERROR_LOG_SECTOR_INVALID = 6600; // // MessageId: ERROR_LOG_SECTOR_PARITY_INVALID // // MessageText: // // Log service encountered a log sector with invalid block parity. // public static final int ERROR_LOG_SECTOR_PARITY_INVALID = 6601; // // MessageId: ERROR_LOG_SECTOR_REMAPPED // // MessageText: // // Log service encountered a remapped log sector. // public static final int ERROR_LOG_SECTOR_REMAPPED = 6602; // // MessageId: ERROR_LOG_BLOCK_INCOMPLETE // // MessageText: // // Log service encountered a partial or incomplete log block. // public static final int ERROR_LOG_BLOCK_INCOMPLETE = 6603; // // MessageId: ERROR_LOG_INVALID_RANGE // // MessageText: // // Log service encountered an attempt access data outside the active log // range. // public static final int ERROR_LOG_INVALID_RANGE = 6604; // // MessageId: ERROR_LOG_BLOCKS_EXHAUSTED // // MessageText: // // Log service user marshalling buffers are exhausted. // public static final int ERROR_LOG_BLOCKS_EXHAUSTED = 6605; // // MessageId: ERROR_LOG_READ_CONTEXT_INVALID // // MessageText: // // Log service encountered an attempt read from a marshalling area with an // invalid read context. // public static final int ERROR_LOG_READ_CONTEXT_INVALID = 6606; // // MessageId: ERROR_LOG_RESTART_INVALID // // MessageText: // // Log service encountered an invalid log restart area. // public static final int ERROR_LOG_RESTART_INVALID = 6607; // // MessageId: ERROR_LOG_BLOCK_VERSION // // MessageText: // // Log service encountered an invalid log block version. // public static final int ERROR_LOG_BLOCK_VERSION = 6608; // // MessageId: ERROR_LOG_BLOCK_INVALID // // MessageText: // // Log service encountered an invalid log block. // public static final int ERROR_LOG_BLOCK_INVALID = 6609; // // MessageId: ERROR_LOG_READ_MODE_INVALID // // MessageText: // // Log service encountered an attempt to read the log with an invalid read // mode. // public static final int ERROR_LOG_READ_MODE_INVALID = 6610; // // MessageId: ERROR_LOG_NO_RESTART // // MessageText: // // Log service encountered a log stream with no restart area. // public static final int ERROR_LOG_NO_RESTART = 6611; // // MessageId: ERROR_LOG_METADATA_CORRUPT // // MessageText: // // Log service encountered a corrupted metadata file. // public static final int ERROR_LOG_METADATA_CORRUPT = 6612; // // MessageId: ERROR_LOG_METADATA_INVALID // // MessageText: // // Log service encountered a metadata file that could not be created by the // log file system. // public static final int ERROR_LOG_METADATA_INVALID = 6613; // // MessageId: ERROR_LOG_METADATA_INCONSISTENT // // MessageText: // // Log service encountered a metadata file with inconsistent data. // public static final int ERROR_LOG_METADATA_INCONSISTENT = 6614; // // MessageId: ERROR_LOG_RESERVATION_INVALID // // MessageText: // // Log service encountered an attempt to erroneous allocate or dispose // reservation space. // public static final int ERROR_LOG_RESERVATION_INVALID = 6615; // // MessageId: ERROR_LOG_CANT_DELETE // // MessageText: // // Log service cannot delete log file or file system container. // public static final int ERROR_LOG_CANT_DELETE = 6616; // // MessageId: ERROR_LOG_CONTAINER_LIMIT_EXCEEDED // // MessageText: // // Log service has reached the maximum allowable containers allocated to a // log file. // public static final int ERROR_LOG_CONTAINER_LIMIT_EXCEEDED = 6617; // // MessageId: ERROR_LOG_START_OF_LOG // // MessageText: // // Log service has attempted to read or write backward past the start of the // log. // public static final int ERROR_LOG_START_OF_LOG = 6618; // // MessageId: ERROR_LOG_POLICY_ALREADY_INSTALLED // // MessageText: // // Log policy could not be installed because a policy of the same type is // already present. // public static final int ERROR_LOG_POLICY_ALREADY_INSTALLED = 6619; // // MessageId: ERROR_LOG_POLICY_NOT_INSTALLED // // MessageText: // // Log policy in question was not installed at the time of the request. // public static final int ERROR_LOG_POLICY_NOT_INSTALLED = 6620; // // MessageId: ERROR_LOG_POLICY_INVALID // // MessageText: // // The installed set of policies on the log is invalid. // public static final int ERROR_LOG_POLICY_INVALID = 6621; // // MessageId: ERROR_LOG_POLICY_CONFLICT // // MessageText: // // A policy on the log in question prevented the operation from completing. // public static final int ERROR_LOG_POLICY_CONFLICT = 6622; // // MessageId: ERROR_LOG_PINNED_ARCHIVE_TAIL // // MessageText: // // Log space cannot be reclaimed because the log is pinned by the archive // tail. // public static final int ERROR_LOG_PINNED_ARCHIVE_TAIL = 6623; // // MessageId: ERROR_LOG_RECORD_NONEXISTENT // // MessageText: // // Log record is not a record in the log file. // public static final int ERROR_LOG_RECORD_NONEXISTENT = 6624; // // MessageId: ERROR_LOG_RECORDS_RESERVED_INVALID // // MessageText: // // Number of reserved log records or the adjustment of the number of // reserved log records is invalid. // public static final int ERROR_LOG_RECORDS_RESERVED_INVALID = 6625; // // MessageId: ERROR_LOG_SPACE_RESERVED_INVALID // // MessageText: // // Reserved log space or the adjustment of the log space is invalid. // public static final int ERROR_LOG_SPACE_RESERVED_INVALID = 6626; // // MessageId: ERROR_LOG_TAIL_INVALID // // MessageText: // // An new or existing archive tail or base of the active log is invalid. // public static final int ERROR_LOG_TAIL_INVALID = 6627; // // MessageId: ERROR_LOG_FULL // // MessageText: // // Log space is exhausted. // public static final int ERROR_LOG_FULL = 6628; // // MessageId: ERROR_COULD_NOT_RESIZE_LOG // // MessageText: // // The log could not be set to the requested size. // public static final int ERROR_COULD_NOT_RESIZE_LOG = 6629; // // MessageId: ERROR_LOG_MULTIPLEXED // // MessageText: // // Log is multiplexed, no direct writes to the physical log is allowed. // public static final int ERROR_LOG_MULTIPLEXED = 6630; // // MessageId: ERROR_LOG_DEDICATED // // MessageText: // // The operation failed because the log is a dedicated log. // public static final int ERROR_LOG_DEDICATED = 6631; // // MessageId: ERROR_LOG_ARCHIVE_NOT_IN_PROGRESS // // MessageText: // // The operation requires an archive context. // public static final int ERROR_LOG_ARCHIVE_NOT_IN_PROGRESS = 6632; // // MessageId: ERROR_LOG_ARCHIVE_IN_PROGRESS // // MessageText: // // Log archival is in progress. // public static final int ERROR_LOG_ARCHIVE_IN_PROGRESS = 6633; // // MessageId: ERROR_LOG_EPHEMERAL // // MessageText: // // The operation requires a non-ephemeral log, but the log is ephemeral. // public static final int ERROR_LOG_EPHEMERAL = 6634; // // MessageId: ERROR_LOG_NOT_ENOUGH_CONTAINERS // // MessageText: // // The log must have at least two containers before it can be read from or // written to. // public static final int ERROR_LOG_NOT_ENOUGH_CONTAINERS = 6635; // // MessageId: ERROR_LOG_CLIENT_ALREADY_REGISTERED // // MessageText: // // A log client has already registered on the stream. // public static final int ERROR_LOG_CLIENT_ALREADY_REGISTERED = 6636; // // MessageId: ERROR_LOG_CLIENT_NOT_REGISTERED // // MessageText: // // A log client has not been registered on the stream. // public static final int ERROR_LOG_CLIENT_NOT_REGISTERED = 6637; // // MessageId: ERROR_LOG_FULL_HANDLER_IN_PROGRESS // // MessageText: // // A request has already been made to handle the log full condition. // public static final int ERROR_LOG_FULL_HANDLER_IN_PROGRESS = 6638; // // MessageId: ERROR_LOG_CONTAINER_READ_FAILED // // MessageText: // // Log service enountered an error when attempting to read from a log // container. // public static final int ERROR_LOG_CONTAINER_READ_FAILED = 6639; // // MessageId: ERROR_LOG_CONTAINER_WRITE_FAILED // // MessageText: // // Log service enountered an error when attempting to write to a log // container. // public static final int ERROR_LOG_CONTAINER_WRITE_FAILED = 6640; // // MessageId: ERROR_LOG_CONTAINER_OPEN_FAILED // // MessageText: // // Log service enountered an error when attempting open a log container. // public static final int ERROR_LOG_CONTAINER_OPEN_FAILED = 6641; // // MessageId: ERROR_LOG_CONTAINER_STATE_INVALID // // MessageText: // // Log service enountered an invalid container state when attempting a // requested action. // public static final int ERROR_LOG_CONTAINER_STATE_INVALID = 6642; // // MessageId: ERROR_LOG_STATE_INVALID // // MessageText: // // Log service is not in the correct state to perform a requested action. // public static final int ERROR_LOG_STATE_INVALID = 6643; // // MessageId: ERROR_LOG_PINNED // // MessageText: // // Log space cannot be reclaimed because the log is pinned. // public static final int ERROR_LOG_PINNED = 6644; // // MessageId: ERROR_LOG_METADATA_FLUSH_FAILED // // MessageText: // // Log metadata flush failed. // public static final int ERROR_LOG_METADATA_FLUSH_FAILED = 6645; // // MessageId: ERROR_LOG_INCONSISTENT_SECURITY // // MessageText: // // Security on the log and its containers is inconsistent. // public static final int ERROR_LOG_INCONSISTENT_SECURITY = 6646; // // MessageId: ERROR_LOG_APPENDED_FLUSH_FAILED // // MessageText: // // Records were appended to the log or reservation changes were made, but // the log could not be flushed. // public static final int ERROR_LOG_APPENDED_FLUSH_FAILED = 6647; // // MessageId: ERROR_LOG_PINNED_RESERVATION // // MessageText: // // The log is pinned due to reservation consuming most of the log space. // Free some reserved records to make space available. // public static final int ERROR_LOG_PINNED_RESERVATION = 6648; // ///////////////////////////////////////////////// // =// // =Transaction (KTM) Error codes // // =// // =6700 to=6799=// // ///////////////////////////////////////////////// // // MessageId: ERROR_INVALID_TRANSACTION // // MessageText: // // The transaction handle associated with this operation is not valid. // public static final int ERROR_INVALID_TRANSACTION = 6700; // // MessageId: ERROR_TRANSACTION_NOT_ACTIVE // // MessageText: // // The requested operation was made in the context of a transaction that is // no longer active. // public static final int ERROR_TRANSACTION_NOT_ACTIVE = 6701; // // MessageId: ERROR_TRANSACTION_REQUEST_NOT_VALID // // MessageText: // // The requested operation is not valid on the Transaction object in its // current state. // public static final int ERROR_TRANSACTION_REQUEST_NOT_VALID = 6702; // // MessageId: ERROR_TRANSACTION_NOT_REQUESTED // // MessageText: // // The caller has called a response API, but the response is not expected // because the TM did not issue the corresponding request to the caller. // public static final int ERROR_TRANSACTION_NOT_REQUESTED = 6703; // // MessageId: ERROR_TRANSACTION_ALREADY_ABORTED // // MessageText: // // It is too late to perform the requested operation, since the Transaction // has already been aborted. // public static final int ERROR_TRANSACTION_ALREADY_ABORTED = 6704; // // MessageId: ERROR_TRANSACTION_ALREADY_COMMITTED // // MessageText: // // It is too late to perform the requested operation, since the Transaction // has already been committed. // public static final int ERROR_TRANSACTION_ALREADY_COMMITTED = 6705; // // MessageId: ERROR_TM_INITIALIZATION_FAILED // // MessageText: // // The Transaction Manager was unable to be successfully initialized. // Transacted operations are not supported. // public static final int ERROR_TM_INITIALIZATION_FAILED = 6706; // // MessageId: ERROR_RESOURCEMANAGER_READ_ONLY // // MessageText: // // The specified ResourceManager made no changes or updates to the resource // under this transaction. // public static final int ERROR_RESOURCEMANAGER_READ_ONLY = 6707; // // MessageId: ERROR_TRANSACTION_NOT_JOINED // // MessageText: // // The resource manager has attempted to prepare a transaction that it has // not successfully joined. // public static final int ERROR_TRANSACTION_NOT_JOINED = 6708; // // MessageId: ERROR_TRANSACTION_SUPERIOR_EXISTS // // MessageText: // // The Transaction object already has a superior enlistment, and the caller // attempted an operation that would have created a new superior. Only a // single superior enlistment is allow. // public static final int ERROR_TRANSACTION_SUPERIOR_EXISTS = 6709; // // MessageId: ERROR_CRM_PROTOCOL_ALREADY_EXISTS // // MessageText: // // The RM tried to register a protocol that already exists. // public static final int ERROR_CRM_PROTOCOL_ALREADY_EXISTS = 6710; // // MessageId: ERROR_TRANSACTION_PROPAGATION_FAILED // // MessageText: // // The attempt to propagate the Transaction failed. // public static final int ERROR_TRANSACTION_PROPAGATION_FAILED = 6711; // // MessageId: ERROR_CRM_PROTOCOL_NOT_FOUND // // MessageText: // // The requested propagation protocol was not registered as a CRM. // public static final int ERROR_CRM_PROTOCOL_NOT_FOUND = 6712; // // MessageId: ERROR_TRANSACTION_INVALID_MARSHALL_BUFFER // // MessageText: // // The buffer passed in to PushTransaction or PullTransaction is not in a // valid format. // public static final int ERROR_TRANSACTION_INVALID_MARSHALL_BUFFER = 6713; // // MessageId: ERROR_CURRENT_TRANSACTION_NOT_VALID // // MessageText: // // The current transaction context associated with the thread is not a valid // handle to a transaction object. // public static final int ERROR_CURRENT_TRANSACTION_NOT_VALID = 6714; // // MessageId: ERROR_TRANSACTION_NOT_FOUND // // MessageText: // // The specified Transaction object could not be opened, because it was not // found. // public static final int ERROR_TRANSACTION_NOT_FOUND = 6715; // // MessageId: ERROR_RESOURCEMANAGER_NOT_FOUND // // MessageText: // // The specified ResourceManager object could not be opened, because it was // not found. // public static final int ERROR_RESOURCEMANAGER_NOT_FOUND = 6716; // // MessageId: ERROR_ENLISTMENT_NOT_FOUND // // MessageText: // // The specified Enlistment object could not be opened, because it was not // found. // public static final int ERROR_ENLISTMENT_NOT_FOUND = 6717; // // MessageId: ERROR_TRANSACTIONMANAGER_NOT_FOUND // // MessageText: // // The specified TransactionManager object could not be opened, because it // was not found. // public static final int ERROR_TRANSACTIONMANAGER_NOT_FOUND = 6718; // // MessageId: ERROR_TRANSACTIONMANAGER_NOT_ONLINE // // MessageText: // // The specified ResourceManager was unable to create an enlistment, because // its associated TransactionManager is not online. // public static final int ERROR_TRANSACTIONMANAGER_NOT_ONLINE = 6719; // // MessageId: ERROR_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION // // MessageText: // // The specified TransactionManager was unable to create the objects // contained in its logfile in the Ob namespace. Therefore, the // TransactionManager was unable to recover. // public static final int ERROR_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION = 6720; // // MessageId: ERROR_TRANSACTION_NOT_ROOT // // MessageText: // // The call to create a superior Enlistment on this Transaction object could // not be completed, because the Transaction object specified for the // enlistment is a subordinate branch of the Transaction. Only the root of // the Transactoin can be enlisted on as a superior. // public static final int ERROR_TRANSACTION_NOT_ROOT = 6721; // // MessageId: ERROR_TRANSACTION_OBJECT_EXPIRED // // MessageText: // // Because the associated transaction manager or resource manager has been // closed, the handle is no longer valid. // public static final int ERROR_TRANSACTION_OBJECT_EXPIRED = 6722; // // MessageId: ERROR_TRANSACTION_RESPONSE_NOT_ENLISTED // // MessageText: // // The specified operation could not be performed on this Superior // enlistment, because the enlistment was not created with the corresponding // completion response in the NotificationMask. // public static final int ERROR_TRANSACTION_RESPONSE_NOT_ENLISTED = 6723; // // MessageId: ERROR_TRANSACTION_RECORD_TOO_LONG // // MessageText: // // The specified operation could not be performed, because the record that // would be logged was too long. This can occur because of two conditions: // either there are too many Enlistments on this Transaction, or the // combined RecoveryInformation being logged on behalf of those Enlistments // is too long. // public static final int ERROR_TRANSACTION_RECORD_TOO_LONG = 6724; // // MessageId: ERROR_IMPLICIT_TRANSACTION_NOT_SUPPORTED // // MessageText: // // Implicit transaction are not supported. // public static final int ERROR_IMPLICIT_TRANSACTION_NOT_SUPPORTED = 6725; // // MessageId: ERROR_TRANSACTION_INTEGRITY_VIOLATED // // MessageText: // // The kernel transaction manager had to abort or forget the transaction // because it blocked forward progress. // public static final int ERROR_TRANSACTION_INTEGRITY_VIOLATED = 6726; // ///////////////////////////////////////////////// // =// // =Transactional File Services (TxF) // // =Error codes=// // =// // =6800 to=6899=// // ///////////////////////////////////////////////// // // MessageId: ERROR_TRANSACTIONAL_CONFLICT // // MessageText: // // The function attempted to use a name that is reserved for use by another // transaction. // public static final int ERROR_TRANSACTIONAL_CONFLICT = 6800; // // MessageId: ERROR_RM_NOT_ACTIVE // // MessageText: // // Transaction support within the specified file system resource manager is // not started or was shutdown due to an error. // public static final int ERROR_RM_NOT_ACTIVE = 6801; // // MessageId: ERROR_RM_METADATA_CORRUPT // // MessageText: // // The metadata of the RM has been corrupted. The RM will not function. // public static final int ERROR_RM_METADATA_CORRUPT = 6802; // // MessageId: ERROR_DIRECTORY_NOT_RM // // MessageText: // // The specified directory does not contain a resource manager. // public static final int ERROR_DIRECTORY_NOT_RM = 6803; // // MessageId: ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE // // MessageText: // // The remote server or share does not support transacted file operations. // public static final int ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE = 6805; // // MessageId: ERROR_LOG_RESIZE_INVALID_SIZE // // MessageText: // // The requested log size is invalid. // public static final int ERROR_LOG_RESIZE_INVALID_SIZE = 6806; // // MessageId: ERROR_OBJECT_NO_LONGER_EXISTS // // MessageText: // // The object (file, stream, link) corresponding to the handle has been // deleted by a Transaction Savepoint Rollback. // public static final int ERROR_OBJECT_NO_LONGER_EXISTS = 6807; // // MessageId: ERROR_STREAM_MINIVERSION_NOT_FOUND // // MessageText: // // The specified file miniversion was not found for this transacted file // open. // public static final int ERROR_STREAM_MINIVERSION_NOT_FOUND = 6808; // // MessageId: ERROR_STREAM_MINIVERSION_NOT_VALID // // MessageText: // // The specified file miniversion was found but has been invalidated. Most // likely cause is a transaction savepoint rollback. // public static final int ERROR_STREAM_MINIVERSION_NOT_VALID = 6809; // // MessageId: ERROR_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION // // MessageText: // // A miniversion may only be opened in the context of the transaction that // created it. // public static final int ERROR_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION = 6810; // // MessageId: ERROR_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT // // MessageText: // // It is not possible to open a miniversion with modify access. // public static final int ERROR_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT = 6811; // // MessageId: ERROR_CANT_CREATE_MORE_STREAM_MINIVERSIONS // // MessageText: // // It is not possible to create any more miniversions for this stream. // public static final int ERROR_CANT_CREATE_MORE_STREAM_MINIVERSIONS = 6812; // // MessageId: ERROR_REMOTE_FILE_VERSION_MISMATCH // // MessageText: // // The remote server sent mismatching version number or Fid for a file // opened with transactions. // public static final int ERROR_REMOTE_FILE_VERSION_MISMATCH = 6814; // // MessageId: ERROR_HANDLE_NO_LONGER_VALID // // MessageText: // // The handle has been invalidated by a transaction. The most likely cause // is the presence of memory mapping on a file or an open handle when the // transaction ended or rolled back to savepoint. // public static final int ERROR_HANDLE_NO_LONGER_VALID = 6815; // // MessageId: ERROR_NO_TXF_METADATA // // MessageText: // // There is no transaction metadata on the file. // public static final int ERROR_NO_TXF_METADATA = 6816; // // MessageId: ERROR_LOG_CORRUPTION_DETECTED // // MessageText: // // The log data is corrupt. // public static final int ERROR_LOG_CORRUPTION_DETECTED = 6817; // // MessageId: ERROR_CANT_RECOVER_WITH_HANDLE_OPEN // // MessageText: // // The file can't be recovered because there is a handle still open on it. // public static final int ERROR_CANT_RECOVER_WITH_HANDLE_OPEN = 6818; // // MessageId: ERROR_RM_DISCONNECTED // // MessageText: // // The transaction outcome is unavailable because the resource manager // responsible for it has disconnected. // public static final int ERROR_RM_DISCONNECTED = 6819; // // MessageId: ERROR_ENLISTMENT_NOT_SUPERIOR // // MessageText: // // The request was rejected because the enlistment in question is not a // superior enlistment. // public static final int ERROR_ENLISTMENT_NOT_SUPERIOR = 6820; // // MessageId: ERROR_RECOVERY_NOT_NEEDED // // MessageText: // // The transactional resource manager is already consistent. Recovery is not // needed. // public static final int ERROR_RECOVERY_NOT_NEEDED = 6821; // // MessageId: ERROR_RM_ALREADY_STARTED // // MessageText: // // The transactional resource manager has already been started. // public static final int ERROR_RM_ALREADY_STARTED = 6822; // // MessageId: ERROR_FILE_IDENTITY_NOT_PERSISTENT // // MessageText: // // The file cannot be opened transactionally, because its identity depends // on the outcome of an unresolved transaction. // public static final int ERROR_FILE_IDENTITY_NOT_PERSISTENT = 6823; // // MessageId: ERROR_CANT_BREAK_TRANSACTIONAL_DEPENDENCY // // MessageText: // // The operation cannot be performed because another transaction is // depending on the fact that this property will not change. // public static final int ERROR_CANT_BREAK_TRANSACTIONAL_DEPENDENCY = 6824; // // MessageId: ERROR_CANT_CROSS_RM_BOUNDARY // // MessageText: // // The operation would involve a single file with two transactional resource // managers and is therefore not allowed. // public static final int ERROR_CANT_CROSS_RM_BOUNDARY = 6825; // // MessageId: ERROR_TXF_DIR_NOT_EMPTY // // MessageText: // // The $Txf directory must be empty for this operation to succeed. // public static final int ERROR_TXF_DIR_NOT_EMPTY = 6826; // // MessageId: ERROR_INDOUBT_TRANSACTIONS_EXIST // // MessageText: // // The operation would leave a transactional resource manager in an // inconsistent state and is therefore not allowed. // public static final int ERROR_INDOUBT_TRANSACTIONS_EXIST = 6827; // // MessageId: ERROR_TM_VOLATILE // // MessageText: // // The operation could not be completed because the transaction manager does // not have a log. // public static final int ERROR_TM_VOLATILE = 6828; // // MessageId: ERROR_ROLLBACK_TIMER_EXPIRED // // MessageText: // // A rollback could not be scheduled because a previously scheduled rollback // has already executed or been queued for execution. // public static final int ERROR_ROLLBACK_TIMER_EXPIRED = 6829; // // MessageId: ERROR_TXF_ATTRIBUTE_CORRUPT // // MessageText: // // The transactional metadata attribute on the file or directory is corrupt // and unreadable. // public static final int ERROR_TXF_ATTRIBUTE_CORRUPT = 6830; // // MessageId: ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION // // MessageText: // // The encryption operation could not be completed because a transaction is // active. // public static final int ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION = 6831; // // MessageId: ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED // // MessageText: // // This object is not allowed to be opened in a transaction. // public static final int ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED = 6832; // // MessageId: ERROR_LOG_GROWTH_FAILED // // MessageText: // // An attempt to create space in the transactional resource manager's log // failed. The failure status has been recorded in the event log. // public static final int ERROR_LOG_GROWTH_FAILED = 6833; // // MessageId: ERROR_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE // // MessageText: // // Memory mapping (creating a mapped section) a remote file under a // transaction is not supported. // public static final int ERROR_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE = 6834; // // MessageId: ERROR_TXF_METADATA_ALREADY_PRESENT // // MessageText: // // Transaction metadata is already present on this file and cannot be // superseded. // public static final int ERROR_TXF_METADATA_ALREADY_PRESENT = 6835; // // MessageId: ERROR_TRANSACTION_SCOPE_CALLBACKS_NOT_SET // // MessageText: // // A transaction scope could not be entered because the scope handler has // not been initialized. // public static final int ERROR_TRANSACTION_SCOPE_CALLBACKS_NOT_SET = 6836; // // MessageId: ERROR_TRANSACTION_REQUIRED_PROMOTION // // MessageText: // // Promotion was required in order to allow the resource manager to enlist, // but the transaction was set to disallow it. // public static final int ERROR_TRANSACTION_REQUIRED_PROMOTION = 6837; // // MessageId: ERROR_CANNOT_EXECUTE_FILE_IN_TRANSACTION // // MessageText: // // This file is open for modification in an unresolved transaction and may // be opened for execute only by a transacted reader. // public static final int ERROR_CANNOT_EXECUTE_FILE_IN_TRANSACTION = 6838; // // MessageId: ERROR_TRANSACTIONS_NOT_FROZEN // // MessageText: // // The request to thaw frozen transactions was ignored because transactions // had not previously been frozen. // public static final int ERROR_TRANSACTIONS_NOT_FROZEN = 6839; // // MessageId: ERROR_TRANSACTION_FREEZE_IN_PROGRESS // // MessageText: // // Transactions cannot be frozen because a freeze is already in progress. // public static final int ERROR_TRANSACTION_FREEZE_IN_PROGRESS = 6840; // // MessageId: ERROR_NOT_SNAPSHOT_VOLUME // // MessageText: // // The target volume is not a snapshot volume. This operation is only valid // on a volume mounted as a snapshot. // public static final int ERROR_NOT_SNAPSHOT_VOLUME = 6841; // // MessageId: ERROR_NO_SAVEPOINT_WITH_OPEN_FILES // // MessageText: // // The savepoint operation failed because files are open on the transaction. // This is not permitted. // public static final int ERROR_NO_SAVEPOINT_WITH_OPEN_FILES = 6842; // // MessageId: ERROR_DATA_LOST_REPAIR // // MessageText: // // Windows has discovered corruption in a file, and that file has since been // repaired. Data loss may have occurred. // public static final int ERROR_DATA_LOST_REPAIR = 6843; // // MessageId: ERROR_SPARSE_NOT_ALLOWED_IN_TRANSACTION // // MessageText: // // The sparse operation could not be completed because a transaction is // active on the file. // public static final int ERROR_SPARSE_NOT_ALLOWED_IN_TRANSACTION = 6844; // // MessageId: ERROR_TM_IDENTITY_MISMATCH // // MessageText: // // The call to create a TransactionManager object failed because the Tm // Identity stored in the logfile does not match the Tm Identity that was // passed in as an argument. // public static final int ERROR_TM_IDENTITY_MISMATCH = 6845; // // MessageId: ERROR_FLOATED_SECTION // // MessageText: // // I/O was attempted on a section object that has been floated as a result // of a transaction ending. There is no valid data. // public static final int ERROR_FLOATED_SECTION = 6846; // // MessageId: ERROR_CANNOT_ACCEPT_TRANSACTED_WORK // // MessageText: // // The transactional resource manager cannot currently accept transacted // work due to a transient condition such as low resources. // public static final int ERROR_CANNOT_ACCEPT_TRANSACTED_WORK = 6847; // // MessageId: ERROR_CANNOT_ABORT_TRANSACTIONS // // MessageText: // // The transactional resource manager had too many tranactions outstanding // that could not be aborted. The transactional resource manger has been // shut down. // public static final int ERROR_CANNOT_ABORT_TRANSACTIONS = 6848; // // MessageId: ERROR_BAD_CLUSTERS // // MessageText: // // The operation could not be completed due to bad clusters on disk. // public static final int ERROR_BAD_CLUSTERS = 6849; // // MessageId: ERROR_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION // // MessageText: // // The compression operation could not be completed because a transaction is // active on the file. // public static final int ERROR_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION = 6850; // // MessageId: ERROR_VOLUME_DIRTY // // MessageText: // // The operation could not be completed because the volume is dirty. Please // run chkdsk and try again. // public static final int ERROR_VOLUME_DIRTY = 6851; // // MessageId: ERROR_NO_LINK_TRACKING_IN_TRANSACTION // // MessageText: // // The link tracking operation could not be completed because a transaction // is active. // public static final int ERROR_NO_LINK_TRACKING_IN_TRANSACTION = 6852; // // MessageId: ERROR_OPERATION_NOT_SUPPORTED_IN_TRANSACTION // // MessageText: // // This operation cannot be performed in a transaction. // public static final int ERROR_OPERATION_NOT_SUPPORTED_IN_TRANSACTION = 6853; // ///////////////////////////////////////////////// // =// // =Available=// // =// // =6900 to=6999=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =Terminal Server Error codes=// // =// // =7000 to=7099=// // ///////////////////////////////////////////////// // // MessageId: ERROR_CTX_WINSTATION_NAME_INVALID // // MessageText: // // The specified session name is invalid. // public static final int ERROR_CTX_WINSTATION_NAME_INVALID = 7001; // // MessageId: ERROR_CTX_INVALID_PD // // MessageText: // // The specified protocol driver is invalid. // public static final int ERROR_CTX_INVALID_PD = 7002; // // MessageId: ERROR_CTX_PD_NOT_FOUND // // MessageText: // // The specified protocol driver was not found in the system path. // public static final int ERROR_CTX_PD_NOT_FOUND = 7003; // // MessageId: ERROR_CTX_WD_NOT_FOUND // // MessageText: // // The specified terminal connection driver was not found in the system // path. // public static final int ERROR_CTX_WD_NOT_FOUND = 7004; // // MessageId: ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY // // MessageText: // // A registry key for event logging could not be created for this session. // public static final int ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY = 7005; // // MessageId: ERROR_CTX_SERVICE_NAME_COLLISION // // MessageText: // // A service with the same name already exists on the system. // public static final int ERROR_CTX_SERVICE_NAME_COLLISION = 7006; // // MessageId: ERROR_CTX_CLOSE_PENDING // // MessageText: // // A close operation is pending on the session. // public static final int ERROR_CTX_CLOSE_PENDING = 7007; // // MessageId: ERROR_CTX_NO_OUTBUF // // MessageText: // // There are no free output buffers available. // public static final int ERROR_CTX_NO_OUTBUF = 7008; // // MessageId: ERROR_CTX_MODEM_INF_NOT_FOUND // // MessageText: // // The MODEM.INF file was not found. // public static final int ERROR_CTX_MODEM_INF_NOT_FOUND = 7009; // // MessageId: ERROR_CTX_INVALID_MODEMNAME // // MessageText: // // The modem name was not found in MODEM.INF. // public static final int ERROR_CTX_INVALID_MODEMNAME = 7010; // // MessageId: ERROR_CTX_MODEM_RESPONSE_ERROR // // MessageText: // // The modem did not accept the command sent to it. Verify that the // configured modem name matches the attached modem. // public static final int ERROR_CTX_MODEM_RESPONSE_ERROR = 7011; // // MessageId: ERROR_CTX_MODEM_RESPONSE_TIMEOUT // // MessageText: // // The modem did not respond to the command sent to it. Verify that the // modem is properly cabled and powered on. // public static final int ERROR_CTX_MODEM_RESPONSE_TIMEOUT = 7012; // // MessageId: ERROR_CTX_MODEM_RESPONSE_NO_CARRIER // // MessageText: // // Carrier detect has failed or carrier has been dropped due to disconnect. // public static final int ERROR_CTX_MODEM_RESPONSE_NO_CARRIER = 7013; // // MessageId: ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE // // MessageText: // // Dial tone not detected within the required time. Verify that the phone // cable is properly attached and functional. // public static final int ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE = 7014; // // MessageId: ERROR_CTX_MODEM_RESPONSE_BUSY // // MessageText: // // Busy signal detected at remote site on callback. // public static final int ERROR_CTX_MODEM_RESPONSE_BUSY = 7015; // // MessageId: ERROR_CTX_MODEM_RESPONSE_VOICE // // MessageText: // // Voice detected at remote site on callback. // public static final int ERROR_CTX_MODEM_RESPONSE_VOICE = 7016; // // MessageId: ERROR_CTX_TD_ERROR // // MessageText: // // Transport driver error // public static final int ERROR_CTX_TD_ERROR = 7017; // // MessageId: ERROR_CTX_WINSTATION_NOT_FOUND // // MessageText: // // The specified session cannot be found. // public static final int ERROR_CTX_WINSTATION_NOT_FOUND = 7022; // // MessageId: ERROR_CTX_WINSTATION_ALREADY_EXISTS // // MessageText: // // The specified session name is already in use. // public static final int ERROR_CTX_WINSTATION_ALREADY_EXISTS = 7023; // // MessageId: ERROR_CTX_WINSTATION_BUSY // // MessageText: // // The requested operation cannot be completed because the terminal // connection is currently busy processing a connect, disconnect, reset, or // delete operation. // public static final int ERROR_CTX_WINSTATION_BUSY = 7024; // // MessageId: ERROR_CTX_BAD_VIDEO_MODE // // MessageText: // // An attempt has been made to connect to a session whose video mode is not // supported by the current client. // public static final int ERROR_CTX_BAD_VIDEO_MODE = 7025; // // MessageId: ERROR_CTX_GRAPHICS_INVALID // // MessageText: // // The application attempted to enable DOS graphics mode. // DOS graphics mode is not supported. // public static final int ERROR_CTX_GRAPHICS_INVALID = 7035; // // MessageId: ERROR_CTX_LOGON_DISABLED // // MessageText: // // Your interactive logon privilege has been disabled. // Please contact your administrator. // public static final int ERROR_CTX_LOGON_DISABLED = 7037; // // MessageId: ERROR_CTX_NOT_CONSOLE // // MessageText: // // The requested operation can be performed only on the system console. // This is most often the result of a driver or system DLL requiring direct // console access. // public static final int ERROR_CTX_NOT_CONSOLE = 7038; // // MessageId: ERROR_CTX_CLIENT_QUERY_TIMEOUT // // MessageText: // // The client failed to respond to the server connect message. // public static final int ERROR_CTX_CLIENT_QUERY_TIMEOUT = 7040; // // MessageId: ERROR_CTX_CONSOLE_DISCONNECT // // MessageText: // // Disconnecting the console session is not supported. // public static final int ERROR_CTX_CONSOLE_DISCONNECT = 7041; // // MessageId: ERROR_CTX_CONSOLE_CONNECT // // MessageText: // // Reconnecting a disconnected session to the console is not supported. // public static final int ERROR_CTX_CONSOLE_CONNECT = 7042; // // MessageId: ERROR_CTX_SHADOW_DENIED // // MessageText: // // The request to control another session remotely was denied. // public static final int ERROR_CTX_SHADOW_DENIED = 7044; // // MessageId: ERROR_CTX_WINSTATION_ACCESS_DENIED // // MessageText: // // The requested session access is denied. // public static final int ERROR_CTX_WINSTATION_ACCESS_DENIED = 7045; // // MessageId: ERROR_CTX_INVALID_WD // // MessageText: // // The specified terminal connection driver is invalid. // public static final int ERROR_CTX_INVALID_WD = 7049; // // MessageId: ERROR_CTX_SHADOW_INVALID // // MessageText: // // The requested session cannot be controlled remotely. // This may be because the session is disconnected or does not currently // have a user logged on. // public static final int ERROR_CTX_SHADOW_INVALID = 7050; // // MessageId: ERROR_CTX_SHADOW_DISABLED // // MessageText: // // The requested session is not configured to allow remote control. // public static final int ERROR_CTX_SHADOW_DISABLED = 7051; // // MessageId: ERROR_CTX_CLIENT_LICENSE_IN_USE // // MessageText: // // Your request to connect to this Terminal Server has been rejected. Your // Terminal Server client license number is currently being used by another // user. // Please call your system administrator to obtain a unique license number. // public static final int ERROR_CTX_CLIENT_LICENSE_IN_USE = 7052; // // MessageId: ERROR_CTX_CLIENT_LICENSE_NOT_SET // // MessageText: // // Your request to connect to this Terminal Server has been rejected. Your // Terminal Server client license number has not been entered for this copy // of the Terminal Server client. // Please contact your system administrator. // public static final int ERROR_CTX_CLIENT_LICENSE_NOT_SET = 7053; // // MessageId: ERROR_CTX_LICENSE_NOT_AVAILABLE // // MessageText: // // The number of connections to this computer is limited and all connections // are in use right now. // Try connecting later or contact your system administrator. // public static final int ERROR_CTX_LICENSE_NOT_AVAILABLE = 7054; // // MessageId: ERROR_CTX_LICENSE_CLIENT_INVALID // // MessageText: // // The client you are using is not licensed to use this system. Your logon // request is denied. // public static final int ERROR_CTX_LICENSE_CLIENT_INVALID = 7055; // // MessageId: ERROR_CTX_LICENSE_EXPIRED // // MessageText: // // The system license has expired. Your logon request is denied. // public static final int ERROR_CTX_LICENSE_EXPIRED = 7056; // // MessageId: ERROR_CTX_SHADOW_NOT_RUNNING // // MessageText: // // Remote control could not be terminated because the specified session is // not currently being remotely controlled. // public static final int ERROR_CTX_SHADOW_NOT_RUNNING = 7057; // // MessageId: ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE // // MessageText: // // The remote control of the console was terminated because the display mode // was changed. Changing the display mode in a remote control session is not // supported. // public static final int ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE = 7058; // // MessageId: ERROR_ACTIVATION_COUNT_EXCEEDED // // MessageText: // // Activation has already been reset the maximum number of times for this // installation. Your activation timer will not be cleared. // public static final int ERROR_ACTIVATION_COUNT_EXCEEDED = 7059; // // MessageId: ERROR_CTX_WINSTATIONS_DISABLED // // MessageText: // // Remote logins are currently disabled. // public static final int ERROR_CTX_WINSTATIONS_DISABLED = 7060; // // MessageId: ERROR_CTX_ENCRYPTION_LEVEL_REQUIRED // // MessageText: // // You do not have the proper encryption level to access this Session. // public static final int ERROR_CTX_ENCRYPTION_LEVEL_REQUIRED = 7061; // // MessageId: ERROR_CTX_SESSION_IN_USE // // MessageText: // // The user %s\\%s is currently logged on to this computer. Only the current // user or an administrator can log on to this computer. // public static final int ERROR_CTX_SESSION_IN_USE = 7062; // // MessageId: ERROR_CTX_NO_FORCE_LOGOFF // // MessageText: // // The user %s\\%s is already logged on to the console of this computer. You // do not have permission to log in at this time. To resolve this issue, // contact %s\\%s and have them log off. // public static final int ERROR_CTX_NO_FORCE_LOGOFF = 7063; // // MessageId: ERROR_CTX_ACCOUNT_RESTRICTION // // MessageText: // // Unable to log you on because of an account restriction. // public static final int ERROR_CTX_ACCOUNT_RESTRICTION = 7064; // // MessageId: ERROR_RDP_PROTOCOL_ERROR // // MessageText: // // The RDP protocol component %2 detected an error in the protocol stream // and has disconnected the client. // public static final int ERROR_RDP_PROTOCOL_ERROR = 7065; // // MessageId: ERROR_CTX_CDM_CONNECT // // MessageText: // // The Client Drive Mapping Service Has Connected on Terminal Connection. // public static final int ERROR_CTX_CDM_CONNECT = 7066; // // MessageId: ERROR_CTX_CDM_DISCONNECT // // MessageText: // // The Client Drive Mapping Service Has Disconnected on Terminal Connection. // public static final int ERROR_CTX_CDM_DISCONNECT = 7067; // // MessageId: ERROR_CTX_SECURITY_LAYER_ERROR // // MessageText: // // The Terminal Server security layer detected an error in the protocol // stream and has disconnected the client. // public static final int ERROR_CTX_SECURITY_LAYER_ERROR = 7068; // // MessageId: ERROR_TS_INCOMPATIBLE_SESSIONS // // MessageText: // // The target session is incompatible with the current session. // public static final int ERROR_TS_INCOMPATIBLE_SESSIONS = 7069; // ///////////////////////////////////////////////// // =// // =Available=// // =// // =7100 to=7499=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =/ // =Traffic Control Error Codes=/ // =/ // =7500 to=7999=/ // =/ // =defined in: tcerror.h=/ // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =Active Directory Error codes=// // =// // =8000 to=8999=// // ///////////////////////////////////////////////// // ***************** // FACILITY_FILE_REPLICATION_SERVICE // ***************** // // MessageId: FRS_ERR_INVALID_API_SEQUENCE // // MessageText: // // The file replication service API was called incorrectly. // public static final int FRS_ERR_INVALID_API_SEQUENCE = 8001; // // MessageId: FRS_ERR_STARTING_SERVICE // // MessageText: // // The file replication service cannot be started. // public static final int FRS_ERR_STARTING_SERVICE = 8002; // // MessageId: FRS_ERR_STOPPING_SERVICE // // MessageText: // // The file replication service cannot be stopped. // public static final int FRS_ERR_STOPPING_SERVICE = 8003; // // MessageId: FRS_ERR_INTERNAL_API // // MessageText: // // The file replication service API terminated the request. // The event log may have more information. // public static final int FRS_ERR_INTERNAL_API = 8004; // // MessageId: FRS_ERR_INTERNAL // // MessageText: // // The file replication service terminated the request. // The event log may have more information. // public static final int FRS_ERR_INTERNAL = 8005; // // MessageId: FRS_ERR_SERVICE_COMM // // MessageText: // // The file replication service cannot be contacted. // The event log may have more information. // public static final int FRS_ERR_SERVICE_COMM = 8006; // // MessageId: FRS_ERR_INSUFFICIENT_PRIV // // MessageText: // // The file replication service cannot satisfy the request because the user // has insufficient privileges. // The event log may have more information. // public static final int FRS_ERR_INSUFFICIENT_PRIV = 8007; // // MessageId: FRS_ERR_AUTHENTICATION // // MessageText: // // The file replication service cannot satisfy the request because // authenticated RPC is not available. // The event log may have more information. // public static final int FRS_ERR_AUTHENTICATION = 8008; // // MessageId: FRS_ERR_PARENT_INSUFFICIENT_PRIV // // MessageText: // // The file replication service cannot satisfy the request because the user // has insufficient privileges on the domain controller. // The event log may have more information. // public static final int FRS_ERR_PARENT_INSUFFICIENT_PRIV = 8009; // // MessageId: FRS_ERR_PARENT_AUTHENTICATION // // MessageText: // // The file replication service cannot satisfy the request because // authenticated RPC is not available on the domain controller. // The event log may have more information. // public static final int FRS_ERR_PARENT_AUTHENTICATION = 8010; // // MessageId: FRS_ERR_CHILD_TO_PARENT_COMM // // MessageText: // // The file replication service cannot communicate with the file replication // service on the domain controller. // The event log may have more information. // public static final int FRS_ERR_CHILD_TO_PARENT_COMM = 8011; // // MessageId: FRS_ERR_PARENT_TO_CHILD_COMM // // MessageText: // // The file replication service on the domain controller cannot communicate // with the file replication service on this computer. // The event log may have more information. // public static final int FRS_ERR_PARENT_TO_CHILD_COMM = 8012; // // MessageId: FRS_ERR_SYSVOL_POPULATE // // MessageText: // // The file replication service cannot populate the system volume because of // an internal error. // The event log may have more information. // public static final int FRS_ERR_SYSVOL_POPULATE = 8013; // // MessageId: FRS_ERR_SYSVOL_POPULATE_TIMEOUT // // MessageText: // // The file replication service cannot populate the system volume because of // an internal timeout. // The event log may have more information. // public static final int FRS_ERR_SYSVOL_POPULATE_TIMEOUT = 8014; // // MessageId: FRS_ERR_SYSVOL_IS_BUSY // // MessageText: // // The file replication service cannot process the request. The system // volume is busy with a previous request. // public static final int FRS_ERR_SYSVOL_IS_BUSY = 8015; // // MessageId: FRS_ERR_SYSVOL_DEMOTE // // MessageText: // // The file replication service cannot stop replicating the system volume // because of an internal error. // The event log may have more information. // public static final int FRS_ERR_SYSVOL_DEMOTE = 8016; // // MessageId: FRS_ERR_INVALID_SERVICE_PARAMETER // // MessageText: // // The file replication service detected an invalid parameter. // public static final int FRS_ERR_INVALID_SERVICE_PARAMETER = 8017; // ***************** // FACILITY DIRECTORY SERVICE // ***************** public static final int DS_S_SUCCESS = NO_ERROR; // // MessageId: ERROR_DS_NOT_INSTALLED // // MessageText: // // An error occurred while installing the directory service. For more // information, see the event log. // public static final int ERROR_DS_NOT_INSTALLED = 8200; // // MessageId: ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY // // MessageText: // // The directory service evaluated group memberships locally. // public static final int ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY = 8201; // // MessageId: ERROR_DS_NO_ATTRIBUTE_OR_VALUE // // MessageText: // // The specified directory service attribute or value does not exist. // public static final int ERROR_DS_NO_ATTRIBUTE_OR_VALUE = 8202; // // MessageId: ERROR_DS_INVALID_ATTRIBUTE_SYNTAX // // MessageText: // // The attribute syntax specified to the directory service is invalid. // public static final int ERROR_DS_INVALID_ATTRIBUTE_SYNTAX = 8203; // // MessageId: ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED // // MessageText: // // The attribute type specified to the directory service is not defined. // public static final int ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED = 8204; // // MessageId: ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS // // MessageText: // // The specified directory service attribute or value already exists. // public static final int ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS = 8205; // // MessageId: ERROR_DS_BUSY // // MessageText: // // The directory service is busy. // public static final int ERROR_DS_BUSY = 8206; // // MessageId: ERROR_DS_UNAVAILABLE // // MessageText: // // The directory service is unavailable. // public static final int ERROR_DS_UNAVAILABLE = 8207; // // MessageId: ERROR_DS_NO_RIDS_ALLOCATED // // MessageText: // // The directory service was unable to allocate a relative identifier. // public static final int ERROR_DS_NO_RIDS_ALLOCATED = 8208; // // MessageId: ERROR_DS_NO_MORE_RIDS // // MessageText: // // The directory service has exhausted the pool of relative identifiers. // public static final int ERROR_DS_NO_MORE_RIDS = 8209; // // MessageId: ERROR_DS_INCORRECT_ROLE_OWNER // // MessageText: // // The requested operation could not be performed because the directory // service is not the master for that type of operation. // public static final int ERROR_DS_INCORRECT_ROLE_OWNER = 8210; // // MessageId: ERROR_DS_RIDMGR_INIT_ERROR // // MessageText: // // The directory service was unable to initialize the subsystem that // allocates relative identifiers. // public static final int ERROR_DS_RIDMGR_INIT_ERROR = 8211; // // MessageId: ERROR_DS_OBJ_CLASS_VIOLATION // // MessageText: // // The requested operation did not satisfy one or more constraints // associated with the class of the object. // public static final int ERROR_DS_OBJ_CLASS_VIOLATION = 8212; // // MessageId: ERROR_DS_CANT_ON_NON_LEAF // // MessageText: // // The directory service can perform the requested operation only on a leaf // object. // public static final int ERROR_DS_CANT_ON_NON_LEAF = 8213; // // MessageId: ERROR_DS_CANT_ON_RDN // // MessageText: // // The directory service cannot perform the requested operation on the RDN // attribute of an object. // public static final int ERROR_DS_CANT_ON_RDN = 8214; // // MessageId: ERROR_DS_CANT_MOD_OBJ_CLASS // // MessageText: // // The directory service detected an attempt to modify the object class of // an object. // public static final int ERROR_DS_CANT_MOD_OBJ_CLASS = 8215; // // MessageId: ERROR_DS_CROSS_DOM_MOVE_ERROR // // MessageText: // // The requested cross-domain move operation could not be performed. // public static final int ERROR_DS_CROSS_DOM_MOVE_ERROR = 8216; // // MessageId: ERROR_DS_GC_NOT_AVAILABLE // // MessageText: // // Unable to contact the global catalog server. // public static final int ERROR_DS_GC_NOT_AVAILABLE = 8217; // // MessageId: ERROR_SHARED_POLICY // // MessageText: // // The policy object is shared and can only be modified at the root. // public static final int ERROR_SHARED_POLICY = 8218; // // MessageId: ERROR_POLICY_OBJECT_NOT_FOUND // // MessageText: // // The policy object does not exist. // public static final int ERROR_POLICY_OBJECT_NOT_FOUND = 8219; // // MessageId: ERROR_POLICY_ONLY_IN_DS // // MessageText: // // The requested policy information is only in the directory service. // public static final int ERROR_POLICY_ONLY_IN_DS = 8220; // // MessageId: ERROR_PROMOTION_ACTIVE // // MessageText: // // A domain controller promotion is currently active. // public static final int ERROR_PROMOTION_ACTIVE = 8221; // // MessageId: ERROR_NO_PROMOTION_ACTIVE // // MessageText: // // A domain controller promotion is not currently active // public static final int ERROR_NO_PROMOTION_ACTIVE = 8222; // =8223 unused // // MessageId: ERROR_DS_OPERATIONS_ERROR // // MessageText: // // An operations error occurred. // public static final int ERROR_DS_OPERATIONS_ERROR = 8224; // // MessageId: ERROR_DS_PROTOCOL_ERROR // // MessageText: // // A protocol error occurred. // public static final int ERROR_DS_PROTOCOL_ERROR = 8225; // // MessageId: ERROR_DS_TIMELIMIT_EXCEEDED // // MessageText: // // The time limit for this request was exceeded. // public static final int ERROR_DS_TIMELIMIT_EXCEEDED = 8226; // // MessageId: ERROR_DS_SIZELIMIT_EXCEEDED // // MessageText: // // The size limit for this request was exceeded. // public static final int ERROR_DS_SIZELIMIT_EXCEEDED = 8227; // // MessageId: ERROR_DS_ADMIN_LIMIT_EXCEEDED // // MessageText: // // The administrative limit for this request was exceeded. // public static final int ERROR_DS_ADMIN_LIMIT_EXCEEDED = 8228; // // MessageId: ERROR_DS_COMPARE_FALSE // // MessageText: // // The compare response was false. // public static final int ERROR_DS_COMPARE_FALSE = 8229; // // MessageId: ERROR_DS_COMPARE_TRUE // // MessageText: // // The compare response was true. // public static final int ERROR_DS_COMPARE_TRUE = 8230; // // MessageId: ERROR_DS_AUTH_METHOD_NOT_SUPPORTED // // MessageText: // // The requested authentication method is not supported by the server. // public static final int ERROR_DS_AUTH_METHOD_NOT_SUPPORTED = 8231; // // MessageId: ERROR_DS_STRONG_AUTH_REQUIRED // // MessageText: // // A more secure authentication method is required for this server. // public static final int ERROR_DS_STRONG_AUTH_REQUIRED = 8232; // // MessageId: ERROR_DS_INAPPROPRIATE_AUTH // // MessageText: // // Inappropriate authentication. // public static final int ERROR_DS_INAPPROPRIATE_AUTH = 8233; // // MessageId: ERROR_DS_AUTH_UNKNOWN // // MessageText: // // The authentication mechanism is unknown. // public static final int ERROR_DS_AUTH_UNKNOWN = 8234; // // MessageId: ERROR_DS_REFERRAL // // MessageText: // // A referral was returned from the server. // public static final int ERROR_DS_REFERRAL = 8235; // // MessageId: ERROR_DS_UNAVAILABLE_CRIT_EXTENSION // // MessageText: // // The server does not support the requested critical extension. // public static final int ERROR_DS_UNAVAILABLE_CRIT_EXTENSION = 8236; // // MessageId: ERROR_DS_CONFIDENTIALITY_REQUIRED // // MessageText: // // This request requires a secure connection. // public static final int ERROR_DS_CONFIDENTIALITY_REQUIRED = 8237; // // MessageId: ERROR_DS_INAPPROPRIATE_MATCHING // // MessageText: // // Inappropriate matching. // public static final int ERROR_DS_INAPPROPRIATE_MATCHING = 8238; // // MessageId: ERROR_DS_CONSTRAINT_VIOLATION // // MessageText: // // A constraint violation occurred. // public static final int ERROR_DS_CONSTRAINT_VIOLATION = 8239; // // MessageId: ERROR_DS_NO_SUCH_OBJECT // // MessageText: // // There is no such object on the server. // public static final int ERROR_DS_NO_SUCH_OBJECT = 8240; // // MessageId: ERROR_DS_ALIAS_PROBLEM // // MessageText: // // There is an alias problem. // public static final int ERROR_DS_ALIAS_PROBLEM = 8241; // // MessageId: ERROR_DS_INVALID_DN_SYNTAX // // MessageText: // // An invalid dn syntax has been specified. // public static final int ERROR_DS_INVALID_DN_SYNTAX = 8242; // // MessageId: ERROR_DS_IS_LEAF // // MessageText: // // The object is a leaf object. // public static final int ERROR_DS_IS_LEAF = 8243; // // MessageId: ERROR_DS_ALIAS_DEREF_PROBLEM // // MessageText: // // There is an alias dereferencing problem. // public static final int ERROR_DS_ALIAS_DEREF_PROBLEM = 8244; // // MessageId: ERROR_DS_UNWILLING_TO_PERFORM // // MessageText: // // The server is unwilling to process the request. // public static final int ERROR_DS_UNWILLING_TO_PERFORM = 8245; // // MessageId: ERROR_DS_LOOP_DETECT // // MessageText: // // A loop has been detected. // public static final int ERROR_DS_LOOP_DETECT = 8246; // // MessageId: ERROR_DS_NAMING_VIOLATION // // MessageText: // // There is a naming violation. // public static final int ERROR_DS_NAMING_VIOLATION = 8247; // // MessageId: ERROR_DS_OBJECT_RESULTS_TOO_LARGE // // MessageText: // // The result set is too large. // public static final int ERROR_DS_OBJECT_RESULTS_TOO_LARGE = 8248; // // MessageId: ERROR_DS_AFFECTS_MULTIPLE_DSAS // // MessageText: // // The operation affects multiple DSAs // public static final int ERROR_DS_AFFECTS_MULTIPLE_DSAS = 8249; // // MessageId: ERROR_DS_SERVER_DOWN // // MessageText: // // The server is not operational. // public static final int ERROR_DS_SERVER_DOWN = 8250; // // MessageId: ERROR_DS_LOCAL_ERROR // // MessageText: // // A local error has occurred. // public static final int ERROR_DS_LOCAL_ERROR = 8251; // // MessageId: ERROR_DS_ENCODING_ERROR // // MessageText: // // An encoding error has occurred. // public static final int ERROR_DS_ENCODING_ERROR = 8252; // // MessageId: ERROR_DS_DECODING_ERROR // // MessageText: // // A decoding error has occurred. // public static final int ERROR_DS_DECODING_ERROR = 8253; // // MessageId: ERROR_DS_FILTER_UNKNOWN // // MessageText: // // The search filter cannot be recognized. // public static final int ERROR_DS_FILTER_UNKNOWN = 8254; // // MessageId: ERROR_DS_PARAM_ERROR // // MessageText: // // One or more parameters are illegal. // public static final int ERROR_DS_PARAM_ERROR = 8255; // // MessageId: ERROR_DS_NOT_SUPPORTED // // MessageText: // // The specified method is not supported. // public static final int ERROR_DS_NOT_SUPPORTED = 8256; // // MessageId: ERROR_DS_NO_RESULTS_RETURNED // // MessageText: // // No results were returned. // public static final int ERROR_DS_NO_RESULTS_RETURNED = 8257; // // MessageId: ERROR_DS_CONTROL_NOT_FOUND // // MessageText: // // The specified control is not supported by the server. // public static final int ERROR_DS_CONTROL_NOT_FOUND = 8258; // // MessageId: ERROR_DS_CLIENT_LOOP // // MessageText: // // A referral loop was detected by the client. // public static final int ERROR_DS_CLIENT_LOOP = 8259; // // MessageId: ERROR_DS_REFERRAL_LIMIT_EXCEEDED // // MessageText: // // The preset referral limit was exceeded. // public static final int ERROR_DS_REFERRAL_LIMIT_EXCEEDED = 8260; // // MessageId: ERROR_DS_SORT_CONTROL_MISSING // // MessageText: // // The search requires a SORT control. // public static final int ERROR_DS_SORT_CONTROL_MISSING = 8261; // // MessageId: ERROR_DS_OFFSET_RANGE_ERROR // // MessageText: // // The search results exceed the offset range specified. // public static final int ERROR_DS_OFFSET_RANGE_ERROR = 8262; // // MessageId: ERROR_DS_ROOT_MUST_BE_NC // // MessageText: // // The root object must be the head of a naming context. The root object // cannot have an instantiated parent. // public static final int ERROR_DS_ROOT_MUST_BE_NC = 8301; // // MessageId: ERROR_DS_ADD_REPLICA_INHIBITED // // MessageText: // // The add replica operation cannot be performed. The naming context must be // writeable in order to create the replica. // public static final int ERROR_DS_ADD_REPLICA_INHIBITED = 8302; // // MessageId: ERROR_DS_ATT_NOT_DEF_IN_SCHEMA // // MessageText: // // A reference to an attribute that is not defined in the schema occurred. // public static final int ERROR_DS_ATT_NOT_DEF_IN_SCHEMA = 8303; // // MessageId: ERROR_DS_MAX_OBJ_SIZE_EXCEEDED // // MessageText: // // The maximum size of an object has been exceeded. // public static final int ERROR_DS_MAX_OBJ_SIZE_EXCEEDED = 8304; // // MessageId: ERROR_DS_OBJ_STRING_NAME_EXISTS // // MessageText: // // An attempt was made to add an object to the directory with a name that is // already in use. // public static final int ERROR_DS_OBJ_STRING_NAME_EXISTS = 8305; // // MessageId: ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA // // MessageText: // // An attempt was made to add an object of a class that does not have an RDN // defined in the schema. // public static final int ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA = 8306; // // MessageId: ERROR_DS_RDN_DOESNT_MATCH_SCHEMA // // MessageText: // // An attempt was made to add an object using an RDN that is not the RDN // defined in the schema. // public static final int ERROR_DS_RDN_DOESNT_MATCH_SCHEMA = 8307; // // MessageId: ERROR_DS_NO_REQUESTED_ATTS_FOUND // // MessageText: // // None of the requested attributes were found on the objects. // public static final int ERROR_DS_NO_REQUESTED_ATTS_FOUND = 8308; // // MessageId: ERROR_DS_USER_BUFFER_TO_SMALL // // MessageText: // // The user buffer is too small. // public static final int ERROR_DS_USER_BUFFER_TO_SMALL = 8309; // // MessageId: ERROR_DS_ATT_IS_NOT_ON_OBJ // // MessageText: // // The attribute specified in the operation is not present on the object. // public static final int ERROR_DS_ATT_IS_NOT_ON_OBJ = 8310; // // MessageId: ERROR_DS_ILLEGAL_MOD_OPERATION // // MessageText: // // Illegal modify operation. Some aspect of the modification is not // permitted. // public static final int ERROR_DS_ILLEGAL_MOD_OPERATION = 8311; // // MessageId: ERROR_DS_OBJ_TOO_LARGE // // MessageText: // // The specified object is too large. // public static final int ERROR_DS_OBJ_TOO_LARGE = 8312; // // MessageId: ERROR_DS_BAD_INSTANCE_TYPE // // MessageText: // // The specified instance type is not valid. // public static final int ERROR_DS_BAD_INSTANCE_TYPE = 8313; // // MessageId: ERROR_DS_MASTERDSA_REQUIRED // // MessageText: // // The operation must be performed at a master DSA. // public static final int ERROR_DS_MASTERDSA_REQUIRED = 8314; // // MessageId: ERROR_DS_OBJECT_CLASS_REQUIRED // // MessageText: // // The object class attribute must be specified. // public static final int ERROR_DS_OBJECT_CLASS_REQUIRED = 8315; // // MessageId: ERROR_DS_MISSING_REQUIRED_ATT // // MessageText: // // A required attribute is missing. // public static final int ERROR_DS_MISSING_REQUIRED_ATT = 8316; // // MessageId: ERROR_DS_ATT_NOT_DEF_FOR_CLASS // // MessageText: // // An attempt was made to modify an object to include an attribute that is // not legal for its class. // public static final int ERROR_DS_ATT_NOT_DEF_FOR_CLASS = 8317; // // MessageId: ERROR_DS_ATT_ALREADY_EXISTS // // MessageText: // // The specified attribute is already present on the object. // public static final int ERROR_DS_ATT_ALREADY_EXISTS = 8318; // =8319 unused // // MessageId: ERROR_DS_CANT_ADD_ATT_VALUES // // MessageText: // // The specified attribute is not present, or has no values. // public static final int ERROR_DS_CANT_ADD_ATT_VALUES = 8320; // // MessageId: ERROR_DS_SINGLE_VALUE_CONSTRAINT // // MessageText: // // Multiple values were specified for an attribute that can have only one // value. // public static final int ERROR_DS_SINGLE_VALUE_CONSTRAINT = 8321; // // MessageId: ERROR_DS_RANGE_CONSTRAINT // // MessageText: // // A value for the attribute was not in the acceptable range of values. // public static final int ERROR_DS_RANGE_CONSTRAINT = 8322; // // MessageId: ERROR_DS_ATT_VAL_ALREADY_EXISTS // // MessageText: // // The specified value already exists. // public static final int ERROR_DS_ATT_VAL_ALREADY_EXISTS = 8323; // // MessageId: ERROR_DS_CANT_REM_MISSING_ATT // // MessageText: // // The attribute cannot be removed because it is not present on the object. // public static final int ERROR_DS_CANT_REM_MISSING_ATT = 8324; // // MessageId: ERROR_DS_CANT_REM_MISSING_ATT_VAL // // MessageText: // // The attribute value cannot be removed because it is not present on the // object. // public static final int ERROR_DS_CANT_REM_MISSING_ATT_VAL = 8325; // // MessageId: ERROR_DS_ROOT_CANT_BE_SUBREF // // MessageText: // // The specified root object cannot be a subref. // public static final int ERROR_DS_ROOT_CANT_BE_SUBREF = 8326; // // MessageId: ERROR_DS_NO_CHAINING // // MessageText: // // Chaining is not permitted. // public static final int ERROR_DS_NO_CHAINING = 8327; // // MessageId: ERROR_DS_NO_CHAINED_EVAL // // MessageText: // // Chained evaluation is not permitted. // public static final int ERROR_DS_NO_CHAINED_EVAL = 8328; // // MessageId: ERROR_DS_NO_PARENT_OBJECT // // MessageText: // // The operation could not be performed because the object's parent is // either uninstantiated or deleted. // public static final int ERROR_DS_NO_PARENT_OBJECT = 8329; // // MessageId: ERROR_DS_PARENT_IS_AN_ALIAS // // MessageText: // // Having a parent that is an alias is not permitted. Aliases are leaf // objects. // public static final int ERROR_DS_PARENT_IS_AN_ALIAS = 8330; // // MessageId: ERROR_DS_CANT_MIX_MASTER_AND_REPS // // MessageText: // // The object and parent must be of the same type, either both masters or // both replicas. // public static final int ERROR_DS_CANT_MIX_MASTER_AND_REPS = 8331; // // MessageId: ERROR_DS_CHILDREN_EXIST // // MessageText: // // The operation cannot be performed because child objects exist. This // operation can only be performed on a leaf object. // public static final int ERROR_DS_CHILDREN_EXIST = 8332; // // MessageId: ERROR_DS_OBJ_NOT_FOUND // // MessageText: // // Directory object not found. // public static final int ERROR_DS_OBJ_NOT_FOUND = 8333; // // MessageId: ERROR_DS_ALIASED_OBJ_MISSING // // MessageText: // // The aliased object is missing. // public static final int ERROR_DS_ALIASED_OBJ_MISSING = 8334; // // MessageId: ERROR_DS_BAD_NAME_SYNTAX // // MessageText: // // The object name has bad syntax. // public static final int ERROR_DS_BAD_NAME_SYNTAX = 8335; // // MessageId: ERROR_DS_ALIAS_POINTS_TO_ALIAS // // MessageText: // // It is not permitted for an alias to refer to another alias. // public static final int ERROR_DS_ALIAS_POINTS_TO_ALIAS = 8336; // // MessageId: ERROR_DS_CANT_DEREF_ALIAS // // MessageText: // // The alias cannot be dereferenced. // public static final int ERROR_DS_CANT_DEREF_ALIAS = 8337; // // MessageId: ERROR_DS_OUT_OF_SCOPE // // MessageText: // // The operation is out of scope. // public static final int ERROR_DS_OUT_OF_SCOPE = 8338; // // MessageId: ERROR_DS_OBJECT_BEING_REMOVED // // MessageText: // // The operation cannot continue because the object is in the process of // being removed. // public static final int ERROR_DS_OBJECT_BEING_REMOVED = 8339; // // MessageId: ERROR_DS_CANT_DELETE_DSA_OBJ // // MessageText: // // The DSA object cannot be deleted. // public static final int ERROR_DS_CANT_DELETE_DSA_OBJ = 8340; // // MessageId: ERROR_DS_GENERIC_ERROR // // MessageText: // // A directory service error has occurred. // public static final int ERROR_DS_GENERIC_ERROR = 8341; // // MessageId: ERROR_DS_DSA_MUST_BE_INT_MASTER // // MessageText: // // The operation can only be performed on an internal master DSA object. // public static final int ERROR_DS_DSA_MUST_BE_INT_MASTER = 8342; // // MessageId: ERROR_DS_CLASS_NOT_DSA // // MessageText: // // The object must be of class DSA. // public static final int ERROR_DS_CLASS_NOT_DSA = 8343; // // MessageId: ERROR_DS_INSUFF_ACCESS_RIGHTS // // MessageText: // // Insufficient access rights to perform the operation. // public static final int ERROR_DS_INSUFF_ACCESS_RIGHTS = 8344; // // MessageId: ERROR_DS_ILLEGAL_SUPERIOR // // MessageText: // // The object cannot be added because the parent is not on the list of // possible superiors. // public static final int ERROR_DS_ILLEGAL_SUPERIOR = 8345; // // MessageId: ERROR_DS_ATTRIBUTE_OWNED_BY_SAM // // MessageText: // // Access to the attribute is not permitted because the attribute is owned // by the Security Accounts Manager (SAM). // public static final int ERROR_DS_ATTRIBUTE_OWNED_BY_SAM = 8346; // // MessageId: ERROR_DS_NAME_TOO_MANY_PARTS // // MessageText: // // The name has too many parts. // public static final int ERROR_DS_NAME_TOO_MANY_PARTS = 8347; // // MessageId: ERROR_DS_NAME_TOO_LONG // // MessageText: // // The name is too long. // public static final int ERROR_DS_NAME_TOO_LONG = 8348; // // MessageId: ERROR_DS_NAME_VALUE_TOO_LONG // // MessageText: // // The name value is too long. // public static final int ERROR_DS_NAME_VALUE_TOO_LONG = 8349; // // MessageId: ERROR_DS_NAME_UNPARSEABLE // // MessageText: // // The directory service encountered an error parsing a name. // public static final int ERROR_DS_NAME_UNPARSEABLE = 8350; // // MessageId: ERROR_DS_NAME_TYPE_UNKNOWN // // MessageText: // // The directory service cannot get the attribute type for a name. // public static final int ERROR_DS_NAME_TYPE_UNKNOWN = 8351; // // MessageId: ERROR_DS_NOT_AN_OBJECT // // MessageText: // // The name does not identify an object; the name identifies a phantom. // public static final int ERROR_DS_NOT_AN_OBJECT = 8352; // // MessageId: ERROR_DS_SEC_DESC_TOO_SHORT // // MessageText: // // The security descriptor is too short. // public static final int ERROR_DS_SEC_DESC_TOO_SHORT = 8353; // // MessageId: ERROR_DS_SEC_DESC_INVALID // // MessageText: // // The security descriptor is invalid. // public static final int ERROR_DS_SEC_DESC_INVALID = 8354; // // MessageId: ERROR_DS_NO_DELETED_NAME // // MessageText: // // Failed to create name for deleted object. // public static final int ERROR_DS_NO_DELETED_NAME = 8355; // // MessageId: ERROR_DS_SUBREF_MUST_HAVE_PARENT // // MessageText: // // The parent of a new subref must exist. // public static final int ERROR_DS_SUBREF_MUST_HAVE_PARENT = 8356; // // MessageId: ERROR_DS_NCNAME_MUST_BE_NC // // MessageText: // // The object must be a naming context. // public static final int ERROR_DS_NCNAME_MUST_BE_NC = 8357; // // MessageId: ERROR_DS_CANT_ADD_SYSTEM_ONLY // // MessageText: // // It is not permitted to add an attribute which is owned by the system. // public static final int ERROR_DS_CANT_ADD_SYSTEM_ONLY = 8358; // // MessageId: ERROR_DS_CLASS_MUST_BE_CONCRETE // // MessageText: // // The class of the object must be structural; you cannot instantiate an // abstract class. // public static final int ERROR_DS_CLASS_MUST_BE_CONCRETE = 8359; // // MessageId: ERROR_DS_INVALID_DMD // // MessageText: // // The schema object could not be found. // public static final int ERROR_DS_INVALID_DMD = 8360; // // MessageId: ERROR_DS_OBJ_GUID_EXISTS // // MessageText: // // A local object with this GUID (dead or alive) already exists. // public static final int ERROR_DS_OBJ_GUID_EXISTS = 8361; // // MessageId: ERROR_DS_NOT_ON_BACKLINK // // MessageText: // // The operation cannot be performed on a back link. // public static final int ERROR_DS_NOT_ON_BACKLINK = 8362; // // MessageId: ERROR_DS_NO_CROSSREF_FOR_NC // // MessageText: // // The cross reference for the specified naming context could not be found. // public static final int ERROR_DS_NO_CROSSREF_FOR_NC = 8363; // // MessageId: ERROR_DS_SHUTTING_DOWN // // MessageText: // // The operation could not be performed because the directory service is // shutting down. // public static final int ERROR_DS_SHUTTING_DOWN = 8364; // // MessageId: ERROR_DS_UNKNOWN_OPERATION // // MessageText: // // The directory service request is invalid. // public static final int ERROR_DS_UNKNOWN_OPERATION = 8365; // // MessageId: ERROR_DS_INVALID_ROLE_OWNER // // MessageText: // // The role owner attribute could not be read. // public static final int ERROR_DS_INVALID_ROLE_OWNER = 8366; // // MessageId: ERROR_DS_COULDNT_CONTACT_FSMO // // MessageText: // // The requested FSMO operation failed. The current FSMO holder could not be // contacted. // public static final int ERROR_DS_COULDNT_CONTACT_FSMO = 8367; // // MessageId: ERROR_DS_CROSS_NC_DN_RENAME // // MessageText: // // Modification of a DN across a naming context is not permitted. // public static final int ERROR_DS_CROSS_NC_DN_RENAME = 8368; // // MessageId: ERROR_DS_CANT_MOD_SYSTEM_ONLY // // MessageText: // // The attribute cannot be modified because it is owned by the system. // public static final int ERROR_DS_CANT_MOD_SYSTEM_ONLY = 8369; // // MessageId: ERROR_DS_REPLICATOR_ONLY // // MessageText: // // Only the replicator can perform this function. // public static final int ERROR_DS_REPLICATOR_ONLY = 8370; // // MessageId: ERROR_DS_OBJ_CLASS_NOT_DEFINED // // MessageText: // // The specified class is not defined. // public static final int ERROR_DS_OBJ_CLASS_NOT_DEFINED = 8371; // // MessageId: ERROR_DS_OBJ_CLASS_NOT_SUBCLASS // // MessageText: // // The specified class is not a subclass. // public static final int ERROR_DS_OBJ_CLASS_NOT_SUBCLASS = 8372; // // MessageId: ERROR_DS_NAME_REFERENCE_INVALID // // MessageText: // // The name reference is invalid. // public static final int ERROR_DS_NAME_REFERENCE_INVALID = 8373; // // MessageId: ERROR_DS_CROSS_REF_EXISTS // // MessageText: // // A cross reference already exists. // public static final int ERROR_DS_CROSS_REF_EXISTS = 8374; // // MessageId: ERROR_DS_CANT_DEL_MASTER_CROSSREF // // MessageText: // // It is not permitted to delete a master cross reference. // public static final int ERROR_DS_CANT_DEL_MASTER_CROSSREF = 8375; // // MessageId: ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD // // MessageText: // // Subtree notifications are only supported on NC heads. // public static final int ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD = 8376; // // MessageId: ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX // // MessageText: // // Notification filter is too complex. // public static final int ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX = 8377; // // MessageId: ERROR_DS_DUP_RDN // // MessageText: // // Schema update failed: duplicate RDN. // public static final int ERROR_DS_DUP_RDN = 8378; // // MessageId: ERROR_DS_DUP_OID // // MessageText: // // Schema update failed: duplicate OID. // public static final int ERROR_DS_DUP_OID = 8379; // // MessageId: ERROR_DS_DUP_MAPI_ID // // MessageText: // // Schema update failed: duplicate MAPI identifier. // public static final int ERROR_DS_DUP_MAPI_ID = 8380; // // MessageId: ERROR_DS_DUP_SCHEMA_ID_GUID // // MessageText: // // Schema update failed: duplicate schema-id GUID. // public static final int ERROR_DS_DUP_SCHEMA_ID_GUID = 8381; // // MessageId: ERROR_DS_DUP_LDAP_DISPLAY_NAME // // MessageText: // // Schema update failed: duplicate LDAP display name. // public static final int ERROR_DS_DUP_LDAP_DISPLAY_NAME = 8382; // // MessageId: ERROR_DS_SEMANTIC_ATT_TEST // // MessageText: // // Schema update failed: range-lower less than range upper. // public static final int ERROR_DS_SEMANTIC_ATT_TEST = 8383; // // MessageId: ERROR_DS_SYNTAX_MISMATCH // // MessageText: // // Schema update failed: syntax mismatch. // public static final int ERROR_DS_SYNTAX_MISMATCH = 8384; // // MessageId: ERROR_DS_EXISTS_IN_MUST_HAVE // // MessageText: // // Schema deletion failed: attribute is used in must-contain. // public static final int ERROR_DS_EXISTS_IN_MUST_HAVE = 8385; // // MessageId: ERROR_DS_EXISTS_IN_MAY_HAVE // // MessageText: // // Schema deletion failed: attribute is used in may-contain. // public static final int ERROR_DS_EXISTS_IN_MAY_HAVE = 8386; // // MessageId: ERROR_DS_NONEXISTENT_MAY_HAVE // // MessageText: // // Schema update failed: attribute in may-contain does not exist. // public static final int ERROR_DS_NONEXISTENT_MAY_HAVE = 8387; // // MessageId: ERROR_DS_NONEXISTENT_MUST_HAVE // // MessageText: // // Schema update failed: attribute in must-contain does not exist. // public static final int ERROR_DS_NONEXISTENT_MUST_HAVE = 8388; // // MessageId: ERROR_DS_AUX_CLS_TEST_FAIL // // MessageText: // // Schema update failed: class in aux-class list does not exist or is not an // auxiliary class. // public static final int ERROR_DS_AUX_CLS_TEST_FAIL = 8389; // // MessageId: ERROR_DS_NONEXISTENT_POSS_SUP // // MessageText: // // Schema update failed: class in poss-superiors does not exist. // public static final int ERROR_DS_NONEXISTENT_POSS_SUP = 8390; // // MessageId: ERROR_DS_SUB_CLS_TEST_FAIL // // MessageText: // // Schema update failed: class in subclassof list does not exist or does not // satisfy hierarchy rules. // public static final int ERROR_DS_SUB_CLS_TEST_FAIL = 8391; // // MessageId: ERROR_DS_BAD_RDN_ATT_ID_SYNTAX // // MessageText: // // Schema update failed: Rdn-Att-Id has wrong syntax. // public static final int ERROR_DS_BAD_RDN_ATT_ID_SYNTAX = 8392; // // MessageId: ERROR_DS_EXISTS_IN_AUX_CLS // // MessageText: // // Schema deletion failed: class is used as auxiliary class. // public static final int ERROR_DS_EXISTS_IN_AUX_CLS = 8393; // // MessageId: ERROR_DS_EXISTS_IN_SUB_CLS // // MessageText: // // Schema deletion failed: class is used as sub class. // public static final int ERROR_DS_EXISTS_IN_SUB_CLS = 8394; // // MessageId: ERROR_DS_EXISTS_IN_POSS_SUP // // MessageText: // // Schema deletion failed: class is used as poss superior. // public static final int ERROR_DS_EXISTS_IN_POSS_SUP = 8395; // // MessageId: ERROR_DS_RECALCSCHEMA_FAILED // // MessageText: // // Schema update failed in recalculating validation cache. // public static final int ERROR_DS_RECALCSCHEMA_FAILED = 8396; // // MessageId: ERROR_DS_TREE_DELETE_NOT_FINISHED // // MessageText: // // The tree deletion is not finished. The request must be made again to // continue deleting the tree. // public static final int ERROR_DS_TREE_DELETE_NOT_FINISHED = 8397; // // MessageId: ERROR_DS_CANT_DELETE // // MessageText: // // The requested delete operation could not be performed. // public static final int ERROR_DS_CANT_DELETE = 8398; // // MessageId: ERROR_DS_ATT_SCHEMA_REQ_ID // // MessageText: // // Cannot read the governs class identifier for the schema record. // public static final int ERROR_DS_ATT_SCHEMA_REQ_ID = 8399; // // MessageId: ERROR_DS_BAD_ATT_SCHEMA_SYNTAX // // MessageText: // // The attribute schema has bad syntax. // public static final int ERROR_DS_BAD_ATT_SCHEMA_SYNTAX = 8400; // // MessageId: ERROR_DS_CANT_CACHE_ATT // // MessageText: // // The attribute could not be cached. // public static final int ERROR_DS_CANT_CACHE_ATT = 8401; // // MessageId: ERROR_DS_CANT_CACHE_CLASS // // MessageText: // // The class could not be cached. // public static final int ERROR_DS_CANT_CACHE_CLASS = 8402; // // MessageId: ERROR_DS_CANT_REMOVE_ATT_CACHE // // MessageText: // // The attribute could not be removed from the cache. // public static final int ERROR_DS_CANT_REMOVE_ATT_CACHE = 8403; // // MessageId: ERROR_DS_CANT_REMOVE_CLASS_CACHE // // MessageText: // // The class could not be removed from the cache. // public static final int ERROR_DS_CANT_REMOVE_CLASS_CACHE = 8404; // // MessageId: ERROR_DS_CANT_RETRIEVE_DN // // MessageText: // // The distinguished name attribute could not be read. // public static final int ERROR_DS_CANT_RETRIEVE_DN = 8405; // // MessageId: ERROR_DS_MISSING_SUPREF // // MessageText: // // No superior reference has been configured for the directory service. The // directory service is therefore unable to issue referrals to objects // outside this forest. // public static final int ERROR_DS_MISSING_SUPREF = 8406; // // MessageId: ERROR_DS_CANT_RETRIEVE_INSTANCE // // MessageText: // // The instance type attribute could not be retrieved. // public static final int ERROR_DS_CANT_RETRIEVE_INSTANCE = 8407; // // MessageId: ERROR_DS_CODE_INCONSISTENCY // // MessageText: // // An internal error has occurred. // public static final int ERROR_DS_CODE_INCONSISTENCY = 8408; // // MessageId: ERROR_DS_DATABASE_ERROR // // MessageText: // // A database error has occurred. // public static final int ERROR_DS_DATABASE_ERROR = 8409; // // MessageId: ERROR_DS_GOVERNSID_MISSING // // MessageText: // // The attribute GOVERNSID is missing. // public static final int ERROR_DS_GOVERNSID_MISSING = 8410; // // MessageId: ERROR_DS_MISSING_EXPECTED_ATT // // MessageText: // // An expected attribute is missing. // public static final int ERROR_DS_MISSING_EXPECTED_ATT = 8411; // // MessageId: ERROR_DS_NCNAME_MISSING_CR_REF // // MessageText: // // The specified naming context is missing a cross reference. // public static final int ERROR_DS_NCNAME_MISSING_CR_REF = 8412; // // MessageId: ERROR_DS_SECURITY_CHECKING_ERROR // // MessageText: // // A security checking error has occurred. // public static final int ERROR_DS_SECURITY_CHECKING_ERROR = 8413; // // MessageId: ERROR_DS_SCHEMA_NOT_LOADED // // MessageText: // // The schema is not loaded. // public static final int ERROR_DS_SCHEMA_NOT_LOADED = 8414; // // MessageId: ERROR_DS_SCHEMA_ALLOC_FAILED // // MessageText: // // Schema allocation failed. Please check if the machine is running low on // memory. // public static final int ERROR_DS_SCHEMA_ALLOC_FAILED = 8415; // // MessageId: ERROR_DS_ATT_SCHEMA_REQ_SYNTAX // // MessageText: // // Failed to obtain the required syntax for the attribute schema. // public static final int ERROR_DS_ATT_SCHEMA_REQ_SYNTAX = 8416; // // MessageId: ERROR_DS_GCVERIFY_ERROR // // MessageText: // // The global catalog verification failed. The global catalog is not // available or does not support the operation. Some part of the directory // is currently not available. // public static final int ERROR_DS_GCVERIFY_ERROR = 8417; // // MessageId: ERROR_DS_DRA_SCHEMA_MISMATCH // // MessageText: // // The replication operation failed because of a schema mismatch between the // servers involved. // public static final int ERROR_DS_DRA_SCHEMA_MISMATCH = 8418; // // MessageId: ERROR_DS_CANT_FIND_DSA_OBJ // // MessageText: // // The DSA object could not be found. // public static final int ERROR_DS_CANT_FIND_DSA_OBJ = 8419; // // MessageId: ERROR_DS_CANT_FIND_EXPECTED_NC // // MessageText: // // The naming context could not be found. // public static final int ERROR_DS_CANT_FIND_EXPECTED_NC = 8420; // // MessageId: ERROR_DS_CANT_FIND_NC_IN_CACHE // // MessageText: // // The naming context could not be found in the cache. // public static final int ERROR_DS_CANT_FIND_NC_IN_CACHE = 8421; // // MessageId: ERROR_DS_CANT_RETRIEVE_CHILD // // MessageText: // // The child object could not be retrieved. // public static final int ERROR_DS_CANT_RETRIEVE_CHILD = 8422; // // MessageId: ERROR_DS_SECURITY_ILLEGAL_MODIFY // // MessageText: // // The modification was not permitted for security reasons. // public static final int ERROR_DS_SECURITY_ILLEGAL_MODIFY = 8423; // // MessageId: ERROR_DS_CANT_REPLACE_HIDDEN_REC // // MessageText: // // The operation cannot replace the hidden record. // public static final int ERROR_DS_CANT_REPLACE_HIDDEN_REC = 8424; // // MessageId: ERROR_DS_BAD_HIERARCHY_FILE // // MessageText: // // The hierarchy file is invalid. // public static final int ERROR_DS_BAD_HIERARCHY_FILE = 8425; // // MessageId: ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED // // MessageText: // // The attempt to build the hierarchy table failed. // public static final int ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED = 8426; // // MessageId: ERROR_DS_CONFIG_PARAM_MISSING // // MessageText: // // The directory configuration parameter is missing from the registry. // public static final int ERROR_DS_CONFIG_PARAM_MISSING = 8427; // // MessageId: ERROR_DS_COUNTING_AB_INDICES_FAILED // // MessageText: // // The attempt to count the address book indices failed. // public static final int ERROR_DS_COUNTING_AB_INDICES_FAILED = 8428; // // MessageId: ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED // // MessageText: // // The allocation of the hierarchy table failed. // public static final int ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED = 8429; // // MessageId: ERROR_DS_INTERNAL_FAILURE // // MessageText: // // The directory service encountered an internal failure. // public static final int ERROR_DS_INTERNAL_FAILURE = 8430; // // MessageId: ERROR_DS_UNKNOWN_ERROR // // MessageText: // // The directory service encountered an unknown failure. // public static final int ERROR_DS_UNKNOWN_ERROR = 8431; // // MessageId: ERROR_DS_ROOT_REQUIRES_CLASS_TOP // // MessageText: // // A root object requires a class of 'top'. // public static final int ERROR_DS_ROOT_REQUIRES_CLASS_TOP = 8432; // // MessageId: ERROR_DS_REFUSING_FSMO_ROLES // // MessageText: // // This directory server is shutting down, and cannot take ownership of new // floating single-master operation roles. // public static final int ERROR_DS_REFUSING_FSMO_ROLES = 8433; // // MessageId: ERROR_DS_MISSING_FSMO_SETTINGS // // MessageText: // // The directory service is missing mandatory configuration information, and // is unable to determine the ownership of floating single-master operation // roles. // public static final int ERROR_DS_MISSING_FSMO_SETTINGS = 8434; // // MessageId: ERROR_DS_UNABLE_TO_SURRENDER_ROLES // // MessageText: // // The directory service was unable to transfer ownership of one or more // floating single-master operation roles to other servers. // public static final int ERROR_DS_UNABLE_TO_SURRENDER_ROLES = 8435; // // MessageId: ERROR_DS_DRA_GENERIC // // MessageText: // // The replication operation failed. // public static final int ERROR_DS_DRA_GENERIC = 8436; // // MessageId: ERROR_DS_DRA_INVALID_PARAMETER // // MessageText: // // An invalid parameter was specified for this replication operation. // public static final int ERROR_DS_DRA_INVALID_PARAMETER = 8437; // // MessageId: ERROR_DS_DRA_BUSY // // MessageText: // // The directory service is too busy to complete the replication operation // at this time. // public static final int ERROR_DS_DRA_BUSY = 8438; // // MessageId: ERROR_DS_DRA_BAD_DN // // MessageText: // // The distinguished name specified for this replication operation is // invalid. // public static final int ERROR_DS_DRA_BAD_DN = 8439; // // MessageId: ERROR_DS_DRA_BAD_NC // // MessageText: // // The naming context specified for this replication operation is invalid. // public static final int ERROR_DS_DRA_BAD_NC = 8440; // // MessageId: ERROR_DS_DRA_DN_EXISTS // // MessageText: // // The distinguished name specified for this replication operation already // exists. // public static final int ERROR_DS_DRA_DN_EXISTS = 8441; // // MessageId: ERROR_DS_DRA_INTERNAL_ERROR // // MessageText: // // The replication system encountered an internal error. // public static final int ERROR_DS_DRA_INTERNAL_ERROR = 8442; // // MessageId: ERROR_DS_DRA_INCONSISTENT_DIT // // MessageText: // // The replication operation encountered a database inconsistency. // public static final int ERROR_DS_DRA_INCONSISTENT_DIT = 8443; // // MessageId: ERROR_DS_DRA_CONNECTION_FAILED // // MessageText: // // The server specified for this replication operation could not be // contacted. // public static final int ERROR_DS_DRA_CONNECTION_FAILED = 8444; // // MessageId: ERROR_DS_DRA_BAD_INSTANCE_TYPE // // MessageText: // // The replication operation encountered an object with an invalid instance // type. // public static final int ERROR_DS_DRA_BAD_INSTANCE_TYPE = 8445; // // MessageId: ERROR_DS_DRA_OUT_OF_MEM // // MessageText: // // The replication operation failed to allocate memory. // public static final int ERROR_DS_DRA_OUT_OF_MEM = 8446; // // MessageId: ERROR_DS_DRA_MAIL_PROBLEM // // MessageText: // // The replication operation encountered an error with the mail system. // public static final int ERROR_DS_DRA_MAIL_PROBLEM = 8447; // // MessageId: ERROR_DS_DRA_REF_ALREADY_EXISTS // // MessageText: // // The replication reference information for the target server already // exists. // public static final int ERROR_DS_DRA_REF_ALREADY_EXISTS = 8448; // // MessageId: ERROR_DS_DRA_REF_NOT_FOUND // // MessageText: // // The replication reference information for the target server does not // exist. // public static final int ERROR_DS_DRA_REF_NOT_FOUND = 8449; // // MessageId: ERROR_DS_DRA_OBJ_IS_REP_SOURCE // // MessageText: // // The naming context cannot be removed because it is replicated to another // server. // public static final int ERROR_DS_DRA_OBJ_IS_REP_SOURCE = 8450; // // MessageId: ERROR_DS_DRA_DB_ERROR // // MessageText: // // The replication operation encountered a database error. // public static final int ERROR_DS_DRA_DB_ERROR = 8451; // // MessageId: ERROR_DS_DRA_NO_REPLICA // // MessageText: // // The naming context is in the process of being removed or is not // replicated from the specified server. // public static final int ERROR_DS_DRA_NO_REPLICA = 8452; // // MessageId: ERROR_DS_DRA_ACCESS_DENIED // // MessageText: // // Replication access was denied. // public static final int ERROR_DS_DRA_ACCESS_DENIED = 8453; // // MessageId: ERROR_DS_DRA_NOT_SUPPORTED // // MessageText: // // The requested operation is not supported by this version of the directory // service. // public static final int ERROR_DS_DRA_NOT_SUPPORTED = 8454; // // MessageId: ERROR_DS_DRA_RPC_CANCELLED // // MessageText: // // The replication remote procedure call was cancelled. // public static final int ERROR_DS_DRA_RPC_CANCELLED = 8455; // // MessageId: ERROR_DS_DRA_SOURCE_DISABLED // // MessageText: // // The source server is currently rejecting replication requests. // public static final int ERROR_DS_DRA_SOURCE_DISABLED = 8456; // // MessageId: ERROR_DS_DRA_SINK_DISABLED // // MessageText: // // The destination server is currently rejecting replication requests. // public static final int ERROR_DS_DRA_SINK_DISABLED = 8457; // // MessageId: ERROR_DS_DRA_NAME_COLLISION // // MessageText: // // The replication operation failed due to a collision of object names. // public static final int ERROR_DS_DRA_NAME_COLLISION = 8458; // // MessageId: ERROR_DS_DRA_SOURCE_REINSTALLED // // MessageText: // // The replication source has been reinstalled. // public static final int ERROR_DS_DRA_SOURCE_REINSTALLED = 8459; // // MessageId: ERROR_DS_DRA_MISSING_PARENT // // MessageText: // // The replication operation failed because a required parent object is // missing. // public static final int ERROR_DS_DRA_MISSING_PARENT = 8460; // // MessageId: ERROR_DS_DRA_PREEMPTED // // MessageText: // // The replication operation was preempted. // public static final int ERROR_DS_DRA_PREEMPTED = 8461; // // MessageId: ERROR_DS_DRA_ABANDON_SYNC // // MessageText: // // The replication synchronization attempt was abandoned because of a lack // of updates. // public static final int ERROR_DS_DRA_ABANDON_SYNC = 8462; // // MessageId: ERROR_DS_DRA_SHUTDOWN // // MessageText: // // The replication operation was terminated because the system is shutting // down. // public static final int ERROR_DS_DRA_SHUTDOWN = 8463; // // MessageId: ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET // // MessageText: // // Synchronization attempt failed because the destination DC is currently // waiting to synchronize new partial attributes from source. This condition // is normal if a recent schema change modified the partial attribute set. // The destination partial attribute set is not a subset of source partial // attribute set. // public static final int ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET = 8464; // // MessageId: ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA // // MessageText: // // The replication synchronization attempt failed because a master replica // attempted to sync from a partial replica. // public static final int ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA = 8465; // // MessageId: ERROR_DS_DRA_EXTN_CONNECTION_FAILED // // MessageText: // // The server specified for this replication operation was contacted, but // that server was unable to contact an additional server needed to complete // the operation. // public static final int ERROR_DS_DRA_EXTN_CONNECTION_FAILED = 8466; // // MessageId: ERROR_DS_INSTALL_SCHEMA_MISMATCH // // MessageText: // // The version of the directory service schema of the source forest is not // compatible with the version of directory service on this computer. // public static final int ERROR_DS_INSTALL_SCHEMA_MISMATCH = 8467; // // MessageId: ERROR_DS_DUP_LINK_ID // // MessageText: // // Schema update failed: An attribute with the same link identifier already // exists. // public static final int ERROR_DS_DUP_LINK_ID = 8468; // // MessageId: ERROR_DS_NAME_ERROR_RESOLVING // // MessageText: // // Name translation: Generic processing error. // public static final int ERROR_DS_NAME_ERROR_RESOLVING = 8469; // // MessageId: ERROR_DS_NAME_ERROR_NOT_FOUND // // MessageText: // // Name translation: Could not find the name or insufficient right to see // name. // public static final int ERROR_DS_NAME_ERROR_NOT_FOUND = 8470; // // MessageId: ERROR_DS_NAME_ERROR_NOT_UNIQUE // // MessageText: // // Name translation: Input name mapped to more than one output name. // public static final int ERROR_DS_NAME_ERROR_NOT_UNIQUE = 8471; // // MessageId: ERROR_DS_NAME_ERROR_NO_MAPPING // // MessageText: // // Name translation: Input name found, but not the associated output format. // public static final int ERROR_DS_NAME_ERROR_NO_MAPPING = 8472; // // MessageId: ERROR_DS_NAME_ERROR_DOMAIN_ONLY // // MessageText: // // Name translation: Unable to resolve completely, only the domain was // found. // public static final int ERROR_DS_NAME_ERROR_DOMAIN_ONLY = 8473; // // MessageId: ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING // // MessageText: // // Name translation: Unable to perform purely syntactical mapping at the // client without going out to the wire. // public static final int ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING = 8474; // // MessageId: ERROR_DS_CONSTRUCTED_ATT_MOD // // MessageText: // // Modification of a constructed attribute is not allowed. // public static final int ERROR_DS_CONSTRUCTED_ATT_MOD = 8475; // // MessageId: ERROR_DS_WRONG_OM_OBJ_CLASS // // MessageText: // // The OM-Object-Class specified is incorrect for an attribute with the // specified syntax. // public static final int ERROR_DS_WRONG_OM_OBJ_CLASS = 8476; // // MessageId: ERROR_DS_DRA_REPL_PENDING // // MessageText: // // The replication request has been posted; waiting for reply. // public static final int ERROR_DS_DRA_REPL_PENDING = 8477; // // MessageId: ERROR_DS_DS_REQUIRED // // MessageText: // // The requested operation requires a directory service, and none was // available. // public static final int ERROR_DS_DS_REQUIRED = 8478; // // MessageId: ERROR_DS_INVALID_LDAP_DISPLAY_NAME // // MessageText: // // The LDAP display name of the class or attribute contains non-ASCII // characters. // public static final int ERROR_DS_INVALID_LDAP_DISPLAY_NAME = 8479; // // MessageId: ERROR_DS_NON_BASE_SEARCH // // MessageText: // // The requested search operation is only supported for base searches. // public static final int ERROR_DS_NON_BASE_SEARCH = 8480; // // MessageId: ERROR_DS_CANT_RETRIEVE_ATTS // // MessageText: // // The search failed to retrieve attributes from the database. // public static final int ERROR_DS_CANT_RETRIEVE_ATTS = 8481; // // MessageId: ERROR_DS_BACKLINK_WITHOUT_LINK // // MessageText: // // The schema update operation tried to add a backward link attribute that // has no corresponding forward link. // public static final int ERROR_DS_BACKLINK_WITHOUT_LINK = 8482; // // MessageId: ERROR_DS_EPOCH_MISMATCH // // MessageText: // // Source and destination of a cross-domain move do not agree on the // object's epoch number. Either source or destination does not have the // latest version of the object. // public static final int ERROR_DS_EPOCH_MISMATCH = 8483; // // MessageId: ERROR_DS_SRC_NAME_MISMATCH // // MessageText: // // Source and destination of a cross-domain move do not agree on the // object's current name. Either source or destination does not have the // latest version of the object. // public static final int ERROR_DS_SRC_NAME_MISMATCH = 8484; // // MessageId: ERROR_DS_SRC_AND_DST_NC_IDENTICAL // // MessageText: // // Source and destination for the cross-domain move operation are identical. // Caller should use local move operation instead of cross-domain move // operation. // public static final int ERROR_DS_SRC_AND_DST_NC_IDENTICAL = 8485; // // MessageId: ERROR_DS_DST_NC_MISMATCH // // MessageText: // // Source and destination for a cross-domain move are not in agreement on // the naming contexts in the forest. Either source or destination does not // have the latest version of the Partitions container. // public static final int ERROR_DS_DST_NC_MISMATCH = 8486; // // MessageId: ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC // // MessageText: // // Destination of a cross-domain move is not authoritative for the // destination naming context. // public static final int ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC = 8487; // // MessageId: ERROR_DS_SRC_GUID_MISMATCH // // MessageText: // // Source and destination of a cross-domain move do not agree on the // identity of the source object. Either source or destination does not have // the latest version of the source object. // public static final int ERROR_DS_SRC_GUID_MISMATCH = 8488; // // MessageId: ERROR_DS_CANT_MOVE_DELETED_OBJECT // // MessageText: // // Object being moved across-domains is already known to be deleted by the // destination server. The source server does not have the latest version of // the source object. // public static final int ERROR_DS_CANT_MOVE_DELETED_OBJECT = 8489; // // MessageId: ERROR_DS_PDC_OPERATION_IN_PROGRESS // // MessageText: // // Another operation which requires exclusive access to the PDC FSMO is // already in progress. // public static final int ERROR_DS_PDC_OPERATION_IN_PROGRESS = 8490; // // MessageId: ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD // // MessageText: // // A cross-domain move operation failed such that two versions of the moved // object exist - one each in the source and destination domains. The // destination object needs to be removed to restore the system to a // consistent state. // public static final int ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD = 8491; // // MessageId: ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION // // MessageText: // // This object may not be moved across domain boundaries either because // cross-domain moves for this class are disallowed, or the object has some // special characteristics, e.g.: trust account or restricted RID, which // prevent its move. // public static final int ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION = 8492; // // MessageId: ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS // // MessageText: // // Can't move objects with memberships across domain boundaries as once // moved, this would violate the membership conditions of the account group. // Remove the object from any account group memberships and retry. // public static final int ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS = 8493; // // MessageId: ERROR_DS_NC_MUST_HAVE_NC_PARENT // // MessageText: // // A naming context head must be the immediate child of another naming // context head, not of an interior node. // public static final int ERROR_DS_NC_MUST_HAVE_NC_PARENT = 8494; // // MessageId: ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE // // MessageText: // // The directory cannot validate the proposed naming context name because it // does not hold a replica of the naming context above the proposed naming // context. Please ensure that the domain naming master role is held by a // server that is configured as a global catalog server, and that the server // is up to date with its replication partners. (Applies only to // Windows=2000 Domain Naming masters) // public static final int ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE = 8495; // // MessageId: ERROR_DS_DST_DOMAIN_NOT_NATIVE // // MessageText: // // Destination domain must be in native mode. // public static final int ERROR_DS_DST_DOMAIN_NOT_NATIVE = 8496; // // MessageId: ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER // // MessageText: // // The operation cannot be performed because the server does not have an // infrastructure container in the domain of interest. // public static final int ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER = 8497; // // MessageId: ERROR_DS_CANT_MOVE_ACCOUNT_GROUP // // MessageText: // // Cross-domain move of non-empty account groups is not allowed. // public static final int ERROR_DS_CANT_MOVE_ACCOUNT_GROUP = 8498; // // MessageId: ERROR_DS_CANT_MOVE_RESOURCE_GROUP // // MessageText: // // Cross-domain move of non-empty resource groups is not allowed. // public static final int ERROR_DS_CANT_MOVE_RESOURCE_GROUP = 8499; // // MessageId: ERROR_DS_INVALID_SEARCH_FLAG // // MessageText: // // The search flags for the attribute are invalid. The ANR bit is valid only // on attributes of Unicode or Teletex strings. // public static final int ERROR_DS_INVALID_SEARCH_FLAG = 8500; // // MessageId: ERROR_DS_NO_TREE_DELETE_ABOVE_NC // // MessageText: // // Tree deletions starting at an object which has an NC head as a descendant // are not allowed. // public static final int ERROR_DS_NO_TREE_DELETE_ABOVE_NC = 8501; // // MessageId: ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE // // MessageText: // // The directory service failed to lock a tree in preparation for a tree // deletion because the tree was in use. // public static final int ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE = 8502; // // MessageId: ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE // // MessageText: // // The directory service failed to identify the list of objects to delete // while attempting a tree deletion. // public static final int ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE = 8503; // // MessageId: ERROR_DS_SAM_INIT_FAILURE // // MessageText: // // Security Accounts Manager initialization failed because of the following // error: %1. // Error Status: 0x%2. Click OK to shut down the system and reboot into // Directory Services Restore Mode. Check the event log for detailed // information. // public static final int ERROR_DS_SAM_INIT_FAILURE = 8504; // // MessageId: ERROR_DS_SENSITIVE_GROUP_VIOLATION // // MessageText: // // Only an administrator can modify the membership list of an administrative // group. // public static final int ERROR_DS_SENSITIVE_GROUP_VIOLATION = 8505; // // MessageId: ERROR_DS_CANT_MOD_PRIMARYGROUPID // // MessageText: // // Cannot change the primary group ID of a domain controller account. // public static final int ERROR_DS_CANT_MOD_PRIMARYGROUPID = 8506; // // MessageId: ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD // // MessageText: // // An attempt is made to modify the base schema. // public static final int ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD = 8507; // // MessageId: ERROR_DS_NONSAFE_SCHEMA_CHANGE // // MessageText: // // Adding a new mandatory attribute to an existing class, deleting a // mandatory attribute from an existing class, or adding an optional // attribute to the special class Top that is not a backlink attribute // (directly or through inheritance, for example, by adding or deleting an // auxiliary class) is not allowed. // public static final int ERROR_DS_NONSAFE_SCHEMA_CHANGE = 8508; // // MessageId: ERROR_DS_SCHEMA_UPDATE_DISALLOWED // // MessageText: // // Schema update is not allowed on this DC because the DC is not the schema // FSMO Role Owner. // public static final int ERROR_DS_SCHEMA_UPDATE_DISALLOWED = 8509; // // MessageId: ERROR_DS_CANT_CREATE_UNDER_SCHEMA // // MessageText: // // An object of this class cannot be created under the schema container. You // can only create attribute-schema and class-schema objects under the // schema container. // public static final int ERROR_DS_CANT_CREATE_UNDER_SCHEMA = 8510; // // MessageId: ERROR_DS_INSTALL_NO_SRC_SCH_VERSION // // MessageText: // // The replica/child install failed to get the objectVersion attribute on // the schema container on the source DC. Either the attribute is missing on // the schema container or the credentials supplied do not have permission // to read it. // public static final int ERROR_DS_INSTALL_NO_SRC_SCH_VERSION = 8511; // // MessageId: ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE // // MessageText: // // The replica/child install failed to read the objectVersion attribute in // the SCHEMA section of the file schema.ini in the system32 directory. // public static final int ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE = 8512; // // MessageId: ERROR_DS_INVALID_GROUP_TYPE // // MessageText: // // The specified group type is invalid. // public static final int ERROR_DS_INVALID_GROUP_TYPE = 8513; // // MessageId: ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN // // MessageText: // // You cannot nest global groups in a mixed domain if the group is // security-enabled. // public static final int ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN = 8514; // // MessageId: ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN // // MessageText: // // You cannot nest local groups in a mixed domain if the group is // security-enabled. // public static final int ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN = 8515; // // MessageId: ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER // // MessageText: // // A global group cannot have a local group as a member. // public static final int ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER = 8516; // // MessageId: ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER // // MessageText: // // A global group cannot have a universal group as a member. // public static final int ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER = 8517; // // MessageId: ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER // // MessageText: // // A universal group cannot have a local group as a member. // public static final int ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER = 8518; // // MessageId: ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER // // MessageText: // // A global group cannot have a cross-domain member. // public static final int ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER = 8519; // // MessageId: ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER // // MessageText: // // A local group cannot have another cross domain local group as a member. // public static final int ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER = 8520; // // MessageId: ERROR_DS_HAVE_PRIMARY_MEMBERS // // MessageText: // // A group with primary members cannot change to a security-disabled group. // public static final int ERROR_DS_HAVE_PRIMARY_MEMBERS = 8521; // // MessageId: ERROR_DS_STRING_SD_CONVERSION_FAILED // // MessageText: // // The schema cache load failed to convert the string default SD on a // class-schema object. // public static final int ERROR_DS_STRING_SD_CONVERSION_FAILED = 8522; // // MessageId: ERROR_DS_NAMING_MASTER_GC // // MessageText: // // Only DSAs configured to be Global Catalog servers should be allowed to // hold the Domain Naming Master FSMO role. (Applies only to Windows=2000 // servers) // public static final int ERROR_DS_NAMING_MASTER_GC = 8523; // // MessageId: ERROR_DS_DNS_LOOKUP_FAILURE // // MessageText: // // The DSA operation is unable to proceed because of a DNS lookup failure. // public static final int ERROR_DS_DNS_LOOKUP_FAILURE = 8524; // // MessageId: ERROR_DS_COULDNT_UPDATE_SPNS // // MessageText: // // While processing a change to the DNS Host Name for an object, the Service // Principal Name values could not be kept in sync. // public static final int ERROR_DS_COULDNT_UPDATE_SPNS = 8525; // // MessageId: ERROR_DS_CANT_RETRIEVE_SD // // MessageText: // // The Security Descriptor attribute could not be read. // public static final int ERROR_DS_CANT_RETRIEVE_SD = 8526; // // MessageId: ERROR_DS_KEY_NOT_UNIQUE // // MessageText: // // The object requested was not found, but an object with that key was // found. // public static final int ERROR_DS_KEY_NOT_UNIQUE = 8527; // // MessageId: ERROR_DS_WRONG_LINKED_ATT_SYNTAX // // MessageText: // // The syntax of the linked attribute being added is incorrect. Forward // links can only have syntax=2.5.5.1,=2.5.5.7, and=2.5.5.14, and backlinks // can only have syntax=2.5.5.1 // public static final int ERROR_DS_WRONG_LINKED_ATT_SYNTAX = 8528; // // MessageId: ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD // // MessageText: // // Security Account Manager needs to get the boot password. // public static final int ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD = 8529; // // MessageId: ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY // // MessageText: // // Security Account Manager needs to get the boot key from floppy disk. // public static final int ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY = 8530; // // MessageId: ERROR_DS_CANT_START // // MessageText: // // Directory Service cannot start. // public static final int ERROR_DS_CANT_START = 8531; // // MessageId: ERROR_DS_INIT_FAILURE // // MessageText: // // Directory Services could not start. // public static final int ERROR_DS_INIT_FAILURE = 8532; // // MessageId: ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION // // MessageText: // // The connection between client and server requires packet privacy or // better. // public static final int ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION = 8533; // // MessageId: ERROR_DS_SOURCE_DOMAIN_IN_FOREST // // MessageText: // // The source domain may not be in the same forest as destination. // public static final int ERROR_DS_SOURCE_DOMAIN_IN_FOREST = 8534; // // MessageId: ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST // // MessageText: // // The destination domain must be in the forest. // public static final int ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST = 8535; // // MessageId: ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED // // MessageText: // // The operation requires that destination domain auditing be enabled. // public static final int ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED = 8536; // // MessageId: ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN // // MessageText: // // The operation couldn't locate a DC for the source domain. // public static final int ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN = 8537; // // MessageId: ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER // // MessageText: // // The source object must be a group or user. // public static final int ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER = 8538; // // MessageId: ERROR_DS_SRC_SID_EXISTS_IN_FOREST // // MessageText: // // The source object's SID already exists in destination forest. // public static final int ERROR_DS_SRC_SID_EXISTS_IN_FOREST = 8539; // // MessageId: ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH // // MessageText: // // The source and destination object must be of the same type. // public static final int ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH = 8540; // // MessageId: ERROR_SAM_INIT_FAILURE // // MessageText: // // Security Accounts Manager initialization failed because of the following // error: %1. // Error Status: 0x%2. Click OK to shut down the system and reboot into Safe // Mode. Check the event log for detailed information. // public static final int ERROR_SAM_INIT_FAILURE = 8541; // // MessageId: ERROR_DS_DRA_SCHEMA_INFO_SHIP // // MessageText: // // Schema information could not be included in the replication request. // public static final int ERROR_DS_DRA_SCHEMA_INFO_SHIP = 8542; // // MessageId: ERROR_DS_DRA_SCHEMA_CONFLICT // // MessageText: // // The replication operation could not be completed due to a schema // incompatibility. // public static final int ERROR_DS_DRA_SCHEMA_CONFLICT = 8543; // // MessageId: ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT // // MessageText: // // The replication operation could not be completed due to a previous schema // incompatibility. // public static final int ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT = 8544; // // MessageId: ERROR_DS_DRA_OBJ_NC_MISMATCH // // MessageText: // // The replication update could not be applied because either the source or // the destination has not yet received information regarding a recent // cross-domain move operation. // public static final int ERROR_DS_DRA_OBJ_NC_MISMATCH = 8545; // // MessageId: ERROR_DS_NC_STILL_HAS_DSAS // // MessageText: // // The requested domain could not be deleted because there exist domain // controllers that still host this domain. // public static final int ERROR_DS_NC_STILL_HAS_DSAS = 8546; // // MessageId: ERROR_DS_GC_REQUIRED // // MessageText: // // The requested operation can be performed only on a global catalog server. // public static final int ERROR_DS_GC_REQUIRED = 8547; // // MessageId: ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY // // MessageText: // // A local group can only be a member of other local groups in the same // domain. // public static final int ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY = 8548; // // MessageId: ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS // // MessageText: // // Foreign security principals cannot be members of universal groups. // public static final int ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS = 8549; // // MessageId: ERROR_DS_CANT_ADD_TO_GC // // MessageText: // // The attribute is not allowed to be replicated to the GC because of // security reasons. // public static final int ERROR_DS_CANT_ADD_TO_GC = 8550; // // MessageId: ERROR_DS_NO_CHECKPOINT_WITH_PDC // // MessageText: // // The checkpoint with the PDC could not be taken because there too many // modifications being processed currently. // public static final int ERROR_DS_NO_CHECKPOINT_WITH_PDC = 8551; // // MessageId: ERROR_DS_SOURCE_AUDITING_NOT_ENABLED // // MessageText: // // The operation requires that source domain auditing be enabled. // public static final int ERROR_DS_SOURCE_AUDITING_NOT_ENABLED = 8552; // // MessageId: ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC // // MessageText: // // Security principal objects can only be created inside domain naming // contexts. // public static final int ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC = 8553; // // MessageId: ERROR_DS_INVALID_NAME_FOR_SPN // // MessageText: // // A Service Principal Name (SPN) could not be constructed because the // provided hostname is not in the necessary format. // public static final int ERROR_DS_INVALID_NAME_FOR_SPN = 8554; // // MessageId: ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS // // MessageText: // // A Filter was passed that uses constructed attributes. // public static final int ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS = 8555; // // MessageId: ERROR_DS_UNICODEPWD_NOT_IN_QUOTES // // MessageText: // // The unicodePwd attribute value must be enclosed in double quotes. // public static final int ERROR_DS_UNICODEPWD_NOT_IN_QUOTES = 8556; // // MessageId: ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED // // MessageText: // // Your computer could not be joined to the domain. You have exceeded the // maximum number of computer accounts you are allowed to create in this // domain. Contact your system administrator to have this limit reset or // increased. // public static final int ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED = 8557; // // MessageId: ERROR_DS_MUST_BE_RUN_ON_DST_DC // // MessageText: // // For security reasons, the operation must be run on the destination DC. // public static final int ERROR_DS_MUST_BE_RUN_ON_DST_DC = 8558; // // MessageId: ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER // // MessageText: // // For security reasons, the source DC must be NT4SP4 or greater. // public static final int ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER = 8559; // // MessageId: ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ // // MessageText: // // Critical Directory Service System objects cannot be deleted during tree // delete operations. The tree delete may have been partially performed. // public static final int ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ = 8560; // // MessageId: ERROR_DS_INIT_FAILURE_CONSOLE // // MessageText: // // Directory Services could not start because of the following error: %1. // Error Status: 0x%2. Please click OK to shutdown the system. You can use // the recovery console to diagnose the system further. // public static final int ERROR_DS_INIT_FAILURE_CONSOLE = 8561; // // MessageId: ERROR_DS_SAM_INIT_FAILURE_CONSOLE // // MessageText: // // Security Accounts Manager initialization failed because of the following // error: %1. // Error Status: 0x%2. Please click OK to shutdown the system. You can use // the recovery console to diagnose the system further. // public static final int ERROR_DS_SAM_INIT_FAILURE_CONSOLE = 8562; // // MessageId: ERROR_DS_FOREST_VERSION_TOO_HIGH // // MessageText: // // The version of the operating system installed is incompatible with the // current forest functional level. You must upgrade to a new version of the // operating system before this server can become a domain controller in // this forest. // public static final int ERROR_DS_FOREST_VERSION_TOO_HIGH = 8563; // // MessageId: ERROR_DS_DOMAIN_VERSION_TOO_HIGH // // MessageText: // // The version of the operating system installed is incompatible with the // current domain functional level. You must upgrade to a new version of the // operating system before this server can become a domain controller in // this domain. // public static final int ERROR_DS_DOMAIN_VERSION_TOO_HIGH = 8564; // // MessageId: ERROR_DS_FOREST_VERSION_TOO_LOW // // MessageText: // // The version of the operating system installed on this server no longer // supports the current forest functional level. You must raise the forest // functional level before this server can become a domain controller in // this forest. // public static final int ERROR_DS_FOREST_VERSION_TOO_LOW = 8565; // // MessageId: ERROR_DS_DOMAIN_VERSION_TOO_LOW // // MessageText: // // The version of the operating system installed on this server no longer // supports the current domain functional level. You must raise the domain // functional level before this server can become a domain controller in // this domain. // public static final int ERROR_DS_DOMAIN_VERSION_TOO_LOW = 8566; // // MessageId: ERROR_DS_INCOMPATIBLE_VERSION // // MessageText: // // The version of the operating system installed on this server is // incompatible with the functional level of the domain or forest. // public static final int ERROR_DS_INCOMPATIBLE_VERSION = 8567; // // MessageId: ERROR_DS_LOW_DSA_VERSION // // MessageText: // // The functional level of the domain (or forest) cannot be raised to the // requested value, because there exist one or more domain controllers in // the domain (or forest) that are at a lower incompatible functional level. // public static final int ERROR_DS_LOW_DSA_VERSION = 8568; // // MessageId: ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN // // MessageText: // // The forest functional level cannot be raised to the requested value since // one or more domains are still in mixed domain mode. All domains in the // forest must be in native mode, for you to raise the forest functional // level. // public static final int ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN = 8569; // // MessageId: ERROR_DS_NOT_SUPPORTED_SORT_ORDER // // MessageText: // // The sort order requested is not supported. // public static final int ERROR_DS_NOT_SUPPORTED_SORT_ORDER = 8570; // // MessageId: ERROR_DS_NAME_NOT_UNIQUE // // MessageText: // // The requested name already exists as a unique identifier. // public static final int ERROR_DS_NAME_NOT_UNIQUE = 8571; // // MessageId: ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4 // // MessageText: // // The machine account was created pre-NT4. The account needs to be // recreated. // public static final int ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4 = 8572; // // MessageId: ERROR_DS_OUT_OF_VERSION_STORE // // MessageText: // // The database is out of version store. // public static final int ERROR_DS_OUT_OF_VERSION_STORE = 8573; // // MessageId: ERROR_DS_INCOMPATIBLE_CONTROLS_USED // // MessageText: // // Unable to continue operation because multiple conflicting controls were // used. // public static final int ERROR_DS_INCOMPATIBLE_CONTROLS_USED = 8574; // // MessageId: ERROR_DS_NO_REF_DOMAIN // // MessageText: // // Unable to find a valid security descriptor reference domain for this // partition. // public static final int ERROR_DS_NO_REF_DOMAIN = 8575; // // MessageId: ERROR_DS_RESERVED_LINK_ID // // MessageText: // // Schema update failed: The link identifier is reserved. // public static final int ERROR_DS_RESERVED_LINK_ID = 8576; // // MessageId: ERROR_DS_LINK_ID_NOT_AVAILABLE // // MessageText: // // Schema update failed: There are no link identifiers available. // public static final int ERROR_DS_LINK_ID_NOT_AVAILABLE = 8577; // // MessageId: ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER // // MessageText: // // An account group cannot have a universal group as a member. // public static final int ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER = 8578; // // MessageId: ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE // // MessageText: // // Rename or move operations on naming context heads or read-only objects // are not allowed. // public static final int ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE = 8579; // // MessageId: ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC // // MessageText: // // Move operations on objects in the schema naming context are not allowed. // public static final int ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC = 8580; // // MessageId: ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG // // MessageText: // // A system flag has been set on the object and does not allow the object to // be moved or renamed. // public static final int ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG = 8581; // // MessageId: ERROR_DS_MODIFYDN_WRONG_GRANDPARENT // // MessageText: // // This object is not allowed to change its grandparent container. Moves are // not forbidden on this object, but are restricted to sibling containers. // public static final int ERROR_DS_MODIFYDN_WRONG_GRANDPARENT = 8582; // // MessageId: ERROR_DS_NAME_ERROR_TRUST_REFERRAL // // MessageText: // // Unable to resolve completely, a referral to another forest is generated. // public static final int ERROR_DS_NAME_ERROR_TRUST_REFERRAL = 8583; // // MessageId: ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER // // MessageText: // // The requested action is not supported on standard server. // public static final int ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER = 8584; // // MessageId: ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD // // MessageText: // // Could not access a partition of the directory service located on a remote // server. Make sure at least one server is running for the partition in // question. // public static final int ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD = 8585; // // MessageId: ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2 // // MessageText: // // The directory cannot validate the proposed naming context (or partition) // name because it does not hold a replica nor can it contact a replica of // the naming context above the proposed naming context. Please ensure that // the parent naming context is properly registered in DNS, and at least one // replica of this naming context is reachable by the Domain Naming master. // public static final int ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2 = 8586; // // MessageId: ERROR_DS_THREAD_LIMIT_EXCEEDED // // MessageText: // // The thread limit for this request was exceeded. // public static final int ERROR_DS_THREAD_LIMIT_EXCEEDED = 8587; // // MessageId: ERROR_DS_NOT_CLOSEST // // MessageText: // // The Global catalog server is not in the closest site. // public static final int ERROR_DS_NOT_CLOSEST = 8588; // // MessageId: ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF // // MessageText: // // The DS cannot derive a service principal name (SPN) with which to // mutually authenticate the target server because the corresponding server // object in the local DS database has no serverReference attribute. // public static final int ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF = 8589; // // MessageId: ERROR_DS_SINGLE_USER_MODE_FAILED // // MessageText: // // The Directory Service failed to enter single user mode. // public static final int ERROR_DS_SINGLE_USER_MODE_FAILED = 8590; // // MessageId: ERROR_DS_NTDSCRIPT_SYNTAX_ERROR // // MessageText: // // The Directory Service cannot parse the script because of a syntax error. // public static final int ERROR_DS_NTDSCRIPT_SYNTAX_ERROR = 8591; // // MessageId: ERROR_DS_NTDSCRIPT_PROCESS_ERROR // // MessageText: // // The Directory Service cannot process the script because of an error. // public static final int ERROR_DS_NTDSCRIPT_PROCESS_ERROR = 8592; // // MessageId: ERROR_DS_DIFFERENT_REPL_EPOCHS // // MessageText: // // The directory service cannot perform the requested operation because the // servers // involved are of different replication epochs (which is usually related to // a // domain rename that is in progress). // public static final int ERROR_DS_DIFFERENT_REPL_EPOCHS = 8593; // // MessageId: ERROR_DS_DRS_EXTENSIONS_CHANGED // // MessageText: // // The directory service binding must be renegotiated due to a change in the // server // extensions information. // public static final int ERROR_DS_DRS_EXTENSIONS_CHANGED = 8594; // // MessageId: ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR // // MessageText: // // Operation not allowed on a disabled cross ref. // public static final int ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR = 8595; // // MessageId: ERROR_DS_NO_MSDS_INTID // // MessageText: // // Schema update failed: No values for msDS-IntId are available. // public static final int ERROR_DS_NO_MSDS_INTID = 8596; // // MessageId: ERROR_DS_DUP_MSDS_INTID // // MessageText: // // Schema update failed: Duplicate msDS-INtId. Retry the operation. // public static final int ERROR_DS_DUP_MSDS_INTID = 8597; // // MessageId: ERROR_DS_EXISTS_IN_RDNATTID // // MessageText: // // Schema deletion failed: attribute is used in rDNAttID. // public static final int ERROR_DS_EXISTS_IN_RDNATTID = 8598; // // MessageId: ERROR_DS_AUTHORIZATION_FAILED // // MessageText: // // The directory service failed to authorize the request. // public static final int ERROR_DS_AUTHORIZATION_FAILED = 8599; // // MessageId: ERROR_DS_INVALID_SCRIPT // // MessageText: // // The Directory Service cannot process the script because it is invalid. // public static final int ERROR_DS_INVALID_SCRIPT = 8600; // // MessageId: ERROR_DS_REMOTE_CROSSREF_OP_FAILED // // MessageText: // // The remote create cross reference operation failed on the Domain Naming // Master FSMO. The operation's error is in the extended data. // public static final int ERROR_DS_REMOTE_CROSSREF_OP_FAILED = 8601; // // MessageId: ERROR_DS_CROSS_REF_BUSY // // MessageText: // // A cross reference is in use locally with the same name. // public static final int ERROR_DS_CROSS_REF_BUSY = 8602; // // MessageId: ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN // // MessageText: // // The DS cannot derive a service principal name (SPN) with which to // mutually authenticate the target server because the server's domain has // been deleted from the forest. // public static final int ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN = 8603; // // MessageId: ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC // // MessageText: // // Writeable NCs prevent this DC from demoting. // public static final int ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC = 8604; // // MessageId: ERROR_DS_DUPLICATE_ID_FOUND // // MessageText: // // The requested object has a non-unique identifier and cannot be retrieved. // public static final int ERROR_DS_DUPLICATE_ID_FOUND = 8605; // // MessageId: ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT // // MessageText: // // Insufficient attributes were given to create an object. This object may // not exist because it may have been deleted and already garbage collected. // public static final int ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT = 8606; // // MessageId: ERROR_DS_GROUP_CONVERSION_ERROR // // MessageText: // // The group cannot be converted due to attribute restrictions on the // requested group type. // public static final int ERROR_DS_GROUP_CONVERSION_ERROR = 8607; // // MessageId: ERROR_DS_CANT_MOVE_APP_BASIC_GROUP // // MessageText: // // Cross-domain move of non-empty basic application groups is not allowed. // public static final int ERROR_DS_CANT_MOVE_APP_BASIC_GROUP = 8608; // // MessageId: ERROR_DS_CANT_MOVE_APP_QUERY_GROUP // // MessageText: // // Cross-domain move of non-empty query based application groups is not // allowed. // public static final int ERROR_DS_CANT_MOVE_APP_QUERY_GROUP = 8609; // // MessageId: ERROR_DS_ROLE_NOT_VERIFIED // // MessageText: // // The FSMO role ownership could not be verified because its directory // partition has not replicated successfully with atleast one replication // partner. // public static final int ERROR_DS_ROLE_NOT_VERIFIED = 8610; // // MessageId: ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL // // MessageText: // // The target container for a redirection of a well known object container // cannot already be a special container. // public static final int ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL = 8611; // // MessageId: ERROR_DS_DOMAIN_RENAME_IN_PROGRESS // // MessageText: // // The Directory Service cannot perform the requested operation because a // domain rename operation is in progress. // public static final int ERROR_DS_DOMAIN_RENAME_IN_PROGRESS = 8612; // // MessageId: ERROR_DS_EXISTING_AD_CHILD_NC // // MessageText: // // The directory service detected a child partition below the requested // partition name. The partition hierarchy must be created in a top down // method. // public static final int ERROR_DS_EXISTING_AD_CHILD_NC = 8613; // // MessageId: ERROR_DS_REPL_LIFETIME_EXCEEDED // // MessageText: // // The directory service cannot replicate with this server because the time // since the last replication with this server has exceeded the tombstone // lifetime. // public static final int ERROR_DS_REPL_LIFETIME_EXCEEDED = 8614; // // MessageId: ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER // // MessageText: // // The requested operation is not allowed on an object under the system // container. // public static final int ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER = 8615; // // MessageId: ERROR_DS_LDAP_SEND_QUEUE_FULL // // MessageText: // // The LDAP servers network send queue has filled up because the client is // not processing the results of it's requests fast enough. No more requests // will be processed until the client catches up. If the client does not // catch up then it will be disconnected. // public static final int ERROR_DS_LDAP_SEND_QUEUE_FULL = 8616; // // MessageId: ERROR_DS_DRA_OUT_SCHEDULE_WINDOW // // MessageText: // // The scheduled replication did not take place because the system was too // busy to execute the request within the schedule window. The replication // queue is overloaded. Consider reducing the number of partners or // decreasing the scheduled replication frequency. // public static final int ERROR_DS_DRA_OUT_SCHEDULE_WINDOW = 8617; // // MessageId: ERROR_DS_POLICY_NOT_KNOWN // // MessageText: // // At this time, it cannot be determined if the branch replication policy is // available on the hub domain controller. Please retry at a later time to // account for replication latencies. // public static final int ERROR_DS_POLICY_NOT_KNOWN = 8618; // // MessageId: ERROR_NO_SITE_SETTINGS_OBJECT // // MessageText: // // The site settings object for the specified site does not exist. // public static final int ERROR_NO_SITE_SETTINGS_OBJECT = 8619; // // MessageId: ERROR_NO_SECRETS // // MessageText: // // The local account store does not contain secret material for the // specified account. // public static final int ERROR_NO_SECRETS = 8620; // // MessageId: ERROR_NO_WRITABLE_DC_FOUND // // MessageText: // // Could not find a writable domain controller in the domain. // public static final int ERROR_NO_WRITABLE_DC_FOUND = 8621; // // MessageId: ERROR_DS_NO_SERVER_OBJECT // // MessageText: // // The server object for the domain controller does not exist. // public static final int ERROR_DS_NO_SERVER_OBJECT = 8622; // // MessageId: ERROR_DS_NO_NTDSA_OBJECT // // MessageText: // // The NTDS Settings object for the domain controller does not exist. // public static final int ERROR_DS_NO_NTDSA_OBJECT = 8623; // // MessageId: ERROR_DS_NON_ASQ_SEARCH // // MessageText: // // The requested search operation is not supported for ASQ searches. // public static final int ERROR_DS_NON_ASQ_SEARCH = 8624; // // MessageId: ERROR_DS_AUDIT_FAILURE // // MessageText: // // A required audit event could not be generated for the operation. // public static final int ERROR_DS_AUDIT_FAILURE = 8625; // // MessageId: ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE // // MessageText: // // The search flags for the attribute are invalid. The subtree index bit is // valid only on single valued attributes. // public static final int ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE = 8626; // // MessageId: ERROR_DS_INVALID_SEARCH_FLAG_TUPLE // // MessageText: // // The search flags for the attribute are invalid. The tuple index bit is // valid only on attributes of Unicode strings. // public static final int ERROR_DS_INVALID_SEARCH_FLAG_TUPLE = 8627; // // MessageId: ERROR_DS_HIERARCHY_TABLE_TOO_DEEP // // MessageText: // // The address books are nested too deeply. Failed to build the hierarchy // table. // public static final int ERROR_DS_HIERARCHY_TABLE_TOO_DEEP = 8628; // ///////////////////////////////////////////////// // =/ // =End of Active Directory Error Codes / // =/ // =8000 to =8999=/ // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =DNS Error codes=// // =// // =9000 to=9999=// // ///////////////////////////////////////////////// // ==== // Facility DNS Error Messages // ==== // // DNS response codes. // public static final int DNS_ERROR_RESPONSE_CODES_BASE = 9000; public static final int DNS_ERROR_RCODE_NO_ERROR = NO_ERROR; public static final int DNS_ERROR_MASK = 0x00002328; // =9000 or // DNS_ERROR_RESPONSE_CODES_BASE // DNS_ERROR_RCODE_FORMAT_ERROR=0x00002329 // // MessageId: DNS_ERROR_RCODE_FORMAT_ERROR // // MessageText: // // DNS server unable to interpret format. // public static final int DNS_ERROR_RCODE_FORMAT_ERROR = 9001; // DNS_ERROR_RCODE_SERVER_FAILURE=0x0000232a // // MessageId: DNS_ERROR_RCODE_SERVER_FAILURE // // MessageText: // // DNS server failure. // public static final int DNS_ERROR_RCODE_SERVER_FAILURE = 9002; // DNS_ERROR_RCODE_NAME_ERROR=0x0000232b // // MessageId: DNS_ERROR_RCODE_NAME_ERROR // // MessageText: // // DNS name does not exist. // public static final int DNS_ERROR_RCODE_NAME_ERROR = 9003; // DNS_ERROR_RCODE_NOT_IMPLEMENTED 0x0000232c // // MessageId: DNS_ERROR_RCODE_NOT_IMPLEMENTED // // MessageText: // // DNS request not supported by name server. // public static final int DNS_ERROR_RCODE_NOT_IMPLEMENTED = 9004; // DNS_ERROR_RCODE_REFUSED=0x0000232d // // MessageId: DNS_ERROR_RCODE_REFUSED // // MessageText: // // DNS operation refused. // public static final int DNS_ERROR_RCODE_REFUSED = 9005; // DNS_ERROR_RCODE_YXDOMAIN=0x0000232e // // MessageId: DNS_ERROR_RCODE_YXDOMAIN // // MessageText: // // DNS name that ought not exist, does exist. // public static final int DNS_ERROR_RCODE_YXDOMAIN = 9006; // DNS_ERROR_RCODE_YXRRSET=0x0000232f // // MessageId: DNS_ERROR_RCODE_YXRRSET // // MessageText: // // DNS RR set that ought not exist, does exist. // public static final int DNS_ERROR_RCODE_YXRRSET = 9007; // DNS_ERROR_RCODE_NXRRSET=0x00002330 // // MessageId: DNS_ERROR_RCODE_NXRRSET // // MessageText: // // DNS RR set that ought to exist, does not exist. // public static final int DNS_ERROR_RCODE_NXRRSET = 9008; // DNS_ERROR_RCODE_NOTAUTH=0x00002331 // // MessageId: DNS_ERROR_RCODE_NOTAUTH // // MessageText: // // DNS server not authoritative for zone. // public static final int DNS_ERROR_RCODE_NOTAUTH = 9009; // DNS_ERROR_RCODE_NOTZONE=0x00002332 // // MessageId: DNS_ERROR_RCODE_NOTZONE // // MessageText: // // DNS name in update or prereq is not in zone. // public static final int DNS_ERROR_RCODE_NOTZONE = 9010; // DNS_ERROR_RCODE_BADSIG=0x00002338 // // MessageId: DNS_ERROR_RCODE_BADSIG // // MessageText: // // DNS signature failed to verify. // public static final int DNS_ERROR_RCODE_BADSIG = 9016; // DNS_ERROR_RCODE_BADKEY=0x00002339 // // MessageId: DNS_ERROR_RCODE_BADKEY // // MessageText: // // DNS bad key. // public static final int DNS_ERROR_RCODE_BADKEY = 9017; // DNS_ERROR_RCODE_BADTIME=0x0000233a // // MessageId: DNS_ERROR_RCODE_BADTIME // // MessageText: // // DNS signature validity expired. // public static final int DNS_ERROR_RCODE_BADTIME = 9018; public static final int DNS_ERROR_RCODE_LAST = DNS_ERROR_RCODE_BADTIME; // // Packet format // public static final int DNS_ERROR_PACKET_FMT_BASE = 9500; // DNS_INFO_NO_RECORDS=0x0000251d // // MessageId: DNS_INFO_NO_RECORDS // // MessageText: // // No records found for given DNS query. // public static final int DNS_INFO_NO_RECORDS = 9501; // DNS_ERROR_BAD_PACKET=0x0000251e // // MessageId: DNS_ERROR_BAD_PACKET // // MessageText: // // Bad DNS packet. // public static final int DNS_ERROR_BAD_PACKET = 9502; // DNS_ERROR_NO_PACKET=0x0000251f // // MessageId: DNS_ERROR_NO_PACKET // // MessageText: // // No DNS packet. // public static final int DNS_ERROR_NO_PACKET = 9503; // DNS_ERROR_RCODE=0x00002520 // // MessageId: DNS_ERROR_RCODE // // MessageText: // // DNS error, check rcode. // public static final int DNS_ERROR_RCODE = 9504; // DNS_ERROR_UNSECURE_PACKET=0x00002521 // // MessageId: DNS_ERROR_UNSECURE_PACKET // // MessageText: // // Unsecured DNS packet. // public static final int DNS_ERROR_UNSECURE_PACKET = 9505; public static final int DNS_STATUS_PACKET_UNSECURE = DNS_ERROR_UNSECURE_PACKET; // // General API errors // public static final int DNS_ERROR_NO_MEMORY = ERROR_OUTOFMEMORY; public static final int DNS_ERROR_INVALID_NAME = ERROR_INVALID_NAME; public static final int DNS_ERROR_INVALID_DATA = ERROR_INVALID_DATA; public static final int DNS_ERROR_GENERAL_API_BASE = 9550; // DNS_ERROR_INVALID_TYPE=0x0000254f // // MessageId: DNS_ERROR_INVALID_TYPE // // MessageText: // // Invalid DNS type. // public static final int DNS_ERROR_INVALID_TYPE = 9551; // DNS_ERROR_INVALID_IP_ADDRESS=0x00002550 // // MessageId: DNS_ERROR_INVALID_IP_ADDRESS // // MessageText: // // Invalid IP address. // public static final int DNS_ERROR_INVALID_IP_ADDRESS = 9552; // DNS_ERROR_INVALID_PROPERTY=0x00002551 // // MessageId: DNS_ERROR_INVALID_PROPERTY // // MessageText: // // Invalid property. // public static final int DNS_ERROR_INVALID_PROPERTY = 9553; // DNS_ERROR_TRY_AGAIN_LATER=0x00002552 // // MessageId: DNS_ERROR_TRY_AGAIN_LATER // // MessageText: // // Try DNS operation again later. // public static final int DNS_ERROR_TRY_AGAIN_LATER = 9554; // DNS_ERROR_NOT_UNIQUE=0x00002553 // // MessageId: DNS_ERROR_NOT_UNIQUE // // MessageText: // // Record for given name and type is not unique. // public static final int DNS_ERROR_NOT_UNIQUE = 9555; // DNS_ERROR_NON_RFC_NAME=0x00002554 // // MessageId: DNS_ERROR_NON_RFC_NAME // // MessageText: // // DNS name does not comply with RFC specifications. // public static final int DNS_ERROR_NON_RFC_NAME = 9556; // DNS_STATUS_FQDN=0x00002555 // // MessageId: DNS_STATUS_FQDN // // MessageText: // // DNS name is a fully-qualified DNS name. // public static final int DNS_STATUS_FQDN = 9557; // DNS_STATUS_DOTTED_NAME=0x00002556 // // MessageId: DNS_STATUS_DOTTED_NAME // // MessageText: // // DNS name is dotted (multi-labe;. // public static final int DNS_STATUS_DOTTED_NAME = 9558; // DNS_STATUS_SINGLE_PART_NAME=0x00002557 // // MessageId: DNS_STATUS_SINGLE_PART_NAME // // MessageText: // // DNS name is a single-part name. // public static final int DNS_STATUS_SINGLE_PART_NAME = 9559; // DNS_ERROR_INVALID_NAME_CHAR=0x00002558 // // MessageId: DNS_ERROR_INVALID_NAME_CHAR // // MessageText: // // DNS name contains an invalid character. // public static final int DNS_ERROR_INVALID_NAME_CHAR = 9560; // DNS_ERROR_NUMERIC_NAME=0x00002559 // // MessageId: DNS_ERROR_NUMERIC_NAME // // MessageText: // // DNS name is entirely numeric. // public static final int DNS_ERROR_NUMERIC_NAME = 9561; // DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER 0x0000255A // // MessageId: DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER // // MessageText: // // The operation requested is not permitted on a DNS root server. // public static final int DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER = 9562; // DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION 0x0000255B // // MessageId: DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION // // MessageText: // // The record could not be created because this part of the DNS namespace // has been delegated to another server. // public static final int DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION = 9563; // DNS_ERROR_CANNOT_FIND_ROOT_HINTS 0x0000255C // // MessageId: DNS_ERROR_CANNOT_FIND_ROOT_HINTS // // MessageText: // // The DNS server could not find a set of root hints. // public static final int DNS_ERROR_CANNOT_FIND_ROOT_HINTS = 9564; // DNS_ERROR_INCONSISTENT_ROOT_HINTS 0x0000255D // // MessageId: DNS_ERROR_INCONSISTENT_ROOT_HINTS // // MessageText: // // The DNS server found root hints but they were not consistent across all // adapters. // public static final int DNS_ERROR_INCONSISTENT_ROOT_HINTS = 9565; // DNS_ERROR_DWORD_VALUE_TOO_SMALL 0x0000255E // // MessageId: DNS_ERROR_DWORD_VALUE_TOO_SMALL // // MessageText: // // The specified value is too small for this parameter. // public static final int DNS_ERROR_DWORD_VALUE_TOO_SMALL = 9566; // DNS_ERROR_DWORD_VALUE_TOO_LARGE 0x0000255F // // MessageId: DNS_ERROR_DWORD_VALUE_TOO_LARGE // // MessageText: // // The specified value is too large for this parameter. // public static final int DNS_ERROR_DWORD_VALUE_TOO_LARGE = 9567; // DNS_ERROR_BACKGROUND_LOADING 0x00002560 // // MessageId: DNS_ERROR_BACKGROUND_LOADING // // MessageText: // // This operation is not allowed while the DNS server is loading zones in // the background. Please try again later. // public static final int DNS_ERROR_BACKGROUND_LOADING = 9568; // DNS_ERROR_NOT_ALLOWED_ON_RODC 0x00002561 // // MessageId: DNS_ERROR_NOT_ALLOWED_ON_RODC // // MessageText: // // The operation requested is not permitted on against a DNS server running // on a read-only DC. // public static final int DNS_ERROR_NOT_ALLOWED_ON_RODC = 9569; // DNS_ERROR_NOT_ALLOWED_UNDER_DNAME 0x00002562 // // MessageId: DNS_ERROR_NOT_ALLOWED_UNDER_DNAME // // MessageText: // // No data is allowed to exist underneath a DNAME record. // public static final int DNS_ERROR_NOT_ALLOWED_UNDER_DNAME = 9570; // // Zone errors // public static final int DNS_ERROR_ZONE_BASE = 9600; // DNS_ERROR_ZONE_DOES_NOT_EXIST=0x00002581 // // MessageId: DNS_ERROR_ZONE_DOES_NOT_EXIST // // MessageText: // // DNS zone does not exist. // public static final int DNS_ERROR_ZONE_DOES_NOT_EXIST = 9601; // DNS_ERROR_NO_ZONE_INFO=0x00002582 // // MessageId: DNS_ERROR_NO_ZONE_INFO // // MessageText: // // DNS zone information not available. // public static final int DNS_ERROR_NO_ZONE_INFO = 9602; // DNS_ERROR_INVALID_ZONE_OPERATION 0x00002583 // // MessageId: DNS_ERROR_INVALID_ZONE_OPERATION // // MessageText: // // Invalid operation for DNS zone. // public static final int DNS_ERROR_INVALID_ZONE_OPERATION = 9603; // DNS_ERROR_ZONE_CONFIGURATION_ERROR 0x00002584 // // MessageId: DNS_ERROR_ZONE_CONFIGURATION_ERROR // // MessageText: // // Invalid DNS zone configuration. // public static final int DNS_ERROR_ZONE_CONFIGURATION_ERROR = 9604; // DNS_ERROR_ZONE_HAS_NO_SOA_RECORD 0x00002585 // // MessageId: DNS_ERROR_ZONE_HAS_NO_SOA_RECORD // // MessageText: // // DNS zone has no start of authority (SOA) record. // public static final int DNS_ERROR_ZONE_HAS_NO_SOA_RECORD = 9605; // DNS_ERROR_ZONE_HAS_NO_NS_RECORDS 0x00002586 // // MessageId: DNS_ERROR_ZONE_HAS_NO_NS_RECORDS // // MessageText: // // DNS zone has no Name Server (NS) record. // public static final int DNS_ERROR_ZONE_HAS_NO_NS_RECORDS = 9606; // DNS_ERROR_ZONE_LOCKED=0x00002587 // // MessageId: DNS_ERROR_ZONE_LOCKED // // MessageText: // // DNS zone is locked. // public static final int DNS_ERROR_ZONE_LOCKED = 9607; // DNS_ERROR_ZONE_CREATION_FAILED=0x00002588 // // MessageId: DNS_ERROR_ZONE_CREATION_FAILED // // MessageText: // // DNS zone creation failed. // public static final int DNS_ERROR_ZONE_CREATION_FAILED = 9608; // DNS_ERROR_ZONE_ALREADY_EXISTS=0x00002589 // // MessageId: DNS_ERROR_ZONE_ALREADY_EXISTS // // MessageText: // // DNS zone already exists. // public static final int DNS_ERROR_ZONE_ALREADY_EXISTS = 9609; // DNS_ERROR_AUTOZONE_ALREADY_EXISTS 0x0000258a // // MessageId: DNS_ERROR_AUTOZONE_ALREADY_EXISTS // // MessageText: // // DNS automatic zone already exists. // public static final int DNS_ERROR_AUTOZONE_ALREADY_EXISTS = 9610; // DNS_ERROR_INVALID_ZONE_TYPE=0x0000258b // // MessageId: DNS_ERROR_INVALID_ZONE_TYPE // // MessageText: // // Invalid DNS zone type. // public static final int DNS_ERROR_INVALID_ZONE_TYPE = 9611; // DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP 0x0000258c // // MessageId: DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP // // MessageText: // // Secondary DNS zone requires master IP address. // public static final int DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP = 9612; // DNS_ERROR_ZONE_NOT_SECONDARY=0x0000258d // // MessageId: DNS_ERROR_ZONE_NOT_SECONDARY // // MessageText: // // DNS zone not secondary. // public static final int DNS_ERROR_ZONE_NOT_SECONDARY = 9613; // DNS_ERROR_NEED_SECONDARY_ADDRESSES 0x0000258e // // MessageId: DNS_ERROR_NEED_SECONDARY_ADDRESSES // // MessageText: // // Need secondary IP address. // public static final int DNS_ERROR_NEED_SECONDARY_ADDRESSES = 9614; // DNS_ERROR_WINS_INIT_FAILED=0x0000258f // // MessageId: DNS_ERROR_WINS_INIT_FAILED // // MessageText: // // WINS initialization failed. // public static final int DNS_ERROR_WINS_INIT_FAILED = 9615; // DNS_ERROR_NEED_WINS_SERVERS=0x00002590 // // MessageId: DNS_ERROR_NEED_WINS_SERVERS // // MessageText: // // Need WINS servers. // public static final int DNS_ERROR_NEED_WINS_SERVERS = 9616; // DNS_ERROR_NBSTAT_INIT_FAILED=0x00002591 // // MessageId: DNS_ERROR_NBSTAT_INIT_FAILED // // MessageText: // // NBTSTAT initialization call failed. // public static final int DNS_ERROR_NBSTAT_INIT_FAILED = 9617; // DNS_ERROR_SOA_DELETE_INVALID=0x00002592 // // MessageId: DNS_ERROR_SOA_DELETE_INVALID // // MessageText: // // Invalid delete of start of authority (SOA) // public static final int DNS_ERROR_SOA_DELETE_INVALID = 9618; // DNS_ERROR_FORWARDER_ALREADY_EXISTS 0x00002593 // // MessageId: DNS_ERROR_FORWARDER_ALREADY_EXISTS // // MessageText: // // A conditional forwarding zone already exists for that name. // public static final int DNS_ERROR_FORWARDER_ALREADY_EXISTS = 9619; // DNS_ERROR_ZONE_REQUIRES_MASTER_IP 0x00002594 // // MessageId: DNS_ERROR_ZONE_REQUIRES_MASTER_IP // // MessageText: // // This zone must be configured with one or more master DNS server IP // addresses. // public static final int DNS_ERROR_ZONE_REQUIRES_MASTER_IP = 9620; // DNS_ERROR_ZONE_IS_SHUTDOWN=0x00002595 // // MessageId: DNS_ERROR_ZONE_IS_SHUTDOWN // // MessageText: // // The operation cannot be performed because this zone is shutdown. // public static final int DNS_ERROR_ZONE_IS_SHUTDOWN = 9621; // // Datafile errors // public static final int DNS_ERROR_DATAFILE_BASE = 9650; // DNS=0x000025b3 // // MessageId: DNS_ERROR_PRIMARY_REQUIRES_DATAFILE // // MessageText: // // Primary DNS zone requires datafile. // public static final int DNS_ERROR_PRIMARY_REQUIRES_DATAFILE = 9651; // DNS=0x000025b4 // // MessageId: DNS_ERROR_INVALID_DATAFILE_NAME // // MessageText: // // Invalid datafile name for DNS zone. // public static final int DNS_ERROR_INVALID_DATAFILE_NAME = 9652; // DNS=0x000025b5 // // MessageId: DNS_ERROR_DATAFILE_OPEN_FAILURE // // MessageText: // // Failed to open datafile for DNS zone. // public static final int DNS_ERROR_DATAFILE_OPEN_FAILURE = 9653; // DNS=0x000025b6 // // MessageId: DNS_ERROR_FILE_WRITEBACK_FAILED // // MessageText: // // Failed to write datafile for DNS zone. // public static final int DNS_ERROR_FILE_WRITEBACK_FAILED = 9654; // DNS=0x000025b7 // // MessageId: DNS_ERROR_DATAFILE_PARSING // // MessageText: // // Failure while reading datafile for DNS zone. // public static final int DNS_ERROR_DATAFILE_PARSING = 9655; // // Database errors // public static final int DNS_ERROR_DATABASE_BASE = 9700; // DNS_ERROR_RECORD_DOES_NOT_EXIST 0x000025e5 // // MessageId: DNS_ERROR_RECORD_DOES_NOT_EXIST // // MessageText: // // DNS record does not exist. // public static final int DNS_ERROR_RECORD_DOES_NOT_EXIST = 9701; // DNS_ERROR_RECORD_FORMAT=0x000025e6 // // MessageId: DNS_ERROR_RECORD_FORMAT // // MessageText: // // DNS record format error. // public static final int DNS_ERROR_RECORD_FORMAT = 9702; // DNS_ERROR_NODE_CREATION_FAILED=0x000025e7 // // MessageId: DNS_ERROR_NODE_CREATION_FAILED // // MessageText: // // Node creation failure in DNS. // public static final int DNS_ERROR_NODE_CREATION_FAILED = 9703; // DNS_ERROR_UNKNOWN_RECORD_TYPE=0x000025e8 // // MessageId: DNS_ERROR_UNKNOWN_RECORD_TYPE // // MessageText: // // Unknown DNS record type. // public static final int DNS_ERROR_UNKNOWN_RECORD_TYPE = 9704; // DNS_ERROR_RECORD_TIMED_OUT=0x000025e9 // // MessageId: DNS_ERROR_RECORD_TIMED_OUT // // MessageText: // // DNS record timed out. // public static final int DNS_ERROR_RECORD_TIMED_OUT = 9705; // DNS_ERROR_NAME_NOT_IN_ZONE=0x000025ea // // MessageId: DNS_ERROR_NAME_NOT_IN_ZONE // // MessageText: // // Name not in DNS zone. // public static final int DNS_ERROR_NAME_NOT_IN_ZONE = 9706; // DNS_ERROR_CNAME_LOOP=0x000025eb // // MessageId: DNS_ERROR_CNAME_LOOP // // MessageText: // // CNAME loop detected. // public static final int DNS_ERROR_CNAME_LOOP = 9707; // DNS_ERROR_NODE_IS_CNAME=0x000025ec // // MessageId: DNS_ERROR_NODE_IS_CNAME // // MessageText: // // Node is a CNAME DNS record. // public static final int DNS_ERROR_NODE_IS_CNAME = 9708; // DNS_ERROR_CNAME_COLLISION=0x000025ed // // MessageId: DNS_ERROR_CNAME_COLLISION // // MessageText: // // A CNAME record already exists for given name. // public static final int DNS_ERROR_CNAME_COLLISION = 9709; // DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT 0x000025ee // // MessageId: DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT // // MessageText: // // Record only at DNS zone root. // public static final int DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT = 9710; // DNS_ERROR_RECORD_ALREADY_EXISTS 0x000025ef // // MessageId: DNS_ERROR_RECORD_ALREADY_EXISTS // // MessageText: // // DNS record already exists. // public static final int DNS_ERROR_RECORD_ALREADY_EXISTS = 9711; // DNS_ERROR_SECONDARY_DATA=0x000025f0 // // MessageId: DNS_ERROR_SECONDARY_DATA // // MessageText: // // Secondary DNS zone data error. // public static final int DNS_ERROR_SECONDARY_DATA = 9712; // DNS_ERROR_NO_CREATE_CACHE_DATA=0x000025f1 // // MessageId: DNS_ERROR_NO_CREATE_CACHE_DATA // // MessageText: // // Could not create DNS cache data. // public static final int DNS_ERROR_NO_CREATE_CACHE_DATA = 9713; // DNS_ERROR_NAME_DOES_NOT_EXIST=0x000025f2 // // MessageId: DNS_ERROR_NAME_DOES_NOT_EXIST // // MessageText: // // DNS name does not exist. // public static final int DNS_ERROR_NAME_DOES_NOT_EXIST = 9714; // DNS_WARNING_PTR_CREATE_FAILED=0x000025f3 // // MessageId: DNS_WARNING_PTR_CREATE_FAILED // // MessageText: // // Could not create pointer (PTR) record. // public static final int DNS_WARNING_PTR_CREATE_FAILED = 9715; // DNS_WARNING_DOMAIN_UNDELETED=0x000025f4 // // MessageId: DNS_WARNING_DOMAIN_UNDELETED // // MessageText: // // DNS domain was undeleted. // public static final int DNS_WARNING_DOMAIN_UNDELETED = 9716; // DNS_ERROR_DS_UNAVAILABLE=0x000025f5 // // MessageId: DNS_ERROR_DS_UNAVAILABLE // // MessageText: // // The directory service is unavailable. // public static final int DNS_ERROR_DS_UNAVAILABLE = 9717; // DNS_ERROR_DS_ZONE_ALREADY_EXISTS 0x000025f6 // // MessageId: DNS_ERROR_DS_ZONE_ALREADY_EXISTS // // MessageText: // // DNS zone already exists in the directory service. // public static final int DNS_ERROR_DS_ZONE_ALREADY_EXISTS = 9718; // DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE 0x000025f7 // // MessageId: DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE // // MessageText: // // DNS server not creating or reading the boot file for the directory // service integrated DNS zone. // public static final int DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE = 9719; // DNS_ERROR_NODE_IS_DNAME=0x000025f8 // // MessageId: DNS_ERROR_NODE_IS_DNAME // // MessageText: // // Node is a DNAME DNS record. // public static final int DNS_ERROR_NODE_IS_DNAME = 9720; // DNS_ERROR_DNAME_COLLISION=0x000025f9 // // MessageId: DNS_ERROR_DNAME_COLLISION // // MessageText: // // A DNAME record already exists for given name. // public static final int DNS_ERROR_DNAME_COLLISION = 9721; // DNS_ERROR_ALIAS_LOOP=0x000025fa // // MessageId: DNS_ERROR_ALIAS_LOOP // // MessageText: // // An alias loop has been detected with either CNAME or DNAME records. // public static final int DNS_ERROR_ALIAS_LOOP = 9722; // // Operation errors // public static final int DNS_ERROR_OPERATION_BASE = 9750; // DNS_INFO_AXFR_COMPLETE=0x00002617 // // MessageId: DNS_INFO_AXFR_COMPLETE // // MessageText: // // DNS AXFR (zone transfer) complete. // public static final int DNS_INFO_AXFR_COMPLETE = 9751; // DNS_ERROR_AXFR=0x00002618 // // MessageId: DNS_ERROR_AXFR // // MessageText: // // DNS zone transfer failed. // public static final int DNS_ERROR_AXFR = 9752; // DNS_INFO_ADDED_LOCAL_WINS=0x00002619 // // MessageId: DNS_INFO_ADDED_LOCAL_WINS // // MessageText: // // Added local WINS server. // public static final int DNS_INFO_ADDED_LOCAL_WINS = 9753; // // Secure update // public static final int DNS_ERROR_SECURE_BASE = 9800; // DNS_STATUS_CONTINUE_NEEDED=0x00002649 // // MessageId: DNS_STATUS_CONTINUE_NEEDED // // MessageText: // // Secure update call needs to continue update request. // public static final int DNS_STATUS_CONTINUE_NEEDED = 9801; // // Setup errors // public static final int DNS_ERROR_SETUP_BASE = 9850; // DNS_ERROR_NO_TCPIP=0x0000267b // // MessageId: DNS_ERROR_NO_TCPIP // // MessageText: // // TCP/IP network protocol not installed. // public static final int DNS_ERROR_NO_TCPIP = 9851; // DNS_ERROR_NO_DNS_SERVERS=0x0000267c // // MessageId: DNS_ERROR_NO_DNS_SERVERS // // MessageText: // // No DNS servers configured for local system. // public static final int DNS_ERROR_NO_DNS_SERVERS = 9852; // // Directory partition (DP) errors // public static final int DNS_ERROR_DP_BASE = 9900; // DNS_ERROR_DP_DOES_NOT_EXIST=0x000026ad // // MessageId: DNS_ERROR_DP_DOES_NOT_EXIST // // MessageText: // // The specified directory partition does not exist. // public static final int DNS_ERROR_DP_DOES_NOT_EXIST = 9901; // DNS_ERROR_DP_ALREADY_EXISTS=0x000026ae // // MessageId: DNS_ERROR_DP_ALREADY_EXISTS // // MessageText: // // The specified directory partition already exists. // public static final int DNS_ERROR_DP_ALREADY_EXISTS = 9902; // DNS_ERROR_DP_NOT_ENLISTED=0x000026af // // MessageId: DNS_ERROR_DP_NOT_ENLISTED // // MessageText: // // This DNS server is not enlisted in the specified directory partition. // public static final int DNS_ERROR_DP_NOT_ENLISTED = 9903; // DNS_ERROR_DP_ALREADY_ENLISTED=0x000026b0 // // MessageId: DNS_ERROR_DP_ALREADY_ENLISTED // // MessageText: // // This DNS server is already enlisted in the specified directory partition. // public static final int DNS_ERROR_DP_ALREADY_ENLISTED = 9904; // DNS_ERROR_DP_NOT_AVAILABLE=0x000026b1 // // MessageId: DNS_ERROR_DP_NOT_AVAILABLE // // MessageText: // // The directory partition is not available at this time. Please wait a few // minutes and try again. // public static final int DNS_ERROR_DP_NOT_AVAILABLE = 9905; // DNS_ERROR_DP_FSMO_ERROR=0x000026b2 // // MessageId: DNS_ERROR_DP_FSMO_ERROR // // MessageText: // // The application directory partition operation failed. The domain // controller holding the domain naming master role is down or unable to // service the request or is not running Windows Server=2003. // public static final int DNS_ERROR_DP_FSMO_ERROR = 9906; // ///////////////////////////////////////////////// // =// // =End of DNS Error Codes=// // =// // =9000 to=9999=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =WinSock Error Codes=// // =// // =10000 to=11999=// // ///////////////////////////////////////////////// // // WinSock error codes are also defined in WinSock.h // and WinSock2.h, hence the IFDEF // public static final int WSABASEERR = 10000; // // MessageId: WSAEINTR // // MessageText: // // A blocking operation was interrupted by a call to WSACancelBlockingCall. // public static final int WSAEINTR = 10004; // // MessageId: WSAEBADF // // MessageText: // // The file handle supplied is not valid. // public static final int WSAEBADF = 10009; // // MessageId: WSAEACCES // // MessageText: // // An attempt was made to access a socket in a way forbidden by its access // permissions. // public static final int WSAEACCES = 10013; // // MessageId: WSAEFAULT // // MessageText: // // The system detected an invalid pointer address in attempting to use a // pointer argument in a call. // public static final int WSAEFAULT = 10014; // // MessageId: WSAEINVAL // // MessageText: // // An invalid argument was supplied. // public static final int WSAEINVAL = 10022; // // MessageId: WSAEMFILE // // MessageText: // // Too many open sockets. // public static final int WSAEMFILE = 10024; // // MessageId: WSAEWOULDBLOCK // // MessageText: // // A non-blocking socket operation could not be completed immediately. // public static final int WSAEWOULDBLOCK = 10035; // // MessageId: WSAEINPROGRESS // // MessageText: // // A blocking operation is currently executing. // public static final int WSAEINPROGRESS = 10036; // // MessageId: WSAEALREADY // // MessageText: // // An operation was attempted on a non-blocking socket that already had an // operation in progress. // public static final int WSAEALREADY = 10037; // // MessageId: WSAENOTSOCK // // MessageText: // // An operation was attempted on something that is not a socket. // public static final int WSAENOTSOCK = 10038; // // MessageId: WSAEDESTADDRREQ // // MessageText: // // A required address was omitted from an operation on a socket. // public static final int WSAEDESTADDRREQ = 10039; // // MessageId: WSAEMSGSIZE // // MessageText: // // A message sent on a datagram socket was larger than the internal message // buffer or some other network limit, or the buffer used to receive a // datagram into was smaller than the datagram itself. // public static final int WSAEMSGSIZE = 10040; // // MessageId: WSAEPROTOTYPE // // MessageText: // // A protocol was specified in the socket function call that does not // support the semantics of the socket type requested. // public static final int WSAEPROTOTYPE = 10041; // // MessageId: WSAENOPROTOOPT // // MessageText: // // An unknown, invalid, or unsupported option or level was specified in a // getsockopt or setsockopt call. // public static final int WSAENOPROTOOPT = 10042; // // MessageId: WSAEPROTONOSUPPORT // // MessageText: // // The requested protocol has not been configured into the system, or no // implementation for it exists. // public static final int WSAEPROTONOSUPPORT = 10043; // // MessageId: WSAESOCKTNOSUPPORT // // MessageText: // // The support for the specified socket type does not exist in this address // family. // public static final int WSAESOCKTNOSUPPORT = 10044; // // MessageId: WSAEOPNOTSUPP // // MessageText: // // The attempted operation is not supported for the type of object // referenced. // public static final int WSAEOPNOTSUPP = 10045; // // MessageId: WSAEPFNOSUPPORT // // MessageText: // // The protocol family has not been configured into the system or no // implementation for it exists. // public static final int WSAEPFNOSUPPORT = 10046; // // MessageId: WSAEAFNOSUPPORT // // MessageText: // // An address incompatible with the requested protocol was used. // public static final int WSAEAFNOSUPPORT = 10047; // // MessageId: WSAEADDRINUSE // // MessageText: // // Only one usage of each socket address (protocol/network address/port) is // normally permitted. // public static final int WSAEADDRINUSE = 10048; // // MessageId: WSAEADDRNOTAVAIL // // MessageText: // // The requested address is not valid in its context. // public static final int WSAEADDRNOTAVAIL = 10049; // // MessageId: WSAENETDOWN // // MessageText: // // A socket operation encountered a dead network. // public static final int WSAENETDOWN = 10050; // // MessageId: WSAENETUNREACH // // MessageText: // // A socket operation was attempted to an unreachable network. // public static final int WSAENETUNREACH = 10051; // // MessageId: WSAENETRESET // // MessageText: // // The connection has been broken due to keep-alive activity detecting a // failure while the operation was in progress. // public static final int WSAENETRESET = 10052; // // MessageId: WSAECONNABORTED // // MessageText: // // An established connection was aborted by the software in your host // machine. // public static final int WSAECONNABORTED = 10053; // // MessageId: WSAECONNRESET // // MessageText: // // An existing connection was forcibly closed by the remote host. // public static final int WSAECONNRESET = 10054; // // MessageId: WSAENOBUFS // // MessageText: // // An operation on a socket could not be performed because the system lacked // sufficient buffer space or because a queue was full. // public static final int WSAENOBUFS = 10055; // // MessageId: WSAEISCONN // // MessageText: // // A connect request was made on an already connected socket. // public static final int WSAEISCONN = 10056; // // MessageId: WSAENOTCONN // // MessageText: // // A request to send or receive data was disallowed because the socket is // not connected and (when sending on a datagram socket using a sendto cal; // no address was supplied. // public static final int WSAENOTCONN = 10057; // // MessageId: WSAESHUTDOWN // // MessageText: // // A request to send or receive data was disallowed because the socket had // already been shut down in that direction with a previous shutdown call. // public static final int WSAESHUTDOWN = 10058; // // MessageId: WSAETOOMANYREFS // // MessageText: // // Too many references to some kernel object. // public static final int WSAETOOMANYREFS = 10059; // // MessageId: WSAETIMEDOUT // // MessageText: // // A connection attempt failed because the connected party did not properly // respond after a period of time, or established connection failed because // connected host has failed to respond. // public static final int WSAETIMEDOUT = 10060; // // MessageId: WSAECONNREFUSED // // MessageText: // // No connection could be made because the target machine actively refused // it. // public static final int WSAECONNREFUSED = 10061; // // MessageId: WSAELOOP // // MessageText: // // Cannot translate name. // public static final int WSAELOOP = 10062; // // MessageId: WSAENAMETOOLONG // // MessageText: // // Name component or name was too long. // public static final int WSAENAMETOOLONG = 10063; // // MessageId: WSAEHOSTDOWN // // MessageText: // // A socket operation failed because the destination host was down. // public static final int WSAEHOSTDOWN = 10064; // // MessageId: WSAEHOSTUNREACH // // MessageText: // // A socket operation was attempted to an unreachable host. // public static final int WSAEHOSTUNREACH = 10065; // // MessageId: WSAENOTEMPTY // // MessageText: // // Cannot remove a directory that is not empty. // public static final int WSAENOTEMPTY = 10066; // // MessageId: WSAEPROCLIM // // MessageText: // // A Windows Sockets implementation may have a limit on the number of // applications that may use it simultaneously. // public static final int WSAEPROCLIM = 10067; // // MessageId: WSAEUSERS // // MessageText: // // Ran out of quota. // public static final int WSAEUSERS = 10068; // // MessageId: WSAEDQUOT // // MessageText: // // Ran out of disk quota. // public static final int WSAEDQUOT = 10069; // // MessageId: WSAESTALE // // MessageText: // // File handle reference is no longer available. // public static final int WSAESTALE = 10070; // // MessageId: WSAEREMOTE // // MessageText: // // Item is not available locally. // public static final int WSAEREMOTE = 10071; // // MessageId: WSASYSNOTREADY // // MessageText: // // WSAStartup cannot function at this time because the underlying system it // uses to provide network services is currently unavailable. // public static final int WSASYSNOTREADY = 10091; // // MessageId: WSAVERNOTSUPPORTED // // MessageText: // // The Windows Sockets version requested is not supported. // public static final int WSAVERNOTSUPPORTED = 10092; // // MessageId: WSANOTINITIALISED // // MessageText: // // Either the application has not called WSAStartup, or WSAStartup failed. // public static final int WSANOTINITIALISED = 10093; // // MessageId: WSAEDISCON // // MessageText: // // Returned by WSARecv or WSARecvFrom to indicate the remote party has // initiated a graceful shutdown sequence. // public static final int WSAEDISCON = 10101; // // MessageId: WSAENOMORE // // MessageText: // // No more results can be returned by WSALookupServiceNext. // public static final int WSAENOMORE = 10102; // // MessageId: WSAECANCELLED // // MessageText: // // A call to WSALookupServiceEnd was made while this call was still // processing. The call has been canceled. // public static final int WSAECANCELLED = 10103; // // MessageId: WSAEINVALIDPROCTABLE // // MessageText: // // The procedure call table is invalid. // public static final int WSAEINVALIDPROCTABLE = 10104; // // MessageId: WSAEINVALIDPROVIDER // // MessageText: // // The requested service provider is invalid. // public static final int WSAEINVALIDPROVIDER = 10105; // // MessageId: WSAEPROVIDERFAILEDINIT // // MessageText: // // The requested service provider could not be loaded or initialized. // public static final int WSAEPROVIDERFAILEDINIT = 10106; // // MessageId: WSASYSCALLFAILURE // // MessageText: // // A system call that should never fail has failed. // public static final int WSASYSCALLFAILURE = 10107; // // MessageId: WSASERVICE_NOT_FOUND // // MessageText: // // No such service is known. The service cannot be found in the specified // name space. // public static final int WSASERVICE_NOT_FOUND = 10108; // // MessageId: WSATYPE_NOT_FOUND // // MessageText: // // The specified class was not found. // public static final int WSATYPE_NOT_FOUND = 10109; // // MessageId: WSA_E_NO_MORE // // MessageText: // // No more results can be returned by WSALookupServiceNext. // public static final int WSA_E_NO_MORE = 10110; // // MessageId: WSA_E_CANCELLED // // MessageText: // // A call to WSALookupServiceEnd was made while this call was still // processing. The call has been canceled. // public static final int WSA_E_CANCELLED = 10111; // // MessageId: WSAEREFUSED // // MessageText: // // A database query failed because it was actively refused. // public static final int WSAEREFUSED = 10112; // // MessageId: WSAHOST_NOT_FOUND // // MessageText: // // No such host is known. // public static final int WSAHOST_NOT_FOUND = 11001; // // MessageId: WSATRY_AGAIN // // MessageText: // // This is usually a temporary error during hostname resolution and means // that the local server did not receive a response from an authoritative // server. // public static final int WSATRY_AGAIN = 11002; // // MessageId: WSANO_RECOVERY // // MessageText: // // A non-recoverable error occurred during a database lookup. // public static final int WSANO_RECOVERY = 11003; // // MessageId: WSANO_DATA // // MessageText: // // The requested name is valid, but no data of the requested type was found. // public static final int WSANO_DATA = 11004; // // MessageId: WSA_QOS_RECEIVERS // // MessageText: // // At least one reserve has arrived. // public static final int WSA_QOS_RECEIVERS = 11005; // // MessageId: WSA_QOS_SENDERS // // MessageText: // // At least one path has arrived. // public static final int WSA_QOS_SENDERS = 11006; // // MessageId: WSA_QOS_NO_SENDERS // // MessageText: // // There are no senders. // public static final int WSA_QOS_NO_SENDERS = 11007; // // MessageId: WSA_QOS_NO_RECEIVERS // // MessageText: // // There are no receivers. // public static final int WSA_QOS_NO_RECEIVERS = 11008; // // MessageId: WSA_QOS_REQUEST_CONFIRMED // // MessageText: // // Reserve has been confirmed. // public static final int WSA_QOS_REQUEST_CONFIRMED = 11009; // // MessageId: WSA_QOS_ADMISSION_FAILURE // // MessageText: // // Error due to lack of resources. // public static final int WSA_QOS_ADMISSION_FAILURE = 11010; // // MessageId: WSA_QOS_POLICY_FAILURE // // MessageText: // // Rejected for administrative reasons - bad credentials. // public static final int WSA_QOS_POLICY_FAILURE = 11011; // // MessageId: WSA_QOS_BAD_STYLE // // MessageText: // // Unknown or conflicting style. // public static final int WSA_QOS_BAD_STYLE = 11012; // // MessageId: WSA_QOS_BAD_OBJECT // // MessageText: // // Problem with some part of the filterspec or providerspecific buffer in // general. // public static final int WSA_QOS_BAD_OBJECT = 11013; // // MessageId: WSA_QOS_TRAFFIC_CTRL_ERROR // // MessageText: // // Problem with some part of the flowspec. // public static final int WSA_QOS_TRAFFIC_CTRL_ERROR = 11014; // // MessageId: WSA_QOS_GENERIC_ERROR // // MessageText: // // General QOS error. // public static final int WSA_QOS_GENERIC_ERROR = 11015; // // MessageId: WSA_QOS_ESERVICETYPE // // MessageText: // // An invalid or unrecognized service type was found in the flowspec. // public static final int WSA_QOS_ESERVICETYPE = 11016; // // MessageId: WSA_QOS_EFLOWSPEC // // MessageText: // // An invalid or inconsistent flowspec was found in the QOS structure. // public static final int WSA_QOS_EFLOWSPEC = 11017; // // MessageId: WSA_QOS_EPROVSPECBUF // // MessageText: // // Invalid QOS provider-specific buffer. // public static final int WSA_QOS_EPROVSPECBUF = 11018; // // MessageId: WSA_QOS_EFILTERSTYLE // // MessageText: // // An invalid QOS filter style was used. // public static final int WSA_QOS_EFILTERSTYLE = 11019; // // MessageId: WSA_QOS_EFILTERTYPE // // MessageText: // // An invalid QOS filter type was used. // public static final int WSA_QOS_EFILTERTYPE = 11020; // // MessageId: WSA_QOS_EFILTERCOUNT // // MessageText: // // An incorrect number of QOS FILTERSPECs were specified in the // FLOWDESCRIPTOR. // public static final int WSA_QOS_EFILTERCOUNT = 11021; // // MessageId: WSA_QOS_EOBJLENGTH // // MessageText: // // An object with an invalid ObjectLength field was specified in the QOS // provider-specific buffer. // public static final int WSA_QOS_EOBJLENGTH = 11022; // // MessageId: WSA_QOS_EFLOWCOUNT // // MessageText: // // An incorrect number of flow descriptors was specified in the QOS // structure. // public static final int WSA_QOS_EFLOWCOUNT = 11023; // // MessageId: WSA_QOS_EUNKOWNPSOBJ // // MessageText: // // An unrecognized object was found in the QOS provider-specific buffer. // public static final int WSA_QOS_EUNKOWNPSOBJ = 11024; // // MessageId: WSA_QOS_EPOLICYOBJ // // MessageText: // // An invalid policy object was found in the QOS provider-specific buffer. // public static final int WSA_QOS_EPOLICYOBJ = 11025; // // MessageId: WSA_QOS_EFLOWDESC // // MessageText: // // An invalid QOS flow descriptor was found in the flow descriptor list. // public static final int WSA_QOS_EFLOWDESC = 11026; // // MessageId: WSA_QOS_EPSFLOWSPEC // // MessageText: // // An invalid or inconsistent flowspec was found in the QOS provider // specific buffer. // public static final int WSA_QOS_EPSFLOWSPEC = 11027; // // MessageId: WSA_QOS_EPSFILTERSPEC // // MessageText: // // An invalid FILTERSPEC was found in the QOS provider-specific buffer. // public static final int WSA_QOS_EPSFILTERSPEC = 11028; // // MessageId: WSA_QOS_ESDMODEOBJ // // MessageText: // // An invalid shape discard mode object was found in the QOS provider // specific buffer. // public static final int WSA_QOS_ESDMODEOBJ = 11029; // // MessageId: WSA_QOS_ESHAPERATEOBJ // // MessageText: // // An invalid shaping rate object was found in the QOS provider-specific // buffer. // public static final int WSA_QOS_ESHAPERATEOBJ = 11030; // // MessageId: WSA_QOS_RESERVED_PETYPE // // MessageText: // // A reserved policy element was found in the QOS provider-specific buffer. // public static final int WSA_QOS_RESERVED_PETYPE = 11031; // ///////////////////////////////////////////////// // =End of WinSock Error Codes=// // =// // =10000 to=11999=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =Available=// // =// // =12000 to=129999=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =Start of IPSec Error codes=// // =// // =13000 to=13999=// // ///////////////////////////////////////////////// // // MessageId: ERROR_IPSEC_QM_POLICY_EXISTS // // MessageText: // // The specified quick mode policy already exists. // public static final int ERROR_IPSEC_QM_POLICY_EXISTS = 13000; // // MessageId: ERROR_IPSEC_QM_POLICY_NOT_FOUND // // MessageText: // // The specified quick mode policy was not found. // public static final int ERROR_IPSEC_QM_POLICY_NOT_FOUND = 13001; // // MessageId: ERROR_IPSEC_QM_POLICY_IN_USE // // MessageText: // // The specified quick mode policy is being used. // public static final int ERROR_IPSEC_QM_POLICY_IN_USE = 13002; // // MessageId: ERROR_IPSEC_MM_POLICY_EXISTS // // MessageText: // // The specified main mode policy already exists. // public static final int ERROR_IPSEC_MM_POLICY_EXISTS = 13003; // // MessageId: ERROR_IPSEC_MM_POLICY_NOT_FOUND // // MessageText: // // The specified main mode policy was not found // public static final int ERROR_IPSEC_MM_POLICY_NOT_FOUND = 13004; // // MessageId: ERROR_IPSEC_MM_POLICY_IN_USE // // MessageText: // // The specified main mode policy is being used. // public static final int ERROR_IPSEC_MM_POLICY_IN_USE = 13005; // // MessageId: ERROR_IPSEC_MM_FILTER_EXISTS // // MessageText: // // The specified main mode filter already exists. // public static final int ERROR_IPSEC_MM_FILTER_EXISTS = 13006; // // MessageId: ERROR_IPSEC_MM_FILTER_NOT_FOUND // // MessageText: // // The specified main mode filter was not found. // public static final int ERROR_IPSEC_MM_FILTER_NOT_FOUND = 13007; // // MessageId: ERROR_IPSEC_TRANSPORT_FILTER_EXISTS // // MessageText: // // The specified transport mode filter already exists. // public static final int ERROR_IPSEC_TRANSPORT_FILTER_EXISTS = 13008; // // MessageId: ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND // // MessageText: // // The specified transport mode filter does not exist. // public static final int ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND = 13009; // // MessageId: ERROR_IPSEC_MM_AUTH_EXISTS // // MessageText: // // The specified main mode authentication list exists. // public static final int ERROR_IPSEC_MM_AUTH_EXISTS = 13010; // // MessageId: ERROR_IPSEC_MM_AUTH_NOT_FOUND // // MessageText: // // The specified main mode authentication list was not found. // public static final int ERROR_IPSEC_MM_AUTH_NOT_FOUND = 13011; // // MessageId: ERROR_IPSEC_MM_AUTH_IN_USE // // MessageText: // // The specified main mode authentication list is being used. // public static final int ERROR_IPSEC_MM_AUTH_IN_USE = 13012; // // MessageId: ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND // // MessageText: // // The specified default main mode policy was not found. // public static final int ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND = 13013; // // MessageId: ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND // // MessageText: // // The specified default main mode authentication list was not found. // public static final int ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND = 13014; // // MessageId: ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND // // MessageText: // // The specified default quick mode policy was not found. // public static final int ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND = 13015; // // MessageId: ERROR_IPSEC_TUNNEL_FILTER_EXISTS // // MessageText: // // The specified tunnel mode filter exists. // public static final int ERROR_IPSEC_TUNNEL_FILTER_EXISTS = 13016; // // MessageId: ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND // // MessageText: // // The specified tunnel mode filter was not found. // public static final int ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND = 13017; // // MessageId: ERROR_IPSEC_MM_FILTER_PENDING_DELETION // // MessageText: // // The Main Mode filter is pending deletion. // public static final int ERROR_IPSEC_MM_FILTER_PENDING_DELETION = 13018; // // MessageId: ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION // // MessageText: // // The transport filter is pending deletion. // public static final int ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION = 13019; // // MessageId: ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION // // MessageText: // // The tunnel filter is pending deletion. // public static final int ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION = 13020; // // MessageId: ERROR_IPSEC_MM_POLICY_PENDING_DELETION // // MessageText: // // The Main Mode policy is pending deletion. // public static final int ERROR_IPSEC_MM_POLICY_PENDING_DELETION = 13021; // // MessageId: ERROR_IPSEC_MM_AUTH_PENDING_DELETION // // MessageText: // // The Main Mode authentication bundle is pending deletion. // public static final int ERROR_IPSEC_MM_AUTH_PENDING_DELETION = 13022; // // MessageId: ERROR_IPSEC_QM_POLICY_PENDING_DELETION // // MessageText: // // The Quick Mode policy is pending deletion. // public static final int ERROR_IPSEC_QM_POLICY_PENDING_DELETION = 13023; // // MessageId: WARNING_IPSEC_MM_POLICY_PRUNED // // MessageText: // // The Main Mode policy was successfully added, but some of the requested // offers are not supported. // public static final int WARNING_IPSEC_MM_POLICY_PRUNED = 13024; // // MessageId: WARNING_IPSEC_QM_POLICY_PRUNED // // MessageText: // // The Quick Mode policy was successfully added, but some of the requested // offers are not supported. // public static final int WARNING_IPSEC_QM_POLICY_PRUNED = 13025; // // MessageId: ERROR_IPSEC_IKE_NEG_STATUS_BEGIN // // MessageText: // // ERROR_IPSEC_IKE_NEG_STATUS_BEGIN // public static final int ERROR_IPSEC_IKE_NEG_STATUS_BEGIN = 13800; // // MessageId: ERROR_IPSEC_IKE_AUTH_FAIL // // MessageText: // // IKE authentication credentials are unacceptable // public static final int ERROR_IPSEC_IKE_AUTH_FAIL = 13801; // // MessageId: ERROR_IPSEC_IKE_ATTRIB_FAIL // // MessageText: // // IKE security attributes are unacceptable // public static final int ERROR_IPSEC_IKE_ATTRIB_FAIL = 13802; // // MessageId: ERROR_IPSEC_IKE_NEGOTIATION_PENDING // // MessageText: // // IKE Negotiation in progress // public static final int ERROR_IPSEC_IKE_NEGOTIATION_PENDING = 13803; // // MessageId: ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR // // MessageText: // // General processing error // public static final int ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR = 13804; // // MessageId: ERROR_IPSEC_IKE_TIMED_OUT // // MessageText: // // Negotiation timed out // public static final int ERROR_IPSEC_IKE_TIMED_OUT = 13805; // // MessageId: ERROR_IPSEC_IKE_NO_CERT // // MessageText: // // IKE failed to find valid machine certificate. Contact your Network // Security Administrator about installing a valid certificate in the // appropriate Certificate Store. // public static final int ERROR_IPSEC_IKE_NO_CERT = 13806; // // MessageId: ERROR_IPSEC_IKE_SA_DELETED // // MessageText: // // IKE SA deleted by peer before establishment completed // public static final int ERROR_IPSEC_IKE_SA_DELETED = 13807; // // MessageId: ERROR_IPSEC_IKE_SA_REAPED // // MessageText: // // IKE SA deleted before establishment completed // public static final int ERROR_IPSEC_IKE_SA_REAPED = 13808; // // MessageId: ERROR_IPSEC_IKE_MM_ACQUIRE_DROP // // MessageText: // // Negotiation request sat in Queue too long // public static final int ERROR_IPSEC_IKE_MM_ACQUIRE_DROP = 13809; // // MessageId: ERROR_IPSEC_IKE_QM_ACQUIRE_DROP // // MessageText: // // Negotiation request sat in Queue too long // public static final int ERROR_IPSEC_IKE_QM_ACQUIRE_DROP = 13810; // // MessageId: ERROR_IPSEC_IKE_QUEUE_DROP_MM // // MessageText: // // Negotiation request sat in Queue too long // public static final int ERROR_IPSEC_IKE_QUEUE_DROP_MM = 13811; // // MessageId: ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM // // MessageText: // // Negotiation request sat in Queue too long // public static final int ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM = 13812; // // MessageId: ERROR_IPSEC_IKE_DROP_NO_RESPONSE // // MessageText: // // No response from peer // public static final int ERROR_IPSEC_IKE_DROP_NO_RESPONSE = 13813; // // MessageId: ERROR_IPSEC_IKE_MM_DELAY_DROP // // MessageText: // // Negotiation took too long // public static final int ERROR_IPSEC_IKE_MM_DELAY_DROP = 13814; // // MessageId: ERROR_IPSEC_IKE_QM_DELAY_DROP // // MessageText: // // Negotiation took too long // public static final int ERROR_IPSEC_IKE_QM_DELAY_DROP = 13815; // // MessageId: ERROR_IPSEC_IKE_ERROR // // MessageText: // // Unknown error occurred // public static final int ERROR_IPSEC_IKE_ERROR = 13816; // // MessageId: ERROR_IPSEC_IKE_CRL_FAILED // // MessageText: // // Certificate Revocation Check failed // public static final int ERROR_IPSEC_IKE_CRL_FAILED = 13817; // // MessageId: ERROR_IPSEC_IKE_INVALID_KEY_USAGE // // MessageText: // // Invalid certificate key usage // public static final int ERROR_IPSEC_IKE_INVALID_KEY_USAGE = 13818; // // MessageId: ERROR_IPSEC_IKE_INVALID_CERT_TYPE // // MessageText: // // Invalid certificate type // public static final int ERROR_IPSEC_IKE_INVALID_CERT_TYPE = 13819; // // MessageId: ERROR_IPSEC_IKE_NO_PRIVATE_KEY // // MessageText: // // IKE negotiation failed because the machine certificate used does not have // a private key. IPsec certificates require a private key. Contact your // Network Security administrator about replacing with a certificate that // has a private key. // public static final int ERROR_IPSEC_IKE_NO_PRIVATE_KEY = 13820; // // MessageId: ERROR_IPSEC_IKE_DH_FAIL // // MessageText: // // Failure in Diffie-Helman computation // public static final int ERROR_IPSEC_IKE_DH_FAIL = 13822; // // MessageId: ERROR_IPSEC_IKE_INVALID_HEADER // // MessageText: // // Invalid header // public static final int ERROR_IPSEC_IKE_INVALID_HEADER = 13824; // // MessageId: ERROR_IPSEC_IKE_NO_POLICY // // MessageText: // // No policy configured // public static final int ERROR_IPSEC_IKE_NO_POLICY = 13825; // // MessageId: ERROR_IPSEC_IKE_INVALID_SIGNATURE // // MessageText: // // Failed to verify signature // public static final int ERROR_IPSEC_IKE_INVALID_SIGNATURE = 13826; // // MessageId: ERROR_IPSEC_IKE_KERBEROS_ERROR // // MessageText: // // Failed to authenticate using kerberos // public static final int ERROR_IPSEC_IKE_KERBEROS_ERROR = 13827; // // MessageId: ERROR_IPSEC_IKE_NO_PUBLIC_KEY // // MessageText: // // Peer's certificate did not have a public key // public static final int ERROR_IPSEC_IKE_NO_PUBLIC_KEY = 13828; // These must stay as a unit. // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR // // MessageText: // // Error processing error payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR = 13829; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_SA // // MessageText: // // Error processing SA payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_SA = 13830; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_PROP // // MessageText: // // Error processing Proposal payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_PROP = 13831; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_TRANS // // MessageText: // // Error processing Transform payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_TRANS = 13832; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_KE // // MessageText: // // Error processing KE payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_KE = 13833; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_ID // // MessageText: // // Error processing ID payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_ID = 13834; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_CERT // // MessageText: // // Error processing Cert payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_CERT = 13835; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ // // MessageText: // // Error processing Certificate Request payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ = 13836; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_HASH // // MessageText: // // Error processing Hash payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_HASH = 13837; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_SIG // // MessageText: // // Error processing Signature payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_SIG = 13838; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_NONCE // // MessageText: // // Error processing Nonce payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_NONCE = 13839; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY // // MessageText: // // Error processing Notify payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY = 13840; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_DELETE // // MessageText: // // Error processing Delete Payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_DELETE = 13841; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR // // MessageText: // // Error processing VendorId payload // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR = 13842; // // MessageId: ERROR_IPSEC_IKE_INVALID_PAYLOAD // // MessageText: // // Invalid payload received // public static final int ERROR_IPSEC_IKE_INVALID_PAYLOAD = 13843; // // MessageId: ERROR_IPSEC_IKE_LOAD_SOFT_SA // // MessageText: // // Soft SA loaded // public static final int ERROR_IPSEC_IKE_LOAD_SOFT_SA = 13844; // // MessageId: ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN // // MessageText: // // Soft SA torn down // public static final int ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN = 13845; // // MessageId: ERROR_IPSEC_IKE_INVALID_COOKIE // // MessageText: // // Invalid cookie received. // public static final int ERROR_IPSEC_IKE_INVALID_COOKIE = 13846; // // MessageId: ERROR_IPSEC_IKE_NO_PEER_CERT // // MessageText: // // Peer failed to send valid machine certificate // public static final int ERROR_IPSEC_IKE_NO_PEER_CERT = 13847; // // MessageId: ERROR_IPSEC_IKE_PEER_CRL_FAILED // // MessageText: // // Certification Revocation check of peer's certificate failed // public static final int ERROR_IPSEC_IKE_PEER_CRL_FAILED = 13848; // // MessageId: ERROR_IPSEC_IKE_POLICY_CHANGE // // MessageText: // // New policy invalidated SAs formed with old policy // public static final int ERROR_IPSEC_IKE_POLICY_CHANGE = 13849; // // MessageId: ERROR_IPSEC_IKE_NO_MM_POLICY // // MessageText: // // There is no available Main Mode IKE policy. // public static final int ERROR_IPSEC_IKE_NO_MM_POLICY = 13850; // // MessageId: ERROR_IPSEC_IKE_NOTCBPRIV // // MessageText: // // Failed to enabled TCB privilege. // public static final int ERROR_IPSEC_IKE_NOTCBPRIV = 13851; // // MessageId: ERROR_IPSEC_IKE_SECLOADFAIL // // MessageText: // // Failed to load SECURITY.DLL. // public static final int ERROR_IPSEC_IKE_SECLOADFAIL = 13852; // // MessageId: ERROR_IPSEC_IKE_FAILSSPINIT // // MessageText: // // Failed to obtain security function table dispatch address from SSPI. // public static final int ERROR_IPSEC_IKE_FAILSSPINIT = 13853; // // MessageId: ERROR_IPSEC_IKE_FAILQUERYSSP // // MessageText: // // Failed to query Kerberos package to obtain max token size. // public static final int ERROR_IPSEC_IKE_FAILQUERYSSP = 13854; // // MessageId: ERROR_IPSEC_IKE_SRVACQFAIL // // MessageText: // // Failed to obtain Kerberos server credentials for ISAKMP/ERROR_IPSEC_IKE // service. Kerberos authentication will not function. The most likely // reason for this is lack of domain membership. This is normal if your // computer is a member of a workgroup. // public static final int ERROR_IPSEC_IKE_SRVACQFAIL = 13855; // // MessageId: ERROR_IPSEC_IKE_SRVQUERYCRED // // MessageText: // // Failed to determine SSPI principal name for ISAKMP/ERROR_IPSEC_IKE // service (QueryCredentialsAttributes). // public static final int ERROR_IPSEC_IKE_SRVQUERYCRED = 13856; // // MessageId: ERROR_IPSEC_IKE_GETSPIFAIL // // MessageText: // // Failed to obtain new SPI for the inbound SA from Ipsec driver. The most // common cause for this is that the driver does not have the correct // filter. Check your policy to verify the filters. // public static final int ERROR_IPSEC_IKE_GETSPIFAIL = 13857; // // MessageId: ERROR_IPSEC_IKE_INVALID_FILTER // // MessageText: // // Given filter is invalid // public static final int ERROR_IPSEC_IKE_INVALID_FILTER = 13858; // // MessageId: ERROR_IPSEC_IKE_OUT_OF_MEMORY // // MessageText: // // Memory allocation failed. // public static final int ERROR_IPSEC_IKE_OUT_OF_MEMORY = 13859; // // MessageId: ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED // // MessageText: // // Failed to add Security Association to IPSec Driver. The most common cause // for this is if the IKE negotiation took too long to complete. If the // problem persists, reduce the load on the faulting machine. // public static final int ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED = 13860; // // MessageId: ERROR_IPSEC_IKE_INVALID_POLICY // // MessageText: // // Invalid policy // public static final int ERROR_IPSEC_IKE_INVALID_POLICY = 13861; // // MessageId: ERROR_IPSEC_IKE_UNKNOWN_DOI // // MessageText: // // Invalid DOI // public static final int ERROR_IPSEC_IKE_UNKNOWN_DOI = 13862; // // MessageId: ERROR_IPSEC_IKE_INVALID_SITUATION // // MessageText: // // Invalid situation // public static final int ERROR_IPSEC_IKE_INVALID_SITUATION = 13863; // // MessageId: ERROR_IPSEC_IKE_DH_FAILURE // // MessageText: // // Diffie-Hellman failure // public static final int ERROR_IPSEC_IKE_DH_FAILURE = 13864; // // MessageId: ERROR_IPSEC_IKE_INVALID_GROUP // // MessageText: // // Invalid Diffie-Hellman group // public static final int ERROR_IPSEC_IKE_INVALID_GROUP = 13865; // // MessageId: ERROR_IPSEC_IKE_ENCRYPT // // MessageText: // // Error encrypting payload // public static final int ERROR_IPSEC_IKE_ENCRYPT = 13866; // // MessageId: ERROR_IPSEC_IKE_DECRYPT // // MessageText: // // Error decrypting payload // public static final int ERROR_IPSEC_IKE_DECRYPT = 13867; // // MessageId: ERROR_IPSEC_IKE_POLICY_MATCH // // MessageText: // // Policy match error // public static final int ERROR_IPSEC_IKE_POLICY_MATCH = 13868; // // MessageId: ERROR_IPSEC_IKE_UNSUPPORTED_ID // // MessageText: // // Unsupported ID // public static final int ERROR_IPSEC_IKE_UNSUPPORTED_ID = 13869; // // MessageId: ERROR_IPSEC_IKE_INVALID_HASH // // MessageText: // // Hash verification failed // public static final int ERROR_IPSEC_IKE_INVALID_HASH = 13870; // // MessageId: ERROR_IPSEC_IKE_INVALID_HASH_ALG // // MessageText: // // Invalid hash algorithm // public static final int ERROR_IPSEC_IKE_INVALID_HASH_ALG = 13871; // // MessageId: ERROR_IPSEC_IKE_INVALID_HASH_SIZE // // MessageText: // // Invalid hash size // public static final int ERROR_IPSEC_IKE_INVALID_HASH_SIZE = 13872; // // MessageId: ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG // // MessageText: // // Invalid encryption algorithm // public static final int ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG = 13873; // // MessageId: ERROR_IPSEC_IKE_INVALID_AUTH_ALG // // MessageText: // // Invalid authentication algorithm // public static final int ERROR_IPSEC_IKE_INVALID_AUTH_ALG = 13874; // // MessageId: ERROR_IPSEC_IKE_INVALID_SIG // // MessageText: // // Invalid certificate signature // public static final int ERROR_IPSEC_IKE_INVALID_SIG = 13875; // // MessageId: ERROR_IPSEC_IKE_LOAD_FAILED // // MessageText: // // Load failed // public static final int ERROR_IPSEC_IKE_LOAD_FAILED = 13876; // // MessageId: ERROR_IPSEC_IKE_RPC_DELETE // // MessageText: // // Deleted via RPC call // public static final int ERROR_IPSEC_IKE_RPC_DELETE = 13877; // // MessageId: ERROR_IPSEC_IKE_BENIGN_REINIT // // MessageText: // // Temporary state created to perform reinit. This is not a real failure. // public static final int ERROR_IPSEC_IKE_BENIGN_REINIT = 13878; // // MessageId: ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY // // MessageText: // // The lifetime value received in the Responder Lifetime Notify is below the // Windows=2000 configured minimum value. Please fix the policy on the peer // machine. // public static final int ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY = 13879; // // MessageId: ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN // // MessageText: // // Key length in certificate is too small for configured security // requirements. // public static final int ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN = 13881; // // MessageId: ERROR_IPSEC_IKE_MM_LIMIT // // MessageText: // // Max number of established MM SAs to peer exceeded. // public static final int ERROR_IPSEC_IKE_MM_LIMIT = 13882; // // MessageId: ERROR_IPSEC_IKE_NEGOTIATION_DISABLED // // MessageText: // // IKE received a policy that disables negotiation. // public static final int ERROR_IPSEC_IKE_NEGOTIATION_DISABLED = 13883; // // MessageId: ERROR_IPSEC_IKE_QM_LIMIT // // MessageText: // // Reached maximum quick mode limit for the main mode. New main mode will be // started. // public static final int ERROR_IPSEC_IKE_QM_LIMIT = 13884; // // MessageId: ERROR_IPSEC_IKE_MM_EXPIRED // // MessageText: // // Main mode SA lifetime expired or peer sent a main mode delete. // public static final int ERROR_IPSEC_IKE_MM_EXPIRED = 13885; // // MessageId: ERROR_IPSEC_IKE_PEER_MM_ASSUMED_INVALID // // MessageText: // // Main mode SA assumed to be invalid because peer stopped responding. // public static final int ERROR_IPSEC_IKE_PEER_MM_ASSUMED_INVALID = 13886; // // MessageId: ERROR_IPSEC_IKE_CERT_CHAIN_POLICY_MISMATCH // // MessageText: // // Certificate doesn't chain to a trusted root in IPsec policy. // public static final int ERROR_IPSEC_IKE_CERT_CHAIN_POLICY_MISMATCH = 13887; // // MessageId: ERROR_IPSEC_IKE_UNEXPECTED_MESSAGE_ID // // MessageText: // // Received unexpected message ID. // public static final int ERROR_IPSEC_IKE_UNEXPECTED_MESSAGE_ID = 13888; // // MessageId: ERROR_IPSEC_IKE_INVALID_AUTH_PAYLOAD // // MessageText: // // Received invalid authentication offers. // public static final int ERROR_IPSEC_IKE_INVALID_AUTH_PAYLOAD = 13889; // // MessageId: ERROR_IPSEC_IKE_DOS_COOKIE_SENT // // MessageText: // // Sent DOS cookie notify to intiator. // public static final int ERROR_IPSEC_IKE_DOS_COOKIE_SENT = 13890; // // MessageId: ERROR_IPSEC_IKE_SHUTTING_DOWN // // MessageText: // // IKE service is shutting down. // public static final int ERROR_IPSEC_IKE_SHUTTING_DOWN = 13891; // // MessageId: ERROR_IPSEC_IKE_CGA_AUTH_FAILED // // MessageText: // // Could not verify binding between CGA address and certificate. // public static final int ERROR_IPSEC_IKE_CGA_AUTH_FAILED = 13892; // // MessageId: ERROR_IPSEC_IKE_PROCESS_ERR_NATOA // // MessageText: // // Error processing NatOA payload. // public static final int ERROR_IPSEC_IKE_PROCESS_ERR_NATOA = 13893; // // MessageId: ERROR_IPSEC_IKE_INVALID_MM_FOR_QM // // MessageText: // // Parameters of the main mode are invalid for this quick mode. // public static final int ERROR_IPSEC_IKE_INVALID_MM_FOR_QM = 13894; // // MessageId: ERROR_IPSEC_IKE_QM_EXPIRED // // MessageText: // // Quick mode SA was expired by IPsec driver. // public static final int ERROR_IPSEC_IKE_QM_EXPIRED = 13895; // // MessageId: ERROR_IPSEC_IKE_TOO_MANY_FILTERS // // MessageText: // // Too many dynamically added IKEEXT filters were detected. // public static final int ERROR_IPSEC_IKE_TOO_MANY_FILTERS = 13896; // // MessageId: ERROR_IPSEC_IKE_NEG_STATUS_END // // MessageText: // // ERROR_IPSEC_IKE_NEG_STATUS_END // public static final int ERROR_IPSEC_IKE_NEG_STATUS_END = 13897; // // Following error codes are returned by IPsec kernel. // // // MessageId: ERROR_IPSEC_BAD_SPI // // MessageText: // // The SPI in the packet does not match a valid IPsec SA. // public static final int ERROR_IPSEC_BAD_SPI = 13910; // // MessageId: ERROR_IPSEC_SA_LIFETIME_EXPIRED // // MessageText: // // Packet was received on an IPsec SA whose lifetime has expired. // public static final int ERROR_IPSEC_SA_LIFETIME_EXPIRED = 13911; // // MessageId: ERROR_IPSEC_WRONG_SA // // MessageText: // // Packet was received on an IPsec SA that doesn't match the packet // characteristics. // public static final int ERROR_IPSEC_WRONG_SA = 13912; // // MessageId: ERROR_IPSEC_REPLAY_CHECK_FAILED // // MessageText: // // Packet sequence number replay check failed. // public static final int ERROR_IPSEC_REPLAY_CHECK_FAILED = 13913; // // MessageId: ERROR_IPSEC_INVALID_PACKET // // MessageText: // // IPsec header and/or trailer in the packet is invalid. // public static final int ERROR_IPSEC_INVALID_PACKET = 13914; // // MessageId: ERROR_IPSEC_INTEGRITY_CHECK_FAILED // // MessageText: // // IPsec integrity check failed. // public static final int ERROR_IPSEC_INTEGRITY_CHECK_FAILED = 13915; // // MessageId: ERROR_IPSEC_CLEAR_TEXT_DROP // // MessageText: // // IPsec dropped a clear text packet. // public static final int ERROR_IPSEC_CLEAR_TEXT_DROP = 13916; // ///////////////////////////////////////////////// // =// // =End of IPSec Error codes=// // =// // =13000 to=13999=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =Start of Side By Side Error Codes // // =// // =14000 to=14999=// // ///////////////////////////////////////////////// // // MessageId: ERROR_SXS_SECTION_NOT_FOUND // // MessageText: // // The requested section was not present in the activation context. // public static final int ERROR_SXS_SECTION_NOT_FOUND = 14000; // // MessageId: ERROR_SXS_CANT_GEN_ACTCTX // // MessageText: // // The application has failed to start because its side-by-side // configuration is incorrect. Please see the application event log for more // detail. // public static final int ERROR_SXS_CANT_GEN_ACTCTX = 14001; // // MessageId: ERROR_SXS_INVALID_ACTCTXDATA_FORMAT // // MessageText: // // The application binding data format is invalid. // public static final int ERROR_SXS_INVALID_ACTCTXDATA_FORMAT = 14002; // // MessageId: ERROR_SXS_ASSEMBLY_NOT_FOUND // // MessageText: // // The referenced assembly is not installed on your system. // public static final int ERROR_SXS_ASSEMBLY_NOT_FOUND = 14003; // // MessageId: ERROR_SXS_MANIFEST_FORMAT_ERROR // // MessageText: // // The manifest file does not begin with the required tag and format // information. // public static final int ERROR_SXS_MANIFEST_FORMAT_ERROR = 14004; // // MessageId: ERROR_SXS_MANIFEST_PARSE_ERROR // // MessageText: // // The manifest file contains one or more syntax errors. // public static final int ERROR_SXS_MANIFEST_PARSE_ERROR = 14005; // // MessageId: ERROR_SXS_ACTIVATION_CONTEXT_DISABLED // // MessageText: // // The application attempted to activate a disabled activation context. // public static final int ERROR_SXS_ACTIVATION_CONTEXT_DISABLED = 14006; // // MessageId: ERROR_SXS_KEY_NOT_FOUND // // MessageText: // // The requested lookup key was not found in any active activation context. // public static final int ERROR_SXS_KEY_NOT_FOUND = 14007; // // MessageId: ERROR_SXS_VERSION_CONFLICT // // MessageText: // // A component version required by the application conflicts with another // component version already active. // public static final int ERROR_SXS_VERSION_CONFLICT = 14008; // // MessageId: ERROR_SXS_WRONG_SECTION_TYPE // // MessageText: // // The type requested activation context section does not match the query // API used. // public static final int ERROR_SXS_WRONG_SECTION_TYPE = 14009; // // MessageId: ERROR_SXS_THREAD_QUERIES_DISABLED // // MessageText: // // Lack of system resources has required isolated activation to be disabled // for the current thread of execution. // public static final int ERROR_SXS_THREAD_QUERIES_DISABLED = 14010; // // MessageId: ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET // // MessageText: // // An attempt to set the process default activation context failed because // the process default activation context was already set. // public static final int ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET = 14011; // // MessageId: ERROR_SXS_UNKNOWN_ENCODING_GROUP // // MessageText: // // The encoding group identifier specified is not recognized. // public static final int ERROR_SXS_UNKNOWN_ENCODING_GROUP = 14012; // // MessageId: ERROR_SXS_UNKNOWN_ENCODING // // MessageText: // // The encoding requested is not recognized. // public static final int ERROR_SXS_UNKNOWN_ENCODING = 14013; // // MessageId: ERROR_SXS_INVALID_XML_NAMESPACE_URI // // MessageText: // // The manifest contains a reference to an invalid URI. // public static final int ERROR_SXS_INVALID_XML_NAMESPACE_URI = 14014; // // MessageId: ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED // // MessageText: // // The application manifest contains a reference to a dependent assembly // which is not installed // public static final int ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED = 14015; // // MessageId: ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED // // MessageText: // // The manifest for an assembly used by the application has a reference to a // dependent assembly which is not installed // public static final int ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED = 14016; // // MessageId: ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE // // MessageText: // // The manifest contains an attribute for the assembly identity which is not // valid. // public static final int ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE = 14017; // // MessageId: ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE // // MessageText: // // The manifest is missing the required default namespace specification on // the assembly element. // public static final int ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE = 14018; // // MessageId: ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE // // MessageText: // // The manifest has a default namespace specified on the assembly element // but its value is not "urn:schemas-microsoft-com:asm.v1". // public static final int ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE = 14019; // // MessageId: ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT // // MessageText: // // The private manifest probed has crossed reparse-point-associated path // public static final int ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT = 14020; // // MessageId: ERROR_SXS_DUPLICATE_DLL_NAME // // MessageText: // // Two or more components referenced directly or indirectly by the // application manifest have files by the same name. // public static final int ERROR_SXS_DUPLICATE_DLL_NAME = 14021; // // MessageId: ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME // // MessageText: // // Two or more components referenced directly or indirectly by the // application manifest have window classes with the same name. // public static final int ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME = 14022; // // MessageId: ERROR_SXS_DUPLICATE_CLSID // // MessageText: // // Two or more components referenced directly or indirectly by the // application manifest have the same COM server CLSIDs. // public static final int ERROR_SXS_DUPLICATE_CLSID = 14023; // // MessageId: ERROR_SXS_DUPLICATE_IID // // MessageText: // // Two or more components referenced directly or indirectly by the // application manifest have proxies for the same COM interface IIDs. // public static final int ERROR_SXS_DUPLICATE_IID = 14024; // // MessageId: ERROR_SXS_DUPLICATE_TLBID // // MessageText: // // Two or more components referenced directly or indirectly by the // application manifest have the same COM type library TLBIDs. // public static final int ERROR_SXS_DUPLICATE_TLBID = 14025; // // MessageId: ERROR_SXS_DUPLICATE_PROGID // // MessageText: // // Two or more components referenced directly or indirectly by the // application manifest have the same COM ProgIDs. // public static final int ERROR_SXS_DUPLICATE_PROGID = 14026; // // MessageId: ERROR_SXS_DUPLICATE_ASSEMBLY_NAME // // MessageText: // // Two or more components referenced directly or indirectly by the // application manifest are different versions of the same component which // is not permitted. // public static final int ERROR_SXS_DUPLICATE_ASSEMBLY_NAME = 14027; // // MessageId: ERROR_SXS_FILE_HASH_MISMATCH // // MessageText: // // A component's file does not match the verification information present in // the component manifest. // public static final int ERROR_SXS_FILE_HASH_MISMATCH = 14028; // // MessageId: ERROR_SXS_POLICY_PARSE_ERROR // // MessageText: // // The policy manifest contains one or more syntax errors. // public static final int ERROR_SXS_POLICY_PARSE_ERROR = 14029; // // MessageId: ERROR_SXS_XML_E_MISSINGQUOTE // // MessageText: // // Manifest Parse Error : A string literal was expected, but no opening // quote character was found. // public static final int ERROR_SXS_XML_E_MISSINGQUOTE = 14030; // // MessageId: ERROR_SXS_XML_E_COMMENTSYNTAX // // MessageText: // // Manifest Parse Error : Incorrect syntax was used in a comment. // public static final int ERROR_SXS_XML_E_COMMENTSYNTAX = 14031; // // MessageId: ERROR_SXS_XML_E_BADSTARTNAMECHAR // // MessageText: // // Manifest Parse Error : A name was started with an invalid character. // public static final int ERROR_SXS_XML_E_BADSTARTNAMECHAR = 14032; // // MessageId: ERROR_SXS_XML_E_BADNAMECHAR // // MessageText: // // Manifest Parse Error : A name contained an invalid character. // public static final int ERROR_SXS_XML_E_BADNAMECHAR = 14033; // // MessageId: ERROR_SXS_XML_E_BADCHARINSTRING // // MessageText: // // Manifest Parse Error : A string literal contained an invalid character. // public static final int ERROR_SXS_XML_E_BADCHARINSTRING = 14034; // // MessageId: ERROR_SXS_XML_E_XMLDECLSYNTAX // // MessageText: // // Manifest Parse Error : Invalid syntax for an xml declaration. // public static final int ERROR_SXS_XML_E_XMLDECLSYNTAX = 14035; // // MessageId: ERROR_SXS_XML_E_BADCHARDATA // // MessageText: // // Manifest Parse Error : An Invalid character was found in text content. // public static final int ERROR_SXS_XML_E_BADCHARDATA = 14036; // // MessageId: ERROR_SXS_XML_E_MISSINGWHITESPACE // // MessageText: // // Manifest Parse Error : Required white space was missing. // public static final int ERROR_SXS_XML_E_MISSINGWHITESPACE = 14037; // // MessageId: ERROR_SXS_XML_E_EXPECTINGTAGEND // // MessageText: // // Manifest Parse Error : The character '>' was expected. // public static final int ERROR_SXS_XML_E_EXPECTINGTAGEND = 14038; // // MessageId: ERROR_SXS_XML_E_MISSINGSEMICOLON // // MessageText: // // Manifest Parse Error : A semi colon character was expected. // public static final int ERROR_SXS_XML_E_MISSINGSEMICOLON = 14039; // // MessageId: ERROR_SXS_XML_E_UNBALANCEDPAREN // // MessageText: // // Manifest Parse Error : Unbalanced parentheses. // public static final int ERROR_SXS_XML_E_UNBALANCEDPAREN = 14040; // // MessageId: ERROR_SXS_XML_E_INTERNALERROR // // MessageText: // // Manifest Parse Error : Internal error. // public static final int ERROR_SXS_XML_E_INTERNALERROR = 14041; // // MessageId: ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE // // MessageText: // // Manifest Parse Error : Whitespace is not allowed at this location. // public static final int ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE = 14042; // // MessageId: ERROR_SXS_XML_E_INCOMPLETE_ENCODING // // MessageText: // // Manifest Parse Error : End of file reached in invalid state for current // encoding. // public static final int ERROR_SXS_XML_E_INCOMPLETE_ENCODING = 14043; // // MessageId: ERROR_SXS_XML_E_MISSING_PAREN // // MessageText: // // Manifest Parse Error : Missing parenthesis. // public static final int ERROR_SXS_XML_E_MISSING_PAREN = 14044; // // MessageId: ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE // // MessageText: // // Manifest Parse Error : A single or double closing quote character (\' or // \") is missing. // public static final int ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE = 14045; // // MessageId: ERROR_SXS_XML_E_MULTIPLE_COLONS // // MessageText: // // Manifest Parse Error : Multiple colons are not allowed in a name. // public static final int ERROR_SXS_XML_E_MULTIPLE_COLONS = 14046; // // MessageId: ERROR_SXS_XML_E_INVALID_DECIMAL // // MessageText: // // Manifest Parse Error : Invalid character for decimal digit. // public static final int ERROR_SXS_XML_E_INVALID_DECIMAL = 14047; // // MessageId: ERROR_SXS_XML_E_INVALID_HEXIDECIMAL // // MessageText: // // Manifest Parse Error : Invalid character for hexidecimal digit. // public static final int ERROR_SXS_XML_E_INVALID_HEXIDECIMAL = 14048; // // MessageId: ERROR_SXS_XML_E_INVALID_UNICODE // // MessageText: // // Manifest Parse Error : Invalid unicode character value for this platform. // public static final int ERROR_SXS_XML_E_INVALID_UNICODE = 14049; // // MessageId: ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK // // MessageText: // // Manifest Parse Error : Expecting whitespace or '?'. // public static final int ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK = 14050; // // MessageId: ERROR_SXS_XML_E_UNEXPECTEDENDTAG // // MessageText: // // Manifest Parse Error : End tag was not expected at this location. // public static final int ERROR_SXS_XML_E_UNEXPECTEDENDTAG = 14051; // // MessageId: ERROR_SXS_XML_E_UNCLOSEDTAG // // MessageText: // // Manifest Parse Error : The following tags were not closed: %1. // public static final int ERROR_SXS_XML_E_UNCLOSEDTAG = 14052; // // MessageId: ERROR_SXS_XML_E_DUPLICATEATTRIBUTE // // MessageText: // // Manifest Parse Error : Duplicate attribute. // public static final int ERROR_SXS_XML_E_DUPLICATEATTRIBUTE = 14053; // // MessageId: ERROR_SXS_XML_E_MULTIPLEROOTS // // MessageText: // // Manifest Parse Error : Only one top level element is allowed in an XML // document. // public static final int ERROR_SXS_XML_E_MULTIPLEROOTS = 14054; // // MessageId: ERROR_SXS_XML_E_INVALIDATROOTLEVEL // // MessageText: // // Manifest Parse Error : Invalid at the top level of the document. // public static final int ERROR_SXS_XML_E_INVALIDATROOTLEVEL = 14055; // // MessageId: ERROR_SXS_XML_E_BADXMLDECL // // MessageText: // // Manifest Parse Error : Invalid xml declaration. // public static final int ERROR_SXS_XML_E_BADXMLDECL = 14056; // // MessageId: ERROR_SXS_XML_E_MISSINGROOT // // MessageText: // // Manifest Parse Error : XML document must have a top level element. // public static final int ERROR_SXS_XML_E_MISSINGROOT = 14057; // // MessageId: ERROR_SXS_XML_E_UNEXPECTEDEOF // // MessageText: // // Manifest Parse Error : Unexpected end of file. // public static final int ERROR_SXS_XML_E_UNEXPECTEDEOF = 14058; // // MessageId: ERROR_SXS_XML_E_BADPEREFINSUBSET // // MessageText: // // Manifest Parse Error : Parameter entities cannot be used inside markup // declarations in an internal subset. // public static final int ERROR_SXS_XML_E_BADPEREFINSUBSET = 14059; // // MessageId: ERROR_SXS_XML_E_UNCLOSEDSTARTTAG // // MessageText: // // Manifest Parse Error : Element was not closed. // public static final int ERROR_SXS_XML_E_UNCLOSEDSTARTTAG = 14060; // // MessageId: ERROR_SXS_XML_E_UNCLOSEDENDTAG // // MessageText: // // Manifest Parse Error : End element was missing the character '>'. // public static final int ERROR_SXS_XML_E_UNCLOSEDENDTAG = 14061; // // MessageId: ERROR_SXS_XML_E_UNCLOSEDSTRING // // MessageText: // // Manifest Parse Error : A string literal was not closed. // public static final int ERROR_SXS_XML_E_UNCLOSEDSTRING = 14062; // // MessageId: ERROR_SXS_XML_E_UNCLOSEDCOMMENT // // MessageText: // // Manifest Parse Error : A comment was not closed. // public static final int ERROR_SXS_XML_E_UNCLOSEDCOMMENT = 14063; // // MessageId: ERROR_SXS_XML_E_UNCLOSEDDECL // // MessageText: // // Manifest Parse Error : A declaration was not closed. // public static final int ERROR_SXS_XML_E_UNCLOSEDDECL = 14064; // // MessageId: ERROR_SXS_XML_E_UNCLOSEDCDATA // // MessageText: // // Manifest Parse Error : A CDATA section was not closed. // public static final int ERROR_SXS_XML_E_UNCLOSEDCDATA = 14065; // // MessageId: ERROR_SXS_XML_E_RESERVEDNAMESPACE // // MessageText: // // Manifest Parse Error : The namespace prefix is not allowed to start with // the reserved string "xml". // public static final int ERROR_SXS_XML_E_RESERVEDNAMESPACE = 14066; // // MessageId: ERROR_SXS_XML_E_INVALIDENCODING // // MessageText: // // Manifest Parse Error : System does not support the specified encoding. // public static final int ERROR_SXS_XML_E_INVALIDENCODING = 14067; // // MessageId: ERROR_SXS_XML_E_INVALIDSWITCH // // MessageText: // // Manifest Parse Error : Switch from current encoding to specified encoding // not supported. // public static final int ERROR_SXS_XML_E_INVALIDSWITCH = 14068; // // MessageId: ERROR_SXS_XML_E_BADXMLCASE // // MessageText: // // Manifest Parse Error : The name 'xml' is reserved and must be lower case. // public static final int ERROR_SXS_XML_E_BADXMLCASE = 14069; // // MessageId: ERROR_SXS_XML_E_INVALID_STANDALONE // // MessageText: // // Manifest Parse Error : The standalone attribute must have the value 'yes' // or 'no'. // public static final int ERROR_SXS_XML_E_INVALID_STANDALONE = 14070; // // MessageId: ERROR_SXS_XML_E_UNEXPECTED_STANDALONE // // MessageText: // // Manifest Parse Error : The standalone attribute cannot be used in // external entities. // public static final int ERROR_SXS_XML_E_UNEXPECTED_STANDALONE = 14071; // // MessageId: ERROR_SXS_XML_E_INVALID_VERSION // // MessageText: // // Manifest Parse Error : Invalid version number. // public static final int ERROR_SXS_XML_E_INVALID_VERSION = 14072; // // MessageId: ERROR_SXS_XML_E_MISSINGEQUALS // // MessageText: // // Manifest Parse Error : Missing equals sign between attribute and // attribute value. // public static final int ERROR_SXS_XML_E_MISSINGEQUALS = 14073; // // MessageId: ERROR_SXS_PROTECTION_RECOVERY_FAILED // // MessageText: // // Assembly Protection Error : Unable to recover the specified assembly. // public static final int ERROR_SXS_PROTECTION_RECOVERY_FAILED = 14074; // // MessageId: ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT // // MessageText: // // Assembly Protection Error : The public key for an assembly was too short // to be allowed. // public static final int ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT = 14075; // // MessageId: ERROR_SXS_PROTECTION_CATALOG_NOT_VALID // // MessageText: // // Assembly Protection Error : The catalog for an assembly is not valid, or // does not match the assembly's manifest. // public static final int ERROR_SXS_PROTECTION_CATALOG_NOT_VALID = 14076; // // MessageId: ERROR_SXS_UNTRANSLATABLE_HRESULT // // MessageText: // // An HRESULT could not be translated to a corresponding Win32 error code. // public static final int ERROR_SXS_UNTRANSLATABLE_HRESULT = 14077; // // MessageId: ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING // // MessageText: // // Assembly Protection Error : The catalog for an assembly is missing. // public static final int ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING = 14078; // // MessageId: ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE // // MessageText: // // The supplied assembly identity is missing one or more attributes which // must be present in this context. // public static final int ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE = 14079; // // MessageId: ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME // // MessageText: // // The supplied assembly identity has one or more attribute names that // contain characters not permitted in XML names. // public static final int ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME = 14080; // // MessageId: ERROR_SXS_ASSEMBLY_MISSING // // MessageText: // // The referenced assembly could not be found. // public static final int ERROR_SXS_ASSEMBLY_MISSING = 14081; // // MessageId: ERROR_SXS_CORRUPT_ACTIVATION_STACK // // MessageText: // // The activation context activation stack for the running thread of // execution is corrupt. // public static final int ERROR_SXS_CORRUPT_ACTIVATION_STACK = 14082; // // MessageId: ERROR_SXS_CORRUPTION // // MessageText: // // The application isolation metadata for this process or thread has become // corrupt. // public static final int ERROR_SXS_CORRUPTION = 14083; // // MessageId: ERROR_SXS_EARLY_DEACTIVATION // // MessageText: // // The activation context being deactivated is not the most recently // activated one. // public static final int ERROR_SXS_EARLY_DEACTIVATION = 14084; // // MessageId: ERROR_SXS_INVALID_DEACTIVATION // // MessageText: // // The activation context being deactivated is not active for the current // thread of execution. // public static final int ERROR_SXS_INVALID_DEACTIVATION = 14085; // // MessageId: ERROR_SXS_MULTIPLE_DEACTIVATION // // MessageText: // // The activation context being deactivated has already been deactivated. // public static final int ERROR_SXS_MULTIPLE_DEACTIVATION = 14086; // // MessageId: ERROR_SXS_PROCESS_TERMINATION_REQUESTED // // MessageText: // // A component used by the isolation facility has requested to terminate the // process. // public static final int ERROR_SXS_PROCESS_TERMINATION_REQUESTED = 14087; // // MessageId: ERROR_SXS_RELEASE_ACTIVATION_CONTEXT // // MessageText: // // A kernel mode component is releasing a reference on an activation // context. // public static final int ERROR_SXS_RELEASE_ACTIVATION_CONTEXT = 14088; // // MessageId: ERROR_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY // // MessageText: // // The activation context of system default assembly could not be generated. // public static final int ERROR_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY = 14089; // // MessageId: ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE // // MessageText: // // The value of an attribute in an identity is not within the legal range. // public static final int ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE = 14090; // // MessageId: ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME // // MessageText: // // The name of an attribute in an identity is not within the legal range. // public static final int ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME = 14091; // // MessageId: ERROR_SXS_IDENTITY_DUPLICATE_ATTRIBUTE // // MessageText: // // An identity contains two definitions for the same attribute. // public static final int ERROR_SXS_IDENTITY_DUPLICATE_ATTRIBUTE = 14092; // // MessageId: ERROR_SXS_IDENTITY_PARSE_ERROR // // MessageText: // // The identity string is malformed. This may be due to a trailing comma, // more than two unnamed attributes, missing attribute name or missing // attribute value. // public static final int ERROR_SXS_IDENTITY_PARSE_ERROR = 14093; // // MessageId: ERROR_MALFORMED_SUBSTITUTION_STRING // // MessageText: // // A string containing localized substitutable content was malformed. Either // a dollar sign ($) was follwed by something other than a left parenthesis // or another dollar sign or an substitution's right parenthesis was not // found. // public static final int ERROR_MALFORMED_SUBSTITUTION_STRING = 14094; // // MessageId: ERROR_SXS_INCORRECT_PUBLIC_KEY_TOKEN // // MessageText: // // The public key token does not correspond to the public key specified. // public static final int ERROR_SXS_INCORRECT_PUBLIC_KEY_TOKEN = 14095; // // MessageId: ERROR_UNMAPPED_SUBSTITUTION_STRING // // MessageText: // // A substitution string had no mapping. // public static final int ERROR_UNMAPPED_SUBSTITUTION_STRING = 14096; // // MessageId: ERROR_SXS_ASSEMBLY_NOT_LOCKED // // MessageText: // // The component must be locked before making the request. // public static final int ERROR_SXS_ASSEMBLY_NOT_LOCKED = 14097; // // MessageId: ERROR_SXS_COMPONENT_STORE_CORRUPT // // MessageText: // // The component store has been corrupted. // public static final int ERROR_SXS_COMPONENT_STORE_CORRUPT = 14098; // // MessageId: ERROR_ADVANCED_INSTALLER_FAILED // // MessageText: // // An advanced installer failed during setup or servicing. // public static final int ERROR_ADVANCED_INSTALLER_FAILED = 14099; // // MessageId: ERROR_XML_ENCODING_MISMATCH // // MessageText: // // The character encoding in the XML declaration did not match the encoding // used in the document. // public static final int ERROR_XML_ENCODING_MISMATCH = 14100; // // MessageId: ERROR_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT // // MessageText: // // The identities of the manifests are identical but their contents are // different. // public static final int ERROR_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT = 14101; // // MessageId: ERROR_SXS_IDENTITIES_DIFFERENT // // MessageText: // // The component identities are different. // public static final int ERROR_SXS_IDENTITIES_DIFFERENT = 14102; // // MessageId: ERROR_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT // // MessageText: // // The assembly is not a deployment. // public static final int ERROR_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT = 14103; // // MessageId: ERROR_SXS_FILE_NOT_PART_OF_ASSEMBLY // // MessageText: // // The file is not a part of the assembly. // public static final int ERROR_SXS_FILE_NOT_PART_OF_ASSEMBLY = 14104; // // MessageId: ERROR_SXS_MANIFEST_TOO_BIG // // MessageText: // // The size of the manifest exceeds the maximum allowed. // public static final int ERROR_SXS_MANIFEST_TOO_BIG = 14105; // // MessageId: ERROR_SXS_SETTING_NOT_REGISTERED // // MessageText: // // The setting is not registered. // public static final int ERROR_SXS_SETTING_NOT_REGISTERED = 14106; // // MessageId: ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE // // MessageText: // // One or more required members of the transaction are not present. // public static final int ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE = 14107; // // MessageId: ERROR_SMI_PRIMITIVE_INSTALLER_FAILED // // MessageText: // // The SMI primitive installer failed during setup or servicing. // public static final int ERROR_SMI_PRIMITIVE_INSTALLER_FAILED = 14108; // // MessageId: ERROR_GENERIC_COMMAND_FAILED // // MessageText: // // A generic command executable returned a result that indicates failure. // public static final int ERROR_GENERIC_COMMAND_FAILED = 14109; // // MessageId: ERROR_SXS_FILE_HASH_MISSING // // MessageText: // // A component is missing file verification information in its manifest. // public static final int ERROR_SXS_FILE_HASH_MISSING = 14110; // ///////////////////////////////////////////////// // =// // =End of Side By Side Error Codes // // =// // =14000 to=14999=// // ///////////////////////////////////////////////// // ///////////////////////////////////////////////// // =// // =Start of WinEvt Error codes=// // =// // =15000 to=15079=// // ///////////////////////////////////////////////// // // MessageId: ERROR_EVT_INVALID_CHANNEL_PATH // // MessageText: // // The specified channel path is invalid. // public static final int ERROR_EVT_INVALID_CHANNEL_PATH = 15000; // // MessageId: ERROR_EVT_INVALID_QUERY // // MessageText: // // The specified query is invalid. // public static final int ERROR_EVT_INVALID_QUERY = 15001; // // MessageId: ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND // // MessageText: // // The publisher metadata cannot be found in the resource. // public static final int ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND = 15002; // // MessageId: ERROR_EVT_EVENT_TEMPLATE_NOT_FOUND // // MessageText: // // The template for an event definition cannot be found in the resource // (error =%1). // public static final int ERROR_EVT_EVENT_TEMPLATE_NOT_FOUND = 15003; // // MessageId: ERROR_EVT_INVALID_PUBLISHER_NAME // // MessageText: // // The specified publisher name is invalid. // public static final int ERROR_EVT_INVALID_PUBLISHER_NAME = 15004; // // MessageId: ERROR_EVT_INVALID_EVENT_DATA // // MessageText: // // The event data raised by the publisher is not compatible with the event // template definition in the publisher's manifest // public static final int ERROR_EVT_INVALID_EVENT_DATA = 15005; // // MessageId: ERROR_EVT_CHANNEL_NOT_FOUND // // MessageText: // // The specified channel could not be found. Check channel configuration. // public static final int ERROR_EVT_CHANNEL_NOT_FOUND = 15007; // // MessageId: ERROR_EVT_MALFORMED_XML_TEXT // // MessageText: // // The specified xml text was not well-formed. See Extended Error for more // details. // public static final int ERROR_EVT_MALFORMED_XML_TEXT = 15008; // // MessageId: ERROR_EVT_SUBSCRIPTION_TO_DIRECT_CHANNEL // // MessageText: // // The caller is trying to subscribe to a direct channel which is not // allowed. The events for a direct channel go directly to a logfile and // cannot be subscribed to. // public static final int ERROR_EVT_SUBSCRIPTION_TO_DIRECT_CHANNEL = 15009; // // MessageId: ERROR_EVT_CONFIGURATION_ERROR // // MessageText: // // Configuration error. // public static final int ERROR_EVT_CONFIGURATION_ERROR = 15010; // // MessageId: ERROR_EVT_QUERY_RESULT_STALE // // MessageText: // // The query result is stale / invalid. This may be due to the log being // cleared or rolling over after the query result was created. Users should // handle this code by releasing the query result object and reissuing the // query. // public static final int ERROR_EVT_QUERY_RESULT_STALE = 15011; // // MessageId: ERROR_EVT_QUERY_RESULT_INVALID_POSITION // // MessageText: // // Query result is currently at an invalid position. // public static final int ERROR_EVT_QUERY_RESULT_INVALID_POSITION = 15012; // // MessageId: ERROR_EVT_NON_VALIDATING_MSXML // // MessageText: // // Registered MSXML doesn't support validation. // public static final int ERROR_EVT_NON_VALIDATING_MSXML = 15013; // // MessageId: ERROR_EVT_FILTER_ALREADYSCOPED // // MessageText: // // An expression can only be followed by a change of scope operation if it // itself evaluates to a node set and is not already part of some other // change of scope operation. // public static final int ERROR_EVT_FILTER_ALREADYSCOPED = 15014; // // MessageId: ERROR_EVT_FILTER_NOTELTSET // // MessageText: // // Can't perform a step operation from a term that does not represent an // element set. // public static final int ERROR_EVT_FILTER_NOTELTSET = 15015; // // MessageId: ERROR_EVT_FILTER_INVARG // // MessageText: // // Left hand side arguments to binary operators must be either attributes, // nodes or variables and right hand side arguments must be constants. // public static final int ERROR_EVT_FILTER_INVARG = 15016; // // MessageId: ERROR_EVT_FILTER_INVTEST // // MessageText: // // A step operation must involve either a node test or, in the case of a // predicate, an algebraic expression against which to test each node in the // node set identified by the preceeding node set can be evaluated. // public static final int ERROR_EVT_FILTER_INVTEST = 15017; // // MessageId: ERROR_EVT_FILTER_INVTYPE // // MessageText: // // This data type is currently unsupported. // public static final int ERROR_EVT_FILTER_INVTYPE = 15018; // // MessageId: ERROR_EVT_FILTER_PARSEERR // // MessageText: // // A syntax error occurred at position %1!d! // public static final int ERROR_EVT_FILTER_PARSEERR = 15019; // // MessageId: ERROR_EVT_FILTER_UNSUPPORTEDOP // // MessageText: // // This operator is unsupported by this implementation of the filter. // public static final int ERROR_EVT_FILTER_UNSUPPORTEDOP = 15020; // // MessageId: ERROR_EVT_FILTER_UNEXPECTEDTOKEN // // MessageText: // // The token encountered was unexpected. // public static final int ERROR_EVT_FILTER_UNEXPECTEDTOKEN = 15021; // // MessageId: ERROR_EVT_INVALID_OPERATION_OVER_ENABLED_DIRECT_CHANNEL // // MessageText: // // The requested operation cannot be performed over an enabled direct // channel. The channel must first be disabled before performing the // requested operation. // public static final int ERROR_EVT_INVALID_OPERATION_OVER_ENABLED_DIRECT_CHANNEL = 15022; // // MessageId: ERROR_EVT_INVALID_CHANNEL_PROPERTY_VALUE // // MessageText: // // Channel property %1!s! contains invalid value. The value has invalid // type, is outside of valid range, can't be updated or is not supported by // this type of channel. // public static final int ERROR_EVT_INVALID_CHANNEL_PROPERTY_VALUE = 15023; // // MessageId: ERROR_EVT_INVALID_PUBLISHER_PROPERTY_VALUE // // MessageText: // // Publisher property %1!s! contains invalid value. The value has invalid // type, is outside of valid range, can't be updated or is not supported by // this type of publisher. // public static final int ERROR_EVT_INVALID_PUBLISHER_PROPERTY_VALUE = 15024; // // MessageId: ERROR_EVT_CHANNEL_CANNOT_ACTIVATE // // MessageText: // // The channel fails to activate. // public static final int ERROR_EVT_CHANNEL_CANNOT_ACTIVATE = 15025; // // MessageId: ERROR_EVT_FILTER_TOO_COMPLEX // // MessageText: // // The xpath expression exceeded supported complexity. Please symplify it or // split it into two or more simple expressions. // public static final int ERROR_EVT_FILTER_TOO_COMPLEX = 15026; // // MessageId: ERROR_EVT_MESSAGE_NOT_FOUND // // MessageText: // // the message resource is present but the message is not found in the // string/message table // public static final int ERROR_EVT_MESSAGE_NOT_FOUND = 15027; // // MessageId: ERROR_EVT_MESSAGE_ID_NOT_FOUND // // MessageText: // // The message id for the desired message could not be found. // public static final int ERROR_EVT_MESSAGE_ID_NOT_FOUND = 15028; // // MessageId: ERROR_EVT_UNRESOLVED_VALUE_INSERT // // MessageText: // // The substitution string for insert index (%1) could not be found. // public static final int ERROR_EVT_UNRESOLVED_VALUE_INSERT = 15029; // // MessageId: ERROR_EVT_UNRESOLVED_PARAMETER_INSERT // // MessageText: // // The description string for parameter reference (%1) could not be found. // public static final int ERROR_EVT_UNRESOLVED_PARAMETER_INSERT = 15030; // // MessageId: ERROR_EVT_MAX_INSERTS_REACHED // // MessageText: // // The maximum number of replacements has been reached. // public static final int ERROR_EVT_MAX_INSERTS_REACHED = 15031; // // MessageId: ERROR_EVT_EVENT_DEFINITION_NOT_FOUND // // MessageText: // // The event definition could not be found for event id (%1). // public static final int ERROR_EVT_EVENT_DEFINITION_NOT_FOUND = 15032; // // MessageId: ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND // // MessageText: // // The locale specific resource for the desired message is not present. // public static final int ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND = 15033; // // MessageId: ERROR_EVT_VERSION_TOO_OLD // // MessageText: // // The resource is too old to be compatible. // public static final int ERROR_EVT_VERSION_TOO_OLD = 15034; // // MessageId: ERROR_EVT_VERSION_TOO_NEW // // MessageText: // // The resource is too new to be compatible. // public static final int ERROR_EVT_VERSION_TOO_NEW = 15035; // // MessageId: ERROR_EVT_CANNOT_OPEN_CHANNEL_OF_QUERY // // MessageText: // // The channel at index %1!d! of the query can't be opened. // public static final int ERROR_EVT_CANNOT_OPEN_CHANNEL_OF_QUERY = 15036; // // MessageId: ERROR_EVT_PUBLISHER_DISABLED // // MessageText: // // The publisher has been disabled and its resource is not avaiable. This // usually occurs when the publisher is in the process of being uninstalled // or upgraded. // public static final int ERROR_EVT_PUBLISHER_DISABLED = 15037; // // MessageId: ERROR_EVT_FILTER_OUT_OF_RANGE // // MessageText: // // Attempted to create a numeric type that is outside of its valid range. // public static final int ERROR_EVT_FILTER_OUT_OF_RANGE = 15038; // ///////////////////////////////////////////////// // =// // =Start of Wecsvc Error codes=// // =// // =15080 to=15099=// // ///////////////////////////////////////////////// // // MessageId: ERROR_EC_SUBSCRIPTION_CANNOT_ACTIVATE // // MessageText: // // The subscription fails to activate. // public static final int ERROR_EC_SUBSCRIPTION_CANNOT_ACTIVATE = 15080; // // MessageId: ERROR_EC_LOG_DISABLED // // MessageText: // // The log of the subscription is in disabled state, and can not be used to // forward events to. The log must first be enabled before the subscription // can be activated. // public static final int ERROR_EC_LOG_DISABLED = 15081; // // MessageId: ERROR_EC_CIRCULAR_FORWARDING // // MessageText: // // When forwarding events from local machine to itself, the query of the // subscription can't contain target log of the subscription. // public static final int ERROR_EC_CIRCULAR_FORWARDING = 15082; // // MessageId: ERROR_EC_CREDSTORE_FULL // // MessageText: // // The credential store that is used to save credentials is full. // public static final int ERROR_EC_CREDSTORE_FULL = 15083; // // MessageId: ERROR_EC_CRED_NOT_FOUND // // MessageText: // // The credential used by this subscription can't be found in credential // store. // public static final int ERROR_EC_CRED_NOT_FOUND = 15084; // // MessageId: ERROR_EC_NO_ACTIVE_CHANNEL // // MessageText: // // No active channel is found for the query. // public static final int ERROR_EC_NO_ACTIVE_CHANNEL = 15085; // ///////////////////////////////////////////////// // =// // =Start of MUI Error codes=// // =// // =15100 to=15199=// // ///////////////////////////////////////////////// // // MessageId: ERROR_MUI_FILE_NOT_FOUND // // MessageText: // // The resource loader failed to find MUI file. // public static final int ERROR_MUI_FILE_NOT_FOUND = 15100; // // MessageId: ERROR_MUI_INVALID_FILE // // MessageText: // // The resource loader failed to load MUI file because the file fail to pass // validation. // public static final int ERROR_MUI_INVALID_FILE = 15101; // // MessageId: ERROR_MUI_INVALID_RC_CONFIG // // MessageText: // // The RC Manifest is corrupted with garbage data or unsupported version or // missing required item. // public static final int ERROR_MUI_INVALID_RC_CONFIG = 15102; // // MessageId: ERROR_MUI_INVALID_LOCALE_NAME // // MessageText: // // The RC Manifest has invalid culture name. // public static final int ERROR_MUI_INVALID_LOCALE_NAME = 15103; // // MessageId: ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME // // MessageText: // // The RC Manifest has invalid ultimatefallback name. // public static final int ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME = 15104; // // MessageId: ERROR_MUI_FILE_NOT_LOADED // // MessageText: // // The resource loader cache doesn't have loaded MUI entry. // public static final int ERROR_MUI_FILE_NOT_LOADED = 15105; // // MessageId: ERROR_RESOURCE_ENUM_USER_STOP // // MessageText: // // User stopped resource enumeration. // public static final int ERROR_RESOURCE_ENUM_USER_STOP = 15106; // // MessageId: ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED // // MessageText: // // UI language installation failed. // public static final int ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED = 15107; // // MessageId: ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME // // MessageText: // // Locale installation failed. // public static final int ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME = 15108; // ///////////////////////////////////////////////// // =// // Start of Monitor Configuration API error codes// // =// // =15200 to=15249=// // ///////////////////////////////////////////////// // // MessageId: ERROR_MCA_INVALID_CAPABILITIES_STRING // // MessageText: // // The monitor returned a DDC/CI capabilities string that did not comply // with the ACCESS.bus=3.0, DDC/CI=1.1 or MCCS=2 Revision=1 specification. // public static final int ERROR_MCA_INVALID_CAPABILITIES_STRING = 15200; // // MessageId: ERROR_MCA_INVALID_VCP_VERSION // // MessageText: // // The monitor's VCP Version (0xDF) VCP code returned an invalid version // value. // public static final int ERROR_MCA_INVALID_VCP_VERSION = 15201; // // MessageId: ERROR_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION // // MessageText: // // The monitor does not comply with the MCCS specification it claims to // support. // public static final int ERROR_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION = 15202; // // MessageId: ERROR_MCA_MCCS_VERSION_MISMATCH // // MessageText: // // The MCCS version in a monitor's mccs_ver capability does not match the // MCCS version the monitor reports when the VCP Version (0xDF) VCP code is // used. // public static final int ERROR_MCA_MCCS_VERSION_MISMATCH = 15203; // // MessageId: ERROR_MCA_UNSUPPORTED_MCCS_VERSION // // MessageText: // // The Monitor Configuration API only works with monitors that support the // MCCS=1.0 specification, MCCS=2.0 specification or the MCCS=2.0 Revision=1 // specification. // public static final int ERROR_MCA_UNSUPPORTED_MCCS_VERSION = 15204; // // MessageId: ERROR_MCA_INTERNAL_ERROR // // MessageText: // // An internal Monitor Configuration API error occurred. // public static final int ERROR_MCA_INTERNAL_ERROR = 15205; // // MessageId: ERROR_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED // // MessageText: // // The monitor returned an invalid monitor technology type. CRT, Plasma and // LCD (TFT) are examples of monitor technology types. This error implies // that the monitor violated the MCCS=2.0 or MCCS=2.0 Revision=1 // specification. // public static final int ERROR_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED = 15206; // // MessageId: ERROR_MCA_UNSUPPORTED_COLOR_TEMPERATURE // // MessageText: // // The caller of SetMonitorColorTemperature specified a color temperature // that the current monitor did not support. This error implies that the // monitor violated the MCCS=2.0 or MCCS=2.0 Revision=1 specification. // public static final int ERROR_MCA_UNSUPPORTED_COLOR_TEMPERATURE = 15207; // //////////////////////////////////////////////// // =// // End of Monitor Configuration API error codes // // =// // =15200 to=15249=// // =// // //////////////////////////////////////////////// // //////////////////////////////////////////////// // =// // =Start of Syspart error codes=// // =15250 -=15299=// // =// // //////////////////////////////////////////////// // // MessageId: ERROR_AMBIGUOUS_SYSTEM_DEVICE // // MessageText: // // The requested system device cannot be identified due to multiple // indistinguishable devices potentially matching the identification // criteria. // public static final int ERROR_AMBIGUOUS_SYSTEM_DEVICE = 15250; // // MessageId: ERROR_SYSTEM_DEVICE_NOT_FOUND // // MessageText: // // The requested system device cannot be found. // public static final int ERROR_SYSTEM_DEVICE_NOT_FOUND = 15299; // ////////////////////////////////// // =// // COM Error Codes=// // =// // ////////////////////////////////// // // The return value of COM functions and methods is an HRESULT. // This is not a handle to anything, but is merely a=32-bit value // with several fields encoded in the value. The parts of an // HRESULT are shown below. // // Many of the macros and functions below were orginally defined to // operate on SCODEs. SCODEs are no longer used. The macros are // still present for compatibility and easy porting of Win16 code. // Newly written code should use the HRESULT macros and functions. // // // HRESULTs are=32 bit values layed out as follows: // // =3=3=2=2=2=2=2=2=2=2=2=2=1=1=1=1=1=1=1=1=1=1 // =1 0=9=8=7=6=5=4=3=2=1 0=9=8=7=6=5=4=3=2=1 0=9=8=7=6=5=4=3=2=1 0 // +-+-+-+-+-+---------------------+-------------------------------+ // |S|R|C|N|r| Facility=|=Code=| // +-+-+-+-+-+---------------------+-------------------------------+ // // where // // S - Severity - indicates success/fail // // =0 - Success // =1 - Fail (COERROR) // // R - reserved portion of the facility code, corresponds to NT's // =second severity bit. // // C - reserved portion of the facility code, corresponds to NT's // =C field. // // N - reserved portion of the facility code. Used to indicate a // =mapped NT status value. // // r - reserved portion of the facility code. Reserved for internal // =use. Used to indicate HRESULT values that are not status // =values, but are instead message ids for display strings. // // Facility - is the facility code // // Code - is the facility's status code // // // Severity values // public static final int SEVERITY_SUCCESS = 0; public static final int SEVERITY_ERROR = 1; // // Generic test for success on any status value (non-negative numbers // indicate success). // public static final boolean SUCCEEDED(int hr) { return hr >= 0; } // // and the inverse // public static final boolean FAILED(int hr) { return hr < 0; } // // Return the code // public static final int HRESULT_CODE(int hr) { return hr & 0xFFFF; } public static final int SCODE_CODE(int sc) { return sc & 0xFFFF; } // // Return the facility // public static final int HRESULT_FACILITY(int hr) { return (hr >>= 16) & 0x1fff; } public static final int SCODE_FACILITY(short sc) { return (sc >>= 16) & 0x1fff; } // // Return the severity // public static short HRESULT_SEVERITY(int hr) { return (short) ((hr >>= 31) & 0x1); } public static short SCODE_SEVERITY(short sc) { return (short) ((sc >>= 31) & 0x1); } // // Create an HRESULT value from component pieces // public static int MAKE_HRESULT(short sev, short fac, short code) { return ((sev << 31) | (fac << 16) | code); } 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. // // Define bits here so macros are guaranteed to work public static final int FACILITY_NT_BIT = 0x10000000; public static final HRESULT HRESULT_FROM_WIN32(int x) { int f = FACILITY_WIN32; return new HRESULT(x <= 0 ? x : ((x) & 0x0000FFFF) | (f <<= 16) | 0x80000000); } // ---------------------- HRESULT value definitions ----------------- // // HRESULT definitions // public static final int NOERROR = 0; // // Error definitions follow // // // Codes 0x4000-0x40ff are reserved for OLE // // // Error codes // // // MessageId: E_UNEXPECTED // // MessageText: // // Catastrophic failure // public static final int E_UNEXPECTED = 0x8000FFFF; // // MessageId: E_NOTIMPL // // MessageText: // // Not implemented // public static final int E_NOTIMPL = 0x80004001; // // MessageId: E_OUTOFMEMORY // // MessageText: // // Ran out of memory // public static final int E_OUTOFMEMORY = 0x8007000E; // // MessageId: E_INVALIDARG // // MessageText: // // One or more arguments are invalid // public static final int E_INVALIDARG = 0x80070057; // // MessageId: E_NOINTERFACE // // MessageText: // // No such interface supported // public static final int E_NOINTERFACE = 0x80004002; // // MessageId: E_POINTER // // MessageText: // // Invalid pointer // public static final int E_POINTER = 0x80004003; // // MessageId: E_HANDLE // // MessageText: // // Invalid handle // public static final int E_HANDLE = 0x80070006; // // MessageId: E_ABORT // // MessageText: // // Operation aborted // public static final int E_ABORT = 0x80004004; // // MessageId: E_FAIL // // MessageText: // // Unspecified error // public static final int E_FAIL = 0x80004005; // // MessageId: E_ACCESSDENIED // // MessageText: // // General access denied error // public static final int E_ACCESSDENIED = 0x80070005; // // MessageId: E_PENDING // // MessageText: // // The data necessary to complete this operation is not yet available. // public static final int E_PENDING = 0x8000000A; // // MessageId: CO_E_INIT_TLS // // MessageText: // // Thread local storage failure // public static final int CO_E_INIT_TLS = 0x80004006; // // MessageId: CO_E_INIT_SHARED_ALLOCATOR // // MessageText: // // Get shared memory allocator failure // public static final int CO_E_INIT_SHARED_ALLOCATOR = 0x80004007; // // MessageId: CO_E_INIT_MEMORY_ALLOCATOR // // MessageText: // // Get memory allocator failure // public static final int CO_E_INIT_MEMORY_ALLOCATOR = 0x80004008; // // MessageId: CO_E_INIT_CLASS_CACHE // // MessageText: // // Unable to initialize class cache // public static final int CO_E_INIT_CLASS_CACHE = 0x80004009; // // MessageId: CO_E_INIT_RPC_CHANNEL // // MessageText: // // Unable to initialize RPC services // public static final int CO_E_INIT_RPC_CHANNEL = 0x8000400A; // // MessageId: CO_E_INIT_TLS_SET_CHANNEL_CONTROL // // MessageText: // // Cannot set thread local storage channel control // public static final int CO_E_INIT_TLS_SET_CHANNEL_CONTROL = 0x8000400B; // // MessageId: CO_E_INIT_TLS_CHANNEL_CONTROL // // MessageText: // // Could not allocate thread local storage channel control // public static final int CO_E_INIT_TLS_CHANNEL_CONTROL = 0x8000400C; // // MessageId: CO_E_INIT_UNACCEPTED_USER_ALLOCATOR // // MessageText: // // The user supplied memory allocator is unacceptable // public static final int CO_E_INIT_UNACCEPTED_USER_ALLOCATOR = 0x8000400D; // // MessageId: CO_E_INIT_SCM_MUTEX_EXISTS // // MessageText: // // The OLE service mutex already exists // public static final int CO_E_INIT_SCM_MUTEX_EXISTS = 0x8000400E; // // MessageId: CO_E_INIT_SCM_FILE_MAPPING_EXISTS // // MessageText: // // The OLE service file mapping already exists // public static final int CO_E_INIT_SCM_FILE_MAPPING_EXISTS = 0x8000400F; // // MessageId: CO_E_INIT_SCM_MAP_VIEW_OF_FILE // // MessageText: // // Unable to map view of file for OLE service // public static final int CO_E_INIT_SCM_MAP_VIEW_OF_FILE = 0x80004010; // // MessageId: CO_E_INIT_SCM_EXEC_FAILURE // // MessageText: // // Failure attempting to launch OLE service // public static final int CO_E_INIT_SCM_EXEC_FAILURE = 0x80004011; // // MessageId: CO_E_INIT_ONLY_SINGLE_THREADED // // MessageText: // // There was an attempt to call CoInitialize a second time while single // threaded // public static final int CO_E_INIT_ONLY_SINGLE_THREADED = 0x80004012; // // MessageId: CO_E_CANT_REMOTE // // MessageText: // // A Remote activation was necessary but was not allowed // public static final int CO_E_CANT_REMOTE = 0x80004013; // // MessageId: CO_E_BAD_SERVER_NAME // // MessageText: // // A Remote activation was necessary but the server name provided was // invalid // public static final int CO_E_BAD_SERVER_NAME = 0x80004014; // // MessageId: CO_E_WRONG_SERVER_IDENTITY // // MessageText: // // The class is configured to run as a security id different from the caller // public static final int CO_E_WRONG_SERVER_IDENTITY = 0x80004015; // // MessageId: CO_E_OLE1DDE_DISABLED // // MessageText: // // Use of Ole1 services requiring DDE windows is disabled // public static final int CO_E_OLE1DDE_DISABLED = 0x80004016; // // MessageId: CO_E_RUNAS_SYNTAX // // MessageText: // // A RunAs specification must be \ or simply // public static final int CO_E_RUNAS_SYNTAX = 0x80004017; // // MessageId: CO_E_CREATEPROCESS_FAILURE // // MessageText: // // The server process could not be started. The pathname may be incorrect. // public static final int CO_E_CREATEPROCESS_FAILURE = 0x80004018; // // MessageId: CO_E_RUNAS_CREATEPROCESS_FAILURE // // MessageText: // // The server process could not be started as the configured identity. The // pathname may be incorrect or unavailable. // public static final int CO_E_RUNAS_CREATEPROCESS_FAILURE = 0x80004019; // // MessageId: CO_E_RUNAS_LOGON_FAILURE // // MessageText: // // The server process could not be started because the configured identity // is incorrect. Check the username and password. // public static final int CO_E_RUNAS_LOGON_FAILURE = 0x8000401A; // // MessageId: CO_E_LAUNCH_PERMSSION_DENIED // // MessageText: // // The client is not allowed to launch this server. // public static final int CO_E_LAUNCH_PERMSSION_DENIED = 0x8000401B; // // MessageId: CO_E_START_SERVICE_FAILURE // // MessageText: // // The service providing this server could not be started. // public static final int CO_E_START_SERVICE_FAILURE = 0x8000401C; // // MessageId: CO_E_REMOTE_COMMUNICATION_FAILURE // // MessageText: // // This computer was unable to communicate with the computer providing the // server. // public static final int CO_E_REMOTE_COMMUNICATION_FAILURE = 0x8000401D; // // MessageId: CO_E_SERVER_START_TIMEOUT // // MessageText: // // The server did not respond after being launched. // public static final int CO_E_SERVER_START_TIMEOUT = 0x8000401E; // // MessageId: CO_E_CLSREG_INCONSISTENT // // MessageText: // // The registration information for this server is inconsistent or // incomplete. // public static final int CO_E_CLSREG_INCONSISTENT = 0x8000401F; // // MessageId: CO_E_IIDREG_INCONSISTENT // // MessageText: // // The registration information for this interface is inconsistent or // incomplete. // public static final int CO_E_IIDREG_INCONSISTENT = 0x80004020; // // MessageId: CO_E_NOT_SUPPORTED // // MessageText: // // The operation attempted is not supported. // public static final int CO_E_NOT_SUPPORTED = 0x80004021; // // MessageId: CO_E_RELOAD_DLL // // MessageText: // // A dll must be loaded. // public static final int CO_E_RELOAD_DLL = 0x80004022; // // MessageId: CO_E_MSI_ERROR // // MessageText: // // A Microsoft Software Installer error was encountered. // public static final int CO_E_MSI_ERROR = 0x80004023; // // MessageId: CO_E_ATTEMPT_TO_CREATE_OUTSIDE_CLIENT_CONTEXT // // MessageText: // // The specified activation could not occur in the client context as // specified. // public static final int CO_E_ATTEMPT_TO_CREATE_OUTSIDE_CLIENT_CONTEXT = 0x80004024; // // MessageId: CO_E_SERVER_PAUSED // // MessageText: // // Activations on the server are paused. // public static final int CO_E_SERVER_PAUSED = 0x80004025; // // MessageId: CO_E_SERVER_NOT_PAUSED // // MessageText: // // Activations on the server are not paused. // public static final int CO_E_SERVER_NOT_PAUSED = 0x80004026; // // MessageId: CO_E_CLASS_DISABLED // // MessageText: // // The component or application containing the component has been disabled. // public static final int CO_E_CLASS_DISABLED = 0x80004027; // // MessageId: CO_E_CLRNOTAVAILABLE // // MessageText: // // The common language runtime is not available // public static final int CO_E_CLRNOTAVAILABLE = 0x80004028; // // MessageId: CO_E_ASYNC_WORK_REJECTED // // MessageText: // // The thread-pool rejected the submitted asynchronous work. // public static final int CO_E_ASYNC_WORK_REJECTED = 0x80004029; // // MessageId: CO_E_SERVER_INIT_TIMEOUT // // MessageText: // // The server started, but did not finish initializing in a timely fashion. // public static final int CO_E_SERVER_INIT_TIMEOUT = 0x8000402A; // // MessageId: CO_E_NO_SECCTX_IN_ACTIVATE // // MessageText: // // Unable to complete the call since there is no COM+ security context // inside IObjectControl.Activate. // public static final int CO_E_NO_SECCTX_IN_ACTIVATE = 0x8000402B; // // MessageId: CO_E_TRACKER_CONFIG // // MessageText: // // The provided tracker configuration is invalid // public static final int CO_E_TRACKER_CONFIG = 0x80004030; // // MessageId: CO_E_THREADPOOL_CONFIG // // MessageText: // // The provided thread pool configuration is invalid // public static final int CO_E_THREADPOOL_CONFIG = 0x80004031; // // MessageId: CO_E_SXS_CONFIG // // MessageText: // // The provided side-by-side configuration is invalid // public static final int CO_E_SXS_CONFIG = 0x80004032; // // MessageId: CO_E_MALFORMED_SPN // // MessageText: // // The server principal name (SPN) obtained during security negotiation is // malformed. // public static final int CO_E_MALFORMED_SPN = 0x80004033; // // Success codes // public static final HRESULT S_OK = new HRESULT(0); public static final HRESULT S_FALSE = new HRESULT(1); // ****************** // FACILITY_ITF // ****************** // // Codes 0x0-0x01ff are reserved for the OLE group of // interfaces. // // // Generic OLE errors that may be returned by many inerfaces // public static final int OLE_E_FIRST = 0x80040000; public static final int OLE_E_LAST = 0x800400FF; public static final int OLE_S_FIRST = 0x00040000; public static final int OLE_S_LAST = 0x000400FF; // // Old OLE errors // // // MessageId: OLE_E_OLEVERB // // MessageText: // // Invalid OLEVERB structure // public static final int OLE_E_OLEVERB = 0x80040000; // // MessageId: OLE_E_ADVF // // MessageText: // // Invalid advise flags // public static final int OLE_E_ADVF = 0x80040001; // // MessageId: OLE_E_ENUM_NOMORE // // MessageText: // // Can't enumerate any more, because the associated data is missing // public static final int OLE_E_ENUM_NOMORE = 0x80040002; // // MessageId: OLE_E_ADVISENOTSUPPORTED // // MessageText: // // This implementation doesn't take advises // public static final int OLE_E_ADVISENOTSUPPORTED = 0x80040003; // // MessageId: OLE_E_NOCONNECTION // // MessageText: // // There is no connection for this connection ID // public static final int OLE_E_NOCONNECTION = 0x80040004; // // MessageId: OLE_E_NOTRUNNING // // MessageText: // // Need to run the object to perform this operation // public static final int OLE_E_NOTRUNNING = 0x80040005; // // MessageId: OLE_E_NOCACHE // // MessageText: // // There is no cache to operate on // public static final int OLE_E_NOCACHE = 0x80040006; // // MessageId: OLE_E_BLANK // // MessageText: // // Uninitialized object // public static final int OLE_E_BLANK = 0x80040007; // // MessageId: OLE_E_CLASSDIFF // // MessageText: // // Linked object's source class has changed // public static final int OLE_E_CLASSDIFF = 0x80040008; // // MessageId: OLE_E_CANT_GETMONIKER // // MessageText: // // Not able to get the moniker of the object // public static final int OLE_E_CANT_GETMONIKER = 0x80040009; // // MessageId: OLE_E_CANT_BINDTOSOURCE // // MessageText: // // Not able to bind to the source // public static final int OLE_E_CANT_BINDTOSOURCE = 0x8004000A; // // MessageId: OLE_E_STATIC // // MessageText: // // Object is static; operation not allowed // public static final int OLE_E_STATIC = 0x8004000B; // // MessageId: OLE_E_PROMPTSAVECANCELLED // // MessageText: // // User canceled out of save dialog // public static final int OLE_E_PROMPTSAVECANCELLED = 0x8004000C; // // MessageId: OLE_E_INVALIDRECT // // MessageText: // // Invalid rectangle // public static final int OLE_E_INVALIDRECT = 0x8004000D; // // MessageId: OLE_E_WRONGCOMPOBJ // // MessageText: // // compobj.dll is too old for the ole2.dll initialized // public static final int OLE_E_WRONGCOMPOBJ = 0x8004000E; // // MessageId: OLE_E_INVALIDHWND // // MessageText: // // Invalid window handle // public static final int OLE_E_INVALIDHWND = 0x8004000F; // // MessageId: OLE_E_NOT_INPLACEACTIVE // // MessageText: // // Object is not in any of the inplace active states // public static final int OLE_E_NOT_INPLACEACTIVE = 0x80040010; // // MessageId: OLE_E_CANTCONVERT // // MessageText: // // Not able to convert object // public static final int OLE_E_CANTCONVERT = 0x80040011; // // MessageId: OLE_E_NOSTORAGE // // MessageText: // // Not able to perform the operation because object is not given storage yet // public static final int OLE_E_NOSTORAGE = 0x80040012; // // MessageId: DV_E_FORMATETC // // MessageText: // // Invalid FORMATETC structure // public static final int DV_E_FORMATETC = 0x80040064; // // MessageId: DV_E_DVTARGETDEVICE // // MessageText: // // Invalid DVTARGETDEVICE structure // public static final int DV_E_DVTARGETDEVICE = 0x80040065; // // MessageId: DV_E_STGMEDIUM // // MessageText: // // Invalid STDGMEDIUM structure // public static final int DV_E_STGMEDIUM = 0x80040066; // // MessageId: DV_E_STATDATA // // MessageText: // // Invalid STATDATA structure // public static final int DV_E_STATDATA = 0x80040067; // // MessageId: DV_E_LINDEX // // MessageText: // // Invalid lindex // public static final int DV_E_LINDEX = 0x80040068; // // MessageId: DV_E_TYMED // // MessageText: // // Invalid tymed // public static final int DV_E_TYMED = 0x80040069; // // MessageId: DV_E_CLIPFORMAT // // MessageText: // // Invalid clipboard format // public static final int DV_E_CLIPFORMAT = 0x8004006A; // // MessageId: DV_E_DVASPECT // // MessageText: // // Invalid aspect(s) // public static final int DV_E_DVASPECT = 0x8004006B; // // MessageId: DV_E_DVTARGETDEVICE_SIZE // // MessageText: // // tdSize parameter of the DVTARGETDEVICE structure is invalid // public static final int DV_E_DVTARGETDEVICE_SIZE = 0x8004006C; // // MessageId: DV_E_NOIVIEWOBJECT // // MessageText: // // Object doesn't support IViewObject interface // public static final int DV_E_NOIVIEWOBJECT = 0x8004006D; public static final int DRAGDROP_E_FIRST = 0x80040100; public static final int DRAGDROP_E_LAST = 0x8004010F; public static final int DRAGDROP_S_FIRST = 0x00040100; public static final int DRAGDROP_S_LAST = 0x0004010F; // // MessageId: DRAGDROP_E_NOTREGISTERED // // MessageText: // // Trying to revoke a drop target that has not been registered // public static final int DRAGDROP_E_NOTREGISTERED = 0x80040100; // // MessageId: DRAGDROP_E_ALREADYREGISTERED // // MessageText: // // This window has already been registered as a drop target // public static final int DRAGDROP_E_ALREADYREGISTERED = 0x80040101; // // MessageId: DRAGDROP_E_INVALIDHWND // // MessageText: // // Invalid window handle // public static final int DRAGDROP_E_INVALIDHWND = 0x80040102; public static final int CLASSFACTORY_E_FIRST = 0x80040110; public static final int CLASSFACTORY_E_LAST = 0x8004011F; public static final int CLASSFACTORY_S_FIRST = 0x00040110; public static final int CLASSFACTORY_S_LAST = 0x0004011F; // // MessageId: CLASS_E_NOAGGREGATION // // MessageText: // // Class does not support aggregation (or class object is remote) // public static final int CLASS_E_NOAGGREGATION = 0x80040110; // // MessageId: CLASS_E_CLASSNOTAVAILABLE // // MessageText: // // ClassFactory cannot supply requested class // public static final int CLASS_E_CLASSNOTAVAILABLE = 0x80040111; // // MessageId: CLASS_E_NOTLICENSED // // MessageText: // // Class is not licensed for use // public static final int CLASS_E_NOTLICENSED = 0x80040112; public static final int MARSHAL_E_FIRST = 0x80040120; public static final int MARSHAL_E_LAST = 0x8004012F; public static final int MARSHAL_S_FIRST = 0x00040120; public static final int MARSHAL_S_LAST = 0x0004012F; public static final int DATA_E_FIRST = 0x80040130; public static final int DATA_E_LAST = 0x8004013F; public static final int DATA_S_FIRST = 0x00040130; public static final int DATA_S_LAST = 0x0004013F; public static final int VIEW_E_FIRST = 0x80040140; public static final int VIEW_E_LAST = 0x8004014F; public static final int VIEW_S_FIRST = 0x00040140; public static final int VIEW_S_LAST = 0x0004014F; // // MessageId: VIEW_E_DRAW // // MessageText: // // Error drawing view // public static final int VIEW_E_DRAW = 0x80040140; public static final int REGDB_E_FIRST = 0x80040150; public static final int REGDB_E_LAST = 0x8004015F; public static final int REGDB_S_FIRST = 0x00040150; public static final int REGDB_S_LAST = 0x0004015F; // // MessageId: REGDB_E_READREGDB // // MessageText: // // Could not read key from registry // public static final int REGDB_E_READREGDB = 0x80040150; // // MessageId: REGDB_E_WRITEREGDB // // MessageText: // // Could not write key to registry // public static final int REGDB_E_WRITEREGDB = 0x80040151; // // MessageId: REGDB_E_KEYMISSING // // MessageText: // // Could not find the key in the registry // public static final int REGDB_E_KEYMISSING = 0x80040152; // // MessageId: REGDB_E_INVALIDVALUE // // MessageText: // // Invalid value for registry // public static final int REGDB_E_INVALIDVALUE = 0x80040153; // // MessageId: REGDB_E_CLASSNOTREG // // MessageText: // // Class not registered // public static final int REGDB_E_CLASSNOTREG = 0x80040154; // // MessageId: REGDB_E_IIDNOTREG // // MessageText: // // Interface not registered // public static final int REGDB_E_IIDNOTREG = 0x80040155; // // MessageId: REGDB_E_BADTHREADINGMODEL // // MessageText: // // Threading model entry is not valid // public static final int REGDB_E_BADTHREADINGMODEL = 0x80040156; public static final int CAT_E_FIRST = 0x80040160; public static final int CAT_E_LAST = 0x80040161; // // MessageId: CAT_E_CATIDNOEXIST // // MessageText: // // CATID does not exist // public static final int CAT_E_CATIDNOEXIST = 0x80040160; // // MessageId: CAT_E_NODESCRIPTION // // MessageText: // // Description not found // public static final int CAT_E_NODESCRIPTION = 0x80040161; // ////////////////////////////////// // =// // Class Store Error Codes // // =// // ////////////////////////////////// public static final int CS_E_FIRST = 0x80040164; public static final int CS_E_LAST = 0x8004016F; // // MessageId: CS_E_PACKAGE_NOTFOUND // // MessageText: // // No package in the software installation data in the Active Directory // meets this criteria. // public static final int CS_E_PACKAGE_NOTFOUND = 0x80040164; // // MessageId: CS_E_NOT_DELETABLE // // MessageText: // // Deleting this will break the referential integrity of the software // installation data in the Active Directory. // public static final int CS_E_NOT_DELETABLE = 0x80040165; // // MessageId: CS_E_CLASS_NOTFOUND // // MessageText: // // The CLSID was not found in the software installation data in the Active // Directory. // public static final int CS_E_CLASS_NOTFOUND = 0x80040166; // // MessageId: CS_E_INVALID_VERSION // // MessageText: // // The software installation data in the Active Directory is corrupt. // public static final int CS_E_INVALID_VERSION = 0x80040167; // // MessageId: CS_E_NO_CLASSSTORE // // MessageText: // // There is no software installation data in the Active Directory. // public static final int CS_E_NO_CLASSSTORE = 0x80040168; // // MessageId: CS_E_OBJECT_NOTFOUND // // MessageText: // // There is no software installation data object in the Active Directory. // public static final int CS_E_OBJECT_NOTFOUND = 0x80040169; // // MessageId: CS_E_OBJECT_ALREADY_EXISTS // // MessageText: // // The software installation data object in the Active Directory already // exists. // public static final int CS_E_OBJECT_ALREADY_EXISTS = 0x8004016A; // // MessageId: CS_E_INVALID_PATH // // MessageText: // // The path to the software installation data in the Active Directory is not // correct. // public static final int CS_E_INVALID_PATH = 0x8004016B; // // MessageId: CS_E_NETWORK_ERROR // // MessageText: // // A network error interrupted the operation. // public static final int CS_E_NETWORK_ERROR = 0x8004016C; // // MessageId: CS_E_ADMIN_LIMIT_EXCEEDED // // MessageText: // // The size of this object exceeds the maximum size set by the // Administrator. // public static final int CS_E_ADMIN_LIMIT_EXCEEDED = 0x8004016D; // // MessageId: CS_E_SCHEMA_MISMATCH // // MessageText: // // The schema for the software installation data in the Active Directory // does not match the required schema. // public static final int CS_E_SCHEMA_MISMATCH = 0x8004016E; // // MessageId: CS_E_INTERNAL_ERROR // // MessageText: // // An error occurred in the software installation data in the Active // Directory. // public static final int CS_E_INTERNAL_ERROR = 0x8004016F; public static final int CACHE_E_FIRST = 0x80040170; public static final int CACHE_E_LAST = 0x8004017F; public static final int CACHE_S_FIRST = 0x00040170; public static final int CACHE_S_LAST = 0x0004017F; // // MessageId: CACHE_E_NOCACHE_UPDATED // // MessageText: // // Cache not updated // public static final int CACHE_E_NOCACHE_UPDATED = 0x80040170; public static final int OLEOBJ_E_FIRST = 0x80040180; public static final int OLEOBJ_E_LAST = 0x8004018F; public static final int OLEOBJ_S_FIRST = 0x00040180; public static final int OLEOBJ_S_LAST = 0x0004018F; // // MessageId: OLEOBJ_E_NOVERBS // // MessageText: // // No verbs for OLE object // public static final int OLEOBJ_E_NOVERBS = 0x80040180; // // MessageId: OLEOBJ_E_INVALIDVERB // // MessageText: // // Invalid verb for OLE object // public static final int OLEOBJ_E_INVALIDVERB = 0x80040181; public static final int CLIENTSITE_E_FIRST = 0x80040190; public static final int CLIENTSITE_E_LAST = 0x8004019F; public static final int CLIENTSITE_S_FIRST = 0x00040190; public static final int CLIENTSITE_S_LAST = 0x0004019F; // // MessageId: INPLACE_E_NOTUNDOABLE // // MessageText: // // Undo is not available // public static final int INPLACE_E_NOTUNDOABLE = 0x800401A0; // // MessageId: INPLACE_E_NOTOOLSPACE // // MessageText: // // Space for tools is not available // public static final int INPLACE_E_NOTOOLSPACE = 0x800401A1; public static final int INPLACE_E_FIRST = 0x800401A0; public static final int INPLACE_E_LAST = 0x800401AF; public static final int INPLACE_S_FIRST = 0x000401A0; public static final int INPLACE_S_LAST = 0x000401AF; public static final int ENUM_E_FIRST = 0x800401B0; public static final int ENUM_E_LAST = 0x800401BF; public static final int ENUM_S_FIRST = 0x000401B0; public static final int ENUM_S_LAST = 0x000401BF; public static final int CONVERT10_E_FIRST = 0x800401C0; public static final int CONVERT10_E_LAST = 0x800401CF; public static final int CONVERT10_S_FIRST = 0x000401C0; public static final int CONVERT10_S_LAST = 0x000401CF; // // MessageId: CONVERT10_E_OLESTREAM_GET // // MessageText: // // OLESTREAM Get method failed // public static final int CONVERT10_E_OLESTREAM_GET = 0x800401C0; // // MessageId: CONVERT10_E_OLESTREAM_PUT // // MessageText: // // OLESTREAM Put method failed // public static final int CONVERT10_E_OLESTREAM_PUT = 0x800401C1; // // MessageId: CONVERT10_E_OLESTREAM_FMT // // MessageText: // // Contents of the OLESTREAM not in correct format // public static final int CONVERT10_E_OLESTREAM_FMT = 0x800401C2; // // MessageId: CONVERT10_E_OLESTREAM_BITMAP_TO_DIB // // MessageText: // // There was an error in a Windows GDI call while converting the bitmap to a // DIB // public static final int CONVERT10_E_OLESTREAM_BITMAP_TO_DIB = 0x800401C3; // // MessageId: CONVERT10_E_STG_FMT // // MessageText: // // Contents of the IStorage not in correct format // public static final int CONVERT10_E_STG_FMT = 0x800401C4; // // MessageId: CONVERT10_E_STG_NO_STD_STREAM // // MessageText: // // Contents of IStorage is missing one of the standard streams // public static final int CONVERT10_E_STG_NO_STD_STREAM = 0x800401C5; // // MessageId: CONVERT10_E_STG_DIB_TO_BITMAP // // MessageText: // // There was an error in a Windows GDI call while converting the DIB to a // bitmap. // // public static final int CONVERT10_E_STG_DIB_TO_BITMAP = 0x800401C6; public static final int CLIPBRD_E_FIRST = 0x800401D0; public static final int CLIPBRD_E_LAST = 0x800401DF; public static final int CLIPBRD_S_FIRST = 0x000401D0; public static final int CLIPBRD_S_LAST = 0x000401DF; // // MessageId: CLIPBRD_E_CANT_OPEN // // MessageText: // // OpenClipboard Failed // public static final int CLIPBRD_E_CANT_OPEN = 0x800401D0; // // MessageId: CLIPBRD_E_CANT_EMPTY // // MessageText: // // EmptyClipboard Failed // public static final int CLIPBRD_E_CANT_EMPTY = 0x800401D1; // // MessageId: CLIPBRD_E_CANT_SET // // MessageText: // // SetClipboard Failed // public static final int CLIPBRD_E_CANT_SET = 0x800401D2; // // MessageId: CLIPBRD_E_BAD_DATA // // MessageText: // // Data on clipboard is invalid // public static final int CLIPBRD_E_BAD_DATA = 0x800401D3; // // MessageId: CLIPBRD_E_CANT_CLOSE // // MessageText: // // CloseClipboard Failed // public static final int CLIPBRD_E_CANT_CLOSE = 0x800401D4; public static final int MK_E_FIRST = 0x800401E0; public static final int MK_E_LAST = 0x800401EF; public static final int MK_S_FIRST = 0x000401E0; public static final int MK_S_LAST = 0x000401EF; // // MessageId: MK_E_CONNECTMANUALLY // // MessageText: // // Moniker needs to be connected manually // public static final int MK_E_CONNECTMANUALLY = 0x800401E0; // // MessageId: MK_E_EXCEEDEDDEADLINE // // MessageText: // // Operation exceeded deadline // public static final int MK_E_EXCEEDEDDEADLINE = 0x800401E1; // // MessageId: MK_E_NEEDGENERIC // // MessageText: // // Moniker needs to be generic // public static final int MK_E_NEEDGENERIC = 0x800401E2; // // MessageId: MK_E_UNAVAILABLE // // MessageText: // // Operation unavailable // public static final int MK_E_UNAVAILABLE = 0x800401E3; // // MessageId: MK_E_SYNTAX // // MessageText: // // Invalid syntax // public static final int MK_E_SYNTAX = 0x800401E4; // // MessageId: MK_E_NOOBJECT // // MessageText: // // No object for moniker // public static final int MK_E_NOOBJECT = 0x800401E5; // // MessageId: MK_E_INVALIDEXTENSION // // MessageText: // // Bad extension for file // public static final int MK_E_INVALIDEXTENSION = 0x800401E6; // // MessageId: MK_E_INTERMEDIATEINTERFACENOTSUPPORTED // // MessageText: // // Intermediate operation failed // public static final int MK_E_INTERMEDIATEINTERFACENOTSUPPORTED = 0x800401E7; // // MessageId: MK_E_NOTBINDABLE // // MessageText: // // Moniker is not bindable // public static final int MK_E_NOTBINDABLE = 0x800401E8; // // MessageId: MK_E_NOTBOUND // // MessageText: // // Moniker is not bound // public static final int MK_E_NOTBOUND = 0x800401E9; // // MessageId: MK_E_CANTOPENFILE // // MessageText: // // Moniker cannot open file // public static final int MK_E_CANTOPENFILE = 0x800401EA; // // MessageId: MK_E_MUSTBOTHERUSER // // MessageText: // // User input required for operation to succeed // public static final int MK_E_MUSTBOTHERUSER = 0x800401EB; // // MessageId: MK_E_NOINVERSE // // MessageText: // // Moniker class has no inverse // public static final int MK_E_NOINVERSE = 0x800401EC; // // MessageId: MK_E_NOSTORAGE // // MessageText: // // Moniker does not refer to storage // public static final int MK_E_NOSTORAGE = 0x800401ED; // // MessageId: MK_E_NOPREFIX // // MessageText: // // No common prefix // public static final int MK_E_NOPREFIX = 0x800401EE; // // MessageId: MK_E_ENUMERATION_FAILED // // MessageText: // // Moniker could not be enumerated // public static final int MK_E_ENUMERATION_FAILED = 0x800401EF; public static final int CO_E_FIRST = 0x800401F0; public static final int CO_E_LAST = 0x800401FF; public static final int CO_S_FIRST = 0x000401F0; public static final int CO_S_LAST = 0x000401FF; // // MessageId: CO_E_NOTINITIALIZED // // MessageText: // // CoInitialize has not been called. // public static final int CO_E_NOTINITIALIZED = 0x800401F0; // // MessageId: CO_E_ALREADYINITIALIZED // // MessageText: // // CoInitialize has already been called. // public static final int CO_E_ALREADYINITIALIZED = 0x800401F1; // // MessageId: CO_E_CANTDETERMINECLASS // // MessageText: // // Class of object cannot be determined // public static final int CO_E_CANTDETERMINECLASS = 0x800401F2; // // MessageId: CO_E_CLASSSTRING // // MessageText: // // Invalid class string // public static final int CO_E_CLASSSTRING = 0x800401F3; // // MessageId: CO_E_IIDSTRING // // MessageText: // // Invalid interface string // public static final int CO_E_IIDSTRING = 0x800401F4; // // MessageId: CO_E_APPNOTFOUND // // MessageText: // // Application not found // public static final int CO_E_APPNOTFOUND = 0x800401F5; // // MessageId: CO_E_APPSINGLEUSE // // MessageText: // // Application cannot be run more than once // public static final int CO_E_APPSINGLEUSE = 0x800401F6; // // MessageId: CO_E_ERRORINAPP // // MessageText: // // Some error in application program // public static final int CO_E_ERRORINAPP = 0x800401F7; // // MessageId: CO_E_DLLNOTFOUND // // MessageText: // // DLL for class not found // public static final int CO_E_DLLNOTFOUND = 0x800401F8; // // MessageId: CO_E_ERRORINDLL // // MessageText: // // Error in the DLL // public static final int CO_E_ERRORINDLL = 0x800401F9; // // MessageId: CO_E_WRONGOSFORAPP // // MessageText: // // Wrong OS or OS version for application // public static final int CO_E_WRONGOSFORAPP = 0x800401FA; // // MessageId: CO_E_OBJNOTREG // // MessageText: // // Object is not registered // public static final int CO_E_OBJNOTREG = 0x800401FB; // // MessageId: CO_E_OBJISREG // // MessageText: // // Object is already registered // public static final int CO_E_OBJISREG = 0x800401FC; // // MessageId: CO_E_OBJNOTCONNECTED // // MessageText: // // Object is not connected to server // public static final int CO_E_OBJNOTCONNECTED = 0x800401FD; // // MessageId: CO_E_APPDIDNTREG // // MessageText: // // Application was launched but it didn't register a class factory // public static final int CO_E_APPDIDNTREG = 0x800401FE; // // MessageId: CO_E_RELEASED // // MessageText: // // Object has been released // public static final int CO_E_RELEASED = 0x800401FF; public static final int EVENT_E_FIRST = 0x80040200; public static final int EVENT_E_LAST = 0x8004021F; public static final int EVENT_S_FIRST = 0x00040200; public static final int EVENT_S_LAST = 0x0004021F; // // MessageId: EVENT_S_SOME_SUBSCRIBERS_FAILED // // MessageText: // // An event was able to invoke some but not all of the subscribers // public static final int EVENT_S_SOME_SUBSCRIBERS_FAILED = 0x00040200; // // MessageId: EVENT_E_ALL_SUBSCRIBERS_FAILED // // MessageText: // // An event was unable to invoke any of the subscribers // public static final int EVENT_E_ALL_SUBSCRIBERS_FAILED = 0x80040201; // // MessageId: EVENT_S_NOSUBSCRIBERS // // MessageText: // // An event was delivered but there were no subscribers // public static final int EVENT_S_NOSUBSCRIBERS = 0x00040202; // // MessageId: EVENT_E_QUERYSYNTAX // // MessageText: // // A syntax error occurred trying to evaluate a query string // public static final int EVENT_E_QUERYSYNTAX = 0x80040203; // // MessageId: EVENT_E_QUERYFIELD // // MessageText: // // An invalid field name was used in a query string // public static final int EVENT_E_QUERYFIELD = 0x80040204; // // MessageId: EVENT_E_INTERNALEXCEPTION // // MessageText: // // An unexpected exception was raised // public static final int EVENT_E_INTERNALEXCEPTION = 0x80040205; // // MessageId: EVENT_E_INTERNALERROR // // MessageText: // // An unexpected internal error was detected // public static final int EVENT_E_INTERNALERROR = 0x80040206; // // MessageId: EVENT_E_INVALID_PER_USER_SID // // MessageText: // // The owner SID on a per-user subscription doesn't exist // public static final int EVENT_E_INVALID_PER_USER_SID = 0x80040207; // // MessageId: EVENT_E_USER_EXCEPTION // // MessageText: // // A user-supplied component or subscriber raised an exception // public static final int EVENT_E_USER_EXCEPTION = 0x80040208; // // MessageId: EVENT_E_TOO_MANY_METHODS // // MessageText: // // An interface has too many methods to fire events from // public static final int EVENT_E_TOO_MANY_METHODS = 0x80040209; // // MessageId: EVENT_E_MISSING_EVENTCLASS // // MessageText: // // A subscription cannot be stored unless its event class already exists // public static final int EVENT_E_MISSING_EVENTCLASS = 0x8004020A; // // MessageId: EVENT_E_NOT_ALL_REMOVED // // MessageText: // // Not all the objects requested could be removed // public static final int EVENT_E_NOT_ALL_REMOVED = 0x8004020B; // // MessageId: EVENT_E_COMPLUS_NOT_INSTALLED // // MessageText: // // COM+ is required for this operation, but is not installed // public static final int EVENT_E_COMPLUS_NOT_INSTALLED = 0x8004020C; // // MessageId: EVENT_E_CANT_MODIFY_OR_DELETE_UNCONFIGURED_OBJECT // // MessageText: // // Cannot modify or delete an object that was not added using the COM+ Admin // SDK // public static final int EVENT_E_CANT_MODIFY_OR_DELETE_UNCONFIGURED_OBJECT = 0x8004020D; // // MessageId: EVENT_E_CANT_MODIFY_OR_DELETE_CONFIGURED_OBJECT // // MessageText: // // Cannot modify or delete an object that was added using the COM+ Admin SDK // public static final int EVENT_E_CANT_MODIFY_OR_DELETE_CONFIGURED_OBJECT = 0x8004020E; // // MessageId: EVENT_E_INVALID_EVENT_CLASS_PARTITION // // MessageText: // // The event class for this subscription is in an invalid partition // public static final int EVENT_E_INVALID_EVENT_CLASS_PARTITION = 0x8004020F; // // MessageId: EVENT_E_PER_USER_SID_NOT_LOGGED_ON // // MessageText: // // The owner of the PerUser subscription is not logged on to the system // specified // public static final int EVENT_E_PER_USER_SID_NOT_LOGGED_ON = 0x80040210; public static final int XACT_E_FIRST = 0x8004D000; public static final int XACT_E_LAST = 0x8004D029; public static final int XACT_S_FIRST = 0x0004D000; public static final int XACT_S_LAST = 0x0004D010; // // MessageId: XACT_E_ALREADYOTHERSINGLEPHASE // // MessageText: // // Another single phase resource manager has already been enlisted in this // transaction. // public static final int XACT_E_ALREADYOTHERSINGLEPHASE = 0x8004D000; // // MessageId: XACT_E_CANTRETAIN // // MessageText: // // A retaining commit or abort is not supported // public static final int XACT_E_CANTRETAIN = 0x8004D001; // // MessageId: XACT_E_COMMITFAILED // // MessageText: // // The transaction failed to commit for an unknown reason. The transaction // was aborted. // public static final int XACT_E_COMMITFAILED = 0x8004D002; // // MessageId: XACT_E_COMMITPREVENTED // // MessageText: // // Cannot call commit on this transaction object because the calling // application did not initiate the transaction. // public static final int XACT_E_COMMITPREVENTED = 0x8004D003; // // MessageId: XACT_E_HEURISTICABORT // // MessageText: // // Instead of committing, the resource heuristically aborted. // public static final int XACT_E_HEURISTICABORT = 0x8004D004; // // MessageId: XACT_E_HEURISTICCOMMIT // // MessageText: // // Instead of aborting, the resource heuristically committed. // public static final int XACT_E_HEURISTICCOMMIT = 0x8004D005; // // MessageId: XACT_E_HEURISTICDAMAGE // // MessageText: // // Some of the states of the resource were committed while others were // aborted, likely because of heuristic decisions. // public static final int XACT_E_HEURISTICDAMAGE = 0x8004D006; // // MessageId: XACT_E_HEURISTICDANGER // // MessageText: // // Some of the states of the resource may have been committed while others // may have been aborted, likely because of heuristic decisions. // public static final int XACT_E_HEURISTICDANGER = 0x8004D007; // // MessageId: XACT_E_ISOLATIONLEVEL // // MessageText: // // The requested isolation level is not valid or supported. // public static final int XACT_E_ISOLATIONLEVEL = 0x8004D008; // // MessageId: XACT_E_NOASYNC // // MessageText: // // The transaction manager doesn't support an asynchronous operation for // this method. // public static final int XACT_E_NOASYNC = 0x8004D009; // // MessageId: XACT_E_NOENLIST // // MessageText: // // Unable to enlist in the transaction. // public static final int XACT_E_NOENLIST = 0x8004D00A; // // MessageId: XACT_E_NOISORETAIN // // MessageText: // // The requested semantics of retention of isolation across retaining commit // and abort boundaries cannot be supported by this transaction // implementation, or isoF;ags was not equal to zero. // public static final int XACT_E_NOISORETAIN = 0x8004D00B; // // MessageId: XACT_E_NORESOURCE // // MessageText: // // There is no resource presently associated with this enlistment // public static final int XACT_E_NORESOURCE = 0x8004D00C; // // MessageId: XACT_E_NOTCURRENT // // MessageText: // // The transaction failed to commit due to the failure of optimistic // concurrency control in at least one of the resource managers. // public static final int XACT_E_NOTCURRENT = 0x8004D00D; // // MessageId: XACT_E_NOTRANSACTION // // MessageText: // // The transaction has already been implicitly or explicitly committed or // aborted // public static final int XACT_E_NOTRANSACTION = 0x8004D00E; // // MessageId: XACT_E_NOTSUPPORTED // // MessageText: // // An invalid combination of F;ags was specified // public static final int XACT_E_NOTSUPPORTED = 0x8004D00F; // // MessageId: XACT_E_UNKNOWNRMGRID // // MessageText: // // The resource manager id is not associated with this transaction or the // transaction manager. // public static final int XACT_E_UNKNOWNRMGRID = 0x8004D010; // // MessageId: XACT_E_WRONGSTATE // // MessageText: // // This method was called in the wrong state // public static final int XACT_E_WRONGSTATE = 0x8004D011; // // MessageId: XACT_E_WRONGUOW // // MessageText: // // The indicated unit of work does not match the unit of work expected by // the resource manager. // public static final int XACT_E_WRONGUOW = 0x8004D012; // // MessageId: XACT_E_XTIONEXISTS // // MessageText: // // An enlistment in a transaction already exists. // public static final int XACT_E_XTIONEXISTS = 0x8004D013; // // MessageId: XACT_E_NOIMPORTOBJECT // // MessageText: // // An import object for the transaction could not be found. // public static final int XACT_E_NOIMPORTOBJECT = 0x8004D014; // // MessageId: XACT_E_INVALIDCOOKIE // // MessageText: // // The transaction cookie is invalid. // public static final int XACT_E_INVALIDCOOKIE = 0x8004D015; // // MessageId: XACT_E_INDOUBT // // MessageText: // // The transaction status is in doubt. A communication failure occurred, or // a transaction manager or resource manager has failed // public static final int XACT_E_INDOUBT = 0x8004D016; // // MessageId: XACT_E_NOTIMEOUT // // MessageText: // // A time-out was specified, but time-outs are not supported. // public static final int XACT_E_NOTIMEOUT = 0x8004D017; // // MessageId: XACT_E_ALREADYINPROGRESS // // MessageText: // // The requested operation is already in progress for the transaction. // public static final int XACT_E_ALREADYINPROGRESS = 0x8004D018; // // MessageId: XACT_E_ABORTED // // MessageText: // // The transaction has already been aborted. // public static final int XACT_E_ABORTED = 0x8004D019; // // MessageId: XACT_E_LOGFULL // // MessageText: // // The Transaction Manager returned a log full error. // public static final int XACT_E_LOGFULL = 0x8004D01A; // // MessageId: XACT_E_TMNOTAVAILABLE // // MessageText: // // The Transaction Manager is not available. // public static final int XACT_E_TMNOTAVAILABLE = 0x8004D01B; // // MessageId: XACT_E_CONNECTION_DOWN // // MessageText: // // A connection with the transaction manager was lost. // public static final int XACT_E_CONNECTION_DOWN = 0x8004D01C; // // MessageId: XACT_E_CONNECTION_DENIED // // MessageText: // // A request to establish a connection with the transaction manager was // denied. // public static final int XACT_E_CONNECTION_DENIED = 0x8004D01D; // // MessageId: XACT_E_REENLISTTIMEOUT // // MessageText: // // Resource manager reenlistment to determine transaction status timed out. // public static final int XACT_E_REENLISTTIMEOUT = 0x8004D01E; // // MessageId: XACT_E_TIP_CONNECT_FAILED // // MessageText: // // This transaction manager failed to establish a connection with another // TIP transaction manager. // public static final int XACT_E_TIP_CONNECT_FAILED = 0x8004D01F; // // MessageId: XACT_E_TIP_PROTOCOL_ERROR // // MessageText: // // This transaction manager encountered a protocol error with another TIP // transaction manager. // public static final int XACT_E_TIP_PROTOCOL_ERROR = 0x8004D020; // // MessageId: XACT_E_TIP_PULL_FAILED // // MessageText: // // This transaction manager could not propagate a transaction from another // TIP transaction manager. // public static final int XACT_E_TIP_PULL_FAILED = 0x8004D021; // // MessageId: XACT_E_DEST_TMNOTAVAILABLE // // MessageText: // // The Transaction Manager on the destination machine is not available. // public static final int XACT_E_DEST_TMNOTAVAILABLE = 0x8004D022; // // MessageId: XACT_E_TIP_DISABLED // // MessageText: // // The Transaction Manager has disabled its support for TIP. // public static final int XACT_E_TIP_DISABLED = 0x8004D023; // // MessageId: XACT_E_NETWORK_TX_DISABLED // // MessageText: // // The transaction manager has disabled its support for remote/network // transactions. // public static final int XACT_E_NETWORK_TX_DISABLED = 0x8004D024; // // MessageId: XACT_E_PARTNER_NETWORK_TX_DISABLED // // MessageText: // // The partner transaction manager has disabled its support for // remote/network transactions. // public static final int XACT_E_PARTNER_NETWORK_TX_DISABLED = 0x8004D025; // // MessageId: XACT_E_XA_TX_DISABLED // // MessageText: // // The transaction manager has disabled its support for XA transactions. // public static final int XACT_E_XA_TX_DISABLED = 0x8004D026; // // MessageId: XACT_E_UNABLE_TO_READ_DTC_CONFIG // // MessageText: // // MSDTC was unable to read its configuration information. // public static final int XACT_E_UNABLE_TO_READ_DTC_CONFIG = 0x8004D027; // // MessageId: XACT_E_UNABLE_TO_LOAD_DTC_PROXY // // MessageText: // // MSDTC was unable to load the dtc proxy dll. // public static final int XACT_E_UNABLE_TO_LOAD_DTC_PROXY = 0x8004D028; // // MessageId: XACT_E_ABORTING // // MessageText: // // The local transaction has aborted. // public static final int XACT_E_ABORTING = 0x8004D029; // // TXF & CRM errors start=4d080. // // MessageId: XACT_E_CLERKNOTFOUND // // MessageText: // // XACT_E_CLERKNOTFOUND // public static final int XACT_E_CLERKNOTFOUND = 0x8004D080; // // MessageId: XACT_E_CLERKEXISTS // // MessageText: // // XACT_E_CLERKEXISTS // public static final int XACT_E_CLERKEXISTS = 0x8004D081; // // MessageId: XACT_E_RECOVERYINPROGRESS // // MessageText: // // XACT_E_RECOVERYINPROGRESS // public static final int XACT_E_RECOVERYINPROGRESS = 0x8004D082; // // MessageId: XACT_E_TRANSACTIONCLOSED // // MessageText: // // XACT_E_TRANSACTIONCLOSED // public static final int XACT_E_TRANSACTIONCLOSED = 0x8004D083; // // MessageId: XACT_E_INVALIDLSN // // MessageText: // // XACT_E_INVALIDLSN // public static final int XACT_E_INVALIDLSN = 0x8004D084; // // MessageId: XACT_E_REPLAYREQUEST // // MessageText: // // XACT_E_REPLAYREQUEST // public static final int XACT_E_REPLAYREQUEST = 0x8004D085; // Begin XACT_DTC_CONSTANTS enumerated values defined in txdtc.h // SymbolicName=XACT_E_CONNECTION_REQUEST_DENIED // // MessageId: 0x8004D100; (No symbolic name defined) // // MessageText: // // The request to connect to the specified transaction coordinator was // denied. // // SymbolicName=XACT_E_TOOMANY_ENLISTMENTS // // MessageId: 0x8004D101; (No symbolic name defined) // // MessageText: // // The maximum number of enlistments for the specified transaction has been // reached. // // SymbolicName=XACT_E_DUPLICATE_GUID // // MessageId: 0x8004D102; (No symbolic name defined) // // MessageText: // // A resource manager with the same identifier is already registered with // the specified transaction coordinator. // // SymbolicName=XACT_E_NOTSINGLEPHASE // // MessageId: 0x8004D103; (No symbolic name defined) // // MessageText: // // The prepare request given was not eligible for single phase // optimizations. // // SymbolicName=XACT_E_RECOVERYALREADYDONE // // MessageId: 0x8004D104; (No symbolic name defined) // // MessageText: // // RecoveryComplete has already been called for the given resource manager. // // SymbolicName=XACT_E_PROTOCOL // // MessageId: 0x8004D105; (No symbolic name defined) // // MessageText: // // The interface call made was incorrect for the current state of the // protocol. // // SymbolicName=XACT_E_RM_FAILURE // // MessageId: 0x8004D106; (No symbolic name defined) // // MessageText: // // xa_open call failed for the XA resource. // // SymbolicName=XACT_E_RECOVERY_FAILED // // MessageId: 0x8004D107; (No symbolic name defined) // // MessageText: // // xa_recover call failed for the XA resource. // // SymbolicName=XACT_E_LU_NOT_FOUND // // MessageId: 0x8004D108; (No symbolic name defined) // // MessageText: // // The Logical Unit of Work specified cannot be found. // // SymbolicName=XACT_E_DUPLICATE_LU // // MessageId: 0x8004D109; (No symbolic name defined) // // MessageText: // // The specified Logical Unit of Work already exists. // // SymbolicName=XACT_E_LU_NOT_CONNECTED // // MessageId: 0x8004D10AL (No symbolic name defined) // // MessageText: // // Subordinate creation failed. The specified Logical Unit of Work was not // connected. // // SymbolicName=XACT_E_DUPLICATE_TRANSID // // MessageId: 0x8004D10BL (No symbolic name defined) // // MessageText: // // A transaction with the given identifier already exists. // // SymbolicName=XACT_E_LU_BUSY // // MessageId: 0x8004D10CL (No symbolic name defined) // // MessageText: // // The resource is in use. // // SymbolicName=XACT_E_LU_NO_RECOVERY_PROCESS // // MessageId: 0x8004D10DL (No symbolic name defined) // // MessageText: // // The LU Recovery process is down. // // SymbolicName=XACT_E_LU_DOWN // // MessageId: 0x8004D10EL (No symbolic name defined) // // MessageText: // // The remote session was lost. // // SymbolicName=XACT_E_LU_RECOVERING // // MessageId: 0x8004D10F; (No symbolic name defined) // // MessageText: // // The resource is currently recovering. // // SymbolicName=XACT_E_LU_RECOVERY_MISMATCH // // MessageId: 0x8004D110; (No symbolic name defined) // // MessageText: // // There was a mismatch in driving recovery. // // SymbolicName=XACT_E_RM_UNAVAILABLE // // MessageId: 0x8004D111; (No symbolic name defined) // // MessageText: // // An error occurred with the XA resource. // // End XACT_DTC_CONSTANTS enumerated values defined in txdtc.h // // OleTx Success codes. // // // MessageId: XACT_S_ASYNC // // MessageText: // // An asynchronous operation was specified. The operation has begun, but its // outcome is not known yet. // public static final int XACT_S_ASYNC = 0x0004D000; // // MessageId: XACT_S_DEFECT // // MessageText: // // XACT_S_DEFECT // public static final int XACT_S_DEFECT = 0x0004D001; // // MessageId: XACT_S_READONLY // // MessageText: // // The method call succeeded because the transaction was read-only. // public static final int XACT_S_READONLY = 0x0004D002; // // MessageId: XACT_S_SOMENORETAIN // // MessageText: // // The transaction was successfully aborted. However, this is a coordinated // transaction, and some number of enlisted resources were aborted outright // because they could not support abort-retaining semantics // public static final int XACT_S_SOMENORETAIN = 0x0004D003; // // MessageId: XACT_S_OKINFORM // // MessageText: // // No changes were made during this call, but the sink wants another chance // to look if any other sinks make further changes. // public static final int XACT_S_OKINFORM = 0x0004D004; // // MessageId: XACT_S_MADECHANGESCONTENT // // MessageText: // // The sink is content and wishes the transaction to proceed. Changes were // made to one or more resources during this call. // public static final int XACT_S_MADECHANGESCONTENT = 0x0004D005; // // MessageId: XACT_S_MADECHANGESINFORM // // MessageText: // // The sink is for the moment and wishes the transaction to proceed, but if // other changes are made following this return by other event sinks then // this sink wants another chance to look // public static final int XACT_S_MADECHANGESINFORM = 0x0004D006; // // MessageId: XACT_S_ALLNORETAIN // // MessageText: // // The transaction was successfully aborted. However, the abort was // non-retaining. // public static final int XACT_S_ALLNORETAIN = 0x0004D007; // // MessageId: XACT_S_ABORTING // // MessageText: // // An abort operation was already in progress. // public static final int XACT_S_ABORTING = 0x0004D008; // // MessageId: XACT_S_SINGLEPHASE // // MessageText: // // The resource manager has performed a single-phase commit of the // transaction. // public static final int XACT_S_SINGLEPHASE = 0x0004D009; // // MessageId: XACT_S_LOCALLY_OK // // MessageText: // // The local transaction has not aborted. // public static final int XACT_S_LOCALLY_OK = 0x0004D00A; // // MessageId: XACT_S_LASTRESOURCEMANAGER // // MessageText: // // The resource manager has requested to be the coordinator (last resource // manager) for the transaction. // public static final int XACT_S_LASTRESOURCEMANAGER = 0x0004D010; public static final int CONTEXT_E_FIRST = 0x8004E000; public static final int CONTEXT_E_LAST = 0x8004E02F; public static final int CONTEXT_S_FIRST = 0x0004E000; public static final int CONTEXT_S_LAST = 0x0004E02F; // // MessageId: CONTEXT_E_ABORTED // // MessageText: // // The root transaction wanted to commit, but transaction aborted // public static final int CONTEXT_E_ABORTED = 0x8004E002; // // MessageId: CONTEXT_E_ABORTING // // MessageText: // // You made a method call on a COM+ component that has a transaction that // has already aborted or in the process of aborting. // public static final int CONTEXT_E_ABORTING = 0x8004E003; // // MessageId: CONTEXT_E_NOCONTEXT // // MessageText: // // There is no MTS object context // public static final int CONTEXT_E_NOCONTEXT = 0x8004E004; // // MessageId: CONTEXT_E_WOULD_DEADLOCK // // MessageText: // // The component is configured to use synchronization and this method call // would cause a deadlock to occur. // public static final int CONTEXT_E_WOULD_DEADLOCK = 0x8004E005; // // MessageId: CONTEXT_E_SYNCH_TIMEOUT // // MessageText: // // The component is configured to use synchronization and a thread has timed // out waiting to enter the context. // public static final int CONTEXT_E_SYNCH_TIMEOUT = 0x8004E006; // // MessageId: CONTEXT_E_OLDREF // // MessageText: // // You made a method call on a COM+ component that has a transaction that // has already committed or aborted. // public static final int CONTEXT_E_OLDREF = 0x8004E007; // // MessageId: CONTEXT_E_ROLENOTFOUND // // MessageText: // // The specified role was not configured for the application // public static final int CONTEXT_E_ROLENOTFOUND = 0x8004E00C; // // MessageId: CONTEXT_E_TMNOTAVAILABLE // // MessageText: // // COM+ was unable to talk to the Microsoft Distributed Transaction // Coordinator // public static final int CONTEXT_E_TMNOTAVAILABLE = 0x8004E00F; // // MessageId: CO_E_ACTIVATIONFAILED // // MessageText: // // An unexpected error occurred during COM+ Activation. // public static final int CO_E_ACTIVATIONFAILED = 0x8004E021; // // MessageId: CO_E_ACTIVATIONFAILED_EVENTLOGGED // // MessageText: // // COM+ Activation failed. Check the event log for more information // public static final int CO_E_ACTIVATIONFAILED_EVENTLOGGED = 0x8004E022; // // MessageId: CO_E_ACTIVATIONFAILED_CATALOGERROR // // MessageText: // // COM+ Activation failed due to a catalog or configuration error. // public static final int CO_E_ACTIVATIONFAILED_CATALOGERROR = 0x8004E023; // // MessageId: CO_E_ACTIVATIONFAILED_TIMEOUT // // MessageText: // // COM+ activation failed because the activation could not be completed in // the specified amount of time. // public static final int CO_E_ACTIVATIONFAILED_TIMEOUT = 0x8004E024; // // MessageId: CO_E_INITIALIZATIONFAILED // // MessageText: // // COM+ Activation failed because an initialization function failed. Check // the event log for more information. // public static final int CO_E_INITIALIZATIONFAILED = 0x8004E025; // // MessageId: CONTEXT_E_NOJIT // // MessageText: // // The requested operation requires that JIT be in the current context and // it is not // public static final int CONTEXT_E_NOJIT = 0x8004E026; // // MessageId: CONTEXT_E_NOTRANSACTION // // MessageText: // // The requested operation requires that the current context have a // Transaction, and it does not // public static final int CONTEXT_E_NOTRANSACTION = 0x8004E027; // // MessageId: CO_E_THREADINGMODEL_CHANGED // // MessageText: // // The components threading model has changed after install into a COM+ // Application. Please re-install component. // public static final int CO_E_THREADINGMODEL_CHANGED = 0x8004E028; // // MessageId: CO_E_NOIISINTRINSICS // // MessageText: // // IIS intrinsics not available. Start your work with IIS. // public static final int CO_E_NOIISINTRINSICS = 0x8004E029; // // MessageId: CO_E_NOCOOKIES // // MessageText: // // An attempt to write a cookie failed. // public static final int CO_E_NOCOOKIES = 0x8004E02A; // // MessageId: CO_E_DBERROR // // MessageText: // // An attempt to use a database generated a database specific error. // public static final int CO_E_DBERROR = 0x8004E02B; // // MessageId: CO_E_NOTPOOLED // // MessageText: // // The COM+ component you created must use object pooling to work. // public static final int CO_E_NOTPOOLED = 0x8004E02C; // // MessageId: CO_E_NOTCONSTRUCTED // // MessageText: // // The COM+ component you created must use object construction to work // correctly. // public static final int CO_E_NOTCONSTRUCTED = 0x8004E02D; // // MessageId: CO_E_NOSYNCHRONIZATION // // MessageText: // // The COM+ component requires synchronization, and it is not configured for // it. // public static final int CO_E_NOSYNCHRONIZATION = 0x8004E02E; // // MessageId: CO_E_ISOLEVELMISMATCH // // MessageText: // // The TxIsolation Level property for the COM+ component being created is // stronger than the TxIsolationLevel for the "root" component for the // transaction. The creation failed. // public static final int CO_E_ISOLEVELMISMATCH = 0x8004E02F; // // MessageId: CO_E_CALL_OUT_OF_TX_SCOPE_NOT_ALLOWED // // MessageText: // // The component attempted to make a cross-context call between invocations // of EnterTransactionScopeand ExitTransactionScope. This is not allowed. // Cross-context calls cannot be made while inside of a transaction scope. // public static final int CO_E_CALL_OUT_OF_TX_SCOPE_NOT_ALLOWED = 0x8004E030; // // MessageId: CO_E_EXIT_TRANSACTION_SCOPE_NOT_CALLED // // MessageText: // // The component made a call to EnterTransactionScope, but did not make a // corresponding call to ExitTransactionScope before returning. // public static final int CO_E_EXIT_TRANSACTION_SCOPE_NOT_CALLED = 0x8004E031; // // Old OLE Success Codes // // // MessageId: OLE_S_USEREG // // MessageText: // // Use the registry database to provide the requested information // public static final int OLE_S_USEREG = 0x00040000; // // MessageId: OLE_S_STATIC // // MessageText: // // Success, but static // public static final int OLE_S_STATIC = 0x00040001; // // MessageId: OLE_S_MAC_CLIPFORMAT // // MessageText: // // Macintosh clipboard format // public static final int OLE_S_MAC_CLIPFORMAT = 0x00040002; // // MessageId: DRAGDROP_S_DROP // // MessageText: // // Successful drop took place // public static final int DRAGDROP_S_DROP = 0x00040100; // // MessageId: DRAGDROP_S_CANCEL // // MessageText: // // Drag-drop operation canceled // public static final int DRAGDROP_S_CANCEL = 0x00040101; // // MessageId: DRAGDROP_S_USEDEFAULTCURSORS // // MessageText: // // Use the default cursor // public static final int DRAGDROP_S_USEDEFAULTCURSORS = 0x00040102; // // MessageId: DATA_S_SAMEFORMATETC // // MessageText: // // Data has same FORMATETC // public static final int DATA_S_SAMEFORMATETC = 0x00040130; // // MessageId: VIEW_S_ALREADY_FROZEN // // MessageText: // // View is already frozen // public static final int VIEW_S_ALREADY_FROZEN = 0x00040140; // // MessageId: CACHE_S_FORMATETC_NOTSUPPORTED // // MessageText: // // FORMATETC not supported // public static final int CACHE_S_FORMATETC_NOTSUPPORTED = 0x00040170; // // MessageId: CACHE_S_SAMECACHE // // MessageText: // // Same cache // public static final int CACHE_S_SAMECACHE = 0x00040171; // // MessageId: CACHE_S_SOMECACHES_NOTUPDATED // // MessageText: // // Some cache(s) not updated // public static final int CACHE_S_SOMECACHES_NOTUPDATED = 0x00040172; // // MessageId: OLEOBJ_S_INVALIDVERB // // MessageText: // // Invalid verb for OLE object // public static final int OLEOBJ_S_INVALIDVERB = 0x00040180; // // MessageId: OLEOBJ_S_CANNOT_DOVERB_NOW // // MessageText: // // Verb number is valid but verb cannot be done now // public static final int OLEOBJ_S_CANNOT_DOVERB_NOW = 0x00040181; // // MessageId: OLEOBJ_S_INVALIDHWND // // MessageText: // // Invalid window handle passed // public static final int OLEOBJ_S_INVALIDHWND = 0x00040182; // // MessageId: INPLACE_S_TRUNCATED // // MessageText: // // Message is too long; some of it had to be truncated before displaying // public static final int INPLACE_S_TRUNCATED = 0x000401A0; // // MessageId: CONVERT10_S_NO_PRESENTATION // // MessageText: // // Unable to convert OLESTREAM to IStorage // public static final int CONVERT10_S_NO_PRESENTATION = 0x000401C0; // // MessageId: MK_S_REDUCED_TO_SELF // // MessageText: // // Moniker reduced to itself // public static final int MK_S_REDUCED_TO_SELF = 0x000401E2; // // MessageId: MK_S_ME // // MessageText: // // Common prefix is this moniker // public static final int MK_S_ME = 0x000401E4; // // MessageId: MK_S_HIM // // MessageText: // // Common prefix is input moniker // public static final int MK_S_HIM = 0x000401E5; // // MessageId: MK_S_US // // MessageText: // // Common prefix is both monikers // public static final int MK_S_US = 0x000401E6; // // MessageId: MK_S_MONIKERALREADYREGISTERED // // MessageText: // // Moniker is already registered in running object table // public static final int MK_S_MONIKERALREADYREGISTERED = 0x000401E7; // // Task Scheduler errors // // // MessageId: SCHED_S_TASK_READY // // MessageText: // // The task is ready to run at its next scheduled time. // public static final int SCHED_S_TASK_READY = 0x00041300; // // MessageId: SCHED_S_TASK_RUNNING // // MessageText: // // The task is currently running. // public static final int SCHED_S_TASK_RUNNING = 0x00041301; // // MessageId: SCHED_S_TASK_DISABLED // // MessageText: // // The task will not run at the scheduled times because it has been // disabled. // public static final int SCHED_S_TASK_DISABLED = 0x00041302; // // MessageId: SCHED_S_TASK_HAS_NOT_RUN // // MessageText: // // The task has not yet run. // public static final int SCHED_S_TASK_HAS_NOT_RUN = 0x00041303; // // MessageId: SCHED_S_TASK_NO_MORE_RUNS // // MessageText: // // There are no more runs scheduled for this task. // public static final int SCHED_S_TASK_NO_MORE_RUNS = 0x00041304; // // MessageId: SCHED_S_TASK_NOT_SCHEDULED // // MessageText: // // One or more of the properties that are needed to run this task on a // schedule have not been set. // public static final int SCHED_S_TASK_NOT_SCHEDULED = 0x00041305; // // MessageId: SCHED_S_TASK_TERMINATED // // MessageText: // // The last run of the task was terminated by the user. // public static final int SCHED_S_TASK_TERMINATED = 0x00041306; // // MessageId: SCHED_S_TASK_NO_VALID_TRIGGERS // // MessageText: // // Either the task has no triggers or the existing triggers are disabled or // not set. // public static final int SCHED_S_TASK_NO_VALID_TRIGGERS = 0x00041307; // // MessageId: SCHED_S_EVENT_TRIGGER // // MessageText: // // Event triggers don't have set run times. // public static final int SCHED_S_EVENT_TRIGGER = 0x00041308; // // MessageId: SCHED_E_TRIGGER_NOT_FOUND // // MessageText: // // Trigger not found. // public static final int SCHED_E_TRIGGER_NOT_FOUND = 0x80041309; // // MessageId: SCHED_E_TASK_NOT_READY // // MessageText: // // One or more of the properties that are needed to run this task have not // been set. // public static final int SCHED_E_TASK_NOT_READY = 0x8004130A; // // MessageId: SCHED_E_TASK_NOT_RUNNING // // MessageText: // // There is no running instance of the task. // public static final int SCHED_E_TASK_NOT_RUNNING = 0x8004130B; // // MessageId: SCHED_E_SERVICE_NOT_INSTALLED // // MessageText: // // The Task Scheduler Service is not installed on this computer. // public static final int SCHED_E_SERVICE_NOT_INSTALLED = 0x8004130C; // // MessageId: SCHED_E_CANNOT_OPEN_TASK // // MessageText: // // The task object could not be opened. // public static final int SCHED_E_CANNOT_OPEN_TASK = 0x8004130D; // // MessageId: SCHED_E_INVALID_TASK // // MessageText: // // The object is either an invalid task object or is not a task object. // public static final int SCHED_E_INVALID_TASK = 0x8004130E; // // MessageId: SCHED_E_ACCOUNT_INFORMATION_NOT_SET // // MessageText: // // No account information could be found in the Task Scheduler security // database for the task indicated. // public static final int SCHED_E_ACCOUNT_INFORMATION_NOT_SET = 0x8004130F; // // MessageId: SCHED_E_ACCOUNT_NAME_NOT_FOUND // // MessageText: // // Unable to establish existence of the account specified. // public static final int SCHED_E_ACCOUNT_NAME_NOT_FOUND = 0x80041310; // // MessageId: SCHED_E_ACCOUNT_DBASE_CORRUPT // // MessageText: // // Corruption was detected in the Task Scheduler security database; the // database has been reset. // public static final int SCHED_E_ACCOUNT_DBASE_CORRUPT = 0x80041311; // // MessageId: SCHED_E_NO_SECURITY_SERVICES // // MessageText: // // Task Scheduler security services are available only on Windows NT. // public static final int SCHED_E_NO_SECURITY_SERVICES = 0x80041312; // // MessageId: SCHED_E_UNKNOWN_OBJECT_VERSION // // MessageText: // // The task object version is either unsupported or invalid. // public static final int SCHED_E_UNKNOWN_OBJECT_VERSION = 0x80041313; // // MessageId: SCHED_E_UNSUPPORTED_ACCOUNT_OPTION // // MessageText: // // The task has been configured with an unsupported combination of account // settings and run time options. // public static final int SCHED_E_UNSUPPORTED_ACCOUNT_OPTION = 0x80041314; // // MessageId: SCHED_E_SERVICE_NOT_RUNNING // // MessageText: // // The Task Scheduler Service is not running. // public static final int SCHED_E_SERVICE_NOT_RUNNING = 0x80041315; // // MessageId: SCHED_E_UNEXPECTEDNODE // // MessageText: // // The task XML contains an unexpected node. // public static final int SCHED_E_UNEXPECTEDNODE = 0x80041316; // // MessageId: SCHED_E_NAMESPACE // // MessageText: // // The task XML contains an element or attribute from an unexpected // namespace. // public static final int SCHED_E_NAMESPACE = 0x80041317; // // MessageId: SCHED_E_INVALIDVALUE // // MessageText: // // The task XML contains a value which is incorrectly formatted or out of // range. // public static final int SCHED_E_INVALIDVALUE = 0x80041318; // // MessageId: SCHED_E_MISSINGNODE // // MessageText: // // The task XML is missing a required element or attribute. // public static final int SCHED_E_MISSINGNODE = 0x80041319; // // MessageId: SCHED_E_MALFORMEDXML // // MessageText: // // The task XML is malformed. // public static final int SCHED_E_MALFORMEDXML = 0x8004131A; // // MessageId: SCHED_S_SOME_TRIGGERS_FAILED // // MessageText: // // The task is registered, but not all specified triggers will start the // task. // public static final int SCHED_S_SOME_TRIGGERS_FAILED = 0x0004131B; // // MessageId: SCHED_S_BATCH_LOGON_PROBLEM // // MessageText: // // The task is registered, but may fail to start. Batch logon privilege // needs to be enabled for the task principal. // public static final int SCHED_S_BATCH_LOGON_PROBLEM = 0x0004131C; // // MessageId: SCHED_E_TOO_MANY_NODES // // MessageText: // // The task XML contains too many nodes of the same type. // public static final int SCHED_E_TOO_MANY_NODES = 0x8004131D; // // MessageId: SCHED_E_PAST_END_BOUNDARY // // MessageText: // // The task cannot be started after the trigger's end boundary. // public static final int SCHED_E_PAST_END_BOUNDARY = 0x8004131E; // // MessageId: SCHED_E_ALREADY_RUNNING // // MessageText: // // An instance of this task is already running. // public static final int SCHED_E_ALREADY_RUNNING = 0x8004131F; // // MessageId: SCHED_E_USER_NOT_LOGGED_ON // // MessageText: // // The task will not run because the user is not logged on. // public static final int SCHED_E_USER_NOT_LOGGED_ON = 0x80041320; // // MessageId: SCHED_E_INVALID_TASK_HASH // // MessageText: // // The task image is corrupt or has been tampered with. // public static final int SCHED_E_INVALID_TASK_HASH = 0x80041321; // // MessageId: SCHED_E_SERVICE_NOT_AVAILABLE // // MessageText: // // The Task Scheduler service is not available. // public static final int SCHED_E_SERVICE_NOT_AVAILABLE = 0x80041322; // // MessageId: SCHED_E_SERVICE_TOO_BUSY // // MessageText: // // The Task Scheduler service is too busy to handle your request. Please try // again later. // public static final int SCHED_E_SERVICE_TOO_BUSY = 0x80041323; // // MessageId: SCHED_E_TASK_ATTEMPTED // // MessageText: // // The Task Scheduler service attempted to run the task, but the task did // not run due to one of the constraints in the task definition. // public static final int SCHED_E_TASK_ATTEMPTED = 0x80041324; // // MessageId: SCHED_S_TASK_QUEUED // // MessageText: // // The Task Scheduler service has asked the task to run. // public static final int SCHED_S_TASK_QUEUED = 0x00041325; // // MessageId: SCHED_E_TASK_DISABLED // // MessageText: // // The task is disabled. // public static final int SCHED_E_TASK_DISABLED = 0x80041326; // // MessageId: SCHED_E_TASK_NOT_V1_COMPAT // // MessageText: // // The task has properties that are not compatible with previous versions of // Windows. // public static final int SCHED_E_TASK_NOT_V1_COMPAT = 0x80041327; // // MessageId: SCHED_E_START_ON_DEMAND // // MessageText: // // The task settings do not allow the task to start on demand. // public static final int SCHED_E_START_ON_DEMAND = 0x80041328; // ****************** // FACILITY_WINDOWS // ****************** // // Codes 0x0-0x01ff are reserved for the OLE group of // interfaces. // // // MessageId: CO_E_CLASS_CREATE_FAILED // // MessageText: // // Attempt to create a class object failed // public static final int CO_E_CLASS_CREATE_FAILED = 0x80080001; // // MessageId: CO_E_SCM_ERROR // // MessageText: // // OLE service could not bind object // public static final int CO_E_SCM_ERROR = 0x80080002; // // MessageId: CO_E_SCM_RPC_FAILURE // // MessageText: // // RPC communication failed with OLE service // public static final int CO_E_SCM_RPC_FAILURE = 0x80080003; // // MessageId: CO_E_BAD_PATH // // MessageText: // // Bad path to object // public static final int CO_E_BAD_PATH = 0x80080004; // // MessageId: CO_E_SERVER_EXEC_FAILURE // // MessageText: // // Server execution failed // public static final int CO_E_SERVER_EXEC_FAILURE = 0x80080005; // // MessageId: CO_E_OBJSRV_RPC_FAILURE // // MessageText: // // OLE service could not communicate with the object server // public static final int CO_E_OBJSRV_RPC_FAILURE = 0x80080006; // // MessageId: MK_E_NO_NORMALIZED // // MessageText: // // Moniker path could not be normalized // public static final int MK_E_NO_NORMALIZED = 0x80080007; // // MessageId: CO_E_SERVER_STOPPING // // MessageText: // // Object server is stopping when OLE service contacts it // public static final int CO_E_SERVER_STOPPING = 0x80080008; // // MessageId: MEM_E_INVALID_ROOT // // MessageText: // // An invalid root block pointer was specified // public static final int MEM_E_INVALID_ROOT = 0x80080009; // // MessageId: MEM_E_INVALID_LINK // // MessageText: // // An allocation chain contained an invalid link pointer // public static final int MEM_E_INVALID_LINK = 0x80080010; // // MessageId: MEM_E_INVALID_SIZE // // MessageText: // // The requested allocation size was too large // public static final int MEM_E_INVALID_SIZE = 0x80080011; // // MessageId: CO_S_NOTALLINTERFACES // // MessageText: // // Not all the requested interfaces were available // public static final int CO_S_NOTALLINTERFACES = 0x00080012; // // MessageId: CO_S_MACHINENAMENOTFOUND // // MessageText: // // The specified machine name was not found in the cache. // public static final int CO_S_MACHINENAMENOTFOUND = 0x00080013; // // MessageId: CO_E_MISSING_DISPLAYNAME // // MessageText: // // The activation requires a display name to be present under the CLSID key. // public static final int CO_E_MISSING_DISPLAYNAME = 0x80080015; // // MessageId: CO_E_RUNAS_VALUE_MUST_BE_AAA // // MessageText: // // The activation requires that the RunAs value for the application is // Activate As Activator. // public static final int CO_E_RUNAS_VALUE_MUST_BE_AAA = 0x80080016; // // MessageId: CO_E_ELEVATION_DISABLED // // MessageText: // // The class is not configured to support Elevated activation. // public static final int CO_E_ELEVATION_DISABLED = 0x80080017; // ****************** // FACILITY_DISPATCH // ****************** // // MessageId: DISP_E_UNKNOWNINTERFACE // // MessageText: // // Unknown interface. // public static final int DISP_E_UNKNOWNINTERFACE = 0x80020001; // // MessageId: DISP_E_MEMBERNOTFOUND // // MessageText: // // Member not found. // public static final int DISP_E_MEMBERNOTFOUND = 0x80020003; // // MessageId: DISP_E_PARAMNOTFOUND // // MessageText: // // Parameter not found. // public static final int DISP_E_PARAMNOTFOUND = 0x80020004; // // MessageId: DISP_E_TYPEMISMATCH // // MessageText: // // Type mismatch. // public static final int DISP_E_TYPEMISMATCH = 0x80020005; // // MessageId: DISP_E_UNKNOWNNAME // // MessageText: // // Unknown name. // public static final int DISP_E_UNKNOWNNAME = 0x80020006; // // MessageId: DISP_E_NONAMEDARGS // // MessageText: // // No named arguments. // public static final int DISP_E_NONAMEDARGS = 0x80020007; // // MessageId: DISP_E_BADVARTYPE // // MessageText: // // Bad variable type. // public static final int DISP_E_BADVARTYPE = 0x80020008; // // MessageId: DISP_E_EXCEPTION // // MessageText: // // Exception occurred. // public static final int DISP_E_EXCEPTION = 0x80020009; // // MessageId: DISP_E_OVERF;OW // // MessageText: // // Out of present range. // public static final int DISP_E_OVERFLOW = 0x8002000A; // // MessageId: DISP_E_BADINDEX // // MessageText: // // Invalid index. // public static final int DISP_E_BADINDEX = 0x8002000B; // // MessageId: DISP_E_UNKNOWNLCID // // MessageText: // // Unknown language. // public static final int DISP_E_UNKNOWNLCID = 0x8002000C; // // MessageId: DISP_E_ARRAYISLOCKED // // MessageText: // // Memory is locked. // public static final int DISP_E_ARRAYISLOCKED = 0x8002000D; // // MessageId: DISP_E_BADPARAMCOUNT // // MessageText: // // Invalid number of parameters. // public static final int DISP_E_BADPARAMCOUNT = 0x8002000E; // // MessageId: DISP_E_PARAMNOTOPTIONAL // // MessageText: // // Parameter not optional. // public static final int DISP_E_PARAMNOTOPTIONAL = 0x8002000F; // // MessageId: DISP_E_BADCALLEE // // MessageText: // // Invalid callee. // public static final int DISP_E_BADCALLEE = 0x80020010; // // MessageId: DISP_E_NOTACOLLECTION // // MessageText: // // Does not support a collection. // public static final int DISP_E_NOTACOLLECTION = 0x80020011; // // MessageId: DISP_E_DIVBYZERO // // MessageText: // // Division by zero. // public static final int DISP_E_DIVBYZERO = 0x80020012; // // MessageId: DISP_E_BUFFERTOOSMALL // // MessageText: // // Buffer too small // public static final int DISP_E_BUFFERTOOSMALL = 0x80020013; // // MessageId: TYPE_E_BUFFERTOOSMALL // // MessageText: // // Buffer too small. // public static final int TYPE_E_BUFFERTOOSMALL = 0x80028016; // // MessageId: TYPE_E_FIELDNOTFOUND // // MessageText: // // Field name not defined in the record. // public static final int TYPE_E_FIELDNOTFOUND = 0x80028017; // // MessageId: TYPE_E_INVDATAREAD // // MessageText: // // Old format or invalid type library. // public static final int TYPE_E_INVDATAREAD = 0x80028018; // // MessageId: TYPE_E_UNSUPFORMAT // // MessageText: // // Old format or invalid type library. // public static final int TYPE_E_UNSUPFORMAT = 0x80028019; // // MessageId: TYPE_E_REGISTRYACCESS // // MessageText: // // Error accessing the OLE registry. // public static final int TYPE_E_REGISTRYACCESS = 0x8002801C; // // MessageId: TYPE_E_LIBNOTREGISTERED // // MessageText: // // Library not registered. // public static final int TYPE_E_LIBNOTREGISTERED = 0x8002801D; // // MessageId: TYPE_E_UNDEFINEDTYPE // // MessageText: // // Bound to unknown type. // public static final int TYPE_E_UNDEFINEDTYPE = 0x80028027; // // MessageId: TYPE_E_QUALIFIEDNAMEDISALLOWED // // MessageText: // // Qualified name disallowed. // public static final int TYPE_E_QUALIFIEDNAMEDISALLOWED = 0x80028028; // // MessageId: TYPE_E_INVALIDSTATE // // MessageText: // // Invalid forward reference, or reference to uncompiled type. // public static final int TYPE_E_INVALIDSTATE = 0x80028029; // // MessageId: TYPE_E_WRONGTYPEKIND // // MessageText: // // Type mismatch. // public static final int TYPE_E_WRONGTYPEKIND = 0x8002802A; // // MessageId: TYPE_E_ELEMENTNOTFOUND // // MessageText: // // Element not found. // public static final int TYPE_E_ELEMENTNOTFOUND = 0x8002802B; // // MessageId: TYPE_E_AMBIGUOUSNAME // // MessageText: // // Ambiguous name. // public static final int TYPE_E_AMBIGUOUSNAME = 0x8002802C; // // MessageId: TYPE_E_NAMECONF;ICT // // MessageText: // // Name already exists in the library. // public static final int TYPE_E_NAMECONFLICT = 0x8002802D; // // MessageId: TYPE_E_UNKNOWNLCID // // MessageText: // // Unknown LCID. // public static final int TYPE_E_UNKNOWNLCID = 0x8002802E; // // MessageId: TYPE_E_DLLFUNCTIONNOTFOUND // // MessageText: // // Function not defined in specified DLL. // public static final int TYPE_E_DLLFUNCTIONNOTFOUND = 0x8002802F; // // MessageId: TYPE_E_BADMODULEKIND // // MessageText: // // Wrong module kind for the operation. // public static final int TYPE_E_BADMODULEKIND = 0x800288BD; // // MessageId: TYPE_E_SIZETOOBIG // // MessageText: // // Size may not exceed=64K. // public static final int TYPE_E_SIZETOOBIG = 0x800288C5; // // MessageId: TYPE_E_DUPLICATEID // // MessageText: // // Duplicate ID in inheritance hierarchy. // public static final int TYPE_E_DUPLICATEID = 0x800288C6; // // MessageId: TYPE_E_INVALIDID // // MessageText: // // Incorrect inheritance depth in standard OLE hmember. // public static final int TYPE_E_INVALIDID = 0x800288CF; // // MessageId: TYPE_E_TYPEMISMATCH // // MessageText: // // Type mismatch. // public static final int TYPE_E_TYPEMISMATCH = 0x80028CA0; // // MessageId: TYPE_E_OUTOFBOUNDS // // MessageText: // // Invalid number of arguments. // public static final int TYPE_E_OUTOFBOUNDS = 0x80028CA1; // // MessageId: TYPE_E_IOERROR // // MessageText: // // I/O Error. // public static final int TYPE_E_IOERROR = 0x80028CA2; // // MessageId: TYPE_E_CANTCREATETMPFILE // // MessageText: // // Error creating unique tmp file. // public static final int TYPE_E_CANTCREATETMPFILE = 0x80028CA3; // // MessageId: TYPE_E_CANTLOADLIBRARY // // MessageText: // // Error loading type library/DLL. // public static final int TYPE_E_CANTLOADLIBRARY = 0x80029C4A; // // MessageId: TYPE_E_INCONSISTENTPROPFUNCS // // MessageText: // // Inconsistent property functions. // public static final int TYPE_E_INCONSISTENTPROPFUNCS = 0x80029C83; // // MessageId: TYPE_E_CIRCULARTYPE // // MessageText: // // Circular dependency between types/modules. // public static final int TYPE_E_CIRCULARTYPE = 0x80029C84; // ****************** // FACILITY_STORAGE // ****************** // // MessageId: STG_E_INVALIDFUNCTION // // MessageText: // // Unable to perform requested operation. // public static final int STG_E_INVALIDFUNCTION = 0x80030001; // // MessageId: STG_E_FILENOTFOUND // // MessageText: // // %1 could not be found. // public static final int STG_E_FILENOTFOUND = 0x80030002; // // MessageId: STG_E_PATHNOTFOUND // // MessageText: // // The path %1 could not be found. // public static final int STG_E_PATHNOTFOUND = 0x80030003; // // MessageId: STG_E_TOOMANYOPENFILES // // MessageText: // // There are insufficient resources to open another file. // public static final int STG_E_TOOMANYOPENFILES = 0x80030004; // // MessageId: STG_E_ACCESSDENIED // // MessageText: // // Access Denied. // public static final int STG_E_ACCESSDENIED = 0x80030005; // // MessageId: STG_E_INVALIDHANDLE // // MessageText: // // Attempted an operation on an invalid object. // public static final int STG_E_INVALIDHANDLE = 0x80030006; // // MessageId: STG_E_INSUFFICIENTMEMORY // // MessageText: // // There is insufficient memory available to complete operation. // public static final int STG_E_INSUFFICIENTMEMORY = 0x80030008; // // MessageId: STG_E_INVALIDPOINTER // // MessageText: // // Invalid pointer error. // public static final int STG_E_INVALIDPOINTER = 0x80030009; // // MessageId: STG_E_NOMOREFILES // // MessageText: // // There are no more entries to return. // public static final int STG_E_NOMOREFILES = 0x80030012; // // MessageId: STG_E_DISKISWRITEPROTECTED // // MessageText: // // Disk is write-protected. // public static final int STG_E_DISKISWRITEPROTECTED = 0x80030013; // // MessageId: STG_E_SEEKERROR // // MessageText: // // An error occurred during a seek operation. // public static final int STG_E_SEEKERROR = 0x80030019; // // MessageId: STG_E_WRITEFAULT // // MessageText: // // A disk error occurred during a write operation. // public static final int STG_E_WRITEFAULT = 0x8003001D; // // MessageId: STG_E_READFAULT // // MessageText: // // A disk error occurred during a read operation. // public static final int STG_E_READFAULT = 0x8003001E; // // MessageId: STG_E_SHAREVIOLATION // // MessageText: // // A share violation has occurred. // public static final int STG_E_SHAREVIOLATION = 0x80030020; // // MessageId: STG_E_LOCKVIOLATION // // MessageText: // // A lock violation has occurred. // public static final int STG_E_LOCKVIOLATION = 0x80030021; // // MessageId: STG_E_FILEALREADYEXISTS // // MessageText: // // %1 already exists. // public static final int STG_E_FILEALREADYEXISTS = 0x80030050; // // MessageId: STG_E_INVALIDPARAMETER // // MessageText: // // Invalid parameter error. // public static final int STG_E_INVALIDPARAMETER = 0x80030057; // // MessageId: STG_E_MEDIUMFULL // // MessageText: // // There is insufficient disk space to complete operation. // public static final int STG_E_MEDIUMFULL = 0x80030070; // // MessageId: STG_E_PROPSETMISMATCHED // // MessageText: // // Illegal write of non-simple property to simple property set. // public static final int STG_E_PROPSETMISMATCHED = 0x800300F0; // // MessageId: STG_E_ABNORMALAPIEXIT // // MessageText: // // An API call exited abnormally. // public static final int STG_E_ABNORMALAPIEXIT = 0x800300FA; // // MessageId: STG_E_INVALIDHEADER // // MessageText: // // The file %1 is not a valid compound file. // public static final int STG_E_INVALIDHEADER = 0x800300FB; // // MessageId: STG_E_INVALIDNAME // // MessageText: // // The name %1 is not valid. // public static final int STG_E_INVALIDNAME = 0x800300FC; // // MessageId: STG_E_UNKNOWN // // MessageText: // // An unexpected error occurred. // public static final int STG_E_UNKNOWN = 0x800300FD; // // MessageId: STG_E_UNIMPLEMENTEDFUNCTION // // MessageText: // // That function is not implemented. // public static final int STG_E_UNIMPLEMENTEDFUNCTION = 0x800300FE; // // MessageId: STG_E_INVALIDF;AG // // MessageText: // // Invalid F;ag error. // public static final int STG_E_INVALIDFLAG = 0x800300FF; // // MessageId: STG_E_INUSE // // MessageText: // // Attempted to use an object that is busy. // public static final int STG_E_INUSE = 0x80030100; // // MessageId: STG_E_NOTCURRENT // // MessageText: // // The storage has been changed since the last commit. // public static final int STG_E_NOTCURRENT = 0x80030101; // // MessageId: STG_E_REVERTED // // MessageText: // // Attempted to use an object that has ceased to exist. // public static final int STG_E_REVERTED = 0x80030102; // // MessageId: STG_E_CANTSAVE // // MessageText: // // Can't save. // public static final int STG_E_CANTSAVE = 0x80030103; // // MessageId: STG_E_OLDFORMAT // // MessageText: // // The compound file %1 was produced with an incompatible version of // storage. // public static final int STG_E_OLDFORMAT = 0x80030104; // // MessageId: STG_E_OLDDLL // // MessageText: // // The compound file %1 was produced with a newer version of storage. // public static final int STG_E_OLDDLL = 0x80030105; // // MessageId: STG_E_SHAREREQUIRED // // MessageText: // // Share.exe or equivalent is required for operation. // public static final int STG_E_SHAREREQUIRED = 0x80030106; // // MessageId: STG_E_NOTFILEBASEDSTORAGE // // MessageText: // // Illegal operation called on non-file based storage. // public static final int STG_E_NOTFILEBASEDSTORAGE = 0x80030107; // // MessageId: STG_E_EXTANTMARSHALLINGS // // MessageText: // // Illegal operation called on object with extant marshallings. // public static final int STG_E_EXTANTMARSHALLINGS = 0x80030108; // // MessageId: STG_E_DOCFILECORRUPT // // MessageText: // // The docfile has been corrupted. // public static final int STG_E_DOCFILECORRUPT = 0x80030109; // // MessageId: STG_E_BADBASEADDRESS // // MessageText: // // OLE32.DLL has been loaded at the wrong address. // public static final int STG_E_BADBASEADDRESS = 0x80030110; // // MessageId: STG_E_DOCFILETOOLARGE // // MessageText: // // The compound file is too large for the current implementation // public static final int STG_E_DOCFILETOOLARGE = 0x80030111; // // MessageId: STG_E_NOTSIMPLEFORMAT // // MessageText: // // The compound file was not created with the STGM_SIMPLE F;ag // public static final int STG_E_NOTSIMPLEFORMAT = 0x80030112; // // MessageId: STG_E_INCOMPLETE // // MessageText: // // The file download was aborted abnormally. The file is incomplete. // public static final int STG_E_INCOMPLETE = 0x80030201; // // MessageId: STG_E_TERMINATED // // MessageText: // // The file download has been terminated. // public static final int STG_E_TERMINATED = 0x80030202; // // MessageId: STG_S_CONVERTED // // MessageText: // // The underlying file was converted to compound file format. // public static final int STG_S_CONVERTED = 0x00030200; // // MessageId: STG_S_BLOCK // // MessageText: // // The storage operation should block until more data is available. // public static final int STG_S_BLOCK = 0x00030201; // // MessageId: STG_S_RETRYNOW // // MessageText: // // The storage operation should retry immediately. // public static final int STG_S_RETRYNOW = 0x00030202; // // MessageId: STG_S_MONITORING // // MessageText: // // The notified event sink will not inF;uence the storage operation. // public static final int STG_S_MONITORING = 0x00030203; // // MessageId: STG_S_MULTIPLEOPENS // // MessageText: // // Multiple opens prevent consolidated. (commit succeeded). // public static final int STG_S_MULTIPLEOPENS = 0x00030204; // // MessageId: STG_S_CONSOLIDATIONFAILED // // MessageText: // // Consolidation of the storage file failed. (commit succeeded). // public static final int STG_S_CONSOLIDATIONFAILED = 0x00030205; // // MessageId: STG_S_CANNOTCONSOLIDATE // // MessageText: // // Consolidation of the storage file is inappropriate. (commit succeeded). // public static final int STG_S_CANNOTCONSOLIDATE = 0x00030206; /* * ++ * * MessageId's 0x0305 - 0x031f (inclusive) are reserved for **STORAGE** copy * protection errors. * * -- */ // // MessageId: STG_E_STATUS_COPY_PROTECTION_FAILURE // // MessageText: // // Generic Copy Protection Error. // public static final int STG_E_STATUS_COPY_PROTECTION_FAILURE = 0x80030305; // // MessageId: STG_E_CSS_AUTHENTICATION_FAILURE // // MessageText: // // Copy Protection Error - DVD CSS Authentication failed. // public static final int STG_E_CSS_AUTHENTICATION_FAILURE = 0x80030306; // // MessageId: STG_E_CSS_KEY_NOT_PRESENT // // MessageText: // // Copy Protection Error - The given sector does not have a valid CSS key. // public static final int STG_E_CSS_KEY_NOT_PRESENT = 0x80030307; // // MessageId: STG_E_CSS_KEY_NOT_ESTABLISHED // // MessageText: // // Copy Protection Error - DVD session key not established. // public static final int STG_E_CSS_KEY_NOT_ESTABLISHED = 0x80030308; // // MessageId: STG_E_CSS_SCRAMBLED_SECTOR // // MessageText: // // Copy Protection Error - The read failed because the sector is encrypted. // public static final int STG_E_CSS_SCRAMBLED_SECTOR = 0x80030309; // // MessageId: STG_E_CSS_REGION_MISMATCH // // MessageText: // // Copy Protection Error - The current DVD's region does not correspond to // the region setting of the drive. // public static final int STG_E_CSS_REGION_MISMATCH = 0x8003030A; // // MessageId: STG_E_RESETS_EXHAUSTED // // MessageText: // // Copy Protection Error - The drive's region setting may be permanent or // the number of user resets has been exhausted. // public static final int STG_E_RESETS_EXHAUSTED = 0x8003030B; /* * ++ * * MessageId's 0x0305 - 0x031f (inclusive) are reserved for **STORAGE** copy * protection errors. * * -- */ // ****************** // FACILITY_RPC // ****************** // // Codes 0x0-0x11 are propagated from=16 bit OLE. // // // MessageId: RPC_E_CALL_REJECTED // // MessageText: // // Call was rejected by callee. // public static final int RPC_E_CALL_REJECTED = 0x80010001; // // MessageId: RPC_E_CALL_CANCELED // // MessageText: // // Call was canceled by the message filter. // public static final int RPC_E_CALL_CANCELED = 0x80010002; // // MessageId: RPC_E_CANTPOST_INSENDCALL // // MessageText: // // The caller is dispatching an intertask SendMessage call and cannot call // out via PostMessage. // public static final int RPC_E_CANTPOST_INSENDCALL = 0x80010003; // // MessageId: RPC_E_CANTCALLOUT_INASYNCCALL // // MessageText: // // The caller is dispatching an asynchronous call and cannot make an // outgoing call on behalf of this call. // public static final int RPC_E_CANTCALLOUT_INASYNCCALL = 0x80010004; // // MessageId: RPC_E_CANTCALLOUT_INEXTERNALCALL // // MessageText: // // It is illegal to call out while inside message filter. // public static final int RPC_E_CANTCALLOUT_INEXTERNALCALL = 0x80010005; // // MessageId: RPC_E_CONNECTION_TERMINATED // // MessageText: // // The connection terminated or is in a bogus state and cannot be used any // more. Other connections are still valid. // public static final int RPC_E_CONNECTION_TERMINATED = 0x80010006; // // MessageId: RPC_E_SERVER_DIED // // MessageText: // // The callee (server [not server application]) is not available and // disappeared; all connections are invalid. The call may have executed. // public static final int RPC_E_SERVER_DIED = 0x80010007; // // MessageId: RPC_E_CLIENT_DIED // // MessageText: // // The caller (client) disappeared while the callee (server) was processing // a call. // public static final int RPC_E_CLIENT_DIED = 0x80010008; // // MessageId: RPC_E_INVALID_DATAPACKET // // MessageText: // // The data packet with the marshalled parameter data is incorrect. // public static final int RPC_E_INVALID_DATAPACKET = 0x80010009; // // MessageId: RPC_E_CANTTRANSMIT_CALL // // MessageText: // // The call was not transmitted properly; the message queue was full and was // not emptied after yielding. // public static final int RPC_E_CANTTRANSMIT_CALL = 0x8001000A; // // MessageId: RPC_E_CLIENT_CANTMARSHAL_DATA // // MessageText: // // The client (caller) cannot marshall the parameter data - low memory, etc. // public static final int RPC_E_CLIENT_CANTMARSHAL_DATA = 0x8001000B; // // MessageId: RPC_E_CLIENT_CANTUNMARSHAL_DATA // // MessageText: // // The client (caller) cannot unmarshall the return data - low memory, etc. // public static final int RPC_E_CLIENT_CANTUNMARSHAL_DATA = 0x8001000C; // // MessageId: RPC_E_SERVER_CANTMARSHAL_DATA // // MessageText: // // The server (callee) cannot marshall the return data - low memory, etc. // public static final int RPC_E_SERVER_CANTMARSHAL_DATA = 0x8001000D; // // MessageId: RPC_E_SERVER_CANTUNMARSHAL_DATA // // MessageText: // // The server (callee) cannot unmarshall the parameter data - low memory, // etc. // public static final int RPC_E_SERVER_CANTUNMARSHAL_DATA = 0x8001000E; // // MessageId: RPC_E_INVALID_DATA // // MessageText: // // Received data is invalid; could be server or client data. // public static final int RPC_E_INVALID_DATA = 0x8001000F; // // MessageId: RPC_E_INVALID_PARAMETER // // MessageText: // // A particular parameter is invalid and cannot be (un)marshalled. // public static final int RPC_E_INVALID_PARAMETER = 0x80010010; // // MessageId: RPC_E_CANTCALLOUT_AGAIN // // MessageText: // // There is no second outgoing call on same channel in DDE conversation. // public static final int RPC_E_CANTCALLOUT_AGAIN = 0x80010011; // // MessageId: RPC_E_SERVER_DIED_DNE // // MessageText: // // The callee (server [not server application]) is not available and // disappeared; all connections are invalid. The call did not execute. // public static final int RPC_E_SERVER_DIED_DNE = 0x80010012; // // MessageId: RPC_E_SYS_CALL_FAILED // // MessageText: // // System call failed. // public static final int RPC_E_SYS_CALL_FAILED = 0x80010100; // // MessageId: RPC_E_OUT_OF_RESOURCES // // MessageText: // // Could not allocate some required resource (memory, events, ...) // public static final int RPC_E_OUT_OF_RESOURCES = 0x80010101; // // MessageId: RPC_E_ATTEMPTED_MULTITHREAD // // MessageText: // // Attempted to make calls on more than one thread in single threaded mode. // public static final int RPC_E_ATTEMPTED_MULTITHREAD = 0x80010102; // // MessageId: RPC_E_NOT_REGISTERED // // MessageText: // // The requested interface is not registered on the server object. // public static final int RPC_E_NOT_REGISTERED = 0x80010103; // // MessageId: RPC_E_FAULT // // MessageText: // // RPC could not call the server or could not return the results of calling // the server. // public static final int RPC_E_FAULT = 0x80010104; // // MessageId: RPC_E_SERVERFAULT // // MessageText: // // The server threw an exception. // public static final int RPC_E_SERVERFAULT = 0x80010105; // // MessageId: RPC_E_CHANGED_MODE // // MessageText: // // Cannot change thread mode after it is set. // public static final int RPC_E_CHANGED_MODE = 0x80010106; // // MessageId: RPC_E_INVALIDMETHOD // // MessageText: // // The method called does not exist on the server. // public static final int RPC_E_INVALIDMETHOD = 0x80010107; // // MessageId: RPC_E_DISCONNECTED // // MessageText: // // The object invoked has disconnected from its clients. // public static final int RPC_E_DISCONNECTED = 0x80010108; // // MessageId: RPC_E_RETRY // // MessageText: // // The object invoked chose not to process the call now. Try again later. // public static final int RPC_E_RETRY = 0x80010109; // // MessageId: RPC_E_SERVERCALL_RETRYLATER // // MessageText: // // The message filter indicated that the application is busy. // public static final int RPC_E_SERVERCALL_RETRYLATER = 0x8001010A; // // MessageId: RPC_E_SERVERCALL_REJECTED // // MessageText: // // The message filter rejected the call. // public static final int RPC_E_SERVERCALL_REJECTED = 0x8001010B; // // MessageId: RPC_E_INVALID_CALLDATA // // MessageText: // // A call control interfaces was called with invalid data. // public static final int RPC_E_INVALID_CALLDATA = 0x8001010C; // // MessageId: RPC_E_CANTCALLOUT_ININPUTSYNCCALL // // MessageText: // // An outgoing call cannot be made since the application is dispatching an // input-synchronous call. // public static final int RPC_E_CANTCALLOUT_ININPUTSYNCCALL = 0x8001010D; // // MessageId: RPC_E_WRONG_THREAD // // MessageText: // // The application called an interface that was marshalled for a different // thread. // public static final int RPC_E_WRONG_THREAD = 0x8001010E; // // MessageId: RPC_E_THREAD_NOT_INIT // // MessageText: // // CoInitialize has not been called on the current thread. // public static final int RPC_E_THREAD_NOT_INIT = 0x8001010F; // // MessageId: RPC_E_VERSION_MISMATCH // // MessageText: // // The version of OLE on the client and server machines does not match. // public static final int RPC_E_VERSION_MISMATCH = 0x80010110; // // MessageId: RPC_E_INVALID_HEADER // // MessageText: // // OLE received a packet with an invalid header. // public static final int RPC_E_INVALID_HEADER = 0x80010111; // // MessageId: RPC_E_INVALID_EXTENSION // // MessageText: // // OLE received a packet with an invalid extension. // public static final int RPC_E_INVALID_EXTENSION = 0x80010112; // // MessageId: RPC_E_INVALID_IPID // // MessageText: // // The requested object or interface does not exist. // public static final int RPC_E_INVALID_IPID = 0x80010113; // // MessageId: RPC_E_INVALID_OBJECT // // MessageText: // // The requested object does not exist. // public static final int RPC_E_INVALID_OBJECT = 0x80010114; // // MessageId: RPC_S_CALLPENDING // // MessageText: // // OLE has sent a request and is waiting for a reply. // public static final int RPC_S_CALLPENDING = 0x80010115; // // MessageId: RPC_S_WAITONTIMER // // MessageText: // // OLE is waiting before retrying a request. // public static final int RPC_S_WAITONTIMER = 0x80010116; // // MessageId: RPC_E_CALL_COMPLETE // // MessageText: // // Call context cannot be accessed after call completed. // public static final int RPC_E_CALL_COMPLETE = 0x80010117; // // MessageId: RPC_E_UNSECURE_CALL // // MessageText: // // Impersonate on unsecure calls is not supported. // public static final int RPC_E_UNSECURE_CALL = 0x80010118; // // MessageId: RPC_E_TOO_LATE // // MessageText: // // Security must be initialized before any interfaces are marshalled or // unmarshalled. It cannot be changed once initialized. // public static final int RPC_E_TOO_LATE = 0x80010119; // // MessageId: RPC_E_NO_GOOD_SECURITY_PACKAGES // // MessageText: // // No security packages are installed on this machine or the user is not // logged on or there are no compatible security packages between the client // and server. // public static final int RPC_E_NO_GOOD_SECURITY_PACKAGES = 0x8001011A; // // MessageId: RPC_E_ACCESS_DENIED // // MessageText: // // Access is denied. // public static final int RPC_E_ACCESS_DENIED = 0x8001011B; // // MessageId: RPC_E_REMOTE_DISABLED // // MessageText: // // Remote calls are not allowed for this process. // public static final int RPC_E_REMOTE_DISABLED = 0x8001011C; // // MessageId: RPC_E_INVALID_OBJREF // // MessageText: // // The marshaled interface data packet (OBJREF) has an invalid or unknown // format. // public static final int RPC_E_INVALID_OBJREF = 0x8001011D; // // MessageId: RPC_E_NO_CONTEXT // // MessageText: // // No context is associated with this call. This happens for some custom // marshalled calls and on the client side of the call. // public static final int RPC_E_NO_CONTEXT = 0x8001011E; // // MessageId: RPC_E_TIMEOUT // // MessageText: // // This operation returned because the timeout period expired. // public static final int RPC_E_TIMEOUT = 0x8001011F; // // MessageId: RPC_E_NO_SYNC // // MessageText: // // There are no synchronize objects to wait on. // public static final int RPC_E_NO_SYNC = 0x80010120; // // MessageId: RPC_E_FULLSIC_REQUIRED // // MessageText: // // Full subject issuer chain SSL principal name expected from the server. // public static final int RPC_E_FULLSIC_REQUIRED = 0x80010121; // // MessageId: RPC_E_INVALID_STD_NAME // // MessageText: // // Principal name is not a valid MSSTD name. // public static final int RPC_E_INVALID_STD_NAME = 0x80010122; // // MessageId: CO_E_FAILEDTOIMPERSONATE // // MessageText: // // Unable to impersonate DCOM client // public static final int CO_E_FAILEDTOIMPERSONATE = 0x80010123; // // MessageId: CO_E_FAILEDTOGETSECCTX // // MessageText: // // Unable to obtain server's security context // public static final int CO_E_FAILEDTOGETSECCTX = 0x80010124; // // MessageId: CO_E_FAILEDTOOPENTHREADTOKEN // // MessageText: // // Unable to open the access token of the current thread // public static final int CO_E_FAILEDTOOPENTHREADTOKEN = 0x80010125; // // MessageId: CO_E_FAILEDTOGETTOKENINFO // // MessageText: // // Unable to obtain user info from an access token // public static final int CO_E_FAILEDTOGETTOKENINFO = 0x80010126; // // MessageId: CO_E_TRUSTEEDOESNTMATCHCLIENT // // MessageText: // // The client who called IAccessControl::IsAccessPermitted was not the // trustee provided to the method // public static final int CO_E_TRUSTEEDOESNTMATCHCLIENT = 0x80010127; // // MessageId: CO_E_FAILEDTOQUERYCLIENTBLANKET // // MessageText: // // Unable to obtain the client's security blanket // public static final int CO_E_FAILEDTOQUERYCLIENTBLANKET = 0x80010128; // // MessageId: CO_E_FAILEDTOSETDACL // // MessageText: // // Unable to set a discretionary ACL into a security descriptor // public static final int CO_E_FAILEDTOSETDACL = 0x80010129; // // MessageId: CO_E_ACCESSCHECKFAILED // // MessageText: // // The system function, AccessCheck, returned false // public static final int CO_E_ACCESSCHECKFAILED = 0x8001012A; // // MessageId: CO_E_NETACCESSAPIFAILED // // MessageText: // // Either NetAccessDel or NetAccessAdd returned an error code. // public static final int CO_E_NETACCESSAPIFAILED = 0x8001012B; // // MessageId: CO_E_WRONGTRUSTEENAMESYNTAX // // MessageText: // // One of the trustee strings provided by the user did not conform to the // \ syntax and it was not the "*" string // public static final int CO_E_WRONGTRUSTEENAMESYNTAX = 0x8001012C; // // MessageId: CO_E_INVALIDSID // // MessageText: // // One of the security identifiers provided by the user was invalid // public static final int CO_E_INVALIDSID = 0x8001012D; // // MessageId: CO_E_CONVERSIONFAILED // // MessageText: // // Unable to convert a wide character trustee string to a multibyte trustee // string // public static final int CO_E_CONVERSIONFAILED = 0x8001012E; // // MessageId: CO_E_NOMATCHINGSIDFOUND // // MessageText: // // Unable to find a security identifier that corresponds to a trustee string // provided by the user // public static final int CO_E_NOMATCHINGSIDFOUND = 0x8001012F; // // MessageId: CO_E_LOOKUPACCSIDFAILED // // MessageText: // // The system function, LookupAccountSID, failed // public static final int CO_E_LOOKUPACCSIDFAILED = 0x80010130; // // MessageId: CO_E_NOMATCHINGNAMEFOUND // // MessageText: // // Unable to find a trustee name that corresponds to a security identifier // provided by the user // public static final int CO_E_NOMATCHINGNAMEFOUND = 0x80010131; // // MessageId: CO_E_LOOKUPACCNAMEFAILED // // MessageText: // // The system function, LookupAccountName, failed // public static final int CO_E_LOOKUPACCNAMEFAILED = 0x80010132; // // MessageId: CO_E_SETSERLHNDLFAILED // // MessageText: // // Unable to set or reset a serialization handle // public static final int CO_E_SETSERLHNDLFAILED = 0x80010133; // // MessageId: CO_E_FAILEDTOGETWINDIR // // MessageText: // // Unable to obtain the Windows directory // public static final int CO_E_FAILEDTOGETWINDIR = 0x80010134; // // MessageId: CO_E_PATHTOOLONG // // MessageText: // // Path too long // public static final int CO_E_PATHTOOLONG = 0x80010135; // // MessageId: CO_E_FAILEDTOGENUUID // // MessageText: // // Unable to generate a uuid. // public static final int CO_E_FAILEDTOGENUUID = 0x80010136; // // MessageId: CO_E_FAILEDTOCREATEFILE // // MessageText: // // Unable to create file // public static final int CO_E_FAILEDTOCREATEFILE = 0x80010137; // // MessageId: CO_E_FAILEDTOCLOSEHANDLE // // MessageText: // // Unable to close a serialization handle or a file handle. // public static final int CO_E_FAILEDTOCLOSEHANDLE = 0x80010138; // // MessageId: CO_E_EXCEEDSYSACLLIMIT // // MessageText: // // The number of ACEs in an ACL exceeds the system limit. // public static final int CO_E_EXCEEDSYSACLLIMIT = 0x80010139; // // MessageId: CO_E_ACESINWRONGORDER // // MessageText: // // Not all the DENY_ACCESS ACEs are arranged in front of the GRANT_ACCESS // ACEs in the stream. // public static final int CO_E_ACESINWRONGORDER = 0x8001013A; // // MessageId: CO_E_INCOMPATIBLESTREAMVERSION // // MessageText: // // The version of ACL format in the stream is not supported by this // implementation of IAccessControl // public static final int CO_E_INCOMPATIBLESTREAMVERSION = 0x8001013B; // // MessageId: CO_E_FAILEDTOOPENPROCESSTOKEN // // MessageText: // // Unable to open the access token of the server process // public static final int CO_E_FAILEDTOOPENPROCESSTOKEN = 0x8001013C; // // MessageId: CO_E_DECODEFAILED // // MessageText: // // Unable to decode the ACL in the stream provided by the user // public static final int CO_E_DECODEFAILED = 0x8001013D; // // MessageId: CO_E_ACNOTINITIALIZED // // MessageText: // // The COM IAccessControl object is not initialized // public static final int CO_E_ACNOTINITIALIZED = 0x8001013F; // // MessageId: CO_E_CANCEL_DISABLED // // MessageText: // // Call Cancellation is disabled // public static final int CO_E_CANCEL_DISABLED = 0x80010140; // // MessageId: RPC_E_UNEXPECTED // // MessageText: // // An internal error occurred. // public static final int RPC_E_UNEXPECTED = 0x8001FFFF; // //////////////////////////////////// // =// // Additional Security Status Codes // // =// // Facility=Security=// // =// // //////////////////////////////////// // // MessageId: ERROR_AUDITING_DISABLED // // MessageText: // // The specified event is currently not being audited. // public static final int ERROR_AUDITING_DISABLED = 0xC0090001; // // MessageId: ERROR_ALL_SIDS_FILTERED // // MessageText: // // The SID filtering operation removed all SIDs. // public static final int ERROR_ALL_SIDS_FILTERED = 0xC0090002; // // MessageId: ERROR_BIZRULES_NOT_ENABLED // // MessageText: // // Business rule scripts are disabled for the calling application. // public static final int ERROR_BIZRULES_NOT_ENABLED = 0xC0090003; // /////////////////////////////////////////// // =// // end of Additional Security Status Codes // // =// // /////////////////////////////////////////// // /////////////// // // FACILITY_SSPI // // /////////////// // // MessageId: NTE_BAD_UID // // MessageText: // // Bad UID. // public static final int NTE_BAD_UID = 0x80090001; // // MessageId: NTE_BAD_HASH // // MessageText: // // Bad Hash. // public static final int NTE_BAD_HASH = 0x80090002; // // MessageId: NTE_BAD_KEY // // MessageText: // // Bad Key. // public static final int NTE_BAD_KEY = 0x80090003; // // MessageId: NTE_BAD_LEN // // MessageText: // // Bad Length. // public static final int NTE_BAD_LEN = 0x80090004; // // MessageId: NTE_BAD_DATA // // MessageText: // // Bad Data. // public static final int NTE_BAD_DATA = 0x80090005; // // MessageId: NTE_BAD_SIGNATURE // // MessageText: // // Invalid Signature. // public static final int NTE_BAD_SIGNATURE = 0x80090006; // // MessageId: NTE_BAD_VER // // MessageText: // // Bad Version of provider. // public static final int NTE_BAD_VER = 0x80090007; // // MessageId: NTE_BAD_ALGID // // MessageText: // // Invalid algorithm specified. // public static final int NTE_BAD_ALGID = 0x80090008; // // MessageId: NTE_BAD_F;AGS // // MessageText: // // Invalid F;ags specified. // public static final int NTE_BAD_FLAGS = 0x80090009; // // MessageId: NTE_BAD_TYPE // // MessageText: // // Invalid type specified. // public static final int NTE_BAD_TYPE = 0x8009000A; // // MessageId: NTE_BAD_KEY_STATE // // MessageText: // // Key not valid for use in specified state. // public static final int NTE_BAD_KEY_STATE = 0x8009000B; // // MessageId: NTE_BAD_HASH_STATE // // MessageText: // // Hash not valid for use in specified state. // public static final int NTE_BAD_HASH_STATE = 0x8009000C; // // MessageId: NTE_NO_KEY // // MessageText: // // Key does not exist. // public static final int NTE_NO_KEY = 0x8009000D; // // MessageId: NTE_NO_MEMORY // // MessageText: // // Insufficient memory available for the operation. // public static final int NTE_NO_MEMORY = 0x8009000E; // // MessageId: NTE_EXISTS // // MessageText: // // Object already exists. // public static final int NTE_EXISTS = 0x8009000F; // // MessageId: NTE_PERM // // MessageText: // // Access denied. // public static final int NTE_PERM = 0x80090010; // // MessageId: NTE_NOT_FOUND // // MessageText: // // Object was not found. // public static final int NTE_NOT_FOUND = 0x80090011; // // MessageId: NTE_DOUBLE_ENCRYPT // // MessageText: // // Data already encrypted. // public static final int NTE_DOUBLE_ENCRYPT = 0x80090012; // // MessageId: NTE_BAD_PROVIDER // // MessageText: // // Invalid provider specified. // public static final int NTE_BAD_PROVIDER = 0x80090013; // // MessageId: NTE_BAD_PROV_TYPE // // MessageText: // // Invalid provider type specified. // public static final int NTE_BAD_PROV_TYPE = 0x80090014; // // MessageId: NTE_BAD_PUBLIC_KEY // // MessageText: // // Provider's public key is invalid. // public static final int NTE_BAD_PUBLIC_KEY = 0x80090015; // // MessageId: NTE_BAD_KEYSET // // MessageText: // // Keyset does not exist // public static final int NTE_BAD_KEYSET = 0x80090016; // // MessageId: NTE_PROV_TYPE_NOT_DEF // // MessageText: // // Provider type not defined. // public static final int NTE_PROV_TYPE_NOT_DEF = 0x80090017; // // MessageId: NTE_PROV_TYPE_ENTRY_BAD // // MessageText: // // Provider type as registered is invalid. // public static final int NTE_PROV_TYPE_ENTRY_BAD = 0x80090018; // // MessageId: NTE_KEYSET_NOT_DEF // // MessageText: // // The keyset is not defined. // public static final int NTE_KEYSET_NOT_DEF = 0x80090019; // // MessageId: NTE_KEYSET_ENTRY_BAD // // MessageText: // // Keyset as registered is invalid. // public static final int NTE_KEYSET_ENTRY_BAD = 0x8009001A; // // MessageId: NTE_PROV_TYPE_NO_MATCH // // MessageText: // // Provider type does not match registered value. // public static final int NTE_PROV_TYPE_NO_MATCH = 0x8009001B; // // MessageId: NTE_SIGNATURE_FILE_BAD // // MessageText: // // The digital signature file is corrupt. // public static final int NTE_SIGNATURE_FILE_BAD = 0x8009001C; // // MessageId: NTE_PROVIDER_DLL_FAIL // // MessageText: // // Provider DLL failed to initialize correctly. // public static final int NTE_PROVIDER_DLL_FAIL = 0x8009001D; // // MessageId: NTE_PROV_DLL_NOT_FOUND // // MessageText: // // Provider DLL could not be found. // public static final int NTE_PROV_DLL_NOT_FOUND = 0x8009001E; // // MessageId: NTE_BAD_KEYSET_PARAM // // MessageText: // // The Keyset parameter is invalid. // public static final int NTE_BAD_KEYSET_PARAM = 0x8009001F; // // MessageId: NTE_FAIL // // MessageText: // // An internal error occurred. // public static final int NTE_FAIL = 0x80090020; // // MessageId: NTE_SYS_ERR // // MessageText: // // A base error occurred. // public static final int NTE_SYS_ERR = 0x80090021; // // MessageId: NTE_SILENT_CONTEXT // // MessageText: // // Provider could not perform the action since the context was acquired as // silent. // public static final int NTE_SILENT_CONTEXT = 0x80090022; // // MessageId: NTE_TOKEN_KEYSET_STORAGE_FULL // // MessageText: // // The security token does not have storage space available for an // additional container. // public static final int NTE_TOKEN_KEYSET_STORAGE_FULL = 0x80090023; // // MessageId: NTE_TEMPORARY_PROFILE // // MessageText: // // The profile for the user is a temporary profile. // public static final int NTE_TEMPORARY_PROFILE = 0x80090024; // // MessageId: NTE_FIXEDPARAMETER // // MessageText: // // The key parameters could not be set because the CSP uses fixed // parameters. // public static final int NTE_FIXEDPARAMETER = 0x80090025; // // MessageId: NTE_INVALID_HANDLE // // MessageText: // // The supplied handle is invalid. // public static final int NTE_INVALID_HANDLE = 0x80090026; // // MessageId: NTE_INVALID_PARAMETER // // MessageText: // // The parameter is incorrect. // public static final int NTE_INVALID_PARAMETER = 0x80090027; // // MessageId: NTE_BUFFER_TOO_SMALL // // MessageText: // // The buffer supplied to a function was too small. // public static final int NTE_BUFFER_TOO_SMALL = 0x80090028; // // MessageId: NTE_NOT_SUPPORTED // // MessageText: // // The requested operation is not supported. // public static final int NTE_NOT_SUPPORTED = 0x80090029; // // MessageId: NTE_NO_MORE_ITEMS // // MessageText: // // No more data is available. // public static final int NTE_NO_MORE_ITEMS = 0x8009002A; // // MessageId: NTE_BUFFERS_OVERLAP // // MessageText: // // The supplied buffers overlap incorrectly. // public static final int NTE_BUFFERS_OVERLAP = 0x8009002B; // // MessageId: NTE_DECRYPTION_FAILURE // // MessageText: // // The specified data could not be decrypted. // public static final int NTE_DECRYPTION_FAILURE = 0x8009002C; // // MessageId: NTE_INTERNAL_ERROR // // MessageText: // // An internal consistency check failed. // public static final int NTE_INTERNAL_ERROR = 0x8009002D; // // MessageId: NTE_UI_REQUIRED // // MessageText: // // This operation requires input from the user. // public static final int NTE_UI_REQUIRED = 0x8009002E; // // MessageId: NTE_HMAC_NOT_SUPPORTED // // MessageText: // // The cryptographic provider does not support HMAC. // public static final int NTE_HMAC_NOT_SUPPORTED = 0x8009002F; // // MessageId: SEC_E_INSUFFICIENT_MEMORY // // MessageText: // // Not enough memory is available to complete this request // public static final int SEC_E_INSUFFICIENT_MEMORY = 0x80090300; // // MessageId: SEC_E_INVALID_HANDLE // // MessageText: // // The handle specified is invalid // public static final int SEC_E_INVALID_HANDLE = 0x80090301; // // MessageId: SEC_E_UNSUPPORTED_FUNCTION // // MessageText: // // The function requested is not supported // public static final int SEC_E_UNSUPPORTED_FUNCTION = 0x80090302; // // MessageId: SEC_E_TARGET_UNKNOWN // // MessageText: // // The specified target is unknown or unreachable // public static final int SEC_E_TARGET_UNKNOWN = 0x80090303; // // MessageId: SEC_E_INTERNAL_ERROR // // MessageText: // // The Local Security Authority cannot be contacted // public static final int SEC_E_INTERNAL_ERROR = 0x80090304; // // MessageId: SEC_E_SECPKG_NOT_FOUND // // MessageText: // // The requested security package does not exist // public static final int SEC_E_SECPKG_NOT_FOUND = 0x80090305; // // MessageId: SEC_E_NOT_OWNER // // MessageText: // // The caller is not the owner of the desired credentials // public static final int SEC_E_NOT_OWNER = 0x80090306; // // MessageId: SEC_E_CANNOT_INSTALL // // MessageText: // // The security package failed to initialize, and cannot be installed // public static final int SEC_E_CANNOT_INSTALL = 0x80090307; // // MessageId: SEC_E_INVALID_TOKEN // // MessageText: // // The token supplied to the function is invalid // public static final int SEC_E_INVALID_TOKEN = 0x80090308; // // MessageId: SEC_E_CANNOT_PACK // // MessageText: // // The security package is not able to marshall the logon buffer, so the // logon attempt has failed // public static final int SEC_E_CANNOT_PACK = 0x80090309; // // MessageId: SEC_E_QOP_NOT_SUPPORTED // // MessageText: // // The per-message Quality of Protection is not supported by the security // package // public static final int SEC_E_QOP_NOT_SUPPORTED = 0x8009030A; // // MessageId: SEC_E_NO_IMPERSONATION // // MessageText: // // The security context does not allow impersonation of the client // public static final int SEC_E_NO_IMPERSONATION = 0x8009030B; // // MessageId: SEC_E_LOGON_DENIED // // MessageText: // // The logon attempt failed // public static final int SEC_E_LOGON_DENIED = 0x8009030C; // // MessageId: SEC_E_UNKNOWN_CREDENTIALS // // MessageText: // // The credentials supplied to the package were not recognized // public static final int SEC_E_UNKNOWN_CREDENTIALS = 0x8009030D; // // MessageId: SEC_E_NO_CREDENTIALS // // MessageText: // // No credentials are available in the security package // public static final int SEC_E_NO_CREDENTIALS = 0x8009030E; // // MessageId: SEC_E_MESSAGE_ALTERED // // MessageText: // // The message or signature supplied for verification has been altered // public static final int SEC_E_MESSAGE_ALTERED = 0x8009030F; // // MessageId: SEC_E_OUT_OF_SEQUENCE // // MessageText: // // The message supplied for verification is out of sequence // public static final int SEC_E_OUT_OF_SEQUENCE = 0x80090310; // // MessageId: SEC_E_NO_AUTHENTICATING_AUTHORITY // // MessageText: // // No authority could be contacted for authentication. // public static final int SEC_E_NO_AUTHENTICATING_AUTHORITY = 0x80090311; // // MessageId: SEC_I_CONTINUE_NEEDED // // MessageText: // // The function completed successfully, but must be called again to complete // the context // public static final int SEC_I_CONTINUE_NEEDED = 0x00090312; // // MessageId: SEC_I_COMPLETE_NEEDED // // MessageText: // // The function completed successfully, but CompleteToken must be called // public static final int SEC_I_COMPLETE_NEEDED = 0x00090313; // // MessageId: SEC_I_COMPLETE_AND_CONTINUE // // MessageText: // // The function completed successfully, but both CompleteToken and this // function must be called to complete the context // public static final int SEC_I_COMPLETE_AND_CONTINUE = 0x00090314; // // MessageId: SEC_I_LOCAL_LOGON // // MessageText: // // The logon was completed, but no network authority was available. The // logon was made using locally known information // public static final int SEC_I_LOCAL_LOGON = 0x00090315; // // MessageId: SEC_E_BAD_PKGID // // MessageText: // // The requested security package does not exist // public static final int SEC_E_BAD_PKGID = 0x80090316; // // MessageId: SEC_E_CONTEXT_EXPIRED // // MessageText: // // The context has expired and can no longer be used. // public static final int SEC_E_CONTEXT_EXPIRED = 0x80090317; // // MessageId: SEC_I_CONTEXT_EXPIRED // // MessageText: // // The context has expired and can no longer be used. // public static final int SEC_I_CONTEXT_EXPIRED = 0x00090317; // // MessageId: SEC_E_INCOMPLETE_MESSAGE // // MessageText: // // The supplied message is incomplete. The signature was not verified. // public static final int SEC_E_INCOMPLETE_MESSAGE = 0x80090318; // // MessageId: SEC_E_INCOMPLETE_CREDENTIALS // // MessageText: // // The credentials supplied were not complete, and could not be verified. // The context could not be initialized. // public static final int SEC_E_INCOMPLETE_CREDENTIALS = 0x80090320; // // MessageId: SEC_E_BUFFER_TOO_SMALL // // MessageText: // // The buffers supplied to a function was too small. // public static final int SEC_E_BUFFER_TOO_SMALL = 0x80090321; // // MessageId: SEC_I_INCOMPLETE_CREDENTIALS // // MessageText: // // The credentials supplied were not complete, and could not be verified. // Additional information can be returned from the context. // public static final int SEC_I_INCOMPLETE_CREDENTIALS = 0x00090320; // // MessageId: SEC_I_RENEGOTIATE // // MessageText: // // The context data must be renegotiated with the peer. // public static final int SEC_I_RENEGOTIATE = 0x00090321; // // MessageId: SEC_E_WRONG_PRINCIPAL // // MessageText: // // The target principal name is incorrect. // public static final int SEC_E_WRONG_PRINCIPAL = 0x80090322; // // MessageId: SEC_I_NO_LSA_CONTEXT // // MessageText: // // There is no LSA mode context associated with this context. // public static final int SEC_I_NO_LSA_CONTEXT = 0x00090323; // // MessageId: SEC_E_TIME_SKEW // // MessageText: // // The clocks on the client and server machines are skewed. // public static final int SEC_E_TIME_SKEW = 0x80090324; // // MessageId: SEC_E_UNTRUSTED_ROOT // // MessageText: // // The certificate chain was issued by an authority that is not trusted. // public static final int SEC_E_UNTRUSTED_ROOT = 0x80090325; // // MessageId: SEC_E_ILLEGAL_MESSAGE // // MessageText: // // The message received was unexpected or badly formatted. // public static final int SEC_E_ILLEGAL_MESSAGE = 0x80090326; // // MessageId: SEC_E_CERT_UNKNOWN // // MessageText: // // An unknown error occurred while processing the certificate. // public static final int SEC_E_CERT_UNKNOWN = 0x80090327; // // MessageId: SEC_E_CERT_EXPIRED // // MessageText: // // The received certificate has expired. // public static final int SEC_E_CERT_EXPIRED = 0x80090328; // // MessageId: SEC_E_ENCRYPT_FAILURE // // MessageText: // // The specified data could not be encrypted. // public static final int SEC_E_ENCRYPT_FAILURE = 0x80090329; // // MessageId: SEC_E_DECRYPT_FAILURE // // MessageText: // // The specified data could not be decrypted. // // public static final int SEC_E_DECRYPT_FAILURE = 0x80090330; // // MessageId: SEC_E_ALGORITHM_MISMATCH // // MessageText: // // The client and server cannot communicate, because they do not possess a // common algorithm. // public static final int SEC_E_ALGORITHM_MISMATCH = 0x80090331; // // MessageId: SEC_E_SECURITY_QOS_FAILED // // MessageText: // // The security context could not be established due to a failure in the // requested quality of service (e.g. mutual authentication or delegation). // public static final int SEC_E_SECURITY_QOS_FAILED = 0x80090332; // // MessageId: SEC_E_UNFINISHED_CONTEXT_DELETED // // MessageText: // // A security context was deleted before the context was completed. This is // considered a logon failure. // public static final int SEC_E_UNFINISHED_CONTEXT_DELETED = 0x80090333; // // MessageId: SEC_E_NO_TGT_REPLY // // MessageText: // // The client is trying to negotiate a context and the server requires // user-to-user but didn't send a TGT reply. // public static final int SEC_E_NO_TGT_REPLY = 0x80090334; // // MessageId: SEC_E_NO_IP_ADDRESSES // // MessageText: // // Unable to accomplish the requested task because the local machine does // not have any IP addresses. // public static final int SEC_E_NO_IP_ADDRESSES = 0x80090335; // // MessageId: SEC_E_WRONG_CREDENTIAL_HANDLE // // MessageText: // // The supplied credential handle does not match the credential associated // with the security context. // public static final int SEC_E_WRONG_CREDENTIAL_HANDLE = 0x80090336; // // MessageId: SEC_E_CRYPTO_SYSTEM_INVALID // // MessageText: // // The crypto system or checksum function is invalid because a required // function is unavailable. // public static final int SEC_E_CRYPTO_SYSTEM_INVALID = 0x80090337; // // MessageId: SEC_E_MAX_REFERRALS_EXCEEDED // // MessageText: // // The number of maximum ticket referrals has been exceeded. // public static final int SEC_E_MAX_REFERRALS_EXCEEDED = 0x80090338; // // MessageId: SEC_E_MUST_BE_KDC // // MessageText: // // The local machine must be a Kerberos KDC (domain controller) and it is // not. // public static final int SEC_E_MUST_BE_KDC = 0x80090339; // // MessageId: SEC_E_STRONG_CRYPTO_NOT_SUPPORTED // // MessageText: // // The other end of the security negotiation is requires strong crypto but // it is not supported on the local machine. // public static final int SEC_E_STRONG_CRYPTO_NOT_SUPPORTED = 0x8009033A; // // MessageId: SEC_E_TOO_MANY_PRINCIPALS // // MessageText: // // The KDC reply contained more than one principal name. // public static final int SEC_E_TOO_MANY_PRINCIPALS = 0x8009033B; // // MessageId: SEC_E_NO_PA_DATA // // MessageText: // // Expected to find PA data for a hint of what etype to use, but it was not // found. // public static final int SEC_E_NO_PA_DATA = 0x8009033C; // // MessageId: SEC_E_PKINIT_NAME_MISMATCH // // MessageText: // // The client certificate does not contain a valid UPN, or does not match // the client name // in the logon request. Please contact your administrator. // public static final int SEC_E_PKINIT_NAME_MISMATCH = 0x8009033D; // // MessageId: SEC_E_SMARTCARD_LOGON_REQUIRED // // MessageText: // // Smartcard logon is required and was not used. // public static final int SEC_E_SMARTCARD_LOGON_REQUIRED = 0x8009033E; // // MessageId: SEC_E_SHUTDOWN_IN_PROGRESS // // MessageText: // // A system shutdown is in progress. // public static final int SEC_E_SHUTDOWN_IN_PROGRESS = 0x8009033F; // // MessageId: SEC_E_KDC_INVALID_REQUEST // // MessageText: // // An invalid request was sent to the KDC. // public static final int SEC_E_KDC_INVALID_REQUEST = 0x80090340; // // MessageId: SEC_E_KDC_UNABLE_TO_REFER // // MessageText: // // The KDC was unable to generate a referral for the service requested. // public static final int SEC_E_KDC_UNABLE_TO_REFER = 0x80090341; // // MessageId: SEC_E_KDC_UNKNOWN_ETYPE // // MessageText: // // The encryption type requested is not supported by the KDC. // public static final int SEC_E_KDC_UNKNOWN_ETYPE = 0x80090342; // // MessageId: SEC_E_UNSUPPORTED_PREAUTH // // MessageText: // // An unsupported preauthentication mechanism was presented to the kerberos // package. // public static final int SEC_E_UNSUPPORTED_PREAUTH = 0x80090343; // // MessageId: SEC_E_DELEGATION_REQUIRED // // MessageText: // // The requested operation cannot be completed. The computer must be trusted // for delegation and the current user account must be configured to allow // delegation. // public static final int SEC_E_DELEGATION_REQUIRED = 0x80090345; // // MessageId: SEC_E_BAD_BINDINGS // // MessageText: // // Client's supplied SSPI channel bindings were incorrect. // public static final int SEC_E_BAD_BINDINGS = 0x80090346; // // MessageId: SEC_E_MULTIPLE_ACCOUNTS // // MessageText: // // The received certificate was mapped to multiple accounts. // public static final int SEC_E_MULTIPLE_ACCOUNTS = 0x80090347; // // MessageId: SEC_E_NO_KERB_KEY // // MessageText: // // SEC_E_NO_KERB_KEY // public static final int SEC_E_NO_KERB_KEY = 0x80090348; // // MessageId: SEC_E_CERT_WRONG_USAGE // // MessageText: // // The certificate is not valid for the requested usage. // public static final int SEC_E_CERT_WRONG_USAGE = 0x80090349; // // MessageId: SEC_E_DOWNGRADE_DETECTED // // MessageText: // // The system detected a possible attempt to compromise security. Please // ensure that you can contact the server that authenticated you. // public static final int SEC_E_DOWNGRADE_DETECTED = 0x80090350; // // MessageId: SEC_E_SMARTCARD_CERT_REVOKED // // MessageText: // // The smartcard certificate used for authentication has been revoked. // Please contact your system administrator. There may be additional // information in the event log. // public static final int SEC_E_SMARTCARD_CERT_REVOKED = 0x80090351; // // MessageId: SEC_E_ISSUING_CA_UNTRUSTED // // MessageText: // // An untrusted certificate authority was detected While processing the // smartcard certificate used for authentication. Please contact your system // administrator. // public static final int SEC_E_ISSUING_CA_UNTRUSTED = 0x80090352; // // MessageId: SEC_E_REVOCATION_OFF;INE_C // // MessageText: // // The revocation status of the smartcard certificate used for // authentication could not be determined. Please contact your system // administrator. // public static final int SEC_E_REVOCATION_OFFLINE_C = 0x80090353; // // MessageId: SEC_E_PKINIT_CLIENT_FAILURE // // MessageText: // // The smartcard certificate used for authentication was not trusted. Please // contact your system administrator. // public static final int SEC_E_PKINIT_CLIENT_FAILURE = 0x80090354; // // MessageId: SEC_E_SMARTCARD_CERT_EXPIRED // // MessageText: // // The smartcard certificate used for authentication has expired. Please // contact your system administrator. // public static final int SEC_E_SMARTCARD_CERT_EXPIRED = 0x80090355; // // MessageId: SEC_E_NO_S4U_PROT_SUPPORT // // MessageText: // // The Kerberos subsystem encountered an error. A service for user protocol // request was made against a domain controller which does not support // service for user. // public static final int SEC_E_NO_S4U_PROT_SUPPORT = 0x80090356; // // MessageId: SEC_E_CROSSREALM_DELEGATION_FAILURE // // MessageText: // // An attempt was made by this server to make a Kerberos constrained // delegation request for a target outside of the server's realm. This is // not supported, and indicates a misconfiguration on this server's allowed // to delegate to list. Please contact your administrator. // public static final int SEC_E_CROSSREALM_DELEGATION_FAILURE = 0x80090357; // // MessageId: SEC_E_REVOCATION_OFF;INE_KDC // // MessageText: // // The revocation status of the domain controller certificate used for // smartcard authentication could not be determined. There is additional // information in the system event log. Please contact your system // administrator. // public static final int SEC_E_REVOCATION_OFFLINE_KDC = 0x80090358; // // MessageId: SEC_E_ISSUING_CA_UNTRUSTED_KDC // // MessageText: // // An untrusted certificate authority was detected while processing the // domain controller certificate used for authentication. There is // additional information in the system event log. Please contact your // system administrator. // public static final int SEC_E_ISSUING_CA_UNTRUSTED_KDC = 0x80090359; // // MessageId: SEC_E_KDC_CERT_EXPIRED // // MessageText: // // The domain controller certificate used for smartcard logon has expired. // Please contact your system administrator with the contents of your system // event log. // public static final int SEC_E_KDC_CERT_EXPIRED = 0x8009035A; // // MessageId: SEC_E_KDC_CERT_REVOKED // // MessageText: // // The domain controller certificate used for smartcard logon has been // revoked. Please contact your system administrator with the contents of // your system event log. // public static final int SEC_E_KDC_CERT_REVOKED = 0x8009035B; // // MessageId: SEC_I_SIGNATURE_NEEDED // // MessageText: // // A signature operation must be performed before the user can authenticate. // public static final int SEC_I_SIGNATURE_NEEDED = 0x0009035C; // // MessageId: SEC_E_INVALID_PARAMETER // // MessageText: // // One or more of the parameters passed to the function was invalid. // public static final int SEC_E_INVALID_PARAMETER = 0x8009035D; // // MessageId: SEC_E_DELEGATION_POLICY // // MessageText: // // Client policy does not allow credential delegation to target server. // public static final int SEC_E_DELEGATION_POLICY = 0x8009035E; // // MessageId: SEC_E_POLICY_NLTM_ONLY // // MessageText: // // Client policy does not allow credential delegation to target server with // NLTM only authentication. // public static final int SEC_E_POLICY_NLTM_ONLY = 0x8009035F; // // MessageId: SEC_I_NO_RENEGOTIATION // // MessageText: // // The recipient rejected the renegotiation request. // public static final int SEC_I_NO_RENEGOTIATION = 0x00090360; // // Provided for backwards compatibility // public static final int SEC_E_NO_SPM = SEC_E_INTERNAL_ERROR; public static final int SEC_E_NOT_SUPPORTED = SEC_E_UNSUPPORTED_FUNCTION; // // MessageId: CRYPT_E_MSG_ERROR // // MessageText: // // An error occurred while performing an operation on a cryptographic // message. // public static final int CRYPT_E_MSG_ERROR = 0x80091001; // // MessageId: CRYPT_E_UNKNOWN_ALGO // // MessageText: // // Unknown cryptographic algorithm. // public static final int CRYPT_E_UNKNOWN_ALGO = 0x80091002; // // MessageId: CRYPT_E_OID_FORMAT // // MessageText: // // The object identifier is poorly formatted. // public static final int CRYPT_E_OID_FORMAT = 0x80091003; // // MessageId: CRYPT_E_INVALID_MSG_TYPE // // MessageText: // // Invalid cryptographic message type. // public static final int CRYPT_E_INVALID_MSG_TYPE = 0x80091004; // // MessageId: CRYPT_E_UNEXPECTED_ENCODING // // MessageText: // // Unexpected cryptographic message encoding. // public static final int CRYPT_E_UNEXPECTED_ENCODING = 0x80091005; // // MessageId: CRYPT_E_AUTH_ATTR_MISSING // // MessageText: // // The cryptographic message does not contain an expected authenticated // attribute. // public static final int CRYPT_E_AUTH_ATTR_MISSING = 0x80091006; // // MessageId: CRYPT_E_HASH_VALUE // // MessageText: // // The hash value is not correct. // public static final int CRYPT_E_HASH_VALUE = 0x80091007; // // MessageId: CRYPT_E_INVALID_INDEX // // MessageText: // // The index value is not valid. // public static final int CRYPT_E_INVALID_INDEX = 0x80091008; // // MessageId: CRYPT_E_ALREADY_DECRYPTED // // MessageText: // // The content of the cryptographic message has already been decrypted. // public static final int CRYPT_E_ALREADY_DECRYPTED = 0x80091009; // // MessageId: CRYPT_E_NOT_DECRYPTED // // MessageText: // // The content of the cryptographic message has not been decrypted yet. // public static final int CRYPT_E_NOT_DECRYPTED = 0x8009100A; // // MessageId: CRYPT_E_RECIPIENT_NOT_FOUND // // MessageText: // // The enveloped-data message does not contain the specified recipient. // public static final int CRYPT_E_RECIPIENT_NOT_FOUND = 0x8009100B; // // MessageId: CRYPT_E_CONTROL_TYPE // // MessageText: // // Invalid control type. // public static final int CRYPT_E_CONTROL_TYPE = 0x8009100C; // // MessageId: CRYPT_E_ISSUER_SERIALNUMBER // // MessageText: // // Invalid issuer and/or serial number. // public static final int CRYPT_E_ISSUER_SERIALNUMBER = 0x8009100D; // // MessageId: CRYPT_E_SIGNER_NOT_FOUND // // MessageText: // // Cannot find the original signer. // public static final int CRYPT_E_SIGNER_NOT_FOUND = 0x8009100E; // // MessageId: CRYPT_E_ATTRIBUTES_MISSING // // MessageText: // // The cryptographic message does not contain all of the requested // attributes. // public static final int CRYPT_E_ATTRIBUTES_MISSING = 0x8009100F; // // MessageId: CRYPT_E_STREAM_MSG_NOT_READY // // MessageText: // // The streamed cryptographic message is not ready to return data. // public static final int CRYPT_E_STREAM_MSG_NOT_READY = 0x80091010; // // MessageId: CRYPT_E_STREAM_INSUFFICIENT_DATA // // MessageText: // // The streamed cryptographic message requires more data to complete the // decode operation. // public static final int CRYPT_E_STREAM_INSUFFICIENT_DATA = 0x80091011; // // MessageId: CRYPT_I_NEW_PROTECTION_REQUIRED // // MessageText: // // The protected data needs to be re-protected. // public static final int CRYPT_I_NEW_PROTECTION_REQUIRED = 0x00091012; // // MessageId: CRYPT_E_BAD_LEN // // MessageText: // // The length specified for the output data was insufficient. // public static final int CRYPT_E_BAD_LEN = 0x80092001; // // MessageId: CRYPT_E_BAD_ENCODE // // MessageText: // // An error occurred during encode or decode operation. // public static final int CRYPT_E_BAD_ENCODE = 0x80092002; // // MessageId: CRYPT_E_FILE_ERROR // // MessageText: // // An error occurred while reading or writing to a file. // public static final int CRYPT_E_FILE_ERROR = 0x80092003; // // MessageId: CRYPT_E_NOT_FOUND // // MessageText: // // Cannot find object or property. // public static final int CRYPT_E_NOT_FOUND = 0x80092004; // // MessageId: CRYPT_E_EXISTS // // MessageText: // // The object or property already exists. // public static final int CRYPT_E_EXISTS = 0x80092005; // // MessageId: CRYPT_E_NO_PROVIDER // // MessageText: // // No provider was specified for the store or object. // public static final int CRYPT_E_NO_PROVIDER = 0x80092006; // // MessageId: CRYPT_E_SELF_SIGNED // // MessageText: // // The specified certificate is self signed. // public static final int CRYPT_E_SELF_SIGNED = 0x80092007; // // MessageId: CRYPT_E_DELETED_PREV // // MessageText: // // The previous certificate or CRL context was deleted. // public static final int CRYPT_E_DELETED_PREV = 0x80092008; // // MessageId: CRYPT_E_NO_MATCH // // MessageText: // // Cannot find the requested object. // public static final int CRYPT_E_NO_MATCH = 0x80092009; // // MessageId: CRYPT_E_UNEXPECTED_MSG_TYPE // // MessageText: // // The certificate does not have a property that references a private key. // public static final int CRYPT_E_UNEXPECTED_MSG_TYPE = 0x8009200A; // // MessageId: CRYPT_E_NO_KEY_PROPERTY // // MessageText: // // Cannot find the certificate and private key for decryption. // public static final int CRYPT_E_NO_KEY_PROPERTY = 0x8009200B; // // MessageId: CRYPT_E_NO_DECRYPT_CERT // // MessageText: // // Cannot find the certificate and private key to use for decryption. // public static final int CRYPT_E_NO_DECRYPT_CERT = 0x8009200C; // // MessageId: CRYPT_E_BAD_MSG // // MessageText: // // Not a cryptographic message or the cryptographic message is not formatted // correctly. // public static final int CRYPT_E_BAD_MSG = 0x8009200D; // // MessageId: CRYPT_E_NO_SIGNER // // MessageText: // // The signed cryptographic message does not have a signer for the specified // signer index. // public static final int CRYPT_E_NO_SIGNER = 0x8009200E; // // MessageId: CRYPT_E_PENDING_CLOSE // // MessageText: // // Final closure is pending until additional frees or closes. // public static final int CRYPT_E_PENDING_CLOSE = 0x8009200F; // // MessageId: CRYPT_E_REVOKED // // MessageText: // // The certificate is revoked. // public static final int CRYPT_E_REVOKED = 0x80092010; // // MessageId: CRYPT_E_NO_REVOCATION_DLL // // MessageText: // // No Dll or exported function was found to verify revocation. // public static final int CRYPT_E_NO_REVOCATION_DLL = 0x80092011; // // MessageId: CRYPT_E_NO_REVOCATION_CHECK // // MessageText: // // The revocation function was unable to check revocation for the // certificate. // public static final int CRYPT_E_NO_REVOCATION_CHECK = 0x80092012; // // MessageId: CRYPT_E_REVOCATION_OFF;INE // // MessageText: // // The revocation function was unable to check revocation because the // revocation server was ofF;ine. // public static final int CRYPT_E_REVOCATION_OFFLINE = 0x80092013; // // MessageId: CRYPT_E_NOT_IN_REVOCATION_DATABASE // // MessageText: // // The certificate is not in the revocation server's database. // public static final int CRYPT_E_NOT_IN_REVOCATION_DATABASE = 0x80092014; // // MessageId: CRYPT_E_INVALID_NUMERIC_STRING // // MessageText: // // The string contains a non-numeric character. // public static final int CRYPT_E_INVALID_NUMERIC_STRING = 0x80092020; // // MessageId: CRYPT_E_INVALID_PRINTABLE_STRING // // MessageText: // // The string contains a non-printable character. // public static final int CRYPT_E_INVALID_PRINTABLE_STRING = 0x80092021; // // MessageId: CRYPT_E_INVALID_IA5_STRING // // MessageText: // // The string contains a character not in the=7 bit ASCII character set. // public static final int CRYPT_E_INVALID_IA5_STRING = 0x80092022; // // MessageId: CRYPT_E_INVALID_X500_STRING // // MessageText: // // The string contains an invalid X500 name attribute key, oid, value or // delimiter. // public static final int CRYPT_E_INVALID_X500_STRING = 0x80092023; // // MessageId: CRYPT_E_NOT_CHAR_STRING // // MessageText: // // The dwValueType for the CERT_NAME_VALUE is not one of the character // strings. Most likely it is either a CERT_RDN_ENCODED_BLOB or // CERT_TDN_OCTED_STRING. // public static final int CRYPT_E_NOT_CHAR_STRING = 0x80092024; // // MessageId: CRYPT_E_FILERESIZED // // MessageText: // // The Put operation cannot continue. The file needs to be resized. However, // there is already a signature present. A complete signing operation must // be done. // public static final int CRYPT_E_FILERESIZED = 0x80092025; // // MessageId: CRYPT_E_SECURITY_SETTINGS // // MessageText: // // The cryptographic operation failed due to a local security option // setting. // public static final int CRYPT_E_SECURITY_SETTINGS = 0x80092026; // // MessageId: CRYPT_E_NO_VERIFY_USAGE_DLL // // MessageText: // // No DLL or exported function was found to verify subject usage. // public static final int CRYPT_E_NO_VERIFY_USAGE_DLL = 0x80092027; // // MessageId: CRYPT_E_NO_VERIFY_USAGE_CHECK // // MessageText: // // The called function was unable to do a usage check on the subject. // public static final int CRYPT_E_NO_VERIFY_USAGE_CHECK = 0x80092028; // // MessageId: CRYPT_E_VERIFY_USAGE_OFF;INE // // MessageText: // // Since the server was ofF;ine, the called function was unable to complete // the usage check. // public static final int CRYPT_E_VERIFY_USAGE_OFFLINE = 0x80092029; // // MessageId: CRYPT_E_NOT_IN_CTL // // MessageText: // // The subject was not found in a Certificate Trust List (CT;. // public static final int CRYPT_E_NOT_IN_CTL = 0x8009202A; // // MessageId: CRYPT_E_NO_TRUSTED_SIGNER // // MessageText: // // None of the signers of the cryptographic message or certificate trust // list is trusted. // public static final int CRYPT_E_NO_TRUSTED_SIGNER = 0x8009202B; // // MessageId: CRYPT_E_MISSING_PUBKEY_PARA // // MessageText: // // The public key's algorithm parameters are missing. // public static final int CRYPT_E_MISSING_PUBKEY_PARA = 0x8009202C; // // MessageId: CRYPT_E_OSS_ERROR // // MessageText: // // OSS Certificate encode/decode error code base // // See asn1code.h for a definition of the OSS runtime errors. The OSS // error values are offset by CRYPT_E_OSS_ERROR. // public static final int CRYPT_E_OSS_ERROR = 0x80093000; // // MessageId: OSS_MORE_BUF // // MessageText: // // OSS ASN.1 Error: Output Buffer is too small. // public static final int OSS_MORE_BUF = 0x80093001; // // MessageId: OSS_NEGATIVE_UINTEGER // // MessageText: // // OSS ASN.1 Error: Signed integer is encoded as a unsigned integer. // public static final int OSS_NEGATIVE_UINTEGER = 0x80093002; // // MessageId: OSS_PDU_RANGE // // MessageText: // // OSS ASN.1 Error: Unknown ASN.1 data type. // public static final int OSS_PDU_RANGE = 0x80093003; // // MessageId: OSS_MORE_INPUT // // MessageText: // // OSS ASN.1 Error: Output buffer is too small, the decoded data has been // truncated. // public static final int OSS_MORE_INPUT = 0x80093004; // // MessageId: OSS_DATA_ERROR // // MessageText: // // OSS ASN.1 Error: Invalid data. // public static final int OSS_DATA_ERROR = 0x80093005; // // MessageId: OSS_BAD_ARG // // MessageText: // // OSS ASN.1 Error: Invalid argument. // public static final int OSS_BAD_ARG = 0x80093006; // // MessageId: OSS_BAD_VERSION // // MessageText: // // OSS ASN.1 Error: Encode/Decode version mismatch. // public static final int OSS_BAD_VERSION = 0x80093007; // // MessageId: OSS_OUT_MEMORY // // MessageText: // // OSS ASN.1 Error: Out of memory. // public static final int OSS_OUT_MEMORY = 0x80093008; // // MessageId: OSS_PDU_MISMATCH // // MessageText: // // OSS ASN.1 Error: Encode/Decode Error. // public static final int OSS_PDU_MISMATCH = 0x80093009; // // MessageId: OSS_LIMITED // // MessageText: // // OSS ASN.1 Error: Internal Error. // public static final int OSS_LIMITED = 0x8009300A; // // MessageId: OSS_BAD_PTR // // MessageText: // // OSS ASN.1 Error: Invalid data. // public static final int OSS_BAD_PTR = 0x8009300B; // // MessageId: OSS_BAD_TIME // // MessageText: // // OSS ASN.1 Error: Invalid data. // public static final int OSS_BAD_TIME = 0x8009300C; // // MessageId: OSS_INDEFINITE_NOT_SUPPORTED // // MessageText: // // OSS ASN.1 Error: Unsupported BER indefinite-length encoding. // public static final int OSS_INDEFINITE_NOT_SUPPORTED = 0x8009300D; // // MessageId: OSS_MEM_ERROR // // MessageText: // // OSS ASN.1 Error: Access violation. // public static final int OSS_MEM_ERROR = 0x8009300E; // // MessageId: OSS_BAD_TABLE // // MessageText: // // OSS ASN.1 Error: Invalid data. // public static final int OSS_BAD_TABLE = 0x8009300F; // // MessageId: OSS_TOO_LONG // // MessageText: // // OSS ASN.1 Error: Invalid data. // public static final int OSS_TOO_LONG = 0x80093010; // // MessageId: OSS_CONSTRAINT_VIOLATED // // MessageText: // // OSS ASN.1 Error: Invalid data. // public static final int OSS_CONSTRAINT_VIOLATED = 0x80093011; // // MessageId: OSS_FATAL_ERROR // // MessageText: // // OSS ASN.1 Error: Internal Error. // public static final int OSS_FATAL_ERROR = 0x80093012; // // MessageId: OSS_ACCESS_SERIALIZATION_ERROR // // MessageText: // // OSS ASN.1 Error: Multi-threading conF;ict. // public static final int OSS_ACCESS_SERIALIZATION_ERROR = 0x80093013; // // MessageId: OSS_NULL_TBL // // MessageText: // // OSS ASN.1 Error: Invalid data. // public static final int OSS_NULL_TBL = 0x80093014; // // MessageId: OSS_NULL_FCN // // MessageText: // // OSS ASN.1 Error: Invalid data. // public static final int OSS_NULL_FCN = 0x80093015; // // MessageId: OSS_BAD_ENCRULES // // MessageText: // // OSS ASN.1 Error: Invalid data. // public static final int OSS_BAD_ENCRULES = 0x80093016; // // MessageId: OSS_UNAVAIL_ENCRULES // // MessageText: // // OSS ASN.1 Error: Encode/Decode function not implemented. // public static final int OSS_UNAVAIL_ENCRULES = 0x80093017; // // MessageId: OSS_CANT_OPEN_TRACE_WINDOW // // MessageText: // // OSS ASN.1 Error: Trace file error. // public static final int OSS_CANT_OPEN_TRACE_WINDOW = 0x80093018; // // MessageId: OSS_UNIMPLEMENTED // // MessageText: // // OSS ASN.1 Error: Function not implemented. // public static final int OSS_UNIMPLEMENTED = 0x80093019; // // MessageId: OSS_OID_DLL_NOT_LINKED // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_OID_DLL_NOT_LINKED = 0x8009301A; // // MessageId: OSS_CANT_OPEN_TRACE_FILE // // MessageText: // // OSS ASN.1 Error: Trace file error. // public static final int OSS_CANT_OPEN_TRACE_FILE = 0x8009301B; // // MessageId: OSS_TRACE_FILE_ALREADY_OPEN // // MessageText: // // OSS ASN.1 Error: Trace file error. // public static final int OSS_TRACE_FILE_ALREADY_OPEN = 0x8009301C; // // MessageId: OSS_TABLE_MISMATCH // // MessageText: // // OSS ASN.1 Error: Invalid data. // public static final int OSS_TABLE_MISMATCH = 0x8009301D; // // MessageId: OSS_TYPE_NOT_SUPPORTED // // MessageText: // // OSS ASN.1 Error: Invalid data. // public static final int OSS_TYPE_NOT_SUPPORTED = 0x8009301E; // // MessageId: OSS_REAL_DLL_NOT_LINKED // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_REAL_DLL_NOT_LINKED = 0x8009301F; // // MessageId: OSS_REAL_CODE_NOT_LINKED // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_REAL_CODE_NOT_LINKED = 0x80093020; // // MessageId: OSS_OUT_OF_RANGE // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_OUT_OF_RANGE = 0x80093021; // // MessageId: OSS_COPIER_DLL_NOT_LINKED // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_COPIER_DLL_NOT_LINKED = 0x80093022; // // MessageId: OSS_CONSTRAINT_DLL_NOT_LINKED // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_CONSTRAINT_DLL_NOT_LINKED = 0x80093023; // // MessageId: OSS_COMPARATOR_DLL_NOT_LINKED // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_COMPARATOR_DLL_NOT_LINKED = 0x80093024; // // MessageId: OSS_COMPARATOR_CODE_NOT_LINKED // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_COMPARATOR_CODE_NOT_LINKED = 0x80093025; // // MessageId: OSS_MEM_MGR_DLL_NOT_LINKED // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_MEM_MGR_DLL_NOT_LINKED = 0x80093026; // // MessageId: OSS_PDV_DLL_NOT_LINKED // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_PDV_DLL_NOT_LINKED = 0x80093027; // // MessageId: OSS_PDV_CODE_NOT_LINKED // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_PDV_CODE_NOT_LINKED = 0x80093028; // // MessageId: OSS_API_DLL_NOT_LINKED // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_API_DLL_NOT_LINKED = 0x80093029; // // MessageId: OSS_BERDER_DLL_NOT_LINKED // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_BERDER_DLL_NOT_LINKED = 0x8009302A; // // MessageId: OSS_PER_DLL_NOT_LINKED // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_PER_DLL_NOT_LINKED = 0x8009302B; // // MessageId: OSS_OPEN_TYPE_ERROR // // MessageText: // // OSS ASN.1 Error: Program link error. // public static final int OSS_OPEN_TYPE_ERROR = 0x8009302C; // // MessageId: OSS_MUTEX_NOT_CREATED // // MessageText: // // OSS ASN.1 Error: System resource error. // public static final int OSS_MUTEX_NOT_CREATED = 0x8009302D; // // MessageId: OSS_CANT_CLOSE_TRACE_FILE // // MessageText: // // OSS ASN.1 Error: Trace file error. // public static final int OSS_CANT_CLOSE_TRACE_FILE = 0x8009302E; // // MessageId: CRYPT_E_ASN1_ERROR // // MessageText: // // ASN1 Certificate encode/decode error code base. // // The ASN1 error values are offset by CRYPT_E_ASN1_ERROR. // public static final int CRYPT_E_ASN1_ERROR = 0x80093100; // // MessageId: CRYPT_E_ASN1_INTERNAL // // MessageText: // // ASN1 internal encode or decode error. // public static final int CRYPT_E_ASN1_INTERNAL = 0x80093101; // // MessageId: CRYPT_E_ASN1_EOD // // MessageText: // // ASN1 unexpected end of data. // public static final int CRYPT_E_ASN1_EOD = 0x80093102; // // MessageId: CRYPT_E_ASN1_CORRUPT // // MessageText: // // ASN1 corrupted data. // public static final int CRYPT_E_ASN1_CORRUPT = 0x80093103; // // MessageId: CRYPT_E_ASN1_LARGE // // MessageText: // // ASN1 value too large. // public static final int CRYPT_E_ASN1_LARGE = 0x80093104; // // MessageId: CRYPT_E_ASN1_CONSTRAINT // // MessageText: // // ASN1 constraint violated. // public static final int CRYPT_E_ASN1_CONSTRAINT = 0x80093105; // // MessageId: CRYPT_E_ASN1_MEMORY // // MessageText: // // ASN1 out of memory. // public static final int CRYPT_E_ASN1_MEMORY = 0x80093106; // // MessageId: CRYPT_E_ASN1_OVERF;OW // // MessageText: // // ASN1 buffer overF;ow. // public static final int CRYPT_E_ASN1_OVERFLOW = 0x80093107; // // MessageId: CRYPT_E_ASN1_BADPDU // // MessageText: // // ASN1 function not supported for this PDU. // public static final int CRYPT_E_ASN1_BADPDU = 0x80093108; // // MessageId: CRYPT_E_ASN1_BADARGS // // MessageText: // // ASN1 bad arguments to function call. // public static final int CRYPT_E_ASN1_BADARGS = 0x80093109; // // MessageId: CRYPT_E_ASN1_BADREAL // // MessageText: // // ASN1 bad real value. // public static final int CRYPT_E_ASN1_BADREAL = 0x8009310A; // // MessageId: CRYPT_E_ASN1_BADTAG // // MessageText: // // ASN1 bad tag value met. // public static final int CRYPT_E_ASN1_BADTAG = 0x8009310B; // // MessageId: CRYPT_E_ASN1_CHOICE // // MessageText: // // ASN1 bad choice value. // public static final int CRYPT_E_ASN1_CHOICE = 0x8009310C; // // MessageId: CRYPT_E_ASN1_RULE // // MessageText: // // ASN1 bad encoding rule. // public static final int CRYPT_E_ASN1_RULE = 0x8009310D; // // MessageId: CRYPT_E_ASN1_UTF8 // // MessageText: // // ASN1 bad unicode (UTF8). // public static final int CRYPT_E_ASN1_UTF8 = 0x8009310E; // // MessageId: CRYPT_E_ASN1_PDU_TYPE // // MessageText: // // ASN1 bad PDU type. // public static final int CRYPT_E_ASN1_PDU_TYPE = 0x80093133; // // MessageId: CRYPT_E_ASN1_NYI // // MessageText: // // ASN1 not yet implemented. // public static final int CRYPT_E_ASN1_NYI = 0x80093134; // // MessageId: CRYPT_E_ASN1_EXTENDED // // MessageText: // // ASN1 skipped unknown extension(s). // public static final int CRYPT_E_ASN1_EXTENDED = 0x80093201; // // MessageId: CRYPT_E_ASN1_NOEOD // // MessageText: // // ASN1 end of data expected // public static final int CRYPT_E_ASN1_NOEOD = 0x80093202; // // MessageId: CERTSRV_E_BAD_REQUESTSUBJECT // // MessageText: // // The request subject name is invalid or too long. // public static final int CERTSRV_E_BAD_REQUESTSUBJECT = 0x80094001; // // MessageId: CERTSRV_E_NO_REQUEST // // MessageText: // // The request does not exist. // public static final int CERTSRV_E_NO_REQUEST = 0x80094002; // // MessageId: CERTSRV_E_BAD_REQUESTSTATUS // // MessageText: // // The request's current status does not allow this operation. // public static final int CERTSRV_E_BAD_REQUESTSTATUS = 0x80094003; // // MessageId: CERTSRV_E_PROPERTY_EMPTY // // MessageText: // // The requested property value is empty. // public static final int CERTSRV_E_PROPERTY_EMPTY = 0x80094004; // // MessageId: CERTSRV_E_INVALID_CA_CERTIFICATE // // MessageText: // // The certification authority's certificate contains invalid data. // public static final int CERTSRV_E_INVALID_CA_CERTIFICATE = 0x80094005; // // MessageId: CERTSRV_E_SERVER_SUSPENDED // // MessageText: // // Certificate service has been suspended for a database restore operation. // public static final int CERTSRV_E_SERVER_SUSPENDED = 0x80094006; // // MessageId: CERTSRV_E_ENCODING_LENGTH // // MessageText: // // The certificate contains an encoded length that is potentially // incompatible with older enrollment software. // public static final int CERTSRV_E_ENCODING_LENGTH = 0x80094007; // // MessageId: CERTSRV_E_ROLECONF;ICT // // MessageText: // // The operation is denied. The user has multiple roles assigned and the // certification authority is configured to enforce role separation. // public static final int CERTSRV_E_ROLECONFLICT = 0x80094008; // // MessageId: CERTSRV_E_RESTRICTEDOFFICER // // MessageText: // // The operation is denied. It can only be performed by a certificate // manager that is allowed to manage certificates for the current requester. // public static final int CERTSRV_E_RESTRICTEDOFFICER = 0x80094009; // // MessageId: CERTSRV_E_KEY_ARCHIVAL_NOT_CONFIGURED // // MessageText: // // Cannot archive private key. The certification authority is not configured // for key archival. // public static final int CERTSRV_E_KEY_ARCHIVAL_NOT_CONFIGURED = 0x8009400A; // // MessageId: CERTSRV_E_NO_VALID_KRA // // MessageText: // // Cannot archive private key. The certification authority could not verify // one or more key recovery certificates. // public static final int CERTSRV_E_NO_VALID_KRA = 0x8009400B; // // MessageId: CERTSRV_E_BAD_REQUEST_KEY_ARCHIVAL // // MessageText: // // The request is incorrectly formatted. The encrypted private key must be // in an unauthenticated attribute in an outermost signature. // public static final int CERTSRV_E_BAD_REQUEST_KEY_ARCHIVAL = 0x8009400C; // // MessageId: CERTSRV_E_NO_CAADMIN_DEFINED // // MessageText: // // At least one security principal must have the permission to manage this // CA. // public static final int CERTSRV_E_NO_CAADMIN_DEFINED = 0x8009400D; // // MessageId: CERTSRV_E_BAD_RENEWAL_CERT_ATTRIBUTE // // MessageText: // // The request contains an invalid renewal certificate attribute. // public static final int CERTSRV_E_BAD_RENEWAL_CERT_ATTRIBUTE = 0x8009400E; // // MessageId: CERTSRV_E_NO_DB_SESSIONS // // MessageText: // // An attempt was made to open a Certification Authority database session, // but there are already too many active sessions. The server may need to be // configured to allow additional sessions. // public static final int CERTSRV_E_NO_DB_SESSIONS = 0x8009400F; // // MessageId: CERTSRV_E_ALIGNMENT_FAULT // // MessageText: // // A memory reference caused a data alignment fault. // public static final int CERTSRV_E_ALIGNMENT_FAULT = 0x80094010; // // MessageId: CERTSRV_E_ENROLL_DENIED // // MessageText: // // The permissions on this certification authority do not allow the current // user to enroll for certificates. // public static final int CERTSRV_E_ENROLL_DENIED = 0x80094011; // // MessageId: CERTSRV_E_TEMPLATE_DENIED // // MessageText: // // The permissions on the certificate template do not allow the current user // to enroll for this type of certificate. // public static final int CERTSRV_E_TEMPLATE_DENIED = 0x80094012; // // MessageId: CERTSRV_E_DOWNLEVEL_DC_SSL_OR_UPGRADE // // MessageText: // // The contacted domain controller cannot support signed LDAP traffic. // Update the domain controller or configure Certificate Services to use SSL // for Active Directory access. // public static final int CERTSRV_E_DOWNLEVEL_DC_SSL_OR_UPGRADE = 0x80094013; // // MessageId: CERTSRV_E_UNSUPPORTED_CERT_TYPE // // MessageText: // // The requested certificate template is not supported by this CA. // public static final int CERTSRV_E_UNSUPPORTED_CERT_TYPE = 0x80094800; // // MessageId: CERTSRV_E_NO_CERT_TYPE // // MessageText: // // The request contains no certificate template information. // public static final int CERTSRV_E_NO_CERT_TYPE = 0x80094801; // // MessageId: CERTSRV_E_TEMPLATE_CONF;ICT // // MessageText: // // The request contains conF;icting template information. // public static final int CERTSRV_E_TEMPLATE_CONFLICT = 0x80094802; // // MessageId: CERTSRV_E_SUBJECT_ALT_NAME_REQUIRED // // MessageText: // // The request is missing a required Subject Alternate name extension. // public static final int CERTSRV_E_SUBJECT_ALT_NAME_REQUIRED = 0x80094803; // // MessageId: CERTSRV_E_ARCHIVED_KEY_REQUIRED // // MessageText: // // The request is missing a required private key for archival by the server. // public static final int CERTSRV_E_ARCHIVED_KEY_REQUIRED = 0x80094804; // // MessageId: CERTSRV_E_SMIME_REQUIRED // // MessageText: // // The request is missing a required SMIME capabilities extension. // public static final int CERTSRV_E_SMIME_REQUIRED = 0x80094805; // // MessageId: CERTSRV_E_BAD_RENEWAL_SUBJECT // // MessageText: // // The request was made on behalf of a subject other than the caller. The // certificate template must be configured to require at least one signature // to authorize the request. // public static final int CERTSRV_E_BAD_RENEWAL_SUBJECT = 0x80094806; // // MessageId: CERTSRV_E_BAD_TEMPLATE_VERSION // // MessageText: // // The request template version is newer than the supported template // version. // public static final int CERTSRV_E_BAD_TEMPLATE_VERSION = 0x80094807; // // MessageId: CERTSRV_E_TEMPLATE_POLICY_REQUIRED // // MessageText: // // The template is missing a required signature policy attribute. // public static final int CERTSRV_E_TEMPLATE_POLICY_REQUIRED = 0x80094808; // // MessageId: CERTSRV_E_SIGNATURE_POLICY_REQUIRED // // MessageText: // // The request is missing required signature policy information. // public static final int CERTSRV_E_SIGNATURE_POLICY_REQUIRED = 0x80094809; // // MessageId: CERTSRV_E_SIGNATURE_COUNT // // MessageText: // // The request is missing one or more required signatures. // public static final int CERTSRV_E_SIGNATURE_COUNT = 0x8009480A; // // MessageId: CERTSRV_E_SIGNATURE_REJECTED // // MessageText: // // One or more signatures did not include the required application or // issuance policies. The request is missing one or more required valid // signatures. // public static final int CERTSRV_E_SIGNATURE_REJECTED = 0x8009480B; // // MessageId: CERTSRV_E_ISSUANCE_POLICY_REQUIRED // // MessageText: // // The request is missing one or more required signature issuance policies. // public static final int CERTSRV_E_ISSUANCE_POLICY_REQUIRED = 0x8009480C; // // MessageId: CERTSRV_E_SUBJECT_UPN_REQUIRED // // MessageText: // // The UPN is unavailable and cannot be added to the Subject Alternate name. // public static final int CERTSRV_E_SUBJECT_UPN_REQUIRED = 0x8009480D; // // MessageId: CERTSRV_E_SUBJECT_DIRECTORY_GUID_REQUIRED // // MessageText: // // The Active Directory GUID is unavailable and cannot be added to the // Subject Alternate name. // public static final int CERTSRV_E_SUBJECT_DIRECTORY_GUID_REQUIRED = 0x8009480E; // // MessageId: CERTSRV_E_SUBJECT_DNS_REQUIRED // // MessageText: // // The DNS name is unavailable and cannot be added to the Subject Alternate // name. // public static final int CERTSRV_E_SUBJECT_DNS_REQUIRED = 0x8009480F; // // MessageId: CERTSRV_E_ARCHIVED_KEY_UNEXPECTED // // MessageText: // // The request includes a private key for archival by the server, but key // archival is not enabled for the specified certificate template. // public static final int CERTSRV_E_ARCHIVED_KEY_UNEXPECTED = 0x80094810; // // MessageId: CERTSRV_E_KEY_LENGTH // // MessageText: // // The public key does not meet the minimum size required by the specified // certificate template. // public static final int CERTSRV_E_KEY_LENGTH = 0x80094811; // // MessageId: CERTSRV_E_SUBJECT_EMAIL_REQUIRED // // MessageText: // // The EMail name is unavailable and cannot be added to the Subject or // Subject Alternate name. // public static final int CERTSRV_E_SUBJECT_EMAIL_REQUIRED = 0x80094812; // // MessageId: CERTSRV_E_UNKNOWN_CERT_TYPE // // MessageText: // // One or more certificate templates to be enabled on this certification // authority could not be found. // public static final int CERTSRV_E_UNKNOWN_CERT_TYPE = 0x80094813; // // MessageId: CERTSRV_E_CERT_TYPE_OVERLAP // // MessageText: // // The certificate template renewal period is longer than the certificate // validity period. The template should be reconfigured or the CA // certificate renewed. // public static final int CERTSRV_E_CERT_TYPE_OVERLAP = 0x80094814; // // MessageId: CERTSRV_E_TOO_MANY_SIGNATURES // // MessageText: // // The certificate template requires too many RA signatures. Only one RA // signature is allowed. // public static final int CERTSRV_E_TOO_MANY_SIGNATURES = 0x80094815; // // The range 0x5000-0x51ff is reserved for XENROLL errors. // // // MessageId: XENROLL_E_KEY_NOT_EXPORTABLE // // MessageText: // // The key is not exportable. // public static final int XENROLL_E_KEY_NOT_EXPORTABLE = 0x80095000; // // MessageId: XENROLL_E_CANNOT_ADD_ROOT_CERT // // MessageText: // // You cannot add the root CA certificate into your local store. // public static final int XENROLL_E_CANNOT_ADD_ROOT_CERT = 0x80095001; // // MessageId: XENROLL_E_RESPONSE_KA_HASH_NOT_FOUND // // MessageText: // // The key archival hash attribute was not found in the response. // public static final int XENROLL_E_RESPONSE_KA_HASH_NOT_FOUND = 0x80095002; // // MessageId: XENROLL_E_RESPONSE_UNEXPECTED_KA_HASH // // MessageText: // // An unexpected key archival hash attribute was found in the response. // public static final int XENROLL_E_RESPONSE_UNEXPECTED_KA_HASH = 0x80095003; // // MessageId: XENROLL_E_RESPONSE_KA_HASH_MISMATCH // // MessageText: // // There is a key archival hash mismatch between the request and the // response. // public static final int XENROLL_E_RESPONSE_KA_HASH_MISMATCH = 0x80095004; // // MessageId: XENROLL_E_KEYSPEC_SMIME_MISMATCH // // MessageText: // // Signing certificate cannot include SMIME extension. // public static final int XENROLL_E_KEYSPEC_SMIME_MISMATCH = 0x80095005; // // MessageId: TRUST_E_SYSTEM_ERROR // // MessageText: // // A system-level error occurred while verifying trust. // public static final int TRUST_E_SYSTEM_ERROR = 0x80096001; // // MessageId: TRUST_E_NO_SIGNER_CERT // // MessageText: // // The certificate for the signer of the message is invalid or not found. // public static final int TRUST_E_NO_SIGNER_CERT = 0x80096002; // // MessageId: TRUST_E_COUNTER_SIGNER // // MessageText: // // One of the counter signatures was invalid. // public static final int TRUST_E_COUNTER_SIGNER = 0x80096003; // // MessageId: TRUST_E_CERT_SIGNATURE // // MessageText: // // The signature of the certificate cannot be verified. // public static final int TRUST_E_CERT_SIGNATURE = 0x80096004; // // MessageId: TRUST_E_TIME_STAMP // // MessageText: // // The timestamp signature and/or certificate could not be verified or is // malformed. // public static final int TRUST_E_TIME_STAMP = 0x80096005; // // MessageId: TRUST_E_BAD_DIGEST // // MessageText: // // The digital signature of the object did not verify. // public static final int TRUST_E_BAD_DIGEST = 0x80096010; // // MessageId: TRUST_E_BASIC_CONSTRAINTS // // MessageText: // // A certificate's basic constraint extension has not been observed. // public static final int TRUST_E_BASIC_CONSTRAINTS = 0x80096019; // // MessageId: TRUST_E_FINANCIAL_CRITERIA // // MessageText: // // The certificate does not meet or contain the Authenticode(tm) financial // extensions. // public static final int TRUST_E_FINANCIAL_CRITERIA = 0x8009601E; // // Error codes for mssipotf.dll // Most of the error codes can only occur when an error occurs // during font file signing // // // // MessageId: MSSIPOTF_E_OUTOFMEMRANGE // // MessageText: // // Tried to reference a part of the file outside the proper range. // public static final int MSSIPOTF_E_OUTOFMEMRANGE = 0x80097001; // // MessageId: MSSIPOTF_E_CANTGETOBJECT // // MessageText: // // Could not retrieve an object from the file. // public static final int MSSIPOTF_E_CANTGETOBJECT = 0x80097002; // // MessageId: MSSIPOTF_E_NOHEADTABLE // // MessageText: // // Could not find the head table in the file. // public static final int MSSIPOTF_E_NOHEADTABLE = 0x80097003; // // MessageId: MSSIPOTF_E_BAD_MAGICNUMBER // // MessageText: // // The magic number in the head table is incorrect. // public static final int MSSIPOTF_E_BAD_MAGICNUMBER = 0x80097004; // // MessageId: MSSIPOTF_E_BAD_OFFSET_TABLE // // MessageText: // // The offset table has incorrect values. // public static final int MSSIPOTF_E_BAD_OFFSET_TABLE = 0x80097005; // // MessageId: MSSIPOTF_E_TABLE_TAGORDER // // MessageText: // // Duplicate table tags or tags out of alphabetical order. // public static final int MSSIPOTF_E_TABLE_TAGORDER = 0x80097006; // // MessageId: MSSIPOTF_E_TABLE_LONGWORD // // MessageText: // // A table does not start on a long word boundary. // public static final int MSSIPOTF_E_TABLE_LONGWORD = 0x80097007; // // MessageId: MSSIPOTF_E_BAD_FIRST_TABLE_PLACEMENT // // MessageText: // // First table does not appear after header information. // public static final int MSSIPOTF_E_BAD_FIRST_TABLE_PLACEMENT = 0x80097008; // // MessageId: MSSIPOTF_E_TABLES_OVERLAP // // MessageText: // // Two or more tables overlap. // public static final int MSSIPOTF_E_TABLES_OVERLAP = 0x80097009; // // MessageId: MSSIPOTF_E_TABLE_PADBYTES // // MessageText: // // Too many pad bytes between tables or pad bytes are not 0. // public static final int MSSIPOTF_E_TABLE_PADBYTES = 0x8009700A; // // MessageId: MSSIPOTF_E_FILETOOSMALL // // MessageText: // // File is too small to contain the last table. // public static final int MSSIPOTF_E_FILETOOSMALL = 0x8009700B; // // MessageId: MSSIPOTF_E_TABLE_CHECKSUM // // MessageText: // // A table checksum is incorrect. // public static final int MSSIPOTF_E_TABLE_CHECKSUM = 0x8009700C; // // MessageId: MSSIPOTF_E_FILE_CHECKSUM // // MessageText: // // The file checksum is incorrect. // public static final int MSSIPOTF_E_FILE_CHECKSUM = 0x8009700D; // // MessageId: MSSIPOTF_E_FAILED_POLICY // // MessageText: // // The signature does not have the correct attributes for the policy. // public static final int MSSIPOTF_E_FAILED_POLICY = 0x80097010; // // MessageId: MSSIPOTF_E_FAILED_HINTS_CHECK // // MessageText: // // The file did not pass the hints check. // public static final int MSSIPOTF_E_FAILED_HINTS_CHECK = 0x80097011; // // MessageId: MSSIPOTF_E_NOT_OPENTYPE // // MessageText: // // The file is not an OpenType file. // public static final int MSSIPOTF_E_NOT_OPENTYPE = 0x80097012; // // MessageId: MSSIPOTF_E_FILE // // MessageText: // // Failed on a file operation (open, map, read, write). // public static final int MSSIPOTF_E_FILE = 0x80097013; // // MessageId: MSSIPOTF_E_CRYPT // // MessageText: // // A call to a CryptoAPI function failed. // public static final int MSSIPOTF_E_CRYPT = 0x80097014; // // MessageId: MSSIPOTF_E_BADVERSION // // MessageText: // // There is a bad version number in the file. // public static final int MSSIPOTF_E_BADVERSION = 0x80097015; // // MessageId: MSSIPOTF_E_DSIG_STRUCTURE // // MessageText: // // The structure of the DSIG table is incorrect. // public static final int MSSIPOTF_E_DSIG_STRUCTURE = 0x80097016; // // MessageId: MSSIPOTF_E_PCONST_CHECK // // MessageText: // // A check failed in a partially constant table. // public static final int MSSIPOTF_E_PCONST_CHECK = 0x80097017; // // MessageId: MSSIPOTF_E_STRUCTURE // // MessageText: // // Some kind of structural error. // public static final int MSSIPOTF_E_STRUCTURE = 0x80097018; // // MessageId: ERROR_CRED_REQUIRES_CONFIRMATION // // MessageText: // // The requested credential requires confirmation. // public static final int ERROR_CRED_REQUIRES_CONFIRMATION = 0x80097019; public static final int NTE_OP_OK = 0; // // Note that additional FACILITY_SSPI errors are in issperr.h // // ****************** // FACILITY_CERT // ****************** // // MessageId: TRUST_E_PROVIDER_UNKNOWN // // MessageText: // // Unknown trust provider. // public static final int TRUST_E_PROVIDER_UNKNOWN = 0x800B0001; // // MessageId: TRUST_E_ACTION_UNKNOWN // // MessageText: // // The trust verification action specified is not supported by the specified // trust provider. // public static final int TRUST_E_ACTION_UNKNOWN = 0x800B0002; // // MessageId: TRUST_E_SUBJECT_FORM_UNKNOWN // // MessageText: // // The form specified for the subject is not one supported or known by the // specified trust provider. // public static final int TRUST_E_SUBJECT_FORM_UNKNOWN = 0x800B0003; // // MessageId: TRUST_E_SUBJECT_NOT_TRUSTED // // MessageText: // // The subject is not trusted for the specified action. // public static final int TRUST_E_SUBJECT_NOT_TRUSTED = 0x800B0004; // // MessageId: DIGSIG_E_ENCODE // // MessageText: // // Error due to problem in ASN.1 encoding process. // public static final int DIGSIG_E_ENCODE = 0x800B0005; // // MessageId: DIGSIG_E_DECODE // // MessageText: // // Error due to problem in ASN.1 decoding process. // public static final int DIGSIG_E_DECODE = 0x800B0006; // // MessageId: DIGSIG_E_EXTENSIBILITY // // MessageText: // // Reading / writing Extensions where Attributes are appropriate, and visa // versa. // public static final int DIGSIG_E_EXTENSIBILITY = 0x800B0007; // // MessageId: DIGSIG_E_CRYPTO // // MessageText: // // Unspecified cryptographic failure. // public static final int DIGSIG_E_CRYPTO = 0x800B0008; // // MessageId: PERSIST_E_SIZEDEFINITE // // MessageText: // // The size of the data could not be determined. // public static final int PERSIST_E_SIZEDEFINITE = 0x800B0009; // // MessageId: PERSIST_E_SIZEINDEFINITE // // MessageText: // // The size of the indefinite-sized data could not be determined. // public static final int PERSIST_E_SIZEINDEFINITE = 0x800B000A; // // MessageId: PERSIST_E_NOTSELFSIZING // // MessageText: // // This object does not read and write self-sizing data. // public static final int PERSIST_E_NOTSELFSIZING = 0x800B000B; // // MessageId: TRUST_E_NOSIGNATURE // // MessageText: // // No signature was present in the subject. // public static final int TRUST_E_NOSIGNATURE = 0x800B0100; // // MessageId: CERT_E_EXPIRED // // MessageText: // // A required certificate is not within its validity period when verifying // against the current system clock or the timestamp in the signed file. // public static final int CERT_E_EXPIRED = 0x800B0101; // // MessageId: CERT_E_VALIDITYPERIODNESTING // // MessageText: // // The validity periods of the certification chain do not nest correctly. // public static final int CERT_E_VALIDITYPERIODNESTING = 0x800B0102; // // MessageId: CERT_E_ROLE // // MessageText: // // A certificate that can only be used as an end-entity is being used as a // CA or visa versa. // public static final int CERT_E_ROLE = 0x800B0103; // // MessageId: CERT_E_PATHLENCONST // // MessageText: // // A path length constraint in the certification chain has been violated. // public static final int CERT_E_PATHLENCONST = 0x800B0104; // // MessageId: CERT_E_CRITICAL // // MessageText: // // A certificate contains an unknown extension that is marked 'critical'. // public static final int CERT_E_CRITICAL = 0x800B0105; // // MessageId: CERT_E_PURPOSE // // MessageText: // // A certificate being used for a purpose other than the ones specified by // its CA. // public static final int CERT_E_PURPOSE = 0x800B0106; // // MessageId: CERT_E_ISSUERCHAINING // // MessageText: // // A parent of a given certificate in fact did not issue that child // certificate. // public static final int CERT_E_ISSUERCHAINING = 0x800B0107; // // MessageId: CERT_E_MALFORMED // // MessageText: // // A certificate is missing or has an empty value for an important field, // such as a subject or issuer name. // public static final int CERT_E_MALFORMED = 0x800B0108; // // MessageId: CERT_E_UNTRUSTEDROOT // // MessageText: // // A certificate chain processed, but terminated in a root certificate which // is not trusted by the trust provider. // public static final int CERT_E_UNTRUSTEDROOT = 0x800B0109; // // MessageId: CERT_E_CHAINING // // MessageText: // // A certificate chain could not be built to a trusted root authority. // public static final int CERT_E_CHAINING = 0x800B010A; // // MessageId: TRUST_E_FAIL // // MessageText: // // Generic trust failure. // public static final int TRUST_E_FAIL = 0x800B010B; // // MessageId: CERT_E_REVOKED // // MessageText: // // A certificate was explicitly revoked by its issuer. // public static final int CERT_E_REVOKED = 0x800B010C; // // MessageId: CERT_E_UNTRUSTEDTESTROOT // // MessageText: // // The certification path terminates with the test root which is not trusted // with the current policy settings. // public static final int CERT_E_UNTRUSTEDTESTROOT = 0x800B010D; // // MessageId: CERT_E_REVOCATION_FAILURE // // MessageText: // // The revocation process could not continue - the certificate(s) could not // be checked. // public static final int CERT_E_REVOCATION_FAILURE = 0x800B010E; // // MessageId: CERT_E_CN_NO_MATCH // // MessageText: // // The certificate's CN name does not match the passed value. // public static final int CERT_E_CN_NO_MATCH = 0x800B010F; // // MessageId: CERT_E_WRONG_USAGE // // MessageText: // // The certificate is not valid for the requested usage. // public static final int CERT_E_WRONG_USAGE = 0x800B0110; // // MessageId: TRUST_E_EXPLICIT_DISTRUST // // MessageText: // // The certificate was explicitly marked as untrusted by the user. // public static final int TRUST_E_EXPLICIT_DISTRUST = 0x800B0111; // // MessageId: CERT_E_UNTRUSTEDCA // // MessageText: // // A certification chain processed correctly, but one of the CA certificates // is not trusted by the policy provider. // public static final int CERT_E_UNTRUSTEDCA = 0x800B0112; // // MessageId: CERT_E_INVALID_POLICY // // MessageText: // // The certificate has invalid policy. // public static final int CERT_E_INVALID_POLICY = 0x800B0113; // // MessageId: CERT_E_INVALID_NAME // // MessageText: // // The certificate has an invalid name. The name is not included in the // permitted list or is explicitly excluded. // public static final int CERT_E_INVALID_NAME = 0x800B0114; // ***************** // FACILITY_SETUPAPI // ***************** // // Since these error codes aren't in the standard Win32 range (i.e., 0-64K), // define a // macro to map either Win32 or SetupAPI error codes into an HRESULT. // // MessageId: SPAPI_E_EXPECTED_SECTION_NAME // // MessageText: // // A non-empty line was encountered in the INF before the start of a // section. // public static final int SPAPI_E_EXPECTED_SECTION_NAME = 0x800F0000; // // MessageId: SPAPI_E_BAD_SECTION_NAME_LINE // // MessageText: // // A section name marker in the INF is not complete, or does not exist on a // line by itself. // public static final int SPAPI_E_BAD_SECTION_NAME_LINE = 0x800F0001; // // MessageId: SPAPI_E_SECTION_NAME_TOO_LONG // // MessageText: // // An INF section was encountered whose name exceeds the maximum section // name length. // public static final int SPAPI_E_SECTION_NAME_TOO_LONG = 0x800F0002; // // MessageId: SPAPI_E_GENERAL_SYNTAX // // MessageText: // // The syntax of the INF is invalid. // public static final int SPAPI_E_GENERAL_SYNTAX = 0x800F0003; // // MessageId: SPAPI_E_WRONG_INF_STYLE // // MessageText: // // The style of the INF is different than what was requested. // public static final int SPAPI_E_WRONG_INF_STYLE = 0x800F0100; // // MessageId: SPAPI_E_SECTION_NOT_FOUND // // MessageText: // // The required section was not found in the INF. // public static final int SPAPI_E_SECTION_NOT_FOUND = 0x800F0101; // // MessageId: SPAPI_E_LINE_NOT_FOUND // // MessageText: // // The required line was not found in the INF. // public static final int SPAPI_E_LINE_NOT_FOUND = 0x800F0102; // // MessageId: SPAPI_E_NO_BACKUP // // MessageText: // // The files affected by the installation of this file queue have not been // backed up for uninstall. // public static final int SPAPI_E_NO_BACKUP = 0x800F0103; // // MessageId: SPAPI_E_NO_ASSOCIATED_CLASS // // MessageText: // // The INF or the device information set or element does not have an // associated install class. // public static final int SPAPI_E_NO_ASSOCIATED_CLASS = 0x800F0200; // // MessageId: SPAPI_E_CLASS_MISMATCH // // MessageText: // // The INF or the device information set or element does not match the // specified install class. // public static final int SPAPI_E_CLASS_MISMATCH = 0x800F0201; // // MessageId: SPAPI_E_DUPLICATE_FOUND // // MessageText: // // An existing device was found that is a duplicate of the device being // manually installed. // public static final int SPAPI_E_DUPLICATE_FOUND = 0x800F0202; // // MessageId: SPAPI_E_NO_DRIVER_SELECTED // // MessageText: // // There is no driver selected for the device information set or element. // public static final int SPAPI_E_NO_DRIVER_SELECTED = 0x800F0203; // // MessageId: SPAPI_E_KEY_DOES_NOT_EXIST // // MessageText: // // The requested device registry key does not exist. // public static final int SPAPI_E_KEY_DOES_NOT_EXIST = 0x800F0204; // // MessageId: SPAPI_E_INVALID_DEVINST_NAME // // MessageText: // // The device instance name is invalid. // public static final int SPAPI_E_INVALID_DEVINST_NAME = 0x800F0205; // // MessageId: SPAPI_E_INVALID_CLASS // // MessageText: // // The install class is not present or is invalid. // public static final int SPAPI_E_INVALID_CLASS = 0x800F0206; // // MessageId: SPAPI_E_DEVINST_ALREADY_EXISTS // // MessageText: // // The device instance cannot be created because it already exists. // public static final int SPAPI_E_DEVINST_ALREADY_EXISTS = 0x800F0207; // // MessageId: SPAPI_E_DEVINFO_NOT_REGISTERED // // MessageText: // // The operation cannot be performed on a device information element that // has not been registered. // public static final int SPAPI_E_DEVINFO_NOT_REGISTERED = 0x800F0208; // // MessageId: SPAPI_E_INVALID_REG_PROPERTY // // MessageText: // // The device property code is invalid. // public static final int SPAPI_E_INVALID_REG_PROPERTY = 0x800F0209; // // MessageId: SPAPI_E_NO_INF // // MessageText: // // The INF from which a driver list is to be built does not exist. // public static final int SPAPI_E_NO_INF = 0x800F020A; // // MessageId: SPAPI_E_NO_SUCH_DEVINST // // MessageText: // // The device instance does not exist in the hardware tree. // public static final int SPAPI_E_NO_SUCH_DEVINST = 0x800F020B; // // MessageId: SPAPI_E_CANT_LOAD_CLASS_ICON // // MessageText: // // The icon representing this install class cannot be loaded. // public static final int SPAPI_E_CANT_LOAD_CLASS_ICON = 0x800F020C; // // MessageId: SPAPI_E_INVALID_CLASS_INSTALLER // // MessageText: // // The class installer registry entry is invalid. // public static final int SPAPI_E_INVALID_CLASS_INSTALLER = 0x800F020D; // // MessageId: SPAPI_E_DI_DO_DEFAULT // // MessageText: // // The class installer has indicated that the default action should be // performed for this installation request. // public static final int SPAPI_E_DI_DO_DEFAULT = 0x800F020E; // // MessageId: SPAPI_E_DI_NOFILECOPY // // MessageText: // // The operation does not require any files to be copied. // public static final int SPAPI_E_DI_NOFILECOPY = 0x800F020F; // // MessageId: SPAPI_E_INVALID_HWPROFILE // // MessageText: // // The specified hardware profile does not exist. // public static final int SPAPI_E_INVALID_HWPROFILE = 0x800F0210; // // MessageId: SPAPI_E_NO_DEVICE_SELECTED // // MessageText: // // There is no device information element currently selected for this device // information set. // public static final int SPAPI_E_NO_DEVICE_SELECTED = 0x800F0211; // // MessageId: SPAPI_E_DEVINFO_LIST_LOCKED // // MessageText: // // The operation cannot be performed because the device information set is // locked. // public static final int SPAPI_E_DEVINFO_LIST_LOCKED = 0x800F0212; // // MessageId: SPAPI_E_DEVINFO_DATA_LOCKED // // MessageText: // // The operation cannot be performed because the device information element // is locked. // public static final int SPAPI_E_DEVINFO_DATA_LOCKED = 0x800F0213; // // MessageId: SPAPI_E_DI_BAD_PATH // // MessageText: // // The specified path does not contain any applicable device INFs. // public static final int SPAPI_E_DI_BAD_PATH = 0x800F0214; // // MessageId: SPAPI_E_NO_CLASSINSTALL_PARAMS // // MessageText: // // No class installer parameters have been set for the device information // set or element. // public static final int SPAPI_E_NO_CLASSINSTALL_PARAMS = 0x800F0215; // // MessageId: SPAPI_E_FILEQUEUE_LOCKED // // MessageText: // // The operation cannot be performed because the file queue is locked. // public static final int SPAPI_E_FILEQUEUE_LOCKED = 0x800F0216; // // MessageId: SPAPI_E_BAD_SERVICE_INSTALLSECT // // MessageText: // // A service installation section in this INF is invalid. // public static final int SPAPI_E_BAD_SERVICE_INSTALLSECT = 0x800F0217; // // MessageId: SPAPI_E_NO_CLASS_DRIVER_LIST // // MessageText: // // There is no class driver list for the device information element. // public static final int SPAPI_E_NO_CLASS_DRIVER_LIST = 0x800F0218; // // MessageId: SPAPI_E_NO_ASSOCIATED_SERVICE // // MessageText: // // The installation failed because a function driver was not specified for // this device instance. // public static final int SPAPI_E_NO_ASSOCIATED_SERVICE = 0x800F0219; // // MessageId: SPAPI_E_NO_DEFAULT_DEVICE_INTERFACE // // MessageText: // // There is presently no default device interface designated for this // interface class. // public static final int SPAPI_E_NO_DEFAULT_DEVICE_INTERFACE = 0x800F021A; // // MessageId: SPAPI_E_DEVICE_INTERFACE_ACTIVE // // MessageText: // // The operation cannot be performed because the device interface is // currently active. // public static final int SPAPI_E_DEVICE_INTERFACE_ACTIVE = 0x800F021B; // // MessageId: SPAPI_E_DEVICE_INTERFACE_REMOVED // // MessageText: // // The operation cannot be performed because the device interface has been // removed from the system. // public static final int SPAPI_E_DEVICE_INTERFACE_REMOVED = 0x800F021C; // // MessageId: SPAPI_E_BAD_INTERFACE_INSTALLSECT // // MessageText: // // An interface installation section in this INF is invalid. // public static final int SPAPI_E_BAD_INTERFACE_INSTALLSECT = 0x800F021D; // // MessageId: SPAPI_E_NO_SUCH_INTERFACE_CLASS // // MessageText: // // This interface class does not exist in the system. // public static final int SPAPI_E_NO_SUCH_INTERFACE_CLASS = 0x800F021E; // // MessageId: SPAPI_E_INVALID_REFERENCE_STRING // // MessageText: // // The reference string supplied for this interface device is invalid. // public static final int SPAPI_E_INVALID_REFERENCE_STRING = 0x800F021F; // // MessageId: SPAPI_E_INVALID_MACHINENAME // // MessageText: // // The specified machine name does not conform to UNC naming conventions. // public static final int SPAPI_E_INVALID_MACHINENAME = 0x800F0220; // // MessageId: SPAPI_E_REMOTE_COMM_FAILURE // // MessageText: // // A general remote communication error occurred. // public static final int SPAPI_E_REMOTE_COMM_FAILURE = 0x800F0221; // // MessageId: SPAPI_E_MACHINE_UNAVAILABLE // // MessageText: // // The machine selected for remote communication is not available at this // time. // public static final int SPAPI_E_MACHINE_UNAVAILABLE = 0x800F0222; // // MessageId: SPAPI_E_NO_CONFIGMGR_SERVICES // // MessageText: // // The Plug and Play service is not available on the remote machine. // public static final int SPAPI_E_NO_CONFIGMGR_SERVICES = 0x800F0223; // // MessageId: SPAPI_E_INVALID_PROPPAGE_PROVIDER // // MessageText: // // The property page provider registry entry is invalid. // public static final int SPAPI_E_INVALID_PROPPAGE_PROVIDER = 0x800F0224; // // MessageId: SPAPI_E_NO_SUCH_DEVICE_INTERFACE // // MessageText: // // The requested device interface is not present in the system. // public static final int SPAPI_E_NO_SUCH_DEVICE_INTERFACE = 0x800F0225; // // MessageId: SPAPI_E_DI_POSTPROCESSING_REQUIRED // // MessageText: // // The device's co-installer has additional work to perform after // installation is complete. // public static final int SPAPI_E_DI_POSTPROCESSING_REQUIRED = 0x800F0226; // // MessageId: SPAPI_E_INVALID_COINSTALLER // // MessageText: // // The device's co-installer is invalid. // public static final int SPAPI_E_INVALID_COINSTALLER = 0x800F0227; // // MessageId: SPAPI_E_NO_COMPAT_DRIVERS // // MessageText: // // There are no compatible drivers for this device. // public static final int SPAPI_E_NO_COMPAT_DRIVERS = 0x800F0228; // // MessageId: SPAPI_E_NO_DEVICE_ICON // // MessageText: // // There is no icon that represents this device or device type. // public static final int SPAPI_E_NO_DEVICE_ICON = 0x800F0229; // // MessageId: SPAPI_E_INVALID_INF_LOGCONFIG // // MessageText: // // A logical configuration specified in this INF is invalid. // public static final int SPAPI_E_INVALID_INF_LOGCONFIG = 0x800F022A; // // MessageId: SPAPI_E_DI_DONT_INSTALL // // MessageText: // // The class installer has denied the request to install or upgrade this // device. // public static final int SPAPI_E_DI_DONT_INSTALL = 0x800F022B; // // MessageId: SPAPI_E_INVALID_FILTER_DRIVER // // MessageText: // // One of the filter drivers installed for this device is invalid. // public static final int SPAPI_E_INVALID_FILTER_DRIVER = 0x800F022C; // // MessageId: SPAPI_E_NON_WINDOWS_NT_DRIVER // // MessageText: // // The driver selected for this device does not support Windows Vista. // public static final int SPAPI_E_NON_WINDOWS_NT_DRIVER = 0x800F022D; // // MessageId: SPAPI_E_NON_WINDOWS_DRIVER // // MessageText: // // The driver selected for this device does not support Windows. // public static final int SPAPI_E_NON_WINDOWS_DRIVER = 0x800F022E; // // MessageId: SPAPI_E_NO_CATALOG_FOR_OEM_INF // // MessageText: // // The third-party INF does not contain digital signature information. // public static final int SPAPI_E_NO_CATALOG_FOR_OEM_INF = 0x800F022F; // // MessageId: SPAPI_E_DEVINSTALL_QUEUE_NONNATIVE // // MessageText: // // An invalid attempt was made to use a device installation file queue for // verification of digital signatures relative to other platforms. // public static final int SPAPI_E_DEVINSTALL_QUEUE_NONNATIVE = 0x800F0230; // // MessageId: SPAPI_E_NOT_DISABLEABLE // // MessageText: // // The device cannot be disabled. // public static final int SPAPI_E_NOT_DISABLEABLE = 0x800F0231; // // MessageId: SPAPI_E_CANT_REMOVE_DEVINST // // MessageText: // // The device could not be dynamically removed. // public static final int SPAPI_E_CANT_REMOVE_DEVINST = 0x800F0232; // // MessageId: SPAPI_E_INVALID_TARGET // // MessageText: // // Cannot copy to specified target. // public static final int SPAPI_E_INVALID_TARGET = 0x800F0233; // // MessageId: SPAPI_E_DRIVER_NONNATIVE // // MessageText: // // Driver is not intended for this platform. // public static final int SPAPI_E_DRIVER_NONNATIVE = 0x800F0234; // // MessageId: SPAPI_E_IN_WOW64 // // MessageText: // // Operation not allowed in WOW64. // public static final int SPAPI_E_IN_WOW64 = 0x800F0235; // // MessageId: SPAPI_E_SET_SYSTEM_RESTORE_POINT // // MessageText: // // The operation involving unsigned file copying was rolled back, so that a // system restore point could be set. // public static final int SPAPI_E_SET_SYSTEM_RESTORE_POINT = 0x800F0236; // // MessageId: SPAPI_E_INCORRECTLY_COPIED_INF // // MessageText: // // An INF was copied into the Windows INF directory in an improper manner. // public static final int SPAPI_E_INCORRECTLY_COPIED_INF = 0x800F0237; // // MessageId: SPAPI_E_SCE_DISABLED // // MessageText: // // The Security Configuration Editor (SCE) APIs have been disabled on this // Embedded product. // public static final int SPAPI_E_SCE_DISABLED = 0x800F0238; // // MessageId: SPAPI_E_UNKNOWN_EXCEPTION // // MessageText: // // An unknown exception was encountered. // public static final int SPAPI_E_UNKNOWN_EXCEPTION = 0x800F0239; // // MessageId: SPAPI_E_PNP_REGISTRY_ERROR // // MessageText: // // A problem was encountered when accessing the Plug and Play registry // database. // public static final int SPAPI_E_PNP_REGISTRY_ERROR = 0x800F023A; // // MessageId: SPAPI_E_REMOTE_REQUEST_UNSUPPORTED // // MessageText: // // The requested operation is not supported for a remote machine. // public static final int SPAPI_E_REMOTE_REQUEST_UNSUPPORTED = 0x800F023B; // // MessageId: SPAPI_E_NOT_AN_INSTALLED_OEM_INF // // MessageText: // // The specified file is not an installed OEM INF. // public static final int SPAPI_E_NOT_AN_INSTALLED_OEM_INF = 0x800F023C; // // MessageId: SPAPI_E_INF_IN_USE_BY_DEVICES // // MessageText: // // One or more devices are presently installed using the specified INF. // public static final int SPAPI_E_INF_IN_USE_BY_DEVICES = 0x800F023D; // // MessageId: SPAPI_E_DI_FUNCTION_OBSOLETE // // MessageText: // // The requested device install operation is obsolete. // public static final int SPAPI_E_DI_FUNCTION_OBSOLETE = 0x800F023E; // // MessageId: SPAPI_E_NO_AUTHENTICODE_CATALOG // // MessageText: // // A file could not be verified because it does not have an associated // catalog signed via Authenticode(tm). // public static final int SPAPI_E_NO_AUTHENTICODE_CATALOG = 0x800F023F; // // MessageId: SPAPI_E_AUTHENTICODE_DISALLOWED // // MessageText: // // Authenticode(tm) signature verification is not supported for the // specified INF. // public static final int SPAPI_E_AUTHENTICODE_DISALLOWED = 0x800F0240; // // MessageId: SPAPI_E_AUTHENTICODE_TRUSTED_PUBLISHER // // MessageText: // // The INF was signed with an Authenticode(tm) catalog from a trusted // publisher. // public static final int SPAPI_E_AUTHENTICODE_TRUSTED_PUBLISHER = 0x800F0241; // // MessageId: SPAPI_E_AUTHENTICODE_TRUST_NOT_ESTABLISHED // // MessageText: // // The publisher of an Authenticode(tm) signed catalog has not yet been // established as trusted. // public static final int SPAPI_E_AUTHENTICODE_TRUST_NOT_ESTABLISHED = 0x800F0242; // // MessageId: SPAPI_E_AUTHENTICODE_PUBLISHER_NOT_TRUSTED // // MessageText: // // The publisher of an Authenticode(tm) signed catalog was not established // as trusted. // public static final int SPAPI_E_AUTHENTICODE_PUBLISHER_NOT_TRUSTED = 0x800F0243; // // MessageId: SPAPI_E_SIGNATURE_OSATTRIBUTE_MISMATCH // // MessageText: // // The software was tested for compliance with Windows Logo requirements on // a different version of Windows, and may not be compatible with this // version. // public static final int SPAPI_E_SIGNATURE_OSATTRIBUTE_MISMATCH = 0x800F0244; // // MessageId: SPAPI_E_ONLY_VALIDATE_VIA_AUTHENTICODE // // MessageText: // // The file may only be validated by a catalog signed via Authenticode(tm). // public static final int SPAPI_E_ONLY_VALIDATE_VIA_AUTHENTICODE = 0x800F0245; // // MessageId: SPAPI_E_DEVICE_INSTALLER_NOT_READY // // MessageText: // // One of the installers for this device cannot perform the installation at // this time. // public static final int SPAPI_E_DEVICE_INSTALLER_NOT_READY = 0x800F0246; // // MessageId: SPAPI_E_DRIVER_STORE_ADD_FAILED // // MessageText: // // A problem was encountered while attempting to add the driver to the // store. // public static final int SPAPI_E_DRIVER_STORE_ADD_FAILED = 0x800F0247; // // MessageId: SPAPI_E_DEVICE_INSTALL_BLOCKED // // MessageText: // // The installation of this device is forbidden by system policy. Contact // your system administrator. // public static final int SPAPI_E_DEVICE_INSTALL_BLOCKED = 0x800F0248; // // MessageId: SPAPI_E_DRIVER_INSTALL_BLOCKED // // MessageText: // // The installation of this driver is forbidden by system policy. Contact // your system administrator. // public static final int SPAPI_E_DRIVER_INSTALL_BLOCKED = 0x800F0249; // // MessageId: SPAPI_E_WRONG_INF_TYPE // // MessageText: // // The specified INF is the wrong type for this operation. // public static final int SPAPI_E_WRONG_INF_TYPE = 0x800F024A; // // MessageId: SPAPI_E_FILE_HASH_NOT_IN_CATALOG // // MessageText: // // The hash for the file is not present in the specified catalog file. The // file is likely corrupt or the victim of tampering. // public static final int SPAPI_E_FILE_HASH_NOT_IN_CATALOG = 0x800F024B; // // MessageId: SPAPI_E_DRIVER_STORE_DELETE_FAILED // // MessageText: // // A problem was encountered while attempting to delete the driver from the // store. // public static final int SPAPI_E_DRIVER_STORE_DELETE_FAILED = 0x800F024C; // // MessageId: SPAPI_E_UNRECOVERABLE_STACK_OVERF;OW // // MessageText: // // An unrecoverable stack overF;ow was encountered. // public static final int SPAPI_E_UNRECOVERABLE_STACK_OVERFLOW = 0x800F0300; // // MessageId: SPAPI_E_ERROR_NOT_INSTALLED // // MessageText: // // No installed components were detected. // public static final int SPAPI_E_ERROR_NOT_INSTALLED = 0x800F1000; // ***************** // FACILITY_SCARD // ***************** // // == // Facility SCARD Error Messages // == // public static final int SCARD_S_SUCCESS = NO_ERROR; // // MessageId: SCARD_F_INTERNAL_ERROR // // MessageText: // // An internal consistency check failed. // public static final int SCARD_F_INTERNAL_ERROR = 0x80100001; // // MessageId: SCARD_E_CANCELLED // // MessageText: // // The action was cancelled by an SCardCancel request. // public static final int SCARD_E_CANCELLED = 0x80100002; // // MessageId: SCARD_E_INVALID_HANDLE // // MessageText: // // The supplied handle was invalid. // public static final int SCARD_E_INVALID_HANDLE = 0x80100003; // // MessageId: SCARD_E_INVALID_PARAMETER // // MessageText: // // One or more of the supplied parameters could not be properly interpreted. // public static final int SCARD_E_INVALID_PARAMETER = 0x80100004; // // MessageId: SCARD_E_INVALID_TARGET // // MessageText: // // Registry startup information is missing or invalid. // public static final int SCARD_E_INVALID_TARGET = 0x80100005; // // MessageId: SCARD_E_NO_MEMORY // // MessageText: // // Not enough memory available to complete this command. // public static final int SCARD_E_NO_MEMORY = 0x80100006; // // MessageId: SCARD_F_WAITED_TOO_LONG // // MessageText: // // An internal consistency timer has expired. // public static final int SCARD_F_WAITED_TOO_LONG = 0x80100007; // // MessageId: SCARD_E_INSUFFICIENT_BUFFER // // MessageText: // // The data buffer to receive returned data is too small for the returned // data. // public static final int SCARD_E_INSUFFICIENT_BUFFER = 0x80100008; // // MessageId: SCARD_E_UNKNOWN_READER // // MessageText: // // The specified reader name is not recognized. // public static final int SCARD_E_UNKNOWN_READER = 0x80100009; // // MessageId: SCARD_E_TIMEOUT // // MessageText: // // The user-specified timeout value has expired. // public static final int SCARD_E_TIMEOUT = 0x8010000A; // // MessageId: SCARD_E_SHARING_VIOLATION // // MessageText: // // The smart card cannot be accessed because of other connections // outstanding. // public static final int SCARD_E_SHARING_VIOLATION = 0x8010000B; // // MessageId: SCARD_E_NO_SMARTCARD // // MessageText: // // The operation requires a Smart Card, but no Smart Card is currently in // the device. // public static final int SCARD_E_NO_SMARTCARD = 0x8010000C; // // MessageId: SCARD_E_UNKNOWN_CARD // // MessageText: // // The specified smart card name is not recognized. // public static final int SCARD_E_UNKNOWN_CARD = 0x8010000D; // // MessageId: SCARD_E_CANT_DISPOSE // // MessageText: // // The system could not dispose of the media in the requested manner. // public static final int SCARD_E_CANT_DISPOSE = 0x8010000E; // // MessageId: SCARD_E_PROTO_MISMATCH // // MessageText: // // The requested protocols are incompatible with the protocol currently in // use with the smart card. // public static final int SCARD_E_PROTO_MISMATCH = 0x8010000F; // // MessageId: SCARD_E_NOT_READY // // MessageText: // // The reader or smart card is not ready to accept commands. // public static final int SCARD_E_NOT_READY = 0x80100010; // // MessageId: SCARD_E_INVALID_VALUE // // MessageText: // // One or more of the supplied parameters values could not be properly // interpreted. // public static final int SCARD_E_INVALID_VALUE = 0x80100011; // // MessageId: SCARD_E_SYSTEM_CANCELLED // // MessageText: // // The action was cancelled by the system, presumably to log off or shut // down. // public static final int SCARD_E_SYSTEM_CANCELLED = 0x80100012; // // MessageId: SCARD_F_COMM_ERROR // // MessageText: // // An internal communications error has been detected. // public static final int SCARD_F_COMM_ERROR = 0x80100013; // // MessageId: SCARD_F_UNKNOWN_ERROR // // MessageText: // // An internal error has been detected, but the source is unknown. // public static final int SCARD_F_UNKNOWN_ERROR = 0x80100014; // // MessageId: SCARD_E_INVALID_ATR // // MessageText: // // An ATR obtained from the registry is not a valid ATR string. // public static final int SCARD_E_INVALID_ATR = 0x80100015; // // MessageId: SCARD_E_NOT_TRANSACTED // // MessageText: // // An attempt was made to end a non-existent transaction. // public static final int SCARD_E_NOT_TRANSACTED = 0x80100016; // // MessageId: SCARD_E_READER_UNAVAILABLE // // MessageText: // // The specified reader is not currently available for use. // public static final int SCARD_E_READER_UNAVAILABLE = 0x80100017; // // MessageId: SCARD_P_SHUTDOWN // // MessageText: // // The operation has been aborted to allow the server application to exit. // public static final int SCARD_P_SHUTDOWN = 0x80100018; // // MessageId: SCARD_E_PCI_TOO_SMALL // // MessageText: // // The PCI Receive buffer was too small. // public static final int SCARD_E_PCI_TOO_SMALL = 0x80100019; // // MessageId: SCARD_E_READER_UNSUPPORTED // // MessageText: // // The reader driver does not meet minimal requirements for support. // public static final int SCARD_E_READER_UNSUPPORTED = 0x8010001A; // // MessageId: SCARD_E_DUPLICATE_READER // // MessageText: // // The reader driver did not produce a unique reader name. // public static final int SCARD_E_DUPLICATE_READER = 0x8010001B; // // MessageId: SCARD_E_CARD_UNSUPPORTED // // MessageText: // // The smart card does not meet minimal requirements for support. // public static final int SCARD_E_CARD_UNSUPPORTED = 0x8010001C; // // MessageId: SCARD_E_NO_SERVICE // // MessageText: // // The Smart card resource manager is not running. // public static final int SCARD_E_NO_SERVICE = 0x8010001D; // // MessageId: SCARD_E_SERVICE_STOPPED // // MessageText: // // The Smart card resource manager has shut down. // public static final int SCARD_E_SERVICE_STOPPED = 0x8010001E; // // MessageId: SCARD_E_UNEXPECTED // // MessageText: // // An unexpected card error has occurred. // public static final int SCARD_E_UNEXPECTED = 0x8010001F; // // MessageId: SCARD_E_ICC_INSTALLATION // // MessageText: // // No Primary Provider can be found for the smart card. // public static final int SCARD_E_ICC_INSTALLATION = 0x80100020; // // MessageId: SCARD_E_ICC_CREATEORDER // // MessageText: // // The requested order of object creation is not supported. // public static final int SCARD_E_ICC_CREATEORDER = 0x80100021; // // MessageId: SCARD_E_UNSUPPORTED_FEATURE // // MessageText: // // This smart card does not support the requested feature. // public static final int SCARD_E_UNSUPPORTED_FEATURE = 0x80100022; // // MessageId: SCARD_E_DIR_NOT_FOUND // // MessageText: // // The identified directory does not exist in the smart card. // public static final int SCARD_E_DIR_NOT_FOUND = 0x80100023; // // MessageId: SCARD_E_FILE_NOT_FOUND // // MessageText: // // The identified file does not exist in the smart card. // public static final int SCARD_E_FILE_NOT_FOUND = 0x80100024; // // MessageId: SCARD_E_NO_DIR // // MessageText: // // The supplied path does not represent a smart card directory. // public static final int SCARD_E_NO_DIR = 0x80100025; // // MessageId: SCARD_E_NO_FILE // // MessageText: // // The supplied path does not represent a smart card file. // public static final int SCARD_E_NO_FILE = 0x80100026; // // MessageId: SCARD_E_NO_ACCESS // // MessageText: // // Access is denied to this file. // public static final int SCARD_E_NO_ACCESS = 0x80100027; // // MessageId: SCARD_E_WRITE_TOO_MANY // // MessageText: // // The smartcard does not have enough memory to store the information. // public static final int SCARD_E_WRITE_TOO_MANY = 0x80100028; // // MessageId: SCARD_E_BAD_SEEK // // MessageText: // // There was an error trying to set the smart card file object pointer. // public static final int SCARD_E_BAD_SEEK = 0x80100029; // // MessageId: SCARD_E_INVALID_CHV // // MessageText: // // The supplied PIN is incorrect. // public static final int SCARD_E_INVALID_CHV = 0x8010002A; // // MessageId: SCARD_E_UNKNOWN_RES_MNG // // MessageText: // // An unrecognized error code was returned from a layered component. // public static final int SCARD_E_UNKNOWN_RES_MNG = 0x8010002B; // // MessageId: SCARD_E_NO_SUCH_CERTIFICATE // // MessageText: // // The requested certificate does not exist. // public static final int SCARD_E_NO_SUCH_CERTIFICATE = 0x8010002C; // // MessageId: SCARD_E_CERTIFICATE_UNAVAILABLE // // MessageText: // // The requested certificate could not be obtained. // public static final int SCARD_E_CERTIFICATE_UNAVAILABLE = 0x8010002D; // // MessageId: SCARD_E_NO_READERS_AVAILABLE // // MessageText: // // Cannot find a smart card reader. // public static final int SCARD_E_NO_READERS_AVAILABLE = 0x8010002E; // // MessageId: SCARD_E_COMM_DATA_LOST // // MessageText: // // A communications error with the smart card has been detected. Retry the // operation. // public static final int SCARD_E_COMM_DATA_LOST = 0x8010002F; // // MessageId: SCARD_E_NO_KEY_CONTAINER // // MessageText: // // The requested key container does not exist on the smart card. // public static final int SCARD_E_NO_KEY_CONTAINER = 0x80100030; // // MessageId: SCARD_E_SERVER_TOO_BUSY // // MessageText: // // The Smart card resource manager is too busy to complete this operation. // public static final int SCARD_E_SERVER_TOO_BUSY = 0x80100031; // // These are warning codes. // // // MessageId: SCARD_W_UNSUPPORTED_CARD // // MessageText: // // The reader cannot communicate with the smart card, due to ATR // configuration conF;icts. // public static final int SCARD_W_UNSUPPORTED_CARD = 0x80100065; // // MessageId: SCARD_W_UNRESPONSIVE_CARD // // MessageText: // // The smart card is not responding to a reset. // public static final int SCARD_W_UNRESPONSIVE_CARD = 0x80100066; // // MessageId: SCARD_W_UNPOWERED_CARD // // MessageText: // // Power has been removed from the smart card, so that further communication // is not possible. // public static final int SCARD_W_UNPOWERED_CARD = 0x80100067; // // MessageId: SCARD_W_RESET_CARD // // MessageText: // // The smart card has been reset, so any shared state information is // invalid. // public static final int SCARD_W_RESET_CARD = 0x80100068; // // MessageId: SCARD_W_REMOVED_CARD // // MessageText: // // The smart card has been removed, so that further communication is not // possible. // public static final int SCARD_W_REMOVED_CARD = 0x80100069; // // MessageId: SCARD_W_SECURITY_VIOLATION // // MessageText: // // Access was denied because of a security violation. // public static final int SCARD_W_SECURITY_VIOLATION = 0x8010006A; // // MessageId: SCARD_W_WRONG_CHV // // MessageText: // // The card cannot be accessed because the wrong PIN was presented. // public static final int SCARD_W_WRONG_CHV = 0x8010006B; // // MessageId: SCARD_W_CHV_BLOCKED // // MessageText: // // The card cannot be accessed because the maximum number of PIN entry // attempts has been reached. // public static final int SCARD_W_CHV_BLOCKED = 0x8010006C; // // MessageId: SCARD_W_EOF // // MessageText: // // The end of the smart card file has been reached. // public static final int SCARD_W_EOF = 0x8010006D; // // MessageId: SCARD_W_CANCELLED_BY_USER // // MessageText: // // The action was cancelled by the user. // public static final int SCARD_W_CANCELLED_BY_USER = 0x8010006E; // // MessageId: SCARD_W_CARD_NOT_AUTHENTICATED // // MessageText: // // No PIN was presented to the smart card. // public static final int SCARD_W_CARD_NOT_AUTHENTICATED = 0x8010006F; // // MessageId: SCARD_W_CACHE_ITEM_NOT_FOUND // // MessageText: // // The requested item could not be found in the cache. // public static final int SCARD_W_CACHE_ITEM_NOT_FOUND = 0x80100070; // // MessageId: SCARD_W_CACHE_ITEM_STALE // // MessageText: // // The requested cache item is too old and was deleted from the cache. // public static final int SCARD_W_CACHE_ITEM_STALE = 0x80100071; // // MessageId: SCARD_W_CACHE_ITEM_TOO_BIG // // MessageText: // // The new cache item exceeds the maximum per-item size defined for the // cache. // public static final int SCARD_W_CACHE_ITEM_TOO_BIG = 0x80100072; // ***************** // FACILITY_COMPLUS // ***************** // // == // Facility COMPLUS Error Messages // == // // // The following are the subranges within the COMPLUS facility // 0x400 - 0x4ff=COMADMIN_E_CAT // 0x600 - 0x6ff=COMQC errors // 0x700 - 0x7ff=MSDTC errors // 0x800 - 0x8ff=Other COMADMIN errors // // COMPLUS Admin errors // // // MessageId: COMADMIN_E_OBJECTERRORS // // MessageText: // // Errors occurred accessing one or more objects - the ErrorInfo collection // may have more detail // public static final int COMADMIN_E_OBJECTERRORS = 0x80110401; // // MessageId: COMADMIN_E_OBJECTINVALID // // MessageText: // // One or more of the object's properties are missing or invalid // public static final int COMADMIN_E_OBJECTINVALID = 0x80110402; // // MessageId: COMADMIN_E_KEYMISSING // // MessageText: // // The object was not found in the catalog // public static final int COMADMIN_E_KEYMISSING = 0x80110403; // // MessageId: COMADMIN_E_ALREADYINSTALLED // // MessageText: // // The object is already registered // public static final int COMADMIN_E_ALREADYINSTALLED = 0x80110404; // // MessageId: COMADMIN_E_APP_FILE_WRITEFAIL // // MessageText: // // Error occurred writing to the application file // public static final int COMADMIN_E_APP_FILE_WRITEFAIL = 0x80110407; // // MessageId: COMADMIN_E_APP_FILE_READFAIL // // MessageText: // // Error occurred reading the application file // public static final int COMADMIN_E_APP_FILE_READFAIL = 0x80110408; // // MessageId: COMADMIN_E_APP_FILE_VERSION // // MessageText: // // Invalid version number in application file // public static final int COMADMIN_E_APP_FILE_VERSION = 0x80110409; // // MessageId: COMADMIN_E_BADPATH // // MessageText: // // The file path is invalid // public static final int COMADMIN_E_BADPATH = 0x8011040A; // // MessageId: COMADMIN_E_APPLICATIONEXISTS // // MessageText: // // The application is already installed // public static final int COMADMIN_E_APPLICATIONEXISTS = 0x8011040B; // // MessageId: COMADMIN_E_ROLEEXISTS // // MessageText: // // The role already exists // public static final int COMADMIN_E_ROLEEXISTS = 0x8011040C; // // MessageId: COMADMIN_E_CANTCOPYFILE // // MessageText: // // An error occurred copying the file // public static final int COMADMIN_E_CANTCOPYFILE = 0x8011040D; // // MessageId: COMADMIN_E_NOUSER // // MessageText: // // One or more users are not valid // public static final int COMADMIN_E_NOUSER = 0x8011040F; // // MessageId: COMADMIN_E_INVALIDUSERIDS // // MessageText: // // One or more users in the application file are not valid // public static final int COMADMIN_E_INVALIDUSERIDS = 0x80110410; // // MessageId: COMADMIN_E_NOREGISTRYCLSID // // MessageText: // // The component's CLSID is missing or corrupt // public static final int COMADMIN_E_NOREGISTRYCLSID = 0x80110411; // // MessageId: COMADMIN_E_BADREGISTRYPROGID // // MessageText: // // The component's progID is missing or corrupt // public static final int COMADMIN_E_BADREGISTRYPROGID = 0x80110412; // // MessageId: COMADMIN_E_AUTHENTICATIONLEVEL // // MessageText: // // Unable to set required authentication level for update request // public static final int COMADMIN_E_AUTHENTICATIONLEVEL = 0x80110413; // // MessageId: COMADMIN_E_USERPASSWDNOTVALID // // MessageText: // // The identity or password set on the application is not valid // public static final int COMADMIN_E_USERPASSWDNOTVALID = 0x80110414; // // MessageId: COMADMIN_E_CLSIDORIIDMISMATCH // // MessageText: // // Application file CLSIDs or IIDs do not match corresponding DLLs // public static final int COMADMIN_E_CLSIDORIIDMISMATCH = 0x80110418; // // MessageId: COMADMIN_E_REMOTEINTERFACE // // MessageText: // // Interface information is either missing or changed // public static final int COMADMIN_E_REMOTEINTERFACE = 0x80110419; // // MessageId: COMADMIN_E_DLLREGISTERSERVER // // MessageText: // // DllRegisterServer failed on component install // public static final int COMADMIN_E_DLLREGISTERSERVER = 0x8011041A; // // MessageId: COMADMIN_E_NOSERVERSHARE // // MessageText: // // No server file share available // public static final int COMADMIN_E_NOSERVERSHARE = 0x8011041B; // // MessageId: COMADMIN_E_DLLLOADFAILED // // MessageText: // // DLL could not be loaded // public static final int COMADMIN_E_DLLLOADFAILED = 0x8011041D; // // MessageId: COMADMIN_E_BADREGISTRYLIBID // // MessageText: // // The registered TypeLib ID is not valid // public static final int COMADMIN_E_BADREGISTRYLIBID = 0x8011041E; // // MessageId: COMADMIN_E_APPDIRNOTFOUND // // MessageText: // // Application install directory not found // public static final int COMADMIN_E_APPDIRNOTFOUND = 0x8011041F; // // MessageId: COMADMIN_E_REGISTRARFAILED // // MessageText: // // Errors occurred while in the component registrar // public static final int COMADMIN_E_REGISTRARFAILED = 0x80110423; // // MessageId: COMADMIN_E_COMPFILE_DOESNOTEXIST // // MessageText: // // The file does not exist // public static final int COMADMIN_E_COMPFILE_DOESNOTEXIST = 0x80110424; // // MessageId: COMADMIN_E_COMPFILE_LOADDLLFAIL // // MessageText: // // The DLL could not be loaded // public static final int COMADMIN_E_COMPFILE_LOADDLLFAIL = 0x80110425; // // MessageId: COMADMIN_E_COMPFILE_GETCLASSOBJ // // MessageText: // // GetClassObject failed in the DLL // public static final int COMADMIN_E_COMPFILE_GETCLASSOBJ = 0x80110426; // // MessageId: COMADMIN_E_COMPFILE_CLASSNOTAVAIL // // MessageText: // // The DLL does not support the components listed in the TypeLib // public static final int COMADMIN_E_COMPFILE_CLASSNOTAVAIL = 0x80110427; // // MessageId: COMADMIN_E_COMPFILE_BADTLB // // MessageText: // // The TypeLib could not be loaded // public static final int COMADMIN_E_COMPFILE_BADTLB = 0x80110428; // // MessageId: COMADMIN_E_COMPFILE_NOTINSTALLABLE // // MessageText: // // The file does not contain components or component information // public static final int COMADMIN_E_COMPFILE_NOTINSTALLABLE = 0x80110429; // // MessageId: COMADMIN_E_NOTCHANGEABLE // // MessageText: // // Changes to this object and its sub-objects have been disabled // public static final int COMADMIN_E_NOTCHANGEABLE = 0x8011042A; // // MessageId: COMADMIN_E_NOTDELETEABLE // // MessageText: // // The delete function has been disabled for this object // public static final int COMADMIN_E_NOTDELETEABLE = 0x8011042B; // // MessageId: COMADMIN_E_SESSION // // MessageText: // // The server catalog version is not supported // public static final int COMADMIN_E_SESSION = 0x8011042C; // // MessageId: COMADMIN_E_COMP_MOVE_LOCKED // // MessageText: // // The component move was disallowed, because the source or destination // application is either a system application or currently locked against // changes // public static final int COMADMIN_E_COMP_MOVE_LOCKED = 0x8011042D; // // MessageId: COMADMIN_E_COMP_MOVE_BAD_DEST // // MessageText: // // The component move failed because the destination application no longer // exists // public static final int COMADMIN_E_COMP_MOVE_BAD_DEST = 0x8011042E; // // MessageId: COMADMIN_E_REGISTERTLB // // MessageText: // // The system was unable to register the TypeLib // public static final int COMADMIN_E_REGISTERTLB = 0x80110430; // // MessageId: COMADMIN_E_SYSTEMAPP // // MessageText: // // This operation cannot be performed on the system application // public static final int COMADMIN_E_SYSTEMAPP = 0x80110433; // // MessageId: COMADMIN_E_COMPFILE_NOREGISTRAR // // MessageText: // // The component registrar referenced in this file is not available // public static final int COMADMIN_E_COMPFILE_NOREGISTRAR = 0x80110434; // // MessageId: COMADMIN_E_COREQCOMPINSTALLED // // MessageText: // // A component in the same DLL is already installed // public static final int COMADMIN_E_COREQCOMPINSTALLED = 0x80110435; // // MessageId: COMADMIN_E_SERVICENOTINSTALLED // // MessageText: // // The service is not installed // public static final int COMADMIN_E_SERVICENOTINSTALLED = 0x80110436; // // MessageId: COMADMIN_E_PROPERTYSAVEFAILED // // MessageText: // // One or more property settings are either invalid or in conF;ict with each // other // public static final int COMADMIN_E_PROPERTYSAVEFAILED = 0x80110437; // // MessageId: COMADMIN_E_OBJECTEXISTS // // MessageText: // // The object you are attempting to add or rename already exists // public static final int COMADMIN_E_OBJECTEXISTS = 0x80110438; // // MessageId: COMADMIN_E_COMPONENTEXISTS // // MessageText: // // The component already exists // public static final int COMADMIN_E_COMPONENTEXISTS = 0x80110439; // // MessageId: COMADMIN_E_REGFILE_CORRUPT // // MessageText: // // The registration file is corrupt // public static final int COMADMIN_E_REGFILE_CORRUPT = 0x8011043B; // // MessageId: COMADMIN_E_PROPERTY_OVERF;OW // // MessageText: // // The property value is too large // public static final int COMADMIN_E_PROPERTY_OVERFLOW = 0x8011043C; // // MessageId: COMADMIN_E_NOTINREGISTRY // // MessageText: // // Object was not found in registry // public static final int COMADMIN_E_NOTINREGISTRY = 0x8011043E; // // MessageId: COMADMIN_E_OBJECTNOTPOOLABLE // // MessageText: // // This object is not poolable // public static final int COMADMIN_E_OBJECTNOTPOOLABLE = 0x8011043F; // // MessageId: COMADMIN_E_APPLID_MATCHES_CLSID // // MessageText: // // A CLSID with the same GUID as the new application ID is already installed // on this machine // public static final int COMADMIN_E_APPLID_MATCHES_CLSID = 0x80110446; // // MessageId: COMADMIN_E_ROLE_DOES_NOT_EXIST // // MessageText: // // A role assigned to a component, interface, or method did not exist in the // application // public static final int COMADMIN_E_ROLE_DOES_NOT_EXIST = 0x80110447; // // MessageId: COMADMIN_E_START_APP_NEEDS_COMPONENTS // // MessageText: // // You must have components in an application in order to start the // application // public static final int COMADMIN_E_START_APP_NEEDS_COMPONENTS = 0x80110448; // // MessageId: COMADMIN_E_REQUIRES_DIFFERENT_PLATFORM // // MessageText: // // This operation is not enabled on this platform // public static final int COMADMIN_E_REQUIRES_DIFFERENT_PLATFORM = 0x80110449; // // MessageId: COMADMIN_E_CAN_NOT_EXPORT_APP_PROXY // // MessageText: // // Application Proxy is not exportable // public static final int COMADMIN_E_CAN_NOT_EXPORT_APP_PROXY = 0x8011044A; // // MessageId: COMADMIN_E_CAN_NOT_START_APP // // MessageText: // // Failed to start application because it is either a library application or // an application proxy // public static final int COMADMIN_E_CAN_NOT_START_APP = 0x8011044B; // // MessageId: COMADMIN_E_CAN_NOT_EXPORT_SYS_APP // // MessageText: // // System application is not exportable // public static final int COMADMIN_E_CAN_NOT_EXPORT_SYS_APP = 0x8011044C; // // MessageId: COMADMIN_E_CANT_SUBSCRIBE_TO_COMPONENT // // MessageText: // // Cannot subscribe to this component (the component may have been imported) // public static final int COMADMIN_E_CANT_SUBSCRIBE_TO_COMPONENT = 0x8011044D; // // MessageId: COMADMIN_E_EVENTCLASS_CANT_BE_SUBSCRIBER // // MessageText: // // An event class cannot also be a subscriber component // public static final int COMADMIN_E_EVENTCLASS_CANT_BE_SUBSCRIBER = 0x8011044E; // // MessageId: COMADMIN_E_LIB_APP_PROXY_INCOMPATIBLE // // MessageText: // // Library applications and application proxies are incompatible // public static final int COMADMIN_E_LIB_APP_PROXY_INCOMPATIBLE = 0x8011044F; // // MessageId: COMADMIN_E_BASE_PARTITION_ONLY // // MessageText: // // This function is valid for the base partition only // public static final int COMADMIN_E_BASE_PARTITION_ONLY = 0x80110450; // // MessageId: COMADMIN_E_START_APP_DISABLED // // MessageText: // // You cannot start an application that has been disabled // public static final int COMADMIN_E_START_APP_DISABLED = 0x80110451; // // MessageId: COMADMIN_E_CAT_DUPLICATE_PARTITION_NAME // // MessageText: // // The specified partition name is already in use on this computer // public static final int COMADMIN_E_CAT_DUPLICATE_PARTITION_NAME = 0x80110457; // // MessageId: COMADMIN_E_CAT_INVALID_PARTITION_NAME // // MessageText: // // The specified partition name is invalid. Check that the name contains at // least one visible character // public static final int COMADMIN_E_CAT_INVALID_PARTITION_NAME = 0x80110458; // // MessageId: COMADMIN_E_CAT_PARTITION_IN_USE // // MessageText: // // The partition cannot be deleted because it is the default partition for // one or more users // public static final int COMADMIN_E_CAT_PARTITION_IN_USE = 0x80110459; // // MessageId: COMADMIN_E_FILE_PARTITION_DUPLICATE_FILES // // MessageText: // // The partition cannot be exported, because one or more components in the // partition have the same file name // public static final int COMADMIN_E_FILE_PARTITION_DUPLICATE_FILES = 0x8011045A; // // MessageId: COMADMIN_E_CAT_IMPORTED_COMPONENTS_NOT_ALLOWED // // MessageText: // // Applications that contain one or more imported components cannot be // installed into a non-base partition // public static final int COMADMIN_E_CAT_IMPORTED_COMPONENTS_NOT_ALLOWED = 0x8011045B; // // MessageId: COMADMIN_E_AMBIGUOUS_APPLICATION_NAME // // MessageText: // // The application name is not unique and cannot be resolved to an // application id // public static final int COMADMIN_E_AMBIGUOUS_APPLICATION_NAME = 0x8011045C; // // MessageId: COMADMIN_E_AMBIGUOUS_PARTITION_NAME // // MessageText: // // The partition name is not unique and cannot be resolved to a partition id // public static final int COMADMIN_E_AMBIGUOUS_PARTITION_NAME = 0x8011045D; // // MessageId: COMADMIN_E_REGDB_NOTINITIALIZED // // MessageText: // // The COM+ registry database has not been initialized // public static final int COMADMIN_E_REGDB_NOTINITIALIZED = 0x80110472; // // MessageId: COMADMIN_E_REGDB_NOTOPEN // // MessageText: // // The COM+ registry database is not open // public static final int COMADMIN_E_REGDB_NOTOPEN = 0x80110473; // // MessageId: COMADMIN_E_REGDB_SYSTEMERR // // MessageText: // // The COM+ registry database detected a system error // public static final int COMADMIN_E_REGDB_SYSTEMERR = 0x80110474; // // MessageId: COMADMIN_E_REGDB_ALREADYRUNNING // // MessageText: // // The COM+ registry database is already running // public static final int COMADMIN_E_REGDB_ALREADYRUNNING = 0x80110475; // // MessageId: COMADMIN_E_MIG_VERSIONNOTSUPPORTED // // MessageText: // // This version of the COM+ registry database cannot be migrated // public static final int COMADMIN_E_MIG_VERSIONNOTSUPPORTED = 0x80110480; // // MessageId: COMADMIN_E_MIG_SCHEMANOTFOUND // // MessageText: // // The schema version to be migrated could not be found in the COM+ registry // database // public static final int COMADMIN_E_MIG_SCHEMANOTFOUND = 0x80110481; // // MessageId: COMADMIN_E_CAT_BITNESSMISMATCH // // MessageText: // // There was a type mismatch between binaries // public static final int COMADMIN_E_CAT_BITNESSMISMATCH = 0x80110482; // // MessageId: COMADMIN_E_CAT_UNACCEPTABLEBITNESS // // MessageText: // // A binary of unknown or invalid type was provided // public static final int COMADMIN_E_CAT_UNACCEPTABLEBITNESS = 0x80110483; // // MessageId: COMADMIN_E_CAT_WRONGAPPBITNESS // // MessageText: // // There was a type mismatch between a binary and an application // public static final int COMADMIN_E_CAT_WRONGAPPBITNESS = 0x80110484; // // MessageId: COMADMIN_E_CAT_PAUSE_RESUME_NOT_SUPPORTED // // MessageText: // // The application cannot be paused or resumed // public static final int COMADMIN_E_CAT_PAUSE_RESUME_NOT_SUPPORTED = 0x80110485; // // MessageId: COMADMIN_E_CAT_SERVERFAULT // // MessageText: // // The COM+ Catalog Server threw an exception during execution // public static final int COMADMIN_E_CAT_SERVERFAULT = 0x80110486; // // COMPLUS Queued component errors // // // MessageId: COMQC_E_APPLICATION_NOT_QUEUED // // MessageText: // // Only COM+ Applications marked "queued" can be invoked using the "queue" // moniker // public static final int COMQC_E_APPLICATION_NOT_QUEUED = 0x80110600; // // MessageId: COMQC_E_NO_QUEUEABLE_INTERFACES // // MessageText: // // At least one interface must be marked "queued" in order to create a // queued component instance with the "queue" moniker // public static final int COMQC_E_NO_QUEUEABLE_INTERFACES = 0x80110601; // // MessageId: COMQC_E_QUEUING_SERVICE_NOT_AVAILABLE // // MessageText: // // MSMQ is required for the requested operation and is not installed // public static final int COMQC_E_QUEUING_SERVICE_NOT_AVAILABLE = 0x80110602; // // MessageId: COMQC_E_NO_IPERSISTSTREAM // // MessageText: // // Unable to marshal an interface that does not support IPersistStream // public static final int COMQC_E_NO_IPERSISTSTREAM = 0x80110603; // // MessageId: COMQC_E_BAD_MESSAGE // // MessageText: // // The message is improperly formatted or was damaged in transit // public static final int COMQC_E_BAD_MESSAGE = 0x80110604; // // MessageId: COMQC_E_UNAUTHENTICATED // // MessageText: // // An unauthenticated message was received by an application that accepts // only authenticated messages // public static final int COMQC_E_UNAUTHENTICATED = 0x80110605; // // MessageId: COMQC_E_UNTRUSTED_ENQUEUER // // MessageText: // // The message was requeued or moved by a user not in the "QC Trusted User" // role // public static final int COMQC_E_UNTRUSTED_ENQUEUER = 0x80110606; // // The range 0x700-0x7ff is reserved for MSDTC errors. // // // MessageId: MSDTC_E_DUPLICATE_RESOURCE // // MessageText: // // Cannot create a duplicate resource of type Distributed Transaction // Coordinator // public static final int MSDTC_E_DUPLICATE_RESOURCE = 0x80110701; // // More COMADMIN errors from 0x8** // // // MessageId: COMADMIN_E_OBJECT_PARENT_MISSING // // MessageText: // // One of the objects being inserted or updated does not belong to a valid // parent collection // public static final int COMADMIN_E_OBJECT_PARENT_MISSING = 0x80110808; // // MessageId: COMADMIN_E_OBJECT_DOES_NOT_EXIST // // MessageText: // // One of the specified objects cannot be found // public static final int COMADMIN_E_OBJECT_DOES_NOT_EXIST = 0x80110809; // // MessageId: COMADMIN_E_APP_NOT_RUNNING // // MessageText: // // The specified application is not currently running // public static final int COMADMIN_E_APP_NOT_RUNNING = 0x8011080A; // // MessageId: COMADMIN_E_INVALID_PARTITION // // MessageText: // // The partition(s) specified are not valid. // public static final int COMADMIN_E_INVALID_PARTITION = 0x8011080B; // // MessageId: COMADMIN_E_SVCAPP_NOT_POOLABLE_OR_RECYCLABLE // // MessageText: // // COM+ applications that run as NT service may not be pooled or recycled // public static final int COMADMIN_E_SVCAPP_NOT_POOLABLE_OR_RECYCLABLE = 0x8011080D; // // MessageId: COMADMIN_E_USER_IN_SET // // MessageText: // // One or more users are already assigned to a local partition set. // public static final int COMADMIN_E_USER_IN_SET = 0x8011080E; // // MessageId: COMADMIN_E_CANTRECYCLELIBRARYAPPS // // MessageText: // // Library applications may not be recycled. // public static final int COMADMIN_E_CANTRECYCLELIBRARYAPPS = 0x8011080F; // // MessageId: COMADMIN_E_CANTRECYCLESERVICEAPPS // // MessageText: // // Applications running as NT services may not be recycled. // public static final int COMADMIN_E_CANTRECYCLESERVICEAPPS = 0x80110811; // // MessageId: COMADMIN_E_PROCESSALREADYRECYCLED // // MessageText: // // The process has already been recycled. // public static final int COMADMIN_E_PROCESSALREADYRECYCLED = 0x80110812; // // MessageId: COMADMIN_E_PAUSEDPROCESSMAYNOTBERECYCLED // // MessageText: // // A paused process may not be recycled. // public static final int COMADMIN_E_PAUSEDPROCESSMAYNOTBERECYCLED = 0x80110813; // // MessageId: COMADMIN_E_CANTMAKEINPROCSERVICE // // MessageText: // // Library applications may not be NT services. // public static final int COMADMIN_E_CANTMAKEINPROCSERVICE = 0x80110814; // // MessageId: COMADMIN_E_PROGIDINUSEBYCLSID // // MessageText: // // The ProgID provided to the copy operation is invalid. The ProgID is in // use by another registered CLSID. // public static final int COMADMIN_E_PROGIDINUSEBYCLSID = 0x80110815; // // MessageId: COMADMIN_E_DEFAULT_PARTITION_NOT_IN_SET // // MessageText: // // The partition specified as default is not a member of the partition set. // public static final int COMADMIN_E_DEFAULT_PARTITION_NOT_IN_SET = 0x80110816; // // MessageId: COMADMIN_E_RECYCLEDPROCESSMAYNOTBEPAUSED // // MessageText: // // A recycled process may not be paused. // public static final int COMADMIN_E_RECYCLEDPROCESSMAYNOTBEPAUSED = 0x80110817; // // MessageId: COMADMIN_E_PARTITION_ACCESSDENIED // // MessageText: // // Access to the specified partition is denied. // public static final int COMADMIN_E_PARTITION_ACCESSDENIED = 0x80110818; // // MessageId: COMADMIN_E_PARTITION_MSI_ONLY // // MessageText: // // Only Application Files (*.MSI files) can be installed into partitions. // public static final int COMADMIN_E_PARTITION_MSI_ONLY = 0x80110819; // // MessageId: COMADMIN_E_LEGACYCOMPS_NOT_ALLOWED_IN_1_0_FORMAT // // MessageText: // // Applications containing one or more legacy components may not be exported // to=1.0 format. // public static final int COMADMIN_E_LEGACYCOMPS_NOT_ALLOWED_IN_1_0_FORMAT = 0x8011081A; // // MessageId: COMADMIN_E_LEGACYCOMPS_NOT_ALLOWED_IN_NONBASE_PARTITIONS // // MessageText: // // Legacy components may not exist in non-base partitions. // public static final int COMADMIN_E_LEGACYCOMPS_NOT_ALLOWED_IN_NONBASE_PARTITIONS = 0x8011081B; // // MessageId: COMADMIN_E_COMP_MOVE_SOURCE // // MessageText: // // A component cannot be moved (or copied) from the System Application, an // application proxy or a non-changeable application // public static final int COMADMIN_E_COMP_MOVE_SOURCE = 0x8011081C; // // MessageId: COMADMIN_E_COMP_MOVE_DEST // // MessageText: // // A component cannot be moved (or copied) to the System Application, an // application proxy or a non-changeable application // public static final int COMADMIN_E_COMP_MOVE_DEST = 0x8011081D; // // MessageId: COMADMIN_E_COMP_MOVE_PRIVATE // // MessageText: // // A private component cannot be moved (or copied) to a library application // or to the base partition // public static final int COMADMIN_E_COMP_MOVE_PRIVATE = 0x8011081E; // // MessageId: COMADMIN_E_BASEPARTITION_REQUIRED_IN_SET // // MessageText: // // The Base Application Partition exists in all partition sets and cannot be // removed. // public static final int COMADMIN_E_BASEPARTITION_REQUIRED_IN_SET = 0x8011081F; // // MessageId: COMADMIN_E_CANNOT_ALIAS_EVENTCLASS // // MessageText: // // Alas, Event Class components cannot be aliased. // public static final int COMADMIN_E_CANNOT_ALIAS_EVENTCLASS = 0x80110820; // // MessageId: COMADMIN_E_PRIVATE_ACCESSDENIED // // MessageText: // // Access is denied because the component is private. // public static final int COMADMIN_E_PRIVATE_ACCESSDENIED = 0x80110821; // // MessageId: COMADMIN_E_SAFERINVALID // // MessageText: // // The specified SAFER level is invalid. // public static final int COMADMIN_E_SAFERINVALID = 0x80110822; // // MessageId: COMADMIN_E_REGISTRY_ACCESSDENIED // // MessageText: // // The specified user cannot write to the system registry // public static final int COMADMIN_E_REGISTRY_ACCESSDENIED = 0x80110823; // // MessageId: COMADMIN_E_PARTITIONS_DISABLED // // MessageText: // // COM+ partitions are currently disabled. // public static final int COMADMIN_E_PARTITIONS_DISABLED = 0x80110824; // *********************** // FACILITY_USERMODE_FILTER_MANAGER // *********************** // // Translation macro for converting: // NTSTATUS --> HRESULT // public static final int FILTER_HRESULT_FROM_FLT_NTSTATUS(int x) { int f = FACILITY_USERMODE_FILTER_MANAGER; return (((x) & 0x8000FFFF) | (f <<= 16)); } // // MessageId: ERROR_FLT_IO_COMPLETE // // MessageText: // // The IO was completed by a filter. // public static final int ERROR_FLT_IO_COMPLETE = 0x001F0001; // // MessageId: ERROR_FLT_NO_HANDLER_DEFINED // // MessageText: // // A handler was not defined by the filter for this operation. // public static final int ERROR_FLT_NO_HANDLER_DEFINED = 0x801F0001; // // MessageId: ERROR_FLT_CONTEXT_ALREADY_DEFINED // // MessageText: // // A context is already defined for this object. // public static final int ERROR_FLT_CONTEXT_ALREADY_DEFINED = 0x801F0002; // // MessageId: ERROR_FLT_INVALID_ASYNCHRONOUS_REQUEST // // MessageText: // // Asynchronous requests are not valid for this operation. // public static final int ERROR_FLT_INVALID_ASYNCHRONOUS_REQUEST = 0x801F0003; // // MessageId: ERROR_FLT_DISALLOW_FAST_IO // // MessageText: // // Disallow the Fast IO path for this operation. // public static final int ERROR_FLT_DISALLOW_FAST_IO = 0x801F0004; // // MessageId: ERROR_FLT_INVALID_NAME_REQUEST // // MessageText: // // An invalid name request was made. The name requested cannot be retrieved // at this time. // public static final int ERROR_FLT_INVALID_NAME_REQUEST = 0x801F0005; // // MessageId: ERROR_FLT_NOT_SAFE_TO_POST_OPERATION // // MessageText: // // Posting this operation to a worker thread for further processing is not // safe at this time because it could lead to a system deadlock. // public static final int ERROR_FLT_NOT_SAFE_TO_POST_OPERATION = 0x801F0006; // // MessageId: ERROR_FLT_NOT_INITIALIZED // // MessageText: // // The Filter Manager was not initialized when a filter tried to register. // Make sure that the Filter Manager is getting loaded as a driver. // public static final int ERROR_FLT_NOT_INITIALIZED = 0x801F0007; // // MessageId: ERROR_FLT_FILTER_NOT_READY // // MessageText: // // The filter is not ready for attachment to volumes because it has not // finished initializing (FLTStartFiltering has not been called). // public static final int ERROR_FLT_FILTER_NOT_READY = 0x801F0008; // // MessageId: ERROR_FLT_POST_OPERATION_CLEANUP // // MessageText: // // The filter must cleanup any operation specific context at this time // because it is being removed from the system before the operation is // completed by the lower drivers. // public static final int ERROR_FLT_POST_OPERATION_CLEANUP = 0x801F0009; // // MessageId: ERROR_FLT_INTERNAL_ERROR // // MessageText: // // The Filter Manager had an internal error from which it cannot recover, // therefore the operation has been failed. This is usually the result of a // filter returning an invalid value from a pre-operation callback. // public static final int ERROR_FLT_INTERNAL_ERROR = 0x801F000A; // // MessageId: ERROR_FLT_DELETING_OBJECT // // MessageText: // // The object specified for this action is in the process of being deleted, // therefore the action requested cannot be completed at this time. // public static final int ERROR_FLT_DELETING_OBJECT = 0x801F000B; // // MessageId: ERROR_FLT_MUST_BE_NONPAGED_POOL // // MessageText: // // Non-paged pool must be used for this type of context. // public static final int ERROR_FLT_MUST_BE_NONPAGED_POOL = 0x801F000C; // // MessageId: ERROR_FLT_DUPLICATE_ENTRY // // MessageText: // // A duplicate handler definition has been provided for an operation. // public static final int ERROR_FLT_DUPLICATE_ENTRY = 0x801F000D; // // MessageId: ERROR_FLT_CBDQ_DISABLED // // MessageText: // // The callback data queue has been disabled. // public static final int ERROR_FLT_CBDQ_DISABLED = 0x801F000E; // // MessageId: ERROR_FLT_DO_NOT_ATTACH // // MessageText: // // Do not attach the filter to the volume at this time. // public static final int ERROR_FLT_DO_NOT_ATTACH = 0x801F000F; // // MessageId: ERROR_FLT_DO_NOT_DETACH // // MessageText: // // Do not detach the filter from the volume at this time. // public static final int ERROR_FLT_DO_NOT_DETACH = 0x801F0010; // // MessageId: ERROR_FLT_INSTANCE_ALTITUDE_COLLISION // // MessageText: // // An instance already exists at this altitude on the volume specified. // public static final int ERROR_FLT_INSTANCE_ALTITUDE_COLLISION = 0x801F0011; // // MessageId: ERROR_FLT_INSTANCE_NAME_COLLISION // // MessageText: // // An instance already exists with this name on the volume specified. // public static final int ERROR_FLT_INSTANCE_NAME_COLLISION = 0x801F0012; // // MessageId: ERROR_FLT_FILTER_NOT_FOUND // // MessageText: // // The system could not find the filter specified. // public static final int ERROR_FLT_FILTER_NOT_FOUND = 0x801F0013; // // MessageId: ERROR_FLT_VOLUME_NOT_FOUND // // MessageText: // // The system could not find the volume specified. // public static final int ERROR_FLT_VOLUME_NOT_FOUND = 0x801F0014; // // MessageId: ERROR_FLT_INSTANCE_NOT_FOUND // // MessageText: // // The system could not find the instance specified. // public static final int ERROR_FLT_INSTANCE_NOT_FOUND = 0x801F0015; // // MessageId: ERROR_FLT_CONTEXT_ALLOCATION_NOT_FOUND // // MessageText: // // No registered context allocation definition was found for the given // request. // public static final int ERROR_FLT_CONTEXT_ALLOCATION_NOT_FOUND = 0x801F0016; // // MessageId: ERROR_FLT_INVALID_CONTEXT_REGISTRATION // // MessageText: // // An invalid parameter was specified during context registration. // public static final int ERROR_FLT_INVALID_CONTEXT_REGISTRATION = 0x801F0017; // // MessageId: ERROR_FLT_NAME_CACHE_MISS // // MessageText: // // The name requested was not found in Filter Manager's name cache and could // not be retrieved from the file system. // public static final int ERROR_FLT_NAME_CACHE_MISS = 0x801F0018; // // MessageId: ERROR_FLT_NO_DEVICE_OBJECT // // MessageText: // // The requested device object does not exist for the given volume. // public static final int ERROR_FLT_NO_DEVICE_OBJECT = 0x801F0019; // // MessageId: ERROR_FLT_VOLUME_ALREADY_MOUNTED // // MessageText: // // The specified volume is already mounted. // public static final int ERROR_FLT_VOLUME_ALREADY_MOUNTED = 0x801F001A; // // MessageId: ERROR_FLT_ALREADY_ENLISTED // // MessageText: // // The specified Transaction Context is already enlisted in a transaction // public static final int ERROR_FLT_ALREADY_ENLISTED = 0x801F001B; // // MessageId: ERROR_FLT_CONTEXT_ALREADY_LINKED // // MessageText: // // The specifiec context is already attached to another object // public static final int ERROR_FLT_CONTEXT_ALREADY_LINKED = 0x801F001C; // // MessageId: ERROR_FLT_NO_WAITER_FOR_REPLY // // MessageText: // // No waiter is present for the filter's reply to this message. // public static final int ERROR_FLT_NO_WAITER_FOR_REPLY = 0x801F0020; // // == // Facility Graphics Error Messages // == // // // The following are the subranges within the Graphics facility // // 0x0000 - 0x0fff Display Driver Loader driver & Video Port errors // (displdr.sys, videoprt.sys) // 0x1000 - 0x1fff Monitor Class Function driver errors=(monitor.sys) // 0x2000 - 0x2fff Windows Graphics Kernel Subsystem errors=(dxgkrnl.sys) // 0x3000 - 0x3fff=Desktop Window Manager errors // 0x2000 - 0x20ff Common errors // 0x2100 - 0x21ff Video Memory Manager (VidMM) subsystem errors // 0x2200 - 0x22ff Video GPU Scheduler (VidSch) subsystem errors // 0x2300 - 0x23ff Video Display Mode Management (VidDMM) subsystem errors // // Display Driver Loader driver & Video Port errors {0x0000..0x0fff} // // // MessageId: ERROR_HUNG_DISPLAY_DRIVER_THREAD // // MessageText: // // {Display Driver Stopped Responding} // The %hs display driver has stopped working normally. Save your work and // reboot the system to restore full display functionality. // The next time you reboot the machine a dialog will be displayed giving // you a chance to report this failure to Microsoft. // public static final int ERROR_HUNG_DISPLAY_DRIVER_THREAD = 0x80260001; // // Desktop Window Manager errors {0x3000..0x3fff} // // // MessageId: DWM_E_COMPOSITIONDISABLED // // MessageText: // // {Desktop composition is disabled} // The operation could not be completed because desktop composition is // disabled. // public static final int DWM_E_COMPOSITIONDISABLED = 0x80263001; // // MessageId: DWM_E_REMOTING_NOT_SUPPORTED // // MessageText: // // {Some desktop composition APIs are not supported while remoting} // The operation is not supported while running in a remote session. // public static final int DWM_E_REMOTING_NOT_SUPPORTED = 0x80263002; // // MessageId: DWM_E_NO_REDIRECTION_SURFACE_AVAILABLE // // MessageText: // // {No DWM redirection surface is available} // The DWM was unable to provide a redireciton surface to complete the // DirectX present. // public static final int DWM_E_NO_REDIRECTION_SURFACE_AVAILABLE = 0x80263003; // // MessageId: DWM_E_NOT_QUEUING_PRESENTS // // MessageText: // // {DWM is not queuing presents for the specified window} // The window specified is not currently using queued presents. // public static final int DWM_E_NOT_QUEUING_PRESENTS = 0x80263004; // // Monitor class function driver errors {0x1000..0x1fff} // // // MessageId: ERROR_MONITOR_NO_DESCRIPTOR // // MessageText: // // Monitor descriptor could not be obtained. // public static final int ERROR_MONITOR_NO_DESCRIPTOR = 0x80261001; // // MessageId: ERROR_MONITOR_UNKNOWN_DESCRIPTOR_FORMAT // // MessageText: // // Format of the obtained monitor descriptor is not supported by this // release. // public static final int ERROR_MONITOR_UNKNOWN_DESCRIPTOR_FORMAT = 0x80261002; // // MessageId: ERROR_MONITOR_INVALID_DESCRIPTOR_CHECKSUM // // MessageText: // // Checksum of the obtained monitor descriptor is invalid. // public static final int ERROR_MONITOR_INVALID_DESCRIPTOR_CHECKSUM = 0xC0261003; // // MessageId: ERROR_MONITOR_INVALID_STANDARD_TIMING_BLOCK // // MessageText: // // Monitor descriptor contains an invalid standard timing block. // public static final int ERROR_MONITOR_INVALID_STANDARD_TIMING_BLOCK = 0xC0261004; // // MessageId: ERROR_MONITOR_WMI_DATABLOCK_REGISTRATION_FAILED // // MessageText: // // WMI data block registration failed for one of the MSMonitorClass WMI // subclasses. // public static final int ERROR_MONITOR_WMI_DATABLOCK_REGISTRATION_FAILED = 0xC0261005; // // MessageId: ERROR_MONITOR_INVALID_SERIAL_NUMBER_MONDSC_BLOCK // // MessageText: // // Provided monitor descriptor block is either corrupted or does not contain // monitor's detailed serial number. // public static final int ERROR_MONITOR_INVALID_SERIAL_NUMBER_MONDSC_BLOCK = 0xC0261006; // // MessageId: ERROR_MONITOR_INVALID_USER_FRIENDLY_MONDSC_BLOCK // // MessageText: // // Provided monitor descriptor block is either corrupted or does not contain // monitor's user friendly name. // public static final int ERROR_MONITOR_INVALID_USER_FRIENDLY_MONDSC_BLOCK = 0xC0261007; // // MessageId: ERROR_MONITOR_NO_MORE_DESCRIPTOR_DATA // // MessageText: // // There is no monitor descriptor data at the specified (offset, size) // region. // public static final int ERROR_MONITOR_NO_MORE_DESCRIPTOR_DATA = 0xC0261008; // // MessageId: ERROR_MONITOR_INVALID_DETAILED_TIMING_BLOCK // // MessageText: // // Monitor descriptor contains an invalid detailed timing block. // public static final int ERROR_MONITOR_INVALID_DETAILED_TIMING_BLOCK = 0xC0261009; // // Windows Graphics Kernel Subsystem errors {0x2000..0x2fff} // // TODO: Add DXG Win32 errors here // // Common errors {0x2000..0x20ff} // // // MessageId: ERROR_GRAPHICS_NOT_EXCLUSIVE_MODE_OWNER // // MessageText: // // Exclusive mode ownership is needed to create unmanaged primary // allocation. // public static final int ERROR_GRAPHICS_NOT_EXCLUSIVE_MODE_OWNER = 0xC0262000; // // MessageId: ERROR_GRAPHICS_INSUFFICIENT_DMA_BUFFER // // MessageText: // // The driver needs more DMA buffer space in order to complete the requested // operation. // public static final int ERROR_GRAPHICS_INSUFFICIENT_DMA_BUFFER = 0xC0262001; // // MessageId: ERROR_GRAPHICS_INVALID_DISPLAY_ADAPTER // // MessageText: // // Specified display adapter handle is invalid. // public static final int ERROR_GRAPHICS_INVALID_DISPLAY_ADAPTER = 0xC0262002; // // MessageId: ERROR_GRAPHICS_ADAPTER_WAS_RESET // // MessageText: // // Specified display adapter and all of its state has been reset. // public static final int ERROR_GRAPHICS_ADAPTER_WAS_RESET = 0xC0262003; // // MessageId: ERROR_GRAPHICS_INVALID_DRIVER_MODEL // // MessageText: // // The driver stack doesn't match the expected driver model. // public static final int ERROR_GRAPHICS_INVALID_DRIVER_MODEL = 0xC0262004; // // MessageId: ERROR_GRAPHICS_PRESENT_MODE_CHANGED // // MessageText: // // Present happened but ended up into the changed desktop mode // public static final int ERROR_GRAPHICS_PRESENT_MODE_CHANGED = 0xC0262005; // // MessageId: ERROR_GRAPHICS_PRESENT_OCCLUDED // // MessageText: // // Nothing to present due to desktop occlusion // public static final int ERROR_GRAPHICS_PRESENT_OCCLUDED = 0xC0262006; // // MessageId: ERROR_GRAPHICS_PRESENT_DENIED // // MessageText: // // Not able to present due to denial of desktop access // public static final int ERROR_GRAPHICS_PRESENT_DENIED = 0xC0262007; // // MessageId: ERROR_GRAPHICS_CANNOTCOLORCONVERT // // MessageText: // // Not able to present with color convertion // public static final int ERROR_GRAPHICS_CANNOTCOLORCONVERT = 0xC0262008; // // MessageId: ERROR_GRAPHICS_DRIVER_MISMATCH // // MessageText: // // The kernel driver detected a version mismatch between it and the user // mode driver. // public static final int ERROR_GRAPHICS_DRIVER_MISMATCH = 0xC0262009; // // MessageId: ERROR_GRAPHICS_PARTIAL_DATA_POPULATED // // MessageText: // // Specified buffer is not big enough to contain entire requested dataset. // Partial data populated upto the size of the buffer. // Caller needs to provide buffer of size as specified in the partially // populated buffer's content (interface specific). // public static final int ERROR_GRAPHICS_PARTIAL_DATA_POPULATED = 0x4026200A; // // Video Memory Manager (VidMM) subsystem errors {0x2100..0x21ff} // // // MessageId: ERROR_GRAPHICS_NO_VIDEO_MEMORY // // MessageText: // // Not enough video memory available to complete the operation. // public static final int ERROR_GRAPHICS_NO_VIDEO_MEMORY = 0xC0262100; // // MessageId: ERROR_GRAPHICS_CANT_LOCK_MEMORY // // MessageText: // // Couldn't probe and lock the underlying memory of an allocation. // public static final int ERROR_GRAPHICS_CANT_LOCK_MEMORY = 0xC0262101; // // MessageId: ERROR_GRAPHICS_ALLOCATION_BUSY // // MessageText: // // The allocation is currently busy. // public static final int ERROR_GRAPHICS_ALLOCATION_BUSY = 0xC0262102; // // MessageId: ERROR_GRAPHICS_TOO_MANY_REFERENCES // // MessageText: // // An object being referenced has reach the maximum reference count already // and can't be reference further. // public static final int ERROR_GRAPHICS_TOO_MANY_REFERENCES = 0xC0262103; // // MessageId: ERROR_GRAPHICS_TRY_AGAIN_LATER // // MessageText: // // A problem couldn't be solved due to some currently existing condition. // The problem should be tried again later. // public static final int ERROR_GRAPHICS_TRY_AGAIN_LATER = 0xC0262104; // // MessageId: ERROR_GRAPHICS_TRY_AGAIN_NOW // // MessageText: // // A problem couldn't be solved due to some currently existing condition. // The problem should be tried again immediately. // public static final int ERROR_GRAPHICS_TRY_AGAIN_NOW = 0xC0262105; // // MessageId: ERROR_GRAPHICS_ALLOCATION_INVALID // // MessageText: // // The allocation is invalid. // public static final int ERROR_GRAPHICS_ALLOCATION_INVALID = 0xC0262106; // // MessageId: ERROR_GRAPHICS_UNSWIZZLING_APERTURE_UNAVAILABLE // // MessageText: // // No more unswizzling aperture are currently available. // public static final int ERROR_GRAPHICS_UNSWIZZLING_APERTURE_UNAVAILABLE = 0xC0262107; // // MessageId: ERROR_GRAPHICS_UNSWIZZLING_APERTURE_UNSUPPORTED // // MessageText: // // The current allocation can't be unswizzled by an aperture. // public static final int ERROR_GRAPHICS_UNSWIZZLING_APERTURE_UNSUPPORTED = 0xC0262108; // // MessageId: ERROR_GRAPHICS_CANT_EVICT_PINNED_ALLOCATION // // MessageText: // // The request failed because a pinned allocation can't be evicted. // public static final int ERROR_GRAPHICS_CANT_EVICT_PINNED_ALLOCATION = 0xC0262109; // // MessageId: ERROR_GRAPHICS_INVALID_ALLOCATION_USAGE // // MessageText: // // The allocation can't be used from it's current segment location for the // specified operation. // public static final int ERROR_GRAPHICS_INVALID_ALLOCATION_USAGE = 0xC0262110; // // MessageId: ERROR_GRAPHICS_CANT_RENDER_LOCKED_ALLOCATION // // MessageText: // // A locked allocation can't be used in the current command buffer. // public static final int ERROR_GRAPHICS_CANT_RENDER_LOCKED_ALLOCATION = 0xC0262111; // // MessageId: ERROR_GRAPHICS_ALLOCATION_CLOSED // // MessageText: // // The allocation being referenced has been closed permanently. // public static final int ERROR_GRAPHICS_ALLOCATION_CLOSED = 0xC0262112; // // MessageId: ERROR_GRAPHICS_INVALID_ALLOCATION_INSTANCE // // MessageText: // // An invalid allocation instance is being referenced. // public static final int ERROR_GRAPHICS_INVALID_ALLOCATION_INSTANCE = 0xC0262113; // // MessageId: ERROR_GRAPHICS_INVALID_ALLOCATION_HANDLE // // MessageText: // // An invalid allocation handle is being referenced. // public static final int ERROR_GRAPHICS_INVALID_ALLOCATION_HANDLE = 0xC0262114; // // MessageId: ERROR_GRAPHICS_WRONG_ALLOCATION_DEVICE // // MessageText: // // The allocation being referenced doesn't belong to the current device. // public static final int ERROR_GRAPHICS_WRONG_ALLOCATION_DEVICE = 0xC0262115; // // MessageId: ERROR_GRAPHICS_ALLOCATION_CONTENT_LOST // // MessageText: // // The specified allocation lost its content. // public static final int ERROR_GRAPHICS_ALLOCATION_CONTENT_LOST = 0xC0262116; // // Video GPU Scheduler (VidSch) subsystem errors {0x2200..0x22ff} // // // MessageId: ERROR_GRAPHICS_GPU_EXCEPTION_ON_DEVICE // // MessageText: // // GPU exception is detected on the given device. The device is not able to // be scheduled. // public static final int ERROR_GRAPHICS_GPU_EXCEPTION_ON_DEVICE = 0xC0262200; // // Video Present Network Management (VidPNMgr) subsystem errors // {0x2300..0x23ff} // // // MessageId: ERROR_GRAPHICS_INVALID_VIDPN_TOPOLOGY // // MessageText: // // Specified VidPN topology is invalid. // public static final int ERROR_GRAPHICS_INVALID_VIDPN_TOPOLOGY = 0xC0262300; // // MessageId: ERROR_GRAPHICS_VIDPN_TOPOLOGY_NOT_SUPPORTED // // MessageText: // // Specified VidPN topology is valid but is not supported by this model of // the display adapter. // public static final int ERROR_GRAPHICS_VIDPN_TOPOLOGY_NOT_SUPPORTED = 0xC0262301; // // MessageId: ERROR_GRAPHICS_VIDPN_TOPOLOGY_CURRENTLY_NOT_SUPPORTED // // MessageText: // // Specified VidPN topology is valid but is not supported by the display // adapter at this time, due to current allocation of its resources. // public static final int ERROR_GRAPHICS_VIDPN_TOPOLOGY_CURRENTLY_NOT_SUPPORTED = 0xC0262302; // // MessageId: ERROR_GRAPHICS_INVALID_VIDPN // // MessageText: // // Specified VidPN handle is invalid. // public static final int ERROR_GRAPHICS_INVALID_VIDPN = 0xC0262303; // // MessageId: ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE // // MessageText: // // Specified video present source is invalid. // public static final int ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE = 0xC0262304; // // MessageId: ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET // // MessageText: // // Specified video present target is invalid. // public static final int ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET = 0xC0262305; // // MessageId: ERROR_GRAPHICS_VIDPN_MODALITY_NOT_SUPPORTED // // MessageText: // // Specified VidPN modality is not supported (e.g. at least two of the // pinned modes are not cofunctiona;. // public static final int ERROR_GRAPHICS_VIDPN_MODALITY_NOT_SUPPORTED = 0xC0262306; // // MessageId: ERROR_GRAPHICS_MODE_NOT_PINNED // // MessageText: // // No mode is pinned on the specified VidPN source/target. // public static final int ERROR_GRAPHICS_MODE_NOT_PINNED = 0x00262307; // // MessageId: ERROR_GRAPHICS_INVALID_VIDPN_SOURCEMODESET // // MessageText: // // Specified VidPN source mode set is invalid. // public static final int ERROR_GRAPHICS_INVALID_VIDPN_SOURCEMODESET = 0xC0262308; // // MessageId: ERROR_GRAPHICS_INVALID_VIDPN_TARGETMODESET // // MessageText: // // Specified VidPN target mode set is invalid. // public static final int ERROR_GRAPHICS_INVALID_VIDPN_TARGETMODESET = 0xC0262309; // // MessageId: ERROR_GRAPHICS_INVALID_FREQUENCY // // MessageText: // // Specified video signal frequency is invalid. // public static final int ERROR_GRAPHICS_INVALID_FREQUENCY = 0xC026230A; // // MessageId: ERROR_GRAPHICS_INVALID_ACTIVE_REGION // // MessageText: // // Specified video signal active region is invalid. // public static final int ERROR_GRAPHICS_INVALID_ACTIVE_REGION = 0xC026230B; // // MessageId: ERROR_GRAPHICS_INVALID_TOTAL_REGION // // MessageText: // // Specified video signal total region is invalid. // public static final int ERROR_GRAPHICS_INVALID_TOTAL_REGION = 0xC026230C; // // MessageId: ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE_MODE // // MessageText: // // Specified video present source mode is invalid. // public static final int ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE_MODE = 0xC0262310; // // MessageId: ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET_MODE // // MessageText: // // Specified video present target mode is invalid. // public static final int ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET_MODE = 0xC0262311; // // MessageId: ERROR_GRAPHICS_PINNED_MODE_MUST_REMAIN_IN_SET // // MessageText: // // Pinned mode must remain in the set on VidPN's cofunctional modality // enumeration. // public static final int ERROR_GRAPHICS_PINNED_MODE_MUST_REMAIN_IN_SET = 0xC0262312; // // MessageId: ERROR_GRAPHICS_PATH_ALREADY_IN_TOPOLOGY // // MessageText: // // Specified video present path is already in VidPN's topology. // public static final int ERROR_GRAPHICS_PATH_ALREADY_IN_TOPOLOGY = 0xC0262313; // // MessageId: ERROR_GRAPHICS_MODE_ALREADY_IN_MODESET // // MessageText: // // Specified mode is already in the mode set. // public static final int ERROR_GRAPHICS_MODE_ALREADY_IN_MODESET = 0xC0262314; // // MessageId: ERROR_GRAPHICS_INVALID_VIDEOPRESENTSOURCESET // // MessageText: // // Specified video present source set is invalid. // public static final int ERROR_GRAPHICS_INVALID_VIDEOPRESENTSOURCESET = 0xC0262315; // // MessageId: ERROR_GRAPHICS_INVALID_VIDEOPRESENTTARGETSET // // MessageText: // // Specified video present target set is invalid. // public static final int ERROR_GRAPHICS_INVALID_VIDEOPRESENTTARGETSET = 0xC0262316; // // MessageId: ERROR_GRAPHICS_SOURCE_ALREADY_IN_SET // // MessageText: // // Specified video present source is already in the video present source // set. // public static final int ERROR_GRAPHICS_SOURCE_ALREADY_IN_SET = 0xC0262317; // // MessageId: ERROR_GRAPHICS_TARGET_ALREADY_IN_SET // // MessageText: // // Specified video present target is already in the video present target // set. // public static final int ERROR_GRAPHICS_TARGET_ALREADY_IN_SET = 0xC0262318; // // MessageId: ERROR_GRAPHICS_INVALID_VIDPN_PRESENT_PATH // // MessageText: // // Specified VidPN present path is invalid. // public static final int ERROR_GRAPHICS_INVALID_VIDPN_PRESENT_PATH = 0xC0262319; // // MessageId: ERROR_GRAPHICS_NO_RECOMMENDED_VIDPN_TOPOLOGY // // MessageText: // // Miniport has no recommendation for augmentation of the specified VidPN's // topology. // public static final int ERROR_GRAPHICS_NO_RECOMMENDED_VIDPN_TOPOLOGY = 0xC026231A; // // MessageId: ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGESET // // MessageText: // // Specified monitor frequency range set is invalid. // public static final int ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGESET = 0xC026231B; // // MessageId: ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE // // MessageText: // // Specified monitor frequency range is invalid. // public static final int ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE = 0xC026231C; // // MessageId: ERROR_GRAPHICS_FREQUENCYRANGE_NOT_IN_SET // // MessageText: // // Specified frequency range is not in the specified monitor frequency range // set. // public static final int ERROR_GRAPHICS_FREQUENCYRANGE_NOT_IN_SET = 0xC026231D; // // MessageId: ERROR_GRAPHICS_NO_PREFERRED_MODE // // MessageText: // // Specified mode set does not specify preference for one of its modes. // public static final int ERROR_GRAPHICS_NO_PREFERRED_MODE = 0x0026231E; // // MessageId: ERROR_GRAPHICS_FREQUENCYRANGE_ALREADY_IN_SET // // MessageText: // // Specified frequency range is already in the specified monitor frequency // range set. // public static final int ERROR_GRAPHICS_FREQUENCYRANGE_ALREADY_IN_SET = 0xC026231F; // // MessageId: ERROR_GRAPHICS_STALE_MODESET // // MessageText: // // Specified mode set is stale. Please reacquire the new mode set. // public static final int ERROR_GRAPHICS_STALE_MODESET = 0xC0262320; // // MessageId: ERROR_GRAPHICS_INVALID_MONITOR_SOURCEMODESET // // MessageText: // // Specified monitor source mode set is invalid. // public static final int ERROR_GRAPHICS_INVALID_MONITOR_SOURCEMODESET = 0xC0262321; // // MessageId: ERROR_GRAPHICS_INVALID_MONITOR_SOURCE_MODE // // MessageText: // // Specified monitor source mode is invalid. // public static final int ERROR_GRAPHICS_INVALID_MONITOR_SOURCE_MODE = 0xC0262322; // // MessageId: ERROR_GRAPHICS_NO_RECOMMENDED_FUNCTIONAL_VIDPN // // MessageText: // // Miniport does not have any recommendation regarding the request to // provide a functional VidPN given the current display adapter // configuration. // public static final int ERROR_GRAPHICS_NO_RECOMMENDED_FUNCTIONAL_VIDPN = 0xC0262323; // // MessageId: ERROR_GRAPHICS_MODE_ID_MUST_BE_UNIQUE // // MessageText: // // ID of the specified mode is already used by another mode in the set. // public static final int ERROR_GRAPHICS_MODE_ID_MUST_BE_UNIQUE = 0xC0262324; // // MessageId: ERROR_GRAPHICS_EMPTY_ADAPTER_MONITOR_MODE_SUPPORT_INTERSECTION // // MessageText: // // System failed to determine a mode that is supported by both the display // adapter and the monitor connected to it. // public static final int ERROR_GRAPHICS_EMPTY_ADAPTER_MONITOR_MODE_SUPPORT_INTERSECTION = 0xC0262325; // // MessageId: ERROR_GRAPHICS_VIDEO_PRESENT_TARGETS_LESS_THAN_SOURCES // // MessageText: // // Number of video present targets must be greater than or equal to the // number of video present sources. // public static final int ERROR_GRAPHICS_VIDEO_PRESENT_TARGETS_LESS_THAN_SOURCES = 0xC0262326; // // MessageId: ERROR_GRAPHICS_PATH_NOT_IN_TOPOLOGY // // MessageText: // // Specified present path is not in VidPN's topology. // public static final int ERROR_GRAPHICS_PATH_NOT_IN_TOPOLOGY = 0xC0262327; // // MessageId: ERROR_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_SOURCE // // MessageText: // // Display adapter must have at least one video present source. // public static final int ERROR_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_SOURCE = 0xC0262328; // // MessageId: ERROR_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_TARGET // // MessageText: // // Display adapter must have at least one video present target. // public static final int ERROR_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_TARGET = 0xC0262329; // // MessageId: ERROR_GRAPHICS_INVALID_MONITORDESCRIPTORSET // // MessageText: // // Specified monitor descriptor set is invalid. // public static final int ERROR_GRAPHICS_INVALID_MONITORDESCRIPTORSET = 0xC026232A; // // MessageId: ERROR_GRAPHICS_INVALID_MONITORDESCRIPTOR // // MessageText: // // Specified monitor descriptor is invalid. // public static final int ERROR_GRAPHICS_INVALID_MONITORDESCRIPTOR = 0xC026232B; // // MessageId: ERROR_GRAPHICS_MONITORDESCRIPTOR_NOT_IN_SET // // MessageText: // // Specified descriptor is not in the specified monitor descriptor set. // public static final int ERROR_GRAPHICS_MONITORDESCRIPTOR_NOT_IN_SET = 0xC026232C; // // MessageId: ERROR_GRAPHICS_MONITORDESCRIPTOR_ALREADY_IN_SET // // MessageText: // // Specified descriptor is already in the specified monitor descriptor set. // public static final int ERROR_GRAPHICS_MONITORDESCRIPTOR_ALREADY_IN_SET = 0xC026232D; // // MessageId: ERROR_GRAPHICS_MONITORDESCRIPTOR_ID_MUST_BE_UNIQUE // // MessageText: // // ID of the specified monitor descriptor is already used by another // descriptor in the set. // public static final int ERROR_GRAPHICS_MONITORDESCRIPTOR_ID_MUST_BE_UNIQUE = 0xC026232E; // // MessageId: ERROR_GRAPHICS_INVALID_VIDPN_TARGET_SUBSET_TYPE // // MessageText: // // Specified video present target subset type is invalid. // public static final int ERROR_GRAPHICS_INVALID_VIDPN_TARGET_SUBSET_TYPE = 0xC026232F; // // MessageId: ERROR_GRAPHICS_RESOURCES_NOT_RELATED // // MessageText: // // Two or more of the specified resources are not related to each other, as // defined by the interface semantics. // public static final int ERROR_GRAPHICS_RESOURCES_NOT_RELATED = 0xC0262330; // // MessageId: ERROR_GRAPHICS_SOURCE_ID_MUST_BE_UNIQUE // // MessageText: // // ID of the specified video present source is already used by another // source in the set. // public static final int ERROR_GRAPHICS_SOURCE_ID_MUST_BE_UNIQUE = 0xC0262331; // // MessageId: ERROR_GRAPHICS_TARGET_ID_MUST_BE_UNIQUE // // MessageText: // // ID of the specified video present target is already used by another // target in the set. // public static final int ERROR_GRAPHICS_TARGET_ID_MUST_BE_UNIQUE = 0xC0262332; // // MessageId: ERROR_GRAPHICS_NO_AVAILABLE_VIDPN_TARGET // // MessageText: // // Specified VidPN source cannot be used because there is no available VidPN // target to connect it to. // public static final int ERROR_GRAPHICS_NO_AVAILABLE_VIDPN_TARGET = 0xC0262333; // // MessageId: ERROR_GRAPHICS_MONITOR_COULD_NOT_BE_ASSOCIATED_WITH_ADAPTER // // MessageText: // // Newly arrived monitor could not be associated with a display adapter. // public static final int ERROR_GRAPHICS_MONITOR_COULD_NOT_BE_ASSOCIATED_WITH_ADAPTER = 0xC0262334; // // MessageId: ERROR_GRAPHICS_NO_VIDPNMGR // // MessageText: // // Display adapter in question does not have an associated VidPN manager. // public static final int ERROR_GRAPHICS_NO_VIDPNMGR = 0xC0262335; // // MessageId: ERROR_GRAPHICS_NO_ACTIVE_VIDPN // // MessageText: // // VidPN manager of the display adapter in question does not have an active // VidPN. // public static final int ERROR_GRAPHICS_NO_ACTIVE_VIDPN = 0xC0262336; // // MessageId: ERROR_GRAPHICS_STALE_VIDPN_TOPOLOGY // // MessageText: // // Specified VidPN topology is stale. Please reacquire the new topology. // public static final int ERROR_GRAPHICS_STALE_VIDPN_TOPOLOGY = 0xC0262337; // // MessageId: ERROR_GRAPHICS_MONITOR_NOT_CONNECTED // // MessageText: // // There is no monitor connected on the specified video present target. // public static final int ERROR_GRAPHICS_MONITOR_NOT_CONNECTED = 0xC0262338; // // MessageId: ERROR_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY // // MessageText: // // Specified source is not part of the specified VidPN's topology. // public static final int ERROR_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY = 0xC0262339; // // MessageId: ERROR_GRAPHICS_INVALID_PRIMARYSURFACE_SIZE // // MessageText: // // Specified primary surface size is invalid. // public static final int ERROR_GRAPHICS_INVALID_PRIMARYSURFACE_SIZE = 0xC026233A; // // MessageId: ERROR_GRAPHICS_INVALID_VISIBLEREGION_SIZE // // MessageText: // // Specified visible region size is invalid. // public static final int ERROR_GRAPHICS_INVALID_VISIBLEREGION_SIZE = 0xC026233B; // // MessageId: ERROR_GRAPHICS_INVALID_STRIDE // // MessageText: // // Specified stride is invalid. // public static final int ERROR_GRAPHICS_INVALID_STRIDE = 0xC026233C; // // MessageId: ERROR_GRAPHICS_INVALID_PIXELFORMAT // // MessageText: // // Specified pixel format is invalid. // public static final int ERROR_GRAPHICS_INVALID_PIXELFORMAT = 0xC026233D; // // MessageId: ERROR_GRAPHICS_INVALID_COLORBASIS // // MessageText: // // Specified color basis is invalid. // public static final int ERROR_GRAPHICS_INVALID_COLORBASIS = 0xC026233E; // // MessageId: ERROR_GRAPHICS_INVALID_PIXELVALUEACCESSMODE // // MessageText: // // Specified pixel value access mode is invalid. // public static final int ERROR_GRAPHICS_INVALID_PIXELVALUEACCESSMODE = 0xC026233F; // // MessageId: ERROR_GRAPHICS_TARGET_NOT_IN_TOPOLOGY // // MessageText: // // Specified target is not part of the specified VidPN's topology. // public static final int ERROR_GRAPHICS_TARGET_NOT_IN_TOPOLOGY = 0xC0262340; // // MessageId: ERROR_GRAPHICS_NO_DISPLAY_MODE_MANAGEMENT_SUPPORT // // MessageText: // // Failed to acquire display mode management interface. // public static final int ERROR_GRAPHICS_NO_DISPLAY_MODE_MANAGEMENT_SUPPORT = 0xC0262341; // // MessageId: ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE // // MessageText: // // Specified VidPN source is already owned by a DMM client and cannot be // used until that client releases it. // public static final int ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE = 0xC0262342; // // MessageId: ERROR_GRAPHICS_CANT_ACCESS_ACTIVE_VIDPN // // MessageText: // // Specified VidPN is active and cannot be accessed. // public static final int ERROR_GRAPHICS_CANT_ACCESS_ACTIVE_VIDPN = 0xC0262343; // // MessageId: ERROR_GRAPHICS_INVALID_PATH_IMPORTANCE_ORDINAL // // MessageText: // // Specified VidPN present path importance ordinal is invalid. // public static final int ERROR_GRAPHICS_INVALID_PATH_IMPORTANCE_ORDINAL = 0xC0262344; // // MessageId: ERROR_GRAPHICS_INVALID_PATH_CONTENT_GEOMETRY_TRANSFORMATION // // MessageText: // // Specified VidPN present path content geometry transformation is invalid. // public static final int ERROR_GRAPHICS_INVALID_PATH_CONTENT_GEOMETRY_TRANSFORMATION = 0xC0262345; // // MessageId: // ERROR_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_SUPPORTED // // MessageText: // // Specified content geometry transformation is not supported on the // respective VidPN present path. // public static final int ERROR_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_SUPPORTED = 0xC0262346; // // MessageId: ERROR_GRAPHICS_INVALID_GAMMA_RAMP // // MessageText: // // Specified gamma ramp is invalid. // public static final int ERROR_GRAPHICS_INVALID_GAMMA_RAMP = 0xC0262347; // // MessageId: ERROR_GRAPHICS_GAMMA_RAMP_NOT_SUPPORTED // // MessageText: // // Specified gamma ramp is not supported on the respective VidPN present // path. // public static final int ERROR_GRAPHICS_GAMMA_RAMP_NOT_SUPPORTED = 0xC0262348; // // MessageId: ERROR_GRAPHICS_MULTISAMPLING_NOT_SUPPORTED // // MessageText: // // Multi-sampling is not supported on the respective VidPN present path. // public static final int ERROR_GRAPHICS_MULTISAMPLING_NOT_SUPPORTED = 0xC0262349; // // MessageId: ERROR_GRAPHICS_MODE_NOT_IN_MODESET // // MessageText: // // Specified mode is not in the specified mode set. // public static final int ERROR_GRAPHICS_MODE_NOT_IN_MODESET = 0xC026234A; // // MessageId: ERROR_GRAPHICS_DATASET_IS_EMPTY // // MessageText: // // Specified data set (e.g. mode set, frequency range set, descriptor set, // topology, etc.) is empty. // public static final int ERROR_GRAPHICS_DATASET_IS_EMPTY = 0x0026234B; // // MessageId: ERROR_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET // // MessageText: // // Specified data set (e.g. mode set, frequency range set, descriptor set, // topology, etc.) does not contain any more elements. // public static final int ERROR_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET = 0x0026234C; // // MessageId: ERROR_GRAPHICS_INVALID_VIDPN_TOPOLOGY_RECOMMENDATION_REASON // // MessageText: // // Specified VidPN topology recommendation reason is invalid. // public static final int ERROR_GRAPHICS_INVALID_VIDPN_TOPOLOGY_RECOMMENDATION_REASON = 0xC026234D; // // MessageId: ERROR_GRAPHICS_INVALID_PATH_CONTENT_TYPE // // MessageText: // // Specified VidPN present path content type is invalid. // public static final int ERROR_GRAPHICS_INVALID_PATH_CONTENT_TYPE = 0xC026234E; // // MessageId: ERROR_GRAPHICS_INVALID_COPYPROTECTION_TYPE // // MessageText: // // Specified VidPN present path copy protection type is invalid. // public static final int ERROR_GRAPHICS_INVALID_COPYPROTECTION_TYPE = 0xC026234F; // // MessageId: ERROR_GRAPHICS_UNASSIGNED_MODESET_ALREADY_EXISTS // // MessageText: // // No more than one unassigned mode set can exist at any given time for a // given VidPN source/target. // public static final int ERROR_GRAPHICS_UNASSIGNED_MODESET_ALREADY_EXISTS = 0xC0262350; // // MessageId: ERROR_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_PINNED // // MessageText: // // Specified content transformation is not pinned on the specified VidPN // present path. // public static final int ERROR_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_PINNED = 0x00262351; // // MessageId: ERROR_GRAPHICS_INVALID_SCANLINE_ORDERING // // MessageText: // // Specified scanline ordering type is invalid. // public static final int ERROR_GRAPHICS_INVALID_SCANLINE_ORDERING = 0xC0262352; // // MessageId: ERROR_GRAPHICS_TOPOLOGY_CHANGES_NOT_ALLOWED // // MessageText: // // Topology changes are not allowed for the specified VidPN. // public static final int ERROR_GRAPHICS_TOPOLOGY_CHANGES_NOT_ALLOWED = 0xC0262353; // // MessageId: ERROR_GRAPHICS_NO_AVAILABLE_IMPORTANCE_ORDINALS // // MessageText: // // All available importance ordinals are already used in specified topology. // public static final int ERROR_GRAPHICS_NO_AVAILABLE_IMPORTANCE_ORDINALS = 0xC0262354; // // MessageId: ERROR_GRAPHICS_INCOMPATIBLE_PRIVATE_FORMAT // // MessageText: // // Specified primary surface has a different private format attribute than // the current primary surface // public static final int ERROR_GRAPHICS_INCOMPATIBLE_PRIVATE_FORMAT = 0xC0262355; // // MessageId: ERROR_GRAPHICS_INVALID_MODE_PRUNING_ALGORITHM // // MessageText: // // Specified mode pruning algorithm is invalid // public static final int ERROR_GRAPHICS_INVALID_MODE_PRUNING_ALGORITHM = 0xC0262356; // // MessageId: ERROR_GRAPHICS_INVALID_MONITOR_CAPABILITY_ORIGIN // // MessageText: // // Specified monitor capability origin is invalid. // public static final int ERROR_GRAPHICS_INVALID_MONITOR_CAPABILITY_ORIGIN = 0xC0262357; // // MessageId: ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE_CONSTRAINT // // MessageText: // // Specified monitor frequency range constraint is invalid. // public static final int ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE_CONSTRAINT = 0xC0262358; // // MessageId: ERROR_GRAPHICS_MAX_NUM_PATHS_REACHED // // MessageText: // // Maximum supported number of present paths has been reached. // public static final int ERROR_GRAPHICS_MAX_NUM_PATHS_REACHED = 0xC0262359; // // MessageId: ERROR_GRAPHICS_CANCEL_VIDPN_TOPOLOGY_AUGMENTATION // // MessageText: // // Miniport requested that augmentation be cancelled for the specified // source of the specified VidPN's topology. // public static final int ERROR_GRAPHICS_CANCEL_VIDPN_TOPOLOGY_AUGMENTATION = 0xC026235A; // // MessageId: ERROR_GRAPHICS_INVALID_CLIENT_TYPE // // MessageText: // // Specified client type was not recognized. // public static final int ERROR_GRAPHICS_INVALID_CLIENT_TYPE = 0xC026235B; // // MessageId: ERROR_GRAPHICS_CLIENTVIDPN_NOT_SET // // MessageText: // // Client VidPN is not set on this adapter (e.g. no user mode initiated mode // changes took place on this adapter yet). // public static final int ERROR_GRAPHICS_CLIENTVIDPN_NOT_SET = 0xC026235C; // // Port specific status codes {0x2400..0x24ff} // // // MessageId: ERROR_GRAPHICS_SPECIFIED_CHILD_ALREADY_CONNECTED // // MessageText: // // Specified display adapter child device already has an external device // connected to it. // public static final int ERROR_GRAPHICS_SPECIFIED_CHILD_ALREADY_CONNECTED = 0xC0262400; // // MessageId: ERROR_GRAPHICS_CHILD_DESCRIPTOR_NOT_SUPPORTED // // MessageText: // // Specified display adapter child device does not support descriptor // exposure. // public static final int ERROR_GRAPHICS_CHILD_DESCRIPTOR_NOT_SUPPORTED = 0xC0262401; // // MessageId: ERROR_GRAPHICS_UNKNOWN_CHILD_STATUS // // MessageText: // // Child device presence was not reliably detected. // public static final int ERROR_GRAPHICS_UNKNOWN_CHILD_STATUS = 0x4026242F; // // MessageId: ERROR_GRAPHICS_NOT_A_LINKED_ADAPTER // // MessageText: // // The display adapter is not linked to any other adapters. // public static final int ERROR_GRAPHICS_NOT_A_LINKED_ADAPTER = 0xC0262430; // // MessageId: ERROR_GRAPHICS_LEADLINK_NOT_ENUMERATED // // MessageText: // // Lead adapter in a linked configuration was not enumerated yet. // public static final int ERROR_GRAPHICS_LEADLINK_NOT_ENUMERATED = 0xC0262431; // // MessageId: ERROR_GRAPHICS_CHAINLINKS_NOT_ENUMERATED // // MessageText: // // Some chain adapters in a linked configuration were not enumerated yet. // public static final int ERROR_GRAPHICS_CHAINLINKS_NOT_ENUMERATED = 0xC0262432; // // MessageId: ERROR_GRAPHICS_ADAPTER_CHAIN_NOT_READY // // MessageText: // // The chain of linked adapters is not ready to start because of an unknown // failure. // public static final int ERROR_GRAPHICS_ADAPTER_CHAIN_NOT_READY = 0xC0262433; // // MessageId: ERROR_GRAPHICS_CHAINLINKS_NOT_STARTED // // MessageText: // // An attempt was made to start a lead link display adapter when the chain // links were not started yet. // public static final int ERROR_GRAPHICS_CHAINLINKS_NOT_STARTED = 0xC0262434; // // MessageId: ERROR_GRAPHICS_CHAINLINKS_NOT_POWERED_ON // // MessageText: // // An attempt was made to power up a lead link display adapter when the // chain links were powered down. // public static final int ERROR_GRAPHICS_CHAINLINKS_NOT_POWERED_ON = 0xC0262435; // // MessageId: ERROR_GRAPHICS_INCONSISTENT_DEVICE_LINK_STATE // // MessageText: // // The adapter link was found to be in an inconsistent state. Not all // adapters are in an expected PNP/Power state. // public static final int ERROR_GRAPHICS_INCONSISTENT_DEVICE_LINK_STATE = 0xC0262436; // // MessageId: ERROR_GRAPHICS_LEADLINK_START_DEFERRED // // MessageText: // // Starting the leadlink adapter has been deferred temporarily. // public static final int ERROR_GRAPHICS_LEADLINK_START_DEFERRED = 0x40262437; // // MessageId: ERROR_GRAPHICS_NOT_POST_DEVICE_DRIVER // // MessageText: // // The driver trying to start is not the same as the driver for the POSTed // display adapter. // public static final int ERROR_GRAPHICS_NOT_POST_DEVICE_DRIVER = 0xC0262438; // // MessageId: ERROR_GRAPHICS_POLLING_TOO_FREQUENTLY // // MessageText: // // The display adapter is being polled for children too frequently at the // same polling level. // public static final int ERROR_GRAPHICS_POLLING_TOO_FREQUENTLY = 0x40262439; // // MessageId: ERROR_GRAPHICS_START_DEFERRED // // MessageText: // // Starting the adapter has been deferred temporarily. // public static final int ERROR_GRAPHICS_START_DEFERRED = 0x4026243A; // // MessageId: ERROR_GRAPHICS_ADAPTER_ACCESS_NOT_EXCLUDED // // MessageText: // // An operation is being attempted that requires the display adapter to be // in a quiescent state. // public static final int ERROR_GRAPHICS_ADAPTER_ACCESS_NOT_EXCLUDED = 0xC026243B; // // OPM, UAB and PVP specific error codes {0x2500..0x257f} // // // MessageId: ERROR_GRAPHICS_OPM_NOT_SUPPORTED // // MessageText: // // The driver does not support OPM. // public static final int ERROR_GRAPHICS_OPM_NOT_SUPPORTED = 0xC0262500; // // MessageId: ERROR_GRAPHICS_COPP_NOT_SUPPORTED // // MessageText: // // The driver does not support COPP. // public static final int ERROR_GRAPHICS_COPP_NOT_SUPPORTED = 0xC0262501; // // MessageId: ERROR_GRAPHICS_UAB_NOT_SUPPORTED // // MessageText: // // The driver does not support UAB. // public static final int ERROR_GRAPHICS_UAB_NOT_SUPPORTED = 0xC0262502; // // MessageId: ERROR_GRAPHICS_OPM_INVALID_ENCRYPTED_PARAMETERS // // MessageText: // // The specified encrypted parameters are invalid. // public static final int ERROR_GRAPHICS_OPM_INVALID_ENCRYPTED_PARAMETERS = 0xC0262503; // // MessageId: ERROR_GRAPHICS_OPM_NO_VIDEO_OUTPUTS_EXIST // // MessageText: // // The GDI display device passed to this function does not have any active // video outputs. // public static final int ERROR_GRAPHICS_OPM_NO_VIDEO_OUTPUTS_EXIST = 0xC0262505; // // MessageId: ERROR_GRAPHICS_OPM_INTERNAL_ERROR // // MessageText: // // An internal error caused this operation to fail. // public static final int ERROR_GRAPHICS_OPM_INTERNAL_ERROR = 0xC026250B; // // MessageId: ERROR_GRAPHICS_OPM_INVALID_HANDLE // // MessageText: // // The function failed because the caller passed in an invalid OPM user mode // handle. // public static final int ERROR_GRAPHICS_OPM_INVALID_HANDLE = 0xC026250C; // // MessageId: ERROR_GRAPHICS_PVP_INVALID_CERTIFICATE_LENGTH // // MessageText: // // A certificate could not be returned because the certificate buffer passed // to the function was too small. // public static final int ERROR_GRAPHICS_PVP_INVALID_CERTIFICATE_LENGTH = 0xC026250E; // // MessageId: ERROR_GRAPHICS_OPM_SPANNING_MODE_ENABLED // // MessageText: // // A video output could not be created because the frame buffer is in // spanning mode. // public static final int ERROR_GRAPHICS_OPM_SPANNING_MODE_ENABLED = 0xC026250F; // // MessageId: ERROR_GRAPHICS_OPM_THEATER_MODE_ENABLED // // MessageText: // // A video output could not be created because the frame buffer is in // theater mode. // public static final int ERROR_GRAPHICS_OPM_THEATER_MODE_ENABLED = 0xC0262510; // // MessageId: ERROR_GRAPHICS_PVP_HFS_FAILED // // MessageText: // // The function failed because the display adapter's Hardware Functionality // Scan failed to validate the graphics hardware. // public static final int ERROR_GRAPHICS_PVP_HFS_FAILED = 0xC0262511; // // MessageId: ERROR_GRAPHICS_OPM_INVALID_SRM // // MessageText: // // The HDCP System Renewability Message passed to this function did not // comply with section=5 of the HDCP=1.1 specification. // public static final int ERROR_GRAPHICS_OPM_INVALID_SRM = 0xC0262512; // // MessageId: ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_HDCP // // MessageText: // // The video output cannot enable the High-bandwidth Digital Content // Protection (HDCP) System because it does not support HDCP. // public static final int ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_HDCP = 0xC0262513; // // MessageId: ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_ACP // // MessageText: // // The video output cannot enable Analogue Copy Protection (ACP) because it // does not support ACP. // public static final int ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_ACP = 0xC0262514; // // MessageId: ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_CGMSA // // MessageText: // // The video output cannot enable the Content Generation Management System // Analogue (CGMS-A) protection technology because it does not support // CGMS-A. // public static final int ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_CGMSA = 0xC0262515; // // MessageId: ERROR_GRAPHICS_OPM_HDCP_SRM_NEVER_SET // // MessageText: // // The IOPMVideoOutput::GetInformation method cannot return the version of // the SRM being used because the application never successfully passed an // SRM to the video output. // public static final int ERROR_GRAPHICS_OPM_HDCP_SRM_NEVER_SET = 0xC0262516; // // MessageId: ERROR_GRAPHICS_OPM_RESOLUTION_TOO_HIGH // // MessageText: // // The IOPMVideoOutput::Configure method cannot enable the specified output // protection technology because the output's screen resolution is too high. // public static final int ERROR_GRAPHICS_OPM_RESOLUTION_TOO_HIGH = 0xC0262517; // // MessageId: ERROR_GRAPHICS_OPM_ALL_HDCP_HARDWARE_ALREADY_IN_USE // // MessageText: // // The IOPMVideoOutput::Configure method cannot enable HDCP because the // display adapter's HDCP hardware is already being used by other physical // outputs. // public static final int ERROR_GRAPHICS_OPM_ALL_HDCP_HARDWARE_ALREADY_IN_USE = 0xC0262518; // // MessageId: ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_NO_LONGER_EXISTS // // MessageText: // // The operating system asynchronously destroyed this OPM video output // because the operating system's state changed. This error typically occurs // because the monitor PDO associated with this video output was removed, // the monitor PDO associated with this video output was stopped, the video // output's session became a non-console session or the video output's // desktop became an inactive desktop. // public static final int ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_NO_LONGER_EXISTS = 0xC026251A; // // MessageId: ERROR_GRAPHICS_OPM_SESSION_TYPE_CHANGE_IN_PROGRESS // // MessageText: // // The method failed because the session is changing its type. No // IOPMVideoOutput methods can be called when a session is changing its // type. There are currently three types of sessions: console, disconnected // and remote (RDP or ICA). // public static final int ERROR_GRAPHICS_OPM_SESSION_TYPE_CHANGE_IN_PROGRESS = 0xC026251B; // // MessageId: ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_DOES_NOT_HAVE_COPP_SEMANTICS // // MessageText: // // Either the IOPMVideoOutput::COPPCompatibleGetInformation, // IOPMVideoOutput::GetInformation, or IOPMVideoOutput::Configure method // failed. This error is only returned if a video output has OPM semantics. // IOPMVideoOutput::COPPCompatibleGetInformation always returns this error // if a video output has OPM semantics. IOPMVideoOutput::GetInformation // returns this error code if the caller requested COPP specific // information. IOPMVideoOutput::Configure returns this error when the // caller tries to use a COPP specific command. // public static final int ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_DOES_NOT_HAVE_COPP_SEMANTICS = 0xC026251C; // // MessageId: ERROR_GRAPHICS_OPM_INVALID_INFORMATION_REQUEST // // MessageText: // // The IOPMVideoOutput::GetInformation and // IOPMVideoOutput::COPPCompatibleGetInformation methods return this error // if the passed in sequence number is not the expected sequence number or // the passed in OMAC value is invalid. // public static final int ERROR_GRAPHICS_OPM_INVALID_INFORMATION_REQUEST = 0xC026251D; // // MessageId: ERROR_GRAPHICS_OPM_DRIVER_INTERNAL_ERROR // // MessageText: // // The method failed because an unexpected error occurred inside of a // display driver. // public static final int ERROR_GRAPHICS_OPM_DRIVER_INTERNAL_ERROR = 0xC026251E; // // MessageId: ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_DOES_NOT_HAVE_OPM_SEMANTICS // // MessageText: // // Either the IOPMVideoOutput::COPPCompatibleGetInformation, // IOPMVideoOutput::GetInformation, or IOPMVideoOutput::Configure method // failed. This error is only returned if a video output has COPP semantics. // IOPMVideoOutput::COPPCompatibleGetInformation returns this error code if // the caller requested OPM specific information. // IOPMVideoOutput::GetInformation always returns this error if a video // output has COPP semantics. IOPMVideoOutput::Configure returns this error // when the caller tries to use an OPM specific command. // public static final int ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_DOES_NOT_HAVE_OPM_SEMANTICS = 0xC026251F; // // MessageId: ERROR_GRAPHICS_OPM_SIGNALING_NOT_SUPPORTED // // MessageText: // // The IOPMVideoOutput::COPPCompatibleGetInformation or // IOPMVideoOutput::Configure method failed because the display driver does // not support the OPM_GET_ACP_AND_CGMSA_SIGNALING and // OPM_SET_ACP_AND_CGMSA_SIGNALING GUIDs. // public static final int ERROR_GRAPHICS_OPM_SIGNALING_NOT_SUPPORTED = 0xC0262520; // // MessageId: ERROR_GRAPHICS_OPM_INVALID_CONFIGURATION_REQUEST // // MessageText: // // The IOPMVideoOutput::Configure function returns this error code if the // passed in sequence number is not the expected sequence number or the // passed in OMAC value is invalid. // public static final int ERROR_GRAPHICS_OPM_INVALID_CONFIGURATION_REQUEST = 0xC0262521; // // Monitor Configuration API error codes {0x2580..0x25DF} // // // MessageId: ERROR_GRAPHICS_I2C_NOT_SUPPORTED // // MessageText: // // The monitor connected to the specified video output does not have an I2C // bus. // public static final int ERROR_GRAPHICS_I2C_NOT_SUPPORTED = 0xC0262580; // // MessageId: ERROR_GRAPHICS_I2C_DEVICE_DOES_NOT_EXIST // // MessageText: // // No device on the I2C bus has the specified address. // public static final int ERROR_GRAPHICS_I2C_DEVICE_DOES_NOT_EXIST = 0xC0262581; // // MessageId: ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA // // MessageText: // // An error occurred while transmitting data to the device on the I2C bus. // public static final int ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA = 0xC0262582; // // MessageId: ERROR_GRAPHICS_I2C_ERROR_RECEIVING_DATA // // MessageText: // // An error occurred while receiving data from the device on the I2C bus. // public static final int ERROR_GRAPHICS_I2C_ERROR_RECEIVING_DATA = 0xC0262583; // // MessageId: ERROR_GRAPHICS_DDCCI_VCP_NOT_SUPPORTED // // MessageText: // // The monitor does not support the specified VCP code. // public static final int ERROR_GRAPHICS_DDCCI_VCP_NOT_SUPPORTED = 0xC0262584; // // MessageId: ERROR_GRAPHICS_DDCCI_INVALID_DATA // // MessageText: // // The data received from the monitor is invalid. // public static final int ERROR_GRAPHICS_DDCCI_INVALID_DATA = 0xC0262585; // // MessageId: // ERROR_GRAPHICS_DDCCI_MONITOR_RETURNED_INVALID_TIMING_STATUS_BYTE // // MessageText: // // The function failed because a monitor returned an invalid Timing Status // byte when the operating system used the DDC/CI Get Timing Report & Timing // Message command to get a timing report from a monitor. // public static final int ERROR_GRAPHICS_DDCCI_MONITOR_RETURNED_INVALID_TIMING_STATUS_BYTE = 0xC0262586; // // MessageId: ERROR_GRAPHICS_MCA_INVALID_CAPABILITIES_STRING // // MessageText: // // The monitor returned a DDC/CI capabilities string which did not comply // with the ACCESS.bus=3.0, DDC/CI=1.1, or MCCS=2 Revision=1 specification. // public static final int ERROR_GRAPHICS_MCA_INVALID_CAPABILITIES_STRING = 0xC0262587; // // MessageId: ERROR_GRAPHICS_MCA_INTERNAL_ERROR // // MessageText: // // An internal Monitor Configuration API error occured. // public static final int ERROR_GRAPHICS_MCA_INTERNAL_ERROR = 0xC0262588; // // MessageId: ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_COMMAND // // MessageText: // // An operation failed because a DDC/CI message had an invalid value in its // command field. // public static final int ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_COMMAND = 0xC0262589; // // MessageId: ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_LENGTH // // MessageText: // // An error occurred because the field length of a DDC/CI message contained // an invalid value. // public static final int ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_LENGTH = 0xC026258A; // // MessageId: ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_CHECKSUM // // MessageText: // // An error occurred because the checksum field in a DDC/CI message did not // match the message's computed checksum value. This error implies that the // data was corrupted while it was being transmitted from a monitor to a // computer. // public static final int ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_CHECKSUM = 0xC026258B; // // MessageId: ERROR_GRAPHICS_INVALID_PHYSICAL_MONITOR_HANDLE // // MessageText: // // This function failed because an invalid monitor handle was passed to it. // public static final int ERROR_GRAPHICS_INVALID_PHYSICAL_MONITOR_HANDLE = 0xC026258C; // // MessageId: ERROR_GRAPHICS_MONITOR_NO_LONGER_EXISTS // // MessageText: // // The operating system asynchronously destroyed the monitor which // corresponds to this handle because the operating system's state changed. // This error typically occurs because the monitor PDO associated with this // handle was removed, the monitor PDO associated with this handle was // stopped, or a display mode change occurred. A display mode change occurs // when windows sends a WM_DISPLAYCHANGE windows message to applications. // public static final int ERROR_GRAPHICS_MONITOR_NO_LONGER_EXISTS = 0xC026258D; // // MessageId: // ERROR_GRAPHICS_DDCCI_CURRENT_CURRENT_VALUE_GREATER_THAN_MAXIMUM_VALUE // // MessageText: // // A continuous VCP code's current value is greater than its maximum value. // This error code indicates that a monitor returned an invalid value. // public static final int ERROR_GRAPHICS_DDCCI_CURRENT_CURRENT_VALUE_GREATER_THAN_MAXIMUM_VALUE = 0xC02625D8; // // MessageId: ERROR_GRAPHICS_MCA_INVALID_VCP_VERSION // // MessageText: // // The monitor's VCP Version (0xDF) VCP code returned an invalid version // value. // public static final int ERROR_GRAPHICS_MCA_INVALID_VCP_VERSION = 0xC02625D9; // // MessageId: ERROR_GRAPHICS_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION // // MessageText: // // The monitor does not comply with the MCCS specification it claims to // support. // public static final int ERROR_GRAPHICS_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION = 0xC02625DA; // // MessageId: ERROR_GRAPHICS_MCA_MCCS_VERSION_MISMATCH // // MessageText: // // The MCCS version in a monitor's mccs_ver capability does not match the // MCCS version the monitor reports when the VCP Version (0xDF) VCP code is // used. // public static final int ERROR_GRAPHICS_MCA_MCCS_VERSION_MISMATCH = 0xC02625DB; // // MessageId: ERROR_GRAPHICS_MCA_UNSUPPORTED_MCCS_VERSION // // MessageText: // // The Monitor Configuration API only works with monitors which support the // MCCS=1.0 specification, MCCS=2.0 specification or the MCCS=2.0 Revision=1 // specification. // public static final int ERROR_GRAPHICS_MCA_UNSUPPORTED_MCCS_VERSION = 0xC02625DC; // // MessageId: ERROR_GRAPHICS_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED // // MessageText: // // The monitor returned an invalid monitor technology type. CRT, Plasma and // LCD (TFT) are examples of monitor technology types. This error implies // that the monitor violated the MCCS=2.0 or MCCS=2.0 Revision=1 // specification. // public static final int ERROR_GRAPHICS_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED = 0xC02625DE; // // MessageId: ERROR_GRAPHICS_MCA_UNSUPPORTED_COLOR_TEMPERATURE // // MessageText: // // SetMonitorColorTemperature()'s caller passed a color temperature to it // which the current monitor did not support. This error implies that the // monitor violated the MCCS=2.0 or MCCS=2.0 Revision=1 specification. // public static final int ERROR_GRAPHICS_MCA_UNSUPPORTED_COLOR_TEMPERATURE = 0xC02625DF; // // OPM, UAB, PVP and DDC/CI shared error codes {0x25E0..0x25ff} // // // MessageId: ERROR_GRAPHICS_ONLY_CONSOLE_SESSION_SUPPORTED // // MessageText: // // This function can only be used if a program is running in the local // console session. It cannot be used if the program is running on a remote // desktop session or on a terminal server session. // public static final int ERROR_GRAPHICS_ONLY_CONSOLE_SESSION_SUPPORTED = 0xC02625E0; // // MessageId: ERROR_GRAPHICS_NO_DISPLAY_DEVICE_CORRESPONDS_TO_NAME // // MessageText: // // This function cannot find an actual GDI display device which corresponds // to the specified GDI display device name. // public static final int ERROR_GRAPHICS_NO_DISPLAY_DEVICE_CORRESPONDS_TO_NAME = 0xC02625E1; // // MessageId: ERROR_GRAPHICS_DISPLAY_DEVICE_NOT_ATTACHED_TO_DESKTOP // // MessageText: // // The function failed because the specified GDI display device was not // attached to the Windows desktop. // public static final int ERROR_GRAPHICS_DISPLAY_DEVICE_NOT_ATTACHED_TO_DESKTOP = 0xC02625E2; // // MessageId: ERROR_GRAPHICS_MIRRORING_DEVICES_NOT_SUPPORTED // // MessageText: // // This function does not support GDI mirroring display devices because GDI // mirroring display devices do not have any physical monitors associated // with them. // public static final int ERROR_GRAPHICS_MIRRORING_DEVICES_NOT_SUPPORTED = 0xC02625E3; // // MessageId: ERROR_GRAPHICS_INVALID_POINTER // // MessageText: // // The function failed because an invalid pointer parameter was passed to // it. A pointer parameter is invalid if it is NULL, points to an invalid // address, points to a kernel mode address, or is not correctly aligned. // public static final int ERROR_GRAPHICS_INVALID_POINTER = 0xC02625E4; // // MessageId: ERROR_GRAPHICS_NO_MONITORS_CORRESPOND_TO_DISPLAY_DEVICE // // MessageText: // // The function failed because the specified GDI device did not have any // monitors associated with it. // public static final int ERROR_GRAPHICS_NO_MONITORS_CORRESPOND_TO_DISPLAY_DEVICE = 0xC02625E5; // // MessageId: ERROR_GRAPHICS_PARAMETER_ARRAY_TOO_SMALL // // MessageText: // // An array passed to the function cannot hold all of the data that the // function must copy into the array. // public static final int ERROR_GRAPHICS_PARAMETER_ARRAY_TOO_SMALL = 0xC02625E6; // // MessageId: ERROR_GRAPHICS_INTERNAL_ERROR // // MessageText: // // An internal error caused an operation to fail. // public static final int ERROR_GRAPHICS_INTERNAL_ERROR = 0xC02625E7; // // MessageId: ERROR_GRAPHICS_SESSION_TYPE_CHANGE_IN_PROGRESS // // MessageText: // // The function failed because the current session is changing its type. // This function cannot be called when the current session is changing its // type. There are currently three types of sessions: console, disconnected // and remote (RDP or ICA). // public static final int ERROR_GRAPHICS_SESSION_TYPE_CHANGE_IN_PROGRESS = 0xC02605E8; // // = // TPM Services and TPM Software Error Messages // = // // The TPM services and TPM software facilities are used by the various // TPM software components. There are two facilities because the services // errors are within the TCG-defined error space and the software errors // are not. // // The following are the subranges within the TPM Services facility. // The TPM hardware errors are defined in the document // TPM Main Specification=1.2 Part=2 TPM Structures. // The TBS errors are slotted into the TCG error namespace at the TBS layer. // // 0x0000 - 0x08ff TPM hardware errors // 0x4000 - 0x40ff TPM Base Services errors (tbssvc.dl; // // The following are the subranges within the TPM Software facility. The TBS // has two classes of errors - those that can be returned (the public // errors, // defined in the TBS spec), which are in the TPM services facility, and // those that are internal or implementation specific, which are here in the // TPM software facility. // // 0x0000 - 0x00ff TPM device driver errors (tpm.sys) // 0x0100 - 0x01ff TPM API errors (tpmapi.lib) // 0x0200 - 0x02ff TBS internal errors (tbssvc.dl; // 0x0300 - 0x03ff TPM Physical Presence errors // // // TPM hardware error codes {0x0000..0x08ff} // This space is further subdivided into hardware errors, vendor-specific // errors, and non-fatal errors. // // // TPM hardware errors {0x0000..0x003ff} // // // MessageId: TPM_E_ERROR_MASK // // MessageText: // // This is an error mask to convert TPM hardware errors to win errors. // public static final int TPM_E_ERROR_MASK = 0x80280000; // // MessageId: TPM_E_AUTHFAIL // // MessageText: // // Authentication failed. // public static final int TPM_E_AUTHFAIL = 0x80280001; // // MessageId: TPM_E_BADINDEX // // MessageText: // // The index to a PCR, DIR or other register is incorrect. // public static final int TPM_E_BADINDEX = 0x80280002; // // MessageId: TPM_E_BAD_PARAMETER // // MessageText: // // One or more parameter is bad. // public static final int TPM_E_BAD_PARAMETER = 0x80280003; // // MessageId: TPM_E_AUDITFAILURE // // MessageText: // // An operation completed successfully but the auditing of that operation // failed. // public static final int TPM_E_AUDITFAILURE = 0x80280004; // // MessageId: TPM_E_CLEAR_DISABLED // // MessageText: // // The clear disable F;ag is set and all clear operations now require // physical access. // public static final int TPM_E_CLEAR_DISABLED = 0x80280005; // // MessageId: TPM_E_DEACTIVATED // // MessageText: // // Activate the Trusted Platform Module (TPM). // public static final int TPM_E_DEACTIVATED = 0x80280006; // // MessageId: TPM_E_DISABLED // // MessageText: // // Enable the Trusted Platform Module (TPM). // public static final int TPM_E_DISABLED = 0x80280007; // // MessageId: TPM_E_DISABLED_CMD // // MessageText: // // The target command has been disabled. // public static final int TPM_E_DISABLED_CMD = 0x80280008; // // MessageId: TPM_E_FAIL // // MessageText: // // The operation failed. // public static final int TPM_E_FAIL = 0x80280009; // // MessageId: TPM_E_BAD_ORDINAL // // MessageText: // // The ordinal was unknown or inconsistent. // public static final int TPM_E_BAD_ORDINAL = 0x8028000A; // // MessageId: TPM_E_INSTALL_DISABLED // // MessageText: // // The ability to install an owner is disabled. // public static final int TPM_E_INSTALL_DISABLED = 0x8028000B; // // MessageId: TPM_E_INVALID_KEYHANDLE // // MessageText: // // The key handle cannot be intrepreted. // public static final int TPM_E_INVALID_KEYHANDLE = 0x8028000C; // // MessageId: TPM_E_KEYNOTFOUND // // MessageText: // // The key handle points to an invalid key. // public static final int TPM_E_KEYNOTFOUND = 0x8028000D; // // MessageId: TPM_E_INAPPROPRIATE_ENC // // MessageText: // // Unacceptable encryption scheme. // public static final int TPM_E_INAPPROPRIATE_ENC = 0x8028000E; // // MessageId: TPM_E_MIGRATEFAIL // // MessageText: // // Migration authorization failed. // public static final int TPM_E_MIGRATEFAIL = 0x8028000F; // // MessageId: TPM_E_INVALID_PCR_INFO // // MessageText: // // PCR information could not be interpreted. // public static final int TPM_E_INVALID_PCR_INFO = 0x80280010; // // MessageId: TPM_E_NOSPACE // // MessageText: // // No room to load key. // public static final int TPM_E_NOSPACE = 0x80280011; // // MessageId: TPM_E_NOSRK // // MessageText: // // There is no Storage Root Key (SRK) set. // public static final int TPM_E_NOSRK = 0x80280012; // // MessageId: TPM_E_NOTSEALED_BLOB // // MessageText: // // An encrypted blob is invalid or was not created by this TPM. // public static final int TPM_E_NOTSEALED_BLOB = 0x80280013; // // MessageId: TPM_E_OWNER_SET // // MessageText: // // The Trusted Platform Module (TPM) already has an owner. // public static final int TPM_E_OWNER_SET = 0x80280014; // // MessageId: TPM_E_RESOURCES // // MessageText: // // The TPM has insufficient internal resources to perform the requested // action. // public static final int TPM_E_RESOURCES = 0x80280015; // // MessageId: TPM_E_SHORTRANDOM // // MessageText: // // A random string was too short. // public static final int TPM_E_SHORTRANDOM = 0x80280016; // // MessageId: TPM_E_SIZE // // MessageText: // // The TPM does not have the space to perform the operation. // public static final int TPM_E_SIZE = 0x80280017; // // MessageId: TPM_E_WRONGPCRVAL // // MessageText: // // The named PCR value does not match the current PCR value. // public static final int TPM_E_WRONGPCRVAL = 0x80280018; // // MessageId: TPM_E_BAD_PARAM_SIZE // // MessageText: // // The paramSize argument to the command has the incorrect value . // public static final int TPM_E_BAD_PARAM_SIZE = 0x80280019; // // MessageId: TPM_E_SHA_THREAD // // MessageText: // // There is no existing SHA-1 thread. // public static final int TPM_E_SHA_THREAD = 0x8028001A; // // MessageId: TPM_E_SHA_ERROR // // MessageText: // // The calculation is unable to proceed because the existing SHA-1 thread // has already encountered an error. // public static final int TPM_E_SHA_ERROR = 0x8028001B; // // MessageId: TPM_E_FAILEDSELFTEST // // MessageText: // // Self-test has failed and the TPM has shutdown. // public static final int TPM_E_FAILEDSELFTEST = 0x8028001C; // // MessageId: TPM_E_AUTH2FAIL // // MessageText: // // The authorization for the second key in a=2 key function failed // authorization. // public static final int TPM_E_AUTH2FAIL = 0x8028001D; // // MessageId: TPM_E_BADTAG // // MessageText: // // The tag value sent to for a command is invalid. // public static final int TPM_E_BADTAG = 0x8028001E; // // MessageId: TPM_E_IOERROR // // MessageText: // // An IO error occurred transmitting information to the TPM. // public static final int TPM_E_IOERROR = 0x8028001F; // // MessageId: TPM_E_ENCRYPT_ERROR // // MessageText: // // The encryption process had a problem. // public static final int TPM_E_ENCRYPT_ERROR = 0x80280020; // // MessageId: TPM_E_DECRYPT_ERROR // // MessageText: // // The decryption process did not complete. // public static final int TPM_E_DECRYPT_ERROR = 0x80280021; // // MessageId: TPM_E_INVALID_AUTHHANDLE // // MessageText: // // An invalid handle was used. // public static final int TPM_E_INVALID_AUTHHANDLE = 0x80280022; // // MessageId: TPM_E_NO_ENDORSEMENT // // MessageText: // // The TPM does not have an Endorsement Key (EK) installed. // public static final int TPM_E_NO_ENDORSEMENT = 0x80280023; // // MessageId: TPM_E_INVALID_KEYUSAGE // // MessageText: // // The usage of a key is not allowed. // public static final int TPM_E_INVALID_KEYUSAGE = 0x80280024; // // MessageId: TPM_E_WRONG_ENTITYTYPE // // MessageText: // // The submitted entity type is not allowed. // public static final int TPM_E_WRONG_ENTITYTYPE = 0x80280025; // // MessageId: TPM_E_INVALID_POSTINIT // // MessageText: // // The command was received in the wrong sequence relative to TPM_Init and a // subsequent TPM_Startup. // public static final int TPM_E_INVALID_POSTINIT = 0x80280026; // // MessageId: TPM_E_INAPPROPRIATE_SIG // // MessageText: // // Signed data cannot include additional DER information. // public static final int TPM_E_INAPPROPRIATE_SIG = 0x80280027; // // MessageId: TPM_E_BAD_KEY_PROPERTY // // MessageText: // // The key properties in TPM_KEY_PARMs are not supported by this TPM. // public static final int TPM_E_BAD_KEY_PROPERTY = 0x80280028; // // MessageId: TPM_E_BAD_MIGRATION // // MessageText: // // The migration properties of this key are incorrect. // public static final int TPM_E_BAD_MIGRATION = 0x80280029; // // MessageId: TPM_E_BAD_SCHEME // // MessageText: // // The signature or encryption scheme for this key is incorrect or not // permitted in this situation. // public static final int TPM_E_BAD_SCHEME = 0x8028002A; // // MessageId: TPM_E_BAD_DATASIZE // // MessageText: // // The size of the data (or blob) parameter is bad or inconsistent with the // referenced key. // public static final int TPM_E_BAD_DATASIZE = 0x8028002B; // // MessageId: TPM_E_BAD_MODE // // MessageText: // // A mode parameter is bad, such as capArea or subCapArea for // TPM_GetCapability, phsicalPresence parameter for TPM_PhysicalPresence, or // migrationType for TPM_CreateMigrationBlob. // public static final int TPM_E_BAD_MODE = 0x8028002C; // // MessageId: TPM_E_BAD_PRESENCE // // MessageText: // // Either the physicalPresence or physicalPresenceLock bits have the wrong // value. // public static final int TPM_E_BAD_PRESENCE = 0x8028002D; // // MessageId: TPM_E_BAD_VERSION // // MessageText: // // The TPM cannot perform this version of the capability. // public static final int TPM_E_BAD_VERSION = 0x8028002E; // // MessageId: TPM_E_NO_WRAP_TRANSPORT // // MessageText: // // The TPM does not allow for wrapped transport sessions. // public static final int TPM_E_NO_WRAP_TRANSPORT = 0x8028002F; // // MessageId: TPM_E_AUDITFAIL_UNSUCCESSFUL // // MessageText: // // TPM audit construction failed and the underlying command was returning a // failure code also. // public static final int TPM_E_AUDITFAIL_UNSUCCESSFUL = 0x80280030; // // MessageId: TPM_E_AUDITFAIL_SUCCESSFUL // // MessageText: // // TPM audit construction failed and the underlying command was returning // success. // public static final int TPM_E_AUDITFAIL_SUCCESSFUL = 0x80280031; // // MessageId: TPM_E_NOTRESETABLE // // MessageText: // // Attempt to reset a PCR register that does not have the resettable // attribute. // public static final int TPM_E_NOTRESETABLE = 0x80280032; // // MessageId: TPM_E_NOTLOCAL // // MessageText: // // Attempt to reset a PCR register that requires locality and locality // modifier not part of command transport. // public static final int TPM_E_NOTLOCAL = 0x80280033; // // MessageId: TPM_E_BAD_TYPE // // MessageText: // // Make identity blob not properly typed. // public static final int TPM_E_BAD_TYPE = 0x80280034; // // MessageId: TPM_E_INVALID_RESOURCE // // MessageText: // // When saving context identified resource type does not match actual // resource. // public static final int TPM_E_INVALID_RESOURCE = 0x80280035; // // MessageId: TPM_E_NOTFIPS // // MessageText: // // The TPM is attempting to execute a command only available when in FIPS // mode. // public static final int TPM_E_NOTFIPS = 0x80280036; // // MessageId: TPM_E_INVALID_FAMILY // // MessageText: // // The command is attempting to use an invalid family ID. // public static final int TPM_E_INVALID_FAMILY = 0x80280037; // // MessageId: TPM_E_NO_NV_PERMISSION // // MessageText: // // The permission to manipulate the NV storage is not available. // public static final int TPM_E_NO_NV_PERMISSION = 0x80280038; // // MessageId: TPM_E_REQUIRES_SIGN // // MessageText: // // The operation requires a signed command. // public static final int TPM_E_REQUIRES_SIGN = 0x80280039; // // MessageId: TPM_E_KEY_NOTSUPPORTED // // MessageText: // // Wrong operation to load an NV key. // public static final int TPM_E_KEY_NOTSUPPORTED = 0x8028003A; // // MessageId: TPM_E_AUTH_CONF;ICT // // MessageText: // // NV_LoadKey blob requires both owner and blob authorization. // public static final int TPM_E_AUTH_CONFLICT = 0x8028003B; // // MessageId: TPM_E_AREA_LOCKED // // MessageText: // // The NV area is locked and not writtable. // public static final int TPM_E_AREA_LOCKED = 0x8028003C; // // MessageId: TPM_E_BAD_LOCALITY // // MessageText: // // The locality is incorrect for the attempted operation. // public static final int TPM_E_BAD_LOCALITY = 0x8028003D; // // MessageId: TPM_E_READ_ONLY // // MessageText: // // The NV area is read only and can't be written to. // public static final int TPM_E_READ_ONLY = 0x8028003E; // // MessageId: TPM_E_PER_NOWRITE // // MessageText: // // There is no protection on the write to the NV area. // public static final int TPM_E_PER_NOWRITE = 0x8028003F; // // MessageId: TPM_E_FAMILYCOUNT // // MessageText: // // The family count value does not match. // public static final int TPM_E_FAMILYCOUNT = 0x80280040; // // MessageId: TPM_E_WRITE_LOCKED // // MessageText: // // The NV area has already been written to. // public static final int TPM_E_WRITE_LOCKED = 0x80280041; // // MessageId: TPM_E_BAD_ATTRIBUTES // // MessageText: // // The NV area attributes conFLIct. // public static final int TPM_E_BAD_ATTRIBUTES = 0x80280042; // // MessageId: TPM_E_INVALID_STRUCTURE // // MessageText: // // The structure tag and version are invalid or inconsistent. // public static final int TPM_E_INVALID_STRUCTURE = 0x80280043; // // MessageId: TPM_E_KEY_OWNER_CONTROL // // MessageText: // // The key is under control of the TPM Owner and can only be evicted by the // TPM Owner. // public static final int TPM_E_KEY_OWNER_CONTROL = 0x80280044; // // MessageId: TPM_E_BAD_COUNTER // // MessageText: // // The counter handle is incorrect. // public static final int TPM_E_BAD_COUNTER = 0x80280045; // // MessageId: TPM_E_NOT_FULLWRITE // // MessageText: // // The write is not a complete write of the area. // public static final int TPM_E_NOT_FULLWRITE = 0x80280046; // // MessageId: TPM_E_CONTEXT_GAP // // MessageText: // // The gap between saved context counts is too large. // public static final int TPM_E_CONTEXT_GAP = 0x80280047; // // MessageId: TPM_E_MAXNVWRITES // // MessageText: // // The maximum number of NV writes without an owner has been exceeded. // public static final int TPM_E_MAXNVWRITES = 0x80280048; // // MessageId: TPM_E_NOOPERATOR // // MessageText: // // No operator AuthData value is set. // public static final int TPM_E_NOOPERATOR = 0x80280049; // // MessageId: TPM_E_RESOURCEMISSING // // MessageText: // // The resource pointed to by context is not loaded. // public static final int TPM_E_RESOURCEMISSING = 0x8028004A; // // MessageId: TPM_E_DELEGATE_LOCK // // MessageText: // // The delegate administration is locked. // public static final int TPM_E_DELEGATE_LOCK = 0x8028004B; // // MessageId: TPM_E_DELEGATE_FAMILY // // MessageText: // // Attempt to manage a family other then the delegated family. // public static final int TPM_E_DELEGATE_FAMILY = 0x8028004C; // // MessageId: TPM_E_DELEGATE_ADMIN // // MessageText: // // Delegation table management not enabled. // public static final int TPM_E_DELEGATE_ADMIN = 0x8028004D; // // MessageId: TPM_E_TRANSPORT_NOTEXCLUSIVE // // MessageText: // // There was a command executed outside of an exclusive transport session. // public static final int TPM_E_TRANSPORT_NOTEXCLUSIVE = 0x8028004E; // // MessageId: TPM_E_OWNER_CONTROL // // MessageText: // // Attempt to context save a owner evict controlled key. // public static final int TPM_E_OWNER_CONTROL = 0x8028004F; // // MessageId: TPM_E_DAA_RESOURCES // // MessageText: // // The DAA command has no resources availble to execute the command. // public static final int TPM_E_DAA_RESOURCES = 0x80280050; // // MessageId: TPM_E_DAA_INPUT_DATA0 // // MessageText: // // The consistency check on DAA parameter inputData0 has failed. // public static final int TPM_E_DAA_INPUT_DATA0 = 0x80280051; // // MessageId: TPM_E_DAA_INPUT_DATA1 // // MessageText: // // The consistency check on DAA parameter inputData1 has failed. // public static final int TPM_E_DAA_INPUT_DATA1 = 0x80280052; // // MessageId: TPM_E_DAA_ISSUER_SETTINGS // // MessageText: // // The consistency check on DAA_issuerSettings has failed. // public static final int TPM_E_DAA_ISSUER_SETTINGS = 0x80280053; // // MessageId: TPM_E_DAA_TPM_SETTINGS // // MessageText: // // The consistency check on DAA_tpmSpecific has failed. // public static final int TPM_E_DAA_TPM_SETTINGS = 0x80280054; // // MessageId: TPM_E_DAA_STAGE // // MessageText: // // The atomic process indicated by the submitted DAA command is not the // expected process. // public static final int TPM_E_DAA_STAGE = 0x80280055; // // MessageId: TPM_E_DAA_ISSUER_VALIDITY // // MessageText: // // The issuer's validity check has detected an inconsistency. // public static final int TPM_E_DAA_ISSUER_VALIDITY = 0x80280056; // // MessageId: TPM_E_DAA_WRONG_W // // MessageText: // // The consistency check on w has failed. // public static final int TPM_E_DAA_WRONG_W = 0x80280057; // // MessageId: TPM_E_BAD_HANDLE // // MessageText: // // The handle is incorrect. // public static final int TPM_E_BAD_HANDLE = 0x80280058; // // MessageId: TPM_E_BAD_DELEGATE // // MessageText: // // Delegation is not correct. // public static final int TPM_E_BAD_DELEGATE = 0x80280059; // // MessageId: TPM_E_BADCONTEXT // // MessageText: // // The context blob is invalid. // public static final int TPM_E_BADCONTEXT = 0x8028005A; // // MessageId: TPM_E_TOOMANYCONTEXTS // // MessageText: // // Too many contexts held by the TPM. // public static final int TPM_E_TOOMANYCONTEXTS = 0x8028005B; // // MessageId: TPM_E_MA_TICKET_SIGNATURE // // MessageText: // // Migration authority signature validation failure. // public static final int TPM_E_MA_TICKET_SIGNATURE = 0x8028005C; // // MessageId: TPM_E_MA_DESTINATION // // MessageText: // // Migration destination not authenticated. // public static final int TPM_E_MA_DESTINATION = 0x8028005D; // // MessageId: TPM_E_MA_SOURCE // // MessageText: // // Migration source incorrect. // public static final int TPM_E_MA_SOURCE = 0x8028005E; // // MessageId: TPM_E_MA_AUTHORITY // // MessageText: // // Incorrect migration authority. // public static final int TPM_E_MA_AUTHORITY = 0x8028005F; // // MessageId: TPM_E_PERMANENTEK // // MessageText: // // Attempt to revoke the EK and the EK is not revocable. // public static final int TPM_E_PERMANENTEK = 0x80280061; // // MessageId: TPM_E_BAD_SIGNATURE // // MessageText: // // Bad signature of CMK ticket. // public static final int TPM_E_BAD_SIGNATURE = 0x80280062; // // MessageId: TPM_E_NOCONTEXTSPACE // // MessageText: // // There is no room in the context list for additional contexts. // public static final int TPM_E_NOCONTEXTSPACE = 0x80280063; // // TPM vendor specific hardware errors {0x0400..0x04ff} // // // MessageId: TPM_E_COMMAND_BLOCKED // // MessageText: // // The command was blocked. // public static final int TPM_E_COMMAND_BLOCKED = 0x80280400; // // MessageId: TPM_E_INVALID_HANDLE // // MessageText: // // The specified handle was not found. // public static final int TPM_E_INVALID_HANDLE = 0x80280401; // // MessageId: TPM_E_DUPLICATE_VHANDLE // // MessageText: // // The TPM returned a duplicate handle and the command needs to be // resubmitted. // public static final int TPM_E_DUPLICATE_VHANDLE = 0x80280402; // // MessageId: TPM_E_EMBEDDED_COMMAND_BLOCKED // // MessageText: // // The command within the transport was blocked. // public static final int TPM_E_EMBEDDED_COMMAND_BLOCKED = 0x80280403; // // MessageId: TPM_E_EMBEDDED_COMMAND_UNSUPPORTED // // MessageText: // // The command within the transport is not supported. // public static final int TPM_E_EMBEDDED_COMMAND_UNSUPPORTED = 0x80280404; // // TPM non-fatal hardware errors {0x0800..0x08ff} // // // MessageId: TPM_E_RETRY // // MessageText: // // The TPM is too busy to respond to the command immediately, but the // command could be resubmitted at a later time. // public static final int TPM_E_RETRY = 0x80280800; // // MessageId: TPM_E_NEEDS_SELFTEST // // MessageText: // // SelfTestFull has not been run. // public static final int TPM_E_NEEDS_SELFTEST = 0x80280801; // // MessageId: TPM_E_DOING_SELFTEST // // MessageText: // // The TPM is currently executing a full selftest. // public static final int TPM_E_DOING_SELFTEST = 0x80280802; // // MessageId: TPM_E_DEFEND_LOCK_RUNNING // // MessageText: // // The TPM is defending against dictionary attacks and is in a time-out // period. // public static final int TPM_E_DEFEND_LOCK_RUNNING = 0x80280803; // // TPM Base Services error codes {0x4000..0x40ff} // // // MessageId: TBS_E_INTERNAL_ERROR // // MessageText: // // An internal software error has been detected. // public static final int TBS_E_INTERNAL_ERROR = 0x80284001; // // MessageId: TBS_E_BAD_PARAMETER // // MessageText: // // One or more input parameters is bad. // public static final int TBS_E_BAD_PARAMETER = 0x80284002; // // MessageId: TBS_E_INVALID_OUTPUT_POINTER // // MessageText: // // A specified output pointer is bad. // public static final int TBS_E_INVALID_OUTPUT_POINTER = 0x80284003; // // MessageId: TBS_E_INVALID_CONTEXT // // MessageText: // // The specified context handle does not refer to a valid context. // public static final int TBS_E_INVALID_CONTEXT = 0x80284004; // // MessageId: TBS_E_INSUFFICIENT_BUFFER // // MessageText: // // A specified output buffer is too small. // public static final int TBS_E_INSUFFICIENT_BUFFER = 0x80284005; // // MessageId: TBS_E_IOERROR // // MessageText: // // An error occurred while communicating with the TPM. // public static final int TBS_E_IOERROR = 0x80284006; // // MessageId: TBS_E_INVALID_CONTEXT_PARAM // // MessageText: // // One or more context parameters is invalid. // public static final int TBS_E_INVALID_CONTEXT_PARAM = 0x80284007; // // MessageId: TBS_E_SERVICE_NOT_RUNNING // // MessageText: // // The TBS service is not running and could not be started. // public static final int TBS_E_SERVICE_NOT_RUNNING = 0x80284008; // // MessageId: TBS_E_TOO_MANY_TBS_CONTEXTS // // MessageText: // // A new context could not be created because there are too many open // contexts. // public static final int TBS_E_TOO_MANY_TBS_CONTEXTS = 0x80284009; // // MessageId: TBS_E_TOO_MANY_RESOURCES // // MessageText: // // A new virtual resource could not be created because there are too many // open // virtual resources. // public static final int TBS_E_TOO_MANY_RESOURCES = 0x8028400A; // // MessageId: TBS_E_SERVICE_START_PENDING // // MessageText: // // The TBS service has been started but is not yet running. // public static final int TBS_E_SERVICE_START_PENDING = 0x8028400B; // // MessageId: TBS_E_PPI_NOT_SUPPORTED // // MessageText: // // The physical presence interface is not supported. // public static final int TBS_E_PPI_NOT_SUPPORTED = 0x8028400C; // // MessageId: TBS_E_COMMAND_CANCELED // // MessageText: // // The command was canceled. // public static final int TBS_E_COMMAND_CANCELED = 0x8028400D; // // MessageId: TBS_E_BUFFER_TOO_LARGE // // MessageText: // // The input or output buffer is too large. // public static final int TBS_E_BUFFER_TOO_LARGE = 0x8028400E; // // MessageId: TBS_E_TPM_NOT_FOUND // // MessageText: // // A compatible Trusted Platform Module (TPM) Security Device cannot be // found on this computer. // public static final int TBS_E_TPM_NOT_FOUND = 0x8028400F; // // MessageId: TBS_E_SERVICE_DISABLED // // MessageText: // // The TBS service has been disabled. // public static final int TBS_E_SERVICE_DISABLED = 0x80284010; // // TPM API error codes {0x0100..0x01ff} // // // MessageId: TPMAPI_E_INVALID_STATE // // MessageText: // // The command buffer is not in the correct state. // public static final int TPMAPI_E_INVALID_STATE = 0x80290100; // // MessageId: TPMAPI_E_NOT_ENOUGH_DATA // // MessageText: // // The command buffer does not contain enough data to satisfy the request. // public static final int TPMAPI_E_NOT_ENOUGH_DATA = 0x80290101; // // MessageId: TPMAPI_E_TOO_MUCH_DATA // // MessageText: // // The command buffer cannot contain any more data. // public static final int TPMAPI_E_TOO_MUCH_DATA = 0x80290102; // // MessageId: TPMAPI_E_INVALID_OUTPUT_POINTER // // MessageText: // // One or more output parameters was NULL or invalid. // public static final int TPMAPI_E_INVALID_OUTPUT_POINTER = 0x80290103; // // MessageId: TPMAPI_E_INVALID_PARAMETER // // MessageText: // // One or more input parameters is invalid. // public static final int TPMAPI_E_INVALID_PARAMETER = 0x80290104; // // MessageId: TPMAPI_E_OUT_OF_MEMORY // // MessageText: // // Not enough memory was available to satisfy the request. // public static final int TPMAPI_E_OUT_OF_MEMORY = 0x80290105; // // MessageId: TPMAPI_E_BUFFER_TOO_SMALL // // MessageText: // // The specified buffer was too small. // public static final int TPMAPI_E_BUFFER_TOO_SMALL = 0x80290106; // // MessageId: TPMAPI_E_INTERNAL_ERROR // // MessageText: // // An internal error was detected. // public static final int TPMAPI_E_INTERNAL_ERROR = 0x80290107; // // MessageId: TPMAPI_E_ACCESS_DENIED // // MessageText: // // The caller does not have the appropriate rights to perform the requested // operation. // public static final int TPMAPI_E_ACCESS_DENIED = 0x80290108; // // MessageId: TPMAPI_E_AUTHORIZATION_FAILED // // MessageText: // // The specified authorization information was invalid. // public static final int TPMAPI_E_AUTHORIZATION_FAILED = 0x80290109; // // MessageId: TPMAPI_E_INVALID_CONTEXT_HANDLE // // MessageText: // // The specified context handle was not valid. // public static final int TPMAPI_E_INVALID_CONTEXT_HANDLE = 0x8029010A; // // MessageId: TPMAPI_E_TBS_COMMUNICATION_ERROR // // MessageText: // // An error occurred while communicating with the TBS. // public static final int TPMAPI_E_TBS_COMMUNICATION_ERROR = 0x8029010B; // // MessageId: TPMAPI_E_TPM_COMMAND_ERROR // // MessageText: // // The TPM returned an unexpected result. // public static final int TPMAPI_E_TPM_COMMAND_ERROR = 0x8029010C; // // MessageId: TPMAPI_E_MESSAGE_TOO_LARGE // // MessageText: // // The message was too large for the encoding scheme. // public static final int TPMAPI_E_MESSAGE_TOO_LARGE = 0x8029010D; // // MessageId: TPMAPI_E_INVALID_ENCODING // // MessageText: // // The encoding in the blob was not recognized. // public static final int TPMAPI_E_INVALID_ENCODING = 0x8029010E; // // MessageId: TPMAPI_E_INVALID_KEY_SIZE // // MessageText: // // The key size is not valid. // public static final int TPMAPI_E_INVALID_KEY_SIZE = 0x8029010F; // // MessageId: TPMAPI_E_ENCRYPTION_FAILED // // MessageText: // // The encryption operation failed. // public static final int TPMAPI_E_ENCRYPTION_FAILED = 0x80290110; // // MessageId: TPMAPI_E_INVALID_KEY_PARAMS // // MessageText: // // The key parameters structure was not valid // public static final int TPMAPI_E_INVALID_KEY_PARAMS = 0x80290111; // // MessageId: TPMAPI_E_INVALID_MIGRATION_AUTHORIZATION_BLOB // // MessageText: // // The requested supplied data does not appear to be a valid migration // authorization blob. // public static final int TPMAPI_E_INVALID_MIGRATION_AUTHORIZATION_BLOB = 0x80290112; // // MessageId: TPMAPI_E_INVALID_PCR_INDEX // // MessageText: // // The specified PCR index was invalid // public static final int TPMAPI_E_INVALID_PCR_INDEX = 0x80290113; // // MessageId: TPMAPI_E_INVALID_DELEGATE_BLOB // // MessageText: // // The data given does not appear to be a valid delegate blob. // public static final int TPMAPI_E_INVALID_DELEGATE_BLOB = 0x80290114; // // MessageId: TPMAPI_E_INVALID_CONTEXT_PARAMS // // MessageText: // // One or more of the specified context parameters was not valid. // public static final int TPMAPI_E_INVALID_CONTEXT_PARAMS = 0x80290115; // // MessageId: TPMAPI_E_INVALID_KEY_BLOB // // MessageText: // // The data given does not appear to be a valid key blob // public static final int TPMAPI_E_INVALID_KEY_BLOB = 0x80290116; // // MessageId: TPMAPI_E_INVALID_PCR_DATA // // MessageText: // // The specified PCR data was invalid. // public static final int TPMAPI_E_INVALID_PCR_DATA = 0x80290117; // // MessageId: TPMAPI_E_INVALID_OWNER_AUTH // // MessageText: // // The format of the owner auth data was invalid. // public static final int TPMAPI_E_INVALID_OWNER_AUTH = 0x80290118; // // MessageId: TPMAPI_E_FIPS_RNG_CHECK_FAILED // // MessageText: // // The random number generated did not pass FIPS RNG check. // public static final int TPMAPI_E_FIPS_RNG_CHECK_FAILED = 0x80290119; // // TBS implementation error codes {0x0200..0x02ff} // // // MessageId: TBSIMP_E_BUFFER_TOO_SMALL // // MessageText: // // The specified buffer was too small. // public static final int TBSIMP_E_BUFFER_TOO_SMALL = 0x80290200; // // MessageId: TBSIMP_E_CLEANUP_FAILED // // MessageText: // // The context could not be cleaned up. // public static final int TBSIMP_E_CLEANUP_FAILED = 0x80290201; // // MessageId: TBSIMP_E_INVALID_CONTEXT_HANDLE // // MessageText: // // The specified context handle is invalid. // public static final int TBSIMP_E_INVALID_CONTEXT_HANDLE = 0x80290202; // // MessageId: TBSIMP_E_INVALID_CONTEXT_PARAM // // MessageText: // // An invalid context parameter was specified. // public static final int TBSIMP_E_INVALID_CONTEXT_PARAM = 0x80290203; // // MessageId: TBSIMP_E_TPM_ERROR // // MessageText: // // An error occurred while communicating with the TPM // public static final int TBSIMP_E_TPM_ERROR = 0x80290204; // // MessageId: TBSIMP_E_HASH_BAD_KEY // // MessageText: // // No entry with the specified key was found. // public static final int TBSIMP_E_HASH_BAD_KEY = 0x80290205; // // MessageId: TBSIMP_E_DUPLICATE_VHANDLE // // MessageText: // // The specified virtual handle matches a virtual handle already in use. // public static final int TBSIMP_E_DUPLICATE_VHANDLE = 0x80290206; // // MessageId: TBSIMP_E_INVALID_OUTPUT_POINTER // // MessageText: // // The pointer to the returned handle location was NULL or invalid // public static final int TBSIMP_E_INVALID_OUTPUT_POINTER = 0x80290207; // // MessageId: TBSIMP_E_INVALID_PARAMETER // // MessageText: // // One or more parameters is invalid // public static final int TBSIMP_E_INVALID_PARAMETER = 0x80290208; // // MessageId: TBSIMP_E_RPC_INIT_FAILED // // MessageText: // // The RPC subsystem could not be initialized. // public static final int TBSIMP_E_RPC_INIT_FAILED = 0x80290209; // // MessageId: TBSIMP_E_SCHEDULER_NOT_RUNNING // // MessageText: // // The TBS scheduler is not running. // public static final int TBSIMP_E_SCHEDULER_NOT_RUNNING = 0x8029020A; // // MessageId: TBSIMP_E_COMMAND_CANCELED // // MessageText: // // The command was canceled. // public static final int TBSIMP_E_COMMAND_CANCELED = 0x8029020B; // // MessageId: TBSIMP_E_OUT_OF_MEMORY // // MessageText: // // There was not enough memory to fulfill the request // public static final int TBSIMP_E_OUT_OF_MEMORY = 0x8029020C; // // MessageId: TBSIMP_E_LIST_NO_MORE_ITEMS // // MessageText: // // The specified list is empty, or the iteration has reached the end of the // list. // public static final int TBSIMP_E_LIST_NO_MORE_ITEMS = 0x8029020D; // // MessageId: TBSIMP_E_LIST_NOT_FOUND // // MessageText: // // The specified item was not found in the list. // public static final int TBSIMP_E_LIST_NOT_FOUND = 0x8029020E; // // MessageId: TBSIMP_E_NOT_ENOUGH_SPACE // // MessageText: // // The TPM does not have enough space to load the requested resource. // public static final int TBSIMP_E_NOT_ENOUGH_SPACE = 0x8029020F; // // MessageId: TBSIMP_E_NOT_ENOUGH_TPM_CONTEXTS // // MessageText: // // There are too many TPM contexts in use. // public static final int TBSIMP_E_NOT_ENOUGH_TPM_CONTEXTS = 0x80290210; // // MessageId: TBSIMP_E_COMMAND_FAILED // // MessageText: // // The TPM command failed. // public static final int TBSIMP_E_COMMAND_FAILED = 0x80290211; // // MessageId: TBSIMP_E_UNKNOWN_ORDINAL // // MessageText: // // The TBS does not recognize the specified ordinal. // public static final int TBSIMP_E_UNKNOWN_ORDINAL = 0x80290212; // // MessageId: TBSIMP_E_RESOURCE_EXPIRED // // MessageText: // // The requested resource is no longer available. // public static final int TBSIMP_E_RESOURCE_EXPIRED = 0x80290213; // // MessageId: TBSIMP_E_INVALID_RESOURCE // // MessageText: // // The resource type did not match. // public static final int TBSIMP_E_INVALID_RESOURCE = 0x80290214; // // MessageId: TBSIMP_E_NOTHING_TO_UNLOAD // // MessageText: // // No resources can be unloaded. // public static final int TBSIMP_E_NOTHING_TO_UNLOAD = 0x80290215; // // MessageId: TBSIMP_E_HASH_TABLE_FULL // // MessageText: // // No new entries can be added to the hash table. // public static final int TBSIMP_E_HASH_TABLE_FULL = 0x80290216; // // MessageId: TBSIMP_E_TOO_MANY_TBS_CONTEXTS // // MessageText: // // A new TBS context could not be created because there are too many open // contexts. // public static final int TBSIMP_E_TOO_MANY_TBS_CONTEXTS = 0x80290217; // // MessageId: TBSIMP_E_TOO_MANY_RESOURCES // // MessageText: // // A new virtual resource could not be created because there are too many // open virtual resources. // public static final int TBSIMP_E_TOO_MANY_RESOURCES = 0x80290218; // // MessageId: TBSIMP_E_PPI_NOT_SUPPORTED // // MessageText: // // The physical presence interface is not supported. // public static final int TBSIMP_E_PPI_NOT_SUPPORTED = 0x80290219; // // MessageId: TBSIMP_E_TPM_INCOMPATIBLE // // MessageText: // // TBS is not compatible with the version of TPM found on the system. // public static final int TBSIMP_E_TPM_INCOMPATIBLE = 0x8029021A; // // TPM Physical Presence implementation error codes {0x0300..0x03ff} // // // MessageId: TPM_E_PPI_ACPI_FAILURE // // MessageText: // // A general error was detected when attempting to acquire the BIOS's // response to a Physical Presence command. // public static final int TPM_E_PPI_ACPI_FAILURE = 0x80290300; // // MessageId: TPM_E_PPI_USER_ABORT // // MessageText: // // The user failed to confirm the TPM operation request. // public static final int TPM_E_PPI_USER_ABORT = 0x80290301; // // MessageId: TPM_E_PPI_BIOS_FAILURE // // MessageText: // // The BIOS failure prevented the successful execution of the requested TPM // operation (e.g. invalid TPM operation request, BIOS communication error // with the TPM). // public static final int TPM_E_PPI_BIOS_FAILURE = 0x80290302; // // MessageId: TPM_E_PPI_NOT_SUPPORTED // // MessageText: // // The BIOS does not support the physical presence interface. // public static final int TPM_E_PPI_NOT_SUPPORTED = 0x80290303; // // == // Facility Performance Logs & Alerts (PLA) Error Messages // == // // // MessageId: PLA_E_DCS_NOT_FOUND // // MessageText: // // Data Collector Set was not found. // public static final int PLA_E_DCS_NOT_FOUND = 0x80300002; // // MessageId: PLA_E_DCS_IN_USE // // MessageText: // // The Data Collector Set or one of its dependencies is already in use. // public static final int PLA_E_DCS_IN_USE = 0x803000AA; // // MessageId: PLA_E_TOO_MANY_FOLDERS // // MessageText: // // Unable to start Data Collector Set because there are too many folders. // public static final int PLA_E_TOO_MANY_FOLDERS = 0x80300045; // // MessageId: PLA_E_NO_MIN_DISK // // MessageText: // // Not enough free disk space to start Data Collector Set. // public static final int PLA_E_NO_MIN_DISK = 0x80300070; // // MessageId: PLA_E_DCS_ALREADY_EXISTS // // MessageText: // // Data Collector Set already exists. // public static final int PLA_E_DCS_ALREADY_EXISTS = 0x803000B7; // // MessageId: PLA_S_PROPERTY_IGNORED // // MessageText: // // Property value will be ignored. // public static final int PLA_S_PROPERTY_IGNORED = 0x00300100; // // MessageId: PLA_E_PROPERTY_CONFLICT // // MessageText: // // Property value conFLIct. // public static final int PLA_E_PROPERTY_CONFLICT = 0x80300101; // // MessageId: PLA_E_DCS_SINGLETON_REQUIRED // // MessageText: // // The current configuration for this Data Collector Set requires that it // contain exactly one Data Collector. // public static final int PLA_E_DCS_SINGLETON_REQUIRED = 0x80300102; // // MessageId: PLA_E_CREDENTIALS_REQUIRED // // MessageText: // // A user account is required in order to commit the current Data Collector // Set properties. // public static final int PLA_E_CREDENTIALS_REQUIRED = 0x80300103; // // MessageId: PLA_E_DCS_NOT_RUNNING // // MessageText: // // Data Collector Set is not running. // public static final int PLA_E_DCS_NOT_RUNNING = 0x80300104; // // MessageId: PLA_E_CONFLICT_INCL_EXCL_API // // MessageText: // // A conFLIct was detected in the list of include/exclude APIs. Do not // specify the same API in both the include list and the exclude list. // public static final int PLA_E_CONFLICT_INCL_EXCL_API = 0x80300105; // // MessageId: PLA_E_NETWORK_EXE_NOT_VALID // // MessageText: // // The executable path you have specified refers to a network share or UNC // path. // public static final int PLA_E_NETWORK_EXE_NOT_VALID = 0x80300106; // // MessageId: PLA_E_EXE_ALREADY_CONFIGURED // // MessageText: // // The executable path you have specified is already configured for API // tracing. // public static final int PLA_E_EXE_ALREADY_CONFIGURED = 0x80300107; // // MessageId: PLA_E_EXE_PATH_NOT_VALID // // MessageText: // // The executable path you have specified does not exist. Verify that the // specified path is correct. // public static final int PLA_E_EXE_PATH_NOT_VALID = 0x80300108; // // MessageId: PLA_E_DC_ALREADY_EXISTS // // MessageText: // // Data Collector already exists. // public static final int PLA_E_DC_ALREADY_EXISTS = 0x80300109; // // MessageId: PLA_E_DCS_START_WAIT_TIMEOUT // // MessageText: // // The wait for the Data Collector Set start notification has timed out. // public static final int PLA_E_DCS_START_WAIT_TIMEOUT = 0x8030010A; // // MessageId: PLA_E_DC_START_WAIT_TIMEOUT // // MessageText: // // The wait for the Data Collector to start has timed out. // public static final int PLA_E_DC_START_WAIT_TIMEOUT = 0x8030010B; // // MessageId: PLA_E_REPORT_WAIT_TIMEOUT // // MessageText: // // The wait for the report generation tool to finish has timed out. // public static final int PLA_E_REPORT_WAIT_TIMEOUT = 0x8030010C; // // MessageId: PLA_E_NO_DUPLICATES // // MessageText: // // Duplicate items are not allowed. // public static final int PLA_E_NO_DUPLICATES = 0x8030010D; // // MessageId: PLA_E_EXE_FULL_PATH_REQUIRED // // MessageText: // // When specifying the executable that you want to trace, you must specify a // full path to the executable and not just a filename. // public static final int PLA_E_EXE_FULL_PATH_REQUIRED = 0x8030010E; // // MessageId: PLA_E_INVALID_SESSION_NAME // // MessageText: // // The session name provided is invalid. // public static final int PLA_E_INVALID_SESSION_NAME = 0x8030010F; // // MessageId: PLA_E_PLA_CHANNEL_NOT_ENABLED // // MessageText: // // The Event Log channel Microsoft-Windows-Diagnosis-PLA/Operational must be // enabled to perform this operation. // public static final int PLA_E_PLA_CHANNEL_NOT_ENABLED = 0x80300110; // // MessageId: PLA_E_TASKSCHED_CHANNEL_NOT_ENABLED // // MessageText: // // The Event Log channel Microsoft-Windows-TaskScheduler must be enabled to // perform this operation. // public static final int PLA_E_TASKSCHED_CHANNEL_NOT_ENABLED = 0x80300111; // // MessageId: PLA_E_RULES_MANAGER_FAILED // // MessageText: // // The execution of the Rules Manager failed. // public static final int PLA_E_RULES_MANAGER_FAILED = 0x80300112; // // MessageId: PLA_E_CABAPI_FAILURE // // MessageText: // // An error occured while attemption to compress or extract the data. // public static final int PLA_E_CABAPI_FAILURE = 0x80300113; // // == // Full Volume Encryption Error Messages // == // // // MessageId: FVE_E_LOCKED_VOLUME // // MessageText: // // This volume is locked by BitLocker Drive Encryption. Return to the // control panel to unlock volume. // public static final int FVE_E_LOCKED_VOLUME = 0x80310000; // // MessageId: FVE_E_NOT_ENCRYPTED // // MessageText: // // The volume is not encrypted, no key is available. // public static final int FVE_E_NOT_ENCRYPTED = 0x80310001; // // MessageId: FVE_E_NO_TPM_BIOS // // MessageText: // // The BIOS did not correctly communicate with the TPM. Contact the computer // manufacturer for BIOS upgrade instructions. // public static final int FVE_E_NO_TPM_BIOS = 0x80310002; // // MessageId: FVE_E_NO_MBR_METRIC // // MessageText: // // The BIOS did not correctly communicate with the Master Boot Record (MBR). // Contact the computer manufacturer for BIOS upgrade instructions. // public static final int FVE_E_NO_MBR_METRIC = 0x80310003; // // MessageId: FVE_E_NO_BOOTSECTOR_METRIC // // MessageText: // // If there is a bootable CD or DVD in your computer, remove it, restart the // computer and turn on BitLocker again. If the problem persists contact the // computer manufacturer for BIOS upgrade instructions. // public static final int FVE_E_NO_BOOTSECTOR_METRIC = 0x80310004; // // MessageId: FVE_E_NO_BOOTMGR_METRIC // // MessageText: // // You have an incompatible boot sector. Update the boot manager (BOOTMGR). // public static final int FVE_E_NO_BOOTMGR_METRIC = 0x80310005; // // MessageId: FVE_E_WRONG_BOOTMGR // // MessageText: // // You have an incompatible boot manager. Update the boot manager (BOOTMGR). // public static final int FVE_E_WRONG_BOOTMGR = 0x80310006; // // MessageId: FVE_E_SECURE_KEY_REQUIRED // // MessageText: // // No secure key protector has been defined. // public static final int FVE_E_SECURE_KEY_REQUIRED = 0x80310007; // // MessageId: FVE_E_NOT_ACTIVATED // // MessageText: // // BitLocker Drive Encryption is not enabled on this volume. Turn on // BitLocker. // public static final int FVE_E_NOT_ACTIVATED = 0x80310008; // // MessageId: FVE_E_ACTION_NOT_ALLOWED // // MessageText: // // BitLocker Drive Encryption could not perform requested action. This // condition may occur when two requests are issued at the same time. // public static final int FVE_E_ACTION_NOT_ALLOWED = 0x80310009; // // MessageId: FVE_E_AD_SCHEMA_NOT_INSTALLED // // MessageText: // // The Active Directory Domain Services forest does not contain the required // attributes and classes to host BitLocker Drive Encryption or Trusted // Platform Module information. // public static final int FVE_E_AD_SCHEMA_NOT_INSTALLED = 0x8031000A; // // MessageId: FVE_E_AD_INVALID_DATATYPE // // MessageText: // // The type of the data obtained from Active Directory was not expected. // public static final int FVE_E_AD_INVALID_DATATYPE = 0x8031000B; // // MessageId: FVE_E_AD_INVALID_DATASIZE // // MessageText: // // The size of the data obtained from Active Directory was not expected. // public static final int FVE_E_AD_INVALID_DATASIZE = 0x8031000C; // // MessageId: FVE_E_AD_NO_VALUES // // MessageText: // // The attribute read from Active Directory has no (zero) values. // public static final int FVE_E_AD_NO_VALUES = 0x8031000D; // // MessageId: FVE_E_AD_ATTR_NOT_SET // // MessageText: // // The attribute was not set. // public static final int FVE_E_AD_ATTR_NOT_SET = 0x8031000E; // // MessageId: FVE_E_AD_GUID_NOT_FOUND // // MessageText: // // The specified GUID could not be found. // public static final int FVE_E_AD_GUID_NOT_FOUND = 0x8031000F; // // MessageId: FVE_E_BAD_INFORMATION // // MessageText: // // The control block for the encrypted volume is not valid. // public static final int FVE_E_BAD_INFORMATION = 0x80310010; // // MessageId: FVE_E_TOO_SMALL // // MessageText: // // The volume cannot be encrypted because it does not have enough free // space. // public static final int FVE_E_TOO_SMALL = 0x80310011; // // MessageId: FVE_E_SYSTEM_VOLUME // // MessageText: // // The volume cannot be encrypted because it contains system boot // information. // public static final int FVE_E_SYSTEM_VOLUME = 0x80310012; // // MessageId: FVE_E_FAILED_WRONG_FS // // MessageText: // // The volume cannot be encrypted because the file system is not supported. // public static final int FVE_E_FAILED_WRONG_FS = 0x80310013; // // MessageId: FVE_E_FAILED_BAD_FS // // MessageText: // // The file system is corrupt. Run CHKDSK. // public static final int FVE_E_FAILED_BAD_FS = 0x80310014; // // MessageId: FVE_E_NOT_SUPPORTED // // MessageText: // // This volume cannot be encrypted. // public static final int FVE_E_NOT_SUPPORTED = 0x80310015; // // MessageId: FVE_E_BAD_DATA // // MessageText: // // Data supplied is malformed. // public static final int FVE_E_BAD_DATA = 0x80310016; // // MessageId: FVE_E_VOLUME_NOT_BOUND // // MessageText: // // Volume is not bound to the system. // public static final int FVE_E_VOLUME_NOT_BOUND = 0x80310017; // // MessageId: FVE_E_TPM_NOT_OWNED // // MessageText: // // You must take ownership of the Trusted Platform Module (TPM). // public static final int FVE_E_TPM_NOT_OWNED = 0x80310018; // // MessageId: FVE_E_NOT_DATA_VOLUME // // MessageText: // // The volume specified is not a data volume. // public static final int FVE_E_NOT_DATA_VOLUME = 0x80310019; // // MessageId: FVE_E_AD_INSUFFICIENT_BUFFER // // MessageText: // // The buffer supplied to a function was insufficient to contain the // returned data. // public static final int FVE_E_AD_INSUFFICIENT_BUFFER = 0x8031001A; // // MessageId: FVE_E_CONV_READ // // MessageText: // // A read operation failed while converting the volume. // public static final int FVE_E_CONV_READ = 0x8031001B; // // MessageId: FVE_E_CONV_WRITE // // MessageText: // // A write operation failed while converting the volume. // public static final int FVE_E_CONV_WRITE = 0x8031001C; // // MessageId: FVE_E_KEY_REQUIRED // // MessageText: // // One or more key protectors are required for this volume. // public static final int FVE_E_KEY_REQUIRED = 0x8031001D; // // MessageId: FVE_E_CLUSTERING_NOT_SUPPORTED // // MessageText: // // Cluster configurations are not supported. // public static final int FVE_E_CLUSTERING_NOT_SUPPORTED = 0x8031001E; // // MessageId: FVE_E_VOLUME_BOUND_ALREADY // // MessageText: // // The volume is already bound to the system. // public static final int FVE_E_VOLUME_BOUND_ALREADY = 0x8031001F; // // MessageId: FVE_E_OS_NOT_PROTECTED // // MessageText: // // The operating system volume is not protected by BitLocker Drive // Encryption. // public static final int FVE_E_OS_NOT_PROTECTED = 0x80310020; // // MessageId: FVE_E_PROTECTION_DISABLED // // MessageText: // // All protectors are effectively disabled (clear key exists). // public static final int FVE_E_PROTECTION_DISABLED = 0x80310021; // // MessageId: FVE_E_RECOVERY_KEY_REQUIRED // // MessageText: // // A recovery key protector is required. // public static final int FVE_E_RECOVERY_KEY_REQUIRED = 0x80310022; // // MessageId: FVE_E_FOREIGN_VOLUME // // MessageText: // // This volume cannot be bound to a TPM. // public static final int FVE_E_FOREIGN_VOLUME = 0x80310023; // // MessageId: FVE_E_OVERLAPPED_UPDATE // // MessageText: // // The control block for the encrypted volume was updated by another thread. // Try again. // public static final int FVE_E_OVERLAPPED_UPDATE = 0x80310024; // // MessageId: FVE_E_TPM_SRK_AUTH_NOT_ZERO // // MessageText: // // The authorization data for the Storage Root Key (SRK) of the Trusted // Platform Module (TPM) is not zero and is therefore incompatible with // BitLocker. // public static final int FVE_E_TPM_SRK_AUTH_NOT_ZERO = 0x80310025; // // MessageId: FVE_E_FAILED_SECTOR_SIZE // // MessageText: // // The volume encryption algorithm cannot be used on this sector size. // public static final int FVE_E_FAILED_SECTOR_SIZE = 0x80310026; // // MessageId: FVE_E_FAILED_AUTHENTICATION // // MessageText: // // The recovery information provided does not match required recovery // information to unlock the volume. Confirm the information and try again. // public static final int FVE_E_FAILED_AUTHENTICATION = 0x80310027; // // MessageId: FVE_E_NOT_OS_VOLUME // // MessageText: // // The volume specified is not the operating system volume. // public static final int FVE_E_NOT_OS_VOLUME = 0x80310028; // // MessageId: FVE_E_AUTOUNLOCK_ENABLED // // MessageText: // // BitLocker Drive Encryption cannot be turned off. Please turn off the auto // unlock on all other volumes before turning off BitLocker on the current // volume. // public static final int FVE_E_AUTOUNLOCK_ENABLED = 0x80310029; // // MessageId: FVE_E_WRONG_BOOTSECTOR // // MessageText: // // The system partition boot sector does not perform TPM measurements. // public static final int FVE_E_WRONG_BOOTSECTOR = 0x8031002A; // // MessageId: FVE_E_WRONG_SYSTEM_FS // // MessageText: // // BitLocker requires the file system to be NTFS. Convert the volume to // NTFS, then enable BitLocker. // public static final int FVE_E_WRONG_SYSTEM_FS = 0x8031002B; // // MessageId: FVE_E_POLICY_PASSWORD_REQUIRED // // MessageText: // // Group policy requires a recovery password before encryption may begin. // public static final int FVE_E_POLICY_PASSWORD_REQUIRED = 0x8031002C; // // MessageId: FVE_E_CANNOT_SET_FVEK_ENCRYPTED // // MessageText: // // The volume encryption algorithm and key cannot be set on an encrypted // volume. // public static final int FVE_E_CANNOT_SET_FVEK_ENCRYPTED = 0x8031002D; // // MessageId: FVE_E_CANNOT_ENCRYPT_NO_KEY // // MessageText: // // A key must be specified before encryption may begin. // public static final int FVE_E_CANNOT_ENCRYPT_NO_KEY = 0x8031002E; // // MessageId: FVE_E_BOOTABLE_CDDVD // // MessageText: // // BitLocker Drive Encryption detected bootable media (CD, DVD, or USB) in // the computer. Remove the media and restart the computer. // public static final int FVE_E_BOOTABLE_CDDVD = 0x80310030; // // MessageId: FVE_E_PROTECTOR_EXISTS // // MessageText: // // An instance of this key protector already exists on the volume. // public static final int FVE_E_PROTECTOR_EXISTS = 0x80310031; // // MessageId: FVE_E_RELATIVE_PATH // // MessageText: // // The file cannot be saved to a relative path. // public static final int FVE_E_RELATIVE_PATH = 0x80310032; // // MessageId: FVE_E_PROTECTOR_NOT_FOUND // // MessageText: // // The specified key protector was not found on the volume. Try another key // protector. // public static final int FVE_E_PROTECTOR_NOT_FOUND = 0x80310033; // // MessageId: FVE_E_INVALID_KEY_FORMAT // // MessageText: // // The recovery password file on the USB device is corrupt. Try another USB // device. // public static final int FVE_E_INVALID_KEY_FORMAT = 0x80310034; // // MessageId: FVE_E_INVALID_PASSWORD_FORMAT // // MessageText: // // The format of the recovery password file is invalid. Select another // recovery password and try again. // public static final int FVE_E_INVALID_PASSWORD_FORMAT = 0x80310035; // // MessageId: FVE_E_FIPS_RNG_CHECK_FAILED // // MessageText: // // The random number generator check test failed. // public static final int FVE_E_FIPS_RNG_CHECK_FAILED = 0x80310036; // // MessageId: FVE_E_FIPS_PREVENTS_RECOVERY_PASSWORD // // MessageText: // // The group policy setting requiring FIPS compliance prevented the recovery // password from being generated or used. Please contact your domain // administrator for more information. // public static final int FVE_E_FIPS_PREVENTS_RECOVERY_PASSWORD = 0x80310037; // // MessageId: FVE_E_FIPS_PREVENTS_EXTERNAL_KEY_EXPORT // // MessageText: // // The group policy setting requiring FIPS compliance prevented the recovery // password from being saved. Please contact your domain administrator for // more information. // public static final int FVE_E_FIPS_PREVENTS_EXTERNAL_KEY_EXPORT = 0x80310038; // // MessageId: FVE_E_NOT_DECRYPTED // // MessageText: // // The volume must be fully decrypted to complete this operation. // public static final int FVE_E_NOT_DECRYPTED = 0x80310039; // // MessageId: FVE_E_INVALID_PROTECTOR_TYPE // // MessageText: // // The specified key protector is not of the correct type. // public static final int FVE_E_INVALID_PROTECTOR_TYPE = 0x8031003A; // // MessageId: FVE_E_NO_PROTECTORS_TO_TEST // // MessageText: // // No TPM protectors exist on the volume to perform the hardware test. // public static final int FVE_E_NO_PROTECTORS_TO_TEST = 0x8031003B; // // MessageId: FVE_E_KEYFILE_NOT_FOUND // // MessageText: // // The BitLocker startup key or recovery password could not be read from the // USB device. Ensure the USB device is plugged into the computer, then turn // on BitLocker and try again. If the problem persists contact the computer // manufacturer for BIOS upgrade instructions. // public static final int FVE_E_KEYFILE_NOT_FOUND = 0x8031003C; // // MessageId: FVE_E_KEYFILE_INVALID // // MessageText: // // The BitLocker startup key or recovery password file is corrupt or // invalid. // public static final int FVE_E_KEYFILE_INVALID = 0x8031003D; // // MessageId: FVE_E_KEYFILE_NO_VMK // // MessageText: // // The BitLocker encryption key could not be obtained from the startup key // or recovery password. // public static final int FVE_E_KEYFILE_NO_VMK = 0x8031003E; // // MessageId: FVE_E_TPM_DISABLED // // MessageText: // // The Trusted Platform Module (TPM) is disabled. // public static final int FVE_E_TPM_DISABLED = 0x8031003F; // // MessageId: FVE_E_NOT_ALLOWED_IN_SAFE_MODE // // MessageText: // // BitLocker Drive Encryption can only be used for recovery purposes in // Safe-Mode. // public static final int FVE_E_NOT_ALLOWED_IN_SAFE_MODE = 0x80310040; // // MessageId: FVE_E_TPM_INVALID_PCR // // MessageText: // // The Trusted Platform Module (TPM) was not able to unlock the volume // because the system boot information changed. // public static final int FVE_E_TPM_INVALID_PCR = 0x80310041; // // MessageId: FVE_E_TPM_NO_VMK // // MessageText: // // The BitLocker encryption key could not be obtained from the Trusted // Platform Module (TPM). // public static final int FVE_E_TPM_NO_VMK = 0x80310042; // // MessageId: FVE_E_PIN_INVALID // // MessageText: // // The BitLocker encryption key could not be obtained from the Trusted // Platform Module (TPM) and PIN. // public static final int FVE_E_PIN_INVALID = 0x80310043; // // MessageId: FVE_E_AUTH_INVALID_APPLICATION // // MessageText: // // A boot application has changed since BitLocker was enabled. // public static final int FVE_E_AUTH_INVALID_APPLICATION = 0x80310044; // // MessageId: FVE_E_AUTH_INVALID_CONFIG // // MessageText: // // The Boot Configuration Data (BCD) settings have changed since BitLocker // was enabled. // public static final int FVE_E_AUTH_INVALID_CONFIG = 0x80310045; // // MessageId: FVE_E_FIPS_DISABLE_PROTECTION_NOT_ALLOWED // // MessageText: // // The group policy setting requiring FIPS compliance prevented BitLocker // from being disabled. Please contact your domain administrator for more // information. // public static final int FVE_E_FIPS_DISABLE_PROTECTION_NOT_ALLOWED = 0x80310046; // // MessageId: FVE_E_FS_NOT_EXTENDED // // MessageText: // // The file system does not extend to the end of the volume. // public static final int FVE_E_FS_NOT_EXTENDED = 0x80310047; // // MessageId: FVE_E_FIRMWARE_TYPE_NOT_SUPPORTED // // MessageText: // // BitLocker Drive Encryption cannot be enabled on this computer. Contact // the computer manufacturer for BIOS upgrade instructions. // public static final int FVE_E_FIRMWARE_TYPE_NOT_SUPPORTED = 0x80310048; // // MessageId: FVE_E_NO_LICENSE // // MessageText: // // This Windows license does not support BitLocker Drive Encryption. To use // BitLocker Drive Encryption, please upgrade your Windows license. // public static final int FVE_E_NO_LICENSE = 0x80310049; // // MessageId: FVE_E_NOT_ON_STACK // // MessageText: // // Critical BitLocker Drive Encryption system files are not available. Use // Windows Startup Repair to restore files. // public static final int FVE_E_NOT_ON_STACK = 0x8031004A; // // MessageId: FVE_E_FS_MOUNTED // // MessageText: // // This operation cannot be performed while the volume is in use. // public static final int FVE_E_FS_MOUNTED = 0x8031004B; // // MessageId: FVE_E_TOKEN_NOT_IMPERSONATED // // MessageText: // // The access token associated with the current thread is not an // impersonated token. // public static final int FVE_E_TOKEN_NOT_IMPERSONATED = 0x8031004C; // // MessageId: FVE_E_DRY_RUN_FAILED // // MessageText: // // The BitLocker encryption key could not be obtained. // public static final int FVE_E_DRY_RUN_FAILED = 0x8031004D; // // MessageId: FVE_E_REBOOT_REQUIRED // // MessageText: // // No action was taken as a system reboot is required. // public static final int FVE_E_REBOOT_REQUIRED = 0x8031004E; // // MessageId: FVE_E_DEBUGGER_ENABLED // // MessageText: // // Boot debugging is enabled. Run bcdedit to turn it off. // public static final int FVE_E_DEBUGGER_ENABLED = 0x8031004F; // // MessageId: FVE_E_RAW_ACCESS // // MessageText: // // No action was taken as BitLocker Drive Encryption is in raw access mode. // public static final int FVE_E_RAW_ACCESS = 0x80310050; // // MessageId: FVE_E_RAW_BLOCKED // // MessageText: // // BitLocker Drive Encryption cannot enter raw access mode for this volume. // public static final int FVE_E_RAW_BLOCKED = 0x80310051; // // MessageId: FVE_E_BCD_APPLICATIONS_PATH_INCORRECT // // MessageText: // // The path specified in the Boot Configuration Data (BCD) for a BitLocker // Drive Encryption integrity-protected application is incorrect. Please // verify and correct your BCD settings and try again. // public static final int FVE_E_BCD_APPLICATIONS_PATH_INCORRECT = 0x80310052; // // MessageId: FVE_E_NOT_ALLOWED_IN_VERSION // // MessageText: // // BitLocker Drive Encryption can only be used for recovery purposes in this // version of Windows. // public static final int FVE_E_NOT_ALLOWED_IN_VERSION = 0x80310053; // // == // Windows Filtering Platform Error Messages // == // // // MessageId: FWP_E_CALLOUT_NOT_FOUND // // MessageText: // // The callout does not exist. // public static final int FWP_E_CALLOUT_NOT_FOUND = 0x80320001; // // MessageId: FWP_E_CONDITION_NOT_FOUND // // MessageText: // // The filter condition does not exist. // public static final int FWP_E_CONDITION_NOT_FOUND = 0x80320002; // // MessageId: FWP_E_FILTER_NOT_FOUND // // MessageText: // // The filter does not exist. // public static final int FWP_E_FILTER_NOT_FOUND = 0x80320003; // // MessageId: FWP_E_LAYER_NOT_FOUND // // MessageText: // // The layer does not exist. // public static final int FWP_E_LAYER_NOT_FOUND = 0x80320004; // // MessageId: FWP_E_PROVIDER_NOT_FOUND // // MessageText: // // The provider does not exist. // public static final int FWP_E_PROVIDER_NOT_FOUND = 0x80320005; // // MessageId: FWP_E_PROVIDER_CONTEXT_NOT_FOUND // // MessageText: // // The provider context does not exist. // public static final int FWP_E_PROVIDER_CONTEXT_NOT_FOUND = 0x80320006; // // MessageId: FWP_E_SUBLAYER_NOT_FOUND // // MessageText: // // The sublayer does not exist. // public static final int FWP_E_SUBLAYER_NOT_FOUND = 0x80320007; // // MessageId: FWP_E_NOT_FOUND // // MessageText: // // The object does not exist. // public static final int FWP_E_NOT_FOUND = 0x80320008; // // MessageId: FWP_E_ALREADY_EXISTS // // MessageText: // // An object with that GUID or LUID already exists. // public static final int FWP_E_ALREADY_EXISTS = 0x80320009; // // MessageId: FWP_E_IN_USE // // MessageText: // // The object is referenced by other objects so cannot be deleted. // public static final int FWP_E_IN_USE = 0x8032000A; // // MessageId: FWP_E_DYNAMIC_SESSION_IN_PROGRESS // // MessageText: // // The call is not allowed from within a dynamic session. // public static final int FWP_E_DYNAMIC_SESSION_IN_PROGRESS = 0x8032000B; // // MessageId: FWP_E_WRONG_SESSION // // MessageText: // // The call was made from the wrong session so cannot be completed. // public static final int FWP_E_WRONG_SESSION = 0x8032000C; // // MessageId: FWP_E_NO_TXN_IN_PROGRESS // // MessageText: // // The call must be made from within an explicit transaction. // public static final int FWP_E_NO_TXN_IN_PROGRESS = 0x8032000D; // // MessageId: FWP_E_TXN_IN_PROGRESS // // MessageText: // // The call is not allowed from within an explicit transaction. // public static final int FWP_E_TXN_IN_PROGRESS = 0x8032000E; // // MessageId: FWP_E_TXN_ABORTED // // MessageText: // // The explicit transaction has been forcibly cancelled. // public static final int FWP_E_TXN_ABORTED = 0x8032000F; // // MessageId: FWP_E_SESSION_ABORTED // // MessageText: // // The session has been cancelled. // public static final int FWP_E_SESSION_ABORTED = 0x80320010; // // MessageId: FWP_E_INCOMPATIBLE_TXN // // MessageText: // // The call is not allowed from within a read-only transaction. // public static final int FWP_E_INCOMPATIBLE_TXN = 0x80320011; // // MessageId: FWP_E_TIMEOUT // // MessageText: // // The call timed out while waiting to acquire the transaction lock. // public static final int FWP_E_TIMEOUT = 0x80320012; // // MessageId: FWP_E_NET_EVENTS_DISABLED // // MessageText: // // Collection of network diagnostic events is disabled. // public static final int FWP_E_NET_EVENTS_DISABLED = 0x80320013; // // MessageId: FWP_E_INCOMPATIBLE_LAYER // // MessageText: // // The operation is not supported by the specified layer. // public static final int FWP_E_INCOMPATIBLE_LAYER = 0x80320014; // // MessageId: FWP_E_KM_CLIENTS_ONLY // // MessageText: // // The call is allowed for kernel-mode callers only. // public static final int FWP_E_KM_CLIENTS_ONLY = 0x80320015; // // MessageId: FWP_E_LIFETIME_MISMATCH // // MessageText: // // The call tried to associate two objects with incompatible lifetimes. // public static final int FWP_E_LIFETIME_MISMATCH = 0x80320016; // // MessageId: FWP_E_BUILTIN_OBJECT // // MessageText: // // The object is built in so cannot be deleted. // public static final int FWP_E_BUILTIN_OBJECT = 0x80320017; // // MessageId: FWP_E_TOO_MANY_CALLOUTS // // MessageText: // // The maximum number of callouts has been reached. // public static final int FWP_E_TOO_MANY_CALLOUTS = 0x80320018; // // MessageId: FWP_E_NOTIFICATION_DROPPED // // MessageText: // // A notification could not be delivered because a message queue is at its // maximum capacity. // public static final int FWP_E_NOTIFICATION_DROPPED = 0x80320019; // // MessageId: FWP_E_TRAFFIC_MISMATCH // // MessageText: // // The traffic parameters do not match those for the security association // context. // public static final int FWP_E_TRAFFIC_MISMATCH = 0x8032001A; // // MessageId: FWP_E_INCOMPATIBLE_SA_STATE // // MessageText: // // The call is not allowed for the current security association state. // public static final int FWP_E_INCOMPATIBLE_SA_STATE = 0x8032001B; // // MessageId: FWP_E_NULL_POINTER // // MessageText: // // A required pointer is null. // public static final int FWP_E_NULL_POINTER = 0x8032001C; // // MessageId: FWP_E_INVALID_ENUMERATOR // // MessageText: // // An enumerator is not valid. // public static final int FWP_E_INVALID_ENUMERATOR = 0x8032001D; // // MessageId: FWP_E_INVALID_F;AGS // // MessageText: // // The F;ags field contains an invalid value. // public static final int FWP_E_INVALID_FLAGS = 0x8032001E; // // MessageId: FWP_E_INVALID_NET_MASK // // MessageText: // // A network mask is not valid. // public static final int FWP_E_INVALID_NET_MASK = 0x8032001F; // // MessageId: FWP_E_INVALID_RANGE // // MessageText: // // An FWP_RANGE is not valid. // public static final int FWP_E_INVALID_RANGE = 0x80320020; // // MessageId: FWP_E_INVALID_INTERVAL // // MessageText: // // The time interval is not valid. // public static final int FWP_E_INVALID_INTERVAL = 0x80320021; // // MessageId: FWP_E_ZERO_LENGTH_ARRAY // // MessageText: // // An array that must contain at least one element is zero length. // public static final int FWP_E_ZERO_LENGTH_ARRAY = 0x80320022; // // MessageId: FWP_E_NULL_DISPLAY_NAME // // MessageText: // // The displayData.name field cannot be null. // public static final int FWP_E_NULL_DISPLAY_NAME = 0x80320023; // // MessageId: FWP_E_INVALID_ACTION_TYPE // // MessageText: // // The action type is not one of the allowed action types for a filter. // public static final int FWP_E_INVALID_ACTION_TYPE = 0x80320024; // // MessageId: FWP_E_INVALID_WEIGHT // // MessageText: // // The filter weight is not valid. // public static final int FWP_E_INVALID_WEIGHT = 0x80320025; // // MessageId: FWP_E_MATCH_TYPE_MISMATCH // // MessageText: // // A filter condition contains a match type that is not compatible with the // operands. // public static final int FWP_E_MATCH_TYPE_MISMATCH = 0x80320026; // // MessageId: FWP_E_TYPE_MISMATCH // // MessageText: // // An FWP_VALUE or FWPM_CONDITION_VALUE is of the wrong type. // public static final int FWP_E_TYPE_MISMATCH = 0x80320027; // // MessageId: FWP_E_OUT_OF_BOUNDS // // MessageText: // // An integer value is outside the allowed range. // public static final int FWP_E_OUT_OF_BOUNDS = 0x80320028; // // MessageId: FWP_E_RESERVED // // MessageText: // // A reserved field is non-zero. // public static final int FWP_E_RESERVED = 0x80320029; // // MessageId: FWP_E_DUPLICATE_CONDITION // // MessageText: // // A filter cannot contain multiple conditions operating on a single field. // public static final int FWP_E_DUPLICATE_CONDITION = 0x8032002A; // // MessageId: FWP_E_DUPLICATE_KEYMOD // // MessageText: // // A policy cannot contain the same keying module more than once. // public static final int FWP_E_DUPLICATE_KEYMOD = 0x8032002B; // // MessageId: FWP_E_ACTION_INCOMPATIBLE_WITH_LAYER // // MessageText: // // The action type is not compatible with the layer. // public static final int FWP_E_ACTION_INCOMPATIBLE_WITH_LAYER = 0x8032002C; // // MessageId: FWP_E_ACTION_INCOMPATIBLE_WITH_SUBLAYER // // MessageText: // // The action type is not compatible with the sublayer. // public static final int FWP_E_ACTION_INCOMPATIBLE_WITH_SUBLAYER = 0x8032002D; // // MessageId: FWP_E_CONTEXT_INCOMPATIBLE_WITH_LAYER // // MessageText: // // The raw context or the provider context is not compatible with the layer. // public static final int FWP_E_CONTEXT_INCOMPATIBLE_WITH_LAYER = 0x8032002E; // // MessageId: FWP_E_CONTEXT_INCOMPATIBLE_WITH_CALLOUT // // MessageText: // // The raw context or the provider context is not compatible with the // callout. // public static final int FWP_E_CONTEXT_INCOMPATIBLE_WITH_CALLOUT = 0x8032002F; // // MessageId: FWP_E_INCOMPATIBLE_AUTH_METHOD // // MessageText: // // The authentication method is not compatible with the policy type. // public static final int FWP_E_INCOMPATIBLE_AUTH_METHOD = 0x80320030; // // MessageId: FWP_E_INCOMPATIBLE_DH_GROUP // // MessageText: // // The Diffie-Hellman group is not compatible with the policy type. // public static final int FWP_E_INCOMPATIBLE_DH_GROUP = 0x80320031; // // MessageId: FWP_E_EM_NOT_SUPPORTED // // MessageText: // // An IKE policy cannot contain an Extended Mode policy. // public static final int FWP_E_EM_NOT_SUPPORTED = 0x80320032; // // MessageId: FWP_E_NEVER_MATCH // // MessageText: // // The enumeration template or subscription will never match any objects. // public static final int FWP_E_NEVER_MATCH = 0x80320033; // // MessageId: FWP_E_PROVIDER_CONTEXT_MISMATCH // // MessageText: // // The provider context is of the wrong type. // public static final int FWP_E_PROVIDER_CONTEXT_MISMATCH = 0x80320034; // // MessageId: FWP_E_INVALID_PARAMETER // // MessageText: // // The parameter is incorrect. // public static final int FWP_E_INVALID_PARAMETER = 0x80320035; // // MessageId: FWP_E_TOO_MANY_SUBLAYERS // // MessageText: // // The maximum number of sublayers has been reached. // public static final int FWP_E_TOO_MANY_SUBLAYERS = 0x80320036; // // MessageId: FWP_E_CALLOUT_NOTIFICATION_FAILED // // MessageText: // // The notification function for a callout returned an error. // public static final int FWP_E_CALLOUT_NOTIFICATION_FAILED = 0x80320037; // // MessageId: FWP_E_INVALID_AUTH_TRANSFORM // // MessageText: // // The IPsec authentication transform is not valid. // public static final int FWP_E_INVALID_AUTH_TRANSFORM = 0x80320038; // // MessageId: FWP_E_INVALID_CIPHER_TRANSFORM // // MessageText: // // The IPsec cipher transform is not valid. // public static final int FWP_E_INVALID_CIPHER_TRANSFORM = 0x80320039; // // NDIS error codes (ndis.sys) // // // MessageId: ERROR_NDIS_INTERFACE_CLOSING // // MessageText: // // The binding to the network interface is being closed. // public static final int ERROR_NDIS_INTERFACE_CLOSING = 0x80340002; // // MessageId: ERROR_NDIS_BAD_VERSION // // MessageText: // // An invalid version was specified. // public static final int ERROR_NDIS_BAD_VERSION = 0x80340004; // // MessageId: ERROR_NDIS_BAD_CHARACTERISTICS // // MessageText: // // An invalid characteristics table was used. // public static final int ERROR_NDIS_BAD_CHARACTERISTICS = 0x80340005; // // MessageId: ERROR_NDIS_ADAPTER_NOT_FOUND // // MessageText: // // Failed to find the network interface or network interface is not ready. // public static final int ERROR_NDIS_ADAPTER_NOT_FOUND = 0x80340006; // // MessageId: ERROR_NDIS_OPEN_FAILED // // MessageText: // // Failed to open the network interface. // public static final int ERROR_NDIS_OPEN_FAILED = 0x80340007; // // MessageId: ERROR_NDIS_DEVICE_FAILED // // MessageText: // // Network interface has encountered an internal unrecoverable failure. // public static final int ERROR_NDIS_DEVICE_FAILED = 0x80340008; // // MessageId: ERROR_NDIS_MULTICAST_FULL // // MessageText: // // The multicast list on the network interface is full. // public static final int ERROR_NDIS_MULTICAST_FULL = 0x80340009; // // MessageId: ERROR_NDIS_MULTICAST_EXISTS // // MessageText: // // An attempt was made to add a duplicate multicast address to the list. // public static final int ERROR_NDIS_MULTICAST_EXISTS = 0x8034000A; // // MessageId: ERROR_NDIS_MULTICAST_NOT_FOUND // // MessageText: // // At attempt was made to remove a multicast address that was never added. // public static final int ERROR_NDIS_MULTICAST_NOT_FOUND = 0x8034000B; // // MessageId: ERROR_NDIS_REQUEST_ABORTED // // MessageText: // // Netowork interface aborted the request. // public static final int ERROR_NDIS_REQUEST_ABORTED = 0x8034000C; // // MessageId: ERROR_NDIS_RESET_IN_PROGRESS // // MessageText: // // Network interface can not process the request because it is being reset. // public static final int ERROR_NDIS_RESET_IN_PROGRESS = 0x8034000D; // // MessageId: ERROR_NDIS_NOT_SUPPORTED // // MessageText: // // Netword interface does not support this request. // public static final int ERROR_NDIS_NOT_SUPPORTED = 0x803400BB; // // MessageId: ERROR_NDIS_INVALID_PACKET // // MessageText: // // An attempt was made to send an invalid packet on a network interface. // public static final int ERROR_NDIS_INVALID_PACKET = 0x8034000F; // // MessageId: ERROR_NDIS_ADAPTER_NOT_READY // // MessageText: // // Network interface is not ready to complete this operation. // public static final int ERROR_NDIS_ADAPTER_NOT_READY = 0x80340011; // // MessageId: ERROR_NDIS_INVALID_LENGTH // // MessageText: // // The length of the buffer submitted for this operation is not valid. // public static final int ERROR_NDIS_INVALID_LENGTH = 0x80340014; // // MessageId: ERROR_NDIS_INVALID_DATA // // MessageText: // // The data used for this operation is not valid. // public static final int ERROR_NDIS_INVALID_DATA = 0x80340015; // // MessageId: ERROR_NDIS_BUFFER_TOO_SHORT // // MessageText: // // The length of buffer submitted for this operation is too small. // public static final int ERROR_NDIS_BUFFER_TOO_SHORT = 0x80340016; // // MessageId: ERROR_NDIS_INVALID_OID // // MessageText: // // Network interface does not support this OID (Object Identifier) // public static final int ERROR_NDIS_INVALID_OID = 0x80340017; // // MessageId: ERROR_NDIS_ADAPTER_REMOVED // // MessageText: // // The network interface has been removed. // public static final int ERROR_NDIS_ADAPTER_REMOVED = 0x80340018; // // MessageId: ERROR_NDIS_UNSUPPORTED_MEDIA // // MessageText: // // Network interface does not support this media type. // public static final int ERROR_NDIS_UNSUPPORTED_MEDIA = 0x80340019; // // MessageId: ERROR_NDIS_GROUP_ADDRESS_IN_USE // // MessageText: // // An attempt was made to remove a token ring group address that is in use // by other components. // public static final int ERROR_NDIS_GROUP_ADDRESS_IN_USE = 0x8034001A; // // MessageId: ERROR_NDIS_FILE_NOT_FOUND // // MessageText: // // An attempt was made to map a file that can not be found. // public static final int ERROR_NDIS_FILE_NOT_FOUND = 0x8034001B; // // MessageId: ERROR_NDIS_ERROR_READING_FILE // // MessageText: // // An error occured while NDIS tried to map the file. // public static final int ERROR_NDIS_ERROR_READING_FILE = 0x8034001C; // // MessageId: ERROR_NDIS_ALREADY_MAPPED // // MessageText: // // An attempt was made to map a file that is alreay mapped. // public static final int ERROR_NDIS_ALREADY_MAPPED = 0x8034001D; // // MessageId: ERROR_NDIS_RESOURCE_CONFLICT // // MessageText: // // An attempt to allocate a hardware resource failed because the resource is // used by another component. // public static final int ERROR_NDIS_RESOURCE_CONFLICT = 0x8034001E; // // MessageId: ERROR_NDIS_MEDIA_DISCONNECTED // // MessageText: // // The I/O operation failed because network media is disconnected or // wireless access point is out of range. // public static final int ERROR_NDIS_MEDIA_DISCONNECTED = 0x8034001F; // // MessageId: ERROR_NDIS_INVALID_ADDRESS // // MessageText: // // The network address used in the request is invalid. // public static final int ERROR_NDIS_INVALID_ADDRESS = 0x80340022; // // MessageId: ERROR_NDIS_INVALID_DEVICE_REQUEST // // MessageText: // // The specified request is not a valid operation for the target device. // public static final int ERROR_NDIS_INVALID_DEVICE_REQUEST = 0x80340010; // // MessageId: ERROR_NDIS_PAUSED // // MessageText: // // The ofF;oad operation on the network interface has been paused. // public static final int ERROR_NDIS_PAUSED = 0x8034002A; // // MessageId: ERROR_NDIS_INTERFACE_NOT_FOUND // // MessageText: // // Network interface was not found. // public static final int ERROR_NDIS_INTERFACE_NOT_FOUND = 0x8034002B; // // MessageId: ERROR_NDIS_UNSUPPORTED_REVISION // // MessageText: // // The revision number specified in the structure is not supported. // public static final int ERROR_NDIS_UNSUPPORTED_REVISION = 0x8034002C; // // MessageId: ERROR_NDIS_INVALID_PORT // // MessageText: // // The specified port does not exist on this network interface. // public static final int ERROR_NDIS_INVALID_PORT = 0x8034002D; // // MessageId: ERROR_NDIS_INVALID_PORT_STATE // // MessageText: // // The current state of the specified port on this network interface does // not support the requested operation. // public static final int ERROR_NDIS_INVALID_PORT_STATE = 0x8034002E; // // MessageId: ERROR_NDIS_LOW_POWER_STATE // // MessageText: // // The miniport adapter is in low power state. // public static final int ERROR_NDIS_LOW_POWER_STATE = 0x8034002F; // // NDIS error codes (802.11 wireless LAN) // // // MessageId: ERROR_NDIS_DOT11_AUTO_CONFIG_ENABLED // // MessageText: // // The wireless local area network interface is in auto configuration mode // and doesn't support the requested parameter change operation. // public static final int ERROR_NDIS_DOT11_AUTO_CONFIG_ENABLED = 0x80342000; // // MessageId: ERROR_NDIS_DOT11_MEDIA_IN_USE // // MessageText: // // The wireless local area network interface is busy and can not perform the // requested operation. // public static final int ERROR_NDIS_DOT11_MEDIA_IN_USE = 0x80342001; // // MessageId: ERROR_NDIS_DOT11_POWER_STATE_INVALID // // MessageText: // // The wireless local area network interface is power down and doesn't // support the requested operation. // public static final int ERROR_NDIS_DOT11_POWER_STATE_INVALID = 0x80342002; // // NDIS informational code (ndis.sys) // // // MessageId: ERROR_NDIS_INDICATION_REQUIRED // // MessageText: // // The request will be completed later by NDIS status indication. // public static final int ERROR_NDIS_INDICATION_REQUIRED = 0x00340001; } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Wdm.java0000644000175000017500000000512511421126020024361 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.win32.StdCallLibrary; /** * Ported from Wdm.h. * Microsoft Windows DDK. * @author dblock[at]dblock.org */ public interface Wdm extends StdCallLibrary { /** * The KEY_BASIC_INFORMATION structure defines a subset of * the full information that is available for a registry key. */ public static class KEY_BASIC_INFORMATION extends Structure { public KEY_BASIC_INFORMATION() { super(); } public KEY_BASIC_INFORMATION(int size) { NameLength = size - 16; // write time, title index and name length Name = new char[NameLength]; allocateMemory(); } public KEY_BASIC_INFORMATION(Pointer memory) { useMemory(memory); read(); } /** * The last time the key or any of its values changed. */ public long LastWriteTime; /** * Device and intermediate drivers should ignore this member. */ public int TitleIndex; /** * Specifies the size in bytes of the following name. */ public int NameLength; /** * A string of Unicode characters naming the key. * The string is not null-terminated. */ public char[] Name; /** * Name of the key. * @return String. */ public String getName() { return Native.toString(Name); } public void read() { super.read(); Name = new char[NameLength / 2]; readField("Name"); } } /** * The KEY_INFORMATION_CLASS enumeration type represents * the type of information to supply about a registry key. */ public abstract class KEY_INFORMATION_CLASS { public static final int KeyBasicInformation = 0; public static final int KeyNodeInformation = 1; public static final int KeyFullInformation = 2; public static final int KeyNameInformation = 3; public static final int KeyCachedInformation = 4; public static final int KeyVirtualizationInformation = 5; } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Guid.java0000644000175000017500000000254711421126016024534 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.win32.StdCallLibrary; /** * Ported from Guid.h. * Microsoft Windows SDK 6.0A. * @author dblock[at]dblock.org */ public interface Guid extends StdCallLibrary { public static class GUID extends Structure { public static class ByReference extends GUID implements Structure.ByReference { public ByReference() { } public ByReference(Pointer memory) { super(memory); } } public GUID() { } public GUID(Pointer memory) { useMemory(memory); read(); } public int Data1; public short Data2; public short Data3; public byte[] Data4 = new byte[8]; } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/W32FileMonitor.java0000644000175000017500000002403111421126020026352 0ustar janjan/* 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. * * 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 java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.HashMap; import java.util.Map; import com.sun.jna.platform.FileMonitor; import com.sun.jna.platform.win32.WinBase.OVERLAPPED; import com.sun.jna.platform.win32.WinNT.FILE_NOTIFY_INFORMATION; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinNT.HANDLEByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.PointerByReference; public class W32FileMonitor extends FileMonitor { private static final int BUFFER_SIZE = 4096; private class FileInfo { public final File file; public final HANDLE handle; public final int notifyMask; public final boolean recursive; public final FILE_NOTIFY_INFORMATION info = new FILE_NOTIFY_INFORMATION(BUFFER_SIZE); public final IntByReference infoLength = new IntByReference(); public final OVERLAPPED overlapped = new OVERLAPPED(); public FileInfo(File f, HANDLE h, int mask, boolean recurse) { this.file = f; this.handle = h; this.notifyMask = mask; this.recursive = recurse; } } private Thread watcher; private HANDLE port; private final Map fileMap = new HashMap(); private final Map handleMap = new HashMap(); private boolean disposing = false; private void handleChanges(FileInfo finfo) throws IOException { Kernel32 klib = Kernel32.INSTANCE; FILE_NOTIFY_INFORMATION fni = finfo.info; // Need an explicit read, since data was filled in asynchronously fni.read(); do { FileEvent event = null; File file = new File(finfo.file, fni.getFilename()); switch(fni.Action) { case 0: break; case WinNT.FILE_ACTION_MODIFIED: event = new FileEvent(file, FILE_MODIFIED); break; case WinNT.FILE_ACTION_ADDED: event = new FileEvent(file, FILE_CREATED); break; case WinNT.FILE_ACTION_REMOVED: event = new FileEvent(file, FILE_DELETED); break; case WinNT.FILE_ACTION_RENAMED_OLD_NAME: event = new FileEvent(file, FILE_NAME_CHANGED_OLD); break; case WinNT.FILE_ACTION_RENAMED_NEW_NAME: event = new FileEvent(file, FILE_NAME_CHANGED_NEW); break; default: // TODO: other actions... System.err.println("Unrecognized file action '" + fni.Action + "'"); } if (event != null) { notify(event); } fni = fni.next(); } while (fni != null); // trigger the next read if (!finfo.file.exists()) { unwatch(finfo.file); return; } if (!klib.ReadDirectoryChangesW(finfo.handle, finfo.info, finfo.info.size(), finfo.recursive, finfo.notifyMask, finfo.infoLength, finfo.overlapped, null)) { if (! disposing) { int err = klib.GetLastError(); throw new IOException("ReadDirectoryChangesW failed on " + finfo.file + ": '" + Kernel32Util.formatMessageFromLastErrorCode(err) + "' (" + err + ")"); } } } private FileInfo waitForChange() { Kernel32 klib = Kernel32.INSTANCE; IntByReference rcount = new IntByReference(); HANDLEByReference rkey = new HANDLEByReference(); PointerByReference roverlap = new PointerByReference(); klib.GetQueuedCompletionStatus(port, rcount, rkey, roverlap, WinBase.INFINITE); synchronized (this) { return (FileInfo)handleMap.get(rkey.getValue()); } } private int convertMask(int mask) { int result = 0; if ((mask & FILE_CREATED) != 0) { result |= WinNT.FILE_NOTIFY_CHANGE_CREATION; } if ((mask & FILE_DELETED) != 0) { result |= WinNT.FILE_NOTIFY_CHANGE_NAME; } if ((mask & FILE_MODIFIED) != 0) { result |= WinNT.FILE_NOTIFY_CHANGE_LAST_WRITE; } if ((mask & FILE_RENAMED) != 0) { result |= WinNT.FILE_NOTIFY_CHANGE_NAME; } if ((mask & FILE_SIZE_CHANGED) != 0) { result |= WinNT.FILE_NOTIFY_CHANGE_SIZE; } if ((mask & FILE_ACCESSED) != 0) { result |= WinNT.FILE_NOTIFY_CHANGE_LAST_ACCESS; } if ((mask & FILE_ATTRIBUTES_CHANGED) != 0) { result |= WinNT.FILE_NOTIFY_CHANGE_ATTRIBUTES; } if ((mask & FILE_SECURITY_CHANGED) != 0) { result |= WinNT.FILE_NOTIFY_CHANGE_SECURITY; } return result; } private static int watcherThreadID; protected synchronized void watch(File file, int eventMask, boolean recursive) throws IOException { File dir = file; if (!dir.isDirectory()) { recursive = false; dir = file.getParentFile(); } while (dir != null && !dir.exists()) { recursive = true; dir = dir.getParentFile(); } if (dir == null) { throw new FileNotFoundException("No ancestor found for " + file); } Kernel32 klib = Kernel32.INSTANCE; int mask = WinNT.FILE_SHARE_READ | WinNT.FILE_SHARE_WRITE | WinNT.FILE_SHARE_DELETE; int flags = WinNT.FILE_FLAG_BACKUP_SEMANTICS | WinNT.FILE_FLAG_OVERLAPPED; HANDLE handle = klib.CreateFile(file.getAbsolutePath(), WinNT.FILE_LIST_DIRECTORY, mask, null, WinNT.OPEN_EXISTING, flags, null); if (WinBase.INVALID_HANDLE_VALUE.equals(handle)) { throw new IOException("Unable to open " + file + " (" + klib.GetLastError() + ")"); } int notifyMask = convertMask(eventMask); FileInfo finfo = new FileInfo(file, handle, notifyMask, recursive); fileMap.put(file, finfo); handleMap.put(handle, finfo); // Existing port is returned port = klib.CreateIoCompletionPort(handle, port, handle.getPointer(), 0); if (WinBase.INVALID_HANDLE_VALUE.equals(port)) { throw new IOException("Unable to create/use I/O Completion port " + "for " + file + " (" + klib.GetLastError() + ")"); } // TODO: use FileIOCompletionRoutine callback method instead of a // dedicated thread if (!klib.ReadDirectoryChangesW(handle, finfo.info, finfo.info.size(), recursive, notifyMask, finfo.infoLength, finfo.overlapped, null)) { int err = klib.GetLastError(); throw new IOException("ReadDirectoryChangesW failed on " + finfo.file + ", handle " + handle + ": '" + Kernel32Util.formatMessageFromLastErrorCode(err) + "' (" + err + ")"); } if (watcher == null) { watcher = new Thread("W32 File Monitor-" + (watcherThreadID++)) { public void run() { FileInfo finfo; while (true) { finfo = waitForChange(); if (finfo == null) { synchronized(W32FileMonitor.this) { if (fileMap.isEmpty()) { watcher = null; break; } } continue; } try { handleChanges(finfo); } catch(IOException e) { // TODO: how is this best handled? e.printStackTrace(); } } } }; watcher.setDaemon(true); watcher.start(); } } protected synchronized void unwatch(File file) { FileInfo finfo = (FileInfo)fileMap.remove(file); if (finfo != null) { handleMap.remove(finfo.handle); Kernel32 klib = Kernel32.INSTANCE; // bug: the watcher may still be processing this file klib.CloseHandle(finfo.handle); } } public synchronized void dispose() { disposing = true; // unwatch any remaining files in map, allows watcher thread to exit int i = 0; for (Object[] keys = fileMap.keySet().toArray(); !fileMap.isEmpty();) { unwatch((File)keys[i++]); } Kernel32 klib = Kernel32.INSTANCE; klib.PostQueuedCompletionStatus(port, 0, null, null); klib.CloseHandle(port); port = null; watcher = null; } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/WinspoolUtil.java0000644000175000017500000000313711421126022026305 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.platform.win32.Winspool.PRINTER_INFO_1; import com.sun.jna.ptr.IntByReference; /** * Winspool Utility API. * @author dblock[at]dblock.org */ public abstract class WinspoolUtil { public static PRINTER_INFO_1[] getPrinterInfo1() { IntByReference pcbNeeded = new IntByReference(); IntByReference pcReturned = new IntByReference(); Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL, null, 1, null, 0, pcbNeeded, pcReturned); if (pcbNeeded.getValue() <= 0) { return new PRINTER_INFO_1[0]; } PRINTER_INFO_1 pPrinterEnum = new PRINTER_INFO_1(pcbNeeded.getValue()); if(! Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL, null, 1, pPrinterEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded, pcReturned)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } return (PRINTER_INFO_1[]) pPrinterEnum.toArray(pcReturned.getValue()); } }libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java0000644000175000017500000000567011421375602024734 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Structure; import com.sun.jna.platform.win32.WinDef.RECT; import com.sun.jna.win32.StdCallLibrary; /** * 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; } public class RGNDATA extends Structure { public RGNDATAHEADER rdh; public byte[] Buffer; 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; } public class RGBQUAD extends Structure { public byte rgbBlue; public byte rgbGreen; public byte rgbRed; public byte rgbReserved = 0; } public class BITMAPINFO extends Structure { public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER(); public RGBQUAD[] bmiColors = new RGBQUAD[1]; public BITMAPINFO() { this(1); } public BITMAPINFO(int size) { bmiColors = new RGBQUAD[size]; } } public int DIB_RGB_COLORS = 0; public int DIB_PAL_COLORS = 1; }libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/NtDllUtil.java0000644000175000017500000000353211421126016025512 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.platform.win32.Wdm.KEY_BASIC_INFORMATION; import com.sun.jna.platform.win32.Wdm.KEY_INFORMATION_CLASS; import com.sun.jna.platform.win32.WinReg.HKEY; import com.sun.jna.ptr.IntByReference; /** * NtDll Utility API. * @author dblock[at]dblock.org */ public abstract class NtDllUtil { /** * Retrieve the name of an opened registry key. * @param hkey Opened registry key. * @return Basic key name, not including node information. */ public static String getKeyName(HKEY hkey) { IntByReference resultLength = new IntByReference(); int rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation, null, 0, resultLength); if (rc != NTStatus.STATUS_BUFFER_TOO_SMALL || resultLength.getValue() <= 0) { throw new Win32Exception(rc); } KEY_BASIC_INFORMATION keyInformation = new KEY_BASIC_INFORMATION( resultLength.getValue()); rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation, keyInformation, resultLength.getValue(), resultLength); if (rc != NTStatus.STATUS_SUCCESS) { throw new Win32Exception(rc); } return keyInformation.getName(); } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Kernel32.java0000644000175000017500000012755511421126016025240 0ustar janjan/* 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. *

* 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 java.nio.Buffer; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.WinBase.MEMORYSTATUSEX; import com.sun.jna.platform.win32.WinBase.SYSTEM_INFO; import com.sun.jna.platform.win32.WinDef.DWORD; import com.sun.jna.platform.win32.WinDef.HMODULE; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinNT.HANDLEByReference; import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER; import com.sun.jna.platform.win32.WinNT.OSVERSIONINFO; import com.sun.jna.platform.win32.WinNT.OSVERSIONINFOEX; import com.sun.jna.ptr.ByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.PointerByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; /** Definition (incomplete) of kernel32.dll. */ public interface Kernel32 extends StdCallLibrary { Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class, W32APIOptions.UNICODE_OPTIONS); /** * Frees the specified local memory object and invalidates its handle. * @param hLocal * A handle to the local memory object. * @return * If the function succeeds, the return value is NULL. * If the function fails, the return value is equal to a handle to the local memory object. * To get extended error information, call GetLastError. */ Pointer LocalFree(Pointer hLocal); /** * Frees the specified global memory object and invalidates its handle. * @param hGlobal * A handle to the global memory object. * @return * If the function succeeds, the return value is NULL * If the function fails, the return value is equal to a handle to the global memory object. * To get extended error information, call GetLastError. */ Pointer GlobalFree(Pointer hGlobal); /** * The GetModuleHandle function retrieves a module handle for the specified module * if the file has been mapped into the address space of the calling process. * @param name * Pointer to a null-terminated string that contains the name of the module * (either a .dll or .exe file). * @return * If the function succeeds, the return value is a handle to the specified module. * If the function fails, the return value is NULL. To get extended error * information, call GetLastError. */ HMODULE GetModuleHandle(String name); /** * The GetSystemTime function retrieves the current system date and time. * The system time is expressed in Coordinated Universal Time (UTC). * @param lpSystemTime * Pointer to a SYSTEMTIME structure to receive the current system date and time. */ void GetSystemTime(WinBase.SYSTEMTIME lpSystemTime); /** * The GetCurrentThreadId function retrieves the thread identifier of the calling thread. * @return The return value is the thread identifier of the calling thread. */ int GetCurrentThreadId(); /** * The GetCurrentThread function retrieves a pseudo handle for the current thread. * @return The return value is a pseudo handle for the current thread. */ HANDLE GetCurrentThread(); /** * This function returns the process identifier of the calling process. * @return The return value is the process identifier of the calling process. */ int GetCurrentProcessId(); /** * This function returns a pseudohandle for the current process. * @return The return value is a pseudohandle to the current process. */ HANDLE GetCurrentProcess(); /** * The GetProcessId function retrieves the process identifier of the * specified process. * @param process * Handle to the process. The handle must have the PROCESS_QUERY_INFORMATION access right. * @return * If the function succeeds, the return value is the process identifier of the * specified process. If the function fails, the return value is zero. To get * extended error information, call GetLastError. */ int GetProcessId(HANDLE process); /** * The GetProcessVersion function retrieves the major and minor version numbers of the system * on which the specified process expects to run. * @param processId * Process identifier of the process of interest. A value of zero specifies the * calling process. * @return * If the function succeeds, the return value is the version of the system on * which the process expects to run. The high word of the return value contains * the major version number. The low word of the return value contains the minor * version number. If the function fails, the return value is zero. To get extended * error information, call GetLastError. The function fails if ProcessId is an * invalid value. */ int GetProcessVersion(int processId); /** * 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(); /** * The SetLastError function sets the last-error code for the calling thread. * @param dwErrCode * Last-error code for the thread. */ void SetLastError(int dwErrCode); /** * The GetDriveType function determines whether a disk drive is a removable, * fixed, CD-ROM, RAM disk, or network drive. * @param lpRootPathName * Pointer to a null-terminated string that specifies the root directory of * the disk to return information about. A trailing backslash is required. * If this parameter is NULL, the function uses the root of the current directory. * @return * The return value specifies the type of drive. */ int GetDriveType(String lpRootPathName); /** * The FormatMessage function formats a message string. The function requires a * message definition as input. The message definition can come from a buffer * passed into the function. It can come from a message table resource in an * already-loaded module. Or the caller can ask the function to search the * system's message table resource(s) for the message definition. The function * finds the message definition in a message table resource based on a message * identifier and a language identifier. The function copies the formatted message * text to an output buffer, processing any embedded insert sequences if requested. * @param dwFlags * Formatting options, and how to interpret the lpSource parameter. The low-order * byte of dwFlags specifies how the function handles line breaks in the output * buffer. The low-order byte can also specify the maximum width of a formatted * output line. * @param lpSource * Location of the message definition. * @param dwMessageId * Message identifier for the requested message. * @param dwLanguageId * Language identifier for the requested message. * @param lpBuffer * Pointer to a buffer that receives the null-terminated string that specifies the * formatted message. * @param nSize * If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies * the size of the output buffer, in TCHARs. If FORMAT_MESSAGE_ALLOCATE_BUFFER is * set, this parameter specifies the minimum number of TCHARs to allocate for an * output buffer. * @param va_list * Pointer to an array of values that are used as insert values in the formatted message. * @return * If the function succeeds, the return value is the number of TCHARs stored in * the output buffer, excluding the terminating null character. If the function * fails, the return value is zero. To get extended error information, call * GetLastError. */ int FormatMessage(int dwFlags, Pointer lpSource, int dwMessageId, int dwLanguageId, PointerByReference lpBuffer, int nSize, Pointer va_list); /** * The FormatMessage function formats a message string. The function requires a * message definition as input. The message definition can come from a buffer * passed into the function. It can come from a message table resource in an * already-loaded module. Or the caller can ask the function to search the * system's message table resource(s) for the message definition. The function * finds the message definition in a message table resource based on a message * identifier and a language identifier. The function copies the formatted message * text to an output buffer, processing any embedded insert sequences if requested. * @param dwFlags * Formatting options, and how to interpret the lpSource parameter. The low-order * byte of dwFlags specifies how the function handles line breaks in the output * buffer. The low-order byte can also specify the maximum width of a formatted * output line. * @param lpSource * Location of the message definition. * @param dwMessageId * Message identifier for the requested message. * @param dwLanguageId * Language identifier for the requested message. * @param lpBuffer * Pointer to a buffer that receives the null-terminated string that specifies the * formatted message. * @param nSize * If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies * the size of the output buffer, in TCHARs. If FORMAT_MESSAGE_ALLOCATE_BUFFER is * set, this parameter specifies the minimum number of TCHARs to allocate for an * output buffer. * @param va_list * Pointer to an array of values that are used as insert values in the formatted message. * @return * If the function succeeds, the return value is the number of TCHARs stored in * the output buffer, excluding the terminating null character. If the function * fails, the return value is zero. To get extended error information, call * GetLastError. */ int FormatMessage(int dwFlags, Pointer lpSource, int dwMessageId, int dwLanguageId, Buffer lpBuffer, int nSize, Pointer va_list); /** * The CreateFile function creates or opens a file, file stream, directory, physical * disk, volume, console buffer, tape drive, communications resource, mailslot, or * named pipe. The function returns a handle that can be used to access an object. * @param lpFileName * A pointer to a null-terminated string that specifies the name of an object to create or open. * @param dwDesiredAccess * The access to the object, which can be read, write, or both. * @param dwShareMode * The sharing mode of an object, which can be read, write, both, or none. * @param lpSecurityAttributes * A pointer to a SECURITY_ATTRIBUTES structure that determines whether or not * the returned handle can be inherited by child processes. If lpSecurityAttributes * is NULL, the handle cannot be inherited. * @param dwCreationDisposition * An action to take on files that exist and do not exist. * @param dwFlagsAndAttributes * The file attributes and flags. * @param hTemplateFile * Handle to a template file with the GENERIC_READ access right. The template file * supplies file attributes and extended attributes for the file that is being * created. This parameter can be NULL. * @return * If the function succeeds, the return value is an open handle to a specified file. * If a specified file exists before the function call and dwCreationDisposition is * CREATE_ALWAYS or OPEN_ALWAYS, a call to GetLastError returns ERROR_ALREADY_EXISTS, * even when the function succeeds. If a file does not exist before the call, * GetLastError returns 0 (zero). If the function fails, the return value is * INVALID_HANDLE_VALUE. To get extended error information, call GetLastError. */ HANDLE CreateFile(String lpFileName, int dwDesiredAccess, int dwShareMode, WinNT.SECURITY_ATTRIBUTES lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, HANDLE hTemplateFile); /** * The CreateDirectory function creates a new directory. If the underlying file * system supports security on files and directories, the function applies a * specified security descriptor to the new directory. * @param lpPathName * Pointer to a null-terminated string that specifies the path of the directory * to be created. * @param lpSecurityAttributes * Pointer to a SECURITY_ATTRIBUTES structure. The lpSecurityDescriptor member * of the structure specifies a security descriptor for the new directory. If * lpSecurityAttributes is NULL, the directory gets a default security descriptor. * @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 CreateDirectory(String lpPathName, WinNT.SECURITY_ATTRIBUTES lpSecurityAttributes); /** * Creates an input/output (I/O) completion port and associates it with a specified * file handle, or creates an I/O completion port that is not yet associated with a * file handle, allowing association at a later time. * @param FileHandle * An open file handle or INVALID_HANDLE_VALUE. * @param ExistingCompletionPort * A handle to an existing I/O completion port or NULL. * @param CompletionKey * The per-handle user-defined completion key that is included in every I/O completion * packet for the specified file handle. * @param NumberOfConcurrentThreads * The maximum number of threads that the operating system can allow to concurrently * process I/O completion packets for the I/O completion port. * @return * If the function succeeds, the return value is the handle to an I/O completion port: * If the ExistingCompletionPort parameter was NULL, the return value is a new handle. * If the ExistingCompletionPort parameter was a valid I/O completion port handle, the return value is that same handle. * If the FileHandle parameter was a valid handle, that file handle is now associated with the returned I/O completion port. * If the function fails, the return value is NULL. To get extended error information, call the GetLastError function. */ HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort, Pointer CompletionKey, int NumberOfConcurrentThreads); /** * Attempts to dequeue an I/O completion packet from the specified I/O completion * port. If there is no completion packet queued, the function waits for a pending * I/O operation associated with the completion port to complete. * @param CompletionPort * A handle to the completion port. * @param lpNumberOfBytes * A pointer to a variable that receives the number of bytes transferred during * an I/O operation that has completed. * @param lpCompletionKey * A pointer to a variable that receives the completion key value associated with * the file handle whose I/O operation has completed. * @param lpOverlapped * A pointer to a variable that receives the address of the OVERLAPPED structure * that was specified when the completed I/O operation was started. * @param dwMilliseconds * The number of milliseconds that the caller is willing to wait for a completion * packet to appear at the completion port. * @return * Returns nonzero (TRUE) if successful or zero (FALSE) otherwise. */ boolean GetQueuedCompletionStatus(HANDLE CompletionPort, IntByReference lpNumberOfBytes, ByReference lpCompletionKey, PointerByReference lpOverlapped, int dwMilliseconds); /** * Posts an I/O completion packet to an I/O completion port. * @param CompletionPort * A handle to an I/O completion port to which the I/O completion packet is to be posted. * @param dwNumberOfBytesTransferred * The value to be returned through the lpNumberOfBytesTransferred parameter of the GetQueuedCompletionStatus function. * @param dwCompletionKey * The value to be returned through the lpCompletionKey parameter of the GetQueuedCompletionStatus function. * @param lpOverlapped * The value to be returned through the lpOverlapped parameter of the GetQueuedCompletionStatus 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 PostQueuedCompletionStatus(HANDLE CompletionPort, int dwNumberOfBytesTransferred, Pointer dwCompletionKey, WinBase.OVERLAPPED lpOverlapped); /** * Waits until the specified object is in the signaled state or the time-out interval elapses. * To enter an alertable wait state, use the WaitForSingleObjectEx function. * To wait for multiple objects, use the WaitForMultipleObjects. * @param hHandle * A handle to the object. For a list of the object types whose handles can be specified, see the following Remarks section. * If this handle is closed while the wait is still pending, the function's behavior is undefined. * The handle must have the SYNCHRONIZE access right. For more information, see Standard Access Rights. * @param dwMilliseconds * The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the object is signaled or the interval elapses. * If dwMilliseconds is zero, the function does not enter a wait state if the object is not signaled; it always returns immediately. * If dwMilliseconds is INFINITE, the function will return only when the object is signaled. * @return * If the function succeeds, the return value indicates the event that caused the function to return. */ int WaitForSingleObject(HANDLE hHandle, int dwMilliseconds); /** * Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses. * To enter an alertable wait state, use the WaitForMultipleObjectsEx function. * @param nCount * The number of object handles in the array pointed to by lpHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS. * @param hHandle * An array of object handles. For a list of the object types whose handles can be specified, see the following Remarks section. The array can contain handles to objects of different types. * It may not contain multiple copies of the same handle. * If one of these handles is closed while the wait is still pending, the function's behavior is undefined. * The handles must have the SYNCHRONIZE access right. For more information, see Standard Access Rights. * @param bWaitAll * If this parameter is TRUE, the function returns when the state of all objects in the lpHandles array is signaled. * If FALSE, the function returns when the state of any one of the objects is set to signaled. * In the latter case, the return value indicates the object whose state caused the function to return. * @param dwMilliseconds * The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the specified objects are signaled or the interval elapses. * If dwMilliseconds is zero, the function does not enter a wait state if the specified objects are not signaled; it always returns immediately. * If dwMilliseconds is INFINITE, the function will return only when the specified objects are signaled. * @return * If the function succeeds, the return value indicates the event that caused the function to return. */ int WaitForMultipleObjects(int nCount, HANDLE[] hHandle, boolean bWaitAll, int dwMilliseconds); /** * The DuplicateHandle function duplicates an object handle. * * @param hSourceProcessHandle * Handle to the process with the handle to duplicate. * The handle must have the PROCESS_DUP_HANDLE access right. * @param hSourceHandle * Handle to duplicate. This is an open object handle that is valid in the * context of the source process. * @param hTargetProcessHandle * Handle to the process that is to receive the duplicated handle. * The handle must have the PROCESS_DUP_HANDLE access right. * @param lpTargetHandle * Pointer to a variable that receives the duplicate handle. This handle value is valid in * the context of the target process. If hSourceHandle is a pseudo handle returned by * GetCurrentProcess or GetCurrentThread, DuplicateHandle converts it to a real handle to * a process or thread, respectively. * @param dwDesiredAccess * Access requested for the new handle. * @param bInheritHandle * Indicates whether the handle is inheritable. * @param dwOptions * Optional actions. * @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 DuplicateHandle(HANDLE hSourceProcessHandle, HANDLE hSourceHandle, HANDLE hTargetProcessHandle, HANDLEByReference lpTargetHandle, int dwDesiredAccess, boolean bInheritHandle, int dwOptions); /** * 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); // TODO: figure out how OVERLAPPED is used and apply an appropriate mapping interface OVERLAPPED_COMPLETION_ROUTINE extends StdCallCallback { void callback(int errorCode, int nBytesTransferred, WinBase.OVERLAPPED overlapped); } /** * Retrieves information that describes the changes within the specified directory. * The function does not report changes to the specified directory itself. * Note: there's no ReadDirectoryChangesA. * @param directory * A handle to the directory to be monitored. This directory must be opened with the * FILE_LIST_DIRECTORY access right. * @param info * A pointer to the DWORD-aligned formatted buffer in which the read results are to be returned. * @param length * The size of the buffer that is pointed to by the lpBuffer parameter, in bytes. * @param watchSubtree * If this parameter is TRUE, the function monitors the directory tree rooted at the specified * directory. If this parameter is FALSE, the function monitors only the directory specified by * the hDirectory parameter. * @param notifyFilter * The filter criteria that the function checks to determine if the wait operation has completed. * @param bytesReturned * For synchronous calls, this parameter receives the number of bytes transferred into the * lpBuffer parameter. For asynchronous calls, this parameter is undefined. You must use an asynchronous * notification technique to retrieve the number of bytes transferred. * @param overlapped * A pointer to an OVERLAPPED structure that supplies data to be used during asynchronous operation. * Otherwise, this value is NULL. The Offset and OffsetHigh members of this structure are not used. * @param completionRoutine * A pointer to a completion routine to be called when the operation has been completed or canceled and * the calling thread is in an alertable wait state. * @return * If the function succeeds, the return value is nonzero. For synchronous calls, this means that the * operation succeeded. For asynchronous calls, this indicates that the operation was successfully queued. * If the function fails, the return value is zero. To get extended error information, call GetLastError. * If the network redirector or the target file system does not support this operation, the function * fails with ERROR_INVALID_FUNCTION. */ public boolean ReadDirectoryChangesW(HANDLE directory, WinNT.FILE_NOTIFY_INFORMATION info, int length, boolean watchSubtree, int notifyFilter, IntByReference bytesReturned, WinBase.OVERLAPPED overlapped, OVERLAPPED_COMPLETION_ROUTINE completionRoutine); /** * Retrieves the short path form of the specified path. * @param lpszLongPath * The path string. * @param lpdzShortPath * A pointer to a buffer to receive the null-terminated short form of the path that lpszLongPath specifies. * @param cchBuffer * The size of the buffer that lpszShortPath points to, in TCHARs. * @return * If the function succeeds, the return value is the length, in TCHARs, of the string that is copied to * lpszShortPath, not including the terminating null character. * If the lpszShortPath buffer is too small to contain the path, the return value is the size of the buffer, * in TCHARs, that is required to hold the path and the terminating null character. * If the function fails for any other reason, the return value is zero. To get extended error information, * call GetLastError. */ int GetShortPathName(String lpszLongPath, char[] lpdzShortPath, int cchBuffer); /** * The LocalAlloc function allocates the specified number of bytes from the heap. * Windows memory management does not provide a separate local heap and global heap. * @param type * Memory allocation attributes. The default is the LMEM_FIXED value. * @param cbInput * Number of bytes to allocate. If this parameter is zero and the uFlags parameter * specifies LMEM_MOVEABLE, the function returns a handle to a memory object that * is marked as discarded. * @return * If the function succeeds, the return value is a handle to the newly allocated memory object. * If the function fails, the return value is NULL. To get extended error information, call GetLastError. */ Pointer LocalAlloc(int type, int cbInput); /** * 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); /** * Creates or opens a named or unnamed event object. * @param lpEventAttributes * A pointer to a SECURITY_ATTRIBUTES structure. If this parameter is NULL, * the handle cannot be inherited by child processes. * @param bManualReset * If this parameter is TRUE, the function creates a manual-reset event object, * which requires the use of the ResetEvent function to set the event state to nonsignaled. * If this parameter is FALSE, the function creates an auto-reset event object, and system * automatically resets the event state to nonsignaled after a single waiting thread has * been released. * @param bInitialState * If this parameter is TRUE, the initial state of the event object is signaled; otherwise, * it is nonsignaled. * @param lpName * The name of the event object. The name is limited to MAX_PATH characters. Name comparison * is case sensitive. * @return * If the function succeeds, the return value is a handle to the event object. If the named event * object existed before the function call, the function returns a handle to the existing object * and GetLastError returns ERROR_ALREADY_EXISTS. * If the function fails, the return value is NULL. To get extended error information, call GetLastError. */ HANDLE CreateEvent(WinNT.SECURITY_ATTRIBUTES lpEventAttributes, boolean bManualReset, boolean bInitialState, String lpName); /** * Sets the specified event object to the signaled state. * @param hEvent * A handle to the event object. The CreateEvent or OpenEvent function returns this handle. * @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 SetEvent(HANDLE hEvent); /** * Sets the specified event object to the signaled state and then resets it to the nonsignaled * state after releasing the appropriate number of waiting threads. * @param hEvent * A handle to the event object. The CreateEvent or OpenEvent function returns this handle. * @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 PulseEvent(HANDLE hEvent); /** * Creates or opens a named or unnamed file mapping object for a specified file. * @param hFile * A handle to the file from which to create a file mapping object. * @param lpAttributes * A pointer to a SECURITY_ATTRIBUTES structure that determines whether a returned handle can be inherited by child processes. The lpSecurityDescriptor member of the SECURITY_ATTRIBUTES structure specifies a security descriptor for a new file mapping object. * @param flProtect * Specifies the page protection of the file mapping object. All mapped views of the object must be compatible with this protection. * @param dwMaximumSizeHigh * The high-order DWORD of the maximum size of the file mapping object. * @param dwMaximumSizeLow * The low-order DWORD of the maximum size of the file mapping object. * @param lpName * The name of the file mapping object. * @return * If the function succeeds, the return value is a handle to the newly created file mapping object. * If the object exists before the function call, the function returns a handle to the existing object (with its current size, not the specified size), and GetLastError returns ERROR_ALREADY_EXISTS. * If the function fails, the return value is NULL. To get extended error information, call GetLastError. */ HANDLE CreateFileMapping(HANDLE hFile, WinNT.SECURITY_ATTRIBUTES lpAttributes, int flProtect, int dwMaximumSizeHigh, int dwMaximumSizeLow, String lpName); /** * Maps a view of a file mapping into the address space of a calling process. * @param hFileMappingObject * A handle to a file mapping object. The CreateFileMapping and OpenFileMapping functions return this handle. * @param dwDesiredAccess * The type of access to a file mapping object, which determines the protection of the pages. * @param dwFileOffsetHigh * A high-order DWORD of the file offset where the view begins. * @param dwFileOffsetLow * A low-order DWORD of the file offset where the view is to begin. * @param dwNumberOfBytesToMap * The number of bytes of a file mapping to map to the view. * @return * If the function succeeds, the return value is the starting address of the mapped view. * If the function fails, the return value is NULL. To get extended error information, call GetLastError. */ Pointer MapViewOfFile(HANDLE hFileMappingObject, int dwDesiredAccess, int dwFileOffsetHigh, int dwFileOffsetLow, int dwNumberOfBytesToMap); /** * Unmaps a mapped view of a file from the calling process's address space. * @param lpBaseAddress * A pointer to the base address of the mapped view of a file that is to be unmapped. * @return * If the function succeeds, the return value is the starting address of the mapped view. * If the function fails, the return value is NULL. To get extended error information, call GetLastError. */ boolean UnmapViewOfFile(Pointer lpBaseAddress); /** * Retrieves only the NetBIOS name of the local computer. * * @param buffer * A pointer to a buffer that receives the computer name or the cluster virtual server * name. The buffer size should be large enough to contain MAX_COMPUTERNAME_LENGTH + 1 * characters. * @param lpnSize * On input, specifies the size of the buffer, in TCHARs. On output, the number of TCHARs * copied to the destination buffer, not including the terminating null character. If * the buffer is too small, the function fails and GetLastError returns * ERROR_BUFFER_OVERFLOW. The lpnSize parameter specifies the size of the buffer required, * including the terminating null character. * @return * If the function succeeds, the return value is a nonzero value. * If the function fails, the return value is zero. To get extended error information, * call GetLastError. */ public boolean GetComputerName(char[] buffer, IntByReference lpnSize); /** * The OpenThread function opens an existing thread object. * @param dwDesiredAccess * Access to the thread object. This access right is checked against any security * descriptor for the thread. * @param bInheritHandle * If this parameter is TRUE, the new process inherits the handle. If the parameter * is FALSE, the handle is not inherited. * @param dwThreadId * Identifier of the thread to be opened. * @return * If the function succeeds, the return value is an open handle to the specified process. * If the function fails, the return value is NULL. To get extended error information, * call GetLastError. */ HANDLE OpenThread(int dwDesiredAccess, boolean bInheritHandle, int dwThreadId); /** * 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, int IDProcess); /** * The GetTempPath function retrieves the path of the directory designated * for temporary files. * @param nBufferLength * Size of the string buffer identified by lpBuffer, in TCHARs. * @param buffer * Pointer to a string buffer that receives the null-terminated string specifying the * temporary file path. The returned string ends with a backslash, for example, * C:\TEMP\. * @return * If the function succeeds, the return value is the length, in TCHARs, of the string * copied to lpBuffer, not including the terminating null character. If the return value * is greater than nBufferLength, the return value is the length, in TCHARs, of the * buffer required to hold the path. * * If the function fails, the return value is zero. To get extended error information, * call GetLastError. */ DWORD GetTempPath(DWORD nBufferLength, char[] buffer); /** * The GetVersion function returns the current version number of the operating system. * @return * If the function succeeds, the return value includes the major and minor version numbers * of the operating system in the low order word, and information about the operating system * platform in the high order word. */ DWORD GetVersion(); /** * The GetVersionEx function obtains extended information about the version of the operating * system that is currently running. * @param lpVersionInfo * Pointer to an OSVERSIONINFO data structure that the function fills with operating system * version information. * @return * If the function succeeds, the return value is a nonzero value. * If the function fails, the return value is zero. To get extended error information, * call GetLastError. The function fails if you specify an invalid value for the * dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure. */ boolean GetVersionEx(OSVERSIONINFO lpVersionInfo); /** * The GetVersionEx function obtains extended information about the version of the operating * system that is currently running. * @param lpVersionInfo * Pointer to an OSVERSIONINFOEX data structure that the function fills with operating system * version information. * @return * If the function succeeds, the return value is a nonzero value. * If the function fails, the return value is zero. To get extended error information, * call GetLastError. The function fails if you specify an invalid value for the * dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure. */ boolean GetVersionEx(OSVERSIONINFOEX lpVersionInfo); /** * 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); /** * The GetNativeSystemInfo function retrieves information about the current system to an * application running under WOW64. If the function is called from a 64-bit application, * it is equivalent to the GetSystemInfo function. * @param lpSystemInfo * Pointer to a SYSTEM_INFO structure that receives the information. */ void GetNativeSystemInfo(SYSTEM_INFO lpSystemInfo); /** * The IsWow64Process function determines whether the specified process is running under WOW64. * @param hProcess * Handle to a process. * @param Wow64Process * Pointer to a value that is set to TRUE if the process is running under WOW64. * Otherwise, the value is set to FALSE. * @return * If the function succeeds, the return value is a nonzero value. * If the function fails, the return value is zero. To get extended error information, call GetLastError. */ boolean IsWow64Process(HANDLE hProcess, IntByReference Wow64Process); /** * Retrieves information about the system's current usage of both physical and virtual memory. * @param lpBuffer * A pointer to a MEMORYSTATUSEX structure that receives information about current memory availability. * @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 GlobalMemoryStatusEx(MEMORYSTATUSEX lpBuffer); /** * The GetLogicalDriveStrings function fills a buffer with strings that specify * valid drives in the system. * @param nBufferLength * Maximum size of the buffer pointed to by lpBuffer, in TCHARs. This size does not include * the terminating null character. If this parameter is zero, lpBuffer is not used. * @param lpBuffer * Pointer to a buffer that receives a series of null-terminated strings, one for each valid * drive in the system, plus with an additional null character. Each string is a device name. * @return * If the function succeeds, the return value is the length, in characters, of the strings * copied to the buffer, not including the terminating null character. Note that an ANSI-ASCII * null character uses one byte, but a Unicode null character uses two bytes. * If the buffer is not large enough, the return value is greater than nBufferLength. It is * the size of the buffer required to hold the drive strings. * If the function fails, the return value is zero. To get extended error information, use * the GetLastError function. */ DWORD GetLogicalDriveStrings(DWORD nBufferLength, char[] lpBuffer); /** * The GetDiskFreeSpaceEx function retrieves information about the amount of space that is * available on a disk volume, which is the total amount of space, the total amount of free * space, and the total amount of free space available to the user that is associated with * the calling thread. * @param lpDirectoryName * A pointer to a null-terminated string that specifies a directory on a disk. * If this parameter is NULL, the function uses the root of the current disk. * If this parameter is a UNC name, it must include a trailing backslash, for example, * \\MyServer\MyShare\. * This parameter does not have to specify the root directory on a disk. The function * accepts any directory on a disk. * @param lpFreeBytesAvailable * A pointer to a variable that receives the total number of free bytes on a disk that * are available to the user who is associated with the calling thread. * This parameter can be NULL. * @param lpTotalNumberOfBytes * A pointer to a variable that receives the total number of bytes on a disk that are * available to the user who is associated with the calling thread. * This parameter can be NULL. * @param lpTotalNumberOfFreeBytes * A pointer to a variable that receives the total number of free bytes on a disk. * This parameter can be NULL. * @return * If the function succeeds, the return value is nonzero. * If the function fails, the return value is 0 (zero). To get extended error information, * call GetLastError. */ boolean GetDiskFreeSpaceEx(String lpDirectoryName, LARGE_INTEGER.ByReference lpFreeBytesAvailable, LARGE_INTEGER.ByReference lpTotalNumberOfBytes, LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes); } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Crypt32.java0000644000175000017500000001271711421126016025112 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT; import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB; import com.sun.jna.ptr.PointerByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; /** * Crypt32.dll Interface. * @author dblock[at]dblock.org */ public interface Crypt32 extends StdCallLibrary { Crypt32 INSTANCE = (Crypt32) Native.loadLibrary("Crypt32", Crypt32.class, W32APIOptions.UNICODE_OPTIONS); /** * The CryptProtectData function performs encryption on the data in a DATA_BLOB * structure. Typically, only a user with the same logon credential as the encrypter * can decrypt the data. In addition, the encryption and decryption usually must be * done on the same computer. * @param pDataIn * Pointer to a DATA_BLOB structure that contains the plaintext to be encrypted. * @param szDataDescr * String with a readable description of the data to be encrypted. This description * string is included with the encrypted data. This parameter is optional and can * be set to NULL, except on Windows 2000. * @param pOptionalEntropy * Pointer to a DATA_BLOB structure that contains a password or other additional * entropy used to encrypt the data. The DATA_BLOB structure used in the encryption * phase must also be used in the decryption phase. This parameter can be set to NULL * for no additional entropy. * @param pvReserved * Reserved for future use and must be set to NULL. * @param pPromptStruct * Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about * where and when prompts are to be displayed and what the content of those prompts * should be. This parameter can be set to NULL in both the encryption and decryption * phases. * @param dwFlags * One of CRYPTPROTECT_LOCAL_MACHINE, CRYPTPROTECT_UI_FORBIDDEN, CRYPTPROTECT_AUDIT, * CRYPTPROTECT_VERIFY_PROTECTION. * @param pDataOut * Pointer to a DATA_BLOB structure that receives the encrypted data. When you have * finished using the DATA_BLOB structure, free its pbData member by calling the * LocalFree function. * @return * If the function succeeds, the function returns TRUE. If the function fails, * it returns FALSE. For extended error information, call GetLastError. */ public boolean CryptProtectData(DATA_BLOB pDataIn, String szDataDescr, DATA_BLOB pOptionalEntropy, Pointer pvReserved, CRYPTPROTECT_PROMPTSTRUCT pPromptStruct, int dwFlags, DATA_BLOB pDataOut); /** * The CryptUnprotectData function decrypts and does an integrity check of the data in * a DATA_BLOB structure. Usually, only a user with the same logon credentials as the * encrypter can decrypt the data. In addition, the encryption and decryption must be * done on the same computer. * @param pDataIn * Pointer to a DATA_BLOB structure that holds the encrypted data. The DATA_BLOB * structure's cbData member holds the length of the pbData member's byte string that * contains the text to be encrypted. * @param szDataDescr * Pointer to a string-readable description of the encrypted data included with the * encrypted data. This parameter can be set to NULL. When you have finished using * ppszDataDescr, free it by calling the LocalFree function. * @param pOptionalEntropy * Pointer to a DATA_BLOB structure that contains a password or other additional * entropy used when the data was encrypted. This parameter can be set to NULL; * however, if an optional entropy DATA_BLOB structure was used in the encryption * phase, that same DATA_BLOB structure must be used for the decryption phase. * @param pvReserved * Reserved for future use; must be set to NULL. * @param pPromptStruct * Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about * where and when prompts are to be displayed and what the content of those prompts * should be. This parameter can be set to NULL. * @param dwFlags * DWORD value that specifies options for this function. This parameter can be zero, * in which case no option is set, or CRYPTPROTECT_UI_FORBIDDEN. * @param pDataOut * Pointer to a DATA_BLOB structure where the function stores the decrypted data. * When you have finished using the DATA_BLOB structure, free its pbData member by * calling the LocalFree function. * @return * If the function succeeds, the return value is TRUE. If the function fails, the * return value is FALSE. */ public boolean CryptUnprotectData(DATA_BLOB pDataIn, PointerByReference szDataDescr, DATA_BLOB pOptionalEntropy, Pointer pvReserved, CRYPTPROTECT_PROMPTSTRUCT pPromptStruct, int dwFlags, DATA_BLOB pDataOut); } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/ObjBase.java0000644000175000017500000000240211421126016025137 0ustar janjan/* * Copyright 2010 Digital Rapids Corp. */ /* Copyright (c) 2010 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. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.platform.win32.WTypes; /** * Definitions from ObjBase.h * @author scott.palmer */ public interface ObjBase { public static final int CLSCTX_INPROC = (WTypes.CLSCTX_INPROC_SERVER | WTypes.CLSCTX_INPROC_HANDLER); // With DCOM, CLSCTX_REMOTE_SERVER should be included public static final int CLSCTX_ALL = (WTypes.CLSCTX_INPROC_SERVER | WTypes.CLSCTX_INPROC_HANDLER | WTypes.CLSCTX_LOCAL_SERVER | WTypes.CLSCTX_REMOTE_SERVER); public static final int CLSCTX_SERVER = (WTypes.CLSCTX_INPROC_SERVER | WTypes.CLSCTX_LOCAL_SERVER | WTypes.CLSCTX_REMOTE_SERVER); } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Kernel32Util.java0000644000175000017500000001010111421126016026050 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import java.util.ArrayList; import java.util.List; import com.sun.jna.LastErrorException; import com.sun.jna.Native; import com.sun.jna.platform.win32.WinDef.DWORD; import com.sun.jna.platform.win32.WinNT.HRESULT; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.PointerByReference; /** * Kernel32 utility API. * @author dblock[at]dblock.org */ public abstract class Kernel32Util { /** * Get current computer NetBIOS name. * @return * Netbios name. */ public static String getComputerName() { char buffer[] = new char[WinBase.MAX_COMPUTERNAME_LENGTH() + 1]; IntByReference lpnSize = new IntByReference(buffer.length); if (! Kernel32.INSTANCE.GetComputerName(buffer, lpnSize)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } return Native.toString(buffer); } /** * Format a message from an HRESULT. * @param code * HRESULT * @return * Formatted message. */ public static String formatMessageFromHR(HRESULT code) { PointerByReference buffer = new PointerByReference(); if (0 == Kernel32.INSTANCE.FormatMessage( WinBase.FORMAT_MESSAGE_ALLOCATE_BUFFER | WinBase.FORMAT_MESSAGE_FROM_SYSTEM | WinBase.FORMAT_MESSAGE_IGNORE_INSERTS, null, code.intValue(), 0, // TODO: MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) buffer, 0, null)) { throw new LastErrorException(Kernel32.INSTANCE.GetLastError()); } String s = buffer.getValue().getString(0, ! Boolean.getBoolean("w32.ascii")); s = s.replace(".\r",".").replace(".\n","."); Kernel32.INSTANCE.LocalFree(buffer.getValue()); return s; } /** * Format a system message from an error code. * @param code * Error code, typically a result of GetLastError. * @return * Formatted message. */ public static String formatMessageFromLastErrorCode(int code) { return formatMessageFromHR(W32Errors.HRESULT_FROM_WIN32(code)); } /** * Return the path designated for temporary files. * @return * Path. */ public static String getTempPath() { DWORD nBufferLength = new DWORD(WinDef.MAX_PATH); char[] buffer = new char[nBufferLength.intValue()]; if (Kernel32.INSTANCE.GetTempPath(nBufferLength, buffer).intValue() == 0) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } return Native.toString(buffer); } /** * Returns valid drives in the system. * @return * An array of valid drives. */ public static String[] getLogicalDriveStrings() { DWORD dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(new DWORD(0), null); if (dwSize.intValue() <= 0) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } char buf[] = new char[dwSize.intValue()]; dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(dwSize, buf); if (dwSize.intValue() <= 0) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } List drives = new ArrayList(); String drive = ""; // the buffer is double-null-terminated for(int i = 0; i < buf.length - 1; i++) { if (buf[i] == 0) { drives.add(drive); drive = ""; } else { drive += buf[i]; } } return drives.toArray(new String[0]); } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java0000644000175000017500000002052411421126016025271 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.WString; import com.sun.jna.platform.win32.WinNT.PSID; import com.sun.jna.win32.StdCallLibrary; /** * Ported from LMAccess.h. * Windows SDK 6.0A. * @author dblock[at]dblock.org */ public interface LMAccess extends StdCallLibrary { public static class LOCALGROUP_INFO_0 extends Structure { public LOCALGROUP_INFO_0() { super(); } public LOCALGROUP_INFO_0(Pointer memory) { useMemory(memory); read(); } public WString lgrui0_name; } public static class LOCALGROUP_INFO_1 extends Structure { public LOCALGROUP_INFO_1() { super(); } public LOCALGROUP_INFO_1(Pointer memory) { useMemory(memory); read(); } public WString lgrui1_name; public WString lgrui1_comment; } // // bit masks for the NetUserEnum filter parameter. // public static final int FILTER_TEMP_DUPLICATE_ACCOUNT = 0x0001; public static final int FILTER_NORMAL_ACCOUNT = 0x0002; // public static final int FILTER_PROXY_ACCOUNT = 0x0004; public static final int FILTER_INTERDOMAIN_TRUST_ACCOUNT = 0x0008; public static final int FILTER_WORKSTATION_TRUST_ACCOUNT = 0x0010; public static final int FILTER_SERVER_TRUST_ACCOUNT = 0x0020; /** * The USER_INFO_0 structure contains a user account name. */ public static class USER_INFO_0 extends Structure { public USER_INFO_0() { super(); } public USER_INFO_0(Pointer memory) { useMemory(memory); read(); } /** * Pointer to a Unicode string that specifies the name of the user account. */ public WString usri0_name; } /** * The USER_INFO_1 structure contains information about a user account, including * account name, password data, privilege level, and the path to the user's home * directory. */ public static class USER_INFO_1 extends Structure { public USER_INFO_1() { super(); } public USER_INFO_1(Pointer memory) { useMemory(memory); read(); } /** * Pointer to a Unicode string that specifies the name of the user * account. */ public WString usri1_name; /** * Pointer to a Unicode string that specifies the password of the user * indicated by the usri1_name member. */ public WString usri1_password; /** * Specifies a DWORD value that indicates the number of seconds that have * elapsed since the usri1_password member was last changed. */ public int usri1_password_age; /** * Specifies a DWORD value that indicates the level of privilege assigned * to the usri1_name member. */ public int usri1_priv; /** * Pointer to a Unicode string specifying the path of the home directory * for the user specified in the usri1_name member. */ public WString usri1_home_dir; /** * Pointer to a Unicode string that contains a comment to associate with * the user account. */ public WString usri1_comment; /** * Specifies a DWORD value that determines several features. */ public int usri1_flags; /** * Pointer to a Unicode string specifying the path for the user's * logon script file. */ public WString usri1_script_path; } /** * The GROUP_USERS_INFO_0 structure contains global group member information. */ public static class GROUP_USERS_INFO_0 extends Structure { public GROUP_USERS_INFO_0() { super(); } public GROUP_USERS_INFO_0(Pointer memory) { useMemory(memory); read(); } /** * Pointer to a null-terminated Unicode character string that specifies a name. */ public WString grui0_name; } /** * The LOCALGROUP_USERS_INFO_0 structure contains local group member information. */ public static class LOCALGROUP_USERS_INFO_0 extends Structure { public LOCALGROUP_USERS_INFO_0() { super(); } public LOCALGROUP_USERS_INFO_0(Pointer memory) { useMemory(memory); read(); } /** * Pointer to a Unicode string specifying the name of a local group to which the user belongs. */ public WString lgrui0_name; } /** * The GROUP_INFO_0 structure contains the name of a global group in the security * database, which is the security accounts manager (SAM) database or, in the case * of domain controllers, the Active Directory. */ public static class GROUP_INFO_0 extends Structure { public GROUP_INFO_0() { super(); } public GROUP_INFO_0(Pointer memory) { useMemory(memory); read(); } /** * Pointer to a null-terminated Unicode character string that specifies * the name of the global group. */ public WString grpi0_name; } /** * The GROUP_INFO_1 structure contains a global group name and a comment to * associate with the group. */ public static class GROUP_INFO_1 extends Structure { public GROUP_INFO_1() { super(); } public GROUP_INFO_1(Pointer memory) { useMemory(memory); read(); } /** * Pointer to a null-terminated Unicode character string that specifies * the name of the global group. */ public WString grpi1_name; /** * Pointer to a null-terminated Unicode character string that specifies * a remark associated with the global group. This member can be a null * string. The comment can contain MAXCOMMENTSZ characters. */ public WString grpi1_comment; } /** * The GROUP_INFO_2 structure contains information about a global group, including * name, identifier, and resource attributes. */ public static class GROUP_INFO_2 extends Structure { public GROUP_INFO_2() { super(); } public GROUP_INFO_2(Pointer memory) { useMemory(memory); read(); } /** * Pointer to a null-terminated Unicode character string that * specifies the name of the global group. */ public WString grpi2_name; /** * Pointer to a null-terminated Unicode character string that contains a * remark associated with the global group. This member can be a null string. * The comment can contain MAXCOMMENTSZ characters. */ public WString grpi2_comment; /** * Specifies a DWORD value that contains the relative identifier (RID) of * the global group. */ public int grpi2_group_id; /** * These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED, * and SE_GROUP_ENABLED_BY_DEFAULT. */ public int grpi2_attributes; } /** * The GROUP_INFO_3 structure contains information about a global group, including * name, security identifier (SID), and resource attributes. */ public static class GROUP_INFO_3 extends Structure { public GROUP_INFO_3() { super(); } public GROUP_INFO_3(Pointer memory) { useMemory(memory); read(); } /** * Pointer to a null-terminated Unicode character string that * specifies the name of the global group. */ public WString grpi3_name; /** * Pointer to a null-terminated Unicode character string that * contains a remark associated with the global group. This member can be * a null string. The comment can contain MAXCOMMENTSZ characters. */ public WString grpi3_comment; /** * Pointer to a SID structure that contains the security identifier (SID) that * uniquely identifies the global group. */ public PSID grpi3_group_sid; /** * These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED, and * SE_GROUP_ENABLED_BY_DEFAULT. */ public int grpi3_attributes; } // // Privilege levels (USER_INFO_X field usriX_priv (X = 0/1)). // public static final int USER_PRIV_MASK = 3; public static final int USER_PRIV_GUEST = 0; public static final int USER_PRIV_USER = 1; public static final int USER_PRIV_ADMIN = 2; } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/LMErr.java0000644000175000017500000013003011421126016024612 0ustar janjan/* 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. * * 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.win32.StdCallLibrary; /** * Ported from LMErr.h. * @author dblock[at]dblock.org * Windows SDK 6.0A */ public interface LMErr extends StdCallLibrary { public static final int NERR_Success = 0; public static final int NERR_BASE = 2100; public static final int NERR_NetNotStarted = NERR_BASE + 2; /* The workstation driver is not installed. */ public static final int NERR_UnknownServer = NERR_BASE + 3; /* The server could not be located. */ public static final int NERR_ShareMem = NERR_BASE + 4; /* An internal error occurred. The network cannot access a shared memory segment. */ public static final int NERR_NoNetworkResource = NERR_BASE + 5; /* A network resource shortage occurred . */ public static final int NERR_RemoteOnly = NERR_BASE + 6; /* This operation is not supported on workstations. */ public static final int NERR_DevNotRedirected = NERR_BASE + 7; /* The device is not connected. */ /* NERR_BASE + 8 is used for ERROR_CONNECTED_OTHER_PASSWORD */ /* NERR_BASE + 9 is used for ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT */ /* UNUSED BASE + 10 */ /* UNUSED BASE + 11 */ /* UNUSED BASE + 12 */ /* UNUSED BASE + 13 */ public static final int NERR_ServerNotStarted = NERR_BASE + 14; /* The Server service is not started. */ public static final int NERR_ItemNotFound = NERR_BASE + 15; /* The queue is empty. */ public static final int NERR_UnknownDevDir = NERR_BASE + 16; /* The device or directory does not exist. */ public static final int NERR_RedirectedPath = NERR_BASE + 17; /* The operation is invalid on a redirected resource. */ public static final int NERR_DuplicateShare = NERR_BASE + 18; /* The name has already been shared. */ public static final int NERR_NoRoom = NERR_BASE + 19; /* The server is currently out of the requested resource. */ /* UNUSED BASE + 20 */ public static final int NERR_TooManyItems = NERR_BASE + 21; /* Requested addition of items exceeds the maximum allowed. */ public static final int NERR_InvalidMaxUsers = NERR_BASE + 22; /* The Peer service supports only two simultaneous users. */ public static final int NERR_BufTooSmall = NERR_BASE + 23; /* The API return buffer is too small. */ /* UNUSED BASE + 24 */ /* UNUSED BASE + 25 */ /* UNUSED BASE + 26 */ public static final int NERR_RemoteErr = NERR_BASE + 27; /* A remote API error occurred. */ /* UNUSED BASE + 28 */ /* UNUSED BASE + 29 */ /* UNUSED BASE + 30 */ public static final int NERR_LanmanIniError = NERR_BASE + 31; /* An error occurred when opening or reading the configuration file. */ /* UNUSED BASE + 32 */ /* UNUSED BASE + 33 */ /* UNUSED BASE + 34 */ /* UNUSED BASE + 35 */ public static final int NERR_NetworkError = NERR_BASE + 36; /* A general network error occurred. */ public static final int NERR_WkstaInconsistentState = NERR_BASE + 37; /* The Workstation service is in an inconsistent state. Restart the computer before restarting the Workstation service. */ public static final int NERR_WkstaNotStarted = NERR_BASE + 38; /* The Workstation service has not been started. */ public static final int NERR_BrowserNotStarted = NERR_BASE + 39; /* The requested information is not available. */ public static final int NERR_InternalError = NERR_BASE + 40; /* An internal Windows error occurred.*/ public static final int NERR_BadTransactConfig = NERR_BASE + 41; /* The server is not configured for transactions. */ public static final int NERR_InvalidAPI = NERR_BASE + 42; /* The requested API is not supported on the remote server. */ public static final int NERR_BadEventName = NERR_BASE + 43; /* The event name is invalid. */ public static final int NERR_DupNameReboot = NERR_BASE + 44; /* The computer name already exists on the network. Change it and restart the computer. */ /* * Config API related * Error codes from BASE + 45 to BASE + 49 */ /* UNUSED BASE + 45 */ public static final int NERR_CfgCompNotFound = NERR_BASE + 46; /* The specified component could not be found in the configuration information. */ public static final int NERR_CfgParamNotFound = NERR_BASE + 47; /* The specified parameter could not be found in the configuration information. */ public static final int NERR_LineTooLong = NERR_BASE + 49; /* A line in the configuration file is too long. */ /* * Spooler API related * Error codes from BASE + 50 to BASE + 79 */ public static final int NERR_QNotFound = NERR_BASE + 50; /* The printer does not exist. */ public static final int NERR_JobNotFound = NERR_BASE + 51; /* The print job does not exist. */ public static final int NERR_DestNotFound = NERR_BASE + 52; /* The printer destination cannot be found. */ public static final int NERR_DestExists = NERR_BASE + 53; /* The printer destination already exists. */ public static final int NERR_QExists = NERR_BASE + 54; /* The printer queue already exists. */ public static final int NERR_QNoRoom = NERR_BASE + 55; /* No more printers can be added. */ public static final int NERR_JobNoRoom = NERR_BASE + 56; /* No more print jobs can be added. */ public static final int NERR_DestNoRoom = NERR_BASE + 57; /* No more printer destinations can be added. */ public static final int NERR_DestIdle = NERR_BASE + 58; /* This printer destination is idle and cannot accept control operations. */ public static final int NERR_DestInvalidOp = NERR_BASE + 59; /* This printer destination request contains an invalid control function. */ public static final int NERR_ProcNoRespond = NERR_BASE + 60; /* The print processor is not responding. */ public static final int NERR_SpoolerNotLoaded = NERR_BASE + 61; /* The spooler is not running. */ public static final int NERR_DestInvalidState = NERR_BASE + 62; /* This operation cannot be performed on the print destination in its current state. */ public static final int NERR_QInvalidState = NERR_BASE + 63; /* This operation cannot be performed on the printer queue in its current state. */ public static final int NERR_JobInvalidState = NERR_BASE + 64; /* This operation cannot be performed on the print job in its current state. */ public static final int NERR_SpoolNoMemory = NERR_BASE + 65; /* A spooler memory allocation failure occurred. */ public static final int NERR_DriverNotFound = NERR_BASE + 66; /* The device driver does not exist. */ public static final int NERR_DataTypeInvalid = NERR_BASE + 67; /* The data type is not supported by the print processor. */ public static final int NERR_ProcNotFound = NERR_BASE + 68; /* The print processor is not installed. */ /* * Service API related * Error codes from BASE + 80 to BASE + 99 */ public static final int NERR_ServiceTableLocked = NERR_BASE + 80; /* The service database is locked. */ public static final int NERR_ServiceTableFull = NERR_BASE + 81; /* The service table is full. */ public static final int NERR_ServiceInstalled = NERR_BASE + 82; /* The requested service has already been started. */ public static final int NERR_ServiceEntryLocked = NERR_BASE + 83; /* The service does not respond to control actions. */ public static final int NERR_ServiceNotInstalled = NERR_BASE + 84; /* The service has not been started. */ public static final int NERR_BadServiceName = NERR_BASE + 85; /* The service name is invalid. */ public static final int NERR_ServiceCtlTimeout = NERR_BASE + 86; /* The service is not responding to the control function. */ public static final int NERR_ServiceCtlBusy = NERR_BASE + 87; /* The service control is busy. */ public static final int NERR_BadServiceProgName = NERR_BASE + 88; /* The configuration file contains an invalid service program name. */ public static final int NERR_ServiceNotCtrl = NERR_BASE + 89; /* The service could not be controlled in its present state. */ public static final int NERR_ServiceKillProc = NERR_BASE + 90; /* The service ended abnormally. */ public static final int NERR_ServiceCtlNotValid = NERR_BASE + 91; /* The requested pause, continue, or stop is not valid for this service. */ public static final int NERR_NotInDispatchTbl = NERR_BASE + 92; /* The service control dispatcher could not find the service name in the dispatch table. */ public static final int NERR_BadControlRecv = NERR_BASE + 93; /* The service control dispatcher pipe read failed. */ public static final int NERR_ServiceNotStarting = NERR_BASE + 94; /* A thread for the new service could not be created. */ /* * Wksta and Logon API related * Error codes from BASE + 100 to BASE + 118 */ public static final int NERR_AlreadyLoggedOn = NERR_BASE + 100; /* This workstation is already logged on to the local-area network. */ public static final int NERR_NotLoggedOn = NERR_BASE + 101; /* The workstation is not logged on to the local-area network. */ public static final int NERR_BadUsername = NERR_BASE + 102; /* The user name or group name parameter is invalid. */ public static final int NERR_BadPassword = NERR_BASE + 103; /* The password parameter is invalid. */ public static final int NERR_UnableToAddName_W = NERR_BASE + 104; /* @W The logon processor did not add the message alias. */ public static final int NERR_UnableToAddName_F = NERR_BASE + 105; /* The logon processor did not add the message alias. */ public static final int NERR_UnableToDelName_W = NERR_BASE + 106; /* @W The logoff processor did not delete the message alias. */ public static final int NERR_UnableToDelName_F = NERR_BASE + 107; /* The logoff processor did not delete the message alias. */ /* UNUSED BASE + 108 */ public static final int NERR_LogonsPaused = NERR_BASE + 109; /* Network logons are paused. */ public static final int NERR_LogonServerConflict = NERR_BASE + 110;/* A centralized logon-server conflict occurred. */ public static final int NERR_LogonNoUserPath = NERR_BASE + 111; /* The server is configured without a valid user path. */ public static final int NERR_LogonScriptError = NERR_BASE + 112; /* An error occurred while loading or running the logon script. */ /* UNUSED BASE + 113 */ public static final int NERR_StandaloneLogon = NERR_BASE + 114; /* The logon server was not specified. Your computer will be logged on as STANDALONE. */ public static final int NERR_LogonServerNotFound = NERR_BASE + 115; /* The logon server could not be found. */ public static final int NERR_LogonDomainExists = NERR_BASE + 116; /* There is already a logon domain for this computer. */ public static final int NERR_NonValidatedLogon = NERR_BASE + 117; /* The logon server could not validate the logon. */ /* * ACF API related = access, user, group; * Error codes from BASE + 119 to BASE + 149 */ public static final int NERR_ACFNotFound = NERR_BASE + 119; /* The security database could not be found. */ public static final int NERR_GroupNotFound = NERR_BASE + 120; /* The group name could not be found. */ public static final int NERR_UserNotFound = NERR_BASE + 121; /* The user name could not be found. */ public static final int NERR_ResourceNotFound = NERR_BASE + 122; /* The resource name could not be found. */ public static final int NERR_GroupExists = NERR_BASE + 123; /* The group already exists. */ public static final int NERR_UserExists = NERR_BASE + 124; /* The account already exists. */ public static final int NERR_ResourceExists = NERR_BASE + 125; /* The resource permission list already exists. */ public static final int NERR_NotPrimary = NERR_BASE + 126; /* This operation is only allowed on the primary domain controller of the domain. */ public static final int NERR_ACFNotLoaded = NERR_BASE + 127; /* The security database has not been started. */ public static final int NERR_ACFNoRoom = NERR_BASE + 128; /* There are too many names in the user accounts database. */ public static final int NERR_ACFFileIOFail = NERR_BASE + 129; /* A disk I/O failure occurred.*/ public static final int NERR_ACFTooManyLists = NERR_BASE + 130; /* The limit of 64 entries per resource was exceeded. */ public static final int NERR_UserLogon = NERR_BASE + 131; /* Deleting a user with a session is not allowed. */ public static final int NERR_ACFNoParent = NERR_BASE + 132; /* The parent directory could not be located. */ public static final int NERR_CanNotGrowSegment = NERR_BASE + 133; /* Unable to add to the security database session cache segment. */ public static final int NERR_SpeGroupOp = NERR_BASE + 134; /* This operation is not allowed on this special group. */ public static final int NERR_NotInCache = NERR_BASE + 135; /* This user is not cached in user accounts database session cache. */ public static final int NERR_UserInGroup = NERR_BASE + 136; /* The user already belongs to this group. */ public static final int NERR_UserNotInGroup = NERR_BASE + 137; /* The user does not belong to this group. */ public static final int NERR_AccountUndefined = NERR_BASE + 138; /* This user account is undefined. */ public static final int NERR_AccountExpired = NERR_BASE + 139; /* This user account has expired. */ public static final int NERR_InvalidWorkstation = NERR_BASE + 140; /* The user is not allowed to log on from this workstation. */ public static final int NERR_InvalidLogonHours = NERR_BASE + 141; /* The user is not allowed to log on at this time. */ public static final int NERR_PasswordExpired = NERR_BASE + 142; /* The password of this user has expired. */ public static final int NERR_PasswordCantChange = NERR_BASE + 143; /* The password of this user cannot change. */ public static final int NERR_PasswordHistConflict = NERR_BASE + 144; /* This password cannot be used now. */ public static final int NERR_PasswordTooShort = NERR_BASE + 145; /* The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements. */ public static final int NERR_PasswordTooRecent = NERR_BASE + 146; /* The password of this user is too recent to change. */ public static final int NERR_InvalidDatabase = NERR_BASE + 147; /* The security database is corrupted. */ public static final int NERR_DatabaseUpToDate = NERR_BASE + 148; /* No updates are necessary to this replicant network/local security database. */ public static final int NERR_SyncRequired = NERR_BASE + 149; /* This replicant database is outdated; synchronization is required. */ /* * Use API related * Error codes from BASE + 150 to BASE + 169 */ public static final int NERR_UseNotFound = NERR_BASE + 150; /* The network connection could not be found. */ public static final int NERR_BadAsgType = NERR_BASE + 151; /* This asg_type is invalid. */ public static final int NERR_DeviceIsShared = NERR_BASE + 152; /* This device is currently being shared. */ public static final int NERR_SameAsComputerName = NERR_BASE + 153; /* The user name may not be same as computer name. */ /* * Message Server related * Error codes BASE + 170 to BASE + 209 */ public static final int NERR_NoComputerName = NERR_BASE + 170; /* The computer name could not be added as a message alias. The name may already exist on the network. */ public static final int NERR_MsgAlreadyStarted = NERR_BASE + 171; /* The Messenger service is already started. */ public static final int NERR_MsgInitFailed = NERR_BASE + 172; /* The Messenger service failed to start. */ public static final int NERR_NameNotFound = NERR_BASE + 173; /* The message alias could not be found on the network. */ public static final int NERR_AlreadyForwarded = NERR_BASE + 174; /* This message alias has already been forwarded. */ public static final int NERR_AddForwarded = NERR_BASE + 175; /* This message alias has been added but is still forwarded. */ public static final int NERR_AlreadyExists = NERR_BASE + 176; /* This message alias already exists locally. */ public static final int NERR_TooManyNames = NERR_BASE + 177; /* The maximum number of added message aliases has been exceeded. */ public static final int NERR_DelComputerName = NERR_BASE + 178; /* The computer name could not be deleted.*/ public static final int NERR_LocalForward = NERR_BASE + 179; /* Messages cannot be forwarded back to the same workstation. */ public static final int NERR_GrpMsgProcessor = NERR_BASE + 180; /* An error occurred in the domain message processor. */ public static final int NERR_PausedRemote = NERR_BASE + 181; /* The message was sent, but the recipient has paused the Messenger service. */ public static final int NERR_BadReceive = NERR_BASE + 182; /* The message was sent but not received. */ public static final int NERR_NameInUse = NERR_BASE + 183; /* The message alias is currently in use. Try again later. */ public static final int NERR_MsgNotStarted = NERR_BASE + 184; /* The Messenger service has not been started. */ public static final int NERR_NotLocalName = NERR_BASE + 185; /* The name is not on the local computer. */ public static final int NERR_NoForwardName = NERR_BASE + 186; /* The forwarded message alias could not be found on the network. */ public static final int NERR_RemoteFull = NERR_BASE + 187; /* The message alias table on the remote station is full. */ public static final int NERR_NameNotForwarded = NERR_BASE + 188; /* Messages for this alias are not currently being forwarded. */ public static final int NERR_TruncatedBroadcast = NERR_BASE + 189; /* The broadcast message was truncated. */ public static final int NERR_InvalidDevice = NERR_BASE + 194; /* This is an invalid device name. */ public static final int NERR_WriteFault = NERR_BASE + 195; /* A write fault occurred. */ /* UNUSED BASE + 196 */ public static final int NERR_DuplicateName = NERR_BASE + 197; /* A duplicate message alias exists on the network. */ public static final int NERR_DeleteLater = NERR_BASE + 198; /* @W This message alias will be deleted later. */ public static final int NERR_IncompleteDel = NERR_BASE + 199; /* The message alias was not successfully deleted from all networks. */ public static final int NERR_MultipleNets = NERR_BASE + 200; /* This operation is not supported on computers with multiple networks. */ /* * Server API related * Error codes BASE + 210 to BASE + 229 */ public static final int NERR_NetNameNotFound = NERR_BASE + 210; /* This shared resource does not exist.*/ public static final int NERR_DeviceNotShared = NERR_BASE + 211; /* This device is not shared. */ public static final int NERR_ClientNameNotFound = NERR_BASE + 212; /* A session does not exist with that computer name. */ public static final int NERR_FileIdNotFound = NERR_BASE + 214; /* There is not an open file with that identification number. */ public static final int NERR_ExecFailure = NERR_BASE + 215; /* A failure occurred when executing a remote administration command. */ public static final int NERR_TmpFile = NERR_BASE + 216; /* A failure occurred when opening a remote temporary file. */ public static final int NERR_TooMuchData = NERR_BASE + 217; /* The data returned from a remote administration command has been truncated to 64K. */ public static final int NERR_DeviceShareConflict = NERR_BASE + 218; /* This device cannot be shared as both a spooled and a non-spooled resource. */ public static final int NERR_BrowserTableIncomplete = NERR_BASE + 219; /* The information in the list of servers may be incorrect. */ public static final int NERR_NotLocalDomain = NERR_BASE + 220; /* The computer is not active in this domain. */ public static final int NERR_IsDfsShare = NERR_BASE + 221; /* The share must be removed from the Distributed File System before it can be deleted. */ /* * CharDev API related * Error codes BASE + 230 to BASE + 249 */ /* UNUSED BASE + 230 */ public static final int NERR_DevInvalidOpCode = NERR_BASE + 231; /* The operation is invalid for this device. */ public static final int NERR_DevNotFound = NERR_BASE + 232; /* This device cannot be shared. */ public static final int NERR_DevNotOpen = NERR_BASE + 233; /* This device was not open. */ public static final int NERR_BadQueueDevString = NERR_BASE + 234; /* This device name list is invalid. */ public static final int NERR_BadQueuePriority = NERR_BASE + 235; /* The queue priority is invalid. */ public static final int NERR_NoCommDevs = NERR_BASE + 237; /* There are no shared communication devices. */ public static final int NERR_QueueNotFound = NERR_BASE + 238; /* The queue you specified does not exist. */ public static final int NERR_BadDevString = NERR_BASE + 240; /* This list of devices is invalid. */ public static final int NERR_BadDev = NERR_BASE + 241; /* The requested device is invalid. */ public static final int NERR_InUseBySpooler = NERR_BASE + 242; /* This device is already in use by the spooler. */ public static final int NERR_CommDevInUse = NERR_BASE + 243; /* This device is already in use as a communication device. */ /* * NetICanonicalize and NetIType and NetIMakeLMFileName * NetIListCanon and NetINameCheck * Error codes BASE + 250 to BASE + 269 */ public static final int NERR_InvalidComputer = NERR_BASE + 251; /* This computer name is invalid. */ /* UNUSED BASE + 252 */ /* UNUSED BASE + 253 */ public static final int NERR_MaxLenExceeded = NERR_BASE + 254; /* The string and prefix specified are too long. */ /* UNUSED BASE + 255 */ public static final int NERR_BadComponent = NERR_BASE + 256; /* This path component is invalid. */ public static final int NERR_CantType = NERR_BASE + 257; /* Could not determine the type of input. */ /* UNUSED BASE + 258 */ /* UNUSED BASE + 259 */ public static final int NERR_TooManyEntries = NERR_BASE + 262; /* The buffer for types is not big enough. */ /* * NetProfile * Error codes BASE + 270 to BASE + 276 */ public static final int NERR_ProfileFileTooBig = NERR_BASE + 270; /* Profile files cannot exceed 64K. */ public static final int NERR_ProfileOffset = NERR_BASE + 271; /* The start offset is out of range. */ public static final int NERR_ProfileCleanup = NERR_BASE + 272; /* The system cannot delete current connections to network resources. */ public static final int NERR_ProfileUnknownCmd = NERR_BASE + 273; /* The system was unable to parse the command line in this file.*/ public static final int NERR_ProfileLoadErr = NERR_BASE + 274; /* An error occurred while loading the profile file. */ public static final int NERR_ProfileSaveErr = NERR_BASE + 275; /* @W Errors occurred while saving the profile file. The profile was partially saved. */ /* * NetAudit and NetErrorLog * Error codes BASE + 277 to BASE + 279 */ public static final int NERR_LogOverflow = NERR_BASE + 277; /* Log file %1 is full. */ public static final int NERR_LogFileChanged = NERR_BASE + 278; /* This log file has changed between reads. */ public static final int NERR_LogFileCorrupt = NERR_BASE + 279; /* Log file %1 is corrupt. */ /* * NetRemote * Error codes BASE + 280 to BASE + 299 */ public static final int NERR_SourceIsDir = NERR_BASE + 280; /* The source path cannot be a directory. */ public static final int NERR_BadSource = NERR_BASE + 281; /* The source path is illegal. */ public static final int NERR_BadDest = NERR_BASE + 282; /* The destination path is illegal. */ public static final int NERR_DifferentServers = NERR_BASE + 283; /* The source and destination paths are on different servers. */ /* UNUSED BASE + 284 */ public static final int NERR_RunSrvPaused = NERR_BASE + 285; /* The Run server you requested is paused. */ /* UNUSED BASE + 286 */ /* UNUSED BASE + 287 */ /* UNUSED BASE + 288 */ public static final int NERR_ErrCommRunSrv = NERR_BASE + 289; /* An error occurred when communicating with a Run server. */ /* UNUSED BASE + 290 */ public static final int NERR_ErrorExecingGhost = NERR_BASE + 291; /* An error occurred when starting a background process. */ public static final int NERR_ShareNotFound = NERR_BASE + 292; /* The shared resource you are connected to could not be found.*/ /* UNUSED BASE + 293 */ /* UNUSED BASE + 294 */ /* * NetWksta.sys = redir; returned error codes. * * NERR_BASE + = 300-329; */ public static final int NERR_InvalidLana = NERR_BASE + 300; /* The LAN adapter number is invalid. */ public static final int NERR_OpenFiles = NERR_BASE + 301; /* There are open files on the connection. */ public static final int NERR_ActiveConns = NERR_BASE + 302; /* Active connections still exist. */ public static final int NERR_BadPasswordCore = NERR_BASE + 303; /* This share name or password is invalid. */ public static final int NERR_DevInUse = NERR_BASE + 304; /* The device is being accessed by an active process. */ public static final int NERR_LocalDrive = NERR_BASE + 305; /* The drive letter is in use locally. */ /* * Alert error codes. * * NERR_BASE + = 330-339; */ public static final int NERR_AlertExists = NERR_BASE + 330; /* The specified client is already registered for the specified event. */ public static final int NERR_TooManyAlerts = NERR_BASE + 331; /* The alert table is full. */ public static final int NERR_NoSuchAlert = NERR_BASE + 332; /* An invalid or nonexistent alert name was raised. */ public static final int NERR_BadRecipient = NERR_BASE + 333; /* The alert recipient is invalid.*/ public static final int NERR_AcctLimitExceeded = NERR_BASE + 334; /* A user's session with this server has been deleted * because the user's logon hours are no longer valid. */ /* * Additional Error and Audit log codes. * * NERR_BASE + (340-343; */ public static final int NERR_InvalidLogSeek = NERR_BASE + 340; /* The log file does not contain the requested record number. */ /* UNUSED BASE + 341 */ /* UNUSED BASE + 342 */ /* UNUSED BASE + 343 */ /* * Additional UAS and NETLOGON codes * * NERR_BASE + (350-359; */ public static final int NERR_BadUasConfig = NERR_BASE + 350; /* The user accounts database is not configured correctly. */ public static final int NERR_InvalidUASOp = NERR_BASE + 351; /* This operation is not permitted when the Netlogon service is running. */ public static final int NERR_LastAdmin = NERR_BASE + 352; /* This operation is not allowed on the last administrative account. */ public static final int NERR_DCNotFound = NERR_BASE + 353; /* Could not find domain controller for this domain. */ public static final int NERR_LogonTrackingError = NERR_BASE + 354; /* Could not set logon information for this user. */ public static final int NERR_NetlogonNotStarted = NERR_BASE + 355; /* The Netlogon service has not been started. */ public static final int NERR_CanNotGrowUASFile = NERR_BASE + 356; /* Unable to add to the user accounts database. */ public static final int NERR_TimeDiffAtDC = NERR_BASE + 357; /* This server's clock is not synchronized with the primary domain controller's clock. */ public static final int NERR_PasswordMismatch = NERR_BASE + 358; /* A password mismatch has been detected. */ /* * Server Integration error codes. * * NERR_BASE + (360-369; */ public static final int NERR_NoSuchServer = NERR_BASE + 360; /* The server identification does not specify a valid server. */ public static final int NERR_NoSuchSession = NERR_BASE + 361; /* The session identification does not specify a valid session. */ public static final int NERR_NoSuchConnection = NERR_BASE + 362; /* The connection identification does not specify a valid connection. */ public static final int NERR_TooManyServers = NERR_BASE + 363; /* There is no space for another entry in the table of available servers. */ public static final int NERR_TooManySessions = NERR_BASE + 364; /* The server has reached the maximum number of sessions it supports. */ public static final int NERR_TooManyConnections = NERR_BASE + 365; /* The server has reached the maximum number of connections it supports. */ public static final int NERR_TooManyFiles = NERR_BASE + 366; /* The server cannot open more files because it has reached its maximum number. */ public static final int NERR_NoAlternateServers = NERR_BASE + 367; /* There are no alternate servers registered on this server. */ /* UNUSED BASE + 368 */ /* UNUSED BASE + 369 */ public static final int NERR_TryDownLevel = NERR_BASE + 370; /* Try down-level = remote admin protocol; version of API instead. */ /* * UPS error codes. * * NERR_BASE + = 380-384; */ public static final int NERR_UPSDriverNotStarted = NERR_BASE + 380; /* The UPS driver could not be accessed by the UPS service. */ public static final int NERR_UPSInvalidConfig = NERR_BASE + 381; /* The UPS service is not configured correctly. */ public static final int NERR_UPSInvalidCommPort = NERR_BASE + 382; /* The UPS service could not access the specified Comm Port. */ public static final int NERR_UPSSignalAsserted = NERR_BASE + 383; /* The UPS indicated a line fail or low battery situation. Service not started. */ public static final int NERR_UPSShutdownFailed = NERR_BASE + 384; /* The UPS service failed to perform a system shut down. */ /* * Remoteboot error codes. * * NERR_BASE + = 400-419; * Error codes 400 - 405 are used by RPLBOOT.SYS. * Error codes 403, 407 - 416 are used by RPLLOADR.COM, * Error code 417 is the alerter message of REMOTEBOOT = RPLSERVR.EXE;. * Error code 418 is for when REMOTEBOOT can't start * Error code 419 is for a disallowed 2nd rpl connection * */ public static final int NERR_BadDosRetCode = NERR_BASE + 400; /* The program below returned an MS-DOS error code:*/ public static final int NERR_ProgNeedsExtraMem = NERR_BASE + 401; /* The program below needs more memory:*/ public static final int NERR_BadDosFunction = NERR_BASE + 402; /* The program below called an unsupported MS-DOS function:*/ public static final int NERR_RemoteBootFailed = NERR_BASE + 403; /* The workstation failed to boot.*/ public static final int NERR_BadFileCheckSum = NERR_BASE + 404; /* The file below is corrupt.*/ public static final int NERR_NoRplBootSystem = NERR_BASE + 405; /* No loader is specified in the boot-block definition file.*/ public static final int NERR_RplLoadrNetBiosErr = NERR_BASE + 406; /* NetBIOS returned an error: The NCB and SMB are dumped above.*/ public static final int NERR_RplLoadrDiskErr = NERR_BASE + 407; /* A disk I/O error occurred.*/ public static final int NERR_ImageParamErr = NERR_BASE + 408; /* Image parameter substitution failed.*/ public static final int NERR_TooManyImageParams = NERR_BASE + 409; /* Too many image parameters cross disk sector boundaries.*/ public static final int NERR_NonDosFloppyUsed = NERR_BASE + 410; /* The image was not generated from an MS-DOS diskette formatted with /S.*/ public static final int NERR_RplBootRestart = NERR_BASE + 411; /* Remote boot will be restarted later.*/ public static final int NERR_RplSrvrCallFailed = NERR_BASE + 412; /* The call to the Remoteboot server failed.*/ public static final int NERR_CantConnectRplSrvr = NERR_BASE + 413; /* Cannot connect to the Remoteboot server.*/ public static final int NERR_CantOpenImageFile = NERR_BASE + 414; /* Cannot open image file on the Remoteboot server.*/ public static final int NERR_CallingRplSrvr = NERR_BASE + 415; /* Connecting to the Remoteboot server...*/ public static final int NERR_StartingRplBoot = NERR_BASE + 416; /* Connecting to the Remoteboot server...*/ public static final int NERR_RplBootServiceTerm = NERR_BASE + 417; /* Remote boot service was stopped; check the error log for the cause of the problem.*/ public static final int NERR_RplBootStartFailed = NERR_BASE + 418; /* Remote boot startup failed; check the error log for the cause of the problem.*/ public static final int NERR_RPL_CONNECTED = NERR_BASE + 419; /* A second connection to a Remoteboot resource is not allowed.*/ /* * FTADMIN API error codes * * NERR_BASE + = 425-434; * * = Currently not used in NT; * */ /* * Browser service API error codes * * NERR_BASE + = 450-475; * */ public static final int NERR_BrowserConfiguredToNotRun = NERR_BASE + 450; /* The browser service was configured with MaintainServerList = No. */ /* * Additional Remoteboot error codes. * * NERR_BASE + = 510-550; */ public static final int NERR_RplNoAdaptersStarted = NERR_BASE + 510; /*Service failed to start since none of the network adapters started with this service.*/ public static final int NERR_RplBadRegistry = NERR_BASE + 511; /*Service failed to start due to bad startup information in the registry.*/ public static final int NERR_RplBadDatabase = NERR_BASE + 512; /*Service failed to start because its database is absent or corrupt.*/ public static final int NERR_RplRplfilesShare = NERR_BASE + 513; /*Service failed to start because RPLFILES share is absent.*/ public static final int NERR_RplNotRplServer = NERR_BASE + 514; /*Service failed to start because RPLUSER group is absent.*/ public static final int NERR_RplCannotEnum = NERR_BASE + 515; /*Cannot enumerate service records.*/ public static final int NERR_RplWkstaInfoCorrupted = NERR_BASE + 516; /*Workstation record information has been corrupted.*/ public static final int NERR_RplWkstaNotFound = NERR_BASE + 517; /*Workstation record was not found.*/ public static final int NERR_RplWkstaNameUnavailable = NERR_BASE + 518; /*Workstation name is in use by some other workstation.*/ public static final int NERR_RplProfileInfoCorrupted = NERR_BASE + 519; /*Profile record information has been corrupted.*/ public static final int NERR_RplProfileNotFound = NERR_BASE + 520; /*Profile record was not found.*/ public static final int NERR_RplProfileNameUnavailable = NERR_BASE + 521; /*Profile name is in use by some other profile.*/ public static final int NERR_RplProfileNotEmpty = NERR_BASE + 522; /*There are workstations using this profile.*/ public static final int NERR_RplConfigInfoCorrupted = NERR_BASE + 523; /*Configuration record information has been corrupted.*/ public static final int NERR_RplConfigNotFound = NERR_BASE + 524; /*Configuration record was not found.*/ public static final int NERR_RplAdapterInfoCorrupted = NERR_BASE + 525; /*Adapter id record information has been corrupted.*/ public static final int NERR_RplInternal = NERR_BASE + 526; /*An internal service error has occurred.*/ public static final int NERR_RplVendorInfoCorrupted = NERR_BASE + 527; /*Vendor id record information has been corrupted.*/ public static final int NERR_RplBootInfoCorrupted = NERR_BASE + 528; /*Boot block record information has been corrupted.*/ public static final int NERR_RplWkstaNeedsUserAcct = NERR_BASE + 529; /*The user account for this workstation record is missing.*/ public static final int NERR_RplNeedsRPLUSERAcct = NERR_BASE + 530; /*The RPLUSER local group could not be found.*/ public static final int NERR_RplBootNotFound = NERR_BASE + 531; /*Boot block record was not found.*/ public static final int NERR_RplIncompatibleProfile = NERR_BASE + 532; /*Chosen profile is incompatible with this workstation.*/ public static final int NERR_RplAdapterNameUnavailable = NERR_BASE + 533; /*Chosen network adapter id is in use by some other workstation.*/ public static final int NERR_RplConfigNotEmpty = NERR_BASE + 534; /*There are profiles using this configuration.*/ public static final int NERR_RplBootInUse = NERR_BASE + 535; /*There are workstations, profiles or configurations using this boot block.*/ public static final int NERR_RplBackupDatabase = NERR_BASE + 536; /*Service failed to backup Remoteboot database.*/ public static final int NERR_RplAdapterNotFound = NERR_BASE + 537; /*Adapter record was not found.*/ public static final int NERR_RplVendorNotFound = NERR_BASE + 538; /*Vendor record was not found.*/ public static final int NERR_RplVendorNameUnavailable = NERR_BASE + 539; /*Vendor name is in use by some other vendor record.*/ public static final int NERR_RplBootNameUnavailable = NERR_BASE + 540; /*(boot name, vendor id; is in use by some other boot block record.*/ public static final int NERR_RplConfigNameUnavailable = NERR_BASE + 541; /*Configuration name is in use by some other configuration.*/ /**INTERNAL_ONLY**/ /* * Dfs API error codes. * * NERR_BASE + = 560-590; */ public static final int NERR_DfsInternalCorruption = NERR_BASE + 560; /*The internal database maintained by the DFS service is corrupt*/ public static final int NERR_DfsVolumeDataCorrupt = NERR_BASE + 561; /*One of the records in the internal DFS database is corrupt*/ public static final int NERR_DfsNoSuchVolume = NERR_BASE + 562; /*There is no DFS name whose entry path matches the input Entry Path*/ public static final int NERR_DfsVolumeAlreadyExists = NERR_BASE + 563; /*A root or link with the given name already exists*/ public static final int NERR_DfsAlreadyShared = NERR_BASE + 564; /*The server share specified is already shared in the DFS*/ public static final int NERR_DfsNoSuchShare = NERR_BASE + 565; /*The indicated server share does not support the indicated DFS namespace*/ public static final int NERR_DfsNotALeafVolume = NERR_BASE + 566; /*The operation is not valid on this portion of the namespace*/ public static final int NERR_DfsLeafVolume = NERR_BASE + 567; /*The operation is not valid on this portion of the namespace*/ public static final int NERR_DfsVolumeHasMultipleServers = NERR_BASE + 568; /*The operation is ambiguous because the link has multiple servers*/ public static final int NERR_DfsCantCreateJunctionPoint = NERR_BASE + 569; /*Unable to create a link*/ public static final int NERR_DfsServerNotDfsAware = NERR_BASE + 570; /*The server is not DFS Aware*/ public static final int NERR_DfsBadRenamePath = NERR_BASE + 571; /*The specified rename target path is invalid*/ public static final int NERR_DfsVolumeIsOffline = NERR_BASE + 572; /*The specified DFS link is offline*/ public static final int NERR_DfsNoSuchServer = NERR_BASE + 573; /*The specified server is not a server for this link*/ public static final int NERR_DfsCyclicalName = NERR_BASE + 574; /*A cycle in the DFS name was detected*/ public static final int NERR_DfsNotSupportedInServerDfs = NERR_BASE + 575; /*The operation is not supported on a server-based DFS*/ public static final int NERR_DfsDuplicateService = NERR_BASE + 576; /*This link is already supported by the specified server-share*/ public static final int NERR_DfsCantRemoveLastServerShare = NERR_BASE + 577; /*Can't remove the last server-share supporting this root or link*/ public static final int NERR_DfsVolumeIsInterDfs = NERR_BASE + 578; /*The operation is not supported for an Inter-DFS link*/ public static final int NERR_DfsInconsistent = NERR_BASE + 579; /*The internal state of the DFS Service has become inconsistent*/ public static final int NERR_DfsServerUpgraded = NERR_BASE + 580; /*The DFS Service has been installed on the specified server*/ public static final int NERR_DfsDataIsIdentical = NERR_BASE + 581; /*The DFS data being reconciled is identical*/ public static final int NERR_DfsCantRemoveDfsRoot = NERR_BASE + 582; /*The DFS root cannot be deleted - Uninstall DFS if required*/ public static final int NERR_DfsChildOrParentInDfs = NERR_BASE + 583; /*A child or parent directory of the share is already in a DFS*/ public static final int NERR_DfsInternalError = NERR_BASE + 590; /*DFS internal error*/ /* * Net setup error codes. * * NERR_BASE + = 591-600; */ public static final int NERR_SetupAlreadyJoined = NERR_BASE + 591; /*This machine is already joined to a domain.*/ public static final int NERR_SetupNotJoined = NERR_BASE + 592; /*This machine is not currently joined to a domain.*/ public static final int NERR_SetupDomainController = NERR_BASE + 593; /*This machine is a domain controller and cannot be unjoined from a domain.*/ public static final int NERR_DefaultJoinRequired = NERR_BASE + 594; /*The destination domain controller does not support creating machine accounts in OUs.*/ public static final int NERR_InvalidWorkgroupName = NERR_BASE + 595; /*The specified workgroup name is invalid.*/ public static final int NERR_NameUsesIncompatibleCodePage = NERR_BASE + 596; /*The specified computer name is incompatible with the default language used on the domain controller.*/ public static final int NERR_ComputerAccountNotFound = NERR_BASE + 597; /*The specified computer account could not be found. Contact an administrator to verify the account is in the domain. If the account has been deleted unjoin, reboot, and rejoin the domain.*/ public static final int NERR_PersonalSku = NERR_BASE + 598; /*This version of Windows cannot be joined to a domain.*/ public static final int NERR_SetupCheckDNSConfig = NERR_BASE + 599; /*An attempt to resolve the DNS name of a DC in the domain being joined has failed. Please verify this client is configured to reach a DNS server that can resolve DNS names in the target domain.*/ /* * Some Password and account error results * * NERR_BASE + = 601 - 608; */ public static final int NERR_PasswordMustChange = NERR_BASE + 601; /* Password must change at next logon */ public static final int NERR_AccountLockedOut = NERR_BASE + 602; /* Account is locked out */ public static final int NERR_PasswordTooLong = NERR_BASE + 603; /* Password is too long */ public static final int NERR_PasswordNotComplexEnough = NERR_BASE + 604; /* Password doesn't meet the complexity policy */ public static final int NERR_PasswordFilterError = NERR_BASE + 605; /* Password doesn't meet the requirements of the filter dll's */ /***********WARNING **************** *The range 2750-2799 has been * *allocated to the IBM LAN Server * ***********************************/ /***********WARNING **************** *The range 2900-2999 has been * *reserved for Microsoft OEMs * ***********************************/ public static final int MAX_NERR = NERR_BASE + 899; /* This is the last error in NERR range. */ } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Secur32Util.java0000644000175000017500000000613211421126016025722 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import java.util.ArrayList; import com.sun.jna.Native; import com.sun.jna.platform.win32.Sspi.PSecPkgInfo; import com.sun.jna.platform.win32.Sspi.SecPkgInfo; import com.sun.jna.ptr.IntByReference; /** * Secur32 Utility API. * @author dblock[at]dblock.org */ public abstract class Secur32Util { /** * An SSPI package. */ public static class SecurityPackage { /** * Package name. */ public String name; /** * Package comment. */ public String comment; } /** * Retrieves the name of the user or other security principal associated * with the calling thread. * * @param format User name format. * @return User name in a given format. */ public static String getUserNameEx(int format) { char[] buffer = new char[128]; IntByReference len = new IntByReference(buffer.length); boolean result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len); if (! result) { int rc = Kernel32.INSTANCE.GetLastError(); switch(rc) { case W32Errors.ERROR_MORE_DATA: buffer = new char[len.getValue() + 1]; break; default: throw new Win32Exception(Native.getLastError()); } result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len); } if (! result) { throw new Win32Exception(Native.getLastError()); } return Native.toString(buffer); } /** * Get the security packages installed on the current computer. * @return * An array of SSPI security packages. */ public static SecurityPackage[] getSecurityPackages() { IntByReference pcPackages = new IntByReference(); PSecPkgInfo.ByReference pPackageInfo = new PSecPkgInfo.ByReference(); int rc = Secur32.INSTANCE.EnumerateSecurityPackages(pcPackages, pPackageInfo); if(W32Errors.SEC_E_OK != rc) { throw new Win32Exception(rc); } SecPkgInfo[] packagesInfo = pPackageInfo.toArray(pcPackages.getValue()); ArrayList packages = new ArrayList(pcPackages.getValue()); for(SecPkgInfo packageInfo : packagesInfo) { SecurityPackage securityPackage = new SecurityPackage(); securityPackage.name = packageInfo.Name.toString(); securityPackage.comment = packageInfo.Comment.toString(); packages.add(securityPackage); } rc = Secur32.INSTANCE.FreeContextBuffer(pPackageInfo.pPkgInfo.getPointer()); if(W32Errors.SEC_E_OK != rc) { throw new Win32Exception(rc); } return packages.toArray(new SecurityPackage[0]); } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Sspi.java0000644000175000017500000003117511421126016024561 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Memory; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.WString; import com.sun.jna.win32.StdCallLibrary; /** * Ported from Sspi.h. * Microsoft Windows SDK 6.0A. * @author dblock[at]dblock.org */ public interface Sspi extends StdCallLibrary { /** * Maximum size in bytes of a security token. */ public static final int MAX_TOKEN_SIZE = 12288; // Flags for the fCredentialUse parameter of AcquireCredentialsHandle /** * Validate an incoming server credential. Inbound credentials might be validated * by using an authenticating authority when InitializeSecurityContext or * AcceptSecurityContext is called. If such an authority is not available, the function will * fail and return SEC_E_NO_AUTHENTICATING_AUTHORITY. Validation is package specific. */ public static final int SECPKG_CRED_INBOUND = 1; /** * Allow a local client credential to prepare an outgoing token. */ public static final int SECPKG_CRED_OUTBOUND = 2; // Flags for the TargetDataRep parameter of AcceptSecurityContext and InitializeSecurityContext /** * Specifies Native data representation. */ public static final int SECURITY_NATIVE_DREP = 0x10; // Flags for the fContextReq parameter of InitializeSecurityContext or AcceptSecurityContext. /** * The security package allocates output buffers for you. * When you have finished using the output buffers, free them by calling the FreeContextBuffer function. */ public static final int ISC_REQ_ALLOCATE_MEMORY = 0x00000100; /** * Encrypt messages by using the EncryptMessage function. */ public static final int ISC_REQ_CONFIDENTIALITY = 0x00000010; /** * The security context will not handle formatting messages. This value is the default. */ public static final int ISC_REQ_CONNECTION = 0x00000800; /** * The server can use the context to authenticate to other servers as the client. * The ISC_REQ_MUTUAL_AUTH flag must be set for this flag to work. Valid for Kerberos. * Ignore this flag for constrained delegation. */ public static final int ISC_REQ_DELEGATE = 0x00000001; /** * When errors occur, the remote party will be notified. */ public static final int ISC_REQ_EXTENDED_ERROR = 0x00004000; /** * Sign messages and verify signatures by using the EncryptMessage and MakeSignature functions. */ public static final int ISC_REQ_INTEGRITY = 0x00010000; /** * The mutual authentication policy of the service will be satisfied. */ public static final int ISC_REQ_MUTUAL_AUTH = 0x00000002; /** * Detect replayed messages that have been encoded by using the * EncryptMessage or MakeSignature functions. */ public static final int ISC_REQ_REPLAY_DETECT = 0x00000004; /** * Detect messages received out of sequence. */ public static final int ISC_REQ_SEQUENCE_DETECT = 0x00000008; /** * Support a stream-oriented connection. */ public static final int ISC_REQ_STREAM = 0x00008000; /** * Version of the SecBuffer struct. */ public static final int SECBUFFER_VERSION = 0; /** * This is a placeholder in the buffer array. */ public static final int SECBUFFER_EMPTY = 0; /** * This buffer type is used for common data. The security package can read * and write this data. */ public static final int SECBUFFER_DATA = 1; /** * This buffer type is used to indicate the security token portion of the message. * This is read-only for input parameters or read/write for output parameters. */ public static final int SECBUFFER_TOKEN = 2; /** * Security handle. */ public static class SecHandle extends Structure { public Pointer dwLower; public Pointer dwUpper; public static class ByReference extends SecHandle implements Structure.ByReference { } /** * An empty SecHandle. */ public SecHandle() { dwLower = null; dwUpper = null; } /** * Returns true if the handle is NULL. * @return * True if NULL, False otherwise. */ public boolean isNull() { return dwLower == null && dwUpper == null; } } /** * A pointer to a SecHandle */ public static class PSecHandle extends Structure { public static class ByReference extends PSecHandle implements Structure.ByReference { } /** * The first entry in an array of SecPkgInfo structures. */ public SecHandle.ByReference secHandle; public PSecHandle() { } public PSecHandle(SecHandle h) { useMemory(h.getPointer()); read(); } } /** * Credentials handle. */ public static class CredHandle extends SecHandle { } /** * Security context handle. */ public static class CtxtHandle extends SecHandle { } /** * The SecBuffer structure describes a buffer allocated by a transport application * to pass to a security package. */ public static class SecBuffer extends Structure { /** * A ByReference SecBuffer. */ public static class ByReference extends SecBuffer implements Structure.ByReference { /** * Create a SECBUFFER_EMPTY SecBuffer. */ public ByReference() { } /** * Create a SecBuffer of a given type and size. * @param type * Buffer type, one of SECBUFFER_EMTPY, etc. * @param size * Buffer size, eg. MAX_TOKEN_SIZE. */ public ByReference(int type, int size) { super(type, size); } public ByReference(int type, byte[] token) { super(type, token); } /** * Get buffer bytes. * @return * Raw buffer bytes. */ public byte[] getBytes() { return super.getBytes(); } } /** * Specifies the size, in bytes, of the buffer pointed to by the pvBuffer member. */ public NativeLong cbBuffer; /** * Bit flags that indicate the type of buffer. Must be one of the values of * the SecBufferType enumeration. */ public NativeLong BufferType; /** * A pointer to a buffer. */ public Pointer pvBuffer; /** * Create a new SECBUFFER_EMPTY buffer. */ public SecBuffer() { cbBuffer = new NativeLong(0); pvBuffer = null; BufferType = new NativeLong(SECBUFFER_EMPTY); } /** * Create a SecBuffer of a given type and size. * @param type * Buffer type, one of SECBUFFER_EMTPY, etc. * @param size * Buffer size, eg. MAX_TOKEN_SIZE. */ public SecBuffer(int type, int size) { cbBuffer = new NativeLong(size); pvBuffer = new Memory(size); BufferType = new NativeLong(type); allocateMemory(); } /** * Create a SecBuffer of a given type with initial data. * @param type * Buffer type, one of SECBUFFER_EMTPY, etc. * @param token * Existing token. */ public SecBuffer(int type, byte[] token) { cbBuffer = new NativeLong(token.length); pvBuffer = new Memory(token.length); pvBuffer.write(0, token, 0, token.length); BufferType = new NativeLong(type); allocateMemory(); } /** * Get buffer bytes. * @return * Raw buffer bytes. */ public byte[] getBytes() { return pvBuffer.getByteArray(0, cbBuffer.intValue()); } } public static class SecBufferDesc extends Structure { /** * Version number. */ public NativeLong ulVersion; /** * Number of buffers. */ public NativeLong cBuffers; /** * Pointer to array of buffers. */ public SecBuffer.ByReference[] pBuffers; /** * Create a new SecBufferDesc with one SECBUFFER_EMPTY buffer. */ public SecBufferDesc() { ulVersion = new NativeLong(SECBUFFER_VERSION); cBuffers = new NativeLong(1); SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(); pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1); allocateMemory(); } /** * Create a new SecBufferDesc with initial data. * @param type * Token type. * @param token * Initial token data. */ public SecBufferDesc(int type, byte[] token) { ulVersion = new NativeLong(SECBUFFER_VERSION); cBuffers = new NativeLong(1); SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(type, token); pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1); allocateMemory(); } /** * Create a new SecBufferDesc with one SecBuffer of a given type and size. * @param type * @param tokenSize */ public SecBufferDesc(int type, int tokenSize) { ulVersion = new NativeLong(SECBUFFER_VERSION); cBuffers = new NativeLong(1); SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(type, tokenSize); pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1); allocateMemory(); } public byte[] getBytes() { if (pBuffers == null || cBuffers == null) { throw new RuntimeException("pBuffers | cBuffers"); } if (cBuffers.intValue() == 1) { return pBuffers[0].getBytes(); } throw new RuntimeException("cBuffers > 1"); } } /** * A security integer. */ public static class SECURITY_INTEGER extends Structure { public NativeLong dwLower; public NativeLong dwUpper; /** * An security integer of 0. */ public SECURITY_INTEGER() { dwLower = new NativeLong(0); dwUpper = new NativeLong(0); } } /** * A timestamp. */ public static class TimeStamp extends SECURITY_INTEGER { } /** * A pointer to an array of SecPkgInfo structures. */ public static class PSecPkgInfo extends Structure { public static class ByReference extends PSecPkgInfo implements Structure.ByReference { } /** * The first entry in an array of SecPkgInfo structures. */ public SecPkgInfo.ByReference pPkgInfo; public PSecPkgInfo() { } /** * An array of SecPkgInfo structures. */ public SecPkgInfo.ByReference[] toArray(int size) { return (SecPkgInfo.ByReference[]) pPkgInfo.toArray(size); } } /** * The SecPkgInfo structure provides general information about a security package, * such as its name and capabilities. */ public static class SecPkgInfo extends Structure { /** * A reference pointer to a SecPkgInfo structure. */ public static class ByReference extends SecPkgInfo implements Structure.ByReference { } /** * Set of bit flags that describes the capabilities of the security package. */ public NativeLong fCapabilities; /** * Specifies the version of the package protocol. Must be 1. */ public short wVersion; /** * Specifies a DCE RPC identifier, if appropriate. If the package does not implement one of * the DCE registered security systems, the reserved value SECPKG_ID_NONE is used. */ public short wRPCID; /** * Specifies the maximum size, in bytes, of the token. */ public NativeLong cbMaxToken; /** * Pointer to a null-terminated string that contains the name of the security package. */ public WString Name; /** * Pointer to a null-terminated string. This can be any additional string passed * back by the package. */ public WString Comment; /** * Create a new package info. */ public SecPkgInfo() { fCapabilities = new NativeLong(0); wVersion = 1; wRPCID = 0; cbMaxToken = new NativeLong(0); } } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/WTypes.java0000644000175000017500000000361511421126022025071 0ustar janjan/* * Copyright 2010 Digital Rapids Corp. */ /* Copyright (c) 2010 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. * * 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; /** * Constant defined in WTypes.h * @author scott.palmer */ public interface WTypes { public static final int CLSCTX_INPROC_SERVER = 0x1; public static final int CLSCTX_INPROC_HANDLER = 0x2; public static final int CLSCTX_LOCAL_SERVER = 0x4; public static final int CLSCTX_INPROC_SERVER16 = 0x8; public static final int CLSCTX_REMOTE_SERVER = 0x10; public static final int CLSCTX_INPROC_HANDLER16 = 0x20; public static final int CLSCTX_RESERVED1 = 0x40; public static final int CLSCTX_RESERVED2 = 0x80; public static final int CLSCTX_RESERVED3 = 0x100; public static final int CLSCTX_RESERVED4 = 0x200; public static final int CLSCTX_NO_CODE_DOWNLOAD = 0x400; public static final int CLSCTX_RESERVED5 = 0x800; public static final int CLSCTX_NO_CUSTOM_MARSHAL = 0x1000; public static final int CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000; public static final int CLSCTX_NO_FAILURE_LOG = 0x4000; public static final int CLSCTX_DISABLE_AAA = 0x8000; public static final int CLSCTX_ENABLE_AAA = 0x10000; public static final int CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000; public static final int CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000; public static final int CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000; } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java0000644000175000017500000001333011421126020025003 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import java.awt.Rectangle; import com.sun.jna.IntegerType; import com.sun.jna.Native; 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.win32.StdCallLibrary; /** * Ported from Windef.h. * Microsoft Windows SDK 6.0A. * @author dblock[at]dblock.org */ @SuppressWarnings("serial") public interface WinDef extends StdCallLibrary { public static final int MAX_PATH = 260; /** * 16-bit unsigned integer. */ public static class WORD extends IntegerType { public WORD() { this(0); } public WORD(long value) { super(2, value); } } /** * 32-bit unsigned integer. */ public static class DWORD extends IntegerType { public DWORD() { this(0); } public DWORD(long value) { super(4, value); } /** * Low WORD. * @return * Low WORD. */ public WORD getLow() { return new WORD(longValue() & 0xFF); } /** * High WORD. * @return * High WORD. */ public WORD getHigh() { return new WORD((longValue() >> 8) & 0xFF); } } /** * 32-bit signed integer. */ public static class LONG extends IntegerType { public LONG() { this(0); } public LONG(long value) { super(Native.LONG_SIZE, value); } } /** * Handle to a device context (DC). */ public static class HDC extends HANDLE { public HDC() { } public HDC(Pointer p) { super(p); } } /** * Handle to an icon. */ public static class HICON extends HANDLE { public HICON() { } public HICON(Pointer p) { super(p); } } /** * Handle to a cursor. */ public static class HCURSOR extends HICON { public HCURSOR() { } public HCURSOR(Pointer p) { super(p); } } /** * Handle to a cursor. */ public static class HMENU extends HANDLE { public HMENU() { } public HMENU(Pointer p) { super(p); } } /** * Handle to a pen. */ public static class HPEN extends HANDLE { public HPEN() { } public HPEN(Pointer p) { super(p); } } /** * Handle to a resource. */ public static class HRSRC extends HANDLE { public HRSRC() { } public HRSRC(Pointer p) { super(p); } } /** * Handle to a palette. */ public static class HPALETTE extends HANDLE { public HPALETTE() { } public HPALETTE(Pointer p) { super(p); } } /** * Handle to a bitmap. */ public static class HBITMAP extends HANDLE { public HBITMAP() { } public HBITMAP(Pointer p) { super(p); } } /** * Handle to a region. */ public static class HRGN extends HANDLE { public HRGN() { } public HRGN(Pointer p) { super(p); } } /** * Handle to a window. */ public static class HWND extends HANDLE { public HWND() { } public HWND(Pointer p) { super(p); } } /** * Handle to an instance. */ public static class HINSTANCE extends HANDLE { } /** * Handle to a module. The value is the base address of the module. */ public static class HMODULE extends HINSTANCE { } /** * Handle to a font. */ public static class HFONT extends HANDLE { public HFONT() { } public HFONT(Pointer p) { super(p); } } /** * Message parameter. */ public static class LPARAM extends LONG_PTR { public LPARAM() { this(0); } public LPARAM(long value) { super(value); } } /** * Signed result of message processing. */ public static class LRESULT extends LONG_PTR { public LRESULT() { this(0); } public LRESULT(long value) { super(value); } } /** * Unsigned INT_PTR. */ public static class UINT_PTR extends IntegerType { public UINT_PTR() { super(Pointer.SIZE); } public UINT_PTR(long value) { super(Pointer.SIZE, value); } public Pointer toPointer() { return Pointer.createConstant(longValue()); } } /** * Message parameter. */ public static class WPARAM extends UINT_PTR { public WPARAM() { this(0); } public WPARAM(long value) { super(value); } } public class RECT extends Structure { public int left; public int top; public int right; public int bottom; public Rectangle toRectangle() { return new Rectangle(left, top, right-left, bottom-top); } public String toString() { return "[(" + left + "," + top + ")(" + right + "," + bottom + ")]"; } } /** * 64-bit unsigned integer. */ public static class ULONGLONG extends IntegerType { public ULONGLONG() { this(0); } public ULONGLONG(long value) { super(8, value); } } /** * 64-bit unsigned integer. */ public static class DWORDLONG extends IntegerType { public DWORDLONG() { this(0); } public DWORDLONG(long value) { super(8, value); } } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Win32Exception.java0000644000175000017500000000276311421126020026420 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.platform.win32.WinNT.HRESULT; /** * Win32 exception. * @author dblock[at]dblock[dot]org */ public class Win32Exception extends RuntimeException { private static final long serialVersionUID = 1L; private HRESULT _hr; /** * Returns the error code of the error. * @return * Error code. */ public HRESULT getHR() { return _hr; } /** * New Win32 exception from HRESULT. * @param hr * HRESULT */ public Win32Exception(HRESULT hr) { super(Kernel32Util.formatMessageFromHR(hr)); _hr = hr; } /** * New Win32 exception from an error code, usually obtained from GetLastError. * @param code * Error code. */ public Win32Exception(int code) { this(W32Errors.HRESULT_FROM_WIN32(code)); } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java0000644000175000017500000002236511421126022025235 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR; 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.RECT; import com.sun.jna.platform.win32.WinDef.WPARAM; import com.sun.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 { public HWND HWND_BROADCAST = new HWND(Pointer.createConstant(0xFFFF)); public int FLASHW_STOP = 0; public int FLASHW_CAPTION = 1; public int FLASHW_TRAY = 2; public int FLASHW_ALL = (FLASHW_CAPTION | FLASHW_TRAY); public int FLASHW_TIMER = 4; public int FLASHW_TIMERNOFG = 12; public int IMAGE_BITMAP = 0; public int IMAGE_ICON = 1; public int IMAGE_CURSOR = 2; public int IMAGE_ENHMETAFILE = 3; public int LR_DEFAULTCOLOR = 0x0000; public int LR_MONOCHROME = 0x0001; public int LR_COLOR = 0x0002; public int LR_COPYRETURNORG = 0x0004; public int LR_COPYDELETEORG = 0x0008; public int LR_LOADFROMFILE = 0x0010; public int LR_LOADTRANSPARENT = 0x0020; public int LR_DEFAULTSIZE = 0x0040; public int LR_VGACOLOR = 0x0080; public int LR_LOADMAP3DCOLORS = 0x1000; public int LR_CREATEDIBSECTION = 0x2000; public int LR_COPYFROMRESOURCE = 0x4000; public 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; } 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; } public int GWL_EXSTYLE = -20; public int GWL_STYLE = -16; public int GWL_WNDPROC = -4; public int GWL_HINSTANCE = -6; public int GWL_ID = -12; public int GWL_USERDATA = -21; public int DWL_DLGPROC = 4; public int DWL_MSGRESULT = 0; public int DWL_USER = 8; public int WS_EX_COMPOSITED = 0x20000000; public int WS_EX_LAYERED = 0x80000; public int WS_EX_TRANSPARENT = 32; public int LWA_COLORKEY = 1; public int LWA_ALPHA = 2; public int ULW_COLORKEY = 1; public int ULW_ALPHA = 2; public 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; } } public class MSG extends Structure { public HWND hWnd; public int message; public WPARAM wParam; public LPARAM lParam; public int time; public POINT pt; } public class FLASHWINFO extends Structure { public int cbSize; public HANDLE hWnd; public int dwFlags; public int uCount; public int 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; } } public int AC_SRC_OVER = 0x00; public int AC_SRC_ALPHA = 0x01; public int AC_SRC_NO_PREMULT_ALPHA = 0x01; public 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; } public int VK_SHIFT = 16; public int VK_LSHIFT = 0xA0; public int VK_RSHIFT = 0xA1; public int VK_CONTROL = 17; public int VK_LCONTROL = 0xA2; public int VK_RCONTROL = 0xA3; public int VK_MENU = 18; public int VK_LMENU = 0xA4; public int VK_RMENU = 0xA5; public int WH_KEYBOARD = 2; public int WH_MOUSE = 7; public int WH_KEYBOARD_LL = 13; public int WH_MOUSE_LL = 14; public class HHOOK extends HANDLE { } public interface HOOKPROC extends StdCallCallback { } public int WM_KEYDOWN = 256; public int WM_KEYUP = 257; public int WM_SYSKEYDOWN = 260; public int WM_SYSKEYUP = 261; public class KBDLLHOOKSTRUCT extends Structure { public int vkCode; public int scanCode; public int flags; public int time; public ULONG_PTR dwExtraInfo; } public int SM_CXSCREEN = 0; public int SM_CYSCREEN = 1; public int SM_CXVSCROLL = 2; public int SM_CYHSCROLL = 3; public int SM_CYCAPTION = 4; public int SM_CXBORDER = 5; public int SM_CYBORDER = 6; public int SM_CXDLGFRAME = 7; public int SM_CYDLGFRAME = 8; public int SM_CYVTHUMB = 9; public int SM_CXHTHUMB = 10; public int SM_CXICON = 11; public int SM_CYICON = 12; public int SM_CXCURSOR = 13; public int SM_CYCURSOR = 14; public int SM_CYMENU = 15; public int SM_CXFULLSCREEN = 16; public int SM_CYFULLSCREEN = 17; public int SM_CYKANJIWINDOW = 18; public int SM_MOUSEPRESENT = 19; public int SM_CYVSCROLL = 20; public int SM_CXHSCROLL = 21; public int SM_DEBUG = 22; public int SM_SWAPBUTTON = 23; public int SM_RESERVED1 = 24; public int SM_RESERVED2 = 25; public int SM_RESERVED3 = 26; public int SM_RESERVED4 = 27; public int SM_CXMIN = 28; public int SM_CYMIN = 29; public int SM_CXSIZE = 30; public int SM_CYSIZE = 31; public int SM_CXFRAME = 32; public int SM_CYFRAME = 33; public int SM_CXMINTRACK = 34; public int SM_CYMINTRACK = 35; public int SM_CXDOUBLECLK = 36; public int SM_CYDOUBLECLK = 37; public int SM_CXICONSPACING = 38; public int SM_CYICONSPACING = 39; public int SM_MENUDROPALIGNMENT = 40; public int SM_PENWINDOWS = 41; public int SM_DBCSENABLED = 42; public int SM_CMOUSEBUTTONS = 43; public int SM_CXFIXEDFRAME = SM_CXDLGFRAME; /* ;win40 name change */ public int SM_CYFIXEDFRAME = SM_CYDLGFRAME; /* ;win40 name change */ public int SM_CXSIZEFRAME = SM_CXFRAME; /* ;win40 name change */ public int SM_CYSIZEFRAME = SM_CYFRAME; /* ;win40 name change */ public int SM_SECURE = 44; public int SM_CXEDGE = 45; public int SM_CYEDGE = 46; public int SM_CXMINSPACING = 47; public int SM_CYMINSPACING = 48; public int SM_CXSMICON = 49; public int SM_CYSMICON = 50; public int SM_CYSMCAPTION = 51; public int SM_CXSMSIZE = 52; public int SM_CYSMSIZE = 53; public int SM_CXMENUSIZE = 54; public int SM_CYMENUSIZE = 55; public int SM_ARRANGE = 56; public int SM_CXMINIMIZED = 57; public int SM_CYMINIMIZED = 58; public int SM_CXMAXTRACK = 59; public int SM_CYMAXTRACK = 60; public int SM_CXMAXIMIZED = 61; public int SM_CYMAXIMIZED = 62; public int SM_NETWORK = 63; public int SM_CLEANBOOT = 67; public int SM_CXDRAG = 68; public int SM_CYDRAG = 69; public int SM_SHOWSOUNDS = 70; public int SM_CXMENUCHECK = 71; public int SM_CYMENUCHECK = 72; public int SM_SLOWMACHINE = 73; public int SM_MIDEASTENABLED = 74; public int SM_MOUSEWHEELPRESENT = 75; public int SM_XVIRTUALSCREEN = 76; public int SM_YVIRTUALSCREEN = 77; public int SM_CXVIRTUALSCREEN = 78; public int SM_CYVIRTUALSCREEN = 79; public int SM_CMONITORS = 80; public int SM_SAMEDISPLAYFORMAT = 81; public int SM_IMMENABLED = 82; public int SM_CXFOCUSBORDER = 83; public int SM_CYFOCUSBORDER = 84; public int SM_TABLETPC = 86; public int SM_MEDIACENTER = 87; public int SM_STARTER = 88; public int SM_SERVERR2 = 89; public int SM_MOUSEHORIZONTALWHEELPRESENT = 91; public int SM_CXPADDEDBORDER = 92; public int SM_REMOTESESSION = 0x1000; public int SM_SHUTTINGDOWN = 0x2000; public int SM_REMOTECONTROL = 0x2001; public int SM_CARETBLINKINGENABLED = 0x2002; } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Ole32.java0000644000175000017500000001131511421126016024521 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.Guid.GUID; import com.sun.jna.platform.win32.WinNT.HRESULT; import com.sun.jna.ptr.PointerByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; /** * Ole32.dll Interface. * @author dblock[at]dblock.org */ public interface Ole32 extends StdCallLibrary { Ole32 INSTANCE = (Ole32) Native.loadLibrary( "Ole32", Ole32.class, W32APIOptions.UNICODE_OPTIONS); /** * Creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers. * @param pguid * A pointer to the requested GUID. * @return * S_OK if the GUID was successfully created. */ HRESULT CoCreateGuid(GUID.ByReference pguid); /** * Converts a globally unique identifier (GUID) into a string of printable characters. * @param rguid * The GUID to be converted. * @param lpsz * A pointer to a caller-allocated string variable to receive the resulting string. * @param cchMax * The number of characters available in the lpsz buffer. * @return * If the function succeeds, the return value is the number of characters in the * returned string, including the null terminator. If the buffer is too small to contain * the string, the return value is 0. */ int StringFromGUID2(GUID.ByReference rguid, char[] lpsz, int cchMax); /** * Converts a string generated by the StringFromIID function back into the * original interface identifier (IID). * @param lpsz * A pointer to the string representation of the IID. * @param lpiid * A pointer to the requested IID on return. * @return * This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, * and S_OK. */ HRESULT IIDFromString(String lpsz, GUID.ByReference lpiid); /** * Initializes the COM library for use by the calling thread, sets the thread's * concurrency model, and creates a new apartment for the thread if one is required. * @param reserved This parameter is reserved and must be NULL. * @param dwCoInit The concurrency model and initialization options for the * thread. Values for this parameter are taken from the COINIT enumeration. * Any combination of values from COINIT can be used, except that the * COINIT_APARTMENTTHREADED and COINIT_MULTITHREADED flags cannot both be * set. The default (and only sane choice) is COINIT_MULTITHREADED. * @return This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following values. S_OK, S_FALSE, RPC_E_CHANGED_MODE */ HRESULT CoInitializeEx(Pointer reserved, int dwCoInit); /** * Closes the COM library on the current thread, unloads all DLLs loaded by * the thread, frees any other resources that the thread maintains, and * forces all RPC connections on the thread to close. * */ void CoUninitialize(); /** * Creates a single uninitialized object of the class associated with a specified CLSID. * @param rclsid The CLSID associated with the data and code that will be used to create the object. * @param pUnkOuter If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL, pointer to the aggregate object's IUnknown interface (the controlling IUnknown). * @param dwClsContext Context in which the code that manages the newly created object will run. The values are taken from the enumeration CLSCTX defined in WTypes. * @param riid A reference to the identifier of the interface to be used to communicate with the object. * @param ppv Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppv contains the requested interface pointer. Upon failure, *ppv contains NULL. * @return an HRESULT */ HRESULT CoCreateInstance( GUID rclsid, Pointer pUnkOuter, int dwClsContext, GUID riid, PointerByReference ppv); } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/WinNT.java0000644000175000017500000013274511421126022024644 0ustar janjan/* 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. * * 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.FromNativeContext; import com.sun.jna.Memory; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; import com.sun.jna.PointerType; import com.sun.jna.Structure; import com.sun.jna.Union; import com.sun.jna.platform.win32.WinDef.DWORD; import com.sun.jna.platform.win32.WinDef.WORD; import com.sun.jna.ptr.ByReference; import com.sun.jna.win32.StdCallLibrary; /** * This module defines the 32-Bit Windows types and constants that are defined * by NT, but exposed through the Win32 API. * Ported from WinNT.h. * Microsoft Windows SDK 6.0A. * @author dblock[at]dblock.org */ @SuppressWarnings("serial") public interface WinNT extends StdCallLibrary { // // The following are masks for the predefined standard access types // public static final int DELETE = 0x00010000; public static final int READ_CONTROL = 0x00020000; public static final int WRITE_DAC = 0x00040000; public static final int WRITE_OWNER = 0x00080000; public static final int SYNCHRONIZE = 0x00100000; public static final int STANDARD_RIGHTS_REQUIRED = 0x000F0000; public static final int STANDARD_RIGHTS_READ = READ_CONTROL; public static final int STANDARD_RIGHTS_WRITE = READ_CONTROL; public static final int STANDARD_RIGHTS_EXECUTE = READ_CONTROL; public static final int STANDARD_RIGHTS_ALL = 0x001F0000; public static final int SPECIFIC_RIGHTS_ALL = 0x0000FFFF; // // Token Specific Access Rights. // /** * Required to attach a primary token to a process. The * SE_ASSIGNPRIMARYTOKEN_NAME privilege is also required to accomplish this * task. */ public static final int TOKEN_ASSIGN_PRIMARY = 0x0001; /** * Required to duplicate an access token. */ public static final int TOKEN_DUPLICATE = 0x0002; /** * Required to attach an impersonation access token to a process. */ public static final int TOKEN_IMPERSONATE = 0x0004; /** * Required to query an access token. */ public static final int TOKEN_QUERY = 0x0008; /** * Required to query the source of an access token. */ public static final int TOKEN_QUERY_SOURCE = 0x0010; /** * Required to enable or disable the privileges in an access token. */ public static final int TOKEN_ADJUST_PRIVILEGES = 0x0020; /** * Required to adjust the attributes of the groups in an access token. */ public static final int TOKEN_ADJUST_GROUPS = 0x0040; /** * Required to change the default owner, primary group, or DACL of an access * token. */ public static final int TOKEN_ADJUST_DEFAULT = 0x0080; /** * Required to adjust the session ID of an access token. The SE_TCB_NAME * privilege is required. */ public static final int TOKEN_ADJUST_SESSIONID = 0x0100; public static final int TOKEN_ALL_ACCESS_P = STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_QUERY_SOURCE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT; /** * Combines all possible access rights for a token. */ public static final int TOKEN_ALL_ACCESS = TOKEN_ALL_ACCESS_P | TOKEN_ADJUST_SESSIONID; /** * Combines STANDARD_RIGHTS_READ and TOKEN_QUERY. */ public static final int TOKEN_READ = STANDARD_RIGHTS_READ | TOKEN_QUERY; /** * Combines STANDARD_RIGHTS_WRITE, TOKEN_ADJUST_PRIVILEGES, * TOKEN_ADJUST_GROUPS, and TOKEN_ADJUST_DEFAULT. */ public static final int TOKEN_WRITE = STANDARD_RIGHTS_WRITE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT; /** * Combines STANDARD_RIGHTS_EXECUTE and TOKEN_IMPERSONATE. */ public static final int TOKEN_EXECUTE = STANDARD_RIGHTS_EXECUTE; public static final int THREAD_TERMINATE = 0x0001; public static final int THREAD_SUSPEND_RESUME = 0x0002; public static final int THREAD_GET_CONTEXT = 0x0008; public static final int THREAD_SET_CONTEXT = 0x0010; public static final int THREAD_QUERY_INFORMATION = 0x0040; public static final int THREAD_SET_INFORMATION = 0x0020; public static final int THREAD_SET_THREAD_TOKEN = 0x0080; public static final int THREAD_IMPERSONATE = 0x0100; public static final int THREAD_DIRECT_IMPERSONATION = 0x0200; public static final int THREAD_SET_LIMITED_INFORMATION = 0x0400; public static final int THREAD_QUERY_LIMITED_INFORMATION = 0x0800; public static final int THREAD_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF; /** * The SECURITY_IMPERSONATION_LEVEL enumeration type contains values that specify security * impersonation levels. Security impersonation levels govern the degree to which a server * process can act on behalf of a client process. */ public abstract class SECURITY_IMPERSONATION_LEVEL { /** * The server process cannot obtain identification information about the client, * and it cannot impersonate the client. It is defined with no value given, and * thus, by ANSI C rules, defaults to a value of zero. */ public static final int SecurityAnonymous = 0; /** * The server process can obtain information about the client, such as security * identifiers and privileges, but it cannot impersonate the client. This is useful * for servers that export their own objects, for example, database products that * export tables and views. Using the retrieved client-security information, the * server can make access-validation decisions without being able to use other * services that are using the client's security context. */ public static final int SecurityIdentification = 1; /** * The server process can impersonate the client's security context on its local system. * The server cannot impersonate the client on remote systems. */ public static final int SecurityImpersonation = 2; /** * The server process can impersonate the client's security context on remote systems. */ public static final int SecurityDelegation = 3; } /** * The TOKEN_INFORMATION_CLASS enumeration type contains values that specify the type of * information being assigned to or retrieved from an access token. */ public abstract class TOKEN_INFORMATION_CLASS { public static final int TokenUser = 1; public static final int TokenGroups = 2; public static final int TokenPrivileges = 3; public static final int TokenOwner = 4; public static final int TokenPrimaryGroup = 5; public static final int TokenDefaultDacl = 6; public static final int TokenSource = 7; public static final int TokenType = 8; public static final int TokenImpersonationLevel = 9; public static final int TokenStatistics = 10; public static final int TokenRestrictedSids = 11; public static final int TokenSessionId = 12; public static final int TokenGroupsAndPrivileges = 13; public static final int TokenSessionReference = 14; public static final int TokenSandBoxInert = 15; public static final int TokenAuditPolicy = 16; public static final int TokenOrigin = 17; public static final int TokenElevationType = 18; public static final int TokenLinkedToken = 19; public static final int TokenElevation = 20; public static final int TokenHasRestrictions = 21; public static final int TokenAccessInformation = 22; public static final int TokenVirtualizationAllowed = 23; public static final int TokenVirtualizationEnabled = 24; public static final int TokenIntegrityLevel = 25; public static final int TokenUIAccess = 26; public static final int TokenMandatoryPolicy = 27; public static final int TokenLogonSid = 28; } /** * The SID_AND_ATTRIBUTES structure represents a security identifier (SID) and its * attributes. SIDs are used to uniquely identify users or groups. */ public static class SID_AND_ATTRIBUTES extends Structure { public SID_AND_ATTRIBUTES() { super(); } public SID_AND_ATTRIBUTES(Pointer memory) { useMemory(memory); read(); } /** * Pointer to a SID structure. */ public PSID.ByReference Sid; /** * Specifies attributes of the SID. This value contains up to 32 one-bit flags. * Its meaning depends on the definition and use of the SID. */ public int Attributes; } /** * The TOKEN_OWNER structure contains the default owner * security identifier (SID) that will be applied to newly created objects. */ public static class TOKEN_OWNER extends Structure { public TOKEN_OWNER() { super(); } public TOKEN_OWNER(Pointer memory) { super(memory); read(); } /** * Pointer to a SID structure representing a user who will become the owner of any * objects created by a process using this access token. The SID must be one of the * user or group SIDs already in the token. */ public PSID.ByReference Owner; // PSID } public static class PSID extends Structure { public static class ByReference extends PSID implements Structure.ByReference { } public PSID() { super(); } public PSID(byte[] data) { super(); Memory memory = new Memory(data.length); memory.write(0, data, 0, data.length); setPointer(memory); } public PSID(int size) { super(new Memory(size)); } public PSID(Pointer memory) { super(memory); read(); } public void setPointer(Pointer p) { useMemory(p); read(); } public byte[] getBytes() { int len = Advapi32.INSTANCE.GetLengthSid(this); return getPointer().getByteArray(0, len); } public Pointer sid; } public static class PSIDByReference extends ByReference { public PSIDByReference() { this(null); } public PSIDByReference(PSID h) { super(Pointer.SIZE); setValue(h); } public void setValue(PSID h) { getPointer().setPointer(0, h != null ? h.getPointer() : null); } public PSID getValue() { Pointer p = getPointer().getPointer(0); if (p == null) return null; PSID h = new PSID(); h.setPointer(p); return h; } } /** * The TOKEN_USER structure identifies the user associated with an access token. */ public static class TOKEN_USER extends Structure { public TOKEN_USER() { super(); } public TOKEN_USER(Pointer memory) { super(memory); read(); } public TOKEN_USER(int size) { super(new Memory(size)); } /** * Specifies a SID_AND_ATTRIBUTES structure representing the user associated with * the access token. There are currently no attributes defined for user security * identifiers (SIDs). */ public SID_AND_ATTRIBUTES User; } /** * The TOKEN_GROUPS structure contains information about the group security identifiers * (SIDs) in an access token. */ public static class TOKEN_GROUPS extends Structure { public TOKEN_GROUPS() { super(); } public TOKEN_GROUPS(Pointer memory) { super(memory); read(); } public TOKEN_GROUPS(int size) { super(new Memory(size)); } /** * Specifies the number of groups in the access token. */ public int GroupCount; public SID_AND_ATTRIBUTES Group0; /** * Specifies an array of SID_AND_ATTRIBUTES structures that contain a set of SIDs * and corresponding attributes. */ public SID_AND_ATTRIBUTES[] getGroups() { return (SID_AND_ATTRIBUTES[]) Group0.toArray(GroupCount); } } /** * The SID_NAME_USE enumeration type contains values that specify the type of a security identifier (SID). */ public abstract class SID_NAME_USE { /** * Indicates a user SID. */ public static final int SidTypeUser = 1; /** * Indicates a group SID. */ public static final int SidTypeGroup = 2; /** * Indicates a domain SID. */ public static final int SidTypeDomain = 3; /** * Indicates an alias SID. */ public static final int SidTypeAlias = 4; /** * Indicates a SID for a well-known group. */ public static final int SidTypeWellKnownGroup = 5; /** * Indicates a SID for a deleted account. */ public static final int SidTypeDeletedAccount = 6; /** * Indicates an invalid SID. */ public static final int SidTypeInvalid = 7; /** * Indicates an unknown SID type. */ public static final int SidTypeUnknown = 8; /** * Indicates a SID for a computer. */ public static final int SidTypeComputer = 9; /** * ? */ public static final int SidTypeLabel = 10; } public static final int FILE_LIST_DIRECTORY = 0x00000001; public static final int CREATE_NEW = 1; public static final int CREATE_ALWAYS = 2; public static final int OPEN_EXISTING = 3; public static final int OPEN_ALWAYS = 4; public static final int TRUNCATE_EXISTING = 5; public static final int FILE_FLAG_WRITE_THROUGH = 0x80000000; public static final int FILE_FLAG_OVERLAPPED = 0x40000000; public static final int FILE_FLAG_NO_BUFFERING = 0x20000000; public static final int FILE_FLAG_RANDOM_ACCESS = 0x10000000; public static final int FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000; public static final int FILE_FLAG_DELETE_ON_CLOSE = 0x04000000; public static final int FILE_FLAG_BACKUP_SEMANTICS = 0x02000000; public static final int FILE_FLAG_POSIX_SEMANTICS = 0x01000000; public static final int FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000; public static final int FILE_FLAG_OPEN_NO_RECALL = 0x00100000; public static final int GENERIC_WRITE = 0x40000000; public static class SECURITY_ATTRIBUTES extends Structure { public final int nLength = size(); public Pointer lpSecurityDescriptor; public boolean bInheritHandle; } public static final int PAGE_READONLY = 0x02; public static final int PAGE_READWRITE = 0x04; public static final int PAGE_WRITECOPY = 0x08; public static final int PAGE_EXECUTE = 0x10; public static final int PAGE_EXECUTE_READ = 0x20; public static final int PAGE_EXECUTE_READWRITE = 0x40; public static final int SECTION_QUERY = 0x0001; public static final int SECTION_MAP_WRITE = 0x0002; public static final int SECTION_MAP_READ = 0x0004; public static final int SECTION_MAP_EXECUTE = 0x0008; public static final int SECTION_EXTEND_SIZE = 0x0010; public static final int FILE_SHARE_READ = 0x00000001; public static final int FILE_SHARE_WRITE = 0x00000002; public static final int FILE_SHARE_DELETE = 0x00000004; public static final int FILE_ATTRIBUTE_READONLY = 0x00000001; public static final int FILE_ATTRIBUTE_HIDDEN = 0x00000002; public static final int FILE_ATTRIBUTE_SYSTEM = 0x00000004; public static final int FILE_ATTRIBUTE_DIRECTORY = 0x00000010; public static final int FILE_ATTRIBUTE_ARCHIVE = 0x00000020; public static final int FILE_ATTRIBUTE_DEVICE = 0x00000040; public static final int FILE_ATTRIBUTE_NORMAL = 0x00000080; public static final int FILE_ATTRIBUTE_TEMPORARY = 0x00000100; public static final int FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200; public static final int FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400; public static final int FILE_ATTRIBUTE_COMPRESSED = 0x00000800; public static final int FILE_ATTRIBUTE_OFFLINE = 0x00001000; public static final int FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000; public static final int FILE_ATTRIBUTE_ENCRYPTED = 0x00004000; public static final int FILE_ATTRIBUTE_VIRTUAL = 0x00010000; public static final int FILE_NOTIFY_CHANGE_FILE_NAME = 0x00000001; public static final int FILE_NOTIFY_CHANGE_DIR_NAME = 0x00000002; public static final int FILE_NOTIFY_CHANGE_NAME = 0x00000003; public static final int FILE_NOTIFY_CHANGE_ATTRIBUTES = 0x00000004; public static final int FILE_NOTIFY_CHANGE_SIZE = 0x00000008; public static final int FILE_NOTIFY_CHANGE_LAST_WRITE = 0x00000010; public static final int FILE_NOTIFY_CHANGE_LAST_ACCESS = 0x00000020; public static final int FILE_NOTIFY_CHANGE_CREATION = 0x00000040; public static final int FILE_NOTIFY_CHANGE_SECURITY = 0x00000100; public static final int FILE_ACTION_ADDED = 0x00000001; public static final int FILE_ACTION_REMOVED = 0x00000002; public static final int FILE_ACTION_MODIFIED = 0x00000003; public static final int FILE_ACTION_RENAMED_OLD_NAME = 0x00000004; public static final int FILE_ACTION_RENAMED_NEW_NAME = 0x00000005; public static final int FILE_CASE_SENSITIVE_SEARCH = 0x00000001; public static final int FILE_CASE_PRESERVED_NAMES = 0x00000002; public static final int FILE_UNICODE_ON_DISK = 0x00000004; public static final int FILE_PERSISTENT_ACLS = 0x00000008; public static final int FILE_FILE_COMPRESSION = 0x00000010; public static final int FILE_VOLUME_QUOTAS = 0x00000020; public static final int FILE_SUPPORTS_SPARSE_FILES = 0x00000040; public static final int FILE_SUPPORTS_REPARSE_POINTS = 0x00000080; public static final int FILE_SUPPORTS_REMOTE_STORAGE = 0x00000100; public static final int FILE_VOLUME_IS_COMPRESSED = 0x00008000; public static final int FILE_SUPPORTS_OBJECT_IDS = 0x00010000; public static final int FILE_SUPPORTS_ENCRYPTION = 0x00020000; public static final int FILE_NAMED_STREAMS = 0x00040000; public static final int FILE_READ_ONLY_VOLUME = 0x00080000; public static final int FILE_SEQUENTIAL_WRITE_ONCE = 0x00100000; public static final int FILE_SUPPORTS_TRANSACTIONS = 0x00200000; /** * The FILE_NOTIFY_INFORMATION structure describes the changes found by the * ReadDirectoryChangesW function. * * This structure is non-trivial since it is a pattern stamped into a large * block of result memory rather than something that stands alone or is used * for input. */ public static class FILE_NOTIFY_INFORMATION extends Structure { public int NextEntryOffset; public int Action; public int FileNameLength; // filename is not nul-terminated, so we can't use a String/WString public char[] FileName = new char[1]; private FILE_NOTIFY_INFORMATION() { } public FILE_NOTIFY_INFORMATION(int size) { if (size < size()) { throw new IllegalArgumentException("Size must greater than " + size() + ", requested " + size); } allocateMemory(size); } /** WARNING: this filename may be either the short or long form of the filename. */ public String getFilename() { return new String(FileName, 0, FileNameLength/2); } public void read() { // avoid reading filename until we know how long it is FileName = new char[0]; super.read(); FileName = getPointer().getCharArray(12, FileNameLength/2); } public FILE_NOTIFY_INFORMATION next() { if (NextEntryOffset == 0) return null; FILE_NOTIFY_INFORMATION next = new FILE_NOTIFY_INFORMATION(); next.useMemory(getPointer(), NextEntryOffset); next.read(); return next; } } /** * Registry options. */ public static final int KEY_QUERY_VALUE = 0x0001; public static final int KEY_SET_VALUE = 0x0002; public static final int KEY_CREATE_SUB_KEY = 0x0004; public static final int KEY_ENUMERATE_SUB_KEYS = 0x0008; public static final int KEY_NOTIFY = 0x0010; public static final int KEY_CREATE_LINK = 0x0020; public static final int KEY_WOW64_32KEY = 0x0200; public static final int KEY_WOW64_64KEY = 0x0100; public static final int KEY_WOW64_RES = 0x0300; public static final int KEY_READ = STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY & (~SYNCHRONIZE); public static final int KEY_WRITE = STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY & (~SYNCHRONIZE); public static final int KEY_EXECUTE = KEY_READ & (~SYNCHRONIZE); public static final int KEY_ALL_ACCESS = STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK & (~SYNCHRONIZE); // // Open/Create Options // /** * Parameter is reserved. */ public static final int REG_OPTION_RESERVED = 0x00000000; /** * Key is preserved when system is rebooted. */ public static final int REG_OPTION_NON_VOLATILE = 0x00000000; /** * Key is not preserved when system is rebooted. */ public static final int REG_OPTION_VOLATILE = 0x00000001; /** * Created key is a symbolic link. */ public static final int REG_OPTION_CREATE_LINK = 0x00000002; /** * Open for backup or restore special access rules privilege required. */ public static final int REG_OPTION_BACKUP_RESTORE = 0x00000004; /** * Open symbolic link. */ public static final int REG_OPTION_OPEN_LINK = 0x00000008; public static final int REG_LEGAL_OPTION = REG_OPTION_RESERVED | REG_OPTION_NON_VOLATILE | REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK | REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK; // // Key creation/open disposition // /** * New Registry Key created. */ public static final int REG_CREATED_NEW_KEY = 0x00000001; /** * Existing Key opened. */ public static final int REG_OPENED_EXISTING_KEY = 0x00000002; public static final int REG_STANDARD_FORMAT = 1; public static final int REG_LATEST_FORMAT = 2; public static final int REG_NO_COMPRESSION = 4; // // Key restore & hive load flags // /** * Restore whole hive volatile. */ public static final int REG_WHOLE_HIVE_VOLATILE = 0x00000001; /** * Unwind changes to last flush. */ public static final int REG_REFRESH_HIVE = 0x00000002; /** * Never lazy flush this hive. */ public static final int REG_NO_LAZY_FLUSH = 0x00000004; /** * Force the restore process even when we have open handles on subkeys. */ public static final int REG_FORCE_RESTORE = 0x00000008; /** * Loads the hive visible to the calling process. */ public static final int REG_APP_HIVE = 0x00000010; /** * Hive cannot be mounted by any other process while in use. */ public static final int REG_PROCESS_PRIVATE = 0x00000020; /** * Starts Hive Journal. */ public static final int REG_START_JOURNAL = 0x00000040; /** * Grow hive file in exact 4k increments. */ public static final int REG_HIVE_EXACT_FILE_GROWTH = 0x00000080; /** * No RM is started for this hive = no transactions. */ public static final int REG_HIVE_NO_RM = 0x00000100; /** * Legacy single logging is used for this hive. */ public static final int REG_HIVE_SINGLE_LOG = 0x00000200; // // Unload Flags // public static final int REG_FORCE_UNLOAD = 1; // // Notify filter values // public static final int REG_NOTIFY_CHANGE_NAME = 0x00000001; public static final int REG_NOTIFY_CHANGE_ATTRIBUTES = 0x00000002; public static final int REG_NOTIFY_CHANGE_LAST_SET = 0x00000004; public static final int REG_NOTIFY_CHANGE_SECURITY = 0x00000008; public static final int REG_LEGAL_CHANGE_FILTER = REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_ATTRIBUTES | REG_NOTIFY_CHANGE_LAST_SET | REG_NOTIFY_CHANGE_SECURITY; // // Predefined Value Types. // /** * No value type. */ public static final int REG_NONE = 0 ; /** * Unicode null-terminated string. */ public static final int REG_SZ = 1; /** * Unicode null-terminated string with environment variable references. */ public static final int REG_EXPAND_SZ = 2; /** * Free-formed binary. */ public static final int REG_BINARY = 3; /** * 32-bit number. */ public static final int REG_DWORD = 4; /** * 32-bit number, same as REG_DWORD. */ public static final int REG_DWORD_LITTLE_ENDIAN = 4; /** * 32-bit number. */ public static final int REG_DWORD_BIG_ENDIAN = 5; /** * Symbolic link (unicode). */ public static final int REG_LINK = 6; /** * Multiple unicode strings. */ public static final int REG_MULTI_SZ = 7; /** * Resource list in the resource map. */ public static final int REG_RESOURCE_LIST = 8; /** * Resource list in the hardware description. */ public static final int REG_FULL_RESOURCE_DESCRIPTOR = 9; /** * */ public static final int REG_RESOURCE_REQUIREMENTS_LIST = 10 ; /** * 64-bit number. */ public static final int REG_QWORD = 11 ; /** * 64-bit number, same as REG_QWORD. */ public static final int REG_QWORD_LITTLE_ENDIAN = 11; /** * A 64-bit value that is guaranteed to be unique on the operating system * that generated it until the system is restarted. */ public static class LUID extends Structure { int LowPart; int HighPart; } /** * A 64-bit integer; */ public static class LARGE_INTEGER extends Structure { public static class ByReference extends LARGE_INTEGER implements Structure.ByReference { } public static class LowHigh extends Structure { public DWORD LowPart; public DWORD HighPart; } public static class UNION extends Union { public LowHigh lh; public long value; } public UNION u; /** * Low DWORD. * @return * DWORD. */ public DWORD getLow() { return u.lh.LowPart; } /** * High DWORD. * @return * DWORD. */ public DWORD getHigh() { return u.lh.HighPart; } /** * 64-bit value. * @return * 64-bit value. */ public long getValue() { return u.value; } } /** * Handle to an object. */ public static class HANDLE extends PointerType { private boolean immutable; public HANDLE() { } public HANDLE(Pointer p) { setPointer(p); immutable = true; } /** Override to the appropriate object for INVALID_HANDLE_VALUE. */ public Object fromNative(Object nativeValue, FromNativeContext context) { Object o = super.fromNative(nativeValue, context); if (WinBase.INVALID_HANDLE_VALUE.equals(o)) return WinBase.INVALID_HANDLE_VALUE; return o; } public void setPointer(Pointer p) { if (immutable) { throw new UnsupportedOperationException("immutable reference"); } super.setPointer(p); } } /** * LPHANDLE */ public static class HANDLEByReference extends ByReference { public HANDLEByReference() { this(null); } public HANDLEByReference(HANDLE h) { super(Pointer.SIZE); setValue(h); } public void setValue(HANDLE h) { getPointer().setPointer(0, h != null ? h.getPointer() : null); } public HANDLE getValue() { Pointer p = getPointer().getPointer(0); if (p == null) return null; if (WinBase.INVALID_HANDLE_VALUE.getPointer().equals(p)) return WinBase.INVALID_HANDLE_VALUE; HANDLE h = new HANDLE(); h.setPointer(p); return h; } } /** * Return code used by interfaces. It is zero upon success and * nonzero to represent an error code or status information. */ class HRESULT extends NativeLong { public HRESULT() { } public HRESULT(int value) { super(value); } } /** * The WELL_KNOWN_SID_TYPE enumeration type is a list of commonly used security identifiers * (SIDs). Programs can pass these values to the CreateWellKnownSid function to create a SID * from this list. */ public abstract class WELL_KNOWN_SID_TYPE { /** * Indicates a null SID. */ public static final int WinNullSid = 0; /** * Indicates a SID that matches everyone. */ public static final int WinWorldSid = 1; /** * Indicates a local SID. */ public static final int WinLocalSid = 2; /** * Indicates a SID that matches the owner or creator of an object. */ public static final int WinCreatorOwnerSid = 3; /** * Indicates a SID that matches the creator group of an object. */ public static final int WinCreatorGroupSid = 4; /** * Indicates a creator owner server SID. */ public static final int WinCreatorOwnerServerSid = 5; /** * Indicates a creator group server SID. */ public static final int WinCreatorGroupServerSid = 6; /** * Indicates a SID for the Windows NT authority. */ public static final int WinNtAuthoritySid = 7; /** * Indicates a SID for a dial-up account. */ public static final int WinDialupSid = 8; /** * Indicates a SID for a network account. This SID is added to the process of a token * when it logs on across a network. The corresponding logon type is * LOGON32_LOGON_NETWORK. */ public static final int WinNetworkSid = 9; /** * Indicates a SID for a batch process. This SID is added to the process of a token * when it logs on as a batch job. The corresponding logon type is LOGON32_LOGON_BATCH. */ public static final int WinBatchSid = 10; /** * Indicates a SID for an interactive account. This SID is added to the process of a * token when it logs on interactively. The corresponding logon type is * LOGON32_LOGON_INTERACTIVE. */ public static final int WinInteractiveSid = 11; /** * Indicates a SID for a service. This SID is added to the process of a token when it * logs on as a service. The corresponding logon type is LOGON32_LOGON_bSERVICE. */ public static final int WinServiceSid = 12; /** * Indicates a SID for the anonymous account. */ public static final int WinAnonymousSid = 13; /** * Indicates a proxy SID. */ public static final int WinProxySid = 14; /** * Indicates a SID for an enterprise controller. */ public static final int WinEnterpriseControllersSid = 15; /** * Indicates a SID for self. */ public static final int WinSelfSid = 16; /** * Indicates a SID that matches any authenticated user. */ public static final int WinAuthenticatedUserSid = 17; /** * Indicates a SID for restricted code. */ public static final int WinRestrictedCodeSid = 18; /** * Indicates a SID that matches a terminal server account. */ public static final int WinTerminalServerSid = 19; /** * Indicates a SID that matches remote logons. */ public static final int WinRemoteLogonIdSid = 20; /** * Indicates a SID that matches logon IDs. */ public static final int WinLogonIdsSid = 21; /** * Indicates a SID that matches the local system. */ public static final int WinLocalSystemSid = 22; /** * Indicates a SID that matches a local service. */ public static final int WinLocalServiceSid = 23; /** * Indicates a SID that matches a network service. */ public static final int WinNetworkServiceSid = 24; /** * Indicates a SID that matches the domain account. */ public static final int WinBuiltinDomainSid = 25; /** * Indicates a SID that matches the administrator account. */ public static final int WinBuiltinAdministratorsSid = 26; /** * Indicates a SID that matches built-in user accounts. */ public static final int WinBuiltinUsersSid = 27; /** * Indicates a SID that matches the guest account. */ public static final int WinBuiltinGuestsSid = 28; /** * Indicates a SID that matches the power users group. */ public static final int WinBuiltinPowerUsersSid = 29; /** * Indicates a SID that matches the account operators account. */ public static final int WinBuiltinAccountOperatorsSid = 30; /** * Indicates a SID that matches the system operators group. */ public static final int WinBuiltinSystemOperatorsSid = 31; /** * Indicates a SID that matches the print operators group. */ public static final int WinBuiltinPrintOperatorsSid = 32; /** * Indicates a SID that matches the backup operators group. */ public static final int WinBuiltinBackupOperatorsSid = 33; /** * Indicates a SID that matches the replicator account. */ public static final int WinBuiltinReplicatorSid = 34; /** * Indicates a SID that matches pre-Windows 2000 compatible accounts. */ public static final int WinBuiltinPreWindows2000CompatibleAccessSid = 35; /** * Indicates a SID that matches remote desktop users. */ public static final int WinBuiltinRemoteDesktopUsersSid = 36; /** * Indicates a SID that matches the network operators group. */ public static final int WinBuiltinNetworkConfigurationOperatorsSid = 37; /** * Indicates a SID that matches the account administrators group. */ public static final int WinAccountAdministratorSid = 38; /** * Indicates a SID that matches the account guest group. */ public static final int WinAccountGuestSid = 39; /** * Indicates a SID that matches account Kerberos target group. */ public static final int WinAccountKrbtgtSid = 40; /** * Indicates a SID that matches the account domain administrator group. */ public static final int WinAccountDomainAdminsSid = 41; /** * Indicates a SID that matches the account domain users group. */ public static final int WinAccountDomainUsersSid = 42; /** * Indicates a SID that matches the account domain guests group. */ public static final int WinAccountDomainGuestsSid = 43; /** * Indicates a SID that matches the account computer group. */ public static final int WinAccountComputersSid = 44; /** * Indicates a SID that matches the account controller group. */ public static final int WinAccountControllersSid = 45; /** * Indicates a SID that matches the certificate administrators group. */ public static final int WinAccountCertAdminsSid = 46; /** * Indicates a SID that matches the schema administrators group. */ public static final int WinAccountSchemaAdminsSid = 47; /** * Indicates a SID that matches the enterprise administrators group. */ public static final int WinAccountEnterpriseAdminsSid = 48; /** * Indicates a SID that matches the policy administrators group. */ public static final int WinAccountPolicyAdminsSid = 49; /** * Indicates a SID that matches the RAS and IAS server account. */ public static final int WinAccountRasAndIasServersSid = 50; /** * Indicates a SID present when the Microsoft NTLM authentication package * authenticated the client. */ public static final int WinNTLMAuthenticationSid = 51; /** * Indicates a SID present when the Microsoft Digest authentication package * authenticated the client. */ public static final int WinDigestAuthenticationSid = 52; /** * Indicates a SID present when the Secure Channel (SSL/TLS) authentication * package authenticated the client. */ public static final int WinSChannelAuthenticationSid = 53; /** * Indicates a SID present when the user authenticated from within the forest * or across a trust that does not have the selective authentication option * enabled. If this SID is present, then WinOtherOrganizationSid cannot be present. */ public static final int WinThisOrganizationSid = 54; /** * Indicates a SID present when the user authenticated across a forest with the * selective authentication option enabled. If this SID is present, then * WinThisOrganizationSid cannot be present. */ public static final int WinOtherOrganizationSid = 55; /** * Indicates a SID that allows a user to create incoming forest trusts. It is added * to the token of users who are a member of the Incoming Forest Trust Builders * built-in group in the root domain of the forest. */ public static final int WinBuiltinIncomingForestTrustBuildersSid = 56; /** * Indicates a SID that matches the performance monitor user group. */ public static final int WinBuiltinPerfMonitoringUsersSid = 57; /** * Indicates a SID that matches the performance log user group. */ public static final int WinBuiltinPerfLoggingUsersSid = 58; /** * Indicates a SID that matches the Windows Authorization Access group. */ public static final int WinBuiltinAuthorizationAccessSid = 59; /** * Indicates a SID is present in a server that can issue Terminal Server licenses. */ public static final int WinBuiltinTerminalServerLicenseServersSid = 60; /** * */ public static final int WinBuiltinDCOMUsersSid = 61; /** * */ public static final int WinBuiltinIUsersSid = 62; /** * */ public static final int WinIUserSid = 63; /** * */ public static final int WinBuiltinCryptoOperatorsSid = 64; /** * */ public static final int WinUntrustedLabelSid = 65; /** * */ public static final int WinLowLabelSid = 66; /** * */ public static final int WinMediumLabelSid = 67; /** * */ public static final int WinHighLabelSid = 68; /** * */ public static final int WinSystemLabelSid = 69; /** * */ public static final int WinWriteRestrictedCodeSid = 70; /** * */ public static final int WinCreatorOwnerRightsSid = 71; /** * */ public static final int WinCacheablePrincipalsGroupSid = 72; /** * */ public static final int WinNonCacheablePrincipalsGroupSid = 73; /** * */ public static final int WinEnterpriseReadonlyControllersSid = 74; /** * Indicates a SID that matches a read-only enterprise domain controller. */ public static final int WinAccountReadonlyControllersSid = 75; /** * Indicates a SID that matches the built-in DCOM certification services access group. */ public static final int WinBuiltinEventLogReadersGroup = 76; } /** * Current SID revision level. */ public static final int SID_REVISION = 1; public static final int SID_MAX_SUB_AUTHORITIES = 15; public static final int SID_RECOMMENDED_SUB_AUTHORITIES = 1; /** * Maximum bytes used by a SID. * (sizeof(SID) - sizeof(DWORD) + (SID_MAX_SUB_AUTHORITIES * sizeof(DWORD))) */ public static final int SECURITY_MAX_SID_SIZE = 68; /** * The OSVERSIONINFO data structure contains operating system version information. * The information includes major and minor version numbers, a build number, a * platform identifier, and descriptive text about the operating system. This structure * is used with the GetVersionEx function. */ public static class OSVERSIONINFO extends Structure { /** * Size of this data structure, in bytes. Set this member to sizeof(OSVERSIONINFO) * before calling the GetVersionEx function. */ public DWORD dwOSVersionInfoSize; /** * Major version number of the operating system. */ public DWORD dwMajorVersion; /** * Minor version number of the operating system. */ public DWORD dwMinorVersion; /** * Build number of the operating system. */ public DWORD dwBuildNumber; /** * Operating system platform. */ public DWORD dwPlatformId; /** * Pointer to a null-terminated string, such as "Service Pack 3", * that indicates the latest Service Pack installed on the system. */ public char szCSDVersion[]; public OSVERSIONINFO() { szCSDVersion = new char[128]; dwOSVersionInfoSize = new DWORD(size()); // sizeof(OSVERSIONINFO) } public OSVERSIONINFO(Pointer memory) { useMemory(memory); read(); } }; /** * Contains operating system version information. The information includes major and minor version numbers, * a build number, a platform identifier, and information about product suites and the latest Service Pack * installed on the system. */ public static class OSVERSIONINFOEX extends Structure { /** * The size of this data structure, in bytes. */ public DWORD dwOSVersionInfoSize; /** * The major version number of the operating system. */ public DWORD dwMajorVersion; /** * The minor version number of the operating system. */ public DWORD dwMinorVersion; /** * The build number of the operating system. */ public DWORD dwBuildNumber; /** * The operating system platform. This member can be VER_PLATFORM_WIN32_NT. */ public DWORD dwPlatformId; /** * A null-terminated string, such as "Service Pack 3", that indicates the latest Service Pack * installed on the system. If no Service Pack has been installed, the string is empty. */ public char szCSDVersion[]; /** * The major version number of the latest Service Pack installed on the system. For example, for * Service Pack 3, the major version number is 3. If no Service Pack has been installed, the value * is zero. */ public WORD wServicePackMajor; /** * The minor version number of the latest Service Pack installed on the system. For example, for * Service Pack 3, the minor version number is 0. */ public WORD wServicePackMinor; /** * A bit mask that identifies the product suites available on the system. */ public WORD wSuiteMask; /** * Any additional information about the system. */ public byte wProductType; /** * Reserved for future use. */ public byte wReserved; public OSVERSIONINFOEX() { szCSDVersion = new char[128]; dwOSVersionInfoSize = new DWORD(size()); // sizeof(OSVERSIONINFOEX) } public OSVERSIONINFOEX(Pointer memory) { useMemory(memory); read(); } }; public static final int VER_EQUAL = 1; public static final int VER_GREATER = 2; public static final int VER_GREATER_EQUAL = 3; public static final int VER_LESS = 4; public static final int VER_LESS_EQUAL = 5; public static final int VER_AND = 6; public static final int VER_OR = 7; public static final int VER_CONDITION_MASK = 7; public static final int VER_NUM_BITS_PER_CONDITION_MASK = 3; public static final int VER_MINORVERSION = 0x0000001; public static final int VER_MAJORVERSION = 0x0000002; public static final int VER_BUILDNUMBER = 0x0000004; public static final int VER_PLATFORMID = 0x0000008; public static final int VER_SERVICEPACKMINOR = 0x0000010; public static final int VER_SERVICEPACKMAJOR = 0x0000020; public static final int VER_SUITENAME = 0x0000040; public static final int VER_PRODUCT_TYPE = 0x0000080; public static final int VER_NT_WORKSTATION = 0x0000001; public static final int VER_NT_DOMAIN_CONTROLLER = 0x0000002; public static final int VER_NT_SERVER = 0x0000003; public static final int VER_PLATFORM_WIN32s = 0; public static final int VER_PLATFORM_WIN32_WINDOWS = 1; public static final int VER_PLATFORM_WIN32_NT = 2; }libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java0000644000175000017500000001254111421126016025240 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.WString; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.win32.StdCallLibrary; /** * Ported from ShellAPI.h. * Microsoft Windows SDK 6.0A. * @author dblock[at]dblock.org */ public interface ShellAPI extends StdCallLibrary { int STRUCTURE_ALIGNMENT = Structure.ALIGN_NONE; public static final int FO_MOVE = 0x0001; public static final int FO_COPY = 0x0002; public static final int FO_DELETE = 0x0003; public static final int FO_RENAME = 0x0004; public static final int FOF_MULTIDESTFILES = 0x0001; public static final int FOF_CONFIRMMOUSE = 0x0002; public static final int FOF_SILENT = 0x0004; // don't display progress UI (confirm prompts may be displayed still) public static final int FOF_RENAMEONCOLLISION = 0x0008; // automatically rename the source files to avoid the collisions public static final int FOF_NOCONFIRMATION = 0x0010; // don't display confirmation UI, assume "yes" for cases that can be bypassed, "no" for those that can not public static final int FOF_WANTMAPPINGHANDLE = 0x0020; // Fill in SHFILEOPSTRUCT.hNameMappings public static final int FOF_ALLOWUNDO = 0x0040; // enable undo including Recycle behavior for IFileOperation::Delete() public static final int FOF_FILESONLY = 0x0080; // only operate on the files (non folders), both files and folders are assumed without this public static final int FOF_SIMPLEPROGRESS = 0x0100; // means don't show names of files public static final int FOF_NOCONFIRMMKDIR = 0x0200; // don't dispplay confirmatino UI before making any needed directories, assume "Yes" in these cases public static final int FOF_NOERRORUI = 0x0400; // don't put up error UI, other UI may be displayed, progress, confirmations public static final int FOF_NOCOPYSECURITYATTRIBS = 0x0800; // dont copy file security attributes (ACLs) public static final int FOF_NORECURSION = 0x1000; // don't recurse into directories for operations that would recurse public static final int FOF_NO_CONNECTED_ELEMENTS = 0x2000; // don't operate on connected elements ("xxx_files" folders that go with .htm files) public static final int FOF_WANTNUKEWARNING = 0x4000; // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION) public static final int FOF_NORECURSEREPARSE = 0x8000; // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts) public static final int FOF_NO_UI = (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR); // don't display any UI at all public static final int PO_DELETE = 0x0013; // printer is being deleted public static final int PO_RENAME = 0x0014; // printer is being renamed public static final int PO_PORTCHANGE = 0x0020; // port this printer connected to is being changed public static final int PO_REN_PORT = 0x0034; // PO_RENAME and PO_PORTCHANGE at same time. /** * Contains information that the SHFileOperation function uses to perform file operations. */ public static class SHFILEOPSTRUCT extends Structure { /** * A window handle to the dialog box to display information about * the status of the file operation. */ public HANDLE hwnd; /** * An FO_* value that indicates which operation to perform. */ public int wFunc; /** * A pointer to one or more source file names, double null-terminated. */ public WString pFrom; /** * A pointer to the destination file or directory name. */ public WString pTo; /** * Flags that control the file operation. */ public short fFlags; /** * When the function returns, this member contains TRUE if any file operations * were aborted before they were completed; otherwise, FALSE. An operation can * be manually aborted by the user through UI or it can be silently aborted by * the system if the FOF_NOERRORUI or FOF_NOCONFIRMATION flags were set. */ public boolean fAnyOperationsAborted; /** * When the function returns, this member contains a handle to a name mapping * object that contains the old and new names of the renamed files. This member * is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag. */ public Pointer pNameMappings; /** * A pointer to the title of a progress dialog box. This is a null-terminated string. */ public WString lpszProgressTitle; /** Use this to encode pFrom/pTo paths. */ public String encodePaths(String[] paths) { String encoded = ""; for (int i=0; i < paths.length;i++) { encoded += paths[i]; encoded += "\0"; } return encoded + "\0"; } } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/BaseTSD.java0000644000175000017500000000404211421126016025061 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.IntegerType; import com.sun.jna.Pointer; import com.sun.jna.win32.StdCallLibrary; /** * @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); } } /** * 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); } } /** * 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); } } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/Oleaut32.java0000644000175000017500000000342011421126016025231 0ustar janjan/* * Copyright (c) 2010 Digital Rapids Corp., All rights reserved. */ /* Copyright (c) 2010 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. * * 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.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; /** * Oleaut32.dll Interface. * @author scott.palmer */ public interface Oleaut32 extends StdCallLibrary { Oleaut32 INSTANCE = (Oleaut32) Native.loadLibrary( "Oleaut32", Oleaut32.class, W32APIOptions.UNICODE_OPTIONS); /** * This function allocates a new string and copies the passed string into it. * @param sz * Null-terminated UNICODE string to copy. * @return * Null if there is insufficient memory or if a null pointer is passed in. */ Pointer SysAllocString(String sz); /** * This function frees a string allocated previously by SysAllocString, * SysAllocStringByteLen, SysReAllocString, SysAllocStringLen, or * SysReAllocStringLen. * @param bstr * Unicode string that was allocated previously, or NULL. Setting this parameter * to NULL causes the function to simply return. */ void SysFreeString(Pointer bstr); } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/win32/LMCons.java0000644000175000017500000000216011421126016024766 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.win32.StdCallLibrary; /** * Ported from LMCons.h. * @author dblock[at]dblock.org * Windows SDK 6.0A */ public interface LMCons extends StdCallLibrary { public static final int NETBIOS_NAME_LEN = 16; // NetBIOS net name (bytes) /** * Value to be used with APIs which have a "preferred maximum length" parameter. * This value indicates that the API should just allocate "as much as it takes." */ public static final int MAX_PREFERRED_LENGTH = -1; } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/unix/0000755000175000017500000000000011421126014023010 5ustar janjanlibjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/unix/X11.java0000644000175000017500000024562311421126014024240 0ustar janjan/* 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. *

* 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.unix; import com.sun.jna.FromNativeContext; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; import com.sun.jna.PointerType; import com.sun.jna.Structure; import com.sun.jna.Union; import com.sun.jna.ptr.ByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.NativeLongByReference; import com.sun.jna.ptr.PointerByReference; /** Definition (incomplete) of the X library. */ public interface X11 extends Library { class VisualID extends NativeLong { private static final long serialVersionUID = 1L; public VisualID() { } public VisualID(long value) { super(value); } } class XID extends NativeLong { private static final long serialVersionUID = 1L; public static final XID None = null; public XID() { this(0); } public XID(long id) { super(id); } protected boolean isNone(Object o) { return o == null || (o instanceof Number && ((Number)o).longValue() == X11.None); } public Object fromNative(Object nativeValue, FromNativeContext context) { if (isNone(nativeValue)) return None; return new XID(((Number)nativeValue).longValue()); } public String toString() { return "0x" + Long.toHexString(longValue()); } } class Atom extends XID { private static final long serialVersionUID = 1L; public static final Atom None = null; public Atom() { } public Atom(long id) { super(id); } /** Return constants for predefined Atom values. */ public Object fromNative(Object nativeValue, FromNativeContext context) { long value = ((Number)nativeValue).longValue(); if (value <= Integer.MAX_VALUE) { switch((int)value) { case 0: return None; case 1: return XA_PRIMARY; case 2: return XA_SECONDARY; case 3: return XA_ARC; case 4: return XA_ATOM; case 5: return XA_BITMAP; case 6: return XA_CARDINAL; case 7: return XA_COLORMAP; case 8: return XA_CURSOR; case 9: return XA_CUT_BUFFER0; case 10: return XA_CUT_BUFFER1; case 11: return XA_CUT_BUFFER2; case 12: return XA_CUT_BUFFER3; case 13: return XA_CUT_BUFFER4; case 14: return XA_CUT_BUFFER5; case 15: return XA_CUT_BUFFER6; case 16: return XA_CUT_BUFFER7; case 17: return XA_DRAWABLE; case 18: return XA_FONT; case 19: return XA_INTEGER; case 20: return XA_PIXMAP; case 21: return XA_POINT; case 22: return XA_RECTANGLE; case 23: return XA_RESOURCE_MANAGER; case 24: return XA_RGB_COLOR_MAP; case 25: return XA_RGB_BEST_MAP; case 26: return XA_RGB_BLUE_MAP; case 27: return XA_RGB_DEFAULT_MAP; case 28: return XA_RGB_GRAY_MAP; case 29: return XA_RGB_GREEN_MAP; case 30: return XA_RGB_RED_MAP; case 31: return XA_STRING; case 32: return XA_VISUALID; case 33: return XA_WINDOW; case 34: return XA_WM_COMMAND; case 35: return XA_WM_HINTS; case 36: return XA_WM_CLIENT_MACHINE; case 37: return XA_WM_ICON_NAME; case 38: return XA_WM_ICON_SIZE; case 39: return XA_WM_NAME; case 40: return XA_WM_NORMAL_HINTS; case 41: return XA_WM_SIZE_HINTS; case 42: return XA_WM_ZOOM_HINTS; case 43: return XA_MIN_SPACE; case 44: return XA_NORM_SPACE; case 45: return XA_MAX_SPACE; case 46: return XA_END_SPACE; case 47: return XA_SUPERSCRIPT_X; case 48: return XA_SUPERSCRIPT_Y; case 49: return XA_SUBSCRIPT_X; case 50: return XA_SUBSCRIPT_Y; case 51: return XA_UNDERLINE_POSITION; case 52: return XA_UNDERLINE_THICKNESS; case 53: return XA_STRIKEOUT_ASCENT; case 54: return XA_STRIKEOUT_DESCENT; case 55: return XA_ITALIC_ANGLE; case 56: return XA_X_HEIGHT; case 57: return XA_QUAD_WIDTH; case 58: return XA_WEIGHT; case 59: return XA_POINT_SIZE; case 60: return XA_RESOLUTION; case 61: return XA_COPYRIGHT; case 62: return XA_NOTICE; case 63: return XA_FONT_NAME; case 64: return XA_FAMILY_NAME; case 65: return XA_FULL_NAME; case 66: return XA_CAP_HEIGHT; case 67: return XA_WM_CLASS; case 68: return XA_WM_TRANSIENT_FOR; default: } } return new Atom(value); } } class AtomByReference extends ByReference { public AtomByReference() { super(XID.SIZE); } public Atom getValue() { NativeLong value = getPointer().getNativeLong(0); return (Atom)new Atom().fromNative(value, null); } } class Colormap extends XID { private static final long serialVersionUID = 1L; public static final Colormap None = null; public Colormap() { } public Colormap(long id) { super(id); } public Object fromNative(Object nativeValue, FromNativeContext context) { if (isNone(nativeValue)) return None; return new Colormap(((Number)nativeValue).longValue()); } } class Font extends XID { private static final long serialVersionUID = 1L; public static final Font None = null; public Font() { } public Font(long id) { super(id); } public Object fromNative(Object nativeValue, FromNativeContext context) { if (isNone(nativeValue)) return None; return new Font(((Number)nativeValue).longValue()); } } class Cursor extends XID { private static final long serialVersionUID = 1L; public static final Cursor None = null; public Cursor() { } public Cursor(long id) { super(id); } public Object fromNative(Object nativeValue, FromNativeContext context) { if (isNone(nativeValue)) return None; return new Cursor(((Number)nativeValue).longValue()); } } class KeySym extends XID { private static final long serialVersionUID = 1L; public static final KeySym None = null; public KeySym() { } public KeySym(long id) { super(id); } public Object fromNative(Object nativeValue, FromNativeContext context) { if (isNone(nativeValue)) return None; return new KeySym(((Number)nativeValue).longValue()); } } class Drawable extends XID { private static final long serialVersionUID = 1L; public static final Drawable None = null; public Drawable() { } public Drawable(long id) { super(id); } public Object fromNative(Object nativeValue, FromNativeContext context) { if (isNone(nativeValue)) return None; return new Drawable(((Number)nativeValue).longValue()); } } class Window extends Drawable { private static final long serialVersionUID = 1L; public static final Window None = null; public Window() { } public Window(long id) { super(id); } public Object fromNative(Object nativeValue, FromNativeContext context) { if (isNone(nativeValue)) return None; return new Window(((Number)nativeValue).longValue()); } } class WindowByReference extends ByReference { public WindowByReference() { super(XID.SIZE); } public Window getValue() { NativeLong value = getPointer().getNativeLong(0); return value.longValue() == X11.None ? Window.None : new Window(value.longValue()); } } class Pixmap extends Drawable { private static final long serialVersionUID = 1L; public static final Pixmap None = null; public Pixmap() { } public Pixmap(long id) { super(id); } public Object fromNative(Object nativeValue, FromNativeContext context) { if (isNone(nativeValue)) return None; return new Pixmap(((Number)nativeValue).longValue()); } } // TODO: define structure class Display extends PointerType { } // TODO: define structure class Visual extends PointerType { public NativeLong getVisualID() { if (getPointer() != null) return getPointer().getNativeLong(Native.POINTER_SIZE); return new NativeLong(0); } public String toString() { return "Visual: VisualID=0x" + Long.toHexString(getVisualID().longValue()); } } // TODO: define structure class Screen extends PointerType { } // TODO: define structure class GC extends PointerType { } // TODO: define structure class XImage extends PointerType { } /** Definition (incomplete) of the Xext library. */ interface Xext extends Library { Xext INSTANCE = (Xext)Native.loadLibrary("Xext", Xext.class); // Shape Kinds int ShapeBounding = 0; int ShapeClip = 1; int ShapeInput = 2; // Operations int ShapeSet = 0; int ShapeUnion = 1; int ShapeIntersect = 2; int ShapeSubtract = 3; int ShapeInvert = 4; void XShapeCombineMask(Display display, Window window, int dest_kind, int x_off, int y_off, Pixmap src, int op); } /** Definition (incomplete) of the Xrender library. */ interface Xrender extends Library { Xrender INSTANCE = (Xrender)Native.loadLibrary("Xrender", Xrender.class); class XRenderDirectFormat extends Structure { public short red, redMask; public short green, greenMask; public short blue, blueMask; public short alpha, alphaMask; } class PictFormat extends NativeLong { private static final long serialVersionUID = 1L; public PictFormat(long value) { super(value); } public PictFormat() { } } class XRenderPictFormat extends Structure { public PictFormat id; public int type; public int depth; public XRenderDirectFormat direct; public Colormap colormap; } int PictTypeIndexed = 0x0; int PictTypeDirect = 0x1; XRenderPictFormat XRenderFindVisualFormat(Display display, Visual visual); } /** Definition of the Xevie library. */ interface Xevie extends Library { /** Instance of Xevie. Note: This extension has been removed from xorg/xserver on Oct 22, 2008 because it is broken and maintainerless. */ Xevie INSTANCE = (Xevie)Native.loadLibrary("Xevie", Xevie.class); int XEVIE_UNMODIFIED = 0; int XEVIE_MODIFIED = 1; // Bool XevieQueryVersion (Display* display, int* major_version, int* minor_version); boolean XevieQueryVersion (Display display, IntByReference major_version, IntByReference minor_version); // Status XevieStart (Display* display); int XevieStart (Display display); // Status XevieEnd (Display* display); int XevieEnd (Display display); // Status XevieSendEvent (Display* display, XEvent* event, int data_type); int XevieSendEvent (Display display, XEvent event, int data_type); // Status XevieSelectInput (Display* display, NativeLong event_mask); int XevieSelectInput (Display display, NativeLong event_mask); } /** Definition of the XTest library. */ interface XTest extends Library { XTest INSTANCE = (XTest)Native.loadLibrary("Xtst", XTest.class);///usr/lib/libxcb-xtest.so.0 boolean XTestQueryExtension(Display display, IntByReference event_basep, IntByReference error_basep, IntByReference majorp, IntByReference minorp); boolean XTestCompareCursorWithWindow(Display display, Window window, Cursor cursor); boolean XTestCompareCurrentCursorWithWindow(Display display, Window window); // extern int XTestFakeKeyEvent(Display* display, unsigned int keycode, Bool is_press, unsigned long delay); int XTestFakeKeyEvent(Display display, int keycode, boolean is_press, NativeLong delay); int XTestFakeButtonEvent(Display display, int button, boolean is_press, NativeLong delay); int XTestFakeMotionEvent(Display display, int screen, int x, int y, NativeLong delay); int XTestFakeRelativeMotionEvent(Display display, int x, int y, NativeLong delay); int XTestFakeDeviceKeyEvent(Display display, XDeviceByReference dev, int keycode, boolean is_press, IntByReference axes, int n_axes, NativeLong delay); int XTestFakeDeviceButtonEvent(Display display, XDeviceByReference dev, int button, boolean is_press, IntByReference axes, int n_axes, NativeLong delay); int XTestFakeProximityEvent(Display display, XDeviceByReference dev, boolean in_prox, IntByReference axes, int n_axes, NativeLong delay); int XTestFakeDeviceMotionEvent(Display display, XDeviceByReference dev, boolean is_relative, int first_axis, IntByReference axes, int n_axes, NativeLong delay); int XTestGrabControl(Display display, boolean impervious); //void XTestSetGContextOfGC(GC gc, GContext gid); void XTestSetVisualIDOfVisual(Visual visual, VisualID visualid); int XTestDiscard(Display display); } class XInputClassInfoByReference extends Structure implements Structure.ByReference { public byte input_class; public byte event_type_base; } class XDeviceByReference extends Structure implements Structure.ByReference { public XID device_id; public int num_classes; public XInputClassInfoByReference classes; } X11 INSTANCE = (X11)Native.loadLibrary("X11", X11.class); /* typedef struct { long flags; // marks which fields in this structure are defined Bool input; // does this application rely on the window manager to // get keyboard input? int initial_state; // see below Pixmap icon_pixmap; // pixmap to be used as icon Window icon_window; // window to be used as icon int icon_x, icon_y; // initial position of icon Pixmap icon_mask; // icon mask bitmap XID window_group; // id of related window group // this structure may be extended in the future } XWMHints; */ class XWMHints extends Structure { public NativeLong flags; public boolean input; public int initial_state; public Pixmap icon_pixmap; public Window icon_window; public int icon_x, icon_y; public Pixmap icon_mask; public XID window_group; } /* typedef struct { unsigned char *value; // same as Property routines Atom encoding; // prop type int format; // prop data format: 8, 16, or 32 unsigned long nitems; // number of data items in value } XTextProperty; */ class XTextProperty extends Structure { public String value; public Atom encoding; public int format; public NativeLong nitems; } /* typedef struct { long flags; // marks which fields in this structure are defined int x, y; // obsolete for new window mgrs, but clients int width, height; /// should set so old wm's don't mess up int min_width, min_height; int max_width, max_height; int width_inc, height_inc; struct { int x; // numerator int y; // denominator } min_aspect, max_aspect; int base_width, base_height; // added by ICCCM version 1 int win_gravity; // added by ICCCM version 1 } XSizeHints; */ class XSizeHints extends Structure { public NativeLong flags; public int x, y; public int width, height; public int min_width, min_height; public int max_width, max_height; public int width_inc, height_inc; public static class Aspect extends Structure { public int x; // numerator public int y; // denominator } public Aspect min_aspect, max_aspect; public int base_width, base_height; public int win_gravity; } /* typedef struct { int x, y; // location of window int width, height; // width and height of window int border_width; // border width of window int depth; // depth of window Visual *visual; // the associated visual structure Window root; // root of screen containing window #if defined(__cplusplus) || defined(c_plusplus) int c_class; // C++ InputOutput, InputOnly #else int class; // InputOutput, InputOnly #endif int bit_gravity; // one of bit gravity values int win_gravity; // one of the window gravity values int backing_store; // NotUseful, WhenMapped, Always unsigned long backing_planes;// planes to be preserved if possible unsigned long backing_pixel;// value to be used when restoring planes Bool save_under; // boolean, should bits under be saved? Colormap colormap; // color map to be associated with window Bool map_installed; // boolean, is color map currently installed int map_state; // IsUnmapped, IsUnviewable, IsViewable long all_event_masks; // set of events all people have interest in long your_event_mask; // my event mask long do_not_propagate_mask; // set of events that should not propagate Bool override_redirect; // boolean value for override-redirect Screen *screen; // back pointer to correct screen } XWindowAttributes; */ class XWindowAttributes extends Structure { public int x, y; public int width, height; public int border_width; public int depth; public Visual visual; public Window root; public int c_class; public int bit_gravity; public int win_gravity; public int backing_store; public NativeLong backing_planes; public NativeLong backing_pixel; public boolean save_under; public Colormap colormap; public boolean map_installed; public int map_state; public NativeLong all_event_masks; public NativeLong your_event_mask; public NativeLong do_not_propagate_mask; public boolean override_redirect; public Screen screen; } /* typedef struct { Pixmap background_pixmap; // background or None or ParentRelative unsigned long background_pixel; // background pixel Pixmap border_pixmap; // border of the window unsigned long border_pixel; // border pixel value int bit_gravity; // one of bit gravity values int win_gravity; // one of the window gravity values int backing_store; // NotUseful, WhenMapped, Always unsigned long backing_planes;// planes to be preseved if possible unsigned long backing_pixel;// value to use in restoring planes Bool save_under; // should bits under be saved? (popups) long event_mask; // set of events that should be saved long do_not_propagate_mask; // set of events that should not propagate Bool override_redirect; // boolean value for override-redirect Colormap colormap; // color map to be associated with window Cursor cursor; // cursor to be displayed (or None) } XSetWindowAttributes; */ class XSetWindowAttributes extends Structure { public Pixmap background_pixmap; public NativeLong background_pixel; public Pixmap border_pixmap; public NativeLong border_pixel; public int bit_gravity; public int win_gravity; public int backing_store; public NativeLong backing_planes; public NativeLong backing_pixel; public boolean save_under; public NativeLong event_mask; public NativeLong do_not_propagate_mask; public boolean override_redirect; public Colormap colormap; public Cursor cursor; } int XK_0 = 0x30; int XK_9 = 0x39; int XK_A = 0x41; int XK_Z = 0x5a; int XK_a = 0x61; int XK_z = 0x7a; int XK_Shift_L = 0xffe1; int XK_Shift_R = 0xffe1; int XK_Control_L = 0xffe3; int XK_Control_R = 0xffe4; int XK_CapsLock = 0xffe5; int XK_ShiftLock = 0xffe6; int XK_Meta_L = 0xffe7; int XK_Meta_R = 0xffe8; int XK_Alt_L = 0xffe9; int XK_Alt_R = 0xffea; int VisualNoMask = 0x0; int VisualIDMask = 0x1; int VisualScreenMask = 0x2; int VisualDepthMask = 0x4; int VisualClassMask = 0x8; int VisualRedMaskMask = 0x10; int VisualGreenMaskMask = 0x20; int VisualBlueMaskMask = 0x40; int VisualColormapSizeMask = 0x80; int VisualBitsPerRGBMask = 0x100; int VisualAllMask = 0x1FF; class XVisualInfo extends Structure { public Visual visual; public VisualID visualid; public int screen; public int depth; public int c_class; public NativeLong red_mask; public NativeLong green_mask; public NativeLong blue_mask; public int colormap_size; public int bits_per_rgb; } class XPoint extends Structure { public short x, y; public XPoint() { } public XPoint(short x, short y) { this.x = x; this.y = y; } } class XRectangle extends Structure { public short x, y; public short width, height; public XRectangle() { } public XRectangle(short x, short y, short width, short height) { this.x = x; this.y = y; this.width = width; this.height = height; } } Atom XA_PRIMARY = new Atom(1); Atom XA_SECONDARY = new Atom(2); Atom XA_ARC = new Atom(3); Atom XA_ATOM = new Atom(4); Atom XA_BITMAP = new Atom(5); Atom XA_CARDINAL = new Atom(6); Atom XA_COLORMAP = new Atom(7); Atom XA_CURSOR = new Atom(8); Atom XA_CUT_BUFFER0 = new Atom(9); Atom XA_CUT_BUFFER1 = new Atom(10); Atom XA_CUT_BUFFER2 = new Atom(11); Atom XA_CUT_BUFFER3 = new Atom(12); Atom XA_CUT_BUFFER4 = new Atom(13); Atom XA_CUT_BUFFER5 = new Atom(14); Atom XA_CUT_BUFFER6 = new Atom(15); Atom XA_CUT_BUFFER7 = new Atom(16); Atom XA_DRAWABLE = new Atom(17); Atom XA_FONT = new Atom(18); Atom XA_INTEGER = new Atom(19); Atom XA_PIXMAP = new Atom(20); Atom XA_POINT = new Atom(21); Atom XA_RECTANGLE = new Atom(22); Atom XA_RESOURCE_MANAGER = new Atom(23); Atom XA_RGB_COLOR_MAP = new Atom(24); Atom XA_RGB_BEST_MAP = new Atom(25); Atom XA_RGB_BLUE_MAP = new Atom(26); Atom XA_RGB_DEFAULT_MAP = new Atom(27); Atom XA_RGB_GRAY_MAP = new Atom(28); Atom XA_RGB_GREEN_MAP = new Atom(29); Atom XA_RGB_RED_MAP = new Atom(30); Atom XA_STRING = new Atom(31); Atom XA_VISUALID = new Atom(32); Atom XA_WINDOW = new Atom(33); Atom XA_WM_COMMAND = new Atom(34); Atom XA_WM_HINTS = new Atom(35); Atom XA_WM_CLIENT_MACHINE = new Atom(36); Atom XA_WM_ICON_NAME = new Atom(37); Atom XA_WM_ICON_SIZE = new Atom(38); Atom XA_WM_NAME = new Atom(39); Atom XA_WM_NORMAL_HINTS = new Atom(40); Atom XA_WM_SIZE_HINTS = new Atom(41); Atom XA_WM_ZOOM_HINTS = new Atom(42); Atom XA_MIN_SPACE = new Atom(43); Atom XA_NORM_SPACE = new Atom(44); Atom XA_MAX_SPACE = new Atom(45); Atom XA_END_SPACE = new Atom(46); Atom XA_SUPERSCRIPT_X = new Atom(47); Atom XA_SUPERSCRIPT_Y = new Atom(48); Atom XA_SUBSCRIPT_X = new Atom(49); Atom XA_SUBSCRIPT_Y = new Atom(50); Atom XA_UNDERLINE_POSITION = new Atom(51); Atom XA_UNDERLINE_THICKNESS = new Atom(52); Atom XA_STRIKEOUT_ASCENT = new Atom(53); Atom XA_STRIKEOUT_DESCENT = new Atom(54); Atom XA_ITALIC_ANGLE = new Atom(55); Atom XA_X_HEIGHT = new Atom(56); Atom XA_QUAD_WIDTH = new Atom(57); Atom XA_WEIGHT = new Atom(58); Atom XA_POINT_SIZE = new Atom(59); Atom XA_RESOLUTION = new Atom(60); Atom XA_COPYRIGHT = new Atom(61); Atom XA_NOTICE = new Atom(62); Atom XA_FONT_NAME = new Atom(63); Atom XA_FAMILY_NAME = new Atom(64); Atom XA_FULL_NAME = new Atom(65); Atom XA_CAP_HEIGHT = new Atom(66); Atom XA_WM_CLASS = new Atom(67); Atom XA_WM_TRANSIENT_FOR = new Atom(68); Atom XA_LAST_PREDEFINED = XA_WM_TRANSIENT_FOR; Display XOpenDisplay(String name); int XGetErrorText(Display display, int code, byte[] buffer, int len); int XDefaultScreen(Display display); Screen DefaultScreenOfDisplay(Display display); Visual XDefaultVisual(Display display, int screen); Colormap XDefaultColormap(Display display, int screen); int XDisplayWidth(Display display, int screen); int XDisplayHeight(Display display, int screen); Window XDefaultRootWindow(Display display); Window XRootWindow(Display display, int screen); int XAllocNamedColor(Display display, int colormap, String color_name, Pointer screen_def_return, Pointer exact_def_return); XSizeHints XAllocSizeHints(); void XSetWMProperties(Display display, Window window, String window_name, String icon_name, String[] argv, int argc, XSizeHints normal_hints, Pointer wm_hints, Pointer class_hints); int XFree(Pointer data); Window XCreateSimpleWindow(Display display, Window parent, int x, int y, int width, int height, int border_width, int border, int background); Pixmap XCreateBitmapFromData(Display display, Window window, Pointer data, int width, int height); int XMapWindow(Display display, Window window); int XMapRaised(Display display, Window window); int XMapSubwindows(Display display, Window window); /** Flushes the output buffer. Most client applications need not use this function because the output buffer is automatically flushed as needed by calls to XPending, XNextEvent, and XWindowEvent. Events generated by the server may be enqueued into the library's event queue. */ int XFlush(Display display); /** Flushes the output buffer and then waits until all requests have been received and processed by the X server. Any errors generated must be handled by the error handler. For each protocol error received by Xlib, XSync calls the client application's error handling routine (see section 11.8.2). Any events generated by the server are enqueued into the library's event queue.
Finally, if you passed False, XSync does not discard the events in the queue. If you passed True, XSync discards all events in the queue, including those events that were on the queue before XSync was called. Client applications seldom need to call XSync. */ int XSync(Display display, boolean discard); /** If mode is QueuedAlready, XEventsQueued returns the number of events already in the event queue (and never performs a system call). If mode is QueuedAfterFlush, XEventsQueued returns the number of events already in the queue if the number is nonzero. If there are no events in the queue, XEventsQueued flushes the output buffer, attempts to read more events out of the application's connection, and returns the number read. If mode is QueuedAfterReading, XEventsQueued returns the number of events already in the queue if the number is nonzero. If there are no events in the queue, XEventsQueued attempts to read more events out of the application's connection without flushing the output buffer and returns the number read.
XEventsQueued always returns immediately without I/O if there are events already in the queue. XEventsQueued with mode QueuedAfterFlush is identical in behavior to XPending. XEventsQueued with mode QueuedAlready is identical to the XQLength function. */ int XEventsQueued(Display display, int mode); /** Returns the number of events that have been received from the X server but have not been removed from the event queue. XPending is identical to XEventsQueued with the mode QueuedAfterFlush specified. */ int XPending(Display display); int XUnmapWindow(Display display, Window window); int XDestroyWindow(Display display, Window window); int XCloseDisplay(Display display); int XClearWindow(Display display, Window window); int XClearArea(Display display, Window window, int x, int y, int w, int h, int exposures); Pixmap XCreatePixmap(Display display, Drawable drawable, int width, int height, int depth); int XFreePixmap(Display display, Pixmap pixmap); class XGCValues extends Structure { public int function; /* logical operation */ public NativeLong plane_mask;/* plane mask */ public NativeLong foreground;/* foreground pixel */ public NativeLong background;/* background pixel */ public int line_width; /* line width (in pixels) */ public int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash*/ public int cap_style; /* CapNotLast, CapButt, CapRound, CapProjecting */ public int join_style; /* JoinMiter, JoinRound, JoinBevel */ public int fill_style; /* FillSolid, FillTiled, FillStippled FillOpaqueStippled*/ public int fill_rule; /* EvenOddRule, WindingRule */ public int arc_mode; /* ArcChord, ArcPieSlice */ public Pixmap tile; /* tile pixmap for tiling operations */ public Pixmap stipple; /* stipple 1 plane pixmap for stippling */ public int ts_x_origin; /* offset for tile or stipple operations */ public int ts_y_origin; public Font font; /* default text font for text operations */ public int subwindow_mode; /* ClipByChildren, IncludeInferiors */ public boolean graphics_exposures; /* boolean, should exposures be generated */ public int clip_x_origin; /* origin for clipping */ public int clip_y_origin; public Pixmap clip_mask; /* bitmap clipping; other calls for rects */ public int dash_offset; /* patterned/dashed line information */ public byte dashes; } GC XCreateGC(Display display, Drawable drawable, NativeLong mask, XGCValues values); int XSetFillRule(Display display, GC gc, int fill_rule); int XFreeGC(Display display, GC gc); int XDrawPoint(Display display, Drawable drawable, GC gc, int x, int y); int XDrawPoints(Display display, Drawable drawable, GC gc, XPoint[] points, int npoints, int mode); int XFillRectangle(Display display, Drawable drawable, GC gc, int x, int y, int width, int height); int XFillRectangles(Display display, Drawable drawable, GC gc, XRectangle[] rectangles, int nrectangles); int XSetForeground(Display display, GC gc, NativeLong color); int XSetBackground(Display display, GC gc, NativeLong color); int XFillArc(Display display, Drawable drawable, GC gc, int x, int y, int width, int height, int angle1, int angle2); int XFillPolygon(Display dpy, Drawable drawable, GC gc, XPoint[] points, int npoints, int shape, int mode); int XQueryTree(Display display, Window window, WindowByReference root, WindowByReference parent, PointerByReference children, IntByReference childCount); boolean XQueryPointer(Display display, Window window, WindowByReference root_return, WindowByReference child_return, IntByReference root_x_return, IntByReference root_y_return, IntByReference win_x_return, IntByReference win_y_return, IntByReference mask_return); int XGetWindowAttributes(Display display, Window window, XWindowAttributes attributes); int XChangeWindowAttributes(Display display, Window window, NativeLong valuemask, XSetWindowAttributes attributes); // Status XGetGeometry(Display *display, Drawable d, Window *root_return, int *x_return, int *y_return, unsigned int *width_return, // unsigned int *height_return, unsigned int *border_width_return, unsigned int *depth_return); int XGetGeometry(Display display, Drawable d, WindowByReference w, IntByReference x, IntByReference y, IntByReference width, IntByReference heigth, IntByReference border_width, IntByReference depth); // Bool XTranslateCoordinates(Display *display, Window src_w, dest_w, int src_x, int src_y, // int *dest_x_return, int *dest_y_return, Window *child_return); boolean XTranslateCoordinates(Display display, Window src_w, Window dest_w, int src_x, int src_y, IntByReference dest_x_return, IntByReference dest_y_return, WindowByReference child_return); /***************************************************************** * RESERVED RESOURCE AND CONSTANT DEFINITIONS *****************************************************************/ int None = 0; /* universal null resource or null atom */ int ParentRelative = 1; /* background pixmap in CreateWindow and ChangeWindowAttributes */ int CopyFromParent = 0; /* border pixmap in CreateWindow and ChangeWindowAttributes special VisualID and special window class passed to CreateWindow */ int PointerWindow = 0; /* destination window in SendEvent */ int InputFocus = 1; /* destination window in SendEvent */ int PointerRoot = 1; /* focus window in SetInputFocus */ int AnyPropertyType = 0; /* special Atom, passed to GetProperty */ int AnyKey = 0; /* special Key Code, passed to GrabKey */ int AnyButton = 0; /* special Button Code, passed to GrabButton */ int AllTemporary = 0; /* special Resource ID passed to KillClient */ int CurrentTime = 0; /* special Time */ int NoSymbol = 0; /* special KeySym */ /***************************************************************** * EVENT DEFINITIONS *****************************************************************/ /* Input Event Masks. Used as event-mask window attribute and as arguments to Grab requests. Not to be confused with event names. */ int NoEventMask = 0; int KeyPressMask = (1<<0); int KeyReleaseMask = (1<<1); int ButtonPressMask = (1<<2); int ButtonReleaseMask = (1<<3); int EnterWindowMask = (1<<4); int LeaveWindowMask = (1<<5); int PointerMotionMask = (1<<6); int PointerMotionHintMask = (1<<7); int Button1MotionMask = (1<<8); int Button2MotionMask = (1<<9); int Button3MotionMask = (1<<10); int Button4MotionMask = (1<<11); int Button5MotionMask = (1<<12); int ButtonMotionMask = (1<<13); int KeymapStateMask = (1<<14); int ExposureMask = (1<<15); int VisibilityChangeMask = (1<<16); int StructureNotifyMask = (1<<17); int ResizeRedirectMask = (1<<18); int SubstructureNotifyMask = (1<<19); int SubstructureRedirectMask = (1<<20); int FocusChangeMask = (1<<21); int PropertyChangeMask = (1<<22); int ColormapChangeMask = (1<<23); int OwnerGrabButtonMask = (1<<24); /* Event names. Used in "type" field in XEvent structures. Not to be confused with event masks above. They start from 2 because 0 and 1 are reserved in the protocol for errors and replies. */ int KeyPress = 2; int KeyRelease = 3; int ButtonPress = 4; int ButtonRelease = 5; int MotionNotify = 6; int EnterNotify = 7; int LeaveNotify = 8; int FocusIn = 9; int FocusOut = 10; int KeymapNotify = 11; int Expose = 12; int GraphicsExpose = 13; int NoExpose = 14; int VisibilityNotify = 15; int CreateNotify = 16; int DestroyNotify = 17; int UnmapNotify = 18; int MapNotify = 19; int MapRequest = 20; int ReparentNotify = 21; int ConfigureNotify = 22; int ConfigureRequest = 23; int GravityNotify = 24; int ResizeRequest = 25; int CirculateNotify = 26; int CirculateRequest = 27; int PropertyNotify = 28; int SelectionClear = 29; int SelectionRequest = 30; int SelectionNotify = 31; int ColormapNotify = 32; int ClientMessage = 33; int MappingNotify = 34; int LASTEvent = 35; // must be bigger than any event # /* Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer, state in various key-, mouse-, and button-related events. */ int ShiftMask = (1 << 0); int LockMask = (1 << 1); int ControlMask = (1 << 2); int Mod1Mask = (1 << 3); int Mod2Mask = (1 << 4); int Mod3Mask = (1 << 5); int Mod4Mask = (1 << 6); int Mod5Mask = (1 << 7); /* modifier names. Used to build a SetModifierMapping request or to read a GetModifierMapping request. These correspond to the masks defined above. */ int ShiftMapIndex = 0; int LockMapIndex = 1; int ControlMapIndex = 2; int Mod1MapIndex = 3; int Mod2MapIndex = 4; int Mod3MapIndex = 5; int Mod4MapIndex = 6; int Mod5MapIndex = 7; /* button masks. Used in same manner as Key masks above. Not to be confused with button names below. */ int Button1Mask = (1 << 8); int Button2Mask = (1 << 9); int Button3Mask = (1 << 10); int Button4Mask = (1 << 11); int Button5Mask = (1 << 12); int AnyModifier = (1 << 15); /* used in GrabButton, GrabKey */ /* button names. Used as arguments to GrabButton and as detail in ButtonPress and ButtonRelease events. Not to be confused with button masks above. Note that 0 is already defined above as "AnyButton". */ int Button1 = 1; int Button2 = 2; int Button3 = 3; int Button4 = 4; int Button5 = 5; /* Notify modes */ int NotifyNormal = 0; int NotifyGrab = 1; int NotifyUngrab = 2; int NotifyWhileGrabbed = 3; int NotifyHint = 1; /* for MotionNotify events */ /* Notify detail */ int NotifyAncestor = 0; int NotifyVirtual = 1; int NotifyInferior = 2; int NotifyNonlinear = 3; int NotifyNonlinearVirtual = 4; int NotifyPointer = 5; int NotifyPointerRoot = 6; int NotifyDetailNone = 7; /* Visibility notify */ int VisibilityUnobscured = 0; int VisibilityPartiallyObscured = 1; int VisibilityFullyObscured = 2; /* Circulation request */ int PlaceOnTop = 0; int PlaceOnBottom = 1; /* protocol families */ int FamilyInternet = 0; /* IPv4 */ int FamilyDECnet = 1; int FamilyChaos = 2; int FamilyInternet6 = 6; /* IPv6 */ /* authentication families not tied to a specific protocol */ int FamilyServerInterpreted = 5; /* Property notification */ int PropertyNewValue = 0; int PropertyDelete = 1; /* Color Map notification */ int ColormapUninstalled = 0; int ColormapInstalled = 1; /* GrabPointer, GrabButton, GrabKeyboard, GrabKey Modes */ int GrabModeSync = 0; int GrabModeAsync = 1; /* GrabPointer, GrabKeyboard reply status */ int GrabSuccess = 0; int AlreadyGrabbed = 1; int GrabInvalidTime = 2; int GrabNotViewable = 3; int GrabFrozen = 4; /* AllowEvents modes */ int AsyncPointer = 0; int SyncPointer = 1; int ReplayPointer = 2; int AsyncKeyboard = 3; int SyncKeyboard = 4; int ReplayKeyboard = 5; int AsyncBoth = 6; int SyncBoth = 7; /* Used in SetInputFocus, GetInputFocus */ int RevertToNone = (int)None; int RevertToPointerRoot = (int)PointerRoot; int RevertToParent = 2; /***************************************************************** * ERROR CODES *****************************************************************/ int Success = 0; /* everything's okay */ int BadRequest = 1; /* bad request code */ int BadValue = 2; /* int parameter out of range */ int BadWindow = 3; /* parameter not a Window */ int BadPixmap = 4; /* parameter not a Pixmap */ int BadAtom = 5; /* parameter not an Atom */ int BadCursor = 6; /* parameter not a Cursor */ int BadFont = 7; /* parameter not a Font */ int BadMatch = 8; /* parameter mismatch */ int BadDrawable = 9; /* parameter not a Pixmap or Window */ int BadAccess = 10; /* depending on context: - key/button already grabbed - attempt to free an illegal cmap entry - attempt to store into a read-only color map entry. - attempt to modify the access control list from other than the local host. */ int BadAlloc = 11; /* insufficient resources */ int BadColor = 12; /* no such colormap */ int BadGC = 13; /* parameter not a GC */ int BadIDChoice = 14; /* choice not in range or already used */ int BadName = 15; /* font or color name doesn't exist */ int BadLength = 16; /* Request length incorrect */ int BadImplementation = 17; /* server is defective */ int FirstExtensionError = 128; int LastExtensionError = 255; /***************************************************************** * WINDOW DEFINITIONS *****************************************************************/ /* Window classes used by CreateWindow */ /* Note that CopyFromParent is already defined as 0 above */ int InputOutput = 1; int InputOnly = 2; /* Window attributes for CreateWindow and ChangeWindowAttributes */ int CWBackPixmap = (1<<0); int CWBackPixel = (1<<1); int CWBorderPixmap = (1<<2); int CWBorderPixel = (1<<3); int CWBitGravity = (1<<4); int CWWinGravity = (1<<5); int CWBackingStore = (1<<6); int CWBackingPlanes = (1<<7); int CWBackingPixel = (1<<8); int CWOverrideRedirect = (1<<9); int CWSaveUnder = (1<<10); int CWEventMask = (1<<11); int CWDontPropagate = (1<<12); int CWColormap = (1<<13); int CWCursor = (1<<14); /* ConfigureWindow structure */ int CWX = (1<<0); int CWY = (1<<1); int CWWidth = (1<<2); int CWHeight = (1<<3); int CWBorderWidth = (1<<4); int CWSibling = (1<<5); int CWStackMode = (1<<6); /* Bit Gravity */ int ForgetGravity = 0; int NorthWestGravity = 1; int NorthGravity = 2; int NorthEastGravity = 3; int WestGravity = 4; int CenterGravity = 5; int EastGravity = 6; int SouthWestGravity = 7; int SouthGravity = 8; int SouthEastGravity = 9; int StaticGravity = 10; /* Window gravity + bit gravity above */ int UnmapGravity = 0; /* Used in CreateWindow for backing-store hint */ int NotUseful = 0; int WhenMapped = 1; int Always = 2; /* Used in GetWindowAttributes reply */ int IsUnmapped = 0; int IsUnviewable = 1; int IsViewable = 2; /* Used in ChangeSaveSet */ int SetModeInsert = 0; int SetModeDelete = 1; /* Used in ChangeCloseDownMode */ int DestroyAll = 0; int RetainPermanent = 1; int RetainTemporary = 2; /* Window stacking method (in configureWindow) */ int Above = 0; int Below = 1; int TopIf = 2; int BottomIf = 3; int Opposite = 4; /* Circulation direction */ int RaiseLowest = 0; int LowerHighest = 1; /* Property modes */ int PropModeReplace = 0; int PropModePrepend = 1; int PropModeAppend = 2; /***************************************************************** * GRAPHICS DEFINITIONS *****************************************************************/ /* graphics functions, as in GC.alu */ int GXclear = 0x0; /* 0 */ int GXand = 0x1; /* src AND dst */ int GXandReverse = 0x2; /* src AND NOT dst */ int GXcopy = 0x3; /* src */ int GXandInverted = 0x4; /* NOT src AND dst */ int GXnoop = 0x5; /* dst */ int GXxor = 0x6; /* src XOR dst */ int GXor = 0x7; /* src OR dst */ int GXnor = 0x8; /* NOT src AND NOT dst */ int GXequiv = 0x9; /* NOT src XOR dst */ int GXinvert = 0xa; /* NOT dst */ int GXorReverse = 0xb; /* src OR NOT dst */ int GXcopyInverted = 0xc; /* NOT src */ int GXorInverted = 0xd; /* NOT src OR dst */ int GXnand = 0xe; /* NOT src OR NOT dst */ int GXset = 0xf; /* 1 */ /* LineStyle */ int LineSolid = 0; int LineOnOffDash = 1; int LineDoubleDash = 2; /* capStyle */ int CapNotLast = 0; int CapButt = 1; int CapRound = 2; int CapProjecting = 3; /* joinStyle */ int JoinMiter = 0; int JoinRound = 1; int JoinBevel = 2; /* fillStyle */ int FillSolid = 0; int FillTiled = 1; int FillStippled = 2; int FillOpaqueStippled = 3; /* fillRule */ int EvenOddRule = 0; int WindingRule = 1; /* subwindow mode */ int ClipByChildren = 0; int IncludeInferiors = 1; /* SetClipRectangles ordering */ int Unsorted = 0; int YSorted = 1; int YXSorted = 2; int YXBanded = 3; /* CoordinateMode for drawing routines */ int CoordModeOrigin = 0; /* relative to the origin */ int CoordModePrevious = 1; /* relative to previous point */ /* Polygon shapes */ int Complex = 0; /* paths may intersect */ int Nonconvex = 1; /* no paths intersect, but not convex */ int Convex = 2; /* wholly convex */ /* Arc modes for PolyFillArc */ int ArcChord = 0; /* join endpoints of arc */ int ArcPieSlice = 1; /* join endpoints to center of arc */ /* GC components: masks used in CreateGC, CopyGC, ChangeGC, OR'ed into GC.stateChanges */ int GCFunction = (1<<0); int GCPlaneMask = (1<<1); int GCForeground = (1<<2); int GCBackground = (1<<3); int GCLineWidth = (1<<4); int GCLineStyle = (1<<5); int GCCapStyle = (1<<6); int GCJoinStyle = (1<<7); int GCFillStyle = (1<<8); int GCFillRule = (1<<9); int GCTile = (1<<10); int GCStipple = (1<<11); int GCTileStipXOrigin = (1<<12); int GCTileStipYOrigin = (1<<13); int GCFont = (1<<14); int GCSubwindowMode = (1<<15); int GCGraphicsExposures = (1<<16); int GCClipXOrigin = (1<<17); int GCClipYOrigin = (1<<18); int GCClipMask = (1<<19); int GCDashOffset = (1<<20); int GCDashList = (1<<21); int GCArcMode = (1<<22); int GCLastBit = 22; /***************************************************************** * FONTS *****************************************************************/ /* used in QueryFont -- draw direction */ int FontLeftToRight = 0; int FontRightToLeft = 1; int FontChange = 255; /***************************************************************** * IMAGING *****************************************************************/ /* ImageFormat -- PutImage, GetImage */ int XYBitmap = 0; /* depth 1, XYFormat */ int XYPixmap = 1; /* depth == drawable depth */ int ZPixmap = 2; /* depth == drawable depth */ /***************************************************************** * COLOR MAP STUFF *****************************************************************/ /* For CreateColormap */ int AllocNone = 0; /* create map with no entries */ int AllocAll = 1; /* allocate entire map writeable */ /* Flags used in StoreNamedColor, StoreColors */ int DoRed = (1<<0); int DoGreen = (1<<1); int DoBlue = (1<<2); /***************************************************************** * CURSOR STUFF *****************************************************************/ /* QueryBestSize Class */ int CursorShape = 0; /* largest size that can be displayed */ int TileShape = 1; /* size tiled fastest */ int StippleShape = 2; /* size stippled fastest */ /***************************************************************** * KEYBOARD/POINTER STUFF *****************************************************************/ int AutoRepeatModeOff = 0; int AutoRepeatModeOn = 1; int AutoRepeatModeDefault = 2; int LedModeOff = 0; int LedModeOn = 1; /* masks for ChangeKeyboardControl */ int KBKeyClickPercent = (1<<0); int KBBellPercent = (1<<1); int KBBellPitch = (1<<2); int KBBellDuration = (1<<3); int KBLed = (1<<4); int KBLedMode = (1<<5); int KBKey = (1<<6); int KBAutoRepeatMode = (1<<7); int MappingSuccess = 0; int MappingBusy = 1; int MappingFailed = 2; int MappingModifier = 0; int MappingKeyboard = 1; int MappingPointer = 2; /***************************************************************** * SCREEN SAVER STUFF *****************************************************************/ int DontPreferBlanking = 0; int PreferBlanking = 1; int DefaultBlanking = 2; int DisableScreenSaver = 0; int DisableScreenInterval = 0; int DontAllowExposures = 0; int AllowExposures = 1; int DefaultExposures = 2; /* for ForceScreenSaver */ int ScreenSaverReset = 0; int ScreenSaverActive = 1; /***************************************************************** * HOSTS AND CONNECTIONS *****************************************************************/ /* for ChangeHosts */ int HostInsert = 0; int HostDelete = 1; /* for ChangeAccessControl */ int EnableAccess = 1; int DisableAccess = 0; /* Display classes used in opening the connection * Note that the statically allocated ones are even numbered and the * dynamically changeable ones are odd numbered */ int StaticGray = 0; int GrayScale = 1; int StaticColor = 2; int PseudoColor = 3; int TrueColor = 4; int DirectColor = 5; /* Byte order used in imageByteOrder and bitmapBitOrder */ int LSBFirst = 0; int MSBFirst = 1; /***************************************************************** * DEFINITIONS OF SPECIFIC EVENTS *****************************************************************/ public static class XEvent extends Union { public int type; public XAnyEvent xany; public XKeyEvent xkey; public XButtonEvent xbutton; public XMotionEvent xmotion; public XCrossingEvent xcrossing; public XFocusChangeEvent xfocus; public XExposeEvent xexpose; public XGraphicsExposeEvent xgraphicsexpose; public XNoExposeEvent xnoexpose; public XVisibilityEvent xvisibility; public XCreateWindowEvent xcreatewindow; public XDestroyWindowEvent xdestroywindow; public XUnmapEvent xunmap; public XMapEvent xmap; public XMapRequestEvent xmaprequest; public XReparentEvent xreparent; public XConfigureEvent xconfigure; public XGravityEvent xgravity; public XResizeRequestEvent xresizerequest; public XConfigureRequestEvent xconfigurerequest; public XCirculateEvent xcirculate; public XCirculateRequestEvent xcirculaterequest; public XPropertyEvent xproperty; public XSelectionClearEvent xselectionclear; public XSelectionRequestEvent xselectionrequest; public XSelectionEvent xselection; public XColormapEvent xcolormap; public XClientMessageEvent xclient; public XMappingEvent xmapping; public XErrorEvent xerror; public XKeymapEvent xkeymap; public NativeLong[] pad = new NativeLong[24]; } public static class XAnyEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; // window on which event was requested in event mask } class XKeyEvent extends Structure { public int type; // of event public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // public Display the event was read from public Window window; // "event" window it is reported relative to public Window root; // root window that the event occurred on public Window subwindow; // child window public NativeLong time; // milliseconds public int x, y; // pointer x, y coordinates in event window public int x_root, y_root; // coordinates relative to root public int state; // key or button mask public int keycode; // detail public int same_screen; // same screen flag } class XButtonEvent extends Structure { public int type; // of event public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; // "event" window it is reported relative to public Window root; // root window that the event occurred on public Window subwindow; // child window public NativeLong time; // milliseconds public int x, y; // pointer x, y coordinates in event window public int x_root, y_root; // coordinates relative to root public int state; // key or button mask public int button; // detail public int same_screen; // same screen flag } class XButtonPressedEvent extends XButtonEvent { } class XButtonReleasedEvent extends XButtonEvent { } public static class XClientMessageEvent extends Structure { public int type; // ClientMessage public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; public Atom message_type; public int format; public Data data; public static class Data extends Union { public byte b[] = new byte[20]; public short s[] = new short[10]; public NativeLong[] l = new NativeLong[5]; } } class XMotionEvent extends Structure { public int type; // of event public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; // "event" window reported relative to public Window root; // root window that the event occurred on public Window subwindow; // child window public NativeLong time; // milliseconds public int x, y; // pointer x, y coordinates in event window public int x_root, y_root; // coordinates relative to root public int state; // key or button mask public byte is_hint; // detail public int same_screen; // same screen flag } class XPointerMovedEvent extends XMotionEvent { } class XCrossingEvent extends Structure { public int type; // of event public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; // "event" window reported relative to public Window root; // root window that the event occurred on public Window subwindow; // child window public NativeLong time; // milliseconds public int x, y; // pointer x, y coordinates in event window public int x_root, y_root; // coordinates relative to root public int mode; // NotifyNormal, NotifyGrab, NotifyUngrab public int detail; /* * NotifyAncestor, NotifyVirtual, NotifyInferior, * NotifyNonlinear,NotifyNonlinearVirtual */ public int same_screen; // same screen flag public int focus; // intean focus public int state; // key or button mask } class XEnterWindowEvent extends XCrossingEvent { } class XLeaveWindowEvent extends XCrossingEvent { } class XFocusChangeEvent extends Structure { public int type; // FocusIn or FocusOut public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; // window of event public int mode; // NotifyNormal, NotifyWhileGrabbed, NotifyGrab, NotifyUngrab public int detail; /* * NotifyAncestor, NotifyVirtual, NotifyInferior, * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer, * NotifyPointerRoot, NotifyDetailNone */ } class XFocusInEvent extends XFocusChangeEvent { } class XFocusOutEvent extends XFocusChangeEvent { } class XExposeEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; public int x, y; public int width, height; public int count; // if non-zero, at least this many more } class XGraphicsExposeEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Drawable drawable; public int x, y; public int width, height; public int count; // if non-zero, at least this many more public int major_code; // core is CopyArea or CopyPlane public int minor_code; // not defined in the core } class XNoExposeEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Drawable drawable; public int major_code; // core is CopyArea or CopyPlane public int minor_code; // not defined in the core } class XVisibilityEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; public int state; // Visibility state } class XCreateWindowEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window parent; // parent of the window public Window window; // window id of window created public int x, y; // window location public int width, height; // size of window public int border_width; // border width public int override_redirect; // creation should be overridden } class XDestroyWindowEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window event; public Window window; } class XUnmapEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window event; public Window window; public int from_configure; } class XMapEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window event; public Window window; public int override_redirect; // intean, is override set... } class XMapRequestEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window parent; public Window window; } class XReparentEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window event; public Window window; public Window parent; public int x, y; public int override_redirect; } class XConfigureEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window event; public Window window; public int x, y; public int width, height; public int border_width; public Window above; public int override_redirect; } class XGravityEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window event; public Window window; public int x, y; } class XResizeRequestEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; public int width, height; } class XConfigureRequestEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window parent; public Window window; public int x, y; public int width, height; public int border_width; public Window above; public int detail; // Above, Below, TopIf, BottomIf, Opposite public NativeLong value_mask; } class XCirculateEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window event; public Window window; public int place; // PlaceOnTop, PlaceOnBottom } class XCirculateRequestEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window parent; public Window window; public int place; // PlaceOnTop, PlaceOnBottom } class XPropertyEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; public Atom atom; public NativeLong time; public int state; // NewValue, Deleted } class XSelectionClearEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; public Atom selection; public NativeLong time; } class XSelectionRequestEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window owner; public Window requestor; public Atom selection; public Atom target; Atom property; public NativeLong time; } class XSelectionEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window requestor; public Atom selection; public Atom target; public Atom property; // ATOM or None public NativeLong time; } class XColormapEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; public Colormap colormap; // COLORMAP or None public int c_new; // C++ public int state; // ColormapInstalled, ColormapUninstalled } class XMappingEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; // unused public int request; // one of MappingModifier, MappingKeyboard, MappingPointer public int first_keycode; // first keycode public int count; // defines range of change w. first_keycode*/ } class XErrorEvent extends Structure { public int type; public Display display; // Display the event was read from public XID resourceid; // resource id public NativeLong serial; // serial number of failed request public byte error_code; // error code of failed request public byte request_code; // Major op-code of failed request public byte minor_code; // Minor op-code of failed request } // generated on EnterWindow and FocusIn when KeyMapState selected class XKeymapEvent extends Structure { public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; public byte key_vector[] = new byte[32]; } int XSelectInput(Display display, Window window, NativeLong eventMask); int XSendEvent(Display display, Window w, int propagate, NativeLong event_mask, XEvent event_send); int XNextEvent(Display display, XEvent event_return); int XPeekEvent(Display display, XEvent event_return); int XWindowEvent(Display display, Window w, NativeLong event_mask, XEvent event_return); boolean XCheckWindowEvent(Display display, Window w, NativeLong event_mask, XEvent event_return); int XMaskEvent(Display display, NativeLong event_mask, XEvent event_return); boolean XCheckMaskEvent(Display display, NativeLong event_mask, XEvent event_return); boolean XCheckTypedEvent(Display display, int event_type, XEvent event_return); boolean XCheckTypedWindowEvent(Display display, Window w, int event_type, XEvent event_return); /** Returns an {@link XWMHints} which must be freed by {@link #XFree}. */ XWMHints XGetWMHints(Display display, Window window); int XGetWMName(Display display, Window window, XTextProperty text_property_return); /** Returns an array of {@link XVisualInfo} which must be freed by {@link #XFree}. * Use {@link XVisualInfo#toArray(int) * toArray(nitems_return.getValue()} to obtain the array. */ XVisualInfo XGetVisualInfo(Display display, NativeLong vinfo_mask, XVisualInfo vinfo_template, IntByReference nitems_return); Colormap XCreateColormap(Display display, Window w, Visual visual, int alloc); int XGetWindowProperty(Display display, Window w, Atom property, NativeLong long_offset, NativeLong long_length, boolean delete, Atom reg_type, AtomByReference actual_type_return, IntByReference actual_format_return, NativeLongByReference nitems_return, NativeLongByReference bytes_after_return, PointerByReference prop_return); int XChangeProperty(Display display, Window w, Atom property, Atom type, int format, int mode, Pointer data, int nelements); int XDeleteProperty(Display display, Window w, Atom property); // Atom XInternAtom(Display *display, char *atom_name, Bool only_if_exists); Atom XInternAtom(Display display, String name, boolean only_if_exists); // char *XGetAtomName(Display *display, Atom atom); String XGetAtomName(Display display, Atom atom); int XCopyArea(Display dpy, Drawable src, Drawable dst, GC gc, int src_x, int src_y, int w, int h, int dst_x, int dst_y); XImage XCreateImage(Display dpy, Visual visual, int depth, int format, int offset, Pointer data, int width, int height, int bitmap_pad, int bytes_per_line); int XPutImage(Display dpy, Drawable d, GC gc, XImage image, int src_x, int src_y, int dest_x, int dest_y, int width, int height); int XDestroyImage(XImage image); /***************************************************************** * KeySyms, Keycodes, Keymaps *****************************************************************/ String XKeysymToString(KeySym keysym); KeySym XStringToKeysym(String string); byte XKeysymToKeycode(Display display, KeySym keysym); KeySym XKeycodeToKeysym(Display display, byte keycode, int index); //int XChangeKeyboardMapping(Display display, int first_keycode, int keysyms_per_keycode, KeySym *keysyms, int num_codes); /** Defines the symbols for the specified number of KeyCodes starting with first_keycode. The symbols for KeyCodes outside this range remain unchanged. The number of elements in keysyms must be: num_codes * keysyms_per_keycode. The specified first_keycode must be greater than or equal to min_keycode returned by XDisplayKeycodes, or a BadValue error results. In addition, the following expression must be less than or equal to max_keycode as returned by XDisplayKeycodes, or a BadValue error results: first_keycode + num_codes - 1. */ int XChangeKeyboardMapping(Display display, int first_keycode, int keysyms_per_keycode, KeySym[] keysyms, int num_codes); /** Returns the symbols for the specified number of KeyCodes starting with first_keycode. The value specified in first_keycode must be greater than or equal to min_keycode as returned by XDisplayKeycodes, or a BadValue error results. In addition, the following expression must be less than or equal to max_keycode as returned by XDisplayKeycodes: first_keycode + keycode_count - 1. If this is not the case, a BadValue error results. The number of elements in the KeySyms list is: keycode_count * keysyms_per_keycode_return. KeySym number N, counting from zero, for KeyCode K has the following index in the list, counting from zero: (K - first_code) * keysyms_per_code_return + N. The X server arbitrarily chooses the keysyms_per_keycode_return value to be large enough to report all requested symbols. A special KeySym value of NoSymbol is used to fill in unused elements for individual KeyCodes. To free the storage returned by XGetKeyboardMapping, use XFree. */ KeySym XGetKeyboardMapping(Display display, byte first_keycode, int keycode_count, IntByReference keysyms_per_keycode_return); /** Returns the min-keycodes and max-keycodes supported by the specified display. The minimum number of KeyCodes returned is never less than 8, and the maximum number of KeyCodes returned is never greater than 255. Not all KeyCodes in this range are required to have corresponding keys. */ int XDisplayKeycodes(Display display, IntByReference min_keycodes_return, IntByReference max_keycodes_return); /** Specifies the KeyCodes of the keys (if any) that are to be used as modifiers. If it succeeds, the X server generates a MappingNotify event, and XSetModifierMapping returns MappingSuccess. X permits at most 8 modifier keys. If more than 8 are specified in the XModifierKeymap structure, a BadLength error results. */ int XSetModifierMapping(Display display, XModifierKeymapRef modmap); /** The XGetModifierMapping function returns a pointer to a newly created XModifierKeymap structure that contains the keys being used as modifiers. The structure should be freed after use by calling XFreeModifiermap. If only zero values appear in the set for any modifier, that modifier is disabled. */ XModifierKeymapRef XGetModifierMapping(Display display); /** Returns a pointer to XModifierKeymap structure for later use. */ XModifierKeymapRef XNewModifiermap(int max_keys_per_mod); /** Adds the specified KeyCode to the set that controls the specified modifier and returns the resulting XModifierKeymap structure (expanded as needed). */ XModifierKeymapRef XInsertModifiermapEntry(XModifierKeymapRef modmap, byte keycode_entry, int modifier); /** Deletes the specified KeyCode from the set that controls the specified modifier and returns a pointer to the resulting XModifierKeymap structure. */ XModifierKeymapRef XDeleteModifiermapEntry(XModifierKeymapRef modmap, byte keycode_entry, int modifier); /** Frees the specified XModifierKeymap structure. */ int XFreeModifiermap(XModifierKeymapRef modmap); /** Changes the keyboard control state. * @param display display * @param value_mask disjunction of KBKeyClickPercent, KBBellPercent, KBBellPitch, KBBellDuration, KBLed, KBLedMode, KBKey, KBAutoRepeatMode */ int XChangeKeyboardControl(Display display, NativeLong value_mask, XKeyboardControlRef values); /** Returns the current control values for the keyboard to the XKeyboardState structure. */ int XGetKeyboardControl(Display display, XKeyboardStateRef values_return); /** Turns on auto-repeat for the keyboard on the specified display. */ int XAutoRepeatOn(Display display); /** Turns off auto-repeat for the keyboard on the specified display. */ int XAutoRepeatOff(Display display); /** Rings the bell on the keyboard on the specified display, if possible. The specified volume is relative to the base volume for the keyboard. If the value for the percent argument is not in the range -100 to 100 inclusive, a BadValue error results. The volume at which the bell rings when the percent argument is nonnegative is: base - [(base * percent) / 100] + percent. The volume at which the bell rings when the percent argument is negative is: base + [(base * percent) / 100]. To change the base volume of the bell, use XChangeKeyboardControl. */ int XBell(Display display, int percent); /** Returns a bit vector for the logical state of the keyboard, where each bit set to 1 indicates that the corresponding key is currently pressed down. The vector is represented as 32 bytes. Byte N (from 0) contains the bits for keys 8N to 8N + 7 with the least significant bit in the byte representing key 8N. Note that the logical state of a device (as seen by client applications) may lag the physical state if device event processing is frozen. */ int XQueryKeymap(Display display, byte[] keys_return); /** The modifiermap member of the XModifierKeymap structure contains 8 sets of max_keypermod KeyCodes, one for each modifier in the order Shift, Lock, Control, Mod1, Mod2, Mod3, Mod4, and Mod5. Only nonzero KeyCodes have meaning in each set, and zero KeyCodes are ignored. In addition, all of the nonzero KeyCodes must be in the range specified by min_keycode and max_keycode in the Display structure, or a BadValue error results. */ class XModifierKeymapRef extends Structure implements Structure.ByReference{ public int max_keypermod; /* The server's max # of keys per modifier */ public Pointer modifiermap; /* An 8 by max_keypermod array of modifiers */ } class XKeyboardControlRef extends Structure implements Structure.ByReference { /** Volume for key clicks between 0 (off) and 100 (loud) inclusive, if possible. A setting of -1 restores the default. */ public int key_click_percent; /** Base volume for the bell between 0 (off) and 100 (loud) inclusive, if possible. A setting of -1 restores the default. */ public int bell_percent; /** Pitch (specified in Hz) of the bell, if possible. A setting of -1 restores the default. */ public int bell_pitch; /** Duration of the bell specified in milliseconds, if possible. A setting of -1 restores the default. */ public int bell_duration; /** State of the LEDs. At most 32 LEDs numbered from one are supported. */ public int led; /** LED mode: LedModeOn or LedModeOff. */ public int led_mode; /** auto_repeat_mode can change the auto repeat settings of this key. */ public int key; /** AutoRepeatModeOff, AutoRepeatModeOn, AutoRepeatModeDefault. */ public int auto_repeat_mode; public String toString() { return "XKeyboardControlByReference{" + "key_click_percent=" + key_click_percent + ", bell_percent=" + bell_percent + ", bell_pitch=" + bell_pitch + ", bell_duration=" + bell_duration + ", led=" + led + ", led_mode=" + led_mode + ", key=" + key + ", auto_repeat_mode=" + auto_repeat_mode + '}'; } } class XKeyboardStateRef extends Structure implements Structure.ByReference { /** Volume for key clicks between 0 (off) and 100 (loud) inclusive, if possible. */ public int key_click_percent; /** Base volume for the bell between 0 (off) and 100 (loud) inclusive, if possible. */ public int bell_percent; /** Pitch (specified in Hz) of the bell, if possible. A setting of -1 restores the default. */ public int bell_pitch; /** Duration of the bell specified in milliseconds, if possible. A setting of -1 restores the default. */ public int bell_duration; /** State of the LEDs. At most 32 LEDs numbered from one are supported. */ public NativeLong led_mask; /** Global auto repeat mode: AutoRepeatModeOff or AutoRepeatModeOn. */ public int global_auto_repeat; /** Bit vector. Each bit set to 1 indicates that auto-repeat is enabled for the corresponding key. The vector is represented as 32 bytes. Byte N (from 0) contains the bits for keys 8N to 8N + 7 with the least significant bit in the byte representing key 8N. */ public byte auto_repeats[] = new byte[32]; public String toString() { return "XKeyboardStateByReference{" + "key_click_percent=" + key_click_percent + ", bell_percent=" + bell_percent + ", bell_pitch=" + bell_pitch + ", bell_duration=" + bell_duration + ", led_mask=" + led_mask + ", global_auto_repeat=" + global_auto_repeat + ", auto_repeats=" + auto_repeats + '}'; } } } libjna-java-3.2.7/contrib/platform/src/com/sun/jna/platform/KeyboardUtils.java0000644000175000017500000001443611421126012025457 0ustar janjan/* 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. * * 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; import java.awt.GraphicsEnvironment; import java.awt.HeadlessException; import java.awt.event.KeyEvent; import com.sun.jna.Platform; import com.sun.jna.platform.unix.X11; import com.sun.jna.platform.unix.X11.Display; import com.sun.jna.platform.win32.User32; import com.sun.jna.platform.win32.WinUser; /** Provide access to the local keyboard state. Note that this is meaningless * on a headless system and some VNC setups. * * @author twall */ // TODO: key clicks // TODO: auto-repeat // TODO: keyboard bell // TODO: led state public class KeyboardUtils { static final NativeKeyboardUtils INSTANCE; static { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException("KeyboardUtils requires a keyboard"); } if (Platform.isWindows()) { INSTANCE = new W32KeyboardUtils(); } else if (Platform.isMac()) { INSTANCE = new MacKeyboardUtils(); throw new UnsupportedOperationException("No support (yet) for " + System.getProperty("os.name")); } else { INSTANCE = new X11KeyboardUtils(); } } public static boolean isPressed(int keycode, int location) { return INSTANCE.isPressed(keycode, location); } public static boolean isPressed(int keycode) { return INSTANCE.isPressed(keycode); } private static abstract class NativeKeyboardUtils { public abstract boolean isPressed(int keycode, int location); public boolean isPressed(int keycode) { return isPressed(keycode, KeyEvent.KEY_LOCATION_UNKNOWN); } } private static class W32KeyboardUtils extends NativeKeyboardUtils { private int toNative(int code, int loc) { if ((code >= KeyEvent.VK_A && code <= KeyEvent.VK_Z) || (code >= KeyEvent.VK_0 && code <= KeyEvent.VK_9)) { return code; } if (code == KeyEvent.VK_SHIFT) { if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) { return WinUser.VK_RSHIFT; } if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) { return WinUser.VK_LSHIFT; } return WinUser.VK_SHIFT; } if (code == KeyEvent.VK_CONTROL) { if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) { return WinUser.VK_RCONTROL; } if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) { return WinUser.VK_LCONTROL; } return WinUser.VK_CONTROL; } if (code == KeyEvent.VK_ALT) { if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) { return WinUser.VK_RMENU; } if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) { return WinUser.VK_LMENU; } return WinUser.VK_MENU; } return 0; } public boolean isPressed(int keycode, int location) { User32 lib = User32.INSTANCE; return (lib.GetAsyncKeyState(toNative(keycode, location)) & 0x8000) != 0; } } private static class MacKeyboardUtils extends NativeKeyboardUtils { public boolean isPressed(int keycode, int location) { return false; } } private static class X11KeyboardUtils extends NativeKeyboardUtils { // TODO: fully map from X11 keycodes to java keycodes // this is a minimal implementation private int toKeySym(int code, int location) { if (code >= KeyEvent.VK_A && code <= KeyEvent.VK_Z) return X11.XK_a + (code - KeyEvent.VK_A); if (code >= KeyEvent.VK_0 && code <= KeyEvent.VK_9) return X11.XK_0 + (code - KeyEvent.VK_0); if (code == KeyEvent.VK_SHIFT) { if ((location & KeyEvent.KEY_LOCATION_RIGHT) != 0) return X11.XK_Shift_R; return X11.XK_Shift_L; } if (code == KeyEvent.VK_CONTROL) { if ((location & KeyEvent.KEY_LOCATION_RIGHT) != 0) return X11.XK_Control_R; return X11.XK_Control_L; } if (code == KeyEvent.VK_ALT) { if ((location & KeyEvent.KEY_LOCATION_RIGHT) != 0) return X11.XK_Alt_R; return X11.XK_Alt_L; } if (code == KeyEvent.VK_META) { if ((location & KeyEvent.KEY_LOCATION_RIGHT) != 0) return X11.XK_Meta_R; return X11.XK_Meta_L; } return 0; } public boolean isPressed(int keycode, int location) { X11 lib = X11.INSTANCE; Display dpy = lib.XOpenDisplay(null); if (dpy == null) { throw new Error("Can't open X Display"); } try { byte[] keys = new byte[32]; // Ignore the return value lib.XQueryKeymap(dpy, keys); int keysym = toKeySym(keycode, location); for (int code=5;code < 256;code++) { int idx = code / 8; int shift = code % 8; if ((keys[idx] & (1 << shift)) != 0) { int sym = lib.XKeycodeToKeysym(dpy, (byte)code, 0).intValue(); if (sym == keysym) return true; } } } finally { lib.XCloseDisplay(dpy); } return false; } } } libjna-java-3.2.7/contrib/platform/test/0000755000175000017500000000000011421126022016235 5ustar janjanlibjna-java-3.2.7/contrib/platform/test/com/0000755000175000017500000000000011421126022017013 5ustar janjanlibjna-java-3.2.7/contrib/platform/test/com/sun/0000755000175000017500000000000011421126022017620 5ustar janjanlibjna-java-3.2.7/contrib/platform/test/com/sun/jna/0000755000175000017500000000000011421126022020370 5ustar janjanlibjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/0000755000175000017500000000000011421126024022216 5ustar janjanlibjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/FileUtilsTest.java0000644000175000017500000000310411421126022025615 0ustar janjan/* 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. *

* 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; import java.io.File; import java.io.IOException; import junit.framework.TestCase; public class FileUtilsTest extends TestCase { public void testMoveToTrash() throws Exception { FileUtils utils = FileUtils.getInstance(); if (!utils.hasTrash()) return; File home = new File(System.getProperty("user.home")); File file = File.createTempFile(getName(), ".tmp", home); try { assertTrue("File should exist", file.exists()); try { utils.moveToTrash(new File[] { file }); } catch(IOException e) { fail(e.toString()); } assertFalse("Failed to move " + file + " to trash", file.exists()); } finally { if (file.exists()) { file.delete(); } } } public static void main(String[] args) { junit.textui.TestRunner.run(FileUtilsTest.class); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/RasterRangesUtilsTest.java0000644000175000017500000000635111421126022027345 0ustar janjan/* Copyright (c) 2008 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. * * 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; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.Area; import java.awt.image.BufferedImage; import java.awt.image.Raster; import java.util.HashSet; import java.util.Set; import junit.framework.TestCase; import com.sun.jna.platform.RasterRangesUtils.RangesOutput; public class RasterRangesUtilsTest extends TestCase { Set rects = new HashSet(); RangesOutput out = new RangesOutput() { public boolean outputRange(int x, int y, int w, int h) { rects.add(new Rectangle(x, y, w, h)); return true; } }; private Raster createRaster(Shape mask) { BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB); Graphics2D g = image.createGraphics(); g.fill(mask); g.dispose(); return image.getRaster(); } public void testDecomposeRectangles() { Set EXPECTED = new HashSet() { { add(new Rectangle(0, 0, 100, 50)); add(new Rectangle(0, 50, 50, 50)); } private static final long serialVersionUID = 1L; }; Area mask = new Area(new Rectangle(0, 0, 100, 100)); mask.subtract(new Area(new Rectangle(50, 50, 50, 50))); RasterRangesUtils.outputOccupiedRanges(createRaster(mask), out); assertEquals("Wrong number of rectangles", EXPECTED.size(), rects.size()); assertEquals("Wrong rectangles", EXPECTED, rects); } public void testDecomposeRectanglesWithHole() { Set EXPECTED = new HashSet() { { add(new Rectangle(0, 0, 100, 25)); add(new Rectangle(0, 25, 25, 50)); add(new Rectangle(75, 25, 25, 50)); add(new Rectangle(0, 75, 100, 25)); } private static final long serialVersionUID = 1L; }; Area mask = new Area(new Rectangle(0, 0, 100, 100)); mask.subtract(new Area(new Rectangle(25, 25, 50, 50))); RasterRangesUtils.outputOccupiedRanges(createRaster(mask), out); assertEquals("Wrong number of rectangles", EXPECTED.size(), rects.size()); assertEquals("Wrong rectangles", EXPECTED, rects); /* long start = System.currentTimeMillis(); for (int i=0;i < 100;i++) { RasterRangesUtils.outputOccupiedRanges(createRaster(mask), out); } System.out.println("raster: " + (System.currentTimeMillis()-start)); */ } public static void main(String[] args) { junit.textui.TestRunner.run(RasterRangesUtilsTest.class); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/0000755000175000017500000000000011421375070023167 5ustar janjanlibjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Win32ExceptionTest.java0000644000175000017500000000260411421126024027446 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; /** * @author dblock[at]dblock[dot]org */ public class Win32ExceptionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Win32ExceptionTest.class); } public void testFormatMessageFromLastErrorCode() { try { throw new Win32Exception(W32Errors.ERROR_SHARING_PAUSED); } catch (Win32Exception e) { assertEquals("The remote server has been paused or is in the process of being started.", e.getMessage()); } } public void testFormatMessageFromHR() { try { throw new Win32Exception(W32Errors.S_OK); } catch (Win32Exception e) { assertEquals("The operation completed successfully.", e.getMessage()); } } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Secur32Test.java0000644000175000017500000004132011421126024026111 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.Native; import com.sun.jna.NativeLong; import com.sun.jna.platform.win32.Sspi.CredHandle; import com.sun.jna.platform.win32.Sspi.CtxtHandle; import com.sun.jna.platform.win32.Sspi.PSecPkgInfo; import com.sun.jna.platform.win32.Sspi.SecBufferDesc; import com.sun.jna.platform.win32.Sspi.SecPkgInfo; import com.sun.jna.platform.win32.Sspi.TimeStamp; import com.sun.jna.platform.win32.WinNT.HANDLEByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.NativeLongByReference; /** * @author dblock[at]dblock[dot]org */ public class Secur32Test extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Secur32Test.class); } public void testGetUserNameEx() { IntByReference len = new IntByReference(); Secur32.INSTANCE.GetUserNameEx( Secur32.EXTENDED_NAME_FORMAT.NameSamCompatible, null, len); assertTrue(len.getValue() > 0); char[] buffer = new char[len.getValue() + 1]; assertTrue(Secur32.INSTANCE.GetUserNameEx( Secur32.EXTENDED_NAME_FORMAT.NameSamCompatible, buffer, len)); String username = Native.toString(buffer); assertTrue(username.length() > 0); } public void testAcquireCredentialsHandle() { CredHandle phCredential = new CredHandle(); TimeStamp ptsExpiry = new TimeStamp(); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle( null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_OUTBOUND), null, null, null, null, phCredential, ptsExpiry)); assertTrue(phCredential.dwLower != null); assertTrue(phCredential.dwUpper != null); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.FreeCredentialsHandle( phCredential)); } public void testAcquireCredentialsHandleInvalidPackage() { CredHandle phCredential = new CredHandle(); TimeStamp ptsExpiry = new TimeStamp(); assertEquals(W32Errors.SEC_E_SECPKG_NOT_FOUND, Secur32.INSTANCE.AcquireCredentialsHandle( null, "PackageDoesntExist", new NativeLong(Sspi.SECPKG_CRED_OUTBOUND), null, null, null, null, phCredential, ptsExpiry)); } public void testInitializeSecurityContext() { CredHandle phCredential = new CredHandle(); TimeStamp ptsExpiry = new TimeStamp(); // acquire a credentials handle assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle( null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_OUTBOUND), null, null, null, null, phCredential, ptsExpiry)); // initialize security context CtxtHandle phNewContext = new CtxtHandle(); SecBufferDesc pbToken = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE); NativeLongByReference pfContextAttr = new NativeLongByReference(); int rc = Secur32.INSTANCE.InitializeSecurityContext(phCredential, null, Advapi32Util.getUserName(), new NativeLong(Sspi.ISC_REQ_CONNECTION), new NativeLong(0), new NativeLong(Sspi.SECURITY_NATIVE_DREP), null, new NativeLong(0), phNewContext, pbToken, pfContextAttr, null); assertTrue(rc == W32Errors.SEC_I_CONTINUE_NEEDED || rc == W32Errors.SEC_E_OK); assertTrue(phNewContext.dwLower != null); assertTrue(phNewContext.dwUpper != null); assertTrue(pbToken.pBuffers[0].getBytes().length > 0); // release assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.DeleteSecurityContext( phNewContext)); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.FreeCredentialsHandle( phCredential)); } public void testAcceptSecurityContext() { // client ----------- acquire outbound credential handle CredHandle phClientCredential = new CredHandle(); TimeStamp ptsClientExpiry = new TimeStamp(); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle( null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_OUTBOUND), null, null, null, null, phClientCredential, ptsClientExpiry)); // client ----------- security context CtxtHandle phClientContext = new CtxtHandle(); NativeLongByReference pfClientContextAttr = new NativeLongByReference(); // server ----------- acquire inbound credential handle CredHandle phServerCredential = new CredHandle(); TimeStamp ptsServerExpiry = new TimeStamp(); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle( null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_INBOUND), null, null, null, null, phServerCredential, ptsServerExpiry)); // server ----------- security context CtxtHandle phServerContext = new CtxtHandle(); SecBufferDesc pbServerToken = null; NativeLongByReference pfServerContextAttr = new NativeLongByReference(); int clientRc = W32Errors.SEC_I_CONTINUE_NEEDED; int serverRc = W32Errors.SEC_I_CONTINUE_NEEDED; do { // client ----------- initialize security context, produce a client token // client token returned is always new SecBufferDesc pbClientToken = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE); if (clientRc == W32Errors.SEC_I_CONTINUE_NEEDED) { // server token is empty the first time SecBufferDesc pbServerTokenCopy = pbServerToken == null ? null : new SecBufferDesc(Sspi.SECBUFFER_TOKEN, pbServerToken.getBytes()); clientRc = Secur32.INSTANCE.InitializeSecurityContext( phClientCredential, phClientContext.isNull() ? null : phClientContext, Advapi32Util.getUserName(), new NativeLong(Sspi.ISC_REQ_CONNECTION), new NativeLong(0), new NativeLong(Sspi.SECURITY_NATIVE_DREP), pbServerTokenCopy, new NativeLong(0), phClientContext, pbClientToken, pfClientContextAttr, null); assertTrue(clientRc == W32Errors.SEC_I_CONTINUE_NEEDED || clientRc == W32Errors.SEC_E_OK); } // server ----------- accept security context, produce a server token if (serverRc == W32Errors.SEC_I_CONTINUE_NEEDED) { pbServerToken = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE); SecBufferDesc pbClientTokenByValue = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, pbClientToken.getBytes()); serverRc = Secur32.INSTANCE.AcceptSecurityContext(phServerCredential, phServerContext.isNull() ? null : phServerContext, pbClientTokenByValue, new NativeLong(Sspi.ISC_REQ_CONNECTION), new NativeLong(Sspi.SECURITY_NATIVE_DREP), phServerContext, pbServerToken, pfServerContextAttr, ptsServerExpiry); assertTrue(serverRc == W32Errors.SEC_I_CONTINUE_NEEDED || serverRc == W32Errors.SEC_E_OK); } } while(serverRc != W32Errors.SEC_E_OK || clientRc != W32Errors.SEC_E_OK); // release server context assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.DeleteSecurityContext( phServerContext)); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.FreeCredentialsHandle( phServerCredential)); // release client context assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.DeleteSecurityContext( phClientContext)); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.FreeCredentialsHandle( phClientCredential)); } public void testImpersonateRevertSecurityContext() { // client ----------- acquire outbound credential handle CredHandle phClientCredential = new CredHandle(); TimeStamp ptsClientExpiry = new TimeStamp(); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle( null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_OUTBOUND), null, null, null, null, phClientCredential, ptsClientExpiry)); // client ----------- security context CtxtHandle phClientContext = new CtxtHandle(); NativeLongByReference pfClientContextAttr = new NativeLongByReference(); // server ----------- acquire inbound credential handle CredHandle phServerCredential = new CredHandle(); TimeStamp ptsServerExpiry = new TimeStamp(); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle( null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_INBOUND), null, null, null, null, phServerCredential, ptsServerExpiry)); // server ----------- security context CtxtHandle phServerContext = new CtxtHandle(); SecBufferDesc pbServerToken = null; NativeLongByReference pfServerContextAttr = new NativeLongByReference(); int clientRc = W32Errors.SEC_I_CONTINUE_NEEDED; int serverRc = W32Errors.SEC_I_CONTINUE_NEEDED; do { // client ----------- initialize security context, produce a client token // client token returned is always new SecBufferDesc pbClientToken = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE); if (clientRc == W32Errors.SEC_I_CONTINUE_NEEDED) { // server token is empty the first time SecBufferDesc pbServerTokenCopy = pbServerToken == null ? null : new SecBufferDesc(Sspi.SECBUFFER_TOKEN, pbServerToken.getBytes()); clientRc = Secur32.INSTANCE.InitializeSecurityContext( phClientCredential, phClientContext.isNull() ? null : phClientContext, Advapi32Util.getUserName(), new NativeLong(Sspi.ISC_REQ_CONNECTION), new NativeLong(0), new NativeLong(Sspi.SECURITY_NATIVE_DREP), pbServerTokenCopy, new NativeLong(0), phClientContext, pbClientToken, pfClientContextAttr, null); assertTrue(clientRc == W32Errors.SEC_I_CONTINUE_NEEDED || clientRc == W32Errors.SEC_E_OK); } // server ----------- accept security context, produce a server token if (serverRc == W32Errors.SEC_I_CONTINUE_NEEDED) { pbServerToken = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE); SecBufferDesc pbClientTokenByValue = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, pbClientToken.getBytes()); serverRc = Secur32.INSTANCE.AcceptSecurityContext(phServerCredential, phServerContext.isNull() ? null : phServerContext, pbClientTokenByValue, new NativeLong(Sspi.ISC_REQ_CONNECTION), new NativeLong(Sspi.SECURITY_NATIVE_DREP), phServerContext, pbServerToken, pfServerContextAttr, ptsServerExpiry); assertTrue(serverRc == W32Errors.SEC_I_CONTINUE_NEEDED || serverRc == W32Errors.SEC_E_OK); } } while(serverRc != W32Errors.SEC_E_OK || clientRc != W32Errors.SEC_E_OK); // impersonate assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.ImpersonateSecurityContext( phServerContext)); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.RevertSecurityContext( phServerContext)); // release server context assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.DeleteSecurityContext( phServerContext)); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.FreeCredentialsHandle( phServerCredential)); // release client context assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.DeleteSecurityContext( phClientContext)); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.FreeCredentialsHandle( phClientCredential)); } public void testEnumerateSecurityPackages() { IntByReference pcPackages = new IntByReference(); PSecPkgInfo.ByReference pPackageInfo = new PSecPkgInfo.ByReference(); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.EnumerateSecurityPackages( pcPackages, pPackageInfo)); SecPkgInfo.ByReference[] packagesInfo = pPackageInfo.toArray( pcPackages.getValue()); for(SecPkgInfo.ByReference packageInfo : packagesInfo) { assertTrue(packageInfo.Name.length() > 0); assertTrue(packageInfo.Comment.length() >= 0); } assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.FreeContextBuffer( pPackageInfo.getPointer())); } public void testQuerySecurityContextToken() { // client ----------- acquire outbound credential handle CredHandle phClientCredential = new CredHandle(); TimeStamp ptsClientExpiry = new TimeStamp(); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle( null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_OUTBOUND), null, null, null, null, phClientCredential, ptsClientExpiry)); // client ----------- security context CtxtHandle phClientContext = new CtxtHandle(); NativeLongByReference pfClientContextAttr = new NativeLongByReference(); // server ----------- acquire inbound credential handle CredHandle phServerCredential = new CredHandle(); TimeStamp ptsServerExpiry = new TimeStamp(); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle( null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_INBOUND), null, null, null, null, phServerCredential, ptsServerExpiry)); // server ----------- security context CtxtHandle phServerContext = new CtxtHandle(); SecBufferDesc pbServerToken = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE); NativeLongByReference pfServerContextAttr = new NativeLongByReference(); int clientRc = W32Errors.SEC_I_CONTINUE_NEEDED; int serverRc = W32Errors.SEC_I_CONTINUE_NEEDED; do { // client token returned is always new SecBufferDesc pbClientToken = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE); // client ----------- initialize security context, produce a client token if (clientRc == W32Errors.SEC_I_CONTINUE_NEEDED) { // server token is empty the first time clientRc = Secur32.INSTANCE.InitializeSecurityContext( phClientCredential, phClientContext.isNull() ? null : phClientContext, Advapi32Util.getUserName(), new NativeLong(Sspi.ISC_REQ_CONNECTION), new NativeLong(0), new NativeLong(Sspi.SECURITY_NATIVE_DREP), pbServerToken, new NativeLong(0), phClientContext, pbClientToken, pfClientContextAttr, null); assertTrue(clientRc == W32Errors.SEC_I_CONTINUE_NEEDED || clientRc == W32Errors.SEC_E_OK); } // server ----------- accept security context, produce a server token if (serverRc == W32Errors.SEC_I_CONTINUE_NEEDED) { serverRc = Secur32.INSTANCE.AcceptSecurityContext(phServerCredential, phServerContext.isNull() ? null : phServerContext, pbClientToken, new NativeLong(Sspi.ISC_REQ_CONNECTION), new NativeLong(Sspi.SECURITY_NATIVE_DREP), phServerContext, pbServerToken, pfServerContextAttr, ptsServerExpiry); assertTrue(serverRc == W32Errors.SEC_I_CONTINUE_NEEDED || serverRc == W32Errors.SEC_E_OK); } } while(serverRc != W32Errors.SEC_E_OK || clientRc != W32Errors.SEC_E_OK); // query security context token HANDLEByReference phContextToken = new HANDLEByReference(); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.QuerySecurityContextToken( phServerContext, phContextToken)); // release security context token assertTrue(Kernel32.INSTANCE.CloseHandle(phContextToken.getValue())); // release server context assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.DeleteSecurityContext( phServerContext)); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.FreeCredentialsHandle( phServerCredential)); // release client context assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.DeleteSecurityContext( phClientContext)); assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.FreeCredentialsHandle( phClientCredential)); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/W32FileMonitorTest.java0000644000175000017500000001676211421126024027422 0ustar janjan/* 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. *

* 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 java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; import com.sun.jna.Platform; import com.sun.jna.platform.FileMonitor; import com.sun.jna.platform.FileMonitor.FileEvent; import com.sun.jna.platform.FileMonitor.FileListener; public class W32FileMonitorTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(W32FileMonitorTest.class); } private Map events; private FileMonitor monitor; private File tmpdir; protected void setUp() throws Exception { events = new HashMap(); final FileListener listener = new FileListener() { public void fileChanged(FileEvent e) { events.put(new Integer(e.getType()), e); } }; monitor = FileMonitor.getInstance(); monitor.addFileListener(listener); tmpdir = new File(Kernel32Util.getTempPath()); } protected void tearDown() { if (monitor != null) { monitor.dispose(); } } public void testNotifyOnFileCreation() throws Exception { monitor.addWatch(tmpdir); File file = File.createTempFile(getName(), ".tmp", tmpdir); file.deleteOnExit(); assertFileEventCreated(file); } public void testNotifyOnFileDelete() throws Exception { monitor.addWatch(tmpdir); File file = File.createTempFile(getName(), ".tmp", tmpdir); file.delete(); final FileEvent event = waitForFileEvent(FileMonitor.FILE_DELETED); assertNotNull("No delete event: " + events, event); assertEquals("Wrong target file for event", file, event.getFile()); } public void testNotifyOnFileDeleteViaAddWatchMask() throws Exception { if (!Platform.isWindows()) return; monitor.addWatch(tmpdir, FileMonitor.FILE_DELETED); File file = File.createTempFile(getName(), ".tmp", tmpdir); file.delete(); final FileEvent event = waitForFileEvent(FileMonitor.FILE_DELETED); assertNotNull("No delete event: " + events, event); assertEquals("Wrong target file for event", file, event.getFile()); } public void testNotifyOnFileRename() throws Exception { monitor.addWatch(tmpdir); File file = File.createTempFile(getName(), ".tmp", tmpdir); File newFile = new File(file.getParentFile(), "newfile"); newFile.deleteOnExit(); file.deleteOnExit(); file.renameTo(newFile); final FileEvent eventFilenameOld = waitForFileEvent(FileMonitor.FILE_NAME_CHANGED_OLD); final FileEvent eventFilenameNew = waitForFileEvent(FileMonitor.FILE_NAME_CHANGED_NEW); assertNotNull("No rename event (old): " + events, eventFilenameOld); assertNotNull("No rename event (new): " + events, eventFilenameNew); assertEquals("Wrong target file for event (old)", file, eventFilenameOld.getFile()); assertEquals("Wrong target file for event (new)", newFile, eventFilenameNew.getFile()); } public void testNotifyOnFileModification() throws Exception { if (!Platform.isWindows()) return; monitor.addWatch(tmpdir); File file = File.createTempFile(getName(), ".tmp", tmpdir); file.deleteOnExit(); final FileOutputStream os = new FileOutputStream(file); try { os.write(getName().getBytes()); } finally { os.close(); } final FileEvent event = waitForFileEvent(FileMonitor.FILE_MODIFIED); assertNotNull("No file modified event: " + events, event); assertEquals("Wrong target file for event (old)", file, event.getFile()); } private void delete(File file) { if (file.isDirectory()) { File[] files = file.listFiles(); for (int i=0;i < files.length;i++) { delete(files[i]); } } file.delete(); } private File createSubdir(File dir, String name) throws IOException { File f = File.createTempFile(name, ".tmp", dir); f.delete(); f.mkdirs(); return f; } public void testMultipleWatches() throws Exception { File subdir1 = createSubdir(tmpdir, "sub1-"); File subdir2 = createSubdir(tmpdir, "sub2-"); try { monitor.addWatch(subdir1); monitor.addWatch(subdir2); // trigger change in dir 1 assertFileEventCreated(File.createTempFile(getName(), ".tmp", subdir1)); // trigger change in dir 2 assertFileEventCreated(File.createTempFile(getName(), ".tmp", subdir2)); // trigger change in dir 1 assertFileEventCreated(File.createTempFile(getName(), ".tmp", subdir1)); } finally { delete(subdir1); delete(subdir2); } } public void testMultipleConsecutiveWatches() throws Exception { File subdir1 = createSubdir(tmpdir, "sub1-"); File subdir2 = createSubdir(tmpdir, "sub2-"); try { monitor.addWatch(subdir1); monitor.addWatch(subdir2); // trigger change in dir 1 assertFileEventCreated(File.createTempFile(getName(), ".tmp", subdir1)); monitor.removeWatch(subdir1); // trigger change in dir 2 assertFileEventCreated(File.createTempFile(getName(), ".tmp", subdir2)); monitor.removeWatch(subdir2); monitor.addWatch(subdir1); // assertion below has intermittent failures on slow W2K box w/out sleep Thread.sleep(10); // trigger change in dir 1 assertFileEventCreated(File.createTempFile(getName(), ".tmp", subdir1)); monitor.removeWatch(subdir1); } finally { delete(subdir1); delete(subdir2); } } private void assertFileEventCreated(final File expectedFile) throws InterruptedException { final FileEvent actualEvent = waitForFileEvent(FileMonitor.FILE_CREATED); assertNotNull("No creation event: " + events, actualEvent); assertEquals("Wrong target file for event", expectedFile, actualEvent.getFile()); events.clear(); } private FileEvent waitForFileEvent(final int expectedFileEvent) throws InterruptedException { final Integer expectedFileEventInteger = new Integer(expectedFileEvent); FileEvent actualEvent = (FileEvent)events.get(expectedFileEventInteger); final long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start < 5000 && actualEvent == null) { Thread.sleep(10); actualEvent = (FileEvent) events.get(expectedFileEventInteger); } assertTrue("No events sent", events.size() != 0); return actualEvent; } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Shell32UtilTest.java0000644000175000017500000000241211421126024026734 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; /** * @author dblock[at]dblock[dot]org */ public class Shell32UtilTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Shell32UtilTest.class); System.out.println("Windows: " + Shell32Util.getFolderPath(ShlObj.CSIDL_WINDOWS)); System.out.println(" System: " + Shell32Util.getFolderPath(ShlObj.CSIDL_SYSTEM)); System.out.println("AppData: " + Shell32Util.getFolderPath(ShlObj.CSIDL_APPDATA)); } public void testGetFolderPath() { assertTrue(Shell32Util.getFolderPath(ShlObj.CSIDL_WINDOWS).length() > 0); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Advapi32Test.java0000644000175000017500000006131411421126024026241 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.WString; import com.sun.jna.platform.win32.LMAccess.USER_INFO_1; import com.sun.jna.platform.win32.WinBase.FILETIME; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinNT.HANDLEByReference; import com.sun.jna.platform.win32.WinNT.PSID; import com.sun.jna.platform.win32.WinNT.PSIDByReference; import com.sun.jna.platform.win32.WinNT.SID_AND_ATTRIBUTES; import com.sun.jna.platform.win32.WinNT.SID_NAME_USE; import com.sun.jna.platform.win32.WinNT.WELL_KNOWN_SID_TYPE; import com.sun.jna.platform.win32.WinReg.HKEYByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.PointerByReference; /** * @author dblock[at]dblock[dot]org */ public class Advapi32Test extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Advapi32Test.class); } public void testGetUserName() { IntByReference len = new IntByReference(); assertFalse(Advapi32.INSTANCE.GetUserNameW(null, len)); assertEquals(W32Errors.ERROR_INSUFFICIENT_BUFFER, Kernel32.INSTANCE.GetLastError()); char[] buffer = new char[len.getValue()]; assertTrue(Advapi32.INSTANCE.GetUserNameW(buffer, len)); String username = Native.toString(buffer); assertTrue(username.length() > 0); } public void testLookupAccountName() { IntByReference pSid = new IntByReference(0); IntByReference pDomain = new IntByReference(0); PointerByReference peUse = new PointerByReference(); String accountName = "Administrator"; assertFalse(Advapi32.INSTANCE.LookupAccountName( null, accountName, null, pSid, null, pDomain, peUse)); assertEquals(W32Errors.ERROR_INSUFFICIENT_BUFFER, Kernel32.INSTANCE.GetLastError()); assertTrue(pSid.getValue() > 0); Memory sidMemory = new Memory(pSid.getValue()); PSID pSidMemory = new PSID(sidMemory); char[] referencedDomainName = new char[pDomain.getValue() + 1]; assertTrue(Advapi32.INSTANCE.LookupAccountName( null, accountName, pSidMemory, pSid, referencedDomainName, pDomain, peUse)); assertEquals(SID_NAME_USE.SidTypeUser, peUse.getPointer().getInt(0)); assertTrue(Native.toString(referencedDomainName).length() > 0); } public void testIsValidSid() { String sidString = "S-1-1-0"; // Everyone PSIDByReference sid = new PSIDByReference(); assertTrue(Advapi32.INSTANCE.ConvertStringSidToSid(sidString, sid)); assertTrue(Advapi32.INSTANCE.IsValidSid(sid.getValue())); int sidLength = Advapi32.INSTANCE.GetLengthSid(sid.getValue()); assertTrue(sidLength > 0); assertTrue(Advapi32.INSTANCE.IsValidSid(sid.getValue())); } public void testGetSidLength() { String sidString = "S-1-1-0"; // Everyone PSIDByReference sid = new PSIDByReference(); assertTrue(Advapi32.INSTANCE.ConvertStringSidToSid(sidString, sid)); assertTrue(12 == Advapi32.INSTANCE.GetLengthSid(sid.getValue())); } public void testLookupAccountSid() { // get SID bytes String sidString = "S-1-1-0"; // Everyone PSIDByReference sid = new PSIDByReference(); assertTrue(Advapi32.INSTANCE.ConvertStringSidToSid(sidString, sid)); int sidLength = Advapi32.INSTANCE.GetLengthSid(sid.getValue()); assertTrue(sidLength > 0); // lookup account IntByReference cchName = new IntByReference(); IntByReference cchReferencedDomainName = new IntByReference(); PointerByReference peUse = new PointerByReference(); assertFalse(Advapi32.INSTANCE.LookupAccountSid(null, sid.getValue(), null, cchName, null, cchReferencedDomainName, peUse)); assertEquals(W32Errors.ERROR_INSUFFICIENT_BUFFER, Kernel32.INSTANCE.GetLastError()); assertTrue(cchName.getValue() > 0); assertTrue(cchReferencedDomainName.getValue() > 0); char[] referencedDomainName = new char[cchReferencedDomainName.getValue()]; char[] name = new char[cchName.getValue()]; assertTrue(Advapi32.INSTANCE.LookupAccountSid(null, sid.getValue(), name, cchName, referencedDomainName, cchReferencedDomainName, peUse)); assertEquals(5, peUse.getPointer().getInt(0)); // SidTypeWellKnownGroup String nameString = Native.toString(name); String referencedDomainNameString = Native.toString(referencedDomainName); assertTrue(nameString.length() > 0); assertEquals("Everyone", nameString); assertTrue(referencedDomainNameString.length() == 0); assertEquals(null, Kernel32.INSTANCE.LocalFree(sid.getValue().getPointer())); } public void testConvertSid() { String sidString = "S-1-1-0"; // Everyone PSIDByReference sid = new PSIDByReference(); assertTrue(Advapi32.INSTANCE.ConvertStringSidToSid( sidString, sid)); PointerByReference convertedSidStringPtr = new PointerByReference(); assertTrue(Advapi32.INSTANCE.ConvertSidToStringSid( sid.getValue(), convertedSidStringPtr)); String convertedSidString = convertedSidStringPtr.getValue().getString(0, true); assertEquals(convertedSidString, sidString); assertEquals(null, Kernel32.INSTANCE.LocalFree(convertedSidStringPtr.getValue())); assertEquals(null, Kernel32.INSTANCE.LocalFree(sid.getValue().getPointer())); } public void testLogonUser() { HANDLEByReference phToken = new HANDLEByReference(); assertFalse(Advapi32.INSTANCE.LogonUser("AccountDoesntExist", ".", "passwordIsInvalid", WinBase.LOGON32_LOGON_NETWORK, WinBase.LOGON32_PROVIDER_DEFAULT, phToken)); assertTrue(W32Errors.ERROR_SUCCESS != Kernel32.INSTANCE.GetLastError()); } public void testOpenThreadTokenNoToken() { HANDLEByReference phToken = new HANDLEByReference(); HANDLE threadHandle = Kernel32.INSTANCE.GetCurrentThread(); assertNotNull(threadHandle); assertFalse(Advapi32.INSTANCE.OpenThreadToken(threadHandle, WinNT.TOKEN_READ, false, phToken)); assertEquals(W32Errors.ERROR_NO_TOKEN, Kernel32.INSTANCE.GetLastError()); } public void testOpenProcessToken() { HANDLEByReference phToken = new HANDLEByReference(); HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess(); assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle, WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken)); assertTrue(Kernel32.INSTANCE.CloseHandle(phToken.getValue())); } public void testOpenThreadOrProcessToken() { HANDLEByReference phToken = new HANDLEByReference(); HANDLE threadHandle = Kernel32.INSTANCE.GetCurrentThread(); if (! Advapi32.INSTANCE.OpenThreadToken(threadHandle, WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, true, phToken)) { assertEquals(W32Errors.ERROR_NO_TOKEN, Kernel32.INSTANCE.GetLastError()); HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess(); assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle, WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken)); } assertTrue(Kernel32.INSTANCE.CloseHandle(phToken.getValue())); } public void testDuplicateToken() { HANDLEByReference phToken = new HANDLEByReference(); HANDLEByReference phTokenDup = new HANDLEByReference(); HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess(); assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle, WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken)); assertTrue(Advapi32.INSTANCE.DuplicateToken(phToken.getValue(), WinNT.SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation, phTokenDup)); assertTrue(Kernel32.INSTANCE.CloseHandle(phTokenDup.getValue())); assertTrue(Kernel32.INSTANCE.CloseHandle(phToken.getValue())); } public void testGetTokenOwnerInformation() { HANDLEByReference phToken = new HANDLEByReference(); HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess(); assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle, WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken)); IntByReference tokenInformationLength = new IntByReference(); assertFalse(Advapi32.INSTANCE.GetTokenInformation(phToken.getValue(), WinNT.TOKEN_INFORMATION_CLASS.TokenOwner, null, 0, tokenInformationLength)); assertEquals(W32Errors.ERROR_INSUFFICIENT_BUFFER, Kernel32.INSTANCE.GetLastError()); Memory tokenInformationBuffer = new Memory(tokenInformationLength.getValue()); WinNT.TOKEN_OWNER owner = new WinNT.TOKEN_OWNER(tokenInformationBuffer); assertTrue(Advapi32.INSTANCE.GetTokenInformation(phToken.getValue(), WinNT.TOKEN_INFORMATION_CLASS.TokenOwner, owner, tokenInformationLength.getValue(), tokenInformationLength)); assertTrue(tokenInformationLength.getValue() > 0); assertTrue(Advapi32.INSTANCE.IsValidSid(owner.Owner)); int sidLength = Advapi32.INSTANCE.GetLengthSid(owner.Owner); assertTrue(sidLength < tokenInformationLength.getValue()); assertTrue(sidLength > 0); // System.out.println(Advapi32Util.convertSidToStringSid(owner.Owner)); assertTrue(Kernel32.INSTANCE.CloseHandle(phToken.getValue())); } public void testGetTokenUserInformation() { HANDLEByReference phToken = new HANDLEByReference(); HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess(); assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle, WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken)); IntByReference tokenInformationLength = new IntByReference(); assertFalse(Advapi32.INSTANCE.GetTokenInformation(phToken.getValue(), WinNT.TOKEN_INFORMATION_CLASS.TokenUser, null, 0, tokenInformationLength)); assertEquals(W32Errors.ERROR_INSUFFICIENT_BUFFER, Kernel32.INSTANCE.GetLastError()); WinNT.TOKEN_USER user = new WinNT.TOKEN_USER(tokenInformationLength.getValue()); assertTrue(Advapi32.INSTANCE.GetTokenInformation(phToken.getValue(), WinNT.TOKEN_INFORMATION_CLASS.TokenUser, user, tokenInformationLength.getValue(), tokenInformationLength)); assertTrue(tokenInformationLength.getValue() > 0); assertTrue(Advapi32.INSTANCE.IsValidSid(user.User.Sid)); int sidLength = Advapi32.INSTANCE.GetLengthSid(user.User.Sid); assertTrue(sidLength > 0); assertTrue(sidLength < tokenInformationLength.getValue()); // System.out.println(Advapi32Util.convertSidToStringSid(user.User.Sid)); assertTrue(Kernel32.INSTANCE.CloseHandle(phToken.getValue())); } public void testGetTokenGroupsInformation() { HANDLEByReference phToken = new HANDLEByReference(); HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess(); assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle, WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken)); IntByReference tokenInformationLength = new IntByReference(); assertFalse(Advapi32.INSTANCE.GetTokenInformation(phToken.getValue(), WinNT.TOKEN_INFORMATION_CLASS.TokenGroups, null, 0, tokenInformationLength)); assertEquals(W32Errors.ERROR_INSUFFICIENT_BUFFER, Kernel32.INSTANCE.GetLastError()); WinNT.TOKEN_GROUPS groups = new WinNT.TOKEN_GROUPS(tokenInformationLength.getValue()); assertTrue(Advapi32.INSTANCE.GetTokenInformation(phToken.getValue(), WinNT.TOKEN_INFORMATION_CLASS.TokenGroups, groups, tokenInformationLength.getValue(), tokenInformationLength)); assertTrue(tokenInformationLength.getValue() > 0); assertTrue(groups.GroupCount > 0); for (SID_AND_ATTRIBUTES sidAndAttribute : groups.getGroups()) { assertTrue(Advapi32.INSTANCE.IsValidSid(sidAndAttribute.Sid)); // System.out.println(Advapi32Util.convertSidToStringSid(sidAndAttribute.Sid)); } assertTrue(Kernel32.INSTANCE.CloseHandle(phToken.getValue())); } public void testImpersonateLoggedOnUser() { USER_INFO_1 userInfo = new USER_INFO_1(); userInfo.usri1_name = new WString("JNAAdvapi32TestImp"); userInfo.usri1_password = new WString("!JNAP$$Wrd0"); userInfo.usri1_priv = LMAccess.USER_PRIV_USER; assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null)); try { HANDLEByReference phUser = new HANDLEByReference(); try { assertTrue(Advapi32.INSTANCE.LogonUser(userInfo.usri1_name.toString(), null, userInfo.usri1_password.toString(), WinBase.LOGON32_LOGON_NETWORK, WinBase.LOGON32_PROVIDER_DEFAULT, phUser)); assertTrue(Advapi32.INSTANCE.ImpersonateLoggedOnUser(phUser.getValue())); assertTrue(Advapi32.INSTANCE.RevertToSelf()); } finally { if (phUser.getValue() != WinBase.INVALID_HANDLE_VALUE) { Kernel32.INSTANCE.CloseHandle(phUser.getValue()); } } } finally { assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserDel( null, userInfo.usri1_name.toString())); } } public void testRegOpenKeyEx() { HKEYByReference phKey = new HKEYByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegOpenKeyEx( WinReg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft", 0, WinNT.KEY_READ, phKey)); assertTrue(WinBase.INVALID_HANDLE_VALUE != phKey.getValue()); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCloseKey(phKey.getValue())); } public void testRegQueryValueEx() { HKEYByReference phKey = new HKEYByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegOpenKeyEx( WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", 0, WinNT.KEY_READ, phKey)); IntByReference lpcbData = new IntByReference(); IntByReference lpType = new IntByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegQueryValueEx( phKey.getValue(), "User Agent", 0, lpType, (char[]) null, lpcbData)); assertEquals(WinNT.REG_SZ, lpType.getValue()); assertTrue(lpcbData.getValue() > 0); char[] buffer = new char[lpcbData.getValue()]; assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegQueryValueEx( phKey.getValue(), "User Agent", 0, lpType, buffer, lpcbData)); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCloseKey(phKey.getValue())); } public void testRegDeleteValue() { assertEquals(W32Errors.ERROR_FILE_NOT_FOUND, Advapi32.INSTANCE.RegDeleteValue( WinReg.HKEY_CURRENT_USER, "JNAAdvapi32TestDoesntExist")); } public void testRegSetValueEx_REG_SZ() { HKEYByReference phKey = new HKEYByReference(); // create parent key assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegOpenKeyEx( WinReg.HKEY_CURRENT_USER, "Software", 0, WinNT.KEY_WRITE | WinNT.KEY_READ, phKey)); HKEYByReference phkTest = new HKEYByReference(); IntByReference lpdwDisposition = new IntByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCreateKeyEx( phKey.getValue(), "JNAAdvapi32Test", 0, null, 0, WinNT.KEY_ALL_ACCESS, null, phkTest, lpdwDisposition)); // write a REG_SZ value char[] lpData = Native.toCharArray("Test"); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegSetValueEx( phkTest.getValue(), "REG_SZ", 0, WinNT.REG_SZ, lpData, lpData.length * 2)); // re-read the REG_SZ value IntByReference lpType = new IntByReference(); IntByReference lpcbData = new IntByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegQueryValueEx( phkTest.getValue(), "REG_SZ", 0, lpType, (char[]) null, lpcbData)); assertEquals(WinNT.REG_SZ, lpType.getValue()); assertTrue(lpcbData.getValue() > 0); char[] buffer = new char[lpcbData.getValue()]; assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegQueryValueEx( phkTest.getValue(), "REG_SZ", 0, lpType, buffer, lpcbData)); assertEquals("Test", Native.toString(buffer)); // delete the test key assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCloseKey( phkTest.getValue())); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegDeleteKey( phKey.getValue(), "JNAAdvapi32Test")); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCloseKey(phKey.getValue())); } public void testRegSetValueEx_DWORD() { HKEYByReference phKey = new HKEYByReference(); // create parent key assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegOpenKeyEx( WinReg.HKEY_CURRENT_USER, "Software", 0, WinNT.KEY_WRITE | WinNT.KEY_READ, phKey)); HKEYByReference phkTest = new HKEYByReference(); IntByReference lpdwDisposition = new IntByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCreateKeyEx( phKey.getValue(), "JNAAdvapi32Test", 0, null, 0, WinNT.KEY_ALL_ACCESS, null, phkTest, lpdwDisposition)); // write a REG_DWORD value int value = 42145; byte[] data = new byte[4]; data[0] = (byte)(value & 0xff); data[1] = (byte)((value >> 8) & 0xff); data[2] = (byte)((value >> 16) & 0xff); data[3] = (byte)((value >> 24) & 0xff); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegSetValueEx( phkTest.getValue(), "DWORD", 0, WinNT.REG_DWORD, data, 4)); // re-read the REG_DWORD value IntByReference lpType = new IntByReference(); IntByReference lpcbData = new IntByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegQueryValueEx( phkTest.getValue(), "DWORD", 0, lpType, (char[]) null, lpcbData)); assertEquals(WinNT.REG_DWORD, lpType.getValue()); assertEquals(4, lpcbData.getValue()); IntByReference valueRead = new IntByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegQueryValueEx( phkTest.getValue(), "DWORD", 0, lpType, valueRead, lpcbData)); assertEquals(value, valueRead.getValue()); // delete the test key assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCloseKey( phkTest.getValue())); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegDeleteKey( phKey.getValue(), "JNAAdvapi32Test")); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCloseKey(phKey.getValue())); } public void testRegCreateKeyEx() { HKEYByReference phKey = new HKEYByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegOpenKeyEx( WinReg.HKEY_CURRENT_USER, "Software", 0, WinNT.KEY_WRITE | WinNT.KEY_READ, phKey)); HKEYByReference phkResult = new HKEYByReference(); IntByReference lpdwDisposition = new IntByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCreateKeyEx( phKey.getValue(), "JNAAdvapi32Test", 0, null, 0, WinNT.KEY_ALL_ACCESS, null, phkResult, lpdwDisposition)); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCloseKey(phkResult.getValue())); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegDeleteKey( phKey.getValue(), "JNAAdvapi32Test")); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCloseKey(phKey.getValue())); } public void testRegDeleteKey() { assertEquals(W32Errors.ERROR_FILE_NOT_FOUND, Advapi32.INSTANCE.RegDeleteKey( WinReg.HKEY_CURRENT_USER, "JNAAdvapi32TestDoesntExist")); } public void testRegEnumKeyEx() { HKEYByReference phKey = new HKEYByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegOpenKeyEx( WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", 0, WinNT.KEY_READ, phKey)); IntByReference lpcSubKeys = new IntByReference(); IntByReference lpcMaxSubKeyLen = new IntByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegQueryInfoKey( phKey.getValue(), null, null, null, lpcSubKeys, lpcMaxSubKeyLen, null, null, null, null, null, null)); char[] name = new char[lpcMaxSubKeyLen.getValue() + 1]; for (int i = 0; i < lpcSubKeys.getValue(); i++) { IntByReference lpcchValueName = new IntByReference(lpcMaxSubKeyLen.getValue() + 1); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegEnumKeyEx( phKey.getValue(), i, name, lpcchValueName, null, null, null, null)); assertEquals(Native.toString(name).length(), lpcchValueName.getValue()); } assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCloseKey(phKey.getValue())); } public void testRegEnumValue() { HKEYByReference phKey = new HKEYByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegOpenKeyEx( WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", 0, WinNT.KEY_READ, phKey)); IntByReference lpcValues = new IntByReference(); IntByReference lpcMaxValueNameLen = new IntByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegQueryInfoKey( phKey.getValue(), null, null, null, null, null, null, lpcValues, lpcMaxValueNameLen, null, null, null)); char[] name = new char[lpcMaxValueNameLen.getValue() + 1]; for (int i = 0; i < lpcValues.getValue(); i++) { IntByReference lpcchValueName = new IntByReference(lpcMaxValueNameLen.getValue() + 1); IntByReference lpType = new IntByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegEnumValue( phKey.getValue(), i, name, lpcchValueName, null, lpType, null, null)); assertEquals(Native.toString(name).length(), lpcchValueName.getValue()); } assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCloseKey(phKey.getValue())); } public void testRegQueryInfoKey() { IntByReference lpcClass = new IntByReference(); IntByReference lpcSubKeys = new IntByReference(); IntByReference lpcMaxSubKeyLen = new IntByReference(); IntByReference lpcValues = new IntByReference(); IntByReference lpcMaxClassLen = new IntByReference(); IntByReference lpcMaxValueNameLen = new IntByReference(); IntByReference lpcMaxValueLen = new IntByReference(); IntByReference lpcbSecurityDescriptor = new IntByReference(); FILETIME lpftLastWriteTime = new FILETIME(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegQueryInfoKey( WinReg.HKEY_LOCAL_MACHINE, null, lpcClass, null, lpcSubKeys, lpcMaxSubKeyLen, lpcMaxClassLen, lpcValues, lpcMaxValueNameLen, lpcMaxValueLen, lpcbSecurityDescriptor, lpftLastWriteTime)); assertTrue(lpcSubKeys.getValue() > 0); } public void testIsWellKnownSid() { String sidString = "S-1-1-0"; // Everyone PSIDByReference sid = new PSIDByReference(); assertTrue(Advapi32.INSTANCE.ConvertStringSidToSid(sidString, sid)); assertTrue(Advapi32.INSTANCE.IsWellKnownSid(sid.getValue(), WELL_KNOWN_SID_TYPE.WinWorldSid)); assertFalse(Advapi32.INSTANCE.IsWellKnownSid(sid.getValue(), WELL_KNOWN_SID_TYPE.WinAccountAdministratorSid)); } public void testCreateWellKnownSid() { PSID pSid = new PSID(WinNT.SECURITY_MAX_SID_SIZE); IntByReference cbSid = new IntByReference(WinNT.SECURITY_MAX_SID_SIZE); assertTrue(Advapi32.INSTANCE.CreateWellKnownSid(WELL_KNOWN_SID_TYPE.WinWorldSid, null, pSid, cbSid)); assertTrue(Advapi32.INSTANCE.IsWellKnownSid(pSid, WELL_KNOWN_SID_TYPE.WinWorldSid)); assertTrue(cbSid.getValue() <= WinNT.SECURITY_MAX_SID_SIZE); PointerByReference convertedSidStringPtr = new PointerByReference(); assertTrue(Advapi32.INSTANCE.ConvertSidToStringSid( pSid, convertedSidStringPtr)); String convertedSidString = convertedSidStringPtr.getValue().getString(0, true); assertEquals("S-1-1-0", convertedSidString); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java0000644000175000017500000003054511421126024026257 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.NativeLong; import com.sun.jna.WString; import com.sun.jna.platform.win32.DsGetDC.DS_DOMAIN_TRUSTS; import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO; import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS; import com.sun.jna.platform.win32.LMAccess.GROUP_INFO_2; import com.sun.jna.platform.win32.LMAccess.GROUP_USERS_INFO_0; import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_USERS_INFO_0; import com.sun.jna.platform.win32.LMAccess.USER_INFO_1; import com.sun.jna.platform.win32.NTSecApi.LSA_FOREST_TRUST_RECORD; import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION; import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_RECORD; import com.sun.jna.platform.win32.Netapi32Util.User; import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.NativeLongByReference; import com.sun.jna.ptr.PointerByReference; /** * @author dblock[at]dblock[dot]org */ public class Netapi32Test extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Netapi32Test.class); } public void testNetGetJoinInformation() { IntByReference bufferType = new IntByReference(); assertEquals(W32Errors.ERROR_INVALID_PARAMETER, Netapi32.INSTANCE.NetGetJoinInformation( null, null, bufferType)); PointerByReference lpNameBuffer = new PointerByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetGetJoinInformation( null, lpNameBuffer, bufferType)); assertTrue(lpNameBuffer.getValue().getString(0).length() > 0); assertTrue(bufferType.getValue() > 0); assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree( lpNameBuffer.getValue())); } public void testNetGetLocalGroups() { for(int i = 0; i < 2; i++) { PointerByReference bufptr = new PointerByReference(); IntByReference entriesRead = new IntByReference(); IntByReference totalEntries = new IntByReference(); assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetLocalGroupEnum(null, i, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null)); assertTrue(entriesRead.getValue() > 0); assertEquals(totalEntries.getValue(), entriesRead.getValue()); assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree( bufptr.getValue())); } } public void testNetGetDCName() { PointerByReference lpNameBuffer = new PointerByReference(); IntByReference BufferType = new IntByReference(); assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetGetJoinInformation(null, lpNameBuffer, BufferType)); if (BufferType.getValue() == LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName) { PointerByReference bufptr = new PointerByReference(); assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetGetDCName(null, null, bufptr)); String dc = bufptr.getValue().getString(0); assertTrue(dc.length() > 0); assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())); } assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue())); } public void testNetUserGetGroups() { User[] users = Netapi32Util.getUsers(); assertTrue(users.length >= 1); PointerByReference bufptr = new PointerByReference(); IntByReference entriesread = new IntByReference(); IntByReference totalentries = new IntByReference(); assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserGetGroups( null, users[0].name, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries)); GROUP_USERS_INFO_0 lgroup = new GROUP_USERS_INFO_0(bufptr.getValue()); GROUP_USERS_INFO_0[] lgroups = (GROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue()); for (GROUP_USERS_INFO_0 localGroupInfo : lgroups) { assertTrue(localGroupInfo.grui0_name.length() > 0); } assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())); } public void testNetUserGetLocalGroups() { String currentUser = Secur32Util.getUserNameEx( EXTENDED_NAME_FORMAT.NameSamCompatible); PointerByReference bufptr = new PointerByReference(); IntByReference entriesread = new IntByReference(); IntByReference totalentries = new IntByReference(); assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserGetLocalGroups( null, currentUser, 0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries)); LOCALGROUP_USERS_INFO_0 lgroup = new LOCALGROUP_USERS_INFO_0(bufptr.getValue()); LOCALGROUP_USERS_INFO_0[] lgroups = (LOCALGROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue()); for (LOCALGROUP_USERS_INFO_0 localGroupInfo : lgroups) { assertTrue(localGroupInfo.lgrui0_name.length() > 0); } assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())); } public void testNetGroupEnum() { PointerByReference bufptr = new PointerByReference(); IntByReference entriesread = new IntByReference(); IntByReference totalentries = new IntByReference(); assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetGroupEnum( null, 2, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries, null)); GROUP_INFO_2 group = new GROUP_INFO_2(bufptr.getValue()); GROUP_INFO_2[] groups = (GROUP_INFO_2[]) group.toArray(entriesread.getValue()); for (GROUP_INFO_2 grpi : groups) { assertTrue(grpi.grpi2_name.length() > 0); } assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())); } public void testNetUserEnum() { PointerByReference bufptr = new PointerByReference(); IntByReference entriesread = new IntByReference(); IntByReference totalentries = new IntByReference(); assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserEnum( null, 1, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries, null)); USER_INFO_1 userinfo = new USER_INFO_1(bufptr.getValue()); USER_INFO_1[] userinfos = (USER_INFO_1[]) userinfo.toArray(entriesread.getValue()); for (USER_INFO_1 ui : userinfos) { assertTrue(ui.usri1_name.length() > 0); } assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())); } public void testNetUserAdd() { USER_INFO_1 userInfo = new USER_INFO_1(); userInfo.usri1_name = new WString("JNANetapi32TestUser"); userInfo.usri1_password = new WString("!JNAP$$Wrd0"); userInfo.usri1_priv = LMAccess.USER_PRIV_USER; assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserAdd( Kernel32Util.getComputerName(), 1, userInfo, null)); assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserDel( Kernel32Util.getComputerName(), userInfo.usri1_name.toString())); } public void testNetUserChangePassword() { USER_INFO_1 userInfo = new USER_INFO_1(); userInfo.usri1_name = new WString("JNANetapi32TestUser"); userInfo.usri1_password = new WString("!JNAP$$Wrd0"); userInfo.usri1_priv = LMAccess.USER_PRIV_USER; assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserAdd( Kernel32Util.getComputerName(), 1, userInfo, null)); try { assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserChangePassword( Kernel32Util.getComputerName(), userInfo.usri1_name.toString(), userInfo.usri1_password.toString(), "!JNAP%%Wrd1")); } finally { assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserDel( Kernel32Util.getComputerName(), userInfo.usri1_name.toString())); } } public void testNetUserDel() { assertEquals(LMErr.NERR_UserNotFound, Netapi32.INSTANCE.NetUserDel( Kernel32Util.getComputerName(), "JNANetapi32TestUserDoesntExist")); } public void testDsGetDcName() { if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName) return; PDOMAIN_CONTROLLER_INFO.ByReference pdci = new PDOMAIN_CONTROLLER_INFO.ByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.DsGetDcName( null, null, null, null, 0, pdci)); assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree( pdci.getPointer())); } public void testDsGetForestTrustInformation() { if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName) return; String domainController = Netapi32Util.getDCName(); PLSA_FOREST_TRUST_INFORMATION.ByReference pfti = new PLSA_FOREST_TRUST_INFORMATION.ByReference(); assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsGetForestTrustInformation( domainController, null, 0, pfti)); assertTrue(pfti.fti.RecordCount.intValue() >= 0); for (PLSA_FOREST_TRUST_RECORD precord : pfti.fti.getEntries()) { LSA_FOREST_TRUST_RECORD.UNION data = precord.tr.u; switch(precord.tr.ForestTrustType) { case NTSecApi.ForestTrustTopLevelName: case NTSecApi.ForestTrustTopLevelNameEx: assertTrue(data.TopLevelName.Length > 0); assertTrue(data.TopLevelName.MaximumLength > 0); assertTrue(data.TopLevelName.MaximumLength >= data.TopLevelName.Length); assertTrue(data.TopLevelName.getString().length() > 0); break; case NTSecApi.ForestTrustDomainInfo: assertTrue(data.DomainInfo.DnsName.Length > 0); assertTrue(data.DomainInfo.DnsName.MaximumLength > 0); assertTrue(data.DomainInfo.DnsName.MaximumLength >= data.DomainInfo.DnsName.Length); assertTrue(data.DomainInfo.DnsName.getString().length() > 0); assertTrue(data.DomainInfo.NetbiosName.Length > 0); assertTrue(data.DomainInfo.NetbiosName.MaximumLength > 0); assertTrue(data.DomainInfo.NetbiosName.MaximumLength >= data.DomainInfo.NetbiosName.Length); assertTrue(data.DomainInfo.NetbiosName.getString().length() > 0); assertTrue(Advapi32.INSTANCE.IsValidSid(data.DomainInfo.Sid)); assertTrue(Advapi32Util.convertSidToStringSid(data.DomainInfo.Sid).startsWith("S-")); break; } } assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree( pfti.getPointer())); } public void testDsEnumerateDomainTrusts() { if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName) return; NativeLongByReference domainCount = new NativeLongByReference(); PDS_DOMAIN_TRUSTS.ByReference domains = new PDS_DOMAIN_TRUSTS.ByReference(); assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsEnumerateDomainTrusts( null, new NativeLong(DsGetDC.DS_DOMAIN_VALID_FLAGS), domains, domainCount)); assertTrue(domainCount.getValue().intValue() >= 0); DS_DOMAIN_TRUSTS[] trusts = domains.getTrusts(domainCount.getValue().intValue()); for(DS_DOMAIN_TRUSTS trust : trusts) { assertTrue(trust.NetbiosDomainName.length() > 0); assertTrue(trust.DnsDomainName.length() > 0); assertTrue(Advapi32.INSTANCE.IsValidSid(trust.DomainSid)); assertTrue(Advapi32Util.convertSidToStringSid(trust.DomainSid).startsWith("S-")); assertTrue(Ole32Util.getStringFromGUID(trust.DomainGuid).startsWith("{")); } assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree( domains.getPointer())); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java0000644000175000017500000000202711421126024025747 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; /** * @author dblock[at]dblock[dot]org */ public class User32Test extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(User32Test.class); } public void testGetSystemMetrics() { int cursorWidth = User32.INSTANCE.GetSystemMetrics(WinUser.SM_CXCURSOR); assertTrue(cursorWidth > 0); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Shell32Test.java0000644000175000017500000000356111421126024026104 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.ptr.PointerByReference; /** * @author dblock[at]dblock[dot]org */ public class Shell32Test extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Shell32Test.class); } public void testStructurePacking() { Structure s = new ShellAPI.SHFILEOPSTRUCT(); final int SIZE = Pointer.SIZE * 5 + 10; // 5 pointers, 2 ints, 1 short assertEquals("Wrong structure size", SIZE, s.size()); } public void testSHGetFolderPath() { char[] pszPath = new char[WinDef.MAX_PATH]; assertEquals(W32Errors.S_OK, Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_PROGRAM_FILES, null, ShlObj.SHGFP_TYPE_CURRENT, pszPath)); assertTrue(Native.toString(pszPath).length() > 0); } public void testSHGetDesktopFolder() { PointerByReference ppshf = new PointerByReference(); WinNT.HRESULT hr = Shell32.INSTANCE.SHGetDesktopFolder(ppshf); assertTrue(W32Errors.SUCCEEDED(hr.intValue())); assertTrue(ppshf.getValue() != null); // should release the interface, but we need Com4JNA to do that. } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Netapi32UtilTest.java0000644000175000017500000001343011421126024027107 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.platform.win32.Netapi32Util.DomainController; import com.sun.jna.platform.win32.Netapi32Util.DomainTrust; /** * @author dblock[at]dblock[dot]org */ public class Netapi32UtilTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Netapi32UtilTest.class); System.out.println("Domain: " + Netapi32Util.getDomainName("localhost")); // server local groups Netapi32Util.LocalGroup[] localGroups = Netapi32Util.getLocalGroups(); System.out.println("Local groups: " + localGroups.length); for(Netapi32Util.LocalGroup localGroup : localGroups) { System.out.println(" " + localGroup.name + " (" + localGroup.comment + ")"); } // global groups Netapi32Util.Group[] groups = Netapi32Util.getGlobalGroups(); System.out.println("Global groups: " + groups.length); for(Netapi32Util.Group group : groups) { System.out.println(" " + group.name); } // server users Netapi32Util.User[] users = Netapi32Util.getUsers(); System.out.println("Users: " + users.length); for(Netapi32Util.User user : users) { System.out.println(" " + user.name); } // user local groups Netapi32Util.Group[] userLocalGroups = Netapi32Util.getCurrentUserLocalGroups(); System.out.println("Local user groups: " + userLocalGroups.length); for(Netapi32Util.Group localGroup : userLocalGroups) { System.out.println(" " + localGroup.name); } // domain controller if (Netapi32Util.getJoinStatus() == LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName) { System.out.println("Pdc: " + Netapi32Util.getDCName()); DomainController dc = Netapi32Util.getDC(); System.out.println("Domain controller:"); System.out.println(" name: " + dc.name); System.out.println(" address: " + dc.address); System.out.println(" domain: " + dc.domainName); System.out.println(" site: " + dc.clientSiteName); System.out.println(" forest: " + dc.dnsForestName); System.out.println(" guid: " + Ole32Util.getStringFromGUID(dc.domainGuid)); } // domain trusts if (Netapi32Util.getJoinStatus() == LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName) { DomainTrust[] trusts = Netapi32Util.getDomainTrusts(); System.out.println("Domain trusts: (" + trusts.length + ")"); for(DomainTrust trust : trusts) { System.out.println(" " + trust.NetbiosDomainName + ": " + trust.DnsDomainName + " (" + trust.DomainSidString + ")"); } } } public void testGetDomain() { String computerName = System.getenv("COMPUTERNAME"); String domain = Netapi32Util.getDomainName(computerName); assertTrue(domain.length() > 0); } public void testGetLocalGroups() { Netapi32Util.LocalGroup[] localGroups = Netapi32Util.getLocalGroups(); assertNotNull(localGroups); for(Netapi32Util.LocalGroup localGroup : localGroups) { assertTrue(localGroup.name.length() > 0); } assertTrue(localGroups.length > 0); } public void testGetUsers() { Netapi32Util.User[] users = Netapi32Util.getUsers(); assertNotNull(users); for(Netapi32Util.User user : users) { assertTrue(user.name.length() > 0); } assertTrue(users.length > 0); } public void testGetGlobalGroups() { Netapi32Util.Group[] groups = Netapi32Util.getGlobalGroups(); assertNotNull(groups); for(Netapi32Util.Group group : groups) { assertTrue(group.name.length() > 0); } assertTrue(groups.length > 0); } public void testGetCurrentUserLocalGroups() { Netapi32Util.Group[] localGroups = Netapi32Util.getCurrentUserLocalGroups(); assertNotNull(localGroups); for(Netapi32Util.Group localGroup : localGroups) { assertTrue(localGroup.name.length() > 0); } assertTrue(localGroups.length > 0); } public void testGetJoinStatus() { int joinStatus = Netapi32Util.getJoinStatus(); assertTrue(joinStatus == LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName || joinStatus == LMJoin.NETSETUP_JOIN_STATUS.NetSetupUnjoined || joinStatus == LMJoin.NETSETUP_JOIN_STATUS.NetSetupWorkgroupName); } public void testGetDCName() { if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName) return; String domainController = Netapi32Util.getDCName(); assertTrue(domainController.length() > 0); assertTrue(domainController.startsWith("\\\\")); } public void testGetDC() { if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName) return; DomainController dc = Netapi32Util.getDC(); assertTrue(dc.address.startsWith("\\\\")); assertTrue(dc.domainName.length() > 0); } public void testGetDomainTrusts() { if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName) return; DomainTrust[] trusts = Netapi32Util.getDomainTrusts(); assertTrue(trusts.length >= 0); for(DomainTrust trust : trusts) { assertTrue(trust.NetbiosDomainName.length() > 0); assertTrue(trust.DnsDomainName.length() > 0); assertTrue(Advapi32.INSTANCE.IsValidSid(trust.DomainSid)); assertTrue(trust.isInbound() || trust.isOutbound() || trust.isPrimary()); } } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/NtDllUtilTest.java0000644000175000017500000000254511421126024026544 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.platform.win32.WinReg.HKEYByReference; /** * @author dblock[at]dblock[dot]org */ public class NtDllUtilTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(NtDllUtilTest.class); } public void testGetKeyName() { HKEYByReference phKey = new HKEYByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegOpenKeyEx( WinReg.HKEY_CURRENT_USER, "Software", 0, WinNT.KEY_WRITE | WinNT.KEY_READ, phKey)); assertEquals("Software", NtDllUtil.getKeyName(phKey.getValue())); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCloseKey(phKey.getValue())); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Ole32Test.java0000644000175000017500000000754711421126024025564 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.Guid.GUID; import com.sun.jna.platform.win32.WinNT.HRESULT; import com.sun.jna.ptr.PointerByReference; /** * @author dblock[at]dblock[dot]org */ public class Ole32Test extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Ole32Test.class); } public void testCoCreateGUID() { GUID.ByReference pguid = new GUID.ByReference(); assertEquals(W32Errors.S_OK, Ole32.INSTANCE.CoCreateGuid(pguid)); assertTrue(pguid.Data1 != 0 || pguid.Data2 != 0 || pguid.Data3 != 0 && pguid.Data4 != null); } public void testIIDFromString() { GUID.ByReference lpiid = new GUID.ByReference(); assertEquals(W32Errors.S_OK, Ole32.INSTANCE.IIDFromString( "{13709620-C279-11CE-A49E-444553540000}", lpiid)); // Shell.Application.1 assertEquals(0x13709620, lpiid.Data1); assertEquals(0xFFFFC279, lpiid.Data2); assertEquals(0x11CE, lpiid.Data3); assertEquals(0xFFFFFFA4, lpiid.Data4[0]); assertEquals(0xFFFFFF9E, lpiid.Data4[1]); assertEquals(0x44, lpiid.Data4[2]); assertEquals(0x45, lpiid.Data4[3]); assertEquals(0x53, lpiid.Data4[4]); assertEquals(0x54, lpiid.Data4[5]); assertEquals(0, lpiid.Data4[6]); assertEquals(0, lpiid.Data4[7]); } public void testStringFromGUID2() { GUID.ByReference pguid = new GUID.ByReference(); pguid.Data1 = 0; pguid.Data2 = 0; pguid.Data3 = 0; for (int i = 0; i < pguid.Data4.length; i++) { pguid.Data4[i] = 0; } int max = 39; char[] lpsz = new char[max]; int len = Ole32.INSTANCE.StringFromGUID2(pguid, lpsz, max); assertTrue(len > 1); lpsz[len - 1] = 0; assertEquals("{00000000-0000-0000-0000-000000000000}", Native.toString(lpsz)); } public void testCoInitializeEx() { HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, 0); assertTrue(W32Errors.SUCCEEDED(hr.intValue()) || hr.intValue() == W32Errors.RPC_E_CHANGED_MODE); if (W32Errors.SUCCEEDED(hr.intValue())) Ole32.INSTANCE.CoUninitialize(); } public void testCoCreateInstance() { HRESULT hrCI = Ole32.INSTANCE.CoInitializeEx(null, 0); GUID guid = Ole32Util.getGUIDFromString("{13709620-C279-11CE-A49E-444553540000}"); //Shell object GUID riid = Ole32Util.getGUIDFromString("{D8F015C0-C278-11CE-A49E-444553540000}"); //IShellDispatch PointerByReference iUnknown = new PointerByReference(); HRESULT hr = Ole32.INSTANCE.CoCreateInstance( guid, null, // pOuter = null, no aggregation ObjBase.CLSCTX_ALL, riid, iUnknown); assertTrue(W32Errors.SUCCEEDED(hr.intValue())); assertTrue(!iUnknown.getValue().equals(Pointer.NULL)); // We leak this iUnknown reference because we don't have the JNACOM lib // here to wrap the native iUnknown pointer and call iUnknown.release() if (W32Errors.SUCCEEDED(hrCI.intValue())) Ole32.INSTANCE.CoUninitialize(); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Crypt32UtilTest.java0000644000175000017500000000352211421126024026771 0ustar janjan/* Copyright (c) Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.Native; /** * @author dblock[at]dblock[dot]org */ public class Crypt32UtilTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Crypt32UtilTest.class); } public void testCryptProtectUnprotectData() { byte[] data = new byte[2]; data[0] = 42; data[1] = 12; byte[] protectedData = Crypt32Util.cryptProtectData(data); byte[] unprotectedData = Crypt32Util.cryptUnprotectData(protectedData); assertEquals(data.length, unprotectedData.length); assertEquals(data[0], unprotectedData[0]); assertEquals(data[1], unprotectedData[1]); } public void testCryptProtectUnprotectMachineKey() { String s = "Hello World"; byte[] data = Native.toByteArray(s); byte[] protectedData = Crypt32Util.cryptProtectData(data, WinCrypt.CRYPTPROTECT_LOCAL_MACHINE | WinCrypt.CRYPTPROTECT_UI_FORBIDDEN); byte[] unprotectedData = Crypt32Util.cryptUnprotectData(protectedData, WinCrypt.CRYPTPROTECT_LOCAL_MACHINE); String unprotectedString = Native.toString(unprotectedData); assertEquals(s, unprotectedString); } }libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Crypt32Test.java0000644000175000017500000000566011421126024026140 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB; import com.sun.jna.ptr.PointerByReference; /** * @author dblock[at]dblock[dot]org */ public class Crypt32Test extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Crypt32Test.class); } public void testCryptProtectUnprotectData() { DATA_BLOB pDataIn = new DATA_BLOB("hello world"); DATA_BLOB pDataEncrypted = new DATA_BLOB(); assertTrue(Crypt32.INSTANCE.CryptProtectData(pDataIn, "description", null, null, null, 0, pDataEncrypted)); PointerByReference pDescription = new PointerByReference(); DATA_BLOB pDataDecrypted = new DATA_BLOB(); assertTrue(Crypt32.INSTANCE.CryptUnprotectData(pDataEncrypted, pDescription, null, null, null, 0, pDataDecrypted)); assertEquals("description", pDescription.getValue().getString(0, true)); assertEquals("hello world", pDataDecrypted.pbData.getString(0)); Kernel32.INSTANCE.LocalFree(pDataEncrypted.pbData); Kernel32.INSTANCE.LocalFree(pDataDecrypted.pbData); Kernel32.INSTANCE.LocalFree(pDescription.getValue()); } public void testCryptProtectUnprotectDataWithEntropy() { DATA_BLOB pDataIn = new DATA_BLOB("hello world"); DATA_BLOB pDataEncrypted = new DATA_BLOB(); DATA_BLOB pEntropy = new DATA_BLOB("entropy"); assertTrue(Crypt32.INSTANCE.CryptProtectData(pDataIn, "description", pEntropy, null, null, 0, pDataEncrypted)); PointerByReference pDescription = new PointerByReference(); DATA_BLOB pDataDecrypted = new DATA_BLOB(); // can't decrypt without entropy assertFalse(Crypt32.INSTANCE.CryptUnprotectData(pDataEncrypted, pDescription, null, null, null, 0, pDataDecrypted)); // decrypt with entropy assertTrue(Crypt32.INSTANCE.CryptUnprotectData(pDataEncrypted, pDescription, pEntropy, null, null, 0, pDataDecrypted)); assertEquals("description", pDescription.getValue().getString(0, true)); assertEquals("hello world", pDataDecrypted.pbData.getString(0)); Kernel32.INSTANCE.LocalFree(pDataEncrypted.pbData); Kernel32.INSTANCE.LocalFree(pDataDecrypted.pbData); Kernel32.INSTANCE.LocalFree(pDescription.getValue()); } }libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/WinspoolUtilTest.java0000644000175000017500000000233111421126024027332 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.platform.win32.Winspool.PRINTER_INFO_1; import junit.framework.TestCase; /** * @author dblock[at]dblock[dot]org */ public class WinspoolUtilTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Shell32UtilTest.class); for(PRINTER_INFO_1 printerInfo : WinspoolUtil.getPrinterInfo1()) { System.out.println(printerInfo.pName + ": " + printerInfo.pDescription); } } public void testGetFolderPath() { assertTrue(WinspoolUtil.getPrinterInfo1().length > 0); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/WinspoolTest.java0000644000175000017500000000355211421126024026502 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.platform.win32.Winspool.PRINTER_INFO_1; import com.sun.jna.ptr.IntByReference; /** * @author dblock[at]dblock[dot]org */ public class WinspoolTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(WinspoolTest.class); } public void testEnumPrinters_1() { IntByReference pcbNeeded = new IntByReference(); IntByReference pcReturned = new IntByReference(); assertFalse(Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL, null, 1, null, 0, pcbNeeded, pcReturned)); assertTrue(pcbNeeded.getValue() > 0); PRINTER_INFO_1 pPrinterEnum = new PRINTER_INFO_1(pcbNeeded.getValue()); assertTrue(pcbNeeded.getValue() > 0); assertTrue(pcReturned.getValue() == 0); assertTrue(Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL, null, 1, pPrinterEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded, pcReturned)); assertTrue(pcReturned.getValue() > 0); PRINTER_INFO_1[] printerInfo = (PRINTER_INFO_1[]) pPrinterEnum.toArray(pcReturned.getValue()); for(PRINTER_INFO_1 pi : printerInfo) { // System.out.println(pi.pName); } } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Secur32UtilTest.java0000644000175000017500000000343611421126024026755 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT; import com.sun.jna.platform.win32.Secur32Util.SecurityPackage; /** * @author dblock[at]dblock[dot]org */ public class Secur32UtilTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Secur32UtilTest.class); System.out.println("Current user: " + Secur32Util.getUserNameEx( EXTENDED_NAME_FORMAT.NameSamCompatible)); System.out.println("Security packages:"); for(SecurityPackage sp : Secur32Util.getSecurityPackages()) { System.out.println(" " + sp.name + ": " + sp.comment); } } public void testGetUsernameEx() { String usernameSamCompatible = Secur32Util.getUserNameEx( EXTENDED_NAME_FORMAT.NameSamCompatible); assertTrue(usernameSamCompatible.length() > 1); assertTrue(usernameSamCompatible.indexOf('\\') > 0); } public void testGetSecurityPackages() { SecurityPackage[] sps = Secur32Util.getSecurityPackages(); for(SecurityPackage sp : sps) { assertTrue(sp.name.length() > 0); assertTrue(sp.comment.length() >= 0); } } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Oleaut32Test.java0000644000175000017500000000243211421126024026262 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.Pointer; /** * @author dblock[at]dblock[dot]org */ public class Oleaut32Test extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Oleaut32Test.class); } public void testSysAllocString() { assertEquals(null, Oleaut32.INSTANCE.SysAllocString(null)); Pointer p = Oleaut32.INSTANCE.SysAllocString("hello world"); assertEquals("hello world", p.getString(0, true)); Oleaut32.INSTANCE.SysFreeString(p); } public void testSysFreeString() { Oleaut32.INSTANCE.SysFreeString(null); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/NtDllTest.java0000644000175000017500000000426511421126024025707 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.platform.win32.Wdm.KEY_BASIC_INFORMATION; import com.sun.jna.platform.win32.Wdm.KEY_INFORMATION_CLASS; import com.sun.jna.platform.win32.WinReg.HKEYByReference; import com.sun.jna.ptr.IntByReference; /** * @author dblock[at]dblock[dot]org */ public class NtDllTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(NtDllTest.class); } public void testZwQueryKey() { // open a key HKEYByReference phKey = new HKEYByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegOpenKeyEx( WinReg.HKEY_CURRENT_USER, "Software", 0, WinNT.KEY_WRITE | WinNT.KEY_READ, phKey)); // query key info IntByReference resultLength = new IntByReference(); assertEquals(NTStatus.STATUS_BUFFER_TOO_SMALL, NtDll.INSTANCE.ZwQueryKey( phKey.getValue(), KEY_INFORMATION_CLASS.KeyBasicInformation, null, 0, resultLength)); assertTrue(resultLength.getValue() > 0); KEY_BASIC_INFORMATION keyInformation = new KEY_BASIC_INFORMATION(resultLength.getValue()); assertEquals(NTStatus.STATUS_SUCCESS, NtDll.INSTANCE.ZwQueryKey( phKey.getValue(), Wdm.KEY_INFORMATION_CLASS.KeyBasicInformation, keyInformation, resultLength.getValue(), resultLength)); // show assertEquals("Software", keyInformation.getName()); // close key assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegCloseKey(phKey.getValue())); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Kernel32UtilTest.java0000644000175000017500000001030611421126024027106 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER; import junit.framework.TestCase; /** * @author dblock[at]dblock[dot]org */ public class Kernel32UtilTest extends TestCase { public static void main(String[] args) throws Exception { System.out.println("Computer name: " + Kernel32Util.getComputerName()); System.out.println("Temp path: " + Kernel32Util.getTempPath()); // logical drives System.out.println("Logical drives: "); String[] logicalDrives = Kernel32Util.getLogicalDriveStrings(); for(String logicalDrive : logicalDrives) { // drive type System.out.println(" " + logicalDrive + " (" + Kernel32.INSTANCE.GetDriveType(logicalDrive) + ")"); // free space LARGE_INTEGER.ByReference lpFreeBytesAvailable = new LARGE_INTEGER.ByReference(); LARGE_INTEGER.ByReference lpTotalNumberOfBytes = new LARGE_INTEGER.ByReference(); LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes = new LARGE_INTEGER.ByReference(); if (Kernel32.INSTANCE.GetDiskFreeSpaceEx(logicalDrive, lpFreeBytesAvailable, lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes)) { System.out.println(" Total: " + formatBytes(lpTotalNumberOfBytes.getValue())); System.out.println(" Free: " + formatBytes(lpTotalNumberOfFreeBytes.getValue())); } } junit.textui.TestRunner.run(Kernel32UtilTest.class); } /** * Format bytes. * @param bytes * Bytes. * @return * Rounded string representation of the byte size. */ private static String formatBytes(long bytes) { if (bytes == 1) { // bytes return String.format("%d byte", bytes); } else if (bytes < 1024) { // bytes return String.format("%d bytes", bytes); } else if (bytes < 1048576 && bytes % 1024 == 0) { // Kb return String.format("%.0f KB", (double) bytes / 1024); } else if (bytes < 1048576) { // Kb return String.format("%.1f KB", (double) bytes / 1024); } else if (bytes % 1048576 == 0 && bytes < 1073741824) { // Mb return String.format("%.0f MB", (double) bytes / 1048576); } else if (bytes < 1073741824) { // Mb return String.format("%.1f MB", (double) bytes / 1048576); } else if (bytes % 1073741824 == 0 && bytes < 1099511627776L) { // GB return String.format("%.0f GB", (double) bytes / 1073741824); } else if (bytes < 1099511627776L ) { return String.format("%.1f GB", (double) bytes / 1073741824); } else if (bytes % 1099511627776L == 0 && bytes < 1125899906842624L) { // TB return String.format("%.0f TB", (double) bytes / 1099511627776L); } else if (bytes < 1125899906842624L ) { return String.format("%.1f TB", (double) bytes / 1099511627776L); } else { return String.format("%d bytes", bytes); } } public void testGetComputerName() { assertTrue(Kernel32Util.getComputerName().length() > 0); } public void testFormatMessageFromLastErrorCode() { assertEquals("The remote server has been paused or is in the process of being started.", Kernel32Util.formatMessageFromLastErrorCode(W32Errors.ERROR_SHARING_PAUSED)); } public void testFormatMessageFromHR() { assertEquals("The operation completed successfully.", Kernel32Util.formatMessageFromHR(W32Errors.S_OK)); } public void testGetTempPath() { assertTrue(Kernel32Util.getTempPath().length() > 0); } public void testGetLogicalDriveStrings() { String[] logicalDrives = Kernel32Util.getLogicalDriveStrings(); assertTrue(logicalDrives.length > 0); for(String logicalDrive : logicalDrives) { assertTrue(logicalDrive.length() > 0); } } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Advapi32UtilTest.java0000644000175000017500000002617611421126024027106 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import java.util.TreeMap; import junit.framework.TestCase; import com.sun.jna.WString; import com.sun.jna.platform.win32.Advapi32Util.Account; import com.sun.jna.platform.win32.LMAccess.USER_INFO_1; import com.sun.jna.platform.win32.WinNT.HANDLEByReference; import com.sun.jna.platform.win32.WinNT.PSID; import com.sun.jna.platform.win32.WinNT.SID_NAME_USE; import com.sun.jna.platform.win32.WinNT.WELL_KNOWN_SID_TYPE; /** * @author dblock[at]dblock[dot]org */ public class Advapi32UtilTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Advapi32UtilTest.class); String currentUserName = Advapi32Util.getUserName(); System.out.println("GetUserName: " + currentUserName); for(Account group : Advapi32Util.getCurrentUserGroups()) { System.out.println(" " + group.fqn + " [" + group.sidString + "]"); } Account accountByName = Advapi32Util.getAccountByName(currentUserName); System.out.println("AccountByName: " + currentUserName); System.out.println(" Fqn: " + accountByName.fqn); System.out.println(" Domain: " + accountByName.domain); System.out.println(" Sid: " + accountByName.sidString); Account accountBySid = Advapi32Util.getAccountBySid(new PSID(accountByName.sid)); System.out.println("AccountBySid: " + accountByName.sidString); System.out.println(" Fqn: " + accountBySid.fqn); System.out.println(" Name: " + accountBySid.name); System.out.println(" Domain: " + accountBySid.domain); } public void testGetUsername() { String username = Advapi32Util.getUserName(); assertTrue(username.length() > 0); } public void testGetAccountBySid() { String accountName = Advapi32Util.getUserName(); Account currentUser = Advapi32Util.getAccountByName(accountName); Account account = Advapi32Util.getAccountBySid(new PSID(currentUser.sid)); assertEquals(SID_NAME_USE.SidTypeUser, account.accountType); assertEquals(currentUser.fqn.toLowerCase(), account.fqn.toLowerCase()); assertEquals(currentUser.name.toLowerCase(), account.name.toLowerCase()); assertEquals(currentUser.domain.toLowerCase(), account.domain.toLowerCase()); assertEquals(currentUser.sidString, account.sidString); } public void testGetAccountByName() { String accountName = Advapi32Util.getUserName(); Account account = Advapi32Util.getAccountByName(accountName); assertEquals(SID_NAME_USE.SidTypeUser, account.accountType); } public void testGetAccountNameFromSid() { assertEquals("Everyone", Advapi32Util.getAccountBySid("S-1-1-0").name); } public void testGetAccountSidFromName() { assertEquals("S-1-1-0", Advapi32Util.getAccountByName("Everyone").sidString); } public void testConvertSid() { String sidString = "S-1-1-0"; // Everyone byte[] sidBytes = Advapi32Util.convertStringSidToSid(sidString); assertTrue(sidBytes.length > 0); String convertedSidString = Advapi32Util.convertSidToStringSid(new PSID(sidBytes)); assertEquals(convertedSidString, sidString); } public void testGetCurrentUserGroups() { Account[] groups = Advapi32Util.getCurrentUserGroups(); assertTrue(groups.length > 0); for(Account group : groups) { assertTrue(group.name.length() > 0); assertTrue(group.sidString.length() > 0); assertTrue(group.sid.length > 0); } } public void testGetUserGroups() { USER_INFO_1 userInfo = new USER_INFO_1(); userInfo.usri1_name = new WString("JNANetapi32TestUser"); userInfo.usri1_password = new WString("!JNAP$$Wrd0"); userInfo.usri1_priv = LMAccess.USER_PRIV_USER; try { assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserAdd( null, 1, userInfo, null)); HANDLEByReference phUser = new HANDLEByReference(); try { assertTrue(Advapi32.INSTANCE.LogonUser(userInfo.usri1_name.toString(), null, userInfo.usri1_password.toString(), WinBase.LOGON32_LOGON_NETWORK, WinBase.LOGON32_PROVIDER_DEFAULT, phUser)); Account[] groups = Advapi32Util.getTokenGroups(phUser.getValue()); assertTrue(groups.length > 0); for(Account group : groups) { assertTrue(group.name.length() > 0); assertTrue(group.sidString.length() > 0); assertTrue(group.sid.length > 0); } } finally { if (phUser.getValue() != WinBase.INVALID_HANDLE_VALUE) { Kernel32.INSTANCE.CloseHandle(phUser.getValue()); } } } finally { assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserDel( null, userInfo.usri1_name.toString())); } } public void testGetUserAccount() { USER_INFO_1 userInfo = new USER_INFO_1(); userInfo.usri1_name = new WString("JNANetapi32TestUser"); userInfo.usri1_password = new WString("!JNAP$$Wrd0"); userInfo.usri1_priv = LMAccess.USER_PRIV_USER; try { assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserAdd( null, 1, userInfo, null)); HANDLEByReference phUser = new HANDLEByReference(); try { assertTrue(Advapi32.INSTANCE.LogonUser(userInfo.usri1_name.toString(), null, userInfo.usri1_password.toString(), WinBase.LOGON32_LOGON_NETWORK, WinBase.LOGON32_PROVIDER_DEFAULT, phUser)); Advapi32Util.Account account = Advapi32Util.getTokenAccount(phUser.getValue()); assertTrue(account.name.length() > 0); assertEquals(userInfo.usri1_name.toString(), account.name); } finally { if (phUser.getValue() != WinBase.INVALID_HANDLE_VALUE) { Kernel32.INSTANCE.CloseHandle(phUser.getValue()); } } } finally { assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserDel( null, userInfo.usri1_name.toString())); } } public void testRegistryKeyExists() { assertTrue(Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, "")); assertTrue(Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, "Software\\Microsoft")); assertFalse(Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, "KeyDoesNotExist\\SubKeyDoesNotExist")); } public void testRegistryValueExists() { assertFalse(Advapi32Util.registryValueExists(WinReg.HKEY_LOCAL_MACHINE, "Software\\Microsoft", "")); assertFalse(Advapi32Util.registryValueExists(WinReg.HKEY_LOCAL_MACHINE, "Software\\Microsoft", "KeyDoesNotExist")); assertTrue(Advapi32Util.registryValueExists(WinReg.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control", "SystemBootDevice")); } public void testRegistryCreateDeleteKey() { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); assertTrue(Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER, "Software\\JNA")); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); assertFalse(Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER, "Software\\JNA")); } public void testRegistryDeleteValue() { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "IntValue", 42); assertTrue(Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "IntValue")); Advapi32Util.registryDeleteValue(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "IntValue"); assertFalse(Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "IntValue")); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); } public void testRegistrySetGetIntValue() { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "IntValue", 42); assertEquals(42, Advapi32Util.registryGetIntValue(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "IntValue")); assertTrue(Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "IntValue")); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); } public void testRegistrySetGetStringValue() { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); Advapi32Util.registrySetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "StringValue", "Hello World"); assertEquals("Hello World", Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "StringValue")); assertTrue(Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "StringValue")); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); } public void testRegistryGetKeys() { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "Key1"); Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "Key2"); String[] subKeys = Advapi32Util.registryGetKeys(WinReg.HKEY_CURRENT_USER, "Software\\JNA"); assertEquals(2, subKeys.length); assertEquals(subKeys[0], "Key1"); assertEquals(subKeys[1], "Key2"); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "Key1"); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "Key2"); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); } public void testRegistryGetValues() { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "FourtyTwo", 42); Advapi32Util.registrySetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "42", "FourtyTwo"); TreeMap values = Advapi32Util.registryGetValues(WinReg.HKEY_CURRENT_USER, "Software\\JNA"); assertEquals(2, values.keySet().size()); assertEquals("FourtyTwo", values.get("42")); assertEquals(42, values.get("FourtyTwo")); Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA"); } public void testIsWellKnownSid() { String everyoneString = "S-1-1-0"; assertTrue(Advapi32Util.isWellKnownSid(everyoneString, WELL_KNOWN_SID_TYPE.WinWorldSid)); assertFalse(Advapi32Util.isWellKnownSid(everyoneString, WELL_KNOWN_SID_TYPE.WinAccountAdministratorSid)); byte[] everyoneBytes = Advapi32Util.convertStringSidToSid(everyoneString); assertTrue(Advapi32Util.isWellKnownSid(everyoneBytes, WELL_KNOWN_SID_TYPE.WinWorldSid)); assertFalse(Advapi32Util.isWellKnownSid(everyoneBytes, WELL_KNOWN_SID_TYPE.WinAccountAdministratorSid)); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/GDI32Test.java0000644000175000017500000000252411421404146025442 0ustar janjan/* Copyright (c) 2010 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. * * 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 junit.framework.TestCase; import com.sun.jna.*; import com.sun.jna.platform.win32.WinGDI.BITMAPINFO; import com.sun.jna.platform.win32.WinGDI.RGBQUAD; /** * @author twalljava[at]dev[dot]java[dot]net */ public class GDI32Test extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(GDI32Test.class); } public void testBITMAPINFO() { BITMAPINFO info = new BITMAPINFO(); assertEquals("Wrong size for BITMAPINFO()", 44, info.size()); info = new BITMAPINFO(2); assertEquals("Wrong size for BITMAPINFO(2)", 48, info.size()); info = new BITMAPINFO(16); assertEquals("Wrong size for BITMAPINFO(16)", 104, info.size()); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Ole32UtilTest.java0000644000175000017500000000441311421126024026407 0ustar janjan/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; import junit.framework.TestCase; import com.sun.jna.platform.win32.Guid.GUID; /** * @author dblock[at]dblock[dot]org */ public class Ole32UtilTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(Ole32UtilTest.class); } public void testGenerateGUID() { GUID guid1 = Ole32Util.generateGUID(); GUID guid2 = Ole32Util.generateGUID(); assertTrue(guid1 != guid2); assertTrue(Ole32Util.getStringFromGUID(guid1) != Ole32Util.getStringFromGUID(guid2)); } public void testGetStringFromGUID() { assertEquals("{00000000-0000-0000-0000-000000000000}", Ole32Util.getStringFromGUID( new GUID())); assertFalse("{00000000-0000-0000-0000-000000000000}" == Ole32Util.getStringFromGUID( Ole32Util.generateGUID())); } public void testGetGUIDFromString() { GUID lpiid = Ole32Util.getGUIDFromString("{13709620-C279-11CE-A49E-444553540000}"); assertEquals(0x13709620, lpiid.Data1); assertEquals(0xFFFFC279, lpiid.Data2); assertEquals(0x11CE, lpiid.Data3); assertEquals(0xFFFFFFA4, lpiid.Data4[0]); assertEquals(0xFFFFFF9E, lpiid.Data4[1]); assertEquals(0x44, lpiid.Data4[2]); assertEquals(0x45, lpiid.Data4[3]); assertEquals(0x53, lpiid.Data4[4]); assertEquals(0x54, lpiid.Data4[5]); assertEquals(0, lpiid.Data4[6]); assertEquals(0, lpiid.Data4[7]); } public void testGetGUIDToFromString() { GUID guid = Ole32Util.generateGUID(); assertEquals(guid, Ole32Util.getGUIDFromString( Ole32Util.getStringFromGUID(guid))); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/win32/Kernel32Test.java0000644000175000017500000002516011421126024026254 0ustar janjan/* 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. * * 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 java.util.Calendar; import java.util.TimeZone; import junit.framework.TestCase; import com.sun.jna.Native; import com.sun.jna.NativeMappedConverter; import com.sun.jna.Platform; import com.sun.jna.platform.win32.WinBase.MEMORYSTATUSEX; import com.sun.jna.platform.win32.WinBase.SYSTEM_INFO; import com.sun.jna.platform.win32.WinDef.DWORD; import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER; import com.sun.jna.platform.win32.WinNT.OSVERSIONINFO; import com.sun.jna.platform.win32.WinNT.OSVERSIONINFOEX; import com.sun.jna.ptr.IntByReference; public class Kernel32Test extends TestCase { public static void main(String[] args) { OSVERSIONINFO lpVersionInfo = new OSVERSIONINFO(); assertTrue(Kernel32.INSTANCE.GetVersionEx(lpVersionInfo)); System.out.println("Operating system: " + lpVersionInfo.dwMajorVersion.longValue() + "." + lpVersionInfo.dwMinorVersion.longValue() + " (" + lpVersionInfo.dwBuildNumber + ")" + " [" + Native.toString(lpVersionInfo.szCSDVersion) + "]"); junit.textui.TestRunner.run(Kernel32Test.class); } public void testGetDriveType() { if (!Platform.isWindows()) return; Kernel32 kernel = Kernel32.INSTANCE; assertEquals("Wrong drive type.", WinBase.DRIVE_FIXED, kernel.GetDriveType("c:")); } public void testStructureOutArgument() { Kernel32 kernel = Kernel32.INSTANCE; WinBase.SYSTEMTIME time = new WinBase.SYSTEMTIME(); kernel.GetSystemTime(time); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); assertEquals("Hour not properly set", cal.get(Calendar.HOUR_OF_DAY), time.wHour); assertEquals("Day not properly set", cal.get(Calendar.DAY_OF_WEEK)-1, time.wDayOfWeek); assertEquals("Year not properly set", cal.get(Calendar.YEAR), time.wYear); } public void testGetLastError() { Kernel32 kernel = Kernel32.INSTANCE; int ERRCODE = 8; kernel.SetLastError(ERRCODE); int code = kernel.GetLastError(); assertEquals("Wrong error value after SetLastError", ERRCODE, code); if (kernel.GetProcessVersion(-1) == 0) { final int INVALID_PARAMETER = 87; code = kernel.GetLastError(); assertEquals("Wrong error value after failed syscall", INVALID_PARAMETER, code); } else { fail("GetProcessId(NULL) should fail"); } } public void testConvertHWND_BROADCAST() { HWND hwnd = WinUser.HWND_BROADCAST; NativeMappedConverter.getInstance(hwnd.getClass()).toNative(hwnd, null); } public void testGetComputerName() { IntByReference lpnSize = new IntByReference(0); assertFalse(Kernel32.INSTANCE.GetComputerName(null, lpnSize)); assertEquals(W32Errors.ERROR_BUFFER_OVERFLOW, Kernel32.INSTANCE.GetLastError()); char buffer[] = new char[WinBase.MAX_COMPUTERNAME_LENGTH() + 1]; lpnSize.setValue(buffer.length); assertTrue(Kernel32.INSTANCE.GetComputerName(buffer, lpnSize)); } public void testWaitForSingleObject() { HANDLE handle = Kernel32.INSTANCE.CreateEvent(null, false, false, null); // handle runs into timeout since it is not triggered // WAIT_TIMEOUT = 0x00000102 assertEquals(W32Errors.WAIT_TIMEOUT, Kernel32.INSTANCE.WaitForSingleObject( handle, 1000)); Kernel32.INSTANCE.CloseHandle(handle); } public void testWaitForMultipleObjects(){ HANDLE[] handles = new HANDLE[2]; handles[0] = Kernel32.INSTANCE.CreateEvent(null, false, false, null); handles[1] = Kernel32.INSTANCE.CreateEvent(null, false, false, null); // handle runs into timeout since it is not triggered // WAIT_TIMEOUT = 0x00000102 assertEquals(W32Errors.WAIT_TIMEOUT, Kernel32.INSTANCE.WaitForMultipleObjects( handles.length, handles, false, 1000)); Kernel32.INSTANCE.CloseHandle(handles[0]); Kernel32.INSTANCE.CloseHandle(handles[1]); // invalid Handle handles[0] = WinBase.INVALID_HANDLE_VALUE; handles[1] = Kernel32.INSTANCE.CreateEvent(null, false, false, null); // returns WAIT_FAILED since handle is invalid assertEquals(WinBase.WAIT_FAILED, Kernel32.INSTANCE.WaitForMultipleObjects( handles.length, handles, false, 5000)); Kernel32.INSTANCE.CloseHandle(handles[1]); } public void testGetCurrentThreadId() { assertTrue(Kernel32.INSTANCE.GetCurrentThreadId() > 0); } public void testGetCurrentThread() { HANDLE h = Kernel32.INSTANCE.GetCurrentThread(); assertNotNull(h); assertFalse(h.equals(0)); // CloseHandle does not need to be called for a thread handle assertFalse(Kernel32.INSTANCE.CloseHandle(h)); assertEquals(W32Errors.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError()); } public void testOpenThread() { HANDLE h = Kernel32.INSTANCE.OpenThread(WinNT.THREAD_ALL_ACCESS, false, Kernel32.INSTANCE.GetCurrentThreadId()); assertNotNull(h); assertFalse(h.equals(0)); assertTrue(Kernel32.INSTANCE.CloseHandle(h)); } public void testGetCurrentProcessId() { assertTrue(Kernel32.INSTANCE.GetCurrentProcessId() > 0); } public void testGetCurrentProcess() { HANDLE h = Kernel32.INSTANCE.GetCurrentProcess(); assertNotNull(h); assertFalse(h.equals(0)); // CloseHandle does not need to be called for a process handle assertFalse(Kernel32.INSTANCE.CloseHandle(h)); assertEquals(W32Errors.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError()); } public void testOpenProcess() { HANDLE h = Kernel32.INSTANCE.OpenProcess(0, false, Kernel32.INSTANCE.GetCurrentProcessId()); assertNull(h); // opening your own process fails with access denied assertEquals(W32Errors.ERROR_ACCESS_DENIED, Kernel32.INSTANCE.GetLastError()); } public void testGetTempPath() { char[] buffer = new char[WinDef.MAX_PATH]; assertTrue(Kernel32.INSTANCE.GetTempPath(new DWORD(WinDef.MAX_PATH), buffer).intValue() > 0); } public void testGetVersion() { DWORD version = Kernel32.INSTANCE.GetVersion(); assertTrue(version.getHigh().intValue() != 0); assertTrue(version.getLow().intValue() >= 0); } public void testGetVersionEx_OSVERSIONINFO() { OSVERSIONINFO lpVersionInfo = new OSVERSIONINFO(); assertEquals(lpVersionInfo.size(), lpVersionInfo.dwOSVersionInfoSize.longValue()); assertTrue(Kernel32.INSTANCE.GetVersionEx(lpVersionInfo)); assertTrue(lpVersionInfo.dwMajorVersion.longValue() > 0); assertTrue(lpVersionInfo.dwMinorVersion.longValue() >= 0); assertEquals(lpVersionInfo.size(), lpVersionInfo.dwOSVersionInfoSize.longValue()); assertTrue(lpVersionInfo.dwPlatformId.longValue() > 0); assertTrue(lpVersionInfo.dwBuildNumber.longValue() > 0); assertTrue(Native.toString(lpVersionInfo.szCSDVersion).length() >= 0); } public void testGetVersionEx_OSVERSIONINFOEX() { OSVERSIONINFOEX lpVersionInfo = new OSVERSIONINFOEX(); assertEquals(lpVersionInfo.size(), lpVersionInfo.dwOSVersionInfoSize.longValue()); assertTrue(Kernel32.INSTANCE.GetVersionEx(lpVersionInfo)); assertTrue(lpVersionInfo.dwMajorVersion.longValue() > 0); assertTrue(lpVersionInfo.dwMinorVersion.longValue() >= 0); assertEquals(lpVersionInfo.size(), lpVersionInfo.dwOSVersionInfoSize.longValue()); assertTrue(lpVersionInfo.dwPlatformId.longValue() > 0); assertTrue(lpVersionInfo.dwBuildNumber.longValue() > 0); assertTrue(Native.toString(lpVersionInfo.szCSDVersion).length() >= 0); assertTrue(lpVersionInfo.wProductType >= 0); } public void testGetSystemInfo() { SYSTEM_INFO lpSystemInfo = new SYSTEM_INFO(); Kernel32.INSTANCE.GetSystemInfo(lpSystemInfo); assertTrue(lpSystemInfo.dwNumberOfProcessors.intValue() > 0); } public void testIsWow64Process() { try { IntByReference isWow64 = new IntByReference(42); HANDLE hProcess = Kernel32.INSTANCE.GetCurrentProcess(); assertTrue(Kernel32.INSTANCE.IsWow64Process(hProcess, isWow64)); assertTrue(0 == isWow64.getValue() || 1 == isWow64.getValue()); } catch (UnsatisfiedLinkError e) { // IsWow64Process is not available on this OS } } public void testGetNativeSystemInfo() { try { SYSTEM_INFO lpSystemInfo = new SYSTEM_INFO(); Kernel32.INSTANCE.GetNativeSystemInfo(lpSystemInfo); assertTrue(lpSystemInfo.dwNumberOfProcessors.intValue() > 0); } catch (UnsatisfiedLinkError e) { // only available under WOW64 } } public void testGlobalMemoryStatusEx() { MEMORYSTATUSEX lpBuffer = new MEMORYSTATUSEX(); assertTrue(Kernel32.INSTANCE.GlobalMemoryStatusEx(lpBuffer)); assertTrue(lpBuffer.ullTotalPhys.longValue() > 0); assertTrue(lpBuffer.dwMemoryLoad.intValue() >= 0 && lpBuffer.dwMemoryLoad.intValue() <= 100); assertEquals(0, lpBuffer.ullAvailExtendedVirtual.intValue()); } public void testGetLogicalDriveStrings() { DWORD dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(new DWORD(0), null); assertTrue(dwSize.intValue() > 0); char buf[] = new char[dwSize.intValue()]; assertTrue(Kernel32.INSTANCE.GetLogicalDriveStrings(dwSize, buf).intValue() > 0); } public void testGetDiskFreeSpaceEx() { LARGE_INTEGER.ByReference lpFreeBytesAvailable = new LARGE_INTEGER.ByReference(); LARGE_INTEGER.ByReference lpTotalNumberOfBytes = new LARGE_INTEGER.ByReference(); LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes = new LARGE_INTEGER.ByReference(); assertTrue(Kernel32.INSTANCE.GetDiskFreeSpaceEx(null, lpFreeBytesAvailable, lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes)); assertTrue(lpTotalNumberOfFreeBytes.getValue() > 0); assertTrue(lpTotalNumberOfFreeBytes.getValue() < lpTotalNumberOfBytes.getValue()); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/WindowUtilsTest.java0000644000175000017500000003670411421126024026223 0ustar janjan/* Copyright (c) 2007-2008 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. * * 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; import java.awt.AlphaComposite; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Frame; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; import java.awt.Point; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Shape; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.geom.Area; import java.lang.ref.WeakReference; import java.util.Arrays; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JWindow; import javax.swing.SwingUtilities; import javax.swing.event.MouseInputAdapter; import junit.framework.TestCase; import com.sun.jna.Platform; // NOTE: java.awt.Robot can't properly capture transparent pixels // Transparency tests are disabled until this can be resolved // TODO: test method invocations before/after pack, before/after setvisible // TODO: test RootPaneContainer/non-RootPaneContainer variations // TODO: use ComponentTestFixture from abbot public class WindowUtilsTest extends TestCase { MouseInputAdapter handler = new MouseInputAdapter() { private Point offset; public void mousePressed(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e)) offset = e.getPoint(); } public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { System.exit(1); } } public void mouseReleased(MouseEvent e) { offset = null; } public void mouseDragged(MouseEvent e) { if (offset != null) { Window w = (Window)e.getSource(); Point where = e.getPoint(); where.translate(-offset.x, -offset.y); Point loc = w.getLocationOnScreen(); loc.translate(where.x, where.y); w.setLocation(loc.x, loc.y); } } }; private Robot robot; protected void setUp() throws Exception { if (!GraphicsEnvironment.isHeadless()) robot = new Robot(); } protected void tearDown() { robot = null; if (!GraphicsEnvironment.isHeadless()) { Window[] owned = JOptionPane.getRootFrame().getOwnedWindows(); for (int i=0;i < owned.length;i++) { owned[i].dispose(); } } } private static final int X = 100; private static final int Y = 100; private static final int W = 100; private static final int H = 100; public void xtestReveal() throws Exception { final int SIZE = 200; System.setProperty("sun.java2d.noddraw", "true"); GraphicsConfiguration gconfig = WindowUtils.getAlphaCompatibleGraphicsConfiguration(); Window w; Container content; if (true) { JFrame frame = new JFrame(getName(), gconfig); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); content = frame.getContentPane(); w = frame; } else { Frame frame = JOptionPane.getRootFrame(); JWindow window = new JWindow(frame, gconfig); content = window.getContentPane(); w = window; } final Window f = w; WindowUtils.setWindowTransparent(f, true); content.add(new JButton("Quit") { private static final long serialVersionUID = 1L; { addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); } }, BorderLayout.SOUTH); content.add(new JComponent() { private static final long serialVersionUID = 1L; public Dimension getPreferredSize() { return new Dimension(SIZE, SIZE); } protected void paintComponent(Graphics graphics) { Graphics2D g = (Graphics2D)graphics.create(); g.setComposite(AlphaComposite.Clear); g.fillRect(0,0,SIZE,SIZE); g.dispose(); g = (Graphics2D)graphics.create(); Color[] colors = { new Color(0,0,0), new Color(0,0,0,128), new Color(128,128,128), new Color(128,128,128,128), new Color(255,255,255), new Color(255,255,255,128), }; for (int i=0;i < colors.length;i++) { g.setColor(colors[i]); g.fillRect((SIZE * i)/colors.length, 0, (SIZE + colors.length-1)/colors.length, SIZE); } g.setColor(Color.red); g.drawRect(0, 0, SIZE-1, SIZE-1); g.dispose(); SwingUtilities.getWindowAncestor(this).toFront(); } }); f.pack(); f.addMouseListener(handler); f.addMouseMotionListener(handler); f.setLocation(100, 100); f.setVisible(true); while (f.isVisible()) { Thread.sleep(1000); //f.repaint(); } } // Expect failure on windows and x11, since transparent pixels are not // properly captured by java.awt.Robot public void xtestWindowTransparency() throws Exception { if (GraphicsEnvironment.isHeadless()) return; System.setProperty("sun.java2d.noddraw", "true"); GraphicsConfiguration gconfig = WindowUtils.getAlphaCompatibleGraphicsConfiguration(); Frame root = JOptionPane.getRootFrame(); final Window background = new Window(root); background.setBackground(Color.white); background.setLocation(X, Y); final JWindow transparent = new JWindow(root, gconfig); transparent.setLocation(X, Y); ((JComponent)transparent.getContentPane()).setOpaque(false); transparent.getContentPane().add(new JComponent() { private static final long serialVersionUID = 1L; public Dimension getPreferredSize() { return new Dimension(W, H); } protected void paintComponent(Graphics g) { g = g.create(); g.setColor(Color.red); g.fillRect(getWidth()/4, getHeight()/4, getWidth()/2, getHeight()/2); g.drawRect(0, 0, getWidth()-1, getHeight()-1); g.dispose(); } }); transparent.addMouseListener(handler); transparent.addMouseMotionListener(handler); SwingUtilities.invokeAndWait(new Runnable() { public void run() { background.pack(); background.setSize(new Dimension(W, H)); background.setVisible(true); transparent.pack(); transparent.setSize(new Dimension(W, H)); transparent.setVisible(true); transparent.toFront(); }}); WindowUtils.setWindowTransparent(transparent, true); //robot.delay(60000); Color sample = robot.getPixelColor(X + W/2, Y + H/2); assertEquals("Painted pixel should be opaque", Color.red, sample); sample = robot.getPixelColor(X + 10, Y + 10); assertEquals("Unpainted pixel should be transparent", Color.white, sample); } // Expect failure on windows and x11, since transparent pixels are not // properly captured by java.awt.Robot public void xtestWindowAlpha() throws Exception { if (GraphicsEnvironment.isHeadless()) return; System.setProperty("sun.java2d.noddraw", "true"); GraphicsConfiguration gconfig = WindowUtils.getAlphaCompatibleGraphicsConfiguration(); Frame root = JOptionPane.getRootFrame(); final Window background = new Window(root); background.setBackground(Color.white); background.setLocation(X, Y); final Window transparent = new Window(root, gconfig); transparent.setBackground(Color.black); transparent.setLocation(X, Y); WindowUtils.setWindowAlpha(transparent, .5f); transparent.addMouseListener(handler); transparent.addMouseMotionListener(handler); SwingUtilities.invokeAndWait(new Runnable() { public void run() { background.pack(); background.setSize(new Dimension(W, H)); background.setVisible(true); transparent.pack(); transparent.setSize(new Dimension(W, H)); transparent.setVisible(true); }}); //robot.delay(60000); Point where = new Point(transparent.getX() + W/2, transparent.getY() + H/2); Color sample = robot.getPixelColor(where.x, where.y); // NOTE: w32 won't sample non-opaque windows if (System.getProperty("os.name").startsWith("Windows")) { assertFalse("Sample not transparent (w32)", sample.equals(transparent.getBackground())); } else { assertEquals("Sample should be 50% fg/bg", new Color(128, 128, 128), sample); } SwingUtilities.invokeAndWait(new Runnable() {public void run() { WindowUtils.setWindowAlpha(transparent, 1f); }}); sample = robot.getPixelColor(where.x, where.y); assertEquals("Window should be opaque with alpha=1f", transparent.getBackground(), sample); SwingUtilities.invokeAndWait(new Runnable() {public void run() { WindowUtils.setWindowAlpha(transparent, 0f); }}); sample = robot.getPixelColor(where.x, where.y); assertEquals("Window should be transparent with alpha=0f", transparent.getBackground(), sample); } /* public void testWindowRegion() throws Exception { if (GraphicsEnvironment.isHeadless()) return; Frame root = JOptionPane.getRootFrame(); final Window back = new Window(root); // Avoid display idiosyncrasies by using "standard" colors // (Don't use black, since a failed sample is sometimes black) final Color BACKGROUND = Color.GREEN; final Color FOREGROUND = Color.RED; back.setBackground(BACKGROUND); back.setLocation(X, Y); final JWindow front = new JWindow(root); front.getContentPane().setBackground(FOREGROUND); front.setLocation(X, Y); Area mask = new Area(new Rectangle(0, 0, W, H)); mask.subtract(new Area(new Rectangle(W/4, H/4, W/2, H/2))); WindowUtils.setWindowMask(front, mask); front.addMouseListener(handler); front.addMouseMotionListener(handler); SwingUtilities.invokeAndWait(new Runnable() { public void run() { back.pack(); back.setSize(new Dimension(W, H)); back.setVisible(true); front.pack(); front.setSize(new Dimension(W, H)); front.setVisible(true); }}); Point where = front.getLocationOnScreen(); where.translate(W/8, H/8); Color sample = robot.getPixelColor(where.x, where.y); long start = System.currentTimeMillis(); while (!sample.equals(FOREGROUND)) { SwingUtilities.invokeAndWait(new Runnable() { public void run() { front.toFront(); }}); Thread.sleep(10); if (System.currentTimeMillis() - start > 5000) fail("Timed out waiting for shaped window to appear, " + "expected foreground color (sample=" + sample + " vs expected=" + FOREGROUND + ")"); sample = robot.getPixelColor(where.x, where.y); } where = front.getLocationOnScreen(); where.translate(W/2, H/2); sample = robot.getPixelColor(where.x, where.y); start = System.currentTimeMillis(); while (!sample.equals(BACKGROUND)) { Thread.sleep(10); if (System.currentTimeMillis() - start > 1000) assertEquals("Background window should show through (center) " + where, BACKGROUND, sample); sample = robot.getPixelColor(where.x, where.y); } } */ public void testDisposeHeavyweightForcer() throws Exception { if (GraphicsEnvironment.isHeadless()) return; // Forcer not required on OSX if (Platform.isMac()) return; Frame root = JOptionPane.getRootFrame(); final JWindow w = new JWindow(root); w.getContentPane().add(new JLabel(getName())); final Rectangle mask = new Rectangle(0, 0, 10, 10); SwingUtilities.invokeAndWait(new Runnable() { public void run() { w.pack(); WindowUtils.setWindowMask(w, mask); w.setVisible(true); } }); try { Window[] owned = w.getOwnedWindows(); WeakReference ref = null; for (int i = 0; i < owned.length; i++) { if (owned[i].getClass().getName().indexOf("Heavy") != -1) { ref = new WeakReference(owned[i]); break; } } owned = null; assertNotNull("Forcer not found", ref); SwingUtilities.invokeAndWait(new Runnable() { public void run() { WindowUtils.setWindowMask(w, WindowUtils.MASK_NONE); } }); System.gc(); long start = System.currentTimeMillis(); while (ref.get() != null) { Thread.sleep(10); System.gc(); if (System.currentTimeMillis() - start > 5000) fail("Timed out waiting for forcer to be GC'd"); } assertNull("Forcer not GC'd", ref.get()); } finally { w.dispose(); } } // Test for accumulation of windows with repetitive setting of mask public void xtestWindowDisposeBug() throws Exception { final JFrame w = new JFrame(getName()); w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); w.getContentPane().add(new JLabel(getName())); WindowUtils.setWindowMask(w, new Area(new Rectangle(600, 20))); w.pack(); // small window, no bug. big window, bug. w.setSize(600, 600); w.setResizable(false); w.setVisible(true); final Shape mask = new Rectangle(0, 0, w.getWidth(), w.getHeight()); while (true) { System.gc(); Thread.sleep(50); SwingUtilities.invokeLater(new Runnable() { public void run() { WindowUtils.setWindowMask(w, mask); Window[] owned = w.getOwnedWindows(); System.err.println(owned.length + ": " + Arrays.asList(w.getOwnedWindows())); } }); } } public static void main(String[] args) { junit.textui.TestRunner.run(WindowUtilsTest.class); } } libjna-java-3.2.7/contrib/platform/test/com/sun/jna/platform/KeyboardUtilsTest.java0000644000175000017500000000443711421126022026510 0ustar janjan/* 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. * * 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; import java.awt.GraphicsEnvironment; import java.awt.Robot; import java.awt.event.KeyEvent; import junit.framework.TestCase; import com.sun.jna.Platform; public class KeyboardUtilsTest extends TestCase { public void testIsPressed() throws Exception { // Can't run this test headless; not yet implemented on mac if (GraphicsEnvironment.isHeadless() || Platform.isMac()) return; Robot robot = new Robot(); int[] keys = { // Avoid terminal control letters (like ^Z) KeyEvent.VK_CONTROL, KeyEvent.VK_SHIFT, }; String[] keystr = { "VK_CONTROL", "VK_SHIFT", }; int[] nonkeys = { KeyEvent.VK_B, KeyEvent.VK_1, KeyEvent.VK_ALT, }; String[] nonkeystr = { "VK_B", "VK_1", "VK_ALT", }; for (int i=0;i < keys.length;i++) { try { robot.keyPress(keys[i]); long start = System.currentTimeMillis(); while (!KeyboardUtils.isPressed(keys[i])) { if (System.currentTimeMillis() - start > 5000) { fail("Timed out waiting for keypress: " + keystr[i]); } Thread.sleep(10); } } finally { robot.keyRelease(keys[i]); } } for (int i=0;i < nonkeys.length;i++) { assertFalse("Key should not be pressed: " + nonkeystr[i], KeyboardUtils.isPressed(nonkeys[i])); } } public static void main(String[] args) { junit.textui.TestRunner.run(KeyboardUtilsTest.class); } } libjna-java-3.2.7/build.xml0000644000175000017500000007112211421531204013620 0ustar janjan Builds and tests JNA Java version ${java.version}, compatibility: ${compatibility} JNA version ${jna.version}, native ${jni.version} ${java.vm.name} (${java.vm.vendor}, ${java.vm.version}) java.home=${java.home} java.library.path=${java.library.path}

Invalidating native code, new checksum is ${md5} API for native code has changed. Re-run this build after updating jni.version and jni.md5 in build.xml Saving test results in ${results.junit} View test report in file://${reports.junit}/index.html One or more tests failed Reports generated in ${reports.clover} JNA API Documentation
${header}
${footer}
libjna-java-3.2.7/src/0000755000175000017500000000000010753020472012572 5ustar janjanlibjna-java-3.2.7/src/com/0000755000175000017500000000000010753020472013350 5ustar janjanlibjna-java-3.2.7/src/com/sun/0000755000175000017500000000000010753020472014155 5ustar janjanlibjna-java-3.2.7/src/com/sun/jna/0000755000175000017500000000000011526013531014722 5ustar janjanlibjna-java-3.2.7/src/com/sun/jna/ToNativeConverter.java0000644000175000017500000000252310753020504021207 0ustar janjan/* * Copyright (c) 2007 Wayne Meissner, 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; /** * Define conversion from a Java type to its corresponding native type. */ public interface ToNativeConverter { /** * Convert a Java type to an appropriate native type. The new type * must be one of the following classes: *

    *
  • {@link Pointer} *
  • Boolean *
  • Byte *
  • Short *
  • Character *
  • Integer *
  • {@link NativeLong} *
  • Long *
  • Float *
  • Double *
  • {@link Structure} *
  • String *
  • {@link WString} *
  • {@link java.nio.Buffer} *
  • primitive array *
*/ Object toNative(Object value, ToNativeContext context); /** Indicate the type expected from {@link #toNative}. */ Class nativeType(); } libjna-java-3.2.7/src/com/sun/jna/FromNativeContext.java0000644000175000017500000000163310753020502021204 0ustar janjan/* 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. * * 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; /** Provides context for converting a native value into a Java type. */ public class FromNativeContext { private Class type; FromNativeContext(Class javaType) { this.type = javaType; } /** The desired Java type of the result. */ public Class getTargetType() { return type; } } libjna-java-3.2.7/src/com/sun/jna/MethodResultContext.java0000644000175000017500000000220110753020502021541 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; import java.lang.reflect.Method; /** Provide result conversion context for a function call that is called via * a Library interface. */ public class MethodResultContext extends FunctionResultContext { private final Method method; MethodResultContext(Class resultClass, Function function, Object[] args, Method method) { super(resultClass, function, args); this.method = method; } /** Get the Method used to invoke this function call. */ public Method getMethod() { return method; } } libjna-java-3.2.7/src/com/sun/jna/package.html0000644000175000017500000000043410742714741017216 0ustar janjan Provides simplified native library access. See the overview for usage details. libjna-java-3.2.7/src/com/sun/jna/FromNativeConverter.java0000644000175000017500000000173710753020502021534 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; /** Define conversion from a native type to the appropriate Java type. */ public interface FromNativeConverter { /** Convert the given native object into its Java representation using * the given context. */ Object fromNative(Object nativeValue, FromNativeContext context); /** Indicate the native type used by this converter. */ Class nativeType(); } libjna-java-3.2.7/src/com/sun/jna/AltCallingConvention.java0000644000175000017500000000140210753020476021646 0ustar janjan/* 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. *

* 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; /** Tagging interface to indicate the library or callback uses an alternate * calling convention. * @author twall */ public interface AltCallingConvention {} libjna-java-3.2.7/src/com/sun/jna/NativeString.java0000644000175000017500000000673211204514570020214 0ustar janjan/* 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; import java.nio.CharBuffer; /** Provides a temporary allocation of an immutable C string * (const char* or const wchar_t*) for use when * converting a Java String into a native memory function argument. * * @author Todd Fast, todd.fast@sun.com * @author twall@users.sf.net */ class NativeString implements CharSequence, Comparable { private Pointer pointer; private boolean wide; /** Create a native string (NUL-terminated array of char).

* If the system property jna.encoding is set, its value will * be used to encode the native string. If not set or if the encoding * is unavailable, the default platform encoding will be used. */ public NativeString(String string) { this(string, false); } /** Create a native string as a NUL-terminated array of wchar_t * (if wide is true) or char.

* If the system property jna.encoding is set, its value will * be used to encode the native charstring. * If not set or if the encoding is unavailable, the default platform * encoding will be used. * * @param string value to write to native memory * @param wide whether to store the String as wchar_t */ public NativeString(String string, boolean wide) { if (string == null) { throw new NullPointerException("String must not be null"); } // Allocate the memory to hold the string. Note, we have to // make this 1 element longer in order to accommodate the terminating // NUL (which is generated in Pointer.setString()). this.wide = wide; if (wide) { int len = (string.length() + 1 ) * Native.WCHAR_SIZE; pointer = new Memory(len); pointer.setString(0, string, true); } else { byte[] data = Native.getBytes(string); pointer = new Memory(data.length + 1); pointer.write(0, data, 0, data.length); pointer.setByte(data.length, (byte)0); } } public int hashCode() { return toString().hashCode(); } public boolean equals(Object other) { if (other instanceof CharSequence) { return compareTo(other) == 0; } return false; } public String toString() { return pointer.getString(0, wide); } public Pointer getPointer() { return pointer; } public char charAt(int index) { return toString().charAt(index); } public int length() { return toString().length(); } public CharSequence subSequence(int start, int end) { return CharBuffer.wrap(toString()).subSequence(start, end); } public int compareTo(Object other) { if (other == null) return 1; return toString().compareTo(other.toString()); } } libjna-java-3.2.7/src/com/sun/jna/StructureWriteContext.java0000644000175000017500000000232311164171324022150 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; import java.lang.reflect.Field; /** Provide Java to native type conversion context for a {@link Structure} * field write. */ public class StructureWriteContext extends ToNativeContext { private Structure struct; private Field field; StructureWriteContext(Structure struct, Field field) { this.struct = struct; this.field = field; } /** Get the {@link Structure} the field is a member of. */ public Structure getStructure() { return struct; } /** Get the {@link Field} being written to native memory. */ public Field getField() { return field; } } libjna-java-3.2.7/src/com/sun/jna/StructureReadContext.java0000644000175000017500000000234211164171324021732 0ustar janjan/* 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. * * 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; import java.lang.reflect.Field; /** Provide native to Java type conversion context for a {@link Structure} * field read. */ public class StructureReadContext extends FromNativeContext { private Structure structure; private Field field; StructureReadContext(Structure struct, Field field) { super(field.getType()); this.structure = struct; this.field = field; } /** Get the {@link Structure} the field is a member of. */ public Structure getStructure() { return structure; } /** Get the {@link Field} being read from native memory. */ public Field getField() { return field; } } libjna-java-3.2.7/src/com/sun/jna/Native.java0000644000175000017500000016722611421404530017026 0ustar janjan/* Copyright (c) 2007, 2008, 2009 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. *

* 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; import java.awt.Component; import java.awt.GraphicsEnvironment; import java.awt.HeadlessException; import java.awt.Window; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.lang.ref.WeakReference; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.Proxy; import java.net.URI; import java.net.URL; import java.net.URISyntaxException; import java.nio.Buffer; import java.nio.ByteBuffer; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.WeakHashMap; import com.sun.jna.Callback.UncaughtExceptionHandler; import com.sun.jna.Structure.FFIType; /** Provides generation of invocation plumbing for a defined native * library interface. Also provides various utilities for native operations. *

* {@link #getTypeMapper} and {@link #getStructureAlignment} are provided * to avoid having to explicitly pass these parameters to {@link Structure}s, * which would require every {@link Structure} which requires custom mapping * or alignment to define a constructor and pass parameters to the superclass. * To avoid lots of boilerplate, the base {@link Structure} constructor * figures out these properties based on its enclosing interface.

* *

Library Loading

* When JNA classes are loaded, the native shared library (jnidispatch) is * loaded as well. An attempt is made to load it from the system library path * using {@link System#loadLibrary}. If not found, the appropriate library * will be extracted from the class path into a temporary directory and * loaded from there. If your system has additional security constraints * regarding execution or load of files (SELinux, for example), you should * probably install the native library in an accessible location and configure * your system accordingly, rather than relying on JNA to extract the library * from its own jar file. * @see Library * @author Todd Fast, todd.fast@sun.com * @author twall@users.sf.net */ public final class Native { private static final String VERSION = "3.2.7"; private static String nativeLibraryPath = null; private static boolean unpacked; private static Map typeMappers = new WeakHashMap(); private static Map alignments = new WeakHashMap(); private static Map options = new WeakHashMap(); private static Map libraries = new WeakHashMap(); private static final UncaughtExceptionHandler DEFAULT_HANDLER = new UncaughtExceptionHandler() { public void uncaughtException(Callback c, Throwable e) { System.err.println("JNA: Callback " + c + " threw the following exception:"); e.printStackTrace(); } }; private static UncaughtExceptionHandler callbackExceptionHandler = DEFAULT_HANDLER; /** The size of a native pointer (void*) on the current * platform, in bytes. */ public static final int POINTER_SIZE; /** Size of a native long type, in bytes. */ public static final int LONG_SIZE; /** Size of a native wchar_t type, in bytes. */ public static final int WCHAR_SIZE; /** Size of a native size_t type, in bytes. */ public static final int SIZE_T_SIZE; private static final int TYPE_VOIDP = 0; private static final int TYPE_LONG = 1; private static final int TYPE_WCHAR_T = 2; private static final int TYPE_SIZE_T = 3; static { loadNativeLibrary(); POINTER_SIZE = sizeof(TYPE_VOIDP); LONG_SIZE = sizeof(TYPE_LONG); WCHAR_SIZE = sizeof(TYPE_WCHAR_T); SIZE_T_SIZE = sizeof(TYPE_SIZE_T); // Perform initialization of other JNA classes until *after* // initializing the above final fields initIDs(); if (Boolean.getBoolean("jna.protected")) { setProtected(true); } } /** Ensure our unpacked native library gets cleaned up if this class gets garbage-collected. */ private static final Object finalizer = new Object() { protected void finalize() { deleteNativeLibrary(); } }; /** Remove any unpacked native library. Forcing the class loader to unload it first is required on Windows, since the temporary native library can't be deleted until the native library is unloaded. Any deferred execution we might install at this point would prevent the Native class and its class loader from being GC'd, so we instead force the native library unload just a little bit prematurely. */ private static boolean deleteNativeLibrary() { String path = nativeLibraryPath; if (path == null || !unpacked) return true; File flib = new File(path); if (flib.delete()) { nativeLibraryPath = null; unpacked = false; return true; } // Reach into the bowels of ClassLoader to force the native // library to unload // NOTE: this may cause a failure when freeing com.sun.jna.Memory // after the library has been unloaded, see // https://jna.dev.java.net/issues/show_bug.cgi?id=157 try { ClassLoader cl = Native.class.getClassLoader(); Field f = ClassLoader.class.getDeclaredField("nativeLibraries"); f.setAccessible(true); List libs = (List)f.get(cl); for (Iterator i = libs.iterator();i.hasNext();) { Object lib = i.next(); f = lib.getClass().getDeclaredField("name"); f.setAccessible(true); String name = (String)f.get(lib); if (name.equals(path) || name.indexOf(path) != -1 || name.equals(flib.getCanonicalPath())) { Method m = lib.getClass().getDeclaredMethod("finalize", new Class[0]); m.setAccessible(true); m.invoke(lib, new Object[0]); nativeLibraryPath = null; if (unpacked) { if (flib.exists()) { if (flib.delete()) { unpacked = false; return true; } return false; } } return true; } } } catch(Exception e) { } return false; } private Native() { } private static native void initIDs(); /** Set whether native memory accesses are protected from invalid * accesses. This should only be set true when testing or debugging, * and should not be considered reliable or robust for applications * where JNA native calls are occurring on multiple threads. * Protected mode will be automatically set if the * system property jna.protected has a value of "true" * when the JNA library is first loaded.

* If not supported by the underlying platform, this setting will * have no effect.

* NOTE: On platforms which support signals (non-Windows), JNA uses * signals to trap errors. This may interfere with the JVM's own use of * signals. When protected mode is enabled, you should make use of the * jsig library, if available (see Signal Chaining). * In short, set the environment variable LD_PRELOAD to the * path to libjsig.so in your JRE lib directory * (usually ${java.home}/lib/${os.arch}/libjsig.so) before launching your * Java application. */ public static synchronized native void setProtected(boolean enable); /** Returns whether protection is enabled. Check the result of this method * after calling {@link #setProtected setProtected(true)} to determine * if this platform supports protecting memory accesses. */ public static synchronized native boolean isProtected(); /** Set whether the system last error result is captured after every * native invocation. Defaults to true (false * for direct-mapped calls).

* @deprecated The preferred method of obtaining the last error result is * to declare your mapped method to throw {@link LastErrorException} * instead. */ public static synchronized native void setPreserveLastError(boolean enable); /** Indicates whether the system last error result is preserved * after every invocation.

* @deprecated The preferred method of obtaining the last error result is * to declare your mapped method to throw {@link LastErrorException} * instead. */ public static synchronized native boolean getPreserveLastError(); /** Utility method to get the native window ID for a Java {@link Window} * as a long value. * This method is primarily for X11-based systems, which use an opaque * XID (usually long int) to identify windows. * @throws HeadlessException if the current VM is running headless */ public static long getWindowID(Window w) throws HeadlessException { return getComponentID(w); } /** Utility method to get the native window ID for a heavyweight Java * {@link Component} as a long value. * This method is primarily for X11-based systems, which use an opaque * XID (usually long int) to identify windows. * @throws HeadlessException if the current VM is running headless */ public static long getComponentID(Component c) throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException("No native windows when headless"); } if (c.isLightweight()) { throw new IllegalArgumentException("Component must be heavyweight"); } if (!c.isDisplayable()) throw new IllegalStateException("Component must be displayable"); // On X11 VMs prior to 1.5, the window must be visible if (Platform.isX11() && System.getProperty("java.version").startsWith("1.4")) { if (!c.isVisible()) { throw new IllegalStateException("Component must be visible"); } } // By this point, we're certain that Toolkit.loadLibraries() has // been called, thus avoiding AWT/JAWT link errors // (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6539705). return getWindowHandle0(c); } /** Utility method to get the native window pointer for a Java * {@link Window} as a {@link Pointer} value. This method is primarily for * w32, which uses the HANDLE type (actually * void *) to identify windows. * @throws HeadlessException if the current VM is running headless */ public static Pointer getWindowPointer(Window w) throws HeadlessException { return getComponentPointer(w); } /** Utility method to get the native window pointer for a heavyweight Java * {@link Component} as a {@link Pointer} value. This method is primarily * for w32, which uses the HWND type (actually * void *) to identify windows. * @throws HeadlessException if the current VM is running headless */ public static Pointer getComponentPointer(Component c) throws HeadlessException { return new Pointer(getComponentID(c)); } private static native long getWindowHandle0(Component c); /** Convert a direct {@link Buffer} into a {@link Pointer}. * @throws IllegalArgumentException if the buffer is not direct. */ public static native Pointer getDirectBufferPointer(Buffer b); /** Obtain a Java String from the given native byte array. If there is * no NUL terminator, the String will comprise the entire array. If the * system property jna.encoding is set, its value will * override the platform default encoding (if supported). */ public static String toString(byte[] buf) { return toString(buf, System.getProperty("jna.encoding")); } /** Obtain a Java String from the given native byte array, using the given * encoding. If there is no NUL terminator, the String will comprise the * entire array. If the encoding parameter is null, * the platform default encoding will be used. */ public static String toString(byte[] buf, String encoding) { String s = null; if (encoding != null) { try { s = new String(buf, encoding); } catch(UnsupportedEncodingException e) { } } if (s == null) { s = new String(buf); } int term = s.indexOf(0); if (term != -1) s = s.substring(0, term); return s; } /** Obtain a Java String from the given native wchar_t array. If there is * no NUL terminator, the String will comprise the entire array. */ public static String toString(char[] buf) { String s = new String(buf); int term = s.indexOf(0); if (term != -1) s = s.substring(0, term); return s; } /** Map a library interface to the current process, providing * the explicit interface class. * @param interfaceClass */ public static Object loadLibrary(Class interfaceClass) { return loadLibrary(null, interfaceClass); } /** Map a library interface to the current process, providing * the explicit interface class. * @param interfaceClass * @param options Map of library options */ public static Object loadLibrary(Class interfaceClass, Map options) { return loadLibrary(null, interfaceClass, options); } /** Map a library interface to the given shared library, providing * the explicit interface class. * If name is null, attempts to map onto the current process. * @param name * @param interfaceClass */ public static Object loadLibrary(String name, Class interfaceClass) { return loadLibrary(name, interfaceClass, Collections.EMPTY_MAP); } /** Load a library interface from the given shared library, providing * the explicit interface class and a map of options for the library. * If no library options are detected the map is interpreted as a map * of Java method names to native function names.

* If name is null, attempts to map onto the current process. * @param name * @param interfaceClass * @param options Map of library options */ public static Object loadLibrary(String name, Class interfaceClass, Map options) { Library.Handler handler = new Library.Handler(name, interfaceClass, options); ClassLoader loader = interfaceClass.getClassLoader(); Library proxy = (Library) Proxy.newProxyInstance(loader, new Class[] {interfaceClass}, handler); cacheOptions(interfaceClass, options, proxy); return proxy; } /** Attempts to force initialization of an instance of the library interface * by loading a public static field of the requisite type. * Returns whether an instance variable was instantiated. * Expects that lock on libraries is already held */ private static void loadLibraryInstance(Class cls) { if (cls != null && !libraries.containsKey(cls)) { try { Field[] fields = cls.getFields(); for (int i=0;i < fields.length;i++) { Field field = fields[i]; if (field.getType() == cls && Modifier.isStatic(field.getModifiers())) { // Ensure the field gets initialized by reading it libraries.put(cls, new WeakReference(field.get(null))); break; } } } catch (Exception e) { throw new IllegalArgumentException("Could not access instance of " + cls + " (" + e + ")"); } } } /** Find the library interface corresponding to the given class. Checks * all ancestor classes and interfaces for a declaring class which * implements {@link Library}. */ static Class findEnclosingLibraryClass(Class cls) { if (cls == null) { return null; } synchronized(libraries) { if (options.containsKey(cls)) { return cls; } } if (Library.class.isAssignableFrom(cls)) { return cls; } if (Callback.class.isAssignableFrom(cls)) { cls = CallbackReference.findCallbackClass(cls); } Class declaring = cls.getDeclaringClass(); Class fromDeclaring = findEnclosingLibraryClass(declaring); if (fromDeclaring != null) { return fromDeclaring; } return findEnclosingLibraryClass(cls.getSuperclass()); } /** Return the preferred native library configuration options for the given * class. * @see Library */ public static Map getLibraryOptions(Class type) { synchronized(libraries) { Class interfaceClass = findEnclosingLibraryClass(type); if (interfaceClass != null) loadLibraryInstance(interfaceClass); else interfaceClass = type; if (!options.containsKey(interfaceClass)) { try { Field field = interfaceClass.getField("OPTIONS"); field.setAccessible(true); options.put(interfaceClass, field.get(null)); } catch (NoSuchFieldException e) { } catch (Exception e) { throw new IllegalArgumentException("OPTIONS must be a public field of type java.util.Map (" + e + "): " + interfaceClass); } } return (Map)options.get(interfaceClass); } } /** Return the preferred {@link TypeMapper} for the given native interface. * See {@link com.sun.jna.Library#OPTION_TYPE_MAPPER}. */ public static TypeMapper getTypeMapper(Class cls) { synchronized(libraries) { Class interfaceClass = findEnclosingLibraryClass(cls); if (interfaceClass != null) loadLibraryInstance(interfaceClass); else interfaceClass = cls; if (!typeMappers.containsKey(interfaceClass)) { try { Field field = interfaceClass.getField("TYPE_MAPPER"); field.setAccessible(true); typeMappers.put(interfaceClass, field.get(null)); } catch (NoSuchFieldException e) { Map options = getLibraryOptions(cls); if (options != null && options.containsKey(Library.OPTION_TYPE_MAPPER)) { typeMappers.put(interfaceClass, options.get(Library.OPTION_TYPE_MAPPER)); } } catch (Exception e) { throw new IllegalArgumentException("TYPE_MAPPER must be a public field of type " + TypeMapper.class.getName() + " (" + e + "): " + interfaceClass); } } return (TypeMapper)typeMappers.get(interfaceClass); } } /** Return the preferred structure alignment for the given native interface. * See {@link com.sun.jna.Library#OPTION_STRUCTURE_ALIGNMENT}. */ public static int getStructureAlignment(Class cls) { synchronized(libraries) { Class interfaceClass = findEnclosingLibraryClass(cls); if (interfaceClass != null) loadLibraryInstance(interfaceClass); else interfaceClass = cls; if (!alignments.containsKey(interfaceClass)) { try { Field field = interfaceClass.getField("STRUCTURE_ALIGNMENT"); field.setAccessible(true); alignments.put(interfaceClass, field.get(null)); } catch(NoSuchFieldException e) { Map options = getLibraryOptions(interfaceClass); if (options != null && options.containsKey(Library.OPTION_STRUCTURE_ALIGNMENT)) { alignments.put(interfaceClass, options.get(Library.OPTION_STRUCTURE_ALIGNMENT)); } } catch(Exception e) { throw new IllegalArgumentException("STRUCTURE_ALIGNMENT must be a public field of type int (" + e + "): " + interfaceClass); } } Integer value = (Integer)alignments.get(interfaceClass); return value != null ? value.intValue() : Structure.ALIGN_DEFAULT; } } /** Return a byte array corresponding to the given String. If the * system property jna.encoding is set, its value will override * the default platform encoding (if supported). */ static byte[] getBytes(String s) { try { return getBytes(s, System.getProperty("jna.encoding")); } catch (UnsupportedEncodingException e) { return s.getBytes(); } } /** Return a byte array corresponding to the given String, using the given encoding. */ static byte[] getBytes(String s, String encoding) throws UnsupportedEncodingException { if (encoding != null) { return s.getBytes(encoding); } return s.getBytes(); } /** Obtain a NUL-terminated byte buffer equivalent to the given String, using jna.encoding or the default platform encoding if that property is not set. */ public static byte[] toByteArray(String s) { byte[] bytes = getBytes(s); byte[] buf = new byte[bytes.length+1]; System.arraycopy(bytes, 0, buf, 0, bytes.length); return buf; } /** Obtain a NUL-terminated byte buffer equivalent to the given String, using the given encoding. */ public static byte[] toByteArray(String s, String encoding) throws UnsupportedEncodingException { byte[] bytes = getBytes(s, encoding); byte[] buf = new byte[bytes.length+1]; System.arraycopy(bytes, 0, buf, 0, bytes.length); return buf; } /** Obtain a NUL-terminated wide character buffer equivalent to the given String. */ public static char[] toCharArray(String s) { char[] chars = s.toCharArray(); char[] buf = new char[chars.length+1]; System.arraycopy(chars, 0, buf, 0, chars.length); return buf; } static String getNativeLibraryResourcePath(int osType, String arch, String name) { String osPrefix; arch = arch.toLowerCase(); switch(osType) { case Platform.WINDOWS: if ("i386".equals(arch)) arch = "x86"; osPrefix = "win32-" + arch; break; case Platform.MAC: osPrefix = "darwin"; break; case Platform.LINUX: if ("x86".equals(arch)) { arch = "i386"; } else if ("x86_64".equals(arch)) { arch = "amd64"; } osPrefix = "linux-" + arch; break; case Platform.SOLARIS: osPrefix = "sunos-" + arch; break; default: osPrefix = name.toLowerCase(); if ("x86".equals(arch)) { arch = "i386"; } if ("x86_64".equals(arch)) { arch = "amd64"; } if ("powerpc".equals(arch)) { arch = "ppc"; } int space = osPrefix.indexOf(" "); if (space != -1) { osPrefix = osPrefix.substring(0, space); } osPrefix += "-" + arch; break; } return "/com/sun/jna/" + osPrefix; } /** * Loads the JNA stub library. It will first attempt to load this library * from the directories specified in jna.boot.library.path. If that fails, * it will fallback to loading from the system library paths. Finally it will * attempt to extract the stub library from from the JNA jar file, and load it. *

* The jna.boot.library.path property is mainly to support jna.jar being * included in -Xbootclasspath, where java.library.path and LD_LIBRARY_PATH * are ignored. It might also be useful in other situations. *

*/ private static void loadNativeLibrary() { String libName = "jnidispatch"; String bootPath = System.getProperty("jna.boot.library.path"); if (bootPath != null) { String[] dirs = bootPath.split(File.pathSeparator); for (int i = 0; i < dirs.length; ++i) { String path = new File(new File(dirs[i]), System.mapLibraryName(libName)).getAbsolutePath(); try { System.load(path); nativeLibraryPath = path; return; } catch (UnsatisfiedLinkError ex) { } if (Platform.isMac()) { String orig, ext; if (path.endsWith("dylib")) { orig = "dylib"; ext = "jnilib"; } else { orig = "jnilib"; ext = "dylib"; } try { path = path.substring(0, path.lastIndexOf(orig)) + ext; System.load(path); nativeLibraryPath = path; return; } catch (UnsatisfiedLinkError ex) { } } } } try { System.loadLibrary(libName); nativeLibraryPath = libName; } catch(UnsatisfiedLinkError e) { loadNativeLibraryFromJar(); } } /** * Attempts to load the native library resource from the filesystem, * extracting the JNA stub library from jna.jar if not already available. */ private static void loadNativeLibraryFromJar() { String libname = System.mapLibraryName("jnidispatch"); String arch = System.getProperty("os.arch"); String name = System.getProperty("os.name"); String resourceName = getNativeLibraryResourcePath(Platform.getOSType(), arch, name) + "/" + libname; URL url = Native.class.getResource(resourceName); // Add an ugly hack for OpenJDK (soylatte) - JNI libs use the usual // .dylib extension if (url == null && Platform.isMac() && resourceName.endsWith(".dylib")) { resourceName = resourceName.substring(0, resourceName.lastIndexOf(".dylib")) + ".jnilib"; url = Native.class.getResource(resourceName); } if (url == null) { throw new UnsatisfiedLinkError("jnidispatch (" + resourceName + ") not found in resource path"); } File lib = null; if (url.getProtocol().toLowerCase().equals("file")) { try { lib = new File(new URI(url.toString())); } catch(URISyntaxException e) { lib = new File(url.getPath()); } if (!lib.exists()) { throw new Error("File URL " + url + " could not be properly decoded"); } } else { InputStream is = Native.class.getResourceAsStream(resourceName); if (is == null) { throw new Error("Can't obtain jnidispatch InputStream"); } FileOutputStream fos = null; try { // Suffix is required on windows, or library fails to load // Let Java pick the suffix, except on windows, to avoid // problems with Web Start. lib = File.createTempFile("jna", Platform.isWindows()?".dll":null); lib.deleteOnExit(); ClassLoader cl = Native.class.getClassLoader(); if (Platform.deleteNativeLibraryAfterVMExit() && (cl == null || cl.equals(ClassLoader.getSystemClassLoader()))) { Runtime.getRuntime().addShutdownHook(new DeleteNativeLibrary(lib)); } fos = new FileOutputStream(lib); int count; byte[] buf = new byte[1024]; while ((count = is.read(buf, 0, buf.length)) > 0) { fos.write(buf, 0, count); } } catch(IOException e) { throw new Error("Failed to create temporary file for jnidispatch library: " + e); } finally { try { is.close(); } catch(IOException e) { } if (fos != null) { try { fos.close(); } catch(IOException e) { } } } unpacked = true; } System.load(lib.getAbsolutePath()); nativeLibraryPath = lib.getAbsolutePath(); } /** * Initialize field and method IDs for native methods of this class. * Returns the size of a native pointer. **/ private static native int sizeof(int type); private static native String getNativeVersion(); private static native String getAPIChecksum(); private static final ThreadLocal lastError = new ThreadLocal() { protected synchronized Object initialValue() { return new Integer(0); } }; /** Retrieve the last error set by the OS. This corresponds to * GetLastError() on Windows, and errno on * most other platforms. The value is preserved per-thread, but whether * the original value is per-thread depends on the underlying OS. The * result is undefined if {@link #getPreserveLastError} is * false.

* The preferred method of obtaining the last error result is * to declare your mapped method to throw {@link LastErrorException} * instead. */ public static int getLastError() { return ((Integer)lastError.get()).intValue(); } /** Set the OS last error code. Whether the setting is per-thread * or global depends on the underlying OS. */ public static native void setLastError(int code); /** Update the last error value (called from native code). */ static void updateLastError(int e) { lastError.set(new Integer(e)); } /** * Returns a synchronized (thread-safe) library backed by the specified * library. This wrapping will prevent simultaneous invocations of any * functions mapped to a given {@link NativeLibrary}. Note that the * native library may still be sensitive to being called from different * threads. *

* @param library the library to be "wrapped" in a synchronized library. * @return a synchronized view of the specified library. */ public static Library synchronizedLibrary(final Library library) { Class cls = library.getClass(); if (!Proxy.isProxyClass(cls)) { throw new IllegalArgumentException("Library must be a proxy class"); } InvocationHandler ih = Proxy.getInvocationHandler(library); if (!(ih instanceof Library.Handler)) { throw new IllegalArgumentException("Unrecognized proxy handler: " + ih); } final Library.Handler handler = (Library.Handler)ih; InvocationHandler newHandler = new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { synchronized(handler.getNativeLibrary()) { return handler.invoke(library, method, args); } } }; return (Library)Proxy.newProxyInstance(cls.getClassLoader(), cls.getInterfaces(), newHandler); } /** If running web start, determine the location of a given native * library. This value may be used to properly set * jna.library.path so that JNA can load libraries identified * by the <nativelib> tag in the JNLP configuration file. Returns * null if the Web Start native library cache location can not * be determined. Note that the path returned may be different for any * given library name. *

* Use System.getProperty("javawebstart.version") to detect * whether your code is running under Web Start. * @throws UnsatisfiedLinkError if the library can't be found by the * Web Start class loader, which usually means it wasn't included as * a <nativelib> resource in the JNLP file. * @return null if unable to query the web start loader. */ public static String getWebStartLibraryPath(final String libName) { if (System.getProperty("javawebstart.version") == null) return null; try { final ClassLoader cl = Native.class.getClassLoader(); Method m = (Method)AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { Method m = ClassLoader.class.getDeclaredMethod("findLibrary", new Class[] { String.class }); m.setAccessible(true); return m; } catch(Exception e) { return null; } } }); String libpath = (String)m.invoke(cl, new Object[] { libName }); if (libpath != null) { return new File(libpath).getParent(); } return null; } catch (Exception e) { return null; } } /** For internal use only. */ public static class DeleteNativeLibrary extends Thread { private final File file; public DeleteNativeLibrary(File file) { this.file = file; } public void run() { // If we can't force an unload/delete, spawn a new process // to do so if (!deleteNativeLibrary()) { try { Runtime.getRuntime().exec(new String[] { System.getProperty("java.home") + "/bin/java", "-cp", System.getProperty("java.class.path"), getClass().getName(), file.getAbsolutePath(), }); } catch(IOException e) { e.printStackTrace(); } } } public static void main(String[] args) { if (args.length == 1) { File file = new File(args[0]); if (file.exists()) { long start = System.currentTimeMillis(); while (!file.delete() && file.exists()) { try { Thread.sleep(10); } catch(InterruptedException e) { } if (System.currentTimeMillis() - start > 5000) { System.err.println("Could not remove temp file: " + file.getAbsolutePath()); break; } } } } System.exit(0); } } /** Returns the native size of the given class, in bytes. * For use with arrays. */ public static int getNativeSize(Class type, Object value) { if (type.isArray()) { int len = Array.getLength(value); if (len > 0) { Object o = Array.get(value, 0); return len * getNativeSize(type.getComponentType(), o); } // Don't process zero-length arrays throw new IllegalArgumentException("Arrays of length zero not allowed: " + type); } if (Structure.class.isAssignableFrom(type) && !Structure.ByReference.class.isAssignableFrom(type)) { if (value == null) value = Structure.newInstance(type); return ((Structure)value).size(); } try { return getNativeSize(type); } catch(IllegalArgumentException e) { throw new IllegalArgumentException("The type \"" + type.getName() + "\" is not supported: " + e.getMessage()); } } /** Returns the native size for a given Java class. Structures are * assumed to be struct pointers unless they implement * {@link Structure.ByValue}. */ public static int getNativeSize(Class cls) { if (NativeMapped.class.isAssignableFrom(cls)) { cls = NativeMappedConverter.getInstance(cls).nativeType(); } // boolean defaults to 32 bit integer if not otherwise mapped if (cls == boolean.class || cls == Boolean.class) return 4; if (cls == byte.class || cls == Byte.class) return 1; if (cls == short.class || cls == Short.class) return 2; if (cls == char.class || cls == Character.class) return WCHAR_SIZE; if (cls == int.class || cls == Integer.class) return 4; if (cls == long.class || cls == Long.class) return 8; if (cls == float.class || cls == Float.class) return 4; if (cls == double.class || cls == Double.class) return 8; if (Structure.class.isAssignableFrom(cls)) { if (Structure.ByValue.class.isAssignableFrom(cls)) { return Structure.newInstance(cls).size(); } return POINTER_SIZE; } if (Pointer.class.isAssignableFrom(cls) || Buffer.class.isAssignableFrom(cls) || Callback.class.isAssignableFrom(cls) || String.class == cls || WString.class == cls) { return POINTER_SIZE; } throw new IllegalArgumentException("Native size for type \"" + cls.getName() + "\" is unknown"); } /** Indicate whether the given class is supported as a native argument * type. */ public static boolean isSupportedNativeType(Class cls) { if (Structure.class.isAssignableFrom(cls)) { return true; } try { return getNativeSize(cls) != 0; } catch(IllegalArgumentException e) { return false; } } /** Set the default handler invoked when a callback throws an uncaught * exception. If the given handler is null, the default * handler will be reinstated. */ public static void setCallbackExceptionHandler(UncaughtExceptionHandler eh) { callbackExceptionHandler = eh == null ? DEFAULT_HANDLER : eh; } /** Returns the current handler for callback uncaught exceptions. */ public static UncaughtExceptionHandler getCallbackExceptionHandler() { return callbackExceptionHandler; } /** When called from a class static initializer, maps all native methods * found within that class to native libraries via the JNA raw calling * interface. * @param libName library name to which functions should be bound */ public static void register(String libName) { register(getNativeClass(getCallingClass()), NativeLibrary.getInstance(libName)); } /** When called from a class static initializer, maps all native methods * found within that class to native libraries via the JNA raw calling * interface. * @param lib native library to which functions should be bound */ public static void register(NativeLibrary lib) { register(getNativeClass(getCallingClass()), lib); } static Class getNativeClass(Class cls) { Method[] methods = cls.getDeclaredMethods(); for (int i=0;i < methods.length;i++) { if ((methods[i].getModifiers() & Modifier.NATIVE) != 0) { return cls; } } int idx = cls.getName().lastIndexOf("$"); if (idx != -1) { String name = cls.getName().substring(0, idx); try { return getNativeClass(Class.forName(name, true, cls.getClassLoader())); } catch(ClassNotFoundException e) { } } throw new IllegalArgumentException("Can't determine class with native methods from the current context (" + cls + ")"); } static Class getCallingClass() { Class[] context = new SecurityManager() { public Class[] getClassContext() { return super.getClassContext(); } }.getClassContext(); if (context.length < 4) { throw new IllegalStateException("This method must be called from the static initializer of a class"); } return context[3]; } private static Map registeredClasses = new HashMap(); private static Map registeredLibraries = new HashMap(); private static Object unloader = new Object() { protected void finalize() { synchronized(registeredClasses) { for (Iterator i=registeredClasses.entrySet().iterator();i.hasNext();) { Map.Entry e = (Map.Entry)i.next(); unregister((Class)e.getKey(), (long[])e.getValue()); i.remove(); } } } }; /** Remove all native mappings for the calling class. Should only be called if the class is no longer referenced and about to be garbage collected. */ public static void unregister() { unregister(getNativeClass(getCallingClass())); } /** Remove all native mappings for the given class. Should only be called if the class is no longer referenced and about to be garbage collected. */ public static void unregister(Class cls) { synchronized(registeredClasses) { if (registeredClasses.containsKey(cls)) { unregister(cls, (long[])registeredClasses.get(cls)); registeredClasses.remove(cls); registeredLibraries.remove(cls); } } } /** Unregister the native methods for the given class. */ private static native void unregister(Class cls, long[] handles); private static String getSignature(Class cls) { if (cls.isArray()) { return "[" + getSignature(cls.getComponentType()); } if (cls.isPrimitive()) { if (cls == void.class) return "V"; if (cls == boolean.class) return "Z"; if (cls == byte.class) return "B"; if (cls == short.class) return "S"; if (cls == char.class) return "C"; if (cls == int.class) return "I"; if (cls == long.class) return "J"; if (cls == float.class) return "F"; if (cls == double.class) return "D"; } return "L" + replace(".", "/", cls.getName()) + ";"; } // No String.replace available in 1.4 static String replace(String s1, String s2, String str) { StringBuffer buf = new StringBuffer(); while (true) { int idx = str.indexOf(s1); if (idx == -1) { buf.append(str); break; } else { buf.append(str.substring(0, idx)); buf.append(s2); str = str.substring(idx + s1.length()); } } return buf.toString(); } private static final int CVT_UNSUPPORTED = -1; private static final int CVT_DEFAULT = 0; private static final int CVT_POINTER = 1; private static final int CVT_STRING = 2; private static final int CVT_STRUCTURE = 3; private static final int CVT_STRUCTURE_BYVAL = 4; private static final int CVT_BUFFER = 5; private static final int CVT_ARRAY_BYTE = 6; private static final int CVT_ARRAY_SHORT = 7; private static final int CVT_ARRAY_CHAR = 8; private static final int CVT_ARRAY_INT = 9; private static final int CVT_ARRAY_LONG = 10; private static final int CVT_ARRAY_FLOAT = 11; private static final int CVT_ARRAY_DOUBLE = 12; private static final int CVT_ARRAY_BOOLEAN = 13; private static final int CVT_BOOLEAN = 14; private static final int CVT_CALLBACK = 15; private static final int CVT_FLOAT = 16; private static final int CVT_NATIVE_MAPPED = 17; private static final int CVT_WSTRING = 18; private static final int CVT_INTEGER_TYPE = 19; private static final int CVT_POINTER_TYPE = 20; private static final int CVT_TYPE_MAPPER = 21; private static int getConversion(Class type, TypeMapper mapper) { if (type == Boolean.class) type = boolean.class; else if (type == Byte.class) type = byte.class; else if (type == Short.class) type = short.class; else if (type == Character.class) type = char.class; else if (type == Integer.class) type = int.class; else if (type == Long.class) type = long.class; else if (type == Float.class) type = float.class; else if (type == Double.class) type = double.class; else if (type == Void.class) type = void.class; if (mapper != null && (mapper.getFromNativeConverter(type) != null || mapper.getToNativeConverter(type) != null)) { return CVT_TYPE_MAPPER; } if (Pointer.class.isAssignableFrom(type)) { return CVT_POINTER; } if (String.class == type) { return CVT_STRING; } if (WString.class.isAssignableFrom(type)) { return CVT_WSTRING; } if (Buffer.class.isAssignableFrom(type)) { return CVT_BUFFER; } if (Structure.class.isAssignableFrom(type)) { if (Structure.ByValue.class.isAssignableFrom(type)) { return CVT_STRUCTURE_BYVAL; } return CVT_STRUCTURE; } if (type.isArray()) { switch(type.getName().charAt(1)) { case 'Z': return CVT_ARRAY_BOOLEAN; case 'B': return CVT_ARRAY_BYTE; case 'S': return CVT_ARRAY_SHORT; case 'C': return CVT_ARRAY_CHAR; case 'I': return CVT_ARRAY_INT; case 'J': return CVT_ARRAY_LONG; case 'F': return CVT_ARRAY_FLOAT; case 'D': return CVT_ARRAY_DOUBLE; default: break; } } if (type.isPrimitive()) { return type == boolean.class ? CVT_BOOLEAN : CVT_DEFAULT; } if (Callback.class.isAssignableFrom(type)) { return CVT_CALLBACK; } if (IntegerType.class.isAssignableFrom(type)) { return CVT_INTEGER_TYPE; } if (PointerType.class.isAssignableFrom(type)) { return CVT_POINTER_TYPE; } if (NativeMapped.class.isAssignableFrom(type)) { return CVT_NATIVE_MAPPED; } return CVT_UNSUPPORTED; } /** When called from a class static initializer, maps all native methods * found within that class to native libraries via the JNA raw calling * interface. * @param lib library to which functions should be bound */ // TODO: derive options from annotations (per-class or per-method) // options: read parameter type mapping (long/native long), // method name, library name, call conv public static void register(Class cls, NativeLibrary lib) { Method[] methods = cls.getDeclaredMethods(); List mlist = new ArrayList(); TypeMapper mapper = (TypeMapper) lib.getOptions().get(Library.OPTION_TYPE_MAPPER); for (int i=0;i < methods.length;i++) { if ((methods[i].getModifiers() & Modifier.NATIVE) != 0) { mlist.add(methods[i]); } } long[] handles = new long[mlist.size()]; for (int i=0;i < handles.length;i++) { Method method = (Method)mlist.get(i); String sig = "("; Class rclass = method.getReturnType(); long rtype, closure_rtype; Class[] ptypes = method.getParameterTypes(); long[] atypes = new long[ptypes.length]; long[] closure_atypes = new long[ptypes.length]; int[] cvt = new int[ptypes.length]; ToNativeConverter[] toNative = new ToNativeConverter[ptypes.length]; FromNativeConverter fromNative = null; int rcvt = getConversion(rclass, mapper); boolean throwLastError = false; switch (rcvt) { case CVT_UNSUPPORTED: throw new IllegalArgumentException(rclass + " is not a supported return type (in method " + method.getName() + " in " + cls + ")"); case CVT_TYPE_MAPPER: fromNative = mapper.getFromNativeConverter(rclass); closure_rtype = FFIType.get(rclass).peer; rtype = FFIType.get(fromNative.nativeType()).peer; break; case CVT_NATIVE_MAPPED: case CVT_INTEGER_TYPE: case CVT_POINTER_TYPE: closure_rtype = FFIType.get(Pointer.class).peer; rtype = FFIType.get(NativeMappedConverter.getInstance(rclass).nativeType()).peer; break; case CVT_STRUCTURE: closure_rtype = rtype = FFIType.get(Pointer.class).peer; break; case CVT_STRUCTURE_BYVAL: closure_rtype = FFIType.get(Pointer.class).peer; rtype = FFIType.get(rclass).peer; break; default: closure_rtype = rtype = FFIType.get(rclass).peer; break; } for (int t=0;t < ptypes.length;t++) { Class type = ptypes[t]; sig += getSignature(type); cvt[t] = getConversion(type, mapper); if (cvt[t] == CVT_UNSUPPORTED) { throw new IllegalArgumentException(type + " is not a supported argument type (in method " + method.getName() + " in " + cls + ")"); } if (cvt[t] == CVT_NATIVE_MAPPED || cvt[t] == CVT_INTEGER_TYPE) { type = NativeMappedConverter.getInstance(type).nativeType(); } else if (cvt[t] == CVT_TYPE_MAPPER) { toNative[t] = mapper.getToNativeConverter(type); } // Determine the type that will be passed to the native // function, as well as the type to be passed // from Java initially switch(cvt[t]) { case CVT_STRUCTURE_BYVAL: case CVT_INTEGER_TYPE: case CVT_POINTER_TYPE: case CVT_NATIVE_MAPPED: atypes[t] = FFIType.get(type).peer; closure_atypes[t] = FFIType.get(Pointer.class).peer; break; case CVT_TYPE_MAPPER: if (type.isPrimitive()) closure_atypes[t] = FFIType.get(type).peer; else closure_atypes[t] = FFIType.get(Pointer.class).peer; atypes[t] = FFIType.get(toNative[t].nativeType()).peer; break; case CVT_DEFAULT: closure_atypes[t] = atypes[t] = FFIType.get(type).peer; break; default: closure_atypes[t] = atypes[t] = FFIType.get(Pointer.class).peer; break; } } sig += ")"; sig += getSignature(rclass); Class[] etypes = method.getExceptionTypes(); for (int e=0;e < etypes.length;e++) { if (LastErrorException.class.isAssignableFrom(etypes[e])) { throwLastError = true; break; } } String name = method.getName(); FunctionMapper fmapper = (FunctionMapper)lib.getOptions().get(Library.OPTION_FUNCTION_MAPPER); if (fmapper != null) { name = fmapper.getFunctionName(lib, method); } Function f = lib.getFunction(name, method); try { handles[i] = registerMethod(cls, method.getName(), sig, cvt, closure_atypes, atypes, rcvt, closure_rtype, rtype, rclass, f.peer, f.getCallingConvention(), throwLastError, toNative, fromNative); } catch(NoSuchMethodError e) { throw new UnsatisfiedLinkError("No method " + method.getName() + " with signature " + sig + " in " + cls); } } synchronized(registeredClasses) { registeredClasses.put(cls, handles); registeredLibraries.put(cls, lib); } cacheOptions(cls, lib.getOptions(), null); } /** Take note of options used for a given library mapping, to facilitate looking them up later. */ private static void cacheOptions(Class cls, Map libOptions, Object proxy) { synchronized(libraries) { if (!libOptions.isEmpty()) options.put(cls, libOptions); if (libOptions.containsKey(Library.OPTION_TYPE_MAPPER)) typeMappers.put(cls, libOptions.get(Library.OPTION_TYPE_MAPPER)); if (libOptions.containsKey(Library.OPTION_STRUCTURE_ALIGNMENT)) alignments.put(cls, libOptions.get(Library.OPTION_STRUCTURE_ALIGNMENT)); if (proxy != null) { libraries.put(cls, new WeakReference(proxy)); } // If it's a direct mapping, AND implements a Library interface, // cache the library interface as well, so that any nested // classes get the appropriate associated options if (!cls.isInterface() && Library.class.isAssignableFrom(cls)) { Class ifaces[] = cls.getInterfaces(); for (int i=0;i < ifaces.length;i++) { if (Library.class.isAssignableFrom(ifaces[i])) { cacheOptions(ifaces[i], libOptions, proxy); break; } } } } } private static native long registerMethod(Class cls, String name, String signature, int[] conversions, long[] closure_arg_types, long[] arg_types, int rconversion, long closure_rtype, long rtype, Class rclass, long fptr, int callingConvention, boolean throwLastError, ToNativeConverter[] toNative, FromNativeConverter fromNative); // Called from native code private static NativeMapped fromNative(Class cls, Object value) { // NOTE: technically should be either CallbackParameterContext or // FunctionResultContext return (NativeMapped)NativeMappedConverter.getInstance(cls).fromNative(value, new FromNativeContext(cls)); } // Called from native code private static Class nativeType(Class cls) { return NativeMappedConverter.getInstance(cls).nativeType(); } // Called from native code private static Object toNative(ToNativeConverter cvt, Object o) { // NOTE: technically should be either CallbackResultContext or // FunctionParameterContext return cvt.toNative(o, new ToNativeContext()); } // Called from native code private static Object fromNative(FromNativeConverter cvt, Object o, Class cls) { // NOTE: technically should be FunctionResultContext return cvt.fromNative(o, new FromNativeContext(cls)); } public static native long ffi_prep_cif(int abi, int nargs, long ffi_return_type, long ffi_types); public static native void ffi_call(long cif, long fptr, long resp, long args); public static native long ffi_prep_closure(long cif, ffi_callback cb); public static native void ffi_free_closure(long closure); /** Returns the size (calculated by libffi) of the given type. */ static native int initialize_ffi_type(long type_info); public interface ffi_callback { void invoke(long cif, long resp, long argp); } /** Prints JNA library details to the console. */ public static void main(String[] args) { final String DEFAULT_TITLE = "Java Native Access (JNA)"; final String DEFAULT_VERSION = VERSION; final String DEFAULT_BUILD = VERSION + " (package information missing)"; Package pkg = Native.class.getPackage(); String title = pkg.getSpecificationTitle(); if (title == null) title = DEFAULT_TITLE; String version = pkg.getSpecificationVersion(); if (version == null) version = DEFAULT_VERSION; title += " API Version " + version; System.out.println(title); version = pkg.getImplementationVersion(); if (version == null) version = DEFAULT_BUILD; System.out.println("Version: " + version); System.out.println(" Native: " + getNativeVersion() + " (" + getAPIChecksum() + ")"); System.exit(0); } } libjna-java-3.2.7/src/com/sun/jna/Library.java0000644000175000017500000002226011234610414017172 0ustar janjan/* 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; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.HashMap; import java.util.Map; import java.util.WeakHashMap; /** Derive from this interface for all native library definitions. * * Define an instance of your library like this: *

 * MyNativeLibrary INSTANCE = (MyNativeLibrary)
 *     Native.loadLibrary("mylib", MyNativeLibrary.class);
 * 
*

* By convention, method names are identical to the native names, although you * can map java names to different native names by providing a * {@link FunctionMapper} as a value for key {@link #OPTION_FUNCTION_MAPPER} * in the options map passed to the * {@link Native#loadLibrary(String, Class, Map)} call. *

* Although the names for structures and structure fields may be chosen * arbitrarily, they should correspond as closely as possible to the native * definitions. The same is true for parameter names. *

* This interface supports multiple, concurrent invocations of any library * methods on the Java side. Check your library documentation for its * multi-threading requirements on the native side. If a library is not safe * for simultaneous multi-threaded access, consider using * {@link Native#synchronizedLibrary} to prevent simultaneous multi-threaded * access to the native code. *

* Optional fields
* Interface options will be automatically propagated to structures defined * within the library provided a call to * {@link Native#loadLibrary(String,Class,Map)} is made prior to instantiating * any of those structures. One common way of ensuring this is to declare * an INSTANCE field in the interface which holds the * loadLibrary result. *

* OPTIONS (an instance of {@link Map}), * TYPE_MAPPER (an instance of {@link TypeMapper}) and * STRUCTURE_ALIGNMENT (one of the alignment types defined in * {@link Structure}) may also be defined. If no instance of the interface * has been instantiated, these fields will be used to determine customization * settings for structures and methods defined within the interface. *

* * @author Todd Fast, todd.fast@sun.com * @author Timothy Wall, twalljava@dev.java.net */ public interface Library { /** Option key for a {@link TypeMapper} for the library. */ String OPTION_TYPE_MAPPER = "type-mapper"; /** Option key for a {@link FunctionMapper} for the library. */ String OPTION_FUNCTION_MAPPER = "function-mapper"; /** Option key for an {@link InvocationMapper} for the library. */ String OPTION_INVOCATION_MAPPER = "invocation-mapper"; /** Option key for structure alignment type ({@link Integer}), which should * be one of the predefined alignment types in {@link Structure}. */ String OPTION_STRUCTURE_ALIGNMENT = "structure-alignment"; /** Option key for a boolean flag to allow any Java class instance as a parameter. If no type mapper is found, the object is passed as a pointer. NOTE: This is for use with raw JNI interactions via the JNIEnv data structure. */ String OPTION_ALLOW_OBJECTS = "allow-objects"; /** Calling convention for the entire library. */ String OPTION_CALLING_CONVENTION = "calling-convention"; static class Handler implements InvocationHandler { static final Method OBJECT_TOSTRING; static final Method OBJECT_HASHCODE; static final Method OBJECT_EQUALS; static { try { OBJECT_TOSTRING = Object.class.getMethod("toString", new Class[0]); OBJECT_HASHCODE= Object.class.getMethod("hashCode", new Class[0]); OBJECT_EQUALS = Object.class.getMethod("equals", new Class[] { Object.class }); } catch (Exception e) { throw new Error("Error retrieving Object.toString() method"); } } private static class FunctionNameMap implements FunctionMapper { private final Map map; public FunctionNameMap(Map map) { this.map = new HashMap(map); } public String getFunctionName(NativeLibrary library, Method method) { String name = method.getName(); if (map.containsKey(name)) { return (String)map.get(name); } return name; } } private final NativeLibrary nativeLibrary; private final Class interfaceClass; // Library invocation options private final Map options; private FunctionMapper functionMapper; private final InvocationMapper invocationMapper; private final Map functions = new WeakHashMap(); public Handler(String libname, Class interfaceClass, Map options) { if (libname != null && "".equals(libname.trim())) { throw new IllegalArgumentException("Invalid library name \"" + libname + "\""); } this.interfaceClass = interfaceClass; options = new HashMap(options); int callingConvention = AltCallingConvention.class.isAssignableFrom(interfaceClass) ? Function.ALT_CONVENTION : Function.C_CONVENTION; if (options.get(OPTION_CALLING_CONVENTION) == null) { options.put(OPTION_CALLING_CONVENTION, new Integer(callingConvention)); } this.options = options; this.nativeLibrary = NativeLibrary.getInstance(libname, options); functionMapper = (FunctionMapper)options.get(OPTION_FUNCTION_MAPPER); if (functionMapper == null) { // backward compatibility; passed-in map is itself the name map functionMapper = new FunctionNameMap(options); } invocationMapper = (InvocationMapper)options.get(OPTION_INVOCATION_MAPPER); } public NativeLibrary getNativeLibrary() { return nativeLibrary; } public String getLibraryName() { return nativeLibrary.getName(); } public Class getInterfaceClass() { return interfaceClass; } private static class FunctionInfo { InvocationHandler handler; Function function; boolean isVarArgs; Map options; } public Object invoke(Object proxy, Method method, Object[] inArgs) throws Throwable { // Intercept Object methods if (OBJECT_TOSTRING.equals(method)) { return "Proxy interface to " + nativeLibrary; } else if (OBJECT_HASHCODE.equals(method)) { return new Integer(hashCode()); } else if (OBJECT_EQUALS.equals(method)) { Object o = inArgs[0]; if (o != null && Proxy.isProxyClass(o.getClass())) { return Function.valueOf(Proxy.getInvocationHandler(o) == this); } return Boolean.FALSE; } FunctionInfo f = null; synchronized(functions) { f = (FunctionInfo)functions.get(method); if (f == null) { f = new FunctionInfo(); f.isVarArgs = Function.isVarArgs(method); if (invocationMapper != null) { f.handler = invocationMapper.getInvocationHandler(nativeLibrary, method); } if (f.handler == null) { // Find the function to invoke String methodName = functionMapper.getFunctionName(nativeLibrary, method); if (methodName == null) { // Just in case the function mapper screwed up methodName = method.getName(); } f.function = nativeLibrary.getFunction(methodName, method); f.options = new HashMap(this.options); f.options.put(Function.OPTION_INVOKING_METHOD, method); } functions.put(method, f); } } if (f.isVarArgs) { inArgs = Function.concatenateVarArgs(inArgs); } if (f.handler != null) { return f.handler.invoke(proxy, method, inArgs); } return f.function.invoke(method.getReturnType(), inArgs, f.options); } } } libjna-java-3.2.7/src/com/sun/jna/ToNativeContext.java0000644000175000017500000000133410753020504020663 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; /** Context for converting a Java value to a native one. */ public class ToNativeContext { ToNativeContext() { } } libjna-java-3.2.7/src/com/sun/jna/CallbackResultContext.java0000644000175000017500000000057710753020476022045 0ustar janjanpackage com.sun.jna; import java.lang.reflect.Method; /** Conversion context from a Java {@link Callback} result to a native value. */ public class CallbackResultContext extends ToNativeContext { private Method method; CallbackResultContext(Method callbackMethod) { this.method = callbackMethod; } public Method getMethod() { return method; } } libjna-java-3.2.7/src/com/sun/jna/LastErrorException.java0000644000175000017500000000356511372233152021374 0ustar janjan/* Copyright (c) 2009 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. *

* 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; /** * Exception representing a non-zero error code returned in either * errno * or GetLastError(). */ public class LastErrorException extends RuntimeException { private int errorCode; private static String formatMessage(int code) { return Platform.isWindows() ? "GetLastError() returned " + code : "errno was " + code; } private static String parseMessage(String m) { try { return formatMessage(Integer.parseInt(m)); } catch(NumberFormatException e) { return m; } } public LastErrorException(String msg) { super(parseMessage(msg)); try { this.errorCode = Integer.parseInt(msg); } catch(NumberFormatException e) { this.errorCode = -1; } } /** * Returns the error code of the error. * @return * Error code. */ public int getErrorCode() { return errorCode; } public LastErrorException(int code) { super(formatMessage(code)); this.errorCode = code; } }libjna-java-3.2.7/src/com/sun/jna/StringArray.java0000644000175000017500000000474711050766576020066 0ustar janjan/* Copyright (c) 2007-2008 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. *

* 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; import java.util.ArrayList; import java.util.List; /** Handle native array of char* or wchar_t* type * by managing allocation/disposal of native strings within an array of * pointers. An extra NULL pointer is always added to the end of the native * pointer array for convenience. */ public class StringArray extends Memory implements Function.PostCallRead { private boolean wide; private List natives = new ArrayList(); private Object[] original; /** Create a native array of strings. */ public StringArray(String[] strings) { this(strings, false); } /** Create a native array of wide strings. */ public StringArray(String[] strings, boolean wide) { this((Object[])strings, wide); } /** Create a native array of wide strings. */ public StringArray(WString[] strings) { this(strings, true); } private StringArray(Object[] strings, boolean wide) { super((strings.length + 1) * Pointer.SIZE); this.original = strings; this.wide = wide; for (int i=0;i < strings.length;i++) { Pointer p = null; if (strings[i] != null) { NativeString ns = new NativeString(strings[i].toString(), wide); natives.add(ns); p = ns.getPointer(); } setPointer(Pointer.SIZE * i, p); } setPointer(Pointer.SIZE * strings.length, null); } /** Read back from native memory. */ public void read() { boolean returnWide = original instanceof WString[]; for (int si=0;si < original.length;si++) { Pointer p = getPointer(si * Pointer.SIZE); Object s = null; if (p != null) { s = p.getString(0, wide); if (returnWide) s = new WString((String)s); } original[si] = s; } } }libjna-java-3.2.7/src/com/sun/jna/IntegerType.java0000644000175000017500000000733511220633672020041 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; /** * Represents a native integer value, which may have a platform-specific size * (e.g. long on unix-based platforms). * * @author wmeissner@gmail.com */ public abstract class IntegerType extends Number implements NativeMapped { private int size; private long value; private Number number; /** Create a zero-valued IntegerType. */ public IntegerType(int size) { this(size, 0); } /** Create a IntegerType with the given value. */ public IntegerType(int size, long value) { this.size = size; setValue(value); } /** Change the value for this data. */ public void setValue(long value) { long truncated = value; this.value = value; switch (size) { case 1: truncated = (byte) value; this.number = new Byte((byte) value); break; case 2: truncated = (short) value; this.number = new Short((short) value); break; case 4: truncated = (int) value; this.number = new Integer((int) value); break; case 8: this.number = new Long(value); break; default: throw new IllegalArgumentException("Unsupported size: " + size); } if (size < 8) { long mask = ~((1L << (size*8)) - 1); if ((value < 0 && truncated != value) || (value >= 0 && (mask & value) != 0)) { throw new IllegalArgumentException("Argument value 0x" + Long.toHexString(value) + " exceeds native capacity (" + size + " bytes) mask=0x" + Long.toHexString(mask)); } } } public Object toNative() { return number; } public Object fromNative(Object nativeValue, FromNativeContext context) { // be forgiving of null values read from memory long value = nativeValue == null ? 0 : ((Number) nativeValue).longValue(); try { IntegerType number = (IntegerType) getClass().newInstance(); number.setValue(value); return number; } catch (InstantiationException e) { throw new IllegalArgumentException("Can't instantiate " + getClass()); } catch (IllegalAccessException e) { throw new IllegalArgumentException("Not allowed to instantiate " + getClass()); } } public Class nativeType() { return number.getClass(); } public int intValue() { return number.intValue(); } public long longValue() { return number.longValue(); } public float floatValue() { return number.floatValue(); } public double doubleValue() { return number.doubleValue(); } public boolean equals(Object rhs) { return rhs instanceof IntegerType && number.equals(((IntegerType)rhs).number); } public String toString() { return number.toString(); } public int hashCode() { return number.hashCode(); } } libjna-java-3.2.7/src/com/sun/jna/FunctionParameterContext.java0000644000175000017500000000223710753020502022561 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; public class FunctionParameterContext extends ToNativeContext { private Function function; private Object[] args; private int index; FunctionParameterContext(Function f, Object[] args, int index) { this.function = f; this.args = args; this.index = index; } /** Get the function that was invoked. */ public Function getFunction() { return function; } /** Get the arguments used in this function call. */ public Object[] getParameters() { return args; } public int getParameterIndex() { return index; } } libjna-java-3.2.7/src/com/sun/jna/Pointer.java0000644000175000017500000014414611421002536017214 0ustar janjan/* 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; import java.io.UnsupportedEncodingException; import java.lang.reflect.Array; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; import java.util.List; /** * An abstraction for a native pointer data type. A Pointer instance * represents, on the Java side, a native pointer. The native pointer could * be any type of native pointer. Methods such as write, * read, getXXX, and setXXX, provide * means to access memory underlying the native pointer.

* The constructors are intentionally package-private, since it's not generally * a good idea to be creating C pointers de novo. * * @author Sheng Liang, originator * @author Todd Fast, suitability modifications * @author Timothy Wall, robust library loading * @see Function */ public class Pointer { /** Size of a native pointer, in bytes. */ public static final int SIZE; static { // Force load of native library if ((SIZE = Native.POINTER_SIZE) == 0) { throw new Error("Native library not initialized"); } } /** Convenience constant, same as null. */ public static final Pointer NULL = null; /** Convenience constant, equivalent to (void*)CONSTANT. */ public static final Pointer createConstant(long peer) { return new Opaque(peer); } /** Convenience constant, equivalent to (void*)CONSTANT. This version will avoid setting any of the high bits on 64-bit systems. */ public static final Pointer createConstant(int peer) { return new Opaque((long)peer & 0xFFFFFFFF); } /** Pointer value of the real native pointer. Use long to be 64-bit safe. */ protected long peer; /** Derived class must assign peer pointer value. */ Pointer() { } /** Create from native pointer. Don't use this unless you know what * you're doing. */ public Pointer(long peer) { this.peer = peer; } public Pointer share(long offset) { return share(offset, 0); } /** Provide a view of this pointer with a different peer base. */ public Pointer share(long offset, long sz) { if (offset == 0) return this; return new Pointer(peer + offset); } /** Zero memory for the given number of bytes. */ public void clear(long size) { setMemory(0, size, (byte)0); } /** * Compares this Pointer to the specified object. * * @param o * A Pointer instance * @return True if the other object is a Pointer, * and the C pointers being pointed to by these objects are also * equal. Returns false otherwise. */ public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; return o instanceof Pointer && ((Pointer)o).peer == peer; } /** * Returns a hashcode for the native pointer represented by this * Pointer object * * @return A hash code value for the represented native pointer */ public int hashCode() { return (int)((peer >>> 32) + (peer & 0xFFFFFFFF)); } ////////////////////////////////////////////////////////////////////////// // Raw read methods ////////////////////////////////////////////////////////////////////////// /** Returns the offset of the given value in memory from the given offset, * or -1 if the value is not found. */ public long indexOf(long offset, byte value) { return _indexOf(peer + offset, value); } private static native long _indexOf(long addr, byte value); /** * Indirect the native pointer, copying from memory pointed to by * native pointer, into the specified array. * * @param offset byte offset from pointer into which data is copied * @param buf byte array into which data is copied * @param index array index from which to start copying * @param length number of elements from native pointer that must be copied */ public void read(long offset, byte[] buf, int index, int length) { _read(peer + offset, buf, index, length); } private static native void _read(long addr, byte[] buf, int index, int length); /** * Indirect the native pointer, copying from memory pointed to by * native pointer, into the specified array. * * @param offset byte offset from pointer from which data is copied * @param buf short array into which data is copied * @param index array index to which data is copied * @param length number of elements from native pointer that must be copied */ public void read(long offset, short[] buf, int index, int length) { _read(peer + offset, buf, index, length); } private static native void _read(long addr, short[] buf, int index, int length); /** * Indirect the native pointer, copying from memory pointed to by * native pointer, into the specified array. * * @param offset byte offset from pointer from which data is copied * @param buf char array into which data is copied * @param index array index to which data is copied * @param length number of elements from native pointer that must be copied */ public void read(long offset, char[] buf, int index, int length) { _read(peer + offset, buf, index, length); } private static native void _read(long addr, char[] buf, int index, int length); /** * Indirect the native pointer, copying from memory pointed to by * native pointer, into the specified array. * * @param offset byte offset from pointer from which data is copied * @param buf int array into which data is copied * @param index array index to which data is copied * @param length number of elements from native pointer that must be copied */ public void read(long offset, int[] buf, int index, int length) { _read(peer + offset, buf, index, length); } private static native void _read(long addr, int[] buf, int index, int length); /** * Indirect the native pointer, copying from memory pointed to by * native pointer, into the specified array. * * @param offset byte offset from pointer from which data is copied * @param buf long array into which data is copied * @param index array index to which data is copied * @param length number of elements from native pointer that must be copied */ public void read(long offset, long[] buf, int index, int length) { _read(peer + offset, buf, index, length); } private static native void _read(long addr, long[] buf, int index, int length); /** * Indirect the native pointer, copying from memory pointed to by * native pointer, into the specified array. * * @param offset byte offset from pointer from which data is copied * @param buf float array into which data is copied * @param index array index to which data is copied * @param length number of elements from native pointer that must be copied */ public void read(long offset, float[] buf, int index, int length) { _read(peer + offset, buf, index, length); } private static native void _read(long addr, float[] buf, int index, int length); /** * Indirect the native pointer, copying from memory pointed to by * native pointer, into the specified array. * * @param offset byte offset from pointer from which data is copied * @param buf double array into which data is copied * @param index array index to which data is copied * @param length number of elements from native pointer that must be copied */ public void read(long offset, double[] buf, int index, int length) { _read(peer + offset, buf, index, length); } private static native void _read(long addr, double[] buf, int index, int length); /** * Indirect the native pointer, copying from memory pointed to by * native pointer, into the specified array. * * @param offset byte offset from pointer from which data is copied * @param buf {@link Pointer} array into which data is copied * @param index array index to which data is copied * @param length number of elements from native pointer that must be copied */ public void read(long offset, Pointer[] buf, int index, int length) { for (int i=0;i < length;i++) { Pointer p = getPointer(offset + i*Pointer.SIZE); Pointer oldp = buf[i+index]; // Avoid replacing the original pointer if it hasn't changed if (oldp == null || p == null || p.peer != oldp.peer) { buf[i+index] = p; } } } ////////////////////////////////////////////////////////////////////////// // Raw write methods ////////////////////////////////////////////////////////////////////////// /** * Indirect the native pointer, copying into memory pointed to by * native pointer, from the specified array. * * @param offset byte offset from pointer into which data is copied * @param buf byte array from which to copy * @param index array index from which to start copying * @param length number of elements from buf that must be * copied */ public void write(long offset, byte[] buf, int index, int length) { _write(peer + offset, buf, index, length); } private static native void _write(long addr, byte[] buf, int index, int length); /** * Indirect the native pointer, copying into memory pointed to by * native pointer, from the specified array. * * @param offset byte offset from pointer into which data is copied * @param buf short array from which to copy * @param index array index from which to start copying * @param length number of elements from buf that must be * copied */ public void write(long offset, short[] buf, int index, int length) { _write(peer + offset, buf, index, length); } private static native void _write(long addr, short[] buf, int index, int length); /** * Indirect the native pointer, copying into memory pointed to by * native pointer, from the specified array. * * @param offset byte offset from pointer into which data is copied * @param buf char array from which to copy * @param index array index from which to start copying * @param length number of elements from buf that must be * copied */ public void write(long offset, char[] buf, int index, int length) { _write(peer + offset, buf, index, length); } private static native void _write(long addr, char[] buf, int index, int length); /** * Indirect the native pointer, copying into memory pointed to by * native pointer, from the specified array. * * @param offset byte offset from pointer into which data is copied * @param buf int array from which to copy * @param index array index from which to start copying * @param length number of elements from buf that must be * copied */ public void write(long offset, int[] buf, int index, int length) { _write(peer + offset, buf, index, length); } private static native void _write(long addr, int[] buf, int index, int length); /** * Indirect the native pointer, copying into memory pointed to by * native pointer, from the specified array. * * @param offset byte offset from pointer into which data is copied * @param buf long array from which to copy * @param index array index from which to start copying * @param length number of elements from buf that must be * copied */ public void write(long offset, long[] buf, int index, int length) { _write(peer + offset, buf, index, length); } private static native void _write(long addr, long[] buf, int index, int length); /** * Indirect the native pointer, copying into memory pointed to by * native pointer, from the specified array. * * @param offset byte offset from pointer into which data is copied * @param buf float array from which to copy * @param index array index from which to start copying * @param length number of elements from buf that must be * copied */ public void write(long offset, float[] buf, int index, int length) { _write(peer + offset, buf, index, length); } private static native void _write(long addr, float[] buf, int index, int length); /** * Indirect the native pointer, copying into memory pointed to by * native pointer, from the specified array. * * @param offset byte offset from pointer into which data is copied * @param buf double array from which to copy * @param index array index from which to start copying * @param length number of elements from buf that must be * copied */ public void write(long offset, double[] buf, int index, int length) { _write(peer + offset, buf, index, length); } private static native void _write(long addr, double[] buf, int index, int length); /** Write the given array of Pointer to native memory. * @param bOff byte offset from pointer into which data is copied * @param buf Pointer array from which to copy * @param index array index from which to start copying * @param length number of elements from buf that must be * copied */ public void write(long bOff, Pointer[] buf, int index, int length) { for (int i=0;i < length;i++) { setPointer(bOff + i * Pointer.SIZE, buf[index + i]); } } ////////////////////////////////////////////////////////////////////////// // Java type read methods ////////////////////////////////////////////////////////////////////////// Object getValue(long offset, Class type, Object currentValue) { Object result = null; if (Structure.class.isAssignableFrom(type)) { Structure s = (Structure)currentValue; if (Structure.ByReference.class.isAssignableFrom(type)) { s = Structure.updateStructureByReference(type, s, getPointer(offset)); } else { s.useMemory(this, (int)offset); s.read(); } result = s; } else if (type == boolean.class || type == Boolean.class) { result = Function.valueOf(getInt(offset) != 0); } else if (type == byte.class || type == Byte.class) { result = new Byte(getByte(offset)); } else if (type == short.class || type == Short.class) { result = new Short(getShort(offset)); } else if (type == char.class || type == Character.class) { result = new Character(getChar(offset)); } else if (type == int.class || type == Integer.class) { result = new Integer(getInt(offset)); } else if (type == long.class || type == Long.class) { result = new Long(getLong(offset)); } else if (type == float.class || type == Float.class) { result=new Float(getFloat(offset)); } else if (type == double.class || type == Double.class) { result = new Double(getDouble(offset)); } else if (Pointer.class.isAssignableFrom(type)) { Pointer p = getPointer(offset); if (p != null) { Pointer oldp = currentValue instanceof Pointer ? (Pointer)currentValue : null; if (oldp == null || p.peer != oldp.peer) result = p; else result = oldp; } } else if (type == String.class) { Pointer p = getPointer(offset); result = p != null ? p.getString(0) : null; } else if (type == WString.class) { Pointer p = getPointer(offset); result = p != null ? new WString(p.getString(0, true)) : null; } else if (Callback.class.isAssignableFrom(type)) { // Overwrite the Java memory if the native pointer is a different // function pointer. Pointer fp = getPointer(offset); if (fp == null) { result = null; } else { Callback cb = (Callback)currentValue; Pointer oldfp = CallbackReference.getFunctionPointer(cb); if (!fp.equals(oldfp)) { cb = CallbackReference.getCallback(type, fp); } result = cb; } } else if (Buffer.class.isAssignableFrom(type)) { Pointer bp = getPointer(offset); if (bp == null) { result = null; } else { Pointer oldbp = currentValue == null ? null : Native.getDirectBufferPointer((Buffer)currentValue); if (oldbp == null || !oldbp.equals(bp)) { throw new IllegalStateException("Can't autogenerate a direct buffer on memory read"); } result = currentValue; } } else if (NativeMapped.class.isAssignableFrom(type)) { NativeMapped nm = (NativeMapped)currentValue; if (nm != null) { Object value = getValue(offset, nm.nativeType(), null); result = nm.fromNative(value, new FromNativeContext(type)); } else { NativeMappedConverter tc = NativeMappedConverter.getInstance(type); Object value = getValue(offset, tc.nativeType(), null); result = tc.fromNative(value, new FromNativeContext(type)); } } else if (type.isArray()) { result = currentValue; if (result == null) { throw new IllegalStateException("Need an initialized array"); } getArrayValue(offset, result, type.getComponentType()); } else { throw new IllegalArgumentException("Reading \"" + type + "\" from memory is not supported"); } return result; } private void getArrayValue(long offset, Object o, Class cls) { int length = 0; length = Array.getLength(o); Object result = o; if (cls == byte.class) { read(offset, (byte[])result, 0, length); } else if (cls == short.class) { read(offset, (short[])result, 0, length); } else if (cls == char.class) { read(offset, (char[])result, 0, length); } else if (cls == int.class) { read(offset, (int[])result, 0, length); } else if (cls == long.class) { read(offset, (long[])result, 0, length); } else if (cls == float.class) { read(offset, (float[])result, 0, length); } else if (cls == double.class) { read(offset, (double[])result, 0, length); } else if (Pointer.class.isAssignableFrom(cls)) { read(offset, (Pointer[])result, 0, length); } else if (Structure.class.isAssignableFrom(cls)) { Structure[] sarray = (Structure[])result; if (Structure.ByReference.class.isAssignableFrom(cls)) { Pointer[] parray = getPointerArray(offset, sarray.length); for (int i=0;i < sarray.length;i++) { sarray[i] = Structure.updateStructureByReference(cls, sarray[i], parray[i]); } } else { for (int i=0;i < sarray.length;i++) { if (sarray[i] == null) { sarray[i] = Structure.newInstance(cls); } sarray[i].useMemory(this, (int)(offset + i * sarray[i].size())); sarray[i].read(); } } } else if (NativeMapped.class.isAssignableFrom(cls)) { NativeMapped[] array = (NativeMapped[])result; NativeMappedConverter tc = NativeMappedConverter.getInstance(cls); int size = Native.getNativeSize(result.getClass(), result) / array.length; for (int i=0;i < array.length;i++) { Object value = getValue(offset + size*i, tc.nativeType(), array[i]); array[i] = (NativeMapped)tc.fromNative(value, new FromNativeContext(cls)); } } else { throw new IllegalArgumentException("Reading array of " + cls + " from memory not supported"); } } /** * Indirect the native pointer as a pointer to byte. This is * equivalent to the expression * *((jbyte *)((char *)Pointer + offset)). * * @param offset offset from pointer to perform the indirection * @return the byte value being pointed to */ public byte getByte(long offset) { return _getByte(peer + offset); } private static native byte _getByte(long addr); /** * Indirect the native pointer as a pointer to wchar_t. This * is equivalent to the expression * *((wchar_t*)((char *)Pointer + offset)). * * @param offset offset from pointer to perform the indirection * @return the wchar_t value being pointed to */ public char getChar(long offset) { return _getChar(peer + offset); } private static native char _getChar(long addr); /** * Indirect the native pointer as a pointer to short. This is * equivalent to the expression * *((jshort *)((char *)Pointer + offset)). * * @param offset byte offset from pointer to perform the indirection * @return the short value being pointed to */ public short getShort(long offset) { return _getShort(peer + offset); } private static native short _getShort(long addr); /** * Indirect the native pointer as a pointer to int. This is * equivalent to the expression * *((jint *)((char *)Pointer + offset)). * * @param offset byte offset from pointer to perform the indirection * @return the int value being pointed to */ public int getInt(long offset) { return _getInt(peer + offset); } private static native int _getInt(long addr); /** * Indirect the native pointer as a pointer to long. This is * equivalent to the expression * *((jlong *)((char *)Pointer + offset)). * * @param offset byte offset from pointer to perform the indirection * @return the long value being pointed to */ public long getLong(long offset) { return _getLong(peer + offset); } private static native long _getLong(long addr); /** * Indirect the native pointer as a pointer to long. This is * equivalent to the expression * *((long *)((char *)Pointer + offset)). * * @param offset byte offset from pointer to perform the indirection * @return the long value being pointed to */ public NativeLong getNativeLong(long offset) { return new NativeLong(NativeLong.SIZE == 8 ? getLong(offset) : getInt(offset)); } /** * Indirect the native pointer as a pointer to float. This is * equivalent to the expression * *((jfloat *)((char *)Pointer + offset)). * * @param offset byte offset from pointer to perform the indirection * @return the float value being pointed to */ public float getFloat(long offset) { return _getFloat(peer + offset); } private native float _getFloat(long addr); /** * Indirect the native pointer as a pointer to double. This * is equivalent to the expression * *((jdouble *)((char *)Pointer + offset)). * * @param offset byte offset from pointer to perform the indirection * @return the double value being pointed to */ public double getDouble(long offset) { return _getDouble(peer + offset); } private static native double _getDouble(long addr); /** * Indirect the native pointer as a pointer to pointer. This is equivalent * to the expression * *((void **)((char *)Pointer + offset)). * * @param offset byte offset from pointer to perform the indirection * @return a {@link Pointer} equivalent of the pointer value * being pointed to, or null if the pointer value is * NULL; */ public Pointer getPointer(long offset) { return _getPointer(peer + offset); } private static native Pointer _getPointer(long addr); /** * Get a ByteBuffer mapped to the memory pointed to by the pointer, * ensuring the buffer uses native byte order. * * @param offset byte offset from pointer to start the buffer * @param length Length of ByteBuffer * @return a direct ByteBuffer that accesses the memory being pointed to, */ public ByteBuffer getByteBuffer(long offset, long length) { return _getDirectByteBuffer(peer + offset, length).order(ByteOrder.nativeOrder()); } /** * Get a direct ByteBuffer mapped to the memory pointed to by the pointer. * * @param addr byte offset from pointer to start the buffer * @param length Length of ByteBuffer * @return a direct ByteBuffer that accesses the memory being pointed to, */ private native ByteBuffer _getDirectByteBuffer(long addr, long length); /** * Copy native memory to a Java String. If wide is true, * access the memory as an array of wchar_t, otherwise * as an array of char, using the default platform encoding. * * @param offset byte offset from pointer to obtain the native string v * @param wide whether to convert from a wide or standard C string * @return the String value being pointed to */ public String getString(long offset, boolean wide) { return _getString(peer + offset, wide); } private static native String _getString(long addr, boolean wide); /** * Copy native memory to a Java String. If the system property * jna.encoding is set, uses it as the native charset * when decoding the value, otherwise falls back to the default platform * encoding. * * @param offset byte offset from pointer to obtain the native string * @return the String value being pointed to */ public String getString(long offset) { String encoding = System.getProperty("jna.encoding"); if (encoding != null) { long len = indexOf(offset, (byte)0); if (len != -1) { if (len > Integer.MAX_VALUE) { throw new OutOfMemoryError("String exceeds maximum length: " + len); } byte[] data = getByteArray(offset, (int)len); try { return new String(data, encoding); } catch(UnsupportedEncodingException e) { } } } return getString(offset, false); } public byte[] getByteArray(long offset, int arraySize) { byte[] buf = new byte[arraySize]; read(offset, buf, 0, arraySize); return buf; } public char[] getCharArray(long offset, int arraySize) { char[] buf = new char[arraySize]; read(offset, buf, 0, arraySize); return buf; } public short[] getShortArray(long offset, int arraySize) { short[] buf = new short[arraySize]; read(offset, buf, 0, arraySize); return buf; } public int[] getIntArray(long offset, int arraySize) { int[] buf = new int[arraySize]; read(offset, buf, 0, arraySize); return buf; } public long[] getLongArray(long offset, int arraySize) { long[] buf = new long[arraySize]; read(offset, buf, 0, arraySize); return buf; } public float[] getFloatArray(long offset, int arraySize) { float[] buf = new float[arraySize]; read(offset, buf, 0, arraySize); return buf; } public double[] getDoubleArray(long offset, int arraySize) { double[] buf = new double[arraySize]; read(offset, buf, 0, arraySize); return buf; } /** Returns an array of {@link Pointer}. The array length is * determined by a NULL-valued terminating element. */ public Pointer[] getPointerArray(long base) { List array = new ArrayList(); int offset = 0; Pointer p = getPointer(base); while (p != null) { array.add(p); offset += Pointer.SIZE; p = getPointer(base + offset); } return (Pointer[])array.toArray(new Pointer[array.size()]); } /** Returns an array of {@link Pointer} of the requested size. */ public Pointer[] getPointerArray(long offset, int arraySize) { Pointer[] buf = new Pointer[arraySize]; read(offset, buf, 0, arraySize); return buf; } /** Returns an array of String based on a native array * of char *. The array length is determined by a * NULL-valued terminating element. */ public String[] getStringArray(long base) { return getStringArray(base, -1, false); } /** Returns an array of String based on a native array * of char *, using the given array length. */ public String[] getStringArray(long base, int length) { return getStringArray(base, length, false); } /** Returns an array of String based on a native array * of char* or wchar_t* based on the * wide parameter. The array length is determined by a * NULL-valued terminating element. */ public String[] getStringArray(long base, boolean wide) { return getStringArray(base, -1, wide); } /** Returns an array of String based on a native array * of char* or wchar_t* based on the * wide parameter, using the given array length. */ public String[] getStringArray(long base, int length, boolean wide) { List strings = new ArrayList(); Pointer p; int offset = 0; if (length != -1) { p = getPointer(base + offset); int count = 0; while (count++ < length) { String s = p == null ? null : p.getString(0, wide); strings.add(s); if (count < length) { offset += SIZE; p = getPointer(base + offset); } } } else { while ((p = getPointer(base + offset)) != null) { String s = p == null ? null : p.getString(0, wide); strings.add(s); offset += SIZE; } } return (String[])strings.toArray(new String[strings.size()]); } ////////////////////////////////////////////////////////////////////////// // Java type write methods ////////////////////////////////////////////////////////////////////////// void setValue(long offset, Object value, Class type) { // Set the value at the offset according to its type if (type == boolean.class || type == Boolean.class) { setInt(offset, Boolean.TRUE.equals(value) ? -1 : 0); } else if (type == byte.class || type == Byte.class) { setByte(offset, value == null ? 0 : ((Byte)value).byteValue()); } else if (type == short.class || type == Short.class) { setShort(offset, value == null ? 0 : ((Short)value).shortValue()); } else if (type == char.class || type == Character.class) { setChar(offset, value == null ? 0 : ((Character)value).charValue()); } else if (type == int.class || type == Integer.class) { setInt(offset, value == null ? 0 : ((Integer)value).intValue()); } else if (type == long.class || type == Long.class) { setLong(offset, value == null ? 0 : ((Long)value).longValue()); } else if (type == float.class || type == Float.class) { setFloat(offset, value == null ? 0f : ((Float)value).floatValue()); } else if (type == double.class || type == Double.class) { setDouble(offset, value == null ? 0.0 : ((Double)value).doubleValue()); } else if (type == Pointer.class) { setPointer(offset, (Pointer)value); } else if (type == String.class) { setPointer(offset, (Pointer)value); } else if (type == WString.class) { setPointer(offset, (Pointer)value); } else if (Structure.class.isAssignableFrom(type)) { Structure s = (Structure)value; if (Structure.ByReference.class.isAssignableFrom(type)) { setPointer(offset, s == null ? null : s.getPointer()); if (s != null) { s.autoWrite(); } } else { s.useMemory(this, (int)offset); s.write(); } } else if (Callback.class.isAssignableFrom(type)) { setPointer(offset, CallbackReference.getFunctionPointer((Callback)value)); } else if (Buffer.class.isAssignableFrom(type)) { Pointer p = value == null ? null : Native.getDirectBufferPointer((Buffer)value); setPointer(offset, p); } else if (NativeMapped.class.isAssignableFrom(type)) { NativeMappedConverter tc = NativeMappedConverter.getInstance(type); Class nativeType = tc.nativeType(); setValue(offset, tc.toNative(value, new ToNativeContext()), nativeType); } else if (type.isArray()) { setArrayValue(offset, value, type.getComponentType()); } else { throw new IllegalArgumentException("Writing " + type + " to memory is not supported"); } } private void setArrayValue(long offset, Object value, Class cls) { if (cls == byte.class) { byte[] buf = (byte[])value; write(offset, buf, 0, buf.length); } else if (cls == short.class) { short[] buf = (short[])value; write(offset, buf, 0, buf.length); } else if (cls == char.class) { char[] buf = (char[])value; write(offset, buf, 0, buf.length); } else if (cls == int.class) { int[] buf = (int[])value; write(offset, buf, 0, buf.length); } else if (cls == long.class) { long[] buf = (long[])value; write(offset, buf, 0, buf.length); } else if (cls == float.class) { float[] buf = (float[])value; write(offset, buf, 0, buf.length); } else if (cls == double.class) { double[] buf = (double[])value; write(offset, buf, 0, buf.length); } else if (Pointer.class.isAssignableFrom(cls)) { Pointer[] buf = (Pointer[])value; write(offset, buf, 0, buf.length); } else if (Structure.class.isAssignableFrom(cls)) { Structure[] sbuf = (Structure[])value; if (Structure.ByReference.class.isAssignableFrom(cls)) { Pointer[] buf = new Pointer[sbuf.length]; for (int i=0;i < sbuf.length;i++) { buf[i] = sbuf[i] == null ? null : sbuf[i].getPointer(); sbuf[i].write(); } write(offset, buf, 0, buf.length); } else { for (int i=0;i < sbuf.length;i++) { if (sbuf[i] == null) { sbuf[i] = Structure.newInstance(cls); } sbuf[i].useMemory(this, (int)(offset + i * sbuf[i].size())); sbuf[i].write(); } } } else if (NativeMapped.class.isAssignableFrom(cls)) { NativeMapped[] buf = (NativeMapped[])value; NativeMappedConverter tc = NativeMappedConverter.getInstance(cls); Class nativeType = tc.nativeType(); int size = Native.getNativeSize(value.getClass(), value) / buf.length; for (int i=0;i < buf.length;i++) { Object element = tc.toNative(buf[i], new ToNativeContext()); setValue(offset + i*size, element, nativeType); } } else { throw new IllegalArgumentException("Writing array of " + cls + " to memory not supported"); } } /** Write value to the requested bank of memory. * @param offset byte offset from pointer to start * @param length number of bytes to write * @param value value to be written */ public void setMemory(long offset, long length, byte value) { _setMemory(peer + offset, length, value); } static native void _setMemory(long addr, long length, byte value); /** * Set value at location being pointed to. This is equivalent * to the expression * *((jbyte *)((char *)Pointer + offset)) = value. * * @param offset byte offset from pointer at which value * must be set * @param value byte value to set */ public void setByte(long offset, byte value) { _setByte(peer + offset, value); } private static native void _setByte(long addr, byte value); /** * Set value at location being pointed to. This is equivalent * to the expression * *((jshort *)((char *)Pointer + offset)) = value. * * @param offset byte offset from pointer at which value * must be set * @param value short value to set */ public void setShort(long offset, short value) { _setShort(peer + offset, value); } private static native void _setShort(long addr, short value); /** * Set value at location being pointed to. This is equivalent * to the expression * *((wchar_t *)((char *)Pointer + offset)) = value. * * @param offset byte offset from pointer at which value * must be set * @param value char value to set */ public void setChar(long offset, char value) { _setChar(peer + offset, value); } private static native void _setChar(long addr, char value); /** * Set value at location being pointed to. This is equivalent * to the expression * *((jint *)((char *)Pointer + offset)) = value. * * @param offset byte offset from pointer at which value * must be set * @param value int value to set */ public void setInt(long offset, int value) { _setInt(peer + offset, value); } private static native void _setInt(long addr, int value); /** * Set value at location being pointed to. This is equivalent * to the expression * *((jlong *)((char *)Pointer + offset)) = value. * * @param offset byte offset from pointer at which value * must be set * @param value long value to set */ public void setLong(long offset, long value) { _setLong(peer + offset, value); } private static native void _setLong(long addr, long value); /** * Set value at location being pointed to. This is equivalent * to the expression * *((long *)((char *)Pointer + offset)) = value. * * @param offset byte offset from pointer at which value * must be set * @param value long value to set */ public void setNativeLong(long offset, NativeLong value) { if (NativeLong.SIZE == 8) { setLong(offset, value.longValue()); } else { setInt(offset, value.intValue()); } } /** * Set value at location being pointed to. This is equivalent * to the expression * *((jfloat *)((char *)Pointer + offset)) = value. * * @param offset byte offset from pointer at which value * must be set * @param value float value to set */ public void setFloat(long offset, float value) { _setFloat(peer + offset, value); } private static native void _setFloat(long addr, float value); /** * Set value at location being pointed to. This is equivalent * to the expression * *((jdouble *)((char *)Pointer + offset)) = value. * * @param offset byte offset from pointer at which value * must be set * @param value double value to set */ public void setDouble(long offset, double value) { _setDouble(peer + offset, value); } private static native void _setDouble(long addr, double value); /** * Set value at location being pointed to. This is equivalent * to the expression * *((void **)((char *)Pointer + offset)) = value. * * @param offset byte offset from pointer at which value * must be set * @param value Pointer holding the actual pointer value to * set, which may be null to indicate a NULL * pointer. */ public void setPointer(long offset, Pointer value) { _setPointer(peer + offset, value != null ? value.peer : 0); } private static native void _setPointer(long addr, long value); /** * Copy string value to the location being pointed to. Copy * each element in value, converted to native encoding, at an * offsetfrom the location pointed to by this pointer. * * @param offset byte offset from pointer at which characters in * value must be set * @param value java.lang.String value to set * @param wide whether to write the native string as an array of * wchar_t. If false, writes as a NUL-terminated array of * char using the default platform encoding. */ public void setString(long offset, String value, boolean wide) { _setString(peer + offset, value, wide); } private static native void _setString(long addr, String value, boolean wide); /** * Copy string value to the location being pointed to. Copy * each element in value, converted to native encoding, at an * offsetfrom the location pointed to by this pointer. * Uses the value of the system property jna.encoding, if set, * to determine the appropriate native charset in which to encode the value. * If the property is not set, uses the default platform encoding. * * @param offset byte offset from pointer at which characters in * value must be set * @param value java.lang.String value to set */ public void setString(long offset, String value) { byte[] data = Native.getBytes(value); write(offset, data, 0, data.length); setByte(offset + data.length, (byte)0); } public String toString() { return "native@0x" + Long.toHexString(peer); } /** Read the native peer value. Use with caution. */ public static long nativeValue(Pointer p) { return p.peer; } /** Set the native peer value. Use with caution. */ public static void nativeValue(Pointer p, long value) { p.peer = value; } /** Pointer which disallows all read/write access. */ private static class Opaque extends Pointer { private Opaque(long peer) { super(peer); } private final String MSG = "This pointer is opaque: " + this; public long indexOf(long offset, byte value) { throw new UnsupportedOperationException(MSG); } public void read(long bOff, byte[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public void read(long bOff, char[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public void read(long bOff, short[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public void read(long bOff, int[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public void read(long bOff, long[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public void read(long bOff, float[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public void read(long bOff, double[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public void write(long bOff, byte[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public void write(long bOff, char[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public void write(long bOff, short[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public void write(long bOff, int[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public void write(long bOff, long[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public void write(long bOff, float[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public void write(long bOff, double[] buf, int index, int length) { throw new UnsupportedOperationException(MSG); } public byte getByte(long bOff) { throw new UnsupportedOperationException(MSG); } public char getChar(long bOff) { throw new UnsupportedOperationException(MSG); } public short getShort(long bOff) { throw new UnsupportedOperationException(MSG); } public int getInt(long bOff) { throw new UnsupportedOperationException(MSG); } public long getLong(long bOff) { throw new UnsupportedOperationException(MSG); } public float getFloat(long bOff) { throw new UnsupportedOperationException(MSG); } public double getDouble(long bOff) { throw new UnsupportedOperationException(MSG); } public Pointer getPointer(long bOff) { throw new UnsupportedOperationException(MSG); } public String getString(long bOff, boolean wide) { throw new UnsupportedOperationException(MSG); } public void setByte(long bOff, byte value) { throw new UnsupportedOperationException(MSG); } public void setChar(long bOff, char value) { throw new UnsupportedOperationException(MSG); } public void setShort(long bOff, short value) { throw new UnsupportedOperationException(MSG); } public void setInt(long bOff, int value) { throw new UnsupportedOperationException(MSG); } public void setLong(long bOff, long value) { throw new UnsupportedOperationException(MSG); } public void setFloat(long bOff, float value) { throw new UnsupportedOperationException(MSG); } public void setDouble(long bOff, double value) { throw new UnsupportedOperationException(MSG); } public void setPointer(long offset, Pointer value) { throw new UnsupportedOperationException(MSG); } public void setString(long offset, String value, boolean wide) { throw new UnsupportedOperationException(MSG); } public String toString() { return "opaque@0x" + Long.toHexString(peer); } } } libjna-java-3.2.7/src/com/sun/jna/Function.java0000644000175000017500000010032711340722124017354 0ustar janjan/* 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; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collections; import java.util.Map; /** * An abstraction for a native function pointer. An instance of * Function represents a pointer to some native function. * {@link #invoke(Class,Object[],Map)} is the primary means to call * the function.

* * Function call behavior may be modified by passing one of the following call * flags: *

    *
  • {@link Function#C_CONVENTION} Use C calling convention (default) *
  • {@link Function#ALT_CONVENTION} Use alternate calling convention (e.g. stdcall) *
  • {@link Function#THROW_LAST_ERROR} Throw a {@link LastErrorException} if * the native function sets the system error to a non-zero value (errno or * GetLastError). Setting this flag will cause the system error to be cleared * prior to native function invocation. *
* * @author Sheng Liang, originator * @author Todd Fast, suitability modifications * @author Timothy Wall * @see Pointer */ public class Function extends Pointer { /** Any argument which implements this interface will have the * {@link #read} method called immediately after function invocation. */ public interface PostCallRead { /** Perform any necessary post-call synchronization. Normally this * just means reading from native memory any changes made by * the native function call. */ void read(); } /** Maximum number of arguments supported by a JNA function call. */ public static final int MAX_NARGS = 256; /** Standard C calling convention. */ public static final int C_CONVENTION = 0; /** First alternate convention (currently used only for w32 stdcall). */ public static final int ALT_CONVENTION = 1; private static final int MASK_CC = 0x3; /** Whether to throw an exception if last error is non-zero after call. */ public static final int THROW_LAST_ERROR = (1<<2); static final Integer INTEGER_TRUE = new Integer(-1); static final Integer INTEGER_FALSE = new Integer(0); /** * Obtain a Function representing a native * function that follows the standard "C" calling convention. * *

The allocated instance represents a pointer to the named native * function from the named library, called with the standard "C" calling * convention. * * @param libraryName * Library in which to find the native function * @param functionName * Name of the native function to be linked with * @throws {@link UnsatisfiedLinkError} if the library is not found or * the given function name is not found within the library. */ public static Function getFunction(String libraryName, String functionName) { return NativeLibrary.getInstance(libraryName).getFunction(functionName); } /** * Obtain a Function representing a native * function. * *

The allocated instance represents a pointer to the named native * function from the named library. * * @param libraryName * Library in which to find the function * @param functionName * Name of the native function to be linked with * @param callFlags * Function call flags * * @throws {@link UnsatisfiedLinkError} if the library is not found or * the given function name is not found within the library. */ public static Function getFunction(String libraryName, String functionName, int callFlags) { return NativeLibrary.getInstance(libraryName).getFunction(functionName, callFlags); } /** * Obtain a Function representing a native * function pointer. In general, this function should be used by dynamic * languages; Java code should allow JNA to bind to a specific Callback * interface instead by defining a return type or Structure field type. * *

The allocated instance represents a pointer to the native * function pointer. * * @param p Native function pointer */ public static Function getFunction(Pointer p) { return getFunction(p, 0); } /** * Obtain a Function representing a native * function pointer. In general, this function should be used by dynamic * languages; Java code should allow JNA to bind to a specific Callback * interface instead by defining a return type or Structure field type. * *

The allocated instance represents a pointer to the native * function pointer. * * @param p * Native function pointer * @param callFlags * Function call flags */ public static Function getFunction(Pointer p, int callFlags) { return new Function(p, callFlags); } // Keep a reference to the NativeLibrary so it does not get garbage // collected until the function is private NativeLibrary library; private final String functionName; int callFlags; final Map options; /** For internal JNA use. */ static final String OPTION_INVOKING_METHOD = "invoking-method"; /** * Create a new Function that is linked with a native * function that follows the given calling convention. * *

The allocated instance represents a pointer to the named native * function from the supplied library, called with the given calling * convention. * * @param library * {@link NativeLibrary} in which to find the function * @param functionName * Name of the native function to be linked with * @param callFlags * Function call flags * @throws {@link UnsatisfiedLinkError} if the given function name is * not found within the library. */ Function(NativeLibrary library, String functionName, int callFlags) { checkCallingConvention(callFlags & MASK_CC); if (functionName == null) throw new NullPointerException("Function name must not be null"); this.library = library; this.functionName = functionName; this.callFlags = callFlags; this.options = library.options; try { this.peer = library.getSymbolAddress(functionName); } catch(UnsatisfiedLinkError e) { throw new UnsatisfiedLinkError("Error looking up function '" + functionName + "': " + e.getMessage()); } } /** * Create a new Function that is linked with a native * function that follows the given calling convention. * *

The allocated instance represents a pointer to the given * function address, called with the given calling * convention. * * @param functionAddress * Address of the native function * @param callFlags * Function call flags */ Function(Pointer functionAddress, int callFlags) { checkCallingConvention(callFlags & MASK_CC); if (functionAddress == null || functionAddress.peer == 0) { throw new NullPointerException("Function address may not be null"); } this.functionName = functionAddress.toString(); this.callFlags = callFlags; this.peer = functionAddress.peer; this.options = Collections.EMPTY_MAP; } private void checkCallingConvention(int convention) throws IllegalArgumentException { switch(convention) { case C_CONVENTION: case ALT_CONVENTION: break; default: throw new IllegalArgumentException("Unrecognized calling convention: " + convention); } } public String getName() { return functionName; } public int getCallingConvention() { return callFlags & MASK_CC; } /** Invoke the native function with the given arguments, returning the * native result as an Object. */ public Object invoke(Class returnType, Object[] inArgs) { return invoke(returnType, inArgs, this.options); } /** Invoke the native function with the given arguments, returning the * native result as an Object. */ public Object invoke(Class returnType, Object[] inArgs, Map options) { // Clone the argument array to obtain a scratch space for modified // types/values Object[] args = { }; if (inArgs != null) { if (inArgs.length > MAX_NARGS) { throw new UnsupportedOperationException("Maximum argument count is " + MAX_NARGS); } args = new Object[inArgs.length]; System.arraycopy(inArgs, 0, args, 0, args.length); } TypeMapper mapper = (TypeMapper)options.get(Library.OPTION_TYPE_MAPPER); Method invokingMethod = (Method)options.get(OPTION_INVOKING_METHOD); boolean allowObjects = Boolean.TRUE.equals(options.get(Library.OPTION_ALLOW_OBJECTS)); for (int i=0; i < args.length; i++) { args[i] = convertArgument(args, i, invokingMethod, mapper, allowObjects); } Class nativeType = returnType; FromNativeConverter resultConverter = null; if (NativeMapped.class.isAssignableFrom(returnType)) { NativeMappedConverter tc = NativeMappedConverter.getInstance(returnType); resultConverter = tc; nativeType = tc.nativeType(); } else if (mapper != null) { resultConverter = mapper.getFromNativeConverter(returnType); if (resultConverter != null) { nativeType = resultConverter.nativeType(); } } Object result = invoke(args, nativeType, allowObjects); // Convert the result to a custom value/type if appropriate if (resultConverter != null) { FromNativeContext context; if (invokingMethod != null) { context = new MethodResultContext(returnType, this, inArgs, invokingMethod); } else { context = new FunctionResultContext(returnType, this, inArgs); } result = resultConverter.fromNative(result, context); } // Sync all memory which might have been modified by the native call if (inArgs != null) { for (int i=0; i < inArgs.length; i++) { Object inArg = inArgs[i]; if (inArg == null) continue; if (inArg instanceof Structure) { if (!(inArg instanceof Structure.ByValue)) { ((Structure)inArg).autoRead(); } } else if (args[i] instanceof PostCallRead) { ((PostCallRead)args[i]).read(); if (args[i] instanceof PointerArray) { PointerArray array = (PointerArray)args[i]; if (Structure.ByReference[].class.isAssignableFrom(inArg.getClass())) { Class type = inArg.getClass().getComponentType(); Structure[] ss = (Structure[])inArg; for (int si=0;si < ss.length;si++) { Pointer p = array.getPointer(Pointer.SIZE * si); ss[si] = Structure.updateStructureByReference(type, ss[si], p); } } } } else if (Structure[].class.isAssignableFrom(inArg.getClass())) { Structure.autoRead((Structure[])inArg); } } } return result; } /** @see NativeLibrary#NativeLibrary(String,String,long,Map) implementation */ Object invoke(Object[] args, Class returnType, boolean allowObjects) { Object result = null; if (returnType == null || returnType==void.class || returnType==Void.class) { invokeVoid(callFlags, args); result = null; } else if (returnType==boolean.class || returnType==Boolean.class) { result = valueOf(invokeInt(callFlags, args) != 0); } else if (returnType==byte.class || returnType==Byte.class) { result = new Byte((byte)invokeInt(callFlags, args)); } else if (returnType==short.class || returnType==Short.class) { result = new Short((short)invokeInt(callFlags, args)); } else if (returnType==char.class || returnType==Character.class) { result = new Character((char)invokeInt(callFlags, args)); } else if (returnType==int.class || returnType==Integer.class) { result = new Integer(invokeInt(callFlags, args)); } else if (returnType==long.class || returnType==Long.class) { result = new Long(invokeLong(callFlags, args)); } else if (returnType==float.class || returnType==Float.class) { result = new Float(invokeFloat(callFlags, args)); } else if (returnType==double.class || returnType==Double.class) { result = new Double(invokeDouble(callFlags, args)); } else if (returnType==String.class) { result = invokeString(callFlags, args, false); } else if (returnType==WString.class) { String s = invokeString(callFlags, args, true); if (s != null) { result = new WString(s); } } else if (Pointer.class.isAssignableFrom(returnType)) { result = invokePointer(callFlags, args); } else if (Structure.class.isAssignableFrom(returnType)) { if (Structure.ByValue.class.isAssignableFrom(returnType)) { Structure s = invokeStructure(callFlags, args, Structure.newInstance(returnType)); s.autoRead(); result = s; } else { result = invokePointer(callFlags, args); if (result != null) { Structure s = Structure.newInstance(returnType); s.useMemory((Pointer)result); s.autoRead(); result = s; } } } else if (Callback.class.isAssignableFrom(returnType)) { result = invokePointer(callFlags, args); if (result != null) { result = CallbackReference.getCallback(returnType, (Pointer)result); } } else if (returnType==String[].class) { Pointer p = invokePointer(callFlags, args); if (p != null) { result = p.getStringArray(0); } } else if (returnType==WString[].class) { Pointer p = invokePointer(callFlags, args); if (p != null) { String[] arr = p.getStringArray(0, true); WString[] warr = new WString[arr.length]; for (int i=0;i < arr.length;i++) { warr[i] = new WString(arr[i]); } result = warr; } } else if (returnType==Pointer[].class) { Pointer p = invokePointer(callFlags, args); if (p != null) { result = p.getPointerArray(0); } } else if (allowObjects) { result = invokeObject(callFlags, args); if (result != null && !returnType.isAssignableFrom(result.getClass())) { throw new ClassCastException("Return type " + returnType + " does not match result " + result.getClass()); } } else { throw new IllegalArgumentException("Unsupported return type " + returnType + " in function " + getName()); } return result; } private Object convertArgument(Object[] args, int index, Method invokingMethod, TypeMapper mapper, boolean allowObjects) { Object arg = args[index]; if (arg != null) { Class type = arg.getClass(); ToNativeConverter converter = null; if (NativeMapped.class.isAssignableFrom(type)) { converter = NativeMappedConverter.getInstance(type); } else if (mapper != null) { converter = mapper.getToNativeConverter(type); } if (converter != null) { ToNativeContext context; if (invokingMethod != null) { context = new MethodParameterContext(this, args, index, invokingMethod) ; } else { context = new FunctionParameterContext(this, args, index); } arg = converter.toNative(arg, context); } } if (arg == null || isPrimitiveArray(arg.getClass())) { return arg; } Class argClass = arg.getClass(); // Convert Structures to native pointers if (arg instanceof Structure) { Structure struct = (Structure)arg; struct.autoWrite(); if (struct instanceof Structure.ByValue) { // Double-check against the method signature, if available Class ptype = struct.getClass(); if (invokingMethod != null) { Class[] ptypes = invokingMethod.getParameterTypes(); if (isVarArgs(invokingMethod)) { if (index < ptypes.length-1) { ptype = ptypes[index]; } else { Class etype = ptypes[ptypes.length-1].getComponentType(); if (etype != Object.class) { ptype = etype; } } } else { ptype = ptypes[index]; } } if (Structure.ByValue.class.isAssignableFrom(ptype)) { return struct; } } return struct.getPointer(); } // Convert Callback to Pointer else if (arg instanceof Callback) { return CallbackReference.getFunctionPointer((Callback)arg); } // String arguments are converted to native pointers here rather // than in native code so that the values will be valid until // this method returns. // Convert String to native pointer (const) else if (arg instanceof String) { return new NativeString((String)arg, false).getPointer(); } // Convert WString to native pointer (const) else if (arg instanceof WString) { return new NativeString(arg.toString(), true).getPointer(); } // Default conversion of boolean to int; if you want something // different, use a ToNativeConverter else if (arg instanceof Boolean) { return Boolean.TRUE.equals(arg) ? INTEGER_TRUE : INTEGER_FALSE; } else if (String[].class == argClass) { return new StringArray((String[])arg); } else if (WString[].class == argClass) { return new StringArray((WString[])arg); } else if (Pointer[].class == argClass) { return new PointerArray((Pointer[])arg); } else if (NativeMapped[].class.isAssignableFrom(argClass)) { return new NativeMappedArray((NativeMapped[])arg); } else if (Structure[].class.isAssignableFrom(argClass)) { Structure[] ss = (Structure[])arg; Class type = argClass.getComponentType(); boolean byRef = Structure.ByReference.class.isAssignableFrom(type); if (byRef) { Pointer[] pointers = new Pointer[ss.length + 1]; for (int i=0;i < ss.length;i++) { pointers[i] = ss[i] != null ? ss[i].getPointer() : null; } return new PointerArray(pointers); } else if (ss.length == 0) { throw new IllegalArgumentException("Structure array must have non-zero length"); } else if (ss[0] == null) { Structure.newInstance(type).toArray(ss); return ss[0].getPointer(); } else { Structure.autoWrite(ss); return ss[0].getPointer(); } } else if (argClass.isArray()){ throw new IllegalArgumentException("Unsupported array argument type: " + argClass.getComponentType()); } else if (allowObjects) { return arg; } else if (!Native.isSupportedNativeType(arg.getClass())) { throw new IllegalArgumentException("Unsupported argument type " + arg.getClass().getName() + " at parameter " + index + " of function " + getName()); } return arg; } private boolean isPrimitiveArray(Class argClass) { return argClass.isArray() && argClass.getComponentType().isPrimitive(); } /** * Call the native function being represented by this object * * @param callFlags calling convention to be used * @param args * Arguments to pass to the native function * @return The value returned by the target native function */ private native int invokeInt(int callFlags, Object[] args); /** * Call the native function being represented by this object * * @param callFlags calling convention to be used * @param args * Arguments to pass to the native function * @return The value returned by the target native function */ private native long invokeLong(int callFlags, Object[] args); /** * Call the native function being represented by this object * * @param args * Arguments to pass to the native function */ public void invoke(Object[] args) { invoke(Void.class, args); } /** * Call the native function being represented by this object * * @param callFlags calling convention to be used * @param args * Arguments to pass to the native function */ private native void invokeVoid(int callFlags, Object[] args); /** * Call the native function being represented by this object * * @param callFlags calling convention to be used * @param args * Arguments to pass to the native function * @return The value returned by the target native function */ private native float invokeFloat(int callFlags, Object[] args); /** * Call the native function being represented by this object * * @param callFlags calling convention to be used * @param args * Arguments to pass to the native function * @return The value returned by the target native function */ private native double invokeDouble(int callFlags, Object[] args); /** * Call the native function being represented by this object * * @param callFlags calling convention to be used * @param args * Arguments to pass to the native function * @param wide whether the native string uses wchar_t; * if false, char is assumed * @return The value returned by the target native function, as a String */ private String invokeString(int callFlags, Object[] args, boolean wide) { Pointer ptr = invokePointer(callFlags, args); String s = null; if (ptr != null) { if (wide) s = ptr.getString(0, wide); else s = ptr.getString(0); } return s; } /** * Call the native function being represented by this object * * @param callFlags calling convention to be used * @param args * Arguments to pass to the native function * @return The native pointer returned by the target native function */ private native Pointer invokePointer(int callFlags, Object[] args); /** * Call the native function being represented by this object, returning * a struct by value. * * @param callFlags calling convention to be used * @param args * Arguments to pass to the native function * @param result Pre-allocated structure to hold the result * @return The passed-in struct argument */ private native Structure invokeStructure(int callFlags, Object[] args, Structure result); /** * Call the native function being represented by this object, returning * a Java Object. * * @param callFlags calling convention to be used * @param args * Arguments to pass to the native function * @return The returned Java Object */ private native Object invokeObject(int callFlags, Object[] args); /** Provide a human-readable representation of this object. */ public String toString() { if (library != null) { return "native function " + functionName + "(" + library.getName() + ")@0x" + Long.toHexString(peer); } return "native function@0x" + Long.toHexString(peer); } /** Convenience method for * {@link #invoke(Class,Object[]) invokeObject(Object.class, args)}. */ public Object invokeObject(Object[] args) { return invoke(Object.class, args); } /** Convenience method for * {@link #invoke(Class,Object[]) invoke(Pointer.class, args)}. */ public Pointer invokePointer(Object[] args) { return (Pointer)invoke(Pointer.class, args); } /** Convenience method for * {@link #invoke(Class,Object[]) invoke(String.class, args)} * or {@link #invoke(Class,Object[]) invoke(WString.class, args)} * @param args Arguments passed to native function * @param wide Whether the return value is of type wchar_t*; * if false, the return value is of type char*. */ public String invokeString(Object[] args, boolean wide) { Object o = invoke(wide ? WString.class : String.class, args); return o != null ? o.toString() : null; } /** Convenience method for * {@link #invoke(Class,Object[]) invoke(Integer.class, args)}. */ public int invokeInt(Object[] args) { return ((Integer)invoke(Integer.class, args)).intValue(); } /** Convenience method for * {@link #invoke(Class,Object[]) invoke(Long.class, args)}. */ public long invokeLong(Object[] args) { return ((Long)invoke(Long.class, args)).longValue(); } /** Convenience method for * {@link #invoke(Class,Object[]) invoke(Float.class, args)}. */ public float invokeFloat(Object[] args) { return ((Float)invoke(Float.class, args)).floatValue(); } /** Convenience method for * {@link #invoke(Class,Object[]) invoke(Double.class, args)}. */ public double invokeDouble(Object[] args) { return ((Double)invoke(Double.class, args)).doubleValue(); } /** Convenience method for * {@link #invoke(Class,Object[]) invoke(Void.class, args)}. */ public void invokeVoid(Object[] args) { invoke(Void.class, args); } /** Two function pointers are equal if they share the same peer address * and calling convention. */ public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o.getClass() == getClass()) { Function other = (Function)o; return other.callFlags == this.callFlags && other.options.equals(this.options) && other.peer == this.peer; } return false; } /** Concatenate varargs with normal args to obtain a simple argument * array. */ static Object[] concatenateVarArgs(Object[] inArgs) { // If the final argument is an array of something other than // primitives, Structure, or String, treat it as varargs and // concatenate the previous arguments with the varargs elements. if (inArgs != null && inArgs.length > 0) { Object lastArg = inArgs[inArgs.length-1]; Class argType = lastArg != null ? lastArg.getClass() : null; if (argType != null && argType.isArray()) { Object[] varArgs = (Object[])lastArg; Object[] fullArgs = new Object[inArgs.length+varArgs.length]; System.arraycopy(inArgs, 0, fullArgs, 0, inArgs.length-1); System.arraycopy(varArgs, 0, fullArgs, inArgs.length-1, varArgs.length); // For convenience, always append a NULL argument to the end // of varargs, whether the called API requires it or not. If // it is not needed, it will be ignored, but if it *is* // required, it avoids forcing the Java client to always // explicitly add it. fullArgs[fullArgs.length-1] = null; inArgs = fullArgs; } } return inArgs; } /** Varargs are only supported on 1.5+. */ static boolean isVarArgs(Method m) { try { Method v = m.getClass().getMethod("isVarArgs", new Class[0]); return Boolean.TRUE.equals(v.invoke(m, new Object[0])); } catch (SecurityException e) { } catch (NoSuchMethodException e) { } catch (IllegalArgumentException e) { } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { } return false; } private static class NativeMappedArray extends Memory implements PostCallRead { private final NativeMapped[] original; public NativeMappedArray(NativeMapped[] arg) { super(Native.getNativeSize(arg.getClass(), arg)); this.original = arg; Class nativeType = arg.getClass().getComponentType(); setValue(0, original, original.getClass()); } public void read() { getValue(0, original.getClass(), original); } } private static class PointerArray extends Memory implements PostCallRead { private final Pointer[] original; public PointerArray(Pointer[] arg) { super(Pointer.SIZE * (arg.length+1)); this.original = arg; for (int i=0;i < arg.length;i++) { setPointer(i*Pointer.SIZE, arg[i]); } setPointer(Pointer.SIZE*arg.length, null); } public void read() { read(0, original, 0, original.length); } } /** Implementation of Boolean.valueOf for older VMs. */ static Boolean valueOf(boolean b) { return b ? Boolean.TRUE : Boolean.FALSE; } } libjna-java-3.2.7/src/com/sun/jna/NativeLong.java0000644000175000017500000000214010753020502017625 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; /** Represents the long C data type, which may be 32 or 64 bits * on *nix-based systems. * * @author wmeissner@gmail.com */ public class NativeLong extends IntegerType { /** Size of a native long, in bytes. */ public static final int SIZE = Native.LONG_SIZE; /** Create a zero-valued NativeLong. */ public NativeLong() { this(0); } /** Create a NativeLong with the given value. */ public NativeLong(long value) { super(SIZE, value); } } libjna-java-3.2.7/src/com/sun/jna/CallbackReference.java0000644000175000017500000005756111234610414021115 0ustar janjan/* Copyright (c) 2007-2008 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. * * 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; import java.lang.ref.WeakReference; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; /** Provides a reference to an association between a native callback closure * and a Java {@link Callback} closure. */ class CallbackReference extends WeakReference { static final Map callbackMap = new WeakHashMap(); static final Map directCallbackMap = new WeakHashMap(); static final Map allocations = new WeakHashMap(); private static final Method PROXY_CALLBACK_METHOD; static { try { PROXY_CALLBACK_METHOD = CallbackProxy.class.getMethod("callback", new Class[] { Object[].class }); } catch(Exception e) { throw new Error("Error looking up CallbackProxy.callback() method"); } } /** Return a Callback associated with the given function pointer. * If the pointer refers to a Java callback trampoline, return the original * Java Callback. Otherwise, return a proxy to the native function pointer. */ public static Callback getCallback(Class type, Pointer p) { return getCallback(type, p, false); } private static Callback getCallback(Class type, Pointer p, boolean direct) { if (p == null) { return null; } if (!type.isInterface()) throw new IllegalArgumentException("Callback type must be an interface"); Map map = direct ? directCallbackMap : callbackMap; synchronized(map) { for (Iterator i=map.keySet().iterator();i.hasNext();) { Callback cb = (Callback)i.next(); if (type.isAssignableFrom(cb.getClass())) { CallbackReference cbref = (CallbackReference)map.get(cb); Pointer cbp = cbref != null ? cbref.getTrampoline() : getNativeFunctionPointer(cb); if (p.equals(cbp)) { return cb; } } } int ctype = AltCallingConvention.class.isAssignableFrom(type) ? Function.ALT_CONVENTION : Function.C_CONVENTION; Map foptions = new HashMap(); Map options = Native.getLibraryOptions(type); if (options != null) { foptions.putAll(options); } foptions.put(Function.OPTION_INVOKING_METHOD, getCallbackMethod(type)); NativeFunctionHandler h = new NativeFunctionHandler(p, ctype, foptions); Callback cb = (Callback)Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, h); map.put(cb, null); return cb; } } Pointer cbstruct; // Keep a reference to the proxy to avoid premature GC of it CallbackProxy proxy; Method method; private CallbackReference(Callback callback, int callingConvention, boolean direct) { super(callback); TypeMapper mapper = Native.getTypeMapper(callback.getClass()); Class[] nativeParamTypes; Class returnType; // Check whether direct mapping may be used, or whether // we need to fall back to conventional mapping String arch = System.getProperty("os.arch").toLowerCase(); boolean ppc = "ppc".equals(arch) || "powerpc".equals(arch); if (direct) { Method m = getCallbackMethod(callback); Class[] ptypes = m.getParameterTypes(); for (int i=0;i < ptypes.length;i++) { // varargs w/FP args via ffi_call fails on ppc (darwin) if (ppc && (ptypes[i] == float.class || ptypes[i] == double.class)) { direct = false; break; } // No TypeMapper support in native callback code if (mapper != null && mapper.getFromNativeConverter(ptypes[i]) != null) { direct = false; break; } } if (mapper != null && mapper.getToNativeConverter(m.getReturnType()) != null) { direct = false; } } if (direct) { method = getCallbackMethod(callback); nativeParamTypes = method.getParameterTypes(); returnType = method.getReturnType(); cbstruct = createNativeCallback(callback, method, nativeParamTypes, returnType, callingConvention, true); } else { if (callback instanceof CallbackProxy) { proxy = (CallbackProxy)callback; } else { proxy = new DefaultCallbackProxy(getCallbackMethod(callback), mapper); } nativeParamTypes = proxy.getParameterTypes(); returnType = proxy.getReturnType(); // Generate a list of parameter types that the native code can // handle. Let the CallbackProxy do any further conversion // to match the true Java callback method signature if (mapper != null) { for (int i=0;i < nativeParamTypes.length;i++) { FromNativeConverter rc = mapper.getFromNativeConverter(nativeParamTypes[i]); if (rc != null) { nativeParamTypes[i] = rc.nativeType(); } } ToNativeConverter tn = mapper.getToNativeConverter(returnType); if (tn != null) { returnType = tn.nativeType(); } } for (int i=0;i < nativeParamTypes.length;i++) { nativeParamTypes[i] = getNativeType(nativeParamTypes[i]); if (!isAllowableNativeType(nativeParamTypes[i])) { String msg = "Callback argument " + nativeParamTypes[i] + " requires custom type conversion"; throw new IllegalArgumentException(msg); } } returnType = getNativeType(returnType); if (!isAllowableNativeType(returnType)) { String msg = "Callback return type " + returnType + " requires custom type conversion"; throw new IllegalArgumentException(msg); } cbstruct = createNativeCallback(proxy, PROXY_CALLBACK_METHOD, nativeParamTypes, returnType, callingConvention, false); } } private Class getNativeType(Class cls) { if (Structure.class.isAssignableFrom(cls)) { // Make sure we can instantiate an argument of this type Structure.newInstance(cls); if (!Structure.ByValue.class.isAssignableFrom(cls)) return Pointer.class; } else if (NativeMapped.class.isAssignableFrom(cls)) { return NativeMappedConverter.getInstance(cls).nativeType(); } else if (cls == String.class || cls == WString.class || cls == String[].class || cls == WString[].class || Callback.class.isAssignableFrom(cls)) { return Pointer.class; } return cls; } private static Method checkMethod(Method m) { if (m.getParameterTypes().length > Function.MAX_NARGS) { String msg = "Method signature exceeds the maximum " + "parameter count: " + m; throw new UnsupportedOperationException(msg); } return m; } /** Find the first instance of an interface which implements the Callback * interface or an interface derived from Callback, which defines an * appropriate callback method. */ static Class findCallbackClass(Class type) { if (!Callback.class.isAssignableFrom(type)) { throw new IllegalArgumentException(type.getName() + " is not derived from com.sun.jna.Callback"); } if (type.isInterface()) { return type; } Class[] ifaces = type.getInterfaces(); for (int i=0;i < ifaces.length;i++) { if (Callback.class.isAssignableFrom(ifaces[i])) { try { // Make sure it's got a recognizable callback method getCallbackMethod(ifaces[i]); return ifaces[i]; } catch(IllegalArgumentException e) { break; } } } if (Callback.class.isAssignableFrom(type.getSuperclass())) { return findCallbackClass(type.getSuperclass()); } return type; } private static Method getCallbackMethod(Callback callback) { return getCallbackMethod(findCallbackClass(callback.getClass())); } private static Method getCallbackMethod(Class cls) { // Look at only public methods defined by the Callback class Method[] pubMethods = cls.getDeclaredMethods(); Method[] classMethods = cls.getMethods(); Set pmethods = new HashSet(Arrays.asList(pubMethods)); pmethods.retainAll(Arrays.asList(classMethods)); // Remove Object methods disallowed as callback method names for (Iterator i=pmethods.iterator();i.hasNext();) { Method m = (Method)i.next(); if (Callback.FORBIDDEN_NAMES.contains(m.getName())) { i.remove(); } } Method[] methods = (Method[])pmethods.toArray(new Method[pmethods.size()]); if (methods.length == 1) { return checkMethod(methods[0]); } for (int i=0;i < methods.length;i++) { Method m = methods[i]; if (Callback.METHOD_NAME.equals(m.getName())) { return checkMethod(m); } } String msg = "Callback must implement a single public method, " + "or one public method named '" + Callback.METHOD_NAME + "'"; throw new IllegalArgumentException(msg); } /** Obtain a pointer to the native glue code for this callback. */ public Pointer getTrampoline() { return cbstruct.getPointer(0); } /** Free native resources associated with this callback. */ protected void finalize() { freeNativeCallback(cbstruct.peer); cbstruct.peer = 0; } private Callback getCallback() { return (Callback)get(); } private static Pointer getNativeFunctionPointer(Callback cb) { if (Proxy.isProxyClass(cb.getClass())) { Object handler = Proxy.getInvocationHandler(cb); if (handler instanceof NativeFunctionHandler) { return ((NativeFunctionHandler)handler).getPointer(); } } return null; } /** Return a {@link Pointer} to the native function address for the * given callback. */ public static Pointer getFunctionPointer(Callback cb) { return getFunctionPointer(cb, false); } /** Native code calls this with direct=true. */ private static Pointer getFunctionPointer(Callback cb, boolean direct) { Pointer fp = null; if (cb == null) { return null; } if ((fp = getNativeFunctionPointer(cb)) != null) { return fp; } int callingConvention = cb instanceof AltCallingConvention ? Function.ALT_CONVENTION : Function.C_CONVENTION; Map map = direct ? directCallbackMap : callbackMap; synchronized(map) { CallbackReference cbref = (CallbackReference)map.get(cb); if (cbref == null) { cbref = new CallbackReference(cb, callingConvention, direct); map.put(cb, cbref); } return cbref.getTrampoline(); } } private class DefaultCallbackProxy implements CallbackProxy { private Method callbackMethod; private ToNativeConverter toNative; private FromNativeConverter[] fromNative; public DefaultCallbackProxy(Method callbackMethod, TypeMapper mapper) { this.callbackMethod = callbackMethod; Class[] argTypes = callbackMethod.getParameterTypes(); Class returnType = callbackMethod.getReturnType(); fromNative = new FromNativeConverter[argTypes.length]; if (NativeMapped.class.isAssignableFrom(returnType)) { toNative = NativeMappedConverter.getInstance(returnType); } else if (mapper != null) { toNative = mapper.getToNativeConverter(returnType); } for (int i=0;i < fromNative.length;i++) { if (NativeMapped.class.isAssignableFrom(argTypes[i])) { fromNative[i] = new NativeMappedConverter(argTypes[i]); } else if (mapper != null) { fromNative[i] = mapper.getFromNativeConverter(argTypes[i]); } } if (!callbackMethod.isAccessible()) { try { callbackMethod.setAccessible(true); } catch(SecurityException e) { throw new IllegalArgumentException("Callback method is inaccessible, make sure the interface is public: " + callbackMethod); } } } private Object invokeCallback(Object[] args) { Class[] paramTypes = callbackMethod.getParameterTypes(); Object[] callbackArgs = new Object[args.length]; // convert basic supported types to appropriate Java parameter types for (int i=0;i < args.length;i++) { Class type = paramTypes[i]; Object arg = args[i]; if (fromNative[i] != null) { FromNativeContext context = new CallbackParameterContext(type, callbackMethod, args, i); callbackArgs[i] = fromNative[i].fromNative(arg, context); } else { callbackArgs[i] = convertArgument(arg, type); } } Object result = null; Callback cb = getCallback(); if (cb != null) { try { result = convertResult(callbackMethod.invoke(cb, callbackArgs)); } catch (IllegalArgumentException e) { Native.getCallbackExceptionHandler().uncaughtException(cb, e); } catch (IllegalAccessException e) { Native.getCallbackExceptionHandler().uncaughtException(cb, e); } catch (InvocationTargetException e) { Native.getCallbackExceptionHandler().uncaughtException(cb, e.getTargetException()); } } // Synch any structure arguments back to native memory for (int i=0;i < callbackArgs.length;i++) { if (callbackArgs[i] instanceof Structure && !(callbackArgs[i] instanceof Structure.ByValue)) { ((Structure)callbackArgs[i]).autoWrite(); } } return result; } /** Called from native code. All arguments are in an array of * Object as the first argument. Converts all arguments to types * required by the actual callback method signature, and converts * the result back into an appropriate native type. * This method must not throw exceptions. */ public Object callback(Object[] args) { try { return invokeCallback(args); } catch (Throwable t) { Native.getCallbackExceptionHandler().uncaughtException(getCallback(), t); return null; } } /** Convert argument from its basic native type to the given * Java parameter type. */ private Object convertArgument(Object value, Class dstType) { if (value instanceof Pointer) { if (dstType == String.class) { value = ((Pointer)value).getString(0); } else if (dstType == WString.class) { value = new WString(((Pointer)value).getString(0, true)); } else if (dstType == String[].class || dstType == WString[].class) { value = ((Pointer)value).getStringArray(0, dstType == WString[].class); } else if (Callback.class.isAssignableFrom(dstType)) { value = getCallback(dstType, (Pointer)value); } else if (Structure.class.isAssignableFrom(dstType)) { Structure s = Structure.newInstance(dstType); // If passed by value, don't hold onto the pointer, which // is only valid for the duration of the callback call if (Structure.ByValue.class.isAssignableFrom(dstType)) { byte[] buf = new byte[s.size()]; ((Pointer)value).read(0, buf, 0, buf.length); s.getPointer().write(0, buf, 0, buf.length); } else { s.useMemory((Pointer)value); } s.read(); value = s; } } else if ((boolean.class == dstType || Boolean.class == dstType) && value instanceof Number) { value = Function.valueOf(((Number)value).intValue() != 0); } return value; } private Object convertResult(Object value) { if (toNative != null) { value = toNative.toNative(value, new CallbackResultContext(callbackMethod)); } if (value == null) return null; Class cls = value.getClass(); if (Structure.class.isAssignableFrom(cls)) { if (Structure.ByValue.class.isAssignableFrom(cls)) { return value; } return ((Structure)value).getPointer(); } else if (cls == boolean.class || cls == Boolean.class) { return Boolean.TRUE.equals(value) ? Function.INTEGER_TRUE : Function.INTEGER_FALSE; } else if (cls == String.class || cls == WString.class) { return getNativeString(value, cls == WString.class); } else if (cls == String[].class || cls == WString.class) { StringArray sa = cls == String[].class ? new StringArray((String[])value) : new StringArray((WString[])value); // Delay GC until array itself is GC'd. allocations.put(value, sa); return sa; } else if (Callback.class.isAssignableFrom(cls)) { return getFunctionPointer((Callback)value); } return value; } public Class[] getParameterTypes() { return callbackMethod.getParameterTypes(); } public Class getReturnType() { return callbackMethod.getReturnType(); } } /** Provide invocation handling for an auto-generated Java interface proxy * for a native function pointer. * Cf. Library.Handler */ private static class NativeFunctionHandler implements InvocationHandler { private Function function; private Map options; public NativeFunctionHandler(Pointer address, int callingConvention, Map options) { this.function = new Function(address, callingConvention); this.options = options; } /** Chain invocation to the native function. */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (Library.Handler.OBJECT_TOSTRING.equals(method)) { String str = "Proxy interface to " + function; Method m = (Method)options.get(Function.OPTION_INVOKING_METHOD); Class cls = findCallbackClass(m.getDeclaringClass()); str += " (" + cls.getName() + ")"; return str; } else if (Library.Handler.OBJECT_HASHCODE.equals(method)) { return new Integer(hashCode()); } else if (Library.Handler.OBJECT_EQUALS.equals(method)) { Object o = args[0]; if (o != null && Proxy.isProxyClass(o.getClass())) { return Function.valueOf(Proxy.getInvocationHandler(o) == this); } return Boolean.FALSE; } if (Function.isVarArgs(method)) { args = Function.concatenateVarArgs(args); } return function.invoke(method.getReturnType(), args, options); } public Pointer getPointer() { return function; } } /** Returns whether the given class is supported in native code. * Other types (String, WString, Structure, arrays, NativeMapped, * etc) are supported in the Java library. */ private static boolean isAllowableNativeType(Class cls) { return cls == void.class || cls == Void.class || cls == boolean.class || cls == Boolean.class || cls == byte.class || cls == Byte.class || cls == short.class || cls == Short.class || cls == char.class || cls == Character.class || cls == int.class || cls == Integer.class || cls == long.class || cls == Long.class || cls == float.class || cls == Float.class || cls == double.class || cls == Double.class || (Structure.ByValue.class.isAssignableFrom(cls) && Structure.class.isAssignableFrom(cls)) || Pointer.class.isAssignableFrom(cls); } private static Pointer getNativeString(Object value, boolean wide) { if (value != null) { NativeString ns = new NativeString(value.toString(), wide); // Delay GC until string itself is GC'd. allocations.put(value, ns); return ns.getPointer(); } return null; } /** Create a native trampoline to delegate execution to the Java callback. */ private static synchronized native Pointer createNativeCallback(Callback callback, Method method, Class[] parameterTypes, Class returnType, int callingConvention, boolean direct); /** Free the given callback trampoline. */ private static synchronized native void freeNativeCallback(long ptr); } libjna-java-3.2.7/src/com/sun/jna/FunctionMapper.java0000644000175000017500000000346110753020502020520 0ustar janjan/* 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. * * 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; import java.lang.reflect.Method; /** Provides mapping of Java method names to native function names. * An instance of this interface may be provided to * {@link Native#loadLibrary(String, Class, java.util.Map)} as an entry in * the options map with key {@link Library#OPTION_FUNCTION_MAPPER}. *

* There are several circumstances where this option might prove useful. *

    *
  • C preprocessor macros are used to allow C code to refer to a library * function by a different name *
  • Generated linker symbols are different than those used in C code. * Windows stdcall functions, for instance, are exported with a * special suffix that describes the stack size of the function arguments * (see {@link com.sun.jna.win32.StdCallFunctionMapper}). *
  • The naming of the C library methods conflicts horribly with your * Java coding standards, or are otherwise hard to follow. It's generally * better to keep the original function names in this case, to avoid confusion * about what's actually being called, but the option is available. *
* * @see Library#OPTION_FUNCTION_MAPPER */ public interface FunctionMapper { String getFunctionName(NativeLibrary library, Method method); } libjna-java-3.2.7/src/com/sun/jna/FunctionResultContext.java0000644000175000017500000000223510753020502022115 0ustar janjan/* 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. * * 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; /** Provide result conversion context for a function call. */ public class FunctionResultContext extends FromNativeContext { private Function function; private Object[] args; FunctionResultContext(Class resultClass, Function function, Object[] args) { super(resultClass); this.function = function; this.args = args; } /** Get the function that was invoked. */ public Function getFunction() { return function; } /** Get the arguments used in this function call. */ public Object[] getArguments() { return args; } } libjna-java-3.2.7/src/com/sun/jna/TypeConverter.java0000644000175000017500000000140710753020504020377 0ustar janjan/* 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. * * 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; /** Convenience interface for bidirectional conversion. * @author Wayne Meissner */ public interface TypeConverter extends FromNativeConverter, ToNativeConverter {} libjna-java-3.2.7/src/com/sun/jna/CallbackParameterContext.java0000644000175000017500000000225110753020476022476 0ustar janjan/* 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. * * 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; import java.lang.reflect.Method; /** Provide argument conversion context for a callback invocation. */ public class CallbackParameterContext extends FromNativeContext { private Method method; private Object[] args; private int index; CallbackParameterContext(Class javaType, Method m, Object[] args, int index) { super(javaType); this.method = m; this.args = args; this.index = index; } public Method getMethod() { return method; } public Object[] getArguments() { return args; } public int getIndex() { return index; } } libjna-java-3.2.7/src/com/sun/jna/Platform.java0000644000175000017500000000660411224550756017371 0ustar janjan/* * 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; /** Provide simplified platform information. */ public final class Platform { public static final int UNSPECIFIED = -1; public static final int MAC = 0; public static final int LINUX = 1; public static final int WINDOWS = 2; public static final int SOLARIS = 3; public static final int FREEBSD = 4; public static final int OPENBSD = 5; public static final int WINDOWSCE = 6; private static final int osType; static { String osName = System.getProperty("os.name"); if (osName.startsWith("Linux")) { osType = LINUX; } else if (osName.startsWith("Mac") || osName.startsWith("Darwin")) { osType = MAC; } else if (osName.startsWith("Windows CE")) { osType = WINDOWSCE; } else if (osName.startsWith("Windows")) { osType = WINDOWS; } else if (osName.startsWith("Solaris") || osName.startsWith("SunOS")) { osType = SOLARIS; } else if (osName.startsWith("FreeBSD")) { osType = FREEBSD; } else if (osName.startsWith("OpenBSD")) { osType = OPENBSD; } else { osType = UNSPECIFIED; } } private Platform() { } public static final int getOSType() { return osType; } public static final boolean isMac() { return osType == MAC; } public static final boolean isLinux() { return osType == LINUX; } public static final boolean isWindowsCE() { return osType == WINDOWSCE; } public static final boolean isWindows() { return osType == WINDOWS || osType == WINDOWSCE; } public static final boolean isSolaris() { return osType == SOLARIS; } public static final boolean isFreeBSD() { return osType == FREEBSD; } public static final boolean isOpenBSD() { return osType == OPENBSD; } public static final boolean isX11() { // TODO: check filesystem for /usr/X11 or some other X11-specific test return !Platform.isWindows() && !Platform.isMac(); } public static final boolean deleteNativeLibraryAfterVMExit() { return osType == WINDOWS; } public static final boolean hasRuntimeExec() { if (isWindowsCE() && "J9".equals(System.getProperty("java.vm.name"))) return false; return true; } public static final boolean is64Bit() { String model = System.getProperty("sun.arch.data.model"); if (model != null) return "64".equals(model); String arch = System.getProperty("os.arch").toLowerCase(); if ("x86_64".equals(arch) || "ppc64".equals(arch) || "sparcv9".equals(arch) || "amd64".equals(arch)) { return true; } return Native.POINTER_SIZE == 8; } } libjna-java-3.2.7/src/com/sun/jna/CallbackProxy.java0000644000175000017500000000242511155215156020333 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; /** Placeholder proxy interface to allow an InvocationHandler to convert * arguments/return values on callback methods. This is a special sub-interface * of {@link Callback} which expects its arguments in a single Object array * passed to its {@link #callback} method. */ public interface CallbackProxy extends Callback { /** This is the callback method invoked from native code. * It must not throw any exceptions whatsoever. */ Object callback(Object[] args); /** Returns the types of the parameters to the callback method. */ Class[] getParameterTypes(); /** Returns the type of the callback method's return value. */ Class getReturnType(); }libjna-java-3.2.7/src/com/sun/jna/TypeMapper.java0000644000175000017500000000177110753020504017660 0ustar janjan/* 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. * * 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; /** Provides converters for conversion to and from native types. */ public interface TypeMapper { /** Return the {@link FromNativeConverter} appropriate for the given Java class. */ FromNativeConverter getFromNativeConverter(Class javaType); /** Return the {@link ToNativeConverter} appropriate for the given Java class. */ ToNativeConverter getToNativeConverter(Class javaType); } libjna-java-3.2.7/src/com/sun/jna/InvocationMapper.java0000644000175000017500000000621110753020502021040 0ustar janjanpackage com.sun.jna; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; /** Provide a method for overriding how a given function is invoked. * An instance of this interface may be provided to * {@link Native#loadLibrary(String, Class, java.util.Map)} as an entry in * the options map with key {@link Library#OPTION_INVOCATION_MAPPER}.

* This is useful for implementing inlined functions, or functions which * are actually C preprocessor macros. Given a native library and JNA * interface method, the mapper may provide a handler which implements the * desired functionality (which may or may not actually make use of a * native method). *

* For example, the GNU C library remaps the stat function * into a call to _xstat with a slight rearrangement of arguments. * A mapper for the GNU C library might look like the following:
*

*
 * new InvocationMapper() {
 *     public InvocationHandler getInvocationHandler(NativeLibrary lib, Method m) {
 *         if (m.getName().equals("stat")) {
 *             final Function f = lib.getFunction("_xstat");
 *             return new InvocationHandler() {
 *                 public Object invoke(Object proxy, Method method, Object[] args) {
 *                     Object[] newArgs = new Object[args.length+1];
 *                     System.arraycopy(args, 0, newArgs, 1, args.length);
 *                     newArgs[0] = new Integer(3); // _xstat version
 *                     return f.invoke(newArgs);
 *                 }
 *             };
 *         }
 *         return null;
 *     } 
 * } 
 * 
*
* Another situation is where a header provides a function-like macro or * inline function definition. *
*
 * // Original C code (macro and inline variations)
 * #define allocblock(x) malloc(x * 1024)
 * static inline void* allocblock(size_t x) { return malloc(x * 1024); }
 * 
 * // Invocation mapping
 * new InvocationMapper() {
 *     public InvocationHandler getInvocationHandler(NativeLibrary lib, Method m) {
 *         if (m.getName().equals("allocblock")) {
 *             final Function f = lib.getFunction("malloc");
 *             return new InvocationHandler() {
 *                 public Object invoke(Object proxy, Method method, Object[] args) {
 *                     args[0] = ((Integer)args[0]).intValue() * 1024;
 *                     return f.invoke(newArgs);
 *                 }
 *             };
 *         }
 *         return null;
 *     } 
 * } 
 * 
*
* @author twall */ public interface InvocationMapper { /** Return an {@link InvocationHandler} responsible for handling the * invocation of the given method, or null if the default * handling should be used. Note that the result of a call to this method * with a given library and method may be cached. * @param lib Target library * @param m Original JNA interface method that was invoked. */ InvocationHandler getInvocationHandler(NativeLibrary lib, Method m); } libjna-java-3.2.7/src/com/sun/jna/NativeMappedConverter.java0000644000175000017500000000535211234610414022036 0ustar janjan/* 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. * * 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; import java.util.Map; import java.util.WeakHashMap; /** Provides type conversion for instances of {@link NativeMapped}. */ public class NativeMappedConverter implements TypeConverter { private static Map converters = new WeakHashMap(); private final Class type; private final Class nativeType; private final NativeMapped instance; public static NativeMappedConverter getInstance(Class cls) { synchronized(converters) { NativeMappedConverter nmc = (NativeMappedConverter)converters.get(cls); if (nmc == null) { nmc = new NativeMappedConverter(cls); converters.put(cls, nmc); } return nmc; } } public NativeMappedConverter(Class type) { if (!NativeMapped.class.isAssignableFrom(type)) throw new IllegalArgumentException("Type must derive from " + NativeMapped.class); this.type = type; this.instance = defaultValue(); this.nativeType = instance.nativeType(); } public NativeMapped defaultValue() { try { return (NativeMapped)type.newInstance(); } catch (InstantiationException e) { String msg = "Can't create an instance of " + type + ", requires a no-arg constructor: " + e; throw new IllegalArgumentException(msg); } catch (IllegalAccessException e) { String msg = "Not allowed to create an instance of " + type + ", requires a public, no-arg constructor: " + e; throw new IllegalArgumentException(msg); } } public Object fromNative(Object nativeValue, FromNativeContext context) { return instance.fromNative(nativeValue, context); } public Class nativeType() { return nativeType; } public Object toNative(Object value, ToNativeContext context) { if (value == null) { if (Pointer.class.isAssignableFrom(nativeType)) { return null; } value = defaultValue(); } return ((NativeMapped)value).toNative(); } }libjna-java-3.2.7/src/com/sun/jna/MethodParameterContext.java0000644000175000017500000000177010753020502022215 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; import java.lang.reflect.Method; public class MethodParameterContext extends FunctionParameterContext { private Method method; MethodParameterContext(Function f, Object[] args, int index, Method m) { super(f, args, index); this.method = m; } /** Get the Method in the Library instance the Function was called from. */ public Method getMethod() { return method; } } libjna-java-3.2.7/src/com/sun/jna/win32/0000755000175000017500000000000011351761024015667 5ustar janjanlibjna-java-3.2.7/src/com/sun/jna/win32/W32APIOptions.java0000644000175000017500000000146411351761024021020 0ustar janjanpackage com.sun.jna.win32; import java.util.HashMap; import java.util.Map; import com.sun.jna.Library; public interface W32APIOptions extends StdCallLibrary { /** Standard options to use the unicode version of a w32 API. */ Map UNICODE_OPTIONS = new HashMap() { { put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE); put(OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE); } }; /** Standard options to use the ASCII/MBCS version of a w32 API. */ Map ASCII_OPTIONS = new HashMap() { { put(OPTION_TYPE_MAPPER, W32APITypeMapper.ASCII); put(OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.ASCII); } }; Map DEFAULT_OPTIONS = Boolean.getBoolean("w32.ascii") ? ASCII_OPTIONS : UNICODE_OPTIONS; } libjna-java-3.2.7/src/com/sun/jna/win32/StdCall.java0000644000175000017500000000140510753020504020054 0ustar janjan/* 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. *

* 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.win32; import com.sun.jna.AltCallingConvention; /** Tagging interface for __stdcall calling convention. */ public interface StdCall extends AltCallingConvention {} libjna-java-3.2.7/src/com/sun/jna/win32/StdCallLibrary.java0000644000175000017500000000234010753020504021400 0ustar janjan/* 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. *

* 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.win32; import com.sun.jna.Callback; import com.sun.jna.Function; import com.sun.jna.FunctionMapper; import com.sun.jna.Library; /** Interface for w32 stdcall calling convention. */ public interface StdCallLibrary extends Library, StdCall { /** Constant identifying the w32 stdcall calling convention. */ int STDCALL_CONVENTION = Function.ALT_CONVENTION; /** Provides auto-lookup of stdcall-decorated names. */ FunctionMapper FUNCTION_MAPPER = new StdCallFunctionMapper(); /** Interface defining a callback using the w32 stdcall calling convention. */ interface StdCallCallback extends Callback, StdCall { } } libjna-java-3.2.7/src/com/sun/jna/win32/W32APIFunctionMapper.java0000644000175000017500000000323510753020504022311 0ustar janjan/* 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. * * 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.win32; import java.lang.reflect.Method; import com.sun.jna.FunctionMapper; import com.sun.jna.NativeLibrary; /** Encapsulates lookup of W32 API UNICODE/ASCII functions. */ public class W32APIFunctionMapper implements FunctionMapper { public static final FunctionMapper UNICODE = new W32APIFunctionMapper(true); public static final FunctionMapper ASCII = new W32APIFunctionMapper(false); private final String suffix; protected W32APIFunctionMapper(boolean unicode) { this.suffix = unicode ? "W" : "A"; } /** Looks up the method name by adding a "W" or "A" suffix as appropriate. */ public String getFunctionName(NativeLibrary library, Method method) { String name = method.getName(); if (!name.endsWith("W") && !name.endsWith("A")) { try { name = library.getFunction(name + suffix, StdCallLibrary.STDCALL_CONVENTION).getName(); } catch(UnsatisfiedLinkError e) { // ignore and let caller use undecorated name } } return name; } } libjna-java-3.2.7/src/com/sun/jna/win32/W32APITypeMapper.java0000644000175000017500000000567311351761024021461 0ustar janjan/* 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. * * 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.win32; import java.util.HashMap; import java.util.Map; import com.sun.jna.DefaultTypeMapper; import com.sun.jna.FromNativeContext; import com.sun.jna.Pointer; import com.sun.jna.Library; import com.sun.jna.StringArray; import com.sun.jna.ToNativeContext; import com.sun.jna.TypeConverter; import com.sun.jna.TypeMapper; import com.sun.jna.WString; /** Provide standard conversion for W32 API types. This comprises the * following native types: *

    *
  • Unicode or ASCII/MBCS strings and arrays of string, as appropriate *
  • BOOL *
* @author twall */ public class W32APITypeMapper extends DefaultTypeMapper { public static final TypeMapper UNICODE = new W32APITypeMapper(true); public static final TypeMapper ASCII = new W32APITypeMapper(false); protected W32APITypeMapper(boolean unicode) { if (unicode) { TypeConverter stringConverter = new TypeConverter() { public Object toNative(Object value, ToNativeContext context) { if (value == null) return null; if (value instanceof String[]) { return new StringArray((String[])value, true); } return new WString(value.toString()); } public Object fromNative(Object value, FromNativeContext context) { if (value == null) return null; return value.toString(); } public Class nativeType() { return WString.class; } }; addTypeConverter(String.class, stringConverter); addToNativeConverter(String[].class, stringConverter); } TypeConverter booleanConverter = new TypeConverter() { public Object toNative(Object value, ToNativeContext context) { return new Integer(Boolean.TRUE.equals(value) ? 1 : 0); } public Object fromNative(Object value, FromNativeContext context) { return ((Integer)value).intValue() != 0 ? Boolean.TRUE : Boolean.FALSE; } public Class nativeType() { // BOOL is 32-bit int return Integer.class; } }; addTypeConverter(Boolean.class, booleanConverter); } } libjna-java-3.2.7/src/com/sun/jna/win32/StdCallFunctionMapper.java0000644000175000017500000000557311220641326022742 0ustar janjan/* 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. * * 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.win32; import java.lang.reflect.Method; import java.nio.Buffer; import java.nio.ByteBuffer; import com.sun.jna.Callback; import com.sun.jna.FunctionMapper; import com.sun.jna.Native; import com.sun.jna.NativeLibrary; import com.sun.jna.NativeLong; import com.sun.jna.NativeMapped; import com.sun.jna.NativeMappedConverter; import com.sun.jna.Pointer; import com.sun.jna.PointerType; import com.sun.jna.Structure; import com.sun.jna.WString; /** Provides mapping from simple method names to w32 stdcall-decorated names * where the name suffix is "@" followed by the number of bytes popped by * the called function.

* NOTE: if you use custom type mapping for primitive types, you may need to * override {@link #getArgumentNativeStackSize(Class)}. */ public class StdCallFunctionMapper implements FunctionMapper { /** Override this to handle any custom class mappings. */ protected int getArgumentNativeStackSize(Class cls) { if (NativeMapped.class.isAssignableFrom(cls)) { cls = NativeMappedConverter.getInstance(cls).nativeType(); } if (cls.isArray()) { return Pointer.SIZE; } try { return Native.getNativeSize(cls); } catch(IllegalArgumentException e) { throw new IllegalArgumentException("Unknown native stack allocation size for " + cls); } } /** Convert the given Java method into a decorated stdcall name, * if possible. */ public String getFunctionName(NativeLibrary library, Method method) { String name = method.getName(); int pop = 0; Class[] argTypes = method.getParameterTypes(); for (int i=0;i < argTypes.length;i++) { pop += getArgumentNativeStackSize(argTypes[i]); } String decorated = name + "@" + pop; int conv = StdCallLibrary.STDCALL_CONVENTION; try { name = library.getFunction(decorated, conv).getName(); } catch(UnsatisfiedLinkError e) { // try with an explicit underscore try { name = library.getFunction("_" + decorated, conv).getName(); } catch(UnsatisfiedLinkError e2) { // not found; let caller try undecorated version } } return name; } }libjna-java-3.2.7/src/com/sun/jna/PointerType.java0000644000175000017500000000661411340722124020055 0ustar janjan/* 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. * * 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; /** Type representing a type-safe native pointer. * Derived classes may override the {@link NativeMapped#fromNative} method, * which should instantiate a new object (or look up an existing one) * of the appropriate type. */ public abstract class PointerType implements NativeMapped { private Pointer pointer; /** The default constructor wraps a NULL pointer. */ protected PointerType() { this.pointer = Pointer.NULL; } /** This constructor is typically used by {@link #fromNative} if generating * a new object instance. */ protected PointerType(Pointer p) { this.pointer = p; } /** All PointerType classes represent a native {@link Pointer}. */ public Class nativeType() { return Pointer.class; } /** Convert this object to its native type (a {@link Pointer}). */ public Object toNative() { return getPointer(); } /** Returns the associated native {@link Pointer}. */ public Pointer getPointer() { return pointer; } public void setPointer(Pointer p) { this.pointer = p; } /** The default implementation simply creates a new instance of the class * and assigns its pointer field. Override if you need different behavior, * such as ensuring a single {@link PointerType} instance for each unique * {@link Pointer} value, or instantiating a different {@link PointerType} * subclass. */ public Object fromNative(Object nativeValue, FromNativeContext context) { // Always pass along null pointer values if (nativeValue == null) { return null; } try { PointerType pt = (PointerType)getClass().newInstance(); pt.pointer = (Pointer)nativeValue; return pt; } catch (InstantiationException e) { throw new IllegalArgumentException("Can't instantiate " + getClass()); } catch (IllegalAccessException e) { throw new IllegalArgumentException("Not allowed to instantiate " + getClass()); } } /** The hash code for a PointerType is the same as that for * its pointer. */ public int hashCode() { return pointer != null ? pointer.hashCode() : 0; } /** Instances of PointerType with identical pointers compare * equal by default. */ public boolean equals(Object o) { if (o == this) return true; if (o instanceof PointerType) { Pointer p = ((PointerType)o).getPointer(); if (pointer == null) return p == null; return pointer.equals(p); } return false; } public String toString() { return pointer == null ? "NULL" : pointer.toString(); } } libjna-java-3.2.7/src/com/sun/jna/WString.java0000644000175000017500000000312711220633672017172 0ustar janjan/* 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. *

* 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; import java.nio.CharBuffer; /** Simple wrapper class to identify a wide string argument or return type. * @author twall@users.sf.net */ public final class WString implements CharSequence, Comparable { private String string; public WString(String s){ if (s == null) throw new NullPointerException("String initializer must be non-null"); this.string = s; } public String toString() { return string; } public boolean equals(Object o) { return o instanceof WString && toString().equals(o.toString()); } public int hashCode() { return toString().hashCode(); } public int compareTo(Object o) { return toString().compareTo(o.toString()); } public int length() { return toString().length(); } public char charAt(int index) { return toString().charAt(index); } public CharSequence subSequence(int start, int end) { return CharBuffer.wrap(toString()).subSequence(start, end); } } libjna-java-3.2.7/src/com/sun/jna/Memory.java0000644000175000017500000005517411372233152017053 0ustar janjan/* 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; import java.nio.ByteBuffer; import java.util.Map; import java.util.WeakHashMap; /** * A Pointer to memory obtained from the native heap via a * call to malloc. * *

In some cases it might be necessary to use memory obtained from * malloc. For example, Memory helps * accomplish the following idiom: *

 * 		void *buf = malloc(BUF_LEN * sizeof(char));
 *		call_some_function(buf);
 *		free(buf);
 * 
* *

The {@link #finalize} method will free allocated memory when * this object is no longer referenced. * * @author Sheng Liang, originator * @author Todd Fast, suitability modifications * @author Timothy Wall * @see Pointer */ public class Memory extends Pointer { private static Map buffers = new WeakHashMap(); protected long size; // Size of the malloc'ed space /** Force cleanup of memory that has associated NIO Buffers which have been GC'd. */ public static void purge() { buffers.size(); } /** Provide a view into the original memory. */ private class SharedMemory extends Memory { public SharedMemory(long offset) { this.size = Memory.this.size - offset; this.peer = Memory.this.peer + offset; } /** No need to free memory. */ protected void finalize() { } /** Pass bounds check to parent. */ protected void boundsCheck(long off, long sz) { Memory.this.boundsCheck(this.peer - Memory.this.peer + off, sz); } public String toString() { return super.toString() + " (shared from " + Memory.this.toString() + ")"; } } /** * Allocate space in the native heap via a call to C's malloc. * * @param size number of bytes of space to allocate */ public Memory(long size) { this.size = size; if (size <= 0) { throw new IllegalArgumentException("Allocation size must be greater than zero"); } peer = malloc(size); if (peer == 0) throw new OutOfMemoryError("Cannot allocate " + size + " bytes"); } protected Memory() { } /** Provide a view onto this structure from the given offset. The * returned {@link Pointer} will have the same size as the original, * reduced by the offset. * @throws IndexOutOfBoundsException if the requested memory is outside * the allocated bounds. */ public Pointer share(long offset) { return share(offset, getSize() - offset); } /** Provide a view onto this structure from the given offset. * @throws IndexOutOfBoundsException if the requested memory is outside * the allocated bounds. */ public Pointer share(long offset, long sz) { if (offset == 0 && sz == getSize()) return this; boundsCheck(offset, sz); return new SharedMemory(offset); } /** Provide a view onto this structure with the given alignment. * @param byteBoundary Align memory to this number of bytes; should be a * power of two. * @throws IndexOutOfBoundsException if the requested alignment can * not be met. * @throws IllegalArgumentException if the requested alignment is not * a positive power of two. */ public Memory align(int byteBoundary) { if (byteBoundary <= 0) { throw new IllegalArgumentException("Byte boundary must be positive: " + byteBoundary); } for (int i=0;i < 32;i++) { if (byteBoundary == (1< size) { String msg = "Bounds exceeds available space : size=" + size + ", offset=" + (off + sz); throw new IndexOutOfBoundsException(msg); } } ////////////////////////////////////////////////////////////////////////// // Raw read methods ////////////////////////////////////////////////////////////////////////// /** * Indirect the native pointer to malloc space, a la * Pointer.read. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#read(long,byte[],int,int) */ public void read(long bOff, byte[] buf, int index, int length) { boundsCheck(bOff, length * 1); super.read(bOff, buf, index, length); } /** * Indirect the native pointer to malloc space, a la * Pointer.read. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#read(long,short[],int,int) */ public void read(long bOff, short[] buf, int index, int length) { boundsCheck(bOff, length * 2); super.read(bOff, buf, index, length); } /** * Indirect the native pointer to malloc space, a la * Pointer.read. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#read(long,char[],int,int) */ public void read(long bOff, char[] buf, int index, int length) { boundsCheck(bOff, length * 2); super.read(bOff, buf, index, length); } /** * Indirect the native pointer to malloc space, a la * Pointer.read. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#read(long,int[],int,int) */ public void read(long bOff, int[] buf, int index, int length) { boundsCheck(bOff, length * 4); super.read(bOff, buf, index, length); } /** * Indirect the native pointer to malloc space, a la * Pointer.read. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#read(long,long[],int,int) */ public void read(long bOff, long[] buf, int index, int length) { boundsCheck(bOff, length * 8); super.read(bOff, buf, index, length); } /** * Indirect the native pointer to malloc space, a la * Pointer.read. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#read(long,float[],int,int) */ public void read(long bOff, float[] buf, int index, int length) { boundsCheck(bOff, length * 4); super.read(bOff, buf, index, length); } /** * Indirect the native pointer to malloc space, a la * Pointer.read. But this method performs a bounds checks to * ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#read(long,double[],int,int) */ public void read(long bOff, double[] buf, int index, int length) { boundsCheck(bOff, length * 8); super.read(bOff, buf, index, length); } ////////////////////////////////////////////////////////////////////////// // Raw write methods ////////////////////////////////////////////////////////////////////////// /** * Indirect the native pointer to malloc space, a la * Pointer.write. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#write(long,byte[],int,int) */ public void write(long bOff, byte[] buf, int index, int length) { boundsCheck(bOff, length * 1); super.write(bOff, buf, index, length); } /** * Indirect the native pointer to malloc space, a la * Pointer.write. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#write(long,short[],int,int) */ public void write(long bOff, short[] buf, int index, int length) { boundsCheck(bOff, length * 2); super.write(bOff, buf, index, length); } /** * Indirect the native pointer to malloc space, a la * Pointer.write. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#write(long,char[],int,int) */ public void write(long bOff, char[] buf, int index, int length) { boundsCheck(bOff, length * 2); super.write(bOff, buf, index, length); } /** * Indirect the native pointer to malloc space, a la * Pointer.write. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#write(long,int[],int,int) */ public void write(long bOff, int[] buf, int index, int length) { boundsCheck(bOff, length * 4); super.write(bOff, buf, index, length); } /** * Indirect the native pointer to malloc space, a la * Pointer.write. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#write(long,long[],int,int) */ public void write(long bOff, long[] buf, int index, int length) { boundsCheck(bOff, length * 8); super.write(bOff, buf, index, length); } /** * Indirect the native pointer to malloc space, a la * Pointer.write. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#write(long,float[],int,int) */ public void write(long bOff, float[] buf, int index, int length) { boundsCheck(bOff, length * 4); super.write(bOff, buf, index, length); } /** * Indirect the native pointer to malloc space, a la * Pointer.write. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#write(long,double[],int,int) */ public void write(long bOff, double[] buf, int index, int length) { boundsCheck(bOff, length * 8); super.write(bOff, buf, index, length); } ////////////////////////////////////////////////////////////////////////// // Java type read methods ////////////////////////////////////////////////////////////////////////// /** * Indirect the native pointer to malloc space, a la * Pointer.getByte. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#getByte(long) */ public byte getByte(long offset) { boundsCheck(offset, 1); return super.getByte(offset); } /** * Indirect the native pointer to malloc space, a la * Pointer.getByte. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#getByte(long) */ public char getChar(long offset) { boundsCheck(offset, 1); return super.getChar(offset); } /** * Indirect the native pointer to malloc space, a la * Pointer.getShort. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#getShort(long) */ public short getShort(long offset) { boundsCheck(offset, 2); return super.getShort(offset); } /** * Indirect the native pointer to malloc space, a la * Pointer.getInt. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#getInt(long) */ public int getInt(long offset) { boundsCheck(offset, 4); return super.getInt(offset); } /** * Indirect the native pointer to malloc space, a la * Pointer.getLong. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#getLong(long) */ public long getLong(long offset) { boundsCheck(offset, 8); return super.getLong(offset); } /** * Indirect the native pointer to malloc space, a la * Pointer.getFloat. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#getFloat(long) */ public float getFloat(long offset) { boundsCheck(offset, 4); return super.getFloat(offset); } /** * Indirect the native pointer to malloc space, a la * Pointer.getDouble. But this method performs a * bounds check to ensure that the indirection does not cause memory * outside the malloced space to be accessed. * * @see Pointer#getDouble(long) */ public double getDouble(long offset) { boundsCheck(offset, 8); return super.getDouble(offset); } /** * Indirect the native pointer to malloc space, a la * Pointer.getPointer. But this method performs * a bounds checks to ensure that the indirection does not cause memory * outside the malloced space to be accessed. * * @see Pointer#getPointer(long) */ public Pointer getPointer(long offset) { boundsCheck(offset, Pointer.SIZE); return super.getPointer(offset); } /** * Get a ByteBuffer mapped to a portion of this memory. * * @param offset byte offset from pointer to start the buffer * @param length Length of ByteBuffer * @return a direct ByteBuffer that accesses the memory being pointed to, */ public ByteBuffer getByteBuffer(long offset, long length) { boundsCheck(offset, length); ByteBuffer b = super.getByteBuffer(offset, length); // Ensure this Memory object will not be GC'd (and its memory freed) // if the Buffer is still extant. buffers.put(b, this); return b; } /** * Indirect the native pointer to malloc space, a la * Pointer.getString. But this method performs a * bounds checks to ensure that the indirection does not cause memory * outside the malloced space to be accessed. * * @see Pointer#getString(long, boolean) */ public String getString(long offset, boolean wide) { // NOTE: we only make sure the start of the string is within bounds boundsCheck(offset, 0); return super.getString(offset, wide); } ////////////////////////////////////////////////////////////////////////// // Java type write methods ////////////////////////////////////////////////////////////////////////// /** * Indirect the native pointer to malloc space, a la * Pointer.setByte. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#setByte */ public void setByte(long offset, byte value) { boundsCheck(offset, 1); super.setByte(offset, value); } /** * Indirect the native pointer to malloc space, a la * Pointer.setChar. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#setChar */ public void setChar(long offset, char value) { boundsCheck(offset, Native.WCHAR_SIZE); super.setChar(offset, value); } /** * Indirect the native pointer to malloc space, a la * Pointer.setShort. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#setShort */ public void setShort(long offset, short value) { boundsCheck(offset, 2); super.setShort(offset, value); } /** * Indirect the native pointer to malloc space, a la * Pointer.setInt. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#setInt */ public void setInt(long offset, int value) { boundsCheck(offset, 4); super.setInt(offset, value); } /** * Indirect the native pointer to malloc space, a la * Pointer.setLong. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#setLong */ public void setLong(long offset, long value) { boundsCheck(offset, 8); super.setLong(offset, value); } /** * Indirect the native pointer to malloc space, a la * Pointer.setFloat. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * malloced space to be accessed. * * @see Pointer#setFloat */ public void setFloat(long offset, float value) { boundsCheck(offset, 4); super.setFloat(offset, value); } /** * Indirect the native pointer to malloc space, a la * Pointer.setDouble. But this method performs a * bounds checks to ensure that the indirection does not cause memory * outside the malloced space to be accessed. * * @see Pointer#setDouble */ public void setDouble(long offset, double value) { boundsCheck(offset, 8); super.setDouble(offset, value); } /** * Indirect the native pointer to malloc space, a la * Pointer.setPointer. But this method performs * a bounds checks to ensure that the indirection does not cause memory * outside the malloced space to be accessed. * * @see Pointer#setPointer */ public void setPointer(long offset, Pointer value) { boundsCheck(offset, Pointer.SIZE); super.setPointer(offset, value); } /** * Indirect the native pointer to malloc space, a la * Pointer.setString. But this method performs a * bounds checks to ensure that the indirection does not cause memory * outside the malloced space to be accessed. * * @see Pointer#setString(long,String,boolean) */ public void setString(long offset, String value, boolean wide) { if (wide) boundsCheck(offset, (value.length() + 1) * Native.WCHAR_SIZE); else boundsCheck(offset, value.getBytes().length + 1); super.setString(offset, value, wide); } /** * Call the real native malloc */ protected static native long malloc(long size); /** * Call the real native free */ protected static native void free(long ptr); public String toString() { return "allocated@0x" + Long.toHexString(peer) + " (" + size + " bytes)"; } } libjna-java-3.2.7/src/com/sun/jna/NativeMapped.java0000644000175000017500000000241610753020502020142 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; /** Provide conversion for a Java type to and from a native type. * {@link Function} and {@link Structure} will use this interface to determine * how to map a given Java object into a native type.

* Implementations of this interface must provide a no-args constructor. * @author wmeissner */ public interface NativeMapped { /** Convert the given native object into its Java representation using * the given context. */ Object fromNative(Object nativeValue, FromNativeContext context); /** Convert this object into a supported native type. */ Object toNative(); /** Indicate the native type used by this converter. */ Class nativeType(); } libjna-java-3.2.7/src/com/sun/jna/overview.html0000644000175000017500000007643211231343207017471 0ustar janjan


Java Native Access

This document is the API specification for the JNA library for simplified native library access for Java.

Top  JNA Home  API w/FRAMES 

Java Native Access (JNA)

JNA provides simplified access to native library methods without requiring any additional JNI or native code.

Table of Contents

Top

Library Mapping

When you've determined which shared library holds the methods to which you need access, create a class corresponding to that library. For example, a mapping for the C library itself would look like one of the following:
// Alternative 1: interface-mapped class, dynamically load the C library
public interface CLibrary extends Library {
    CLibrary INSTANCE = (CLibrary)Native.loadLibrary("c", CLibrary.class);
}

// Alternative 2: direct-mapped class
public class CLibrary {
    static {
        Native.register("c");
    }
}
The String passed to the {@link com.sun.jna.Native#loadLibrary(String,Class)} (or {@link com.sun.jna.NativeLibrary#getInstance(String)}) method is the undecorated name of the shared library file. Here are some examples of library name mappings.

OSLibrary NameString
Windowsuser32.dlluser32
LinuxlibX11.soX11
Mac OS Xlibm.dylibm
Mac OS X Framework/System/Library/Frameworks/Carbon.framework/CarbonCarbon
Any Platform<current process>null

Any given native library with a unique filesystem path is represented by a single instance of {@link com.sun.jna.NativeLibrary} and obtained via {@link com.sun.jna.NativeLibrary#getInstance(String)}. The native library will be unloaded when no longer referenced by any Java code.

If the library name is null, your mappings will apply to the current process instead of a separately loaded library. This may help avoid conflicts if there are several incompatible versions of a library available.

The search path for loaded native libraries may be modified by setting jna.library.path and a few other properties. See {@link com.sun.jna.NativeLibrary} for details.

Table of Contents

Function Mapping

Function names are mapped directly from their Java interface name to the symbol exported by the native library. For instance, the function to convert an ASCII string into an integer would look like this:
public interface CLibrary extends Library {
    int atol(String s);
}
Alternatively, you can map directly to a declared native method:
public class CLibrary {
    public static native int atol(String s);
}
If you prefer to rename the Java methods to conform to Java coding conventions, then you can provide an entry ({@link com.sun.jna.Library#OPTION_FUNCTION_MAPPER}/{@link com.sun.jna.FunctionMapper}) in the options {@link java.util.Map} passed to {@link com.sun.jna.Native#loadLibrary(String,Class,java.util.Map) Native.loadLibrary()} which maps the Java names to the native names. While this keeps your Java code a little cleaner, the additional mapping of names may make it a little less obvious the native functions being called.

An instance of the {@link com.sun.jna.Function} class is obtained through the {@link com.sun.jna.NativeLibrary} instance corresponding to the containing native library. This {@link com.sun.jna.Function} instance handles argument marshalling and delegation to the native function.

Table of Contents

Marshalling/Unmarshalling (Java/Native Type Conversions)

Java types must be chosen to match native types of the same size. Following are the types supported by the JNA library.

C TypeNative RepresentationJava Type
char8-bit integerbyte
wchar_tplatform-dependentchar
short16-bit integershort
int32-bit integerint
intboolean flagboolean
enumenumeration typeint (usually)
long long, __int6464-bit integerlong
float32-bit floating pointfloat
double64-bit floating pointdouble
pointer (e.g. void*)platform-dependent (32- or 64-bit pointer to memory){@link java.nio.Buffer}
{@link com.sun.jna.Pointer}
pointer (e.g. void*),
array
32- or 64-bit pointer to memory (argument/return)
contiguous memory (struct member)
<P>[] (array of primitive type)
In addition to the above types, which are supported at the native layer, the JNA Java library automatically handles the following types. All but NativeMapped and NativeLong are converted to {@link com.sun.jna.Pointer} before being passed to the native layer.
longplatform-dependent (32- or 64-bit integer){@link com.sun.jna.NativeLong}
const char*NUL-terminated array (native encoding or jna.encoding){@link java.lang.String}
const wchar_t*NUL-terminated array (unicode){@link com.sun.jna.WString}
char**NULL-terminated array of C strings{@link java.lang.String String[]}
wchar_t**NULL-terminated array of wide C strings{@link com.sun.jna.WString WString[]}
void**NULL-terminated array of pointers{@link com.sun.jna.Pointer Pointer[]}
struct*
struct
pointer to struct (argument or return) ({@link com.sun.jna.Structure.ByReference or explicitly})
struct by value (member of struct) ({@link com.sun.jna.Structure.ByValue or explicitly})
{@link com.sun.jna.Structure}
unionsame as Structure{@link com.sun.jna.Union}
struct[]array of structs, contiguous in memory{@link com.sun.jna.Structure Structure[]}
void (*FP)()function pointer (Java or native){@link com.sun.jna.Callback}
pointer (<T> *)same as Pointer{@link com.sun.jna.PointerType}
otherinteger type{@link com.sun.jna.IntegerType}
othercustom mapping, depends on definition{@link com.sun.jna.NativeMapped}

NOTES

  • Unsigned values may be passed by assigning the corresponding two's-complement representation to the signed type of the same size.
  • Java arrays of primitive type may be wrapped by {@link java.nio.Buffer} in order to access a subset of the array (changing the effective size and/or offest).
  • Java arrays of primitive type are only valid for use within the scope of a single call. If the native code keeps a reference to the memory, use {@link com.sun.jna.Memory} or {@link java.nio.Buffer} instead.
  • Primitive arrays and structures as members of a structure are overlaid on the parent structure memory.
  • Bitfields must be manually packed into an integer type.
  • All other types must eventually be converted to one of the types in the this table. Methods with arguments or return values of types other than these must either use types deriving from {@link com.sun.jna.NativeMapped} or supply type conversion information for the unsupported types.
  • Type mapping behavior may be customized by providing a {@link com.sun.jna.TypeMapper} for the {@link com.sun.jna.Library#OPTION_TYPE_MAPPER} option when initializing a library interface. See {@link com.sun.jna.win32.W32APITypeMapper} for an example which provides custom conversion of boolean and String types. You are free to use whatever types are convenient in your defined interfaces, but all custom types must provide a mapping to one of the basic or derived types listed above.
  • Type mapping may also be customized on a per-class basis for user-defined types by making the user-defined type implement the {@link com.sun.jna.NativeMapped} interface.
  • Structure and Union are not converted to Pointer when passed by value.

Primitive Arrays

Java primitive arrays may be used wherever a native primitive array is used. Any changes made by the native code to an array during a function call will be reflected in the Java array. If the native code will use the array outside of the function call where the array is provided, {@link com.sun.jna.Memory} or {@link java.nio.Buffer} should be used instead (see Buffers).

To map a native multi-dimensional array, use a single-dimensional Java array with a number of elements equivalent to the full native array, e.g.

// Original C code
#define DIM0 2
#define DIM1 3
int array[DIM0][DIM1];
int i,j;

for (i=0;i < DIM0;i++) {
  for (j=0;j < DIM1;j++) {
    array[i][j] = i*DIM1 + j;
  }
}

// Equivalent JNA code
final int DIM0 = 2;
final int DIM1 = 3;
int[] array = new int[6];
for (int i=0;i < DIM0;i++) {
  for (int j=0;j < DIM1;j++) {
    array[i*DIM1 + j] = i*DIM1 + j;                   
  }                   
}

Pointers

Pointers may be used as an opaque type from which other data types may be extracted. The Pointer type is a reasonable fallback for any pointer-based type (including arrays). The user is generally not allowed to construct a Pointer de novo.

Type-safe pointers may be defined by deriving from the {@link com.sun.jna.PointerType} class. Any such user-defined type will be treated the same as a {@link com.sun.jna.Pointer}.

Strings

Java Strings perform the same function as the native types const char* and const wchar_t* (NUL-terminated arrays). In order to use the proper type when calling a native function, we have to introduce some sort of annotation to identify how the java String should be converted. Java Strings are normally converted to char* since this is the most common usage of strings. Strings are automatically converted to a NUL-terminated array of char across the function call. Returned char* values are automatically copied into a String if the method signature returns String (strdup, for example).

If the native method returns char* and actually allocates memory, a return type of {@link com.sun.jna.Pointer} should be used to avoid leaking the memory. It is then up to you to take the necessary steps to free the allocated memory.

When converting Java unicode characters into an array of char, the default platform encoding is used, unless the system property jna.encoding is set to a valid encoding. This property may be set to "UTF8", for example, to ensure all native strings use that encoding.

Arrays of String passed to native code (either as a function argument or callback return value) will be converted into a NULL-terminated array of char* (or wchar_t* in the case of an array of WString.

Wide Strings

The {@link com.sun.jna.WString} class is used to identify wide character strings. Unicode values are copied directly from the Java char array to a native wchar_t array.

Buffers/Memory Blocks

Use arrays to represent buffers of primitive types passed to a function for use only during the function invocation. A native method cannot return a Java array, since there is no canonical way to indicate the intended length of the returned array. Instead, use one of the array access methods in the Pointer class, supplying the length of the returned array.

{@link java.nio.Buffer}s may also be used as a memory buffer input argument; direct byte buffers can often provide much improved performance over primitive arrays. A pointer provided by native code may be converted to a {@link java.nio.Buffer} by calling {@link com.sun.jna.Pointer#getByteBuffer}.

If you need to pass in a subset of a primitive array, you can do so by wrapping it in a {@link java.nio.Buffer} subclass, such as {@link java.nio.ByteBuffer}, using the {@link java.nio.ByteBuffer#wrap(byte[],int,int)} method. Wrapping an array in a buffer also allows you to pass only a subset of a Java array to the native function.

Callbacks (Function Pointers)

JNA supports supplying Java callbacks to native code. You must define an interface that extends the {@link com.sun.jna.Callback} interface, and define a single callback method with a signature that matches the function pointer required by the native code. The name of the method may be something other than "callback" only if there is only a single method in the interface which extends Callback or the class which implements {@link com.sun.jna.Callback}. The arguments and return value follow the same rules as for a direct function invocation.

If the callback returns a String or String[], the returned memory will be valid until the returned object is GC'd.

If your native code initializes function pointers within a struct, JNA will automatically generate an Callback instance matching the declared type. This enables you to easily call the function supplied by native code using proper Java syntax.

// Original C code
struct _functions {
  int (*open)(const char*,int);
  int (*close)(int);
};

// Equivalent JNA mapping
public class Functions extends Structure {
  public static interface OpenFunc extends Callback {
    int invoke(String name, int options);
  }
  public static interface CloseFunc extends Callback {
    int invoke(int fd);
  }
  public OpenFunc open;
  public CloseFunc close;
}
...
Functions funcs = new Functions();
lib.init(funcs);
int fd = funcs.open.invoke("myfile", 0);
funcs.close.invoke(fd);
Callbacks may also be used as return values. Native function pointers are wrapped in a proxy implementing the declared Callback type, to facilitate calling from Java.
// Original C code
typedef void (*sig_t)(int);
sig_t signal(int signal, sig_t sigfunc);

// Equivalent JNA mapping
public interface CLibrary extends Library {
    public interface SignalFunction extends Callback {
        void invoke(int signal);
    }
    SignalFunction signal(int signal, SignalFunction func);
}

Varargs

The C varargs function definition may be mapped to a Java varargs method definition. For example,
// Original C code
extern int printf(const char* fmt, ...);

// Equivalent JNA mapping
interface CLibrary extends Library {
    int printf(String fmt, ...);
}

Structures

The Java {@link com.sun.jna.Structure} represents a native struct. By default, this type is treated as a pointer to structure (struct *) on the native side when used as a parameter or return value. When used as a structure field, the structure is interpreted as by value. To force the complementary interpretation, the tagging interfaces {@link com.sun.jna.Structure.ByValue} and {@link com.sun.jna.Structure.ByReference} are provided.

Pointer-to-Structure Arguments

To pass a pointer to a structure as an argument, simply use the Java structure subclass, and a pointer to native data memory will be used. The contents of the structure will be passed to the function and updated when the function returns. Structures are packed according to the default alignment rules for the platform's native C structs.
// Original C code
typedef struct _Point {
  int x, y;
} Point;

Point* translate(Point* pt, int dx, int dy);

// Equivalent JNA mapping
class Point extends Structure { public int x, y; }
Point translate(Point pt, int x, int y);
...
Point pt = new Point();
Point result = translate(pt, 100, 100);

Structure by Value Arguments/Return

To pass a structure by value, first define the structure, then define an empty class from that which implements {@link com.sun.jna.Structure.ByValue}. Use the ByValue class as the argument or return type.

// Original C code
typedef struct _Point {
  int x, y;
} Point;

Point translate(Point pt, int dx, int dy);

// Equivalent JNA mapping
class Point extends Structure {
    public static class ByValue extends Point implements Structure.ByValue { }
    public int x, y;
}
Point.ByValue translate(Point.ByValue pt, int x, int y);
...
Point.ByValue pt = new Point.ByValue();
Point result = translate(pt, 100, 100);

Array-of-Structure Arguments

To pass an array of structures, simply use a Java array of the desired structure type. If the array is uninitialized, it will be auto-initialized prior to the function call.

// Original C code
void get_devices(struct Device[], int size);

// Equivalent JNA mapping
int size = ...
Device[] devices = new Device[size];
lib.get_devices(devices, devices.length);
Alternatively, you can reallocate a single Structure instance into an array as follows:
Device dev = new Device();
// As an array of Structure
Structure[] structs = dev.toArray(size);
// As an array of Device
Device[] devices = (Device[])dev.toArray(size);

Returning an Array of struct

Declare the method as returning a {@link com.sun.jna.Structure} of the appropriate type, then invoke {@link com.sun.jna.Structure#toArray(int)} to convert to an array of initialized structures of the appropriate size. Note that your {@link com.sun.jna.Structure} class must have a no-args constructor, and you are responsible for freeing the returned memory if applicable in whatever way is appropriate for the called function.

// Original C code
struct Display* get_displays(int* pcount);
void free_displays(struct Display* displays);

// Equivalent JNA mapping
Display get_displays(IntByReference pcount);
void free_displays(Display[] displays);
...
IntByReference pcount = new IntByReference();
Display d = lib.get_displays(pcount);
Display[] displays = (Display[])d.toArray(pcount.getValue());
...
lib.free_displays(displays);

Nested Structure Definitions

Nested structures are treated as consecutive memory (as opposed to pointers to structures). For example:
// Original C code
typedef struct _Point {
  int x, y;
} Point;

typedef struct _Line {
  Point start;
  Point end;
} Line;

// Equivalent JNA mapping
class Point extends Structure {
  public int x, y;
}

class Line extends Structure {
  public Point start;
  public Point end;
}
Explicit initialization of nested structures is not required; the objects will be created as needed and properly mapped to the parent structure's memory.

If you need a pointer to a structure within your structure, you can use the {@link com.sun.jna.Structure.ByReference} tagging interface to indicate the field should be treated as a pointer instead of inlining the full structure.

// Original C code
typedef struct _Line2 {
  Point* p1;
  Point* p2;
} Line2;

// Equivalent JNA mapping
class Point extends Structure {
    public static class ByReference extends Point implements Structure.ByReference { }
    public int x, y;
}
class Line2 extends Structure {
  public Point.ByReference p1;
  public Point.ByReference p2;
}
The more general case is just a pointer to memory. This allows you to define the field without necessarily defining the inner structure itself, similar to declaring a struct without defining it in C:
// Original C code
typedef struct _Line2 {
  Point* p1;
  Point* p2;
} Line2;

// Equivalent JNA mapping
class Line2 extends Structure {
  public Pointer p1;
  public Pointer p2;
}

Line2 line2;
Point p1, p2;
...
line2.p1 = p1.getPointer();
line2.p2 = p2.getPointer();

Nested arrays

Structures with nested arrays require an explicit constructor to ensure the structure size is properly calculated.
typedef struct _Buffer {
  char buf1[32];
  char buf2[1024];
} Buffer;

class Buffer extends Structure {
  public byte[] buf1 = new byte[32];
  public byte[] buf2 = new byte[1024];
}
Calculation of the native size of the structure is deferred until the structure is actually used.

Variable-sized structures

Structures with variable size, or with primitive array elements, for example:
// Original C code
typedef struct _Header {
  int flags;
  int buf_length;
  char buffer[1];
} Header;
require a constructor which establishes the required size for the structure and initializes things appropriately. For example:
// Equivalent JNA mapping
class Header extends Structure {
  public int flags;
  public int buf_length;
  public byte[] buffer;
  public Header(int bufferSize) {
    buffer = new byte[bufferSize];
    buf_length = buffer.length;
    allocateMemory();
  }
}

Volatile fields

Normally, JNA will write the entire contents of a Structure prior to a function call and read back from native memory after the function call. Sometimes a structure field is not intended for client use, gets modified asynchronously by hardware, or otherwise is effectively read-only. If you expect any fields of the structure to be modified by any agent outside your Java program, you should mark the field volatile. This prevents JNA from automatically updating the native memory from the Java value. You can still force an update of the native memory from the Java value by calling {@link com.sun.jna.Structure#writeField(String)} for the field in question.
class Data extends com.sun.jna.Structure {
  public volatile int refCount;
  public int value;
}
...
Data data = new Data();
In the above example, the field refCount will only be written to native memory based on the Java value with a call to data.writeField("refCount"). To obtain the current state of native memory, call {@link com.sun.jna.Structure#read()} (to update the entire structure) or {@link com.sun.jna.Structure#readField(String) data.readField("refCount")} (to update just the refCount field).

Read-only fields

If you want to absolutely prevent Java code from modifying a Structure's contents, you may mark its fields final. Structure reads can still overwrite the values based on native memory contents, but no Java code will be able to modify any of the fields.
class ReadOnly extends com.sun.jna.Structure {
  // Do not initialize the field here, or the compiler will inline the value!
  public final int refCount;
  {
    // Initialize fields here, to ensure the values are not inlined
    refCount = -1;
    read();
    // refCount might now have a different value
  }
}
...
ReadOnly ro = new ReadOnly();
// Will not compile!
ro.refCount = 0;
Make certain you attend to the following:
  1. All final fields should be initialized in the constructor.
  2. If you call Structure.read() from anywhere but the constructor, keep in mind that the compiler and/or hotspot will be assuming field values will not change across that function call.

Unions

Unions are a special type of Structure. Each declared field within the union overlays the same space in native memory. When writing a union to native memory, you must specify which field is to be written by supplying the desired field's class to the {@link com.sun.jna.Union#setType} method. On read, all non-pointer-based fields will be initialized from native memory. Structure, String, and WString members will not be initialized unless they are selected via {@link com.sun.jna.Union#setType}.

Obtaining "last" error

If a function sets the system error property (errno or GetLastError()), the error code will be thrown as a {@link com.sun.jna.LastErrorException} if you declare the exception in your JNA mapping. Alternatively, you can use {@link com.sun.jna.Native#getLastError()} to retrieve it, providing that {@link com.sun.jna.Native#setPreserveLastError(boolean)} has been called with a true value. Throwing an exception is preferred since it has better performance.

Arbitrary Java Object arguments/return values

In some cases, such as invoking native VM functions directly, it is necessary to pass Java objects to the native methods. By default, JNA disallows using any Java object that is not explicitly supported unless it derives from {@link com.sun.jna.NativeMapped}, because it is generally unnecessary to use such objects and usually signals a programmer error. To avoid errors flagging the use of Java objects, use the library load option {@link com.sun.jna.Library#OPTION_ALLOW_OBJECTS} with Boolean.TRUE.

Table of Contents

Invocation Mapping

Sometimes native functions exist only as C preprocessor macros or as inline functions. If you need to do more than simply change the name of the invoked function (which can be handled via Function Mapping), an {@link com.sun.jna.InvocationMapper} allows you to arbitrarily reconfigure the function invocation, including changing the method name and reordering, adding, or removing arguments. See the {@link com.sun.jna.InvocationMapper} documentation for details.

Table of Contents

Library Global Data

The method {@link com.sun.jna.NativeLibrary#getGlobalVariableAddress} may be used to obtain the address of global variables as a {@link com.sun.jna.Pointer}. Pointer methods may then be used to read or write the value as appropriate for the variable type.

Table of Contents

VM Crash Protection

It is not uncommon when defining a new library and writing tests to encounter memory access errors which crash the VM. These are often caused by improper mappings or invalid arguments passed to the native library. To generate Java errors instead of crashing the VM, call {@link com.sun.jna.Native#setProtected Native.setProtected(true)}. Not all platforms support this protection; if not, the value of {@link com.sun.jna.Native#isProtected} will remain false.

NOTE: When protected mode is enabled, you should make use of the jsig library, if available (see Signal Chaining) to avoid interfering with the JVM's use of signals. In short, set the environment variable LD_PRELOAD (or LD_PRELOAD_64) to the path to libjsig.so in your JRE lib directory (usually ${java.home}/lib/${os.arch}/libjsig.so) before launching your Java application.

Table of Contents

Performance

Use direct mapping of methods

Using direct mapping of methods makes native calls more efficiently than does interface mapping. Direct mapping does not support varargs calls or arrays of Pointer, String, or WString as an argument or return value.

Avoid type mapping

Type mapping incurs additional overhead on each function call. You can avoid this by ensuring that your arguments and/or return types are already primitive types.

Pointer/Array/Buffer Variants

Java primitive arrays are generally slower to use than direct memory (Pointer, Memory, or ByReference) or NIO buffers, since the Java memory has to be pinned and possibly copied across the native call, since the Java array is not necessarily contiguously allocated.

Large Structures

Structures are normally written to native memory before and read back from native memory after a function call. With very large structures, there can be a performance hit using reflection to walk through all the fields. Structure auto-synch can be disabled by calling {@link com.sun.jna.Structure#setAutoSynch} with a false parameter. It is then up to you to use {@link com.sun.jna.Structure#readField(String)} and {@link com.sun.jna.Structure#writeField(String)} or {@link com.sun.jna.Structure#writeField(String,Object)} to synch with just the fields of interest. libjna-java-3.2.7/src/com/sun/jna/NativeLibrary.java0000644000175000017500000006000711421002536020340 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, All Rights Reserved * Copyright (c) 2007, 2008, 2009 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. *

* 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; import java.io.File; import java.io.FilenameFilter; import java.lang.ref.WeakReference; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.StringTokenizer; /** * Provides management of native library resources. One instance of this * class corresponds to a single loaded native library. May also be used * to map to the current process (see {@link NativeLibrary#getProcess()}). *

* Library Search Paths * A search for a given library will scan the following locations: *

    *
  1. jna.library.path User-customizable path *
  2. jna.platform.library.path Platform-specific paths *
* @author Wayne Meissner, split library loading from Function.java */ public class NativeLibrary { private long handle; private final String libraryName; private final String libraryPath; private final Map functions = new HashMap(); final int callFlags; final Map options; private static final Map libraries = new HashMap(); private static final Map searchPaths = Collections.synchronizedMap(new HashMap()); private static final List librarySearchPath = new LinkedList(); static { // Force initialization of native library if (Native.POINTER_SIZE == 0) throw new Error("Native library not initialized"); } private static String functionKey(String name, int flags) { return name + "|" + flags; } private NativeLibrary(String libraryName, String libraryPath, long handle, Map options) { this.libraryName = getLibraryName(libraryName); this.libraryPath = libraryPath; this.handle = handle; Object option = options.get(Library.OPTION_CALLING_CONVENTION); int callingConvention = option instanceof Integer ? ((Integer)option).intValue() : Function.C_CONVENTION; this.callFlags = callingConvention; this.options = options; // Special workaround for w32 kernel32.GetLastError // Short-circuit the function to use built-in GetLastError access if (Platform.isWindows() && "kernel32".equals(this.libraryName.toLowerCase())) { synchronized(functions) { Function f = new Function(this, "GetLastError", Function.ALT_CONVENTION) { Object invoke(Object[] args, Class returnType, boolean b) { return new Integer(Native.getLastError()); } }; functions.put(functionKey("GetLastError", callFlags), f); } } } private static NativeLibrary loadLibrary(String libraryName, Map options) { List searchPath = new LinkedList(); // Append web start path, if available. Note that this does not // attempt any library name variations String webstartPath = Native.getWebStartLibraryPath(libraryName); if (webstartPath != null) { searchPath.add(webstartPath); } // // Prepend any custom search paths specifically for this library // List customPaths = (List) searchPaths.get(libraryName); if (customPaths != null) { synchronized (customPaths) { searchPath.addAll(0, customPaths); } } searchPath.addAll(initPaths("jna.library.path")); String libraryPath = findLibraryPath(libraryName, searchPath); long handle = 0; // // Only search user specified paths first. This will also fall back // to dlopen/LoadLibrary() since findLibraryPath returns the mapped // name if it cannot find the library. // try { handle = open(libraryPath); } catch(UnsatisfiedLinkError e) { // Add the system paths back for all fallback searching searchPath.addAll(librarySearchPath); } try { if (handle == 0) { libraryPath = findLibraryPath(libraryName, searchPath); handle = open(libraryPath); } } catch(UnsatisfiedLinkError e) { if (Platform.isLinux()) { // // Failed to load the library normally - try to match libfoo.so.* // libraryPath = matchLibrary(libraryName, searchPath); if (libraryPath != null) { try { handle = open(libraryPath); } catch(UnsatisfiedLinkError e2) { e = e2; } } } // Search framework libraries on OS X else if (Platform.isMac() && !libraryName.endsWith(".dylib")) { libraryPath = "/System/Library/Frameworks/" + libraryName + ".framework/" + libraryName; if (new File(libraryPath).exists()) { try { handle = open(libraryPath); } catch(UnsatisfiedLinkError e2) { e = e2; } } } // Try the same library with a "lib" prefix else if (Platform.isWindows()) { libraryPath = findLibraryPath("lib" + libraryName, searchPath); try { handle = open(libraryPath); } catch(UnsatisfiedLinkError e2) { e = e2; } } if (handle == 0) { throw new UnsatisfiedLinkError("Unable to load library '" + libraryName + "': " + e.getMessage()); } } return new NativeLibrary(libraryName, libraryPath, handle, options); } private String getLibraryName(String libraryName) { String simplified = libraryName; final String BASE = "---"; String template = mapLibraryName(BASE); int prefixEnd = template.indexOf(BASE); if (prefixEnd > 0 && simplified.startsWith(template.substring(0, prefixEnd))) { simplified = simplified.substring(prefixEnd); } String suffix = template.substring(prefixEnd + BASE.length()); int suffixStart = simplified.indexOf(suffix); if (suffixStart != -1) { simplified = simplified.substring(0, suffixStart); } return simplified; } /** * Returns an instance of NativeLibrary for the specified name. * The library is loaded if not already loaded. If already loaded, the * existing instance is returned.

* More than one name may map to the same NativeLibrary instance; only * a single instance will be provided for any given unique file path. * * @param libraryName The library name to load. * This can be short form (e.g. "c"), * an explicit version (e.g. "libc.so.6"), or * the full path to the library (e.g. "/lib/libc.so.6"). */ public static final NativeLibrary getInstance(String libraryName) { return getInstance(libraryName, Collections.EMPTY_MAP); } /** * Returns an instance of NativeLibrary for the specified name. * The library is loaded if not already loaded. If already loaded, the * existing instance is returned.

* More than one name may map to the same NativeLibrary instance; only * a single instance will be provided for any given unique file path. * * @param libraryName The library name to load. * This can be short form (e.g. "c"), * an explicit version (e.g. "libc.so.6"), or * the full path to the library (e.g. "/lib/libc.so.6"). * @param options native library options for the given library (see {@link * Library}). */ public static final NativeLibrary getInstance(String libraryName, Map options) { options = new HashMap(options); if (options.get(Library.OPTION_CALLING_CONVENTION) == null) { options.put(Library.OPTION_CALLING_CONVENTION, new Integer(Function.C_CONVENTION)); } // Use current process to load libraries we know are already // loaded by the VM to ensure we get the correct version if (Platform.isLinux() && "c".equals(libraryName)) { libraryName = null; } synchronized (libraries) { WeakReference ref = (WeakReference)libraries.get(libraryName + options); NativeLibrary library = ref != null ? (NativeLibrary)ref.get() : null; if (library == null) { if (libraryName == null) { library = new NativeLibrary("", null, open(null), options); } else { library = loadLibrary(libraryName, options); } ref = new WeakReference(library); libraries.put(library.getName() + options, ref); File file = library.getFile(); if (file != null) { libraries.put(file.getAbsolutePath() + options, ref); libraries.put(file.getName() + options, ref); } } return library; } } /** * Returns an instance of NativeLibrary which refers to the current * process. This is useful for accessing functions which were already * mapped by some other mechanism, without having to reference or even * know the exact name of the native library. */ public static synchronized final NativeLibrary getProcess() { return getInstance(null); } /** * Returns an instance of NativeLibrary which refers to the current * process. This is useful for accessing functions which were already * mapped by some other mechanism, without having to reference or even * know the exact name of the native library. */ public static synchronized final NativeLibrary getProcess(Map options) { return getInstance(null, options); } /** * Add a path to search for the specified library, ahead of any system * paths. * * @param libraryName The name of the library to use the path for * @param path The path to use when trying to load the library */ public static final void addSearchPath(String libraryName, String path) { synchronized (searchPaths) { List customPaths = (List) searchPaths.get(libraryName); if (customPaths == null) { customPaths = Collections.synchronizedList(new LinkedList()); searchPaths.put(libraryName, customPaths); } customPaths.add(path); } } /** * Create a new {@link Function} that is linked with a native * function that follows the NativeLibrary's calling convention. * *

The allocated instance represents a pointer to the named native * function from the library. * * @param functionName * Name of the native function to be linked with * @throws UnsatisfiedLinkError if the function is not found */ public Function getFunction(String functionName) { return getFunction(functionName, callFlags); } /** * Create a new {@link Function} that is linked with a native * function that follows the NativeLibrary's calling convention. * *

The allocated instance represents a pointer to the named native * function from the library. * * @param name * Name of the native function to be linked with * @param method * Method to which the native function is to be mapped * @throws UnsatisfiedLinkError if the function is not found */ Function getFunction(String name, Method method) { int flags = this.callFlags; Class[] etypes = method.getExceptionTypes(); for (int i=0;i < etypes.length;i++) { if (LastErrorException.class.isAssignableFrom(etypes[i])) { flags |= Function.THROW_LAST_ERROR; } } return getFunction(name, flags); } /** * Create a new @{link Function} that is linked with a native * function that follows a given calling flags. * * @param functionName * Name of the native function to be linked with * @param callFlags * Flags affecting the function invocation * @throws UnsatisfiedLinkError if the function is not found */ public Function getFunction(String functionName, int callFlags) { if (functionName == null) throw new NullPointerException("Function name may not be null"); synchronized (functions) { String key = functionKey(functionName, callFlags); Function function = (Function) functions.get(key); if (function == null) { function = new Function(this, functionName, callFlags); functions.put(key, function); } return function; } } /** Returns this native library instance's options. */ public Map getOptions() { return options; } /** Look up the given global variable within this library. * @param symbolName * @return Pointer representing the global variable address * @throws UnsatisfiedLinkError if the symbol is not found */ public Pointer getGlobalVariableAddress(String symbolName) { try { return new Pointer(getSymbolAddress(symbolName)); } catch(UnsatisfiedLinkError e) { throw new UnsatisfiedLinkError("Error looking up '" + symbolName + "': " + e.getMessage()); } } /** * Used by the Function class to locate a symbol * @throws UnsatisfiedLinkError if the symbol can't be found */ long getSymbolAddress(String name) { if (handle == 0) { throw new UnsatisfiedLinkError("Library has been unloaded"); } return findSymbol(handle, name); } public String toString() { return "Native Library <" + libraryPath + "@" + handle + ">"; } /** Returns the simple name of this library. */ public String getName() { return libraryName; } /** * Returns the file on disk corresponding to this NativeLibrary instance. * If this NativeLibrary represents the current process, this function will return null. */ public File getFile() { if (libraryPath == null) return null; return new File(libraryPath); } /** Close the library when it is no longer referenced. */ protected void finalize() { dispose(); } public void dispose() { synchronized(libraries) { libraries.remove(getName() + options); File file = getFile(); if (file != null) { libraries.remove(file.getAbsolutePath() + options); libraries.remove(file.getName() + options); } } synchronized(this) { if (handle != 0) { close(handle); handle = 0; } } } private static List initPaths(String key) { String value = System.getProperty(key, ""); if ("".equals(value)) { return Collections.EMPTY_LIST; } StringTokenizer st = new StringTokenizer(value, File.pathSeparator); List list = new ArrayList(); while (st.hasMoreTokens()) { String path = st.nextToken(); if (!"".equals(path)) { list.add(path); } } return list; } /** Use standard library search paths to find the library. */ private static String findLibraryPath(String libName, List searchPath) { // // If a full path to the library was specified, don't search for it // if (new File(libName).isAbsolute()) { return libName; } // // Get the system name for the library (e.g. libfoo.so) // String name = mapLibraryName(libName); // Search in the JNA paths for it for (Iterator it = searchPath.iterator(); it.hasNext(); ) { String path = (String)it.next(); File file = new File(path, name); if (file.exists()) { return file.getAbsolutePath(); } if (Platform.isMac()) { // Native libraries delivered via JNLP class loader // may require a .jnilib extension to be found if (name.endsWith(".dylib")) { file = new File(path, name.substring(0, name.lastIndexOf(".dylib")) + ".jnilib"); if (file.exists()) { return file.getAbsolutePath(); } } } } // // Default to returning the mapped library name and letting the system // search for it // return name; } private static String mapLibraryName(String libName) { if (Platform.isMac()) { if (libName.startsWith("lib") && (libName.endsWith(".dylib") || libName.endsWith(".jnilib"))) { return libName; } String name = System.mapLibraryName(libName); // On MacOSX, System.mapLibraryName() returns the .jnilib extension // (the suffix for JNI libraries); ordinarily shared libraries have // a .dylib suffix if (name.endsWith(".jnilib")) { return name.substring(0, name.lastIndexOf(".jnilib")) + ".dylib"; } return name; } else if (Platform.isLinux()) { if (isVersionedName(libName) || libName.endsWith(".so")) { // A specific version was requested - use as is for search return libName; } } else if (Platform.isWindows()) { if (libName.endsWith(".drv") || libName.endsWith(".dll")) { return libName; } } return System.mapLibraryName(libName); } private static boolean isVersionedName(String name) { if (name.startsWith("lib")) { int so = name.lastIndexOf(".so."); if (so != -1 && so + 4 < name.length()) { for (int i=so+4;i < name.length();i++) { char ch = name.charAt(i); if (!Character.isDigit(ch) && ch != '.') { return false; } } return true; } } return false; } /** * matchLibrary() is very Linux specific. It is here to deal with the case * where /usr/lib/libc.so does not exist, or it is not a valid symlink to * a versioned file (e.g. /lib/libc.so.6). */ static String matchLibrary(final String libName, List searchPath) { File lib = new File(libName); if (lib.isAbsolute()) { searchPath = Arrays.asList(new String[] { lib.getParent() }); } FilenameFilter filter = new FilenameFilter() { public boolean accept(File dir, String filename) { return (filename.startsWith("lib" + libName + ".so") || (filename.startsWith(libName + ".so") && libName.startsWith("lib"))) && isVersionedName(filename); } }; List matches = new LinkedList(); for (Iterator it = searchPath.iterator(); it.hasNext(); ) { File[] files = new File((String) it.next()).listFiles(filter); if (files != null && files.length > 0) { matches.addAll(Arrays.asList(files)); } } // // Search through the results and return the highest numbered version // i.e. libc.so.6 is preferred over libc.so.5 double bestVersion = -1; String bestMatch = null; for (Iterator it = matches.iterator(); it.hasNext(); ) { String path = ((File) it.next()).getAbsolutePath(); String ver = path.substring(path.lastIndexOf(".so.") + 4); double version = parseVersion(ver); if (version > bestVersion) { bestVersion = version; bestMatch = path; } } return bestMatch; } static double parseVersion(String ver) { double v = 0; double divisor = 1; int dot = ver.indexOf("."); while (ver != null) { String num; if (dot != -1) { num = ver.substring(0, dot); ver = ver.substring(dot + 1); dot = ver.indexOf("."); } else { num = ver; ver = null; } try { v += Integer.parseInt(num) / divisor; } catch(NumberFormatException e) { return 0; } divisor *= 100; } return v; } private static native long open(String name); private static native void close(long handle); private static native long findSymbol(long handle, String name); static { String webstartPath = Native.getWebStartLibraryPath("jnidispatch"); if (webstartPath != null) { librarySearchPath.add(webstartPath); } if (System.getProperty("jna.platform.library.path") == null && !Platform.isWindows()) { // Add default path lookups for unix-like systems String platformPath = ""; String sep = ""; String archPath = ""; // // Search first for an arch specific path if one exists, but always // include the generic paths if they exist. // NOTES (wmeissner): // Some older linux amd64 distros did not have /usr/lib64, and 32bit // distros only have /usr/lib. FreeBSD also only has /usr/lib by // default, with /usr/lib32 for 32bit compat. // Solaris seems to have both, but defaults to 32bit userland even on // 64bit machines, so we have to explicitly search the 64bit one when // running a 64bit JVM. // if (Platform.isLinux() || Platform.isSolaris() || Platform.isFreeBSD()) { // Linux & FreeBSD use /usr/lib32, solaris uses /usr/lib/32 archPath = (Platform.isSolaris() ? "/" : "") + Pointer.SIZE * 8; } String[] paths = { "/usr/lib" + archPath, "/lib" + archPath, "/usr/lib", "/lib", }; // Linux 64-bit does not use /lib or /usr/lib if (Platform.isLinux() && Pointer.SIZE == 8) { paths = new String[] { "/usr/lib" + archPath, "/lib" + archPath, }; } for (int i=0;i < paths.length;i++) { File dir = new File(paths[i]); if (dir.exists() && dir.isDirectory()) { platformPath += sep + paths[i]; sep = File.pathSeparator; } } if (!"".equals(platformPath)) { System.setProperty("jna.platform.library.path", platformPath); } } librarySearchPath.addAll(initPaths("jna.platform.library.path")); } } libjna-java-3.2.7/src/com/sun/jna/Structure.java0000644000175000017500000015037711421002536017577 0ustar janjan/* 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; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.nio.Buffer; import java.util.AbstractCollection; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; /** * Represents a native structure with a Java peer class. When used as a * function parameter or return value, this class corresponds to * struct*. When used as a field within another * Structure, it corresponds to struct. The * tagging interfaces {@link ByReference} and {@link ByValue} may be used * to alter the default behavior. *

* See the overview for supported * type mappings. *

* Structure alignment and type mappings are derived by default from the * enclosing interface definition (if any) by using * {@link Native#getStructureAlignment} and {@link Native#getTypeMapper}. *

* Structure fields corresponding to native fields must be public. * The may additionally have the following modifiers:
*

    *
  • volatile JNA will not write the field unless specifically * instructed to do so via {@link #writeField(String)}. *
  • final JNA will overwrite the field via {@link #read()}, * but otherwise the field is not modifiable from Java. Take care when using * this option, since the compiler will usually assume all accesses * to the field (for a given Structure instance) have the same value. *
* NOTE: Strings are used to represent native C strings because usage of * char * is generally more common than wchar_t *. *

* NOTE: This class assumes that fields are returned in {@link Class#getFields} * in the same or reverse order as declared. If your VM returns them in * no particular order, you're out of luck. * * @author Todd Fast, todd.fast@sun.com * @author twall@users.sf.net */ public abstract class Structure { /** Tagging interface to indicate the value of an instance of the * Structure type is to be used in function invocations rather * than its address. The default behavior is to treat * Structure function parameters and return values as by * reference, meaning the address of the structure is used. */ public interface ByValue { } /** Tagging interface to indicate the address of an instance of the * Structure type is to be used within a Structure definition * rather than nesting the full Structure contents. The default behavior * is to inline Structure fields. */ public interface ByReference { } private static class MemberOrder { private static final String[] FIELDS = { "first", "second", "middle", "penultimate", "last", }; public int first; public int second; public int middle; public int penultimate; public int last; } private static final boolean REVERSE_FIELDS; private static final boolean REQUIRES_FIELD_ORDER; static final boolean isPPC; static final boolean isSPARC; static { // Check for predictable field order; IBM and JRockit store fields in // reverse order; Excelsior JET requires explicit order Field[] fields = MemberOrder.class.getFields(); List names = new ArrayList(); for(int i=0;i < fields.length;i++) { names.add(fields[i].getName()); } List expected = Arrays.asList(MemberOrder.FIELDS); List reversed = new ArrayList(expected); Collections.reverse(reversed); REVERSE_FIELDS = names.equals(reversed); REQUIRES_FIELD_ORDER = !(names.equals(expected) || REVERSE_FIELDS); String arch = System.getProperty("os.arch").toLowerCase(); isPPC = "ppc".equals(arch) || "powerpc".equals(arch); isSPARC = "sparc".equals(arch); } /** Use the platform default alignment. */ public static final int ALIGN_DEFAULT = 0; /** No alignment, place all fields on nearest 1-byte boundary */ public static final int ALIGN_NONE = 1; /** validated for 32-bit x86 linux/gcc; align field size, max 4 bytes */ public static final int ALIGN_GNUC = 2; /** validated for w32/msvc; align on field size */ public static final int ALIGN_MSVC = 3; /** Align to a 2-byte boundary. */ //public static final int ALIGN_2 = 4; /** Align to a 4-byte boundary. */ //public static final int ALIGN_4 = 5; /** Align to an 8-byte boundary. */ //public static final int ALIGN_8 = 6; private static final int MAX_GNUC_ALIGNMENT = isSPARC ? 8 : Native.LONG_SIZE; protected static final int CALCULATE_SIZE = -1; // This field is accessed by native code private Pointer memory; private int size = CALCULATE_SIZE; private int alignType; private int structAlignment; private final Map structFields = new LinkedHashMap(); // Keep track of java strings which have been converted to C strings private final Map nativeStrings = new HashMap(); private TypeMapper typeMapper; // This field is accessed by native code private long typeInfo; private List fieldOrder; private boolean autoRead = true; private boolean autoWrite = true; private Structure[] array; protected Structure() { this((Pointer)null); } protected Structure(TypeMapper mapper) { this((Pointer)null, ALIGN_DEFAULT, mapper); } /** Create a structure cast onto preallocated memory. */ protected Structure(Pointer p) { this(p, ALIGN_DEFAULT); } protected Structure(Pointer p, int alignment) { this(p, alignment, null); } protected Structure(Pointer p, int alignment, TypeMapper mapper) { setAlignType(alignment); setTypeMapper(mapper); if (p != null) { useMemory(p); } else { allocateMemory(CALCULATE_SIZE); } } /** Return all fields in this structure (ordered). */ Map fields() { return structFields; } /** Change the type mapping for this structure. May cause the structure * to be resized and any existing memory to be reallocated. * If null, the default mapper for the * defining class will be used. */ protected void setTypeMapper(TypeMapper mapper) { if (mapper == null) { Class declaring = getClass().getDeclaringClass(); if (declaring != null) { mapper = Native.getTypeMapper(declaring); } } this.typeMapper = mapper; this.size = CALCULATE_SIZE; if (this.memory instanceof AutoAllocated) { this.memory = null; } } /** Change the alignment of this structure. Re-allocates memory if * necessary. If alignment is {@link #ALIGN_DEFAULT}, the default * alignment for the defining class will be used. */ protected void setAlignType(int alignType) { if (alignType == ALIGN_DEFAULT) { Class declaring = getClass().getDeclaringClass(); if (declaring != null) alignType = Native.getStructureAlignment(declaring); if (alignType == ALIGN_DEFAULT) { if (Platform.isWindows()) alignType = ALIGN_MSVC; else alignType = ALIGN_GNUC; } } this.alignType = alignType; this.size = CALCULATE_SIZE; if (this.memory instanceof AutoAllocated) { this.memory = null; } } protected Memory autoAllocate(int size) { return new AutoAllocated(size); } /** Set the memory used by this structure. This method is used to * indicate the given structure is nested within another or otherwise * overlaid on some other memory block and thus does not own its own * memory. */ protected void useMemory(Pointer m) { useMemory(m, 0); } /** Set the memory used by this structure. This method is used to * indicate the given structure is nested within another or otherwise * overlaid on some other memory block and thus does not own its own * memory. */ protected void useMemory(Pointer m, int offset) { // Invoking size() here is important when this method is invoked // from the ctor, to ensure fields are properly scanned and allocated try { // Set the structure's memory field temporarily to avoid // auto-allocating memory in the call to size() this.memory = m; if (size == CALCULATE_SIZE) { size = calculateSize(false); } if (size != CALCULATE_SIZE) { this.memory = m.share(offset, size); } this.array = null; } catch(IndexOutOfBoundsException e) { throw new IllegalArgumentException("Structure exceeds provided memory bounds"); } } protected void ensureAllocated() { if (memory == null) { allocateMemory(); } } /** Attempt to allocate memory if sufficient information is available. * Returns whether the operation was successful. */ protected void allocateMemory() { allocateMemory(calculateSize(true)); } /** Provided for derived classes to indicate a different * size than the default. Returns whether the operation was successful. * Will leave memory untouched if it is non-null and not allocated * by this class. */ protected void allocateMemory(int size) { if (size == CALCULATE_SIZE) { // Analyze the struct, but don't worry if we can't yet do it size = calculateSize(false); } else if (size <= 0) { throw new IllegalArgumentException("Structure size must be greater than zero: " + size); } // May need to defer size calculation if derived class not fully // initialized if (size != CALCULATE_SIZE) { if (this.memory == null || this.memory instanceof AutoAllocated) { this.memory = autoAllocate(size); } this.size = size; } } public int size() { ensureAllocated(); if (size == CALCULATE_SIZE) { size = calculateSize(true); } return size; } public void clear() { memory.clear(size()); } /** Return a {@link Pointer} object to this structure. Note that if you * use the structure's pointer as a function argument, you are responsible * for calling {@link #write()} prior to the call and {@link #read()} * after the call. These calls are normally handled automatically by the * {@link Function} object when it encounters a {@link Structure} argument * or return value. */ public Pointer getPointer() { ensureAllocated(); return memory; } ////////////////////////////////////////////////////////////////////////// // Data synchronization methods ////////////////////////////////////////////////////////////////////////// // Keep track of ByReference reads to avoid creating multiple structures // mapped to the same address private static final ThreadLocal reads = new ThreadLocal() { protected synchronized Object initialValue() { return new HashMap(); } }; // Keep track of what is currently being read/written to avoid redundant // reads (avoids problems with circular references). private static final ThreadLocal busy = new ThreadLocal() { /** Avoid using a hash-based implementation since the hash code will change if structure field values change. */ class StructureSet extends AbstractCollection implements Set { private Structure[] elements; private int count; private void ensureCapacity(int size) { if (elements == null) { elements = new Structure[size*3/2]; } else if (elements.length < size) { Structure[] e = new Structure[size*3/2]; System.arraycopy(elements, 0, e, 0, elements.length); elements = e; } } public int size() { return count; } public boolean contains(Object o) { return indexOf(o) != -1; } public boolean add(Object o) { if (!contains(o)) { ensureCapacity(count+1); elements[count++] = (Structure)o; } return true; } private int indexOf(Object o) { Structure s1 = (Structure)o; for (int i=0;i < count;i++) { Structure s2 = elements[i]; if (s1 == s2 || (s1.getClass() == s2.getClass() && s1.size() == s2.size() && s1.getPointer().equals(s2.getPointer()))) { return i; } } return -1; } public boolean remove(Object o) { int idx = indexOf(o); if (idx != -1) { if (--count > 0) { elements[idx] = elements[count]; elements[count] = null; } return true; } return false; } public Iterator iterator() { // never actually used return null; } } protected synchronized Object initialValue() { return new StructureSet(); } }; static Set busy() { return (Set)busy.get(); } static Map reading() { return (Map)reads.get(); } /** * Reads the fields of the struct from native memory */ public void read() { // convenience: allocate memory if it hasn't been already; this // allows structures to do field-based initialization of arrays and not // have to explicitly call allocateMemory in a ctor ensureAllocated(); // Avoid redundant reads if (busy().contains(this)) { return; } busy().add(this); if (this instanceof Structure.ByReference) { reading().put(getPointer(), this); } try { for (Iterator i=structFields.values().iterator();i.hasNext();) { readField((StructField)i.next()); } } finally { busy().remove(this); if (reading().get(getPointer()) == this) { reading().remove(getPointer()); } } } /** Force a read of the given field from native memory. The Java field * will be updated from the current contents of native memory. * @return the new field value, after updating * @throws IllegalArgumentException if no field exists with the given name */ public Object readField(String name) { ensureAllocated(); StructField f = (StructField)structFields.get(name); if (f == null) throw new IllegalArgumentException("No such field: " + name); return readField(f); } /** Obtain the value currently in the Java field. Does not read from * memory. */ Object getField(StructField structField) { try { return structField.field.get(this); } catch (Exception e) { throw new Error("Exception reading field '" + structField.name + "' in " + getClass() + ": " + e); } } void setField(StructField structField, Object value) { try { structField.field.set(this, value); } catch(IllegalAccessException e) { throw new Error("Unexpectedly unable to write to field '" + structField.name + "' within " + getClass() + ": " + e); } } /** Only keep the original structure if its native address is unchanged. * Otherwise replace it with a new object. * @param type Structure subclass * @param s Original Structure object * @param address the native struct * * @return Updated Structure.ByReference object */ static Structure updateStructureByReference(Class type, Structure s, Pointer address) { if (address == null) { s = null; } else { if (s == null || !address.equals(s.getPointer())) { Structure s1 = (Structure)reading().get(address); if (s1 != null && type.equals(s1.getClass())) { s = s1; } else { s = newInstance(type); s.useMemory(address); } } s.autoRead(); } return s; } /** Read the given field and return its value. The Java field will be * updated from the contents of native memory. */ // TODO: make overridable method with calculated native type, offset, etc Object readField(StructField structField) { // Get the offset of the field int offset = structField.offset; // Determine the type of the field Class fieldType = structField.type; FromNativeConverter readConverter = structField.readConverter; if (readConverter != null) { fieldType = readConverter.nativeType(); } // Get the current value only for types which might need to be preserved Object currentValue = (Structure.class.isAssignableFrom(fieldType) || Callback.class.isAssignableFrom(fieldType) || Buffer.class.isAssignableFrom(fieldType) || Pointer.class.isAssignableFrom(fieldType) || fieldType.isArray()) ? getField(structField) : null; Object result = memory.getValue(offset, fieldType, currentValue); // TODO: process against current value here if (readConverter != null) { result = readConverter.fromNative(result, structField.context); } // Update the value on the field setField(structField, result); return result; } /** * Writes the fields of the struct to native memory */ public void write() { // convenience: allocate memory if it hasn't been already; this // allows structures to do field-based initialization of arrays and not // have to explicitly call allocateMemory in a ctor ensureAllocated(); // Update native FFI type information, if needed if (this instanceof ByValue) { getTypeInfo(); } // Avoid redundant writes if (busy().contains(this)) { return; } busy().add(this); try { // Write all fields, except those marked 'volatile' for (Iterator i=structFields.values().iterator();i.hasNext();) { StructField sf = (StructField)i.next(); if (!sf.isVolatile) { writeField(sf); } } } finally { busy().remove(this); } } /** Write the given field to native memory. The current value in the Java * field will be translated into native memory. * @throws IllegalArgumentException if no field exists with the given name */ public void writeField(String name) { ensureAllocated(); StructField f = (StructField)structFields.get(name); if (f == null) throw new IllegalArgumentException("No such field: " + name); writeField(f); } /** Write the given field value to the field and native memory. The * given value will be written both to the Java field and the * corresponding native memory. * @throws IllegalArgumentException if no field exists with the given name */ public void writeField(String name, Object value) { ensureAllocated(); StructField f = (StructField)structFields.get(name); if (f == null) throw new IllegalArgumentException("No such field: " + name); setField(f, value); writeField(f); } void writeField(StructField structField) { if (structField.isReadOnly) return; // Get the offset of the field int offset = structField.offset; // Get the value from the field Object value = getField(structField); // Determine the type of the field Class fieldType = structField.type; ToNativeConverter converter = structField.writeConverter; if (converter != null) { value = converter.toNative(value, new StructureWriteContext(this, structField.field)); fieldType = converter.nativeType(); } // Java strings get converted to C strings, where a Pointer is used if (String.class == fieldType || WString.class == fieldType) { // Allocate a new string in memory boolean wide = fieldType == WString.class; if (value != null) { NativeString nativeString = new NativeString(value.toString(), wide); // Keep track of allocated C strings to avoid // premature garbage collection of the memory. nativeStrings.put(structField.name, nativeString); value = nativeString.getPointer(); } else { value = null; nativeStrings.remove(structField.name); } } try { memory.setValue(offset, value, fieldType); } catch(IllegalArgumentException e) { e.printStackTrace(); String msg = "Structure field \"" + structField.name + "\" was declared as " + structField.type + (structField.type == fieldType ? "" : " (native type " + fieldType + ")") + ", which is not supported within a Structure"; throw new IllegalArgumentException(msg); } } private boolean hasFieldOrder() { synchronized(this) { return fieldOrder != null; } } protected List getFieldOrder() { synchronized(this) { if (fieldOrder == null) { fieldOrder = new ArrayList(); } return fieldOrder; } } /** Provided for VMs where the field order as returned by {@link * Class#getFields()} is not predictable. */ protected void setFieldOrder(String[] fields) { getFieldOrder().addAll(Arrays.asList(fields)); // Force recalculation of size/field layout this.size = CALCULATE_SIZE; if (this.memory instanceof AutoAllocated) { this.memory = null; } } /** Sort the structure fields according to the given array of names. */ protected void sortFields(List fields, List names) { for (int i=0;i < names.size();i++) { String name = (String)names.get(i); for (int f=0;f < fields.size();f++) { Field field = (Field)fields.get(f); if (name.equals(field.getName())) { Collections.swap(fields, i, f); break; } } } } protected List getFields(boolean force) { // Restrict to valid fields List flist = new ArrayList(); for (Class cls = getClass(); !cls.equals(Structure.class); cls = cls.getSuperclass()) { List classFields = new ArrayList(); Field[] fields = cls.getDeclaredFields(); for (int i=0;i < fields.length;i++) { int modifiers = fields[i].getModifiers(); if (Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) continue; classFields.add(fields[i]); } if (REVERSE_FIELDS) { Collections.reverse(classFields); } flist.addAll(0, classFields); } if (REQUIRES_FIELD_ORDER || hasFieldOrder()) { List fieldOrder = getFieldOrder(); if (fieldOrder.size() < flist.size()) { if (force) { throw new Error("This VM does not store fields in a predictable order; you must use Structure.setFieldOrder to explicitly indicate the field order: " + System.getProperty("java.vendor") + ", " + System.getProperty("java.version")); } return null; } sortFields(flist, fieldOrder); } return flist; } /** Calculate the amount of native memory required for this structure. * May return {@link #CALCULATE_SIZE} if the size can not yet be * determined (usually due to fields in the derived class not yet * being initialized). *

* If the force parameter is true will throw * an {@link IllegalStateException} if the size can not be determined. * @throws IllegalStateException an array field is not initialized * @throws IllegalArgumentException when an unsupported field type is * encountered */ int calculateSize(boolean force) { // TODO: maybe cache this information on a per-class basis // so that we don't have to re-analyze this static information each // time a struct is allocated. structAlignment = 1; int calculatedSize = 0; List fields = getFields(force); if (fields == null) { return CALCULATE_SIZE; } boolean firstField = true; for (Iterator i=fields.iterator();i.hasNext();firstField=false) { Field field = (Field)i.next(); int modifiers = field.getModifiers(); Class type = field.getType(); StructField structField = new StructField(); structField.isVolatile = Modifier.isVolatile(modifiers); structField.isReadOnly = Modifier.isFinal(modifiers); if (Modifier.isFinal(modifiers)) { field.setAccessible(true); } structField.field = field; structField.name = field.getName(); structField.type = type; // Check for illegal field types if (Callback.class.isAssignableFrom(type) && !type.isInterface()) { throw new IllegalArgumentException("Structure Callback field '" + field.getName() + "' must be an interface"); } if (type.isArray() && Structure.class.equals(type.getComponentType())) { String msg = "Nested Structure arrays must use a " + "derived Structure type so that the size of " + "the elements can be determined"; throw new IllegalArgumentException(msg); } int fieldAlignment = 1; if (!Modifier.isPublic(field.getModifiers())) continue; Object value = getField(structField); if (value == null) { if (Structure.class.isAssignableFrom(type) && !(ByReference.class.isAssignableFrom(type))) { try { value = newInstance(type); setField(structField, value); } catch(IllegalArgumentException e) { String msg = "Can't determine size of nested structure: " + e.getMessage(); throw new IllegalArgumentException(msg); } } else if (type.isArray()) { // can't calculate size yet, defer until later if (force) { throw new IllegalStateException("Array fields must be initialized"); } return CALCULATE_SIZE; } } Class nativeType = type; if (NativeMapped.class.isAssignableFrom(type)) { NativeMappedConverter tc = NativeMappedConverter.getInstance(type); if (value == null) { value = tc.defaultValue(); setField(structField, value); } nativeType = tc.nativeType(); structField.writeConverter = tc; structField.readConverter = tc; structField.context = new StructureReadContext(this, field); } else if (typeMapper != null) { ToNativeConverter writeConverter = typeMapper.getToNativeConverter(type); FromNativeConverter readConverter = typeMapper.getFromNativeConverter(type); if (writeConverter != null && readConverter != null) { value = writeConverter.toNative(value, new StructureWriteContext(this, structField.field)); nativeType = value != null ? value.getClass() : Pointer.class; structField.writeConverter = writeConverter; structField.readConverter = readConverter; structField.context = new StructureReadContext(this, field); } else if (writeConverter != null || readConverter != null) { String msg = "Structures require bidirectional type conversion for " + type; throw new IllegalArgumentException(msg); } } try { structField.size = Native.getNativeSize(nativeType, value); fieldAlignment = getNativeAlignment(nativeType, value, firstField); } catch(IllegalArgumentException e) { // Might simply not yet have a type mapper set if (!force && typeMapper == null) { return CALCULATE_SIZE; } String msg = "Invalid Structure field in " + getClass() + ", field name '" + structField.name + "', " + structField.type + ": " + e.getMessage(); throw new IllegalArgumentException(msg); } // Align fields as appropriate structAlignment = Math.max(structAlignment, fieldAlignment); if ((calculatedSize % fieldAlignment) != 0) { calculatedSize += fieldAlignment - (calculatedSize % fieldAlignment); } structField.offset = calculatedSize; calculatedSize += structField.size; // Save the field in our list structFields.put(structField.name, structField); } if (calculatedSize > 0) { int size = calculateAlignedSize(calculatedSize); // Update native FFI type information, if needed if (this instanceof ByValue) { getTypeInfo(); } if (this.memory != null && !(this.memory instanceof AutoAllocated)) { // Ensure we've set bounds on the memory used this.memory = this.memory.share(0, size); } return size; } throw new IllegalArgumentException("Structure " + getClass() + " has unknown size (ensure " + "all fields are public)"); } int calculateAlignedSize(int calculatedSize) { // Structure size must be an integral multiple of its alignment, // add padding if necessary. if (alignType != ALIGN_NONE) { if ((calculatedSize % structAlignment) != 0) { calculatedSize += structAlignment - (calculatedSize % structAlignment); } } return calculatedSize; } protected int getStructAlignment() { if (size == CALCULATE_SIZE) { // calculate size, but don't allocate memory calculateSize(true); } return structAlignment; } /** Overridable in subclasses. */ // TODO: write getNaturalAlignment(stack/alloc) + getEmbeddedAlignment(structs) // TODO: move this into a native call which detects default alignment // automatically protected int getNativeAlignment(Class type, Object value, boolean isFirstElement) { int alignment = 1; if (NativeMapped.class.isAssignableFrom(type)) { NativeMappedConverter tc = NativeMappedConverter.getInstance(type); type = tc.nativeType(); value = tc.toNative(value, new ToNativeContext()); } int size = Native.getNativeSize(type, value); if (type.isPrimitive() || Long.class == type || Integer.class == type || Short.class == type || Character.class == type || Byte.class == type || Boolean.class == type || Float.class == type || Double.class == type) { alignment = size; } else if (Pointer.class == type || Buffer.class.isAssignableFrom(type) || Callback.class.isAssignableFrom(type) || WString.class == type || String.class == type) { alignment = Pointer.SIZE; } else if (Structure.class.isAssignableFrom(type)) { if (ByReference.class.isAssignableFrom(type)) { alignment = Pointer.SIZE; } else { if (value == null) value = newInstance(type); alignment = ((Structure)value).getStructAlignment(); } } else if (type.isArray()) { alignment = getNativeAlignment(type.getComponentType(), null, isFirstElement); } else { throw new IllegalArgumentException("Type " + type + " has unknown " + "native alignment"); } if (alignType == ALIGN_NONE) { alignment = 1; } else if (alignType == ALIGN_MSVC) { alignment = Math.min(8, alignment); } else if (alignType == ALIGN_GNUC) { // NOTE this is published ABI for 32-bit gcc/linux/x86, osx/x86, // and osx/ppc. osx/ppc special-cases the first element if (!isFirstElement || !(Platform.isMac() && isPPC)) { alignment = Math.min(MAX_GNUC_ALIGNMENT, alignment); } } return alignment; } public String toString() { return toString(0, true); } private String format(Class type) { String s = type.getName(); int dot = s.lastIndexOf("."); return s.substring(dot + 1); } private String toString(int indent, boolean showContents) { String LS = System.getProperty("line.separator"); String name = format(getClass()) + "(" + getPointer() + ")"; if (!(getPointer() instanceof Memory)) { name += " (" + size() + " bytes)"; } String prefix = ""; for (int idx=0;idx < indent;idx++) { prefix += " "; } String contents = LS; if (!showContents) { contents = "...}"; } else for (Iterator i=structFields.values().iterator();i.hasNext();) { StructField sf = (StructField)i.next(); Object value = getField(sf); String type = format(sf.type); String index = ""; contents += prefix; if (sf.type.isArray() && value != null) { type = format(sf.type.getComponentType()); index = "[" + Array.getLength(value) + "]"; } contents += " " + type + " " + sf.name + index + "@" + Integer.toHexString(sf.offset); if (value instanceof Structure) { value = ((Structure)value).toString(indent + 1, !(value instanceof Structure.ByReference)); } contents += "="; if (value instanceof Long) { contents += Long.toHexString(((Long)value).longValue()); } else if (value instanceof Integer) { contents += Integer.toHexString(((Integer)value).intValue()); } else if (value instanceof Short) { contents += Integer.toHexString(((Short)value).shortValue()); } else if (value instanceof Byte) { contents += Integer.toHexString(((Byte)value).byteValue()); } else { contents += String.valueOf(value).trim(); } contents += LS; if (!i.hasNext()) contents += prefix + "}"; } if (indent == 0 && Boolean.getBoolean("jna.dump_memory")) { byte[] buf = getPointer().getByteArray(0, size()); final int BYTES_PER_ROW = 4; contents += LS + "memory dump" + LS; for (int i=0;i < buf.length;i++) { if ((i % BYTES_PER_ROW) == 0) contents += "["; if (buf[i] >=0 && buf[i] < 16) contents += "0"; contents += Integer.toHexString(buf[i] & 0xFF); if ((i % BYTES_PER_ROW) == BYTES_PER_ROW-1 && i < buf.length-1) contents += "]" + LS; } contents += "]"; } return name + " {" + contents; } /** Returns a view of this structure's memory as an array of structures. * Note that this Structure must have a public, no-arg * constructor. If the structure is currently using auto-allocated * {@link Memory} backing, the memory will be resized to fit the entire * array. */ public Structure[] toArray(Structure[] array) { ensureAllocated(); if (this.memory instanceof AutoAllocated) { // reallocate if necessary Memory m = (Memory)this.memory; int requiredSize = array.length * size(); if (m.size() < requiredSize) { useMemory(autoAllocate(requiredSize)); } } array[0] = this; int size = size(); for (int i=1;i < array.length;i++) { array[i] = Structure.newInstance(getClass()); array[i].useMemory(memory.share(i*size, size)); array[i].read(); } if (!(this instanceof ByValue)) { // keep track for later auto-read/writes this.array = array; } return array; } /** Returns a view of this structure's memory as an array of structures. * Note that this Structure must have a public, no-arg * constructor. If the structure is currently using auto-allocated * {@link Memory} backing, the memory will be resized to fit the entire * array. */ public Structure[] toArray(int size) { return toArray((Structure[])Array.newInstance(getClass(), size)); } private Class baseClass() { if ((this instanceof Structure.ByReference || this instanceof Structure.ByValue) && Structure.class.isAssignableFrom(getClass().getSuperclass())) { return getClass().getSuperclass(); } return getClass(); } /** This structure is equal to another based on the same data type * and visible data fields. */ public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof Structure)) { return false; } if (o.getClass() != getClass() && ((Structure)o).baseClass() != baseClass()) { return false; } Structure s = (Structure)o; if (s.size() == size()) { clear(); write(); byte[] buf = getPointer().getByteArray(0, size()); s.clear(); s.write(); byte[] sbuf = s.getPointer().getByteArray(0, s.size()); return Arrays.equals(buf, sbuf); } return false; } /** Since {@link #equals} depends on the native address, use that * as the hash code. */ public int hashCode() { clear(); write(); return Arrays.hashCode(getPointer().getByteArray(0, size())); } protected void cacheTypeInfo(Pointer p) { typeInfo = p.peer; } /** Obtain native type information for this structure. */ Pointer getTypeInfo() { Pointer p = getTypeInfo(this); cacheTypeInfo(p); return p; } /** Set whether the structure is automatically synchronized to native memory before and after a native function call. Convenience method for


        boolean auto = ...;
        setAutoRead(auto);
        setAutoWrite(auto);
        
*/ public void setAutoSynch(boolean auto) { setAutoRead(auto); setAutoWrite(auto); } /** Set whether the structure is read from native memory prior to a native function call. */ public void setAutoRead(boolean auto) { this.autoRead = auto; } /** Returns whether the structure is read from native memory prior to a native function call. */ public boolean getAutoRead() { return this.autoRead; } /** Set whether the structure is written to native memory after a native function call. */ public void setAutoWrite(boolean auto) { this.autoWrite = auto; } /** Returns whether the structure is written to native memory after a native function call. */ public boolean getAutoWrite() { return this.autoWrite; } /** Exposed for testing purposes only. */ static Pointer getTypeInfo(Object obj) { return FFIType.get(obj); } /** Create a new Structure instance of the given type * @param type * @return the new instance * @throws IllegalArgumentException if the instantiation fails */ public static Structure newInstance(Class type) throws IllegalArgumentException { try { Structure s = (Structure)type.newInstance(); if (s instanceof ByValue) { s.allocateMemory(); } return s; } catch(InstantiationException e) { String msg = "Can't instantiate " + type + " (" + e + ")"; throw new IllegalArgumentException(msg); } catch(IllegalAccessException e) { String msg = "Instantiation of " + type + " not allowed, is it public? (" + e + ")"; throw new IllegalArgumentException(msg); } } class StructField extends Object { public String name; public Class type; public Field field; public int size = -1; public int offset = -1; public boolean isVolatile; public boolean isReadOnly; public FromNativeConverter readConverter; public ToNativeConverter writeConverter; public FromNativeContext context; } /** This class auto-generates an ffi_type structure appropriate for a given * structure for use by libffi. The lifecycle of this structure is easier * to manage on the Java side than in native code. */ static class FFIType extends Structure { public static class size_t extends IntegerType { public size_t() { this(0); } public size_t(long value) { super(Native.POINTER_SIZE, value); } } private static Map typeInfoMap = new WeakHashMap(); // Native.initIDs initializes these fields to their appropriate // pointer values. These are in a separate class from FFIType so that // they may be initialized prior to loading the FFIType class private static class FFITypes { private static Pointer ffi_type_void; private static Pointer ffi_type_float; private static Pointer ffi_type_double; private static Pointer ffi_type_longdouble; private static Pointer ffi_type_uint8; private static Pointer ffi_type_sint8; private static Pointer ffi_type_uint16; private static Pointer ffi_type_sint16; private static Pointer ffi_type_uint32; private static Pointer ffi_type_sint32; private static Pointer ffi_type_uint64; private static Pointer ffi_type_sint64; private static Pointer ffi_type_pointer; } static { if (Native.POINTER_SIZE == 0) throw new Error("Native library not initialized"); if (FFITypes.ffi_type_void == null) throw new Error("FFI types not initialized"); typeInfoMap.put(void.class, FFITypes.ffi_type_void); typeInfoMap.put(Void.class, FFITypes.ffi_type_void); typeInfoMap.put(float.class, FFITypes.ffi_type_float); typeInfoMap.put(Float.class, FFITypes.ffi_type_float); typeInfoMap.put(double.class, FFITypes.ffi_type_double); typeInfoMap.put(Double.class, FFITypes.ffi_type_double); typeInfoMap.put(long.class, FFITypes.ffi_type_sint64); typeInfoMap.put(Long.class, FFITypes.ffi_type_sint64); typeInfoMap.put(int.class, FFITypes.ffi_type_sint32); typeInfoMap.put(Integer.class, FFITypes.ffi_type_sint32); typeInfoMap.put(short.class, FFITypes.ffi_type_sint16); typeInfoMap.put(Short.class, FFITypes.ffi_type_sint16); Pointer ctype = Native.WCHAR_SIZE == 2 ? FFITypes.ffi_type_uint16 : FFITypes.ffi_type_uint32; typeInfoMap.put(char.class, ctype); typeInfoMap.put(Character.class, ctype); typeInfoMap.put(byte.class, FFITypes.ffi_type_sint8); typeInfoMap.put(Byte.class, FFITypes.ffi_type_sint8); typeInfoMap.put(boolean.class, FFITypes.ffi_type_uint32); typeInfoMap.put(Boolean.class, FFITypes.ffi_type_uint32); typeInfoMap.put(Pointer.class, FFITypes.ffi_type_pointer); typeInfoMap.put(String.class, FFITypes.ffi_type_pointer); typeInfoMap.put(WString.class, FFITypes.ffi_type_pointer); } // From ffi.h private static final int FFI_TYPE_STRUCT = 13; // Structure fields public size_t size; public short alignment; public short type = FFI_TYPE_STRUCT; public Pointer elements; private FFIType(Structure ref) { Pointer[] els; if (ref instanceof Union) { StructField sf = ((Union)ref).biggestField; els = new Pointer[] { get(ref.getField(sf), sf.type), null, }; } else { els = new Pointer[ref.fields().size() + 1]; int idx = 0; for (Iterator i=ref.fields().values().iterator();i.hasNext();) { StructField sf = (StructField)i.next(); els[idx++] = get(ref.getField(sf), sf.type); } } init(els); } // Represent fixed-size arrays as structures of N identical elements private FFIType(Object array, Class type) { int length = Array.getLength(array); Pointer[] els = new Pointer[length+1]; Pointer p = get(null, type.getComponentType()); for (int i=0;i < length;i++) { els[i] = p; } init(els); } private void init(Pointer[] els) { elements = new Memory(Pointer.SIZE * els.length); elements.write(0, els, 0, els.length); write(); } static Pointer get(Object obj) { if (obj == null) return FFITypes.ffi_type_pointer; if (obj instanceof Class) return get(null, (Class)obj); return get(obj, obj.getClass()); } private static Pointer get(Object obj, Class cls) { synchronized(typeInfoMap) { Object o = typeInfoMap.get(cls); if (o instanceof Pointer) { return (Pointer)o; } if (o instanceof FFIType) { return ((FFIType)o).getPointer(); } if (Buffer.class.isAssignableFrom(cls) || Callback.class.isAssignableFrom(cls)) { typeInfoMap.put(cls, FFITypes.ffi_type_pointer); return FFITypes.ffi_type_pointer; } if (Structure.class.isAssignableFrom(cls)) { if (obj == null) obj = newInstance(cls); if (ByReference.class.isAssignableFrom(cls)) { typeInfoMap.put(cls, FFITypes.ffi_type_pointer); return FFITypes.ffi_type_pointer; } FFIType type = new FFIType((Structure)obj); typeInfoMap.put(cls, type); return type.getPointer(); } if (NativeMapped.class.isAssignableFrom(cls)) { NativeMappedConverter c = NativeMappedConverter.getInstance(cls); return get(c.toNative(obj, new ToNativeContext()), c.nativeType()); } if (cls.isArray()) { FFIType type = new FFIType(obj, cls); // Store it in the map to prevent premature GC of type info typeInfoMap.put(obj, type); return type.getPointer(); } throw new IllegalArgumentException("Unsupported type " + cls); } } } private class AutoAllocated extends Memory { public AutoAllocated(int size) { super(size); // Always clear new structure memory clear(); } } private static void structureArrayCheck(Structure[] ss) { Pointer base = ss[0].getPointer(); int size = ss[0].size(); for (int si=1;si < ss.length;si++) { if (ss[si].getPointer().peer != base.peer + size*si) { String msg = "Structure array elements must use" + " contiguous memory (bad backing address at Structure array index " + si + ")"; throw new IllegalArgumentException(msg); } } } public static void autoRead(Structure[] ss) { structureArrayCheck(ss); if (ss[0].array == ss) { ss[0].autoRead(); } else { for (int si=0;si < ss.length;si++) { ss[si].autoRead(); } } } public void autoRead() { if (getAutoRead()) { read(); if (array != null) { for (int i=1;i < array.length;i++) { array[i].autoRead(); } } } } public static void autoWrite(Structure[] ss) { structureArrayCheck(ss); if (ss[0].array == ss) { ss[0].autoWrite(); } else { for (int si=0;si < ss.length;si++) { ss[si].autoWrite(); } } } public void autoWrite() { if (getAutoWrite()) { write(); if (array != null) { for (int i=1;i < array.length;i++) { array[i].autoWrite(); } } } } } libjna-java-3.2.7/src/com/sun/jna/Callback.java0000644000175000017500000000443111155215156017270 0ustar janjan/* 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. *

* 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; import java.util.Arrays; import java.util.Collection; /** All callback definitions must derive from this interface. Any * derived interfaces must define a single public method (which may not be named * "hashCode", "equals", or "toString"), or one public method named "callback". * You are responsible for deregistering your callback (if necessary) * in its {@link Object#finalize} method. If native code attempts to call * a callback which has been GC'd, you will likely crash the VM. If * there is no method to deregister the callback (e.g. atexit * in the C library), you must ensure that you always keep a live reference * to the callback object.

* A callback should generally never throw an exception, since it doesn't * necessarily have an encompassing Java environment to catch it. Any * exceptions thrown will be passed to the default callback exception * handler. */ public interface Callback { interface UncaughtExceptionHandler { /** Method invoked when the given callback throws an uncaught * exception.

* Any exception thrown by this method will be ignored. */ void uncaughtException(Callback c, Throwable e); } /** You must this method name if your callback interface has multiple public methods. Typically a callback will have only one such method, in which case any method name may be used, with the exception of those in {@link #FORBIDDEN_NAMES}. */ String METHOD_NAME = "callback"; /** These method names may not be used for a callback method. */ Collection FORBIDDEN_NAMES = Arrays.asList(new String[] { "hashCode", "equals", "toString", }); } libjna-java-3.2.7/src/com/sun/jna/DefaultTypeMapper.java0000644000175000017500000001236010753020476021171 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** Provide custom mappings to and from native types. The default lookup * checks classes corresponding to converters in the order added; if the * class to be converted is an instance of the converter's registered class, * the converter will be used.

* Derived classes should install additional converters using * {@link #addToNativeConverter} * and/or {@link #addFromNativeConverter} in the default constructor. Classes * for primitive types will automatically register for the corresponding * Object type and vice versa (i.e. you don't have to register both * int.class and Integer.class). * If you want different mapping behavior than the default, simply override * {@link #getToNativeConverter} and {@link #getFromNativeConverter}. * @see Library#OPTION_TYPE_MAPPER */ public class DefaultTypeMapper implements TypeMapper { private static class Entry { public Class type; public Object converter; public Entry(Class type, Object converter) { this.type = type; this.converter = converter; } } private List toNativeConverters = new ArrayList(); private List fromNativeConverters = new ArrayList(); private Class getAltClass(Class cls) { if (cls == Boolean.class) { return boolean.class; } else if (cls == boolean.class) { return Boolean.class; } else if (cls == Byte.class) { return byte.class; } else if (cls == byte.class) { return Byte.class; } else if (cls == Character.class) { return char.class; } else if (cls == char.class) { return Character.class; } else if (cls == Short.class) { return short.class; } else if (cls == short.class) { return Short.class; } else if (cls == Integer.class) { return int.class; } else if (cls == int.class) { return Integer.class; } else if (cls == Long.class) { return long.class; } else if (cls == long.class) { return Long.class; } else if (cls == Float.class) { return float.class; } else if (cls == float.class) { return Float.class; } else if (cls == Double.class) { return double.class; } else if (cls == double.class) { return Double.class; } return null; } /** Add a {@link ToNativeConverter} to define the conversion into a native * type from arguments of the given Java type. Converters are * checked for in the order added. */ public void addToNativeConverter(Class cls, ToNativeConverter converter) { toNativeConverters.add(new Entry(cls, converter)); Class alt = getAltClass(cls); if (alt != null) { toNativeConverters.add(new Entry(alt, converter)); } } /** Add a {@link FromNativeConverter} to convert a native result type into the * given Java type. Converters are checked for in the order added. */ public void addFromNativeConverter(Class cls, FromNativeConverter converter) { fromNativeConverters.add(new Entry(cls, converter)); Class alt = getAltClass(cls); if (alt != null) { fromNativeConverters.add(new Entry(alt, converter)); } } /** Add a {@link TypeConverter} to provide bidirectional mapping between * a native and Java type. */ protected void addTypeConverter(Class cls, TypeConverter converter) { addFromNativeConverter(cls, converter); addToNativeConverter(cls, converter); } private Object lookupConverter(Class javaClass, List converters) { for (Iterator i=converters.iterator();i.hasNext();) { Entry entry = (Entry)i.next(); if (entry.type.isAssignableFrom(javaClass)) { return entry.converter; } } return null; } /* (non-Javadoc) * @see com.sun.jna.TypeMapper#getFromNativeConverter(java.lang.Class) */ public FromNativeConverter getFromNativeConverter(Class javaType) { return (FromNativeConverter)lookupConverter(javaType, fromNativeConverters); } /* (non-Javadoc) * @see com.sun.jna.TypeMapper#getToNativeConverter(java.lang.Class) */ public ToNativeConverter getToNativeConverter(Class javaType) { return (ToNativeConverter)lookupConverter(javaType, toNativeConverters); } } libjna-java-3.2.7/src/com/sun/jna/Union.java0000644000175000017500000002111011204227140016644 0ustar janjan/* 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. * * 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; import java.util.Iterator; /** Represents a native union. When writing to native memory, the field * corresponding to the type passed to {@link #setType} will be written * to native memory. Upon reading from native memory, Structure, String, * or WString fields will not be initialized unless they are * the current field as identified by a call to {@link #setType}. The current * field is always unset by default to avoid accidentally attempting to read * a field that is not valid. In the case of a String, for instance, an * invalid pointer may result in a memory fault when attempting to initialize * the String. */ public abstract class Union extends Structure { private StructField activeField; StructField biggestField; /** Create a Union whose size and alignment will be calculated * automatically. */ protected Union() { } /** Create a Union of the given size, using default alignment. */ protected Union(Pointer p) { super(p); } /** Create a Union of the given size and alignment type. */ protected Union(Pointer p, int alignType) { super(p, alignType); } /** Create a Union of the given size and alignment type. */ protected Union(TypeMapper mapper) { super(mapper); } /** Create a Union of the given size and alignment type. */ protected Union(Pointer p, int alignType, TypeMapper mapper) { super(p, alignType, mapper); } /** Indicates which field will be used to write to native memory. * @throws IllegalArgumentException if the type does not correspond to * any declared union field. */ public void setType(Class type) { ensureAllocated(); for (Iterator i=fields().values().iterator();i.hasNext();) { StructField f = (StructField)i.next(); if (f.type == type) { activeField = f; return; } } throw new IllegalArgumentException("No field of type " + type + " in " + this); } /** Force a read of the given field from native memory. * @return the new field value, after updating * @throws IllegalArgumentException if no field exists with the given name */ public Object readField(String name) { ensureAllocated(); StructField f = (StructField)fields().get(name); if (f != null) { setType(f.type); } return super.readField(name); } /** Write the given field value to native memory. * The given field will become the active one. * @throws IllegalArgumentException if no field exists with the given name */ public void writeField(String name) { ensureAllocated(); StructField f = (StructField)fields().get(name); if (f != null) { setType(f.type); } super.writeField(name); } /** Write the given field value to the field and native memory. * The given field will become the active one. * @throws IllegalArgumentException if no field exists with the given name */ public void writeField(String name, Object value) { ensureAllocated(); StructField f = (StructField)fields().get(name); if (f != null) { setType(f.type); } super.writeField(name, value); } /** Reads the Structure field of the given type from memory, sets it as * the active type and returns it. Convenience method for *


     * Union u;
     * Class type;
     * u.setType(type);
     * u.read();
     * value = u.field;
     * 
* @param type class type of the Structure field to read * @return the Structure field with the given type */ public Object getTypedValue(Class type) { ensureAllocated(); for (Iterator i=fields().values().iterator();i.hasNext();) { StructField f = (StructField)i.next(); if (f.type == type) { activeField = f; read(); return getField(activeField); } } throw new IllegalArgumentException("No field of type " + type + " in " + this); } /** Set the active type and its value. Convenience method for *

     * Union u;
     * Class type;
     * u.setType(type);
     * u.field = value;
     * 
* @param object instance of a class which is part of the union * @return this Union object */ public Object setTypedValue(Object object) { ensureAllocated(); StructField f = findField(object.getClass()); if (f != null) { activeField = f; setField(f, object); return this; } throw new IllegalArgumentException("No field of type " + object.getClass() + " in " + this); } /** Returns the field in this union with the same type as type, * if any, null otherwise. * @param type type to search for * @return StructField of matching type */ private StructField findField(Class type) { for (Iterator i=fields().values().iterator();i.hasNext();) { StructField f = (StructField)i.next(); if (f.type.isAssignableFrom(type)) { return f; } } return null; } /** Only the currently selected field will be written. */ void writeField(StructField field) { if (field == activeField) { super.writeField(field); } } /** Avoid reading pointer-based fields and structures unless explicitly * selected. Structures may contain pointer-based fields which can * crash the VM if not properly initialized. */ Object readField(StructField field) { if (field == activeField || (!Structure.class.isAssignableFrom(field.type) && !String.class.isAssignableFrom(field.type) && !WString.class.isAssignableFrom(field.type))) { return super.readField(field); } // Field not accessible // TODO: read structure, to the extent possible; need a "recursive" // flag to "read" return null; } /** Adjust the size to be the size of the largest element, and ensure * all fields begin at offset zero. */ int calculateSize(boolean force) { int size = super.calculateSize(force); if (size != CALCULATE_SIZE) { int fsize = 0; for (Iterator i=fields().values().iterator();i.hasNext();) { StructField f = (StructField)i.next(); f.offset = 0; if (f.size > fsize // Prefer aggregate types to simple types, since they // will have more complex packing rules (some platforms // have specific methods for packing small structs into // registers, which may not match the packing of bytes // for a primitive type). || (f.size == fsize && Structure.class.isAssignableFrom(f.type))) { fsize = f.size; biggestField = f; } } size = calculateAlignedSize(fsize); if (size > 0) { // Update native FFI type information, if needed if (this instanceof ByValue) { getTypeInfo(); } } } return size; } /** All fields are considered the "first" element. */ protected int getNativeAlignment(Class type, Object value, boolean isFirstElement) { return super.getNativeAlignment(type, value, true); } /** Avoid calculating type information until we know our biggest field. * Return type information for the largest field to ensure all available * bits are used. */ Pointer getTypeInfo() { if (biggestField == null) { // Not calculated yet return null; } return super.getTypeInfo(); } } libjna-java-3.2.7/src/com/sun/jna/ptr/0000755000175000017500000000000011220641326015527 5ustar janjanlibjna-java-3.2.7/src/com/sun/jna/ptr/DoubleByReference.java0000644000175000017500000000175710753020504021727 0ustar janjan/* 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. *

* 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.ptr; public class DoubleByReference extends ByReference { public DoubleByReference() { this(0d); } public DoubleByReference(double value) { super(8); setValue(value); } public void setValue(double value) { getPointer().setDouble(0, value); } public double getValue() { return getPointer().getDouble(0); } } libjna-java-3.2.7/src/com/sun/jna/ptr/ShortByReference.java0000644000175000017500000000176210753020504021610 0ustar janjan/* 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. *

* 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.ptr; public class ShortByReference extends ByReference { public ShortByReference() { this((short)0); } public ShortByReference(short value) { super(2); setValue(value); } public void setValue(short value) { getPointer().setShort(0, value); } public short getValue() { return getPointer().getShort(0); } } libjna-java-3.2.7/src/com/sun/jna/ptr/LongByReference.java0000644000175000017500000000173210753020504021405 0ustar janjan/* 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. *

* 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.ptr; public class LongByReference extends ByReference { public LongByReference() { this(0L); } public LongByReference(long value) { super(8); setValue(value); } public void setValue(long value) { getPointer().setLong(0, value); } public long getValue() { return getPointer().getLong(0); } } libjna-java-3.2.7/src/com/sun/jna/ptr/ByteByReference.java0000644000175000017500000000174110753020504021411 0ustar janjan/* 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. *

* 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.ptr; public class ByteByReference extends ByReference { public ByteByReference() { this((byte)0); } public ByteByReference(byte value) { super(1); setValue(value); } public void setValue(byte value) { getPointer().setByte(0, value); } public byte getValue() { return getPointer().getByte(0); } } libjna-java-3.2.7/src/com/sun/jna/ptr/ByReference.java0000644000175000017500000000255311220641326020570 0ustar janjan/* 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. *

* 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.ptr; import com.sun.jna.Memory; import com.sun.jna.NativeMapped; import com.sun.jna.Pointer; import com.sun.jna.PointerType; /** Provides generic "pointer to type" functionality, often used in C * code to return values to the caller in addition to a function result. *

* Derived classes should define setValue(<T>) * and <T> getValue() methods which write to/read from * memory. *

This class derives from PointerType instead of Memory in order to * restrict the API to only getValue/setValue. *

NOTE: this class would ideally be replaced by a generic. */ public abstract class ByReference extends PointerType { protected ByReference(int dataSize) { setPointer(new Memory(dataSize)); } } libjna-java-3.2.7/src/com/sun/jna/ptr/PointerByReference.java0000644000175000017500000000222210753020504022121 0ustar janjan/* 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. *

* 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.ptr; import com.sun.jna.Pointer; /** Represents a reference to a pointer to native data. * In C notation, void**. * @author twall */ public class PointerByReference extends ByReference { public PointerByReference() { this(null); } public PointerByReference(Pointer value) { super(Pointer.SIZE); setValue(value); } public void setValue(Pointer value) { getPointer().setPointer(0, value); } public Pointer getValue() { return getPointer().getPointer(0); } } libjna-java-3.2.7/src/com/sun/jna/ptr/IntByReference.java0000644000175000017500000000172210753020504021237 0ustar janjan/* 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. *

* 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.ptr; public class IntByReference extends ByReference { public IntByReference() { this(0); } public IntByReference(int value) { super(4); setValue(value); } public void setValue(int value) { getPointer().setInt(0, value); } public int getValue() { return getPointer().getInt(0); } } libjna-java-3.2.7/src/com/sun/jna/ptr/FloatByReference.java0000644000175000017500000000174310753020504021555 0ustar janjan/* 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. *

* 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.ptr; public class FloatByReference extends ByReference { public FloatByReference() { this(0f); } public FloatByReference(float value) { super(4); setValue(value); } public void setValue(float value) { getPointer().setFloat(0, value); } public float getValue() { return getPointer().getFloat(0); } } libjna-java-3.2.7/src/com/sun/jna/ptr/NativeLongByReference.java0000644000175000017500000000210410753020504022546 0ustar janjan/* 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. * * 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.ptr; import com.sun.jna.NativeLong; public class NativeLongByReference extends ByReference { public NativeLongByReference() { this(new NativeLong(0)); } public NativeLongByReference(NativeLong value) { super(NativeLong.SIZE); setValue(value); } public void setValue(NativeLong value) { getPointer().setNativeLong(0, value); } public NativeLong getValue() { return getPointer().getNativeLong(0); } } libjna-java-3.2.7/test/0000755000175000017500000000000011060341164012756 5ustar janjanlibjna-java-3.2.7/test/com/0000755000175000017500000000000010753020506013536 5ustar janjanlibjna-java-3.2.7/test/com/sun/0000755000175000017500000000000010753020506014343 5ustar janjanlibjna-java-3.2.7/test/com/sun/jna/0000755000175000017500000000000011421002534015105 5ustar janjanlibjna-java-3.2.7/test/com/sun/jna/UnionTest.java0000644000175000017500000001432411372233154017715 0ustar janjan/* 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. * * 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; import junit.framework.TestCase; @SuppressWarnings("unused") public class UnionTest extends TestCase { public static class TestStructure extends Structure { public String value; } public static class BigTestStructure extends Structure { public long field1; public long field2; } public static class IntStructure extends Structure { public int value; } public static class SubIntStructure extends IntStructure {} public static interface Func1 extends Callback { public void callback(); } public static class SizedUnion extends Union { public byte byteField; public short shortField; public int intField; public long longField; public TestStructure structField; public BigTestStructure structField2; public String string; public WString wstring; public Pointer pointer; } public static class StructUnion extends Union { public int intField; public TestStructure testStruct; public IntStructure intStruct; public Func1 func1; } public void testCalculateSize() { Union u = new SizedUnion(); assertEquals("Union should be size of largest field", new BigTestStructure().size(), u.size()); } public void testFieldOffsets() { StructUnion u = new StructUnion(); u.setType(u.testStruct.getClass()); u.write(); assertEquals("Wrong struct member base address", u.getPointer(), u.testStruct.getPointer()); u.setType(u.intStruct.getClass()); u.write(); assertEquals("Wrong struct member base address (2)", u.getPointer(), u.intStruct.getPointer()); } public void testWriteUnion() { SizedUnion u = new SizedUnion(); final int VALUE = 0x12345678; u.intField = VALUE; u.setType(int.class); u.write(); assertEquals("Wrong value written", VALUE, u.getPointer().getInt(0)); } public void testReadUnion() { SizedUnion u = new SizedUnion(); final int VALUE = 0x12345678; u.getPointer().setInt(0, VALUE); u.read(); assertEquals("int field not read properly", VALUE, u.intField); assertTrue("byte field not read", u.byteField != 0); assertTrue("short field not read", u.shortField != 0); assertTrue("long field not read", u.longField != 0); assertNotNull("Unselected Pointer not read", u.pointer); assertNull("Unselected structure should not be read", u.structField.value); assertNull("Unselected String should be null", u.string); assertNull("Unselected WString should be null", u.wstring); } public void testWriteTypedUnion() { final int VALUE = 0x12345678; // write an instance of a direct union class to memory StructUnion u = new StructUnion(); IntStructure intStruct = new IntStructure(); intStruct.value = VALUE; u.setTypedValue(intStruct); u.write(); assertEquals("Wrong value written", VALUE, u.getPointer().getInt(0)); // write an instance of a sub class of an union class to memory u = new StructUnion(); SubIntStructure subIntStructure = new SubIntStructure(); subIntStructure.value = VALUE; u.setTypedValue(subIntStructure); u.write(); assertEquals("Wrong value written", VALUE, u.getPointer().getInt(0)); // write an instance of an interface u = new StructUnion(); Func1 func1 = new Func1() { public void callback() { System.out.println("hi"); } }; u.setTypedValue(func1); } public void testReadTypedUnion() { StructUnion u = new StructUnion(); final int VALUE = 0x12345678; u.getPointer().setInt(0, VALUE); assertEquals("int structure not read properly", VALUE, ((IntStructure) u.getTypedValue(IntStructure.class)).value); } public void testReadTypeInfo() { SizedUnion u = new SizedUnion(); if (Native.POINTER_SIZE == 4) { assertEquals("Type size should be that of longest field if no field active", Structure.getTypeInfo(BigTestStructure.class).getInt(0), u.getTypeInfo().getInt(0)); } else { assertEquals("Type size should be that of longest field if no field active", Structure.getTypeInfo(BigTestStructure.class).getLong(0), u.getTypeInfo().getLong(0)); } u.setType(int.class); if (Native.POINTER_SIZE == 4) { assertEquals("Type size should be that of longest field if field active", Structure.getTypeInfo(BigTestStructure.class).getInt(0), u.getTypeInfo().getInt(0)); } else { assertEquals("Type size should be that of longest field if field active", Structure.getTypeInfo(BigTestStructure.class).getLong(0), u.getTypeInfo().getLong(0)); } } public void testArraysInUnion() { class TestUnion extends Union { public byte[] bytes = new byte[16]; public short[] shorts = new short[8]; public int[] ints = new int[4]; } Union u = new TestUnion(); u.setType(byte[].class); u.setType(short[].class); u.setType(int[].class); } public static void main(String[] args) { junit.textui.TestRunner.run(UnionTest.class); } } libjna-java-3.2.7/test/com/sun/jna/DirectTest.java0000644000175000017500000004764511372233154020053 0ustar janjan/* Copyright (c) 2009 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. *

* 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; import junit.framework.*; import com.sun.jna.*; import com.sun.jna.ptr.PointerByReference; import java.lang.ref.*; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; @SuppressWarnings("unused") public class DirectTest extends TestCase { private static final String BUILDDIR = System.getProperty("jna.builddir", "build" + (Platform.is64Bit() ? "-d64" : "")); private static class JNI { static { String path = BUILDDIR + "/native/" + System.mapLibraryName("testlib");; if (!new File(path).isAbsolute()) { path = System.getProperty("user.dir") + "/" + path; } if (path.endsWith(".jnilib")) { path = path.replace(".jnilib", ".dylib"); } System.load(path); } private static native double cos(double x); } public static void main(java.lang.String[] argList) { junit.textui.TestRunner.run(DirectTest.class); checkPerformance(); } static class MathLibrary { public static native double cos(double x); static { Native.register(Platform.isWindows()?"msvcrt":"m"); } } interface MathInterface extends Library { double cos(double x); } static class CLibrary { public static class size_t extends IntegerType { public size_t() { super(Native.POINTER_SIZE); } public size_t(long value) { super(Native.POINTER_SIZE, value); } } public static native Pointer memset(Pointer p, int v, size_t len); public static native Pointer memset(Pointer p, int v, int len); public static native Pointer memset(Pointer p, int v, long len); public static native long memset(long p, int v, long len); public static native int memset(int p, int v, int len); public static native int strlen(String s1); public static native int strlen(Pointer p); public static native int strlen(byte[] b); public static native int strlen(Buffer b); static { Native.register(Platform.isWindows()?"msvcrt":"c"); } } static interface CInterface extends Library { Pointer memset(Pointer p, int v, int len); int strlen(String s); } static interface TestInterface extends Library { interface Int32Callback extends Callback { int invoke(int arg1, int arg2); } interface NativeLongCallback extends Callback { NativeLong invoke(NativeLong arg1, NativeLong arg2); } int callInt32CallbackRepeatedly(Int32Callback cb, int arg1, int arg2, int count); NativeLong callLongCallbackRepeatedly(NativeLongCallback cb, NativeLong arg1, NativeLong arg2, int count); } static class TestLibrary implements TestInterface { public native int callInt32CallbackRepeatedly(Int32Callback cb, int arg1, int arg2, int count); public native NativeLong callLongCallbackRepeatedly(NativeLongCallback cb, NativeLong arg1, NativeLong arg2, int count); static { Native.register("testlib"); } } private static class TestLoader extends URLClassLoader { public TestLoader() throws MalformedURLException { super(new URL[] { new File(BUILDDIR + "/classes").toURI().toURL(), new File(BUILDDIR + "/test-classes").toURI().toURL(), }, null); } } public void testRegisterMethods() throws Exception { // Use a dedicated class loader to ensure the class can be gc'd String name = "com.sun.jna.DirectTest$MathLibrary"; ClassLoader loader = new TestLoader(); Class cls = Class.forName(name, true, loader); assertNotNull("Failed loading class", cls); WeakReference ref = new WeakReference(cls); loader = null; cls = null; System.gc(); for (int i=0;i < 100 && ref.get() != null;i++) { try { Thread.sleep(10); // Give the GC a chance to run System.gc(); } finally {} } // TODO: need a real check to ensure native memory is freed assertNull("Registered methods not GC'd: " + ref.get(), ref.get()); } private Class returnCallingClass() { return Native.getCallingClass(); } public void testFindCallingClass() { assertEquals("Wrong calling class detected", getClass(), returnCallingClass()); } public void testFindNativeClass() { class UnregisterLibrary { class Inner { public Class getNativeClass() { return getNativeClassInner(); } public Class getNativeClassInner() { return Native.getNativeClass(Native.getCallingClass()); }; } public native double cos(double x); public Class getNativeClass() { return new Inner().getNativeClass(); }; } assertEquals("Wrong native class found", UnregisterLibrary.class, new UnregisterLibrary().getNativeClass()); } // Requires java.library.path include testlib public static void checkPerformance() { final int COUNT = 100000; System.out.println("Checking performance of different access methods (" + COUNT + " iterations)"); final int SIZE = 8*1024; ByteBuffer b = ByteBuffer.allocateDirect(SIZE); // Native order is faster b.order(ByteOrder.nativeOrder()); Pointer pb = Native.getDirectBufferPointer(b); String mname = Platform.isWindows()?"msvcrt":"m"; MathInterface mlib = (MathInterface) Native.loadLibrary(mname, MathInterface.class); Function f = NativeLibrary.getInstance(mname).getFunction("cos"); /////////////////////////////////////////// // cos Object[] args = { new Double(0) }; double dresult; long start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { dresult = mlib.cos(0d); } long delta = System.currentTimeMillis() - start; System.out.println("cos (JNA interface): " + delta + "ms"); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { dresult = f.invokeDouble(args); } delta = System.currentTimeMillis() - start; System.out.println("cos (JNA function): " + delta + "ms"); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { dresult = MathLibrary.cos(0d); } delta = System.currentTimeMillis() - start; System.out.println("cos (JNA direct): " + delta + "ms"); long types = pb.peer; long cif; long resp; long argv; if (Native.POINTER_SIZE == 4) { b.putInt(0, (int)Structure.FFIType.get(double.class).peer); cif = Native.ffi_prep_cif(0, 1, Structure.FFIType.get(double.class).peer, types); resp = pb.peer + 4; argv = pb.peer + 12; double INPUT = 42; start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { b.putInt(12, (int)pb.peer + 16); b.putDouble(16, INPUT); Native.ffi_call(cif, f.peer, resp, argv); dresult = b.getDouble(4); } delta = System.currentTimeMillis() - start; } else { b.putLong(0, Structure.FFIType.get(double.class).peer); cif = Native.ffi_prep_cif(0, 1, Structure.FFIType.get(double.class).peer, types); resp = pb.peer + 8; argv = pb.peer + 16; double INPUT = 42; start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { b.putLong(16, pb.peer + 24); b.putDouble(24, INPUT); Native.ffi_call(cif, f.peer, resp, argv); dresult = b.getDouble(8); } delta = System.currentTimeMillis() - start; } System.out.println("cos (JNI ffi): " + delta + "ms"); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { dresult = JNI.cos(0d); } delta = System.currentTimeMillis() - start; System.out.println("cos (JNI): " + delta + "ms"); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { dresult = Math.cos(0d); } delta = System.currentTimeMillis() - start; System.out.println("cos (pure java): " + delta + "ms"); /////////////////////////////////////////// // memset Pointer presult; String cname = Platform.isWindows()?"msvcrt":"c"; CInterface clib = (CInterface) Native.loadLibrary(cname, CInterface.class); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { presult = clib.memset(null, 0, 0); } delta = System.currentTimeMillis() - start; System.out.println("memset (JNA interface): " + delta + "ms"); f = NativeLibrary.getInstance(cname).getFunction("memset"); args = new Object[] { null, new Integer(0), new Integer(0)}; start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { presult = f.invokePointer(args); } delta = System.currentTimeMillis() - start; System.out.println("memset (JNA function): " + delta + "ms"); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { presult = CLibrary.memset((Pointer)null, 0, new CLibrary.size_t(0)); } delta = System.currentTimeMillis() - start; System.out.println("memset (JNA direct Pointer/size_t): " + delta + "ms"); start = System.currentTimeMillis(); if (Native.POINTER_SIZE == 4) { for (int i=0;i < COUNT;i++) { presult = CLibrary.memset((Pointer)null, 0, 0); } } else { for (int i=0;i < COUNT;i++) { presult = CLibrary.memset((Pointer)null, 0, 0L); } } delta = System.currentTimeMillis() - start; System.out.println("memset (JNA direct Pointer/primitive): " + delta + "ms"); int iresult; long jresult; start = System.currentTimeMillis(); if (Native.POINTER_SIZE == 4) { for (int i=0;i < COUNT;i++) { iresult = CLibrary.memset(0, 0, 0); } } else { for (int i=0;i < COUNT;i++) { jresult = CLibrary.memset(0L, 0, 0L); } } delta = System.currentTimeMillis() - start; System.out.println("memset (JNA direct primitives): " + delta + "ms"); if (Native.POINTER_SIZE == 4) { b.putInt(0, (int)Structure.FFIType.get(Pointer.class).peer); b.putInt(4, (int)Structure.FFIType.get(int.class).peer); b.putInt(8, (int)Structure.FFIType.get(int.class).peer); cif = Native.ffi_prep_cif(0, 3, Structure.FFIType.get(Pointer.class).peer, types); resp = pb.peer + 12; argv = pb.peer + 16; start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { b.putInt(16, (int)pb.peer + 28); b.putInt(20, (int)pb.peer + 32); b.putInt(24, (int)pb.peer + 36); b.putInt(28, 0); b.putInt(32, 0); b.putInt(36, 0); Native.ffi_call(cif, f.peer, resp, argv); b.getInt(12); } delta = System.currentTimeMillis() - start; } else { b.putLong(0, Structure.FFIType.get(Pointer.class).peer); b.putLong(8, Structure.FFIType.get(int.class).peer); b.putLong(16, Structure.FFIType.get(long.class).peer); cif = Native.ffi_prep_cif(0, 3, Structure.FFIType.get(Pointer.class).peer, types); resp = pb.peer + 24; argv = pb.peer + 32; start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { b.putLong(32, pb.peer + 56); b.putLong(40, pb.peer + 64); b.putLong(48, pb.peer + 72); b.putLong(56, 0); b.putInt(64, 0); b.putLong(72, 0); Native.ffi_call(cif, f.peer, resp, argv); b.getLong(24); } delta = System.currentTimeMillis() - start; } System.out.println("memset (JNI ffi): " + delta + "ms"); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { Pointer._setMemory(0L, 0L, (byte)0); } delta = System.currentTimeMillis() - start; System.out.println("memset (JNI): " + delta + "ms"); /////////////////////////////////////////// // strlen String str = "performance test"; start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { iresult = clib.strlen(str); } delta = System.currentTimeMillis() - start; System.out.println("strlen (JNA interface): " + delta + "ms"); f = NativeLibrary.getInstance(cname).getFunction("strlen"); args = new Object[] { str }; start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { iresult = f.invokeInt(args); } delta = System.currentTimeMillis() - start; System.out.println("strlen (JNA function): " + delta + "ms"); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { iresult = CLibrary.strlen(str); } delta = System.currentTimeMillis() - start; System.out.println("strlen (JNA direct - String): " + delta + "ms"); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { iresult = CLibrary.strlen(new NativeString(str).getPointer()); } delta = System.currentTimeMillis() - start; System.out.println("strlen (JNA direct - Pointer): " + delta + "ms"); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { iresult = CLibrary.strlen(Native.toByteArray(str)); } delta = System.currentTimeMillis() - start; System.out.println("strlen (JNA direct - byte[]): " + delta + "ms"); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { byte[] bytes = str.getBytes(); b.position(0); b.put(bytes); b.put((byte)0); iresult = CLibrary.strlen(b); } delta = System.currentTimeMillis() - start; System.out.println("strlen (JNA direct - Buffer): " + delta + "ms"); if (Native.POINTER_SIZE == 4) { b.putInt(0, (int)Structure.FFIType.get(Pointer.class).peer); cif = Native.ffi_prep_cif(0, 1, Structure.FFIType.get(int.class).peer, types); resp = pb.peer + 4; argv = pb.peer + 8; start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { b.putInt(8, (int)pb.peer + 12); b.putInt(12, (int)pb.peer + 16); b.position(16); // This operation is very expensive! b.put(str.getBytes()); b.put((byte)0); Native.ffi_call(cif, f.peer, resp, argv); iresult = b.getInt(4); } delta = System.currentTimeMillis() - start; } else { b.putLong(0, Structure.FFIType.get(Pointer.class).peer); cif = Native.ffi_prep_cif(0, 1, Structure.FFIType.get(long.class).peer, types); resp = pb.peer + 8; argv = pb.peer + 16; start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { b.putLong(16, pb.peer + 24); b.putLong(24, pb.peer + 32); b.position(32); // This operation is very expensive! b.put(str.getBytes()); b.put((byte)0); Native.ffi_call(cif, f.peer, resp, argv); jresult = b.getLong(8); } delta = System.currentTimeMillis() - start; } System.out.println("strlen (JNI ffi): " + delta + "ms"); /////////////////////////////////////////// // Direct buffer vs. Pointer methods byte[] bulk = new byte[SIZE]; start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { b.putInt(0, 0); } delta = System.currentTimeMillis() - start; System.out.println("direct Buffer write: " + delta + "ms"); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { b.position(0); b.put(bulk); } delta = System.currentTimeMillis() - start; System.out.println("direct Buffer write (bulk): " + delta + "ms"); Pointer p = new Memory(SIZE); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { p.setInt(0, 0); } delta = System.currentTimeMillis() - start; System.out.println("Memory write: " + delta + "ms"); start = System.currentTimeMillis(); for (int i=0;i < COUNT;i++) { p.write(0, bulk, 0, bulk.length); } delta = System.currentTimeMillis() - start; System.out.println("Memory write (bulk): " + delta + "ms"); /////////////////////////////////////////// // Callbacks TestInterface tlib = (TestInterface)Native.loadLibrary("testlib", TestInterface.class); start = System.currentTimeMillis(); TestInterface.Int32Callback cb = new TestInterface.Int32Callback() { public int invoke(int arg1, int arg2) { return arg1 + arg2; } }; tlib.callInt32CallbackRepeatedly(cb, 1, 2, COUNT); delta = System.currentTimeMillis() - start; System.out.println("callback (JNA interface): " + delta + "ms"); tlib = new TestLibrary(); start = System.currentTimeMillis(); tlib.callInt32CallbackRepeatedly(cb, 1, 2, COUNT); delta = System.currentTimeMillis() - start; System.out.println("callback (JNA direct): " + delta + "ms"); start = System.currentTimeMillis(); TestInterface.NativeLongCallback nlcb = new TestInterface.NativeLongCallback() { public NativeLong invoke(NativeLong arg1, NativeLong arg2) { return new NativeLong(arg1.longValue() + arg2.longValue()); } }; tlib.callLongCallbackRepeatedly(nlcb, new NativeLong(1), new NativeLong(2), COUNT); delta = System.currentTimeMillis() - start; System.out.println("callback w/NativeMapped (JNA interface): " + delta + "ms"); tlib = new TestLibrary(); start = System.currentTimeMillis(); tlib.callLongCallbackRepeatedly(nlcb, new NativeLong(1), new NativeLong(2), COUNT); delta = System.currentTimeMillis() - start; System.out.println("callback w/NativeMapped (JNA direct): " + delta + "ms"); } } libjna-java-3.2.7/test/com/sun/jna/StructureTest.java0000644000175000017500000013520611372233154020630 0ustar janjan/* Copyright (c) 2007-2009 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. *

* 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; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.DoubleBuffer; import java.util.Arrays; import java.util.List; import java.util.Map; import junit.framework.TestCase; import com.sun.jna.ptr.ByteByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.LongByReference; /** TODO: need more alignment tests, especially platform-specific behavior * @author twall@users.sf.net */ @SuppressWarnings("unused") public class StructureTest extends TestCase { public static void main(java.lang.String[] argList) { junit.textui.TestRunner.run(StructureTest.class); } public void testSimpleSize() throws Exception { class TestStructure extends Structure { public int field; } Structure s = new TestStructure(); assertEquals("Wrong size", 4, s.size()); } // must be public to populate array public static class TestAllocStructure extends Structure { public int f0; public int f1; public int f2; public int f3; } public void testFieldsAllocated() { class TestStructure extends Structure { public TestStructure() { } public TestStructure(Pointer p) { super(p); } public int field; public int fieldCount() { return fields().size(); } } TestStructure s = new TestStructure(); assertEquals("Wrong number of fields (default)", 1, s.fieldCount()); s = new TestStructure(new Memory(4)); assertEquals("Wrong number of fields (preallocated)", 1, s.fieldCount()); } public void testProvidedMemoryTooSmall() { class TestStructure extends Structure { public TestStructure() { } public TestStructure(Pointer p) { super(p); } public int field; public int fieldCount() { return fields().size(); } } try { TestStructure s = new TestStructure(new Memory(2)); fail("Expect exception if provided memory is insufficient"); } catch(IllegalArgumentException e) { } } public void testClearOnAllocate() { TestAllocStructure s = new TestAllocStructure(); s.read(); assertEquals("Memory not cleared on structure init", 0, s.f0); assertEquals("Memory not cleared on structure init", 0, s.f1); assertEquals("Memory not cleared on structure init", 0, s.f2); assertEquals("Memory not cleared on structure init", 0, s.f3); s = (TestAllocStructure)s.toArray(2)[1]; assertEquals("Memory not cleared on array init", 0, s.f0); assertEquals("Memory not cleared on array init", 0, s.f1); assertEquals("Memory not cleared on array init", 0, s.f2); assertEquals("Memory not cleared on array init", 0, s.f3); } // cross-platform smoke test public void testGNUCAlignment() { class TestStructure extends Structure { public byte b; public short s; public int i; public long l; public float f; public double d; } TestStructure s = new TestStructure(); s.setAlignType(Structure.ALIGN_GNUC); boolean isSPARC = "sparc".equals(System.getProperty("os.arch")); final int SIZE = NativeLong.SIZE == 4 && !isSPARC ? 28 : 32; assertEquals("Wrong structure size", SIZE, s.size()); } // cross-platform smoke test public void testMSVCAlignment() { class TestStructure extends Structure { public byte b; public short s; public int i; public long l; public float f; public double d; } TestStructure s = new TestStructure(); s.setAlignType(Structure.ALIGN_MSVC); assertEquals("Wrong structure size", 32, s.size()); } public static class FilledStructure extends Structure { public FilledStructure() { for (int i=0;i < size();i++) { getPointer().setByte(i, (byte)0xFF); } } } // Do NOT change the order of naming w/o changing testlib.c as well public static class TestStructure0 extends FilledStructure { public byte field0 = 0x01; public short field1 = 0x0202; } public static class TestStructure1 extends FilledStructure { public byte field0 = 0x01; public int field1 = 0x02020202; } public static class TestStructure2 extends FilledStructure { public short field0 = 0x0101; public int field1 = 0x02020202; } public static class TestStructure3 extends FilledStructure { public int field0 = 0x01010101; public short field1 = 0x0202; public int field2 = 0x03030303; } public static class TestStructure4 extends FilledStructure { public int field0 = 0x01010101; public long field1 = 0x0202020202020202L; public int field2 = 0x03030303; public long field3 = 0x0404040404040404L; } public static class TestStructure5 extends FilledStructure { public long field0 = 0x0101010101010101L; public byte field1 = 0x02; } public interface SizeTest extends Library { int getStructureSize(int type); } private void testStructureSize(int index) { try { SizeTest lib = (SizeTest)Native.loadLibrary("testlib", SizeTest.class); Class cls = Class.forName(getClass().getName() + "$TestStructure" + index); Structure s = Structure.newInstance(cls); assertEquals("Incorrect size: " + s, lib.getStructureSize(index), s.size()); } catch(Exception e) { throw new Error(e); } } public void testStructureSize0() { testStructureSize(0); } public void testStructureSize1() { testStructureSize(1); } public void testStructureSize2() { testStructureSize(2); } public void testStructureSize3() { testStructureSize(3); } public void testStructureSize4() { testStructureSize(4); } public void testStructureSize5() { testStructureSize(5); } public interface AlignmentTest extends Library { int testStructureAlignment(Structure s, int type, IntByReference offsetp, LongByReference valuep); } private void testAlignStruct(int index) { AlignmentTest lib = (AlignmentTest)Native.loadLibrary("testlib", AlignmentTest.class); try { IntByReference offset = new IntByReference(); LongByReference value = new LongByReference(); Class cls = Class.forName(getClass().getName() + "$TestStructure" + index); Structure s = (Structure)cls.newInstance(); int result = lib.testStructureAlignment(s, index, offset, value); assertEquals("Wrong native value at field " + result + "=0x" + Long.toHexString(value.getValue()) + " (actual native field offset=" + offset.getValue() + ") in " + s, -2, result); } catch(Exception e) { throw new Error(e); } } public void testAlignStruct0() { testAlignStruct(0); } public void testAlignStruct1() { testAlignStruct(1); } public void testAlignStruct2() { testAlignStruct(2); } public void testAlignStruct3() { testAlignStruct(3); } public void testAlignStruct4() { testAlignStruct(4); } public void testAlignStruct5() { testAlignStruct(5); } // must be publicly accessible in order to create array elements public static class PublicTestStructure extends Structure { public static class ByReference extends PublicTestStructure implements Structure.ByReference { } public int x, y; } public void testStructureField() { class TestStructure extends Structure { public PublicTestStructure s1, s2; public int after; } TestStructure s = new TestStructure(); assertNotNull("Inner structure should be initialized", s.s1); assertEquals("Wrong aggregate size", s.s1.size() + s.s2.size() + 4, s.size()); s.write(); assertEquals("Wrong memory for structure field 1 after write", s.getPointer(), s.s1.getPointer()); assertEquals("Wrong memory for structure field 2 after write", s.getPointer().share(s.s1.size()), s.s2.getPointer()); s.read(); assertEquals("Wrong memory for structure field 1 after read", s.getPointer(), s.s1.getPointer()); assertEquals("Wrong memory for structure field 2 after read", s.getPointer().share(s.s1.size()), s.s2.getPointer()); } public void testPrimitiveArrayField() { class TestStructure extends Structure { public byte[] buffer = new byte[1024]; } TestStructure s = new TestStructure(); assertEquals("Wrong size for structure with nested array", 1024, s.size()); assertNotNull("Array should be initialized", s.buffer); s.write(); s.read(); } public void testStructureArrayField() { class TestStructure extends Structure { public PublicTestStructure[] inner = new PublicTestStructure[2]; public PublicTestStructure[] inner2 = (PublicTestStructure[]) new PublicTestStructure().toArray(2); } TestStructure s = new TestStructure(); int innerSize = new PublicTestStructure().size(); assertEquals("Wrong size for structure with nested array of struct", s.inner.length * innerSize + s.inner2.length * innerSize, s.size()); s.write(); assertNotNull("Inner array elements should auto-initialize", s.inner[0]); s.inner[0].x = s.inner[0].y = -1; s.inner[1].x = s.inner[1].y = -1; s.read(); assertEquals("Inner structure array element 0 not properly read", 0, s.inner[0].x); assertEquals("Inner structure array element 1 not properly read", 0, s.inner[1].x); assertEquals("Wrong memory for uninitialized nested array", s.getPointer(), s.inner[0].getPointer()); assertEquals("Wrong memory for initialized nested array", s.getPointer().share(innerSize * s.inner.length), s.inner2[0].getPointer()); } public static class ToArrayTestStructure extends Structure { public PublicTestStructure[] inner = (PublicTestStructure[])new PublicTestStructure().toArray(2); } public void testToArrayWithStructureArrayField() { ToArrayTestStructure[] array = (ToArrayTestStructure[])new ToArrayTestStructure().toArray(2); assertEquals("Wrong address for top-level array element", array[0].getPointer().share(array[0].size()), array[1].getPointer()); assertEquals("Wrong address for nested array element", array[1].inner[0].getPointer().share(array[1].inner[0].size()), array[1].inner[1].getPointer()); } public void testUninitializedNestedArrayFails() { class TestStructure extends Structure { public Pointer[] buffer; } TestStructure s = new TestStructure(); try { s.size(); fail("Size can't be calculated unless array fields are initialized"); } catch(IllegalStateException e) { } } public void testReadWriteStructure() { class TestStructure extends Structure { public TestStructure() { // Have to do this due to inline primitive arrays allocateMemory(); } public boolean z; // native int public byte b; // native char public char c; // native wchar_t public short s; // native short public int i; // native int public long l; // native long long public float f; // native float public double d; // native double public byte[] ba = new byte[3]; public char[] ca = new char[3]; public short[] sa = new short[3]; public int[] ia = new int[3]; public long[] la = new long[3]; public float[] fa = new float[3]; public double[] da = new double[3]; public PublicTestStructure nested; } TestStructure s = new TestStructure(); // set content of the structure s.z = true; s.b = 1; s.c = 2; s.s = 3; s.i = 4; s.l = 5; s.f = 6.0f; s.d = 7.0; s.nested.x = 1; s.nested.y = 2; for (int i = 0; i < 3; i++) { s.ba[i] = (byte) (8 + i); s.ca[i] = (char) (11 + i); s.sa[i] = (short) (14 + i); s.ia[i] = 17 + i; s.la[i] = 23 + i; s.fa[i] = (float) 26 + i; s.da[i] = (double) 29 + i; } // write content to memory s.write(); Pointer p = s.getPointer(); s = new TestStructure(); s.useMemory(p); // read content from memory and compare field values s.read(); assertEquals("Wrong boolean field value after write/read", s.z, true); assertEquals("Wrong byte field value after write/read", s.b, 1); assertEquals("Wrong char field value after write/read", s.c, 2); assertEquals("Wrong short field value after write/read", s.s, 3); assertEquals("Wrong int field value after write/read", s.i, 4); assertEquals("Wrong long field value after write/read", s.l, 5); assertEquals("Wrong float field value after write/read", s.f, 6.0f); assertEquals("Wrong double field value after write/read", s.d, 7.0); assertEquals("Wrong nested struct field value after write/read (x)", s.nested.x, 1); assertEquals("Wrong nested struct field value after write/read (y)", s.nested.y, 2); for (int i = 0; i < 3; i++) { assertEquals("Wrong byte array field value after write/read", s.ba[i], (byte) (8 + i)); assertEquals("Wrong char array field value after write/read", s.ca[i], (char) (11 + i)); assertEquals("Wrong short array field value after write/read", s.sa[i], (short) (14 + i)); assertEquals("Wrong int array field value after write/read", s.ia[i], 17 + i); assertEquals("Wrong long array field value after write/read", s.la[i], 23 + i); assertEquals("Wrong float array field value after write/read", s.fa[i], (float) 26 + i); assertEquals("Wrong double array field value after write/read", s.da[i], (double) 29 + i); } // test constancy of references after read int[] ia = s.ia; s.read(); assertTrue("Array field reference should be unchanged", ia == s.ia); } public void testNativeLongSize() throws Exception { class TestStructure extends Structure { public NativeLong l; } Structure s = new TestStructure(); assertEquals("Wrong size", NativeLong.SIZE, s.size()); } public void testNativeLongRead() throws Exception { class TestStructure extends Structure { public int i; public NativeLong l; } TestStructure s = new TestStructure(); if (NativeLong.SIZE == 8) { final long MAGIC = 0x1234567887654321L; s.getPointer().setLong(8, MAGIC); s.read(); assertEquals("NativeLong field mismatch", MAGIC, s.l.longValue()); } else { final int MAGIC = 0xABEDCF23; s.getPointer().setInt(4, MAGIC); s.read(); assertEquals("NativeLong field mismatch", MAGIC, s.l.intValue()); } } public void testNativeLongWrite() throws Exception { class TestStructure extends Structure { public int i; public NativeLong l; } TestStructure s = new TestStructure(); if (NativeLong.SIZE == 8) { final long MAGIC = 0x1234567887654321L; s.l = new NativeLong(MAGIC); s.write(); long l = s.getPointer().getLong(8); assertEquals("NativeLong field mismatch", MAGIC, l); } else { final int MAGIC = 0xABEDCF23; s.l = new NativeLong(MAGIC); s.write(); int i = s.getPointer().getInt(4); assertEquals("NativeLong field mismatch", MAGIC, i); } } public void testDisallowFunctionPointerAsField() { class BadFieldStructure extends Structure { public Function cb; } try { new BadFieldStructure().size(); fail("Function fields should not be allowed"); } catch(IllegalArgumentException e) { } } public static class BadFieldStructure extends Structure { public Object badField; } public void testUnsupportedField() { class BadNestedStructure extends Structure { public BadFieldStructure badStruct = new BadFieldStructure(); } try { new BadFieldStructure().size(); fail("Should throw IllegalArgumentException on bad field"); } catch(IllegalArgumentException e) { assertTrue("Exception should include field name", e.getMessage().indexOf("badField") != -1); } try { new BadNestedStructure().size(); fail("Should throw IllegalArgumentException on bad field"); } catch(IllegalArgumentException e) { assertTrue("Exception should include enclosing type: " + e, e.getMessage().indexOf(BadNestedStructure.class.getName()) != -1); assertTrue("Exception should include nested field name: " + e, e.getMessage().indexOf("badStruct") != -1); assertTrue("Exception should include field name: " + e, e.getMessage().indexOf("badField") != -1); } } public void testToArray() { PublicTestStructure s = new PublicTestStructure(); PublicTestStructure[] array = (PublicTestStructure[])s.toArray(1); assertEquals("Array should consist of a single element", 1, array.length); assertEquals("First element should be original", s, array[0]); assertEquals("Structure memory should be expanded", 2, s.toArray(2).length); } public void testByReferenceArraySync() { PublicTestStructure.ByReference s = new PublicTestStructure.ByReference(); PublicTestStructure.ByReference[] array = (PublicTestStructure.ByReference[])s.toArray(2); class TestStructure extends Structure { public PublicTestStructure.ByReference ref; } TestStructure ts = new TestStructure(); ts.ref = s; final int VALUE = 42; array[0].x = VALUE; array[1].x = VALUE; ts.write(); assertEquals("Array element not written: " + array[0], VALUE, array[0].getPointer().getInt(0)); assertEquals("Array element not written: " + array[1], VALUE, array[1].getPointer().getInt(0)); array[0].getPointer().setInt(4, VALUE); array[1].getPointer().setInt(4, VALUE); ts.read(); assertEquals("Array element not read: " + array[0], VALUE, array[0].y); assertEquals("Array element not read: " + array[1], VALUE, array[1].y); } static class CbStruct extends Structure { public Callback cb; } public void testCallbackWrite() { final CbStruct s = new CbStruct(); s.cb = new Callback() { public void callback() { } }; s.write(); Pointer func = s.getPointer().getPointer(0); assertNotNull("Callback trampoline not set", func); Map refs = CallbackReference.callbackMap; assertTrue("Callback not cached", refs.containsKey(s.cb)); CallbackReference ref = (CallbackReference)refs.get(s.cb); assertEquals("Wrong trampoline", ref.getTrampoline(), func); } public void testUninitializedArrayField() { class UninitializedArrayFieldStructure extends Structure { public byte[] array; } try { Structure s = new UninitializedArrayFieldStructure(); assertTrue("Invalid size: " + s.size(), s.size() > 0); fail("Uninitialized array field should cause write failure"); } catch(IllegalStateException e) { } } public static class ArrayOfStructure extends Structure { public Structure[] array; } public void testPlainStructureArrayField() { try { new ArrayOfStructure(); fail("Structure[] not allowed as a field of Structure"); } catch(IllegalArgumentException e) { } catch(Exception e) { fail("Wrong exception thrown on Structure[] field in Structure: " + e); } } public void testPointerArrayField() { class ArrayOfPointerStructure extends Structure { final static int SIZE = 10; public Pointer[] array = new Pointer[SIZE]; } ArrayOfPointerStructure s = new ArrayOfPointerStructure(); int size = s.size(); assertEquals("Wrong size", ArrayOfPointerStructure.SIZE * Pointer.SIZE, size); s.array[0] = s.getPointer(); s.write(); s.array[0] = null; s.read(); assertEquals("Wrong first element", s.getPointer(), s.array[0]); } class BufferStructure extends Structure { public Buffer buffer; public DoubleBuffer dbuffer; } public void testBufferFieldWriteNULL() { BufferStructure bs = new BufferStructure(); bs.write(); } public void testBufferFieldWriteNonNULL() { BufferStructure bs = new BufferStructure(); bs.buffer = ByteBuffer.allocateDirect(16); bs.dbuffer = ((ByteBuffer)bs.buffer).asDoubleBuffer(); bs.write(); } public void testBufferFieldReadUnchanged() { BufferStructure bs = new BufferStructure(); Buffer b = ByteBuffer.allocateDirect(16); bs.buffer = b; bs.dbuffer = ((ByteBuffer)bs.buffer).asDoubleBuffer(); bs.write(); bs.read(); assertEquals("Buffer field should be unchanged", b, bs.buffer); } public void testBufferFieldReadChanged() { BufferStructure bs = new BufferStructure(); if (Pointer.SIZE == 4) { bs.getPointer().setInt(0, 0x1); } else { bs.getPointer().setLong(0, 0x1); } try { bs.read(); fail("Structure read should fail if Buffer pointer was set"); } catch(IllegalStateException e) { } bs.buffer = ByteBuffer.allocateDirect(16); try { bs.read(); fail("Structure read should fail if Buffer pointer has changed"); } catch(IllegalStateException e) { } } public void testBufferFieldReadChangedToNULL() { BufferStructure bs = new BufferStructure(); bs.buffer = ByteBuffer.allocateDirect(16); bs.dbuffer = ((ByteBuffer)bs.buffer).asDoubleBuffer(); bs.read(); assertNull("Structure Buffer field should be set null", bs.buffer); assertNull("Structure DoubleBuffer field should be set null", bs.dbuffer); } public void testVolatileStructureField() { class VolatileStructure extends Structure { public volatile int counter; public int value; } VolatileStructure s = new VolatileStructure(); s.counter = 1; s.value = 1; s.write(); assertEquals("Volatile field should not be written", 0, s.getPointer().getInt(0)); assertEquals("Non-volatile field should be written", 1, s.getPointer().getInt(4)); s.writeField("counter"); assertEquals("Explicit volatile field write failed", 1, s.getPointer().getInt(0)); } public static class StructureWithPointers extends Structure { public PublicTestStructure.ByReference s1; public PublicTestStructure.ByReference s2; } public void testStructureByReferenceField() { StructureWithPointers s = new StructureWithPointers(); assertEquals("Wrong size for structure with structure references", Pointer.SIZE * 2, s.size()); assertNull("Initial refs should be null", s.s1); } public void testRegenerateStructureByReferenceField() { StructureWithPointers s = new StructureWithPointers(); PublicTestStructure.ByReference inner = new PublicTestStructure.ByReference(); s.s1 = inner; s.write(); s.s1 = null; s.read(); assertEquals("Inner structure not regenerated on read", inner, s.s1); } public void testPreserveStructureByReferenceWithUnchangedPointerOnRead() { StructureWithPointers s = new StructureWithPointers(); PublicTestStructure.ByReference inner = new PublicTestStructure.ByReference(); s.s1 = inner; s.write(); s.read(); assertSame("Read should preserve structure object", inner, s.s1); assertTrue("Read should preserve structure memory", inner.getPointer() instanceof Memory); } public static class TestPointer extends PointerType { } public void testPreservePointerFields() { class TestStructure extends Structure { public Pointer p = new Memory(256); public TestPointer p2 = new TestPointer() { { setPointer(new Memory(256)); } }; } TestStructure s = new TestStructure(); final Pointer p = s.p; s.write(); s.read(); assertSame("Should preserve Pointer references if peer unchanged", p, s.p); } public void testOverwriteStructureByReferenceFieldOnRead() { StructureWithPointers s = new StructureWithPointers(); PublicTestStructure.ByReference inner = new PublicTestStructure.ByReference(); PublicTestStructure.ByReference inner2 = new PublicTestStructure.ByReference(); s.s1 = inner2; s.write(); s.s1 = inner; s.read(); assertNotSame("Read should overwrite structure reference", inner, s.s1); } public void testAutoWriteStructureByReferenceField() { StructureWithPointers s = new StructureWithPointers(); s.s1 = new StructureTest.PublicTestStructure.ByReference(); s.s1.x = -1; s.write(); assertEquals("Structure.ByReference field not written automatically", -1, s.s1.getPointer().getInt(0)); } public void testStructureByReferenceArrayField() { class TestStructure extends Structure { public PublicTestStructure.ByReference[] array = new PublicTestStructure.ByReference[2]; } TestStructure s = new TestStructure(); assertEquals("Wrong structure size", 2*Pointer.SIZE, s.size()); PublicTestStructure.ByReference ref = new PublicTestStructure.ByReference(); ref.x = 42; Object aref = s.array; s.array[0] = ref; s.array[1] = new PublicTestStructure.ByReference(); s.write(); s.read(); assertSame("Array reference should not change", aref, s.array); assertSame("Elements should not be overwritten when unchanged", ref, s.array[0]); s.array[0] = null; s.read(); assertNotSame("Null should be overwritten with a new ref", ref, s.array[0]); assertNotNull("New ref should not be null", s.array[0]); assertEquals("New ref should be equivalent", ref, s.array[0]); } public void testAutoReadWriteStructureByReferenceArrayField() { class TestStructure extends Structure { public PublicTestStructure.ByReference field; } TestStructure s = new TestStructure(); s.field = new PublicTestStructure.ByReference(); PublicTestStructure.ByReference[] array = (PublicTestStructure.ByReference[])s.field.toArray(2); final int VALUE = -1; array[1].x = VALUE; s.write(); assertEquals("ByReference array member not auto-written", VALUE, array[1].getPointer().getInt(0)); array[1].getPointer().setInt(0, VALUE*2); s.read(); assertEquals("ByReference array member not auto-read", VALUE*2, array[1].x); } static class NestedTypeInfoStructure extends Structure { public static class Inner extends Structure { public int dummy; } public Inner inner; public int dummy; } public static class size_t extends IntegerType { public size_t() { this(0); } public size_t(long value) { super(Native.POINTER_SIZE, value); } } public void testNestedStructureTypeInfo() { class FFIType extends Structure { public FFIType(Pointer p) { useMemory(p); read(); } public size_t size; public short alignment; public short type; public Pointer elements; } NestedTypeInfoStructure s = new NestedTypeInfoStructure(); Pointer p = s.getTypeInfo(); FFIType ffi_type = new FFIType(p); assertNotNull("Type info should not be null", p); Pointer els = ffi_type.elements; Pointer inner = s.inner.getTypeInfo(); assertEquals("Wrong type information for 'inner' field", inner, els.getPointer(0)); assertEquals("Wrong type information for integer field", Structure.getTypeInfo(new Integer(0)), els.getPointer(Pointer.SIZE)); assertNull("Type element list should be null-terminated", els.getPointer(Pointer.SIZE*2)); } public void testInnerArrayTypeInfo() { class TestStructure extends Structure { public int[] inner = new int[5]; } TestStructure s = new TestStructure(); assertEquals("Wrong structure size", 20, s.size()); Pointer p = s.getTypeInfo(); assertNotNull("Type info should not be null", p); } public void testTypeInfoForNull() { assertEquals("Wrong type information for 'null'", Structure.getTypeInfo(new Pointer(0)), Structure.getTypeInfo(null)); } public void testToString() { class TestStructure extends Structure { public int intField; public PublicTestStructure inner; } TestStructure s = new TestStructure(); final String LS = System.getProperty("line.separator"); System.setProperty("jna.dump_memory", "true"); final String EXPECTED = "(?m).*" + s.size() + " bytes.*\\{" + LS + " int intField@0=0" + LS + " .* inner@4=.*\\{" + LS + " int x@0=0" + LS + " int y@4=0" + LS + " \\}" + LS + "\\}" + LS + "memory dump" + LS + "\\[00000000\\]" + LS + "\\[00000000\\]" + LS + "\\[00000000\\]"; String actual = s.toString(); assertTrue("Improperly formatted toString(): expected " + EXPECTED + "\n" + actual, actual.matches(EXPECTED)); } public void testNativeMappedWrite() { class TestStructure extends Structure { public ByteByReference ref; } TestStructure s = new TestStructure(); ByteByReference ref = s.ref = new ByteByReference(); s.write(); assertEquals("Value not properly written", ref.getPointer(), s.getPointer().getPointer(0)); s.ref = null; s.write(); assertNull("Non-null value was written: " + s.getPointer().getPointer(0), s.getPointer().getPointer(0)); } public void testNativeMappedRead() { class TestStructure extends Structure { public ByteByReference ref; } TestStructure s = new TestStructure(); s.read(); assertNull("Should read null for initial field value", s.ref); ByteByReference ref = new ByteByReference(); s.getPointer().setPointer(0, ref.getPointer()); s.read(); assertEquals("Field incorrectly read", ref, s.ref); s.getPointer().setPointer(0, null); s.read(); assertNull("Null field incorrectly read", s.ref); } public static class ROStructure extends Structure { public final int field; { // Initialize in ctor to avoid compiler replacing // field references with a constant everywhere field = 0; } } private ROStructure avoidConstantFieldOptimization(ROStructure s) { return s; } public void testReadOnlyField() { ROStructure s = new ROStructure(); s.getPointer().setInt(0, 42); s.read(); s = avoidConstantFieldOptimization(s); assertEquals("Field value should be set from native", 42, s.field); s.getPointer().setInt(0, 0); s.read(); s = avoidConstantFieldOptimization(s); assertEquals("Field value not synched after native change", 0, s.field); s.getPointer().setInt(0, 42); // current Java field value of zero should not be written to native mem s.write(); assertEquals("Field should not be written", 42, s.getPointer().getInt(0)); s.read(); s = avoidConstantFieldOptimization(s); assertEquals("Field value not synched after native change (2)", 42, s.field); } public void testNativeMappedArrayField() { final int SIZE = 24; class TestStructure extends Structure { public NativeLong[] longs = new NativeLong[SIZE]; } TestStructure s = new TestStructure(); assertEquals("Wrong structure size", Native.LONG_SIZE * SIZE, s.size()); NativeLong[] aref = s.longs; for (int i=0;i < s.longs.length;i++) { s.longs[i] = new NativeLong(i); } s.write(); for (int i=0;i < s.longs.length;i++) { assertEquals("Value not written to memory at index " + i, i, s.getPointer().getNativeLong(i * NativeLong.SIZE).intValue()); } s.read(); assertEquals("Array reference should remain unchanged on read", aref, s.longs); for (int i=0;i < s.longs.length;i++) { assertEquals("Wrong value after read at index " + i, i, s.longs[i].intValue()); } } public void testInitializeNativeMappedField() { final long VALUE = 20; final NativeLong INITIAL = new NativeLong(VALUE); class TestStructure extends Structure { // field overwritten, wrong value before write // NL bug, wrong value written { setAlignType(ALIGN_NONE); } public NativeLong nl = INITIAL; public NativeLong uninitialized; } TestStructure ts = new TestStructure(); assertEquals("Wrong value in field", VALUE, ts.nl.longValue()); assertSame("Initial value overwritten", INITIAL, ts.nl); assertEquals("Wrong field value before write", VALUE, ts.nl.longValue()); assertNotNull("Uninitialized field should be initialized", ts.uninitialized); assertEquals("Wrong initialized value", 0, ts.uninitialized.longValue()); ts.write(); assertEquals("Wrong field value written", VALUE, ts.getPointer().getNativeLong(0).longValue()); assertEquals("Wrong field value written (2)", 0, ts.getPointer().getNativeLong(NativeLong.SIZE).longValue()); ts.read(); assertEquals("Wrong field value", VALUE, ts.nl.longValue()); assertEquals("Wrong field value (2)", 0, ts.uninitialized.longValue()); } public void testInheritedStructureFieldOrder() { class TestStructure extends Structure { public int first = 1; } class TestStructureSub extends TestStructure { public int second = 2; } TestStructureSub s = new TestStructureSub(); assertEquals("Wrong size", 8, s.size()); s.write(); assertEquals("Wrong first field: " + s, s.first, s.getPointer().getInt(0)); assertEquals("Wrong second field: " + s, s.second, s.getPointer().getInt(4)); } public void testExplicitStructureFieldOrder() { final String[] ORDER = new String[] { "one", "two", "three" }; final String[] ORDER2 = new String[] { "one", "two", "three", "four" }; class TestStructure extends Structure { public int one = 1; public int three = 3; public int two = 2; { setFieldOrder(ORDER); } public List getFieldOrder() { return super.getFieldOrder(); } } class DerivedTestStructure extends TestStructure { public int four = 4; { setFieldOrder(new String[] { "four" }); } } TestStructure s = new TestStructure(); assertEquals("Wrong field order", Arrays.asList(ORDER), s.getFieldOrder()); s.write(); assertEquals("Wrong first field: " + s, s.one, s.getPointer().getInt(0)); assertEquals("Wrong second field: " + s, s.two, s.getPointer().getInt(4)); assertEquals("Wrong third field: " + s, s.three, s.getPointer().getInt(8)); DerivedTestStructure s2 = new DerivedTestStructure(); assertEquals("Wrong field order", Arrays.asList(ORDER2), s2.getFieldOrder()); s2.write(); assertEquals("Wrong first field: " + s2, s2.one, s2.getPointer().getInt(0)); assertEquals("Wrong second field: " + s2, s2.two, s2.getPointer().getInt(4)); assertEquals("Wrong third field: " + s2, s2.three, s2.getPointer().getInt(8)); assertEquals("Wrong derived field: " + s2, s2.four, s2.getPointer().getInt(12)); } public void testCustomTypeMapper() { class TestField { } class TestStructure extends Structure { public TestField field; public TestStructure() { DefaultTypeMapper m = new DefaultTypeMapper(); m.addTypeConverter(TestField.class, new TypeConverter() { public Object fromNative(Object value, FromNativeContext context) { return new TestField(); } public Class nativeType() { return String.class; } public Object toNative(Object value, ToNativeContext ctx) { return value == null ? null : value.toString(); } }); setTypeMapper(new DefaultTypeMapper()); } } new TestStructure(); } public void testWriteWithNullBoxedPrimitives() { class TestStructure extends Structure { public Boolean zfield; public Integer field; } TestStructure s = new TestStructure(); s.write(); s.read(); assertNotNull("Field should not be null after read", s.field); } public void testStructureEquals() { class OtherStructure extends Structure { public int first; public int[] second = new int[4]; public Pointer[] third = new Pointer[4]; } class TestStructure extends Structure { public int first; public int[] second = new int[4]; public Pointer[] third = new Pointer[4]; } OtherStructure s0 = new OtherStructure(); TestStructure s1 = new TestStructure(); TestStructure s2 = new TestStructure(); TestStructure s3 = new TestStructure(); int VALUE = 99; s1.first = s2.first = s3.first = VALUE; assertFalse("Structures of different classes with same fields are not equal", s1.equals(s0)); assertFalse("Structures of different classes with same fields are not equal (reflexive)", s0.equals(s1)); assertFalse("Compare to null failed", s1.equals(null)); assertTrue("Equals is not reflexive", s1.equals(s1)); assertTrue("Equals failed on identical structures", s1.equals(s2)); assertTrue("Equals is not symmetric", s2.equals(s1)); assertTrue("Equals is not transitive", s1.equals(s2) && s2.equals(s3) && s1.equals(s3)); } public void testStructureEqualsByValueByReference() { class TestStructure extends Structure { public int first; public int[] second = new int[4]; public Pointer[] third = new Pointer[4]; } class ByReference extends TestStructure implements Structure.ByReference { } class ByValue extends TestStructure implements Structure.ByValue { } TestStructure s1 = new TestStructure(); TestStructure s2 = new ByReference(); TestStructure s3 = new ByValue(); int VALUE = 99; s1.first = s2.first = s3.first = VALUE; assertTrue("Equals failed on identical ByReference", s1.equals(s2)); assertTrue("Equals is not symmetric (ByReference)", s2.equals(s1)); assertTrue("Equals failed on identical ByValue", s1.equals(s3)); assertTrue("Equals is not symmetric (ByValue)", s3.equals(s1)); assertTrue("Equals is not transitive (ByReference/ByValue)", s1.equals(s2) && s2.equals(s3) && s1.equals(s3)); } public void testStructureHashCodeMatchesEqualsTrue() { class TestStructure extends Structure { public int first; } TestStructure s1 = new TestStructure(); TestStructure s2 = new TestStructure(); s1.first = s2.first = 0x12345678; assertEquals("hashCode should match when structures equal", s1.hashCode(), s2.hashCode()); } public void testStructureEqualsIgnoresPadding() { class TestStructure extends Structure { public byte first; public int second; } TestStructure s1 = new TestStructure(); TestStructure s2 = new TestStructure(); // Make padding bits non-zero s2.getPointer().setInt(0, -1); s2.write(); assertTrue("Structure equals should ignore padding", s1.equals(s2)); } public void testRecursiveWrite() { class TestStructureByRef extends Structure implements Structure.ByReference{ public TestStructureByRef(Pointer p) { super(p); } public TestStructureByRef() { } public int unique; public TestStructureByRef s; } TestStructureByRef s = new TestStructureByRef(); s.s = new TestStructureByRef(); s.unique = 1; s.s.s = s; s.s.unique = 2; s.write(); assertEquals("Structure field contents not written", 1, s.getPointer().getInt(0)); assertEquals("ByReference structure field contents not written", 2, s.s.getPointer().getInt(0)); s.s.unique = 0; Structure value = s.s; s.read(); assertEquals("ByReference structure field not preserved", value, s.s); assertEquals("ByReference structure field contents not read", 2, s.s.unique); assertTrue("Temporary storage should be cleared", s.busy().isEmpty()); } public static class CyclicTestStructure extends Structure { public static class ByReference extends CyclicTestStructure implements Structure.ByReference {} public CyclicTestStructure(Pointer p) { super(p); } public CyclicTestStructure() { } public CyclicTestStructure.ByReference next; } public void testCyclicRead() { CyclicTestStructure s = new CyclicTestStructure(); s.next = new CyclicTestStructure.ByReference(); Structure value = s.next; s.next.next = s.next; s.write(); s.read(); assertEquals("ByReference structure field not preserved", value, s.next); value = s.next; s.next.next = null; s.read(); assertSame("ByReference structure field should reuse existing value", value, s.next); assertSame("Nested ByReference structure field should reuse existing value", value, s.next.next); } public void testAvoidMemoryAllocationInPointerCTOR() { class TestStructure extends Structure { public int field; public TestStructure(Pointer p) { super(p); } protected Memory autoAllocate(int size) { fail("Memory should not be auto-allocated"); return null; } } Memory p = new Memory(4); Structure s = new TestStructure(p); } public void testPointerCTORWithInitializedFields() { class TestStructure extends Structure { public byte[] field = new byte[256]; public TestStructure(Pointer p) { super(p); } } Memory p = new Memory(256); Structure s = new TestStructure(p); assertEquals("Wrong structure size", p.size(), s.size()); } public void testEquals() { class TestStructure extends Structure { public int field; } Structure s = new TestStructure(); assertTrue("Should match self", s.equals(s)); assertFalse("Not equal null", s.equals(null)); assertFalse("Not equal some other object", s.equals(new Object())); } } libjna-java-3.2.7/test/com/sun/jna/NativeTest.java0000644000175000017500000003465011421002534020046 0ustar janjan/* 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. * * 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; import java.util.HashMap; import java.util.Map; import java.util.Properties; import junit.framework.TestCase; @SuppressWarnings("unused") public class NativeTest extends TestCase { public void testDefaultStringEncoding() throws Exception { String encoding = System.getProperty("file.encoding"); // Keep stuff within the extended ASCII range so we work with more // limited native encodings String unicode = "Un \u00e9l\u00e9ment gr\u00e2ce \u00e0 l'index"; if (!unicode.equals(new String(unicode.getBytes()))) { // If the extended characters aren't encodable in the default // encoding, punt and use straight ASCII unicode = ""; for (char ch=1;ch < 128;ch++) { unicode += ch; } } String unicodez = unicode + "\0more stuff"; byte[] defaultEncoded = Native.getBytes(unicode); byte[] expected = unicode.getBytes(); for (int i=0;i < Math.min(defaultEncoded.length, expected.length);i++) { assertEquals("Improperly encoded (" + encoding + ") from Java at " + i, expected[i], defaultEncoded[i]); } assertEquals("Wrong number of encoded characters (" + encoding + ")", expected.length, defaultEncoded.length); String result = Native.toString(defaultEncoded); assertEquals("Improperly decoded from native bytes (" + encoding + ")", unicode, result); assertEquals("Should truncate bytes at NUL terminator", unicode, Native.toString(unicodez.getBytes())); } public void testCustomStringEncoding() throws Exception { Properties oldprops = (Properties)System.getProperties().clone(); try { String encoding = "UTF8"; System.setProperty("jna.encoding", encoding); String unicode = "\u0444\u043b\u0441\u0432\u0443"; String unicodez = unicode + "\0more stuff"; byte[] utf8 = Native.getBytes(unicode); byte[] expected = unicode.getBytes(encoding); for (int i=0;i < Math.min(utf8.length, expected.length);i++) { assertEquals("Improperly encoded at " + i, expected[i], utf8[i]); } assertEquals("Wrong number of encoded characters", expected.length, utf8.length); String result = Native.toString(utf8); assertEquals("Improperly decoded", unicode, result); assertEquals("Should truncate bytes at NUL terminator", unicode, Native.toString(unicodez.getBytes(encoding))); } finally { System.setProperties(oldprops); } } public static interface TestLib extends Library { interface VoidCallback extends Callback { void callback(); } void callVoidCallback(VoidCallback callback); } public void testSynchronizedAccess() throws Exception { final boolean[] lockHeld = { false }; final NativeLibrary nlib = NativeLibrary.getInstance("testlib"); final TestLib lib = (TestLib)Native.loadLibrary("testlib", TestLib.class); final TestLib synchlib = (TestLib)Native.synchronizedLibrary(lib); final TestLib.VoidCallback cb = new TestLib.VoidCallback() { public void callback() { lockHeld[0] = Thread.holdsLock(nlib); } }; Thread t0 = new Thread() { public void run() { lib.callVoidCallback(cb); } }; t0.start(); t0.join(); assertFalse("NativeLibrary lock should not be held during native call to normal library", lockHeld[0]); Thread t1 = new Thread() { public void run() { synchlib.callVoidCallback(cb); } }; t1.start(); t1.join(); assertTrue("NativeLibrary lock should be held during native call to synchronized library", lockHeld[0]); } interface TestInterface extends Library { static class InnerTestClass extends Structure { interface TestCallback extends Callback { } static class InnerSubclass extends InnerTestClass implements Structure.ByReference { } } } public void testFindInterfaceClass() throws Exception { Class interfaceClass = TestInterface.class; Class cls = TestInterface.InnerTestClass.class; Class subClass = TestInterface.InnerTestClass.InnerSubclass.class; Class callbackClass = TestInterface.InnerTestClass.TestCallback.class; assertEquals("Enclosing interface not found for class", interfaceClass, Native.findEnclosingLibraryClass(cls)); assertEquals("Enclosing interface not found for derived class", interfaceClass, Native.findEnclosingLibraryClass(subClass)); assertEquals("Enclosing interface not found for callback", interfaceClass, Native.findEnclosingLibraryClass(callbackClass)); } public interface TestInterfaceWithInstance extends Library { int TEST_ALIGNMENT = Structure.ALIGN_NONE; TypeMapper TEST_MAPPER = new DefaultTypeMapper(); Map TEST_OPTS = new HashMap() { { put(OPTION_TYPE_MAPPER, TEST_MAPPER); put(OPTION_STRUCTURE_ALIGNMENT, new Integer(TEST_ALIGNMENT)); }}; TestInterfaceWithInstance ARBITRARY = (TestInterfaceWithInstance) Native.loadLibrary("testlib", TestInterfaceWithInstance.class, TEST_OPTS); } public void testOptionsInferenceFromInstanceField() { assertEquals("Wrong options found for interface which provides an instance", TestInterfaceWithInstance.TEST_OPTS, Native.getLibraryOptions(TestInterfaceWithInstance.class)); assertEquals("Wrong type mapper found", TestInterfaceWithInstance.TEST_MAPPER, Native.getTypeMapper(TestInterfaceWithInstance.class)); assertEquals("Wrong alignment found", TestInterfaceWithInstance.TEST_ALIGNMENT, Native.getStructureAlignment(TestInterfaceWithInstance.class)); } public interface TestInterfaceWithOptions extends Library { int TEST_ALIGNMENT = Structure.ALIGN_NONE; TypeMapper TEST_MAPPER = new DefaultTypeMapper(); Map OPTIONS = new HashMap() { { put(OPTION_TYPE_MAPPER, TEST_MAPPER); put(OPTION_STRUCTURE_ALIGNMENT, new Integer(TEST_ALIGNMENT)); }}; } public void testOptionsInferenceFromOptionsField() { assertEquals("Wrong options found for interface which provides OPTIONS", TestInterfaceWithOptions.OPTIONS, Native.getLibraryOptions(TestInterfaceWithOptions.class)); assertEquals("Wrong type mapper found", TestInterfaceWithOptions.TEST_MAPPER, Native.getTypeMapper(TestInterfaceWithOptions.class)); assertEquals("Wrong alignment found", TestInterfaceWithOptions.TEST_ALIGNMENT, Native.getStructureAlignment(TestInterfaceWithOptions.class)); } public interface TestInterfaceWithTypeMapper extends Library { TypeMapper TEST_MAPPER = new DefaultTypeMapper(); TypeMapper TYPE_MAPPER = TEST_MAPPER; } public void testOptionsInferenceFromTypeMapperField() { assertEquals("Wrong type mapper found for interface which provides TYPE_MAPPER", TestInterfaceWithTypeMapper.TEST_MAPPER, Native.getTypeMapper(TestInterfaceWithTypeMapper.class)); } public interface TestInterfaceWithAlignment extends Library { int STRUCTURE_ALIGNMENT = Structure.ALIGN_NONE; } public void testOptionsInferenceFromAlignmentField() { assertEquals("Wrong alignment found for interface which provides STRUCTURE_ALIGNMENT", Structure.ALIGN_NONE, Native.getStructureAlignment(TestInterfaceWithAlignment.class)); } public void testCharArrayToString() { char[] buf = { 'a', 'b', 'c', '\0', 'd', 'e' }; assertEquals("Wrong String generated", "abc", Native.toString(buf)); } public void testByteArrayToString() { byte[] buf = { 'a', 'b', 'c', '\0', 'd', 'e' }; assertEquals("Wrong String generated", "abc", Native.toString(buf)); } public void testToByteArray() { final String VALUE = getName(); byte[] buf = Native.toByteArray(VALUE); assertEquals("Wrong byte array length", VALUE.length()+1, buf.length); assertEquals("Missing NUL terminator", (byte)0, buf[buf.length-1]); assertEquals("Wrong byte array contents", VALUE, new String(buf, 0, buf.length-1)); } public void testToCharArray() { final String VALUE = getName(); char[] buf = Native.toCharArray(VALUE); assertEquals("Wrong char array length", VALUE.length()+1, buf.length); assertEquals("Missing NUL terminator", (char)0, buf[buf.length-1]); assertEquals("Wrong char array contents: " + new String(buf), VALUE, new String(buf, 0, buf.length-1)); } public void testOSPrefix() { assertEquals("Wrong resource path", "/com/sun/jna/win32-x86", Native.getNativeLibraryResourcePath(Platform.WINDOWS, "x86", "Windows")); assertEquals("Wrong resource path Windows/i386", "/com/sun/jna/win32-x86", Native.getNativeLibraryResourcePath(Platform.WINDOWS, "i386", "Windows")); assertEquals("Wrong resource path Mac/x86", "/com/sun/jna/darwin", Native.getNativeLibraryResourcePath(Platform.MAC, "x86", "Darwin")); assertEquals("Wrong resource path Mac/x86_64", "/com/sun/jna/darwin", Native.getNativeLibraryResourcePath(Platform.MAC, "x86_64", "Mac")); assertEquals("Wrong resource path Solaris/sparc", "/com/sun/jna/sunos-sparc", Native.getNativeLibraryResourcePath(Platform.SOLARIS, "sparc", "Solaris")); assertEquals("Wrong resource path SunOS/sparcv9", "/com/sun/jna/sunos-sparcv9", Native.getNativeLibraryResourcePath(Platform.SOLARIS, "sparcv9", "SunOS")); assertEquals("Wrong resource path Linux/i386", "/com/sun/jna/linux-i386", Native.getNativeLibraryResourcePath(Platform.LINUX, "i386", "Linux/Gnu")); assertEquals("Wrong resource path Linux/x86", "/com/sun/jna/linux-i386", Native.getNativeLibraryResourcePath(Platform.LINUX, "x86", "Linux")); assertEquals("Wrong resource path OpenBSD/x86", "/com/sun/jna/openbsd-i386", Native.getNativeLibraryResourcePath(Platform.OPENBSD, "x86", "OpenBSD")); assertEquals("Wrong resource path FreeBSD/x86", "/com/sun/jna/freebsd-i386", Native.getNativeLibraryResourcePath(Platform.FREEBSD, "x86", "FreeBSD")); assertEquals("Wrong resource path other/other", "/com/sun/jna/name-ppc", Native.getNativeLibraryResourcePath(Platform.UNSPECIFIED, "PowerPC", "Name Of System")); } public static class DirectMapping { public static class DirectStructure extends Structure { public int field; } public static interface DirectCallback extends Callback { void invoke(); } public DirectMapping(Map options) { Native.register(getClass(), NativeLibrary.getInstance("testlib", options)); } } public void testGetTypeMapperForDirectMapping() { final TypeMapper mapper = new DefaultTypeMapper(); Map options = new HashMap(); options.put(Library.OPTION_TYPE_MAPPER, mapper); DirectMapping lib = new DirectMapping(options); assertEquals("Wrong type mapper for direct mapping", mapper, Native.getTypeMapper(DirectMapping.class)); assertEquals("Wrong type mapper for direct mapping nested structure", mapper, Native.getTypeMapper(DirectMapping.DirectStructure.class)); assertEquals("Wrong type mapper for direct mapping nested callback", mapper, Native.getTypeMapper(DirectMapping.DirectCallback.class)); } private static class TestCallback implements Callback { public static final TypeMapper TYPE_MAPPER = new DefaultTypeMapper(); public void callback() { } } public void testGetTypeMapperFromCallbackInterface() throws Exception { assertEquals("Wrong type mapper for callback class", TestCallback.TYPE_MAPPER, Native.getTypeMapper(TestCallback.class)); } public void testStringReplace() { assertEquals("Bad replace", "abcdefg", Native.replace("z", "a", "zbcdefg")); assertEquals("Bad replace", "abcdefg", Native.replace("z", "g", "abcdefz")); assertEquals("Bad replace", "abcdefg", Native.replace("z", "d", "abczefg")); assertEquals("Bad replace", "abcaefa", Native.replace("z", "a", "zbczefz")); } public static void main(String[] args) { junit.textui.TestRunner.run(NativeTest.class); } } libjna-java-3.2.7/test/com/sun/jna/HeadlessLoadLibraryTest.java0000644000175000017500000000066110753020510022471 0ustar janjanpackage com.sun.jna; import junit.framework.TestCase; public class HeadlessLoadLibraryTest extends TestCase { public void testLoadWhenHeadless() { System.setProperty("java.awt.headless", "true"); assertTrue("Pointer size must not be zero", Pointer.SIZE > 0); } public static void main(String[] args) { junit.textui.TestRunner.run(HeadlessLoadLibraryTest.class); } } libjna-java-3.2.7/test/com/sun/jna/DirectCallbacksTest.java0000644000175000017500000000714311224550756021646 0ustar janjan/* Copyright (c) 2009 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. *

* 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; import java.util.Map; import com.sun.jna.ptr.IntByReference; /** Exercise callback-related functionality. * * @author twall@users.sf.net */ public class DirectCallbacksTest extends CallbacksTest { public static class DirectTestLibrary implements TestLibrary { public native void callVoidCallback(VoidCallbackCustom c); public native boolean callBooleanCallback(BooleanCallback c, boolean arg, boolean arg2); public native byte callInt8Callback(ByteCallback c, byte arg, byte arg2); public native short callInt16Callback(ShortCallback c, short arg, short arg2); public native int callInt32Callback(Int32Callback c, int arg, int arg2); public native NativeLong callNativeLongCallback(NativeLongCallback c, NativeLong arg, NativeLong arg2); public native long callInt64Callback(Int64Callback c, long arg, long arg2); public native float callFloatCallback(FloatCallback c, float arg, float arg2); public native double callDoubleCallback(DoubleCallback c, double arg, double arg2); public native SmallTestStructure callStructureCallback(StructureCallback c, SmallTestStructure arg); public native String callStringCallback(StringCallback c, String arg); public native WString callWideStringCallback(WideStringCallback c, WString arg); public Pointer callStringArrayCallback(StringArrayCallback c, String[] arg) { throw new UnsupportedOperationException(); } public native int callCallbackWithByReferenceArgument(CopyArgToByReference cb, int arg, IntByReference result); public native TestStructure.ByValue callCallbackWithStructByValue(TestStructure.TestCallback callback, TestStructure.ByValue cbstruct); public native CbCallback callCallbackWithCallback(CbCallback cb); public native Int32CallbackX returnCallback(); public native Int32CallbackX returnCallbackArgument(Int32CallbackX cb); public native void callVoidCallback(VoidCallback c); public native int callInt32Callback(CustomCallback cb, int arg1, int arg2); public native void callCallbackInStruct(CbStruct s); static { Native.register("testlib"); } } protected void setUp() { lib = new DirectTestLibrary(); } public static class DirectCallbackTestLibrary implements CallbackTestLibrary { public native double callInt32Callback(DoubleCallback c, double arg, double arg2); public native float callInt64Callback(FloatCallback c, float arg, float arg2); static { Native.register(NativeLibrary.getInstance("testlib", _OPTIONS)); } } protected CallbackTestLibrary loadCallbackTestLibrary() { return new DirectCallbackTestLibrary(); } // Currently unsupported tests public void testCallStringArrayCallback() { } public void testCallbackExceptionHandlerWithCallbackProxy() { } public static void main(java.lang.String[] argList) { junit.textui.TestRunner.run(DirectCallbacksTest.class); } } libjna-java-3.2.7/test/com/sun/jna/StructureByValueTest.java0000644000175000017500000000746211372233154022122 0ustar janjan/* 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. *

* 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; import java.nio.Buffer; import java.nio.ByteBuffer; import java.util.Map; import junit.framework.TestCase; /** General structure by value functionality tests. */ public class StructureByValueTest extends TestCase { public static void main(java.lang.String[] argList) { junit.textui.TestRunner.run(StructureByValueTest.class); } public static class TestNativeMappedInStructure extends Structure { public static class ByValue extends TestNativeMappedInStructure implements Structure.ByValue { } public NativeLong field; } public void testNativeMappedInByValue() { new TestNativeMappedInStructure.ByValue(); } public interface TestLibrary extends Library { byte testStructureByValueArgument8(ByValue8 arg); short testStructureByValueArgument16(ByValue16 arg); int testStructureByValueArgument32(ByValue32 arg); long testStructureByValueArgument64(ByValue64 arg); long testStructureByValueArgument128(ByValue128 arg); } TestLibrary lib; protected void setUp() { lib = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class); } protected void tearDown() { lib = null; } public static class ByValueStruct extends Structure implements Structure.ByValue { } public static class ByValue8 extends ByValueStruct { public byte data; } public static class ByValue16 extends ByValueStruct { public short data; } public static class ByValue32 extends ByValueStruct { public int data; } public static class ByValue64 extends ByValueStruct { public long data; } public static class ByValue128 extends ByValueStruct { public long data, data1; } final long MAGIC = 0x0123456789ABCDEFL; public void testStructureArgByValue8() { ByValue8 data = new ByValue8(); final byte DATA = (byte)MAGIC; data.data = DATA; assertEquals("Failed to pass 8-bit struct by value", DATA, lib.testStructureByValueArgument8(data)); } public void testStructureArgByValue16() { ByValue16 data = new ByValue16(); final short DATA = (short)MAGIC; data.data = DATA; assertEquals("Failed to pass 16-bit struct by value", DATA, lib.testStructureByValueArgument16(data)); } public void testStructureArgByValue32() { ByValue32 data = new ByValue32(); final int DATA = (int)MAGIC; data.data = DATA; assertEquals("Failed to pass 32-bit struct by value", DATA, lib.testStructureByValueArgument32(data)); } public void testStructureArgByValue64() { ByValue64 data = new ByValue64(); final long DATA = MAGIC; data.data = DATA; assertEquals("Failed to pass 64-bit struct by value", DATA, lib.testStructureByValueArgument64(data)); } public void testStructureArgByValue128() { ByValue128 data = new ByValue128(); final long DATA = MAGIC; data.data = DATA; data.data1 = DATA; assertEquals("Failed to pass 128-bit struct by value", 2*DATA, lib.testStructureByValueArgument128(data)); } }libjna-java-3.2.7/test/com/sun/jna/DirectTypeMapperTest.java0000644000175000017500000001577211224550756022064 0ustar janjan/* Copyright (c) 2009 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. *

* 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; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; public class DirectTypeMapperTest extends TestCase { public static class DirectTestLibraryBoolean { final static int MAGIC = 0xABEDCF23; public native int returnInt32Argument(boolean b); static { Map options = new HashMap(); DefaultTypeMapper mapper = new DefaultTypeMapper(); mapper.addToNativeConverter(Boolean.class, new ToNativeConverter() { public Object toNative(Object arg, ToNativeContext ctx) { return new Integer(Boolean.TRUE.equals(arg) ? MAGIC : 0); } public Class nativeType() { return Integer.class; } }); options.put(Library.OPTION_TYPE_MAPPER, mapper); Native.register(NativeLibrary.getInstance("testlib", options)); } } public static class DirectTestLibraryString { public native int returnInt32Argument(String s); static { DefaultTypeMapper mapper = new DefaultTypeMapper(); mapper.addToNativeConverter(String.class, new ToNativeConverter() { public Object toNative(Object arg, ToNativeContext ctx) { return Integer.valueOf((String) arg, 16); } public Class nativeType() { return Integer.class; } }); Map options = new HashMap(); options.put(Library.OPTION_TYPE_MAPPER, mapper); Native.register(NativeLibrary.getInstance("testlib", options)); } } public static class DirectTestLibraryCharSequence { public native int returnInt32Argument(String n); static { DefaultTypeMapper mapper = new DefaultTypeMapper(); mapper.addToNativeConverter(CharSequence.class, new ToNativeConverter() { public Object toNative(Object arg, ToNativeContext ctx) { return Integer.valueOf(((CharSequence)arg).toString(), 16); } public Class nativeType() { return Integer.class; } }); Map options = new HashMap(); options.put(Library.OPTION_TYPE_MAPPER, mapper); Native.register(NativeLibrary.getInstance("testlib", options)); } } public static class DirectTestLibraryNumber { public native int returnInt32Argument(Number n); static { DefaultTypeMapper mapper = new DefaultTypeMapper(); mapper.addToNativeConverter(Number.class, new ToNativeConverter() { public Object toNative(Object arg, ToNativeContext ctx) { return new Integer(((Number)arg).intValue()); } public Class nativeType() { return Integer.class; } }); Map options = new HashMap(); options.put(Library.OPTION_TYPE_MAPPER, mapper); Native.register(NativeLibrary.getInstance("testlib", options)); } } public void testBooleanToIntArgumentConversion() { DirectTestLibraryBoolean lib = new DirectTestLibraryBoolean(); assertEquals("Failed to convert Boolean argument to Int", lib.MAGIC, lib.returnInt32Argument(true)); } public void testStringToIntArgumentConversion() { final int MAGIC = 0x7BEDCF23; DirectTestLibraryString lib = new DirectTestLibraryString(); assertEquals("Failed to convert String argument to Int", MAGIC, lib.returnInt32Argument(Integer.toHexString(MAGIC))); } public void testCharSequenceToIntArgumentConversion() { final int MAGIC = 0x7BEDCF23; DirectTestLibraryCharSequence lib = new DirectTestLibraryCharSequence(); assertEquals("Failed to convert String argument to Int", MAGIC, lib.returnInt32Argument(Integer.toHexString(MAGIC))); } public void testNumberToIntArgumentConversion() { final int MAGIC = 0x7BEDCF23; DirectTestLibraryNumber lib = new DirectTestLibraryNumber(); assertEquals("Failed to convert Double argument to Int", MAGIC, lib.returnInt32Argument(new Double(MAGIC))); } public static class DirectBooleanTestLibrary { public native boolean returnInt32Argument(boolean b); static { final int MAGIC = 0xABEDCF23; Map options = new HashMap(); DefaultTypeMapper mapper = new DefaultTypeMapper(); // Use opposite sense of default int<-->boolean conversions mapper.addToNativeConverter(Boolean.class, new ToNativeConverter() { public Object toNative(Object value, ToNativeContext ctx) { return new Integer(Boolean.TRUE.equals(value) ? 0 : MAGIC); } public Class nativeType() { return Integer.class; } }); mapper.addFromNativeConverter(Boolean.class, new FromNativeConverter() { public Object fromNative(Object value, FromNativeContext context) { return Boolean.valueOf(((Integer) value).intValue() != MAGIC); } public Class nativeType() { return Integer.class; } }); options.put(Library.OPTION_TYPE_MAPPER, mapper); Native.register(NativeLibrary.getInstance("testlib", options)); } } public void testIntegerToBooleanResultConversion() throws Exception { DirectBooleanTestLibrary lib = new DirectBooleanTestLibrary(); // argument "true" converts to zero; result zero converts to "true" assertTrue("Failed to convert integer return to boolean TRUE", lib.returnInt32Argument(true)); // argument "true" converts to MAGIC; result MAGIC converts to "false" assertFalse("Failed to convert integer return to boolean FALSE", lib.returnInt32Argument(false)); } public static void main(String[] args) { junit.textui.TestRunner.run(DirectTypeMapperTest.class); } } libjna-java-3.2.7/test/com/sun/jna/DirectArgumentsMarshalTest.java0000644000175000017500000001603511234610410023225 0ustar janjan/* Copyright (c) 2009 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. *

* 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; import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.DoubleBuffer; import java.nio.IntBuffer; import java.nio.LongBuffer; import java.nio.ShortBuffer; /** Exercise a range of native methods. * * @author twall@users.sf.net */ public class DirectArgumentsMarshalTest extends ArgumentsMarshalTest { public static class DirectTestLibrary implements TestLibrary { /** Dummy. Automatically fail when passed an object. */ public String returnStringArgument(Object arg) {throw new IllegalArgumentException(arg.getClass().getName()); } public native boolean returnBooleanArgument(boolean arg); public native byte returnInt8Argument(byte arg); public native char returnWideCharArgument(char arg); public native short returnInt16Argument(short arg); public native int returnInt32Argument(int i); public native long returnInt64Argument(long l); public native NativeLong returnLongArgument(NativeLong l); public native float returnFloatArgument(float f); public native double returnDoubleArgument(double d); public native String returnStringArgument(String s); public native WString returnWStringArgument(WString s); public native Pointer returnPointerArgument(Pointer p); public String returnStringArrayElement(String[] args, int which) {throw new UnsupportedOperationException();} public WString returnWideStringArrayElement(WString[] args, int which) {throw new UnsupportedOperationException();} public Pointer returnPointerArrayElement(Pointer[] args, int which) {throw new UnsupportedOperationException();} public TestPointerType returnPointerArrayElement(TestPointerType[] args, int which) {throw new UnsupportedOperationException();} public CheckFieldAlignment returnPointerArrayElement(CheckFieldAlignment.ByReference[] args, int which) {throw new UnsupportedOperationException();} public int returnRotatedArgumentCount(String[] args) {throw new UnsupportedOperationException();} public native long checkInt64ArgumentAlignment(int i, long j, int i2, long j2); public native double checkDoubleArgumentAlignment(float i, double j, float i2, double j2); public native Pointer testStructurePointerArgument(CheckFieldAlignment p); public native double testStructureByValueArgument(CheckFieldAlignment.ByValue p); public int testStructureArrayInitialization(CheckFieldAlignment[] p, int len) { throw new UnsupportedOperationException(); } public void modifyStructureArray(CheckFieldAlignment[] p, int length) { throw new UnsupportedOperationException(); } public native int fillInt8Buffer(byte[] buf, int len, byte value); public native int fillInt16Buffer(short[] buf, int len, short value); public native int fillInt32Buffer(int[] buf, int len, int value); public native int fillInt64Buffer(long[] buf, int len, long value); public native int fillFloatBuffer(float[] buf, int len, float value); public native int fillDoubleBuffer(double[] buf, int len, double value); // ByteBuffer alternative definitions public native int fillInt8Buffer(ByteBuffer buf, int len, byte value); public native int fillInt16Buffer(ByteBuffer buf, int len, short value); public native int fillInt32Buffer(ByteBuffer buf, int len, int value); public native int fillInt64Buffer(ByteBuffer buf, int len, long value); public native int fillFloatBuffer(ByteBuffer buf, int len, float value); public native int fillDoubleBuffer(ByteBuffer buf, int len, double value); // {Short|Int|Long|Float|Double}Buffer alternative definitions public native int fillInt16Buffer(ShortBuffer buf, int len, short value); public native int fillInt32Buffer(IntBuffer buf, int len, int value); public native int fillInt64Buffer(LongBuffer buf, int len, long value); public native int fillFloatBuffer(FloatBuffer buf, int len, float value); public native int fillDoubleBuffer(DoubleBuffer buf, int len, double value); // dummy to avoid causing Native.register to fail public boolean returnBooleanArgument(Object arg) {throw new IllegalArgumentException();} public native Pointer testStructurePointerArgument(MinTestStructure s); public native String returnStringFromVariableSizedStructure(VariableSizedStructure s); public native void setCallbackInStruct(CbStruct s); public native TestUnion testUnionByValueCallbackArgument(UnionCallback cb, TestUnion arg); static { Native.register("testlib"); } } /* Override original. */ protected void setUp() { lib = new DirectTestLibrary(); } public static class DirectNativeMappedLibrary implements NativeMappedLibrary { public native int returnInt32Argument(Custom arg); static { Native.register("testlib"); } } protected NativeMappedLibrary loadNativeMappedLibrary() { return new DirectNativeMappedLibrary(); } // This test crashes on w32 IBM J9 unless -Xint is used // (jvmwi3260-20080415_18762) public void testWideCharArgument() { if (Platform.isWindows() && "IBM".equals(System.getProperty("java.vm.vendor"))) { fail("XFAIL, crash avoided"); } super.testWideCharArgument(); } // This test crashes on w32 IBM J9 unless -Xint is used // (jvmwi3260-20080415_18762) public void testWStringArgumentReturn() { if (Platform.isWindows() && "IBM".equals(System.getProperty("java.vm.vendor"))) { fail("XFAIL, crash avoided"); } super.testWStringArgumentReturn(); } // Override tests not yet supported public void testStringArrayArgument() { } public void testWriteStructureArrayArgumentMemory() { } public void testUninitializedStructureArrayArgument() { } public void testRejectNoncontiguousStructureArrayArgument() { } public void testWideStringArrayArgument() { } public void testPointerArrayArgument() { } public void testNativeMappedArrayArgument() { } public void testStructureByReferenceArrayArgument() { } public void testModifiedCharArrayArgument() { } public static void main(java.lang.String[] argList) { junit.textui.TestRunner.run(DirectArgumentsMarshalTest.class); } } libjna-java-3.2.7/test/com/sun/jna/ByReferenceArgumentsTest.java0000644000175000017500000000774111220641326022705 0ustar janjan/* 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. *

* 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; import junit.framework.TestCase; import com.sun.jna.ptr.ByteByReference; import com.sun.jna.ptr.DoubleByReference; import com.sun.jna.ptr.FloatByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.LongByReference; import com.sun.jna.ptr.NativeLongByReference; import com.sun.jna.ptr.PointerByReference; import com.sun.jna.ptr.ShortByReference; /** Exercise a range of native methods. * * @author twall@users.sf.net */ public class ByReferenceArgumentsTest extends TestCase { public static interface TestLibrary extends Library { void incrementInt8ByReference(ByteByReference b); void incrementInt16ByReference(ShortByReference s); void incrementInt32ByReference(IntByReference i); void incrementNativeLongByReference(NativeLongByReference l); void incrementInt64ByReference(LongByReference l); void complementFloatByReference(FloatByReference f); void complementDoubleByReference(DoubleByReference d); void setPointerByReferenceNull(PointerByReference p); } TestLibrary lib; protected void setUp() { lib = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class); } protected void tearDown() { lib = null; } public void testByteByReference() { ByteByReference bref = new ByteByReference(); lib.incrementInt8ByReference(bref); assertEquals("Byte argument not modified", 1, bref.getValue()); } public void testShortByReference() { ShortByReference sref = new ShortByReference(); lib.incrementInt16ByReference(sref); assertEquals("Short argument not modified", 1, sref.getValue()); } public void testIntByReference() { IntByReference iref = new IntByReference(); lib.incrementInt32ByReference(iref); assertEquals("Int argument not modified", 1, iref.getValue()); } public void testNativeLongByReference() { NativeLongByReference iref = new NativeLongByReference(); lib.incrementNativeLongByReference(iref); assertEquals("Native long argument not modified", new NativeLong(1), iref.getValue()); } public void testLongByReference() { LongByReference lref = new LongByReference(); lib.incrementInt64ByReference(lref); assertEquals("Long argument not modified", 1, lref.getValue()); } public void testFloatByReference() { FloatByReference fref = new FloatByReference(1f); lib.complementFloatByReference(fref); assertEquals("Float argument not modified", -1f, fref.getValue(), 0.0); } public void testDoubleByReference() { DoubleByReference dref = new DoubleByReference(1d); lib.complementDoubleByReference(dref); assertEquals("Int argument not modified", -1d, dref.getValue(), 0.0); } public void testPointerByReference() { PointerByReference pref = new PointerByReference(); assertNull("Default pointer should be null", pref.getValue()); pref = new PointerByReference(new Memory(16)); assertNotNull("Explicit pointer should not be null", pref.getValue()); lib.setPointerByReferenceNull(pref); assertNull("Default pointer should be NULL after call", pref.getValue()); } public static void main(java.lang.String[] argList) { junit.textui.TestRunner.run(ByReferenceArgumentsTest.class); } } libjna-java-3.2.7/test/com/sun/jna/IntegerTypeTest.java0000644000175000017500000000351011036420056021053 0ustar janjanpackage com.sun.jna; import junit.framework.TestCase; public class IntegerTypeTest extends TestCase { public static class Sized extends IntegerType { public Sized() { this(4, 0); } public Sized(int size, long value) { super(size, value); } } public void testWriteNull() { class NTStruct extends Structure { public Sized field; } NTStruct s = new NTStruct(); assertNotNull("Field not initialized", s.field); } public void testReadNull() { class NTStruct extends Structure { public Sized field; } NTStruct s = new NTStruct(); s.read(); assertNotNull("Integer type field should be initialized on read", s.field); } public void testCheckArgumentSize() { for (int i=1;i <= 8;i*=2) { long value = -1L << (i*8-1); new Sized(i, value); new Sized(i, -1); new Sized(i, 0); new Sized(i, 1); value = 1L << (i*8-1); new Sized(i, value); value = -1L & ~(-1L << (i*8)); new Sized(i, value); if (i < 8) { try { value = 1L << (i*8); new Sized(i, value); fail("Value exceeding size (" + i + ") should fail"); } catch(IllegalArgumentException e) { } } if (i < 8) { try { value = -1L << (i*8); new Sized(i, value); fail("Negative value (" + value + ") exceeding size (" + i + ") should fail"); } catch(IllegalArgumentException e) { } } } } public void testInitialValue() { long VALUE = 20; NativeLong nl = new NativeLong(VALUE); assertEquals("Wrong initial value", VALUE, nl.longValue()); } public static void main(String[] args) { junit.textui.TestRunner.run(IntegerTypeTest.class); } } libjna-java-3.2.7/test/com/sun/jna/VarArgsTest.java0000644000175000017500000000611111220641326020161 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; import com.sun.jna.VarArgsTest.TestLibrary.TestStructure; import junit.framework.TestCase; public class VarArgsTest extends TestCase { final int MAGIC32 = 0x12345678; public static interface TestLibrary extends Library { public static class TestStructure extends Structure { public int magic = 0; } public int addInt32VarArgs(String fmt, Number... args); public String returnStringVarArgs(String fmt, Object... args); public void modifyStructureVarArgs(String fmt, Object arg1, Object... args); } TestLibrary lib; protected void setUp() { lib = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class); } protected void tearDown() { lib = null; } public void testIntVarArgs() { int arg1 = 1; int arg2 = 2; assertEquals("VarArgs not added correctly", arg1 + arg2, lib.addInt32VarArgs("dd", new Integer(arg1), new Integer(arg2))); } public void testShortVarArgs() { short arg1 = 1; short arg2 = 2; assertEquals("VarArgs not added correctly", arg1 + arg2, lib.addInt32VarArgs("dd", new Short(arg1), new Short(arg2))); } public void testLongVarArgs() { short arg1 = 1; short arg2 = 2; assertEquals("VarArgs not added correctly", arg1 + arg2, lib.addInt32VarArgs("ll", new Long(arg1), new Long(arg2))); } public void testStringVarArgs() { Object[] args = new Object[] { "Test" }; assertEquals("Did not return correct string", args[0], lib.returnStringVarArgs("", args)); } public void testAppendNullToVarargs() { Number[] args = new Number[] { new Integer(1) }; assertEquals("No trailing NULL was appended to varargs list", 1, lib.addInt32VarArgs("dd", args)); } public void testModifyStructureInVarargs() { TestStructure arg1 = new TestStructure(); TestStructure[] varargs = new TestStructure[] { new TestStructure() }; lib.modifyStructureVarArgs("ss", arg1, varargs[0]); assertEquals("Structure memory not read in fixed arg w/varargs", MAGIC32, arg1.magic); assertEquals("Structure memory not read in varargs", MAGIC32, varargs[0].magic); } public static void main(String[] args) { junit.textui.TestRunner.run(VarArgsTest.class); } } libjna-java-3.2.7/test/com/sun/jna/LibraryTest.java0000644000175000017500000000305311220641326020222 0ustar janjanpackage com.sun.jna; import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import junit.framework.TestCase; public class LibraryTest extends TestCase { @Retention(RetentionPolicy.RUNTIME) public @interface TestAnnotation { } public interface Library { } public interface AnnotatedLibrary extends Library { @TestAnnotation boolean isAnnotated(); } public class TestInvocationHandler implements InvocationHandler { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return Boolean.valueOf(method.getAnnotations().length == 1); } } // There's a rumor that some VMs don't copy annotation information to // dynamically generated proxies. Detect it here. public void testProxyMethodHasAnnotations() throws Exception { AnnotatedLibrary a = (AnnotatedLibrary) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { AnnotatedLibrary.class }, new TestInvocationHandler()); assertTrue("Proxy method not annotated", a.isAnnotated()); } public static void main(String[] args) { junit.textui.TestRunner.run(LibraryTest.class); } } libjna-java-3.2.7/test/com/sun/jna/NativeLibraryTest.java0000644000175000017500000001711511224616150021376 0ustar janjan/* 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. * * 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; import java.io.File; import java.lang.ref.WeakReference; import java.util.Arrays; import java.util.List; import junit.framework.TestCase; public class NativeLibraryTest extends TestCase { public static interface TestLibrary extends Library { int callCount(); } public void testGCNativeLibrary() throws Exception { NativeLibrary lib = NativeLibrary.getInstance("testlib"); WeakReference ref = new WeakReference(lib); lib = null; System.gc(); long start = System.currentTimeMillis(); while (ref.get() != null) { Thread.sleep(10); if (System.currentTimeMillis() - start > 5000) break; } assertNull("Library not GC'd", ref.get()); } public void testAvoidDuplicateLoads() { TestLibrary lib = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class); assertEquals("Library should be loaded exactly once", 1, lib.callCount()); assertEquals("Library should not be reloaded", 2, lib.callCount()); } public void testUseSingleLibraryInstance() { TestLibrary lib = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class); int count = lib.callCount(); TestLibrary lib2 = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class); int count2 = lib2.callCount(); assertEquals("Interfaces should share a library instance", count + 1, count2); } public void testAliasLibraryFilename() { TestLibrary lib = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class); int count = lib.callCount(); NativeLibrary nl = NativeLibrary.getInstance("testlib"); TestLibrary lib2 = (TestLibrary)Native.loadLibrary(nl.getFile().getName(), TestLibrary.class); int count2 = lib2.callCount(); assertEquals("Simple filename load not aliased", count + 1, count2); } public void testAliasLibraryFullPath() { TestLibrary lib = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class); int count = lib.callCount(); NativeLibrary nl = NativeLibrary.getInstance("testlib"); TestLibrary lib2 = (TestLibrary)Native.loadLibrary(nl.getFile().getAbsolutePath(), TestLibrary.class); int count2 = lib2.callCount(); assertEquals("Full pathname load not aliased", count + 1, count2); } public void testAliasSimpleLibraryName() throws Exception { NativeLibrary nl = NativeLibrary.getInstance("testlib"); File file = nl.getFile(); WeakReference ref = new WeakReference(nl); nl = null; System.gc(); long start = System.currentTimeMillis(); while (ref.get() != null) { Thread.sleep(10); if (System.currentTimeMillis() - start > 5000) fail("Timed out waiting for library to be GC'd"); } TestLibrary lib = (TestLibrary)Native.loadLibrary(file.getAbsolutePath(), TestLibrary.class); int count = lib.callCount(); TestLibrary lib2 = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class); int count2 = lib2.callCount(); assertEquals("Simple library name not aliased", count + 1, count2); } public void testFunctionHoldsLibraryReference() throws Exception { NativeLibrary lib = NativeLibrary.getInstance("testlib"); WeakReference ref = new WeakReference(lib); Function f = lib.getFunction("callCount"); lib = null; System.gc(); long start = System.currentTimeMillis(); while (ref.get() != null && System.currentTimeMillis() - start < 2000) { Thread.sleep(10); } assertNotNull("Library GC'd when it should not be", ref.get()); f.invokeInt(new Object[0]); f = null; System.gc(); while (ref.get() != null && System.currentTimeMillis() - start < 5000) { Thread.sleep(10); } assertNull("Library not GC'd", ref.get()); } public void testLoadFrameworkLibrary() { if (Platform.isMac()) { try { NativeLibrary lib = NativeLibrary.getInstance("CoreServices"); assertNotNull("CoreServices not found", lib); } catch(UnsatisfiedLinkError e) { fail("Should search /System/Library/Frameworks"); } } } public void testLookupGlobalVariable() { NativeLibrary lib = NativeLibrary.getInstance("testlib"); Pointer global = lib.getGlobalVariableAddress("test_global"); assertNotNull("Test variable not found", global); final int MAGIC = 0x12345678; assertEquals("Wrong value for library global variable", MAGIC, global.getInt(0)); global.setInt(0, MAGIC+1); assertEquals("Library global variable not updated", MAGIC+1, global.getInt(0)); } public void testMatchUnversionedToVersioned() throws Exception { File lib0 = File.createTempFile("lib", ".so.0"); File dir = lib0.getParentFile(); String name = lib0.getName(); name = name.substring(3, name.indexOf(".so")); lib0.deleteOnExit(); File lib1 = new File(dir, "lib" + name + ".so.1.0"); lib1.createNewFile(); lib1.deleteOnExit(); File lib1_1 = new File(dir, "lib" + name + ".so.1.1"); lib1_1.createNewFile(); lib1_1.deleteOnExit(); List path = Arrays.asList(new String[] { dir.getAbsolutePath() }); assertEquals("Latest versioned library not found when unversioned requested", lib1_1.getAbsolutePath(), NativeLibrary.matchLibrary(name, path)); } public void testAvoidFalseMatch() throws Exception { File lib0 = File.createTempFile("lib", ".so.1"); File dir = lib0.getParentFile(); lib0.deleteOnExit(); String name = lib0.getName(); name = name.substring(3, name.indexOf(".so")); File lib1 = new File(dir, "lib" + name + "-client.so.2"); lib1.createNewFile(); lib1.deleteOnExit(); List path = Arrays.asList(new String[] { dir.getAbsolutePath() }); assertEquals("Library with similar prefix should be ignored", lib0.getAbsolutePath(), NativeLibrary.matchLibrary(name, path)); } public void testParseVersion() throws Exception { String[] VERSIONS = { "1", "1.2", "1.2.3", "1.2.3.4", }; double[] EXPECTED = { 1, 1.02, 1.0203, 1.020304, }; for (int i=0;i < VERSIONS.length;i++) { assertEquals("Badly parsed version", EXPECTED[i], NativeLibrary.parseVersion(VERSIONS[i]), 0.0000001); } } public void testGetProcess() { NativeLibrary process = NativeLibrary.getProcess(); // Access a common C library function process.getFunction("printf"); } public static void main(String[] args) { junit.textui.TestRunner.run(NativeLibraryTest.class); } } libjna-java-3.2.7/test/com/sun/jna/WebStartTest.java0000644000175000017500000004246511340722130020357 0ustar janjan/* Copyright (c) 2009 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. * * 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; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JScrollPane; import java.awt.GraphicsEnvironment; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketTimeoutException; import java.util.Enumeration; import java.util.Properties; import junit.framework.AssertionFailedError; import junit.framework.TestCase; import junit.framework.TestFailure; import junit.framework.TestResult; /** * Run tests under web start * Works under OSX, windows, and linux. */ public class WebStartTest extends TestCase { // Provide a policy file for unsigned jars // Unfortunately this does not allow native libraries private static final String POLICY = "grant { \n" + " permission java.security.AllPermission;\n" + "};"; private static final String JNLP = "\n" + "\n" + " \n" + " JNLP Web Start Test\n" + " JNA\n" + " \n" + " Local JNLP launch test.\n" + " Launch Test\n" + " \n" // all-permissions is required for s // but will cause unsigned jars to fail (irrespective of policy) + " \n" + " \n" // Explicitly supply javawebstart.version, which is missing in NetX // Boo, java-vm-args doesn't work in NetX // and neither does javaws -J + " \n" + " \n" + " \n" + " {CLOVER}\n" + " \n" + " \n" + " \n" + " \n" + " {CLASS}\n" + " {METHOD}\n" + " {PORT}\n" // NetX doesn't set javawebstart.version, so explicitly flag it + " javawebstart\n" + " \n" + ""; public void testLaunchedUnderWebStart() throws Exception { assertNotNull("Test not launched under web start", System.getProperty("javawebstart.version")); } private static final String FAILURE = "This test is supposed to fail"; public void testDetectFailure() { fail(FAILURE); } private static final String ERROR = "This test is supposed to error"; public void testDetectError() { throw new Error(ERROR); } public interface Dummy extends Library { void dummy(); } public void testJNLPFindCustomLibrary() { assertNotNull("Custom library path not found by JNLP class loader", Native.getWebStartLibraryPath("jnidispatch")); Native.loadLibrary("jnidispatch", Dummy.class); } public void testJNLPFindProcessLibrary() { String libname = Platform.isWindows()?"msvcrt":"c"; assertNull("Process library path not expected to be found by JNLP class loader", Native.getWebStartLibraryPath(libname)); Native.loadLibrary(libname, Dummy.class); } public void testJNLPFindLibraryFailure() { try { Native.loadLibrary("xyzzy", Dummy.class); fail("Missing native libraries should throw UnsatisfiedLinkError"); } catch(UnsatisfiedLinkError e) { } } private void runTestUnderWebStart(String testClass, String testMethod) throws Exception { String BUILDDIR = System.getProperty("jna.builddir", "build" + (Platform.is64Bit() ? "-d64" : "")); String codebase = new File(BUILDDIR, "jws").toURI().toURL().toString(); ServerSocket s = new ServerSocket(0); s.setSoTimeout(120000); int port = s.getLocalPort(); File jnlp = File.createTempFile(getName(), ".jnlp"); String contents = JNLP.replace("{CLASS}", testClass); contents = contents.replace("{METHOD}", testMethod); contents = contents.replace("{CODEBASE}", codebase); contents = contents.replace("{JNLP_FILE}", jnlp.toURI().toURL().toString()); contents = contents.replace("{PORT}", String.valueOf(port)); boolean clover = System.getProperty("java.class.path").indexOf("clover") != -1; contents = contents.replace("{CLOVER}", clover ? "" : ""); try { OutputStream os = new FileOutputStream(jnlp); os.write(contents.getBytes()); os.close(); String path = findJWS(); String[] cmd = { path, "-Xnosplash", "-wait", jnlp.toURI().toURL().toString(), }; final Process p = Runtime.getRuntime().exec(cmd); final StringBuffer output = new StringBuffer(); class SocketHandler extends Thread { private InputStream is; private StringBuffer sb; public SocketHandler(Socket s, StringBuffer b) throws IOException { this.is = s.getInputStream(); this.sb = b; } public void run() { byte[] buf = new byte[256]; while (true) { try { int count = is.read(buf, 0, buf.length); if (count == -1) break; if (count == 0) { try { sleep(1); } catch(InterruptedException e) { } } else { sb.append(new String(buf, 0, count)); } } catch(IOException e) { showMessage("read error: " + e.toString()); } } try { is.close(); } catch(IOException e) { } } } Thread out = null; try { out = new SocketHandler(s.accept(), output); out.start(); } catch(SocketTimeoutException e) { try { p.exitValue(); } catch(IllegalThreadStateException e2) { p.destroy(); throw new Error("JWS Timed out"); } } p.waitFor(); if (out != null) { out.join(); } int code = p.exitValue(); String error = output.toString(); if (code != 0 || !"".equals(error)) { if (code == 1 || error.indexOf("AssertionFailedError") != -1) { fail("JWS FAIL: " + error); } throw new Error("JWS ERROR: " + error); } } finally { jnlp.delete(); } } private static boolean runningWebStart() { return System.getProperty("javawebstart.version") != null; } private void runTestUnderWebStart() throws Exception { if (getClass().equals(WebStartTest.class)) { if (getName().equals("testDetectFailure")) { try { runTestUnderWebStart(getClass().getName(), getName()); } catch(AssertionFailedError e) { if (e.getMessage().indexOf(FAILURE) != -1) return; } fail("Failed to detect test failure"); } else if (getName().equals("testDetectError")) { try { runTestUnderWebStart(getClass().getName(), getName()); } catch(AssertionFailedError e) { fail("Test produced a failure instead of an error: " + e); } catch(Error e) { if (e.getMessage().indexOf(ERROR) != -1) return; throw e; } fail("Failed to detect test error"); } else { runTestUnderWebStart(getClass().getName(), getName()); } } else { runTestUnderWebStart(getClass().getName(), getName()); } } public interface FolderInfo extends com.sun.jna.win32.StdCallLibrary { int MAX_PATH = 260; int SHGFP_TYPE_CURRENT = 0; int SHGFP_TYPE_DEFAULT = 1; int CSIDL_APPDATA = 26; int CSIDL_WINDOWS = 36; int SHGetFolderPathW(Pointer owner, int folder, Pointer token, int flags, char[] path); } private String findJWS() throws IOException { String JAVA_HOME = System.getProperty("java.home"); String BIN = new File(JAVA_HOME, "/bin").getAbsolutePath(); File javaws = new File(BIN, "javaws" + (Platform.isWindows()?".exe":"")); if (!javaws.exists()) { // NOTE: OSX puts javaws somewhere else entirely if (Platform.isMac()) { javaws = new File(JAVA_HOME, "../Commands/javaws"); } // NOTE: win64 only includes javaws in the system path if (Platform.isWindows()) { FolderInfo info = (FolderInfo) Native.loadLibrary("shell32", FolderInfo.class); char[] buf = new char[FolderInfo.MAX_PATH]; //int result = info.SHGetFolderPathW(null, FolderInfo.CSIDL_WINDOWS, null, 0, buf); String path = Native.toString(buf); if (Platform.is64Bit()) { javaws = new File(path, "SysWOW64/javaws.exe"); } else { javaws = new File(path, "system32/javaws.exe"); } } if (!javaws.exists()) { throw new IOException("javaws executable not found"); } } return javaws.getAbsolutePath(); } // TODO: find some way of querying the current VM for the deployment // properties path private File findDeploymentProperties() { String path = System.getProperty("user.home"); File deployment; if (Platform.isWindows()) { FolderInfo info = (FolderInfo) Native.loadLibrary("shell32", FolderInfo.class); char[] buf = new char[FolderInfo.MAX_PATH]; //int result = info.SHGetFolderPathW(null, FolderInfo.CSIDL_APPDATA, null, 0, buf); path = Native.toString(buf); // NOTE: works for Sun and IBM, may not work for others String vendor = System.getProperty("java.vm.vendor"); if (vendor.indexOf(" ") != -1) { vendor = vendor.substring(0, vendor.indexOf(" ")); } deployment = new File(path + "/" + vendor + "/Java/Deployment"); if (!deployment.exists() && deployment.getAbsolutePath().indexOf("Roaming") != -1) { deployment = new File(deployment.getAbsolutePath().replace("Roaming", "LocalLow")); if (!deployment.exists()) { deployment = new File(deployment.getAbsolutePath().replace("LocalLow", "Local")); } } } else if (Platform.isMac()) { deployment = new File(path + "/Library/Caches/Java"); } else { deployment = new File(path + "/.java/deployment"); } if (!deployment.exists()) { throw new Error("The user deployment directory " + deployment + " does not exist; save Java Control Panel or Web Start settings to initialize it"); } return new File(deployment, "deployment.properties"); } private static final String POLICY_KEY = "deployment.user.security.policy"; private static final String CERTS_KEY = "deployment.user.security.trusted.certs"; public void runBare() throws Throwable { if (runningWebStart()) { super.runBare(); } else if (Platform.isWindows() && Platform.is64Bit()) { throw new Error("Web start launch not supported"); } else if (!GraphicsEnvironment.isHeadless()) { File policy = File.createTempFile(getName(), ".policy"); OutputStream os = new FileOutputStream(policy); os.write(POLICY.getBytes()); os.close(); File dpfile = findDeploymentProperties(); Properties saved = new Properties(); saved.load(new FileInputStream(dpfile)); Properties props = new Properties(); props.putAll(saved); props.setProperty(CERTS_KEY, new File("jna.keystore").getAbsolutePath()); props.setProperty(POLICY_KEY, policy.getAbsolutePath()); os = new FileOutputStream(dpfile); props.store(os, "deployment.properties (for testing)"); os.close(); try { runTestUnderWebStart(); } finally { policy.delete(); os = new FileOutputStream(dpfile); saved.store(os, "deployment.properties"); os.close(); } } } private static void runTestCaseTest(String testClass, String method, int port) { try { TestCase test = (TestCase)Class.forName(testClass).newInstance(); test.setName(method); TestResult result = new TestResult(); test.run(result); Socket s = new Socket(InetAddress.getLocalHost(), port); OutputStream os = s.getOutputStream(); if (result.failureCount() != 0) { Enumeration e = result.failures(); Throwable t = ((TestFailure)e.nextElement()).thrownException(); t.printStackTrace(new PrintStream(os)); } else if (result.errorCount() != 0) { Enumeration e = result.errors(); Throwable t = ((TestFailure)e.nextElement()).thrownException(); t.printStackTrace(new PrintStream(os)); } // NOTE: System.exit with non-zero status causes an error dialog // on w32 sun "1.6.0_14" (build 1.6.0_14-b08) s.close(); System.exit(0); } catch(Throwable e) { // Can't communicate back to launching process showMessage("ERROR: " + e.getMessage()); System.exit(0); } } private static void showMessage(String msg) { showMessage(msg, 60000); } private static void showMessage(String msg, int timeout) { JFrame f = new JFrame("Web Start Test Failure"); f.getContentPane().add(new JScrollPane(new JLabel(msg))); f.pack(); f.setLocation(100, 100); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); if (timeout != 0) { try { Thread.sleep(timeout); } catch(Exception e) { } } } public static void main(String[] args) { try { if (args.length == 4 && "javawebstart".equals(args[3]) && !runningWebStart()) { System.setProperty("javawebstart.version", "fake"); } if (runningWebStart()) { String testClass = args.length > 0 ? args[0] : WebStartTest.class.getName(); String testMethod = args.length > 1 ? args[1] : "testLaunchedUnderWebStart"; int port = args.length > 2 ? Integer.parseInt(args[2]) : 8080; runTestCaseTest(testClass, testMethod, port); } else { junit.textui.TestRunner.run(WebStartTest.class); } } catch(Throwable t) { showMessage("ERROR: " + t.getMessage()); } } } libjna-java-3.2.7/test/com/sun/jna/JNAUnloadTest.java0000644000175000017500000001235711220633670020403 0ustar janjan/* Copyright (c) 2007-2009 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. * * 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; import java.io.File; import java.lang.ref.WeakReference; import java.lang.reflect.Field; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import junit.framework.TestCase; public class JNAUnloadTest extends TestCase { private static final String BUILDDIR = System.getProperty("jna.builddir", "build" + (Platform.is64Bit() ? "-d64" : "")); private static class TestLoader extends URLClassLoader { public TestLoader(boolean fromJar) throws MalformedURLException { super(new URL[] { new File(BUILDDIR + (fromJar ? "/jna.jar" : "/classes")).toURI().toURL(), }, null); } } // Fails under clover public void testUnloadFromJar() throws Exception { File jar = new File(BUILDDIR + "/jna.jar"); assertTrue("Expected JNA jar file at " + jar + " is missing", jar.exists()); ClassLoader loader = new TestLoader(true); Class cls = Class.forName("com.sun.jna.Native", true, loader); assertEquals("Wrong class loader", loader, cls.getClassLoader()); Field field = cls.getDeclaredField("nativeLibraryPath"); field.setAccessible(true); String path = (String)field.get(null); assertTrue("Native library not unpacked from jar: " + path, path.startsWith(System.getProperty("java.io.tmpdir"))); WeakReference ref = new WeakReference(cls); WeakReference clref = new WeakReference(loader); loader = null; cls = null; field = null; System.gc(); for (int i=0;i < 100 && (ref.get() != null || clref.get() != null);i++) { Thread.sleep(10); System.gc(); } assertNull("Class not GC'd: " + ref.get(), ref.get()); assertNull("ClassLoader not GC'd: " + clref.get(), clref.get()); File f = new File(path); for (int i=0;i < 100 && f.exists();i++) { Thread.sleep(10); System.gc(); } // NOTE: Temporary file removal on Windows only works on a Sun VM try { if (Platform.isWindows()) { ClassLoader.class.getDeclaredField("nativeLibraries"); } if (f.exists() && !f.delete()) { assertFalse("Temporary native library still locked: " + path, f.exists()); } } catch(Exception e) { // Skip on non-supported VMs } try { loader = new TestLoader(true); cls = Class.forName("com.sun.jna.Native", true, loader); } catch(Throwable t) { fail("Native library not unloaded: " + t.getMessage()); } finally { loader = null; cls = null; System.gc(); } } // Fails under clover public void testUnload() throws Exception { ClassLoader loader = new TestLoader(false); Class cls = Class.forName("com.sun.jna.Native", true, loader); assertEquals("Wrong class loader", loader, cls.getClassLoader()); Field field = cls.getDeclaredField("nativeLibraryPath"); field.setAccessible(true); String path = (String)field.get(null); assertNotNull("Native library not found", path); WeakReference ref = new WeakReference(cls); WeakReference clref = new WeakReference(loader); loader = null; cls = null; field = null; System.gc(); for (int i=0;i < 100 && (ref.get() != null || clref.get() != null);i++) { Thread.sleep(10); System.gc(); } assertNull("Class not GC'd: " + ref.get(), ref.get()); assertNull("ClassLoader not GC'd: " + clref.get(), clref.get()); Throwable throwable = null; // NOTE: IBM J9 needs some extra time to unload the native library, // so try a few times before failing for (int i=0;i < 100;i++) { System.gc(); Thread.sleep(10); try { loader = new TestLoader(false); cls = Class.forName("com.sun.jna.Native", true, loader); break; } catch(Throwable t) { loader = null; throwable = t; } } try { if (loader == null) fail("Native library not unloaded: " + throwable.getMessage()); } finally { loader = null; cls = null; System.gc(); } } public static void main(String[] args) { junit.textui.TestRunner.run(JNAUnloadTest.class); } } libjna-java-3.2.7/test/com/sun/jna/LibraryLoadTest.java0000644000175000017500000001217611234610410021023 0ustar janjan/* Copyright (c) 2007-2009 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. * * 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; import java.awt.Frame; import java.awt.GraphicsEnvironment; import java.awt.Toolkit; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import junit.framework.TestCase; public class LibraryLoadTest extends TestCase { private static final String BUILDDIR = System.getProperty("jna.builddir", "build" + (Platform.is64Bit() ? "-d64" : "")); public void testLoadJNALibrary() { assertTrue("Point size should never be zero", Pointer.SIZE > 0); } public void testLoadJAWT() { if (GraphicsEnvironment.isHeadless()) return; Frame f = new Frame(getName()); f.pack(); try { // FIXME: this works as a test, but fails in ShapedWindowDemo // if the JAWT load workaround is not used Native.getWindowPointer(f); } finally { f.dispose(); } } public static interface CLibrary extends Library { int wcslen(WString wstr); int strlen(String str); int atol(String str); Pointer getpwuid(int uid); int geteuid(); } public void testLoadAWTAfterJNA() { if (GraphicsEnvironment.isHeadless()) return; if (Pointer.SIZE > 0) { Toolkit.getDefaultToolkit(); } } private Object load() { return Native.loadLibrary(System.getProperty("os.name").startsWith("Windows") ? "msvcrt" : "c", CLibrary.class); } public void testLoadCLibrary() { load(); } private static final String UNICODE = "\u0444\u043b\u0441\u0432\u0443"; private void copy(File src, File dst) throws Exception { FileInputStream is = new FileInputStream(src); FileOutputStream os = new FileOutputStream(dst); int count; byte[] buf = new byte[1024]; try { while ((count = is.read(buf, 0, buf.length)) > 0) { os.write(buf, 0, count); } } finally { try { is.close(); } catch(IOException e) { } try { os.close(); } catch(IOException e) { } } } public void testLoadLibraryWithUnicodeName() throws Exception { String tmp = System.getProperty("java.io.tmpdir"); String libName = System.mapLibraryName("jnidispatch"); File src = new File(BUILDDIR + "/native", libName); assertTrue("Expected JNA native library at " + src + " is missing", src.exists()); String newLibName = UNICODE; if (libName.startsWith("lib")) newLibName = "lib" + newLibName; int dot = libName.lastIndexOf("."); if (dot != -1) { if (Platform.isMac()) { newLibName += ".dylib"; } else { newLibName += libName.substring(dot, libName.length()); } } File dst = new File(tmp, newLibName); dst.deleteOnExit(); copy(src, dst); NativeLibrary.addSearchPath(UNICODE, tmp); NativeLibrary nl = NativeLibrary.getInstance(UNICODE); nl.dispose(); } public void testHandleObjectMethods() { CLibrary lib = (CLibrary)load(); String method = "toString"; try { lib.toString(); method = "hashCode"; lib.hashCode(); method = "equals"; lib.equals(null); } catch(UnsatisfiedLinkError e) { fail("Object method '" + method + "' not handled"); } } public interface TestLib2 extends Library { int dependentReturnFalse(); } public void testLoadDependentLibrary() { try { TestLib2 lib = (TestLib2)Native.loadLibrary("testlib2", TestLib2.class); lib.dependentReturnFalse(); } catch(UnsatisfiedLinkError e) { // failure expected on anything but windows if (Platform.isWindows()) { fail("Failed to load dependent libraries: " + e); } } } // Ubuntu bug when arch-specific libc is active // Only fails on *some* functions public void testLoadProperCLibraryVersion() { if (Platform.isWindows()) return; CLibrary lib = (CLibrary)Native.loadLibrary("c", CLibrary.class); assertNotNull("Couldn't get current user", lib.getpwuid(lib.geteuid())); } public static void main(String[] args) { junit.textui.TestRunner.run(LibraryLoadTest.class); } } libjna-java-3.2.7/test/com/sun/jna/LastErrorTest.java0000644000175000017500000000557711372233154020554 0ustar janjan/* Copyright (c) 2009 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. * * 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; import java.util.Map; import java.util.HashMap; import java.lang.reflect.Method; import junit.framework.TestCase; @SuppressWarnings("unused") public class LastErrorTest extends TestCase { private static final Map OPTIONS = new HashMap() {{ put(Library.OPTION_FUNCTION_MAPPER, new FunctionMapper() { public String getFunctionName(NativeLibrary library, Method m) { if (m.getName().equals("noThrowLastError") || m.getName().equals("throwLastError")) { return "setLastError"; } return m.getName(); } }); }}; public interface TestLibrary extends Library { void noThrowLastError(int code); void throwLastError(int code) throws LastErrorException; } public static class DirectTestLibrary implements TestLibrary { public native void noThrowLastError(int code); public native void throwLastError(int code) throws LastErrorException; static { Native.register(NativeLibrary.getInstance("testlib", OPTIONS)); } } public void testThrowLastError() { Map options = new HashMap(); TestLibrary lib = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class, OPTIONS); final int ERROR = -1; lib.noThrowLastError(ERROR); assertEquals("Last error not preserved", ERROR, Native.getLastError()); try { lib.throwLastError(ERROR); fail("Method should throw LastErrorException"); } catch(LastErrorException e) { assertEquals("Exception should contain error code", ERROR, e.getErrorCode()); } } public void testThrowLastErrorDirect() { TestLibrary lib = new DirectTestLibrary(); final int ERROR = -1; lib.noThrowLastError(ERROR); assertEquals("Last error not preserved", ERROR, Native.getLastError()); try { lib.throwLastError(ERROR); fail("Method should throw LastErrorException"); } catch(LastErrorException e) { assertEquals("Exception should contain error code", ERROR, e.getErrorCode()); } } public static void main(String[] args) { junit.textui.TestRunner.run(LastErrorTest.class); } } libjna-java-3.2.7/test/com/sun/jna/VMCrashProtectionTest.java0000644000175000017500000000263510753020510022171 0ustar janjan/* 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. * * 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; import junit.framework.TestCase; // TODO: add more platforms public class VMCrashProtectionTest extends TestCase { protected void setUp() { Native.setProtected(true); } protected void tearDown() { Native.setProtected(false); } public void testAccessViolation() { if (!Native.isProtected()) return; Memory m = new Memory(Pointer.SIZE); if (Pointer.SIZE == 4) m.setInt(0, 1); else m.setLong(0, 1); Pointer p = m.getPointer(0); try { p.setInt(0, 0); fail("Exception should be thrown"); } catch(Throwable e) { } } public static void main(String[] args) { junit.textui.TestRunner.run(VMCrashProtectionTest.class); } } libjna-java-3.2.7/test/com/sun/jna/win32/0000755000175000017500000000000011351761002016053 5ustar janjanlibjna-java-3.2.7/test/com/sun/jna/win32/W32APIMapperTest.java0000644000175000017500000001576111351761002021642 0ustar janjan/* 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. * * 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.win32; import junit.framework.TestCase; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; public class W32APIMapperTest extends TestCase { final String MAGIC = "magic"; public static void main(String[] args) { junit.textui.TestRunner.run(W32APIMapperTest.class); } public interface UnicodeLibrary extends Library { public static class TestStructure extends Structure { public String string; public String string2; public boolean bool; public boolean bool2; } String returnWStringArgument(String arg); boolean returnInt32Argument(boolean arg); String returnWideStringArrayElement(String[] args, int which); } public interface ASCIILibrary extends Library { public static class TestStructure extends Structure { public String string; public String string2; public boolean bool; public boolean bool2; } String returnStringArgument(String arg); boolean returnInt32Argument(boolean arg); } UnicodeLibrary unicode; ASCIILibrary ascii; protected void setUp() { unicode = (UnicodeLibrary) Native.loadLibrary("testlib", UnicodeLibrary.class, W32APIOptions.UNICODE_OPTIONS); ascii = (ASCIILibrary) Native.loadLibrary("testlib", ASCIILibrary.class, W32APIOptions.ASCII_OPTIONS); } protected void tearDown() { unicode = null; ascii = null; } public void testInvalidHandleValue() { String expected = "opaque@0xffffffff"; if (Pointer.SIZE == 8) { expected += "ffffffff"; } assertEquals("Wrong value", expected, Pointer.createConstant(Pointer.SIZE == 8 ? -1 : 0xFFFFFFFFL).toString()); } public void testBooleanArgumentConversion() { assertTrue("Wrong boolean TRUE argument conversion (unicode)", unicode.returnInt32Argument(true)); assertFalse("Wrong boolean FALSE argument conversion (unicode)", unicode.returnInt32Argument(false)); assertTrue("Wrong boolean TRUE argument conversion (ASCII)", ascii.returnInt32Argument(true)); assertFalse("Wrong boolean FALSE argument conversion (ASCII)", ascii.returnInt32Argument(false)); } public void testUnicodeMapping() { assertEquals("Strings should correspond to wide strings", MAGIC, unicode.returnWStringArgument(MAGIC)); String[] args = { "one", "two" }; assertEquals("String arrays should be converted to wchar_t*[] and back", args[0], unicode.returnWideStringArrayElement(args, 0)); } public void testASCIIMapping() { assertEquals("Strings should correspond to C strings", MAGIC, ascii.returnStringArgument(MAGIC)); } public void testUnicodeStructureSize() { UnicodeLibrary.TestStructure s = new UnicodeLibrary.TestStructure(); assertEquals("Wrong structure size", Pointer.SIZE*2+8, s.size()); } public void testASCIIStructureSize() { ASCIILibrary.TestStructure s = new ASCIILibrary.TestStructure(); assertEquals("Wrong structure size", Pointer.SIZE*2+8, s.size()); } public void testUnicodeStructureWriteBoolean() { UnicodeLibrary.TestStructure s = new UnicodeLibrary.TestStructure(); s.bool2 = true; s.write(); assertEquals("Wrong value written for FALSE", 0, s.getPointer().getInt(Pointer.SIZE*2)); assertEquals("Wrong value written for TRUE", 1, s.getPointer().getInt(Pointer.SIZE*2+4)); } public void testASCIIStructureWriteBoolean() { ASCIILibrary.TestStructure s = new ASCIILibrary.TestStructure(); s.bool2 = true; s.write(); assertEquals("Wrong value written for FALSE", 0, s.getPointer().getInt(Pointer.SIZE*2)); assertEquals("Wrong value written for TRUE", 1, s.getPointer().getInt(Pointer.SIZE*2+4)); } public void testUnicodeStructureReadBoolean() { UnicodeLibrary.TestStructure s = new UnicodeLibrary.TestStructure(); s.getPointer().setInt(Pointer.SIZE*2, 1); s.getPointer().setInt(Pointer.SIZE*2+4, 0); s.read(); assertTrue("Wrong value read for TRUE", s.bool); assertFalse("Wrong value read for FALSE", s.bool2); } public void testASCIIStructureReadBoolean() { ASCIILibrary.TestStructure s = new ASCIILibrary.TestStructure(); s.getPointer().setInt(Pointer.SIZE*2, 1); s.getPointer().setInt(Pointer.SIZE*2+4, 0); s.read(); assertTrue("Wrong value read for TRUE", s.bool); assertFalse("Wrong value read for FALSE", s.bool2); } public void testUnicodeStructureWriteString() { UnicodeLibrary.TestStructure s = new UnicodeLibrary.TestStructure(); s.string = null; s.string2 = MAGIC; s.write(); assertEquals("Improper null write", null, s.getPointer().getPointer(0)); assertEquals("Improper string write", MAGIC, s.getPointer().getPointer(Pointer.SIZE).getString(0, true)); } public void testASCIIStructureWriteString() { ASCIILibrary.TestStructure s = new ASCIILibrary.TestStructure(); s.string = null; s.string2 = MAGIC; s.write(); assertEquals("Improper null write", null, s.getPointer().getPointer(0)); assertEquals("Improper string write", MAGIC, s.getPointer().getPointer(Pointer.SIZE).getString(0, false)); } public void testUnicodeStructureReadString() { UnicodeLibrary.TestStructure s = new UnicodeLibrary.TestStructure(); s.string = MAGIC; s.string2 = null; s.write(); s.read(); assertEquals("Improper string read", MAGIC, s.string); assertEquals("Improper null string read", null, s.string2); } public void testASCIIStructureReadString() { ASCIILibrary.TestStructure s = new ASCIILibrary.TestStructure(); s.string = MAGIC; s.string2 = null; s.write(); s.read(); assertEquals("Improper string read", MAGIC, s.string); assertEquals("Improper null string read", null, s.string2); } } libjna-java-3.2.7/test/com/sun/jna/win32/W32StdCallTest.java0000644000175000017500000001211010777467706021424 0ustar janjan/* 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. *

* 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.win32; import java.lang.reflect.Method; import java.util.HashMap; import junit.framework.TestCase; import com.sun.jna.FunctionMapper; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.NativeLibrary; import com.sun.jna.Structure; /** * @author twall@users.sf.net */ public class W32StdCallTest extends TestCase { public static interface TestLibrary extends StdCallLibrary { public static class Inner extends Structure { public double value; } public static class TestStructure extends Structure { public static class ByValue extends TestStructure implements Structure.ByValue { } public byte c; public short s; public int i; public long j; public Inner inner; } int returnInt32ArgumentStdCall(int arg); TestStructure.ByValue returnStructureByValueArgumentStdCall(TestStructure.ByValue arg); interface Int32Callback extends StdCallCallback { int callback(int arg, int arg2); } int callInt32StdCallCallback(Int32Callback c, int arg, int arg2); } public static void main(java.lang.String[] argList) { junit.textui.TestRunner.run(W32StdCallTest.class); } private TestLibrary testlib; protected void setUp() { testlib = (TestLibrary) Native.loadLibrary("testlib", TestLibrary.class, new HashMap() { { put(Library.OPTION_FUNCTION_MAPPER, StdCallLibrary.FUNCTION_MAPPER); } }); } protected void tearDown() { testlib = null; } public void testFunctionMapper() throws Exception { FunctionMapper mapper = StdCallLibrary.FUNCTION_MAPPER; NativeLibrary lib = NativeLibrary.getInstance("testlib"); Method[] methods = { TestLibrary.class.getMethod("returnInt32ArgumentStdCall", new Class[] { int.class }), TestLibrary.class.getMethod("returnStructureByValueArgumentStdCall", new Class[] { TestLibrary.TestStructure.ByValue.class }), TestLibrary.class.getMethod("callInt32StdCallCallback", new Class[] { TestLibrary.Int32Callback.class, int.class, int.class, }), }; for (int i=0;i < methods.length;i++) { String name = mapper.getFunctionName(lib, methods[i]); assertTrue("Function name not decorated for method " + methods[i].getName() + ": " + name, name.indexOf("@") != -1); assertEquals("Wrong name in mapped function", name, lib.getFunction(name, StdCallLibrary.STDCALL_CONVENTION).getName()); } } public void testStdCallReturnInt32Argument() { final int MAGIC = 0x12345678; assertEquals("Expect zero return", 0, testlib.returnInt32ArgumentStdCall(0)); assertEquals("Expect magic return", MAGIC, testlib.returnInt32ArgumentStdCall(MAGIC)); } public void testStdCallReturnStructureByValueArgument() { TestLibrary.TestStructure.ByValue s = new TestLibrary.TestStructure.ByValue(); assertEquals("Wrong value", s, testlib.returnStructureByValueArgumentStdCall(s)); } public void testStdCallCallback() { final int MAGIC = 0x11111111; final boolean[] called = { false }; TestLibrary.Int32Callback cb = new TestLibrary.Int32Callback() { public int callback(int arg, int arg2) { called[0] = true; return arg + arg2; } }; final int EXPECTED = MAGIC*3; int value = testlib.callInt32StdCallCallback(cb, MAGIC, MAGIC*2); assertTrue("stdcall callback not called", called[0]); if (value == -1) { fail("stdcall callback did not restore the stack pointer"); } assertEquals("Wrong stdcall callback value", Integer.toHexString(EXPECTED), Integer.toHexString(value)); value = testlib.callInt32StdCallCallback(cb, -1, -2); if (value == -1) { fail("stdcall callback did not restore the stack pointer"); } assertEquals("Wrong stdcall callback return", -3, value); } } libjna-java-3.2.7/test/com/sun/jna/DirectByReferenceArgumentsTest.java0000644000175000017500000000402611224550756024043 0ustar janjan/* Copyright (c) 2009 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. *

* 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; import com.sun.jna.ptr.ByteByReference; import com.sun.jna.ptr.DoubleByReference; import com.sun.jna.ptr.FloatByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.LongByReference; import com.sun.jna.ptr.NativeLongByReference; import com.sun.jna.ptr.PointerByReference; import com.sun.jna.ptr.ShortByReference; /** Exercise a range of native methods. * * @author twall@users.sf.net */ public class DirectByReferenceArgumentsTest extends ByReferenceArgumentsTest { public static class DirectTestLibrary implements TestLibrary { public native void incrementInt8ByReference(ByteByReference b); public native void incrementInt16ByReference(ShortByReference s); public native void incrementInt32ByReference(IntByReference i); public native void incrementNativeLongByReference(NativeLongByReference i); public native void incrementInt64ByReference(LongByReference l); public native void complementFloatByReference(FloatByReference f); public native void complementDoubleByReference(DoubleByReference d); public native void setPointerByReferenceNull(PointerByReference p); static { Native.register("testlib"); } } protected void setUp() { lib = new DirectTestLibrary(); } public static void main(java.lang.String[] argList) { junit.textui.TestRunner.run(DirectByReferenceArgumentsTest.class); } } libjna-java-3.2.7/test/com/sun/jna/DirectStructureByValueTest.java0000644000175000017500000000303511235774010023244 0ustar janjan/* Copyright (c) 2009 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. *

* 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; import java.nio.Buffer; import java.nio.ByteBuffer; import java.util.Map; import junit.framework.TestCase; /** General structure by value functionality tests. */ public class DirectStructureByValueTest extends StructureByValueTest { public static void main(java.lang.String[] argList) { junit.textui.TestRunner.run(DirectStructureByValueTest.class); } public static class DirectTestLibrary implements TestLibrary { public native byte testStructureByValueArgument8(ByValue8 arg); public native short testStructureByValueArgument16(ByValue16 arg); public native int testStructureByValueArgument32(ByValue32 arg); public native long testStructureByValueArgument64(ByValue64 arg); public native long testStructureByValueArgument128(ByValue128 arg); static { Native.register("testlib"); } } protected void setUp() { lib = new DirectTestLibrary(); } }libjna-java-3.2.7/test/com/sun/jna/DirectReturnTypesTest.java0000644000175000017500000000721411224550756022272 0ustar janjan/* Copyright (c) 2009 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. *

* 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; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; import com.sun.jna.ReturnTypesTest.TestLibrary.SimpleStructure; import com.sun.jna.ReturnTypesTest.TestLibrary.TestStructure; import com.sun.jna.ReturnTypesTest.TestLibrary.TestSmallStructure; /** Exercise a range of native methods. * * @author twall@users.sf.net */ public class DirectReturnTypesTest extends ReturnTypesTest { public static class DirectTestLibrary implements TestLibrary { public Object returnObjectArgument(Object s) { throw new IllegalArgumentException(s.getClass().getName()); } public TestObject returnObjectArgument(TestObject s) { throw new IllegalArgumentException(s.getClass().getName()); } public native boolean returnFalse(); public native boolean returnTrue(); public native int returnInt32Zero(); public native int returnInt32Magic(); public native long returnInt64Zero(); public native long returnInt64Magic(); public native NativeLong returnLongZero(); public native NativeLong returnLongMagic(); public native float returnFloatZero(); public native float returnFloatMagic(); public native double returnDoubleZero(); public native double returnDoubleMagic(); public native String returnStringMagic(); public native WString returnWStringMagic(); public native SimpleStructure returnStaticTestStructure(); public native SimpleStructure returnNullTestStructure(); public native TestSmallStructure.ByValue returnSmallStructureByValue(); public native TestStructure.ByValue returnStructureByValue(); public Pointer[] returnPointerArgument(Pointer[] arg) {throw new UnsupportedOperationException();} public String[] returnPointerArgument(String[] arg) {throw new UnsupportedOperationException();} public WString[] returnPointerArgument(WString[] arg) {throw new UnsupportedOperationException();} static { Native.register("testlib"); } } protected void setUp() { lib = new DirectTestLibrary(); } public static class DirectObjectTestLibrary extends DirectTestLibrary { public DirectObjectTestLibrary(Map options) { Native.register(getClass(), NativeLibrary.getInstance("testlib", options)); } } public static class DirectNativeMappedLibrary implements NativeMappedLibrary { public native Custom returnInt32Argument(int arg); static { Native.register("testlib"); } } protected NativeMappedLibrary loadNativeMappedLibrary() { return new DirectNativeMappedLibrary(); } // Override not-yet-supported tests public void testReturnObject() { } public void testReturnPointerArray() { } public void testReturnStringArray() { } public void testReturnWStringArray() { } public static void main(java.lang.String[] argList) { junit.textui.TestRunner.run(DirectReturnTypesTest.class); } } libjna-java-3.2.7/test/com/sun/jna/MemoryTest.java0000644000175000017500000001113611372233154020073 0ustar janjan/* 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. * * 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; import java.lang.ref.WeakReference; import java.nio.Buffer; import java.nio.ByteBuffer; import junit.framework.TestCase; public class MemoryTest extends TestCase { public void testAutoFreeMemory() throws Exception { final boolean[] flag = { false }; Memory core = new Memory(10) { protected void finalize() { super.finalize(); flag[0] = true; } }; Pointer shared = core.share(0, 5); WeakReference ref = new WeakReference(core); core = null; System.gc(); long start = System.currentTimeMillis(); assertFalse("Memory prematurely GC'd", flag[0]); assertNotNull("Base memory GC'd while shared memory extant", ref.get()); // Avoid having IBM J9 prematurely nullify "shared" shared.setInt(0, 0); shared = null; System.gc(); while (ref.get() != null) { if (System.currentTimeMillis() - start > 5000) break; Thread.sleep(10); } assertNull("Memory not GC'd", ref.get()); } public void testSharedMemoryBounds() { Memory base = new Memory(16); Pointer shared = base.share(4, 4); shared.getInt(-4); try { shared.getInt(-8); fail("Bounds check should fail"); } catch(IndexOutOfBoundsException e) { } shared.getInt(8); try { shared.getInt(12); fail("Bounds check should fail"); } catch(IndexOutOfBoundsException e) { } } public void testAlignment() { final int SIZE = 1<<16; Memory base = new Memory(SIZE); for (int align=1;align < SIZE;align *= 2) { Memory unaligned = base; long mask = ~((long)align - 1); if ((base.peer & mask) == base.peer) unaligned = (Memory)base.share(1, SIZE-1); Pointer aligned = unaligned.align(align); assertEquals("Memory not aligned (" + align + ")", aligned.peer & mask, aligned.peer); assertSame("Alignment request on aligned memory should no-op", aligned, ((Memory)aligned).align(align)); } } public void testNegativeAlignment() { final int SIZE = 128; Memory base = new Memory(SIZE); try { base.align(-1); fail("Negative alignments not allowed"); } catch(IllegalArgumentException e) { } } public void testInvalidAlignment() { final int SIZE = 128; Memory base = new Memory(SIZE); int[] alignments = { 0, 3, 5, 9, 13 }; for (int i=0;i < alignments.length;i++) { try { base.align(alignments[i]); fail("Power-of-two alignments required"); } catch(IllegalArgumentException e) { } } } public void testAvoidGCWithExtantBuffer() throws Exception { Memory m = new Memory(1024); ByteBuffer b = m.getByteBuffer(0, m.size()); WeakReference ref = new WeakReference(m); WeakReference bref = new WeakReference(b); m = null; System.gc(); Memory.purge(); for (int i=0;i < 100 && ref.get() != null;i++) { Thread.sleep(10); System.gc(); Memory.purge(); } assertNotNull("Memory GC'd while NIO Buffer still extant", ref.get()); // Avoid IBM J9 optimization resulting in premature GC of buffer b.put((byte)0); b = null; System.gc(); Memory.purge(); for (int i=0;i < 100 && (bref.get() != null || ref.get() != null);i++) { Thread.sleep(10); System.gc(); Memory.purge(); } assertNull("Buffer not GC'd\n", bref.get()); assertNull("Memory not GC'd after buffer GC'd\n", ref.get()); } public static void main(String[] args) { junit.textui.TestRunner.run(MemoryTest.class); } } libjna-java-3.2.7/test/com/sun/jna/TypeMapperTest.java0000644000175000017500000002257511372233154020722 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; @SuppressWarnings("unused") public class TypeMapperTest extends TestCase { public static interface TestLibrary extends Library { int returnInt32Argument(boolean b); int returnInt32Argument(String s); int returnInt32Argument(Number n); } public void testBooleanToIntArgumentConversion() { final int MAGIC = 0xABEDCF23; Map options = new HashMap(); DefaultTypeMapper mapper = new DefaultTypeMapper(); mapper.addToNativeConverter(Boolean.class, new ToNativeConverter() { public Object toNative(Object arg, ToNativeContext ctx) { return new Integer(Boolean.TRUE.equals(arg) ? MAGIC : 0); } public Class nativeType() { return Integer.class; } }); options.put(Library.OPTION_TYPE_MAPPER, mapper); TestLibrary lib = (TestLibrary) Native.loadLibrary("testlib", TestLibrary.class, options); assertEquals("Failed to convert Boolean argument to Int", MAGIC, lib.returnInt32Argument(true)); } public void testStringToIntArgumentConversion() { DefaultTypeMapper mapper = new DefaultTypeMapper(); mapper.addToNativeConverter(String.class, new ToNativeConverter() { public Object toNative(Object arg, ToNativeContext ctx) { return Integer.valueOf((String) arg, 16); } public Class nativeType() { return Integer.class; } }); Map options = new HashMap(); options.put(Library.OPTION_TYPE_MAPPER, mapper); final int MAGIC = 0x7BEDCF23; TestLibrary lib = (TestLibrary) Native.loadLibrary("testlib", TestLibrary.class, options); assertEquals("Failed to convert String argument to Int", MAGIC, lib.returnInt32Argument(Integer.toHexString(MAGIC))); } public void testCharSequenceToIntArgumentConversion() { DefaultTypeMapper mapper = new DefaultTypeMapper(); mapper.addToNativeConverter(CharSequence.class, new ToNativeConverter() { public Object toNative(Object arg, ToNativeContext ctx) { return Integer.valueOf(((CharSequence)arg).toString(), 16); } public Class nativeType() { return Integer.class; } }); Map options = new HashMap(); options.put(Library.OPTION_TYPE_MAPPER, mapper); final int MAGIC = 0x7BEDCF23; TestLibrary lib = (TestLibrary) Native.loadLibrary("testlib", TestLibrary.class, options); assertEquals("Failed to convert String argument to Int", MAGIC, lib.returnInt32Argument(Integer.toHexString(MAGIC))); } public void testNumberToIntArgumentConversion() { DefaultTypeMapper mapper = new DefaultTypeMapper(); mapper.addToNativeConverter(Double.class, new ToNativeConverter() { public Object toNative(Object arg, ToNativeContext ctx) { return new Integer(((Double)arg).intValue()); } public Class nativeType() { return Integer.class; } }); Map options = new HashMap(); options.put(Library.OPTION_TYPE_MAPPER, mapper); final int MAGIC = 0x7BEDCF23; TestLibrary lib = (TestLibrary) Native.loadLibrary("testlib", TestLibrary.class, options); assertEquals("Failed to convert Double argument to Int", MAGIC, lib.returnInt32Argument(new Double(MAGIC))); } public static interface BooleanTestLibrary extends Library { boolean returnInt32Argument(boolean b); } public void testIntegerToBooleanResultConversion() throws Exception { final int MAGIC = 0xABEDCF23; Map options = new HashMap(); DefaultTypeMapper mapper = new DefaultTypeMapper(); mapper.addToNativeConverter(Boolean.class, new ToNativeConverter() { public Object toNative(Object value, ToNativeContext ctx) { return new Integer(Boolean.TRUE.equals(value) ? MAGIC : 0); } public Class nativeType() { return Integer.class; } }); mapper.addFromNativeConverter(Boolean.class, new FromNativeConverter() { public Object fromNative(Object value, FromNativeContext context) { return Boolean.valueOf(((Integer) value).intValue() == MAGIC); } public Class nativeType() { return Integer.class; } }); options.put(Library.OPTION_TYPE_MAPPER, mapper); BooleanTestLibrary lib = (BooleanTestLibrary) Native.loadLibrary("testlib", BooleanTestLibrary.class, options); assertEquals("Failed to convert integer return to boolean TRUE", true, lib.returnInt32Argument(true)); assertEquals("Failed to convert integer return to boolean FALSE", false, lib.returnInt32Argument(false)); } public static interface StructureTestLibrary extends Library { public static class TestStructure extends Structure { public TestStructure(TypeMapper mapper) { setTypeMapper(mapper); } public boolean data; } } public void testStructureConversion() throws Exception { DefaultTypeMapper mapper = new DefaultTypeMapper(); TypeConverter converter = new TypeConverter() { public Object toNative(Object value, ToNativeContext ctx) { return new Integer(Boolean.TRUE.equals(value) ? 1 : 0); } public Object fromNative(Object value, FromNativeContext context) { return new Boolean(((Integer)value).intValue() == 1); } public Class nativeType() { return Integer.class; } }; mapper.addTypeConverter(Boolean.class, converter); Map options = new HashMap(); options.put(Library.OPTION_TYPE_MAPPER, mapper); StructureTestLibrary lib = (StructureTestLibrary) Native.loadLibrary("testlib", StructureTestLibrary.class, options); StructureTestLibrary.TestStructure s = new StructureTestLibrary.TestStructure(mapper); assertEquals("Wrong native size", 4, s.size()); s.data = true; s.write(); assertEquals("Wrong value written", 1, s.getPointer().getInt(0)); s.getPointer().setInt(0, 0); s.read(); assertFalse("Wrong value read", s.data); } @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public static @interface FooBoolean {} public static interface AnnotationTestLibrary extends Library { @FooBoolean boolean returnInt32Argument(boolean b); } public void testAnnotationsOnMethods() throws Exception { final int MAGIC = 0xABEDCF23; Map options = new HashMap(); final boolean[] hasAnnotation = {false, false}; DefaultTypeMapper mapper = new DefaultTypeMapper(); mapper.addTypeConverter(Boolean.class, new TypeConverter() { public Object toNative(Object value, ToNativeContext ctx) { MethodParameterContext mcontext = (MethodParameterContext)ctx; hasAnnotation[0] = mcontext.getMethod().getAnnotation(FooBoolean.class) != null; return new Integer(Boolean.TRUE.equals(value) ? MAGIC : 0); } public Object fromNative(Object value, FromNativeContext context) { MethodResultContext mcontext = (MethodResultContext)context; hasAnnotation[1] = mcontext.getMethod().getAnnotation(FooBoolean.class) != null; return Boolean.valueOf(((Integer) value).intValue() == MAGIC); } public Class nativeType() { return Integer.class; } }); options.put(Library.OPTION_TYPE_MAPPER, mapper); AnnotationTestLibrary lib = (AnnotationTestLibrary) Native.loadLibrary("testlib", AnnotationTestLibrary.class, options); assertEquals("Failed to convert integer return to boolean TRUE", true, lib.returnInt32Argument(true)); assertTrue("Failed to get annotation from ParameterContext", hasAnnotation[0]); assertTrue("Failed to get annotation from ResultContext", hasAnnotation[1]); } public static void main(String[] args) { junit.textui.TestRunner.run(TypeMapperTest.class); } } libjna-java-3.2.7/test/com/sun/jna/ReturnTypesTest.java0000644000175000017500000002436211224550756021142 0ustar janjan/* 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. *

* 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; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; import com.sun.jna.ReturnTypesTest.TestLibrary.SimpleStructure; import com.sun.jna.ReturnTypesTest.TestLibrary.TestStructure; import com.sun.jna.ReturnTypesTest.TestLibrary.TestSmallStructure; /** Exercise a range of native methods. * * @author twall@users.sf.net */ public class ReturnTypesTest extends TestCase { private static final double DOUBLE_MAGIC = -118.625d; private static final float FLOAT_MAGIC = -118.625f; public static interface TestLibrary extends Library { public static class SimpleStructure extends Structure { public double value; } public static class TestSmallStructure extends Structure { public static class ByValue extends TestSmallStructure implements Structure.ByValue { } public byte c1; public byte c2; public short s; } public static class TestStructure extends Structure { public static class ByValue extends TestStructure implements Structure.ByValue { } public byte c; public short s; public int i; public long j; public SimpleStructure inner; } class CheckFieldAlignment extends Structure { public int int32Field = 1; public long int64Field = 2; public float floatField = 3f; public double doubleField = 4d; } class TestObject { } Object returnObjectArgument(Object s); TestObject returnObjectArgument(TestObject s); boolean returnFalse(); boolean returnTrue(); int returnInt32Zero(); int returnInt32Magic(); long returnInt64Zero(); long returnInt64Magic(); NativeLong returnLongZero(); NativeLong returnLongMagic(); float returnFloatZero(); float returnFloatMagic(); double returnDoubleZero(); double returnDoubleMagic(); String returnStringMagic(); WString returnWStringMagic(); SimpleStructure returnStaticTestStructure(); SimpleStructure returnNullTestStructure(); TestSmallStructure.ByValue returnSmallStructureByValue(); TestStructure.ByValue returnStructureByValue(); Pointer[] returnPointerArgument(Pointer[] arg); String[] returnPointerArgument(String[] arg); WString[] returnPointerArgument(WString[] arg); } TestLibrary lib; protected void setUp() { lib = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class); } protected void tearDown() { lib = null; } public void testReturnObject() throws Exception { Map options = new HashMap() { { put(Library.OPTION_ALLOW_OBJECTS, Boolean.TRUE); }}; lib = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class, options); assertNull("null value not returned", lib.returnObjectArgument(null)); final Object VALUE = new Object() { public String toString() { return getName(); } }; assertEquals("Wrong object returned", VALUE, lib.returnObjectArgument(VALUE)); } public void testReturnObjectUnsupported() throws Exception { try { lib.returnObjectArgument(new TestLibrary.TestObject()); fail("Java Object return is not supported, should throw IllegalArgumentException"); } catch(IllegalArgumentException e) { assertTrue("Exception should include return object type: " + e, e.getMessage().indexOf(TestLibrary.TestObject.class.getName()) != -1); } catch(Throwable e) { fail("Method declared with Java Object return should throw IllegalArgumentException, not " + e); } } public void testInvokeBoolean() { assertFalse("Expect false", lib.returnFalse()); assertTrue("Expect true", lib.returnTrue()); } public void testInvokeInt() { assertEquals("Expect 32-bit zero", 0, lib.returnInt32Zero()); assertEquals("Expect 32-bit magic", "12345678", Integer.toHexString(lib.returnInt32Magic())); } public void testInvokeLong() { assertEquals("Expect 64-bit zero", 0L, lib.returnInt64Zero()); assertEquals("Expect 64-bit magic", "123456789abcdef0", Long.toHexString(lib.returnInt64Magic())); } public void testInvokeNativeLong() { if (NativeLong.SIZE == 4) { assertEquals("Expect 32-bit zero", new NativeLong(0), lib.returnLongZero()); assertEquals("Expect 32-bit magic", "12345678", Integer.toHexString(lib.returnLongMagic().intValue())); } else { assertEquals("Expect 64-bit zero", new NativeLong(0L), lib.returnLongZero()); assertEquals("Expect 64-bit magic", "123456789abcdef0", Long.toHexString(lib.returnLongMagic().longValue())); } } public interface NativeMappedLibrary extends Library { Custom returnInt32Argument(int arg); } public static class Custom implements NativeMapped { private int value; public Custom() { } public Custom(int value) { this.value = value; } public Object fromNative(Object nativeValue, FromNativeContext context) { return new Custom(((Integer)nativeValue).intValue()); } public Class nativeType() { return Integer.class; } public Object toNative() { return new Integer(value); } public boolean equals(Object o) { return o instanceof Custom && ((Custom)o).value == value; } } protected NativeMappedLibrary loadNativeMappedLibrary() { return (NativeMappedLibrary) Native.loadLibrary("testlib", NativeMappedLibrary.class); } public void testInvokeNativeMapped() { NativeMappedLibrary lib = loadNativeMappedLibrary(); final int MAGIC = 0x12345678; final Custom EXPECTED = new Custom(MAGIC); assertEquals("Argument not mapped", EXPECTED, lib.returnInt32Argument(MAGIC)); } public void testInvokeFloat() { assertEquals("Expect float zero", 0f, lib.returnFloatZero(), 0d); assertEquals("Expect float magic", FLOAT_MAGIC, lib.returnFloatMagic(), 0d); } public void testInvokeDouble() { assertEquals("Expect double zero", 0d, lib.returnDoubleZero(), 0d); assertEquals("Expect double magic", DOUBLE_MAGIC, lib.returnDoubleMagic(), 0d); } static final String MAGIC = "magic"; public void testInvokeString() { assertEquals("Expect String magic", MAGIC, lib.returnStringMagic()); } public void testInvokeWString() { WString s = lib.returnWStringMagic(); assertEquals("Wrong length", MAGIC.length(), s.toString().length()); assertEquals("Expect WString magic", new WString(MAGIC), s); } public void testInvokeStructure() { SimpleStructure s = lib.returnStaticTestStructure(); assertEquals("Expect test structure magic", DOUBLE_MAGIC, s.value, 0d); } public void testInvokeNullStructure() { SimpleStructure s = lib.returnNullTestStructure(); assertNull("Expect null structure return", s); } public void testReturnSmallStructureByValue() { TestSmallStructure s = lib.returnSmallStructureByValue(); assertNotNull("Returned structure must not be null", s); assertEquals("Wrong char field value (1)", 1, s.c1); assertEquals("Wrong char field value (2)", 2, s.c2); assertEquals("Wrong short field value", 3, s.s); } public void testReturnStructureByValue() { TestStructure s = lib.returnStructureByValue(); assertNotNull("Returned structure must not be null", s); assertEquals("Wrong char field value", 1, s.c); assertEquals("Wrong short field value", 2, s.s); assertEquals("Wrong int field value", 3, s.i); assertEquals("Wrong long field value", 4, s.j); assertNotNull("Structure not initialized", s.inner); assertEquals("Wrong inner structure value", 5, s.inner.value, 0); } public void testReturnPointerArray() { Pointer value = new Memory(10); Pointer[] input = { value, null, }; Pointer[] result = lib.returnPointerArgument(input); assertEquals("Wrong array length", input.length-1, result.length); assertEquals("Wrong array element value", value, result[0]); } public void testReturnStringArray() { String value = getName(); String[] input = { value, null, }; String[] result = lib.returnPointerArgument(input); assertEquals("Wrong array length", input.length-1, result.length); assertEquals("Wrong array element value", value, result[0]); } public void testReturnWStringArray() { WString value = new WString(getName()); WString[] input = { value, null, }; WString[] result = lib.returnPointerArgument(input); assertEquals("Wrong array length", input.length-1, result.length); assertEquals("Wrong array element value", value, result[0]); } public static void main(java.lang.String[] argList) { junit.textui.TestRunner.run(ReturnTypesTest.class); } } libjna-java-3.2.7/test/com/sun/jna/CallbacksTest.java0000644000175000017500000011052111372233154020500 0ustar janjan/* Copyright (c) 2007-2008 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. *

* 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; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.lang.ref.WeakReference; import java.util.HashMap; import java.util.Map; import java.util.WeakHashMap; import junit.framework.TestCase; import com.sun.jna.Callback.UncaughtExceptionHandler; import com.sun.jna.CallbacksTest.TestLibrary.CbCallback; import com.sun.jna.ptr.IntByReference; /** Exercise callback-related functionality. * * @author twall@users.sf.net */ @SuppressWarnings("unused") public class CallbacksTest extends TestCase { private static final double DOUBLE_MAGIC = -118.625d; private static final float FLOAT_MAGIC = -118.625f; public static class SmallTestStructure extends Structure { public double value; } public static class TestStructure extends Structure { public static class ByValue extends TestStructure implements Structure.ByValue { } public static interface TestCallback extends Callback { TestStructure.ByValue callback(TestStructure.ByValue s); } public byte c; public short s; public int i; public long j; public SmallTestStructure inner; } public static interface TestLibrary extends Library { interface NoMethodCallback extends Callback { } interface CustomMethodCallback extends Callback { void invoke(); } interface TooManyMethodsCallback extends Callback { void invoke(); void invoke2(); } interface MultipleMethodsCallback extends Callback { void invoke(); void callback(); } interface VoidCallback extends Callback { void callback(); } void callVoidCallback(VoidCallback c); interface VoidCallbackCustom extends Callback { void customMethodName(); } abstract class VoidCallbackCustomAbstract implements VoidCallbackCustom { public void customMethodName() { } } class VoidCallbackCustomDerived extends VoidCallbackCustomAbstract { } void callVoidCallback(VoidCallbackCustom c); interface BooleanCallback extends Callback { boolean callback(boolean arg, boolean arg2); } boolean callBooleanCallback(BooleanCallback c, boolean arg, boolean arg2); interface ByteCallback extends Callback { byte callback(byte arg, byte arg2); } byte callInt8Callback(ByteCallback c, byte arg, byte arg2); interface ShortCallback extends Callback { short callback(short arg, short arg2); } short callInt16Callback(ShortCallback c, short arg, short arg2); interface Int32Callback extends Callback { int callback(int arg, int arg2); } int callInt32Callback(Int32Callback c, int arg, int arg2); interface NativeLongCallback extends Callback { NativeLong callback(NativeLong arg, NativeLong arg2); } NativeLong callNativeLongCallback(NativeLongCallback c, NativeLong arg, NativeLong arg2); interface Int64Callback extends Callback { long callback(long arg, long arg2); } long callInt64Callback(Int64Callback c, long arg, long arg2); interface FloatCallback extends Callback { float callback(float arg, float arg2); } float callFloatCallback(FloatCallback c, float arg, float arg2); interface DoubleCallback extends Callback { double callback(double arg, double arg2); } double callDoubleCallback(DoubleCallback c, double arg, double arg2); interface StructureCallback extends Callback { SmallTestStructure callback(SmallTestStructure arg); } SmallTestStructure callStructureCallback(StructureCallback c, SmallTestStructure arg); interface StringCallback extends Callback { String callback(String arg); } String callStringCallback(StringCallback c, String arg); interface WideStringCallback extends Callback { WString callback(WString arg); } WString callWideStringCallback(WideStringCallback c, WString arg); interface CopyArgToByReference extends Callback { int callback(int arg, IntByReference result); } interface StringArrayCallback extends Callback { String[] callback(String[] arg); } Pointer callStringArrayCallback(StringArrayCallback c, String[] arg); int callCallbackWithByReferenceArgument(CopyArgToByReference cb, int arg, IntByReference result); TestStructure.ByValue callCallbackWithStructByValue(TestStructure.TestCallback callback, TestStructure.ByValue cbstruct); interface CbCallback extends Callback { CbCallback callback(CbCallback arg); } CbCallback callCallbackWithCallback(CbCallback cb); interface Int32CallbackX extends Callback { public int callback(int arg); } Int32CallbackX returnCallback(); Int32CallbackX returnCallbackArgument(Int32CallbackX cb); interface CustomCallback extends Callback { Custom callback(Custom arg1, Custom arg2); } int callInt32Callback(CustomCallback cb, int arg1, int arg2); class CbStruct extends Structure { public Callback cb; } void callCallbackInStruct(CbStruct cbstruct); } TestLibrary lib; protected void setUp() { lib = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class); } protected void tearDown() { lib = null; } public void testLookupNullCallback() { assertNull("NULL pointer should result in null callback", CallbackReference.getCallback(null, null)); try { CallbackReference.getCallback(TestLibrary.VoidCallback.class, new Pointer(0)); fail("Null pointer lookup should fail"); } catch(NullPointerException e) { } } public void testLookupNonCallbackClass() { try { CallbackReference.getCallback(String.class, new Pointer(0)); fail("Request for non-Callback class should fail"); } catch(IllegalArgumentException e) { } } public void testNoMethodCallback() { try { CallbackReference.getCallback(TestLibrary.NoMethodCallback.class, new Pointer(1)); fail("Callback with no callback method should fail"); } catch(IllegalArgumentException e) { } } public void testCustomMethodCallback() { CallbackReference.getCallback(TestLibrary.CustomMethodCallback.class, new Pointer(1)); } public void testTooManyMethodsCallback() { try { CallbackReference.getCallback(TestLibrary.TooManyMethodsCallback.class, new Pointer(1)); fail("Callback lookup with too many methods should fail"); } catch(IllegalArgumentException e) { } } public void testMultipleMethodsCallback() { CallbackReference.getCallback(TestLibrary.MultipleMethodsCallback.class, new Pointer(1)); } public void testNativeFunctionPointerStringValue() { Callback cb = CallbackReference.getCallback(TestLibrary.VoidCallback.class, new Pointer(1)); Class cls = CallbackReference.findCallbackClass(cb.getClass()); assertTrue("toString should include Java Callback type: " + cb + " (" + cls + ")", cb.toString().indexOf(cls.getName()) != -1); } public void testLookupSameCallback() { Callback cb = CallbackReference.getCallback(TestLibrary.VoidCallback.class, new Pointer(1)); Callback cb2 = CallbackReference.getCallback(TestLibrary.VoidCallback.class, new Pointer(1)); assertEquals("Callback lookups for same pointer should return same Callback object", cb, cb2); } public void testGCCallback() throws Exception { final boolean[] called = { false }; TestLibrary.VoidCallback cb = new TestLibrary.VoidCallback() { public void callback() { called[0] = true; } }; lib.callVoidCallback(cb); assertTrue("Callback not called", called[0]); Map refs = new WeakHashMap(CallbackReference.callbackMap); refs.putAll(CallbackReference.directCallbackMap); assertTrue("Callback not cached", refs.containsKey(cb)); CallbackReference ref = (CallbackReference)refs.get(cb); refs = ref.proxy != null ? CallbackReference.callbackMap : CallbackReference.directCallbackMap; Pointer cbstruct = ref.cbstruct; cb = null; System.gc(); for (int i = 0; i < 100 && (ref.get() != null || refs.containsValue(ref)); ++i) { try { Thread.sleep(10); // Give the GC a chance to run } finally {} } assertNull("Callback not GC'd", ref.get()); assertFalse("Callback still in map", refs.containsValue(ref)); ref = null; System.gc(); for (int i = 0; i < 100 && (cbstruct.peer != 0 || refs.size() > 0); ++i) { // Flush weak hash map refs.size(); try { Thread.sleep(10); // Give the GC a chance to run System.gc(); } finally {} } assertEquals("Callback trampoline not freed", 0, cbstruct.peer); } public void testFindCallbackInterface() { TestLibrary.Int32Callback cb = new TestLibrary.Int32Callback() { public int callback(int arg, int arg2) { return arg + arg2; } }; assertEquals("Wrong callback interface", TestLibrary.Int32Callback.class, CallbackReference.findCallbackClass(cb.getClass())); } public void testCallInt32Callback() { final int MAGIC = 0x11111111; final boolean[] called = { false }; TestLibrary.Int32Callback cb = new TestLibrary.Int32Callback() { public int callback(int arg, int arg2) { called[0] = true; return arg + arg2; } }; final int EXPECTED = MAGIC*3; int value = lib.callInt32Callback(cb, MAGIC, MAGIC*2); assertTrue("Callback not called", called[0]); assertEquals("Wrong callback value", Integer.toHexString(EXPECTED), Integer.toHexString(value)); value = lib.callInt32Callback(cb, -1, -2); assertEquals("Wrong callback return", -3, value); } public void testCallInt64Callback() { final long MAGIC = 0x1111111111111111L; final boolean[] called = { false }; TestLibrary.Int64Callback cb = new TestLibrary.Int64Callback() { public long callback(long arg, long arg2) { called[0] = true; return arg + arg2; } }; final long EXPECTED = MAGIC*3; long value = lib.callInt64Callback(cb, MAGIC, MAGIC*2); assertTrue("Callback not called", called[0]); assertEquals("Wrong callback value", Long.toHexString(EXPECTED), Long.toHexString(value)); value = lib.callInt64Callback(cb, -1, -2); assertEquals("Wrong callback return", -3, value); } public void testCallFloatCallback() { final boolean[] called = { false }; final float[] args = { 0, 0 }; TestLibrary.FloatCallback cb = new TestLibrary.FloatCallback() { public float callback(float arg, float arg2) { called[0] = true; args[0] = arg; args[1] = arg2; return arg + arg2; } }; final float EXPECTED = FLOAT_MAGIC*3; float value = lib.callFloatCallback(cb, FLOAT_MAGIC, FLOAT_MAGIC*2); assertTrue("Callback not called", called[0]); assertEquals("Wrong first argument", FLOAT_MAGIC, args[0], 0); assertEquals("Wrong second argument", FLOAT_MAGIC*2, args[1], 0); assertEquals("Wrong callback value", EXPECTED, value, 0); value = lib.callFloatCallback(cb, -1f, -2f); assertEquals("Wrong callback return", -3f, value, 0); } public void testCallDoubleCallback() { final boolean[] called = { false }; final double[] args = { 0, 0 }; TestLibrary.DoubleCallback cb = new TestLibrary.DoubleCallback() { public double callback(double arg, double arg2) { called[0] = true; args[0] = arg; args[1] = arg2; return arg + arg2; } }; final double EXPECTED = DOUBLE_MAGIC*3; double value = lib.callDoubleCallback(cb, DOUBLE_MAGIC, DOUBLE_MAGIC*2); assertTrue("Callback not called", called[0]); assertEquals("Wrong first argument", DOUBLE_MAGIC, args[0], 0); assertEquals("Wrong second argument", DOUBLE_MAGIC*2, args[1], 0); assertEquals("Wrong callback value", EXPECTED, value, 0); value = lib.callDoubleCallback(cb, -1d, -2d); assertEquals("Wrong callback return", -3d, value, 0); } public void testCallStructureCallback() { final boolean[] called = {false}; final Pointer[] cbarg = { null }; final SmallTestStructure s = new SmallTestStructure(); final double MAGIC = 118.625; TestLibrary.StructureCallback cb = new TestLibrary.StructureCallback() { public SmallTestStructure callback(SmallTestStructure arg) { called[0] = true; cbarg[0] = arg.getPointer(); arg.value = MAGIC; return arg; } }; SmallTestStructure value = lib.callStructureCallback(cb, s); assertTrue("Callback not called", called[0]); assertEquals("Wrong argument passed to callback", s.getPointer(), cbarg[0]); assertEquals("Structure argument not synched on callback return", MAGIC, s.value); assertEquals("Wrong structure return", s.getPointer(), value.getPointer()); assertEquals("Structure return not synched", MAGIC, value.value); } public void testCallStructureArrayCallback() { final SmallTestStructure s = new SmallTestStructure(); final SmallTestStructure[] array = (SmallTestStructure[])s.toArray(2); final double MAGIC = 118.625; TestLibrary.StructureCallback cb = new TestLibrary.StructureCallback() { public SmallTestStructure callback(SmallTestStructure arg) { SmallTestStructure[] array = (SmallTestStructure[])arg.toArray(2); array[0].value = MAGIC; array[1].value = MAGIC*2; return arg; } }; SmallTestStructure value = lib.callStructureCallback(cb, s); assertEquals("Structure array element 0 not synched on callback return", MAGIC, array[0].value); assertEquals("Structure array element 1 not synched on callback return", MAGIC*2, array[1].value); } public void testCallBooleanCallback() { final boolean[] called = {false}; final boolean[] cbargs = { false, false }; TestLibrary.BooleanCallback cb = new TestLibrary.BooleanCallback() { public boolean callback(boolean arg, boolean arg2) { called[0] = true; cbargs[0] = arg; cbargs[1] = arg2; return arg && arg2; } }; boolean value = lib.callBooleanCallback(cb, true, false); assertTrue("Callback not called", called[0]); assertEquals("Wrong callback argument 1", true, cbargs[0]); assertEquals("Wrong callback argument 2", false, cbargs[1]); assertFalse("Wrong boolean return", value); } public void testCallInt8Callback() { final boolean[] called = {false}; final byte[] cbargs = { 0, 0 }; TestLibrary.ByteCallback cb = new TestLibrary.ByteCallback() { public byte callback(byte arg, byte arg2) { called[0] = true; cbargs[0] = arg; cbargs[1] = arg2; return (byte)(arg + arg2); } }; final byte MAGIC = 0x11; byte value = lib.callInt8Callback(cb, MAGIC, (byte)(MAGIC*2)); assertTrue("Callback not called", called[0]); assertEquals("Wrong callback argument 1", Integer.toHexString(MAGIC), Integer.toHexString(cbargs[0])); assertEquals("Wrong callback argument 2", Integer.toHexString(MAGIC*2), Integer.toHexString(cbargs[1])); assertEquals("Wrong byte return", Integer.toHexString(MAGIC*3), Integer.toHexString(value)); value = lib.callInt8Callback(cb, (byte)-1, (byte)-2); assertEquals("Wrong byte return (hi bit)", (byte)-3, value); } public void testCallInt16Callback() { final boolean[] called = {false}; final short[] cbargs = { 0, 0 }; TestLibrary.ShortCallback cb = new TestLibrary.ShortCallback() { public short callback(short arg, short arg2) { called[0] = true; cbargs[0] = arg; cbargs[1] = arg2; return (short)(arg + arg2); } }; final short MAGIC = 0x1111; short value = lib.callInt16Callback(cb, MAGIC, (short)(MAGIC*2)); assertTrue("Callback not called", called[0]); assertEquals("Wrong callback argument 1", Integer.toHexString(MAGIC), Integer.toHexString(cbargs[0])); assertEquals("Wrong callback argument 2", Integer.toHexString(MAGIC*2), Integer.toHexString(cbargs[1])); assertEquals("Wrong short return", Integer.toHexString(MAGIC*3), Integer.toHexString(value)); value = lib.callInt16Callback(cb, (short)-1, (short)-2); assertEquals("Wrong short return (hi bit)", (short)-3, value); } public void testCallNativeLongCallback() { final boolean[] called = {false}; final NativeLong[] cbargs = { null, null}; TestLibrary.NativeLongCallback cb = new TestLibrary.NativeLongCallback() { public NativeLong callback(NativeLong arg, NativeLong arg2) { called[0] = true; cbargs[0] = arg; cbargs[1] = arg2; return new NativeLong(arg.intValue() + arg2.intValue()); } }; NativeLong value = lib.callNativeLongCallback(cb, new NativeLong(1), new NativeLong(2)); assertTrue("Callback not called", called[0]); assertEquals("Wrong callback argument 1", new NativeLong(1), cbargs[0]); assertEquals("Wrong callback argument 2", new NativeLong(2), cbargs[1]); assertEquals("Wrong boolean return", new NativeLong(3), value); } public static class Custom implements NativeMapped { private int value; public Custom() { } public Custom(int value) { this.value = value; } public Object fromNative(Object nativeValue, FromNativeContext context) { return new Custom(((Integer)nativeValue).intValue()); } public Class nativeType() { return Integer.class; } public Object toNative() { return new Integer(value); } public boolean equals(Object o) { return o instanceof Custom && ((Custom)o).value == value; } } public void testCallNativeMappedCallback() { final boolean[] called = {false}; final Custom[] cbargs = { null, null}; TestLibrary.CustomCallback cb = new TestLibrary.CustomCallback() { public Custom callback(Custom arg, Custom arg2) { called[0] = true; cbargs[0] = arg; cbargs[1] = arg2; return new Custom(arg.value + arg2.value); } }; int value = lib.callInt32Callback(cb, 1, 2); assertTrue("Callback not called", called[0]); assertEquals("Wrong callback argument 1", new Custom(1), cbargs[0]); assertEquals("Wrong callback argument 2", new Custom(2), cbargs[1]); assertEquals("Wrong NativeMapped return", 3, value); } public void testCallStringCallback() { final boolean[] called = {false}; final String[] cbargs = { null }; TestLibrary.StringCallback cb = new TestLibrary.StringCallback() { public String callback(String arg) { called[0] = true; cbargs[0] = arg; return arg; } }; final String VALUE = "value"; String value = lib.callStringCallback(cb, VALUE); assertTrue("Callback not called", called[0]); assertEquals("Wrong callback argument 1", VALUE, cbargs[0]); assertEquals("Wrong String return", VALUE, value); } public void testStringCallbackMemoryReclamation() throws InterruptedException { TestLibrary.StringCallback cb = new TestLibrary.StringCallback() { public String callback(String arg) { return arg; } }; // A little internal groping Map m = CallbackReference.allocations; String arg = getName() + "1"; String value = lib.callStringCallback(cb, arg); WeakReference ref = new WeakReference(value); arg = null; value = null; System.gc(); for (int i = 0; i < 100 && (ref.get() != null || m.values().size() > 0); ++i) { try { Thread.sleep(10); // Give the GC a chance to run System.gc(); } finally {} } assertNull("String reference not GC'd", ref.get()); assertEquals("NativeString reference still held", 0, m.values().size()); } public void testCallWideStringCallback() { final boolean[] called = {false}; final WString[] cbargs = { null }; TestLibrary.WideStringCallback cb = new TestLibrary.WideStringCallback() { public WString callback(WString arg) { called[0] = true; cbargs[0] = arg; return arg; } }; final WString VALUE = new WString("value"); WString value = lib.callWideStringCallback(cb, VALUE); assertTrue("Callback not called", called[0]); assertEquals("Wrong callback argument 1", VALUE, cbargs[0]); assertEquals("Wrong wide string return", VALUE, value); } public void testCallStringArrayCallback() { final boolean[] called = {false}; final String[][] cbargs = { null }; TestLibrary.StringArrayCallback cb = new TestLibrary.StringArrayCallback() { public String[] callback(String[] arg) { called[0] = true; cbargs[0] = arg; return arg; } }; final String[] VALUE = { "value", null }; Pointer value = lib.callStringArrayCallback(cb, VALUE); assertTrue("Callback not called", called[0]); assertEquals("Wrong callback argument 1", VALUE[0], cbargs[0][0]); String[] result = value.getStringArray(0); assertEquals("Wrong String return", VALUE[0], result[0]); } public void testCallCallbackWithByReferenceArgument() { final boolean[] called = {false}; TestLibrary.CopyArgToByReference cb = new TestLibrary.CopyArgToByReference() { public int callback(int arg, IntByReference result) { called[0] = true; result.setValue(arg); return result.getValue(); } }; final int VALUE = 0; IntByReference ref = new IntByReference(~VALUE); int value = lib.callCallbackWithByReferenceArgument(cb, VALUE, ref); assertEquals("Wrong value returned", VALUE, value); assertEquals("Wrong value in by reference memory", VALUE, ref.getValue()); } public void testCallCallbackWithStructByValue() { final TestStructure.ByValue s = new TestStructure.ByValue(); final TestStructure innerResult = new TestStructure(); TestStructure.TestCallback cb = new TestStructure.TestCallback() { public TestStructure.ByValue callback(TestStructure.ByValue s) { // Copy the argument value for later comparison Pointer old = innerResult.getPointer(); innerResult.useMemory(s.getPointer()); innerResult.read(); innerResult.useMemory(old); innerResult.write(); return s; } }; s.c = (byte)0x11; s.s = 0x2222; s.i = 0x33333333; s.j = 0x4444444444444444L; s.inner.value = 5; TestStructure result = lib.callCallbackWithStructByValue(cb, s); assertEquals("Wrong value passed to callback", s, innerResult); assertEquals("Wrong value for result", s, result); } public void testCallCallbackWithCallbackArgumentAndResult() { TestLibrary.CbCallback cb = new TestLibrary.CbCallback() { public CbCallback callback(CbCallback arg) { return arg; } }; TestLibrary.CbCallback cb2 = lib.callCallbackWithCallback(cb); assertEquals("Callback reference should be reused", cb, cb2); } public void testDefaultCallbackExceptionHandler() { final RuntimeException ERROR = new RuntimeException(getName()); PrintStream ps = System.err; ByteArrayOutputStream s = new ByteArrayOutputStream(); System.setErr(new PrintStream(s)); try { TestLibrary.CbCallback cb = new TestLibrary.CbCallback() { public CbCallback callback(CbCallback arg) { throw ERROR; } }; TestLibrary.CbCallback cb2 = lib.callCallbackWithCallback(cb); String output = s.toString(); assertTrue("Default handler not called", output.length() > 0); } finally { System.setErr(ps); } } /* Most Callbacks are wrapped in DefaultCallbackProxy, which catches their * exceptions. */ public void testCallbackExceptionHandler() { final RuntimeException ERROR = new RuntimeException(getName()); final Throwable CAUGHT[] = { null }; final Callback CALLBACK[] = { null }; UncaughtExceptionHandler old = Native.getCallbackExceptionHandler(); UncaughtExceptionHandler handler = new UncaughtExceptionHandler() { public void uncaughtException(Callback cb, Throwable e) { CALLBACK[0] = cb; CAUGHT[0] = e; } }; Native.setCallbackExceptionHandler(handler); try { TestLibrary.CbCallback cb = new TestLibrary.CbCallback() { public CbCallback callback(CbCallback arg) { throw ERROR; } }; TestLibrary.CbCallback cb2 = lib.callCallbackWithCallback(cb); assertNotNull("Exception handler not called", CALLBACK[0]); assertEquals("Wrong callback argument to handler", cb, CALLBACK[0]); assertEquals("Wrong exception passed to handler", ERROR, CAUGHT[0]); } finally { Native.setCallbackExceptionHandler(old); } } /* CallbackProxy is called directly from native. */ public void testCallbackExceptionHandlerWithCallbackProxy() throws Throwable { final RuntimeException ERROR = new RuntimeException(getName()); final Throwable CAUGHT[] = { null }; final Callback CALLBACK[] = { null }; UncaughtExceptionHandler old = Native.getCallbackExceptionHandler(); UncaughtExceptionHandler handler = new UncaughtExceptionHandler() { public void uncaughtException(Callback cb, Throwable e) { CALLBACK[0] = cb; CAUGHT[0] = e; } }; Native.setCallbackExceptionHandler(handler); try { class TestProxy implements CallbackProxy, TestLibrary.CbCallback { public CbCallback callback(CbCallback arg) { throw new Error("Should never be called"); } public Object callback(Object[] args) { throw ERROR; } public Class[] getParameterTypes() { return new Class[] { CbCallback.class }; } public Class getReturnType() { return CbCallback.class; } }; TestLibrary.CbCallback cb = new TestProxy(); TestLibrary.CbCallback cb2 = lib.callCallbackWithCallback(cb); assertNotNull("Exception handler not called", CALLBACK[0]); assertEquals("Wrong callback argument to handler", cb, CALLBACK[0]); assertEquals("Wrong exception passed to handler", ERROR, CAUGHT[0]); } finally { Native.setCallbackExceptionHandler(old); } } public void testResetCallbackExceptionHandler() { Native.setCallbackExceptionHandler(null); assertNotNull("Should not be able to set callback EH null", Native.getCallbackExceptionHandler()); } public void testInvokeCallback() { TestLibrary.Int32CallbackX cb = lib.returnCallback(); assertNotNull("Callback should not be null", cb); assertEquals("Callback should be callable", 1, cb.callback(1)); TestLibrary.Int32CallbackX cb2 = new TestLibrary.Int32CallbackX() { public int callback(int arg) { return 0; } }; assertSame("Java callback should be looked up", cb2, lib.returnCallbackArgument(cb2)); assertSame("Existing native function wrapper should be reused", cb, lib.returnCallbackArgument(cb)); } public void testCallCallbackInStructure() { final boolean[] flag = {false}; final TestLibrary.CbStruct s = new TestLibrary.CbStruct(); s.cb = new Callback() { public void callback() { flag[0] = true; } }; lib.callCallbackInStruct(s); assertTrue("Callback not invoked", flag[0]); } public void testCustomCallbackMethodName() { final boolean[] called = {false}; TestLibrary.VoidCallbackCustom cb = new TestLibrary.VoidCallbackCustom() { public void customMethodName() { called[0] = true; } public String toString() { return "Some debug output"; } }; lib.callVoidCallback(cb); assertTrue("Callback with custom method name not called", called[0]); } public void testCustomCallbackVariedInheritance() { final boolean[] called = {false}; TestLibrary.VoidCallbackCustom cb = new TestLibrary.VoidCallbackCustomDerived(); lib.callVoidCallback(cb); } public static interface CallbackTestLibrary extends Library { final TypeMapper _MAPPER = new DefaultTypeMapper() { { // Convert java doubles into native integers and back TypeConverter converter = new TypeConverter() { public Object fromNative(Object value, FromNativeContext context) { return new Double(((Integer)value).intValue()); } public Class nativeType() { return Integer.class; } public Object toNative(Object value, ToNativeContext ctx) { return new Integer(((Double)value).intValue()); } }; addTypeConverter(double.class, converter); converter = new TypeConverter() { public Object fromNative(Object value, FromNativeContext context) { return new Float(((Long)value).intValue()); } public Class nativeType() { return Long.class; } public Object toNative(Object value, ToNativeContext ctx) { return new Long(((Float)value).longValue()); } }; addTypeConverter(float.class, converter); } }; final Map _OPTIONS = new HashMap() { { put(Library.OPTION_TYPE_MAPPER, _MAPPER); } }; interface DoubleCallback extends Callback { double callback(double arg, double arg2); } double callInt32Callback(DoubleCallback c, double arg, double arg2); interface FloatCallback extends Callback { float callback(float arg, float arg2); } float callInt64Callback(FloatCallback c, float arg, float arg2); } protected CallbackTestLibrary loadCallbackTestLibrary() { return (CallbackTestLibrary) Native.loadLibrary("testlib", CallbackTestLibrary.class, CallbackTestLibrary._OPTIONS); } /** This test is here instead of NativeTest in order to facilitate running the exact same test on a direct-mapped library without the tests interfering with one another due to persistent/cached state in library loading. */ public void testCallbackUsesTypeMapper() throws Exception { CallbackTestLibrary lib = loadCallbackTestLibrary(); final double[] ARGS = new double[2]; CallbackTestLibrary.DoubleCallback cb = new CallbackTestLibrary.DoubleCallback() { public double callback(double arg, double arg2) { ARGS[0] = arg; ARGS[1] = arg2; return arg + arg2; } }; assertEquals("Wrong type mapper for callback class", lib._MAPPER, Native.getTypeMapper(CallbackTestLibrary.DoubleCallback.class)); assertEquals("Wrong type mapper for callback object", lib._MAPPER, Native.getTypeMapper(cb.getClass())); double result = lib.callInt32Callback(cb, -1, -1); assertEquals("Wrong callback argument 1", -1, ARGS[0], 0); assertEquals("Wrong callback argument 2", -1, ARGS[1], 0); assertEquals("Incorrect result of callback invocation", -2, result, 0); } public void testCallbackUsesTypeMapperWithDifferentReturnTypeSize() throws Exception { CallbackTestLibrary lib = loadCallbackTestLibrary(); final float[] ARGS = new float[2]; CallbackTestLibrary.FloatCallback cb = new CallbackTestLibrary.FloatCallback() { public float callback(float arg, float arg2) { ARGS[0] = arg; ARGS[1] = arg2; return arg + arg2; } }; assertEquals("Wrong type mapper for callback class", lib._MAPPER, Native.getTypeMapper(CallbackTestLibrary.FloatCallback.class)); assertEquals("Wrong type mapper for callback object", lib._MAPPER, Native.getTypeMapper(cb.getClass())); float result = lib.callInt64Callback(cb, -1, -1); assertEquals("Wrong callback argument 1", -1, ARGS[0], 0); assertEquals("Wrong callback argument 2", -1, ARGS[1], 0); assertEquals("Incorrect result of callback invocation", -2, result, 0); } public static void main(java.lang.String[] argList) { junit.textui.TestRunner.run(CallbacksTest.class); } } libjna-java-3.2.7/test/com/sun/jna/PointerTest.java0000644000175000017500000003077111372233154020251 0ustar janjan/* Copyright (c) 2007 Wayne Meissner, 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; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.DoubleBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.LongBuffer; import java.util.Arrays; import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.Map.Entry; import junit.framework.TestCase; public class PointerTest extends TestCase { public void testByteBufferPutString() { final String MAGIC = "magic"; Memory m = new Memory(1024); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); buf.put(MAGIC.getBytes()).put((byte) 0).flip(); assertEquals("String not written to memory", MAGIC, m.getString(0, false)); } public void testByteBufferPutByte() { final byte MAGIC = (byte)0xED; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); buf.put(MAGIC).flip(); assertEquals("Byte not written to memory", MAGIC, m.getByte(0)); } public void testByteBufferPutInt() { final int MAGIC = 0xABEDCF23; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); buf.putInt(MAGIC).flip(); assertEquals("Int not written to memory", MAGIC, m.getInt(0)); } public void testByteBufferPutLong() { final long MAGIC = 0x1234567887654321L; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); buf.putLong(MAGIC).flip(); assertEquals("Long not written to memory", MAGIC, m.getLong(0)); } public void testByteBufferGetByte() { final byte MAGIC = (byte)0xED; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); m.setByte(0, MAGIC); assertEquals("Byte not read from memory", MAGIC, buf.get(0)); } public void testByteBufferGetInt() { final int MAGIC = 0xABEDCF23; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); m.setInt(0, MAGIC); assertEquals("Int not read from memory", MAGIC, buf.getInt(0)); } public void testByteBufferGetLong() { final long MAGIC = 0x1234567887654321L; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); m.setLong(0, MAGIC); assertEquals("Long not read from memory", MAGIC, buf.getLong(0)); } public void testGetNativeLong() { Memory m = new Memory(8); if (NativeLong.SIZE == 4) { final int MAGIC = 0xABEDCF23; m.setInt(0, MAGIC); NativeLong l = m.getNativeLong(0); assertEquals("Native long mismatch", MAGIC, l.intValue()); } else { final long MAGIC = 0x1234567887654321L; m.setLong(0, MAGIC); NativeLong l = m.getNativeLong(0); assertEquals("Native long mismatch", MAGIC, l.longValue()); } } public void testSetNativeLong() { Memory m = new Memory(8); if (NativeLong.SIZE == 4) { final int MAGIC = 0xABEDCF23; m.setNativeLong(0, new NativeLong(MAGIC)); assertEquals("Native long mismatch", MAGIC, m.getInt(0)); } else { final long MAGIC = 0x1234567887654321L; m.setNativeLong(0, new NativeLong(MAGIC)); assertEquals("Native long mismatch", MAGIC, m.getLong(0)); } } public void testIntBufferPut() { final int MAGIC = 0xABEDCF23; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); IntBuffer ib = buf.asIntBuffer(); ib.put(MAGIC).flip(); assertEquals("Int not written to memory", MAGIC, m.getInt(0)); } public void testLongBufferPut() { final long MAGIC = 0x1234567887654321L; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); LongBuffer lb = buf.asLongBuffer(); lb.put(MAGIC).flip(); assertEquals("Long not written to memory", MAGIC, m.getLong(0)); } public void testFloatBufferPut() { final float MAGIC = 1234.5678f; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); FloatBuffer fb = buf.asFloatBuffer(); fb.put(MAGIC).flip(); assertEquals("Int not written to memory", MAGIC, m.getFloat(0)); } public void testDoubleBufferPut() { final double MAGIC = 1234.5678; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); DoubleBuffer db = buf.asDoubleBuffer(); db.put(MAGIC).flip(); assertEquals("Int not written to memory", MAGIC, m.getDouble(0)); } public void testIntBufferGet() { final int MAGIC = 0xABEDCF23; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); IntBuffer ib = buf.asIntBuffer(); m.setInt(0, MAGIC); assertEquals("Int not read from memory", MAGIC, ib.get(0)); } public void testLongBufferGet() { final long MAGIC = 0x1234567887654321L; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); LongBuffer lb = buf.asLongBuffer(); m.setLong(0, MAGIC); assertEquals("Long not read from memory", MAGIC, lb.get(0)); } public void testFloatBufferGet() { final float MAGIC = 1234.5678f; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); FloatBuffer fb = buf.asFloatBuffer(); m.setFloat(0, MAGIC); assertEquals("Float not read from memory", MAGIC, fb.get(0)); } public void testDoubleBufferGet() { final double MAGIC = 1234.5678; Memory m = new Memory(8); ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder()); DoubleBuffer db = buf.asDoubleBuffer(); m.setDouble(0, MAGIC); assertEquals("Double not read from memory", MAGIC, db.get(0)); } public void testSetStringWithEncoding() throws Exception { String old = System.getProperty("jna.encoding"); String VALUE = "\u0444\u0438\u0441\u0432\u0443"; System.setProperty("jna.encoding", "UTF8"); try { int size = VALUE.getBytes("UTF8").length+1; Memory m = new Memory(size); m.setString(0, VALUE); assertEquals("UTF8 encoding should be double", VALUE.length() * 2 + 1, size); assertEquals("Wrong decoded value", VALUE, m.getString(0)); } finally { if (old != null) { System.setProperty("jna.encoding", old); } else { Map props = System.getProperties(); props.remove("jna.encoding"); Properties newProps = new Properties(); for (Iterator i = props.entrySet().iterator();i.hasNext();) { Entry e = (Entry)i.next(); newProps.setProperty(e.getKey().toString(), e.getValue().toString()); } System.setProperties(newProps); } } } public void testDirectBufferPointer() throws Exception { Pointer p = new Memory(1024); ByteBuffer b = p.getByteBuffer(0, 1024); assertEquals("ByteBuffer Pointer does not match", p, Native.getDirectBufferPointer(b)); assertEquals("ShortBuffer Pointer does not match", p, Native.getDirectBufferPointer(b.asShortBuffer())); assertEquals("IntBuffer Pointer does not match", p, Native.getDirectBufferPointer(b.asIntBuffer())); assertEquals("LongBuffer Pointer does not match", p, Native.getDirectBufferPointer(b.asLongBuffer())); assertEquals("FloatBuffer Pointer does not match", p, Native.getDirectBufferPointer(b.asFloatBuffer())); assertEquals("DoubleBuffer Pointer does not match", p, Native.getDirectBufferPointer(b.asDoubleBuffer())); assertEquals("Wrong direct buffer address", p, Native.getDirectBufferPointer(b)); } public static class TestPointerType extends PointerType { public TestPointerType() { } public TestPointerType(Pointer p) { super(p); } } public void testSetNativeMapped() { Pointer p = new Memory(Pointer.SIZE); TestPointerType tp = new TestPointerType(p); p.setValue(0, tp, tp.getClass()); assertEquals("Wrong value written", p, p.getPointer(0)); } public void testGetNativeMapped() { Pointer p = new Memory(Pointer.SIZE); p.setPointer(0, null); Object o = p.getValue(0, TestPointerType.class, null); assertNull("Wrong empty value: " + o, o); p.setPointer(0, p); TestPointerType tp = new TestPointerType(p); assertEquals("Wrong value", tp, p.getValue(0, TestPointerType.class, null)); } public void testGetStringArray() { Pointer p = new Memory(Pointer.SIZE*3); String VALUE1 = getName(); String VALUE2 = getName() + "2"; p.setPointer(0, new NativeString(VALUE1).getPointer()); p.setPointer(Pointer.SIZE, new NativeString(VALUE2).getPointer()); p.setPointer(Pointer.SIZE*2, null); assertEquals("Wrong null-terminated String array", Arrays.asList(new String[] { VALUE1, VALUE2 }), Arrays.asList(p.getStringArray(0))); assertEquals("Wrong length-specified String array (1)", Arrays.asList(new String[] { VALUE1 }), Arrays.asList(p.getStringArray(0, 1))); assertEquals("Wrong length-specified String array (2)", Arrays.asList(new String[] { VALUE1, VALUE2 }), Arrays.asList(p.getStringArray(0, 2))); } public void testReadPointerArray() { Pointer mem = new Memory(Pointer.SIZE * 2); Pointer[] p = new Pointer[2]; String VALUE1 = getName(); p[0] = new NativeString(VALUE1).getPointer(); p[1] = new Memory(1024); Pointer[] orig = new Pointer[p.length]; System.arraycopy(p, 0, orig, 0, p.length); mem.write(0, p, 0, p.length); mem.read(0, p, 0, p.length); assertSame("Pointer object not preserved[0]", orig[0], p[0]); assertSame("Pointer object not preserved[1]", orig[1], p[1]); mem.setPointer(0, null); mem.setPointer(Pointer.SIZE, new Memory(1024)); mem.read(0, p, 0, p.length); assertNull("Pointer element not updated[0]", p[0]); assertNotSame("Pointer element not updated[1]", orig[1], p[1]); } public void testCreateConstantPointer() { Pointer p = Pointer.createConstant(0xFFFFFFFF); assertEquals("Wrong peer value", p.peer, 0xFFFFFFFF); p = Pointer.createConstant(-1); assertEquals("Wrong peer value", p.peer, -1); } public void testReadStringArrayNULLElement() { Memory m = new Memory(Pointer.SIZE); m.clear(); String[] arr = m.getStringArray(0, 1); assertEquals("Wrong array size", 1, arr.length); assertNull("Array element should be null", arr[0]); } public static void main(String[] args) { junit.textui.TestRunner.run(PointerTest.class); } } libjna-java-3.2.7/test/com/sun/jna/ArgumentsMarshalTest.java0000644000175000017500000007202111372233154022100 0ustar janjan/* 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. *

* 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; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.DoubleBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.LongBuffer; import java.nio.ShortBuffer; import java.util.Arrays; import com.sun.jna.ArgumentsMarshalTest.TestLibrary.CheckFieldAlignment; import junit.framework.TestCase; /** Exercise a range of native methods. * * @author twall@users.sf.net */ @SuppressWarnings("unused") public class ArgumentsMarshalTest extends TestCase { public static interface TestLibrary extends Library { class CheckFieldAlignment extends Structure { public static class ByValue extends CheckFieldAlignment implements Structure.ByValue { } public static class ByReference extends CheckFieldAlignment implements Structure.ByReference { } public byte int8Field = 1; public short int16Field = 2; public int int32Field = 3; public long int64Field = 4; public float floatField = 5f; public double doubleField = 6d; } String returnStringArgument(Object arg); boolean returnBooleanArgument(boolean arg); byte returnInt8Argument(byte arg); char returnWideCharArgument(char arg); short returnInt16Argument(short arg); int returnInt32Argument(int i); long returnInt64Argument(long l); NativeLong returnLongArgument(NativeLong l); float returnFloatArgument(float f); double returnDoubleArgument(double d); String returnStringArgument(String s); WString returnWStringArgument(WString s); Pointer returnPointerArgument(Pointer p); String returnStringArrayElement(String[] args, int which); WString returnWideStringArrayElement(WString[] args, int which); Pointer returnPointerArrayElement(Pointer[] args, int which); public static class TestPointerType extends PointerType { public TestPointerType() { } public TestPointerType(Pointer p) { super(p); } } TestPointerType returnPointerArrayElement(TestPointerType[] args, int which); CheckFieldAlignment returnPointerArrayElement(CheckFieldAlignment.ByReference[] args, int which); int returnRotatedArgumentCount(String[] args); long checkInt64ArgumentAlignment(int i, long j, int i2, long j2); double checkDoubleArgumentAlignment(float i, double j, float i2, double j2); Pointer testStructurePointerArgument(CheckFieldAlignment p); double testStructureByValueArgument(CheckFieldAlignment.ByValue p); int testStructureArrayInitialization(CheckFieldAlignment[] p, int len); void modifyStructureArray(CheckFieldAlignment[] p, int length); int fillInt8Buffer(byte[] buf, int len, byte value); int fillInt16Buffer(short[] buf, int len, short value); int fillInt32Buffer(int[] buf, int len, int value); int fillInt64Buffer(long[] buf, int len, long value); int fillFloatBuffer(float[] buf, int len, float value); int fillDoubleBuffer(double[] buf, int len, double value); // ByteBuffer alternative definitions int fillInt8Buffer(ByteBuffer buf, int len, byte value); int fillInt16Buffer(ByteBuffer buf, int len, short value); int fillInt32Buffer(ByteBuffer buf, int len, int value); int fillInt64Buffer(ByteBuffer buf, int len, long value); int fillFloatBuffer(ByteBuffer buf, int len, float value); int fillDoubleBuffer(ByteBuffer buf, int len, double value); // {Short|Int|Long|,Float|Double}Buffer alternative definitions int fillInt16Buffer(ShortBuffer buf, int len, short value); int fillInt32Buffer(IntBuffer buf, int len, int value); int fillInt64Buffer(LongBuffer buf, int len, long value); int fillFloatBuffer(FloatBuffer buf, int len, float value); int fillDoubleBuffer(DoubleBuffer buf, int len, double value); // Nonexistent functions boolean returnBooleanArgument(Object arg); // Structure class MinTestStructure extends Structure { public int field; } Pointer testStructurePointerArgument(MinTestStructure s); class VariableSizedStructure extends Structure { public int length; public byte[] buffer; public VariableSizedStructure(String arg) { length = arg.length() + 1; buffer = new byte[length]; System.arraycopy(arg.getBytes(), 0, buffer, 0, arg.length()); } } String returnStringFromVariableSizedStructure(VariableSizedStructure s); class CbStruct extends Structure { public static interface TestCallback extends Callback { int callback(int arg1, int arg2); } public TestCallback cb; } void setCallbackInStruct(CbStruct cbstruct); // Union (by value) class TestUnion extends Union implements Structure.ByValue { public String f1; public int f2; } interface UnionCallback extends Callback { TestUnion invoke(TestUnion arg); } TestUnion testUnionByValueCallbackArgument(UnionCallback cb, TestUnion arg); } TestLibrary lib; protected void setUp() { lib = (TestLibrary)Native.loadLibrary("testlib", TestLibrary.class); } protected void tearDown() { lib = null; } public void testJavaObjectArgument() { Object o = this; try { lib.returnStringArgument(o); fail("Java Object arguments should throw IllegalArgumentException"); } catch(IllegalArgumentException e) { assertTrue("Exception should include Object type description: " + e, e.getMessage().indexOf(o.getClass().getName()) != -1); } catch(Throwable e) { fail("Java Object arguments should throw IllegalArgumentException, not " + e); } } public void testBooleanArgument() { assertTrue("True argument should be returned", lib.returnBooleanArgument(true)); assertFalse("False argument should be returned", lib.returnBooleanArgument(false)); } public void testInt8Argument() { byte b = 0; assertEquals("Wrong value returned", b, lib.returnInt8Argument(b)); b = 127; assertEquals("Wrong value returned", b, lib.returnInt8Argument(b)); b = -128; assertEquals("Wrong value returned", b, lib.returnInt8Argument(b)); } public void testWideCharArgument() { char c = 0; assertEquals("Wrong value returned", c, lib.returnWideCharArgument(c)); c = 0xFFFF; assertEquals("Wrong value returned", c, lib.returnWideCharArgument(c)); c = 0x7FFF; assertEquals("Wrong value returned", c, lib.returnWideCharArgument(c)); } public void testInt16Argument() { short v = 0; assertEquals("Wrong value returned", v, lib.returnInt16Argument(v)); v = 32767; assertEquals("Wrong value returned", v, lib.returnInt16Argument(v)); v = -32768; assertEquals("Wrong value returned", v, lib.returnInt16Argument(v)); } public void testIntArgument() { int value = 0; assertEquals("Should return 32-bit argument", value, lib.returnInt32Argument(value)); value = 1; assertEquals("Should return 32-bit argument", value, lib.returnInt32Argument(value)); value = 0x7FFFFFFF; assertEquals("Should return 32-bit argument", value, lib.returnInt32Argument(value)); value = 0x80000000; assertEquals("Should return 32-bit argument", value, lib.returnInt32Argument(value)); } public void testLongArgument() { long value = 0L; assertEquals("Should return 64-bit argument", value, lib.returnInt64Argument(value)); value = 1L; assertEquals("Should return 64-bit argument", value, lib.returnInt64Argument(value)); value = 0x7FFFFFFFL; assertEquals("Should return 64-bit argument", value, lib.returnInt64Argument(value)); value = 0x80000000L; assertEquals("Should return 64-bit argument", value, lib.returnInt64Argument(value)); value = 0x7FFFFFFF00000000L; assertEquals("Should return 64-bit argument", value, lib.returnInt64Argument(value)); value = 0x8000000000000000L; assertEquals("Should return 64-bit argument", value, lib.returnInt64Argument(value)); } public void testNativeLongArgument() { NativeLong value = new NativeLong(0); assertEquals("Should return 0", value, lib.returnLongArgument(value)); value = new NativeLong(1); assertEquals("Should return 1", value, lib.returnLongArgument(value)); value = new NativeLong(0x7FFFFFFF); assertEquals("Should return 0x7FFFFFFF", value, lib.returnLongArgument(value)); value = new NativeLong(0x80000000); assertEquals("Should return 0x80000000", value, lib.returnLongArgument(value)); } public interface NativeMappedLibrary extends Library { int returnInt32Argument(Custom arg); } public static class Custom implements NativeMapped { private int value; public Custom() { } public Custom(int value) { this.value = value; } public Object fromNative(Object nativeValue, FromNativeContext context) { return new Custom(((Integer)nativeValue).intValue()); } public Class nativeType() { return Integer.class; } public Object toNative() { return new Integer(value); } } protected NativeMappedLibrary loadNativeMappedLibrary() { return (NativeMappedLibrary) Native.loadLibrary("testlib", NativeMappedLibrary.class); } public void testNativeMappedArgument() { NativeMappedLibrary lib = loadNativeMappedLibrary(); final int MAGIC = 0x12345678; Custom arg = new Custom(MAGIC); assertEquals("Argument not mapped", MAGIC, lib.returnInt32Argument(arg)); } public void testPointerArgumentReturn() { assertEquals("Expect null pointer", null, lib.returnPointerArgument(null)); Structure s = new TestLibrary.CheckFieldAlignment(); assertEquals("Expect structure pointer", s.getPointer(), lib.returnPointerArgument(s.getPointer())); } static final String MAGIC = "magic"; public void testStringArgumentReturn() { assertEquals("Expect null pointer", null, lib.returnStringArgument(null)); assertEquals("Expect string magic", MAGIC, lib.returnStringArgument(MAGIC)); } public void testWStringArgumentReturn() { assertEquals("Expect null pointer", null, lib.returnStringArgument(null)); assertEquals("Expect string magic", MAGIC, lib.returnStringArgument(MAGIC).toString()); } public void testInt64ArgumentAlignment() { long value = lib.checkInt64ArgumentAlignment(0x10101010, 0x1111111111111111L, 0x01010101, 0x2222222222222222L); assertEquals("Improper handling of interspersed int32/int64", 0x3333333344444444L, value); } public void testDoubleArgumentAlignment() { double value = lib.checkDoubleArgumentAlignment(1f, 2d, 3f, 4d); assertEquals("Improper handling of interspersed float/double", 10d, value, 0); } public void testStructurePointerArgument() { TestLibrary.CheckFieldAlignment struct = new TestLibrary.CheckFieldAlignment(); assertEquals("Native address of structure should be returned", struct.getPointer(), lib.testStructurePointerArgument(struct)); // ensure that even if the argument is ByValue, it's passed as ptr struct = new TestLibrary.CheckFieldAlignment.ByValue(); assertEquals("Structure argument should be passed according to method " + "parameter type, not argument type", struct.getPointer(), lib.testStructurePointerArgument(struct)); struct = null; assertNull("Null argument should be returned", lib.testStructurePointerArgument(struct)); } public void testStructureByValueArgument() { TestLibrary.CheckFieldAlignment.ByValue struct = new TestLibrary.CheckFieldAlignment.ByValue(); assertEquals("Wrong sum of fields", 21d, lib.testStructureByValueArgument(struct)); } public void testStructureByValueTypeInfo() { class TestStructure extends Structure implements Structure.ByValue { public byte b; public char c; public short s; public int i; public long j; public float f; public double d; public Pointer[] parray = new Pointer[2]; public byte[] barray = new byte[2]; } Structure s = new TestStructure(); // Force generation of type info s.size(); } public void testWriteStructureArrayArgumentMemory() { final int LENGTH = 10; TestLibrary.CheckFieldAlignment block = new TestLibrary.CheckFieldAlignment(); TestLibrary.CheckFieldAlignment[] array = (TestLibrary.CheckFieldAlignment[])block.toArray(LENGTH); for (int i=0;i < array.length;i++) { array[i].int32Field = i; } assertEquals("Structure array memory not properly initialized", -1, lib.testStructureArrayInitialization(array, array.length)); } public void testUninitializedStructureArrayArgument() { final int LENGTH = 10; TestLibrary.CheckFieldAlignment[] block = new TestLibrary.CheckFieldAlignment[LENGTH]; lib.modifyStructureArray(block, block.length); for (int i=0;i < block.length;i++) { assertNotNull("Structure array not initialized at " + i, block[i]); assertEquals("Wrong value for int32 field of structure at " + i, i, block[i].int32Field); assertEquals("Wrong value for int64 field of structure at " + i, i + 1, block[i].int64Field); assertEquals("Wrong value for float field of structure at " + i, i + 2, block[i].floatField, 0); assertEquals("Wrong value for double field of structure at " + i, i + 3, block[i].doubleField, 0); } } public void testRejectNoncontiguousStructureArrayArgument() { TestLibrary.CheckFieldAlignment s1, s2, s3; s3 = new TestLibrary.CheckFieldAlignment(); s1 = new TestLibrary.CheckFieldAlignment(); s2 = new TestLibrary.CheckFieldAlignment(); TestLibrary.CheckFieldAlignment[] block = { s1, s2, s3 }; try { lib.modifyStructureArray(block, block.length); fail("Library invocation should fail"); } catch(IllegalArgumentException e) { } } public void testByteArrayArgument() { byte[] buf = new byte[1024]; final byte MAGIC = (byte)0xED; assertEquals("Wrong return value", buf.length, lib.fillInt8Buffer(buf, buf.length, MAGIC)); for (int i=0;i < buf.length;i++) { assertEquals("Bad value at index " + i, MAGIC, buf[i]); } } public void testShortArrayArgument() { short[] buf = new short[1024]; final short MAGIC = (short)0xABED; assertEquals("Wrong return value", buf.length, lib.fillInt16Buffer(buf, buf.length, MAGIC)); for (int i=0;i < buf.length;i++) { assertEquals("Bad value at index " + i, MAGIC, buf[i]); } } public void testIntArrayArgument() { int[] buf = new int[1024]; final int MAGIC = 0xABEDCF23; assertEquals("Wrong return value", buf.length, lib.fillInt32Buffer(buf, buf.length, MAGIC)); for (int i=0;i < buf.length;i++) { assertEquals("Bad value at index " + i, MAGIC, buf[i]); } } public void testLongArrayArgument() { long[] buf = new long[1024]; final long MAGIC = 0x1234567887654321L; assertEquals("Wrong return value", buf.length, lib.fillInt64Buffer(buf, buf.length, MAGIC)); for (int i=0;i < buf.length;i++) { assertEquals("Bad value at index " + i, MAGIC, buf[i]); } } public void testByteBufferArgument() { ByteBuffer buf = ByteBuffer.allocate(1024).order(ByteOrder.nativeOrder()); final byte MAGIC = (byte)0xED; lib.fillInt8Buffer(buf, 1024, MAGIC); for (int i=0;i < buf.capacity();i++) { assertEquals("Bad value at index " + i, MAGIC, buf.get(i)); } } public void testShortBufferArgument() { ShortBuffer buf = ShortBuffer.allocate(1024); final short MAGIC = (short)0xABED; lib.fillInt16Buffer(buf, 1024, MAGIC); for (int i=0;i < buf.capacity();i++) { assertEquals("Bad value at index " + i, MAGIC, buf.get(i)); } } public void testIntBufferArgument() { IntBuffer buf = IntBuffer.allocate(1024); final int MAGIC = 0xABEDCF23; lib.fillInt32Buffer(buf, 1024, MAGIC); for (int i=0;i < buf.capacity();i++) { assertEquals("Bad value at index " + i, MAGIC, buf.get(i)); } } public void testLongBufferArgument() { LongBuffer buf = LongBuffer.allocate(1024); final long MAGIC = 0x1234567887654321L; lib.fillInt64Buffer(buf, 1024, MAGIC); for (int i=0;i < buf.capacity();i++) { assertEquals("Bad value at index " + i, MAGIC, buf.get(i)); } } public void testDirectByteBufferArgument() { ByteBuffer buf = ByteBuffer.allocateDirect(1024).order(ByteOrder.nativeOrder()); final byte MAGIC = (byte)0xED; lib.fillInt8Buffer(buf, 1024, MAGIC); for (int i=0;i < buf.capacity();i++) { assertEquals("Bad value at index " + i, MAGIC, buf.get(i)); } } public void testDirectShortBufferArgument() { ByteBuffer buf = ByteBuffer.allocateDirect(1024*2).order(ByteOrder.nativeOrder()); ShortBuffer shortBuf = buf.asShortBuffer(); final short MAGIC = (short)0xABED; lib.fillInt16Buffer(shortBuf, 1024, MAGIC); for (int i=0;i < shortBuf.capacity();i++) { assertEquals("Bad value at index " + i, MAGIC, shortBuf.get(i)); } } public void testDirectIntBufferArgument() { ByteBuffer buf = ByteBuffer.allocateDirect(1024*4).order(ByteOrder.nativeOrder()); IntBuffer intBuf = buf.asIntBuffer(); final int MAGIC = 0xABEDCF23; lib.fillInt32Buffer(intBuf, 1024, MAGIC); for (int i=0;i < intBuf.capacity();i++) { assertEquals("Bad value at index " + i, MAGIC, intBuf.get(i)); } } public void testDirectLongBufferArgument() { ByteBuffer buf = ByteBuffer.allocateDirect(1024*8).order(ByteOrder.nativeOrder()); LongBuffer longBuf = buf.asLongBuffer(); final long MAGIC = 0x1234567887654321L; lib.fillInt64Buffer(longBuf, 1024, MAGIC); for (int i=0;i < longBuf.capacity();i++) { assertEquals("Bad value at index " + i, MAGIC, longBuf.get(i)); } } public void testWrappedByteArrayArgument() { byte[] array = new byte[1024]; ByteBuffer buf = ByteBuffer.wrap(array, 512, 512).slice(); final byte MAGIC = (byte)0xAB; lib.fillInt8Buffer(buf, 512, MAGIC); for (int i=0;i < array.length;i++) { assertEquals("Bad value at index " + i, i < 512 ? 0 : MAGIC, array[i]); } } public void testWrappedShortArrayArgument() { short[] array = new short[1024]; ShortBuffer buf = ShortBuffer.wrap(array, 512, 512).slice(); final short MAGIC = (short)0xABED; lib.fillInt16Buffer(buf, 512, MAGIC); for (int i=0;i < array.length;i++) { assertEquals("Bad value at index " + i, i < 512 ? 0 : MAGIC, array[i]); } } public void testWrappedIntArrayArgument() { int[] array = new int[1024]; IntBuffer buf = IntBuffer.wrap(array, 512, 512).slice(); final int MAGIC = 0xABEDCF23; lib.fillInt32Buffer(buf, 512, MAGIC); for (int i=0;i < array.length;i++) { assertEquals("Bad value at index " + i, i < 512 ? 0 : MAGIC, array[i]); } } public void testWrappedLongArrayArguent() { long[] array = new long[1024]; LongBuffer buf = LongBuffer.wrap(array, 512, 512).slice(); final long MAGIC = 0x1234567887654321L; lib.fillInt64Buffer(buf, 512, MAGIC); for (int i=0;i < array.length;i++) { assertEquals("Bad value at index " + i, i < 512 ? 0 : MAGIC, array[i]); } } public void testWrappedFloatArrayArguent() { float[] array = new float[1024]; FloatBuffer buf = FloatBuffer.wrap(array, 512, 512).slice(); final float MAGIC = -118.625f; lib.fillFloatBuffer(buf, 512, MAGIC); for (int i=0;i < array.length;i++) { assertEquals("Bad value at index " + i, i < 512 ? 0 : MAGIC, array[i]); } } public void testWrappedDoubleArrayArguent() { double[] array = new double[1024]; DoubleBuffer buf = DoubleBuffer.wrap(array, 512, 512).slice(); final double MAGIC = -118.625; lib.fillDoubleBuffer(buf, 512, MAGIC); for (int i=0;i < array.length;i++) { assertEquals("Bad value at index " + i, i < 512 ? 0 : MAGIC, array[i]); } } public void testInvalidArgument() { try { lib.returnBooleanArgument(this); fail("Unsupported Java objects should be rejected"); } catch(IllegalArgumentException e) { } } public void testStringArrayArgument() { String[] args = { "one", "two", "three" }; assertEquals("Wrong value returned", args[0], lib.returnStringArrayElement(args, 0)); assertNull("Native String array should be null terminated", lib.returnStringArrayElement(args, args.length)); } public void testWideStringArrayArgument() { WString[] args = { new WString("one"), new WString("two"), new WString("three") }; assertEquals("Wrong value returned", args[0], lib.returnWideStringArrayElement(args, 0)); assertNull("Native WString array should be null terminated", lib.returnWideStringArrayElement(args, args.length)); } public void testPointerArrayArgument() { Pointer[] args = { new NativeString(getName()).getPointer(), null, new NativeString(getName()+"2").getPointer(), }; Pointer[] originals = new Pointer[args.length]; System.arraycopy(args, 0, originals, 0, args.length); assertEquals("Wrong value returned", args[0], lib.returnPointerArrayElement(args, 0)); assertNull("Wrong value returned", lib.returnPointerArrayElement(args, 1)); assertEquals("Wrong value returned", args[2], lib.returnPointerArrayElement(args, 2)); assertNull("Native array should be null terminated", lib.returnPointerArrayElement(args, 3)); assertSame("Argument pointers should remain unmodified [0]", originals[0], args[0]); assertSame("Argument pointers should remain unmodified [2]", originals[2], args[2]); } public void testNativeMappedArrayArgument() { TestLibrary.TestPointerType[] args = { new TestLibrary.TestPointerType(new NativeString(getName()).getPointer()), null, new TestLibrary.TestPointerType(new NativeString(getName()+"2").getPointer()), }; assertEquals("Wrong value returned", args[0], lib.returnPointerArrayElement(args, 0)); assertNull("Wrong value returned", lib.returnPointerArrayElement(args, 1)); assertEquals("Wrong value returned", args[2], lib.returnPointerArrayElement(args, 2)); }; public void testStructureByReferenceArrayArgument() { CheckFieldAlignment.ByReference[] args = { new CheckFieldAlignment.ByReference(), null, new CheckFieldAlignment.ByReference(), }; assertEquals("Wrong value returned (0)", args[0], lib.returnPointerArrayElement(args, 0)); assertNull("Wrong value returned (1)", lib.returnPointerArrayElement(args, 1)); assertEquals("Wrong value returned (2)", args[2], lib.returnPointerArrayElement(args, 2)); assertNull("Native array should be null terminated", lib.returnPointerArrayElement(args, 3)); } public void testModifiedCharArrayArgument() { String[] args = { "one", "two", "three" }; assertEquals("Wrong native array count", args.length, lib.returnRotatedArgumentCount(args)); assertEquals("Modified array argument not re-read", Arrays.asList(new String[] { "two", "three", "one" }), Arrays.asList(args)); } public void testReadFunctionPointerAsCallback() { TestLibrary.CbStruct s = new TestLibrary.CbStruct(); assertNull("Function pointer field should be null", s.cb); lib.setCallbackInStruct(s); assertNotNull("Callback field not set", s.cb); } public void testCallProxiedFunctionPointer() { TestLibrary.CbStruct s = new TestLibrary.CbStruct(); lib.setCallbackInStruct(s); assertEquals("Proxy to native function pointer failed: " + s.cb, 3, s.cb.callback(1, 2)); } public void testVariableSizedStructureArgument() { String EXPECTED = getName(); TestLibrary.VariableSizedStructure s = new TestLibrary.VariableSizedStructure(EXPECTED); assertEquals("Wrong string returned from variable sized struct", EXPECTED, lib.returnStringFromVariableSizedStructure(s)); } public void testDisableAutoSynch() { TestLibrary.MinTestStructure s = new TestLibrary.MinTestStructure(); final int VALUE = 42; s.field = VALUE; s.setAutoWrite(false); lib.testStructurePointerArgument(s); assertEquals("Auto write should be disabled", 0, s.field); final int EXPECTED = s.field; s.getPointer().setInt(0, VALUE); s.setAutoRead(false); lib.testStructurePointerArgument(s); assertEquals("Auto read should be disabled", EXPECTED, s.field); } public void testUnionByValueCallbackArgument() throws Exception{ TestLibrary.TestUnion arg = new TestLibrary.TestUnion(); arg.setType(String.class); final String VALUE = getName(); arg.f1 = VALUE; final boolean[] called = { false }; final String[] cbvalue = { null }; TestLibrary.TestUnion result = lib.testUnionByValueCallbackArgument(new TestLibrary.UnionCallback() { public TestLibrary.TestUnion invoke(TestLibrary.TestUnion v) { called[0] = true; v.setType(String.class); v.read(); cbvalue[0] = v.f1; return v; } }, arg); assertTrue("Callback not called", called[0]); assertEquals("Incorrect callback union argument", VALUE, cbvalue[0]); assertEquals("Union value not propagated", VALUE, result.getTypedValue(String.class)); } public static void main(java.lang.String[] argList) { junit.textui.TestRunner.run(ArgumentsMarshalTest.class); } } libjna-java-3.2.7/native/0000755000175000017500000000000011421526312013266 5ustar janjanlibjna-java-3.2.7/native/README.libffi0000644000175000017500000000024411372233170015402 0ustar janjan--- libffi notes --- All JNA customizations to date have been merged to upstream libffi. This source tree has been synched to http://github.com/atgreen/libffi. libjna-java-3.2.7/native/dispatch.c0000644000175000017500000027451711421002534015244 0ustar janjan/* * @(#)dispatch.c 1.9 98/03/22 * * Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2007-2009 Timothy Wall. All Rights Reserved. * Copyright (c) 2007 Wayne Meissner. 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. */ /* * JNI native methods supporting the infrastructure for shared * dispatchers. */ #if defined(_WIN32) #ifdef _MSC_VER #pragma warning( disable : 4201 ) /* nameless struct/union (jni_md.h) */ #endif #ifndef UNICODE #define UNICODE #endif #define WIN32_LEAN_AND_MEAN #include #include #define LIBNAMETYPE wchar_t* #define LIBNAME2CSTR(ENV,JSTR) newWideCString(ENV,JSTR) /* See http://msdn.microsoft.com/en-us/library/ms682586(VS.85).aspx: * "Note that the standard search strategy and the alternate search strategy * specified by LoadLibraryEx with LOAD_WITH_ALTERED_SEARCH_PATH differ in * just one way: The standard search begins in the calling application's * directory, and the alternate search begins in the directory of the * executable module that LoadLibraryEx is loading." */ #define LOAD_LIBRARY(NAME) (NAME ? LoadLibraryExW(NAME, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) : GetModuleHandleW(NULL)) #define LOAD_ERROR(BUF,LEN) w32_format_error(BUF, LEN) #define FREE_LIBRARY(HANDLE) (((HANDLE)==GetModuleHandleW(NULL) || FreeLibrary(HANDLE))?0:-1) #define FIND_ENTRY(HANDLE, NAME) GetProcAddress(HANDLE, NAME) #define GET_LAST_ERROR() GetLastError() #define SET_LAST_ERROR(CODE) SetLastError(CODE) static char* w32_format_error(char* buf, int len) { FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buf, len, NULL); return buf; } #else #include #include #define LIBNAMETYPE char* #ifdef __APPLE__ #define LIBNAME2CSTR(ENV,JSTR) newCStringUTF8(ENV,JSTR) #else #define LIBNAME2CSTR(ENV,JSTR) newCString(ENV,JSTR) #endif #define LOAD_LIBRARY(NAME) dlopen(NAME, RTLD_LAZY|RTLD_GLOBAL) #define LOAD_ERROR(BUF,LEN) (snprintf(BUF, LEN, "%s", dlerror()), BUF) #define FREE_LIBRARY(HANDLE) dlclose(HANDLE) #define FIND_ENTRY(HANDLE, NAME) dlsym(HANDLE, NAME) #define GET_LAST_ERROR() errno #define SET_LAST_ERROR(CODE) (errno = (CODE)) #endif #include #include #include #include #include #include #include "dispatch.h" #include "com_sun_jna_Pointer.h" #include "com_sun_jna_Memory.h" #include "com_sun_jna_Function.h" #include "com_sun_jna_Native.h" #include "com_sun_jna_NativeLibrary.h" #include "com_sun_jna_CallbackReference.h" #ifdef HAVE_PROTECTION static int _protect; #undef PROTECT #define PROTECT _protect #endif #ifdef __cplusplus extern "C" #endif static jboolean preserve_last_error; #define MEMCPY(D,S,L) do { \ PSTART(); memcpy(D,S,L); PEND(); \ } while(0) #define MEMSET(D,C,L) do { \ PSTART(); memset(D,C,L); PEND(); \ } while(0) #define MASK_CC com_sun_jna_Function_MASK_CC #define THROW_LAST_ERROR com_sun_jna_Function_THROW_LAST_ERROR /* Cached class, field and method IDs */ static jclass classObject; static jclass classClass; static jclass classMethod; static jclass classVoid, classPrimitiveVoid; static jclass classBoolean, classPrimitiveBoolean; static jclass classByte, classPrimitiveByte; static jclass classCharacter, classPrimitiveCharacter; static jclass classShort, classPrimitiveShort; static jclass classInteger, classPrimitiveInteger; static jclass classLong, classPrimitiveLong; static jclass classFloat, classPrimitiveFloat; static jclass classDouble, classPrimitiveDouble; static jclass classString, classWString; static jclass classBuffer; static jclass classByteBuffer; static jclass classCharBuffer; static jclass classShortBuffer; static jclass classIntBuffer; static jclass classLongBuffer; static jclass classFloatBuffer; static jclass classDoubleBuffer; static jclass classPointer; static jclass classNative; static jclass classStructure; static jclass classStructureByValue; static jclass classCallback; static jclass classCallbackReference; static jclass classNativeMapped; static jclass classIntegerType; static jclass classPointerType; static jclass class_ffi_callback; static jmethodID MID_Class_getComponentType; static jmethodID MID_Object_toString; static jmethodID MID_String_getBytes; static jmethodID MID_String_getBytes2; static jmethodID MID_String_toCharArray; static jmethodID MID_String_init_bytes; static jmethodID MID_Method_getReturnType; static jmethodID MID_Method_getParameterTypes; static jmethodID MID_Long_init; static jmethodID MID_Integer_init; static jmethodID MID_Short_init; static jmethodID MID_Character_init; static jmethodID MID_Byte_init; static jmethodID MID_Boolean_init; static jmethodID MID_Float_init; static jmethodID MID_Double_init; static jmethodID MID_ByteBuffer_array; static jmethodID MID_ByteBuffer_arrayOffset; static jmethodID MID_CharBuffer_array; static jmethodID MID_CharBuffer_arrayOffset; static jmethodID MID_ShortBuffer_array; static jmethodID MID_ShortBuffer_arrayOffset; static jmethodID MID_IntBuffer_array; static jmethodID MID_IntBuffer_arrayOffset; static jmethodID MID_LongBuffer_array; static jmethodID MID_LongBuffer_arrayOffset; static jmethodID MID_FloatBuffer_array; static jmethodID MID_FloatBuffer_arrayOffset; static jmethodID MID_DoubleBuffer_array; static jmethodID MID_DoubleBuffer_arrayOffset; static jmethodID MID_Pointer_init; static jmethodID MID_Native_updateLastError; static jmethodID MID_Native_fromNative; static jmethodID MID_Native_nativeType; static jmethodID MID_Native_toNativeTypeMapped; static jmethodID MID_Native_fromNativeTypeMapped; static jmethodID MID_Structure_getTypeInfo; static jmethodID MID_Structure_newInstance; static jmethodID MID_Structure_useMemory; static jmethodID MID_Structure_read; static jmethodID MID_Structure_write; static jmethodID MID_CallbackReference_getCallback; static jmethodID MID_CallbackReference_getFunctionPointer; static jmethodID MID_CallbackReference_getNativeString; static jmethodID MID_NativeMapped_toNative; static jmethodID MID_WString_init; static jmethodID MID_ToNativeConverter_nativeType; static jmethodID MID_ffi_callback_invoke; static jfieldID FID_Boolean_value; static jfieldID FID_Byte_value; static jfieldID FID_Short_value; static jfieldID FID_Character_value; static jfieldID FID_Integer_value; static jfieldID FID_Long_value; static jfieldID FID_Float_value; static jfieldID FID_Double_value; static jfieldID FID_Pointer_peer; static jfieldID FID_Structure_memory; static jfieldID FID_Structure_typeInfo; static jfieldID FID_IntegerType_value; static jfieldID FID_PointerType_pointer; /* Value of System property jna.encoding. */ static const char* jna_encoding = NULL; /* Forward declarations */ static char* newCString(JNIEnv *env, jstring jstr); static char* newCStringUTF8(JNIEnv *env, jstring jstr); static char* newCStringEncoding(JNIEnv *env, jstring jstr, const char* encoding); static wchar_t* newWideCString(JNIEnv *env, jstring jstr); static void* getBufferArray(JNIEnv*, jobject, jobject*, void **, void **); static char getArrayComponentType(JNIEnv *, jobject); static ffi_type* getStructureType(JNIEnv *, jobject); static void update_last_error(JNIEnv*, int); typedef void (JNICALL* release_t)(JNIEnv*,jarray,void*,jint); /** Invokes System.err.println (for debugging only). */ static void println(JNIEnv* env, const char* msg) { jclass cls = (*env)->FindClass(env, "java/lang/System"); jfieldID fid = (*env)->GetStaticFieldID(env, cls, "err", "Ljava/io/PrintStream;"); jobject err = (*env)->GetStaticObjectField(env, cls, fid); jclass pscls = (*env)->FindClass(env, "java/io/PrintStream"); jmethodID mid = (*env)->GetMethodID(env, pscls, "println", "(Ljava/lang/String;)V"); jstring str = newJavaString(env, msg, JNI_FALSE); (*env)->CallObjectMethod(env, err, mid, str); } jboolean ffi_error(JNIEnv* env, const char* op, ffi_status status) { char msg[256]; switch(status) { case FFI_BAD_ABI: snprintf(msg, sizeof(msg), "Invalid calling convention"); throwByName(env, EIllegalArgument, msg); return JNI_TRUE; case FFI_BAD_TYPEDEF: snprintf(msg, sizeof(msg), "Invalid structure definition (native typedef error)"); throwByName(env, EIllegalArgument, msg); return JNI_TRUE; default: snprintf(msg, sizeof(msg), "%s failed (%d)", op, status); throwByName(env, EError, msg); return JNI_TRUE; case FFI_OK: return JNI_FALSE; } } /* invoke the real native function */ static void dispatch(JNIEnv *env, jobject self, jint flags, jobjectArray arr, ffi_type *ffi_return_type, void *resP) { int i, nargs; void *func; jvalue* c_args; char array_pt; struct _array_elements { jobject array; void *elems; release_t release; } *array_elements; volatile int array_count = 0; ffi_cif cif; ffi_type** ffi_types; void** ffi_values; ffi_abi abi; ffi_status status; char msg[128]; callconv_t callconv = flags & MASK_CC; const char* volatile throw_type = NULL; const char* volatile throw_msg = NULL; nargs = (*env)->GetArrayLength(env, arr); if (nargs > MAX_NARGS) { snprintf(msg, sizeof(msg), "Too many arguments (max %ld)", MAX_NARGS); throwByName(env, EUnsupportedOperation, msg); return; } c_args = (jvalue*)alloca(nargs * sizeof(jvalue)); array_elements = (struct _array_elements*) alloca(nargs * sizeof(struct _array_elements)); ffi_types = (ffi_type**)alloca(nargs * sizeof(ffi_type*)); ffi_values = (void**)alloca(nargs * sizeof(void*)); // Get the function pointer func = getNativeAddress(env, self); for (i = 0; i < nargs; i++) { jobject arg = (*env)->GetObjectArrayElement(env, arr, i); if (arg == NULL) { c_args[i].l = NULL; ffi_types[i] = &ffi_type_pointer; ffi_values[i] = &c_args[i].l; } else if ((*env)->IsInstanceOf(env, arg, classBoolean)) { c_args[i].i = (*env)->GetBooleanField(env, arg, FID_Boolean_value); ffi_types[i] = &ffi_type_sint32; ffi_values[i] = &c_args[i].i; } else if ((*env)->IsInstanceOf(env, arg, classByte)) { c_args[i].b = (*env)->GetByteField(env, arg, FID_Byte_value); ffi_types[i] = &ffi_type_sint8; ffi_values[i] = &c_args[i].b; } else if ((*env)->IsInstanceOf(env, arg, classShort)) { c_args[i].s = (*env)->GetShortField(env, arg, FID_Short_value); ffi_types[i] = &ffi_type_sint16; ffi_values[i] = &c_args[i].s; } else if ((*env)->IsInstanceOf(env, arg, classCharacter)) { if (sizeof(wchar_t) == 2) { c_args[i].c = (*env)->GetCharField(env, arg, FID_Character_value); ffi_types[i] = &ffi_type_uint16; ffi_values[i] = &c_args[i].c; } else if (sizeof(wchar_t) == 4) { c_args[i].i = (*env)->GetCharField(env, arg, FID_Character_value); ffi_types[i] = &ffi_type_uint32; ffi_values[i] = &c_args[i].i; } else { snprintf(msg, sizeof(msg), "Unsupported wchar_t size (%d)", (int)sizeof(wchar_t)); throw_type = EUnsupportedOperation; throw_msg = msg; goto cleanup; } } else if ((*env)->IsInstanceOf(env, arg, classInteger)) { c_args[i].i = (*env)->GetIntField(env, arg, FID_Integer_value); ffi_types[i] = &ffi_type_sint32; ffi_values[i] = &c_args[i].i; } else if ((*env)->IsInstanceOf(env, arg, classLong)) { c_args[i].j = (*env)->GetLongField(env, arg, FID_Long_value); ffi_types[i] = &ffi_type_sint64; ffi_values[i] = &c_args[i].j; } else if ((*env)->IsInstanceOf(env, arg, classFloat)) { c_args[i].f = (*env)->GetFloatField(env, arg, FID_Float_value); ffi_types[i] = &ffi_type_float; ffi_values[i] = &c_args[i].f; } else if ((*env)->IsInstanceOf(env, arg, classDouble)) { c_args[i].d = (*env)->GetDoubleField(env, arg, FID_Double_value); ffi_types[i] = &ffi_type_double; ffi_values[i] = &c_args[i].d; } else if ((*env)->IsInstanceOf(env, arg, classPointer)) { c_args[i].l = getNativeAddress(env, arg); ffi_types[i] = &ffi_type_pointer; ffi_values[i] = &c_args[i].l; } else if ((*env)->IsInstanceOf(env, arg, classStructure)) { c_args[i].l = getStructureAddress(env, arg); ffi_types[i] = getStructureType(env, arg); ffi_values[i] = c_args[i].l; if (!ffi_types[i]) { snprintf(msg, sizeof(msg), "Structure type info not initialized at argument %d", i); throw_type = EIllegalState; throw_msg = msg; goto cleanup; } } else if ((*env)->IsInstanceOf(env, arg, classBuffer)) { c_args[i].l = (*env)->GetDirectBufferAddress(env, arg); ffi_types[i] = &ffi_type_pointer; ffi_values[i] = &c_args[i].l; if (c_args[i].l == NULL) { c_args[i].l = getBufferArray(env, arg, &array_elements[array_count].array, &array_elements[array_count].elems, (void**)&array_elements[array_count].release); if (c_args[i].l == NULL) { throw_type = EIllegalArgument; throw_msg = "Buffer arguments must be direct or have a primitive backing array"; goto cleanup; } ++array_count; } } else if ((array_pt = getArrayComponentType(env, arg)) != 0 && array_pt != 'L') { void *ptr = NULL; release_t release = NULL; #define GET_ELEMS(TYPE) do {ptr=(*env)->Get##TYPE##ArrayElements(env,arg,NULL); release=(void*)(*env)->Release##TYPE##ArrayElements; }while(0) switch(array_pt) { case 'Z': GET_ELEMS(Boolean); break; case 'B': GET_ELEMS(Byte); break; case 'C': GET_ELEMS(Char); break; case 'S': GET_ELEMS(Short); break; case 'I': GET_ELEMS(Int); break; case 'J': GET_ELEMS(Long); break; case 'F': GET_ELEMS(Float); break; case 'D': GET_ELEMS(Double); break; } if (!ptr) { throw_type = EOutOfMemory; throw_msg = "Could not obtain memory for primitive buffer"; goto cleanup; } c_args[i].l = ptr; ffi_types[i] = &ffi_type_pointer; ffi_values[i] = &c_args[i].l; array_elements[array_count].array = arg; array_elements[array_count].elems = ptr; array_elements[array_count++].release = release; } else { // Anything else, pass directly as a pointer c_args[i].l = (void*)arg; ffi_types[i] = &ffi_type_pointer; ffi_values[i] = &c_args[i].l; } } switch (callconv) { case CALLCONV_C: abi = FFI_DEFAULT_ABI; break; #ifdef _WIN32 case CALLCONV_STDCALL: #ifdef _WIN64 // Ignore requests for stdcall on win64 abi = FFI_DEFAULT_ABI; #else abi = FFI_STDCALL; #endif break; #endif // _WIN32 default: snprintf(msg, sizeof(msg), "Unrecognized calling convention: %d", (int)callconv); throw_type = EIllegalArgument; throw_msg = msg; goto cleanup; } status = ffi_prep_cif(&cif, abi, nargs, ffi_return_type, ffi_types); if (!ffi_error(env, "Native call setup", status)) { PSTART(); if (flags & THROW_LAST_ERROR) { SET_LAST_ERROR(0); } ffi_call(&cif, FFI_FN(func), resP, ffi_values); if (flags & THROW_LAST_ERROR) { int error = GET_LAST_ERROR(); if (error) { snprintf(msg, sizeof(msg), "%d", error); throw_type = ELastError; throw_msg = msg; } } else if (preserve_last_error) { update_last_error(env, GET_LAST_ERROR()); } PROTECTED_END(do { throw_type=EError;throw_msg="Invalid memory access";} while(0)); } cleanup: // Release array elements for (i=0;i < array_count;i++) { array_elements[i].release(env, array_elements[i].array, array_elements[i].elems, 0); } // Must raise any exception *after* all other JNI operations if (throw_type) { throwByName(env, throw_type, throw_msg); } } static void getChars(JNIEnv* env, wchar_t* dst, jcharArray chars, jint off, jint len) { PSTART(); if (sizeof(jchar) == sizeof(wchar_t)) { (*env)->GetCharArrayRegion(env, chars, 0, len, (jchar*)dst); } else { int i; jchar* buf = (jchar *)alloca(len * sizeof(jchar)); (*env)->GetCharArrayRegion(env, chars, 0, len, buf); for (i=0;i < len;i++) { dst[i] = (wchar_t)buf[i]; } } PEND(); } static void setChars(JNIEnv* env, wchar_t* src, jcharArray chars, jint off, jint len) { jchar* buf = (jchar*)src; PSTART(); if (sizeof(jchar) != sizeof(wchar_t)) { int i; buf = (jchar *)alloca(len * sizeof(jchar)); for (i=0;i < len;i++) { buf[i] = (jchar)src[i]; } } (*env)->SetCharArrayRegion(env, chars, 0, len, buf); PEND(); } /* * Class: Function * Method: invokePointer * Signature: (I[Ljava/lang/Object;)LPointer; */ JNIEXPORT jobject JNICALL Java_com_sun_jna_Function_invokePointer(JNIEnv *env, jobject self, jint callconv, jobjectArray arr) { jvalue result; dispatch(env, self, callconv, arr, &ffi_type_pointer, &result); return newJavaPointer(env, result.l); } /* * Class: Function * Method: invokeObject * Signature: (I[Ljava/lang/Object;)Ljava/lang/Object; */ JNIEXPORT jobject JNICALL Java_com_sun_jna_Function_invokeObject(JNIEnv *env, jobject self, jint callconv, jobjectArray arr) { jvalue result; dispatch(env, self, callconv, arr, &ffi_type_pointer, &result); return result.l; } /* * Class: Function * Method: invokeStructure * Signature: (I[Ljava/lang/Object;Lcom/sun/jna/Structure)LStructure; */ JNIEXPORT jobject JNICALL Java_com_sun_jna_Function_invokeStructure(JNIEnv *env, jobject self, jint callconv, jobjectArray arr, jobject result) { void* memory = getStructureAddress(env, result); ffi_type* rtype = getStructureType(env, result); if (!rtype) { throwByName(env, EIllegalState, "Return structure type info not initialized"); } else { dispatch(env, self, callconv, arr, rtype, memory); } return result; } /* * Class: Function * Method: invokeDouble * Signature: (I[Ljava/lang/Object;)D */ JNIEXPORT jdouble JNICALL Java_com_sun_jna_Function_invokeDouble(JNIEnv *env, jobject self, jint callconv, jobjectArray arr) { jvalue result; dispatch(env, self, callconv, arr, &ffi_type_double, &result); return result.d; } /* * Class: Function * Method: invokeFloat * Signature: (I[Ljava/lang/Object;)F */ JNIEXPORT jfloat JNICALL Java_com_sun_jna_Function_invokeFloat(JNIEnv *env, jobject self, jint callconv, jobjectArray arr) { jvalue result; dispatch(env, self, callconv, arr, &ffi_type_float, &result); return result.f; } /* * Class: Function * Method: invokeInt * Signature: (I[Ljava/lang/Object;)I */ JNIEXPORT jint JNICALL Java_com_sun_jna_Function_invokeInt(JNIEnv *env, jobject self, jint callconv, jobjectArray arr) { ffi_arg result; dispatch(env, self, callconv, arr, &ffi_type_sint32, &result); return (jint)result; } /* * Class: Function * Method: invokeLong * Signature: (I[Ljava/lang/Object;)J */ JNIEXPORT jlong JNICALL Java_com_sun_jna_Function_invokeLong(JNIEnv *env, jobject self, jint callconv, jobjectArray arr) { jvalue result; dispatch(env, self, callconv, arr, &ffi_type_sint64, &result); return result.j; } /* * Class: Function * Method: invokeVoid * Signature: (I[Ljava/lang/Object;)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Function_invokeVoid(JNIEnv *env, jobject self, jint callconv, jobjectArray arr) { jvalue result; dispatch(env, self, callconv, arr, &ffi_type_void, &result); } JNIEXPORT jobject JNICALL Java_com_sun_jna_CallbackReference_createNativeCallback(JNIEnv *env, jclass clazz, jobject obj, jobject method, jobjectArray param_types, jclass return_type, jint call_conv, jboolean direct) { callback* cb = create_callback(env, obj, method, param_types, return_type, call_conv, direct); return cb == NULL ? NULL : newJavaPointer(env, cb); } JNIEXPORT void JNICALL Java_com_sun_jna_CallbackReference_freeNativeCallback(JNIEnv *env, jclass clazz, jlong ptr) { free_callback(env, (callback*)L2A(ptr)); } /* * Class: com_sun_jna_NativeLibrary * Method: open * Signature: (Ljava/lang/String;)J */ JNIEXPORT jlong JNICALL Java_com_sun_jna_NativeLibrary_open(JNIEnv *env, jclass cls, jstring lib){ void *handle = NULL; const LIBNAMETYPE libname = NULL; /* dlopen on Unix allows NULL to mean "current process" */ if (lib != NULL) { if ((libname = LIBNAME2CSTR(env, lib)) == NULL) { return A2L(NULL); } } handle = (void *)LOAD_LIBRARY(libname); if (!handle) { char buf[1024]; throwByName(env, EUnsatisfiedLink, LOAD_ERROR(buf, sizeof(buf))); } if (libname != NULL) free((void *)libname); return A2L(handle); } /* * Class: com_sun_jna_NativeLibrary * Method: close * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_sun_jna_NativeLibrary_close(JNIEnv *env, jclass cls, jlong handle) { if (FREE_LIBRARY(L2A(handle))) { char buf[1024]; throwByName(env, EError, LOAD_ERROR(buf, sizeof(buf))); } } /* * Class: com_sun_jna_NativeLibrary * Method: findSymbol * Signature: (JLjava/lang/String;)J */ JNIEXPORT jlong JNICALL Java_com_sun_jna_NativeLibrary_findSymbol(JNIEnv *env, jclass cls, jlong libHandle, jstring fun) { void *handle = L2A(libHandle); void *func = NULL; const char *funname = NULL; if ((funname = newCString(env, fun)) != NULL) { #ifdef _WIN32 if (handle == GetModuleHandleW(NULL)) { HANDLE cur_proc = GetCurrentProcess (); HMODULE *modules; DWORD needed, i; if (!EnumProcessModules (cur_proc, NULL, 0, &needed)) { fail: throwByName(env, EError, "Unexpected error enumerating modules"); free((void *)funname); return 0; } modules = (HMODULE*) alloca (needed); if (!EnumProcessModules (cur_proc, modules, needed, &needed)) { goto fail; } for (i = 0; i < needed / sizeof (HMODULE); i++) if ((func = (void *) GetProcAddress (modules[i], funname))) break; } else #endif func = (void *)FIND_ENTRY(handle, funname); if (!func) { char buf[1024]; throwByName(env, EUnsatisfiedLink, LOAD_ERROR(buf, sizeof(buf))); } free((void *)funname); } return A2L(func); } static const void* get_system_property(JNIEnv* env, const char* name, jboolean wide) { jclass classSystem = (*env)->FindClass(env, "java/lang/System"); if (classSystem != NULL) { jmethodID mid = (*env)->GetStaticMethodID(env, classSystem, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;"); if (mid != NULL) { jstring propname = newJavaString(env, name, JNI_FALSE); jstring value = (*env)->CallStaticObjectMethod(env, classSystem, mid, propname); if (value) { if (wide) return newWideCString(env, value); return newCStringUTF8(env, value); } } } return NULL; } static const char* jnidispatch_init(JNIEnv* env) { if (!LOAD_CREF(env, Object, "java/lang/Object")) return "java.lang.Object"; if (!LOAD_CREF(env, Class, "java/lang/Class")) return "java.lang.Class"; if (!LOAD_CREF(env, Method, "java/lang/reflect/Method")) return "java.lang.reflect.Method"; if (!LOAD_CREF(env, String, "java/lang/String")) return "java.lang.String"; if (!LOAD_CREF(env, Buffer, "java/nio/Buffer")) return "java.nio.Buffer"; if (!LOAD_CREF(env, ByteBuffer, "java/nio/ByteBuffer")) return "java.nio.ByteBuffer"; if (!LOAD_CREF(env, CharBuffer, "java/nio/CharBuffer")) return "java.nio.CharBuffer"; if (!LOAD_CREF(env, ShortBuffer, "java/nio/ShortBuffer")) return "java.nio.ShortBuffer"; if (!LOAD_CREF(env, IntBuffer, "java/nio/IntBuffer")) return "java.nio.IntBuffer"; if (!LOAD_CREF(env, LongBuffer, "java/nio/LongBuffer")) return "java.nio.LongBuffer"; if (!LOAD_CREF(env, FloatBuffer, "java/nio/FloatBuffer")) return "java.nio.FloatBuffer"; if (!LOAD_CREF(env, DoubleBuffer, "java/nio/DoubleBuffer")) return "java.nio.DoubleBuffer"; if (!LOAD_PCREF(env, Void, "java/lang/Void")) return "java.lang.Void"; if (!LOAD_PCREF(env, Boolean, "java/lang/Boolean")) return "java.lang.Boolean"; if (!LOAD_PCREF(env, Byte, "java/lang/Byte")) return "java.lang.Byte"; if (!LOAD_PCREF(env, Character, "java/lang/Character")) return "java.lang.Character"; if (!LOAD_PCREF(env, Short, "java/lang/Short")) return "java.lang.Short"; if (!LOAD_PCREF(env, Integer, "java/lang/Integer")) return "java.lang.Integer"; if (!LOAD_PCREF(env, Long, "java/lang/Long")) return "java.lang.Long"; if (!LOAD_PCREF(env, Float, "java/lang/Float")) return "java.lang.Float"; if (!LOAD_PCREF(env, Double, "java/lang/Double")) return "java.lang.Double"; if (!LOAD_MID(env, MID_Long_init, classLong, "", "(J)V")) return "java.lang.Long(J)V"; if (!LOAD_MID(env, MID_Integer_init, classInteger, "", "(I)V")) return "java.lang.Integer(I)V"; if (!LOAD_MID(env, MID_Short_init, classShort, "", "(S)V")) return "java.lang.Short(S)V"; if (!LOAD_MID(env, MID_Character_init, classCharacter, "", "(C)V")) return "java.lang.Character(C)V"; if (!LOAD_MID(env, MID_Byte_init, classByte, "", "(B)V")) return "java.lang.Byte(B)V"; if (!LOAD_MID(env, MID_Boolean_init, classBoolean, "", "(Z)V")) return "java.lang.Boolean(Z)V"; if (!LOAD_MID(env, MID_Float_init, classFloat, "", "(F)V")) return "java.lang.Float(F)V"; if (!LOAD_MID(env, MID_Double_init, classDouble, "", "(D)V")) return "java.lang.Double(D)V"; if (!LOAD_MID(env, MID_Class_getComponentType, classClass, "getComponentType", "()Ljava/lang/Class;")) return "Class.getComponentType()"; if (!LOAD_MID(env, MID_Object_toString, classObject, "toString", "()Ljava/lang/String;")) return "Object.toString()"; if (!LOAD_MID(env, MID_String_getBytes, classString, "getBytes", "()[B")) return "String.getBytes()"; if (!LOAD_MID(env, MID_String_getBytes2, classString, "getBytes", "(Ljava/lang/String;)[B")) return "String.getBytes(String)"; if (!LOAD_MID(env, MID_String_toCharArray, classString, "toCharArray", "()[C")) return "String.toCharArray()"; if (!LOAD_MID(env, MID_String_init_bytes, classString, "", "([B)V")) return "String([B)V"; if (!LOAD_MID(env, MID_Method_getParameterTypes, classMethod, "getParameterTypes", "()[Ljava/lang/Class;")) return "Method.getParameterTypes()"; if (!LOAD_MID(env, MID_Method_getReturnType, classMethod, "getReturnType", "()Ljava/lang/Class;")) return "Method.getReturnType()"; if (!LOAD_MID(env, MID_ByteBuffer_array, classByteBuffer, "array", "()[B")) return "ByteBuffer.array"; if (!LOAD_MID(env, MID_ByteBuffer_arrayOffset, classByteBuffer, "arrayOffset", "()I")) return "ByteBuffer.arrayOffset"; if (!LOAD_MID(env, MID_CharBuffer_array, classCharBuffer, "array", "()[C")) return "CharBuffer.array"; if (!LOAD_MID(env, MID_CharBuffer_arrayOffset, classCharBuffer, "arrayOffset", "()I")) return "CharBuffer.arrayOffset"; if (!LOAD_MID(env, MID_ShortBuffer_array, classShortBuffer, "array", "()[S")) return "ShortBuffer.array"; if (!LOAD_MID(env, MID_ShortBuffer_arrayOffset, classShortBuffer, "arrayOffset", "()I")) return "ShortBuffer.arrayOffset"; if (!LOAD_MID(env, MID_IntBuffer_array, classIntBuffer, "array", "()[I")) return "IntBuffer.array"; if (!LOAD_MID(env, MID_IntBuffer_arrayOffset, classIntBuffer, "arrayOffset", "()I")) return "IntBuffer.arrayOffset"; if (!LOAD_MID(env, MID_LongBuffer_array, classLongBuffer, "array", "()[J")) return "LongBuffer.array"; if (!LOAD_MID(env, MID_LongBuffer_arrayOffset, classLongBuffer, "arrayOffset", "()I")) return "LongBuffer.arrayOffset"; if (!LOAD_MID(env, MID_FloatBuffer_array, classFloatBuffer, "array", "()[F")) return "FloatBuffer.array"; if (!LOAD_MID(env, MID_FloatBuffer_arrayOffset, classFloatBuffer, "arrayOffset", "()I")) return "FloatBuffer.arrayOffset"; if (!LOAD_MID(env, MID_DoubleBuffer_array, classDoubleBuffer, "array", "()[D")) return "DoubleBuffer.array"; if (!LOAD_MID(env, MID_DoubleBuffer_arrayOffset, classDoubleBuffer, "arrayOffset", "()I")) return "DoubleBuffer.arrayOffset"; if (!LOAD_FID(env, FID_Boolean_value, classBoolean, "value", "Z")) return "Boolean.value"; if (!LOAD_FID(env, FID_Byte_value, classByte, "value", "B")) return "Byte.value"; if (!LOAD_FID(env, FID_Short_value, classShort, "value", "S")) return "Short.value"; if (!LOAD_FID(env, FID_Character_value, classCharacter, "value", "C")) return "Character.value"; if (!LOAD_FID(env, FID_Integer_value, classInteger, "value", "I")) return "Integer.value"; if (!LOAD_FID(env, FID_Long_value, classLong, "value", "J")) return "Long.value"; if (!LOAD_FID(env, FID_Float_value, classFloat, "value", "F")) return "Float.value"; if (!LOAD_FID(env, FID_Double_value, classDouble, "value", "D")) return "Double.value"; // Cache jna.encoding value jna_encoding = get_system_property(env, "jna.encoding", JNI_FALSE); return NULL; } /* * Class: Pointer * Method: _write * Signature: (J[BII)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1write__J_3BII (JNIEnv *env, jclass cls, jlong addr, jbyteArray arr, jint off, jint n) { PSTART(); (*env)->GetByteArrayRegion(env, arr, off, n, L2A(addr)); PEND(); } /* * Class: Pointer * Method: _write * Signature: (J[CII)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1write__J_3CII (JNIEnv *env, jclass cls, jlong addr, jcharArray arr, jint off, jint n) { getChars(env, (wchar_t*)L2A(addr), arr, off, n); } /* * Class: Pointer * Method: _write * Signature: (J[DII)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1write__J_3DII (JNIEnv *env, jclass cls, jlong addr, jdoubleArray arr, jint off, jint n) { PSTART(); (*env)->GetDoubleArrayRegion(env, arr, off, n, (jdouble*)L2A(addr)); PEND(); } /* * Class: Pointer * Method: _write * Signature: (J[FII)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1write__J_3FII (JNIEnv *env, jclass cls, jlong addr, jfloatArray arr, jint off, jint n) { PSTART(); (*env)->GetFloatArrayRegion(env, arr, off, n, (jfloat*)L2A(addr)); PEND(); } /* * Class: Pointer * Method: _write * Signature: (J[III)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1write__J_3III (JNIEnv *env, jclass cls, jlong addr, jintArray arr, jint off, jint n) { PSTART(); (*env)->GetIntArrayRegion(env, arr, off, n, (jint*)L2A(addr)); PEND(); } /* * Class: Pointer * Method: _write * Signature: (J[JII)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1write__J_3JII (JNIEnv *env, jclass cls, jlong addr, jlongArray arr, jint off, jint n) { PSTART(); (*env)->GetLongArrayRegion(env, arr, off, n, (jlong*)L2A(addr)); PEND(); } /* * Class: Pointer * Method: _write * Signature: (J[SII)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1write__J_3SII (JNIEnv *env, jclass cls, jlong addr, jshortArray arr, jint off, jint n) { PSTART(); (*env)->GetShortArrayRegion(env, arr, off, n, (jshort*)L2A(addr)); PEND(); } /* * Class: Pointer * Method: _indexOf * Signature: (JB)J */ JNIEXPORT jlong JNICALL Java_com_sun_jna_Pointer__1indexOf__JB (JNIEnv *env, jclass cls, jlong addr, jbyte value) { jbyte *peer = (jbyte *)L2A(addr); volatile jlong i = 0; volatile jlong result = -1L; PSTART(); while (i >= 0 && result == -1L) { if (peer[i] == value) result = i; ++i; } PEND(); return result; } /* * Class: Pointer * Method: _read * Signature: (J[BII)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1read__J_3BII (JNIEnv *env, jclass cls, jlong addr, jbyteArray arr, jint off, jint n) { PSTART(); (*env)->SetByteArrayRegion(env, arr, off, n, L2A(addr)); PEND(); } /* * Class: Pointer * Method: _read * Signature: (J[CII)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1read__J_3CII (JNIEnv *env, jclass cls, jlong addr, jcharArray arr, jint off, jint n) { setChars(env, (wchar_t*)L2A(addr), arr, off, n); } /* * Class: Pointer * Method: _read * Signature: (J[DII)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1read__J_3DII (JNIEnv *env, jclass cls, jlong addr, jdoubleArray arr, jint off, jint n) { PSTART(); (*env)->SetDoubleArrayRegion(env, arr, off, n, (jdouble*)L2A(addr)); PEND(); } /* * Class: Pointer * Method: _read * Signature: (J[FII)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1read__J_3FII (JNIEnv *env, jclass cls, jlong addr, jfloatArray arr, jint off, jint n) { PSTART(); (*env)->SetFloatArrayRegion(env, arr, off, n, (jfloat*)L2A(addr)); PEND(); } /* * Class: Pointer * Method: _read * Signature: (J[III)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1read__J_3III (JNIEnv *env, jclass cls, jlong addr, jintArray arr, jint off, jint n) { PSTART(); (*env)->SetIntArrayRegion(env, arr, off, n, (jint*)L2A(addr)); PEND(); } /* * Class: Pointer * Method: _read * Signature: (J[JII)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1read__J_3JII (JNIEnv *env, jclass cls, jlong addr, jlongArray arr, jint off, jint n) { PSTART(); (*env)->SetLongArrayRegion(env, arr, off, n, (jlong*)L2A(addr)); PEND(); } /* * Class: Pointer * Method: _read * Signature: (J[SII)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1read__J_3SII (JNIEnv *env, jclass cls, jlong addr, jshortArray arr, jint off, jint n) { PSTART(); (*env)->SetShortArrayRegion(env, arr, off, n, (jshort*)L2A(addr)); PEND(); } /* * Class: Pointer * Method: _getByte * Signature: (J)B */ JNIEXPORT jbyte JNICALL Java_com_sun_jna_Pointer__1getByte (JNIEnv *env, jclass cls, jlong addr) { jbyte res = 0; MEMCPY(&res, L2A(addr), sizeof(res)); return res; } /* * Class: Pointer * Method: _getChar * Signature: (J)C */ JNIEXPORT jchar JNICALL Java_com_sun_jna_Pointer__1getChar (JNIEnv *env, jclass cls, jlong addr) { wchar_t res = 0; MEMCPY(&res, L2A(addr), sizeof(res)); return (jchar)res; } /* * Class: Pointer * Method: _getPointer * Signature: (J)LPointer; */ JNIEXPORT jobject JNICALL Java_com_sun_jna_Pointer__1getPointer (JNIEnv *env, jclass cls, jlong addr) { void *ptr = NULL; MEMCPY(&ptr, L2A(addr), sizeof(ptr)); return newJavaPointer(env, ptr); } /* * Class: com_sun_jna_Pointer * Method: _getDirectByteBuffer * Signature: (JJ)Ljava/nio/ByteBuffer; */ JNIEXPORT jobject JNICALL Java_com_sun_jna_Pointer__1getDirectByteBuffer (JNIEnv *env, jclass cls, jlong addr, jlong length) { return (*env)->NewDirectByteBuffer(env, L2A(addr), length); } /* * Class: Pointer * Method: _getDouble * Signature: (J)D */ JNIEXPORT jdouble JNICALL Java_com_sun_jna_Pointer__1getDouble (JNIEnv *env, jclass cls, jlong addr) { jdouble res = 0; MEMCPY(&res, L2A(addr), sizeof(res)); return res; } /* * Class: Pointer * Method: _getFloat * Signature: (J)F */ JNIEXPORT jfloat JNICALL Java_com_sun_jna_Pointer__1getFloat (JNIEnv *env, jclass cls, jlong addr) { jfloat res = 0; MEMCPY(&res, L2A(addr), sizeof(res)); return res; } /* * Class: Pointer * Method: _getInt * Signature: (J)I */ JNIEXPORT jint JNICALL Java_com_sun_jna_Pointer__1getInt (JNIEnv *env, jclass cls, jlong addr) { jint res = 0; MEMCPY(&res, L2A(addr), sizeof(res)); return res; } /* * Class: Pointer * Method: _getLong * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_com_sun_jna_Pointer__1getLong (JNIEnv *env, jclass cls, jlong addr) { jlong res = 0; MEMCPY(&res, L2A(addr), sizeof(res)); return res; } /* * Class: Pointer * Method: _getShort * Signature: (J)S */ JNIEXPORT jshort JNICALL Java_com_sun_jna_Pointer__1getShort (JNIEnv *env, jclass cls, jlong addr) { jshort res = 0; MEMCPY(&res, L2A(addr), sizeof(res)); return res; } /* * Class: Pointer * Method: _getString * Signature: (JB)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_com_sun_jna_Pointer__1getString (JNIEnv *env, jclass cls, jlong addr, jboolean wide) { return newJavaString(env, L2A(addr), wide); } /* * Class: Pointer * Method: _setMemory * Signature: (JJB)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1setMemory (JNIEnv *env, jclass cls, jlong addr, jlong count, jbyte value) { MEMSET(L2A(addr), (int)value, (size_t)count); } /* * Class: Pointer * Method: _setByte * Signature: (JB)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1setByte (JNIEnv *env, jclass cls, jlong addr, jbyte value) { MEMCPY(L2A(addr), &value, sizeof(value)); } /* * Class: Pointer * Method: _setChar * Signature: (JC)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1setChar (JNIEnv *env, jclass cls, jlong addr, jchar value) { wchar_t ch = value; MEMCPY(L2A(addr), &ch, sizeof(ch)); } /* * Class: Pointer * Method: _setPointer * Signature: (JJ)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1setPointer (JNIEnv *env, jclass cls, jlong addr, jlong value) { void *ptr = L2A(value); MEMCPY(L2A(addr), &ptr, sizeof(void *)); } /* * Class: Pointer * Method: _setDouble * Signature: (JD)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1setDouble (JNIEnv *env, jclass cls, jlong addr, jdouble value) { MEMCPY(L2A(addr), &value, sizeof(value)); } /* * Class: Pointer * Method: _setFloat * Signature: (JF)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1setFloat (JNIEnv *env, jclass cls, jlong addr, jfloat value) { MEMCPY(L2A(addr), &value, sizeof(value)); } /* * Class: Pointer * Method: _setInt * Signature: (JI)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1setInt (JNIEnv *env, jclass cls, jlong addr, jint value) { MEMCPY(L2A(addr), &value, sizeof(value)); } /* * Class: Pointer * Method: _setLong * Signature: (JJ)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1setLong (JNIEnv *env, jclass cls, jlong addr, jlong value) { MEMCPY(L2A(addr), &value, sizeof(value)); } /* * Class: Pointer * Method: _setShort * Signature: (JS)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1setShort (JNIEnv *env, jclass cls, jlong addr, jshort value) { MEMCPY(L2A(addr), &value, sizeof(value)); } /* * Class: Pointer * Method: _setString * Signature: (JLjava/lang/String;Z)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Pointer__1setString (JNIEnv *env, jclass cls, jlong addr, jstring value, jboolean wide) { int len = (*env)->GetStringLength(env, value); const void* volatile str; volatile int size = len + 1; if (wide) { size *= sizeof(wchar_t); str = newWideCString(env, value); } else { str = newCStringEncoding(env, value, jna_encoding); } if (str != NULL) { MEMCPY(L2A(addr), str, size); free((void*)str); } } /* * Class: Memory * Method: malloc * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_com_sun_jna_Memory_malloc (JNIEnv *env, jclass cls, jlong size) { return A2L(malloc((size_t)size)); } /* * Class: Memory * Method: free * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_sun_jna_Memory_free (JNIEnv *env, jclass cls, jlong ptr) { free(L2A(ptr)); } //******************************************************************* // Utility functions //******************************************************************* /* Throw an exception by name */ void throwByName(JNIEnv *env, const char *name, const char *msg) { jclass cls; (*env)->ExceptionClear(env); cls = (*env)->FindClass(env, name); if (cls != NULL) { /* Otherwise an exception has already been thrown */ (*env)->ThrowNew(env, cls, msg); /* It's a good practice to clean up the local references. */ (*env)->DeleteLocalRef(env, cls); } } /* Translates a Java string to a C string using the String.getBytes * method, which uses default platform encoding. */ static char * newCString(JNIEnv *env, jstring jstr) { jbyteArray bytes = 0; char *result = NULL; bytes = (*env)->CallObjectMethod(env, jstr, MID_String_getBytes); if (!(*env)->ExceptionCheck(env)) { jint len = (*env)->GetArrayLength(env, bytes); result = (char *)malloc(len + 1); if (result == NULL) { (*env)->DeleteLocalRef(env, bytes); throwByName(env, EOutOfMemory, "Can't allocate C string"); return NULL; } (*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *)result); result[len] = 0; /* NUL-terminate */ } (*env)->DeleteLocalRef(env, bytes); return result; } /* Translates a Java string to a C string using the String.getBytes("UTF8") * method, which uses UTF8 encoding. */ static char * newCStringUTF8(JNIEnv *env, jstring jstr) { return newCStringEncoding(env, jstr, "UTF8"); } static char* newCStringEncoding(JNIEnv *env, jstring jstr, const char* encoding) { jbyteArray bytes = 0; char *result = NULL; if (!encoding) return newCString(env, jstr); bytes = (*env)->CallObjectMethod(env, jstr, MID_String_getBytes2, newJavaString(env, encoding, JNI_FALSE)); if (!(*env)->ExceptionCheck(env)) { jint len = (*env)->GetArrayLength(env, bytes); result = (char *)malloc(len + 1); if (result == NULL) { (*env)->DeleteLocalRef(env, bytes); throwByName(env, EOutOfMemory, "Can't allocate C string"); return NULL; } (*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *)result); result[len] = 0; /* NUL-terminate */ } (*env)->DeleteLocalRef(env, bytes); return result; } /* Translates a Java string to a wide C string using the String.toCharArray * method. */ // TODO: are any encoding changes required? static wchar_t * newWideCString(JNIEnv *env, jstring str) { jcharArray chars = 0; wchar_t *result = NULL; chars = (*env)->CallObjectMethod(env, str, MID_String_toCharArray); if (!(*env)->ExceptionCheck(env)) { jint len = (*env)->GetArrayLength(env, chars); result = (wchar_t *)malloc(sizeof(wchar_t) * (len + 1)); if (result == NULL) { (*env)->DeleteLocalRef(env, chars); throwByName(env, EOutOfMemory, "Can't allocate wide C string"); return NULL; } // TODO: ensure proper encoding conversion from jchar to native wchar_t getChars(env, result, chars, 0, len); result[len] = 0; /* NUL-terminate */ } (*env)->DeleteLocalRef(env, chars); return result; } /** Update the per-thread last error setting. */ static void update_last_error(JNIEnv* env, int err) { (*env)->CallStaticVoidMethod(env, classNative, MID_Native_updateLastError, err); } jobject newJavaWString(JNIEnv *env, const wchar_t* ptr) { jstring s = newJavaString(env, (const char*)ptr, JNI_TRUE); return (*env)->NewObject(env, classWString, MID_WString_init, s); } /* Constructs a Java string from a char array (using the String(byte []) * constructor, which uses default local encoding) or a short array (using the * String(char[]) ctor, which uses the character values unmodified). */ jstring newJavaString(JNIEnv *env, const char *ptr, jboolean wide) { volatile jstring result = 0; PSTART(); if (ptr) { if (wide) { // TODO: proper conversion from native wchar_t to jchar, if any int len = (int)wcslen((const wchar_t*)ptr); if (sizeof(jchar) != sizeof(wchar_t)) { jchar* buf = (jchar*)alloca(len * sizeof(jchar)); int i; for (i=0;i < len;i++) { buf[i] = *((const wchar_t*)ptr + i); } result = (*env)->NewString(env, buf, len); } else { result = (*env)->NewString(env, (const jchar*)ptr, len); } } else { jbyteArray bytes = 0; int len = (int)strlen(ptr); bytes = (*env)->NewByteArray(env, len); if (bytes != 0) { (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte *)ptr); result = (*env)->NewObject(env, classString, MID_String_init_bytes, bytes); (*env)->DeleteLocalRef(env, bytes); } } } PEND(); return result; } jobject newJavaPointer(JNIEnv *env, void *p) { jobject obj = NULL; if (p != NULL) { obj = (*env)->NewObject(env, classPointer, MID_Pointer_init, A2L(p)); } return obj; } jobject newJavaStructure(JNIEnv *env, void *data, jclass type, jboolean new_memory) { if (data != NULL) { volatile jobject obj = (*env)->CallStaticObjectMethod(env, classStructure, MID_Structure_newInstance, type); ffi_type* rtype = getStructureType(env, obj); if (new_memory) { MEMCPY(getStructureAddress(env, obj), data, rtype->size); } else { (*env)->CallVoidMethod(env, obj, MID_Structure_useMemory, newJavaPointer(env, data)); } (*env)->CallVoidMethod(env, obj, MID_Structure_read); return obj; } return NULL; } jobject newJavaCallback(JNIEnv* env, void* fptr, jclass type) { if (fptr != NULL) { jobject ptr = newJavaPointer(env, fptr); return (*env)->CallStaticObjectMethod(env, classCallbackReference, MID_CallbackReference_getCallback, type, ptr, JNI_TRUE); } return NULL; } void* getNativeString(JNIEnv* env, jstring s, jboolean wide) { if (s != NULL) { jobject ptr = (*env)->CallStaticObjectMethod(env, classCallbackReference, MID_CallbackReference_getNativeString, s, wide); return getNativeAddress(env, ptr); } return NULL; } int get_conversion_flag(JNIEnv* env, jclass cls) { int type = get_jtype(env, cls); if (type == 's') { return CVT_STRUCTURE_BYVAL; } if (type == '*') { if ((*env)->IsAssignableFrom(env, cls, classPointer)) { return CVT_POINTER; } if ((*env)->IsAssignableFrom(env, cls, classStructure)) { return CVT_STRUCTURE; } if ((*env)->IsAssignableFrom(env, cls, classString)) { return CVT_STRING; } if ((*env)->IsAssignableFrom(env, cls, classWString)) { return CVT_WSTRING; } if ((*env)->IsAssignableFrom(env, cls, classCallback)) { return CVT_CALLBACK; } if ((*env)->IsAssignableFrom(env, cls, classIntegerType)) { return CVT_INTEGER_TYPE; } if ((*env)->IsAssignableFrom(env, cls, classPointerType)) { return CVT_POINTER_TYPE; } if ((*env)->IsAssignableFrom(env, cls, classNativeMapped)) { return CVT_NATIVE_MAPPED; } } return CVT_DEFAULT; } int get_jtype_from_ffi_type(ffi_type* type) { switch(type->type) { // FIXME aliases 'C' on *nix; this will cause problems if anyone // ever installs a type mapper for char/Character (not a common arg type) case FFI_TYPE_UINT32: return 'Z'; case FFI_TYPE_SINT8: return 'B'; case FFI_TYPE_SINT16: return 'S'; case FFI_TYPE_UINT16: return 'C'; case FFI_TYPE_SINT32: return 'I'; case FFI_TYPE_SINT64: return 'J'; case FFI_TYPE_FLOAT: return 'F'; case FFI_TYPE_DOUBLE: return 'D'; default: return '*'; } } int get_jtype(JNIEnv* env, jclass cls) { if ((*env)->IsSameObject(env, classVoid, cls) || (*env)->IsSameObject(env, classPrimitiveVoid, cls)) return 'V'; if ((*env)->IsSameObject(env, classBoolean, cls) || (*env)->IsSameObject(env, classPrimitiveBoolean, cls)) return 'Z'; if ((*env)->IsSameObject(env, classByte, cls) || (*env)->IsSameObject(env, classPrimitiveByte, cls)) return 'B'; if ((*env)->IsSameObject(env, classCharacter, cls) || (*env)->IsSameObject(env, classPrimitiveCharacter, cls)) return 'C'; if ((*env)->IsSameObject(env,classShort, cls) || (*env)->IsSameObject(env, classPrimitiveShort, cls)) return 'S'; if ((*env)->IsSameObject(env, classInteger, cls) || (*env)->IsSameObject(env, classPrimitiveInteger, cls)) return 'I'; if ((*env)->IsSameObject(env, classLong, cls) || (*env)->IsSameObject(env, classPrimitiveLong, cls)) return 'J'; if ((*env)->IsSameObject(env, classFloat, cls) || (*env)->IsSameObject(env, classPrimitiveFloat, cls)) return 'F'; if ((*env)->IsSameObject(env, classDouble, cls) || (*env)->IsSameObject(env, classPrimitiveDouble, cls)) return 'D'; if ((*env)->IsAssignableFrom(env, cls, classStructure)) { if ((*env)->IsAssignableFrom(env, cls, classStructureByValue)) return 's'; return '*'; } if ((*env)->IsAssignableFrom(env, cls, classPointer) || (*env)->IsAssignableFrom(env, cls, classCallback) || (*env)->IsAssignableFrom(env, cls, classNativeMapped) || (*env)->IsAssignableFrom(env, cls, classWString) || (*env)->IsAssignableFrom(env, cls, classString)) return '*'; return -1; } jlong getIntegerTypeValue(JNIEnv* env, jobject obj) { return (*env)->GetLongField(env, obj, FID_IntegerType_value); } void* getPointerTypeAddress(JNIEnv* env, jobject obj) { return getNativeAddress(env, (*env)->GetObjectField(env, obj, FID_PointerType_pointer)); } void * getStructureAddress(JNIEnv *env, jobject obj) { if (obj != NULL) { jobject ptr = (*env)->GetObjectField(env, obj, FID_Structure_memory); return getNativeAddress(env, ptr); } return NULL; } void writeStructure(JNIEnv *env, jobject s) { if (s != NULL) { (*env)->CallVoidMethod(env, s, MID_Structure_write); } } void * getCallbackAddress(JNIEnv *env, jobject obj) { if (obj != NULL) { jobject ptr = (*env)->CallStaticObjectMethod(env, classCallbackReference, MID_CallbackReference_getFunctionPointer, obj, JNI_TRUE); return getNativeAddress(env, ptr); } return NULL; } jclass getNativeType(JNIEnv* env, jclass cls) { return (*env)->CallStaticObjectMethod(env, classNative, MID_Native_nativeType, cls); } void* getFFITypeTypeMapped(JNIEnv* env, jobject converter) { return L2A((*env)->CallStaticLongMethod(env, converter, MID_ToNativeConverter_nativeType)); } void toNative(JNIEnv* env, jobject obj, void* valuep, size_t size, jboolean promote) { if (obj != NULL) { jobject arg = (*env)->CallObjectMethod(env, obj, MID_NativeMapped_toNative); extract_value(env, arg, valuep, size, promote); } else { MEMSET(valuep, 0, size); } } static void toNativeTypeMapped(JNIEnv* env, jobject obj, void* valuep, size_t size, jobject to_native) { if (obj != NULL) { jobject arg = (*env)->CallStaticObjectMethod(env, classNative, MID_Native_toNativeTypeMapped, to_native, obj); extract_value(env, arg, valuep, size, JNI_FALSE); } else { MEMSET(valuep, 0, size); } } static void fromNativeTypeMapped(JNIEnv* env, jobject from_native, void* resp, ffi_type* type, jclass javaClass, void* result) { int jtype = get_jtype_from_ffi_type(type); jobject value = new_object(env, (char)jtype, resp, JNI_TRUE); jobject obj = (*env)->CallStaticObjectMethod(env, classNative, MID_Native_fromNativeTypeMapped, from_native, value, javaClass); // Must extract primitive types if (type->type != FFI_TYPE_POINTER) { extract_value(env, obj, result, type->size, JNI_TRUE); } } jobject fromNative(JNIEnv* env, jclass javaClass, ffi_type* type, void* resp, jboolean promote) { int jtype = get_jtype_from_ffi_type(type); jobject value = new_object(env, (char)jtype, resp, promote); return (*env)->CallStaticObjectMethod(env, classNative, MID_Native_fromNative, javaClass, value); } static ffi_type* getStructureType(JNIEnv *env, jobject obj) { jlong typeInfo = (*env)->GetLongField(env, obj, FID_Structure_typeInfo); if (!typeInfo) { (*env)->CallObjectMethod(env, obj, MID_Structure_getTypeInfo); typeInfo = (*env)->GetLongField(env, obj, FID_Structure_typeInfo); } return (ffi_type*)L2A(typeInfo); } void * getNativeAddress(JNIEnv *env, jobject obj) { if (obj != NULL) return L2A((*env)->GetLongField(env, obj, FID_Pointer_peer)); return NULL; } static char getArrayComponentType(JNIEnv *env, jobject obj) { jclass cls = (*env)->GetObjectClass(env, obj); jclass type = (*env)->CallObjectMethod(env, cls, MID_Class_getComponentType); if (type != NULL) { return (char)get_jtype(env, type); } return 0; } static void* getBufferArray(JNIEnv* env, jobject buf, jobject* arrayp, void **basep, void **releasep) { void *ptr = NULL; int offset = 0; jobject array = NULL; #define GET_ARRAY(TYPE, ELEM_SIZE) \ do { \ array = (*env)->CallObjectMethod(env, buf, MID_##TYPE##Buffer_array); \ if (array != NULL) { \ offset = \ (*env)->CallIntMethod(env, buf, MID_##TYPE##Buffer_arrayOffset) \ * ELEM_SIZE; \ ptr = (*env)->Get##TYPE##ArrayElements(env, array, NULL); \ if (releasep) *releasep = (void*)(*env)->Release##TYPE##ArrayElements; \ } \ else if (releasep) *releasep = NULL; \ } while(0) if ((*env)->IsInstanceOf(env, buf, classByteBuffer)) { GET_ARRAY(Byte, 1); } else if((*env)->IsInstanceOf(env, buf, classCharBuffer)) { GET_ARRAY(Char, 2); } else if((*env)->IsInstanceOf(env, buf, classShortBuffer)) { GET_ARRAY(Short, 2); } else if((*env)->IsInstanceOf(env, buf, classIntBuffer)) { GET_ARRAY(Int, 4); } else if((*env)->IsInstanceOf(env, buf, classLongBuffer)) { GET_ARRAY(Long, 8); } else if((*env)->IsInstanceOf(env, buf, classFloatBuffer)) { GET_ARRAY(Float, 4); } else if((*env)->IsInstanceOf(env, buf, classDoubleBuffer)) { GET_ARRAY(Double, 8); } if (ptr != NULL) { if (basep) *basep = ptr; if (arrayp) *arrayp = array; ptr = (char *)ptr + offset; } return ptr; } /* * Class: Native * Method: sizeof * Signature: (I)I */ JNIEXPORT jint JNICALL Java_com_sun_jna_Native_sizeof(JNIEnv *env, jclass cls, jint type) { switch(type) { case com_sun_jna_Native_TYPE_VOIDP: return sizeof(void*); case com_sun_jna_Native_TYPE_LONG: return sizeof(long); case com_sun_jna_Native_TYPE_WCHAR_T: return sizeof(wchar_t); case com_sun_jna_Native_TYPE_SIZE_T: return sizeof(size_t); default: { char msg[1024]; snprintf(msg, sizeof(msg), "Invalid sizeof type %d", (int)type); throwByName(env, EIllegalArgument, msg); return -1; } } } /** Initialize com.sun.jna classes separately from the library load to * avoid initialization inconsistencies. */ JNIEXPORT void JNICALL Java_com_sun_jna_Native_initIDs(JNIEnv *env, jclass cls) { preserve_last_error = JNI_TRUE; if (!LOAD_CREF(env, Pointer, "com/sun/jna/Pointer")) { throwByName(env, EUnsatisfiedLink, "Can't obtain class com.sun.jna.Pointer"); } else if (!LOAD_MID(env, MID_Pointer_init, classPointer, "", "(J)V")) { throwByName(env, EUnsatisfiedLink, "Can't obtain constructor for class com.sun.jna.Pointer"); } else if (!LOAD_FID(env, FID_Pointer_peer, classPointer, "peer", "J")) { throwByName(env, EUnsatisfiedLink, "Can't obtain peer field ID for class com.sun.jna.Pointer"); } else if (!(classNative = (*env)->NewWeakGlobalRef(env, cls))) { throwByName(env, EUnsatisfiedLink, "Can't obtain global reference for class com.sun.jna.Native"); } else if (!(MID_Native_updateLastError = (*env)->GetStaticMethodID(env, classNative, "updateLastError", "(I)V"))) { throwByName(env, EUnsatisfiedLink, "Can't obtain updateLastError method for class com.sun.jna.Native"); } else if (!(MID_Native_fromNative = (*env)->GetStaticMethodID(env, classNative, "fromNative", "(Ljava/lang/Class;Ljava/lang/Object;)Lcom/sun/jna/NativeMapped;"))) { throwByName(env, EUnsatisfiedLink, "Can't obtain static method fromNative from class com.sun.jna.Native"); } else if (!(MID_Native_nativeType = (*env)->GetStaticMethodID(env, classNative, "nativeType", "(Ljava/lang/Class;)Ljava/lang/Class;"))) { throwByName(env, EUnsatisfiedLink, "Can't obtain static method nativeType from class com.sun.jna.Native"); } else if (!(MID_Native_toNativeTypeMapped = (*env)->GetStaticMethodID(env, classNative, "toNative", "(Lcom/sun/jna/ToNativeConverter;Ljava/lang/Object;)Ljava/lang/Object;"))) { throwByName(env, EUnsatisfiedLink, "Can't obtain static method toNative from class com.sun.jna.Native"); } else if (!(MID_Native_fromNativeTypeMapped = (*env)->GetStaticMethodID(env, classNative, "fromNative", "(Lcom/sun/jna/FromNativeConverter;Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;"))) { throwByName(env, EUnsatisfiedLink, "Can't obtain static method fromNative from class com.sun.jna.Native"); } else if (!LOAD_CREF(env, Structure, "com/sun/jna/Structure")) { throwByName(env, EUnsatisfiedLink, "Can't obtain class com.sun.jna.Structure"); } else if (!LOAD_MID(env, MID_Structure_getTypeInfo, classStructure, "getTypeInfo", "()Lcom/sun/jna/Pointer;")) { throwByName(env, EUnsatisfiedLink, "Can't obtain getTypeInfo method for class com.sun.jna.Structure"); } else if (!(MID_Structure_newInstance = (*env)->GetStaticMethodID(env, classStructure, "newInstance", "(Ljava/lang/Class;)Lcom/sun/jna/Structure;"))) { throwByName(env, EUnsatisfiedLink, "Can't obtain static newInstance method for class com.sun.jna.Structure"); } else if (!LOAD_MID(env, MID_Structure_useMemory, classStructure, "useMemory", "(Lcom/sun/jna/Pointer;)V")) { throwByName(env, EUnsatisfiedLink, "Can't obtain useMemory method for class com.sun.jna.Structure"); } else if (!LOAD_MID(env, MID_Structure_read, classStructure, "autoRead", "()V")) { throwByName(env, EUnsatisfiedLink, "Can't obtain read method for class com.sun.jna.Structure"); } else if (!LOAD_MID(env, MID_Structure_write, classStructure, "autoWrite", "()V")) { throwByName(env, EUnsatisfiedLink, "Can't obtain write method for class com.sun.jna.Structure"); } else if (!LOAD_FID(env, FID_Structure_memory, classStructure, "memory", "Lcom/sun/jna/Pointer;")) { throwByName(env, EUnsatisfiedLink, "Can't obtain memory field ID for class com.sun.jna.Structure"); } else if (!LOAD_FID(env, FID_Structure_typeInfo, classStructure, "typeInfo", "J")) { throwByName(env, EUnsatisfiedLink, "Can't obtain typeInfo field ID for class com.sun.jna.Structure"); } else if (!LOAD_CREF(env, StructureByValue, "com/sun/jna/Structure$ByValue")) { throwByName(env, EUnsatisfiedLink, "Can't obtain class com.sun.jna.Structure.ByValue"); } else if (!LOAD_CREF(env, Callback, "com/sun/jna/Callback")) { throwByName(env, EUnsatisfiedLink, "Can't obtain class com.sun.jna.Callback"); } else if (!LOAD_CREF(env, CallbackReference, "com/sun/jna/CallbackReference")) { throwByName(env, EUnsatisfiedLink, "Can't obtain class com.sun.jna.CallbackReference"); } else if (!(MID_CallbackReference_getCallback = (*env)->GetStaticMethodID(env, classCallbackReference, "getCallback", "(Ljava/lang/Class;Lcom/sun/jna/Pointer;Z)Lcom/sun/jna/Callback;"))) { throwByName(env, EUnsatisfiedLink, "Can't obtain static method getCallback from class com.sun.jna.CallbackReference"); } else if (!(MID_CallbackReference_getFunctionPointer = (*env)->GetStaticMethodID(env, classCallbackReference, "getFunctionPointer", "(Lcom/sun/jna/Callback;Z)Lcom/sun/jna/Pointer;"))) { throwByName(env, EUnsatisfiedLink, "Can't obtain static method getFunctionPointer from class com.sun.jna.CallbackReference"); } else if (!(MID_CallbackReference_getNativeString = (*env)->GetStaticMethodID(env, classCallbackReference, "getNativeString", "(Ljava/lang/Object;Z)Lcom/sun/jna/Pointer;"))) { throwByName(env, EUnsatisfiedLink, "Can't obtain static method getNativeString from class com.sun.jna.CallbackReference"); } else if (!LOAD_CREF(env, WString, "com/sun/jna/WString")) { throwByName(env, EUnsatisfiedLink, "Can't obtain class com.sun.jna.WString"); } else if (!LOAD_CREF(env, NativeMapped, "com/sun/jna/NativeMapped")) { throwByName(env, EUnsatisfiedLink, "Can't obtain class com.sun.jna.NativeMapped"); } else if (!LOAD_MID(env, MID_NativeMapped_toNative, classNativeMapped, "toNative", "()Ljava/lang/Object;")) { throwByName(env, EUnsatisfiedLink, "Can't obtain toNative method for class com.sun.jna.NativeMapped"); } else if (!LOAD_CREF(env, IntegerType, "com/sun/jna/IntegerType")) { throwByName(env, EUnsatisfiedLink, "Can't obtain class com.sun.jna.IntegerType"); } else if (!LOAD_FID(env, FID_IntegerType_value, classIntegerType, "value", "J")) { throwByName(env, EUnsatisfiedLink, "Can't obtain value field ID for class com.sun.jna.IntegerType"); } else if (!LOAD_CREF(env, PointerType, "com/sun/jna/PointerType")) { throwByName(env, EUnsatisfiedLink, "Can't obtain class com.sun.jna.PointerType"); } else if (!LOAD_FID(env, FID_PointerType_pointer, classPointerType, "pointer", "Lcom/sun/jna/Pointer;")) { throwByName(env, EUnsatisfiedLink, "Can't obtain typeInfo field ID for class com.sun.jna.Structure"); } else if (!LOAD_MID(env, MID_WString_init, classWString, "", "(Ljava/lang/String;)V")) { throwByName(env, EUnsatisfiedLink, "Can't obtain constructor for class com.sun.jna.WString"); } else if (!LOAD_CREF(env, _ffi_callback, "com/sun/jna/Native$ffi_callback")) { throwByName(env, EUnsatisfiedLink, "Can't obtain class com.sun.jna.Native$ffi_callback"); } else if (!LOAD_MID(env, MID_ffi_callback_invoke, class_ffi_callback, "invoke", "(JJJ)V")) { throwByName(env, EUnsatisfiedLink, "Can't obtain invoke method from class com.sun.jna.Native$ffi_callback"); } // Initialize type fields within Structure.FFIType else { #define CFFITYPE "com/sun/jna/Structure$FFIType$FFITypes" jclass cls = (*env)->FindClass(env, CFFITYPE); jfieldID fid; unsigned i; const char* fields[] = { "void", "float", "double", "longdouble", "uint8", "sint8", "uint16", "sint16", "uint32", "sint32", "uint64", "sint64", "pointer", }; ffi_type* types[] = { &ffi_type_void, &ffi_type_float, &ffi_type_double, &ffi_type_longdouble, &ffi_type_uint8, &ffi_type_sint8, &ffi_type_uint16, &ffi_type_sint16, &ffi_type_uint32, &ffi_type_sint32, &ffi_type_uint64, &ffi_type_sint64, &ffi_type_pointer, }; char field[32]; if (!cls) { throwByName(env, EUnsatisfiedLink, "Structure$FFIType missing"); return; } for (i=0;i < sizeof(fields)/sizeof(fields[0]);i++) { snprintf(field, sizeof(field), "ffi_type_%s", fields[i]); fid = (*env)->GetStaticFieldID(env, cls, field, "Lcom/sun/jna/Pointer;"); if (!fid) { throwByName(env, EUnsatisfiedLink, field); return; } (*env)->SetStaticObjectField(env, cls, fid, newJavaPointer(env, types[i])); } } } #if !defined(__APPLE__) #define JAWT_HEADLESS_HACK #ifdef _WIN32 #define JAWT_NAME "jawt.dll" #define METHOD_NAME (sizeof(void*)==4?"_JAWT_GetAWT@8":"JAWT_GetAWT") #else #define JAWT_NAME "libjawt.so" #define METHOD_NAME "JAWT_GetAWT" #endif static void* jawt_handle = NULL; static jboolean (JNICALL *pJAWT_GetAWT)(JNIEnv*,JAWT*); #define JAWT_GetAWT (*pJAWT_GetAWT) #endif JNIEXPORT jlong JNICALL Java_com_sun_jna_Native_getWindowHandle0(JNIEnv *env, jclass classp, jobject w) { jlong handle = 0; JAWT_DrawingSurface* ds; JAWT_DrawingSurfaceInfo* dsi; jint lock; JAWT awt; // NOTE: AWT/JAWT must be loaded prior to this code's execution // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6539705 awt.version = JAWT_VERSION_1_4; #ifdef JAWT_HEADLESS_HACK // Java versions 1.5/1.6 throw UnsatisfiedLinkError when run headless // Avoid the issue by dynamic linking if (!pJAWT_GetAWT) { #ifdef _WIN32 // Windows needs the full path to JAWT; calling System.loadLibrary("jawt") // from Java adds it to the path so that a simple LoadLibrary("jawt.dll") // works, but may cause other attempts to load that library from Java to // to get an UnsatisfiedLinkError, reporting that the library is already // loaded in a different class loader, since there is no way to force the // JAWT library by the system class loader. // Use Unicode strings in case the path to the library includes non-ASCII // characters. wchar_t* path = L"jawt.dll"; wchar_t* prop = (wchar_t*)get_system_property(env, "java.home", JNI_TRUE); if (prop != NULL) { const wchar_t* suffix = L"/bin/jawt.dll"; size_t len = wcslen(prop) + wcslen(suffix) + 1; path = (wchar_t*)alloca(len * sizeof(wchar_t)); #ifdef _MSC_VER swprintf(path, len, L"%s%s", prop, suffix); #else swprintf(path, L"%s%s", prop, suffix); #endif free(prop); } #undef JAWT_NAME #define JAWT_NAME path #endif if ((jawt_handle = LOAD_LIBRARY(JAWT_NAME)) == NULL) { char msg[1024]; throwByName(env, EUnsatisfiedLink, LOAD_ERROR(msg, sizeof(msg))); return -1; } if ((pJAWT_GetAWT = (void*)FIND_ENTRY(jawt_handle, METHOD_NAME)) == NULL) { char msg[1024], buf[1024]; snprintf(msg, sizeof(msg), "Error looking up %s: %s", METHOD_NAME, LOAD_ERROR(buf, sizeof(buf))); throwByName(env, EUnsatisfiedLink, msg); return -1; } } #endif if (!JAWT_GetAWT(env, &awt)) { throwByName(env, EUnsatisfiedLink, "Can't load JAWT"); return 0; } ds = awt.GetDrawingSurface(env, w); if (ds == NULL) { throwByName(env, EError, "Can't get drawing surface"); } else { lock = ds->Lock(ds); if ((lock & JAWT_LOCK_ERROR) != 0) { awt.FreeDrawingSurface(ds); throwByName(env, EError, "Can't get drawing surface lock"); return 0; } dsi = ds->GetDrawingSurfaceInfo(ds); if (dsi == NULL) { throwByName(env, EError, "Can't get drawing surface info"); } else { #ifdef _WIN32 JAWT_Win32DrawingSurfaceInfo* wdsi = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; if (wdsi != NULL) { // FIXME this kills the VM if the window is not realized; // if not, wdsi might be a bogus, non-null value // TODO: fix JVM (right) or ensure window is realized (done in Java) handle = A2L(wdsi->hwnd); if (!handle) { throwByName(env, EIllegalState, "Can't get HWND"); } } else { throwByName(env, EError, "Can't get w32 platform info"); } #elif __APPLE__ // WARNING: the view ref is not guaranteed to be stable except during // component paint (see jni_md.h) JAWT_MacOSXDrawingSurfaceInfo* mdsi = (JAWT_MacOSXDrawingSurfaceInfo*)dsi->platformInfo; if (mdsi != NULL) { handle = (unsigned long)mdsi->cocoaViewRef; if (!handle) { throwByName(env, EIllegalState, "Can't get Cocoa View"); } } else { throwByName(env, EError, "Can't get OS X platform info"); } #else JAWT_X11DrawingSurfaceInfo* xdsi = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo; if (xdsi != NULL) { handle = xdsi->drawable; if (!handle) { throwByName(env, EIllegalState, "Can't get Drawable"); } } else { throwByName(env, EError, "Can't get X11 platform info"); } #endif ds->FreeDrawingSurfaceInfo(dsi); } ds->Unlock(ds); awt.FreeDrawingSurface(ds); } return handle; } JNIEXPORT jobject JNICALL Java_com_sun_jna_Native_getDirectBufferPointer(JNIEnv *env, jclass classp, jobject buffer) { void* addr = (*env)->GetDirectBufferAddress(env, buffer); if (addr == NULL) { throwByName(env, EIllegalArgument, "Non-direct Buffer is not supported"); return NULL; } return newJavaPointer(env, addr); } JNIEXPORT void JNICALL Java_com_sun_jna_Native_setProtected(JNIEnv *env, jclass classp, jboolean protect_access) { #ifdef HAVE_PROTECTION _protect = protect_access; #endif } jboolean is_protected() { #ifdef HAVE_PROTECTION if (_protect) return JNI_TRUE; #endif return JNI_FALSE; } JNIEXPORT jboolean JNICALL Java_com_sun_jna_Native_isProtected(JNIEnv *env, jclass classp) { return is_protected(); } JNIEXPORT void JNICALL Java_com_sun_jna_Native_setPreserveLastError(JNIEnv *env, jclass classp, jboolean preserve) { preserve_last_error = preserve; } JNIEXPORT jboolean JNICALL Java_com_sun_jna_Native_getPreserveLastError(JNIEnv *env, jclass classp) { return preserve_last_error; } JNIEXPORT void JNICALL Java_com_sun_jna_Native_setLastError(JNIEnv *env, jclass classp, jint code) { SET_LAST_ERROR(code); update_last_error(env, code); } JNIEXPORT jstring JNICALL Java_com_sun_jna_Native_getNativeVersion(JNIEnv *env, jclass classp) { #ifndef JNA_JNI_VERSION #define JNA_JNI_VERSION "undefined" #endif return newJavaString(env, JNA_JNI_VERSION, JNI_FALSE); } JNIEXPORT jstring JNICALL Java_com_sun_jna_Native_getAPIChecksum(JNIEnv *env, jclass classp) { #ifndef CHECKSUM #define CHECKSUM "undefined" #endif return newJavaString(env, CHECKSUM, JNI_FALSE); } void extract_value(JNIEnv* env, jobject value, void* resp, size_t size, jboolean promote) { if (value == NULL) { *(void **)resp = NULL; } else if ((*env)->IsInstanceOf(env, value, classVoid)) { // nothing to do } else if ((*env)->IsInstanceOf(env, value, classBoolean)) { jboolean b = (*env)->GetBooleanField(env, value, FID_Boolean_value); if (promote) { *(ffi_arg*)resp = b; } else { *(jint*)resp = b; } } else if ((*env)->IsInstanceOf(env, value, classByte)) { jbyte b = (*env)->GetByteField(env, value, FID_Byte_value); if (promote) { *(ffi_arg*)resp = b; } else { *(jbyte*)resp = b; } } else if ((*env)->IsInstanceOf(env, value, classShort)) { jshort s = (*env)->GetShortField(env, value, FID_Short_value); if (promote) { *(ffi_arg*)resp = s; } else { *(jshort*)resp = s; } } else if ((*env)->IsInstanceOf(env, value, classCharacter)) { jchar c = (*env)->GetCharField(env, value, FID_Character_value); if (promote) { *(ffi_arg*)resp = c; } else { *(wchar_t*)resp = c; } } else if ((*env)->IsInstanceOf(env, value, classInteger)) { jint i = (*env)->GetIntField(env, value, FID_Integer_value); if (promote) { *(ffi_arg*)resp = i; } else { *(jint*)resp = i; } } else if ((*env)->IsInstanceOf(env, value, classLong)) { *(jlong *)resp = (*env)->GetLongField(env, value, FID_Long_value); } else if ((*env)->IsInstanceOf(env, value, classFloat)) { *(float *)resp = (*env)->GetFloatField(env, value, FID_Float_value); } else if ((*env)->IsInstanceOf(env, value, classDouble)) { *(double *)resp = (*env)->GetDoubleField(env, value, FID_Double_value); } else if ((*env)->IsInstanceOf(env, value, classStructure)) { void* ptr = getStructureAddress(env, value); memcpy(resp, ptr, size); } else if ((*env)->IsInstanceOf(env, value, classPointer)) { *(void **)resp = getNativeAddress(env, value); } else { fprintf(stderr, "JNA: unrecognized return type, size %d\n", (int)size); memset(resp, 0, size); } } /** Construct a new Java object from a native value. */ jobject new_object(JNIEnv* env, char jtype, void* valuep, jboolean promote) { switch(jtype) { case 's': return newJavaPointer(env, valuep); case '*': return newJavaPointer(env, *(void**)valuep); case 'J': return (*env)->NewObject(env, classLong, MID_Long_init, *(jlong *)valuep); case 'F': return (*env)->NewObject(env, classFloat, MID_Float_init, *(float *)valuep); case 'D': return (*env)->NewObject(env, classDouble, MID_Double_init, *(double *)valuep); case 'Z': // Default mapping for boolean is int32_t return (*env)->NewObject(env, classBoolean, MID_Boolean_init, (promote ? (jint)*(ffi_arg*)valuep : (*(jint *)valuep)) ? JNI_TRUE : JNI_FALSE); case 'B': return (*env)->NewObject(env, classByte, MID_Byte_init, promote ? (jbyte)*(ffi_arg*)valuep : (*(jbyte *)valuep)); case 'C': return (*env)->NewObject(env, classCharacter, MID_Character_init, promote ? (jchar)*(ffi_arg*)valuep : (jchar)(*(wchar_t *)valuep)); case 'S': return (*env)->NewObject(env, classShort, MID_Short_init, promote ? (jshort)*(ffi_arg*)valuep : (*(jshort *)valuep)); case 'I': return (*env)->NewObject(env, classInteger, MID_Integer_init, promote ? (jint)*(ffi_arg*)valuep : *(jint *)valuep); default: return NULL; } } JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { JNIEnv* env; int result = JNI_VERSION_1_4; int attached = (*jvm)->GetEnv(jvm, (void *)&env, JNI_VERSION_1_4) == JNI_OK; const char* err; if (!attached) { if ((*jvm)->AttachCurrentThread(jvm, (void *)&env, NULL) != JNI_OK) { fprintf(stderr, "JNA: Can't attach to JVM thread on load\n"); return 0; } } if ((err = jnidispatch_init(env)) != NULL) { fprintf(stderr, "JNA: Problems loading core IDs: %s\n", err); result = 0; } else if ((err = jnidispatch_callback_init(env)) != NULL) { fprintf(stderr, "JNA: Problems loading callback IDs: %s\n", err); result = 0; } if (!attached) { (*jvm)->DetachCurrentThread(jvm); } return result; } JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) { jobject* refs[] = { &classObject, &classClass, &classMethod, &classString, &classBuffer, &classByteBuffer, &classCharBuffer, &classShortBuffer, &classIntBuffer, &classLongBuffer, &classFloatBuffer, &classDoubleBuffer, &classVoid, &classPrimitiveVoid, &classBoolean, &classPrimitiveBoolean, &classByte, &classPrimitiveByte, &classCharacter, &classPrimitiveCharacter, &classShort, &classPrimitiveShort, &classInteger, &classPrimitiveInteger, &classLong, &classPrimitiveLong, &classFloat, &classPrimitiveFloat, &classDouble, &classPrimitiveDouble, &classPointer, &classNative, &classWString, &classStructure, &classStructureByValue, &classCallbackReference, &classNativeMapped, &classIntegerType, &classPointerType, }; unsigned i; JNIEnv* env; int attached = (*vm)->GetEnv(vm, (void*)&env, JNI_VERSION_1_4) == JNI_OK; if (!attached) { if ((*vm)->AttachCurrentThread(vm, (void*)&env, NULL) != JNI_OK) { fprintf(stderr, "JNA: Can't attach to JVM thread on unload\n"); return; } } for (i=0;i < sizeof(refs)/sizeof(refs[0]);i++) { if (*refs[i]) { (*env)->DeleteWeakGlobalRef(env, *refs[i]); *refs[i] = NULL; } } jnidispatch_callback_dispose(env); #ifdef JAWT_HEADLESS_HACK if (jawt_handle != NULL) { FREE_LIBRARY(jawt_handle); jawt_handle = NULL; pJAWT_GetAWT = NULL; } #endif if (jna_encoding) { free((void*)jna_encoding); } if (!attached) { (*vm)->DetachCurrentThread(vm); } } /** Get the FFI type for the native type which will be converted to the given Java class. */ ffi_type* get_ffi_type(JNIEnv* env, jclass cls, char jtype) { switch (jtype) { case 'Z': return &ffi_type_uint32; case 'B': return &ffi_type_sint8; case 'C': return sizeof(wchar_t) == 2 ? &ffi_type_uint16 : &ffi_type_uint32; case 'S': return &ffi_type_sint16; case 'I': return &ffi_type_sint32; case 'J': return &ffi_type_sint64; case 'F': return &ffi_type_float; case 'D': return &ffi_type_double; case 'V': return &ffi_type_void; case 's': { jobject s = (*env)->CallStaticObjectMethod(env, classStructure, MID_Structure_newInstance, cls); return getStructureType(env, s); } case '*': default: return &ffi_type_pointer; } } /** Return the FFI type corresponding to the native equivalent of a callback function's return value. */ ffi_type* get_ffi_rtype(JNIEnv* env, jclass cls, char jtype) { switch (jtype) { case 'Z': case 'B': case 'C': case 'S': case 'I': /* * Always use a return type the size of a cpu register. This fixes up * callbacks on big-endian 64bit machines, and does not break things on * i386 or amd64. */ return &ffi_type_slong; default: return get_ffi_type(env, cls, jtype); } } typedef struct _method_data { ffi_cif cif; ffi_cif closure_cif; void* fptr; ffi_type** arg_types; ffi_type** closure_arg_types; int* flags; int rflag; jclass closure_rclass; jobject* to_native; jobject from_native; jboolean throw_last_error; } method_data; // VM vectors to this callback, which calls native code static void method_handler(ffi_cif* cif, void* volatile resp, void** argp, void *cdata) { JNIEnv* env = (JNIEnv*)*(void **)argp[0]; method_data *data = (method_data*)cdata; // ignore first two arguments, which are pointers void** args = argp + 2; void** volatile objects = NULL; release_t* volatile release = NULL; void** volatile elems = NULL; unsigned i; void* oldresp = resp; const char* volatile throw_type = NULL; const char* volatile throw_msg = NULL; char msg[64]; if (data->flags) { objects = alloca(data->cif.nargs * sizeof(void*)); memset(objects, 0, data->cif.nargs * sizeof(void*)); release = alloca(data->cif.nargs * sizeof(release_t)); memset(release, 0, data->cif.nargs * sizeof(release_t)); elems = alloca(data->cif.nargs * sizeof(void*)); for (i=0;i < data->cif.nargs;i++) { if (data->flags[i] == CVT_DEFAULT) { continue; } if (data->arg_types[i]->type == FFI_TYPE_POINTER && *(void **)args[i] == NULL) { continue; } switch(data->flags[i]) { case CVT_INTEGER_TYPE: { jlong value = getIntegerTypeValue(env, *(void **)args[i]); if (cif->arg_types[i+2]->size < data->cif.arg_types[i]->size) { args[i] = alloca(data->cif.arg_types[i]->size); } if (data->cif.arg_types[i]->size > sizeof(ffi_arg)) { *(jlong *)args[i] = value; } else { *(ffi_arg *)args[i] = (ffi_arg)value; } } break; case CVT_POINTER_TYPE: *(void **)args[i] = getPointerTypeAddress(env, *(void **)args[i]); break; case CVT_TYPE_MAPPER: { void* valuep = args[i]; int jtype = get_jtype_from_ffi_type(data->closure_cif.arg_types[i+2]); jobject obj = jtype == '*' ? *(void **)valuep : new_object(env, (char)jtype, valuep, JNI_FALSE); if (cif->arg_types[i+2]->size < data->cif.arg_types[i]->size) { args[i] = alloca(data->cif.arg_types[i]->size); } toNativeTypeMapped(env, obj, args[i], data->cif.arg_types[i]->size, data->to_native[i]); } break; case CVT_NATIVE_MAPPED: toNative(env, *(void **)args[i], args[i], data->cif.arg_types[i]->size, JNI_FALSE); break; case CVT_POINTER: *(void **)args[i] = getNativeAddress(env, *(void **)args[i]); break; case CVT_STRUCTURE: objects[i] = *(void **)args[i]; writeStructure(env, *(void **)args[i]); *(void **)args[i] = getStructureAddress(env, *(void **)args[i]); break; case CVT_STRUCTURE_BYVAL: objects[i] = *(void **)args[i]; writeStructure(env, objects[i]); args[i] = getStructureAddress(env, objects[i]); break; case CVT_STRING: *(void **)args[i] = newCStringEncoding(env, (jstring)*(void **)args[i], jna_encoding); break; case CVT_WSTRING: { jstring s = (*env)->CallObjectMethod(env, *(void **)args[i], MID_Object_toString); *(void **)args[i] = newWideCString(env, s); } break; case CVT_CALLBACK: *(void **)args[i] = getCallbackAddress(env, *(void **)args[i]); break; case CVT_BUFFER: { void *ptr = (*env)->GetDirectBufferAddress(env, *(void **)args[i]); if (ptr != NULL) { objects[i] = NULL; release[i] = NULL; } else { ptr = getBufferArray(env, *(jobject *)args[i], (jobject *)&objects[i], &elems[i], (void**)&release[i]); if (ptr == NULL) { throw_type = EIllegalArgument; throw_msg = "Buffer arguments must be direct or have a primitive backing array"; goto cleanup; } } *(void **)args[i] = ptr; } break; #define ARRAY(Type) \ do { \ objects[i] = *(void **)args[i]; \ release[i] = (void *)(*env)->Release##Type##ArrayElements; \ elems[i] = *(void **)args[i] = (*env)->Get##Type##ArrayElements(env, objects[i], NULL); } while(0) case CVT_ARRAY_BYTE: ARRAY(Byte); break; case CVT_ARRAY_SHORT: ARRAY(Short); break; case CVT_ARRAY_CHAR: ARRAY(Char); break; case CVT_ARRAY_INT: ARRAY(Int); break; case CVT_ARRAY_LONG: ARRAY(Long); break; case CVT_ARRAY_FLOAT: ARRAY(Float); break; case CVT_ARRAY_DOUBLE: ARRAY(Double); break; default: break; } } } if (data->rflag == CVT_NATIVE_MAPPED) { resp = alloca(sizeof(jobject)); } else if (data->rflag == CVT_TYPE_MAPPER) { // Ensure enough space for the inner call result resp = alloca(data->cif.rtype->size); } else if (data->rflag == CVT_STRUCTURE_BYVAL) { // In the case of returned structure by value, the inner and // outer calls have different return types; we pass the structure memory // to the inner call but return a Java object to the outer call. resp = alloca(data->cif.rtype->size); } { PSTART(); if (data->throw_last_error) { SET_LAST_ERROR(0); } ffi_call(&data->cif, FFI_FN(data->fptr), resp, args); if (data->throw_last_error) { int error = GET_LAST_ERROR(); if (error) { snprintf(msg, sizeof(msg), "%d", error); throw_type = ELastError; throw_msg = msg; } } PROTECTED_END(do { throw_type=EError;throw_msg="Invalid memory access"; } while(0)); } switch(data->rflag) { case CVT_TYPE_MAPPER: fromNativeTypeMapped(env, data->from_native, resp, data->cif.rtype, data->closure_rclass, oldresp); break; case CVT_INTEGER_TYPE: case CVT_POINTER_TYPE: case CVT_NATIVE_MAPPED: *(void **)oldresp = fromNative(env, data->closure_rclass, data->cif.rtype, resp, JNI_TRUE); break; case CVT_POINTER: *(void **)resp = newJavaPointer(env, *(void **)resp); break; case CVT_STRING: *(void **)resp = newJavaString(env, *(void **)resp, JNI_FALSE); break; case CVT_WSTRING: *(void **)resp = newJavaWString(env, *(void **)resp); break; case CVT_STRUCTURE: *(void **)resp = newJavaStructure(env, *(void **)resp, data->closure_rclass, JNI_FALSE); break; case CVT_STRUCTURE_BYVAL: *(void **)oldresp = newJavaStructure(env, resp, data->closure_rclass, JNI_TRUE); break; case CVT_CALLBACK: *(void **)resp = newJavaCallback(env, *(void **)resp, data->closure_rclass); break; default: break; } cleanup: if (data->flags) { for (i=0;i < data->cif.nargs;i++) { switch(data->flags[i]) { case CVT_STRUCTURE: if (objects[i]) { (*env)->CallVoidMethod(env, objects[i], MID_Structure_read); } break; case CVT_STRING: case CVT_WSTRING: // Free allocated native strings free(*(void **)args[i]); break; case CVT_BUFFER: case CVT_ARRAY_BYTE: case CVT_ARRAY_SHORT: case CVT_ARRAY_CHAR: case CVT_ARRAY_INT: case CVT_ARRAY_LONG: case CVT_ARRAY_FLOAT: case CVT_ARRAY_DOUBLE: if (*(void **)args[i] && release[i]) release[i](env, objects[i], elems[i], 0); break; } } } if (throw_type) { throwByName(env, throw_type, throw_msg); } } JNIEXPORT void JNICALL Java_com_sun_jna_Native_unregister(JNIEnv *env, jclass ncls, jclass cls, jlongArray handles) { jlong* data = (*env)->GetLongArrayElements(env, handles, NULL); int count = (*env)->GetArrayLength(env, handles); while (count-- > 0) { method_data* md = (method_data*)L2A(data[count]); if (md->to_native) { unsigned i; for (i=0;i < md->cif.nargs;i++) { if (md->to_native[i]) (*env)->DeleteWeakGlobalRef(env, md->to_native[i]); } } if (md->from_native) (*env)->DeleteWeakGlobalRef(env, md->from_native); if (md->closure_rclass) (*env)->DeleteWeakGlobalRef(env, md->closure_rclass); free(md->arg_types); free(md->closure_arg_types); free(md->flags); free(md); } (*env)->ReleaseLongArrayElements(env, handles, data, 0); // Not required, or recommended (see description in JNI docs, // http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/functions.html //(*env)->UnregisterNatives(env, cls); } JNIEXPORT jlong JNICALL Java_com_sun_jna_Native_registerMethod(JNIEnv *env, jclass ncls, jclass cls, jstring name, jstring signature, jintArray conversions, jlongArray closure_atypes, jlongArray atypes, jint rconversion, jlong closure_return_type, jlong return_type, jclass closure_rclass, jlong function, jint cc, jboolean throw_last_error, jobjectArray to_native, jobject from_native) { int argc = atypes ? (*env)->GetArrayLength(env, atypes) : 0; const char* cname = newCStringUTF8(env, name); const char* sig = newCStringUTF8(env, signature); void *code; void *closure; method_data* data = malloc(sizeof(method_data)); ffi_cif* closure_cif = &data->closure_cif; int status; int i; int abi = FFI_DEFAULT_ABI; ffi_type* rtype = (ffi_type*)L2A(return_type); ffi_type* closure_rtype = (ffi_type*)L2A(closure_return_type); jlong* types = atypes ? (*env)->GetLongArrayElements(env, atypes, NULL) : NULL; jlong* closure_types = closure_atypes ? (*env)->GetLongArrayElements(env, closure_atypes, NULL) : NULL; jint* cvts = conversions ? (*env)->GetIntArrayElements(env, conversions, NULL) : NULL; #if defined(_WIN32) && !defined(_WIN64) if (cc == CALLCONV_STDCALL) abi = FFI_STDCALL; #endif data->throw_last_error = throw_last_error; data->arg_types = malloc(sizeof(ffi_type*) * argc); data->closure_arg_types = malloc(sizeof(ffi_type*) * (argc + 2)); data->closure_arg_types[0] = &ffi_type_pointer; data->closure_arg_types[1] = &ffi_type_pointer; data->closure_rclass = NULL; data->flags = cvts ? malloc(sizeof(jint)*argc) : NULL; data->rflag = rconversion; data->to_native = NULL; data->from_native = from_native ? (*env)->NewWeakGlobalRef(env, from_native) : NULL; for (i=0;i < argc;i++) { data->closure_arg_types[i+2] = (ffi_type*)L2A(closure_types[i]); data->arg_types[i] = (ffi_type*)L2A(types[i]); if (cvts) { data->flags[i] = cvts[i]; // Type mappers only apply to non-primitive arguments if (cvts[i] == CVT_TYPE_MAPPER) { if (!data->to_native) { data->to_native = calloc(argc, sizeof(jweak)); } data->to_native[i] = (*env)->NewWeakGlobalRef(env, (*env)->GetObjectArrayElement(env, to_native, i)); } } } if (types) (*env)->ReleaseLongArrayElements(env, atypes, types, 0); if (closure_types) (*env)->ReleaseLongArrayElements(env, closure_atypes, closure_types, 0); if (cvts) (*env)->ReleaseIntArrayElements(env, conversions, cvts, 0); data->fptr = L2A(function); data->closure_rclass = (*env)->NewWeakGlobalRef(env, closure_rclass); status = ffi_prep_cif(closure_cif, abi, argc+2, closure_rtype, data->closure_arg_types); if (ffi_error(env, "Native method mapping", status)) { goto cleanup; } status = ffi_prep_cif(&data->cif, abi, argc, rtype, data->arg_types); if (ffi_error(env, "Native method setup", status)) { goto cleanup; } closure = ffi_closure_alloc(sizeof(ffi_closure), &code); status = ffi_prep_closure_loc(closure, closure_cif, method_handler, data, code); if (status != FFI_OK) { throwByName(env, EError, "Native method linkage failed"); goto cleanup; } { JNINativeMethod m = { (char*)cname, (char*)sig, code }; (*env)->RegisterNatives(env, cls, &m, 1); } cleanup: if (status != FFI_OK) { free(data->arg_types); free(data->flags); free(data); data = NULL; } free((void *)cname); free((void *)sig); return A2L(data); } JNIEXPORT void JNICALL Java_com_sun_jna_Native_ffi_1call(JNIEnv *env, jclass cls, jlong cif, jlong fptr, jlong resp, jlong args) { ffi_call(L2A(cif), FFI_FN(L2A(fptr)), L2A(resp), L2A(args)); } JNIEXPORT jlong JNICALL Java_com_sun_jna_Native_ffi_1prep_1cif(JNIEnv *env, jclass cls, jint abi, jint nargs, jlong ffi_return_type, jlong ffi_types) { ffi_cif* cif = malloc(sizeof(ffi_cif)); ffi_status s = ffi_prep_cif(L2A(cif), abi, nargs, L2A(ffi_return_type), L2A(ffi_types)); if (ffi_error(env, "ffi_prep_cif", s)) { return 0; } return A2L(cif); } static void closure_handler(ffi_cif* cif, void* resp, void** argp, void *cdata) { callback* cb = (callback *)cdata; JavaVM* jvm = cb->vm; JNIEnv* env; jobject obj; int attached; attached = (*jvm)->GetEnv(jvm, (void *)&env, JNI_VERSION_1_4) == JNI_OK; if (!attached) { if ((*jvm)->AttachCurrentThread(jvm, (void *)&env, NULL) != JNI_OK) { fprintf(stderr, "JNA: Can't attach to current thread\n"); return; } } // Give the callback its own local frame to ensure all local references // are properly disposed if ((*env)->PushLocalFrame(env, 16) < 0) { fprintf(stderr, "JNA: Out of memory: Can't allocate local frame"); } else { obj = (*env)->NewLocalRef(env, cb->object); if ((*env)->IsSameObject(env, obj, NULL)) { fprintf(stderr, "JNA: callback object has been garbage collected\n"); if (cif->rtype->type != FFI_TYPE_VOID) memset(resp, 0, cif->rtype->size); } else { (*env)->CallVoidMethod(env, obj, MID_ffi_callback_invoke, A2L(cif), A2L(resp), A2L(argp)); } (*env)->PopLocalFrame(env, NULL); } if (!attached) { (*jvm)->DetachCurrentThread(jvm); } } JNIEXPORT jlong JNICALL Java_com_sun_jna_Native_ffi_1prep_1closure(JNIEnv *env, jclass cls, jlong cif, jobject obj) { callback* cb = (callback *)malloc(sizeof(callback)); ffi_status s; if ((*env)->GetJavaVM(env, &cb->vm) != JNI_OK) { throwByName(env, EUnsatisfiedLink, "Can't get Java VM"); return 0; } cb->object = (*env)->NewWeakGlobalRef(env, obj); cb->closure = ffi_closure_alloc(sizeof(ffi_closure), L2A(&cb->x_closure)); s = ffi_prep_closure_loc(cb->closure, L2A(cif), &closure_handler, cb, cb->x_closure); if (ffi_error(env, "ffi_prep_cif", s)) { return 0; } return A2L(cb); } JNIEXPORT void JNICALL Java_com_sun_jna_Native_ffi_1free_1closure(JNIEnv *env, jclass cls, jlong closure) { callback* cb = (callback *)L2A(closure); (*env)->DeleteWeakGlobalRef(env, cb->object); ffi_closure_free(cb->closure); free(cb); } JNIEXPORT jint JNICALL Java_com_sun_jna_Native_initialize_1ffi_1type(JNIEnv *env, jclass cls, jlong type_info) { ffi_type* type = L2A(type_info); ffi_cif cif; ffi_status status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, type, NULL); if (ffi_error(env, "ffi_prep_cif", status)) { return 0; } return (jint)type->size; } #ifdef __cplusplus } #endif libjna-java-3.2.7/native/testlib.c0000644000175000017500000004070311235774010015107 0ustar janjan/* Copyright (c) 2007-2008 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. *

* 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. */ /* Native library implementation to support JUnit tests. */ #ifdef __cplusplus extern "C" { #endif #include #include #include #include #ifdef _MSC_VER typedef signed char int8_t; typedef short int16_t; typedef int int32_t; typedef __int64 int64_t; #else #include #endif #ifdef _WIN32 #ifndef UNICODE #define UNICODE #endif #define WIN32_LEAN_AND_MEAN #include #define EXPORT __declspec(dllexport) #else #define EXPORT #endif #ifdef _MSC_VER #define LONG(X) X ## I64 #elif __GNUC__ #define LONG(X) X ## LL #else #error 64-bit type not defined for this compiler #endif #define MAGICSTRING "magic"; #define MAGICWSTRING L"magic" #define MAGIC32 0x12345678L #define MAGIC64 LONG(0x123456789ABCDEF0) #define MAGICFLOAT -118.625 #define MAGICDOUBLE ((double)(-118.625)) #define MAGICDATA "0123456789" EXPORT int test_global = MAGIC32; // TODO: check more fields/alignments struct CheckFieldAlignment { int8_t int8Field; int16_t int16Field; int32_t int32Field; int64_t int64Field; float floatField; double doubleField; }; static int _callCount; EXPORT void setLastError(int err) { #ifdef _WIN32 SetLastError(err); #else errno = err; #endif } EXPORT int callCount() { return ++_callCount; } EXPORT int returnFalse() { return 0; } EXPORT int returnTrue() { return -1; } EXPORT int returnBooleanArgument(int arg) { return arg; } EXPORT int8_t returnInt8Argument(int8_t arg) { return arg; } EXPORT wchar_t returnWideCharArgument(wchar_t arg) { return arg; } EXPORT int16_t returnInt16Argument(int16_t arg) { return arg; } EXPORT int32_t returnInt32Zero() { int32_t value = 0; return value; } EXPORT int32_t returnInt32Magic() { int32_t value = MAGIC32; return value; } EXPORT int32_t returnInt32Argument(int32_t arg) { return arg; } EXPORT int64_t returnInt64Zero() { int64_t value = 0; return value; } EXPORT int64_t returnInt64Magic() { int64_t value = MAGIC64; return value; } EXPORT int64_t returnInt64Argument(int64_t arg) { return arg; } EXPORT long returnLongZero() { long value = 0; return value; } EXPORT long returnLongMagic() { long value = sizeof(long) == 4 ? MAGIC32 : MAGIC64; return value; } EXPORT long returnLongArgument(long arg) { return arg; } EXPORT float returnFloatZero() { float value = 0.0; return value; } EXPORT float returnFloatMagic() { float value = MAGICFLOAT; return value; } EXPORT float returnFloatArgument(float arg) { return arg; } EXPORT double returnDoubleZero() { double value = (double)0.0; return value; } EXPORT double returnDoubleMagic() { double value = MAGICDOUBLE; return value; } EXPORT double returnDoubleArgument(double arg) { return arg; } EXPORT void* returnPointerArgument(void *arg) { return arg; } EXPORT char* returnStringMagic() { return MAGICSTRING; } EXPORT char* returnStringArgument(char *arg) { return arg; } EXPORT void* returnObjectArgument(void* arg) { return arg; } EXPORT wchar_t* returnWStringMagic() { return MAGICWSTRING; } EXPORT wchar_t* returnWStringArgument(wchar_t *arg) { return arg; } EXPORT char* returnStringArrayElement(char* args[], int which) { return args[which]; } EXPORT wchar_t* returnWideStringArrayElement(wchar_t* args[], int which) { return args[which]; } EXPORT void* returnPointerArrayElement(void* args[], int which) { return args[which]; } EXPORT int returnRotatedArgumentCount(char* args[]) { int count = 0; char* first = args[0]; while (args[count] != NULL) { ++count; args[count-1] = args[count] ? args[count] : first; } return count; } typedef struct _TestStructure { double value; } TestStructure; EXPORT TestStructure* returnStaticTestStructure() { static TestStructure test_structure; test_structure.value = MAGICDOUBLE; return &test_structure; } EXPORT TestStructure* returnNullTestStructure() { return NULL; } typedef struct _VariableSizedStructure { int length; char buffer[1]; } VariableSizedStructure; EXPORT char* returnStringFromVariableSizedStructure(VariableSizedStructure* s) { return s->buffer; } typedef struct _TestAmallStructureByValue { int8_t c1; int8_t c2; int16_t s; } TestSmallStructureByValue; EXPORT TestSmallStructureByValue returnSmallStructureByValue() { TestSmallStructureByValue v; v.c1 = 1; v.c2 = 2; v.s = 3; return v; } typedef struct _TestStructureByValue { int8_t c; int16_t s; int32_t i; int64_t j; TestStructure inner; } TestStructureByValue; EXPORT TestStructureByValue returnStructureByValue() { TestStructureByValue v; v.c = 1; v.s = 2; v.i = 3; v.j = 4; v.inner.value = 5; return v; } typedef void (*callback_t)(); typedef int32_t (*int32_callback_t)(int32_t); typedef callback_t (*cb_callback_t)(callback_t); EXPORT int32_callback_t returnCallback() { return &returnInt32Argument; } EXPORT int32_callback_t returnCallbackArgument(int32_callback_t arg) { return arg; } EXPORT void incrementInt8ByReference(int8_t *arg) { if (arg) ++*arg; } EXPORT void incrementInt16ByReference(int16_t *arg) { if (arg) ++*arg; } EXPORT void incrementInt32ByReference(int32_t *arg) { if (arg) ++*arg; } EXPORT void incrementNativeLongByReference(long *arg) { if (arg) ++*arg; } EXPORT void incrementInt64ByReference(int64_t *arg) { if (arg) ++*arg; } EXPORT void complementFloatByReference(float *arg) { if (arg) *arg = -*arg; } EXPORT void complementDoubleByReference(double *arg) { if (arg) *arg = -*arg; } EXPORT void setPointerByReferenceNull(void **arg) { if (arg) *arg = NULL; } EXPORT int64_t checkInt64ArgumentAlignment(int32_t i, int64_t j, int32_t i2, int64_t j2) { if (i != 0x10101010 || j != LONG(0x1111111111111111) || i2 != 0x01010101 || j2 != LONG(0x2222222222222222)) return -1; return i + j + i2 + j2; } EXPORT double checkDoubleArgumentAlignment(float f, double d, float f2, double d2) { // float: 1=3f800000 2=40000000 3=40400000 4=40800000 // double: 1=3ff00... 2=40000... 3=40080... 4=40100... if (f != 1 || d != 2 || f2 != 3 || d2 != 4) return -1; return f + d + f2 + d2; } EXPORT void* testStructurePointerArgument(struct CheckFieldAlignment* arg) { return arg; } EXPORT double testStructureByValueArgument(struct CheckFieldAlignment arg) { return arg.int8Field + arg.int16Field + arg.int32Field + arg.int64Field + arg.floatField + arg.doubleField; } typedef struct ByValue8 { int8_t data; } ByValue8; typedef struct ByValue16 { int16_t data; } ByValue16; typedef struct ByValue32 { int32_t data; } ByValue32; typedef struct ByValue64 { int64_t data; } ByValue64; typedef struct ByValue128 { int64_t data, data1; } ByValue128; EXPORT int8_t testStructureByValueArgument8(struct ByValue8 arg){ return arg.data; } EXPORT int16_t testStructureByValueArgument16(struct ByValue16 arg){ return arg.data; } EXPORT int32_t testStructureByValueArgument32(struct ByValue32 arg){ return arg.data; } EXPORT int64_t testStructureByValueArgument64(struct ByValue64 arg){ return arg.data; } EXPORT int64_t testStructureByValueArgument128(struct ByValue128 arg){ return arg.data + arg.data1; } typedef union _test_union_t { // Use non-primitive fields, doesn't matter what they are char* f1; int32_t f2; } test_union_t; typedef test_union_t (*test_union_cb_t)(test_union_t arg); EXPORT test_union_t testUnionByValueCallbackArgument(test_union_cb_t cb, test_union_t arg) { return (*cb)(arg); } typedef struct { int8_t field0; int16_t field1; } Align16BitField8; typedef struct { int8_t field0; int32_t field1; } Align32BitField8; typedef struct { int16_t field0; int32_t field1; } Align32BitField16; typedef struct { int32_t field0; int16_t field1; int32_t field2; } Align32BitField16_2; typedef struct { int32_t field0; int64_t field1; int32_t field2; int64_t field3; } Align64BitField32; typedef struct { int64_t field0; int8_t field1; } PadTrailingSmallField; static int STRUCT_SIZES[] = { sizeof(Align16BitField8), sizeof(Align32BitField8), sizeof(Align32BitField16), sizeof(Align32BitField16_2), sizeof(Align64BitField32), sizeof(PadTrailingSmallField), }; EXPORT int32_t getStructureSize(unsigned index) { if (index >= (int)sizeof(STRUCT_SIZES)/sizeof(STRUCT_SIZES[0])) return -1; return STRUCT_SIZES[index]; } extern void exit(int); #define FIELD(T,X,N) (((T*)X)->field ## N) #define OFFSET(T,X,N) (int)(((char*)&FIELD(T,X,N))-((char*)&FIELD(T,X,0))) #define V8(N) (N+1) #define V16(N) ((((int32_t)V8(N))<<8)|V8(N)) #define V32(N) ((((int32_t)V16(N))<<16)|V16(N)) #define V64(N) ((((int64_t)V32(N))<<32)|V32(N)) #define VALUE(T,X,N) \ ((sizeof(FIELD(T,X,N)) == 1) \ ? V8(N) : ((sizeof(FIELD(T,X,N)) == 2) \ ? V16(N) : ((sizeof(FIELD(T,X,N)) == 4) \ ? V32(N) : V64(N)))) #define VALIDATE_FIELDN(T,X,N) \ do { if (FIELD(T,X,N) != VALUE(T,X,N)) {*offsetp=OFFSET(T,X,N); *valuep=FIELD(T,X,N); return N;} } while (0) #define VALIDATE1(T,X) VALIDATE_FIELDN(T,X,0) #define VALIDATE2(T,X) do { VALIDATE1(T,X); VALIDATE_FIELDN(T,X,1); } while(0) #define VALIDATE3(T,X) do { VALIDATE2(T,X); VALIDATE_FIELDN(T,X,2); } while(0) #define VALIDATE4(T,X) do { VALIDATE3(T,X); VALIDATE_FIELDN(T,X,3); } while(0) // returns the field index which failed, and the expected field offset // returns -2 on success EXPORT int32_t testStructureAlignment(void* s, unsigned index, int* offsetp, int64_t* valuep) { if (index >= sizeof(STRUCT_SIZES)/sizeof(STRUCT_SIZES[0])) return -1; switch(index) { case 0: VALIDATE2(Align16BitField8,s); break; case 1: VALIDATE2(Align32BitField8,s); break; case 2: VALIDATE2(Align32BitField16,s); break; case 3: VALIDATE3(Align32BitField16_2,s); break; case 4: VALIDATE4(Align64BitField32,s); break; case 5: VALIDATE2(PadTrailingSmallField,s); break; } return -2; } EXPORT int32_t testStructureArrayInitialization(struct CheckFieldAlignment arg[], int len) { int i; for (i=0;i < len;i++) { if (arg[i].int32Field != i) return i; } return -1; } EXPORT void modifyStructureArray(struct CheckFieldAlignment arg[], int length) { int i; for (i=0;i < length;i++) { arg[i].int32Field = i; arg[i].int64Field = i+1; arg[i].floatField = (float)i+2; arg[i].doubleField = (double)i+3; } } EXPORT void callVoidCallback(void (*func)(void)) { (*func)(); } EXPORT int callBooleanCallback(int (*func)(int arg, int arg2), int arg, int arg2) { return (*func)(arg, arg2); } EXPORT int8_t callInt8Callback(int8_t (*func)(int8_t arg, int8_t arg2), int8_t arg, int8_t arg2) { return (*func)(arg, arg2); } EXPORT int16_t callInt16Callback(int16_t (*func)(int16_t arg, int16_t arg2), int16_t arg, int16_t arg2) { return (*func)(arg, arg2); } EXPORT int32_t callInt32Callback(int32_t (*func)(int32_t arg, int32_t arg2), int32_t arg, int32_t arg2) { return (*func)(arg, arg2); } EXPORT int32_t callInt32CallbackRepeatedly(int32_t (*func)(int32_t arg, int32_t arg2), int32_t arg, int32_t arg2, int32_t count) { int i; int sum = 0; for (i=0;i < count;i++) { sum += (*func)(arg, arg2); } return sum; } EXPORT long callLongCallbackRepeatedly(long (*func)(long arg, long arg2), long arg, long arg2, int32_t count) { int i; long sum = 0; for (i=0;i < count;i++) { sum += (*func)(arg, arg2); } return sum; } EXPORT long callNativeLongCallback(long (*func)(long arg, long arg2), long arg, long arg2) { return (*func)(arg, arg2); } EXPORT int64_t callInt64Callback(int64_t (*func)(int64_t arg, int64_t arg2), int64_t arg, int64_t arg2) { return (*func)(arg, arg2); } EXPORT float callFloatCallback(float (*func)(float arg, float arg2), float arg, float arg2) { return (*func)(arg, arg2); } EXPORT double callDoubleCallback(double (*func)(double arg, double arg2), double arg, double arg2) { return (*func)(arg, arg2); } EXPORT TestStructure* callStructureCallback(TestStructure* (*func)(TestStructure*), TestStructure* arg) { return (*func)(arg); } EXPORT int callCallbackWithByReferenceArgument(int (*func)(int arg, int* result), int arg, int* result) { return (*func)(arg, result); } EXPORT char* callStringCallback(char* (*func)(char* arg), char* arg) { return (*func)(arg); } EXPORT char** callStringArrayCallback(char** (*func)(char** arg), char** arg) { return (*func)(arg); } EXPORT wchar_t* callWideStringCallback(wchar_t* (*func)(wchar_t* arg), wchar_t* arg) { return (*func)(arg); } struct cbstruct { void (*func)(void); }; EXPORT void callCallbackInStruct(struct cbstruct *cb) { (*cb->func)(); } EXPORT TestStructureByValue callCallbackWithStructByValue(TestStructureByValue (*func)(TestStructureByValue), TestStructureByValue s) { return (*func)(s); } EXPORT callback_t callCallbackWithCallback(cb_callback_t cb) { return (*cb)((callback_t)cb); } static int32_t structCallbackFunction(int32_t arg1, int32_t arg2) { return arg1 + arg2; } EXPORT void setCallbackInStruct(struct cbstruct* cb) { cb->func = (void (*)(void))structCallbackFunction; } EXPORT int32_t fillInt8Buffer(int8_t *buf, int len, char value) { int i; for (i=0;i < len;i++) { buf[i] = value; } return len; } EXPORT int32_t fillInt16Buffer(int16_t *buf, int len, short value) { int i; for (i=0;i < len;i++) { buf[i] = value; } return len; } EXPORT int32_t fillInt32Buffer(int32_t *buf, int len, int32_t value) { int i; for (i=0;i < len;i++) { buf[i] = value; } return len; } EXPORT int32_t fillInt64Buffer(int64_t *buf, int len, int64_t value) { int i; for (i=0;i < len;i++) { buf[i] = value; } return len; } EXPORT int32_t fillFloatBuffer(float *buf, int len, float value) { int i; for (i=0;i < len;i++) { buf[i] = value; } return len; } EXPORT int32_t fillDoubleBuffer(double *buf, int len, double value) { int i; for (i=0;i < len;i++) { buf[i] = value; } return len; } EXPORT int32_t addInt32VarArgs(const char *fmt, ...) { va_list ap; int32_t sum = 0; va_start(ap, fmt); while (*fmt) { switch (*fmt++) { case 'd': sum += va_arg(ap, int32_t); break; case 'l': sum += (int) va_arg(ap, int64_t); break; case 'c': sum += (int) va_arg(ap, int); break; default: break; } } va_end(ap); return sum; } EXPORT void modifyStructureVarArgs(const char* fmt, ...) { struct _ss { int32_t magic; } *s; va_list ap; va_start(ap, fmt); while (*fmt) { switch(*fmt++) { case 's': s = (struct _ss *)va_arg(ap, void*); s->magic = MAGIC32; break; default: break; } } va_end(ap); } EXPORT char * returnStringVarArgs(const char *fmt, ...) { char* cp; va_list ap; va_start(ap, fmt); cp = va_arg(ap, char *); va_end(ap); return cp; } #if defined(_WIN32) && !defined(_WIN64) /////////////////////////////////////////////////////////////////////// // stdcall tests /////////////////////////////////////////////////////////////////////// EXPORT int32_t __stdcall returnInt32ArgumentStdCall(int32_t arg) { return arg; } EXPORT TestStructureByValue __stdcall returnStructureByValueArgumentStdCall(TestStructureByValue arg) { return arg; } EXPORT int32_t __stdcall callInt32StdCallCallback(int32_t (__stdcall *func)(int32_t arg, int32_t arg2), int32_t arg, int32_t arg2) { void* sp1 = NULL; void* sp2 = NULL; int value = -1; #if defined(_MSC_VER) __asm mov sp1, esp; value = (*func)(arg, arg2); __asm mov sp2, esp; #elif defined(__GNUC__) asm volatile (" movl %%esp,%0" : "=g" (sp1)); value = (*func)(arg, arg2); asm volatile (" movl %%esp,%0" : "=g" (sp2)); #endif if (sp1 != sp2) { return -1; } return value; } #endif /* _WIN32 && !_WIN64 */ #include #include JNIEXPORT jdouble JNICALL Java_com_sun_jna_DirectTest_00024JNI_cos(JNIEnv *env, jclass cls, jdouble x) { return cos(x); } #ifdef __cplusplus } #endif libjna-java-3.2.7/native/cc.sh0000644000175000017500000000574011227047776014235 0ustar janjan#!/bin/sh # # GCC-compatible wrapper for cl.exe # MSVC="/c/Program Files (x86)/Microsoft Visual Studio 9.0/vc/bin" nowarn="/wd4127 /wd4820 /wd4706 /wd4100 /wd4255 /wd4668" args="/nologo /EHac /W3 /LD $nowarn" # /WX # FIXME is this equivalent to --static-libgcc? links to msvcrt.lib # I've forgotten why it was originally added # /MD causes link problems #md=/MD cl="$MSVC/cl" ml="$MSVC/ml" output= while [ $# -gt 0 ] do case $1 in -fexceptions) shift 1 ;; -fno-omit-frame-pointer) # TODO: does this have an equivalent? shift 1 ;; -fno-strict-aliasing) # TODO: does this have an equivalent? shift 1 ;; -mno-cygwin) shift 1 ;; -m32) cl="$MSVC/cl" ml="$MSVC/ml" shift 1 ;; -m64) cl="$MSVC/x86_amd64/cl" ml="$MSVC/x86_amd64/ml64" shift 1 ;; -O*) args="$args $i" shift 1 ;; -g) # using /RTC1 instead of /GZ args="$args /Od /D_DEBUG /RTC1 /Zi" md=/MDd shift 1 ;; -c) args="$args /c" args="$(echo $args | sed 's%/Fe%/Fo%g')" single="/c" shift 1 ;; -D*=*) name="$(echo $1|sed 's/-D\([^=][^=]*\)=.*/\1/g')" value="$(echo $1|sed 's/-D[^=][^=]*=//g')" args="$args -D${name}='$value'" defines="$defines -D${name}='$value'" shift 1 ;; -D*) args="$args $1" defines="$defines $1" shift 1 ;; -I) args="$args /I\"$2\"" includes="$includes /I\"$2\"" shift 2 ;; -I*) args="$args /I\"$(echo $1|sed -e 's/-I//g')\"" includes="$includes /I\"$(echo $1|sed -e 's/-I//g')\"" shift 1 ;; -W|-Wextra) # TODO map extra warnings shift 1 ;; -Wall) args="$args /Wall" shift 1 ;; -Werror) args="$args /WX" shift 1 ;; -W*) # TODO map specific warnings shift 1 ;; -S) args="$args /FAs" shift 1 ;; -o) outdir="$(dirname $2)" base="$(basename $2|sed 's/\.[^.]*//g')" if [ -n "$single" ]; then output="/Fo$2" else output="/Fe$2" fi if [ -n "$assembly" ]; then args="$args $output" else args="$args $output /Fd$outdir/$base /Fp$outdir/$base /Fa$outdir/$base" fi shift 2 ;; *.S) src="$(echo $1|sed -e 's/.S$/.asm/g' -e 's%\\%/%g')" echo "$cl /EP $includes $defines $1 > $src" "$cl" /nologo /EP $includes $defines $1 > $src || exit $? md="" cl="$ml" output="$(echo $output | sed 's%/F[dpa][^ ]*%%g')" args="/nologo $single $src $output" assembly="true" shift 1 ;; *.c) args="$args $(echo $1|sed -e 's%\\%/%g')" shift 1 ;; *) echo "Unsupported argument '$1'" exit 1 ;; esac done args="$md $args" echo "$cl $args" eval "\"$cl\" $args" result=$? # @#!%@!# ml64 broken output if [ -n "$assembly" ]; then mv $src $outdir mv *.obj $outdir fi exit $resultlibjna-java-3.2.7/native/Makefile0000644000175000017500000001661611421051452014736 0ustar janjan# # Makefile for JNA native bits # Copyright (c) 2007-2010 Timothy Wall All Rights Reserved # # You may need to run 'ant javah' at the root before performing a build from # this directory. # # To build with debug information, use 'make DEBUG=true' # # Supported platforms (built and tested): # # Windows 2000/XP/2003/Vista (x86) # Darwin/OS X (i386/x86_64/ppc) # Linux (i386/amd64) # Solaris (i386/amd64/sparc/sparcv9) # FreeBSD (i386/amd64) # # Systems which support POSIX signals may be able to support VM crash # protection simply by defining HAVE_PROTECTION. This has been enabled # only for those platforms on which it has been tested successfully. OS=$(shell uname | sed -e 's/\(CYGWIN\|MINGW32\).*/win32/g' \ -e 's/SunOS.*/solaris/g' \ -e 's/FreeBSD.*/freebsd/g' \ -e 's/OpenBSD.*/openbsd/g' \ -e 's/Darwin.*/darwin/g' \ -e 's/Linux.*/linux/g') JNA_JNI_VERSION=3.2.2 # auto-generated by ant CHECKSUM=c870290c36c8d3fdf85db7c782febc3f # auto-generated by ant JAVA_INCLUDES=-I"$(JAVA_HOME)/include" \ -I"$(JAVA_HOME)/include/$(OS)" BUILD=../build/native JAVAH=$(BUILD) INSTALLDIR=../build/$(OS) JNIDISPATCH_OBJS=$(BUILD)/dispatch.o $(BUILD)/callback.o $(EXTRAOBJS) RSRC=$(BUILD)/rsrc.o ifneq ($(DYNAMIC_LIBFFI),true) FFI_SRC=$(shell pwd)/libffi FFI_BUILD=$(BUILD)/libffi FFI_LIB=$(FFI_BUILD)/.libs/libffi$(ARSFX) FFI_ENV=CC="$(CC)" CFLAGS="$(COPT) $(CDEBUG)" CPPFLAGS="$(CDEFINES)" FFI_CONFIG=--enable-static --disable-shared --with-pic=yes endif LIBRARY=$(BUILD)/$(LIBPFX)jnidispatch$(JNISFX) TESTLIB=$(BUILD)/$(LIBPFX)testlib$(LIBSFX) TESTLIB2=$(BUILD)/$(LIBPFX)testlib2$(LIBSFX) # Reasonable defaults based on GCC LIBPFX=lib LIBSFX=.so ARSFX=.a JNISFX=$(LIBSFX) CC=gcc LD=gcc LIBS= # Default to Sun recommendations for JNI compilation COPT=-O2 -fno-omit-frame-pointer -fno-strict-aliasing CASM=-S ifeq ($(DEBUG),true) CDEBUG=-g endif CFLAGS_EXTRA= COUT=-o $@ CINCLUDES=$(JAVA_INCLUDES) -I"$(JAVAH)" -I$(FFI_BUILD)/include CDEFINES=-D_REENTRANT PCFLAGS=-W -Wall -Wno-unused -Wno-parentheses CFLAGS=$(PCFLAGS) $(CFLAGS_EXTRA) $(COPT) $(CDEBUG) $(CDEFINES) $(CINCLUDES) \ -DJNA_JNI_VERSION='"$(JNA_JNI_VERSION)"' -DCHECKSUM='"$(CHECKSUM)"' LDFLAGS=-o $@ -shared ifeq ($(DYNAMIC_LIBFFI),true) CFLAGS += $(shell pkg-config --cflags libffi 2>/dev/null || echo) LIBS += $(shell pkg-config --libs libffi 2>/dev/null || echo -lffi) else # -static-libgcc avoids gcc library incompatibilities across linux systems LDFLAGS += -static-libgcc endif # Avoid bug in X11-based 1.5/1.6 VMs; dynamically load instead of linking # See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6539705 #LIBS=-L"$(LIBDIR)" -ljawt STRIP=strip -x # end defaults ifeq ($(OS),win32) ARCH=$(shell uname -m | sed 's/i.86/i386/g') CDEFINES=-DHAVE_PROTECTION -DPSAPI_VERSION=1 LIBS=-lpsapi WINDRES=windres EXTRAOBJS=$(RSRC) STRIP=@echo LIBPFX= LIBSFX=.dll ifeq ($(CC),gcc) CC += -mno-cygwin LD += -mno-cygwin -Wl,--add-stdcall-alias endif ifeq ($(ARCH),amd64) WINDRES=/usr/local/mingw64-cross/bin/x86_64-pc-mingw32-windres # Uncomment to enable MINGW64 cross compiler # Should build properly as of 090601, but lacks SEH, so MSVC build is preferred #MINGW = x86_64-pc-mingw32-gcc ifneq ($(MINGW),) CC = $(MINGW) -m64 -mno-cygwin LD = $(CC) LDFLAGS=-o $@ -shared LIBS= -lmingwex -lpsapi -lkernel32 -lmsvcrt FFI_CONFIG += --host=x86_64-pc-mingw32 else # MSVC (wrapper scripts) CC=$(FFI_SRC)/../cc.sh -m64 LD=$(FFI_SRC)/../ld.sh -m64 COPT= LIBS=psapi.lib ARSFX=.lib FFI_CONFIG += --host=x86_64-pc-mingw32 && rm -f include/ffitarget.h && cp $(FFI_SRC)/include/*.h $(FFI_SRC)/src/x86/ffitarget.h include FFI_ENV += LD="$(LD)" CPP=cpp endif endif endif ifeq ($(OS),linux) ARCH=$(shell uname -m | sed 's/i.86/i386/g') PCFLAGS+=-fPIC CDEFINES+=-DHAVE_PROTECTION LDFLAGS+=-Wl,-soname,$@ endif ifeq ($(OS),freebsd) ARCH=$(shell uname -m | sed 's/i.86/i386/g') PCFLAGS+=-fPIC CINCLUDES+=-I/usr/X11R6/include LDFLAGS=-o $@ -shared CDEFINES+=-DHAVE_PROTECTION -DFFI_MMAP_EXEC_WRIT endif ifeq ($(OS),openbsd) ARCH=$(shell uname -m | sed 's/i.86/i386/g') PCFLAGS+=-fPIC CINCLUDES+=-I/usr/X11R6/include LDFLAGS=-o $@ -shared CDEFINES+=-DHAVE_PROTECTION -DFFI_MMAP_EXEC_WRIT endif ifeq ($(OS),solaris) ifeq ($(ARCH),) ARCH=$(shell uname -p) endif PCFLAGS+=-fPIC CDEFINES+=-DHAVE_PROTECTION -DFFI_MMAP_EXEC_WRIT ifeq ($(ARCH), sparcv9) # alter CC instead of PCFLAGS, since we need to pass it down to libffi # configure and some of the other settings in PCFLAGS might make the build # choke CC += -m64 LD += -m64 endif endif # Enable 64-bit builds if the arch demands it ifeq ($(CC),gcc) ifeq ($(ARCH),amd64) CC += -m64 LD += -m64 endif endif ifeq ($(OS),darwin) ARCH=$(shell arch) ifeq ($(ARCH),ppc) ALT_ARCHS=i386 else ALT_ARCHS=ppc endif LIBSFX=.dylib JNISFX=.jnilib ifneq ($(SDKROOT),) SYSLIBROOT=-Wl,-syslibroot,$(SDKROOT) ISYSROOT=-isysroot $(SDKROOT) ARCHFLAGS=-arch ppc -arch i386 ifneq ($(findstring 10.5,$(SDKROOT)),) ALT_ARCHS+=x86_64 ARCHFLAGS+=-arch x86_64 endif endif PCFLAGS+=$(ISYSROOT) -x objective-c CDEFINES+=-DTARGET_RT_MAC_CFM=0 -DFFI_MMAP_EXEC_WRIT LDFLAGS=$(ARCHFLAGS) -dynamiclib -o $@ -framework JavaVM \ -compatibility_version $(shell echo ${JNA_JNI_VERSION}|sed 's/^\([0-9][0-9]*\).*/\1/g') \ -current_version $(JNA_JNI_VERSION) \ -mmacosx-version-min=10.3 \ -install_name ${@F} \ $(SYSLIBROOT) # JAWT linkage handled by -framework JavaVM LIBS= endif # Unfortunately, we have to use different libffi include files depending on # the target, so we can't do a simple universal build on darwin. Do # separate builds, then merge the results. $(BUILD)/%.o : %.c dispatch.h $(FFI_LIB) @mkdir -p $(BUILD) ifneq ($(SDKROOT),) $(CC) -arch $(ARCH) $(CFLAGS) -c $< -o $@.$(ARCH) for arch in $(ALT_ARCHS); do \ $(CC) -arch $$arch -I$(BUILD)/libffi.$$arch/include $(CFLAGS) -c $< -o $@.$$arch; \ done lipo -create -output $@ $@.* else $(CC) $(CFLAGS) -c $< $(COUT) endif all: $(LIBRARY) $(TESTLIB) $(TESTLIB2) install: mkdir $(INSTALLDIR) cp $(LIBRARY) $(INSTALLDIR) $(RSRC): $(BUILD)/jnidispatch.rc $(WINDRES) -i $< -o $@ \ || (echo > $@.c && $(CC) $(CFLAGS) -c $@.c $(COUT)) $(LIBRARY): $(JNIDISPATCH_OBJS) $(FFI_LIB) $(LD) $(LDFLAGS) $(JNIDISPATCH_OBJS) $(FFI_LIB) $(LIBS) $(TESTLIB): $(BUILD)/testlib.o $(LD) $(LDFLAGS) $< ifeq ($(ARSFX),.lib) TESTDEP=$(TESTLIB:.dll=.lib) else TESTDEP=$(TESTLIB) endif $(TESTLIB2): $(BUILD)/testlib2.o $(LD) $(LDFLAGS) $< $(TESTDEP) ifneq ($(DYNAMIC_LIBFFI),true) $(FFI_LIB): @mkdir -p $(FFI_BUILD) @if [ ! -f $(FFI_BUILD)/Makefile ]; then \ echo "Configuring libffi ($(ARCH))"; \ (cd $(FFI_BUILD) \ && $(FFI_ENV) $(FFI_SRC)/configure $(FFI_CONFIG)); \ fi $(MAKE) -C $(FFI_BUILD) ifneq ($(SDKROOT),) @for arch in $(ALT_ARCHS); do \ mkdir -p $(BUILD)/libffi.$$arch; \ if [ ! -f $(BUILD)/libffi.$$arch/Makefile ]; then \ echo "Configuring libffi ($$arch)"; \ (cd $(BUILD)/libffi.$$arch \ && CC="$(CC)" CFLAGS="-arch $$arch $(ISYSROOT) $(COPT) $(CDEBUG)" CPPFLAGS="$(CDEFINES)" \ LDFLAGS="-arch $$arch" \ $(FFI_SRC)/configure $(FFI_CONFIG) --host=$$arch-apple-darwin --disable-dependency-tracking); \ fi; \ $(MAKE) -C $(BUILD)/libffi.$$arch; \ done /usr/bin/libtool -static -o $@.tmp $(FFI_BUILD)/.libs/${@F} $(BUILD)/libffi.*/.libs/${@F} mv $@.tmp $@ endif endif clean: $(RM) -rf $(BUILD) version: @echo version=$(JNA_JNI_VERSION) #EOF libjna-java-3.2.7/native/ld.sh0000644000175000017500000000207511073050252014223 0ustar janjan#!/bin/sh # # ld-compatible wrapper for link.exe # #args="/pdbtype:sept" MSVC="/c/Program Files (x86)/Microsoft Visual Studio 9.0/vc/bin" args="/nologo /opt:REF /incremental:no /subsystem:console /nodefaultlib:msvcrtd" link="$MSVC/link" while [ $# -gt 0 ] do case $1 in -m32) link="$MSVC/link" args="$args /machine:X86" shift 1 ;; -m64) link="$MSVC/x86_amd64/link" args="$args /machine:X64" shift 1 ;; -g) args="$args /debug" shift 1 ;; -o) dir="$(dirname $2)" base="$(basename $2|sed 's/\.[^.]*//g')" args="$args /out:\"$2\" /pdb:$dir/$base.pdb /implib:$dir/$base.lib" shift 2 ;; -shared) args="$args /DLL" shift 1 ;; -static-libgcc) shift 1 ;; *.dll) args="$args $(echo $1|sed -e 's/.dll/.lib/g')" shift 1 ;; *.o|*.lib|*.a) args="$args $(echo $1|sed -e 's%\\%/%g')" shift 1 ;; *) echo "Unsupported argument '$1'" exit 1 ;; esac done echo "\"$link\" $args" eval "\"$link\" $args"libjna-java-3.2.7/native/jnidispatch.rc0000644000175000017500000000151611421051452016115 0ustar janjan// Resource file to generate version information for jnidispatch.dll // Copyright (c) 2008-2010 Timothy Wall // Type: version // Name: 1 LANGUAGE 0, 0 1 VERSIONINFO FILEVERSION 3,0,0,0 PRODUCTVERSION 3,0,1,0 FILEFLAGSMASK 0x3f FILEOS 0x4 FILETYPE 0x2 BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "000004b0" BEGIN VALUE "CompanyName", "Java(TM) Native Access (JNA)" VALUE "FileDescription", "JNA native library" VALUE "FileVersion","3.0.0" VALUE "Full Version","3.0.0 b0" VALUE "InternalName", "jnidispatch" VALUE "LegalCopyright", "Copyright \251 2008-2010 Timothy Wall" VALUE "OriginalFilename", "jnidispatch.dll" VALUE "ProductName", "Java(TM) Native Access" VALUE "ProductVersion","3" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0, 1200 END END libjna-java-3.2.7/native/testlib2.c0000644000175000017500000000155011065664600015172 0ustar janjan/* Copyright (c) 2007-2008 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. *

* 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. */ /* Simple library with a dependency. */ #ifdef __cplusplus extern "C" { #endif #ifdef _WIN32 #define EXPORT __declspec(dllexport) #else #define EXPORT #endif extern int returnFalse(); EXPORT int dependentReturnFalse() { return returnFalse(); } #ifdef __cplusplus } #endif libjna-java-3.2.7/native/callback.c0000644000175000017500000003354311227071530015177 0ustar janjan/* Copyright (c) 2007 Timothy Wall, All Rights Reserved * Copyright (c) 2007 Wayne Meissner, 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. */ #include #include #include #include #if defined(_WIN32) # define WIN32_LEAN_AND_MEAN # include #else # include # include #endif #include "dispatch.h" #ifdef __cplusplus extern "C" { #endif static void callback_dispatch(ffi_cif*, void*, void**, void*); static jclass classObject; callback* create_callback(JNIEnv* env, jobject obj, jobject method, jobjectArray param_types, jclass return_type, callconv_t calling_convention, jboolean direct) { callback* cb; ffi_abi abi = FFI_DEFAULT_ABI; ffi_abi java_abi = FFI_DEFAULT_ABI; ffi_type* ffi_rtype; ffi_status status; jsize argc; JavaVM* vm; int rtype; char msg[64]; int i; int cvt = 0; const char* throw_type = NULL; const char* throw_msg = NULL; if ((*env)->GetJavaVM(env, &vm) != JNI_OK) { throwByName(env, EUnsatisfiedLink, "Can't get Java VM"); return NULL; } argc = (*env)->GetArrayLength(env, param_types); cb = (callback *)malloc(sizeof(callback)); cb->closure = ffi_closure_alloc(sizeof(ffi_closure), &cb->x_closure); cb->object = (*env)->NewWeakGlobalRef(env, obj); cb->methodID = (*env)->FromReflectedMethod(env, method); cb->vm = vm; cb->arg_types = (ffi_type**)malloc(sizeof(ffi_type*) * argc); cb->java_arg_types = (ffi_type**)malloc(sizeof(ffi_type*) * (argc + 3)); cb->arg_jtypes = (char*)malloc(sizeof(char) * argc); cb->flags = (int *)malloc(sizeof(int) * argc); cb->rflag = CVT_DEFAULT; cb->arg_classes = (jobject*)malloc(sizeof(jobject) * argc); cb->direct = direct; cb->java_arg_types[0] = cb->java_arg_types[1] = cb->java_arg_types[2] = &ffi_type_pointer; for (i=0;i < argc;i++) { int jtype; jclass cls = (*env)->GetObjectArrayElement(env, param_types, i); if ((cb->flags[i] = get_conversion_flag(env, cls)) != CVT_DEFAULT) { cb->arg_classes[i] = (*env)->NewWeakGlobalRef(env, cls); cvt = 1; } jtype = get_jtype(env, cls); if (jtype == -1) { snprintf(msg, sizeof(msg), "Unsupported argument at index %d", i); throw_type = EIllegalArgument; throw_msg = msg; goto failure_cleanup; } cb->arg_jtypes[i] = (char)jtype; cb->java_arg_types[i+3] = cb->arg_types[i] = get_ffi_type(env, cls, cb->arg_jtypes[i]); if (cb->flags[i] == CVT_NATIVE_MAPPED || cb->flags[i] == CVT_POINTER_TYPE || cb->flags[i] == CVT_INTEGER_TYPE) { jclass ncls; ncls = getNativeType(env, cls); jtype = get_jtype(env, ncls); if (jtype == -1) { snprintf(msg, sizeof(msg), "Unsupported NativeMapped argument native type at argument %d", i); throw_type = EIllegalArgument; throw_msg = msg; goto failure_cleanup; } cb->arg_jtypes[i] = (char)jtype; cb->java_arg_types[i+3] = &ffi_type_pointer; cb->arg_types[i] = get_ffi_type(env, ncls, cb->arg_jtypes[i]); } if (cb->arg_types[i]->type == FFI_TYPE_FLOAT) { // Java method is varargs, so promote floats to double cb->java_arg_types[i+3] = &ffi_type_double; cb->flags[i] = CVT_FLOAT; cvt = 1; } else if (cb->java_arg_types[i+3]->type == FFI_TYPE_STRUCT) { // All callback structure arguments are passed as a jobject cb->java_arg_types[i+3] = &ffi_type_pointer; } } if (!direct || !cvt) { free(cb->flags); cb->flags = NULL; free(cb->arg_classes); cb->arg_classes = NULL; } if (direct) { cb->rflag = get_conversion_flag(env, return_type); if (cb->rflag == CVT_NATIVE_MAPPED || cb->rflag == CVT_INTEGER_TYPE || cb->rflag == CVT_POINTER_TYPE) { return_type = getNativeType(env, return_type); } } #if defined(_WIN32) && !defined(_WIN64) if (calling_convention == CALLCONV_STDCALL) { abi = FFI_STDCALL; } java_abi = FFI_STDCALL; #endif // _WIN32 rtype = get_jtype(env, return_type); if (rtype == -1) { throw_type = EIllegalArgument; throw_msg = "Unsupported return type"; goto failure_cleanup; } ffi_rtype = get_ffi_rtype(env, return_type, (char)rtype); if (!ffi_rtype) { throw_type = EIllegalArgument; throw_msg = "Error in return type"; goto failure_cleanup; } status = ffi_prep_cif(&cb->cif, abi, argc, ffi_rtype, cb->arg_types); if (!ffi_error(env, "callback setup", status)) { ffi_type* java_ffi_rtype = ffi_rtype; if (cb->rflag == CVT_STRUCTURE_BYVAL || cb->rflag == CVT_NATIVE_MAPPED || cb->rflag == CVT_POINTER_TYPE || cb->rflag == CVT_INTEGER_TYPE) { // Java method returns a jobject, not a struct java_ffi_rtype = &ffi_type_pointer; rtype = '*'; } switch(rtype) { case 'V': cb->fptr = (*env)->CallVoidMethod; break; case 'Z': cb->fptr = (*env)->CallBooleanMethod; break; case 'B': cb->fptr = (*env)->CallByteMethod; break; case 'S': cb->fptr = (*env)->CallShortMethod; break; case 'C': cb->fptr = (*env)->CallCharMethod; break; case 'I': cb->fptr = (*env)->CallIntMethod; break; case 'J': cb->fptr = (*env)->CallLongMethod; break; case 'F': cb->fptr = (*env)->CallFloatMethod; break; case 'D': cb->fptr = (*env)->CallDoubleMethod; break; default: cb->fptr = (*env)->CallObjectMethod; break; } status = ffi_prep_cif(&cb->java_cif, java_abi, argc+3, java_ffi_rtype, cb->java_arg_types); if (!ffi_error(env, "callback setup (2)", status)) { ffi_prep_closure_loc(cb->closure, &cb->cif, callback_dispatch, cb, cb->x_closure); return cb; } } failure_cleanup: free_callback(env, cb); if (throw_type) { throwByName(env, throw_type, msg); } return NULL; } void free_callback(JNIEnv* env, callback *cb) { (*env)->DeleteWeakGlobalRef(env, cb->object); ffi_closure_free(cb->closure); free(cb->arg_types); if (cb->arg_classes) { unsigned i; for (i=0;i < cb->cif.nargs;i++) { (*env)->DeleteWeakGlobalRef(env, cb->arg_classes[i]); } free(cb->arg_classes); } free(cb->java_arg_types); if (cb->flags) free(cb->flags); free(cb->arg_jtypes); free(cb); } static int handle_exception(JNIEnv* env, jobject cb, jthrowable throwable) { #define HANDLER_TYPE "com/sun/jna/Callback$UncaughtExceptionHandler" #define HANDLER_SIG "Lcom/sun/jna/Callback$UncaughtExceptionHandler;" jclass classHandler = (*env)->FindClass(env, HANDLER_TYPE); if (classHandler) { jclass classNative = (*env)->FindClass(env, "com/sun/jna/Native"); if (classNative) { jfieldID fid = (*env)->GetStaticFieldID(env, classNative, "callbackExceptionHandler", HANDLER_SIG); if (fid) { jobject handler = (*env)->GetStaticObjectField(env, classNative, fid); if (handler) { jmethodID mid = (*env)->GetMethodID(env, classHandler, "uncaughtException", "(Lcom/sun/jna/Callback;Ljava/lang/Throwable;)V"); if (mid) { if (!(*env)->IsSameObject(env, handler, NULL)) { (*env)->CallVoidMethod(env, handler, mid, cb, throwable); } if ((*env)->ExceptionCheck(env) == 0) { return 1; } } } } } } (*env)->ExceptionDescribe(env); (*env)->ExceptionClear(env); return 0; } static void callback_invoke(JNIEnv* env, callback *cb, ffi_cif* cif, void *resp, void **cbargs) { jobject self; void *oldresp = resp; self = (*env)->NewLocalRef(env, cb->object); // Avoid calling back to a GC'd object if ((*env)->IsSameObject(env, self, NULL)) { fprintf(stderr, "JNA: callback object has been garbage collected\n"); if (cif->rtype->type != FFI_TYPE_VOID) memset(resp, 0, cif->rtype->size); } else if (cb->direct) { unsigned int i; void **args = alloca((cif->nargs + 3) * sizeof(void *)); args[0] = (void *)&env; args[1] = &self; args[2] = &cb->methodID; memcpy(&args[3], cbargs, cif->nargs * sizeof(void *)); if (cb->flags) { for (i=0;i < cif->nargs;i++) { switch(cb->flags[i]) { case CVT_INTEGER_TYPE: case CVT_POINTER_TYPE: case CVT_NATIVE_MAPPED: *((void **)args[i+3]) = fromNative(env, cb->arg_classes[i], cif->arg_types[i], args[i+3], JNI_FALSE); break; case CVT_POINTER: *((void **)args[i+3]) = newJavaPointer(env, *(void **)args[i+3]); break; case CVT_STRING: *((void **)args[i+3]) = newJavaString(env, *(void **)args[i+3], JNI_FALSE); break; case CVT_WSTRING: *((void **)args[i+3]) = newJavaWString(env, *(void **)args[i+3]); break; case CVT_STRUCTURE: *((void **)args[i+3]) = newJavaStructure(env, *(void **)args[i+3], cb->arg_classes[i], JNI_FALSE); break; case CVT_STRUCTURE_BYVAL: { void *ptr = args[i+3]; args[i+3] = alloca(sizeof(void *)); *((void **)args[i+3]) = newJavaStructure(env, ptr, cb->arg_classes[i], JNI_TRUE); } break; case CVT_CALLBACK: *((void **)args[i+3]) = newJavaCallback(env, *(void **)args[i+3], cb->arg_classes[i]); break; case CVT_FLOAT: { void *ptr = alloca(sizeof(double)); *(double *)ptr = *(float*)args[i+3]; args[i+3] = ptr; } break; } } } if (cb->rflag == CVT_STRUCTURE_BYVAL) { resp = alloca(sizeof(jobject)); } else if (cb->cif.rtype->size > cif->rtype->size) { resp = alloca(cb->cif.rtype->size); } ffi_call(&cb->java_cif, FFI_FN(cb->fptr), resp, args); if ((*env)->ExceptionCheck(env)) { jthrowable throwable = (*env)->ExceptionOccurred(env); (*env)->ExceptionClear(env); if (!handle_exception(env, self, throwable)) { fprintf(stderr, "JNA: error handling callback exception, continuing\n"); } if (cif->rtype->type != FFI_TYPE_VOID) memset(oldresp, 0, cif->rtype->size); } else switch(cb->rflag) { case CVT_INTEGER_TYPE: if (cb->cif.rtype->size > sizeof(ffi_arg)) { *(jlong *)oldresp = getIntegerTypeValue(env, *(void **)resp); } else { *(ffi_arg *)oldresp = (ffi_arg)getIntegerTypeValue(env, *(void **)resp); } break; case CVT_POINTER_TYPE: *(void **)resp = getPointerTypeAddress(env, *(void **)resp); break; case CVT_NATIVE_MAPPED: toNative(env, *(void **)resp, oldresp, cb->cif.rtype->size, JNI_TRUE); break; case CVT_POINTER: *(void **)resp = getNativeAddress(env, *(void **)resp); break; case CVT_STRING: *(void **)resp = getNativeString(env, *(void **)resp, JNI_FALSE); break; case CVT_WSTRING: *(void **)resp = getNativeString(env, *(void **)resp, JNI_TRUE); break; case CVT_STRUCTURE: writeStructure(env, *(void **)resp); *(void **)resp = getStructureAddress(env, *(void **)resp); break; case CVT_STRUCTURE_BYVAL: writeStructure(env, *(void **)resp); memcpy(oldresp, getStructureAddress(env, *(void **)resp), cb->cif.rtype->size); break; case CVT_CALLBACK: *(void **)resp = getCallbackAddress(env, *(void **)resp); break; default: break; } if (cb->flags) { for (i=0;i < cif->nargs;i++) { if (cb->flags[i] == CVT_STRUCTURE) { writeStructure(env, *(void **)args[i+3]); } } } } else { jobject result; jobjectArray array = (*env)->NewObjectArray(env, cif->nargs, classObject, NULL); unsigned int i; for (i=0;i < cif->nargs;i++) { jobject arg = new_object(env, cb->arg_jtypes[i], cbargs[i], JNI_FALSE); (*env)->SetObjectArrayElement(env, array, i, arg); } result = (*env)->CallObjectMethod(env, self, cb->methodID, array); if ((*env)->ExceptionCheck(env)) { jthrowable throwable = (*env)->ExceptionOccurred(env); (*env)->ExceptionClear(env); if (!handle_exception(env, self, throwable)) { fprintf(stderr, "JNA: error handling callback exception, continuing\n"); } if (cif->rtype->type != FFI_TYPE_VOID) memset(resp, 0, cif->rtype->size); } else { extract_value(env, result, resp, cif->rtype->size, JNI_TRUE); } } } static void callback_dispatch(ffi_cif* cif, void* resp, void** cbargs, void* user_data) { JavaVM* jvm = ((callback *)user_data)->vm; JNIEnv* env; int attached; attached = (*jvm)->GetEnv(jvm, (void *)&env, JNI_VERSION_1_4) == JNI_OK; if (!attached) { if ((*jvm)->AttachCurrentThread(jvm, (void *)&env, NULL) != JNI_OK) { fprintf(stderr, "JNA: Can't attach to current thread\n"); return; } } // Give the callback its own local frame to ensure all local references // are properly disposed if ((*env)->PushLocalFrame(env, 16) < 0) { fprintf(stderr, "JNA: Out of memory: Can't allocate local frame"); } else { callback_invoke(env, (callback *)user_data, cif, resp, cbargs); (*env)->PopLocalFrame(env, NULL); } if (!attached) { (*jvm)->DetachCurrentThread(jvm); } } const char* jnidispatch_callback_init(JNIEnv* env) { if (!LOAD_CREF(env, Object, "java/lang/Object")) return "java.lang.Object"; return NULL; } void jnidispatch_callback_dispose(JNIEnv* env) { if (classObject) { (*env)->DeleteWeakGlobalRef(env, classObject); classObject = NULL; } } #ifdef __cplusplus } #endif libjna-java-3.2.7/native/dispatch.h0000644000175000017500000001535111227047776015263 0ustar janjan/* 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. *

* 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. */ #ifndef DISPATCH_H #define DISPATCH_H #include "ffi.h" #include "com_sun_jna_Function.h" #include "com_sun_jna_Native.h" #ifdef sun # include #endif #ifdef _WIN32 #ifdef _MSC_VER #define alloca _alloca #pragma warning( disable : 4152 ) /* function/data conversion */ #pragma warning( disable : 4054 ) /* cast function pointer to data pointer */ #pragma warning( disable : 4055 ) /* cast data pointer to function pointer */ #pragma warning( disable : 4204 ) /* structure initializer */ #pragma warning( disable : 4710 ) /* swprintf not inlined */ #else #include #endif /* _MSC_VER */ #endif /* _WIN32 */ #ifdef __cplusplus extern "C" { #endif /* These are the calling conventions an invocation can handle. */ typedef enum _callconv { CALLCONV_C = com_sun_jna_Function_C_CONVENTION, #ifdef _WIN32 CALLCONV_STDCALL = com_sun_jna_Function_ALT_CONVENTION, #endif } callconv_t; /* Maximum number of allowed arguments in libffi. */ #define MAX_NARGS com_sun_jna_Function_MAX_NARGS enum { CVT_DEFAULT = com_sun_jna_Native_CVT_DEFAULT, CVT_POINTER = com_sun_jna_Native_CVT_POINTER, CVT_STRING = com_sun_jna_Native_CVT_STRING, CVT_STRUCTURE = com_sun_jna_Native_CVT_STRUCTURE, CVT_STRUCTURE_BYVAL = com_sun_jna_Native_CVT_STRUCTURE_BYVAL, CVT_BUFFER = com_sun_jna_Native_CVT_BUFFER, CVT_ARRAY_BYTE = com_sun_jna_Native_CVT_ARRAY_BYTE, CVT_ARRAY_SHORT = com_sun_jna_Native_CVT_ARRAY_SHORT, CVT_ARRAY_CHAR = com_sun_jna_Native_CVT_ARRAY_CHAR, CVT_ARRAY_INT = com_sun_jna_Native_CVT_ARRAY_INT, CVT_ARRAY_LONG = com_sun_jna_Native_CVT_ARRAY_LONG, CVT_ARRAY_FLOAT = com_sun_jna_Native_CVT_ARRAY_FLOAT, CVT_ARRAY_DOUBLE = com_sun_jna_Native_CVT_ARRAY_DOUBLE, CVT_ARRAY_BOOLEAN = com_sun_jna_Native_CVT_ARRAY_BOOLEAN, CVT_BOOLEAN = com_sun_jna_Native_CVT_BOOLEAN, CVT_CALLBACK = com_sun_jna_Native_CVT_CALLBACK, CVT_FLOAT = com_sun_jna_Native_CVT_FLOAT, CVT_NATIVE_MAPPED = com_sun_jna_Native_CVT_NATIVE_MAPPED, CVT_WSTRING = com_sun_jna_Native_CVT_WSTRING, CVT_INTEGER_TYPE = com_sun_jna_Native_CVT_INTEGER_TYPE, CVT_POINTER_TYPE = com_sun_jna_Native_CVT_POINTER_TYPE, CVT_TYPE_MAPPER = com_sun_jna_Native_CVT_TYPE_MAPPER, }; typedef struct _callback { // Location of this field must agree with CallbackReference.getTrampoline() void* x_closure; ffi_closure* closure; ffi_cif cif; ffi_cif java_cif; ffi_type** arg_types; ffi_type** java_arg_types; jobject* arg_classes; int* flags; int rflag; JavaVM* vm; jobject object; jmethodID methodID; char* arg_jtypes; jboolean direct; void* fptr; } callback; #if defined(SOLARIS2) || defined(__GNUC__) #if defined(_WIN64) #define L2A(X) ((void *)(long long)(X)) #define A2L(X) ((jlong)(long long)(X)) #else #define L2A(X) ((void *)(unsigned long)(X)) #define A2L(X) ((jlong)(unsigned long)(X)) #endif #endif #if defined(_MSC_VER) #define L2A(X) ((void *)(X)) #define A2L(X) ((jlong)(X)) #define snprintf sprintf_s #endif /* Convenience macros */ #define LOAD_WEAKREF(ENV,VAR) \ ((VAR == 0) \ ? 0 : ((VAR = (*ENV)->NewWeakGlobalRef(ENV, VAR)) == 0 ? 0 : VAR)) #define FIND_CLASS(ENV,SIMPLE,NAME) \ (class ## SIMPLE = (*ENV)->FindClass(ENV, NAME)) #define FIND_PRIMITIVE_CLASS(ENV,SIMPLE) \ (classPrimitive ## SIMPLE = (*ENV)->GetStaticObjectField(ENV,class ## SIMPLE,(*ENV)->GetStaticFieldID(ENV,class ## SIMPLE,"TYPE","Ljava/lang/Class;"))) #define LOAD_CREF(ENV,SIMPLE,NAME) \ (FIND_CLASS(ENV,SIMPLE,NAME) && LOAD_WEAKREF(ENV,class ## SIMPLE)) #define LOAD_PCREF(ENV,SIMPLE,NAME) \ (LOAD_CREF(ENV,SIMPLE,NAME) \ && FIND_PRIMITIVE_CLASS(ENV,SIMPLE) \ && LOAD_WEAKREF(ENV,classPrimitive ## SIMPLE)) #define LOAD_MID(ENV,VAR,CLASS,NAME,SIG) \ ((VAR = (*ENV)->GetMethodID(ENV, CLASS, NAME, SIG)) ? VAR : 0) #define LOAD_FID(ENV,VAR,CLASS,NAME,SIG) \ ((VAR = (*ENV)->GetFieldID(ENV, CLASS, NAME, SIG)) ? VAR : 0) // Avoid typos in class names #define EIllegalArgument "java/lang/IllegalArgumentException" #define EOutOfMemory "java/lang/OutOfMemoryError" #define EUnsatisfiedLink "java/lang/UnsatisfiedLinkError" #define EIllegalState "java/lang/IllegalStateException" #define EUnsupportedOperation "java/lang/UnsupportedOperationException" #define ERuntime "java/lang/RuntimeException" #define EError "java/lang/Error" #define ELastError "com/sun/jna/LastErrorException" extern void throwByName(JNIEnv *env, const char *name, const char *msg); extern int get_jtype(JNIEnv*, jclass); extern ffi_type* get_ffi_type(JNIEnv*, jclass, char); extern ffi_type* get_ffi_rtype(JNIEnv*, jclass, char); extern const char* jnidispatch_callback_init(JNIEnv*); extern void jnidispatch_callback_dispose(JNIEnv*); extern callback* create_callback(JNIEnv*, jobject, jobject, jobjectArray, jclass, callconv_t, jboolean); extern void free_callback(JNIEnv*, callback*); extern void extract_value(JNIEnv*, jobject, void*, size_t, jboolean); extern jobject new_object(JNIEnv*, char, void*, jboolean); extern jboolean is_protected(); extern int get_conversion_flag(JNIEnv*, jclass); extern jboolean ffi_error(JNIEnv*,const char*,ffi_status); extern jobject newJavaPointer(JNIEnv*, void*); extern jstring newJavaString(JNIEnv*, const char*, jboolean); extern jobject newJavaWString(JNIEnv*, const wchar_t*); extern jobject newJavaStructure(JNIEnv*, void*, jclass, jboolean); extern jobject newJavaCallback(JNIEnv*, void*, jclass); extern void* getNativeString(JNIEnv*, jstring, jboolean); extern void* getNativeAddress(JNIEnv*, jobject); extern void* getStructureAddress(JNIEnv*, jobject); extern void* getCallbackAddress(JNIEnv*, jobject); extern jlong getIntegerTypeValue(JNIEnv*, jobject); extern void* getPointerTypeAddress(JNIEnv*, jobject); extern void writeStructure(JNIEnv*, jobject); extern jclass getNativeType(JNIEnv*, jclass); extern void toNative(JNIEnv*, jobject, void*, size_t, jboolean); extern jclass fromNative(JNIEnv*, jclass, ffi_type*, void*, jboolean); /* Native memory fault protection */ #ifdef HAVE_PROTECTION #define PROTECT is_protected() #endif #include "protect.h" #define ON_ERROR() throwByName(env, EError, "Invalid memory access") #define PSTART() PROTECTED_START() #define PEND() PROTECTED_END(ON_ERROR()) #ifdef __cplusplus } #endif #endif /* DISPATCH_H */ libjna-java-3.2.7/native/protect.h0000644000175000017500000001001311220635060015110 0ustar janjan/* 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. *

* 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. */ #ifndef PROTECT_H #define PROTECT_H // Native memory access protection // // Enable or disable by changing the value of the PROTECT flag. // // Example usage: // // #define PROTECT _protect // static int _protect; // #include "protect.h" // // void my_function() { // int variable_decls; // PROTECTED_START(); // // do some dangerous stuff here // PROTECTED_END(fprintf(stderr, "Error!")); // } // // The PROTECT_START() macro must immediately follow any variable declarations // // The w32 implementation is based on code by Ranjit Mathew // http://gcc.gnu.org/ml/java/2003-03/msg00243.html #ifndef PROTECT #define PROTECTED_START() #define PROTECTED_END(ONERR) #else #ifdef _WIN32 #ifdef __GNUC__ #include #else // copied from mingw header typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER) (struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*); typedef struct _EXCEPTION_REGISTRATION { struct _EXCEPTION_REGISTRATION* prev; PEXCEPTION_HANDLER handler; } EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION; #endif #include typedef struct _exc_rec { EXCEPTION_REGISTRATION ex_reg; jmp_buf buf; struct _EXCEPTION_RECORD er; } exc_rec; static EXCEPTION_DISPOSITION __cdecl _exc_handler(struct _EXCEPTION_RECORD* exception_record, void *establisher_frame, struct _CONTEXT *context_record, void* dispatcher_context) { exc_rec* xer = (exc_rec *)establisher_frame; xer->er = *exception_record; longjmp(xer->buf, exception_record->ExceptionCode); // Never reached return ExceptionContinueExecution; } #ifdef _MSC_VER #define PROTECTED_START() __try { #define PROTECTED_END(ONERR) } __except((PROTECT)?EXCEPTION_EXECUTE_HANDLER:EXCEPTION_CONTINUE_SEARCH) { ONERR; } #else #ifdef _WIN64 #error "GCC does not implement SEh" #else #define SEH_TRY(ER) \ __asm__ ("movl %%fs:0, %0" : "=r" ((ER).ex_reg.prev)); \ __asm__ ("movl %0, %%fs:0" : : "r" (&(ER))) #define SEH_CATCH(ER) \ __asm__ ("movl %0, %%fs:0" : : "r" ((ER).ex_reg.prev)) #endif /* !_WIN64 */ #define PROTECTED_START() \ exc_rec _er; \ int _error = 0; \ if (PROTECT) { \ _er.ex_reg.handler = _exc_handler; \ SEH_TRY(_er); \ if ((_error = setjmp(_er.buf)) != 0) { \ goto _exc_caught; \ } \ } // The initial conditional is required to ensure GCC doesn't consider // _exc_caught to be unreachable #define PROTECTED_END(ONERR) do { \ if (!_error) \ goto _remove_handler; \ _exc_caught: \ ONERR; \ _remove_handler: \ if (PROTECT) { SEH_CATCH(_er); } \ } while(0) #endif /* !_MSC_VER */ #else // _WIN32 // Most other platforms support signals // Catch both SIGSEGV and SIGBUS #include #include static jmp_buf _context; static void* _old_segv_handler = NULL; static void* _old_bus_handler = NULL; static volatile int _error; static void _exc_handler(int sig) { if (sig == SIGSEGV || sig == SIGBUS) { longjmp(_context, sig); } } #define PROTECTED_START() \ if (PROTECT) { \ _old_segv_handler = signal(SIGSEGV, _exc_handler); \ _old_bus_handler = signal(SIGBUS, _exc_handler); \ if ((_error = setjmp(_context) != 0)) { \ goto _exc_caught; \ } \ } #define PROTECTED_END(ONERR) do { \ if (!_error) \ goto _remove_handler; \ _exc_caught: \ ONERR; \ _remove_handler: \ if (PROTECT) { \ signal(SIGSEGV, _old_segv_handler); \ signal(SIGBUS, _old_bus_handler); \ } \ } while(0) #endif #endif // PROTECT #endif // PROTECT_H libjna-java-3.2.7/LICENSE.txt0000644000175000017500000006447411006656776013663 0ustar janjan GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it!