commit 6327cbf7d017641576198fa4aebadeee6aba2c85 Author: Hipstercat Date: Thu Feb 6 00:58:37 2020 +0100 init diff --git a/ShowGiantsForm.sln b/ShowGiantsForm.sln new file mode 100644 index 0000000..37ecc5a --- /dev/null +++ b/ShowGiantsForm.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.572 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShowGiantsForm", "ShowGiantsForm\ShowGiantsForm.csproj", "{61828767-329E-4DF3-BFB4-AA1A53310094}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {61828767-329E-4DF3-BFB4-AA1A53310094}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61828767-329E-4DF3-BFB4-AA1A53310094}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61828767-329E-4DF3-BFB4-AA1A53310094}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61828767-329E-4DF3-BFB4-AA1A53310094}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {34633D5A-C8F8-444C-81B0-BD42527DA2C9} + EndGlobalSection +EndGlobal diff --git a/ShowGiantsForm/App.config b/ShowGiantsForm/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/ShowGiantsForm/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ShowGiantsForm/Form1.Designer.cs b/ShowGiantsForm/Form1.Designer.cs new file mode 100644 index 0000000..a63a59f --- /dev/null +++ b/ShowGiantsForm/Form1.Designer.cs @@ -0,0 +1,86 @@ +namespace ShowGiantsForm +{ + partial class Form1 + { + /// + /// Variable nécessaire au concepteur. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Nettoyage des ressources utilisées. + /// + /// true si les ressources managées doivent être supprimées ; sinon, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Code généré par le Concepteur Windows Form + + /// + /// Méthode requise pour la prise en charge du concepteur - ne modifiez pas + /// le contenu de cette méthode avec l'éditeur de code. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.SpeedLbl = new System.Windows.Forms.Label(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.hpLbl = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // SpeedLbl + // + this.SpeedLbl.AutoSize = true; + this.SpeedLbl.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SpeedLbl.ForeColor = System.Drawing.Color.Red; + this.SpeedLbl.Location = new System.Drawing.Point(-1, 0); + this.SpeedLbl.Name = "SpeedLbl"; + this.SpeedLbl.Size = new System.Drawing.Size(117, 37); + this.SpeedLbl.TabIndex = 0; + this.SpeedLbl.Text = "Speed:"; + // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // hpLbl + // + this.hpLbl.AutoSize = true; + this.hpLbl.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.hpLbl.ForeColor = System.Drawing.Color.Red; + this.hpLbl.Location = new System.Drawing.Point(-1, 35); + this.hpLbl.Name = "hpLbl"; + this.hpLbl.Size = new System.Drawing.Size(0, 37); + this.hpLbl.TabIndex = 2; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(305, 72); + this.Controls.Add(this.hpLbl); + this.Controls.Add(this.SpeedLbl); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label SpeedLbl; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Label hpLbl; + } +} + diff --git a/ShowGiantsForm/Form1.cs b/ShowGiantsForm/Form1.cs new file mode 100644 index 0000000..afb44ca --- /dev/null +++ b/ShowGiantsForm/Form1.cs @@ -0,0 +1,115 @@ +using System; +using System.Diagnostics; +using System.Drawing; +using System.Runtime.InteropServices; +using System.Windows.Forms; + +namespace ShowGiantsForm +{ + public partial class Form1 : Form + { + + const int PROCESS_WM_READ = 0x0010; + + IntPtr processHandle; + Process process; + + public Form1() + { + InitializeComponent(); + this.BackColor = Color.Magenta; + this.TransparencyKey = Color.Magenta; + this.TopMost = true; + SetStyle(ControlStyles.SupportsTransparentBackColor, true); + } + + private void Form1_Load(object sender, EventArgs e) + { + SpeedLbl.Text = "Waiting for Giants..."; + } + protected override void OnPaintBackground(PaintEventArgs e) + { + e.Graphics.FillRectangle(Brushes.Magenta, e.ClipRectangle); + } + + private void lookForProcess(String windowName) + { + process = Process.GetProcessesByName(windowName)[0]; + processHandle = OpenProcess(PROCESS_WM_READ, false, process.Id); + } + + private void timer1_Tick(object sender, EventArgs e) + { + if (processHandle == IntPtr.Zero) + { + try + { + lookForProcess("Giants"); + } catch (Exception ex) + { + // SpeedLbl.Text = ex.Message; + } + } + if (processHandle != IntPtr.Zero) { + RECT Rect = new RECT(); + GetWindowRect(process.MainWindowHandle, ref Rect); + int newx = Rect.right - 730; + int newy = Rect.bottom - 170; + this.Location = new Point(newx, newy); + try { + float speedx = readFloatPointer(0x161D00, 0x134); + float speedy = readFloatPointer(0x161D00, 0x138); + float speedz = readFloatPointer(0x161D00, 0x13C); + + float maxHp = readFloatPointer(0x161D00, 0x1c0); + float damage = readFloatPointer(0x161D00, 0x278); + float currentHp = maxHp - damage; + + float speed = Math.Abs(speedx) + Math.Abs(speedy) + Math.Abs(speedz); + SpeedLbl.Text = "Speed: " + speed; + hpLbl.Text = "HP: " + currentHp; + } catch (Exception ex) + { + SpeedLbl.Text = ex.Message; + } + } + + } + + private float readFloatPointer(int pointer, int offset) + { + int bytesRead = 0; + byte[] buffer = new byte[4]; + + Int32 baseAddress = process.MainModule.BaseAddress.ToInt32() + pointer; + ReadProcessMemory((int)processHandle, baseAddress, buffer, buffer.Length, ref bytesRead); + Int32 baseValue = BitConverter.ToInt32(buffer, 0); + + Int32 firstAddress = baseValue + offset; + ReadProcessMemory((int)processHandle, firstAddress, buffer, buffer.Length, ref bytesRead); + float firstValue = BitConverter.ToSingle(buffer, 0); + + return firstValue; + + } + + [DllImport("kernel32.dll")] + public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId); + + [DllImport("kernel32.dll")] + public static extern bool ReadProcessMemory(int hProcess, int lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesRead); + + [DllImport("user32.dll", SetLastError = true)] + static extern bool GetWindowRect(IntPtr hWnd, ref RECT Rect); + + [StructLayout(LayoutKind.Sequential)] + public struct RECT + { + public int left; + public int top; + public int right; + public int bottom; + } + + } +} diff --git a/ShowGiantsForm/Form1.resx b/ShowGiantsForm/Form1.resx new file mode 100644 index 0000000..1f666f2 --- /dev/null +++ b/ShowGiantsForm/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/ShowGiantsForm/Program.cs b/ShowGiantsForm/Program.cs new file mode 100644 index 0000000..24dc461 --- /dev/null +++ b/ShowGiantsForm/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ShowGiantsForm +{ + static class Program + { + /// + /// Point d'entrée principal de l'application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/ShowGiantsForm/Properties/AssemblyInfo.cs b/ShowGiantsForm/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..24136a7 --- /dev/null +++ b/ShowGiantsForm/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Les informations générales relatives à un assembly dépendent de +// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations +// associées à un assembly. +[assembly: AssemblyTitle("ShowGiantsForm")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ShowGiantsForm")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly +// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de +// COM, affectez la valeur true à l'attribut ComVisible sur ce type. +[assembly: ComVisible(false)] + +// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM +[assembly: Guid("61828767-329e-4df3-bfb4-aa1a53310094")] + +// Les informations de version pour un assembly se composent des quatre valeurs suivantes : +// +// Version principale +// Version secondaire +// Numéro de build +// Révision +// +// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut +// en utilisant '*', comme indiqué ci-dessous : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ShowGiantsForm/Properties/Resources.Designer.cs b/ShowGiantsForm/Properties/Resources.Designer.cs new file mode 100644 index 0000000..afee121 --- /dev/null +++ b/ShowGiantsForm/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Ce code a été généré par un outil. +// Version du runtime :4.0.30319.42000 +// +// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si +// le code est régénéré. +// +//------------------------------------------------------------------------------ + +namespace ShowGiantsForm.Properties +{ + + + /// + /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. + /// + // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder + // à l'aide d'un outil, tel que ResGen ou Visual Studio. + // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen + // avec l'option /str ou régénérez votre projet VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ShowGiantsForm.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Remplace la propriété CurrentUICulture du thread actuel pour toutes + /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/ShowGiantsForm/Properties/Resources.resx b/ShowGiantsForm/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/ShowGiantsForm/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ShowGiantsForm/Properties/Settings.Designer.cs b/ShowGiantsForm/Properties/Settings.Designer.cs new file mode 100644 index 0000000..354c31f --- /dev/null +++ b/ShowGiantsForm/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ShowGiantsForm.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/ShowGiantsForm/Properties/Settings.settings b/ShowGiantsForm/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/ShowGiantsForm/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ShowGiantsForm/ShowGiantsForm.csproj b/ShowGiantsForm/ShowGiantsForm.csproj new file mode 100644 index 0000000..7cccee2 --- /dev/null +++ b/ShowGiantsForm/ShowGiantsForm.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {61828767-329E-4DF3-BFB4-AA1A53310094} + WinExe + ShowGiantsForm + ShowGiantsForm + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file