Solved

Find mutex owner

Posted on 2008-10-07
9
1,529 Views
Last Modified: 2009-03-24
How can I find the owner of a mutex?  I have a list of mutex names and I want to find the PID/Handle of the mutex owner.  I get ACCESS DENIED when I try to open a mutex or create a new handle to a mutex.

I am running as administrator on XP SP3, with debug privs.
0
Comment
Question by:DSOM
  • 3
  • 2
9 Comments
 
LVL 28

Expert Comment

by:ciuly
ID: 22663447
I couldn't find any usable delphi code. however, here is a C++ one that is supposed to work: http://www.experts-exchange.com/Programming/Languages/CPP/Q_20073497.html
another idea, since a mutex handle is jsut another handle, would be to find the thereadid of the creator/owner of that handle. meaning enumerating handles and comparing them with what you have and then checking the owner.
I *think* you can use the enumMetaFile api function. wilson has some nice units that he says doe the job: http://www.wilsonc.demon.co.uk/d7ntutils.htm
0
 
LVL 45

Expert Comment

by:aikimark
ID: 22678315
I think this might be what you are looking for:
http://www.swissdelphicenter.ch/torry/showcode.php?id=2126

There seems to be something wrong with the page this morning, so you can see it in Google's cache:
http://74.125.45.104/search?q=cache:yJIG_4oX8yEJ:www.swissdelphicenter.ch/torry/showcode.php%3Fid%3D2126+Mutex+handle+delphi&hl=en&ct=clnk&cd=31&gl=us
0
 

Author Comment

by:DSOM
ID: 22689482
That doesn't help in this situation.  I have a list of active Mutex and I want to get a handle to each one, not a new handle, but the handle of the original creator of the Mutex so I can map it to a process.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 28

Accepted Solution

by:
ciuly earned 500 total points
ID: 22799252
I tested the code from wilson, doesn't work right.
I did a little digging around and found a PAQ qith a solution from ThievingSix (http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_23535337.html) leading to his blog post:
http://w-shadow.com/blog/2006/10/19/listing-all-open-handles/
tested, works. you will notice it prints out all handles with their name and, what you need, owning PID.

I vbelieve starting from there is pretty easy to adapt the code to your needs :)
0
 
LVL 45

Expert Comment

by:aikimark
ID: 23834840
@DSOM

Did you follow the 10/24/08 link posted by ciuly and evaluate the code?
0
 
LVL 45

Expert Comment

by:aikimark
ID: 23891579
I recommend ciuly comment http:#a22799252 be accepted with no points refunded if we don't hear from DSOM.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now