Solved Address to Module BaseName

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Freak

Newbie
Full Member
Jan 17, 2013
7
174
0
Hellow guyz!

I need some help

i have the address 0x12345678

And i dont know what module name from this address, so i need a function to convert it to something like
(modulename + 0x45678) same as CE does and put it in a messagebox.


ex.
0x12345678 => engine.dll + 0x45678

thanks
 
Last edited:

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
https://stackoverflow.com/questions/6734095/how-to-get-module-handle-from-func-ptr-in-win32

If you take a look at the response of "Arty", he uses this:

C++:
HMODULE hmodule = NULL;
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, reinterpret_cast<LPCTSTR>(address), &hmodule);
To get a HMODULE having the address..


Not too sure whether that works or not it's just that he got many ratings up so I guess it does.. If that works use

DWORD WINAPI GetModuleFileName(
_In_opt_ HMODULE hModule,
_Out_ LPTSTR lpFilename,
_In_ DWORD nSize
);

to get the name of the module (path)

(https://msdn.microsoft.com/en-us/library/windows/desktop/ms683197(v=vs.85).aspx)
 

squeenie

Hacker
Meme Tier VIP
Dank Tier Donator
Mar 6, 2013
677
5,478
37
Use moduleinformation to check the base of the dll plus the size and see if your address is within its boundaries
 

Freak

Newbie
Full Member
Jan 17, 2013
7
174
0
Use moduleinformation to check the base of the dll plus the size and see if your address is within its boundaries
i know this one,

I made a function to get the modulesize of all modules of process, and just check if my address is > or < of modulesize to return the module name, but i think which have some more easy way to do it.
Can you do it?
 
Last edited:

squeenie

Hacker
Meme Tier VIP
Dank Tier Donator
Mar 6, 2013
677
5,478
37
i know this one,

I made a function to get the modulesize of all modules of process, and just check if my address is > or < of modulesize to return the module name, but i think which have some more easy way to do it.
Can you do it?
That's the best I can think of right now. Why don't you just use that?
 

Freak

Newbie
Full Member
Jan 17, 2013
7
174
0
That's the best I can think of right now. Why don't you just use that?
Thanks for help,
Im using works not bad, i wrote the function by myself and i not sure if this is really best way to do it, maybe there would be an easier way to get it.
 

x86asm

Jr.Coder
Full Member
Nobleman
Jan 3, 2013
53
438
0
Hello, you take also my function.


C++:
unsigned GetDllBaseAddress( string DllName, int ProcessId )
{
HANDLE snap;
MODULEENTRY32 lppe;
lppe.dwSize = sizeof(MODULEENTRY32);


		snap =  CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, ProcessId );

		if ( snap == INVALID_HANDLE_VALUE )
		{
			cout<< "CreateToolhelp32Snapshot error: " << GetLastError()<<"\n";
			system("PAUSE");
			return 0;
		}

		Module32First(  snap, &lppe );
		do
		{
			if ( !strcmp( lppe.szModule, DllName.c_str() ) )
			{
				//cout<<lppe.szModule<< "     "<<hex<<lppe.hModule<<"\n";
				return unsigned(lppe.hModule);
			}
	   }
	   while ( Module32Next ( snap , &lppe ) == 1 ) ;

return 0;
}




int GetProcessIdByName ( string ProcessName )
{
HANDLE h = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS,0);

PROCESSENTRY32 lppe;
lppe.dwSize = sizeof(PROCESSENTRY32);

	Process32First( h, &lppe );
	do
	{
		if ( strcmp(lppe.szExeFile,ProcessName.c_str()) == false )
		{
			return lppe.th32ProcessID;
		}
	}
	while ( Process32Next (h, &lppe) == true );

return -1;
}
 

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
Hello, you take also my function.


C++:
unsigned GetDllBaseAddress( string DllName, int ProcessId )
{
HANDLE snap;
MODULEENTRY32 lppe;
lppe.dwSize = sizeof(MODULEENTRY32);


		snap =  CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, ProcessId );

		if ( snap == INVALID_HANDLE_VALUE )
		{
			cout<< "CreateToolhelp32Snapshot error: " << GetLastError()<<"\n";
			system("PAUSE");
			return 0;
		}

		Module32First(  snap, &lppe );
		do
		{
			if ( !strcmp( lppe.szModule, DllName.c_str() ) )
			{
				//cout<<lppe.szModule<< "     "<<hex<<lppe.hModule<<"\n";
				return unsigned(lppe.hModule);
			}
	   }
	   while ( Module32Next ( snap , &lppe ) == 1 ) ;

return 0;
}




int GetProcessIdByName ( string ProcessName )
{
HANDLE h = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS,0);

PROCESSENTRY32 lppe;
lppe.dwSize = sizeof(PROCESSENTRY32);

	Process32First( h, &lppe );
	do
	{
		if ( strcmp(lppe.szExeFile,ProcessName.c_str()) == false )
		{
			return lppe.th32ProcessID;
		}
	}
	while ( Process32Next (h, &lppe) == true );

return -1;
}
He wants to get the module handle which covers a certain address not vice-versa.
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods