jna

How to detect when a process/ thread is waiting for user input

假如想象 提交于 2019-12-20 04:22:59
问题 Is there a way to detect when a windows process is waiting for user input. For instance, when you click on a particular program it loads, in this case the program's process is probably in loading state rite? what happens when the program is fully loaded and is waiting for user input to procedure to next step. Is there a way to detect this? Cheers 回答1: Call WaitForInputIdle with a handle to a process. it will suspend execution until the program completes its initialization and is waiting for

How to use JNA callback

我只是一个虾纸丫 提交于 2019-12-20 03:49:12
问题 I am using JNA to call functions of a dll file. simpleDLL.h: typedef int (__stdcall *eventCallback)(unsigned int id, int value); namespace test { class hotas { public: static __declspec(dllexport) int readValue(int a); static __declspec(dllexport) void setCallback(eventCallback evnHnd); }; } simpleDLL.cpp: #include "simpleDLL.h" #include <stdexcept> using namespace std; namespace test { eventCallback callback1 = NULL; int test::readValue(int a) { return 2*a; } void test::setCallback

JNA Memory Leak - How to fix?

烂漫一生 提交于 2019-12-20 03:43:15
问题 public static User32 USER32_INSTANCE = (User32) Native.loadLibrary("user32", User32.class); user32 = USER32_INSTANCE; user32.EnumWindows((hWnd, arg) -> { int size = 1024 * 8; char[] buffer = new char[size]; USER32_INSTANCE.GetWindowTextW(hWnd, buffer, size); char[] buffer2 = new char[size]; PointerByReference pointer = new PointerByReference(); User32DLL.GetWindowThreadProcessId(hWnd, pointer); Pointer process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, false, pointer.getValue(

Exception in thread “main” java.lang.UnsatisfiedLinkError: jnidispatch (/com/sun /jna/win32-x86/jnidispatch.dll) not found in resource path

旧时模样 提交于 2019-12-20 03:27:08
问题 I have a small test program which runs perfectly in the JBuilder 6 debugger. When I make a .jar file and run it I get an error >java -jar testadll.jar Start of DLL test Exception in thread "main" java.lang.UnsatisfiedLinkError: jnidispatch (/com/sun /jna/win32-x86/jnidispatch.dll) not found in resource path at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:708) at com.sun.jna.Native.loadNativeLibrary(Native.java:685) at com.sun.jna.Native.<clinit>(Native.java:109) at testadll

JNA for Windows API function GetVolumePathNamesForVolumeName

佐手、 提交于 2019-12-20 01:07:14
问题 I've successfully used JNA to call a couple of Windows API functions but I get stuck at this one GetVolumePathNamesForVolumeName The full C declaration is: BOOL WINAPI GetVolumePathNamesForVolumeName( __in LPCTSTR lpszVolumeName, __out LPTSTR lpszVolumePathNames, __in DWORD cchBufferLength, __out PDWORD lpcchReturnLength ); My Kernel32 interface method prototype for this is: boolean GetVolumePathNamesForVolumeName(String lpszVolumeName, Pointer lpszVolumePathNames, int cchBufferLength,

JNA - calling methods upon C++ instance passed back from DLL

我与影子孤独终老i 提交于 2019-12-19 18:56:50
问题 Say I have a C++ DLL with a single exported method such as: CustomerProcessor* getInstance(); i.e. it simply returns an instance of the class that actually contains the methods I need to call. I know I can map the getInstance() method to a Class in Java using JNA (extending com.sun.jna.Library), store the returned CustomerProcessor instance in a com.sun.jna.Pointer. Can I then somehow map this to the CustomerProcessor class so that I can call methods upon it (and if so, how)? 回答1: For any

JNA: Native Library dependencies and JAR extraction

我是研究僧i 提交于 2019-12-19 09:22:03
问题 I will access the MSP430.dll (see here) via JNA. But this library has a dependency to other native library, which cames bundled with the MSP430.dll. This dependend native library is called HIL.dll. With use of jna.library.path all does work perfect. Now I would bundle the native librarys to my own .jar package. Then I would use the automatic native library loading from jar of the JNA framework. But this makes problems with native librarys that have dependencies. If I package the MSP430.dll

Java JNA focus a specific Window

一世执手 提交于 2019-12-19 04:52:28
问题 I am trying to give my application the power to focus another Window (Notepad in this case) My Class is looking like this public static class Win32WindowUtils { public interface User32 extends StdCallLibrary { User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class, W32APIOptions.DEFAULT_OPTIONS); HWND GetParent(HWND hWnd); HWND FindWindow(String lpClassName, String lpWindowName); HWND SetFocus(HWND hWnd); HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, String lpszClass,

Converting String to Pointer for JNA

时光怂恿深爱的人放手 提交于 2019-12-18 08:32:12
问题 I'm trying to use JNA to query the effective permissions for a file in Windows. Eventually, I plan on using the GetEffectiveRightsFromAcl function, but to do so, I need to provide a pointer to a populated TRUSTEE structure. The JNA Platform (platform.jar) doesn't appear define this struct, so I'm trying to define it myself instead. Here's what I have so far: public static class TRUSTEE extends Structure { public TRUSTEE() { super(); } public TRUSTEE(Pointer p) { super(p); read(); } public