Post Reply 
Social Buttons
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Editing Memory Addresses
Author Message
Scorch Offline
Intermediate C++
********

Trade Count: (0)
Posts: 83
Joined: Jan 2011
Reputation: 15
Post: #1
Editing Memory Addresses
This will be an example on editing a memory address.

For this example I will demonstrate using the cheat engine tutorial which you can download at their website.

For editing you obviously need an address. You can search yourself by using ReadProccessMemory().
However I don't believe in reinventing the wheel, so I use cheat engine/tsearch to find the addresses.

The proccess is simple, so i'll let the code explain it.
Code:
//Memory editing by Scorch
#include <iostream>
#include <windows.h>

int main()
{
    HWND hwnd;
    HANDLE handle;
    DWORD id;
    DWORD parameter;
    BYTE data = 0x9AE;//Write hex value to the proccess

    /* Depending on the program or your OS you may need to uncomment this
    HANDLE Token;
    LUID Priv;
    TOKEN_PRIVILEGES tkp;
    OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &Token);//This is necessary for getting priviledges
    LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &Priv);
    tkp.PrivilegeCount = 1;
    tkp.Privileges[0].Luid = Priv;
    tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    AdjustTokenPrivileges(Token, false, &tkp, sizeof tkp, NULL, NULL);
    CloseHandle(Token);*/

    hwnd = FindWindow(NULL, "Cheat Engine Tutorial");//Name of window to find
    if (hwnd != 0) {
        GetWindowThreadProcessId(hwnd, &id);
        handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);

    }
    else
    {
        std::cout << "Could not find the window.";
        std::cin.get();
        return 0;
    }
    if (handle != 0)
    {
        if(WriteProcessMemory(handle, (int*)(0x006D5168)/*This address will be different*/,&data, sizeof(data), &parameter))
        {
        std::cout << "Memory wrote successfully.";
        std::cin.ignore();
        std::cin.get();
        }
        else
        {
            std::cout<<"\nError writing to memory\n"<<GetLastError();
            std::cin.get();
        }
    }
    else
    {
        std::cout << "Couldn't get a handle";
        std::cin.get();
    }
    return 0;
}
(This post was last modified: 01-22-2011 05:58 AM by Scorch.)
01-22-2011 05:57 AM
Find all posts by this user Quote this message in a reply
Ironside Offline
Site Owner
**********

Trade Count: (0)
Posts: 170
Joined: Nov 2010
Reputation: 7
Post: #2
RE: Editing Memory Addresses
Will come useful once I start C++.
01-22-2011 11:30 AM
Find all posts by this user Quote this message in a reply
Scorch Offline
Intermediate C++
********

Trade Count: (0)
Posts: 83
Joined: Jan 2011
Reputation: 15
Post: #3
RE: Editing Memory Addresses
You can always just post a thread or shoot me a pm if you have any problems with C++.
01-22-2011 07:00 PM
Find all posts by this user Quote this message in a reply
Ironside Offline
Site Owner
**********

Trade Count: (0)
Posts: 170
Joined: Nov 2010
Reputation: 7
Post: #4
RE: Editing Memory Addresses
Thank you, will do so Wink
(This post was last modified: 01-22-2011 07:09 PM by Ironside.)
01-22-2011 07:09 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: