Merge pull request #8 from BerkanYildiz/patch-1

My bad, ZwUnloadDriver has to be called before RegDeleteKey
This commit is contained in:
Jan
2019-06-24 00:03:38 +02:00
committed by GitHub
+14 -8
View File
@@ -102,17 +102,23 @@ namespace native
inline bool unload_driver(const std::wstring& service)
{
HKEY key;
UNICODE_STRING str;
auto wservice = internal::make_path(service);
RtlInitUnicodeString(&str, wservice.c_str());
if (!RegOpenKeyW(HKEY_LOCAL_MACHINE, L"system\\CurrentControlSet\\Services", &key))
{
RegDeleteKeyW(key, L"Capcom");
RegCloseKey(key);
}
return ZwUnloadDriver(&str) >= 0;
bool isUnloaded = ZwUnloadDriver(&str) >= 0;
if (isUnloaded)
{
HKEY key;
if (!RegOpenKeyW(HKEY_LOCAL_MACHINE, L"system\\CurrentControlSet\\Services", &key))
{
RegDeleteKeyW(key, L"Capcom");
RegCloseKey(key);
}
}
return isUnloaded;
}
}