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 


[FIXED]Small problem, please help.[FIXED]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Evil_Intentions
Expert Cheater
Reputation: 65

Joined: 07 Jan 2010
Posts: 214

PostPosted: Sun Jun 13, 2010 12:43 am    Post subject: [FIXED]Small problem, please help.[FIXED] Reply with quote

Here is a code i wrote for a mmory reader/writer.

Code:
#include <iostream>
#include <windows.h>
using namespace std;

int MemoryRW(char Window[], long int Address, int Value, char RW)
{
    //Variables
    HWND hwnd;
    DWORD pid;
    HANDLE proc_handle;
    int changeValue;

    //Initialization
    hwnd = FindWindow(NULL, (LPCTSTR)Window);
    GetWindowThreadProcessId(hwnd, &pid);
    proc_handle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);

    //Actions
    if (RW == 'r' || RW == 'R')
    {

        ReadProcessMemory(proc_handle, (LPVOID)Address, &Value, sizeof(long int), NULL);
        cout << "\nThe value is: " << Value;

    }
    else if (RW == 'w' || RW == 'W')
    {

        cout << "\nWhat is the new value:";
        cin >> changeValue;
        WriteProcessMemory(proc_handle, (LPVOID)Address, &changeValue, sizeof(int), NULL);
    }


}

int main()
{
    char whatAction;
    char winName[100];
    long int address;
    int value = 0;


    cout << "What window do you wish to opperate on: ";
    cin >> winName;

    cout << "\nWhat action do you with to perform, READ or WRITE? [r/w]";
    cin >> whatAction;

    cout << "\nWhat address do you wish to opperate on:";
    cin >> hex >> address;

    MemoryRW(winName, address, value, whatAction);

    //Closing
    cout << "\nPress any key to exit";
    cin.get();
    return 0;
}


Everything works like a DREAM (thanks to slovach) but i am running into one minor annoyance.

Whenever i write to an address, my number is interpreted and added as a hex, so if i use the value 35, i get 53 in the target program. How do i prevent this from happening?

Also, feel free to use that MemoryRW function if you feel so inclined.


EDIT: FIXED...had to set cin back to dec. "cin >> dec >> changeValue"
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