Beispiel #1
0
        public static void CreateConsole()
        {
            NativeImport.AllocConsole();

            var outFile = NativeImport.CreateFile("CONOUT$", NativeImport.GENERIC_WRITE | NativeImport.GENERIC_READ,
                                                  NativeImport.FILE_SHARE_WRITE, 0, NativeImport.OPEN_EXISTING, /*FILE_ATTRIBUTE_NORMAL*/ 0, 0);
            var safeHandle = new SafeFileHandle(outFile, true);

            NativeImport.SetStdHandle(-11, outFile);

            var fs     = new FileStream(safeHandle, FileAccess.Write);
            var writer = new StreamWriter(fs)
            {
                AutoFlush = true
            };

            Console.SetOut(writer);

            if (NativeImport.GetConsoleMode(outFile, out var cMode))
            {
                NativeImport.SetConsoleMode(outFile, cMode | 0x0200);
            }

            Console.Title = $@"Debug Window - {Assembly.GetExecutingAssembly().GetName().Name}";
        }
Beispiel #2
0
        public static string ReadString(int address, Encoding Encoding)
        {
            var dataBuffer = new byte[512];

            NativeImport.ReadProcessMemory(
                System.Diagnostics.Process.GetProcessesByName("League of Legends").FirstOrDefault().Handle,
                (IntPtr)address, dataBuffer, dataBuffer.Length, out var bytesRead);

            return(bytesRead == IntPtr.Zero ? string.Empty : Encoding.GetString(dataBuffer).Split('\0')[0]);
        }
Beispiel #3
0
        public static IntPtr GetPubgWindow()
        {
            IntPtr hwnd = NativeImport.FindWindow("TXGuiFoundation", "Gameloop【Turbo AOW Engine-4.4】");

            if (hwnd == IntPtr.Zero)
            {
                hwnd = NativeImport.FindWindow("TXGuiFoundation", "Gameloop【Turbo AOW Engine】");
            }
            hwnd = NativeImport.FindWindowEx(hwnd, 0, "AEngineRenderWindowClass", "AEngineRenderWindow");
            return(hwnd);
        }
Beispiel #4
0
 public static void Clear()
 {
     if (NativeImport.GetConsoleWindow() != IntPtr.Zero)
     {
         Console.Clear();
     }
     else
     {
         MessageBox.Show(null, "Error: There is no debug console running!", $"{Assembly.GetExecutingAssembly().GetName().Name}");
         return;
     }
 }
Beispiel #5
0
 public static IntPtr GetConsoleHandle()
 {
     if (NativeImport.GetConsoleWindow() != IntPtr.Zero)
     {
         return(NativeImport.GetConsoleWindow());
     }
     else
     {
         MessageBox.Show(null, @"Error: There is no debug console running!",
                         $@"{Assembly.GetExecutingAssembly().GetName().Name}");
         return(IntPtr.Zero);
     }
 }
Beispiel #6
0
 public static void HideConsole()
 {
     if (NativeImport.GetConsoleWindow() != IntPtr.Zero)
     {
         var handle = NativeImport.GetConsoleWindow();
         NativeImport.ShowWindow(handle, NativeImport.SW_HIDE);
     }
     else
     {
         MessageBox.Show(null, "Error: There is no debug console running!", $"{Assembly.GetExecutingAssembly().GetName().Name}");
         return;
     }
 }
Beispiel #7
0
        public static T Read <T>(int Address)
        {
            var  Size   = Marshal.SizeOf <T>();
            var  Buffer = new byte[Size];
            bool Result = NativeImport.ReadProcessMemory(Process.GetProcessesByName("League of Legends").FirstOrDefault().Handle, (IntPtr)Address, Buffer, Size, out var lpRead);
            var  Ptr    = Marshal.AllocHGlobal(Size);

            Marshal.Copy(Buffer, 0, Ptr, Size);
            var Struct = Marshal.PtrToStructure <T>(Ptr);

            Marshal.FreeHGlobal(Ptr);
            return(Struct);
        }
Beispiel #8
0
        public static bool IsGameOnDisplay()
        {
            string windowTitle = NativeImport.GetActiveWindowTitle();

            if (windowTitle != null)
            {
                if (windowTitle.Contains("Turbo AOW Engine"))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #9
0
        public static string Log(string format, LogLevel formatColor = LogLevel.Debug)
        {
            if (NativeImport.GetConsoleWindow() != IntPtr.Zero)
            {
                var consoleColour = Console.ForegroundColor;

                switch (formatColor)
                {
                case LogLevel.Debug:
                    consoleColour = ConsoleColor.Cyan;
                    break;

                case LogLevel.Error:
                    consoleColour = ConsoleColor.Red;
                    break;

                case LogLevel.Warn:
                    consoleColour = ConsoleColor.Magenta;
                    break;

                case LogLevel.Info:
                    break;

                default:
                    // Default color
                    break;
                }

                Console.ForegroundColor = consoleColour;

                if (string.IsNullOrEmpty(format))
                {
                    Console.WriteLine(
                        $@"[{Assembly.GetExecutingAssembly().GetName().Name}] StringNullOrEmpty Occured at LogService.Log");
                    return
                        ($"[{Assembly.GetExecutingAssembly().GetName().Name}] StringNullOrEmpty Occured at LogService.Log");
                }

                Console.WriteLine(
                    $@"[{DateTime.Now:h:mm:ss tt} - {Assembly.GetExecutingAssembly().GetName().Name}]: {format}");
                return($"[{DateTime.Now:h:mm:ss tt} - {Assembly.GetExecutingAssembly().GetName().Name}]: {format}");
            }
            else
            {
                MessageBox.Show(null, @"Error: There is no debug console running!",
                                $@"{Assembly.GetExecutingAssembly().GetName().Name}");
                return("Error: There is no debug console running!");
            }
        }
Beispiel #10
0
        public static T Read <T>(int address)
        {
            var size   = Marshal.SizeOf <T>();
            var buffer = new byte[size];
            var result = NativeImport.ReadProcessMemory(
                Process.GetProcessesByName("League of Legends").FirstOrDefault().Handle, (IntPtr)address, buffer, size,
                out var lpRead);
            var ptr = Marshal.AllocHGlobal(size);

            Marshal.Copy(buffer, 0, ptr, size);
            var ptrToStructure = Marshal.PtrToStructure <T>(ptr);

            Marshal.FreeHGlobal(ptr);
            return(ptrToStructure);
        }
Beispiel #11
0
        public static Vector3 Read3DVector(int address)
        {
            Vector3 tmp = new Vector3();

            byte[] Buffer = new byte[12];
            IntPtr ByteRead;

            NativeImport.ReadProcessMemory(Process.GetProcessesByName("League of Legends").FirstOrDefault().Handle, (IntPtr)(address + Game.OffsetManager.Object.Pos), Buffer, 12, out ByteRead);

            tmp.X = BitConverter.ToSingle(Buffer, (0 * 4));
            tmp.Y = BitConverter.ToSingle(Buffer, (1 * 4));
            tmp.Z = BitConverter.ToSingle(Buffer, (2 * 4));

            return(tmp);
        }
Beispiel #12
0
        public static Bitmap GetScreenCapture(Rectangle fov)
        {
            var screenCopy = new Bitmap(fov.Width, fov.Height, PixelFormat.Format24bppRgb);

            using (var gdest = Graphics.FromImage(screenCopy))

                using (var gsrc = Graphics.FromHwnd(IntPtr.Zero))
                {
                    var hSrcDc = gsrc.GetHdc();
                    var hDc    = gdest.GetHdc();
                    NativeImport.BitBlt(hDc, 0, 0, fov.Width, fov.Height, hSrcDc, fov.X, fov.Y, (int)CopyPixelOperation.SourceCopy);

                    gdest.ReleaseHdc();
                    gsrc.ReleaseHdc();
                }

            return(screenCopy);
        }
Beispiel #13
0
        /// <summary>
        /// Moves the cursor to a point in a timespan
        /// </summary>
        public static void MoveCursor(Point point, TimeSpan timeSpan)
        {
            if (point.X < 0 || point.Y < 0)
            {
                throw new ArgumentException("The provided point was invalid");
            }

            if (timeSpan.TotalMilliseconds <= 0)
            {
                throw new ArgumentException("The provided timespan was invalid");
            }

            // Generate a randomised set of movements from the current cursor position to the point

            if (!NativeImport.GetCursorPos(out var currentCursorPosition))
            {
                throw new Win32Exception();
            }

            var cursorMovements = GenerateMovements(currentCursorPosition, point, (int)timeSpan.TotalMilliseconds);

            // Perform the movements

            var stopwatch = Stopwatch.StartNew();

            foreach (var movement in cursorMovements)
            {
                if (movement.Points.Any(movementPoint => !NativeImport.SetCursorPos(movementPoint.X, movementPoint.Y)))
                {
                    throw new Win32Exception();
                }

                while (stopwatch.ElapsedMilliseconds < movement.Delay.Milliseconds)
                {
                    // Wait
                }

                stopwatch.Restart();
            }
        }
Beispiel #14
0
        public static Matrix ReadMatrix(int address)
        {
            Matrix tmp = Matrix.Zero;

            byte[] Buffer = new byte[64];
            IntPtr ByteRead;

            NativeImport.ReadProcessMemory(Process.GetProcessesByName("League of Legends").FirstOrDefault().Handle, (IntPtr)address, Buffer, 64, out ByteRead);

            if (ByteRead == IntPtr.Zero)
            {
                //Console.WriteLine($"[ReadMatrix] No bytes has been read at 0x{address.ToString("X")}");
                return(new Matrix());
            }

            tmp.M11 = BitConverter.ToSingle(Buffer, (0 * 4));
            tmp.M12 = BitConverter.ToSingle(Buffer, (1 * 4));
            tmp.M13 = BitConverter.ToSingle(Buffer, (2 * 4));
            tmp.M14 = BitConverter.ToSingle(Buffer, (3 * 4));

            tmp.M21 = BitConverter.ToSingle(Buffer, (4 * 4));
            tmp.M22 = BitConverter.ToSingle(Buffer, (5 * 4));
            tmp.M23 = BitConverter.ToSingle(Buffer, (6 * 4));
            tmp.M24 = BitConverter.ToSingle(Buffer, (7 * 4));

            tmp.M31 = BitConverter.ToSingle(Buffer, (8 * 4));
            tmp.M32 = BitConverter.ToSingle(Buffer, (9 * 4));
            tmp.M33 = BitConverter.ToSingle(Buffer, (10 * 4));
            tmp.M34 = BitConverter.ToSingle(Buffer, (11 * 4));

            tmp.M41 = BitConverter.ToSingle(Buffer, (12 * 4));
            tmp.M42 = BitConverter.ToSingle(Buffer, (13 * 4));
            tmp.M43 = BitConverter.ToSingle(Buffer, (14 * 4));
            tmp.M44 = BitConverter.ToSingle(Buffer, (15 * 4));

            return(tmp);
        }
Beispiel #15
0
 public static bool IsKeyPressed(System.Windows.Forms.Keys keys)
 {
     return(0 != (NativeImport.GetAsyncKeyState((int)keys) & 0x8000));
 }
Beispiel #16
0
 public static bool IsGameOnDisplay()
 {
     return(NativeImport.GetActiveWindowTitle() == "League of Legends (TM) Client");
 }
Beispiel #17
0
 public static bool IsKeyPressed(uint keys)
 {
     return(0 != (NativeImport.GetAsyncKeyState((int)keys) & 0x8000));
 }
Beispiel #18
0
 public static bool IsGameOnDisplay()
 {
     //TODO: HWND Locking up on League's HWND
     return(NativeImport.GetActiveWindowTitle() == "League of Legends (TM) Client");
 }