Decompile and Rebuild v0.1.2
begin work: base version 0993 move original program for orgnization golang work snapshot decompiled code it builds! (but doesnt run) source code bump library stash decompile 0.1.2, make it build
This commit is contained in:
commit
3e31aa0363
45 changed files with 7996 additions and 0 deletions
55
ControlApp/LockMouse.cs
Normal file
55
ControlApp/LockMouse.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ControlApp;
|
||||
|
||||
internal class LockMouse
|
||||
{
|
||||
private delegate nint LowLevelMouseProc(int nCode, nint wParam, nint lParam);
|
||||
|
||||
private const int WH_MOUSE_LL = 14;
|
||||
|
||||
private static LowLevelMouseProc _mouseProc = MouseHookCallback;
|
||||
|
||||
private static nint _mouseHookID = IntPtr.Zero;
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern nint SetWindowsHookEx(int idHook, LowLevelMouseProc lpfn, nint hMod, uint dwThreadId);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool UnhookWindowsHookEx(nint hhk);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern nint CallNextHookEx(nint hhk, int nCode, nint wParam, nint lParam);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern nint GetModuleHandle(string lpModuleName);
|
||||
|
||||
private static nint SetMouseHook(LowLevelMouseProc proc)
|
||||
{
|
||||
using Process curProcess = Process.GetCurrentProcess();
|
||||
using ProcessModule curModule = curProcess.MainModule;
|
||||
return SetWindowsHookEx(14, proc, GetModuleHandle(curModule.ModuleName), 0u);
|
||||
}
|
||||
|
||||
private static nint MouseHookCallback(int nCode, nint wParam, nint lParam)
|
||||
{
|
||||
if (nCode >= 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return CallNextHookEx(_mouseHookID, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
public void Lock()
|
||||
{
|
||||
_mouseHookID = SetMouseHook(_mouseProc);
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
UnhookWindowsHookEx(_mouseHookID);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue