Beispiel #1
0
 private void LinkSendLogToDev_Click(object sender, EventArgs e)
 {
     try
     {
         string subject = InputBox.Input("Any comment? (optional)", settings.StyleColor);
         if (subject != null)
         {
             WaitingOverlay waitingOverlay = new WaitingOverlay(this, "Please wait...", settings.StyleColor).Show();
             Task.Factory.StartNew(() =>
             {
                 try
                 {
                     Log2.UploadLog(subject);
                 }
                 catch (Exception ex)
                 {
                     log.Error("Can't send log: " + ex.Message);
                     this.TaskDialog("Can't send log", ex.Message, NotifyUserType.Error);
                 }
                 finally
                 {
                     BeginInvoke(new Action(waitingOverlay.Close));
                 }
             });
         }
     }
     catch (Exception ex)
     {
         log.Info("Can't send log file: " + ex.Message);
         this.TaskDialog("Log file sending error", ex.Message, NotifyUserType.Error);
     }
 }
Beispiel #2
0
        /// <summary>
        ///     Selects <see cref="WowProcess"/> from all available processes (via <see cref="WoWProcessSelector"/>).
        ///     Checks selected process for <see cref="WowProcess.IsValidBuild"/> and <see cref="GameInterface.IsInGame"/> states.
        ///     If something went wrong, informs user via Utils.NotifyUser().
        /// </summary>
        /// <returns>
        ///     Instance of <see cref="WowProcess"/> if successful, null otherwise
        /// </returns>
        internal static WowProcess GetProcess()
        {
            WowProcess wowProcess = WoWProcessSelector.GetWoWProcess();

            if (wowProcess != null)
            {
                if (wowProcess.IsValidBuild)
                {
                    if (new GameInterface(wowProcess).IsInGame)
                    {
                        if (wowProcess.Memory == null)
                        {
                            wowProcess.Memory = new MemoryManager(Process.GetProcessById(wowProcess.ProcessID));
                        }
                        return(wowProcess);
                    }
                    log.Info($"{wowProcess} Player isn't logged in");
                    Notify.SmartNotify("Cannot attach to WoW client", "Player isn't logged in", NotifyUserType.Error, true);
                    return(null);
                }
                else
                {
                    log.Error($"{wowProcess} WoW client is outdated: {wowProcess.GetExecutableRevision()}");
                    Notify.SmartNotify("Cannot attach to WoW client", "AxTools is outdated. Please standby", NotifyUserType.Error, true);
                    return(null);
                }
            }
            Notify.SmartNotify("Module error", "No WoW process found", NotifyUserType.Error, true);
            return(null);
        }
Beispiel #3
0
        private static bool TryGetSavedOffsets(byte[] hash)
        {
            Log2   log          = new Log2(nameof(WowBuildInfoX64));
            string hashAsString = BitConverter.ToString(hash);
            var    directory    = Directory.CreateDirectory(Path.Combine(AppFolders.DataDir, "wow-builds"));
            var    filePath     = Path.Combine(directory.FullName, hashAsString + ".json");

            log.Info($"TryGetSavedOffsets: filepath: '{filePath}'");
            if (File.Exists(filePath))
            {
                log.Info($"TryGetSavedOffsets: file exists, trying to deserialize...");
                try
                {
                    var offsets = JsonConvert.DeserializeObject <Dictionary <string, IntPtr> >(File.ReadAllText(filePath, Encoding.UTF8));
                    if (offsets.Count == patterns.Length)
                    {
                        log.Info("TryGetSavedOffsets: deserialization is successful!");
                        WoWHash             = hash;
                        BlackMarketNumItems = offsets[nameof(BlackMarketNumItems)].ToInt32();
                        BlackMarketItems    = offsets[nameof(BlackMarketItems)].ToInt32();
                        LastHardwareAction  = offsets[nameof(LastHardwareAction)].ToInt32();
                        TickCount           = offsets[nameof(TickCount)].ToInt32();
                        MouseoverGUID       = offsets[nameof(MouseoverGUID)].ToInt32();
                        ChatIsOpened        = offsets[nameof(ChatIsOpened)].ToInt32();
                        FocusedWidget       = offsets[nameof(FocusedWidget)].ToInt32();
                        ObjectManager       = offsets[nameof(ObjectManager)].ToInt32();
                        GlueState           = offsets[nameof(GlueState)].ToInt32();
                        GameState           = offsets[nameof(GameState)].ToInt32();
                        KnownSpellsCount    = offsets[nameof(KnownSpellsCount)].ToInt32();
                        KnownSpells         = offsets[nameof(KnownSpells)].ToInt32();
                        UIFrameBase         = offsets[nameof(UIFrameBase)].ToInt32();
                        PlayerZoneID        = offsets[nameof(PlayerZoneID)].ToInt32();
                        PlayerIsLooting     = offsets[nameof(PlayerIsLooting)].ToInt32();
                        PlayerGUID          = offsets[nameof(PlayerGUID)].ToInt32();
                        NotLoadingScreen    = offsets[nameof(NotLoadingScreen)].ToInt32();
                        IsChatAFK           = offsets[nameof(IsChatAFK)].ToInt32();
                        ChatBuffer          = offsets[nameof(ChatBuffer)].ToInt32();
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    log.Error($"TryGetSavedOffsets: deserialization is failed: {ex.Message}");
                }
            }
            return(false);
        }
Beispiel #4
0
        private void EnterCredentialsASAP()
        {
            var counter = 300;

            while (counter > 0)
            {
                try
                {
                    process.Refresh();
                    if (process.MainWindowHandle != (IntPtr)0)
                    {
                        if (WoWProcessManager.Processes.TryGetValue(process.Id, out WowProcess wowProcess) && wowProcess.Memory != null)
                        {
                            bool okay;
                            if (wowProcess.IsValidBuild)
                            {
                                GlueState glueState     = wowProcess.Memory.Read <GlueState>(wowProcess.Memory.ImageBase + WowBuildInfoX64.GlueState);
                                var       focusedWidget = wowProcess.Memory.Read <IntPtr>(wowProcess.Memory.ImageBase + WowBuildInfoX64.FocusedWidget);
                                okay = glueState == GlueState.Disconnected && focusedWidget != (IntPtr)0;
                            }
                            else
                            {
                                Thread.Sleep(3000);
                                okay = true;
                            }
                            if (okay)
                            {
                                foreach (char ch in wowAccount.GetLogin())
                                {
                                    NativeMethods.PostMessage(wowProcess.MainWindowHandle, Win32Consts.WM_CHAR, (IntPtr)ch, IntPtr.Zero);
                                    Thread.Sleep(5);
                                }
                                var tabCode = new IntPtr(0x09);
                                NativeMethods.PostMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYDOWN, tabCode, IntPtr.Zero);
                                NativeMethods.PostMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYUP, tabCode, IntPtr.Zero);
                                Thread.Sleep(5);
                                foreach (char ch in wowAccount.GetPassword())
                                {
                                    NativeMethods.PostMessage(wowProcess.MainWindowHandle, Win32Consts.WM_CHAR, (IntPtr)ch, IntPtr.Zero);
                                    Thread.Sleep(5);
                                }
                                var enterCode = new IntPtr(0x0D);
                                NativeMethods.PostMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYDOWN, enterCode, IntPtr.Zero);
                                NativeMethods.PostMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYUP, enterCode, IntPtr.Zero);
                                log.Info($"{wowProcess} Credendials have been entered [{Utils.SecureString(wowAccount.GetLogin())}]");
                                break;
                            }
                        }
                    }
                    Thread.Sleep(100);
                    counter--;
                }
                catch (Exception ex)
                {
                    log.Error($"[{process.ProcessName}:{process.Id}] Internal error: {ex.Message}");
                }
            }
        }
 void xrun()
 {
     while (true)
     {
         IPEndPoint   clientIP = new IPEndPoint(IPAddress.Any, 28960);
         byte[]       data     = udp.Receive(ref clientIP);
         MemoryStream memsr    = new MemoryStream(data);
         BinaryReader reader   = new BinaryReader(memsr);
         Log2.Info("Header_Int: " + reader.ReadInt32().ToString());
         Log2.Info("Body: " + reader.ReadString());
     }
 }
Beispiel #6
0
 internal MainWindow()
 {
     log.Info("Initializing main window...");
     Instance      = this;
     WoWLaunchLock = new MultiLock();
     InitializeComponent();
     StyleManager.Style = Settings2.Instance.StyleColor;
     Icon                             = Resources.ApplicationIcon;
     Closing                         += MainFormClosing;
     notifyIconMain.Icon              = Resources.ApplicationIcon;
     tabControl.SelectedIndex         = 0;
     linkEditWowAccounts.Location     = new Point(metroTabPage1.Size.Width / 2 - linkEditWowAccounts.Size.Width / 2, linkEditWowAccounts.Location.Y);
     cmbboxAccSelect.Location         = new Point(metroTabPage1.Size.Width / 2 - cmbboxAccSelect.Size.Width / 2, cmbboxAccSelect.Location.Y);
     progressBarAddonsBackup.Size     = linkBackup.Size;
     progressBarAddonsBackup.Location = linkBackup.Location;
     progressBarAddonsBackup.Visible  = false;
     SetupControls();
     SetupEvents();
     SetTooltips();
     PostInvoke(AfterInitializingAsync);
     log.Info("MainWindow is constructed");
 }
Beispiel #7
0
 private static void KeyboardListener2_KeyPressed(KeyboardWatcher.KeyExt obj)
 {
     if (obj == _settings.ClickerHotkey)
     {
         if (_settings.ClickerKey == Keys.None)
         {
             Notify.TrayPopup("Incorrect parameter!", "Clicker don't know what key it should press. Click here to setup clicker", NotifyUserType.Error, true, null, 10, (sender, args) =>
             {
                 ClickerSettings clickerSettings = Utils.FindForms <ClickerSettings>().FirstOrDefault();
                 if (clickerSettings == null)
                 {
                     new ClickerSettings().Show(MainWindow.Instance);
                 }
                 else
                 {
                     clickerSettings.ActivateBrutal();
                 }
             });
             return;
         }
         if (Enabled)
         {
             Stop();
             WowProcess cProcess = WoWProcessManager.Processes.Values.FirstOrDefault(i => i.MainWindowHandle == Handle);
             logger.Info(cProcess != null
                 ? $"{cProcess} Disabled"
                 : "UNKNOWN:null :: Disabled");
         }
         else
         {
             WowProcess cProcess = WoWProcessManager.Processes.Values.FirstOrDefault(i => i.MainWindowHandle == NativeMethods.GetForegroundWindow());
             if (cProcess != null)
             {
                 Start(_settings.ClickerInterval, cProcess.MainWindowHandle, (IntPtr)_settings.ClickerKey);
                 logger.Info($"{cProcess} Enabled, interval {_settings.ClickerInterval}ms, window handle 0x{cProcess.MainWindowHandle.ToInt64():X}");
             }
         }
     }
 }
Beispiel #8
0
 private static ObservableCollection <WoWAccount2> Load()
 {
     try
     {
         if (Settings2.Instance.WoWAccounts2.Length > 0)
         {
             ObservableCollection <WoWAccount2> list = JsonConvert.DeserializeObject <ObservableCollection <WoWAccount2> >(Encoding.UTF8.GetString(Settings2.Instance.WoWAccounts2));
             list.CollectionChanged += WoWAccounts_Changed;
             log.Info("WoW accounts was loaded");
             return(list);
         }
         ObservableCollection <WoWAccount2> emptyList = new ObservableCollection <WoWAccount2>();
         emptyList.CollectionChanged += WoWAccounts_Changed;
         log.Info("WoW accounts: new collection is created");
         return(emptyList);
     }
     catch (Exception ex)
     {
         log.Error("WoW accounts loading failed, new accounts will not be saved: " + ex.Message);
         return(new ObservableCollection <WoWAccount2>());
     }
 }
        int SendChallenge(IPEndPoint ip, UdpClient udp)
        {
            int          c       = new Random().Next();
            MemoryStream getChng = new MemoryStream();
            BinaryWriter w       = new BinaryWriter(getChng);

            w.Write(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF });
            w.Write(string.Format("getchallenge {0}", c));
            w.Flush();
            byte[] data = getChng.ToArray();
            udp.Send(data, data.Length, ip);
            Log2.Info("Sending challange data to " + ip.ToString() + "...");
            return(c);
        }
Beispiel #10
0
 public static WowheadItemInfo GetItemInfo(uint itemID)
 {
     // <name><![CDATA[Iceblade Arrow]]></name>
     // <class id="1"><![CDATA[Контейнеры]]></class>
     // <level>85</level>
     // <quality id="1">Обычный</quality>
     // "inv_misc_questionmark"
     if (!ItemInfos.TryGetValue(itemID, out WowheadItemInfo info))
     {
         if ((info = ItemInfo_GetCachedValue(itemID)) == null)
         {
             using (WebClient webClient = new WebClient())
             {
                 webClient.Encoding = Encoding.UTF8;
                 string xml   = webClient.DownloadString("https://" + _locale + ".wowhead.com/item=" + itemID + "&xml");
                 Regex  regex = new Regex("<name><!\\[CDATA\\[(.+)\\]\\]></name>.*<level>(\\d+)</level>.*<quality id=\"(\\d+)\">.*</quality>.*<class id=\"(\\d+)\">.*<icon.*>(.+)</icon>");
                 Match  match = regex.Match(xml);
                 if (match.Success)
                 {
                     info = new WowheadItemInfo(Regex.Unescape(match.Groups[1].Value), uint.Parse(match.Groups[4].Value), uint.Parse(match.Groups[2].Value), uint.Parse(match.Groups[3].Value));
                     using (MemoryStream ms = new MemoryStream(webClient.DownloadData("https://wow.zamimg.com/images/wow/icons/small/" + match.Groups[5].Value + ".jpg")))
                     {
                         info.ImageBytes = ms.ToArray();
                     }
                     ItemInfo_SaveToCache(itemID, info);
                 }
                 else
                 {
                     info = new WowheadItemInfo(UNKNOWN, 0, 0, 0);
                     log.Info("GetItemInfo(): regex isn't match: " + JsonConvert.SerializeObject(xml));
                 }
             }
         }
         ItemInfos.TryAdd(itemID, info);
     }
     return(info);
 }
Beispiel #11
0
        static void Main(string[] args)
        {
            Log2.Initialize("Log2.txt", LogLevel.All, false);
            string ip = Console.ReadLine();

            client.Connect(IPAddress.Parse(ip), 57852);
            sr = client.GetStream();
            Log2.Info("Updating client size...");
            UpdateClientSize();
            new Thread(WaitForIt).Start();
            new Thread(SendPicture).Start();
            Log2.Debug("Systems up!");
            while (true)
            {
                Log2.WriteAway();
            }
        }
Beispiel #12
0
        static void WaitForIt()
        {
            BinaryReader reader = new BinaryReader(sr);

            while (true)
            {
                if (sr != null)
                {
                    int typ = reader.ReadInt32();
                    if (typ == 0x12)
                    {
                        int x = reader.ReadInt32();
                        int y = reader.ReadInt32();
                        Cursor.Position = ClientToScreen(ClientSize, Screen.PrimaryScreen.WorkingArea.Size, new Point(x, y));
                        Log2.Info("Cursor position has been updated..");
                    }
                }
            }
        }
Beispiel #13
0
 internal static void DeployArchive(string path)
 {
     IsRunning = true;
     IsRunningChanged?.Invoke(true);
     try
     {
         if (Directory.Exists(_settings.WoWDirectory))
         {
             if (File.Exists(path))
             {
                 log.Info("Deploying archive: " + path);
                 Unzip(path);
                 log.Info("Archive is deployed: " + path);
             }
             else
             {
                 log.Info("Archive " + path + " isn't found");
                 Notify.TrayPopup("Backup error", "Archive " + path + " isn't found", NotifyUserType.Error, true);
             }
         }
         else
         {
             log.Info("WoW dir (" + _settings.WoWDirectory + ") isn't found");
             Notify.TrayPopup("Backup error", "WoW dir (" + _settings.WoWDirectory + ") isn't found", NotifyUserType.Error, true);
         }
     }
     catch (Exception ex)
     {
         log.Error("Deploying error: " + ex.Message);
         Notify.TrayPopup("Deploying error", ex.Message, NotifyUserType.Error, true);
     }
     IsRunningChanged?.Invoke(false);
     IsRunning = false;
 }
Beispiel #14
0
        private static void Zip()
        {
            Log2 vssLog = new Log2(nameof(AddonsBackup) + " - VSS Service");
            // get free drive letter
            string driveLetter = new string[] { "P:", "Q:", "R:", "S:", "T:", "U:", "V:", "W:" }.FirstOrDefault(l => !DriveInfo.GetDrives().Select(m => m.RootDirectory.Name).Contains(l));

            if (driveLetter == default(string))
            {
                throw new IOException("Can't find free drive letter!");
            }
            vssLog.Info($"Free drive letter: {driveLetter}");
            // making VSS snapshot
            IVssImplementation   vssImplementation = VssUtils.LoadImplementation();
            IVssBackupComponents backupComponents  = vssImplementation.CreateVssBackupComponents();

            backupComponents.InitializeForBackup(null);
            vssLog.Info("VssBackupComponents is initialized");
            Guid backupGuid1 = Guid.Empty;

            try
            {
                backupComponents.GatherWriterMetadata();
                backupComponents.SetContext(VssVolumeSnapshotAttributes.Persistent | VssVolumeSnapshotAttributes.NoAutoRelease);
                backupComponents.SetBackupState(false, true, VssBackupType.Full, false);
                vssLog.Info("VssBackupComponents is set up");
                backupComponents.StartSnapshotSet();
                backupGuid1 = backupComponents.AddToSnapshotSet(new DirectoryInfo(_settings.WoWDirectory).Root.Name, Guid.Empty);
                backupComponents.PrepareForBackup();
                backupComponents.DoSnapshotSet();
                vssLog.Info("Snapshot is taken");
                backupComponents.ExposeSnapshot(backupGuid1, null, VssVolumeSnapshotAttributes.ExposedLocally, driveLetter);
                // zipping
                string zipPath = $"{_settings.WoWAddonsBackupPath}\\AddonsBackup_{DateTime.UtcNow:yyyyMMdd_HHmmss}.zip";
                log.Info("Zipping to file: " + zipPath);
                using (ZipFile zip = new ZipFile(zipPath, Encoding.UTF8))
                {
                    zip.CompressionLevel = (CompressionLevel)_settings.WoWAddonsBackupCompressionLevel;
                    foreach (string dirName in FoldersToArchive)
                    {
                        zip.AddDirectory(_settings.WoWDirectory.Replace(new DirectoryInfo(_settings.WoWDirectory).Root.Name, $"{driveLetter}\\") + "\\" + dirName, "\\" + dirName);
                    }
                    zip.SaveProgress += AddonsBackup_SaveProgress;
                    var processPriority = Process.GetCurrentProcess().PriorityClass;
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
                    zip.Save();
                    Process.GetCurrentProcess().PriorityClass = processPriority;
                    zip.SaveProgress -= AddonsBackup_SaveProgress;
                }
            }
            finally
            {
                VssSnapshotProperties existingSnapshot = backupComponents.QuerySnapshots().FirstOrDefault(l => l.SnapshotId == backupGuid1);
                if (existingSnapshot == default(VssSnapshotProperties))
                {
                    vssLog.Error($"Can't delete snapshot {backupGuid1}");
                }
                else
                {
                    backupComponents.DeleteSnapshot(existingSnapshot.SnapshotId, true);
                    backupComponents.Dispose();
                    vssLog.Info($"Snapshot is deleted ({existingSnapshot.SnapshotId})");
                }
                GC.Collect();
            }
        }
Beispiel #15
0
 private static void Main(string[] args)
 {
     UIThread = Thread.CurrentThread.ManagedThreadId;
     if (args.Length == 0)
     {
         if (Process.GetProcessesByName(nameof(AxTools)).Length > 1)
         {
             log.Info("Waiting for parent AxTools process (1000 ms)");
             Thread.Sleep(1000);
         }
         using (new Mutex(true, "AxToolsMainExecutable", out bool newInstance))
         {
             if (newInstance)
             {
                 if (Environment.OSVersion.Version >= new Version(6, 1))
                 {
                     using (WindowsIdentity p = WindowsIdentity.GetCurrent())
                     {
                         var pricipal = new WindowsPrincipal(p);
                         if (!pricipal.IsInRole(WindowsBuiltInRole.Administrator))
                         {
                             TaskDialog.Show("This program requires administrator privileges", nameof(AxTools), "Make sure you have administrator privileges", TaskDialogButton.OK, TaskDialogIcon.SecurityError);
                             return;
                         }
                     }
                     Application.EnableVisualStyles();
                     Application.SetCompatibleTextRenderingDefault(false);
                     WebRequest.DefaultWebProxy = null;
                     DeleteTempFolder();
                     Legacy();
                     InstallRootCertificate();
                     log.Info("Adjusting process priorities..."); Utils.SetProcessPrioritiesToNormal(Process.GetCurrentProcess().Id); // in case we'are starting from Task Scheduler priorities can be lower than normal
                     log.Info($"{typeof(WoWAntiKick)} is subscribing for {typeof(WoWProcessManager)}'s events"); WoWAntiKick.StartWaitForWoWProcesses();
                     log.Info($"Registered for: {Settings2.Instance.UserID}");
                     log.Info("Starting to load plugins..."); PluginManagerEx.LoadPluginsAsync();
                     log.Info("Starting WoW process manager..."); StartWoWProcessManagerTask = Task.Run((Action)WoWProcessManager.StartWatcher);
                     log.Info("Looking for WoW client..."); WoWPathSearchTask = Task.Run((Action)CheckWoWDirectoryIsValid);
                     log.Info("Starting add-ons backup service..."); Task.Run((Action)AddonsBackup.StartService);
                     log.Info("Starting pinger..."); Task.Run(delegate { Pinger.Enabled = Settings2.Instance.PingerServerID != 0; });
                     log.Info("Starting updater service..."); Task.Run((Action)UpdaterService.Start);
                     log.Info($"Constructing MainWindow, app version: {Globals.AppVersion}"); Application.Run(new MainWindow());
                     log.Info("MainWindow is closed, waiting for ShutdownLock..."); ShutdownLock.WaitForLocks();
                     log.Info($"Invoking 'Exit' handlers ({Exit?.GetInvocationList().Length})..."); Exit?.Invoke();
                     log.Info("Application is closed");
                     SendLogToDeveloper();
                 }
                 else
                 {
                     MessageBox.Show("This program works only on Windows 7 or higher", nameof(AxTools), MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else
             {
                 TaskDialog.Show("This program is already running", nameof(AxTools), "", TaskDialogButton.OK, TaskDialogIcon.Warning);
             }
         }
     }
     else
     {
         ProcessArgs();
     }
 }
Beispiel #16
0
        private static void Legacy()
        {
            var legacyLog = new Log2(nameof(Legacy));

            // 08.10.2015
            try
            {
                var mySettingsDir  = AppFolders.PluginsSettingsDir + "\\Fishing";
                var mySettingsFile = mySettingsDir + "\\FishingSettings.json";
                if (File.Exists(mySettingsFile))
                {
                    File.Move(mySettingsFile, mySettingsDir + "\\settings.json");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            // 11.07.2016
            try
            {
                if (Directory.Exists(Application.StartupPath + "\\wowheadCache"))
                {
                    Directory.Delete(Application.StartupPath + "\\wowheadCache", true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            // 12.01.2018
            try
            {
                foreach (string hotkeyName in new[] { "ClickerHotkey", "WoWPluginHotkey" })
                {
                    var cfg   = File.ReadAllText(AppFolders.ConfigDir + "\\settings.json", Encoding.UTF8);
                    var regex = new Regex($"\"{hotkeyName}\": (\\d+)");
                    var match = regex.Match(cfg);
                    if (match.Success)
                    {
                        var oldKey = JsonConvert.DeserializeObject <Keys>(match.Groups[1].Value);
                        var alt    = false;
                        var ctrl   = false;
                        var shift  = false;
                        if ((oldKey & Keys.Alt) == Keys.Alt)
                        {
                            alt = true;
                        }
                        if ((oldKey & Keys.Control) == Keys.Control)
                        {
                            ctrl = true;
                        }
                        if ((oldKey & Keys.Shift) == Keys.Shift)
                        {
                            shift = true;
                        }
                        oldKey = oldKey & ~Keys.Control & ~Keys.Shift & ~Keys.Alt;
                        var newCfg = cfg.Replace(match.Value, $"\"{hotkeyName}\": " + JsonConvert.SerializeObject(new KeyboardWatcher.KeyExt(oldKey, alt, shift, ctrl)));
                        File.WriteAllText(AppFolders.ConfigDir + "\\settings.json", newCfg, Encoding.UTF8);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            // 17.04.2017
            try
            {
                if (Settings2.Instance.LastUsedVersion <= new VersionExt(12, 2, 46))
                {
                    var fileName = AppFolders.DataDir + "\\wowhead.ldb";
                    if (File.Exists(fileName))
                    {
                        File.Delete(fileName);
                        legacyLog.Info("Old db file is deleted");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            // 17.01.2018
            try
            {
                var fileName = AppFolders.DataDir + "\\wowhead.ldb";
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                    legacyLog.Info($"Old db file is deleted ({fileName})");
                }
                fileName = AppFolders.DataDir + "\\players.ldb";
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                    legacyLog.Info($"Old db file is deleted ({fileName})");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            // 10.08.2018
            try
            {
                if (Settings2.Instance.LastUsedVersion <= new VersionExt(12, 3, 46))
                {
                    var fileName = Path.Combine(AppFolders.ConfigDir, "lua-console.json");
                    if (File.Exists(fileName))
                    {
                        File.Delete(fileName);
                        legacyLog.Info($"{fileName} is deleted");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            // 10.08.2018
            try
            {
                if (Settings2.Instance.LastUsedVersion <= new VersionExt(12, 3, 46))
                {
                    var fileName = Path.Combine(AppFolders.ConfigDir, "wow-radar.json");
                    if (File.Exists(fileName))
                    {
                        var newFilePath = Path.Combine(AppFolders.PluginsSettingsDir, "Radar\\settings.json");
                        if (File.Exists(newFilePath))
                        {
                            File.Delete(newFilePath);
                        }
                        var rawConfig = File.ReadAllText(fileName, Encoding.UTF8);
                        var config    = rawConfig.Replace(Path.Combine(AppFolders.ResourcesDir, "alarm.wav").Replace(@"\", @"\\"), Path.Combine(Settings2.Instance.PluginSourceFolder, "Radar\\alarm.wav").Replace(@"\", @"\\"));
                        File.WriteAllText(fileName, config, Encoding.UTF8);
                        File.Move(fileName, newFilePath);
                        legacyLog.Info($"{fileName} is moved to {newFilePath}");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #17
0
 internal void ChatboxSendText(string text, int attempts = 3)
 {
     if (text.Length <= 254) // 254 - max length of non-latin string in game chat box
     {
         lock (chatLocks[wowProcess.ProcessID])
         {
             wowProcess.WaitWhileWoWIsMinimized();
             if (IsInGame && !IsLoadingScreen)
             {
                 if (ChatIsOpened)
                 {
                     var vkLControl = (IntPtr)0xA2;
                     var vkA        = (IntPtr)0x41;
                     var vkDelete   = (IntPtr)0x2E;
                     NativeMethods.SendMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYDOWN, vkLControl, IntPtr.Zero);
                     NativeMethods.SendMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYDOWN, vkA, IntPtr.Zero);
                     NativeMethods.SendMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYUP, vkA, IntPtr.Zero);
                     NativeMethods.SendMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYUP, vkLControl, IntPtr.Zero);
                     NativeMethods.SendMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYDOWN, vkDelete, IntPtr.Zero);
                     NativeMethods.SendMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYUP, vkDelete, IntPtr.Zero);
                     Thread.Sleep(200);
                 }
                 else
                 {
                     var counter = 1000;
                     NativeMethods.SendMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYDOWN, (IntPtr)13, IntPtr.Zero);
                     NativeMethods.SendMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYUP, (IntPtr)13, IntPtr.Zero);
                     while (!ChatIsOpened && counter > 0)
                     {
                         counter -= 10;
                         Thread.Sleep(10);
                     }
                     Thread.Sleep(250);
                 }
                 foreach (char ch in text)
                 {
                     NativeMethods.PostMessage(wowProcess.MainWindowHandle, Win32Consts.WM_CHAR, (IntPtr)ch, IntPtr.Zero);
                 }
                 string editboxText = null;
                 Thread.Sleep(100);
                 for (int i = 0; i < 10; i++)
                 {
                     if ((editboxText = GetEditboxText()) == text)
                     {
                         NativeMethods.SendMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYDOWN, (IntPtr)13, IntPtr.Zero);
                         NativeMethods.SendMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYUP, (IntPtr)13, IntPtr.Zero);
                         return;
                     }
                     Thread.Sleep(100);
                 }
                 attempts--;
                 if (attempts > 0)
                 {
                     log.Info($"ChatboxSendText: recursive call, attempts: {attempts}");
                     ChatboxSendText(text, attempts);
                 }
                 else
                 {
                     log.Error($"ChatboxSendText: text and editboxText are not equal; text: {text}; editboxText: {editboxText}");
                     Notify.TrayPopup("Can't send command via chat", "Please don't type while this bot is working", NotifyUserType.Warn, true);
                 }
             }
         }
     }
     else
     {
         log.Error($"ChatboxSendText: string is too long (length={text.Length}): {text}");
     }
 }
 void Done(IAsyncResult state)
 {
     Log2.Info("Sending message to client! [" + state.AsyncState.ToString() + "]");
 }
Beispiel #19
0
 /// <summary>
 /// Makes a record to the log. WoW process name, process id and plug-in name are included
 /// </summary>
 /// <param name="plugin"></param>
 /// <param name="text"></param>
 public static void LogPrint(this IPlugin3 plugin, object text)
 {
     log.Info($"[Plug-in: {plugin.Name}] {text}");
 }
Beispiel #20
0
 private static void Program_Exit()
 {
     foreach (var i in Processes)
     {
         string name = i.Value.ProcessName;
         i.Value.Dispose();
         log.Info($"{name}:{i.Key} :: [WoW hook] Memory manager disposed");
     }
 }
Beispiel #21
0
        internal static void ApplyUpdate(string updateDir, string axtoolsDir)
        {
            try
            {
                log.Info("Copying distr directory, updateDir: " + updateDir + "; axtoolsDir: " + axtoolsDir);
                Utils.DirectoryCopy(updateDir, axtoolsDir, true);
                var pluginsDirectoryInfo = new DirectoryInfo(Path.Combine(axtoolsDir, "pluginsAssemblies"));
                if (pluginsDirectoryInfo.Exists)
                {
                    log.Info("Deleting plug-ins assemblies directory...");
                    pluginsDirectoryInfo.Delete(true);
                }
                log.Info("Deleting junk files...");
                foreach (string i in JunkFiles)
                {
                    try
                    {
                        File.Delete(Path.Combine(axtoolsDir, i));
                        log.Info("Junk file is deleted: " + Path.Combine(axtoolsDir, i));
                    }
#pragma warning disable CC0004
                    catch { /* don't care why */ }
#pragma warning restore CC0004
                }
                foreach (string junkFolder in JunkFolders)
                {
                    try
                    {
                        Directory.Delete(Path.Combine(axtoolsDir, junkFolder), true);
                    }
#pragma warning disable CC0004
                    catch { /* don't care why */ }
#pragma warning restore CC0004
                }
                log.Info("ApplyUpdate: done");
            }
            catch (Exception ex)
            {
                TaskDialog.Show("Critical update error", nameof(AxTools), ex.Message, TaskDialogButton.Close, TaskDialogIcon.Stop);
            }
        }
Beispiel #22
0
 private void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (settings.WoWAntiKick)
     {
         if (wowProcess.IsValidBuild)
         {
             if (info.IsInGame)
             {
                 try
                 {
                     var lastHardwareAction = wowProcess.Memory.Read <int>(wowProcess.Memory.ImageBase + WowBuildInfoX64.LastHardwareAction);
                     var tickCount          = wowProcess.Memory.Read <int>(wowProcess.Memory.ImageBase + WowBuildInfoX64.TickCount);
                     if (tickCount - lastHardwareAction > maxTime)
                     {
                         maxTime = Utils.Rnd.Next(150000, 280000);
                         wowProcess.Memory.Write(wowProcess.Memory.ImageBase + WowBuildInfoX64.LastHardwareAction, tickCount);
                         logger.Info($"{wowProcess} Action emulated, next MaxTime: {maxTime}");
                         if (settings.WoW_AntiKick_SetAfkState)
                         {
                             if (!wowProcess.IsMinimized)
                             {
                                 if (!info.IsAfk)
                                 {
                                     info.IsAfk = true;
                                     logger.Info($"{wowProcess} /afk status is set");
                                 }
                                 else
                                 {
                                     logger.Info($"{wowProcess} /afk status is already set");
                                 }
                             }
                             else
                             {
                                 logger.Info($"{wowProcess} Can't set /afk status because WoW client is minimized");
                             }
                         }
                         ActionEmulated?.Invoke(wowProcess.MainWindowHandle);
                     }
                 }
                 catch (Exception ex)
                 {
                     logger.Error($"{wowProcess} Can't emulate action: {ex.Message}");
                 }
             }
         }
         else
         {
             if (!fallback_keyboardWatcherInitialized)
             {
                 KeyboardWatcher.HotkeyManager.AddKeys(GetType() + wowProcess.ProcessID.ToString(), moveKeys);
                 KeyboardWatcher.HotkeyManager.KeyPressed += HotkeyManager_KeyPressed;
                 fallback_keyboardWatcherInitialized       = true;
                 logger.Info($"{wowProcess} Unsupported version of WoW client. Adding WASDSpace to hotkeys");
             }
             //Log.Info($"{Environment.TickCount}; {fallback_lastTimeActionEmulated}; {maxTime}");
             if (Environment.TickCount - fallback_lastTimeActionEmulated > maxTime)
             {
                 maxTime = Utils.Rnd.Next(150000, 280000);
                 fallback_lastTimeActionEmulated = Environment.TickCount;
                 NativeMethods.SendMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYDOWN, (IntPtr)Keys.Space, IntPtr.Zero);
                 NativeMethods.SendMessage(wowProcess.MainWindowHandle, Win32Consts.WM_KEYUP, (IntPtr)Keys.Space, IntPtr.Zero);
                 ActionEmulated?.Invoke(wowProcess.MainWindowHandle);
                 logger.Info($"{wowProcess} Unsupported version of WoW client, fallback to space jumping; next MaxTime: {maxTime}");
             }
         }
     }
 }
 void xrun()
 {
     while (true)
     {
         IPEndPoint   clientIP = new IPEndPoint(IPAddress.Any, 00000);
         byte[]       data     = udp.Receive(ref clientIP);
         MemoryStream memsr    = new MemoryStream(data);
         Log2.Info(Encoding.ASCII.GetString(data));
         BinaryReader reader = new BinaryReader(memsr);
         if (data.Length > 4)
         {
             reader.ReadInt32(); // Clear the header...
             string type = Encoding.ASCII.GetString(reader.ReadBytes(data.Length - 4));
             if (type.Contains("heartbeat"))
             {
                 if (!type.Contains("flatline"))  //We still on...
                 {
                     int          a    = SendChallenge(clientIP, udp);
                     MemoryStream gsts = new MemoryStream();
                     BinaryWriter w    = new BinaryWriter(gsts);
                     w.Write(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF });
                     w.Write("getstatus " + a.ToString());
                     w.Flush();
                     byte[] bdata = gsts.ToArray();
                     udp.BeginSend(bdata, bdata.Length, clientIP, new AsyncCallback(Done), "GT-STS");
                 }
                 else
                 {
                     var cs = from cl in OnlineServers where cl.IP.ToString() == clientIP.ToString() select cl;
                     if (cs.Count() > 0)
                     {
                         Log2.Info("Client [" + cs.First().Configuration["sv_hostname"] + "] has been disconnected!");
                         OnlineServers.Remove(cs.First());  // Server removed!
                     }
                 }
             }
             if (type.Contains("statusResponse"))
             {
                 var cs = from cl in OnlineServers where cl.IP.ToString() == clientIP.ToString() select cl;
                 if (cs.Count() > 0)
                 {
                     int index = OnlineServers.IndexOf(cs.First());
                     OnlineServers[index] = new DedicatedClient(type, clientIP);
                     Log2.Info("Client [" + OnlineServers[index].Configuration["sv_hostname"] + "] has been updated.");
                 }
                 else
                 {
                     DedicatedClient dc = new DedicatedClient(type, clientIP);
                     OnlineServers.Add(dc);
                     Log2.Info("Connected client [" + dc.Configuration["sv_hostname"] + "].");
                 }
             }
             if (type.Contains("challengeResponse"))  // Do we really wanna mess up with this ?
             {
                 /*long chng = long.Parse(type.Split(' ')[1]);
                  * MemoryStream memsr2 = new MemoryStream();
                  * BinaryWriter writer = new BinaryWriter(memsr2);
                  * writer.Write(new byte[] { 0x00, 0xFF, 0xFF, 0xFF, 0xFF });  //Header
                  * writer.Write("getstatus");
                  * writer.Write(new byte[] { 0x02, 0x2D });
                  * writer.Write(chng);
                  * writer.Write(0x00);
                  * writer.Flush();
                  * byte[] fres = memsr2.ToArray();
                  * memsr2.Dispose(); //Stack saver?
                  * udp.BeginSend(fres, fres.Length, clientIP, new AsyncCallback(Done), "STS-REQ-" + chng.ToString());  // done with the chanllage shit!*/
             }
             if (type.Contains("getservers"))
             {
                 // Protocol Check
                 // 6 - Call of Duty 4
                 // 118 - Call of Duty 2
                 if (type.Split(' ')[1] == "6")
                 {
                     MemoryStream back = new MemoryStream();
                     BinaryWriter wr   = new BinaryWriter(back);
                     wr.Write(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF });
                     wr.Write(new byte[] { 0x67, 0x65, 0x74, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6F, 0x6E, 0x73, 0x65 });
                     //wr.Write(new byte[] { 0x0A, 0x00 });  // Ermm.. magic number ?
                     wr.Write((byte)0x5C);
                     if (OnlineServers.Count > 0)
                     {
                         foreach (var cl in OnlineServers)
                         {
                             byte[] ip = cl.IP.Address.GetAddressBytes();
                             wr.Write(ip);
                             wr.Write((short)cl.IP.Port);
                         }
                     }
                     wr.Write((byte)0x5C);
                     wr.Write(new byte[] { 0x45, 0x4f, 0x66 });
                     wr.Flush();
                     byte[] servs = back.ToArray();
                     udp.BeginSend(servs, servs.Length, clientIP, new AsyncCallback(Done), "GT-SERVERS");
                 }
             }
             if (type.Contains("getIpAuthorize"))
             {
                 string[]     parts  = type.Split(' ');
                 MemoryStream memsr2 = new MemoryStream();
                 BinaryWriter writer = new BinaryWriter(memsr2);
                 writer.Write(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF });
                 writer.Write("ipAuthorize ");
                 writer.Write(parts[1] + " ");
                 writer.Write("accept KEY_IS_GOOD");
                 writer.Flush();
                 byte[] final = memsr2.ToArray();
                 udp.BeginSend(final, final.Length, clientIP, new AsyncCallback(Done), "IP-ACCEPT");
             }
         }
         else
         {
             Log2.Data("Unkown packet?");
         }
     }
 }
Beispiel #24
0
 internal static void AddPluginToRunning(IPlugin3 plugin, WowProcess process)
 {
     lock (AddRemoveLock)
     {
         if (!RunningPlugins.Contains(plugin))
         {
             _pluginContainers.First(l => l.Plugin.GetType() == plugin.GetType()).IsRunning = true;
             try
             {
                 plugin.OnStart(new GameInterface(process));
                 PluginWoW[plugin.Name] = process.ProcessID;
                 PluginsUsageStats[plugin.Name].Add(DateTime.UtcNow);
                 SavePluginUsageStats();
                 log.Info($"{process} [{plugin.Name}] Plug-in is started");
             }
             catch (Exception ex)
             {
                 log.Error($"Plug-in OnStart error [{plugin.Name}]: {ex.Message}");
             }
             Notify.TrayPopup(nameof(AxTools), "Plug-in <" + plugin.Name + "> is started", NotifyUserType.Info, false, plugin.TrayIcon);
             PluginStateChanged?.Invoke(plugin);
         }
     }
 }