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
Solved

Find mutex owner

Posted on 2008-10-07
9
1,564 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: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 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 28

Accepted Solution

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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