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 


[Delphi] Get module name from ptr(address)

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

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Tue Mar 17, 2009 3:38 pm    Post subject: [Delphi] Get module name from ptr(address) Reply with quote

I have a RANDOM address in memory, with that address i want to be able to get the name of the module which it is into.

Is that possible and how? (i hope it will not be too complicated) Smile

Sorry for my bad english.

_________________

Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Tue Mar 17, 2009 4:06 pm    Post subject: Reply with quote

If there's no better way, you could always enumerate the modules of the process and check their address range to see if yours fits.

Code:

//C++:
//#include <windows.h>
//#include <tlhelp32.h>

BOOL FindModule( DWORD dwAddress, LPTSTR tszModuleName )
{
    HANDLE hSnapshot;
    MODULEENTRY32 me32;

    tszModuleName[ 0 ] = 0; //to make things easier to determine if we've succeeded or not
   
    hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, GetCurrentProcessId( ) );

    if( !hSnapshot )
        return FALSE;

    me32.dwSize = sizeof( MODULEENTRY32 );

    if( !Module32First( hSnapshot, &me32 )
        return FALSE;

    do {
        if( dwAddress >= ( DWORD )me32.modBaseAddr &&
            dwAddress <= ( ( DWORD )me32.modBaseAddr + me32.modBaseSize ) ) {
            _tcscpy( tszModuleName, me32.szModule );
            break;
        }
    } while( Module32Next( hSnapshot, &me32 ) );

    CloseHandle( hSnapshot );

    return( tszModuleName[ 0 ] == 0 );
}

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
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
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