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 


getModuleHandle()
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Sat Feb 13, 2010 1:28 am    Post subject: getModuleHandle() Reply with quote

is there a similar function but for a standalone .exe (or any other that will return the base address ), as far as i know i can only use this function if im injecting a DLL .

thanks.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25831
Location: The netherlands

PostPosted: Sat Feb 13, 2010 2:29 am    Post subject: Reply with quote

look up the apis : createtoolhelp32snapshot , module32first and module32next

or EnumProcessModules(Ex) combined with GetModuleFileNameEx

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Sat Feb 13, 2010 4:55 am    Post subject: Re: getModuleHandle() Reply with quote

rooski wrote:
as far as i know i can only use this function if im injecting a DLL.
GetModuleHandle(NULL); will return a handle to the file used to create the calling process (.exe file).
Back to top
View user's profile Send private message
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Sat Feb 13, 2010 1:33 pm    Post subject: Reply with quote

@jani

i still dont understand how that will help me , im trying to write a trainer that uses read/write process memory , so my app is in no way hooking / creating a thread in the target process.

all i need is the base address , there has to be a simpler way to get it Sad

thanks for helping out a newbie Smile .
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: Sat Feb 13, 2010 1:56 pm    Post subject: Reply with quote

rooski wrote:
@jani

i still dont understand how that will help me , im trying to write a trainer that uses read/write process memory , so my app is in no way hooking / creating a thread in the target process.

all i need is the base address , there has to be a simpler way to get it Sad

thanks for helping out a newbie Smile .


Dark Byte already posted the necessary APIs.

Look into those APIs, and this structure:

http://msdn.microsoft.com/en-us/library/ms684225%28VS.85%29.aspx
Back to top
View user's profile Send private message
igoticecream
Grandmaster Cheater Supreme
Reputation: 0

Joined: 23 Apr 2006
Posts: 1807
Location: 0x00400000

PostPosted: Sat Feb 13, 2010 4:01 pm    Post subject: Reply with quote

well, if your desire is use Read/WriteProcessMemory, you need the process handle, this can be found calling OpenProcess and of course you need the process ID, that can be found by window name (GetWindowThreadProcessId) or by process name (CreateToolhelp32Snapshot)

So:

CreateToolhelp32Snapshot/GetWindowThreadProcessId -> OpenProcess -> Read/WriteProcessMemory


hope this will be useful for you

_________________
+~
Back to top
View user's profile Send private message
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Sun Feb 14, 2010 2:15 am    Post subject: Reply with quote

ok so far with this code

Code:

void read();
{
                DWORD pid = 0;
   HANDLE hProcess = 0;
   HWND hProc;
                HANDLE hModuleSnap = INVALID_HANDLE_VALUE;

   hProc = FindWindow(NULL, L"world of warcraft retail");
   if(hProc)
   {
      GetWindowThreadProcessId(hProc, &pid);
    }
   
   hProcess = OpenProcess(PROCESS_VM_READ, 0, pid);
   
   
                MODULEENTRY32 me32;

                hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, pid );

                if( hModuleSnap == INVALID_HANDLE_VALUE )
                      {
                         cout<<"CreateToolhelp32Snapshot (of modules)"; 
                      }
 
                me32.dwSize = sizeof( MODULEENTRY32 );

                if( !Module32First( hModuleSnap, &me32 ) )
                       {
                         cout<<"Module32First"; 
                         CloseHandle( hModuleSnap );     
                       }

             do
               {
                 cout <<"\n\n     MODULE NAME:    "<< me32.szModule ;
                 cout << "\n     executable     = "<< me32.szExePath;
                 cout << "\n     process ID     = "<< me32.th32ProcessID ;
                 cout << "\n     ref count (g)  = "<< me32.GlblcntUsage ;
    cout << "\n     ref count (p)  = "<< me32.ProccntUsage ;
                 cout << "\n     base address   = "<< (DWORD) me32.modBaseAddr ;
                 cout << "\n     base size      = "<< me32.modBaseSize ;
 
                } while( Module32Next( hModuleSnap, &me32 ) );

   CloseHandle( hModuleSnap );
}


i get this , which isnt what i was hoping for , any ideas?



CEfo.jpg
 Description:
output pic
 Filesize:  65.54 KB
 Viewed:  15973 Time(s)

CEfo.jpg


Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25831
Location: The netherlands

PostPosted: Sun Feb 14, 2010 4:35 am    Post subject: Reply with quote

why isn't it what you are hoping for ?
base address looks exactly like the thing you want

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Sun Feb 14, 2010 4:41 am    Post subject: Reply with quote

Dark Byte wrote:
why isn't it what you are hoping for ?
base address looks exactly like the thing you want


Now i don't know anything, but isn't 0x1260000 a bit weird for the first module?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25831
Location: The netherlands

PostPosted: Sun Feb 14, 2010 5:02 am    Post subject: Reply with quote

not really, you can make the entry point almost any value you want, as long as it ends with 4 0's
also, it could be the console buffer is full and the first entries have been deleted (so won't even show when scrolling up)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Sun Feb 14, 2010 5:35 am    Post subject: Reply with quote

Dark Byte wrote:
not really, you can make the entry point almost any value you want, as long as it ends with 4 0's
also, it could be the console buffer is full and the first entries have been deleted (so won't even show when scrolling up)


I know it can be any address ending with 4 0's, but 1260000? never saw one that high. I like the second one with the console buffer better Razz, it sure is WoW, a lot of Modules!
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Sun Feb 14, 2010 10:41 am    Post subject: Reply with quote

rooski wrote:
i still dont understand how that will help me , im trying to write a trainer that uses read/write process memory , so my app is in no way hooking / creating a thread in the target process.
Ah, sorry, I understood that you thought that you can't call GetModuleHandle from an exe and that you'd need a DLL for it. Well, you got the answer.
Back to top
View user's profile Send private message
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Sun Feb 14, 2010 1:39 pm    Post subject: Reply with quote

this is kind of newbish of me , but how do i get a usable hex address from that dword one?

and how do i know which module is wow.exe since .szModule is supposed to give me the name but doesnt?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25831
Location: The netherlands

PostPosted: Sun Feb 14, 2010 1:52 pm    Post subject: Reply with quote

a dword is a hex, it's just a way of displaying it on the screen, you don't need to convert it

szModule is an array (char array)
arrays are usually pointers, so look at the memory that array points to (or just use one of the string routines to make it easier.)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
rooski
Master Cheater
Reputation: 0

Joined: 31 Oct 2007
Posts: 340
Location: Siberia

PostPosted: Sun Feb 14, 2010 2:16 pm    Post subject: Reply with quote

alright , that makes sense , and thank you all so much for the help.

EDIT_________________
for some reason when ever i run my program the process id and base address for the modules change , and what string routines can i use to get the name of the modules?

edit2________
printf() instead of cout , and i had to enable debug privileges to get it working .
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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