?
Solved

Process Hanlde to hInstance

Posted on 2003-03-22
6
Medium Priority
?
1,509 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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

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!

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

771 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