in Lib/Collectors/WindowsFileSystemUtils.cs [62:108]
public static List<DLLCHARACTERISTICS> GetDllCharacteristics(string Path)
{
List<DLLCHARACTERISTICS> output = new List<DLLCHARACTERISTICS>();
if (NeedsSignature(Path))
{
try
{
if (PeFile.IsPeFile(Path))
{
using var mmf = new PeNet.FileParser.MMFile(Path);
var peHeader = new PeFile(mmf);
var dllCharacteristics = peHeader.ImageNtHeaders?.OptionalHeader.DllCharacteristics;
if (dllCharacteristics is DllCharacteristicsType chars)
{
ushort characteristics = (ushort)chars;
foreach (DLLCHARACTERISTICS? characteristic in Enum.GetValues(typeof(DLLCHARACTERISTICS)))
{
if (characteristic is DLLCHARACTERISTICS c)
{
if (((ushort)c & characteristics) == (ushort)c)
{
output.Add(c);
}
}
}
}
}
}
catch (Exception e) when (
e is IndexOutOfRangeException
|| e is ArgumentNullException
|| e is System.IO.IOException
|| e is ArgumentException
|| e is UnauthorizedAccessException
|| e is NullReferenceException)
{
Log.Verbose("Failed to get PE Headers for {0} ({1}:{2})", Path, e.GetType(), e.Message);
}
catch (Exception e)
{
Log.Debug(e, "Failed to get PE Headers for {0} ({1}:{2})", Path, e.GetType(), e.Message);
}
}
return output;
}