>> { DWORD OldProt;
remove the '{' character.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>> void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len); {
remove the semicolon
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
that's what happens then you fix something :cheesy: look at the first eror message and try to find out why MemOffset is undefined. Where did you define it? It must be in one of two places: (1) a global variable, or (2) a variable declared inside the function in which its used.
Fix one error and it may solve several error messages.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
First you have this:
void WriteMem(DWORD MemOffset, DWORD DataPtr, DWORD dataLen) {
...
}
void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len); {
for(DWORD i = 0; i < len; i++)
WriteMem((DWORD)AddrToChange+i, (DWORD)To+i, 1);
}
and the recomendation was>> void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len); {
remove the semicolon
Now you have:
void WriteMem(DWORD MemOffset, DWORD DataPtr, DWORD dataLen); {
What changed in the line (and more importantly, why did it change?)
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
and first you have this:
void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len); {
for(DWORD i = 0; i < len; i++)
WriteMem((DWORD)AddrToChange+i, (DWORD)To+i, 1);
}
and now:
void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len);
for(DWORD i = 0; i < len; i++)
WriteMem((DWORD)AddrToChange+i, (DWORD)To+i, 1);
}
which are both wrong. Is this the implementation of the function or are your just trying to call it and is it part of something else?
regards Niek
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
ok, then you should remove the semicolon as Ancient Dragon allready said.
void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len)
{
for(DWORD i = 0; i < len; i++)
WriteMem((DWORD)AddrToChange+i, (DWORD)To+i, 1);
}
And in your other function too offcourse, as WaltP pointed out.
regards Niek
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
error C2065: 'godmode' : undeclared identifier
You are declaring "godmode" inside an if-statement, this means it won't be visible outside it. Just declare it at the beginning of the function.
regards Niek
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
You will see the problem immediately if you format your code better:
Put each { and } on separate lines
Every line between corresponding { }'s should be indented 3-4 SPACEs.
For example:
int function(int val)
{
int rtn, tmp;
if (val > 10)
{
tmp = val * 4;
rtn = tmp + val;
}
else
{
tmp = val * 6;
rtn = tmp - val;
}
return rtn;
}
Errors
--------------------Configuration: DLL - Win32 Debug--------------------
Compiling...
Main.cpp
error C2109: subscript requires array or pointer type
error C2065: 'godmode' : undeclared identifier
Error executing cl.exe.
Creating browse info file...
DLL.dll - 2 error(s), 0 warning(s)
Please let us know what lines these error are on. Just telling us the errors does not give us enough information (although I did find one -- this time)
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
just after bool bRet = true;
Where did you get this code anyway? Because I'm guessing you didn't write it youself? Be sure to read and understand WaltP's post because you'll encouter a lot more problems related to this...
regard Niek
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
int function(int val)
{
int rtn;
if (val > 10)
{
int tmp = val * 4;
rtn = tmp + val;
}
else
{
tmp = val * 6;
rtn = tmp - val;
}
return rtn;
}
In this version of WaltPs example rtn is visible/available throughout the function whereas tmp is only visible/available in the body of the if and is not visible/available in the body of the else. This is what's happening in the code you posted.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
The function is reduced to this:
int function(int val)
{
return (val * 5);
}
why? because of the associative (?) properties of mathametics
val * 4 + val
is the same as
val + val + val + val + val; // there are 5 vals on this line
val * 6 - val;
is the same as this
val + val + val + val + val + val - val;
which is
val + val + val + val + val; // there are also 5 vals on this line
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Guys, I was showing formatting techniques to aid the poster. Multiple posts explaning the code is not helpful in understanding the formatting:
You will see the problem immediately if you format your code better:
Put each { and } on separate lines
Every line between corresponding { }'s should be indented 3-4 SPACEs.
For example:...
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944