Skip to content

Commit

Permalink
[process] move the search for conflicting process to a background thread
Browse files Browse the repository at this point in the history
* Removes the annoyance of having to wait for the process search to complete before media creation can start.
* Also update the "Process Hacker" references to its new "System Informer" name.
  • Loading branch information
pbatard committed Oct 10, 2023
1 parent 8859c59 commit 45a5f22
Show file tree
Hide file tree
Showing 8 changed files with 554 additions and 343 deletions.
7 changes: 2 additions & 5 deletions src/drive.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ static HANDLE GetHandle(char* Path, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWr
uprintf("Warning: Could not obtain exclusive rights. Retrying with write sharing enabled...");
bWriteShare = TRUE;
// Try to report the process that is locking the drive
// We also use bit 6 as a flag to indicate that SearchProcess was called.
access_mask = SearchProcess(DevPath, SEARCH_PROCESS_TIMEOUT, TRUE, TRUE, FALSE) | 0x40;
access_mask = GetProcessSearch(SEARCH_PROCESS_TIMEOUT, 0x07, FALSE);
}
Sleep(DRIVE_ACCESS_TIMEOUT / DRIVE_ACCESS_RETRIES);
}
Expand Down Expand Up @@ -203,9 +202,7 @@ static HANDLE GetHandle(char* Path, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWr
uprintf("Could not lock access to %s: %s", Path, WindowsErrorString());
// See if we can report the processes are accessing the drive
if (!IS_ERROR(FormatStatus) && (access_mask == 0))
// Double the search process timeout here, as Windows is so bloated with processes
// that 10 seconds has become way too small to get much of any results these days...
access_mask = SearchProcess(DevPath, 2 * SEARCH_PROCESS_TIMEOUT, TRUE, TRUE, FALSE);
access_mask = GetProcessSearch(SEARCH_PROCESS_TIMEOUT, 0x07, FALSE);
// Try to continue if the only access rights we saw were for read-only
if ((access_mask & 0x07) != 0x01)
safe_closehandle(hDrive);
Expand Down
6 changes: 3 additions & 3 deletions src/license.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Licensing Data
* Copyright © 2011-2015 Pete Batard <[email protected]>
* Copyright © 2011-2023 Pete Batard <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -89,8 +89,8 @@ const char* additional_copyrights =
"https://www.codeguru.com/forum/showthread.php?p=1951973\\line\n"
"Public Domain\\line\n"
"\\line\n"
"Handle search & process enumeration from Process Hacker by wj32 & dmex:\\line\n"
"https://processhacker.sourceforge.io/\\line\n"
"Handle search & process enumeration from System Informer by wj32 & dmex:\\line\n"
"https://systeminformer.sourceforge.io/\\line\n"
"GNU General Public License (GPL) v3 or later\\line\n"
"\\line\n"
"Decompression support from BusyBox/Bled:\\line\n"
Expand Down
Loading

0 comments on commit 45a5f22

Please sign in to comment.