help with reading a file,

ok i'm kinda new to this,
i wanted to make it into a dll and then let it change memory of a game >.>


this what i'm gonna post is COMPLETLY wrong and i just got it from someone, who roughly made of it , i read the last tutorial for reading files but i don't rly get it.
i always and up with a minimum of 10 errors
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <windows.h>
#include <iostream>
#include <fstream>
#include <string>

void ReadHax() 
{ 
int linenum = 0; 
string line; 

ifstream myfile; 
myfile.open("wthax.txt"); 

if (myfile.is_open()) 
{ 
while (!myfile.eof()) 
{ 
getline (myfile, line); 

if (atoi(line.c_str()) != 0) 
{ 
haxvals[linenum] = atoi(line.c_str()); 
} 

linenum+=1; 
} 
myfile.close(); 
} 
}
	
		DWORD WINAPI minerals( LPVOID lpParam  ); DWORD WINAPI minerals( LPVOID lpParam){DWORD OldProt;
		int *offset = (int*)0x3427CC08;
		while(true)
		{
	    while(!(GetAsyncKeyState(0x63))) Sleep(100);
		VirtualProtect(offset, 4, PAGE_EXECUTE_READWRITE, &OldProt);
		*offset = haxvals[0];
		VirtualProtect(offset, 4, OldProt, &OldProt);
		}
	return 0;
	}  


	


btw, i need it to change more vals, but if i know how to do one, i can figure out the rest myself :P
Last edited on
I don't think I understand what this code is supposed to do. Can you walk me through it?

I did a little memory-manipulating experiments some months back. Here's something I wrote that you may find useful*:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
HANDLE getProcessHandle(char* name){
//Given a window name, returns the process handle of that window.
//If it fails, returns NULL.
 HWND hwnd = FindWindow(NULL, name);
 if (hwnd == NULL)
 {
  return NULL;
 }
 LPDWORD bar;
 GetWindowThreadProcessId(hwnd, bar);
 HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, *bar);
 if (processHandle == NULL){
  std::cout << "\ncouldn't get processHandle";
 }
 return processHandle;
}

WORD peek(HANDLE processHandle, unsigned long address){
//reads the value of the memory at the address.
 WORD memContents = 0;
 SIZE_T numberOfBytesRead;
 if(!ReadProcessMemory(processHandle, (LPVOID)address, &memContents, 1, &numberOfBytesRead)){
  return NULL;
 }
 return memContents;
}


bool poke(HANDLE processHandle, unsigned long address, char value){
//sets the value of the memory at the address.
 SIZE_T numberOfBytesWritten;
 if(!WriteProcessMemory(processHandle, (LPVOID)address, &value, 1, &numberOfBytesWritten)){return 0;}
 else{return 1;}
}


*all code provided AS IS without warranty. By using it, you agree that magicalblender is not responsible or liable for any death, dismemberment, or general misfortune that may arise as a result of this code.
Last edited on
This is madified version of your code: you can change whatever data in it
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <windows.h>
#include <iostream>
#include <fstream>
#include <string>

using namespace std;
#define  SIZE 100000
int haxvals[SIZE];

void ReadHax() 
{ 
	int linenum = 0; 
	string line; 

	ifstream myfile; 
	myfile.open("wthax.txt"); 

	if (myfile.is_open()) 
	{ 
		while (!myfile.eof()) 
		{ 
			getline (myfile, line); 

			if (atoi(line.c_str()) != 0) 
			{ 
				haxvals[linenum] = atoi(line.c_str()); 
			} 

			linenum+=1; 
		} 
		myfile.close(); 
	} 
}

DWORD WINAPI minerals( LPVOID lpParam  ); DWORD WINAPI minerals( LPVOID lpParam){DWORD OldProt;
int *offset = (int*)0x3427CC08;
while(true)
{
	while(!(GetAsyncKeyState(0x63))) Sleep(100);
	VirtualProtect(offset, 4, PAGE_EXECUTE_READWRITE, &OldProt);
	*offset = haxvals[0];
	VirtualProtect(offset, 4, OldProt, &OldProt);                                                                                
}
return 0;
}  


ok ty,
now i got it down to 1 error,
(43) : fatal error C1010: unexpected end of file while looking for precompiled header directive(last line..)
Topic archived. No new replies allowed.