This commit is contained in:
Timothy Baldridge 2020-07-14 21:04:31 -06:00
parent a1dc137c1a
commit 4b2142ed99
3 changed files with 42 additions and 2 deletions

View File

@ -331,11 +331,11 @@ namespace Wabbajack.Common
await fs.WriteAsync(data);
}
public async Task WriteAllAsync(Stream data, bool disposeAfter = true)
public async Task WriteAllAsync(Stream data, bool disposeDataAfter = true)
{
await using var fs = await Create();
await data.CopyToAsync(fs);
if (disposeAfter) await data.DisposeAsync();
if (disposeDataAfter) await data.DisposeAsync();
}
[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]

View File

@ -0,0 +1,38 @@
using System.IO;
using System.Threading.Tasks;
using Wabbajack.Common;
namespace Wabbajack.Lib
{
/// <summary>
/// Wrapper around Windows Defender's commandline tool
/// </summary>
public class VirusScanner
{
public enum Result : int
{
NotMalware = 0,
Malware = 2
}
public static async Task<Result> ScanStream(Stream stream)
{
await using var file = new TempFile();
await file.Path.WriteAllAsync(stream);
var process = new ProcessHelper()
{
Path =
(AbsolutePath)@"C:\ProgramData\Microsoft\Windows Defender\Platform\4.18.2006.10-0\X86\MpCmdRun.exe",
Arguments = new object[] {"-Scan", "-ScanType", "3", "-DisableRemediation", "-File", file.Path},
};
return (Result)await process.Start();
}
public static Task<bool> ShouldScan(AbsolutePath path)
{
}
}
}

View File

@ -46,11 +46,13 @@ namespace Wabbajack.VirtualFileSystem
Size = br.ReadInt64(),
};
var lst = new List<IndexedVirtualFile>();
ivf.Children = lst;
var count = br.ReadInt32();
for (int x = 0; x < count; x++)
{
lst.Add(Read(br));
}
return ivf;
}