From b2bb9d95e72cab133aba53bee69cfe2f13df6f73 Mon Sep 17 00:00:00 2001 From: BeneficialCode <3123132899@qq.com> Date: Tue, 7 Mar 2023 10:09:08 +0800 Subject: [PATCH] Change the service config by ChangeServiceConfig --- WinSysCore/DriverHelper.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/WinSysCore/DriverHelper.cpp b/WinSysCore/DriverHelper.cpp index 1855e1c..519d379 100644 --- a/WinSysCore/DriverHelper.cpp +++ b/WinSysCore/DriverHelper.cpp @@ -76,14 +76,9 @@ bool DriverHelper::InstallDriver(bool justCopy,void* pBuffer,DWORD size) { hService.reset(::OpenService(hScm.get(), L"AntiRootkit", SERVICE_ALL_ACCESS)); if (!hService) return false; - if (!DeleteService(hService.get())) - return false; - hService.reset(::CreateService(hScm.get(), L"AntiRootkit", nullptr, SERVICE_ALL_ACCESS, - SERVICE_KERNEL_DRIVER, - SERVICE_DEMAND_START, // starting service on demand - SERVICE_ERROR_NORMAL, // the error is logged to the event log service - path, // the full path to the executable to run for the service - nullptr, nullptr, nullptr, nullptr, nullptr)); + ChangeServiceConfig(hService.get(), + SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, + path, nullptr, nullptr, nullptr, nullptr, nullptr, L"AntiRootkit"); } auto success = hService != nullptr; return success;