944,137 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3482
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Nov 15th, 2006
0

C++ A Few Errors

Expand Post »
When i compile this code i get a few errors (i guess are simple for you guys)

C++ Syntax (Toggle Plain Text)
  1. void WriteMem(DWORD MemOffset, DWORD DataPtr, DWORD dataLen) {
  2. { DWORD OldProt;
  3. VirtualProtect((void*) MemOffset, dataLen, PAGE_EXECUTE_READWRITE, &OldProt);
  4. RtlMoveMemory((void*) MemOffset, (const void*) DataPtr, dataLen);
  5. VirtualProtect((void*) MemOffset, dataLen, OldProt, &OldProt);
  6. }
  7. void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len); {
  8. for(DWORD i = 0; i < len; i++)
  9. WriteMem((DWORD)AddrToChange+i, (DWORD)To+i, 1);
  10. }

Errors
C++ Syntax (Toggle Plain Text)
  1.  
  2. --------------------Configuration: DLL - Win32 Debug--------------------
  3. Compiling...
  4. Main.cpp
  5. error C2601: 'WriteMem' : local function definitions are illegal
  6. error C2601: 'Initialize' : local function definitions are illegal
  7. error C2601: 'Shutdown' : local function definitions are illegal
  8. error C2601: 'DllMain' : local function definitions are illegal
  9. fatal error C1004: unexpected end of file found
  10. Error executing cl.exe.
  11. DLL.dll - 5 error(s), 0 warning(s)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Gunner54 is offline Offline
37 posts
since Aug 2006
Nov 15th, 2006
0

Re: C++ A Few Errors

>> { DWORD OldProt;

remove the '{' character.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Nov 15th, 2006
0

Re: C++ A Few Errors

LOL im so dumb not to see that! i must be blind but... now i have these

C++ Syntax (Toggle Plain Text)
  1.  
  2. --------------------Configuration: DLL - Win32 Debug--------------------
  3. Compiling...
  4. Main.cpp
  5. error C2601: 'WriteMem' : local function definitions are illegal
  6. error C2065: 'len' : undeclared identifier
  7. warning C4018: '<' : signed/unsigned mismatch
  8. error C2065: 'AddrToChange' : undeclared identifier
  9. error C2065: 'To' : undeclared identifier
  10. Error executing cl.exe.
  11. DLL.dll - 4 error(s), 1 warning(s)
Reputation Points: 10
Solved Threads: 0
Light Poster
Gunner54 is offline Offline
37 posts
since Aug 2006
Nov 15th, 2006
0

Re: C++ A Few Errors

>> void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len); {

remove the semicolon
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Nov 15th, 2006
0

Re: C++ A Few Errors

Now i have like the most errors ever.

C++ Syntax (Toggle Plain Text)
  1.  
  2. --------------------Configuration: DLL - Win32 Debug--------------------
  3. Compiling...
  4. Main.cpp
  5. error C2065: 'MemOffset' : undeclared identifier
  6. error C2065: 'dataLen' : undeclared identifier
  7. error C2065: 'DataPtr' : undeclared identifier
  8. error C2065: 'len' : undeclared identifier
  9. warning C4018: '<' : signed/unsigned mismatch
  10. error C2065: 'AddrToChange' : undeclared identifier
  11. error C2065: 'To' : undeclared identifier
  12. error C2143: syntax error : missing ';' before 'else'
  13. error C2143: syntax error : missing ';' before '{'
  14. error C2447: missing function header (old-style formal list?)
  15. error C2143: syntax error : missing ';' before 'else'
  16. error C2143: syntax error : missing ';' before '{'
  17. error C2447: missing function header (old-style formal list?)
  18. error C2143: syntax error : missing ';' before 'else'
  19. error C2143: syntax error : missing ';' before '{'
  20. error C2447: missing function header (old-style formal list?)
  21. error C2143: syntax error : missing ';' before 'else'
  22. error C2143: syntax error : missing ';' before '{'
  23. error C2447: missing function header (old-style formal list?)
  24. error C2143: syntax error : missing ';' before 'else'
  25. error C2143: syntax error : missing ';' before '{'
  26. error C2447: missing function header (old-style formal list?)
  27. error C2143: syntax error : missing ';' before 'else'
  28. error C2143: syntax error : missing ';' before '.'
  29. error C2501: 'ZChat__InputDet' : missing storage-class or type specifiers
  30. error C2371: 'ZChat__InputDet' : redefinition; different basic types
  31. see declaration of 'ZChat__InputDet'
  32. error C2143: syntax error : missing ';' before '.'
  33. error C2143: syntax error : missing ';' before 'return'
  34. error C2143: syntax error : missing ';' before '}'
  35. error C2143: syntax error : missing ';' before '}'
  36. error C2143: syntax error : missing ';' before '}'
  37. error C2143: syntax error : missing ';' before '{'
  38. error C2447: missing function header (old-style formal list?)
  39. error C2065: 'Initialize' : undeclared identifier
  40. Error executing cl.exe.
  41. DLL.dll - 33 error(s), 1 warning(s)


My Code


C++ Syntax (Toggle Plain Text)
  1.  
  2. void WriteMem(DWORD MemOffset, DWORD DataPtr, DWORD dataLen); {
  3. DWORD OldProt;
  4. VirtualProtect((void*) MemOffset, dataLen, PAGE_EXECUTE_READWRITE, &OldProt);
  5. RtlMoveMemory((void*) MemOffset, (const void*) DataPtr, dataLen);
  6. VirtualProtect((void*) MemOffset, dataLen, OldProt, &OldProt);
  7. }
  8. void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len);
  9. for(DWORD i = 0; i < len; i++)
  10. WriteMem((DWORD)AddrToChange+i, (DWORD)To+i, 1);
  11. }
Reputation Points: 10
Solved Threads: 0
Light Poster
Gunner54 is offline Offline
37 posts
since Aug 2006
Nov 15th, 2006
0

Re: C++ A Few Errors

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Nov 16th, 2006
0

Re: C++ A Few Errors

First you have this:
C++ Syntax (Toggle Plain Text)
  1. void WriteMem(DWORD MemOffset, DWORD DataPtr, DWORD dataLen) {
  2. ...
  3. }
  4. void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len); {
  5. for(DWORD i = 0; i < len; i++)
  6. WriteMem((DWORD)AddrToChange+i, (DWORD)To+i, 1);
  7. }
and the recomendation was
>> void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len); {
remove the semicolon
Now you have:
C++ Syntax (Toggle Plain Text)
  1.  
  2. void WriteMem(DWORD MemOffset, DWORD DataPtr, DWORD dataLen); {

What changed in the line (and more importantly, why did it change?)
Moderator
Reputation Points: 3281
Solved Threads: 895
Posting Sage
WaltP is offline Offline
7,749 posts
since May 2006
Nov 16th, 2006
0

Re: C++ A Few Errors

and first you have this:

C++ Syntax (Toggle Plain Text)
  1.  
  2. void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len); {
  3. for(DWORD i = 0; i < len; i++)
  4. WriteMem((DWORD)AddrToChange+i, (DWORD)To+i, 1);
  5. }
and now:
C++ Syntax (Toggle Plain Text)
  1.  
  2. void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len);
  3. for(DWORD i = 0; i < len; i++)
  4. WriteMem((DWORD)AddrToChange+i, (DWORD)To+i, 1);
  5. }
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
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Nov 16th, 2006
0

Re: C++ A Few Errors

im trying to make the EnableHack function (its so i can edit a processes memory)
Reputation Points: 10
Solved Threads: 0
Light Poster
Gunner54 is offline Offline
37 posts
since Aug 2006
Nov 16th, 2006
0

Re: C++ A Few Errors

ok, then you should remove the semicolon as Ancient Dragon allready said.


C++ Syntax (Toggle Plain Text)
  1.  
  2. void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len)
  3. {
  4. for(DWORD i = 0; i < len; i++)
  5. WriteMem((DWORD)AddrToChange+i, (DWORD)To+i, 1);
  6. }

And in your other function too offcourse, as WaltP pointed out.

regards Niek
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: please help me with this error
Next Thread in C++ Forum Timeline: Help Me Solve My Infinite Loop





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC