mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[core] re-add the VID:PID lookup fallback using the Device ID string
* The call for the node connection information will fail for device such as Mp3 media players * In that case, we can still obtain the VID:PID from the Device ID * Also improve mutex release for commandline hogger
This commit is contained in:
		
							parent
							
								
									d5bb6bfe6f
								
							
						
					
					
						commit
						8b9c180404
					
				
					 3 changed files with 33 additions and 13 deletions
				
			
		|  | @ -2101,7 +2101,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine | |||
| 			} | ||||
| 			input[i].type = INPUT_KEYBOARD; | ||||
| 			input[i].ki.wVk = VK_RETURN; | ||||
| //			SetWindowPos(GetConsoleWindow(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
 | ||||
| 			SendInput(i+1, input, sizeof(INPUT)); | ||||
| 			safe_free(input); | ||||
| 		} | ||||
|  | @ -2390,9 +2389,11 @@ relaunch: | |||
| 	} | ||||
| 
 | ||||
| out: | ||||
| 	// Destroy our commandline hogger first, so that we can delete the app
 | ||||
| 	// Destroy the hogger mutex first, so that the cmdline app can exit and we can delete it
 | ||||
| 	if (attached_console) { | ||||
| 		ReleaseMutex(hogmutex); | ||||
| 		safe_closehandle(hogmutex); | ||||
| 	} | ||||
| 	if ((!external_loc_file) && (loc_file[0] != 0)) | ||||
| 		DeleteFileU(loc_file); | ||||
| 	DestroyAllTooltips(); | ||||
|  |  | |||
							
								
								
									
										12
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | |||
| 
 | ||||
| IDD_DIALOG DIALOGEX 12, 12, 206, 329 | ||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||
| CAPTION "Rufus 1.4.8.496" | ||||
| CAPTION "Rufus 1.4.8.497" | ||||
| FONT 8, "MS Shell Dlg", 400, 0, 0x1 | ||||
| BEGIN | ||||
|     DEFPUSHBUTTON   "Start",IDC_START,94,291,50,14 | ||||
|  | @ -165,7 +165,7 @@ END | |||
| RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329 | ||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||
| EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL | ||||
| CAPTION "Rufus 1.4.8.496" | ||||
| CAPTION "Rufus 1.4.8.497" | ||||
| FONT 8, "MS Shell Dlg", 400, 0, 0x1 | ||||
| BEGIN | ||||
|     DEFPUSHBUTTON   "Start",IDC_START,94,291,50,14 | ||||
|  | @ -428,8 +428,8 @@ END | |||
| // | ||||
| 
 | ||||
| VS_VERSION_INFO VERSIONINFO | ||||
|  FILEVERSION 1,4,8,496 | ||||
|  PRODUCTVERSION 1,4,8,496 | ||||
|  FILEVERSION 1,4,8,497 | ||||
|  PRODUCTVERSION 1,4,8,497 | ||||
|  FILEFLAGSMASK 0x3fL | ||||
| #ifdef _DEBUG | ||||
|  FILEFLAGS 0x1L | ||||
|  | @ -446,13 +446,13 @@ BEGIN | |||
|         BEGIN | ||||
|             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" | ||||
|             VALUE "FileDescription", "Rufus" | ||||
|             VALUE "FileVersion", "1.4.8.496" | ||||
|             VALUE "FileVersion", "1.4.8.497" | ||||
|             VALUE "InternalName", "Rufus" | ||||
|             VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)" | ||||
|             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" | ||||
|             VALUE "OriginalFilename", "rufus.exe" | ||||
|             VALUE "ProductName", "Rufus" | ||||
|             VALUE "ProductVersion", "1.4.8.496" | ||||
|             VALUE "ProductVersion", "1.4.8.497" | ||||
|         END | ||||
|     END | ||||
|     BLOCK "VarFileInfo" | ||||
|  |  | |||
							
								
								
									
										25
									
								
								src/usb.c
									
										
									
									
									
								
							
							
						
						
									
										25
									
								
								src/usb.c
									
										
									
									
									
								
							|  | @ -68,7 +68,7 @@ static void GetUSBProperties(char* parent_path, char* device_id, usb_device_prop | |||
| 
 | ||||
| 	handle = CreateFileA(parent_path, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); | ||||
| 	if (handle == INVALID_HANDLE_VALUE) { | ||||
| 		uprintf("could not open hub %s: %s", parent_path, WindowsErrorString()); | ||||
| 		uprintf("Could not open hub %s: %s", parent_path, WindowsErrorString()); | ||||
| 		goto out; | ||||
| 	} | ||||
| 	memset(&conn_info, 0, sizeof(conn_info)); | ||||
|  | @ -76,7 +76,7 @@ static void GetUSBProperties(char* parent_path, char* device_id, usb_device_prop | |||
| 	conn_info.ConnectionIndex = (ULONG)props->port; | ||||
| 	// coverity[tainted_data_argument]
 | ||||
| 	if (!DeviceIoControl(handle, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, &conn_info, size, &conn_info, size, &size, NULL)) { | ||||
| 		uprintf("could not get node connection information for device '%s': %s", device_id, WindowsErrorString()); | ||||
| 		uprintf("Could not get node connection information for '%s': %s", device_id, WindowsErrorString()); | ||||
| 		goto out; | ||||
| 	} | ||||
| 
 | ||||
|  | @ -92,7 +92,7 @@ static void GetUSBProperties(char* parent_path, char* device_id, usb_device_prop | |||
| 		conn_info_v2.Length = size; | ||||
| 		conn_info_v2.SupportedUsbProtocols.Usb300 = 1; | ||||
| 		if (!DeviceIoControl(handle, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX_V2, &conn_info_v2, size, &conn_info_v2, size, &size, NULL)) { | ||||
| 			uprintf("could not get node connection information (V2) for device '%s': %s", device_id, WindowsErrorString()); | ||||
| 			uprintf("Could not get node connection information (V2) for device '%s': %s", device_id, WindowsErrorString()); | ||||
| 		} else if (conn_info_v2.Flags.DeviceIsOperatingAtSuperSpeedOrHigher) { | ||||
| 			props->speed = USB_SPEED_SUPER_OR_LATER; | ||||
| 		} else if (conn_info_v2.Flags.DeviceIsSuperSpeedCapableOrHigher) { | ||||
|  | @ -262,6 +262,25 @@ BOOL GetUSBDevices(DWORD devnum) | |||
| 					if (j > 0) { | ||||
| 						GetUSBProperties(dev_if_path.String[(uint32_t)htab_devid.table[j].data], device_id, &props); | ||||
| 					} | ||||
| 
 | ||||
| 					// If the previous calls didn't succeed in getting the VID:PID, try from the device_id
 | ||||
| 					// (This is for the case for USB media player devices, for instance)
 | ||||
| 					if ((props.vid == 0) && (props.pid == 0)) { | ||||
| 						BOOL post_backslash = FALSE; | ||||
| 						for (j=0, k=0; (j<strlen(device_id))&&(k<2); j++) { | ||||
| 							// The ID is in the form USB_VENDOR_BUSID\VID_xxxx&PID_xxxx\...
 | ||||
| 							if (device_id[j] == '\\') | ||||
| 								post_backslash = TRUE; | ||||
| 							if (!post_backslash) | ||||
| 								continue; | ||||
| 							if (device_id[j] == '_') { | ||||
| 								props.pid = (uint16_t)strtoul(&device_id[j+1], NULL, 16); | ||||
| 								if (k++==0) | ||||
| 									props.vid = props.pid; | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 
 | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue