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:
@@ -38,21 +38,23 @@ namespace LD_SysInfo
|
||||
{
|
||||
|
||||
private static readonly HttpClient httpClient = new HttpClient();
|
||||
private static AppConfig _config;
|
||||
private static string jwtToken = null; // 🔹 Store the JWT token globally in the app
|
||||
private readonly DispatcherTimer messageClearTimer;
|
||||
private readonly DispatcherTimer postTimer;
|
||||
private readonly DispatcherTimer keepAliveTimer;
|
||||
private readonly DispatcherTimer tokenRefreshTimer;
|
||||
private static AppConfig _config = null!; // Initialized in LoadConfig
|
||||
private static string? jwtToken = null; // 🔹 Store the JWT token globally in the app
|
||||
private readonly DispatcherTimer messageClearTimer = null!; // Initialized in constructor
|
||||
private readonly DispatcherTimer postTimer = null!; // Initialized in constructor
|
||||
private readonly DispatcherTimer keepAliveTimer = null!; // Initialized in constructor
|
||||
private readonly DispatcherTimer tokenRefreshTimer = null!; // Initialized in constructor
|
||||
private readonly Uri LightThemeUri = new Uri("pack://application:,,,/Themes/LightTheme.xaml", UriKind.Absolute);
|
||||
private readonly Uri DarkThemeUri = new Uri("pack://application:,,,/Themes/DarkTheme.xaml", UriKind.Absolute);
|
||||
private bool isDarkTheme = false;
|
||||
private SystemInfo _cachedSystemInfo = null!; // Initialized in DisplaySystemInfo
|
||||
|
||||
private static readonly string ConfigPath = Path.Combine(AppContext.BaseDirectory, "config.json");
|
||||
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
|
||||
// ⚠️ Temporary SSL Certificate Bypass - For Testing Only
|
||||
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
|
||||
|
||||
@@ -109,9 +111,35 @@ namespace LD_SysInfo
|
||||
tokenRefreshTimer.Tick += TokenRefreshTimer_Tick;
|
||||
tokenRefreshTimer.Start();
|
||||
|
||||
// Ensure initial refresh occurs after UI is ready
|
||||
this.Loaded += async (s, e) =>
|
||||
{
|
||||
// Small delay so UI visuals finish initializing
|
||||
await Task.Delay(50);
|
||||
await RefreshSystemInfoAsync();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private async void RunOsqueryQuery_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OsqueryOutputBox.Text = "Running query...";
|
||||
string sql = OsqueryQueryBox.Text.Trim();
|
||||
|
||||
try
|
||||
{
|
||||
var result = await Task.Run(() => OsqueryService.Query(sql));
|
||||
|
||||
string prettyJson = System.Text.Json.JsonSerializer.Serialize(result,
|
||||
new System.Text.Json.JsonSerializerOptions { WriteIndented = true });
|
||||
|
||||
OsqueryOutputBox.Text = prettyJson;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OsqueryOutputBox.Text = $"❌ Error running query:\n{ex}";
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadConfig()
|
||||
{
|
||||
@@ -120,7 +148,7 @@ namespace LD_SysInfo
|
||||
//System.Windows.MessageBox.Show($"DEBUG: AppContext.BaseDirectory = {AppContext.BaseDirectory}");
|
||||
//System.Windows.MessageBox.Show($"DEBUG: ConfigPath = {ConfigPath}");
|
||||
|
||||
if (!File.Exists((string?)ConfigPath))
|
||||
if (!File.Exists(ConfigPath))
|
||||
{
|
||||
System.Windows.MessageBox.Show("❌ config.json not found at resolved path!");
|
||||
}
|
||||
@@ -226,7 +254,7 @@ namespace LD_SysInfo
|
||||
string logDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "LD_SysInfo", "Logs");
|
||||
Directory.CreateDirectory(logDir); // Ensure directory exists
|
||||
|
||||
string logFile = Path.Combine(logDir, $"log_{DateTime.Now:yyyyMMdd_HHmmss}.txt");
|
||||
string logFile = Path.Combine(logDir, $"log_{DateTime.Now:yyyyMMdd_HHmms}.txt");
|
||||
File.WriteAllText(logFile, "=== LD SysInfo Diagnostic Log ===\n");
|
||||
|
||||
File.AppendAllText(logFile, $"Timestamp: {DateTime.Now}\n");
|
||||
@@ -244,21 +272,15 @@ namespace LD_SysInfo
|
||||
|
||||
private void DisplaySystemInfo()
|
||||
{
|
||||
var sysInfo = SystemInfo.GetSystemInfo();
|
||||
OSNameTextBlock.Text = $"OS Name: {sysInfo.OSName}";
|
||||
OSVersionTextBlock.Text = $"OS Version: {sysInfo.OSVersion}";
|
||||
WindowsVersionTextBlock.Text = $"Windows Version: {sysInfo.WindowsVersion}";
|
||||
WindowsBuildTextBlock.Text = $"Windows Build: {sysInfo.WindowsBuild}";
|
||||
OSArchitectureTextBlock.Text = $"OS Architecture: {sysInfo.OSArchitecture}";
|
||||
ProcessorNameTextBlock.Text = $"Processor Name: {sysInfo.ProcessorName}";
|
||||
ProcessorArchitectureTextBlock.Text = $"Processor Architecture: {sysInfo.ProcessorArchitecture}";
|
||||
HostnameTextBlock.Text = $"Hostname: {sysInfo.Hostname}";
|
||||
_cachedSystemInfo = SystemInfo.GetSystemInfo();
|
||||
UpdateSysInfoUI(_cachedSystemInfo);
|
||||
}
|
||||
|
||||
private void LoadInstalledAppsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var applications = SystemInfo.GetInstalledApplicationsFromRegistry();
|
||||
InstalledAppsListBox.ItemsSource = applications;
|
||||
var sysInfo = SystemInfo.GetSystemInfo();
|
||||
InstalledAppsListBox.ItemsSource = sysInfo.InstalledApplications;
|
||||
|
||||
}
|
||||
|
||||
private async void StoreSystemInfoButton_Click(object sender, RoutedEventArgs e)
|
||||
@@ -272,7 +294,7 @@ namespace LD_SysInfo
|
||||
try
|
||||
{
|
||||
var sysInfo = SystemInfo.GetSystemInfo();
|
||||
var applications = SystemInfo.GetInstalledApplicationsFromRegistry();
|
||||
var applications = sysInfo.InstalledApplications;
|
||||
|
||||
var formattedApplications = new List<object>();
|
||||
foreach (var app in applications)
|
||||
@@ -469,7 +491,7 @@ namespace LD_SysInfo
|
||||
writer.WriteLine("Installed Applications:");
|
||||
writer.WriteLine("Name,Version,Publisher");
|
||||
|
||||
var applications = SystemInfo.GetInstalledApplicationsFromRegistry();
|
||||
var applications = sysInfo.InstalledApplications;
|
||||
foreach (var app in applications)
|
||||
{
|
||||
writer.WriteLine($"{app.Name},{app.Version},{app.Publisher}");
|
||||
@@ -565,7 +587,16 @@ namespace LD_SysInfo
|
||||
messageClearTimer.Stop();
|
||||
}
|
||||
|
||||
private async void PostTimer_Tick(object sender, EventArgs e)
|
||||
private void OpenOsqueryConsole_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var console = new OsqueryConsole
|
||||
{
|
||||
Owner = this
|
||||
};
|
||||
console.ShowDialog();
|
||||
}
|
||||
|
||||
private async void PostTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ApiClient.GetJwtToken())) // Ensure authentication is active
|
||||
{
|
||||
@@ -575,8 +606,9 @@ namespace LD_SysInfo
|
||||
|
||||
var apiClient = new ApiClient(_config); // Create an instance of ApiClient
|
||||
|
||||
var sysInfo = SystemInfo.GetSystemInfo();
|
||||
var applications = SystemInfo.GetInstalledApplicationsFromRegistry();
|
||||
_cachedSystemInfo = SystemInfo.GetSystemInfo();
|
||||
var sysInfo = _cachedSystemInfo;
|
||||
var applications = sysInfo.InstalledApplications;
|
||||
|
||||
var formattedApplications = new List<object>();
|
||||
foreach (var app in applications)
|
||||
@@ -670,7 +702,7 @@ namespace LD_SysInfo
|
||||
}
|
||||
}
|
||||
|
||||
private async void KeepAliveTimer_Tick(object sender, EventArgs e)
|
||||
private async void KeepAliveTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
var apiClient = new ApiClient(_config);
|
||||
bool isConnected = await apiClient.CheckConnectivity();
|
||||
@@ -693,12 +725,12 @@ namespace LD_SysInfo
|
||||
}
|
||||
|
||||
|
||||
private void MessageClearTimer_Tick(object sender, EventArgs e)
|
||||
private void MessageClearTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
FadeOutStatusMessage(); // Trigger the fade-out effect
|
||||
}
|
||||
|
||||
private async void TokenRefreshTimer_Tick(object sender, EventArgs e)
|
||||
private async void TokenRefreshTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ApiClient.GetJwtToken()))
|
||||
{
|
||||
@@ -751,5 +783,101 @@ namespace LD_SysInfo
|
||||
base.OnStateChanged(e);
|
||||
}
|
||||
|
||||
private void UpdateSysInfoUI(SystemInfo sysInfo)
|
||||
{
|
||||
if (sysInfo == null) return;
|
||||
|
||||
HostnameTextBlock.Text = $"Hostname: {(string.IsNullOrEmpty(sysInfo.Hostname) ? "N/A" : sysInfo.Hostname)}";
|
||||
OSNameTextBlock.Text = $"OS Name: {(string.IsNullOrEmpty(sysInfo.OSName) ? "N/A" : sysInfo.OSName)}";
|
||||
OSVersionTextBlock.Text = $"OS Version: {(string.IsNullOrEmpty(sysInfo.OSVersion) ? "N/A" : sysInfo.OSVersion)}";
|
||||
WindowsVersionTextBlock.Text = $"Windows Version: {(string.IsNullOrEmpty(sysInfo.WindowsVersion) ? "N/A" : sysInfo.WindowsVersion)}";
|
||||
WindowsBuildTextBlock.Text = $"Windows Build: {(string.IsNullOrEmpty(sysInfo.WindowsBuild) ? "N/A" : sysInfo.WindowsBuild)}";
|
||||
OSArchitectureTextBlock.Text = $"OS Architecture: {(string.IsNullOrEmpty(sysInfo.OSArchitecture) ? "N/A" : sysInfo.OSArchitecture)}";
|
||||
ProcessorNameTextBlock.Text = $"Processor Name: {(string.IsNullOrEmpty(sysInfo.ProcessorName) ? "N/A" : sysInfo.ProcessorName)}";
|
||||
ProcessorArchitectureTextBlock.Text = $"Processor Architecture: {(string.IsNullOrEmpty(sysInfo.ProcessorArchitecture) ? "N/A" : sysInfo.ProcessorArchitecture)}";
|
||||
|
||||
// Memory
|
||||
MemoryTextBlock.Text = $"Total Memory: {(string.IsNullOrEmpty(sysInfo.TotalMemory) ? "N/A" : sysInfo.TotalMemory)}";
|
||||
|
||||
// GPUs (join multiple models)
|
||||
GpuTextBlock.Text = (sysInfo.GpuNames == null || sysInfo.GpuNames.Count == 0)
|
||||
? "GPU(s): N/A"
|
||||
: $"GPU(s): {string.Join(", ", sysInfo.GpuNames)}";
|
||||
|
||||
// IP addresses - format each on its own line for readability
|
||||
if (sysInfo.IpAddresses == null || sysInfo.IpAddresses.Count == 0)
|
||||
{
|
||||
IpTextBlock.Text = "IP Addresses: N/A";
|
||||
}
|
||||
else
|
||||
{
|
||||
var parts = new List<string>();
|
||||
foreach (var ni in sysInfo.IpAddresses)
|
||||
{
|
||||
var ip = string.IsNullOrEmpty(ni.IpAddress) ? "N/A" : ni.IpAddress;
|
||||
parts.Add($" • {ip}");
|
||||
}
|
||||
IpTextBlock.Text = $"IP Addresses:\n{string.Join("\n", parts)}";
|
||||
}
|
||||
|
||||
// CollectedAt / Last updated
|
||||
CollectedAtTextBlock.Text = !string.IsNullOrEmpty(sysInfo.CollectedAt)
|
||||
? $"Last updated: {sysInfo.CollectedAt}"
|
||||
: $"Last updated: {DateTimeOffset.Now:g}";
|
||||
}
|
||||
|
||||
private async Task RefreshSystemInfoAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Show immediate feedback
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
StatusTextBlock.Text = "Collecting system info...";
|
||||
try { StatusTextBlock.Foreground = (SolidColorBrush)FindResource("StatusConnectedBrush"); } catch { StatusTextBlock.Foreground = new SolidColorBrush(Colors.Black); }
|
||||
});
|
||||
|
||||
// Run osquery work off the UI thread
|
||||
var info = await Task.Run(() => SystemInfo.GetSystemInfo());
|
||||
_cachedSystemInfo = info;
|
||||
|
||||
// Update UI on UI thread
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
UpdateSysInfoUI(info);
|
||||
CollectedAtTextBlock.Text = !string.IsNullOrEmpty(info.CollectedAt)
|
||||
? $"Last updated: {info.CollectedAt}"
|
||||
: $"Last updated: {DateTimeOffset.Now:g}";
|
||||
|
||||
StatusTextBlock.Text = "✅ System info refreshed";
|
||||
try { StatusTextBlock.Foreground = (SolidColorBrush)FindResource("StatusConnectedBrush"); } catch { StatusTextBlock.Foreground = new SolidColorBrush(Colors.Green); }
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
StatusTextBlock.Text = $"❌ Refresh failed: {ex.Message}";
|
||||
StatusTextBlock.Foreground = new SolidColorBrush(Colors.Red);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async void RefreshButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Disable the button while running (UI lookup)
|
||||
if (sender is System.Windows.Controls.Button b)
|
||||
{
|
||||
b.IsEnabled = false;
|
||||
}
|
||||
|
||||
await RefreshSystemInfoAsync();
|
||||
|
||||
if (sender is System.Windows.Controls.Button b2)
|
||||
{
|
||||
b2.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user