I am attempting to monitor mouse events with Low Level Mouse Hook in Java using the JNA (or Java Native Access) to check for the LLMHF_INJECTED
flag. I cant figure out for how to cast the lparam pointer to a MSLLHOOKSTRUCT
like I would in c++. This is what my current callback function looks like.
LowLevelMouseProc LLMP = new LowLevelMouseProc() {
public LRESULT callback(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode >= 0){
}
Pointer ptr = lParam.toPointer();
long peer = Pointer.nativeValue(ptr);
return User32.INSTANCE.CallNextHookEx(hook, nCode, wParam,new LPARAM(peer));
}
};
I also have the hook struct outlined in its own class as shown below:
public class MSLLHOOKSTRUCT extends Structure{
public static class ByReference extends MSLLHOOKSTRUCT implements Structure.ByReference {};
public POINT pt;
public DWORD mouseData;
public DWORD flags;
public DWORD time;
public ULONG_PTR dwExtraInfo;
@Override
protected List<String> getFieldOrder() {
return null;
}
}
I just need to know how to map the pointer to the MSLLHOOKSTRUCT
.