?
Solved

Find mutex owner

Posted on 2008-10-07
9
Medium Priority
?
1,629 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
[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
  • 2
9 Comments
 
LVL 28

Expert Comment

by:2266180
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 46

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
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!

 
LVL 28

Accepted Solution

by:
2266180 earned 1500 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 46

Expert Comment

by:aikimark
ID: 23834840
@DSOM

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

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

800 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