From 63acce922a67e578513188373540becd7e536700 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Thu, 13 Mar 2025 22:16:48 -0500 Subject: [PATCH] Remove function to install WinRing0 kernel driver in main.cpp --- main.cpp | 79 -------------------------------------------------------- 1 file changed, 79 deletions(-) diff --git a/main.cpp b/main.cpp index 9b06f0e9c..364888f77 100644 --- a/main.cpp +++ b/main.cpp @@ -78,80 +78,6 @@ void WaitWhileServerOnline(NetworkServer* srv) }; } -/******************************************************************************************\ -* * -* Install SMBus Driver WinRing0, If not already installed (Win32) * -* * -\******************************************************************************************/ -#ifdef _WIN32 -void InstallWinRing0() -{ - TCHAR winring0_install_location[MAX_PATH]; // driver final location usually C:\windows\system32\drivers\WinRing0x64.sys - uint system_path_length = GetSystemDirectory(winring0_install_location, MAX_PATH); - std::string winring0_filename = "WinRing0.sys"; - BOOL bIsWow64 = false; -#if _WIN64 - winring0_filename = "WinRing0x64.sys"; -#else - BOOL (*fnIsWow64Process)(HANDLE, PBOOL) = (BOOL (__cdecl *)(HANDLE, PBOOL))GetProcAddress(GetModuleHandle(TEXT("kernel32")),"IsWow64Process"); - if (fnIsWow64Process) - { - fnIsWow64Process(GetCurrentProcess(),&bIsWow64); - } - if(bIsWow64) - { - winring0_filename = "WinRing0x64.sys"; - } -#endif - std::strncat(winring0_install_location, "\\drivers\\", MAX_PATH - system_path_length - 1); - std::strncat(winring0_install_location, winring0_filename.c_str(), MAX_PATH - system_path_length - 10); - - std::string driver_name = winring0_filename.substr(0, winring0_filename.size() - 4); // driver name: WinRing0 or WinRing0x64 - SC_HANDLE manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if (manager) - { - PVOID wow64_fsredirection_OldValue = NULL; - if(bIsWow64) - { - Wow64DisableWow64FsRedirection(&wow64_fsredirection_OldValue); - } - if(INVALID_FILE_ATTRIBUTES == GetFileAttributes(winring0_install_location) && GetLastError()==ERROR_FILE_NOT_FOUND) - { - char module_path_buffer[MAX_PATH]; - GetModuleFileNameA(NULL, module_path_buffer, MAX_PATH); - std::string::size_type exe_loc = std::string(module_path_buffer).find_last_of("\\/"); - std::string driver_source_path = std::string(module_path_buffer).substr(0, exe_loc + 1) + winring0_filename; - CopyFile(driver_source_path.c_str(), winring0_install_location, true); - } - if(bIsWow64) - { - Wow64RevertWow64FsRedirection(wow64_fsredirection_OldValue); - } - - SC_HANDLE service = OpenService(manager, driver_name.c_str(), SERVICE_ALL_ACCESS); - if(!service) - { - std::string service_sys_path = "System32\\Drivers\\" + winring0_filename; - service = CreateService(manager, - driver_name.c_str(), - driver_name.c_str(), - SERVICE_ALL_ACCESS, - SERVICE_KERNEL_DRIVER, - SERVICE_AUTO_START, - SERVICE_ERROR_NORMAL, - service_sys_path.c_str(), - NULL, - NULL, - NULL, - NULL, - NULL); - } - CloseServiceHandle(service); - CloseServiceHandle(manager); - } -} -#endif - /******************************************************************************************\ * * * main * @@ -184,11 +110,6 @@ int main(int argc, char* argv[]) std::thread * InitializeTimerResolutionThread; InitializeTimerResolutionThread = new std::thread(InitializeTimerResolutionThreadFunction); InitializeTimerResolutionThread->detach(); - - /*---------------------------------------------------------*\ - | Windows only - Install SMBus Driver WinRing0 | - \*---------------------------------------------------------*/ - InstallWinRing0(); #endif /*---------------------------------------------------------*\