Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] Help find adress api

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Danielb
Cheater
Reputation: 0

Joined: 22 Jul 2007
Posts: 30

PostPosted: Wed Feb 25, 2009 7:58 pm    Post subject: [C++] Help find adress api Reply with quote

I need to find the address of "WriteProcessMemory" then with the help of a friend made the following program that is full of errors. Help fix please!

Code:

#include <tchar.h>

DWORD ADRESS = NULL;

int _tmain(int argc, TCHAR *argv[])
{
_ADRESS = (DWORD)GetProcAddress(LoadLibrary(_T("KERNEL32.dll")), "WriteProcessMemory") + 5;
if (_ADRESS == 5)
{
_tprintf(_T("Erro no Progama."));
return 0;
}
else
{
_tprintf(_T("WriteProcessMemory: 0x%08X"), _ADRESS;
}
return 0;
}



Sorry for my English. I am Brazilian Razz
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Wed Feb 25, 2009 8:03 pm    Post subject: Reply with quote

Get Cheatengine.
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Wed Feb 25, 2009 9:01 pm    Post subject: Reply with quote

Code:

#include <windows.h>

DWORD ADDRESS = NULL;

int main(int argc, TCHAR *argv[])
{
ADDRESS = (DWORD)GetProcAddress(LoadLibrary"KERNEL32.dll"), "WriteProcessMemory") + 5;
if (ADDRESS == 5)
{
      return 0;
}
else
{
   printf(("WriteProcessMemory: 0x%08X"),ADDRESS);
   return 1;
}
return 0;
}

regards BanMe
Back to top
View user's profile Send private message MSN Messenger
Danielb
Cheater
Reputation: 0

Joined: 22 Jul 2007
Posts: 30

PostPosted: Wed Feb 25, 2009 9:08 pm    Post subject: Reply with quote

BanMe wrote:
Code:

#include <windows.h>

DWORD ADDRESS = NULL;

int main(int argc, TCHAR *argv[])
{
ADDRESS = (DWORD)GetProcAddress(LoadLibrary"KERNEL32.dll"), "WriteProcessMemory") + 5;
if (ADDRESS == 5)
{
      return 0;
}
else
{
   printf(("WriteProcessMemory: 0x%08X"),ADDRESS);
   return 1;
}
return 0;
}

regards BanMe


Errors:

4 C:\Dev-Cpp\main.cpp [Warning] converting to non-pointer type `DWORD' from NULL

C:\Dev-Cpp\main.cpp In function `int main(int, TCHAR**)':

8 C:\Dev-Cpp\main.cpp cannot convert `HINSTANCE__*(*)(const CHAR*)' to `HINSTANCE__*' for argument `1' to `int (* GetProcAddress(HINSTANCE__*, const CHAR*))()'

8 C:\Dev-Cpp\main.cpp expected primary-expression before ')' token

8 C:\Dev-Cpp\main.cpp expected `;' before "GetProcAddress"

15 C:\Dev-Cpp\main.cpp `printf' undeclared (first use this function)

(Each undeclared identifier is reported only once for each function it appears in.)

C:\Dev-Cpp\Makefile.win [Build Error] [main.o] Error 1

Crying or Very sad
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Wed Feb 25, 2009 9:19 pm    Post subject: Reply with quote

BanMe wrote:
Code:

#include <windows.h>

DWORD ADDRESS = NULL;

int main(int argc, TCHAR *argv[])
{
ADDRESS = (DWORD)GetProcAddress(LoadLibrary"KERNEL32.dll"), "WriteProcessMemory") + 5;
if (ADDRESS == 5)
{
      return 0;
}
else
{
   printf(("WriteProcessMemory: 0x%08X"),ADDRESS);
   return 1;
}
return 0;
}

regards BanMe


Errors:

4 C:\Dev-Cpp\main.cpp [Warning] converting to non-pointer type `DWORD' from NULL

C:\Dev-Cpp\main.cpp In function `int main(int, TCHAR**)':

8 C:\Dev-Cpp\main.cpp cannot convert `HINSTANCE__*(*)(const CHAR*)' to `HINSTANCE__*' for argument `1' to `int (* GetProcAddress(HINSTANCE__*, const CHAR*))()'

8 C:\Dev-Cpp\main.cpp expected primary-expression before ')' token

8 C:\Dev-Cpp\main.cpp expected `;' before "GetProcAddress"

15 C:\Dev-Cpp\main.cpp `printf' undeclared (first use this function)

(Each undeclared identifier is reported only once for each function it appears in.)

C:\Dev-Cpp\Makefile.win [Build Error] [main.o] Error 1

Code:

#include <windows.h>

DWORD ADDRESS = NULL;

int main(int argc, TCHAR *argv[])
{
ADDRESS = (DWORD)GetProcAddress(LoadLibrary("KERNEL32.dll"), "WriteProcessMemory") + 5;
if (ADDRESS == 5)
{
      return 0;
}
else
{
   printf(("WriteProcessMemory: 0x%08X"),ADDRESS);
   return 1;
}
return 0;
}


he was missing a parenthase.
Back to top
View user's profile Send private message
Danielb
Cheater
Reputation: 0

Joined: 22 Jul 2007
Posts: 30

PostPosted: Wed Feb 25, 2009 9:26 pm    Post subject: Reply with quote

smartz993 wrote:
BanMe wrote:
Code:

#include <windows.h>

DWORD ADDRESS = NULL;

int main(int argc, TCHAR *argv[])
{
ADDRESS = (DWORD)GetProcAddress(LoadLibrary"KERNEL32.dll"), "WriteProcessMemory") + 5;
if (ADDRESS == 5)
{
      return 0;
}
else
{
   printf(("WriteProcessMemory: 0x%08X"),ADDRESS);
   return 1;
}
return 0;
}

regards BanMe


Errors:

4 C:\Dev-Cpp\main.cpp [Warning] converting to non-pointer type `DWORD' from NULL

C:\Dev-Cpp\main.cpp In function `int main(int, TCHAR**)':

8 C:\Dev-Cpp\main.cpp cannot convert `HINSTANCE__*(*)(const CHAR*)' to `HINSTANCE__*' for argument `1' to `int (* GetProcAddress(HINSTANCE__*, const CHAR*))()'

8 C:\Dev-Cpp\main.cpp expected primary-expression before ')' token

8 C:\Dev-Cpp\main.cpp expected `;' before "GetProcAddress"

15 C:\Dev-Cpp\main.cpp `printf' undeclared (first use this function)

(Each undeclared identifier is reported only once for each function it appears in.)

C:\Dev-Cpp\Makefile.win [Build Error] [main.o] Error 1

Code:

#include <windows.h>

DWORD ADDRESS = NULL;

int main(int argc, TCHAR *argv[])
{
ADDRESS = (DWORD)GetProcAddress(LoadLibrary("KERNEL32.dll"), "WriteProcessMemory") + 5;
if (ADDRESS == 5)
{
      return 0;
}
else
{
   printf(("WriteProcessMemory: 0x%08X"),ADDRESS);
   return 1;
}
return 0;
}


he was missing a parenthase.



Thanks, decreased the amount of error. Still have some more:
3 C:\Dev-Cpp\Untitled2.cpp [Warning] converting to non-pointer type `DWORD' from NULL

C:\Dev-Cpp\Untitled2.cpp In function `int main(int, TCHAR**)':

14 C:\Dev-Cpp\Untitled2.cpp `printf' undeclared (first use this function)

(Each undeclared identifier is reported only once for each function it appears in.)

17 C:\Dev-Cpp\Untitled2.cpp expected `}' at end of input
Back to top
View user's profile Send private message
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Wed Feb 25, 2009 9:28 pm    Post subject: Reply with quote

Here's a better suggestion. Stop using DEV-C++. MingW is old.
_________________
Back to top
View user's profile Send private message
Danielb
Cheater
Reputation: 0

Joined: 22 Jul 2007
Posts: 30

PostPosted: Wed Feb 25, 2009 9:30 pm    Post subject: Reply with quote

sponge wrote:
Here's a better suggestion. Stop using DEV-C++. MingW is old.


I tried to install Visual C + + was no more problem to connect. Can you recommend any other?
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Wed Feb 25, 2009 9:32 pm    Post subject: Reply with quote

I agrees with sponge Very Happy
and damn man im sorry.. ;p I don always code perfect using this posting mechanism ;{ pls excuse minor mistakes Very Happy
Back to top
View user's profile Send private message MSN Messenger
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Wed Feb 25, 2009 9:41 pm    Post subject: Reply with quote

Urhm... why are you guys adding 5 bytes... He just wants the address...
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Thu Feb 26, 2009 2:19 pm    Post subject: Reply with quote

You're missing some header files.

Code:

#include <windows.h>
#include <stdio.h>
#include <tchar.h>
Back to top
View user's profile Send private message
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Fri Feb 27, 2009 4:15 am    Post subject: Reply with quote

Like Irwin demonstrated, there is no need to call LoadLibrary if you need the address of WriteProcessMemory in your own address space.
(considering you included windows.h)
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites