-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ER: Ask user about disabling exclusive locking if we can't lock the drive #773
Comments
Mmm, this is more tricky than it looks. Or at least, I think Windows is using a different method than trying to lock the drive and seeing if it fails before producing that message. The message itself is generated from By the way, MUI Dialog ID |
Looking further into this, it doesn't look like The only way I'm seeing to actually achieve what we want is to go over ALL processes, and replicate the code that Process Explorer uses to list the files opened by each process, as it's the only application I know of that is able to list physical drives (for instance, it'll list Yay, more reverse engineering for me! At any rate, this isn't something I'm going to look into for the 2.12 timeframe. |
Well, since the source for Process Explorer is not available, but the good people of Process Hacker are offering what looks like a powerful GPLv3 equivalent, I've been trying to see if I could reuse some of their code (though I'm not entirely sure about the idea of having to embed 32+64 bit Windows driver binaries in Rufus to be able to perform handle lookup)... Only issue however is that the latest Process Hacker release does not seem to be able to list disk/volume handles. Damn! Logged issue winsiderss/systeminformer#131 to try to get some input on that... |
Looks like I wasn't looking at the right place, which is good news! It also appears that the kernel driver is not needed when looking for handles in PH, so I might be able to craft a handle lookup based of that code and integrate it into Rufus. Other nice thing about PH is that it can also tell whether the handle is opened for read/write, which may come handy... |
* Using functionality from Process Hacker: https://github.com/processhacker2/processhacker2/ * Part of the #773 enhancement * Also fix minor MinGW and WDK warnings
It's possible HxD is using a custom driver that bypasses Windows... Unmounting and formatting the disk should still succeed since Windows won't know about those handles (and it's not your problem if other software is bypassing Windows and breaking stuff - that's their problem 😄).
Explorer uses NtQueryInformationFile with the FileProcessIdsUsingFileInformation class. Try using this function instead of the handle enumeration code from Process Hacker:
You can use this function to identify which processes have open handles to the file, volume or disk.
Note: The above code also works from standard user accounts that do not have administrative privileges 😃 |
Nah. Accessing the disk doesn't require a driver (I'm doing that all the time in Rufus), especially as HxD requires Admin privileges to be able to do so. The most logical explanation is that Microsoft is simply checking against the volumes and not the disks, so they don't see all of the processes that may be accessing the device.
That's a great tip. Many thanks for that! As you probably guessed, I'm not familiar with the |
Something like this might also help 👍
|
Okay, I played with your code, and it seems to work just fine. Got no issue identifying processes like HxD accessing the disks/volumes (or even Rufus, when it turned out I forgot to close the handle I had opened for the search). The only real issue I have with it, which doesn't have anything to do with the code is: Part of the reason I need a process search is to figure out which process(es) might be preventing Rufus' This is also the reason why I don't think I'll apply the Granted, the only reason the I have still integrated your alternate search suggestion, as unused code, since it does work. Depending on the feedback I get with regards to the process search, I may switch to using this new method in a future version. |
* As suggested in #773 * Don't switch to using this method though, as it requires a handle to the disk or volume to be obtained, and we use the process search in case there is an issue doing so.
Moving the remainder of this ER (adding a UI report that lists the drive handle-hogging processes + running a sanity check to prompt the user to disable drive locking) to a future release. Will see how the 2.15 log-only report of conflicting processes goes, and take it from there. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query. |
If you have a DOS prompt open on a drive that you are attempting to format, the Windows 10 default formatting tool will ask the following:
![formatting_e_with_a_dos_prompt_open_windows_default](https://cloud.githubusercontent.com/assets/1206968/15929506/4c8d832e-2e45-11e6-92e2-6f22d4364088.png)
I suspect they attempt to exclusively lock the drive, find that it fails, and, if the user answers 'Yes', try formatting without the exclusive lock.
Maybe we should do something similar in Rufus?
The text was updated successfully, but these errors were encountered: