Avatar of RafaelK
RafaelK

asked on 

C++ - How to I get the base address of a process (.exe)

I want to use ReadProcessMemory. It needs the "base address" as a second parameter. I have the process handle. How to I get the base address (HMODULE)?

I have tried calling VirtualQueryEx with the second parameter set to NULL. It returns 28 (is successful), but the information in the struct is garbage. The base address is always 0. I have tried EnumProcessModules but it only gives the DLLs that that application has loaded.

I want to obtain the address from within my program.

CVisual C++.NETWindows Vista

Avatar of undefined
Last Comment
RafaelK
Avatar of Gideon7
Gideon7
Flag of United States of America image

Call GetModuleHandle(NULL).  It returns the HMODULE (load address) of the EXE.  See http://msdn.microsoft.com/en-us/library/ms683199.aspx
Avatar of RafaelK
RafaelK

ASKER

That will not work. I want to get the base address of another process. Not my own base address.

So i have another application running, e.g. "calc.exe". I want to obtain its base address, not my own.
ASKER CERTIFIED SOLUTION
Avatar of Gideon7
Gideon7
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of RafaelK
RafaelK

ASKER

Sweet, thank you very much :)
C
C

C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, so it has found lasting use in applications that had formerly been coded in assembly language, including operating systems as well as various application software for computers ranging from supercomputers to embedded systems. It is distinct from C++ (which has its roots in C) and C#, and many later languages have borrowed directly or indirectly from C.

23K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo