Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions config/device_identifiers.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
"hardware_id": "pentablet\\\\hid",
"class_uuid": "745a17a0-74d3-11d0-b6fe-00a0c90f57da"
},
{
"friendly_name": "Wacom LibusbK Device",
"device_desc": ".*\\(Interface[ _]\\d+\\)",
"manufacturer": "Wacom",
"class_uuid": "ecfb0cfd-74c4-4f52-bbf7-343461cd72ac",
"uninstall_inf": true
},
{
"friendly_name": "Wacom Driver Downloader",
"device_desc": "Wacom Driver Downloader",
Expand Down
18 changes: 17 additions & 1 deletion src/cleanup_modules/device_cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,22 @@ impl ModuleStrategy for DeviceCleanupModule {
run_info.reboot_required = true;
}

if to_uninstall.uninstall_inf.unwrap_or(false) {
let inf_path = Path::new(object.driver_store_location().unwrap())
.join(object.inf_original_name().unwrap());
let driver_uninstall = super::driver_cleanup::DriverToUninstall {
friendly_name: object.friendly_name().unwrap().to_string(),
original_name: None,
provider: None,
class: None
};

super::driver_cleanup::uninstall_driver(&inf_path, &driver_uninstall, run_info)
.attach_printable_lazy(|| {
format!("failed to uninstall driver for device {}", object.instance_id())
})?
}

Ok(())
}
}
Expand Down Expand Up @@ -181,13 +197,13 @@ impl Dumper for DeviceDumper {
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct DeviceToUninstall {
friendly_name: String,
device_desc: Option<String>,
manufacturer: Option<String>,
hardware_id: Option<String>,
class_uuid: Option<Uuid>,
uninstall_inf: Option<bool>
}

impl ToUninstall<Device> for DeviceToUninstall {
Expand Down
66 changes: 36 additions & 30 deletions src/cleanup_modules/driver_cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,36 +85,43 @@ impl ModuleStrategy for DriverCleanupModule {
) -> Result<(), UninstallError> {
let inf_path = Path::new(object.driver_store_location().unwrap())
.join(object.inf_original_name().unwrap());
uninstall_driver(&inf_path, to_uninstall, run_info)
}

unsafe {
let mut reboot: BOOL = false.into();
if !DiUninstallDriverW(
None,
&HSTRING::from(inf_path.as_path()),
0,
Some(&mut reboot),
)
.as_bool()
{
let err = windows::core::Error::from_win32();
return Err(err)
.into_report()
.attach_printable_lazy(|| {
format!("failed to uninstall inf: {}", inf_path.display())
})
.into_uninstall_report(to_uninstall);
}
fn get_dumper(&self) -> Option<&dyn Dumper> {
Some(&self.driver_dumper)
}
}

if reboot.as_bool() {
run_info.reboot_required = true;
}
pub(crate) fn uninstall_driver(
inf_path: &Path,
to_uninstall: &DriverToUninstall,
run_info: &mut ModuleRunInfo,
) -> Result<(), UninstallError> {
unsafe {
let mut reboot: BOOL = false.into();
if !DiUninstallDriverW(
None,
&HSTRING::from(inf_path),
0,
Some(&mut reboot),
)
.as_bool()
{
let err = windows::core::Error::from_win32();
return Err(err)
.into_report()
.attach_printable_lazy(|| {
format!("failed to uninstall inf: {}", inf_path.display())
})
.into_uninstall_report(to_uninstall);
}

Ok(())
if reboot.as_bool() {
run_info.reboot_required = true;
}
}

fn get_dumper(&self) -> Option<&dyn Dumper> {
Some(&self.driver_dumper)
Ok(())
}
}

Expand Down Expand Up @@ -155,12 +162,11 @@ impl Dumper for DriverDumper {
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct DriverToUninstall {
friendly_name: String,
original_name: Option<String>,
provider: Option<String>,
class: Option<Uuid>,
pub friendly_name: String,
pub original_name: Option<String>,
pub provider: Option<String>,
pub class: Option<Uuid>,
}

impl ToUninstall<Driver> for DriverToUninstall {
Expand Down