// [Test(Description = "Test loading kernel driver on specific machine")] public static void TestLoading() { BridgeDriver.RegisterLoggerCallback(Target); Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); Console.WriteLine($"Test working directory is: {Directory.GetCurrentDirectory()}"); var state = KernelDriverBridge.InitializeEnvironment(); if (state == KernelDriverInitState.RhmsDriverManagerIncorrectDrvSignature) { Assert.Ignore("Won't check driver signature, target machine should disable 'Driver Signature Checking' " + "before perform driver loading test, because it always leads to test failure"); } Assert.AreEqual(KernelDriverInitState.RhmsDrvNoError, state, "Unnable to load driver or create service"); }
internal static void Main(string[] args) { _isCanShutdown = false; Native.SetConsoleCtrlHandler(ConsoleCtrlCheck, true); NetworkRemoteControl.Initialize(); Console.Title = "RHMS Client Data Collecting Server"; Thread.CurrentThread.Name = "main"; AppLogger = new Logger(); AppLogger.Initialize(); Logger.Info("Starting server"); Logger.Info($"Working directory '{Directory.GetCurrentDirectory()}'"); BridgeDriver.RegisterLoggerCallback(DriverLoggerCallback); KernelDriverInitState = KernelDriverBridge.InitializeEnvironment(); if (KernelDriverInitState == KernelDriverInitState.RhmsDrvNoError) { var cpusInfo = Drivers.Presentation.Cpuid.Get(); var firstCpu = cpusInfo?[0]; if (firstCpu != null) { Console.WriteLine(firstCpu.ToString()); } } Logger.Auto(KernelDriverInitState == KernelDriverInitState.RhmsDrvNoError ? DriverLogLevel.Info : DriverLogLevel.Error, $"Load driver state: {KernelDriverInitState}"); if (KernelDriverInitState != KernelDriverInitState.RhmsDrvNoError) { if (KernelDriverInitState == KernelDriverInitState.RhmsDriverManagerIncorrectDrvSignature) { Logger.Warn("Kernel driver signature checking is enabled in your system, RHMS server is not able to load custom kernel driver."); Logger.Warn("You need to disable signature checking on target subsystem."); } else { Logger.Warn("Kernel driver are failed to initializate, maybe driver signing checks are enabled on target system."); } Logger.Warn("Some features as collecting physical devices data will not available."); } CollectingServer = new RhmsCollectingServer(); Debug.Assert(CollectingServer.GetModuleLoader() != null); if (!CollectingServer.LoadSettings()) { Logger.Warn("Unable to load server settings!"); AppLogger.Shutdown(); return; } Logger.Info("Initialize collecting server"); try { if (!CollectingServer.Initialize()) { Logger.Error("Could not initialize RHMS Collecting Server! Press any key to exit."); Console.ReadLine(); return; } } catch (Exception e) { Logger.Error("Could not initialize RHMS Collecting Server, internal error has occured! Press any key to exit.", e); Console.ReadLine(); return; } Logger.Info("Loading modules"); CollectingServer.GetModuleLoader().LoadFromFolder(Directory.GetCurrentDirectory() + @"\modules"); Logger.Info("Loading modules has finished."); CollectingServer.StartNetworkUpdates(); CollectingServer.StartHardwareUpdates(); _isCanShutdown = true; // There's no commands yet, just listen for any line and close Console.ReadLine(); Shutdown(); }