Process Hanlde to hInstance

Is there a way to get the hInstance of a process when u only have a handle to that process
or the PID of the process?
JeFFAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nietodCommented:
yes and No.

hinstances are sort of meaningless.  In win32, almost every process has the exact same hinstance.  the hinstance is the load address of the process's executable in the process's virtual memory space.  Almost all processes use the exact same address, so almost all processes have the same hinstance.    

So you probalby know the hinstance for every process in the system.  but that doesn't help you at all.  a hinstance is a pseudo handle and it only "makes sense" within the process that is running.  i.e.   and API procedure that uses an hinstance parameter assumes that the hinstance for the current process.  There is no way to tell the procedure to work with a different process.  The hinstance value itself can't tell the API function that, since, as I said, all processes usually have the same hinstance.

So the answer is yes, but it doesn't help you to accomplish anything at all.  

so the next question is, what is that you want to do?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JeFFAuthor Commented:
Well, what i need is the base address of a process for analyzing the PE structure. I use NtQuerySystemInformation for getting all the running processes.
0
nietodCommented:
I don't get that.  What do you need the base address for?  That doesn't seem like that could be of any value.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

JeFFAuthor Commented:
Well i use GetModuleHandle(NULL) to start analyse the PE structure of the process itself. Now i wanna analyze the PE structures of all running processes and i got no clue how to do this.
0
nietodCommented:
The question is, what do you need the module handle for in the this analysis?   I don't understand that.
0
JeFFAuthor Commented:
i found it, thx anyway nietod
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.