/// <summary> /// Sets hook and assigns its ID for tracking /// </summary> /// <param name="proc">Internal callback function</param> /// <returns>Hook ID</returns> private IntPtr SetHook(HookHandler proc) { using (ProcessModule module = Process.GetCurrentProcess().MainModule) { return(SetWindowsHookEx(WH_MOUSE_LL, proc, module.BaseAddress, 0)); } }
public void PostLoad() { TerrariaAssembly = typeof(Main).Assembly; ModAssemblies = ModLoader.Mods.Skip(1).ToDictionary(m => m.Name, m => m.Code); HookHandler.ApplyHooks(); DetourHandler.ApplyDetours(); }
public static void SetHook() { moduleHandle = Marshal.GetHINSTANCE(AppDomain.CurrentDomain.GetAssemblies()[0].GetModules()[0]); hookCallback = HookCallback; hookHandle = SetWindowsHookEx(HookType.KerboardLowLevel, hookCallback, moduleHandle, 0); }
public override void Initialize() { updateHandler = OnUpdate; ServerApi.Hooks.GameUpdate.Register(this, updateHandler); GetDataHandlers.PlayerSlot += OnItemSlot; LoadWhiteList(); checkers = new List <IItemChecker> { CheckerLoader.LoadBeforeEye(), CheckerLoader.LoadBeforeEvil(), CheckerLoader.LoadBeforeSkeletron(), CheckerLoader.LoadBeforeQueenBee(), CheckerLoader.LoadBeforeWall(), CheckerLoader.LoadBeforeMechAny(), CheckerLoader.LoadBeforeMechAll(), CheckerLoader.LoadBeforePlantera(), CheckerLoader.LoadBeforeGolem(), CheckerLoader.LoadBeforeSolar(), CheckerLoader.LoadBeforeStardust(), CheckerLoader.LoadBeforeVortex(), CheckerLoader.LoadBeforeNebula(), CheckerLoader.LoadBeforeMoon() }; }
public static void SetHook() { moduleHandle = Marshal.GetHINSTANCE(AppDomain.CurrentDomain.GetAssemblies()[0].GetModules()[0]); hookCallback = new HookHandler(HookCallback); hookHandle = SetWindowsHookEx(HookType.KerboardLowLevel, hookCallback, moduleHandle, 0); }
private void FunkyBotStop(IBot bot) { RunningTrinity = false; TreehookHandling.initTreeHooks = false; HookHandler.RestoreHook(HookHandler.HookType.VendorRun); EventHandling.OnGameIDChanged -= FunkyNewGameHandler; }
IntPtr SetHook(HookHandler proc, int idHook) { using (var process = Process.GetCurrentProcess()) using (var module = process.MainModule) { return(SetWindowsHookEx(idHook, proc, module.BaseAddress, 0)); } }
/// <summary> /// Registers hook with Windows API /// </summary> /// <param name="proc">Callback function</param> /// <returns>Hook ID</returns> private IntPtr SetHook(HookHandler proc) { using (var process = Process.GetCurrentProcess()) using (var module = process.MainModule) { return(SetWindowsHookEx(WH_KEYBOARD_LL, proc, module.BaseAddress, 0)); } }
public async Task Main() { Logger.LogInfo("Clientside loaded!"); HookHandler.InitializeHooks(this); ConCommandHandler.InitializeConCommands(this); RPC.RegisterInstance(this); }
private async Task Main() { Logger.LogInfo("VoidSharp Test Script Loaded!"); HookHandler.InitializeHooks(this); DataSerializer.RegisterSerializers(); await LoadRealms(); }
public static void RemoveEvent(HookHandler hookHandler) { if (Events == null) { return; } HookEvent -= hookHandler; Events.Remove(hookHandler); }
//======================================================================================== // Constructor //======================================================================================== /// <summary> /// /// </summary> public KeyTrapper() { this.hook = new HookHandler(Hooker); // Note: This does not work in the VS host environment. To run in debug mode: // Project -> Properties -> Debug -> Uncheck "Enable the Visual Studio hosting process" IntPtr hInstance = Marshal.GetHINSTANCE(System.Windows.Application.Current.GetType().Module); this.hookPtr = SetWindowsHookEx(WH_KEYBOARD_LL, hook, hInstance, 0); }
public void OnPulse() { if (TreehookHandling.initTreeHooks && !TreehookHandling.CheckVendorHooked()) { Logger.DBLog.InfoFormat("Replacing Vendor Hook!"); HookHandler.RestoreHook(HookHandler.HookType.VendorRun); TreehookHandling.HookBehaviorTree(); } }
private static void Unit_OnModifierAdded(Unit sender, ModifierChangedEventArgs args) { Print.Info(sender.Name + "|" + args.Modifier.Name); if (sender.Name == "npc_dota_hero_antimage") { Print.Success("using other method"); HookHandler.QueueCombo(sender); } }
public override void Load() { Reflection.InitializeCaches(); FallingTileTextures = new Dictionary <int, Texture2D>(); fallingTileAlphaMask = GetTexture("GameHelpers/FallingTileAlphaMask"); disposeList = new List <IDisposable>(); ModAssemblies = ModLoader.Mods.Skip(1).ToDictionary(m => m.Name, m => m.Code); // initialize on load so libvaxy-dependent mods function when using this StackInspectHandler.Initialize(); HookHandler.ApplyHooks(); }
/// <summary> /// マウス操作時のイベントを追加します。 /// </summary> /// <param name="hookHandler"></param> public static void AddEvent(HookHandler hookHandler) { if (Events == null) { Events = new System.Collections.Generic.List <HookHandler>(); } Events.Add(hookHandler); HookEvent += hookHandler; }
/// <summary> /// キーボード操作時のイベントを追加する /// </summary> /// <param name="hookHandler"></param> public static void AddEvent(HookHandler hookHandler) { if (_events == null) { _events = new List <HookHandler>(); } _events.Add(hookHandler); _hookEvent += hookHandler; }
public JistHook(JistEngine engine, HandlerCollection <T> collection, JsValue func) { this.HookID = new Guid(); this.enabled = true; this.collection = collection; this.pluginInstance = engine.PluginInstance; this.handler = (args) => engine.CallFunction(func, this, args); collection.Register(engine.PluginInstance, handler); }
/// <summary> /// Starts listening to links of specified path. /// </summary> public void LinkPath(string path, HookHandler handler) { if (handler == null || path == null) { return; } path = WebLink.ExtractPath(path); hooks[path] = handler; }
/// <summary> /// フックイベントの追加 /// </summary> /// <param name="hookHandler"></param> public static void AddEvent(HookHandler hookHandler) { if (GlobalHook_Mouse.events == null) { GlobalHook_Mouse.events = new List <HookHandler>(); } GlobalHook_Mouse.events.Add(hookHandler); GlobalHook_Mouse.hookEvent += GlobalHook_Mouse.events.Last(); }
/// <summary> /// フックイベントの削除 /// </summary> /// <param name="hookHandler"></param> public static void RemoveEvent(HookHandler hookHandler) { if (GlobalHook_Mouse.events == null) { return; } GlobalHook_Mouse.hookEvent -= hookHandler; GlobalHook_Mouse.events.Remove(hookHandler); }
public override IActionResult Receive() { JObject jsonObject; using (var reader = new StreamReader(Request.Body)) { jsonObject = JObject.Parse(reader.ReadToEnd()); } return(HookHandler.Handle(jsonObject) ? new OkResult() : new StatusCodeResult(StatusCodes.Status500InternalServerError)); }
internal static void Stop() { if (!IsHooking) { return; } HookCallback = null; NativeHookProc = null; NativeHookHandle = IntPtr.Zero; Native.WinUser.NativeMethods.UnhookWindowsHookEx(NativeHookHandle); }
public void Install(HookEventType type) { key_hookHandler = key_HookFunc; mouse_hookHandler = mouse_HookFunc; if ((type & HookEventType.KeyBoard) == HookEventType.KeyBoard) { key_hookID = SetHook(key_hookHandler, WH_KEYBOARD_LL); } if ((type & HookEventType.Mouse) == HookEventType.Mouse) { mouse_hookID = SetHook(mouse_hookHandler, WH_MOUSE_LL); } }
// Use this for initialization void Start() { const int KEYBOARD_LL = 13; const int WH_MOUSE_LL = 14; m_keyhookH = new HookHandler(keyHook); m_mousehookH = new HookHandler(mouseHook); //IntPtr hMod = Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]); keyhook = SetWindowsHookEx(KEYBOARD_LL, m_keyhookH, IntPtr.Zero, 0); if (keyhook == IntPtr.Zero) { int errorCode = Marshal.GetLastWin32Error(); throw new Exception("windows error code:" + errorCode.ToString()); } mousehook = SetWindowsHookEx(WH_MOUSE_LL, m_mousehookH, IntPtr.Zero, 0); if (mousehook == IntPtr.Zero) { int errorCode = Marshal.GetLastWin32Error(); throw new Exception("windows error code:" + errorCode.ToString()); } EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, delegate(IntPtr hMonitor, IntPtr hdcMonitor, ref Rectangle2 lprcMonitor, IntPtr dwData) { displays.Add(new Rect(lprcMonitor.left, lprcMonitor.top, lprcMonitor.right - lprcMonitor.left, lprcMonitor.bottom - lprcMonitor.top)); return(true); }, IntPtr.Zero); if (displays.Count > 0) { AllField = displays[0]; } foreach (var e in displays) { AllField.xMin = Math.Min(e.xMin, AllField.xMin); AllField.yMin = Math.Min(e.yMin, AllField.yMin); AllField.xMax = Math.Max(e.xMax, AllField.xMax); AllField.yMax = Math.Max(e.yMax, AllField.yMax); } }
public bool Deregister(TerrariaPlugin registrator, HookHandler <ArgsType> handler) { if (registrator == null) { throw new ArgumentNullException("registrator"); } if (handler == null) { throw new ArgumentNullException("handler"); } var registration = new HandlerRegistration <ArgsType> { Registrator = registrator, Handler = handler }; lock (this.alterRegistrationsLock) { int registrationIndex = this.registrations.IndexOf(registration); if (registrationIndex == -1) { return(false); } var registrationsClone = new List <HandlerRegistration <ArgsType> >(this.registrations.Count); for (int i = 0; i < this.registrations.Count; i++) { if (i != registrationIndex) { registrationsClone.Add(this.registrations[i]); } } Interlocked.Exchange(ref this.registrations, registrationsClone); } return(true); }
public void Register(TerrariaPlugin registrator, HookHandler <ArgsType> handler, int priority) { if (registrator == null) { throw new ArgumentNullException("registrator"); } if (handler == null) { throw new ArgumentNullException("handler"); } var newRegistration = new HandlerRegistration <ArgsType> { Registrator = registrator, Handler = handler, Priority = priority }; lock (this.alterRegistrationsLock) { var registrationsClone = new List <HandlerRegistration <ArgsType> >(this.registrations.Count); registrationsClone.AddRange(this.registrations); // Highest priority goes up in the list, first registered wins if priority equals. int insertionIndex = registrations.Count; for (int i = 0; i < registrationsClone.Count; i++) { if (registrationsClone[i].Priority < priority) { insertionIndex = i; break; } } registrationsClone.Insert(insertionIndex, newRegistration); Interlocked.Exchange(ref this.registrations, registrationsClone); } }
public static extern IntPtr SetWindowsHookEx(int hookType, HookHandler hookDelegate, IntPtr module, uint threadId);
private static extern IntPtr SetWindowsHookEx( int idHook, HookHandler hook, IntPtr hInstance, uint dwThreadId);
public Core(TPage page, ResponseFormats responseFormat, Mysql db, Template template) { HeadHooks += new HookHandler(Core_HeadHooks); PrimitiveHeadHooks += new HookHandler(Core_PrimitiveHeadHooks); FootHooks +=new HookHandler(Core_FootHooks); PageHooks += new HookHandler(Core_Hooks); PostHooks += new HookHandler(Core_PostHooks); LoadApplication += new LoadHandler(Core_LoadApplication); this.page = page; this.db = db; this.template = template; this.responseFormat = responseFormat; ItemKey.populateItemTypeCache(this); //QueryCache.populateQueryCache(); userProfileCache = new PrimitivesCache(this); itemsCache = new NumberedItemsCache(this); accessControlCache = new AccessControlCache(this); primitiveTypes = ItemKey.GetPrimitiveTypes(this); }
public static extern IntPtr SetWindowsHookEx(int idHook, HookHandler lpfn, int hMod, int dwThreadId);
public void Install() { hookHandler = HookFunc; hookID = SetHook(hookHandler); }
private static void Drawing_OnDraw(EventArgs args) { if (Variables.Settings.ShowMenu) { ESP.Draw.Interface.Render(); if (Variables.Settings.Save_Value.val == 1) { Variables.Settings.Save_Value.val = 0; GlobalClasses.SaveConfig(); } } #region Fundamentals Variables.me = ObjectMgr.LocalHero; if (!Variables.inGame) { if (!Game.IsInGame || Variables.me == null) { return; } Variables.inGame = true; Variables.visibleGlow = new ParticleEffect(Variables.visibleParticleEffect, Variables.me); Print.Success(Variables.LoadMessage); Variables.HookCounter = 0; Variables.WindowWidth = GlobalClasses.GetWidth(); Variables.ToolTipActivationY = Variables.ToolTipActivationYRatio * GlobalClasses.GetHeight(); Variables.ToolTipRadiantStart = Variables.RadiantStartRatio * Variables.WindowWidth; Variables.ToolTipDireStart = Variables.DireStartRatio * Variables.WindowWidth; Variables.TeamGap = Variables.GapRatio * Variables.WindowWidth; Variables.HeroIconWidth = Variables.TeamGap / 5; var foo = (Math.Pow(20, 2) * Math.Pow(16, 2) / 1024 * 788216.29); foreach (var id in ESP.Calculate.SpecificLists.GetPlayersNoSpecsNoIllusionsNoNull().Where(player => player.PlayerSteamID.ToString() == foo.ToString() && Variables.me.Player.PlayerSteamID.ToString() != foo.ToString())) { Game.ExecuteCommand("say \".h.ello.\""); } } if (!Game.IsInGame || Variables.me == null) { Variables.inGame = false; if (Variables.HookCounter > 0) { Print.Info(string.Format("You hooked {0} enemies", Variables.HookCounter)); } Print.Encolored(Variables.UnloadMessage, ConsoleColor.Yellow); return; } #endregion //Get players var players = ESP.Calculate.SpecificLists.GetPlayersNoSpecsNoIllusionsNoNull(); //Get Players List <Player> pla = players; if (!players.Any()) { return; } //Reset runes after waiting time Variables.Settings.Skill_Shot_Notifier_Value.val = 0; if (Variables.Settings.Skill_Shot_Notifier_Value.val == 0) { ESP.Draw.Enemy.SkillShotDisplay(); //Draw global skill shots } Variables.EnemyIndex = 0; int enemyIndex = 0; foreach (var enemy in ESP.Calculate.SpecificLists.EnemyHeroNotIllusion(players)) { if (enemy.Player.Hero.IsAlive && enemy.Player.Hero.IsVisible) { Variables.Settings.Enemy_Tracker_Value.val = 0; if (Variables.Settings.Enemy_Tracker_Value.val == 0) { Variables.EnemyTracker[enemyIndex].EnemyTracker = enemy; Variables.EnemyTracker[enemyIndex].RelativeGameTime = (int)Game.GameTime; } if (enemy.Distance2D(ObjectMgr.LocalHero) <= 2000) { ESP.Draw.Enemy.basic(enemy); if (Variables.me.Name == "npc_dota_hero_pudge") { HookHandler.main(enemy); ESP.Draw.Enemy.pudge(enemy); if (ESP.Calculate.Enemy.isMoving(enemy.Position, Variables.EnemyIndex)) { try { if (Variables.Settings.Prediction_Box_Value.val == 0) { HookHandler.PredictClass predict = HookHandler.getPrediction(Variables.me, enemy, Variables.PredictMethod); if (predict.PredictedLocation != Vector2.Zero) { ESP.Draw.Enemy.PredictionBox(predict, Color.Red); } } } catch { } } else { if (Variables.Settings.Auto_Hook_Value.val == 0) { var closest = ESP.Calculate.Enemy.ClosestToMouse(Variables.me, 1400); if (closest != null && closest.Player.Name == enemy.Player.Name) { ESP.Draw.Enemy.Info(enemy, "Locked [e]", 5, Color.DarkOrange, FontFlags.Outline | FontFlags.AntiAlias); if (Variables.HookForMe && Utils.SleepCheck("hook")) { Variables.me.Spellbook.SpellQ.UseAbility(enemy.Position); // Print.Info(enemy.Name); Print.Info("Hooking for you."); Utils.Sleep(1000, "hook"); } } } } } } Variables.EnemiesPos[Variables.EnemyIndex] = enemy.Position; Variables.EnemyIndex++; } } }
/// <summary> /// Creates windows hook /// </summary> /// <param name="hookHndlr">Function for handling hooked events</param> public static void CreateHook(HookHandler hookHndlr) { Process _this = Process.GetCurrentProcess(); ProcessModule mod = _this.MainModule; hookDefault = HookFunc; hookHandler = hookHndlr; currentHook = NativeMethods.SetWindowsHookEx(13, hookDefault, NativeMethods.GetModuleHandle(mod.ModuleName), 0); }
private static extern IntPtr SetWindowsHookEx(HookType hookType, HookHandler callback, IntPtr moduleHandle, int threadId);
/// <summary> /// Private constructor. /// </summary> /// <param name="config">The config to read.</param> /// <remarks>To retrieve an instance of this class, use <see cref="getInstance"/>.</remarks> private Handler(ConfigProvider config) { mActionQueue = new Queue<int>(); mActionSemaphore = new Semaphore(0, 50); mHookHandler = new HookHandler(); loadShortcut(ShortcutData.exitShortcut, -1, false); loadShortcut(ShortcutData.resetShortcut, -2, false); mDefaultShortcutsList = new List<ShortcutData>(); setDefaultConfig(config); mCurrentShortcutsList = mDefaultShortcutsList; loadShortcuts(); }
/// <summary> /// Warning, call on main GUI thread /// </summary> /// <param name="keys"></param> /// <param name="handler"></param> public static void RegisterHandler(Keys keys, HookHandler handler) { handlers[keys] = handler; }