private FileSystemWatcher() {
   cf = (CoreFoundation) Native.loadLibrary("CoreFoundation", CoreFoundation.class); // NOI18N
   cs = (CoreServices) Native.loadLibrary("CoreServices", CoreServices.class); // NOI18N
   callback = new EventCallbackImpl();
   events = new LinkedBlockingQueue<Event>();
   listensOn = new ConcurrentHashMap<String, Key>();
 }
  public interface User32 extends W32APIOptions {
    public static final String SHELL_TRAY_WND = "Shell_TrayWnd";
    public static final int WM_COMMAND = 0x111;
    public static final int MIN_ALL = 0x1a3;
    public static final int MIN_ALL_UNDO = 0x1a0;
    User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class);

    HWND GetForegroundWindow(); // add this

    int GetWindowTextA(PointerType hWnd, byte[] lpString, int nMaxCount);

    User32 instance = (User32) Native.loadLibrary("user32", User32.class, DEFAULT_OPTIONS);

    HWND FindWindow(String winClass, String title);

    long SendMessageA(HWND hWnd, int msg, int num1, int num2);

    boolean IsWindowVisible(int hWnd);

    int GetWindowRect(int hWnd, RECT r);

    void GetWindowTextA(int hWnd, byte[] buffer, int buflen);

    int GetTopWindow(int hWnd);

    int GetWindow(int hWnd, int flag);

    final int GW_HWNDNEXT = 2;
  }
示例#3
0
 static {
   if (SystemUtils.IS_OS_LINUX) {
     try {
       libappindicator = (AppIndicator) Native.loadLibrary("appindicator", AppIndicator.class);
       libgtk = (Gtk) Native.loadLibrary("gtk-x11-2.0", Gtk.class);
       libgobject = (Gobject) Native.loadLibrary("gobject-2.0", Gobject.class);
       libglib = (Glib) Native.loadLibrary("glib-2.0", Glib.class);
       // libunique = (Unique) Native.loadLibrary("unique-3.0", Unique.class);
     } catch (final Throwable ex) {
       LOG.warn("no supported version of appindicator libs found", ex);
     }
   }
 }
  // deve saber se win ou linux
  public static IComunicacaoSensores getConector() {
    IComunicacaoSensores conector = null;

    if (Platform.isWindows()) {
      conector =
          (IComunicacaoSensores)
              Native.loadLibrary("comunicacaosensores.dll", IComunicacaoSensores.class);

    } else if (Platform.isLinux()) {
      conector =
          (IComunicacaoSensores)
              Native.loadLibrary("comunicacaosensores.so", IComunicacaoSensores.class);
    }
    return conector;
  }
示例#5
0
  public interface User32 extends W32APIOptions {
    User32 instance = (User32) Native.loadLibrary("user32", User32.class, DEFAULT_OPTIONS);

    boolean ShowWindow(HWND hWnd, int nCmdShow);

    boolean SetForegroundWindow(HWND hWnd);

    HWND FindWindow(String winClass, String title);

    LRESULT SendMessage(HWND hWnd, int Msg, WPARAM wParam, LPARAM lParam);

    boolean EnumWindows(WNDENUMPROC wndenumproc, int lParam);

    boolean EnumChildWindows(HWND hWnd, WNDENUMPROC lpEnumFunc, Pointer data);

    HWND GetParent(HWND hWnd);

    boolean IsWindowVisible(HWND hWnd);

    int GetWindowRect(HWND hWnd, RECT r);

    void GetWindowTextA(HWND hWnd, byte[] buffer, int buflen);

    int GetTopWindow(HWND hWnd);

    int GetWindow(HWND hWnd, int flag);

    final int GW_HWNDNEXT = 2;

    int GetClassName(HWND hWnd, char[] buffer2, int i);
  }
示例#6
0
/** Simple example of native library declaration and usage. */
public interface User32 extends Library {
  User32 INSTANCE = (User32) Native.loadLibrary(null, User32.class);

  void system(String command);

  void printf(String text, Object... obj);

  void WriteConsoleOutputCharacterA(int hwnd, String content, int size, int coord, Object bytes);

  int GetStdHandle(int ok);

  int CreateConsoleScreenBuffer(int access, int shareMode, Object security, int flags, Object data);

  int SetConsoleActiveScreenBuffer(int hwnd);

  int SetConsoleCursorInfo(int hwnd); // int cursorInfo);

  int GetConsoleCursorInfo(int hwnd);

  int SetConsoleScreenBufferSize(int hwnd, int size);

  int WriteConsoleA(int hwnd, String text, int size, int lpNumberOfCharsWritten, Object flags);

  int ReadConsoleA(int hwnd, String text, int size, String out, Object smg);

  int FlushConsoleInputBuffer(int hwnd);

  int ReadConsoleOutputCharacterA(int hwnd, String text, int size, int coord, Object smg);

  int SetConsoleTitleA(String title);
}
  /**
   * Uses JNA to retrieve the module file name of a program and parses it as a string which is then
   * passed to the InterruptionLogic class.
   */
  private void getProgramIdentifier() {

    PSAPI psapi = (PSAPI) Native.loadLibrary("psapi", PSAPI.class);

    HWND focusedWindow = User32.INSTANCE.GetForegroundWindow();
    byte[] name = new byte[1024];

    IntByReference pid = new IntByReference();
    User32.INSTANCE.GetWindowThreadProcessId(focusedWindow, pid);

    System.out.println("pid = " + pid.getValue());

    HANDLE process = Kernel32.INSTANCE.OpenProcess(0x0400 | 0x0010, false, pid.getValue());

    // Initally I was using the 'GetWindowModuleFileName' which provided
    // erronous behaviour. 'technomage' on Stackoverflow pointed out that
    // the method that should be used is 'GetModuleFileNameEx' -
    // http://stackoverflow.com/questions/15693210/getmodulefilename-for-window-in-focus-jna-windows-os

    psapi.GetModuleFileNameExA(process, null, name, 1024);
    String nameString = Native.toString(name);

    System.out.println(nameString);

    interruptDec.interruptNow(nameString);
  }
示例#8
0
 public static final Object getLibrary(String name, String path, final Class<?> libraryClass) {
   Object original =
       com.sun.jna.Native.loadLibrary(path, libraryClass, MangledFunctionMapper.DEFAULT_OPTIONS);
   return shouldTraceCalls(name)
       ? LibraryExtractor.getTracingLibrary(original, libraryClass)
       : original;
 }
示例#9
0
/**
 * Provides access to ioctl calls for register access.
 *
 * @author jnaous
 */
public interface NFRegAccess extends Library {

  /* create an instance of this interface to load the library */
  NFRegAccess INSTANCE = (NFRegAccess) Native.loadLibrary("nf10", NFRegAccess.class);

  public static class NF2 extends Structure {
    public String device_name;
    public int fd;
    public int net_iface;

    @Override
    protected List getFieldOrder() {
      return Arrays.asList("device_name", "fd", "net_iface");
    };
  }

  public int readReg(int fd, int reg, IntByReference val);

  public int writeReg(int fd, int reg, int val);

  public int check_iface(NF2 nf2);

  public int openDescriptor(NF2 nf2);

  public int closeDescriptor(NF2 nf2);

  public void read_info(NF2 nf2);

  public void printHello(NF2 nf2, IntByReference val);
}
示例#10
0
  // 定义接口CLibrary,继承自com.sun.jna.Library
  public interface CLibrary extends Library {
    // 定义并初始化接口的静态变量 这一个语句是来加载 dll 的, 注意 dll 文件的路径
    // 可以是绝对路径也可以是相对路径,只需要填写 dll 的文件名,不能加后缀
    CLibrary Instance =
        (CLibrary)
            Native.loadLibrary(System.getProperty("user.dir") + "\\source\\NLPIR", CLibrary.class);
    // 初始化函数声明
    public int NLPIR_Init(String sDataPath, int encoding, String sLicenceCode);
    // 执行分词函数声明
    public String NLPIR_ParagraphProcess(String sSrc, int bPOSTagged);
    // 提取关键词函数声明
    public String NLPIR_GetKeyWords(String sLine, int nMaxKeyLimit, boolean bWeightOut);

    public String NLPIR_GetFileKeyWords(String sLine, int nMaxKeyLimit, boolean bWeightOut);
    // 添加用户词典声明
    public int NLPIR_AddUserWord(String sWord); // add by qp 2008.11.10
    // 删除用户词典声明
    public int NLPIR_DelUsrWord(String sWord); // add by qp 2008.11.10

    public String NLPIR_GetLastErrorMsg();
    // 退出函数声明
    public void NLPIR_Exit();
    // 文件分词声明
    public void NLPIR_FileProcess(String utf8File, String utf8FileResult, int i);
  }
示例#11
0
 /*package*/ static Kernel32 load() {
   try {
     return (Kernel32) Native.loadLibrary("kernel32", Kernel32.class);
   } catch (Throwable e) {
     LOGGER.log(Level.SEVERE, "Failed to load Kernel32", e);
     return InitializationErrorInvocationHandler.create(Kernel32.class, e);
   }
 }
示例#12
0
 @Override
 public <T> T loadLibrary(String libraryName, Class<T> libraryClass) {
   try {
     return libraryClass.cast(Native.loadLibrary(libraryName, libraryClass));
   } catch (Exception ex) {
     ex.printStackTrace();
     return null;
   }
 }
示例#13
0
  public interface Kernel32 extends W32APIOptions {
    Kernel32 instance = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class, DEFAULT_OPTIONS);

    boolean GetDiskFreeSpaceEx(
        String lpDirectoryName,
        LARGE_INTEGER.ByReference lpFreeBytesAvailable,
        LARGE_INTEGER.ByReference lpTotalNumberOfBytes,
        LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes);
  }
示例#14
0
  public interface TuxDriver extends Library {
    TuxDriver INSTANCE = (TuxDriver) Native.loadLibrary("tuxdriver", TuxDriver.class);
    public static boolean started = true;

    public static final int LOG_LEVEL_DEBUG = 0;
    public static final int LOG_LEVEL_INFO = 1;
    public static final int LOG_LEVEL_WARNING = 2;
    public static final int LOG_LEVEL_ERROR = 3;
    public static final int LOG_LEVEL_NONE = 4;

    public static final int LOG_TARGET_TUX = 0;
    public static final int LOG_TARGET_SHELL = 1;

    void TuxDrv_Start();

    void TuxDrv_Stop();

    String TuxDrv_PerformCommand(double delay, String cmd_str);

    void TuxDrv_ClearCommandStack();

    void TuxDrv_SetLogLevel(int level);

    void TuxDrv_SetLogTarget(int target);

    void TuxDrv_ResetPositions();

    void TuxDrv_ResetDongle();

    double get_time();

    /** Callback management (buttons and other events) */
    public abstract class EventCallback implements com.sun.jna.Callback {
      protected TuxDroid tuxdroid;

      public EventCallback(TuxDroid td) {
        super();
        tuxdroid = td;
      }

      public abstract boolean callback(String msg);
    }

    public int TuxDrv_SetStatusCallback(EventCallback ec);

    /** Not yet used methods */
    // TuxDrvError TuxDrv_GetStatusName(int id, char* name);
    // TuxDrvError TuxDrv_GetStatusId(char* name, int *id);
    // TuxDrvError TuxDrv_GetStatusState(int id, char *state);
    // TuxDrvError TuxDrv_GetStatusValue(int id, char *value);
    // void TuxDrv_GetAllStatusState(char *state);
    // int TuxDrv_TokenizeStatus(char *status, drv_tokens_t *tokens);
    // TuxDrvError TuxDrv_PerformMacroFile(char *file_path);
    // TuxDrvError TuxDrv_PerformMacroText(char *macro);
    // TuxDrvError TuxDrv_SoundReflash(char *tracks);
  }
  /** @param libraryPath */
  public JNAEtherstubHelper(String libraryPath) {

    String filePath = libraryPath + File.separator + LIB_NAME;

    logger.info("Loading Crossbow native library (" + filePath + ")");
    handle = (EtherstubHandle) Native.loadLibrary(filePath, EtherstubHandle.class);
    logger.info("Crossbow native library loaded!");

    handle.init();
  }
示例#16
0
  protected static synchronized void loadLibrary(UnixSyslogConfig config)
      throws SyslogRuntimeException {
    if (!OSDetectUtility.isUnix()) {
      throw new SyslogRuntimeException("UnixSyslog not supported on non-Unix platforms");
    }

    if (libraryInstance == null) {
      libraryInstance = (CLibrary) Native.loadLibrary(config.getLibrary(), CLibrary.class);
    }
  }
示例#17
0
/**
 * This JNA interface provides access to the environment variable-related functions in the C
 * library. How to use: CLibrary clib = CLibrary.INSTANCE; String s =
 * clib.getenv("DYLD_LIBRARY_PATH");
 */
public interface CLibrary extends Library {
  CLibrary INSTANCE = (CLibrary) Native.loadLibrary("c", CLibrary.class);

  int setenv(String name, String value, int overwrite);

  String getenv(String name);

  int unsetenv(String name);

  int putenv(String string);
}
 static {
   try {
     if (!Platform.isWindows()) {
       C_LIB = ((CLib) Native.loadLibrary("c", CLib.class));
     }
   } catch (Exception e) {
     Logger log = Logger.getInstance(UnixProcessManager.class);
     log.warn("Can't load c library", e);
     C_LIB = null;
   }
 }
示例#19
0
 static {
   SolarisLibrary lib = null;
   if (Constants.SUN_OS) {
     try {
       lib = (SolarisLibrary) Native.loadLibrary("c", SolarisLibrary.class);
     } catch (UnsatisfiedLinkError e) {
       logger.warn("unable to link C library. native methods (priv_set) will be disabled.", e);
     }
   }
   libc_solaris = lib;
 }
示例#20
0
 static {
   MacLibrary lib = null;
   if (Constants.MAC_OS_X) {
     try {
       lib = (MacLibrary) Native.loadLibrary("c", MacLibrary.class);
     } catch (UnsatisfiedLinkError e) {
       logger.warn("unable to link C library. native methods (seatbelt) will be disabled.", e);
     }
   }
   libc_mac = lib;
 }
示例#21
0
 static {
   LinuxLibrary lib = null;
   if (Constants.LINUX) {
     try {
       lib = (LinuxLibrary) Native.loadLibrary("c", LinuxLibrary.class);
     } catch (UnsatisfiedLinkError e) {
       logger.warn("unable to link C library. native methods (seccomp) will be disabled.", e);
     }
   }
   linux_libc = lib;
 }
示例#22
0
文件: Env.java 项目: davidhoyt/comm
  // <editor-fold defaultstate="collapsed" desc="JNA Library Declarations">
  interface EnvLibraryWindows extends Win32Library {
    // <editor-fold defaultstate="collapsed" desc="Constants">
    public static final String LIB_NAME = "msvcrt";

    public static final EnvLibraryWindows INSTANCE =
        (EnvLibraryWindows) Native.loadLibrary(LIB_NAME, EnvLibraryWindows.class);
    // </editor-fold>

    public String getenv(final String name);

    public int _putenv(final String name);
  }
/** Created by cam on 10/29/16. */
public interface GtkSeparatorMenuItemLibrary extends GtkMenuItemLibrary {
  GtkSeparatorMenuItemLibrary INSTANCE =
      (GtkSeparatorMenuItemLibrary)
          Native.loadLibrary("libgtk-3", GtkSeparatorMenuItemLibrary.class);

  /**
   * Creates a new GtkSeparatorMenuItem.
   *
   * @return a new GtkSeparatorMenuItem.
   */
  GtkSeparatorMenuItem gtk_separator_menu_item_new();
}
  static {
    // Set JNA to convert java.lang.String to char* using UTF-8, and match that with
    // the way we tell CF to interpret our char*
    // May be removed if we use toStringViaUTF16
    System.setProperty("jna.encoding", "UTF8");

    Map<String, Object> foundationOptions = new HashMap<String, Object>();
    // foundationOptions.put(Library.OPTION_TYPE_MAPPER, FoundationTypeMapper.INSTANCE);

    myFoundationLibrary =
        (FoundationLibrary)
            Native.loadLibrary("Foundation", FoundationLibrary.class, foundationOptions);
  }
示例#25
0
  public interface CV4l2 extends Library {

    CV4l2 INSTANCE =
        (CV4l2)
            Native.loadLibrary(
                (Platform.isWindows() ? "webcamstudio" : "webcamstudio"), CV4l2.class);

    int close_device(int device);

    int open_device(String path, int w, int h, int pixFormat);

    int writeData(int device, byte[] buffer, int length);
  }
示例#26
0
 private Louis() {
   INSTANCE = (LouisLibrary) Native.loadLibrary(("louis"), LouisLibrary.class);
   charSize = INSTANCE.lou_charSize();
   switch (charSize) {
     case 2:
       encoding = "UTF-16LE";
       break;
     case 4:
       encoding = "UTF-32LE";
       break;
     default:
       throw new RuntimeException("unsuported char size configured in liblouis: " + charSize);
   }
 }
示例#27
0
  // 定义接口CLibrary,继承自com.sun.jna.Library
  public interface CLibrary extends Library {
    // 定义并初始化接口的静态变量
    CLibrary Instance =
        (CLibrary) Native.loadLibrary("E://java//JNI//JnaTest_NLPIR//NLPIR", CLibrary.class);

    // printf函数声明
    public int NLPIR_Init(byte[] sDataPath, int encoding, byte[] sLicenceCode);

    public String NLPIR_ParagraphProcess(String sSrc, int bPOSTagged);

    public String NLPIR_GetKeyWords(String sLine, int nMaxKeyLimit, boolean bWeightOut);

    public void NLPIR_Exit();
  }
示例#28
0
public interface FastVerCode extends Library {

  FastVerCode INSTANCE = (FastVerCode) Native.loadLibrary("FastVerCode", FastVerCode.class);

  public String GetUserInfo(String UserName, String passWord);

  public String RecByte(byte[] imgByte, int len, String username, String password);

  public String RecYZM(String path, String UserName, String passWord);

  public void ReportError(WString UserName, WString passWord);

  public int Reglz(
      String userName, String passWord, String email, String qq, String dlId, String dlAccount);
}
示例#29
0
文件: Env.java 项目: davidhoyt/comm
  interface EnvLibraryUnix extends Library {
    // <editor-fold defaultstate="collapsed" desc="Constants">
    public static final String LIB_NAME = "c";

    public static final EnvLibraryUnix INSTANCE =
        (EnvLibraryUnix) Native.loadLibrary(LIB_NAME, EnvLibraryUnix.class);
    // </editor-fold>

    public String getenv(final String name);

    public int setenv(final String name, final String value, final int overwrite);

    public int unsetenv(final String name);

    public int chdir(final String path);
  }
示例#30
0
public interface GDI32Extra extends GDI32 {

  GDI32Extra INSTANCE =
      (GDI32Extra) Native.loadLibrary("gdi32", GDI32Extra.class, W32APIOptions.DEFAULT_OPTIONS);

  public boolean BitBlt(
      HDC hObject,
      int nXDest,
      int nYDest,
      int nWidth,
      int nHeight,
      HDC hObjectSource,
      int nXSrc,
      int nYSrc,
      DWORD dwRop);
}