Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


VB.NET How To Change Array Of Byte?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
dreamfancys
Newbie cheater
Reputation: 0

Joined: 09 May 2020
Posts: 13

PostPosted: Sat May 09, 2020 2:20 pm    Post subject: VB.NET How To Change Array Of Byte? Reply with quote

Process: notepad.exe

For example I want to change this aob code "54 73 6C 52 65". I want to make "53 52 6C 32 45"

But there are no changes. What's the easiest way to do this with Visual Basic? Please help me.
My guess is that the pointer has a lot of trouble finding it, because it's too long. But can you write me a suitable code for this? I love you. Thx <3
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 17

Joined: 01 Feb 2016
Posts: 1543

PostPosted: Sat May 09, 2020 2:30 pm    Post subject: Reply with quote

there are plenty of game hacking resources on cheat engine forums, and i bet on other forums as well.

just do a quick search here in the forums and you should be fine, also do a web search you may want to search how to alter different process memory using vb.net or maybe search for how to read and write to process using vb.net.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Back to top
View user's profile Send private message Visit poster's website
dreamfancys
Newbie cheater
Reputation: 0

Joined: 09 May 2020
Posts: 13

PostPosted: Sat May 09, 2020 3:05 pm    Post subject: Reply with quote

OldCheatEngineUser wrote:
there are plenty of game hacking resources on cheat engine forums, and i bet on other forums as well.

just do a quick search here in the forums and you should be fine, also do a web search you may want to search how to alter different process memory using vb.net or maybe search for how to read and write to process using vb.net.


I called but couldn't find it. I'm about to go crazy. Please help me.
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 17

Joined: 01 Feb 2016
Posts: 1543

PostPosted: Sat May 09, 2020 3:37 pm    Post subject: Reply with quote

a quick web search:

- using pointers:
https://www.youtube.com/watch?v=Sye3TYzTEGQ

- using dynamic 1 time use address:
https://www.youtube.com/watch?v=AZnKO7GEJrI

- vbforums have similar content:
http://www.vbforums.com/showthread.php?419320-WriteProcessMemory

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Back to top
View user's profile Send private message Visit poster's website
dreamfancys
Newbie cheater
Reputation: 0

Joined: 09 May 2020
Posts: 13

PostPosted: Sat May 09, 2020 3:49 pm    Post subject: Reply with quote

OldCheatEngineUser wrote:
a quic....


Really thank you. But "array of byte" doesn't give information about how to change the type. These only provide information to change fixed addresses. I just want to change (ARRAY OF BYTE) AOB. I couldn't find any resources about this.
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 17

Joined: 01 Feb 2016
Posts: 1543

PostPosted: Sat May 09, 2020 4:00 pm    Post subject: Reply with quote

array of byte, means a group of bytes; which also means it is altered 1 byte at a time.
so make a loop maybe a for-loop, and write 1 byte at a time until there are no bytes to write.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Back to top
View user's profile Send private message Visit poster's website
dreamfancys
Newbie cheater
Reputation: 0

Joined: 09 May 2020
Posts: 13

PostPosted: Sat May 09, 2020 4:42 pm    Post subject: Reply with quote

OldCheatEngineUser wrote:
array of byte, means a group of bytes; which also means it is altered 1 byte at a time.
so make a loop maybe a for-loop, and write 1 byte at a time until there are no bytes to write.


I coded something like this. You will understand me better if you watch the video.

What I want to do is change such an array of bytes. How do I do this? I am a beginner. I would be glad if you explain it in detail. So if you give the code <3

youtube com/watch?v=YFcKZOTp0eY&feature=emb_title
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 17

Joined: 01 Feb 2016
Posts: 1543

PostPosted: Sat May 09, 2020 6:17 pm    Post subject: Reply with quote

dreamfancys wrote:
I coded something like this. You will understand me better if you watch the video.

What I want to do is change such an array of bytes. How do I do this? I am a beginner. I would be glad if you explain it in detail. So if you give the code <3

https://www.youtube.com/watch?v=YFcKZOTp0eY&feature=emb_title


i do not understand VB, so i can not read the code and i can not write VB.

its not clear what you are doing, are you trying to change every address that contains the given array of bytes?

or maybe you are trying to retrieve the addresses that contain the AOB?

either ways i do not see any reference for WriteProcessMemory or ReadProcessMemory in your code.

i am assuming you are trying to change some executable code, so it might be a better idea to tell CE to scan readable and executable memory only.

the best i can do for you is to give you the functions you may need, also check the links i posted earlier they contain great code i guess.

also do not forget when writing bytes, make sure to increment the address by 1 after each call to WriteProcessMemory.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Back to top
View user's profile Send private message Visit poster's website
Corroder
Grandmaster Cheater Supreme
Reputation: 33

Joined: 10 Apr 2015
Posts: 1316

PostPosted: Sat May 09, 2020 7:24 pm    Post subject: Reply with quote

First, create a memory scan module library (I am using C#), contains two cs file:

Code:
// ScanMemory.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.IO;
using Microsoft.Win32.SafeHandles;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Runtime.ConstrainedExecution;
using System.Security;
using System.Security.Principal;

public class dotNetMemoryScan
{

    [DllImport("kernel32.dll")]
    public static extern uint GetLastError();
    [DllImport("kernel32.dll", SetLastError = true)]
    static extern void SetLastError(uint dwErrorCode);
    [DllImport("kernel32.dll")]
    public static extern int OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
    [DllImport("kernel32.dll")]
    protected static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] buffer, uint size, out uint lpNumberOfBytesRead);

    [DllImport("kernel32.dll")]
    public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] buffer, uint size, uint lpNumberOfBytesWritten);

    [DllImport("kernel32.dll", SetLastError = true)]
    protected static extern int VirtualQueryEx(IntPtr hProcess, IntPtr lpAddress, out MEMORY_BASIC_INFORMATION lpBuffer, uint dwLength);

    [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool IsWow64Process([In] IntPtr processHandle,
     [Out, MarshalAs(UnmanagedType.Bool)] out bool wow64Process);
    [DllImport("kernel32.dll", EntryPoint = "GetProcessId", CharSet = CharSet.Auto)]
    static extern int GetProcessId(IntPtr handle);
    [DllImport("kernel32.dll")]
    static extern bool VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress,
    UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect);
    public dotNetMemoryScan()
    {
        EnablePrivileges.GoDebugPriv();
    }

    public static string GetSystemMessage(uint errorCode)
    {
        var exception = new System.ComponentModel.Win32Exception((int)errorCode);
        return exception.Message;
    }
    [StructLayout(LayoutKind.Sequential)]
    protected struct MEMORY_BASIC_INFORMATION
    {
        public IntPtr BaseAddress;
        public IntPtr AllocationBase;
        public uint AllocationProtect;
        public uint RegionSize;
        public uint State;
        public uint Protect;
        public uint Type;
    }
    //uint PROCESS_ALL_ACCESS = 0x1F0FF;
    //Memory Protect
    //https://msdn.microsoft.com/en-us/library/windows/hardware/dn957515(v=vs.85).aspx
    private enum AllocationProtectEnum : uint
    {
        PAGE_EXECUTE            = 0x00000010,
        PAGE_EXECUTE_READ       = 0x00000020,
        PAGE_EXECUTE_READWRITE  = 0x00000040,
        PAGE_EXECUTE_WRITECOPY  = 0x00000080,
        PAGE_NOACCESS           = 0x00000001,
        PAGE_READONLY           = 0x00000002,
        PAGE_READWRITE          = 0x00000004,
        PAGE_WRITECOPY          = 0x00000008,
        PAGE_GUARD              = 0x00000100,
        PAGE_NOCACHE            = 0x00000200,
        PAGE_WRITECOMBINE       = 0x00000400
    }
    //Memory State
    //https://msdn.microsoft.com/en-us/library/windows/desktop/aa366775(v=vs.85).aspx
    private enum StateEnum : uint
    {
        MEM_COMMIT              = 0x1000,
        MEM_FREE                = 0x10000,
        MEM_RESERVE             = 0x2000
    }
    private enum TypeEnum : uint
    {
        MEM_IMAGE               = 0x1000000,
        MEM_MAPPED              = 0x40000,
        MEM_PRIVATE             = 0x20000
    }
    byte[] current_aob = null;
    string mask = "";
    IntPtr handle = IntPtr.Zero;
    int pid = 0;
    bool is_valid_hex_array(string text)
    {
        var regex = new Regex(@"^([a-fA-F0-9]{2}?(.*\?)?\s?)+$");
        var match = regex.Match(text);
        return (match.Success);
    }
    bool is_valid_pattern_mask(string text)
    {
        var regex = new Regex(@"^([\\*][x][a-fA-F0-9]{2})+$");
        var match = regex.Match(text);
        return (match.Success);
    }
    bool is_valid_mask(string text)
    {
        var regex = new Regex(@"^([xX]?(.*\?)?)+$");
        var match = regex.Match(text);
        return (match.Success);
    }
    int str_array_to_aob(string inputed_str)
    {
        var trated_str = inputed_str.Replace("  ", "");
        trated_str = (trated_str[0] == ' ') ? trated_str.Substring(1, trated_str.Length - 1) : trated_str;
        trated_str = (trated_str.Substring(trated_str.Length - 1, 1) == " ") ? trated_str.Substring(0, trated_str.Length - 1) : trated_str;

        if (!is_valid_hex_array(trated_str))
        {
            MessageBox.Show("not valid hex array {x1F0}", "by dotNetMemoryScan");
            return 0;
        }
     
        mask = "";
        var part_hex = inputed_str.Split(' ');
        current_aob = new byte[part_hex.Count()];
        for (var i = 0; i < part_hex.Count(); ++i)
        {
            if (part_hex[i].Contains("?"))
            {
                current_aob[i] = 0xCC;
                mask += "?";
            } else {
                current_aob[i] = Convert.ToByte(part_hex[i], 16);
                mask += "x";
            }
        }
        return part_hex.Count();
    }
   int pattern_to_aob(string inputed_str, string i_mask)
    {
        if (!is_valid_mask(i_mask))
            return 0;
        var trated_str = inputed_str.Replace(" ", "");
        if (!is_valid_pattern_mask(trated_str))
        {
            MessageBox.Show("not valid pattern {x1F0}", "by dotNetMemoryScan");
            return 0;
        }

        var part_hex = inputed_str.Split(new[] { @"\x" }, StringSplitOptions.None);
        if ((part_hex.Count() - 1) != i_mask.Length)
            return 0;
        mask = i_mask;
        current_aob = new byte[part_hex.Count()-1];
        for (var i = 1; i < part_hex.Count(); ++i)
        {
            var l = i - 1;
            if (i_mask[l] == '?')
                current_aob[l] = 0xCC;
            else
                current_aob[l] = Convert.ToByte(part_hex[i], 16);     
        }
        return part_hex.Count();
    }

    int pattern_to_aob(string inputed_str)
    {
        var trated_str = inputed_str.Replace(" ", "");
        if (!is_valid_pattern_mask(trated_str))
        {
            MessageBox.Show("not valid pattern {x1F1}", "by dotNetMemoryScan");
            return 0;
        }
        var part_hex = inputed_str.Split(new[] { @"\x" }, StringSplitOptions.None);
        current_aob = new byte[part_hex.Count() - 1];
        for (var i = 1; i < part_hex.Count(); ++i)
             current_aob[i - 1] = Convert.ToByte(part_hex[i], 16);   
        return part_hex.Count();
    }
    public static bool IsAdministrator()
    {
        return (new WindowsPrincipal(WindowsIdentity.GetCurrent()))
                  .IsInRole(WindowsBuiltInRole.Administrator);
    }
    IntPtr get_handle(Process p)
    {
        if (p == null)
            return IntPtr.Zero;
        try
        { return p.Handle; }
        catch(Exception ex)
        {
            if (!IsAdministrator())
                MessageBox.Show("Run the program as an administrator.", "by dotNetMemoryScan");
            else
                MessageBox.Show("error: " + ex.Message);
        }
        return IntPtr.Zero;
    }
    //===================================================================================================================================
    //===================================================================================================================================
    //===================================================================================================================================
    public IntPtr scan_all(IntPtr handle, string pattern)
    {
        if (str_array_to_aob(pattern) == 0)
            return IntPtr.Zero;
        this.handle = handle;
        this.pid    = GetProcessId(this.handle);
        return scan_all_regions();
    }
    public IntPtr scan_all(Process p, string pattern)
    {
        var by_handle = get_handle(p);
        if (by_handle != IntPtr.Zero)
            return scan_all(by_handle, pattern);
        return IntPtr.Zero;
    }
    public IntPtr scan_all(string p_name, string pattern)
    {
        var by_handle = get_handle(GetPID(p_name.Replace(".exe", "")));
        if (by_handle != IntPtr.Zero)
            return scan_all(by_handle, pattern);
        return IntPtr.Zero;
    }
    public IntPtr scan_all(int pid, string pattern)
    {
        var by_handle = get_handle(Process.GetProcessById(pid));
        if (by_handle != IntPtr.Zero)
            return scan_all(by_handle, pattern);
        return IntPtr.Zero;
    }
    //===================================================================================================================================
    //===================================================================================================================================
    //===================================================================================================================================
    public IntPtr scan_all(IntPtr handle, string pattern, string mask)
    {
        if (pattern_to_aob(pattern, mask) == 0)
            return IntPtr.Zero;
        this.handle = handle;
        return scan_all_regions();
    }
    public IntPtr scan_all(Process p, string pattern, string mask)
    {
        var by_handle = get_handle(p);
        if (by_handle != IntPtr.Zero)
            return scan_all(by_handle, pattern, mask);
        return IntPtr.Zero;
    }
    public IntPtr scan_all(string p_name, string pattern, string mask)
    {
        var by_handle = get_handle(GetPID(p_name.Replace(".exe", "")));
        if (by_handle != IntPtr.Zero)
            return scan_all(by_handle, pattern, mask);
        return IntPtr.Zero;
    }
    public IntPtr scan_all(int pid, string pattern, string mask)
    {
        var by_handle = get_handle(Process.GetProcessById(pid));
        if (by_handle != IntPtr.Zero)
            return scan_all(by_handle, pattern, mask);
        return IntPtr.Zero;
    }
    //===================================================================================================================================
    //===================================================================================================================================
    //===================================================================================================================================
    public IntPtr scan_module(Process p, string module_name, string pattern)
    {
        this.handle = get_handle(p);
        if (this.handle == IntPtr.Zero)
            return IntPtr.Zero;
        if (str_array_to_aob(pattern) == 0)
            return IntPtr.Zero;
        return module_region(p, module_name);
    }
    public IntPtr scan_module(int pid, string module_name, string pattern)
    {
        var p = Process.GetProcessById(pid);
        if (p != null)
            return scan_module(p, module_name, pattern);
        return IntPtr.Zero;
    }
    public IntPtr scan_module(string p_name, string module_name, string pattern)
    {
        var p = GetPID(p_name.Replace(".exe", ""));
        if (p != null)
            return scan_module(p, module_name, pattern);
        return IntPtr.Zero;
    }
    public IntPtr scan_module(IntPtr handle, string module_name, string pattern)
    {
        int pid = GetProcessId(handle);
        if (pid == 0)
            return IntPtr.Zero;
        return scan_module(pid, module_name, pattern);
    }
    //===================================================================================================================================
    //===================================================================================================================================
    //===================================================================================================================================
    public IntPtr scan_module(Process p, string module_name, string pattern, string mask)
    {
        this.handle = get_handle(p);
        if (this.handle == IntPtr.Zero)
            return IntPtr.Zero;
        if (pattern_to_aob(pattern, mask) == 0)
            return IntPtr.Zero;
        return module_region(p, module_name);
    }
    public IntPtr scan_module(int pid, string module_name, string pattern, string mask)
    {
        var p = Process.GetProcessById(pid);
        if (p != null)
            return scan_module(p, module_name, pattern, mask);
        return IntPtr.Zero;
    }
    public IntPtr scan_module(string p_name, string module_name, string pattern, string mask)
    {
        var p = GetPID(p_name.Replace(".exe", ""));
        if (p != null)
            return scan_module(p, module_name, pattern, mask);
        return IntPtr.Zero;
    }
    public IntPtr scan_module(IntPtr handle, string module_name, string pattern, string mask)
    {
        int pid = GetProcessId(handle);
        if (pid == 0)
            return IntPtr.Zero;
        return scan_module(pid, module_name, pattern, mask);
    }
    //===================================================================================================================================
    //===================================================================================================================================
    //===================================================================================================================================
    protected bool map_process_memory(IntPtr pHandle, List<MEMORY_BASIC_INFORMATION> mapped_memory)
    {
        IntPtr address = new IntPtr();
        MEMORY_BASIC_INFORMATION MBI = new MEMORY_BASIC_INFORMATION();
        while (VirtualQueryEx(pHandle, address, out MBI, (uint)Marshal.SizeOf(MBI)) != 0)
        {
            if ((MBI.State & (uint)StateEnum.MEM_COMMIT) != 0 && (MBI.Protect & (uint)AllocationProtectEnum.PAGE_GUARD) != (uint)AllocationProtectEnum.PAGE_GUARD)
                mapped_memory.Add(MBI);
            address = new IntPtr(MBI.BaseAddress.ToInt64() + MBI.RegionSize);
        }
        return (mapped_memory.Count() > 0);
    }
    int is_x64_process(IntPtr by_handle)
    {
        var is_64 = false;
        if (!IsWow64Process(by_handle, out is_64))
            return -1;
        return Convert.ToInt32(!is_64);
    }
    int search_pattern(byte[] buffer, int init_index)
    {
        for (var i = init_index; i < buffer.Count(); ++i)
        {
            for (var x = 0; x < current_aob.Count(); x++)
            {
                if (current_aob[x] != buffer[i + x] && mask[x] != '?')
                    goto end;
            }
            return i;
            end:;
        }
        return 0;
    }
    IntPtr module_region(Process p,  string module_str)
    {
        if (is_x64_process(Process.GetCurrentProcess().Handle) != is_x64_process(this.handle))
        {
            MessageBox.Show("Problems with retaining information or architectural incompatibility with the target process.", "by dotNetMemoryScan");
            return IntPtr.Zero;
        }
        var mod = find_module(p, module_str);
        if (mod == null)
            return IntPtr.Zero;
        byte[] buffer = new byte[mod.ModuleMemorySize];
        uint NumberOfBytesRead;
        if (ReadProcessMemory(handle, mod.BaseAddress, buffer, (uint)mod.ModuleMemorySize, out NumberOfBytesRead) && NumberOfBytesRead > 0)
        {
            var ret = search_pattern(buffer, 0);
            if (ret != 0)
                return (IntPtr)(mod.BaseAddress.ToInt64() + ret);
        }

        return IntPtr.Zero;
    }
    IntPtr scan_all_regions()
    {
        if (is_x64_process(Process.GetCurrentProcess().Handle) != is_x64_process(this.handle))
        {
            MessageBox.Show("Problems with retaining information or architectural incompatibility with the target process.", "by dotNetMemoryScan");
            return IntPtr.Zero;
        }
        var mapped_memory = new List<MEMORY_BASIC_INFORMATION>();
        if (!map_process_memory(handle, mapped_memory))
            return IntPtr.Zero;

        for (int i = 0; i < mapped_memory.Count(); i++)
        {
            byte[] buffer = new byte[mapped_memory[i].RegionSize];
            uint NumberOfBytesRead;
            if (ReadProcessMemory(handle, mapped_memory[i].BaseAddress, buffer, mapped_memory[i].RegionSize, out NumberOfBytesRead) && NumberOfBytesRead > 0)
            {
                var ret = search_pattern(buffer, 0);
                if (ret != 0)
                    return (IntPtr)(mapped_memory[i].BaseAddress.ToInt64() + ret);
            }
            var error_code = GetLastError();
            if (error_code == 6)//sometimes .net closes the handle.
            {
                var p = Process.GetProcessById(pid);
                if (p != null)
                    this.handle = p.Handle;
            }
        }
        return IntPtr.Zero;
    }
    public Process GetPID(string ProcessName)
    {
        try
        { return Process.GetProcessesByName(ProcessName)[0];  }
        catch {  }
        return null;
    }
    bool write_mem(IntPtr address, string pattern)
    {
        var size = 0;
        if (pattern.Contains(@"\x"))
            size = pattern_to_aob(pattern);
        else
            size = str_array_to_aob(pattern);
        if (size == 0)
            return false;
        uint old_p = 0;
        if (!VirtualProtectEx(handle, address, (UIntPtr)size, (uint)AllocationProtectEnum.PAGE_EXECUTE_READWRITE, out old_p))
            return false;
        var ret = WriteProcessMemory(handle, address, current_aob, (uint)size, 0);
        VirtualProtectEx(handle, address, (UIntPtr)size, old_p, out old_p);
        return ret;
    }
    public bool write_mem(IntPtr handle, IntPtr address, string pattern)
    {
        if (address == null)
            return false;
        this.handle = handle;
        return write_mem(address, pattern);
    }
    public bool write_mem(Process p, IntPtr address, string pattern)
    {
        var by_handle = get_handle(p);
        if (by_handle == IntPtr.Zero)
            return false;
        return write_mem(by_handle, address, pattern);
    }
    public bool write_mem(string p_name, IntPtr address, string pattern)
    {
        var by_handle = get_handle(GetPID(p_name.Replace(".exe", "")));
        if (by_handle == IntPtr.Zero)
            return false;
        return write_mem(by_handle, address, pattern);
    }
    public bool write_mem(int pid, IntPtr address, string pattern)
    {
        var by_handle = get_handle(Process.GetProcessById(pid));
        if (by_handle == IntPtr.Zero)
            return false;
        return write_mem(by_handle, address, pattern);
       
    }
    public ProcessModule find_module(Process p, string module_str)
    {
        foreach (ProcessModule modu in p.Modules)
        {
            if (modu.FileName.ToLower().Contains(module_str.ToLower()))
             return modu;
        }
        return null;
    }
    public Process get_chrome_flashplayer_process()
    {
        foreach (Process proc in Process.GetProcessesByName("chrome"))
        {
            if (find_module(proc, "pepflashplayer.dll") != null)
                return proc;
        }
        return null;
    }
}



Code:
//EnablePriviliges.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;


public class EnablePrivileges
    {
        [DllImport("advapi32.dll", SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool OpenProcessToken(IntPtr ProcessHandle,
            UInt32 DesiredAccess, out IntPtr TokenHandle);

        private static uint STANDARD_RIGHTS_REQUIRED = 0x000F0000;
        private static uint STANDARD_RIGHTS_READ = 0x00020000;
        private static uint TOKEN_ASSIGN_PRIMARY = 0x0001;
        private static uint TOKEN_DUPLICATE = 0x0002;
        private static uint TOKEN_IMPERSONATE = 0x0004;
        private static uint TOKEN_QUERY = 0x0008;
        private static uint TOKEN_QUERY_SOURCE = 0x0010;
        private static uint TOKEN_ADJUST_PRIVILEGES = 0x0020;
        private static uint TOKEN_ADJUST_GROUPS = 0x0040;
        private static uint TOKEN_ADJUST_DEFAULT = 0x0080;
        private static uint TOKEN_ADJUST_SESSIONID = 0x0100;
        private static uint TOKEN_READ = (STANDARD_RIGHTS_READ | TOKEN_QUERY);
        private static uint TOKEN_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY |
            TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_QUERY_SOURCE |
            TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT |
            TOKEN_ADJUST_SESSIONID);

        [DllImport("kernel32.dll", SetLastError = true)]
        static extern IntPtr GetCurrentProcess();

        [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool LookupPrivilegeValue(string lpSystemName, string lpName,
            out LUID lpLuid);

        public const string SE_ASSIGNPRIMARYTOKEN_NAME = "SeAssignPrimaryTokenPrivilege";
        public const string SE_AUDIT_NAME = "SeAuditPrivilege";

        public const string SE_BACKUP_NAME = "SeBackupPrivilege";

        public const string SE_CHANGE_NOTIFY_NAME = "SeChangeNotifyPrivilege";

        public const string SE_CREATE_GLOBAL_NAME = "SeCreateGlobalPrivilege";

        public const string SE_CREATE_PAGEFILE_NAME = "SeCreatePagefilePrivilege";

        public const string SE_CREATE_PERMANENT_NAME = "SeCreatePermanentPrivilege";

        public const string SE_CREATE_SYMBOLIC_LINK_NAME = "SeCreateSymbolicLinkPrivilege";

        public const string SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege";

        public const string SE_DEBUG_NAME = "SeDebugPrivilege";

        public const string SE_ENABLE_DELEGATION_NAME = "SeEnableDelegationPrivilege";

        public const string SE_IMPERSONATE_NAME = "SeImpersonatePrivilege";

        public const string SE_INC_BASE_PRIORITY_NAME = "SeIncreaseBasePriorityPrivilege";

        public const string SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege";

        public const string SE_INC_WORKING_SET_NAME = "SeIncreaseWorkingSetPrivilege";

        public const string SE_LOAD_DRIVER_NAME = "SeLoadDriverPrivilege";

        public const string SE_LOCK_MEMORY_NAME = "SeLockMemoryPrivilege";

        public const string SE_MACHINE_ACCOUNT_NAME = "SeMachineAccountPrivilege";

        public const string SE_MANAGE_VOLUME_NAME = "SeManageVolumePrivilege";

        public const string SE_PROF_SINGLE_PROCESS_NAME = "SeProfileSingleProcessPrivilege";

        public const string SE_RELABEL_NAME = "SeRelabelPrivilege";

        public const string SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege";

        public const string SE_RESTORE_NAME = "SeRestorePrivilege";

        public const string SE_SECURITY_NAME = "SeSecurityPrivilege";

        public const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";

        public const string SE_SYNC_AGENT_NAME = "SeSyncAgentPrivilege";

        public const string SE_SYSTEM_ENVIRONMENT_NAME = "SeSystemEnvironmentPrivilege";

        public const string SE_SYSTEM_PROFILE_NAME = "SeSystemProfilePrivilege";

        public const string SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege";

        public const string SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege";

        public const string SE_TCB_NAME = "SeTcbPrivilege";

        public const string SE_TIME_ZONE_NAME = "SeTimeZonePrivilege";

        public const string SE_TRUSTED_CREDMAN_ACCESS_NAME = "SeTrustedCredManAccessPrivilege";

        public const string SE_UNDOCK_NAME = "SeUndockPrivilege";

        public const string SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege";

        [StructLayout(LayoutKind.Sequential)]
        public struct LUID
        {
            public UInt32 LowPart;
            public Int32 HighPart;
        }

        [DllImport("kernel32.dll", SetLastError = true)]
        static extern bool CloseHandle(IntPtr hHandle);

        public const UInt32 SE_PRIVILEGE_ENABLED_BY_DEFAULT = 0x00000001;
        public const UInt32 SE_PRIVILEGE_ENABLED = 0x00000002;
        public const UInt32 SE_PRIVILEGE_REMOVED = 0x00000004;
        public const UInt32 SE_PRIVILEGE_USED_FOR_ACCESS = 0x80000000;

        [StructLayout(LayoutKind.Sequential)]
        public struct TOKEN_PRIVILEGES
        {
            public UInt32 PrivilegeCount;
            public LUID Luid;
            public UInt32 Attributes;
        }

        [StructLayout(LayoutKind.Sequential)]
        public struct LUID_AND_ATTRIBUTES
        {
            public LUID Luid;
            public UInt32 Attributes;
        }

        // Use this signature if you do not want the previous state
        [DllImport("advapi32.dll", SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool AdjustTokenPrivileges(IntPtr TokenHandle,
           [MarshalAs(UnmanagedType.Bool)]bool DisableAllPrivileges,
           ref TOKEN_PRIVILEGES NewState,
           UInt32 Zero,
           IntPtr Null1,
           IntPtr Null2);

    public static void GoDebugPriv()
    {
            IntPtr hToken;
            LUID luidSEDebugNameValue;
            TOKEN_PRIVILEGES tkpPrivileges;

            if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, out hToken))
            {           
                return;
            }
            if (!LookupPrivilegeValue(null, SE_DEBUG_NAME, out luidSEDebugNameValue))
            {
                CloseHandle(hToken);
                return;
            }
            tkpPrivileges.PrivilegeCount = 1;
            tkpPrivileges.Luid = luidSEDebugNameValue;
            tkpPrivileges.Attributes = SE_PRIVILEGE_ENABLED;
            AdjustTokenPrivileges(hToken, false, ref tkpPrivileges, 0, IntPtr.Zero, IntPtr.Zero);
            CloseHandle(hToken);
        }
    }



Build the library with the class name: dotNetMemoryScan

Example: use for scan and write AOB in VB Net (Console app)

Code:
Module Module1


    '83 05 ?? ?? ?? ?? 0A A1
    '\x83\x05\x00\x00\x00\x00\x0A\xA1
    'xx????xx
    '0045B072

    Sub use_example()

        Dim find_aob As New dotNetMemoryScan()
        ' scan_all: will scan all process memory, from Static And dynamic.
        Dim test1 = IntPtr.Zero
        Dim test2 = IntPtr.Zero

        ' with simple array
        test2 = find_aob.scan_all("test.exe", "83 05 ?? ?? ?? ?? 0A A1")

        ' with pattern And mask
        test1 = find_aob.scan_all("test.exe", "\x83\x05\x00\x00\x00\x00\x0A\xA1", "xx????xx")

        Console.WriteLine("result 0x{0:X16}, 0x{0:X16}", test1.ToInt64(), test2.ToInt64())
        Dim p = Process.GetProcessesByName("test")
        If Not IsNothing(p) And p.Count() > 0 Then

            ' can be used by passing the process handle directly.
            test1 = find_aob.scan_all(p(0).Handle, "83 05 ?? ?? ?? ?? 0A A1")
            Console.WriteLine("[handle] result 0x{0:X16}", test1.ToInt64())

            ' can be used by passing the process.
            test1 = find_aob.scan_all(p(0), "83 05 ?? ?? ?? ?? 0A A1")
            Console.WriteLine("[process] result 0x{0:X16}", test1.ToInt64())

            ' can be used by passing the process id.
            test1 = find_aob.scan_all(p(0).Id, "83 05 ?? ?? ?? ?? 0A A1")
            Console.WriteLine("[pid] result 0x{0:X16}", test1.ToInt64())
        End If

        ' scan_module: scans only the Static part Of the Module
        test2 = find_aob.scan_module("test.exe", "test.exe", "83 05 ?? ?? ?? ?? 0A A1")
        Console.WriteLine("[module 1] result 0x{0:X16}", test1.ToInt64())

        ' with pattern And mask
        test1 = find_aob.scan_module("test.exe", "name.dll", "\x83\x05\x00\x00\x00\x00\x0A\xA1", "xx????xx")
        Console.WriteLine("[module 2] result 0x{0:X16}", test1.ToInt64())

        ' Writing in memory.
        find_aob.write_mem("test.exe", test1, "90 90 90 90 90 90 90")

        ' or
        find_aob.write_mem("test.exe", test1, "\x90\x90\x90\x90\x90\x90\x90")
    End Sub
    Sub Main()
        use_example()
        Console.ReadKey()
    End Sub

End Module


_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
dreamfancys
Newbie cheater
Reputation: 0

Joined: 09 May 2020
Posts: 13

PostPosted: Sun May 10, 2020 3:53 am    Post subject: Reply with quote

Corroder wrote:
First, cre.....

[/code]


Thank you so much <3. But

i.imgur. com/et0SeY9.png
youtube. com/watch?v=YFcKZOTp0eY

As you can see here, the pointer number of the array of byte code is too long. Therefore, no coding and software can change the array of bytes of pointers of this length. How can I solve this?
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 33

Joined: 10 Apr 2015
Posts: 1316

PostPosted: Sun May 10, 2020 5:32 am    Post subject: Reply with quote

What you mean with the pointer?. I just see them as addresses.

Example:

Code:
 <DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function WriteProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As  IntPtr, ByVal lpBuffer As Byte(), ByVal nSize As System.UInt32, <Out()> ByRef lpNumberOfBytesWritten As Int32) As Boolean
End Function

Dim p As Process() = Process.GetProcessesByName(AppName.Text)
Dim Written As Boolean = False
Written = WriteProcessMemory(p, &HB8FDCC change to your address, your aob, size)

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
dreamfancys
Newbie cheater
Reputation: 0

Joined: 09 May 2020
Posts: 13

PostPosted: Sun May 10, 2020 6:16 am    Post subject: Reply with quote

Corroder wrote:
What you mean with the pointer?. I just see them as addresses.

Example:

Code:
 <DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function WriteProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As  IntPtr, ByVal lpBuffer As Byte(), ByVal nSize As System.UInt32, <Out()> ByRef lpNumberOfBytesWritten As Int32) As Boolean
End Function

Dim p As Process() = Process.GetProcessesByName(AppName.Text)
Dim Written As Boolean = False
Written = WriteProcessMemory(p, &HB8FDCC change to your address, your aob, size)



I want to replace an existing array of bytes without the need for a pointer.

Example;

Previous AOB : 54 73 6C 52 65 63 6F 69 6C 43 6F
New Changed AOB : 55 66 6F 52 65 63 6F 69 6C 43 6F
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 33

Joined: 10 Apr 2015
Posts: 1316

PostPosted: Sun May 10, 2020 2:55 pm    Post subject: Reply with quote

dreamfancys wrote:

I want to replace an existing array of bytes without the need for a pointer.


Please tell me what is a pointer?.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
dreamfancys
Newbie cheater
Reputation: 0

Joined: 09 May 2020
Posts: 13

PostPosted: Sun May 10, 2020 8:09 pm    Post subject: Reply with quote

Corroder wrote:
dreamfancys wrote:

I want to replace an existing array of bytes without the need for a pointer.


Please tell me what is a pointer?.


Pointer: 20838EB5BE9

This is not always the same. It is changing.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites