Release v1.2.0: Integrate osquery for enhanced system information
Major Features: - Integrated osquery for comprehensive system information gathering - Added OsqueryService for executing SQL queries against system tables - Implemented Osquery Console tab for interactive SQL queries System Info Improvements: - Enhanced system info collection using osquery tables - Added support for multiple GPU detection - Improved memory detection with proper GB formatting - Fixed OS Architecture detection (x64/x86) - Better network interface detection (IPv4 only) - Human-readable timestamp formatting UI/UX Enhancements: - Added window resizing with corner drag support - Implemented dynamic window sizing (SizeToContent) - Added ScrollViewer for content overflow - Improved IP address formatting with bullet points - Added field labels to all system info displays - Set minimum/maximum window size constraints Bug Fixes: - Fixed XAML StackPanel Spacing property issue - Merged duplicate MainWindow constructors - Fixed non-nullable field warnings - Fixed EventHandler nullability signatures - Removed redundant hostname/OS name fields - Fixed GPU registry query to detect all GPUs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
78
LD-SysInfo/Services/OsqueryService.cs
Normal file
78
LD-SysInfo/Services/OsqueryService.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace LD_SysInfo.Services
|
||||
{
|
||||
public static class OsqueryService
|
||||
{
|
||||
private static string GetOsqueryPath()
|
||||
{
|
||||
var baseDir = AppContext.BaseDirectory;
|
||||
var path = Path.Combine(baseDir, "Assets", "osqueryi.exe");
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
File.AppendAllText("osquery_error.log", $"[{DateTime.Now}] ❌ osqueryi.exe not found at {path}\n");
|
||||
throw new FileNotFoundException("osqueryi.exe not found", path);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
private static string RunQuery(string sql)
|
||||
{
|
||||
var processInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = GetOsqueryPath(),
|
||||
Arguments = $"--json \"{sql}\"",
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true
|
||||
};
|
||||
|
||||
using var process = Process.Start(processInfo); // ✅ FIXED — actually start the process
|
||||
if (process == null)
|
||||
throw new Exception("Failed to start osquery process");
|
||||
|
||||
string output = process.StandardOutput.ReadToEnd();
|
||||
process.WaitForExit();
|
||||
|
||||
// Optional debug logging
|
||||
File.AppendAllText("osquery_debug.log",
|
||||
$"[{DateTime.Now}] Ran query: {sql}\nOutput length: {output.Length}\n");
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public static List<Dictionary<string, string>> Query(string sql)
|
||||
{
|
||||
string json = RunQuery(sql);
|
||||
|
||||
try
|
||||
{
|
||||
var jArray = JArray.Parse(json);
|
||||
var results = new List<Dictionary<string, string>>();
|
||||
|
||||
foreach (var obj in jArray)
|
||||
{
|
||||
var dict = new Dictionary<string, string>();
|
||||
foreach (var prop in (JObject)obj)
|
||||
dict[prop.Key] = prop.Value?.ToString() ?? "";
|
||||
results.Add(dict);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
File.AppendAllText("osquery_error.log",
|
||||
$"[{DateTime.Now}] ⚠️ JSON parse failed for query '{sql}': {ex.Message}\n");
|
||||
return new List<Dictionary<string, string>>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user