WriteProcessMemory

This is a discussion on WriteProcessMemory within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I'm using Microsoft Visual C++ 2005 express edition, and I am currently writing a program to write to the ...

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    4

    WriteProcessMemory

    Hi, I'm using Microsoft Visual C++ 2005 express edition, and I am currently writing a program to write to the memory in a game. I got what I needed to get working, but when I can't seem to simplify down the code, without getting errors.

    Basically I have 6 Combo Box's, and each combo box has about 10 different selections (all the same).


    This code works:
    Code:
                                                    byte data[4];
                                                    byte data2[4];
    					        selectedIndex[0] = comboBox1->SelectedIndex;
    						selectedIndex[1] = comboBox2->SelectedIndex;
    
                                                    //selectedIndex 2 3 4 5..
    
    							if(selectedIndex[0] == 0){
    								byte data[4] = {0x6c, 0x18, 0xf2, 0x4b};
    								byte data2[4] = {0x9d, 0x05, 0x11, 0xe7};
    								WriteProcessMemory(phandle, (LPVOID)0x4BF4A700, (LPVOID) &data, 4, 0);
    								WriteProcessMemory(phandle, (LPVOID)0x4BF4A708, (LPVOID) &data2, 4, 0);
    								WriteProcessMemory(phandle, (LPVOID)0x4BF4A7CC, (LPVOID) &data, 4, 0);
    								WriteProcessMemory(phandle, (LPVOID)0x4BF4A7D4, (LPVOID) &data2, 4, 0);
    							}
    							else if(selectedIndex[0] == 1){
    								byte data[4] = {0x7f, 0xd8, 0xf2, 0x4b};
    								byte data2[4] = {0x14, 0x04, 0x88, 0xe5};
    								WriteProcessMemory(phandle, (LPVOID)0x4BF4A700, (LPVOID) &data, 4, 0);
    								WriteProcessMemory(phandle, (LPVOID)0x4BF4A708, (LPVOID) &data2, 4, 0);
    								WriteProcessMemory(phandle, (LPVOID)0x4BF4A7CC, (LPVOID) &data, 4, 0);
    								WriteProcessMemory(phandle, (LPVOID)0x4BF4A7D4, (LPVOID) &data2, 4, 0);
                                                             //else if(selectedIndex .. 4 more continue this way.
    Here is what I'm trying to simplify it down to, but running into errors.

    Code:
                                                    byte data[4];
                                                    byte data2[4];
    					        selectedIndex[0] = comboBox1->SelectedIndex;
    						selectedIndex[1] = comboBox2->SelectedIndex;
    
                                                    //selectedIndex 2 3 4 5..
    
    
                                                    for(int i = 0; i < 5; i++){
    							if(selectedIndex[i] == 0){
    								byte data[4] = {0x6c, 0x18, 0xf2, 0x4b};
    								byte data2[4] = {0x9d, 0x05, 0x11, 0xe7};
    							}
    							else if(selectedIndex[i] == 1){
    								byte data[4] = {0x7f, 0xd8, 0xf2, 0x4b};
    								byte data2[4] = {0x14, 0x04, 0x88, 0xe5};
                                                          }
    
                                                             //else if(selectedIndex .. 4 more continue this way.
    
    								WriteProcessMemory(phandle, (LPVOID)0x4BF4A700, (LPVOID) &data, 4, 0);
    								WriteProcessMemory(phandle, (LPVOID)0x4BF4A708, (LPVOID) &data2, 4, 0);
    								WriteProcessMemory(phandle, (LPVOID)0x4BF4A7CC, (LPVOID) &data, 4, 0);
    								WriteProcessMemory(phandle, (LPVOID)0x4BF4A7D4, (LPVOID) &data2, 4, 0);
    Anyway that can simplify this code is greatly appreciated. Thanks.

    - Crypt Easy -

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    What kind of game hacking is this? If this is singleplayer, then whatever. If it's multiplayer, you're scum (and for that matter it breaks the forum rules).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WriteProcessMemory failing with GetLastError 87
    By Anddos in forum Windows Programming
    Replies: 5
    Last Post: 04-19-2009, 03:34 PM
  2. createremotethread and writeprocessmemory problems
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 01-19-2008, 09:33 AM
  3. createremotethread and writeprocessmemory problems
    By cloudy in forum C++ Programming
    Replies: 1
    Last Post: 07-03-2005, 06:06 PM
  4. WriteProcessMemory help please
    By Rune Hunter in forum Windows Programming
    Replies: 6
    Last Post: 02-22-2005, 12:34 AM
  5. WriteProcessMemory
    By cppdude in forum Windows Programming
    Replies: 3
    Last Post: 04-12-2002, 09:31 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21