Unknown error

I'm not certain where the error is at the moment so I'll just post one at a time where I suspect the problem/s lie.
First the deepest part of the debugger type application.
1
2
#define SetRamX( m_Handle, m_Address, m_buff, m_Size ) WriteProcessMemory( m_Handle, ( void* )m_Address, m_buff, m_Size, NULL )
#define GetRamX( m_Handle, m_Address, m_buff, m_Size )  ReadProcessMemory( m_Handle, ( void* )m_Address, m_buff, m_Size, NULL ) 

With buffers it behaves fine but I'm not so sure about values used via the & operator. To be accurate I'm testing via PCSX2 because the recent editions have a fixed RAM location and I have some codes I've previously hacked with a less useful application.
I've already made sure the codes being loaded from file are being read correctly and my hooking function is reaching the usage of SetRamX so it has to have something to do with SetRamX or values being used because I've seen no sign of changes being made to the game that I'm testing on.
¿could you be a little more explicit about the error, please?

I recommend you to use a function instead of a macro
¿what does WriteProcessMemory() returns?
Here's part of a function using 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
void G::UseHook( xTreeID root, s32 endian, s8 cIndex, s8 cCount )
{
	HACK* hack   = mGetHack( root );
	if ( hack->use )
	{
		CODE code;
		u64  value;
		u64  hookStart;
		bool tBool;
		bool recurse = false;
		s8   v, vCount;
		u8   i, iCount;
		u64  address, fliped, ptr;
		s8   p, pCount;
		if ( cCount < 0 )
		{
			recurse = true;
			cCount = hack->GetCount();
		}
		for ( ; cIndex < cCount; ++cIndex )
		{
			code    = ( *hack )[ cIndex ];
			value   = code[ 0 ];
			hookStart = hookArray[ code.ram ];
			p       = 0;
			pCount  = code.ptrDepth;
			v       = 0;
			vCount  = code.loop;
			address = hookStart + code.byte;
			GetAddress( address, fliped, code.size, endian );
			ptr     = fliped;
			if ( hookApp )
			{
				for ( ; p < pCount; ++p )
				{
					fliped = ptr;
					GetRamX( appHandle, fliped, &ptr, 4u );
				}
			}
			else
			{
				for ( ; p < pCount; ++p )
				{
					fliped = ptr;
					bin_BF.Seek( fliped, wxFromStart );
					bin_BF.Read( &ptr, 4u );
				}
			}
			switch ( code.type )
			{
				case CT_WRITE:
					if ( hookApp )
					{
						do
						{
							SetRamX( appHandle, ptr, &value, code.size );
							ptr   += code.increment;
							value += code.slide;
							++v;
						} while ( v < vCount );
					}
					else
					{
						do {
							bin_BF.Seek(  ptr, wxFromStart  );
							bin_BF.Write( &value, code.size );
							ptr   += code.increment;
							value += code.slide;
							++v;
						} while ( v < vCount );
					}
					break;
				case CT_COPY:

Potentially there can be up to 10000 codes being used at once so the less function calls I have to make the better.
Last edited on
I have to go to a volunteer job so if anyone replies don't check back until 15:00 at least
You could inline the function.
Potentially there can be up to 10000 codes being used at once
small fish...


I don't understand your error description. ¿what do you expect, what is happenning, how are you measuring that?
For example one code is supposed to fill out key items in Final Fantasy 12 (UK) ( Incidentally I created a test code to prevent the corrupted save scenario ), This is not happening at the moment because something is wrong with the application's code.

As for it being small fish, not so much when each code can be looped up to 255 times, add to that the List codes that can have up to 255 values to write for each loop or the Copy codes that need to read the memory first and it becomes possible for the hacking to take longer than 500 Milliseconds which is the minimum wait between each call of UseHook( void ) which gets the hacking started.

I'm aiming to get this tool as fast as possible on single thread mode before I add threading capabilities, the reason for this is because this tool is to target old computers as well as modern.
¿What error is WriteProcessMemory() returning?
http://msdn.microsoft.com/en-us/library/windows/desktop/ms679351%28v=vs.85%29.aspx

Off-topic: ¿why do they use void main()?
It's not returning an error it's just that while the function is being used with the correct addresses I'm not seeing any results in PCSX2 when I should be, which is why I need help spotting what the error in my code is to make sure those results actually show up.
Inlining it worked, had to think for a bit because I couldn't remember how to take both references and pointers of any type via one variable.
Here's my code (from the relevant cpp file)
1
2
3
4
5
6
7
8
9
10
11
12
inline void GetRamX( uHandle fHandle, u64 fAddress, void* fBuffer, u32 fSize )
{
#ifdef WIN32
	ReadProcessMemory( fHandle, ( void* )fAddress, fBuffer, fSize, NULL );
#endif
}
inline void SetRamX( uHandle fHandle, u64 fAddress, void* fBuffer, u32 fSize )
{
#ifdef WIN32
	WriteProcessMemory( fHandle, ( void* )fAddress, fBuffer, fSize, NULL );
#endif
}
Topic archived. No new replies allowed.