C++ A Few Errors

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2006
Posts: 37
Reputation: Gunner54 is an unknown quantity at this point 
Solved Threads: 0
Gunner54 Gunner54 is offline Offline
Light Poster

C++ A Few Errors

 
0
  #1
Nov 15th, 2006
When i compile this code i get a few errors (i guess are simple for you guys)

  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
  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)
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,462
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1476
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: C++ A Few Errors

 
0
  #2
Nov 15th, 2006
>> { DWORD OldProt;

remove the '{' character.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 37
Reputation: Gunner54 is an unknown quantity at this point 
Solved Threads: 0
Gunner54 Gunner54 is offline Offline
Light Poster

Re: C++ A Few Errors

 
0
  #3
Nov 15th, 2006
LOL im so dumb not to see that! i must be blind but... now i have these

  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)
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,462
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1476
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: C++ A Few Errors

 
0
  #4
Nov 15th, 2006
>> void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len); {

remove the semicolon
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 37
Reputation: Gunner54 is an unknown quantity at this point 
Solved Threads: 0
Gunner54 Gunner54 is offline Offline
Light Poster

Re: C++ A Few Errors

 
0
  #5
Nov 15th, 2006
Now i have like the most errors ever.

  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


  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. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,462
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1476
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: C++ A Few Errors

 
0
  #6
Nov 15th, 2006
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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: C++ A Few Errors

 
0
  #7
Nov 16th, 2006
First you have this:
  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
Originally Posted by Ancient Dragon View Post
>> void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len); {
remove the semicolon
Now you have:
  1.  
  2. void WriteMem(DWORD MemOffset, DWORD DataPtr, DWORD dataLen); {

What changed in the line (and more importantly, why did it change?)
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,897
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 302
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: C++ A Few Errors

 
0
  #8
Nov 16th, 2006
and first you have this:

  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:
  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
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 37
Reputation: Gunner54 is an unknown quantity at this point 
Solved Threads: 0
Gunner54 Gunner54 is offline Offline
Light Poster

Re: C++ A Few Errors

 
0
  #9
Nov 16th, 2006
im trying to make the EnableHack function (its so i can edit a processes memory)
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,897
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 302
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: C++ A Few Errors

 
0
  #10
Nov 16th, 2006
ok, then you should remove the semicolon as Ancient Dragon allready said.


  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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC