Solved

Find mutex owner

Posted on 2008-10-07
9
1,579 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
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 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
Downloading email attachments 2 85
How to convert memory stream to PDF file 6 183
CheckListBox usage 3 81
shape, triangle, dbctrlgrid 3 33
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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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