private Hooking() { hookIDs = new List<HookInfo>(); hookCallbackThread = new Thread(keepAlive) ; mouseHook = new HookInfo(); mouseHook.callback = clearMouseLLInjectedFlag; mouseHook.hID = Win32.HookingIDs.WH_Mouse_LL; keyboardHook = new HookInfo(); keyboardHook.callback = clearKeyboardLLInjectedFlag; keyboardHook.hID = Win32.HookingIDs.WH_Keyboard_LL; }
static bool useHook_patch(InteractableVehicle __instance) { List <HookInfo> hooked = get_priv_hooked(__instance); if (hooked.Count > 0) { __instance.clearHooked(); return(false); } float radius; if (!Plugin.TryGetCustomDataFor <float>(__instance.asset.GUID, FieldName, out radius)) { radius = 3f; } var hook = get_priv_hook(__instance); var grab = get_priv_grab(); int num = Physics.OverlapSphereNonAlloc(hook.position, radius, grab, 67108864); for (int i = 0; i < num; i++) { InteractableVehicle vehicle = DamageTool.getVehicle(grab[i].transform); if (!(vehicle == null) && !(vehicle == __instance) && vehicle.isEmpty && !vehicle.isHooked && vehicle.asset.engine != EEngine.TRAIN) { HookInfo hookInfo = new HookInfo { target = vehicle.transform, vehicle = vehicle, deltaPosition = hook.InverseTransformPoint(vehicle.transform.position), deltaRotation = Quaternion.FromToRotation(hook.forward, vehicle.transform.forward) }; hooked.Add(hookInfo); vehicle.isHooked = true; __instance.ignoreCollisionWith(vehicle.vehicleColliders, true); } } set_priv_hooked(hooked, __instance); return(false); }
/// <summary> /// Process the given macro input and return a script. /// </summary> /// <param name="input">Input to process.</param> /// <returns>A runnable script.</returns> public string Process(string input) { var lines = input.Split(new[] { '\r', '\n' }); var ctx = ParseContext.None; var setupBody = string.Empty; var noneBody = string.Empty; var initBody = string.Empty; var disposeBody = string.Empty; var drawBody = string.Empty; var tHook = new HookInfo(); var hooks = new List <HookInfo>(); for (var i = 0; i < lines.Length; i++) { var line = lines[i]; if (line.StartsWith("INITIALIZE:")) { ctx = ParseContext.Init; continue; } if (line.StartsWith("DRAW:")) { ctx = ParseContext.Draw; continue; } if (line.StartsWith("DISPOSE:")) { ctx = ParseContext.Dispose; continue; } if (line.StartsWith("HOOK(")) { ctx = ParseContext.Hook; var args = Regex.Match(line, "HOOK\\((.+)+\\):").Groups[0].Captures[0].Value .Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(x => x[0] == ' ' ? x[1..] : x).ToArray();
private static void Callback(ScriptState luaState, HookInfo info) { var hookMgr = GetManager(luaState); if (hookMgr == null) { return; } if (hookMgr.Disposed) { return; } try { hookMgr.TriggerHook(new HookEventArgs(luaState, info)); } catch (Exception ex) { hookMgr.TriggerError(new ErrorEventArgs(ex)); } }
bool InstallHook(int threadId, HookInfo hookInfo) { if (hookInfo != null) { bool isOk = false; hookInfo.CbtHookHandle = IntPtr.Zero; hookInfo.GetMsgHookHandle = IntPtr.Zero; if (hookInfo.GetMsgHookHandle == IntPtr.Zero) { const int WH_GETMESSAGE = 3; hookInfo.GetMsgHookHandle = Win32.SetWindowsHookEx(WH_GETMESSAGE, procGetMsg, IntPtr.Zero, threadId); isOk = isOk || (hookInfo.GetMsgHookHandle != IntPtr.Zero); } if (hookInfo.CbtHookHandle == IntPtr.Zero) { const int WH_CBT = 5; hookInfo.CbtHookHandle = Win32.SetWindowsHookEx(WH_CBT, procCbt, IntPtr.Zero, threadId); isOk = isOk || (hookInfo.CbtHookHandle != IntPtr.Zero); } //if (hookInfo.MouseHandle == IntPtr.Zero) { // const int WH_MOUSE = 7; // hookInfo.MouseHandle = Win32.SetWindowsHookEx(WH_MOUSE, MouseProc, 0, threadId); // isOk = isOk || (hookInfo.MouseHandle != IntPtr.Zero); //} //if (hookInfo.KeyboardHandle == IntPtr.Zero) { // const int WH_KEYBOARD = 2; // hookInfo.KeyboardHandle = Win32.SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, 0, threadId); // isOk = isOk || (hookInfo.KeyboardHandle != IntPtr.Zero); //} //if (hookInfo.MsgFilterHandle == IntPtr.Zero) { // const int WH_MSGFILTER = -1; // hookInfo.MsgFilterHandle = Win32.SetWindowsHookEx(WH_MSGFILTER, MsgFilterProc, 0, threadId); // isOk = isOk || (hookInfo.MsgFilterHandle != IntPtr.Zero); //} return(isOk); } return(false); }
internal IntPtr addHook(Win32.HookingIDs hID, WinAPI.LowLevelMouseProc callback) { if (ModuleHandle == IntPtr.Zero) { using (var curProcess = Process.GetCurrentProcess()) using (var curModule = curProcess.MainModule) { IntPtr ret = WinAPI.SetWindowsHookEx((int)hID, callback, WinAPI.GetModuleHandle(curModule.ModuleName), 0); HookInfo info = new HookInfo(); info.hookID = ret; info.callback = callback; info.hID = hID; hookIDs.Add(info); return ret; } } else { IntPtr ret = WinAPI.SetWindowsHookEx((int)hID, callback, ModuleHandle, 0); HookInfo info = new HookInfo(); info.hookID = ret; info.callback = callback; info.hID = hID; hookIDs.Add(info); hookIDs.Add(info); return ret; } }
public WriteBytesHookTransferStation(HookInfo info) : base(info) { }
public AresHookTransferStation(HookInfo info) : base(info) { }
public BuildTriggerRequest(HookInfo hookInfo, BuildParams buildParams) { hook_info = hookInfo; build_params = buildParams; }
public HookInfo enable(IntPtr Handle, Modifiers Mod, Keys Key) { HookInfo item = new HookInfo(Handle, this.freeID++); this.hookedKeys.Add(item); RegisterHotKey(Handle, item.ID, (int)Mod, (int)Key); return item; }
//1. get hook gameObject //2. add component //3. activate //4. Init //5. OnEnter //6. Add it into Map public void NewEnter(Message msg) { MessageSycHook allhookInfo = JsonReader.Deserialize <MessageSycHook>(msg.rawString); int iCount = allhookInfo.playerList.Count; if (iCount == 1) { HookInfo info = allhookInfo.playerList[0]; this.PassTime = info.enterTime; HookPos hookPos = (HookPos)Enum.Parse(typeof(HookPos), info.chairId); AllStuffNeeded allStuff = SceneMgr.Instance.hookPosAllStuffMap[hookPos]; hook = allStuff.gmObjRealPoleEnd.AddComponent <Hook>(); allStuff.gmObjBoat.SetActive(true); FloatEffect floatEffect = allStuff.gmObjBoat.AddComponent <FloatEffect>(); floatEffect.Init(); floatEffect.StartEffect(); hook.gameObject.SetActive(true); hook.Init(hookPos); hook.OnEnter(info.enterTime, _player, allStuff); uIDHookMap.Add(info.uid, hook); _raisePlayerInitCompleteEvent(hook.hookPos); _raisePlayerChangeEvent(hook.hookPos, true); _raiseScoreChangeEvent(hook.hookPos, _player.Score); raiseLotteryChangeEvent(hook.hookPos, _player.Lottery); raiseHookPowerEvent(1); } else if (iCount == 2) { this.PassTime = Mathf.Max(allhookInfo.playerList[0].enterTime, allhookInfo.playerList[1].enterTime); for (int i = 0; i < iCount; i++) { HookInfo info = allhookInfo.playerList[i]; if (info.uid == Game.Instance.player.UID) { if (hook == null) { this.PassTime = info.enterTime; HookPos hookPos = (HookPos)Enum.Parse(typeof(HookPos), info.chairId); AllStuffNeeded allStuff = SceneMgr.Instance.hookPosAllStuffMap[hookPos]; hook = allStuff.gmObjRealPoleEnd.AddComponent <Hook>(); allStuff.gmObjBoat.SetActive(true); FloatEffect floatEffect = allStuff.gmObjBoat.AddComponent <FloatEffect>(); floatEffect.Init(); floatEffect.StartEffect(); hook.gameObject.SetActive(true); hook.Init(hookPos); hook.OnEnter(info.enterTime, _player, allStuff); uIDHookMap.Add(info.uid, hook); _raisePlayerInitCompleteEvent(hook.hookPos); _raisePlayerChangeEvent(hook.hookPos, true); _raiseScoreChangeEvent(hook.hookPos, _player.Score); raiseLotteryChangeEvent(hook.hookPos, _player.Lottery); raiseHookPowerEvent(1); } } else if (info.uid != Game.Instance.player.UID) { HookPos hookPos = (HookPos)Enum.Parse(typeof(HookPos), info.chairId); AllStuffNeeded allStuff = SceneMgr.Instance.hookPosAllStuffMap[hookPos]; if (oHook == null) { oHook = allStuff.gmObjRealPoleEnd.AddComponent <OHook>(); //Assume that player can't change position in level oHook.Init(hookPos); FloatEffect floatEffect = allStuff.gmObjBoat.AddComponent <FloatEffect>(); floatEffect.Init(); floatEffect.StartEffect(); } allStuff.gmObjBoat.SetActive(true); oHook.gameObject.SetActive(true); uIDHookMap.Add(info.uid, oHook); //Init oPlayer(no definition, just intialize it) _oPlayer.UID = info.uid; _oPlayer.Score = info.score; _oPlayer.Lottery = info.lottery; uIDPlayerMap.Add(info.uid, _oPlayer); oHook.OnEnter(info.enterTime, _oPlayer, allStuff); oHook.ChangeHooks(info.hook); _raisePlayerChangeEvent(oHook.hookPos, true); _raiseScoreChangeEvent(oHook.hookPos, _oPlayer.Score); raiseLotteryChangeEvent(oHook.hookPos, _oPlayer.Lottery); } } } else { DebugLogger.LogWarning(eLogType.LT_LOGIC, iCount + " hooks, out of bound!"); } }
bool GenerateHook (HookType hookType, HookDir dir, Type type, string member) { GenerateHooks (hookType, dir, type, null, HookAction.InsertBefore); if (GenerateHooks (hookType, dir, type, null, HookAction.Replace)) { GenerateHooks (hookType, dir, type, null, HookAction.InsertAfter); return true; } else { HookInfo hi = new HookInfo (); hi.HookType = hookType; hi.Type = type; hi.Member = member; hi.Direction = dir; _hookOpenHooks.Push (hi); return false; } }
public void disable(HookInfo i) { this.RemoveHook(i); UnregisterHotKey(i.hWnd, i.ID); }
/// <summary> /// removes a HookInfo from the list of hooked keys /// </summary> /// <param name="hInfo">HookInfo of a registered key</param> private void RemoveHook(HookInfo hInfo) { for (int i = 0; i < hookedKeys.Count; i++) { if (hookedKeys[i].hWnd == hInfo.hWnd && hookedKeys[i].ID == hInfo.ID) { hookedKeys.RemoveAt(i--); } } }
/// <summary> /// Enables a global hotkey hook /// </summary> /// <param name="Handle">Handle to a form or application message processing class that can receive messages. Easiest: a form with overridden WndProc method</param> /// <param name="Mod">Modifiers (Alt, Shift, ...)</param> /// <param name="Key">Key to record</param> /// <returns>Hook information, required for disabling. Can also be obtained with HookedKeys property</returns> public HookInfo enable(IntPtr Handle,Modifiers Mod, Keys Key) { HookInfo i=new HookInfo(Handle,freeID++); hookedKeys.Add(i); RegisterHotKey(Handle, i.ID, (int)Mod, (int)Key); return i; }
public JumpHookTransferStation(HookInfo info) : base(info) { }
public void Disable(HookInfo hInfo) { RemoveHook(hInfo); UnregisterHotKey(hInfo.Hwnd, hInfo.Id); }
public static extern int GetHookInfo(IntPtr luaState, ref HookInfo info);
public HookEventArgs(ScriptState luaState, HookInfo info) { _luaState = luaState; _info = info; }
public static extern int GetStack(IntPtr luaState, int level, ref HookInfo info);
public void disable(HookInfo i) { this.RemoveHook(i); UnregisterHotKey(i.hWnd, i.ID); }
public static extern void FreeDebug(HookInfo info);
private void RemoveHook(HookInfo hInfo) { for (int i = 0; i < this.hookedKeys.Count; i++) { if ((this.hookedKeys[i].hWnd == hInfo.hWnd) && (this.hookedKeys[i].ID == hInfo.ID)) { this.hookedKeys.RemoveAt(i--); } } }
public static void FreeDebug(HookInfo info) { ScriptApi.FreeDebug(info); }