Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Process Hanlde to hInstance

Posted on 2003-03-22
6
Medium Priority
?
1,517 Views
Last Modified: 2012-06-27
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?
0
Comment
Question by:JeFF
  • 3
  • 3
6 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 75 total points
ID: 8186868
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
 

Author Comment

by:JeFF
ID: 8188083
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
 
LVL 22

Expert Comment

by:nietod
ID: 8188235
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:JeFF
ID: 8189491
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
 
LVL 22

Expert Comment

by:nietod
ID: 8189590
The question is, what do you need the module handle for in the this analysis?   I don't understand that.
0
 

Author Comment

by:JeFF
ID: 8191391
i found it, thx anyway nietod
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question