public bool Install() { if (!Exists()) { return(false); } try { pd = new ProcessDebugger(process.Id); pd.Run(); var now = DateTime.Now; while (!pd.WaitForComeUp(50) && now.MSecToNow() < 1000) { } foreach (ProcessThread pT in process.Threads) { if (pd.GetThreadStartAddress(pT.Id) == pd.GetAddress(D2Pointers.Game.mainThread)) { mainThreadId = pT.Id; break; } } ApplySettings(); } catch { return(false); } CheckInGame(true); overlay = new OverlayWindow(); overlay.game = this; overlay.PostCreate(); overlay.InGameStateChanged(InGame); AutoTeleport = new AutoTeleHandler(this); Pickit = new Pickit(this); PlayerInfo = new PlayerInfo(this); MapHandler = new MapHandler(this); syncTimer.Start(); gameCheckTimer.Start(); selectedUnitTimer.Start(); return(true); }
public bool Detach() { if (overlay != null) { overlay.Close(); overlay.Dispose(); overlay = null; } syncTimer.Stop(); gameCheckTimer.Stop(); selectedUnitTimer.Stop(); if (Pickit != null) { Pickit.Stop(); Pickit = null; } if (MapHandler != null) { MapHandler.Reset(); MapHandler = null; } if (AutoTeleport != null) { AutoTeleport.Terminate(); AutoTeleport = null; } PlayerInfo = null; if (Installed) { try { pd.StopDebugging(); pd.Join(); pd = null; } catch { return(false); } } return(true); }
/*public void Log(string message, Color color, params object[] args) * { * this.overlay.logTextBox.LogLine(message, color, args); * } * * public void Log(string message, params object[] args) * { * Log(message, Color.Empty, args); * } * * public void LogWarning(string message, params object[] args) * { * Log(message, Color.Red, args); * }*/ public void ExitedGame() { chickening = false; backToTown = false; pricePerItem.Clear(); socketsPerItem.Clear(); viewingUnit = 0; if (Pickit != null) { Pickit.Reset(); } if (PlayerInfo != null) { PlayerInfo.Reset(); } if (AutoTeleport != null) { AutoTeleport.Reset(); } }
public bool HandleMessage(Keys key, MessageEvent mEvent) { //Console.WriteLine(mEvent.ToString() + " " + vkCode.ToString()); //Log(mEvent.ToString() + " " + key.ToString()); if (key == Keys.LControlKey || key == Keys.RControlKey) { if (mEvent == MessageEvent.WM_KEYUP && !overlay.ClickThrough) { overlay.MakeNonInteractive(true); } else if (mEvent == MessageEvent.WM_KEYDOWN && overlay.ClickThrough) { overlay.MakeNonInteractive(false); } } if (mEvent == MessageEvent.WM_KEYUP && GetUIVar(UIVars.ChatInput) == 0) { if (key == Settings.FastExit.Key) { using (var suspender = new GameSuspender(this)) { ExitGame(); } } if (key == Settings.OpenCube.Key) { using (var suspender = new GameSuspender(this)) { OpenCube(); } } if (key == Settings.OpenStash.Key) { using (var suspender = new GameSuspender(this)) { OpenStash(); } } if (key == Settings.RevealAct.Key) { using (var suspender = new GameSuspender(this)) { MapHandler.RevealAct(); //ItemStorage.LoadCodes(this); //Test(); } } if (key == Settings.FastPortal.Key) { using (var suspender = new GameSuspender(this)) { if (OpenPortal() && Settings.GoToTownAfterPortal.IsEnabled()) { backToTown = true; } } } if (key == Settings.ViewInventory.ViewInventoryKey && Settings.ViewInventory.Enabled) { using (var suspender = new GameSuspender(this)) { OnViewInventoryKey(); } } if (key == Settings.ReceivePacketHack.ItemTracker.ReactivatePickit.Key && Settings.ReceivePacketHack.ItemTracker.EnablePickit.IsEnabled()) { if (Pickit != null) { Pickit.ToggleEnabled(); } } if (key == Settings.AutoteleNext.Key) { using (var suspender = new GameSuspender(this)) { AutoTeleport.ManageTele(TeleType.Next); } } if (key == Settings.AutoteleMisc.Key) { using (var suspender = new GameSuspender(this)) { AutoTeleport.ManageTele(TeleType.Misc); } } if (key == Settings.AutoteleWP.Key) { using (var suspender = new GameSuspender(this)) { AutoTeleport.ManageTele(TeleType.WP); } } if (key == Settings.AutotelePrev.Key) { using (var suspender = new GameSuspender(this)) { AutoTeleport.ManageTele(TeleType.Prev); } } } if (mEvent == MessageEvent.WM_LBUTTONDOWN && Settings.ViewInventory.Enabled) { if (viewingUnit != 0 && GameReady() && GetUIVar(UIVars.Inventory) != 0 && GetViewingUnit() != 0 && viewingUnit != 0 && GetMouseX() >= 400) { return(false); } } return(true); }