private void ThreadProc() { while (!_stopped) { _manualResetEvent.WaitOne(); Thread.Sleep((int)_threadPriority); try { var remoteProc = RemoteProc.Instance(); if (remoteProc == null) { continue; } var addr = _ptr.GetAddress(remoteProc); if (addr == IntPtr.Zero) { continue; } var bytes = remoteProc.ReadBytes(addr, _bytesToRead); if (bytes.IsEqual(_value)) { continue; } _value = bytes; ValueChanged?.Invoke(this, new MemoryThreadEventArgs { Bytes = _value }); } catch (Exception e) { Diag.WriteLine($"[MemoryThread {_name}] {e.Message}"); } } Diag.WriteLine($"[MemoryThread {_name}] stopped"); }
public static bool CheckForUpdates(out string latestVer) { Diag.WriteLine("Checking for updates"); try { using (var wc = new WebClient()) { wc.Headers.Set("Content-Type", "application/json"); wc.Headers.Set("User-Agent", "Sekiro.SpeedrunUtility"); var json = wc.DownloadString(_apiEndpoint); var obj = JObject.Parse(json); var tagName = obj["tag_name"].ToString(); var vCur = new Version(Application.ProductVersion); var latest = new Version(tagName); if (latest.CompareTo(vCur) > 0) { latestVer = tagName; Diag.WriteLine($"Update available! {tagName} > {Application.ProductVersion}"); return(true); } Diag.WriteLine($"No updates available {Application.ProductVersion} >= {tagName}"); latestVer = ""; return(false); } } catch (Exception ex) { Diag.WriteLine($"Update check failed :( {ex.Message}"); } latestVer = ""; return(false); }
public static void Teleport(Vector3 coords) { var sekiro = Utils.Sekiro(); if (sekiro == null) { return; } using (var remoteProc = new RemoteProcess(sekiro)) { var address = Coordinates().BasePtr; try { address = Coordinates().Offsets.Aggregate(address, (current, offset) => remoteProc.Read <IntPtr>(current) + offset); remoteProc.WriteBytes(address, coords.ToByteArray()); } catch (Exception e) { Diag.WriteLine($"Exception in Coordinate Teleport {e.Message}"); } } }
private IntPtr Callback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode < 0 || wParam != (IntPtr)WM_KEYDOWN) { return(CallNextHookEx(_hookId, nCode, wParam, lParam)); } try { var vkCode = Marshal.ReadInt32(lParam); var eargs = new KeyPressEventArgs { KeyPressed = (Keys)vkCode, Modifiers = GetModifiers() }; var modifiers = GetModifiers(); OnKeyPressed?.Invoke(this, eargs); } catch (Exception ex) { Diag.WriteLine($"[KeyboardHook] {ex.Message}"); } return(CallNextHookEx(_hookId, nCode, wParam, lParam)); }