mirror of
https://github.com/stellarbear/YaraSharp
synced 2026-06-08 17:36:09 +00:00
Disable file existance checks to let files with long filenames to take place
This commit is contained in:
Binary file not shown.
+27075
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -26,15 +26,16 @@ using (YaraSharp.CContext YSContext = new YaraSharp.CContext())
|
||||
using (YaraSharp.CRules YSRules = YSInstance.CompileFromFiles(RuleFilenames, Externals, out Errors))
|
||||
{
|
||||
// Some file to test yara rules
|
||||
string Filename = "<some_file>";
|
||||
// Here comes long filenames
|
||||
string Filename = "\\?\<some_file>";
|
||||
|
||||
// Get matches
|
||||
List<YaraSharp.CMatches> Matches = YSInstance.ScanFile(Filename, YSRules,
|
||||
new Dictionary<string, object>()
|
||||
{
|
||||
{ "filename", System.IO.Path.GetFileName(Filename) },
|
||||
{ "filepath", System.IO.Path.GetFullPath(Filename) },
|
||||
{ "extension", System.IO.Path.GetExtension(Filename) }
|
||||
{ "filename", Alphaleonis.Win32.Filesystem.Path.GetFileName(Filename) },
|
||||
{ "filepath", Alphaleonis.Win32.Filesystem.Path.GetFullPath(Filename) },
|
||||
{ "extension", Alphaleonis.Win32.Filesystem.Path.GetExtension(Filename) }
|
||||
},
|
||||
0);
|
||||
|
||||
@@ -44,7 +45,8 @@ using (YaraSharp.CContext YSContext = new YaraSharp.CContext())
|
||||
//...
|
||||
}
|
||||
}
|
||||
// Log errors
|
||||
// Log errorsìîæíî è òàê
|
||||
|
||||
}
|
||||
```
|
||||
For async scanning use **must** call destroy methods:
|
||||
|
||||
@@ -72,8 +72,10 @@ namespace YaraSharp
|
||||
{
|
||||
CScanner^ FScanner = gcnew CScanner(Rules, ExternalVariables);
|
||||
|
||||
if (!File::Exists(Path))
|
||||
throw gcnew FileNotFoundException(Path);
|
||||
// Ïðîâåðêà îòêëþ÷åíà, òàê êàê ñëèøêîì äëèííûå èìåíà ôàéëîâ èãíîðèðóþòñÿ
|
||||
// Ïðîâåðêà íà ñóùåñòâîâàíèå ñêàíèðóåìîãî ôàéëà íà âàñ
|
||||
//if (!File::Exists(Path))
|
||||
// throw gcnew FileNotFoundException(Path);
|
||||
|
||||
// Callback ñåêöèÿ
|
||||
List<CMatches^>^ Results = gcnew List<CMatches^>();
|
||||
|
||||
+4
-4
@@ -32,15 +32,15 @@ namespace YaraTest
|
||||
using (YaraSharp.CRules YSRules = YSInstance.CompileFromFiles(Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "..\\..\\signatures"), "*.yar", SearchOption.AllDirectories).ToList(), Externals, out Errors))
|
||||
{
|
||||
// Some file to test yara rules
|
||||
string Filename = "<some_file>";
|
||||
string Filename = @"\\?\<Filename>";
|
||||
|
||||
// Get matches
|
||||
List<YaraSharp.CMatches> Matches = YSInstance.ScanFile(Filename, YSRules,
|
||||
new Dictionary<string, object>()
|
||||
{
|
||||
{ "filename", System.IO.Path.GetFileName(Filename) },
|
||||
{ "filepath", System.IO.Path.GetFullPath(Filename) },
|
||||
{ "extension", System.IO.Path.GetExtension(Filename) }
|
||||
{ "filename", Alphaleonis.Win32.Filesystem.Path.GetFileName(Filename) },
|
||||
{ "filepath", Alphaleonis.Win32.Filesystem.Path.GetFullPath(Filename) },
|
||||
{ "extension", Alphaleonis.Win32.Filesystem.Path.GetExtension(Filename) }
|
||||
},
|
||||
0);
|
||||
|
||||
|
||||
@@ -34,8 +34,12 @@
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AlphaFS, Version=2.2.0.0, Culture=neutral, PublicKeyToken=4d31a58f7d7ad5c9, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AlphaFS.2.2.1\lib\net452\AlphaFS.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
@@ -52,6 +56,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AlphaFS" version="2.2.1" targetFramework="net461" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user