-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from GeneralLibrary/dev
Dev
- Loading branch information
Showing
252 changed files
with
3,746 additions
and
8,969 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
@echo off | ||
setlocal | ||
|
||
if "%~1"=="" ( | ||
echo Please provide the export path as the first parameter. | ||
exit /b 1 | ||
) | ||
|
||
set exportDir=%~1 | ||
|
||
if not exist "%exportDir%" ( | ||
mkdir "%exportDir%" | ||
) | ||
|
||
set outputFile=%exportDir%\driverInfo.txt | ||
|
||
:: 导出驱动信息 | ||
driverquery /v /fo table > "%outputFile%" | ||
echo %outputFile% Export successfully. | ||
|
||
:: 导出系统信息 | ||
set systemInfoFile=%exportDir%\systeminfo.txt | ||
systeminfo > "%systemInfoFile%" | ||
echo %systemInfoFile% Export successfully. | ||
|
||
:: 获取当前日期 | ||
for /f "tokens=1-4 delims=/- " %%i in ('date /t') do ( | ||
set yyyy=%%i | ||
set mm=%%j | ||
set dd=%%k | ||
) | ||
|
||
:: 设置日志文件名 | ||
set logFile=%exportDir%\systemlog.evtx | ||
|
||
:: 导出系统日志 | ||
wevtutil epl System "%logFile%" /q:"*[System[TimeCreated[timediff(@SystemTime) <= 86400000]]]" | ||
echo %logFile% Export successfully. | ||
|
||
endlocal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,64 @@ | ||
using System; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
using System.Text.Json; | ||
using GeneralUpdate.Bowl.Strategys; | ||
using GeneralUpdate.Common.AOT.JsonContext; | ||
using GeneralUpdate.Common.Shared.Object; | ||
|
||
namespace GeneralUpdate.Bowl; | ||
|
||
public class Bowl | ||
/// <summary> | ||
/// Surveillance Main Program. | ||
/// </summary> | ||
public sealed class Bowl | ||
{ | ||
private IStrategy _strategy; | ||
private static IStrategy? _strategy; | ||
|
||
public Bowl(MonitorParameter parameter = null) | ||
{ | ||
CreateStrategy(); | ||
_strategy!.SetParameter(parameter); | ||
} | ||
private Bowl() { } | ||
|
||
private void CreateStrategy() | ||
private static void CreateStrategy() | ||
{ | ||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
_strategy = new WindowStrategy(); | ||
} | ||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||
/*else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||
{ | ||
_strategy = new LinuxStrategy(); | ||
} | ||
}*/ | ||
|
||
if (_strategy == null) | ||
throw new PlatformNotSupportedException("Unsupported operating system"); | ||
} | ||
|
||
public static void Launch(MonitorParameter? monitorParameter = null) | ||
{ | ||
monitorParameter ??= CreateParameter(); | ||
CreateStrategy(); | ||
_strategy?.SetParameter(monitorParameter); | ||
_strategy?.Launch(); | ||
} | ||
|
||
public Bowl SetParameter(MonitorParameter parameter) | ||
private static MonitorParameter CreateParameter() | ||
{ | ||
if(parameter.Verify()) | ||
throw new ArgumentException("Parameter contains illegal values"); | ||
var json = Environment.GetEnvironmentVariable("ProcessInfo", EnvironmentVariableTarget.User); | ||
if(string.IsNullOrWhiteSpace(json)) | ||
throw new ArgumentNullException("ProcessInfo environment variable not set !"); | ||
|
||
var processInfo = JsonSerializer.Deserialize<ProcessInfo>(json, ProcessInfoJsonContext.Default.ProcessInfo); | ||
if(processInfo == null) | ||
throw new ArgumentNullException("ProcessInfo json deserialize fail!"); | ||
|
||
_strategy.SetParameter(parameter); | ||
return this; | ||
return new MonitorParameter | ||
{ | ||
ProcessNameOrId = processInfo.AppName, | ||
DumpFileName = $"{processInfo.LastVersion}_fail.dmp", | ||
FailFileName = $"{processInfo.LastVersion}_fail.json", | ||
TargetPath = processInfo.InstallPath, | ||
FailDirectory = Path.Combine(processInfo.InstallPath, "fail", processInfo.LastVersion), | ||
BackupDirectory = Path.Combine(processInfo.InstallPath, processInfo.LastVersion), | ||
ExtendedField = processInfo.LastVersion | ||
}; | ||
} | ||
|
||
public void Launch() => _strategy.Launch(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace GeneralUpdate.Bowl.Strategys; | ||
|
||
public class Crash | ||
{ | ||
public MonitorParameter Parameter { get; set; } | ||
|
||
public List<string> ProcdumpOutPutLines { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.